summaryrefslogtreecommitdiffstats
path: root/ospf6d
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-04-04 17:55:00 +0200
committerGitHub <noreply@github.com>2017-04-04 17:55:00 +0200
commitb3cfe637a66a5de00c72125f5fa051155ccb4a29 (patch)
tree16af08958977f24dc9b563bca5bb7a003da0f040 /ospf6d
parentMerge pull request #322 from qlyoung/fix-distance-commands (diff)
parentvtysh: handle "show modules" like "show memory" (diff)
downloadfrr-b3cfe637a66a5de00c72125f5fa051155ccb4a29.tar.xz
frr-b3cfe637a66a5de00c72125f5fa051155ccb4a29.zip
Merge pull request #294 from opensourcerouting/modules
Loadable module support
Diffstat (limited to 'ospf6d')
-rw-r--r--ospf6d/Makefile.am12
-rw-r--r--ospf6d/ospf6_interface.c15
-rw-r--r--ospf6d/ospf6_interface.h5
-rw-r--r--ospf6d/ospf6_neighbor.c13
-rw-r--r--ospf6d/ospf6_neighbor.h6
-rw-r--r--ospf6d/ospf6_snmp.c49
-rw-r--r--ospf6d/ospf6_snmp.h31
-rw-r--r--ospf6d/ospf6d.c8
8 files changed, 70 insertions, 69 deletions
diff --git a/ospf6d/Makefile.am b/ospf6d/Makefile.am
index 06fc7a30a..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 = \
@@ -22,7 +23,7 @@ noinst_HEADERS = \
ospf6_network.h ospf6_message.h ospf6_lsa.h ospf6_lsdb.h \
ospf6_top.h ospf6_area.h ospf6_interface.h ospf6_neighbor.h \
ospf6_flood.h ospf6_route.h ospf6_intra.h ospf6_zebra.h \
- ospf6_spf.h ospf6_proto.h ospf6_asbr.h ospf6_abr.h ospf6_snmp.h \
+ ospf6_spf.h ospf6_proto.h ospf6_asbr.h ospf6_abr.h \
ospf6d.h ospf6_bfd.h
ospf6d_SOURCES = \
@@ -30,5 +31,12 @@ ospf6d_SOURCES = \
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_interface.c b/ospf6d/ospf6_interface.c
index 8e0779df9..8cf7f4afa 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -41,12 +41,14 @@
#include "ospf6_neighbor.h"
#include "ospf6_intra.h"
#include "ospf6_spf.h"
-#include "ospf6_snmp.h"
#include "ospf6d.h"
#include "ospf6_bfd.h"
DEFINE_MTYPE_STATIC(OSPF6D, CFG_PLIST_NAME, "configured prefix list names")
DEFINE_QOBJ_TYPE(ospf6_interface)
+DEFINE_HOOK(ospf6_interface_change,
+ (struct ospf6_interface *oi, int state, int old_state),
+ (oi, state, old_state))
unsigned char conf_debug_ospf6_interface = 0;
@@ -518,16 +520,7 @@ ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area);
}
-#ifdef HAVE_SNMP
- /* Terminal state or regression */
- if ((next_state == OSPF6_INTERFACE_POINTTOPOINT) ||
- (next_state == OSPF6_INTERFACE_DROTHER) ||
- (next_state == OSPF6_INTERFACE_BDR) ||
- (next_state == OSPF6_INTERFACE_DR) ||
- (next_state < prev_state))
- ospf6TrapIfStateChange (oi);
-#endif
-
+ hook_call(ospf6_interface_change, oi, next_state, prev_state);
}
diff --git a/ospf6d/ospf6_interface.h b/ospf6d/ospf6_interface.h
index 179477a63..846cde419 100644
--- a/ospf6d/ospf6_interface.h
+++ b/ospf6d/ospf6_interface.h
@@ -23,6 +23,7 @@
#define OSPF6_INTERFACE_H
#include "qobj.h"
+#include "hook.h"
#include "if.h"
/* Debug option */
@@ -182,4 +183,8 @@ extern void install_element_ospf6_clear_interface (void);
extern int config_write_ospf6_debug_interface (struct vty *vty);
extern void install_element_ospf6_debug_interface (void);
+DECLARE_HOOK(ospf6_interface_change,
+ (struct ospf6_interface *oi, int state, int old_state),
+ (oi, state, old_state))
+
#endif /* OSPF6_INTERFACE_H */
diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c
index ec79a1552..118210dfc 100644
--- a/ospf6d/ospf6_neighbor.c
+++ b/ospf6d/ospf6_neighbor.c
@@ -38,7 +38,6 @@
#include "ospf6_neighbor.h"
#include "ospf6_intra.h"
#include "ospf6_flood.h"
-#include "ospf6_snmp.h"
#include "ospf6d.h"
#include "ospf6_bfd.h"
#include "ospf6_abr.h"
@@ -47,6 +46,10 @@
#include "ospf6_spf.h"
#include "ospf6_zebra.h"
+DEFINE_HOOK(ospf6_neighbor_change,
+ (struct ospf6_neighbor *on, int state, int next_state),
+ (on, state, next_state))
+
unsigned char conf_debug_ospf6_neighbor = 0;
const char *ospf6_neighbor_state_str[] =
@@ -202,13 +205,7 @@ ospf6_neighbor_state_change (u_char next_state, struct ospf6_neighbor *on, int e
next_state != OSPF6_NEIGHBOR_LOADING))
ospf6_maxage_remove (on->ospf6_if->area->ospf6);
-#ifdef HAVE_SNMP
- /* Terminal state or regression */
- if ((next_state == OSPF6_NEIGHBOR_FULL) ||
- (next_state == OSPF6_NEIGHBOR_TWOWAY) ||
- (next_state < prev_state))
- ospf6TrapNbrStateChange (on);
-#endif
+ hook_call(ospf6_neighbor_change, on, next_state, prev_state);
ospf6_bfd_trigger_event(on, prev_state, next_state);
}
diff --git a/ospf6d/ospf6_neighbor.h b/ospf6d/ospf6_neighbor.h
index f9e197e99..c275ff830 100644
--- a/ospf6d/ospf6_neighbor.h
+++ b/ospf6d/ospf6_neighbor.h
@@ -22,6 +22,8 @@
#ifndef OSPF6_NEIGHBOR_H
#define OSPF6_NEIGHBOR_H
+#include "hook.h"
+
/* Debug option */
extern unsigned char conf_debug_ospf6_neighbor;
#define OSPF6_DEBUG_NEIGHBOR_STATE 0x01
@@ -179,4 +181,8 @@ extern void ospf6_neighbor_init (void);
extern int config_write_ospf6_debug_neighbor (struct vty *vty);
extern void install_element_ospf6_debug_neighbor (void);
+DECLARE_HOOK(ospf6_neighbor_change,
+ (struct ospf6_neighbor *on, int state, int next_state),
+ (on, state, next_state))
+
#endif /* OSPF6_NEIGHBOR_H */
diff --git a/ospf6d/ospf6_snmp.c b/ospf6d/ospf6_snmp.c
index 86cfd17c8..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"
@@ -45,7 +45,6 @@
#include "ospf6_abr.h"
#include "ospf6_asbr.h"
#include "ospf6d.h"
-#include "ospf6_snmp.h"
/* OSPFv3-MIB */
#define OSPFv3MIB 1,3,6,1,2,1,191
@@ -1139,11 +1138,18 @@ static struct trap_object ospf6IfTrapList[] =
{4, {1, 7, 1, OSPFv3IFAREAID}}
};
-void
-ospf6TrapNbrStateChange (struct ospf6_neighbor *on)
+static int
+ospf6TrapNbrStateChange (struct ospf6_neighbor *on,
+ int next_state, int prev_state)
{
oid index[3];
+ /* Terminal state or regression */
+ if ((next_state != OSPF6_NEIGHBOR_FULL) &&
+ (next_state != OSPF6_NEIGHBOR_TWOWAY) &&
+ (next_state >= prev_state))
+ return 0;
+
index[0] = on->ospf6_if->interface->ifindex;
index[1] = on->ospf6_if->instance_id;
index[2] = ntohl (on->router_id);
@@ -1155,13 +1161,23 @@ ospf6TrapNbrStateChange (struct ospf6_neighbor *on)
ospf6NbrTrapList,
sizeof ospf6NbrTrapList / sizeof (struct trap_object),
NBRSTATECHANGE);
+ return 0;
}
-void
-ospf6TrapIfStateChange (struct ospf6_interface *oi)
+static int
+ospf6TrapIfStateChange (struct ospf6_interface *oi,
+ int next_state, int prev_state)
{
oid index[2];
+ /* Terminal state or regression */
+ if ((next_state != OSPF6_INTERFACE_POINTTOPOINT) &&
+ (next_state != OSPF6_INTERFACE_DROTHER) &&
+ (next_state != OSPF6_INTERFACE_BDR) &&
+ (next_state != OSPF6_INTERFACE_DR) &&
+ (next_state >= prev_state))
+ return 0;
+
index[0] = oi->interface->ifindex;
index[1] = oi->instance_id;
@@ -1172,15 +1188,30 @@ ospf6TrapIfStateChange (struct ospf6_interface *oi)
ospf6IfTrapList,
sizeof ospf6IfTrapList / sizeof (struct trap_object),
IFSTATECHANGE);
+ return 0;
}
/* Register OSPFv3-MIB. */
-void
+static int
ospf6_snmp_init (struct thread_master *master)
{
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/ospf6_snmp.h b/ospf6d/ospf6_snmp.h
deleted file mode 100644
index fa1b0c37a..000000000
--- a/ospf6d/ospf6_snmp.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* OSPFv3 SNMP support
- * Copyright (C) 2004 Yasuhiro Ohara
- *
- * 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 OSPF6_SNMP_H
-#define OSPF6_SNMP_H
-
-extern void ospf6TrapNbrStateChange (struct ospf6_neighbor *);
-extern void ospf6TrapIfStateChange (struct ospf6_interface *);
-extern void ospf6_snmp_init (struct thread_master *);
-
-#endif /*OSPF6_SNMP_H*/
-
-
diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c
index 2aaed5fcb..036cc6d4c 100644
--- a/ospf6d/ospf6d.c
+++ b/ospf6d/ospf6d.c
@@ -45,10 +45,6 @@
#include "ospf6d.h"
#include "ospf6_bfd.h"
-#ifdef HAVE_SNMP
-#include "ospf6_snmp.h"
-#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);