blob: 93c4d26049e685736b81e7cab2043919175a7560 [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{
Jeff Thompson93034532013-10-08 11:52:43 -070018 if (forwardingEntryStruct.action.value && forwardingEntryStruct.action.length > 0)
19 action_ = string(forwardingEntryStruct.action.value, forwardingEntryStruct.action.value + forwardingEntryStruct.action.length);
Jeff Thompson990599b2013-08-27 15:14:25 -070020 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
Jeff Thompson93034532013-10-08 11:52:43 -070039 forwardingEntryStruct.action.length = action_.size();
Jeff Thompson990599b2013-08-27 15:14:25 -070040 if (action_.size() > 0)
Jeff Thompson93034532013-10-08 11:52:43 -070041 forwardingEntryStruct.action.value = (uint8_t *)&action_[0];
Jeff Thompson990599b2013-08-27 15:14:25 -070042 else
Jeff Thompson93034532013-10-08 11:52:43 -070043 forwardingEntryStruct.action.value = 0;
Jeff Thompson990599b2013-08-27 15:14:25 -070044}
45
46}