X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fpackets.h;h=16834a8b72b28a6711d8245852bd95aa6f7ae368;hb=6aa728e0efd1ed300c707af8fb54f9f3acacda10;hp=e727cc9a5da5a0263c155677553190d4bddc68f6;hpb=aad29cd1a1fb76aa68a9c404a47b66ac516149b5;p=sliver-openvswitch.git diff --git a/lib/packets.h b/lib/packets.h index e727cc9a5..16834a8b7 100644 --- a/lib/packets.h +++ b/lib/packets.h @@ -38,7 +38,7 @@ static const uint8_t eth_addr_broadcast[ETH_ADDR_LEN] OVS_UNUSED = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; static const uint8_t eth_addr_stp[ETH_ADDR_LEN] OVS_UNUSED - = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x01 }; + = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x00 }; static const uint8_t eth_addr_lacp[ETH_ADDR_LEN] OVS_UNUSED = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x02 }; @@ -132,6 +132,9 @@ void compose_benign_packet(struct ofpbuf *, const char *tag, const uint8_t eth_src[ETH_ADDR_LEN]); void eth_push_vlan(struct ofpbuf *, ovs_be16 tci); +void eth_pop_vlan(struct ofpbuf *); + +const char *eth_from_hex(const char *hex, struct ofpbuf **packetp); /* Example: * @@ -291,6 +294,11 @@ ip_is_cidr(ovs_be32 netmask) uint32_t x = ~ntohl(netmask); return !(x & (x + 1)); } +static inline bool +ip_is_multicast(ovs_be32 ip) +{ + return (ip & htonl(0xf0000000)) == htonl(0xe0000000); +} int ip_count_cidr_bits(ovs_be32 netmask); void ip_format_masked(ovs_be32 ip, ovs_be32 mask, struct ds *); @@ -325,11 +333,23 @@ struct ip_header { }; BUILD_ASSERT_DECL(IP_HEADER_LEN == sizeof(struct ip_header)); -#define ICMP_HEADER_LEN 4 +#define ICMP_HEADER_LEN 8 struct icmp_header { uint8_t icmp_type; uint8_t icmp_code; ovs_be16 icmp_csum; + union { + struct { + ovs_be16 id; + ovs_be16 seq; + } echo; + struct { + ovs_be16 empty; + ovs_be16 mtu; + } frag; + ovs_be32 gateway; + } icmp_fields; + uint8_t icmp_data[0]; }; BUILD_ASSERT_DECL(ICMP_HEADER_LEN == sizeof(struct icmp_header)); @@ -349,6 +369,7 @@ BUILD_ASSERT_DECL(UDP_HEADER_LEN == sizeof(struct udp_header)); #define TCP_ACK 0x10 #define TCP_URG 0x20 +#define TCP_CTL(flags, offset) (htons((flags) | ((offset) << 12))) #define TCP_FLAGS(tcp_ctl) (ntohs(tcp_ctl) & 0x003f) #define TCP_OFFSET(tcp_ctl) (ntohs(tcp_ctl) >> 12) @@ -387,6 +408,9 @@ struct arp_eth_header { } __attribute__((packed)); BUILD_ASSERT_DECL(ARP_ETH_HEADER_LEN == sizeof(struct arp_eth_header)); +/* The IPv6 flow label is in the lower 20 bits of the first 32-bit word. */ +#define IPV6_LABEL_MASK 0x000fffff + /* Example: * * char *string = "1 ::1 2";