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