7 #ifndef ODP_FRAGREASS_PP_IP_H_
8 #define ODP_FRAGREASS_PP_IP_H_
10 #include <odp/helper/ip.h>
12 #define IP_HDR_LEN_MIN ODPH_IPV4HDR_LEN
13 #define IP_HDR_LEN_MAX 60
14 #define IP_IHL_MIN ODPH_IPV4HDR_IHL_MIN
16 #define IP_OCTET_MAX ((1U << 14U) - 1U)
17 #define IP_FRAGOFF_MAX 8192
19 #define IP_FRAG_RESV 0x8000
20 #define IP_FRAG_DONT 0x4000
21 #define IP_FRAG_MORE 0x2000
22 #define IP_FRAG_MASK 0x1fff
24 #define BYTES_TO_OCTS(bytes) (((bytes) + 7U) / 8U)
25 #define OCTS_TO_BYTES(bytes) ((bytes) * 8)
26 #define WORDS_TO_BYTES(words) ((words) * 4)
33 static inline void ipv4hdr_init(odph_ipv4hdr_t *h)
50 static inline uint8_t ipv4hdr_ihl_words(odph_ipv4hdr_t h)
52 return ODPH_IPV4HDR_IHL(h.ver_ihl);
62 static inline uint8_t ipv4hdr_ihl(odph_ipv4hdr_t h)
64 return WORDS_TO_BYTES(ipv4hdr_ihl_words(h));
73 static inline void ipv4hdr_set_ihl_words(odph_ipv4hdr_t *h, uint8_t ihl)
75 h->ver_ihl = (ODPH_IPV4HDR_VER(h->ver_ihl) << 4)
76 | ODPH_IPV4HDR_IHL(ihl);
86 static inline bool ipv4hdr_dont_fragment(odph_ipv4hdr_t h)
97 static inline void ipv4hdr_set_dont_fragment(odph_ipv4hdr_t *h,
bool df)
112 static inline bool ipv4hdr_more_fragments(odph_ipv4hdr_t h)
123 static inline void ipv4hdr_set_more_fragments(odph_ipv4hdr_t *h,
bool mf)
138 static inline bool ipv4hdr_is_fragment(odph_ipv4hdr_t h)
150 static inline uint16_t ipv4hdr_fragment_offset_oct(odph_ipv4hdr_t h)
161 static inline void ipv4hdr_set_fragment_offset_oct(odph_ipv4hdr_t *h,
165 & ~IP_FRAG_MASK) | offset);
175 static inline uint16_t ipv4hdr_payload_len(odph_ipv4hdr_t h)
178 uint32_t header_size = ipv4hdr_ihl(h);
180 return (uint16_t)(packet_len >= header_size ? (packet_len - header_size)
191 static inline uint16_t ipv4hdr_payload_len_oct(odph_ipv4hdr_t h)
193 return BYTES_TO_OCTS(ipv4hdr_payload_len(h));
202 static inline void ipv4hdr_set_payload_len(odph_ipv4hdr_t *h, uint16_t len)
218 static inline uint16_t ipv4hdr_reass_payload_len(odph_ipv4hdr_t h)
220 uint16_t fragment_offset_oct;
222 if (ipv4hdr_more_fragments(h))
225 fragment_offset_oct = ipv4hdr_fragment_offset_oct(h);
226 return OCTS_TO_BYTES(fragment_offset_oct) + ipv4hdr_payload_len(h);
240 static inline uint16_t ipv4hdr_reass_payload_len_oct(odph_ipv4hdr_t h)
242 uint16_t fragment_offset_oct;
244 if (ipv4hdr_more_fragments(h))
247 fragment_offset_oct = ipv4hdr_fragment_offset_oct(h);
248 return fragment_offset_oct + ipv4hdr_payload_len_oct(h);
odp_u16be_t odp_cpu_to_be_16(uint16_t cpu16)
Convert cpu native uint16_t to 16bit big endian.
uint16_t odp_be_to_cpu_16(odp_u16be_t be16)
Convert 16bit big endian to cpu native uint16_t.