blob: fad1e191e57fe125f475f5f592e6dc7ba3c9940a [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 Thompson1656e6a2013-08-29 18:01:48 -070015void ForwardingEntry::set(const struct ndn_ForwardingEntry& forwardingEntryStruct)
Jeff Thompson990599b2013-08-27 15:14:25 -070016{
17 if (forwardingEntryStruct.action && forwardingEntryStruct.actionLength > 0)
18 action_ = string(forwardingEntryStruct.action, forwardingEntryStruct.action + forwardingEntryStruct.actionLength);
19 else
20 action_ = "";
21
22 prefix_.set(forwardingEntryStruct.prefix);
23 publisherPublicKeyDigest_.set(forwardingEntryStruct.publisherPublicKeyDigest);
24 faceId_ = forwardingEntryStruct.faceId;
25 forwardingFlags_ = forwardingEntryStruct.forwardingFlags;
26 freshnessSeconds_ = forwardingEntryStruct.freshnessSeconds;
27}
28
Jeff Thompson1656e6a2013-08-29 18:01:48 -070029void ForwardingEntry::get(struct ndn_ForwardingEntry& forwardingEntryStruct) const
Jeff Thompson990599b2013-08-27 15:14:25 -070030{
31 prefix_.get(forwardingEntryStruct.prefix);
32 publisherPublicKeyDigest_.get(forwardingEntryStruct.publisherPublicKeyDigest);
33 forwardingEntryStruct.faceId = faceId_;
34 forwardingEntryStruct.forwardingFlags = forwardingFlags_;
35 forwardingEntryStruct.freshnessSeconds = freshnessSeconds_;
36
37 forwardingEntryStruct.actionLength = action_.size();
38 if (action_.size() > 0)
39 forwardingEntryStruct.action = (unsigned char *)&action_[0];
40 else
41 forwardingEntryStruct.action = 0;
42}
43
44}