#include "hash.h"
#include "util.h"
-struct ofpbuf;
+struct dp_packet;
struct ds;
/* Tunnel information used in flow key and metadata. */
uint8_t ip_ttl;
ovs_be16 tp_src;
ovs_be16 tp_dst;
+ ovs_be16 gbp_id;
+ uint8_t gbp_flags;
+ uint8_t pad1[5]; /* Pad to 64 bits. */
};
/* Unfortunately, a "struct flow" sometimes has to handle OpenFlow port
static const uint8_t eth_addr_bfd[ETH_ADDR_LEN] OVS_UNUSED
= { 0x00, 0x23, 0x20, 0x00, 0x00, 0x01 };
-static inline bool eth_addr_is_broadcast(const uint8_t ea[6])
+static inline bool eth_addr_is_broadcast(const uint8_t ea[ETH_ADDR_LEN])
{
return (ea[0] & ea[1] & ea[2] & ea[3] & ea[4] & ea[5]) == 0xff;
}
-static inline bool eth_addr_is_multicast(const uint8_t ea[6])
+static inline bool eth_addr_is_multicast(const uint8_t ea[ETH_ADDR_LEN])
{
return ea[0] & 1;
}
-static inline bool eth_addr_is_local(const uint8_t ea[6])
+static inline bool eth_addr_is_local(const uint8_t ea[ETH_ADDR_LEN])
{
/* Local if it is either a locally administered address or a Nicira random
* address. */
return ea[0] & 2
|| (ea[0] == 0x00 && ea[1] == 0x23 && ea[2] == 0x20 && ea[3] & 0x80);
}
-static inline bool eth_addr_is_zero(const uint8_t ea[6])
+static inline bool eth_addr_is_zero(const uint8_t ea[ETH_ADDR_LEN])
{
return !(ea[0] | ea[1] | ea[2] | ea[3] | ea[4] | ea[5]);
}
bool eth_addr_is_reserved(const uint8_t ea[ETH_ADDR_LEN]);
bool eth_addr_from_string(const char *, uint8_t ea[ETH_ADDR_LEN]);
-void compose_rarp(struct ofpbuf *, const uint8_t eth_src[ETH_ADDR_LEN]);
+void compose_rarp(struct dp_packet *, const uint8_t eth_src[ETH_ADDR_LEN]);
-void eth_push_vlan(struct ofpbuf *, ovs_be16 tpid, ovs_be16 tci);
-void eth_pop_vlan(struct ofpbuf *);
+void eth_push_vlan(struct dp_packet *, ovs_be16 tpid, ovs_be16 tci);
+void eth_pop_vlan(struct dp_packet *);
-const char *eth_from_hex(const char *hex, struct ofpbuf **packetp);
+const char *eth_from_hex(const char *hex, struct dp_packet **packetp);
void eth_format_masked(const uint8_t eth[ETH_ADDR_LEN],
const uint8_t mask[ETH_ADDR_LEN], struct ds *s);
void eth_addr_bitand(const uint8_t src[ETH_ADDR_LEN],
const uint8_t mask[ETH_ADDR_LEN],
uint8_t dst[ETH_ADDR_LEN]);
-void set_mpls_lse(struct ofpbuf *, ovs_be32 label);
-void push_mpls(struct ofpbuf *packet, ovs_be16 ethtype, ovs_be32 lse);
-void pop_mpls(struct ofpbuf *, ovs_be16 ethtype);
+void set_mpls_lse(struct dp_packet *, ovs_be32 label);
+void push_mpls(struct dp_packet *packet, ovs_be16 ethtype, ovs_be32 lse);
+void pop_mpls(struct dp_packet *, ovs_be16 ethtype);
void set_mpls_lse_ttl(ovs_be32 *lse, uint8_t ttl);
void set_mpls_lse_tc(ovs_be32 *lse, uint8_t tc);
#define ETH_TYPE_IP 0x0800
#define ETH_TYPE_ARP 0x0806
+#define ETH_TYPE_TEB 0x6558
#define ETH_TYPE_VLAN_8021Q 0x8100
#define ETH_TYPE_VLAN ETH_TYPE_VLAN_8021Q
#define ETH_TYPE_VLAN_8021AD 0x88a8
ovs_16aligned_be32 ip_src;
ovs_16aligned_be32 ip_dst;
};
+
BUILD_ASSERT_DECL(IP_HEADER_LEN == sizeof(struct ip_header));
#define ICMP_HEADER_LEN 8
} frag;
ovs_16aligned_be32 gateway;
} icmp_fields;
- uint8_t icmp_data[0];
};
BUILD_ASSERT_DECL(ICMP_HEADER_LEN == sizeof(struct icmp_header));
uint8_t icmp6_type;
uint8_t icmp6_code;
ovs_be16 icmp6_cksum;
- uint8_t icmp6_data[0];
};
BUILD_ASSERT_DECL(ICMP6_HEADER_LEN == sizeof(struct icmp6_header));
+/* Neighbor Discovery option field.
+ * ND options are always a multiple of 8 bytes in size. */
+#define ND_OPT_LEN 8
+struct ovs_nd_opt {
+ uint8_t nd_opt_type; /* Values defined in icmp6.h */
+ uint8_t nd_opt_len; /* in units of 8 octets (the size of this struct) */
+ uint8_t nd_opt_data[6]; /* Ethernet address in the case of SLL or TLL options */
+};
+BUILD_ASSERT_DECL(ND_OPT_LEN == sizeof(struct ovs_nd_opt));
+
+/* Like struct nd_msg (from ndisc.h), but whereas that struct requires 32-bit
+ * alignment, this one only requires 16-bit alignment. */
+#define ND_MSG_LEN 24
+struct ovs_nd_msg {
+ struct icmp6_header icmph;
+ ovs_16aligned_be32 rco_flags;
+ union ovs_16aligned_in6_addr target;
+ struct ovs_nd_opt options[0];
+};
+BUILD_ASSERT_DECL(ND_MSG_LEN == sizeof(struct ovs_nd_msg));
+
/* The IPv6 flow label is in the lower 20 bits of the first 32-bit word. */
#define IPV6_LABEL_MASK 0x000fffff
|| dl_type == htons(ETH_TYPE_IPV6);
}
+/* Tunnel header */
#define GENEVE_CRIT_OPT_TYPE (1 << 7)
struct geneve_opt {
ovs_be16 opt_class;
uint8_t type;
-#ifdef LITTLE_ENDIAN
- uint8_t length:5;
- uint8_t r3:1;
- uint8_t r2:1;
- uint8_t r1:1;
-#else
+#ifdef WORDS_BIGENDIAN
uint8_t r1:1;
uint8_t r2:1;
uint8_t r3:1;
uint8_t length:5;
+#else
+ uint8_t length:5;
+ uint8_t r3:1;
+ uint8_t r2:1;
+ uint8_t r1:1;
#endif
uint8_t opt_data[];
};
+struct genevehdr {
+#ifdef WORDS_BIGENDIAN
+ uint8_t ver:2;
+ uint8_t opt_len:6;
+ uint8_t oam:1;
+ uint8_t critical:1;
+ uint8_t rsvd1:6;
+#else
+ uint8_t opt_len:6;
+ uint8_t ver:2;
+ uint8_t rsvd1:6;
+ uint8_t critical:1;
+ uint8_t oam:1;
+#endif
+ ovs_be16 proto_type;
+ ovs_16aligned_be32 vni;
+ struct geneve_opt options[];
+};
+
+/* GRE protocol header */
+struct gre_base_hdr {
+ ovs_be16 flags;
+ ovs_be16 protocol;
+};
+
+#define GRE_CSUM 0x8000
+#define GRE_ROUTING 0x4000
+#define GRE_KEY 0x2000
+#define GRE_SEQ 0x1000
+#define GRE_STRICT 0x0800
+#define GRE_REC 0x0700
+#define GRE_FLAGS 0x00F8
+#define GRE_VERSION 0x0007
+
+/* VXLAN protocol header */
+struct vxlanhdr {
+ ovs_16aligned_be32 vx_flags;
+ ovs_16aligned_be32 vx_vni;
+};
+
+#define VXLAN_FLAGS 0x08000000 /* struct vxlanhdr.vx_flags required value. */
+
void format_ipv6_addr(char *addr_str, const struct in6_addr *addr);
void print_ipv6_addr(struct ds *string, const struct in6_addr *addr);
void print_ipv6_masked(struct ds *string, const struct in6_addr *addr,
int ipv6_count_cidr_bits(const struct in6_addr *netmask);
bool ipv6_is_cidr(const struct in6_addr *netmask);
-void *eth_compose(struct ofpbuf *, const uint8_t eth_dst[ETH_ADDR_LEN],
+void *eth_compose(struct dp_packet *, const uint8_t eth_dst[ETH_ADDR_LEN],
const uint8_t eth_src[ETH_ADDR_LEN], uint16_t eth_type,
size_t size);
-void *snap_compose(struct ofpbuf *, const uint8_t eth_dst[ETH_ADDR_LEN],
+void *snap_compose(struct dp_packet *, const uint8_t eth_dst[ETH_ADDR_LEN],
const uint8_t eth_src[ETH_ADDR_LEN],
unsigned int oui, uint16_t snap_type, size_t size);
-void packet_set_ipv4(struct ofpbuf *, ovs_be32 src, ovs_be32 dst, uint8_t tos,
+void packet_set_ipv4(struct dp_packet *, ovs_be32 src, ovs_be32 dst, uint8_t tos,
uint8_t ttl);
-void packet_set_ipv6(struct ofpbuf *, uint8_t proto, const ovs_be32 src[4],
+void packet_set_ipv6(struct dp_packet *, uint8_t proto, const ovs_be32 src[4],
const ovs_be32 dst[4], uint8_t tc,
ovs_be32 fl, uint8_t hlmit);
-void packet_set_tcp_port(struct ofpbuf *, ovs_be16 src, ovs_be16 dst);
-void packet_set_udp_port(struct ofpbuf *, ovs_be16 src, ovs_be16 dst);
-void packet_set_sctp_port(struct ofpbuf *, ovs_be16 src, ovs_be16 dst);
+void packet_set_tcp_port(struct dp_packet *, ovs_be16 src, ovs_be16 dst);
+void packet_set_udp_port(struct dp_packet *, ovs_be16 src, ovs_be16 dst);
+void packet_set_sctp_port(struct dp_packet *, ovs_be16 src, ovs_be16 dst);
+void packet_set_nd(struct dp_packet *, const ovs_be32 target[4],
+ const uint8_t sll[6], const uint8_t tll[6]);
void packet_format_tcp_flags(struct ds *, uint16_t);
const char *packet_tcp_flag_to_string(uint32_t flag);
+void compose_arp(struct dp_packet *b, const uint8_t eth_src[ETH_ADDR_LEN],
+ ovs_be32 ip_src, ovs_be32 ip_dst);
#endif /* packets.h */