Don't hide that linkhdr_t is a struct.
[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
10 #include <pcap.h>
11 #include <netinet/in_systm.h> /* n_time */
12 #define __USE_GNU 1
13 #include <netinet/in.h> /* for <netinet/ip.h> */
14 #include <netinet/ip.h> /* struct ip */
15
16 #include "hosts_db.h" /* addr46 */
17
18 #define PPP_HDR_LEN 4
19 #define FDDI_HDR_LEN 21
20 #define IP_HDR_LEN sizeof(struct ip)
21 #define IPV6_HDR_LEN sizeof(struct ip6_hdr)
22 #define TCP_HDR_LEN sizeof(struct tcphdr)
23 #define UDP_HDR_LEN sizeof(struct udphdr)
24 #define NULL_HDR_LEN 4
25 #define PPPOE_HDR_LEN 8
26 #define SLL_HDR_LEN 16
27 #define RAW_HDR_LEN 0
28
29 #ifndef ETHER_ADDR_LEN
30 #define ETHER_ADDR_LEN 6
31 #endif
32
33 #ifndef IPPROTO_OSPF
34 # define IPPROTO_OSPF 89
35 #endif
36
37 struct linkhdr {
38 int linktype;
39 unsigned int hdrlen;
40 pcap_handler handler;
41 };
42
43 const struct linkhdr *getlinkhdr(const int linktype);
44 int getsnaplen(const struct linkhdr *lh);
45 char *ip_to_str(const struct addr46 *const ip);
46 char *ip_to_str_af(const void *const addr, sa_family_t af);
47
48 typedef struct {
49 /* Fields are in host byte order (except IPs) */
50 union {
51 struct in_addr src_ip;
52 struct in6_addr src_ip6;
53 };
54 union {
55 struct in_addr dest_ip;
56 struct in6_addr dest_ip6;
57 };
58 time_t time;
59 uint16_t len;
60 sa_family_t af; /* AF_{UNSPEC, INET, INET6} */
61 uint8_t proto; /* IPPROTO_{TCP, UDP, ICMP} */
62 uint8_t tcp_flags; /* only for TCP */
63 uint16_t src_port, dest_port; /* only for TCP, UDP */
64 uint8_t src_mac[ETHER_ADDR_LEN],
65 dst_mac[ETHER_ADDR_LEN]; /* only for Ethernet */
66 } pktsummary;
67
68 /* vim:set ts=3 sw=3 tw=78 expandtab: */