First graphical accounting of IPv6.
[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.h> /* in_addr_t */
12 #include <netinet/ip.h> /* struct ip */
13
14 #define PPP_HDR_LEN 4
15 #define FDDI_HDR_LEN 21
16 #define IP_HDR_LEN sizeof(struct ip)
17 #define IPV6_HDR_LEN sizeof(struct ip6_hdr)
18 #define TCP_HDR_LEN sizeof(struct tcphdr)
19 #define UDP_HDR_LEN sizeof(struct udphdr)
20 #define NULL_HDR_LEN 4
21 #define PPPOE_HDR_LEN 8
22 #define SLL_HDR_LEN 16
23 #define RAW_HDR_LEN 0
24
25 #ifndef ETHER_ADDR_LEN
26 #define ETHER_ADDR_LEN 6
27 #endif
28
29 typedef struct {
30 int linktype;
31 unsigned int hdrlen;
32 pcap_handler handler;
33 } linkhdr_t;
34
35 const linkhdr_t *getlinkhdr(int linktype);
36 int getsnaplen(const linkhdr_t *lh);
37 char *ip_to_str(const in_addr_t ip);
38 char *ip6_to_str(const struct in6_addr *ip6);
39
40 typedef struct {
41 /* Fields are in host byte order (except IPs) */
42 union {
43 in_addr_t src_ip;
44 struct in6_addr src_ip6;
45 };
46 union {
47 in_addr_t dest_ip;
48 struct in6_addr dest_ip6;
49 };
50 time_t time;
51 uint16_t len;
52 uint8_t af; /* AF_{UNSPEC, INET, INET6} */
53 uint8_t proto; /* IPPROTO_{TCP, UDP, ICMP} */
54 uint8_t tcp_flags; /* only for TCP */
55 uint16_t src_port, dest_port; /* only for TCP, UDP */
56 uint8_t src_mac[ETHER_ADDR_LEN],
57 dst_mac[ETHER_ADDR_LEN]; /* only for Ethernet */
58 } pktsummary;
59
60 /* vim:set ts=3 sw=3 tw=78 expandtab: */