[ospfd] Implement new ospf router subcommand "log-adjacency-changes [detail]"
2006-06-28 Erik Muller <erikm@internap.com>
* ospfd.h: Define 2 new struct ospf config flags:
OSPF_LOG_ADJACENCY_CHANGES and OSPF_LOG_ADJACENCY_DETAIL
* ospf_nsm.c (nsm_change_state): Log adjacency changes if
requested.
* ospf_vty.c (ospf_log_adjacency_changes): New command function
to implement ospf subcommand "log-adjacency-changes [detail]".
(no_ospf_log_adjacency_changes) Turn off log-adjacency-changes.
(show_ip_ospf) Show whether adjacency changes are logged.
(ospf_config_write) Add "log-adjacency-changes [detail]" to config.
(ospf_vty_init) Add ospf_log_adjacency_changes and
no_ospf_log_adjacency_changes.
* ospfd.texi: Document new ospf router subcommand
"log-adjacency-changes [detail]".
diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c
index 8a93f0e..878ab56 100644
--- a/ospfd/ospf_nsm.c
+++ b/ospfd/ospf_nsm.c
@@ -697,7 +697,17 @@
if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
vl_area = ospf_area_lookup_by_area_id (oi->ospf, oi->vl_data->vl_area_id);
-
+
+ /* Optionally notify about adjacency changes */
+ if (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_CHANGES) &&
+ (old_state != state) &&
+ (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL) ||
+ (state == NSM_Full) || (state < old_state)))
+ zlog_notice("AdjChg: Nbr %s on %s: %s -> %s",
+ inet_ntoa (nbr->router_id), IF_NAME (nbr->oi),
+ LOOKUP (ospf_nsm_state_msg, old_state),
+ LOOKUP (ospf_nsm_state_msg, state));
+
#ifdef HAVE_SNMP
/* Terminal state or regression */
if ((state == NSM_Full) || (state == NSM_TwoWay) || (state < old_state))