X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_dns.c;h=dfced5c72c13dfc4bf71938c9e08bda834eb8a56;hb=96f2b2eadf9a6c750e8745f2e463d91e78b4d02a;hp=2b40676353522922446a300343820de422b96497;hpb=43a771aa5443266cca4cb7aecaf70eb75100a32c;p=collectd.git diff --git a/src/utils_dns.c b/src/utils_dns.c index 2b406763..dfced5c7 100644 --- a/src/utils_dns.c +++ b/src/utils_dns.c @@ -1,7 +1,7 @@ /* * collectd - src/utils_dns.c - * Modifications Copyright (C) 2006 Florian octo Forster - * Copyright (C) 2002 The Measurement Factory, Inc. + * Copyright (C) 2006 Florian octo Forster + * Copyright (C) 2002 The Measurement Factory, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,7 +30,7 @@ * * Authors: * The Measurement Factory, Inc. - * Florian octo Forster + * Florian octo Forster */ #define _DEFAULT_SOURCE @@ -40,10 +40,6 @@ #include "plugin.h" #include "common.h" -#if HAVE_SYS_SOCKET_H -# include -#endif - #if HAVE_NET_IF_ARP_H # include #endif @@ -66,9 +62,6 @@ #if HAVE_NETINET_IP6_H # include #endif -#if HAVE_NETINET_IP_COMPAT_H -# include -#endif #if HAVE_NETINET_IF_ETHER_H # include #endif @@ -163,9 +156,6 @@ typedef int (printer)(const char *, ...); /* * Global variables */ -int qtype_counts[T_MAX]; -int opcode_counts[OP_MAX]; -int qclass_counts[C_MAX]; #if HAVE_PCAP_H static pcap_t *pcap_obj = NULL; @@ -219,7 +209,7 @@ static void ignore_list_add (const struct in6_addr *addr) if (ignore_list_match (addr) != 0) return; - new = malloc (sizeof (ip_list_t)); + new = malloc (sizeof (*new)); if (new == NULL) { perror ("malloc"); @@ -293,8 +283,7 @@ void dnstop_set_callback (void (*cb) (const rfc1035_header_t *)) #define RFC1035_MAXLABELSZ 63 static int -rfc1035NameUnpack(const char *buf, size_t sz, off_t * off, char *name, size_t ns -) +rfc1035NameUnpack(const char *buf, size_t sz, off_t * off, char *name, size_t ns) { off_t no = 0; unsigned char c; @@ -305,7 +294,7 @@ rfc1035NameUnpack(const char *buf, size_t sz, off_t * off, char *name, size_t ns if (ns <= 0) return 4; /* probably compression loop */ do { - if ((*off) >= sz) + if ((*off) >= ((off_t) sz)) break; c = *(buf + (*off)); if (c > 191) { @@ -317,11 +306,11 @@ rfc1035NameUnpack(const char *buf, size_t sz, off_t * off, char *name, size_t ns s = ntohs(s); (*off) += sizeof(s); /* Sanity check */ - if ((*off) >= sz) + if ((*off) >= ((off_t) sz)) return 1; /* message too short */ ptr = s & 0x3FFF; /* Make sure the pointer is inside this message */ - if (ptr >= sz) + if (ptr >= ((off_t) sz)) return 2; /* bad compression ptr */ if (ptr < DNS_MSG_HDR_SZ) return 2; /* bad compression ptr */ @@ -334,7 +323,6 @@ rfc1035NameUnpack(const char *buf, size_t sz, off_t * off, char *name, size_t ns * "(The 10 and 01 combinations are reserved for future use.)" */ return 3; /* reserved label/compression flags */ - break; } else { (*off)++; len = (size_t) c; @@ -355,7 +343,7 @@ rfc1035NameUnpack(const char *buf, size_t sz, off_t * off, char *name, size_t ns if (no > 0) *(name + no - 1) = '\0'; /* make sure we didn't allow someone to overflow the name buffer */ - assert(no <= ns); + assert(no <= ((off_t) ns)); return 0; } @@ -425,11 +413,6 @@ handle_dns(const char *buf, int len) qh.length = (uint16_t) len; - /* gather stats */ - qtype_counts[qh.qtype]++; - qclass_counts[qh.qclass]++; - opcode_counts[qh.opcode]++; - if (Callback != NULL) Callback (&qh); @@ -845,9 +828,7 @@ const char *qtype_str(int t) default: ssnprintf (buf, sizeof (buf), "#%i", t); return (buf); - }; /* switch (t) */ - /* NOTREACHED */ - return (NULL); + } /* switch (t) */ } const char *opcode_str (int o) @@ -856,24 +837,18 @@ const char *opcode_str (int o) switch (o) { case 0: return "Query"; - break; case 1: return "Iquery"; - break; case 2: return "Status"; - break; case 4: return "Notify"; - break; case 5: return "Update"; - break; default: ssnprintf(buf, sizeof (buf), "Opcode%d", o); return buf; } - /* NOTREACHED */ } const char *rcode_str (int rcode) @@ -917,8 +892,6 @@ const char *rcode_str (int rcode) ssnprintf (buf, sizeof (buf), "RCode%i", rcode); return (buf); } - /* Never reached */ - return (NULL); } /* const char *rcode_str (int rcode) */ #if 0