blob: 7548968dae43f5a87d0cddf95a3826b2a8079322 [file] [log] [blame]
Jeff Thompson5cae5e52013-07-10 19:41:20 -07001/**
2 * @author: Jeff Thompson
3 * See COPYING for copyright and distribution information.
4 */
5
6#include "common.hpp"
Jeff Thompson53412192013-08-06 13:35:50 -07007#include "key.hpp"
Jeff Thompson5cae5e52013-07-10 19:41:20 -07008
9using namespace std;
10
11namespace ndn {
12
13void KeyLocator::get(struct ndn_KeyLocator &keyLocatorStruct) const
14{
15 keyLocatorStruct.type = type_;
16
Jeff Thompson63d02692013-08-16 12:09:07 -070017 keyLocatorStruct.keyDataLength = keyData_.size();
18 if (keyData_.size() > 0)
19 keyLocatorStruct.keyData = (unsigned char *)&keyData_[0];
Jeff Thompson5cae5e52013-07-10 19:41:20 -070020 else
Jeff Thompson63d02692013-08-16 12:09:07 -070021 keyLocatorStruct.keyData = 0;
Jeff Thompson5cae5e52013-07-10 19:41:20 -070022
Jeff Thompson7329a132013-08-16 15:57:37 -070023 keyName_.get(keyLocatorStruct.keyName);
24 keyLocatorStruct.keyNameType = keyNameType_;
Jeff Thompson5cae5e52013-07-10 19:41:20 -070025}
26
27void KeyLocator::set(const struct ndn_KeyLocator &keyLocatorStruct)
28{
29 type_ = keyLocatorStruct.type;
Jeff Thompson63d02692013-08-16 12:09:07 -070030 setVector(keyData_, keyLocatorStruct.keyData, keyLocatorStruct.keyDataLength);
Jeff Thompson7329a132013-08-16 15:57:37 -070031 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 Thompson5cae5e52013-07-10 19:41:20 -070039}
40
41}
42