source: test/test-decode2.c @ f0c639b

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

Update the copyright information
Fix libpcap issue
Remove all swig/python builds

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 * This file is part of libtrace
3 *
4 * Copyright (c) 2007 The University of Waikato, Hamilton, New Zealand.
5 * Authors: Daniel Lawson
6 *          Perry Lorier
7 *         
8 * All rights reserved.
9 *
10 * This code has been developed by the University of Waikato WAND
11 * research group. For further information please see http://www.wand.net.nz/
12 *
13 * libtrace is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * libtrace is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with libtrace; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 *
27 * $Id: test-rtclient.c,v 1.2 2006/02/27 03:41:12 perry Exp $
28 *
29 */
30#ifndef WIN32
31#  include <sys/time.h>
32#  include <netinet/in.h>
33#  include <netinet/in_systm.h>
34#  include <netinet/tcp.h>
35#  include <netinet/ip.h>
36#  include <netinet/ip_icmp.h>
37#  include <arpa/inet.h>
38#  include <sys/socket.h>
39#endif
40#include <stdio.h>
41#include <stdlib.h>
42#include <assert.h>
43#include <string.h>
44#include <sys/types.h>
45#include <time.h>
46#include <string.h>
47
48#include "dagformat.h"
49#include "libtrace.h"
50#include "libpacketdump.h"
51
52void iferr(libtrace_t *trace)
53{
54        libtrace_err_t err = trace_get_err(trace);
55        if (err.err_num==0)
56                return;
57        printf("Error: %s\n",err.problem);
58        exit(1);
59}
60
61int main(int argc, char *argv[]) {
62        int psize = 0;
63        int error = 0;
64        int count = 0;
65        int level = 0;
66        int ipcnt = 0;
67        int expected = 100;
68        libtrace_t *trace;
69        libtrace_packet_t *packet;
70
71        if (argc<2) {
72                fprintf(stderr,"usage: %s uri\n",argv[0]);
73                return 1;
74        }
75
76        trace = trace_create(argv[1]);
77        iferr(trace);
78
79        if (strcmp(argv[1],"rtclient")==0) expected=101;
80       
81        level=0;
82
83        trace_start(trace);
84        iferr(trace);
85       
86        packet=trace_create_packet();
87        for (;;) {
88                if ((psize = trace_read_packet(trace, packet)) <0) {
89                        error = 1;
90                        iferr(trace);
91                        break;
92                }
93                if (psize == 0) {
94                        error = 0;
95                        break;
96                }
97
98                if ((trace_get_ip(packet)!=NULL)) {
99                        ++ipcnt;
100                }
101                count ++;
102                if (count>100)
103                        break;
104        }
105        trace_destroy_packet(packet);
106        if (ipcnt==0) {
107                error=1;
108                printf("No IP packets found!\n");
109        }
110        trace_destroy(trace);
111        return error;
112}
Note: See TracBrowser for help on using the repository browser.