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