+
+/* 'OFS' is a compile-time constant. */
+#define MINIFLOW_GET_TYPE(MF, TYPE, OFS) \
+ (MF->map & UINT64_C(1) << OFS / 4) \
+ ? ((OVS_FORCE const TYPE *) \
+ (MF->values + count_1bits(MF->map & ((UINT64_C(1) << OFS / 4) - 1)))) \
+ [OFS % 4 / sizeof(TYPE)] \
+ : 0
+
+static inline uint8_t
+miniflow_get_u8(const struct miniflow *flow, unsigned int ofs)
+{
+ return MINIFLOW_GET_TYPE(flow, uint8_t, ofs);
+}
+
+static inline uint16_t
+miniflow_get_u16(const struct miniflow *flow, unsigned int ofs)
+{
+ return MINIFLOW_GET_TYPE(flow, uint16_t, ofs);
+}
+
+/* Returns the ovs_be16 that would be at byte offset 'u8_ofs' if 'flow' were
+ * expanded into a "struct flow". */
+static inline ovs_be16
+miniflow_get_be16(const struct miniflow *flow, unsigned int ofs)
+{
+ return MINIFLOW_GET_TYPE(flow, ovs_be16, ofs);
+}
+
+static inline uint32_t
+miniflow_get_u32(const struct miniflow *flow, unsigned int ofs)
+{
+ return MINIFLOW_GET_TYPE(flow, uint32_t, ofs);
+}
+
+static inline ovs_be32
+miniflow_get_be32(const struct miniflow *flow, unsigned int ofs)
+{
+ return MINIFLOW_GET_TYPE(flow, ovs_be32, ofs);
+}
+
+#undef MINIFLOW_GET_TYPE
+
+/* Returns the VID within the vlan_tci member of the "struct flow" represented
+ * by 'flow'. */
+static inline uint16_t
+miniflow_get_vid(const struct miniflow *flow)
+{
+ ovs_be16 tci = miniflow_get_be16(flow, offsetof(struct flow, vlan_tci));
+ return vlan_tci_to_vid(tci);
+}
+
+/* Returns the VID mask within the vlan_tci member of the "struct
+ * flow_wildcards" represented by 'mask'. */
+static inline uint16_t
+minimask_get_vid_mask(const struct minimask *mask)
+{
+ return miniflow_get_vid(&mask->masks);
+}
+
+/* Returns the value of the "tcp_flags" field in 'flow'. */
+static inline uint16_t
+miniflow_get_tcp_flags(const struct miniflow *flow)
+{
+ return ntohs(miniflow_get_be16(flow, offsetof(struct flow, tcp_flags)));
+}
+