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