Jeff Thompson | 25b4e61 | 2013-10-10 16:03:24 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Jeff Thompson | 47eecfc | 2013-07-07 22:56:46 -0700 | [diff] [blame] | 2 | /** |
Jeff Thompson | 7687dc0 | 2013-09-13 11:54:07 -0700 | [diff] [blame] | 3 | * Copyright (C) 2013 Regents of the University of California. |
| 4 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
Jeff Thompson | 47eecfc | 2013-07-07 22:56:46 -0700 | [diff] [blame] | 5 | * See COPYING for copyright and distribution information. |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #ifndef NDN_INTEREST_HPP |
Jeff Thompson | 2d27e2f | 2013-08-09 12:55:00 -0700 | [diff] [blame] | 9 | #define NDN_INTEREST_HPP |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 10 | |
Jeff Thompson | 5341219 | 2013-08-06 13:35:50 -0700 | [diff] [blame] | 11 | #include "name.hpp" |
| 12 | #include "publisher-public-key-digest.hpp" |
Jeff Thompson | 25b4e61 | 2013-10-10 16:03:24 -0700 | [diff] [blame] | 13 | #include "c/interest-types.h" |
| 14 | #include "encoding/wire-format.hpp" |
| 15 | |
| 16 | struct ndn_ExcludeEntry; |
| 17 | struct ndn_Exclude; |
| 18 | struct ndn_Interest; |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 19 | |
| 20 | namespace ndn { |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 21 | |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 22 | /** |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 23 | * An Exclude holds a vector of ExcludeEntry. |
| 24 | */ |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 25 | class Exclude { |
| 26 | public: |
| 27 | /** |
| 28 | * Create a new Exclude with no entries. |
| 29 | */ |
| 30 | Exclude() { |
| 31 | } |
Jeff Thompson | f62f9f2 | 2013-11-26 17:22:54 -0800 | [diff] [blame^] | 32 | |
| 33 | /** |
| 34 | * An Exclude::Entry holds an ndn_ExcludeType, and if it is a COMPONENT, it holds the component value. |
| 35 | */ |
| 36 | class Entry { |
| 37 | public: |
| 38 | /** |
| 39 | * Create an Exclude::Entry of type ndn_Exclude_ANY |
| 40 | */ |
| 41 | Entry() |
| 42 | : type_(ndn_Exclude_ANY) |
| 43 | { |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Create an Exclude::Entry of type ndn_Exclude_COMPONENT. |
| 48 | */ |
| 49 | Entry(uint8_t *component, size_t componentLen) |
| 50 | : type_(ndn_Exclude_COMPONENT), component_(component, componentLen) |
| 51 | { |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Create an Exclude::Entry of type ndn_Exclude_COMPONENT. |
| 56 | */ |
| 57 | Entry(const Blob& component) |
| 58 | : type_(ndn_Exclude_COMPONENT), component_(component) |
| 59 | { |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Set the type in the excludeEntryStruct and to point to this entry, without copying any memory. |
| 64 | * WARNING: The resulting pointer in excludeEntryStruct is invalid after a further use of this object which could reallocate memory. |
| 65 | * @param excludeEntryStruct the C ndn_ExcludeEntry struct to receive the pointer |
| 66 | */ |
| 67 | void |
| 68 | get(struct ndn_ExcludeEntry& excludeEntryStruct) const; |
| 69 | |
| 70 | ndn_ExcludeType getType() const { return type_; } |
| 71 | |
| 72 | const Name::Component& getComponent() const { return component_; } |
| 73 | |
| 74 | private: |
| 75 | ndn_ExcludeType type_; |
| 76 | Name::Component component_; /**< only used if type_ is ndn_Exclude_COMPONENT */ |
| 77 | }; |
| 78 | |
| 79 | /** |
| 80 | * Get the number of entries. |
| 81 | * @return The number of entries. |
| 82 | */ |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 83 | size_t |
Jeff Thompson | f62f9f2 | 2013-11-26 17:22:54 -0800 | [diff] [blame^] | 84 | size() const { return entries_.size(); } |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 85 | |
Jeff Thompson | f62f9f2 | 2013-11-26 17:22:54 -0800 | [diff] [blame^] | 86 | /** |
| 87 | * Get the entry at the given index. |
| 88 | * @param i The index of the entry, starting from 0. |
| 89 | * @return The entry at the index. |
| 90 | */ |
| 91 | const Exclude::Entry& |
| 92 | get(size_t i) const { return entries_[i]; } |
| 93 | |
| 94 | /** |
| 95 | * @deprecated Use size(). |
| 96 | */ |
| 97 | size_t |
| 98 | getEntryCount() const { return entries_.size(); } |
| 99 | |
| 100 | /** |
| 101 | * @deprecated Use get(i). |
| 102 | */ |
| 103 | const Exclude::Entry& |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 104 | getEntry(size_t i) const { return entries_[i]; } |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 105 | |
| 106 | /** |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 107 | * Set the excludeStruct to point to the entries in this Exclude, without copying any memory. |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 108 | * WARNING: The resulting pointers in excludeStruct are invalid after a further use of this object which could reallocate memory. |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 109 | * @param excludeStruct a C ndn_Exclude struct where the entries array is already allocated |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 110 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 111 | void |
| 112 | get(struct ndn_Exclude& excludeStruct) const; |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 113 | |
| 114 | /** |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 115 | * Clear this Exclude, and set the entries by copying from the ndn_Exclude struct. |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 116 | * @param excludeStruct a C ndn_Exclude struct |
| 117 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 118 | void |
| 119 | set(const struct ndn_Exclude& excludeStruct); |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 120 | |
| 121 | /** |
Jeff Thompson | 832d297 | 2013-10-31 11:24:55 -0700 | [diff] [blame] | 122 | * Append a new entry of type ndn_Exclude_ANY. |
| 123 | * @return This Exclude so that you can chain calls to append. |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 124 | */ |
Jeff Thompson | 832d297 | 2013-10-31 11:24:55 -0700 | [diff] [blame] | 125 | Exclude& |
| 126 | appendAny() |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 127 | { |
Jeff Thompson | f62f9f2 | 2013-11-26 17:22:54 -0800 | [diff] [blame^] | 128 | entries_.push_back(Entry()); |
Jeff Thompson | 832d297 | 2013-10-31 11:24:55 -0700 | [diff] [blame] | 129 | return *this; |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | /** |
Jeff Thompson | b096e49 | 2013-10-31 11:29:28 -0700 | [diff] [blame] | 133 | * Append a new entry of type ndn_Exclude_COMPONENT, copying from component of length componentLength. |
Jeff Thompson | 832d297 | 2013-10-31 11:24:55 -0700 | [diff] [blame] | 134 | * @param component A pointer to the component byte array. |
| 135 | * @param componentLength The length of component. |
| 136 | * @return This Exclude so that you can chain calls to append. |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 137 | */ |
Jeff Thompson | 832d297 | 2013-10-31 11:24:55 -0700 | [diff] [blame] | 138 | Exclude& |
| 139 | appendComponent(uint8_t *component, size_t componentLength) |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 140 | { |
Jeff Thompson | f62f9f2 | 2013-11-26 17:22:54 -0800 | [diff] [blame^] | 141 | entries_.push_back(Entry(component, componentLength)); |
Jeff Thompson | 832d297 | 2013-10-31 11:24:55 -0700 | [diff] [blame] | 142 | return *this; |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 143 | } |
Jeff Thompson | 832d297 | 2013-10-31 11:24:55 -0700 | [diff] [blame] | 144 | |
| 145 | /** |
Jeff Thompson | b096e49 | 2013-10-31 11:29:28 -0700 | [diff] [blame] | 146 | * Append a new entry of type ndn_Exclude_COMPONENT, taking another pointer to the Blob value. |
Jeff Thompson | 832d297 | 2013-10-31 11:24:55 -0700 | [diff] [blame] | 147 | * @param component A blob with a pointer to an immutable array. The pointer is copied. |
| 148 | * @return This Exclude so that you can chain calls to append. |
| 149 | */ |
| 150 | Exclude& |
| 151 | appendComponent(const Blob &component) |
| 152 | { |
Jeff Thompson | f62f9f2 | 2013-11-26 17:22:54 -0800 | [diff] [blame^] | 153 | entries_.push_back(Entry(component)); |
Jeff Thompson | 832d297 | 2013-10-31 11:24:55 -0700 | [diff] [blame] | 154 | return *this; |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * @deprecated Use appendAny. |
| 159 | */ |
| 160 | Exclude& |
| 161 | addAny() { return appendAny(); } |
| 162 | |
| 163 | /** |
| 164 | * @deprecated Use appendComponent. |
| 165 | */ |
| 166 | Exclude& |
| 167 | addComponent(uint8_t *component, size_t componentLength) { return appendComponent(component, componentLength); } |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 168 | |
| 169 | /** |
| 170 | * Clear all the entries. |
| 171 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 172 | void |
Jeff Thompson | f62f9f2 | 2013-11-26 17:22:54 -0800 | [diff] [blame^] | 173 | clear() |
| 174 | { |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 175 | entries_.clear(); |
| 176 | } |
| 177 | |
Jeff Thompson | 37527d6 | 2013-08-21 11:15:54 -0700 | [diff] [blame] | 178 | /** |
| 179 | * Encode this Exclude with elements separated by "," and ndn_Exclude_ANY shown as "*". |
| 180 | * @return the URI string |
| 181 | */ |
| 182 | std::string toUri() const; |
| 183 | |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 184 | private: |
Jeff Thompson | f62f9f2 | 2013-11-26 17:22:54 -0800 | [diff] [blame^] | 185 | std::vector<Entry> entries_; |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 186 | }; |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 187 | |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 188 | /** |
| 189 | * An Interest holds a Name and other fields for an interest. |
| 190 | */ |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 191 | class Interest { |
| 192 | public: |
Jeff Thompson | 1b4a7b1 | 2013-11-15 12:00:02 -0800 | [diff] [blame] | 193 | /** |
| 194 | * Create a new Interest for the given name and values. |
| 195 | * @param name |
| 196 | * @param minSuffixComponents |
| 197 | * @param maxSuffixComponents |
| 198 | * @param publisherPublicKeyDigest |
| 199 | * @param exclude |
| 200 | * @param childSelector |
| 201 | * @param answerOriginKind |
| 202 | * @param scope |
| 203 | * @param interestLifetimeMilliseconds |
| 204 | * @param nonce |
| 205 | */ |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame] | 206 | Interest(const Name& name, int minSuffixComponents, int maxSuffixComponents, |
| 207 | const PublisherPublicKeyDigest& publisherPublicKeyDigest, const Exclude& exclude, int childSelector, int answerOriginKind, |
Jeff Thompson | 83bf07e | 2013-11-19 11:46:18 -0800 | [diff] [blame] | 208 | int scope, Milliseconds interestLifetimeMilliseconds, const Blob& nonce) |
Jeff Thompson | f59a87a | 2013-07-31 16:55:41 -0700 | [diff] [blame] | 209 | : name_(name), minSuffixComponents_(minSuffixComponents), maxSuffixComponents_(maxSuffixComponents), |
| 210 | publisherPublicKeyDigest_(publisherPublicKeyDigest), exclude_(exclude), childSelector_(childSelector), |
| 211 | answerOriginKind_(answerOriginKind), scope_(scope), interestLifetimeMilliseconds_(interestLifetimeMilliseconds), |
| 212 | nonce_(nonce) |
| 213 | { |
| 214 | } |
Jeff Thompson | 3f76e9e | 2013-08-21 13:14:58 -0700 | [diff] [blame] | 215 | |
Jeff Thompson | 1b4a7b1 | 2013-11-15 12:00:02 -0800 | [diff] [blame] | 216 | /** |
| 217 | * Create a new Interest with the given name and values, and "none" for the nonce. |
| 218 | * @param name |
| 219 | * @param minSuffixComponents |
| 220 | * @param maxSuffixComponents |
| 221 | * @param publisherPublicKeyDigest |
| 222 | * @param exclude |
| 223 | * @param childSelector |
| 224 | * @param answerOriginKind |
| 225 | * @param scope |
| 226 | * @param interestLifetimeMilliseconds |
| 227 | */ |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame] | 228 | Interest(const Name& name, int minSuffixComponents, int maxSuffixComponents, |
| 229 | const PublisherPublicKeyDigest& publisherPublicKeyDigest, const Exclude& exclude, int childSelector, int answerOriginKind, |
Jeff Thompson | 9a8e82f | 2013-10-17 14:13:43 -0700 | [diff] [blame] | 230 | int scope, Milliseconds interestLifetimeMilliseconds) |
Jeff Thompson | 3f76e9e | 2013-08-21 13:14:58 -0700 | [diff] [blame] | 231 | : name_(name), minSuffixComponents_(minSuffixComponents), maxSuffixComponents_(maxSuffixComponents), |
| 232 | publisherPublicKeyDigest_(publisherPublicKeyDigest), exclude_(exclude), childSelector_(childSelector), |
| 233 | answerOriginKind_(answerOriginKind), scope_(scope), interestLifetimeMilliseconds_(interestLifetimeMilliseconds) |
| 234 | { |
| 235 | } |
| 236 | |
Jeff Thompson | 1b4a7b1 | 2013-11-15 12:00:02 -0800 | [diff] [blame] | 237 | /** |
| 238 | * Create a new Interest with the given name and interest lifetime and "none" for other values. |
| 239 | * @param name The name for the interest. |
| 240 | * @param interestLifetimeMilliseconds The interest lifetime in milliseconds, or -1 for none. |
| 241 | */ |
Jeff Thompson | 9a8e82f | 2013-10-17 14:13:43 -0700 | [diff] [blame] | 242 | Interest(const Name& name, Milliseconds interestLifetimeMilliseconds) |
Jeff Thompson | f62382a | 2013-08-21 16:33:39 -0700 | [diff] [blame] | 243 | : name_(name) |
| 244 | { |
| 245 | construct(); |
| 246 | interestLifetimeMilliseconds_ = interestLifetimeMilliseconds; |
| 247 | } |
| 248 | |
Jeff Thompson | 1b4a7b1 | 2013-11-15 12:00:02 -0800 | [diff] [blame] | 249 | /** |
| 250 | * Create a new Interest with the given name and "none" for other values. |
| 251 | * @param name The name for the interest. |
| 252 | */ |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame] | 253 | Interest(const Name& name) |
Jeff Thompson | 3f76e9e | 2013-08-21 13:14:58 -0700 | [diff] [blame] | 254 | : name_(name) |
| 255 | { |
Jeff Thompson | 3f76e9e | 2013-08-21 13:14:58 -0700 | [diff] [blame] | 256 | construct(); |
| 257 | } |
| 258 | |
Jeff Thompson | 1b4a7b1 | 2013-11-15 12:00:02 -0800 | [diff] [blame] | 259 | /** |
| 260 | * Create a new Interest with an empty name and "none" for all values. |
| 261 | */ |
Jeff Thompson | 3f76e9e | 2013-08-21 13:14:58 -0700 | [diff] [blame] | 262 | Interest() |
| 263 | { |
| 264 | construct(); |
| 265 | } |
Jeff Thompson | f59a87a | 2013-07-31 16:55:41 -0700 | [diff] [blame] | 266 | |
Jeff Thompson | 1b4a7b1 | 2013-11-15 12:00:02 -0800 | [diff] [blame] | 267 | /** |
| 268 | * Encode this Interest for a particular wire format. |
| 269 | * @param wireFormat A WireFormat object used to decode the input. If omitted, use WireFormat::getDefaultWireFormat(). |
| 270 | * @return The encoded byte array. |
| 271 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 272 | Blob |
| 273 | wireEncode(WireFormat& wireFormat = *WireFormat::getDefaultWireFormat()) const |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 274 | { |
Jeff Thompson | b0979fd | 2013-07-30 15:48:21 -0700 | [diff] [blame] | 275 | return wireFormat.encodeInterest(*this); |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 276 | } |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 277 | |
Jeff Thompson | 1b4a7b1 | 2013-11-15 12:00:02 -0800 | [diff] [blame] | 278 | /** |
| 279 | * Decode the input using a particular wire format and update this Interest. |
| 280 | * @param input The input byte array to be decoded. |
| 281 | * @param inputLength The length of input. |
| 282 | * @param wireFormat A WireFormat object used to decode the input. If omitted, use WireFormat::getDefaultWireFormat(). |
| 283 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 284 | void |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 285 | wireDecode(const uint8_t *input, size_t inputLength, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat()) |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 286 | { |
| 287 | wireFormat.decodeInterest(*this, input, inputLength); |
| 288 | } |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 289 | |
Jeff Thompson | 1b4a7b1 | 2013-11-15 12:00:02 -0800 | [diff] [blame] | 290 | /** |
| 291 | * Decode the input using a particular wire format and update this Interest. |
| 292 | * @param input The input byte array to be decoded. |
| 293 | * @param wireFormat A WireFormat object used to decode the input. If omitted, use WireFormat::getDefaultWireFormat(). |
| 294 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 295 | void |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame] | 296 | wireDecode(const std::vector<uint8_t>& input, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat()) |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 297 | { |
Jeff Thompson | 67e9e0a | 2013-08-02 19:16:19 -0700 | [diff] [blame] | 298 | wireDecode(&input[0], input.size(), wireFormat); |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 299 | } |
Jeff Thompson | d9e278c | 2013-07-08 15:20:13 -0700 | [diff] [blame] | 300 | |
| 301 | /** |
| 302 | * Set the interestStruct to point to the components in this interest, without copying any memory. |
| 303 | * WARNING: The resulting pointers in interestStruct are invalid after a further use of this object which could reallocate memory. |
| 304 | * @param interestStruct a C ndn_Interest struct where the name components array is already allocated. |
| 305 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 306 | void |
| 307 | get(struct ndn_Interest& interestStruct) const; |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 308 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 309 | Name& |
| 310 | getName() { return name_; } |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 311 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 312 | const Name& |
| 313 | getName() const { return name_; } |
Jeff Thompson | d345a5b | 2013-07-08 16:18:23 -0700 | [diff] [blame] | 314 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 315 | int |
| 316 | getMinSuffixComponents() const { return minSuffixComponents_; } |
Jeff Thompson | 0a68172 | 2013-07-08 16:21:54 -0700 | [diff] [blame] | 317 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 318 | int |
| 319 | getMaxSuffixComponents() const { return maxSuffixComponents_; } |
Jeff Thompson | 0a68172 | 2013-07-08 16:21:54 -0700 | [diff] [blame] | 320 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 321 | PublisherPublicKeyDigest& |
| 322 | getPublisherPublicKeyDigest() { return publisherPublicKeyDigest_; } |
| 323 | |
| 324 | const PublisherPublicKeyDigest& |
| 325 | getPublisherPublicKeyDigest() const { return publisherPublicKeyDigest_; } |
Jeff Thompson | 0a68172 | 2013-07-08 16:21:54 -0700 | [diff] [blame] | 326 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 327 | Exclude& |
| 328 | getExclude() { return exclude_; } |
| 329 | |
| 330 | const Exclude& |
| 331 | getExclude() const { return exclude_; } |
| 332 | |
| 333 | int |
| 334 | getChildSelector() const { return childSelector_; } |
Jeff Thompson | 0a68172 | 2013-07-08 16:21:54 -0700 | [diff] [blame] | 335 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 336 | int |
| 337 | getAnswerOriginKind() const { return answerOriginKind_; } |
Jeff Thompson | d345a5b | 2013-07-08 16:18:23 -0700 | [diff] [blame] | 338 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 339 | int |
| 340 | getScope() const { return scope_; } |
Jeff Thompson | 0a68172 | 2013-07-08 16:21:54 -0700 | [diff] [blame] | 341 | |
Jeff Thompson | 9a8e82f | 2013-10-17 14:13:43 -0700 | [diff] [blame] | 342 | Milliseconds |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 343 | getInterestLifetimeMilliseconds() const { return interestLifetimeMilliseconds_; } |
| 344 | |
| 345 | const Blob& |
| 346 | getNonce() const { return nonce_; } |
Jeff Thompson | 2255290 | 2013-07-07 21:26:20 -0700 | [diff] [blame] | 347 | |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 348 | /** |
| 349 | * Clear this interest, and set the values by copying from the interest struct. |
| 350 | * @param interestStruct a C ndn_Interest struct |
| 351 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 352 | void |
| 353 | set(const struct ndn_Interest& interestStruct); |
Jeff Thompson | eb316a8 | 2013-07-09 15:11:17 -0700 | [diff] [blame] | 354 | |
Jeff Thompson | 4b70d3d | 2013-10-21 17:34:34 -0700 | [diff] [blame] | 355 | void |
| 356 | setName(const Name& name) { name_ = name; } |
| 357 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 358 | void |
Jeff Thompson | 83bf07e | 2013-11-19 11:46:18 -0800 | [diff] [blame] | 359 | setMinSuffixComponents(int minSuffixComponents) { minSuffixComponents_ = minSuffixComponents; } |
Jeff Thompson | eb316a8 | 2013-07-09 15:11:17 -0700 | [diff] [blame] | 360 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 361 | void |
Jeff Thompson | 83bf07e | 2013-11-19 11:46:18 -0800 | [diff] [blame] | 362 | setMaxSuffixComponents(int maxSuffixComponents) { maxSuffixComponents_ = maxSuffixComponents; } |
Jeff Thompson | eb316a8 | 2013-07-09 15:11:17 -0700 | [diff] [blame] | 363 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 364 | void |
Jeff Thompson | 83bf07e | 2013-11-19 11:46:18 -0800 | [diff] [blame] | 365 | setChildSelector(int childSelector) { childSelector_ = childSelector; } |
Jeff Thompson | eb316a8 | 2013-07-09 15:11:17 -0700 | [diff] [blame] | 366 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 367 | void |
Jeff Thompson | 83bf07e | 2013-11-19 11:46:18 -0800 | [diff] [blame] | 368 | setAnswerOriginKind(int answerOriginKind) { answerOriginKind_ = answerOriginKind; } |
Jeff Thompson | eb316a8 | 2013-07-09 15:11:17 -0700 | [diff] [blame] | 369 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 370 | void |
Jeff Thompson | 83bf07e | 2013-11-19 11:46:18 -0800 | [diff] [blame] | 371 | setScope(int scope) { scope_ = scope; } |
Jeff Thompson | eb316a8 | 2013-07-09 15:11:17 -0700 | [diff] [blame] | 372 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 373 | void |
Jeff Thompson | 83bf07e | 2013-11-19 11:46:18 -0800 | [diff] [blame] | 374 | setInterestLifetimeMilliseconds(Milliseconds interestLifetimeMilliseconds) { interestLifetimeMilliseconds_ = interestLifetimeMilliseconds; } |
Jeff Thompson | eb316a8 | 2013-07-09 15:11:17 -0700 | [diff] [blame] | 375 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 376 | void |
Jeff Thompson | 83bf07e | 2013-11-19 11:46:18 -0800 | [diff] [blame] | 377 | setNonce(const Blob& nonce) { nonce_ = nonce; } |
Jeff Thompson | eb316a8 | 2013-07-09 15:11:17 -0700 | [diff] [blame] | 378 | |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 379 | private: |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 380 | void |
| 381 | construct() |
Jeff Thompson | c0486c1 | 2013-07-16 14:36:16 -0700 | [diff] [blame] | 382 | { |
Jeff Thompson | 2d27e2f | 2013-08-09 12:55:00 -0700 | [diff] [blame] | 383 | minSuffixComponents_ = -1; |
| 384 | maxSuffixComponents_ = -1; |
| 385 | childSelector_ = -1; |
| 386 | answerOriginKind_ = -1; |
| 387 | scope_ = -1; |
| 388 | interestLifetimeMilliseconds_ = -1.0; |
Jeff Thompson | c0486c1 | 2013-07-16 14:36:16 -0700 | [diff] [blame] | 389 | } |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 390 | |
| 391 | Name name_; |
Jeff Thompson | 2d27e2f | 2013-08-09 12:55:00 -0700 | [diff] [blame] | 392 | int minSuffixComponents_; |
| 393 | int maxSuffixComponents_; |
| 394 | PublisherPublicKeyDigest publisherPublicKeyDigest_; |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 395 | Exclude exclude_; |
Jeff Thompson | 2d27e2f | 2013-08-09 12:55:00 -0700 | [diff] [blame] | 396 | int childSelector_; |
| 397 | int answerOriginKind_; |
| 398 | int scope_; |
Jeff Thompson | 9a8e82f | 2013-10-17 14:13:43 -0700 | [diff] [blame] | 399 | Milliseconds interestLifetimeMilliseconds_; |
Jeff Thompson | 412226d | 2013-09-12 15:55:46 -0700 | [diff] [blame] | 400 | Blob nonce_; |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 401 | }; |
| 402 | |
| 403 | } |
| 404 | |
| 405 | #endif |