2 * copyright (c) 2001-2012 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) */
31 uint8_t proto
; /* IPPROTO_INVALID means don't do proto accounting */
32 uint8_t tcp_flags
; /* only for TCP */
33 uint16_t src_port
, dst_port
; /* only for TCP, UDP */
34 uint8_t src_mac
[ETHER_ADDR_LEN
], /* only for Ethernet */
35 dst_mac
[ETHER_ADDR_LEN
]; /* only for Ethernet */
38 struct pcap_pkthdr
; /* from pcap.h */
40 #define DECODER_ARGS const struct pcap_pkthdr *pheader, \
41 const u_char *pdata, \
44 /* Returns 0 on decode failure (meaning accounting should not be performed) */
45 typedef int (decoder_fn
)(DECODER_ARGS
);
53 const struct linkhdr
*getlinkhdr(const int linktype
);
54 int getsnaplen(const struct linkhdr
*lh
);
56 #endif /* __DARKSTAT_DECODE_H */
57 /* vim:set ts=3 sw=3 tw=78 expandtab: */