Navigation


Changeset 378:41e3c2a3721c in freeDiameter for freeDiameter/sctp.c


Ignore:
Timestamp:
Jul 5, 2010, 4:21:22 PM (14 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Replaced old mechanism to discover local addresses by a call to getifaddrs, lot cleaner!
Should close #4

File:
1 edited

Legend:

Unmodified
Added
Removed
  • freeDiameter/sctp.c

    r258 r378  
    933933}
    934934
    935 /* Get the list of local endpoints of the socket */
    936 int fd_sctp_get_local_ep(int sock, struct fd_list * list)
    937 {
    938         union {
    939                 sSA     *sa;
    940                 uint8_t *buf;
    941         } ptr;
    942        
    943         sSA * data = NULL;
    944         int count;
    945        
    946         TRACE_ENTRY("%d %p", sock, list);
    947         CHECK_PARAMS(list);
    948        
    949         /* Read the list on the socket */
    950         CHECK_SYS( count = sctp_getladdrs(sock, 0, &data)  );
    951         ptr.sa = data;
    952        
    953         while (count) {
    954                 socklen_t sl;
    955                 switch (ptr.sa->sa_family) {
    956                         case AF_INET:   sl = sizeof(sSA4); break;
    957                         case AF_INET6:  sl = sizeof(sSA6); break;
    958                         default:
    959                                 TRACE_DEBUG(INFO, "Unknown address family returned in sctp_getladdrs: %d", ptr.sa->sa_family);
    960                                 goto stop;
    961                 }
    962                                
    963                 CHECK_FCT( fd_ep_add_merge( list, ptr.sa, sl, EP_FL_LL ) );
    964                 ptr.buf += sl;
    965                 count --;
    966         }
    967 stop:
    968         /* Free the list */
    969         sctp_freeladdrs(data);
    970        
    971         /* Now get the primary address, the add function will take care of merging with existing entry */
    972         {
    973                 sSS ss;
    974                 socklen_t sl = sizeof(sSS);
    975        
    976                 CHECK_SYS(getsockname(sock, (sSA *)&ss, &sl));
    977                 CHECK_FCT( fd_ep_add_merge( list, (sSA *)&ss, sl, EP_FL_PRIMARY ) );
    978         }
    979        
    980         return 0;
    981 }
    982 
    983935/* Get the list of remote endpoints of the socket */
    984936int fd_sctp_get_remote_ep(int sock, struct fd_list * list)
Note: See TracChangeset for help on using the changeset viewer.