#ifndef _LDP_TRACE_H_ #define _LDP_TRACE_H_ #include #include "ldp_struct.h" extern uint32_t _trace_flags; extern uint8_t trace_buffer[16834]; extern int trace_buffer_len; #define LDP_TRACE_OUT(handle,args...) { \ if(trace_buffer_len == 0) { \ trace_buffer_len += sprintf(trace_buffer,"OUT: " ## args);\ } else { \ trace_buffer_len += sprintf(trace_buffer+trace_buffer_len,args);\ } \ if(trace_buffer[strlen(trace_buffer)-1] == '\n') { \ fprintf(stderr,"%s",trace_buffer); \ trace_buffer_len = 0; \ } \ } #define LDP_TRACE_LOG(handle,class,type,args...) { \ if(type & _trace_flags) { \ LDP_TRACE_OUT(handle,args); \ } \ } #define LDP_TRACE_PKT(handle,class,type,header,body) { \ if(type & _trace_flags) { \ header; \ body; \ } \ } #define LDP_DUMP_PKT(handle,class,type,func) { \ if(type & _trace_flags) { \ func; \ } \ } #define LDP_PRINT(data,args...) { \ if(data); \ fprintf(stderr, "PRT: " ## args); \ } #if 0 #define LDP_ENTER(data,args...) { \ if(data); \ fprintf(stderr, "ENTER: " ## args ## "\n"); \ } #define LDP_EXIT(data,args...) { \ if(data); \ fprintf(stderr, "EXIT: " ## args ## "\n"); \ } #else #define LDP_ENTER(data,args...) #define LDP_EXIT(data,args...) #endif #endif