split some parts of the packet counting functions into their own files capture_info...
[metze/wireshark/wip.git] / capture_info.c
1 /* capture_info.c
2  * capture info functions
3  *
4  * $Id$
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@ethereal.com>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #ifdef HAVE_LIBPCAP
30
31 #include <glib.h>
32
33 #include <epan/packet.h>
34 /* XXX - try to remove this later */
35 #include <epan/prefs.h>
36 /* XXX - try to remove this later */
37
38 #include "capture_info.h"
39
40 #include <epan/dissectors/packet-ap1394.h>
41 #include <epan/dissectors/packet-atalk.h>
42 #include <epan/dissectors/packet-atm.h>
43 #include <epan/dissectors/packet-clip.h>
44 #include <epan/dissectors/packet-eth.h>
45 #include <epan/dissectors/packet-fddi.h>
46 #include <epan/dissectors/packet-fr.h>
47 #include <epan/dissectors/packet-null.h>
48 #include <epan/dissectors/packet-ppp.h>
49 #include <epan/dissectors/packet-raw.h>
50 #include <epan/dissectors/packet-sll.h>
51 #include <epan/dissectors/packet-tr.h>
52 #include <epan/dissectors/packet-ieee80211.h>
53 #include <epan/dissectors/packet-chdlc.h>
54 #include <epan/dissectors/packet-prism.h>
55 #include <epan/dissectors/packet-ipfc.h>
56 #include <epan/dissectors/packet-arcnet.h>
57
58
59 void
60 capture_info_init(packet_counts *counts)
61 {
62   counts->total       = 0;
63   counts->sctp        = 0;
64   counts->tcp         = 0;
65   counts->udp         = 0;
66   counts->icmp        = 0;
67   counts->ospf        = 0;
68   counts->gre         = 0;
69   counts->ipx         = 0;
70   counts->netbios     = 0;
71   counts->vines       = 0;
72   counts->other       = 0;
73   counts->arp         = 0;
74 }
75
76
77 void
78 capture_info_packet(packet_counts *counts, gint wtap_linktype, const u_char *pd, guint32 caplen, union wtap_pseudo_header pseudo_header)
79 {
80   counts->total++;
81   switch (wtap_linktype) {
82     case WTAP_ENCAP_ETHERNET:
83       capture_eth(pd, 0, caplen, counts);
84       break;
85     case WTAP_ENCAP_FDDI:
86     case WTAP_ENCAP_FDDI_BITSWAPPED:
87       capture_fddi(pd, caplen, counts);
88       break;
89     case WTAP_ENCAP_PRISM_HEADER:
90       capture_prism(pd, 0, caplen, counts);
91       break;
92     case WTAP_ENCAP_TOKEN_RING:
93       capture_tr(pd, 0, caplen, counts);
94       break;
95     case WTAP_ENCAP_NULL:
96       capture_null(pd, caplen, counts);
97       break;
98     case WTAP_ENCAP_PPP:
99       capture_ppp_hdlc(pd, 0, caplen, counts);
100       break;
101     case WTAP_ENCAP_RAW_IP:
102       capture_raw(pd, caplen, counts);
103       break;
104     case WTAP_ENCAP_SLL:
105       capture_sll(pd, caplen, counts);
106       break;
107     case WTAP_ENCAP_LINUX_ATM_CLIP:
108       capture_clip(pd, caplen, counts);
109       break;
110     case WTAP_ENCAP_IEEE_802_11:
111     case WTAP_ENCAP_IEEE_802_11_WITH_RADIO:
112       capture_ieee80211(pd, 0, caplen, counts);
113       break;
114     case WTAP_ENCAP_CHDLC:
115       capture_chdlc(pd, 0, caplen, counts);
116       break;
117     case WTAP_ENCAP_LOCALTALK:
118       capture_llap(counts);
119       break;
120     case WTAP_ENCAP_ATM_PDUS:
121       capture_atm(&pseudo_header, pd, caplen, counts);
122       break;
123     case WTAP_ENCAP_IP_OVER_FC:
124       capture_ipfc(pd, caplen, counts);
125       break;
126     case WTAP_ENCAP_ARCNET:
127       capture_arcnet(pd, caplen, counts, FALSE, TRUE);
128       break;
129     case WTAP_ENCAP_ARCNET_LINUX:
130       capture_arcnet(pd, caplen, counts, TRUE, FALSE);
131       break;
132     case WTAP_ENCAP_APPLE_IP_OVER_IEEE1394:
133       capture_ap1394(pd, 0, caplen, counts);
134       break;
135     case WTAP_ENCAP_FRELAY:
136     case WTAP_ENCAP_FRELAY_WITH_PHDR:
137       capture_fr(pd, 0, caplen, counts);
138       break;
139     /* XXX - some ATM drivers on FreeBSD might prepend a 4-byte ATM
140        pseudo-header to DLT_ATM_RFC1483, with LLC header following;
141        we might have to implement that at some point. */
142   }
143 }
144
145
146 #endif /* HAVE_LIBPCAP */