+/* Bucket for use in groups. */
+struct ofputil_bucket {
+ struct list list_node;
+ uint16_t weight; /* Relative weight, for "select" groups. */
+ ofp_port_t watch_port; /* Port whose state affects whether this bucket
+ * is live. Only required for fast failover
+ * groups. */
+ uint32_t watch_group; /* Group whose state affects whether this
+ * bucket is live. Only required for fast
+ * failover groups. */
+ struct ofpact *ofpacts; /* Series of "struct ofpact"s. */
+ size_t ofpacts_len; /* Length of ofpacts, in bytes. */
+};
+
+/* Protocol-independent group_mod. */
+struct ofputil_group_mod {
+ uint16_t command; /* One of OFPGC11_*. */
+ uint8_t type; /* One of OFPGT11_*. */
+ uint32_t group_id; /* Group identifier. */
+ struct list buckets; /* Contains "struct ofputil_bucket"s. */
+};
+
+struct bucket_counter {
+ uint64_t packet_count; /* Number of packets processed by bucket. */
+ uint64_t byte_count; /* Number of bytes processed by bucket. */
+};
+
+/* Group stats reply, independent of protocol. */
+struct ofputil_group_stats {
+ uint32_t group_id; /* Group identifier. */
+ uint32_t ref_count;
+ uint64_t packet_count; /* Packet count, UINT64_MAX if unknown. */
+ uint64_t byte_count; /* Byte count, UINT64_MAX if unknown. */
+ uint32_t duration_sec; /* UINT32_MAX if unknown. */
+ uint32_t duration_nsec;
+ uint32_t n_buckets;
+ struct bucket_counter *bucket_stats;
+};
+
+/* Group features reply, independent of protocol.
+ *
+ * Only OF1.2 and later support group features replies. */
+struct ofputil_group_features {
+ uint32_t types; /* Bitmap of OFPGT_* values supported. */
+ uint32_t capabilities; /* Bitmap of OFPGFC12_* capability supported. */
+ uint32_t max_groups[4]; /* Maximum number of groups for each type. */
+
+ /* Bitmaps of OFPAT_* that are supported. OF1.2+ actions only. */
+ uint32_t actions[4];
+};
+
+/* Group desc reply, independent of protocol. */
+struct ofputil_group_desc {
+ uint8_t type; /* One of OFPGT_*. */
+ uint32_t group_id; /* Group identifier. */
+ struct list buckets; /* Contains "struct ofputil_bucket"s. */
+};
+
+void ofputil_bucket_list_destroy(struct list *buckets);
+
+static inline bool
+ofputil_bucket_has_liveness(const struct ofputil_bucket *bucket)
+{
+ return (bucket->watch_port != OFPP_ANY ||
+ bucket->watch_group != OFPG_ANY);
+}
+
+struct ofpbuf *ofputil_encode_group_stats_request(enum ofp_version,
+ uint32_t group_id);
+enum ofperr ofputil_decode_group_stats_request(
+ const struct ofp_header *request, uint32_t *group_id);
+void ofputil_append_group_stats(struct list *replies,
+ const struct ofputil_group_stats *);
+struct ofpbuf *ofputil_encode_group_features_request(enum ofp_version);
+struct ofpbuf *ofputil_encode_group_features_reply(
+ const struct ofputil_group_features *, const struct ofp_header *request);
+void ofputil_decode_group_features_reply(const struct ofp_header *,
+ struct ofputil_group_features *);
+struct ofpbuf *ofputil_encode_group_mod(enum ofp_version ofp_version,
+ const struct ofputil_group_mod *gm);
+
+enum ofperr ofputil_decode_group_mod(const struct ofp_header *,
+ struct ofputil_group_mod *);
+
+int ofputil_decode_group_stats_reply(struct ofpbuf *,
+ struct ofputil_group_stats *);
+
+int ofputil_decode_group_desc_reply(struct ofputil_group_desc *,
+ struct ofpbuf *, enum ofp_version);
+
+void ofputil_append_group_desc_reply(const struct ofputil_group_desc *,
+ struct list *buckets,
+ struct list *replies);
+struct ofpbuf *ofputil_encode_group_desc_request(enum ofp_version);
+