Navigation



Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/libfreeDiameter.h

    r29 r20  
    120120 *
    121121 * PARAMETERS:
    122  *  ts          : The timestamp to log, or NULL for "now"
    123122 *  buf         : An array where the time must be stored
    124123 *  len         : size of the buffer
    125124 *
    126125 * DESCRIPTION:
    127  *  Writes the timestamp (in human readable format) in a buffer.
     126 *  Writes the current timestamp (in human readable format) in a buffer.
    128127 *
    129128 * RETURN VALUE:
    130129 *  pointer to buf.
    131130 */
    132 char * fd_log_time ( struct timespec * ts, char * buf, size_t len );
     131char * fd_log_time ( char * buf, size_t len );
    133132
    134133
     
    174173                fd_log_debug("\t | tid:%-20s\t%s\tin %s@%s:%d\n"                                                                \
    175174                          "\t%s|%*s" format "\n",                                                                               \
    176                                         __thn, fd_log_time(NULL, __buf, sizeof(__buf)), __PRETTY_FUNCTION__, __FILE__, __LINE__,        \
     175                                        __thn, fd_log_time(__buf, sizeof(__buf)), __PRETTY_FUNCTION__, __FILE__, __LINE__,      \
    177176                                        (level < FULL)?"@":" ",level, "", ## args);                                             \
    178177        }                                                                                                                       \
     
    181180/* Helper for function entry -- for very detailed trace of the execution */
    182181#define TRACE_ENTRY(_format,_args... ) \
    183         TRACE_DEBUG(FCTS, "[enter] %s(" _format ") {" #_args "}", __PRETTY_FUNCTION__, ##_args );
     182        TRACE_DEBUG(FCTS, "->%s (" #_args ") = (" _format ") >", __PRETTY_FUNCTION__, ##_args );
    184183
    185184/* Helper for debugging by adding traces -- for debuging a specific location of the code */
     
    329328                        flag);                                  \
    330329          if (__rc)                                             \
    331                 fd_log_debug("%s", (char *)gai_strerror(__rc)); \
     330                fd_log_debug((char *)gai_strerror(__rc));       \
    332331          else                                                  \
    333                 fd_log_debug("%s", &__addrbuf[0]);              \
     332                fd_log_debug(&__addrbuf[0]);                    \
    334333        } else {                                                \
    335334                fd_log_debug("(NULL / ANY)");                   \
    336335        }                                                       \
    337336}
    338 /* Same but with the port (service) also */
    339 #define sSA_DUMP_NODE_SERV( sa, flag ) {                                \
    340         sSA * __sa = (sSA *)(sa);                                       \
    341         char __addrbuf[INET6_ADDRSTRLEN];                               \
    342         char __servbuf[32];                                             \
    343         if (__sa) {                                                     \
    344           int __rc = getnameinfo(__sa,                                  \
    345                         sizeof(sSS),                                    \
    346                         __addrbuf,                                      \
    347                         sizeof(__addrbuf),                              \
    348                         __servbuf,                                      \
    349                         sizeof(__servbuf),                              \
    350                         flag);                                          \
    351           if (__rc)                                                     \
    352                 fd_log_debug("%s", (char *)gai_strerror(__rc));         \
    353           else                                                          \
    354                 fd_log_debug("[%s]:%s", &__addrbuf[0],&__servbuf[0]);   \
    355         } else {                                                        \
    356                 fd_log_debug("(NULL / ANY)");                           \
    357         }                                                               \
    358 }
    359 /* Inside a debug trace */
    360 #define TRACE_DEBUG_sSA(level, prefix, sa, flags, suffix ) {                                                                            \
    361         if ( TRACE_BOOL(level) ) {                                                                                              \
    362                 char __buf[25];                                                                                                 \
    363                 char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");                                       \
    364                 fd_log_debug("\t | tid:%-20s\t%s\tin %s@%s:%d\n"                                                                \
    365                           "\t%s|%*s" prefix ,                                                                                   \
    366                                         __thn, fd_log_time(NULL, __buf, sizeof(__buf)), __PRETTY_FUNCTION__, __FILE__, __LINE__,\
    367                                         (level < FULL)?"@":" ",level, "");                                                      \
    368                 sSA_DUMP_NODE_SERV( sa, flags );                                                                                \
    369                 fd_log_debug(suffix "\n");                                                                                      \
    370         }                                                                                                                       \
    371 }
    372 
     337/* if needed, add sSA_DUMP_SERVICE */
    373338
    374339/* A l4 protocol name (TCP / SCTP) */
     
    425390        (    ((ts1)->tv_sec  < (ts2)->tv_sec )  \
    426391          || (((ts1)->tv_sec  == (ts2)->tv_sec ) && ((ts1)->tv_nsec < (ts2)->tv_nsec) ))
    427 
    428 
    429 /* Trace a binary buffer content */
    430 #define TRACE_DEBUG_BUFFER(level, prefix, buf, bufsz, suffix ) {                                                                \
    431         if ( TRACE_BOOL(level) ) {                                                                                              \
    432                 int __i;                                                                                                        \
    433                 size_t __sz = (size_t)(bufsz);                                                                                  \
    434                 uint8_t * __buf = (uint8_t *)(buf);                                                                             \
    435                 char * __thn = ((char *)pthread_getspecific(fd_log_thname) ?: "unnamed");                                       \
    436                 fd_log_debug("\t | tid:%-20s\t%s\tin %s@%s:%d\n"                                                                \
    437                           "\t%s|%*s" prefix ,                                                                                   \
    438                                         __thn, fd_log_time(NULL, __buf, sizeof(__buf)), __PRETTY_FUNCTION__, __FILE__, __LINE__,\
    439                                         (level < FULL)?"@":" ",level, "");                                                      \
    440                 for (__i = 0; __i < __sz; __i++) {                                                                              \
    441                         fd_log_debug("%02.2hhx", __buf[__i]);                                                                   \
    442                 }                                                                                                               \
    443                 fd_log_debug(suffix "\n");                                                                                      \
    444         }                                                                                                                       \
    445 }
    446 
    447392
    448393
     
    470415       
    471416        if (th_ret != NULL) {
    472                 TRACE_DEBUG(ANNOYING, "The thread returned the following value: %p (ignored)", th_ret);
     417                TRACE_DEBUG(FULL, "The thread returned the following value: %p (ignored)", th_ret);
    473418        }
    474419       
     
    494439        free(buffer);
    495440}
    496 static __inline__ void fd_cleanup_socket(void * sockptr)
    497 {
    498         if (sockptr) {
    499                 shutdown(*(int *)sockptr, SHUT_RDWR);
    500                 *(int *)sockptr = 0;
    501         }
    502 }
    503 
    504441
    505442/*============================================================*/
     
    528465void fd_list_insert_after  ( struct fd_list * ref, struct fd_list * item );
    529466void fd_list_insert_before ( struct fd_list * ref, struct fd_list * item );
    530 
    531 /* Move a list at the end of another */
    532 void fd_list_move_end(struct fd_list * ref, struct fd_list * senti);
    533467
    534468/* Insert an item in an ordered list -- ordering function provided. If duplicate object found, EEXIST and it is returned in ref_duplicate */
     
    24082342
    24092343/*
    2410  * FUNCTION:    fd_fifo_move
    2411  *
    2412  * PARAMETERS:
    2413  *  old         : Location of a FIFO that is to be emptied and deleted.
    2414  *  new         : A FIFO that will receive the old data.
    2415  *  loc_update  : if non NULL, a place to store the pointer to new FIFO atomically with the move.
    2416  *
    2417  * DESCRIPTION:
    2418  *  Delete a queue and move its content to another one atomically.
    2419  *
    2420  * RETURN VALUE:
    2421  *  0           : The queue has been destroyed successfully.
    2422  *  EINVAL      : A parameter is invalid.
    2423  */
    2424 int fd_fifo_move ( struct fifo ** old, struct fifo * new, struct fifo ** loc_update );
    2425 
    2426 /*
    24272344 * FUNCTION:    fd_fifo_length
    24282345 *
Note: See TracChangeset for help on using the changeset viewer.