Use struct addr - big cleanup.
[darkstat] / decode.h
1 /* darkstat 3
2 * copyright (c) 2001-2009 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 struct linkhdr {
40 int linktype;
41 unsigned int hdrlen;
42 pcap_handler handler;
43 };
44
45 const struct linkhdr *getlinkhdr(const int linktype);
46 int getsnaplen(const struct linkhdr *lh);
47
48 struct pktsummary {
49 /* Fields are in host byte order (except IPs) */
50 struct addr src, dst;
51 time_t time;
52 uint16_t len;
53 uint8_t proto; /* IPPROTO_{TCP, UDP, ICMP} */
54 uint8_t tcp_flags; /* only for TCP */
55 uint16_t src_port, dst_port; /* only for TCP, UDP */
56 uint8_t src_mac[ETHER_ADDR_LEN],
57 dst_mac[ETHER_ADDR_LEN]; /* only for Ethernet */
58 };
59
60 #endif /* __DARKSTAT_DECODE_H */
61 /* vim:set ts=3 sw=3 tw=78 expandtab: */