diff options
-rw-r--r-- | bgpd/Makefile.am | 15 | ||||
-rw-r--r-- | bgpd/bgp_snmp.c | 29 | ||||
-rw-r--r-- | bgpd/bgpd.c | 4 | ||||
-rwxr-xr-x | configure.ac | 1 | ||||
-rw-r--r-- | lib/Makefile.am | 6 | ||||
-rw-r--r-- | lib/agentx.c | 4 | ||||
-rw-r--r-- | lib/smux.c | 4 | ||||
-rw-r--r-- | lib/snmp.c | 2 | ||||
-rw-r--r-- | ospf6d/Makefile.am | 12 | ||||
-rw-r--r-- | ospf6d/ospf6_snmp.c | 27 | ||||
-rw-r--r-- | ospf6d/ospf6d.c | 8 | ||||
-rw-r--r-- | ospfd/Makefile.am | 12 | ||||
-rw-r--r-- | ospfd/ospf_main.c | 3 | ||||
-rw-r--r-- | ospfd/ospf_snmp.c | 31 | ||||
-rw-r--r-- | ospfd/ospfd.h | 1 | ||||
-rw-r--r-- | ripd/Makefile.am | 12 | ||||
-rw-r--r-- | ripd/rip_snmp.c | 28 | ||||
-rw-r--r-- | ripd/ripd.c | 5 | ||||
-rw-r--r-- | ripd/ripd.h | 1 | ||||
-rw-r--r-- | zebra/Makefile.am | 13 | ||||
-rw-r--r-- | zebra/main.c | 4 | ||||
-rw-r--r-- | zebra/zebra_snmp.c | 26 | ||||
-rw-r--r-- | zebra/zserv.h | 1 |
23 files changed, 166 insertions, 83 deletions
diff --git a/bgpd/Makefile.am b/bgpd/Makefile.am index 4050e0162..af6c8faf0 100644 --- a/bgpd/Makefile.am +++ b/bgpd/Makefile.am @@ -67,6 +67,7 @@ INSTALL_SDATA=@INSTALL@ -m 600 AM_CFLAGS = $(WERROR) noinst_LIBRARIES = libbgp.a +module_LTLIBRARIES = sbin_PROGRAMS = bgpd bin_PROGRAMS = bgp_btoa @@ -75,7 +76,7 @@ libbgp_a_SOURCES = \ bgpd.c bgp_fsm.c bgp_aspath.c bgp_community.c bgp_attr.c \ bgp_debug.c bgp_route.c bgp_zebra.c bgp_open.c bgp_routemap.c \ bgp_packet.c bgp_network.c bgp_filter.c bgp_regex.c bgp_clist.c \ - bgp_dump.c bgp_snmp.c bgp_ecommunity.c bgp_lcommunity.c \ + bgp_dump.c bgp_ecommunity.c bgp_lcommunity.c \ bgp_mplsvpn.c bgp_nexthop.c \ bgp_damp.c bgp_table.c bgp_advertise.c bgp_vty.c bgp_mpath.c \ bgp_nht.c bgp_updgrp.c bgp_updgrp_packet.c bgp_updgrp_adv.c bgp_bfd.c \ @@ -94,13 +95,21 @@ noinst_HEADERS = \ $(BGP_VNC_RFAPI_HD) bgp_attr_evpn.h bgp_evpn.h bgp_evpn_vty.h bgp_vpn.h bgpd_SOURCES = bgp_main.c -bgpd_LDADD = libbgp.a $(BGP_VNC_RFP_LIB) ../lib/libfrr.la ../lib/libfrrsnmp.la @LIBCAP@ @LIBM@ +bgpd_LDADD = libbgp.a $(BGP_VNC_RFP_LIB) ../lib/libfrr.la @LIBCAP@ @LIBM@ bgpd_LDFLAGS = $(BGP_VNC_RFP_LD_FLAGS) bgp_btoa_SOURCES = bgp_btoa.c -bgp_btoa_LDADD = libbgp.a $(BGP_VNC_RFP_LIB) ../lib/libfrr.la ../lib/libfrrsnmp.la @LIBCAP@ @LIBM@ +bgp_btoa_LDADD = libbgp.a $(BGP_VNC_RFP_LIB) ../lib/libfrr.la @LIBCAP@ @LIBM@ bgp_btoa_LDFLAGS = $(BGP_VNC_RFP_LD_FLAGS) +if SNMP +module_LTLIBRARIES += bgpd_snmp.la +endif + +bgpd_snmp_la_SOURCES = bgp_snmp.c +bgpd_snmp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic +bgpd_snmp_la_LIBADD = ../lib/libfrrsnmp.la + examplesdir = $(exampledir) dist_examples_DATA = bgpd.conf.sample bgpd.conf.sample2 \ bgpd.conf.vnc.sample diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c index 6896c86e4..f45d68384 100644 --- a/bgpd/bgp_snmp.c +++ b/bgpd/bgp_snmp.c @@ -20,7 +20,6 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include <zebra.h> -#ifdef HAVE_SNMP #include <net-snmp/net-snmp-config.h> #include <net-snmp/net-snmp-includes.h> @@ -31,6 +30,9 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "thread.h" #include "smux.h" #include "filter.h" +#include "hook.h" +#include "libfrr.h" +#include "version.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_table.h" @@ -881,15 +883,26 @@ bgpTrapBackwardTransition (struct peer *peer) return 0; } -void bgp_snmp_init (void); +static int +bgp_snmp_init (struct thread_master *tm) +{ + smux_init (tm); + REGISTER_MIB("mibII/bgp", bgp_variables, variable, bgp_oid); + return 0; +} -void -bgp_snmp_init (void) +static int +bgp_snmp_module_init (void) { hook_register(peer_established, bgpTrapEstablished); hook_register(peer_backward_transition, bgpTrapBackwardTransition); - - smux_init (bm->master); - REGISTER_MIB("mibII/bgp", bgp_variables, variable, bgp_oid); + hook_register(frr_late_init, bgp_snmp_init); + return 0; } -#endif /* HAVE_SNMP */ + +FRR_MODULE_SETUP( + .name = "bgpd_snmp", + .version = FRR_VERSION, + .description = "bgpd AgentX SNMP module", + .init = bgp_snmp_module_init +) diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 031cab902..1733f2956 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -7694,10 +7694,6 @@ bgp_init (void) /* Community list initialize. */ bgp_clist = community_list_init (); -#ifdef HAVE_SNMP - bgp_snmp_init (); -#endif /* HAVE_SNMP */ - /* BFD init */ bgp_bfd_init(); } diff --git a/configure.ac b/configure.ac index 27d456191..466acb25d 100755 --- a/configure.ac +++ b/configure.ac @@ -1337,7 +1337,6 @@ int main(void); ])],[AC_MSG_RESULT(yes)],[ AC_MSG_RESULT(no) AC_MSG_ERROR([--enable-snmp given but not usable])]) - AC_DEFINE(HAVE_SNMP,,SNMP) case "${enable_snmp}" in yes) SNMP_METHOD=agentx diff --git a/lib/Makefile.am b/lib/Makefile.am index 14259f2e0..14b7130c8 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -10,7 +10,7 @@ command_lex.h: command_lex.c @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) command_lex.c; else :; fi command_parse.lo: command_lex.h -lib_LTLIBRARIES = libfrr.la libfrrsnmp.la +lib_LTLIBRARIES = libfrr.la libfrr_la_LDFLAGS = -version-info 0:0:0 libfrr_la_SOURCES = \ @@ -40,6 +40,10 @@ BUILT_SOURCES = route_types.h gitversion.h command_parse.h command_lex.h libfrr_la_LIBADD = @LIBCAP@ +if SNMP +lib_LTLIBRARIES += libfrrsnmp.la +endif + libfrrsnmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) libfrrsnmp_la_LDFLAGS = -version-info 0:0:0 libfrrsnmp_la_LIBADD = libfrr.la $(SNMP_LIBS) diff --git a/lib/agentx.c b/lib/agentx.c index 4175e7ba9..11d5c9385 100644 --- a/lib/agentx.c +++ b/lib/agentx.c @@ -21,7 +21,7 @@ #include <zebra.h> -#if defined HAVE_SNMP && defined SNMP_AGENTX +#ifdef SNMP_AGENTX #include <net-snmp/net-snmp-config.h> #include <net-snmp/net-snmp-includes.h> #include <net-snmp/agent/net-snmp-agent-includes.h> @@ -315,4 +315,4 @@ smux_trap (struct variable *vp, size_t vp_len, return 1; } -#endif /* HAVE_SNMP */ +#endif /* SNMP_AGENTX */ diff --git a/lib/smux.c b/lib/smux.c index 3abfadcd2..370b8f138 100644 --- a/lib/smux.c +++ b/lib/smux.c @@ -21,7 +21,7 @@ #include <zebra.h> -#if defined HAVE_SNMP && defined SNMP_SMUX +#ifdef SNMP_SMUX #include <net-snmp/net-snmp-config.h> #include <net-snmp/net-snmp-includes.h> @@ -1445,4 +1445,4 @@ smux_start(void) /* Schedule first connection. */ smux_event (SMUX_SCHEDULE, 0); } -#endif /* HAVE_SNMP */ +#endif /* SNMP_SMUX */ diff --git a/lib/snmp.c b/lib/snmp.c index f6f9845e2..1cbd41c72 100644 --- a/lib/snmp.c +++ b/lib/snmp.c @@ -21,7 +21,6 @@ #include <zebra.h> -#ifdef HAVE_SNMP #include <net-snmp/net-snmp-config.h> #include <net-snmp/net-snmp-includes.h> @@ -130,4 +129,3 @@ smux_header_table (struct variable *v, oid *name, size_t *length, int exact, return MATCH_SUCCEEDED; } -#endif /* HAVE_SNMP */ diff --git a/ospf6d/Makefile.am b/ospf6d/Makefile.am index 30268c688..933a97ca8 100644 --- a/ospf6d/Makefile.am +++ b/ospf6d/Makefile.am @@ -7,6 +7,7 @@ INSTALL_SDATA=@INSTALL@ -m 600 AM_CFLAGS = $(WERROR) noinst_LIBRARIES = libospf6.a +module_LTLIBRARIES = sbin_PROGRAMS = ospf6d libospf6_a_SOURCES = \ @@ -14,7 +15,7 @@ libospf6_a_SOURCES = \ ospf6_network.c ospf6_message.c ospf6_lsa.c ospf6_lsdb.c \ ospf6_top.c ospf6_area.c ospf6_interface.c ospf6_neighbor.c \ ospf6_flood.c ospf6_route.c ospf6_intra.c ospf6_zebra.c \ - ospf6_spf.c ospf6_proto.c ospf6_asbr.c ospf6_abr.c ospf6_snmp.c \ + ospf6_spf.c ospf6_proto.c ospf6_asbr.c ospf6_abr.c \ ospf6d.c ospf6_bfd.c noinst_HEADERS = \ @@ -28,7 +29,14 @@ noinst_HEADERS = \ ospf6d_SOURCES = \ ospf6_main.c $(libospf6_a_SOURCES) -ospf6d_LDADD = ../lib/libfrr.la ../lib/libfrrsnmp.la @LIBCAP@ +ospf6d_LDADD = ../lib/libfrr.la @LIBCAP@ + +if SNMP +module_LTLIBRARIES += ospf6d_snmp.la +endif +ospf6d_snmp_la_SOURCES = ospf6_snmp.c +ospf6d_snmp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic +ospf6d_snmp_la_LIBADD = ../lib/libfrrsnmp.la examplesdir = $(exampledir) dist_examples_DATA = ospf6d.conf.sample diff --git a/ospf6d/ospf6_snmp.c b/ospf6d/ospf6_snmp.c index 57fc94fd5..96f1e3dd2 100644 --- a/ospf6d/ospf6_snmp.c +++ b/ospf6d/ospf6_snmp.c @@ -21,8 +21,6 @@ #include <zebra.h> -#ifdef HAVE_SNMP - #include <net-snmp/net-snmp-config.h> #include <net-snmp/net-snmp-includes.h> @@ -32,6 +30,8 @@ #include "vector.h" #include "vrf.h" #include "smux.h" +#include "libfrr.h" +#include "version.h" #include "ospf6_proto.h" #include "ospf6_lsa.h" @@ -46,8 +46,6 @@ #include "ospf6_asbr.h" #include "ospf6d.h" -void ospf6_snmp_init (struct thread_master *master); - /* OSPFv3-MIB */ #define OSPFv3MIB 1,3,6,1,2,1,191 @@ -1194,15 +1192,26 @@ ospf6TrapIfStateChange (struct ospf6_interface *oi, } /* Register OSPFv3-MIB. */ -void +static int ospf6_snmp_init (struct thread_master *master) { - hook_register(ospf6_interface_change, ospf6TrapIfStateChange); - hook_register(ospf6_neighbor_change, ospf6TrapNbrStateChange); - smux_init (master); REGISTER_MIB ("OSPFv3MIB", ospfv3_variables, variable, ospfv3_oid); + return 0; } -#endif /* HAVE_SNMP */ +static int +ospf6_snmp_module_init (void) +{ + hook_register(ospf6_interface_change, ospf6TrapIfStateChange); + hook_register(ospf6_neighbor_change, ospf6TrapNbrStateChange); + hook_register(frr_late_init, ospf6_snmp_init); + return 0; +} +FRR_MODULE_SETUP( + .name = "ospf6d_snmp", + .version = FRR_VERSION, + .description = "ospf6d AgentX SNMP module", + .init = ospf6_snmp_module_init, +) diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c index 9a5868f57..036cc6d4c 100644 --- a/ospf6d/ospf6d.c +++ b/ospf6d/ospf6d.c @@ -45,10 +45,6 @@ #include "ospf6d.h" #include "ospf6_bfd.h" -#ifdef HAVE_SNMP -extern void ospf6_snmp_init (struct thread_master *); -#endif /*HAVE_SNMP*/ - char ospf6_daemon_version[] = OSPF6_DAEMON_VERSION; struct route_node * @@ -1215,10 +1211,6 @@ ospf6_init (void) ospf6_asbr_init (); ospf6_abr_init (); -#ifdef HAVE_SNMP - ospf6_snmp_init (master); -#endif /*HAVE_SNMP*/ - ospf6_bfd_init(); install_node (&debug_node, config_write_ospf6_debug); diff --git a/ospfd/Makefile.am b/ospfd/Makefile.am index 52c7dade7..e9d0ed219 100644 --- a/ospfd/Makefile.am +++ b/ospfd/Makefile.am @@ -6,13 +6,14 @@ DEFS = @DEFS@ $(LOCAL_OPTS) -DSYSCONFDIR=\"$(sysconfdir)/\" INSTALL_SDATA=@INSTALL@ -m 600 noinst_LIBRARIES = libfrrospf.a +module_LTLIBRARIES = sbin_PROGRAMS = ospfd libfrrospf_a_SOURCES = \ ospfd.c ospf_zebra.c ospf_interface.c ospf_ism.c ospf_neighbor.c \ ospf_nsm.c ospf_dump.c ospf_network.c ospf_packet.c ospf_lsa.c \ ospf_spf.c ospf_route.c ospf_ase.c ospf_abr.c ospf_ia.c ospf_flood.c \ - ospf_lsdb.c ospf_asbr.c ospf_routemap.c ospf_snmp.c \ + ospf_lsdb.c ospf_asbr.c ospf_routemap.c \ ospf_opaque.c ospf_te.c ospf_ri.c ospf_vty.c ospf_api.c ospf_apiserver.c \ ospf_bfd.c ospf_memory.c ospf_dump_api.c @@ -31,7 +32,14 @@ noinst_HEADERS = \ ospfd_SOURCES = ospf_main.c -ospfd_LDADD = libfrrospf.a ../lib/libfrr.la ../lib/libfrrsnmp.la @LIBCAP@ @LIBM@ +ospfd_LDADD = libfrrospf.a ../lib/libfrr.la @LIBCAP@ @LIBM@ + +if SNMP +module_LTLIBRARIES += ospfd_snmp.la +endif +ospfd_snmp_la_SOURCES = ospf_snmp.c +ospfd_snmp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic +ospfd_snmp_la_LIBADD = ../lib/libfrrsnmp.la EXTRA_DIST = OSPF-MIB.txt OSPF-TRAP-MIB.txt ChangeLog.opaque.txt diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c index f462c207e..38718b35d 100644 --- a/ospfd/ospf_main.c +++ b/ospfd/ospf_main.c @@ -225,9 +225,6 @@ main (int argc, char **argv) ospf_bfd_init(); ospf_route_map_init (); -#ifdef HAVE_SNMP - ospf_snmp_init (); -#endif /* HAVE_SNMP */ ospf_opaque_init (); /* Need to initialize the default ospf structure, so the interface mode diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index b5813d7d5..32449d559 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -24,7 +24,6 @@ #include <zebra.h> -#ifdef HAVE_SNMP #include <net-snmp/net-snmp-config.h> #include <net-snmp/net-snmp-includes.h> @@ -35,6 +34,8 @@ #include "command.h" #include "memory.h" #include "smux.h" +#include "libfrr.h" +#include "version.h" #include "ospfd/ospfd.h" #include "ospfd/ospf_interface.h" @@ -2781,8 +2782,18 @@ ospf_snmp_ism_change (struct ospf_interface *oi, } /* Register OSPF2-MIB. */ -void -ospf_snmp_init () +static int +ospf_snmp_init (struct thread_master *tm) +{ + ospf_snmp_iflist = list_new (); + ospf_snmp_vl_table = route_table_init (); + smux_init (tm); + REGISTER_MIB("mibII/ospf", ospf_variables, variable, ospf_oid); + return 0; +} + +static int +ospf_snmp_module_init (void) { hook_register(ospf_if_update, ospf_snmp_if_update); hook_register(ospf_if_delete, ospf_snmp_if_delete); @@ -2791,9 +2802,13 @@ ospf_snmp_init () hook_register(ospf_ism_change, ospf_snmp_ism_change); hook_register(ospf_nsm_change, ospf_snmp_nsm_change); - ospf_snmp_iflist = list_new (); - ospf_snmp_vl_table = route_table_init (); - smux_init (om->master); - REGISTER_MIB("mibII/ospf", ospf_variables, variable, ospf_oid); + hook_register(frr_late_init, ospf_snmp_init); + return 0; } -#endif /* HAVE_SNMP */ + +FRR_MODULE_SETUP( + .name = "ospfd_snmp", + .version = FRR_VERSION, + .description = "ospfd AgentX SNMP module", + .init = ospf_snmp_module_init, +) diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h index a3bd0ca12..9198d5c62 100644 --- a/ospfd/ospfd.h +++ b/ospfd/ospfd.h @@ -574,7 +574,6 @@ extern void ospf_area_add_if (struct ospf_area *, struct ospf_interface *); extern void ospf_area_del_if (struct ospf_area *, struct ospf_interface *); extern void ospf_route_map_init (void); -extern void ospf_snmp_init (void); extern void ospf_master_init (struct thread_master *master); diff --git a/ripd/Makefile.am b/ripd/Makefile.am index 47c471aeb..827869121 100644 --- a/ripd/Makefile.am +++ b/ripd/Makefile.am @@ -7,11 +7,12 @@ INSTALL_SDATA=@INSTALL@ -m 600 AM_CFLAGS = $(WERROR) noinst_LIBRARIES = librip.a +module_LTLIBRARIES = sbin_PROGRAMS = ripd librip_a_SOURCES = \ rip_memory.c \ - ripd.c rip_zebra.c rip_interface.c rip_debug.c rip_snmp.c \ + ripd.c rip_zebra.c rip_interface.c rip_debug.c \ rip_routemap.c rip_peer.c rip_offset.c noinst_HEADERS = \ @@ -21,7 +22,14 @@ noinst_HEADERS = \ ripd_SOURCES = \ rip_main.c $(librip_a_SOURCES) -ripd_LDADD = ../lib/libfrr.la ../lib/libfrrsnmp.la @LIBCAP@ +ripd_LDADD = ../lib/libfrr.la @LIBCAP@ + +if SNMP +module_LTLIBRARIES += ripd_snmp.la +endif +ripd_snmp_la_SOURCES = rip_snmp.c +ripd_snmp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic +ripd_snmp_la_LIBADD = ../lib/libfrrsnmp.la examplesdir = $(exampledir) dist_examples_DATA = ripd.conf.sample diff --git a/ripd/rip_snmp.c b/ripd/rip_snmp.c index bdae0409d..06cd3cef6 100644 --- a/ripd/rip_snmp.c +++ b/ripd/rip_snmp.c @@ -21,7 +21,6 @@ #include <zebra.h> -#ifdef HAVE_SNMP #include <net-snmp/net-snmp-config.h> #include <net-snmp/net-snmp-includes.h> @@ -32,6 +31,8 @@ #include "command.h" #include "table.h" #include "smux.h" +#include "libfrr.h" +#include "version.h" #include "ripd/ripd.h" @@ -587,14 +588,29 @@ rip2PeerTable (struct variable *v, oid name[], size_t *length, } /* Register RIPv2-MIB. */ -void -rip_snmp_init () +static int +rip_snmp_init (struct thread_master *master) { rip_ifaddr_table = route_table_init (); - hook_register(rip_ifaddr_add, rip_snmp_ifaddr_add); - hook_register(rip_ifaddr_del, rip_snmp_ifaddr_del); smux_init (master); REGISTER_MIB("mibII/rip", rip_variables, variable, rip_oid); + return 0; } -#endif /* HAVE_SNMP */ + +static int +rip_snmp_module_init (void) +{ + hook_register(rip_ifaddr_add, rip_snmp_ifaddr_add); + hook_register(rip_ifaddr_del, rip_snmp_ifaddr_del); + + hook_register(frr_late_init, rip_snmp_init); + return 0; +} + +FRR_MODULE_SETUP( + .name = "ripd_snmp", + .version = FRR_VERSION, + .description = "ripd AgentX SNMP module", + .init = rip_snmp_module_init, +) diff --git a/ripd/ripd.c b/ripd/ripd.c index 82e460ced..0eaa909fd 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -4064,11 +4064,6 @@ rip_init (void) /* Debug related init. */ rip_debug_init (); - /* SNMP init. */ -#ifdef HAVE_SNMP - rip_snmp_init (); -#endif /* HAVE_SNMP */ - /* Access list install. */ access_list_init (); access_list_add_hook (rip_distribute_update_all_wrapper); diff --git a/ripd/ripd.h b/ripd/ripd.h index 66113cdc9..eeb008e3d 100644 --- a/ripd/ripd.h +++ b/ripd/ripd.h @@ -392,7 +392,6 @@ extern void rip_if_init (void); extern void rip_if_down_all (void); extern void rip_route_map_init (void); extern void rip_route_map_reset (void); -extern void rip_snmp_init (void); extern void rip_zclient_init(struct thread_master *); extern void rip_zclient_reset (void); extern void rip_offset_init (void); diff --git a/zebra/Makefile.am b/zebra/Makefile.am index 4711c5e0b..5958f63b5 100644 --- a/zebra/Makefile.am +++ b/zebra/Makefile.am @@ -34,13 +34,13 @@ endif AM_CFLAGS = $(WERROR) sbin_PROGRAMS = zebra - noinst_PROGRAMS = testzebra +module_LTLIBRARIES = zebra_SOURCES = \ zebra_memory.c \ zserv.c main.c interface.c connected.c zebra_rib.c zebra_routemap.c \ - redistribute.c debug.c rtadv.c zebra_snmp.c zebra_vty.c \ + redistribute.c debug.c rtadv.c zebra_vty.c \ irdp_main.c irdp_interface.c irdp_packet.c router-id.c zebra_fpm.c \ $(othersrc) zebra_ptm.c zebra_rnh.c zebra_ptm_redistribute.c \ zebra_ns.c zebra_vrf.c zebra_static.c zebra_mpls.c zebra_mpls_vty.c \ @@ -62,12 +62,19 @@ noinst_HEADERS = \ zebra_ns.h zebra_vrf.h ioctl_solaris.h zebra_static.h zebra_mpls.h \ kernel_netlink.h if_netlink.h zebra_mroute.h label_manager.h -zebra_LDADD = $(otherobj) ../lib/libfrr.la ../lib/libfrrsnmp.la $(LIBCAP) $(Q_FPM_PB_CLIENT_LDOPTS) +zebra_LDADD = $(otherobj) ../lib/libfrr.la $(LIBCAP) $(Q_FPM_PB_CLIENT_LDOPTS) testzebra_LDADD = ../lib/libfrr.la $(LIBCAP) zebra_DEPENDENCIES = $(otherobj) +if SNMP +module_LTLIBRARIES += zebra_snmp.la +endif +zebra_snmp_la_SOURCES = zebra_snmp.c +zebra_snmp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic +zebra_snmp_la_LIBADD = ../lib/libfrrsnmp.la + EXTRA_DIST = if_ioctl.c if_ioctl_solaris.c if_netlink.c \ if_sysctl.c ipforward_proc.c \ ipforward_solaris.c ipforward_sysctl.c rt_netlink.c \ diff --git a/zebra/main.c b/zebra/main.c index 26e66f961..ac19c3410 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -329,10 +329,6 @@ main (int argc, char **argv) /* Initialize NS( and implicitly the VRF module), and make kernel routing socket. */ zebra_ns_init (); -#ifdef HAVE_SNMP - zebra_snmp_init (); -#endif /* HAVE_SNMP */ - #ifdef HAVE_FPM zfpm_init (zebrad.master, 1, 0, fpm_format); #else diff --git a/zebra/zebra_snmp.c b/zebra/zebra_snmp.c index 19364b5b9..8adb8873d 100644 --- a/zebra/zebra_snmp.c +++ b/zebra/zebra_snmp.c @@ -25,7 +25,6 @@ #include <zebra.h> -#ifdef HAVE_SNMP #include <net-snmp/net-snmp-config.h> #include <net-snmp/net-snmp-includes.h> @@ -36,6 +35,9 @@ #include "smux.h" #include "table.h" #include "vrf.h" +#include "hook.h" +#include "libfrr.h" +#include "version.h" #include "zebra/rib.h" #include "zebra/zserv.h" @@ -571,10 +573,24 @@ ipCidrTable (struct variable *v, oid objid[], size_t *objid_len, return NULL; } -void -zebra_snmp_init () +static int +zebra_snmp_init (struct thread_master *tm) { - smux_init (zebrad.master); + smux_init (tm); REGISTER_MIB("mibII/ipforward", zebra_variables, variable, ipfw_oid); + return 0; +} + +static int +zebra_snmp_module_init (void) +{ + hook_register(frr_late_init, zebra_snmp_init); + return 0; } -#endif /* HAVE_SNMP */ + +FRR_MODULE_SETUP( + .name = "zebra_snmp", + .version = FRR_VERSION, + .description = "zebra AgentX SNMP module", + .init = zebra_snmp_module_init, +) diff --git a/zebra/zserv.h b/zebra/zserv.h index 9e3473823..cd1948373 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -149,7 +149,6 @@ extern void route_read (struct zebra_ns *); extern void kernel_init (struct zebra_ns *); extern void kernel_terminate (struct zebra_ns *); extern void zebra_route_map_init (void); -extern void zebra_snmp_init (void); extern void zebra_vty_init (void); extern int zsend_vrf_add (struct zserv *, struct zebra_vrf *); |