source: examples/tracedump/tracedump-libtrace.cc @ 5d6ebe1

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 5d6ebe1 was 5d6ebe1, checked in by Perry Lorier <perry@…>, 17 years ago

Added asn1 parsing
Started fixing bug with tcp option parsing

  • Property mode set to 100644
File size: 735 bytes
RevLine 
[d907ff5]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;
[5d6ebe1]11        struct libtrace_filter_t *filter=NULL;
12       
[d907ff5]13        if (!trace) {
14                errx(1,"Failed to open trace");
15        }
16
[5d6ebe1]17        if (argc>2)
18                filter=trace_bpf_setfilter(argv[2]);
19
[d907ff5]20        while(trace_read_packet(trace,&packet)!=-1) {
21                time_t sec = (time_t)trace_get_seconds(&packet);
22                char *link=(char *)trace_get_link(&packet);
[5d6ebe1]23                if (filter && !trace_bpf_filter(filter,&packet))
24                        continue;
25
[d907ff5]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.