From 0af1b01b5ca61422c779b40a9c99cd0b29b40049 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Sat, 24 Oct 2009 14:10:41 +0000 Subject: Support for multiple local sockets (ie: INET + INET6) * Allows us to make ipv6 queries. --- daemon/rrdbotd.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'daemon') diff --git a/daemon/rrdbotd.c b/daemon/rrdbotd.c index 573eb5f..f2ecd52 100644 --- a/daemon/rrdbotd.c +++ b/daemon/rrdbotd.c @@ -204,8 +204,9 @@ removepid(const char* pidfile) int main(int argc, char* argv[]) { + const char** local = NULL; + int n_local = 0; const char* pidfile = NULL; - const char *bind_address = NULL; int daemonize = 1; char ch; char* t; @@ -231,7 +232,9 @@ main(int argc, char* argv[]) /* Bind address */ case 'b': - bind_address = optarg; + local = xrealloc (local, sizeof (char*) * (n_local + 2)); + local[n_local] = optarg; + local[++n_local] = NULL; break; /* Config directory */ @@ -301,6 +304,17 @@ main(int argc, char* argv[]) if(argc != 0) usage(); + /* No bind addresses specified, use defaults... */ + if (local == NULL) { + local = xrealloc (local, sizeof (char*) * 3); + local[0] = "0.0.0.0"; + local[1] = NULL; +#ifdef HAVE_INET6 + local[1] = "::"; + local[2] = NULL; +#endif + } + /* The mainloop server */ server_init(); @@ -311,9 +325,13 @@ main(int argc, char* argv[]) mib_uninit(); /* Rev up the main engine */ - snmp_engine_init(bind_address, 3); + snmp_engine_init (local, 3); rb_poll_engine_init(); + free (local); + n_local = 0; + local = NULL; + if(daemonize) { /* Fork a daemon nicely */ -- cgit v1.2.3