Navigation


Changeset 1540:407e0a889c7e in freeDiameter for libfdcore/cnxctx.c


Ignore:
Timestamp:
May 1, 2020, 5:20:33 PM (4 years ago)
Author:
Luke Mewburn <luke@mewburn.net>
Branch:
default
Phase:
public
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfdcore/cnxctx.c

    r1419 r1540  
    331331}
    332332
    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)
     333/* Same for SCTP, accepts a list of remote addresses to connect to (see sctp_connectx for how they are used).
     334 * If src_list is not NULL and not empty, list of local addresses to connect from via sctp_bindx(). */
     335struct cnxctx * fd_cnx_cli_connect_sctp(int no_ip6, uint16_t port, struct fd_list * list, struct fd_list * src_list)
    335336{
    336337#ifdef DISABLE_SCTP
     
    345346        sSS primary;
    346347
    347         TRACE_ENTRY("%p", list);
     348        TRACE_ENTRY("%p %p", list, src_list);
    348349        CHECK_PARAMS_DO( list && !FD_IS_LIST_EMPTY(list), return NULL );
    349350
     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
    350368        fd_sa_sdump_numeric(sa_buf, &((struct fd_endpoint *)(list->next))->sa);
    351369
     
    353371
    354372        {
    355                 int ret = fd_sctp_client( &sock, no_ip6, port, list );
     373                int ret = fd_sctp_client( &sock, no_ip6, port, list, src_list );
    356374                if (ret != 0) {
    357375                        LOG_D("SCTP connection to [%s,...] failed: %s", sa_buf, strerror(ret));
Note: See TracChangeset for help on using the changeset viewer.