Navigation


Changeset 950:51c15f98a965 in freeDiameter


Ignore:
Timestamp:
Feb 21, 2013, 7:57:32 PM (11 years ago)
Author:
Thomas Klausner <tk@giga.or.at>
Branch:
default
Parents:
949:ad5c976e0dc7 (diff), 924:877592751fee (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 current version from 1.1 branch (927:877592751fee).

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/libfdproto.h

    r924 r950  
    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 */
     
    255260
    256261
     262#define STD_TRACE_FMT_STRING "thread %s in %s@%s:%d: "
    257263/*************
    258264 The general debug macro, each call results in two lines of debug messages (change the macro for more compact output)
     
    262268#define TRACE_DEBUG(level,format,args... ) {                                                                                    \
    263269        if ( TRACE_BOOL(level) ) {                                                                                              \
    264                 char __buf[25];                                                                                                 \
    265270                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);                                             \
     271                fd_log(level, STD_TRACE_FMT_STRING format, \
     272                                        __thn, __PRETTY_FUNCTION__, __FILE__, __LINE__, ## args);                                               \
    270273        }                                                                                                                       \
    271274}
     
    275278        if ( TRACE_BOOL(level) ) {                                                                                                      \
    276279                if (fd_g_debug_lvl > FULL) {                                                                                            \
    277                         char __buf[25];                                                                                                 \
    278280                        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);                                             \
     281                        fd_log(level, STD_TRACE_FMT_STRING format,      \
     282                               __thn, __PRETTY_FUNCTION__, __FILE__, __LINE__, ## args);  \
    283283                } else {                                                                                                                \
    284                         fd_log_debug(format "\n", ## args);                                                                             \
     284                        fd_log(level, format, ## args);           \
    285285                }                                                                                                                       \
    286286        }                                                                                                                               \
     
    316316#define TRACE_DEBUG_BUFFER(level, prefix, buf, bufsz, suffix ) {                                                                \
    317317        if ( TRACE_BOOL(level) ) {                                                                                              \
    318                 char __ts[25];                                                                                                  \
    319318                int __i;                                                                                                        \
    320319                size_t __sz = (size_t)(bufsz);                                                                                  \
    321320                uint8_t * __buf = (uint8_t *)(buf);                                                                             \
    322321                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, "");                                                      \
     322                fd_log(level, STD_TRACE_FMT_STRING prefix,              \
     323                       __thn, __PRETTY_FUNCTION__, __FILE__, __LINE__); \
    327324                for (__i = 0; __i < __sz; __i++) {                                                                              \
    328                         fd_log_debug("%02.2hhx", __buf[__i]);                                                                   \
     325                        fd_log(level, "%02.2hhx", __buf[__i]);         \
    329326                }                                                                                                               \
    330                 fd_log_debug(suffix "\n");                                                                                      \
     327                fd_log(level, suffix);                        \
    331328        }                                                                                                                       \
    332329}
     
    345342
    346343/* Dump one sockaddr Node information */
    347 #define sSA_DUMP_NODE( sa, flag ) {                             \
     344#define sSA_DUMP_NODE( buf, bufsize, sa, flag ) {                \
    348345        sSA * __sa = (sSA *)(sa);                               \
    349346        char __addrbuf[INET6_ADDRSTRLEN];                       \
     
    357354                        flag);                                  \
    358355          if (__rc)                                             \
    359                 fd_log_debug("%s", (char *)gai_strerror(__rc)); \
     356                snprintf(buf, bufsize, "%s", gai_strerror(__rc));       \
    360357          else                                                  \
    361                 fd_log_debug("%s", &__addrbuf[0]);              \
     358                snprintf(buf, bufsize, "%s", &__addrbuf[0]);       \
    362359        } else {                                                \
    363                 fd_log_debug("(NULL / ANY)");                   \
     360                snprintf(buf, bufsize, "(NULL / ANY)");             \
    364361        }                                                       \
    365362}
    366363/* Same but with the port (service) also */
    367 #define sSA_DUMP_NODE_SERV( sa, flag ) {                                \
     364#define sSA_DUMP_NODE_SERV( buf, bufsize, sa, flag ) {                  \
    368365        sSA * __sa = (sSA *)(sa);                                       \
    369366        char __addrbuf[INET6_ADDRSTRLEN];                               \
     
    378375                        flag);                                          \
    379376          if (__rc)                                                     \
    380                 fd_log_debug("%s", (char *)gai_strerror(__rc));         \
     377                snprintf(buf, bufsize, "%s", gai_strerror(__rc));  \
    381378          else                                                          \
    382                 fd_log_debug("[%s]:%s", &__addrbuf[0],&__servbuf[0]);   \
     379                snprintf(buf, bufsize, "[%s]:%s", &__addrbuf[0],&__servbuf[0]); \
    383380        } else {                                                        \
    384                 fd_log_debug("(NULL / ANY)");                           \
     381                snprintf(buf, bufsize,"(NULL / ANY)");         \
    385382        }                                                               \
    386383}
     
    389386#define TRACE_DEBUG_sSA(level, prefix, sa, flags, suffix ) {                                                                            \
    390387        if ( TRACE_BOOL(level) ) {                                                                                              \
    391                 char __buf[25];                                                                                                 \
     388                char buf[1024]; \
    392389                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");                                                                                      \
     390                sSA_DUMP_NODE_SERV(buf, sizeof(buf), sa, flags );       \
     391                fd_log(level, STD_TRACE_FMT_STRING "%s%s%s",              \
     392                       __thn, __PRETTY_FUNCTION__, __FILE__, __LINE__, prefix, buf, suffix); \
    399393        }                                                                                                                       \
    400394}
     
    418412#define TRACE_DEBUG_sSA(level, prefix, sa, flags, suffix )
    419413#define TRACE_DEBUG_ERROR(format,args... ) {    \
    420         fd_log_debug(format "\n", ## args);     \
     414        fd_log(FD_LOG_ERROR, format, ## args);  \
    421415}
    422416#endif /* STRIP_DEBUG_CODE */
  • include/freeDiameter/libfdproto.h

    r946 r950  
    11581158};
    11591159
     1160/****
     1161 Callbacks defined in libfdproto/dictionary_functions.c file -- see that file for usage.
     1162 */
     1163
     1164/* Convert an Address type AVP into a struct sockaddr_storage */
     1165int fd_dictfct_Address_encode(void * data, union avp_value * avp_value);
     1166int fd_dictfct_Address_interpret(union avp_value * avp_value, void * interpreted);
     1167char * fd_dictfct_Address_dump(union avp_value * avp_value);
     1168
     1169/* Display the content of an AVP of type UTF8String in the log file */
     1170char * fd_dictfct_UTF8String_dump(union avp_value * avp_value);
     1171
     1172/* For Time AVPs, map with time_t value directly */
     1173int fd_dictfct_Time_encode(void * data, union avp_value * avp_value);
     1174int fd_dictfct_Time_interpret(union avp_value * avp_value, void * interpreted);
     1175char * fd_dictfct_Time_dump(union avp_value * avp_value);
     1176
     1177
     1178
     1179/****/
    11601180
    11611181/***
     
    11881208 
    11891209*/
    1190          
     1210
    11911211/*
    11921212 ***************************************************************************
     
    17901810 *
    17911811 * RETURN VALUE:
    1792  *  0           : The session is created.
    1793  *  EINVAL      : A parameter is invalid.
    1794  *  EALREADY    : A session with the same name already exists (returned in *session)
     1812 *  0           : The session is created, the initial msg refcount is 1.
     1813 *  EINVAL      : A parameter is invalid.
     1814 *  EALREADY    : A session with the same name already exists (returned in *session), the msg refcount is increased.
    17951815 *  ENOMEM      : Not enough memory to complete the operation
    17961816 */
     
    24792499int fd_msg_sess_get(struct dictionary * dict, struct msg * msg, struct session ** session, int * isnew);
    24802500
     2501/* This one is used by the libfdcore, you should use fd_msg_new_session rather than fd_sess_new, when possible */
     2502int fd_msg_sess_set(struct msg * msg, struct session * session);
     2503
     2504
    24812505/***************************************/
    24822506/*   Manage AVP values                 */
  • libfdcore/fdd.l

    r944 r950  
    5252        yylloc->first_column = yylloc->last_column + 1;                 \
    5353        yylloc->last_column = yylloc->first_column + yyleng - 1;        \
    54         TRACE_DEBUG_ERROR("(%d:%d-%d:%d) matched rule %d, length=%d, txt='%s'\n",       \
     54        TRACE_DEBUG_ERROR(                                              \
     55                "(%d:%d-%d:%d) matched rule %d, length=%d, txt='%s'\n", \
    5556                yylloc->first_line, yylloc->first_column,               \
    5657                yylloc->last_line, yylloc->last_column,                 \
     
    145146<*>[[:alnum:]]+         |       /* This rule is only useful to print a complete token in error messages */
    146147        /* Unrecognized character */
    147 <*>.                    { 
     148<*>.                    {
    148149                                TRACE_DEBUG_ERROR("Unrecognized text on line %d col %d: '%s'.\n", yylloc->first_line, yylloc->first_column, yytext);
    149150                                return LEX_ERROR;
  • libfdcore/fdd.y

    r944 r950  
    328328                                if (fd == NULL) {
    329329                                        int ret = errno;
    330                                         TRACE_DEBUG(INFO, "Unable to open extension file %s for reading: %s\n", fname, strerror(ret));
     330                                        TRACE_DEBUG_ERROR("Unable to open extension file %s for reading: %s\n", fname, strerror(ret));
    331331                                        yyerror (&yylloc, conf, "Error adding extension");
    332332                                        YYERROR;
     
    502502                                if (fd == NULL) {
    503503                                        int ret = errno;
    504                                         TRACE_DEBUG(INFO, "Unable to open certificate file %s for reading: %s\n", $3, strerror(ret));
     504                                        TRACE_DEBUG_ERROR("Unable to open certificate file %s for reading: %s\n", $3, strerror(ret));
    505505                                        yyerror (&yylloc, conf, "Error on file name");
    506506                                        YYERROR;
     
    510510                                if (fd == NULL) {
    511511                                        int ret = errno;
    512                                         TRACE_DEBUG(INFO, "Unable to open private key file %s for reading: %s\n", $5, strerror(ret));
     512                                        TRACE_DEBUG_ERROR("Unable to open private key file %s for reading: %s\n", $5, strerror(ret));
    513513                                        yyerror (&yylloc, conf, "Error on file name");
    514514                                        YYERROR;
     
    533533                                if (fd == NULL) {
    534534                                        int ret = errno;
    535                                         TRACE_DEBUG(INFO, "Unable to open CA file %s for reading: %s\n", $3, strerror(ret));
     535                                        TRACE_DEBUG_ERROR("Unable to open CA file %s for reading: %s\n", $3, strerror(ret));
    536536                                        yyerror (&yylloc, conf, "Error on file name");
    537537                                        YYERROR;
     
    573573                                if (fd == NULL) {
    574574                                        int ret = errno;
    575                                         TRACE_DEBUG(INFO, "Unable to open CRL file %s for reading: %s\n", $3, strerror(ret));
     575                                        TRACE_DEBUG_ERROR("Unable to open CRL file %s for reading: %s\n", $3, strerror(ret));
    576576                                        yyerror (&yylloc, conf, "Error on file name");
    577577                                        YYERROR;
     
    616616                                                        &err_pos),
    617617                                                { yyerror (&yylloc, conf, "Error setting Priority parameter.");
    618                                                   fprintf(stderr, "Error at position : %s\n", err_pos);
     618                                                  TRACE_DEBUG_ERROR("Error at position : %s\n", err_pos);
    619619                                                  YYERROR; } );
    620620                        }
     
    633633                                if (fd == NULL) {
    634634                                        int ret = errno;
    635                                         TRACE_DEBUG(INFO, "Unable to open DH file %s for reading: %s\n", $3, strerror(ret));
     635                                        TRACE_DEBUG_ERROR("Unable to open DH file %s for reading: %s\n", $3, strerror(ret));
    636636                                        yyerror (&yylloc, conf, "Error on file name");
    637637                                        YYERROR;
  • libfdcore/peers.c

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

    r947 r950  
    549549        ev_data->validate = !found;
    550550       
    551         CHECK_FCT_DO( ret = fd_event_send(peer->p_events, FDEVP_CNX_INCOMING, sizeof(ev_data), ev_data), goto out );
     551        CHECK_FCT_DO( ret = fd_event_send(peer->p_events, FDEVP_CNX_INCOMING, sizeof(*ev_data), ev_data), goto out );
    552552       
    553553out:   
  • libfdcore/sctp.c

    r921 r950  
    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 );
    911913                fd_log_debug( "SCTP_STATUS : sstat_state                  : %i\n" , status.sstat_state);
    912914                fd_log_debug( "              sstat_rwnd                   : %u\n" , status.sstat_rwnd);
     
    916918                fd_log_debug( "              sstat_outstrms               : %hu\n", status.sstat_outstrms);
    917919                fd_log_debug( "              sstat_fragmentation_point    : %u\n" , status.sstat_fragmentation_point);
    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" );
     920                fd_log_debug( "              sstat_primary.spinfo_address : %s\n" , buf);
    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);
  • libfdcore/sctp.c

    r946 r950  
    654654                if (ep->sa.sa_family == AF_INET6)
    655655                #else /* SCTP_USE_MAPPED_ADDRESSES */
    656                 if (target_family == AF_INET6) {
     656                if (target_family == AF_INET6)
    657657                #endif /* SCTP_USE_MAPPED_ADDRESSES */
    658658                        sz = sizeof(sSA6);
     
    10871087        /* We will loop while all data is not received. */
    10881088incomplete:
    1089         if (datasize == bufsz - sizeof(struct timespec)) {
     1089        while (datasize + sizeof(struct timespec) >= bufsz ) {
    10901090                /* The buffer is full, enlarge it */
    10911091                bufsz += mempagesz;
Note: See TracChangeset for help on using the changeset viewer.