Lines Matching +full:non +full:- +full:overlap +full:- +full:time
1 // SPDX-License-Identifier: GPL-2.0
16 #include <time.h>
63 if (ret == -1 && (errno == ETIMEDOUT || errno == EAGAIN)) in recv_validate_udp()
66 if (ret != -1) in recv_validate_udp()
73 if (ret == -1) in recv_validate_udp()
89 sum -= 0xffff; in raw_checksum()
95 sum -= 0xffff; in raw_checksum()
106 sum = raw_checksum((uint8_t *)&iphdr->ip_src, 2 * sizeof(iphdr->ip_src), in udp_checksum()
122 sum = raw_checksum((uint8_t *)&iphdr->ip6_src, 2 * sizeof(iphdr->ip6_src), in udp6_checksum()
124 sum = raw_checksum((uint8_t *)&udphdr->len, sizeof(udphdr->len), sum); in udp6_checksum()
139 int payload_offset = offset > 0 ? offset - UDP_HLEN : 0; in send_fragment()
159 if (payload_len - payload_offset <= max_frag_len && offset > 0) { in send_fragment()
161 frag_len = FRAG_HLEN + payload_len - payload_offset; in send_fragment()
162 fraghdr->ip6f_offlg = htons(offset); in send_fragment()
165 fraghdr->ip6f_offlg = htons(offset | IP6_MF); in send_fragment()
167 ip6hdr->ip6_plen = htons(frag_len); in send_fragment()
170 frag_len - FRAG_HLEN - UDP_HLEN); in send_fragment()
173 frag_len - FRAG_HLEN); in send_fragment()
177 if (payload_len - payload_offset <= max_frag_len && offset > 0) { in send_fragment()
179 frag_len = IP4_HLEN + payload_len - payload_offset; in send_fragment()
180 iphdr->ip_off = htons(offset / 8); in send_fragment()
183 iphdr->ip_off = htons(offset / 8 | IP4_MF); in send_fragment()
185 iphdr->ip_len = htons(frag_len); in send_fragment()
188 frag_len - IP4_HLEN - UDP_HLEN); in send_fragment()
191 frag_len - IP4_HLEN); in send_fragment()
221 ((struct sockaddr_in6 *)addr)->sin6_port = 0; in send_udp_frags()
223 ip6hdr->ip6_flow = htonl(6<<28); /* Version. */ in send_udp_frags()
224 ip6hdr->ip6_nxt = IPPROTO_FRAGMENT; in send_udp_frags()
225 ip6hdr->ip6_hops = 255; in send_udp_frags()
226 ip6hdr->ip6_src = addr6; in send_udp_frags()
227 ip6hdr->ip6_dst = addr6; in send_udp_frags()
228 fraghdr->ip6f_nxt = IPPROTO_UDP; in send_udp_frags()
229 fraghdr->ip6f_reserved = 0; in send_udp_frags()
230 fraghdr->ip6f_ident = htonl(ip_id++); in send_udp_frags()
233 iphdr->ip_hl = 5; in send_udp_frags()
234 iphdr->ip_v = 4; in send_udp_frags()
235 iphdr->ip_tos = 0; in send_udp_frags()
236 iphdr->ip_id = htons(ip_id++); in send_udp_frags()
237 iphdr->ip_ttl = 0x40; in send_udp_frags()
238 iphdr->ip_p = IPPROTO_UDP; in send_udp_frags()
239 iphdr->ip_src.s_addr = htonl(INADDR_LOOPBACK); in send_udp_frags()
240 iphdr->ip_dst = addr4; in send_udp_frags()
241 iphdr->ip_sum = 0; in send_udp_frags()
244 /* Occasionally test in-order fragments. */ in send_udp_frags()
292 * hard-code offset and frag_len. in send_udp_frags()
307 fraghdr->ip6f_offlg = htons(offset / 8 | IP6_MF); in send_udp_frags()
308 ip6hdr->ip6_plen = htons(frag_len); in send_udp_frags()
312 iphdr->ip_off = htons(offset / 8 | IP4_MF); in send_udp_frags()
313 iphdr->ip_len = htons(frag_len); in send_udp_frags()
317 error(1, errno, "sendto overlap: %d", frag_len); in send_udp_frags()
319 error(1, 0, "sendto overlap: %d vs %d", (int)res, frag_len); in send_udp_frags()
350 fd_tx_raw = socket(addr->sa_family, SOCK_RAW, IPPROTO_RAW); in run_test()
351 if (fd_tx_raw == -1) in run_test()
354 fd_rx_udp = socket(addr->sa_family, SOCK_DGRAM, 0); in run_test()
355 if (fd_rx_udp == -1) in run_test()
371 * is not enough test time to run a nested loop: in run_test()
372 * the full overlap test takes 20-30 seconds. in run_test()
375 rand() % (1500 - FRAG_HLEN - min_frag_len); in run_test()
380 * send/receive pair below) takes very little time to in run_test()
382 * with a nested loop: the full non-overlap test takes in run_test()
390 } while (max_frag_len < (1500 - FRAG_HLEN) && in run_test()
435 while ((c = getopt(argc, argv, "46opv")) != -1) { in parse_opts()
461 seed = time(NULL); in main()