Index: src/target_pcap.c =================================================================== --- src/target_pcap.c (revision 127) +++ src/target_pcap.c (working copy) @@ -20,11 +20,12 @@ #include "target_pcap.h" -#define PARAMS_NUM 3 +#define PARAMS_NUM 4 char *target_pcap_params[PARAMS_NUM][3] = { { "filename", "dump.cap", "filename to save packets to. default : dump.cap" }, { "snaplen", "1522", "snaplen of saved packets. default : 1522" }, { "layer", "ethernet", "type of layer to capture. ethernet, linux_cooked, docsis or ipv4. default : ethernet" }, + { "size", "2147483648" , "size of file to save packet. default : 1 073 741 824 Bytes"}, }; struct target_functions *tg_functions; @@ -146,9 +147,25 @@ phdr.caplen = len; else phdr.caplen = SNAPLEN; + + struct stat *sstat; + sstat=malloc(sizeof(struct stat); + fstat((int)priv->pdump,sstat) + if(sstat->st_size>==t->params_value[3]) { + if(target_close_pcap(t)) { + dprint("Unable tu close pcap dumper !\n"); + } + else { + /*add something to move the recently closed file to an other name in the same location*/ + priv->pdump = pcap_dump_open(priv->p, t->params_value[0]); + if (!priv->pdump) { + dprint("Unable to open pcap dumper !\n"); + return 0; + } + } + } pcap_dump((u_char*)priv->pdump, &phdr, f->buff + start); - //pcap_dump_flush(priv->pdump); priv->size += len;