2 * copyright (c) 2001-2011 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
14 #ifndef ETHER_ADDR_LEN
15 # define ETHER_ADDR_LEN 6
18 #define IPPROTO_INVALID 254 /* special: means don't do proto accounting */
21 # define IPPROTO_OSPF 89
24 #define PPPOE_HDR_LEN 8
26 /* Decoding creates a summary which is passed to accounting. */
28 /* Fields are in host byte order (except IPs) */
32 uint8_t proto
; /* IPPROTO_INVALID means don't do proto accounting */
33 uint8_t tcp_flags
; /* only for TCP */
34 uint16_t src_port
, dst_port
; /* only for TCP, UDP */
35 uint8_t src_mac
[ETHER_ADDR_LEN
], /* only for Ethernet */
36 dst_mac
[ETHER_ADDR_LEN
]; /* only for Ethernet */
39 struct pcap_pkthdr
; /* from pcap.h */
41 #define DECODER_ARGS const struct pcap_pkthdr *pheader, \
42 const u_char *pdata, \
45 /* Returns 0 on decode failure (meaning accounting should not be performed) */
46 typedef int (decoder_fn
)(DECODER_ARGS
);
54 const struct linkhdr
*getlinkhdr(const int linktype
);
55 int getsnaplen(const struct linkhdr
*lh
);
57 #endif /* __DARKSTAT_DECODE_H */
58 /* vim:set ts=3 sw=3 tw=78 expandtab: */