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;
88 memset (&phu, 0,
sizeof (phu));
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);
146 ip_address_t * dst,
u32 proto)
150 clib_warning (
"src %U and dst %U IP have different AFI! Discarding!",
172 ip_address_t * sip, ip_address_t * dip)
180 ih =
pkt_push_ip (vm, b, sip, dip, IP_PROTOCOL_UDP);
184 if (udpsum == (
u16) ~ 0)
199 memset (h, 0,
sizeof (h[0]));
sll srl srl sll sra u16x4 i
u16 udp_checksum(udp_header_t *uh, u32 udp_len, void *ih, u8 version)
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)
u16 udp_ip4_checksum(const void *b, u32 len, u8 *src, u8 *dst)
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)
u16 udp_ip6_checksum(ip6_header_t *ip6, udp_header_t *up, u32 len)
#define ip_addr_version(_a)
static void * vlib_buffer_push_ip4(vlib_main_t *vm, vlib_buffer_t *b, ip4_address_t *src, ip4_address_t *dst, int proto)
Push IPv4 header to buffer.
#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.
void * pkt_push_ecm_hdr(vlib_buffer_t *b)