1 /* SCTP kernel Implementation
2 * Copyright (c) 2003 Hewlett-Packard Development Company, L.P
3 * (C) Copyright IBM Corp. 2004
5 * When init timeout is set to zero, a connect () crashed the system. This case
6 * tests the fix for the same.
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)
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.
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.
25 * Please send any bug reports or fixes you make to the
27 * lksctp developers <lksctp-developers@lists.sourceforge.net>
29 * Or submit a bug report through the following website:
30 * http://www.sf.net/projects/lksctp
33 * Any bugs reported given to us we will try to fix... any fixes shared will
34 * be incorporated into the next SCTP release.
42 #include <sys/types.h>
43 #include <sys/socket.h>
44 #include <netinet/in.h> /* for sockaddr_in */
45 #include <arpa/inet.h>
47 #include <netinet/sctp.h>
51 char *TCID = __FILE__;
56 main (int argc, char **argv)
58 int sk1, sk2, sk3, pf_class;
60 struct sockaddr_in lstn_addr, acpt_addr;
61 struct sockaddr_in conn_addr;
63 struct sctp_initmsg sinmsg;
64 char *message = "Hello World!\n";
66 /* Rather than fflush() throughout the code, set stdout to
69 setvbuf(stdout, NULL, _IONBF, 0);
70 setvbuf(stderr, NULL, _IONBF, 0);
72 /* Opening the socket*/
76 sk1 = test_socket(pf_class, SOCK_STREAM, IPPROTO_SCTP);
77 sk3 = test_socket(pf_class, SOCK_STREAM, IPPROTO_SCTP);
79 conn_addr.sin_family = AF_INET;
80 conn_addr.sin_addr.s_addr = SCTP_IP_LOOPBACK;
81 conn_addr.sin_port = htons(SCTP_TESTPORT_1);
83 lstn_addr.sin_family = AF_INET;
84 lstn_addr.sin_addr.s_addr = SCTP_IP_LOOPBACK;
85 lstn_addr.sin_port = htons(SCTP_TESTPORT_1);
87 test_bind(sk3, (struct sockaddr *) &lstn_addr, sizeof(lstn_addr));
89 len = sizeof(struct sctp_initmsg);
90 sinmsg.sinit_num_ostreams = 65535;
91 sinmsg.sinit_max_instreams = 10;
92 sinmsg.sinit_max_attempts = 1;
93 sinmsg.sinit_max_init_timeo = 0;
94 test_setsockopt(sk1, SCTP_INITMSG, &sinmsg, len);
95 sinmsg.sinit_num_ostreams = 10;
96 sinmsg.sinit_max_instreams = 65535;
97 test_setsockopt(sk3, SCTP_INITMSG, &sinmsg, len);
101 len = sizeof(struct sockaddr_in);
102 test_connect(sk1, (struct sockaddr *) &conn_addr, len);
104 sk2 = test_accept(sk3, (struct sockaddr *) &acpt_addr, &len);
106 test_sctp_sendmsg(sk1, message, strlen(message) + 1,
107 (struct sockaddr *)&conn_addr, len,
110 buffer_rcv = malloc(100);
111 test_recv(sk2, buffer_rcv, (strlen(message) + 1), MSG_NOSIGNAL);
113 tst_resm(TPASS, "connect() with init timeout set to 0 - SUCCESS");