Jeff Thompson | 25b4e61 | 2013-10-10 16:03:24 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 2 | /** |
Jeff Thompson | 7687dc0 | 2013-09-13 11:54:07 -0700 | [diff] [blame] | 3 | * Copyright (C) 2013 Regents of the University of California. |
| 4 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 5 | * See COPYING for copyright and distribution information. |
| 6 | */ |
Jeff Thompson | 7687dc0 | 2013-09-13 11:54:07 -0700 | [diff] [blame] | 7 | |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 8 | #include <stdexcept> |
Jeff Thompson | 25b4e61 | 2013-10-10 16:03:24 -0700 | [diff] [blame] | 9 | #include <ndn-cpp/common.hpp> |
| 10 | #include <ndn-cpp/forwarding-entry.hpp> |
| 11 | #include "c/forwarding-entry.h" |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 12 | |
| 13 | using namespace std; |
| 14 | |
| 15 | namespace ndn { |
| 16 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 17 | void |
| 18 | ForwardingEntry::set(const struct ndn_ForwardingEntry& forwardingEntryStruct) |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 19 | { |
Jeff Thompson | 9303453 | 2013-10-08 11:52:43 -0700 | [diff] [blame] | 20 | if (forwardingEntryStruct.action.value && forwardingEntryStruct.action.length > 0) |
| 21 | action_ = string(forwardingEntryStruct.action.value, forwardingEntryStruct.action.value + forwardingEntryStruct.action.length); |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 22 | else |
| 23 | action_ = ""; |
| 24 | |
| 25 | prefix_.set(forwardingEntryStruct.prefix); |
| 26 | publisherPublicKeyDigest_.set(forwardingEntryStruct.publisherPublicKeyDigest); |
| 27 | faceId_ = forwardingEntryStruct.faceId; |
| 28 | forwardingFlags_ = forwardingEntryStruct.forwardingFlags; |
| 29 | freshnessSeconds_ = forwardingEntryStruct.freshnessSeconds; |
| 30 | } |
| 31 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 32 | void |
| 33 | ForwardingEntry::get(struct ndn_ForwardingEntry& forwardingEntryStruct) const |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 34 | { |
| 35 | prefix_.get(forwardingEntryStruct.prefix); |
| 36 | publisherPublicKeyDigest_.get(forwardingEntryStruct.publisherPublicKeyDigest); |
| 37 | forwardingEntryStruct.faceId = faceId_; |
| 38 | forwardingEntryStruct.forwardingFlags = forwardingFlags_; |
| 39 | forwardingEntryStruct.freshnessSeconds = freshnessSeconds_; |
| 40 | |
Jeff Thompson | 9303453 | 2013-10-08 11:52:43 -0700 | [diff] [blame] | 41 | forwardingEntryStruct.action.length = action_.size(); |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 42 | if (action_.size() > 0) |
Jeff Thompson | 9303453 | 2013-10-08 11:52:43 -0700 | [diff] [blame] | 43 | forwardingEntryStruct.action.value = (uint8_t *)&action_[0]; |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 44 | else |
Jeff Thompson | 9303453 | 2013-10-08 11:52:43 -0700 | [diff] [blame] | 45 | forwardingEntryStruct.action.value = 0; |
Jeff Thompson | 990599b | 2013-08-27 15:14:25 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | } |