blob: 116a5425c07fefb59b8b631dc28fc823e57ac66b [file] [log] [blame]
Jeff Thompson990599b2013-08-27 15:14:25 -07001/**
2 * @author: Jeff Thompson
3 * See COPYING for copyright and distribution information.
4 */
5#include <stdexcept>
6#include "common.hpp"
7#include "forwarding-entry.hpp"
8
9using namespace std;
10
11namespace ndn {
12
Jeff Thompson1656e6a2013-08-29 18:01:48 -070013void ForwardingEntry::set(const struct ndn_ForwardingEntry& forwardingEntryStruct)
Jeff Thompson990599b2013-08-27 15:14:25 -070014{
15 if (forwardingEntryStruct.action && forwardingEntryStruct.actionLength > 0)
16 action_ = string(forwardingEntryStruct.action, forwardingEntryStruct.action + forwardingEntryStruct.actionLength);
17 else
18 action_ = "";
19
20 prefix_.set(forwardingEntryStruct.prefix);
21 publisherPublicKeyDigest_.set(forwardingEntryStruct.publisherPublicKeyDigest);
22 faceId_ = forwardingEntryStruct.faceId;
23 forwardingFlags_ = forwardingEntryStruct.forwardingFlags;
24 freshnessSeconds_ = forwardingEntryStruct.freshnessSeconds;
25}
26
Jeff Thompson1656e6a2013-08-29 18:01:48 -070027void ForwardingEntry::get(struct ndn_ForwardingEntry& forwardingEntryStruct) const
Jeff Thompson990599b2013-08-27 15:14:25 -070028{
29 prefix_.get(forwardingEntryStruct.prefix);
30 publisherPublicKeyDigest_.get(forwardingEntryStruct.publisherPublicKeyDigest);
31 forwardingEntryStruct.faceId = faceId_;
32 forwardingEntryStruct.forwardingFlags = forwardingFlags_;
33 forwardingEntryStruct.freshnessSeconds = freshnessSeconds_;
34
35 forwardingEntryStruct.actionLength = action_.size();
36 if (action_.size() > 0)
37 forwardingEntryStruct.action = (unsigned char *)&action_[0];
38 else
39 forwardingEntryStruct.action = 0;
40}
41
42}