forwarding-entry.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
22 #ifndef NDN_FORWARDING_ENTRY_HPP
23 #define NDN_FORWARDING_ENTRY_HPP
24 
25 #include <math.h>
26 #include <string>
27 #include "name.hpp"
28 #include "publisher-public-key-digest.hpp"
29 #include "forwarding-flags.hpp"
30 #include "encoding/wire-format.hpp"
31 
32 struct ndn_ForwardingEntry;
33 
34 namespace ndn {
35 
42 public:
44  (const std::string& action, const Name& prefix, const PublisherPublicKeyDigest publisherPublicKeyDigest,
45  int faceId, const ForwardingFlags& forwardingFlags, Milliseconds freshnessPeriod);
46 
48 
49  Blob
50  wireEncode(WireFormat& wireFormat = *WireFormat::getDefaultWireFormat()) const
51  {
52  return wireFormat.encodeForwardingEntry(*this);
53  }
54 
55  void
56  wireDecode(const uint8_t *input, size_t inputLength, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat())
57  {
58  wireFormat.decodeForwardingEntry(*this, input, inputLength);
59  }
60 
61  void
62  wireDecode(const std::vector<uint8_t>& input, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat())
63  {
64  wireDecode(&input[0], input.size(), wireFormat);
65  }
66 
72  void
73  get(struct ndn_ForwardingEntry& forwardingEntryStruct) const;
74 
75  const std::string&
76  getAction() const { return action_; }
77 
78  Name&
79  getPrefix() { return prefix_; }
80 
81  const Name&
82  getPrefix() const { return prefix_; }
83 
85  getPublisherPublicKeyDigest() { return publisherPublicKeyDigest_; }
86 
88  getPublisherPublicKeyDigest() const { return publisherPublicKeyDigest_; }
89 
90  int
91  getFaceId() const { return faceId_; }
92 
93  const ForwardingFlags&
94  getForwardingFlags() const { return forwardingFlags_; }
95 
97  getFreshnessPeriod() const { return freshnessPeriod_; }
98 
102  int
103  DEPRECATED_IN_NDN_CPP getFreshnessSeconds() const
104  {
105  return freshnessPeriod_ < 0 ? -1 : (int)round(freshnessPeriod_ / 1000.0);
106  }
107 
112  void
113  set(const struct ndn_ForwardingEntry& forwardingEntryStruct);
114 
115  void
116  setAction(const std::string& action) { action_ = action; }
117 
118  void
119  setFaceId(int faceId) { faceId_ = faceId; }
120 
121  void
122  setForwardingFlags(const ForwardingFlags& forwardingFlags) { forwardingFlags_ = forwardingFlags; }
123 
124  void
125  setFreshnessPeriod(Milliseconds freshnessPeriod)
126  {
127  freshnessPeriod_ = freshnessPeriod;
128  }
129 
133  void
134  DEPRECATED_IN_NDN_CPP setFreshnessSeconds(int freshnessSeconds)
135  {
136  setFreshnessPeriod(freshnessSeconds < 0 ? -1.0 : (double)freshnessSeconds * 1000.0);
137  }
138 
139 private:
140  std::string action_;
141  Name prefix_;
142  PublisherPublicKeyDigest publisherPublicKeyDigest_;
143  int faceId_;
144  ForwardingFlags forwardingFlags_;
145  Milliseconds freshnessPeriod_;
146 };
147 
148 }
149 
150 #endif
int faceId
-1 for none.
Definition: forwarding-entry.h:52
double Milliseconds
A time interval represented as the number of milliseconds.
Definition: common.hpp:111
Copyright (C) 2013-2015 Regents of the University of California.
Definition: common.hpp:35
An ndn_ForwardingEntry holds fields for a ForwardingEntry which is used to register a prefix with a h...
Definition: forwarding-entry.h:48
A ForwardingEntry holds an action and Name prefix and other fields for a forwarding entry...
Definition: forwarding-entry.hpp:41
ndn_Milliseconds freshnessPeriod
-1 for none.
Definition: forwarding-entry.h:54
A ForwardingFlags object holds the flags which specify how the forwarding daemon should forward an in...
Definition: forwarding-flags.hpp:34
A PublisherPublicKeyDigest holds the publisher public key digest value, if any.
Definition: publisher-public-key-digest.hpp:37
struct ndn_Blob action
A Blob whose value is a pointer to a pre-allocated buffer.
Definition: forwarding-entry.h:49
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:42
A Blob holds a pointer to an immutable byte array implemented as const std::vector.
Definition: blob.hpp:42
void set(const struct ndn_ForwardingEntry &forwardingEntryStruct)
Clear this forwarding entry, and set the values by copying from forwardingEntryStruct.
Definition: forwarding-entry.cpp:54
static WireFormat * getDefaultWireFormat()
Return the default WireFormat used by default encoding and decoding methods which was set with setDef...
Definition: wire-format.cpp:36
Definition: wire-format.hpp:37
void DEPRECATED_IN_NDN_CPP setFreshnessSeconds(int freshnessSeconds)
Definition: forwarding-entry.hpp:134
int DEPRECATED_IN_NDN_CPP getFreshnessSeconds() const
Definition: forwarding-entry.hpp:103