]> git.proxmox.com Git - ovs.git/blob - include/openvswitch/ofp-msgs.h
ipfix: Add support for exporting ipfix statistics.
[ovs.git] / include / openvswitch / ofp-msgs.h
1 /*
2 * Copyright (c) 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
3 *
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:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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 implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef OPENVSWITCH_OFP_MSGS_H
18 #define OPENVSWITCH_OFP_MSGS_H 1
19
20 /* OpenFlow message headers abstraction.
21 *
22 * OpenFlow headers are unnecessarily complicated:
23 *
24 * - Some messages with the same meaning were renumbered between 1.0 and 1.1.
25 *
26 * - "Statistics" (aka multipart) messages have a different format from other
27 * messages.
28 *
29 * - The 1.0 header for statistics messages is an odd number of 32-bit words
30 * long, leaving 64-bit quantities in the body misaligned. The 1.1 header
31 * for statistics added a padding word to fix this misalignment, although
32 * many statistic message bodies did not change.
33 *
34 * - Vendor-defined messages have an additional header but no standard way to
35 * distinguish individual types of message within a given vendor.
36 *
37 * This file attempts to abstract out the differences between the various forms
38 * of headers.
39 */
40
41 #include "openvswitch/ofp-errors.h"
42 #include "openvswitch/types.h"
43 #include "util.h"
44
45 struct ovs_list;
46 \f
47 /* Raw identifiers for OpenFlow messages.
48 *
49 * Some OpenFlow messages with similar meanings have multiple variants across
50 * OpenFlow versions or vendor extensions. Each variant has a different
51 * OFPRAW_* enumeration constant. More specifically, if two messages have
52 * different types, different numbers, or different arguments, then they must
53 * have different OFPRAW_* values.
54 *
55 * The comments here must follow a stylized form because the "extract-ofp-msgs"
56 * program parses them at build time to generate data tables. The syntax of
57 * each comment is:
58 *
59 * type versions (number): arguments.
60 *
61 * where the syntax of each part is:
62 *
63 * - type: One of the following:
64 *
65 * * OFPT: standard OpenFlow message.
66 * * OFPST: standard OpenFlow statistics or multipart message.
67 * * NXT: Nicira extension message.
68 * * NXST: Nicira extension statistics or multipart message.
69 * * ONFT: Open Networking Foundation extension message.
70 * * ONFST: Open Networking Foundation multipart message.
71 *
72 * As new vendors implement extensions it will make sense to expand the
73 * dictionary of possible types.
74 *
75 * - versions: The OpenFlow version or versions in which this message is
76 * supported, e.g. "1.0" or "1.1" or "1.0+".
77 *
78 * - number:
79 * For OFPT, the 'type' in struct ofp_header.
80 * For OFPST, the 'type' in struct ofp_stats_msg or ofp11_stats_msg.
81 * For NXT or ONFT, the 'subtype' in struct ofp_vendor_header.
82 * For NXST or ONFST, the 'subtype' in an appropriate vendor stats
83 * struct.
84 *
85 * - arguments: The types of data that follow the OpenFlow headers (the
86 * message "body"). This can be "void" if the message has no body.
87 * Otherwise, it should be a comma-separated sequence of C types. The
88 * last type in the sequence can end with [] if the body ends in a
89 * variable-length sequence.
90 *
91 * The arguments are used to validate the lengths of messages when a
92 * header is parsed. Any message whose length isn't valid as a length of
93 * the specified types will be rejected with OFPERR_OFPBRC_BAD_LEN.
94 *
95 * A few OpenFlow messages, such as OFPT_PACKET_IN, intentionally end with
96 * only part of a structure, up to some specified member. The syntax "up
97 * to <member>" indicates this, e.g. "struct ofp11_packet_in up to data".
98 */
99 enum ofpraw {
100 /* Immutable standard messages.
101 *
102 * The OpenFlow standard promises to preserve these messages and their numbers
103 * in future versions, so we mark them as <all>, which covers every OpenFlow
104 * version numbered 0x01...0xff, rather than as OF1.0+, which covers only
105 * OpenFlow versions that we otherwise implement.
106 *
107 * Without <all> here, then we would fail to decode "hello" messages that
108 * announce a version higher than we understand, even though there still could
109 * be a version in common with the peer that we do understand. The <all>
110 * keyword is less useful for the other messages, because our OpenFlow channels
111 * accept only OpenFlow messages with a previously negotiated version.
112 */
113
114 /* OFPT <all> (0): uint8_t[]. */
115 OFPRAW_OFPT_HELLO,
116
117 /* OFPT <all> (1): struct ofp_error_msg, uint8_t[]. */
118 OFPRAW_OFPT_ERROR,
119
120 /* OFPT <all> (2): uint8_t[]. */
121 OFPRAW_OFPT_ECHO_REQUEST,
122
123 /* OFPT <all> (3): uint8_t[]. */
124 OFPRAW_OFPT_ECHO_REPLY,
125
126 /* Other standard messages.
127 *
128 * The meanings of these messages can (and often do) change from one version
129 * of OpenFlow to another. */
130
131 /* OFPT 1.0+ (5): void. */
132 OFPRAW_OFPT_FEATURES_REQUEST,
133
134 /* OFPT 1.0 (6): struct ofp_switch_features, struct ofp10_phy_port[]. */
135 OFPRAW_OFPT10_FEATURES_REPLY,
136 /* OFPT 1.1-1.2 (6): struct ofp_switch_features, struct ofp11_port[]. */
137 OFPRAW_OFPT11_FEATURES_REPLY,
138 /* OFPT 1.3+ (6): struct ofp_switch_features. */
139 OFPRAW_OFPT13_FEATURES_REPLY,
140
141 /* OFPT 1.0+ (7): void. */
142 OFPRAW_OFPT_GET_CONFIG_REQUEST,
143
144 /* OFPT 1.0+ (8): struct ofp_switch_config. */
145 OFPRAW_OFPT_GET_CONFIG_REPLY,
146
147 /* OFPT 1.0+ (9): struct ofp_switch_config. */
148 OFPRAW_OFPT_SET_CONFIG,
149
150 /* OFPT 1.0 (10): struct ofp10_packet_in up to data, uint8_t[]. */
151 OFPRAW_OFPT10_PACKET_IN,
152 /* OFPT 1.1 (10): struct ofp11_packet_in, uint8_t[]. */
153 OFPRAW_OFPT11_PACKET_IN,
154 /* OFPT 1.2 (10): struct ofp12_packet_in, uint8_t[]. */
155 OFPRAW_OFPT12_PACKET_IN,
156 /* OFPT 1.3+ (10): struct ofp12_packet_in, ovs_be64, uint8_t[]. */
157 OFPRAW_OFPT13_PACKET_IN,
158 /* NXT 1.0+ (17): struct nx_packet_in, uint8_t[]. */
159 OFPRAW_NXT_PACKET_IN,
160 /* NXT 1.0+ (30): uint8_t[8][]. */
161 OFPRAW_NXT_PACKET_IN2,
162
163 /* OFPT 1.0 (11): struct ofp10_flow_removed. */
164 OFPRAW_OFPT10_FLOW_REMOVED,
165 /* OFPT 1.1+ (11): struct ofp11_flow_removed, uint8_t[8][]. */
166 OFPRAW_OFPT11_FLOW_REMOVED,
167 /* NXT 1.0+ (14): struct nx_flow_removed, uint8_t[8][]. */
168 OFPRAW_NXT_FLOW_REMOVED,
169
170 /* OFPT 1.0 (12): struct ofp_port_status, struct ofp10_phy_port. */
171 OFPRAW_OFPT10_PORT_STATUS,
172 /* OFPT 1.1-1.3 (12): struct ofp_port_status, struct ofp11_port. */
173 OFPRAW_OFPT11_PORT_STATUS,
174 /* OFPT 1.4+ (12): struct ofp_port_status, struct ofp14_port, uint8_t[8][]. */
175 OFPRAW_OFPT14_PORT_STATUS,
176
177 /* OFPT 1.0 (13): struct ofp10_packet_out, uint8_t[]. */
178 OFPRAW_OFPT10_PACKET_OUT,
179 /* OFPT 1.1+ (13): struct ofp11_packet_out, uint8_t[]. */
180 OFPRAW_OFPT11_PACKET_OUT,
181
182 /* OFPT 1.0 (14): struct ofp10_flow_mod, uint8_t[8][]. */
183 OFPRAW_OFPT10_FLOW_MOD,
184 /* OFPT 1.1+ (14): struct ofp11_flow_mod, struct ofp11_instruction[]. */
185 OFPRAW_OFPT11_FLOW_MOD,
186 /* NXT 1.0+ (13): struct nx_flow_mod, uint8_t[8][]. */
187 OFPRAW_NXT_FLOW_MOD,
188
189 /* OFPT 1.1-1.4 (15): struct ofp11_group_mod, uint8_t[8][]. */
190 OFPRAW_OFPT11_GROUP_MOD,
191 /* OFPT 1.5+ (15): struct ofp15_group_mod, uint8_t[8][]. */
192 OFPRAW_OFPT15_GROUP_MOD,
193
194 /* OFPT 1.0 (15): struct ofp10_port_mod. */
195 OFPRAW_OFPT10_PORT_MOD,
196 /* OFPT 1.1-1.3 (16): struct ofp11_port_mod. */
197 OFPRAW_OFPT11_PORT_MOD,
198 /* OFPT 1.4+ (16): struct ofp14_port_mod, uint8_t[8][]. */
199 OFPRAW_OFPT14_PORT_MOD,
200
201 /* OFPT 1.1-1.3 (17): struct ofp11_table_mod. */
202 OFPRAW_OFPT11_TABLE_MOD,
203 /* OFPT 1.4+ (17): struct ofp14_table_mod, uint8_t[8][]. */
204 OFPRAW_OFPT14_TABLE_MOD,
205
206 /* OFPT 1.0 (18): void. */
207 OFPRAW_OFPT10_BARRIER_REQUEST,
208 /* OFPT 1.1+ (20): void. */
209 OFPRAW_OFPT11_BARRIER_REQUEST,
210
211 /* OFPT 1.0 (19): void. */
212 OFPRAW_OFPT10_BARRIER_REPLY,
213 /* OFPT 1.1+ (21): void. */
214 OFPRAW_OFPT11_BARRIER_REPLY,
215
216 /* OFPT 1.0 (20): struct ofp10_queue_get_config_request. */
217 OFPRAW_OFPT10_QUEUE_GET_CONFIG_REQUEST,
218 /* OFPT 1.1-1.3 (22): struct ofp11_queue_get_config_request. */
219 OFPRAW_OFPT11_QUEUE_GET_CONFIG_REQUEST,
220
221 /* OFPT 1.0 (21): struct ofp10_queue_get_config_reply, uint8_t[8][]. */
222 OFPRAW_OFPT10_QUEUE_GET_CONFIG_REPLY,
223 /* OFPT 1.1-1.3 (23): struct ofp11_queue_get_config_reply, uint8_t[8][]. */
224 OFPRAW_OFPT11_QUEUE_GET_CONFIG_REPLY,
225
226 /* OFPT 1.2+ (24): struct ofp12_role_request. */
227 OFPRAW_OFPT12_ROLE_REQUEST,
228 /* NXT 1.0+ (10): struct nx_role_request. */
229 OFPRAW_NXT_ROLE_REQUEST,
230
231 /* OFPT 1.2+ (25): struct ofp12_role_request. */
232 OFPRAW_OFPT12_ROLE_REPLY,
233 /* NXT 1.0+ (11): struct nx_role_request. */
234 OFPRAW_NXT_ROLE_REPLY,
235
236 /* OFPT 1.3 (26): void. */
237 OFPRAW_OFPT13_GET_ASYNC_REQUEST,
238 /* OFPT 1.4+ (26): void. */
239 OFPRAW_OFPT14_GET_ASYNC_REQUEST,
240 /* OFPT 1.3 (27): struct ofp13_async_config. */
241 OFPRAW_OFPT13_GET_ASYNC_REPLY,
242 /* OFPT 1.4+ (27): uint8_t[8][]. */
243 OFPRAW_OFPT14_GET_ASYNC_REPLY,
244 /* OFPT 1.3 (28): struct ofp13_async_config. */
245 OFPRAW_OFPT13_SET_ASYNC,
246 /* NXT 1.0+ (19): struct nx_async_config. */
247 OFPRAW_NXT_SET_ASYNC_CONFIG,
248 /* NXT 1.0-1.3 (27): uint8_t[8][]. */
249 OFPRAW_NXT_SET_ASYNC_CONFIG2,
250 /* OFPT 1.4+ (28): uint8_t[8][]. */
251 OFPRAW_OFPT14_SET_ASYNC,
252
253 /* OFPT 1.3+ (29): struct ofp13_meter_mod, uint8_t[8][]. */
254 OFPRAW_OFPT13_METER_MOD,
255
256 /* OFPT 1.4+ (30): struct ofp14_role_status, uint8_t[8][]. */
257 OFPRAW_OFPT14_ROLE_STATUS,
258
259 /* OFPT 1.4+ (31): struct ofp14_table_status, uint8_t[8][]. */
260 OFPRAW_OFPT14_TABLE_STATUS,
261
262 /* OFPT 1.4+ (32): struct ofp14_requestforward, uint8_t[8][]. */
263 OFPRAW_OFPT14_REQUESTFORWARD,
264
265 /* OFPT 1.4+ (33): struct ofp14_bundle_ctrl_msg, uint8_t[8][]. */
266 OFPRAW_OFPT14_BUNDLE_CONTROL,
267 /* ONFT 1.3 (2300): struct ofp14_bundle_ctrl_msg, uint8_t[8][]. */
268 OFPRAW_ONFT13_BUNDLE_CONTROL,
269
270 /* OFPT 1.4+ (34): struct ofp14_bundle_ctrl_msg, uint8_t[]. */
271 OFPRAW_OFPT14_BUNDLE_ADD_MESSAGE,
272 /* ONFT 1.3 (2301): struct ofp14_bundle_ctrl_msg, uint8_t[]. */
273 OFPRAW_ONFT13_BUNDLE_ADD_MESSAGE,
274
275 /* Standard statistics. */
276
277 /* OFPST 1.0+ (0): void. */
278 OFPRAW_OFPST_DESC_REQUEST,
279
280 /* OFPST 1.0+ (0): struct ofp_desc_stats. */
281 OFPRAW_OFPST_DESC_REPLY,
282
283 /* OFPST 1.0 (1): struct ofp10_flow_stats_request. */
284 OFPRAW_OFPST10_FLOW_REQUEST,
285 /* OFPST 1.1+ (1): struct ofp11_flow_stats_request, uint8_t[8][]. */
286 OFPRAW_OFPST11_FLOW_REQUEST,
287 /* NXST 1.0 (0): struct nx_flow_stats_request, uint8_t[8][]. */
288 OFPRAW_NXST_FLOW_REQUEST,
289
290 /* OFPST 1.0 (1): uint8_t[]. */
291 OFPRAW_OFPST10_FLOW_REPLY,
292 /* OFPST 1.1-1.2 (1): uint8_t[]. */
293 OFPRAW_OFPST11_FLOW_REPLY,
294 /* OFPST 1.3+ (1): uint8_t[]. */
295 OFPRAW_OFPST13_FLOW_REPLY,
296 /* NXST 1.0 (0): uint8_t[]. */
297 OFPRAW_NXST_FLOW_REPLY,
298
299 /* OFPST 1.0 (2): struct ofp10_flow_stats_request. */
300 OFPRAW_OFPST10_AGGREGATE_REQUEST,
301 /* OFPST 1.1+ (2): struct ofp11_flow_stats_request, uint8_t[8][]. */
302 OFPRAW_OFPST11_AGGREGATE_REQUEST,
303 /* NXST 1.0 (1): struct nx_flow_stats_request, uint8_t[8][]. */
304 OFPRAW_NXST_AGGREGATE_REQUEST,
305
306 /* OFPST 1.0+ (2): struct ofp_aggregate_stats_reply. */
307 OFPRAW_OFPST_AGGREGATE_REPLY,
308 /* NXST 1.0 (1): struct ofp_aggregate_stats_reply. */
309 OFPRAW_NXST_AGGREGATE_REPLY,
310
311 /* OFPST 1.0+ (3): void. */
312 OFPRAW_OFPST_TABLE_REQUEST,
313
314 /* OFPST 1.0 (3): struct ofp10_table_stats[]. */
315 OFPRAW_OFPST10_TABLE_REPLY,
316 /* OFPST 1.1 (3): struct ofp11_table_stats[]. */
317 OFPRAW_OFPST11_TABLE_REPLY,
318 /* OFPST 1.2 (3): struct ofp12_table_stats[]. */
319 OFPRAW_OFPST12_TABLE_REPLY,
320 /* OFPST 1.3+ (3): struct ofp13_table_stats[]. */
321 OFPRAW_OFPST13_TABLE_REPLY,
322
323 /* OFPST 1.0 (4): struct ofp10_port_stats_request. */
324 OFPRAW_OFPST10_PORT_REQUEST,
325 /* OFPST 1.1+ (4): struct ofp11_port_stats_request. */
326 OFPRAW_OFPST11_PORT_REQUEST,
327
328 /* OFPST 1.0 (4): struct ofp10_port_stats[]. */
329 OFPRAW_OFPST10_PORT_REPLY,
330 /* OFPST 1.1-1.2 (4): struct ofp11_port_stats[]. */
331 OFPRAW_OFPST11_PORT_REPLY,
332 /* OFPST 1.3 (4): struct ofp13_port_stats[]. */
333 OFPRAW_OFPST13_PORT_REPLY,
334 /* OFPST 1.4+ (4): uint8_t[8][]. */
335 OFPRAW_OFPST14_PORT_REPLY,
336
337 /* OFPST 1.0 (5): struct ofp10_queue_stats_request. */
338 OFPRAW_OFPST10_QUEUE_REQUEST,
339 /* OFPST 1.1+ (5): struct ofp11_queue_stats_request. */
340 OFPRAW_OFPST11_QUEUE_REQUEST,
341
342 /* OFPST 1.0 (5): struct ofp10_queue_stats[]. */
343 OFPRAW_OFPST10_QUEUE_REPLY,
344 /* OFPST 1.1-1.2 (5): struct ofp11_queue_stats[]. */
345 OFPRAW_OFPST11_QUEUE_REPLY,
346 /* OFPST 1.3 (5): struct ofp13_queue_stats[]. */
347 OFPRAW_OFPST13_QUEUE_REPLY,
348 /* OFPST 1.4+ (5): uint8_t[8][]. */
349 OFPRAW_OFPST14_QUEUE_REPLY,
350
351 /* OFPST 1.1+ (6): struct ofp11_group_stats_request. */
352 OFPRAW_OFPST11_GROUP_REQUEST,
353
354 /* OFPST 1.1-1.2 (6): uint8_t[8][]. */
355 OFPRAW_OFPST11_GROUP_REPLY,
356 /* OFPST 1.3+ (6): uint8_t[8][]. */
357 OFPRAW_OFPST13_GROUP_REPLY,
358
359 /* OFPST 1.1-1.4 (7): void. */
360 OFPRAW_OFPST11_GROUP_DESC_REQUEST,
361 /* OFPST 1.5+ (7): struct ofp15_group_desc_request. */
362 OFPRAW_OFPST15_GROUP_DESC_REQUEST,
363
364 /* OFPST 1.1+ (7): uint8_t[8][]. */
365 OFPRAW_OFPST11_GROUP_DESC_REPLY,
366
367 /* OFPST 1.2+ (8): void. */
368 OFPRAW_OFPST12_GROUP_FEATURES_REQUEST,
369
370 /* OFPST 1.2+ (8): struct ofp12_group_features_stats. */
371 OFPRAW_OFPST12_GROUP_FEATURES_REPLY,
372
373 /* OFPST 1.3+ (9): struct ofp13_meter_multipart_request. */
374 OFPRAW_OFPST13_METER_REQUEST,
375
376 /* OFPST 1.3+ (9): uint8_t[8][]. */
377 OFPRAW_OFPST13_METER_REPLY,
378
379 /* OFPST 1.3+ (10): struct ofp13_meter_multipart_request. */
380 OFPRAW_OFPST13_METER_CONFIG_REQUEST,
381
382 /* OFPST 1.3+ (10): uint8_t[8][]. */
383 OFPRAW_OFPST13_METER_CONFIG_REPLY,
384
385 /* OFPST 1.3+ (11): void. */
386 OFPRAW_OFPST13_METER_FEATURES_REQUEST,
387
388 /* OFPST 1.3+ (11): struct ofp13_meter_features. */
389 OFPRAW_OFPST13_METER_FEATURES_REPLY,
390
391 /* OFPST 1.3+ (12): void. */
392 OFPRAW_OFPST13_TABLE_FEATURES_REQUEST,
393
394 /* OFPST 1.3+ (12): struct ofp13_table_features, uint8_t[8][]. */
395 OFPRAW_OFPST13_TABLE_FEATURES_REPLY,
396
397 /* OFPST 1.4+ (14): void. */
398 OFPRAW_OFPST14_TABLE_DESC_REQUEST,
399
400 /* OFPST 1.4+ (14): struct ofp14_table_desc, uint8_t[8][]. */
401 OFPRAW_OFPST14_TABLE_DESC_REPLY,
402
403 /* OFPST 1.0-1.4 (13): void. */
404 OFPRAW_OFPST10_PORT_DESC_REQUEST,
405 /* OFPST 1.5+ (13): struct ofp15_port_desc_request. */
406 OFPRAW_OFPST15_PORT_DESC_REQUEST,
407
408 /* OFPST 1.0 (13): struct ofp10_phy_port[]. */
409 OFPRAW_OFPST10_PORT_DESC_REPLY,
410 /* OFPST 1.1-1.3 (13): struct ofp11_port[]. */
411 OFPRAW_OFPST11_PORT_DESC_REPLY,
412 /* OFPST 1.4+ (13): uint8_t[8][]. */
413 OFPRAW_OFPST14_PORT_DESC_REPLY,
414
415 /* OFPST 1.4+ (15): struct ofp14_queue_desc_request. */
416 OFPRAW_OFPST14_QUEUE_DESC_REQUEST,
417 /* OFPST 1.4+ (15): uint8_t[8][]. */
418 OFPRAW_OFPST14_QUEUE_DESC_REPLY,
419
420 /* OFPST 1.4+ (16): uint8_t[8][]. */
421 OFPRAW_OFPST14_FLOW_MONITOR_REQUEST,
422 /* NXST 1.0 (2): uint8_t[8][]. */
423 OFPRAW_NXST_FLOW_MONITOR_REQUEST,
424
425 /* OFPST 1.4+ (16): uint8_t[8][]. */
426 OFPRAW_OFPST14_FLOW_MONITOR_REPLY,
427 /* NXST 1.0 (2): uint8_t[8][]. */
428 OFPRAW_NXST_FLOW_MONITOR_REPLY,
429
430 /* Nicira extension messages.
431 *
432 * Nicira extensions that correspond to standard OpenFlow messages are listed
433 * alongside the standard versions above. */
434
435 /* NXT 1.0 (12): struct nx_set_flow_format. */
436 OFPRAW_NXT_SET_FLOW_FORMAT,
437
438 /* NXT 1.0+ (15): struct nx_flow_mod_table_id. */
439 OFPRAW_NXT_FLOW_MOD_TABLE_ID,
440
441 /* NXT 1.0+ (16): struct nx_set_packet_in_format. */
442 OFPRAW_NXT_SET_PACKET_IN_FORMAT,
443
444 /* NXT 1.0+ (18): void. */
445 OFPRAW_NXT_FLOW_AGE,
446
447 /* NXT 1.0+ (20): struct nx_controller_id. */
448 OFPRAW_NXT_SET_CONTROLLER_ID,
449
450 /* NXT 1.0+ (21): struct nx_flow_monitor_cancel. */
451 OFPRAW_NXT_FLOW_MONITOR_CANCEL,
452
453 /* NXT 1.0+ (22): void. */
454 OFPRAW_NXT_FLOW_MONITOR_PAUSED,
455
456 /* NXT 1.0+ (23): void. */
457 OFPRAW_NXT_FLOW_MONITOR_RESUMED,
458
459 /* NXT 1.0+ (24): struct nx_tlv_table_mod, struct nx_tlv_map[]. */
460 OFPRAW_NXT_TLV_TABLE_MOD,
461
462 /* NXT 1.0+ (25): void. */
463 OFPRAW_NXT_TLV_TABLE_REQUEST,
464
465 /* NXT 1.0+ (26): struct nx_tlv_table_reply, struct nx_tlv_map[]. */
466 OFPRAW_NXT_TLV_TABLE_REPLY,
467
468 /* NXT 1.0+ (28): uint8_t[8][]. */
469 OFPRAW_NXT_RESUME,
470
471 /* NXST 1.0+ (3): void. */
472 OFPRAW_NXST_IPFIX_BRIDGE_REQUEST,
473
474 /* NXST 1.0+ (3): struct nx_ipfix_stats_reply. */
475 OFPRAW_NXST_IPFIX_BRIDGE_REPLY,
476
477 /* NXST 1.0+ (4): void. */
478 OFPRAW_NXST_IPFIX_FLOW_REQUEST,
479
480 /* NXST 1.0+ (4): struct nx_ipfix_stats_reply[]. */
481 OFPRAW_NXST_IPFIX_FLOW_REPLY,
482 };
483
484 /* Decoding messages into OFPRAW_* values. */
485 enum ofperr ofpraw_decode(enum ofpraw *, const struct ofp_header *);
486 enum ofpraw ofpraw_decode_assert(const struct ofp_header *);
487 enum ofperr ofpraw_pull(enum ofpraw *, struct ofpbuf *);
488 enum ofpraw ofpraw_pull_assert(struct ofpbuf *);
489
490 enum ofperr ofpraw_decode_partial(enum ofpraw *,
491 const struct ofp_header *, size_t length);
492
493 /* Encoding messages using OFPRAW_* values. */
494 struct ofpbuf *ofpraw_alloc(enum ofpraw, uint8_t ofp_version,
495 size_t extra_tailroom);
496 struct ofpbuf *ofpraw_alloc_xid(enum ofpraw, uint8_t ofp_version,
497 ovs_be32 xid, size_t extra_tailroom);
498 struct ofpbuf *ofpraw_alloc_reply(enum ofpraw,
499 const struct ofp_header *request,
500 size_t extra_tailroom);
501 struct ofpbuf *ofpraw_alloc_stats_reply(const struct ofp_header *request,
502 size_t extra_tailroom);
503
504 void ofpraw_put(enum ofpraw, uint8_t ofp_version, struct ofpbuf *);
505 void ofpraw_put_xid(enum ofpraw, uint8_t ofp_version, ovs_be32 xid,
506 struct ofpbuf *);
507 void ofpraw_put_reply(enum ofpraw, const struct ofp_header *request,
508 struct ofpbuf *);
509 void ofpraw_put_stats_reply(const struct ofp_header *request, struct ofpbuf *);
510
511 /* Information about OFPRAW_* values. */
512 const char *ofpraw_get_name(enum ofpraw);
513 enum ofpraw ofpraw_stats_request_to_reply(enum ofpraw, uint8_t version);
514 \f
515 /* Semantic identifiers for OpenFlow messages.
516 *
517 * Each OFPTYPE_* enumeration constant represents one or more concrete format
518 * of OpenFlow message. When two variants of a message have essentially the
519 * same meaning, they are assigned a single OFPTYPE_* value.
520 *
521 * The comments here must follow a stylized form because the "extract-ofp-msgs"
522 * program parses them at build time to generate data tables. The format is
523 * simply to list each OFPRAW_* enumeration constant for a given OFPTYPE_*,
524 * each followed by a period. */
525 enum ofptype {
526 /* Immutable messages. */
527 OFPTYPE_HELLO, /* OFPRAW_OFPT_HELLO. */
528 OFPTYPE_ERROR, /* OFPRAW_OFPT_ERROR. */
529 OFPTYPE_ECHO_REQUEST, /* OFPRAW_OFPT_ECHO_REQUEST. */
530 OFPTYPE_ECHO_REPLY, /* OFPRAW_OFPT_ECHO_REPLY. */
531
532 /* Switch configuration messages. */
533 OFPTYPE_FEATURES_REQUEST, /* OFPRAW_OFPT_FEATURES_REQUEST. */
534 OFPTYPE_FEATURES_REPLY, /* OFPRAW_OFPT10_FEATURES_REPLY.
535 * OFPRAW_OFPT11_FEATURES_REPLY.
536 * OFPRAW_OFPT13_FEATURES_REPLY. */
537 OFPTYPE_GET_CONFIG_REQUEST, /* OFPRAW_OFPT_GET_CONFIG_REQUEST. */
538 OFPTYPE_GET_CONFIG_REPLY, /* OFPRAW_OFPT_GET_CONFIG_REPLY. */
539 OFPTYPE_SET_CONFIG, /* OFPRAW_OFPT_SET_CONFIG. */
540
541 /* Asynchronous messages. */
542 OFPTYPE_PACKET_IN, /* OFPRAW_OFPT10_PACKET_IN.
543 * OFPRAW_OFPT11_PACKET_IN.
544 * OFPRAW_OFPT12_PACKET_IN.
545 * OFPRAW_OFPT13_PACKET_IN.
546 * OFPRAW_NXT_PACKET_IN2.
547 * OFPRAW_NXT_PACKET_IN. */
548 OFPTYPE_FLOW_REMOVED, /* OFPRAW_OFPT10_FLOW_REMOVED.
549 * OFPRAW_OFPT11_FLOW_REMOVED.
550 * OFPRAW_NXT_FLOW_REMOVED. */
551 OFPTYPE_PORT_STATUS, /* OFPRAW_OFPT10_PORT_STATUS.
552 * OFPRAW_OFPT11_PORT_STATUS.
553 * OFPRAW_OFPT14_PORT_STATUS. */
554
555 /* Controller command messages. */
556 OFPTYPE_PACKET_OUT, /* OFPRAW_OFPT10_PACKET_OUT.
557 * OFPRAW_OFPT11_PACKET_OUT. */
558 OFPTYPE_FLOW_MOD, /* OFPRAW_OFPT10_FLOW_MOD.
559 * OFPRAW_OFPT11_FLOW_MOD.
560 * OFPRAW_NXT_FLOW_MOD. */
561 OFPTYPE_GROUP_MOD, /* OFPRAW_OFPT11_GROUP_MOD.
562 * OFPRAW_OFPT15_GROUP_MOD. */
563 OFPTYPE_PORT_MOD, /* OFPRAW_OFPT10_PORT_MOD.
564 * OFPRAW_OFPT11_PORT_MOD.
565 * OFPRAW_OFPT14_PORT_MOD. */
566 OFPTYPE_TABLE_MOD, /* OFPRAW_OFPT11_TABLE_MOD.
567 * OFPRAW_OFPT14_TABLE_MOD. */
568
569 /* Barrier messages. */
570 OFPTYPE_BARRIER_REQUEST, /* OFPRAW_OFPT10_BARRIER_REQUEST.
571 * OFPRAW_OFPT11_BARRIER_REQUEST. */
572 OFPTYPE_BARRIER_REPLY, /* OFPRAW_OFPT10_BARRIER_REPLY.
573 * OFPRAW_OFPT11_BARRIER_REPLY. */
574
575 /* Queue Configuration messages. */
576 OFPTYPE_QUEUE_GET_CONFIG_REQUEST, /* OFPRAW_OFPT10_QUEUE_GET_CONFIG_REQUEST.
577 * OFPRAW_OFPT11_QUEUE_GET_CONFIG_REQUEST.
578 * OFPRAW_OFPST14_QUEUE_DESC_REQUEST. */
579 OFPTYPE_QUEUE_GET_CONFIG_REPLY, /* OFPRAW_OFPT10_QUEUE_GET_CONFIG_REPLY.
580 * OFPRAW_OFPT11_QUEUE_GET_CONFIG_REPLY.
581 * OFPRAW_OFPST14_QUEUE_DESC_REPLY. */
582
583 /* Controller role change request messages. */
584 OFPTYPE_ROLE_REQUEST, /* OFPRAW_OFPT12_ROLE_REQUEST.
585 * OFPRAW_NXT_ROLE_REQUEST. */
586 OFPTYPE_ROLE_REPLY, /* OFPRAW_OFPT12_ROLE_REPLY.
587 * OFPRAW_NXT_ROLE_REPLY. */
588
589 /* Asynchronous message configuration. */
590 OFPTYPE_GET_ASYNC_REQUEST, /* OFPRAW_OFPT13_GET_ASYNC_REQUEST.
591 * OFPRAW_OFPT14_GET_ASYNC_REQUEST. */
592 OFPTYPE_GET_ASYNC_REPLY, /* OFPRAW_OFPT13_GET_ASYNC_REPLY.
593 * OFPRAW_OFPT14_GET_ASYNC_REPLY. */
594 OFPTYPE_SET_ASYNC_CONFIG, /* OFPRAW_NXT_SET_ASYNC_CONFIG.
595 * OFPRAW_NXT_SET_ASYNC_CONFIG2.
596 * OFPRAW_OFPT13_SET_ASYNC.
597 * OFPRAW_OFPT14_SET_ASYNC. */
598
599 /* Meters and rate limiters configuration messages. */
600 OFPTYPE_METER_MOD, /* OFPRAW_OFPT13_METER_MOD. */
601
602 /* Controller role change event messages. */
603 OFPTYPE_ROLE_STATUS, /* OFPRAW_OFPT14_ROLE_STATUS. */
604
605 /* Request forwarding by the switch. */
606 OFPTYPE_REQUESTFORWARD, /* OFPRAW_OFPT14_REQUESTFORWARD. */
607
608 /* Asynchronous messages. */
609 OFPTYPE_TABLE_STATUS, /* OFPRAW_OFPT14_TABLE_STATUS. */
610
611 OFPTYPE_BUNDLE_CONTROL, /* OFPRAW_OFPT14_BUNDLE_CONTROL.
612 * OFPRAW_ONFT13_BUNDLE_CONTROL. */
613
614 OFPTYPE_BUNDLE_ADD_MESSAGE, /* OFPRAW_OFPT14_BUNDLE_ADD_MESSAGE.
615 * OFPRAW_ONFT13_BUNDLE_ADD_MESSAGE. */
616
617 /* Statistics. */
618 OFPTYPE_DESC_STATS_REQUEST, /* OFPRAW_OFPST_DESC_REQUEST. */
619 OFPTYPE_DESC_STATS_REPLY, /* OFPRAW_OFPST_DESC_REPLY. */
620 OFPTYPE_FLOW_STATS_REQUEST, /* OFPRAW_OFPST10_FLOW_REQUEST.
621 * OFPRAW_OFPST11_FLOW_REQUEST.
622 * OFPRAW_NXST_FLOW_REQUEST. */
623 OFPTYPE_FLOW_STATS_REPLY, /* OFPRAW_OFPST10_FLOW_REPLY.
624 * OFPRAW_OFPST11_FLOW_REPLY.
625 * OFPRAW_OFPST13_FLOW_REPLY.
626 * OFPRAW_NXST_FLOW_REPLY. */
627 OFPTYPE_AGGREGATE_STATS_REQUEST, /* OFPRAW_OFPST10_AGGREGATE_REQUEST.
628 * OFPRAW_OFPST11_AGGREGATE_REQUEST.
629 * OFPRAW_NXST_AGGREGATE_REQUEST. */
630 OFPTYPE_AGGREGATE_STATS_REPLY, /* OFPRAW_OFPST_AGGREGATE_REPLY.
631 * OFPRAW_NXST_AGGREGATE_REPLY. */
632 OFPTYPE_TABLE_STATS_REQUEST, /* OFPRAW_OFPST_TABLE_REQUEST. */
633 OFPTYPE_TABLE_STATS_REPLY, /* OFPRAW_OFPST10_TABLE_REPLY.
634 * OFPRAW_OFPST11_TABLE_REPLY.
635 * OFPRAW_OFPST12_TABLE_REPLY.
636 * OFPRAW_OFPST13_TABLE_REPLY. */
637 OFPTYPE_PORT_STATS_REQUEST, /* OFPRAW_OFPST10_PORT_REQUEST.
638 * OFPRAW_OFPST11_PORT_REQUEST. */
639 OFPTYPE_PORT_STATS_REPLY, /* OFPRAW_OFPST10_PORT_REPLY.
640 * OFPRAW_OFPST11_PORT_REPLY.
641 * OFPRAW_OFPST13_PORT_REPLY.
642 * OFPRAW_OFPST14_PORT_REPLY. */
643 OFPTYPE_QUEUE_STATS_REQUEST, /* OFPRAW_OFPST10_QUEUE_REQUEST.
644 * OFPRAW_OFPST11_QUEUE_REQUEST. */
645 OFPTYPE_QUEUE_STATS_REPLY, /* OFPRAW_OFPST10_QUEUE_REPLY.
646 * OFPRAW_OFPST11_QUEUE_REPLY.
647 * OFPRAW_OFPST13_QUEUE_REPLY.
648 * OFPRAW_OFPST14_QUEUE_REPLY. */
649
650 OFPTYPE_GROUP_STATS_REQUEST, /* OFPRAW_OFPST11_GROUP_REQUEST. */
651
652 OFPTYPE_GROUP_STATS_REPLY, /* OFPRAW_OFPST11_GROUP_REPLY.
653 * OFPRAW_OFPST13_GROUP_REPLY. */
654
655 OFPTYPE_GROUP_DESC_STATS_REQUEST, /* OFPRAW_OFPST11_GROUP_DESC_REQUEST.
656 * OFPRAW_OFPST15_GROUP_DESC_REQUEST. */
657
658 OFPTYPE_GROUP_DESC_STATS_REPLY, /* OFPRAW_OFPST11_GROUP_DESC_REPLY. */
659
660 OFPTYPE_GROUP_FEATURES_STATS_REQUEST, /* OFPRAW_OFPST12_GROUP_FEATURES_REQUEST. */
661
662 OFPTYPE_GROUP_FEATURES_STATS_REPLY, /* OFPRAW_OFPST12_GROUP_FEATURES_REPLY. */
663
664 OFPTYPE_METER_STATS_REQUEST, /* OFPRAW_OFPST13_METER_REQUEST. */
665
666 OFPTYPE_METER_STATS_REPLY, /* OFPRAW_OFPST13_METER_REPLY. */
667
668 OFPTYPE_METER_CONFIG_STATS_REQUEST, /* OFPRAW_OFPST13_METER_CONFIG_REQUEST. */
669
670 OFPTYPE_METER_CONFIG_STATS_REPLY, /* OFPRAW_OFPST13_METER_CONFIG_REPLY. */
671
672 OFPTYPE_METER_FEATURES_STATS_REQUEST, /* OFPRAW_OFPST13_METER_FEATURES_REQUEST. */
673
674 OFPTYPE_METER_FEATURES_STATS_REPLY, /* OFPRAW_OFPST13_METER_FEATURES_REPLY. */
675
676 OFPTYPE_TABLE_FEATURES_STATS_REQUEST, /* OFPRAW_OFPST13_TABLE_FEATURES_REQUEST. */
677
678 OFPTYPE_TABLE_FEATURES_STATS_REPLY, /* OFPRAW_OFPST13_TABLE_FEATURES_REPLY. */
679
680 OFPTYPE_TABLE_DESC_REQUEST, /* OFPRAW_OFPST14_TABLE_DESC_REQUEST. */
681
682 OFPTYPE_TABLE_DESC_REPLY, /* OFPRAW_OFPST14_TABLE_DESC_REPLY. */
683
684 OFPTYPE_PORT_DESC_STATS_REQUEST, /* OFPRAW_OFPST10_PORT_DESC_REQUEST.
685 * OFPRAW_OFPST15_PORT_DESC_REQUEST. */
686
687 OFPTYPE_PORT_DESC_STATS_REPLY, /* OFPRAW_OFPST10_PORT_DESC_REPLY.
688 * OFPRAW_OFPST11_PORT_DESC_REPLY.
689 * OFPRAW_OFPST14_PORT_DESC_REPLY. */
690
691 OFPTYPE_FLOW_MONITOR_STATS_REQUEST, /* OFPRAW_OFPST14_FLOW_MONITOR_REQUEST.
692 * OFPRAW_NXST_FLOW_MONITOR_REQUEST. */
693 OFPTYPE_FLOW_MONITOR_STATS_REPLY, /* OFPRAW_OFPST14_FLOW_MONITOR_REPLY.
694 * OFPRAW_NXST_FLOW_MONITOR_REPLY. */
695
696 /* Nicira extensions. */
697 OFPTYPE_SET_FLOW_FORMAT, /* OFPRAW_NXT_SET_FLOW_FORMAT. */
698 OFPTYPE_FLOW_MOD_TABLE_ID, /* OFPRAW_NXT_FLOW_MOD_TABLE_ID. */
699 OFPTYPE_SET_PACKET_IN_FORMAT, /* OFPRAW_NXT_SET_PACKET_IN_FORMAT. */
700 OFPTYPE_FLOW_AGE, /* OFPRAW_NXT_FLOW_AGE. */
701 OFPTYPE_SET_CONTROLLER_ID, /* OFPRAW_NXT_SET_CONTROLLER_ID. */
702 OFPTYPE_NXT_TLV_TABLE_MOD, /* OFPRAW_NXT_TLV_TABLE_MOD. */
703 OFPTYPE_NXT_TLV_TABLE_REQUEST, /* OFPRAW_NXT_TLV_TABLE_REQUEST. */
704 OFPTYPE_NXT_TLV_TABLE_REPLY, /* OFPRAW_NXT_TLV_TABLE_REPLY. */
705 OFPTYPE_NXT_RESUME, /* OFPRAW_NXT_RESUME. */
706 OFPTYPE_IPFIX_BRIDGE_STATS_REQUEST, /* OFPRAW_NXST_IPFIX_BRIDGE_REQUEST */
707 OFPTYPE_IPFIX_BRIDGE_STATS_REPLY, /* OFPRAW_NXST_IPFIX_BRIDGE_REPLY */
708 OFPTYPE_IPFIX_FLOW_STATS_REQUEST, /* OFPRAW_NXST_IPFIX_FLOW_REQUEST */
709 OFPTYPE_IPFIX_FLOW_STATS_REPLY, /* OFPRAW_NXST_IPFIX_FLOW_REPLY */
710
711 /* Flow monitor extension. */
712 OFPTYPE_FLOW_MONITOR_CANCEL, /* OFPRAW_NXT_FLOW_MONITOR_CANCEL. */
713 OFPTYPE_FLOW_MONITOR_PAUSED, /* OFPRAW_NXT_FLOW_MONITOR_PAUSED. */
714 OFPTYPE_FLOW_MONITOR_RESUMED, /* OFPRAW_NXT_FLOW_MONITOR_RESUMED. */
715 };
716
717 /* Decoding messages into OFPTYPE_* values. */
718 enum ofperr ofptype_decode(enum ofptype *, const struct ofp_header *);
719 enum ofperr ofptype_pull(enum ofptype *, struct ofpbuf *);
720 enum ofptype ofptype_from_ofpraw(enum ofpraw);
721
722 /* Information about OFTYPE_* values. */
723 const char *ofptype_get_name(enum ofptype);
724 \f
725 /* OpenFlow message properties. */
726 void ofpmsg_update_length(struct ofpbuf *);
727 const void *ofpmsg_body(const struct ofp_header *);
728 bool ofpmsg_is_stat_request(const struct ofp_header *);
729 \f
730 /* Multipart messages (aka "statistics").
731 *
732 * Individual OpenFlow messages are limited to 64 kB in size, but some messages
733 * need to be longer. Therefore, multipart messages allow a longer message to
734 * be divided into multiple parts at some convenient boundary. For example,
735 * limiting the response to a "flow dump" request to 64 kB would unreasonably
736 * limit the maximum number of flows in an OpenFlow switch, so a "flow dump" is
737 * expressed as a multipart request/reply pair, with the reply broken into
738 * pieces between flows.
739 *
740 * Multipart messages always consist of a request/reply pair.
741 *
742 * In OpenFlow 1.0, 1.1, and 1.2, requests must always fit in a single message,
743 * that is, only a multipart reply may have more than one part. OpenFlow 1.3
744 * adds one multipart request. This code does not yet support multipart
745 * requests. */
746
747 /* Encoding multipart replies.
748 *
749 * These functions are useful for multipart replies that might really require
750 * more than one message. A multipart message that is known in advance to fit
751 * within 64 kB doesn't need any special treatment, so you might as well use
752 * the ofpraw_alloc_*() functions.
753 *
754 * These functions work with a "struct ovs_list" of "struct ofpbuf"s, each of
755 * which represents one part of a multipart message. */
756 void ofpmp_init(struct ovs_list *, const struct ofp_header *request);
757 struct ofpbuf *ofpmp_reserve(struct ovs_list *, size_t len);
758 void *ofpmp_append(struct ovs_list *, size_t len);
759 void ofpmp_postappend(struct ovs_list *, size_t start_ofs);
760
761 enum ofp_version ofpmp_version(struct ovs_list *);
762 enum ofpraw ofpmp_decode_raw(struct ovs_list *);
763
764 /* Decoding multipart replies. */
765 uint16_t ofpmp_flags(const struct ofp_header *);
766 bool ofpmp_more(const struct ofp_header *);
767
768 #endif /* ofp-msgs.h */