/src/frr/ospfd/ospf_routemap_nb_config.c
Line | Count | Source |
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 "ospf_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 | 0 | { |
22 | 0 | struct routemap_hook_context *rhc; |
23 | 0 | const char *type; |
24 | 0 | int rv; |
25 | |
|
26 | 0 | if (args->event != NB_EV_APPLY) |
27 | 0 | return NB_OK; |
28 | | |
29 | | /* Add configuration. */ |
30 | 0 | rhc = nb_running_get_entry(args->dnode, NULL, true); |
31 | 0 | type = yang_dnode_get_string(args->dnode, NULL); |
32 | | |
33 | | /* Set destroy information. */ |
34 | 0 | rhc->rhc_shook = generic_set_delete; |
35 | 0 | rhc->rhc_rule = "metric-type"; |
36 | 0 | rhc->rhc_event = RMAP_EVENT_SET_DELETED; |
37 | |
|
38 | 0 | rv = generic_set_add(rhc->rhc_rmi, "metric-type", type, |
39 | 0 | args->errmsg, args->errmsg_len); |
40 | 0 | if (rv != CMD_SUCCESS) { |
41 | 0 | rhc->rhc_mhook = NULL; |
42 | 0 | return NB_ERR_INCONSISTENCY; |
43 | 0 | } |
44 | | |
45 | 0 | return NB_OK; |
46 | 0 | } |
47 | | |
48 | | int lib_route_map_entry_set_action_rmap_set_action_metric_type_destroy( |
49 | | struct nb_cb_destroy_args *args) |
50 | 0 | { |
51 | 0 | return lib_route_map_entry_set_destroy(args); |
52 | 0 | } |