Navigation


Changeset 24:bd83ce9328ed in freeDiameter for include


Ignore:
Timestamp:
Oct 21, 2009, 6:42:45 PM (15 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Cleanups and completed sctp code (not finished)

Location:
include/freeDiameter
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/CMakeLists.txt

    r23 r24  
    1313IF (NOT DISABLE_SCTP)
    1414        OPTION(DEBUG_SCTP "Verbose SCTP (for debug)?" OFF)
     15        OPTION(SCTP_USE_MAPPED_ADDRESSES "Use v6-mapped v4 addresses in SCTP (workaround some SCTP limitations)?" OFF)
    1516ENDIF (NOT DISABLE_SCTP)
    1617
  • include/freeDiameter/freeDiameter-host.h.in

    r23 r24  
    4646#cmakedefine DISABLE_SCTP
    4747#cmakedefine DEBUG_SCTP
     48#cmakedefine SCTP_USE_MAPPED_ADDRESSES
    4849#cmakedefine ERRORS_ON_TODO
    4950#cmakedefine DEBUG
  • include/freeDiameter/freeDiameter.h

    r23 r24  
    118118struct fd_endpoint {
    119119        struct fd_list  chain;  /* link in cnf_endpoints list */
     120       
    120121        union {
    121                 sSS             ss;     /* the socket information. List is always ordered by ss value (memcmp) */
     122                sSS             ss;     /* the socket information. List is always ordered by ss value (memcmp) -- see fd_ep_add_merge */
    122123                sSA4            sin;
    123124                sSA6            sin6;
    124125                sSA             sa;
    125126        };
    126         struct {
    127                 unsigned conf : 1; /* This endpoint is statically configured in a configuration file */
    128                 unsigned disc : 1; /* This endpoint was resolved from the Diameter Identity or other DNS query */
    129                 unsigned adv  : 1; /* This endpoint was advertized in Diameter CER/CEA exchange */
    130                 unsigned ll   : 1; /* Lower layer mechanism provided this endpoint */
    131                
    132                 /* To add: a validity timestamp for DNS records ? How do we retrieve this lifetime from DNS ? */
    133 
    134         }               meta;   /* Additional information about the endpoint */
    135 };
    136 
    137 /* Add a new entry in a list of endpoints -- merge if the sockaddr was already there */
    138 int fd_ep_add_merge( struct fd_list * list, sSA * sa, socklen_t sl, int conf, int disc, int adv, int ll );
     127       
     128#define EP_FL_CONF      (1 << 0)        /* This endpoint is statically configured in a configuration file */
     129#define EP_FL_DISC      (1 << 1)        /* This endpoint was resolved from the Diameter Identity or other DNS query */
     130#define EP_FL_ADV       (1 << 2)        /* This endpoint was advertized in Diameter CER/CEA exchange */
     131#define EP_FL_LL        (1 << 3)        /* Lower layer mechanism provided this endpoint */
     132#define EP_FL_PRIMARY   (1 << 4)        /* This endpoint is primary in a multihomed SCTP association */
     133        uint32_t        flags;          /* Additional information about the endpoint */
     134               
     135        /* To add: a validity timestamp for DNS records ? How do we retrieve this lifetime from DNS ? */
     136};
    139137
    140138/* Applications */
     
    468466
    469467
     468/***************************************/
     469/*   Endpoints lists helpers           */
     470/***************************************/
     471
     472int fd_ep_add_merge( struct fd_list * list, sSA * sa, socklen_t sl, uint32_t flags );
     473int fd_ep_filter( struct fd_list * list, uint32_t flags );
     474int fd_ep_clearflags( struct fd_list * list, uint32_t flags );
     475
     476
     477
    470478#endif /* _FREEDIAMETER_H */
  • include/freeDiameter/libfreeDiameter.h

    r23 r24  
    336336        }                                                       \
    337337}
    338 /* Same, for a service */
    339 #define sSA_DUMP_SERV( sa, flag ) {                             \
    340         sSA * __sa = (sSA *)(sa);                               \
    341         char __servbuf[32];                                     \
    342         if (__sa) {                                             \
    343           int __rc = getnameinfo(__sa,                          \
    344                         sizeof(sSS),                            \
    345                         NULL,                                   \
    346                         0,                                      \
    347                         __servbuf,                              \
    348                         sizeof(__servbuf),                      \
    349                         flag);                                  \
    350           if (__rc)                                             \
    351                 fd_log_debug("%s", (char *)gai_strerror(__rc)); \
    352           else                                                  \
    353                 fd_log_debug("%s", &__servbuf[0]);              \
    354         } else {                                                \
    355                 fd_log_debug("(unknown)");                      \
    356         }                                                       \
    357 }
    358 /* Combine both */
     338/* Same but with the port (service) also */
    359339#define sSA_DUMP_NODE_SERV( sa, flag ) {                                \
    360340        sSA * __sa = (sSA *)(sa);                                       \
     
    376356                fd_log_debug("(NULL / ANY)");                           \
    377357        }                                                               \
     358}
     359/* Inside a debug trace */
     360#define TRACE_DEBUG_sSA(level, prefix, sa, flags, suffix ) {                                                                            \
     361        if ( TRACE_BOOL(level) ) {                                                                                              \
     362                char __buf[25];                                                                                                 \
     363                char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");                                       \
     364                fd_log_debug("\t | tid:%-20s\t%s\tin %s@%s:%d\n"                                                                \
     365                          "\t%s|%*s" prefix ,                                                                                   \
     366                                        __thn, fd_log_time(NULL, __buf, sizeof(__buf)), __PRETTY_FUNCTION__, __FILE__, __LINE__,\
     367                                        (level < FULL)?"@":" ",level, "");                                                      \
     368                sSA_DUMP_NODE_SERV( sa, flags );                                                                                \
     369                fd_log_debug(suffix "\n");                                                                                      \
     370        }                                                                                                                       \
    378371}
    379372
     
    481474        free(buffer);
    482475}
     476static __inline__ void fd_cleanup_socket(void * sockptr)
     477{
     478        if (sockptr) {
     479                shutdown(*(int *)sockptr, SHUT_RDWR);
     480                *(int *)sockptr = 0;
     481        }
     482}
     483
    483484
    484485/*============================================================*/
Note: See TracChangeset for help on using the changeset viewer.