summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6079f1d)
raw | patch | inline | side by side (parent: 6079f1d)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Wed, 16 Jun 2010 12:12:46 +0000 (14:12 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Wed, 16 Jun 2010 12:12:46 +0000 (14:12 +0200) |
src/dns.c | patch | blob | history | |
src/utils_dns.c | patch | blob | history |
diff --git a/src/dns.c b/src/dns.c
index f3280c0bed9f65ef37d3e8e554be640ca36ab83d..6e63fe4474f030a1ad65fb17360c5135e7adb308 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
{
counter_list_t *entry;
- DEBUG ("counter_list_search (list = %p, key = %u)",
- (void *) *list, key);
-
for (entry = *list; entry != NULL; entry = entry->next)
if (entry->key == key)
break;
- DEBUG ("return (%p)", (void *) entry);
return (entry);
}
{
counter_list_t *entry;
- DEBUG ("counter_list_create (list = %p, key = %u, value = %u)",
- (void *) *list, key, value);
-
entry = (counter_list_t *) malloc (sizeof (counter_list_t));
if (entry == NULL)
return (NULL);
last->next = entry;
}
- DEBUG ("return (%p)", (void *) entry);
return (entry);
}
{
counter_list_t *entry;
- DEBUG ("counter_list_add (list = %p, key = %u, increment = %u)",
- (void *) *list, key, increment);
-
entry = counter_list_search (list, key);
if (entry != NULL)
{
counter_list_create (list, key, increment);
}
- DEBUG ("return ()");
}
static int dns_config (const char *key, const char *value)
return (NULL);
}
- DEBUG ("PCAP object created.");
+ DEBUG ("dns plugin: PCAP object created.");
dnstop_set_pcap_obj (pcap_obj);
dnstop_set_callback (dns_child_callback);
ERROR ("dns plugin: Listener thread is exiting "
"abnormally: %s", pcap_geterr (pcap_obj));
- DEBUG ("child is exiting");
+ DEBUG ("dns plugin: Child is exiting.");
pcap_close (pcap_obj);
listen_thread_init = 0;
for (i = 0; i < len; i++)
{
- DEBUG ("qtype = %u; counter = %u;", keys[i], values[i]);
+ DEBUG ("dns plugin: qtype = %u; counter = %u;", keys[i], values[i]);
submit_counter ("dns_qtype", qtype_str (keys[i]), values[i]);
}
for (i = 0; i < len; i++)
{
- DEBUG ("opcode = %u; counter = %u;", keys[i], values[i]);
+ DEBUG ("dns plugin: opcode = %u; counter = %u;", keys[i], values[i]);
submit_counter ("dns_opcode", opcode_str (keys[i]), values[i]);
}
for (i = 0; i < len; i++)
{
- DEBUG ("rcode = %u; counter = %u;", keys[i], values[i]);
+ DEBUG ("dns plugin: rcode = %u; counter = %u;", keys[i], values[i]);
submit_counter ("dns_rcode", rcode_str (keys[i]), values[i]);
}
diff --git a/src/utils_dns.c b/src/utils_dns.c
index 66798e2b02e127ee6af71805eb80281f6b7a00e5..22c9b95994377f9ed1752d4192eb25c29a97b8e8 100644 (file)
--- a/src/utils_dns.c
+++ b/src/utils_dns.c
uint16_t us;
off_t offset;
char *t;
- int x;
+ int status;
/* The DNS header is 12 bytes long */
- if (len < 12)
+ if (len < DNS_MSG_HDR_SZ)
return 0;
memcpy(&us, buf + 0, 2);
memcpy(&us, buf + 10, 2);
qh.arcount = ntohs(us);
- offset = 12;
+ offset = DNS_MSG_HDR_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;
+ }
if ('\0' == qh.qname[0])
sstrncpy (qh.qname, ".", sizeof (qh.qname));
while ((t = strchr(qh.qname, '\n')))
@@ -660,10 +664,6 @@ void handle_pcap(u_char *udata, const struct pcap_pkthdr *hdr, const u_char *pkt
{
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;
@@ -697,7 +697,7 @@ void handle_pcap(u_char *udata, const struct pcap_pkthdr *hdr, const u_char *pkt
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;