Rich Lane | a06d0c3 | 2013-03-25 08:52:03 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford |
| 2 | * Junior University |
| 3 | * |
| 4 | * We are making the OpenFlow specification and associated documentation |
| 5 | * (Software) available for public use and benefit with the expectation |
| 6 | * that others will use, modify and enhance the Software and contribute |
| 7 | * those enhancements back to the community. However, since we would |
| 8 | * like to make the Software available for broadest use, with as few |
| 9 | * restrictions as possible permission is hereby granted, free of |
| 10 | * charge, to any person obtaining a copy of this Software to deal in |
| 11 | * the Software under the copyrights without restriction, including |
| 12 | * without limitation the rights to use, copy, modify, merge, publish, |
| 13 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 14 | * permit persons to whom the Software is furnished to do so, subject to |
| 15 | * the following conditions: |
| 16 | * |
| 17 | * The above copyright notice and this permission notice shall be |
| 18 | * included in all copies or substantial portions of the Software. |
| 19 | * |
| 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 24 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 25 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 27 | * SOFTWARE. |
| 28 | * |
| 29 | * The name and trademarks of copyright holder(s) may NOT be used in |
| 30 | * advertising or publicity pertaining to the Software or any |
| 31 | * derivatives without specific, written prior permission. |
| 32 | */ |
| 33 | |
| 34 | /* OpenFlow: protocol between controller and datapath. */ |
| 35 | |
| 36 | #ifndef OPENFLOW_OPENFLOW_H |
| 37 | #define OPENFLOW_OPENFLOW_H 1 |
| 38 | |
| 39 | #ifdef __KERNEL__ |
| 40 | #include <linux/types.h> |
| 41 | #else |
| 42 | #include <stdint.h> |
| 43 | #endif |
| 44 | |
| 45 | #ifdef SWIG |
| 46 | #define OFP_ASSERT(EXPR) /* SWIG can't handle OFP_ASSERT. */ |
| 47 | #elif !defined(__cplusplus) |
| 48 | /* Build-time assertion for use in a declaration context. */ |
| 49 | #define OFP_ASSERT(EXPR) \ |
| 50 | extern int (*build_assert(void))[ sizeof(struct { \ |
| 51 | unsigned int build_assert_failed : (EXPR) ? 1 : -1; })] |
| 52 | #else /* __cplusplus */ |
| 53 | #define OFP_ASSERT(_EXPR) typedef int build_assert_failed[(_EXPR) ? 1 : -1] |
| 54 | #endif /* __cplusplus */ |
| 55 | |
| 56 | #ifndef SWIG |
| 57 | #define OFP_PACKED __attribute__((packed)) |
| 58 | #else |
| 59 | #define OFP_PACKED /* SWIG doesn't understand __attribute. */ |
| 60 | #endif |
| 61 | |
| 62 | /* Version number: |
| 63 | * Non-experimental versions released: 0x01 |
| 64 | * Experimental versions released: 0x81 -- 0x99 |
| 65 | */ |
| 66 | /* The most significant bit being set in the version field indicates an |
| 67 | * experimental OpenFlow version. |
| 68 | */ |
| 69 | #define OFP_VERSION 0x02 |
| 70 | |
| 71 | #define OFP_MAX_TABLE_NAME_LEN 32 |
| 72 | #define OFP_MAX_PORT_NAME_LEN 16 |
| 73 | |
| 74 | #define OFP_TCP_PORT 6633 |
| 75 | #define OFP_SSL_PORT 6633 |
| 76 | |
| 77 | #define OFP_ETH_ALEN 6 /* Bytes in an Ethernet address. */ |
| 78 | |
| 79 | /* Port numbering. Ports are numbered starting from 1. */ |
| 80 | enum ofp_port_no { |
| 81 | /* Maximum number of physical switch ports. */ |
| 82 | OFPP_MAX = 0xffffff00, |
| 83 | |
| 84 | /* Fake output "ports". */ |
| 85 | OFPP_IN_PORT = 0xfffffff8, /* Send the packet out the input port. This |
| 86 | virtual port must be explicitly used |
| 87 | in order to send back out of the input |
| 88 | port. */ |
| 89 | OFPP_TABLE = 0xfffffff9, /* Submit the packet to the first flow table |
| 90 | NB: This destination port can only be |
| 91 | used in packet-out messages. */ |
| 92 | OFPP_NORMAL = 0xfffffffa, /* Process with normal L2/L3 switching. */ |
| 93 | OFPP_FLOOD = 0xfffffffb, /* All physical ports in VLAN, except input |
| 94 | port and those blocked or link down. */ |
| 95 | OFPP_ALL = 0xfffffffc, /* All physical ports except input port. */ |
| 96 | OFPP_CONTROLLER = 0xfffffffd, /* Send to controller. */ |
| 97 | OFPP_LOCAL = 0xfffffffe, /* Local openflow "port". */ |
| 98 | OFPP_ANY = 0xffffffff /* Wildcard port used only for flow mod |
| 99 | (delete) and flow stats requests. Selects |
| 100 | all flows regardless of output port |
| 101 | (including flows with no output port). */ |
| 102 | }; |
| 103 | |
| 104 | enum ofp_type { |
| 105 | /* Immutable messages. */ |
| 106 | OFPT_HELLO, /* Symmetric message */ |
| 107 | OFPT_ERROR, /* Symmetric message */ |
| 108 | OFPT_ECHO_REQUEST, /* Symmetric message */ |
| 109 | OFPT_ECHO_REPLY, /* Symmetric message */ |
| 110 | OFPT_EXPERIMENTER, /* Symmetric message */ |
| 111 | |
| 112 | /* Switch configuration messages. */ |
| 113 | OFPT_FEATURES_REQUEST, /* Controller/switch message */ |
| 114 | OFPT_FEATURES_REPLY, /* Controller/switch message */ |
| 115 | OFPT_GET_CONFIG_REQUEST, /* Controller/switch message */ |
| 116 | OFPT_GET_CONFIG_REPLY, /* Controller/switch message */ |
| 117 | OFPT_SET_CONFIG, /* Controller/switch message */ |
| 118 | |
| 119 | /* Asynchronous messages. */ |
| 120 | OFPT_PACKET_IN, /* Async message */ |
| 121 | OFPT_FLOW_REMOVED, /* Async message */ |
| 122 | OFPT_PORT_STATUS, /* Async message */ |
| 123 | |
| 124 | /* Controller command messages. */ |
| 125 | OFPT_PACKET_OUT, /* Controller/switch message */ |
| 126 | OFPT_FLOW_MOD, /* Controller/switch message */ |
| 127 | OFPT_GROUP_MOD, /* Controller/switch message */ |
| 128 | OFPT_PORT_MOD, /* Controller/switch message */ |
| 129 | OFPT_TABLE_MOD, /* Controller/switch message */ |
| 130 | |
| 131 | /* Statistics messages. */ |
| 132 | OFPT_STATS_REQUEST, /* Controller/switch message */ |
| 133 | OFPT_STATS_REPLY, /* Controller/switch message */ |
| 134 | |
| 135 | /* Barrier messages. */ |
| 136 | OFPT_BARRIER_REQUEST, /* Controller/switch message */ |
| 137 | OFPT_BARRIER_REPLY, /* Controller/switch message */ |
| 138 | |
| 139 | /* Queue Configuration messages. */ |
| 140 | OFPT_QUEUE_GET_CONFIG_REQUEST, /* Controller/switch message */ |
| 141 | OFPT_QUEUE_GET_CONFIG_REPLY, /* Controller/switch message */ |
| 142 | }; |
| 143 | |
| 144 | /* Header on all OpenFlow packets. */ |
| 145 | struct ofp_header { |
| 146 | uint8_t version; /* OFP_VERSION. */ |
| 147 | uint8_t type; /* One of the OFPT_ constants. */ |
| 148 | uint16_t length; /* Length including this ofp_header. */ |
| 149 | uint32_t xid; /* Transaction id associated with this packet. |
| 150 | Replies use the same id as was in the request |
| 151 | to facilitate pairing. */ |
| 152 | }; |
| 153 | OFP_ASSERT(sizeof(struct ofp_header) == 8); |
| 154 | |
| 155 | /* OFPT_HELLO. This message has an empty body, but implementations must |
| 156 | * ignore any data included in the body, to allow for future extensions. */ |
| 157 | struct ofp_hello { |
| 158 | struct ofp_header header; |
| 159 | }; |
| 160 | |
| 161 | #define OFP_DEFAULT_MISS_SEND_LEN 128 |
| 162 | |
| 163 | enum ofp_config_flags { |
| 164 | /* Handling of IP fragments. */ |
| 165 | OFPC_FRAG_NORMAL = 0, /* No special handling for fragments. */ |
| 166 | OFPC_FRAG_DROP = 1 << 0, /* Drop fragments. */ |
| 167 | OFPC_FRAG_REASM = 1 << 1, /* Reassemble (only if OFPC_IP_REASM set). */ |
| 168 | OFPC_FRAG_MASK = 3, |
| 169 | |
| 170 | /* TTL processing - applicable for IP and MPLS packets */ |
| 171 | OFPC_INVALID_TTL_TO_CONTROLLER = 1 << 2, /* Send packets with invalid TTL |
| 172 | ie. 0 or 1 to controller */ |
| 173 | }; |
| 174 | |
| 175 | /* Switch configuration. */ |
| 176 | struct ofp_switch_config { |
| 177 | struct ofp_header header; |
| 178 | uint16_t flags; /* OFPC_* flags. */ |
| 179 | uint16_t miss_send_len; /* Max bytes of new flow that datapath should |
| 180 | send to the controller. */ |
| 181 | }; |
| 182 | OFP_ASSERT(sizeof(struct ofp_switch_config) == 12); |
| 183 | |
| 184 | /* Flags to indicate behavior of the flow table for unmatched packets. |
| 185 | These flags are used in ofp_table_stats messages to describe the current |
| 186 | configuration and in ofp_table_mod messages to configure table behavior. */ |
| 187 | enum ofp_table_config { |
| 188 | OFPTC_TABLE_MISS_CONTROLLER = 0, /* Send to controller. */ |
| 189 | OFPTC_TABLE_MISS_CONTINUE = 1 << 0, /* Continue to the next table in the |
| 190 | pipeline (OpenFlow 1.0 |
| 191 | behavior). */ |
| 192 | OFPTC_TABLE_MISS_DROP = 1 << 1, /* Drop the packet. */ |
| 193 | OFPTC_TABLE_MISS_MASK = 3 |
| 194 | }; |
| 195 | |
| 196 | /* Configure/Modify behavior of a flow table */ |
| 197 | struct ofp_table_mod { |
| 198 | struct ofp_header header; |
| 199 | uint8_t table_id; /* ID of the table, 0xFF indicates all tables */ |
| 200 | uint8_t pad[3]; /* Pad to 32 bits */ |
| 201 | uint32_t config; /* Bitmap of OFPTC_* flags */ |
| 202 | }; |
| 203 | OFP_ASSERT(sizeof(struct ofp_table_mod) == 16); |
| 204 | |
| 205 | /* Capabilities supported by the datapath. */ |
| 206 | enum ofp_capabilities { |
| 207 | OFPC_FLOW_STATS = 1 << 0, /* Flow statistics. */ |
| 208 | OFPC_TABLE_STATS = 1 << 1, /* Table statistics. */ |
| 209 | OFPC_PORT_STATS = 1 << 2, /* Port statistics. */ |
| 210 | OFPC_GROUP_STATS = 1 << 3, /* Group statistics. */ |
| 211 | OFPC_IP_REASM = 1 << 5, /* Can reassemble IP fragments. */ |
| 212 | OFPC_QUEUE_STATS = 1 << 6, /* Queue statistics. */ |
| 213 | OFPC_ARP_MATCH_IP = 1 << 7 /* Match IP addresses in ARP pkts. */ |
| 214 | }; |
| 215 | |
| 216 | /* Flags to indicate behavior of the physical port. These flags are |
| 217 | * used in ofp_port to describe the current configuration. They are |
| 218 | * used in the ofp_port_mod message to configure the port's behavior. |
| 219 | */ |
| 220 | enum ofp_port_config { |
| 221 | OFPPC_PORT_DOWN = 1 << 0, /* Port is administratively down. */ |
| 222 | |
| 223 | OFPPC_NO_RECV = 1 << 2, /* Drop all packets received by port. */ |
| 224 | OFPPC_NO_FWD = 1 << 5, /* Drop packets forwarded to port. */ |
| 225 | OFPPC_NO_PACKET_IN = 1 << 6 /* Do not send packet-in msgs for port. */ |
| 226 | }; |
| 227 | |
| 228 | /* Current state of the physical port. These are not configurable from |
| 229 | * the controller. |
| 230 | */ |
| 231 | enum ofp_port_state { |
| 232 | OFPPS_LINK_DOWN = 1 << 0, /* No physical link present. */ |
| 233 | OFPPS_BLOCKED = 1 << 1, /* Port is blocked */ |
| 234 | OFPPS_LIVE = 1 << 2, /* Live for Fast Failover Group. */ |
| 235 | }; |
| 236 | |
| 237 | /* Features of ports available in a datapath. */ |
| 238 | enum ofp_port_features { |
| 239 | OFPPF_10MB_HD = 1 << 0, /* 10 Mb half-duplex rate support. */ |
| 240 | OFPPF_10MB_FD = 1 << 1, /* 10 Mb full-duplex rate support. */ |
| 241 | OFPPF_100MB_HD = 1 << 2, /* 100 Mb half-duplex rate support. */ |
| 242 | OFPPF_100MB_FD = 1 << 3, /* 100 Mb full-duplex rate support. */ |
| 243 | OFPPF_1GB_HD = 1 << 4, /* 1 Gb half-duplex rate support. */ |
| 244 | OFPPF_1GB_FD = 1 << 5, /* 1 Gb full-duplex rate support. */ |
| 245 | OFPPF_10GB_FD = 1 << 6, /* 10 Gb full-duplex rate support. */ |
| 246 | OFPPF_40GB_FD = 1 << 7, /* 40 Gb full-duplex rate support. */ |
| 247 | OFPPF_100GB_FD = 1 << 8, /* 100 Gb full-duplex rate support. */ |
| 248 | OFPPF_1TB_FD = 1 << 9, /* 1 Tb full-duplex rate support. */ |
| 249 | OFPPF_OTHER = 1 << 10, /* Other rate, not in the list. */ |
| 250 | |
| 251 | OFPPF_COPPER = 1 << 11, /* Copper medium. */ |
| 252 | OFPPF_FIBER = 1 << 12, /* Fiber medium. */ |
| 253 | OFPPF_AUTONEG = 1 << 13, /* Auto-negotiation. */ |
| 254 | OFPPF_PAUSE = 1 << 14, /* Pause. */ |
| 255 | OFPPF_PAUSE_ASYM = 1 << 15 /* Asymmetric pause. */ |
| 256 | }; |
| 257 | |
| 258 | /* Description of a port */ |
| 259 | struct ofp_port { |
| 260 | uint32_t port_no; |
| 261 | uint8_t pad[4]; |
| 262 | uint8_t hw_addr[OFP_ETH_ALEN]; |
| 263 | uint8_t pad2[2]; /* Align to 64 bits. */ |
| 264 | char name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated */ |
| 265 | |
| 266 | uint32_t config; /* Bitmap of OFPPC_* flags. */ |
| 267 | uint32_t state; /* Bitmap of OFPPS_* flags. */ |
| 268 | |
| 269 | /* Bitmaps of OFPPF_* that describe features. All bits zeroed if |
| 270 | * unsupported or unavailable. */ |
| 271 | uint32_t curr; /* Current features. */ |
| 272 | uint32_t advertised; /* Features being advertised by the port. */ |
| 273 | uint32_t supported; /* Features supported by the port. */ |
| 274 | uint32_t peer; /* Features advertised by peer. */ |
| 275 | |
| 276 | uint32_t curr_speed; /* Current port bitrate in kbps. */ |
| 277 | uint32_t max_speed; /* Max port bitrate in kbps */ |
| 278 | }; |
| 279 | OFP_ASSERT(sizeof(struct ofp_port) == 64); |
| 280 | |
| 281 | /* Switch features. */ |
| 282 | struct ofp_switch_features { |
| 283 | struct ofp_header header; |
| 284 | uint64_t datapath_id; /* Datapath unique ID. The lower 48-bits are for |
| 285 | a MAC address, while the upper 16-bits are |
| 286 | implementer-defined. */ |
| 287 | |
| 288 | uint32_t n_buffers; /* Max packets buffered at once. */ |
| 289 | |
| 290 | uint8_t n_tables; /* Number of tables supported by datapath. */ |
| 291 | uint8_t pad[3]; /* Align to 64-bits. */ |
| 292 | |
| 293 | /* Features. */ |
| 294 | uint32_t capabilities; /* Bitmap of support "ofp_capabilities". */ |
| 295 | uint32_t reserved; |
| 296 | |
| 297 | /* Port info.*/ |
| 298 | struct ofp_port ports[0]; /* Port definitions. The number of ports |
| 299 | is inferred from the length field in |
| 300 | the header. */ |
| 301 | }; |
| 302 | OFP_ASSERT(sizeof(struct ofp_switch_features) == 32); |
| 303 | |
| 304 | /* What changed about the physical port */ |
| 305 | enum ofp_port_reason { |
| 306 | OFPPR_ADD, /* The port was added. */ |
| 307 | OFPPR_DELETE, /* The port was removed. */ |
| 308 | OFPPR_MODIFY /* Some attribute of the port has changed. */ |
| 309 | }; |
| 310 | |
| 311 | /* A physical port has changed in the datapath */ |
| 312 | struct ofp_port_status { |
| 313 | struct ofp_header header; |
| 314 | uint8_t reason; /* One of OFPPR_*. */ |
| 315 | uint8_t pad[7]; /* Align to 64-bits. */ |
| 316 | struct ofp_port desc; |
| 317 | }; |
| 318 | OFP_ASSERT(sizeof(struct ofp_port_status) == 80); |
| 319 | |
| 320 | /* Modify behavior of the physical port */ |
| 321 | struct ofp_port_mod { |
| 322 | struct ofp_header header; |
| 323 | uint32_t port_no; |
| 324 | uint8_t pad[4]; |
| 325 | uint8_t hw_addr[OFP_ETH_ALEN]; /* The hardware address is not |
| 326 | configurable. This is used to |
| 327 | sanity-check the request, so it must |
| 328 | be the same as returned in an |
| 329 | ofp_port struct. */ |
| 330 | uint8_t pad2[2]; /* Pad to 64 bits. */ |
| 331 | uint32_t config; /* Bitmap of OFPPC_* flags. */ |
| 332 | uint32_t mask; /* Bitmap of OFPPC_* flags to be changed. */ |
| 333 | |
| 334 | uint32_t advertise; /* Bitmap of OFPPF_*. Zero all bits to prevent |
| 335 | any action taking place. */ |
| 336 | uint8_t pad3[4]; /* Pad to 64 bits. */ |
| 337 | }; |
| 338 | OFP_ASSERT(sizeof(struct ofp_port_mod) == 40); |
| 339 | |
| 340 | /* Why is this packet being sent to the controller? */ |
| 341 | enum ofp_packet_in_reason { |
| 342 | OFPR_NO_MATCH, /* No matching flow. */ |
| 343 | OFPR_ACTION /* Action explicitly output to controller. */ |
| 344 | }; |
| 345 | |
| 346 | /* Packet received on port (datapath -> controller). */ |
| 347 | struct ofp_packet_in { |
| 348 | struct ofp_header header; |
| 349 | uint32_t buffer_id; /* ID assigned by datapath. */ |
| 350 | uint32_t in_port; /* Port on which frame was received. */ |
| 351 | uint32_t in_phy_port; /* Physical Port on which frame was received. */ |
| 352 | uint16_t total_len; /* Full length of frame. */ |
| 353 | uint8_t reason; /* Reason packet is being sent (one of OFPR_*) */ |
| 354 | uint8_t table_id; /* ID of the table that was looked up */ |
| 355 | uint8_t data[0]; /* Ethernet frame, halfway through 32-bit word, |
| 356 | so the IP header is 32-bit aligned. The |
| 357 | amount of data is inferred from the length |
| 358 | field in the header. Because of padding, |
| 359 | offsetof(struct ofp_packet_in, data) == |
| 360 | sizeof(struct ofp_packet_in) - 2. */ |
| 361 | }; |
| 362 | OFP_ASSERT(sizeof(struct ofp_packet_in) == 24); |
| 363 | |
| 364 | enum ofp_action_type { |
| 365 | OFPAT_OUTPUT, /* Output to switch port. */ |
| 366 | OFPAT_SET_VLAN_VID, /* Set the 802.1q VLAN id. */ |
| 367 | OFPAT_SET_VLAN_PCP, /* Set the 802.1q priority. */ |
| 368 | OFPAT_SET_DL_SRC, /* Ethernet source address. */ |
| 369 | OFPAT_SET_DL_DST, /* Ethernet destination address. */ |
| 370 | OFPAT_SET_NW_SRC, /* IP source address. */ |
| 371 | OFPAT_SET_NW_DST, /* IP destination address. */ |
| 372 | OFPAT_SET_NW_TOS, /* IP ToS (DSCP field, 6 bits). */ |
| 373 | OFPAT_SET_NW_ECN, /* IP ECN (2 bits). */ |
| 374 | OFPAT_SET_TP_SRC, /* TCP/UDP/SCTP source port. */ |
| 375 | OFPAT_SET_TP_DST, /* TCP/UDP/SCTP destination port. */ |
| 376 | OFPAT_COPY_TTL_OUT, /* Copy TTL "outwards" -- from next-to-outermost to |
| 377 | outermost */ |
| 378 | OFPAT_COPY_TTL_IN, /* Copy TTL "inwards" -- from outermost to |
| 379 | next-to-outermost */ |
| 380 | OFPAT_SET_MPLS_LABEL, /* MPLS label */ |
| 381 | OFPAT_SET_MPLS_TC, /* MPLS TC */ |
| 382 | OFPAT_SET_MPLS_TTL, /* MPLS TTL */ |
| 383 | OFPAT_DEC_MPLS_TTL, /* Decrement MPLS TTL */ |
| 384 | |
| 385 | OFPAT_PUSH_VLAN, /* Push a new VLAN tag */ |
| 386 | OFPAT_POP_VLAN, /* Pop the outer VLAN tag */ |
| 387 | OFPAT_PUSH_MPLS, /* Push a new MPLS tag */ |
| 388 | OFPAT_POP_MPLS, /* Pop the outer MPLS tag */ |
| 389 | OFPAT_SET_QUEUE, /* Set queue id when outputting to a port */ |
| 390 | OFPAT_GROUP, /* Apply group. */ |
| 391 | OFPAT_SET_NW_TTL, /* IP TTL. */ |
| 392 | OFPAT_DEC_NW_TTL, /* Decrement IP TTL. */ |
| 393 | OFPAT_EXPERIMENTER = 0xffff |
| 394 | }; |
| 395 | |
| 396 | /* Action structure for OFPAT_OUTPUT, which sends packets out 'port'. |
| 397 | * When the 'port' is the OFPP_CONTROLLER, 'max_len' indicates the max |
| 398 | * number of bytes to send. A 'max_len' of zero means no bytes of the |
| 399 | * packet should be sent.*/ |
| 400 | struct ofp_action_output { |
| 401 | uint16_t type; /* OFPAT_OUTPUT. */ |
| 402 | uint16_t len; /* Length is 16. */ |
| 403 | uint32_t port; /* Output port. */ |
| 404 | uint16_t max_len; /* Max length to send to controller. */ |
| 405 | uint8_t pad[6]; /* Pad to 64 bits. */ |
| 406 | }; |
| 407 | OFP_ASSERT(sizeof(struct ofp_action_output) == 16); |
| 408 | |
| 409 | /* Action structure for OFPAT_SET_VLAN_VID. */ |
| 410 | struct ofp_action_vlan_vid { |
| 411 | uint16_t type; /* OFPAT_SET_VLAN_VID. */ |
| 412 | uint16_t len; /* Length is 8. */ |
| 413 | uint16_t vlan_vid; /* VLAN id. */ |
| 414 | uint8_t pad[2]; |
| 415 | }; |
| 416 | OFP_ASSERT(sizeof(struct ofp_action_vlan_vid) == 8); |
| 417 | |
| 418 | /* Action structure for OFPAT_SET_VLAN_PCP. */ |
| 419 | struct ofp_action_vlan_pcp { |
| 420 | uint16_t type; /* OFPAT_SET_VLAN_PCP. */ |
| 421 | uint16_t len; /* Length is 8. */ |
| 422 | uint8_t vlan_pcp; /* VLAN priority. */ |
| 423 | uint8_t pad[3]; |
| 424 | }; |
| 425 | OFP_ASSERT(sizeof(struct ofp_action_vlan_pcp) == 8); |
| 426 | |
| 427 | /* Action structure for OFPAT_SET_DL_SRC/DST. */ |
| 428 | struct ofp_action_dl_addr { |
| 429 | uint16_t type; /* OFPAT_SET_DL_SRC/DST. */ |
| 430 | uint16_t len; /* Length is 16. */ |
| 431 | uint8_t dl_addr[OFP_ETH_ALEN]; /* Ethernet address. */ |
| 432 | uint8_t pad[6]; |
| 433 | }; |
| 434 | OFP_ASSERT(sizeof(struct ofp_action_dl_addr) == 16); |
| 435 | |
| 436 | /* Action structure for OFPAT_SET_NW_SRC/DST. */ |
| 437 | struct ofp_action_nw_addr { |
| 438 | uint16_t type; /* OFPAT_SET_TW_SRC/DST. */ |
| 439 | uint16_t len; /* Length is 8. */ |
| 440 | uint32_t nw_addr; /* IP address. */ |
| 441 | }; |
| 442 | OFP_ASSERT(sizeof(struct ofp_action_nw_addr) == 8); |
| 443 | |
| 444 | /* Action structure for OFPAT_SET_TP_SRC/DST. */ |
| 445 | struct ofp_action_tp_port { |
| 446 | uint16_t type; /* OFPAT_SET_TP_SRC/DST. */ |
| 447 | uint16_t len; /* Length is 8. */ |
| 448 | uint16_t tp_port; /* TCP/UDP/SCTP port. */ |
| 449 | uint8_t pad[2]; |
| 450 | }; |
| 451 | OFP_ASSERT(sizeof(struct ofp_action_tp_port) == 8); |
| 452 | |
| 453 | /* Action structure for OFPAT_SET_NW_TOS. */ |
| 454 | struct ofp_action_nw_tos { |
| 455 | uint16_t type; /* OFPAT_SET_TW_SRC/DST. */ |
| 456 | uint16_t len; /* Length is 8. */ |
| 457 | uint8_t nw_tos; /* IP ToS (DSCP field, 6 bits). */ |
| 458 | uint8_t pad[3]; |
| 459 | }; |
| 460 | OFP_ASSERT(sizeof(struct ofp_action_nw_tos) == 8); |
| 461 | |
| 462 | /* Action structure for OFPAT_SET_NW_ECN. */ |
| 463 | struct ofp_action_nw_ecn { |
| 464 | uint16_t type; /* OFPAT_SET_TW_SRC/DST. */ |
| 465 | uint16_t len; /* Length is 8. */ |
| 466 | uint8_t nw_ecn; /* IP ECN (2 bits). */ |
| 467 | uint8_t pad[3]; |
| 468 | }; |
| 469 | OFP_ASSERT(sizeof(struct ofp_action_nw_ecn) == 8); |
| 470 | |
| 471 | /* Action structure for OFPAT_SET_MPLS_LABEL. */ |
| 472 | struct ofp_action_mpls_label { |
| 473 | uint16_t type; /* OFPAT_SET_MPLS_LABEL. */ |
| 474 | uint16_t len; /* Length is 8. */ |
| 475 | uint32_t mpls_label; /* MPLS label */ |
| 476 | }; |
| 477 | OFP_ASSERT(sizeof(struct ofp_action_mpls_label) == 8); |
| 478 | |
| 479 | /* Action structure for OFPAT_SET_MPLS_TC. */ |
| 480 | struct ofp_action_mpls_tc { |
| 481 | uint16_t type; /* OFPAT_SET_MPLS_TC. */ |
| 482 | uint16_t len; /* Length is 8. */ |
| 483 | uint8_t mpls_tc; /* MPLS TC */ |
| 484 | uint8_t pad[3]; |
| 485 | }; |
| 486 | OFP_ASSERT(sizeof(struct ofp_action_mpls_tc) == 8); |
| 487 | |
| 488 | /* Action structure for OFPAT_SET_MPLS_TTL. */ |
| 489 | struct ofp_action_mpls_ttl { |
| 490 | uint16_t type; /* OFPAT_SET_MPLS_TTL. */ |
| 491 | uint16_t len; /* Length is 8. */ |
| 492 | uint8_t mpls_ttl; /* MPLS TTL */ |
| 493 | uint8_t pad[3]; |
| 494 | }; |
| 495 | OFP_ASSERT(sizeof(struct ofp_action_mpls_ttl) == 8); |
| 496 | |
| 497 | /* Action structure for OFPAT_PUSH_VLAN/MPLS. */ |
| 498 | struct ofp_action_push { |
| 499 | uint16_t type; /* OFPAT_PUSH_VLAN/MPLS. */ |
| 500 | uint16_t len; /* Length is 8. */ |
| 501 | uint16_t ethertype; /* Ethertype */ |
| 502 | uint8_t pad[2]; |
| 503 | }; |
| 504 | OFP_ASSERT(sizeof(struct ofp_action_push) == 8); |
| 505 | |
| 506 | /* Action structure for OFPAT_POP_MPLS. */ |
| 507 | struct ofp_action_pop_mpls { |
| 508 | uint16_t type; /* OFPAT_POP_MPLS. */ |
| 509 | uint16_t len; /* Length is 8. */ |
| 510 | uint16_t ethertype; /* Ethertype */ |
| 511 | uint8_t pad[2]; |
| 512 | }; |
| 513 | OFP_ASSERT(sizeof(struct ofp_action_pop_mpls) == 8); |
| 514 | |
| 515 | /* Action structure for OFPAT_GROUP. */ |
| 516 | struct ofp_action_group { |
| 517 | uint16_t type; /* OFPAT_GROUP. */ |
| 518 | uint16_t len; /* Length is 8. */ |
| 519 | uint32_t group_id; /* Group identifier. */ |
| 520 | }; |
| 521 | OFP_ASSERT(sizeof(struct ofp_action_group) == 8); |
| 522 | |
| 523 | /* Action structure for OFPAT_SET_NW_TTL. */ |
| 524 | struct ofp_action_nw_ttl { |
| 525 | uint16_t type; /* OFPAT_SET_NW_TTL. */ |
| 526 | uint16_t len; /* Length is 8. */ |
| 527 | uint8_t nw_ttl; /* IP TTL */ |
| 528 | uint8_t pad[3]; |
| 529 | }; |
| 530 | OFP_ASSERT(sizeof(struct ofp_action_nw_ttl) == 8); |
| 531 | |
| 532 | /* Action header for OFPAT_EXPERIMENTER. |
| 533 | * The rest of the body is experimenter-defined. */ |
| 534 | struct ofp_action_experimenter_header { |
| 535 | uint16_t type; /* OFPAT_EXPERIMENTER. */ |
| 536 | uint16_t len; /* Length is a multiple of 8. */ |
| 537 | uint32_t experimenter; /* Experimenter ID which takes the same |
| 538 | form as in struct |
| 539 | ofp_experimenter_header. */ |
| 540 | }; |
| 541 | OFP_ASSERT(sizeof(struct ofp_action_experimenter_header) == 8); |
| 542 | |
| 543 | /* Action header that is common to all actions. The length includes the |
| 544 | * header and any padding used to make the action 64-bit aligned. |
| 545 | * NB: The length of an action *must* always be a multiple of eight. */ |
| 546 | struct ofp_action_header { |
| 547 | uint16_t type; /* One of OFPAT_*. */ |
| 548 | uint16_t len; /* Length of action, including this |
| 549 | header. This is the length of action, |
| 550 | including any padding to make it |
| 551 | 64-bit aligned. */ |
| 552 | uint8_t pad[4]; |
| 553 | }; |
| 554 | OFP_ASSERT(sizeof(struct ofp_action_header) == 8); |
| 555 | |
| 556 | /* Send packet (controller -> datapath). */ |
| 557 | struct ofp_packet_out { |
| 558 | struct ofp_header header; |
| 559 | uint32_t buffer_id; /* ID assigned by datapath (-1 if none). */ |
| 560 | uint32_t in_port; /* Packet's input port or OFPP_CONTROLLER. */ |
| 561 | uint16_t actions_len; /* Size of action array in bytes. */ |
| 562 | uint8_t pad[6]; |
| 563 | struct ofp_action_header actions[0]; /* Action list. */ |
| 564 | /* uint8_t data[0]; */ /* Packet data. The length is inferred |
| 565 | from the length field in the header. |
| 566 | (Only meaningful if buffer_id == -1.) */ |
| 567 | }; |
| 568 | OFP_ASSERT(sizeof(struct ofp_packet_out) == 24); |
| 569 | |
| 570 | enum ofp_flow_mod_command { |
| 571 | OFPFC_ADD, /* New flow. */ |
| 572 | OFPFC_MODIFY, /* Modify all matching flows. */ |
| 573 | OFPFC_MODIFY_STRICT, /* Modify entry strictly matching wildcards and |
| 574 | priority. */ |
| 575 | OFPFC_DELETE, /* Delete all matching flows. */ |
| 576 | OFPFC_DELETE_STRICT /* Delete entry strictly matching wildcards and |
| 577 | priority. */ |
| 578 | }; |
| 579 | |
| 580 | /* Group commands */ |
| 581 | enum ofp_group_mod_command { |
| 582 | OFPGC_ADD, /* New group. */ |
| 583 | OFPGC_MODIFY, /* Modify all matching groups. */ |
| 584 | OFPGC_DELETE, /* Delete all matching groups. */ |
| 585 | }; |
| 586 | |
| 587 | /* Flow wildcards. */ |
| 588 | enum ofp_flow_wildcards { |
| 589 | OFPFW_IN_PORT = 1 << 0, /* Switch input port. */ |
| 590 | OFPFW_DL_VLAN = 1 << 1, /* VLAN id. */ |
| 591 | OFPFW_DL_VLAN_PCP = 1 << 2, /* VLAN priority. */ |
| 592 | OFPFW_DL_TYPE = 1 << 3, /* Ethernet frame type. */ |
| 593 | OFPFW_NW_TOS = 1 << 4, /* IP ToS (DSCP field, 6 bits). */ |
| 594 | OFPFW_NW_PROTO = 1 << 5, /* IP protocol. */ |
| 595 | OFPFW_TP_SRC = 1 << 6, /* TCP/UDP/SCTP source port. */ |
| 596 | OFPFW_TP_DST = 1 << 7, /* TCP/UDP/SCTP destination port. */ |
| 597 | OFPFW_MPLS_LABEL = 1 << 8, /* MPLS label. */ |
| 598 | OFPFW_MPLS_TC = 1 << 9, /* MPLS TC. */ |
| 599 | |
| 600 | /* Wildcard all fields. */ |
| 601 | OFPFW_ALL = ((1 << 10) - 1) |
| 602 | }; |
| 603 | |
| 604 | /* The wildcards for ICMP type and code fields use the transport source |
| 605 | * and destination port fields, respectively. */ |
| 606 | #define OFPFW_ICMP_TYPE OFPFW_TP_SRC |
| 607 | #define OFPFW_ICMP_CODE OFPFW_TP_DST |
| 608 | |
| 609 | /* Values below this cutoff are 802.3 packets and the two bytes |
| 610 | * following MAC addresses are used as a frame length. Otherwise, the |
| 611 | * two bytes are used as the Ethernet type. |
| 612 | */ |
| 613 | #define OFP_DL_TYPE_ETH2_CUTOFF 0x0600 |
| 614 | |
| 615 | /* Value of dl_type to indicate that the frame does not include an |
| 616 | * Ethernet type. |
| 617 | */ |
| 618 | #define OFP_DL_TYPE_NOT_ETH_TYPE 0x05ff |
| 619 | |
| 620 | /* The VLAN id is 12-bits, so we can use the entire 16 bits to indicate |
| 621 | * special conditions. |
| 622 | */ |
| 623 | enum ofp_vlan_id { |
| 624 | OFPVID_ANY = 0xfffe, /* Indicate that a VLAN id is set but don't care |
| 625 | about it's value. Note: only valid when specifying |
| 626 | the VLAN id in a match */ |
| 627 | OFPVID_NONE = 0xffff, /* No VLAN id was set. */ |
| 628 | }; |
| 629 | /* Define for compatibility */ |
| 630 | #define OFP_VLAN_NONE OFPVID_NONE |
| 631 | |
| 632 | /* The match type indicates the match structure (set of fields that compose the |
| 633 | * match) in use. The match type is placed in the type field at the beginning |
| 634 | * of all match structures. The "standard" type corresponds to ofp_match and |
| 635 | * must be supported by all OpenFlow switches. Extensions that define other |
| 636 | * match types may be published on the OpenFlow wiki. Support for extensions is |
| 637 | * optional. |
| 638 | */ |
| 639 | enum ofp_match_type { |
| 640 | OFPMT_STANDARD, /* The match fields defined in the ofp_match |
| 641 | structure apply */ |
| 642 | }; |
| 643 | |
| 644 | /* Size/length of STANDARD match */ |
| 645 | #define OFPMT_STANDARD_LENGTH 88 |
| 646 | |
| 647 | /* Fields to match against flows */ |
| 648 | struct ofp_match { |
| 649 | uint16_t type; /* One of OFPMT_* */ |
| 650 | uint16_t length; /* Length of ofp_match */ |
| 651 | uint32_t in_port; /* Input switch port. */ |
| 652 | uint32_t wildcards; /* Wildcard fields. */ |
| 653 | uint8_t dl_src[OFP_ETH_ALEN]; /* Ethernet source address. */ |
| 654 | uint8_t dl_src_mask[OFP_ETH_ALEN]; /* Ethernet source address mask. */ |
| 655 | uint8_t dl_dst[OFP_ETH_ALEN]; /* Ethernet destination address. */ |
| 656 | uint8_t dl_dst_mask[OFP_ETH_ALEN]; /* Ethernet destination address mask. */ |
| 657 | uint16_t dl_vlan; /* Input VLAN id. */ |
| 658 | uint8_t dl_vlan_pcp; /* Input VLAN priority. */ |
| 659 | uint8_t pad1[1]; /* Align to 32-bits */ |
| 660 | uint16_t dl_type; /* Ethernet frame type. */ |
| 661 | uint8_t nw_tos; /* IP ToS (actually DSCP field, 6 bits). */ |
| 662 | uint8_t nw_proto; /* IP protocol or lower 8 bits of |
| 663 | * ARP opcode. */ |
| 664 | uint32_t nw_src; /* IP source address. */ |
| 665 | uint32_t nw_src_mask; /* IP source address mask. */ |
| 666 | uint32_t nw_dst; /* IP destination address. */ |
| 667 | uint32_t nw_dst_mask; /* IP destination address mask. */ |
| 668 | uint16_t tp_src; /* TCP/UDP/SCTP source port. */ |
| 669 | uint16_t tp_dst; /* TCP/UDP/SCTP destination port. */ |
| 670 | uint32_t mpls_label; /* MPLS label. */ |
| 671 | uint8_t mpls_tc; /* MPLS TC. */ |
| 672 | uint8_t pad2[3]; /* Align to 64-bits */ |
| 673 | uint64_t metadata; /* Metadata passed between tables. */ |
| 674 | uint64_t metadata_mask; /* Mask for metadata. */ |
| 675 | }; |
| 676 | OFP_ASSERT(sizeof(struct ofp_match) == OFPMT_STANDARD_LENGTH); |
| 677 | |
| 678 | /* The match fields for ICMP type and code use the transport source and |
| 679 | * destination port fields, respectively. */ |
| 680 | #define icmp_type tp_src |
| 681 | #define icmp_code tp_dst |
| 682 | |
| 683 | /* Value used in "idle_timeout" and "hard_timeout" to indicate that the entry |
| 684 | * is permanent. */ |
| 685 | #define OFP_FLOW_PERMANENT 0 |
| 686 | |
| 687 | /* By default, choose a priority in the middle. */ |
| 688 | #define OFP_DEFAULT_PRIORITY 0x8000 |
| 689 | |
| 690 | enum ofp_instruction_type { |
| 691 | OFPIT_GOTO_TABLE = 1, /* Setup the next table in the lookup |
| 692 | pipeline */ |
| 693 | OFPIT_WRITE_METADATA = 2, /* Setup the metadata field for use later in |
| 694 | pipeline */ |
| 695 | OFPIT_WRITE_ACTIONS = 3, /* Write the action(s) onto the datapath action |
| 696 | set */ |
| 697 | OFPIT_APPLY_ACTIONS = 4, /* Applies the action(s) immediately */ |
| 698 | OFPIT_CLEAR_ACTIONS = 5, /* Clears all actions from the datapath |
| 699 | action set */ |
| 700 | |
| 701 | OFPIT_EXPERIMENTER = 0xFFFF /* Experimenter instruction */ |
| 702 | }; |
| 703 | |
| 704 | /* Generic ofp_instruction structure */ |
| 705 | struct ofp_instruction { |
| 706 | uint16_t type; /* Instruction type */ |
| 707 | uint16_t len; /* Length of this struct in bytes. */ |
| 708 | uint8_t pad[4]; /* Align to 64-bits */ |
| 709 | }; |
| 710 | OFP_ASSERT(sizeof(struct ofp_instruction) == 8); |
| 711 | |
| 712 | /* Instruction structure for OFPIT_GOTO_TABLE */ |
| 713 | struct ofp_instruction_goto_table { |
| 714 | uint16_t type; /* OFPIT_GOTO_TABLE */ |
| 715 | uint16_t len; /* Length of this struct in bytes. */ |
| 716 | uint8_t table_id; /* Set next table in the lookup pipeline */ |
| 717 | uint8_t pad[3]; /* Pad to 64 bits. */ |
| 718 | }; |
| 719 | OFP_ASSERT(sizeof(struct ofp_instruction_goto_table) == 8); |
| 720 | |
| 721 | /* Instruction structure for OFPIT_WRITE_METADATA */ |
| 722 | struct ofp_instruction_write_metadata { |
| 723 | uint16_t type; /* OFPIT_WRITE_METADATA */ |
| 724 | uint16_t len; /* Length of this struct in bytes. */ |
| 725 | uint8_t pad[4]; /* Align to 64-bits */ |
| 726 | uint64_t metadata; /* Metadata value to write */ |
| 727 | uint64_t metadata_mask; /* Metadata write bitmask */ |
| 728 | }; |
| 729 | OFP_ASSERT(sizeof(struct ofp_instruction_write_metadata) == 24); |
| 730 | |
| 731 | /* Instruction structure for OFPIT_WRITE/APPLY/CLEAR_ACTIONS */ |
| 732 | struct ofp_instruction_actions { |
| 733 | uint16_t type; /* One of OFPIT_*_ACTIONS */ |
| 734 | uint16_t len; /* Length of this struct in bytes. */ |
| 735 | uint8_t pad[4]; /* Align to 64-bits */ |
| 736 | struct ofp_action_header actions[0]; /* Actions associated with |
| 737 | OFPIT_WRITE_ACTIONS and |
| 738 | OFPIT_APPLY_ACTIONS */ |
| 739 | }; |
| 740 | OFP_ASSERT(sizeof(struct ofp_instruction_actions) == 8); |
| 741 | |
| 742 | /* Instruction structure for experimental instructions */ |
| 743 | struct ofp_instruction_experimenter { |
| 744 | uint16_t type; /* OFPIT_EXPERIMENTER */ |
| 745 | uint16_t len; /* Length of this struct in bytes */ |
| 746 | uint32_t experimenter; /* Experimenter ID: |
| 747 | * - MSB 0: low-order bytes are IEEE OUI. |
| 748 | * - MSB != 0: defined by OpenFlow |
| 749 | * consortium. */ |
| 750 | /* Experimenter-defined arbitrary additional data. */ |
| 751 | }; |
| 752 | OFP_ASSERT(sizeof(struct ofp_instruction_experimenter) == 8); |
| 753 | |
| 754 | enum ofp_flow_mod_flags { |
| 755 | OFPFF_SEND_FLOW_REM = 1 << 0, /* Send flow removed message when flow |
| 756 | * expires or is deleted. */ |
| 757 | OFPFF_CHECK_OVERLAP = 1 << 1 /* Check for overlapping entries first. */ |
| 758 | }; |
| 759 | |
| 760 | /* Flow setup and teardown (controller -> datapath). */ |
| 761 | struct ofp_flow_mod { |
| 762 | struct ofp_header header; |
| 763 | uint64_t cookie; /* Opaque controller-issued identifier. */ |
| 764 | uint64_t cookie_mask; /* Mask used to restrict the cookie bits |
| 765 | that must match when the command is |
| 766 | OFPFC_MODIFY* or OFPFC_DELETE*. A value |
| 767 | of 0 indicates no restriction. */ |
| 768 | |
| 769 | /* Flow actions. */ |
| 770 | uint8_t table_id; /* ID of the table to put the flow in */ |
| 771 | uint8_t command; /* One of OFPFC_*. */ |
| 772 | uint16_t idle_timeout; /* Idle time before discarding (seconds). */ |
| 773 | uint16_t hard_timeout; /* Max time before discarding (seconds). */ |
| 774 | uint16_t priority; /* Priority level of flow entry. */ |
| 775 | uint32_t buffer_id; /* Buffered packet to apply to (or -1). |
| 776 | Not meaningful for OFPFC_DELETE*. */ |
| 777 | uint32_t out_port; /* For OFPFC_DELETE* commands, require |
| 778 | matching entries to include this as an |
| 779 | output port. A value of OFPP_ANY |
| 780 | indicates no restriction. */ |
| 781 | uint32_t out_group; /* For OFPFC_DELETE* commands, require |
| 782 | matching entries to include this as an |
| 783 | output group. A value of OFPG_ANY |
| 784 | indicates no restriction. */ |
| 785 | uint16_t flags; /* One of OFPFF_*. */ |
| 786 | uint8_t pad[2]; |
| 787 | struct ofp_match match; /* Fields to match */ |
| 788 | struct ofp_instruction instructions[0]; /* Instruction set */ |
| 789 | }; |
| 790 | OFP_ASSERT(sizeof(struct ofp_flow_mod) == 136); |
| 791 | |
| 792 | /* Group numbering. Groups can use any number up to OFPG_MAX. */ |
| 793 | enum ofp_group { |
| 794 | /* Last usable group number. */ |
| 795 | OFPG_MAX = 0xffffff00, |
| 796 | |
| 797 | /* Fake groups. */ |
| 798 | OFPG_ALL = 0xfffffffc, /* Represents all groups for group delete |
| 799 | commands. */ |
| 800 | OFPG_ANY = 0xffffffff /* Wildcard group used only for flow stats |
| 801 | requests. Selects all flows regardless of |
| 802 | group (including flows with no group). |
| 803 | */ |
| 804 | }; |
| 805 | |
| 806 | /* Bucket for use in groups. */ |
| 807 | struct ofp_bucket { |
| 808 | uint16_t len; /* Length the bucket in bytes, including |
| 809 | this header and any padding to make it |
| 810 | 64-bit aligned. */ |
| 811 | uint16_t weight; /* Relative weight of bucket. Only |
| 812 | defined for select groups. */ |
| 813 | uint32_t watch_port; /* Port whose state affects whether this |
| 814 | bucket is live. Only required for fast |
| 815 | failover groups. */ |
| 816 | uint32_t watch_group; /* Group whose state affects whether this |
| 817 | bucket is live. Only required for fast |
| 818 | failover groups. */ |
| 819 | uint8_t pad[4]; |
| 820 | struct ofp_action_header actions[0]; /* The action length is inferred |
| 821 | from the length field in the |
| 822 | header. */ |
| 823 | }; |
| 824 | OFP_ASSERT(sizeof(struct ofp_bucket) == 16); |
| 825 | |
| 826 | /* Group setup and teardown (controller -> datapath). */ |
| 827 | struct ofp_group_mod { |
| 828 | struct ofp_header header; |
| 829 | uint16_t command; /* One of OFPGC_*. */ |
| 830 | uint8_t type; /* One of OFPGT_*. */ |
| 831 | uint8_t pad; /* Pad to 64 bits. */ |
| 832 | uint32_t group_id; /* Group identifier. */ |
| 833 | struct ofp_bucket buckets[0]; /* The bucket length is inferred from the |
| 834 | length field in the header. */ |
| 835 | }; |
| 836 | OFP_ASSERT(sizeof(struct ofp_group_mod) == 16); |
| 837 | |
| 838 | /* Group types. Values in the range [128, 255] are reserved for experimental |
| 839 | * use. */ |
| 840 | enum ofp_group_type { |
| 841 | OFPGT_ALL, /* All (multicast/broadcast) group. */ |
| 842 | OFPGT_SELECT, /* Select group. */ |
| 843 | OFPGT_INDIRECT, /* Indirect group. */ |
| 844 | OFPGT_FF /* Fast failover group. */ |
| 845 | }; |
| 846 | |
| 847 | /* Why was this flow removed? */ |
| 848 | enum ofp_flow_removed_reason { |
| 849 | OFPRR_IDLE_TIMEOUT, /* Flow idle time exceeded idle_timeout. */ |
| 850 | OFPRR_HARD_TIMEOUT, /* Time exceeded hard_timeout. */ |
| 851 | OFPRR_DELETE, /* Evicted by a DELETE flow mod. */ |
| 852 | OFPRR_GROUP_DELETE /* Group was removed. */ |
| 853 | }; |
| 854 | |
| 855 | /* Flow removed (datapath -> controller). */ |
| 856 | struct ofp_flow_removed { |
| 857 | struct ofp_header header; |
| 858 | uint64_t cookie; /* Opaque controller-issued identifier. */ |
| 859 | |
| 860 | uint16_t priority; /* Priority level of flow entry. */ |
| 861 | uint8_t reason; /* One of OFPRR_*. */ |
| 862 | uint8_t table_id; /* ID of the table */ |
| 863 | |
| 864 | uint32_t duration_sec; /* Time flow was alive in seconds. */ |
| 865 | uint32_t duration_nsec; /* Time flow was alive in nanoseconds beyond |
| 866 | duration_sec. */ |
| 867 | uint16_t idle_timeout; /* Idle timeout from original flow mod. */ |
| 868 | uint8_t pad2[2]; /* Align to 64-bits. */ |
| 869 | uint64_t packet_count; |
| 870 | uint64_t byte_count; |
| 871 | struct ofp_match match; /* Description of fields. */ |
| 872 | }; |
| 873 | OFP_ASSERT(sizeof(struct ofp_flow_removed) == 136); |
| 874 | |
| 875 | /* Values for 'type' in ofp_error_message. These values are immutable: they |
| 876 | * will not change in future versions of the protocol (although new values may |
| 877 | * be added). */ |
| 878 | enum ofp_error_type { |
| 879 | OFPET_HELLO_FAILED, /* Hello protocol failed. */ |
| 880 | OFPET_BAD_REQUEST, /* Request was not understood. */ |
| 881 | OFPET_BAD_ACTION, /* Error in action description. */ |
| 882 | OFPET_BAD_INSTRUCTION, /* Error in instruction list. */ |
| 883 | OFPET_BAD_MATCH, /* Error in match. */ |
| 884 | OFPET_FLOW_MOD_FAILED, /* Problem modifying flow entry. */ |
| 885 | OFPET_GROUP_MOD_FAILED, /* Problem modifying group entry. */ |
| 886 | OFPET_PORT_MOD_FAILED, /* Port mod request failed. */ |
| 887 | OFPET_TABLE_MOD_FAILED, /* Table mod request failed. */ |
| 888 | OFPET_QUEUE_OP_FAILED, /* Queue operation failed. */ |
| 889 | OFPET_SWITCH_CONFIG_FAILED, /* Switch config request failed. */ |
| 890 | }; |
| 891 | |
| 892 | /* ofp_error_msg 'code' values for OFPET_HELLO_FAILED. 'data' contains an |
| 893 | * ASCII text string that may give failure details. */ |
| 894 | enum ofp_hello_failed_code { |
| 895 | OFPHFC_INCOMPATIBLE, /* No compatible version. */ |
| 896 | OFPHFC_EPERM /* Permissions error. */ |
| 897 | }; |
| 898 | |
| 899 | /* ofp_error_msg 'code' values for OFPET_BAD_REQUEST. 'data' contains at least |
| 900 | * the first 64 bytes of the failed request. */ |
| 901 | enum ofp_bad_request_code { |
| 902 | OFPBRC_BAD_VERSION, /* ofp_header.version not supported. */ |
| 903 | OFPBRC_BAD_TYPE, /* ofp_header.type not supported. */ |
| 904 | OFPBRC_BAD_STAT, /* ofp_stats_request.type not supported. */ |
| 905 | OFPBRC_BAD_EXPERIMENTER, /* Experimenter id not supported |
| 906 | * (in ofp_experimenter_header |
| 907 | * or ofp_stats_request or ofp_stats_reply). */ |
| 908 | OFPBRC_BAD_SUBTYPE, /* Experimenter subtype not supported. */ |
| 909 | OFPBRC_EPERM, /* Permissions error. */ |
| 910 | OFPBRC_BAD_LEN, /* Wrong request length for type. */ |
| 911 | OFPBRC_BUFFER_EMPTY, /* Specified buffer has already been used. */ |
| 912 | OFPBRC_BUFFER_UNKNOWN, /* Specified buffer does not exist. */ |
| 913 | OFPBRC_BAD_TABLE_ID /* Specified table-id invalid or does not |
| 914 | * exist. */ |
| 915 | }; |
| 916 | |
| 917 | /* ofp_error_msg 'code' values for OFPET_BAD_ACTION. 'data' contains at least |
| 918 | * the first 64 bytes of the failed request. */ |
| 919 | enum ofp_bad_action_code { |
| 920 | OFPBAC_BAD_TYPE, /* Unknown action type. */ |
| 921 | OFPBAC_BAD_LEN, /* Length problem in actions. */ |
| 922 | OFPBAC_BAD_EXPERIMENTER, /* Unknown experimenter id specified. */ |
| 923 | OFPBAC_BAD_EXPERIMENTER_TYPE, /* Unknown action type for experimenter id. */ |
| 924 | OFPBAC_BAD_OUT_PORT, /* Problem validating output port. */ |
| 925 | OFPBAC_BAD_ARGUMENT, /* Bad action argument. */ |
| 926 | OFPBAC_EPERM, /* Permissions error. */ |
| 927 | OFPBAC_TOO_MANY, /* Can't handle this many actions. */ |
| 928 | OFPBAC_BAD_QUEUE, /* Problem validating output queue. */ |
| 929 | OFPBAC_BAD_OUT_GROUP, /* Invalid group id in forward action. */ |
| 930 | OFPBAC_MATCH_INCONSISTENT, /* Action can't apply for this match. */ |
| 931 | OFPBAC_UNSUPPORTED_ORDER, /* Action order is unsupported for the action |
| 932 | list in an Apply-Actions instruction */ |
| 933 | OFPBAC_BAD_TAG, /* Actions uses an unsupported |
| 934 | tag/encap. */ |
| 935 | }; |
| 936 | |
| 937 | /* ofp_error_msg 'code' values for OFPET_BAD_INSTRUCTION. 'data' contains at least |
| 938 | * the first 64 bytes of the failed request. */ |
| 939 | enum ofp_bad_instruction_code { |
| 940 | OFPBIC_UNKNOWN_INST, /* Unknown instruction. */ |
| 941 | OFPBIC_UNSUP_INST, /* Switch or table does not support the |
| 942 | instruction. */ |
| 943 | OFPBIC_BAD_TABLE_ID, /* Invalid Table-ID specified. */ |
| 944 | OFPBIC_UNSUP_METADATA, /* Metadata value unsupported by datapath. */ |
| 945 | OFPBIC_UNSUP_METADATA_MASK,/* Metadata mask value unsupported by |
| 946 | datapath. */ |
| 947 | OFPBIC_UNSUP_EXP_INST, /* Specific experimenter instruction |
| 948 | unsupported. */ |
| 949 | }; |
| 950 | |
| 951 | /* ofp_error_msg 'code' values for OFPET_BAD_MATCH. 'data' contains at least |
| 952 | * the first 64 bytes of the failed request. */ |
| 953 | enum ofp_bad_match_code { |
| 954 | OFPBMC_BAD_TYPE, /* Unsupported match type specified by the |
| 955 | match */ |
| 956 | OFPBMC_BAD_LEN, /* Length problem in match. */ |
| 957 | OFPBMC_BAD_TAG, /* Match uses an unsupported tag/encap. */ |
| 958 | OFPBMC_BAD_DL_ADDR_MASK, /* Unsupported datalink addr mask - switch does |
| 959 | not support arbitrary datalink address |
| 960 | mask. */ |
| 961 | OFPBMC_BAD_NW_ADDR_MASK, /* Unsupported network addr mask - switch does |
| 962 | not support arbitrary network address |
| 963 | mask. */ |
| 964 | OFPBMC_BAD_WILDCARDS, /* Unsupported wildcard specified in the |
| 965 | match. */ |
| 966 | OFPBMC_BAD_FIELD, /* Unsupported field in the match. */ |
| 967 | OFPBMC_BAD_VALUE, /* Unsupported value in a match field. */ |
| 968 | }; |
| 969 | |
| 970 | /* ofp_error_msg 'code' values for OFPET_FLOW_MOD_FAILED. 'data' contains |
| 971 | * at least the first 64 bytes of the failed request. */ |
| 972 | enum ofp_flow_mod_failed_code { |
| 973 | OFPFMFC_UNKNOWN, /* Unspecified error. */ |
| 974 | OFPFMFC_TABLE_FULL, /* Flow not added because table was full. */ |
| 975 | OFPFMFC_BAD_TABLE_ID, /* Table does not exist */ |
| 976 | OFPFMFC_OVERLAP, /* Attempted to add overlapping flow with |
| 977 | CHECK_OVERLAP flag set. */ |
| 978 | OFPFMFC_EPERM, /* Permissions error. */ |
| 979 | OFPFMFC_BAD_TIMEOUT, /* Flow not added because of unsupported |
| 980 | idle/hard timeout. */ |
| 981 | OFPFMFC_BAD_COMMAND, /* Unsupported or unknown command. */ |
| 982 | }; |
| 983 | |
| 984 | /* ofp_error_msg 'code' values for OFPET_GROUP_MOD_FAILED. 'data' contains |
| 985 | * at least the first 64 bytes of the failed request. */ |
| 986 | enum ofp_group_mod_failed_code { |
| 987 | OFPGMFC_GROUP_EXISTS, /* Group not added because a group ADD |
| 988 | * attempted to replace an |
| 989 | * already-present group. */ |
| 990 | OFPGMFC_INVALID_GROUP, /* Group not added because Group specified |
| 991 | * is invalid. */ |
| 992 | OFPGMFC_WEIGHT_UNSUPPORTED, /* Switch does not support unequal load |
| 993 | * sharing with select groups. */ |
| 994 | OFPGMFC_OUT_OF_GROUPS, /* The group table is full. */ |
| 995 | OFPGMFC_OUT_OF_BUCKETS, /* The maximum number of action buckets |
| 996 | * for a group has been exceeded. */ |
| 997 | OFPGMFC_CHAINING_UNSUPPORTED, /* Switch does not support groups that |
| 998 | * forward to groups. */ |
| 999 | OFPGMFC_WATCH_UNSUPPORTED, /* This group cannot watch the |
| 1000 | watch_port or watch_group specified. */ |
| 1001 | OFPGMFC_LOOP, /* Group entry would cause a loop. */ |
| 1002 | OFPGMFC_UNKNOWN_GROUP, /* Group not modified because a group |
| 1003 | MODIFY attempted to modify a |
| 1004 | non-existent group. */ |
| 1005 | }; |
| 1006 | |
| 1007 | /* ofp_error_msg 'code' values for OFPET_PORT_MOD_FAILED. 'data' contains |
| 1008 | * at least the first 64 bytes of the failed request. */ |
| 1009 | enum ofp_port_mod_failed_code { |
| 1010 | OFPPMFC_BAD_PORT, /* Specified port number does not exist. */ |
| 1011 | OFPPMFC_BAD_HW_ADDR, /* Specified hardware address does not |
| 1012 | * match the port number. */ |
| 1013 | OFPPMFC_BAD_CONFIG, /* Specified config is invalid. */ |
| 1014 | OFPPMFC_BAD_ADVERTISE /* Specified advertise is invalid. */ |
| 1015 | }; |
| 1016 | |
| 1017 | /* ofp_error_msg 'code' values for OFPET_TABLE_MOD_FAILED. 'data' contains |
| 1018 | * at least the first 64 bytes of the failed request. */ |
| 1019 | enum ofp_table_mod_failed_code { |
| 1020 | OFPTMFC_BAD_TABLE, /* Specified table does not exist. */ |
| 1021 | OFPTMFC_BAD_CONFIG /* Specified config is invalid. */ |
| 1022 | }; |
| 1023 | |
| 1024 | /* ofp_error msg 'code' values for OFPET_QUEUE_OP_FAILED. 'data' contains |
| 1025 | * at least the first 64 bytes of the failed request */ |
| 1026 | enum ofp_queue_op_failed_code { |
| 1027 | OFPQOFC_BAD_PORT, /* Invalid port (or port does not exist). */ |
| 1028 | OFPQOFC_BAD_QUEUE, /* Queue does not exist. */ |
| 1029 | OFPQOFC_EPERM /* Permissions error. */ |
| 1030 | }; |
| 1031 | |
| 1032 | /* ofp_error_msg 'code' values for OFPET_SWITCH_CONFIG_FAILED. 'data' contains |
| 1033 | * at least the first 64 bytes of the failed request. */ |
| 1034 | enum ofp_switch_config_failed_code { |
| 1035 | OFPSCFC_BAD_FLAGS, /* Specified flags is invalid. */ |
| 1036 | OFPSCFC_BAD_LEN /* Specified len is invalid. */ |
| 1037 | }; |
| 1038 | |
| 1039 | /* OFPT_ERROR: Error message (datapath -> controller). */ |
| 1040 | struct ofp_error_msg { |
| 1041 | struct ofp_header header; |
| 1042 | |
| 1043 | uint16_t type; |
| 1044 | uint16_t code; |
| 1045 | uint8_t data[0]; /* Variable-length data. Interpreted based |
| 1046 | on the type and code. No padding. */ |
| 1047 | }; |
| 1048 | OFP_ASSERT(sizeof(struct ofp_error_msg) == 12); |
| 1049 | |
| 1050 | enum ofp_stats_types { |
| 1051 | /* Description of this OpenFlow switch. |
| 1052 | * The request body is empty. |
| 1053 | * The reply body is struct ofp_desc_stats. */ |
| 1054 | OFPST_DESC, |
| 1055 | |
| 1056 | /* Individual flow statistics. |
| 1057 | * The request body is struct ofp_flow_stats_request. |
| 1058 | * The reply body is an array of struct ofp_flow_stats. */ |
| 1059 | OFPST_FLOW, |
| 1060 | |
| 1061 | /* Aggregate flow statistics. |
| 1062 | * The request body is struct ofp_aggregate_stats_request. |
| 1063 | * The reply body is struct ofp_aggregate_stats_reply. */ |
| 1064 | OFPST_AGGREGATE, |
| 1065 | |
| 1066 | /* Flow table statistics. |
| 1067 | * The request body is empty. |
| 1068 | * The reply body is an array of struct ofp_table_stats. */ |
| 1069 | OFPST_TABLE, |
| 1070 | |
| 1071 | /* Port statistics. |
| 1072 | * The request body is struct ofp_port_stats_request. |
| 1073 | * The reply body is an array of struct ofp_port_stats. */ |
| 1074 | OFPST_PORT, |
| 1075 | |
| 1076 | /* Queue statistics for a port |
| 1077 | * The request body defines the port |
| 1078 | * The reply body is an array of struct ofp_queue_stats */ |
| 1079 | OFPST_QUEUE, |
| 1080 | |
| 1081 | /* Group counter statistics. |
| 1082 | * The request body is empty. |
| 1083 | * The reply is struct ofp_group_stats. */ |
| 1084 | OFPST_GROUP, |
| 1085 | |
| 1086 | /* Group description statistics. |
| 1087 | * The request body is empty. |
| 1088 | * The reply body is struct ofp_group_desc_stats. */ |
| 1089 | OFPST_GROUP_DESC, |
| 1090 | |
| 1091 | /* Experimenter extension. |
| 1092 | * The request and reply bodies begin with a 32-bit experimenter ID, |
| 1093 | * which takes the same form as in "struct ofp_experimenter_header". |
| 1094 | * The request and reply bodies are otherwise experimenter-defined. */ |
| 1095 | OFPST_EXPERIMENTER = 0xffff |
| 1096 | }; |
| 1097 | |
| 1098 | struct ofp_stats_request { |
| 1099 | struct ofp_header header; |
| 1100 | uint16_t type; /* One of the OFPST_* constants. */ |
| 1101 | uint16_t flags; /* OFPSF_REQ_* flags (none yet defined). */ |
| 1102 | uint8_t pad[4]; |
| 1103 | uint8_t body[0]; /* Body of the request. */ |
| 1104 | }; |
| 1105 | OFP_ASSERT(sizeof(struct ofp_stats_request) == 16); |
| 1106 | |
| 1107 | enum ofp_stats_reply_flags { |
| 1108 | OFPSF_REPLY_MORE = 1 << 0 /* More replies to follow. */ |
| 1109 | }; |
| 1110 | |
| 1111 | struct ofp_stats_reply { |
| 1112 | struct ofp_header header; |
| 1113 | uint16_t type; /* One of the OFPST_* constants. */ |
| 1114 | uint16_t flags; /* OFPSF_REPLY_* flags. */ |
| 1115 | uint8_t pad[4]; |
| 1116 | uint8_t body[0]; /* Body of the reply. */ |
| 1117 | }; |
| 1118 | OFP_ASSERT(sizeof(struct ofp_stats_reply) == 16); |
| 1119 | |
| 1120 | #define DESC_STR_LEN 256 |
| 1121 | #define SERIAL_NUM_LEN 32 |
| 1122 | /* Body of reply to OFPST_DESC request. Each entry is a NULL-terminated |
| 1123 | * ASCII string. */ |
| 1124 | struct ofp_desc_stats { |
| 1125 | char mfr_desc[DESC_STR_LEN]; /* Manufacturer description. */ |
| 1126 | char hw_desc[DESC_STR_LEN]; /* Hardware description. */ |
| 1127 | char sw_desc[DESC_STR_LEN]; /* Software description. */ |
| 1128 | char serial_num[SERIAL_NUM_LEN]; /* Serial number. */ |
| 1129 | char dp_desc[DESC_STR_LEN]; /* Human readable description of datapath. */ |
| 1130 | }; |
| 1131 | OFP_ASSERT(sizeof(struct ofp_desc_stats) == 1056); |
| 1132 | |
| 1133 | /* Body for ofp_stats_request of type OFPST_FLOW. */ |
| 1134 | struct ofp_flow_stats_request { |
| 1135 | uint8_t table_id; /* ID of table to read (from ofp_table_stats), |
| 1136 | 0xff for all tables. */ |
| 1137 | uint8_t pad[3]; /* Align to 64 bits. */ |
| 1138 | uint32_t out_port; /* Require matching entries to include this |
| 1139 | as an output port. A value of OFPP_ANY |
| 1140 | indicates no restriction. */ |
| 1141 | uint32_t out_group; /* Require matching entries to include this |
| 1142 | as an output group. A value of OFPG_ANY |
| 1143 | indicates no restriction. */ |
| 1144 | uint8_t pad2[4]; /* Align to 64 bits. */ |
| 1145 | uint64_t cookie; /* Require matching entries to contain this |
| 1146 | cookie value */ |
| 1147 | uint64_t cookie_mask; /* Mask used to restrict the cookie bits that |
| 1148 | must match. A value of 0 indicates |
| 1149 | no restriction. */ |
| 1150 | struct ofp_match match; /* Fields to match. */ |
| 1151 | }; |
| 1152 | OFP_ASSERT(sizeof(struct ofp_flow_stats_request) == 120); |
| 1153 | |
| 1154 | /* Body of reply to OFPST_FLOW request. */ |
| 1155 | struct ofp_flow_stats { |
| 1156 | uint16_t length; /* Length of this entry. */ |
| 1157 | uint8_t table_id; /* ID of table flow came from. */ |
| 1158 | uint8_t pad; |
| 1159 | uint32_t duration_sec; /* Time flow has been alive in seconds. */ |
| 1160 | uint32_t duration_nsec; /* Time flow has been alive in nanoseconds beyond |
| 1161 | duration_sec. */ |
| 1162 | uint16_t priority; /* Priority of the entry. Only meaningful |
| 1163 | when this is not an exact-match entry. */ |
| 1164 | uint16_t idle_timeout; /* Number of seconds idle before expiration. */ |
| 1165 | uint16_t hard_timeout; /* Number of seconds before expiration. */ |
| 1166 | uint8_t pad2[6]; /* Align to 64-bits. */ |
| 1167 | uint64_t cookie; /* Opaque controller-issued identifier. */ |
| 1168 | uint64_t packet_count; /* Number of packets in flow. */ |
| 1169 | uint64_t byte_count; /* Number of bytes in flow. */ |
| 1170 | struct ofp_match match; /* Description of fields. */ |
| 1171 | struct ofp_instruction instructions[0]; /* Instruction set. */ |
| 1172 | }; |
| 1173 | OFP_ASSERT(sizeof(struct ofp_flow_stats) == 136); |
| 1174 | |
| 1175 | /* Body for ofp_stats_request of type OFPST_AGGREGATE. */ |
| 1176 | struct ofp_aggregate_stats_request { |
| 1177 | uint8_t table_id; /* ID of table to read (from ofp_table_stats) |
| 1178 | 0xff for all tables. */ |
| 1179 | uint8_t pad[3]; /* Align to 64 bits. */ |
| 1180 | uint32_t out_port; /* Require matching entries to include this |
| 1181 | as an output port. A value of OFPP_ANY |
| 1182 | indicates no restriction. */ |
| 1183 | uint32_t out_group; /* Require matching entries to include this |
| 1184 | as an output group. A value of OFPG_ANY |
| 1185 | indicates no restriction. */ |
| 1186 | uint8_t pad2[4]; /* Align to 64 bits. */ |
| 1187 | uint64_t cookie; /* Require matching entries to contain this |
| 1188 | cookie value */ |
| 1189 | uint64_t cookie_mask; /* Mask used to restrict the cookie bits that |
| 1190 | must match. A value of 0 indicates |
| 1191 | no restriction. */ |
| 1192 | struct ofp_match match; /* Fields to match. */ |
| 1193 | }; |
| 1194 | OFP_ASSERT(sizeof(struct ofp_aggregate_stats_request) == 120); |
| 1195 | |
| 1196 | /* Body of reply to OFPST_AGGREGATE request. */ |
| 1197 | struct ofp_aggregate_stats_reply { |
| 1198 | uint64_t packet_count; /* Number of packets in flows. */ |
| 1199 | uint64_t byte_count; /* Number of bytes in flows. */ |
| 1200 | uint32_t flow_count; /* Number of flows. */ |
| 1201 | uint8_t pad[4]; /* Align to 64 bits. */ |
| 1202 | }; |
| 1203 | OFP_ASSERT(sizeof(struct ofp_aggregate_stats_reply) == 24); |
| 1204 | |
| 1205 | /* Flow match fields. */ |
| 1206 | enum ofp_flow_match_fields { |
| 1207 | OFPFMF_IN_PORT = 1 << 0, /* Switch input port. */ |
| 1208 | OFPFMF_DL_VLAN = 1 << 1, /* VLAN id. */ |
| 1209 | OFPFMF_DL_VLAN_PCP = 1 << 2, /* VLAN priority. */ |
| 1210 | OFPFMF_DL_TYPE = 1 << 3, /* Ethernet frame type. */ |
| 1211 | OFPFMF_NW_TOS = 1 << 4, /* IP ToS (DSCP field, 6 bits). */ |
| 1212 | OFPFMF_NW_PROTO = 1 << 5, /* IP protocol. */ |
| 1213 | OFPFMF_TP_SRC = 1 << 6, /* TCP/UDP/SCTP source port. */ |
| 1214 | OFPFMF_TP_DST = 1 << 7, /* TCP/UDP/SCTP destination port. */ |
| 1215 | OFPFMF_MPLS_LABEL = 1 << 8, /* MPLS label. */ |
| 1216 | OFPFMF_MPLS_TC = 1 << 9, /* MPLS TC. */ |
| 1217 | OFPFMF_TYPE = 1 << 10, /* Match type. */ |
| 1218 | OFPFMF_DL_SRC = 1 << 11, /* Ethernet source address. */ |
| 1219 | OFPFMF_DL_DST = 1 << 12, /* Ethernet destination address. */ |
| 1220 | OFPFMF_NW_SRC = 1 << 13, /* IP source address. */ |
| 1221 | OFPFMF_NW_DST = 1 << 14, /* IP destination address. */ |
| 1222 | OFPFMF_METADATA = 1 << 15, /* Metadata passed between tables. */ |
| 1223 | }; |
| 1224 | |
| 1225 | /* Body of reply to OFPST_TABLE request. */ |
| 1226 | struct ofp_table_stats { |
| 1227 | uint8_t table_id; /* Identifier of table. Lower numbered tables |
| 1228 | are consulted first. */ |
| 1229 | uint8_t pad[7]; /* Align to 64-bits. */ |
| 1230 | char name[OFP_MAX_TABLE_NAME_LEN]; |
| 1231 | uint32_t wildcards; /* Bitmap of OFPFMF_* wildcards that are |
| 1232 | supported by the table. */ |
| 1233 | uint32_t match; /* Bitmap of OFPFMF_* that indicate the fields |
| 1234 | the table can match on. */ |
| 1235 | uint32_t instructions; /* Bitmap of OFPIT_* values supported. */ |
| 1236 | uint32_t write_actions; /* Bitmap of OFPAT_* that are supported |
| 1237 | by the table with OFPIT_WRITE_ACTIONS. */ |
| 1238 | uint32_t apply_actions; /* Bitmap of OFPAT_* that are supported |
| 1239 | by the table with OFPIT_APPLY_ACTIONS. */ |
| 1240 | uint32_t config; /* Bitmap of OFPTC_* values */ |
| 1241 | uint32_t max_entries; /* Max number of entries supported. */ |
| 1242 | uint32_t active_count; /* Number of active entries. */ |
| 1243 | uint64_t lookup_count; /* Number of packets looked up in table. */ |
| 1244 | uint64_t matched_count; /* Number of packets that hit table. */ |
| 1245 | }; |
| 1246 | OFP_ASSERT(sizeof(struct ofp_table_stats) == 88); |
| 1247 | |
| 1248 | /* Body for ofp_stats_request of type OFPST_PORT. */ |
| 1249 | struct ofp_port_stats_request { |
| 1250 | uint32_t port_no; /* OFPST_PORT message must request statistics |
| 1251 | * either for a single port (specified in |
| 1252 | * port_no) or for all ports (if port_no == |
| 1253 | * OFPP_ANY). */ |
| 1254 | uint8_t pad[4]; |
| 1255 | }; |
| 1256 | OFP_ASSERT(sizeof(struct ofp_port_stats_request) == 8); |
| 1257 | |
| 1258 | /* Body of reply to OFPST_PORT request. If a counter is unsupported, set |
| 1259 | * the field to all ones. */ |
| 1260 | struct ofp_port_stats { |
| 1261 | uint32_t port_no; |
| 1262 | uint8_t pad[4]; /* Align to 64-bits. */ |
| 1263 | uint64_t rx_packets; /* Number of received packets. */ |
| 1264 | uint64_t tx_packets; /* Number of transmitted packets. */ |
| 1265 | uint64_t rx_bytes; /* Number of received bytes. */ |
| 1266 | uint64_t tx_bytes; /* Number of transmitted bytes. */ |
| 1267 | uint64_t rx_dropped; /* Number of packets dropped by RX. */ |
| 1268 | uint64_t tx_dropped; /* Number of packets dropped by TX. */ |
| 1269 | uint64_t rx_errors; /* Number of receive errors. This is a super-set |
| 1270 | of more specific receive errors and should be |
| 1271 | greater than or equal to the sum of all |
| 1272 | rx_*_err values. */ |
| 1273 | uint64_t tx_errors; /* Number of transmit errors. This is a super-set |
| 1274 | of more specific transmit errors and should be |
| 1275 | greater than or equal to the sum of all |
| 1276 | tx_*_err values (none currently defined.) */ |
| 1277 | uint64_t rx_frame_err; /* Number of frame alignment errors. */ |
| 1278 | uint64_t rx_over_err; /* Number of packets with RX overrun. */ |
| 1279 | uint64_t rx_crc_err; /* Number of CRC errors. */ |
| 1280 | uint64_t collisions; /* Number of collisions. */ |
| 1281 | }; |
| 1282 | OFP_ASSERT(sizeof(struct ofp_port_stats) == 104); |
| 1283 | |
| 1284 | /* Body of OFPST_GROUP request. */ |
| 1285 | struct ofp_group_stats_request { |
| 1286 | uint32_t group_id; /* All groups if OFPG_ALL. */ |
| 1287 | uint8_t pad[4]; /* Align to 64 bits. */ |
| 1288 | }; |
| 1289 | OFP_ASSERT(sizeof(struct ofp_group_stats_request) == 8); |
| 1290 | |
| 1291 | /* Used in group stats replies. */ |
| 1292 | struct ofp_bucket_counter { |
| 1293 | uint64_t packet_count; /* Number of packets processed by bucket. */ |
| 1294 | uint64_t byte_count; /* Number of bytes processed by bucket. */ |
| 1295 | }; |
| 1296 | OFP_ASSERT(sizeof(struct ofp_bucket_counter) == 16); |
| 1297 | |
| 1298 | /* Body of reply to OFPST_GROUP request. */ |
| 1299 | struct ofp_group_stats { |
| 1300 | uint16_t length; /* Length of this entry. */ |
| 1301 | uint8_t pad[2]; /* Align to 64 bits. */ |
| 1302 | uint32_t group_id; /* Group identifier. */ |
| 1303 | uint32_t ref_count; /* Number of flows or groups that directly forward |
| 1304 | to this group. */ |
| 1305 | uint8_t pad2[4]; /* Align to 64 bits. */ |
| 1306 | uint64_t packet_count; /* Number of packets processed by group. */ |
| 1307 | uint64_t byte_count; /* Number of bytes processed by group. */ |
| 1308 | struct ofp_bucket_counter bucket_stats[0]; |
| 1309 | }; |
| 1310 | OFP_ASSERT(sizeof(struct ofp_group_stats) == 32); |
| 1311 | |
| 1312 | /* Body of reply to OFPST_GROUP_DESC request. */ |
| 1313 | struct ofp_group_desc_stats { |
| 1314 | uint16_t length; /* Length of this entry. */ |
| 1315 | uint8_t type; /* One of OFPGT_*. */ |
| 1316 | uint8_t pad; /* Pad to 64 bits. */ |
| 1317 | uint32_t group_id; /* Group identifier. */ |
| 1318 | struct ofp_bucket buckets[0]; |
| 1319 | }; |
| 1320 | OFP_ASSERT(sizeof(struct ofp_group_desc_stats) == 8); |
| 1321 | |
| 1322 | /* Experimenter extension. */ |
| 1323 | struct ofp_experimenter_header { |
| 1324 | struct ofp_header header; /* Type OFPT_EXPERIMENTER. */ |
| 1325 | uint32_t experimenter; /* Experimenter ID: |
| 1326 | * - MSB 0: low-order bytes are IEEE OUI. |
| 1327 | * - MSB != 0: defined by OpenFlow |
| 1328 | * consortium. */ |
| 1329 | uint8_t pad[4]; |
| 1330 | /* Experimenter-defined arbitrary additional data. */ |
| 1331 | }; |
| 1332 | OFP_ASSERT(sizeof(struct ofp_experimenter_header) == 16); |
| 1333 | |
| 1334 | /* All ones is used to indicate all queues in a port (for stats retrieval). */ |
| 1335 | #define OFPQ_ALL 0xffffffff |
| 1336 | |
| 1337 | /* Min rate > 1000 means not configured. */ |
| 1338 | #define OFPQ_MIN_RATE_UNCFG 0xffff |
| 1339 | |
| 1340 | enum ofp_queue_properties { |
| 1341 | OFPQT_NONE = 0, /* No property defined for queue (default). */ |
| 1342 | OFPQT_MIN_RATE, /* Minimum datarate guaranteed. */ |
| 1343 | /* Other types should be added here |
| 1344 | * (i.e. max rate, precedence, etc). */ |
| 1345 | }; |
| 1346 | |
| 1347 | /* Common description for a queue. */ |
| 1348 | struct ofp_queue_prop_header { |
| 1349 | uint16_t property; /* One of OFPQT_. */ |
| 1350 | uint16_t len; /* Length of property, including this header. */ |
| 1351 | uint8_t pad[4]; /* 64-bit alignemnt. */ |
| 1352 | }; |
| 1353 | OFP_ASSERT(sizeof(struct ofp_queue_prop_header) == 8); |
| 1354 | |
| 1355 | /* Min-Rate queue property description. */ |
| 1356 | struct ofp_queue_prop_min_rate { |
| 1357 | struct ofp_queue_prop_header prop_header; /* prop: OFPQT_MIN, len: 16. */ |
| 1358 | uint16_t rate; /* In 1/10 of a percent; >1000 -> disabled. */ |
| 1359 | uint8_t pad[6]; /* 64-bit alignment */ |
| 1360 | }; |
| 1361 | OFP_ASSERT(sizeof(struct ofp_queue_prop_min_rate) == 16); |
| 1362 | |
| 1363 | /* Full description for a queue. */ |
| 1364 | struct ofp_packet_queue { |
| 1365 | uint32_t queue_id; /* id for the specific queue. */ |
| 1366 | uint16_t len; /* Length in bytes of this queue desc. */ |
| 1367 | uint8_t pad[2]; /* 64-bit alignment. */ |
| 1368 | struct ofp_queue_prop_header properties[0]; /* List of properties. */ |
| 1369 | }; |
| 1370 | OFP_ASSERT(sizeof(struct ofp_packet_queue) == 8); |
| 1371 | |
| 1372 | /* Query for port queue configuration. */ |
| 1373 | struct ofp_queue_get_config_request { |
| 1374 | struct ofp_header header; |
| 1375 | uint32_t port; /* Port to be queried. Should refer |
| 1376 | to a valid physical port (i.e. < OFPP_MAX) */ |
| 1377 | uint8_t pad[4]; |
| 1378 | }; |
| 1379 | OFP_ASSERT(sizeof(struct ofp_queue_get_config_request) == 16); |
| 1380 | |
| 1381 | /* Queue configuration for a given port. */ |
| 1382 | struct ofp_queue_get_config_reply { |
| 1383 | struct ofp_header header; |
| 1384 | uint32_t port; |
| 1385 | uint8_t pad[4]; |
| 1386 | struct ofp_packet_queue queues[0]; /* List of configured queues. */ |
| 1387 | }; |
| 1388 | OFP_ASSERT(sizeof(struct ofp_queue_get_config_reply) == 16); |
| 1389 | |
| 1390 | /* OFPAT_SET_QUEUE action struct: send packets to given queue on port. */ |
| 1391 | struct ofp_action_set_queue { |
| 1392 | uint16_t type; /* OFPAT_SET_QUEUE. */ |
| 1393 | uint16_t len; /* Len is 8. */ |
| 1394 | uint32_t queue_id; /* Queue id for the packets. */ |
| 1395 | }; |
| 1396 | OFP_ASSERT(sizeof(struct ofp_action_set_queue) == 8); |
| 1397 | |
| 1398 | struct ofp_queue_stats_request { |
| 1399 | uint32_t port_no; /* All ports if OFPP_ANY. */ |
| 1400 | uint32_t queue_id; /* All queues if OFPQ_ALL. */ |
| 1401 | }; |
| 1402 | OFP_ASSERT(sizeof(struct ofp_queue_stats_request) == 8); |
| 1403 | |
| 1404 | struct ofp_queue_stats { |
| 1405 | uint32_t port_no; |
| 1406 | uint32_t queue_id; /* Queue i.d */ |
| 1407 | uint64_t tx_bytes; /* Number of transmitted bytes. */ |
| 1408 | uint64_t tx_packets; /* Number of transmitted packets. */ |
| 1409 | uint64_t tx_errors; /* Number of packets dropped due to overrun. */ |
| 1410 | }; |
| 1411 | OFP_ASSERT(sizeof(struct ofp_queue_stats) == 32); |
| 1412 | |
| 1413 | #endif /* openflow/openflow.h */ |