| 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 sendmsg() call for 1-1 style sockets |
| 6 | * |
| 7 | * TEST1: Bad socket descriptor |
| 8 | * TEST2: Invalid socket |
| 9 | * TEST3: On a listening socket |
| 10 | * TEST4: Invalid iovec pointer |
| 11 | * TEST5: Invalid iovec length |
| 12 | * TEST6: Invalid msghdr pointer |
| 13 | * TEST7: Invalid sinfo flags |
| 14 | * TEST8: SCTP_EOF flag set |
| 15 | * TEST9: SCTP_ABORT flag set |
| 16 | * TEST10: On a closed association |
| 17 | * |
| 18 | * TEST11: Sending data from server socket to client socket |
| 19 | * TEST12: Sending data from client socket to server socket |
| 20 | * TEST13: Sending data from unconnected client to server |
| 21 | * TEST14: Sending a message on SHUT_RD socket |
| 22 | * |
| 23 | * The SCTP implementation is free software; |
| 24 | * you can redistribute it and/or modify it under the terms of |
| 25 | * the GNU General Public License as published by |
| 26 | * the Free Software Foundation; either version 2, or (at your option) |
| 27 | * any later version. |
| 28 | * |
| 29 | * The SCTP implementation is distributed in the hope that it |
| 30 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
| 31 | * ************************ |
| 32 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 33 | * See the GNU General Public License for more details. |
| 34 | * |
| 35 | * You should have received a copy of the GNU General Public License |
| 36 | * along with GNU CC; see the file COPYING. If not, write to |
| 37 | * the Free Software Foundation, 59 Temple Place - Suite 330, |
| 38 | * Boston, MA 02111-1307, USA. |
| 39 | * |
| 40 | * Please send any bug reports or fixes you make to the |
| 41 | * email address(es): |
| 42 | * lksctp developers <[email protected]> |
| 43 | * |
| 44 | * Or submit a bug report through the following website: |
| 45 | * https://github.com/sctp/lksctp-tools/ |
| 46 | * |
| 47 | * Any bugs reported given to us we will try to fix... any fixes shared will |
| 48 | * be incorporated into the next SCTP release |
| 49 | * |
| 50 | */ |
| 51 | |
| 52 | #include <stdio.h> |
| 53 | #include <unistd.h> |
| 54 | #include <fcntl.h> |
| 55 | #include <stdlib.h> |
| 56 | #include <string.h> |
| 57 | #include <sys/types.h> |
| 58 | #include <sys/socket.h> |
| 59 | #include <netinet/in.h> /* for sockaddr_in */ |
| 60 | #include <arpa/inet.h> |
| 61 | #include <errno.h> |
| 62 | #include <netinet/sctp.h>cxx . . $ `<file>/src/include/netinet/sctp.h`/ |
| 63 | #include <sys/uio.h> |
| 64 | #include <linux/socket.h> |
| 65 | #include <sctputil.h>cxx . . $ `<file>/src/testlib/sctputil.h`/ |
| 66 | |
| 67 | char *TCIDcxx . . $ TCID. = __FILE__; |
| 68 | int TST_TOTALcxx . . $ TST_TOTAL. = 14; |
| 69 | int TST_CNTcxx . . $ TST_CNT. = 0; |
| 70 | |
| 71 | int |
| 72 | maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[]) |
| 73 | { |
| 74 | socklen_tcxx . . $ socklen_t# len; |
| 75 | int msg_count; |
| 76 | int sk,sk1,pf_class,lstn_sk,acpt_sk,acpt1_sk, flag; |
| 77 | struct msghdrcxx . . $ msghdr# outmessage; |
| 78 | char *message = "hello, world!\n"; |
| 79 | struct sctp_sndrcvinfocxx . . $ sctp_sndrcvinfo# *sinfo; |
| 80 | int count; |
| 81 | char outcmsg[CMSG_SPACEcxx . . $ `<external>/8962547315054503424/socket.h:309:9`!(sizeof(struct sctp_sndrcvinfo))]; |
| 82 | struct cmsghdrcxx . . $ cmsghdr# *cmsg; |
| 83 | struct ioveccxx . . $ iovec# out_iov; |
| 84 | struct msghdrcxx . . $ msghdr# inmessage; |
| 85 | char * buffer_rcv; |
| 86 | struct sockaddr_incxx . . $ sockaddr_in# conn_addr,lstn_addr,svr_addr; |
| 87 | struct ioveccxx . . $ iovec# iov_rcv; |
| 88 | char incmsg[CMSG_SPACEcxx . . $ `<external>/8962547315054503424/socket.h:309:9`!(sizeof(sctp_cmsg_data_t))]; |
| 89 | int fd, err_no = 0; |
| 90 | char filename[21]; |
| 91 | |
| 92 | /* Rather than fflush() throughout the code, set stdout to |
| 93 | * be unbuffered. |
| 94 | */ |
| 95 | 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); |
| 96 | 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); |
| 97 | |
| 98 | pf_class = PF_INETcxx . . $ `<external>/8962547315054503424/socket.h:45:9`!; |
| 99 | |
| 100 | sk = test_socketcxx . . $ test_socket(2326284602b0bb2d).(pf_class, SOCK_STREAMcxx . . $ `<external>/5956532346368192945/socket_type.h:28:9`!, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!); |
| 101 | |
| 102 | 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`!); |
| 103 | |
| 104 | lstn_sk = test_socketcxx . . $ test_socket(2326284602b0bb2d).(pf_class, SOCK_STREAMcxx . . $ `<external>/5956532346368192945/socket_type.h:28:9`!, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!); |
| 105 | |
| 106 | conn_addr.sin_familycxx . . $ sockaddr_in#sin_family. = AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!; |
| 107 | conn_addr.sin_addrcxx . . $ sockaddr_in#sin_addr..s_addrcxx . . $ in_addr#s_addr. = SCTP_IP_LOOPBACKcxx . . $ `src/testlib/sctputil.h:76:9`!; |
| 108 | conn_addr.sin_portcxx . . $ sockaddr_in#sin_port. = htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(SCTP_TESTPORT_1cxx . . $ `src/testlib/sctputil.h:71:9`!); |
| 109 | |
| 110 | lstn_addr.sin_familycxx . . $ sockaddr_in#sin_family. = AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!; |
| 111 | lstn_addr.sin_addrcxx . . $ sockaddr_in#sin_addr..s_addrcxx . . $ in_addr#s_addr. = SCTP_IP_LOOPBACKcxx . . $ `src/testlib/sctputil.h:76:9`!; |
| 112 | lstn_addr.sin_portcxx . . $ sockaddr_in#sin_port. = htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(SCTP_TESTPORT_1cxx . . $ `src/testlib/sctputil.h:71:9`!); |
| 113 | |
| 114 | /*Binding the listen socket*/ |
| 115 | test_bindcxx . . $ test_bind(18e507052d945257).(lstn_sk, (struct sockaddrcxx . . $ sockaddr# *) &lstn_addr, sizeof(lstn_addr)); |
| 116 | |
| 117 | /*Listening the socket*/ |
| 118 | test_listencxx . . $ test_listen(9b79fb6aee4c0440).(lstn_sk, 10); |
| 119 | |
| 120 | len = sizeof(struct sockaddr_incxx . . $ sockaddr_in#); |
| 121 | |
| 122 | test_connectcxx . . $ test_connect(18e507052d945257).(sk, (struct sockaddrcxx . . $ sockaddr# *) &conn_addr, len); |
| 123 | |
| 124 | acpt_sk = test_acceptcxx . . $ test_accept(46fcd054f4a4d98b).(lstn_sk, (struct sockaddrcxx . . $ sockaddr# *)&svr_addr, &len); |
| 125 | |
| 126 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&outmessage, 0, sizeof(outmessage)); |
| 127 | outmessage.msg_namecxx . . $ msghdr#msg_name. = &conn_addr; |
| 128 | outmessage.msg_namelencxx . . $ msghdr#msg_namelen. = sizeof(conn_addr); |
| 129 | outmessage.msg_iovcxx . . $ msghdr#msg_iov. = &out_iov; |
| 130 | outmessage.msg_iovlencxx . . $ msghdr#msg_iovlen. = 1; |
| 131 | outmessage.msg_controlcxx . . $ msghdr#msg_control. = outcmsg; |
| 132 | outmessage.msg_controllencxx . . $ msghdr#msg_controllen. = sizeof(outcmsg); |
| 133 | outmessage.msg_flagscxx . . $ msghdr#msg_flags. = 0; |
| 134 | |
| 135 | cmsg = CMSG_FIRSTHDRcxx . . $ `<external>/8962547315054503424/socket.h:304:9`!(&outmessage); |
| 136 | cmsg->cmsg_levelcxx . . $ cmsghdr#cmsg_level. = IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!; |
| 137 | cmsg->cmsg_typecxx . . $ cmsghdr#cmsg_type. = SCTP_SNDRCVcxx . . $ `<external>/17169092326581286071/sctp.h:333:9`!; |
| 138 | cmsg->cmsg_lencxx . . $ cmsghdr#cmsg_len. = CMSG_LENcxx . . $ `<external>/8962547315054503424/socket.h:311:9`!(sizeof(struct sctp_sndrcvinfo)); |
| 139 | outmessage.msg_controllencxx . . $ msghdr#msg_controllen. = cmsg->cmsg_lencxx . . $ cmsghdr#cmsg_len.; |
| 140 | sinfo = (struct sctp_sndrcvinfocxx . . $ sctp_sndrcvinfo# *)CMSG_DATAcxx . . $ `<external>/8962547315054503424/socket.h:299:10`!(cmsg); |
| 141 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(sinfo, 0x00, sizeof(struct sctp_sndrcvinfocxx . . $ sctp_sndrcvinfo#)); |
| 142 | |
| 143 | outmessage.msg_iovcxx . . $ msghdr#msg_iov.->iov_basecxx . . $ iovec#iov_base. = message; |
| 144 | outmessage.msg_iovcxx . . $ msghdr#msg_iov.->iov_lencxx . . $ iovec#iov_len. = strlencxx . . $ strlen(751346f8406fd082).(message) + 1; |
| 145 | |
| 146 | flag = MSG_NOSIGNALcxx . . $ `<external>/8962547315054503424/socket.h:242:9`!; |
| 147 | /*sendmsg () TEST1: Bad socket descriptor, EBADF Expected error*/ |
| 148 | count = sendmsgcxx . . $ sendmsg(bc65c149164ceef5).(-1, &outmessage, flag); |
| 149 | if (count != -1 || errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != EBADFcxx . . $ `<external>/8987895939074593727/errno-base.h:13:9`!) |
| 150 | tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "sendmsg with a bad socket " |
| 151 | "descriptor count:%d, errno:%d", count, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 152 | |
| 153 | tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "sendmsg() with a bad socket descriptor - EBADF"); |
| 154 | |
| 155 | /*sendmsg () TEST2: Invalid socket, ENOTSOCK Expected error*/ |
| 156 | strcpycxx . . $ strcpy(b7b3a83273496486).(filename, "/tmp/sctptest.XXXXXX"); |
| 157 | fd = mkstempcxx . . $ mkstemp(1ef8e6ec083aabb9).(filename); |
| 158 | if (fd == -1) |
| 159 | tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "Failed to mkstemp %s: %s", |
| 160 | filename, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 161 | count = sendmsgcxx . . $ sendmsg(bc65c149164ceef5).(fd, &outmessage, flag); |
| 162 | if (count == -1) |
| 163 | err_no = errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!; |
| 164 | closecxx . . $ close(7864480464b09eea).(fd); |
| 165 | unlinkcxx . . $ unlink(5c4306d8553b3696).(filename); |
| 166 | if (count != -1 || err_no != ENOTSOCKcxx . . $ `<external>/17922322188510340118/errno.h:72:9`!) |
| 167 | tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "sendmsg with invalid socket " |
| 168 | "count:%d, errno:%d", count, err_no); |
| 169 | |
| 170 | tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "sendmsg() with invalid socket - ENOTSOCK"); |
| 171 | |
| 172 | /*sendmsg () TEST3: sendmsg on listening socket, EPIPE Expected error*/ |
| 173 | count = sendmsgcxx . . $ sendmsg(bc65c149164ceef5).(lstn_sk, &outmessage, flag); |
| 174 | if (count != -1 || errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != EPIPEcxx . . $ `<external>/8987895939074593727/errno-base.h:36:9`!) |
| 175 | tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "sendmsg on a listening socket " |
| 176 | "count:%d, errno:%d", count, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 177 | |
| 178 | tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "sendmsg() on a listening socket - EPIPE"); |
| 179 | |
| 180 | /*sendmsg () TEST4: Invalid iovec pointer EFAULT, Expected error*/ |
| 181 | outmessage.msg_iovcxx . . $ msghdr#msg_iov. = (struct ioveccxx . . $ iovec# *)-1; |
| 182 | count = sendmsgcxx . . $ sendmsg(bc65c149164ceef5).(sk, &outmessage, flag); |
| 183 | if (count != -1 || errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != EFAULTcxx . . $ `<external>/8987895939074593727/errno-base.h:18:9`!) |
| 184 | tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "sendmsg with invalid iovec " |
| 185 | "pointer count:%d, errno:%d", count, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 186 | |
| 187 | tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "sendmsg() with invalid iovec ptr - EFAULT"); |
| 188 | |
| 189 | outmessage.msg_iovcxx . . $ msghdr#msg_iov. = &out_iov; |
| 190 | |
| 191 | /*sendmsg () TEST5: Invalid iovec count EINVAL, Expected error*/ |
| 192 | outmessage.msg_iovlencxx . . $ msghdr#msg_iovlen. = 0; |
| 193 | count = sendmsgcxx . . $ sendmsg(bc65c149164ceef5).(sk, &outmessage, flag); |
| 194 | if (count != -1 || errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!) |
| 195 | tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "sendmsg with invalid iovec " |
| 196 | "length count:%d, errno:%d", count, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 197 | |
| 198 | tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "sendmsg() with invalid iovec length - EINVAL"); |
| 199 | |
| 200 | outmessage.msg_iovlencxx . . $ msghdr#msg_iovlen. = 1; |
| 201 | |
| 202 | /*sendmsg () TEST6: Invalid msghdr pointer EFAULT, Expected error*/ |
| 203 | count = sendmsgcxx . . $ sendmsg(bc65c149164ceef5).(sk, (struct msghdrcxx . . $ msghdr# *)-1, flag); |
| 204 | if (count != -1 || errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != EFAULTcxx . . $ `<external>/8987895939074593727/errno-base.h:18:9`!) |
| 205 | tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "sendmsg with invalid msghdr " |
| 206 | "pointer count:%d, errno:%d", count, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 207 | |
| 208 | tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "sendmsg() with invalid msghdr ptr - EFAULT"); |
| 209 | |
| 210 | /*sendmsg () TEST7: Invalid sinfo flag EINVAL, Expected error*/ |
| 211 | sinfo->sinfo_flagscxx . . $ sctp_sndrcvinfo#sinfo_flags. = 999; |
| 212 | count = sendmsgcxx . . $ sendmsg(bc65c149164ceef5).(sk, &outmessage, -1); |
| 213 | if (count != -1 || errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!) |
| 214 | tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "sendmsg with invalid sinfo " |
| 215 | "flags count:%d, errno:%d", count, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 216 | |
| 217 | tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "sendmsg() with invalid sinfo flags - EINVAL"); |
| 218 | |
| 219 | /*sendmsg () TEST8: SCTP_EOF flag EINVAL, Expected error*/ |
| 220 | sinfo->sinfo_flagscxx . . $ sctp_sndrcvinfo#sinfo_flags. = SCTP_EOFcxx . . $ SCTP_EOF.; |
| 221 | count = sendmsgcxx . . $ sendmsg(bc65c149164ceef5).(sk, &outmessage, flag); |
| 222 | if (count != -1 || errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!) |
| 223 | tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "sendmsg with SCTP_EOF flag " |
| 224 | "count:%d, errno:%d", count, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 225 | |
| 226 | tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "sendmsg() with SCTP_EOF flag - EINVAL"); |
| 227 | |
| 228 | /*sendmsg () TEST9: SCTP_ABORT flag EINVAL, Expected error*/ |
| 229 | sinfo->sinfo_flagscxx . . $ sctp_sndrcvinfo#sinfo_flags. = SCTP_ABORTcxx . . $ SCTP_ABORT.; |
| 230 | count = sendmsgcxx . . $ sendmsg(bc65c149164ceef5).(sk, &outmessage, flag); |
| 231 | if (count != -1 || errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!) |
| 232 | tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "sendmsg with SCTP_ABORT flag " |
| 233 | "count:%d, errno:%d", count, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 234 | |
| 235 | tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "sendmsg() with SCTP_ABORT flag - EINVAL"); |
| 236 | |
| 237 | sinfo->sinfo_flagscxx . . $ sctp_sndrcvinfo#sinfo_flags. = 0; |
| 238 | |
| 239 | test_connectcxx . . $ test_connect(18e507052d945257).(sk1, (struct sockaddrcxx . . $ sockaddr# *) &lstn_addr, len); |
| 240 | |
| 241 | test_sendmsgcxx . . $ test_sendmsg(c45a39c477f473e).(sk1, &outmessage, flag, strlencxx . . $ strlen(751346f8406fd082).(message)+1); |
| 242 | |
| 243 | closecxx . . $ close(7864480464b09eea).(sk1); |
| 244 | acpt1_sk = test_acceptcxx . . $ test_accept(46fcd054f4a4d98b).(lstn_sk, (struct sockaddrcxx . . $ sockaddr# *)&conn_addr, &len); |
| 245 | |
| 246 | /*sendmsg () TEST10:sendmsg on closed association, EPIPE Expected error*/ |
| 247 | count = sendmsgcxx . . $ sendmsg(bc65c149164ceef5).(acpt1_sk, &outmessage, flag); |
| 248 | if (count != -1 || errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != EPIPEcxx . . $ `<external>/8987895939074593727/errno-base.h:36:9`!) |
| 249 | tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "sendmsg on a closed association " |
| 250 | "count:%d, errno:%d", count, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 251 | |
| 252 | tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "sendmsg() on a closed association - EPIPE"); |
| 253 | |
| 254 | closecxx . . $ close(7864480464b09eea).(acpt1_sk); |
| 255 | closecxx . . $ close(7864480464b09eea).(sk); |
| 256 | closecxx . . $ close(7864480464b09eea).(lstn_sk); |
| 257 | closecxx . . $ close(7864480464b09eea).(acpt_sk); |
| 258 | |
| 259 | sk = test_socketcxx . . $ test_socket(2326284602b0bb2d).(pf_class, SOCK_STREAMcxx . . $ `<external>/5956532346368192945/socket_type.h:28:9`!, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!); |
| 260 | |
| 261 | lstn_sk = test_socketcxx . . $ test_socket(2326284602b0bb2d).(pf_class, SOCK_STREAMcxx . . $ `<external>/5956532346368192945/socket_type.h:28:9`!, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!); |
| 262 | |
| 263 | conn_addr.sin_familycxx . . $ sockaddr_in#sin_family. = AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!; |
| 264 | conn_addr.sin_addrcxx . . $ sockaddr_in#sin_addr..s_addrcxx . . $ in_addr#s_addr. = SCTP_IP_LOOPBACKcxx . . $ `src/testlib/sctputil.h:76:9`!; |
| 265 | conn_addr.sin_portcxx . . $ sockaddr_in#sin_port. = htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(SCTP_TESTPORT_1cxx . . $ `src/testlib/sctputil.h:71:9`!); |
| 266 | |
| 267 | lstn_addr.sin_familycxx . . $ sockaddr_in#sin_family. = AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!; |
| 268 | lstn_addr.sin_addrcxx . . $ sockaddr_in#sin_addr..s_addrcxx . . $ in_addr#s_addr. = SCTP_IP_LOOPBACKcxx . . $ `src/testlib/sctputil.h:76:9`!; |
| 269 | lstn_addr.sin_portcxx . . $ sockaddr_in#sin_port. = htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(SCTP_TESTPORT_1cxx . . $ `src/testlib/sctputil.h:71:9`!); |
| 270 | |
| 271 | /*Binding the listen socket*/ |
| 272 | test_bindcxx . . $ test_bind(18e507052d945257).(lstn_sk, (struct sockaddrcxx . . $ sockaddr# *) &lstn_addr, sizeof(lstn_addr)); |
| 273 | |
| 274 | /*Listening the socket*/ |
| 275 | test_listencxx . . $ test_listen(9b79fb6aee4c0440).(lstn_sk, 10); |
| 276 | |
| 277 | len = sizeof(struct sockaddr_incxx . . $ sockaddr_in#); |
| 278 | flag = MSG_NOSIGNALcxx . . $ `<external>/8962547315054503424/socket.h:242:9`!; |
| 279 | |
| 280 | test_connectcxx . . $ test_connect(18e507052d945257).(sk, (struct sockaddrcxx . . $ sockaddr# *) &conn_addr, len); |
| 281 | |
| 282 | acpt_sk = test_acceptcxx . . $ test_accept(46fcd054f4a4d98b).(lstn_sk, (struct sockaddrcxx . . $ sockaddr# *)&svr_addr, &len); |
| 283 | |
| 284 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&outmessage, 0, sizeof(outmessage)); |
| 285 | outmessage.msg_namecxx . . $ msghdr#msg_name. = &svr_addr; |
| 286 | outmessage.msg_namelencxx . . $ msghdr#msg_namelen. = sizeof(svr_addr); |
| 287 | outmessage.msg_iovcxx . . $ msghdr#msg_iov. = &out_iov; |
| 288 | outmessage.msg_iovlencxx . . $ msghdr#msg_iovlen. = 1; |
| 289 | outmessage.msg_controlcxx . . $ msghdr#msg_control. = outcmsg; |
| 290 | outmessage.msg_controllencxx . . $ msghdr#msg_controllen. = sizeof(outcmsg); |
| 291 | outmessage.msg_flagscxx . . $ msghdr#msg_flags. = 0; |
| 292 | |
| 293 | cmsg = CMSG_FIRSTHDRcxx . . $ `<external>/8962547315054503424/socket.h:304:9`!(&outmessage); |
| 294 | cmsg->cmsg_levelcxx . . $ cmsghdr#cmsg_level. = IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!; |
| 295 | cmsg->cmsg_typecxx . . $ cmsghdr#cmsg_type. = SCTP_SNDRCVcxx . . $ `<external>/17169092326581286071/sctp.h:333:9`!; |
| 296 | cmsg->cmsg_lencxx . . $ cmsghdr#cmsg_len. = CMSG_LENcxx . . $ `<external>/8962547315054503424/socket.h:311:9`!(sizeof(struct sctp_sndrcvinfo)); |
| 297 | outmessage.msg_controllencxx . . $ msghdr#msg_controllen. = cmsg->cmsg_lencxx . . $ cmsghdr#cmsg_len.; |
| 298 | sinfo = (struct sctp_sndrcvinfocxx . . $ sctp_sndrcvinfo# *)CMSG_DATAcxx . . $ `<external>/8962547315054503424/socket.h:299:10`!(cmsg); |
| 299 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(sinfo, 0x00, sizeof(struct sctp_sndrcvinfocxx . . $ sctp_sndrcvinfo#)); |
| 300 | |
| 301 | outmessage.msg_iovcxx . . $ msghdr#msg_iov.->iov_basecxx . . $ iovec#iov_base. = message; |
| 302 | outmessage.msg_iovcxx . . $ msghdr#msg_iov.->iov_lencxx . . $ iovec#iov_len. = strlencxx . . $ strlen(751346f8406fd082).(message) + 1; |
| 303 | |
| 304 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&inmessage, 0, sizeof(inmessage)); |
| 305 | buffer_rcv = test_malloccxx . . $ test_malloc(bfcfa4d6b7f7ef64).(REALLY_BIGcxx . . $ `src/testlib/sctputil.h:65:9`!); |
| 306 | |
| 307 | iov_rcv.iov_basecxx . . $ iovec#iov_base. = buffer_rcv; |
| 308 | iov_rcv.iov_lencxx . . $ iovec#iov_len. = REALLY_BIGcxx . . $ `src/testlib/sctputil.h:65:9`!; |
| 309 | inmessage.msg_iovcxx . . $ msghdr#msg_iov. = &iov_rcv; |
| 310 | inmessage.msg_iovlencxx . . $ msghdr#msg_iovlen. = 1; |
| 311 | inmessage.msg_controlcxx . . $ msghdr#msg_control. = incmsg; |
| 312 | inmessage.msg_controllencxx . . $ msghdr#msg_controllen. = sizeof(incmsg); |
| 313 | |
| 314 | msg_count = strlencxx . . $ strlen(751346f8406fd082).(message) + 1; |
| 315 | |
| 316 | /*sendmsg() TEST11: Sending data from server socket to client socket*/ |
| 317 | count = sendmsgcxx . . $ sendmsg(bc65c149164ceef5).(acpt_sk, &outmessage, flag); |
| 318 | if (count != msg_count) |
| 319 | tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "sendmsg from accept socket to " |
| 320 | "client count:%d, errno:%d", count, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 321 | |
| 322 | tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "sendmsg() from accept socket to client - SUCCESS"); |
| 323 | |
| 324 | count = test_recvmsgcxx . . $ test_recvmsg(2284ea468be03a33).(sk, &inmessage, flag); |
| 325 | test_check_msg_datacxx . . $ test_check_msg_data(87a4c472fd2f0d28).(&inmessage, count, msg_count, MSG_EORcxx . . $ `<external>/8962547315054503424/socket.h:228:9`!, 0, 0); |
| 326 | |
| 327 | outmessage.msg_namecxx . . $ msghdr#msg_name. = &conn_addr; |
| 328 | outmessage.msg_namelencxx . . $ msghdr#msg_namelen. = sizeof(conn_addr); |
| 329 | /*sendmsg() TEST12: Sending data from client socket to server socket*/ |
| 330 | count = sendmsgcxx . . $ sendmsg(bc65c149164ceef5).(sk, &outmessage, flag); |
| 331 | if (count != msg_count) |
| 332 | tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "sendmsg from client to server " |
| 333 | "count:%d, errno:%d", count, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 334 | |
| 335 | tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "sendmsg() from client to server - SUCCESS"); |
| 336 | |
| 337 | count = test_recvmsgcxx . . $ test_recvmsg(2284ea468be03a33).(acpt_sk, &inmessage, flag); |
| 338 | test_check_msg_datacxx . . $ test_check_msg_data(87a4c472fd2f0d28).(&inmessage, count, msg_count, MSG_EORcxx . . $ `<external>/8962547315054503424/socket.h:228:9`!, 0, 0); |
| 339 | |
| 340 | outmessage.msg_namecxx . . $ msghdr#msg_name. = &conn_addr; |
| 341 | outmessage.msg_namelencxx . . $ msghdr#msg_namelen. = sizeof(conn_addr); |
| 342 | closecxx . . $ close(7864480464b09eea).(sk); |
| 343 | closecxx . . $ close(7864480464b09eea).(acpt_sk); |
| 344 | 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`!); |
| 345 | |
| 346 | /*sendmsg() TEST13: Sending data from unconnected client socket to |
| 347 | server socket*/ |
| 348 | count = sendmsgcxx . . $ sendmsg(bc65c149164ceef5).(sk1, &outmessage, flag); |
| 349 | if (count != msg_count) |
| 350 | tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "sendmsg from unconnected client to " |
| 351 | "server count:%d, errno:%d", count, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 352 | |
| 353 | tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "sendmsg() from unconnected clt to server - SUCCESS"); |
| 354 | |
| 355 | acpt_sk = test_acceptcxx . . $ test_accept(46fcd054f4a4d98b).(lstn_sk, (struct sockaddrcxx . . $ sockaddr# *)&svr_addr, &len); |
| 356 | |
| 357 | count = test_recvmsgcxx . . $ test_recvmsg(2284ea468be03a33).(acpt_sk, &inmessage, flag); |
| 358 | test_check_msg_datacxx . . $ test_check_msg_data(87a4c472fd2f0d28).(&inmessage, count, msg_count, MSG_EORcxx . . $ `<external>/8962547315054503424/socket.h:228:9`!, 0, 0); |
| 359 | |
| 360 | test_shutdowncxx . . $ test_shutdown(9b79fb6aee4c0440).(sk1, SHUT_RDcxx . . $ `<external>/14344695994193663403/socket.h:44:9`!); |
| 361 | |
| 362 | /*sendmsg() TEST14: Sending a message on SHUT_RD socket*/ |
| 363 | count = sendmsgcxx . . $ sendmsg(bc65c149164ceef5).(sk1, &outmessage, flag); |
| 364 | if (count != msg_count) |
| 365 | tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "sendmsg on a SHUT_RD socket " |
| 366 | "count:%d, errno:%d", count, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!); |
| 367 | |
| 368 | tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "sendmsg() on a SHUT_RD socket - SUCCESS"); |
| 369 | |
| 370 | count = test_recvmsgcxx . . $ test_recvmsg(2284ea468be03a33).(acpt_sk, &inmessage, flag); |
| 371 | test_check_msg_datacxx . . $ test_check_msg_data(87a4c472fd2f0d28).(&inmessage, count, msg_count, MSG_EORcxx . . $ `<external>/8962547315054503424/socket.h:228:9`!, 0, 0); |
| 372 | |
| 373 | closecxx . . $ close(7864480464b09eea).(sk1); |
| 374 | closecxx . . $ close(7864480464b09eea).(lstn_sk); |
| 375 | closecxx . . $ close(7864480464b09eea).(acpt_sk); |
| 376 | |
| 377 | freecxx . . $ free(5d22bdacc48458e8).(buffer_rcv); |
| 378 | return 0; |
| 379 | } |