lib: add agentx_enabled hook

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>
This commit is contained in:
Karen Schoener 2021-02-05 16:05:36 -05:00
parent 658186e8b6
commit ec48460efd
2 changed files with 17 additions and 0 deletions

View 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)
{

View 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