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
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)
if (dport == 80 || dport == 8080 || dport == 8081 || dport == 3128)
{
- appl = &appl_asave;
+ appl = &appl_http;
save_dir = "flows";
}
f->appl = appl;
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;
{
xfree(p);
}
+
+void pkt_flush_queue(list *l)
+{
+ struct pkt *p;
+ while (p = list_head(l))
+ {
+ list_remove(&p->n);
+ pkt_free(p);
+ }
+}
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;
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;
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(;;)