Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2013 Regents of the University of California. |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 7 | #ifndef NDN_MANAGEMENT_NDND_FACE_INSTANCE_HPP |
| 8 | #define NDN_MANAGEMENT_NDND_FACE_INSTANCE_HPP |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 9 | |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 10 | #include "../encoding/tlv-ndnd.hpp" |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 11 | #include "../encoding/block.hpp" |
| 12 | #include "../name.hpp" |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 13 | |
| 14 | namespace ndn { |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 15 | namespace ndnd { |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 16 | |
| 17 | /** |
| 18 | * An FaceInstance holds an action and Name prefix and other fields for an forwarding entry. |
| 19 | */ |
| 20 | class FaceInstance { |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 21 | public: |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 22 | FaceInstance(const std::string& action, |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 23 | int64_t faceId, |
| 24 | uint32_t ipProto, |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 25 | const std::string& host, |
| 26 | const std::string& port, |
| 27 | const std::string& multicastInterface, |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 28 | uint32_t multicastTtl, |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 29 | const time::milliseconds& freshnessPeriod) |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 30 | : action_(action) |
| 31 | , faceId_(faceId) |
| 32 | , ipProto_(ipProto) |
| 33 | , host_(host) |
| 34 | , port_(port) |
| 35 | , multicastInterface_(multicastInterface) |
| 36 | , multicastTtl_(multicastTtl) |
| 37 | , freshnessPeriod_(freshnessPeriod) |
| 38 | { |
| 39 | } |
| 40 | |
| 41 | FaceInstance() |
| 42 | : faceId_(-1) |
| 43 | , ipProto_(-1) |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 44 | , multicastTtl_(-1) |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 45 | , freshnessPeriod_(time::milliseconds::min()) |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 46 | { |
| 47 | } |
| 48 | |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 49 | /** |
| 50 | * @brief Create from wire encoding |
| 51 | */ |
| 52 | explicit |
| 53 | FaceInstance(const Block& wire) |
| 54 | { |
| 55 | wireDecode(wire); |
| 56 | } |
| 57 | |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 58 | // Action |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 59 | const std::string& |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 60 | getAction() const { return action_; } |
| 61 | |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 62 | void |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 63 | setAction(const std::string& action) { action_ = action; wire_.reset(); } |
| 64 | |
| 65 | // FaceID |
| 66 | int64_t |
| 67 | getFaceId() const { return faceId_; } |
| 68 | |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 69 | void |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 70 | setFaceId(int64_t faceId) { faceId_ = faceId; wire_.reset(); } |
| 71 | |
| 72 | // IPProto |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 73 | int32_t |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 74 | getIpProto() const { return ipProto_; } |
| 75 | |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 76 | void |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 77 | setIpProto(int32_t ipProto) { ipProto_ = ipProto; wire_.reset(); } |
| 78 | |
| 79 | // Host |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 80 | const std::string& |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 81 | getHost() const { return host_; } |
| 82 | |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 83 | void |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 84 | setHost(const std::string& host) { host_ = host; wire_.reset(); } |
| 85 | |
| 86 | // Port |
Alexander Afanasyev | 0a5eabf | 2014-01-02 09:03:25 -0800 | [diff] [blame] | 87 | const std::string& |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 88 | getPort() const { return port_; } |
| 89 | |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 90 | void |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 91 | setPort(const std::string& port) { port_ = port; wire_.reset(); } |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 92 | |
| 93 | // MulticastInterface |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 94 | const std::string& |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 95 | getMulticastInterface() const { return multicastInterface_; } |
| 96 | |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 97 | void |
| 98 | setMulticastInterface(const std::string& multicastInterface) |
| 99 | { |
| 100 | multicastInterface_ = multicastInterface; wire_.reset(); |
| 101 | } |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 102 | |
| 103 | // MulticastTTL |
| 104 | int32_t |
| 105 | getMulticastTtl() const { return multicastTtl_; } |
| 106 | |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 107 | void |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 108 | setMulticastTtl(int32_t multicastTtl) { multicastTtl_ = multicastTtl; wire_.reset(); } |
| 109 | |
| 110 | // Freshness |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 111 | const time::milliseconds& |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 112 | getFreshnessPeriod() const { return freshnessPeriod_; } |
| 113 | |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 114 | void |
| 115 | setFreshnessPeriod(const time::milliseconds& freshnessPeriod) |
| 116 | { |
| 117 | freshnessPeriod_ = freshnessPeriod; wire_.reset(); |
| 118 | } |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 119 | |
| 120 | // Wire |
| 121 | inline const Block& |
| 122 | wireEncode() const; |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 123 | |
| 124 | inline void |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 125 | wireDecode(const Block& wire); |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 126 | |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 127 | private: |
| 128 | std::string action_; |
| 129 | int64_t faceId_; |
| 130 | int32_t ipProto_; |
| 131 | std::string host_; |
Alexander Afanasyev | 0a5eabf | 2014-01-02 09:03:25 -0800 | [diff] [blame] | 132 | std::string port_; |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 133 | std::string multicastInterface_; |
| 134 | int32_t multicastTtl_; |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 135 | time::milliseconds freshnessPeriod_; |
| 136 | |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 137 | mutable Block wire_; |
| 138 | }; |
| 139 | |
| 140 | inline const Block& |
| 141 | FaceInstance::wireEncode() const |
| 142 | { |
| 143 | if (wire_.hasWire()) |
| 144 | return wire_; |
| 145 | |
| 146 | // FaceInstance ::= FACE-INSTANCE-TYPE TLV-LENGTH |
| 147 | // Action? |
| 148 | // FaceID? |
| 149 | // IPProto? |
| 150 | // Host? |
| 151 | // Port? |
| 152 | // MulticastInterface? |
| 153 | // MulticastTTL? |
| 154 | // FreshnessPeriod? |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 155 | |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 156 | wire_ = Block(tlv::ndnd::FaceInstance); |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 157 | |
| 158 | // Action |
| 159 | if (!action_.empty()) |
| 160 | { |
| 161 | wire_.push_back |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 162 | (dataBlock(tlv::ndnd::Action, action_.c_str(), action_.size())); |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | // FaceID |
| 166 | if (faceId_ >= 0) |
| 167 | { |
| 168 | wire_.push_back |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 169 | (nonNegativeIntegerBlock(tlv::ndnd::FaceID, faceId_)); |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | // IPProto |
| 173 | if (ipProto_ >= 0) |
| 174 | { |
| 175 | wire_.push_back |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 176 | (nonNegativeIntegerBlock(tlv::ndnd::IPProto, ipProto_)); |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 177 | } |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 178 | |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 179 | // Host |
| 180 | if (!host_.empty()) |
| 181 | { |
| 182 | wire_.push_back |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 183 | (dataBlock(tlv::ndnd::Host, host_.c_str(), host_.size())); |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | // Port |
Alexander Afanasyev | 0a5eabf | 2014-01-02 09:03:25 -0800 | [diff] [blame] | 187 | if (!port_.empty()) |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 188 | { |
| 189 | wire_.push_back |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 190 | (dataBlock(tlv::ndnd::Port, port_.c_str(), port_.size())); |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | // MulticastInterface |
| 194 | if (!multicastInterface_.empty()) |
| 195 | { |
| 196 | wire_.push_back |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 197 | (dataBlock(tlv::ndnd::MulticastInterface, multicastInterface_.c_str(), multicastInterface_.size())); |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | // MulticastTTL |
| 201 | if (multicastTtl_ >= 0) |
| 202 | { |
| 203 | wire_.push_back |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 204 | (nonNegativeIntegerBlock(tlv::ndnd::MulticastTTL, multicastTtl_)); |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | // FreshnessPeriod |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 208 | if (freshnessPeriod_ >= time::milliseconds::zero()) |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 209 | { |
| 210 | wire_.push_back |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 211 | (nonNegativeIntegerBlock(Tlv::FreshnessPeriod, freshnessPeriod_.count())); |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 212 | } |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 213 | |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 214 | wire_.encode(); |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 215 | return wire_; |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 216 | } |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 217 | |
| 218 | inline void |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 219 | FaceInstance::wireDecode(const Block& wire) |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 220 | { |
| 221 | action_.clear(); |
| 222 | faceId_ = -1; |
| 223 | ipProto_ = -1; |
| 224 | host_.clear(); |
Alexander Afanasyev | 0a5eabf | 2014-01-02 09:03:25 -0800 | [diff] [blame] | 225 | port_.clear(); |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 226 | multicastInterface_.clear(); |
| 227 | multicastTtl_ = -1; |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 228 | freshnessPeriod_ = time::milliseconds::min(); |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 229 | |
| 230 | wire_ = wire; |
| 231 | wire_.parse(); |
| 232 | |
| 233 | // FaceInstance ::= FACE-INSTANCE-TYPE TLV-LENGTH |
| 234 | // Action? |
| 235 | // FaceID? |
| 236 | // IPProto? |
| 237 | // Host? |
| 238 | // Port? |
| 239 | // MulticastInterface? |
| 240 | // MulticastTTL? |
| 241 | // FreshnessPeriod? |
| 242 | |
| 243 | // Action |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 244 | Block::element_const_iterator val = wire_.find(tlv::ndnd::Action); |
Alexander Afanasyev | 29e5c3d | 2014-02-11 00:01:10 -0800 | [diff] [blame] | 245 | if (val != wire_.elements_end()) |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 246 | { |
| 247 | action_ = std::string(reinterpret_cast<const char*>(val->value()), val->value_size()); |
| 248 | } |
| 249 | |
| 250 | // FaceID |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 251 | val = wire_.find(tlv::ndnd::FaceID); |
Alexander Afanasyev | 29e5c3d | 2014-02-11 00:01:10 -0800 | [diff] [blame] | 252 | if (val != wire_.elements_end()) |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 253 | { |
| 254 | faceId_ = readNonNegativeInteger(*val); |
| 255 | } |
| 256 | |
| 257 | // IPProto |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 258 | val = wire_.find(tlv::ndnd::IPProto); |
Alexander Afanasyev | 29e5c3d | 2014-02-11 00:01:10 -0800 | [diff] [blame] | 259 | if (val != wire_.elements_end()) |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 260 | { |
| 261 | ipProto_ = readNonNegativeInteger(*val); |
| 262 | } |
| 263 | |
| 264 | // Host |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 265 | val = wire_.find(tlv::ndnd::Host); |
Alexander Afanasyev | 29e5c3d | 2014-02-11 00:01:10 -0800 | [diff] [blame] | 266 | if (val != wire_.elements_end()) |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 267 | { |
| 268 | host_ = std::string(reinterpret_cast<const char*>(val->value()), val->value_size()); |
| 269 | } |
| 270 | |
| 271 | // Port |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 272 | val = wire_.find(tlv::ndnd::Port); |
Alexander Afanasyev | 29e5c3d | 2014-02-11 00:01:10 -0800 | [diff] [blame] | 273 | if (val != wire_.elements_end()) |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 274 | { |
Alexander Afanasyev | 0a5eabf | 2014-01-02 09:03:25 -0800 | [diff] [blame] | 275 | port_ = std::string(reinterpret_cast<const char*>(val->value()), val->value_size()); |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | // MulticastInterface |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 279 | val = wire_.find(tlv::ndnd::MulticastInterface); |
Alexander Afanasyev | 29e5c3d | 2014-02-11 00:01:10 -0800 | [diff] [blame] | 280 | if (val != wire_.elements_end()) |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 281 | { |
| 282 | multicastInterface_ = std::string(reinterpret_cast<const char*>(val->value()), val->value_size()); |
| 283 | } |
| 284 | |
| 285 | // MulticastTTL |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 286 | val = wire_.find(tlv::ndnd::MulticastTTL); |
Alexander Afanasyev | 29e5c3d | 2014-02-11 00:01:10 -0800 | [diff] [blame] | 287 | if (val != wire_.elements_end()) |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 288 | { |
| 289 | multicastTtl_ = readNonNegativeInteger(*val); |
| 290 | } |
| 291 | |
| 292 | // FreshnessPeriod |
| 293 | val = wire_.find(Tlv::FreshnessPeriod); |
Alexander Afanasyev | 29e5c3d | 2014-02-11 00:01:10 -0800 | [diff] [blame] | 294 | if (val != wire_.elements_end()) |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 295 | { |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 296 | freshnessPeriod_ = time::milliseconds(readNonNegativeInteger(*val)); |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 297 | } |
| 298 | } |
| 299 | |
| 300 | inline std::ostream& |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 301 | operator << (std::ostream& os, const FaceInstance& entry) |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 302 | { |
| 303 | os << "FaceInstance("; |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 304 | |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 305 | // Action |
| 306 | if (!entry.getAction().empty()) |
| 307 | { |
| 308 | os << "Action:" << entry.getAction() << ", "; |
| 309 | } |
| 310 | |
| 311 | // FaceID |
| 312 | if (entry.getFaceId() >= 0) |
| 313 | { |
| 314 | os << "FaceID:" << entry.getFaceId() << ", "; |
| 315 | } |
| 316 | |
| 317 | // IPProto |
| 318 | if (entry.getIpProto() >= 0) |
| 319 | { |
| 320 | os << "IPProto:" << entry.getIpProto() << ", "; |
| 321 | } |
| 322 | |
| 323 | // Host |
| 324 | if (!entry.getHost().empty()) |
| 325 | { |
| 326 | os << "Host:" << entry.getHost() << ", "; |
| 327 | } |
| 328 | |
| 329 | // Port |
Alexander Afanasyev | 0a5eabf | 2014-01-02 09:03:25 -0800 | [diff] [blame] | 330 | if (!entry.getPort().empty()) |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 331 | { |
| 332 | os << "Port:" << entry.getPort() << ", "; |
| 333 | } |
| 334 | |
| 335 | // MulticastInterface |
| 336 | if (!entry.getMulticastInterface().empty()) |
| 337 | { |
| 338 | os << "MulticastInterface:" << entry.getMulticastInterface() << ", "; |
| 339 | } |
| 340 | |
| 341 | // MulticastTTL |
| 342 | if (entry.getMulticastTtl() >= 0) |
| 343 | { |
| 344 | os << "MulticastTTL:" << entry.getMulticastTtl() << ", "; |
| 345 | } |
| 346 | |
| 347 | // FreshnessPeriod |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 348 | if (entry.getFreshnessPeriod() >= time::milliseconds::zero()) |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 349 | { |
| 350 | os << "FreshnessPeriod:" << entry.getFreshnessPeriod() << ", "; |
| 351 | } |
| 352 | |
| 353 | os << ")"; |
| 354 | return os; |
| 355 | } |
| 356 | |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 357 | } // namespace ndnd |
| 358 | } // namespace ndn |
Alexander Afanasyev | 5d7db8e | 2014-01-05 22:43:57 -0800 | [diff] [blame] | 359 | |
Alexander Afanasyev | c8823bc | 2014-02-09 19:33:33 -0800 | [diff] [blame] | 360 | #endif // NDN_MANAGEMENT_NDND_FACE_INSTANCE_HPP |