# HG changeset patch # User Thomas Klausner # Date 1590395687 -7200 # Node ID 7bad8025e69df9f58a0c31e33081fa6870999244 # Parent 9222d31123b16123e95da5d46e4234b26102c58c# Parent 8d7d4e1dfea878ee20fbbc7daad4f7f23c0d6014 merge diff -r 9222d31123b1 -r 7bad8025e69d contrib/debian/changelog --- a/contrib/debian/changelog Mon May 25 10:32:57 2020 +0200 +++ b/contrib/debian/changelog Mon May 25 10:34:47 2020 +0200 @@ -1,3 +1,126 @@ +freediameter (UNRELEASED) UNRELEASED; urgency=low + + * freeDiameter: + - Add -g to help + - Change -d and -q to control syslog level, as per stdout logging. + - Syslog to LOG_DAEMON. + - Actually syslog to LOG_DEBUG, now that -d/-q are used. + - Add -p pidfile + - SCTP client: bind to local endpoints configured with ListenOn so + that the SCTP INIT only contains those local endpoint addresses, + matching what is advertised in the CER. + * Base dictionary: Add rules for Experimental-Result. + * All extensions: Hide symbols except for fd_ext_init() and fd_ext_fini(). + * dbg_dict_dump.fdx: add extension to write the dictionary + to the given file or to the log. + * dbg_dict_dump_json.fdx: add extension to write the dictionary as JSON + to the given file or stdout. + * dict_dcca_3gpp.fdx: Update to 3GPP Release 15, adding many standards. + This adds 96 TYPEs, 145 ENUMVALs, 791 AVPs, 52 RULEs. + There are various breaking changes (documented below). + * contrib/dictionary_dcca_3gpp.json: Remove non-3GPP AVPs that are + actually from base IETF RFCs: + - MIP6-Feature-Vector (124). IETF RFC 5447 + - Service-Selection (493). IETF RFC 5778 + - Mobile-Node-Identifier (506). IETF RFC 5779 + - QoS-Capability (578). IETF RFC 5777. + * New API: fd_msg_add_result(): set Result-Code or Experimental-Result. + * New API: log level FD_LOG_INFO. + * fd_conf_dump(): fix formatting of local endpoints. + * fd_msg_search_avp(): support searching avp as well as msg. + * Fix compiler warnings. + * Add ERRORS_ON_WARNINGS cmake boolean to enable fatal compiler warnings. + * New tool: grep_fd_dict_dump: cleanup fd_dict_dump() output in logs. + * New tool: csv_to_fd: convert .csv with AVP tables to freeDiameter C or JSON. + * New tool: org_to_csv: convert .org files into .csv files. + + * dict_dcca_3gpp.fdx changes per update to 3GPP Release 15 as at 2019-12: + - AVP changes: + - 3GPP-CG-IPv6-Address (14) renamed to 3GPP-CG-Ipv6-Address (14). + - 3GPP-GGSN-IPv6-Address (16) renamed to 3GPP-GGSN-Ipv6-Address (16). + - 3GPP-IPv6-DNS-Servers (17) renamed to 3GPP-Ipv6-DNS-Servers (17). + - 3GPP-SGSN-IPv6-Address (15) renamed to 3GPP-SGSN-Ipv6-Address (15). + - 3GPP2-BSID (9010) flag M MUST. + - 3GPP2-BSID (9010) type changed from OctetString to UTF8String. + - ADC-Revalidation-Time (2801) Time removed in 3GPP TS 29.212 V12.1.0 (2013-06). + - ADC-Rule-Base-Name (1095) flag M MUST. + - ADC-Rule-Definition (1094) flag M MUST. + - ADC-Rule-Install (1092) flag M MUST. + - ADC-Rule-Name (1096) flag M MUST. + - ADC-Rule-Remove (1093) flag M MUST. + - ADC-Rule-Report (1097) flag M MUST. + - Application-Service-Type (2102) type changed from UTF8String to Enumerated. + - Application–Session–Id (2103) type changed from UTF8String to Unsigned32. + - Call-Barring-Infor-List (1488) renamed to Call-Barring-Info (1488). + - External-Identifier (28) OctetString replaced by External-Identifier (3111) UTF8String. + - LCS-Requestor-Id (1239) renamed to LCS-Requestor-ID (1239). + - LCS-Requestor-Id-String (1240) renamed to LCS-Requestor-ID-String (1240). + - MBMS-BMSC-SSM-IPv6-Address (919) renamed to MBMS-BMSC-SSM-Ipv6-Address (919). + - MBMS-GGSN-IPv6-Address (917) renamed to MBMS-GGSN-Ipv6-Address (917). + - MBMSGW-Address (2307) renamed to MBMS-GW-Address (2307). + - Measurement-Period-LTE (1656) code changed to Measurement-Period-LTE (1655). + - Measurement-Period-UMTS (1655) code changed to Measurement-Period-UMTS (1656). + - MME-LocationInformation (1600) renamed to MME-Location-Information(1600). + - PDG-Address (895) Address removed in 3GPP TS 32.299 V12.6.0 (2014-09). + - PDG-Charging-Id (896) Unsigned32 removed in 3GPP TS 32.299 V12.6.0 (2014-09). + - PDN-Connection-ID (1065) flag M MUST NOT. + - PoC-User-Role-info-Units (1254) renamed to PoC-User-Role-Info-Units (1254). + - PS-to-CS-Session-Continuity (1099) flag M MUST NOT. + - SS-Status (1477) type changed from Grouped to OctetString. + - Status (2702) renamed to Status-AS-Code (2702). + - WAG-Address (890) Address removed in 3GPP TS 32.299 V12.6.0 (2014-09). + - WAG-PLMN-Id (891) OctetString removed in 3GPP TS 32.299 V12.6.0 (2014-09). + - WLAN-Information (875) Grouped removed in 3GPP TS 32.299 V12.6.0 (2014-09). + - WLAN-Radio-Container (892) Grouped removed in 3GPP TS 32.299 V12.6.0 (2014-09). + - WLAN-Session-Id (1246) UTF8String removed in 3GPP TS 32.299 V12.6.0 (2014-09). + - WLAN-Technology (893) Unsigned32 removed in 3GPP TS 32.299 V12.6.0 (2014-09). + - WLAN-UE-Local-IPAddress (894) Address removed in 3GPP TS 32.299 V12.6.0 (2014-09). + - AVP renames: + - Rename Call-Barring-Infor-List (1488) to Call-Barring-Info (1488). + - Rename LCS-Requestor-Id (1239) to LCS-Requestor-ID (1239). + - Rename LCS-Requestor-Id-String (1240) to LCS-Requestor-ID-String (1240). + - Rename MBMSGW-Address (2307) to MBMS-GW-Address (2307). + - Rename MME-LocationInformation (1600) to MME-Location-Information(1600). + - Rename PoC-User-Role-info-Units (1254) to PoC-User-Role-Info-Units (1254). + - Rename Status (2702) to Status-AS-Code (2702). + - AVP name conflicts: + - Time-Window (3818) in 3GPP TS 29.345 V12.1.0 (2014-12) predates + Time-Window-29.154 (4204) in 3GPP TS 29.154 V13.1.0 (2016-03). + - Add Enumerated(3GPP/Experimental-Result-Code). 145 values. + - Update standards: + - 3GPP TS 29.061 V15.5.0 (2018-12). 15 AVPs. + - 3GPP TS 29.173 V15.0.0 (2018-06). 1 AVP. + - 3GPP TS 29.212 V15.9.0 (2019-12). 46 AVPs. + - 3GPP TS 29.214 V15.7.0 (2019-09). 27 AVPs. + - 3GPP TS 29.229 V15.2.0 (2019-09). 8 AVPs. + - 3GPP TS 29.272 V15.10.0 (2019-12). 44 AVPs. + - 3GPP TS 29.329 V15.2.0 (2019-09). 5 AVPs. + - 3GPP TS 32.299 V15.7.0 (2019-06). 154 AVPs. + - Add standards: + - 3GPP TS 29.109 V15.0.0 (2017-06). 21 AVPs. + - 3GPP TS 29.128 V15.6.0 (2019-09). 25 AVPs. + - 3GPP TS 29.153 V15.1.0 (2019-09). 2 AVPs. + - 3GPP TS 29.154 V15.3.0 (2019-09). 16 AVPs. + - 3GPP TS 29.172 V15.2.0 (2019-12). 66 AVPs. + - 3GPP TS 29.209 V6.8.0 (2011-09). 2 AVPs. + - 3GPP TS 29.215 V15.2.0 (2019-09). 9 AVPs. + - 3GPP TS 29.217 V15.1.0 (2019-09). 14 AVPs. + - 3GPP TS 29.219 V15.3.0 (2019-09). 7 AVPs. + - 3GPP TS 29.234 V11.2.0 (2013-06). 19 AVPs. + - 3GPP TS 29.273 V15.4.0 (2019-09). 40 AVPs. + - 3GPP TS 29.283 V15.1.0 (2019-09). 16 AVPs. + - 3GPP TS 29.336 V15.7.0 (2019-09). 79 AVPs. + - 3GPP TS 29.337 V15.0.0 (2018-06). 4 AVPs. + - 3GPP TS 29.338 V15.1.0 (2018-12). 34 AVPs. + - 3GPP TS 29.343 V15.1.0 (2019-09). 13 AVPs. + - 3GPP TS 29.344 V15.1.0 (2019-09). 7 AVPs. + - 3GPP TS 29.345 V15.1.0 (2019-09). 68 AVPs. + - 3GPP TS 29.368 V15.1.0 (2019-09). 12 AVPs. + - 3GPP TS 29.388 V15.1.0 (2019-09). 3 AVPs. + - 3GPP TS 29.389 V15.1.0 (2019-09). 3 AVPs. + - 3GPP TS 29.468 V15.8.0 (2019-12). 33 AVPs. + - 3GPP TS 29.561 V16.3.0 (2020-03). 9 AVPs. + freediameter (1.4.0) RELEASED; urgency=low * New API: fd_fifo_set_max to change the capacity of a queue. diff -r 9222d31123b1 -r 7bad8025e69d include/freeDiameter/libfdcore.h --- a/include/freeDiameter/libfdcore.h Mon May 25 10:32:57 2020 +0200 +++ b/include/freeDiameter/libfdcore.h Mon May 25 10:34:47 2020 +0200 @@ -151,6 +151,7 @@ unsigned no_sctp: 1; /* disable the use of SCTP */ unsigned pr_tcp : 1; /* prefer TCP over SCTP */ unsigned tls_alg: 1; /* TLS algorithm for initiated cnx. 0: separate port. 1: inband-security (old) */ + unsigned no_bind: 1; /* disable client bind to cnf_endpoints if non configured (bind all) */ } cnf_flags; struct { diff -r 9222d31123b1 -r 7bad8025e69d libfdcore/cnxctx.c --- a/libfdcore/cnxctx.c Mon May 25 10:32:57 2020 +0200 +++ b/libfdcore/cnxctx.c Mon May 25 10:34:47 2020 +0200 @@ -330,8 +330,9 @@ return cnx; } -/* Same for SCTP, accepts a list of remote addresses to connect to (see sctp_connectx for how they are used) */ -struct cnxctx * fd_cnx_cli_connect_sctp(int no_ip6, uint16_t port, struct fd_list * list) +/* Same for SCTP, accepts a list of remote addresses to connect to (see sctp_connectx for how they are used). + * If src_list is not NULL and not empty, list of local addresses to connect from via sctp_bindx(). */ +struct cnxctx * fd_cnx_cli_connect_sctp(int no_ip6, uint16_t port, struct fd_list * list, struct fd_list * src_list) { #ifdef DISABLE_SCTP TRACE_DEBUG(INFO, "This function should never be called when SCTP is disabled..."); @@ -344,15 +345,32 @@ char sa_buf[sSA_DUMP_STRLEN]; sSS primary; - TRACE_ENTRY("%p", list); + TRACE_ENTRY("%p %p", list, src_list); CHECK_PARAMS_DO( list && !FD_IS_LIST_EMPTY(list), return NULL ); + /* Log SCTP association source and destination endpoints */ + { + char * buf = NULL; + size_t len = 0, offset = 0; + CHECK_MALLOC_DO( fd_dump_extend( &buf, &len, &offset, "Connecting SCTP endpoints"), ); + CHECK_MALLOC_DO( fd_dump_extend( &buf, &len, &offset, " source: "), ); + if (src_list && !FD_IS_LIST_EMPTY(src_list)) { + CHECK_MALLOC_DO( fd_ep_dump( &buf, &len, &offset, 0, 0, src_list ), ); + } else { + CHECK_MALLOC_DO( fd_dump_extend( &buf, &len, &offset, "(ANY)"), ); + } + CHECK_MALLOC_DO( fd_dump_extend( &buf, &len, &offset, ", destination: "), ); + CHECK_MALLOC_DO( fd_ep_dump( &buf, &len, &offset, 0, 0, list ), ); + LOG_D("%s", buf ?: "Error determining SCTP endpoints"); + free(buf); + } + fd_sa_sdump_numeric(sa_buf, &((struct fd_endpoint *)(list->next))->sa); LOG_D("Connecting to SCTP %s:%hu...", sa_buf, port); { - int ret = fd_sctp_client( &sock, no_ip6, port, list ); + int ret = fd_sctp_client( &sock, no_ip6, port, list, src_list ); if (ret != 0) { LOG_D("SCTP connection to [%s,...] failed: %s", sa_buf, strerror(ret)); return NULL; diff -r 9222d31123b1 -r 7bad8025e69d libfdcore/cnxctx.h --- a/libfdcore/cnxctx.h Mon May 25 10:32:57 2020 +0200 +++ b/libfdcore/cnxctx.h Mon May 25 10:34:47 2020 +0200 @@ -117,7 +117,7 @@ /* SCTP */ int fd_sctp_create_bind_server( int * sock, int family, struct fd_list * list, uint16_t port ); int fd_sctp_listen( int sock ); -int fd_sctp_client( int *sock, int no_ip6, uint16_t port, struct fd_list * list ); +int fd_sctp_client( int *sock, int no_ip6, uint16_t port, struct fd_list * list, struct fd_list * src_list ); int fd_sctp_get_local_ep(int sock, struct fd_list * list); int fd_sctp_get_remote_ep(int sock, struct fd_list * list); int fd_sctp_get_str_info( int sock, uint16_t *in, uint16_t *out, sSS *primary ); diff -r 9222d31123b1 -r 7bad8025e69d libfdcore/config.c --- a/libfdcore/config.c Mon May 25 10:32:57 2020 +0200 +++ b/libfdcore/config.c Mon May 25 10:34:47 2020 +0200 @@ -147,6 +147,7 @@ #endif /* DISABLE_SCTP */ CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " - Pref. proto .. : %s\n", fd_g_config->cnf_flags.pr_tcp ? "TCP" : "SCTP"), return NULL); CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " - TLS method ... : %s\n", fd_g_config->cnf_flags.tls_alg ? "INBAND" : "Separate port"), return NULL); + CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " - Client bind .. : %s\n", fd_g_config->cnf_flags.no_bind ? "DISABLED" : "Enabled"), return NULL); CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " TLS : - Certificate .. : %s\n", fd_g_config->cnf_sec_data.cert_file ?: "(NONE)"), return NULL); CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " - Private key .. : %s\n", fd_g_config->cnf_sec_data.key_file ?: "(NONE)"), return NULL); @@ -351,7 +352,8 @@ } /* Validate local endpoints */ - if ((!FD_IS_LIST_EMPTY(&fd_g_config->cnf_endpoints)) && (fd_g_config->cnf_flags.no_ip4 || fd_g_config->cnf_flags.no_ip6)) { + fd_g_config->cnf_flags.no_bind = FD_IS_LIST_EMPTY(&fd_g_config->cnf_endpoints); + if ((!fd_g_config->cnf_flags.no_bind) && (fd_g_config->cnf_flags.no_ip4 || fd_g_config->cnf_flags.no_ip6)) { struct fd_list * li; for ( li = fd_g_config->cnf_endpoints.next; li != &fd_g_config->cnf_endpoints; li = li->next) { struct fd_endpoint * ep = (struct fd_endpoint *)li; diff -r 9222d31123b1 -r 7bad8025e69d libfdcore/fdcore-internal.h --- a/libfdcore/fdcore-internal.h Mon May 25 10:32:57 2020 +0200 +++ b/libfdcore/fdcore-internal.h Mon May 25 10:34:47 2020 +0200 @@ -342,7 +342,7 @@ int fd_cnx_serv_listen(struct cnxctx * conn); struct cnxctx * fd_cnx_serv_accept(struct cnxctx * serv); struct cnxctx * fd_cnx_cli_connect_tcp(sSA * sa, socklen_t addrlen); -struct cnxctx * fd_cnx_cli_connect_sctp(int no_ip6, uint16_t port, struct fd_list * list); +struct cnxctx * fd_cnx_cli_connect_sctp(int no_ip6, uint16_t port, struct fd_list * list, struct fd_list * src_list); int fd_cnx_start_clear(struct cnxctx * conn, int loop); void fd_cnx_sethostname(struct cnxctx * conn, DiamId_t hn); int fd_cnx_proto_info(struct cnxctx * conn, char * buf, size_t len); diff -r 9222d31123b1 -r 7bad8025e69d libfdcore/p_cnx.c --- a/libfdcore/p_cnx.c Mon May 25 10:32:57 2020 +0200 +++ b/libfdcore/p_cnx.c Mon May 25 10:34:47 2020 +0200 @@ -261,12 +261,14 @@ switch (nc->proto) { case IPPROTO_TCP: +/* TODO: use no_bind and first of cnf_endpoints of nc->ss.sa_family ? */ cnx = fd_cnx_cli_connect_tcp((sSA *)&nc->ss, sSAlen(&nc->ss)); break; #ifndef DISABLE_SCTP case IPPROTO_SCTP: cnx = fd_cnx_cli_connect_sctp((peer->p_hdr.info.config.pic_flags.pro3 == PI_P3_IP) ? 1 : fd_g_config->cnf_flags.no_ip6, - nc->port, &peer->p_hdr.info.pi_endpoints); + nc->port, &peer->p_hdr.info.pi_endpoints, + fd_g_config->cnf_flags.no_bind ? NULL : &fd_g_config->cnf_endpoints); break; #endif /* DISABLE_SCTP */ } diff -r 9222d31123b1 -r 7bad8025e69d libfdcore/sctp.c --- a/libfdcore/sctp.c Mon May 25 10:32:57 2020 +0200 +++ b/libfdcore/sctp.c Mon May 25 10:34:47 2020 +0200 @@ -58,6 +58,34 @@ #define ADJUST_RTX_PARAMS #endif /* USE_DEFAULT_SCTP_RTX_PARAMS */ + +DECLARE_FD_DUMP_PROTOTYPE(fd_sa_dump_array, sSA * saddrs, int saddrs_count) +{ + union { + sSA *sa; + uint8_t *buf; + } ptr; + int i; + int salen; + + FD_DUMP_HANDLE_OFFSET(); + + ptr.sa = saddrs; + for (i = 0; i < saddrs_count; i++) { + salen = sSAlen(ptr.sa); + if (salen == 0) { + LOG_E("fd_sa_dump_array: Unknown sockaddr family"); + break; + } + if (i > 0) { + CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " "), return NULL); + } + CHECK_MALLOC_DO( fd_sa_dump( FD_DUMP_STD_PARAMS, ptr.sa, NI_NUMERICHOST | NI_NUMERICSERV), return NULL); + ptr.buf += salen; + } + return *buf; +} + /* Pre-binding socket options -- # streams read in config */ static int fd_setsockopt_prebind(int sk) { @@ -814,21 +842,16 @@ bind_default = 1; goto redo; } - - #if 0 - union { - sSA *sa; - uint8_t *buf; - } ptr; - int i; - ptr.sa = sar; - fd_log_debug("Calling sctp_bindx with the following address array:"); - for (i = 0; i < count; i++) { - TRACE_sSA(FD_LOG_DEBUG, FULL, " - ", ptr.sa, NI_NUMERICHOST | NI_NUMERICSERV, "" ); - ptr.buf += (ptr.sa->sa_family == AF_INET) ? sizeof(sSA4) : sizeof(sSA6) ; - } - #endif - + + /* Debug: show bound addresses */ + { + char * buf = NULL; + size_t len = 0; + CHECK_MALLOC_DO( fd_sa_dump_array( &buf, &len, 0, sar, count), ); + LOG_D("SCTP server binding local addresses: %s", buf); + free(buf); + } + /* Bind to this array */ CHECK_SYS( sctp_bindx(*sock, sar, count, SCTP_BINDX_ADD_ADDR) ); @@ -840,22 +863,19 @@ CHECK_FCT( fd_setsockopt_postbind(*sock, bind_default) ); /* Debug: show all local listening addresses */ - #if 0 - sSA *sar; - union { - sSA *sa; - uint8_t *buf; - } ptr; - int sz; - + { + sSA *sar = NULL; + int sz = 0; + char * buf = NULL; + size_t len = 0; + CHECK_SYS( sz = sctp_getladdrs(*sock, 0, &sar) ); - - fd_log_debug("SCTP server bound on :"); - for (ptr.sa = sar; sz-- > 0; ptr.buf += (ptr.sa->sa_family == AF_INET) ? sizeof(sSA4) : sizeof(sSA6)) { - TRACE_sSA(FD_LOG_DEBUG, FULL, " - ", ptr.sa, NI_NUMERICHOST | NI_NUMERICSERV, "" ); - } + + CHECK_MALLOC_DO( fd_sa_dump_array( &buf, &len, 0, sar, sz), ); + LOG_D("SCTP server locally bound addresses: %s", buf); sctp_freeladdrs(sar); - #endif + free(buf); + } return 0; } @@ -869,7 +889,7 @@ } /* Create a client socket and connect to remote server */ -int fd_sctp_client( int *sock, int no_ip6, uint16_t port, struct fd_list * list ) +int fd_sctp_client( int *sock, int no_ip6, uint16_t port, struct fd_list * list, struct fd_list * src_list ) { int family; union { @@ -879,11 +899,13 @@ size_t size = 0; int count = 0; int ret; + int bind_default = 1; /* enable ASCONF in postbind */ sar.buf = NULL; - TRACE_ENTRY("%p %i %hu %p", sock, no_ip6, port, list); + TRACE_ENTRY("%p %i %hu %p %p", sock, no_ip6, port, list, src_list); CHECK_PARAMS( sock && list && (!FD_IS_LIST_EMPTY(list)) ); + CHECK_PARAMS( !src_list || (src_list && (!FD_IS_LIST_EMPTY(src_list))) ); if (no_ip6) { family = AF_INET; @@ -899,31 +921,47 @@ /* Set the socket options */ CHECK_FCT_DO( ret = fd_setsockopt_prebind(*sock), goto out ); - + + /* Bind to explicit source addresses if requested */ + if (src_list && !FD_IS_LIST_EMPTY(src_list)) { + sSA * bindsar = NULL; /* array of addresses */ + size_t sz = 0; /* size of the array */ + int sarcount = 0; /* number of sock addr in the array */ + + /* Create the array of configured addresses */ + CHECK_FCT_DO( ret = add_addresses_from_list_mask((void *)&bindsar, &sz, &sarcount, family, 0, src_list, EP_FL_CONF, EP_FL_CONF), goto out ); + + if (sarcount) { + char * buf = NULL; + size_t len = 0; + CHECK_MALLOC_DO( fd_sa_dump_array( &buf, &len, 0, bindsar, sarcount), goto out ); + LOG_A("SCTP client binding local addresses: %s", buf); + free(buf); + + CHECK_SYS_DO( ret = sctp_bindx(*sock, bindsar, sarcount, SCTP_BINDX_ADD_ADDR), goto out ); + } + + /* Disable ASCONF option in postbind */ + bind_default = 0; + + /* We don't need bindsar anymore */ + free(bindsar); + } + /* Create the array of addresses, add first the configured addresses, then the discovered, then the other ones */ CHECK_FCT_DO( ret = add_addresses_from_list_mask(&sar.buf, &size, &count, family, htons(port), list, EP_FL_CONF, EP_FL_CONF ), goto out ); CHECK_FCT_DO( ret = add_addresses_from_list_mask(&sar.buf, &size, &count, family, htons(port), list, EP_FL_CONF | EP_FL_DISC, EP_FL_DISC ), goto out ); CHECK_FCT_DO( ret = add_addresses_from_list_mask(&sar.buf, &size, &count, family, htons(port), list, EP_FL_CONF | EP_FL_DISC, 0 ), goto out ); /* Try connecting */ - LOG_A("Attempting SCTP connection (%d addresses attempted) ", count); - -#if 0 - /* Dump the SAs */ - union { - uint8_t *buf; - sSA *sa; - sSA4 *sin; - sSA6 *sin6; - } ptr; - int i; - ptr.buf = sar.buf; - for (i=0; i< count; i++) { - TRACE_sSA(FD_LOG_DEBUG, FULL, " - ", ptr.sa, NI_NUMERICHOST | NI_NUMERICSERV, "" ); - ptr.buf += (ptr.sa->sa_family == AF_INET) ? sizeof(sSA4) : sizeof(sSA6); - } -#endif - + { + char * buf = NULL; + size_t len = 0; + CHECK_MALLOC_DO( fd_sa_dump_array( &buf, &len, 0, sar.sa, count), goto out ); + LOG_A("SCTP client connecting to addresses: %s", buf); + free(buf); + } + /* Bug in some Linux kernel, the sctp_connectx is not a cancellation point. To avoid blocking freeDiameter, we allow async cancel here */ pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); #ifdef SCTP_CONNECTX_4_ARGS @@ -944,7 +982,7 @@ free(sar.buf); sar.buf = NULL; /* Set the remaining sockopts */ - CHECK_FCT_DO( ret = fd_setsockopt_postbind(*sock, 1), + CHECK_FCT_DO( ret = fd_setsockopt_postbind(*sock, bind_default), { CHECK_SYS_DO( shutdown(*sock, SHUT_RDWR), /* continue */ ); } ); @@ -982,7 +1020,7 @@ } #if 0 char sa_buf[sSA_DUMP_STRLEN]; - fd_sa_sdump_numeric(sa_buf, &status.sstat_primary.spinfo_address); + fd_sa_sdump_numeric(sa_buf, (sSA *)&status.sstat_primary.spinfo_address); fd_log_debug( "SCTP_STATUS : sstat_state : %i" , status.sstat_state); fd_log_debug( " sstat_rwnd : %u" , status.sstat_rwnd); fd_log_debug( " sstat_unackdata : %hu", status.sstat_unackdata); @@ -1218,6 +1256,7 @@ /* Handle the case where the data received is a notification */ if (mhdr.msg_flags & MSG_NOTIFICATION) { union sctp_notification * notif = (union sctp_notification *) data; + char sa_buf[sSA_DUMP_STRLEN]; TRACE_DEBUG(FULL, "Received %zdb data of notification on socket %d", datasize, conn->cc_socket); @@ -1235,7 +1274,8 @@ case SCTP_PEER_ADDR_CHANGE: TRACE_DEBUG(FULL, "Received SCTP_PEER_ADDR_CHANGE notification"); - /* TRACE_sSA(FD_LOG_DEBUG, ANNOYING, " intf_change : ", &(notif->sn_paddr_change.spc_aaddr), NI_NUMERICHOST | NI_NUMERICSERV, "" ); */ + fd_sa_sdump_numeric(sa_buf, (sSA *)&(notif->sn_paddr_change.spc_aaddr)); + TRACE_DEBUG(ANNOYING, " intf_change : %s", sa_buf); TRACE_DEBUG(ANNOYING, " state : %d", notif->sn_paddr_change.spc_state); TRACE_DEBUG(ANNOYING, " error : %d", notif->sn_paddr_change.spc_error); diff -r 9222d31123b1 -r 7bad8025e69d libfdproto/fifo.c --- a/libfdproto/fifo.c Mon May 25 10:32:57 2020 +0200 +++ b/libfdproto/fifo.c Mon May 25 10:34:47 2020 +0200 @@ -170,7 +170,7 @@ int fd_fifo_del ( struct fifo ** queue ) { struct fifo * q; -#ifdef DEBUG +#ifndef NDEBUG int loops = 0; #endif @@ -227,7 +227,7 @@ /* Move the content of old into new, and update loc_update atomically. We leave the old queue empty but valid */ int fd_fifo_move ( struct fifo * old, struct fifo * new, struct fifo ** loc_update ) { -#ifdef DEBUG +#ifndef NDEBUG int loops = 0; #endif @@ -420,7 +420,7 @@ pthread_cleanup_pop(0); queue->thrs_push-- ; -#ifndef DEBUG +#ifdef NDEBUG (void)ret; #endif ASSERT( ret == 0 ); diff -r 9222d31123b1 -r 7bad8025e69d libfdproto/messages.c --- a/libfdproto/messages.c Mon May 25 10:32:57 2020 +0200 +++ b/libfdproto/messages.c Mon May 25 10:34:47 2020 +0200 @@ -2284,7 +2284,7 @@ /* First, check if we already have a model. */ if (msg->msg_model != NULL) { /* Check if this model is still valid for the message data */ -#ifdef DEBUG +#ifndef NDEBUG enum dict_object_type dicttype; #endif struct dict_cmd_data data; diff -r 9222d31123b1 -r 7bad8025e69d tests/testcnx.c --- a/tests/testcnx.c Mon May 25 10:32:57 2020 +0200 +++ b/tests/testcnx.c Mon May 25 10:34:47 2020 +0200 @@ -674,7 +674,7 @@ #ifndef DISABLE_SCTP case IPPROTO_SCTP: { - cnx = fd_cnx_cli_connect_sctp(0, TEST_PORT, &eps); + cnx = fd_cnx_cli_connect_sctp(0, TEST_PORT, &eps, NULL); CHECK( 1, (cnx ? 1 : 0) ^ cf->expect_failure ); } break; diff -r 9222d31123b1 -r 7bad8025e69d tests/testsctp.c --- a/tests/testsctp.c Mon May 25 10:32:57 2020 +0200 +++ b/tests/testsctp.c Mon May 25 10:34:47 2020 +0200 @@ -98,7 +98,7 @@ CHECK( 0, fd_sctp_listen( sock )); /* Now, create the client socket */ - CHECK( 0, fd_sctp_client( &cli.cc_socket, 0, TEST_PORT, &eps )); + CHECK( 0, fd_sctp_client( &cli.cc_socket, 0, TEST_PORT, &eps, NULL )); /* Accept this connection */ srv.cc_socket = accept(sock, NULL, NULL);