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