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