Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 1 | /** |
Jeff Thompson | 7687dc0 | 2013-09-13 11:54:07 -0700 | [diff] [blame] | 2 | * Copyright (C) 2013 Regents of the University of California. |
| 3 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
Jeff Thompson | 7687dc0 | 2013-09-13 11:54:07 -0700 | [diff] [blame] | 6 | |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 7 | #include <stdexcept> |
| 8 | #include "common.hpp" |
| 9 | #include "forwarding-entry.hpp" |
| 10 | |
| 11 | using namespace std; |
| 12 | |
| 13 | namespace ndn { |
| 14 | |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame] | 15 | void ForwardingEntry::set(const struct ndn_ForwardingEntry& forwardingEntryStruct) |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 16 | { |
| 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 Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame] | 29 | void ForwardingEntry::get(struct ndn_ForwardingEntry& forwardingEntryStruct) const |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 30 | { |
| 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 | } |