From: Martin Mares Date: Sun, 8 Jun 2003 12:31:48 +0000 (+0000) Subject: Added HTTP analyser. X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=017e4c895149f094c3100b6c077fb05b0d67bf38;p=netgrind.git Added HTTP analyser. --- diff --git a/netgrind/Makefile b/netgrind/Makefile index 5f0bd0f..a176ff4 100644 --- a/netgrind/Makefile +++ b/netgrind/Makefile @@ -1,6 +1,6 @@ DIRS+=netgrind PROGS+=obj/netgrind/netgrind -NG_OBJS=netgrind.o pkt.o link.o ip.o tcp.o save.o +NG_OBJS=netgrind.o pkt.o link.o ip.o tcp.o save.o http.o obj/netgrind/netgrind: $(addprefix obj/netgrind/,$(NG_OBJS)) $(LIBSH) obj/netgrind/netgrind: LIBS+=-lpcap diff --git a/netgrind/ip.c b/netgrind/ip.c index 2368ead..b021335 100644 --- a/netgrind/ip.c +++ b/netgrind/ip.c @@ -17,6 +17,7 @@ uns tcpip_calc_checksum(void *data, uns len, uns csum) { + /* FIXME: This is awfully slow and it probably consumes most of our run time */ byte *x = data; while (len >= 2) diff --git a/netgrind/netgrind.c b/netgrind/netgrind.c index e46dd3a..233d293 100644 --- a/netgrind/netgrind.c +++ b/netgrind/netgrind.c @@ -43,7 +43,7 @@ static void mux_open(struct flow *f, u64 when) if (dport == 80 || dport == 8080 || dport == 8081 || dport == 3128) { - appl = &appl_asave; + appl = &appl_http; save_dir = "flows"; } f->appl = appl; diff --git a/netgrind/netgrind.h b/netgrind/netgrind.h index 2f53adf..db766a8 100644 --- a/netgrind/netgrind.h +++ b/netgrind/netgrind.h @@ -93,3 +93,10 @@ extern byte *save_dir; void sink_open(struct flow *f, u64 when); void sink_close(struct flow *f, int cause, u64 when); void sink_input(struct flow *f, int dir, struct pkt *p); + +#define TIMESTAMP_LEN 32 +void format_timestamp(byte *buf, u64 time); + +/* http.c */ + +extern struct appl_hooks appl_http; diff --git a/netgrind/pkt.c b/netgrind/pkt.c index ad0c21c..1e46084 100644 --- a/netgrind/pkt.c +++ b/netgrind/pkt.c @@ -25,3 +25,13 @@ void pkt_free(struct pkt *p) { xfree(p); } + +void pkt_flush_queue(list *l) +{ + struct pkt *p; + while (p = list_head(l)) + { + list_remove(&p->n); + pkt_free(p); + } +} diff --git a/netgrind/pkt.h b/netgrind/pkt.h index 0a6afd5..559836c 100644 --- a/netgrind/pkt.h +++ b/netgrind/pkt.h @@ -62,6 +62,7 @@ static inline byte *pkt_unappend(struct pkt *p, uns len) struct pkt *pkt_new(uns preroom, uns postroom); void pkt_free(struct pkt *pkt); +void pkt_flush_queue(list *l); struct pkt_stats { u64 packets; diff --git a/netgrind/save.c b/netgrind/save.c index 56d496e..4a0be0d 100644 --- a/netgrind/save.c +++ b/netgrind/save.c @@ -19,8 +19,7 @@ byte *save_dir; -#define TIMESTAMP_LEN 32 -static void format_timestamp(byte *buf, u64 time) +void format_timestamp(byte *buf, u64 time) { struct tm *tm; time_t t = time / 1000000; diff --git a/netgrind/tcp.c b/netgrind/tcp.c index e78cb64..b90838d 100644 --- a/netgrind/tcp.c +++ b/netgrind/tcp.c @@ -160,14 +160,7 @@ static void tcp_time_step(uns now, uns doomsday) f->appl->close(f, cause, now_to_timestamp(now)); } for (uns i=0; i<2; i++) - { - struct pkt *p; - while (p = list_head(&f->pipe[i].queue)) - { - list_remove(&p->n); - pkt_free(p); - } - } + pkt_flush_queue(&f->pipe[i].queue); uns h = flow_calc_hash(f->saddr, f->daddr, f->sport, f->dport); struct flow **gg = &flow_hash[h]; for(;;)