comparison libfdcore/sctp.c @ 1543:9222d31123b1

Use more portable sctp_opt_info() instead of getsockopt() for SCTP. From Robert Swindells.
author Thomas Klausner <tk@giga.or.at>
date Mon, 25 May 2020 10:32:57 +0200
parents acbfec3df281
children 7bad8025e69d
comparison
equal deleted inserted replaced
1538:7c9214a5f095 1543:9222d31123b1
80 memset(&rtoinfo, 0, sizeof(rtoinfo)); 80 memset(&rtoinfo, 0, sizeof(rtoinfo));
81 81
82 if (TRACE_BOOL(ANNOYING)) { 82 if (TRACE_BOOL(ANNOYING)) {
83 sz = sizeof(rtoinfo); 83 sz = sizeof(rtoinfo);
84 /* Read socket defaults */ 84 /* Read socket defaults */
85 CHECK_SYS( getsockopt(sk, IPPROTO_SCTP, SCTP_RTOINFO, &rtoinfo, &sz) ); 85 CHECK_SYS( sctp_opt_info(sk, 0, SCTP_RTOINFO, &rtoinfo, &sz) );
86 if (sz != sizeof(rtoinfo)) 86 if (sz != sizeof(rtoinfo))
87 { 87 {
88 TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(rtoinfo)); 88 TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(rtoinfo));
89 return ENOTSUP; 89 return ENOTSUP;
90 } 90 }
100 /* Set the option to the socket */ 100 /* Set the option to the socket */
101 CHECK_SYS( setsockopt(sk, IPPROTO_SCTP, SCTP_RTOINFO, &rtoinfo, sizeof(rtoinfo)) ); 101 CHECK_SYS( setsockopt(sk, IPPROTO_SCTP, SCTP_RTOINFO, &rtoinfo, sizeof(rtoinfo)) );
102 102
103 if (TRACE_BOOL(ANNOYING)) { 103 if (TRACE_BOOL(ANNOYING)) {
104 /* Check new values */ 104 /* Check new values */
105 CHECK_SYS( getsockopt(sk, IPPROTO_SCTP, SCTP_RTOINFO, &rtoinfo, &sz) ); 105 CHECK_SYS( sctp_opt_info(sk, 0, SCTP_RTOINFO, &rtoinfo, &sz) );
106 fd_log_debug( "New SCTP_RTOINFO : srto_initial : %u", rtoinfo.srto_initial); 106 fd_log_debug( "New SCTP_RTOINFO : srto_initial : %u", rtoinfo.srto_initial);
107 fd_log_debug( " srto_max : %u", rtoinfo.srto_max); 107 fd_log_debug( " srto_max : %u", rtoinfo.srto_max);
108 fd_log_debug( " srto_min : %u", rtoinfo.srto_min); 108 fd_log_debug( " srto_min : %u", rtoinfo.srto_min);
109 } 109 }
110 } 110 }
119 memset(&assoc, 0, sizeof(assoc)); 119 memset(&assoc, 0, sizeof(assoc));
120 120
121 if (TRACE_BOOL(ANNOYING)) { 121 if (TRACE_BOOL(ANNOYING)) {
122 sz = sizeof(assoc); 122 sz = sizeof(assoc);
123 /* Read socket defaults */ 123 /* Read socket defaults */
124 CHECK_SYS( getsockopt(sk, IPPROTO_SCTP, SCTP_ASSOCINFO, &assoc, &sz) ); 124 CHECK_SYS( sctp_opt_info(sk, 0, SCTP_ASSOCINFO, &assoc, &sz) );
125 if (sz != sizeof(assoc)) 125 if (sz != sizeof(assoc))
126 { 126 {
127 TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(assoc)); 127 TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(assoc));
128 return ENOTSUP; 128 return ENOTSUP;
129 } 129 }
140 /* Set the option to the socket */ 140 /* Set the option to the socket */
141 CHECK_SYS( setsockopt(sk, IPPROTO_SCTP, SCTP_ASSOCINFO, &assoc, sizeof(assoc)) ); 141 CHECK_SYS( setsockopt(sk, IPPROTO_SCTP, SCTP_ASSOCINFO, &assoc, sizeof(assoc)) );
142 142
143 if (TRACE_BOOL(ANNOYING)) { 143 if (TRACE_BOOL(ANNOYING)) {
144 /* Check new values */ 144 /* Check new values */
145 CHECK_SYS( getsockopt(sk, IPPROTO_SCTP, SCTP_ASSOCINFO, &assoc, &sz) ); 145 CHECK_SYS( sctp_opt_info(sk, 0, SCTP_ASSOCINFO, &assoc, &sz) );
146 fd_log_debug( "New SCTP_ASSOCINFO : sasoc_asocmaxrxt : %hu", assoc.sasoc_asocmaxrxt); 146 fd_log_debug( "New SCTP_ASSOCINFO : sasoc_asocmaxrxt : %hu", assoc.sasoc_asocmaxrxt);
147 fd_log_debug( " sasoc_number_peer_destinations : %hu", assoc.sasoc_number_peer_destinations); 147 fd_log_debug( " sasoc_number_peer_destinations : %hu", assoc.sasoc_number_peer_destinations);
148 fd_log_debug( " sasoc_peer_rwnd : %u" , assoc.sasoc_peer_rwnd); 148 fd_log_debug( " sasoc_peer_rwnd : %u" , assoc.sasoc_peer_rwnd);
149 fd_log_debug( " sasoc_local_rwnd : %u" , assoc.sasoc_local_rwnd); 149 fd_log_debug( " sasoc_local_rwnd : %u" , assoc.sasoc_local_rwnd);
150 fd_log_debug( " sasoc_cookie_life : %u" , assoc.sasoc_cookie_life); 150 fd_log_debug( " sasoc_cookie_life : %u" , assoc.sasoc_cookie_life);
316 316
317 if (TRACE_BOOL(ANNOYING)) { 317 if (TRACE_BOOL(ANNOYING)) {
318 sz = sizeof(parms); 318 sz = sizeof(parms);
319 319
320 /* Read socket defaults */ 320 /* Read socket defaults */
321 CHECK_SYS( getsockopt(sk, IPPROTO_SCTP, SCTP_PEER_ADDR_PARAMS, &parms, &sz) ); 321 CHECK_SYS( sctp_opt_info(sk, 0, SCTP_PEER_ADDR_PARAMS, &parms, &sz) );
322 if (sz != sizeof(parms)) 322 if (sz != sizeof(parms))
323 { 323 {
324 TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(parms)); 324 TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(parms));
325 return ENOTSUP; 325 return ENOTSUP;
326 } 326 }
345 /* Set the option to the socket */ 345 /* Set the option to the socket */
346 CHECK_SYS( setsockopt(sk, IPPROTO_SCTP, SCTP_PEER_ADDR_PARAMS, &parms, sizeof(parms)) ); 346 CHECK_SYS( setsockopt(sk, IPPROTO_SCTP, SCTP_PEER_ADDR_PARAMS, &parms, sizeof(parms)) );
347 347
348 if (TRACE_BOOL(ANNOYING)) { 348 if (TRACE_BOOL(ANNOYING)) {
349 /* Check new values */ 349 /* Check new values */
350 CHECK_SYS( getsockopt(sk, IPPROTO_SCTP, SCTP_PEER_ADDR_PARAMS, &parms, &sz) ); 350 CHECK_SYS( sctp_opt_info(sk, 0, SCTP_PEER_ADDR_PARAMS, &parms, &sz) );
351 fd_log_debug( "New SCTP_PEER_ADDR_PARAMS : spp_hbinterval : %u", parms.spp_hbinterval); 351 fd_log_debug( "New SCTP_PEER_ADDR_PARAMS : spp_hbinterval : %u", parms.spp_hbinterval);
352 fd_log_debug( " spp_pathmaxrxt : %hu", parms.spp_pathmaxrxt); 352 fd_log_debug( " spp_pathmaxrxt : %hu", parms.spp_pathmaxrxt);
353 fd_log_debug( " spp_pathmtu : %u", parms.spp_pathmtu); 353 fd_log_debug( " spp_pathmtu : %u", parms.spp_pathmtu);
354 fd_log_debug( " spp_flags : %x", parms.spp_flags); 354 fd_log_debug( " spp_flags : %x", parms.spp_flags);
355 // fd_log_debug( " spp_ipv6_flowlabel: %u", parms.spp_ipv6_flowlabel); 355 // fd_log_debug( " spp_ipv6_flowlabel: %u", parms.spp_ipv6_flowlabel);
"Welcome to our mercurial repository"