Implement --hexdump
[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
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 #define RAW_HDR_LEN 0
22
23 #ifndef ETHER_ADDR_LEN
24 #define ETHER_ADDR_LEN 6
25 #endif
26
27 typedef struct {
28 int linktype;
29 unsigned int hdrlen;
30 pcap_handler handler;
31 } linkhdr_t;
32
33 const linkhdr_t *getlinkhdr(int linktype);
34 int getcaplen(const linkhdr_t *lh);
35 char *ip_to_str(const in_addr_t ip);
36
37 typedef struct {
38 /* Fields are in host byte order (except IPs) */
39 in_addr_t src_ip, dest_ip;
40 time_t time;
41 uint16_t len;
42 uint8_t proto; /* IPPROTO_{TCP, UDP, ICMP} */
43 uint8_t tcp_flags; /* only for TCP */
44 uint16_t src_port, dest_port; /* only for TCP, UDP */
45 uint8_t src_mac[ETHER_ADDR_LEN],
46 dst_mac[ETHER_ADDR_LEN]; /* only for Ethernet */
47 } pktsummary;
48
49 /* vim:set ts=3 sw=3 tw=78 expandtab: */