]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: add agentx_enabled hook 8023/head
authorKaren Schoener <karen@voltanet.io>
Fri, 5 Feb 2021 21:05:36 +0000 (16:05 -0500)
committerKaren Schoener <karen@voltanet.io>
Tue, 16 Feb 2021 16:53:42 +0000 (11:53 -0500)
Adding agentx_enabled hook.

This permits the main LDP process to signal the lde and ldpe
processes when agentx is enabled.

Signed-off-by: Karen Schoener <karen@voltanet.io>
lib/agentx.c
lib/smux.h

index f049d699a87d4ea5142d29d496c8a8c8c5f14415..4f5a1d1847bb927b964fd47375eb470643550952 100644 (file)
@@ -36,6 +36,8 @@
 
 XREF_SETUP()
 
+DEFINE_HOOK(agentx_enabled, (), ())
+
 static int agentx_enabled = 0;
 
 static struct thread_master *agentx_tm;
@@ -226,6 +228,7 @@ DEFUN (agentx_enable,
                events = list_new();
                agentx_events_update();
                agentx_enabled = 1;
+               hook_call(agentx_enabled);
        }
 
        return CMD_SUCCESS;
@@ -259,6 +262,16 @@ void smux_init(struct thread_master *tm)
        install_element(CONFIG_NODE, &no_agentx_cmd);
 }
 
+void smux_agentx_enable(void)
+{
+       if (!agentx_enabled) {
+               init_snmp(FRR_SMUX_NAME);
+               events = list_new();
+               agentx_events_update();
+               agentx_enabled = 1;
+       }
+}
+
 void smux_register_mib(const char *descr, struct variable *var, size_t width,
                       int num, oid name[], size_t namelen)
 {
index 6896f02354951dbd1435a050041b0852d99e38a2..1f79d41ef8cd261f6c206e5e4479872ba0b43dd5 100644 (file)
@@ -25,6 +25,7 @@
 #include <net-snmp/agent/snmp_vars.h>
 
 #include "thread.h"
+#include "hook.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -70,6 +71,7 @@ struct trap_object {
         (uint8_t *)&snmp_in_addr_val)
 
 extern void smux_init(struct thread_master *tm);
+extern void smux_agentx_enable(void);
 extern void smux_register_mib(const char *, struct variable *, size_t, int,
                              oid[], size_t);
 extern int smux_header_generic(struct variable *, oid[], size_t *, int,
@@ -107,6 +109,8 @@ extern void oid2in_addr(oid[], int, struct in_addr *);
 extern void *oid_copy(void *, const void *, size_t);
 extern void oid_copy_addr(oid[], const struct in_addr *, int);
 
+DECLARE_HOOK(agentx_enabled, (), ())
+
 #ifdef __cplusplus
 }
 #endif