Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @author: Jeff Thompson |
| 3 | * See COPYING for copyright and distribution information. |
| 4 | */ |
| 5 | |
| 6 | #include "common.hpp" |
Jeff Thompson | 5341219 | 2013-08-06 13:35:50 -0700 | [diff] [blame] | 7 | #include "key.hpp" |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 8 | |
| 9 | using namespace std; |
| 10 | |
| 11 | namespace ndn { |
| 12 | |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame] | 13 | void KeyLocator::get(struct ndn_KeyLocator& keyLocatorStruct) const |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 14 | { |
| 15 | keyLocatorStruct.type = type_; |
| 16 | |
Jeff Thompson | 63d0269 | 2013-08-16 12:09:07 -0700 | [diff] [blame] | 17 | keyLocatorStruct.keyDataLength = keyData_.size(); |
| 18 | if (keyData_.size() > 0) |
Jeff Thompson | 4c9c045 | 2013-09-12 14:10:11 -0700 | [diff] [blame] | 19 | keyLocatorStruct.keyData = (unsigned char *)keyData_.buf(); |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 20 | else |
Jeff Thompson | 63d0269 | 2013-08-16 12:09:07 -0700 | [diff] [blame] | 21 | keyLocatorStruct.keyData = 0; |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 22 | |
Jeff Thompson | 7329a13 | 2013-08-16 15:57:37 -0700 | [diff] [blame] | 23 | keyName_.get(keyLocatorStruct.keyName); |
| 24 | keyLocatorStruct.keyNameType = keyNameType_; |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 25 | } |
| 26 | |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame] | 27 | void KeyLocator::set(const struct ndn_KeyLocator& keyLocatorStruct) |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 28 | { |
| 29 | type_ = keyLocatorStruct.type; |
Jeff Thompson | 4c9c045 | 2013-09-12 14:10:11 -0700 | [diff] [blame] | 30 | keyData_ = Blob(keyLocatorStruct.keyData, keyLocatorStruct.keyDataLength); |
Jeff Thompson | 7329a13 | 2013-08-16 15:57:37 -0700 | [diff] [blame] | 31 | if (keyLocatorStruct.type == ndn_KeyLocatorType_KEYNAME) { |
| 32 | keyName_.set(keyLocatorStruct.keyName); |
| 33 | keyNameType_ = keyLocatorStruct.keyNameType; |
| 34 | } |
| 35 | else { |
| 36 | keyName_.clear(); |
| 37 | keyNameType_ = (ndn_KeyNameType)-1; |
| 38 | } |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | } |
| 42 | |