Navigation


Changeset 961:d95cd3ca9e8d in freeDiameter for include


Ignore:
Timestamp:
Mar 7, 2013, 4:09:54 AM (11 years ago)
Author:
Thomas Klausner <tk@giga.or.at>
Branch:
default
Parents:
960:f39fa6cd86e0 (diff), 933:04f590da5821 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Message:

merge latest 1.1 branch (one commit post 1.1.6)

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/libfdproto.h

    r928 r961  
    110110
    111111/*
    112  * FUNCTION:    fd_log_debug_fstr
     112 * FUNCTION:    fd_log
    113113 * MACRO:       fd_log_debug
    114114 *
    115115 * PARAMETERS:
    116  *  fstr        : Stream where the text will be sent (default: stdout)
     116 *  loglevel    : Integer, how important the message is
    117117 *  format      : Same format string as in the printf function
    118118 *  ...         : Same list as printf
    119119 *
    120120 * DESCRIPTION:
    121  *  Log internal information for use of developpers only.
     121 * Write information to log.
    122122 * The format and arguments may contain UTF-8 encoded data. The
    123  * output medium (file or console) is expected to support this encoding.
     123 * output medium is expected to support this encoding.
    124124 *
    125125 * RETURN VALUE:
    126126 *  None.
    127127 */
    128 void fd_log_debug_fstr ( FILE * fstr, const char * format, ... );
    129 #define fd_log_debug(format,args...) fd_log_debug_fstr(NULL, format, ## args)
     128void fd_log ( int, const char *, ... );
     129#define fd_log_debug(format,args...) fd_log(FD_LOG_DEBUG, format, ## args)
     130void fd_log_debug_fstr( FILE *, const char *, ... );
    130131
    131132/* these are internal objects of the debug facility,
     
    174175 *
    175176 * PARAMETERS:
    176  *  fstr        : Stream where the text will be sent to (default: stdout)
     177 *  loglevel    : priority of the message
    177178 *  format      : Same format string as in the printf function
    178179 *  va_list     : Argument list
     
    184185 * int          : Success or failure
    185186 */
    186 int fd_log_handler_register ( void (*logger)(const char * format, va_list *args) );
     187int fd_log_handler_register ( void (*logger)(int loglevel, const char * format, va_list args) );
    187188
    188189/*
     
    209210#endif /* ASSERT */
    210211
    211 /* levels definitions */
     212/* log levels definitions */
     213#define FD_LOG_DEBUG 0
     214#define FD_LOG_ERROR 5
     215
     216/* print level definitions */
    212217#define NONE 0  /* Display no debug message */
    213218#define INFO 1  /* Display errors only */
     
    216221#define FCTS 6  /* Display entry parameters of most functions */
    217222#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. */
    225 static int local_debug_level = TRACE_LEVEL;
    226223
    227224/* A global level, changed by configuration or cmd line for example. Default is INFO (in libfdproto/log.c). */
     
    247244/* Boolean for tracing at a certain level */
    248245#ifdef DEBUG
    249 #define TRACE_BOOL(_level_) ( ((_level_) <= local_debug_level + fd_g_debug_lvl)                                         \
     246#define TRACE_BOOL(_level_) ( ((_level_) <= fd_g_debug_lvl)                                     \
    250247                                || (fd_debug_one_function && !strcmp(fd_debug_one_function, __PRETTY_FUNCTION__))       \
    251248                                || (fd_debug_one_file && !strcmp(fd_debug_one_file, __STRIPPED_FILE__) ) )
    252249#else /* DEBUG */
    253 #define TRACE_BOOL(_level_) ((_level_) <= local_debug_level + fd_g_debug_lvl)
     250#define TRACE_BOOL(_level_) ((_level_) <= fd_g_debug_lvl)
    254251#endif /* DEBUG */
    255252
    256253
     254#define STD_TRACE_FMT_STRING "thread %s in %s@%s:%d: "
    257255/*************
    258256 The general debug macro, each call results in two lines of debug messages (change the macro for more compact output)
     
    262260#define TRACE_DEBUG(level,format,args... ) {                                                                                    \
    263261        if ( TRACE_BOOL(level) ) {                                                                                              \
    264                 char __buf[25];                                                                                                 \
    265262                const char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");                                 \
    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);                                             \
     263                fd_log(level, STD_TRACE_FMT_STRING format, \
     264                                        __thn, __PRETTY_FUNCTION__, __FILE__, __LINE__, ## args);                                               \
    270265        }                                                                                                                       \
    271266}
     
    275270        if ( TRACE_BOOL(level) ) {                                                                                                      \
    276271                if (fd_g_debug_lvl > FULL) {                                                                                            \
    277                         char __buf[25];                                                                                                 \
    278272                        const char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");                                 \
    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);                                             \
     273                        fd_log(level, STD_TRACE_FMT_STRING format,      \
     274                               __thn, __PRETTY_FUNCTION__, __FILE__, __LINE__, ## args);  \
    283275                } else {                                                                                                                \
    284                         fd_log_debug(format "\n", ## args);                                                                             \
     276                        fd_log(level, format, ## args);           \
    285277                }                                                                                                                       \
    286278        }                                                                                                                               \
     
    316308#define TRACE_DEBUG_BUFFER(level, prefix, buf, bufsz, suffix ) {                                                                \
    317309        if ( TRACE_BOOL(level) ) {                                                                                              \
    318                 char __ts[25];                                                                                                  \
    319310                int __i;                                                                                                        \
    320311                size_t __sz = (size_t)(bufsz);                                                                                  \
    321312                uint8_t * __buf = (uint8_t *)(buf);                                                                             \
    322313                char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");                                       \
    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, "");                                                      \
     314                fd_log(level, STD_TRACE_FMT_STRING prefix,              \
     315                       __thn, __PRETTY_FUNCTION__, __FILE__, __LINE__); \
    327316                for (__i = 0; __i < __sz; __i++) {                                                                              \
    328                         fd_log_debug("%02.2hhx", __buf[__i]);                                                                   \
     317                        fd_log(level, "%02.2hhx", __buf[__i]);         \
    329318                }                                                                                                               \
    330                 fd_log_debug(suffix "\n");                                                                                      \
     319                fd_log(level, suffix);                        \
    331320        }                                                                                                                       \
    332321}
     
    345334
    346335/* Dump one sockaddr Node information */
    347 #define sSA_DUMP_NODE( sa, flag ) {                             \
     336#define sSA_DUMP_NODE( buf, bufsize, sa, flag ) {                \
    348337        sSA * __sa = (sSA *)(sa);                               \
    349338        char __addrbuf[INET6_ADDRSTRLEN];                       \
     
    357346                        flag);                                  \
    358347          if (__rc)                                             \
    359                 fd_log_debug("%s", (char *)gai_strerror(__rc)); \
     348                snprintf(buf, bufsize, "%s", gai_strerror(__rc));       \
    360349          else                                                  \
    361                 fd_log_debug("%s", &__addrbuf[0]);              \
     350                snprintf(buf, bufsize, "%s", &__addrbuf[0]);       \
    362351        } else {                                                \
    363                 fd_log_debug("(NULL / ANY)");                   \
     352                snprintf(buf, bufsize, "(NULL / ANY)");             \
    364353        }                                                       \
    365354}
    366355/* Same but with the port (service) also */
    367 #define sSA_DUMP_NODE_SERV( sa, flag ) {                                \
     356#define sSA_DUMP_NODE_SERV( buf, bufsize, sa, flag ) {                  \
    368357        sSA * __sa = (sSA *)(sa);                                       \
    369358        char __addrbuf[INET6_ADDRSTRLEN];                               \
     
    378367                        flag);                                          \
    379368          if (__rc)                                                     \
    380                 fd_log_debug("%s", (char *)gai_strerror(__rc));         \
     369                snprintf(buf, bufsize, "%s", gai_strerror(__rc));  \
    381370          else                                                          \
    382                 fd_log_debug("[%s]:%s", &__addrbuf[0],&__servbuf[0]);   \
     371                snprintf(buf, bufsize, "[%s]:%s", &__addrbuf[0],&__servbuf[0]); \
    383372        } else {                                                        \
    384                 fd_log_debug("(NULL / ANY)");                           \
     373                snprintf(buf, bufsize,"(NULL / ANY)");         \
    385374        }                                                               \
    386375}
     
    389378#define TRACE_DEBUG_sSA(level, prefix, sa, flags, suffix ) {                                                                            \
    390379        if ( TRACE_BOOL(level) ) {                                                                                              \
    391                 char __buf[25];                                                                                                 \
     380                char buf[1024]; \
    392381                char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");                                       \
    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");                                                                                      \
     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); \
    399385        }                                                                                                                       \
    400386}
     
    418404#define TRACE_DEBUG_sSA(level, prefix, sa, flags, suffix )
    419405#define TRACE_DEBUG_ERROR(format,args... ) {    \
    420         fd_log_debug(format "\n", ## args);     \
     406        fd_log(FD_LOG_ERROR, format, ## args);  \
    421407}
    422408#endif /* STRIP_DEBUG_CODE */
     
    14451431         
    14461432         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);
    14471436         
    14481437 }
  • include/freeDiameter/libfdproto.h

    r958 r961  
    33* Author: Sebastien Decugis <sdecugis@freediameter.net>                                                  *
    44*                                                                                                        *
    5 * Copyright (c) 2012, WIDE Project and NICT                                                              *
     5* Copyright (c) 2013, WIDE Project and NICT                                                              *
    66* All rights reserved.                                                                                   *
    77*                                                                                                        *
Note: See TracChangeset for help on using the changeset viewer.