lib: implement route map northbound

Based on the route map old CLI, implement the route map handling using
the exported functions.

Use a curry-like programming pattern avoid code repetition when
destroying match/set entries. This is needed by other daemons that
implement custom route map functions and need to pass to lib their
specific destroy functions.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
This commit is contained in:
Rafael Zalamena 2019-09-30 10:34:49 -03:00
parent a7282663ef
commit 686d244f00
4 changed files with 1420 additions and 0 deletions

View file

@ -644,6 +644,30 @@ extern struct route_map_index *route_map_index_get(struct route_map *map,
int pref);
extern void route_map_index_delete(struct route_map_index *index, int notify);
/* routemap_northbound.c */
typedef int (*routemap_match_hook_fun)(struct vty *vty,
struct route_map_index *rmi,
const char *command, const char *arg,
route_map_event_t event);
typedef int (*routemap_set_hook_fun)(struct vty *vty,
struct route_map_index *rmi,
const char *command, const char *arg);
struct routemap_hook_context {
struct route_map_index *rhc_rmi;
const char *rhc_rule;
route_map_event_t rhc_event;
routemap_set_hook_fun rhc_shook;
routemap_match_hook_fun rhc_mhook;
};
int lib_route_map_entry_match_destroy(enum nb_event event,
const struct lyd_node *dnode);
int lib_route_map_entry_set_destroy(enum nb_event event,
const struct lyd_node *dnode);
extern const struct frr_yang_module_info frr_route_map_info;
#ifdef __cplusplus
}
#endif

1393
lib/routemap_northbound.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -71,6 +71,7 @@ lib_libfrr_la_SOURCES = \
lib/qobj.c \
lib/ringbuf.c \
lib/routemap.c \
lib/routemap_northbound.c \
lib/sbuf.c \
lib/seqlock.c \
lib/sha256.c \
@ -105,6 +106,7 @@ lib_libfrr_la_SOURCES = \
nodist_lib_libfrr_la_SOURCES = \
yang/frr-interface.yang.c \
yang/frr-route-map.yang.c \
yang/frr-route-types.yang.c \
yang/ietf/ietf-routing-types.yang.c \
yang/frr-module-translator.yang.c \

View file

@ -22,6 +22,7 @@ EXTRA_DIST += yang/embedmodel.py
dist_yangmodels_DATA += yang/frr-module-translator.yang
dist_yangmodels_DATA += yang/frr-test-module.yang
dist_yangmodels_DATA += yang/frr-interface.yang
dist_yangmodels_DATA += yang/frr-route-map.yang
dist_yangmodels_DATA += yang/frr-route-types.yang
dist_yangmodels_DATA += yang/ietf/ietf-routing-types.yang