Import darkstat 3.0.712
[darkstat] / decode.h
1 /* darkstat 3
2 * copyright (c) 2001-2007 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
13 #define PPP_HDR_LEN 4
14 #define FDDI_HDR_LEN 21
15 #define IP_HDR_LEN 20
16 #define TCP_HDR_LEN 20
17 #define UDP_HDR_LEN 8
18 #define NULL_HDR_LEN 4
19 #define PPPOE_HDR_LEN 8
20 #define SLL_HDR_LEN 16
21
22 #ifndef ETHER_ADDR_LEN
23 #define ETHER_ADDR_LEN 6
24 #endif
25
26 typedef struct {
27 int linktype;
28 int hdrlen;
29 pcap_handler handler;
30 } linkhdr_t;
31
32 const linkhdr_t *getlinkhdr(int linktype);
33 int getcaplen(const linkhdr_t *lh);
34 char *ip_to_str(const in_addr_t ip);
35
36 typedef struct {
37 /* Fields are in host byte order (except IPs) */
38 in_addr_t src_ip, dest_ip;
39 time_t time;
40 uint16_t len;
41 uint8_t proto; /* IPPROTO_{TCP, UDP, ICMP} */
42 uint8_t tcp_flags; /* only for TCP */
43 uint16_t src_port, dest_port; /* only for TCP, UDP */
44 uint8_t src_mac[ETHER_ADDR_LEN],
45 dst_mac[ETHER_ADDR_LEN]; /* only for Ethernet */
46 } pktsummary;
47
48 /* vim:set ts=3 sw=3 tw=78 expandtab: */