X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fpackets.h;h=78ccfe90dc1c8e18038f365dc2156e3e84f0e0ce;hb=ca261b65354f522ba43c823221763ca6f4604e2d;hp=848775419b8631bbef36951e496cc422f14111f8;hpb=b37e6334fd80a6460aabc95f05eb8ab68e5a82ed;p=openvswitch diff --git a/lib/packets.h b/lib/packets.h index 84877541..78ccfe90 100644 --- a/lib/packets.h +++ b/lib/packets.h @@ -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: * @@ -330,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)); @@ -354,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) @@ -392,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"; @@ -444,5 +463,9 @@ void *eth_compose(struct ofpbuf *, const uint8_t eth_dst[ETH_ADDR_LEN], void *snap_compose(struct ofpbuf *, 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, + uint8_t ttl); +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); #endif /* packets.h */