+/* Returns a bitmap of OpenFlow versions that are supported by at
+ * least one of the 'protocols'. */
+uint32_t
+ofputil_protocols_to_version_bitmap(enum ofputil_protocol protocols)
+{
+ uint32_t bitmap = 0;
+
+ for (; protocols; protocols = zero_rightmost_1bit(protocols)) {
+ enum ofputil_protocol protocol = rightmost_1bit(protocols);
+
+ bitmap |= 1u << ofputil_protocol_to_ofp_version(protocol);
+ }
+
+ return bitmap;
+}
+
+/* Returns the set of protocols that are supported on top of the
+ * OpenFlow versions included in 'bitmap'. */
+enum ofputil_protocol
+ofputil_protocols_from_version_bitmap(uint32_t bitmap)
+{
+ enum ofputil_protocol protocols = 0;
+
+ for (; bitmap; bitmap = zero_rightmost_1bit(bitmap)) {
+ enum ofp_version version = rightmost_1bit_idx(bitmap);
+
+ protocols |= ofputil_protocols_from_ofp_version(version);
+ }
+
+ return protocols;
+}
+