source: examples/tracedump/tracedump-libtrace.cc @ 3fe7937

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 3fe7937 was 3fe7937, checked in by Daniel Lawson <dlawson@…>, 16 years ago

check for fragmented packet- if so, don't return TCP header

  • Property mode set to 100644
File size: 734 bytes
Line 
1#include <libtrace.h>
2#include <err.h>
3#include <time.h>
4#include "tracedump.h"
5#include <stdio.h>
6
7int main(int argc,char **argv)
8{
9        struct libtrace_t *trace = trace_create(argv[1]);
10        struct libtrace_packet_t packet;
11        struct libtrace_filter_t *filter=NULL;
12       
13        if (!trace) {
14                errx(1,"Failed to open trace");
15        }
16
17        if (argc>2)
18                filter=trace_bpf_setfilter(argv[2]);
19
20        while(trace_read_packet(trace,&packet)> 0 ){
21                time_t sec = (time_t)trace_get_seconds(&packet);
22                char *link=(char *)trace_get_link(&packet);
23                if (filter && !trace_bpf_filter(filter,&packet))
24                        continue;
25
26                printf("%s",ctime(&sec));
27                per_packet(trace_get_link_type(&packet),
28                                link,
29                                packet.size-(link-packet.buffer));
30        }
31
32        trace_destroy(trace);
33        return 0;
34}
Note: See TracBrowser for help on using the repository browser.