X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fpackets.h;h=7388152d580fdaab2f341b7082e1819a10dce623;hb=b2f2acd543f159ba984a00059892917933612a10;hp=33be891f034480ca288ba8f97e8cd19d9222208e;hpb=7aaeab4df24b7e9460705b1dad1010eef0354c50;p=sliver-openvswitch.git diff --git a/lib/packets.h b/lib/packets.h index 33be891f0..7388152d5 100644 --- a/lib/packets.h +++ b/lib/packets.h @@ -143,8 +143,6 @@ void compose_rarp(struct ofpbuf *, const uint8_t eth_src[ETH_ADDR_LEN]); void eth_push_vlan(struct ofpbuf *, ovs_be16 tci); void eth_pop_vlan(struct ofpbuf *); -uint16_t eth_mpls_depth(const struct ofpbuf *packet); - void set_ethertype(struct ofpbuf *packet, ovs_be16 eth_type); const char *eth_from_hex(const char *hex, struct ofpbuf **packetp); @@ -446,8 +444,8 @@ struct ip_header { uint8_t ip_ttl; uint8_t ip_proto; ovs_be16 ip_csum; - ovs_be32 ip_src; - ovs_be32 ip_dst; + ovs_16aligned_be32 ip_src; + ovs_16aligned_be32 ip_dst; }; BUILD_ASSERT_DECL(IP_HEADER_LEN == sizeof(struct ip_header)); @@ -465,12 +463,21 @@ struct icmp_header { ovs_be16 empty; ovs_be16 mtu; } frag; - ovs_be32 gateway; + ovs_16aligned_be32 gateway; } icmp_fields; uint8_t icmp_data[0]; }; BUILD_ASSERT_DECL(ICMP_HEADER_LEN == sizeof(struct icmp_header)); +#define SCTP_HEADER_LEN 12 +struct sctp_header { + ovs_be16 sctp_src; + ovs_be16 sctp_dst; + ovs_be32 sctp_vtag; + ovs_be32 sctp_csum; +}; +BUILD_ASSERT_DECL(SCTP_HEADER_LEN == sizeof(struct sctp_header)); + #define UDP_HEADER_LEN 8 struct udp_header { ovs_be16 udp_src; @@ -495,8 +502,8 @@ BUILD_ASSERT_DECL(UDP_HEADER_LEN == sizeof(struct udp_header)); struct tcp_header { ovs_be16 tcp_src; ovs_be16 tcp_dst; - ovs_be32 tcp_seq; - ovs_be32 tcp_ack; + ovs_16aligned_be32 tcp_seq; + ovs_16aligned_be32 tcp_ack; ovs_be16 tcp_ctl; ovs_be16 tcp_winsz; ovs_be16 tcp_csum; @@ -511,7 +518,6 @@ BUILD_ASSERT_DECL(TCP_HEADER_LEN == sizeof(struct tcp_header)); #define ARP_OP_RARP 3 #define ARP_ETH_HEADER_LEN 28 -OVS_PACKED( struct arp_eth_header { /* Generic members. */ ovs_be16 ar_hrd; /* Hardware type. */ @@ -522,12 +528,44 @@ struct arp_eth_header { /* Ethernet+IPv4 specific members. */ uint8_t ar_sha[ETH_ADDR_LEN]; /* Sender hardware address. */ - ovs_be32 ar_spa; /* Sender protocol address. */ + ovs_16aligned_be32 ar_spa; /* Sender protocol address. */ uint8_t ar_tha[ETH_ADDR_LEN]; /* Target hardware address. */ - ovs_be32 ar_tpa; /* Target protocol address. */ -}); + ovs_16aligned_be32 ar_tpa; /* Target protocol address. */ +}; BUILD_ASSERT_DECL(ARP_ETH_HEADER_LEN == sizeof(struct arp_eth_header)); +/* Like struct in6_addr, but whereas that struct requires 32-bit alignment on + * most implementations, this one only requires 16-bit alignment. */ +union ovs_16aligned_in6_addr { + ovs_be16 be16[8]; + ovs_16aligned_be32 be32[4]; +}; + +/* Like struct in6_hdr, but whereas that struct requires 32-bit alignment, this + * one only requires 16-bit alignment. */ +struct ovs_16aligned_ip6_hdr { + union { + struct ovs_16aligned_ip6_hdrctl { + ovs_16aligned_be32 ip6_un1_flow; + ovs_be16 ip6_un1_plen; + uint8_t ip6_un1_nxt; + uint8_t ip6_un1_hlim; + } ip6_un1; + uint8_t ip6_un2_vfc; + } ip6_ctlun; + union ovs_16aligned_in6_addr ip6_src; + union ovs_16aligned_in6_addr ip6_dst; +}; + +/* Like struct in6_frag, but whereas that struct requires 32-bit alignment, + * this one only requires 16-bit alignment. */ +struct ovs_16aligned_ip6_frag { + uint8_t ip6f_nxt; + uint8_t ip6f_reserved; + ovs_be16 ip6f_offlg; + ovs_16aligned_be32 ip6f_ident; +}; + /* The IPv6 flow label is in the lower 20 bits of the first 32-bit word. */ #define IPV6_LABEL_MASK 0x000fffff @@ -601,6 +639,7 @@ void packet_set_ipv6(struct ofpbuf *, uint8_t proto, const ovs_be32 src[4], 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); uint8_t packet_get_tcp_flags(const struct ofpbuf *, const struct flow *); void packet_format_tcp_flags(struct ds *, uint8_t);