comparison libfdcore/cnxctx.c @ 1540:407e0a889c7e

SCTP ConnectPeer: sctp_bindx() to local endpoints When connecting to an SCTP peer using sctp_connectx() with local addresses configured with ListenOn, bind to the ListenOn addresses using sctp_bindx() so that the SCTP INIT only contains the configured local addresses, matching what is advertised in the CER, and disable SCTP_AUTO_ASCONF. If no local addresses are configured with ListenOn, the previous behaviour of sctp_connectx() and enable SCTP_AUTO_ASCONF is used.
author Luke Mewburn <luke@mewburn.net>
date Fri, 01 May 2020 18:20:33 +1000
parents 89cbb08d3189
children 566bb46cc73f
comparison
equal deleted inserted replaced
1539:d25ce064c667 1540:407e0a889c7e
328 LOG_A("TCP connection to %s succeed (socket:%d).", sa_buf, sock); 328 LOG_A("TCP connection to %s succeed (socket:%d).", sa_buf, sock);
329 329
330 return cnx; 330 return cnx;
331 } 331 }
332 332
333 /* Same for SCTP, accepts a list of remote addresses to connect to (see sctp_connectx for how they are used) */ 333 /* Same for SCTP, accepts a list of remote addresses to connect to (see sctp_connectx for how they are used).
334 struct cnxctx * fd_cnx_cli_connect_sctp(int no_ip6, uint16_t port, struct fd_list * list) 334 * If src_list is not NULL and not empty, list of local addresses to connect from via sctp_bindx(). */
335 struct cnxctx * fd_cnx_cli_connect_sctp(int no_ip6, uint16_t port, struct fd_list * list, struct fd_list * src_list)
335 { 336 {
336 #ifdef DISABLE_SCTP 337 #ifdef DISABLE_SCTP
337 TRACE_DEBUG(INFO, "This function should never be called when SCTP is disabled..."); 338 TRACE_DEBUG(INFO, "This function should never be called when SCTP is disabled...");
338 ASSERT(0); 339 ASSERT(0);
339 CHECK_FCT_DO( ENOTSUP, ); 340 CHECK_FCT_DO( ENOTSUP, );
342 int sock = 0; 343 int sock = 0;
343 struct cnxctx * cnx = NULL; 344 struct cnxctx * cnx = NULL;
344 char sa_buf[sSA_DUMP_STRLEN]; 345 char sa_buf[sSA_DUMP_STRLEN];
345 sSS primary; 346 sSS primary;
346 347
347 TRACE_ENTRY("%p", list); 348 TRACE_ENTRY("%p %p", list, src_list);
348 CHECK_PARAMS_DO( list && !FD_IS_LIST_EMPTY(list), return NULL ); 349 CHECK_PARAMS_DO( list && !FD_IS_LIST_EMPTY(list), return NULL );
349 350
351 /* Log SCTP association source and destination endpoints */
352 {
353 char * buf = NULL;
354 size_t len = 0, offset = 0;
355 CHECK_MALLOC_DO( fd_dump_extend( &buf, &len, &offset, "Connecting SCTP endpoints"), );
356 CHECK_MALLOC_DO( fd_dump_extend( &buf, &len, &offset, " source: "), );
357 if (src_list && !FD_IS_LIST_EMPTY(src_list)) {
358 CHECK_MALLOC_DO( fd_ep_dump( &buf, &len, &offset, 0, 0, src_list ), );
359 } else {
360 CHECK_MALLOC_DO( fd_dump_extend( &buf, &len, &offset, "(ANY)"), );
361 }
362 CHECK_MALLOC_DO( fd_dump_extend( &buf, &len, &offset, ", destination: "), );
363 CHECK_MALLOC_DO( fd_ep_dump( &buf, &len, &offset, 0, 0, list ), );
364 LOG_D("%s", buf ?: "Error determining SCTP endpoints");
365 free(buf);
366 }
367
350 fd_sa_sdump_numeric(sa_buf, &((struct fd_endpoint *)(list->next))->sa); 368 fd_sa_sdump_numeric(sa_buf, &((struct fd_endpoint *)(list->next))->sa);
351 369
352 LOG_D("Connecting to SCTP %s:%hu...", sa_buf, port); 370 LOG_D("Connecting to SCTP %s:%hu...", sa_buf, port);
353 371
354 { 372 {
355 int ret = fd_sctp_client( &sock, no_ip6, port, list ); 373 int ret = fd_sctp_client( &sock, no_ip6, port, list, src_list );
356 if (ret != 0) { 374 if (ret != 0) {
357 LOG_D("SCTP connection to [%s,...] failed: %s", sa_buf, strerror(ret)); 375 LOG_D("SCTP connection to [%s,...] failed: %s", sa_buf, strerror(ret));
358 return NULL; 376 return NULL;
359 } 377 }
360 } 378 }
"Welcome to our mercurial repository"