blob: ef5726531b97a966a2da3860c58270a63140f6b3 [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 Thompson0050abe2013-09-17 12:50:25 -070014void
15KeyLocator::get(struct ndn_KeyLocator& keyLocatorStruct) const
Jeff Thompson5cae5e52013-07-10 19:41:20 -070016{
17 keyLocatorStruct.type = type_;
18
Jeff Thompson63d02692013-08-16 12:09:07 -070019 keyLocatorStruct.keyDataLength = keyData_.size();
20 if (keyData_.size() > 0)
Jeff Thompson10ad12a2013-09-24 16:19:11 -070021 keyLocatorStruct.keyData = (uint8_t *)keyData_.buf();
Jeff Thompson5cae5e52013-07-10 19:41:20 -070022 else
Jeff Thompson63d02692013-08-16 12:09:07 -070023 keyLocatorStruct.keyData = 0;
Jeff Thompson5cae5e52013-07-10 19:41:20 -070024
Jeff Thompson7329a132013-08-16 15:57:37 -070025 keyName_.get(keyLocatorStruct.keyName);
26 keyLocatorStruct.keyNameType = keyNameType_;
Jeff Thompson5cae5e52013-07-10 19:41:20 -070027}
28
Jeff Thompson0050abe2013-09-17 12:50:25 -070029void
30KeyLocator::set(const struct ndn_KeyLocator& keyLocatorStruct)
Jeff Thompson5cae5e52013-07-10 19:41:20 -070031{
32 type_ = keyLocatorStruct.type;
Jeff Thompson4c9c0452013-09-12 14:10:11 -070033 keyData_ = Blob(keyLocatorStruct.keyData, keyLocatorStruct.keyDataLength);
Jeff Thompson7329a132013-08-16 15:57:37 -070034 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 Thompson5cae5e52013-07-10 19:41:20 -070042}
43
44}
45