source: examples/protocol/protocol.c @ 52e95c7

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

modified the protocol sample

  • Property mode set to 100644
File size: 953 bytes
Line 
1// $Id$
2
3#include <stdio.h> /* printf */
4#include <netinet/in.h> /* ntohs */
5#include <netdb.h>
6#include "dagformat.h"
7
8#include "libtrace.h"
9
10struct libtrace_t *trace;
11
12char *buffer[4096];
13
14int main(int argc, char *argv[]) {
15
16        char *hostname = "rtclient:chasm.cs.waikato.ac.nz";
17        struct libtrace_ip *ipptr = 0;
18       
19        int status; // need to pass to rtclient_read_packet
20        int psize;
21        if (argc == 2) {
22                hostname = argv[1];
23        }
24
25        // create an rtclient to hostname, on the default port
26        trace = create_trace(hostname);
27
28        for (;;) {
29                if ((psize = libtrace_read_packet(trace, buffer,4096, &status)) <= 0) {
30                        // terminate
31                        break;
32                }
33                ipptr = get_ip(trace,buffer,4096);
34                if (ipptr) {
35                        printf("%d:%d\n",ipptr->ip_p,get_link_type(trace,buffer,4096));
36                }
37        }
38        destroy_trace(trace);
39        return 0;
40}
Note: See TracBrowser for help on using the repository browser.