blob: 7311e3cfffb6b1b9613c342372bbf69cd4ec4845 [file] [log] [blame]
Jeff Thompson990599b2013-08-27 15:14:25 -07001/**
Jeff Thompson7687dc02013-09-13 11:54:07 -07002 * Copyright (C) 2013 Regents of the University of California.
3 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompson990599b2013-08-27 15:14:25 -07004 * See COPYING for copyright and distribution information.
5 */
Jeff Thompson7687dc02013-09-13 11:54:07 -07006
Jeff Thompson990599b2013-08-27 15:14:25 -07007#include <stdexcept>
8#include "common.hpp"
9#include "forwarding-entry.hpp"
10
11using namespace std;
12
13namespace ndn {
14
Jeff Thompson0050abe2013-09-17 12:50:25 -070015void
16ForwardingEntry::set(const struct ndn_ForwardingEntry& forwardingEntryStruct)
Jeff Thompson990599b2013-08-27 15:14:25 -070017{
18 if (forwardingEntryStruct.action && forwardingEntryStruct.actionLength > 0)
19 action_ = string(forwardingEntryStruct.action, forwardingEntryStruct.action + forwardingEntryStruct.actionLength);
20 else
21 action_ = "";
22
23 prefix_.set(forwardingEntryStruct.prefix);
24 publisherPublicKeyDigest_.set(forwardingEntryStruct.publisherPublicKeyDigest);
25 faceId_ = forwardingEntryStruct.faceId;
26 forwardingFlags_ = forwardingEntryStruct.forwardingFlags;
27 freshnessSeconds_ = forwardingEntryStruct.freshnessSeconds;
28}
29
Jeff Thompson0050abe2013-09-17 12:50:25 -070030void
31ForwardingEntry::get(struct ndn_ForwardingEntry& forwardingEntryStruct) const
Jeff Thompson990599b2013-08-27 15:14:25 -070032{
33 prefix_.get(forwardingEntryStruct.prefix);
34 publisherPublicKeyDigest_.get(forwardingEntryStruct.publisherPublicKeyDigest);
35 forwardingEntryStruct.faceId = faceId_;
36 forwardingEntryStruct.forwardingFlags = forwardingFlags_;
37 forwardingEntryStruct.freshnessSeconds = freshnessSeconds_;
38
39 forwardingEntryStruct.actionLength = action_.size();
40 if (action_.size() > 0)
41 forwardingEntryStruct.action = (unsigned char *)&action_[0];
42 else
43 forwardingEntryStruct.action = 0;
44}
45
46}