blob: 452d39b3820f09c0bf3f4b2cdef581770e784183 [file] [log] [blame]
Jeff Thompson25b4e612013-10-10 16:03:24 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Jeff Thompson990599b2013-08-27 15:14:25 -07002/**
Jeff Thompson7687dc02013-09-13 11:54:07 -07003 * Copyright (C) 2013 Regents of the University of California.
4 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompson990599b2013-08-27 15:14:25 -07005 * See COPYING for copyright and distribution information.
6 */
Jeff Thompson7687dc02013-09-13 11:54:07 -07007
Jeff Thompson990599b2013-08-27 15:14:25 -07008#include <stdexcept>
Jeff Thompson25b4e612013-10-10 16:03:24 -07009#include <ndn-cpp/common.hpp>
10#include <ndn-cpp/forwarding-entry.hpp>
11#include "c/forwarding-entry.h"
Jeff Thompson990599b2013-08-27 15:14:25 -070012
13using namespace std;
14
15namespace ndn {
16
Jeff Thompson0050abe2013-09-17 12:50:25 -070017void
18ForwardingEntry::set(const struct ndn_ForwardingEntry& forwardingEntryStruct)
Jeff Thompson990599b2013-08-27 15:14:25 -070019{
Jeff Thompson93034532013-10-08 11:52:43 -070020 if (forwardingEntryStruct.action.value && forwardingEntryStruct.action.length > 0)
21 action_ = string(forwardingEntryStruct.action.value, forwardingEntryStruct.action.value + forwardingEntryStruct.action.length);
Jeff Thompson990599b2013-08-27 15:14:25 -070022 else
23 action_ = "";
24
25 prefix_.set(forwardingEntryStruct.prefix);
26 publisherPublicKeyDigest_.set(forwardingEntryStruct.publisherPublicKeyDigest);
27 faceId_ = forwardingEntryStruct.faceId;
28 forwardingFlags_ = forwardingEntryStruct.forwardingFlags;
29 freshnessSeconds_ = forwardingEntryStruct.freshnessSeconds;
30}
31
Jeff Thompson0050abe2013-09-17 12:50:25 -070032void
33ForwardingEntry::get(struct ndn_ForwardingEntry& forwardingEntryStruct) const
Jeff Thompson990599b2013-08-27 15:14:25 -070034{
35 prefix_.get(forwardingEntryStruct.prefix);
36 publisherPublicKeyDigest_.get(forwardingEntryStruct.publisherPublicKeyDigest);
37 forwardingEntryStruct.faceId = faceId_;
38 forwardingEntryStruct.forwardingFlags = forwardingFlags_;
39 forwardingEntryStruct.freshnessSeconds = freshnessSeconds_;
40
Jeff Thompson93034532013-10-08 11:52:43 -070041 forwardingEntryStruct.action.length = action_.size();
Jeff Thompson990599b2013-08-27 15:14:25 -070042 if (action_.size() > 0)
Jeff Thompson93034532013-10-08 11:52:43 -070043 forwardingEntryStruct.action.value = (uint8_t *)&action_[0];
Jeff Thompson990599b2013-08-27 15:14:25 -070044 else
Jeff Thompson93034532013-10-08 11:52:43 -070045 forwardingEntryStruct.action.value = 0;
Jeff Thompson990599b2013-08-27 15:14:25 -070046}
47
48}