From bbea66e1caeba3c136cc02970ba5250192de106c Mon Sep 17 00:00:00 2001 From: Vincent Date: Sat, 27 Feb 2010 10:18:03 +0100 Subject: [PATCH] Allow to specify the AgentX socket to use (instead of the default one). This means that AgentX can be configured to use tcp:127.0.0.1:705 (for example). Since we are running in a chroot, we cannot use hostnames. Any network socket should work. Unix sockets should work as before (using privilege separation). --- src/agent.c | 5 ++++- src/lldpd.c | 14 +++++++++++--- src/lldpd.h | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/agent.c b/src/agent.c index a1bfc8f9..8751b5bf 100644 --- a/src/agent.c +++ b/src/agent.c @@ -1259,7 +1259,7 @@ static struct variable8 lldp_vars[] = { }; void -agent_init(struct lldpd *cfg, int debug) +agent_init(struct lldpd *cfg, char *agentx, int debug) { int rc; #ifdef HAVE___PROGNAME @@ -1287,6 +1287,9 @@ agent_init(struct lldpd *cfg, int debug) /* We provide our UNIX domain transport */ agent_priv_register_domain(); + if (agentx) + netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, + NETSNMP_DS_AGENT_X_SOCKET, agentx); init_agent("lldpAgent"); REGISTER_MIB("lldp", lldp_vars, variable8, lldp_oid); init_snmp("lldpAgent"); diff --git a/src/lldpd.c b/src/lldpd.c index c95bd49b..03b793b2 100644 --- a/src/lldpd.c +++ b/src/lldpd.c @@ -744,13 +744,14 @@ lldpd_main(int argc, char *argv[]) int ch, debug = 0; #ifdef USE_SNMP int snmp = 0; + char *agentx = NULL; /* AgentX socket */ #endif char *mgmtp = NULL; char *popt, opts[] = #ifdef ENABLE_LISTENVLAN "v" #endif - "kdxm:p:M:i@ "; + "kdxX:m:p:M:i@ "; int i, found, advertise_version = 1; #ifdef ENABLE_LISTENVLAN int vlan = 0; @@ -805,10 +806,17 @@ lldpd_main(int argc, char *argv[]) usage(); break; #endif - case 'x': #ifdef USE_SNMP + case 'x': + snmp = 1; + break; + case 'X': snmp = 1; + agentx = optarg; + break; #else + case 'x': + case 'X': fprintf(stderr, "SNMP support is not built-in\n"); usage(); #endif @@ -901,7 +909,7 @@ lldpd_main(int argc, char *argv[]) #ifdef USE_SNMP if (snmp) { cfg->g_snmp = 1; - agent_init(cfg, debug); + agent_init(cfg, agentx, debug); } #endif /* USE_SNMP */ diff --git a/src/lldpd.h b/src/lldpd.h index c3a7eb3d..aa26938f 100644 --- a/src/lldpd.h +++ b/src/lldpd.h @@ -427,7 +427,7 @@ void fatalx(const char *); /* agent.c */ void agent_shutdown(void); -void agent_init(struct lldpd *, int); +void agent_init(struct lldpd *, char *, int); /* agent_priv.c */ void agent_priv_register_domain(void); -- 2.39.5