/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#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_broadcast[ETH_ADDR_LEN] OVS_UNUSED
= { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+static const uint8_t eth_addr_zero[ETH_ADDR_LEN] OVS_UNUSED
+ = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
static const uint8_t eth_addr_stp[ETH_ADDR_LEN] OVS_UNUSED
= { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x00 };
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);
eth_type == htons(ETH_TYPE_MPLS_MCAST);
}
+static inline bool eth_type_vlan(ovs_be16 eth_type)
+{
+ return eth_type == htons(ETH_TYPE_VLAN_8021Q) ||
+ eth_type == htons(ETH_TYPE_VLAN_8021AD);
+}
+
+
/* Minimum value for an Ethernet type. Values below this are IEEE 802.2 frame
* lengths. */
#define ETH_TYPE_MIN 0x600
} frag;
ovs_16aligned_be32 gateway;
} icmp_fields;
- uint8_t icmp_data[0];
};
BUILD_ASSERT_DECL(ICMP_HEADER_LEN == sizeof(struct icmp_header));
};
BUILD_ASSERT_DECL(IGMP_HEADER_LEN == sizeof(struct igmp_header));
+#define IGMPV3_HEADER_LEN 8
+struct igmpv3_header {
+ uint8_t type;
+ uint8_t rsvr1;
+ ovs_be16 csum;
+ ovs_be16 rsvr2;
+ ovs_be16 ngrp;
+};
+BUILD_ASSERT_DECL(IGMPV3_HEADER_LEN == sizeof(struct igmpv3_header));
+
+#define IGMPV3_RECORD_LEN 8
+struct igmpv3_record {
+ uint8_t type;
+ uint8_t aux_len;
+ ovs_be16 nsrcs;
+ ovs_16aligned_be32 maddr;
+};
+BUILD_ASSERT_DECL(IGMPV3_RECORD_LEN == sizeof(struct igmpv3_record));
+
#define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* From RFC1112 */
#define IGMP_HOST_MEMBERSHIP_REPORT 0x12 /* Ditto */
#define IGMPV2_HOST_MEMBERSHIP_REPORT 0x16 /* V2 version of 0x12 */
#define IGMP_HOST_LEAVE_MESSAGE 0x17
#define IGMPV3_HOST_MEMBERSHIP_REPORT 0x22 /* V3 version of 0x12 */
+#define IGMPV3_MODE_IS_INCLUDE 1
+#define IGMPV3_MODE_IS_EXCLUDE 2
+#define IGMPV3_CHANGE_TO_INCLUDE_MODE 3
+#define IGMPV3_CHANGE_TO_EXCLUDE_MODE 4
+#define IGMPV3_ALLOW_NEW_SOURCES 5
+#define IGMPV3_BLOCK_OLD_SOURCES 6
+
#define SCTP_HEADER_LEN 12
struct sctp_header {
ovs_be16 sctp_src;
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));
uint8_t r2:1;
uint8_t r1:1;
#endif
- uint8_t opt_data[];
+ /* Option 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 */
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_nd(struct ofpbuf *, const ovs_be32 target[4],
+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 ofpbuf *b, const uint8_t eth_src[ETH_ADDR_LEN],
- ovs_be32 ip_src, ovs_be32 ip_dst);
+void compose_arp(struct dp_packet *, uint16_t arp_op,
+ const uint8_t arp_sha[ETH_ADDR_LEN],
+ const uint8_t arp_tha[ETH_ADDR_LEN], bool broadcast,
+ ovs_be32 arp_spa, ovs_be32 arp_tpa);
+uint32_t packet_csum_pseudoheader(const struct ip_header *);
#endif /* packets.h */