projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
src/utils_dns.c: Make IPv6 support optional.
[collectd.git]
/
src
/
utils_dns.c
diff --git
a/src/utils_dns.c
b/src/utils_dns.c
index
66798e2
..
d1c8d5d
100644
(file)
--- a/
src/utils_dns.c
+++ b/
src/utils_dns.c
@@
-358,10
+358,10
@@
handle_dns(const char *buf, int len)
uint16_t us;
off_t offset;
char *t;
uint16_t us;
off_t offset;
char *t;
- int
x
;
+ int
status
;
/* The DNS header is 12 bytes long */
/* The DNS header is 12 bytes long */
- if (len <
12
)
+ if (len <
DNS_MSG_HDR_SZ
)
return 0;
memcpy(&us, buf + 0, 2);
return 0;
memcpy(&us, buf + 0, 2);
@@
-392,11
+392,15
@@
handle_dns(const char *buf, int len)
memcpy(&us, buf + 10, 2);
qh.arcount = ntohs(us);
memcpy(&us, buf + 10, 2);
qh.arcount = ntohs(us);
- offset =
12
;
+ offset =
DNS_MSG_HDR_SZ
;
memset(qh.qname, '\0', MAX_QNAME_SZ);
memset(qh.qname, '\0', MAX_QNAME_SZ);
- x = rfc1035NameUnpack(buf, len, &offset, qh.qname, MAX_QNAME_SZ);
- if (0 != x)
+ status = rfc1035NameUnpack(buf, len, &offset, qh.qname, MAX_QNAME_SZ);
+ if (status != 0)
+ {
+ INFO ("utils_dns: handle_dns: rfc1035NameUnpack failed "
+ "with status %i.", status);
return 0;
return 0;
+ }
if ('\0' == qh.qname[0])
sstrncpy (qh.qname, ".", sizeof (qh.qname));
while ((t = strchr(qh.qname, '\n')))
if ('\0' == qh.qname[0])
sstrncpy (qh.qname, ".", sizeof (qh.qname));
while ((t = strchr(qh.qname, '\n')))
@@
-437,6
+441,7
@@
handle_udp(const struct udphdr *udp, int len)
return 1;
}
return 1;
}
+#if HAVE_NETINET_IP6_H
static int
handle_ipv6 (struct ip6_hdr *ipv6, int len)
{
static int
handle_ipv6 (struct ip6_hdr *ipv6, int len)
{
@@
-508,6
+513,16
@@
handle_ipv6 (struct ip6_hdr *ipv6, int len)
return (1); /* Success */
} /* int handle_ipv6 */
return (1); /* Success */
} /* int handle_ipv6 */
+/* #endif HAVE_NETINET_IP6_H */
+
+#else /* if !HAVE_NETINET_IP6_H */
+static int
+handle_ipv6 (__attribute__((unused)) void *pkg,
+ __attribute__((unused)) int len)
+{
+ return (0);
+}
+#endif /* !HAVE_NETINET_IP6_H */
static int
handle_ip(const struct ip *ip, int len)
static int
handle_ip(const struct ip *ip, int len)
@@
-518,7
+533,7
@@
handle_ip(const struct ip *ip, int len)
struct in6_addr d_addr;
if (ip->ip_v == 6)
struct in6_addr d_addr;
if (ip->ip_v == 6)
- return (handle_ipv6 ((
struct ip6_hdr
*) ip, len));
+ return (handle_ipv6 ((
void
*) ip, len));
in6_addr_from_buffer (&s_addr, &ip->ip_src.s_addr, sizeof (ip->ip_src.s_addr), AF_INET);
in6_addr_from_buffer (&d_addr, &ip->ip_dst.s_addr, sizeof (ip->ip_dst.s_addr), AF_INET);
in6_addr_from_buffer (&s_addr, &ip->ip_src.s_addr, sizeof (ip->ip_src.s_addr), AF_INET);
in6_addr_from_buffer (&d_addr, &ip->ip_dst.s_addr, sizeof (ip->ip_dst.s_addr), AF_INET);
@@
-616,7
+631,7
@@
handle_ether(const u_char * pkt, int len)
return 0;
memcpy(buf, pkt, len);
if (ETHERTYPE_IPV6 == etype)
return 0;
memcpy(buf, pkt, len);
if (ETHERTYPE_IPV6 == etype)
- return (handle_ipv6 ((
struct ip6_hdr
*) buf, len));
+ return (handle_ipv6 ((
void
*) buf, len));
else
return handle_ip((struct ip *) buf, len);
}
else
return handle_ip((struct ip *) buf, len);
}
@@
-649,7
+664,7
@@
handle_linux_sll (const u_char *pkt, int len)
return 0;
if (ETHERTYPE_IPV6 == etype)
return 0;
if (ETHERTYPE_IPV6 == etype)
- return (handle_ipv6 ((
struct ip6_hdr
*) pkt, len));
+ return (handle_ipv6 ((
void
*) pkt, len));
else
return handle_ip((struct ip *) pkt, len);
}
else
return handle_ip((struct ip *) pkt, len);
}
@@
-660,10
+675,6
@@
void handle_pcap(u_char *udata, const struct pcap_pkthdr *hdr, const u_char *pkt
{
int status;
{
int status;
- DEBUG ("handle_pcap (udata = %p, hdr = %p, pkt = %p): hdr->caplen = %i\n",
- (void *) udata, (void *) hdr, (void *) pkt,
- hdr->caplen);
-
if (hdr->caplen < ETHER_HDR_LEN)
return;
if (hdr->caplen < ETHER_HDR_LEN)
return;
@@
-697,7
+708,7
@@
void handle_pcap(u_char *udata, const struct pcap_pkthdr *hdr, const u_char *pkt
break;
default:
break;
default:
- ERROR ("handle_pcap: unsupported data link type %d
\n
",
+ ERROR ("handle_pcap: unsupported data link type %d",
pcap_datalink(pcap_obj));
status = 0;
break;
pcap_datalink(pcap_obj));
status = 0;
break;