From: Maxim Mamontov Date: Sun, 11 Nov 2012 19:08:48 +0000 (+0200) Subject: Better logging for ipq_cap. X-Git-Tag: 2.409~402 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/f33655defbdef7570c05d258ba8b117a58de0487?hp=67d75b405747515c015c5667f9e89e53b2c51aa4 Better logging for ipq_cap. --- diff --git a/projects/stargazer/plugins/capture/ipq_linux/ipq_cap.cpp b/projects/stargazer/plugins/capture/ipq_linux/ipq_cap.cpp index 2dcded07..9818378a 100644 --- a/projects/stargazer/plugins/capture/ipq_linux/ipq_cap.cpp +++ b/projects/stargazer/plugins/capture/ipq_linux/ipq_cap.cpp @@ -23,6 +23,7 @@ #include #include +#include #include "stg/raw_ip_packet.h" #include "stg/traffcounter.h" @@ -160,7 +161,7 @@ ipq_h = ipq_create_handle(0, PF_INET); if (ipq_h == NULL) { ipq_destroy_handle(ipq_h); - logger("Cannot create IPQ handle."); + logger("Cannot create IPQ handle. Error: '%s', '%s'", ipq_errstr(), strerror(errno)); errorStr = "Cannot create ipq handle!"; return -1; } diff --git a/projects/stargazer/plugins/capture/ipq_linux/libipq.c b/projects/stargazer/plugins/capture/ipq_linux/libipq.c index 798faebb..a7ed5745 100644 --- a/projects/stargazer/plugins/capture/ipq_linux/libipq.c +++ b/projects/stargazer/plugins/capture/ipq_linux/libipq.c @@ -61,7 +61,7 @@ enum }; #define IPQ_MAXERR IPQ_ERR_PROTOCOL -/*struct ipq_errmap_t +struct ipq_errmap_t { int errcode; char *message; @@ -83,7 +83,7 @@ enum { IPQ_ERR_RECVBUF, "Receive buffer size invalid"}, { IPQ_ERR_TIMEOUT, "Timeout"}, { IPQ_ERR_PROTOCOL, "Invalid protocol specified"} -};*/ +}; static int ipq_errno = IPQ_ERR_NONE; @@ -205,12 +205,12 @@ static ssize_t ipq_netlink_recvfrom(const struct ipq_handle *h, return status; } //----------------------------------------------------------------------------- -/*static char *ipq_strerror(int errcode) +static char *ipq_strerror(int errcode) { if (errcode < 0 || errcode > IPQ_MAXERR) errcode = IPQ_ERR_IMPL; return ipq_errmap[errcode].message; -}*/ +} /**************************************************************************** * @@ -386,10 +386,10 @@ int ipq_ctl(const struct ipq_handle __attribute__((unused)) * handle, int __attr return 1; } //----------------------------------------------------------------------------- -/*char *ipq_errstr(void) +char *ipq_errstr(void) { return ipq_strerror(ipq_errno); -}*/ +} //----------------------------------------------------------------------------- /*void ipq_perror(const char *s) { diff --git a/projects/stargazer/plugins/capture/ipq_linux/libipq.h b/projects/stargazer/plugins/capture/ipq_linux/libipq.h index 5f06057a..c55a4e52 100644 --- a/projects/stargazer/plugins/capture/ipq_linux/libipq.h +++ b/projects/stargazer/plugins/capture/ipq_linux/libipq.h @@ -35,10 +35,7 @@ #include "ip_queue_64.h" typedef u_int64_t ipq_id_t; #else -#ifdef HAS_IP_QUEUE_H #include -#else -#include "ip_queue.h" #endif typedef unsigned long ipq_id_t; #endif @@ -86,8 +83,8 @@ int ipq_set_verdict(const struct ipq_handle *h, int ipq_ctl(const struct ipq_handle *h, int request, ...); -/*char *ipq_errstr(void); -void ipq_perror(const char *s);*/ +char *ipq_errstr(void); +//void ipq_perror(const char *s); #endif /* _LIBIPQ_H */