1 #ifndef MINIX_TEST_SOCKLIB_H 2 #define MINIX_TEST_SOCKLIB_H 3 4 /* TCP/IP test values. */ 5 #define TEST_PORT_A 12345 /* this port should be free and usable */ 6 #define TEST_PORT_B 12346 /* this port should be free and usable */ 7 8 #define LOOPBACK_IFNAME "lo0" /* loopback interface name */ 9 #define LOOPBACK_IPV4 "127.0.0.1" /* IPv4 address */ 10 #define LOOPBACK_LL_IPV6 "fe80::1" /* link-local IPv6 address */ 11 12 /* These address should simply eat all packets. */ 13 /* 14 * IMPORTANT: the ::2 address works only if there is a route for ::/64. This 15 * route is supposed to be added by /etc/rc.d/network, and is not present by 16 * default. As a result, the tests will pass only when regular system/network 17 * initialization is not skipped. We cannot add the route ourselves, since not 18 * all tests run as root. 19 */ 20 #define TEST_BLACKHOLE_IPV4 "127.255.0.254" 21 #define TEST_BLACKHOLE_IPV6 "::2" 22 #define TEST_BLACKHOLE_LL_IPV6 "fe80::ffff" 23 24 #define BAD_SCOPE_ID 255 /* guaranteed not to belong to an interface */ 25 26 enum state { 27 S_NEW, 28 S_N_SHUT_R, 29 S_N_SHUT_W, 30 S_N_SHUT_RW, 31 S_BOUND, 32 S_LISTENING, 33 S_L_SHUT_R, 34 S_L_SHUT_W, 35 S_L_SHUT_RW, 36 S_CONNECTING, 37 S_C_SHUT_R, 38 S_C_SHUT_W, 39 S_C_SHUT_RW, 40 S_CONNECTED, 41 S_ACCEPTED, 42 S_SHUT_R, 43 S_SHUT_W, 44 S_SHUT_RW, 45 S_RSHUT_R, 46 S_RSHUT_W, 47 S_RSHUT_RW, 48 S_SHUT2_R, 49 S_SHUT2_W, 50 S_SHUT2_RW, 51 S_PRE_EOF, 52 S_AT_EOF, 53 S_POST_EOF, 54 S_PRE_SHUT_R, 55 S_EOF_SHUT_R, 56 S_POST_SHUT_R, 57 S_PRE_SHUT_W, 58 S_EOF_SHUT_W, 59 S_POST_SHUT_W, 60 S_PRE_SHUT_RW, 61 S_EOF_SHUT_RW, 62 S_POST_SHUT_RW, 63 S_PRE_RESET, 64 S_AT_RESET, 65 S_POST_RESET, 66 S_FAILED, 67 S_POST_FAILED, 68 S_MAX 69 }; 70 71 enum call { 72 C_ACCEPT, 73 C_BIND, 74 C_CONNECT, 75 C_GETPEERNAME, 76 C_GETSOCKNAME, 77 C_GETSOCKOPT_ERR, 78 C_GETSOCKOPT_KA, 79 C_GETSOCKOPT_RB, 80 C_IOCTL_NREAD, 81 C_LISTEN, 82 C_RECV, 83 C_RECVFROM, 84 C_SEND, 85 C_SENDTO, 86 C_SELECT_R, 87 C_SELECT_W, 88 C_SELECT_X, 89 C_SETSOCKOPT_BC, 90 C_SETSOCKOPT_KA, 91 C_SETSOCKOPT_L, 92 C_SETSOCKOPT_RA, 93 C_SHUTDOWN_R, 94 C_SHUTDOWN_RW, 95 C_SHUTDOWN_W, 96 C_MAX 97 }; 98 99 int socklib_sweep_call(enum call call, int fd, struct sockaddr * local_addr, 100 struct sockaddr * remote_addr, socklen_t addr_len); 101 void socklib_sweep(int domain, int type, int protocol, 102 const enum state * states, unsigned int nstates, const int * results, 103 int (* proc)(int domain, int type, int protocol, enum state, 104 enum call)); 105 106 void socklib_multicast_tx_options(int type); 107 void socklib_large_transfers(int fd[2]); 108 void socklib_producer_consumer(int fd[2]); 109 void socklib_stream_recv(int (* socket_pair)(int, int, int, int *), int domain, 110 int type, int (* break_recv)(int, const char *, size_t)); 111 int socklib_find_pcb(const char * path, int protocol, uint16_t local_port, 112 uint16_t remote_port, struct kinfo_pcb * ki); 113 void socklib_test_addrs(int type, int protocol); 114 void socklib_test_multicast(int type, int protocol); 115 116 #endif /* !MINIX_TEST_SOCKLIB_H */ 117