#include "bfd.h"
#include "libfrr.h"
#include "ns.h"
+#include "libagentx.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_attr.h"
bgp_option_set(BGP_OPT_NO_ZEBRA);
bgp_error_init();
/* Initializations. */
+ libagentx_init();
bgp_vrf_init();
+
#ifdef HAVE_SCRIPTING
bgp_script_init();
#endif
#include "distribute.h"
#include "libfrr.h"
#include "routemap.h"
+#include "libagentx.h"
//#include "if_rmap.h"
#include "eigrpd/eigrp_structs.h"
/* EIGRP master init. */
eigrp_master_init();
+
eigrp_om->master = frr_init();
master = eigrp_om->master;
+ libagentx_init();
eigrp_error_init();
eigrp_vrf_init();
vrf_init(NULL, NULL, NULL, NULL);
#include "libfrr.h"
#include "routemap.h"
#include "affinitymap.h"
+#include "libagentx.h"
#include "isisd/isis_affinitymap.h"
#include "isisd/isis_constants.h"
/*
* initializations
*/
+ libagentx_init();
cmd_init_config_callbacks(isis_config_start, isis_config_end);
isis_error_init();
access_list_init();
#include "libfrr.h"
#include "lib_errors.h"
#include "zlog_recirculate.h"
+#include "libagentx.h"
static void ldpd_shutdown(void);
static pid_t start_child(enum ldpd_process, char *, int, int, int);
zlog_recirculate_subscribe(master, pipe_lde_log[0]);
zlog_recirculate_subscribe(master, pipe_ldpe_log[0]);
+ libagentx_init();
vrf_init(NULL, NULL, NULL, NULL);
access_list_init();
ldp_vty_init();
#include "hook.h"
#include "libfrr.h"
#include "xref.h"
+#include "lib/libagentx.h"
XREF_SETUP();
DEFINE_HOOK(agentx_enabled, (), ());
-static bool agentx_enabled = false;
+//bool agentx_enabled = false;
static struct event_loop *agentx_tm;
static struct event *timeout_thr = NULL;
netsnmp_large_fd_set_cleanup(&lfds);
}
-/* AgentX node. */
-static int config_write_agentx(struct vty *vty);
-static struct cmd_node agentx_node = {
- .name = "smux",
- .node = SMUX_NODE,
- .prompt = "",
- .config_write = config_write_agentx,
-};
-
/* Logging NetSNMP messages */
static int agentx_log_callback(int major, int minor, void *serverarg,
void *clientarg)
return SNMP_ERR_NOERROR;
}
-static int config_write_agentx(struct vty *vty)
-{
- if (agentx_enabled)
- vty_out(vty, "agentx\n");
- return 1;
-}
-
-DEFUN (agentx_enable,
- agentx_enable_cmd,
- "agentx",
- "SNMP AgentX protocol settings\n")
+static int agentx_cli_on(void)
{
if (!agentx_enabled) {
init_snmp(FRR_SMUX_NAME);
hook_call(agentx_enabled);
}
- return CMD_SUCCESS;
+ return 1;
}
-DEFUN (no_agentx,
- no_agentx_cmd,
- "no agentx",
- NO_STR
- "SNMP AgentX protocol settings\n")
+static int agentx_cli_off(void)
{
if (!agentx_enabled)
- return CMD_SUCCESS;
- vty_out(vty, "SNMP AgentX support cannot be disabled once enabled\n");
- return CMD_WARNING_CONFIG_FAILED;
+ return 1;
+ return 0;
}
static int smux_disable(void)
{
agentx_tm = tm;
+ hook_register(agentx_cli_enabled, agentx_cli_on);
+ hook_register(agentx_cli_disabled, agentx_cli_off);
+
netsnmp_enable_subagent();
snmp_disable_log();
snmp_enable_calllog();
agentx_log_callback, NULL);
init_agent(FRR_SMUX_NAME);
- install_node(&agentx_node);
- install_element(CONFIG_NODE, &agentx_enable_cmd);
- install_element(CONFIG_NODE, &no_agentx_cmd);
-
hook_register(frr_early_fini, smux_disable);
}
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0-or-later
+/* SNMP cli support
+ * Copyright (C) 2024 Donald Sharp <sharpd@nvidia.com> NVIDIA Corporation
+ */
+#include <zebra.h>
+
+#include "lib/hook.h"
+#include "lib/libagentx.h"
+#include "command.h"
+
+DEFINE_HOOK(agentx_cli_enabled, (), ());
+DEFINE_HOOK(agentx_cli_disabled, (), ());
+
+bool agentx_enabled;
+
+/* AgentX node. */
+static int config_write_agentx(struct vty *vty)
+{
+ if (agentx_enabled)
+ vty_out(vty, "agentx\n");
+ return 1;
+}
+
+static struct cmd_node agentx_node = {
+ .name = "smux",
+ .node = SMUX_NODE,
+ .prompt = "",
+ .config_write = config_write_agentx,
+};
+
+DEFUN(agentx_enable, agentx_enable_cmd, "agentx",
+ "SNMP AgentX protocol settings\n")
+{
+ if (!hook_have_hooks(agentx_cli_enabled)) {
+ zlog_info(
+ "agentx specified but the agentx Module is not loaded, is this intentional?");
+
+ return CMD_SUCCESS;
+ }
+
+ hook_call(agentx_cli_enabled);
+
+ return CMD_SUCCESS;
+}
+
+DEFUN(no_agentx, no_agentx_cmd, "no agentx",
+ NO_STR "SNMP AgentX protocol settings\n")
+{
+ vty_out(vty, "SNMP AgentX support cannot be disabled once enabled\n");
+ if (!hook_call(agentx_cli_disabled))
+ return CMD_WARNING_CONFIG_FAILED;
+
+ return CMD_SUCCESS;
+}
+
+void libagentx_init(void)
+{
+ agentx_enabled = false;
+
+ install_node(&agentx_node);
+ install_element(CONFIG_NODE, &agentx_enable_cmd);
+ install_element(CONFIG_NODE, &no_agentx_cmd);
+}
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0-or-later
+/* SNMP cli support
+ * Copyright (C) 2024 Donald Sharp <sharpd@nvidia.com> NVIDIA Corporation
+ */
+#ifndef __LIBAGENTX_H__
+#define __LIBAGENTX_H__
+
+extern void libagentx_init(void);
+extern bool agentx_enabled;
+
+DECLARE_HOOK(agentx_cli_enabled, (), ());
+DECLARE_HOOK(agentx_cli_disabled, (), ());
+
+#endif
*/
extern bool smux_enabled(void);
+extern void libagentx_init(void);
extern void smux_init(struct event_loop *tm);
extern void smux_agentx_enable(void);
extern void smux_register_mib(const char *, struct variable *, size_t, int,
lib/ldp_sync.c \
lib/lib_errors.c \
lib/lib_vty.c \
+ lib/libagentx.c \
lib/libfrr.c \
lib/libfrr_trace.c \
lib/linklist.c \
lib/ldp_sync.h \
lib/lib_errors.h \
lib/lib_vty.h \
+ lib/libagentx.h \
lib/libfrr.h \
lib/libfrr_trace.h \
lib/libospf.h \
#include "vrf.h"
#include "bfd.h"
#include "libfrr.h"
+#include "libagentx.h"
#include "ospf6d.h"
#include "ospf6_top.h"
/* thread master */
master = om6->master;
+ libagentx_init();
keychain_init();
ospf6_vrf_init();
access_list_init();
#include "libfrr.h"
#include "routemap.h"
#include "keychain.h"
+#include "libagentx.h"
#include "ospfd/ospfd.h"
#include "ospfd/ospf_interface.h"
master = om->master;
/* Library inits. */
+ libagentx_init();
ospf_debug_init();
ospf_vrf_init();
# not quite obvious...
daemon_flags = {
- "lib/agentx.c": "VTYSH_ISISD|VTYSH_RIPD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ZEBRA",
+ "lib/libagentx.c": "VTYSH_ISISD|VTYSH_RIPD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ZEBRA",
"lib/filter.c": "VTYSH_ACL_SHOW",
"lib/filter_cli.c": "VTYSH_ACL_CONFIG",
"lib/if.c": "VTYSH_INTERFACE",
#include "routemap.h"
#include "bfd.h"
#include "mgmt_be_client.h"
+#include "libagentx.h"
#include "ripd/ripd.h"
#include "ripd/rip_bfd.h"
master = frr_init();
/* Library initialization. */
+ libagentx_init();
rip_error_init();
keychain_init_new(true);
rip_vrf_init();
#include "routemap.h"
#include "routing_nb.h"
#include "mgmt_be_client.h"
+#include "libagentx.h"
#include "zebra/zebra_router.h"
#include "zebra/zebra_errors.h"
zrouter.master = frr_init();
/* Zebra related initialize. */
+ libagentx_init();
zebra_router_init(asic_offload, notify_on_ack, v6_with_v4_nexthop);
zserv_init();
zebra_rib_init();