40 #ifndef included_ip4_packet_h 41 #define included_ip4_packet_h 152 #define IP4_HEADER_FLAG_MORE_FRAGMENTS (1 << 13) 153 #define IP4_HEADER_FLAG_DONT_FRAGMENT (1 << 14) 154 #define IP4_HEADER_FLAG_CONGESTION (1 << 15) 180 u64 checksum_data_64[2];
181 u32 checksum_data_64_32[1];
188 u32 checksum_data_32[5];
194 #define IP4_VERSION_AND_HEADER_LENGTH_NO_OPTIONS \ 195 ((4 << 4) | (sizeof (ip4_header_t) / sizeof (u32))) 197 #define IP4_ROUTER_ALERT_OPTION 20 261 if (csum == 0 && save == 0xffff)
337 #define ip4_partial_header_checksum_x1(ip0,sum0) \ 339 if (BITS (ip_csum_t) > 32) \ 341 sum0 = ip0->checksum_data_64[0]; \ 342 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_64[1]); \ 343 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_64_32[0]); \ 347 sum0 = ip0->checksum_data_32[0]; \ 348 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[1]); \ 349 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[2]); \ 350 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[3]); \ 351 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[4]); \ 355 #define ip4_partial_header_checksum_x2(ip0,ip1,sum0,sum1) \ 357 if (BITS (ip_csum_t) > 32) \ 359 sum0 = ip0->checksum_data_64[0]; \ 360 sum1 = ip1->checksum_data_64[0]; \ 361 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_64[1]); \ 362 sum1 = ip_csum_with_carry (sum1, ip1->checksum_data_64[1]); \ 363 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_64_32[0]); \ 364 sum1 = ip_csum_with_carry (sum1, ip1->checksum_data_64_32[0]); \ 368 sum0 = ip0->checksum_data_32[0]; \ 369 sum1 = ip1->checksum_data_32[0]; \ 370 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[1]); \ 371 sum1 = ip_csum_with_carry (sum1, ip1->checksum_data_32[1]); \ 372 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[2]); \ 373 sum1 = ip_csum_with_carry (sum1, ip1->checksum_data_32[2]); \ 374 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[3]); \ 375 sum1 = ip_csum_with_carry (sum1, ip1->checksum_data_32[3]); \ 376 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[4]); \ 377 sum1 = ip_csum_with_carry (sum1, ip1->checksum_data_32[4]); \ 384 return (a->
data[0] & 0xf0) == 0xe0;
390 return (a->
as_u32) == 0xffffffff;
398 a->
as_u32 = clib_host_to_net_u32 ((0xe << 28) + g);
407 ethernet_address[0] = 0x01;
408 ethernet_address[1] = 0x00;
409 ethernet_address[2] = 0x5e;
410 ethernet_address[3] = d[1] & 0x7f;
411 ethernet_address[4] = d[2];
412 ethernet_address[5] = d[3];
435 u32 src0, dst0, src1, dst1;
static ip_dscp_t ip4_header_get_dscp(const ip4_header_t *ip4)
#define clib_memcpy_fast(a, b, c)
static void ip4_header_set_ecn_w_chksum(ip4_header_t *ip4, ip_ecn_t ecn)
static void ip4_header_set_dscp(ip4_header_t *ip4, ip_dscp_t dscp)
#define IP_PACKET_TC_FIELD_ECN_MASK
static uword ip4_address_is_multicast(const ip4_address_t *a)
struct _tcp_header tcp_header_t
static void ip4_header_clear_df(ip4_header_t *ip4)
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 int ip4_is_fragment(const ip4_header_t *i)
static uword ip4_header_checksum_is_valid(ip4_header_t *i)
static u16 ip4_get_fragment_more(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.
static void * ip4_next_header(ip4_header_t *i)
static void ip4_header_set_ecn(ip4_header_t *ip4, ip_ecn_t ecn)
static void ip4_header_set_df(ip4_header_t *ip4)
static void ip4_tcp_reply_x2(ip4_header_t *ip0, ip4_header_t *ip1, tcp_header_t *tcp0, tcp_header_t *tcp1)
#define IP4_HEADER_FLAG_MORE_FRAGMENTS
static void ip4_multicast_ethernet_address(u8 *ethernet_address, const ip4_address_t *a)
sll srl srl sll sra u16x4 i
static u16 ip4_get_fragment_offset(const ip4_header_t *i)
manual_print typedef address
enum ip_dscp_t_ ip_dscp_t
static void ip4_multicast_address_set_for_group(ip4_address_t *a, ip_multicast_group_t g)
static void ip4_addr_fib_init(ip4_address_fib_t *addr_fib, const ip4_address_t *address, u32 fib_index)
static u8 ip4_header_get_df(const ip4_header_t *ip4)
static int ip4_is_first_fragment(const ip4_header_t *i)
#define ip_csum_update(sum, old, new, type, field)
static ip_ecn_t ip4_header_get_ecn(const ip4_header_t *ip4)
static uword ip4_address_is_global_broadcast(const ip4_address_t *a)
#define IP4_HEADER_FLAG_DONT_FRAGMENT
static uword ip4_address_netmask_length(const ip4_address_t *a)
static int ip4_header_bytes(const ip4_header_t *i)
static ip_csum_t ip_incremental_checksum(ip_csum_t sum, void *_data, uword n_bytes)
static u16 ip4_header_checksum(ip4_header_t *i)
static u16 ip_csum_fold(ip_csum_t c)