]> git.proxmox.com Git - mirror_frr.git/blame - ospf6d/ospf6_routemap_nb_config.c
Merge pull request #12075 from donaldsharp/highline
[mirror_frr.git] / ospf6d / ospf6_routemap_nb_config.c
CommitLineData
078110ca
SP
1/*
2 * Copyright (C) 2020 Vmware
3 * Sarita Patra
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
1f8031f7
DL
20#include <zebra.h>
21
078110ca
SP
22#include "lib/command.h"
23#include "lib/log.h"
24#include "lib/northbound.h"
25#include "lib/routemap.h"
26#include "ospf6_routemap_nb.h"
27
28/*
29 * XPath:
30 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-ospf-route-map:metric-type
31 */
32int lib_route_map_entry_set_action_rmap_set_action_metric_type_modify(
33 struct nb_cb_modify_args *args)
34{
35 struct routemap_hook_context *rhc;
36 const char *type;
37 int rv;
38
39 switch (args->event) {
40 case NB_EV_VALIDATE:
41 case NB_EV_PREPARE:
42 case NB_EV_ABORT:
43 break;
44 case NB_EV_APPLY:
45 /* Add configuration. */
46 rhc = nb_running_get_entry(args->dnode, NULL, true);
47 type = yang_dnode_get_string(args->dnode, NULL);
48
49 /* Set destroy information. */
50 rhc->rhc_shook = generic_set_delete;
51 rhc->rhc_rule = "metric-type";
52 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
53
54 rv = generic_set_add(rhc->rhc_rmi, "metric-type", type,
55 args->errmsg, args->errmsg_len);
56 if (rv != CMD_SUCCESS) {
57 rhc->rhc_mhook = NULL;
58 return NB_ERR_INCONSISTENCY;
59 }
60 }
61
62 return NB_OK;
63}
64
65int lib_route_map_entry_set_action_rmap_set_action_metric_type_destroy(
66 struct nb_cb_destroy_args *args)
67{
68 switch (args->event) {
69 case NB_EV_VALIDATE:
70 case NB_EV_PREPARE:
71 case NB_EV_ABORT:
72 break;
73 case NB_EV_APPLY:
74 return lib_route_map_entry_set_destroy(args);
75 }
76
77 return NB_OK;
78}
79
80/*
81 * XPath:
82 * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-ospf6-route-map:ipv6-address
83 */
84int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_modify(
85 struct nb_cb_modify_args *args)
86{
87 struct routemap_hook_context *rhc;
88 const char *ipv6_addr;
89 int rv;
90
91 switch (args->event) {
92 case NB_EV_VALIDATE:
93 case NB_EV_PREPARE:
94 case NB_EV_ABORT:
95 break;
96 case NB_EV_APPLY:
97 /* Add configuration. */
98 rhc = nb_running_get_entry(args->dnode, NULL, true);
99 ipv6_addr = yang_dnode_get_string(args->dnode, NULL);
100
101 /* Set destroy information. */
102 rhc->rhc_shook = generic_set_delete;
103 rhc->rhc_rule = "forwarding-address";
104 rhc->rhc_event = RMAP_EVENT_SET_DELETED;
105
106 rv = generic_set_add(rhc->rhc_rmi, "forwarding-address",
107 ipv6_addr,
108 args->errmsg, args->errmsg_len);
109 if (rv != CMD_SUCCESS) {
110 rhc->rhc_mhook = NULL;
111 return NB_ERR_INCONSISTENCY;
112 }
113 }
114
115 return NB_OK;
116}
117
118int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_destroy(
119 struct nb_cb_destroy_args *args)
120{
121 switch (args->event) {
122 case NB_EV_VALIDATE:
123 case NB_EV_PREPARE:
124 case NB_EV_ABORT:
125 break;
126 case NB_EV_APPLY:
127 return lib_route_map_entry_set_destroy(args);
128 }
129
130 return NB_OK;
131}