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