29#define ERR_BUF_LEN 256
43 __attribute__((format(printf, 2, 3)));
48#ifndef PCP_MAX_LOG_LEVEL
50#define PCP_MAX_LOG_LEVEL PCP_LOGLVL_DEBUG
53#define PCP_LOG(level, fmt, ...) { if (level<=PCP_MAX_LOG_LEVEL) \
54pcp_logger(level, "FILE: %s:%d; Func: %s:\n " fmt,\
55__FILE__, __LINE__, __FUNCTION__, __VA_ARGS__); }
57#define PCP_LOG_END(level) { if (level<=PCP_MAX_LOG_LEVEL) \
58pcp_logger(level, "FILE: %s:%d; Func: %s: END \n " ,\
59__FILE__, __LINE__, __FUNCTION__); }
61#define PCP_LOG_BEGIN(level) { if (level<=PCP_MAX_LOG_LEVEL) \
62pcp_logger(level, "FILE: %s:%d; Func: %s: BEGIN \n ",\
63__FILE__, __LINE__, __FUNCTION__); }
66#ifndef PCP_MAX_LOG_LEVEL
68#define PCP_MAX_LOG_LEVEL PCP_LOGLVL_INFO
71#define PCP_LOG(level, fmt, ...)
73#define PCP_LOG_END(level)
75#define PCP_LOG_BEGIN(level)
78#if PCP_MAX_LOG_LEVEL>=PCP_LOGLVL_DEBUG
79#define PCP_LOG_DEBUG(fmt, ...) PCP_LOG(PCP_LOGLVL_DEBUG, fmt, __VA_ARGS__)
81#define PCP_LOG_DEBUG(fmt, ...)
84#if PCP_MAX_LOG_LEVEL>=PCP_LOGLVL_INFO
85#define PCP_LOG_FLOW(f, msg) \
87 if (pcp_log_level >= PCP_LOGLVL_INFO) { \
88 char src_buf[INET6_ADDRSTRLEN]="Unknown"; \
89 char dst_buf[INET6_ADDRSTRLEN]="Unknown"; \
90 char pcp_buf[INET6_ADDRSTRLEN]="Unknown"; \
92 inet_ntop(AF_INET6, &f->kd.src_ip, src_buf, sizeof(src_buf)); \
93 inet_ntop(AF_INET6, &f->kd.map_peer.dst_ip, dst_buf, \
95 inet_ntop(AF_INET6, &f->kd.pcp_server_ip, pcp_buf, sizeof(pcp_buf)); \
96 PCP_LOG(PCP_LOGLVL_INFO, \
97 "%s(PCP server: %s; Int. addr: [%s]:%d; Dest. addr: [%s]:%d; Key bucket: %d)", \
98 msg, pcp_buf, src_buf, ntohs(f->kd.map_peer.src_port), dst_buf, ntohs(f->kd.map_peer.dst_port), f->key_bucket); \
102#define PCP_LOG_FLOW(f, msg) do{} while(0)
void pcp_strerror(int errnum, char *buf, size_t buflen)
void pcp_logger_init(void)
void pcp_logger(pcp_loglvl_e log_level, const char *fmt,...) __attribute__((format(printf