| 1 | /* SCTP kernel Implementation |
| 2 | * Copyright (c) 2003 Hewlett-Packard Development Company, L.P |
| 3 | * (C) Copyright IBM Corp. 2004 |
| 4 | * |
| 5 | * When init timeout is set to zero, a connect () crashed the system. This case |
| 6 | * tests the fix for the same. |
| 7 | * |
| 8 | * The SCTP implementation is free software; |
| 9 | * you can redistribute it and/or modify it under the terms of |
| 10 | * the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2, or (at your option) |
| 12 | * any later version. |
| 13 | * |
| 14 | * The SCTP implementation is distributed in the hope that it |
| 15 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
| 16 | * ************************ |
| 17 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 18 | * See the GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with GNU CC; see the file COPYING. If not, write to |
| 22 | * the Free Software Foundation, 59 Temple Place - Suite 330, |
| 23 | * Boston, MA 02111-1307, USA. |
| 24 | * |
| 25 | * Please send any bug reports or fixes you make to the |
| 26 | * email address(es): |
| 27 | * lksctp developers <[email protected]> |
| 28 | * |
| 29 | * Or submit a bug report through the following website: |
| 30 | * https://github.com/sctp/lksctp-tools/ |
| 31 | * |
| 32 | * |
| 33 | * Any bugs reported given to us we will try to fix... any fixes shared will |
| 34 | * be incorporated into the next SCTP release. |
| 35 | * |
| 36 | */ |
| 37 | #include <stdio.h> |
| 38 | #include <unistd.h> |
| 39 | #include <fcntl.h> |
| 40 | #include <stdlib.h> |
| 41 | #include <string.h> |
| 42 | #include <sys/types.h> |
| 43 | #include <sys/socket.h> |
| 44 | #include <netinet/in.h> /* for sockaddr_in */ |
| 45 | #include <arpa/inet.h> |
| 46 | #include <errno.h> |
| 47 | #include <netinet/sctp.h>cxx . . $ `<file>/src/include/netinet/sctp.h`/ |
| 48 | #include <sys/uio.h> |
| 49 | #include <sctputil.h>cxx . . $ `<file>/src/testlib/sctputil.h`/ |
| 50 | |
| 51 | char *TCIDcxx . . $ TCID. = __FILE__; |
| 52 | int TST_TOTALcxx . . $ TST_TOTAL. = 1; |
| 53 | int TST_CNTcxx . . $ TST_CNT. = 0; |
| 54 | |
| 55 | int |
| 56 | maincxx . . $ main(afcd3168fc1188a4). (int argc, char **argv) |
| 57 | { |
| 58 | int sk1, sk2, sk3, pf_class; |
| 59 | socklen_tcxx . . $ socklen_t# len; |
| 60 | struct sockaddr_incxx . . $ sockaddr_in# lstn_addr, acpt_addr; |
| 61 | struct sockaddr_incxx . . $ sockaddr_in# conn_addr; |
| 62 | char * buffer_rcv; |
| 63 | struct sctp_initmsgcxx . . $ sctp_initmsg# sinmsg; |
| 64 | char *message = "Hello World!\n"; |
| 65 | |
| 66 | /* Rather than fflush() throughout the code, set stdout to |
| 67 | * be unbuffered. |
| 68 | */ |
| 69 | setvbufcxx . . $ setvbuf(4da3ba8c983f31bc).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, _IONBFcxx . . $ `<external>/232824719582829767/stdio.h:100:9`!, 0); |
| 70 | setvbufcxx . . $ setvbuf(4da3ba8c983f31bc).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, _IONBFcxx . . $ `<external>/232824719582829767/stdio.h:100:9`!, 0); |
| 71 | |
| 72 | /* Opening the socket*/ |
| 73 | |
| 74 | pf_class = PF_INETcxx . . $ `<external>/8962547315054503424/socket.h:45:9`!; |
| 75 | |
| 76 | sk1 = test_socketcxx . . $ test_socket(2326284602b0bb2d).(pf_class, SOCK_STREAMcxx . . $ `<external>/5956532346368192945/socket_type.h:28:9`!, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!); |
| 77 | sk3 = test_socketcxx . . $ test_socket(2326284602b0bb2d).(pf_class, SOCK_STREAMcxx . . $ `<external>/5956532346368192945/socket_type.h:28:9`!, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!); |
| 78 | |
| 79 | conn_addr.sin_familycxx . . $ sockaddr_in#sin_family. = AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!; |
| 80 | conn_addr.sin_addrcxx . . $ sockaddr_in#sin_addr..s_addrcxx . . $ in_addr#s_addr. = SCTP_IP_LOOPBACKcxx . . $ `src/testlib/sctputil.h:76:9`!; |
| 81 | conn_addr.sin_portcxx . . $ sockaddr_in#sin_port. = htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(SCTP_TESTPORT_1cxx . . $ `src/testlib/sctputil.h:71:9`!); |
| 82 | |
| 83 | lstn_addr.sin_familycxx . . $ sockaddr_in#sin_family. = AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!; |
| 84 | lstn_addr.sin_addrcxx . . $ sockaddr_in#sin_addr..s_addrcxx . . $ in_addr#s_addr. = SCTP_IP_LOOPBACKcxx . . $ `src/testlib/sctputil.h:76:9`!; |
| 85 | lstn_addr.sin_portcxx . . $ sockaddr_in#sin_port. = htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(SCTP_TESTPORT_1cxx . . $ `src/testlib/sctputil.h:71:9`!); |
| 86 | |
| 87 | test_bindcxx . . $ test_bind(18e507052d945257).(sk3, (struct sockaddrcxx . . $ sockaddr# *) &lstn_addr, sizeof(lstn_addr)); |
| 88 | |
| 89 | len = sizeof(struct sctp_initmsgcxx . . $ sctp_initmsg#); |
| 90 | sinmsg.sinit_num_ostreamscxx . . $ sctp_initmsg#sinit_num_ostreams. = 65535; |
| 91 | sinmsg.sinit_max_instreamscxx . . $ sctp_initmsg#sinit_max_instreams. = 10; |
| 92 | sinmsg.sinit_max_attemptscxx . . $ sctp_initmsg#sinit_max_attempts. = 1; |
| 93 | sinmsg.sinit_max_init_timeocxx . . $ sctp_initmsg#sinit_max_init_timeo. = 0; |
| 94 | test_setsockoptcxx . . $ test_setsockopt(57908ac6eaa2fecc).(sk1, SCTP_INITMSGcxx . . $ `<external>/17169092326581286071/sctp.h:71:9`!, &sinmsg, len); |
| 95 | sinmsg.sinit_num_ostreamscxx . . $ sctp_initmsg#sinit_num_ostreams. = 10; |
| 96 | sinmsg.sinit_max_instreamscxx . . $ sctp_initmsg#sinit_max_instreams. = 65535; |
| 97 | test_setsockoptcxx . . $ test_setsockopt(57908ac6eaa2fecc).(sk3, SCTP_INITMSGcxx . . $ `<external>/17169092326581286071/sctp.h:71:9`!, &sinmsg, len); |
| 98 | |
| 99 | test_listencxx . . $ test_listen(9b79fb6aee4c0440).(sk3, 1); |
| 100 | |
| 101 | len = sizeof(struct sockaddr_incxx . . $ sockaddr_in#); |
| 102 | test_connectcxx . . $ test_connect(18e507052d945257).(sk1, (struct sockaddrcxx . . $ sockaddr# *) &conn_addr, len); |
| 103 | |
| 104 | sk2 = test_acceptcxx . . $ test_accept(46fcd054f4a4d98b).(sk3, (struct sockaddrcxx . . $ sockaddr# *) &acpt_addr, &len); |
| 105 | |
| 106 | test_sctp_sendmsgcxx . . $ test_sctp_sendmsg(9dfe5aa294f24c42).(sk1, message, strlencxx . . $ strlen(751346f8406fd082).(message) + 1, |
| 107 | (struct sockaddrcxx . . $ sockaddr# *)&conn_addr, len, |
| 108 | 0, 0, 65534, 0, 0); |
| 109 | |
| 110 | buffer_rcv = test_malloccxx . . $ test_malloc(bfcfa4d6b7f7ef64).(100); |
| 111 | test_recvcxx . . $ test_recv(6076e73854a1e617).(sk2, buffer_rcv, (strlencxx . . $ strlen(751346f8406fd082).(message) + 1), MSG_NOSIGNALcxx . . $ `<external>/8962547315054503424/socket.h:242:9`!); |
| 112 | |
| 113 | tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "connect() with init timeout set to 0 - SUCCESS"); |
| 114 | |
| 115 | closecxx . . $ close(7864480464b09eea). (sk1); |
| 116 | closecxx . . $ close(7864480464b09eea). (sk2); |
| 117 | closecxx . . $ close(7864480464b09eea). (sk3); |
| 118 | |
| 119 | freecxx . . $ free(5d22bdacc48458e8).(buffer_rcv); |
| 120 | return 0; |
| 121 | } |