blob: 0e8c6d7ed1a41b57bc057a07e1ebbb981497d6c7 [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
13void ForwardingEntry::set(const struct ndn_ForwardingEntry &forwardingEntryStruct)
14{
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
27void ForwardingEntry::get(struct ndn_ForwardingEntry &forwardingEntryStruct) const
28{
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}