#include "ospfd/ospf_bfd.h"
#include "ospfd/ospf_errors.h"
#include "ospfd/ospf_ldp_sync.h"
+#include "ospfd/ospf_routemap_nb.h"
/* ospfd privileges */
zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND, ZCAP_NET_ADMIN,
&frr_interface_info,
&frr_route_map_info,
&frr_vrf_info,
+ &frr_ospf_route_map_info,
};
FRR_DAEMON_INFO(ospfd, OSPF, .vty_port = OSPF_VTY_PORT,
#include "plist.h"
#include "vrf.h"
#include "frrstr.h"
+#include "northbound_cli.h"
#include "ospfd/ospfd.h"
#include "ospfd/ospf_asbr.h"
route_map_rule_tag_free,
};
-DEFUN (set_metric_type,
+DEFUN_YANG (set_metric_type,
set_metric_type_cmd,
"set metric-type <type-1|type-2>",
SET_STR
"OSPF[6] external type 2 metric\n")
{
char *ext = argv[2]->text;
- return generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
- "metric-type", ext);
+
+ const char *xpath =
+ "./set-action[action='frr-ospf-route-map:metric-type']";
+ char xpath_value[XPATH_MAXLEN];
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+ snprintf(xpath_value, sizeof(xpath_value),
+ "%s/rmap-set-action/frr-ospf-route-map:metric-type", xpath);
+ nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, ext);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (no_set_metric_type,
+DEFUN_YANG (no_set_metric_type,
no_set_metric_type_cmd,
"no set metric-type [<type-1|type-2>]",
NO_STR
"OSPF[6] external type 1 metric\n"
"OSPF[6] external type 2 metric\n")
{
- char *ext = (argc == 4) ? argv[3]->text : NULL;
- return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
- "metric-type", ext);
+ const char *xpath =
+ "./set-action[action='frr-ospf-route-map:metric-type']";
+
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
/* Route-map init */
--- /dev/null
+/*
+ * Copyright (C) 2020 Vmware
+ * Sarita Patra
+ *
+ * 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 "lib/northbound.h"
+#include "lib/routemap.h"
+#include "ospf_routemap_nb.h"
+
+/* clang-format off */
+const struct frr_yang_module_info frr_ospf_route_map_info = {
+ .name = "frr-ospf-route-map",
+ .nodes = {
+ {
+ .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-ospf-route-map:metric-type",
+ .cbs = {
+ .modify = lib_route_map_entry_set_action_rmap_set_action_metric_type_modify,
+ .destroy = lib_route_map_entry_set_action_rmap_set_action_metric_type_destroy,
+ }
+ },
+ {
+ .xpath = NULL,
+ },
+ }
+};
--- /dev/null
+/*
+ * Copyright (C) 2020 Vmware
+ * Sarita Patra
+ *
+ * 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_OSPF_ROUTEMAP_NB_H_
+#define _FRR_OSPF_ROUTEMAP_NB_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const struct frr_yang_module_info frr_ospf_route_map_info;
+
+/* prototypes */
+int lib_route_map_entry_set_action_rmap_set_action_metric_type_modify(struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_metric_type_destroy(struct nb_cb_destroy_args *args);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2020 Vmware
+ * Sarita Patra
+ *
+ * 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 "lib/command.h"
+#include "lib/log.h"
+#include "lib/northbound.h"
+#include "lib/routemap.h"
+#include "ospf_routemap_nb.h"
+
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-ospf-route-map:metric-type
+ */
+int lib_route_map_entry_set_action_rmap_set_action_metric_type_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct routemap_hook_context *rhc;
+ const char *type;
+ int rv;
+
+ if (args->event != NB_EV_APPLY)
+ return NB_OK;
+
+ /* Add configuration. */
+ rhc = nb_running_get_entry(args->dnode, NULL, true);
+ type = yang_dnode_get_string(args->dnode, NULL);
+
+ /* Set destroy information. */
+ rhc->rhc_shook = generic_set_delete;
+ rhc->rhc_rule = "metric-type";
+ rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+ rv = generic_set_add(rhc->rhc_rmi, "metric-type", type,
+ args->errmsg, args->errmsg_len);
+ if (rv != CMD_SUCCESS) {
+ rhc->rhc_mhook = NULL;
+ return NB_ERR_INCONSISTENCY;
+ }
+
+ return NB_OK;
+}
+
+int lib_route_map_entry_set_action_rmap_set_action_metric_type_destroy(
+ struct nb_cb_destroy_args *args)
+{
+ return lib_route_map_entry_set_destroy(args);
+}
const struct p_space *b);
extern int q_spaces_compare_func(const struct q_space *a,
const struct q_space *b);
+
#endif /* _ZEBRA_OSPFD_H */
ospfd/ospf_ri.c \
ospfd/ospf_route.c \
ospfd/ospf_routemap.c \
+ ospfd/ospf_routemap_nb.c \
+ ospfd/ospf_routemap_nb_config.c \
ospfd/ospf_spf.c \
ospfd/ospf_ti_lfa.c \
ospfd/ospf_sr.c \
ospfd/ospf_packet.h \
ospfd/ospf_ri.h \
ospfd/ospf_route.h \
+ ospfd/ospf_routemap_nb.h \
ospfd/ospf_spf.h \
ospfd/ospf_ti_lfa.h \
ospfd/ospf_sr.h \
EXTRA_DIST += \
ospfd/ChangeLog.opaque.txt \
# end
+
+nodist_ospfd_ospfd_SOURCES = \
+ yang/frr-ospf-route-map.yang.c \
+ # end