Lines Matching +full:0 +full:xee000000
43 static int dorandom = 0;
45 static int verbose = 0;
62 #define PRIV_ASIS 0
68 return (socket(PF_INET, type, 0)); in get_socket_unpriv()
77 if (getuid() != 0) in get_socket_priv()
78 errx(-1, "get_sock_priv: running without real uid 0"); in get_socket_priv()
81 if (seteuid(0) < 0) in get_socket_priv()
82 err(-1, "get_sock_priv: seteuid(0)"); in get_socket_priv()
84 sock = socket(PF_INET, type, 0); in get_socket_priv()
86 if (seteuid(olduid) < 0) in get_socket_priv()
105 * - That there is no initial set of options (length returned is 0).
122 if (getsockopt(sock, IPPROTO_IP, IP_OPTIONS, test_options, &len) < 0) in test_ip_options()
126 if (len != 0) in test_ip_options()
130 #define TEST_MAGIC 0xc34e4212 in test_ip_options()
139 sizeof(new_options)) < 0) in test_ip_options()
149 test_options[0] = TEST_MAGIC; in test_ip_options()
152 if (getsockopt(sock, IPPROTO_IP, IP_OPTIONS, test_options, &len) < 0) in test_ip_options()
167 if (test_options[0] == TEST_MAGIC) in test_ip_options()
174 if (new_options != test_options[0]) in test_ip_options()
177 new_options, test_options[0]); in test_ip_options()
182 if (setsockopt(sock, IPPROTO_IP, IP_OPTIONS, NULL, 0) < 0) in test_ip_options()
189 test_options[0] = TEST_MAGIC; in test_ip_options()
192 if (getsockopt(sock, IPPROTO_IP, IP_OPTIONS, test_options, &len) < 0) in test_ip_options()
196 if (len != 0) in test_ip_options()
221 sock = socket(PF_INET, SOCK_STREAM, 0); in test_ip_hdrincl()
225 flag[0] = -1; in test_ip_hdrincl()
226 len = sizeof(flag[0]); in test_ip_hdrincl()
227 if (getsockopt(sock, IPPROTO_IP, IP_HDRINCL, flag, &len) == 0) in test_ip_hdrincl()
235 flag[0] = 1; in test_ip_hdrincl()
236 if (setsockopt(sock, IPPROTO_IP, IP_HDRINCL, flag, sizeof(flag[0])) in test_ip_hdrincl()
237 == 0) in test_ip_hdrincl()
251 sock = socket(PF_INET, SOCK_DGRAM, 0); in test_ip_hdrincl()
255 flag[0] = -1; in test_ip_hdrincl()
256 len = sizeof(flag[0]); in test_ip_hdrincl()
257 if (getsockopt(sock, IPPROTO_IP, IP_HDRINCL, flag, &len) == 0) in test_ip_hdrincl()
266 if (setsockopt(sock, IPPROTO_IP, IP_HDRINCL, flag, sizeof(flag[0])) in test_ip_hdrincl()
267 == 0) in test_ip_hdrincl()
285 sock = socket(PF_INET, SOCK_RAW, 0); in test_ip_hdrincl()
286 if (geteuid() != 0) { in test_ip_hdrincl()
296 * Make sure the initial value of the flag is 0 (disabled). in test_ip_hdrincl()
298 flag[0] = -1; in test_ip_hdrincl()
301 if (getsockopt(sock, IPPROTO_IP, IP_HDRINCL, flag, &len) < 0) in test_ip_hdrincl()
305 if (len != sizeof(flag[0])) in test_ip_hdrincl()
309 if (flag[0] != 0) in test_ip_hdrincl()
311 flag[0]); in test_ip_hdrincl()
316 flag[0] = 1; in test_ip_hdrincl()
317 if (setsockopt(sock, IPPROTO_IP, IP_HDRINCL, flag, sizeof(flag[0])) in test_ip_hdrincl()
318 < 0) in test_ip_hdrincl()
324 flag[0] = -1; in test_ip_hdrincl()
327 if (getsockopt(sock, IPPROTO_IP, IP_HDRINCL, flag, &len) < 0) in test_ip_hdrincl()
331 if (flag[0] == 0) in test_ip_hdrincl()
333 "after set had flag of %d\n", flag[0]); in test_ip_hdrincl()
336 if (flag[0] != HISTORICAL_INP_HDRINCL) in test_ip_hdrincl()
339 flag[0]); in test_ip_hdrincl()
342 * Reset the IP_HDRINCL flag to 0. in test_ip_hdrincl()
344 flag[0] = 0; in test_ip_hdrincl()
345 if (setsockopt(sock, IPPROTO_IP, IP_HDRINCL, flag, sizeof(flag[0])) in test_ip_hdrincl()
346 < 0) in test_ip_hdrincl()
347 err(-1, "test_ip_hdrincl(): setsockopt(IP_HDRINCL, 0)"); in test_ip_hdrincl()
350 * Check that the IP_HDRINCL flag was reset to 0. in test_ip_hdrincl()
352 flag[0] = -1; in test_ip_hdrincl()
355 if (getsockopt(sock, IPPROTO_IP, IP_HDRINCL, flag, &len) < 0) in test_ip_hdrincl()
359 if (flag[0] != 0) in test_ip_hdrincl()
361 "after set had flag of %d\n", flag[0]); in test_ip_hdrincl()
379 * - The initial value of the TOS option is 0, TTL is 64.
384 * - When we reset it back to zero, we can read it as 0.
396 * Check that the initial value is 0, and that the size is one in test_ip_uchar()
399 val[0] = -1; in test_ip_uchar()
402 if (getsockopt(sock, IPPROTO_IP, option, val, &len) < 0) in test_ip_uchar()
406 if (len != sizeof(val[0])) in test_ip_uchar()
410 if (val[0] == -1) in test_ip_uchar()
414 if (val[0] != initial) in test_ip_uchar()
417 val[0], initial); in test_ip_uchar()
422 val[0] = 128; in test_ip_uchar()
424 if (setsockopt(sock, IPPROTO_IP, option, val, sizeof(val[0])) < 0) in test_ip_uchar()
431 val[0] = -1; in test_ip_uchar()
434 if (getsockopt(sock, IPPROTO_IP, option, val, &len) < 0) in test_ip_uchar()
438 if (len != sizeof(val[0])) in test_ip_uchar()
442 if (val[0] == -1) in test_ip_uchar()
446 if (val[0] != 128) in test_ip_uchar()
448 "128 returned %d", socktypename, optionname, val[0]); in test_ip_uchar()
451 * Reset the value to 0, check that it was reset. in test_ip_uchar()
453 val[0] = 0; in test_ip_uchar()
454 val[1] = 0; in test_ip_uchar()
455 if (setsockopt(sock, IPPROTO_IP, option, val, sizeof(val[0])) < 0) in test_ip_uchar()
459 if (len != sizeof(val[0])) in test_ip_uchar()
464 if (val[0] == -1) in test_ip_uchar()
468 if (val[0] != 0) in test_ip_uchar()
471 val[0]); in test_ip_uchar()
479 val[0] = 32000; in test_ip_uchar()
481 if (setsockopt(sock, IPPROTO_IP, option, val, sizeof(val[0])) < 0) { in test_ip_uchar()
492 val[0] = -1; in test_ip_uchar()
495 if (getsockopt(sock, IPPROTO_IP, option, val, &len) < 0) in test_ip_uchar()
499 if (len != sizeof(val[0])) in test_ip_uchar()
504 if (val[0] == -1) in test_ip_uchar()
508 if (val[0] == 32000) in test_ip_uchar()
540 if (initial == 0) in test_ip_boolean()
541 newvalue = 0xff; in test_ip_boolean()
543 newvalue = 0; in test_ip_boolean()
545 val[0] = -1; in test_ip_boolean()
548 if (getsockopt(sock, IPPROTO_IP, option, val, &len) < 0) in test_ip_boolean()
551 if (len != sizeof(val[0])) in test_ip_boolean()
555 if (val[0] == -1) in test_ip_boolean()
559 if (val[0] != initial) in test_ip_boolean()
562 val[0], initial); in test_ip_boolean()
568 < 0) in test_ip_boolean()
574 * not be what we set it to, as we set it to 0xff above). in test_ip_boolean()
576 val[0] = -1; in test_ip_boolean()
579 if (getsockopt(sock, IPPROTO_IP, option, val, &len) < 0) in test_ip_boolean()
583 if (len != sizeof(val[0])) in test_ip_boolean()
588 if (val[0] == -1) in test_ip_boolean()
594 * If we set it to true, check for '1', otherwise '0. in test_ip_boolean()
596 if (val[0] != (newvalue ? 1 : 0)) in test_ip_boolean()
599 val[0]); in test_ip_boolean()
606 < 0) in test_ip_boolean()
613 val[0] = -1; in test_ip_boolean()
616 if (getsockopt(sock, IPPROTO_IP, option, val, &len) < 0) in test_ip_boolean()
620 if (len != sizeof(val[0])) in test_ip_boolean()
624 if (val[0] == -1) in test_ip_boolean()
628 if (val[0] != newvalue) in test_ip_boolean()
649 if (getsockopt(sock, SOL_SOCKET, SO_TYPE, &sotype, &sotypelen) < 0) in test_ip_multicast_membership()
669 basegroup = 0xEE000000; /* 238.0.0.0 */ in test_ip_multicast_membership()
673 basegroup = 0xEE010100; /* 238.1.1.0 */ in test_ip_multicast_membership()
687 sizeof(mreq)) < 0) { in test_ip_multicast_membership()
700 sizeof(mreq)) < 0) { in test_ip_multicast_membership()
745 for (i = 0; i < sizeof(socktypeset)/sizeof(int); i++) { in testsuite()
753 if (getuid() != 0 && socktype == SOCK_RAW) in testsuite()
755 if (geteuid() != 0 && !priv && socktype == SOCK_RAW) in testsuite()
765 test_ip_uchar(sock, socktypename, IP_TOS, "IP_TOS", 0); in testsuite()
780 "IP_RECVOPTS", 0, BOOLEAN_ANYONE); in testsuite()
788 "IP_RECVRETOPTS", 0, BOOLEAN_ANYONE); in testsuite()
796 "IP_RECVDSTADDR", 0, BOOLEAN_ANYONE); in testsuite()
804 0, BOOLEAN_ANYONE); in testsuite()
812 0, BOOLEAN_ANYONE); in testsuite()
819 test_ip_boolean(sock, socktypename, IP_FAITH, "IP_FAITH", 0, in testsuite()
828 "IP_ONESBCAST", 0, BOOLEAN_ANYONE); in testsuite()
871 test_ip_multicast_if(0, NULL); in testsuite()
872 test_ip_multicast_vif(0, NULL); in testsuite()
916 if (geteuid() != 0) { in main()
925 "Running tests with ruid %d euid %d sock uid 0\n", in main()
928 if (seteuid(65534) != 0) in main()
935 "Running tests with ruid %d euid %d sock uid 0\n", in main()
940 exit(0); in main()