44 sum = (sum & 0xFFFF) + (sum >> 16);
59 sum += clib_host_to_net_u16 (IP_PROTOCOL_UDP);
60 sum += clib_host_to_net_u16 (length);
64 sum = (sum & 0xFFFF) + (sum >> 16);
67 return ((
u16) (~sum));
74 register const u16 *sp;
93 phu.ph.ph_len = clib_host_to_net_u32 (len);
94 phu.ph.ph_nxt = IP_PROTOCOL_UDP;
97 for (i = 0; i <
sizeof (phu.pa) /
sizeof (phu.pa[0]); i++)
100 sp = (
const u16 *) up;
102 for (i = 0; i < (len & ~1); i += 2)
106 sum += clib_host_to_net_u16 ((*(
const u8 *) sp) << 8);
109 sum = (sum & 0xffff) + (sum >> 16);
139 uh->
src_port = clib_host_to_net_u16 (sp);
140 uh->
dst_port = clib_host_to_net_u16 (dp);
141 uh->
length = clib_host_to_net_u16 (udp_len);
152 clib_warning (
"src %U and dst %U IP have different AFI! Discarding!",
184 ih =
pkt_push_ip (vm, b, sip, dip, IP_PROTOCOL_UDP, 1);
185 b->
flags |= VNET_BUFFER_F_OFFLOAD_UDP_CKSUM;
192 ih =
pkt_push_ip (vm, b, sip, dip, IP_PROTOCOL_UDP, 0);
195 if (udpsum == (
u16) ~ 0)
201 b->
flags &= ~(VNET_BUFFER_F_IS_IP4 | VNET_BUFFER_F_IS_IP6);
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
u16 udp_checksum(udp_header_t *uh, u32 udp_len, void *ih, u8 version)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
u16 udp_ip4_checksum(const void *b, u32 len, u8 *src, u8 *dst)
#define ip_addr_version(_a)
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
void * pkt_push_udp(vlib_main_t *vm, vlib_buffer_t *b, u16 sp, u16 dp)
void * pkt_push_ip(vlib_main_t *vm, vlib_buffer_t *b, ip_address_t *src, ip_address_t *dst, u32 proto, u8 csum_offload)
u16 udp_ip6_checksum(ip6_header_t *ip6, udp_header_t *up, u32 len)
pool_header_t * ph(void *p)
GDB callable function: ph - call pool_header - get pool header.
static void * vlib_buffer_push_ip6(vlib_main_t *vm, vlib_buffer_t *b, ip6_address_t *src, ip6_address_t *dst, int proto)
Push IPv6 header to buffer.
vl_api_address_union_t src_address
void * pkt_push_udp_and_ip(vlib_main_t *vm, vlib_buffer_t *b, u16 sp, u16 dp, ip_address_t *sip, ip_address_t *dip, u8 csum_offload)
sll srl srl sll sra u16x4 i
#define clib_warning(format, args...)
u8 * format_ip_address(u8 *s, va_list *args)
static void * vlib_buffer_push_uninit(vlib_buffer_t *b, u8 size)
Prepend uninitialized data to buffer.
VLIB buffer representation.
void * pkt_push_ecm_hdr(vlib_buffer_t *b)
static void * vlib_buffer_push_ip4(vlib_main_t *vm, vlib_buffer_t *b, ip4_address_t *src, ip4_address_t *dst, int proto, u8 csum_offload)
Push IPv4 header to buffer.