blob: bbd687710286c1c083047fc326f624a788e3211a [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
Jeff Thompson1656e6a2013-08-29 18:01:48 -070013void KeyLocator::get(struct ndn_KeyLocator& keyLocatorStruct) const
Jeff Thompson5cae5e52013-07-10 19:41:20 -070014{
15 keyLocatorStruct.type = type_;
16
Jeff Thompson63d02692013-08-16 12:09:07 -070017 keyLocatorStruct.keyDataLength = keyData_.size();
18 if (keyData_.size() > 0)
Jeff Thompson4c9c0452013-09-12 14:10:11 -070019 keyLocatorStruct.keyData = (unsigned char *)keyData_.buf();
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
Jeff Thompson1656e6a2013-08-29 18:01:48 -070027void KeyLocator::set(const struct ndn_KeyLocator& keyLocatorStruct)
Jeff Thompson5cae5e52013-07-10 19:41:20 -070028{
29 type_ = keyLocatorStruct.type;
Jeff Thompson4c9c0452013-09-12 14:10:11 -070030 keyData_ = Blob(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