summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c381dc2)
raw | patch | inline | side by side (parent: c381dc2)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Wed, 25 Oct 2006 14:18:29 +0000 (16:18 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Wed, 25 Oct 2006 14:18:29 +0000 (16:18 +0200) |
src/dns.c | patch | blob | history |
diff --git a/src/dns.c b/src/dns.c
index 15afef9cc40e3fc93ae7757b4c9d756e4c7b2ecf..a4b3c80d8ed16c8c0abf1611fe0819538fa2c334 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
static char *pcap_device = NULL;
static int pipe_fd = -1;
+static unsigned int tr_queries;
+static unsigned int tr_responses;
static counter_list_t *qtype_list;
static counter_list_t *opcode_list;
static counter_list_t *rcode_list;
if (dns->qr == 0)
{
/* This is a query */
+ tr_queries += dns->length;
counter_list_add (&qtype_list, dns->qtype, 1);
}
else
{
/* This is a reply */
+ tr_responses += dns->length;
counter_list_add (&rcode_list, dns->rcode, 1);
}
else if (poll_fds[0].revents & POLLOUT)
{
DBG ("Sending data..");
+
+ DBG ("swrite (pipe_fd = %i, tr_queries = %i)", pipe_fd, tr_queries);
+ if (swrite (pipe_fd, (const void *) &tr_queries, sizeof (tr_queries)) != 0)
+ {
+ DBG ("Writing to pipe_fd failed: %s", strerror (errno));
+ syslog (LOG_ERR, "dns plugin: Writing to pipe_fd failed: %s",
+ strerror (errno));
+ return;
+ }
+
+ DBG ("swrite (pipe_fd = %i, tr_responses = %i)", pipe_fd, tr_responses);
+ if (swrite (pipe_fd, (const void *) &tr_responses, sizeof (tr_responses)) != 0)
+ {
+ DBG ("Writing to pipe_fd failed: %s", strerror (errno));
+ syslog (LOG_ERR, "dns plugin: Writing to pipe_fd failed: %s",
+ strerror (errno));
+ return;
+ }
+
counter_list_send (qtype_list, pipe_fd);
counter_list_send (opcode_list, pipe_fd);
counter_list_send (rcode_list, pipe_fd);
int pipe_fds[2];
pid_t pid_child;
+ tr_queries = 0;
+ tr_responses = 0;
+
if (pipe (pipe_fds) != 0)
{
syslog (LOG_ERR, "dns plugin: pipe(2) failed: %s",
if (pipe_fd < 0)
return;
+ if (sread (pipe_fd, (void *) &tr_queries, sizeof (tr_queries)) != 0)
+ {
+ DBG ("Reading from the pipe failed: %s",
+ strerror (errno));
+ syslog (LOG_ERR, "dns plugin: Reading from the pipe failed: %s",
+ strerror (errno));
+ pipe_fd = -1;
+ return;
+ }
+ DBG ("sread (pipe_fd = %i, tr_queries = %u)", pipe_fd, tr_queries);
+
+ if (sread (pipe_fd, (void *) &tr_responses, sizeof (tr_responses)) != 0)
+ {
+ DBG ("Reading from the pipe failed: %s",
+ strerror (errno));
+ syslog (LOG_ERR, "dns plugin: Reading from the pipe failed: %s",
+ strerror (errno));
+ pipe_fd = -1;
+ return;
+ }
+ DBG ("sread (pipe_fd = %i, tr_responses = %u)", pipe_fd, tr_responses);
+
values_num = dns_read_array (values);
for (i = 0; i < values_num; i++)
{