/* darkstat 3
- * copyright (c) 2001-2009 Emil Mikulic.
+ * copyright (c) 2001-2011 Emil Mikulic.
*
* decode.h: packet decoding.
*
* You may use, modify and redistribute this file under the terms of the
* GNU General Public License version 2. (see COPYING.GPL)
*/
+#ifndef __DARKSTAT_DECODE_H
+#define __DARKSTAT_DECODE_H
#include <pcap.h>
-#include <netinet/in.h> /* in_addr_t */
+#include <netinet/in_systm.h> /* n_time */
+#define __USE_GNU 1
+#include <netinet/in.h> /* for <netinet/ip.h> */
#include <netinet/ip.h> /* struct ip */
+#include "addr.h"
+
#define PPP_HDR_LEN 4
#define FDDI_HDR_LEN 21
#define IP_HDR_LEN sizeof(struct ip)
#define ETHER_ADDR_LEN 6
#endif
-typedef struct {
+#ifndef IPPROTO_OSPF
+#define IPPROTO_OSPF 89
+#endif
+
+#define IPPROTO_INVALID 254 /* don't do proto accounting */
+
+struct linkhdr {
int linktype;
unsigned int hdrlen;
pcap_handler handler;
-} linkhdr_t;
+};
-const linkhdr_t *getlinkhdr(int linktype);
-int getsnaplen(const linkhdr_t *lh);
-char *ip_to_str(const in_addr_t ip);
-char *ip6_to_str(const struct in6_addr *ip6);
+const struct linkhdr *getlinkhdr(const int linktype);
+int getsnaplen(const struct linkhdr *lh);
-typedef struct {
+struct pktsummary {
/* Fields are in host byte order (except IPs) */
- union {
- in_addr_t src_ip;
- struct in6_addr src_ip6;
- };
- union {
- in_addr_t dest_ip;
- struct in6_addr dest_ip6;
- };
+ struct addr src, dst;
time_t time;
uint16_t len;
- uint8_t af; /* AF_{UNSPEC, INET, INET6} */
- uint8_t proto; /* IPPROTO_{TCP, UDP, ICMP} */
- uint8_t tcp_flags; /* only for TCP */
- uint16_t src_port, dest_port; /* only for TCP, UDP */
+ uint8_t proto; /* IPPROTO_{TCP, UDP, ICMP} */
+ uint8_t tcp_flags; /* only for TCP */
+ uint16_t src_port, dst_port; /* only for TCP, UDP */
uint8_t src_mac[ETHER_ADDR_LEN],
dst_mac[ETHER_ADDR_LEN]; /* only for Ethernet */
-} pktsummary;
+};
+#endif /* __DARKSTAT_DECODE_H */
/* vim:set ts=3 sw=3 tw=78 expandtab: */