parse_vlan(struct ofpbuf *b, struct flow *flow)
{
struct qtag_prefix {
- uint16_t eth_type; /* ETH_TYPE_VLAN */
- uint16_t tci;
+ ovs_be16 eth_type; /* ETH_TYPE_VLAN */
+ ovs_be16 tci;
};
- if (b->size >= sizeof(struct qtag_prefix) + sizeof(uint16_t)) {
+ if (b->size >= sizeof(struct qtag_prefix) + sizeof(ovs_be16)) {
struct qtag_prefix *qp = ofpbuf_pull(b, sizeof *qp);
flow->dl_vlan = qp->tci & htons(VLAN_VID_MASK);
flow->dl_vlan_pcp = (ntohs(qp->tci) & VLAN_PCP_MASK) >> VLAN_PCP_SHIFT;
}
}
-static uint16_t
+static ovs_be16
parse_ethertype(struct ofpbuf *b)
{
struct llc_snap_header *llc;
- uint16_t proto;
+ ovs_be16 proto;
- proto = *(uint16_t *) ofpbuf_pull(b, sizeof proto);
+ proto = *(ovs_be16 *) ofpbuf_pull(b, sizeof proto);
if (ntohs(proto) >= ODP_DL_TYPE_ETH2_CUTOFF) {
return proto;
}
return llc->snap.snap_type;
}
-/* 'tun_id' is in network byte order, while 'in_port' is in host byte order.
- * These byte orders are the same as they are in struct odp_flow_key.
- *
- * Initializes packet header pointers as follows:
+/* Initializes 'flow' members from 'packet', 'tun_id', and 'in_port.
+ * Initializes 'packet' header pointers as follows:
*
* - packet->l2 to the start of the Ethernet header.
*
* present and has a correct length, and otherwise NULL.
*/
int
-flow_extract(struct ofpbuf *packet, uint32_t tun_id, uint16_t in_port,
+flow_extract(struct ofpbuf *packet, ovs_be32 tun_id, uint16_t in_port,
struct flow *flow)
{
struct ofpbuf b = *packet;
void
flow_from_match(const struct ofp_match *match, bool tun_id_from_cookie,
- uint64_t cookie, struct flow *flow, uint32_t *flow_wildcards)
+ ovs_be64 cookie, struct flow *flow, uint32_t *flow_wildcards)
{
uint32_t wildcards = ntohl(match->wildcards);
struct ofpbuf;
struct flow {
- uint32_t tun_id; /* Encapsulating tunnel ID. */
- uint32_t nw_src; /* IP source address. */
- uint32_t nw_dst; /* IP destination address. */
+ ovs_be32 tun_id; /* Encapsulating tunnel ID. */
+ ovs_be32 nw_src; /* IP source address. */
+ ovs_be32 nw_dst; /* IP destination address. */
uint16_t in_port; /* Input switch port. */
- uint16_t dl_vlan; /* Input VLAN. */
- uint16_t dl_type; /* Ethernet frame type. */
- uint16_t tp_src; /* TCP/UDP source port. */
- uint16_t tp_dst; /* TCP/UDP destination port. */
+ ovs_be16 dl_vlan; /* Input VLAN. */
+ ovs_be16 dl_type; /* Ethernet frame type. */
+ ovs_be16 tp_src; /* TCP/UDP source port. */
+ ovs_be16 tp_dst; /* TCP/UDP destination port. */
uint8_t dl_src[6]; /* Ethernet source address. */
uint8_t dl_dst[6]; /* Ethernet destination address. */
uint8_t nw_proto; /* IP protocol or low 8 bits of ARP opcode. */
BUILD_ASSERT_DECL(sizeof(((struct flow *)0)->nw_tos) == 1);
BUILD_ASSERT_DECL(sizeof(struct flow) == FLOW_SIG_SIZE + FLOW_PAD_SIZE);
-int flow_extract(struct ofpbuf *, uint32_t tun_id, uint16_t in_port,
+int flow_extract(struct ofpbuf *, ovs_be32 tun_id, uint16_t in_port,
struct flow *);
void flow_extract_stats(const struct flow *flow, struct ofpbuf *packet,
struct odp_flow_stats *stats);
void flow_to_match(const struct flow *, uint32_t wildcards, bool tun_id_cookie,
struct ofp_match *);
void flow_from_match(const struct ofp_match *, bool tun_id_from_cookie,
- uint64_t cookie, struct flow *, uint32_t *wildcards);
+ ovs_be64 cookie, struct flow *, uint32_t *wildcards);
char *flow_to_string(const struct flow *);
void flow_format(struct ds *, const struct flow *);
void flow_print(FILE *, const struct flow *);
/* Information on wildcards for a flow, as a supplement to struct flow. */
struct flow_wildcards {
- uint32_t wildcards; /* enum ofp_flow_wildcards (in host order). */
- uint32_t nw_src_mask; /* 1-bit in each significant nw_src bit. */
- uint32_t nw_dst_mask; /* 1-bit in each significant nw_dst bit. */
+ uint32_t wildcards; /* enum ofp_flow_wildcards. */
+ ovs_be32 nw_src_mask; /* 1-bit in each significant nw_src bit. */
+ ovs_be32 nw_dst_mask; /* 1-bit in each significant nw_dst bit. */
};
/* Given the wildcard bit count in bits 'shift' through 'shift + 5' (inclusive)
* is exact match, 1 ignores the LSB, 2 ignores the 2 least-significant bits,
* ..., 32 and higher wildcard the entire field. This is the *opposite* of the
* usual convention where e.g. /24 indicates that 8 bits (not 24 bits) are
- * wildcarded.
- *
- * 'wildcards' is in host byte order. The return value is in network byte
- * order. */
-static inline uint32_t
+ * wildcarded. */
+static inline ovs_be32
flow_nw_bits_to_mask(uint32_t wildcards, int shift)
{
wildcards = (wildcards >> shift) & 0x3f;