]>
Commit | Line | Data |
---|---|---|
1 | // SPDX-License-Identifier: GPL-2.0-or-later | |
2 | /* | |
3 | * Copyright (C) 2020 Vmware | |
4 | * Sarita Patra | |
5 | */ | |
6 | ||
7 | #include <zebra.h> | |
8 | ||
9 | #include "lib/command.h" | |
10 | #include "lib/log.h" | |
11 | #include "lib/northbound.h" | |
12 | #include "lib/routemap.h" | |
13 | #include "ospf6_routemap_nb.h" | |
14 | ||
15 | /* | |
16 | * XPath: | |
17 | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-ospf-route-map:metric-type | |
18 | */ | |
19 | int lib_route_map_entry_set_action_rmap_set_action_metric_type_modify( | |
20 | struct nb_cb_modify_args *args) | |
21 | { | |
22 | struct routemap_hook_context *rhc; | |
23 | const char *type; | |
24 | int rv; | |
25 | ||
26 | switch (args->event) { | |
27 | case NB_EV_VALIDATE: | |
28 | case NB_EV_PREPARE: | |
29 | case NB_EV_ABORT: | |
30 | break; | |
31 | case NB_EV_APPLY: | |
32 | /* Add configuration. */ | |
33 | rhc = nb_running_get_entry(args->dnode, NULL, true); | |
34 | type = yang_dnode_get_string(args->dnode, NULL); | |
35 | ||
36 | /* Set destroy information. */ | |
37 | rhc->rhc_shook = generic_set_delete; | |
38 | rhc->rhc_rule = "metric-type"; | |
39 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; | |
40 | ||
41 | rv = generic_set_add(rhc->rhc_rmi, "metric-type", type, | |
42 | args->errmsg, args->errmsg_len); | |
43 | if (rv != CMD_SUCCESS) { | |
44 | rhc->rhc_mhook = NULL; | |
45 | return NB_ERR_INCONSISTENCY; | |
46 | } | |
47 | } | |
48 | ||
49 | return NB_OK; | |
50 | } | |
51 | ||
52 | int lib_route_map_entry_set_action_rmap_set_action_metric_type_destroy( | |
53 | struct nb_cb_destroy_args *args) | |
54 | { | |
55 | switch (args->event) { | |
56 | case NB_EV_VALIDATE: | |
57 | case NB_EV_PREPARE: | |
58 | case NB_EV_ABORT: | |
59 | break; | |
60 | case NB_EV_APPLY: | |
61 | return lib_route_map_entry_set_destroy(args); | |
62 | } | |
63 | ||
64 | return NB_OK; | |
65 | } | |
66 | ||
67 | /* | |
68 | * XPath: | |
69 | * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-ospf6-route-map:ipv6-address | |
70 | */ | |
71 | int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_modify( | |
72 | struct nb_cb_modify_args *args) | |
73 | { | |
74 | struct routemap_hook_context *rhc; | |
75 | const char *ipv6_addr; | |
76 | int rv; | |
77 | ||
78 | switch (args->event) { | |
79 | case NB_EV_VALIDATE: | |
80 | case NB_EV_PREPARE: | |
81 | case NB_EV_ABORT: | |
82 | break; | |
83 | case NB_EV_APPLY: | |
84 | /* Add configuration. */ | |
85 | rhc = nb_running_get_entry(args->dnode, NULL, true); | |
86 | ipv6_addr = yang_dnode_get_string(args->dnode, NULL); | |
87 | ||
88 | /* Set destroy information. */ | |
89 | rhc->rhc_shook = generic_set_delete; | |
90 | rhc->rhc_rule = "forwarding-address"; | |
91 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; | |
92 | ||
93 | rv = generic_set_add(rhc->rhc_rmi, "forwarding-address", | |
94 | ipv6_addr, | |
95 | args->errmsg, args->errmsg_len); | |
96 | if (rv != CMD_SUCCESS) { | |
97 | rhc->rhc_mhook = NULL; | |
98 | return NB_ERR_INCONSISTENCY; | |
99 | } | |
100 | } | |
101 | ||
102 | return NB_OK; | |
103 | } | |
104 | ||
105 | int lib_route_map_entry_set_action_rmap_set_action_ipv6_address_destroy( | |
106 | struct nb_cb_destroy_args *args) | |
107 | { | |
108 | switch (args->event) { | |
109 | case NB_EV_VALIDATE: | |
110 | case NB_EV_PREPARE: | |
111 | case NB_EV_ABORT: | |
112 | break; | |
113 | case NB_EV_APPLY: | |
114 | return lib_route_map_entry_set_destroy(args); | |
115 | } | |
116 | ||
117 | return NB_OK; | |
118 | } |