|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
40 #ifndef included_ip4_packet_h
41 #define included_ip4_packet_h
107 #define IP4_HEADER_FLAG_MORE_FRAGMENTS (1 << 13)
108 #define IP4_HEADER_FLAG_DONT_FRAGMENT (1 << 14)
109 #define IP4_HEADER_FLAG_CONGESTION (1 << 15)
135 u64 checksum_data_64[2];
136 u32 checksum_data_64_32[1];
143 u32 checksum_data_32[5];
149 #define IP4_VERSION_AND_HEADER_LENGTH_NO_OPTIONS \
150 ((4 << 4) | (sizeof (ip4_header_t) / sizeof (u32)))
152 #define IP4_ROUTER_ALERT_OPTION 20
157 return clib_net_to_host_u16 (
i->flags_and_fragment_offset) & 0x1fff;
163 return clib_net_to_host_u16 (
i->flags_and_fragment_offset) &
170 return (
i->flags_and_fragment_offset &
177 return (
i->flags_and_fragment_offset &
192 return sizeof (
u32) * (
i->ip_version_and_header_length & 0xf);
211 int option_len = (
i->ip_version_and_header_length & 0xf) - 5;
218 sum += with_checksum ? iphdr[2] : *(
u16 *) (iphdr + 2);
250 sum = ((
u32) sum) + (sum >> 32);
304 sum = ((
u16) sum) + (sum >> 16);
305 sum = ((
u16) sum) + (sum >> 16);
377 ip4->flags_and_fragment_offset |=
384 ip4->flags_and_fragment_offset &=
391 return (! !(
ip4->flags_and_fragment_offset &
401 #define ip4_partial_header_checksum_x1(ip0,sum0) \
403 if (BITS (ip_csum_t) > 32) \
405 sum0 = ip0->checksum_data_64[0]; \
406 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_64[1]); \
407 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_64_32[0]); \
411 sum0 = ip0->checksum_data_32[0]; \
412 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[1]); \
413 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[2]); \
414 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[3]); \
415 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[4]); \
419 #define ip4_partial_header_checksum_x2(ip0,ip1,sum0,sum1) \
421 if (BITS (ip_csum_t) > 32) \
423 sum0 = ip0->checksum_data_64[0]; \
424 sum1 = ip1->checksum_data_64[0]; \
425 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_64[1]); \
426 sum1 = ip_csum_with_carry (sum1, ip1->checksum_data_64[1]); \
427 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_64_32[0]); \
428 sum1 = ip_csum_with_carry (sum1, ip1->checksum_data_64_32[0]); \
432 sum0 = ip0->checksum_data_32[0]; \
433 sum1 = ip1->checksum_data_32[0]; \
434 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[1]); \
435 sum1 = ip_csum_with_carry (sum1, ip1->checksum_data_32[1]); \
436 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[2]); \
437 sum1 = ip_csum_with_carry (sum1, ip1->checksum_data_32[2]); \
438 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[3]); \
439 sum1 = ip_csum_with_carry (sum1, ip1->checksum_data_32[3]); \
440 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[4]); \
441 sum1 = ip_csum_with_carry (sum1, ip1->checksum_data_32[4]); \
448 return (
a->data[0] & 0xf0) == 0xe0;
454 return (
a->as_u32) == 0xffffffff;
462 a->as_u32 = clib_host_to_net_u32 ((0xe << 28) + g);
469 const u8 *d =
a->as_u8;
471 ethernet_address[0] = 0x01;
472 ethernet_address[1] = 0x00;
473 ethernet_address[2] = 0x5e;
474 ethernet_address[3] = d[1] & 0x7f;
475 ethernet_address[4] = d[2];
476 ethernet_address[5] = d[3];
499 u32 src0, dst0, src1, dst1;
#define IP4_HEADER_FLAG_DONT_FRAGMENT
enum ip_dscp_t_ ip_dscp_t
static void ip4_header_set_ecn_w_chksum(ip4_header_t *ip4, ip_ecn_t ecn)
static u8 ip4_header_get_df(const ip4_header_t *ip4)
struct _tcp_header tcp_header_t
static uword ip4_header_checksum_is_valid(ip4_header_t *i)
static void ip4_tcp_reply_x1(ip4_header_t *ip0, tcp_header_t *tcp0)
static int ip4_get_fragment_offset_bytes(const ip4_header_t *i)
static uword ip4_address_is_global_broadcast(const ip4_address_t *a)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
static void ip4_header_set_df(ip4_header_t *ip4)
static uword ip4_address_is_multicast(const ip4_address_t *a)
static int ip4_is_fragment(const ip4_header_t *i)
static void ip4_addr_fib_init(ip4_address_fib_t *addr_fib, const ip4_address_t *address, u32 fib_index)
static void ip4_multicast_ethernet_address(u8 *ethernet_address, const ip4_address_t *a)
static u16 ip4_get_fragment_offset(const ip4_header_t *i)
#define static_always_inline
static void ip4_header_set_ecn(ip4_header_t *ip4, ip_ecn_t ecn)
static void ip4_header_set_dscp(ip4_header_t *ip4, ip_dscp_t dscp)
manual_print typedef address
static void ip4_multicast_address_set_for_group(ip4_address_t *a, ip_multicast_group_t g)
static u16 ip4_get_fragment_more(const ip4_header_t *i)
static int ip4_is_first_fragment(const ip4_header_t *i)
#define IP_PACKET_TC_FIELD_DSCP_BIT_SHIFT
IP DSCP bit shift The ECN occupies the 2 least significant bits of the TC field.
#define IP_PACKET_TC_FIELD_ECN_MASK
static ip_dscp_t ip4_header_get_dscp(const ip4_header_t *ip4)
static void ip4_header_set_ttl(ip4_header_t *ip4, u8 ttl)
static void ip4_tcp_reply_x2(ip4_header_t *ip0, ip4_header_t *ip1, tcp_header_t *tcp0, tcp_header_t *tcp1)
#define ip_csum_update(sum, old, new, type, field)
static ip_ecn_t ip4_header_get_ecn(const ip4_header_t *ip4)
static u16 ip4_header_checksum(ip4_header_t *i)
static int ip4_header_bytes(const ip4_header_t *i)
static u16 ip_csum_fold(ip_csum_t c)
#define IP4_HEADER_FLAG_MORE_FRAGMENTS
static void ip4_header_clear_df(ip4_header_t *ip4)
static_always_inline u16 ip4_header_checksum_inline(ip4_header_t *i, int with_checksum)
static u8 ip4_header_get_ttl(const ip4_header_t *ip4)
static void * ip4_next_header(ip4_header_t *i)