Changeset 1540:407e0a889c7e in freeDiameter for libfdcore/sctp.c
- Timestamp:
- May 1, 2020, 5:20:33 PM (4 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdcore/sctp.c
r1495 r1540 870 870 871 871 /* Create a client socket and connect to remote server */ 872 int fd_sctp_client( int *sock, int no_ip6, uint16_t port, struct fd_list * list )872 int fd_sctp_client( int *sock, int no_ip6, uint16_t port, struct fd_list * list, struct fd_list * src_list ) 873 873 { 874 874 int family; … … 880 880 int count = 0; 881 881 int ret; 882 int bind_default = 1; /* enable ASCONF in postbind */ 882 883 883 884 sar.buf = NULL; 884 885 885 TRACE_ENTRY("%p %i %hu %p ", sock, no_ip6, port,list);886 TRACE_ENTRY("%p %i %hu %p %p", sock, no_ip6, port, list, src_list); 886 887 CHECK_PARAMS( sock && list && (!FD_IS_LIST_EMPTY(list)) ); 888 CHECK_PARAMS( !src_list || (src_list && (!FD_IS_LIST_EMPTY(src_list))) ); 887 889 888 890 if (no_ip6) { … … 900 902 /* Set the socket options */ 901 903 CHECK_FCT_DO( ret = fd_setsockopt_prebind(*sock), goto out ); 902 904 905 /* Bind to explicit source addresses if requested */ 906 if (src_list && !FD_IS_LIST_EMPTY(src_list)) { 907 sSA * bindsar = NULL; /* array of addresses */ 908 size_t sz = 0; /* size of the array */ 909 int sarcount = 0; /* number of sock addr in the array */ 910 911 /* Create the array of configured addresses */ 912 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 ); 913 914 if (sarcount) { 915 LOG_A("Bind to local SCTP endpoints (%d addresses attempted) ", sarcount); 916 917 CHECK_SYS_DO( ret = sctp_bindx(*sock, bindsar, sarcount, SCTP_BINDX_ADD_ADDR), goto out ); 918 } 919 920 /* Disable ASCONF option in postbind */ 921 bind_default = 0; 922 923 /* We don't need bindsar anymore */ 924 free(bindsar); 925 } 926 903 927 /* Create the array of addresses, add first the configured addresses, then the discovered, then the other ones */ 904 928 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 ); … … 945 969 946 970 /* Set the remaining sockopts */ 947 CHECK_FCT_DO( ret = fd_setsockopt_postbind(*sock, 1),971 CHECK_FCT_DO( ret = fd_setsockopt_postbind(*sock, bind_default), 948 972 { 949 973 CHECK_SYS_DO( shutdown(*sock, SHUT_RDWR), /* continue */ );
Note: See TracChangeset
for help on using the changeset viewer.