source: tools/tracereport/tracereport.c @ 2a34193

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 2a34193 was 49ce177, checked in by Perry Lorier <perry@…>, 16 years ago

Added:

  • error reports
  • flow reports
  • per port reports
  • direction report
  • moved everything to use the container library
  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 * This file is part of libtrace
3 *
4 * Copyright (c) 2004 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$
28 *
29 */
30
31//
32// This program takes a series of traces and bpf filters and outputs how many
33// bytes/packets
34
35#include <stdio.h>
36#include <stdlib.h>
37#include <assert.h>
38#include <string.h>
39#include <sys/time.h>
40#include <sys/types.h>
41#include <time.h>
42
43#include <netinet/in.h>
44#include <netinet/in_systm.h>
45#include <netinet/tcp.h>
46#include <netinet/ip.h>
47#include <netinet/ip_icmp.h>
48#include <arpa/inet.h>
49#include <sys/socket.h>
50#include <getopt.h>
51#include <inttypes.h>
52
53#include "libtrace.h"
54#include "tracereport.h"
55#include "report.h"
56
57struct libtrace_t *trace;
58
59/* Process a trace, counting packets that match filter(s) */
60void run_trace(char *uri) 
61{
62        struct libtrace_packet_t packet;
63
64        fprintf(stderr,"%s:\n",uri);
65
66        trace = trace_create(uri);
67
68        for (;;) {
69                int psize;
70                if ((psize = trace_read_packet(trace, &packet)) <1) {
71                        break;
72                }
73
74                error_per_packet(&packet);
75                port_per_packet(&packet);
76                protocol_per_packet(&packet);
77                tos_per_packet(&packet);
78                ttl_per_packet(&packet);
79                flow_per_packet(&packet);
80                dir_per_packet(&packet);
81
82        }
83
84        trace_destroy(trace);
85}
86
87void usage(char *argv0)
88{
89        fprintf(stderr,"Usage: %s [--filter|-f bpf ]... libtraceuri...\n",argv0);
90}
91
92int main(int argc, char *argv[]) {
93
94        int i;
95
96
97        for(i=1;i<argc;++i) {
98                run_trace(argv[i]);
99        }
100
101        error_report();
102        flow_report();
103        tos_report();
104        protocol_report();
105        port_report();
106        ttl_report();
107        dir_report();
108
109
110        return 0;
111}
Note: See TracBrowser for help on using the repository browser.