Lines Matching +full:test +full:- +full:part1
105 ip->ip_tos = 0; in ip_test1()
106 ip->ip_off = 0; in ip_test1()
107 ip->ip_ttl = 60; in ip_test1()
108 ip->ip_p = IPPROTO_UDP; in ip_test1()
109 ip->ip_sum = 0; in ip_test1()
111 u->uh_sport = htons(1); in ip_test1()
112 u->uh_dport = htons(9); in ip_test1()
113 u->uh_sum = 0; in ip_test1()
114 u->uh_ulen = htons(sizeof(*u) + 4); in ip_test1()
115 ip->ip_len = sizeof(*ip) + ntohs(u->uh_ulen); in ip_test1()
116 len = ip->ip_len; in ip_test1()
119 if (nfd == -1) in ip_test1()
124 * Part1: hl < len in ip_test1()
126 ip->ip_id = 0; in ip_test1()
128 for (i = 0; i < ((sizeof(*ip) + ntohs(u->uh_ulen)) >> 2); i++) { in ip_test1()
142 ip->ip_id = 0; in ip_test1()
144 for (; i < ((sizeof(*ip) * 2 + ntohs(u->uh_ulen)) >> 2); i++) { in ip_test1()
158 ip->ip_id = 0; in ip_test1()
175 ip->ip_id = 0; in ip_test1()
191 ip->ip_id = 0; in ip_test1()
193 i = ip->ip_len + 1; in ip_test1()
195 for (; i < (ip->ip_len * 2); i++) { in ip_test1()
196 ip->ip_id = htons(id++); in ip_test1()
197 ip->ip_sum = 0; in ip_test1()
198 ip->ip_sum = chksum((u_short *)ip, IP_HL(ip) << 2); in ip_test1()
205 printf("1.5.1 ip_len < packet size (ip_len-, short packets)\n"); in ip_test1()
206 for (i = len; i > 0; i--) { in ip_test1()
207 ip->ip_id = htons(id++); in ip_test1()
208 ip->ip_len = i; in ip_test1()
209 ip->ip_sum = 0; in ip_test1()
210 ip->ip_sum = chksum((u_short *)ip, IP_HL(ip) << 2); in ip_test1()
223 ip->ip_id = 0; in ip_test1()
226 ip->ip_id = htons(id++); in ip_test1()
227 ip->ip_len = i; in ip_test1()
228 ip->ip_sum = 0; in ip_test1()
229 ip->ip_sum = chksum((u_short *)ip, IP_HL(ip) << 2); in ip_test1()
236 ip->ip_len = len; in ip_test1()
237 printf("1.6.1 ip_len > packet size (size--, short packets)\n"); in ip_test1()
238 for (i = len; i > 0; i--) { in ip_test1()
239 ip->ip_id = htons(id++); in ip_test1()
240 ip->ip_sum = 0; in ip_test1()
241 ip->ip_sum = chksum((u_short *)ip, IP_HL(ip) << 2); in ip_test1()
255 ip->ip_id = 0; in ip_test1()
256 ip->ip_len = sizeof(*ip); in ip_test1()
257 ip->ip_off = htons(IP_MF); in ip_test1()
263 ip->ip_id = 0; in ip_test1()
264 ip->ip_len = sizeof(*ip); in ip_test1()
265 ip->ip_off = htons(IP_MF); in ip_test1()
271 ip->ip_id = 0; in ip_test1()
272 ip->ip_len = sizeof(*ip); in ip_test1()
273 ip->ip_off = htons(0xa000); in ip_test1()
279 ip->ip_id = 0; in ip_test1()
280 ip->ip_len = sizeof(*ip); in ip_test1()
281 ip->ip_off = htons(0x0100); in ip_test1()
298 ip->ip_p = IPPROTO_ICMP; in ip_test1()
299 ip->ip_off = htons(IP_MF); in ip_test1()
300 u->uh_dport = htons(9); in ip_test1()
301 ip->ip_id = htons(id++); in ip_test1()
303 ip->ip_len = 768 + 20 + 8; in ip_test1()
307 ip->ip_len = MIN(768 + 20, mtu - 68); in ip_test1()
310 ip->ip_off = htons(IP_MF | (i >> 3)); in ip_test1()
316 ip->ip_len = 896 + 20; in ip_test1()
317 ip->ip_off = htons(i >> 3); in ip_test1()
329 ip->ip_p = IPPROTO_ICMP; in ip_test1()
330 ip->ip_off = htons(IP_MF); in ip_test1()
331 u->uh_dport = htons(9); in ip_test1()
332 ip->ip_id = htons(id++); in ip_test1()
334 ip->ip_len = 768 + 20 + 8; in ip_test1()
341 ip->ip_len = MIN(768 + 20, mtu - 68); in ip_test1()
344 ip->ip_off = htons(IP_MF | (i >> 3)); in ip_test1()
353 ip->ip_len = 896 + 20; in ip_test1()
354 ip->ip_off = htons(i >> 3); in ip_test1()
364 * Part8.3: 33k packet - test for not dealing with -ve length in ip_test1()
369 ip->ip_p = IPPROTO_ICMP; in ip_test1()
370 ip->ip_off = htons(IP_MF); in ip_test1()
371 u->uh_dport = htons(9); in ip_test1()
372 ip->ip_id = htons(id++); in ip_test1()
374 ip->ip_len = 768 + 20 + 8; in ip_test1()
378 ip->ip_len = MIN(768 + 20, mtu - 68); in ip_test1()
381 ip->ip_off = htons(IP_MF | (i >> 3)); in ip_test1()
387 ip->ip_len = 896 + 20; in ip_test1()
388 ip->ip_off = htons(i >> 3); in ip_test1()
395 ip->ip_len = len; in ip_test1()
396 ip->ip_off = 0; in ip_test1()
401 ip->ip_id = 0; in ip_test1()
402 ip->ip_off = htons(0x8000); in ip_test1()
409 ip->ip_off = 0; in ip_test1()
415 ip->ip_id = 0; in ip_test1()
416 ip->ip_ttl = 255; in ip_test1()
422 ip->ip_ttl = 128; in ip_test1()
428 ip->ip_ttl = 0; in ip_test1()
456 if (nfd == -1)
460 ip->ip_len = IP_HL(ip) << 2;
466 * Test 1: option length > packet length,
472 ip->ip_p = IPPROTO_IP;
480 ip->ip_len = IP_HL(ip) << 2;
483 * Test 2: options have length = 0
533 * test 3 (ICMP)
550 ip->ip_tos = 0; in ip_test3()
551 ip->ip_off = 0; in ip_test3()
552 ip->ip_ttl = 60; in ip_test3()
553 ip->ip_p = IPPROTO_ICMP; in ip_test3()
554 ip->ip_sum = 0; in ip_test3()
555 ip->ip_len = sizeof(*ip) + sizeof(*icp); in ip_test3()
559 if (nfd == -1) in ip_test3()
564 * Type 0 - 31, 255, code = 0 in ip_test3()
568 icp->icmp_type = i; in ip_test3()
573 icp->icmp_type = 255; in ip_test3()
582 * Type 3, code = 0 - 31 in ip_test3()
584 icp->icmp_type = 3; in ip_test3()
586 icp->icmp_code = i; in ip_test3()
597 icp->icmp_type = 4; in ip_test3()
598 icp->icmp_code = 0; in ip_test3()
602 icp->icmp_code = 127; in ip_test3()
606 icp->icmp_code = 128; in ip_test3()
610 icp->icmp_code = 255; in ip_test3()
620 icp->icmp_type = 5; in ip_test3()
621 icp->icmp_code = 0; in ip_test3()
625 icp->icmp_code = 127; in ip_test3()
629 icp->icmp_code = 128; in ip_test3()
633 icp->icmp_code = 255; in ip_test3()
641 * Type 8-10;13-18, code - 0,127,128,255 in ip_test3()
644 icp->icmp_type = ict1[i]; in ip_test3()
645 icp->icmp_code = 0; in ip_test3()
650 icp->icmp_code = 127; in ip_test3()
655 icp->icmp_code = 128; in ip_test3()
660 icp->icmp_code = 255; in ip_test3()
671 * Type 12, code - 0,127,128,129,255 in ip_test3()
673 icp->icmp_type = 12; in ip_test3()
674 icp->icmp_code = 0; in ip_test3()
678 icp->icmp_code = 127; in ip_test3()
682 icp->icmp_code = 128; in ip_test3()
686 icp->icmp_code = 129; in ip_test3()
690 icp->icmp_code = 255; in ip_test3()
699 * Type 3;9-10;13-14;17-18 - shorter packets in ip_test3()
701 ip->ip_len = sizeof(*ip) + sizeof(*icp) / 2; in ip_test3()
703 icp->icmp_type = ict1[i]; in ip_test3()
704 icp->icmp_code = 0; in ip_test3()
708 i * 4, icp->icmp_type); in ip_test3()
709 icp->icmp_code = 127; in ip_test3()
713 i * 4 + 1, icp->icmp_type); in ip_test3()
714 icp->icmp_code = 128; in ip_test3()
718 i * 4 + 2, icp->icmp_type); in ip_test3()
719 icp->icmp_code = 255; in ip_test3()
723 i * 4 + 3, icp->icmp_type); in ip_test3()
730 /* Perform test 4 (UDP) */
746 ip->ip_tos = 0; in ip_test4()
747 ip->ip_off = 0; in ip_test4()
748 ip->ip_ttl = 60; in ip_test4()
749 ip->ip_p = IPPROTO_UDP; in ip_test4()
750 ip->ip_sum = 0; in ip_test4()
752 u->uh_sport = htons(1); in ip_test4()
753 u->uh_dport = htons(1); in ip_test4()
754 u->uh_ulen = htons(sizeof(*u) + 4); in ip_test4()
757 if (nfd == -1) in ip_test4()
762 * Test 1. ulen > packet in ip_test4()
764 u->uh_ulen = htons(sizeof(*u) + 4); in ip_test4()
765 ip->ip_len = (IP_HL(ip) << 2) + ntohs(u->uh_ulen); in ip_test4()
766 printf("4.1 UDP uh_ulen > packet size - short packets\n"); in ip_test4()
767 for (i = ntohs(u->uh_ulen) * 2; i > sizeof(*u) + 4; i--) { in ip_test4()
768 u->uh_ulen = htons(i); in ip_test4()
779 * Test 2. ulen < packet in ip_test4()
781 u->uh_ulen = htons(sizeof(*u) + 4); in ip_test4()
782 ip->ip_len = (IP_HL(ip) << 2) + ntohs(u->uh_ulen); in ip_test4()
783 printf("4.2 UDP uh_ulen < packet size - short packets\n"); in ip_test4()
784 for (i = ntohs(u->uh_ulen) * 2; i > sizeof(*u) + 4; i--) { in ip_test4()
785 ip->ip_len = i; in ip_test4()
796 * Test 3: sport = 0, sport = 1, sport = 32767 in ip_test4()
799 u->uh_ulen = sizeof(*u) + 4; in ip_test4()
800 ip->ip_len = (IP_HL(ip) << 2) + ntohs(u->uh_ulen); in ip_test4()
802 u->uh_sport = 0; in ip_test4()
808 u->uh_sport = htons(1); in ip_test4()
814 u->uh_sport = htons(32767); in ip_test4()
820 u->uh_sport = htons(32768); in ip_test4()
827 u->uh_sport = htons(65535); in ip_test4()
836 * Test 4: dport = 0, dport = 1, dport = 32767 in ip_test4()
839 u->uh_ulen = ntohs(sizeof(*u) + 4); in ip_test4()
840 u->uh_sport = htons(1); in ip_test4()
841 ip->ip_len = (IP_HL(ip) << 2) + ntohs(u->uh_ulen); in ip_test4()
843 u->uh_dport = 0; in ip_test4()
849 u->uh_dport = htons(1); in ip_test4()
855 u->uh_dport = htons(32767); in ip_test4()
861 u->uh_dport = htons(32768); in ip_test4()
867 u->uh_dport = htons(65535); in ip_test4()
876 * Test 5: sizeof(ip_t) <= MTU <= sizeof(udphdr_t) + in ip_test4()
880 for (i = sizeof(*ip); i <= ntohs(u->uh_ulen); i++) { in ip_test4()
891 /* Perform test 5 (TCP) */
906 t->th_sport = htons(1); in ip_test5()
907 t->th_dport = htons(1); in ip_test5()
908 t->th_win = htons(4096); in ip_test5()
909 t->th_urp = 0; in ip_test5()
910 t->th_sum = 0; in ip_test5()
911 t->th_seq = htonl(1); in ip_test5()
912 t->th_ack = 0; in ip_test5()
913 ip->ip_len = sizeof(ip_t) + sizeof(tcphdr_t); in ip_test5()
916 if (nfd == -1) in ip_test5()
921 * Test 1: flags variations, 0 - 1ff in ip_test5()
924 printf("5.1 Test TCP flag combinations\n"); in ip_test5()
938 * Test 2: seq = 0, seq = 1, seq = 0x7fffffff, seq=0x80000000, in ip_test5()
942 t->th_seq = htonl(0); in ip_test5()
948 t->th_seq = htonl(1); in ip_test5()
954 t->th_seq = htonl(0x7fffffff); in ip_test5()
960 t->th_seq = htonl(0x80000000); in ip_test5()
966 t->th_seq = htonl(0xc0000000); in ip_test5()
972 t->th_seq = htonl(0xffffffff); in ip_test5()
981 * Test 3: ack = 0, ack = 1, ack = 0x7fffffff, ack = 0x8000000 in ip_test5()
985 t->th_ack = 0; in ip_test5()
991 t->th_ack = htonl(1); in ip_test5()
997 t->th_ack = htonl(0x7fffffff); in ip_test5()
1003 t->th_ack = htonl(0x80000000); in ip_test5()
1009 t->th_ack = htonl(0xc0000000); in ip_test5()
1015 t->th_ack = htonl(0xffffffff); in ip_test5()
1024 * Test 4: win = 0, win = 32768, win = 65535 in ip_test5()
1027 t->th_seq = htonl(0); in ip_test5()
1033 t->th_seq = htonl(0x7fff); in ip_test5()
1039 t->th_win = htons(0xffff); in ip_test5()
1059 sin.sin_addr.s_addr = ip->ip_dst.s_addr; in ip_test5()
1069 printf("to host %s for test 5 and 6 - skipping.\n", in ip_test5()
1070 inet_ntoa(ip->ip_dst)); in ip_test5()
1075 t->th_dport = htons(i); in ip_test5()
1078 t->th_sport = sin.sin_port; in ip_test5()
1085 ti.ti_seq = htonl(tcb.snd_nxt - 1); in ip_test5()
1090 * Test 5: urp in ip_test5()
1094 ntohs(t->th_sport), ntohs(t->th_dport)); in ip_test5()
1095 t->th_urp = htons(1); in ip_test5()
1099 t->th_seq = htonl(tcb.snd_nxt); in ip_test5()
1100 ip->ip_len = sizeof(ip_t) + sizeof(tcphdr_t) + 1; in ip_test5()
1101 t->th_urp = htons(0x7fff); in ip_test5()
1104 t->th_urp = htons(0x8000); in ip_test5()
1107 t->th_urp = htons(0xffff); in ip_test5()
1110 t->th_urp = 0; in ip_test5()
1112 ip->ip_len = sizeof(ip_t) + sizeof(tcphdr_t); in ip_test5()
1117 * Test 6: data offset, off = 0, off is inside, off is outside in ip_test5()
1120 printf("5.6.1 TCP off = 1-15, len = 40\n"); in ip_test5()
1129 ip->ip_len = sizeof(ip_t) + sizeof(tcphdr_t); in ip_test5()
1136 t->th_seq = htonl(1); in ip_test5()
1137 t->th_ack = htonl(1); in ip_test5()
1143 * Test 7: sport = 0, sport = 1, sport = 32767 in ip_test5()
1147 t->th_sport = 0; in ip_test5()
1153 t->th_sport = htons(1); in ip_test5()
1159 t->th_sport = htons(32767); in ip_test5()
1165 t->th_sport = htons(32768); in ip_test5()
1171 t->th_sport = htons(65535); in ip_test5()
1178 t->th_sport = htons(1); in ip_test5()
1181 * Test 8: dport = 0, dport = 1, dport = 32767 in ip_test5()
1185 t->th_dport = 0; in ip_test5()
1191 t->th_dport = htons(1); in ip_test5()
1197 t->th_dport = htons(32767); in ip_test5()
1203 t->th_dport = htons(32768); in ip_test5()
1209 t->th_dport = htons(65535); in ip_test5()
1215 /* LAND attack - self connect, so make src & dst ip/port the same */ in ip_test5()
1219 t->th_sport = htons(25); in ip_test5()
1220 t->th_dport = htons(25); in ip_test5()
1222 ip->ip_src = ip->ip_dst; in ip_test5()
1233 /* Perform test 6 (exhaust mbuf test) */
1247 ip->ip_tos = 0; in ip_test6()
1248 ip->ip_off = 0; in ip_test6()
1249 ip->ip_ttl = 60; in ip_test6()
1250 ip->ip_p = IPPROTO_UDP; in ip_test6()
1251 ip->ip_sum = 0; in ip_test6()
1253 u->uh_sport = htons(1); in ip_test6()
1254 u->uh_dport = htons(9); in ip_test6()
1255 u->uh_sum = 0; in ip_test6()
1258 if (nfd == -1) in ip_test6()
1261 u->uh_ulen = htons(7168); in ip_test6()
1263 printf("6. Exhaustive mbuf test.\n"); in ip_test6()
1270 ip->ip_len = sizeof(*ip) + 768 + sizeof(*u); in ip_test6()
1272 ip->ip_off = htons(IP_MF); in ip_test6()
1280 ip->ip_len = sizeof(*ip) + 128 + sizeof(*u); in ip_test6()
1281 ip->ip_off = htons(IP_MF); in ip_test6()
1288 ip->ip_len = sizeof(*ip) + 768; in ip_test6()
1289 ip->ip_off = htons(IP_MF|(j>>3)); in ip_test6()
1295 ip->ip_len = sizeof(*ip) + 128; in ip_test6()
1296 for (k = j - 768; k < j; k += 128) { in ip_test6()
1297 ip->ip_off = htons(IP_MF|(k>>3)); in ip_test6()
1309 /* Perform test 7 (random packets) */
1326 if (nfd == -1) in ip_test7()
1339 bcopy((char *)&ip->ip_dst, (char *)&pip->ip_dst, in ip_test7()
1341 pip->ip_sum = 0; in ip_test7()
1342 pip->ip_len &= 0xff; in ip_test7()
1354 pip->ip_off &= htons(0xc000); in ip_test7()
1355 bcopy((char *)&ip->ip_dst, (char *)&pip->ip_dst, in ip_test7()
1357 pip->ip_sum = 0; in ip_test7()
1358 pip->ip_len &= 0xff; in ip_test7()