ofp-msgs: Correct code for queue configuration messages in OpenFlow 1.0.
[cascardo/ovs.git] / lib / ofp-msgs.h
1 /*
2  * Copyright (c) 2012, 2013, 2014 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 OFP_MSGS_H
18 #define 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/types.h"
42 #include "ofp-errors.h"
43 #include "util.h"
44
45 struct 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 OFPT (standard OpenFlow message), OFPST (standard OpenFlow
64  *      statistics message), NXT (Nicira extension message), or NXST (Nicira
65  *      extension statistics message).
66  *
67  *      As new vendors implement extensions it will make sense to expand the
68  *      dictionary of possible types.
69  *
70  *    - versions: The OpenFlow version or versions in which this message is
71  *      supported, e.g. "1.0" or "1.1" or "1.0+".
72  *
73  *    - number:
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
78  *           nicira11_stats_msg.
79  *
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.
85  *
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.
89  *
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".
93  */
94 enum ofpraw {
95 /* Immutable standard messages.
96  *
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.
101  *
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.
107  */
108
109     /* OFPT <all> (0): uint8_t[]. */
110     OFPRAW_OFPT_HELLO,
111
112     /* OFPT <all> (1): struct ofp_error_msg, uint8_t[]. */
113     OFPRAW_OFPT_ERROR,
114
115     /* OFPT <all> (2): uint8_t[]. */
116     OFPRAW_OFPT_ECHO_REQUEST,
117
118     /* OFPT <all> (3): uint8_t[]. */
119     OFPRAW_OFPT_ECHO_REPLY,
120
121 /* Other standard messages.
122  *
123  * The meanings of these messages can (and often do) change from one version
124  * of OpenFlow to another. */
125
126     /* OFPT 1.0+ (5): void. */
127     OFPRAW_OFPT_FEATURES_REQUEST,
128
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,
135
136     /* OFPT 1.0+ (7): void. */
137     OFPRAW_OFPT_GET_CONFIG_REQUEST,
138
139     /* OFPT 1.0+ (8): struct ofp_switch_config. */
140     OFPRAW_OFPT_GET_CONFIG_REPLY,
141
142     /* OFPT 1.0+ (9): struct ofp_switch_config. */
143     OFPRAW_OFPT_SET_CONFIG,
144
145     /* OFPT 1.0 (10): struct ofp10_packet_in up to data, uint8_t[]. */
146     OFPRAW_OFPT10_PACKET_IN,
147     /* OFPT 1.1 (10): struct ofp11_packet_in, 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,
155
156     /* OFPT 1.0 (11): struct ofp10_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,
162
163     /* OFPT 1.0 (12): struct ofp_port_status, struct ofp10_phy_port. */
164     OFPRAW_OFPT10_PORT_STATUS,
165     /* OFPT 1.1-1.3 (12): struct ofp_port_status, struct ofp11_port. */
166     OFPRAW_OFPT11_PORT_STATUS,
167     /* OFPT 1.4+ (12): struct ofp_port_status, struct ofp14_port, uint8_t[8][]. */
168     OFPRAW_OFPT14_PORT_STATUS,
169
170     /* OFPT 1.0 (13): struct ofp10_packet_out, uint8_t[]. */
171     OFPRAW_OFPT10_PACKET_OUT,
172     /* OFPT 1.1+ (13): struct ofp11_packet_out, uint8_t[]. */
173     OFPRAW_OFPT11_PACKET_OUT,
174
175     /* OFPT 1.0 (14): struct ofp10_flow_mod, struct ofp_action_header[]. */
176     OFPRAW_OFPT10_FLOW_MOD,
177     /* OFPT 1.1+ (14): struct ofp11_flow_mod, struct ofp11_instruction[]. */
178     OFPRAW_OFPT11_FLOW_MOD,
179     /* NXT 1.0+ (13): struct nx_flow_mod, uint8_t[8][]. */
180     OFPRAW_NXT_FLOW_MOD,
181
182     /* OFPT 1.1+ (15): struct ofp11_group_mod, uint8_t[8][]. */
183     OFPRAW_OFPT11_GROUP_MOD,
184
185     /* OFPT 1.0 (15): struct ofp10_port_mod. */
186     OFPRAW_OFPT10_PORT_MOD,
187     /* OFPT 1.1-1.3 (16): struct ofp11_port_mod. */
188     OFPRAW_OFPT11_PORT_MOD,
189     /* OFPT 1.4+ (16): struct ofp14_port_mod, uint8_t[8][]. */
190     OFPRAW_OFPT14_PORT_MOD,
191
192     /* OFPT 1.1-1.3 (17): struct ofp11_table_mod. */
193     OFPRAW_OFPT11_TABLE_MOD,
194     /* OFPT 1.4+ (17): struct ofp14_table_mod, uint8_t[8][]. */
195     OFPRAW_OFPT14_TABLE_MOD,
196
197     /* OFPT 1.0 (18): void. */
198     OFPRAW_OFPT10_BARRIER_REQUEST,
199     /* OFPT 1.1+ (20): void. */
200     OFPRAW_OFPT11_BARRIER_REQUEST,
201
202     /* OFPT 1.0 (19): void. */
203     OFPRAW_OFPT10_BARRIER_REPLY,
204     /* OFPT 1.1+ (21): void. */
205     OFPRAW_OFPT11_BARRIER_REPLY,
206
207     /* OFPT 1.0 (20): struct ofp10_queue_get_config_request. */
208     OFPRAW_OFPT10_QUEUE_GET_CONFIG_REQUEST,
209     /* OFPT 1.1+ (22): struct ofp11_queue_get_config_request. */
210     OFPRAW_OFPT11_QUEUE_GET_CONFIG_REQUEST,
211
212     /* OFPT 1.0 (21): struct ofp10_queue_get_config_reply, uint8_t[8][]. */
213     OFPRAW_OFPT10_QUEUE_GET_CONFIG_REPLY,
214     /* OFPT 1.1+ (23): struct ofp11_queue_get_config_reply, uint8_t[8][]. */
215     OFPRAW_OFPT11_QUEUE_GET_CONFIG_REPLY,
216
217     /* OFPT 1.2+ (24): struct ofp12_role_request. */
218     OFPRAW_OFPT12_ROLE_REQUEST,
219     /* NXT 1.0+ (10): struct nx_role_request. */
220     OFPRAW_NXT_ROLE_REQUEST,
221
222     /* OFPT 1.2+ (25): struct ofp12_role_request. */
223     OFPRAW_OFPT12_ROLE_REPLY,
224     /* NXT 1.0+ (11): struct nx_role_request. */
225     OFPRAW_NXT_ROLE_REPLY,
226
227     /* OFPT 1.3+ (26): void. */
228     OFPRAW_OFPT13_GET_ASYNC_REQUEST,
229     /* OFPT 1.3+ (27): struct ofp13_async_config. */
230     OFPRAW_OFPT13_GET_ASYNC_REPLY,
231     /* OFPT 1.3+ (28): struct ofp13_async_config. */
232     OFPRAW_OFPT13_SET_ASYNC,
233     /* NXT 1.0+ (19): struct nx_async_config. */
234     OFPRAW_NXT_SET_ASYNC_CONFIG,
235
236     /* OFPT 1.3+ (29): struct ofp13_meter_mod, uint8_t[8][]. */
237     OFPRAW_OFPT13_METER_MOD,
238
239     /* OFPT 1.4+ (30): struct ofp14_role_status, uint8_t[8][]. */
240     OFPRAW_OFPT14_ROLE_STATUS,
241
242     /* OFPT 1.4+ (33): struct ofp14_bundle_ctrl_msg, uint8_t[8][]. */
243     OFPRAW_OFPT14_BUNDLE_CONTROL,
244
245     /* OFPT 1.4+ (34): struct ofp14_bundle_ctrl_msg, uint8_t[]. */
246     OFPRAW_OFPT14_BUNDLE_ADD_MESSAGE,
247
248 /* Standard statistics. */
249
250     /* OFPST 1.0+ (0): void. */
251     OFPRAW_OFPST_DESC_REQUEST,
252
253     /* OFPST 1.0+ (0): struct ofp_desc_stats. */
254     OFPRAW_OFPST_DESC_REPLY,
255
256     /* OFPST 1.0 (1): struct ofp10_flow_stats_request. */
257     OFPRAW_OFPST10_FLOW_REQUEST,
258     /* OFPST 1.1+ (1): struct ofp11_flow_stats_request, uint8_t[8][]. */
259     OFPRAW_OFPST11_FLOW_REQUEST,
260     /* NXST 1.0 (0): struct nx_flow_stats_request, uint8_t[8][]. */
261     OFPRAW_NXST_FLOW_REQUEST,
262
263     /* OFPST 1.0 (1): uint8_t[]. */
264     OFPRAW_OFPST10_FLOW_REPLY,
265     /* OFPST 1.1-1.2 (1): uint8_t[]. */
266     OFPRAW_OFPST11_FLOW_REPLY,
267     /* OFPST 1.3+ (1): uint8_t[]. */
268     OFPRAW_OFPST13_FLOW_REPLY,
269     /* NXST 1.0 (0): uint8_t[]. */
270     OFPRAW_NXST_FLOW_REPLY,
271
272     /* OFPST 1.0 (2): struct ofp10_flow_stats_request. */
273     OFPRAW_OFPST10_AGGREGATE_REQUEST,
274     /* OFPST 1.1+ (2): struct ofp11_flow_stats_request, uint8_t[8][]. */
275     OFPRAW_OFPST11_AGGREGATE_REQUEST,
276     /* NXST 1.0 (1): struct nx_flow_stats_request, uint8_t[8][]. */
277     OFPRAW_NXST_AGGREGATE_REQUEST,
278
279     /* OFPST 1.0+ (2): struct ofp_aggregate_stats_reply. */
280     OFPRAW_OFPST_AGGREGATE_REPLY,
281     /* NXST 1.0 (1): struct ofp_aggregate_stats_reply. */
282     OFPRAW_NXST_AGGREGATE_REPLY,
283
284     /* OFPST 1.0+ (3): void. */
285     OFPRAW_OFPST_TABLE_REQUEST,
286
287     /* OFPST 1.0 (3): struct ofp10_table_stats[]. */
288     OFPRAW_OFPST10_TABLE_REPLY,
289     /* OFPST 1.1 (3): struct ofp11_table_stats[]. */
290     OFPRAW_OFPST11_TABLE_REPLY,
291     /* OFPST 1.2 (3): struct ofp12_table_stats[]. */
292     OFPRAW_OFPST12_TABLE_REPLY,
293     /* OFPST 1.3+ (3): struct ofp13_table_stats[]. */
294     OFPRAW_OFPST13_TABLE_REPLY,
295
296     /* OFPST 1.0 (4): struct ofp10_port_stats_request. */
297     OFPRAW_OFPST10_PORT_REQUEST,
298     /* OFPST 1.1+ (4): struct ofp11_port_stats_request. */
299     OFPRAW_OFPST11_PORT_REQUEST,
300
301     /* OFPST 1.0 (4): struct ofp10_port_stats[]. */
302     OFPRAW_OFPST10_PORT_REPLY,
303     /* OFPST 1.1-1.2 (4): struct ofp11_port_stats[]. */
304     OFPRAW_OFPST11_PORT_REPLY,
305     /* OFPST 1.3 (4): struct ofp13_port_stats[]. */
306     OFPRAW_OFPST13_PORT_REPLY,
307     /* OFPST 1.4+ (4): uint8_t[8][]. */
308     OFPRAW_OFPST14_PORT_REPLY,
309
310     /* OFPST 1.0 (5): struct ofp10_queue_stats_request. */
311     OFPRAW_OFPST10_QUEUE_REQUEST,
312     /* OFPST 1.1+ (5): struct ofp11_queue_stats_request. */
313     OFPRAW_OFPST11_QUEUE_REQUEST,
314
315     /* OFPST 1.0 (5): struct ofp10_queue_stats[]. */
316     OFPRAW_OFPST10_QUEUE_REPLY,
317     /* OFPST 1.1-1.2 (5): struct ofp11_queue_stats[]. */
318     OFPRAW_OFPST11_QUEUE_REPLY,
319     /* OFPST 1.3 (5): struct ofp13_queue_stats[]. */
320     OFPRAW_OFPST13_QUEUE_REPLY,
321     /* OFPST 1.4+ (5): uint8_t[8][]. */
322     OFPRAW_OFPST14_QUEUE_REPLY,
323
324     /* OFPST 1.1+ (6): struct ofp11_group_stats_request. */
325     OFPRAW_OFPST11_GROUP_REQUEST,
326
327     /* OFPST 1.1-1.2 (6): uint8_t[8][]. */
328     OFPRAW_OFPST11_GROUP_REPLY,
329     /* OFPST 1.3+ (6): uint8_t[8][]. */
330     OFPRAW_OFPST13_GROUP_REPLY,
331
332     /* OFPST 1.1-1.4 (7): void. */
333     OFPRAW_OFPST11_GROUP_DESC_REQUEST,
334     /* OFPST 1.5+ (7): ovs_be32. */
335     OFPRAW_OFPST15_GROUP_DESC_REQUEST,
336
337     /* OFPST 1.1+ (7): uint8_t[8][]. */
338     OFPRAW_OFPST11_GROUP_DESC_REPLY,
339
340     /* OFPST 1.2+ (8): void. */
341     OFPRAW_OFPST12_GROUP_FEATURES_REQUEST,
342
343     /* OFPST 1.2+ (8): struct ofp12_group_features_stats. */
344     OFPRAW_OFPST12_GROUP_FEATURES_REPLY,
345
346     /* OFPST 1.3+ (9): struct ofp13_meter_multipart_request. */
347     OFPRAW_OFPST13_METER_REQUEST,
348
349     /* OFPST 1.3+ (9): uint8_t[8][]. */
350     OFPRAW_OFPST13_METER_REPLY,
351
352     /* OFPST 1.3+ (10): struct ofp13_meter_multipart_request. */
353     OFPRAW_OFPST13_METER_CONFIG_REQUEST,
354
355     /* OFPST 1.3+ (10): uint8_t[8][]. */
356     OFPRAW_OFPST13_METER_CONFIG_REPLY,
357
358     /* OFPST 1.3+ (11): void. */
359     OFPRAW_OFPST13_METER_FEATURES_REQUEST,
360
361     /* OFPST 1.3+ (11): struct ofp13_meter_features. */
362     OFPRAW_OFPST13_METER_FEATURES_REPLY,
363
364     /* OFPST 1.3+ (12): void. */
365     OFPRAW_OFPST13_TABLE_FEATURES_REQUEST,
366
367     /* OFPST 1.3+ (12): struct ofp13_table_features, uint8_t[8][]. */
368     OFPRAW_OFPST13_TABLE_FEATURES_REPLY,
369
370     /* OFPST 1.0-1.4 (13): void. */
371     OFPRAW_OFPST10_PORT_DESC_REQUEST,
372     /* OFPST 1.5+ (13): ovs_be32. */
373     OFPRAW_OFPST15_PORT_DESC_REQUEST,
374
375     /* OFPST 1.0 (13): struct ofp10_phy_port[]. */
376     OFPRAW_OFPST10_PORT_DESC_REPLY,
377     /* OFPST 1.1-1.3 (13): struct ofp11_port[]. */
378     OFPRAW_OFPST11_PORT_DESC_REPLY,
379     /* OFPST 1.4+ (13): uint8_t[8][]. */
380     OFPRAW_OFPST14_PORT_DESC_REPLY,
381
382 /* Nicira extension messages.
383  *
384  * Nicira extensions that correspond to standard OpenFlow messages are listed
385  * alongside the standard versions above. */
386
387     /* NXT 1.0 (12): struct nx_set_flow_format. */
388     OFPRAW_NXT_SET_FLOW_FORMAT,
389
390     /* NXT 1.0+ (15): struct nx_flow_mod_table_id. */
391     OFPRAW_NXT_FLOW_MOD_TABLE_ID,
392
393     /* NXT 1.0+ (16): struct nx_set_packet_in_format. */
394     OFPRAW_NXT_SET_PACKET_IN_FORMAT,
395
396     /* NXT 1.0+ (18): void. */
397     OFPRAW_NXT_FLOW_AGE,
398
399     /* NXT 1.0+ (20): struct nx_controller_id. */
400     OFPRAW_NXT_SET_CONTROLLER_ID,
401
402     /* NXT 1.0+ (21): struct nx_flow_monitor_cancel. */
403     OFPRAW_NXT_FLOW_MONITOR_CANCEL,
404
405     /* NXT 1.0+ (22): void. */
406     OFPRAW_NXT_FLOW_MONITOR_PAUSED,
407
408     /* NXT 1.0+ (23): void. */
409     OFPRAW_NXT_FLOW_MONITOR_RESUMED,
410
411 /* Nicira extension statistics.
412  *
413  * Nicira extension statistics that correspond to standard OpenFlow statistics
414  * are listed alongside the standard versions above. */
415
416     /* NXST 1.0 (2): uint8_t[8][]. */
417     OFPRAW_NXST_FLOW_MONITOR_REQUEST,
418
419     /* NXST 1.0 (2): uint8_t[8][]. */
420     OFPRAW_NXST_FLOW_MONITOR_REPLY,
421 };
422
423 /* Decoding messages into OFPRAW_* values. */
424 enum ofperr ofpraw_decode(enum ofpraw *, const struct ofp_header *);
425 enum ofpraw ofpraw_decode_assert(const struct ofp_header *);
426 enum ofperr ofpraw_pull(enum ofpraw *, struct ofpbuf *);
427 enum ofpraw ofpraw_pull_assert(struct ofpbuf *);
428
429 enum ofperr ofpraw_decode_partial(enum ofpraw *,
430                                   const struct ofp_header *, size_t length);
431
432 /* Encoding messages using OFPRAW_* values. */
433 struct ofpbuf *ofpraw_alloc(enum ofpraw, uint8_t ofp_version,
434                             size_t extra_tailroom);
435 struct ofpbuf *ofpraw_alloc_xid(enum ofpraw, uint8_t ofp_version,
436                                 ovs_be32 xid, size_t extra_tailroom);
437 struct ofpbuf *ofpraw_alloc_reply(enum ofpraw,
438                                   const struct ofp_header *request,
439                                   size_t extra_tailroom);
440 struct ofpbuf *ofpraw_alloc_stats_reply(const struct ofp_header *request,
441                                         size_t extra_tailroom);
442
443 void ofpraw_put(enum ofpraw, uint8_t ofp_version, struct ofpbuf *);
444 void ofpraw_put_xid(enum ofpraw, uint8_t ofp_version, ovs_be32 xid,
445                     struct ofpbuf *);
446 void ofpraw_put_reply(enum ofpraw, const struct ofp_header *request,
447                       struct ofpbuf *);
448 void ofpraw_put_stats_reply(const struct ofp_header *request, struct ofpbuf *);
449
450 /* Information about OFPRAW_* values. */
451 const char *ofpraw_get_name(enum ofpraw);
452 enum ofpraw ofpraw_stats_request_to_reply(enum ofpraw, uint8_t version);
453 \f
454 /* Semantic identifiers for OpenFlow messages.
455  *
456  * Each OFPTYPE_* enumeration constant represents one or more concrete format
457  * of OpenFlow message.  When two variants of a message have essentially the
458  * same meaning, they are assigned a single OFPTYPE_* value.
459  *
460  * The comments here must follow a stylized form because the "extract-ofp-msgs"
461  * program parses them at build time to generate data tables.  The format is
462  * simply to list each OFPRAW_* enumeration constant for a given OFPTYPE_*,
463  * each followed by a period. */
464 enum ofptype {
465     /* Immutable messages. */
466     OFPTYPE_HELLO,               /* OFPRAW_OFPT_HELLO. */
467     OFPTYPE_ERROR,               /* OFPRAW_OFPT_ERROR. */
468     OFPTYPE_ECHO_REQUEST,        /* OFPRAW_OFPT_ECHO_REQUEST. */
469     OFPTYPE_ECHO_REPLY,          /* OFPRAW_OFPT_ECHO_REPLY. */
470
471     /* Switch configuration messages. */
472     OFPTYPE_FEATURES_REQUEST,    /* OFPRAW_OFPT_FEATURES_REQUEST. */
473     OFPTYPE_FEATURES_REPLY,      /* OFPRAW_OFPT10_FEATURES_REPLY.
474                                   * OFPRAW_OFPT11_FEATURES_REPLY.
475                                   * OFPRAW_OFPT13_FEATURES_REPLY. */
476     OFPTYPE_GET_CONFIG_REQUEST,  /* OFPRAW_OFPT_GET_CONFIG_REQUEST. */
477     OFPTYPE_GET_CONFIG_REPLY,    /* OFPRAW_OFPT_GET_CONFIG_REPLY. */
478     OFPTYPE_SET_CONFIG,          /* OFPRAW_OFPT_SET_CONFIG. */
479
480     /* Asynchronous messages. */
481     OFPTYPE_PACKET_IN,           /* OFPRAW_OFPT10_PACKET_IN.
482                                   * OFPRAW_OFPT11_PACKET_IN.
483                                   * OFPRAW_OFPT12_PACKET_IN.
484                                   * OFPRAW_OFPT13_PACKET_IN.
485                                   * OFPRAW_NXT_PACKET_IN. */
486     OFPTYPE_FLOW_REMOVED,        /* OFPRAW_OFPT10_FLOW_REMOVED.
487                                   * OFPRAW_OFPT11_FLOW_REMOVED.
488                                   * OFPRAW_NXT_FLOW_REMOVED. */
489     OFPTYPE_PORT_STATUS,         /* OFPRAW_OFPT10_PORT_STATUS.
490                                   * OFPRAW_OFPT11_PORT_STATUS.
491                                   * OFPRAW_OFPT14_PORT_STATUS. */
492
493     /* Controller command messages. */
494     OFPTYPE_PACKET_OUT,          /* OFPRAW_OFPT10_PACKET_OUT.
495                                   * OFPRAW_OFPT11_PACKET_OUT. */
496     OFPTYPE_FLOW_MOD,            /* OFPRAW_OFPT10_FLOW_MOD.
497                                   * OFPRAW_OFPT11_FLOW_MOD.
498                                   * OFPRAW_NXT_FLOW_MOD. */
499     OFPTYPE_GROUP_MOD,           /* OFPRAW_OFPT11_GROUP_MOD. */
500     OFPTYPE_PORT_MOD,            /* OFPRAW_OFPT10_PORT_MOD.
501                                   * OFPRAW_OFPT11_PORT_MOD.
502                                   * OFPRAW_OFPT14_PORT_MOD. */
503     OFPTYPE_TABLE_MOD,           /* OFPRAW_OFPT11_TABLE_MOD.
504                                   * OFPRAW_OFPT14_TABLE_MOD. */
505
506     /* Barrier messages. */
507     OFPTYPE_BARRIER_REQUEST,     /* OFPRAW_OFPT10_BARRIER_REQUEST.
508                                   * OFPRAW_OFPT11_BARRIER_REQUEST. */
509     OFPTYPE_BARRIER_REPLY,       /* OFPRAW_OFPT10_BARRIER_REPLY.
510                                   * OFPRAW_OFPT11_BARRIER_REPLY. */
511
512     /* Queue Configuration messages. */
513     OFPTYPE_QUEUE_GET_CONFIG_REQUEST, /* OFPRAW_OFPT10_QUEUE_GET_CONFIG_REQUEST.
514                                        * OFPRAW_OFPT11_QUEUE_GET_CONFIG_REQUEST. */
515     OFPTYPE_QUEUE_GET_CONFIG_REPLY, /* OFPRAW_OFPT10_QUEUE_GET_CONFIG_REPLY.
516                                      * OFPRAW_OFPT11_QUEUE_GET_CONFIG_REPLY. */
517
518     /* Controller role change request messages. */
519     OFPTYPE_ROLE_REQUEST,         /* OFPRAW_OFPT12_ROLE_REQUEST.
520                                    * OFPRAW_NXT_ROLE_REQUEST. */
521     OFPTYPE_ROLE_REPLY,           /* OFPRAW_OFPT12_ROLE_REPLY.
522                                    * OFPRAW_NXT_ROLE_REPLY. */
523
524     /* Asynchronous message configuration. */
525     OFPTYPE_GET_ASYNC_REQUEST,    /* OFPRAW_OFPT13_GET_ASYNC_REQUEST. */
526     OFPTYPE_GET_ASYNC_REPLY,      /* OFPRAW_OFPT13_GET_ASYNC_REPLY. */
527     OFPTYPE_SET_ASYNC_CONFIG,     /* OFPRAW_NXT_SET_ASYNC_CONFIG.
528                                    * OFPRAW_OFPT13_SET_ASYNC. */
529
530     /* Meters and rate limiters configuration messages. */
531     OFPTYPE_METER_MOD,            /* OFPRAW_OFPT13_METER_MOD. */
532
533     /* Controller role change event messages. */
534     OFPTYPE_ROLE_STATUS,          /* OFPRAW_OFPT14_ROLE_STATUS. */
535
536     OFPTYPE_BUNDLE_CONTROL,       /* OFPRAW_OFPT14_BUNDLE_CONTROL. */
537
538     OFPTYPE_BUNDLE_ADD_MESSAGE,   /* OFPRAW_OFPT14_BUNDLE_ADD_MESSAGE. */
539
540     /* Statistics. */
541     OFPTYPE_DESC_STATS_REQUEST,      /* OFPRAW_OFPST_DESC_REQUEST. */
542     OFPTYPE_DESC_STATS_REPLY,        /* OFPRAW_OFPST_DESC_REPLY. */
543     OFPTYPE_FLOW_STATS_REQUEST,      /* OFPRAW_OFPST10_FLOW_REQUEST.
544                                       * OFPRAW_OFPST11_FLOW_REQUEST.
545                                       * OFPRAW_NXST_FLOW_REQUEST. */
546     OFPTYPE_FLOW_STATS_REPLY,        /* OFPRAW_OFPST10_FLOW_REPLY.
547                                       * OFPRAW_OFPST11_FLOW_REPLY.
548                                       * OFPRAW_OFPST13_FLOW_REPLY.
549                                       * OFPRAW_NXST_FLOW_REPLY. */
550     OFPTYPE_AGGREGATE_STATS_REQUEST, /* OFPRAW_OFPST10_AGGREGATE_REQUEST.
551                                       * OFPRAW_OFPST11_AGGREGATE_REQUEST.
552                                       * OFPRAW_NXST_AGGREGATE_REQUEST. */
553     OFPTYPE_AGGREGATE_STATS_REPLY,   /* OFPRAW_OFPST_AGGREGATE_REPLY.
554                                       * OFPRAW_NXST_AGGREGATE_REPLY. */
555     OFPTYPE_TABLE_STATS_REQUEST,     /* OFPRAW_OFPST_TABLE_REQUEST. */
556     OFPTYPE_TABLE_STATS_REPLY,       /* OFPRAW_OFPST10_TABLE_REPLY.
557                                       * OFPRAW_OFPST11_TABLE_REPLY.
558                                       * OFPRAW_OFPST12_TABLE_REPLY.
559                                       * OFPRAW_OFPST13_TABLE_REPLY. */
560     OFPTYPE_PORT_STATS_REQUEST,      /* OFPRAW_OFPST10_PORT_REQUEST.
561                                       * OFPRAW_OFPST11_PORT_REQUEST. */
562     OFPTYPE_PORT_STATS_REPLY,        /* OFPRAW_OFPST10_PORT_REPLY.
563                                       * OFPRAW_OFPST11_PORT_REPLY.
564                                       * OFPRAW_OFPST13_PORT_REPLY.
565                                       * OFPRAW_OFPST14_PORT_REPLY. */
566     OFPTYPE_QUEUE_STATS_REQUEST,     /* OFPRAW_OFPST10_QUEUE_REQUEST.
567                                       * OFPRAW_OFPST11_QUEUE_REQUEST. */
568     OFPTYPE_QUEUE_STATS_REPLY,       /* OFPRAW_OFPST10_QUEUE_REPLY.
569                                       * OFPRAW_OFPST11_QUEUE_REPLY.
570                                       * OFPRAW_OFPST13_QUEUE_REPLY.
571                                       * OFPRAW_OFPST14_QUEUE_REPLY. */
572
573     OFPTYPE_GROUP_STATS_REQUEST,     /* OFPRAW_OFPST11_GROUP_REQUEST. */
574
575     OFPTYPE_GROUP_STATS_REPLY,       /* OFPRAW_OFPST11_GROUP_REPLY.
576                                       * OFPRAW_OFPST13_GROUP_REPLY. */
577
578     OFPTYPE_GROUP_DESC_STATS_REQUEST, /* OFPRAW_OFPST11_GROUP_DESC_REQUEST.
579                                        * OFPRAW_OFPST15_GROUP_DESC_REQUEST. */
580
581     OFPTYPE_GROUP_DESC_STATS_REPLY,  /* OFPRAW_OFPST11_GROUP_DESC_REPLY. */
582
583     OFPTYPE_GROUP_FEATURES_STATS_REQUEST, /* OFPRAW_OFPST12_GROUP_FEATURES_REQUEST. */
584
585     OFPTYPE_GROUP_FEATURES_STATS_REPLY, /* OFPRAW_OFPST12_GROUP_FEATURES_REPLY. */
586
587     OFPTYPE_METER_STATS_REQUEST,     /* OFPRAW_OFPST13_METER_REQUEST. */
588
589     OFPTYPE_METER_STATS_REPLY,       /* OFPRAW_OFPST13_METER_REPLY. */
590
591     OFPTYPE_METER_CONFIG_STATS_REQUEST, /* OFPRAW_OFPST13_METER_CONFIG_REQUEST. */
592
593     OFPTYPE_METER_CONFIG_STATS_REPLY, /* OFPRAW_OFPST13_METER_CONFIG_REPLY. */
594
595     OFPTYPE_METER_FEATURES_STATS_REQUEST, /* OFPRAW_OFPST13_METER_FEATURES_REQUEST. */
596
597     OFPTYPE_METER_FEATURES_STATS_REPLY, /* OFPRAW_OFPST13_METER_FEATURES_REPLY. */
598
599     OFPTYPE_TABLE_FEATURES_STATS_REQUEST, /* OFPRAW_OFPST13_TABLE_FEATURES_REQUEST. */
600
601     OFPTYPE_TABLE_FEATURES_STATS_REPLY, /* OFPRAW_OFPST13_TABLE_FEATURES_REPLY. */
602
603     OFPTYPE_PORT_DESC_STATS_REQUEST, /* OFPRAW_OFPST10_PORT_DESC_REQUEST.
604                                       * OFPRAW_OFPST15_PORT_DESC_REQUEST. */
605
606     OFPTYPE_PORT_DESC_STATS_REPLY,   /* OFPRAW_OFPST10_PORT_DESC_REPLY.
607                                       * OFPRAW_OFPST11_PORT_DESC_REPLY.
608                                       * OFPRAW_OFPST14_PORT_DESC_REPLY. */
609
610     /* Nicira extensions. */
611     OFPTYPE_SET_FLOW_FORMAT,      /* OFPRAW_NXT_SET_FLOW_FORMAT. */
612     OFPTYPE_FLOW_MOD_TABLE_ID,    /* OFPRAW_NXT_FLOW_MOD_TABLE_ID. */
613     OFPTYPE_SET_PACKET_IN_FORMAT, /* OFPRAW_NXT_SET_PACKET_IN_FORMAT. */
614     OFPTYPE_FLOW_AGE,             /* OFPRAW_NXT_FLOW_AGE. */
615     OFPTYPE_SET_CONTROLLER_ID,    /* OFPRAW_NXT_SET_CONTROLLER_ID. */
616
617     /* Flow monitor extension. */
618     OFPTYPE_FLOW_MONITOR_STATS_REQUEST, /* OFPRAW_NXST_FLOW_MONITOR_REQUEST. */
619     OFPTYPE_FLOW_MONITOR_STATS_REPLY,   /* OFPRAW_NXST_FLOW_MONITOR_REPLY. */
620     OFPTYPE_FLOW_MONITOR_CANCEL,        /* OFPRAW_NXT_FLOW_MONITOR_CANCEL. */
621     OFPTYPE_FLOW_MONITOR_PAUSED,        /* OFPRAW_NXT_FLOW_MONITOR_PAUSED. */
622     OFPTYPE_FLOW_MONITOR_RESUMED,       /* OFPRAW_NXT_FLOW_MONITOR_RESUMED. */
623 };
624
625 /* Decoding messages into OFPTYPE_* values. */
626 enum ofperr ofptype_decode(enum ofptype *, const struct ofp_header *);
627 enum ofperr ofptype_pull(enum ofptype *, struct ofpbuf *);
628 enum ofptype ofptype_from_ofpraw(enum ofpraw);
629 \f
630 /* OpenFlow message properties. */
631 void ofpmsg_update_length(struct ofpbuf *);
632 const void *ofpmsg_body(const struct ofp_header *);
633 bool ofpmsg_is_stat_request(const struct ofp_header *);
634 \f
635 /* Multipart messages (aka "statistics").
636  *
637  * Individual OpenFlow messages are limited to 64 kB in size, but some messages
638  * need to be longer.  Therefore, multipart messages allow a longer message to
639  * be divided into multiple parts at some convenient boundary.  For example,
640  * limiting the response to a "flow dump" request to 64 kB would unreasonably
641  * limit the maximum number of flows in an OpenFlow switch, so a "flow dump" is
642  * expressed as a multipart request/reply pair, with the reply broken into
643  * pieces between flows.
644  *
645  * Multipart messages always consist of a request/reply pair.
646  *
647  * In OpenFlow 1.0, 1.1, and 1.2, requests must always fit in a single message,
648  * that is, only a multipart reply may have more than one part.  OpenFlow 1.3
649  * adds one multipart request.  This code does not yet support multipart
650  * requests. */
651
652 /* Encoding multipart replies.
653  *
654  * These functions are useful for multipart replies that might really require
655  * more than one message.  A multipart message that is known in advance to fit
656  * within 64 kB doesn't need any special treatment, so you might as well use
657  * the ofpraw_alloc_*() functions.
658  *
659  * These functions work with a "struct list" of "struct ofpbuf"s, each of
660  * which represents one part of a multipart message. */
661 void ofpmp_init(struct list *, const struct ofp_header *request);
662 struct ofpbuf *ofpmp_reserve(struct list *, size_t len);
663 void *ofpmp_append(struct list *, size_t len);
664 void ofpmp_postappend(struct list *, size_t start_ofs);
665
666 enum ofp_version ofpmp_version(struct list *);
667 enum ofpraw ofpmp_decode_raw(struct list *);
668
669 /* Decoding multipart replies. */
670 uint16_t ofpmp_flags(const struct ofp_header *);
671 bool ofpmp_more(const struct ofp_header *);
672
673 #endif /* ofp-msgs.h */