diff options
author | Stef Walter <stef@memberwebs.com> | 2009-10-24 14:10:41 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2009-10-24 14:10:41 +0000 |
commit | 0af1b01b5ca61422c779b40a9c99cd0b29b40049 (patch) | |
tree | 26374207ac7df32b16332090328cd1a99ddeff4f /daemon | |
parent | 54c751ffc4f79dcd916b4dffe690f59615c7146d (diff) |
Support for multiple local sockets (ie: INET + INET6)
* Allows us to make ipv6 queries.
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/rrdbotd.c | 24 |
1 files changed, 21 insertions, 3 deletions
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 */ |