ofproto: Add support for sending OFPTYPE_ROLE_STATUS messages.
[sliver-openvswitch.git] / lib / ofp-util.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 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_UTIL_H
18 #define OFP_UTIL_H 1
19
20 #include <stdbool.h>
21 #include <stddef.h>
22 #include <stdint.h>
23 #include "classifier.h"
24 #include "compiler.h"
25 #include "flow.h"
26 #include "match.h"
27 #include "netdev.h"
28 #include "openflow/nicira-ext.h"
29 #include "openvswitch/types.h"
30 #include "type-props.h"
31
32 struct ofpbuf;
33 union ofp_action;
34
35 /* Port numbers. */
36 enum ofperr ofputil_port_from_ofp11(ovs_be32 ofp11_port,
37                                     ofp_port_t *ofp10_port);
38 ovs_be32 ofputil_port_to_ofp11(ofp_port_t ofp10_port);
39
40 enum ofperr ofputil_check_output_port(ofp_port_t ofp_port,
41                                       ofp_port_t max_ports);
42 bool ofputil_port_from_string(const char *, ofp_port_t *portp);
43 void ofputil_format_port(ofp_port_t port, struct ds *);
44 void ofputil_port_to_string(ofp_port_t, char namebuf[OFP_MAX_PORT_NAME_LEN],
45                             size_t bufsize);
46
47 /* Group numbers. */
48 enum { MAX_GROUP_NAME_LEN = INT_STRLEN(uint32_t) };
49 bool ofputil_group_from_string(const char *, uint32_t *group_id);
50 void ofputil_format_group(uint32_t group_id, struct ds *);
51 void ofputil_group_to_string(uint32_t group_id,
52                              char namebuf[MAX_GROUP_NAME_LEN + 1],
53                              size_t bufsize);
54
55 /* Converting OFPFW10_NW_SRC_MASK and OFPFW10_NW_DST_MASK wildcard bit counts
56  * to and from IP bitmasks. */
57 ovs_be32 ofputil_wcbits_to_netmask(int wcbits);
58 int ofputil_netmask_to_wcbits(ovs_be32 netmask);
59
60 /* Protocols.
61  *
62  * A "protocol" is an OpenFlow version plus, for some OpenFlow versions,
63  * a bit extra about the flow match format in use.
64  *
65  * These are arranged from most portable to least portable, or alternatively
66  * from least powerful to most powerful.  Protocols earlier on the list are
67  * more likely to be understood for the purpose of making requests, but
68  * protocol later on the list are more likely to accurately describe a flow
69  * within a switch.
70  *
71  * On any given OpenFlow connection, a single protocol is in effect at any
72  * given time.  These values use separate bits only because that makes it easy
73  * to test whether a particular protocol is within a given set of protocols and
74  * to implement set union and intersection.
75  */
76 enum ofputil_protocol {
77     /* OpenFlow 1.0 protocols.
78      *
79      * The "STD" protocols use the standard OpenFlow 1.0 flow format.
80      * The "NXM" protocols use the Nicira Extensible Match (NXM) flow format.
81      *
82      * The protocols with "TID" mean that the nx_flow_mod_table_id Nicira
83      * extension has been enabled.  The other protocols have it disabled.
84      */
85 #define OFPUTIL_P_NONE 0
86     OFPUTIL_P_OF10_STD     = 1 << 0,
87     OFPUTIL_P_OF10_STD_TID = 1 << 1,
88     OFPUTIL_P_OF10_NXM     = 1 << 2,
89     OFPUTIL_P_OF10_NXM_TID = 1 << 3,
90 #define OFPUTIL_P_OF10_STD_ANY (OFPUTIL_P_OF10_STD | OFPUTIL_P_OF10_STD_TID)
91 #define OFPUTIL_P_OF10_NXM_ANY (OFPUTIL_P_OF10_NXM | OFPUTIL_P_OF10_NXM_TID)
92 #define OFPUTIL_P_OF10_ANY (OFPUTIL_P_OF10_STD_ANY | OFPUTIL_P_OF10_NXM_ANY)
93
94     /* OpenFlow 1.1 protocol.
95      *
96      * We only support the standard OpenFlow 1.1 flow format.
97      *
98      * OpenFlow 1.1 always operates with an equivalent of the
99      * nx_flow_mod_table_id Nicira extension enabled, so there is no "TID"
100      * variant. */
101     OFPUTIL_P_OF11_STD     = 1 << 4,
102
103     /* OpenFlow 1.2+ protocols (only one variant each).
104      *
105      * These use the standard OpenFlow Extensible Match (OXM) flow format.
106      *
107      * OpenFlow 1.2+ always operates with an equivalent of the
108      * nx_flow_mod_table_id Nicira extension enabled, so there is no "TID"
109      * variant. */
110     OFPUTIL_P_OF12_OXM      = 1 << 5,
111     OFPUTIL_P_OF13_OXM      = 1 << 6,
112 #define OFPUTIL_P_ANY_OXM (OFPUTIL_P_OF12_OXM | OFPUTIL_P_OF13_OXM)
113
114 #define OFPUTIL_P_NXM_OF11_UP (OFPUTIL_P_OF10_NXM_ANY | OFPUTIL_P_OF11_STD | \
115                                OFPUTIL_P_ANY_OXM)
116
117 #define OFPUTIL_P_NXM_OXM_ANY (OFPUTIL_P_OF10_NXM_ANY | OFPUTIL_P_ANY_OXM)
118
119 #define OFPUTIL_P_OF11_UP (OFPUTIL_P_OF11_STD | OFPUTIL_P_ANY_OXM)
120
121 #define OFPUTIL_P_OF12_UP (OFPUTIL_P_ANY_OXM)
122
123 #define OFPUTIL_P_OF13_UP (OFPUTIL_P_OF13_OXM)
124
125     /* All protocols. */
126 #define OFPUTIL_P_ANY ((1 << 7) - 1)
127
128     /* Protocols in which a specific table may be specified in flow_mods. */
129 #define OFPUTIL_P_TID (OFPUTIL_P_OF10_STD_TID | \
130                        OFPUTIL_P_OF10_NXM_TID | \
131                        OFPUTIL_P_OF11_STD |     \
132                        OFPUTIL_P_ANY_OXM)
133 };
134
135 /* Protocols to use for flow dumps, from most to least preferred. */
136 extern enum ofputil_protocol ofputil_flow_dump_protocols[];
137 extern size_t ofputil_n_flow_dump_protocols;
138
139 enum ofputil_protocol ofputil_protocol_from_ofp_version(enum ofp_version);
140 enum ofputil_protocol ofputil_protocols_from_ofp_version(enum ofp_version);
141 enum ofp_version ofputil_protocol_to_ofp_version(enum ofputil_protocol);
142
143 bool ofputil_protocol_is_valid(enum ofputil_protocol);
144 enum ofputil_protocol ofputil_protocol_set_tid(enum ofputil_protocol,
145                                                bool enable);
146 enum ofputil_protocol ofputil_protocol_to_base(enum ofputil_protocol);
147 enum ofputil_protocol ofputil_protocol_set_base(
148     enum ofputil_protocol cur, enum ofputil_protocol new_base);
149
150 const char *ofputil_protocol_to_string(enum ofputil_protocol);
151 char *ofputil_protocols_to_string(enum ofputil_protocol);
152 enum ofputil_protocol ofputil_protocols_from_string(const char *);
153
154 void ofputil_format_version(struct ds *, enum ofp_version);
155 void ofputil_format_version_name(struct ds *, enum ofp_version);
156
157 /* A bitmap of version numbers
158  *
159  * Bit offsets correspond to ofp_version numbers which in turn correspond to
160  * wire-protocol numbers for Open Flow versions..  E.g. (1u << OFP11_VERSION)
161  * is the mask for Open Flow 1.1.  If the bit for a version is set then it is
162  * allowed, otherwise it is disallowed. */
163
164 void ofputil_format_version_bitmap(struct ds *msg, uint32_t bitmap);
165 void ofputil_format_version_bitmap_names(struct ds *msg, uint32_t bitmap);
166
167 uint32_t ofputil_protocols_to_version_bitmap(enum ofputil_protocol);
168 enum ofputil_protocol ofputil_protocols_from_version_bitmap(uint32_t bitmap);
169
170 /* Bitmap of OpenFlow versions that Open vSwitch supports. */
171 #define OFPUTIL_SUPPORTED_VERSIONS \
172     ((1u << OFP10_VERSION) | (1u << OFP12_VERSION) | (1u << OFP13_VERSION))
173
174 /* Bitmap of OpenFlow versions to enable by default (a subset of
175  * OFPUTIL_SUPPORTED_VERSIONS). */
176 #define OFPUTIL_DEFAULT_VERSIONS (1u << OFP10_VERSION)
177
178 enum ofputil_protocol ofputil_protocols_from_string(const char *s);
179
180 const char *ofputil_version_to_string(enum ofp_version ofp_version);
181 uint32_t ofputil_versions_from_string(const char *s);
182 uint32_t ofputil_versions_from_strings(char ** const s, size_t count);
183
184 bool ofputil_decode_hello(const struct ofp_header *,
185                           uint32_t *allowed_versions);
186 struct ofpbuf *ofputil_encode_hello(uint32_t version_bitmap);
187
188 struct ofpbuf *ofputil_encode_set_protocol(enum ofputil_protocol current,
189                                            enum ofputil_protocol want,
190                                            enum ofputil_protocol *next);
191
192 /* nx_flow_format */
193 struct ofpbuf *ofputil_encode_nx_set_flow_format(enum nx_flow_format);
194 enum ofputil_protocol ofputil_nx_flow_format_to_protocol(enum nx_flow_format);
195 bool ofputil_nx_flow_format_is_valid(enum nx_flow_format);
196 const char *ofputil_nx_flow_format_to_string(enum nx_flow_format);
197
198 /* Work with ofp10_match. */
199 void ofputil_wildcard_from_ofpfw10(uint32_t ofpfw, struct flow_wildcards *);
200 void ofputil_match_from_ofp10_match(const struct ofp10_match *,
201                                     struct match *);
202 void ofputil_normalize_match(struct match *);
203 void ofputil_normalize_match_quiet(struct match *);
204 void ofputil_match_to_ofp10_match(const struct match *, struct ofp10_match *);
205
206 /* Work with ofp11_match. */
207 enum ofperr ofputil_pull_ofp11_match(struct ofpbuf *, struct match *,
208                                      uint16_t *padded_match_len);
209 enum ofperr ofputil_match_from_ofp11_match(const struct ofp11_match *,
210                                            struct match *);
211 int ofputil_put_ofp11_match(struct ofpbuf *, const struct match *,
212                             enum ofputil_protocol);
213 void ofputil_match_to_ofp11_match(const struct match *, struct ofp11_match *);
214 int ofputil_match_typical_len(enum ofputil_protocol);
215
216 /* dl_type translation between OpenFlow and 'struct flow' format. */
217 ovs_be16 ofputil_dl_type_to_openflow(ovs_be16 flow_dl_type);
218 ovs_be16 ofputil_dl_type_from_openflow(ovs_be16 ofp_dl_type);
219
220 /* PACKET_IN. */
221 bool ofputil_packet_in_format_is_valid(enum nx_packet_in_format);
222 int ofputil_packet_in_format_from_string(const char *);
223 const char *ofputil_packet_in_format_to_string(enum nx_packet_in_format);
224 struct ofpbuf *ofputil_make_set_packet_in_format(enum ofp_version,
225                                                  enum nx_packet_in_format);
226
227 /* NXT_FLOW_MOD_TABLE_ID extension. */
228 struct ofpbuf *ofputil_make_flow_mod_table_id(bool flow_mod_table_id);
229
230 /* Protocol-independent flow_mod flags. */
231 enum ofputil_flow_mod_flags {
232     /* Flags that are maintained with a flow as part of its state.
233      *
234      * (OFPUTIL_FF_EMERG would be here too, if OVS supported it.) */
235     OFPUTIL_FF_SEND_FLOW_REM = 1 << 0, /* All versions. */
236     OFPUTIL_FF_NO_PKT_COUNTS = 1 << 1, /* OpenFlow 1.3+. */
237     OFPUTIL_FF_NO_BYT_COUNTS = 1 << 2, /* OpenFlow 1.3+. */
238 #define OFPUTIL_FF_STATE (OFPUTIL_FF_SEND_FLOW_REM      \
239                           | OFPUTIL_FF_NO_PKT_COUNTS    \
240                           | OFPUTIL_FF_NO_BYT_COUNTS)
241
242     /* Flags that affect flow_mod behavior but are not part of flow state. */
243     OFPUTIL_FF_CHECK_OVERLAP = 1 << 3, /* All versions. */
244     OFPUTIL_FF_EMERG         = 1 << 4, /* OpenFlow 1.0 only. */
245     OFPUTIL_FF_RESET_COUNTS  = 1 << 5, /* OpenFlow 1.2+. */
246 };
247
248 /* Protocol-independent flow_mod.
249  *
250  * The handling of cookies across multiple versions of OpenFlow is a bit
251  * confusing.  See DESIGN for the details. */
252 struct ofputil_flow_mod {
253     struct list list_node;    /* For queuing flow_mods. */
254
255     struct match match;
256     unsigned int priority;
257
258     /* Cookie matching.  The flow_mod affects only flows that have cookies that
259      * bitwise match 'cookie' bits in positions where 'cookie_mask has 1-bits.
260      *
261      * 'cookie_mask' should be zero for OFPFC_ADD flow_mods. */
262     ovs_be64 cookie;         /* Cookie bits to match. */
263     ovs_be64 cookie_mask;    /* 1-bit in each 'cookie' bit to match. */
264
265     /* Cookie changes.
266      *
267      * OFPFC_ADD uses 'new_cookie' as the new flow's cookie.  'new_cookie'
268      * should not be UINT64_MAX.
269      *
270      * OFPFC_MODIFY and OFPFC_MODIFY_STRICT have two cases:
271      *
272      *   - If one or more matching flows exist and 'modify_cookie' is true,
273      *     then the flow_mod changes the existing flows' cookies to
274      *     'new_cookie'.  'new_cookie' should not be UINT64_MAX.
275      *
276      *   - If no matching flow exists, 'new_cookie' is not UINT64_MAX, and
277      *     'cookie_mask' is 0, then the flow_mod adds a new flow with
278      *     'new_cookie' as its cookie.
279      */
280     ovs_be64 new_cookie;     /* New cookie to install or UINT64_MAX. */
281     bool modify_cookie;      /* Set cookie of existing flow to 'new_cookie'? */
282
283     uint8_t table_id;
284     uint16_t command;
285     uint16_t idle_timeout;
286     uint16_t hard_timeout;
287     uint32_t buffer_id;
288     ofp_port_t out_port;
289     uint32_t out_group;
290     enum ofputil_flow_mod_flags flags;
291     struct ofpact *ofpacts;     /* Series of "struct ofpact"s. */
292     size_t ofpacts_len;         /* Length of ofpacts, in bytes. */
293 };
294
295 enum ofperr ofputil_decode_flow_mod(struct ofputil_flow_mod *,
296                                     const struct ofp_header *,
297                                     enum ofputil_protocol,
298                                     struct ofpbuf *ofpacts);
299 struct ofpbuf *ofputil_encode_flow_mod(const struct ofputil_flow_mod *,
300                                        enum ofputil_protocol);
301
302 /* Flow stats or aggregate stats request, independent of protocol. */
303 struct ofputil_flow_stats_request {
304     bool aggregate;             /* Aggregate results? */
305     struct match match;
306     ovs_be64 cookie;
307     ovs_be64 cookie_mask;
308     ofp_port_t out_port;
309     uint32_t out_group;
310     uint8_t table_id;
311 };
312
313 enum ofperr ofputil_decode_flow_stats_request(
314     struct ofputil_flow_stats_request *, const struct ofp_header *);
315 struct ofpbuf *ofputil_encode_flow_stats_request(
316     const struct ofputil_flow_stats_request *, enum ofputil_protocol);
317
318 /* Flow stats reply, independent of protocol. */
319 struct ofputil_flow_stats {
320     struct match match;
321     ovs_be64 cookie;
322     uint8_t table_id;
323     uint32_t duration_sec;
324     uint32_t duration_nsec;
325     uint16_t priority;
326     uint16_t idle_timeout;
327     uint16_t hard_timeout;
328     int idle_age;               /* Seconds since last packet, -1 if unknown. */
329     int hard_age;               /* Seconds since last change, -1 if unknown. */
330     uint64_t packet_count;      /* Packet count, UINT64_MAX if unknown. */
331     uint64_t byte_count;        /* Byte count, UINT64_MAX if unknown. */
332     struct ofpact *ofpacts;
333     size_t ofpacts_len;
334     enum ofputil_flow_mod_flags flags;
335 };
336
337 int ofputil_decode_flow_stats_reply(struct ofputil_flow_stats *,
338                                     struct ofpbuf *msg,
339                                     bool flow_age_extension,
340                                     struct ofpbuf *ofpacts);
341 void ofputil_append_flow_stats_reply(const struct ofputil_flow_stats *,
342                                      struct list *replies);
343
344 /* Aggregate stats reply, independent of protocol. */
345 struct ofputil_aggregate_stats {
346     uint64_t packet_count;      /* Packet count, UINT64_MAX if unknown. */
347     uint64_t byte_count;        /* Byte count, UINT64_MAX if unknown. */
348     uint32_t flow_count;
349 };
350
351 struct ofpbuf *ofputil_encode_aggregate_stats_reply(
352     const struct ofputil_aggregate_stats *stats,
353     const struct ofp_header *request);
354 enum ofperr ofputil_decode_aggregate_stats_reply(
355     struct ofputil_aggregate_stats *,
356     const struct ofp_header *reply);
357
358 /* Flow removed message, independent of protocol. */
359 struct ofputil_flow_removed {
360     struct match match;
361     uint16_t priority;
362     ovs_be64 cookie;
363     uint8_t reason;             /* One of OFPRR_*. */
364     uint8_t table_id;           /* 255 if message didn't include table ID. */
365     uint32_t duration_sec;
366     uint32_t duration_nsec;
367     uint16_t idle_timeout;
368     uint16_t hard_timeout;
369     uint64_t packet_count;      /* Packet count, UINT64_MAX if unknown. */
370     uint64_t byte_count;        /* Byte count, UINT64_MAX if unknown. */
371 };
372
373 enum ofperr ofputil_decode_flow_removed(struct ofputil_flow_removed *,
374                                         const struct ofp_header *);
375 struct ofpbuf *ofputil_encode_flow_removed(const struct ofputil_flow_removed *,
376                                            enum ofputil_protocol);
377
378 /* Abstract packet-in message. */
379 struct ofputil_packet_in {
380     /* Packet data and metadata.
381      *
382      * To save bandwidth, in some cases a switch may send only the first
383      * several bytes of a packet, indicated by 'packet_len < total_len'.  When
384      * the full packet is included, 'packet_len == total_len'. */
385     const void *packet;
386     size_t packet_len;          /* Number of bytes in 'packet'. */
387     size_t total_len;           /* Size of packet, pre-truncation. */
388     struct flow_metadata fmd;
389
390     /* Identifies a buffer in the switch that contains the full packet, to
391      * allow the controller to reference it later without having to send the
392      * entire packet back to the switch.
393      *
394      * UINT32_MAX indicates that the packet is not buffered in the switch.  A
395      * switch should only use UINT32_MAX when it sends the entire packet. */
396     uint32_t buffer_id;
397
398     /* Reason that the packet-in is being sent. */
399     enum ofp_packet_in_reason reason;    /* One of OFPR_*. */
400
401     /* Information about the OpenFlow flow that triggered the packet-in.
402      *
403      * A packet-in triggered by a flow table miss has no associated flow.  In
404      * that case, 'cookie' is UINT64_MAX. */
405     uint8_t table_id;                    /* OpenFlow table ID. */
406     ovs_be64 cookie;                     /* Flow's cookie. */
407 };
408
409 enum ofperr ofputil_decode_packet_in(struct ofputil_packet_in *,
410                                      const struct ofp_header *);
411 struct ofpbuf *ofputil_encode_packet_in(const struct ofputil_packet_in *,
412                                         enum ofputil_protocol protocol,
413                                         enum nx_packet_in_format);
414
415 enum { OFPUTIL_PACKET_IN_REASON_BUFSIZE = INT_STRLEN(int) + 1 };
416 const char *ofputil_packet_in_reason_to_string(enum ofp_packet_in_reason,
417                                                char *reasonbuf,
418                                                size_t bufsize);
419 bool ofputil_packet_in_reason_from_string(const char *,
420                                           enum ofp_packet_in_reason *);
421
422 /* Abstract packet-out message.
423  *
424  * ofputil_decode_packet_out() will ensure that 'in_port' is a physical port
425  * (OFPP_MAX or less) or one of OFPP_LOCAL, OFPP_NONE, or OFPP_CONTROLLER. */
426 struct ofputil_packet_out {
427     const void *packet;         /* Packet data, if buffer_id == UINT32_MAX. */
428     size_t packet_len;          /* Length of packet data in bytes. */
429     uint32_t buffer_id;         /* Buffer id or UINT32_MAX if no buffer. */
430     ofp_port_t in_port;         /* Packet's input port. */
431     struct ofpact *ofpacts;     /* Actions. */
432     size_t ofpacts_len;         /* Size of ofpacts in bytes. */
433 };
434
435 enum ofperr ofputil_decode_packet_out(struct ofputil_packet_out *,
436                                       const struct ofp_header *,
437                                       struct ofpbuf *ofpacts);
438 struct ofpbuf *ofputil_encode_packet_out(const struct ofputil_packet_out *,
439                                          enum ofputil_protocol protocol);
440
441 enum ofputil_port_config {
442     /* OpenFlow 1.0 and 1.1 share these values for these port config bits. */
443     OFPUTIL_PC_PORT_DOWN    = 1 << 0, /* Port is administratively down. */
444     OFPUTIL_PC_NO_RECV      = 1 << 2, /* Drop all packets received by port. */
445     OFPUTIL_PC_NO_FWD       = 1 << 5, /* Drop packets forwarded to port. */
446     OFPUTIL_PC_NO_PACKET_IN = 1 << 6, /* No send packet-in msgs for port. */
447     /* OpenFlow 1.0 only. */
448     OFPUTIL_PC_NO_STP       = 1 << 1, /* No 802.1D spanning tree for port. */
449     OFPUTIL_PC_NO_RECV_STP  = 1 << 3, /* Drop received 802.1D STP packets. */
450     OFPUTIL_PC_NO_FLOOD     = 1 << 4, /* Do not include port when flooding. */
451     /* There are no OpenFlow 1.1-only bits. */
452 };
453
454 enum ofputil_port_state {
455     /* OpenFlow 1.0 and 1.1 share this values for these port state bits. */
456     OFPUTIL_PS_LINK_DOWN   = 1 << 0, /* No physical link present. */
457     /* OpenFlow 1.1 only. */
458     OFPUTIL_PS_BLOCKED     = 1 << 1, /* Port is blocked */
459     OFPUTIL_PS_LIVE        = 1 << 2, /* Live for Fast Failover Group. */
460     /* OpenFlow 1.0 only. */
461     OFPUTIL_PS_STP_LISTEN  = 0 << 8, /* Not learning or relaying frames. */
462     OFPUTIL_PS_STP_LEARN   = 1 << 8, /* Learning but not relaying frames. */
463     OFPUTIL_PS_STP_FORWARD = 2 << 8, /* Learning and relaying frames. */
464     OFPUTIL_PS_STP_BLOCK   = 3 << 8, /* Not part of spanning tree. */
465     OFPUTIL_PS_STP_MASK    = 3 << 8  /* Bit mask for OFPPS10_STP_* values. */
466 };
467
468 /* Abstract ofp10_phy_port or ofp11_port. */
469 struct ofputil_phy_port {
470     ofp_port_t port_no;
471     uint8_t hw_addr[OFP_ETH_ALEN];
472     char name[OFP_MAX_PORT_NAME_LEN];
473     enum ofputil_port_config config;
474     enum ofputil_port_state state;
475
476     /* NETDEV_F_* feature bitmasks. */
477     enum netdev_features curr;       /* Current features. */
478     enum netdev_features advertised; /* Features advertised by the port. */
479     enum netdev_features supported;  /* Features supported by the port. */
480     enum netdev_features peer;       /* Features advertised by peer. */
481
482     /* Speed. */
483     uint32_t curr_speed;        /* Current speed, in kbps. */
484     uint32_t max_speed;         /* Maximum supported speed, in kbps. */
485 };
486
487 enum ofputil_capabilities {
488     /* OpenFlow 1.0, 1.1, 1.2, and 1.3 share these capability values. */
489     OFPUTIL_C_FLOW_STATS     = 1 << 0,  /* Flow statistics. */
490     OFPUTIL_C_TABLE_STATS    = 1 << 1,  /* Table statistics. */
491     OFPUTIL_C_PORT_STATS     = 1 << 2,  /* Port statistics. */
492     OFPUTIL_C_IP_REASM       = 1 << 5,  /* Can reassemble IP fragments. */
493     OFPUTIL_C_QUEUE_STATS    = 1 << 6,  /* Queue statistics. */
494
495     /* OpenFlow 1.0 and 1.1 share this capability. */
496     OFPUTIL_C_ARP_MATCH_IP   = 1 << 7,  /* Match IP addresses in ARP pkts. */
497
498     /* OpenFlow 1.0 only. */
499     OFPUTIL_C_STP            = 1 << 3,  /* 802.1d spanning tree. */
500
501     /* OpenFlow 1.1, 1.2, and 1.3 share this capability. */
502     OFPUTIL_C_GROUP_STATS    = 1 << 4,  /* Group statistics. */
503
504     /* OpenFlow 1.2 and 1.3 share this capability */
505     OFPUTIL_C_PORT_BLOCKED   = 1 << 8,  /* Switch will block looping ports */
506 };
507
508 enum ofputil_action_bitmap {
509     OFPUTIL_A_OUTPUT         = 1 << 0,
510     OFPUTIL_A_SET_VLAN_VID   = 1 << 1,
511     OFPUTIL_A_SET_VLAN_PCP   = 1 << 2,
512     OFPUTIL_A_STRIP_VLAN     = 1 << 3,
513     OFPUTIL_A_SET_DL_SRC     = 1 << 4,
514     OFPUTIL_A_SET_DL_DST     = 1 << 5,
515     OFPUTIL_A_SET_NW_SRC     = 1 << 6,
516     OFPUTIL_A_SET_NW_DST     = 1 << 7,
517     OFPUTIL_A_SET_NW_ECN     = 1 << 8,
518     OFPUTIL_A_SET_NW_TOS     = 1 << 9,
519     OFPUTIL_A_SET_TP_SRC     = 1 << 10,
520     OFPUTIL_A_SET_TP_DST     = 1 << 11,
521     OFPUTIL_A_ENQUEUE        = 1 << 12,
522     OFPUTIL_A_COPY_TTL_OUT   = 1 << 13,
523     OFPUTIL_A_COPY_TTL_IN    = 1 << 14,
524     OFPUTIL_A_SET_MPLS_LABEL = 1 << 15,
525     OFPUTIL_A_SET_MPLS_TC    = 1 << 16,
526     OFPUTIL_A_SET_MPLS_TTL   = 1 << 17,
527     OFPUTIL_A_DEC_MPLS_TTL   = 1 << 18,
528     OFPUTIL_A_PUSH_VLAN      = 1 << 19,
529     OFPUTIL_A_POP_VLAN       = 1 << 20,
530     OFPUTIL_A_PUSH_MPLS      = 1 << 21,
531     OFPUTIL_A_POP_MPLS       = 1 << 22,
532     OFPUTIL_A_SET_QUEUE      = 1 << 23,
533     OFPUTIL_A_GROUP          = 1 << 24,
534     OFPUTIL_A_SET_NW_TTL     = 1 << 25,
535     OFPUTIL_A_DEC_NW_TTL     = 1 << 26,
536     OFPUTIL_A_SET_FIELD      = 1 << 27,
537 };
538
539 /* Abstract ofp_switch_features. */
540 struct ofputil_switch_features {
541     uint64_t datapath_id;       /* Datapath unique ID. */
542     uint32_t n_buffers;         /* Max packets buffered at once. */
543     uint8_t n_tables;           /* Number of tables supported by datapath. */
544     uint8_t auxiliary_id;       /* Identify auxiliary connections */
545     enum ofputil_capabilities capabilities;
546     enum ofputil_action_bitmap actions;
547 };
548
549 enum ofperr ofputil_decode_switch_features(const struct ofp_header *,
550                                            struct ofputil_switch_features *,
551                                            struct ofpbuf *);
552
553 struct ofpbuf *ofputil_encode_switch_features(
554     const struct ofputil_switch_features *, enum ofputil_protocol,
555     ovs_be32 xid);
556 void ofputil_put_switch_features_port(const struct ofputil_phy_port *,
557                                       struct ofpbuf *);
558 bool ofputil_switch_features_ports_trunc(struct ofpbuf *b);
559
560 /* phy_port helper functions. */
561 int ofputil_pull_phy_port(enum ofp_version ofp_version, struct ofpbuf *,
562                           struct ofputil_phy_port *);
563 size_t ofputil_count_phy_ports(uint8_t ofp_version, struct ofpbuf *);
564
565 /* Abstract ofp_port_status. */
566 struct ofputil_port_status {
567     enum ofp_port_reason reason;
568     struct ofputil_phy_port desc;
569 };
570
571 enum ofperr ofputil_decode_port_status(const struct ofp_header *,
572                                        struct ofputil_port_status *);
573 struct ofpbuf *ofputil_encode_port_status(const struct ofputil_port_status *,
574                                           enum ofputil_protocol);
575
576 /* Abstract ofp_port_mod. */
577 struct ofputil_port_mod {
578     ofp_port_t port_no;
579     uint8_t hw_addr[OFP_ETH_ALEN];
580     enum ofputil_port_config config;
581     enum ofputil_port_config mask;
582     enum netdev_features advertise;
583 };
584
585 enum ofperr ofputil_decode_port_mod(const struct ofp_header *,
586                                     struct ofputil_port_mod *);
587 struct ofpbuf *ofputil_encode_port_mod(const struct ofputil_port_mod *,
588                                        enum ofputil_protocol);
589
590 /* Abstract ofp_table_mod. */
591 struct ofputil_table_mod {
592     uint8_t table_id;         /* ID of the table, 0xff indicates all tables. */
593     uint32_t config;
594 };
595
596 enum ofperr ofputil_decode_table_mod(const struct ofp_header *,
597                                     struct ofputil_table_mod *);
598 struct ofpbuf *ofputil_encode_table_mod(const struct ofputil_table_mod *,
599                                        enum ofputil_protocol);
600
601 /* Meter band configuration for all supported band types. */
602 struct ofputil_meter_band {
603     uint16_t type;
604     uint8_t prec_level;         /* Non-zero if type == OFPMBT_DSCP_REMARK. */
605     uint32_t rate;
606     uint32_t burst_size;
607 };
608
609 struct ofputil_meter_band_stats {
610     uint64_t packet_count;
611     uint64_t byte_count;
612 };
613
614 struct ofputil_meter_config {
615     uint32_t meter_id;
616     uint16_t flags;
617     uint16_t n_bands;
618     struct ofputil_meter_band *bands;
619 };
620
621 /* Abstract ofp_meter_mod. */
622 struct ofputil_meter_mod {
623     uint16_t command;
624     struct ofputil_meter_config meter;
625 };
626
627 struct ofputil_meter_stats {
628     uint32_t meter_id;
629     uint32_t flow_count;
630     uint64_t packet_in_count;
631     uint64_t byte_in_count;
632     uint32_t duration_sec;
633     uint32_t duration_nsec;
634     uint16_t n_bands;
635     struct ofputil_meter_band_stats *bands;
636 };
637
638 struct ofputil_meter_features {
639     uint32_t max_meters;        /* Maximum number of meters. */
640     uint32_t band_types;        /* Can support max 32 band types. */
641     uint32_t capabilities;      /* Supported flags. */
642     uint8_t  max_bands;
643     uint8_t  max_color;
644 };
645
646 enum ofperr ofputil_decode_meter_mod(const struct ofp_header *,
647                                      struct ofputil_meter_mod *,
648                                      struct ofpbuf *bands);
649 struct ofpbuf *ofputil_encode_meter_mod(enum ofp_version,
650                                         const struct ofputil_meter_mod *);
651
652 void ofputil_decode_meter_features(const struct ofp_header *,
653                                    struct ofputil_meter_features *);
654 struct ofpbuf *ofputil_encode_meter_features_reply(const struct
655                                                    ofputil_meter_features *,
656                                                    const struct ofp_header *
657                                                    request);
658 void ofputil_decode_meter_request(const struct ofp_header *,
659                                   uint32_t *meter_id);
660
661 void ofputil_append_meter_config(struct list *replies,
662                                  const struct ofputil_meter_config *);
663
664 void ofputil_append_meter_stats(struct list *replies,
665                                 const struct ofputil_meter_stats *);
666
667 enum ofputil_meter_request_type {
668     OFPUTIL_METER_FEATURES,
669     OFPUTIL_METER_CONFIG,
670     OFPUTIL_METER_STATS
671 };
672
673 struct ofpbuf *ofputil_encode_meter_request(enum ofp_version,
674                                             enum ofputil_meter_request_type,
675                                             uint32_t meter_id);
676
677 int ofputil_decode_meter_stats(struct ofpbuf *,
678                                struct ofputil_meter_stats *,
679                                struct ofpbuf *bands);
680
681 int ofputil_decode_meter_config(struct ofpbuf *,
682                                 struct ofputil_meter_config *,
683                                 struct ofpbuf *bands);
684
685 /* Type for meter_id in ofproto provider interface, UINT32_MAX if invalid. */
686 typedef struct { uint32_t uint32; } ofproto_meter_id;
687
688 /* Abstract ofp_role_request and reply. */
689 struct ofputil_role_request {
690     enum ofp12_controller_role role;
691     bool have_generation_id;
692     uint64_t generation_id;
693 };
694
695 struct ofputil_role_status {
696     enum ofp12_controller_role role;
697     enum ofp14_controller_role_reason reason;
698     uint64_t generation_id;
699 };
700
701 enum ofperr ofputil_decode_role_message(const struct ofp_header *,
702                                         struct ofputil_role_request *);
703 struct ofpbuf *ofputil_encode_role_reply(const struct ofp_header *,
704                                          const struct ofputil_role_request *);
705
706 struct ofpbuf *ofputil_encode_role_status(
707                                 const struct ofputil_role_status *status,
708                                 enum ofputil_protocol protocol);
709
710 enum ofperr ofputil_decode_role_status(const struct ofp_header *oh,
711                                        struct ofputil_role_status *rs);
712 /* Abstract table stats.
713  *
714  * For now we use ofp12_table_stats as a superset of the other protocol
715  * versions' table stats. */
716
717 struct ofpbuf *ofputil_encode_table_stats_reply(
718     const struct ofp12_table_stats[], int n,
719     const struct ofp_header *request);
720
721 /* Queue configuration request. */
722 struct ofpbuf *ofputil_encode_queue_get_config_request(enum ofp_version,
723                                                        ofp_port_t port);
724 enum ofperr ofputil_decode_queue_get_config_request(const struct ofp_header *,
725                                                     ofp_port_t *port);
726
727 /* Queue configuration reply. */
728 struct ofputil_queue_config {
729     uint32_t queue_id;
730
731     /* Each of these optional values is expressed in tenths of a percent.
732      * Values greater than 1000 indicate that the feature is disabled.
733      * UINT16_MAX indicates that the value is omitted. */
734     uint16_t min_rate;
735     uint16_t max_rate;
736 };
737
738 struct ofpbuf *ofputil_encode_queue_get_config_reply(
739     const struct ofp_header *request);
740 void ofputil_append_queue_get_config_reply(
741     struct ofpbuf *reply, const struct ofputil_queue_config *);
742
743 enum ofperr ofputil_decode_queue_get_config_reply(struct ofpbuf *reply,
744                                                   ofp_port_t *);
745 int ofputil_pull_queue_get_config_reply(struct ofpbuf *reply,
746                                         struct ofputil_queue_config *);
747
748
749 /* Abstract nx_flow_monitor_request. */
750 struct ofputil_flow_monitor_request {
751     uint32_t id;
752     enum nx_flow_monitor_flags flags;
753     ofp_port_t out_port;
754     uint8_t table_id;
755     struct match match;
756 };
757
758 int ofputil_decode_flow_monitor_request(struct ofputil_flow_monitor_request *,
759                                         struct ofpbuf *msg);
760 void ofputil_append_flow_monitor_request(
761     const struct ofputil_flow_monitor_request *, struct ofpbuf *msg);
762
763 /* Abstract nx_flow_update. */
764 struct ofputil_flow_update {
765     enum nx_flow_update_event event;
766
767     /* Used only for NXFME_ADDED, NXFME_DELETED, NXFME_MODIFIED. */
768     enum ofp_flow_removed_reason reason;
769     uint16_t idle_timeout;
770     uint16_t hard_timeout;
771     uint8_t table_id;
772     ovs_be64 cookie;
773     struct match *match;
774     uint16_t priority;
775     struct ofpact *ofpacts;
776     size_t ofpacts_len;
777
778     /* Used only for NXFME_ABBREV. */
779     ovs_be32 xid;
780 };
781
782 int ofputil_decode_flow_update(struct ofputil_flow_update *,
783                                struct ofpbuf *msg, struct ofpbuf *ofpacts);
784 void ofputil_start_flow_update(struct list *replies);
785 void ofputil_append_flow_update(const struct ofputil_flow_update *,
786                                 struct list *replies);
787
788 /* Abstract nx_flow_monitor_cancel. */
789 uint32_t ofputil_decode_flow_monitor_cancel(const struct ofp_header *);
790 struct ofpbuf *ofputil_encode_flow_monitor_cancel(uint32_t id);
791
792 /* Encoding OpenFlow stats messages. */
793 void ofputil_append_port_desc_stats_reply(enum ofp_version ofp_version,
794                                           const struct ofputil_phy_port *pp,
795                                           struct list *replies);
796
797 /* Encoding simple OpenFlow messages. */
798 struct ofpbuf *make_echo_request(enum ofp_version);
799 struct ofpbuf *make_echo_reply(const struct ofp_header *rq);
800
801 struct ofpbuf *ofputil_encode_barrier_request(enum ofp_version);
802
803 const char *ofputil_frag_handling_to_string(enum ofp_config_flags);
804 bool ofputil_frag_handling_from_string(const char *, enum ofp_config_flags *);
805
806 \f
807 /* Actions. */
808
809 /* The type of an action.
810  *
811  * For each implemented OFPAT10_* and NXAST_* action type, there is a
812  * corresponding constant prefixed with OFPUTIL_, e.g.:
813  *
814  * OFPUTIL_OFPAT10_OUTPUT
815  * OFPUTIL_OFPAT10_SET_VLAN_VID
816  * OFPUTIL_OFPAT10_SET_VLAN_PCP
817  * OFPUTIL_OFPAT10_STRIP_VLAN
818  * OFPUTIL_OFPAT10_SET_DL_SRC
819  * OFPUTIL_OFPAT10_SET_DL_DST
820  * OFPUTIL_OFPAT10_SET_NW_SRC
821  * OFPUTIL_OFPAT10_SET_NW_DST
822  * OFPUTIL_OFPAT10_SET_NW_TOS
823  * OFPUTIL_OFPAT10_SET_TP_SRC
824  * OFPUTIL_OFPAT10_SET_TP_DST
825  * OFPUTIL_OFPAT10_ENQUEUE
826  * OFPUTIL_NXAST_RESUBMIT
827  * OFPUTIL_NXAST_SET_TUNNEL
828  * OFPUTIL_NXAST_SET_METADATA
829  * OFPUTIL_NXAST_SET_QUEUE
830  * OFPUTIL_NXAST_POP_QUEUE
831  * OFPUTIL_NXAST_REG_MOVE
832  * OFPUTIL_NXAST_REG_LOAD
833  * OFPUTIL_NXAST_NOTE
834  * OFPUTIL_NXAST_SET_TUNNEL64
835  * OFPUTIL_NXAST_MULTIPATH
836  * OFPUTIL_NXAST_BUNDLE
837  * OFPUTIL_NXAST_BUNDLE_LOAD
838  * OFPUTIL_NXAST_RESUBMIT_TABLE
839  * OFPUTIL_NXAST_OUTPUT_REG
840  * OFPUTIL_NXAST_LEARN
841  * OFPUTIL_NXAST_DEC_TTL
842  * OFPUTIL_NXAST_FIN_TIMEOUT
843  *
844  * (The above list helps developers who want to "grep" for these definitions.)
845  */
846 enum OVS_PACKED_ENUM ofputil_action_code {
847     OFPUTIL_ACTION_INVALID,
848 #define OFPAT10_ACTION(ENUM, STRUCT, NAME)             OFPUTIL_##ENUM,
849 #define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) OFPUTIL_##ENUM,
850 #define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME)   OFPUTIL_##ENUM,
851 #include "ofp-util.def"
852 };
853
854 /* The number of values of "enum ofputil_action_code". */
855 enum {
856 #define OFPAT10_ACTION(ENUM, STRUCT, NAME)             + 1
857 #define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) + 1
858 #define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME)   + 1
859     OFPUTIL_N_ACTIONS = 1
860 #include "ofp-util.def"
861 };
862
863 int ofputil_action_code_from_name(const char *);
864
865 void *ofputil_put_action(enum ofputil_action_code, struct ofpbuf *buf);
866
867 /* For each OpenFlow action <ENUM> that has a corresponding action structure
868  * struct <STRUCT>, this defines two functions:
869  *
870  *   void ofputil_init_<ENUM>(struct <STRUCT> *action);
871  *
872  *     Initializes the parts of 'action' that identify it as having type <ENUM>
873  *     and length 'sizeof *action' and zeros the rest.  For actions that have
874  *     variable length, the length used and cleared is that of struct <STRUCT>.
875  *
876  *  struct <STRUCT> *ofputil_put_<ENUM>(struct ofpbuf *buf);
877  *
878  *     Appends a new 'action', of length 'sizeof(struct <STRUCT>)', to 'buf',
879  *     initializes it with ofputil_init_<ENUM>(), and returns it.
880  */
881 #define OFPAT10_ACTION(ENUM, STRUCT, NAME)              \
882     void ofputil_init_##ENUM(struct STRUCT *);          \
883     struct STRUCT *ofputil_put_##ENUM(struct ofpbuf *);
884 #define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME)  \
885     void ofputil_init_##ENUM(struct STRUCT *);          \
886     struct STRUCT *ofputil_put_##ENUM(struct ofpbuf *);
887 #define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME)    \
888     void ofputil_init_##ENUM(struct STRUCT *);          \
889     struct STRUCT *ofputil_put_##ENUM(struct ofpbuf *);
890 #include "ofp-util.def"
891
892 #define OFP_ACTION_ALIGN 8      /* Alignment of ofp_actions. */
893
894 bool action_outputs_to_port(const union ofp_action *, ovs_be16 port);
895
896 enum ofperr ofputil_pull_actions(struct ofpbuf *, unsigned int actions_len,
897                                  union ofp_action **, size_t *);
898
899 bool ofputil_actions_equal(const union ofp_action *a, size_t n_a,
900                            const union ofp_action *b, size_t n_b);
901 union ofp_action *ofputil_actions_clone(const union ofp_action *, size_t n);
902
903 /* Handy utility for parsing flows and actions. */
904 bool ofputil_parse_key_value(char **stringp, char **keyp, char **valuep);
905
906 struct ofputil_port_stats {
907     ofp_port_t port_no;
908     struct netdev_stats stats;
909     uint32_t duration_sec;      /* UINT32_MAX if unknown. */
910     uint32_t duration_nsec;
911 };
912
913 struct ofpbuf *ofputil_encode_dump_ports_request(enum ofp_version ofp_version,
914                                                  ofp_port_t port);
915 void ofputil_append_port_stat(struct list *replies,
916                               const struct ofputil_port_stats *ops);
917 size_t ofputil_count_port_stats(const struct ofp_header *);
918 int ofputil_decode_port_stats(struct ofputil_port_stats *, struct ofpbuf *msg);
919 enum ofperr ofputil_decode_port_stats_request(const struct ofp_header *request,
920                                               ofp_port_t *ofp10_port);
921
922 struct ofputil_queue_stats_request {
923     ofp_port_t port_no;           /* OFPP_ANY means "all ports". */
924     uint32_t queue_id;
925 };
926
927 enum ofperr
928 ofputil_decode_queue_stats_request(const struct ofp_header *request,
929                                    struct ofputil_queue_stats_request *oqsr);
930 struct ofpbuf *
931 ofputil_encode_queue_stats_request(enum ofp_version ofp_version,
932                                    const struct ofputil_queue_stats_request *oqsr);
933
934 struct ofputil_queue_stats {
935     ofp_port_t port_no;
936     uint32_t queue_id;
937
938     /* Values of unsupported statistics are set to all-1-bits (UINT64_MAX). */
939     uint64_t tx_bytes;
940     uint64_t tx_packets;
941     uint64_t tx_errors;
942
943     /* UINT32_MAX if unknown. */
944     uint32_t duration_sec;
945     uint32_t duration_nsec;
946 };
947
948 size_t ofputil_count_queue_stats(const struct ofp_header *);
949 int ofputil_decode_queue_stats(struct ofputil_queue_stats *qs, struct ofpbuf *msg);
950 void ofputil_append_queue_stat(struct list *replies,
951                                const struct ofputil_queue_stats *oqs);
952
953 /* Bucket for use in groups. */
954 struct ofputil_bucket {
955     struct list list_node;
956     uint16_t weight;            /* Relative weight, for "select" groups. */
957     ofp_port_t watch_port;      /* Port whose state affects whether this bucket
958                                  * is live. Only required for fast failover
959                                  * groups. */
960     uint32_t watch_group;       /* Group whose state affects whether this
961                                  * bucket is live. Only required for fast
962                                  * failover groups. */
963     struct ofpact *ofpacts;     /* Series of "struct ofpact"s. */
964     size_t ofpacts_len;         /* Length of ofpacts, in bytes. */
965 };
966
967 /* Protocol-independent group_mod. */
968 struct ofputil_group_mod {
969     uint16_t command;             /* One of OFPGC11_*. */
970     uint8_t type;                 /* One of OFPGT11_*. */
971     uint32_t group_id;            /* Group identifier. */
972     struct list buckets;          /* Contains "struct ofputil_bucket"s. */
973 };
974
975 struct bucket_counter {
976     uint64_t packet_count;   /* Number of packets processed by bucket. */
977     uint64_t byte_count;     /* Number of bytes processed by bucket. */
978 };
979
980 /* Group stats reply, independent of protocol. */
981 struct ofputil_group_stats {
982     uint32_t group_id;    /* Group identifier. */
983     uint32_t ref_count;
984     uint64_t packet_count;      /* Packet count, UINT64_MAX if unknown. */
985     uint64_t byte_count;        /* Byte count, UINT64_MAX if unknown. */
986     uint32_t duration_sec;      /* UINT32_MAX if unknown. */
987     uint32_t duration_nsec;
988     uint32_t n_buckets;
989     struct bucket_counter *bucket_stats;
990 };
991
992 /* Group features reply, independent of protocol. */
993 struct ofputil_group_features {
994     uint32_t  types;           /* Bitmap of OFPGT_* values supported. */
995     uint32_t  capabilities;    /* Bitmap of OFPGFC12_* capability supported. */
996     uint32_t  max_groups[4];   /* Maximum number of groups for each type. */
997     uint32_t  actions[4];      /* Bitmaps of OFPAT_* that are supported. */
998 };
999
1000 /* Group desc reply, independent of protocol. */
1001 struct ofputil_group_desc {
1002     uint8_t type;               /* One of OFPGT_*. */
1003     uint32_t group_id;          /* Group identifier. */
1004     struct list buckets;        /* Contains "struct ofputil_bucket"s. */
1005 };
1006
1007 void ofputil_bucket_list_destroy(struct list *buckets);
1008
1009 struct ofpbuf *ofputil_encode_group_stats_request(enum ofp_version,
1010                                                   uint32_t group_id);
1011 enum ofperr ofputil_decode_group_stats_request(
1012     const struct ofp_header *request, uint32_t *group_id);
1013 void ofputil_append_group_stats(struct list *replies,
1014                                 const struct ofputil_group_stats *);
1015 struct ofpbuf *ofputil_encode_group_features_request(enum ofp_version);
1016 struct ofpbuf *ofputil_encode_group_features_reply(
1017     const struct ofputil_group_features *, const struct ofp_header *request);
1018 void ofputil_decode_group_features_reply(const struct ofp_header *,
1019                                          struct ofputil_group_features *);
1020 struct ofpbuf *ofputil_encode_group_mod(enum ofp_version ofp_version,
1021                                         const struct ofputil_group_mod *gm);
1022
1023 enum ofperr ofputil_decode_group_mod(const struct ofp_header *,
1024                                      struct ofputil_group_mod *);
1025
1026 int ofputil_decode_group_stats_reply(struct ofpbuf *,
1027                                      struct ofputil_group_stats *);
1028
1029 int ofputil_decode_group_desc_reply(struct ofputil_group_desc *,
1030                                     struct ofpbuf *, enum ofp_version);
1031
1032 void ofputil_append_group_desc_reply(const struct ofputil_group_desc *,
1033                                      struct list *buckets,
1034                                      struct list *replies);
1035 struct ofpbuf *ofputil_encode_group_desc_request(enum ofp_version);
1036
1037 #endif /* ofp-util.h */