head 1.3; access; symbols; locks; strict; comment @ * @; 1.3 date 2009.08.07.17.42.40; author wessels; state Exp; branches; next 1.2; 1.2 date 2009.07.16.20.47.33; author wessels; state Exp; branches; next 1.1; 1.1 date 2009.07.16.20.45.17; author wessels; state Exp; branches; next ; desc @@ 1.3 log @pcap_layers_init() now has reassemble flag @ text @#include #include #include #include #include #include #include #include #include #include #include #include #include #include "pcap_layers.h" #include "byteorder.h" const char *progname; struct pcap_pkthdr out_hdr; const u_char *out_data; /* * this will only be called if 'ip' is a complete IPv header */ int my_ip4_handler(const struct ip *ip4, int len, void *userdata) { out_hdr.caplen = len; out_data = (void*) ip4; return 0; } int my_ip6_handler(const struct ip6_hdr *ip6, int len, void *userdata) { out_hdr.caplen = len; out_data = (void*) ip6; return 0; } int main(int argc, char *argv[]) { pcap_t *in = NULL; char errbuf[PCAP_ERRBUF_SIZE + 1]; struct pcap_pkthdr hdr; const u_char *data; pcap_dumper_t *out = NULL; pcap_t *dead; progname = argv[0]; if (argc < 2) { fprintf(stderr, "usage: %s pcapfiles\n", progname); exit(1); } in = pcap_open_offline(argv[1], errbuf); if (NULL == in) { fprintf(stderr, "%s: %s", argv[1], errbuf); exit(1); } dead = pcap_open_dead(DLT_RAW, 65536); if (NULL == dead) { perror("pcap_open_dead"); exit(1); } out = pcap_dump_open(dead, "-"); if (NULL == out) { perror("stdout"); exit(1); } pcap_layers_init(pcap_datalink(in), 0); callback_ipv4 = my_ip4_handler; callback_ipv6 = my_ip6_handler; while ((data = pcap_next(in, &hdr))) { out_hdr.ts = hdr.ts; out_hdr.len = hdr.len; out_hdr.caplen = 0; out_data = NULL; handle_pcap(NULL, &hdr, data); if (out_data && out_hdr.caplen) pcap_dump((void *)out, &out_hdr, out_data); } pcap_close(in); pcap_dump_close(out); exit(0); } @ 1.2 log @fix @ text @d73 1 a73 1 pcap_layers_init(pcap_datalink(in)); @ 1.1 log @Initial revision @ text @d21 1 d30 1 d38 1 d80 1 d82 1 a82 1 if (out_hdr.caplen) @