35cb42a21b3fb3d68a774ade7cc94e7c5cda6e40
[darkstat-debian] / decode.h
1 /* darkstat 3
2 * copyright (c) 2001-2011 Emil Mikulic.
3 *
4 * decode.h: packet decoding.
5 *
6 * You may use, modify and redistribute this file under the terms of the
7 * GNU General Public License version 2. (see COPYING.GPL)
8 */
9 #ifndef __DARKSTAT_DECODE_H
10 #define __DARKSTAT_DECODE_H
11
12 #include <pcap.h>
13 #include <netinet/in_systm.h> /* n_time */
14 #define __USE_GNU 1
15 #include <netinet/in.h> /* for <netinet/ip.h> */
16 #include <netinet/ip.h> /* struct ip */
17
18 #include "addr.h"
19
20 #define PPP_HDR_LEN 4
21 #define FDDI_HDR_LEN 21
22 #define IP_HDR_LEN sizeof(struct ip)
23 #define IPV6_HDR_LEN sizeof(struct ip6_hdr)
24 #define TCP_HDR_LEN sizeof(struct tcphdr)
25 #define UDP_HDR_LEN sizeof(struct udphdr)
26 #define NULL_HDR_LEN 4
27 #define PPPOE_HDR_LEN 8
28 #define SLL_HDR_LEN 16
29 #define RAW_HDR_LEN 0
30
31 #ifndef ETHER_ADDR_LEN
32 #define ETHER_ADDR_LEN 6
33 #endif
34
35 #ifndef IPPROTO_OSPF
36 #define IPPROTO_OSPF 89
37 #endif
38
39 #define IPPROTO_INVALID 254 /* don't do proto accounting */
40
41 struct linkhdr {
42 int linktype;
43 unsigned int hdrlen;
44 pcap_handler handler;
45 };
46
47 const struct linkhdr *getlinkhdr(const int linktype);
48 int getsnaplen(const struct linkhdr *lh);
49
50 struct pktsummary {
51 /* Fields are in host byte order (except IPs) */
52 struct addr src, dst;
53 time_t time;
54 uint16_t len;
55 uint8_t proto; /* IPPROTO_{TCP, UDP, ICMP} */
56 uint8_t tcp_flags; /* only for TCP */
57 uint16_t src_port, dst_port; /* only for TCP, UDP */
58 uint8_t src_mac[ETHER_ADDR_LEN],
59 dst_mac[ETHER_ADDR_LEN]; /* only for Ethernet */
60 };
61
62 #endif /* __DARKSTAT_DECODE_H */
63 /* vim:set ts=3 sw=3 tw=78 expandtab: */