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