First batch of fixes for new debug and logging API usage.

remotes/origin/master-1.0.x
Victor Julien 16 years ago
parent 8069fc759b
commit f4acd5a27e

@ -17,8 +17,6 @@
#include "alert-unified2-alert.h"
#include "decode-ipv4.h"
#define DEBUG
/*prototypes*/
int Unified2Alert (ThreadVars *, Packet *, void *, PacketQueue *);
int Unified2AlertThreadInit(ThreadVars *, void *, void **);

@ -1042,7 +1042,7 @@ int PerfOutputCounterFileIface()
fprintf(perf_op_ctx->fp, "%-25s | %-25s | %-" PRIu64 "\n",
pc->name->cname, pc->name->tm_name, *ui64_cvalue);
#ifdef DEBUG
printf("%-10" PRIuMAX " %-10" PRIu16 " %-10s %-" PRIu64 "\n", pc->name->tid, pc->id,
printf("%-10" PRIuMAX " %-10" PRIu16 " %-10s %-" PRIu64 "\n", (uintmax_t)pc->name->tid, pc->id,
pc->name->cname, *ui64_cvalue);
#endif
pc = pc->next;

@ -6,6 +6,7 @@
#include "decode-events.h"
#include "util-unittest.h"
#include "util-debug.h"
void DecodeEthernet(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint16_t len, PacketQueue *pq)
{
@ -20,9 +21,7 @@ void DecodeEthernet(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *p
if (ethh == NULL)
return;
#ifdef DEBUG
printf("DecodeEthernet: p %p pkt %p ether type %04x\n", p, pkt, ntohs(ethh->eth_type));
#endif
SCDebug("p %p pkt %p ether type %04x", p, pkt, ntohs(ethh->eth_type));
if (ntohs(ethh->eth_type) == ETHERNET_TYPE_IP) {
//printf("DecodeEthernet ip4\n");

@ -408,7 +408,7 @@ void DecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt,
#ifdef DEBUG
if (IPV6_EXTHDR_ISSET_FH(p)) {
printf("IPV6 FRAG - HDRLEN: %" PRIuMAX " NH: %" PRIu32 " OFFSET: %" PRIu32 " ID: %" PRIu32 "\n",
IPV6_EXTHDR_GET_FH_HDRLEN(p), IPV6_EXTHDR_GET_FH_NH(p),
(uintmax_t)IPV6_EXTHDR_GET_FH_HDRLEN(p), IPV6_EXTHDR_GET_FH_NH(p),
IPV6_EXTHDR_GET_FH_OFFSET(p), IPV6_EXTHDR_GET_FH_ID(p));
}
if (IPV6_EXTHDR_ISSET_RH(p)) {

@ -4,6 +4,7 @@
#include "eidps-common.h"
#include "decode.h"
#include "util-debug.h"
void DecodeTunnel(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint16_t len, PacketQueue *pq)
{
@ -16,7 +17,7 @@ void DecodeTunnel(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt
case IPPROTO_IPV6:
return DecodeIPV6(tv, dtv, p, pkt, len, pq);
default:
printf("FIXME: DecodeTunnel: protocol %" PRIu32 " not supported.\n", p->tunnel_proto);
SCInfo("FIXME: DecodeTunnel: protocol %" PRIu32 " not supported.", p->tunnel_proto);
break;
}
}

@ -71,6 +71,9 @@
#include "runmodes.h"
#include "util-debug.h"
#include "util-debug.h"
#include "util-error.h"
/*
* we put this here, because we only use it here in main.
*/
@ -249,6 +252,9 @@ int main(int argc, char **argv)
char *conf_filename = NULL;
int dump_config = 0;
/* initialize the logging subsys */
SCLogInitLogModule(NULL);
/* Initialize the configuration module. */
ConfInit();

@ -9,7 +9,6 @@
*/
#include "eidps-common.h"
#include "debug.h"
#include "decode.h"
#include "threads.h"
#include "tm-modules.h"
@ -26,6 +25,8 @@
#include "flow-private.h"
#include "util-unittest.h"
#include "util-debug.h"
//#define FLOW_DEFAULT_HASHSIZE 262144
#define FLOW_DEFAULT_HASHSIZE 65536
//#define FLOW_DEFAULT_MEMCAP 128 * 1024 * 1024 /* 128 MB */
@ -170,8 +171,8 @@ static int FlowPrune (FlowQueue *q, struct timeval *ts)
}
}
DEBUGPRINT("got lock, now check: %" PRId64 "+%" PRIu32 "=(%" PRId64 ") < %" PRId64 "", f->lastts.tv_sec,
timeout, f->lastts.tv_sec + timeout, ts->tv_sec);
SCDebug("got lock, now check: %" PRIdMAX "+%" PRIu32 "=(%" PRIdMAX ") < %" PRIdMAX "", (intmax_t)f->lastts.tv_sec,
timeout, (intmax_t)f->lastts.tv_sec + timeout, (intmax_t)ts->tv_sec);
/* do the timeout check */
if ((f->lastts.tv_sec + timeout) >= ts->tv_sec) {
@ -183,15 +184,12 @@ static int FlowPrune (FlowQueue *q, struct timeval *ts)
/** never prune a flow that is used by a packet or stream msg
* we are currently processing in one of the threads */
if (f->use_cnt > 0) {
printf("FlowPrune: timed out but use_cnt > 0: %"PRIu16", %p, proto %"PRIu8"\n", f->use_cnt, f, f->proto);
SCDebug("timed out but use_cnt > 0: %"PRIu16", %p, proto %"PRIu8"", f->use_cnt, f, f->proto);
mutex_unlock(&f->fb->m);
mutex_unlock(&f->m);
return 0;
}
//printf("timed out %" PRIuMAX "+%" PRIu32 "=(%" PRIuMAX ") < %" PRIuMAX ": %p, proto %"PRIu8"\n", (uintmax_t)f->lastts.tv_sec,
// timeout, (uintmax_t)(f->lastts.tv_sec + timeout), (uintmax_t)ts->tv_sec, f, f->proto);
/* remove from the hash */
if (f->hprev)
f->hprev->hnext = f->hnext;
@ -515,7 +513,7 @@ void *FlowManagerThread(void *td)
/* Get the time */
memset(&ts, 0, sizeof(ts));
TimeGet(&ts);
DEBUGPRINT("ts %" PRId64 "", ts.tv_sec);
SCDebug("ts %" PRIdMAX "", (intmax_t)ts.tv_sec);
/* see if we still have enough spare flows */
FlowUpdateSpareFlows();
@ -525,21 +523,21 @@ void *FlowManagerThread(void *td)
/* prune closing list */
nowcnt = FlowPruneFlows(&flow_close_q[i], &ts);
if (nowcnt) {
DEBUGPRINT("Pruned %" PRIu32 " closing flows...\n", nowcnt);
SCDebug("Pruned %" PRIu32 " closing flows...", nowcnt);
closing_cnt += nowcnt;
}
/* prune new list */
nowcnt = FlowPruneFlows(&flow_new_q[i], &ts);
if (nowcnt) {
DEBUGPRINT("Pruned %" PRIu32 " new flows...\n", nowcnt);
SCDebug("Pruned %" PRIu32 " new flows...", nowcnt);
new_cnt += nowcnt;
}
/* prune established list */
nowcnt = FlowPruneFlows(&flow_est_q[i], &ts);
if (nowcnt) {
DEBUGPRINT("Pruned %" PRIu32 " established flows...\n", nowcnt);
SCDebug("Pruned %" PRIu32 " established flows...", nowcnt);
established_cnt += nowcnt;
}
}

@ -146,6 +146,7 @@ static inline void SCLogPrintToStream(FILE *fd, char *msg)
if (fprintf(fd, "%s", msg) < 0)
printf("Error writing to stream using fprintf\n");
fflush(fd);
return;
}

@ -3,8 +3,7 @@
#include "eidps-common.h"
#include "detect.h"
#include "threads.h"
//#define DEBUG
#include "util-debug.h"
static struct timeval current_time = { 0,0 };
static pthread_mutex_t current_time_mutex = PTHREAD_MUTEX_INITIALIZER;
@ -12,10 +11,12 @@ static char live = TRUE;
void TimeModeSetLive(void) {
live = TRUE;
SCDebug("live time mode enabled");
}
void TimeModeSetOffline (void) {
live = FALSE;
SCDebug("offline time mode enabled");
}
void TimeSet(struct timeval *tv) {
@ -29,10 +30,8 @@ void TimeSet(struct timeval *tv) {
current_time.tv_sec = tv->tv_sec;
current_time.tv_usec = tv->tv_usec;
#ifdef DEBUG
printf("TimeSet: time set to %" PRIuMAX " sec, %" PRIuMAX " usec\n",
SCDebug("time set to %" PRIuMAX " sec, %" PRIuMAX " usec",
(uintmax_t)current_time.tv_sec, (uintmax_t)current_time.tv_usec);
#endif
mutex_unlock(&current_time_mutex);
}
@ -50,9 +49,7 @@ void TimeGet(struct timeval *tv) {
mutex_unlock(&current_time_mutex);
}
#ifdef DEBUG
printf("TimeGet: time we got is %" PRIuMAX " sec, %" PRIuMAX " usec\n",
SCDebug("time we got is %" PRIuMAX " sec, %" PRIuMAX " usec",
(uintmax_t)tv->tv_sec, (uintmax_t)tv->tv_usec);
#endif
}

Loading…
Cancel
Save