blob: 1fa70757240bcd4fbe84640877acc8f466f01a5b [file] [log] [blame]
Jeff Thompson5cae5e52013-07-10 19:41:20 -07001/**
Jeff Thompson7687dc02013-09-13 11:54:07 -07002 * Copyright (C) 2013 Regents of the University of California.
3 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompson5cae5e52013-07-10 19:41:20 -07004 * See COPYING for copyright and distribution information.
5 */
6
7#include "common.hpp"
Jeff Thompson53412192013-08-06 13:35:50 -07008#include "key.hpp"
Jeff Thompson5cae5e52013-07-10 19:41:20 -07009
10using namespace std;
11
12namespace ndn {
13
Jeff Thompson1656e6a2013-08-29 18:01:48 -070014void KeyLocator::get(struct ndn_KeyLocator& keyLocatorStruct) const
Jeff Thompson5cae5e52013-07-10 19:41:20 -070015{
16 keyLocatorStruct.type = type_;
17
Jeff Thompson63d02692013-08-16 12:09:07 -070018 keyLocatorStruct.keyDataLength = keyData_.size();
19 if (keyData_.size() > 0)
Jeff Thompson4c9c0452013-09-12 14:10:11 -070020 keyLocatorStruct.keyData = (unsigned char *)keyData_.buf();
Jeff Thompson5cae5e52013-07-10 19:41:20 -070021 else
Jeff Thompson63d02692013-08-16 12:09:07 -070022 keyLocatorStruct.keyData = 0;
Jeff Thompson5cae5e52013-07-10 19:41:20 -070023
Jeff Thompson7329a132013-08-16 15:57:37 -070024 keyName_.get(keyLocatorStruct.keyName);
25 keyLocatorStruct.keyNameType = keyNameType_;
Jeff Thompson5cae5e52013-07-10 19:41:20 -070026}
27
Jeff Thompson1656e6a2013-08-29 18:01:48 -070028void KeyLocator::set(const struct ndn_KeyLocator& keyLocatorStruct)
Jeff Thompson5cae5e52013-07-10 19:41:20 -070029{
30 type_ = keyLocatorStruct.type;
Jeff Thompson4c9c0452013-09-12 14:10:11 -070031 keyData_ = Blob(keyLocatorStruct.keyData, keyLocatorStruct.keyDataLength);
Jeff Thompson7329a132013-08-16 15:57:37 -070032 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 Thompson5cae5e52013-07-10 19:41:20 -070040}
41
42}
43