Merge pull request #5186 from opensourcerouting/nb-cbs-reorg

northbound callbacks reorganization
This commit is contained in:
Quentin Young 2019-10-30 13:59:13 -04:00 committed by GitHub
commit e64f235bc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
51 changed files with 9769 additions and 8597 deletions

View File

@ -593,29 +593,6 @@ void bfdd_vty_init(void);
*/
void bfdd_cli_init(void);
void bfd_cli_show_header(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void bfd_cli_show_header_end(struct vty *vty, struct lyd_node *dnode);
void bfd_cli_show_single_hop_peer(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
void bfd_cli_show_multi_hop_peer(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
void bfd_cli_show_peer_end(struct vty *vty, struct lyd_node *dnode);
void bfd_cli_show_mult(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void bfd_cli_show_tx(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void bfd_cli_show_rx(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void bfd_cli_show_shutdown(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void bfd_cli_show_echo(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void bfd_cli_show_echo_interval(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
/*
* ptm_adapter.c
@ -630,12 +607,4 @@ void bfd_session_update_vrf_name(struct bfd_session *bs, struct vrf *vrf);
int ptm_bfd_notify(struct bfd_session *bs, uint8_t notify_state);
/*
* bfdd_northbound.c
*
* BFD northbound callbacks.
*/
extern const struct frr_yang_module_info frr_bfdd_info;
#endif /* _BFD_H_ */

View File

@ -23,6 +23,7 @@
#include "filter.h"
#include "bfd.h"
#include "bfdd_nb.h"
#include "lib/version.h"

View File

@ -31,6 +31,7 @@
#endif /* VTYSH_EXTRACT_PL */
#include "bfd.h"
#include "bfdd_nb.h"
/*
* Definitions.

388
bfdd/bfdd_nb.c Normal file
View File

@ -0,0 +1,388 @@
/*
* BFD daemon northbound implementation.
*
* Copyright (C) 2019 Network Device Education Foundation, Inc. ("NetDEF")
* Rafael Zalamena
*
* This program 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 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
#include <zebra.h>
#include "lib/log.h"
#include "lib/northbound.h"
#include "bfdd_nb.h"
/* clang-format off */
const struct frr_yang_module_info frr_bfdd_info = {
.name = "frr-bfdd",
.nodes = {
{
.xpath = "/frr-bfdd:bfdd/bfd",
.cbs = {
.create = bfdd_bfd_create,
.destroy = bfdd_bfd_destroy,
.cli_show = bfd_cli_show_header,
.cli_show_end = bfd_cli_show_header_end,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop",
.cbs = {
.create = bfdd_bfd_sessions_single_hop_create,
.destroy = bfdd_bfd_sessions_single_hop_destroy,
.get_next = bfdd_bfd_sessions_single_hop_get_next,
.get_keys = bfdd_bfd_sessions_single_hop_get_keys,
.lookup_entry = bfdd_bfd_sessions_single_hop_lookup_entry,
.cli_show = bfd_cli_show_single_hop_peer,
.cli_show_end = bfd_cli_show_peer_end,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/source-addr",
.cbs = {
.modify = bfdd_bfd_sessions_single_hop_source_addr_modify,
.destroy = bfdd_bfd_sessions_single_hop_source_addr_destroy,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/detection-multiplier",
.cbs = {
.modify = bfdd_bfd_sessions_single_hop_detection_multiplier_modify,
.cli_show = bfd_cli_show_mult,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/desired-transmission-interval",
.cbs = {
.modify = bfdd_bfd_sessions_single_hop_desired_transmission_interval_modify,
.cli_show = bfd_cli_show_tx,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/required-receive-interval",
.cbs = {
.modify = bfdd_bfd_sessions_single_hop_required_receive_interval_modify,
.cli_show = bfd_cli_show_rx,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/administrative-down",
.cbs = {
.modify = bfdd_bfd_sessions_single_hop_administrative_down_modify,
.cli_show = bfd_cli_show_shutdown,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/echo-mode",
.cbs = {
.modify = bfdd_bfd_sessions_single_hop_echo_mode_modify,
.cli_show = bfd_cli_show_echo,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/desired-echo-transmission-interval",
.cbs = {
.modify = bfdd_bfd_sessions_single_hop_desired_echo_transmission_interval_modify,
.cli_show = bfd_cli_show_echo_interval,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/stats/local-discriminator",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_local_discriminator_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/stats/local-state",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_local_state_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/stats/local-diagnostic",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_local_diagnostic_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/stats/local-multiplier",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_local_multiplier_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/stats/remote-discriminator",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_remote_discriminator_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/stats/remote-state",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_remote_state_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/stats/remote-diagnostic",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_remote_diagnostic_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/stats/remote-multiplier",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_remote_multiplier_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/stats/negotiated-transmission-interval",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_negotiated_transmission_interval_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/stats/negotiated-receive-interval",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_negotiated_receive_interval_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/stats/detection-mode",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_detection_mode_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/stats/last-down-time",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_last_down_time_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/stats/last-up-time",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_last_up_time_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/stats/session-down-count",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_session_down_count_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/stats/session-up-count",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_session_up_count_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/stats/control-packet-input-count",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_control_packet_input_count_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/stats/control-packet-output-count",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_control_packet_output_count_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/stats/negotiated-echo-transmission-interval",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_negotiated_echo_transmission_interval_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/stats/echo-packet-input-count",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_echo_packet_input_count_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/single-hop/stats/echo-packet-output-count",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_echo_packet_output_count_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop",
.cbs = {
.create = bfdd_bfd_sessions_multi_hop_create,
.destroy = bfdd_bfd_sessions_multi_hop_destroy,
.get_next = bfdd_bfd_sessions_multi_hop_get_next,
.get_keys = bfdd_bfd_sessions_multi_hop_get_keys,
.lookup_entry = bfdd_bfd_sessions_multi_hop_lookup_entry,
.cli_show = bfd_cli_show_multi_hop_peer,
.cli_show_end = bfd_cli_show_peer_end,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/detection-multiplier",
.cbs = {
.modify = bfdd_bfd_sessions_single_hop_detection_multiplier_modify,
.cli_show = bfd_cli_show_mult,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/desired-transmission-interval",
.cbs = {
.modify = bfdd_bfd_sessions_single_hop_desired_transmission_interval_modify,
.cli_show = bfd_cli_show_tx,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/required-receive-interval",
.cbs = {
.modify = bfdd_bfd_sessions_single_hop_required_receive_interval_modify,
.cli_show = bfd_cli_show_rx,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/administrative-down",
.cbs = {
.modify = bfdd_bfd_sessions_single_hop_administrative_down_modify,
.cli_show = bfd_cli_show_shutdown,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/stats/local-discriminator",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_local_discriminator_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/stats/local-state",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_local_state_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/stats/local-diagnostic",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_local_diagnostic_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/stats/local-multiplier",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_local_multiplier_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/stats/remote-discriminator",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_remote_discriminator_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/stats/remote-state",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_remote_state_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/stats/remote-diagnostic",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_remote_diagnostic_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/stats/remote-multiplier",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_remote_multiplier_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/stats/negotiated-transmission-interval",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_negotiated_transmission_interval_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/stats/negotiated-receive-interval",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_negotiated_receive_interval_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/stats/detection-mode",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_detection_mode_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/stats/last-down-time",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_last_down_time_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/stats/last-up-time",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_last_up_time_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/stats/session-down-count",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_session_down_count_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/stats/session-up-count",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_session_up_count_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/stats/control-packet-input-count",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_control_packet_input_count_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/stats/control-packet-output-count",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_control_packet_output_count_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/stats/negotiated-echo-transmission-interval",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_negotiated_echo_transmission_interval_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/stats/echo-packet-input-count",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_echo_packet_input_count_get_elem,
}
},
{
.xpath = "/frr-bfdd:bfdd/bfd/sessions/multi-hop/stats/echo-packet-output-count",
.cbs = {
.get_elem = bfdd_bfd_sessions_single_hop_stats_echo_packet_output_count_get_elem,
}
},
{
.xpath = NULL,
},
}
};

217
bfdd/bfdd_nb.h Normal file
View File

@ -0,0 +1,217 @@
/*
* BFD daemon northbound implementation.
*
* Copyright (C) 2019 Network Device Education Foundation, Inc. ("NetDEF")
* Rafael Zalamena
*
* This program 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 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
#ifndef _FRR_BFDD_NB_H_
#define _FRR_BFDD_NB_H_
extern const struct frr_yang_module_info frr_bfdd_info;
/* Mandatory callbacks. */
int bfdd_bfd_create(enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int bfdd_bfd_destroy(enum nb_event event, const struct lyd_node *dnode);
int bfdd_bfd_sessions_single_hop_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int bfdd_bfd_sessions_single_hop_destroy(enum nb_event event,
const struct lyd_node *dnode);
const void *bfdd_bfd_sessions_single_hop_get_next(const void *parent_list_entry,
const void *list_entry);
int bfdd_bfd_sessions_single_hop_get_keys(const void *list_entry,
struct yang_list_keys *keys);
const void *
bfdd_bfd_sessions_single_hop_lookup_entry(const void *parent_list_entry,
const struct yang_list_keys *keys);
int bfdd_bfd_sessions_single_hop_source_addr_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int bfdd_bfd_sessions_single_hop_source_addr_destroy(
enum nb_event event, const struct lyd_node *dnode);
int bfdd_bfd_sessions_single_hop_detection_multiplier_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int bfdd_bfd_sessions_single_hop_desired_transmission_interval_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int bfdd_bfd_sessions_single_hop_required_receive_interval_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int bfdd_bfd_sessions_single_hop_administrative_down_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int bfdd_bfd_sessions_single_hop_echo_mode_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int bfdd_bfd_sessions_single_hop_desired_echo_transmission_interval_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_local_discriminator_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_local_state_get_elem(const char *xpath,
const void *list_entry);
struct yang_data *bfdd_bfd_sessions_single_hop_stats_local_diagnostic_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *bfdd_bfd_sessions_single_hop_stats_local_multiplier_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_remote_discriminator_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *bfdd_bfd_sessions_single_hop_stats_remote_state_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *bfdd_bfd_sessions_single_hop_stats_remote_diagnostic_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *bfdd_bfd_sessions_single_hop_stats_remote_multiplier_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_negotiated_transmission_interval_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_negotiated_receive_interval_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *bfdd_bfd_sessions_single_hop_stats_detection_mode_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *bfdd_bfd_sessions_single_hop_stats_last_down_time_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *bfdd_bfd_sessions_single_hop_stats_last_up_time_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_session_down_count_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *bfdd_bfd_sessions_single_hop_stats_session_up_count_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_control_packet_input_count_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_control_packet_output_count_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_negotiated_echo_transmission_interval_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_echo_packet_input_count_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_echo_packet_output_count_get_elem(
const char *xpath, const void *list_entry);
int bfdd_bfd_sessions_multi_hop_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int bfdd_bfd_sessions_multi_hop_destroy(enum nb_event event,
const struct lyd_node *dnode);
const void *bfdd_bfd_sessions_multi_hop_get_next(const void *parent_list_entry,
const void *list_entry);
int bfdd_bfd_sessions_multi_hop_get_keys(const void *list_entry,
struct yang_list_keys *keys);
const void *
bfdd_bfd_sessions_multi_hop_lookup_entry(const void *parent_list_entry,
const struct yang_list_keys *keys);
int bfdd_bfd_sessions_multi_hop_detection_multiplier_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int bfdd_bfd_sessions_multi_hop_desired_transmission_interval_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int bfdd_bfd_sessions_multi_hop_required_receive_interval_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int bfdd_bfd_sessions_multi_hop_administrative_down_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
struct yang_data *
bfdd_bfd_sessions_multi_hop_stats_local_discriminator_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_multi_hop_stats_local_state_get_elem(const char *xpath,
const void *list_entry);
struct yang_data *bfdd_bfd_sessions_multi_hop_stats_local_diagnostic_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *bfdd_bfd_sessions_multi_hop_stats_local_multiplier_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_multi_hop_stats_remote_discriminator_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_multi_hop_stats_remote_state_get_elem(const char *xpath,
const void *list_entry);
struct yang_data *bfdd_bfd_sessions_multi_hop_stats_remote_diagnostic_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *bfdd_bfd_sessions_multi_hop_stats_remote_multiplier_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_multi_hop_stats_negotiated_transmission_interval_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_multi_hop_stats_negotiated_receive_interval_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *bfdd_bfd_sessions_multi_hop_stats_detection_mode_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *bfdd_bfd_sessions_multi_hop_stats_last_down_time_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_multi_hop_stats_last_up_time_get_elem(const char *xpath,
const void *list_entry);
struct yang_data *bfdd_bfd_sessions_multi_hop_stats_session_down_count_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *bfdd_bfd_sessions_multi_hop_stats_session_up_count_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_multi_hop_stats_control_packet_input_count_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_multi_hop_stats_control_packet_output_count_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_multi_hop_stats_negotiated_echo_transmission_interval_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_multi_hop_stats_echo_packet_input_count_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
bfdd_bfd_sessions_multi_hop_stats_echo_packet_output_count_get_elem(
const char *xpath, const void *list_entry);
/* Optional 'cli_show' callbacks. */
void bfd_cli_show_header(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void bfd_cli_show_header_end(struct vty *vty, struct lyd_node *dnode);
void bfd_cli_show_single_hop_peer(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void bfd_cli_show_multi_hop_peer(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void bfd_cli_show_peer_end(struct vty *vty, struct lyd_node *dnode);
void bfd_cli_show_mult(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void bfd_cli_show_tx(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void bfd_cli_show_rx(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void bfd_cli_show_shutdown(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void bfd_cli_show_echo(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void bfd_cli_show_echo_interval(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
#endif /* _FRR_BFDD_NB_H_ */

520
bfdd/bfdd_nb_config.c Normal file
View File

@ -0,0 +1,520 @@
/*
* BFD daemon northbound implementation.
*
* Copyright (C) 2019 Network Device Education Foundation, Inc. ("NetDEF")
* Rafael Zalamena
*
* This program 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 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
#include <zebra.h>
#include "lib/log.h"
#include "lib/northbound.h"
#include "bfd.h"
#include "bfdd_nb.h"
/*
* Helpers.
*/
static void bfd_session_get_key(bool mhop, const struct lyd_node *dnode,
struct bfd_key *bk)
{
const char *ifname = NULL, *vrfname = NULL;
struct sockaddr_any psa, lsa;
/* Required destination parameter. */
strtosa(yang_dnode_get_string(dnode, "./dest-addr"), &psa);
/* Get optional source address. */
memset(&lsa, 0, sizeof(lsa));
if (yang_dnode_exists(dnode, "./source-addr"))
strtosa(yang_dnode_get_string(dnode, "./source-addr"), &lsa);
/* Get optional interface and vrf names. */
if (yang_dnode_exists(dnode, "./interface"))
ifname = yang_dnode_get_string(dnode, "./interface");
if (yang_dnode_exists(dnode, "./vrf"))
vrfname = yang_dnode_get_string(dnode, "./vrf");
/* Generate the corresponding key. */
gen_bfd_key(bk, &psa, &lsa, mhop, ifname, vrfname);
}
static int bfd_session_create(enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource, bool mhop)
{
struct bfd_session *bs;
const char *ifname;
struct bfd_key bk;
struct prefix p;
switch (event) {
case NB_EV_VALIDATE:
/*
* When `dest-addr` is IPv6 and link-local we must
* require interface name, otherwise we can't figure
* which interface to use to send the packets.
*/
yang_dnode_get_prefix(&p, dnode, "./dest-addr");
/*
* To support old FRR versions we must allow empty
* interface to be specified, however that should
* change in the future.
*/
if (yang_dnode_exists(dnode, "./interface"))
ifname = yang_dnode_get_string(dnode, "./interface");
else
ifname = "";
if (p.family == AF_INET6 && IN6_IS_ADDR_LINKLOCAL(&p.u.prefix6)
&& strlen(ifname) == 0) {
zlog_warn(
"%s: when using link-local you must specify "
"an interface.",
__func__);
return NB_ERR_VALIDATION;
}
break;
case NB_EV_PREPARE:
bfd_session_get_key(mhop, dnode, &bk);
bs = bfd_key_lookup(bk);
/* This session was already configured by another daemon. */
if (bs != NULL) {
/* Now it is configured also by CLI. */
BFD_SET_FLAG(bs->flags, BFD_SESS_FLAG_CONFIG);
bs->refcount++;
resource->ptr = bs;
break;
}
bs = bfd_session_new();
if (bs == NULL)
return NB_ERR_RESOURCE;
/* Fill the session key. */
bfd_session_get_key(mhop, dnode, &bs->key);
/* Set configuration flags. */
bs->refcount = 1;
BFD_SET_FLAG(bs->flags, BFD_SESS_FLAG_CONFIG);
if (mhop)
BFD_SET_FLAG(bs->flags, BFD_SESS_FLAG_MH);
if (bs->key.family == AF_INET6)
BFD_SET_FLAG(bs->flags, BFD_SESS_FLAG_IPV6);
resource->ptr = bs;
break;
case NB_EV_APPLY:
bs = resource->ptr;
/* Only attempt to registrate if freshly allocated. */
if (bs->discrs.my_discr == 0 && bs_registrate(bs) == NULL)
return NB_ERR_RESOURCE;
nb_running_set_entry(dnode, bs);
break;
case NB_EV_ABORT:
bs = resource->ptr;
if (bs->refcount <= 1)
bfd_session_free(resource->ptr);
break;
}
return NB_OK;
}
static int bfd_session_destroy(enum nb_event event,
const struct lyd_node *dnode, bool mhop)
{
struct bfd_session *bs;
struct bfd_key bk;
switch (event) {
case NB_EV_VALIDATE:
bfd_session_get_key(mhop, dnode, &bk);
if (bfd_key_lookup(bk) == NULL)
return NB_ERR_INCONSISTENCY;
break;
case NB_EV_PREPARE:
/* NOTHING */
break;
case NB_EV_APPLY:
bs = nb_running_unset_entry(dnode);
/* CLI is not using this session anymore. */
if (BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_CONFIG) == 0)
break;
BFD_UNSET_FLAG(bs->flags, BFD_SESS_FLAG_CONFIG);
bs->refcount--;
/* There are still daemons using it. */
if (bs->refcount > 0)
break;
bfd_session_free(bs);
break;
case NB_EV_ABORT:
/* NOTHING */
break;
}
return NB_OK;
}
/*
* XPath: /frr-bfdd:bfdd/bfd
*/
int bfdd_bfd_create(enum nb_event event,
const struct lyd_node *dnode __attribute__((__unused__)),
union nb_resource *resource __attribute__((__unused__)))
{
/* NOTHING */
return NB_OK;
}
int bfdd_bfd_destroy(enum nb_event event, const struct lyd_node *dnode)
{
switch (event) {
case NB_EV_VALIDATE:
/* NOTHING */
return NB_OK;
case NB_EV_PREPARE:
/* NOTHING */
return NB_OK;
case NB_EV_APPLY:
bfd_sessions_remove_manual();
break;
case NB_EV_ABORT:
/* NOTHING */
return NB_OK;
}
return NB_OK;
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop
*/
int bfdd_bfd_sessions_single_hop_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
return bfd_session_create(event, dnode, resource, false);
}
int bfdd_bfd_sessions_single_hop_destroy(enum nb_event event,
const struct lyd_node *dnode)
{
return bfd_session_destroy(event, dnode, false);
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/source-addr
*/
int bfdd_bfd_sessions_single_hop_source_addr_modify(enum nb_event event
__attribute__((__unused__)),
const struct lyd_node *dnode
__attribute__((__unused__)),
union nb_resource *resource
__attribute__((__unused__)))
{
return NB_OK;
}
int bfdd_bfd_sessions_single_hop_source_addr_destroy(
enum nb_event event __attribute__((__unused__)),
const struct lyd_node *dnode __attribute__((__unused__)))
{
return NB_OK;
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/detection-multiplier
*/
int bfdd_bfd_sessions_single_hop_detection_multiplier_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource __attribute__((__unused__)))
{
uint8_t detection_multiplier = yang_dnode_get_uint8(dnode, NULL);
struct bfd_session *bs;
switch (event) {
case NB_EV_VALIDATE:
break;
case NB_EV_PREPARE:
/* NOTHING */
break;
case NB_EV_APPLY:
bs = nb_running_get_entry(dnode, NULL, true);
bs->detect_mult = detection_multiplier;
break;
case NB_EV_ABORT:
/* NOTHING */
break;
}
return NB_OK;
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/desired-transmission-interval
*/
int bfdd_bfd_sessions_single_hop_desired_transmission_interval_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource __attribute__((__unused__)))
{
uint32_t tx_interval = yang_dnode_get_uint32(dnode, NULL);
struct bfd_session *bs;
switch (event) {
case NB_EV_VALIDATE:
if (tx_interval < 10000 || tx_interval > 60000000)
return NB_ERR_VALIDATION;
break;
case NB_EV_PREPARE:
/* NOTHING */
break;
case NB_EV_APPLY:
bs = nb_running_get_entry(dnode, NULL, true);
if (tx_interval == bs->timers.desired_min_tx)
return NB_OK;
bs->timers.desired_min_tx = tx_interval;
bfd_set_polling(bs);
break;
case NB_EV_ABORT:
/* NOTHING */
break;
}
return NB_OK;
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/required-receive-interval
*/
int bfdd_bfd_sessions_single_hop_required_receive_interval_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource __attribute__((__unused__)))
{
uint32_t rx_interval = yang_dnode_get_uint32(dnode, NULL);
struct bfd_session *bs;
switch (event) {
case NB_EV_VALIDATE:
if (rx_interval < 10000 || rx_interval > 60000000)
return NB_ERR_VALIDATION;
break;
case NB_EV_PREPARE:
/* NOTHING */
break;
case NB_EV_APPLY:
bs = nb_running_get_entry(dnode, NULL, true);
if (rx_interval == bs->timers.required_min_rx)
return NB_OK;
bs->timers.required_min_rx = rx_interval;
bfd_set_polling(bs);
break;
case NB_EV_ABORT:
/* NOTHING */
break;
}
return NB_OK;
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/administrative-down
*/
int bfdd_bfd_sessions_single_hop_administrative_down_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource __attribute__((__unused__)))
{
bool shutdown = yang_dnode_get_bool(dnode, NULL);
struct bfd_session *bs;
switch (event) {
case NB_EV_VALIDATE:
case NB_EV_PREPARE:
return NB_OK;
case NB_EV_APPLY:
break;
case NB_EV_ABORT:
return NB_OK;
}
bs = nb_running_get_entry(dnode, NULL, true);
if (shutdown == false) {
if (!BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_SHUTDOWN))
return NB_OK;
BFD_UNSET_FLAG(bs->flags, BFD_SESS_FLAG_SHUTDOWN);
/* Change and notify state change. */
bs->ses_state = PTM_BFD_DOWN;
control_notify(bs, bs->ses_state);
/* Enable all timers. */
bfd_recvtimer_update(bs);
bfd_xmttimer_update(bs, bs->xmt_TO);
if (BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_ECHO)) {
bfd_echo_recvtimer_update(bs);
bfd_echo_xmttimer_update(bs, bs->echo_xmt_TO);
}
} else {
if (BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_SHUTDOWN))
return NB_OK;
BFD_SET_FLAG(bs->flags, BFD_SESS_FLAG_SHUTDOWN);
/* Disable all events. */
bfd_recvtimer_delete(bs);
bfd_echo_recvtimer_delete(bs);
bfd_xmttimer_delete(bs);
bfd_echo_xmttimer_delete(bs);
/* Change and notify state change. */
bs->ses_state = PTM_BFD_ADM_DOWN;
control_notify(bs, bs->ses_state);
ptm_bfd_snd(bs, 0);
}
return NB_OK;
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/echo-mode
*/
int bfdd_bfd_sessions_single_hop_echo_mode_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource
__attribute__((__unused__)))
{
bool echo = yang_dnode_get_bool(dnode, NULL);
struct bfd_session *bs;
switch (event) {
case NB_EV_VALIDATE:
case NB_EV_PREPARE:
return NB_OK;
case NB_EV_APPLY:
break;
case NB_EV_ABORT:
return NB_OK;
}
bs = nb_running_get_entry(dnode, NULL, true);
if (echo == false) {
if (!BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_ECHO))
return NB_OK;
BFD_UNSET_FLAG(bs->flags, BFD_SESS_FLAG_ECHO);
ptm_bfd_echo_stop(bs);
} else {
if (BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_ECHO))
return NB_OK;
BFD_SET_FLAG(bs->flags, BFD_SESS_FLAG_ECHO);
/* Apply setting immediately. */
if (!BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_SHUTDOWN))
bs_echo_timer_handler(bs);
}
return NB_OK;
}
/*
* XPath:
* /frr-bfdd:bfdd/bfd/sessions/single-hop/desired-echo-transmission-interval
*/
int bfdd_bfd_sessions_single_hop_desired_echo_transmission_interval_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource __attribute__((__unused__)))
{
uint32_t echo_interval = yang_dnode_get_uint32(dnode, NULL);
struct bfd_session *bs;
switch (event) {
case NB_EV_VALIDATE:
if (echo_interval < 10000 || echo_interval > 60000000)
return NB_ERR_VALIDATION;
break;
case NB_EV_PREPARE:
/* NOTHING */
break;
case NB_EV_APPLY:
bs = nb_running_get_entry(dnode, NULL, true);
if (echo_interval == bs->timers.required_min_echo)
return NB_OK;
bs->timers.required_min_echo = echo_interval;
break;
case NB_EV_ABORT:
/* NOTHING */
break;
}
return NB_OK;
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/multi-hop
*/
int bfdd_bfd_sessions_multi_hop_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
return bfd_session_create(event, dnode, resource, true);
}
int bfdd_bfd_sessions_multi_hop_destroy(enum nb_event event,
const struct lyd_node *dnode)
{
return bfd_session_destroy(event, dnode, true);
}

383
bfdd/bfdd_nb_state.c Normal file
View File

@ -0,0 +1,383 @@
/*
* BFD daemon northbound implementation.
*
* Copyright (C) 2019 Network Device Education Foundation, Inc. ("NetDEF")
* Rafael Zalamena
*
* This program 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 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
#include <zebra.h>
#include "lib/log.h"
#include "lib/northbound.h"
#include "bfd.h"
#include "bfdd_nb.h"
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop
*/
const void *bfdd_bfd_sessions_single_hop_get_next(const void *parent_list_entry
__attribute__((__unused__)),
const void *list_entry)
{
return bfd_session_next(list_entry, false);
}
int bfdd_bfd_sessions_single_hop_get_keys(const void *list_entry,
struct yang_list_keys *keys)
{
const struct bfd_session *bs = list_entry;
char dstbuf[INET6_ADDRSTRLEN];
inet_ntop(bs->key.family, &bs->key.peer, dstbuf, sizeof(dstbuf));
keys->num = 3;
strlcpy(keys->key[0], dstbuf, sizeof(keys->key[0]));
strlcpy(keys->key[1], bs->key.ifname, sizeof(keys->key[1]));
strlcpy(keys->key[2], bs->key.vrfname, sizeof(keys->key[2]));
return NB_OK;
}
const void *
bfdd_bfd_sessions_single_hop_lookup_entry(const void *parent_list_entry
__attribute__((__unused__)),
const struct yang_list_keys *keys)
{
const char *dest_addr = keys->key[0];
const char *ifname = keys->key[1];
const char *vrf = keys->key[2];
struct sockaddr_any psa, lsa;
struct bfd_key bk;
strtosa(dest_addr, &psa);
memset(&lsa, 0, sizeof(lsa));
gen_bfd_key(&bk, &psa, &lsa, false, ifname, vrf);
return bfd_key_lookup(bk);
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/stats/local-discriminator
*/
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_local_discriminator_get_elem(
const char *xpath, const void *list_entry)
{
const struct bfd_session *bs = list_entry;
return yang_data_new_uint32(xpath, bs->discrs.my_discr);
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/stats/local-state
*/
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_local_state_get_elem(const char *xpath,
const void *list_entry)
{
const struct bfd_session *bs = list_entry;
return yang_data_new_enum(xpath, bs->ses_state);
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/stats/local-diagnostic
*/
struct yang_data *bfdd_bfd_sessions_single_hop_stats_local_diagnostic_get_elem(
const char *xpath, const void *list_entry)
{
const struct bfd_session *bs = list_entry;
return yang_data_new_enum(xpath, bs->local_diag);
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/stats/local-multiplier
*/
struct yang_data *bfdd_bfd_sessions_single_hop_stats_local_multiplier_get_elem(
const char *xpath, const void *list_entry)
{
const struct bfd_session *bs = list_entry;
return yang_data_new_int8(xpath, bs->detect_mult);
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/stats/remote-discriminator
*/
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_remote_discriminator_get_elem(
const char *xpath, const void *list_entry)
{
const struct bfd_session *bs = list_entry;
if (bs->discrs.remote_discr == 0)
return NULL;
return yang_data_new_uint32(xpath, bs->discrs.remote_discr);
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/stats/remote-state
*/
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_remote_state_get_elem(const char *xpath,
const void *list_entry)
{
const struct bfd_session *bs = list_entry;
return yang_data_new_enum(xpath, bs->ses_state);
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/stats/remote-diagnostic
*/
struct yang_data *bfdd_bfd_sessions_single_hop_stats_remote_diagnostic_get_elem(
const char *xpath, const void *list_entry)
{
const struct bfd_session *bs = list_entry;
return yang_data_new_enum(xpath, bs->remote_diag);
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/stats/remote-multiplier
*/
struct yang_data *bfdd_bfd_sessions_single_hop_stats_remote_multiplier_get_elem(
const char *xpath, const void *list_entry)
{
const struct bfd_session *bs = list_entry;
return yang_data_new_int8(xpath, bs->remote_detect_mult);
}
/*
* XPath:
* /frr-bfdd:bfdd/bfd/sessions/single-hop/stats/negotiated-transmission-interval
*/
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_negotiated_transmission_interval_get_elem(
const char *xpath, const void *list_entry)
{
const struct bfd_session *bs = list_entry;
return yang_data_new_uint32(xpath, bs->remote_timers.desired_min_tx);
}
/*
* XPath:
* /frr-bfdd:bfdd/bfd/sessions/single-hop/stats/negotiated-receive-interval
*/
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_negotiated_receive_interval_get_elem(
const char *xpath, const void *list_entry)
{
const struct bfd_session *bs = list_entry;
return yang_data_new_uint32(xpath, bs->remote_timers.required_min_rx);
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/stats/detection-mode
*/
struct yang_data *bfdd_bfd_sessions_single_hop_stats_detection_mode_get_elem(
const char *xpath, const void *list_entry)
{
const struct bfd_session *bs = list_entry;
int detection_mode;
/*
* Detection mode:
* 1. Async with echo
* 2. Async without echo
* 3. Demand with echo
* 4. Demand without echo
*
* TODO: support demand mode.
*/
if (BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_ECHO))
detection_mode = 1;
else
detection_mode = 2;
return yang_data_new_enum(xpath, detection_mode);
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/stats/last-down-time
*/
struct yang_data *bfdd_bfd_sessions_single_hop_stats_last_down_time_get_elem(
const char *xpath __attribute__((__unused__)),
const void *list_entry __attribute__((__unused__)))
{
/*
* TODO: implement me.
*
* No yang support for time elements yet.
*/
return NULL;
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/stats/last-up-time
*/
struct yang_data *bfdd_bfd_sessions_single_hop_stats_last_up_time_get_elem(
const char *xpath __attribute__((__unused__)),
const void *list_entry __attribute__((__unused__)))
{
/*
* TODO: implement me.
*
* No yang support for time elements yet.
*/
return NULL;
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/stats/session-down-count
*/
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_session_down_count_get_elem(
const char *xpath, const void *list_entry)
{
const struct bfd_session *bs = list_entry;
return yang_data_new_uint64(xpath, bs->stats.session_down);
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/stats/session-up-count
*/
struct yang_data *bfdd_bfd_sessions_single_hop_stats_session_up_count_get_elem(
const char *xpath, const void *list_entry)
{
const struct bfd_session *bs = list_entry;
return yang_data_new_uint64(xpath, bs->stats.session_up);
}
/*
* XPath:
* /frr-bfdd:bfdd/bfd/sessions/single-hop/stats/control-packet-input-count
*/
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_control_packet_input_count_get_elem(
const char *xpath, const void *list_entry)
{
const struct bfd_session *bs = list_entry;
return yang_data_new_uint64(xpath, bs->stats.rx_ctrl_pkt);
}
/*
* XPath:
* /frr-bfdd:bfdd/bfd/sessions/single-hop/stats/control-packet-output-count
*/
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_control_packet_output_count_get_elem(
const char *xpath, const void *list_entry)
{
const struct bfd_session *bs = list_entry;
return yang_data_new_uint64(xpath, bs->stats.tx_ctrl_pkt);
}
/*
* XPath:
* /frr-bfdd:bfdd/bfd/sessions/single-hop/stats/negotiated-echo-transmission-interval
*/
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_negotiated_echo_transmission_interval_get_elem(
const char *xpath, const void *list_entry)
{
const struct bfd_session *bs = list_entry;
return yang_data_new_uint32(xpath, bs->remote_timers.required_min_echo);
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/stats/echo-packet-input-count
*/
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_echo_packet_input_count_get_elem(
const char *xpath, const void *list_entry)
{
const struct bfd_session *bs = list_entry;
return yang_data_new_uint64(xpath, bs->stats.rx_echo_pkt);
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/single-hop/stats/echo-packet-output-count
*/
struct yang_data *
bfdd_bfd_sessions_single_hop_stats_echo_packet_output_count_get_elem(
const char *xpath, const void *list_entry)
{
const struct bfd_session *bs = list_entry;
return yang_data_new_uint64(xpath, bs->stats.tx_echo_pkt);
}
/*
* XPath: /frr-bfdd:bfdd/bfd/sessions/multi-hop
*/
const void *bfdd_bfd_sessions_multi_hop_get_next(const void *parent_list_entry
__attribute__((__unused__)),
const void *list_entry)
{
return bfd_session_next(list_entry, true);
}
int bfdd_bfd_sessions_multi_hop_get_keys(const void *list_entry,
struct yang_list_keys *keys)
{
const struct bfd_session *bs = list_entry;
char dstbuf[INET6_ADDRSTRLEN], srcbuf[INET6_ADDRSTRLEN];
inet_ntop(bs->key.family, &bs->key.peer, dstbuf, sizeof(dstbuf));
inet_ntop(bs->key.family, &bs->key.local, srcbuf, sizeof(srcbuf));
keys->num = 4;
strlcpy(keys->key[0], srcbuf, sizeof(keys->key[0]));
strlcpy(keys->key[1], dstbuf, sizeof(keys->key[1]));
strlcpy(keys->key[2], bs->key.ifname, sizeof(keys->key[2]));
strlcpy(keys->key[3], bs->key.vrfname, sizeof(keys->key[3]));
return NB_OK;
}
const void *
bfdd_bfd_sessions_multi_hop_lookup_entry(const void *parent_list_entry
__attribute__((__unused__)),
const struct yang_list_keys *keys)
{
const char *source_addr = keys->key[0];
const char *dest_addr = keys->key[1];
const char *ifname = keys->key[2];
const char *vrf = keys->key[3];
struct sockaddr_any psa, lsa;
struct bfd_key bk;
strtosa(dest_addr, &psa);
strtosa(source_addr, &lsa);
gen_bfd_key(&bk, &psa, &lsa, true, ifname, vrf);
return bfd_key_lookup(bk);
}

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,9 @@ endif
bfdd_libbfd_a_SOURCES = \
bfdd/bfd.c \
bfdd/bfdd_northbound.c \
bfdd/bfdd_nb.c \
bfdd/bfdd_nb_config.c \
bfdd/bfdd_nb_state.c \
bfdd/bfdd_vty.c \
bfdd/bfdd_cli.c \
bfdd/bfd_packet.c \
@ -32,6 +34,7 @@ bfdd/bfdd_cli.$(OBJEXT): bfdd/bfdd_cli_clippy.c
noinst_HEADERS += \
bfdd/bfdctl.h \
bfdd/bfdd_nb.h \
bfdd/bfd.h \
# end

View File

@ -48,6 +48,7 @@
#include "isisd/isis_mt.h"
#include "isisd/isis_tlvs.h"
#include "isisd/fabricd.h"
#include "isisd/isis_nb.h"
extern struct isis *isis;
@ -375,6 +376,20 @@ void isis_adj_print(struct isis_adjacency *adj)
return;
}
const char *isis_adj_yang_state(enum isis_adj_state state)
{
switch (state) {
case ISIS_ADJ_DOWN:
return "down";
case ISIS_ADJ_UP:
return "up";
case ISIS_ADJ_INITIALIZING:
return "init";
default:
return "failed";
}
}
int isis_adj_expire(struct thread *thread)
{
struct isis_adjacency *adj;

View File

@ -121,6 +121,7 @@ DECLARE_HOOK(isis_adj_state_change_hook, (struct isis_adjacency *adj), (adj))
void isis_adj_state_change(struct isis_adjacency *adj,
enum isis_adj_state state, const char *reason);
void isis_adj_print(struct isis_adjacency *adj);
const char *isis_adj_yang_state(enum isis_adj_state state);
int isis_adj_expire(struct thread *thread);
void isis_adj_print_vty(struct isis_adjacency *adj, struct vty *vty,
char detail);

View File

@ -58,6 +58,7 @@
#include "isisd/isis_mt.h"
#include "isisd/isis_errors.h"
#include "isisd/isis_tx_queue.h"
#include "isisd/isis_nb.h"
DEFINE_QOBJ_TYPE(isis_circuit)

View File

@ -32,7 +32,7 @@
#include "yang.h"
#include "lib/linklist.h"
#include "isisd/isisd.h"
#include "isisd/isis_cli.h"
#include "isisd/isis_nb.h"
#include "isisd/isis_misc.h"
#include "isisd/isis_circuit.h"
#include "isisd/isis_csm.h"

View File

@ -1,127 +0,0 @@
/*
* Copyright (C) 2018 Volta Networks
* Emanuele Di Pascale
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ISISD_ISIS_CLI_H_
#define ISISD_ISIS_CLI_H_
/* add cli_show declarations here as externs */
void cli_show_router_isis(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_ipv4(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_ipv6(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_bfd_monitoring(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_area_address(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_is_type(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_dynamic_hostname(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_attached(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_overload(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_metric_style(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_area_pwd(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_domain_pwd(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_lsp_gen_interval(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_lsp_ref_interval(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_lsp_max_lifetime(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_lsp_mtu(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_spf_min_interval(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_spf_ietf_backoff(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_purge_origin(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_mpls_te(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_mpls_te_router_addr(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_def_origin_ipv4(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_def_origin_ipv6(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_redistribute_ipv4(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_redistribute_ipv6(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_mt_ipv4_multicast(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_mt_ipv4_mgmt(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_mt_ipv6_unicast(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_mt_ipv6_multicast(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_mt_ipv6_mgmt(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_mt_ipv6_dstsrc(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_passive(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_password(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_metric(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_hello_interval(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_hello_multi(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_threeway_shake(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_hello_padding(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_csnp_interval(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_psnp_interval(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_mt_ipv4_unicast(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_mt_ipv4_multicast(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_mt_ipv4_mgmt(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_mt_ipv6_unicast(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_mt_ipv6_multicast(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_mt_ipv6_mgmt(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_mt_ipv6_dstsrc(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_circ_type(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_network_type(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_priority(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_log_adjacency(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
#endif /* ISISD_ISIS_CLI_H_ */

View File

@ -57,6 +57,7 @@
#include "isisd/isis_te.h"
#include "isisd/fabricd.h"
#include "isisd/isis_tx_queue.h"
#include "isisd/isis_nb.h"
static int lsp_refresh(struct thread *thread);
static int lsp_l1_refresh_pseudo(struct thread *thread);

View File

@ -57,6 +57,7 @@
#include "isisd/isis_lsp.h"
#include "isisd/isis_mt.h"
#include "isisd/fabricd.h"
#include "isisd/isis_nb.h"
/* Default configuration file name */
#define ISISD_DEFAULT_CONFIG "isisd.conf"

815
isisd/isis_nb.c Normal file
View File

@ -0,0 +1,815 @@
/*
* Copyright (C) 2018 Volta Networks
* Emanuele Di Pascale
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "northbound.h"
#include "libfrr.h"
#include "isisd/isis_nb.h"
/* clang-format off */
const struct frr_yang_module_info frr_isisd_info = {
.name = "frr-isisd",
.nodes = {
{
.xpath = "/frr-isisd:isis/instance",
.cbs = {
.cli_show = cli_show_router_isis,
.create = isis_instance_create,
.destroy = isis_instance_destroy,
},
.priority = NB_DFLT_PRIORITY - 1,
},
{
.xpath = "/frr-isisd:isis/instance/is-type",
.cbs = {
.cli_show = cli_show_isis_is_type,
.modify = isis_instance_is_type_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/area-address",
.cbs = {
.cli_show = cli_show_isis_area_address,
.create = isis_instance_area_address_create,
.destroy = isis_instance_area_address_destroy,
},
},
{
.xpath = "/frr-isisd:isis/instance/dynamic-hostname",
.cbs = {
.cli_show = cli_show_isis_dynamic_hostname,
.modify = isis_instance_dynamic_hostname_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/attached",
.cbs = {
.cli_show = cli_show_isis_attached,
.modify = isis_instance_attached_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/overload",
.cbs = {
.cli_show = cli_show_isis_overload,
.modify = isis_instance_overload_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/metric-style",
.cbs = {
.cli_show = cli_show_isis_metric_style,
.modify = isis_instance_metric_style_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/purge-originator",
.cbs = {
.cli_show = cli_show_isis_purge_origin,
.modify = isis_instance_purge_originator_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/lsp/mtu",
.cbs = {
.cli_show = cli_show_isis_lsp_mtu,
.modify = isis_instance_lsp_mtu_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/lsp/refresh-interval",
.cbs = {
.cli_show = cli_show_isis_lsp_ref_interval,
},
},
{
.xpath = "/frr-isisd:isis/instance/lsp/refresh-interval/level-1",
.cbs = {
.modify = isis_instance_lsp_refresh_interval_level_1_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/lsp/refresh-interval/level-2",
.cbs = {
.modify = isis_instance_lsp_refresh_interval_level_2_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/lsp/maximum-lifetime",
.cbs = {
.cli_show = cli_show_isis_lsp_max_lifetime,
},
},
{
.xpath = "/frr-isisd:isis/instance/lsp/maximum-lifetime/level-1",
.cbs = {
.modify = isis_instance_lsp_maximum_lifetime_level_1_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/lsp/maximum-lifetime/level-2",
.cbs = {
.modify = isis_instance_lsp_maximum_lifetime_level_2_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/lsp/generation-interval",
.cbs = {
.cli_show = cli_show_isis_lsp_gen_interval,
},
},
{
.xpath = "/frr-isisd:isis/instance/lsp/generation-interval/level-1",
.cbs = {
.modify = isis_instance_lsp_generation_interval_level_1_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/lsp/generation-interval/level-2",
.cbs = {
.modify = isis_instance_lsp_generation_interval_level_2_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/spf/ietf-backoff-delay",
.cbs = {
.apply_finish = ietf_backoff_delay_apply_finish,
.cli_show = cli_show_isis_spf_ietf_backoff,
.create = isis_instance_spf_ietf_backoff_delay_create,
.destroy = isis_instance_spf_ietf_backoff_delay_destroy,
},
},
{
.xpath = "/frr-isisd:isis/instance/spf/ietf-backoff-delay/init-delay",
.cbs = {
.modify = isis_instance_spf_ietf_backoff_delay_init_delay_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/spf/ietf-backoff-delay/short-delay",
.cbs = {
.modify = isis_instance_spf_ietf_backoff_delay_short_delay_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/spf/ietf-backoff-delay/long-delay",
.cbs = {
.modify = isis_instance_spf_ietf_backoff_delay_long_delay_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/spf/ietf-backoff-delay/hold-down",
.cbs = {
.modify = isis_instance_spf_ietf_backoff_delay_hold_down_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/spf/ietf-backoff-delay/time-to-learn",
.cbs = {
.modify = isis_instance_spf_ietf_backoff_delay_time_to_learn_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/spf/minimum-interval",
.cbs = {
.cli_show = cli_show_isis_spf_min_interval,
},
},
{
.xpath = "/frr-isisd:isis/instance/spf/minimum-interval/level-1",
.cbs = {
.modify = isis_instance_spf_minimum_interval_level_1_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/spf/minimum-interval/level-2",
.cbs = {
.modify = isis_instance_spf_minimum_interval_level_2_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/area-password",
.cbs = {
.apply_finish = area_password_apply_finish,
.cli_show = cli_show_isis_area_pwd,
.create = isis_instance_area_password_create,
.destroy = isis_instance_area_password_destroy,
},
},
{
.xpath = "/frr-isisd:isis/instance/area-password/password",
.cbs = {
.modify = isis_instance_area_password_password_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/area-password/password-type",
.cbs = {
.modify = isis_instance_area_password_password_type_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/area-password/authenticate-snp",
.cbs = {
.modify = isis_instance_area_password_authenticate_snp_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/domain-password",
.cbs = {
.apply_finish = domain_password_apply_finish,
.cli_show = cli_show_isis_domain_pwd,
.create = isis_instance_domain_password_create,
.destroy = isis_instance_domain_password_destroy,
},
},
{
.xpath = "/frr-isisd:isis/instance/domain-password/password",
.cbs = {
.modify = isis_instance_domain_password_password_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/domain-password/password-type",
.cbs = {
.modify = isis_instance_domain_password_password_type_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/domain-password/authenticate-snp",
.cbs = {
.modify = isis_instance_domain_password_authenticate_snp_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/default-information-originate/ipv4",
.cbs = {
.apply_finish = default_info_origin_ipv4_apply_finish,
.cli_show = cli_show_isis_def_origin_ipv4,
.create = isis_instance_default_information_originate_ipv4_create,
.destroy = isis_instance_default_information_originate_ipv4_destroy,
},
},
{
.xpath = "/frr-isisd:isis/instance/default-information-originate/ipv4/always",
.cbs = {
.modify = isis_instance_default_information_originate_ipv4_always_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/default-information-originate/ipv4/route-map",
.cbs = {
.destroy = isis_instance_default_information_originate_ipv4_route_map_destroy,
.modify = isis_instance_default_information_originate_ipv4_route_map_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/default-information-originate/ipv4/metric",
.cbs = {
.modify = isis_instance_default_information_originate_ipv4_metric_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/default-information-originate/ipv6",
.cbs = {
.apply_finish = default_info_origin_ipv6_apply_finish,
.cli_show = cli_show_isis_def_origin_ipv6,
.create = isis_instance_default_information_originate_ipv6_create,
.destroy = isis_instance_default_information_originate_ipv6_destroy,
},
},
{
.xpath = "/frr-isisd:isis/instance/default-information-originate/ipv6/always",
.cbs = {
.modify = isis_instance_default_information_originate_ipv6_always_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/default-information-originate/ipv6/route-map",
.cbs = {
.destroy = isis_instance_default_information_originate_ipv6_route_map_destroy,
.modify = isis_instance_default_information_originate_ipv6_route_map_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/default-information-originate/ipv6/metric",
.cbs = {
.modify = isis_instance_default_information_originate_ipv6_metric_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/redistribute/ipv4",
.cbs = {
.apply_finish = redistribute_ipv4_apply_finish,
.cli_show = cli_show_isis_redistribute_ipv4,
.create = isis_instance_redistribute_ipv4_create,
.destroy = isis_instance_redistribute_ipv4_destroy,
},
},
{
.xpath = "/frr-isisd:isis/instance/redistribute/ipv4/route-map",
.cbs = {
.destroy = isis_instance_redistribute_ipv4_route_map_destroy,
.modify = isis_instance_redistribute_ipv4_route_map_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/redistribute/ipv4/metric",
.cbs = {
.modify = isis_instance_redistribute_ipv4_metric_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/redistribute/ipv6",
.cbs = {
.apply_finish = redistribute_ipv6_apply_finish,
.cli_show = cli_show_isis_redistribute_ipv6,
.create = isis_instance_redistribute_ipv6_create,
.destroy = isis_instance_redistribute_ipv6_destroy,
},
},
{
.xpath = "/frr-isisd:isis/instance/redistribute/ipv6/route-map",
.cbs = {
.destroy = isis_instance_redistribute_ipv6_route_map_destroy,
.modify = isis_instance_redistribute_ipv6_route_map_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/redistribute/ipv6/metric",
.cbs = {
.modify = isis_instance_redistribute_ipv6_metric_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv4-multicast",
.cbs = {
.cli_show = cli_show_isis_mt_ipv4_multicast,
.create = isis_instance_multi_topology_ipv4_multicast_create,
.destroy = isis_instance_multi_topology_ipv4_multicast_destroy,
},
},
{
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv4-multicast/overload",
.cbs = {
.modify = isis_instance_multi_topology_ipv4_multicast_overload_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv4-management",
.cbs = {
.cli_show = cli_show_isis_mt_ipv4_mgmt,
.create = isis_instance_multi_topology_ipv4_management_create,
.destroy = isis_instance_multi_topology_ipv4_management_destroy,
},
},
{
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv4-management/overload",
.cbs = {
.modify = isis_instance_multi_topology_ipv4_management_overload_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-unicast",
.cbs = {
.cli_show = cli_show_isis_mt_ipv6_unicast,
.create = isis_instance_multi_topology_ipv6_unicast_create,
.destroy = isis_instance_multi_topology_ipv6_unicast_destroy,
},
},
{
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-unicast/overload",
.cbs = {
.modify = isis_instance_multi_topology_ipv6_unicast_overload_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-multicast",
.cbs = {
.cli_show = cli_show_isis_mt_ipv6_multicast,
.create = isis_instance_multi_topology_ipv6_multicast_create,
.destroy = isis_instance_multi_topology_ipv6_multicast_destroy,
},
},
{
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-multicast/overload",
.cbs = {
.modify = isis_instance_multi_topology_ipv6_multicast_overload_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-management",
.cbs = {
.cli_show = cli_show_isis_mt_ipv6_mgmt,
.create = isis_instance_multi_topology_ipv6_management_create,
.destroy = isis_instance_multi_topology_ipv6_management_destroy,
},
},
{
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-management/overload",
.cbs = {
.modify = isis_instance_multi_topology_ipv6_management_overload_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-dstsrc",
.cbs = {
.cli_show = cli_show_isis_mt_ipv6_dstsrc,
.create = isis_instance_multi_topology_ipv6_dstsrc_create,
.destroy = isis_instance_multi_topology_ipv6_dstsrc_destroy,
},
},
{
.xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-dstsrc/overload",
.cbs = {
.modify = isis_instance_multi_topology_ipv6_dstsrc_overload_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/log-adjacency-changes",
.cbs = {
.cli_show = cli_show_isis_log_adjacency,
.modify = isis_instance_log_adjacency_changes_modify,
},
},
{
.xpath = "/frr-isisd:isis/instance/mpls-te",
.cbs = {
.cli_show = cli_show_isis_mpls_te,
.create = isis_instance_mpls_te_create,
.destroy = isis_instance_mpls_te_destroy,
},
},
{
.xpath = "/frr-isisd:isis/instance/mpls-te/router-address",
.cbs = {
.cli_show = cli_show_isis_mpls_te_router_addr,
.destroy = isis_instance_mpls_te_router_address_destroy,
.modify = isis_instance_mpls_te_router_address_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis",
.cbs = {
.create = lib_interface_isis_create,
.destroy = lib_interface_isis_destroy,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/area-tag",
.cbs = {
.modify = lib_interface_isis_area_tag_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/circuit-type",
.cbs = {
.cli_show = cli_show_ip_isis_circ_type,
.modify = lib_interface_isis_circuit_type_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/ipv4-routing",
.cbs = {
.cli_show = cli_show_ip_isis_ipv4,
.modify = lib_interface_isis_ipv4_routing_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/ipv6-routing",
.cbs = {
.cli_show = cli_show_ip_isis_ipv6,
.modify = lib_interface_isis_ipv6_routing_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/bfd-monitoring",
.cbs = {
.modify = lib_interface_isis_bfd_monitoring_modify,
.cli_show = cli_show_ip_isis_bfd_monitoring,
}
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/csnp-interval",
.cbs = {
.cli_show = cli_show_ip_isis_csnp_interval,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-1",
.cbs = {
.modify = lib_interface_isis_csnp_interval_level_1_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-2",
.cbs = {
.modify = lib_interface_isis_csnp_interval_level_2_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/psnp-interval",
.cbs = {
.cli_show = cli_show_ip_isis_psnp_interval,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-1",
.cbs = {
.modify = lib_interface_isis_psnp_interval_level_1_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-2",
.cbs = {
.modify = lib_interface_isis_psnp_interval_level_2_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/padding",
.cbs = {
.cli_show = cli_show_ip_isis_hello_padding,
.modify = lib_interface_isis_hello_padding_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/interval",
.cbs = {
.cli_show = cli_show_ip_isis_hello_interval,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-1",
.cbs = {
.modify = lib_interface_isis_hello_interval_level_1_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-2",
.cbs = {
.modify = lib_interface_isis_hello_interval_level_2_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/multiplier",
.cbs = {
.cli_show = cli_show_ip_isis_hello_multi,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-1",
.cbs = {
.modify = lib_interface_isis_hello_multiplier_level_1_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-2",
.cbs = {
.modify = lib_interface_isis_hello_multiplier_level_2_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/metric",
.cbs = {
.cli_show = cli_show_ip_isis_metric,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/metric/level-1",
.cbs = {
.modify = lib_interface_isis_metric_level_1_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/metric/level-2",
.cbs = {
.modify = lib_interface_isis_metric_level_2_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/priority",
.cbs = {
.cli_show = cli_show_ip_isis_priority,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/priority/level-1",
.cbs = {
.modify = lib_interface_isis_priority_level_1_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/priority/level-2",
.cbs = {
.modify = lib_interface_isis_priority_level_2_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/network-type",
.cbs = {
.cli_show = cli_show_ip_isis_network_type,
.modify = lib_interface_isis_network_type_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/passive",
.cbs = {
.cli_show = cli_show_ip_isis_passive,
.modify = lib_interface_isis_passive_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/password",
.cbs = {
.cli_show = cli_show_ip_isis_password,
.create = lib_interface_isis_password_create,
.destroy = lib_interface_isis_password_destroy,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/password/password",
.cbs = {
.modify = lib_interface_isis_password_password_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/password/password-type",
.cbs = {
.modify = lib_interface_isis_password_password_type_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/disable-three-way-handshake",
.cbs = {
.cli_show = cli_show_ip_isis_threeway_shake,
.modify = lib_interface_isis_disable_three_way_handshake_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-unicast",
.cbs = {
.cli_show = cli_show_ip_isis_mt_ipv4_unicast,
.modify = lib_interface_isis_multi_topology_ipv4_unicast_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-multicast",
.cbs = {
.cli_show = cli_show_ip_isis_mt_ipv4_multicast,
.modify = lib_interface_isis_multi_topology_ipv4_multicast_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-management",
.cbs = {
.cli_show = cli_show_ip_isis_mt_ipv4_mgmt,
.modify = lib_interface_isis_multi_topology_ipv4_management_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-unicast",
.cbs = {
.cli_show = cli_show_ip_isis_mt_ipv6_unicast,
.modify = lib_interface_isis_multi_topology_ipv6_unicast_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-multicast",
.cbs = {
.cli_show = cli_show_ip_isis_mt_ipv6_multicast,
.modify = lib_interface_isis_multi_topology_ipv6_multicast_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-management",
.cbs = {
.cli_show = cli_show_ip_isis_mt_ipv6_mgmt,
.modify = lib_interface_isis_multi_topology_ipv6_management_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-dstsrc",
.cbs = {
.cli_show = cli_show_ip_isis_mt_ipv6_dstsrc,
.modify = lib_interface_isis_multi_topology_ipv6_dstsrc_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency",
.cbs = {
.get_next = lib_interface_isis_adjacencies_adjacency_get_next,
}
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-sys-type",
.cbs = {
.get_elem = lib_interface_isis_adjacencies_adjacency_neighbor_sys_type_get_elem,
}
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-sysid",
.cbs = {
.get_elem = lib_interface_isis_adjacencies_adjacency_neighbor_sysid_get_elem,
}
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-extended-circuit-id",
.cbs = {
.get_elem = lib_interface_isis_adjacencies_adjacency_neighbor_extended_circuit_id_get_elem,
}
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-snpa",
.cbs = {
.get_elem = lib_interface_isis_adjacencies_adjacency_neighbor_snpa_get_elem,
}
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/hold-timer",
.cbs = {
.get_elem = lib_interface_isis_adjacencies_adjacency_hold_timer_get_elem,
}
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-priority",
.cbs = {
.get_elem = lib_interface_isis_adjacencies_adjacency_neighbor_priority_get_elem,
}
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/state",
.cbs = {
.get_elem = lib_interface_isis_adjacencies_adjacency_state_get_elem,
}
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-changes",
.cbs = {
.get_elem = lib_interface_isis_event_counters_adjacency_changes_get_elem,
}
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-number",
.cbs = {
.get_elem = lib_interface_isis_event_counters_adjacency_number_get_elem,
}
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/init-fails",
.cbs = {
.get_elem = lib_interface_isis_event_counters_init_fails_get_elem,
}
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-rejects",
.cbs = {
.get_elem = lib_interface_isis_event_counters_adjacency_rejects_get_elem,
}
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/id-len-mismatch",
.cbs = {
.get_elem = lib_interface_isis_event_counters_id_len_mismatch_get_elem,
}
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/max-area-addresses-mismatch",
.cbs = {
.get_elem = lib_interface_isis_event_counters_max_area_addresses_mismatch_get_elem,
}
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/authentication-type-fails",
.cbs = {
.get_elem = lib_interface_isis_event_counters_authentication_type_fails_get_elem,
}
},
{
.xpath = "/frr-interface:lib/interface/frr-isisd:isis/event-counters/authentication-fails",
.cbs = {
.get_elem = lib_interface_isis_event_counters_authentication_fails_get_elem,
}
},
{
.xpath = NULL,
},
}
};

548
isisd/isis_nb.h Normal file
View File

@ -0,0 +1,548 @@
/*
* Copyright (C) 2018 Volta Networks
* Emanuele Di Pascale
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ISISD_ISIS_NB_H_
#define ISISD_ISIS_NB_H_
extern const struct frr_yang_module_info frr_isisd_info;
/* Forward declaration(s). */
struct isis_area;
struct isis_circuit;
struct isis_adjacency;
/* Mandatory callbacks. */
int isis_instance_create(enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_destroy(enum nb_event event, const struct lyd_node *dnode);
int isis_instance_is_type_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_area_address_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_area_address_destroy(enum nb_event event,
const struct lyd_node *dnode);
int isis_instance_dynamic_hostname_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_attached_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_overload_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_metric_style_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_purge_originator_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_lsp_mtu_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_lsp_refresh_interval_level_1_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_lsp_refresh_interval_level_2_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_lsp_maximum_lifetime_level_1_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_lsp_maximum_lifetime_level_2_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_lsp_generation_interval_level_1_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_lsp_generation_interval_level_2_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_spf_ietf_backoff_delay_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_spf_ietf_backoff_delay_destroy(enum nb_event event,
const struct lyd_node *dnode);
int isis_instance_spf_ietf_backoff_delay_init_delay_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_spf_ietf_backoff_delay_short_delay_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_spf_ietf_backoff_delay_long_delay_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_spf_ietf_backoff_delay_hold_down_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_spf_ietf_backoff_delay_time_to_learn_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_spf_minimum_interval_level_1_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_spf_minimum_interval_level_2_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_area_password_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_area_password_destroy(enum nb_event event,
const struct lyd_node *dnode);
int isis_instance_area_password_password_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_area_password_password_type_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_area_password_authenticate_snp_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_domain_password_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_domain_password_destroy(enum nb_event event,
const struct lyd_node *dnode);
int isis_instance_domain_password_password_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_domain_password_password_type_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_domain_password_authenticate_snp_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_default_information_originate_ipv4_create(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_default_information_originate_ipv4_destroy(
enum nb_event event, const struct lyd_node *dnode);
int isis_instance_default_information_originate_ipv4_always_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_default_information_originate_ipv4_route_map_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_default_information_originate_ipv4_route_map_destroy(
enum nb_event event, const struct lyd_node *dnode);
int isis_instance_default_information_originate_ipv4_metric_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_default_information_originate_ipv6_create(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_default_information_originate_ipv6_destroy(
enum nb_event event, const struct lyd_node *dnode);
int isis_instance_default_information_originate_ipv6_always_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_default_information_originate_ipv6_route_map_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_default_information_originate_ipv6_route_map_destroy(
enum nb_event event, const struct lyd_node *dnode);
int isis_instance_default_information_originate_ipv6_metric_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_redistribute_ipv4_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_redistribute_ipv4_destroy(enum nb_event event,
const struct lyd_node *dnode);
int isis_instance_redistribute_ipv4_route_map_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_redistribute_ipv4_route_map_destroy(
enum nb_event event, const struct lyd_node *dnode);
int isis_instance_redistribute_ipv4_metric_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_redistribute_ipv6_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_redistribute_ipv6_destroy(enum nb_event event,
const struct lyd_node *dnode);
int isis_instance_redistribute_ipv6_route_map_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_redistribute_ipv6_route_map_destroy(
enum nb_event event, const struct lyd_node *dnode);
int isis_instance_redistribute_ipv6_metric_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_multi_topology_ipv4_multicast_create(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_multi_topology_ipv4_multicast_destroy(
enum nb_event event, const struct lyd_node *dnode);
int isis_instance_multi_topology_ipv4_multicast_overload_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_multi_topology_ipv4_management_create(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_multi_topology_ipv4_management_destroy(
enum nb_event event, const struct lyd_node *dnode);
int isis_instance_multi_topology_ipv4_management_overload_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_multi_topology_ipv6_unicast_create(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_multi_topology_ipv6_unicast_destroy(
enum nb_event event, const struct lyd_node *dnode);
int isis_instance_multi_topology_ipv6_unicast_overload_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_multi_topology_ipv6_multicast_create(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_multi_topology_ipv6_multicast_destroy(
enum nb_event event, const struct lyd_node *dnode);
int isis_instance_multi_topology_ipv6_multicast_overload_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_multi_topology_ipv6_management_create(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_multi_topology_ipv6_management_destroy(
enum nb_event event, const struct lyd_node *dnode);
int isis_instance_multi_topology_ipv6_management_overload_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_multi_topology_ipv6_dstsrc_create(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_multi_topology_ipv6_dstsrc_destroy(
enum nb_event event, const struct lyd_node *dnode);
int isis_instance_multi_topology_ipv6_dstsrc_overload_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_log_adjacency_changes_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_mpls_te_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_mpls_te_destroy(enum nb_event event,
const struct lyd_node *dnode);
int isis_instance_mpls_te_router_address_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int isis_instance_mpls_te_router_address_destroy(enum nb_event event,
const struct lyd_node *dnode);
int lib_interface_isis_create(enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_destroy(enum nb_event event,
const struct lyd_node *dnode);
int lib_interface_isis_area_tag_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_ipv4_routing_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_ipv6_routing_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_circuit_type_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_bfd_monitoring_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_csnp_interval_level_1_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_csnp_interval_level_2_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_psnp_interval_level_1_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_psnp_interval_level_2_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_hello_padding_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_hello_interval_level_1_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_hello_interval_level_2_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_hello_multiplier_level_1_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_hello_multiplier_level_2_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_metric_level_1_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_metric_level_2_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_priority_level_1_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_priority_level_2_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_network_type_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_passive_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_password_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_password_destroy(enum nb_event event,
const struct lyd_node *dnode);
int lib_interface_isis_password_password_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_password_password_type_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_disable_three_way_handshake_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_multi_topology_ipv4_unicast_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_multi_topology_ipv4_multicast_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_multi_topology_ipv4_management_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_multi_topology_ipv6_unicast_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_multi_topology_ipv6_multicast_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_multi_topology_ipv6_management_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_isis_multi_topology_ipv6_dstsrc_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
const void *
lib_interface_isis_adjacencies_adjacency_get_next(const void *parent_list_entry,
const void *list_entry);
struct yang_data *
lib_interface_isis_adjacencies_adjacency_neighbor_sys_type_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
lib_interface_isis_adjacencies_adjacency_neighbor_sysid_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
lib_interface_isis_adjacencies_adjacency_neighbor_extended_circuit_id_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
lib_interface_isis_adjacencies_adjacency_neighbor_snpa_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *lib_interface_isis_adjacencies_adjacency_hold_timer_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
lib_interface_isis_adjacencies_adjacency_neighbor_priority_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
lib_interface_isis_adjacencies_adjacency_state_get_elem(const char *xpath,
const void *list_entry);
struct yang_data *lib_interface_isis_event_counters_adjacency_changes_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *lib_interface_isis_event_counters_adjacency_number_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
lib_interface_isis_event_counters_init_fails_get_elem(const char *xpath,
const void *list_entry);
struct yang_data *lib_interface_isis_event_counters_adjacency_rejects_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *lib_interface_isis_event_counters_id_len_mismatch_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
lib_interface_isis_event_counters_max_area_addresses_mismatch_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
lib_interface_isis_event_counters_authentication_type_fails_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
lib_interface_isis_event_counters_authentication_fails_get_elem(
const char *xpath, const void *list_entry);
/* Optional 'apply_finish' callbacks. */
void ietf_backoff_delay_apply_finish(const struct lyd_node *dnode);
void area_password_apply_finish(const struct lyd_node *dnode);
void domain_password_apply_finish(const struct lyd_node *dnode);
void default_info_origin_apply_finish(const struct lyd_node *dnode, int family);
void default_info_origin_ipv4_apply_finish(const struct lyd_node *dnode);
void default_info_origin_ipv6_apply_finish(const struct lyd_node *dnode);
void redistribute_apply_finish(const struct lyd_node *dnode, int family);
void redistribute_ipv4_apply_finish(const struct lyd_node *dnode);
void redistribute_ipv6_apply_finish(const struct lyd_node *dnode);
/* Optional 'cli_show' callbacks. */
void cli_show_router_isis(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_ipv4(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_ipv6(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_bfd_monitoring(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_area_address(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_is_type(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_dynamic_hostname(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_attached(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_overload(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_metric_style(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_area_pwd(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_domain_pwd(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_lsp_gen_interval(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_lsp_ref_interval(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_lsp_max_lifetime(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_lsp_mtu(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_spf_min_interval(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_spf_ietf_backoff(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_purge_origin(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_mpls_te(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_mpls_te_router_addr(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_def_origin_ipv4(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_def_origin_ipv6(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_redistribute_ipv4(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_redistribute_ipv6(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_mt_ipv4_multicast(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_mt_ipv4_mgmt(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_mt_ipv6_unicast(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_mt_ipv6_multicast(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_mt_ipv6_mgmt(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_mt_ipv6_dstsrc(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_passive(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_password(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_metric(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_hello_interval(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_hello_multi(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_threeway_shake(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_hello_padding(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_csnp_interval(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_psnp_interval(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_mt_ipv4_unicast(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_mt_ipv4_multicast(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_mt_ipv4_mgmt(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_mt_ipv6_unicast(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_mt_ipv6_multicast(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_mt_ipv6_mgmt(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_mt_ipv6_dstsrc(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_circ_type(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_network_type(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_isis_priority(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_isis_log_adjacency(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
/* Notifications. */
void isis_notif_db_overload(const struct isis_area *area, bool overload);
void isis_notif_lsp_too_large(const struct isis_circuit *circuit,
uint32_t pdu_size, const char *lsp_id);
void isis_notif_if_state_change(const struct isis_circuit *circuit, bool down);
void isis_notif_corrupted_lsp(const struct isis_area *area,
const char *lsp_id); /* currently unused */
void isis_notif_lsp_exceed_max(const struct isis_area *area,
const char *lsp_id);
void isis_notif_max_area_addr_mismatch(const struct isis_circuit *circuit,
uint8_t max_area_addrs,
const char *raw_pdu);
void isis_notif_authentication_type_failure(const struct isis_circuit *circuit,
const char *raw_pdu);
void isis_notif_authentication_failure(const struct isis_circuit *circuit,
const char *raw_pdu);
void isis_notif_adj_state_change(const struct isis_adjacency *adj,
int new_state, const char *reason);
void isis_notif_reject_adjacency(const struct isis_circuit *circuit,
const char *reason, const char *raw_pdu);
void isis_notif_area_mismatch(const struct isis_circuit *circuit,
const char *raw_pdu);
void isis_notif_lsp_received(const struct isis_circuit *circuit,
const char *lsp_id, uint32_t seqno,
uint32_t timestamp, const char *sys_id);
void isis_notif_lsp_gen(const struct isis_area *area, const char *lsp_id,
uint32_t seqno, uint32_t timestamp);
void isis_notif_id_len_mismatch(const struct isis_circuit *circuit,
uint8_t rcv_id_len, const char *raw_pdu);
void isis_notif_version_skew(const struct isis_circuit *circuit,
uint8_t version, const char *raw_pdu);
void isis_notif_lsp_error(const struct isis_circuit *circuit,
const char *lsp_id, const char *raw_pdu,
uint32_t offset, uint8_t tlv_type);
void isis_notif_seqno_skipped(const struct isis_circuit *circuit,
const char *lsp_id);
void isis_notif_own_lsp_purge(const struct isis_circuit *circuit,
const char *lsp_id);
#endif /* ISISD_ISIS_NB_H_ */

2236
isisd/isis_nb_config.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,491 @@
/*
* Copyright (C) 2018 Volta Networks
* Emanuele Di Pascale
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "northbound.h"
#include "log.h"
#include "isisd/isisd.h"
#include "isisd/isis_nb.h"
#include "isisd/isis_adjacency.h"
#include "isisd/isis_dynhn.h"
#include "isisd/isis_misc.h"
/*
* Helper functions.
*/
static void notif_prep_instance_hdr(const char *xpath,
const struct isis_area *area,
const char *routing_instance,
struct list *args)
{
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
snprintf(xpath_arg, sizeof(xpath_arg), "%s/routing-instance", xpath);
data = yang_data_new_string(xpath_arg, routing_instance);
listnode_add(args, data);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/routing-protocol-name",
xpath);
data = yang_data_new_string(xpath_arg, area->area_tag);
listnode_add(args, data);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/isis-level", xpath);
data = yang_data_new_enum(xpath_arg, area->is_type);
listnode_add(args, data);
}
static void notif_prepr_iface_hdr(const char *xpath,
const struct isis_circuit *circuit,
struct list *args)
{
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
snprintf(xpath_arg, sizeof(xpath_arg), "%s/interface-name", xpath);
data = yang_data_new_string(xpath_arg, circuit->interface->name);
listnode_add(args, data);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/interface-level", xpath);
data = yang_data_new_enum(xpath_arg, circuit->is_type);
listnode_add(args, data);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/extended-circuit-id", xpath);
/* we do not seem to have the extended version of the circuit_id */
data = yang_data_new_uint32(xpath_arg, (uint32_t)circuit->circuit_id);
listnode_add(args, data);
}
/*
* XPath: /frr-isisd:database-overload
*/
void isis_notif_db_overload(const struct isis_area *area, bool overload)
{
const char *xpath = "/frr-isisd:database-overload";
struct list *arguments = yang_data_list_new();
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
notif_prep_instance_hdr(xpath, area, "default", arguments);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/overload", xpath);
data = yang_data_new_enum(xpath_arg, !!overload);
listnode_add(arguments, data);
nb_notification_send(xpath, arguments);
}
/*
* XPath: /frr-isisd:lsp-too-large
*/
void isis_notif_lsp_too_large(const struct isis_circuit *circuit,
uint32_t pdu_size, const char *lsp_id)
{
const char *xpath = "/frr-isisd:lsp-too-large";
struct list *arguments = yang_data_list_new();
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
struct isis_area *area = circuit->area;
notif_prep_instance_hdr(xpath, area, "default", arguments);
notif_prepr_iface_hdr(xpath, circuit, arguments);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/pdu-size", xpath);
data = yang_data_new_uint32(xpath_arg, pdu_size);
listnode_add(arguments, data);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath);
data = yang_data_new_string(xpath_arg, lsp_id);
listnode_add(arguments, data);
nb_notification_send(xpath, arguments);
}
/*
* XPath: /frr-isisd:if-state-change
*/
void isis_notif_if_state_change(const struct isis_circuit *circuit, bool down)
{
const char *xpath = "/frr-isisd:if-state-change";
struct list *arguments = yang_data_list_new();
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
struct isis_area *area = circuit->area;
notif_prep_instance_hdr(xpath, area, "default", arguments);
notif_prepr_iface_hdr(xpath, circuit, arguments);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/state", xpath);
data = yang_data_new_enum(xpath_arg, !!down);
listnode_add(arguments, data);
nb_notification_send(xpath, arguments);
}
/*
* XPath: /frr-isisd:corrupted-lsp-detected
*/
void isis_notif_corrupted_lsp(const struct isis_area *area, const char *lsp_id)
{
const char *xpath = "/frr-isisd:corrupted-lsp-detected";
struct list *arguments = yang_data_list_new();
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
notif_prep_instance_hdr(xpath, area, "default", arguments);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath);
data = yang_data_new_string(xpath_arg, lsp_id);
listnode_add(arguments, data);
nb_notification_send(xpath, arguments);
}
/*
* XPath: /frr-isisd:attempt-to-exceed-max-sequence
*/
void isis_notif_lsp_exceed_max(const struct isis_area *area, const char *lsp_id)
{
const char *xpath = "/frr-isisd:attempt-to-exceed-max-sequence";
struct list *arguments = yang_data_list_new();
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
notif_prep_instance_hdr(xpath, area, "default", arguments);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath);
data = yang_data_new_string(xpath_arg, lsp_id);
listnode_add(arguments, data);
nb_notification_send(xpath, arguments);
}
/*
* XPath: /frr-isisd:max-area-addresses-mismatch
*/
void isis_notif_max_area_addr_mismatch(const struct isis_circuit *circuit,
uint8_t max_area_addrs,
const char *raw_pdu)
{
const char *xpath = "/frr-isisd:max-area-addresses-mismatch";
struct list *arguments = yang_data_list_new();
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
struct isis_area *area = circuit->area;
notif_prep_instance_hdr(xpath, area, "default", arguments);
notif_prepr_iface_hdr(xpath, circuit, arguments);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/max-area-addresses", xpath);
data = yang_data_new_uint8(xpath_arg, max_area_addrs);
listnode_add(arguments, data);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath);
data = yang_data_new(xpath_arg, raw_pdu);
listnode_add(arguments, data);
nb_notification_send(xpath, arguments);
}
/*
* XPath: /frr-isisd:authentication-type-failure
*/
void isis_notif_authentication_type_failure(const struct isis_circuit *circuit,
const char *raw_pdu)
{
const char *xpath = "/frr-isisd:authentication-type-failure";
struct list *arguments = yang_data_list_new();
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
struct isis_area *area = circuit->area;
notif_prep_instance_hdr(xpath, area, "default", arguments);
notif_prepr_iface_hdr(xpath, circuit, arguments);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath);
data = yang_data_new(xpath_arg, raw_pdu);
listnode_add(arguments, data);
nb_notification_send(xpath, arguments);
}
/*
* XPath: /frr-isisd:authentication-failure
*/
void isis_notif_authentication_failure(const struct isis_circuit *circuit,
const char *raw_pdu)
{
const char *xpath = "/frr-isisd:authentication-failure";
struct list *arguments = yang_data_list_new();
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
struct isis_area *area = circuit->area;
notif_prep_instance_hdr(xpath, area, "default", arguments);
notif_prepr_iface_hdr(xpath, circuit, arguments);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath);
data = yang_data_new(xpath_arg, raw_pdu);
listnode_add(arguments, data);
nb_notification_send(xpath, arguments);
}
/*
* XPath: /frr-isisd:adjacency-state-change
*/
void isis_notif_adj_state_change(const struct isis_adjacency *adj,
int new_state, const char *reason)
{
const char *xpath = "/frr-isisd:adjacency-state-change";
struct list *arguments = yang_data_list_new();
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
struct isis_circuit *circuit = adj->circuit;
struct isis_area *area = circuit->area;
struct isis_dynhn *dyn = dynhn_find_by_id(adj->sysid);
notif_prep_instance_hdr(xpath, area, "default", arguments);
notif_prepr_iface_hdr(xpath, circuit, arguments);
if (dyn) {
snprintf(xpath_arg, sizeof(xpath_arg), "%s/neighbor", xpath);
data = yang_data_new_string(xpath_arg, dyn->hostname);
listnode_add(arguments, data);
}
snprintf(xpath_arg, sizeof(xpath_arg), "%s/neighbor-system-id", xpath);
data = yang_data_new_string(xpath_arg, sysid_print(adj->sysid));
listnode_add(arguments, data);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/state", xpath);
data = yang_data_new_string(xpath_arg, isis_adj_yang_state(new_state));
listnode_add(arguments, data);
if (new_state == ISIS_ADJ_DOWN) {
snprintf(xpath_arg, sizeof(xpath_arg), "%s/reason", xpath);
data = yang_data_new_string(xpath_arg, reason);
listnode_add(arguments, data);
}
nb_notification_send(xpath, arguments);
}
/*
* XPath: /frr-isisd:rejected-adjacency
*/
void isis_notif_reject_adjacency(const struct isis_circuit *circuit,
const char *reason, const char *raw_pdu)
{
const char *xpath = "/frr-isisd:rejected-adjacency";
struct list *arguments = yang_data_list_new();
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
struct isis_area *area = circuit->area;
notif_prep_instance_hdr(xpath, area, "default", arguments);
notif_prepr_iface_hdr(xpath, circuit, arguments);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/reason", xpath);
data = yang_data_new_string(xpath_arg, reason);
listnode_add(arguments, data);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath);
data = yang_data_new(xpath_arg, raw_pdu);
listnode_add(arguments, data);
nb_notification_send(xpath, arguments);
}
/*
* XPath: /frr-isisd:area-mismatch
*/
void isis_notif_area_mismatch(const struct isis_circuit *circuit,
const char *raw_pdu)
{
const char *xpath = "/frr-isisd:area-mismatch";
struct list *arguments = yang_data_list_new();
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
struct isis_area *area = circuit->area;
notif_prep_instance_hdr(xpath, area, "default", arguments);
notif_prepr_iface_hdr(xpath, circuit, arguments);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath);
data = yang_data_new(xpath_arg, raw_pdu);
listnode_add(arguments, data);
nb_notification_send(xpath, arguments);
}
/*
* XPath: /frr-isisd:lsp-received
*/
void isis_notif_lsp_received(const struct isis_circuit *circuit,
const char *lsp_id, uint32_t seqno,
uint32_t timestamp, const char *sys_id)
{
const char *xpath = "/frr-isisd:lsp-received";
struct list *arguments = yang_data_list_new();
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
struct isis_area *area = circuit->area;
notif_prep_instance_hdr(xpath, area, "default", arguments);
notif_prepr_iface_hdr(xpath, circuit, arguments);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath);
data = yang_data_new_string(xpath_arg, lsp_id);
listnode_add(arguments, data);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/sequence", xpath);
data = yang_data_new_uint32(xpath_arg, seqno);
listnode_add(arguments, data);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/received-timestamp", xpath);
data = yang_data_new_uint32(xpath_arg, timestamp);
listnode_add(arguments, data);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/neighbor-system-id", xpath);
data = yang_data_new_string(xpath_arg, sys_id);
listnode_add(arguments, data);
nb_notification_send(xpath, arguments);
}
/*
* XPath: /frr-isisd:lsp-generation
*/
void isis_notif_lsp_gen(const struct isis_area *area, const char *lsp_id,
uint32_t seqno, uint32_t timestamp)
{
const char *xpath = "/frr-isisd:lsp-generation";
struct list *arguments = yang_data_list_new();
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
notif_prep_instance_hdr(xpath, area, "default", arguments);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath);
data = yang_data_new_string(xpath_arg, lsp_id);
listnode_add(arguments, data);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/sequence", xpath);
data = yang_data_new_uint32(xpath_arg, seqno);
listnode_add(arguments, data);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/send-timestamp", xpath);
data = yang_data_new_uint32(xpath_arg, timestamp);
listnode_add(arguments, data);
nb_notification_send(xpath, arguments);
}
/*
* XPath: /frr-isisd:id-len-mismatch
*/
void isis_notif_id_len_mismatch(const struct isis_circuit *circuit,
uint8_t rcv_id_len, const char *raw_pdu)
{
const char *xpath = "/frr-isisd:id-len-mismatch";
struct list *arguments = yang_data_list_new();
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
struct isis_area *area = circuit->area;
notif_prep_instance_hdr(xpath, area, "default", arguments);
notif_prepr_iface_hdr(xpath, circuit, arguments);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/pdu-field-len", xpath);
data = yang_data_new_uint8(xpath_arg, rcv_id_len);
listnode_add(arguments, data);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath);
data = yang_data_new(xpath_arg, raw_pdu);
listnode_add(arguments, data);
nb_notification_send(xpath, arguments);
}
/*
* XPath: /frr-isisd:version-skew
*/
void isis_notif_version_skew(const struct isis_circuit *circuit,
uint8_t version, const char *raw_pdu)
{
const char *xpath = "/frr-isisd:version-skew";
struct list *arguments = yang_data_list_new();
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
struct isis_area *area = circuit->area;
notif_prep_instance_hdr(xpath, area, "default", arguments);
notif_prepr_iface_hdr(xpath, circuit, arguments);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/protocol-version", xpath);
data = yang_data_new_uint8(xpath_arg, version);
listnode_add(arguments, data);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath);
data = yang_data_new(xpath_arg, raw_pdu);
listnode_add(arguments, data);
nb_notification_send(xpath, arguments);
}
/*
* XPath: /frr-isisd:lsp-error-detected
*/
void isis_notif_lsp_error(const struct isis_circuit *circuit,
const char *lsp_id, const char *raw_pdu,
__attribute__((unused)) uint32_t offset,
__attribute__((unused)) uint8_t tlv_type)
{
const char *xpath = "/frr-isisd:lsp-error-detected";
struct list *arguments = yang_data_list_new();
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
struct isis_area *area = circuit->area;
notif_prep_instance_hdr(xpath, area, "default", arguments);
notif_prepr_iface_hdr(xpath, circuit, arguments);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath);
data = yang_data_new_string(xpath_arg, lsp_id);
listnode_add(arguments, data);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath);
data = yang_data_new(xpath_arg, raw_pdu);
listnode_add(arguments, data);
/* ignore offset and tlv_type which cannot be set properly */
nb_notification_send(xpath, arguments);
}
/*
* XPath: /frr-isisd:sequence-number-skipped
*/
void isis_notif_seqno_skipped(const struct isis_circuit *circuit,
const char *lsp_id)
{
const char *xpath = "/frr-isisd:sequence-number-skipped";
struct list *arguments = yang_data_list_new();
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
struct isis_area *area = circuit->area;
notif_prep_instance_hdr(xpath, area, "default", arguments);
notif_prepr_iface_hdr(xpath, circuit, arguments);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath);
data = yang_data_new_string(xpath_arg, lsp_id);
listnode_add(arguments, data);
nb_notification_send(xpath, arguments);
}
/*
* XPath: /frr-isisd:own-lsp-purge
*/
void isis_notif_own_lsp_purge(const struct isis_circuit *circuit,
const char *lsp_id)
{
const char *xpath = "/frr-isisd:own-lsp-purge";
struct list *arguments = yang_data_list_new();
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
struct isis_area *area = circuit->area;
notif_prep_instance_hdr(xpath, area, "default", arguments);
notif_prepr_iface_hdr(xpath, circuit, arguments);
snprintf(xpath_arg, sizeof(xpath_arg), "%s/lsp-id", xpath);
data = yang_data_new_string(xpath_arg, lsp_id);
listnode_add(arguments, data);
nb_notification_send(xpath, arguments);
}

386
isisd/isis_nb_state.c Normal file
View File

@ -0,0 +1,386 @@
/*
* Copyright (C) 2018 Volta Networks
* Emanuele Di Pascale
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "northbound.h"
#include "linklist.h"
#include "isisd/isisd.h"
#include "isisd/isis_nb.h"
#include "isisd/isis_circuit.h"
#include "isisd/isis_adjacency.h"
#include "isisd/isis_misc.h"
/*
* XPath: /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency
*/
const void *
lib_interface_isis_adjacencies_adjacency_get_next(const void *parent_list_entry,
const void *list_entry)
{
struct interface *ifp;
struct isis_circuit *circuit;
struct isis_adjacency *adj, *adj_next = NULL;
struct list *list;
struct listnode *node, *node_next;
/* Get first adjacency. */
if (list_entry == NULL) {
ifp = (struct interface *)parent_list_entry;
if (!ifp)
return NULL;
circuit = circuit_scan_by_ifp(ifp);
if (!circuit)
return NULL;
switch (circuit->circ_type) {
case CIRCUIT_T_BROADCAST:
for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS;
level++) {
adj = listnode_head(
circuit->u.bc.adjdb[level - 1]);
if (adj)
break;
}
break;
case CIRCUIT_T_P2P:
adj = circuit->u.p2p.neighbor;
break;
default:
adj = NULL;
break;
}
return adj;
}
/* Get next adjacency. */
adj = (struct isis_adjacency *)list_entry;
circuit = adj->circuit;
switch (circuit->circ_type) {
case CIRCUIT_T_BROADCAST:
list = circuit->u.bc.adjdb[adj->level - 1];
node = listnode_lookup(list, adj);
node_next = listnextnode(node);
if (node_next)
adj_next = listgetdata(node_next);
else if (adj->level == ISIS_LEVEL1) {
/*
* Once we finish the L1 adjacencies, move to the L2
* adjacencies list.
*/
list = circuit->u.bc.adjdb[ISIS_LEVEL2 - 1];
adj_next = listnode_head(list);
}
break;
case CIRCUIT_T_P2P:
/* P2P circuits have at most one adjacency. */
default:
break;
}
return adj_next;
}
/*
* XPath:
* /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-sys-type
*/
struct yang_data *
lib_interface_isis_adjacencies_adjacency_neighbor_sys_type_get_elem(
const char *xpath, const void *list_entry)
{
const struct isis_adjacency *adj = list_entry;
return yang_data_new_enum(xpath, adj->level);
}
/*
* XPath:
* /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-sysid
*/
struct yang_data *
lib_interface_isis_adjacencies_adjacency_neighbor_sysid_get_elem(
const char *xpath, const void *list_entry)
{
const struct isis_adjacency *adj = list_entry;
return yang_data_new_string(xpath, sysid_print(adj->sysid));
}
/*
* XPath:
* /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-extended-circuit-id
*/
struct yang_data *
lib_interface_isis_adjacencies_adjacency_neighbor_extended_circuit_id_get_elem(
const char *xpath, const void *list_entry)
{
const struct isis_adjacency *adj = list_entry;
return yang_data_new_uint32(xpath, adj->circuit->circuit_id);
}
/*
* XPath:
* /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-snpa
*/
struct yang_data *
lib_interface_isis_adjacencies_adjacency_neighbor_snpa_get_elem(
const char *xpath, const void *list_entry)
{
const struct isis_adjacency *adj = list_entry;
return yang_data_new_string(xpath, snpa_print(adj->snpa));
}
/*
* XPath:
* /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/hold-timer
*/
struct yang_data *lib_interface_isis_adjacencies_adjacency_hold_timer_get_elem(
const char *xpath, const void *list_entry)
{
const struct isis_adjacency *adj = list_entry;
return yang_data_new_uint16(xpath, adj->hold_time);
}
/*
* XPath:
* /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/neighbor-priority
*/
struct yang_data *
lib_interface_isis_adjacencies_adjacency_neighbor_priority_get_elem(
const char *xpath, const void *list_entry)
{
const struct isis_adjacency *adj = list_entry;
return yang_data_new_uint8(xpath, adj->prio[adj->level - 1]);
}
/*
* XPath:
* /frr-interface:lib/interface/frr-isisd:isis/adjacencies/adjacency/state
*/
struct yang_data *
lib_interface_isis_adjacencies_adjacency_state_get_elem(const char *xpath,
const void *list_entry)
{
const struct isis_adjacency *adj = list_entry;
return yang_data_new_string(xpath, isis_adj_yang_state(adj->adj_state));
}
/*
* XPath:
* /frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-changes
*/
struct yang_data *lib_interface_isis_event_counters_adjacency_changes_get_elem(
const char *xpath, const void *list_entry)
{
struct interface *ifp;
struct isis_circuit *circuit;
ifp = (struct interface *)list_entry;
if (!ifp)
return NULL;
circuit = circuit_scan_by_ifp(ifp);
if (!circuit)
return NULL;
return yang_data_new_uint32(xpath, circuit->adj_state_changes);
}
/*
* XPath:
* /frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-number
*/
struct yang_data *lib_interface_isis_event_counters_adjacency_number_get_elem(
const char *xpath, const void *list_entry)
{
struct interface *ifp;
struct isis_circuit *circuit;
struct isis_adjacency *adj;
struct listnode *node;
uint32_t total = 0;
ifp = (struct interface *)list_entry;
if (!ifp)
return NULL;
circuit = circuit_scan_by_ifp(ifp);
if (!circuit)
return NULL;
/*
* TODO: keep track of the number of adjacencies instead of calculating
* it on demand.
*/
switch (circuit->circ_type) {
case CIRCUIT_T_BROADCAST:
for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) {
for (ALL_LIST_ELEMENTS_RO(
circuit->u.bc.adjdb[level - 1], node, adj))
total++;
}
break;
case CIRCUIT_T_P2P:
adj = circuit->u.p2p.neighbor;
if (adj)
total = 1;
break;
default:
break;
}
return yang_data_new_uint32(xpath, total);
}
/*
* XPath: /frr-interface:lib/interface/frr-isisd:isis/event-counters/init-fails
*/
struct yang_data *
lib_interface_isis_event_counters_init_fails_get_elem(const char *xpath,
const void *list_entry)
{
struct interface *ifp;
struct isis_circuit *circuit;
ifp = (struct interface *)list_entry;
if (!ifp)
return NULL;
circuit = circuit_scan_by_ifp(ifp);
if (!circuit)
return NULL;
return yang_data_new_uint32(xpath, circuit->init_failures);
}
/*
* XPath:
* /frr-interface:lib/interface/frr-isisd:isis/event-counters/adjacency-rejects
*/
struct yang_data *lib_interface_isis_event_counters_adjacency_rejects_get_elem(
const char *xpath, const void *list_entry)
{
struct interface *ifp;
struct isis_circuit *circuit;
ifp = (struct interface *)list_entry;
if (!ifp)
return NULL;
circuit = circuit_scan_by_ifp(ifp);
if (!circuit)
return NULL;
return yang_data_new_uint32(xpath, circuit->rej_adjacencies);
}
/*
* XPath:
* /frr-interface:lib/interface/frr-isisd:isis/event-counters/id-len-mismatch
*/
struct yang_data *lib_interface_isis_event_counters_id_len_mismatch_get_elem(
const char *xpath, const void *list_entry)
{
struct interface *ifp;
struct isis_circuit *circuit;
ifp = (struct interface *)list_entry;
if (!ifp)
return NULL;
circuit = circuit_scan_by_ifp(ifp);
if (!circuit)
return NULL;
return yang_data_new_uint32(xpath, circuit->id_len_mismatches);
}
/*
* XPath:
* /frr-interface:lib/interface/frr-isisd:isis/event-counters/max-area-addresses-mismatch
*/
struct yang_data *
lib_interface_isis_event_counters_max_area_addresses_mismatch_get_elem(
const char *xpath, const void *list_entry)
{
struct interface *ifp;
struct isis_circuit *circuit;
ifp = (struct interface *)list_entry;
if (!ifp)
return NULL;
circuit = circuit_scan_by_ifp(ifp);
if (!circuit)
return NULL;
return yang_data_new_uint32(xpath, circuit->max_area_addr_mismatches);
}
/*
* XPath:
* /frr-interface:lib/interface/frr-isisd:isis/event-counters/authentication-type-fails
*/
struct yang_data *
lib_interface_isis_event_counters_authentication_type_fails_get_elem(
const char *xpath, const void *list_entry)
{
struct interface *ifp;
struct isis_circuit *circuit;
ifp = (struct interface *)list_entry;
if (!ifp)
return NULL;
circuit = circuit_scan_by_ifp(ifp);
if (!circuit)
return NULL;
return yang_data_new_uint32(xpath, circuit->auth_type_failures);
}
/*
* XPath:
* /frr-interface:lib/interface/frr-isisd:isis/event-counters/authentication-fails
*/
struct yang_data *
lib_interface_isis_event_counters_authentication_fails_get_elem(
const char *xpath, const void *list_entry)
{
struct interface *ifp;
struct isis_circuit *circuit;
ifp = (struct interface *)list_entry;
if (!ifp)
return NULL;
circuit = circuit_scan_by_ifp(ifp);
if (!circuit)
return NULL;
return yang_data_new_uint32(xpath, circuit->auth_failures);
}

File diff suppressed because it is too large Load Diff

View File

@ -58,6 +58,7 @@
#include "isisd/fabricd.h"
#include "isisd/isis_tx_queue.h"
#include "isisd/isis_pdu_counter.h"
#include "isisd/isis_nb.h"
static int ack_lsp(struct isis_lsp_hdr *hdr, struct isis_circuit *circuit,
int level)

View File

@ -57,6 +57,7 @@
#include "isisd/isis_te.h"
#include "isisd/isis_mt.h"
#include "isisd/fabricd.h"
#include "isisd/isis_nb.h"
struct isis *isis = NULL;

View File

@ -219,52 +219,6 @@ int isis_area_passwd_cleartext_set(struct isis_area *area, int level,
int isis_area_passwd_hmac_md5_set(struct isis_area *area, int level,
const char *passwd, uint8_t snp_auth);
extern const struct frr_yang_module_info frr_isisd_info;
extern void isis_northbound_init(void);
/* YANG northbound notifications */
extern void isis_notif_db_overload(const struct isis_area *area, bool overload);
extern void isis_notif_lsp_too_large(const struct isis_circuit *circuit,
uint32_t pdu_size, const char *lsp_id);
extern void isis_notif_if_state_change(const struct isis_circuit *circuit,
bool down);
extern void isis_notif_corrupted_lsp(const struct isis_area *area,
const char *lsp_id); /* currently unused */
extern void isis_notif_lsp_exceed_max(const struct isis_area *area,
const char *lsp_id);
extern void
isis_notif_max_area_addr_mismatch(const struct isis_circuit *circuit,
uint8_t max_area_addrs, const char *raw_pdu);
extern void
isis_notif_authentication_type_failure(const struct isis_circuit *circuit,
const char *raw_pdu);
extern void
isis_notif_authentication_failure(const struct isis_circuit *circuit,
const char *raw_pdu);
extern void isis_notif_adj_state_change(const struct isis_adjacency *adj,
int new_state, const char *reason);
extern void isis_notif_reject_adjacency(const struct isis_circuit *circuit,
const char *reason,
const char *raw_pdu);
extern void isis_notif_area_mismatch(const struct isis_circuit *circuit,
const char *raw_pdu);
extern void isis_notif_lsp_received(const struct isis_circuit *circuit,
const char *lsp_id, uint32_t seqno,
uint32_t timestamp, const char *sys_id);
extern void isis_notif_lsp_gen(const struct isis_area *area, const char *lsp_id,
uint32_t seqno, uint32_t timestamp);
extern void isis_notif_id_len_mismatch(const struct isis_circuit *circuit,
uint8_t rcv_id_len, const char *raw_pdu);
extern void isis_notif_version_skew(const struct isis_circuit *circuit,
uint8_t version, const char *raw_pdu);
extern void isis_notif_lsp_error(const struct isis_circuit *circuit,
const char *lsp_id, const char *raw_pdu,
uint32_t offset, uint8_t tlv_type);
extern void isis_notif_seqno_skipped(const struct isis_circuit *circuit,
const char *lsp_id);
extern void isis_notif_own_lsp_purge(const struct isis_circuit *circuit,
const char *lsp_id);
/* Master of threads. */
extern struct thread_master *master;

View File

@ -39,6 +39,7 @@ noinst_HEADERS += \
isisd/isis_memory.h \
isisd/isis_misc.h \
isisd/isis_mt.h \
isisd/isis_nb.h \
isisd/isis_network.h \
isisd/isis_pdu.h \
isisd/isis_pdu_counter.h \
@ -54,7 +55,6 @@ noinst_HEADERS += \
isisd/isisd.h \
isisd/iso_checksum.h \
isisd/fabricd.h \
isisd/isis_cli.h \
# end
LIBISIS_SOURCES = \
@ -99,7 +99,10 @@ ISIS_LDADD_COMMON = lib/libfrr.la $(LIBCAP)
isisd_libisis_a_SOURCES = \
$(LIBISIS_SOURCES) \
isisd/isis_northbound.c \
isisd/isis_nb.c \
isisd/isis_nb_config.c \
isisd/isis_nb_notifications.c \
isisd/isis_nb_state.c \
isisd/isis_cli.c \
#end

View File

@ -29,7 +29,7 @@
#include "libfrr.h"
#include "ripd/ripd.h"
#include "ripd/rip_cli.h"
#include "ripd/rip_nb.h"
#ifndef VTYSH_EXTRACT_PL
#include "ripd/rip_cli_clippy.c"
#endif

View File

@ -1,86 +0,0 @@
/*
* Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
* Copyright (C) 2018 NetDEF, Inc.
* Renato Westphal
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _FRR_RIP_CLI_H_
#define _FRR_RIP_CLI_H_
extern void cli_show_router_rip(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_rip_allow_ecmp(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_rip_default_information_originate(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_rip_default_metric(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_rip_distance(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_rip_distance_source(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_rip_neighbor(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_rip_network_prefix(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_rip_network_interface(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_rip_offset_list(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_rip_passive_default(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_rip_passive_interface(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_rip_non_passive_interface(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_rip_redistribute(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_rip_route(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_rip_timers(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_rip_version(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_ip_rip_split_horizon(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_ip_rip_v2_broadcast(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_ip_rip_receive_version(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_ip_rip_send_version(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_ip_rip_authentication_scheme(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_ip_rip_authentication_string(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_ip_rip_authentication_key_chain(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
#endif /* _FRR_RIP_CLI_H_ */

View File

@ -38,6 +38,7 @@
#include "libfrr.h"
#include "ripd/ripd.h"
#include "ripd/rip_nb.h"
#include "ripd/rip_errors.h"
/* ripd options. */

369
ripd/rip_nb.c Normal file
View File

@ -0,0 +1,369 @@
/*
* Copyright (C) 2018 NetDEF, Inc.
* Renato Westphal
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "northbound.h"
#include "libfrr.h"
#include "ripd/rip_nb.h"
/* clang-format off */
const struct frr_yang_module_info frr_ripd_info = {
.name = "frr-ripd",
.nodes = {
{
.xpath = "/frr-ripd:ripd/instance",
.cbs = {
.cli_show = cli_show_router_rip,
.create = ripd_instance_create,
.destroy = ripd_instance_destroy,
.get_keys = ripd_instance_get_keys,
.get_next = ripd_instance_get_next,
.lookup_entry = ripd_instance_lookup_entry,
},
},
{
.xpath = "/frr-ripd:ripd/instance/allow-ecmp",
.cbs = {
.cli_show = cli_show_rip_allow_ecmp,
.modify = ripd_instance_allow_ecmp_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/default-information-originate",
.cbs = {
.cli_show = cli_show_rip_default_information_originate,
.modify = ripd_instance_default_information_originate_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/default-metric",
.cbs = {
.cli_show = cli_show_rip_default_metric,
.modify = ripd_instance_default_metric_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/distance/default",
.cbs = {
.cli_show = cli_show_rip_distance,
.modify = ripd_instance_distance_default_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/distance/source",
.cbs = {
.cli_show = cli_show_rip_distance_source,
.create = ripd_instance_distance_source_create,
.destroy = ripd_instance_distance_source_destroy,
},
},
{
.xpath = "/frr-ripd:ripd/instance/distance/source/distance",
.cbs = {
.modify = ripd_instance_distance_source_distance_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/distance/source/access-list",
.cbs = {
.destroy = ripd_instance_distance_source_access_list_destroy,
.modify = ripd_instance_distance_source_access_list_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/explicit-neighbor",
.cbs = {
.cli_show = cli_show_rip_neighbor,
.create = ripd_instance_explicit_neighbor_create,
.destroy = ripd_instance_explicit_neighbor_destroy,
},
},
{
.xpath = "/frr-ripd:ripd/instance/network",
.cbs = {
.cli_show = cli_show_rip_network_prefix,
.create = ripd_instance_network_create,
.destroy = ripd_instance_network_destroy,
},
},
{
.xpath = "/frr-ripd:ripd/instance/interface",
.cbs = {
.cli_show = cli_show_rip_network_interface,
.create = ripd_instance_interface_create,
.destroy = ripd_instance_interface_destroy,
},
},
{
.xpath = "/frr-ripd:ripd/instance/offset-list",
.cbs = {
.cli_show = cli_show_rip_offset_list,
.create = ripd_instance_offset_list_create,
.destroy = ripd_instance_offset_list_destroy,
},
},
{
.xpath = "/frr-ripd:ripd/instance/offset-list/access-list",
.cbs = {
.modify = ripd_instance_offset_list_access_list_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/offset-list/metric",
.cbs = {
.modify = ripd_instance_offset_list_metric_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/passive-default",
.cbs = {
.cli_show = cli_show_rip_passive_default,
.modify = ripd_instance_passive_default_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/passive-interface",
.cbs = {
.cli_show = cli_show_rip_passive_interface,
.create = ripd_instance_passive_interface_create,
.destroy = ripd_instance_passive_interface_destroy,
},
},
{
.xpath = "/frr-ripd:ripd/instance/non-passive-interface",
.cbs = {
.cli_show = cli_show_rip_non_passive_interface,
.create = ripd_instance_non_passive_interface_create,
.destroy = ripd_instance_non_passive_interface_destroy,
},
},
{
.xpath = "/frr-ripd:ripd/instance/redistribute",
.cbs = {
.apply_finish = ripd_instance_redistribute_apply_finish,
.cli_show = cli_show_rip_redistribute,
.create = ripd_instance_redistribute_create,
.destroy = ripd_instance_redistribute_destroy,
},
},
{
.xpath = "/frr-ripd:ripd/instance/redistribute/route-map",
.cbs = {
.destroy = ripd_instance_redistribute_route_map_destroy,
.modify = ripd_instance_redistribute_route_map_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/redistribute/metric",
.cbs = {
.destroy = ripd_instance_redistribute_metric_destroy,
.modify = ripd_instance_redistribute_metric_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/static-route",
.cbs = {
.cli_show = cli_show_rip_route,
.create = ripd_instance_static_route_create,
.destroy = ripd_instance_static_route_destroy,
},
},
{
.xpath = "/frr-ripd:ripd/instance/timers",
.cbs = {
.apply_finish = ripd_instance_timers_apply_finish,
.cli_show = cli_show_rip_timers,
},
},
{
.xpath = "/frr-ripd:ripd/instance/timers/flush-interval",
.cbs = {
.modify = ripd_instance_timers_flush_interval_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/timers/holddown-interval",
.cbs = {
.modify = ripd_instance_timers_holddown_interval_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/timers/update-interval",
.cbs = {
.modify = ripd_instance_timers_update_interval_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/version",
.cbs = {
.cli_show = cli_show_rip_version,
},
},
{
.xpath = "/frr-ripd:ripd/instance/version/receive",
.cbs = {
.modify = ripd_instance_version_receive_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/version/send",
.cbs = {
.modify = ripd_instance_version_send_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/split-horizon",
.cbs = {
.cli_show = cli_show_ip_rip_split_horizon,
.modify = lib_interface_rip_split_horizon_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/v2-broadcast",
.cbs = {
.cli_show = cli_show_ip_rip_v2_broadcast,
.modify = lib_interface_rip_v2_broadcast_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/version-receive",
.cbs = {
.cli_show = cli_show_ip_rip_receive_version,
.modify = lib_interface_rip_version_receive_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/version-send",
.cbs = {
.cli_show = cli_show_ip_rip_send_version,
.modify = lib_interface_rip_version_send_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-scheme",
.cbs = {
.cli_show = cli_show_ip_rip_authentication_scheme,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-scheme/mode",
.cbs = {
.modify = lib_interface_rip_authentication_scheme_mode_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-scheme/md5-auth-length",
.cbs = {
.destroy = lib_interface_rip_authentication_scheme_md5_auth_length_destroy,
.modify = lib_interface_rip_authentication_scheme_md5_auth_length_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-password",
.cbs = {
.cli_show = cli_show_ip_rip_authentication_string,
.destroy = lib_interface_rip_authentication_password_destroy,
.modify = lib_interface_rip_authentication_password_modify,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-key-chain",
.cbs = {
.cli_show = cli_show_ip_rip_authentication_key_chain,
.destroy = lib_interface_rip_authentication_key_chain_destroy,
.modify = lib_interface_rip_authentication_key_chain_modify,
},
},
{
.xpath = "/frr-ripd:ripd/instance/state/neighbors/neighbor",
.cbs = {
.get_keys = ripd_instance_state_neighbors_neighbor_get_keys,
.get_next = ripd_instance_state_neighbors_neighbor_get_next,
.lookup_entry = ripd_instance_state_neighbors_neighbor_lookup_entry,
},
},
{
.xpath = "/frr-ripd:ripd/instance/state/neighbors/neighbor/address",
.cbs = {
.get_elem = ripd_instance_state_neighbors_neighbor_address_get_elem,
},
},
{
.xpath = "/frr-ripd:ripd/instance/state/neighbors/neighbor/last-update",
.cbs = {
.get_elem = ripd_instance_state_neighbors_neighbor_last_update_get_elem,
},
},
{
.xpath = "/frr-ripd:ripd/instance/state/neighbors/neighbor/bad-packets-rcvd",
.cbs = {
.get_elem = ripd_instance_state_neighbors_neighbor_bad_packets_rcvd_get_elem,
},
},
{
.xpath = "/frr-ripd:ripd/instance/state/neighbors/neighbor/bad-routes-rcvd",
.cbs = {
.get_elem = ripd_instance_state_neighbors_neighbor_bad_routes_rcvd_get_elem,
},
},
{
.xpath = "/frr-ripd:ripd/instance/state/routes/route",
.cbs = {
.get_keys = ripd_instance_state_routes_route_get_keys,
.get_next = ripd_instance_state_routes_route_get_next,
.lookup_entry = ripd_instance_state_routes_route_lookup_entry,
},
},
{
.xpath = "/frr-ripd:ripd/instance/state/routes/route/prefix",
.cbs = {
.get_elem = ripd_instance_state_routes_route_prefix_get_elem,
},
},
{
.xpath = "/frr-ripd:ripd/instance/state/routes/route/next-hop",
.cbs = {
.get_elem = ripd_instance_state_routes_route_next_hop_get_elem,
},
},
{
.xpath = "/frr-ripd:ripd/instance/state/routes/route/interface",
.cbs = {
.get_elem = ripd_instance_state_routes_route_interface_get_elem,
},
},
{
.xpath = "/frr-ripd:ripd/instance/state/routes/route/metric",
.cbs = {
.get_elem = ripd_instance_state_routes_route_metric_get_elem,
},
},
{
.xpath = "/frr-ripd:clear-rip-route",
.cbs = {
.rpc = clear_rip_route_rpc,
},
},
{
.xpath = NULL,
},
}
};

265
ripd/rip_nb.h Normal file
View File

@ -0,0 +1,265 @@
/*
* Copyright (C) 2018 NetDEF, Inc.
* Renato Westphal
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _FRR_RIP_NB_H_
#define _FRR_RIP_NB_H_
extern const struct frr_yang_module_info frr_ripd_info;
/* Mandatory callbacks. */
int ripd_instance_create(enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_destroy(enum nb_event event, const struct lyd_node *dnode);
const void *ripd_instance_get_next(const void *parent_list_entry,
const void *list_entry);
int ripd_instance_get_keys(const void *list_entry, struct yang_list_keys *keys);
const void *ripd_instance_lookup_entry(const void *parent_list_entry,
const struct yang_list_keys *keys);
int ripd_instance_allow_ecmp_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_default_information_originate_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_default_metric_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_distance_default_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_distance_source_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_distance_source_destroy(enum nb_event event,
const struct lyd_node *dnode);
int ripd_instance_distance_source_distance_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_distance_source_access_list_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_distance_source_access_list_destroy(
enum nb_event event, const struct lyd_node *dnode);
int ripd_instance_explicit_neighbor_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_explicit_neighbor_destroy(enum nb_event event,
const struct lyd_node *dnode);
int ripd_instance_network_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_network_destroy(enum nb_event event,
const struct lyd_node *dnode);
int ripd_instance_interface_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_interface_destroy(enum nb_event event,
const struct lyd_node *dnode);
int ripd_instance_offset_list_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_offset_list_destroy(enum nb_event event,
const struct lyd_node *dnode);
int ripd_instance_offset_list_access_list_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_offset_list_metric_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_passive_default_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_passive_interface_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_passive_interface_destroy(enum nb_event event,
const struct lyd_node *dnode);
int ripd_instance_non_passive_interface_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_non_passive_interface_destroy(enum nb_event event,
const struct lyd_node *dnode);
int ripd_instance_redistribute_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_redistribute_destroy(enum nb_event event,
const struct lyd_node *dnode);
int ripd_instance_redistribute_route_map_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_redistribute_route_map_destroy(enum nb_event event,
const struct lyd_node *dnode);
int ripd_instance_redistribute_metric_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_redistribute_metric_destroy(enum nb_event event,
const struct lyd_node *dnode);
int ripd_instance_static_route_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_static_route_destroy(enum nb_event event,
const struct lyd_node *dnode);
int ripd_instance_timers_flush_interval_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_timers_holddown_interval_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_timers_update_interval_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_version_receive_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripd_instance_version_send_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
const void *
ripd_instance_state_neighbors_neighbor_get_next(const void *parent_list_entry,
const void *list_entry);
int ripd_instance_state_neighbors_neighbor_get_keys(
const void *list_entry, struct yang_list_keys *keys);
const void *ripd_instance_state_neighbors_neighbor_lookup_entry(
const void *parent_list_entry, const struct yang_list_keys *keys);
struct yang_data *
ripd_instance_state_neighbors_neighbor_address_get_elem(const char *xpath,
const void *list_entry);
struct yang_data *ripd_instance_state_neighbors_neighbor_last_update_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
ripd_instance_state_neighbors_neighbor_bad_packets_rcvd_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
ripd_instance_state_neighbors_neighbor_bad_routes_rcvd_get_elem(
const char *xpath, const void *list_entry);
const void *
ripd_instance_state_routes_route_get_next(const void *parent_list_entry,
const void *list_entry);
int ripd_instance_state_routes_route_get_keys(const void *list_entry,
struct yang_list_keys *keys);
const void *ripd_instance_state_routes_route_lookup_entry(
const void *parent_list_entry, const struct yang_list_keys *keys);
struct yang_data *
ripd_instance_state_routes_route_prefix_get_elem(const char *xpath,
const void *list_entry);
struct yang_data *
ripd_instance_state_routes_route_next_hop_get_elem(const char *xpath,
const void *list_entry);
struct yang_data *
ripd_instance_state_routes_route_interface_get_elem(const char *xpath,
const void *list_entry);
struct yang_data *
ripd_instance_state_routes_route_metric_get_elem(const char *xpath,
const void *list_entry);
int clear_rip_route_rpc(const char *xpath, const struct list *input,
struct list *output);
int lib_interface_rip_split_horizon_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_rip_v2_broadcast_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_rip_version_receive_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_rip_version_send_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_rip_authentication_scheme_mode_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_rip_authentication_scheme_md5_auth_length_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_rip_authentication_scheme_md5_auth_length_destroy(
enum nb_event event, const struct lyd_node *dnode);
int lib_interface_rip_authentication_password_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_rip_authentication_password_destroy(
enum nb_event event, const struct lyd_node *dnode);
int lib_interface_rip_authentication_key_chain_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int lib_interface_rip_authentication_key_chain_destroy(
enum nb_event event, const struct lyd_node *dnode);
/* Optional 'apply_finish' callbacks. */
void ripd_instance_redistribute_apply_finish(const struct lyd_node *dnode);
void ripd_instance_timers_apply_finish(const struct lyd_node *dnode);
/* Optional 'cli_show' callbacks. */
void cli_show_router_rip(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_rip_allow_ecmp(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_rip_default_information_originate(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
void cli_show_rip_default_metric(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_rip_distance(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_rip_distance_source(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_rip_neighbor(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_rip_network_prefix(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_rip_network_interface(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_rip_offset_list(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_rip_passive_default(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_rip_passive_interface(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_rip_non_passive_interface(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_rip_redistribute(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_rip_route(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_rip_timers(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_rip_version(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_rip_split_horizon(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_rip_v2_broadcast(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_rip_receive_version(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_rip_send_version(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_rip_authentication_scheme(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_rip_authentication_string(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
void cli_show_ip_rip_authentication_key_chain(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
/* Notifications. */
extern void ripd_notif_send_auth_type_failure(const char *ifname);
extern void ripd_notif_send_auth_failure(const char *ifname);
#endif /* _FRR_RIP_NB_H_ */

1099
ripd/rip_nb_config.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,73 @@
/*
* Copyright (C) 2018 NetDEF, Inc.
* Renato Westphal
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "if.h"
#include "vrf.h"
#include "log.h"
#include "prefix.h"
#include "table.h"
#include "command.h"
#include "routemap.h"
#include "northbound.h"
#include "libfrr.h"
#include "ripd/ripd.h"
#include "ripd/rip_nb.h"
#include "ripd/rip_debug.h"
#include "ripd/rip_interface.h"
/*
* XPath: /frr-ripd:authentication-type-failure
*/
void ripd_notif_send_auth_type_failure(const char *ifname)
{
const char *xpath = "/frr-ripd:authentication-type-failure";
struct list *arguments;
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
arguments = yang_data_list_new();
snprintf(xpath_arg, sizeof(xpath_arg), "%s/interface-name", xpath);
data = yang_data_new_string(xpath_arg, ifname);
listnode_add(arguments, data);
nb_notification_send(xpath, arguments);
}
/*
* XPath: /frr-ripd:authentication-failure
*/
void ripd_notif_send_auth_failure(const char *ifname)
{
const char *xpath = "/frr-ripd:authentication-failure";
struct list *arguments;
char xpath_arg[XPATH_MAXLEN];
struct yang_data *data;
arguments = yang_data_list_new();
snprintf(xpath_arg, sizeof(xpath_arg), "%s/interface-name", xpath);
data = yang_data_new_string(xpath_arg, ifname);
listnode_add(arguments, data);
nb_notification_send(xpath, arguments);
}

105
ripd/rip_nb_rpcs.c Normal file
View File

@ -0,0 +1,105 @@
/*
* Copyright (C) 2018 NetDEF, Inc.
* Renato Westphal
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "if.h"
#include "vrf.h"
#include "log.h"
#include "prefix.h"
#include "table.h"
#include "command.h"
#include "routemap.h"
#include "northbound.h"
#include "libfrr.h"
#include "ripd/ripd.h"
#include "ripd/rip_nb.h"
#include "ripd/rip_debug.h"
#include "ripd/rip_interface.h"
/*
* XPath: /frr-ripd:clear-rip-route
*/
static void clear_rip_route(struct rip *rip)
{
struct route_node *rp;
if (IS_RIP_DEBUG_EVENT)
zlog_debug("Clearing all RIP routes (VRF %s)", rip->vrf_name);
/* Clear received RIP routes */
for (rp = route_top(rip->table); rp; rp = route_next(rp)) {
struct list *list;
struct listnode *listnode;
struct rip_info *rinfo;
list = rp->info;
if (!list)
continue;
for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
if (!rip_route_rte(rinfo))
continue;
if (CHECK_FLAG(rinfo->flags, RIP_RTF_FIB))
rip_zebra_ipv4_delete(rip, rp);
break;
}
if (rinfo) {
RIP_TIMER_OFF(rinfo->t_timeout);
RIP_TIMER_OFF(rinfo->t_garbage_collect);
listnode_delete(list, rinfo);
rip_info_free(rinfo);
}
if (list_isempty(list)) {
list_delete(&list);
rp->info = NULL;
route_unlock_node(rp);
}
}
}
int clear_rip_route_rpc(const char *xpath, const struct list *input,
struct list *output)
{
struct rip *rip;
struct yang_data *yang_vrf;
yang_vrf = yang_data_list_find(input, "%s/%s", xpath, "input/vrf");
if (yang_vrf) {
rip = rip_lookup_by_vrf_name(yang_vrf->value);
if (rip)
clear_rip_route(rip);
} else {
struct vrf *vrf;
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
rip = vrf->info;
if (!rip)
continue;
clear_rip_route(rip);
}
}
return NB_OK;
}

284
ripd/rip_nb_state.c Normal file
View File

@ -0,0 +1,284 @@
/*
* Copyright (C) 2018 NetDEF, Inc.
* Renato Westphal
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "if.h"
#include "vrf.h"
#include "log.h"
#include "prefix.h"
#include "table.h"
#include "command.h"
#include "routemap.h"
#include "northbound.h"
#include "libfrr.h"
#include "ripd/ripd.h"
#include "ripd/rip_nb.h"
#include "ripd/rip_debug.h"
#include "ripd/rip_interface.h"
/*
* XPath: /frr-ripd:ripd/instance
*/
const void *ripd_instance_get_next(const void *parent_list_entry,
const void *list_entry)
{
struct rip *rip = (struct rip *)list_entry;
if (list_entry == NULL)
rip = RB_MIN(rip_instance_head, &rip_instances);
else
rip = RB_NEXT(rip_instance_head, rip);
return rip;
}
int ripd_instance_get_keys(const void *list_entry, struct yang_list_keys *keys)
{
const struct rip *rip = list_entry;
keys->num = 1;
strlcpy(keys->key[0], rip->vrf_name, sizeof(keys->key[0]));
return NB_OK;
}
const void *ripd_instance_lookup_entry(const void *parent_list_entry,
const struct yang_list_keys *keys)
{
const char *vrf_name = keys->key[0];
return rip_lookup_by_vrf_name(vrf_name);
}
/*
* XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor
*/
const void *
ripd_instance_state_neighbors_neighbor_get_next(const void *parent_list_entry,
const void *list_entry)
{
const struct rip *rip = parent_list_entry;
struct listnode *node;
if (list_entry == NULL)
node = listhead(rip->peer_list);
else
node = listnextnode((struct listnode *)list_entry);
return node;
}
int ripd_instance_state_neighbors_neighbor_get_keys(const void *list_entry,
struct yang_list_keys *keys)
{
const struct listnode *node = list_entry;
const struct rip_peer *peer = listgetdata(node);
keys->num = 1;
(void)inet_ntop(AF_INET, &peer->addr, keys->key[0],
sizeof(keys->key[0]));
return NB_OK;
}
const void *ripd_instance_state_neighbors_neighbor_lookup_entry(
const void *parent_list_entry, const struct yang_list_keys *keys)
{
const struct rip *rip = parent_list_entry;
struct in_addr address;
struct rip_peer *peer;
struct listnode *node;
yang_str2ipv4(keys->key[0], &address);
for (ALL_LIST_ELEMENTS_RO(rip->peer_list, node, peer)) {
if (IPV4_ADDR_SAME(&peer->addr, &address))
return node;
}
return NULL;
}
/*
* XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor/address
*/
struct yang_data *
ripd_instance_state_neighbors_neighbor_address_get_elem(const char *xpath,
const void *list_entry)
{
const struct listnode *node = list_entry;
const struct rip_peer *peer = listgetdata(node);
return yang_data_new_ipv4(xpath, &peer->addr);
}
/*
* XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor/last-update
*/
struct yang_data *ripd_instance_state_neighbors_neighbor_last_update_get_elem(
const char *xpath, const void *list_entry)
{
/* TODO: yang:date-and-time is tricky */
return NULL;
}
/*
* XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor/bad-packets-rcvd
*/
struct yang_data *
ripd_instance_state_neighbors_neighbor_bad_packets_rcvd_get_elem(
const char *xpath, const void *list_entry)
{
const struct listnode *node = list_entry;
const struct rip_peer *peer = listgetdata(node);
return yang_data_new_uint32(xpath, peer->recv_badpackets);
}
/*
* XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor/bad-routes-rcvd
*/
struct yang_data *
ripd_instance_state_neighbors_neighbor_bad_routes_rcvd_get_elem(
const char *xpath, const void *list_entry)
{
const struct listnode *node = list_entry;
const struct rip_peer *peer = listgetdata(node);
return yang_data_new_uint32(xpath, peer->recv_badroutes);
}
/*
* XPath: /frr-ripd:ripd/instance/state/routes/route
*/
const void *
ripd_instance_state_routes_route_get_next(const void *parent_list_entry,
const void *list_entry)
{
const struct rip *rip = parent_list_entry;
struct route_node *rn;
if (list_entry == NULL)
rn = route_top(rip->table);
else
rn = route_next((struct route_node *)list_entry);
while (rn && rn->info == NULL)
rn = route_next(rn);
return rn;
}
int ripd_instance_state_routes_route_get_keys(const void *list_entry,
struct yang_list_keys *keys)
{
const struct route_node *rn = list_entry;
keys->num = 1;
(void)prefix2str(&rn->p, keys->key[0], sizeof(keys->key[0]));
return NB_OK;
}
const void *
ripd_instance_state_routes_route_lookup_entry(const void *parent_list_entry,
const struct yang_list_keys *keys)
{
const struct rip *rip = parent_list_entry;
struct prefix prefix;
struct route_node *rn;
yang_str2ipv4p(keys->key[0], &prefix);
rn = route_node_lookup(rip->table, &prefix);
if (!rn || !rn->info)
return NULL;
route_unlock_node(rn);
return rn;
}
/*
* XPath: /frr-ripd:ripd/instance/state/routes/route/prefix
*/
struct yang_data *
ripd_instance_state_routes_route_prefix_get_elem(const char *xpath,
const void *list_entry)
{
const struct route_node *rn = list_entry;
const struct rip_info *rinfo = listnode_head(rn->info);
return yang_data_new_ipv4p(xpath, &rinfo->rp->p);
}
/*
* XPath: /frr-ripd:ripd/instance/state/routes/route/next-hop
*/
struct yang_data *
ripd_instance_state_routes_route_next_hop_get_elem(const char *xpath,
const void *list_entry)
{
const struct route_node *rn = list_entry;
const struct rip_info *rinfo = listnode_head(rn->info);
switch (rinfo->nh.type) {
case NEXTHOP_TYPE_IPV4:
case NEXTHOP_TYPE_IPV4_IFINDEX:
return yang_data_new_ipv4(xpath, &rinfo->nh.gate.ipv4);
default:
return NULL;
}
}
/*
* XPath: /frr-ripd:ripd/instance/state/routes/route/interface
*/
struct yang_data *
ripd_instance_state_routes_route_interface_get_elem(const char *xpath,
const void *list_entry)
{
const struct route_node *rn = list_entry;
const struct rip_info *rinfo = listnode_head(rn->info);
const struct rip *rip = rip_info_get_instance(rinfo);
switch (rinfo->nh.type) {
case NEXTHOP_TYPE_IFINDEX:
case NEXTHOP_TYPE_IPV4_IFINDEX:
return yang_data_new_string(
xpath,
ifindex2ifname(rinfo->nh.ifindex, rip->vrf->vrf_id));
default:
return NULL;
}
}
/*
* XPath: /frr-ripd:ripd/instance/state/routes/route/metric
*/
struct yang_data *
ripd_instance_state_routes_route_metric_get_elem(const char *xpath,
const void *list_entry)
{
const struct route_node *rn = list_entry;
const struct rip_info *rinfo = listnode_head(rn->info);
return yang_data_new_uint8(xpath, rinfo->metric);
}

File diff suppressed because it is too large Load Diff

View File

@ -46,6 +46,7 @@
#include "northbound_cli.h"
#include "ripd/ripd.h"
#include "ripd/rip_nb.h"
#include "ripd/rip_debug.h"
#include "ripd/rip_errors.h"
#include "ripd/rip_interface.h"

View File

@ -521,10 +521,7 @@ extern int offset_list_cmp(struct rip_offset_list *o1,
extern void rip_vrf_init(void);
extern void rip_vrf_terminate(void);
/* YANG notifications */
extern void ripd_notif_send_auth_type_failure(const char *ifname);
extern void ripd_notif_send_auth_failure(const char *ifname);
extern void rip_cli_init(void);
extern struct zebra_privs_t ripd_privs;
extern struct rip_instance_head rip_instances;
@ -535,8 +532,4 @@ extern struct thread_master *master;
DECLARE_HOOK(rip_ifaddr_add, (struct connected * ifc), (ifc))
DECLARE_HOOK(rip_ifaddr_del, (struct connected * ifc), (ifc))
/* Northbound. */
extern void rip_cli_init(void);
extern const struct frr_yang_module_info frr_ripd_info;
#endif /* _ZEBRA_RIP_H */

View File

@ -24,7 +24,11 @@ ripd_librip_a_SOURCES = \
ripd/rip_errors.c \
ripd/rip_interface.c \
ripd/rip_offset.c \
ripd/rip_northbound.c \
ripd/rip_nb.c \
ripd/rip_nb_config.c \
ripd/rip_nb_rpcs.c \
ripd/rip_nb_notifications.c \
ripd/rip_nb_state.c \
ripd/rip_peer.c \
ripd/rip_routemap.c \
ripd/rip_zebra.c \
@ -35,10 +39,10 @@ ripd/rip_cli_clippy.c: $(CLIPPY_DEPS)
ripd/rip_cli.$(OBJEXT): ripd/rip_cli_clippy.c
noinst_HEADERS += \
ripd/rip_cli.h \
ripd/rip_debug.h \
ripd/rip_errors.h \
ripd/rip_interface.h \
ripd/rip_nb.h \
ripd/ripd.h \
# end

View File

@ -29,7 +29,7 @@
#include "libfrr.h"
#include "ripngd/ripngd.h"
#include "ripngd/ripng_cli.h"
#include "ripngd/ripng_nb.h"
#ifndef VTYSH_EXTRACT_PL
#include "ripngd/ripng_cli_clippy.c"
#endif

View File

@ -1,58 +0,0 @@
/*
* Copyright (C) 1998 Kunihiro Ishiguro
* Copyright (C) 2018 NetDEF, Inc.
* Renato Westphal
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _FRR_RIPNG_CLI_H_
#define _FRR_RIPNG_CLI_H_
extern void cli_show_router_ripng(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_ripng_allow_ecmp(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_ripng_default_information_originate(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_ripng_default_metric(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_ripng_network_prefix(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_ripng_network_interface(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_ripng_offset_list(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_ripng_passive_interface(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_ripng_redistribute(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_ripng_route(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_ripng_aggregate_address(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_ripng_timers(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
extern void cli_show_ipv6_ripng_split_horizon(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
#endif /* _FRR_RIPNG_CLI_H_ */

View File

@ -39,6 +39,7 @@
#include "libfrr.h"
#include "ripngd/ripngd.h"
#include "ripngd/ripng_nb.h"
/* RIPngd options. */
struct option longopts[] = {{0}};

252
ripngd/ripng_nb.c Normal file
View File

@ -0,0 +1,252 @@
/*
* Copyright (C) 2018 NetDEF, Inc.
* Renato Westphal
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "northbound.h"
#include "libfrr.h"
#include "ripngd/ripng_nb.h"
/* clang-format off */
const struct frr_yang_module_info frr_ripngd_info = {
.name = "frr-ripngd",
.nodes = {
{
.xpath = "/frr-ripngd:ripngd/instance",
.cbs = {
.cli_show = cli_show_router_ripng,
.create = ripngd_instance_create,
.destroy = ripngd_instance_destroy,
.get_keys = ripngd_instance_get_keys,
.get_next = ripngd_instance_get_next,
.lookup_entry = ripngd_instance_lookup_entry,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/allow-ecmp",
.cbs = {
.cli_show = cli_show_ripng_allow_ecmp,
.modify = ripngd_instance_allow_ecmp_modify,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/default-information-originate",
.cbs = {
.cli_show = cli_show_ripng_default_information_originate,
.modify = ripngd_instance_default_information_originate_modify,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/default-metric",
.cbs = {
.cli_show = cli_show_ripng_default_metric,
.modify = ripngd_instance_default_metric_modify,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/network",
.cbs = {
.cli_show = cli_show_ripng_network_prefix,
.create = ripngd_instance_network_create,
.destroy = ripngd_instance_network_destroy,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/interface",
.cbs = {
.cli_show = cli_show_ripng_network_interface,
.create = ripngd_instance_interface_create,
.destroy = ripngd_instance_interface_destroy,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/offset-list",
.cbs = {
.cli_show = cli_show_ripng_offset_list,
.create = ripngd_instance_offset_list_create,
.destroy = ripngd_instance_offset_list_destroy,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/offset-list/access-list",
.cbs = {
.modify = ripngd_instance_offset_list_access_list_modify,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/offset-list/metric",
.cbs = {
.modify = ripngd_instance_offset_list_metric_modify,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/passive-interface",
.cbs = {
.cli_show = cli_show_ripng_passive_interface,
.create = ripngd_instance_passive_interface_create,
.destroy = ripngd_instance_passive_interface_destroy,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/redistribute",
.cbs = {
.apply_finish = ripngd_instance_redistribute_apply_finish,
.cli_show = cli_show_ripng_redistribute,
.create = ripngd_instance_redistribute_create,
.destroy = ripngd_instance_redistribute_destroy,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/redistribute/route-map",
.cbs = {
.destroy = ripngd_instance_redistribute_route_map_destroy,
.modify = ripngd_instance_redistribute_route_map_modify,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/redistribute/metric",
.cbs = {
.destroy = ripngd_instance_redistribute_metric_destroy,
.modify = ripngd_instance_redistribute_metric_modify,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/static-route",
.cbs = {
.cli_show = cli_show_ripng_route,
.create = ripngd_instance_static_route_create,
.destroy = ripngd_instance_static_route_destroy,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/aggregate-address",
.cbs = {
.cli_show = cli_show_ripng_aggregate_address,
.create = ripngd_instance_aggregate_address_create,
.destroy = ripngd_instance_aggregate_address_destroy,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/timers",
.cbs = {
.apply_finish = ripngd_instance_timers_apply_finish,
.cli_show = cli_show_ripng_timers,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/timers/flush-interval",
.cbs = {
.modify = ripngd_instance_timers_flush_interval_modify,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/timers/holddown-interval",
.cbs = {
.modify = ripngd_instance_timers_holddown_interval_modify,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/timers/update-interval",
.cbs = {
.modify = ripngd_instance_timers_update_interval_modify,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/state/neighbors/neighbor",
.cbs = {
.get_keys = ripngd_instance_state_neighbors_neighbor_get_keys,
.get_next = ripngd_instance_state_neighbors_neighbor_get_next,
.lookup_entry = ripngd_instance_state_neighbors_neighbor_lookup_entry,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/state/neighbors/neighbor/address",
.cbs = {
.get_elem = ripngd_instance_state_neighbors_neighbor_address_get_elem,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/state/neighbors/neighbor/last-update",
.cbs = {
.get_elem = ripngd_instance_state_neighbors_neighbor_last_update_get_elem,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/state/neighbors/neighbor/bad-packets-rcvd",
.cbs = {
.get_elem = ripngd_instance_state_neighbors_neighbor_bad_packets_rcvd_get_elem,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/state/neighbors/neighbor/bad-routes-rcvd",
.cbs = {
.get_elem = ripngd_instance_state_neighbors_neighbor_bad_routes_rcvd_get_elem,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/state/routes/route",
.cbs = {
.get_keys = ripngd_instance_state_routes_route_get_keys,
.get_next = ripngd_instance_state_routes_route_get_next,
.lookup_entry = ripngd_instance_state_routes_route_lookup_entry,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/state/routes/route/prefix",
.cbs = {
.get_elem = ripngd_instance_state_routes_route_prefix_get_elem,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/state/routes/route/next-hop",
.cbs = {
.get_elem = ripngd_instance_state_routes_route_next_hop_get_elem,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/state/routes/route/interface",
.cbs = {
.get_elem = ripngd_instance_state_routes_route_interface_get_elem,
},
},
{
.xpath = "/frr-ripngd:ripngd/instance/state/routes/route/metric",
.cbs = {
.get_elem = ripngd_instance_state_routes_route_metric_get_elem,
},
},
{
.xpath = "/frr-ripngd:clear-ripng-route",
.cbs = {
.rpc = clear_ripng_route_rpc,
},
},
{
.xpath = "/frr-interface:lib/interface/frr-ripngd:ripng/split-horizon",
.cbs = {
.cli_show = cli_show_ipv6_ripng_split_horizon,
.modify = lib_interface_ripng_split_horizon_modify,
},
},
{
.xpath = NULL,
},
}
};

179
ripngd/ripng_nb.h Normal file
View File

@ -0,0 +1,179 @@
/*
* Copyright (C) 2018 NetDEF, Inc.
* Renato Westphal
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _FRR_RIPNG_NB_H_
#define _FRR_RIPNG_NB_H_
extern const struct frr_yang_module_info frr_ripngd_info;
/* Mandatory callbacks. */
int ripngd_instance_create(enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int ripngd_instance_destroy(enum nb_event event, const struct lyd_node *dnode);
const void *ripngd_instance_get_next(const void *parent_list_entry,
const void *list_entry);
int ripngd_instance_get_keys(const void *list_entry,
struct yang_list_keys *keys);
const void *ripngd_instance_lookup_entry(const void *parent_list_entry,
const struct yang_list_keys *keys);
int ripngd_instance_allow_ecmp_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripngd_instance_default_information_originate_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int ripngd_instance_default_metric_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripngd_instance_network_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripngd_instance_network_destroy(enum nb_event event,
const struct lyd_node *dnode);
int ripngd_instance_interface_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripngd_instance_interface_destroy(enum nb_event event,
const struct lyd_node *dnode);
int ripngd_instance_offset_list_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripngd_instance_offset_list_destroy(enum nb_event event,
const struct lyd_node *dnode);
int ripngd_instance_offset_list_access_list_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripngd_instance_offset_list_metric_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripngd_instance_passive_interface_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripngd_instance_passive_interface_destroy(enum nb_event event,
const struct lyd_node *dnode);
int ripngd_instance_redistribute_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripngd_instance_redistribute_destroy(enum nb_event event,
const struct lyd_node *dnode);
int ripngd_instance_redistribute_route_map_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripngd_instance_redistribute_route_map_destroy(
enum nb_event event, const struct lyd_node *dnode);
int ripngd_instance_redistribute_metric_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripngd_instance_redistribute_metric_destroy(enum nb_event event,
const struct lyd_node *dnode);
int ripngd_instance_static_route_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripngd_instance_static_route_destroy(enum nb_event event,
const struct lyd_node *dnode);
int ripngd_instance_aggregate_address_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripngd_instance_aggregate_address_destroy(enum nb_event event,
const struct lyd_node *dnode);
int ripngd_instance_timers_flush_interval_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
int ripngd_instance_timers_holddown_interval_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource);
int ripngd_instance_timers_update_interval_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
const void *
ripngd_instance_state_neighbors_neighbor_get_next(const void *parent_list_entry,
const void *list_entry);
int ripngd_instance_state_neighbors_neighbor_get_keys(
const void *list_entry, struct yang_list_keys *keys);
const void *ripngd_instance_state_neighbors_neighbor_lookup_entry(
const void *parent_list_entry, const struct yang_list_keys *keys);
struct yang_data *ripngd_instance_state_neighbors_neighbor_address_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *ripngd_instance_state_neighbors_neighbor_last_update_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
ripngd_instance_state_neighbors_neighbor_bad_packets_rcvd_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
ripngd_instance_state_neighbors_neighbor_bad_routes_rcvd_get_elem(
const char *xpath, const void *list_entry);
const void *
ripngd_instance_state_routes_route_get_next(const void *parent_list_entry,
const void *list_entry);
int ripngd_instance_state_routes_route_get_keys(const void *list_entry,
struct yang_list_keys *keys);
const void *ripngd_instance_state_routes_route_lookup_entry(
const void *parent_list_entry, const struct yang_list_keys *keys);
struct yang_data *
ripngd_instance_state_routes_route_prefix_get_elem(const char *xpath,
const void *list_entry);
struct yang_data *
ripngd_instance_state_routes_route_next_hop_get_elem(const char *xpath,
const void *list_entry);
struct yang_data *
ripngd_instance_state_routes_route_interface_get_elem(const char *xpath,
const void *list_entry);
struct yang_data *
ripngd_instance_state_routes_route_metric_get_elem(const char *xpath,
const void *list_entry);
int clear_ripng_route_rpc(const char *xpath, const struct list *input,
struct list *output);
int lib_interface_ripng_split_horizon_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource);
/* Optional 'apply_finish' callbacks. */
void ripngd_instance_redistribute_apply_finish(const struct lyd_node *dnode);
void ripngd_instance_timers_apply_finish(const struct lyd_node *dnode);
/* Optional 'cli_show' callbacks. */
void cli_show_router_ripng(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ripng_allow_ecmp(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ripng_default_information_originate(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
void cli_show_ripng_default_metric(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ripng_network_prefix(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ripng_network_interface(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ripng_offset_list(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ripng_passive_interface(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ripng_redistribute(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ripng_route(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ripng_aggregate_address(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ripng_timers(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_ipv6_ripng_split_horizon(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
#endif /* _FRR_RIPNG_NB_H_ */

714
ripngd/ripng_nb_config.c Normal file
View File

@ -0,0 +1,714 @@
/*
* Copyright (C) 1998 Kunihiro Ishiguro
* Copyright (C) 2018 NetDEF, Inc.
* Renato Westphal
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "if.h"
#include "vrf.h"
#include "log.h"
#include "prefix.h"
#include "table.h"
#include "command.h"
#include "routemap.h"
#include "agg_table.h"
#include "northbound.h"
#include "libfrr.h"
#include "ripngd/ripngd.h"
#include "ripngd/ripng_nb.h"
#include "ripngd/ripng_debug.h"
#include "ripngd/ripng_route.h"
/*
* XPath: /frr-ripngd:ripngd/instance
*/
int ripngd_instance_create(enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource)
{
struct ripng *ripng;
struct vrf *vrf;
const char *vrf_name;
int socket;
vrf_name = yang_dnode_get_string(dnode, "./vrf");
vrf = vrf_lookup_by_name(vrf_name);
/*
* Try to create a RIPng socket only if the VRF is enabled, otherwise
* create a disabled RIPng instance and wait for the VRF to be enabled.
*/
switch (event) {
case NB_EV_VALIDATE:
break;
case NB_EV_PREPARE:
if (!vrf || !vrf_is_enabled(vrf))
break;
socket = ripng_make_socket(vrf);
if (socket < 0)
return NB_ERR_RESOURCE;
resource->fd = socket;
break;
case NB_EV_ABORT:
if (!vrf || !vrf_is_enabled(vrf))
break;
socket = resource->fd;
close(socket);
break;
case NB_EV_APPLY:
if (vrf && vrf_is_enabled(vrf))
socket = resource->fd;
else
socket = -1;
ripng = ripng_create(vrf_name, vrf, socket);
nb_running_set_entry(dnode, ripng);
break;
}
return NB_OK;
}
int ripngd_instance_destroy(enum nb_event event, const struct lyd_node *dnode)
{
struct ripng *ripng;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_unset_entry(dnode);
ripng_clean(ripng);
return NB_OK;
}
const void *ripngd_instance_get_next(const void *parent_list_entry,
const void *list_entry)
{
struct ripng *ripng = (struct ripng *)list_entry;
if (list_entry == NULL)
ripng = RB_MIN(ripng_instance_head, &ripng_instances);
else
ripng = RB_NEXT(ripng_instance_head, ripng);
return ripng;
}
int ripngd_instance_get_keys(const void *list_entry,
struct yang_list_keys *keys)
{
const struct ripng *ripng = list_entry;
keys->num = 1;
strlcpy(keys->key[0], ripng->vrf_name, sizeof(keys->key[0]));
return NB_OK;
}
const void *ripngd_instance_lookup_entry(const void *parent_list_entry,
const struct yang_list_keys *keys)
{
const char *vrf_name = keys->key[0];
return ripng_lookup_by_vrf_name(vrf_name);
}
/*
* XPath: /frr-ripngd:ripngd/instance/allow-ecmp
*/
int ripngd_instance_allow_ecmp_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
struct ripng *ripng;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
ripng->ecmp = yang_dnode_get_bool(dnode, NULL);
if (!ripng->ecmp)
ripng_ecmp_disable(ripng);
return NB_OK;
}
/*
* XPath: /frr-ripngd:ripngd/instance/default-information-originate
*/
int ripngd_instance_default_information_originate_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource)
{
struct ripng *ripng;
bool default_information;
struct prefix_ipv6 p;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
default_information = yang_dnode_get_bool(dnode, NULL);
str2prefix_ipv6("::/0", &p);
if (default_information) {
ripng_redistribute_add(ripng, ZEBRA_ROUTE_RIPNG,
RIPNG_ROUTE_DEFAULT, &p, 0, NULL, 0);
} else {
ripng_redistribute_delete(ripng, ZEBRA_ROUTE_RIPNG,
RIPNG_ROUTE_DEFAULT, &p, 0);
}
return NB_OK;
}
/*
* XPath: /frr-ripngd:ripngd/instance/default-metric
*/
int ripngd_instance_default_metric_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
struct ripng *ripng;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
ripng->default_metric = yang_dnode_get_uint8(dnode, NULL);
return NB_OK;
}
/*
* XPath: /frr-ripngd:ripngd/instance/network
*/
int ripngd_instance_network_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
struct ripng *ripng;
struct prefix p;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
yang_dnode_get_ipv6p(&p, dnode, NULL);
apply_mask_ipv6((struct prefix_ipv6 *)&p);
return ripng_enable_network_add(ripng, &p);
}
int ripngd_instance_network_destroy(enum nb_event event,
const struct lyd_node *dnode)
{
struct ripng *ripng;
struct prefix p;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
yang_dnode_get_ipv6p(&p, dnode, NULL);
apply_mask_ipv6((struct prefix_ipv6 *)&p);
return ripng_enable_network_delete(ripng, &p);
}
/*
* XPath: /frr-ripngd:ripngd/instance/interface
*/
int ripngd_instance_interface_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
struct ripng *ripng;
const char *ifname;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
ifname = yang_dnode_get_string(dnode, NULL);
return ripng_enable_if_add(ripng, ifname);
}
int ripngd_instance_interface_destroy(enum nb_event event,
const struct lyd_node *dnode)
{
struct ripng *ripng;
const char *ifname;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
ifname = yang_dnode_get_string(dnode, NULL);
return ripng_enable_if_delete(ripng, ifname);
}
/*
* XPath: /frr-ripngd:ripngd/instance/offset-list
*/
int ripngd_instance_offset_list_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
struct ripng *ripng;
const char *ifname;
struct ripng_offset_list *offset;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
ifname = yang_dnode_get_string(dnode, "./interface");
offset = ripng_offset_list_new(ripng, ifname);
nb_running_set_entry(dnode, offset);
return NB_OK;
}
int ripngd_instance_offset_list_destroy(enum nb_event event,
const struct lyd_node *dnode)
{
int direct;
struct ripng_offset_list *offset;
if (event != NB_EV_APPLY)
return NB_OK;
direct = yang_dnode_get_enum(dnode, "./direction");
offset = nb_running_unset_entry(dnode);
if (offset->direct[direct].alist_name) {
free(offset->direct[direct].alist_name);
offset->direct[direct].alist_name = NULL;
}
if (offset->direct[RIPNG_OFFSET_LIST_IN].alist_name == NULL
&& offset->direct[RIPNG_OFFSET_LIST_OUT].alist_name == NULL)
ripng_offset_list_del(offset);
return NB_OK;
}
/*
* XPath: /frr-ripngd:ripngd/instance/offset-list/access-list
*/
int ripngd_instance_offset_list_access_list_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
int direct;
struct ripng_offset_list *offset;
const char *alist_name;
if (event != NB_EV_APPLY)
return NB_OK;
direct = yang_dnode_get_enum(dnode, "../direction");
alist_name = yang_dnode_get_string(dnode, NULL);
offset = nb_running_get_entry(dnode, NULL, true);
if (offset->direct[direct].alist_name)
free(offset->direct[direct].alist_name);
offset->direct[direct].alist_name = strdup(alist_name);
return NB_OK;
}
/*
* XPath: /frr-ripngd:ripngd/instance/offset-list/metric
*/
int ripngd_instance_offset_list_metric_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
int direct;
uint8_t metric;
struct ripng_offset_list *offset;
if (event != NB_EV_APPLY)
return NB_OK;
direct = yang_dnode_get_enum(dnode, "../direction");
metric = yang_dnode_get_uint8(dnode, NULL);
offset = nb_running_get_entry(dnode, NULL, true);
offset->direct[direct].metric = metric;
return NB_OK;
}
/*
* XPath: /frr-ripngd:ripngd/instance/passive-interface
*/
int ripngd_instance_passive_interface_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
struct ripng *ripng;
const char *ifname;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
ifname = yang_dnode_get_string(dnode, NULL);
return ripng_passive_interface_set(ripng, ifname);
}
int ripngd_instance_passive_interface_destroy(enum nb_event event,
const struct lyd_node *dnode)
{
struct ripng *ripng;
const char *ifname;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
ifname = yang_dnode_get_string(dnode, NULL);
return ripng_passive_interface_unset(ripng, ifname);
}
/*
* XPath: /frr-ripngd:ripngd/instance/redistribute
*/
int ripngd_instance_redistribute_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
struct ripng *ripng;
int type;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
type = yang_dnode_get_enum(dnode, "./protocol");
ripng->redist[type].enabled = true;
return NB_OK;
}
int ripngd_instance_redistribute_destroy(enum nb_event event,
const struct lyd_node *dnode)
{
struct ripng *ripng;
int type;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
type = yang_dnode_get_enum(dnode, "./protocol");
ripng->redist[type].enabled = false;
if (ripng->redist[type].route_map.name) {
free(ripng->redist[type].route_map.name);
ripng->redist[type].route_map.name = NULL;
ripng->redist[type].route_map.map = NULL;
}
ripng->redist[type].metric_config = false;
ripng->redist[type].metric = 0;
if (ripng->enabled)
ripng_redistribute_conf_delete(ripng, type);
return NB_OK;
}
void ripngd_instance_redistribute_apply_finish(const struct lyd_node *dnode)
{
struct ripng *ripng;
int type;
ripng = nb_running_get_entry(dnode, NULL, true);
type = yang_dnode_get_enum(dnode, "./protocol");
if (ripng->enabled)
ripng_redistribute_conf_update(ripng, type);
}
/*
* XPath: /frr-ripngd:ripngd/instance/redistribute/route-map
*/
int ripngd_instance_redistribute_route_map_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
struct ripng *ripng;
int type;
const char *rmap_name;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
type = yang_dnode_get_enum(dnode, "../protocol");
rmap_name = yang_dnode_get_string(dnode, NULL);
if (ripng->redist[type].route_map.name)
free(ripng->redist[type].route_map.name);
ripng->redist[type].route_map.name = strdup(rmap_name);
ripng->redist[type].route_map.map = route_map_lookup_by_name(rmap_name);
return NB_OK;
}
int ripngd_instance_redistribute_route_map_destroy(enum nb_event event,
const struct lyd_node *dnode)
{
struct ripng *ripng;
int type;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
type = yang_dnode_get_enum(dnode, "../protocol");
free(ripng->redist[type].route_map.name);
ripng->redist[type].route_map.name = NULL;
ripng->redist[type].route_map.map = NULL;
return NB_OK;
}
/*
* XPath: /frr-ripngd:ripngd/instance/redistribute/metric
*/
int ripngd_instance_redistribute_metric_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
struct ripng *ripng;
int type;
uint8_t metric;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
type = yang_dnode_get_enum(dnode, "../protocol");
metric = yang_dnode_get_uint8(dnode, NULL);
ripng->redist[type].metric_config = true;
ripng->redist[type].metric = metric;
return NB_OK;
}
int ripngd_instance_redistribute_metric_destroy(enum nb_event event,
const struct lyd_node *dnode)
{
struct ripng *ripng;
int type;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
type = yang_dnode_get_enum(dnode, "../protocol");
ripng->redist[type].metric_config = false;
ripng->redist[type].metric = 0;
return NB_OK;
}
/*
* XPath: /frr-ripngd:ripngd/instance/static-route
*/
int ripngd_instance_static_route_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
struct ripng *ripng;
struct prefix_ipv6 p;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
yang_dnode_get_ipv6p(&p, dnode, NULL);
apply_mask_ipv6(&p);
ripng_redistribute_add(ripng, ZEBRA_ROUTE_RIPNG, RIPNG_ROUTE_STATIC, &p,
0, NULL, 0);
return NB_OK;
}
int ripngd_instance_static_route_destroy(enum nb_event event,
const struct lyd_node *dnode)
{
struct ripng *ripng;
struct prefix_ipv6 p;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
yang_dnode_get_ipv6p(&p, dnode, NULL);
apply_mask_ipv6(&p);
ripng_redistribute_delete(ripng, ZEBRA_ROUTE_RIPNG, RIPNG_ROUTE_STATIC,
&p, 0);
return NB_OK;
}
/*
* XPath: /frr-ripngd:ripngd/instance/aggregate-address
*/
int ripngd_instance_aggregate_address_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
struct ripng *ripng;
struct prefix_ipv6 p;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
yang_dnode_get_ipv6p(&p, dnode, NULL);
apply_mask_ipv6(&p);
ripng_aggregate_add(ripng, (struct prefix *)&p);
return NB_OK;
}
int ripngd_instance_aggregate_address_destroy(enum nb_event event,
const struct lyd_node *dnode)
{
struct ripng *ripng;
struct prefix_ipv6 p;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
yang_dnode_get_ipv6p(&p, dnode, NULL);
apply_mask_ipv6(&p);
ripng_aggregate_delete(ripng, (struct prefix *)&p);
return NB_OK;
}
/*
* XPath: /frr-ripngd:ripngd/instance/timers
*/
void ripngd_instance_timers_apply_finish(const struct lyd_node *dnode)
{
struct ripng *ripng;
ripng = nb_running_get_entry(dnode, NULL, true);
/* Reset update timer thread. */
ripng_event(ripng, RIPNG_UPDATE_EVENT, 0);
}
/*
* XPath: /frr-ripngd:ripngd/instance/timers/flush-interval
*/
int ripngd_instance_timers_flush_interval_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
struct ripng *ripng;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
ripng->garbage_time = yang_dnode_get_uint16(dnode, NULL);
return NB_OK;
}
/*
* XPath: /frr-ripngd:ripngd/instance/timers/holddown-interval
*/
int ripngd_instance_timers_holddown_interval_modify(
enum nb_event event, const struct lyd_node *dnode,
union nb_resource *resource)
{
struct ripng *ripng;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
ripng->timeout_time = yang_dnode_get_uint16(dnode, NULL);
return NB_OK;
}
/*
* XPath: /frr-ripngd:ripngd/instance/timers/update-interval
*/
int ripngd_instance_timers_update_interval_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
struct ripng *ripng;
if (event != NB_EV_APPLY)
return NB_OK;
ripng = nb_running_get_entry(dnode, NULL, true);
ripng->update_time = yang_dnode_get_uint16(dnode, NULL);
return NB_OK;
}
/*
* XPath: /frr-interface:lib/interface/frr-ripngd:ripng/split-horizon
*/
int lib_interface_ripng_split_horizon_modify(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
struct interface *ifp;
struct ripng_interface *ri;
if (event != NB_EV_APPLY)
return NB_OK;
ifp = nb_running_get_entry(dnode, NULL, true);
ri = ifp->info;
ri->split_horizon = yang_dnode_get_enum(dnode, NULL);
return NB_OK;
}

107
ripngd/ripng_nb_rpcs.c Normal file
View File

@ -0,0 +1,107 @@
/*
* Copyright (C) 2018 NetDEF, Inc.
* Renato Westphal
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "if.h"
#include "vrf.h"
#include "log.h"
#include "prefix.h"
#include "table.h"
#include "command.h"
#include "routemap.h"
#include "agg_table.h"
#include "northbound.h"
#include "libfrr.h"
#include "ripngd/ripngd.h"
#include "ripngd/ripng_nb.h"
#include "ripngd/ripng_debug.h"
#include "ripngd/ripng_route.h"
/*
* XPath: /frr-ripngd:clear-ripng-route
*/
static void clear_ripng_route(struct ripng *ripng)
{
struct agg_node *rp;
if (IS_RIPNG_DEBUG_EVENT)
zlog_debug("Clearing all RIPng routes (VRF %s)",
ripng->vrf_name);
/* Clear received RIPng routes */
for (rp = agg_route_top(ripng->table); rp; rp = agg_route_next(rp)) {
struct list *list;
struct listnode *listnode;
struct ripng_info *rinfo;
list = rp->info;
if (list == NULL)
continue;
for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
if (!ripng_route_rte(rinfo))
continue;
if (CHECK_FLAG(rinfo->flags, RIPNG_RTF_FIB))
ripng_zebra_ipv6_delete(ripng, rp);
break;
}
if (rinfo) {
RIPNG_TIMER_OFF(rinfo->t_timeout);
RIPNG_TIMER_OFF(rinfo->t_garbage_collect);
listnode_delete(list, rinfo);
ripng_info_free(rinfo);
}
if (list_isempty(list)) {
list_delete(&list);
rp->info = NULL;
agg_unlock_node(rp);
}
}
}
int clear_ripng_route_rpc(const char *xpath, const struct list *input,
struct list *output)
{
struct ripng *ripng;
struct yang_data *yang_vrf;
yang_vrf = yang_data_list_find(input, "%s/%s", xpath, "input/vrf");
if (yang_vrf) {
ripng = ripng_lookup_by_vrf_name(yang_vrf->value);
if (ripng)
clear_ripng_route(ripng);
} else {
struct vrf *vrf;
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
ripng = vrf->info;
if (!ripng)
continue;
clear_ripng_route(ripng);
}
}
return NB_OK;
}

236
ripngd/ripng_nb_state.c Normal file
View File

@ -0,0 +1,236 @@
/*
* Copyright (C) 2018 NetDEF, Inc.
* Renato Westphal
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "if.h"
#include "vrf.h"
#include "log.h"
#include "prefix.h"
#include "table.h"
#include "command.h"
#include "routemap.h"
#include "agg_table.h"
#include "northbound.h"
#include "libfrr.h"
#include "ripngd/ripngd.h"
#include "ripngd/ripng_nb.h"
#include "ripngd/ripng_debug.h"
#include "ripngd/ripng_route.h"
/*
* XPath: /frr-ripngd:ripngd/instance/state/neighbors/neighbor
*/
const void *
ripngd_instance_state_neighbors_neighbor_get_next(const void *parent_list_entry,
const void *list_entry)
{
const struct ripng *ripng = parent_list_entry;
struct listnode *node;
if (list_entry == NULL)
node = listhead(ripng->peer_list);
else
node = listnextnode((struct listnode *)list_entry);
return node;
}
int ripngd_instance_state_neighbors_neighbor_get_keys(
const void *list_entry, struct yang_list_keys *keys)
{
const struct listnode *node = list_entry;
const struct ripng_peer *peer = listgetdata(node);
keys->num = 1;
(void)inet_ntop(AF_INET6, &peer->addr, keys->key[0],
sizeof(keys->key[0]));
return NB_OK;
}
const void *ripngd_instance_state_neighbors_neighbor_lookup_entry(
const void *parent_list_entry, const struct yang_list_keys *keys)
{
const struct ripng *ripng = parent_list_entry;
struct in6_addr address;
struct ripng_peer *peer;
struct listnode *node;
yang_str2ipv6(keys->key[0], &address);
for (ALL_LIST_ELEMENTS_RO(ripng->peer_list, node, peer)) {
if (IPV6_ADDR_SAME(&peer->addr, &address))
return node;
}
return NULL;
}
/*
* XPath: /frr-ripngd:ripngd/instance/state/neighbors/neighbor/address
*/
struct yang_data *ripngd_instance_state_neighbors_neighbor_address_get_elem(
const char *xpath, const void *list_entry)
{
const struct listnode *node = list_entry;
const struct ripng_peer *peer = listgetdata(node);
return yang_data_new_ipv6(xpath, &peer->addr);
}
/*
* XPath: /frr-ripngd:ripngd/instance/state/neighbors/neighbor/last-update
*/
struct yang_data *ripngd_instance_state_neighbors_neighbor_last_update_get_elem(
const char *xpath, const void *list_entry)
{
/* TODO: yang:date-and-time is tricky */
return NULL;
}
/*
* XPath: /frr-ripngd:ripngd/instance/state/neighbors/neighbor/bad-packets-rcvd
*/
struct yang_data *
ripngd_instance_state_neighbors_neighbor_bad_packets_rcvd_get_elem(
const char *xpath, const void *list_entry)
{
const struct listnode *node = list_entry;
const struct ripng_peer *peer = listgetdata(node);
return yang_data_new_uint32(xpath, peer->recv_badpackets);
}
/*
* XPath: /frr-ripngd:ripngd/instance/state/neighbors/neighbor/bad-routes-rcvd
*/
struct yang_data *
ripngd_instance_state_neighbors_neighbor_bad_routes_rcvd_get_elem(
const char *xpath, const void *list_entry)
{
const struct listnode *node = list_entry;
const struct ripng_peer *peer = listgetdata(node);
return yang_data_new_uint32(xpath, peer->recv_badroutes);
}
/*
* XPath: /frr-ripngd:ripngd/instance/state/routes/route
*/
const void *
ripngd_instance_state_routes_route_get_next(const void *parent_list_entry,
const void *list_entry)
{
const struct ripng *ripng = parent_list_entry;
struct agg_node *rn;
if (list_entry == NULL)
rn = agg_route_top(ripng->table);
else
rn = agg_route_next((struct agg_node *)list_entry);
while (rn && rn->info == NULL)
rn = agg_route_next(rn);
return rn;
}
int ripngd_instance_state_routes_route_get_keys(const void *list_entry,
struct yang_list_keys *keys)
{
const struct agg_node *rn = list_entry;
keys->num = 1;
(void)prefix2str(&rn->p, keys->key[0], sizeof(keys->key[0]));
return NB_OK;
}
const void *ripngd_instance_state_routes_route_lookup_entry(
const void *parent_list_entry, const struct yang_list_keys *keys)
{
const struct ripng *ripng = parent_list_entry;
struct prefix prefix;
struct agg_node *rn;
yang_str2ipv6p(keys->key[0], &prefix);
rn = agg_node_lookup(ripng->table, &prefix);
if (!rn || !rn->info)
return NULL;
agg_unlock_node(rn);
return rn;
}
/*
* XPath: /frr-ripngd:ripngd/instance/state/routes/route/prefix
*/
struct yang_data *
ripngd_instance_state_routes_route_prefix_get_elem(const char *xpath,
const void *list_entry)
{
const struct agg_node *rn = list_entry;
const struct ripng_info *rinfo = listnode_head(rn->info);
return yang_data_new_ipv6p(xpath, &rinfo->rp->p);
}
/*
* XPath: /frr-ripngd:ripngd/instance/state/routes/route/next-hop
*/
struct yang_data *
ripngd_instance_state_routes_route_next_hop_get_elem(const char *xpath,
const void *list_entry)
{
const struct agg_node *rn = list_entry;
const struct ripng_info *rinfo = listnode_head(rn->info);
return yang_data_new_ipv6(xpath, &rinfo->nexthop);
}
/*
* XPath: /frr-ripngd:ripngd/instance/state/routes/route/interface
*/
struct yang_data *
ripngd_instance_state_routes_route_interface_get_elem(const char *xpath,
const void *list_entry)
{
const struct agg_node *rn = list_entry;
const struct ripng_info *rinfo = listnode_head(rn->info);
const struct ripng *ripng = ripng_info_get_instance(rinfo);
return yang_data_new_string(
xpath, ifindex2ifname(rinfo->ifindex, ripng->vrf->vrf_id));
}
/*
* XPath: /frr-ripngd:ripngd/instance/state/routes/route/metric
*/
struct yang_data *
ripngd_instance_state_routes_route_metric_get_elem(const char *xpath,
const void *list_entry)
{
const struct agg_node *rn = list_entry;
const struct ripng_info *rinfo = listnode_head(rn->info);
return yang_data_new_uint8(xpath, rinfo->metric);
}

File diff suppressed because it is too large Load Diff

View File

@ -494,9 +494,6 @@ extern struct ripng_info *ripng_ecmp_delete(struct ripng *ripng,
extern void ripng_vrf_init(void);
extern void ripng_vrf_terminate(void);
/* Northbound. */
extern void ripng_cli_init(void);
extern const struct frr_yang_module_info frr_ripngd_info;
#endif /* _ZEBRA_RIPNG_RIPNGD_H */

View File

@ -19,7 +19,10 @@ ripngd_libripng_a_SOURCES = \
ripngd/ripng_interface.c \
ripngd/ripng_nexthop.c \
ripngd/ripng_offset.c \
ripngd/ripng_northbound.c \
ripngd/ripng_nb.c \
ripngd/ripng_nb_config.c \
ripngd/ripng_nb_rpcs.c \
ripngd/ripng_nb_state.c \
ripngd/ripng_peer.c \
ripngd/ripng_route.c \
ripngd/ripng_routemap.c \
@ -31,8 +34,8 @@ ripngd/ripng_cli_clippy.c: $(CLIPPY_DEPS)
ripngd/ripng_cli.$(OBJEXT): ripngd/ripng_cli_clippy.c
noinst_HEADERS += \
ripngd/ripng_cli.h \
ripngd/ripng_debug.h \
ripngd/ripng_nb.h \
ripngd/ripng_nexthop.h \
ripngd/ripng_route.h \
ripngd/ripngd.h \

View File

@ -26,10 +26,12 @@
#include "yang.h"
#include "northbound.h"
static bool static_cbs;
static void __attribute__((noreturn)) usage(int status)
{
extern const char *__progname;
fprintf(stderr, "usage: %s [-h] [-p path] MODULE\n", __progname);
fprintf(stderr, "usage: %s [-h] [-s] [-p path] MODULE\n", __progname);
exit(status);
}
@ -153,10 +155,46 @@ static void generate_callback_name(struct lys_node *snode,
replace_hyphens_by_underscores(buffer);
}
static void generate_prototype(const struct nb_callback_info *ncinfo,
const char *cb_name)
{
printf("%s%s(%s);\n", ncinfo->return_type, cb_name, ncinfo->arguments);
}
static int generate_prototypes(const struct lys_node *snode, void *arg)
{
switch (snode->nodetype) {
case LYS_CONTAINER:
case LYS_LEAF:
case LYS_LEAFLIST:
case LYS_LIST:
case LYS_NOTIF:
case LYS_RPC:
break;
default:
return YANG_ITER_CONTINUE;
}
for (struct nb_callback_info *cb = &nb_callbacks[0];
cb->operation != -1; cb++) {
char cb_name[BUFSIZ];
if (cb->optional
|| !nb_operation_is_valid(cb->operation, snode))
continue;
generate_callback_name((struct lys_node *)snode, cb->operation,
cb_name, sizeof(cb_name));
generate_prototype(cb, cb_name);
}
return YANG_ITER_CONTINUE;
}
static void generate_callback(const struct nb_callback_info *ncinfo,
const char *cb_name)
{
printf("static %s%s(%s)\n{\n",
printf("%s%s%s(%s)\n{\n", static_cbs ? "static " : "",
ncinfo->return_type, cb_name, ncinfo->arguments);
switch (ncinfo->operation) {
@ -287,7 +325,7 @@ int main(int argc, char *argv[])
struct stat st;
int opt;
while ((opt = getopt(argc, argv, "hp:")) != -1) {
while ((opt = getopt(argc, argv, "hp:s")) != -1) {
switch (opt) {
case 'h':
usage(EXIT_SUCCESS);
@ -307,6 +345,9 @@ int main(int argc, char *argv[])
search_path = optarg;
break;
case 's':
static_cbs = true;
break;
default:
usage(EXIT_FAILURE);
/* NOTREACHED */
@ -332,6 +373,14 @@ int main(int argc, char *argv[])
/* Create a nb_node for all YANG schema nodes. */
nb_nodes_create();
/* Generate callback prototypes. */
if (!static_cbs) {
printf("/* prototypes */\n");
yang_snodes_iterate_module(module->info, generate_prototypes, 0,
NULL);
printf("\n");
}
/* Generate callback functions. */
yang_snodes_iterate_module(module->info, generate_callbacks, 0, NULL);