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);
181 clib_host_to_net_u32 (0x6<<28);
185 payload_length -=
sizeof (*ip6h);
199 ip_address_t *dst,
u32 proto)
203 clib_warning(
"src %s and dst %s IP have different AFI! Discarding!",
223 ip_address_t *sip, ip_address_t *dip)
231 ih =
pkt_push_ip (vm, b, sip, dip, IP_PROTOCOL_UDP);
235 if (udpsum == (
u16) ~0)
250 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)
void * pkt_push_ipv4(vlib_main_t *vm, vlib_buffer_t *b, ip4_address_t *src, ip4_address_t *dst, int proto)
u16 udp_ip4_checksum(const void *b, u32 len, u8 *src, u8 *dst)
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)
always_inline void * vlib_buffer_push_uninit(vlib_buffer_t *b, u8 size)
always_inline uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
#define clib_warning(format, args...)
u16 udp_ip6_checksum(ip6_header_t *ip6, udp_header_t *up, u32 len)
#define ip_addr_version(_a)
void * pkt_push_ipv6(vlib_main_t *vm, vlib_buffer_t *b, ip6_address_t *src, ip6_address_t *dst, int proto)
always_inline u16 ip4_header_checksum(ip4_header_t *i)
#define clib_memcpy(a, b, c)
u8 * format_ip_address(u8 *s, va_list *args)
void * pkt_push_ecm_hdr(vlib_buffer_t *b)