From: Florian Forster Date: Wed, 25 Oct 2006 13:45:55 +0000 (+0200) Subject: Renamed more variables and functions and such from `named' -> `dns' X-Git-Tag: collectd-3.11.0~42^2~5 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=c381dc2559e8380899fc9e7b5203700ea9a7f9be;p=collectd.git Renamed more variables and functions and such from `named' -> `dns' --- diff --git a/src/dns.c b/src/dns.c index 7ab28141..15afef9c 100644 --- a/src/dns.c +++ b/src/dns.c @@ -1,5 +1,5 @@ /** - * collectd - src/named.c + * collectd - src/dns.c * Copyright (C) 2006 Florian octo Forster * * This program is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ # include #endif -#define MODULE_NAME "named" +#define MODULE_NAME "dns" #if HAVE_LIBPCAP # define NAMED_HAVE_CONFIG 1 @@ -53,9 +53,9 @@ struct counter_list_s }; typedef struct counter_list_s counter_list_t; -static char *qtype_file = "named/qtype-%s.rrd"; -static char *opcode_file = "named/opcode-%s.rrd"; -static char *rcode_file = "named/rcode-%s.rrd"; +static char *qtype_file = "dns/qtype-%s.rrd"; +static char *opcode_file = "dns/opcode-%s.rrd"; +static char *rcode_file = "dns/rcode-%s.rrd"; static char *qtype_ds_def[] = { @@ -195,7 +195,7 @@ static int counter_list_send (counter_list_t *list, int fd) if (swrite (fd, (const void *) &values_num, sizeof (values_num)) != 0) { DBG ("Writing to fd failed: %s", strerror (errno)); - syslog (LOG_ERR, "named plugin: Writing to fd failed: %s", + syslog (LOG_ERR, "dns plugin: Writing to fd failed: %s", strerror (errno)); return (-1); } @@ -208,7 +208,7 @@ static int counter_list_send (counter_list_t *list, int fd) if (swrite (fd, (const void *) values, 2 * sizeof (int) * values_num) != 0) { DBG ("Writing to pipe failed: %s", strerror (errno)); - syslog (LOG_ERR, "named plugin: Writing to pipe failed: %s", + syslog (LOG_ERR, "dns plugin: Writing to pipe failed: %s", strerror (errno)); return (-1); } @@ -216,7 +216,7 @@ static int counter_list_send (counter_list_t *list, int fd) return (values_num); } #if NAMED_HAVE_CONFIG -static int named_config (char *key, char *value) +static int dns_config (char *key, char *value) { #if HAVE_LIBPCAP if (strcasecmp (key, "Interface") == 0) @@ -241,7 +241,7 @@ static int named_config (char *key, char *value) } #endif /* NAMED_HAVE_CONFIG */ -static void named_child_callback (const rfc1035_header_t *dns) +static void dns_child_callback (const rfc1035_header_t *dns) { if (dns->qr == 0) { @@ -258,7 +258,7 @@ static void named_child_callback (const rfc1035_header_t *dns) counter_list_add (&opcode_list, dns->opcode, 1); } -static void named_child_loop (void) +static void dns_child_loop (void) { pcap_t *pcap_obj; char pcap_error[PCAP_ERRBUF_SIZE]; @@ -276,7 +276,7 @@ static void named_child_loop (void) pcap_error); if (pcap_obj == NULL) { - syslog (LOG_ERR, "named plugin: Opening interface `%s' failed: %s", + syslog (LOG_ERR, "dns plugin: Opening interface `%s' failed: %s", (pcap_device != NULL) ? pcap_device : "any", pcap_error); close (pipe_fd); @@ -288,7 +288,7 @@ static void named_child_loop (void) if (pcap_compile (pcap_obj, &fp, "udp port 53", 1, 0) < 0) { DBG ("pcap_compile failed"); - syslog (LOG_ERR, "named plugin: pcap_compile failed"); + syslog (LOG_ERR, "dns plugin: pcap_compile failed"); close (pipe_fd); pipe_fd = -1; return; @@ -296,7 +296,7 @@ static void named_child_loop (void) if (pcap_setfilter (pcap_obj, &fp) < 0) { DBG ("pcap_setfilter failed"); - syslog (LOG_ERR, "named plugin: pcap_setfilter failed"); + syslog (LOG_ERR, "dns plugin: pcap_setfilter failed"); close (pipe_fd); pipe_fd = -1; return; @@ -305,7 +305,7 @@ static void named_child_loop (void) DBG ("PCAP object created."); dnstop_set_pcap_obj (pcap_obj); - dnstop_set_callback (named_child_callback); + dnstop_set_callback (dns_child_callback); /* Set up pipe end */ poll_fds[0].fd = pipe_fd; @@ -322,7 +322,7 @@ static void named_child_loop (void) if (status < 0) { - syslog (LOG_ERR, "named plugin: poll(2) failed: %s", + syslog (LOG_ERR, "dns plugin: poll(2) failed: %s", strerror (errno)); break; } @@ -330,7 +330,7 @@ static void named_child_loop (void) if (poll_fds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) { DBG ("Pipe closed. Exiting."); - syslog (LOG_NOTICE, "named plugin: Pipe closed. Exiting."); + syslog (LOG_NOTICE, "dns plugin: Pipe closed. Exiting."); break; } else if (poll_fds[0].revents & POLLOUT) @@ -344,7 +344,7 @@ static void named_child_loop (void) if (poll_fds[1].revents & (POLLERR | POLLHUP | POLLNVAL)) { DBG ("pcap-device closed. Exiting."); - syslog (LOG_ERR, "named plugin: pcap-device closed. Exiting."); + syslog (LOG_ERR, "dns plugin: pcap-device closed. Exiting."); break; } else if (poll_fds[1].revents & (POLLIN | POLLPRI)) @@ -356,7 +356,7 @@ static void named_child_loop (void) if (status < 0) { DBG ("pcap_dispatch failed: %s", pcap_geterr (pcap_obj)); - syslog (LOG_ERR, "named plugin: pcap_dispatch failed: %s", + syslog (LOG_ERR, "dns plugin: pcap_dispatch failed: %s", pcap_geterr (pcap_obj)); break; } @@ -368,9 +368,9 @@ static void named_child_loop (void) close (pipe_fd); pipe_fd = -1; pcap_close (pcap_obj); -} /* static void named_child_loop (void) */ +} /* static void dns_child_loop (void) */ -static void named_init (void) +static void dns_init (void) { #if HAVE_LIBPCAP int pipe_fds[2]; @@ -378,7 +378,7 @@ static void named_init (void) if (pipe (pipe_fds) != 0) { - syslog (LOG_ERR, "named plugin: pipe(2) failed: %s", + syslog (LOG_ERR, "dns plugin: pipe(2) failed: %s", strerror (errno)); return; } @@ -387,7 +387,7 @@ static void named_init (void) pid_child = fork (); if (pid_child < 0) { - syslog (LOG_ERR, "named plugin: fork(2) failed: %s", + syslog (LOG_ERR, "dns plugin: fork(2) failed: %s", strerror (errno)); close (pipe_fds[0]); close (pipe_fds[1]); @@ -405,7 +405,7 @@ static void named_init (void) pipe_fd = pipe_fds[1]; close (pipe_fds[0]); - named_child_loop (); + dns_child_loop (); exit (0); } @@ -468,7 +468,7 @@ static void qtype_submit (int qtype, unsigned int counter) if ((status < 1) || (status >= 32)) return; - plugin_submit ("named_qtype", inst, buffer); + plugin_submit ("dns_qtype", inst, buffer); } static void rcode_submit (int rcode, unsigned int counter) @@ -484,7 +484,7 @@ static void rcode_submit (int rcode, unsigned int counter) if ((status < 1) || (status >= 32)) return; - plugin_submit ("named_rcode", inst, buffer); + plugin_submit ("dns_rcode", inst, buffer); } static void opcode_submit (int opcode, unsigned int counter) @@ -500,11 +500,11 @@ static void opcode_submit (int opcode, unsigned int counter) if ((status < 1) || (status >= 32)) return; - plugin_submit ("named_opcode", inst, buffer); + plugin_submit ("dns_opcode", inst, buffer); } #if NAMED_HAVE_READ -static unsigned int named_read_array (unsigned int *values) +static unsigned int dns_read_array (unsigned int *values) { unsigned int values_num; @@ -515,7 +515,7 @@ static unsigned int named_read_array (unsigned int *values) { DBG ("Reading from the pipe failed: %s", strerror (errno)); - syslog (LOG_ERR, "named plugin: Reading from the pipe failed: %s", + syslog (LOG_ERR, "dns plugin: Reading from the pipe failed: %s", strerror (errno)); pipe_fd = -1; return (0); @@ -531,7 +531,7 @@ static unsigned int named_read_array (unsigned int *values) { DBG ("Reading from the pipe failed: %s", strerror (errno)); - syslog (LOG_ERR, "named plugin: Reading from the pipe failed: %s", + syslog (LOG_ERR, "dns plugin: Reading from the pipe failed: %s", strerror (errno)); pipe_fd = -1; return (0); @@ -540,7 +540,7 @@ static unsigned int named_read_array (unsigned int *values) return (values_num); } -static void named_read (void) +static void dns_read (void) { unsigned int values[2 * T_MAX]; unsigned int values_num; @@ -549,21 +549,21 @@ static void named_read (void) if (pipe_fd < 0) return; - values_num = named_read_array (values); + values_num = dns_read_array (values); for (i = 0; i < values_num; i++) { DBG ("qtype = %u; counter = %u;", values[2 * i], values[(2 * i) + 1]); qtype_submit (values[2 * i], values[(2 * i) + 1]); } - values_num = named_read_array (values); + values_num = dns_read_array (values); for (i = 0; i < values_num; i++) { DBG ("opcode = %u; counter = %u;", values[2 * i], values[(2 * i) + 1]); opcode_submit (values[2 * i], values[(2 * i) + 1]); } - values_num = named_read_array (values); + values_num = dns_read_array (values); for (i = 0; i < values_num; i++) { DBG ("rcode = %u; counter = %u;", values[2 * i], values[(2 * i) + 1]); @@ -571,16 +571,16 @@ static void named_read (void) } } #else /* if !NAMED_HAVE_READ */ -# define named_read NULL +# define dns_read NULL #endif void module_register (void) { - plugin_register (MODULE_NAME, named_init, named_read, NULL); - plugin_register ("named_qtype", NULL, NULL, qtype_write); - plugin_register ("named_rcode", NULL, NULL, rcode_write); - plugin_register ("named_opcode", NULL, NULL, opcode_write); - cf_register (MODULE_NAME, named_config, config_keys, config_keys_num); + plugin_register (MODULE_NAME, dns_init, dns_read, NULL); + plugin_register ("dns_qtype", NULL, NULL, qtype_write); + plugin_register ("dns_rcode", NULL, NULL, rcode_write); + plugin_register ("dns_opcode", NULL, NULL, opcode_write); + cf_register (MODULE_NAME, dns_config, config_keys, config_keys_num); } #undef MODULE_NAME