17 #include <netinet/in.h>
31 #define IP_MAX_MTU ETHER_MAX_MTU
32 #define TTL_DEFAULT 64
35 #define DEFAULT_IPV4_HDR_SIZE 20
36 #define IPv4_VER_LEN_VALUE ((IPv4_VERSION << 4) | (sizeof(struct cne_ipv4_hdr) / 4))
44 uint64_t ip_ver_error;
46 uint64_t vec_pool_empty;
47 uint64_t ip_invalid_src_addr;
48 uint64_t ip_checksum_error;
49 uint64_t route_lookup_failed;
50 uint64_t ip_forward_failed;
51 uint64_t ip_reassemble_failed;
52 uint64_t ip_proto_invalid;
53 uint64_t ip_mbuf_too_small;
54 uint64_t ip_option_invalid;
55 uint64_t ip_mforward_pkts;
56 uint64_t ip_mforward_failed;
57 uint64_t ip_mlookup_failed;
58 uint64_t ip_forwarding_disabled;
62 uint8_t ip_forwarding;
65 struct ipfwd_info *fwd_info;
66 struct ipv4_stats stats;
70 } __cne_cache_aligned;
72 #define IPv4(a, b, c, d) \
73 ((uint32_t)(((a)&0xff) << 24) | (((b)&0xff) << 16) | (((c)&0xff) << 8) | ((d)&0xff))
97 #define _ISFRAG(off) ((off) & (_OFF_MF | _OFF_MASK))
98 #define _OFF_MASK 0x1fff
99 #define _OFF_MF 0x2000
100 #define _OFF_DF 0x4000
103 struct ipv4_overlay {
121 #define MAX_TIMESTAMP_SIZE 40
122 #define MAX_OPTION_SIZE MAX_TIMESTAMP_SIZE
125 #define __netmask(_ip) \
126 (((_ip) == 0UL) ? 0UL \
127 : IN_CLASSA((_ip)) ? IN_CLASSA_NET \
128 : IN_CLASSB((_ip)) ? IN_CLASSB_NET \
129 : IN_CLASSC((_ip)) ? IN_CLASSC_NET \
130 : IN_CLASSD((_ip)) ? IN_CLASSD_NET \
133 #define __netbytes(_ip) \
134 ((uint8_t)(((_ip) == 0UL) ? 0 \
135 : IN_CLASSA((_ip)) ? 1 \
136 : IN_CLASSB((_ip)) ? 2 \
137 : IN_CLASSC((_ip)) ? 3 \
138 : IN_CLASSD((_ip)) ? 4 \
166 cksum = (int32_t)(hdr->
hdr_checksum ^ 0xFFFF) + (int32_t)htobe16(((1 << 8) ^ 0xFFFF));
194 #if CNET_IP4_DUMP_ENABLED
195 #define IP4_DUMP(ip) \
197 cne_printf("[cyan]([orange]%s[cyan]:[orange]%d[cyan]) ", __func__, __LINE__); \
198 cnet_ipv4_dump(NULL, ip); \
201 #define IP4_DUMP(ip) \
CNDP_API int cnet_ipv4_stats_dump(struct stk_s *stk)
Dump the IPv4 statistics.
CNDP_API void cnet_ipv4_dump(const char *msg, struct cne_ipv4_hdr *ip)
Dump information about IPv4 header.