Navigation


Changeset 29:5ba91682f0bc in freeDiameter


Ignore:
Timestamp:
Oct 28, 2009, 3:19:50 PM (14 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Added a test for cnxctx (tbc) and fixed some bugs

Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • contrib/ca_script/Makefile

    r19 r29  
    3232O = WIDE
    3333OU = "AAA WG"
     34
     35#Default lifetime
     36DAYS = 365
    3437
    3538#Values for the CA
     
    130133        @openssl ca $(CONFIG) -in $(DIR)/clients/csr/$(name).csr \
    131134                -out $(DIR)/clients/certs/$(name).cert \
     135                -days $(DAYS) \
    132136                -batch
    133137        @ln -s $(DIR)/clients/certs/$(name).cert $(DIR)/certs/`openssl x509 -noout -hash < $(DIR)/clients/certs/$(name).cert`.0
  • freeDiameter/cnxctx.c

    r27 r29  
    397397}
    398398
     399/* Return the protocol of a connection */
     400int fd_cnx_getproto(struct cnxctx * conn)
     401{
     402        CHECK_PARAMS_DO( conn, return 0 );
     403        return conn->cc_proto;
     404}
     405
     406/* Return the TLS state of a connection */
     407int fd_cnx_getTLS(struct cnxctx * conn)
     408{
     409        CHECK_PARAMS_DO( conn, return 0 );
     410        return conn->cc_tls;
     411}
     412
    399413/* Get the list of endpoints (IP addresses) of the local and remote peers on this connection */
    400414int fd_cnx_getendpoints(struct cnxctx * conn, struct fd_list * local, struct fd_list * remote)
     
    474488       
    475489        TRACE_ENTRY("%p", arg);
    476        
    477490        CHECK_PARAMS_DO(conn && (conn->cc_socket > 0), goto out);
     491       
     492        /* Set the thread name */
     493        {
     494                char buf[48];
     495                snprintf(buf, sizeof(buf), "Receiver (%d) TCP/noTLS)", conn->cc_socket);
     496                fd_log_threadname ( buf );
     497        }
     498       
    478499        ASSERT( conn->cc_proto == IPPROTO_TCP );
    479500        ASSERT( conn->cc_tls == 0 );
     
    548569       
    549570        TRACE_ENTRY("%p", arg);
    550        
    551571        CHECK_PARAMS_DO(conn && (conn->cc_socket > 0), goto out);
     572       
     573        /* Set the thread name */
     574        {
     575                char buf[48];
     576                snprintf(buf, sizeof(buf), "Receiver (%d) SCTP/noTLS)", conn->cc_socket);
     577                fd_log_threadname ( buf );
     578        }
     579       
    552580        ASSERT( conn->cc_proto == IPPROTO_SCTP );
    553581        ASSERT( conn->cc_tls == 0 );
     
    607635int fd_tls_rcvthr_core(struct cnxctx * conn, gnutls_session_t session)
    608636{
    609         /* No guaranty that GnuTLS preserves the message boundaries, so we re-build it as in TCP */
     637        /* No guarantee that GnuTLS preserves the message boundaries, so we re-build it as in TCP */
    610638        do {
    611639                uint8_t header[4];
     
    616644
    617645                do {
    618                         ret = fd_tls_recv_handle_error(conn, conn->cc_tls_para.session, &header[received], sizeof(header) - received);
     646                        ret = fd_tls_recv_handle_error(conn, session, &header[received], sizeof(header) - received);
    619647                        if (ret == 0) {
    620648                                /* The connection is closed */
     
    640668                while (received < length) {
    641669                        pthread_cleanup_push(free, newmsg); /* In case we are canceled, clean the partialy built buffer */
    642                         ret = fd_tls_recv_handle_error(conn, conn->cc_tls_para.session, newmsg + received, length - received);
     670                        ret = fd_tls_recv_handle_error(conn, session, newmsg + received, length - received);
    643671                        pthread_cleanup_pop(0);
    644672
     
    664692       
    665693        TRACE_ENTRY("%p", arg);
    666        
    667694        CHECK_PARAMS_DO(conn && (conn->cc_socket > 0), goto error);
     695       
     696        /* Set the thread name */
     697        {
     698                char buf[48];
     699                snprintf(buf, sizeof(buf), "Receiver (%d) TLS/ single stream)", conn->cc_socket);
     700                fd_log_threadname ( buf );
     701        }
     702       
    668703        ASSERT( conn->cc_tls == 1 );
    669704        ASSERT( Target_Queue(conn) );
     
    709744
    710745/* Prepare a gnutls session object for handshake */
    711 int fd_tls_prepare(gnutls_session_t * session, int mode, char * priority)
     746int fd_tls_prepare(gnutls_session_t * session, int mode, char * priority, void * alt_creds)
    712747{
    713748        /* Create the master session context */
     
    724759
    725760        /* Set the credentials of this side of the connection */
    726         CHECK_GNUTLS_DO( gnutls_credentials_set (*session, GNUTLS_CRD_CERTIFICATE, fd_g_config->cnf_sec_data.credentials), return EINVAL );
     761        CHECK_GNUTLS_DO( gnutls_credentials_set (*session, GNUTLS_CRD_CERTIFICATE, alt_creds ?: fd_g_config->cnf_sec_data.credentials), return EINVAL );
    727762
    728763        /* Request the remote credentials as well */
     
    735770
    736771/* TLS handshake a connection; no need to have called start_clear before. Reception is active if handhsake is successful */
    737 int fd_cnx_handshake(struct cnxctx * conn, int mode, char * priority)
     772int fd_cnx_handshake(struct cnxctx * conn, int mode, char * priority, void * alt_creds)
    738773{
    739774        TRACE_ENTRY( "%p %d", conn, mode);
     
    750785       
    751786        /* Prepare the master session credentials and priority */
    752         CHECK_FCT( fd_tls_prepare(&conn->cc_tls_para.session, mode, priority) );
     787        CHECK_FCT( fd_tls_prepare(&conn->cc_tls_para.session, mode, priority, alt_creds) );
    753788
    754789        /* Special case: multi-stream TLS is not natively managed in GNU TLS, we use a wrapper library */
     
    801836#ifndef DISABLE_SCTP
    802837                /* Resume all additional sessions from the master one. */
    803                 CHECK_FCT(fd_sctps_handshake_others(conn, priority));
    804                
     838                CHECK_FCT(fd_sctps_handshake_others(conn, priority, alt_creds));
     839               
     840                /* Mark the connection as protected from here */
     841                conn->cc_tls = 1;
     842
    805843                /* Start decrypting the messages from all threads and queuing them in target queue */
    806844                CHECK_FCT(fd_sctps_startthreads(conn));
    807845#endif /* DISABLE_SCTP */
    808846        } else {
     847                /* Mark the connection as protected from here */
     848                conn->cc_tls = 1;
     849
    809850                /* Start decrypting the data */
    810851                CHECK_POSIX( pthread_create( &conn->cc_rcvthr, NULL, rcvthr_tls_single, conn ) );
    811852        }
    812 
     853       
    813854        return 0;
    814855}
  • freeDiameter/cnxctx.h

    r25 r29  
    7979/* TLS */
    8080int fd_tls_rcvthr_core(struct cnxctx * conn, gnutls_session_t session);
    81 int fd_tls_prepare(gnutls_session_t * session, int mode, char * priority);
     81int fd_tls_prepare(gnutls_session_t * session, int mode, char * priority, void * alt_creds);
    8282
    8383/* TCP */
     
    114114
    115115int fd_sctps_init(struct cnxctx * conn);
    116 int fd_sctps_handshake_others(struct cnxctx * conn, char * priority);
     116int fd_sctps_handshake_others(struct cnxctx * conn, char * priority, void * alt_creds);
    117117int fd_sctps_startthreads(struct cnxctx * conn);
    118118void fd_sctps_stopthreads(struct cnxctx * conn);
  • freeDiameter/fD.h

    r28 r29  
    177177        (((int)(_e) >= FDEVP_DUMP_ALL) && ((int)(_e) <= FDEVP_PSM_TIMEOUT))
    178178
     179/* The data structure for FDEVP_CNX_INCOMING events */
     180struct cnx_incoming {
     181        struct msg      * cer;          /* the CER message received on this connection */
     182        struct cnxctx   * cnx;          /* The connection context */
     183        int               validate;     /* The peer is new, it must be validated (by an extension) or error CEA to be sent */
     184};
     185
    179186/* Structure to store a sent request */
    180187struct sentreq {
     
    190197int  fd_peer_alloc(struct fd_peer ** ptr);
    191198int  fd_peer_free(struct fd_peer ** ptr);
    192 int fd_peer_handle_newCER( struct msg ** cer, struct cnxctx ** cnx, int tls_done );
     199int fd_peer_handle_newCER( struct msg ** cer, struct cnxctx ** cnx );
    193200/* fd_peer_add declared in freeDiameter.h */
     201int fd_peer_validate( struct fd_peer * peer );
    194202
    195203/* Peer expiry */
     
    216224struct cnxctx * fd_cnx_cli_connect_tcp(sSA * sa, socklen_t addrlen);
    217225struct cnxctx * fd_cnx_cli_connect_sctp(int no_ip6, uint16_t port, struct fd_list * list);
     226int             fd_cnx_start_clear(struct cnxctx * conn, int loop);
     227int             fd_cnx_handshake(struct cnxctx * conn, int mode, char * priority, void * alt_creds);
    218228char *          fd_cnx_getid(struct cnxctx * conn);
    219 int             fd_cnx_start_clear(struct cnxctx * conn, int loop);
    220 int             fd_cnx_handshake(struct cnxctx * conn, int mode, char * priority);
     229int             fd_cnx_getproto(struct cnxctx * conn);
     230int             fd_cnx_getTLS(struct cnxctx * conn);
    221231int             fd_cnx_getcred(struct cnxctx * conn, const gnutls_datum_t **cert_list, unsigned int *cert_list_size);
    222232int             fd_cnx_getendpoints(struct cnxctx * conn, struct fd_list * local, struct fd_list * remote);
  • freeDiameter/p_psm.c

    r28 r29  
    209209        }
    210210       
     211        /* A new connection was established and CER containing this peer id was received */
     212        if (event == FDEVP_CNX_INCOMING) {
     213                struct cnx_incoming * params = ev_data;
     214                ASSERT(params);
     215               
     216                switch (peer->p_hdr.info.pi_state) {
     217                        case STATE_CLOSED:
     218                                TODO("Handle the CER, validate the peer if needed (and set expiry), set the alt_fifo in the connection, reply a CEA, eventually handshake, move to OPEN or REOPEN state");
     219                                break;
     220                               
     221                        case STATE_WAITCNXACK:
     222                        case STATE_WAITCEA:
     223                                TODO("Election");
     224                                break;
     225                               
     226                        default:
     227                                TODO("Reply with error CEA");
     228                                TODO("Close the connection");
     229                                /* reject_incoming_connection */
     230                       
     231                }
     232               
     233                free(ev_data);
     234                goto psm_loop;
     235        }
     236       
    211237        /* MSG_RECEIVED: fd_p_expi_update(struct fd_peer * peer ) */
    212238        /* If timeout or OPEN : call cb if defined */
     
    223249psm_end:
    224250        pthread_cleanup_pop(1); /* set STATE_ZOMBIE */
    225         pthread_detach(peer->p_psm);
    226251        peer->p_psm = (pthread_t)NULL;
     252        pthread_detach(pthread_self());
    227253        return NULL;
    228254}       
  • freeDiameter/peers.c

    r28 r29  
    376376
    377377/* Handle an incoming CER request on a new connection */
    378 int fd_peer_handle_newCER( struct msg ** cer, struct cnxctx ** cnx, int tls_done )
     378int fd_peer_handle_newCER( struct msg ** cer, struct cnxctx ** cnx )
    379379{
    380380        struct msg * msg;
     
    385385        struct fd_list * li;
    386386        int found = 0;
     387        int ret = 0;
    387388        struct fd_peer * peer;
    388        
    389         TRACE_ENTRY("%p %p %d", cer, cnx, tls_done);
     389        struct cnx_incoming * ev_data;
     390       
     391        TRACE_ENTRY("%p %p", cer, cnx);
    390392        CHECK_PARAMS(cer && *cer && cnx && *cnx);
    391393       
     
    411413       
    412414        if (!found) {
    413                
    414                 TODO("Create a new peer entry with this diameter id (pf_responder = 1)");
    415                 TODO("Upgrade the lock to wr");
    416                 TODO("Add the new peer in the list");
    417                 TODO("Release the wr lock");
    418                 TODO("Start the peer PSM, which will have to validate if this peer is authorized to connect, and so on");
    419         }
    420                
    421         TODO("Send the new connection event to the peer SM with the appropriate data: msg, conn, tls_done, found");
    422         /* FDEVP_CNX_INCOMING */
    423        
    424         /* Reset the "out" parameters, so that they are not cleanup on function return. */
    425         *cer = NULL;
    426         *cnx = NULL;
    427        
     415                /* Create a new peer entry for this new remote peer */
     416                peer = NULL;
     417                CHECK_FCT_DO( ret = fd_peer_alloc(&peer), goto out );
     418               
     419                /* Set the peer Diameter Id and the responder flag parameters */
     420                CHECK_MALLOC_DO( peer->p_hdr.info.pi_diamid = malloc(avp_hdr->avp_value->os.len + 1), { ret = ENOMEM; goto out; } );
     421                CHECK_MALLOC_DO( peer->p_dbgorig = strdup(fd_cnx_getid(*cnx)), { ret = ENOMEM; goto out; } );
     422                peer->p_flags.pf_responder = 1;
     423               
     424                /* Upgrade the lock to write lock */
     425                CHECK_POSIX_DO( ret = pthread_rwlock_wrlock(&fd_g_peers_rw), goto out );
     426               
     427                /* Insert the new peer in the list (the PSM will take care of setting the expiry after validation) */
     428                fd_list_insert_before( li, &peer->p_hdr.chain );
     429               
     430                /* Release the write lock */
     431                CHECK_POSIX_DO( ret = pthread_rwlock_unlock(&fd_g_peers_rw), goto out );
     432               
     433                /* Start the PSM, which will receive the event bellow */
     434                CHECK_FCT_DO( ret = fd_psm_begin(peer), goto out );
     435        }
     436               
     437        /* Send the new connection event to the PSM */
     438        CHECK_MALLOC_DO( ev_data = malloc(sizeof(struct cnx_incoming)), { ret = ENOMEM; goto out; } );
     439        memset(ev_data, 0, sizeof(ev_data));
     440       
     441        ev_data->cer = msg;
     442        ev_data->cnx = *cnx;
     443        ev_data->validate = !found;
     444       
     445        CHECK_FCT_DO( ret = fd_event_send(peer->p_events, FDEVP_CNX_INCOMING, sizeof(ev_data), ev_data), goto out );
     446       
     447out:   
    428448        CHECK_POSIX( pthread_rwlock_unlock(&fd_g_peers_rw) );
    429449
    430        
    431         TODO("(later if not tls_done) handshake or start_clear(.., 1) ");
    432        
    433         return 0;
     450        if (ret == 0) {
     451                /* Reset the "out" parameters, so that they are not cleanup on function return. */
     452                *cer = NULL;
     453                *cnx = NULL;
     454        }
     455       
     456        return ret;
    434457}
    435458
     
    441464        return ENOTSUP;
    442465}
     466
     467/* Validate a peer by calling the callbacks in turn -- return 0 if the peer is validated, ! 0 in case of error or if the peer is rejected */
     468int fd_peer_validate( struct fd_peer * peer )
     469{
     470        TODO("Default to reject");
     471        TODO("Call all callbacks in turn");
     472        TODO("Save cb2 in the peer if needed");
     473        return ENOTSUP;
     474}
  • freeDiameter/sctp.c

    r27 r29  
    4545#endif /* CMSG_BUF_LEN */
    4646
     47/* Level of SCTP-specific traces */
     48#ifdef DEBUG_SCTP
     49#define SCTP_LEVEL      FULL
     50#else /* DEBUG_SCTP */
     51#define SCTP_LEVEL      ANNOYING
     52#endif /* DEBUG_SCTP */
     53
    4754/* Pre-binding socket options -- # streams read in config */
    4855static int fd_setsockopt_prebind(int sk)
    4956{
    50         #ifdef DEBUG_SCTP
    5157        socklen_t sz;
    52         #endif /* DEBUG_SCTP */
    5358       
    5459        TRACE_ENTRY( "%d", sk);
     
    7479                CHECK_SYS(  setsockopt(sk, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(event)) );
    7580               
    76                 #ifdef DEBUG_SCTP
    77                 sz = sizeof(event);
    78                 CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_EVENTS, &event, &sz) );
    79                 if (sz != sizeof(event))
    80                 {
    81                         TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(event));
    82                         return ENOTSUP;
    83                 }
    84                
    85                 TRACE_DEBUG(FULL, "SCTP_EVENTS : sctp_data_io_event          : %hhu", event.sctp_data_io_event);
    86                 TRACE_DEBUG(FULL, "              sctp_association_event      : %hhu", event.sctp_association_event);
    87                 TRACE_DEBUG(FULL, "              sctp_address_event          : %hhu", event.sctp_address_event);
    88                 TRACE_DEBUG(FULL, "              sctp_send_failure_event     : %hhu", event.sctp_send_failure_event);
    89                 TRACE_DEBUG(FULL, "              sctp_peer_error_event       : %hhu", event.sctp_peer_error_event);
    90                 TRACE_DEBUG(FULL, "              sctp_shutdown_event         : %hhu", event.sctp_shutdown_event);
    91                 TRACE_DEBUG(FULL, "              sctp_partial_delivery_event : %hhu", event.sctp_partial_delivery_event);
    92                 TRACE_DEBUG(FULL, "              sctp_adaptation_layer_event : %hhu", event.sctp_adaptation_layer_event);
    93                 // TRACE_DEBUG(FULL, "             sctp_authentication_event    : %hhu", event.sctp_authentication_event);
    94                 #endif /* DEBUG_SCTP */
     81                if (TRACE_BOOL(SCTP_LEVEL)) {
     82                        sz = sizeof(event);
     83                        CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_EVENTS, &event, &sz) );
     84                        if (sz != sizeof(event))
     85                        {
     86                                TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(event));
     87                                return ENOTSUP;
     88                        }
     89
     90                        fd_log_debug( "SCTP_EVENTS : sctp_data_io_event          : %hhu\n", event.sctp_data_io_event);
     91                        fd_log_debug( "              sctp_association_event      : %hhu\n", event.sctp_association_event);
     92                        fd_log_debug( "              sctp_address_event          : %hhu\n", event.sctp_address_event);
     93                        fd_log_debug( "              sctp_send_failure_event     : %hhu\n", event.sctp_send_failure_event);
     94                        fd_log_debug( "              sctp_peer_error_event       : %hhu\n", event.sctp_peer_error_event);
     95                        fd_log_debug( "              sctp_shutdown_event         : %hhu\n", event.sctp_shutdown_event);
     96                        fd_log_debug( "              sctp_partial_delivery_event : %hhu\n", event.sctp_partial_delivery_event);
     97                        fd_log_debug( "              sctp_adaptation_layer_event : %hhu\n", event.sctp_adaptation_layer_event);
     98                        // fd_log_debug( "             sctp_authentication_event    : %hhu\n", event.sctp_authentication_event);
     99                }
    95100               
    96101        }
     
    101106                memset(&init, 0, sizeof(init));
    102107               
    103                 #ifdef DEBUG_SCTP
    104                 sz = sizeof(init);
    105                
    106                 /* Read socket defaults */
    107                 CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_INITMSG, &init, &sz)  );
    108                 if (sz != sizeof(init))
    109                 {
    110                         TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(init));
    111                         return ENOTSUP;
    112                 }
    113                 TRACE_DEBUG(FULL, "Def SCTP_INITMSG : sinit_num_ostreams   : %hu", init.sinit_num_ostreams);
    114                 TRACE_DEBUG(FULL, "                   sinit_max_instreams  : %hu", init.sinit_max_instreams);
    115                 TRACE_DEBUG(FULL, "                   sinit_max_attempts   : %hu", init.sinit_max_attempts);
    116                 TRACE_DEBUG(FULL, "                   sinit_max_init_timeo : %hu", init.sinit_max_init_timeo);
    117                 #endif /* DEBUG_SCTP */
     108                if (TRACE_BOOL(SCTP_LEVEL)) {
     109                        sz = sizeof(init);
     110
     111                        /* Read socket defaults */
     112                        CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_INITMSG, &init, &sz)  );
     113                        if (sz != sizeof(init))
     114                        {
     115                                TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(init));
     116                                return ENOTSUP;
     117                        }
     118                        fd_log_debug( "Def SCTP_INITMSG : sinit_num_ostreams   : %hu\n", init.sinit_num_ostreams);
     119                        fd_log_debug( "                   sinit_max_instreams  : %hu\n", init.sinit_max_instreams);
     120                        fd_log_debug( "                   sinit_max_attempts   : %hu\n", init.sinit_max_attempts);
     121                        fd_log_debug( "                   sinit_max_init_timeo : %hu\n", init.sinit_max_init_timeo);
     122                }
    118123
    119124                /* Set the init options -- need to receive SCTP_COMM_UP to confirm the requested parameters */
     
    124129                CHECK_SYS(  setsockopt(sk, IPPROTO_SCTP, SCTP_INITMSG, &init, sizeof(init))  );
    125130               
    126                 #ifdef DEBUG_SCTP
    127                 /* Check new values */
    128                 CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_INITMSG, &init, &sz)  );
    129                 TRACE_DEBUG(FULL, "New SCTP_INITMSG : sinit_num_ostreams   : %hu", init.sinit_num_ostreams);
    130                 TRACE_DEBUG(FULL, "                   sinit_max_instreams  : %hu", init.sinit_max_instreams);
    131                 TRACE_DEBUG(FULL, "                   sinit_max_attempts   : %hu", init.sinit_max_attempts);
    132                 TRACE_DEBUG(FULL, "                   sinit_max_init_timeo : %hu", init.sinit_max_init_timeo);
    133                 #endif /* DEBUG_SCTP */
     131                if (TRACE_BOOL(SCTP_LEVEL)) {
     132                        /* Check new values */
     133                        CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_INITMSG, &init, &sz)  );
     134                        fd_log_debug( "New SCTP_INITMSG : sinit_num_ostreams   : %hu\n", init.sinit_num_ostreams);
     135                        fd_log_debug( "                   sinit_max_instreams  : %hu\n", init.sinit_max_instreams);
     136                        fd_log_debug( "                   sinit_max_attempts   : %hu\n", init.sinit_max_attempts);
     137                        fd_log_debug( "                   sinit_max_init_timeo : %hu\n", init.sinit_max_init_timeo);
     138                }
    134139        }
    135140       
     
    139144                int nofrag;
    140145               
    141                 #ifdef DEBUG_SCTP
    142                 sz = sizeof(nofrag);
    143                 /* Read socket defaults */
    144                 CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_DISABLE_FRAGMENTS, &nofrag, &sz)  );
    145                 if (sz != sizeof(nofrag))
    146                 {
    147                         TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(nofrag));
    148                         return ENOTSUP;
    149                 }
    150                 TRACE_DEBUG(FULL, "Def SCTP_DISABLE_FRAGMENTS value : %s", nofrag ? "true" : "false");
    151                 #endif /* DEBUG_SCTP */
     146                if (TRACE_BOOL(SCTP_LEVEL)) {
     147                        sz = sizeof(nofrag);
     148                        /* Read socket defaults */
     149                        CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_DISABLE_FRAGMENTS, &nofrag, &sz)  );
     150                        if (sz != sizeof(nofrag))
     151                        {
     152                                TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(nofrag));
     153                                return ENOTSUP;
     154                        }
     155                        fd_log_debug( "Def SCTP_DISABLE_FRAGMENTS value : %s\n", nofrag ? "true" : "false");
     156                }
    152157
    153158                nofrag = 0;     /* We turn ON the fragmentation */
     
    156161                CHECK_SYS(  setsockopt(sk, IPPROTO_SCTP, SCTP_DISABLE_FRAGMENTS, &nofrag, sizeof(nofrag))  );
    157162               
    158                 #ifdef DEBUG_SCTP
    159                 /* Check new values */
    160                 CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_DISABLE_FRAGMENTS, &nofrag, &sz)  );
    161                 TRACE_DEBUG(FULL, "New SCTP_DISABLE_FRAGMENTS value : %s", nofrag ? "true" : "false");
    162                 #endif /* DEBUG_SCTP */
     163                if (TRACE_BOOL(SCTP_LEVEL)) {
     164                        /* Check new values */
     165                        CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_DISABLE_FRAGMENTS, &nofrag, &sz)  );
     166                        fd_log_debug( "New SCTP_DISABLE_FRAGMENTS value : %s\n", nofrag ? "true" : "false");
     167                }
    163168        }
    164169        #else /* SCTP_DISABLE_FRAGMENTS */
     
    173178                memset(&rtoinfo, 0, sizeof(rtoinfo));
    174179
    175                 #ifdef DEBUG_SCTP
    176                 sz = sizeof(rtoinfo);
    177                 /* Read socket defaults */
    178                 CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_RTOINFO, &rtoinfo, &sz)  );
    179                 if (sz != sizeof(rtoinfo))
    180                 {
    181                         TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(rtoinfo));
    182                         return ENOTSUP;
    183                 }
    184                 TRACE_DEBUG(FULL, "Def SCTP_RTOINFO : srto_initial : %u", rtoinfo.srto_initial);
    185                 TRACE_DEBUG(FULL, "                   srto_max     : %u", rtoinfo.srto_max);
    186                 TRACE_DEBUG(FULL, "                   srto_min     : %u", rtoinfo.srto_min);
    187                 #endif /* DEBUG_SCTP */
     180                if (TRACE_BOOL(SCTP_LEVEL)) {
     181                        sz = sizeof(rtoinfo);
     182                        /* Read socket defaults */
     183                        CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_RTOINFO, &rtoinfo, &sz)  );
     184                        if (sz != sizeof(rtoinfo))
     185                        {
     186                                TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(rtoinfo));
     187                                return ENOTSUP;
     188                        }
     189                        fd_log_debug( "Def SCTP_RTOINFO : srto_initial : %u\n", rtoinfo.srto_initial);
     190                        fd_log_debug( "                   srto_max     : %u\n", rtoinfo.srto_max);
     191                        fd_log_debug( "                   srto_min     : %u\n", rtoinfo.srto_min);
     192                }
    188193
    189194                rtoinfo.srto_max     = fd_g_config->cnf_timer_tw * 500 - 1000;  /* Maximum retransmit timer (in ms) (set to Tw / 2 - 1) */
     
    192197                CHECK_SYS(  setsockopt(sk, IPPROTO_SCTP, SCTP_RTOINFO, &rtoinfo, sizeof(rtoinfo))  );
    193198               
    194                 #ifdef DEBUG_SCTP
    195                 /* Check new values */
    196                 CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_RTOINFO, &rtoinfo, &sz)  );
    197                 TRACE_DEBUG(FULL, "New SCTP_RTOINFO : srto_initial : %u", rtoinfo.srto_initial);
    198                 TRACE_DEBUG(FULL, "                   srto_max     : %u", rtoinfo.srto_max);
    199                 TRACE_DEBUG(FULL, "                   srto_min     : %u", rtoinfo.srto_min);
    200                 #endif /* DEBUG_SCTP */
     199                if (TRACE_BOOL(SCTP_LEVEL)) {
     200                        /* Check new values */
     201                        CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_RTOINFO, &rtoinfo, &sz)  );
     202                        fd_log_debug( "New SCTP_RTOINFO : srto_initial : %u\n", rtoinfo.srto_initial);
     203                        fd_log_debug( "                   srto_max     : %u\n", rtoinfo.srto_max);
     204                        fd_log_debug( "                   srto_min     : %u\n", rtoinfo.srto_min);
     205                }
    201206        }
    202207        #else /* SCTP_RTOINFO */
    203         # ifdef DEBUG_SCTP
    204         TRACE_DEBUG(FULL, "Skipping SCTP_RTOINFO");
    205         # endif /* DEBUG_SCTP */
     208        TRACE_DEBUG(SCTP_LEVEL, "Skipping SCTP_RTOINFO");
    206209        #endif /* SCTP_RTOINFO */
    207210       
     
    212215                memset(&assoc, 0, sizeof(assoc));
    213216
    214                 #ifdef DEBUG_SCTP
    215                 sz = sizeof(assoc);
    216                 /* Read socket defaults */
    217                 CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_ASSOCINFO, &assoc, &sz)  );
    218                 if (sz != sizeof(assoc))
    219                 {
    220                         TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(assoc));
    221                         return ENOTSUP;
    222                 }
    223                 TRACE_DEBUG(FULL, "Def SCTP_ASSOCINFO : sasoc_asocmaxrxt               : %hu", assoc.sasoc_asocmaxrxt);
    224                 TRACE_DEBUG(FULL, "                     sasoc_number_peer_destinations : %hu", assoc.sasoc_number_peer_destinations);
    225                 TRACE_DEBUG(FULL, "                     sasoc_peer_rwnd                : %u" , assoc.sasoc_peer_rwnd);
    226                 TRACE_DEBUG(FULL, "                     sasoc_local_rwnd               : %u" , assoc.sasoc_local_rwnd);
    227                 TRACE_DEBUG(FULL, "                     sasoc_cookie_life              : %u" , assoc.sasoc_cookie_life);
    228                 #endif /* DEBUG_SCTP */
     217                if (TRACE_BOOL(SCTP_LEVEL)) {
     218                        sz = sizeof(assoc);
     219                        /* Read socket defaults */
     220                        CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_ASSOCINFO, &assoc, &sz)  );
     221                        if (sz != sizeof(assoc))
     222                        {
     223                                TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(assoc));
     224                                return ENOTSUP;
     225                        }
     226                        fd_log_debug( "Def SCTP_ASSOCINFO : sasoc_asocmaxrxt               : %hu\n", assoc.sasoc_asocmaxrxt);
     227                        fd_log_debug( "                     sasoc_number_peer_destinations : %hu\n", assoc.sasoc_number_peer_destinations);
     228                        fd_log_debug( "                     sasoc_peer_rwnd                : %u\n" , assoc.sasoc_peer_rwnd);
     229                        fd_log_debug( "                     sasoc_local_rwnd               : %u\n" , assoc.sasoc_local_rwnd);
     230                        fd_log_debug( "                     sasoc_cookie_life              : %u\n" , assoc.sasoc_cookie_life);
     231                }
    229232
    230233                assoc.sasoc_asocmaxrxt = 5;     /* Maximum retransmission attempts: we want fast detection of errors */
     
    233236                CHECK_SYS(  setsockopt(sk, IPPROTO_SCTP, SCTP_ASSOCINFO, &assoc, sizeof(assoc))  );
    234237               
    235                 #ifdef DEBUG_SCTP
    236                 /* Check new values */
    237                 CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_ASSOCINFO, &assoc, &sz)  );
    238                 TRACE_DEBUG(FULL, "New SCTP_ASSOCINFO : sasoc_asocmaxrxt               : %hu", assoc.sasoc_asocmaxrxt);
    239                 TRACE_DEBUG(FULL, "                     sasoc_number_peer_destinations : %hu", assoc.sasoc_number_peer_destinations);
    240                 TRACE_DEBUG(FULL, "                     sasoc_peer_rwnd                : %u" , assoc.sasoc_peer_rwnd);
    241                 TRACE_DEBUG(FULL, "                     sasoc_local_rwnd               : %u" , assoc.sasoc_local_rwnd);
    242                 TRACE_DEBUG(FULL, "                     sasoc_cookie_life              : %u" , assoc.sasoc_cookie_life);
    243                 #endif /* DEBUG_SCTP */
     238                if (TRACE_BOOL(SCTP_LEVEL)) {
     239                        /* Check new values */
     240                        CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_ASSOCINFO, &assoc, &sz)  );
     241                        fd_log_debug( "New SCTP_ASSOCINFO : sasoc_asocmaxrxt               : %hu\n", assoc.sasoc_asocmaxrxt);
     242                        fd_log_debug( "                     sasoc_number_peer_destinations : %hu\n", assoc.sasoc_number_peer_destinations);
     243                        fd_log_debug( "                     sasoc_peer_rwnd                : %u\n" , assoc.sasoc_peer_rwnd);
     244                        fd_log_debug( "                     sasoc_local_rwnd               : %u\n" , assoc.sasoc_local_rwnd);
     245                        fd_log_debug( "                     sasoc_cookie_life              : %u\n" , assoc.sasoc_cookie_life);
     246                }
    244247        }
    245248        #else /* SCTP_ASSOCINFO */
    246         # ifdef DEBUG_SCTP
    247         TRACE_DEBUG(FULL, "Skipping SCTP_ASSOCINFO");
    248         # endif /* DEBUG_SCTP */
     249        TRACE_DEBUG(SCTP_LEVEL, "Skipping SCTP_ASSOCINFO");
    249250        #endif /* SCTP_ASSOCINFO */
    250251       
     
    256257                memset(&linger, 0, sizeof(linger));
    257258               
    258                 #ifdef DEBUG_SCTP
    259                 sz = sizeof(linger);
    260                 /* Read socket defaults */
    261                 CHECK_SYS(  getsockopt(sk, SOL_SOCKET, SO_LINGER, &linger, &sz)  );
    262                 if (sz != sizeof(linger))
    263                 {
    264                         TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(linger));
    265                         return ENOTSUP;
    266                 }
    267                 TRACE_DEBUG(FULL, "Def SO_LINGER : l_onoff  : %d", linger.l_onoff);
    268                 TRACE_DEBUG(FULL, "                l_linger : %d", linger.l_linger);
    269                 #endif /* DEBUG_SCTP */
     259                if (TRACE_BOOL(SCTP_LEVEL)) {
     260                        sz = sizeof(linger);
     261                        /* Read socket defaults */
     262                        CHECK_SYS(  getsockopt(sk, SOL_SOCKET, SO_LINGER, &linger, &sz)  );
     263                        if (sz != sizeof(linger))
     264                        {
     265                                TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(linger));
     266                                return ENOTSUP;
     267                        }
     268                        fd_log_debug( "Def SO_LINGER : l_onoff  : %d\n", linger.l_onoff);
     269                        fd_log_debug( "                l_linger : %d\n", linger.l_linger);
     270                }
    270271               
    271272                linger.l_onoff  = 0;    /* Do not activate the linger */
     
    275276                CHECK_SYS(  setsockopt(sk, SOL_SOCKET, SO_LINGER, &linger, sizeof(linger))  );
    276277               
    277                 #ifdef DEBUG_SCTP
    278                 /* Check new values */
    279                 CHECK_SYS(  getsockopt(sk, SOL_SOCKET, SO_LINGER, &linger, &sz)  );
    280                 TRACE_DEBUG(FULL, "New SO_LINGER : l_onoff  : %d", linger.l_onoff);
    281                 TRACE_DEBUG(FULL, "                l_linger : %d", linger.l_linger);
    282                 #endif /* DEBUG_SCTP */
     278                if (TRACE_BOOL(SCTP_LEVEL)) {
     279                        /* Check new values */
     280                        CHECK_SYS(  getsockopt(sk, SOL_SOCKET, SO_LINGER, &linger, &sz)  );
     281                        fd_log_debug( "New SO_LINGER : l_onoff  : %d\n", linger.l_onoff);
     282                        fd_log_debug( "           l_linger : %d\n", linger.l_linger);
     283                }
    283284        }
    284285        #else /* SO_LINGER */
    285         # ifdef DEBUG_SCTP
    286         TRACE_DEBUG(FULL, "Skipping SO_LINGER");
    287         # endif /* DEBUG_SCTP */
     286        TRACE_DEBUG(SCTP_LEVEL, "Skipping SO_LINGER");
    288287        #endif /* SO_LINGER */
    289288       
     
    293292                int nodelay;
    294293               
    295                 #ifdef DEBUG_SCTP
    296                 sz = sizeof(nodelay);
    297                 /* Read socket defaults */
    298                 CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_NODELAY, &nodelay, &sz)  );
    299                 if (sz != sizeof(nodelay))
    300                 {
    301                         TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(nodelay));
    302                         return ENOTSUP;
    303                 }
    304                 TRACE_DEBUG(FULL, "Def SCTP_NODELAY value : %s", nodelay ? "true" : "false");
    305                 #endif /* DEBUG_SCTP */
     294                if (TRACE_BOOL(SCTP_LEVEL)) {
     295                        sz = sizeof(nodelay);
     296                        /* Read socket defaults */
     297                        CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_NODELAY, &nodelay, &sz)  );
     298                        if (sz != sizeof(nodelay))
     299                        {
     300                                TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(nodelay));
     301                                return ENOTSUP;
     302                        }
     303                        fd_log_debug( "Def SCTP_NODELAY value : %s\n", nodelay ? "true" : "false");
     304                }
    306305
    307306                nodelay = 0;    /* We turn ON the Nagle algorithm (probably the default already) */
     
    310309                CHECK_SYS(  setsockopt(sk, IPPROTO_SCTP, SCTP_NODELAY, &nodelay, sizeof(nodelay))  );
    311310               
    312                 #ifdef DEBUG_SCTP
    313                 /* Check new values */
    314                 CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_NODELAY, &nodelay, &sz)  );
    315                 TRACE_DEBUG(FULL, "New SCTP_NODELAY value : %s", nodelay ? "true" : "false");
    316                 #endif /* DEBUG_SCTP */
     311                if (TRACE_BOOL(SCTP_LEVEL)) {
     312                        /* Check new values */
     313                        CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_NODELAY, &nodelay, &sz)  );
     314                        fd_log_debug( "New SCTP_NODELAY value : %s\n", nodelay ? "true" : "false");
     315                }
    317316        }
    318317        #else /* SCTP_NODELAY */
    319         # ifdef DEBUG_SCTP
    320         TRACE_DEBUG(FULL, "Skipping SCTP_NODELAY");
    321         # endif /* DEBUG_SCTP */
     318        TRACE_DEBUG(SCTP_LEVEL, "Skipping SCTP_NODELAY");
    322319        #endif /* SCTP_NODELAY */
    323320       
     
    327324                int interleave;
    328325               
    329                 #ifdef DEBUG_SCTP
    330                 sz = sizeof(interleave);
    331                 /* Read socket defaults */
    332                 CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_FRAGMENT_INTERLEAVE, &interleave, &sz)  );
    333                 if (sz != sizeof(interleave))
    334                 {
    335                         TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(interleave));
    336                         return ENOTSUP;
    337                 }
    338                 TRACE_DEBUG(FULL, "Def SCTP_FRAGMENT_INTERLEAVE value : %d", interleave);
    339                 #endif /* DEBUG_SCTP */
     326                if (TRACE_BOOL(SCTP_LEVEL)) {
     327                        sz = sizeof(interleave);
     328                        /* Read socket defaults */
     329                        CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_FRAGMENT_INTERLEAVE, &interleave, &sz)  );
     330                        if (sz != sizeof(interleave))
     331                        {
     332                                TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(interleave));
     333                                return ENOTSUP;
     334                        }
     335                        fd_log_debug( "Def SCTP_FRAGMENT_INTERLEAVE value : %d\n", interleave);
     336                }
    340337
    341338                #if 0
     
    348345                CHECK_SYS(  setsockopt(sk, IPPROTO_SCTP, SCTP_FRAGMENT_INTERLEAVE, &interleave, sizeof(interleave))  );
    349346               
    350                 #ifdef DEBUG_SCTP
    351                 /* Check new values */
    352                 CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_FRAGMENT_INTERLEAVE, &interleave, &sz)  );
    353                 TRACE_DEBUG(FULL, "New SCTP_FRAGMENT_INTERLEAVE value : %d", interleave);
    354                 #endif /* DEBUG_SCTP */
     347                if (TRACE_BOOL(SCTP_LEVEL)) {
     348                        /* Check new values */
     349                        CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_FRAGMENT_INTERLEAVE, &interleave, &sz)  );
     350                        fd_log_debug( "New SCTP_FRAGMENT_INTERLEAVE value : %d\n", interleave);
     351                }
    355352        }
    356353        #else /* SCTP_FRAGMENT_INTERLEAVE */
    357         # ifdef DEBUG_SCTP
    358         TRACE_DEBUG(FULL, "Skipping SCTP_FRAGMENT_INTERLEAVE");
    359         # endif /* DEBUG_SCTP */
     354        TRACE_DEBUG(SCTP_LEVEL, "Skipping SCTP_FRAGMENT_INTERLEAVE");
    360355        #endif /* SCTP_FRAGMENT_INTERLEAVE */
    361356       
     
    365360                int v4mapped;
    366361               
    367                 #ifdef DEBUG_SCTP
    368                 sz = sizeof(v4mapped);
    369                 /* Read socket defaults */
    370                 CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_I_WANT_MAPPED_V4_ADDR, &v4mapped, &sz)  );
    371                 if (sz != sizeof(v4mapped))
    372                 {
    373                         TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(v4mapped));
    374                         return ENOTSUP;
    375                 }
    376                 TRACE_DEBUG(FULL, "Def SCTP_I_WANT_MAPPED_V4_ADDR value : %s", v4mapped ? "true" : "false");
    377                 #endif /* DEBUG_SCTP */
     362                if (TRACE_BOOL(SCTP_LEVEL)) {
     363                        sz = sizeof(v4mapped);
     364                        /* Read socket defaults */
     365                        CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_I_WANT_MAPPED_V4_ADDR, &v4mapped, &sz)  );
     366                        if (sz != sizeof(v4mapped))
     367                        {
     368                                TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(v4mapped));
     369                                return ENOTSUP;
     370                        }
     371                        fd_log_debug( "Def SCTP_I_WANT_MAPPED_V4_ADDR value : %s\n", v4mapped ? "true" : "false");
     372                }
    378373
    379374#ifndef SCTP_USE_MAPPED_ADDRESSES
     
    386381                CHECK_SYS(  setsockopt(sk, IPPROTO_SCTP, SCTP_I_WANT_MAPPED_V4_ADDR, &v4mapped, sizeof(v4mapped))  );
    387382               
    388                 #ifdef DEBUG_SCTP
    389                 /* Check new values */
    390                 CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_I_WANT_MAPPED_V4_ADDR, &v4mapped, &sz)  );
    391                 TRACE_DEBUG(FULL, "New SCTP_I_WANT_MAPPED_V4_ADDR value : %s", v4mapped ? "true" : "false");
    392                 #endif /* DEBUG_SCTP */
     383                if (TRACE_BOOL(SCTP_LEVEL)) {
     384                        /* Check new values */
     385                        CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_I_WANT_MAPPED_V4_ADDR, &v4mapped, &sz)  );
     386                        fd_log_debug( "New SCTP_I_WANT_MAPPED_V4_ADDR value : %s\n", v4mapped ? "true" : "false");
     387                }
    393388        }
    394389        #else /* SCTP_I_WANT_MAPPED_V4_ADDR */
    395         # ifdef DEBUG_SCTP
    396         TRACE_DEBUG(FULL, "Skipping SCTP_I_WANT_MAPPED_V4_ADDR");
    397         # endif /* DEBUG_SCTP */
     390        TRACE_DEBUG(SCTP_LEVEL, "Skipping SCTP_I_WANT_MAPPED_V4_ADDR");
    398391        #endif /* SCTP_I_WANT_MAPPED_V4_ADDR */
    399392                           
     
    456449                int asconf;
    457450               
    458                 #ifdef DEBUG_SCTP
    459                 socklen_t sz;
    460                
    461                 sz = sizeof(asconf);
    462                 /* Read socket defaults */
    463                 CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_AUTO_ASCONF, &asconf, &sz)  );
    464                 if (sz != sizeof(asconf))
    465                 {
    466                         TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(asconf));
    467                         return ENOTSUP;
    468                 }
    469                 TRACE_DEBUG(FULL, "Def SCTP_AUTO_ASCONF value : %s", asconf ? "true" : "false");
    470                 #endif /* DEBUG_SCTP */
     451                if (TRACE_BOOL(SCTP_LEVEL)) {
     452                        socklen_t sz;
     453
     454                        sz = sizeof(asconf);
     455                        /* Read socket defaults */
     456                        CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_AUTO_ASCONF, &asconf, &sz)  );
     457                        if (sz != sizeof(asconf))
     458                        {
     459                                TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(asconf));
     460                                return ENOTSUP;
     461                        }
     462                        fd_log_debug( "Def SCTP_AUTO_ASCONF value : %s\n", asconf ? "true" : "false");
     463                }
    471464
    472465                asconf = bound_to_default ? 1 : 0;      /* allow automatic use of added or removed addresses in the association (for bound-all sockets) */
     
    475468                CHECK_SYS(  setsockopt(sk, IPPROTO_SCTP, SCTP_AUTO_ASCONF, &asconf, sizeof(asconf))  );
    476469               
    477                 #ifdef DEBUG_SCTP
    478                 /* Check new values */
    479                 CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_AUTO_ASCONF, &asconf, &sz)  );
    480                 TRACE_DEBUG(FULL, "New SCTP_AUTO_ASCONF value : %s", asconf ? "true" : "false");
    481                 #endif /* DEBUG_SCTP */
     470                if (TRACE_BOOL(SCTP_LEVEL)) {
     471                        socklen_t sz = sizeof(asconf);
     472                        /* Check new values */
     473                        CHECK_SYS(  getsockopt(sk, IPPROTO_SCTP, SCTP_AUTO_ASCONF, &asconf, &sz)  );
     474                        fd_log_debug( "New SCTP_AUTO_ASCONF value : %s\n", asconf ? "true" : "false");
     475                }
    482476        }
    483477        #else /* SCTP_AUTO_ASCONF */
    484         # ifdef DEBUG_SCTP
    485         TRACE_DEBUG(FULL, "Skipping SCTP_AUTO_ASCONF");
    486         # endif /* DEBUG_SCTP */
     478        TRACE_DEBUG(SCTP_LEVEL, "Skipping SCTP_AUTO_ASCONF");
    487479        #endif /* SCTP_AUTO_ASCONF */
    488480       
     
    600592                }
    601593               
    602                 # ifdef DEBUG_SCTP
    603                 if (TRACE_BOOL(FULL)) {
     594                if (TRACE_BOOL(SCTP_LEVEL)) {
    604595                        int i;
    605596                        ptr.buf = sar.buf;
     
    610601                        }
    611602                }
    612                 #endif /* DEBUG_SCTP */
    613603               
    614604                /* Bind to this array */
     
    622612        CHECK_FCT( fd_setsockopt_postbind(*sock, bind_default) );
    623613       
    624         #ifdef DEBUG_SCTP
    625614        /* Debug: show all local listening addresses */
    626         if (TRACE_BOOL(FULL)) {
     615        if (TRACE_BOOL(SCTP_LEVEL)) {
    627616                sSA *sar;
    628617                union {
     
    640629                sctp_freeladdrs(sar);
    641630        }
    642         #endif /* DEBUG_SCTP */
    643631
    644632        return 0;
     
    767755                return ENOTSUP;
    768756        }
    769         #ifdef DEBUG_SCTP
    770         TRACE_DEBUG(FULL, "SCTP_STATUS : sstat_state                  : %i" , status.sstat_state);
    771         TRACE_DEBUG(FULL, "              sstat_rwnd                   : %u" , status.sstat_rwnd);
    772         TRACE_DEBUG(FULL, "              sstat_unackdata              : %hu", status.sstat_unackdata);
    773         TRACE_DEBUG(FULL, "              sstat_penddata               : %hu", status.sstat_penddata);
    774         TRACE_DEBUG(FULL, "              sstat_instrms                : %hu", status.sstat_instrms);
    775         TRACE_DEBUG(FULL, "              sstat_outstrms               : %hu", status.sstat_outstrms);
    776         TRACE_DEBUG(FULL, "              sstat_fragmentation_point    : %u" , status.sstat_fragmentation_point);
    777         TRACE_DEBUG_sSA(FULL, "          sstat_primary.spinfo_address : ", &status.sstat_primary.spinfo_address, NI_NUMERICHOST | NI_NUMERICSERV, "" );
    778         TRACE_DEBUG(FULL, "              sstat_primary.spinfo_state   : %d" , status.sstat_primary.spinfo_state);
    779         TRACE_DEBUG(FULL, "              sstat_primary.spinfo_cwnd    : %u" , status.sstat_primary.spinfo_cwnd);
    780         TRACE_DEBUG(FULL, "              sstat_primary.spinfo_srtt    : %u" , status.sstat_primary.spinfo_srtt);
    781         TRACE_DEBUG(FULL, "              sstat_primary.spinfo_rto     : %u" , status.sstat_primary.spinfo_rto);
    782         TRACE_DEBUG(FULL, "              sstat_primary.spinfo_mtu     : %u" , status.sstat_primary.spinfo_mtu);
    783         #endif /* DEBUG_SCTP */
     757        if (TRACE_BOOL(SCTP_LEVEL)) {
     758                fd_log_debug( "SCTP_STATUS : sstat_state                  : %i\n" , status.sstat_state);
     759                fd_log_debug( "              sstat_rwnd                   : %u\n" , status.sstat_rwnd);
     760                fd_log_debug( "              sstat_unackdata              : %hu\n", status.sstat_unackdata);
     761                fd_log_debug( "              sstat_penddata               : %hu\n", status.sstat_penddata);
     762                fd_log_debug( "              sstat_instrms                : %hu\n", status.sstat_instrms);
     763                fd_log_debug( "              sstat_outstrms               : %hu\n", status.sstat_outstrms);
     764                fd_log_debug( "              sstat_fragmentation_point    : %u\n" , status.sstat_fragmentation_point);
     765                fd_log_debug( "              sstat_primary.spinfo_address : ");
     766                sSA_DUMP_NODE_SERV(&status.sstat_primary.spinfo_address, NI_NUMERICHOST | NI_NUMERICSERV );
     767                fd_log_debug( "\n" );
     768                fd_log_debug( "              sstat_primary.spinfo_state   : %d\n" , status.sstat_primary.spinfo_state);
     769                fd_log_debug( "              sstat_primary.spinfo_cwnd    : %u\n" , status.sstat_primary.spinfo_cwnd);
     770                fd_log_debug( "              sstat_primary.spinfo_srtt    : %u\n" , status.sstat_primary.spinfo_srtt);
     771                fd_log_debug( "              sstat_primary.spinfo_rto     : %u\n" , status.sstat_primary.spinfo_rto);
     772                fd_log_debug( "              sstat_primary.spinfo_mtu     : %u\n" , status.sstat_primary.spinfo_mtu);
     773        }
    784774       
    785775        *in = status.sstat_instrms;
     
    936926        mhdr.msg_controllen = sizeof(anci);
    937927       
    938         #ifdef DEBUG_SCTP
    939928        TRACE_DEBUG(FULL, "Sending %db data on stream %hu of socket %d", len, strid, sock);
    940         #endif /* DEBUG_SCTP */
    941929       
    942930        CHECK_SYS( ret = sendmsg(sock, &mhdr, 0) );
     
    1005993        }
    1006994       
     995        TRACE_DEBUG(FULL, "Received %db data on socket %d", datasize, sock);
     996       
    1007997        /* Handle the case where the data received is a notification */
    1008998        if (mhdr.msg_flags & MSG_NOTIFICATION) {
     
    10121002                       
    10131003                        case SCTP_ASSOC_CHANGE:
    1014                                 #ifdef DEBUG_SCTP
    10151004                                TRACE_DEBUG(FULL, "Received SCTP_ASSOC_CHANGE notification");
    1016                                 TRACE_DEBUG(FULL, "    state : %hu", notif->sn_assoc_change.sac_state);
    1017                                 TRACE_DEBUG(FULL, "    error : %hu", notif->sn_assoc_change.sac_error);
    1018                                 TRACE_DEBUG(FULL, "    instr : %hu", notif->sn_assoc_change.sac_inbound_streams);
    1019                                 TRACE_DEBUG(FULL, "   outstr : %hu", notif->sn_assoc_change.sac_outbound_streams);
    1020                                 #endif /* DEBUG_SCTP */
     1005                                TRACE_DEBUG(SCTP_LEVEL, "    state : %hu", notif->sn_assoc_change.sac_state);
     1006                                TRACE_DEBUG(SCTP_LEVEL, "    error : %hu", notif->sn_assoc_change.sac_error);
     1007                                TRACE_DEBUG(SCTP_LEVEL, "    instr : %hu", notif->sn_assoc_change.sac_inbound_streams);
     1008                                TRACE_DEBUG(SCTP_LEVEL, "   outstr : %hu", notif->sn_assoc_change.sac_outbound_streams);
    10211009                               
    10221010                                *event = FDEVP_CNX_EP_CHANGE;
     
    10241012       
    10251013                        case SCTP_PEER_ADDR_CHANGE:
    1026                                 #ifdef DEBUG_SCTP
    10271014                                TRACE_DEBUG(FULL, "Received SCTP_PEER_ADDR_CHANGE notification");
    1028                                 TRACE_DEBUG_sSA(FULL, "    intf_change : ", &(notif->sn_paddr_change.spc_aaddr), NI_NUMERICHOST | NI_NUMERICSERV, "" );
    1029                                 TRACE_DEBUG(FULL, "          state : %d", notif->sn_paddr_change.spc_state);
    1030                                 TRACE_DEBUG(FULL, "          error : %d", notif->sn_paddr_change.spc_error);
    1031                                 #endif /* DEBUG_SCTP */
     1015                                TRACE_DEBUG_sSA(SCTP_LEVEL, "    intf_change : ", &(notif->sn_paddr_change.spc_aaddr), NI_NUMERICHOST | NI_NUMERICSERV, "" );
     1016                                TRACE_DEBUG(SCTP_LEVEL, "          state : %d", notif->sn_paddr_change.spc_state);
     1017                                TRACE_DEBUG(SCTP_LEVEL, "          error : %d", notif->sn_paddr_change.spc_error);
    10321018                               
    10331019                                *event = FDEVP_CNX_EP_CHANGE;
     
    10351021       
    10361022                        case SCTP_SEND_FAILED:
    1037                                 #ifdef DEBUG_SCTP
    10381023                                TRACE_DEBUG(FULL, "Received SCTP_SEND_FAILED notification");
    1039                                 TRACE_DEBUG(FULL, "    len : %hu", notif->sn_send_failed.ssf_length);
    1040                                 TRACE_DEBUG(FULL, "    err : %d",  notif->sn_send_failed.ssf_error);
    1041                                 #endif /* DEBUG_SCTP */
     1024                                TRACE_DEBUG(SCTP_LEVEL, "    len : %hu", notif->sn_send_failed.ssf_length);
     1025                                TRACE_DEBUG(SCTP_LEVEL, "    err : %d",  notif->sn_send_failed.ssf_error);
    10421026                               
    10431027                                *event = FDEVP_CNX_ERROR;
     
    10451029                       
    10461030                        case SCTP_REMOTE_ERROR:
    1047                                 #ifdef DEBUG_SCTP
    10481031                                TRACE_DEBUG(FULL, "Received SCTP_REMOTE_ERROR notification");
    1049                                 TRACE_DEBUG(FULL, "    err : %hu", ntohs(notif->sn_remote_error.sre_error));
    1050                                 TRACE_DEBUG(FULL, "    len : %hu", ntohs(notif->sn_remote_error.sre_length));
    1051                                 #endif /* DEBUG_SCTP */
     1032                                TRACE_DEBUG(SCTP_LEVEL, "    err : %hu", ntohs(notif->sn_remote_error.sre_error));
     1033                                TRACE_DEBUG(SCTP_LEVEL, "    len : %hu", ntohs(notif->sn_remote_error.sre_length));
    10521034                               
    10531035                                *event = FDEVP_CNX_ERROR;
     
    10551037       
    10561038                        case SCTP_SHUTDOWN_EVENT:
    1057                                 #ifdef DEBUG_SCTP
    10581039                                TRACE_DEBUG(FULL, "Received SCTP_SHUTDOWN_EVENT notification");
    1059                                 #endif /* DEBUG_SCTP */
    10601040                               
    10611041                                *event = FDEVP_CNX_ERROR;
     
    10961076                       
    10971077                        sndrcv = (struct sctp_sndrcvinfo *) CMSG_DATA(hdr);
    1098                         #ifdef DEBUG_SCTP
    1099                         TRACE_DEBUG(FULL, "Anciliary block IPPROTO_SCTP / SCTP_SNDRCV");
    1100                         TRACE_DEBUG(FULL, "    sinfo_stream    : %hu", sndrcv->sinfo_stream);
    1101                         TRACE_DEBUG(FULL, "    sinfo_ssn       : %hu", sndrcv->sinfo_ssn);
    1102                         TRACE_DEBUG(FULL, "    sinfo_flags     : %hu", sndrcv->sinfo_flags);
    1103                         /* TRACE_DEBUG(FULL, "    sinfo_pr_policy : %hu", sndrcv->sinfo_pr_policy); */
    1104                         TRACE_DEBUG(FULL, "    sinfo_ppid      : %u" , sndrcv->sinfo_ppid);
    1105                         TRACE_DEBUG(FULL, "    sinfo_context   : %u" , sndrcv->sinfo_context);
    1106                         /* TRACE_DEBUG(FULL, "    sinfo_pr_value  : %u" , sndrcv->sinfo_pr_value); */
    1107                         TRACE_DEBUG(FULL, "    sinfo_tsn       : %u" , sndrcv->sinfo_tsn);
    1108                         TRACE_DEBUG(FULL, "    sinfo_cumtsn    : %u" , sndrcv->sinfo_cumtsn);
    1109                         #endif /* DEBUG_SCTP */
     1078                        if (TRACE_BOOL(SCTP_LEVEL)) {
     1079                                fd_log_debug( "Anciliary block IPPROTO_SCTP / SCTP_SNDRCV\n");
     1080                                fd_log_debug( "    sinfo_stream    : %hu\n", sndrcv->sinfo_stream);
     1081                                fd_log_debug( "    sinfo_ssn       : %hu\n", sndrcv->sinfo_ssn);
     1082                                fd_log_debug( "    sinfo_flags     : %hu\n", sndrcv->sinfo_flags);
     1083                                /* fd_log_debug( "    sinfo_pr_policy : %hu\n", sndrcv->sinfo_pr_policy); */
     1084                                fd_log_debug( "    sinfo_ppid      : %u\n" , sndrcv->sinfo_ppid);
     1085                                fd_log_debug( "    sinfo_context   : %u\n" , sndrcv->sinfo_context);
     1086                                /* fd_log_debug( "    sinfo_pr_value  : %u\n" , sndrcv->sinfo_pr_value); */
     1087                                fd_log_debug( "    sinfo_tsn       : %u\n" , sndrcv->sinfo_tsn);
     1088                                fd_log_debug( "    sinfo_cumtsn    : %u\n" , sndrcv->sinfo_cumtsn);
     1089                        }
    11101090
    11111091                        *strid = sndrcv->sinfo_stream;
  • freeDiameter/sctps.c

    r27 r29  
    7373       
    7474        TRACE_ENTRY("%p", arg);
    75        
    7675        CHECK_PARAMS_DO(conn && (conn->cc_socket > 0), goto out);
     76       
     77        /* Set the thread name */
     78        {
     79                char buf[48];
     80                snprintf(buf, sizeof(buf), "Demuxer (%d)", conn->cc_socket);
     81                fd_log_threadname ( buf );
     82        }
     83       
    7784        ASSERT( conn->cc_proto == IPPROTO_SCTP );
    78         ASSERT( conn->cc_tls == 1 );
    7985        ASSERT( Target_Queue(conn) );
    8086        ASSERT( conn->cc_sctps_data.array );
     
    115121       
    116122        TRACE_ENTRY("%p", arg);
    117        
    118123        CHECK_PARAMS_DO(ctx && ctx->raw_recv && ctx->parent, goto error);
    119124        cnx = ctx->parent;
    120125        ASSERT( Target_Queue(cnx) );
     126       
     127        /* Set the thread name */
     128        {
     129                char buf[48];
     130                snprintf(buf, sizeof(buf), "Decipher (%hu@%d)", ctx->strid, cnx->cc_socket);
     131                fd_log_threadname ( buf );
     132        }
    121133       
    122134        CHECK_FCT_DO(fd_tls_rcvthr_core(cnx, ctx->strid ? ctx->session : cnx->cc_tls_para.session), /* continue */);
     
    209221        pthread_rwlock_t lock;
    210222        struct cnxctx   *parent;
     223        /* Add another list to chain in a global list to implement a garbage collector on sessions */
    211224};
    212225
     
    219232
    220233/* The level at which we debug session resuming */
    221 #define SR_LEVEL FULL
     234#define SR_LEVEL (FULL + 1)
    222235
    223236/* Initialize the store area for a connection */
     
    303316       
    304317        CHECK_PARAMS_DO( sto && key.data && data.data, return -1 );
    305         TRACE_DEBUG_BUFFER(SR_LEVEL, "Session store [key ", key.data, key.size < 16 ? key.size : 16, "]");
    306318       
    307319        CHECK_POSIX_DO( pthread_rwlock_wrlock(&sto->lock), return -1 );
     320        TRACE_DEBUG_BUFFER(SR_LEVEL, "Session store [key ", key.data, key.size, "]");
    308321       
    309322        li = find_or_next(sto, key, &match);
     
    313326                /* Check the data is the same */
    314327                if ((data.size != sr->data.size) || memcmp(data.data, sr->data.data, data.size)) {
    315                         TRACE_DEBUG(INFO, "GnuTLS tried to store a session with same key and different data!");
     328                        TRACE_DEBUG(SR_LEVEL, "GnuTLS tried to store a session with same key and different data!");
    316329                        ret = -1;
     330                } else {
     331                        TRACE_DEBUG(SR_LEVEL, "GnuTLS tried to store a session with same key and same data, skipped.");
    317332                }
    318333                goto out;
     
    350365       
    351366        CHECK_PARAMS_DO( sto && key.data, return -1 );
    352         TRACE_DEBUG_BUFFER(SR_LEVEL, "Session delete [key ", key.data, key.size < 16 ? key.size : 16, "]");
    353367       
    354368        CHECK_POSIX_DO( pthread_rwlock_wrlock(&sto->lock), return -1 );
     369        TRACE_DEBUG_BUFFER(SR_LEVEL, "Session delete [key ", key.data, key.size, "]");
    355370       
    356371        li = find_or_next(sto, key, &match);
     
    382397
    383398        CHECK_PARAMS_DO( sto && key.data, return error );
    384         TRACE_DEBUG_BUFFER(SR_LEVEL, "Session fetch [key ", key.data, key.size < 16 ? key.size : 16, "]");
    385399
    386400        CHECK_POSIX_DO( pthread_rwlock_rdlock(&sto->lock), return error );
     401        TRACE_DEBUG_BUFFER(SR_LEVEL, "Session fetch [key ", key.data, key.size, "]");
    387402       
    388403        li = find_or_next(sto, key, &match);
     
    394409        }
    395410out:   
     411        TRACE_DEBUG(SR_LEVEL, "Fetched (%p, %d) from store %p", res.data, res.size, sto);
    396412        CHECK_POSIX_DO( pthread_rwlock_unlock(&sto->lock), return error);
    397413        return res;
     
    417433        TRACE_ENTRY("%p", arg);
    418434       
     435        /* Set the thread name */
     436        {
     437                char buf[48];
     438                snprintf(buf, sizeof(buf), "Handshake resume (%hu@%d)", ctx->strid, ctx->parent->cc_socket);
     439                fd_log_threadname ( buf );
     440        }
     441       
    419442        TRACE_DEBUG(FULL, "Starting TLS resumed handshake on stream %hu", ctx->strid);
    420443        CHECK_GNUTLS_DO( gnutls_handshake( ctx->session ), return NULL);
    421444                       
    422         /* We can trace success of resuming handshake by using gnutls_session_is_resumed */
     445        if (TRACE_BOOL(FULL)) {
     446                int resumed = gnutls_session_is_resumed(ctx->session);
     447                if (resumed) {
     448                        fd_log_debug("Session was resumed successfully on stream %hu (conn: '%s')\n", ctx->strid, fd_cnx_getid(ctx->parent));
     449                } else {
     450                        fd_log_debug("Session was NOT resumed (full handshake) on stream %hu (conn: '%s')\n", ctx->strid, fd_cnx_getid(ctx->parent));
     451                }
     452        }
    423453                       
    424454        /* Finish */
     
    467497
    468498/* Handshake other streams, after full handshake on the master session */
    469 int fd_sctps_handshake_others(struct cnxctx * conn, char * priority)
     499int fd_sctps_handshake_others(struct cnxctx * conn, char * priority, void * alt_creds)
    470500{
    471501        uint16_t i;
     
    487517        for (i = 1; i < conn->cc_sctp_para.pairs; i++) {
    488518                /* Set credentials and priority */
    489                 CHECK_FCT( fd_tls_prepare(&conn->cc_sctps_data.array[i].session, conn->cc_tls_para.mode, priority) );
     519                CHECK_FCT( fd_tls_prepare(&conn->cc_sctps_data.array[i].session, conn->cc_tls_para.mode, priority, alt_creds) );
    490520               
    491521                /* For the client, copy data from master session; for the server, set session resuming pointers */
     
    550580}
    551581
     582static void * bye_th(void * arg)
     583{
     584        struct sctps_ctx * ctx = (struct sctps_ctx *) arg;
     585        TRACE_ENTRY("%p", arg);
     586       
     587        /* Set the thread name */
     588        {
     589                char buf[48];
     590                snprintf(buf, sizeof(buf), "gnutls_bye (%hu@%d)", ctx->strid, ctx->parent->cc_socket);
     591                fd_log_threadname ( buf );
     592        }
     593       
     594        CHECK_GNUTLS_DO( gnutls_bye(ctx->session, GNUTLS_SHUT_RDWR), /* Continue */ );
     595                       
     596        /* Finish */
     597        return arg;
     598}
     599
     600
     601
    552602/* Destroy a wrapper context */
    553603void fd_sctps_destroy(struct cnxctx * conn)
     
    560610        fd_sctps_stopthreads(conn);
    561611       
    562         /* End all TLS sessions -- maybe we should do it in parallel ? */
    563         for (i = 0; i < conn->cc_sctp_para.pairs; i++) {
    564                 CHECK_GNUTLS_DO( gnutls_bye(conn->cc_sctps_data.array[i].session, GNUTLS_SHUT_RDWR), /* Continue */ );
    565         }
    566        
     612        /* End all TLS sessions, in parallel */
     613        for (i = 1; i < conn->cc_sctp_para.pairs; i++) {
     614                CHECK_POSIX_DO( pthread_create( &conn->cc_sctps_data.array[i].thr, NULL, bye_th, &conn->cc_sctps_data.array[i] ), break );
     615        }
     616        for (--i; i > 0; --i) {
     617                CHECK_POSIX_DO( pthread_join( conn->cc_sctps_data.array[i].thr, NULL ), continue );
     618        }
     619skip:   
    567620        /* Now, stop the demux thread */
    568621        CHECK_FCT_DO( fd_thr_term(&conn->cc_rcvthr), /* continue */ );
     
    572625                fd_event_destroy( &conn->cc_sctps_data.array[i].raw_recv, free );
    573626                free(conn->cc_sctps_data.array[i].partial.buf);
    574                 gnutls_deinit(conn->cc_sctps_data.array[i].session);
     627                if (i > 0)
     628                        gnutls_deinit(conn->cc_sctps_data.array[i].session);
    575629        }
    576630       
  • freeDiameter/server.c

    r28 r29  
    116116        /* Handshake if we are a secure server port, or start clear otherwise */
    117117        if (s->secur) {
    118                 int ret = fd_cnx_handshake(c->conn, GNUTLS_SERVER, NULL);
     118                int ret = fd_cnx_handshake(c->conn, GNUTLS_SERVER, NULL, NULL);
    119119                if (ret != 0) {
    120120                        if (TRACE_BOOL(INFO)) {
     
    153153       
    154154        /* Finally, pass the information to the peers module which will handle it next */
    155         CHECK_FCT_DO( fd_peer_handle_newCER( &msg, &c->conn, s->secur ), goto fatal_error );
     155        pthread_cleanup_push((void *)fd_cnx_destroy, c->conn);
     156        pthread_cleanup_push((void *)fd_msg_free, msg);
     157        CHECK_FCT_DO( fd_peer_handle_newCER( &msg, &c->conn ), goto cleanup );
     158        pthread_cleanup_pop(0);
     159        pthread_cleanup_pop(0);
    156160       
    157161        /* The end, we cleanup the client structure */
  • freeDiameter/tests/CMakeLists.txt

    r10 r29  
    1818        testsess
    1919        testdisp
     20        testcnx
    2021)
    2122
  • freeDiameter/tests/tests.h

    r10 r29  
    4646#include <pthread.h>
    4747#include <errno.h>
     48#include <gcrypt.h>
    4849
    4950/* Test timeout duration, unless -n is passed on the command line */
    5051#ifndef TEST_TIMEOUT
    51 #define TEST_TIMEOUT    5       /* 5 seconds */
     52#define TEST_TIMEOUT    30      /* in seconds */
    5253#endif /* TEST_TIMEOUT */
    5354
     
    7879struct fd_config * fd_g_config = &conf;
    7980
     81/* gcrypt functions to support posix threads */
     82GCRY_THREAD_OPTION_PTHREAD_IMPL;
     83
    8084/* Define the standard check routines */
    8185#define CHECK( _val, _assert ){                         \
     
    99103
    100104/* Minimum inits */
    101 #define INIT_FD() {                                             \
    102         memset(fd_g_config, 0, sizeof(struct fd_config));       \
    103         CHECK( 0, fd_lib_init() );                              \
    104         fd_log_threadname(basename(__FILE__));                  \
    105         CHECK( 0, fd_conf_init() );                             \
    106         CHECK( 0, fd_dict_base_protocol(fd_g_config->cnf_dict) );       \
    107         parse_cmdline(argc, argv);                              \
     105#define INIT_FD() {                                                             \
     106        memset(fd_g_config, 0, sizeof(struct fd_config));                       \
     107        CHECK( 0, fd_lib_init() );                                              \
     108        fd_log_threadname(basename(__FILE__));                                  \
     109        (void) gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);    \
     110        (void) gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);                   \
     111        CHECK( 0, gnutls_global_init());                                        \
     112        CHECK( 0, fd_conf_init() );                                             \
     113        CHECK( 0, fd_dict_base_protocol(fd_g_config->cnf_dict) );               \
     114        parse_cmdline(argc, argv);                                              \
    108115}
    109116
  • include/freeDiameter/libfreeDiameter.h

    r25 r29  
    181181/* Helper for function entry -- for very detailed trace of the execution */
    182182#define TRACE_ENTRY(_format,_args... ) \
    183         TRACE_DEBUG(FCTS, "->%s (" #_args ") = (" _format ") >", __PRETTY_FUNCTION__, ##_args );
     183        TRACE_DEBUG(FCTS, "[enter] %s(" _format ") {" #_args "}", __PRETTY_FUNCTION__, ##_args );
    184184
    185185/* Helper for debugging by adding traces -- for debuging a specific location of the code */
     
    470470       
    471471        if (th_ret != NULL) {
    472                 TRACE_DEBUG(FULL, "The thread returned the following value: %p (ignored)", th_ret);
     472                TRACE_DEBUG(ANNOYING, "The thread returned the following value: %p (ignored)", th_ret);
    473473        }
    474474       
Note: See TracChangeset for help on using the changeset viewer.