Jeff Thompson | 47eecfc | 2013-07-07 22:56:46 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @author: Jeff Thompson |
| 3 | * See COPYING for copyright and distribution information. |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include "Interest.hpp" |
| 7 | |
| 8 | using namespace std; |
| 9 | |
| 10 | namespace ndn { |
| 11 | |
| 12 | void Interest::set(struct ndn_Interest &interestStruct) |
| 13 | { |
| 14 | name_.set(interestStruct.name); |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 15 | minSuffixComponents_ = interestStruct.minSuffixComponents; |
Jeff Thompson | f2e5e28 | 2013-07-08 15:26:16 -0700 | [diff] [blame] | 16 | maxSuffixComponents_ = interestStruct.maxSuffixComponents; |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 17 | |
| 18 | publisherPublicKeyDigest_.clear(); |
| 19 | if (interestStruct.publisherPublicKeyDigest) |
| 20 | publisherPublicKeyDigest_.insert |
| 21 | (publisherPublicKeyDigest_.begin(), interestStruct.publisherPublicKeyDigest, interestStruct.publisherPublicKeyDigest + interestStruct.publisherPublicKeyDigestLength); |
| 22 | // TODO: implement exclude |
| 23 | childSelector_ = interestStruct.childSelector; |
| 24 | answerOriginKind_ = interestStruct.answerOriginKind; |
| 25 | scope_ = interestStruct.scope; |
| 26 | interestLifetime_ = interestStruct.interestLifetime; |
| 27 | nonce_.clear(); |
| 28 | if (interestStruct.nonce) |
| 29 | nonce_.insert |
| 30 | (nonce_.begin(), interestStruct.nonce, interestStruct.nonce + interestStruct.nonceLength); |
| 31 | } |
Jeff Thompson | d9e278c | 2013-07-08 15:20:13 -0700 | [diff] [blame] | 32 | |
Jeff Thompson | d345a5b | 2013-07-08 16:18:23 -0700 | [diff] [blame^] | 33 | void Interest::get(struct ndn_Interest &interestStruct) const |
Jeff Thompson | d9e278c | 2013-07-08 15:20:13 -0700 | [diff] [blame] | 34 | { |
| 35 | name_.get(interestStruct.name); |
Jeff Thompson | d9e278c | 2013-07-08 15:20:13 -0700 | [diff] [blame] | 36 | interestStruct.minSuffixComponents = minSuffixComponents_; |
Jeff Thompson | f2e5e28 | 2013-07-08 15:26:16 -0700 | [diff] [blame] | 37 | interestStruct.maxSuffixComponents = maxSuffixComponents_; |
Jeff Thompson | d9e278c | 2013-07-08 15:20:13 -0700 | [diff] [blame] | 38 | |
| 39 | interestStruct.publisherPublicKeyDigestLength = publisherPublicKeyDigest_.size(); |
| 40 | if (publisherPublicKeyDigest_.size() > 0) |
Jeff Thompson | d345a5b | 2013-07-08 16:18:23 -0700 | [diff] [blame^] | 41 | interestStruct.publisherPublicKeyDigest = (unsigned char *)&publisherPublicKeyDigest_[0]; |
Jeff Thompson | d9e278c | 2013-07-08 15:20:13 -0700 | [diff] [blame] | 42 | else |
| 43 | interestStruct.publisherPublicKeyDigest = 0; |
| 44 | |
| 45 | // TODO: implement exclude. |
| 46 | |
| 47 | interestStruct.childSelector = childSelector_; |
| 48 | interestStruct.answerOriginKind = answerOriginKind_; |
| 49 | interestStruct.scope = scope_; |
| 50 | interestStruct.interestLifetime = interestLifetime_; |
| 51 | |
| 52 | interestStruct.nonceLength = nonce_.size(); |
| 53 | if (nonce_.size() > 0) |
Jeff Thompson | d345a5b | 2013-07-08 16:18:23 -0700 | [diff] [blame^] | 54 | interestStruct.nonce = (unsigned char *)&nonce_[0]; |
Jeff Thompson | d9e278c | 2013-07-08 15:20:13 -0700 | [diff] [blame] | 55 | else |
| 56 | interestStruct.nonce = 0; |
| 57 | } |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 58 | |
| 59 | } |
| 60 | |