2 * Copyright (c) 2012 Nicira, Inc.
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 implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 /* OpenFlow message headers abstraction.
22 * OpenFlow headers are unnecessarily complicated:
24 * - Some messages with the same meaning were renumbered between 1.0 and 1.1.
26 * - "Statistics" (aka multipart) messages have a different format from other
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.
34 * - Vendor-defined messages have an additional header but no standard way to
35 * distinguish individual types of message within a given vendor.
37 * This file attempts to abstract out the differences between the various forms
41 #include "openvswitch/types.h"
42 #include "ofp-errors.h"
47 /* Raw identifiers for OpenFlow messages.
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.
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
59 * type versions (number): arguments.
61 * where the syntax of each part is:
63 * - type: One of OFPT (standard OpenFlow message), OFPST (standard OpenFlow
64 * statistics message), NXT (Nicira extension message), or NXST (Nicira
65 * extension statistics message).
67 * As new vendors implement extensions it will make sense to expand the
68 * dictionary of possible types.
70 * - versions: The OpenFlow version or versions in which this message is
71 * supported, e.g. "1.0" or "1.1" or "1.0+".
74 * For OFPT, the 'type' in struct ofp_header.
75 * For OFPST, the 'type' in struct ofp_stats_msg or ofp11_stats_msg.
76 * For NXT, the 'subtype' in struct nicira_header.
77 * For NXST, the 'subtype' in struct nicira10_stats_msg or
80 * - arguments: The types of data that follow the OpenFlow headers (the
81 * message "body"). This can be "void" if the message has no body.
82 * Otherwise, it should be a comma-separated sequence of C types. The
83 * last type in the sequence can end with [] if the body ends in a
84 * variable-length sequence.
86 * The arguments are used to validate the lengths of messages when a
87 * header is parsed. Any message whose length isn't valid as a length of
88 * the specified types will be rejected with OFPERR_OFPBRC_BAD_LEN.
90 * A few OpenFlow messages, such as OFPT_PACKET_IN, intentionally end with
91 * only part of a structure, up to some specified member. The syntax "up
92 * to <member>" indicates this, e.g. "struct ofp11_packet_in up to data".
95 /* Immutable standard messages.
97 * The OpenFlow standard promises to preserve these messages and their numbers
98 * in future versions, so we mark them as <all>, which covers every OpenFlow
99 * version numbered 0x01...0xff, rather than as OF1.0+, which covers only
100 * OpenFlow versions that we otherwise implement.
102 * Without <all> here, then we would fail to decode "hello" messages that
103 * announce a version higher than we understand, even though there still could
104 * be a version in common with the peer that we do understand. The <all>
105 * keyword is less useful for the other messages, because our OpenFlow channels
106 * accept only OpenFlow messages with a previously negotiated version.
109 /* OFPT <all> (0): uint8_t[]. */
112 /* OFPT <all> (1): struct ofp_error_msg, uint8_t[]. */
115 /* OFPT <all> (2): uint8_t[]. */
116 OFPRAW_OFPT_ECHO_REQUEST,
118 /* OFPT <all> (3): uint8_t[]. */
119 OFPRAW_OFPT_ECHO_REPLY,
121 /* Other standard messages.
123 * The meanings of these messages can (and often do) change from one version
124 * of OpenFlow to another. */
126 /* OFPT 1.0+ (5): void. */
127 OFPRAW_OFPT_FEATURES_REQUEST,
129 /* OFPT 1.0 (6): struct ofp_switch_features, struct ofp10_phy_port[]. */
130 OFPRAW_OFPT10_FEATURES_REPLY,
131 /* OFPT 1.1-1.2 (6): struct ofp_switch_features, struct ofp11_port[]. */
132 OFPRAW_OFPT11_FEATURES_REPLY,
133 /* OFPT 1.3+ (6): struct ofp_switch_features. */
134 OFPRAW_OFPT13_FEATURES_REPLY,
136 /* OFPT 1.0+ (7): void. */
137 OFPRAW_OFPT_GET_CONFIG_REQUEST,
139 /* OFPT 1.0+ (8): struct ofp_switch_config. */
140 OFPRAW_OFPT_GET_CONFIG_REPLY,
142 /* OFPT 1.0+ (9): struct ofp_switch_config. */
143 OFPRAW_OFPT_SET_CONFIG,
145 /* OFPT 1.0 (10): struct ofp_packet_in up to data, uint8_t[]. */
146 OFPRAW_OFPT10_PACKET_IN,
147 /* OFPT 1.1 (10): struct ofp11_packet_in up to data, uint8_t[]. */
148 OFPRAW_OFPT11_PACKET_IN,
149 /* OFPT 1.2 (10): struct ofp12_packet_in, uint8_t[]. */
150 OFPRAW_OFPT12_PACKET_IN,
151 /* OFPT 1.3 (10): struct ofp13_packet_in, uint8_t[]. */
152 OFPRAW_OFPT13_PACKET_IN,
153 /* NXT 1.0+ (17): struct nx_packet_in, uint8_t[]. */
154 OFPRAW_NXT_PACKET_IN,
156 /* OFPT 1.0 (11): struct ofp_flow_removed. */
157 OFPRAW_OFPT10_FLOW_REMOVED,
158 /* OFPT 1.1+ (11): struct ofp11_flow_removed, uint8_t[8][]. */
159 OFPRAW_OFPT11_FLOW_REMOVED,
160 /* NXT 1.0+ (14): struct nx_flow_removed, uint8_t[8][]. */
161 OFPRAW_NXT_FLOW_REMOVED,
163 /* OFPT 1.0 (12): struct ofp_port_status, struct ofp10_phy_port. */
164 OFPRAW_OFPT10_PORT_STATUS,
165 /* OFPT 1.1+ (12): struct ofp_port_status, struct ofp11_port. */
166 OFPRAW_OFPT11_PORT_STATUS,
168 /* OFPT 1.0 (13): struct ofp_packet_out, uint8_t[]. */
169 OFPRAW_OFPT10_PACKET_OUT,
170 /* OFPT 1.1+ (13): struct ofp11_packet_out, uint8_t[]. */
171 OFPRAW_OFPT11_PACKET_OUT,
173 /* OFPT 1.0 (14): struct ofp10_flow_mod, struct ofp_action_header[]. */
174 OFPRAW_OFPT10_FLOW_MOD,
175 /* OFPT 1.1+ (14): struct ofp11_flow_mod, struct ofp11_instruction[]. */
176 OFPRAW_OFPT11_FLOW_MOD,
177 /* NXT 1.0+ (13): struct nx_flow_mod, uint8_t[8][]. */
180 /* OFPT 1.0 (15): struct ofp10_port_mod. */
181 OFPRAW_OFPT10_PORT_MOD,
182 /* OFPT 1.1+ (16): struct ofp11_port_mod. */
183 OFPRAW_OFPT11_PORT_MOD,
185 /* OFPT 1.0 (18): void. */
186 OFPRAW_OFPT10_BARRIER_REQUEST,
187 /* OFPT 1.1+ (20): void. */
188 OFPRAW_OFPT11_BARRIER_REQUEST,
190 /* OFPT 1.0 (19): void. */
191 OFPRAW_OFPT10_BARRIER_REPLY,
192 /* OFPT 1.1+ (21): void. */
193 OFPRAW_OFPT11_BARRIER_REPLY,
195 /* OFPT 1.3+ (26): void. */
196 OFPRAW_OFPT13_GET_ASYNC_REQUEST,
197 /* OFPT 1.3+ (27): struct ofp13_async_config. */
198 OFPRAW_OFPT13_GET_ASYNC_REPLY,
199 /* OFPT 1.3+ (28): struct ofp13_async_config. */
200 OFPRAW_OFPT13_SET_ASYNC,
201 /* NXT 1.0+ (19): struct nx_async_config. */
202 OFPRAW_NXT_SET_ASYNC_CONFIG,
204 /* OFPT 1.3+ (29): struct ofp13_meter_mod. */
205 OFPRAW_OFPT13_METER_MOD,
207 /* Standard statistics. */
209 /* OFPST 1.0+ (0): void. */
210 OFPRAW_OFPST_DESC_REQUEST,
212 /* OFPST 1.0+ (0): struct ofp_desc_stats. */
213 OFPRAW_OFPST_DESC_REPLY,
215 /* OFPST 1.0 (1): struct ofp10_flow_stats_request. */
216 OFPRAW_OFPST10_FLOW_REQUEST,
217 /* OFPST 1.1+ (1): struct ofp11_flow_stats_request, uint8_t[8][]. */
218 OFPRAW_OFPST11_FLOW_REQUEST,
219 /* NXST 1.0 (0): struct nx_flow_stats_request, uint8_t[8][]. */
220 OFPRAW_NXST_FLOW_REQUEST,
222 /* OFPST 1.0 (1): uint8_t[]. */
223 OFPRAW_OFPST10_FLOW_REPLY,
224 /* OFPST 1.1-1.2 (1): uint8_t[]. */
225 OFPRAW_OFPST11_FLOW_REPLY,
226 /* OFPST 1.3+ (1): uint8_t[]. */
227 OFPRAW_OFPST13_FLOW_REPLY,
228 /* NXST 1.0 (0): uint8_t[]. */
229 OFPRAW_NXST_FLOW_REPLY,
231 /* OFPST 1.0 (2): struct ofp10_flow_stats_request. */
232 OFPRAW_OFPST10_AGGREGATE_REQUEST,
233 /* OFPST 1.1+ (2): struct ofp11_flow_stats_request, uint8_t[8][]. */
234 OFPRAW_OFPST11_AGGREGATE_REQUEST,
235 /* NXST 1.0 (1): struct nx_flow_stats_request, uint8_t[8][]. */
236 OFPRAW_NXST_AGGREGATE_REQUEST,
238 /* OFPST 1.0+ (2): struct ofp_aggregate_stats_reply. */
239 OFPRAW_OFPST_AGGREGATE_REPLY,
240 /* NXST 1.0 (1): struct ofp_aggregate_stats_reply. */
241 OFPRAW_NXST_AGGREGATE_REPLY,
243 /* OFPST 1.0+ (3): void. */
244 OFPRAW_OFPST_TABLE_REQUEST,
246 /* OFPST 1.0 (3): struct ofp10_table_stats[]. */
247 OFPRAW_OFPST10_TABLE_REPLY,
248 /* OFPST 1.1 (3): struct ofp11_table_stats[]. */
249 OFPRAW_OFPST11_TABLE_REPLY,
250 /* OFPST 1.2 (3): struct ofp12_table_stats[]. */
251 OFPRAW_OFPST12_TABLE_REPLY,
252 /* OFPST 1.3 (3): struct ofp13_table_stats[]. */
253 OFPRAW_OFPST13_TABLE_REPLY,
255 /* OFPST 1.0 (4): struct ofp10_port_stats_request. */
256 OFPRAW_OFPST10_PORT_REQUEST,
257 /* OFPST 1.1+ (4): struct ofp11_port_stats_request. */
258 OFPRAW_OFPST11_PORT_REQUEST,
260 /* OFPST 1.0 (4): struct ofp10_port_stats[]. */
261 OFPRAW_OFPST10_PORT_REPLY,
262 /* OFPST 1.1-1.2 (4): struct ofp11_port_stats[]. */
263 OFPRAW_OFPST11_PORT_REPLY,
264 /* OFPST 1.3+ (4): struct ofp13_port_stats[]. */
265 OFPRAW_OFPST13_PORT_REPLY,
267 /* OFPST 1.0 (5): struct ofp10_queue_stats_request. */
268 OFPRAW_OFPST10_QUEUE_REQUEST,
269 /* OFPST 1.1+ (5): struct ofp11_queue_stats_request. */
270 OFPRAW_OFPST11_QUEUE_REQUEST,
272 /* OFPST 1.0 (5): struct ofp10_queue_stats[]. */
273 OFPRAW_OFPST10_QUEUE_REPLY,
274 /* OFPST 1.1-1.2 (5): struct ofp11_queue_stats[]. */
275 OFPRAW_OFPST11_QUEUE_REPLY,
276 /* OFPST 1.3+ (5): struct ofp13_queue_stats[]. */
277 OFPRAW_OFPST13_QUEUE_REPLY,
279 /* OFPST 1.1+ (6): struct ofp11_group_stats_request. */
280 OFPRAW_OFPST11_GROUP_REQUEST,
282 /* OFPST 1.1-1.2 (6): struct ofp11_group_stats[]. */
283 OFPRAW_OFPST11_GROUP_REPLY,
284 /* OFPST 1.3 (6): struct ofp13_group_stats[]. */
285 OFPRAW_OFPST13_GROUP_REPLY,
287 /* OFPST 1.1+ (7): void. */
288 OFPRAW_OFPST11_GROUP_DESC_REQUEST,
290 /* OFPST 1.1+ (7): struct ofp11_group_desc_stats[]. */
291 OFPRAW_OFPST11_GROUP_DESC_REPLY,
293 /* OFPST 1.2+ (8): void. */
294 OFPRAW_OFPST12_GROUP_FEATURES_REQUEST,
296 /* OFPST 1.2+ (8): struct ofp12_group_features_stats. */
297 OFPRAW_OFPST12_GROUP_FEATURES_REPLY,
299 /* OFPST 1.3+ (9): struct ofp13_meter_multipart_request. */
300 OFPRAW_OFPST13_METER_REQUEST,
302 /* OFPST 1.3+ (9): struct ofp13_meter_stats[]. */
303 OFPRAW_OFPST13_METER_REPLY,
305 /* OFPST 1.3+ (10): struct ofp13_meter_multipart_request. */
306 OFPRAW_OFPST13_METER_CONFIG_REQUEST,
308 /* OFPST 1.3+ (10): struct ofp13_meter_config[]. */
309 OFPRAW_OFPST13_METER_CONFIG_REPLY,
311 /* OFPST 1.3+ (11): void. */
312 OFPRAW_OFPST13_METER_FEATURES_REQUEST,
314 /* OFPST 1.3+ (11): struct ofp13_meter_features. */
315 OFPRAW_OFPST13_METER_FEATURES_REPLY,
317 /* OFPST 1.3+ (12): struct ofp13_table_features[]. */
318 OFPRAW_OFPST13_TABLE_FEATURES_REQUEST,
320 /* OFPST 1.3+ (12): struct ofp13_table_features[]. */
321 OFPRAW_OFPST13_TABLE_FEATURES_REPLY,
323 /* OFPST 1.0+ (13): void. */
324 OFPRAW_OFPST_PORT_DESC_REQUEST,
326 /* OFPST 1.0 (13): struct ofp10_phy_port[]. */
327 OFPRAW_OFPST10_PORT_DESC_REPLY,
328 /* OFPST 1.1+ (13): struct ofp11_port[]. */
329 OFPRAW_OFPST11_PORT_DESC_REPLY,
331 /* Nicira extension messages.
333 * Nicira extensions that correspond to standard OpenFlow messages are listed
334 * alongside the standard versions above. */
336 /* NXT 1.0+ (10): struct nx_role_request. */
337 OFPRAW_NXT_ROLE_REQUEST,
339 /* NXT 1.0+ (11): struct nx_role_request. */
340 OFPRAW_NXT_ROLE_REPLY,
342 /* NXT 1.0 (12): struct nx_set_flow_format. */
343 OFPRAW_NXT_SET_FLOW_FORMAT,
345 /* NXT 1.0+ (15): struct nx_flow_mod_table_id. */
346 OFPRAW_NXT_FLOW_MOD_TABLE_ID,
348 /* NXT 1.0+ (16): struct nx_set_packet_in_format. */
349 OFPRAW_NXT_SET_PACKET_IN_FORMAT,
351 /* NXT 1.0+ (18): void. */
354 /* NXT 1.0+ (20): struct nx_controller_id. */
355 OFPRAW_NXT_SET_CONTROLLER_ID,
357 /* NXT 1.0+ (21): struct nx_flow_monitor_cancel. */
358 OFPRAW_NXT_FLOW_MONITOR_CANCEL,
360 /* NXT 1.0+ (22): void. */
361 OFPRAW_NXT_FLOW_MONITOR_PAUSED,
363 /* NXT 1.0+ (23): void. */
364 OFPRAW_NXT_FLOW_MONITOR_RESUMED,
366 /* Nicira extension statistics.
368 * Nicira extension statistics that correspond to standard OpenFlow statistics
369 * are listed alongside the standard versions above. */
371 /* NXST 1.0 (2): uint8_t[8][]. */
372 OFPRAW_NXST_FLOW_MONITOR_REQUEST,
374 /* NXST 1.0 (2): uint8_t[8][]. */
375 OFPRAW_NXST_FLOW_MONITOR_REPLY,
378 /* Decoding messages into OFPRAW_* values. */
379 enum ofperr ofpraw_decode(enum ofpraw *, const struct ofp_header *);
380 enum ofperr ofpraw_pull(enum ofpraw *, struct ofpbuf *);
381 enum ofpraw ofpraw_pull_assert(struct ofpbuf *);
383 enum ofperr ofpraw_decode_partial(enum ofpraw *,
384 const struct ofp_header *, size_t length);
386 /* Encoding messages using OFPRAW_* values. */
387 struct ofpbuf *ofpraw_alloc(enum ofpraw, uint8_t ofp_version,
388 size_t extra_tailroom);
389 struct ofpbuf *ofpraw_alloc_xid(enum ofpraw, uint8_t ofp_version,
390 ovs_be32 xid, size_t extra_tailroom);
391 struct ofpbuf *ofpraw_alloc_reply(enum ofpraw,
392 const struct ofp_header *request,
393 size_t extra_tailroom);
394 struct ofpbuf *ofpraw_alloc_stats_reply(const struct ofp_header *request,
395 size_t extra_tailroom);
397 void ofpraw_put(enum ofpraw, uint8_t ofp_version, struct ofpbuf *);
398 void ofpraw_put_xid(enum ofpraw, uint8_t ofp_version, ovs_be32 xid,
400 void ofpraw_put_reply(enum ofpraw, const struct ofp_header *request,
402 void ofpraw_put_stats_reply(const struct ofp_header *request, struct ofpbuf *);
404 /* Information about OFPRAW_* values. */
405 const char *ofpraw_get_name(enum ofpraw);
406 enum ofpraw ofpraw_stats_request_to_reply(enum ofpraw, uint8_t version);
408 /* Semantic identifiers for OpenFlow messages.
410 * Each OFPTYPE_* enumeration constant represents one or more concrete format
411 * of OpenFlow message. When two variants of a message have essentially the
412 * same meaning, they are assigned a single OFPTYPE_* value.
414 * The comments here must follow a stylized form because the "extract-ofp-msgs"
415 * program parses them at build time to generate data tables. The format is
416 * simply to list each OFPRAW_* enumeration constant for a given OFPTYPE_*,
417 * each followed by a period. */
419 /* Immutable messages. */
420 OFPTYPE_HELLO, /* OFPRAW_OFPT_HELLO. */
421 OFPTYPE_ERROR, /* OFPRAW_OFPT_ERROR. */
422 OFPTYPE_ECHO_REQUEST, /* OFPRAW_OFPT_ECHO_REQUEST. */
423 OFPTYPE_ECHO_REPLY, /* OFPRAW_OFPT_ECHO_REPLY. */
425 /* Switch configuration messages. */
426 OFPTYPE_FEATURES_REQUEST, /* OFPRAW_OFPT_FEATURES_REQUEST. */
427 OFPTYPE_FEATURES_REPLY, /* OFPRAW_OFPT10_FEATURES_REPLY.
428 * OFPRAW_OFPT11_FEATURES_REPLY.
429 * OFPRAW_OFPT13_FEATURES_REPLY. */
430 OFPTYPE_GET_CONFIG_REQUEST, /* OFPRAW_OFPT_GET_CONFIG_REQUEST. */
431 OFPTYPE_GET_CONFIG_REPLY, /* OFPRAW_OFPT_GET_CONFIG_REPLY. */
432 OFPTYPE_SET_CONFIG, /* OFPRAW_OFPT_SET_CONFIG. */
434 /* Asynchronous messages. */
435 OFPTYPE_PACKET_IN, /* OFPRAW_OFPT10_PACKET_IN.
436 * OFPRAW_OFPT11_PACKET_IN.
437 * OFPRAW_OFPT12_PACKET_IN.
438 * OFPRAW_OFPT13_PACKET_IN.
439 * OFPRAW_NXT_PACKET_IN. */
440 OFPTYPE_FLOW_REMOVED, /* OFPRAW_OFPT10_FLOW_REMOVED.
441 * OFPRAW_OFPT11_FLOW_REMOVED.
442 * OFPRAW_NXT_FLOW_REMOVED. */
443 OFPTYPE_PORT_STATUS, /* OFPRAW_OFPT10_PORT_STATUS.
444 * OFPRAW_OFPT11_PORT_STATUS. */
446 /* Controller command messages. */
447 OFPTYPE_PACKET_OUT, /* OFPRAW_OFPT10_PACKET_OUT.
448 * OFPRAW_OFPT11_PACKET_OUT. */
449 OFPTYPE_FLOW_MOD, /* OFPRAW_OFPT10_FLOW_MOD.
450 * OFPRAW_OFPT11_FLOW_MOD.
451 * OFPRAW_NXT_FLOW_MOD. */
452 OFPTYPE_PORT_MOD, /* OFPRAW_OFPT10_PORT_MOD.
453 * OFPRAW_OFPT11_PORT_MOD. */
455 /* Barrier messages. */
456 OFPTYPE_BARRIER_REQUEST, /* OFPRAW_OFPT10_BARRIER_REQUEST.
457 * OFPRAW_OFPT11_BARRIER_REQUEST. */
458 OFPTYPE_BARRIER_REPLY, /* OFPRAW_OFPT10_BARRIER_REPLY.
459 * OFPRAW_OFPT11_BARRIER_REPLY. */
461 /* Asynchronous message configuration. */
462 OFPTYPE_GET_ASYNC_REQUEST, /* OFPRAW_OFPT13_GET_ASYNC_REQUEST. */
463 OFPTYPE_GET_ASYNC_REPLY, /* OFPRAW_OFPT13_GET_ASYNC_REPLY. */
464 OFPTYPE_SET_ASYNC_CONFIG, /* OFPRAW_NXT_SET_ASYNC_CONFIG.
465 * OFPRAW_OFPT13_SET_ASYNC. */
467 /* Meters and rate limiters configuration messages. */
468 OFPTYPE_METER_MOD, /* OFPRAW_OFPT13_METER_MOD. */
471 OFPTYPE_DESC_STATS_REQUEST, /* OFPRAW_OFPST_DESC_REQUEST. */
472 OFPTYPE_DESC_STATS_REPLY, /* OFPRAW_OFPST_DESC_REPLY. */
473 OFPTYPE_FLOW_STATS_REQUEST, /* OFPRAW_OFPST10_FLOW_REQUEST.
474 * OFPRAW_OFPST11_FLOW_REQUEST.
475 * OFPRAW_NXST_FLOW_REQUEST. */
476 OFPTYPE_FLOW_STATS_REPLY, /* OFPRAW_OFPST10_FLOW_REPLY.
477 * OFPRAW_OFPST11_FLOW_REPLY.
478 * OFPRAW_OFPST13_FLOW_REPLY.
479 * OFPRAW_NXST_FLOW_REPLY. */
480 OFPTYPE_AGGREGATE_STATS_REQUEST, /* OFPRAW_OFPST10_AGGREGATE_REQUEST.
481 * OFPRAW_OFPST11_AGGREGATE_REQUEST.
482 * OFPRAW_NXST_AGGREGATE_REQUEST. */
483 OFPTYPE_AGGREGATE_STATS_REPLY, /* OFPRAW_OFPST_AGGREGATE_REPLY.
484 * OFPRAW_NXST_AGGREGATE_REPLY. */
485 OFPTYPE_TABLE_STATS_REQUEST, /* OFPRAW_OFPST_TABLE_REQUEST. */
486 OFPTYPE_TABLE_STATS_REPLY, /* OFPRAW_OFPST10_TABLE_REPLY.
487 * OFPRAW_OFPST11_TABLE_REPLY.
488 * OFPRAW_OFPST12_TABLE_REPLY.
489 * OFPRAW_OFPST13_TABLE_REPLY. */
490 OFPTYPE_PORT_STATS_REQUEST, /* OFPRAW_OFPST10_PORT_REQUEST.
491 * OFPRAW_OFPST11_PORT_REQUEST. */
492 OFPTYPE_PORT_STATS_REPLY, /* OFPRAW_OFPST10_PORT_REPLY.
493 * OFPRAW_OFPST11_PORT_REPLY.
494 * OFPRAW_OFPST13_PORT_REPLY. */
495 OFPTYPE_QUEUE_STATS_REQUEST, /* OFPRAW_OFPST10_QUEUE_REQUEST.
496 * OFPRAW_OFPST11_QUEUE_REQUEST. */
497 OFPTYPE_QUEUE_STATS_REPLY, /* OFPRAW_OFPST10_QUEUE_REPLY.
498 * OFPRAW_OFPST11_QUEUE_REPLY.
499 * OFPRAW_OFPST13_QUEUE_REPLY. */
501 OFPTYPE_GROUP_REQUEST, /* OFPRAW_OFPST11_GROUP_REQUEST. */
503 OFPTYPE_GROUP_REPLY, /* OFPRAW_OFPST11_GROUP_REPLY.
504 * OFPRAW_OFPST13_GROUP_REPLY. */
506 OFPTYPE_GROUP_DESC_REQUEST, /* OFPRAW_OFPST11_GROUP_DESC_REQUEST. */
508 OFPTYPE_GROUP_DESC_REPLY, /* OFPRAW_OFPST11_GROUP_DESC_REPLY. */
510 OFPTYPE_GROUP_FEATURES_REQUEST, /* OFPRAW_OFPST12_GROUP_FEATURES_REQUEST. */
512 OFPTYPE_GROUP_FEATURES_REPLY, /* OFPRAW_OFPST12_GROUP_FEATURES_REPLY. */
514 OFPTYPE_METER_REQUEST, /* OFPRAW_OFPST13_METER_REQUEST. */
516 OFPTYPE_METER_REPLY, /* OFPRAW_OFPST13_METER_REPLY. */
518 OFPTYPE_METER_CONFIG_REQUEST, /* OFPRAW_OFPST13_METER_CONFIG_REQUEST. */
520 OFPTYPE_METER_CONFIG_REPLY, /* OFPRAW_OFPST13_METER_CONFIG_REPLY. */
522 OFPTYPE_METER_FEATURES_REQUEST, /* OFPRAW_OFPST13_METER_FEATURES_REQUEST. */
524 OFPTYPE_METER_FEATURES_REPLY, /* OFPRAW_OFPST13_METER_FEATURES_REPLY. */
526 OFPTYPE_TABLE_FEATURES_REQUEST, /* OFPRAW_OFPST13_TABLE_FEATURES_REQUEST. */
528 OFPTYPE_TABLE_FEATURES_REPLY, /* OFPRAW_OFPST13_TABLE_FEATURES_REPLY. */
530 OFPTYPE_PORT_DESC_STATS_REQUEST, /* OFPRAW_OFPST_PORT_DESC_REQUEST. */
532 OFPTYPE_PORT_DESC_STATS_REPLY, /* OFPRAW_OFPST10_PORT_DESC_REPLY.
533 * OFPRAW_OFPST11_PORT_DESC_REPLY. */
535 /* Nicira extensions. */
536 OFPTYPE_ROLE_REQUEST, /* OFPRAW_NXT_ROLE_REQUEST. */
537 OFPTYPE_ROLE_REPLY, /* OFPRAW_NXT_ROLE_REPLY. */
538 OFPTYPE_SET_FLOW_FORMAT, /* OFPRAW_NXT_SET_FLOW_FORMAT. */
539 OFPTYPE_FLOW_MOD_TABLE_ID, /* OFPRAW_NXT_FLOW_MOD_TABLE_ID. */
540 OFPTYPE_SET_PACKET_IN_FORMAT, /* OFPRAW_NXT_SET_PACKET_IN_FORMAT. */
541 OFPTYPE_FLOW_AGE, /* OFPRAW_NXT_FLOW_AGE. */
542 OFPTYPE_SET_CONTROLLER_ID, /* OFPRAW_NXT_SET_CONTROLLER_ID. */
544 /* Flow monitor extension. */
545 OFPTYPE_FLOW_MONITOR_STATS_REQUEST, /* OFPRAW_NXST_FLOW_MONITOR_REQUEST. */
546 OFPTYPE_FLOW_MONITOR_STATS_REPLY, /* OFPRAW_NXST_FLOW_MONITOR_REPLY. */
547 OFPTYPE_FLOW_MONITOR_CANCEL, /* OFPRAW_NXT_FLOW_MONITOR_CANCEL. */
548 OFPTYPE_FLOW_MONITOR_PAUSED, /* OFPRAW_NXT_FLOW_MONITOR_PAUSED. */
549 OFPTYPE_FLOW_MONITOR_RESUMED, /* OFPRAW_NXT_FLOW_MONITOR_RESUMED. */
552 /* Decoding messages into OFPTYPE_* values. */
553 enum ofperr ofptype_decode(enum ofptype *, const struct ofp_header *);
554 enum ofperr ofptype_pull(enum ofptype *, struct ofpbuf *);
555 enum ofptype ofptype_from_ofpraw(enum ofpraw);
557 /* OpenFlow message properties. */
558 void ofpmsg_update_length(struct ofpbuf *);
559 const void *ofpmsg_body(const struct ofp_header *);
561 /* Multipart messages (aka "statistics").
563 * Individual OpenFlow messages are limited to 64 kB in size, but some messages
564 * need to be longer. Therefore, multipart messages allow a longer message to
565 * be divided into multiple parts at some convenient boundary. For example,
566 * limiting the response to a "flow dump" request to 64 kB would unreasonably
567 * limit the maximum number of flows in an OpenFlow switch, so a "flow dump" is
568 * expressed as a multipart request/reply pair, with the reply broken into
569 * pieces between flows.
571 * Multipart messages always consist of a request/reply pair.
573 * In OpenFlow 1.0, 1.1, and 1.2, requests must always fit in a single message,
574 * that is, only a multipart reply may have more than one part. OpenFlow 1.3
575 * adds one multipart request. This code does not yet support multipart
578 /* Encoding multipart replies.
580 * These functions are useful for multipart replies that might really require
581 * more than one message. A multipart message that is known in advance to fit
582 * within 64 kB doesn't need any special treatment, so you might as well use
583 * the ofpraw_alloc_*() functions.
585 * These functions work with a "struct list" of "struct ofpbuf"s, each of
586 * which represents one part of a multipart message. */
587 void ofpmp_init(struct list *, const struct ofp_header *request);
588 struct ofpbuf *ofpmp_reserve(struct list *, size_t len);
589 void *ofpmp_append(struct list *, size_t len);
590 void ofpmp_postappend(struct list *, size_t start_ofs);
592 /* Decoding multipart replies. */
593 uint16_t ofpmp_flags(const struct ofp_header *);
594 bool ofpmp_more(const struct ofp_header *);
596 #endif /* ofp-msgs.h */