2 * copyright (c) 2001-2009 Emil Mikulic.
4 * decode.h: packet decoding.
6 * You may use, modify and redistribute this file under the terms of the
7 * GNU General Public License version 2. (see COPYING.GPL)
9 #ifndef __DARKSTAT_DECODE_H
10 #define __DARKSTAT_DECODE_H
13 #include <netinet/in_systm.h> /* n_time */
15 #include <netinet/in.h> /* for <netinet/ip.h> */
16 #include <netinet/ip.h> /* struct ip */
18 #include "hosts_db.h" /* addr46 */
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
31 #ifndef ETHER_ADDR_LEN
32 #define ETHER_ADDR_LEN 6
36 # define IPPROTO_OSPF 89
45 const struct linkhdr
*getlinkhdr(const int linktype
);
46 int getsnaplen(const struct linkhdr
*lh
);
47 char *ip_to_str(const struct addr46
*const ip
);
48 char *ip_to_str_af(const void *const addr
, sa_family_t af
);
51 /* Fields are in host byte order (except IPs) */
53 struct in_addr src_ip
;
54 struct in6_addr src_ip6
;
57 struct in_addr dest_ip
;
58 struct in6_addr dest_ip6
;
62 sa_family_t af
; /* AF_{UNSPEC, INET, INET6} */
63 uint8_t proto
; /* IPPROTO_{TCP, UDP, ICMP} */
64 uint8_t tcp_flags
; /* only for TCP */
65 uint16_t src_port
, dest_port
; /* only for TCP, UDP */
66 uint8_t src_mac
[ETHER_ADDR_LEN
],
67 dst_mac
[ETHER_ADDR_LEN
]; /* only for Ethernet */
70 #endif /* __DARKSTAT_DECODE_H */
71 /* vim:set ts=3 sw=3 tw=78 expandtab: */