OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * This program is free software; you can redistribute it and/or modify | 3 * This program is free software; you can redistribute it and/or modify |
4 * it under the terms of the GNU General Public License version 2 as | 4 * it under the terms of the GNU General Public License version 2 as |
5 * published by the Free Software Foundation; | 5 * published by the Free Software Foundation; |
6 * | 6 * |
7 * This program is distributed in the hope that it will be useful, | 7 * This program is distributed in the hope that it will be useful, |
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 * GNU General Public License for more details. | 10 * GNU General Public License for more details. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 tx_packets (0), | 127 tx_packets (0), |
128 rx_bytes (0), | 128 rx_bytes (0), |
129 tx_bytes (0), | 129 tx_bytes (0), |
130 tx_dropped (0), | 130 tx_dropped (0), |
131 mpls_ttl0_dropped (0) | 131 mpls_ttl0_dropped (0) |
132 { | 132 { |
133 } | 133 } |
134 | 134 |
135 uint32_t config; ///< Some subset of OFPPC_* flags. | 135 uint32_t config; ///< Some subset of OFPPC_* flags. |
136 uint32_t state; ///< Some subset of OFPPS_* flags. | 136 uint32_t state; ///< Some subset of OFPPS_* flags. |
137 Ptr<NetDevice> netdev; | 137 Ptr<NetDevice> netdev; ///< net device |
138 unsigned long long int rx_packets, tx_packets; | 138 unsigned long long int rx_packets; ///< receive packets |
139 unsigned long long int rx_bytes, tx_bytes; | 139 unsigned long long int tx_packets; ///< transmit packets |
140 unsigned long long int tx_dropped; | 140 unsigned long long int rx_bytes; ///< reeive bytes |
141 unsigned long long int mpls_ttl0_dropped; | 141 unsigned long long int tx_bytes; ///< transmit bytes |
| 142 unsigned long long int tx_dropped; ///< transmit dropped |
| 143 unsigned long long int mpls_ttl0_dropped; ///< MPLS TTL dropped |
142 }; | 144 }; |
143 | 145 |
| 146 /// Stats class |
144 class Stats | 147 class Stats |
145 { | 148 { |
146 public: | 149 public: |
| 150 /** |
| 151 * Constructor |
| 152 * |
| 153 * \param _type OFP type |
| 154 * \param body_len length |
| 155 */ |
147 Stats (ofp_stats_types _type, size_t body_len); | 156 Stats (ofp_stats_types _type, size_t body_len); |
148 | 157 |
149 /** | 158 /** |
150 * \brief Prepares to dump some kind of statistics on the connected OpenFlowSw
itchNetDevice. | 159 * \brief Prepares to dump some kind of statistics on the connected OpenFlowSw
itchNetDevice. |
151 * | 160 * |
152 * \param body Body member of the struct ofp_stats_request. | 161 * \param body Body member of the struct ofp_stats_request. |
153 * \param body_len Length of the body member. | 162 * \param body_len Length of the body member. |
154 * \param state State information. | 163 * \param state State information. |
155 * \return 0 if successful, otherwise a negative error code. | 164 * \return 0 if successful, otherwise a negative error code. |
156 */ | 165 */ |
(...skipping 16 matching lines...) Expand all Loading... |
173 * | 182 * |
174 * \param state State information to clear. | 183 * \param state State information to clear. |
175 */ | 184 */ |
176 void DoCleanup (void *state); | 185 void DoCleanup (void *state); |
177 | 186 |
178 /** | 187 /** |
179 * \brief State of the FlowStats request/reply. | 188 * \brief State of the FlowStats request/reply. |
180 */ | 189 */ |
181 struct FlowStatsState | 190 struct FlowStatsState |
182 { | 191 { |
183 int table_idx; | 192 int table_idx; ///< table index |
184 sw_table_position position; | 193 sw_table_position position; ///< table position |
185 ofp_flow_stats_request rq; | 194 ofp_flow_stats_request rq; ///< fow stats request |
186 time_t now; | 195 time_t now; ///< now time |
187 | 196 |
188 ofpbuf *buffer; | 197 ofpbuf *buffer; ///< output buffer |
189 }; | 198 }; |
190 | 199 |
191 /** | 200 /** |
192 * \brief State of the PortStats request/reply. | 201 * \brief State of the PortStats request/reply. |
193 */ | 202 */ |
194 struct PortStatsState | 203 struct PortStatsState |
195 { | 204 { |
196 uint32_t num_ports; ///< Number of ports in host byte order | 205 uint32_t num_ports; ///< Number of ports in host byte order |
197 uint32_t *ports; ///< Array of ports in network byte order | 206 uint32_t *ports; ///< Array of ports in network byte order |
198 }; | 207 }; |
199 | 208 |
200 ofp_stats_types type; | 209 ofp_stats_types type; ///< stats type |
201 private: | 210 private: |
| 211 /** |
| 212 * dump description stats function |
| 213 * \param state the state |
| 214 * \param buffer the OFP buffer |
| 215 * \returns 0 |
| 216 */ |
202 int DescStatsDump (void *state, ofpbuf *buffer); | 217 int DescStatsDump (void *state, ofpbuf *buffer); |
203 | 218 |
| 219 /** |
| 220 * initialize flow stats function |
| 221 * \param body the flow stats request |
| 222 * \param body_len (unused) |
| 223 * \param state the initialized state |
| 224 * \returns 0 |
| 225 */ |
204 int FlowStatsInit (const void *body, int body_len, void **state); | 226 int FlowStatsInit (const void *body, int body_len, void **state); |
| 227 /** |
| 228 * flow dump callback function |
| 229 * \param flow the flow |
| 230 * \param state the current state· |
| 231 * \returns the buffer size |
| 232 */ |
205 int (*FlowDumpCallback)(sw_flow *flow, void *state); | 233 int (*FlowDumpCallback)(sw_flow *flow, void *state); |
| 234 /** |
| 235 * dump flow stats function |
| 236 * \param dp the device |
| 237 * \param s the flow stats state |
| 238 * \param buffer the buffer |
| 239 * \returns the buffer size |
| 240 */ |
206 int FlowStatsDump (Ptr<OpenFlowSwitchNetDevice> dp, FlowStatsState *s, ofpbuf
*buffer); | 241 int FlowStatsDump (Ptr<OpenFlowSwitchNetDevice> dp, FlowStatsState *s, ofpbuf
*buffer); |
207 | 242 |
| 243 /** |
| 244 * init aggregate status function |
| 245 * \param body the aggregate stats request |
| 246 * \param body_len (unused) |
| 247 * \param state the current state |
| 248 * \returns 0 |
208 int AggregateStatsInit (const void *body, int body_len, void **state); | 249 int AggregateStatsInit (const void *body, int body_len, void **state); |
| 250 /** |
| 251 * aggregate dump callback |
| 252 * \param flow the flow |
| 253 * \param state the current state· |
| 254 * \returns the buffer size |
| 255 */ |
209 int (*AggregateDumpCallback)(sw_flow *flow, void *state); | 256 int (*AggregateDumpCallback)(sw_flow *flow, void *state); |
| 257 /** |
| 258 * dump aggregate stats function |
| 259 * \param dp the device |
| 260 * \param s the aggregate stats state |
| 261 * \param buffer the buffer |
| 262 * \returns the buffer size |
| 263 */ |
210 int AggregateStatsDump (Ptr<OpenFlowSwitchNetDevice> dp, ofp_aggregate_stats_r
equest *s, ofpbuf *buffer); | 264 int AggregateStatsDump (Ptr<OpenFlowSwitchNetDevice> dp, ofp_aggregate_stats_r
equest *s, ofpbuf *buffer); |
211 | 265 |
| 266 /** |
| 267 * dump table stats function |
| 268 * \param dp the device |
| 269 * \param state the table stats state |
| 270 * \param buffer the buffer |
| 271 * \returns the buffer size |
| 272 */ |
212 int TableStatsDump (Ptr<OpenFlowSwitchNetDevice> dp, void *state, ofpbuf *buff
er); | 273 int TableStatsDump (Ptr<OpenFlowSwitchNetDevice> dp, void *state, ofpbuf *buff
er); |
213 | 274 |
| 275 /** |
| 276 * initialize port stats function |
| 277 * \param body the aggregate stats request |
| 278 * \param body_len (unused) |
| 279 * \param state the current state |
| 280 * \returns 0 |
| 281 */ |
214 int PortStatsInit (const void *body, int body_len, void **state); | 282 int PortStatsInit (const void *body, int body_len, void **state); |
| 283 /** |
| 284 * dump port stats function |
| 285 * \param dp the device |
| 286 * \param s the port stats state |
| 287 * \param buffer the buffer |
| 288 * \returns the buffer size |
| 289 */ |
215 int PortStatsDump (Ptr<OpenFlowSwitchNetDevice> dp, PortStatsState *s, ofpbuf
*buffer); | 290 int PortStatsDump (Ptr<OpenFlowSwitchNetDevice> dp, PortStatsState *s, ofpbuf
*buffer); |
216 | 291 |
| 292 /** |
| 293 * dump port table stats function |
| 294 * \param dp the device |
| 295 * \param state the port table stats state |
| 296 * \param buffer the buffer |
| 297 * \returns the buffer size |
| 298 */ |
217 int PortTableStatsDump (Ptr<OpenFlowSwitchNetDevice> dp, void *state, ofpbuf *
buffer); | 299 int PortTableStatsDump (Ptr<OpenFlowSwitchNetDevice> dp, void *state, ofpbuf *
buffer); |
218 }; | 300 }; |
219 | 301 |
220 /** | 302 /** |
221 * \brief Class for handling flow table actions. | 303 * \brief Class for handling flow table actions. |
222 */ | 304 */ |
223 struct Action | 305 struct Action |
224 { | 306 { |
225 /** | 307 /** |
226 * \param type Type of Flow Table Action. | 308 * \param type Type of Flow Table Action. |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 | 499 |
418 /** | 500 /** |
419 * Get the packet type on the buffer, which can then be used | 501 * Get the packet type on the buffer, which can then be used |
420 * to determine how to handle the buffer. | 502 * to determine how to handle the buffer. |
421 * | 503 * |
422 * \param buffer The packet in OpenFlow buffer format. | 504 * \param buffer The packet in OpenFlow buffer format. |
423 * \return The packet type, as defined in the ofp_type struct. | 505 * \return The packet type, as defined in the ofp_type struct. |
424 */ | 506 */ |
425 uint8_t GetPacketType (ofpbuf* buffer); | 507 uint8_t GetPacketType (ofpbuf* buffer); |
426 | 508 |
427 typedef std::set<Ptr<OpenFlowSwitchNetDevice> > Switches_t; | 509 typedef std::set<Ptr<OpenFlowSwitchNetDevice> > Switches_t; ///< switches type
def |
428 Switches_t m_switches; ///< The collection of switches registered to this con
troller. | 510 Switches_t m_switches; ///< The collection of switches registered to this con
troller. |
429 }; | 511 }; |
430 | 512 |
431 /** | 513 /** |
432 * Demonstration of a Drop controller. When a connected switch | 514 * Demonstration of a Drop controller. When a connected switch |
433 * passes it a packet the switch doesn't recognize, the controller | 515 * passes it a packet the switch doesn't recognize, the controller |
434 * configures the switch to make a flow that drops alike packets. | 516 * configures the switch to make a flow that drops alike packets. |
435 */ | 517 */ |
436 class DropController : public Controller | 518 class DropController : public Controller |
437 { | 519 { |
(...skipping 24 matching lines...) Expand all Loading... |
462 static TypeId GetTypeId (void); | 544 static TypeId GetTypeId (void); |
463 | 545 |
464 virtual ~LearningController () | 546 virtual ~LearningController () |
465 { | 547 { |
466 m_learnState.clear (); | 548 m_learnState.clear (); |
467 } | 549 } |
468 | 550 |
469 void ReceiveFromSwitch (Ptr<OpenFlowSwitchNetDevice> swtch, ofpbuf* buffer); | 551 void ReceiveFromSwitch (Ptr<OpenFlowSwitchNetDevice> swtch, ofpbuf* buffer); |
470 | 552 |
471 protected: | 553 protected: |
| 554 /// LearnedState |
472 struct LearnedState | 555 struct LearnedState |
473 { | 556 { |
474 uint32_t port; ///< Learned port. | 557 uint32_t port; ///< Learned port. |
475 }; | 558 }; |
476 Time m_expirationTime; ///< Time it takes for learned MAC state
entry/created flow to expire. | 559 Time m_expirationTime; ///< Time it takes for learned MAC state
entry/created flow to expire. |
477 typedef std::map<Mac48Address, LearnedState> LearnState_t; | 560 typedef std::map<Mac48Address, LearnedState> LearnState_t; ///< learn state ty
pedef |
478 LearnState_t m_learnState; ///< Learned state data. | 561 LearnState_t m_learnState; ///< Learned state data. |
479 }; | 562 }; |
480 | 563 |
481 /** | 564 /** |
482 * \brief Executes a list of flow table actions. | 565 * \brief Executes a list of flow table actions. |
483 * | 566 * |
484 * \param swtch OpenFlowSwitchNetDevice these actions are being executed on. | 567 * \param swtch OpenFlowSwitchNetDevice these actions are being executed on. |
485 * \param packet_uid Packet UID; used to fetch the packet and its metadata. | 568 * \param packet_uid Packet UID; used to fetch the packet and its metadata. |
486 * \param buffer The Packet OpenFlow buffer. | 569 * \param buffer The Packet OpenFlow buffer. |
487 * \param key The matching key for the flow tied to this list of actions. | 570 * \param key The matching key for the flow tied to this list of actions. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 #define PKT_BUFFER_BITS 8 | 635 #define PKT_BUFFER_BITS 8 |
553 #define N_PKT_BUFFERS (1 << PKT_BUFFER_BITS) | 636 #define N_PKT_BUFFERS (1 << PKT_BUFFER_BITS) |
554 #define PKT_BUFFER_MASK (N_PKT_BUFFERS - 1) | 637 #define PKT_BUFFER_MASK (N_PKT_BUFFERS - 1) |
555 #define PKT_COOKIE_BITS (32 - PKT_BUFFER_BITS) | 638 #define PKT_COOKIE_BITS (32 - PKT_BUFFER_BITS) |
556 | 639 |
557 } | 640 } |
558 | 641 |
559 } | 642 } |
560 | 643 |
561 #endif /* OPENFLOW_INTERFACE_H */ | 644 #endif /* OPENFLOW_INTERFACE_H */ |
OLD | NEW |