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); |
| 15 | maxSuffixComponents_ = interestStruct.maxSuffixComponents; |
| 16 | minSuffixComponents_ = interestStruct.minSuffixComponents; |
| 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 | |
| 33 | void Interest::get(struct ndn_Interest &interestStruct) |
| 34 | { |
| 35 | name_.get(interestStruct.name); |
| 36 | interestStruct.maxSuffixComponents = maxSuffixComponents_; |
| 37 | interestStruct.minSuffixComponents = minSuffixComponents_; |
| 38 | |
| 39 | interestStruct.publisherPublicKeyDigestLength = publisherPublicKeyDigest_.size(); |
| 40 | if (publisherPublicKeyDigest_.size() > 0) |
| 41 | interestStruct.publisherPublicKeyDigest = &publisherPublicKeyDigest_[0]; |
| 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) |
| 54 | interestStruct.nonce = &nonce_[0]; |
| 55 | else |
| 56 | interestStruct.nonce = 0; |
| 57 | } |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 58 | |
| 59 | } |
| 60 | |