]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Allow to specify the AgentX socket to use (instead of the default one).
authorVincent <bernat@luffy.cx>
Sat, 27 Feb 2010 09:18:03 +0000 (10:18 +0100)
committerVincent <bernat@luffy.cx>
Sat, 27 Feb 2010 09:18:03 +0000 (10:18 +0100)
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
src/lldpd.c
src/lldpd.h

index a1bfc8f9ce2f988079ef4c3ebf95c4b138ced5c4..8751b5bf24da6710960f79fd5742bbfb99d522d2 100644 (file)
@@ -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");
index c95bd49be13e8fdfefca5392991771a55dfa4e9d..03b793b290a902adb61d3c0af2757b39fbb74add 100644 (file)
@@ -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 */
 
index c3a7eb3d32d54f29b7fc63ebc60b2e1bd51025a7..aa26938f520ab85acc21377c39bb5d226a8587fb 100644 (file)
@@ -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);