42 sum = (sum & 0xFFFF) + (sum >> 16);
57 sum += clib_host_to_net_u16 (IP_PROTOCOL_UDP);
58 sum += clib_host_to_net_u16 (length);
62 sum = (sum & 0xFFFF) + (sum >> 16);
65 return ((
u16) (~sum));
72 register const u16 *sp;
91 phu.ph.ph_len = clib_host_to_net_u32 (len);
92 phu.ph.ph_nxt = IP_PROTOCOL_UDP;
95 for (i = 0; i <
sizeof (phu.pa) /
sizeof (phu.pa[0]); i++)
98 sp = (
const u16 *) up;
100 for (i = 0; i < (len & ~1); i += 2)
104 sum += clib_host_to_net_u16 ((*(
const u8 *) sp) << 8);
107 sum = (sum & 0xffff) + (sum >> 16);
137 uh->
src_port = clib_host_to_net_u16 (sp);
138 uh->
dst_port = clib_host_to_net_u16 (dp);
139 uh->
length = clib_host_to_net_u16 (udp_len);
150 clib_warning (
"src %U and dst %U IP have different AFI! Discarding!",
182 ih =
pkt_push_ip (vm, b, sip, dip, IP_PROTOCOL_UDP, 1);
183 b->
flags |= VNET_BUFFER_F_OFFLOAD_UDP_CKSUM;
190 ih =
pkt_push_ip (vm, b, sip, dip, IP_PROTOCOL_UDP, 0);
193 if (udpsum == (
u16) ~ 0)
199 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)
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)
#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.
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.
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.
vl_api_fib_path_nh_proto_t proto