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 | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 14 | void |
| 15 | KeyLocator::get(struct ndn_KeyLocator& keyLocatorStruct) const |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 16 | { |
| 17 | keyLocatorStruct.type = type_; |
| 18 | |
Jeff Thompson | 63d0269 | 2013-08-16 12:09:07 -0700 | [diff] [blame] | 19 | keyLocatorStruct.keyDataLength = keyData_.size(); |
| 20 | if (keyData_.size() > 0) |
Jeff Thompson | 4c9c045 | 2013-09-12 14:10:11 -0700 | [diff] [blame] | 21 | keyLocatorStruct.keyData = (unsigned char *)keyData_.buf(); |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 22 | else |
Jeff Thompson | 63d0269 | 2013-08-16 12:09:07 -0700 | [diff] [blame] | 23 | keyLocatorStruct.keyData = 0; |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 24 | |
Jeff Thompson | 7329a13 | 2013-08-16 15:57:37 -0700 | [diff] [blame] | 25 | keyName_.get(keyLocatorStruct.keyName); |
| 26 | keyLocatorStruct.keyNameType = keyNameType_; |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 27 | } |
| 28 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 29 | void |
| 30 | KeyLocator::set(const struct ndn_KeyLocator& keyLocatorStruct) |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 31 | { |
| 32 | type_ = keyLocatorStruct.type; |
Jeff Thompson | 4c9c045 | 2013-09-12 14:10:11 -0700 | [diff] [blame] | 33 | keyData_ = Blob(keyLocatorStruct.keyData, keyLocatorStruct.keyDataLength); |
Jeff Thompson | 7329a13 | 2013-08-16 15:57:37 -0700 | [diff] [blame] | 34 | if (keyLocatorStruct.type == ndn_KeyLocatorType_KEYNAME) { |
| 35 | keyName_.set(keyLocatorStruct.keyName); |
| 36 | keyNameType_ = keyLocatorStruct.keyNameType; |
| 37 | } |
| 38 | else { |
| 39 | keyName_.clear(); |
| 40 | keyNameType_ = (ndn_KeyNameType)-1; |
| 41 | } |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | } |
| 45 | |