---
bgpd/Makefile.am | 9 +++++++--
bgpd/bgp_snmp.c | 24 ++++++++++++++++++------
bgpd/bgp_snmp.h | 31 -------------------------------
bgpd/bgpd.c | 9 +++------
bgpd/bgpd.h | 3 +++
5 files changed, 31 insertions(+), 45 deletions(-)
delete mode 100644 bgpd/bgp_snmp.h
diff --git a/bgpd/Makefile.am b/bgpd/Makefile.am
index 608d018..e8bd218 100644
--- a/bgpd/Makefile.am
+++ b/bgpd/Makefile.am
@@ -15,7 +15,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_mplsvpn.c bgp_nexthop.c \
+ bgp_dump.c bgp_ecommunity.c bgp_mplsvpn.c bgp_nexthop.c \
bgp_damp.c bgp_table.c bgp_advertise.c bgp_vty.c bgp_mpath.c \
bgp_encap.c bgp_encap_tlv.c
@@ -25,7 +25,7 @@ noinst_HEADERS = \
bgp_network.h bgp_open.h bgp_packet.h bgp_regex.h bgp_route.h \
bgpd.h bgp_filter.h bgp_clist.h bgp_dump.h bgp_zebra.h \
bgp_ecommunity.h bgp_mplsvpn.h bgp_nexthop.h bgp_damp.h bgp_table.h \
- bgp_advertise.h bgp_snmp.h bgp_vty.h bgp_mpath.h \
+ bgp_advertise.h bgp_vty.h bgp_mpath.h \
bgp_encap.h bgp_encap_tlv.h bgp_encap_types.h
bgpd_SOURCES = bgp_main.c
@@ -34,6 +34,11 @@ bgpd_LDADD = libbgp.a ../lib/libzebra.la @LIBCAP@ @LIBM@
bgp_btoa_SOURCES = bgp_btoa.c
bgp_btoa_LDADD = libbgp.a ../lib/libzebra.la @LIBCAP@ @LIBM@
+lib_LTLIBRARIES = bgp_snmp.la
+
+bgp_snmp_la_SOURCES = bgp_snmp.c
+bgp_snmp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic
+
examplesdir = $(exampledir)
dist_examples_DATA = bgpd.conf.sample bgpd.conf.sample2
diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c
index 3454e14..4d2eaf6 100644
--- a/bgpd/bgp_snmp.c
+++ b/bgpd/bgp_snmp.c
@@ -38,7 +38,6 @@ Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA
#include "bgpd/bgp_attr.h"
#include "bgpd/bgp_route.h"
#include "bgpd/bgp_fsm.h"
-#include "bgpd/bgp_snmp.h"
/* BGP4-MIB described in RFC1657. */
#define BGP4MIB 1,3,6,1,2,1,15
@@ -878,13 +877,26 @@ bgpTrapBackwardTransition (void *arg, struct peer *peer)
BGPBACKWARDTRANSITION);
}
-void
-bgp_snmp_init (void)
+static void
+bgp_snmp_init (void *arg, struct bgp_master *bm)
{
- hook_register(peer_established, bgpTrapEstablished, NULL);
- hook_register(peer_backward_transition, bgpTrapBackwardTransition, NULL);
-
smux_init (bm->master);
REGISTER_MIB("mibII/bgp", bgp_variables, variable, bgp_oid);
}
+
+static int
+bgp_snmp_plugin_init (void)
+{
+ hook_register(peer_established, bgpTrapEstablished, NULL);
+ hook_register(peer_backward_transition, bgpTrapBackwardTransition, NULL);
+ hook_register(bgp_init, bgp_snmp_init, NULL);
+ return 0;
+}
+
+QUAGGA_PLUGIN_SETUP(
+ .name = "bgpd AgentX SNMP plugin",
+ //.compat_list = ";bgpd;",
+ .init = bgp_snmp_plugin_init
+)
+
#endif /* HAVE_SNMP */
diff --git a/bgpd/bgp_snmp.h b/bgpd/bgp_snmp.h
deleted file mode 100644
index bbb0d16..0000000
--- a/bgpd/bgp_snmp.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* BGP4 SNMP support
- Copyright (C) 1999, 2000 Kunihiro Ishiguro
-
-This file is part of GNU Zebra.
-
-GNU Zebra is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-GNU Zebra is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Zebra; see the file COPYING. If not, write to the Free
-Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA. */
-
-#ifndef _QUAGGA_BGP_SNMP_H
-#define _QUAGGA_BGP_SNMP_H
-
-extern void bgp_snmp_init (void);
-
-#if 0
-extern void bgpTrapEstablished (struct peer *);
-extern void bgpTrapBackwardTransition (struct peer *);
-#endif
-
-#endif /* _QUAGGA_BGP_SNMP_H */
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 5886cc6..9fc240d 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -61,9 +61,8 @@ Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA
#include "bgpd/bgp_network.h"
#include "bgpd/bgp_vty.h"
#include "bgpd/bgp_mpath.h"
-#ifdef HAVE_SNMP
-#include "bgpd/bgp_snmp.h"
-#endif /* HAVE_SNMP */
+
+DEFINE_HOOK(bgp_init, (struct bgp_master *bm), (bm))
/* BGP process wide configuration. */
static struct bgp_master bgp_master;
@@ -5663,9 +5662,7 @@ bgp_init (void)
/* Community list initialize. */
bgp_clist = community_list_init ();
-#ifdef HAVE_SNMP
- bgp_snmp_init ();
-#endif /* HAVE_SNMP */
+ hook_call(bgp_init, bm);
}
void
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 55ac2bb..7759cab 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -24,6 +24,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA
/* For union sockunion. */
#include "sockunion.h"
#include "bgp_memory.h"
+#include "hook.h"
/* Typedef BGP specific types. */
typedef u_int32_t as_t;
@@ -832,6 +833,8 @@ enum bgp_clear_type
extern struct bgp_master *bm;
+DECLARE_HOOK(bgp_init, (struct bgp_master *bm), (bm))
+
/* Prototypes. */
extern void bgp_terminate (void);
extern void bgp_reset (void);
--
2.7.3
_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev