1 /* SCTP kernel Implementation
2 * Copyright (c) 2003 Hewlett-Packard Development Company, L.P
3 * (C) Copyright IBM Corp. 2004
5 * This file has test cases to test the getsockopt () and sectsockopt () with
6 * SCTP_RTOINFO option on 1-1 style socket
8 * This program first gets the default values using getsockopt(). It also sets
9 * the value using setsockopt() and gets the set value using getsockopt().
10 * A comparison between set values and get values are performed.
12 * The SCTP implementation is free software;
13 * you can redistribute it and/or modify it under the terms of
14 * the GNU General Public License as published by
15 * the Free Software Foundation; either version 2, or (at your option)
18 * The SCTP implementation is distributed in the hope that it
19 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
20 * ************************
21 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 * See the GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with GNU CC; see the file COPYING. If not, write to
26 * the Free Software Foundation, 59 Temple Place - Suite 330,
27 * Boston, MA 02111-1307, USA.
29 * Please send any bug reports or fixes you make to the
31 * lksctp developers <lksctp-developers@lists.sourceforge.net>
33 * Or submit a bug report through the following website:
34 * http://www.sf.net/projects/lksctp
36 * Any bugs reported given to us we will try to fix... any fixes shared will
37 * be incorporated into the next SCTP release
46 #include <sys/types.h>
47 #include <sys/socket.h>
48 #include <linux/socket.h>
49 #include <linux/in.h> /* for sockaddr_in */
50 #include <linux/in6.h> /* for sockaddr_in6 */
51 #include <sys/errno.h>
53 #include <netinet/sctp.h>
56 char *TCID = __FILE__;
66 struct sctp_rtoinfo srtoinfo; /*setting the variables*/
67 struct sctp_rtoinfo grtoinfo; /*Getting the variables*/
69 sd = test_socket (PF_INET, SOCK_STREAM, IPPROTO_SCTP);
71 len = sizeof(struct sctp_rtoinfo);
73 /*TEST1 Getting the default values using getsockopt()*/
74 ret = getsockopt(sd, IPPROTO_SCTP, SCTP_RTOINFO, &grtoinfo, &len);
76 tst_brkm(TBROK, tst_exit, "getsockopt SCTP_RTOINFO "
77 "ret:%d, errno:%d", ret, errno);
79 tst_resm(TPASS, "getsockopt() SCTP_RTOINFO - SUCCESS");
81 /*Assigning the values to RTO initial and max and min bounds*/
82 srtoinfo.srto_initial=60;
83 srtoinfo.srto_max=100;
86 /*TEST2 Setting the values using setsockopt()*/
87 ret = setsockopt(sd, IPPROTO_SCTP, SCTP_RTOINFO, &srtoinfo,
88 sizeof(struct sctp_rtoinfo));
90 tst_brkm(TBROK, tst_exit, "setsockopt SCTP_RTOINFO "
91 "ret:%d, errno:%d", ret, errno);
93 tst_resm(TPASS, "setsockopt() SCTP_RTOINFO - SUCCESS");
95 /*Getting the values which are set using setsockopt()*/
96 ret = getsockopt(sd, IPPROTO_SCTP, SCTP_RTOINFO, &grtoinfo, &len);
98 tst_brkm(TBROK, tst_exit, "getsockopt SCTP_RTOINFO "
99 "ret:%d, errno:%d", ret, errno);
101 /* TEST3 Compare the get values with the set values. */
102 if (srtoinfo.srto_initial != grtoinfo.srto_initial &&
103 srtoinfo.srto_max != grtoinfo.srto_max &&
104 srtoinfo.srto_min != grtoinfo.srto_min)
105 tst_brkm(TBROK, tst_exit, "setsockopt/getsockopt SCTP_RTOINFO "
108 tst_resm(TPASS, "setsockopt()/getsockopt SCTP_RTOINFO compare - "