Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
openflow12.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford
6  * Junior University
7  *
8  * We are making the OpenFlow specification and associated documentation
9  * (Software) available for public use and benefit with the expectation
10  * that others will use, modify and enhance the Software and contribute
11  * those enhancements back to the community. However, since we would
12  * like to make the Software available for broadest use, with as few
13  * restrictions as possible permission is hereby granted, free of
14  * charge, to any person obtaining a copy of this Software to deal in
15  * the Software under the copyrights without restriction, including
16  * without limitation the rights to use, copy, modify, merge, publish,
17  * distribute, sublicense, and/or sell copies of the Software, and to
18  * permit persons to whom the Software is furnished to do so, subject to
19  * the following conditions:
20  *
21  * The above copyright notice and this permission notice shall be
22  * included in all copies or substantial portions of the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31  * SOFTWARE.
32  *
33  * The name and trademarks of copyright holder(s) may NOT be used in
34  * advertising or publicity pertaining to the Software or any
35  * derivatives without specific, written prior permission.
36  */
37 
38 /* OpenFlow: protocol between controller and datapath. */
39 
40 #ifndef _OPENFLOW_OPENFLOW12_H
41 #define _OPENFLOW_OPENFLOW12_H 1
42 
43 #include "rofl/common/openflow/openflow_common.h"
44 
45 /* Version number:
46  * Non-experimental versions released: 0x01
47  * Experimental versions released: 0x81 -- 0x99
48  */
49 /* The most significant bit being set in the version field indicates an
50  * experimental OpenFlow version.
51  */
52 
53 namespace rofl {
54 namespace openflow12 {
55 
56  enum ofp_version_t {
57  OFP_VERSION = 3,
58  };
59 
60  #define OFP12_VERSION 3
61 
62 
63  /* Header on all OpenFlow packets. */
64  struct ofp_header {
65  uint8_t version; /* OFP10_VERSION. */
66  uint8_t type; /* One of the OFP10T_ constants. */
67  uint16_t length; /* Length including this ofp10_header. */
68  uint32_t xid; /* Transaction id associated with this packet.
69  Replies use the same id as was in the request
70  to facilitate pairing. */
71  };
72  OFP_ASSERT(sizeof(struct ofp_header) == 8);
73 
74 
75  /* OFPT_ERROR: Error message (datapath -> controller). */
76  struct ofp_error_msg {
77  struct ofp_header header;
78 
79  uint16_t type;
80  uint16_t code;
81  uint8_t data[0]; /* Variable-length data. Interpreted based
82  on the type and code. No padding. */
83  };
84  OFP_ASSERT(sizeof(struct ofp_error_msg) == 12);
85 
86 
87 
88 
89 
90  /* Port numbering. Ports are numbered starting from 1. */
91  enum ofp_port_no {
92  /* Maximum number of physical switch ports. */
93  OFPP_MAX = 0xffffff00,
94 
95  /* Fake output "ports". */
96  OFPP_IN_PORT = 0xfffffff8, /* Send the packet out the input port. This
97  virtual port must be explicitly used
98  in order to send back out of the input
99  port. */
100  OFPP_TABLE = 0xfffffff9, /* Submit the packet to the first flow table
101  NB: This destination port can only be
102  used in packet-out messages. */
103  OFPP_NORMAL = 0xfffffffa, /* Process with normal L2/L3 switching. */
104  OFPP_FLOOD = 0xfffffffb, /* All physical ports in VLAN, except input
105  port and those blocked or link down. */
106  OFPP_ALL = 0xfffffffc, /* All physical ports except input port. */
107  OFPP_CONTROLLER = 0xfffffffd, /* Send to controller. */
108  OFPP_LOCAL = 0xfffffffe, /* Local OpenFlow "port". */
109  OFPP_ANY = 0xffffffff /* Wildcard port used only for flow mod
110  (delete) and flow stats requests. Selects
111  all flows regardless of output port
112  (including flows with no output port). */
113  };
114 
115 
116  enum ofp_type {
117  /* Immutable messages. */
118  OFPT_HELLO = 0, /* Symmetric message */
119  OFPT_ERROR = 1, /* Symmetric message */
120  OFPT_ECHO_REQUEST = 2, /* Symmetric message */
121  OFPT_ECHO_REPLY = 3, /* Symmetric message */
122  OFPT_EXPERIMENTER = 4, /* Symmetric message */
123 
124  /* Switch configuration messages. */
125  OFPT_FEATURES_REQUEST = 5, /* Controller/switch message */
126  OFPT_FEATURES_REPLY = 6, /* Controller/switch message */
127  OFPT_GET_CONFIG_REQUEST = 7, /* Controller/switch message */
128  OFPT_GET_CONFIG_REPLY = 8, /* Controller/switch message */
129  OFPT_SET_CONFIG = 9, /* Controller/switch message */
130 
131  /* Asynchronous messages. */
132  OFPT_PACKET_IN = 10, /* Async message */
133  OFPT_FLOW_REMOVED = 11, /* Async message */
134  OFPT_PORT_STATUS = 12, /* Async message */
135 
136  /* Controller command messages. */
137  OFPT_PACKET_OUT = 13, /* Controller/switch message */
138  OFPT_FLOW_MOD = 14, /* Controller/switch message */
139  OFPT_GROUP_MOD = 15, /* Controller/switch message */
140  OFPT_PORT_MOD = 16, /* Controller/switch message */
141  OFPT_TABLE_MOD = 17, /* Controller/switch message */
142 
143  /* Multipart messages. */
144  OFPT_MULTIPART_REQUEST = 18, /* Controller/switch message */
145  OFPT_MULTIPART_REPLY = 19, /* Controller/switch message */
146 
147  /* Statistics messages (up to and including OF1.2) */
148  OFPT_STATS_REQUEST = 18, /* Controller/switch message */
149  OFPT_STATS_REPLY = 19, /* Controller/switch message */
150 
151  /* Barrier messages. */
152  OFPT_BARRIER_REQUEST = 20, /* Controller/switch message */
153  OFPT_BARRIER_REPLY = 21, /* Controller/switch message */
154 
155  /* Queue Configuration messages. */
156  OFPT_QUEUE_GET_CONFIG_REQUEST = 22, /* Controller/switch message */
157  OFPT_QUEUE_GET_CONFIG_REPLY = 23, /* Controller/switch message */
158 
159  /* Controller role change request messages. */
160  OFPT_ROLE_REQUEST = 24, /* Controller/switch message */
161  OFPT_ROLE_REPLY = 25, /* Controller/switch message */
162 
163  /* Asynchronous message configuration. */
164  OFPT_GET_ASYNC_REQUEST = 26, /* Controller/switch message */
165  OFPT_GET_ASYNC_REPLY = 27, /* Controller/switch message */
166  OFPT_SET_ASYNC = 28, /* Controller/switch message */
167 
168  /* Meters and rate limiters configuration messages. */
169  OFPT_METER_MOD = 29, /* Controller/switch message */
170  };
171 
172 
173  /* OFPT_HELLO. This message has an empty body, but implementations must
174  * ignore any data included in the body, to allow for future extensions. */
175  struct ofp_hello {
176  struct ofp_header header;
177  };
178 
179  #define OFP_DEFAULT_MISS_SEND_LEN 128
180 
181  enum ofp_config_flags {
182  /* Handling of IP fragments. */
183  OFPC_FRAG_NORMAL = 0, /* No special handling for fragments. */
184  OFPC_FRAG_DROP = 1 << 0, /* Drop fragments. */
185  OFPC_FRAG_REASM = 1 << 1, /* Reassemble (only if OFPC_IP_REASM set). */
186  OFPC_FRAG_MASK = 3,
187 
188  /* TTL processing - applicable for IP and MPLS packets */
189  OFPC_INVALID_TTL_TO_CONTROLLER = 1 << 2, /* Send packets with invalid TTL
190  ie. 0 or 1 to controller */
191  };
192 
193  /* Switch configuration. */
195  struct ofp_header header;
196  uint16_t flags; /* OFPC_* flags. */
197  uint16_t miss_send_len; /* Max bytes of new flow that datapath should
198  send to the controller. */
199  };
200  OFP_ASSERT(sizeof(struct ofp_switch_config) == 12);
201 
202  /* Flags to indicate behavior of the flow table for unmatched packets.
203  These flags are used in ofp_table_stats messages to describe the current
204  configuration and in ofp_table_mod messages to configure table behavior. */
205  enum ofp_table_config {
206  OFPTC_TABLE_MISS_CONTROLLER = 0, /* Send to controller. */
207  OFPTC_TABLE_MISS_CONTINUE = 1 << 0, /* Continue to the next table in the
208  pipeline (OpenFlow 1.0
209  behavior). */
210  OFPTC_TABLE_MISS_DROP = 1 << 1, /* Drop the packet. */
211  OFPTC_TABLE_MISS_MASK = 3
212  };
213 
214  /* Table numbering. Tables can use any number up to OFPT_MAX. */
215  enum ofp_table {
216  /* Last usable table number. */
217  OFPTT_MAX = 0xfe,
218  /* Fake tables. */
219  OFPTT_ALL = 0xff
220  /* Wildcard table used for table config,
221  flow stats and flow deletes. */
222  };
223 
224 
225  /* Configure/Modify behavior of a flow table */
226  struct ofp_table_mod {
227  struct ofp_header header;
228  uint8_t table_id; /* ID of the table, 0xFF indicates all tables */
229  uint8_t pad[3]; /* Pad to 32 bits */
230  uint32_t config; /* Bitmap of OFPTC_* flags */
231  };
232  OFP_ASSERT(sizeof(struct ofp_table_mod) == 16);
233 
234  /* Capabilities supported by the datapath. */
235  enum ofp_capabilities {
236  OFPC_FLOW_STATS = 1 << 0, /* Flow statistics. */
237  OFPC_TABLE_STATS = 1 << 1, /* Table statistics. */
238  OFPC_PORT_STATS = 1 << 2, /* Port statistics. */
239  OFPC_GROUP_STATS = 1 << 3, /* Group statistics. */
240  OFPC_IP_REASM = 1 << 5, /* Can reassemble IP fragments. */
241  OFPC_QUEUE_STATS = 1 << 6, /* Queue statistics. */
242  OFPC_ARP_MATCH_IP = 1 << 7 /* Match IP addresses in ARP pkts. */
243  };
244 
245  /* Flags to indicate behavior of the physical port. These flags are
246  * used in ofp_port to describe the current configuration. They are
247  * used in the ofp_port_mod message to configure the port's behavior.
248  */
249  enum ofp_port_config {
250  OFPPC_PORT_DOWN = 1 << 0, /* Port is administratively down. */
251 
252  OFPPC_NO_RECV = 1 << 2, /* Drop all packets received by port. */
253  OFPPC_NO_FWD = 1 << 5, /* Drop packets forwarded to port. */
254  OFPPC_NO_PACKET_IN = 1 << 6 /* Do not send packet-in msgs for port. */
255  };
256 
257  /* Current state of the physical port. These are not configurable from
258  * the controller.
259  */
260  enum ofp_port_state {
261  OFPPS_LINK_DOWN = 1 << 0, /* No physical link present. */
262  OFPPS_BLOCKED = 1 << 1, /* Port is blocked */
263  OFPPS_LIVE = 1 << 2, /* Live for Fast Failover Group. */
264  };
265 
266  /* Features of ports available in a datapath. */
267  enum ofp_port_features {
268  OFPPF_10MB_HD = 1 << 0, /* 10 Mb half-duplex rate support. */
269  OFPPF_10MB_FD = 1 << 1, /* 10 Mb full-duplex rate support. */
270  OFPPF_100MB_HD = 1 << 2, /* 100 Mb half-duplex rate support. */
271  OFPPF_100MB_FD = 1 << 3, /* 100 Mb full-duplex rate support. */
272  OFPPF_1GB_HD = 1 << 4, /* 1 Gb half-duplex rate support. */
273  OFPPF_1GB_FD = 1 << 5, /* 1 Gb full-duplex rate support. */
274  OFPPF_10GB_FD = 1 << 6, /* 10 Gb full-duplex rate support. */
275  OFPPF_40GB_FD = 1 << 7, /* 40 Gb full-duplex rate support. */
276  OFPPF_100GB_FD = 1 << 8, /* 100 Gb full-duplex rate support. */
277  OFPPF_1TB_FD = 1 << 9, /* 1 Tb full-duplex rate support. */
278  OFPPF_OTHER = 1 << 10, /* Other rate, not in the list. */
279 
280  OFPPF_COPPER = 1 << 11, /* Copper medium. */
281  OFPPF_FIBER = 1 << 12, /* Fiber medium. */
282  OFPPF_AUTONEG = 1 << 13, /* Auto-negotiation. */
283  OFPPF_PAUSE = 1 << 14, /* Pause. */
284  OFPPF_PAUSE_ASYM = 1 << 15 /* Asymmetric pause. */
285  };
286 
287  /* Description of a port */
288  struct ofp_port {
289  uint32_t port_no;
290  uint8_t pad[4];
291  uint8_t hw_addr[OFP_ETH_ALEN];
292  uint8_t pad2[2]; /* Align to 64 bits. */
293  char name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated */
294 
295  uint32_t config; /* Bitmap of OFPPC_* flags. */
296  uint32_t state; /* Bitmap of OFPPS_* flags. */
297 
298  /* Bitmaps of OFPPF_* that describe features. All bits zeroed if
299  * unsupported or unavailable. */
300  uint32_t curr; /* Current features. */
301  uint32_t advertised; /* Features being advertised by the port. */
302  uint32_t supported; /* Features supported by the port. */
303  uint32_t peer; /* Features advertised by peer. */
304 
305  uint32_t curr_speed; /* Current port bitrate in kbps. */
306  uint32_t max_speed; /* Max port bitrate in kbps */
307  };
308  OFP_ASSERT(sizeof(struct ofp_port) == 64);
309 
310  /* Switch features. */
312  struct ofp_header header;
313  uint64_t datapath_id; /* Datapath unique ID. The lower 48-bits are for
314  a MAC address, while the upper 16-bits are
315  implementer-defined. */
316 
317  uint32_t n_buffers; /* Max packets buffered at once. */
318 
319  uint8_t n_tables; /* Number of tables supported by datapath. */
320  uint8_t pad[3]; /* Align to 64-bits. */
321 
322  /* Features. */
323  uint32_t capabilities; /* Bitmap of support "ofp_capabilities". */
324  uint32_t reserved;
325 
326  /* Port info.*/
327  struct ofp_port ports[0]; /* Port definitions. The number of ports
328  is inferred from the length field in
329  the header. */
330  };
331  OFP_ASSERT(sizeof(struct ofp_switch_features) == 32);
332 
333  /* What changed about the physical port */
334  enum ofp_port_reason {
335  OFPPR_ADD, /* The port was added. */
336  OFPPR_DELETE, /* The port was removed. */
337  OFPPR_MODIFY /* Some attribute of the port has changed. */
338  };
339 
340  /* A physical port has changed in the datapath */
342  struct ofp_header header;
343  uint8_t reason; /* One of OFPPR_*. */
344  uint8_t pad[7]; /* Align to 64-bits. */
345  struct ofp_port desc;
346  };
347  OFP_ASSERT(sizeof(struct ofp_port_status) == 80);
348 
349  /* Modify behavior of the physical port */
350  struct ofp_port_mod {
351  struct ofp_header header;
352  uint32_t port_no;
353  uint8_t pad[4];
354  uint8_t hw_addr[OFP_ETH_ALEN]; /* The hardware address is not
355  configurable. This is used to
356  sanity-check the request, so it must
357  be the same as returned in an
358  ofp_port struct. */
359  uint8_t pad2[2]; /* Pad to 64 bits. */
360  uint32_t config; /* Bitmap of OFPPC_* flags. */
361  uint32_t mask; /* Bitmap of OFPPC_* flags to be changed. */
362 
363  uint32_t advertise; /* Bitmap of OFPPF_*. Zero all bits to prevent
364  any action taking place. */
365  uint8_t pad3[4]; /* Pad to 64 bits. */
366  };
367  OFP_ASSERT(sizeof(struct ofp_port_mod) == 40);
368 
369  /* Why is this packet being sent to the controller? */
370  enum ofp_packet_in_reason {
371  OFPR_NO_MATCH = 0, /* No matching flow. */
372  OFPR_ACTION = 1, /* Action explicitly output to controller. */
373  OFPR_INVALID_TTL = 2 /* Packet has invalid TTL */
374  };
375 
376 
377 
378 
379  /* Fields to match against flows */
380  struct ofp_match {
381  uint16_t type; /* One of OFPMT_* */
382  uint16_t length; /* Length of ofp_match (excluding padding) */
383  /* Followed by:
384  * - Exactly (length - 4) (possibly 0) bytes containing OXM TLVs, then
385  * - Exactly ((length + 7)/8*8 - length) (between 0 and 7) bytes of
386  * all-zero bytes
387  * In summary, ofp_match is padded as needed, to make its overall size
388  * a multiple of 8, to preserve alignement in structures using it.
389  */
390  uint8_t oxm_fields[4];
391  /* OXMs start here - Make compiler happy */
392  };
393  OFP_ASSERT(sizeof(struct ofp_match) == 8);
394 
395  static int const OFP_MATCH_STATIC_LEN = 2 * sizeof(uint16_t);
396 
397  /* The match type indicates the match structure (set of fields that compose the
398  * match) in use. The match type is placed in the type field at the beginning
399  * of all match structures. The "OpenFlow Extensible Match" type corresponds
400  * to OXM TLV format described below and must be supported by all OpenFlow
401  * switches. Extensions that define other match types may be published on the
402  * ONF wiki. Support for extensions is optional.
403  */
404  enum ofp_match_type {
405  OFPMT_STANDARD = 0, /* Deprecated. */
406  OFPMT_OXM = 1, /* OpenFlow Extensible Match */
407  };
408 
409 
410  struct ofp_oxm_hdr {
411  uint16_t oxm_class; /* oxm_class */
412  uint8_t oxm_field; /* includes has_mask bit! */
413  uint8_t oxm_length; /* oxm_length */
414  };
415 
416 
417 
418 
419  // OXM_OF_VLAN_PCP /* 3 bits */
420  // OXM_OF_IP_DSCP /* 6 bits */
421  // OXM_OF_IP_ECN /* 2 bits */
422  // OXM_OF_IP_PROTO /* 8 bits */
423  // OXM_OF_ICMPV4_TYPE
424  // OXM_OF_ICMPV4_CODE
425  // OXM_OF_ICMPV6_TYPE
426  // OXM_OF_ICMPV6_CODE
427  // OXM_OF_MPLS_TC /* 3 bits */
429  struct ofp_oxm_hdr hdr; /* oxm header */
430  uint8_t byte;
431  uint8_t mask;
432  };
433 
434 
435  // OXM_OF_ETH_TYPE
436  // OXM_OF_VLAN_VID (mask)
437  // OXM_OF_TCP_SRC
438  // OXM_OF_TCP_DST
439  // OXM_OF_UDP_SRC
440  // OXM_OF_UDP_DST
441  // OXM_OF_SCTP_SRC
442  // OXM_OF_SCTP_DST
443  // OXM_OF_ARP_OP
445  struct ofp_oxm_hdr hdr; /* oxm header */
446  uint16_t word; /* network byte order */
447  uint16_t mask;
448  };
449 
450 
451  // OXM_OF_IN_PORT
452  // OXM_OF_IN_PHY_PORT
453  // OXM_OF_IPV4_SRC (mask)
454  // OXM_OF_IPV4_DST (mask)
455  // OXM_OF_ARP_SPA (mask)
456  // OXM_OF_ARP_THA (mask)
457  // OXM_OF_IPV6_FLABEL (mask)
458  // OXM_OF_MPLS_LABEL
460  struct ofp_oxm_hdr hdr; /* oxm header */
461  uint32_t dword; /* network byte order */
462  uint32_t mask; /* only valid, when oxm_hasmask=1 */
463  };
464 
465 
466  // OXM_OF_IPV6_ND_SLL
467  // OXM_OF_IPV6_ND_TLL
469  struct ofp_oxm_hdr hdr; /* oxm header */
470  uint8_t value[6];
471  uint8_t mask[6]; /* only valid, when oxm_hasmask=1 */
472  };
473 
474  // OXM_OF_METADATA (mask)
476  struct ofp_oxm_hdr hdr; /* oxm header */
477  uint8_t word[8];
478  uint8_t mask[8];
479  #if 0
480  uint64_t qword; /* network byte order */
481  uint64_t mask; /* only valid, when oxm_hasmask=1 */
482  #endif
483  };
484 
485 
486  // OXM_OF_ETH_DST (mask)
487  // OXM_OF_ETH_SRC (mask)
489  struct ofp_oxm_hdr hdr; /* oxm header */
490  uint8_t addr[OFP_ETH_ALEN];
491  uint8_t mask[OFP_ETH_ALEN]; /* only valid, when oxm_hasmask=1 */
492  };
493 
494 
495  // OXM_OF_IPV6_SRC (mask)
496  // OXM_OF_IPV6_DST (mask)
497  // OXM_OF_IPV6_ND_TARGET
499  struct ofp_oxm_hdr hdr; /* oxm header */
500  uint8_t addr[16];
501  uint8_t mask[16]; /* only valid, when oxm_hasmask=1 */
502  };
503 
504 
505  /* OXM Class IDs.
506  * The high order bit differentiate reserved classes from member classes.
507  * Classes 0x0000 to 0x7FFF are member classes, allocated by ONF.
508  * Classes 0x8000 to 0xFFFE are reserved classes, reserved for standardisation.
509  */
510  enum ofp_oxm_class {
511  OFPXMC_NXM_0 = 0x0000, /* Backward compatibility with NXM */
512  OFPXMC_NXM_1 = 0x0001, /* Backward compatibility with NXM */
513  OFPXMC_OPENFLOW_BASIC = 0x8000, /* Basic class for OpenFlow */
514  OFPXMC_EXPERIMENTER = 0xFFFF, /* Experimenter class */
515  };
516 
517 
518  /* OXM Flow match field types for OpenFlow basic class. */
519  enum oxm_ofb_match_fields {
520  OFPXMT_OFB_IN_PORT = 0, /* Switch input port. */ // required
521  OFPXMT_OFB_IN_PHY_PORT = 1, /* Switch physical input port. */
522  OFPXMT_OFB_METADATA = 2, /* Metadata passed between tables. */
523  OFPXMT_OFB_ETH_DST = 3, /* Ethernet destination address. */ // required
524  OFPXMT_OFB_ETH_SRC = 4, /* Ethernet source address. */ // required
525  OFPXMT_OFB_ETH_TYPE = 5, /* Ethernet frame type. */ // required
526  OFPXMT_OFB_VLAN_VID = 6, /* VLAN id. */
527  OFPXMT_OFB_VLAN_PCP = 7, /* VLAN priority. */
528  OFPXMT_OFB_IP_DSCP = 8, /* IP DSCP (6 bits in ToS field). */
529  OFPXMT_OFB_IP_ECN = 9, /* IP ECN (2 bits in ToS field). */
530  OFPXMT_OFB_IP_PROTO = 10, /* IP protocol. */ // required
531  OFPXMT_OFB_IPV4_SRC = 11, /* IPv4 source address. */ // required
532  OFPXMT_OFB_IPV4_DST = 12, /* IPv4 destination address. */ // required
533  OFPXMT_OFB_TCP_SRC = 13, /* TCP source port. */ // required
534  OFPXMT_OFB_TCP_DST = 14, /* TCP destination port. */ // required
535  OFPXMT_OFB_UDP_SRC = 15, /* UDP source port. */ // required
536  OFPXMT_OFB_UDP_DST = 16, /* UDP destination port. */ // required
537  OFPXMT_OFB_SCTP_SRC = 17, /* SCTP source port. */
538  OFPXMT_OFB_SCTP_DST = 18, /* SCTP destination port. */
539  OFPXMT_OFB_ICMPV4_TYPE = 19, /* ICMP type. */
540  OFPXMT_OFB_ICMPV4_CODE = 20, /* ICMP code. */
541  OFPXMT_OFB_ARP_OP = 21, /* ARP opcode. */
542  OFPXMT_OFB_ARP_SPA = 22, /* ARP source IPv4 address. */
543  OFPXMT_OFB_ARP_TPA = 23, /* ARP target IPv4 address. */
544  OFPXMT_OFB_ARP_SHA = 24, /* ARP source hardware address. */
545  OFPXMT_OFB_ARP_THA = 25, /* ARP target hardware address. */
546  OFPXMT_OFB_IPV6_SRC = 26, /* IPv6 source address. */ // required
547  OFPXMT_OFB_IPV6_DST = 27, /* IPv6 destination address. */ // required
548  OFPXMT_OFB_IPV6_FLABEL = 28, /* IPv6 Flow Label */
549  OFPXMT_OFB_ICMPV6_TYPE = 29, /* ICMPv6 type. */
550  OFPXMT_OFB_ICMPV6_CODE = 30, /* ICMPv6 code. */
551  OFPXMT_OFB_IPV6_ND_TARGET = 31, /* Target address for ND. */
552  OFPXMT_OFB_IPV6_ND_SLL = 32, /* Source link-layer for ND. */
553  OFPXMT_OFB_IPV6_ND_TLL = 33, /* Target link-layer for ND. */
554  OFPXMT_OFB_MPLS_LABEL = 34, /* MPLS label. */
555  OFPXMT_OFB_MPLS_TC = 35, /* MPLS TC. */
556  /* max value */
557  OFPXMT_OFB_MAX,
558  };
559 
560  /* Header for OXM experimenter match fields. */
562  uint32_t oxm_header; /* oxm_class = OFPXMC_EXPERIMENTER */
563  uint32_t experimenter; /* Experimenter ID which takes the same
564  form as in struct ofp_experimenter_header. */
565  };
566  OFP_ASSERT(sizeof(struct ofp_oxm_experimenter_header) == 8);
567 
568 
569 
570  #if 0
571  /* Packet received on port (datapath -> controller). */
572  struct ofp_packet_in {
573  struct ofp_header header;
574  uint32_t buffer_id; /* ID assigned by datapath. */
575  uint32_t in_port; /* Port on which frame was received. */
576  uint32_t in_phy_port; /* Physical Port on which frame was received. */
577  uint16_t total_len; /* Full length of frame. */
578  uint8_t reason; /* Reason packet is being sent (one of OFPR_*) */
579  uint8_t table_id; /* ID of the table that was looked up */
580  uint8_t data[0]; /* Ethernet frame, halfway through 32-bit word,
581  so the IP header is 32-bit aligned. The
582  amount of data is inferred from the length
583  field in the header. Because of padding,
584  offsetof(struct ofp_packet_in, data) ==
585  sizeof(struct ofp_packet_in) - 2. */
586  };
587  OFP_ASSERT(sizeof(struct ofp_packet_in) == 24);
588  #endif
589 
590  /* Packet received on port (datapath -> controller). */
591  struct ofp_packet_in {
592  struct ofp_header header;
593  uint32_t buffer_id; /* ID assigned by datapath. */
594  uint16_t total_len; /* Full length of frame. */
595  uint8_t reason; /* Reason packet is being sent (one of OFPR_*) */
596  uint8_t table_id; /* ID of the table that was looked up */
597  struct ofp_match match; /* Packet metadata. Variable size. */
598  /* Followed by:
599  * - Exactly 2 all-zero padding bytes, then
600  * - An Ethernet frame whose length is inferred from header.length.
601  * The padding bytes preceding the Ethernet frame ensure that the IP
602  * header (if any) following the Ethernet header is 32-bit aligned.
603  */
604  //uint8_t pad[2]; /* Align to 64 bit + 16 bit */
605  //uint8_t data[0]; /* Ethernet frame */
606  };
607  OFP_ASSERT(sizeof(struct ofp_packet_in) == 24);
608 
609  static int const OFP_PACKET_IN_STATIC_HDR_LEN = sizeof(struct ofp_packet_in) - sizeof(struct ofp_match);
610 
611  enum ofp_buffer_t {
612  OFP_NO_BUFFER = 0xffffffff,
613  };
614 
615  enum ofp_action_type {
616  OFPAT_OUTPUT = 0, /* Output to switch port. */
617  OFPAT_COPY_TTL_OUT = 11, /* Copy TTL "outwards" -- from next-to-outermost to outermost */
618  OFPAT_COPY_TTL_IN = 12, /* Copy TTL "inwards" -- from outermost to next-to-outermost */
619  OFPAT_SET_MPLS_TTL = 15, /* MPLS TTL */
620  OFPAT_DEC_MPLS_TTL = 16, /* Decrement MPLS TTL */
621  OFPAT_PUSH_VLAN = 17, /* Push a new VLAN tag */
622  OFPAT_POP_VLAN = 18, /* Pop the outer VLAN tag */
623  OFPAT_PUSH_MPLS = 19, /* Push a new MPLS tag */
624  OFPAT_POP_MPLS = 20, /* Pop the outer MPLS tag */
625  OFPAT_SET_QUEUE = 21, /* Set queue id when outputting to a port */
626  OFPAT_GROUP = 22, /* Apply group. */
627  OFPAT_SET_NW_TTL = 23, /* IP TTL. */
628  OFPAT_DEC_NW_TTL = 24, /* Decrement IP TTL. */
629  OFPAT_SET_FIELD = 25, /* Set a header field using OXM TLV format. */
630  OFPAT_EXPERIMENTER = 0xffff
631  };
632 
633 
634  /* Action header that is common to all actions. The length includes the
635  * header and any padding used to make the action 64-bit aligned.
636  * NB: The length of an action *must* always be a multiple of eight. */
638  uint16_t type; /* One of OFPAT_*. */
639  uint16_t len; /* Length of action, including this
640  header. This is the length of action,
641  including any padding to make it
642  64-bit aligned. */
643  uint8_t pad[4];
644  };
645  OFP_ASSERT(sizeof(struct ofp_action_header) == 8);
646 
647 
648  /* Action structure for OFPAT_OUTPUT, which sends packets out 'port'.
649  * When the 'port' is the OFPP_CONTROLLER, 'max_len' indicates the max
650  * number of bytes to send. A 'max_len' of zero means no bytes of the
651  * packet should be sent.*/
653  uint16_t type; /* OFPAT_OUTPUT. */
654  uint16_t len; /* Length is 16. */
655  uint32_t port; /* Output port. */
656  uint16_t max_len; /* Max length to send to controller. */
657  uint8_t pad[6]; /* Pad to 64 bits. */
658  };
659  OFP_ASSERT(sizeof(struct ofp_action_output) == 16);
660 
661  enum ofp_controller_max_len {
662  OFPCML_MAX = 0xffe5, /* maximum max_len value which can be used to request a specific byte length. */
663  OFPCML_NO_BUFFER = 0xffff, /* indicates that no buffering should be
664  applied and the whole packet is to be
665  sent to the controller. */
666  };
667 
668 
669  /* Action structure for OFPAT_SET_FIELD. */
671  uint16_t type; /* OFPAT_SET_FIELD. */
672  uint16_t len; /* Length is padded to 64 bits. */
673  /* Followed by:
674  * - Exactly oxm_len bytes containing a single OXM TLV, then
675  * - Exactly ((oxm_len + 4) + 7)/8*8 - (oxm_len + 4) (between 0 and 7)
676  * bytes of all-zero bytes
677  */
678  uint8_t field[4]; /* OXM TLV - Make compiler happy */
679  };
680  OFP_ASSERT(sizeof(struct ofp_action_set_field) == 8);
681 
682 
683  /* Action structure for OFPAT_SET_MPLS_TTL. */
685  uint16_t type; /* OFPAT_SET_MPLS_TTL. */
686  uint16_t len; /* Length is 8. */
687  uint8_t mpls_ttl; /* MPLS TTL */
688  uint8_t pad[3];
689  };
690  OFP_ASSERT(sizeof(struct ofp_action_mpls_ttl) == 8);
691 
692  /* Action structure for OFPAT_PUSH_VLAN/MPLS. */
694  uint16_t type; /* OFPAT_PUSH_VLAN/MPLS. */
695  uint16_t len; /* Length is 8. */
696  uint16_t ethertype; /* Ethertype */
697  uint8_t pad[2];
698  };
699  OFP_ASSERT(sizeof(struct ofp_action_push) == 8);
700 
701  /* Action structure for OFPAT_POP_MPLS. */
703  uint16_t type; /* OFPAT_POP_MPLS. */
704  uint16_t len; /* Length is 8. */
705  uint16_t ethertype; /* Ethertype */
706  uint8_t pad[2];
707  };
708  OFP_ASSERT(sizeof(struct ofp_action_pop_mpls) == 8);
709 
710 
711 
712 
713 
714  /* Action structure for OFPAT_GROUP. */
716  uint16_t type; /* OFPAT_GROUP. */
717  uint16_t len; /* Length is 8. */
718  uint32_t group_id; /* Group identifier. */
719  };
720  OFP_ASSERT(sizeof(struct ofp_action_group) == 8);
721 
722  /* Action structure for OFPAT_SET_NW_TTL. */
724  uint16_t type; /* OFPAT_SET_NW_TTL. */
725  uint16_t len; /* Length is 8. */
726  uint8_t nw_ttl; /* IP TTL */
727  uint8_t pad[3];
728  };
729  OFP_ASSERT(sizeof(struct ofp_action_nw_ttl) == 8);
730 
731  /* Action header for OFPAT_EXPERIMENTER.
732  * The rest of the body is experimenter-defined. */
734  uint16_t type; /* OFPAT_EXPERIMENTER. */
735  uint16_t len; /* Length is a multiple of 8. */
736  uint32_t experimenter; /* Experimenter ID which takes the same
737  form as in struct
738  ofp_experimenter_header. */
739  uint32_t exp_type;
740  uint8_t data[0];
741  };
742  OFP_ASSERT(sizeof(struct ofp_action_experimenter_header) == 12);
743 
744 
745 
746 
747 
748  /* Send packet (controller -> datapath). */
749  struct ofp_packet_out {
750  struct ofp_header header;
751  uint32_t buffer_id; /* ID assigned by datapath (-1 if none). */
752  uint32_t in_port; /* Packet's input port or OFPP_CONTROLLER. */
753  uint16_t actions_len; /* Size of action array in bytes. */
754  uint8_t pad[6];
755  struct ofp_action_header actions[0]; /* Action list. */
756  /* uint8_t data[0]; */ /* Packet data. The length is inferred
757  from the length field in the header.
758  (Only meaningful if buffer_id == -1.) */
759  };
760  OFP_ASSERT(sizeof(struct ofp_packet_out) == 24);
761 
762  enum ofp_flow_mod_command {
763  OFPFC_ADD, /* New flow. */
764  OFPFC_MODIFY, /* Modify all matching flows. */
765  OFPFC_MODIFY_STRICT, /* Modify entry strictly matching wildcards and
766  priority. */
767  OFPFC_DELETE, /* Delete all matching flows. */
768  OFPFC_DELETE_STRICT /* Delete entry strictly matching wildcards and
769  priority. */
770  };
771 
772  enum flow_mod_header_len {
773  OFP_FLOW_MOD_STATIC_HDR_LEN = 48,
774  };
775 
776  /* Group commands */
777  enum ofp_group_mod_command {
778  OFPGC_ADD, /* New group. */
779  OFPGC_MODIFY, /* Modify all matching groups. */
780  OFPGC_DELETE, /* Delete all matching groups. */
781  };
782 
783  /* Flow wildcards. */
784  enum ofp_flow_wildcards {
785  OFPFW_IN_PORT = 1 << 0, /* Switch input port. */
786  OFPFW_DL_VLAN = 1 << 1, /* VLAN id. */
787  OFPFW_DL_VLAN_PCP = 1 << 2, /* VLAN priority. */
788  OFPFW_DL_TYPE = 1 << 3, /* Ethernet frame type. */
789  OFPFW_NW_TOS = 1 << 4, /* IP ToS (DSCP field, 6 bits). */
790  OFPFW_NW_PROTO = 1 << 5, /* IP protocol. */
791  OFPFW_TP_SRC = 1 << 6, /* TCP/UDP/SCTP source port. */
792  OFPFW_TP_DST = 1 << 7, /* TCP/UDP/SCTP destination port. */
793  OFPFW_MPLS_LABEL = 1 << 8, /* MPLS label. */
794  OFPFW_MPLS_TC = 1 << 9, /* MPLS TC. */
795  #if 0
796  #ifdef ORAN
797  OFPFW_PPPOE_CODE = 1 << 10, /* PPPoE code */
798  OFPFW_PPPOE_TYPE = 1 << 11, /* PPPoE type */
799  OFPFW_PPPOE_SESS = 1 << 12, /* PPPoE session */
800  OFPFW_PPP_CODE = 1 << 13, /* PPP code */
801  #endif
802  #endif
803 
804  /* Wildcard all fields. */
805  OFPFW_ALL = ((1 << 14) - 1)
806  //OFPFW_ALL = ((1 << 10) - 1)
807  };
808 
809  /* The wildcards for ICMP type and code fields use the transport source
810  * and destination port fields, respectively. */
811  #define OFPFW_ICMP_TYPE OFPFW_TP_SRC
812  #define OFPFW_ICMP_CODE OFPFW_TP_DST
813 
814  /* Values below this cutoff are 802.3 packets and the two bytes
815  * following MAC addresses are used as a frame length. Otherwise, the
816  * two bytes are used as the Ethernet type.
817  */
818  #define OFP_DL_TYPE_ETH2_CUTOFF 0x0600
819 
820  /* Value of dl_type to indicate that the frame does not include an
821  * Ethernet type.
822  */
823  #define OFP_DL_TYPE_NOT_ETH_TYPE 0x05ff
824 
825  /*
826  * OpenFlow 1.2 [start]
827  */
828 
829  /* The VLAN id is 12-bits, so we can use the entire 16 bits to indicate
830  * special conditions.
831  */
832  enum ofp_vlan_id {
833  OFPVID_PRESENT = 0x1000, /* Bit that indicate that a VLAN id is set */
834  OFPVID_NONE = 0x0000, /* No VLAN id was set. */
835  };
836 
837 
838 
839 
840 
841  /*
842  * OpenFlow 1.2 [end]
843  */
844 
845 
846 
847 
848  /* The match fields for ICMP type and code use the transport source and
849  * destination port fields, respectively. */
850  #define icmp_type tp_src
851  #define icmp_code tp_dst
852 
853  /* Value used in "idle_timeout" and "hard_timeout" to indicate that the entry
854  * is permanent. */
855  #define OFP_FLOW_PERMANENT 0
856 
857  /* By default, choose a priority in the middle. */
858  #define OFP_DEFAULT_PRIORITY 0x8000
859 
860  enum ofp_instruction_type {
861  OFPIT_GOTO_TABLE = 1, /* Setup the next table in the lookup
862  pipeline */
863  OFPIT_WRITE_METADATA = 2, /* Setup the metadata field for use later in
864  pipeline */
865  OFPIT_WRITE_ACTIONS = 3, /* Write the action(s) onto the datapath action
866  set */
867  OFPIT_APPLY_ACTIONS = 4, /* Applies the action(s) immediately */
868  OFPIT_CLEAR_ACTIONS = 5, /* Clears all actions from the datapath
869  action set */
870 
871  OFPIT_EXPERIMENTER = 0xFFFF /* Experimenter instruction */
872  };
873 
874  /* Generic ofp_instruction structure */
876  uint16_t type; /* Instruction type */
877  uint16_t len; /* Length of this struct in bytes. */
878 #if 0
879  uint8_t pad[4]; /* Align to 64-bits */
880 #endif
881  };
882  OFP_ASSERT(sizeof(struct ofp_instruction) == 4);
883 
884  /* Instruction structure for OFPIT_GOTO_TABLE */
886  uint16_t type; /* OFPIT_GOTO_TABLE */
887  uint16_t len; /* Length of this struct in bytes. */
888  uint8_t table_id; /* Set next table in the lookup pipeline */
889  uint8_t pad[3]; /* Pad to 64 bits. */
890  };
891  OFP_ASSERT(sizeof(struct ofp_instruction_goto_table) == 8);
892 
893  /* Instruction structure for OFPIT_WRITE_METADATA */
895  uint16_t type; /* OFPIT_WRITE_METADATA */
896  uint16_t len; /* Length of this struct in bytes. */
897  uint8_t pad[4]; /* Align to 64-bits */
898  uint64_t metadata; /* Metadata value to write */
899  uint64_t metadata_mask; /* Metadata write bitmask */
900  };
901  OFP_ASSERT(sizeof(struct ofp_instruction_write_metadata) == 24);
902 
903  /* Instruction structure for OFPIT_WRITE/APPLY/CLEAR_ACTIONS */
905  uint16_t type; /* One of OFPIT_*_ACTIONS */
906  uint16_t len; /* Length of this struct in bytes. */
907  uint8_t pad[4]; /* Align to 64-bits */
908  struct ofp_action_header actions[0]; /* Actions associated with
909  OFPIT_WRITE_ACTIONS and
910  OFPIT_APPLY_ACTIONS */
911  };
912  OFP_ASSERT(sizeof(struct ofp_instruction_actions) == 8);
913 
914  /* Instruction structure for experimental instructions */
916  uint16_t type; /* OFPIT_EXPERIMENTER */
917  uint16_t len; /* Length of this struct in bytes */
918  uint32_t experimenter; /* Experimenter ID:
919  * - MSB 0: low-order bytes are IEEE OUI.
920  * - MSB != 0: defined by OpenFlow
921  * consortium. */
922  /* Experimenter-defined arbitrary additional data. */
923  };
924  OFP_ASSERT(sizeof(struct ofp_instruction_experimenter) == 8);
925 
926  enum ofp_flow_mod_flags {
927  OFPFF_SEND_FLOW_REM = 1 << 0, /* Send flow removed message when flow
928  * expires or is deleted. */
929  OFPFF_CHECK_OVERLAP = 1 << 1, /* Check for overlapping entries first. */
930  OFPFF_RESET_COUNTS = 1 << 2 /* Reset flow packet and byte counts. */
931  };
932 
933  /* Flow setup and teardown (controller -> datapath). */
934  struct ofp_flow_mod {
935  struct ofp_header header;
936  uint64_t cookie; /* Opaque controller-issued identifier. */
937  uint64_t cookie_mask; /* Mask used to restrict the cookie bits
938  that must match when the command is
939  OFPFC_MODIFY* or OFPFC_DELETE*. A value
940  of 0 indicates no restriction. */
941 
942  /* Flow actions. */
943  uint8_t table_id; /* ID of the table to put the flow in */
944  uint8_t command; /* One of OFPFC_*. */
945  uint16_t idle_timeout; /* Idle time before discarding (seconds). */
946  uint16_t hard_timeout; /* Max time before discarding (seconds). */
947  uint16_t priority; /* Priority level of flow entry. */
948  uint32_t buffer_id; /* Buffered packet to apply to (or -1).
949  Not meaningful for OFPFC_DELETE*. */
950  uint32_t out_port; /* For OFPFC_DELETE* commands, require
951  matching entries to include this as an
952  output port. A value of OFPP_ANY
953  indicates no restriction. */
954  uint32_t out_group; /* For OFPFC_DELETE* commands, require
955  matching entries to include this as an
956  output group. A value of OFPG_ANY
957  indicates no restriction. */
958  uint16_t flags; /* One of OFPFF_*. */
959  uint8_t pad[2];
960  struct ofp_match match; /* Fields to match */
961  //struct ofp_instruction instructions[0]; /* Instruction set */
962  };
963  OFP_ASSERT(sizeof(struct ofp_flow_mod) == 56);
964 
965  /* Group numbering. Groups can use any number up to OFPG_MAX. */
966  enum ofp_group {
967  /* Last usable group number. */
968  OFPG_MAX = 0xffffff00,
969 
970  /* Fake groups. */
971  OFPG_ALL = 0xfffffffc, /* Represents all groups for group delete
972  commands. */
973  OFPG_ANY = 0xffffffff /* Wildcard group used only for flow stats
974  requests. Selects all flows regardless of
975  group (including flows with no group).
976  */
977  };
978 
979  /* Bucket for use in groups. */
980  struct ofp_bucket {
981  uint16_t len; /* Length the bucket in bytes, including
982  this header and any padding to make it
983  64-bit aligned. */
984  uint16_t weight; /* Relative weight of bucket. Only
985  defined for select groups. */
986  uint32_t watch_port; /* Port whose state affects whether this
987  bucket is live. Only required for fast
988  failover groups. */
989  uint32_t watch_group; /* Group whose state affects whether this
990  bucket is live. Only required for fast
991  failover groups. */
992  uint8_t pad[4];
993  struct ofp_action_header actions[0]; /* The action length is inferred
994  from the length field in the
995  header. */
996  };
997  OFP_ASSERT(sizeof(struct ofp_bucket) == 16);
998 
999  /* Group setup and teardown (controller -> datapath). */
1000  struct ofp_group_mod {
1001  struct ofp_header header;
1002  uint16_t command; /* One of OFPGC_*. */
1003  uint8_t type; /* One of OFPGT_*. */
1004  uint8_t pad; /* Pad to 64 bits. */
1005  uint32_t group_id; /* Group identifier. */
1006  struct ofp_bucket buckets[0]; /* The bucket length is inferred from the
1007  length field in the header. */
1008  };
1009  OFP_ASSERT(sizeof(struct ofp_group_mod) == 16);
1010 
1011  /* Group types. Values in the range [128, 255] are reserved for experimental
1012  * use. */
1013  enum ofp_group_type {
1014  OFPGT_ALL = 0, /* All (multicast/broadcast) group. */
1015  OFPGT_SELECT = 1, /* Select group. */
1016  OFPGT_INDIRECT = 2, /* Indirect group. */
1017  OFPGT_FF = 3, /* Fast failover group. */
1018  };
1019 
1020  /* Why was this flow removed? */
1021  enum ofp_flow_removed_reason {
1022  OFPRR_IDLE_TIMEOUT, /* Flow idle time exceeded idle_timeout. */
1023  OFPRR_HARD_TIMEOUT, /* Time exceeded hard_timeout. */
1024  OFPRR_DELETE, /* Evicted by a DELETE flow mod. */
1025  OFPRR_GROUP_DELETE /* Group was removed. */
1026  };
1027 
1028  /* Flow removed (datapath -> controller). */ // adjusted to OF1.2
1030  struct ofp_header header;
1031  uint64_t cookie; /* Opaque controller-issued identifier. */
1032 
1033  uint16_t priority; /* Priority level of flow entry. */
1034  uint8_t reason; /* One of OFPRR_*. */
1035  uint8_t table_id; /* ID of the table */
1036 
1037  uint32_t duration_sec; /* Time flow was alive in seconds. */
1038  uint32_t duration_nsec; /* Time flow was alive in nanoseconds beyond
1039  duration_sec. */
1040  uint16_t idle_timeout; /* Idle timeout from original flow mod. */
1041  uint16_t hard_timeout; /* Idle timeout from original flow mod. */
1042  uint64_t packet_count;
1043  uint64_t byte_count;
1044  struct ofp_match match; /* Description of fields. */
1045  };
1046  OFP_ASSERT(sizeof(struct ofp_flow_removed) == 56);
1047 
1048  /* Values for ’type’ in ofp_error_message. These values are immutable: they
1049  * will not change in future versions of the protocol (although new values may
1050  * be added). */
1051  enum ofp_error_type {
1052  OFPET_HELLO_FAILED = 0, /* Hello protocol failed. */
1053  OFPET_BAD_REQUEST = 1, /* Request was not understood. */
1054  OFPET_BAD_ACTION = 2, /* Error in action description. */
1055  OFPET_BAD_INSTRUCTION = 3, /* Error in instruction list. */
1056  OFPET_BAD_MATCH = 4, /* Error in match. */
1057  OFPET_FLOW_MOD_FAILED = 5, /* Problem modifying flow entry. */
1058  OFPET_GROUP_MOD_FAILED = 6, /* Problem modifying group entry. */
1059  OFPET_PORT_MOD_FAILED = 7, /* Port mod request failed. */
1060  OFPET_TABLE_MOD_FAILED = 8, /* Table mod request failed. */
1061  OFPET_QUEUE_OP_FAILED = 9, /* Queue operation failed. */
1062  OFPET_SWITCH_CONFIG_FAILED = 10, /* Switch config request failed. */
1063  OFPET_ROLE_REQUEST_FAILED = 11, /* Controller Role request failed. */
1064  OFPET_EXPERIMENTER = 0xffff /* Experimenter error messages. */
1065  };
1066 
1067  /* ofp_error_msg 'code' values for OFPET_HELLO_FAILED. 'data' contains an
1068  * ASCII text string that may give failure details. */
1069  enum ofp_hello_failed_code {
1070  OFPHFC_INCOMPATIBLE, /* No compatible version. */
1071  OFPHFC_EPERM /* Permissions error. */
1072  };
1073 
1074  /* ofp_error_msg ’code’ values for OFPET_BAD_REQUEST. ’data’ contains at least
1075  * the first 64 bytes of the failed request. */
1076  enum ofp_bad_request_code {
1077  OFPBRC_BAD_VERSION = 0, /* ofp_header.version not supported. */
1078  OFPBRC_BAD_TYPE = 1, /* ofp_header.type not supported. */
1079  OFPBRC_BAD_STAT = 2, /* ofp_stats_request.type not supported. */
1080  OFPBRC_BAD_EXPERIMENTER = 3, /* Experimenter id not supported
1081  * (in ofp_experimenter_header or
1082  * ofp_stats_request or ofp_stats_reply). */
1083  OFPBRC_BAD_EXP_TYPE = 4, /* Experimenter type not supported. */
1084  OFPBRC_EPERM = 5, /* Permissions error. */
1085  OFPBRC_BAD_LEN = 6, /* Wrong request length for type. */
1086  OFPBRC_BUFFER_EMPTY = 7, /* Specified buffer has already been used. */
1087  OFPBRC_BUFFER_UNKNOWN = 8, /* Specified buffer does not exist. */
1088  OFPBRC_BAD_TABLE_ID = 9, /* Specified table-id invalid or does not
1089  * exist. */
1090  OFPBRC_IS_SLAVE = 10, /* Denied because controller is slave. */
1091  OFPBRC_BAD_PORT = 11, /* Invalid port. */
1092  OFPBRC_BAD_PACKET = 12, /* Invalid packet in packet-out. */
1093  };
1094 
1095 
1096  /* ofp_error_msg 'code' values for OFPET_BAD_ACTION. 'data' contains at least
1097  * the first 64 bytes of the failed request. */
1098  enum ofp_bad_action_code {
1099  OFPBAC_BAD_TYPE, /* Unknown action type. */
1100  OFPBAC_BAD_LEN, /* Length problem in actions. */
1101  OFPBAC_BAD_EXPERIMENTER, /* Unknown experimenter id specified. */
1102  OFPBAC_BAD_EXPERIMENTER_TYPE, /* Unknown action type for experimenter id. */
1103  OFPBAC_BAD_OUT_PORT, /* Problem validating output port. */
1104  OFPBAC_BAD_ARGUMENT, /* Bad action argument. */
1105  OFPBAC_EPERM, /* Permissions error. */
1106  OFPBAC_TOO_MANY, /* Can't handle this many actions. */
1107  OFPBAC_BAD_QUEUE, /* Problem validating output queue. */
1108  OFPBAC_BAD_OUT_GROUP, /* Invalid group id in forward action. */
1109  OFPBAC_MATCH_INCONSISTENT, /* Action can't apply for this match. */
1110  OFPBAC_UNSUPPORTED_ORDER, /* Action order is unsupported for the action
1111  list in an Apply-Actions instruction */
1112  OFPBAC_BAD_TAG, /* Actions uses an unsupported
1113  tag/encap. */
1114  };
1115 
1116  /* ofp_error_msg 'code' values for OFPET_BAD_INSTRUCTION. 'data' contains at least
1117  * the first 64 bytes of the failed request. */
1118  enum ofp_bad_instruction_code {
1119  OFPBIC_UNKNOWN_INST, /* Unknown instruction. */
1120  OFPBIC_UNSUP_INST, /* Switch or table does not support the
1121  instruction. */
1122  OFPBIC_BAD_TABLE_ID, /* Invalid Table-ID specified. */
1123  OFPBIC_UNSUP_METADATA, /* Metadata value unsupported by datapath. */
1124  OFPBIC_UNSUP_METADATA_MASK,/* Metadata mask value unsupported by
1125  datapath. */
1126  OFPBIC_UNSUP_EXP_INST, /* Specific experimenter instruction
1127  unsupported. */
1128  };
1129 
1130  /* ofp_error_msg 'code' values for OFPET_BAD_MATCH. 'data' contains at least
1131  * the first 64 bytes of the failed request. */
1132  enum ofp_bad_match_code {
1133  OFPBMC_BAD_TYPE, /* Unsupported match type specified by the
1134  match */
1135  OFPBMC_BAD_LEN, /* Length problem in match. */
1136  OFPBMC_BAD_TAG, /* Match uses an unsupported tag/encap. */
1137  OFPBMC_BAD_DL_ADDR_MASK, /* Unsupported datalink addr mask - switch does
1138  not support arbitrary datalink address
1139  mask. */
1140  OFPBMC_BAD_NW_ADDR_MASK, /* Unsupported network addr mask - switch does
1141  not support arbitrary network address
1142  mask. */
1143  OFPBMC_BAD_WILDCARDS, /* Unsupported wildcard specified in the
1144  match. */
1145  OFPBMC_BAD_FIELD, /* Unsupported field in the match. */
1146  OFPBMC_BAD_VALUE, /* Unsupported value in a match field. */
1147  OFPBMC_BAD_MASK, /* Unsupported mask specified in the match,
1148  * field is not dl-address or nw-address. */
1149  OFPBMC_BAD_PREREQ, /* A prerequisite was not met. */
1150  OFPBMC_DUP_FIELD, /* A field type was duplicated. */
1151  OFPBMC_EPERM, /* Permissions error. */
1152  };
1153 
1154  /* ofp_error_msg 'code' values for OFPET_FLOW_MOD_FAILED. 'data' contains
1155  * at least the first 64 bytes of the failed request. */
1156  enum ofp_flow_mod_failed_code {
1157  OFPFMFC_UNKNOWN, /* Unspecified error. */
1158  OFPFMFC_TABLE_FULL, /* Flow not added because table was full. */
1159  OFPFMFC_BAD_TABLE_ID, /* Table does not exist */
1160  OFPFMFC_OVERLAP, /* Attempted to add overlapping flow with
1161  CHECK_OVERLAP flag set. */
1162  OFPFMFC_EPERM, /* Permissions error. */
1163  OFPFMFC_BAD_TIMEOUT, /* Flow not added because of unsupported
1164  idle/hard timeout. */
1165  OFPFMFC_BAD_COMMAND, /* Unsupported or unknown command. */
1166  };
1167 
1168  /* ofp_error_msg 'code' values for OFPET_GROUP_MOD_FAILED. 'data' contains
1169  * at least the first 64 bytes of the failed request. */
1170  enum ofp_group_mod_failed_code {
1171  OFPGMFC_GROUP_EXISTS = 0, /* Group not added because a group ADD
1172  * attempted to replace an
1173  * already-present group. */
1174  OFPGMFC_INVALID_GROUP = 1, /* Group not added because Group specified
1175  * is invalid. */
1176  OFPGMFC_WEIGHT_UNSUPPORTED = 2, /* Switch does not support unequal load
1177  * sharing with select groups. */
1178  OFPGMFC_OUT_OF_GROUPS = 3, /* The group table is full. */
1179  OFPGMFC_OUT_OF_BUCKETS = 4, /* The maximum number of action buckets
1180  * for a group has been exceeded. */
1181  OFPGMFC_CHAINING_UNSUPPORTED = 5, /* Switch does not support groups that
1182  * forward to groups. */
1183  OFPGMFC_WATCH_UNSUPPORTED = 6, /* This group cannot watch the
1184  watch_port or watch_group specified. */
1185  OFPGMFC_LOOP = 7, /* Group entry would cause a loop. */
1186  OFPGMFC_UNKNOWN_GROUP = 8, /* Group not modified because a group
1187  MODIFY attempted to modify a
1188  non-existent group. */
1189  OFPGMFC_CHAINED_GROUP = 9, /* Group not deleted because another
1190  group is forwarding to it. */
1191  OFPGMFC_BAD_TYPE = 10, /* Unsupported or unknown group type. */
1192  OFPGMFC_BAD_COMMAND = 11, /* Unsupported or unknown command. */
1193  OFPGMFC_BAD_BUCKET = 12, /* Error in bucket. */
1194  OFPGMFC_BAD_WATCH = 13, /* Error in watch port/group. */
1195  OFPGMFC_EPERM = 14, /* Permissions error. */
1196  };
1197 
1198  /* ofp_error_msg 'code' values for OFPET_PORT_MOD_FAILED. 'data' contains
1199  * at least the first 64 bytes of the failed request. */
1200  enum ofp_port_mod_failed_code {
1201  OFPPMFC_BAD_PORT, /* Specified port number does not exist. */
1202  OFPPMFC_BAD_HW_ADDR, /* Specified hardware address does not
1203  * match the port number. */
1204  OFPPMFC_BAD_CONFIG, /* Specified config is invalid. */
1205  OFPPMFC_BAD_ADVERTISE /* Specified advertise is invalid. */
1206  };
1207 
1208  /* ofp_error_msg 'code' values for OFPET_TABLE_MOD_FAILED. 'data' contains
1209  * at least the first 64 bytes of the failed request. */
1210  enum ofp_table_mod_failed_code {
1211  OFPTMFC_BAD_TABLE, /* Specified table does not exist. */
1212  OFPTMFC_BAD_CONFIG /* Specified config is invalid. */
1213  };
1214 
1215  /* ofp_error msg 'code' values for OFPET_QUEUE_OP_FAILED. 'data' contains
1216  * at least the first 64 bytes of the failed request */
1217  enum ofp_queue_op_failed_code {
1218  OFPQOFC_BAD_PORT, /* Invalid port (or port does not exist). */
1219  OFPQOFC_BAD_QUEUE, /* Queue does not exist. */
1220  OFPQOFC_EPERM /* Permissions error. */
1221  };
1222 
1223  /* ofp_error_msg 'code' values for OFPET_SWITCH_CONFIG_FAILED. 'data' contains
1224  * at least the first 64 bytes of the failed request. */
1225  enum ofp_switch_config_failed_code {
1226  OFPSCFC_BAD_FLAGS, /* Specified flags is invalid. */
1227  OFPSCFC_BAD_LEN /* Specified len is invalid. */
1228  };
1229 
1230  /* ofp_error_msg ’code’ values for OFPET_ROLE_REQUEST_FAILED. ’data’ contains
1231  * at least the first 64 bytes of the failed request. */
1232  enum ofp_role_request_failed_code {
1233  OFPRRFC_STALE = 0, /* Stale Message: old generation_id. */
1234  OFPRRFC_UNSUP = 1, /* Controller role change unsupported. */
1235  OFPRRFC_BAD_ROLE = 2, /* Invalid role. */
1236  };
1237 
1238 
1239  enum ofp_stats_types {
1240  /* Description of this OpenFlow switch.
1241  * The request body is empty.
1242  * The reply body is struct ofp_desc_stats. */
1243  OFPST_DESC = 0,
1244 
1245  /* Individual flow statistics.
1246  * The request body is struct ofp_flow_stats_request.
1247  * The reply body is an array of struct ofp_flow_stats. */
1248  OFPST_FLOW = 1,
1249 
1250  /* Aggregate flow statistics.
1251  * The request body is struct ofp_aggregate_stats_request.
1252  * The reply body is struct ofp_aggregate_stats_reply. */
1253  OFPST_AGGREGATE = 2,
1254 
1255  /* Flow table statistics.
1256  * The request body is empty.
1257  * The reply body is an array of struct ofp_table_stats. */
1258  OFPST_TABLE = 3,
1259 
1260  /* Port statistics.
1261  * The request body is struct ofp_port_stats_request.
1262  * The reply body is an array of struct ofp_port_stats. */
1263  OFPST_PORT = 4,
1264 
1265  /* Queue statistics for a port
1266  * The request body defines the port
1267  * The reply body is an array of struct ofp_queue_stats */
1268  OFPST_QUEUE = 5,
1269 
1270  /* Group counter statistics.
1271  * The request body is empty.
1272  * The reply is struct ofp_group_stats. */
1273  OFPST_GROUP = 6,
1274 
1275  /* Group description statistics.
1276  * The request body is empty.
1277  * The reply body is struct ofp_group_desc_stats. */
1278  OFPST_GROUP_DESC = 7,
1279 
1280  /* Group features.
1281  * The request body is empty.
1282  * The reply body is struct ofp_group_features_stats. */
1283  OFPST_GROUP_FEATURES = 8,
1284 
1285  /* Experimenter extension.
1286  * The request and reply bodies begin with a 32-bit experimenter ID,
1287  * which takes the same form as in "struct ofp_experimenter_header".
1288  * The request and reply bodies are otherwise experimenter-defined. */
1289  OFPST_EXPERIMENTER = 0xffff
1290  };
1291 
1293  struct ofp_header header;
1294  uint16_t type; /* One of the OFPST_* constants. */
1295  uint16_t flags; /* OFPSF_REQ_* flags (none yet defined). */
1296  uint8_t pad[4];
1297  uint8_t body[0]; /* Body of the request. */
1298  };
1299  OFP_ASSERT(sizeof(struct ofp_stats_request) == 16);
1300 
1301  enum ofp_stats_reply_flags {
1302  OFPSF_REPLY_MORE = 1 << 0 /* More replies to follow. */
1303  };
1304 
1306  struct ofp_header header;
1307  uint16_t type; /* One of the OFPST_* constants. */
1308  uint16_t flags; /* OFPSF_REPLY_* flags. */
1309  uint8_t pad[4];
1310  uint8_t body[0]; /* Body of the reply. */
1311  };
1312  OFP_ASSERT(sizeof(struct ofp_stats_reply) == 16);
1313 
1314  #define DESC_STR_LEN 256
1315  #define SERIAL_NUM_LEN 32
1316  /* Body of reply to OFPST_DESC request. Each entry is a NULL-terminated
1317  * ASCII string. */
1319  char mfr_desc[DESC_STR_LEN]; /* Manufacturer description. */
1320  char hw_desc[DESC_STR_LEN]; /* Hardware description. */
1321  char sw_desc[DESC_STR_LEN]; /* Software description. */
1322  char serial_num[SERIAL_NUM_LEN]; /* Serial number. */
1323  char dp_desc[DESC_STR_LEN]; /* Human readable description of datapath. */
1324  };
1325  OFP_ASSERT(sizeof(struct ofp_desc_stats) == 1056);
1326 
1327  /* Body for ofp_stats_request of type OFPST_FLOW. */
1329  uint8_t table_id; /* ID of table to read (from ofp_table_stats),
1330  0xff for all tables. */
1331  uint8_t pad[3]; /* Align to 64 bits. */
1332  uint32_t out_port; /* Require matching entries to include this
1333  as an output port. A value of OFPP_ANY
1334  indicates no restriction. */
1335  uint32_t out_group; /* Require matching entries to include this
1336  as an output group. A value of OFPG_ANY
1337  indicates no restriction. */
1338  uint8_t pad2[4]; /* Align to 64 bits. */
1339  uint64_t cookie; /* Require matching entries to contain this
1340  cookie value */
1341  uint64_t cookie_mask; /* Mask used to restrict the cookie bits that
1342  must match. A value of 0 indicates
1343  no restriction. */
1344  struct ofp_match match; /* Fields to match. */
1345  };
1346  OFP_ASSERT(sizeof(struct ofp_flow_stats_request) == 40);
1347 
1348  /* Body of reply to OFPST_FLOW request. */
1350  uint16_t length; /* Length of this entry. */
1351  uint8_t table_id; /* ID of table flow came from. */
1352  uint8_t pad;
1353  uint32_t duration_sec; /* Time flow has been alive in seconds. */
1354  uint32_t duration_nsec; /* Time flow has been alive in nanoseconds beyond
1355  duration_sec. */
1356  uint16_t priority; /* Priority of the entry. Only meaningful
1357  when this is not an exact-match entry. */
1358  uint16_t idle_timeout; /* Number of seconds idle before expiration. */
1359  uint16_t hard_timeout; /* Number of seconds before expiration. */
1360  uint8_t pad2[6]; /* Align to 64-bits. */
1361  uint64_t cookie; /* Opaque controller-issued identifier. */
1362  uint64_t packet_count; /* Number of packets in flow. */
1363  uint64_t byte_count; /* Number of bytes in flow. */
1364  struct ofp_match match; /* Description of fields. */
1365  //struct ofp_instruction instructions[0]; /* Instruction set. */
1366  };
1367  OFP_ASSERT(sizeof(struct ofp_flow_stats) == 56);
1368 
1369  /* Body for ofp_stats_request of type OFPST_AGGREGATE. */
1371  uint8_t table_id; /* ID of table to read (from ofp_table_stats)
1372  0xff for all tables. */
1373  uint8_t pad[3]; /* Align to 64 bits. */
1374  uint32_t out_port; /* Require matching entries to include this
1375  as an output port. A value of OFPP_ANY
1376  indicates no restriction. */
1377  uint32_t out_group; /* Require matching entries to include this
1378  as an output group. A value of OFPG_ANY
1379  indicates no restriction. */
1380  uint8_t pad2[4]; /* Align to 64 bits. */
1381  uint64_t cookie; /* Require matching entries to contain this
1382  cookie value */
1383  uint64_t cookie_mask; /* Mask used to restrict the cookie bits that
1384  must match. A value of 0 indicates
1385  no restriction. */
1386  struct ofp_match match; /* Fields to match. */
1387  };
1388  OFP_ASSERT(sizeof(struct ofp_aggregate_stats_request) == 40);
1389 
1390  /* Body of reply to OFPST_AGGREGATE request. */
1392  uint64_t packet_count; /* Number of packets in flows. */
1393  uint64_t byte_count; /* Number of bytes in flows. */
1394  uint32_t flow_count; /* Number of flows. */
1395  uint8_t pad[4]; /* Align to 64 bits. */
1396  };
1397  OFP_ASSERT(sizeof(struct ofp_aggregate_stats_reply) == 24);
1398 
1399  /* Flow match fields. */
1400  enum ofp_flow_match_fields {
1401  OFPFMF_IN_PORT = 1 << 0, /* Switch input port. */
1402  OFPFMF_DL_VLAN = 1 << 1, /* VLAN id. */
1403  OFPFMF_DL_VLAN_PCP = 1 << 2, /* VLAN priority. */
1404  OFPFMF_DL_TYPE = 1 << 3, /* Ethernet frame type. */
1405  OFPFMF_NW_TOS = 1 << 4, /* IP ToS (DSCP field, 6 bits). */
1406  OFPFMF_NW_PROTO = 1 << 5, /* IP protocol. */
1407  OFPFMF_TP_SRC = 1 << 6, /* TCP/UDP/SCTP source port. */
1408  OFPFMF_TP_DST = 1 << 7, /* TCP/UDP/SCTP destination port. */
1409  OFPFMF_MPLS_LABEL = 1 << 8, /* MPLS label. */
1410  OFPFMF_MPLS_TC = 1 << 9, /* MPLS TC. */
1411  OFPFMF_TYPE = 1 << 10, /* Match type. */
1412  OFPFMF_DL_SRC = 1 << 11, /* Ethernet source address. */
1413  OFPFMF_DL_DST = 1 << 12, /* Ethernet destination address. */
1414  OFPFMF_NW_SRC = 1 << 13, /* IP source address. */
1415  OFPFMF_NW_DST = 1 << 14, /* IP destination address. */
1416  OFPFMF_METADATA = 1 << 15, /* Metadata passed between tables. */
1417  #ifdef ORAN
1418  OFPFMF_PPPOE_CODE = 1 << 16, /* PPPoE code */
1419  OFPFMF_PPPOE_TYPE = 1 << 17, /* PPPoE type */
1420  OFPFMF_PPPOE_SESS = 1 << 18, /* PPPoE session */
1421  OFPFMF_PPP_PROT = 1 << 19, /* PPP code */
1422  #endif
1423  };
1424 
1425  /* Body of reply to OFPST_TABLE request. */
1427  uint8_t table_id; /* Identifier of table. Lower numbered tables
1428  are consulted first. */
1429  uint8_t pad[7]; /* Align to 64-bits. */
1430  char name[OFP_MAX_TABLE_NAME_LEN];
1431  uint64_t match; /* Bitmap of (1 << OFPXMT_*) that indicate the
1432  fields the table can match on. */
1433  uint64_t wildcards; /* Bitmap of (1 << OFPXMT_*) wildcards that are
1434  supported by the table. */
1435  uint32_t write_actions; /* Bitmap of OFPAT_* that are supported
1436  by the table with OFPIT_WRITE_ACTIONS. */
1437  uint32_t apply_actions; /* Bitmap of OFPAT_* that are supported
1438  by the table with OFPIT_APPLY_ACTIONS. */
1439  uint64_t write_setfields;/* Bitmap of (1 << OFPXMT_*) header fields that
1440  can be set with OFPIT_WRITE_ACTIONS. */
1441  uint64_t apply_setfields;/* Bitmap of (1 << OFPXMT_*) header fields that
1442  can be set with OFPIT_APPLY_ACTIONS. */
1443  uint64_t metadata_match; /* Bits of metadata table can match. */
1444  uint64_t metadata_write; /* Bits of metadata table can write. */
1445  uint32_t instructions; /* Bitmap of OFPIT_* values supported. */
1446  uint32_t config; /* Bitmap of OFPTC_* values */
1447  uint32_t max_entries; /* Max number of entries supported. */
1448  uint32_t active_count; /* Number of active entries. */
1449  uint64_t lookup_count; /* Number of packets looked up in table. */
1450  uint64_t matched_count; /* Number of packets that hit table. */
1451  };
1452  OFP_ASSERT(sizeof(struct ofp_table_stats) == 128);
1453 
1454  /* Body for ofp_stats_request of type OFPST_PORT. */
1456  uint32_t port_no; /* OFPST_PORT message must request statistics
1457  * either for a single port (specified in
1458  * port_no) or for all ports (if port_no ==
1459  * OFPP_ANY). */
1460  uint8_t pad[4];
1461  };
1462  OFP_ASSERT(sizeof(struct ofp_port_stats_request) == 8);
1463 
1464  /* Body of reply to OFPST_PORT request. If a counter is unsupported, set
1465  * the field to all ones. */
1467  uint32_t port_no;
1468  uint8_t pad[4]; /* Align to 64-bits. */
1469  uint64_t rx_packets; /* Number of received packets. */
1470  uint64_t tx_packets; /* Number of transmitted packets. */
1471  uint64_t rx_bytes; /* Number of received bytes. */
1472  uint64_t tx_bytes; /* Number of transmitted bytes. */
1473  uint64_t rx_dropped; /* Number of packets dropped by RX. */
1474  uint64_t tx_dropped; /* Number of packets dropped by TX. */
1475  uint64_t rx_errors; /* Number of receive errors. This is a super-set
1476  of more specific receive errors and should be
1477  greater than or equal to the sum of all
1478  rx_*_err values. */
1479  uint64_t tx_errors; /* Number of transmit errors. This is a super-set
1480  of more specific transmit errors and should be
1481  greater than or equal to the sum of all
1482  tx_*_err values (none currently defined.) */
1483  uint64_t rx_frame_err; /* Number of frame alignment errors. */
1484  uint64_t rx_over_err; /* Number of packets with RX overrun. */
1485  uint64_t rx_crc_err; /* Number of CRC errors. */
1486  uint64_t collisions; /* Number of collisions. */
1487  };
1488  OFP_ASSERT(sizeof(struct ofp_port_stats) == 104);
1489 
1490  /* Body of OFPST_GROUP request. */
1492  uint32_t group_id; /* All groups if OFPG_ALL. */
1493  uint8_t pad[4]; /* Align to 64 bits. */
1494  };
1495  OFP_ASSERT(sizeof(struct ofp_group_stats_request) == 8);
1496 
1497  /* Used in group stats replies. */
1499  uint64_t packet_count; /* Number of packets processed by bucket. */
1500  uint64_t byte_count; /* Number of bytes processed by bucket. */
1501  };
1502  OFP_ASSERT(sizeof(struct ofp_bucket_counter) == 16);
1503 
1504  /* Body of reply to OFPST_GROUP request. */
1506  uint16_t length; /* Length of this entry. */
1507  uint8_t pad[2]; /* Align to 64 bits. */
1508  uint32_t group_id; /* Group identifier. */
1509  uint32_t ref_count; /* Number of flows or groups that directly forward
1510  to this group. */
1511  uint8_t pad2[4]; /* Align to 64 bits. */
1512  uint64_t packet_count; /* Number of packets processed by group. */
1513  uint64_t byte_count; /* Number of bytes processed by group. */
1514  struct ofp_bucket_counter bucket_stats[0];
1515  };
1516  OFP_ASSERT(sizeof(struct ofp_group_stats) == 32);
1517 
1518  /* Body of reply to OFPST_GROUP_DESC request. */
1520  uint16_t length; /* Length of this entry. */
1521  uint8_t type; /* One of OFPGT_*. */
1522  uint8_t pad; /* Pad to 64 bits. */
1523  uint32_t group_id; /* Group identifier. */
1524  struct ofp_bucket buckets[0];
1525  };
1526  OFP_ASSERT(sizeof(struct ofp_group_desc_stats) == 8);
1527 
1528  /* Body of reply to OFPST_GROUP_FEATURES request. Group features. */
1530  uint32_t types; /* Bitmap of OFPGT_* values supported. */
1531  uint32_t capabilities; /* Bitmap of OFPGFC_* capability supported. */
1532  uint32_t max_groups[4]; /* Maximum number of groups for each type. */
1533  uint32_t actions[4]; /* Bitmaps of OFPAT_* that are supported. */
1534  };
1535  OFP_ASSERT(sizeof(struct ofp_group_features_stats) == 40);
1536 
1537  /* Group configuration flags */
1538  enum ofp_group_capabilities {
1539  OFPGFC_SELECT_WEIGHT = 1 << 0, /* Support weight for select groups */
1540  OFPGFC_SELECT_LIVENESS = 1 << 1, /* Support liveness for select groups */
1541  OFPGFC_CHAINING = 1 << 2, /* Support chaining groups */
1542  OFPGFC_CHAINING_CHECKS = 1 << 3, /* Check chaining for loops and delete */
1543  };
1544 
1545 
1546  /* Body for ofp_stats_request/reply of type OFPST_EXPERIMENTER. */
1548  uint32_t experimenter;
1549  /* Experimenter ID which takes the same form
1550  as in struct ofp_experimenter_header. */
1551  uint32_t exp_type;
1552  /* Experimenter defined. */
1553  /* Experimenter-defined arbitrary additional data. */
1554  };
1555  OFP_ASSERT(sizeof(struct ofp_experimenter_stats_header) == 8);
1556 
1557 
1558  /* Experimenter extension. */
1560  struct ofp_header header; /* Type OFPT_EXPERIMENTER. */
1561  uint32_t experimenter; /* Experimenter ID:
1562  * - MSB 0: low-order bytes are IEEE OUI.
1563  * - MSB != 0: defined by OpenFlow
1564  * consortium. */
1565  uint32_t exp_type; /* Experimenter defined. */
1566  /* Experimenter-defined arbitrary additional data. */
1567  uint8_t body[0];
1568  };
1569  OFP_ASSERT(sizeof(struct ofp_experimenter_header) == 16);
1570 
1571  /* All ones is used to indicate all queues in a port (for stats retrieval). */
1572  #define OFPQ_ALL 0xffffffff
1573 
1574  /* Min rate > 1000 means not configured. */
1575  #define OFPQ_MIN_RATE_UNCFG 0xffff
1576 
1577  enum ofp_queue_properties {
1578  OFPQT_NONE = 0, /* No property defined for queue (default). */
1579  OFPQT_MIN_RATE = 1, /* Minimum datarate guaranteed. */
1580  /* Other types should be added here
1581  * (i.e. max rate, precedence, etc). */
1582  OFPQT_MAX_RATE = 2,
1583  OFPQT_EXPERIMENTER = 0xffff,
1584  };
1585 
1586  /* Common description for a queue. */
1588  uint16_t property; /* One of OFPQT_. */
1589  uint16_t len; /* Length of property, including this header. */
1590  uint8_t pad[4]; /* 64-bit alignemnt. */
1591  };
1592  OFP_ASSERT(sizeof(struct ofp_queue_prop_header) == 8);
1593 
1594  /* Min-Rate queue property description. */
1596  struct ofp_queue_prop_header prop_header; /* prop: OFPQT_MIN, len: 16. */
1597  uint16_t rate; /* In 1/10 of a percent; >1000 -> disabled. */
1598  uint8_t pad[6]; /* 64-bit alignment */
1599  };
1600  OFP_ASSERT(sizeof(struct ofp_queue_prop_min_rate) == 16);
1601 
1603  struct ofp_queue_prop_header prop_header; /* prop: OFPQT_EXPERIMENTER, len: 16. */
1604  uint32_t experimenter;
1605  uint8_t pad[4]; /* 64-bit alignment */
1606  uint8_t data[0];
1607  };
1608  OFP_ASSERT(sizeof(struct ofp_queue_prop_experimenter) == 16);
1609 
1610  /* Full description for a queue. */
1612  uint32_t queue_id; /* id for the specific queue. */
1613  uint32_t port; /* Port this queue is attached to. */
1614  uint16_t len; /* Length in bytes of this queue desc. */
1615  uint8_t pad[6]; /* 64-bit alignment. */
1616  struct ofp_queue_prop_header properties[0]; /* List of properties. */
1617  };
1618  OFP_ASSERT(sizeof(struct ofp_packet_queue) == 16);
1619 
1620  /* Query for port queue configuration. */
1622  struct ofp_header header;
1623  uint32_t port; /* Port to be queried. Should refer
1624  to a valid physical port (i.e. < OFPP_MAX) */
1625  uint8_t pad[4];
1626  };
1627  OFP_ASSERT(sizeof(struct ofp_queue_get_config_request) == 16);
1628 
1629  /* Queue configuration for a given port. */
1631  struct ofp_header header;
1632  uint32_t port;
1633  uint8_t pad[4];
1634  struct ofp_packet_queue queues[0]; /* List of configured queues. */
1635  };
1636  OFP_ASSERT(sizeof(struct ofp_queue_get_config_reply) == 16);
1637 
1638 
1639 
1640 
1641  /* OFPAT_SET_QUEUE action struct: send packets to given queue on port. */
1643  uint16_t type; /* OFPAT_SET_QUEUE. */
1644  uint16_t len; /* Len is 8. */
1645  uint32_t queue_id; /* Queue id for the packets. */
1646  };
1647  OFP_ASSERT(sizeof(struct ofp_action_set_queue) == 8);
1648 
1650  uint32_t port_no; /* All ports if OFPP_ANY. */
1651  uint32_t queue_id; /* All queues if OFPQ_ALL. */
1652  };
1653  OFP_ASSERT(sizeof(struct ofp_queue_stats_request) == 8);
1654 
1656  uint32_t port_no;
1657  uint32_t queue_id; /* Queue i.d */
1658  uint64_t tx_bytes; /* Number of transmitted bytes. */
1659  uint64_t tx_packets; /* Number of transmitted packets. */
1660  uint64_t tx_errors; /* Number of packets dropped due to overrun. */
1661  };
1662  OFP_ASSERT(sizeof(struct ofp_queue_stats) == 32);
1663 
1664 
1665 
1666  /* Role request and reply message. */
1668  struct ofp_header header; /* Type OFPT_ROLE_REQUEST/OFPT_ROLE_REPLY. */
1669  uint32_t role; /* One of NX_ROLE_*. */
1670  uint8_t pad[4]; /* Align to 64 bits. */
1671  uint64_t generation_id; /* Master Election Generation Id */
1672  };
1673  OFP_ASSERT(sizeof(struct ofp_role_request) == 24);
1674 
1675  /* Controller roles. */
1676  enum ofp_controller_role {
1677  OFPCR_ROLE_NOCHANGE = 0, /* Don’t change current role. */
1678  OFPCR_ROLE_EQUAL = 1, /* Default role, full access. */
1679  OFPCR_ROLE_MASTER = 2, /* Full access, at most one master. */
1680  OFPCR_ROLE_SLAVE = 3, /* Read-only access. */
1681  };
1682 
1683 }; // end of namespace openflow12
1684 }; // end of namespace rofl
1685 
1686 #endif /* _OPENFLOW_OPENFLOW12_H */
Definition: openflow12.h:693
Definition: openflow12.h:1391
Definition: openflow12.h:1559
Definition: openflow12.h:1667
Definition: openflow12.h:684
Definition: openflow12.h:428
Definition: openflow12.h:1466
Definition: openflow12.h:1611
Definition: openflow12.h:1491
Definition: openflow12.h:1649
Definition: openflow12.h:1426
Definition: openflow12.h:311
Definition: openflow12.h:475
Definition: openflow12.h:226
Definition: openflow12.h:875
Definition: openflow12.h:1029
Definition: openflow12.h:288
Definition: openflow12.h:1642
Definition: openflow12.h:904
Definition: openflow12.h:652
Definition: openflow12.h:459
Definition: openflow12.h:670
Definition: openflow12.h:76
Definition: openflow12.h:1505
Definition: openflow12.h:194
Definition: openflow12.h:468
Definition: openflow12.h:380
Definition: openflow12.h:1529
Definition: openflow12.h:498
Definition: openflow12.h:175
Definition: openflow12.h:749
Definition: openflow12.h:488
Definition: openflow12.h:1498
Definition: openflow12.h:637
Definition: openflow12.h:1328
Definition: openflow12.h:64
Definition: openflow12.h:341
Definition: openflow12.h:1595
Definition: openflow12.h:1349
Definition: openflow12.h:702
Definition: openflow12.h:1318
Definition: openflow12.h:980
Definition: openflow12.h:1519
Definition: openflow12.h:591
Definition: openflow12.h:444
Definition: openflow12.h:1587
Definition: openflow12.h:723
Definition: openflow12.h:410
Definition: openflow12.h:1655
Definition: openflow12.h:1292
Definition: openflow12.h:350
Definition: openflow12.h:1305
Definition: openflow12.h:934
Definition: openflow12.h:1455
Definition: openflow12.h:715
Definition: openflow12.h:1000