Changeset 950:51c15f98a965 in freeDiameter
- Timestamp:
- Feb 21, 2013, 7:57:32 PM (11 years ago)
- 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
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
include/freeDiameter/libfdproto.h
r924 r950 110 110 111 111 /* 112 * FUNCTION: fd_log _debug_fstr112 * FUNCTION: fd_log 113 113 * MACRO: fd_log_debug 114 114 * 115 115 * PARAMETERS: 116 * fstr : Stream where the text will be sent (default: stdout)116 * loglevel : Integer, how important the message is 117 117 * format : Same format string as in the printf function 118 118 * ... : Same list as printf 119 119 * 120 120 * DESCRIPTION: 121 * Log internal information for use of developpers only.121 * Write information to log. 122 122 * 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. 124 124 * 125 125 * RETURN VALUE: 126 126 * None. 127 127 */ 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) 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 *, ... ); 130 131 131 132 /* these are internal objects of the debug facility, … … 174 175 * 175 176 * PARAMETERS: 176 * fstr : Stream where the text will be sent to (default: stdout)177 * loglevel : priority of the message 177 178 * format : Same format string as in the printf function 178 179 * va_list : Argument list … … 184 185 * int : Success or failure 185 186 */ 186 int fd_log_handler_register ( void (*logger)( const char * format, va_list *args) );187 int fd_log_handler_register ( void (*logger)(int loglevel, const char * format, va_list args) ); 187 188 188 189 /* … … 209 210 #endif /* ASSERT */ 210 211 211 /* levels definitions */ 212 /* log levels definitions */ 213 #define FD_LOG_DEBUG 0 214 #define FD_LOG_ERROR 5 215 216 /* print level definitions */ 212 217 #define NONE 0 /* Display no debug message */ 213 218 #define INFO 1 /* Display errors only */ … … 255 260 256 261 262 #define STD_TRACE_FMT_STRING "thread %s in %s@%s:%d: " 257 263 /************* 258 264 The general debug macro, each call results in two lines of debug messages (change the macro for more compact output) … … 262 268 #define TRACE_DEBUG(level,format,args... ) { \ 263 269 if ( TRACE_BOOL(level) ) { \ 264 char __buf[25]; \265 270 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); \ 270 273 } \ 271 274 } … … 275 278 if ( TRACE_BOOL(level) ) { \ 276 279 if (fd_g_debug_lvl > FULL) { \ 277 char __buf[25]; \278 280 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); \ 283 283 } else { \ 284 fd_log _debug(format "\n", ## args);\284 fd_log(level, format, ## args); \ 285 285 } \ 286 286 } \ … … 316 316 #define TRACE_DEBUG_BUFFER(level, prefix, buf, bufsz, suffix ) { \ 317 317 if ( TRACE_BOOL(level) ) { \ 318 char __ts[25]; \319 318 int __i; \ 320 319 size_t __sz = (size_t)(bufsz); \ 321 320 uint8_t * __buf = (uint8_t *)(buf); \ 322 321 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__); \ 327 324 for (__i = 0; __i < __sz; __i++) { \ 328 fd_log _debug("%02.2hhx", __buf[__i]);\325 fd_log(level, "%02.2hhx", __buf[__i]); \ 329 326 } \ 330 fd_log _debug(suffix "\n");\327 fd_log(level, suffix); \ 331 328 } \ 332 329 } … … 345 342 346 343 /* Dump one sockaddr Node information */ 347 #define sSA_DUMP_NODE( sa, flag ) {\344 #define sSA_DUMP_NODE( buf, bufsize, sa, flag ) { \ 348 345 sSA * __sa = (sSA *)(sa); \ 349 346 char __addrbuf[INET6_ADDRSTRLEN]; \ … … 357 354 flag); \ 358 355 if (__rc) \ 359 fd_log_debug("%s", (char *)gai_strerror(__rc)); \356 snprintf(buf, bufsize, "%s", gai_strerror(__rc)); \ 360 357 else \ 361 fd_log_debug("%s", &__addrbuf[0]);\358 snprintf(buf, bufsize, "%s", &__addrbuf[0]); \ 362 359 } else { \ 363 fd_log_debug("(NULL / ANY)");\360 snprintf(buf, bufsize, "(NULL / ANY)"); \ 364 361 } \ 365 362 } 366 363 /* 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 ) { \ 368 365 sSA * __sa = (sSA *)(sa); \ 369 366 char __addrbuf[INET6_ADDRSTRLEN]; \ … … 378 375 flag); \ 379 376 if (__rc) \ 380 fd_log_debug("%s", (char *)gai_strerror(__rc));\377 snprintf(buf, bufsize, "%s", gai_strerror(__rc)); \ 381 378 else \ 382 fd_log_debug("[%s]:%s", &__addrbuf[0],&__servbuf[0]);\379 snprintf(buf, bufsize, "[%s]:%s", &__addrbuf[0],&__servbuf[0]); \ 383 380 } else { \ 384 fd_log_debug("(NULL / ANY)");\381 snprintf(buf, bufsize,"(NULL / ANY)"); \ 385 382 } \ 386 383 } … … 389 386 #define TRACE_DEBUG_sSA(level, prefix, sa, flags, suffix ) { \ 390 387 if ( TRACE_BOOL(level) ) { \ 391 char __buf[25];\388 char buf[1024]; \ 392 389 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); \ 399 393 } \ 400 394 } … … 418 412 #define TRACE_DEBUG_sSA(level, prefix, sa, flags, suffix ) 419 413 #define TRACE_DEBUG_ERROR(format,args... ) { \ 420 fd_log _debug(format "\n", ## args); \414 fd_log(FD_LOG_ERROR, format, ## args); \ 421 415 } 422 416 #endif /* STRIP_DEBUG_CODE */ -
include/freeDiameter/libfdproto.h
r946 r950 1158 1158 }; 1159 1159 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 */ 1165 int fd_dictfct_Address_encode(void * data, union avp_value * avp_value); 1166 int fd_dictfct_Address_interpret(union avp_value * avp_value, void * interpreted); 1167 char * fd_dictfct_Address_dump(union avp_value * avp_value); 1168 1169 /* Display the content of an AVP of type UTF8String in the log file */ 1170 char * fd_dictfct_UTF8String_dump(union avp_value * avp_value); 1171 1172 /* For Time AVPs, map with time_t value directly */ 1173 int fd_dictfct_Time_encode(void * data, union avp_value * avp_value); 1174 int fd_dictfct_Time_interpret(union avp_value * avp_value, void * interpreted); 1175 char * fd_dictfct_Time_dump(union avp_value * avp_value); 1176 1177 1178 1179 /****/ 1160 1180 1161 1181 /*** … … 1188 1208 1189 1209 */ 1190 1210 1191 1211 /* 1192 1212 *************************************************************************** … … 1790 1810 * 1791 1811 * 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. 1795 1815 * ENOMEM : Not enough memory to complete the operation 1796 1816 */ … … 2479 2499 int fd_msg_sess_get(struct dictionary * dict, struct msg * msg, struct session ** session, int * isnew); 2480 2500 2501 /* This one is used by the libfdcore, you should use fd_msg_new_session rather than fd_sess_new, when possible */ 2502 int fd_msg_sess_set(struct msg * msg, struct session * session); 2503 2504 2481 2505 /***************************************/ 2482 2506 /* Manage AVP values */ -
libfdcore/fdd.l
r944 r950 52 52 yylloc->first_column = yylloc->last_column + 1; \ 53 53 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", \ 55 56 yylloc->first_line, yylloc->first_column, \ 56 57 yylloc->last_line, yylloc->last_column, \ … … 145 146 <*>[[:alnum:]]+ | /* This rule is only useful to print a complete token in error messages */ 146 147 /* Unrecognized character */ 147 <*>. { 148 <*>. { 148 149 TRACE_DEBUG_ERROR("Unrecognized text on line %d col %d: '%s'.\n", yylloc->first_line, yylloc->first_column, yytext); 149 150 return LEX_ERROR; -
libfdcore/fdd.y
r944 r950 328 328 if (fd == NULL) { 329 329 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)); 331 331 yyerror (&yylloc, conf, "Error adding extension"); 332 332 YYERROR; … … 502 502 if (fd == NULL) { 503 503 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)); 505 505 yyerror (&yylloc, conf, "Error on file name"); 506 506 YYERROR; … … 510 510 if (fd == NULL) { 511 511 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)); 513 513 yyerror (&yylloc, conf, "Error on file name"); 514 514 YYERROR; … … 533 533 if (fd == NULL) { 534 534 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)); 536 536 yyerror (&yylloc, conf, "Error on file name"); 537 537 YYERROR; … … 573 573 if (fd == NULL) { 574 574 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)); 576 576 yyerror (&yylloc, conf, "Error on file name"); 577 577 YYERROR; … … 616 616 &err_pos), 617 617 { 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); 619 619 YYERROR; } ); 620 620 } … … 633 633 if (fd == NULL) { 634 634 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)); 636 636 yyerror (&yylloc, conf, "Error on file name"); 637 637 YYERROR; -
libfdcore/peers.c
r917 r950 91 91 92 92 /* Add a new peer entry */ 93 int fd_peer_add ( struct peer_info * info, c har * orig_dbg, void (*cb)(struct peer_info *, void *), void * cb_data )93 int fd_peer_add ( struct peer_info * info, const char * orig_dbg, void (*cb)(struct peer_info *, void *), void * cb_data ) 94 94 { 95 95 struct fd_peer *p = NULL; -
libfdcore/peers.c
r947 r950 549 549 ev_data->validate = !found; 550 550 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 ); 552 552 553 553 out: -
libfdcore/sctp.c
r921 r950 909 909 } 910 910 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 ); 911 913 fd_log_debug( "SCTP_STATUS : sstat_state : %i\n" , status.sstat_state); 912 914 fd_log_debug( " sstat_rwnd : %u\n" , status.sstat_rwnd); … … 916 918 fd_log_debug( " sstat_outstrms : %hu\n", status.sstat_outstrms); 917 919 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); 921 921 fd_log_debug( " sstat_primary.spinfo_state : %d\n" , status.sstat_primary.spinfo_state); 922 922 fd_log_debug( " sstat_primary.spinfo_cwnd : %u\n" , status.sstat_primary.spinfo_cwnd); -
libfdcore/sctp.c
r946 r950 654 654 if (ep->sa.sa_family == AF_INET6) 655 655 #else /* SCTP_USE_MAPPED_ADDRESSES */ 656 if (target_family == AF_INET6) {656 if (target_family == AF_INET6) 657 657 #endif /* SCTP_USE_MAPPED_ADDRESSES */ 658 658 sz = sizeof(sSA6); … … 1087 1087 /* We will loop while all data is not received. */ 1088 1088 incomplete: 1089 if (datasize == bufsz - sizeof(struct timespec)) {1089 while (datasize + sizeof(struct timespec) >= bufsz ) { 1090 1090 /* The buffer is full, enlarge it */ 1091 1091 bufsz += mempagesz;
Note: See TracChangeset
for help on using the changeset viewer.