diff -Naur /tmp/tmp.bnMpe13094/como.snp/src/base/sniffer-libpcap.c /tmp/tmp.thdmt13095/como.snp/src/base/sniffer-libpcap.c --- /tmp/tmp.bnMpe13094/como.snp/src/base/sniffer-libpcap.c 2005-02-11 16:13:14.664428365 +0000 +++ /tmp/tmp.thdmt13095/como.snp/src/base/sniffer-libpcap.c 2005-02-11 16:13:14.745429473 +0000 @@ -201,7 +201,6 @@ bcopy(pkt, &hdr->p, hl); } bcopy(pkt, hdr->payload, pkthdr.caplen); - hdr->payload_len = pkthdr.caplen; return 1; } diff -Naur /tmp/tmp.bnMpe13094/como.snp/src/base/sniffer-pcap.c /tmp/tmp.thdmt13095/como.snp/src/base/sniffer-pcap.c --- /tmp/tmp.bnMpe13094/como.snp/src/base/sniffer-pcap.c 2005-02-11 16:13:14.664428365 +0000 +++ /tmp/tmp.thdmt13095/como.snp/src/base/sniffer-pcap.c 2005-02-11 16:13:14.745429473 +0000 @@ -178,9 +178,10 @@ return npkt; need_more: + printf("sniffer_next done in %d.\n", getpid()); len -= ofs; bcopy(buf+ofs, buf, (uint)len); return npkt; } diff -Naur /tmp/tmp.bnMpe13094/como.snp/src/include/stdpkt.h /tmp/tmp.thdmt13095/como.snp/src/include/stdpkt.h --- /tmp/tmp.bnMpe13094/como.snp/src/include/stdpkt.h 2005-02-11 16:13:14.665428378 +0000 +++ /tmp/tmp.thdmt13095/como.snp/src/include/stdpkt.h 2005-02-11 16:13:14.746429486 +0000 @@ -139,15 +139,14 @@ struct _como_udphdr udph; struct _como_icmphdr icmph; } p; - uint32_t payload_len; - uint8_t payload[1]; + uint8_t payload[0]; }; /* XXX SOS22: If anyone knows how to do this portably, feel free to do it. */ #define ALIGN_UP(x) ( ((x) + __alignof__(long)) & ~(__alignof__(long)-1) ) -#define STDPKT_SIZE(x) ALIGN_UP((sizeof(pkt_t) - 1 + (x)->payload_len)) +#define STDPKT_SIZE(x) ALIGN_UP((sizeof(pkt_t) + (x)->caplen)) #define STDPKT_NEXT(p) (pkt_t *)((unsigned long)(p) + STDPKT_SIZE(p)) /* diff -Naur /tmp/tmp.bnMpe13094/como.snp/src/modules/como.gmk /tmp/tmp.thdmt13095/como.snp/src/modules/como.gmk --- /tmp/tmp.bnMpe13094/como.snp/src/modules/como.gmk 2005-02-11 16:13:14.647428132 +0000 +++ /tmp/tmp.thdmt13095/como.snp/src/modules/como.gmk 2005-02-11 16:13:14.746429486 +0000 @@ -13,7 +13,8 @@ topdest.so \ connx.so \ utilization.so \ - trace.so + trace.so \ + full_cap.so INCDIRS = ../base diff -Naur /tmp/tmp.bnMpe13094/como.snp/src/modules/full_cap.c /tmp/tmp.thdmt13095/como.snp/src/modules/full_cap.c --- /tmp/tmp.bnMpe13094/como.snp/src/modules/full_cap.c 1970-01-01 01:00:00.000000000 +0100 +++ /tmp/tmp.thdmt13095/como.snp/src/modules/full_cap.c 2005-02-11 16:13:14.746429486 +0000 @@ -0,0 +1,82 @@ +/* + * Full capture module + * + * This module captures entire packets and dumps them in pcap format. + * + * Config parameters: + * + * . hashsize 1 + * . blocksize: should match BUFSIZE defined below + 4 + sizeof(rec_t) + */ + +#include +#include +#include +#include "como.h" +#include "module.h" + +#define FLOWDESC struct _capture + +#define BUF_SIZE 65530 +FLOWDESC { + rec_t r; + uint bytes_used; + uint8_t bytes[BUF_SIZE]; +}; + +static int +update(pkt_t *pkt, rec_t *fh, int new_rec) +{ + FLOWDESC *x = F(fh); + struct pcap_pkthdr *phdr; + + if (new_rec) + x->bytes_used = 0; + phdr = (struct pcap_pkthdr *)((unsigned long *)x->bytes + x->bytes_used); + phdr->ts.tv_sec = TS2SEC(pkt->ts); + phdr->ts.tv_usec = TS2USEC(pkt->ts); + phdr->caplen = pkt->caplen; + phdr->len = pkt->len; + bcopy(pkt->payload, phdr + 1, pkt->caplen); + x->bytes_used += sizeof(*phdr) + pkt->caplen; + if (x->bytes_used + sizeof(*phdr) + 1514 >= BUF_SIZE) + return 1; /* The record might overflow next time we try to use + * it. */ + else + return 0; +} + +static ssize_t +store(rec_t *fh, char *buf, size_t len) +{ + const FLOWDESC *x = F(fh); + + assert(len >= BUF_SIZE + 4); + *(size_t *)buf = x->bytes_used + 4; + memcpy(buf + 4, x->bytes, x->bytes_used); + return x->bytes_used + 4; +} + +static size_t +load(char *buf, size_t len __unused, timestamp_t *ts __unused) +{ + size_t s = *(size_t *)buf; + if (s == 0) + return -1; + else + return s; +} + +static char * +print(char *buf) +{ + return buf + 4; +} + +callbacks_t callbacks = { + ca_recordsize: sizeof(FLOWDESC), + update: update, + store: store, + load: load, + print: print +};