| 1 | /* SCTP kernel reference Implementation |
| 2 | * (C) Copyright Fujitsu Ltd. 2008, 2009 |
| 3 | * |
| 4 | * The SCTP reference implementation is free software; |
| 5 | * you can redistribute it and/or modify it under the terms of |
| 6 | * the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2, or (at your option) |
| 8 | * any later version. |
| 9 | * |
| 10 | * The SCTP reference implementation is distributed in the hope that it |
| 11 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
| 12 | * ************************ |
| 13 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 14 | * See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with GNU CC; see the file COPYING. If not, write to |
| 18 | * the Free Software Foundation, 59 Temple Place - Suite 330, |
| 19 | * Boston, MA 02111-1307, USA. |
| 20 | * |
| 21 | * Please send any bug reports or fixes you make to the |
| 22 | * email address(es): |
| 23 | * lksctp developers <[email protected]> |
| 24 | * |
| 25 | * Or submit a bug report through the following website: |
| 26 | * https://github.com/sctp/lksctp-tools/ |
| 27 | * |
| 28 | * Any bugs reported to us we will try to fix... any fixes shared will |
| 29 | * be incorporated into the next SCTP release. |
| 30 | * |
| 31 | * Written or modified by: |
| 32 | * Wei Yongjun <[email protected]> |
| 33 | */ |
| 34 | |
| 35 | #include <stdio.h> |
| 36 | #include <stdlib.h> |
| 37 | #include <sys/types.h> |
| 38 | #include <sys/socket.h> |
| 39 | #include <arpa/inet.h> |
| 40 | #include <net/if.h> |
| 41 | #include <netinet/sctp.h>cxx . . $ `<file>/src/include/netinet/sctp.h`/ |
| 42 | #include <signal.h> |
| 43 | #include <sys/time.h> |
| 44 | #include <unistd.h> |
| 45 | #include <errno.h> |
| 46 | #include <netdb.h> |
| 47 | #include <string.h> |
| 48 | |
| 49 | #define DEFAULT_SECcxx . . $ `src/apps/sctp_status.c:49:9`! 0 |
| 50 | #define DEFAULT_USECcxx . . $ `src/apps/sctp_status.c:50:9`! 5000 |
| 51 | |
| 52 | #define REALLY_BIGcxx . . $ `src/apps/sctp_status.c:52:9`! 65536 |
| 53 | |
| 54 | #define SERVERcxx . . $ `src/apps/sctp_status.c:54:9`! 0 |
| 55 | #define CLIENTcxx . . $ `src/apps/sctp_status.c:55:9`! 1 |
| 56 | #define NOT_DEFINEDcxx . . $ `src/apps/sctp_status.c:56:9`! 666 |
| 57 | |
| 58 | #define DEBUG_NONEcxx . . $ `src/apps/sctp_status.c:58:9`! 0 |
| 59 | #define DEBUG_MINcxx . . $ `src/apps/sctp_status.c:59:9`! 1 |
| 60 | #define DEBUG_MAXcxx . . $ `src/apps/sctp_status.c:60:9`! 2 |
| 61 | |
| 62 | #define ORDER_PATTERN_UNORDEREDcxx . . $ `src/apps/sctp_status.c:62:9`! 0 |
| 63 | #define ORDER_PATTERN_ORDEREDcxx . . $ `src/apps/sctp_status.c:63:9`! 1 |
| 64 | #define ORDER_PATTERN_ALTERNATEcxx . . $ `src/apps/sctp_status.c:64:9`! 2 |
| 65 | #define ORDER_PATTERN_RANDOMcxx . . $ `src/apps/sctp_status.c:65:9`! 3 |
| 66 | |
| 67 | #define STREAM_PATTERN_SEQUENTIALcxx . . $ `src/apps/sctp_status.c:67:9`! 0 |
| 68 | #define STREAM_PATTERN_RANDOMcxx . . $ `src/apps/sctp_status.c:68:9`! 1 |
| 69 | |
| 70 | #define MAX_BIND_RETRYScxx . . $ `src/apps/sctp_status.c:70:9`! 10 |
| 71 | #define BIG_REPEATcxx . . $ `src/apps/sctp_status.c:71:9`! 1000000 |
| 72 | #define REPEATcxx . . $ `src/apps/sctp_status.c:72:9`! 10 |
| 73 | |
| 74 | #define DEFAULT_MAX_WINDOWcxx . . $ `src/apps/sctp_status.c:74:9`! 32768 |
| 75 | #define DEFAULT_MIN_WINDOWcxx . . $ `src/apps/sctp_status.c:75:9`! 1500 |
| 76 | |
| 77 | #define MSG_CNTcxx . . $ `src/apps/sctp_status.c:77:9`! 10 |
| 78 | |
| 79 | #define DEBUG_PRINTcxx . . $ `src/apps/sctp_status.c:79:9`!(level, print_this...) \ |
| 80 | { \ |
| 81 | if (debug_level >= level) { \ |
| 82 | fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!, print_this); \ |
| 83 | fflush(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!); \ |
| 84 | } \ |
| 85 | } /* DEBUG_PRINT */ |
| 86 | |
| 87 | char *local_hostcxx . . $ local_host. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 88 | int local_portcxx . . $ local_port. = 0; |
| 89 | char *remote_hostcxx . . $ remote_host. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 90 | int remote_portcxx . . $ remote_port. = 0; |
| 91 | struct sockaddr_storagecxx . . $ sockaddr_storage# s_remcxx . . $ s_rem., s_loccxx . . $ s_loc.; |
| 92 | int r_lencxx . . $ r_len., l_lencxx . . $ l_len.; |
| 93 | int size_argcxx . . $ size_arg. = 0; |
| 94 | int debug_levelcxx . . $ debug_level. = DEBUG_NONEcxx . . $ `src/apps/sctp_status.c:58:9`!; |
| 95 | int order_patterncxx . . $ order_pattern. = ORDER_PATTERN_UNORDEREDcxx . . $ `src/apps/sctp_status.c:62:9`!; |
| 96 | int order_statecxx . . $ order_state. = 0; |
| 97 | int stream_patterncxx . . $ stream_pattern. = STREAM_PATTERN_SEQUENTIALcxx . . $ `src/apps/sctp_status.c:67:9`!; |
| 98 | int stream_statecxx . . $ stream_state. = 0; |
| 99 | int repeatcxx . . $ repeat. = REPEATcxx . . $ `src/apps/sctp_status.c:72:9`!; |
| 100 | int repeat_countcxx . . $ repeat_count. = 0; |
| 101 | int max_msgsizecxx . . $ max_msgsize. = DEFAULT_MAX_WINDOWcxx . . $ `src/apps/sctp_status.c:74:9`!; |
| 102 | int msg_cntcxx . . $ msg_cnt. = MSG_CNTcxx . . $ `src/apps/sctp_status.c:77:9`!; |
| 103 | int draincxx . . $ drain. = 0; |
| 104 | int max_streamcxx . . $ max_stream. = 0; |
| 105 | int gskcxx . . $ gsk. = -1; |
| 106 | int periodcxx . . $ period. = 1; |
| 107 | char *statusfilecxx . . $ statusfile. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 108 | |
| 109 | void printstatuscxx . . $ printstatus(d4f767463ce0a6b3).(int sk); |
| 110 | void sighandlercxx . . $ sighandler(d4f767463ce0a6b3).(int signo); |
| 111 | void settimerhandlecxx . . $ settimerhandle(49f6e7a06ebc5aa8).(void); |
| 112 | void usagecxx . . $ usage(fda57c8427c60377).(char *argv0); |
| 113 | void start_testcxx . . $ start_test(d4f767463ce0a6b3).(int role); |
| 114 | |
| 115 | unsigned char msgcxx . . $ msg.[] = "012345678901234567890123456789012345678901234567890"; |
| 116 | |
| 117 | /* Convenience structure to determine space needed for cmsg. */ |
| 118 | typedef unioncxx . . $ $anonymous_type_a594d3a17f0e3d31_0# { |
| 119 | struct sctp_initmsgcxx . . $ sctp_initmsg# initcxx . . $ $anonymous_type_a594d3a17f0e3d31_0#init.; |
| 120 | struct sctp_sndrcvinfocxx . . $ sctp_sndrcvinfo# sndrcvinfocxx . . $ $anonymous_type_a594d3a17f0e3d31_0#sndrcvinfo.; |
| 121 | } _sctp_cmsg_data_tcxx . . $ _sctp_cmsg_data_t#; |
| 122 | |
| 123 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[]) { |
| 124 | int c, role = NOT_DEFINEDcxx . . $ `src/apps/sctp_status.c:56:9`!; |
| 125 | char *interface = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 126 | struct sockaddr_incxx . . $ sockaddr_in# *t_addr; |
| 127 | struct sockaddr_in6cxx . . $ sockaddr_in6# *t_addr6; |
| 128 | |
| 129 | /* Parse the arguments. */ |
| 130 | while ((c = getoptcxx . . $ getopt(2483c31ff9bab884).(argc, argv, ":H:L:P:h:p:c:d:lm:sx:X:o:M:Di:I:f:")) >= 0 ) { |
| 131 | switch (c) { |
| 132 | case 'H': |
| 133 | local_hostcxx . . $ local_host. = optargcxx . . $ optarg.; |
| 134 | break; |
| 135 | case 'P': |
| 136 | local_portcxx . . $ local_port. = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.); |
| 137 | break; |
| 138 | case 'h': |
| 139 | remote_hostcxx . . $ remote_host. = optargcxx . . $ optarg.; |
| 140 | break; |
| 141 | case 'p': |
| 142 | remote_portcxx . . $ remote_port. = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.); |
| 143 | break; |
| 144 | case 'l': |
| 145 | if (role != NOT_DEFINEDcxx . . $ `src/apps/sctp_status.c:56:9`!) { |
| 146 | printfcxx . . $ printf(581fddd72a8db8fc).("%s: only -s or -l\n", argv[0]); |
| 147 | usagecxx . . $ usage(fda57c8427c60377).(argv[0]); |
| 148 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 149 | } |
| 150 | role = SERVERcxx . . $ `src/apps/sctp_status.c:54:9`!; |
| 151 | break; |
| 152 | case 's': |
| 153 | if (role != NOT_DEFINEDcxx . . $ `src/apps/sctp_status.c:56:9`!) { |
| 154 | printfcxx . . $ printf(581fddd72a8db8fc).("%s: only -s or -l\n", argv[0]); |
| 155 | usagecxx . . $ usage(fda57c8427c60377).(argv[0]); |
| 156 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 157 | } |
| 158 | role = CLIENTcxx . . $ `src/apps/sctp_status.c:55:9`!; |
| 159 | break; |
| 160 | case 'D': |
| 161 | draincxx . . $ drain. = 1; |
| 162 | break; |
| 163 | case 'd': |
| 164 | debug_levelcxx . . $ debug_level. = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.); |
| 165 | if (debug_levelcxx . . $ debug_level. < DEBUG_NONEcxx . . $ `src/apps/sctp_status.c:58:9`! |
| 166 | || debug_levelcxx . . $ debug_level. > DEBUG_MAXcxx . . $ `src/apps/sctp_status.c:60:9`!) { |
| 167 | usagecxx . . $ usage(fda57c8427c60377).(argv[0]); |
| 168 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 169 | } |
| 170 | break; |
| 171 | case 'I': |
| 172 | periodcxx . . $ period. = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.); |
| 173 | if (periodcxx . . $ period. < 0) { |
| 174 | usagecxx . . $ usage(fda57c8427c60377).(argv[0]); |
| 175 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 176 | } |
| 177 | break; |
| 178 | case 'x': |
| 179 | repeatcxx . . $ repeat. = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.); |
| 180 | if (!repeatcxx . . $ repeat.) { |
| 181 | repeatcxx . . $ repeat. = BIG_REPEATcxx . . $ `src/apps/sctp_status.c:71:9`!; |
| 182 | } |
| 183 | break; |
| 184 | case 'X': |
| 185 | msg_cntcxx . . $ msg_cnt. = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.); |
| 186 | if ((msg_cntcxx . . $ msg_cnt. <= 0) || (msg_cntcxx . . $ msg_cnt. > MSG_CNTcxx . . $ `src/apps/sctp_status.c:77:9`!)) { |
| 187 | usagecxx . . $ usage(fda57c8427c60377).(argv[0]); |
| 188 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 189 | } |
| 190 | break; |
| 191 | case 'c': |
| 192 | size_argcxx . . $ size_arg. = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.); |
| 193 | if (size_argcxx . . $ size_arg. < 0) { |
| 194 | usagecxx . . $ usage(fda57c8427c60377).(argv[0]); |
| 195 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 196 | } |
| 197 | |
| 198 | break; |
| 199 | case 'o': |
| 200 | order_patterncxx . . $ order_pattern. = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.); |
| 201 | if (order_patterncxx . . $ order_pattern. < ORDER_PATTERN_UNORDEREDcxx . . $ `src/apps/sctp_status.c:62:9`! |
| 202 | || order_patterncxx . . $ order_pattern. > ORDER_PATTERN_RANDOMcxx . . $ `src/apps/sctp_status.c:65:9`! ) { |
| 203 | usagecxx . . $ usage(fda57c8427c60377).(argv[0]); |
| 204 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 205 | } |
| 206 | break; |
| 207 | case 'M': |
| 208 | max_streamcxx . . $ max_stream. = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.); |
| 209 | if (max_streamcxx . . $ max_stream. < 0 |
| 210 | || max_streamcxx . . $ max_stream. >= (1<<16)) { |
| 211 | usagecxx . . $ usage(fda57c8427c60377).(argv[0]); |
| 212 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 213 | } |
| 214 | break; |
| 215 | case 'm': |
| 216 | max_msgsizecxx . . $ max_msgsize. = atoicxx . . $ atoi(5c4306d8553b3696).(optargcxx . . $ optarg.); |
| 217 | break; |
| 218 | case 'i': |
| 219 | interface = optargcxx . . $ optarg.; |
| 220 | break; |
| 221 | case 'f': |
| 222 | statusfilecxx . . $ statusfile. = optargcxx . . $ optarg.; |
| 223 | break; |
| 224 | case '?': |
| 225 | default: |
| 226 | usagecxx . . $ usage(fda57c8427c60377).(argv[0]); |
| 227 | exitcxx . . $ exit(3ca292c338df9bb3).(0); |
| 228 | } |
| 229 | } /* while() */ |
| 230 | |
| 231 | if (NOT_DEFINEDcxx . . $ `src/apps/sctp_status.c:56:9`! == role) { |
| 232 | usagecxx . . $ usage(fda57c8427c60377).(argv[0]); |
| 233 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 234 | } |
| 235 | |
| 236 | if (SERVERcxx . . $ `src/apps/sctp_status.c:54:9`! == role && NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! == local_hostcxx . . $ local_host. && remote_hostcxx . . $ remote_host. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 237 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s: Server needs local address, " |
| 238 | "not remote address\n", argv[0]); |
| 239 | usagecxx . . $ usage(fda57c8427c60377).(argv[0]); |
| 240 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 241 | } |
| 242 | if (CLIENTcxx . . $ `src/apps/sctp_status.c:55:9`! == role && NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! == remote_hostcxx . . $ remote_host.) { |
| 243 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s: Client needs at least remote address " |
| 244 | "& port\n", argv[0]); |
| 245 | usagecxx . . $ usage(fda57c8427c60377).(argv[0]); |
| 246 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 247 | } |
| 248 | |
| 249 | if (optindcxx . . $ optind. < argc) { |
| 250 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s: non-option arguments are illegal: ", argv[0]); |
| 251 | while (optindcxx . . $ optind. < argc) |
| 252 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s ", argv[optindcxx . . $ optind.++]); |
| 253 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac). (stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n"); |
| 254 | usagecxx . . $ usage(fda57c8427c60377).(argv[0]); |
| 255 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 256 | } |
| 257 | |
| 258 | if (remote_hostcxx . . $ remote_host. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! && remote_portcxx . . $ remote_port. != 0) { |
| 259 | struct addrinfocxx . . $ addrinfo# *res; |
| 260 | int error; |
| 261 | char *host_s, *serv_s; |
| 262 | |
| 263 | if ((host_s = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(NI_MAXHOSTcxx . . $ `<external>/564697342961150458/netdb.h:638:11`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 264 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n*** host_s malloc failed!!! ***\n"); |
| 265 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 266 | } |
| 267 | if ((serv_s = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(NI_MAXSERVcxx . . $ `<external>/564697342961150458/netdb.h:639:11`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 268 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n*** serv_s malloc failed!!! ***\n"); |
| 269 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 270 | } |
| 271 | |
| 272 | error = getaddrinfocxx . . $ getaddrinfo(f68af21b9849b03e).(remote_hostcxx . . $ remote_host., 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, &res); |
| 273 | if (error) { |
| 274 | printfcxx . . $ printf(581fddd72a8db8fc).("%s.\n", gai_strerrorcxx . . $ gai_strerror(f7ae7e56280f18ae).(error)); |
| 275 | usagecxx . . $ usage(fda57c8427c60377).(argv[0]); |
| 276 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 277 | } |
| 278 | |
| 279 | switch (res->ai_familycxx . . $ addrinfo#ai_family.) { |
| 280 | case AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!: |
| 281 | t_addr = (struct sockaddr_incxx . . $ sockaddr_in# *)&s_remcxx . . $ s_rem.; |
| 282 | |
| 283 | memcpycxx . . $ memcpy(cc817cb175f282d).(t_addr, res->ai_addrcxx . . $ addrinfo#ai_addr., |
| 284 | res->ai_addrlencxx . . $ addrinfo#ai_addrlen.); |
| 285 | t_addr->sin_familycxx . . $ sockaddr_in#sin_family. = res->ai_familycxx . . $ addrinfo#ai_family.; |
| 286 | t_addr->sin_portcxx . . $ sockaddr_in#sin_port. = htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(remote_port); |
| 287 | |
| 288 | r_lencxx . . $ r_len. = res->ai_addrlencxx . . $ addrinfo#ai_addrlen.; |
| 289 | #ifdef __FreeBSD__ |
| 290 | t_addr->sin_len = r_len; |
| 291 | #endif |
| 292 | break; |
| 293 | case AF_INET6cxx . . $ `<external>/8962547315054503424/socket.h:105:9`!: |
| 294 | t_addr6 = (struct sockaddr_in6cxx . . $ sockaddr_in6# *)&s_remcxx . . $ s_rem.; |
| 295 | |
| 296 | memcpycxx . . $ memcpy(cc817cb175f282d).(t_addr6, res->ai_addrcxx . . $ addrinfo#ai_addr., |
| 297 | res->ai_addrlencxx . . $ addrinfo#ai_addrlen.); |
| 298 | t_addr6->sin6_familycxx . . $ sockaddr_in6#sin6_family. = res->ai_familycxx . . $ addrinfo#ai_family.; |
| 299 | t_addr6->sin6_portcxx . . $ sockaddr_in6#sin6_port. = htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(remote_port); |
| 300 | if (interface) |
| 301 | t_addr6->sin6_scope_idcxx . . $ sockaddr_in6#sin6_scope_id. = if_nametoindexcxx . . $ if_nametoindex(c61c63047ce273de).(interface); |
| 302 | |
| 303 | r_lencxx . . $ r_len. = res->ai_addrlencxx . . $ addrinfo#ai_addrlen.; |
| 304 | |
| 305 | #ifdef __FreeBSD__ |
| 306 | t_addr6->sin6_len = r_len; |
| 307 | #endif |
| 308 | break; |
| 309 | } |
| 310 | |
| 311 | getnameinfocxx . . $ getnameinfo(44a49899269c09ff).((struct sockaddrcxx . . $ sockaddr# *)&s_remcxx . . $ s_rem., r_lencxx . . $ r_len., host_s, |
| 312 | NI_MAXHOSTcxx . . $ `<external>/564697342961150458/netdb.h:638:11`!, serv_s, NI_MAXSERVcxx . . $ `<external>/564697342961150458/netdb.h:639:11`!, NI_NUMERICHOSTcxx . . $ `<external>/564697342961150458/netdb.h:642:10`!); |
| 313 | |
| 314 | DEBUG_PRINTcxx . . $ `src/apps/sctp_status.c:79:9`!(DEBUG_MAXcxx . . $ `src/apps/sctp_status.c:60:9`!, "remote:addr=%s, port=%s, family=%d\n", |
| 315 | host_s, serv_s, res->ai_family); |
| 316 | |
| 317 | freecxx . . $ free(5d22bdacc48458e8).(host_s); |
| 318 | freecxx . . $ free(5d22bdacc48458e8).(serv_s); |
| 319 | freeaddrinfocxx . . $ freeaddrinfo(aadc8f19092a28e8).(res); |
| 320 | } |
| 321 | |
| 322 | if (local_hostcxx . . $ local_host. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 323 | struct addrinfocxx . . $ addrinfo# *res; |
| 324 | int error; |
| 325 | char *host_s, *serv_s; |
| 326 | struct sockaddr_incxx . . $ sockaddr_in# *t_addr; |
| 327 | struct sockaddr_in6cxx . . $ sockaddr_in6# *t_addr6; |
| 328 | |
| 329 | if ((host_s = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(NI_MAXHOSTcxx . . $ `<external>/564697342961150458/netdb.h:638:11`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 330 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n*** host_s malloc failed!!! ***\n"); |
| 331 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 332 | } |
| 333 | if ((serv_s = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(NI_MAXSERVcxx . . $ `<external>/564697342961150458/netdb.h:639:11`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 334 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n*** serv_s malloc failed!!! ***\n"); |
| 335 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 336 | } |
| 337 | |
| 338 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(local_hostcxx . . $ local_host., "0") == 0) |
| 339 | local_hostcxx . . $ local_host. = "0.0.0.0"; |
| 340 | |
| 341 | error = getaddrinfocxx . . $ getaddrinfo(f68af21b9849b03e).(local_hostcxx . . $ local_host., 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, &res); |
| 342 | if (error) { |
| 343 | printfcxx . . $ printf(581fddd72a8db8fc).("%s.\n", gai_strerrorcxx . . $ gai_strerror(f7ae7e56280f18ae).(error)); |
| 344 | usagecxx . . $ usage(fda57c8427c60377).(argv[0]); |
| 345 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 346 | } |
| 347 | |
| 348 | switch (res->ai_familycxx . . $ addrinfo#ai_family.) { |
| 349 | case AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!: |
| 350 | t_addr = (struct sockaddr_incxx . . $ sockaddr_in# *)&s_loccxx . . $ s_loc.; |
| 351 | |
| 352 | memcpycxx . . $ memcpy(cc817cb175f282d).(t_addr, res->ai_addrcxx . . $ addrinfo#ai_addr., |
| 353 | res->ai_addrlencxx . . $ addrinfo#ai_addrlen.); |
| 354 | t_addr->sin_familycxx . . $ sockaddr_in#sin_family. = res->ai_familycxx . . $ addrinfo#ai_family.; |
| 355 | t_addr->sin_portcxx . . $ sockaddr_in#sin_port. = htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(local_port); |
| 356 | |
| 357 | l_lencxx . . $ l_len. = res->ai_addrlencxx . . $ addrinfo#ai_addrlen.; |
| 358 | #ifdef __FreeBSD__ |
| 359 | t_addr->sin_len = l_len; |
| 360 | #endif |
| 361 | break; |
| 362 | case AF_INET6cxx . . $ `<external>/8962547315054503424/socket.h:105:9`!: |
| 363 | t_addr6 = (struct sockaddr_in6cxx . . $ sockaddr_in6# *)&s_loccxx . . $ s_loc.; |
| 364 | |
| 365 | memcpycxx . . $ memcpy(cc817cb175f282d).(t_addr6, res->ai_addrcxx . . $ addrinfo#ai_addr., |
| 366 | res->ai_addrlencxx . . $ addrinfo#ai_addrlen.); |
| 367 | t_addr6->sin6_familycxx . . $ sockaddr_in6#sin6_family. = res->ai_familycxx . . $ addrinfo#ai_family.; |
| 368 | t_addr6->sin6_portcxx . . $ sockaddr_in6#sin6_port. = htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(local_port); |
| 369 | if (interface) |
| 370 | t_addr6->sin6_scope_idcxx . . $ sockaddr_in6#sin6_scope_id. = if_nametoindexcxx . . $ if_nametoindex(c61c63047ce273de).(interface); |
| 371 | |
| 372 | l_lencxx . . $ l_len. = res->ai_addrlencxx . . $ addrinfo#ai_addrlen.; |
| 373 | |
| 374 | #ifdef __FreeBSD__ |
| 375 | t_addr6->sin6_len = l_len; |
| 376 | #endif |
| 377 | break; |
| 378 | } |
| 379 | |
| 380 | error = getnameinfocxx . . $ getnameinfo(44a49899269c09ff).((struct sockaddrcxx . . $ sockaddr# *)&s_loccxx . . $ s_loc., l_lencxx . . $ l_len., host_s, |
| 381 | NI_MAXHOSTcxx . . $ `<external>/564697342961150458/netdb.h:638:11`!, serv_s, NI_MAXSERVcxx . . $ `<external>/564697342961150458/netdb.h:639:11`!, NI_NUMERICHOSTcxx . . $ `<external>/564697342961150458/netdb.h:642:10`!); |
| 382 | |
| 383 | if (error) |
| 384 | printfcxx . . $ printf(581fddd72a8db8fc).("%s..\n", gai_strerrorcxx . . $ gai_strerror(f7ae7e56280f18ae).(error)); |
| 385 | |
| 386 | DEBUG_PRINTcxx . . $ `src/apps/sctp_status.c:79:9`!(DEBUG_MAXcxx . . $ `src/apps/sctp_status.c:60:9`!, "local:addr=%s, port=%s, family=%d\n", |
| 387 | host_s, serv_s, res->ai_family); |
| 388 | |
| 389 | freecxx . . $ free(5d22bdacc48458e8).(host_s); |
| 390 | freecxx . . $ free(5d22bdacc48458e8).(serv_s); |
| 391 | freeaddrinfocxx . . $ freeaddrinfo(aadc8f19092a28e8).(res); |
| 392 | } |
| 393 | |
| 394 | /* Let the testing begin. */ |
| 395 | start_testcxx . . $ start_test(d4f767463ce0a6b3).(role); |
| 396 | |
| 397 | return 0; |
| 398 | } |
| 399 | |
| 400 | int bind_rcxx . . $ bind_r(cb0e15757f8cc62c).(int sk, struct sockaddr_storagecxx . . $ sockaddr_storage# *saddr) { |
| 401 | int error = 0, i = 0; |
| 402 | char *host_s, *serv_s; |
| 403 | |
| 404 | if ((host_s = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(NI_MAXHOSTcxx . . $ `<external>/564697342961150458/netdb.h:638:11`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 405 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n\t\t*** host_s malloc failed!!! ***\n"); |
| 406 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 407 | } |
| 408 | if ((serv_s = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(NI_MAXSERVcxx . . $ `<external>/564697342961150458/netdb.h:639:11`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 409 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n\t\t*** serv_s malloc failed!!! ***\n"); |
| 410 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 411 | } |
| 412 | |
| 413 | do { |
| 414 | if (i > 0) sleepcxx . . $ sleep(2141b656ce2cc063).(1); /* sleep a while before new try... */ |
| 415 | |
| 416 | error = getnameinfocxx . . $ getnameinfo(44a49899269c09ff).((struct sockaddrcxx . . $ sockaddr# *)saddr, l_lencxx . . $ l_len., host_s, |
| 417 | NI_MAXHOSTcxx . . $ `<external>/564697342961150458/netdb.h:638:11`!, serv_s, NI_MAXSERVcxx . . $ `<external>/564697342961150458/netdb.h:639:11`!, |
| 418 | NI_NUMERICHOSTcxx . . $ `<external>/564697342961150458/netdb.h:642:10`!); |
| 419 | |
| 420 | if (error) |
| 421 | printfcxx . . $ printf(581fddd72a8db8fc).("%s\n", gai_strerrorcxx . . $ gai_strerror(f7ae7e56280f18ae).(error)); |
| 422 | |
| 423 | DEBUG_PRINTcxx . . $ `src/apps/sctp_status.c:79:9`!(DEBUG_MINcxx . . $ `src/apps/sctp_status.c:59:9`!, |
| 424 | "\tbind(sk=%d, [a:%s,p:%s]) -- attempt %d/%d\n", |
| 425 | sk, host_s, serv_s, i+1, MAX_BIND_RETRYScxx . . $ `src/apps/sctp_status.c:70:9`!); |
| 426 | |
| 427 | error = bindcxx . . $ bind(1ce9971e209c3c95).(sk, (struct sockaddrcxx . . $ sockaddr# *)saddr, l_lencxx . . $ l_len.); |
| 428 | |
| 429 | if (error != 0) { |
| 430 | if( errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != EADDRINUSEcxx . . $ `<external>/17922322188510340118/errno.h:82:9`! ) { |
| 431 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n\n\t\t***bind: can " |
| 432 | "not bind to %s:%s: %s ****\n", |
| 433 | host_s, serv_s, strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 434 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 435 | } |
| 436 | } |
| 437 | i++; |
| 438 | if (i >= MAX_BIND_RETRYScxx . . $ `src/apps/sctp_status.c:70:9`!) { |
| 439 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Maximum bind() attempts. " |
| 440 | "Die now...\n\n"); |
| 441 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 442 | } |
| 443 | } while (error < 0 && i < MAX_BIND_RETRYScxx . . $ `src/apps/sctp_status.c:70:9`!); |
| 444 | |
| 445 | freecxx . . $ free(5d22bdacc48458e8).(host_s); |
| 446 | freecxx . . $ free(5d22bdacc48458e8).(serv_s); |
| 447 | return 0; |
| 448 | } /* bind_r() */ |
| 449 | |
| 450 | int listen_rcxx . . $ listen_r(9b79fb6aee4c0440).(int sk, int listen_count) { |
| 451 | int error = 0; |
| 452 | |
| 453 | DEBUG_PRINTcxx . . $ `src/apps/sctp_status.c:79:9`!(DEBUG_MINcxx . . $ `src/apps/sctp_status.c:59:9`!, "\tlisten(sk=%d,backlog=%d)\n", |
| 454 | sk, listen_count); |
| 455 | |
| 456 | /* Mark sk as being able to accept new associations */ |
| 457 | error = listencxx . . $ listen(9b79fb6aee4c0440).(sk, 1); |
| 458 | if (error != 0) { |
| 459 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n\n\t\t*** listen: %s ***\n\n\n", strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 460 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 461 | } |
| 462 | |
| 463 | return 0; |
| 464 | } /* listen_r() */ |
| 465 | |
| 466 | int accept_rcxx . . $ accept_r(7864480464b09eea).(int sk){ |
| 467 | socklen_tcxx . . $ socklen_t# len = 0; |
| 468 | |
| 469 | DEBUG_PRINTcxx . . $ `src/apps/sctp_status.c:79:9`!(DEBUG_MINcxx . . $ `src/apps/sctp_status.c:59:9`!, "\taccept(sk=%d)\n", sk); |
| 470 | |
| 471 | gskcxx . . $ gsk. = acceptcxx . . $ accept(46fcd054f4a4d98b).(sk, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, &len); |
| 472 | if (gskcxx . . $ gsk. < 0) { |
| 473 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n\n\t\t*** accept: %s ***\n\n\n", strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 474 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 475 | } |
| 476 | |
| 477 | return 0; |
| 478 | } /* accept_r() */ |
| 479 | |
| 480 | int connect_rcxx . . $ connect_r(1ce9971e209c3c95).(int sk, const struct sockaddrcxx . . $ sockaddr# *serv_addr, socklen_tcxx . . $ socklen_t# addrlen) { |
| 481 | int error = 0; |
| 482 | |
| 483 | DEBUG_PRINTcxx . . $ `src/apps/sctp_status.c:79:9`!(DEBUG_MINcxx . . $ `src/apps/sctp_status.c:59:9`!, "\tconnect(sk=%d)\n", sk); |
| 484 | |
| 485 | /* Mark sk as being able to accept new associations */ |
| 486 | error = connectcxx . . $ connect(1ce9971e209c3c95).(sk, serv_addr, addrlen); |
| 487 | if (error != 0) { |
| 488 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n\n\t\t*** connect: %s ***\n\n\n", |
| 489 | strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 490 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 491 | } |
| 492 | |
| 493 | gskcxx . . $ gsk. = sk; |
| 494 | |
| 495 | return 0; |
| 496 | } /* connect_r() */ |
| 497 | |
| 498 | int close_rcxx . . $ close_r(7864480464b09eea).(int sk) { |
| 499 | int error = 0; |
| 500 | |
| 501 | DEBUG_PRINTcxx . . $ `src/apps/sctp_status.c:79:9`!(DEBUG_MINcxx . . $ `src/apps/sctp_status.c:59:9`!, "\tclose(sk=%d)\n",sk); |
| 502 | |
| 503 | error = closecxx . . $ close(7864480464b09eea).(sk); |
| 504 | if (error != 0) { |
| 505 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n\n\t\t*** close: %s ***\n\n", |
| 506 | strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 507 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 508 | } |
| 509 | fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!); |
| 510 | return 0; |
| 511 | } /* close_r() */ |
| 512 | |
| 513 | int receive_rcxx . . $ receive_r(7864480464b09eea).(int sk) |
| 514 | { |
| 515 | int error = 0; |
| 516 | char incmsg[CMSG_SPACEcxx . . $ `<external>/8962547315054503424/socket.h:309:9`!(sizeof(_sctp_cmsg_data_t))]; |
| 517 | struct ioveccxx . . $ iovec# iov; |
| 518 | struct msghdrcxx . . $ msghdr# inmessage; |
| 519 | |
| 520 | /* Initialize inmessage with enough space for DATA... */ |
| 521 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&inmessage, 0, sizeof(inmessage)); |
| 522 | if ((iov.iov_basecxx . . $ iovec#iov_base. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(REALLY_BIGcxx . . $ `src/apps/sctp_status.c:52:9`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 523 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n\t\t*** malloc not enough memory!!! ***\n"); |
| 524 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 525 | } |
| 526 | iov.iov_lencxx . . $ iovec#iov_len. = REALLY_BIGcxx . . $ `src/apps/sctp_status.c:52:9`!; |
| 527 | inmessage.msg_iovcxx . . $ msghdr#msg_iov. = &iov; |
| 528 | inmessage.msg_iovlencxx . . $ msghdr#msg_iovlen. = 1; |
| 529 | /* or a control message. */ |
| 530 | inmessage.msg_controlcxx . . $ msghdr#msg_control. = incmsg; |
| 531 | inmessage.msg_controllencxx . . $ msghdr#msg_controllen. = sizeof(incmsg); |
| 532 | |
| 533 | /* Get the messages sent */ |
| 534 | while (1) { |
| 535 | DEBUG_PRINTcxx . . $ `src/apps/sctp_status.c:79:9`!(DEBUG_MINcxx . . $ `src/apps/sctp_status.c:59:9`!, "\trecvmsg(sk=%d) ", sk); |
| 536 | |
| 537 | error = recvmsgcxx . . $ recvmsg(616999ca12de9af7).(sk, &inmessage, MSG_WAITALLcxx . . $ `<external>/8962547315054503424/socket.h:230:9`!); |
| 538 | if (error < 0 && errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != EAGAINcxx . . $ `<external>/8987895939074593727/errno-base.h:15:9`!) { |
| 539 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n\t\t*** recvmsg: %s ***\n\n", |
| 540 | strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 541 | fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!); |
| 542 | closecxx . . $ close(7864480464b09eea).(sk); |
| 543 | freecxx . . $ free(5d22bdacc48458e8).(iov.iov_basecxx . . $ iovec#iov_base.); |
| 544 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 545 | } else if (error == 0) { |
| 546 | printfcxx . . $ printf(581fddd72a8db8fc).("\n\t\trecvmsg() returned 0 !!!!\n"); |
| 547 | fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!); |
| 548 | } |
| 549 | |
| 550 | if(MSG_NOTIFICATIONcxx . . $ `<external>/17169092326581286071/sctp.h:181:9`! & inmessage.msg_flagscxx . . $ msghdr#msg_flags.) |
| 551 | continue; /* got a notification... */ |
| 552 | |
| 553 | inmessage.msg_controlcxx . . $ msghdr#msg_control. = incmsg; |
| 554 | inmessage.msg_controllencxx . . $ msghdr#msg_controllen. = sizeof(incmsg); |
| 555 | iov.iov_lencxx . . $ iovec#iov_len. = REALLY_BIGcxx . . $ `src/apps/sctp_status.c:52:9`!; |
| 556 | break; |
| 557 | } |
| 558 | |
| 559 | freecxx . . $ free(5d22bdacc48458e8).(iov.iov_basecxx . . $ iovec#iov_base.); |
| 560 | return 0; |
| 561 | } /* receive_r () */ |
| 562 | |
| 563 | void servercxx . . $ server(d4f767463ce0a6b3).(int sk) { |
| 564 | int i; |
| 565 | |
| 566 | if (max_msgsizecxx . . $ max_msgsize. > DEFAULT_MAX_WINDOWcxx . . $ `src/apps/sctp_status.c:74:9`!) { |
| 567 | if (setsockoptcxx . . $ setsockopt(506cc1d0fc70fdf1).(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SO_RCVBUFcxx . . $ `<external>/9030916627833342711/socket.h:18:9`!, &max_msgsizecxx . . $ max_msgsize., |
| 568 | sizeof(max_msgsizecxx . . $ max_msgsize.)) < 0) { |
| 569 | perrorcxx . . $ perror(85c52e162fed56f9).("setsockopt(SO_RCVBUF)"); |
| 570 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | for (i = 0; i < msg_cntcxx . . $ msg_cnt.; i++) { |
| 575 | receive_rcxx . . $ receive_r(7864480464b09eea).(sk); |
| 576 | DEBUG_PRINTcxx . . $ `src/apps/sctp_status.c:79:9`!(DEBUG_MINcxx . . $ `src/apps/sctp_status.c:59:9`!, "count %d\n", i+1); |
| 577 | } |
| 578 | } /* server() */ |
| 579 | |
| 580 | void * build_msgcxx . . $ build_msg(d1680a912d714170).(int len) { |
| 581 | int i = len - 1; |
| 582 | int n; |
| 583 | char *msg_buf, *p; |
| 584 | |
| 585 | msg_buf = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(len); |
| 586 | if (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! == msg_buf) { |
| 587 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n\t\t*** malloc not enough memory!!! ***\n"); |
| 588 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 589 | } |
| 590 | p = msg_buf; |
| 591 | |
| 592 | do { |
| 593 | n = ((i > 50)?50:i); |
| 594 | memcpycxx . . $ memcpy(cc817cb175f282d).(p, msgcxx . . $ msg., ((i > 50)?50:i)); |
| 595 | p += n; |
| 596 | i -= n; |
| 597 | } while (i > 0); |
| 598 | |
| 599 | msg_buf[len-1] = '\0'; |
| 600 | |
| 601 | return(msg_buf); |
| 602 | |
| 603 | } /* build_msg() */ |
| 604 | |
| 605 | int send_rcxx . . $ send_r(ea6ae529d4ec1c7a).(int sk, int stream, int order, int send_size, int assoc_i) { |
| 606 | int error = 0; |
| 607 | struct msghdrcxx . . $ msghdr# outmsg; |
| 608 | struct ioveccxx . . $ iovec# iov; |
| 609 | char *message = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 610 | int msglen = 0; |
| 611 | char outcmsg[CMSG_SPACEcxx . . $ `<external>/8962547315054503424/socket.h:309:9`!(sizeof(struct sctp_sndrcvinfo))]; |
| 612 | struct cmsghdrcxx . . $ cmsghdr# *cmsg; |
| 613 | struct sctp_sndrcvinfocxx . . $ sctp_sndrcvinfo# *sinfo; |
| 614 | |
| 615 | if (send_size > 0) { |
| 616 | message = build_msgcxx . . $ build_msg(d1680a912d714170).(send_size); |
| 617 | msglen = strlencxx . . $ strlen(751346f8406fd082).(message) + 1; |
| 618 | iov.iov_basecxx . . $ iovec#iov_base. = message; |
| 619 | iov.iov_lencxx . . $ iovec#iov_len. = msglen; |
| 620 | } else { |
| 621 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 622 | } |
| 623 | |
| 624 | outmsg.msg_namecxx . . $ msghdr#msg_name. = &s_remcxx . . $ s_rem.; |
| 625 | outmsg.msg_namelencxx . . $ msghdr#msg_namelen. = sizeof(struct sockaddr_storagecxx . . $ sockaddr_storage#); |
| 626 | outmsg.msg_iovcxx . . $ msghdr#msg_iov. = &iov; |
| 627 | outmsg.msg_iovlencxx . . $ msghdr#msg_iovlen. = 1; |
| 628 | outmsg.msg_controlcxx . . $ msghdr#msg_control. = outcmsg; |
| 629 | outmsg.msg_controllencxx . . $ msghdr#msg_controllen. = sizeof(outcmsg); |
| 630 | outmsg.msg_flagscxx . . $ msghdr#msg_flags. = 0; |
| 631 | |
| 632 | cmsg = CMSG_FIRSTHDRcxx . . $ `<external>/8962547315054503424/socket.h:304:9`!(&outmsg); |
| 633 | cmsg->cmsg_levelcxx . . $ cmsghdr#cmsg_level. = IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!; |
| 634 | cmsg->cmsg_typecxx . . $ cmsghdr#cmsg_type. = SCTP_SNDRCVcxx . . $ `<external>/17169092326581286071/sctp.h:333:9`!; |
| 635 | cmsg->cmsg_lencxx . . $ cmsghdr#cmsg_len. = CMSG_LENcxx . . $ `<external>/8962547315054503424/socket.h:311:9`!(sizeof(struct sctp_sndrcvinfo)); |
| 636 | |
| 637 | outmsg.msg_controllencxx . . $ msghdr#msg_controllen. = cmsg->cmsg_lencxx . . $ cmsghdr#cmsg_len.; |
| 638 | sinfo = (struct sctp_sndrcvinfocxx . . $ sctp_sndrcvinfo# *)CMSG_DATAcxx . . $ `<external>/8962547315054503424/socket.h:299:10`!(cmsg); |
| 639 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(sinfo, 0, sizeof(struct sctp_sndrcvinfocxx . . $ sctp_sndrcvinfo#)); |
| 640 | sinfo->sinfo_ppidcxx . . $ sctp_sndrcvinfo#sinfo_ppid. = randcxx . . $ rand(b126dc7c1de90089).(); |
| 641 | sinfo->sinfo_streamcxx . . $ sctp_sndrcvinfo#sinfo_stream. = stream; |
| 642 | sinfo->sinfo_flagscxx . . $ sctp_sndrcvinfo#sinfo_flags. = 0; |
| 643 | if (!order) |
| 644 | sinfo->sinfo_flagscxx . . $ sctp_sndrcvinfo#sinfo_flags. = SCTP_UNORDEREDcxx . . $ SCTP_UNORDERED.; |
| 645 | |
| 646 | DEBUG_PRINTcxx . . $ `src/apps/sctp_status.c:79:9`!(DEBUG_MINcxx . . $ `src/apps/sctp_status.c:59:9`!, "\tsendmsg(sk=%d, assoc=%d) %4d bytes.\n", |
| 647 | sk, assoc_i, send_size); |
| 648 | DEBUG_PRINTcxx . . $ `src/apps/sctp_status.c:79:9`!(DEBUG_MAXcxx . . $ `src/apps/sctp_status.c:60:9`!, "\t SNDRCV"); |
| 649 | if (DEBUG_MAXcxx . . $ `src/apps/sctp_status.c:60:9`! == debug_levelcxx . . $ debug_level.) { |
| 650 | printfcxx . . $ printf(581fddd72a8db8fc).("(stream=%u ", sinfo->sinfo_streamcxx . . $ sctp_sndrcvinfo#sinfo_stream.); |
| 651 | printfcxx . . $ printf(581fddd72a8db8fc).("flags=0x%x ", sinfo->sinfo_flagscxx . . $ sctp_sndrcvinfo#sinfo_flags.); |
| 652 | printfcxx . . $ printf(581fddd72a8db8fc).("ppid=%u)\n", sinfo->sinfo_ppidcxx . . $ sctp_sndrcvinfo#sinfo_ppid.); |
| 653 | } |
| 654 | |
| 655 | /* Send to our neighbor. */ |
| 656 | error = sendmsgcxx . . $ sendmsg(bc65c149164ceef5).(sk, &outmsg, MSG_WAITALLcxx . . $ `<external>/8962547315054503424/socket.h:230:9`!); |
| 657 | if (error != msglen) { |
| 658 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n\t\t*** sendmsg: %s ***\n\n", |
| 659 | strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 660 | fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!); |
| 661 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 662 | } |
| 663 | |
| 664 | if (send_size > 0) freecxx . . $ free(5d22bdacc48458e8).(message); |
| 665 | return 0; |
| 666 | } /* send_r() */ |
| 667 | |
| 668 | int next_ordercxx . . $ next_order(9b79fb6aee4c0440).(int state, int pattern) |
| 669 | { |
| 670 | switch (pattern){ |
| 671 | case ORDER_PATTERN_UNORDEREDcxx . . $ `src/apps/sctp_status.c:62:9`!: |
| 672 | state = 0; |
| 673 | break; |
| 674 | case ORDER_PATTERN_ORDEREDcxx . . $ `src/apps/sctp_status.c:63:9`!: |
| 675 | state = 1; |
| 676 | break; |
| 677 | case ORDER_PATTERN_ALTERNATEcxx . . $ `src/apps/sctp_status.c:64:9`!: |
| 678 | state = state ? 0 : 1; |
| 679 | break; |
| 680 | case ORDER_PATTERN_RANDOMcxx . . $ `src/apps/sctp_status.c:65:9`!: |
| 681 | state = randcxx . . $ rand(b126dc7c1de90089).() % 2; |
| 682 | break; |
| 683 | } |
| 684 | |
| 685 | return state; |
| 686 | } |
| 687 | |
| 688 | int next_streamcxx . . $ next_stream(9b79fb6aee4c0440).(int state, int pattern) |
| 689 | { |
| 690 | switch (pattern){ |
| 691 | case STREAM_PATTERN_RANDOMcxx . . $ `src/apps/sctp_status.c:68:9`!: |
| 692 | state = randcxx . . $ rand(b126dc7c1de90089).() % max_streamcxx . . $ max_stream.; |
| 693 | break; |
| 694 | case STREAM_PATTERN_SEQUENTIALcxx . . $ `src/apps/sctp_status.c:67:9`!: |
| 695 | state = state + 1; |
| 696 | if (state >= max_streamcxx . . $ max_stream.) |
| 697 | state = 0; |
| 698 | break; |
| 699 | } |
| 700 | |
| 701 | return state; |
| 702 | } |
| 703 | |
| 704 | int next_msg_sizecxx . . $ next_msg_size(7864480464b09eea).(int msg_cnt) |
| 705 | { |
| 706 | int msg_size; |
| 707 | |
| 708 | if (size_argcxx . . $ size_arg.) { |
| 709 | msg_size = size_argcxx . . $ size_arg.; |
| 710 | } else { |
| 711 | msg_size = (randcxx . . $ rand(b126dc7c1de90089).() % max_msgsizecxx . . $ max_msgsize.) + 1; |
| 712 | } |
| 713 | |
| 714 | return msg_size; |
| 715 | |
| 716 | } /* next_msg_size() */ |
| 717 | |
| 718 | void clientcxx . . $ client(d4f767463ce0a6b3).(int sk) { |
| 719 | int msg_size; |
| 720 | int i; |
| 721 | |
| 722 | for (i = 0; i < msg_cntcxx . . $ msg_cnt.; i++) { |
| 723 | msg_size = next_msg_sizecxx . . $ next_msg_size(7864480464b09eea).(i); |
| 724 | order_statecxx . . $ order_state. = next_ordercxx . . $ next_order(9b79fb6aee4c0440).(order_statecxx . . $ order_state., order_patterncxx . . $ order_pattern.); |
| 725 | stream_statecxx . . $ stream_state. = next_streamcxx . . $ next_stream(9b79fb6aee4c0440).(stream_statecxx . . $ stream_state., stream_patterncxx . . $ stream_pattern.); |
| 726 | |
| 727 | if (send_rcxx . . $ send_r(ea6ae529d4ec1c7a).(sk, stream_statecxx . . $ stream_state., order_statecxx . . $ order_state., msg_size, 0) < 0) { |
| 728 | closecxx . . $ close(7864480464b09eea).(sk); |
| 729 | break; |
| 730 | } |
| 731 | |
| 732 | /* The sender is echoing so do discard the echoed data. */ |
| 733 | if (draincxx . . $ drain. && ((i + 1) % periodcxx . . $ period. == 0)) { |
| 734 | receive_rcxx . . $ receive_r(7864480464b09eea).(sk); |
| 735 | } |
| 736 | } |
| 737 | } /* client() */ |
| 738 | |
| 739 | void start_testcxx . . $ start_test(d4f767463ce0a6b3).(int role) { |
| 740 | int sk, pid, ret; |
| 741 | int i = 0; |
| 742 | |
| 743 | DEBUG_PRINTcxx . . $ `src/apps/sctp_status.c:79:9`!(DEBUG_NONEcxx . . $ `src/apps/sctp_status.c:58:9`!, "\nStarting tests...\n"); |
| 744 | |
| 745 | repeat_countcxx . . $ repeat_count. = repeatcxx . . $ repeat.; |
| 746 | |
| 747 | DEBUG_PRINTcxx . . $ `src/apps/sctp_status.c:79:9`!(DEBUG_MINcxx . . $ `src/apps/sctp_status.c:59:9`!, "\tsocket(SOCK_STREAM, IPPROTO_SCTP)"); |
| 748 | |
| 749 | if ((sk = socketcxx . . $ socket(2326284602b0bb2d).(s_loccxx . . $ s_loc..ss_familycxx . . $ sockaddr_storage#ss_family., SOCK_STREAMcxx . . $ `<external>/5956532346368192945/socket_type.h:28:9`!, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!)) < 0 ) { |
| 750 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n\n\t\t*** socket: failed to create" |
| 751 | " socket: %s ***\n", strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 752 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 753 | } |
| 754 | DEBUG_PRINTcxx . . $ `src/apps/sctp_status.c:79:9`!(DEBUG_MINcxx . . $ `src/apps/sctp_status.c:59:9`!, " -> sk=%d\n", sk); |
| 755 | |
| 756 | bind_rcxx . . $ bind_r(cb0e15757f8cc62c).(sk, &s_loccxx . . $ s_loc.); |
| 757 | |
| 758 | if (role == SERVERcxx . . $ `src/apps/sctp_status.c:54:9`!) { |
| 759 | listen_rcxx . . $ listen_r(9b79fb6aee4c0440).(sk, 1); |
| 760 | accept_rcxx . . $ accept_r(7864480464b09eea).(sk); |
| 761 | } else { |
| 762 | if (max_streamcxx . . $ max_stream. > 0) { |
| 763 | struct sctp_initmsgcxx . . $ sctp_initmsg# initmsg; |
| 764 | |
| 765 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&initmsg, 0, sizeof(initmsg)); |
| 766 | initmsg.sinit_num_ostreamscxx . . $ sctp_initmsg#sinit_num_ostreams. = max_streamcxx . . $ max_stream.; |
| 767 | initmsg.sinit_max_instreamscxx . . $ sctp_initmsg#sinit_max_instreams. = max_streamcxx . . $ max_stream.; |
| 768 | initmsg.sinit_max_attemptscxx . . $ sctp_initmsg#sinit_max_attempts. = 3; |
| 769 | |
| 770 | ret = setsockoptcxx . . $ setsockopt(506cc1d0fc70fdf1).(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_INITMSGcxx . . $ `<external>/17169092326581286071/sctp.h:71:9`!, |
| 771 | &initmsg, sizeof(initmsg)); |
| 772 | if (ret < 0) { |
| 773 | perrorcxx . . $ perror(85c52e162fed56f9).("setsockopt(SCTP_INITMSG)"); |
| 774 | exitcxx . . $ exit(3ca292c338df9bb3).(0); |
| 775 | } |
| 776 | } |
| 777 | |
| 778 | connect_rcxx . . $ connect_r(1ce9971e209c3c95).(sk, (struct sockaddrcxx . . $ sockaddr# *)&s_remcxx . . $ s_rem., r_lencxx . . $ r_len.); |
| 779 | } |
| 780 | |
| 781 | if ((pid = forkcxx . . $ fork(b126dc7c1de90089).()) == 0) { |
| 782 | settimerhandlecxx . . $ settimerhandle(49f6e7a06ebc5aa8).(); |
| 783 | printstatuscxx . . $ printstatus(d4f767463ce0a6b3).(gskcxx . . $ gsk.); |
| 784 | while(1); |
| 785 | } else { |
| 786 | if (!debug_levelcxx . . $ debug_level.) { |
| 787 | printfcxx . . $ printf(581fddd72a8db8fc).(" "); |
| 788 | } |
| 789 | |
| 790 | for(i = 0; i < repeat_countcxx . . $ repeat_count.; i++) { |
| 791 | |
| 792 | if (role == SERVERcxx . . $ `src/apps/sctp_status.c:54:9`!) { |
| 793 | DEBUG_PRINTcxx . . $ `src/apps/sctp_status.c:79:9`!(DEBUG_NONEcxx . . $ `src/apps/sctp_status.c:58:9`!, "Server: Receiving packets.(%d/%d)\n", |
| 794 | i+1, repeat_count); |
| 795 | servercxx . . $ server(d4f767463ce0a6b3).(gskcxx . . $ gsk.); |
| 796 | } else { |
| 797 | DEBUG_PRINTcxx . . $ `src/apps/sctp_status.c:79:9`!(DEBUG_NONEcxx . . $ `src/apps/sctp_status.c:58:9`!, "Client: Sending packets.(%d/%d)\n", |
| 798 | i+1, repeat_count); |
| 799 | clientcxx . . $ client(d4f767463ce0a6b3).(sk); |
| 800 | } |
| 801 | |
| 802 | fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!); |
| 803 | } |
| 804 | |
| 805 | if (role == SERVERcxx . . $ `src/apps/sctp_status.c:54:9`!) close_rcxx . . $ close_r(7864480464b09eea).(gskcxx . . $ gsk.); |
| 806 | close_rcxx . . $ close_r(7864480464b09eea).(sk); |
| 807 | } |
| 808 | } /* start_test() */ |
| 809 | |
| 810 | void settimerhandlecxx . . $ settimerhandle(49f6e7a06ebc5aa8).(void) { |
| 811 | struct sigactioncxx . . $ sigaction# act; |
| 812 | struct itimervalcxx . . $ itimerval# interval; |
| 813 | |
| 814 | act.sa_handlercxx . . $ `<external>/16635209305659446502/sigaction.h:39:10`! = sighandlercxx . . $ sighandler(d4f767463ce0a6b3).; |
| 815 | act.sa_flagscxx . . $ sigaction#sa_flags. = 0; |
| 816 | sigemptysetcxx . . $ sigemptyset(f9c066a8ff75ee9d).(&act.sa_maskcxx . . $ sigaction#sa_mask.); |
| 817 | sigactioncxx . . $ sigaction(53aba09fe16b06c7).(SIGPROFcxx . . $ `<external>/1457673850468744829/signum-arch.h:48:9`!, &act, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 818 | |
| 819 | interval.it_valuecxx . . $ itimerval#it_value..tv_seccxx . . $ timeval#tv_sec. = DEFAULT_SECcxx . . $ `src/apps/sctp_status.c:49:9`!; |
| 820 | interval.it_valuecxx . . $ itimerval#it_value..tv_useccxx . . $ timeval#tv_usec. = DEFAULT_USECcxx . . $ `src/apps/sctp_status.c:50:9`!; |
| 821 | interval.it_intervalcxx . . $ itimerval#it_interval. = interval.it_valuecxx . . $ itimerval#it_value.; |
| 822 | |
| 823 | setitimercxx . . $ setitimer(12b0c0f0343f6498).(ITIMER_PROFcxx . . $ `<external>/8057359269225398204/time.h:125:9`!, &interval, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 824 | } |
| 825 | |
| 826 | void usagecxx . . $ usage(fda57c8427c60377).(char *argv0) { |
| 827 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\nusage:\n"); |
| 828 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, " server:\n"); |
| 829 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, " %8s -H local-addr -P local-port -l [-d level] [-x]\n" |
| 830 | "\t [-L num-ports] [-S num-ports]\n" |
| 831 | "\t [-a assoc-pattern]\n" |
| 832 | "\t [-i interface]\n" |
| 833 | "\t [-f status-file]\n", |
| 834 | argv0); |
| 835 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n"); |
| 836 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, " client:\n"); |
| 837 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, " %8s -H local-addr -P local-port -h remote-addr\n" |
| 838 | "\t -p remote-port -s [-c case ] [-d level]\n" |
| 839 | "\t [-x repeat] [-o order-pattern] ream-pattern]\n" |
| 840 | "\t [-M max-stream]\n" |
| 841 | "\t [-m max-msgsize]\n" |
| 842 | "\t [-L num-ports] [-S num-ports]\n" |
| 843 | "\t [-i interface]\n" |
| 844 | "\t [-f status-file]\n", |
| 845 | argv0); |
| 846 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n"); |
| 847 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\t-c value = Packets of specifed size.\n"); |
| 848 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\t-m msgsize(1500-65515, default value 32768)\n"); |
| 849 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\t-x number of repeats\n"); |
| 850 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\t-X number of messages\n"); |
| 851 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\t-o order-pattern\n"); |
| 852 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\t 0 = all unordered(default) \n"); |
| 853 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\t 1 = all ordered \n"); |
| 854 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\t 2 = alternating \n"); |
| 855 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\t 3 = random\n"); |
| 856 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\t-M max-stream (default value 0)\n"); |
| 857 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\t-D drain. If in client mode do a read following send.\n"); |
| 858 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\t-I receive after <n> times of send, default value 1.\n"); |
| 859 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n"); |
| 860 | fflushcxx . . $ fflush(89bc1efcdac0ca22).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!); |
| 861 | |
| 862 | } /* usage() */ |
| 863 | |
| 864 | void sighandlercxx . . $ sighandler(d4f767463ce0a6b3).(int signo) { |
| 865 | DEBUG_PRINTcxx . . $ `src/apps/sctp_status.c:79:9`!(DEBUG_MAXcxx . . $ `src/apps/sctp_status.c:60:9`!, "timeout sig\n"); |
| 866 | printstatuscxx . . $ printstatus(d4f767463ce0a6b3).(gskcxx . . $ gsk.); |
| 867 | } |
| 868 | |
| 869 | char* get_sstat_statecxx . . $ get_sstat_state(ff224f080444ee45).(int state) { |
| 870 | switch(state) { |
| 871 | case SCTP_EMPTYcxx . . $ SCTP_EMPTY.: |
| 872 | return "EMPTY"; |
| 873 | case SCTP_CLOSEDcxx . . $ SCTP_CLOSED.: |
| 874 | return "CLOSED"; |
| 875 | case SCTP_COOKIE_WAITcxx . . $ SCTP_COOKIE_WAIT.: |
| 876 | return "COOKIE_WAIT"; |
| 877 | case SCTP_COOKIE_ECHOEDcxx . . $ SCTP_COOKIE_ECHOED.: |
| 878 | return "COOKIE_ECHOED"; |
| 879 | case SCTP_ESTABLISHEDcxx . . $ SCTP_ESTABLISHED.: |
| 880 | return "ESTABLISHED"; |
| 881 | case SCTP_SHUTDOWN_PENDINGcxx . . $ SCTP_SHUTDOWN_PENDING.: |
| 882 | return "SHUTDOWN_PENDING"; |
| 883 | case SCTP_SHUTDOWN_SENTcxx . . $ SCTP_SHUTDOWN_SENT.: |
| 884 | return "SHUTDOWN_SENT"; |
| 885 | case SCTP_SHUTDOWN_RECEIVEDcxx . . $ SCTP_SHUTDOWN_RECEIVED.: |
| 886 | return "SHUTDOWN_RECEIVED"; |
| 887 | case SCTP_SHUTDOWN_ACK_SENTcxx . . $ SCTP_SHUTDOWN_ACK_SENT.: |
| 888 | return "SHUTDOWN_ACK_SENT"; |
| 889 | default: |
| 890 | return "UNKNOW"; |
| 891 | } |
| 892 | } |
| 893 | |
| 894 | void printstatuscxx . . $ printstatus(d4f767463ce0a6b3).(int sk) { |
| 895 | static int cwnd = 0; |
| 896 | static int count = 0; |
| 897 | struct sctp_statuscxx . . $ sctp_status# status; |
| 898 | socklen_tcxx . . $ socklen_t# optlen; |
| 899 | FILEcxx . . $ FILE# * fp; |
| 900 | const char *state_to_str[] = { |
| 901 | [SCTP_INACTIVEcxx . . $ SCTP_INACTIVE.] = "INACTIVE", |
| 902 | [SCTP_PFcxx . . $ SCTP_PF.] = "PF", |
| 903 | [SCTP_ACTIVEcxx . . $ SCTP_ACTIVE.] = "ACTIVE", |
| 904 | [SCTP_UNCONFIRMEDcxx . . $ SCTP_UNCONFIRMED.] = "UNCONFIRMED", |
| 905 | }; |
| 906 | |
| 907 | optlen = sizeof(struct sctp_statuscxx . . $ sctp_status#); |
| 908 | if(getsockoptcxx . . $ getsockopt(b79d9f11efef15f9).(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_STATUScxx . . $ `<external>/17169092326581286071/sctp.h:83:9`!, &status, &optlen) < 0) { |
| 909 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Error getting status: %s.\n", strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 910 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 911 | } |
| 912 | |
| 913 | if (statusfilecxx . . $ statusfile. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 914 | if (count == 0) |
| 915 | unlinkcxx . . $ unlink(5c4306d8553b3696).(statusfilecxx . . $ statusfile.); |
| 916 | |
| 917 | if((fp = fopencxx . . $ fopen(82ec0787cd37e0a3).(statusfilecxx . . $ statusfile., "a+")) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 918 | perrorcxx . . $ perror(85c52e162fed56f9).("fopen"); |
| 919 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 920 | } |
| 921 | } else |
| 922 | fp = stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!; |
| 923 | |
| 924 | if (count == 0) |
| 925 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, "NO. ASSOC-ID STATE RWND UNACKDATA PENDDATA INSTRMS OUTSTRMS " |
| 926 | "FRAG-POINT SPINFO-STATE SPINFO-CWDN SPINFO-SRTT SPINFO-RTO SPINFO-MTU\n"); |
| 927 | |
| 928 | if (cwnd != status.sstat_primarycxx . . $ sctp_status#sstat_primary..spinfo_cwndcxx . . $ sctp_paddrinfo#spinfo_cwnd.) { |
| 929 | count++; |
| 930 | |
| 931 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, "%-3d %-8d %-17s %-8d %-9d %-8d %-7d %-8d %-10d %-12s %-11d %-11d %-10d %d\n", count, |
| 932 | status.sstat_assoc_idcxx . . $ sctp_status#sstat_assoc_id., get_sstat_statecxx . . $ get_sstat_state(ff224f080444ee45).(status.sstat_statecxx . . $ sctp_status#sstat_state.), |
| 933 | status.sstat_rwndcxx . . $ sctp_status#sstat_rwnd., status.sstat_unackdatacxx . . $ sctp_status#sstat_unackdata., status.sstat_penddatacxx . . $ sctp_status#sstat_penddata., |
| 934 | status.sstat_instrmscxx . . $ sctp_status#sstat_instrms., status.sstat_outstrmscxx . . $ sctp_status#sstat_outstrms., status.sstat_fragmentation_pointcxx . . $ sctp_status#sstat_fragmentation_point., |
| 935 | state_to_str[status.sstat_primarycxx . . $ sctp_status#sstat_primary..spinfo_statecxx . . $ sctp_paddrinfo#spinfo_state.], |
| 936 | status.sstat_primarycxx . . $ sctp_status#sstat_primary..spinfo_cwndcxx . . $ sctp_paddrinfo#spinfo_cwnd., status.sstat_primarycxx . . $ sctp_status#sstat_primary..spinfo_srttcxx . . $ sctp_paddrinfo#spinfo_srtt., |
| 937 | status.sstat_primarycxx . . $ sctp_status#sstat_primary..spinfo_rtocxx . . $ sctp_paddrinfo#spinfo_rto., status.sstat_primarycxx . . $ sctp_status#sstat_primary..spinfo_mtucxx . . $ sctp_paddrinfo#spinfo_mtu.); |
| 938 | } |
| 939 | |
| 940 | cwnd = status.sstat_primarycxx . . $ sctp_status#sstat_primary..spinfo_cwndcxx . . $ sctp_paddrinfo#spinfo_cwnd.; |
| 941 | |
| 942 | fflushcxx . . $ fflush(89bc1efcdac0ca22).(fp); |
| 943 | |
| 944 | if (fp != stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!) |
| 945 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(fp); |
| 946 | |
| 947 | if (status.sstat_primarycxx . . $ sctp_status#sstat_primary..spinfo_statecxx . . $ sctp_paddrinfo#spinfo_state. != SCTP_ACTIVEcxx . . $ SCTP_ACTIVE.) { |
| 948 | close_rcxx . . $ close_r(7864480464b09eea).(sk); |
| 949 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 950 | } |
| 951 | } |