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 | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame^] | 15 | void |
| 16 | ForwardingEntry::set(const struct ndn_ForwardingEntry& forwardingEntryStruct) |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 17 | { |
| 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 Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame^] | 30 | void |
| 31 | ForwardingEntry::get(struct ndn_ForwardingEntry& forwardingEntryStruct) const |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 32 | { |
| 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 | } |