1 # Copyright (C) 2012,2013 Nippon Telegraph and Telephone Corporation.
2 # Copyright (C) 2012 Isaku Yamahata <yamahata at valinux co jp>
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 OpenFlow 1.4 definitions.
21 from ryu.lib import type_desc
22 from ryu.ofproto import nicira_ext
23 from ryu.ofproto import ofproto_utils
24 from ryu.ofproto import oxm_fields
26 from struct import calcsize
30 # Port numbering. Ports are numbered starting from 1.
31 OFPP_MAX = 0xffffff00 # Maximum number of physical and logical
33 OFPP_IN_PORT = 0xfffffff8 # Send the packet out the input port. This
34 # reserved port must be explicitly used in
35 # order to send back out of the input port.
36 OFPP_TABLE = 0xfffffff9 # Submit the packet to the first flow table
37 # NB: This destination port can only be used
38 # in packet-out messages.
39 OFPP_NORMAL = 0xfffffffa # Process with normal L2/L3 switching.
40 OFPP_FLOOD = 0xfffffffb # All physical ports in VLAN, except input
41 # port and those blocked or link down.
42 OFPP_ALL = 0xfffffffc # All physical ports except input port.
43 OFPP_CONTROLLER = 0xfffffffd # Send to controller.
44 OFPP_LOCAL = 0xfffffffe # Local openflow "port".
45 OFPP_ANY = 0xffffffff # Wildcard port used only for flow mod
46 # (delete) and flow stats requests. Selects
47 # all flows regardless of output port
48 # (including flows with no output port).
53 OFPT_HELLO = 0 # Symmetric message
54 OFPT_ERROR = 1 # Symmetric message
55 OFPT_ECHO_REQUEST = 2 # Symmetric message
56 OFPT_ECHO_REPLY = 3 # Symmetric message
57 OFPT_EXPERIMENTER = 4 # Symmetric message
58 # Switch configuration messages.
59 OFPT_FEATURES_REQUEST = 5 # Controller/switch message
60 OFPT_FEATURES_REPLY = 6 # Controller/switch message
61 OFPT_GET_CONFIG_REQUEST = 7 # Controller/switch message
62 OFPT_GET_CONFIG_REPLY = 8 # Controller/switch message
63 OFPT_SET_CONFIG = 9 # Controller/switch message
64 # Asynchronous messages.
65 OFPT_PACKET_IN = 10 # Async message
66 OFPT_FLOW_REMOVED = 11 # Async message
67 OFPT_PORT_STATUS = 12 # Async message
68 # Controller command messages.
69 OFPT_PACKET_OUT = 13 # Controller/switch message
70 OFPT_FLOW_MOD = 14 # Controller/switch message
71 OFPT_GROUP_MOD = 15 # Controller/switch message
72 OFPT_PORT_MOD = 16 # Controller/switch message
73 OFPT_TABLE_MOD = 17 # Controller/switch message
75 OFPT_MULTIPART_REQUEST = 18 # Controller/switch message
76 OFPT_MULTIPART_REPLY = 19 # Controller/switch message
78 OFPT_BARRIER_REQUEST = 20 # Controller/switch message
79 OFPT_BARRIER_REPLY = 21 # Controller/switch message
80 # Controller role change request messages.
81 OFPT_ROLE_REQUEST = 24 # Controller/switch message
82 OFPT_ROLE_REPLY = 25 # Controller/switch message
83 # Asynchronous message configuration.
84 OFPT_GET_ASYNC_REQUEST = 26 # Controller/switch message
85 OFPT_GET_ASYNC_REPLY = 27 # Controller/switch message
86 OFPT_SET_ASYNC = 28 # Controller/switch message
87 # Meters and rate limiters configuration messages.
88 OFPT_METER_MOD = 29 # Controller/switch message
89 # Controller role change event messages.
90 OFPT_ROLE_STATUS = 30 # Async message
91 # Asynchronous messages.
92 OFPT_TABLE_STATUS = 31 # Async message
93 # Request forwarding by the switch.
94 OFPT_REQUESTFORWARD = 32 # Async message
95 # Bundle operations (multiple messages as a single operation).
96 OFPT_BUNDLE_CONTROL = 33
97 OFPT_BUNDLE_ADD_MESSAGE = 34
100 _OFP_HEADER_PACK_STR = 'BBHI'
101 OFP_HEADER_PACK_STR = '!' + _OFP_HEADER_PACK_STR
106 OFP_HELLO_HEADER_SIZE = 8
108 # struct ofp_hello_elem_header
109 OFP_HELLO_ELEM_HEADER_PACK_STR = '!HH'
110 OFP_HELLO_ELEM_HEADER_SIZE = 4
111 assert (calcsize(OFP_HELLO_ELEM_HEADER_PACK_STR) == OFP_HELLO_ELEM_HEADER_SIZE)
113 # enum ofp_hello_elem_type
114 OFPHET_VERSIONBITMAP = 1
116 # struct ofp_hello_elem_versionbitmap
117 OFP_HELLO_ELEM_VERSIONBITMAP_HEADER_PACK_STR = '!HH'
118 OFP_HELLO_ELEM_VERSIONBITMAP_HEADER_SIZE = 4
119 assert (calcsize(OFP_HELLO_ELEM_VERSIONBITMAP_HEADER_PACK_STR) ==
120 OFP_HELLO_ELEM_VERSIONBITMAP_HEADER_SIZE)
123 OFP_DEFAULT_MISS_SEND_LEN = 128
125 # enum ofp_config_flags
126 # Handling of IP fragments.
127 OFPC_FRAG_NORMAL = 0 # No special handling for fragments.
128 OFPC_FRAG_DROP = 1 << 0 # Drop fragments.
129 OFPC_FRAG_REASM = 1 << 1 # Reassemble (only if OFPC_IP_REASM set).
132 # struct ofp_switch_config
133 OFP_SWITCH_CONFIG_PACK_STR = '!HH'
134 OFP_SWITCH_CONFIG_SIZE = 12
135 assert (calcsize(OFP_SWITCH_CONFIG_PACK_STR) + OFP_HEADER_SIZE ==
136 OFP_SWITCH_CONFIG_SIZE)
140 OFPTT_MAX = 0xfe # Last usable table number.
141 OFPTT_ALL = 0xff # Wildcard table used for table config, flow stats
145 # enum ofp_table_config
146 OFPTC_DEPRECATED_MASK = 3 # Deprecated bits
147 OFPTC_EVICTION = 1 << 2 # Authorise table to evict flows.
148 OFPTC_VACANCY_EVENTS = 1 << 3 # Enable vacancy events.
150 # enum ofp_table_mod_prop_type
151 OFPTMPT_EVICTION = 0x2 # Eviction property.
152 OFPTMPT_VACANCY = 0x3 # Vacancy property.
153 OFPTMPT_EXPERIMENTER = 0xFFFF # Experimenter property.
155 # enum ofp_table_mod_prop_eviction_flag
156 OFPTMPEF_OTHER = 1 << 0 # Using other factors.
157 OFPTMPEF_IMPORTANCE = 1 << 1 # Using flow entry importance.
158 OFPTMPEF_LIFETIME = 1 << 2 # Using flow entry lifetime.
160 # struct ofp_table_mod_prop_eviction
161 OFP_TABLE_MOD_PROP_EVICTION_PACK_STR = '!HHI'
162 OFP_TABLE_MOD_PROP_EVICTION_SIZE = 8
163 assert(calcsize(OFP_TABLE_MOD_PROP_EVICTION_PACK_STR) ==
164 OFP_TABLE_MOD_PROP_EVICTION_SIZE)
166 # struct ofp_table_mod_prop_vacancy
167 OFP_TABLE_MOD_PROP_VACANCY_PACK_STR = '!HHBBBx'
168 OFP_TABLE_MOD_PROP_VACANCY_SIZE = 8
169 assert(calcsize(OFP_TABLE_MOD_PROP_VACANCY_PACK_STR) ==
170 OFP_TABLE_MOD_PROP_VACANCY_SIZE)
172 # struct ofp_table_mod_prop_experimenter
173 OFP_TABLE_MOD_PROP_EXPERIMENTER_PACK_STR = '!HHII'
174 OFP_TABLE_MOD_PROP_EXPERIMENTER_SIZE = 12
175 assert(calcsize(OFP_TABLE_MOD_PROP_EXPERIMENTER_PACK_STR) ==
176 OFP_TABLE_MOD_PROP_EXPERIMENTER_SIZE)
178 # struct ofp_table_mod
179 OFP_TABLE_MOD_PACK_STR = '!B3xI'
180 OFP_TABLE_MOD_SIZE = 16
181 assert (calcsize(OFP_TABLE_MOD_PACK_STR) + OFP_HEADER_SIZE ==
184 # enum ofp_capabilities
185 OFPC_FLOW_STATS = 1 << 0 # Flow statistics.
186 OFPC_TABLE_STATS = 1 << 1 # Table statistics.
187 OFPC_PORT_STATS = 1 << 2 # Port statistics.
188 OFPC_GROUP_STATS = 1 << 3 # Group statistics.
189 OFPC_IP_REASM = 1 << 5 # Can reassemble IP fragments.
190 OFPC_QUEUE_STATS = 1 << 6 # Queue statistics.
191 OFPC_PORT_BLOCKED = 1 << 8 # Switch will block looping ports.
193 # enum ofp_port_config
194 OFPPC_PORT_DOWN = 1 << 0 # Port is administratively down.
195 OFPPC_NO_RECV = 1 << 2 # Drop all packets recieved by port.
196 OFPPC_NO_FWD = 1 << 5 # Drop packets forwarded to port.
197 OFPPC_NO_PACKET_IN = 1 << 6 # Do not send packet-in msgs for port.
199 # enum ofp_port_state
200 OFPPS_LINK_DOWN = 1 << 0 # No physical link present.
201 OFPPS_BLOCKED = 1 << 1 # Port is blocked
202 OFPPS_LIVE = 1 << 2 # Live for Fast Failover Group.
204 # enum ofp_port_features
205 OFPPF_10MB_HD = 1 << 0 # 10 Mb half-duplex rate support.
206 OFPPF_10MB_FD = 1 << 1 # 10 Mb full-duplex rate support.
207 OFPPF_100MB_HD = 1 << 2 # 100 Mb half-duplex rate support.
208 OFPPF_100MB_FD = 1 << 3 # 100 Mb full-duplex rate support.
209 OFPPF_1GB_HD = 1 << 4 # 1 Gb half-duplex rate support.
210 OFPPF_1GB_FD = 1 << 5 # 1 Gb full-duplex rate support.
211 OFPPF_10GB_FD = 1 << 6 # 10 Gb full-duplex rate support.
212 OFPPF_40GB_FD = 1 << 7 # 40 Gb full-duplex rate support.
213 OFPPF_100GB_FD = 1 << 8 # 100 Gb full-duplex rate support.
214 OFPPF_1TB_FD = 1 << 9 # 1 Tb full-duplex rate support.
215 OFPPF_OTHER = 1 << 10 # Other rate, not in the list.
216 OFPPF_COPPER = 1 << 11 # Copper medium.
217 OFPPF_FIBER = 1 << 12 # Fiber medium.
218 OFPPF_AUTONEG = 1 << 13 # Auto-negotiation.
219 OFPPF_PAUSE = 1 << 14 # Pause.
220 OFPPF_PAUSE_ASYM = 1 << 15 # Asymmetric pause.
222 # enum ofp_port_desc_prop_type
223 OFPPDPT_ETHERNET = 0 # Ethernet property.
224 OFPPDPT_OPTICAL = 1 # Optical property.
225 OFPPDPT_EXPERIMENTER = 0xFFFF # Experimenter property.
227 # struct ofp_port_desc_prop_ethernet
228 OFP_PORT_DESC_PROP_ETHERNET_PACK_STR = '!HH4xIIIIII'
229 OFP_PORT_DESC_PROP_ETHERNET_SIZE = 32
230 assert (calcsize(OFP_PORT_DESC_PROP_ETHERNET_PACK_STR) ==
231 OFP_PORT_DESC_PROP_ETHERNET_SIZE)
233 # enum ofp_optical_port_features
234 OFPOPF_RX_TUNE = 1 << 0 # Receiver is tunable
235 OFPOPF_TX_TUNE = 1 << 1 # Transmit is tunable
236 OFPOPF_TX_PWR = 1 << 2 # Power is configurable
237 OFPOPF_USE_FREQ = 1 << 3 # Use Frequency, not wavelength
239 # struct ofp_port_desc_prop_optical
240 OFP_PORT_DESC_PROP_OPTICAL_PACK_STR = '!HH4xIIIIIIIHH'
241 OFP_PORT_DESC_PROP_OPTICAL_SIZE = 40
242 assert (calcsize(OFP_PORT_DESC_PROP_OPTICAL_PACK_STR) ==
243 OFP_PORT_DESC_PROP_OPTICAL_SIZE)
245 # struct ofp_port_desc_prop_experimenter
246 OFP_PORT_DESC_PROP_EXPERIMENTER_PACK_STR = '!HHII'
247 OFP_PORT_DESC_PROP_EXPERIMENTER_SIZE = 12
248 assert (calcsize(OFP_PORT_DESC_PROP_EXPERIMENTER_PACK_STR) ==
249 OFP_PORT_DESC_PROP_EXPERIMENTER_SIZE)
252 OFP_MAX_PORT_NAME_LEN = 16
254 OFP_ETH_ALEN_STR = str(OFP_ETH_ALEN)
255 _OFP_PORT_PACK_STR = 'IH2x' + OFP_ETH_ALEN_STR + 's' + '2x' + \
256 str(OFP_MAX_PORT_NAME_LEN) + 's' + 'II'
257 OFP_PORT_PACK_STR = '!' + _OFP_PORT_PACK_STR
259 assert (calcsize(OFP_PORT_PACK_STR) == OFP_PORT_SIZE)
261 # struct ofp_switch_features
262 OFP_SWITCH_FEATURES_PACK_STR = '!QIBB2xII'
263 OFP_SWITCH_FEATURES_SIZE = 32
264 assert (calcsize(OFP_SWITCH_FEATURES_PACK_STR) + OFP_HEADER_SIZE ==
265 OFP_SWITCH_FEATURES_SIZE)
267 # enum ofp_port_reason
268 OFPPR_ADD = 0 # The port was added.
269 OFPPR_DELETE = 1 # The port was removed.
270 OFPPR_MODIFY = 2 # Some attribute of the port has changed.
272 # struct ofp_port_status
273 OFP_PORT_STATUS_PACK_STR = '!B7x' + _OFP_PORT_PACK_STR
274 OFP_PORT_STATUS_SIZE = 56
275 assert (calcsize(OFP_PORT_STATUS_PACK_STR) + OFP_HEADER_SIZE ==
276 OFP_PORT_STATUS_SIZE)
278 # enum ofp_port_mod_prop_type
279 OFPPMPT_ETHERNET = 0 # Ethernet property.
280 OFPPMPT_OPTICAL = 1 # Optical property.
281 OFPPMPT_EXPERIMENTER = 0xFFFF # Experimenter property.
283 # struct ofp_port_mod_prop_ethernet
284 OFP_PORT_MOD_PROP_ETHERNET_PACK_STR = '!HHI'
285 OFP_PORT_MOD_PROP_ETHERNET_SIZE = 8
286 assert (calcsize(OFP_PORT_MOD_PROP_ETHERNET_PACK_STR) ==
287 OFP_PORT_MOD_PROP_ETHERNET_SIZE)
289 # struct ofp_port_mod_prop_optical
290 OFP_PORT_MOD_PROP_OPTICAL_PACK_STR = '!HHIIIII'
291 OFP_PORT_MOD_PROP_OPTICAL_SIZE = 24
292 assert (calcsize(OFP_PORT_MOD_PROP_OPTICAL_PACK_STR) ==
293 OFP_PORT_MOD_PROP_OPTICAL_SIZE)
295 # struct ofp_port_mod_prop_experimenter
296 OFP_PORT_MOD_PROP_EXPERIMENTER_PACK_STR = '!HHII'
297 OFP_PORT_MOD_PROP_EXPERIMENTER_SIZE = 12
298 assert (calcsize(OFP_PORT_MOD_PROP_EXPERIMENTER_PACK_STR) ==
299 OFP_PORT_MOD_PROP_EXPERIMENTER_SIZE)
301 # struct ofp_port_mod
302 OFP_PORT_MOD_PACK_STR = '!I4x' + OFP_ETH_ALEN_STR + 's2xII'
303 OFP_PORT_MOD_SIZE = 32
304 assert (calcsize(OFP_PORT_MOD_PACK_STR) + OFP_HEADER_SIZE ==
308 # enum ofp_match_type
309 OFPMT_STANDARD = 0 # Deprecated
310 OFPMT_OXM = 1 # OpenFlow Extensible Match
313 _OFP_MATCH_PACK_STR = 'HH4x'
314 OFP_MATCH_PACK_STR = '!' + _OFP_MATCH_PACK_STR
316 assert calcsize(OFP_MATCH_PACK_STR) == OFP_MATCH_SIZE
319 OFPXMC_NXM_0 = 0x0000 # Backward compatibility with NXM
320 OFPXMC_NXM_1 = 0x0001 # Backward compatibility with NXM
321 OFPXMC_OPENFLOW_BASIC = 0x8000 # Basic class for OpenFlow
322 OFPXMC_EXPERIMENTER = 0xFFFF # Experimenter class
325 OFPVID_PRESENT = 0x1000 # bit that indicate that a VLAN id is set.
326 OFPVID_NONE = 0X0000 # No VLAN id was set.
329 def _oxm_tlv_header(class_, field, hasmask, length):
330 return (class_ << 16) | (field << 9) | (hasmask << 8) | length
333 def oxm_tlv_header(field, length):
334 return _oxm_tlv_header(OFPXMC_OPENFLOW_BASIC, field, 0, length)
337 def oxm_tlv_header_w(field, length):
338 return _oxm_tlv_header(OFPXMC_OPENFLOW_BASIC, field, 1, length * 2)
341 def oxm_tlv_header_extract_hasmask(header):
342 return (header >> 8) & 1
345 def oxm_tlv_header_extract_length(header):
346 if oxm_tlv_header_extract_hasmask(header):
347 length = (header & 0xff) // 2
349 length = header & 0xff
354 oxm_fields.OpenFlowBasic('in_port', 0, type_desc.Int4),
355 oxm_fields.OpenFlowBasic('in_phy_port', 1, type_desc.Int4),
356 oxm_fields.OpenFlowBasic('metadata', 2, type_desc.Int8),
357 oxm_fields.OpenFlowBasic('eth_dst', 3, type_desc.MacAddr),
358 oxm_fields.OpenFlowBasic('eth_src', 4, type_desc.MacAddr),
359 oxm_fields.OpenFlowBasic('eth_type', 5, type_desc.Int2),
360 oxm_fields.OpenFlowBasic('vlan_vid', 6, type_desc.Int2),
361 oxm_fields.OpenFlowBasic('vlan_pcp', 7, type_desc.Int1),
362 oxm_fields.OpenFlowBasic('ip_dscp', 8, type_desc.Int1),
363 oxm_fields.OpenFlowBasic('ip_ecn', 9, type_desc.Int1),
364 oxm_fields.OpenFlowBasic('ip_proto', 10, type_desc.Int1),
365 oxm_fields.OpenFlowBasic('ipv4_src', 11, type_desc.IPv4Addr),
366 oxm_fields.OpenFlowBasic('ipv4_dst', 12, type_desc.IPv4Addr),
367 oxm_fields.OpenFlowBasic('tcp_src', 13, type_desc.Int2),
368 oxm_fields.OpenFlowBasic('tcp_dst', 14, type_desc.Int2),
369 oxm_fields.OpenFlowBasic('udp_src', 15, type_desc.Int2),
370 oxm_fields.OpenFlowBasic('udp_dst', 16, type_desc.Int2),
371 oxm_fields.OpenFlowBasic('sctp_src', 17, type_desc.Int2),
372 oxm_fields.OpenFlowBasic('sctp_dst', 18, type_desc.Int2),
373 oxm_fields.OpenFlowBasic('icmpv4_type', 19, type_desc.Int1),
374 oxm_fields.OpenFlowBasic('icmpv4_code', 20, type_desc.Int1),
375 oxm_fields.OpenFlowBasic('arp_op', 21, type_desc.Int2),
376 oxm_fields.OpenFlowBasic('arp_spa', 22, type_desc.IPv4Addr),
377 oxm_fields.OpenFlowBasic('arp_tpa', 23, type_desc.IPv4Addr),
378 oxm_fields.OpenFlowBasic('arp_sha', 24, type_desc.MacAddr),
379 oxm_fields.OpenFlowBasic('arp_tha', 25, type_desc.MacAddr),
380 oxm_fields.OpenFlowBasic('ipv6_src', 26, type_desc.IPv6Addr),
381 oxm_fields.OpenFlowBasic('ipv6_dst', 27, type_desc.IPv6Addr),
382 oxm_fields.OpenFlowBasic('ipv6_flabel', 28, type_desc.Int4),
383 oxm_fields.OpenFlowBasic('icmpv6_type', 29, type_desc.Int1),
384 oxm_fields.OpenFlowBasic('icmpv6_code', 30, type_desc.Int1),
385 oxm_fields.OpenFlowBasic('ipv6_nd_target', 31, type_desc.IPv6Addr),
386 oxm_fields.OpenFlowBasic('ipv6_nd_sll', 32, type_desc.MacAddr),
387 oxm_fields.OpenFlowBasic('ipv6_nd_tll', 33, type_desc.MacAddr),
388 oxm_fields.OpenFlowBasic('mpls_label', 34, type_desc.Int4),
389 oxm_fields.OpenFlowBasic('mpls_tc', 35, type_desc.Int1),
390 oxm_fields.OpenFlowBasic('mpls_bos', 36, type_desc.Int1),
391 oxm_fields.OpenFlowBasic('pbb_isid', 37, type_desc.Int3),
392 oxm_fields.OpenFlowBasic('tunnel_id', 38, type_desc.Int8),
393 oxm_fields.OpenFlowBasic('ipv6_exthdr', 39, type_desc.Int2),
394 oxm_fields.OpenFlowBasic('pbb_uca', 41, type_desc.Int1),
395 # EXT-109 TCP flags match field Extension
396 oxm_fields.ONFExperimenter('tcp_flags', 42, type_desc.Int2),
397 # EXT-233 Output match Extension
398 # NOTE(yamamoto): The spec says uint64_t but I assume it's an error.
399 oxm_fields.ONFExperimenter('actset_output', 43, type_desc.Int4),
400 ] + nicira_ext.oxm_types
402 oxm_fields.generate(__name__)
405 # enum ofp_action_type
406 OFPAT_OUTPUT = 0 # Output to switch port.
407 OFPAT_COPY_TTL_OUT = 11 # Copy TTL "outwards" -- from
408 # next-to-outermost to outermost
409 OFPAT_COPY_TTL_IN = 12 # Copy TTL "inwards" -- from outermost to
411 OFPAT_SET_MPLS_TTL = 15 # MPLS TTL.
412 OFPAT_DEC_MPLS_TTL = 16 # Decrement MPLS TTL
413 OFPAT_PUSH_VLAN = 17 # Push a new VLAN tag
414 OFPAT_POP_VLAN = 18 # Pop the outer VLAN tag
415 OFPAT_PUSH_MPLS = 19 # Push a new MPLS tag
416 OFPAT_POP_MPLS = 20 # Pop the outer MPLS tag
417 OFPAT_SET_QUEUE = 21 # Set queue id when outputting to a port
418 OFPAT_GROUP = 22 # Apply group
419 OFPAT_SET_NW_TTL = 23 # IP TTL.
420 OFPAT_DEC_NW_TTL = 24 # Decrement IP TTL.
421 OFPAT_SET_FIELD = 25 # Set a header field using OXM TLV format.
422 OFPAT_PUSH_PBB = 26 # Push a new PBB service tag (I-TAG)
423 OFPAT_POP_PBB = 27 # Pop the outer PBB service tag (I-TAG)
424 OFPAT_EXPERIMENTER = 0xffff
427 # struct ofp_action_header
428 OFP_ACTION_HEADER_PACK_STR = '!HH4x'
429 OFP_ACTION_HEADER_SIZE = 8
430 assert calcsize(OFP_ACTION_HEADER_PACK_STR) == OFP_ACTION_HEADER_SIZE
432 # enum ofp_controller_max_len
433 OFPCML_MAX = 0xffe5 # maximum max_len value which can be used to
434 # request a specific byte length.
435 OFPCML_NO_BUFFER = 0xffff # indicates that no buffering should be
436 # applied and the whole packet is to be
437 # sent to the controller.
439 # struct ofp_action_output
440 OFP_ACTION_OUTPUT_PACK_STR = '!HHIH6x'
441 OFP_ACTION_OUTPUT_SIZE = 16
442 assert calcsize(OFP_ACTION_OUTPUT_PACK_STR) == OFP_ACTION_OUTPUT_SIZE
444 # struct ofp_action_generic
445 OFP_ACTION_GENERIC_PACK_STR = '!HH4x'
446 OFP_ACTION_GENERIC_SIZE = 8
447 assert (calcsize(OFP_ACTION_GENERIC_PACK_STR) == OFP_ACTION_GENERIC_SIZE)
449 # struct ofp_action_mpls_ttl
450 OFP_ACTION_MPLS_TTL_PACK_STR = '!HHB3x'
451 OFP_ACTION_MPLS_TTL_SIZE = 8
452 assert calcsize(OFP_ACTION_MPLS_TTL_PACK_STR) == OFP_ACTION_MPLS_TTL_SIZE
454 # struct ofp_action_push
455 OFP_ACTION_PUSH_PACK_STR = '!HHH2x'
456 OFP_ACTION_PUSH_SIZE = 8
457 assert calcsize(OFP_ACTION_PUSH_PACK_STR) == OFP_ACTION_PUSH_SIZE
459 # struct ofp_action_pop_mpls
460 OFP_ACTION_POP_MPLS_PACK_STR = '!HHH2x'
461 OFP_ACTION_POP_MPLS_SIZE = 8
462 assert calcsize(OFP_ACTION_POP_MPLS_PACK_STR) == OFP_ACTION_POP_MPLS_SIZE
464 # struct ofp_action_set_queue
465 OFP_ACTION_SET_QUEUE_PACK_STR = '!HHI'
466 OFP_ACTION_SET_QUEUE_SIZE = 8
467 assert calcsize(OFP_ACTION_SET_QUEUE_PACK_STR) == OFP_ACTION_SET_QUEUE_SIZE
469 # struct ofp_action_group
470 OFP_ACTION_GROUP_PACK_STR = '!HHI'
471 OFP_ACTION_GROUP_SIZE = 8
472 assert calcsize(OFP_ACTION_GROUP_PACK_STR) == OFP_ACTION_GROUP_SIZE
474 # struct ofp_action_nw_ttl
475 OFP_ACTION_NW_TTL_PACK_STR = '!HHB3x'
476 OFP_ACTION_NW_TTL_SIZE = 8
477 assert calcsize(OFP_ACTION_NW_TTL_PACK_STR) == OFP_ACTION_NW_TTL_SIZE
479 # struct ofp_action_set_field
480 OFP_ACTION_SET_FIELD_PACK_STR = '!HH4x'
481 OFP_ACTION_SET_FIELD_SIZE = 8
482 assert calcsize(OFP_ACTION_SET_FIELD_PACK_STR) == OFP_ACTION_SET_FIELD_SIZE
484 # struct ofp_action_experimenter_header
485 OFP_ACTION_EXPERIMENTER_HEADER_PACK_STR = '!HHI'
486 OFP_ACTION_EXPERIMENTER_HEADER_SIZE = 8
487 assert (calcsize(OFP_ACTION_EXPERIMENTER_HEADER_PACK_STR) ==
488 OFP_ACTION_EXPERIMENTER_HEADER_SIZE)
490 # enum ofp_instruction_type
491 OFPIT_GOTO_TABLE = 1 # Setup the next table in the lookup pipeline.
492 OFPIT_WRITE_METADATA = 2 # Setup the metadata field for use later in
494 OFPIT_WRITE_ACTIONS = 3 # Write the action(s) onto the datapath
496 OFPIT_APPLY_ACTIONS = 4 # Applies the action(s) immediately
497 OFPIT_CLEAR_ACTIONS = 5 # Clears all actions from the datapath action
499 OFPIT_METER = 6 # Apply meter (rate limiter)
500 OFPIT_EXPERIMENTER = 0xFFFF # Experimenter instruction
502 # struct ofp_instruction_goto_table
503 OFP_INSTRUCTION_GOTO_TABLE_PACK_STR = '!HHB3x'
504 OFP_INSTRUCTION_GOTO_TABLE_SIZE = 8
505 assert (calcsize(OFP_INSTRUCTION_GOTO_TABLE_PACK_STR) ==
506 OFP_INSTRUCTION_GOTO_TABLE_SIZE)
508 # struct ofp_instruction_write_metadata
509 OFP_INSTRUCTION_WRITE_METADATA_PACK_STR = '!HH4xQQ'
510 OFP_INSTRUCTION_WRITE_METADATA_SIZE = 24
511 assert (calcsize(OFP_INSTRUCTION_WRITE_METADATA_PACK_STR) ==
512 OFP_INSTRUCTION_WRITE_METADATA_SIZE)
514 # struct ofp_instruction_actions
515 OFP_INSTRUCTION_ACTIONS_PACK_STR = '!HH4x'
516 OFP_INSTRUCTION_ACTIONS_SIZE = 8
517 assert (calcsize(OFP_INSTRUCTION_ACTIONS_PACK_STR) ==
518 OFP_INSTRUCTION_ACTIONS_SIZE)
520 # struct ofp_instruction_meter
521 OFP_INSTRUCTION_METER_PACK_STR = '!HHI'
522 OFP_INSTRUCTION_METER_SIZE = 8
523 assert calcsize(OFP_INSTRUCTION_METER_PACK_STR) == OFP_INSTRUCTION_METER_SIZE
525 # struct ofp_instruction_experimenter_header
526 OFP_INSTRUCTION_EXPERIMENTER_HEADER_PACK_STR = '!HHI'
527 OFP_INSTRUCTION_EXPERIMENTER_HEADER_SIZE = 8
528 assert (calcsize(OFP_INSTRUCTION_EXPERIMENTER_HEADER_PACK_STR) ==
529 OFP_INSTRUCTION_EXPERIMENTER_HEADER_SIZE)
531 # enum ofp_flow_mod_command
532 OFPFC_ADD = 0 # New flow.
533 OFPFC_MODIFY = 1 # Modify all matching flows.
534 OFPFC_MODIFY_STRICT = 2 # Modify entry strictly matching wildcards
535 OFPFC_DELETE = 3 # Delete all matching flows.
536 OFPFC_DELETE_STRICT = 4 # Strictly match wildcards and priority.
538 # Value used in "idle_timeout" and "hard_timeout" to indicate that the
539 # entry is permanent. */
540 OFP_FLOW_PERMANENT = 0
542 # By default, choose a priority in the middle.
543 OFP_DEFAULT_PRIORITY = 0x8000
545 # enum ofp_flow_mod_flags
546 OFPFF_SEND_FLOW_REM = 1 << 0 # Send flow removed message when flow
547 # expires or is deleted.
548 OFPFF_CHECK_OVERLAP = 1 << 1 # Check for overlapping entries first.
549 OFPFF_RESET_COUNTS = 1 << 2 # Reset flow packet and byte counts.
550 OFPFF_NO_PKT_COUNTS = 1 << 3 # Don't keep track of packet count.
551 OFPFF_NO_BYT_COUNTS = 1 << 4 # Don't keep track of byte count.
553 # struct ofp_flow_mod
554 _OFP_FLOW_MOD_PACK_STR0 = 'QQBBHHHIIIHH'
555 OFP_FLOW_MOD_PACK_STR = '!' + _OFP_FLOW_MOD_PACK_STR0 + _OFP_MATCH_PACK_STR
556 OFP_FLOW_MOD_PACK_STR0 = '!' + _OFP_FLOW_MOD_PACK_STR0
557 OFP_FLOW_MOD_SIZE = 56
558 assert (calcsize(OFP_FLOW_MOD_PACK_STR) + OFP_HEADER_SIZE ==
562 OFPG_MAX = 0xffffff00 # Last usable group number.
563 OFPG_ALL = 0xfffffffc # Represents all groups for group delete commands.
564 OFPG_ANY = 0xffffffff # Wildcard group used only for flow stats requests.
565 # Selects all flows regardless of group
566 # (including flows with no group).
568 # enum ofp_group_mod_command
569 OFPGC_ADD = 0 # New group.
570 OFPGC_MODIFY = 1 # Modify all matching groups.
571 OFPGC_DELETE = 2 # Delete all matching groups.
574 OFP_BUCKET_PACK_STR = '!HHII4x'
576 assert calcsize(OFP_BUCKET_PACK_STR) == OFP_BUCKET_SIZE
578 # struct ofp_group_mod
579 OFP_GROUP_MOD_PACK_STR = '!HBxI'
580 OFP_GROUP_MOD_SIZE = 16
581 assert (calcsize(OFP_GROUP_MOD_PACK_STR) + OFP_HEADER_SIZE ==
584 # enum ofp_group_type
585 OFPGT_ALL = 0 # All (multicast/broadcast) group.
586 OFPGT_SELECT = 1 # Select group.
587 OFPGT_INDIRECT = 2 # Indirect group.
588 OFPGT_FF = 3 # Fast failover group.
591 OFP_NO_BUFFER = 0xffffffff # Special buffer-id to indicate 'no buffer'
593 # struct ofp_packet_out
594 OFP_PACKET_OUT_PACK_STR = '!IIH6x'
595 OFP_PACKET_OUT_SIZE = 24
596 assert (calcsize(OFP_PACKET_OUT_PACK_STR) + OFP_HEADER_SIZE ==
599 # enum ofp_packet_in_reason
600 OFPR_TABLE_MISS = 0 # No matching flow (table-miss flow entry).
601 OFPR_APPLY_ACTION = 1 # Output to controller in apply-actions.
602 OFPR_INVALID_TTL = 2 # Packet has invalid TTL.
603 OFPR_ACTION_SET = 3 # Output to controller in action set.
604 OFPR_GROUP = 4 # Output to controller in group bucket.
605 OFPR_PACKET_OUT = 5 # Output to controller in packet-out.
607 # struct ofp_packet_in
608 OFP_PACKET_IN_PACK_STR = '!IHBBQ'
609 OFP_PACKET_IN_SIZE = 32
610 assert (calcsize(OFP_PACKET_IN_PACK_STR) + OFP_MATCH_SIZE + OFP_HEADER_SIZE ==
613 # enum ofp_flow_removed_reason
614 OFPRR_IDLE_TIMEOUT = 0 # Flow idle time exceeded idle_timeout.
615 OFPRR_HARD_TIMEOUT = 1 # Time exceeded hard_timeout.
616 OFPRR_DELETE = 2 # Evicted by a DELETE flow mod.
617 OFPRR_GROUP_DELETE = 3 # Group was removed.
618 OFPRR_METER_DELETE = 4 # Meter was removed.
619 OFPRR_EVICTION = 5 # Switch eviction to free resources.
621 # struct ofp_port_status
622 OFP_PORT_STATUS_PACK_STR = '!B7x' + _OFP_PORT_PACK_STR
623 OFP_PORT_STATUS_DESC_OFFSET = OFP_HEADER_SIZE + 8
624 OFP_PORT_STATUS_SIZE = 56
625 assert (calcsize(OFP_PORT_STATUS_PACK_STR) + OFP_HEADER_SIZE ==
626 OFP_PORT_STATUS_SIZE)
628 # struct ofp_flow_removed
629 _OFP_FLOW_REMOVED_PACK_STR0 = 'QHBBIIHHQQ'
630 OFP_FLOW_REMOVED_PACK_STR = '!' + _OFP_FLOW_REMOVED_PACK_STR0 + \
632 OFP_FLOW_REMOVED_PACK_STR0 = '!' + _OFP_FLOW_REMOVED_PACK_STR0
633 OFP_FLOW_REMOVED_SIZE = 56
634 assert (calcsize(OFP_FLOW_REMOVED_PACK_STR) + OFP_HEADER_SIZE ==
635 OFP_FLOW_REMOVED_SIZE)
638 OFPM_MAX = 0xffff0000
639 OFPM_SLOWPATH = 0xfffffffd # Meter for slow datapath, if any.
640 OFPM_CONTROLLER = 0xfffffffe # Meter for controller connection.
641 OFPM_ALL = 0xffffffff # Represents all meters for stat requests
644 # enum ofp_meter_band_type
645 OFPMBT_DROP = 1 # Drop packet.
646 OFPMBT_DSCP_REMARK = 2 # Remark DSCP in the IP header.
647 OFPMBT_EXPERIMENTER = 0xFFFF # Experimenter meter band.
649 # struct ofp_meter_band_drop
650 OFP_METER_BAND_DROP_PACK_STR = '!HHII4x'
651 OFP_METER_BAND_DROP_SIZE = 16
652 assert (calcsize(OFP_METER_BAND_DROP_PACK_STR) ==
653 OFP_METER_BAND_DROP_SIZE)
655 # struct ofp_meter_band_dscp_remark
656 OFP_METER_BAND_DSCP_REMARK_PACK_STR = '!HHIIB3x'
657 OFP_METER_BAND_DSCP_REMARK_SIZE = 16
658 assert (calcsize(OFP_METER_BAND_DSCP_REMARK_PACK_STR) ==
659 OFP_METER_BAND_DSCP_REMARK_SIZE)
661 # struct ofp_meter_band_experimenter
662 OFP_METER_BAND_EXPERIMENTER_PACK_STR = '!HHIII'
663 OFP_METER_BAND_EXPERIMENTER_SIZE = 16
664 assert (calcsize(OFP_METER_BAND_EXPERIMENTER_PACK_STR) ==
665 OFP_METER_BAND_EXPERIMENTER_SIZE)
667 # enum ofp_meter_mod_command
668 OFPMC_ADD = 0 # New meter.
669 OFPMC_MODIFY = 1 # Modify specified meter.
670 OFPMC_DELETE = 2 # Delete specified meter.
672 # enum ofp_meter_flags
673 OFPMF_KBPS = 1 << 0 # Rate value in kb/s (kilo-bit per second).
674 OFPMF_PKTPS = 1 << 1 # Rate value in packet/sec.
675 OFPMF_BURST = 1 << 2 # Do burst size.
676 OFPMF_STATS = 1 << 3 # Collect statistics.
678 # struct ofp_meter_band_header
679 OFP_METER_BAND_HEADER_PACK_STR = '!HHII'
680 OFP_METER_BAND_HEADER_SIZE = 12
681 assert (calcsize(OFP_METER_BAND_HEADER_PACK_STR) ==
682 OFP_METER_BAND_HEADER_SIZE)
684 # struct ofp_meter_mod
685 OFP_METER_MOD_PACK_STR = '!HHI'
686 OFP_METER_MOD_SIZE = 16
687 assert (calcsize(OFP_METER_MOD_PACK_STR) + OFP_HEADER_SIZE ==
691 # enum ofp_error_type
692 OFPET_HELLO_FAILED = 0 # Hello protocol failed.
693 OFPET_BAD_REQUEST = 1 # Request was not understood.
694 OFPET_BAD_ACTION = 2 # Error in action description.
695 OFPET_BAD_INSTRUCTION = 3 # Error in instruction list.
696 OFPET_BAD_MATCH = 4 # Error in match.
697 OFPET_FLOW_MOD_FAILED = 5 # Problem modifying flow entry.
698 OFPET_GROUP_MOD_FAILED = 6 # Problem modifying group entry.
699 OFPET_PORT_MOD_FAILED = 7 # OFPT_PORT_MOD failed.
700 OFPET_TABLE_MOD_FAILED = 8 # Table mod request failed.
701 OFPET_QUEUE_OP_FAILED = 9 # Queue operation failed.
702 OFPET_SWITCH_CONFIG_FAILED = 10 # Switch config request failed.
703 OFPET_ROLE_REQUEST_FAILED = 11 # Controller Role request failed.
704 OFPET_METER_MOD_FAILED = 12 # Error in meter.
705 OFPET_TABLE_FEATURES_FAILED = 13 # Setting table features failed.
706 OFPET_BAD_PROPERTY = 14 # Some property is invalid.
707 OFPET_ASYNC_CONFIG_FAILED = 15 # Asynchronous config request failed.
708 OFPET_FLOW_MONITOR_FAILED = 16 # Setting flow monitor failed.
709 OFPET_BUNDLE_FAILED = 17 # Bundle operation failed.
710 OFPET_EXPERIMENTER = 0xffff # Experimenter error messages.
712 # enum ofp_hello_failed_code
713 OFPHFC_INCOMPATIBLE = 0 # No compatible version.
714 OFPHFC_EPERM = 1 # Permissions error.
716 # enum ofp_bad_request_code
717 OFPBRC_BAD_VERSION = 0 # ofp_header.version not supported.
718 OFPBRC_BAD_TYPE = 1 # ofp_header.type not supported.
719 OFPBRC_BAD_MULTIPART = 2 # ofp_multipart_request.type not
721 OFPBRC_BAD_EXPERIMENTER = 3 # Experimenter id not supported
722 # (in ofp_experimenter_header
723 # or ofp_multipart_request or
724 # ofp_multipart_reply).
725 OFPBRC_BAD_EXP_TYPE = 4 # Experimenter type not supported.
726 OFPBRC_EPERM = 5 # Permissions error.
727 OFPBRC_BAD_LEN = 6 # Wrong request length for type.
728 OFPBRC_BUFFER_EMPTY = 7 # Specified buffer has already been
730 OFPBRC_BUFFER_UNKNOWN = 8 # Specified buffer does not exist.
731 OFPBRC_BAD_TABLE_ID = 9 # Specified table-id invalid or does
733 OFPBRC_IS_SLAVE = 10 # Denied because controller is slave.
734 OFPBRC_BAD_PORT = 11 # Invalid port.
735 OFPBRC_BAD_PACKET = 12 # Invalid packet in packet-out
736 OFPBRC_MULTIPART_BUFFER_OVERFLOW = 13 # ofp_multipart_request
737 # overflowed the assigned buffer.
738 OFPBRC_MULTIPART_REQUEST_TIMEOUT = 14 # Timeout during multipart request.
739 OFPBRC_MULTIPART_REPLY_TIMEOUT = 15 # Timeout during multipart reply.
742 # enum ofp_bad_action_code
743 OFPBAC_BAD_TYPE = 0 # Unknown action type.
744 OFPBAC_BAD_LEN = 1 # Length problem in actions.
745 OFPBAC_BAD_EXPERIMENTER = 2 # Unknown experimenter id specified.
746 OFPBAC_BAD_EXP_TYPE = 3 # Unknown action type for experimenter id.
747 OFPBAC_BAD_OUT_PORT = 4 # Problem validating output action.
748 OFPBAC_BAD_ARGUMENT = 5 # Bad action argument.
749 OFPBAC_EPERM = 6 # Permissions error.
750 OFPBAC_TOO_MANY = 7 # Can't handle this many actions.
751 OFPBAC_BAD_QUEUE = 8 # Problem validating output queue.
752 OFPBAC_BAD_OUT_GROUP = 9 # Invalid group id in forward action.
753 OFPBAC_MATCH_INCONSISTENT = 10 # Action can't apply for this match,
754 # or Set-Field missing prerequisite.
755 OFPBAC_UNSUPPORTED_ORDER = 11 # Action order is unsupported for
756 # the action list in an Apply-Actions
758 OFPBAC_BAD_TAG = 12 # Actions uses an unsupported tag/encap.
759 OFPBAC_BAD_SET_TYPE = 13 # Unsupported type in SET_FIELD action.
760 OFPBAC_BAD_SET_LEN = 14 # Length problem in SET_FIELD action.
761 OFPBAC_BAD_SET_ARGUMENT = 15 # Bad arguement in SET_FIELD action.
763 # enum ofp_bad_instruction_code
764 OFPBIC_UNKNOWN_INST = 0 # Unknown instruction.
765 OFPBIC_UNSUP_INST = 1 # Switch or table does not support
767 OFPBIC_BAD_TABLE_ID = 2 # Invalid Table-Id specified
768 OFPBIC_UNSUP_METADATA = 3 # Metadata value unsupported by datapath.
769 OFPBIC_UNSUP_METADATA_MASK = 4 # Metadata mask value unsupported by
771 OFPBIC_BAD_EXPERIMENTER = 5 # Unknown experimenter id specified.
772 OFPBIC_BAD_EXP_TYPE = 6 # Unknown instruction for experimenter id.
773 OFPBIC_BAD_LEN = 7 # Length problem in instrucitons.
774 OFPBIC_EPERM = 8 # Permissions error.
775 OFPBIC_DUP_INST = 9 # Duplicate instruction.
777 # enum ofp_bad_match_code
778 OFPBMC_BAD_TYPE = 0 # Unsupported match type apecified by
780 OFPBMC_BAD_LEN = 1 # Length problem in math.
781 OFPBMC_BAD_TAG = 2 # Match uses an unsupported tag/encap.
782 OFPBMC_BAD_DL_ADDR_MASK = 3 # Unsupported datalink addr mask -
783 # switch does not support arbitrary
784 # datalink address mask.
785 OFPBMC_BAD_NW_ADDR_MASK = 4 # Unsupported network addr mask -
786 # switch does not support arbitrary
787 # network addres mask.
788 OFPBMC_BAD_WILDCARDS = 5 # Unsupported combination of fields
789 # masked or omitted in the match.
790 OFPBMC_BAD_FIELD = 6 # Unsupported field type in the match.
791 OFPBMC_BAD_VALUE = 7 # Unsupported value in a match field.
792 OFPBMC_BAD_MASK = 8 # Unsupported mask specified in the
794 OFPBMC_BAD_PREREQ = 9 # A prerequisite was not met.
795 OFPBMC_DUP_FIELD = 10 # A field type was duplicated.
796 OFPBMC_EPERM = 11 # Permissions error.
798 # enum ofp_flow_mod_failed_code
799 OFPFMFC_UNKNOWN = 0 # Unspecified error.
800 OFPFMFC_TABLE_FULL = 1 # Flow not added because table was full.
801 OFPFMFC_BAD_TABLE_ID = 2 # Table does not exist
802 OFPFMFC_OVERLAP = 3 # Attempted to add overlapping flow with
803 # CHECK_OVERLAP flag set.
804 OFPFMFC_EPERM = 4 # Permissions error.
805 OFPFMFC_BAD_TIMEOUT = 5 # Flow not added because of unsupported
807 OFPFMFC_BAD_COMMAND = 6 # Unsupported or unknown command.
808 OFPFMFC_BAD_FLAGS = 7 # Unsupported or unknown flags.
809 OFPFMFC_CANT_SYNC = 8 # Problem in table synchronisation.
810 OFPFMFC_BAD_PRIORITY = 9 # Unsupported priority value.
812 # enum ofp_group_mod_failed_code
813 OFPGMFC_GROUP_EXISTS = 0 # Group not added because a group ADD
814 # attempted to replace an already-present
816 OFPGMFC_INVALID_GROUP = 1 # Group not added because Group specified
818 OFPGMFC_WEIGHT_UNSUPPORTED = 2 # Switch does not support unequal load
819 # sharing with select groups.
820 OFPGMFC_OUT_OF_GROUPS = 3 # The group table is full.
821 OFPGMFC_OUT_OF_BUCKETS = 4 # The maximum number of action buckets
822 # for a group has been exceeded.
823 OFPGMFC_CHAINING_UNSUPPORTED = 5 # Switch does not support groups that
825 OFPGMFC_WATCH_UNSUPPORTED = 6 # This group cannot watch the
826 # watch_port or watch_group specified.
827 OFPGMFC_LOOP = 7 # Group entry would cause a loop.
828 OFPGMFC_UNKNOWN_GROUP = 8 # Group not modified because a group MODIFY
829 # attempted to modify a non-existent group.
830 OFPGMFC_CHAINED_GROUP = 9 # Group not deleted because another group
831 # is forwarding to it.
832 OFPGMFC_BAD_TYPE = 10 # Unsupported or unknown group type.
833 OFPGMFC_BAD_COMMAND = 11 # Unsupported or unknown command.
834 OFPGMFC_BAD_BUCKET = 12 # Error in bucket.
835 OFPGMFC_BAD_WATCH = 13 # Error in watch port/group.
836 OFPGMFC_EPERM = 14 # Permissions error.
838 # enum ofp_port_mod_failed_code
839 OFPPMFC_BAD_PORT = 0 # Specified port does not exist.
840 OFPPMFC_BAD_HW_ADDR = 1 # Specified hardware address does not match
842 OFPPMFC_BAD_CONFIG = 2 # Specified config is invalid.
843 OFPPMFC_BAD_ADVERTISE = 3 # Specified advertise is invalid.
844 OFPPMFC_EPERM = 4 # Permissions error.
846 # enum ofp_table_mod_failed_code
847 OFPTMFC_BAD_TABLE = 0 # Specified table does not exist.
848 OFPTMFC_BAD_CONFIG = 1 # Specified config is invalid.
849 OFPTMFC_EPERM = 2 # Permissions error
851 # enum ofp_queue_op_failed_code
852 OFPQOFC_BAD_PORT = 0 # Invalid port (or port does not exist).
853 OFPQOFC_BAD_QUEUE = 1 # Queue does not exist.
854 OFPQOFC_EPERM = 2 # Permissions error.
856 # enum ofp_switch_config_failed_code
857 OFPSCFC_BAD_FLAGS = 0 # Specified flags is invalid.
858 OFPSCFC_BAD_LEN = 1 # Specified len is invalid.
859 OFPSCFC_EPERM = 2 # Permissions error.
861 # enum ofp_role_request_failed_code
862 OFPRRFC_STALE = 0 # Stale Message: old generation_id.
863 OFPRRFC_UNSUP = 1 # Controller role change unsupported.
864 OFPRRFC_BAD_ROLE = 2 # Invalid role.
866 # enum ofp_meter_mod_failed_code
867 OFPMMFC_UNKNOWN = 0 # Unspecified error.
868 OFPMMFC_METER_EXISTS = 1 # Meter not added because a Meter ADD
869 # attempted to replace an existing Meter.
870 OFPMMFC_INVALID_METER = 2 # Meter not added because Meter specified
872 OFPMMFC_UNKNOWN_METER = 3 # Meter not modified because a Meter MODIFY
873 # attempted to modify a non-existent Meter.
874 OFPMMFC_BAD_COMMAND = 4 # Unsupported or unknown command.
875 OFPMMFC_BAD_FLAGS = 5 # Flag configuration unsupported.
876 OFPMMFC_BAD_RATE = 6 # Rate unsupported.
877 OFPMMFC_BAD_BURST = 7 # Burst size unsupported.
878 OFPMMFC_BAD_BAND = 8 # Band unsupported.
879 OFPMMFC_BAD_BAND_VALUE = 9 # Band value unsupported.
880 OFPMMFC_OUT_OF_METERS = 10 # No more meters availabile.
881 OFPMMFC_OUT_OF_BANDS = 11 # The maximum number of properties for a
882 # meter has been exceeded.
884 # enum ofp_table_features_failed_code
885 OFPTFFC_BAD_TABLE = 0 # Specified table does not exist.
886 OFPTFFC_BAD_METADATA = 1 # Invalid metadata mask.
887 OFPTFFC_EPERM = 5 # Permissions error.
889 # enum ofp_bad_property_code
890 OFPBPC_BAD_TYPE = 0 # Unknown property type.
891 OFPBPC_BAD_LEN = 1 # Length problem in property.
892 OFPBPC_BAD_VALUE = 2 # Unsupported property value.
893 OFPBPC_TOO_MANY = 3 # Can't handle this many properties.
894 OFPBPC_DUP_TYPE = 4 # A property type was duplicated.
895 OFPBPC_BAD_EXPERIMENTER = 5 # Unknown experimenter id specified.
896 OFPBPC_BAD_EXP_TYPE = 6 # Unknown exp_type for experimenter id.
897 OFPBPC_BAD_EXP_VALUE = 7 # Unknown value for experimenter id.
898 OFPBPC_EPERM = 8 # Permissions error.
900 # enum ofp_async_config_failed_code
901 OFPACFC_INVALID = 0 # One mask is invalid.
902 OFPACFC_UNSUPPORTED = 1 # Requested configuration not supported.
903 OFPACFC_EPERM = 2 # Permissions error.
905 # enum ofp_flow_monitor_failed_code
906 OFPMOFC_UNKNOWN = 0 # Unspecified error.
907 OFPMOFC_MONITOR_EXISTS = 1 # Monitor not added because a Monitor ADD
908 # attempted to replace an existing
910 OFPMOFC_INVALID_MONITOR = 2 # Monitor not added because Monitor
911 # specified is invalid.
912 OFPMOFC_UNKNOWN_MONITOR = 3 # Monitor not modified because a Monitor
913 # MODIFY attempted to modify a non-existent
915 OFPMOFC_BAD_COMMAND = 4 # Unsupported or unknown command.
916 OFPMOFC_BAD_FLAGS = 5 # Flag configuration unsupported.
917 OFPMOFC_BAD_TABLE_ID = 6 # Specified table does not exist.
918 OFPMOFC_BAD_OUT = 7 # Error in output port/group.
920 # enum ofp_bundle_failed_code
921 OFPBFC_UNKNOWN = 0 # Unspecified error.
922 OFPBFC_EPERM = 1 # Permissions error.
923 OFPBFC_BAD_ID = 2 # Bundle ID doesn't exist.
924 OFPBFC_BUNDLE_EXIST = 3 # Bundle ID already exist.
925 OFPBFC_BUNDLE_CLOSED = 4 # Bundle ID is closed.
926 OFPBFC_OUT_OF_BUNDLES = 5 # Too many bundles IDs.
927 OFPBFC_BAD_TYPE = 6 # Unsupported or unknown message control type.
928 OFPBFC_BAD_FLAGS = 7 # Unsupported, unknown, or inconsistent flags.
929 OFPBFC_MSG_BAD_LEN = 8 # Length problem in included message.
930 OFPBFC_MSG_BAD_XID = 9 # Inconsistent or duplicate XID.
931 OFPBFC_MSG_UNSUP = 10 # Unsupported message in this bundle.
932 OFPBFC_MSG_CONFLICT = 11 # Unsupported message combination in this
934 OFPBFC_MSG_TOO_MANY = 12 # Can't handle this many messages in bundle.
935 OFPBFC_MSG_FAILED = 13 # One message in bundle failed.
936 OFPBFC_TIMEOUT = 14 # Bundle is taking too long.
937 OFPBFC_BUNDLE_IN_PROGRESS = 15 # Bundle is locking the resource.
939 # struct ofp_error_msg
940 OFP_ERROR_MSG_PACK_STR = '!HH'
941 OFP_ERROR_MSG_SIZE = 12
942 assert (calcsize(OFP_ERROR_MSG_PACK_STR) + OFP_HEADER_SIZE ==
945 # struct ofp_error_experimenter_msg
946 OFP_ERROR_EXPERIMENTER_MSG_PACK_STR = '!HHI'
947 OFP_ERROR_EXPERIMENTER_MSG_SIZE = 16
948 assert (calcsize(OFP_ERROR_EXPERIMENTER_MSG_PACK_STR) +
949 OFP_HEADER_SIZE) == OFP_ERROR_EXPERIMENTER_MSG_SIZE
951 # struct ofp_experimenter_header
952 OFP_EXPERIMENTER_HEADER_PACK_STR = '!II'
953 OFP_EXPERIMENTER_HEADER_SIZE = 16
954 assert (calcsize(OFP_EXPERIMENTER_HEADER_PACK_STR) + OFP_HEADER_SIZE
955 == OFP_EXPERIMENTER_HEADER_SIZE)
957 # enum ofp_multipart_type
963 OFPMP_QUEUE_STATS = 5
966 OFPMP_GROUP_FEATURES = 8
968 OFPMP_METER_CONFIG = 10
969 OFPMP_METER_FEATURES = 11
970 OFPMP_TABLE_FEATURES = 12
972 OFPMP_TABLE_DESC = 14
973 OFPMP_QUEUE_DESC = 15
974 OFPMP_FLOW_MONITOR = 16
975 OFPMP_EXPERIMENTER = 0xffff
977 # struct ofp_multipart_request
978 OFP_MULTIPART_REQUEST_PACK_STR = '!HH4x'
979 OFP_MULTIPART_REQUEST_SIZE = 16
980 assert (calcsize(OFP_MULTIPART_REQUEST_PACK_STR) + OFP_HEADER_SIZE ==
981 OFP_MULTIPART_REQUEST_SIZE)
983 # enum ofp_multipart_reply_flags
984 OFPMPF_REPLY_MORE = 1 << 0 # More requests to follow.
986 # struct ofp_multipart_reply
987 OFP_MULTIPART_REPLY_PACK_STR = '!HH4x'
988 OFP_MULTIPART_REPLY_SIZE = 16
989 assert (calcsize(OFP_MULTIPART_REPLY_PACK_STR) + OFP_HEADER_SIZE ==
990 OFP_MULTIPART_REPLY_SIZE)
993 DESC_STR_LEN_STR = str(DESC_STR_LEN)
995 SERIAL_NUM_LEN_STR = str(SERIAL_NUM_LEN)
996 OFP_DESC_PACK_STR = '!' + \
997 DESC_STR_LEN_STR + 's' + \
998 DESC_STR_LEN_STR + 's' + \
999 DESC_STR_LEN_STR + 's' + \
1000 SERIAL_NUM_LEN_STR + 's' + \
1001 DESC_STR_LEN_STR + 's'
1002 OFP_DESC_SIZE = 1056
1003 assert calcsize(OFP_DESC_PACK_STR) == OFP_DESC_SIZE
1005 # struct ofp_flow_stats_request
1006 _OFP_FLOW_STATS_REQUEST_0_PACK_STR = 'B3xII4xQQ'
1007 OFP_FLOW_STATS_REQUEST_0_PACK_STR = '!' + _OFP_FLOW_STATS_REQUEST_0_PACK_STR
1008 OFP_FLOW_STATS_REQUEST_0_SIZE = 32
1009 assert (calcsize(OFP_FLOW_STATS_REQUEST_0_PACK_STR) ==
1010 OFP_FLOW_STATS_REQUEST_0_SIZE)
1011 OFP_FLOW_STATS_REQUEST_PACK_STR = (OFP_FLOW_STATS_REQUEST_0_PACK_STR +
1012 _OFP_MATCH_PACK_STR)
1013 OFP_FLOW_STATS_REQUEST_SIZE = 40
1014 assert (calcsize(OFP_FLOW_STATS_REQUEST_PACK_STR) ==
1015 OFP_FLOW_STATS_REQUEST_SIZE)
1017 # struct ofp_flow_stats
1018 _OFP_FLOW_STATS_0_PACK_STR = 'HBxIIHHHHH2xQQQ'
1019 OFP_FLOW_STATS_0_PACK_STR = '!' + _OFP_FLOW_STATS_0_PACK_STR
1020 OFP_FLOW_STATS_0_SIZE = 48
1021 assert calcsize(OFP_FLOW_STATS_0_PACK_STR) == OFP_FLOW_STATS_0_SIZE
1022 OFP_FLOW_STATS_PACK_STR = (OFP_FLOW_STATS_0_PACK_STR +
1023 _OFP_MATCH_PACK_STR)
1024 OFP_FLOW_STATS_SIZE = 56
1025 assert calcsize(OFP_FLOW_STATS_PACK_STR) == OFP_FLOW_STATS_SIZE
1027 # struct ofp_aggregate_stats_request
1028 OFP_AGGREGATE_STATS_REQUEST_PACK_STR = '!B3xII4xQQ' + _OFP_MATCH_PACK_STR
1029 OFP_AGGREGATE_STATS_REQUEST_SIZE = 40
1030 assert (calcsize(OFP_AGGREGATE_STATS_REQUEST_PACK_STR) ==
1031 OFP_AGGREGATE_STATS_REQUEST_SIZE)
1033 # struct ofp_aggregate_stats_reply
1034 OFP_AGGREGATE_STATS_REPLY_PACK_STR = '!QQI4x'
1035 OFP_AGGREGATE_STATS_REPLY_SIZE = 24
1036 assert (calcsize(OFP_AGGREGATE_STATS_REPLY_PACK_STR) ==
1037 OFP_AGGREGATE_STATS_REPLY_SIZE)
1040 # enum ofp_table_feature_prop_type
1041 OFPTFPT_INSTRUCTIONS = 0
1042 OFPTFPT_INSTRUCTIONS_MISS = 1
1043 OFPTFPT_NEXT_TABLES = 2
1044 OFPTFPT_NEXT_TABLES_MISS = 3
1045 OFPTFPT_WRITE_ACTIONS = 4
1046 OFPTFPT_WRITE_ACTIONS_MISS = 5
1047 OFPTFPT_APPLY_ACTIONS = 6
1048 OFPTFPT_APPLY_ACTIONS_MISS = 7
1050 OFPTFPT_WILDCARDS = 10
1051 OFPTFPT_WRITE_SETFIELD = 12
1052 OFPTFPT_WRITE_SETFIELD_MISS = 13
1053 OFPTFPT_APPLY_SETFIELD = 14
1054 OFPTFPT_APPLY_SETFIELD_MISS = 15
1055 OFPTFPT_TABLE_SYNC_FROM = 16
1056 OFPTFPT_EXPERIMENTER = 0xFFFE
1057 OFPTFPT_EXPERIMENTER_MISS = 0xFFFF
1059 # struct ofp_instruction_id
1060 OFP_INSTRUCTION_ID_PACK_STR = '!HH'
1061 OFP_INSTRUCTION_ID_SIZE = 4
1062 assert calcsize(OFP_INSTRUCTION_ID_PACK_STR) == OFP_INSTRUCTION_ID_SIZE
1064 # struct ofp_table_feature_prop_instructions
1065 OFP_TABLE_FEATURE_PROP_INSTRUCTIONS_PACK_STR = '!HH'
1066 OFP_TABLE_FEATURE_PROP_INSTRUCTIONS_SIZE = 4
1067 assert (calcsize(OFP_TABLE_FEATURE_PROP_INSTRUCTIONS_PACK_STR) ==
1068 OFP_TABLE_FEATURE_PROP_INSTRUCTIONS_SIZE)
1070 # struct ofp_table_feature_prop_actions
1071 OFP_TABLE_FEATURE_PROP_ACTIONS_PACK_STR = '!HH'
1072 OFP_TABLE_FEATURE_PROP_ACTIONS_SIZE = 4
1073 assert (calcsize(OFP_TABLE_FEATURE_PROP_ACTIONS_PACK_STR) ==
1074 OFP_TABLE_FEATURE_PROP_ACTIONS_SIZE)
1076 # struct ofp_table_feature_prop_oxm
1077 OFP_TABLE_FEATURE_PROP_OXM_PACK_STR = '!HH'
1078 OFP_TABLE_FEATURE_PROP_OXM_SIZE = 4
1079 assert (calcsize(OFP_TABLE_FEATURE_PROP_OXM_PACK_STR) ==
1080 OFP_TABLE_FEATURE_PROP_OXM_SIZE)
1082 # struct ofp_table_feature_prop_experimenter
1083 OFP_TABLE_FEATURE_PROP_EXPERIMENTER_PACK_STR = '!HHII'
1084 OFP_TABLE_FEATURE_PROP_EXPERIMENTER_SIZE = 12
1085 assert (calcsize(OFP_TABLE_FEATURE_PROP_EXPERIMENTER_PACK_STR) ==
1086 OFP_TABLE_FEATURE_PROP_EXPERIMENTER_SIZE)
1089 # struct ofp_table_features
1090 OFP_MAX_TABLE_NAME_LEN = 32
1091 OFP_MAX_TABLE_NAME_LEN_STR = str(OFP_MAX_TABLE_NAME_LEN)
1092 OFP_TABLE_FEATURES_PACK_STR = '!HB5x' + OFP_MAX_TABLE_NAME_LEN_STR + \
1094 OFP_TABLE_FEATURES_SIZE = 64
1095 assert (calcsize(OFP_TABLE_FEATURES_PACK_STR) ==
1096 OFP_TABLE_FEATURES_SIZE)
1098 # struct ofp_table_stats
1099 OFP_TABLE_STATS_PACK_STR = '!B3xIQQ'
1100 OFP_TABLE_STATS_SIZE = 24
1101 assert calcsize(OFP_TABLE_STATS_PACK_STR) == OFP_TABLE_STATS_SIZE
1103 # struct ofp_table_desc
1104 _OFP_TABLE_DESC_PACK_STR = 'HBxI'
1105 OFP_TABLE_DESC_PACK_STR = '!' + _OFP_TABLE_DESC_PACK_STR
1106 OFP_TABLE_DESC_SIZE = 8
1107 assert calcsize(OFP_TABLE_DESC_PACK_STR) == OFP_TABLE_DESC_SIZE
1109 # struct ofp_port_stats_request
1110 OFP_PORT_STATS_REQUEST_PACK_STR = '!I4x'
1111 OFP_PORT_STATS_REQUEST_SIZE = 8
1112 assert (calcsize(OFP_PORT_STATS_REQUEST_PACK_STR) ==
1113 OFP_PORT_STATS_REQUEST_SIZE)
1115 # enum ofp_port_stats_prop_type
1116 OFPPSPT_ETHERNET = 0 # Ethernet property.
1117 OFPPSPT_OPTICAL = 1 # Optical property.
1118 OFPPSPT_EXPERIMENTER = 0xFFFF # Experimenter property.
1120 # struct ofp_port_stats_prop_ethernet
1121 OFP_PORT_STATS_PROP_ETHERNET_PACK_STR = '!HH4xQQQQ'
1122 OFP_PORT_STATS_PROP_ETHERNET_SIZE = 40
1123 assert (calcsize(OFP_PORT_STATS_PROP_ETHERNET_PACK_STR) ==
1124 OFP_PORT_STATS_PROP_ETHERNET_SIZE)
1126 # struct ofp_port_stats_prop_optical
1127 OFP_PORT_STATS_PROP_OPTICAL_PACK_STR = '!HH4xIIIIIIIHHHH'
1128 OFP_PORT_STATS_PROP_OPTICAL_SIZE = 44
1129 assert (calcsize(OFP_PORT_STATS_PROP_OPTICAL_PACK_STR) ==
1130 OFP_PORT_STATS_PROP_OPTICAL_SIZE)
1132 # enum ofp_port_stats_optical_flags
1133 OFPOSF_RX_TUNE = 1 << 0 # Receiver tune info valid
1134 OFPOSF_TX_TUNE = 1 << 1 # Transmit tune info valid
1135 OFPOSF_TX_PWR = 1 << 2 # TX Power is valid
1136 OFPOSF_RX_PWR = 1 << 4 # RX power is valid
1137 OFPOSF_TX_BIAS = 1 << 5 # Transmit bias is valid
1138 OFPOSF_TX_TEMP = 1 << 6 # TX Temp is valid
1140 # struct ofp_port_stats_prop_experimenter
1141 OFP_PORT_STATS_PROP_EXPERIMENTER_PACK_STR = '!HHII'
1142 OFP_PORT_STATS_PROP_EXPERIMENTER_SIZE = 12
1143 assert (calcsize(OFP_PORT_STATS_PROP_EXPERIMENTER_PACK_STR) ==
1144 OFP_PORT_STATS_PROP_EXPERIMENTER_SIZE)
1146 # struct ofp_port_stats
1147 OFP_PORT_STATS_PACK_STR = '!H2xIIIQQQQQQQQ'
1148 OFP_PORT_STATS_SIZE = 80
1149 assert calcsize(OFP_PORT_STATS_PACK_STR) == OFP_PORT_STATS_SIZE
1151 # struct ofp_group_stats_request
1152 OFP_GROUP_STATS_REQUEST_PACK_STR = '!I4x'
1153 OFP_GROUP_STATS_REQUEST_SIZE = 8
1154 assert (calcsize(OFP_GROUP_STATS_REQUEST_PACK_STR) ==
1155 OFP_GROUP_STATS_REQUEST_SIZE)
1157 # struct ofp_bucket_counter
1158 OFP_BUCKET_COUNTER_PACK_STR = '!QQ'
1159 OFP_BUCKET_COUNTER_SIZE = 16
1160 assert calcsize(OFP_BUCKET_COUNTER_PACK_STR) == OFP_BUCKET_COUNTER_SIZE
1162 # struct ofp_group_stats
1163 OFP_GROUP_STATS_PACK_STR = '!H2xII4xQQII'
1164 OFP_GROUP_STATS_SIZE = 40
1165 assert calcsize(OFP_GROUP_STATS_PACK_STR) == OFP_GROUP_STATS_SIZE
1167 # struct ofp_group_desc
1168 OFP_GROUP_DESC_PACK_STR = '!HBxI'
1169 OFP_GROUP_DESC_SIZE = 8
1170 assert calcsize(OFP_GROUP_DESC_PACK_STR) == OFP_GROUP_DESC_SIZE
1172 # struct ofp_group_desc_stats
1173 # Backward compatibility with 1.3.1 - avoid breaking the API.
1174 OFP_GROUP_DESC_STATS_PACK_STR = OFP_GROUP_DESC_PACK_STR
1175 OFP_GROUP_DESC_STATS_SIZE = OFP_GROUP_DESC_SIZE
1176 assert calcsize(OFP_GROUP_DESC_STATS_PACK_STR) == OFP_GROUP_DESC_STATS_SIZE
1178 # enum ofp_group_capabilities
1179 OFPGFC_SELECT_WEIGHT = 1 << 0 # Support weight for select groups.
1180 OFPGFC_SELECT_LIVENESS = 1 << 1 # Support liveness for select groups.
1181 OFPGFC_CHAINING = 1 << 2 # Support chaining groups.
1182 OFPGFC_CHAINING_CHECKS = 1 << 3 # Check chaining for loops and delete
1184 # struct ofp_group_features
1185 OFP_GROUP_FEATURES_PACK_STR = '!II4I4I'
1186 OFP_GROUP_FEATURES_SIZE = 40
1187 assert calcsize(OFP_GROUP_FEATURES_PACK_STR) == OFP_GROUP_FEATURES_SIZE
1189 # struct ofp_meter_multipart_request
1190 OFP_METER_MULTIPART_REQUEST_PACK_STR = '!I4x'
1191 OFP_METER_MULTIPART_REQUEST_SIZE = 8
1192 assert (calcsize(OFP_METER_MULTIPART_REQUEST_PACK_STR) ==
1193 OFP_METER_MULTIPART_REQUEST_SIZE)
1195 # struct ofp_meter_stats
1196 OFP_METER_STATS_PACK_STR = '!IH6xIQQII'
1197 OFP_METER_STATS_SIZE = 40
1198 assert calcsize(OFP_METER_STATS_PACK_STR) == OFP_METER_STATS_SIZE
1200 # struct ofp_meter_band_stats
1201 OFP_METER_BAND_STATS_PACK_STR = '!QQ'
1202 OFP_METER_BAND_STATS_SIZE = 16
1203 assert (calcsize(OFP_METER_BAND_STATS_PACK_STR) ==
1204 OFP_METER_BAND_STATS_SIZE)
1206 # struct ofp_meter_config
1207 OFP_METER_CONFIG_PACK_STR = '!HHI'
1208 OFP_METER_CONFIG_SIZE = 8
1209 assert calcsize(OFP_METER_CONFIG_PACK_STR) == OFP_METER_CONFIG_SIZE
1211 # struct ofp_meter_features
1212 OFP_METER_FEATURES_PACK_STR = '!IIIBB2x'
1213 OFP_METER_FEATURES_SIZE = 16
1214 assert (calcsize(OFP_METER_FEATURES_PACK_STR) ==
1215 OFP_METER_FEATURES_SIZE)
1217 # All ones is used to indicate all queues in a port (for stats retrieval).
1218 OFPQ_ALL = 0xffffffff
1220 # Min rate > 1000 means not configured.
1221 OFPQ_MIN_RATE_UNCFG = 0xffff
1223 # Max rate > 1000 means not configured.
1224 OFPQ_MAX_RATE_UNCFG = 0xffff
1226 # enum ofp_queue_desc_prop_type
1227 OFPQDPT_MIN_RATE = 1 # Minimum datarate guaranteed.
1228 OFPQDPT_MAX_RATE = 2 # Maximum datarate.
1229 OFPQDPT_EXPERIMENTER = 0xffff # Experimenter defined property.
1231 # struct ofp_queue_desc_prop_min_rate
1232 OFP_QUEUE_DESC_PROP_MIN_RATE_PACK_STR = '!HHH2x'
1233 OFP_QUEUE_DESC_PROP_MIN_RATE_SIZE = 8
1234 assert (calcsize(OFP_QUEUE_DESC_PROP_MIN_RATE_PACK_STR) ==
1235 OFP_QUEUE_DESC_PROP_MIN_RATE_SIZE)
1237 # ofp_queue_desc_prop_max_rate
1238 OFP_QUEUE_DESC_PROP_MAX_RATE_PACK_STR = '!HHH2x'
1239 OFP_QUEUE_DESC_PROP_MAX_RATE_SIZE = 8
1240 assert (calcsize(OFP_QUEUE_DESC_PROP_MAX_RATE_PACK_STR) ==
1241 OFP_QUEUE_DESC_PROP_MAX_RATE_SIZE)
1243 # struct ofp_queue_desc_prop_experimenter
1244 OFP_QUEUE_DESC_PROP_EXPERIMENTER_PACK_STR = '!HHII'
1245 OFP_QUEUE_DESC_PROP_EXPERIMENTER_SIZE = 12
1246 assert (calcsize(OFP_QUEUE_DESC_PROP_EXPERIMENTER_PACK_STR) ==
1247 OFP_QUEUE_DESC_PROP_EXPERIMENTER_SIZE)
1249 # struct ofp_queue_desc_request
1250 OFP_QUEUE_DESC_REQUEST_PACK_STR = '!II'
1251 OFP_QUEUE_DESC_REQUEST_SIZE = 8
1252 assert (calcsize(OFP_QUEUE_DESC_REQUEST_PACK_STR) ==
1253 OFP_QUEUE_DESC_REQUEST_SIZE)
1255 # struct ofp_queue_desc
1256 OFP_QUEUE_DESC_PACK_STR = '!IIH6x'
1257 OFP_QUEUE_DESC_SIZE = 16
1258 assert calcsize(OFP_QUEUE_DESC_PACK_STR) == OFP_QUEUE_DESC_SIZE
1260 # struct ofp_queue_stats_request
1261 OFP_QUEUE_STATS_REQUEST_PACK_STR = '!II'
1262 OFP_QUEUE_STATS_REQUEST_SIZE = 8
1263 assert (calcsize(OFP_QUEUE_STATS_REQUEST_PACK_STR) ==
1264 OFP_QUEUE_STATS_REQUEST_SIZE)
1266 # enum ofp_queue_stats_prop_type
1267 OFPQSPT_EXPERIMENTER = 0xffff # Experimenter defined property.
1269 # struct ofp_queue_stats_prop_experimenter
1270 OFP_QUEUE_STATS_PROP_EXPERIMENTER_PACK_STR = '!HHII'
1271 OFP_QUEUE_STATS_PROP_EXPERIMENTER_SIZE = 12
1272 assert (calcsize(OFP_QUEUE_STATS_PROP_EXPERIMENTER_PACK_STR) ==
1273 OFP_QUEUE_STATS_PROP_EXPERIMENTER_SIZE)
1275 # struct ofp_queue_stats
1276 OFP_QUEUE_STATS_PACK_STR = '!H6xIIQQQII'
1277 OFP_QUEUE_STATS_SIZE = 48
1278 assert calcsize(OFP_QUEUE_STATS_PACK_STR) == OFP_QUEUE_STATS_SIZE
1280 # struct ofp_flow_monitor_request
1281 _OFP_FLOW_MONITOR_REQUEST_0_PACK_STR = 'IIIHBB'
1282 OFP_FLOW_MONITOR_REQUEST_0_PACK_STR = ('!' +
1283 _OFP_FLOW_MONITOR_REQUEST_0_PACK_STR)
1284 OFP_FLOW_MONITOR_REQUEST_0_SIZE = 16
1285 OFP_FLOW_MONITOR_REQUEST_PACK_STR = (OFP_FLOW_MONITOR_REQUEST_0_PACK_STR +
1286 _OFP_MATCH_PACK_STR)
1287 OFP_FLOW_MONITOR_REQUEST_SIZE = 24
1288 assert (calcsize(OFP_FLOW_MONITOR_REQUEST_PACK_STR) ==
1289 OFP_FLOW_MONITOR_REQUEST_SIZE)
1291 # enum ofp_flow_monitor_command
1292 OFPFMC_ADD = 0 # New flow monitor.
1293 OFPFMC_MODIFY = 1 # Modify existing flow monitor.
1294 OFPFMC_DELETE = 2 # Delete/cancel existing flow monitor.
1296 # enum ofp_flow_monitor_flags
1297 # When to send updates.
1298 OFPFMF_INITIAL = 1 << 0 # Initially matching flows.
1299 OFPFMF_ADD = 1 << 1 # New matching flows as they are added.
1300 OFPFMF_REMOVED = 1 << 2 # Old matching flows as they are removed.
1301 OFPFMF_MODIFY = 1 << 3 # Matching flows as they are changed.
1302 # What to include in updates.
1303 OFPFMF_INSTRUCTIONS = 1 << 4 # If set, instructions are included.
1304 OFPFMF_NO_ABBREV = 1 << 5 # If set, include own changes in full.
1305 OFPFMF_ONLY_OWN = 1 << 6 # If set, don't include other controllers.
1307 # struct ofp_flow_update_header
1308 OFP_FLOW_UPDATE_HEADER_PACK_STR = '!HH'
1309 OFP_FLOW_UPDATE_HEADER_SIZE = 4
1310 assert (calcsize(OFP_FLOW_UPDATE_HEADER_PACK_STR) ==
1311 OFP_FLOW_UPDATE_HEADER_SIZE)
1313 # enum ofp_flow_update_event
1314 # struct ofp_flow_update_full.
1315 OFPFME_INITIAL = 0 # Flow present when flow monitor created.
1316 OFPFME_ADDED = 1 # Flow was added.
1317 OFPFME_REMOVED = 2 # Flow was removed.
1318 OFPFME_MODIFIED = 3 # Flow instructions were changed.
1319 # struct ofp_flow_update_abbrev.
1320 OFPFME_ABBREV = 4 # Abbreviated reply.
1321 # struct ofp_flow_update_header.
1322 OFPFME_PAUSED = 5 # Monitoring paused (out of buffer space).
1323 OFPFME_RESUMED = 6 # Monitoring resumed.
1325 # struct ofp_flow_update_full
1326 _OFP_FLOW_UPDATE_FULL_0_PACK_STR = 'HHBBHHH4xQ'
1327 OFP_FLOW_UPDATE_FULL_0_PACK_STR = '!' + _OFP_FLOW_UPDATE_FULL_0_PACK_STR
1328 OFP_FLOW_UPDATE_FULL_0_SIZE = 24
1329 OFP_FLOW_UPDATE_FULL_PACK_STR = (OFP_FLOW_UPDATE_FULL_0_PACK_STR +
1330 _OFP_MATCH_PACK_STR)
1331 OFP_FLOW_UPDATE_FULL_SIZE = 32
1332 assert (calcsize(OFP_FLOW_UPDATE_FULL_PACK_STR) ==
1333 OFP_FLOW_UPDATE_FULL_SIZE)
1335 # struct ofp_flow_update_abbrev
1336 OFP_FLOW_UPDATE_ABBREV_PACK_STR = '!HHI'
1337 OFP_FLOW_UPDATE_ABBREV_SIZE = 8
1338 assert (calcsize(OFP_FLOW_UPDATE_ABBREV_PACK_STR) ==
1339 OFP_FLOW_UPDATE_ABBREV_SIZE)
1341 # struct ofp_flow_update_paused
1342 OFP_FLOW_UPDATE_PAUSED_PACK_STR = '!HH4x'
1343 OFP_FLOW_UPDATE_PAUSED_SIZE = 8
1344 assert (calcsize(OFP_FLOW_UPDATE_PAUSED_PACK_STR) ==
1345 OFP_FLOW_UPDATE_PAUSED_SIZE)
1347 # struct ofp_experimenter_multipart_header
1348 OFP_EXPERIMENTER_MULTIPART_HEADER_PACK_STR = '!II'
1349 OFP_EXPERIMENTER_MULTIPART_HEADER_SIZE = 8
1350 assert (calcsize(OFP_EXPERIMENTER_MULTIPART_HEADER_PACK_STR) ==
1351 OFP_EXPERIMENTER_MULTIPART_HEADER_SIZE)
1353 # struct ofp_experimenter_structure
1354 OFP_EXPERIMENTER_STRUCTURE_PACK_STR = '!II'
1355 OFP_EXPERIMENTER_STRUCTURE_SIZE = 8
1356 assert (calcsize(OFP_EXPERIMENTER_STRUCTURE_PACK_STR) ==
1357 OFP_EXPERIMENTER_STRUCTURE_SIZE)
1359 # struct ofp_error_experimenter_msg
1360 OFP_ERROR_EXPERIMENTER_MSG_PACK_STR = '!HHI'
1361 OFP_ERROR_EXPERIMENTER_MSG_SIZE = 16
1362 assert (calcsize(OFP_ERROR_EXPERIMENTER_MSG_PACK_STR) +
1363 OFP_HEADER_SIZE) == OFP_ERROR_EXPERIMENTER_MSG_SIZE
1365 # enum ofp_controller_role
1366 OFPCR_ROLE_NOCHANGE = 0 # Don't change current role.
1367 OFPCR_ROLE_EQUAL = 1 # Default role, full access.
1368 OFPCR_ROLE_MASTER = 2 # Full access, at most one master.
1369 OFPCR_ROLE_SLAVE = 3 # Read-only access.
1371 # struct ofp_role_request
1372 OFP_ROLE_REQUEST_PACK_STR = '!I4xQ'
1373 OFP_ROLE_REQUEST_SIZE = 24
1374 assert (calcsize(OFP_ROLE_REQUEST_PACK_STR) + OFP_HEADER_SIZE ==
1375 OFP_ROLE_REQUEST_SIZE)
1377 # enum ofp_role_prop_type
1378 OFPRPT_EXPERIMENTER = 0xFFFF # Experimenter property.
1380 # struct ofp_role_prop_experimenter
1381 OFP_ROLE_PROP_EXPERIMENTER_PACK_STR = '!HHII'
1382 OFP_ROLE_PROP_EXPERIMENTER_SIZE = 12
1383 assert (calcsize(OFP_ROLE_PROP_EXPERIMENTER_PACK_STR) ==
1384 OFP_ROLE_PROP_EXPERIMENTER_SIZE)
1386 # enum ofp_controller_role_reason
1387 OFPCRR_MASTER_REQUEST = 0 # Another controller asked to be master.
1388 OFPCRR_CONFIG = 1 # Configuration changed on the switch.
1389 OFPCRR_EXPERIMENTER = 2 # Experimenter data changed.
1391 # struct ofp_role_status
1392 OFP_ROLE_STATUS_PACK_STR = '!IB3xQ'
1393 OFP_ROLE_STATUS_SIZE = 24
1394 assert (calcsize(OFP_ROLE_STATUS_PACK_STR) + OFP_HEADER_SIZE ==
1395 OFP_ROLE_STATUS_SIZE)
1397 # enum ofp_async_config_prop_type
1398 OFPACPT_PACKET_IN_SLAVE = 0 # Packet-in mask for slave.
1399 OFPACPT_PACKET_IN_MASTER = 1 # Packet-in mask for master.
1400 OFPACPT_PORT_STATUS_SLAVE = 2 # Port-status mask for slave.
1401 OFPACPT_PORT_STATUS_MASTER = 3 # Port-status mask for master.
1402 OFPACPT_FLOW_REMOVED_SLAVE = 4 # Flow removed mask for slave.
1403 OFPACPT_FLOW_REMOVED_MASTER = 5 # Flow removed mask for master.
1404 OFPACPT_ROLE_STATUS_SLAVE = 6 # Role status mask for slave.
1405 OFPACPT_ROLE_STATUS_MASTER = 7 # Role status mask for master.
1406 OFPACPT_TABLE_STATUS_SLAVE = 8 # Table status mask for slave.
1407 OFPACPT_TABLE_STATUS_MASTER = 9 # Table status mask for master.
1408 OFPACPT_REQUESTFORWARD_SLAVE = 10 # RequestForward mask for slave.
1409 OFPACPT_REQUESTFORWARD_MASTER = 11 # RequestForward mask for master.
1410 OFPTFPT_EXPERIMENTER_SLAVE = 0xFFFE # Experimenter for slave (depracated).
1411 OFPTFPT_EXPERIMENTER_MASTER = 0xFFFF # Experimenter for master (depracated).
1412 # New or updated Ryu applications shall use
1413 # OFPACPT_EXPERIMENTER_SLAVE and OFPACPT_EXPERIMENTER_MASTER.
1414 # The variable name is a typo of in specifications before v1.5.0.
1415 OFPACPT_EXPERIMENTER_SLAVE = 0xFFFE # Experimenter for slave.
1416 OFPACPT_EXPERIMENTER_MASTER = 0xFFFF # Experimenter for master.
1417 # Backporting from ofproto_v1_5 for consistency with
1420 # struct ofp_async_config_prop_reasons
1421 OFP_ASYNC_CONFIG_PROP_REASONS_PACK_STR = '!HHI'
1422 OFP_ASYNC_CONFIG_PROP_REASONS_SIZE = 8
1423 assert (calcsize(OFP_ASYNC_CONFIG_PROP_REASONS_PACK_STR) ==
1424 OFP_ASYNC_CONFIG_PROP_REASONS_SIZE)
1426 # struct ofp_async_config_prop_experimenter
1427 OFP_ASYNC_CONFIG_PROP_EXPERIMENTER_PACK_STR = '!HHII'
1428 OFP_ASYNC_CONFIG_PROP_EXPERIMENTER_SIZE = 12
1429 assert (calcsize(OFP_ASYNC_CONFIG_PROP_EXPERIMENTER_PACK_STR) ==
1430 OFP_ASYNC_CONFIG_PROP_EXPERIMENTER_SIZE)
1432 # enum ofp_table_reason
1433 OFPTR_VACANCY_DOWN = 3 # Vacancy down threshold event.
1434 OFPTR_VACANCY_UP = 4 # Vacancy up threshold event.
1436 # struct ofp_table_status
1437 _OFP_TABLE_STATUS_0_PACK_STR = 'B7x'
1438 OFP_TABLE_STATUS_0_PACK_STR = '!' + _OFP_TABLE_STATUS_0_PACK_STR
1439 OFP_TABLE_STATUS_0_SIZE = 16
1440 OFP_TABLE_STATUS_PACK_STR = (OFP_TABLE_STATUS_0_PACK_STR +
1441 _OFP_TABLE_DESC_PACK_STR)
1442 OFP_TABLE_STATUS_SIZE = 24
1443 assert (calcsize(OFP_TABLE_STATUS_PACK_STR) + OFP_HEADER_SIZE ==
1444 OFP_TABLE_STATUS_SIZE)
1446 # enum ofp_requestforward_reason
1447 OFPRFR_GROUP_MOD = 0 # Forward group mod requests.
1448 OFPRFR_METER_MOD = 1 # Forward meter mod requests.
1450 # enum ofp_bundle_prop_type
1451 OFPBPT_EXPERIMENTER = 0xFFFF # Experimenter property.
1453 # struct ofp_bundle_prop_experimenter
1454 OFP_BUNDLE_PROP_EXPERIMENTER_PACK_STR = '!HHII'
1455 OFP_BUNDLE_PROP_EXPERIMENTER_SIZE = 12
1456 assert (calcsize(OFP_BUNDLE_PROP_EXPERIMENTER_PACK_STR) ==
1457 OFP_BUNDLE_PROP_EXPERIMENTER_SIZE)
1459 # enum ofp_bundle_ctrl_type
1460 OFPBCT_OPEN_REQUEST = 0
1461 OFPBCT_OPEN_REPLY = 1
1462 OFPBCT_CLOSE_REQUEST = 2
1463 OFPBCT_CLOSE_REPLY = 3
1464 OFPBCT_COMMIT_REQUEST = 4
1465 OFPBCT_COMMIT_REPLY = 5
1466 OFPBCT_DISCARD_REQUEST = 6
1467 OFPBCT_DISCARD_REPLY = 7
1469 # enum ofp_bundle_flags
1470 OFPBF_ATOMIC = 1 << 0 # Execute atomically.
1471 OFPBF_ORDERED = 1 << 1 # Execute in specified order.
1473 # struct ofp_bundle_ctrl_msg
1474 OFP_BUNDLE_CTRL_MSG_PACK_STR = '!IHH'
1475 OFP_BUNDLE_CTRL_MSG_SIZE = 16
1476 assert (calcsize(OFP_BUNDLE_CTRL_MSG_PACK_STR) + OFP_HEADER_SIZE ==
1477 OFP_BUNDLE_CTRL_MSG_SIZE)
1479 # struct ofp_bundle_add_msg
1480 _OFP_BUNDLE_ADD_MSG_0_PACK_STR = 'I2xH'
1481 OFP_BUNDLE_ADD_MSG_0_PACK_STR = '!' + _OFP_BUNDLE_ADD_MSG_0_PACK_STR
1482 OFP_BUNDLE_ADD_MSG_PACK_STR = (OFP_BUNDLE_ADD_MSG_0_PACK_STR +
1483 _OFP_HEADER_PACK_STR)
1484 OFP_BUNDLE_ADD_MSG_SIZE = 24
1485 assert (calcsize(OFP_BUNDLE_ADD_MSG_PACK_STR) + OFP_HEADER_SIZE ==
1486 OFP_BUNDLE_ADD_MSG_SIZE)
1488 # Note: struct ofp_prop_experimenter is specific to this implementation.
1489 # It does not have a corresponding structure in the specification.
1490 # This structure defines common structure for ofp_*_prop_experimenter.
1491 # struct ofp_prop_experimenter
1492 OFP_PROP_EXPERIMENTER_PACK_STR = '!HHII'
1493 OFP_PROP_EXPERIMENTER_SIZE = 12
1494 assert (calcsize(OFP_PROP_EXPERIMENTER_PACK_STR) ==
1495 OFP_PROP_EXPERIMENTER_SIZE)
1497 # generate utility methods
1498 ofproto_utils.generate(__name__)
1504 MAX_XID = 0xffffffff