From 9ccaa12da64b0f94bc39f974485c2760e994874f Mon Sep 17 00:00:00 2001 From: Igor Ryzhov Date: Mon, 16 Aug 2021 15:38:57 +0300 Subject: [PATCH] staticd: convert typedef to enum Signed-off-by: Igor Ryzhov --- staticd/static_nb_config.c | 8 ++++---- staticd/static_routes.c | 7 ++++--- staticd/static_routes.h | 13 +++++++------ staticd/static_vty.c | 2 +- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/staticd/static_nb_config.c b/staticd/static_nb_config.c index deeca97b0e..470c7bdad5 100644 --- a/staticd/static_nb_config.c +++ b/staticd/static_nb_config.c @@ -122,7 +122,7 @@ struct nexthop_iter { static int nexthop_iter_cb(const struct lyd_node *dnode, void *arg) { struct nexthop_iter *iter = arg; - int nh_type; + enum static_nh_type nh_type; nh_type = yang_dnode_get_enum(dnode, "./nh-type"); @@ -141,7 +141,7 @@ static bool static_nexthop_create(struct nb_cb_create_args *args) struct static_path *pn; struct ipaddr ipaddr; struct static_nexthop *nh; - int nh_type; + enum static_nh_type nh_type; const char *ifname; const char *nh_vrf; @@ -304,7 +304,7 @@ static int static_nexthop_mpls_label_modify(struct nb_cb_modify_args *args) static int static_nexthop_onlink_modify(struct nb_cb_modify_args *args) { struct static_nexthop *nh; - static_types nh_type; + enum static_nh_type nh_type; switch (args->event) { case NB_EV_VALIDATE: @@ -352,7 +352,7 @@ static int static_nexthop_color_destroy(struct nb_cb_destroy_args *args) static int static_nexthop_bh_type_modify(struct nb_cb_modify_args *args) { struct static_nexthop *nh; - static_types nh_type; + enum static_nh_type nh_type; switch (args->event) { case NB_EV_VALIDATE: diff --git a/staticd/static_routes.c b/staticd/static_routes.c index 77a10092f8..60f384e517 100644 --- a/staticd/static_routes.c +++ b/staticd/static_routes.c @@ -186,7 +186,8 @@ void static_del_route(struct route_node *rn) route_unlock_node(rn); } -bool static_add_nexthop_validate(const char *nh_vrf_name, static_types type, +bool static_add_nexthop_validate(const char *nh_vrf_name, + enum static_nh_type type, struct ipaddr *ipaddr) { struct vrf *vrf; @@ -257,7 +258,7 @@ void static_del_path(struct static_path *pn) } struct static_nexthop *static_add_nexthop(struct static_path *pn, - static_types type, + enum static_nh_type type, struct ipaddr *ipaddr, const char *ifname, const char *nh_vrf, uint32_t color) @@ -772,7 +773,7 @@ void static_ifindex_update(struct interface *ifp, bool up) static_ifindex_update_af(ifp, up, AFI_IP6, SAFI_MULTICAST); } -void static_get_nh_type(static_types stype, char *type, size_t size) +void static_get_nh_type(enum static_nh_type stype, char *type, size_t size) { switch (stype) { case STATIC_IFNAME: diff --git a/staticd/static_routes.h b/staticd/static_routes.h index 2211384916..c901a8926a 100644 --- a/staticd/static_routes.h +++ b/staticd/static_routes.h @@ -47,14 +47,14 @@ enum static_blackhole_type { * The order for below macros should be in sync with * yang model typedef nexthop-type */ -typedef enum { +enum static_nh_type { STATIC_IFNAME = 1, STATIC_IPV4_GATEWAY, STATIC_IPV4_GATEWAY_IFNAME, STATIC_IPV6_GATEWAY, STATIC_IPV6_GATEWAY_IFNAME, STATIC_BLACKHOLE, -} static_types; +}; /* * Route Creation gives us: @@ -123,7 +123,7 @@ struct static_nexthop { enum static_install_states state; /* Flag for this static route's type. */ - static_types type; + enum static_nh_type type; /* * Nexthop value. @@ -169,7 +169,7 @@ extern struct zebra_privs_t static_privs; void static_fixup_vrf_ids(struct static_vrf *svrf); extern struct static_nexthop * -static_add_nexthop(struct static_path *pn, static_types type, +static_add_nexthop(struct static_path *pn, enum static_nh_type type, struct ipaddr *ipaddr, const char *ifname, const char *nh_vrf, uint32_t color); extern void static_install_nexthop(struct static_nexthop *nh); @@ -194,9 +194,10 @@ extern struct static_path *static_add_path(struct route_node *rn, uint32_t table_id, uint8_t distance); extern void static_del_path(struct static_path *pn); -extern void static_get_nh_type(static_types stype, char *type, size_t size); +extern void static_get_nh_type(enum static_nh_type stype, char *type, + size_t size); extern bool static_add_nexthop_validate(const char *nh_vrf_name, - static_types type, + enum static_nh_type type, struct ipaddr *ipaddr); extern struct stable_info *static_get_stable_info(struct route_node *rn); diff --git a/staticd/static_vty.c b/staticd/static_vty.c index f16b40a23f..f4cb13434c 100644 --- a/staticd/static_vty.c +++ b/staticd/static_vty.c @@ -56,7 +56,7 @@ static int static_route_leak(struct vty *vty, const char *svrf, int ret; struct prefix p, src; struct in_addr mask; - uint8_t type; + enum static_nh_type type; const char *bh_type; char xpath_prefix[XPATH_MAXLEN]; char xpath_nexthop[XPATH_MAXLEN];