#include "collectd.h"
+#if HAVE_NETINET_IN_SYSTM_H
+# include <netinet/in_systm.h>
+#endif
#if HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
-#if HAVE_PCAP_H
-# include <pcap.h>
-#endif
#if HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
#if HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
# include <net/if_ppp.h>
#endif
-#if HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
#if HAVE_NETDB_H
# include <netdb.h>
#endif
-#if HAVE_NETINET_IN_SYSTM_H
-# include <netinet/in_systm.h>
-#endif
-#if HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
#if HAVE_NETINET_IP_H
# include <netinet/ip.h>
#endif
# include <netinet/udp.h>
#endif
+#if HAVE_PCAP_H
+# include <pcap.h>
+#endif
+
#define PCAP_SNAPLEN 1460
#ifndef ETHER_HDR_LEN
#define ETHER_ADDR_LEN 6
# define PPP_CONTROL_VAL 0x03 /* The control byte value */
#endif
-#ifndef __FAVOR_BSD
-#define uh_sport source
-#define uh_dport dest
+#if HAVE_STRUCT_UDPHDR_UH_DPORT && HAVE_STRUCT_UDPHDR_UH_SPORT
+# define UDP_DEST uh_dport
+# define UDP_SRC uh_dport
+#elif HAVE_STRUCT_UDPHDR_DEST && HAVE_STRUCT_UDPHDR_SOURCE
+# define UDP_DEST dest
+# define UDP_SRC source
+#else
+# error "`struct udphdr' is unusable."
#endif
#include "utils_dns.h"
const struct in6_addr *d_addr)
{
char buf[PCAP_SNAPLEN];
- if ((ntohs (udp->uh_dport) != 53)
- && (ntohs (udp->uh_sport) != 53))
+ if ((ntohs (udp->UDP_DEST) != 53)
+ && (ntohs (udp->UDP_SRC) != 53))
return 0;
memcpy(buf, udp + 1, len - sizeof(*udp));
if (0 == handle_dns(buf, len - sizeof(*udp), s_addr, d_addr))