Navigation


Changes in / [961:d95cd3ca9e8d:933:04f590da5821] in freeDiameter


Ignore:
Files:
6 deleted
24 edited

Legend:

Unmodified
Added
Removed
  • .hgtags

    r961 r932  
    3030226f5957186ae4369467b070aeb61b1c631c9a5c 1.1.5-rc2
    3131ae96ae28f3ddc48b9e2676e9538008eab2b9d60a 1.1.5
    32 8500947421cb412b5f4f2dfffdf1a35b6fb369e0 FORK
    3332155d45d0653025f45b58ab96b6ba0d5e6fb7fcf8 1.1.6
  • extensions/_sample/CMakeLists.txt

    r958 r653  
    11# The sample extension
    22PROJECT("Sample extension")
     3
     4# Overwrite the debug level for the extension code if configured
     5OPTION(DEBUG_LEVEL__SAMPLE "Overwrite debug level for the extension _sample if defined (valid values: FULL, ANNOYING, CALL...)" OFF)
     6IF (DEBUG_LEVEL__SAMPLE)
     7     ADD_DEFINITIONS(-DTRACE_LEVEL=${DEBUG_LEVEL__SAMPLE})
     8ENDIF (DEBUG_LEVEL__SAMPLE)
     9IF (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
     10  MARK_AS_ADVANCED(DEBUG_LEVEL__SAMPLE)
     11ENDIF (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
    312
    413# Compile as a module
  • extensions/acl_wl/CMakeLists.txt

    r958 r833  
    1717)
    1818
     19# Overwrite the debug level for the extension code if configured
     20OPTION(DEBUG_LEVEL_ACL_WL "Overwrite debug level for the extension acl_wl if defined (valid values: FULL, ANNOYING, CALL...)" OFF)
     21IF (DEBUG_LEVEL_ACL_WL)
     22     ADD_DEFINITIONS(-DTRACE_LEVEL=${DEBUG_LEVEL_ACL_WL})
     23ENDIF (DEBUG_LEVEL_ACL_WL)
     24IF (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
     25  MARK_AS_ADVANCED(DEBUG_LEVEL_ACL_WL)
     26ENDIF (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
     27
    1928# Compile as a module
    2029FD_ADD_EXTENSION(acl_wl ${ACL_WL_SRC})
  • extensions/acl_wl/aw_conf.y

    r961 r928  
    3535
    3636/* Yacc extension's configuration parser.
    37  * See doc/acl_wl.conf.sample for configuration file format
     37 * See doc/app_test.conf.sample for configuration file format
    3838 */
    3939
  • extensions/app_diameap/diameap_tls.h

    r959 r565  
    4242#include "diameap_defs.h"
    4343#include <gnutls/gnutls.h>
    44 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
    4544#include <gcrypt.h>
    46 #pragma GCC diagnostic warning "-Wdeprecated-declarations"
    4745#include <errno.h>
    4846#include <pthread.h>
  • extensions/app_diameap/libcrypt.h

    r959 r425  
    4040#define LIBCRYPT_H_
    4141
    42 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
    4342#include <gcrypt.h>
    44 #pragma GCC diagnostic warning "-Wdeprecated-declarations"
    4543#include <stdio.h>
    4644
  • extensions/app_diameap/plugins/eap_md5/eap_md5.c

    r959 r425  
    3838
    3939#include "../../plugins.h"
    40 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
    4140#include <gcrypt.h>
    42 #pragma GCC diagnostic warning "-Wdeprecated-declarations"
    4341
    4442#define CHALLENGE_LEN   16
  • extensions/app_radgw/CMakeLists.txt

    r958 r845  
    11# The app_radgw extension
    22PROJECT("RADIUS/Diameter extensible gateway application for freeDiameter" C)
     3
     4
     5# Overwrite the debug level for the extension code if configured
     6OPTION(DEBUG_LEVEL_APP_RADGW "Overwrite debug level for the extension app_radgw if defined (valid values: FULL, ANNOYING, CALL...)" OFF)
     7IF (DEBUG_LEVEL_APP_RADGW)
     8     ADD_DEFINITIONS(-DTRACE_LEVEL=${DEBUG_LEVEL_APP_RADGW})
     9ENDIF (DEBUG_LEVEL_APP_RADGW)
     10IF (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
     11  MARK_AS_ADVANCED(DEBUG_LEVEL_APP_RADGW)
     12ENDIF (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
    313
    414
  • extensions/app_sip/app_sip.h

    r959 r639  
    3939#include <stdlib.h>
    4040#include <stdio.h>
    41 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
    4241#include <gcrypt.h>
    43 #pragma GCC diagnostic warning "-Wdeprecated-declarations"
    4442#include <string.h>
    4543#include <mysql.h>
  • extensions/rt_default/CMakeLists.txt

    r958 r313  
    3131INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
    3232
     33# Overwrite the debug level for the extension code if configured, example: cmake -DDEBUG_LEVEL_RT_DEFAULT:STATIC=CALL ...
     34OPTION(DEBUG_LEVEL_RT_DEFAULT "Overwrite debug level for the extension rt_default if defined (valid values: FULL, ANNOYING, CALL...)" OFF)
     35IF (DEBUG_LEVEL_RT_DEFAULT)
     36     ADD_DEFINITIONS(-DTRACE_LEVEL=${DEBUG_LEVEL_RT_DEFAULT})
     37ENDIF (DEBUG_LEVEL_RT_DEFAULT)
     38IF (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
     39  MARK_AS_ADVANCED(DEBUG_LEVEL_RT_DEFAULT)
     40ENDIF (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
     41
    3342# Compile these files as a freeDiameter extension
    3443FD_ADD_EXTENSION(rt_default ${RT_DEFAULT_SRC})
  • extensions/test_sip/test_sip.h

    r959 r639  
    3939#include <stdlib.h>
    4040#include <stdio.h>
    41 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
    4241#include <gcrypt.h>
    43 #pragma GCC diagnostic warning "-Wdeprecated-declarations"
    4442#include <string.h>
    4543#include <mysql.h>
  • include/freeDiameter/libfdcore.h

    r947 r904  
    8787
    8888/* Parse the freeDiameter.conf configuration file, load the extensions */
    89 int fd_core_parseconf(const char * conffile);
     89int fd_core_parseconf(char * conffile);
    9090
    9191/* Start the server & client threads */
     
    111111        int              cnf_eyec;      /* Eye catcher: EYEC_CONFIG */
    112112       
    113         const char      *cnf_file;      /* Configuration file to parse, default is DEFAULT_CONF_FILE */
     113        char            *cnf_file;      /* Configuration file to parse, default is DEFAULT_CONF_FILE */
    114114       
    115115        DiamId_t         cnf_diamid;    /* Diameter Identity of the local peer (FQDN -- ASCII) */
     
    350350 *    ENOMEM    : Memory allocation for the new object element failed.)
    351351 */
    352 int fd_peer_add ( struct peer_info * info, const char * orig_dbg, void (*cb)(struct peer_info *, void *), void * cb_data );
     352int fd_peer_add ( struct peer_info * info, char * orig_dbg, void (*cb)(struct peer_info *, void *), void * cb_data );
    353353
    354354/*
  • include/freeDiameter/libfdproto.h

    r961 r928  
    110110
    111111/*
    112  * FUNCTION:    fd_log
     112 * FUNCTION:    fd_log_debug_fstr
    113113 * MACRO:       fd_log_debug
    114114 *
    115115 * PARAMETERS:
    116  *  loglevel    : Integer, how important the message is
     116 *  fstr        : Stream where the text will be sent (default: stdout)
    117117 *  format      : Same format string as in the printf function
    118118 *  ...         : Same list as printf
    119119 *
    120120 * DESCRIPTION:
    121  * Write information to log.
     121 *  Log internal information for use of developpers only.
    122122 * The format and arguments may contain UTF-8 encoded data. The
    123  * output medium is expected to support this encoding.
     123 * output medium (file or console) is expected to support this encoding.
    124124 *
    125125 * RETURN VALUE:
    126126 *  None.
    127127 */
    128 void fd_log ( int, const char *, ... );
    129 #define fd_log_debug(format,args...) fd_log(FD_LOG_DEBUG, format, ## args)
    130 void fd_log_debug_fstr( FILE *, const char *, ... );
     128void fd_log_debug_fstr ( FILE * fstr, const char * format, ... );
     129#define fd_log_debug(format,args...) fd_log_debug_fstr(NULL, format, ## args)
    131130
    132131/* these are internal objects of the debug facility,
     
    175174 *
    176175 * PARAMETERS:
    177  *  loglevel    : priority of the message
     176 *  fstr        : Stream where the text will be sent to (default: stdout)
    178177 *  format      : Same format string as in the printf function
    179178 *  va_list     : Argument list
     
    185184 * int          : Success or failure
    186185 */
    187 int fd_log_handler_register ( void (*logger)(int loglevel, const char * format, va_list args) );
     186int fd_log_handler_register ( void (*logger)(const char * format, va_list *args) );
    188187
    189188/*
     
    210209#endif /* ASSERT */
    211210
    212 /* log levels definitions */
    213 #define FD_LOG_DEBUG 0
    214 #define FD_LOG_ERROR 5
    215 
    216 /* print level definitions */
     211/* levels definitions */
    217212#define NONE 0  /* Display no debug message */
    218213#define INFO 1  /* Display errors only */
     
    221216#define FCTS 6  /* Display entry parameters of most functions */
    222217#define CALL 9  /* Display calls to most functions (with CHECK macros) */
     218
     219/* Increment the debug level for a file at compilation time by defining -DTRACE_LEVEL=FULL for example. */
     220#ifndef TRACE_LEVEL
     221#define TRACE_LEVEL NONE
     222#endif /* TRACE_LEVEL */
     223
     224/* The level of the file being compiled. */
     225static int local_debug_level = TRACE_LEVEL;
    223226
    224227/* A global level, changed by configuration or cmd line for example. Default is INFO (in libfdproto/log.c). */
     
    244247/* Boolean for tracing at a certain level */
    245248#ifdef DEBUG
    246 #define TRACE_BOOL(_level_) ( ((_level_) <= fd_g_debug_lvl)                                     \
     249#define TRACE_BOOL(_level_) ( ((_level_) <= local_debug_level + fd_g_debug_lvl)                                         \
    247250                                || (fd_debug_one_function && !strcmp(fd_debug_one_function, __PRETTY_FUNCTION__))       \
    248251                                || (fd_debug_one_file && !strcmp(fd_debug_one_file, __STRIPPED_FILE__) ) )
    249252#else /* DEBUG */
    250 #define TRACE_BOOL(_level_) ((_level_) <= fd_g_debug_lvl)
     253#define TRACE_BOOL(_level_) ((_level_) <= local_debug_level + fd_g_debug_lvl)
    251254#endif /* DEBUG */
    252255
    253256
    254 #define STD_TRACE_FMT_STRING "thread %s in %s@%s:%d: "
    255257/*************
    256258 The general debug macro, each call results in two lines of debug messages (change the macro for more compact output)
     
    260262#define TRACE_DEBUG(level,format,args... ) {                                                                                    \
    261263        if ( TRACE_BOOL(level) ) {                                                                                              \
     264                char __buf[25];                                                                                                 \
    262265                const char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");                                 \
    263                 fd_log(level, STD_TRACE_FMT_STRING format, \
    264                                         __thn, __PRETTY_FUNCTION__, __FILE__, __LINE__, ## args);                                               \
     266                fd_log_debug("\t | tid:%-20s\t%s\tin %s@%s:%d\n"                                                                \
     267                          "\t%s|%*s" format "\n",                                                                               \
     268                                        __thn, fd_log_time(NULL, __buf, sizeof(__buf)), __PRETTY_FUNCTION__, __FILE__, __LINE__,\
     269                                        (level < FULL)?"@":" ",level, "", ## args);                                             \
    265270        }                                                                                                                       \
    266271}
     
    270275        if ( TRACE_BOOL(level) ) {                                                                                                      \
    271276                if (fd_g_debug_lvl > FULL) {                                                                                            \
     277                        char __buf[25];                                                                                                 \
    272278                        const char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");                                 \
    273                         fd_log(level, STD_TRACE_FMT_STRING format,      \
    274                                __thn, __PRETTY_FUNCTION__, __FILE__, __LINE__, ## args);  \
     279                        fd_log_debug("\t | tid:%-20s\t%s\tin %s@%s:%d\n"                                                                \
     280                                  "\t%s|%*s" format "\n",                                                                               \
     281                                                __thn, fd_log_time(NULL, __buf, sizeof(__buf)), __PRETTY_FUNCTION__, __FILE__, __LINE__,\
     282                                                (level < FULL)?"@":" ",level, "", ## args);                                             \
    275283                } else {                                                                                                                \
    276                         fd_log(level, format, ## args);           \
     284                        fd_log_debug(format "\n", ## args);                                                                             \
    277285                }                                                                                                                       \
    278286        }                                                                                                                               \
     
    308316#define TRACE_DEBUG_BUFFER(level, prefix, buf, bufsz, suffix ) {                                                                \
    309317        if ( TRACE_BOOL(level) ) {                                                                                              \
     318                char __ts[25];                                                                                                  \
    310319                int __i;                                                                                                        \
    311320                size_t __sz = (size_t)(bufsz);                                                                                  \
    312321                uint8_t * __buf = (uint8_t *)(buf);                                                                             \
    313322                char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");                                       \
    314                 fd_log(level, STD_TRACE_FMT_STRING prefix,              \
    315                        __thn, __PRETTY_FUNCTION__, __FILE__, __LINE__); \
     323                fd_log_debug("\t | tid:%-20s\t%s\tin %s@%s:%d\n"                                                                \
     324                          "\t%s|%*s" prefix ,                                                                                   \
     325                                        __thn, fd_log_time(NULL, __ts, sizeof(__ts)), __PRETTY_FUNCTION__, __FILE__, __LINE__,  \
     326                                        (level < FULL)?"@":" ",level, "");                                                      \
    316327                for (__i = 0; __i < __sz; __i++) {                                                                              \
    317                         fd_log(level, "%02.2hhx", __buf[__i]);         \
     328                        fd_log_debug("%02.2hhx", __buf[__i]);                                                                   \
    318329                }                                                                                                               \
    319                 fd_log(level, suffix);                        \
     330                fd_log_debug(suffix "\n");                                                                                      \
    320331        }                                                                                                                       \
    321332}
     
    334345
    335346/* Dump one sockaddr Node information */
    336 #define sSA_DUMP_NODE( buf, bufsize, sa, flag ) {                \
     347#define sSA_DUMP_NODE( sa, flag ) {                             \
    337348        sSA * __sa = (sSA *)(sa);                               \
    338349        char __addrbuf[INET6_ADDRSTRLEN];                       \
     
    346357                        flag);                                  \
    347358          if (__rc)                                             \
    348                 snprintf(buf, bufsize, "%s", gai_strerror(__rc));       \
     359                fd_log_debug("%s", (char *)gai_strerror(__rc)); \
    349360          else                                                  \
    350                 snprintf(buf, bufsize, "%s", &__addrbuf[0]);       \
     361                fd_log_debug("%s", &__addrbuf[0]);              \
    351362        } else {                                                \
    352                 snprintf(buf, bufsize, "(NULL / ANY)");             \
     363                fd_log_debug("(NULL / ANY)");                   \
    353364        }                                                       \
    354365}
    355366/* Same but with the port (service) also */
    356 #define sSA_DUMP_NODE_SERV( buf, bufsize, sa, flag ) {                  \
     367#define sSA_DUMP_NODE_SERV( sa, flag ) {                                \
    357368        sSA * __sa = (sSA *)(sa);                                       \
    358369        char __addrbuf[INET6_ADDRSTRLEN];                               \
     
    367378                        flag);                                          \
    368379          if (__rc)                                                     \
    369                 snprintf(buf, bufsize, "%s", gai_strerror(__rc));  \
     380                fd_log_debug("%s", (char *)gai_strerror(__rc));         \
    370381          else                                                          \
    371                 snprintf(buf, bufsize, "[%s]:%s", &__addrbuf[0],&__servbuf[0]); \
     382                fd_log_debug("[%s]:%s", &__addrbuf[0],&__servbuf[0]);   \
    372383        } else {                                                        \
    373                 snprintf(buf, bufsize,"(NULL / ANY)");         \
     384                fd_log_debug("(NULL / ANY)");                           \
    374385        }                                                               \
    375386}
     
    378389#define TRACE_DEBUG_sSA(level, prefix, sa, flags, suffix ) {                                                                            \
    379390        if ( TRACE_BOOL(level) ) {                                                                                              \
    380                 char buf[1024]; \
     391                char __buf[25];                                                                                                 \
    381392                char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");                                       \
    382                 sSA_DUMP_NODE_SERV(buf, sizeof(buf), sa, flags );       \
    383                 fd_log(level, STD_TRACE_FMT_STRING "%s%s%s",              \
    384                        __thn, __PRETTY_FUNCTION__, __FILE__, __LINE__, prefix, buf, suffix); \
     393                fd_log_debug("\t | tid:%-20s\t%s\tin %s@%s:%d\n"                                                                \
     394                          "\t%s|%*s" prefix ,                                                                                   \
     395                                        __thn, fd_log_time(NULL, __buf, sizeof(__buf)), __PRETTY_FUNCTION__, __FILE__, __LINE__,\
     396                                        (level < FULL)?"@":" ",level, "");                                                      \
     397                sSA_DUMP_NODE_SERV( sa, flags );                                                                                \
     398                fd_log_debug(suffix "\n");                                                                                      \
    385399        }                                                                                                                       \
    386400}
     
    404418#define TRACE_DEBUG_sSA(level, prefix, sa, flags, suffix )
    405419#define TRACE_DEBUG_ERROR(format,args... ) {    \
    406         fd_log(FD_LOG_ERROR, format, ## args);  \
     420        fd_log_debug(format "\n", ## args);     \
    407421}
    408422#endif /* STRIP_DEBUG_CODE */
     
    14311445         
    14321446         ret = fd_dict_search ( dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &avpvendorboolean, &avp_sampleboolean, ENOENT);
    1433 
    1434          -- this would also work, but be slower, because it has to search all vendor dictionaries --
    1435          ret = fd_dict_search ( dict, DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Sample-Boolean", &avp_sampleboolean, ENOENT);
    14361447         
    14371448 }
  • libfdcore/cnxctx.c

    r961 r928  
    229229       
    230230        if (TRACE_BOOL(INFO)) {
    231                 char buf[1024];
    232                 sSA_DUMP_NODE( buf, sizeof(buf), &ss, NI_NUMERICHOST );
    233                 fd_log_debug("%s : accepted new client [%s].\n", fd_cnx_getid(serv), buf);
     231                fd_log_debug("%s : accepted new client [", fd_cnx_getid(serv));
     232                sSA_DUMP_NODE( &ss, NI_NUMERICHOST );
     233                fd_log_debug("].\n");
    234234        }
    235235       
     
    312312       
    313313        if (TRACE_BOOL(INFO)) {
    314                 char buf[1024];
    315                 sSA_DUMP_NODE_SERV( buf, sizeof(buf), sa, NI_NUMERICSERV);
    316                 fd_log_debug("Connection established to server '%s' (TCP:%d).\n", buf, sock);
     314                fd_log_debug("Connection established to server '");
     315                sSA_DUMP_NODE_SERV( sa, NI_NUMERICSERV);
     316                fd_log_debug("' (TCP:%d).\n", sock);
    317317        }
    318318       
     
    404404       
    405405        if (TRACE_BOOL(INFO)) {
    406                 char buf[1024];
    407                 sSA_DUMP_NODE_SERV( buf, sizeof(buf), &primary, NI_NUMERICSERV);
    408                 fd_log_debug("Connection established to server '%s' (SCTP:%d, %d/%d streams).\n", buf, sock, cnx->cc_sctp_para.str_in, cnx->cc_sctp_para.str_out);
     406                fd_log_debug("Connection established to server '");
     407                sSA_DUMP_NODE_SERV( &primary, NI_NUMERICSERV);
     408                fd_log_debug("' (SCTP:%d, %d/%d streams).\n", sock, cnx->cc_sctp_para.str_in, cnx->cc_sctp_para.str_out);
    409409        }
    410410       
  • libfdcore/config.c

    r947 r897  
    230230{
    231231        extern FILE * fddin;
    232         const char * orig = NULL;
     232        char * orig = NULL;
    233233       
    234234        /* Attempt to find the configuration file */
     
    238238        fddin = fopen(fd_g_config->cnf_file, "r");
    239239        if ((fddin == NULL) && (*fd_g_config->cnf_file != '/')) {
    240                 char * new_cnf = NULL;
    241240                /* We got a relative path, attempt to add the default directory prefix */
    242241                orig = fd_g_config->cnf_file;
    243                 CHECK_MALLOC( new_cnf = malloc(strlen(orig) + strlen(DEFAULT_CONF_PATH) + 2) ); /* we will not free it, but not important */
    244                 sprintf( new_cnf, DEFAULT_CONF_PATH "/%s", orig );
    245                 fd_g_config->cnf_file = new_cnf;
     242                CHECK_MALLOC( fd_g_config->cnf_file = malloc(strlen(orig) + strlen(DEFAULT_CONF_PATH) + 2) ); /* we will not free it, but not important */
     243                sprintf( fd_g_config->cnf_file, DEFAULT_CONF_PATH "/%s", orig );
    246244                fddin = fopen(fd_g_config->cnf_file, "r");
    247245        }
    248246        if (fddin == NULL) {
    249247                int ret = errno;
    250                 TRACE_DEBUG_ERROR("Unable to open configuration file for reading; tried the following locations: %s%s%s; Error: %s\n",
    251                                   orig ?: "", orig? " and " : "", fd_g_config->cnf_file, strerror(ret));
     248                if (orig) {
     249                        fprintf(stderr, "Unable to open configuration file for reading\n"
     250                                        "Tried the following locations:\n"
     251                                        " - %s\n"
     252                                        " - %s\n"
     253                                        "Error: %s\n", orig, fd_g_config->cnf_file, strerror(ret));
     254                } else {
     255                        fprintf(stderr, "Unable to open '%s' for reading: %s\n", fd_g_config->cnf_file, strerror(ret));
     256                }
    252257                return ret;
    253258        }
     
    347352                                fd_list_unlink(&ep->chain);
    348353                                if (TRACE_BOOL(INFO)) {
    349                                         char buf[1024];
    350                                         sSA_DUMP_NODE( buf, sizeof(buf), &ep->sa, NI_NUMERICHOST );
    351                                         fd_log_debug("Info: Removing local address conflicting with the flags no_IP / no_IP6 : %s\n", buf);
     354                                        fd_log_debug("Info: Removing local address conflicting with the flags no_IP / no_IP6 : ");
     355                                        sSA_DUMP_NODE( &ep->sa, NI_NUMERICHOST );
     356                                        fd_log_debug("\n");
    352357                                }
    353358                                free(ep);
  • libfdcore/core.c

    r961 r928  
    226226
    227227/* Parse the freeDiameter.conf configuration file, load the extensions */
    228 int fd_core_parseconf(const char * conffile)
     228int fd_core_parseconf(char * conffile)
    229229{
    230230        TRACE_ENTRY("%p", conffile);
  • libfdcore/endpoints.c

    r946 r740  
    5959       
    6060        if (TRACE_BOOL(ANNOYING + 1)) {
    61                 char buf[1024];
    62                 sSA_DUMP_NODE_SERV( buf, sizeof(buf), sa, NI_NUMERICHOST | NI_NUMERICSERV );
    6361                TRACE_DEBUG(ANNOYING, "  DEBUG:fd_ep_add_merge  Current list:");
    6462                fd_ep_dump( 4, list );
    6563                TRACE_DEBUG(ANNOYING, "  DEBUG:fd_ep_add_merge  Adding:");
    66                 fd_log_debug("    %s {%s%s%s%s}\n", buf,
     64                fd_log_debug("    ");
     65                sSA_DUMP_NODE_SERV( sa, NI_NUMERICHOST | NI_NUMERICSERV );
     66                fd_log_debug(" {%s%s%s%s}\n",
    6767                                (flags & EP_FL_CONF)    ? "C" : "-",
    6868                                (flags & EP_FL_DISC)        ? "D" : "-",
     
    336336void fd_ep_dump_one( char * prefix, struct fd_endpoint * ep, char * suffix )
    337337{
    338         char buf[1024];
    339        
    340         sSA_DUMP_NODE_SERV( buf, sizeof(buf), &ep->sa, NI_NUMERICHOST | NI_NUMERICSERV );
    341         fd_log_debug("%s%s {%s%s%s%s}%s", prefix ?: "", buf,
     338        if (prefix)
     339                fd_log_debug("%s", prefix);
     340       
     341        sSA_DUMP_NODE_SERV( &ep->sa, NI_NUMERICHOST | NI_NUMERICSERV );
     342        fd_log_debug(" {%s%s%s%s}",
    342343                        (ep->flags & EP_FL_CONF)        ? "C" : "-",
    343344                        (ep->flags & EP_FL_DISC)        ? "D" : "-",
    344345                        (ep->flags & EP_FL_ADV)         ? "A" : "-",
    345346                        (ep->flags & EP_FL_LL)          ? "L" : "-",
    346                         (ep->flags & EP_FL_PRIMARY)     ? "P" : "-",
    347                         suffix ?: "");
     347                        (ep->flags & EP_FL_PRIMARY)     ? "P" : "-");
     348        if (suffix)
     349                fd_log_debug("%s", suffix);
    348350}
    349351
  • libfdcore/peers.c

    r961 r933  
    9191
    9292/* Add a new peer entry */
    93 int fd_peer_add ( struct peer_info * info, const char * orig_dbg, void (*cb)(struct peer_info *, void *), void * cb_data )
     93int fd_peer_add ( struct peer_info * info, char * orig_dbg, void (*cb)(struct peer_info *, void *), void * cb_data )
    9494{
    9595        struct fd_peer *p = NULL;
  • libfdcore/sctp.c

    r961 r928  
    909909        }
    910910        if (TRACE_BOOL(SCTP_LEVEL)) {
    911                 char buf[1024];
    912                 sSA_DUMP_NODE_SERV(buf, sizeof(buf), &status.sstat_primary.spinfo_address, NI_NUMERICHOST | NI_NUMERICSERV );
    913911                fd_log_debug( "SCTP_STATUS : sstat_state                  : %i\n" , status.sstat_state);
    914912                fd_log_debug( "              sstat_rwnd                   : %u\n" , status.sstat_rwnd);
     
    918916                fd_log_debug( "              sstat_outstrms               : %hu\n", status.sstat_outstrms);
    919917                fd_log_debug( "              sstat_fragmentation_point    : %u\n" , status.sstat_fragmentation_point);
    920                 fd_log_debug( "              sstat_primary.spinfo_address : %s\n" , buf);
     918                fd_log_debug( "              sstat_primary.spinfo_address : ");
     919                sSA_DUMP_NODE_SERV(&status.sstat_primary.spinfo_address, NI_NUMERICHOST | NI_NUMERICSERV );
     920                fd_log_debug( "\n" );
    921921                fd_log_debug( "              sstat_primary.spinfo_state   : %d\n" , status.sstat_primary.spinfo_state);
    922922                fd_log_debug( "              sstat_primary.spinfo_cwnd    : %u\n" , status.sstat_primary.spinfo_cwnd);
  • libfdproto/dictionary.c

    r961 r928  
    12781278                _OBINFO(obj).dump_data(&obj->data);
    12791279       
     1280        fd_log_debug("\n");
     1281       
    12801282        if (depth) {
    12811283                int i;
     
    14681470       
    14691471        /* Done! */
     1472        CHECK_FCT( dump_add_str(outstr, offset, outlen, "\n") );
    14701473        return 0;
    14711474}
     
    17221725                switch (type) {
    17231726                        case DICT_VENDOR:
    1724                                 TRACE_DEBUG(FULL, "Vendor %s already in dictionary", new->data.vendor.vendor_name);
    17251727                                /* if we are here, it means the two vendors id are identical */
    17261728                                if (fd_os_cmp(locref->data.vendor.vendor_name, locref->datastr_len,
     
    17341736
    17351737                        case DICT_APPLICATION:
    1736                                 TRACE_DEBUG(FULL, "Application %s already in dictionary", new->data.application.application_name);
    17371738                                /* got same id */
    17381739                                if (fd_os_cmp(locref->data.application.application_name, locref->datastr_len,
     
    17451746
    17461747                        case DICT_TYPE:
    1747                                 TRACE_DEBUG(FULL, "Type %s already in dictionary", new->data.type.type_name);
    17481748                                /* got same name */
    17491749                                if (locref->data.type.type_base != new->data.type.type_base) {
     
    17681768
    17691769                        case DICT_ENUMVAL:
    1770                                 TRACE_DEBUG(FULL, "Enum %s already in dictionary", new->data.enumval.enum_name);
    17711770                                /* got either same name or same value. We check that both are true */
    17721771                                if (order_enum_by_name(locref, new)) {
     
    17821781
    17831782                        case DICT_AVP:
    1784                                 TRACE_DEBUG(FULL, "AVP %s already in dictionary", new->data.avp.avp_name);
    17851783                                /* got either same name or code */
    17861784                                if (order_avp_by_code(locref, new)) {
     
    18121810
    18131811                        case DICT_COMMAND:
    1814                                 TRACE_DEBUG(FULL, "Command %s already in dictionary", new->data.cmd.cmd_name);
    18151812                                /* We got either same name, or same code + R flag */
    18161813                                if (order_cmd_by_name(locref, new)) {
  • libfdproto/log.c

    r961 r928  
    4444int fd_g_debug_lvl = INFO;
    4545
    46 static void fd_internal_logger( int, const char *, va_list );
    47 
    4846/* These may be used to pass specific debug requests via the command-line parameters */
    4947char * fd_debug_one_function = NULL;
     
    5553
    5654/* Allow passing of the log and debug information from base stack to extensions */
    57 void (*fd_logger)( int loglevel, const char * format, va_list args ) = fd_internal_logger;
     55void (*fd_external_logger)( const char * format, va_list *args ) = NULL;
    5856
    59 /* Register an external call back for tracing and debug */
    60 int fd_log_handler_register( void (*logger)(int loglevel, const char * format, va_list args) )
     57/* Register an dexternal call back for tracing and debug */
     58int fd_log_handler_register( void (*logger)(const char * format, va_list *args))
    6159{
    6260        CHECK_PARAMS( logger );
    6361
    64         if ( fd_logger != fd_internal_logger )
     62        if ( fd_external_logger != NULL )
    6563        {
    6664               return EALREADY; /* only one registration allowed */
     
    6866        else
    6967        {
    70                fd_logger = logger;
     68               fd_external_logger = logger;
    7169        }
    72 
    7370        return 0;
    7471}
     
    7774int fd_log_handler_unregister ( void )
    7875{
    79         fd_logger = fd_internal_logger;
     76        fd_external_logger = NULL;
    8077        return 0; /* Successfull in all cases. */
    8178}
     
    8683}
    8784
    88 
    89 static void fd_internal_logger( int loglevel, const char *format, va_list ap )
    90 {
    91     char buf[25];
    92     FILE *fstr = fd_g_debug_fstr ?: stdout;
    93 
    94     /* logging has been decided by macros outside already */
    95 
    96     /* add timestamp */
    97     fprintf(fd_g_debug_fstr, "%s\t", fd_log_time(NULL, buf, sizeof(buf)));
    98     vfprintf(fd_g_debug_fstr, format, ap);
    99     if (format && (format[strlen(format)-1] != '\n')) {
    100         fprintf(fd_g_debug_fstr, "\n");
    101     }
    102     fflush(fd_g_debug_fstr);
    103 }
    104 
    10585/* Log a debug message */
    106 void fd_log ( int loglevel, const char * format, ... )
     86void fd_log_debug_fstr ( FILE * fstr, const char * format, ... )
    10787{
    10888        va_list ap;
     
    11393       
    11494        va_start(ap, format);
    115         fd_logger(loglevel, format, ap);
     95        if ( fd_external_logger != NULL )
     96        {
     97               fd_external_logger( format, &ap );
     98        }
     99        else
     100        {
     101               vfprintf( fstr ?: stdout, format, ap);
     102               fflush(fstr ?: stdout);
     103        }
    116104        va_end(ap);
    117105
     
    119107       
    120108        (void)pthread_mutex_unlock(&fd_log_lock);
    121 }
    122 
    123 /* Log debug message to file. */
    124 void fd_log_debug_fstr( FILE * fstr, const char * format, ... )
    125 {
    126         va_list ap;
    127        
    128         va_start(ap, format);
    129         vfprintf(fstr, format, ap);
    130         va_end(ap);
    131109}
    132110
  • libfdproto/messages.c

    r961 r928  
    683683        struct tm tm;
    684684       
    685         CHECK_FCT( dump_add_str(outstr, offset, outlen, "%*sMSG: %p|", INOBJHDRVAL, msg) );
     685        CHECK_FCT( dump_add_str(outstr, offset, outlen, "%*sMSG: %p\n", INOBJHDRVAL, msg) );
    686686       
    687687        if (!CHECK_MSG(msg)) {
    688                 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "INVALID!", INOBJHDRVAL) );
     688                CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "INVALID!\n", INOBJHDRVAL) );
    689689                return 0;
    690690        }
     
    693693                tsoffset += strftime(buftime + tsoffset, sizeof(buftime) - tsoffset, "%D,%T", localtime_r( &msg->msg_ts_rcv.tv_sec , &tm ));
    694694                tsoffset += snprintf(buftime + tsoffset, sizeof(buftime) - tsoffset, ".%6.6ld", msg->msg_ts_rcv.tv_nsec / 1000);
    695                 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "Received: %s|", INOBJHDRVAL, buftime) );
     695                CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "Received: %s\n", INOBJHDRVAL, buftime) );
    696696        }
    697697        if ((msg->msg_ts_sent.tv_sec != 0) || (msg->msg_ts_sent.tv_nsec != 0)) {
    698698                tsoffset += strftime(buftime + tsoffset, sizeof(buftime) - tsoffset, "%D,%T", localtime_r( &msg->msg_ts_sent.tv_sec , &tm ));
    699699                tsoffset += snprintf(buftime + tsoffset, sizeof(buftime) - tsoffset, ".%6.6ld", msg->msg_ts_sent.tv_nsec / 1000);
    700                 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "Sent    : %s|", INOBJHDRVAL, buftime) );
     700                CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "Sent    : %s\n", INOBJHDRVAL, buftime) );
    701701        }
    702702       
    703703        if (!msg->msg_model) {
    704704               
    705                 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(no model)|", INOBJHDRVAL) );
     705                CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(no model)\n", INOBJHDRVAL) );
    706706               
    707707        } else {
     
    711711                ret = fd_dict_gettype(msg->msg_model, &dicttype);
    712712                if (ret || (dicttype != DICT_COMMAND)) {
    713                         CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(invalid model: %d %d)|", INOBJHDRVAL, ret, dicttype) );
     713                        CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(invalid model: %d %d)\n", INOBJHDRVAL, ret, dicttype) );
    714714                        goto public;
    715715                }
    716716                ret = fd_dict_getval(msg->msg_model, &dictdata);
    717717                if (ret != 0) {
    718                         CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(error getting model data: %s)|", INOBJHDRVAL, strerror(ret)) );
     718                        CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(error getting model data: %s)\n", INOBJHDRVAL, strerror(ret)) );
    719719                        goto public;
    720720                }
    721                 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "model : v/m:" DUMP_CMDFL_str "/" DUMP_CMDFL_str ", %u \"%s\"|", INOBJHDRVAL,
     721                CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "model : v/m:" DUMP_CMDFL_str "/" DUMP_CMDFL_str ", %u \"%s\"\n", INOBJHDRVAL,
    722722                        DUMP_CMDFL_val(dictdata.cmd_flag_val), DUMP_CMDFL_val(dictdata.cmd_flag_mask), dictdata.cmd_code, dictdata.cmd_name) );
    723723        }
    724724public:
    725         CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "public: V:%d L:%d fl:" DUMP_CMDFL_str " CC:%u A:%d hi:%x ei:%x|", INOBJHDRVAL,
     725        CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "public: V:%d L:%d fl:" DUMP_CMDFL_str " CC:%u A:%d hi:%x ei:%x\n", INOBJHDRVAL,
    726726                msg->msg_public.msg_version,
    727727                msg->msg_public.msg_length,
     
    732732                msg->msg_public.msg_eteid
    733733                ) );
    734         CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "intern: rwb:%p rt:%d cb:%p(%p) qry:%p asso:%d sess:%p src:%s(%zd)|",
     734        CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "intern: rwb:%p rt:%d cb:%p(%p) qry:%p asso:%d sess:%p src:%s(%zd)\n",
    735735                        INOBJHDRVAL, msg->msg_rawbuffer, msg->msg_routable, msg->msg_cb.fct, msg->msg_cb.data, msg->msg_query, msg->msg_associated, msg->msg_sess, msg->msg_src_id?:"(nil)", msg->msg_src_id_len) );
    736736        return 0;
     
    743743       
    744744        if (!CHECK_AVP(avp)) {
    745                 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "INVALID!", INOBJHDRVAL) );
     745                CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "INVALID!\n", INOBJHDRVAL) );
    746746                return 0;
    747747        }
     
    749749        if (!avp->avp_model) {
    750750               
    751                 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(no model resolved)|", INOBJHDRVAL) );
     751                CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(no model resolved)\n", INOBJHDRVAL) );
    752752               
    753753        } else {
     
    757757                ret = fd_dict_gettype(avp->avp_model, &dicttype);
    758758                if (ret || (dicttype != DICT_AVP)) {
    759                         CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(invalid model: %d %d)|", INOBJHDRVAL, ret, dicttype) );
     759                        CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(invalid model: %d %d)\n", INOBJHDRVAL, ret, dicttype) );
    760760                        goto public;
    761761                }
    762762                ret = fd_dict_getval(avp->avp_model, &dictdata);
    763763                if (ret != 0) {
    764                         CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(error getting model data: %s)|", INOBJHDRVAL, strerror(ret)) );
     764                        CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(error getting model data: %s)\n", INOBJHDRVAL, strerror(ret)) );
    765765                        goto public;
    766766                }
    767                 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "model : v/m:" DUMP_AVPFL_str "/" DUMP_AVPFL_str ", %12s, %u \"%s\"|", INOBJHDRVAL,
     767                CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "model : v/m:" DUMP_AVPFL_str "/" DUMP_AVPFL_str ", %12s, %u \"%s\"\n", INOBJHDRVAL,
    768768                        DUMP_AVPFL_val(dictdata.avp_flag_val),
    769769                        DUMP_AVPFL_val(dictdata.avp_flag_mask),
     
    773773        }
    774774public:
    775         CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "public: C:%u fl:" DUMP_AVPFL_str " L:%d V:%u  data:@%p|", INOBJHDRVAL,
     775        CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "public: C:%u fl:" DUMP_AVPFL_str " L:%d V:%u  data:@%p\n", INOBJHDRVAL,
    776776                avp->avp_public.avp_code,
    777777                DUMP_AVPFL_val(avp->avp_public.avp_flags),
     
    783783        if (avp->avp_public.avp_value) {
    784784                if (!avp->avp_model) {
    785                         CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(data set but no model: ERROR)|", INOBJHDRVAL) );
     785                        CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(data set but no model: ERROR)\n", INOBJHDRVAL) );
    786786                } else {
    787787                        CHECK_FCT( fd_dict_dump_avp_value(avp->avp_public.avp_value, avp->avp_model, indent, outstr, offset, outlen) );
     
    789789        }
    790790
    791         CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "intern: src:%p mf:%d raw:%p(%d)|", INOBJHDRVAL, avp->avp_source, avp->avp_mustfreeos, avp->avp_rawdata, avp->avp_rawlen) );
     791        CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "intern: src:%p mf:%d raw:%p(%d)\n", INOBJHDRVAL, avp->avp_source, avp->avp_mustfreeos, avp->avp_rawdata, avp->avp_rawlen) );
    792792        return 0;
    793793}
     
    880880        /* now really output this in one shot, so it is not interrupted */
    881881        TRACE_DEBUG(level, "------ Dumping object %p (w)-------", obj);
    882         TRACE_DEBUG(level, "%s", outstr);
     882        fd_log_debug_fstr(fd_g_debug_fstr, "%s", outstr);
    883883        TRACE_DEBUG(level, "------ /end of object %p -------", obj);
    884884       
     
    896896                        fd_log_debug_fstr(fd_g_debug_fstr, "Error while dumping %p\n", obj) );
    897897        TRACE_DEBUG(level, "------ Dumping object %p (s)-------", obj);
    898         TRACE_DEBUG(level, "%s", outstr);
     898        fd_log_debug_fstr(fd_g_debug_fstr, "%s", outstr);
    899899        TRACE_DEBUG(level, "------ /end of object %p -------", obj);
    900900        free(outstr);
  • tests/CMakeLists.txt

    r958 r878  
    3636
    3737ADD_DEFINITIONS(-DTEST_DEBUG)
     38ADD_DEFINITIONS(-DTRACE_LEVEL=NONE)
    3839ADD_DEFINITIONS(-DBUILD_DIR="${CMAKE_BINARY_DIR}")
    3940
  • tests/tests.h

    r959 r854  
    4747#include <pthread.h>
    4848#include <errno.h>
    49 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
    5049#include <gcrypt.h>
    51 #pragma GCC diagnostic warning "-Wdeprecated-declarations"
    5250
    5351/* Test timeout duration, unless -n is passed on the command line */
Note: See TracChangeset for help on using the changeset viewer.