Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame^] | 1 | /** |
| 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 | |
| 9 | using namespace std; |
| 10 | |
| 11 | namespace ndn { |
| 12 | |
| 13 | void 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 | |
| 27 | void 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 | } |