source: examples/skeleton/trivial.c @ bad6a93

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since bad6a93 was bad6a93, checked in by Shane Alcock <salcock@…>, 14 years ago

trace_get_vlan_payload_from_ethernet is now available to libtrace users.
Fixed error where erf wire length was having padding subtracted from it - wire length doesn't include padding.
erf can also attach padding to the end of packets - get_capture_length now returns the minimum of the record length - padding and the wire length.
Added support for RT_LOSTCONN - also other zero sized rt packets shouldn't cause TRACE_EVENT_TERMINATE anymore
rt header information is no longer stored statically when doing a non-blocking read
The packet->buffer for rt packets is now regarded as external, so now trace_destroy_packet shouldn't cause a segfault

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/* Trivial libtrace skeleton program
2 *
3 * This libtrace skeleton has the bare minimum required to write a useful
4 * libtrace program, including error handling.
5 *
6 * If you are going to base your program on anything, you should look at the
7 * complete.c and use that.
8 *
9 */
10#include "libtrace.h"
11#include <stdio.h>
12#include <assert.h>
13
14void per_packet(libtrace_packet_t *packet)
15{
16        /* You really should consider using complete.c instead */
17
18        /* Your code goes here */
19}
20
21int main(int argc, char *argv[])
22{
23        libtrace_t *trace;
24        libtrace_packet_t *packet;
25
26        if (argc<2) {
27                fprintf(stderr,"usage: %s libtraceuri\n",argv[0]);
28                return 1;
29        }
30
31        trace = trace_create(argv[1]);
32
33        if (trace_is_err(trace)) {
34                trace_perror(trace,"Opening trace file");
35                return 1;
36        }
37
38        if (trace_start(trace)) {
39                trace_perror(trace,"Starting trace");
40                trace_destroy(trace);
41                return 1;
42        }
43
44        packet = trace_create_packet();
45
46        while (trace_read_packet(trace,packet)>0) {
47                per_packet(packet);
48        }
49
50        trace_destroy_packet(packet);
51
52        if (trace_is_err(trace)) {
53                trace_perror(trace,"Reading packets");
54                trace_destroy(trace);
55                return 1;
56        }
57
58        trace_destroy(trace);
59
60        return 0;
61}
Note: See TracBrowser for help on using the repository browser.