Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
openflow13.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 #ifndef _OPENFLOW_OPENFLOW13_H
6 #define _OPENFLOW_OPENFLOW13_H 1
7 
8 #include "rofl/common/openflow/openflow_common.h"
9 
10 namespace rofl {
11 namespace openflow13 {
12 
13  enum ofp_version_t {
14  OFP_VERSION = 4,
15  };
16 
17  #define OFP13_VERSION 4
18 
19  enum ofp_buffer_t {
20  OFP_NO_BUFFER = 0xffffffff,
21  };
22 
23  // 7.1
24 
25  /* 7.1 Header on all OpenFlow packets. */
26  struct ofp_header {
27  uint8_t version; /* OFP10_VERSION. */
28  uint8_t type; /* One of the OFP10T_ constants. */
29  uint16_t length; /* Length including this ofp10_header. */
30  uint32_t xid; /* Transaction id associated with this packet.
31  Replies use the same id as was in the request
32  to facilitate pairing. */
33  };
34  OFP_ASSERT(sizeof(struct ofp_header) == 8);
35 
36  enum ofp_type {
37  /* Immutable messages. */
38  OFPT_HELLO = 0, /* Symmetric message */
39  OFPT_ERROR = 1, /* Symmetric message */
40  OFPT_ECHO_REQUEST = 2, /* Symmetric message */
41  OFPT_ECHO_REPLY = 3, /* Symmetric message */
42  OFPT_EXPERIMENTER = 4, /* Symmetric message */
43 
44  /* Switch configuration messages. */
45  OFPT_FEATURES_REQUEST = 5, /* Controller/switch message */
46  OFPT_FEATURES_REPLY = 6, /* Controller/switch message */
47  OFPT_GET_CONFIG_REQUEST = 7, /* Controller/switch message */
48  OFPT_GET_CONFIG_REPLY = 8, /* Controller/switch message */
49  OFPT_SET_CONFIG = 9, /* Controller/switch message */
50 
51  /* Asynchronous messages. */
52  OFPT_PACKET_IN = 10, /* Async message */
53  OFPT_FLOW_REMOVED = 11, /* Async message */
54  OFPT_PORT_STATUS = 12, /* Async message */
55 
56  /* Controller command messages. */
57  OFPT_PACKET_OUT = 13, /* Controller/switch message */
58  OFPT_FLOW_MOD = 14, /* Controller/switch message */
59  OFPT_GROUP_MOD = 15, /* Controller/switch message */
60  OFPT_PORT_MOD = 16, /* Controller/switch message */
61  OFPT_TABLE_MOD = 17, /* Controller/switch message */
62 
63  /* Multipart messages. */
64  OFPT_MULTIPART_REQUEST = 18, /* Controller/switch message */
65  OFPT_MULTIPART_REPLY = 19, /* Controller/switch message */
66 
67  /* Barrier messages. */
68  OFPT_BARRIER_REQUEST = 20, /* Controller/switch message */
69  OFPT_BARRIER_REPLY = 21, /* Controller/switch message */
70 
71  /* Queue Configuration messages. */
72  OFPT_QUEUE_GET_CONFIG_REQUEST = 22, /* Controller/switch message */
73  OFPT_QUEUE_GET_CONFIG_REPLY = 23, /* Controller/switch message */
74 
75  /* Controller role change request messages. */
76  OFPT_ROLE_REQUEST = 24, /* Controller/switch message */
77  OFPT_ROLE_REPLY = 25, /* Controller/switch message */
78 
79  /* Asynchronous message configuration. */
80  OFPT_GET_ASYNC_REQUEST = 26, /* Controller/switch message */
81  OFPT_GET_ASYNC_REPLY = 27, /* Controller/switch message */
82  OFPT_SET_ASYNC = 28, /* Controller/switch message */
83 
84  /* Meters and rate limiters configuration messages. */
85  OFPT_METER_MOD = 29, /* Controller/switch message */
86  };
87 
88  // 7.2.1
89 
90  /* 7.2.1 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  /* 7.2.1 Description of a port */
116  struct ofp_port {
117  uint32_t port_no;
118  uint8_t pad[4];
119  uint8_t hw_addr[OFP_ETH_ALEN];
120  uint8_t pad2[2]; /* Align to 64 bits. */
121  char name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated */
122 
123  uint32_t config; /* Bitmap of OFPPC_* flags. */
124  uint32_t state; /* Bitmap of OFPPS_* flags. */
125 
126  /* Bitmaps of OFPPF_* that describe features. All bits zeroed if
127  * unsupported or unavailable. */
128  uint32_t curr; /* Current features. */
129  uint32_t advertised; /* Features being advertised by the port. */
130  uint32_t supported; /* Features supported by the port. */
131  uint32_t peer; /* Features advertised by peer. */
132 
133  uint32_t curr_speed; /* Current port bitrate in kbps. */
134  uint32_t max_speed; /* Max port bitrate in kbps */
135  };
136  OFP_ASSERT(sizeof(struct ofp_port) == 64);
137 
138  /* Flags to indicate behavior of the physical port. These flags are
139  * used in ofp_port to describe the current configuration. They are
140  * used in the ofp_port_mod message to configure the port's behavior.
141  */
142  enum ofp_port_config {
143  OFPPC_PORT_DOWN = 1 << 0, /* Port is administratively down. */
144 
145  OFPPC_NO_RECV = 1 << 2, /* Drop all packets received by port. */
146  OFPPC_NO_FWD = 1 << 5, /* Drop packets forwarded to port. */
147  OFPPC_NO_PACKET_IN = 1 << 6 /* Do not send packet-in msgs for port. */
148  };
149 
150  /* Current state of the physical port. These are not configurable from
151  * the controller.
152  */
153  enum ofp_port_state {
154  OFPPS_LINK_DOWN = 1 << 0, /* No physical link present. */
155  OFPPS_BLOCKED = 1 << 1, /* Port is blocked */
156  OFPPS_LIVE = 1 << 2, /* Live for Fast Failover Group. */
157  };
158 
159  /* Features of ports available in a datapath. */
160  enum ofp_port_features {
161  OFPPF_10MB_HD = 1 << 0, /* 10 Mb half-duplex rate support. */
162  OFPPF_10MB_FD = 1 << 1, /* 10 Mb full-duplex rate support. */
163  OFPPF_100MB_HD = 1 << 2, /* 100 Mb half-duplex rate support. */
164  OFPPF_100MB_FD = 1 << 3, /* 100 Mb full-duplex rate support. */
165  OFPPF_1GB_HD = 1 << 4, /* 1 Gb half-duplex rate support. */
166  OFPPF_1GB_FD = 1 << 5, /* 1 Gb full-duplex rate support. */
167  OFPPF_10GB_FD = 1 << 6, /* 10 Gb full-duplex rate support. */
168  OFPPF_40GB_FD = 1 << 7, /* 40 Gb full-duplex rate support. */
169  OFPPF_100GB_FD = 1 << 8, /* 100 Gb full-duplex rate support. */
170  OFPPF_1TB_FD = 1 << 9, /* 1 Tb full-duplex rate support. */
171  OFPPF_OTHER = 1 << 10, /* Other rate, not in the list. */
172 
173  OFPPF_COPPER = 1 << 11, /* Copper medium. */
174  OFPPF_FIBER = 1 << 12, /* Fiber medium. */
175  OFPPF_AUTONEG = 1 << 13, /* Auto-negotiation. */
176  OFPPF_PAUSE = 1 << 14, /* Pause. */
177  OFPPF_PAUSE_ASYM = 1 << 15 /* Asymmetric pause. */
178  };
179 
180  // 7.2.2
181 
182  /* All ones is used to indicate all queues in a port (for stats retrieval). */
183  #define OFPQ_ALL 0xffffffff
184 
185  /* Min rate > 1000 means not configured. */
186  #define OFPQ_MIN_RATE_UNCFG 0xffff
187  #define OFPQ_MAX_RATE_UNCFG 0xffff
188 
189  enum ofp_queue_properties {
190  OFPQT_MIN_RATE = 1, /* Minimum datarate guaranteed. */
191  /* Other types should be added here
192  * (i.e. max rate, precedence, etc). */
193  OFPQT_MAX_RATE = 2,
194  OFPQT_EXPERIMENTER = 0xffff,
195  };
196 
197  /* Common description for a queue. */
199  uint16_t property; /* One of OFPQT_. */
200  uint16_t len; /* Length of property, including this header. */
201  uint8_t pad[4]; /* 64-bit alignment. */
202  };
203  OFP_ASSERT(sizeof(struct ofp_queue_prop_header) == 8);
204 
205  /* Full description for a queue. */
207  uint32_t queue_id; /* id for the specific queue. */
208  uint32_t port; /* Port this queue is attached to. */
209  uint16_t len; /* Length in bytes of this queue desc. */
210  uint8_t pad[6]; /* 64-bit alignment. */
211  struct ofp_queue_prop_header properties[0]; /* List of properties. */
212  };
213  OFP_ASSERT(sizeof(struct ofp_packet_queue) == 16);
214 
215  /* Min-Rate queue property description. */
217  struct ofp_queue_prop_header prop_header; /* prop: OFPQT_MIN, len: 16. */
218  uint16_t rate; /* In 1/10 of a percent; >1000 -> disabled. */
219  uint8_t pad[6]; /* 64-bit alignment */
220  };
221  OFP_ASSERT(sizeof(struct ofp_queue_prop_min_rate) == 16);
222 
223  /* Max-Rate queue property description. */
225  struct ofp_queue_prop_header prop_header; /* prop: OFPQT_MAX, len: 16. */
226  uint16_t rate; /* In 1/10 of a percent; >1000 -> disabled. */
227  uint8_t pad[6]; /* 64-bit alignment */
228  };
229  OFP_ASSERT(sizeof(struct ofp_queue_prop_max_rate) == 16);
230 
231  /* Experimenter queue property description. */
233  struct ofp_queue_prop_header prop_header; /* prop: OFPQT_EXPERIMENTER, len: 16. */
234  uint32_t experimenter; /* Experimenter ID which takes the same form as in struct ofp_experimenter_header. */
235  uint8_t pad[4]; /* 64-bit alignment */
236  uint8_t data[0]; /* Experimenter defined data. */
237  };
238  OFP_ASSERT(sizeof(struct ofp_queue_prop_experimenter) == 16);
239 
240 
241 
242  // 7.2.3
243 
244  /* Fields to match against flows */
245  struct ofp_match {
246  uint16_t type; /* One of OFPMT_* */
247  uint16_t length; /* Length of ofp_match (excluding padding) */
248  /* Followed by:
249  * - Exactly (length - 4) (possibly 0) bytes containing OXM TLVs, then
250  * - Exactly ((length + 7)/8*8 - length) (between 0 and 7) bytes of
251  * all-zero bytes
252  * In summary, ofp_match is padded as needed, to make its overall size
253  * a multiple of 8, to preserve alignment in structures using it.
254  */
255  uint8_t oxm_fields[0]; /* 0 or more OXM match fields */
256  uint8_t pad[4]; /* Zero bytes - see above for sizing */
257  };
258  OFP_ASSERT(sizeof(struct ofp_match) == 8);
259 
260  /* length of static part of ofp_match header */
261  static int const OFP_MATCH_STATIC_LEN = 2 * sizeof(uint16_t);
262 
263  /* The match type indicates the match structure (set of fields that compose the
264  * match) in use. The match type is placed in the type field at the beginning
265  * of all match structures. The "OpenFlow Extensible Match" type corresponds
266  * to OXM TLV format described below and must be supported by all OpenFlow
267  * switches. Extensions that define other match types may be published on the
268  * ONF wiki. Support for extensions is optional.
269  */
270  enum ofp_match_type {
271  OFPMT_STANDARD = 0, /* Deprecated. */
272  OFPMT_OXM = 1, /* OpenFlow Extensible Match */
273  };
274 
275  // 7.2.3.3
276 
277  /* OXM Class IDs.
278  * The high order bit differentiate reserved classes from member classes.
279  * Classes 0x0000 to 0x7FFF are member classes, allocated by ONF.
280  * Classes 0x8000 to 0xFFFE are reserved classes, reserved for standardisation.
281  */
282  enum ofp_oxm_class {
283  OFPXMC_NXM_0 = 0x0000, /* Backward compatibility with NXM */
284  OFPXMC_NXM_1 = 0x0001, /* Backward compatibility with NXM */
285  OFPXMC_OPENFLOW_BASIC = 0x8000, /* Basic class for OpenFlow */
286  OFPXMC_EXPERIMENTER = 0xFFFF, /* Experimenter class */
287  };
288 
289  // 7.2.3.7
290 
291  /* OXM Flow match field types for OpenFlow basic class. */
292  enum ofp_oxm_ofb_match_fields {
293  OFPXMT_OFB_IN_PORT = 0, /* Switch input port. */ // required
294  OFPXMT_OFB_IN_PHY_PORT = 1, /* Switch physical input port. */
295  OFPXMT_OFB_METADATA = 2, /* Metadata passed between tables. */
296  OFPXMT_OFB_ETH_DST = 3, /* Ethernet destination address. */ // required
297  OFPXMT_OFB_ETH_SRC = 4, /* Ethernet source address. */ // required
298  OFPXMT_OFB_ETH_TYPE = 5, /* Ethernet frame type. */ // required
299  OFPXMT_OFB_VLAN_VID = 6, /* VLAN id. */
300  OFPXMT_OFB_VLAN_PCP = 7, /* VLAN priority. */
301  OFPXMT_OFB_IP_DSCP = 8, /* IP DSCP (6 bits in ToS field). */
302  OFPXMT_OFB_IP_ECN = 9, /* IP ECN (2 bits in ToS field). */
303  OFPXMT_OFB_IP_PROTO = 10, /* IP protocol. */ // required
304  OFPXMT_OFB_IPV4_SRC = 11, /* IPv4 source address. */ // required
305  OFPXMT_OFB_IPV4_DST = 12, /* IPv4 destination address. */ // required
306  OFPXMT_OFB_TCP_SRC = 13, /* TCP source port. */ // required
307  OFPXMT_OFB_TCP_DST = 14, /* TCP destination port. */ // required
308  OFPXMT_OFB_UDP_SRC = 15, /* UDP source port. */ // required
309  OFPXMT_OFB_UDP_DST = 16, /* UDP destination port. */ // required
310  OFPXMT_OFB_SCTP_SRC = 17, /* SCTP source port. */
311  OFPXMT_OFB_SCTP_DST = 18, /* SCTP destination port. */
312  OFPXMT_OFB_ICMPV4_TYPE = 19, /* ICMP type. */
313  OFPXMT_OFB_ICMPV4_CODE = 20, /* ICMP code. */
314  OFPXMT_OFB_ARP_OP = 21, /* ARP opcode. */
315  OFPXMT_OFB_ARP_SPA = 22, /* ARP source IPv4 address. */
316  OFPXMT_OFB_ARP_TPA = 23, /* ARP target IPv4 address. */
317  OFPXMT_OFB_ARP_SHA = 24, /* ARP source hardware address. */
318  OFPXMT_OFB_ARP_THA = 25, /* ARP target hardware address. */
319  OFPXMT_OFB_IPV6_SRC = 26, /* IPv6 source address. */ // required
320  OFPXMT_OFB_IPV6_DST = 27, /* IPv6 destination address. */ // required
321  OFPXMT_OFB_IPV6_FLABEL = 28, /* IPv6 Flow Label */
322  OFPXMT_OFB_ICMPV6_TYPE = 29, /* ICMPv6 type. */
323  OFPXMT_OFB_ICMPV6_CODE = 30, /* ICMPv6 code. */
324  OFPXMT_OFB_IPV6_ND_TARGET = 31, /* Target address for ND. */
325  OFPXMT_OFB_IPV6_ND_SLL = 32, /* Source link-layer for ND. */
326  OFPXMT_OFB_IPV6_ND_TLL = 33, /* Target link-layer for ND. */
327  OFPXMT_OFB_MPLS_LABEL = 34, /* MPLS label. */
328  OFPXMT_OFB_MPLS_TC = 35, /* MPLS TC. */
329  OFPXMT_OFB_MPLS_BOS = 36, /* MPLS BoS bit. */
330  OFPXMT_OFB_PBB_ISID = 37, /* PBB I-SID. */
331  OFPXMT_OFB_TUNNEL_ID = 38, /* Logical Port Metadata. */
332  OFPXMT_OFB_IPV6_EXTHDR = 39, /* IPv6 Extension Header pseudo-field */
333  /* max value */
334  OFPXMT_OFB_MAX,
335  };
336 
337 #define OXM_TLV_HAS_MASK (1 << 8)
338 #define OXM_TLV_PAYLOAD_1BYTE (1)
339 #define OXM_TLV_PAYLOAD_2BYTES (2)
340 #define OXM_TLV_PAYLOAD_3BYTES (3)
341 #define OXM_TLV_PAYLOAD_4BYTES (4)
342 #define OXM_TLV_PAYLOAD_6BYTES (6)
343 #define OXM_TLV_PAYLOAD_8BYTES (8)
344 #define OXM_TLV_PAYLOAD_16BYTES (16)
345 
346 #define OXM_TLV_OFB_IN_PORT ((OFPXMC_OPENFLOW_BASIC << 16) + (OFPXMT_OFB_IN_PORT << 9) + OXM_TLV_PAYLOAD_4BYTES)
347 #define OXM_TLV_OFB_IN_PHY_PORT ((OFPXMC_OPENFLOW_BASIC << 16) + (OFPXMT_OFB_IN_PHY_PORT << 9) + OXM_TLV_PAYLOAD_4BYTES)
348 #define OXM_TLV_OFB_METADATA ((OFPXMC_OPENFLOW_BASIC << 16) + (OFPXMT_OFB_METADATA << 9) + OXM_TLV_PAYLOAD_8BYTES)
349 #define OXM_TLV_OFB_METADATA_MASK ((OFPXMC_OPENFLOW_BASIC << 16) + (OFPXMT_OFB_METADATA << 9) + 2*OXM_TLV_PAYLOAD_8BYTES + OXM_TLV_HAS_MASK)
350 #define OXM_TLV_OFB_ETH_DST ((OFPXMC_OPENFLOW_BASIC << 16) + (OFPXMT_OFB_ETH_DST << 9) + OXM_TLV_PAYLOAD_6BYTES)
351 #define OXM_TLV_OFB_ETH_DST_MASK ((OFPXMC_OPENFLOW_BASIC << 16) + (OFPXMT_OFB_ETH_DST << 9) + 2*OXM_TLV_PAYLOAD_6BYTES + OXM_TLV_HAS_MASK)
352 #define OXM_TLV_OFB_ETH_SRC ((OFPXMC_OPENFLOW_BASIC << 16) + (OFPXMT_OFB_ETH_SRC << 9) + OXM_TLV_PAYLOAD_6BYTES)
353 #define OXM_TLV_OFB_ETH_SRC_MASK ((OFPXMC_OPENFLOW_BASIC << 16) + (OFPXMT_OFB_ETH_SRC << 9) + 2*OXM_TLV_PAYLOAD_6BYTES + OXM_TLV_HAS_MASK)
354 #define OXM_TLV_OFB_ETH_TYPE ((OFPXMC_OPENFLOW_BASIC << 16) + (OFPXMT_OFB_ETH_TYPE << 9) + OXM_TLV_PAYLOAD_2BYTES)
355 // to be continued ...
356 
357  /* The VLAN id is 12-bits, so we can use the entire 16 bits to indicate
358  * special conditions.
359  */
360  enum ofp_vlan_id {
361  OFPVID_PRESENT = 0x1000, /* Bit that indicate that a VLAN id is set */
362  OFPVID_NONE = 0x0000, /* No VLAN id was set. */
363  };
364 
365  /* Bit definitions for IPv6 Extension Header pseudo-field. */
366  enum ofp_ipv6exthdr_flags {
367  OFPIEH_NONEXT = 1 << 0, /* "No next header" encountered. */
368  OFPIEH_ESP = 1 << 1, /* Encrypted Sec Payload header present. */
369  OFPIEH_AUTH = 1 << 2, /* Authentication header present. */
370  OFPIEH_DEST = 1 << 3, /* 1 or 2 dest headers present. */
371  OFPIEH_FRAG = 1 << 4, /* Fragment header present. */
372  OFPIEH_ROUTER = 1 << 5, /* Router header present. */
373  OFPIEH_HOP = 1 << 6, /* Hop-by-hop header present. */
374  OFPIEH_UNREP = 1 << 7, /* Unexpected repeats encountered. */
375  OFPIEH_UNSEQ = 1 << 8, /* Unexpected sequencing encountered. */
376  };
377 
378  struct ofp_oxm_hdr {
379  uint16_t oxm_class; /* oxm_class */
380  uint8_t oxm_field; /* includes has_mask bit! */
381  uint8_t oxm_length; /* oxm_length */
382  };
383 
384 
385  // OXM_OF_VLAN_PCP /* 3 bits */
386  // OXM_OF_IP_DSCP /* 6 bits */
387  // OXM_OF_IP_ECN /* 2 bits */
388  // OXM_OF_IP_PROTO /* 8 bits */
389  // OXM_OF_ICMPV4_TYPE
390  // OXM_OF_ICMPV4_CODE
391  // OXM_OF_ICMPV6_TYPE
392  // OXM_OF_ICMPV6_CODE
393  // OXM_OF_MPLS_TC /* 3 bits */
395  struct ofp_oxm_hdr hdr; /* oxm header */
396  uint8_t byte;
397  uint8_t mask;
398  };
399 
400 
401  // OXM_OF_ETH_TYPE
402  // OXM_OF_VLAN_VID (mask)
403  // OXM_OF_TCP_SRC
404  // OXM_OF_TCP_DST
405  // OXM_OF_UDP_SRC
406  // OXM_OF_UDP_DST
407  // OXM_OF_SCTP_SRC
408  // OXM_OF_SCTP_DST
409  // OXM_OF_ARP_OP
411  struct ofp_oxm_hdr hdr; /* oxm header */
412  uint16_t word; /* network byte order */
413  uint16_t mask;
414  };
415 
416 
417  // OXM_OF_IN_PORT
418  // OXM_OF_IN_PHY_PORT
419  // OXM_OF_IPV4_SRC (mask)
420  // OXM_OF_IPV4_DST (mask)
421  // OXM_OF_ARP_SPA (mask)
422  // OXM_OF_ARP_THA (mask)
423  // OXM_OF_IPV6_FLABEL (mask)
424  // OXM_OF_MPLS_LABEL
426  struct ofp_oxm_hdr hdr; /* oxm header */
427  uint32_t dword; /* network byte order */
428  uint32_t mask; /* only valid, when oxm_hasmask=1 */
429  };
430 
431 
432  // OXM_OF_IPV6_ND_SLL
433  // OXM_OF_IPV6_ND_TLL
435  struct ofp_oxm_hdr hdr; /* oxm header */
436  uint8_t value[6];
437  uint8_t mask[6]; /* only valid, when oxm_hasmask=1 */
438  };
439 
440  // OXM_OF_METADATA (mask)
442  struct ofp_oxm_hdr hdr; /* oxm header */
443  uint8_t word[8];
444  uint8_t mask[8];
445  };
446 
447  // OXM_OF_ETH_DST (mask)
448  // OXM_OF_ETH_SRC (mask)
450  struct ofp_oxm_hdr hdr; /* oxm header */
451  uint8_t addr[OFP_ETH_ALEN];
452  uint8_t mask[OFP_ETH_ALEN]; /* only valid, when oxm_hasmask=1 */
453  };
454 
455 
456  // OXM_OF_IPV6_SRC (mask)
457  // OXM_OF_IPV6_DST (mask)
458  // OXM_OF_IPV6_ND_TARGET
460  struct ofp_oxm_hdr hdr; /* oxm header */
461  uint8_t addr[16];
462  uint8_t mask[16]; /* only valid, when oxm_hasmask=1 */
463  };
464 
465  // 7.2.3.8
466 
467  /* Header for OXM experimenter match fields. */
469  uint32_t oxm_header; /* oxm_class = OFPXMC_EXPERIMENTER */
470  uint32_t experimenter; /* Experimenter ID which takes the same
471  form as in struct ofp_experimenter_header. */
472  };
473  OFP_ASSERT(sizeof(struct ofp_oxm_experimenter_header) == 8);
474 
475 
476 
477 
478  /*
479  * 7.2.4 Flow Instruction Structures
480  */
481 
482  enum ofp_instruction_type {
483  OFPIT_GOTO_TABLE = 1, /* Setup the next table in the lookup
484  pipeline */
485  OFPIT_WRITE_METADATA = 2, /* Setup the metadata field for use later in
486  pipeline */
487  OFPIT_WRITE_ACTIONS = 3, /* Write the action(s) onto the datapath action
488  set */
489  OFPIT_APPLY_ACTIONS = 4, /* Applies the action(s) immediately */
490  OFPIT_CLEAR_ACTIONS = 5, /* Clears all actions from the datapath
491  action set */
492  OFPIT_METER = 6, /* Apply meter (rate limiter) */
493  OFPIT_EXPERIMENTER = 0xFFFF /* Experimenter instruction */
494  };
495 
496  /* Instruction header that is common to all instructions. The length includes
497  * the header and any padding used to make the instruction 64-bit aligned.
498  * NB: The length of an instruction *must* always be a multiple of eight. */
500  uint16_t type; /* Instruction type */
501  uint16_t len; /* Length of this struct in bytes. */
502  };
503  OFP_ASSERT(sizeof(struct ofp_instruction) == 4);
504 
505  /* Instruction structure for OFPIT_GOTO_TABLE */
507  uint16_t type; /* OFPIT_GOTO_TABLE */
508  uint16_t len; /* Length of this struct in bytes. */
509  uint8_t table_id; /* Set next table in the lookup pipeline */
510  uint8_t pad[3]; /* Pad to 64 bits. */
511  };
512  OFP_ASSERT(sizeof(struct ofp_instruction_goto_table) == 8);
513 
514  /* Instruction structure for OFPIT_WRITE_METADATA */
516  uint16_t type; /* OFPIT_WRITE_METADATA */
517  uint16_t len; /* Length of this struct in bytes. */
518  uint8_t pad[4]; /* Align to 64-bits */
519  uint64_t metadata; /* Metadata value to write */
520  uint64_t metadata_mask; /* Metadata write bitmask */
521  };
522  OFP_ASSERT(sizeof(struct ofp_instruction_write_metadata) == 24);
523 
524  /* Action header that is common to all actions. The length includes the
525  * header and any padding used to make the action 64-bit aligned.
526  * NB: The length of an action *must* always be a multiple of eight. */
528  uint16_t type; /* One of OFPAT_*. */
529  uint16_t len; /* Length of action, including this
530  header. This is the length of action,
531  including any padding to make it
532  64-bit aligned. */
533  uint8_t pad[4];
534  };
535  OFP_ASSERT(sizeof(struct ofp_action_header) == 8);
536 
537  /* Instruction structure for OFPIT_WRITE/APPLY/CLEAR_ACTIONS */
539  uint16_t type; /* One of OFPIT_*_ACTIONS */
540  uint16_t len; /* Length of this struct in bytes. */
541  uint8_t pad[4]; /* Align to 64-bits */
542  struct ofp_action_header actions[0]; /* Actions associated with
543  OFPIT_WRITE_ACTIONS and
544  OFPIT_APPLY_ACTIONS */
545  };
546  OFP_ASSERT(sizeof(struct ofp_instruction_actions) == 8);
547 
548  /* Instruction structure for OFPIT_METER */
550  uint16_t type; /* OFPIT_METER */
551  uint16_t len; /* Length is 8. */
552  uint32_t meter_id; /* Meter instance. */
553  };
554  OFP_ASSERT(sizeof(struct ofp_instruction_meter) == 8);
555 
556  /* Instruction structure for experimental instructions */
558  uint16_t type; /* OFPIT_EXPERIMENTER */
559  uint16_t len; /* Length of this struct in bytes */
560  uint32_t experimenter; /* Experimenter ID:
561  * - MSB 0: low-order bytes are IEEE OUI.
562  * - MSB != 0: defined by OpenFlow
563  * consortium. */
564  uint8_t body[0];
565  /* Experimenter-defined arbitrary additional data. */
566  };
567  OFP_ASSERT(sizeof(struct ofp_instruction_experimenter) == 8);
568 
569 
570 
571 
572  /*
573  * 7.2.5. Action Structures
574  */
575 
576  enum ofp_action_type {
577  OFPAT_OUTPUT = 0, /* Output to switch port. */
578  OFPAT_COPY_TTL_OUT = 11, /* Copy TTL "outwards" -- from next-to-outermost to outermost */
579  OFPAT_COPY_TTL_IN = 12, /* Copy TTL "inwards" -- from outermost to next-to-outermost */
580  OFPAT_SET_MPLS_TTL = 15, /* MPLS TTL */
581  OFPAT_DEC_MPLS_TTL = 16, /* Decrement MPLS TTL */
582  OFPAT_PUSH_VLAN = 17, /* Push a new VLAN tag */
583  OFPAT_POP_VLAN = 18, /* Pop the outer VLAN tag */
584  OFPAT_PUSH_MPLS = 19, /* Push a new MPLS tag */
585  OFPAT_POP_MPLS = 20, /* Pop the outer MPLS tag */
586  OFPAT_SET_QUEUE = 21, /* Set queue id when outputting to a port */
587  OFPAT_GROUP = 22, /* Apply group. */
588  OFPAT_SET_NW_TTL = 23, /* IP TTL. */
589  OFPAT_DEC_NW_TTL = 24, /* Decrement IP TTL. */
590  OFPAT_SET_FIELD = 25, /* Set a header field using OXM TLV format. */
591  OFPAT_PUSH_PBB = 26, /* Push a new PBB service tag (I-TAG) */
592  OFPAT_POP_PBB = 27, /* Pop the outer PBB service tag (I-TAG) */
593  OFPAT_EXPERIMENTER = 0xffff
594  };
595 
596  /* Action structure for OFPAT_OUTPUT, which sends packets out 'port'.
597  * When the 'port' is the OFPP_CONTROLLER, 'max_len' indicates the max
598  * number of bytes to send. A 'max_len' of zero means no bytes of the
599  * packet should be sent.*/
601  uint16_t type; /* OFPAT_OUTPUT. */
602  uint16_t len; /* Length is 16. */
603  uint32_t port; /* Output port. */
604  uint16_t max_len; /* Max length to send to controller. */
605  uint8_t pad[6]; /* Pad to 64 bits. */
606  };
607  OFP_ASSERT(sizeof(struct ofp_action_output) == 16);
608 
609  enum ofp_controller_max_len {
610  OFPCML_MAX = 0xffe5, /* maximum max_len value which can be used to request a specific byte length. */
611  OFPCML_NO_BUFFER = 0xffff, /* indicates that no buffering should be
612  applied and the whole packet is to be
613  sent to the controller. */
614  };
615 
616  /* Action structure for OFPAT_GROUP. */
618  uint16_t type; /* OFPAT_GROUP. */
619  uint16_t len; /* Length is 8. */
620  uint32_t group_id; /* Group identifier. */
621  };
622  OFP_ASSERT(sizeof(struct ofp_action_group) == 8);
623 
624  /* OFPAT_SET_QUEUE action struct: send packets to given queue on port. */
626  uint16_t type; /* OFPAT_SET_QUEUE. */
627  uint16_t len; /* Len is 8. */
628  uint32_t queue_id; /* Queue id for the packets. */
629  };
630  OFP_ASSERT(sizeof(struct ofp_action_set_queue) == 8);
631 
632  /* Action structure for OFPAT_SET_MPLS_TTL. */
634  uint16_t type; /* OFPAT_SET_MPLS_TTL. */
635  uint16_t len; /* Length is 8. */
636  uint8_t mpls_ttl; /* MPLS TTL */
637  uint8_t pad[3];
638  };
639  OFP_ASSERT(sizeof(struct ofp_action_mpls_ttl) == 8);
640 
641  /* Action structure for OFPAT_SET_NW_TTL. */
643  uint16_t type; /* OFPAT_SET_NW_TTL. */
644  uint16_t len; /* Length is 8. */
645  uint8_t nw_ttl; /* IP TTL */
646  uint8_t pad[3];
647  };
648  OFP_ASSERT(sizeof(struct ofp_action_nw_ttl) == 8);
649 
650  /* Action structure for OFPAT_PUSH_VLAN/MPLS. */
652  uint16_t type; /* OFPAT_PUSH_VLAN/MPLS. */
653  uint16_t len; /* Length is 8. */
654  uint16_t ethertype; /* Ethertype */
655  uint8_t pad[2];
656  };
657  OFP_ASSERT(sizeof(struct ofp_action_push) == 8);
658 
659  /* Action structure for OFPAT_POP_MPLS. */
661  uint16_t type; /* OFPAT_POP_MPLS. */
662  uint16_t len; /* Length is 8. */
663  uint16_t ethertype; /* Ethertype */
664  uint8_t pad[2];
665  };
666  OFP_ASSERT(sizeof(struct ofp_action_pop_mpls) == 8);
667 
668  /* Action structure for OFPAT_SET_FIELD. */
670  uint16_t type; /* OFPAT_SET_FIELD. */
671  uint16_t len; /* Length is padded to 64 bits. */
672  /* Followed by:
673  * - Exactly oxm_len bytes containing a single OXM TLV, then
674  * - Exactly ((oxm_len + 4) + 7)/8*8 - (oxm_len + 4) (between 0 and 7)
675  * bytes of all-zero bytes
676  */
677  uint8_t field[4]; /* OXM TLV - Make compiler happy */
678  };
679  OFP_ASSERT(sizeof(struct ofp_action_set_field) == 8);
680 
681  /* Action header for OFPAT_EXPERIMENTER.
682  * The rest of the body is experimenter-defined. */
684  uint16_t type; /* OFPAT_EXPERIMENTER. */
685  uint16_t len; /* Length is a multiple of 8. */
686  uint32_t experimenter; /* Experimenter ID which takes the same
687  form as in struct
688  ofp_experimenter_header. */
689  //uint32_t exp_type;
690  uint8_t data[0];
691  };
692  OFP_ASSERT(sizeof(struct ofp_action_experimenter_header) == 8);
693 
694  /*
695  * 7.3.1 Handshake
696  */
697 
698  /* Switch features. */
700  struct ofp_header header;
701  uint64_t datapath_id; /* Datapath unique ID. The lower 48-bits are for
702  a MAC address, while the upper 16-bits are
703  implementer-defined. */
704  uint32_t n_buffers; /* Max packets buffered at once. */
705  uint8_t n_tables; /* Number of tables supported by datapath. */
706  uint8_t auxiliary_id; /* Identify auxiliary connections */
707  uint8_t pad[2]; /* Align to 64-bits. */
708  /* Features. */
709  uint32_t capabilities; /* Bitmap of support "ofp_capabilities". */
710  uint32_t reserved;
711  };
712  OFP_ASSERT(sizeof(struct ofp_switch_features) == 32);
713 
714  /* Capabilities supported by the datapath. */
715  enum ofp_capabilities {
716  OFPC_FLOW_STATS = 1 << 0, /* Flow statistics. */
717  OFPC_TABLE_STATS = 1 << 1, /* Table statistics. */
718  OFPC_PORT_STATS = 1 << 2, /* Port statistics. */
719  OFPC_GROUP_STATS = 1 << 3, /* Group statistics. */
720  OFPC_IP_REASM = 1 << 5, /* Can reassemble IP fragments. */
721  OFPC_QUEUE_STATS = 1 << 6, /* Queue statistics. */
722  //OFPC_ARP_MATCH_IP removed from OF1.3 /* Match IP addresses in ARP pkts. */
723  OFPC_PORT_BLOCKED = 1 << 8, /* Switch will block looping ports. */
724  };
725 
726  /*
727  * 7.3.2 Switch Configuration
728  */
729 
730  /* Switch configuration. */
732  struct ofp_header header;
733  uint16_t flags; /* OFPC_* flags. */
734  uint16_t miss_send_len; /* Max bytes of new flow that datapath should
735  send to the controller. */
736  };
737  OFP_ASSERT(sizeof(struct ofp_switch_config) == 12);
738 
739  enum ofp_config_flags {
740  /* Handling of IP fragments. */
741  OFPC_FRAG_NORMAL = 0, /* No special handling for fragments. */
742  OFPC_FRAG_DROP = 1 << 0, /* Drop fragments. */
743  OFPC_FRAG_REASM = 1 << 1, /* Reassemble (only if OFPC_IP_REASM set). */
744  OFPC_FRAG_MASK = 3,
745  // OFPC_INVALID_TTL_TO_CONTROLLER was removed in OF1.3
746  };
747 
748  /*
749  * 7.3.3.
750  */
751 
752  /* Table numbering. Tables can use any number up to OFPT_MAX. */
753  enum ofp_table {
754  /* Last usable table number. */
755  OFPTT_MAX = 0xfe,
756  /* Fake tables. */
757  OFPTT_ALL = 0xff /* Wildcard table used for table config,
758  flow stats and flow deletes. */
759  };
760 
761  /* Configure/Modify behavior of a flow table */
762  struct ofp_table_mod {
763  struct ofp_header header;
764  uint8_t table_id; /* ID of the table, 0xFF indicates all tables */
765  uint8_t pad[3]; /* Pad to 32 bits */
766  uint32_t config; /* Bitmap of OFPTC_* flags */
767  };
768  OFP_ASSERT(sizeof(struct ofp_table_mod) == 16);
769 
770  /* Flags to indicate behavior of the flow table for unmatched packets.
771  These flags are used in ofp_table_stats messages to describe the current
772  configuration and in ofp_table_mod messages to configure table behavior. */
773  enum ofp_table_config {
774  OFPTC_DEPRECATED_MASK = 3, /* Deprecated bits */
775  };
776 
777 
778  /*
779  * 7.3.4.1 Modify Flow Entry Message
780  */
781 
782  /* Flow setup and teardown (controller -> datapath). */
783  struct ofp_flow_mod {
784  struct ofp_header header;
785  uint64_t cookie; /* Opaque controller-issued identifier. */
786  uint64_t cookie_mask; /* Mask used to restrict the cookie bits
787  that must match when the command is
788  OFPFC_MODIFY* or OFPFC_DELETE*. A value
789  of 0 indicates no restriction. */
790 
791  /* Flow actions. */
792  uint8_t table_id; /* ID of the table to put the flow in */
793  uint8_t command; /* One of OFPFC_*. */
794  uint16_t idle_timeout; /* Idle time before discarding (seconds). */
795  uint16_t hard_timeout; /* Max time before discarding (seconds). */
796  uint16_t priority; /* Priority level of flow entry. */
797  uint32_t buffer_id; /* Buffered packet to apply to (or -1).
798  Not meaningful for OFPFC_DELETE*. */
799  uint32_t out_port; /* For OFPFC_DELETE* commands, require
800  matching entries to include this as an
801  output port. A value of OFPP_ANY
802  indicates no restriction. */
803  uint32_t out_group; /* For OFPFC_DELETE* commands, require
804  matching entries to include this as an
805  output group. A value of OFPG_ANY
806  indicates no restriction. */
807  uint16_t flags; /* One of OFPFF_*. */
808  uint8_t pad[2];
809  struct ofp_match match; /* Fields to match */
810  //struct ofp_instruction instructions[0]; /* Instruction set */
811  };
812  OFP_ASSERT(sizeof(struct ofp_flow_mod) == 56);
813 
814  enum ofp_flow_mod_command {
815  OFPFC_ADD = 0, /* New flow. */
816  OFPFC_MODIFY = 1, /* Modify all matching flows. */
817  OFPFC_MODIFY_STRICT = 2, /* Modify entry strictly matching wildcards and
818  priority. */
819  OFPFC_DELETE = 3, /* Delete all matching flows. */
820  OFPFC_DELETE_STRICT = 4, /* Delete entry strictly matching wildcards and
821  priority. */
822  };
823 
824  enum ofp_flow_mod_flags {
825  OFPFF_SEND_FLOW_REM = 1 << 0, /* Send flow removed message when flow expires or is deleted. */
826  OFPFF_CHECK_OVERLAP = 1 << 1, /* Check for overlapping entries first. */
827  OFPFF_RESET_COUNTS = 1 << 2, /* Reset flow packet and byte counts. */
828  OFPFF_NO_PKT_COUNTS = 1 << 3, /* Don’t keep track of packet count. */
829  OFPFF_NO_BYT_COUNTS = 1 << 4, /* Don’t keep track of byte count. */
830  };
831 
832  static int const OFP_FLOW_MOD_STATIC_HDR_LEN = sizeof(struct ofp_flow_mod) - sizeof(struct ofp_match);
833 
834  /*
835  * 7.3.4.2 Modify Group Entry Message
836  */
837 
838  /* Bucket for use in groups. */
839  struct ofp_bucket {
840  uint16_t len; /* Length the bucket in bytes, including
841  this header and any padding to make it
842  64-bit aligned. */
843  uint16_t weight; /* Relative weight of bucket. Only
844  defined for select groups. */
845  uint32_t watch_port; /* Port whose state affects whether this
846  bucket is live. Only required for fast
847  failover groups. */
848  uint32_t watch_group; /* Group whose state affects whether this
849  bucket is live. Only required for fast
850  failover groups. */
851  uint8_t pad[4];
852  struct ofp_action_header actions[0]; /* The action length is inferred
853  from the length field in the
854  header. */
855  };
856  OFP_ASSERT(sizeof(struct ofp_bucket) == 16);
857 
858  /* Group setup and teardown (controller -> datapath). */
859  struct ofp_group_mod {
860  struct ofp_header header;
861  uint16_t command; /* One of OFPGC_*. */
862  uint8_t type; /* One of OFPGT_*. */
863  uint8_t pad; /* Pad to 64 bits. */
864  uint32_t group_id; /* Group identifier. */
865  struct ofp_bucket buckets[0]; /* The bucket length is inferred from the
866  length field in the header. */
867  };
868  OFP_ASSERT(sizeof(struct ofp_group_mod) == 16);
869 
870  /* Group commands */
871  enum ofp_group_mod_command {
872  OFPGC_ADD = 0, /* New group. */
873  OFPGC_MODIFY = 1, /* Modify all matching groups. */
874  OFPGC_DELETE = 2, /* Delete all matching groups. */
875  };
876 
877  /* Group types. Values in the range [128, 255] are reserved for experimental
878  * use. */
879  enum ofp_group_type {
880  OFPGT_ALL = 0, /* All (multicast/broadcast) group. */
881  OFPGT_SELECT = 1, /* Select group. */
882  OFPGT_INDIRECT = 2, /* Indirect group. */
883  OFPGT_FF = 3, /* Fast failover group. */
884  };
885 
886  /* Group numbering. Groups can use any number up to OFPG_MAX. */
887  enum ofp_group {
888  /* Last usable group number. */
889  OFPG_MAX = 0xffffff00,
890 
891  /* Fake groups. */
892  OFPG_ALL = 0xfffffffc, /* Represents all groups for group delete
893  commands. */
894  OFPG_ANY = 0xffffffff /* Wildcard group used only for flow stats
895  requests. Selects all flows regardless of
896  group (including flows with no group).
897  */
898  };
899 
900  /*
901  * 7.3.4.3 Port Modification Message
902  */
903 
904  /* Modify behavior of the physical port */
905  struct ofp_port_mod {
906  struct ofp_header header;
907  uint32_t port_no;
908  uint8_t pad[4];
909  uint8_t hw_addr[OFP_ETH_ALEN]; /* The hardware address is not
910  configurable. This is used to
911  sanity-check the request, so it must
912  be the same as returned in an
913  ofp_port struct. */
914  uint8_t pad2[2]; /* Pad to 64 bits. */
915  uint32_t config; /* Bitmap of OFPPC_* flags. */
916  uint32_t mask; /* Bitmap of OFPPC_* flags to be changed. */
917 
918  uint32_t advertise; /* Bitmap of OFPPF_*. Zero all bits to prevent
919  any action taking place. */
920  uint8_t pad3[4]; /* Pad to 64 bits. */
921  };
922  OFP_ASSERT(sizeof(struct ofp_port_mod) == 40);
923 
924  /* Why is this packet being sent to the controller? */
925  enum ofp_packet_in_reason {
926  OFPR_NO_MATCH = 0, /* No matching flow. */
927  OFPR_ACTION = 1, /* Action explicitly output to controller. */
928  OFPR_INVALID_TTL = 2 /* Packet has invalid TTL */
929  };
930 
931  /*
932  * 7.3.4.4 Meter Modification Message
933  */
934 
935  /* Common header for all meter bands */
937  uint16_t type; /* One of OFPMBT_*. */
938  uint16_t len; /* Length in bytes of this band. */
939  uint32_t rate; /* Rate for this band. */
940  uint32_t burst_size; /* Size of bursts. */
941  uint8_t body[0];
942  };
943  OFP_ASSERT(sizeof(struct ofp_meter_band_header) == 12);
944 
945  /* Meter configuration. OFPT_METER_MOD. */
946  struct ofp_meter_mod {
947  struct ofp_header header;
948  uint16_t command; /* One of OFPMC_*. */
949  uint16_t flags; /* One of OFPMF_*. */
950  uint32_t meter_id; /* Meter instance. */
951  struct ofp_meter_band_header bands[0];
952  /* The bands length is inferred from the length field in the header. */
953  };
954  OFP_ASSERT(sizeof(struct ofp_meter_mod) == 16);
955 
956  /* Meter numbering. Flow meters can use any number up to OFPM_MAX. */
957  enum ofp_meter {
958  /* Last usable meter. */
959  OFPM_MAX = 0xffff0000,
960 
961  /* Virtual meters. */
962  OFPM_SLOWPATH = 0xfffffffd, /* Meter for slow datapath. */
963  OFPM_CONTROLLER = 0xfffffffe, /* Meter for controller connection. */
964  OFPM_ALL = 0xffffffff, /* Represents all meters for stat requests commands. */
965  };
966 
967  /* Meter commands */
968  enum ofp_meter_mod_command {
969  OFPMC_ADD = 0, /* New meter. */
970  OFPMC_MODIFY = 1, /* Modify specified meter. */
971  OFPMC_DELETE = 2, /* Delete specified meter. */
972  };
973 
974  /* Meter configuration flags */
975  enum ofp_meter_flags {
976  OFPMF_KBPS = 1 << 0, /* Rate value in kb/s (kilo-bit per second). */
977  OFPMF_PKTPS = 1 << 1, /* Rate value in packet/sec. */
978  OFPMF_BURST = 1 << 2, /* Do burst size. */
979  OFPMF_STATS = 1 << 3, /* Collect statistics. */
980  };
981 
982  /* Meter band types */
983  enum ofp_meter_band_type {
984  OFPMBT_DROP = 1, /* Drop packet. */
985  OFPMBT_DSCP_REMARK = 2, /* Remark DSCP in the IP header. */
986  OFPMBT_EXPERIMENTER = 0xFFFF, /* Experimenter meter band. */
987  };
988 
989  /* OFPMBT_DROP band - drop packets */
991  uint16_t type; /* OFPMBT_DROP. */
992  uint16_t len; /* Length in bytes of this band. */
993  uint32_t rate; /* Rate for dropping packets. */
994  uint32_t burst_size; /* Size of bursts. */
995  uint8_t pad[4];
996  };
997  OFP_ASSERT(sizeof(struct ofp_meter_band_drop) == 16);
998 
999  /* OFPMBT_DSCP_REMARK band - Remark DSCP in the IP header */
1001  uint16_t type; /* OFPMBT_DSCP_REMARK. */
1002  uint16_t len; /* Length in bytes of this band. */
1003  uint32_t rate; /* Rate for remarking packets. */
1004  uint32_t burst_size; /* Size of bursts. */
1005  uint8_t prec_level; /* Number of drop precedence level to add. */
1006  uint8_t pad[3];
1007  };
1008  OFP_ASSERT(sizeof(struct ofp_meter_band_dscp_remark) == 16);
1009 
1010  /* OFPMBT_EXPERIMENTER band - Write actions in action set */
1012  uint16_t type; /* One of OFPMBT_*. */
1013  uint16_t len; /* Length in bytes of this band. */
1014  uint32_t rate; /* Rate for this band. */
1015  uint32_t burst_size; /* Size of bursts. */
1016  uint32_t experimenter; /* Experimenter ID which takes the same form as in struct ofp_experimenter_header. */
1017  uint8_t body[0];
1018  };
1019  OFP_ASSERT(sizeof(struct ofp_meter_band_experimenter) == 16);
1020 
1021 
1022  /*
1023  * 7.3.5 Multipart Messages
1024  */
1025 
1027  struct ofp_header header;
1028  uint16_t type; /* One of the OFPMP_* constants. */
1029  uint16_t flags; /* OFPMPF_REQ_* flags. */
1030  uint8_t pad[4];
1031  uint8_t body[0]; /* Body of the request. */
1032  };
1033  OFP_ASSERT(sizeof(struct ofp_multipart_request) == 16);
1034 
1036  struct ofp_header header;
1037  uint16_t type; /* One of the OFPMP_* constants. */
1038  uint16_t flags; /* OFPMPF_REPLY_* flags. */
1039  uint8_t pad[4];
1040  uint8_t body[0]; /* Body of the reply. */
1041  };
1042  OFP_ASSERT(sizeof(struct ofp_multipart_reply) == 16);
1043 
1044  enum ofp_multipart_request_flags {
1045  OFPMPF_REQ_MORE = 1 << 0 /* More requests to follow. */
1046  };
1047 
1048  enum ofp_multipart_reply_flags {
1049  OFPMPF_REPLY_MORE = 1 << 0 /* More replies to follow. */
1050  };
1051 
1052  enum ofp_multipart_types {
1053  /* Description of this OpenFlow switch.
1054  * The request body is empty.
1055  * The reply body is struct ofp_desc. */
1056  OFPMP_DESC = 0,
1057 
1058  /* Individual flow statistics.
1059  * The request body is struct ofp_flow_stats_request.
1060  * The reply body is an array of struct ofp_flow_stats. */
1061  OFPMP_FLOW = 1,
1062 
1063  /* Aggregate flow statistics.
1064  * The request body is struct ofp_aggregate_stats_request.
1065  * The reply body is struct ofp_aggregate_stats_reply. */
1066  OFPMP_AGGREGATE = 2,
1067 
1068  /* Flow table statistics.
1069  * The request body is empty.
1070  * The reply body is an array of struct ofp_table_stats. */
1071  OFPMP_TABLE = 3,
1072 
1073  /* Port statistics.
1074  * The request body is struct ofp_port_stats_request.
1075  * The reply body is an array of struct ofp_port_stats. */
1076  OFPMP_PORT_STATS = 4,
1077 
1078  /* Queue statistics for a port
1079  * The request body is struct ofp_queue_stats_request.
1080  * The reply body is an array of struct ofp_queue_stats */
1081  OFPMP_QUEUE = 5,
1082 
1083  /* Group counter statistics.
1084  * The request body is struct ofp_group_stats_request.
1085  * The reply is an array of struct ofp_group_stats. */
1086  OFPMP_GROUP = 6,
1087 
1088  /* Group description.
1089  * The request body is empty.
1090  * The reply body is an array of struct ofp_group_desc_stats. */
1091  OFPMP_GROUP_DESC = 7,
1092 
1093  /* Group features.
1094  * The request body is empty.
1095  * The reply body is struct ofp_group_features. */
1096  OFPMP_GROUP_FEATURES = 8,
1097 
1098  /* Meter statistics.
1099  * The request body is struct ofp_meter_multipart_requests.
1100  * The reply body is an array of struct ofp_meter_stats. */
1101  OFPMP_METER = 9,
1102 
1103  /* Meter configuration.
1104  * The request body is struct ofp_meter_multipart_requests.
1105  * The reply body is an array of struct ofp_meter_config. */
1106  OFPMP_METER_CONFIG = 10,
1107 
1108  /* Meter features.
1109  * The request body is empty.
1110  * The reply body is struct ofp_meter_features. */
1111  OFPMP_METER_FEATURES = 11,
1112 
1113  /* Table features.
1114  * The request body is either empty or contains an array of
1115  * struct ofp_table_features containing the controller’s
1116  * desired view of the switch. If the switch is unable to
1117  * set the specified view an error is returned.
1118  * The reply body is an array of struct ofp_table_features. */
1119  OFPMP_TABLE_FEATURES = 12,
1120 
1121  /* Port description.
1122  * The request body is empty.
1123  * The reply body is an array of struct ofp_port. */
1124  OFPMP_PORT_DESC = 13,
1125 
1126  /* Experimenter extension.
1127  * The request and reply bodies begin with
1128  * struct ofp_experimenter_multipart_header.
1129  * The request and reply bodies are otherwise experimenter-defined. */
1130  OFPMP_EXPERIMENTER = 0xffff
1131  };
1132 
1133 #if 0
1134  struct ofp_stats_request {
1135  struct ofp_header header;
1136  uint16_t type; /* One of the OFPST_* constants. */
1137  uint16_t flags; /* OFPSF_REQ_* flags (none yet defined). */
1138  uint8_t pad[4];
1139  uint8_t body[0]; /* Body of the request. */
1140  };
1141  OFP_ASSERT(sizeof(struct ofp_stats_request) == 16);
1142 
1143  enum ofp_stats_reply_flags {
1144  OFPSF_REPLY_MORE = 1 << 0 /* More replies to follow. */
1145  };
1146 
1147  struct ofp_stats_reply {
1148  struct ofp_header header;
1149  uint16_t type; /* One of the OFPST_* constants. */
1150  uint16_t flags; /* OFPSF_REPLY_* flags. */
1151  uint8_t pad[4];
1152  uint8_t body[0]; /* Body of the reply. */
1153  };
1154  OFP_ASSERT(sizeof(struct ofp_stats_reply) == 16);
1155 #endif
1156 
1157  /*
1158  * 7.3.5.1 Description
1159  */
1160 
1161  #define DESC_STR_LEN 256
1162  #define SERIAL_NUM_LEN 32
1163 
1164  /* Body of reply to OFPMP_DESC request. Each entry is a NULL-terminated
1165  * ASCII string. */
1166  struct ofp_desc {
1167  char mfr_desc[DESC_STR_LEN]; /* Manufacturer description. */
1168  char hw_desc[DESC_STR_LEN]; /* Hardware description. */
1169  char sw_desc[DESC_STR_LEN]; /* Software description. */
1170  char serial_num[SERIAL_NUM_LEN]; /* Serial number. */
1171  char dp_desc[DESC_STR_LEN]; /* Human readable description of datapath. */
1172  };
1173  OFP_ASSERT(sizeof(struct ofp_desc) == 1056);
1174 
1175 
1176  /*
1177  * 7.3.5.2 Individual Flow Statistics
1178  */
1179 
1180  /* Body for ofp_multipart_request of type OFPMP_FLOW. */
1182  uint8_t table_id; /* ID of table to read (from ofp_table_stats), OFPTT_ALL for all tables. */
1183  uint8_t pad[3]; /* Align to 32 bits. */
1184  uint32_t out_port; /* Require matching entries to include this as an output port. A value of OFPP_ANY indicates no restriction. */
1185  uint32_t out_group; /* Require matching entries to include this as an output group. A value of OFPG_ANY indicates no restriction. */
1186  uint8_t pad2[4]; /* Align to 64 bits. */
1187  uint64_t cookie; /* Require matching entries to contain this cookie value */
1188  uint64_t cookie_mask; /* Mask used to restrict the cookie bits that must match. A value of 0 indicates no restriction. */
1189  struct ofp_match match; /* Fields to match. Variable size. */
1190  };
1191  OFP_ASSERT(sizeof(struct ofp_flow_stats_request) == 40);
1192 
1193  /* Body of reply to OFPST_FLOW request. */
1195  uint16_t length; /* Length of this entry. */
1196  uint8_t table_id; /* ID of table flow came from. */
1197  uint8_t pad;
1198  uint32_t duration_sec; /* Time flow has been alive in seconds. */
1199  uint32_t duration_nsec; /* Time flow has been alive in nanoseconds beyond
1200  duration_sec. */
1201  uint16_t priority; /* Priority of the entry. Only meaningful
1202  when this is not an exact-match entry. */
1203  uint16_t idle_timeout; /* Number of seconds idle before expiration. */
1204  uint16_t hard_timeout; /* Number of seconds before expiration. */
1205  uint16_t flags; /* OFPFF_... */
1206  uint8_t pad2[4]; /* Align to 64-bits. */
1207  uint64_t cookie; /* Opaque controller-issued identifier. */
1208  uint64_t packet_count; /* Number of packets in flow. */
1209  uint64_t byte_count; /* Number of bytes in flow. */
1210  struct ofp_match match; /* Description of fields. */
1211  //struct ofp_instruction instructions[0]; /* Instruction set. */
1212  };
1213  OFP_ASSERT(sizeof(struct ofp_flow_stats) == 56);
1214 
1215  /* Body for ofp_stats_request of type OFPST_AGGREGATE. */
1217  uint8_t table_id; /* ID of table to read (from ofp_table_stats)
1218  0xff for all tables. */
1219  uint8_t pad[3]; /* Align to 64 bits. */
1220  uint32_t out_port; /* Require matching entries to include this
1221  as an output port. A value of OFPP_ANY
1222  indicates no restriction. */
1223  uint32_t out_group; /* Require matching entries to include this
1224  as an output group. A value of OFPG_ANY
1225  indicates no restriction. */
1226  uint8_t pad2[4]; /* Align to 64 bits. */
1227  uint64_t cookie; /* Require matching entries to contain this
1228  cookie value */
1229  uint64_t cookie_mask; /* Mask used to restrict the cookie bits that
1230  must match. A value of 0 indicates
1231  no restriction. */
1232  struct ofp_match match; /* Fields to match. */
1233  };
1234  OFP_ASSERT(sizeof(struct ofp_aggregate_stats_request) == 40);
1235 
1236  /* Body of reply to OFPST_AGGREGATE request. */
1238  uint64_t packet_count; /* Number of packets in flows. */
1239  uint64_t byte_count; /* Number of bytes in flows. */
1240  uint32_t flow_count; /* Number of flows. */
1241  uint8_t pad[4]; /* Align to 64 bits. */
1242  };
1243  OFP_ASSERT(sizeof(struct ofp_aggregate_stats_reply) == 24);
1244 
1245  /*
1246  * 7.3.5.4 Table Statistics
1247  */
1248 
1249  /* Body of reply to OFPMP_TABLE request. */
1251  uint8_t table_id; /* Identifier of table. Lower numbered tables are consulted first. */
1252  uint8_t pad[3]; /* Align to 32-bits. */
1253  uint32_t active_count; /* Number of active entries. */
1254  uint64_t lookup_count; /* Number of packets looked up in table. */
1255  uint64_t matched_count; /* Number of packets that hit table. */
1256  };
1257  OFP_ASSERT(sizeof(struct ofp_table_stats) == 24);
1258 
1259  /*
1260  * 7.3.5.5 Table Features
1261  */
1262 
1263  /* Common header for all Table Feature Properties */
1265  uint16_t type; /* One of OFPTFPT_*. */
1266  uint16_t length; /* Length in bytes of this property. */
1267  };
1268  OFP_ASSERT(sizeof(struct ofp_table_feature_prop_header) == 4);
1269 
1270  #define OFP_MAX_TABLE_NAME_LEN 32
1271 
1272  /* Body for ofp_multipart_request of type OFPMP_TABLE_FEATURES./
1273  * Body of reply to OFPMP_TABLE_FEATURES request. */
1275  uint16_t length; /* Length is padded to 64 bits. */
1276  uint8_t table_id; /* Identifier of table. Lower numbered tables are consulted first. */
1277  uint8_t pad[5]; /* Align to 64-bits. */
1278  char name[OFP_MAX_TABLE_NAME_LEN];
1279  uint64_t metadata_match; /* Bits of metadata table can match. */
1280  uint64_t metadata_write; /* Bits of metadata table can write. */
1281  uint32_t config; /* Bitmap of OFPTC_* values */
1282  uint32_t max_entries; /* Max number of entries supported. */
1283  /* Table Feature Property list */
1284  struct ofp_table_feature_prop_header properties[0];
1285  };
1286  OFP_ASSERT(sizeof(struct ofp_table_features) == 64);
1287 
1288  /* Table Feature property types.
1289  * Low order bit cleared indicates a property for a regular Flow Entry.
1290  * Low order bit set indicates a property for the Table-Miss Flow Entry.
1291  */
1292  enum ofp_table_feature_prop_type {
1293  OFPTFPT_INSTRUCTIONS = 0, /* Instructions property. */
1294  OFPTFPT_INSTRUCTIONS_MISS = 1, /* Instructions for table-miss. */
1295  OFPTFPT_NEXT_TABLES = 2, /* Next Table property. */
1296  OFPTFPT_NEXT_TABLES_MISS = 3, /* Next Table for table-miss. */
1297  OFPTFPT_WRITE_ACTIONS = 4, /* Write Actions property. */
1298  OFPTFPT_WRITE_ACTIONS_MISS = 5, /* Write Actions for table-miss. */
1299  OFPTFPT_APPLY_ACTIONS = 6, /* Apply Actions property. */
1300  OFPTFPT_APPLY_ACTIONS_MISS = 7, /* Apply Actions for table-miss. */
1301  OFPTFPT_MATCH = 8, /* Match property. */
1302  OFPTFPT_WILDCARDS = 10, /* Wildcards property. */
1303  OFPTFPT_WRITE_SETFIELD = 12, /* Write Set-Field property. */
1304  OFPTFPT_WRITE_SETFIELD_MISS = 13, /* Write Set-Field for table-miss. */
1305  OFPTFPT_APPLY_SETFIELD = 14, /* Apply Set-Field property. */
1306  OFPTFPT_APPLY_SETFIELD_MISS = 15, /* Apply Set-Field for table-miss. */
1307  OFPTFPT_EXPERIMENTER = 0xFFFE, /* Experimenter property. */
1308  OFPTFPT_EXPERIMENTER_MISS = 0xFFFF, /* Experimenter for table-miss. */
1309  };
1310 
1311  /* Instructions property */
1313  uint16_t type; /* One of OFPTFPT_INSTRUCTIONS, OFPTFPT_INSTRUCTIONS_MISS. */
1314  uint16_t length; /* Length in bytes of this property. */
1315  /* Followed by:
1316  * - Exactly (length - 4) bytes containing the instruction ids, then
1317  * - Exactly (length + 7)/8*8 - (length) (between 0 and 7)
1318  * bytes of all-zero bytes */
1319  struct ofp_instruction instruction_ids[0]; /* List of instructions: 4 bytes per instruction
1320  for non-experimental instructions*/
1321  };
1322  OFP_ASSERT(sizeof(struct ofp_table_feature_prop_instructions) == 4);
1323 
1324  /* Next Tables property */
1326  uint16_t type; /* One of OFPTFPT_NEXT_TABLES, OFPTFPT_NEXT_TABLES_MISS. */
1327  uint16_t length; /* Length in bytes of this property. */
1328  /* Followed by:
1329  * - Exactly (length - 4) bytes containing the table_ids, then
1330  * - Exactly (length + 7)/8*8 - (length) (between 0 and 7)
1331  * bytes of all-zero bytes */
1332  uint8_t next_table_ids[0];
1333  };
1334  OFP_ASSERT(sizeof(struct ofp_table_feature_prop_next_tables) == 4);
1335 
1336  /* Actions property */
1338  uint16_t type; /* One of OFPTFPT_WRITE_ACTIONS, OFPTFPT_WRITE_ACTIONS_MISS, OFPTFPT_APPLY_ACTIONS, OFPTFPT_APPLY_ACTIONS_MISS. */
1339  uint16_t length; /* Length in bytes of this property. */
1340  /* Followed by:
1341  * - Exactly (length - 4) bytes containing the action_ids, then
1342  * - Exactly (length + 7)/8*8 - (length) (between 0 and 7)
1343  * bytes of all-zero bytes */
1344  struct ofp_action_header action_ids[0]; /* List of actions */
1345  };
1346  OFP_ASSERT(sizeof(struct ofp_table_feature_prop_actions) == 4);
1347 
1348  /* Match, Wildcard or Set-Field property */
1350  uint16_t type; /* One of OFPTFPT_MATCH, OFPTFPT_WILDCARDS, OFPTFPT_WRITE_SETFIELD, OFPTFPT_WRITE_SETFIELD_MISS, OFPTFPT_APPLY_SETFIELD, OFPTFPT_APPLY_SETFIELD_MISS. */
1351  uint16_t length; /* Length in bytes of this property. */
1352  /* Followed by:
1353  * - Exactly (length - 4) bytes containing the oxm_ids, then
1354  * - Exactly (length + 7)/8*8 - (length) (between 0 and 7)
1355  * bytes of all-zero bytes */
1356  uint32_t oxm_ids[0]; /* Array of OXM headers */
1357  };
1358  OFP_ASSERT(sizeof(struct ofp_table_feature_prop_oxm) == 4);
1359 
1360  /* Experimenter table feature property */
1362  uint16_t type; /* One of OFPTFPT_EXPERIMENTER, OFPTFPT_EXPERIMENTER_MISS. */
1363  uint16_t length; /* Length in bytes of this property. */
1364  uint32_t experimenter; /* Experimenter ID which takes the same form as in struct ofp_experimenter_header. */
1365  uint32_t exp_type; /* Experimenter defined. */
1366  /* Followed by:
1367  * - Exactly (length - 12) bytes containing the experimenter data, then
1368  * - Exactly (length + 7)/8*8 - (length) (between 0 and 7)
1369  * bytes of all-zero bytes */
1370  uint32_t experimenter_data[0];
1371  };
1372  OFP_ASSERT(sizeof(struct ofp_table_feature_prop_experimenter) == 12);
1373 
1374 
1375  /*
1376  * 7.3.5.6 Port Statistics
1377  */
1378 
1379  /* Body for ofp_multipart_request of type OFPMP_PORT. */
1381  uint32_t port_no; /* OFPMP_PORT message must request statistics
1382  * either for a single port (specified in
1383  * port_no) or for all ports (if port_no ==
1384  * OFPP_ANY). */
1385  uint8_t pad[4];
1386  };
1387  OFP_ASSERT(sizeof(struct ofp_port_stats_request) == 8);
1388 
1389 
1390  /* Body of reply to OFPMP_PORT request. If a counter is unsupported, set
1391  * the field to all ones. */
1393  uint32_t port_no;
1394  uint8_t pad[4]; /* Align to 64-bits. */
1395  uint64_t rx_packets; /* Number of received packets. */
1396  uint64_t tx_packets; /* Number of transmitted packets. */
1397  uint64_t rx_bytes; /* Number of received bytes. */
1398  uint64_t tx_bytes; /* Number of transmitted bytes. */
1399  uint64_t rx_dropped; /* Number of packets dropped by RX. */
1400  uint64_t tx_dropped; /* Number of packets dropped by TX. */
1401  uint64_t rx_errors; /* Number of receive errors. This is a super-set
1402  of more specific receive errors and should be
1403  greater than or equal to the sum of all
1404  rx_*_err values. */
1405  uint64_t tx_errors; /* Number of transmit errors. This is a super-set
1406  of more specific transmit errors and should be
1407  greater than or equal to the sum of all
1408  tx_*_err values (none currently defined.) */
1409  uint64_t rx_frame_err; /* Number of frame alignment errors. */
1410  uint64_t rx_over_err; /* Number of packets with RX overrun. */
1411  uint64_t rx_crc_err; /* Number of CRC errors. */
1412  uint64_t collisions; /* Number of collisions. */
1413  uint32_t duration_sec; /* Time port has been alive in seconds. */
1414  uint32_t duration_nsec; /* Time port has been alive in nanoseconds beyond
1415  duration_sec. */
1416  };
1417  OFP_ASSERT(sizeof(struct ofp_port_stats) == 112);
1418 
1419  /*
1420  * 7.3.5.7 Port Description
1421  */
1422 
1423  // nothing to define
1424 
1425  /*
1426  * 7.3.5.8 Queue Statistics
1427  */
1428 
1430  uint32_t port_no; /* All ports if OFPP_ANY. */
1431  uint32_t queue_id; /* All queues if OFPQ_ALL. */
1432  };
1433  OFP_ASSERT(sizeof(struct ofp_queue_stats_request) == 8);
1434 
1436  uint32_t port_no;
1437  uint32_t queue_id; /* Queue i.d */
1438  uint64_t tx_bytes; /* Number of transmitted bytes. */
1439  uint64_t tx_packets; /* Number of transmitted packets. */
1440  uint64_t tx_errors; /* Number of packets dropped due to overrun. */
1441  uint32_t duration_sec; /* Time queue has been alive in seconds. */
1442  uint32_t duration_nsec; /* Time queue has been alive in nanoseconds beyond duration_sec. */
1443  };
1444  OFP_ASSERT(sizeof(struct ofp_queue_stats) == 40);
1445 
1446 
1447  /*
1448  * 7.3.5.9 Group Statistics
1449  */
1450 
1451  /* Body of OFPMP_GROUP request. */
1453  uint32_t group_id; /* All groups if OFPG_ALL. */
1454  uint8_t pad[4]; /* Align to 64 bits. */
1455  };
1456  OFP_ASSERT(sizeof(struct ofp_group_stats_request) == 8);
1457 
1458  /* Used in group stats replies. */
1460  uint64_t packet_count; /* Number of packets processed by bucket. */
1461  uint64_t byte_count; /* Number of bytes processed by bucket. */
1462  };
1463  OFP_ASSERT(sizeof(struct ofp_bucket_counter) == 16);
1464 
1465  /* Body of reply to OFPMP_GROUP request. */
1467  uint16_t length; /* Length of this entry. */
1468  uint8_t pad[2]; /* Align to 64 bits. */
1469  uint32_t group_id; /* Group identifier. */
1470  uint32_t ref_count; /* Number of flows or groups that directly forward to this group. */
1471  uint8_t pad2[4]; /* Align to 64 bits. */
1472  uint64_t packet_count; /* Number of packets processed by group. */
1473  uint64_t byte_count; /* Number of bytes processed by group. */
1474  uint32_t duration_sec; /* Time group has been alive in seconds. */
1475  uint32_t duration_nsec; /* Time group has been alive in nanoseconds beyond duration_sec. */
1476  struct ofp_bucket_counter bucket_stats[0];
1477  };
1478  OFP_ASSERT(sizeof(struct ofp_group_stats) == 40);
1479 
1480  /*
1481  * 7.3.5.10 Group Description
1482  */
1483 
1484  /* Body of reply to OFPMP_GROUP_DESC request. */
1486  uint16_t length; /* Length of this entry. */
1487  uint8_t type; /* One of OFPGT_*. */
1488  uint8_t pad; /* Pad to 64 bits. */
1489  uint32_t group_id; /* Group identifier. */
1490  struct ofp_bucket buckets[0];
1491  };
1492  OFP_ASSERT(sizeof(struct ofp_group_desc) == 8);
1493 
1494  /*
1495  * 7.3.5.11 Group Features
1496  */
1497 
1498  /* Body of reply to OFPMP_GROUP_FEATURES request. Group features. */
1500  uint32_t types; /* Bitmap of OFPGT_* values supported. */
1501  uint32_t capabilities; /* Bitmap of OFPGFC_* capability supported. */
1502  uint32_t max_groups[4]; /* Maximum number of groups for each type. */
1503  uint32_t actions[4]; /* Bitmaps of OFPAT_* that are supported. */
1504  };
1505  OFP_ASSERT(sizeof(struct ofp_group_features) == 40);
1506 
1507  /* Group configuration flags */
1508  enum ofp_group_capabilities {
1509  OFPGFC_SELECT_WEIGHT = 1 << 0, /* Support weight for select groups */
1510  OFPGFC_SELECT_LIVENESS = 1 << 1, /* Support liveness for select groups */
1511  OFPGFC_CHAINING = 1 << 2, /* Support chaining groups */
1512  OFPGFC_CHAINING_CHECKS = 1 << 3, /* Check chaining for loops and delete */
1513  };
1514 
1515  /*
1516  * 7.3.5.12 Meter Statistics
1517  */
1518 
1519  /* Body of OFPMP_METER and OFPMP_METER_CONFIG requests. */
1521  uint32_t meter_id; /* Meter instance, or OFPM_ALL. */
1522  uint8_t pad[4]; /* Align to 64 bits. */
1523  };
1524  OFP_ASSERT(sizeof(struct ofp_meter_multipart_request) == 8);
1525 
1526  /* Statistics for each meter band */
1528  uint64_t packet_band_count; /* Number of packets in band. */
1529  uint64_t byte_band_count; /* Number of bytes in band. */
1530  };
1531  OFP_ASSERT(sizeof(struct ofp_meter_band_stats) == 16);
1532 
1533  /* Body of reply to OFPMP_METER request. Meter statistics. */
1535  uint32_t meter_id; /* Meter instance. */
1536  uint16_t len; /* Length in bytes of this stats. */
1537  uint8_t pad[6];
1538  uint32_t flow_count; /* Number of flows bound to meter. */
1539  uint64_t packet_in_count; /* Number of packets in input. */
1540  uint64_t byte_in_count; /* Number of bytes in input. */
1541  uint32_t duration_sec; /* Time meter has been alive in seconds. */
1542  uint32_t duration_nsec; /* Time meter has been alive in nanoseconds beyond duration_sec. */
1543  struct ofp_meter_band_stats band_stats[0]; /* The band_stats length is inferred from the length field. */
1544  };
1545  OFP_ASSERT(sizeof(struct ofp_meter_stats) == 40);
1546 
1547  /*
1548  * 7.3.5.13 Meter Configuration Statistics
1549  */
1550 
1551  // for request, see structure ofp_meter_multipart_request; in section 7.3.5.12 "Meter Statistics" above
1552 
1553  /* Body of reply to OFPMP_METER_CONFIG request. Meter configuration. */
1555  uint16_t length; /* Length of this entry. */
1556  uint16_t flags; /* All OFPMC_* that apply. */
1557  uint32_t meter_id; /* Meter instance. */
1558  struct ofp_meter_band_header bands[0]; /* The bands length is inferred from the length field. */
1559  };
1560  OFP_ASSERT(sizeof(struct ofp_meter_config) == 8);
1561 
1562  /*
1563  * 7.3.5.14 Meter Features Statistics
1564  */
1565 
1566  /* Body of reply to OFPMP_METER_FEATURES request. Meter features. */
1568  uint32_t max_meter; /* Maximum number of meters. */
1569  uint32_t band_types; /* Bitmaps of OFPMBT_* values supported. */
1570  uint32_t capabilities; /* Bitmaps of "ofp_meter_flags". */
1571  uint8_t max_bands; /* Maximum bands per meters */
1572  uint8_t max_color; /* Maximum color value */
1573  uint8_t pad[2];
1574  };
1575  OFP_ASSERT(sizeof(struct ofp_meter_features) == 16);
1576 
1577  /*
1578  * 7.3.5.15 Experimenter Multipart
1579  */
1580 
1581  /* Body for ofp_multipart_request/reply of type OFPMP_EXPERIMENTER. */
1583  uint32_t experimenter; /* Experimenter ID which takes the same form as in struct ofp_experimenter_header. */
1584  uint32_t exp_type; /* Experimenter defined. */
1585  /* Experimenter-defined arbitrary additional data. */
1586  };
1587  OFP_ASSERT(sizeof(struct ofp_experimenter_multipart_header) == 8);
1588 
1589  /*
1590  * 7.3.6 Queue Configuration Messages
1591  */
1592 
1593  /* Query for port queue configuration. */
1595  struct ofp_header header;
1596  uint32_t port; /* Port to be queried. Should refer
1597  to a valid physical port (i.e. < OFPP_MAX) */
1598  uint8_t pad[4];
1599  };
1600  OFP_ASSERT(sizeof(struct ofp_queue_get_config_request) == 16);
1601 
1602  /* Queue configuration for a given port. */
1604  struct ofp_header header;
1605  uint32_t port;
1606  uint8_t pad[4];
1607  struct ofp_packet_queue queues[0]; /* List of configured queues. */
1608  };
1609  OFP_ASSERT(sizeof(struct ofp_queue_get_config_reply) == 16);
1610 
1611  /*
1612  * 7.3.7 Packet-Out Message
1613  */
1614 
1615  /* Send packet (controller -> datapath). */
1617  struct ofp_header header;
1618  uint32_t buffer_id; /* ID assigned by datapath (-1 if none). */
1619  uint32_t in_port; /* Packet's input port or OFPP_CONTROLLER. */
1620  uint16_t actions_len; /* Size of action array in bytes. */
1621  uint8_t pad[6];
1622  struct ofp_action_header actions[0]; /* Action list. */
1623  /* uint8_t data[0]; */ /* Packet data. The length is inferred
1624  from the length field in the header.
1625  (Only meaningful if buffer_id == -1.) */
1626  };
1627  OFP_ASSERT(sizeof(struct ofp_packet_out) == 24);
1628 
1629  /*
1630  * 7.3.8 Barrier Message
1631  */
1632 
1633  // nothing to define
1634 
1635  /*
1636  * 7.3.9 Role Request Message
1637  */
1638 
1639  /* Role request and reply message. */
1641  struct ofp_header header; /* Type OFPT_ROLE_REQUEST/OFPT_ROLE_REPLY. */
1642  uint32_t role; /* One of NX_ROLE_*. */
1643  uint8_t pad[4]; /* Align to 64 bits. */
1644  uint64_t generation_id; /* Master Election Generation Id */
1645  };
1646  OFP_ASSERT(sizeof(struct ofp_role_request) == 24);
1647 
1648  /* Controller roles. */
1649  enum ofp_controller_role {
1650  OFPCR_ROLE_NOCHANGE = 0, /* Don’t change current role. */
1651  OFPCR_ROLE_EQUAL = 1, /* Default role, full access. */
1652  OFPCR_ROLE_MASTER = 2, /* Full access, at most one master. */
1653  OFPCR_ROLE_SLAVE = 3, /* Read-only access. */
1654  };
1655 
1656  /*
1657  * 7.3.10 Set Asynchronous Configuration Message
1658  */
1659 
1660  /* Asynchronous message configuration. */
1662  struct ofp_header header; /* OFPT_GET_ASYNC_REPLY or OFPT_SET_ASYNC. */
1663  uint32_t packet_in_mask[2]; /* Bitmasks of OFPR_* values. */
1664  uint32_t port_status_mask[2]; /* Bitmasks of OFPPR_* values. */
1665  uint32_t flow_removed_mask[2]; /* Bitmasks of OFPRR_* values. */
1666  };
1667  OFP_ASSERT(sizeof(struct ofp_async_config) == 32);
1668 
1669  /*
1670  * 7.4 Asynchronous Messages
1671  */
1672 
1673  /*
1674  * 7.4.1 Packet-In Message
1675  */
1676 
1677  /* Packet received on port (datapath -> controller). */
1678  struct ofp_packet_in {
1679  struct ofp_header header;
1680  uint32_t buffer_id; /* ID assigned by datapath. */
1681  uint16_t total_len; /* Full length of frame. */
1682  uint8_t reason; /* Reason packet is being sent (one of OFPR_*) */
1683  uint8_t table_id; /* ID of the table that was looked up */
1684  uint64_t cookie; /* Cookie of the flow entry that was looked up. */
1685  struct ofp_match match; /* Packet metadata. Variable size. */
1686  /* Followed by:
1687  * - Exactly 2 all-zero padding bytes, then
1688  * - An Ethernet frame whose length is inferred from header.length.
1689  * The padding bytes preceding the Ethernet frame ensure that the IP
1690  * header (if any) following the Ethernet header is 32-bit aligned.
1691  */
1692  //uint8_t pad[2]; /* Align to 64 bit + 16 bit */
1693  //uint8_t data[0]; /* Ethernet frame */
1694  };
1695  OFP_ASSERT(sizeof(struct ofp_packet_in) == 32);
1696 
1697  static int const OFP_PACKET_IN_STATIC_HDR_LEN = sizeof(struct ofp_packet_in) - sizeof(struct ofp_match);
1698 
1699  /*
1700  * 7.4.2 Flow Removed Message
1701  */
1702 
1703  /* Flow removed (datapath -> controller). */ // adjusted to OF1.2
1705  struct ofp_header header;
1706  uint64_t cookie; /* Opaque controller-issued identifier. */
1707 
1708  uint16_t priority; /* Priority level of flow entry. */
1709  uint8_t reason; /* One of OFPRR_*. */
1710  uint8_t table_id; /* ID of the table */
1711 
1712  uint32_t duration_sec; /* Time flow was alive in seconds. */
1713  uint32_t duration_nsec; /* Time flow was alive in nanoseconds beyond
1714  duration_sec. */
1715  uint16_t idle_timeout; /* Idle timeout from original flow mod. */
1716  uint16_t hard_timeout; /* Idle timeout from original flow mod. */
1717  uint64_t packet_count;
1718  uint64_t byte_count;
1719  struct ofp_match match; /* Description of fields. */
1720  };
1721  OFP_ASSERT(sizeof(struct ofp_flow_removed) == 56);
1722 
1723  /* Why was this flow removed? */
1724  enum ofp_flow_removed_reason {
1725  OFPRR_IDLE_TIMEOUT = 0, /* Flow idle time exceeded idle_timeout. */
1726  OFPRR_HARD_TIMEOUT = 1, /* Time exceeded hard_timeout. */
1727  OFPRR_DELETE = 2, /* Evicted by a DELETE flow mod. */
1728  OFPRR_GROUP_DELETE = 3, /* Group was removed. */
1729  };
1730 
1731  /*
1732  * 7.4.3 Port Status Message
1733  */
1734 
1735  /* A physical port has changed in the datapath */
1737  struct ofp_header header;
1738  uint8_t reason; /* One of OFPPR_*. */
1739  uint8_t pad[7]; /* Align to 64-bits. */
1740  struct ofp_port desc;
1741  };
1742  OFP_ASSERT(sizeof(struct ofp_port_status) == 80);
1743 
1744  /* What changed about the physical port */
1745  enum ofp_port_reason {
1746  OFPPR_ADD = 0, /* The port was added. */
1747  OFPPR_DELETE = 1, /* The port was removed. */
1748  OFPPR_MODIFY = 2, /* Some attribute of the port has changed. */
1749  };
1750 
1751  /*
1752  * 7.4.4 Error Message
1753  */
1754 
1755  /* OFPT_ERROR: Error message (datapath -> controller). */
1756  struct ofp_error_msg {
1757  struct ofp_header header;
1758  uint16_t type;
1759  uint16_t code;
1760  uint8_t data[0]; /* Variable-length data. Interpreted based
1761  on the type and code. No padding. */
1762  };
1763  OFP_ASSERT(sizeof(struct ofp_error_msg) == 12);
1764 
1765  /* Values for ’type’ in ofp_error_message. These values are immutable: they
1766  * will not change in future versions of the protocol (although new values may
1767  * be added). */
1768  enum ofp_error_type {
1769  OFPET_HELLO_FAILED = 0, /* Hello protocol failed. */
1770  OFPET_BAD_REQUEST = 1, /* Request was not understood. */
1771  OFPET_BAD_ACTION = 2, /* Error in action description. */
1772  OFPET_BAD_INSTRUCTION = 3, /* Error in instruction list. */
1773  OFPET_BAD_MATCH = 4, /* Error in match. */
1774  OFPET_FLOW_MOD_FAILED = 5, /* Problem modifying flow entry. */
1775  OFPET_GROUP_MOD_FAILED = 6, /* Problem modifying group entry. */
1776  OFPET_PORT_MOD_FAILED = 7, /* Port mod request failed. */
1777  OFPET_TABLE_MOD_FAILED = 8, /* Table mod request failed. */
1778  OFPET_QUEUE_OP_FAILED = 9, /* Queue operation failed. */
1779  OFPET_SWITCH_CONFIG_FAILED = 10, /* Switch config request failed. */
1780  OFPET_ROLE_REQUEST_FAILED = 11, /* Controller Role request failed. */
1781  OFPET_METER_MOD_FAILED = 12, /* Error in meter. */
1782  OFPET_TABLE_FEATURES_FAILED = 13, /* Setting table features failed. */
1783  OFPET_EXPERIMENTER = 0xffff /* Experimenter error messages. */
1784  };
1785 
1786 
1787  /* ofp_error_msg 'code' values for OFPET_HELLO_FAILED. 'data' contains an
1788  * ASCII text string that may give failure details. */
1789  enum ofp_hello_failed_code {
1790  OFPHFC_INCOMPATIBLE = 0, /* No compatible version. */
1791  OFPHFC_EPERM = 1, /* Permissions error. */
1792  };
1793 
1794  /* ofp_error_msg ’code’ values for OFPET_BAD_REQUEST. ’data’ contains at least
1795  * the first 64 bytes of the failed request. */
1796  enum ofp_bad_request_code {
1797  OFPBRC_BAD_VERSION = 0, /* ofp_header.version not supported. */
1798  OFPBRC_BAD_TYPE = 1, /* ofp_header.type not supported. */
1799  OFPBRC_BAD_STAT = 2, /* ofp_stats_request.type not supported. */
1800  OFPBRC_BAD_EXPERIMENTER = 3, /* Experimenter id not supported
1801  * (in ofp_experimenter_header or
1802  * ofp_stats_request or ofp_stats_reply). */
1803  OFPBRC_BAD_EXP_TYPE = 4, /* Experimenter type not supported. */
1804  OFPBRC_EPERM = 5, /* Permissions error. */
1805  OFPBRC_BAD_LEN = 6, /* Wrong request length for type. */
1806  OFPBRC_BUFFER_EMPTY = 7, /* Specified buffer has already been used. */
1807  OFPBRC_BUFFER_UNKNOWN = 8, /* Specified buffer does not exist. */
1808  OFPBRC_BAD_TABLE_ID = 9, /* Specified table-id invalid or does not
1809  * exist. */
1810  OFPBRC_IS_SLAVE = 10, /* Denied because controller is slave. */
1811  OFPBRC_BAD_PORT = 11, /* Invalid port. */
1812  OFPBRC_BAD_PACKET = 12, /* Invalid packet in packet-out. */
1813  OFPBRC_MULTIPART_BUFFER_OVERFLOW = 13, /* ofp_multipart_request
1814  * overflowed the assigned buffer. */
1815  };
1816 
1817 
1818  /* ofp_error_msg 'code' values for OFPET_BAD_ACTION. 'data' contains at least
1819  * the first 64 bytes of the failed request. */
1820  enum ofp_bad_action_code {
1821  OFPBAC_BAD_TYPE = 0, /* Unknown action type. */
1822  OFPBAC_BAD_LEN = 1, /* Length problem in actions. */
1823  OFPBAC_BAD_EXPERIMENTER = 2, /* Unknown experimenter id specified. */
1824  OFPBAC_BAD_EXP_TYPE = 3, /* Unknown action type for experimenter id. */
1825  OFPBAC_BAD_OUT_PORT = 4, /* Problem validating output port. */
1826  OFPBAC_BAD_ARGUMENT = 5, /* Bad action argument. */
1827  OFPBAC_EPERM = 6, /* Permissions error. */
1828  OFPBAC_TOO_MANY = 7, /* Can't handle this many actions. */
1829  OFPBAC_BAD_QUEUE = 8, /* Problem validating output queue. */
1830  OFPBAC_BAD_OUT_GROUP = 9, /* Invalid group id in forward action. */
1831  OFPBAC_MATCH_INCONSISTENT = 10, /* Action can't apply for this match. */
1832  OFPBAC_UNSUPPORTED_ORDER = 11, /* Action order is unsupported for the action
1833  * list in an Apply-Actions instruction */
1834  OFPBAC_BAD_TAG = 12, /* Actions uses an unsupported
1835  * tag/encap. */
1836  OFPBAC_BAD_SET_TYPE = 13, /* Unsupported type in SET_FIELD action. */
1837  OFPBAC_BAD_SET_LEN = 14, /* Length problem in SET_FIELD action. */
1838  OFPBAC_BAD_SET_ARGUMENT = 15, /* Bad argument in SET_FIELD action. */
1839  };
1840 
1841  /* ofp_error_msg 'code' values for OFPET_BAD_INSTRUCTION. 'data' contains at least
1842  * the first 64 bytes of the failed request. */
1843  enum ofp_bad_instruction_code {
1844  OFPBIC_UNKNOWN_INST = 0, /* Unknown instruction. */
1845  OFPBIC_UNSUP_INST = 1, /* Switch or table does not support the
1846  * instruction. */
1847  OFPBIC_BAD_TABLE_ID = 2, /* Invalid Table-ID specified. */
1848  OFPBIC_UNSUP_METADATA = 3, /* Metadata value unsupported by datapath. */
1849  OFPBIC_UNSUP_METADATA_MASK = 4, /* Metadata mask value unsupported by
1850  * datapath. */
1851  OFPBIC_BAD_EXPERIMENTER = 5, /* Specific experimenter instruction
1852  * unsupported. */
1853  OFPBIC_BAD_EXP_TYPE = 6, /* Unknown instruction for experimenter id. */
1854  OFPBIC_BAD_LEN = 7, /* Length problem in instructions. */
1855  OFPBIC_EPERM = 8, /* Permissions error. */
1856  };
1857 
1858  /* ofp_error_msg 'code' values for OFPET_BAD_MATCH. 'data' contains at least
1859  * the first 64 bytes of the failed request. */
1860  enum ofp_bad_match_code {
1861  OFPBMC_BAD_TYPE = 0, /* Unsupported match type specified by the match */
1862  OFPBMC_BAD_LEN = 1, /* Length problem in match. */
1863  OFPBMC_BAD_TAG = 2, /* Match uses an unsupported tag/encap. */
1864  OFPBMC_BAD_DL_ADDR_MASK = 3, /* Unsupported datalink addr mask - switch
1865  * does not support arbitrary datalink
1866  * address mask. */
1867  OFPBMC_BAD_NW_ADDR_MASK = 4, /* Unsupported network addr mask - switch
1868  * does not support arbitrary network
1869  * address mask. */
1870  OFPBMC_BAD_WILDCARDS = 5, /* Unsupported combination of fields masked
1871  * or omitted in the match. */
1872  OFPBMC_BAD_FIELD = 6, /* Unsupported field type in the match. */
1873  OFPBMC_BAD_VALUE = 7, /* Unsupported value in a match field. */
1874  OFPBMC_BAD_MASK = 8, /* Unsupported mask specified in the match,
1875  * field is not dl-address or nw-address. */
1876  OFPBMC_BAD_PREREQ = 9, /* A prerequisite was not met. */
1877  OFPBMC_DUP_FIELD = 10, /* A field type was duplicated. */
1878  OFPBMC_EPERM = 11, /* Permissions error. */
1879  };
1880 
1881  /* ofp_error_msg 'code' values for OFPET_FLOW_MOD_FAILED. 'data' contains
1882  * at least the first 64 bytes of the failed request. */
1883  enum ofp_flow_mod_failed_code {
1884  OFPFMFC_UNKNOWN = 0, /* Unspecified error. */
1885  OFPFMFC_TABLE_FULL = 1, /* Flow not added because table was full. */
1886  OFPFMFC_BAD_TABLE_ID = 2, /* Table does not exist */
1887  OFPFMFC_OVERLAP = 3, /* Attempted to add overlapping flow with
1888  * CHECK_OVERLAP flag set. */
1889  OFPFMFC_EPERM = 4, /* Permissions error. */
1890  OFPFMFC_BAD_TIMEOUT = 5, /* Flow not added because of unsupported
1891  * idle/hard timeout. */
1892  OFPFMFC_BAD_COMMAND = 6, /* Unsupported or unknown command. */
1893  OFPFMFC_BAD_FLAGS = 7, /* Unsupported or unknown flags. */
1894  };
1895 
1896  /* ofp_error_msg 'code' values for OFPET_GROUP_MOD_FAILED. 'data' contains
1897  * at least the first 64 bytes of the failed request. */
1898  enum ofp_group_mod_failed_code {
1899  OFPGMFC_GROUP_EXISTS = 0, /* Group not added because a group ADD
1900  * attempted to replace an
1901  * already-present group. */
1902  OFPGMFC_INVALID_GROUP = 1, /* Group not added because Group specified
1903  * is invalid. */
1904  OFPGMFC_WEIGHT_UNSUPPORTED = 2, /* Switch does not support unequal load
1905  * sharing with select groups. */
1906  OFPGMFC_OUT_OF_GROUPS = 3, /* The group table is full. */
1907  OFPGMFC_OUT_OF_BUCKETS = 4, /* The maximum number of action buckets
1908  * for a group has been exceeded. */
1909  OFPGMFC_CHAINING_UNSUPPORTED = 5, /* Switch does not support groups that
1910  * forward to groups. */
1911  OFPGMFC_WATCH_UNSUPPORTED = 6, /* This group cannot watch the
1912  watch_port or watch_group specified. */
1913  OFPGMFC_LOOP = 7, /* Group entry would cause a loop. */
1914  OFPGMFC_UNKNOWN_GROUP = 8, /* Group not modified because a group
1915  MODIFY attempted to modify a
1916  non-existent group. */
1917  OFPGMFC_CHAINED_GROUP = 9, /* Group not deleted because another
1918  group is forwarding to it. */
1919  OFPGMFC_BAD_TYPE = 10, /* Unsupported or unknown group type. */
1920  OFPGMFC_BAD_COMMAND = 11, /* Unsupported or unknown command. */
1921  OFPGMFC_BAD_BUCKET = 12, /* Error in bucket. */
1922  OFPGMFC_BAD_WATCH = 13, /* Error in watch port/group. */
1923  OFPGMFC_EPERM = 14, /* Permissions error. */
1924  };
1925 
1926  /* ofp_error_msg 'code' values for OFPET_PORT_MOD_FAILED. 'data' contains
1927  * at least the first 64 bytes of the failed request. */
1928  enum ofp_port_mod_failed_code {
1929  OFPPMFC_BAD_PORT = 0, /* Specified port number does not exist. */
1930  OFPPMFC_BAD_HW_ADDR = 1, /* Specified hardware address does not
1931  * match the port number. */
1932  OFPPMFC_BAD_CONFIG = 2, /* Specified config is invalid. */
1933  OFPPMFC_BAD_ADVERTISE = 3, /* Specified advertise is invalid. */
1934  OFPPMFC_EPERM = 4, /* Permissions error. */
1935  };
1936 
1937  /* ofp_error_msg 'code' values for OFPET_TABLE_MOD_FAILED. 'data' contains
1938  * at least the first 64 bytes of the failed request. */
1939  enum ofp_table_mod_failed_code {
1940  OFPTMFC_BAD_TABLE = 0, /* Specified table does not exist. */
1941  OFPTMFC_BAD_CONFIG = 1, /* Specified config is invalid. */
1942  OFPTMFC_EPERM = 2, /* Permissions error. */
1943  };
1944 
1945  /* ofp_error msg 'code' values for OFPET_QUEUE_OP_FAILED. 'data' contains
1946  * at least the first 64 bytes of the failed request */
1947  enum ofp_queue_op_failed_code {
1948  OFPQOFC_BAD_PORT = 0, /* Invalid port (or port does not exist). */
1949  OFPQOFC_BAD_QUEUE = 1, /* Queue does not exist. */
1950  OFPQOFC_EPERM = 2, /* Permissions error. */
1951  };
1952 
1953  /* ofp_error_msg 'code' values for OFPET_SWITCH_CONFIG_FAILED. 'data' contains
1954  * at least the first 64 bytes of the failed request. */
1955  enum ofp_switch_config_failed_code {
1956  OFPSCFC_BAD_FLAGS = 0, /* Specified flags is invalid. */
1957  OFPSCFC_BAD_LEN = 1, /* Specified len is invalid. */
1958  OFPSCFC_EPERM = 2, /* Permissions error. */
1959  };
1960 
1961  /* ofp_error_msg ’code’ values for OFPET_ROLE_REQUEST_FAILED. ’data’ contains
1962  * at least the first 64 bytes of the failed request. */
1963  enum ofp_role_request_failed_code {
1964  OFPRRFC_STALE = 0, /* Stale Message: old generation_id. */
1965  OFPRRFC_UNSUP = 1, /* Controller role change unsupported. */
1966  OFPRRFC_BAD_ROLE = 2, /* Invalid role. */
1967  };
1968 
1969  /* ofp_error_msg ’code’ values for OFPET_METER_MOD_FAILED. ’data’ contains
1970  * at least the first 64 bytes of the failed request. */
1971  enum ofp_meter_mod_failed_code {
1972  OFPMMFC_UNKNOWN = 0, /* Unspecified error. */
1973  OFPMMFC_METER_EXISTS = 1, /* Meter not added because a Meter ADD
1974  * attempted to replace an existing Meter. */
1975  OFPMMFC_INVALID_METER = 2, /* Meter not added because Meter specified
1976  * is invalid. */
1977  OFPMMFC_UNKNOWN_METER = 3, /* Meter not modified because a Meter
1978  * MODIFY attempted to modify a non-existent
1979  * Meter. */
1980  OFPMMFC_BAD_COMMAND = 4, /* Unsupported or unknown command. */
1981  OFPMMFC_BAD_FLAGS = 5, /* Flag configuration unsupported. */
1982  OFPMMFC_BAD_RATE = 6, /* Rate unsupported. */
1983  OFPMMFC_BAD_BURST = 7, /* Burst size unsupported. */
1984  OFPMMFC_BAD_BAND = 8, /* Band unsupported. */
1985  OFPMMFC_BAD_BAND_VALUE = 9, /* Band value unsupported. */
1986  OFPMMFC_OUT_OF_METERS = 10, /* No more meters available. */
1987  OFPMMFC_OUT_OF_BANDS = 11, /* The maximum number of properties
1988  * for a meter has been exceeded. */
1989  };
1990 
1991  /* ofp_error_msg ’code’ values for OFPET_TABLE_FEATURES_FAILED. ’data’ contains
1992  * at least the first 64 bytes of the failed request. */
1993  enum ofp_table_features_failed_code {
1994  OFPTFFC_BAD_TABLE = 0, /* Specified table does not exist. */
1995  OFPTFFC_BAD_METADATA = 1, /* Invalid metadata mask. */
1996  OFPTFFC_BAD_TYPE = 2, /* Unknown property type. */
1997  OFPTFFC_BAD_LEN = 3, /* Length problem in properties. */
1998  OFPTFFC_BAD_ARGUMENT = 4, /* Unsupported property value. */
1999  OFPTFFC_EPERM = 5, /* Permissions error. */
2000  };
2001 
2002  /* OFPET_EXPERIMENTER: Error message (datapath -> controller). */
2004  struct ofp_header header;
2005  uint16_t type; /* OFPET_EXPERIMENTER. */
2006  uint16_t exp_type; /* Experimenter defined. */
2007  uint32_t experimenter; /* Experimenter ID which takes the same form
2008  * as in struct ofp_experimenter_header. */
2009  uint8_t data[0]; /* Variable-length data. Interpreted based
2010  * on the type and code. No padding. */
2011  };
2012  OFP_ASSERT(sizeof(struct ofp_error_experimenter_msg) == 16);
2013 
2014 
2015  /*
2016  * 7.5 Symmetric Messages
2017  */
2018 
2019  /*
2020  * 7.5.1 Hello
2021  */
2022 
2023  /* Common header for all Hello Elements */
2025  uint16_t type; /* One of OFPHET_*. */
2026  uint16_t length; /* Length in bytes of this element. */
2027  };
2028  OFP_ASSERT(sizeof(struct ofp_hello_elem_header) == 4);
2029 
2030  /* OFPT_HELLO. This message includes zero or more hello elements having
2031  * variable size. Unknown elements types must be ignored/skipped, to allow
2032  * for future extensions. */
2033  struct ofp_hello {
2034  struct ofp_header header;
2035  /* Hello element list */
2036  struct ofp_hello_elem_header elements[0]; /* List of elements - 0 or more */
2037  };
2038  OFP_ASSERT(sizeof(struct ofp_hello) == 8);
2039 
2040  /* Hello elements types.
2041  */
2042  enum ofp_hello_elem_type {
2043  OFPHET_VERSIONBITMAP = 1,/* Bitmap of version supported. */
2044  };
2045 
2046  /* Version bitmap Hello Element */
2048  uint16_t type; /* OFPHET_VERSIONBITMAP. */
2049  uint16_t length; /* Length in bytes of this element. */
2050  /* Followed by:
2051  * - Exactly (length - 4) bytes containing the bitmaps, then
2052  * - Exactly (length + 7)/8*8 - (length) (between 0 and 7)
2053  * bytes of all-zero bytes */
2054  uint32_t bitmaps[0];/* List of bitmaps - supported versions */
2055  };
2056  OFP_ASSERT(sizeof(struct ofp_hello_elem_versionbitmap) == 4);
2057 
2058  /*
2059  * 7.5.4 Experimenter
2060  */
2061 
2062  /* Experimenter extension. */
2064  struct ofp_header header; /* Type OFPT_EXPERIMENTER. */
2065  uint32_t experimenter; /* Experimenter ID:
2066  * - MSB 0: low-order bytes are IEEE OUI.
2067  * - MSB != 0: defined by ONF. */
2068  uint32_t exp_type; /* Experimenter defined. */
2069  /* Experimenter-defined arbitrary additional data. */
2070  uint8_t body[0];
2071  };
2072  OFP_ASSERT(sizeof(struct ofp_experimenter_header) == 16);
2073 
2074 
2075 
2076 }; // end of namespace openflow13
2077 }; // end of namespace rofl
2078 
2079 #endif /* _OPENFLOW_OPENFLOW13_H */
Definition: openflow13.h:224
Definition: openflow13.h:449
Definition: openflow13.h:1181
Definition: openflow13.h:1035
Definition: openflow13.h:410
Definition: openflow13.h:216
Definition: openflow13.h:1237
Definition: openflow13.h:1756
Definition: openflow13.h:633
Definition: openflow13.h:1392
Definition: openflow13.h:783
Definition: openflow13.h:198
Definition: openflow13.h:1250
Definition: openflow13.h:936
Definition: openflow13.h:1678
Definition: openflow13.h:499
Definition: openflow13.h:1527
Definition: openflow13.h:1274
Definition: openflow13.h:1459
Definition: openflow13.h:946
Definition: openflow13.h:1452
Definition: openflow13.h:394
Definition: openflow13.h:625
Definition: openflow13.h:1429
Definition: openflow13.h:859
Definition: openflow13.h:669
Definition: openflow13.h:245
Definition: openflow13.h:1567
Definition: openflow13.h:1466
Definition: openflow13.h:549
Definition: openflow13.h:1380
Definition: openflow13.h:990
Definition: openflow13.h:206
Definition: openflow13.h:1616
Definition: openflow13.h:2033
Definition: openflow13.h:1485
Definition: openflow13.h:459
Definition: openflow13.h:26
Definition: openflow13.h:617
Definition: openflow13.h:642
Definition: openflow13.h:1736
Definition: openflow13.h:434
Definition: openflow13.h:2063
Definition: openflow13.h:1194
Definition: openflow13.h:905
Definition: openflow13.h:1640
Definition: openflow13.h:1704
Definition: openflow13.h:425
Definition: openflow13.h:660
Definition: openflow13.h:116
Definition: openflow13.h:839
Definition: openflow13.h:699
Definition: openflow13.h:731
Definition: openflow13.h:1534
Definition: openflow13.h:600
Definition: openflow13.h:1435
Definition: openflow13.h:378
Definition: openflow13.h:2024
Definition: openflow13.h:1026
Definition: openflow13.h:762
Definition: openflow13.h:1661
Definition: openflow13.h:1499
Definition: openflow13.h:538
Definition: openflow13.h:441
Definition: openflow13.h:1166
Definition: openflow13.h:1554
Definition: openflow13.h:527
Definition: openflow13.h:651