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 | |
| 13 | void KeyLocator::get(struct ndn_KeyLocator &keyLocatorStruct) const |
| 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) |
| 19 | keyLocatorStruct.keyData = (unsigned char *)&keyData_[0]; |
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 | |
| 27 | void KeyLocator::set(const struct ndn_KeyLocator &keyLocatorStruct) |
| 28 | { |
| 29 | type_ = keyLocatorStruct.type; |
Jeff Thompson | 63d0269 | 2013-08-16 12:09:07 -0700 | [diff] [blame] | 30 | setVector(keyData_, 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 | |