| 1 | /* SCTP kernel Implementation |
| 2 | * Copyright (c) 2003 Hewlett-Packard Development Company, L.P |
| 3 | * (C) Copyright IBM Corp. 2004 |
| 4 | * |
| 5 | * This file has test cases to test the getsockopt () and sectsockopt () with |
| 6 | * SCTP_RTOINFO option on 1-1 style socket |
| 7 | * |
| 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. |
| 11 | * |
| 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) |
| 16 | * any later version. |
| 17 | * |
| 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. |
| 23 | * |
| 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. |
| 28 | * |
| 29 | * Please send any bug reports or fixes you make to the |
| 30 | * email address(es): |
| 31 | * lksctp developers <[email protected]> |
| 32 | * |
| 33 | * Or submit a bug report through the following website: |
| 34 | * https://github.com/sctp/lksctp-tools/ |
| 35 | * |
| 36 | * Any bugs reported given to us we will try to fix... any fixes shared will |
| 37 | * be incorporated into the next SCTP release |
| 38 | * |
| 39 | */ |
| 40 | |
| 41 | #include <stdio.h> |
| 42 | #include <unistd.h> |
| 43 | #include <fcntl.h> |
| 44 | #include <stdlib.h> |
| 45 | #include <string.h> |
| 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 <errno.h> |
| 52 | #include <sys/uio.h> |
| 53 | #include <netinet/sctp.h>cxx . . $ `<file>/src/include/netinet/sctp.h`/ |
| 54 | #include <sctputil.h>cxx . . $ `<file>/src/testlib/sctputil.h`/ |
| 55 | |
| 56 | char *TCIDcxx . . $ TCID. = __FILE__; |
| 57 | int TST_TOTALcxx . . $ TST_TOTAL. = 3; |
| 58 | int TST_CNTcxx . . $ TST_CNT. = 0; |
| 59 | |
| 60 | int |
| 61 | maincxx . . $ main(b126dc7c1de90089).(void) |
| 62 | { |
| 63 | |
| 64 | int sd, ret; |
| 65 | socklen_tcxx . . $ socklen_t# len; |
| 66 | struct sctp_rtoinfocxx . . $ sctp_rtoinfo# srtoinfo; /*setting the variables*/ |
| 67 | struct sctp_rtoinfocxx . . $ sctp_rtoinfo# grtoinfo; /*Getting the variables*/ |
| 68 | |
| 69 | sd = test_socketcxx . . $ test_socket(2326284602b0bb2d). (PF_INETcxx . . $ `<external>/8962547315054503424/socket.h:45:9`!, SOCK_STREAMcxx . . $ `<external>/5956532346368192945/socket_type.h:28:9`!, IPPROTO_SCTPcxx . . $ `<external>/11409867738300076284/in.h:75:9`!); |
| 70 | |
| 71 | len = sizeof(struct sctp_rtoinfocxx . . $ sctp_rtoinfo#); |
| 72 | |
| 73 | /*TEST1 Getting the default values using getsockopt()*/ |
| 74 | ret = getsockoptcxx . . $ getsockopt(b79d9f11efef15f9).(sd, IPPROTO_SCTPcxx . . $ `<external>/11409867738300076284/in.h:75:9`!, SCTP_RTOINFOcxx . . $ `<external>/17169092326581286071/sctp.h:69:9`!, &grtoinfo, &len); |
| 75 | if (ret < 0) |
| 76 | tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "getsockopt SCTP_RTOINFO " |
| 77 | "ret:%d, errno:%d", ret, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 78 | |
| 79 | tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "getsockopt() SCTP_RTOINFO - SUCCESS"); |
| 80 | |
| 81 | /*Assigning the values to RTO initial and max and min bounds*/ |
| 82 | srtoinfo.srto_initialcxx . . $ sctp_rtoinfo#srto_initial.=60; |
| 83 | srtoinfo.srto_maxcxx . . $ sctp_rtoinfo#srto_max.=100; |
| 84 | srtoinfo.srto_mincxx . . $ sctp_rtoinfo#srto_min.=40; |
| 85 | srtoinfo.srto_assoc_idcxx . . $ sctp_rtoinfo#srto_assoc_id. = 0; |
| 86 | |
| 87 | /*TEST2 Setting the values using setsockopt()*/ |
| 88 | ret = setsockoptcxx . . $ setsockopt(506cc1d0fc70fdf1).(sd, IPPROTO_SCTPcxx . . $ `<external>/11409867738300076284/in.h:75:9`!, SCTP_RTOINFOcxx . . $ `<external>/17169092326581286071/sctp.h:69:9`!, &srtoinfo, |
| 89 | sizeof(struct sctp_rtoinfocxx . . $ sctp_rtoinfo#)); |
| 90 | if (ret < 0) |
| 91 | tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "setsockopt SCTP_RTOINFO " |
| 92 | "ret:%d, errno:%d", ret, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 93 | |
| 94 | tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "setsockopt() SCTP_RTOINFO - SUCCESS"); |
| 95 | |
| 96 | /*Getting the values which are set using setsockopt()*/ |
| 97 | ret = getsockoptcxx . . $ getsockopt(b79d9f11efef15f9).(sd, IPPROTO_SCTPcxx . . $ `<external>/11409867738300076284/in.h:75:9`!, SCTP_RTOINFOcxx . . $ `<external>/17169092326581286071/sctp.h:69:9`!, &grtoinfo, &len); |
| 98 | if (ret < 0) |
| 99 | tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "getsockopt SCTP_RTOINFO " |
| 100 | "ret:%d, errno:%d", ret, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 101 | |
| 102 | /* TEST3 Compare the get values with the set values. */ |
| 103 | if (srtoinfo.srto_initialcxx . . $ sctp_rtoinfo#srto_initial. != grtoinfo.srto_initialcxx . . $ sctp_rtoinfo#srto_initial. && |
| 104 | srtoinfo.srto_maxcxx . . $ sctp_rtoinfo#srto_max. != grtoinfo.srto_maxcxx . . $ sctp_rtoinfo#srto_max. && |
| 105 | srtoinfo.srto_mincxx . . $ sctp_rtoinfo#srto_min. != grtoinfo.srto_mincxx . . $ sctp_rtoinfo#srto_min.) |
| 106 | tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "setsockopt/getsockopt SCTP_RTOINFO " |
| 107 | "compare failed"); |
| 108 | |
| 109 | tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "setsockopt()/getsockopt SCTP_RTOINFO compare - " |
| 110 | "SUCCESS"); |
| 111 | |
| 112 | closecxx . . $ close(7864480464b09eea).(sd); |
| 113 | |
| 114 | return 0; |
| 115 | } |