diff options
Diffstat (limited to 'ripd')
-rw-r--r-- | ripd/rip_nb.h | 241 | ||||
-rw-r--r-- | ripd/rip_nb_config.c | 492 | ||||
-rw-r--r-- | ripd/rip_nb_rpcs.c | 6 | ||||
-rw-r--r-- | ripd/rip_nb_state.c | 136 |
4 files changed, 360 insertions, 515 deletions
diff --git a/ripd/rip_nb.h b/ripd/rip_nb.h index 441b253fe..26bb3cb3b 100644 --- a/ripd/rip_nb.h +++ b/ripd/rip_nb.h @@ -23,186 +23,109 @@ extern const struct frr_yang_module_info frr_ripd_info; /* Mandatory callbacks. */ -int ripd_instance_create(enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_destroy(enum nb_event event, const struct lyd_node *dnode); -const void *ripd_instance_get_next(const void *parent_list_entry, - const void *list_entry); -int ripd_instance_get_keys(const void *list_entry, struct yang_list_keys *keys); -const void *ripd_instance_lookup_entry(const void *parent_list_entry, - const struct yang_list_keys *keys); -int ripd_instance_allow_ecmp_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); +int ripd_instance_create(struct nb_cb_create_args *args); +int ripd_instance_destroy(struct nb_cb_destroy_args *args); +const void *ripd_instance_get_next(struct nb_cb_get_next_args *args); +int ripd_instance_get_keys(struct nb_cb_get_keys_args *args); +const void *ripd_instance_lookup_entry(struct nb_cb_lookup_entry_args *args); +int ripd_instance_allow_ecmp_modify(struct nb_cb_modify_args *args); int ripd_instance_default_information_originate_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_default_metric_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_distance_default_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_distance_source_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_distance_source_destroy(enum nb_event event, - const struct lyd_node *dnode); -int ripd_instance_distance_source_distance_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); + struct nb_cb_modify_args *args); +int ripd_instance_default_metric_modify(struct nb_cb_modify_args *args); +int ripd_instance_distance_default_modify(struct nb_cb_modify_args *args); +int ripd_instance_distance_source_create(struct nb_cb_create_args *args); +int ripd_instance_distance_source_destroy(struct nb_cb_destroy_args *args); +int ripd_instance_distance_source_distance_modify( + struct nb_cb_modify_args *args); int ripd_instance_distance_source_access_list_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource); + struct nb_cb_modify_args *args); int ripd_instance_distance_source_access_list_destroy( - enum nb_event event, const struct lyd_node *dnode); -int ripd_instance_explicit_neighbor_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_explicit_neighbor_destroy(enum nb_event event, - const struct lyd_node *dnode); -int ripd_instance_network_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_network_destroy(enum nb_event event, - const struct lyd_node *dnode); -int ripd_instance_interface_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_interface_destroy(enum nb_event event, - const struct lyd_node *dnode); -int ripd_instance_offset_list_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_offset_list_destroy(enum nb_event event, - const struct lyd_node *dnode); -int ripd_instance_offset_list_access_list_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_offset_list_metric_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_passive_default_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_passive_interface_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_passive_interface_destroy(enum nb_event event, - const struct lyd_node *dnode); -int ripd_instance_non_passive_interface_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_non_passive_interface_destroy(enum nb_event event, - const struct lyd_node *dnode); -int ripd_instance_redistribute_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_redistribute_destroy(enum nb_event event, - const struct lyd_node *dnode); -int ripd_instance_redistribute_route_map_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_redistribute_route_map_destroy(enum nb_event event, - const struct lyd_node *dnode); -int ripd_instance_redistribute_metric_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_redistribute_metric_destroy(enum nb_event event, - const struct lyd_node *dnode); -int ripd_instance_static_route_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_static_route_destroy(enum nb_event event, - const struct lyd_node *dnode); -int ripd_instance_timers_flush_interval_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_timers_holddown_interval_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_timers_update_interval_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_version_receive_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int ripd_instance_version_send_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -const void * -ripd_instance_state_neighbors_neighbor_get_next(const void *parent_list_entry, - const void *list_entry); + struct nb_cb_destroy_args *args); +int ripd_instance_explicit_neighbor_create(struct nb_cb_create_args *args); +int ripd_instance_explicit_neighbor_destroy(struct nb_cb_destroy_args *args); +int ripd_instance_network_create(struct nb_cb_create_args *args); +int ripd_instance_network_destroy(struct nb_cb_destroy_args *args); +int ripd_instance_interface_create(struct nb_cb_create_args *args); +int ripd_instance_interface_destroy(struct nb_cb_destroy_args *args); +int ripd_instance_offset_list_create(struct nb_cb_create_args *args); +int ripd_instance_offset_list_destroy(struct nb_cb_destroy_args *args); +int ripd_instance_offset_list_access_list_modify( + struct nb_cb_modify_args *args); +int ripd_instance_offset_list_metric_modify(struct nb_cb_modify_args *args); +int ripd_instance_passive_default_modify(struct nb_cb_modify_args *args); +int ripd_instance_passive_interface_create(struct nb_cb_create_args *args); +int ripd_instance_passive_interface_destroy(struct nb_cb_destroy_args *args); +int ripd_instance_non_passive_interface_create(struct nb_cb_create_args *args); +int ripd_instance_non_passive_interface_destroy( + struct nb_cb_destroy_args *args); +int ripd_instance_redistribute_create(struct nb_cb_create_args *args); +int ripd_instance_redistribute_destroy(struct nb_cb_destroy_args *args); +int ripd_instance_redistribute_route_map_modify(struct nb_cb_modify_args *args); +int ripd_instance_redistribute_route_map_destroy( + struct nb_cb_destroy_args *args); +int ripd_instance_redistribute_metric_modify(struct nb_cb_modify_args *args); +int ripd_instance_redistribute_metric_destroy(struct nb_cb_destroy_args *args); +int ripd_instance_static_route_create(struct nb_cb_create_args *args); +int ripd_instance_static_route_destroy(struct nb_cb_destroy_args *args); +int ripd_instance_timers_flush_interval_modify(struct nb_cb_modify_args *args); +int ripd_instance_timers_holddown_interval_modify( + struct nb_cb_modify_args *args); +int ripd_instance_timers_update_interval_modify(struct nb_cb_modify_args *args); +int ripd_instance_version_receive_modify(struct nb_cb_modify_args *args); +int ripd_instance_version_send_modify(struct nb_cb_modify_args *args); +const void *ripd_instance_state_neighbors_neighbor_get_next( + struct nb_cb_get_next_args *args); int ripd_instance_state_neighbors_neighbor_get_keys( - const void *list_entry, struct yang_list_keys *keys); + struct nb_cb_get_keys_args *args); const void *ripd_instance_state_neighbors_neighbor_lookup_entry( - const void *parent_list_entry, const struct yang_list_keys *keys); -struct yang_data * -ripd_instance_state_neighbors_neighbor_address_get_elem(const char *xpath, - const void *list_entry); + struct nb_cb_lookup_entry_args *args); +struct yang_data *ripd_instance_state_neighbors_neighbor_address_get_elem( + struct nb_cb_get_elem_args *args); struct yang_data *ripd_instance_state_neighbors_neighbor_last_update_get_elem( - const char *xpath, const void *list_entry); + struct nb_cb_get_elem_args *args); struct yang_data * ripd_instance_state_neighbors_neighbor_bad_packets_rcvd_get_elem( - const char *xpath, const void *list_entry); + struct nb_cb_get_elem_args *args); struct yang_data * ripd_instance_state_neighbors_neighbor_bad_routes_rcvd_get_elem( - const char *xpath, const void *list_entry); + struct nb_cb_get_elem_args *args); const void * -ripd_instance_state_routes_route_get_next(const void *parent_list_entry, - const void *list_entry); -int ripd_instance_state_routes_route_get_keys(const void *list_entry, - struct yang_list_keys *keys); +ripd_instance_state_routes_route_get_next(struct nb_cb_get_next_args *args); +int ripd_instance_state_routes_route_get_keys(struct nb_cb_get_keys_args *args); const void *ripd_instance_state_routes_route_lookup_entry( - const void *parent_list_entry, const struct yang_list_keys *keys); -struct yang_data * -ripd_instance_state_routes_route_prefix_get_elem(const char *xpath, - const void *list_entry); -struct yang_data * -ripd_instance_state_routes_route_next_hop_get_elem(const char *xpath, - const void *list_entry); -struct yang_data * -ripd_instance_state_routes_route_interface_get_elem(const char *xpath, - const void *list_entry); -struct yang_data * -ripd_instance_state_routes_route_metric_get_elem(const char *xpath, - const void *list_entry); -int clear_rip_route_rpc(const char *xpath, const struct list *input, - struct list *output); -int lib_interface_rip_split_horizon_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int lib_interface_rip_v2_broadcast_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int lib_interface_rip_version_receive_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); -int lib_interface_rip_version_send_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource); + struct nb_cb_lookup_entry_args *args); +struct yang_data *ripd_instance_state_routes_route_prefix_get_elem( + struct nb_cb_get_elem_args *args); +struct yang_data *ripd_instance_state_routes_route_next_hop_get_elem( + struct nb_cb_get_elem_args *args); +struct yang_data *ripd_instance_state_routes_route_interface_get_elem( + struct nb_cb_get_elem_args *args); +struct yang_data *ripd_instance_state_routes_route_metric_get_elem( + struct nb_cb_get_elem_args *args); +int clear_rip_route_rpc(struct nb_cb_rpc_args *args); +int lib_interface_rip_split_horizon_modify(struct nb_cb_modify_args *args); +int lib_interface_rip_v2_broadcast_modify(struct nb_cb_modify_args *args); +int lib_interface_rip_version_receive_modify(struct nb_cb_modify_args *args); +int lib_interface_rip_version_send_modify(struct nb_cb_modify_args *args); int lib_interface_rip_authentication_scheme_mode_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource); + struct nb_cb_modify_args *args); int lib_interface_rip_authentication_scheme_md5_auth_length_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource); + struct nb_cb_modify_args *args); int lib_interface_rip_authentication_scheme_md5_auth_length_destroy( - enum nb_event event, const struct lyd_node *dnode); + struct nb_cb_destroy_args *args); int lib_interface_rip_authentication_password_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource); + struct nb_cb_modify_args *args); int lib_interface_rip_authentication_password_destroy( - enum nb_event event, const struct lyd_node *dnode); + struct nb_cb_destroy_args *args); int lib_interface_rip_authentication_key_chain_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource); + struct nb_cb_modify_args *args); int lib_interface_rip_authentication_key_chain_destroy( - enum nb_event event, const struct lyd_node *dnode); + struct nb_cb_destroy_args *args); /* Optional 'apply_finish' callbacks. */ -void ripd_instance_redistribute_apply_finish(const struct lyd_node *dnode); -void ripd_instance_timers_apply_finish(const struct lyd_node *dnode); +void ripd_instance_redistribute_apply_finish( + struct nb_cb_apply_finish_args *args); +void ripd_instance_timers_apply_finish(struct nb_cb_apply_finish_args *args); /* Optional 'cli_show' callbacks. */ void cli_show_router_rip(struct vty *vty, struct lyd_node *dnode, diff --git a/ripd/rip_nb_config.c b/ripd/rip_nb_config.c index e75db342a..c640ca27a 100644 --- a/ripd/rip_nb_config.c +++ b/ripd/rip_nb_config.c @@ -38,22 +38,21 @@ /* * XPath: /frr-ripd:ripd/instance */ -int ripd_instance_create(enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_create(struct nb_cb_create_args *args) { struct rip *rip; struct vrf *vrf; const char *vrf_name; int socket; - vrf_name = yang_dnode_get_string(dnode, "./vrf"); + vrf_name = yang_dnode_get_string(args->dnode, "./vrf"); vrf = vrf_lookup_by_name(vrf_name); /* * Try to create a RIP socket only if the VRF is enabled, otherwise * create a disabled RIP instance and wait for the VRF to be enabled. */ - switch (event) { + switch (args->event) { case NB_EV_VALIDATE: break; case NB_EV_PREPARE: @@ -63,37 +62,37 @@ int ripd_instance_create(enum nb_event event, const struct lyd_node *dnode, socket = rip_create_socket(vrf); if (socket < 0) return NB_ERR_RESOURCE; - resource->fd = socket; + args->resource->fd = socket; break; case NB_EV_ABORT: if (!vrf || !vrf_is_enabled(vrf)) break; - socket = resource->fd; + socket = args->resource->fd; close(socket); break; case NB_EV_APPLY: if (vrf && vrf_is_enabled(vrf)) - socket = resource->fd; + socket = args->resource->fd; else socket = -1; rip = rip_create(vrf_name, vrf, socket); - nb_running_set_entry(dnode, rip); + nb_running_set_entry(args->dnode, rip); break; } return NB_OK; } -int ripd_instance_destroy(enum nb_event event, const struct lyd_node *dnode) +int ripd_instance_destroy(struct nb_cb_destroy_args *args) { struct rip *rip; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_unset_entry(dnode); + rip = nb_running_unset_entry(args->dnode); rip_clean(rip); return NB_OK; @@ -102,17 +101,15 @@ int ripd_instance_destroy(enum nb_event event, const struct lyd_node *dnode) /* * XPath: /frr-ripd:ripd/instance/allow-ecmp */ -int ripd_instance_allow_ecmp_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_allow_ecmp_modify(struct nb_cb_modify_args *args) { struct rip *rip; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - rip->ecmp = yang_dnode_get_bool(dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + rip->ecmp = yang_dnode_get_bool(args->dnode, NULL); if (!rip->ecmp) rip_ecmp_disable(rip); @@ -123,18 +120,17 @@ int ripd_instance_allow_ecmp_modify(enum nb_event event, * XPath: /frr-ripd:ripd/instance/default-information-originate */ int ripd_instance_default_information_originate_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) + struct nb_cb_modify_args *args) { struct rip *rip; bool default_information; struct prefix_ipv4 p; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - default_information = yang_dnode_get_bool(dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + default_information = yang_dnode_get_bool(args->dnode, NULL); memset(&p, 0, sizeof(struct prefix_ipv4)); p.family = AF_INET; @@ -156,17 +152,15 @@ int ripd_instance_default_information_originate_modify( /* * XPath: /frr-ripd:ripd/instance/default-metric */ -int ripd_instance_default_metric_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_default_metric_modify(struct nb_cb_modify_args *args) { struct rip *rip; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - rip->default_metric = yang_dnode_get_uint8(dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + rip->default_metric = yang_dnode_get_uint8(args->dnode, NULL); /* rip_update_default_metric (); */ return NB_OK; @@ -175,17 +169,15 @@ int ripd_instance_default_metric_modify(enum nb_event event, /* * XPath: /frr-ripd:ripd/instance/distance/default */ -int ripd_instance_distance_default_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_distance_default_modify(struct nb_cb_modify_args *args) { struct rip *rip; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - rip->distance = yang_dnode_get_uint8(dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + rip->distance = yang_dnode_get_uint8(args->dnode, NULL); return NB_OK; } @@ -193,39 +185,36 @@ int ripd_instance_distance_default_modify(enum nb_event event, /* * XPath: /frr-ripd:ripd/instance/distance/source */ -int ripd_instance_distance_source_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_distance_source_create(struct nb_cb_create_args *args) { struct rip *rip; struct prefix_ipv4 prefix; struct route_node *rn; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - yang_dnode_get_ipv4p(&prefix, dnode, "./prefix"); + yang_dnode_get_ipv4p(&prefix, args->dnode, "./prefix"); apply_mask_ipv4(&prefix); /* Get RIP distance node. */ - rip = nb_running_get_entry(dnode, NULL, true); + rip = nb_running_get_entry(args->dnode, NULL, true); rn = route_node_get(rip->distance_table, (struct prefix *)&prefix); rn->info = rip_distance_new(); - nb_running_set_entry(dnode, rn); + nb_running_set_entry(args->dnode, rn); return NB_OK; } -int ripd_instance_distance_source_destroy(enum nb_event event, - const struct lyd_node *dnode) +int ripd_instance_distance_source_destroy(struct nb_cb_destroy_args *args) { struct route_node *rn; struct rip_distance *rdistance; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rn = nb_running_unset_entry(dnode); + rn = nb_running_unset_entry(args->dnode); rdistance = rn->info; rip_distance_free(rdistance); rn->info = NULL; @@ -237,20 +226,19 @@ int ripd_instance_distance_source_destroy(enum nb_event event, /* * XPath: /frr-ripd:ripd/instance/distance/source/distance */ -int ripd_instance_distance_source_distance_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_distance_source_distance_modify( + struct nb_cb_modify_args *args) { struct route_node *rn; uint8_t distance; struct rip_distance *rdistance; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; /* Set distance value. */ - rn = nb_running_get_entry(dnode, NULL, true); - distance = yang_dnode_get_uint8(dnode, NULL); + rn = nb_running_get_entry(args->dnode, NULL, true); + distance = yang_dnode_get_uint8(args->dnode, NULL); rdistance = rn->info; rdistance->distance = distance; @@ -261,20 +249,19 @@ int ripd_instance_distance_source_distance_modify(enum nb_event event, * XPath: /frr-ripd:ripd/instance/distance/source/access-list */ int ripd_instance_distance_source_access_list_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) + struct nb_cb_modify_args *args) { const char *acl_name; struct route_node *rn; struct rip_distance *rdistance; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - acl_name = yang_dnode_get_string(dnode, NULL); + acl_name = yang_dnode_get_string(args->dnode, NULL); /* Set access-list */ - rn = nb_running_get_entry(dnode, NULL, true); + rn = nb_running_get_entry(args->dnode, NULL, true); rdistance = rn->info; if (rdistance->access_list) free(rdistance->access_list); @@ -284,16 +271,16 @@ int ripd_instance_distance_source_access_list_modify( } int ripd_instance_distance_source_access_list_destroy( - enum nb_event event, const struct lyd_node *dnode) + struct nb_cb_destroy_args *args) { struct route_node *rn; struct rip_distance *rdistance; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; /* Reset access-list configuration. */ - rn = nb_running_get_entry(dnode, NULL, true); + rn = nb_running_get_entry(args->dnode, NULL, true); rdistance = rn->info; free(rdistance->access_list); rdistance->access_list = NULL; @@ -304,37 +291,34 @@ int ripd_instance_distance_source_access_list_destroy( /* * XPath: /frr-ripd:ripd/instance/explicit-neighbor */ -int ripd_instance_explicit_neighbor_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_explicit_neighbor_create(struct nb_cb_create_args *args) { struct rip *rip; struct prefix_ipv4 p; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); + rip = nb_running_get_entry(args->dnode, NULL, true); p.family = AF_INET; p.prefixlen = IPV4_MAX_BITLEN; - yang_dnode_get_ipv4(&p.prefix, dnode, NULL); + yang_dnode_get_ipv4(&p.prefix, args->dnode, NULL); return rip_neighbor_add(rip, &p); } -int ripd_instance_explicit_neighbor_destroy(enum nb_event event, - const struct lyd_node *dnode) +int ripd_instance_explicit_neighbor_destroy(struct nb_cb_destroy_args *args) { struct rip *rip; struct prefix_ipv4 p; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); + rip = nb_running_get_entry(args->dnode, NULL, true); p.family = AF_INET; p.prefixlen = IPV4_MAX_BITLEN; - yang_dnode_get_ipv4(&p.prefix, dnode, NULL); + yang_dnode_get_ipv4(&p.prefix, args->dnode, NULL); return rip_neighbor_delete(rip, &p); } @@ -342,34 +326,31 @@ int ripd_instance_explicit_neighbor_destroy(enum nb_event event, /* * XPath: /frr-ripd:ripd/instance/network */ -int ripd_instance_network_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_network_create(struct nb_cb_create_args *args) { struct rip *rip; struct prefix p; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - yang_dnode_get_ipv4p(&p, dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + yang_dnode_get_ipv4p(&p, args->dnode, NULL); apply_mask_ipv4((struct prefix_ipv4 *)&p); return rip_enable_network_add(rip, &p); } -int ripd_instance_network_destroy(enum nb_event event, - const struct lyd_node *dnode) +int ripd_instance_network_destroy(struct nb_cb_destroy_args *args) { struct rip *rip; struct prefix p; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - yang_dnode_get_ipv4p(&p, dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + yang_dnode_get_ipv4p(&p, args->dnode, NULL); apply_mask_ipv4((struct prefix_ipv4 *)&p); return rip_enable_network_delete(rip, &p); @@ -378,33 +359,30 @@ int ripd_instance_network_destroy(enum nb_event event, /* * XPath: /frr-ripd:ripd/instance/interface */ -int ripd_instance_interface_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_interface_create(struct nb_cb_create_args *args) { struct rip *rip; const char *ifname; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - ifname = yang_dnode_get_string(dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + ifname = yang_dnode_get_string(args->dnode, NULL); return rip_enable_if_add(rip, ifname); } -int ripd_instance_interface_destroy(enum nb_event event, - const struct lyd_node *dnode) +int ripd_instance_interface_destroy(struct nb_cb_destroy_args *args) { struct rip *rip; const char *ifname; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - ifname = yang_dnode_get_string(dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + ifname = yang_dnode_get_string(args->dnode, NULL); return rip_enable_if_delete(rip, ifname); } @@ -412,38 +390,35 @@ int ripd_instance_interface_destroy(enum nb_event event, /* * XPath: /frr-ripd:ripd/instance/offset-list */ -int ripd_instance_offset_list_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_offset_list_create(struct nb_cb_create_args *args) { struct rip *rip; const char *ifname; struct rip_offset_list *offset; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - ifname = yang_dnode_get_string(dnode, "./interface"); + rip = nb_running_get_entry(args->dnode, NULL, true); + ifname = yang_dnode_get_string(args->dnode, "./interface"); offset = rip_offset_list_new(rip, ifname); - nb_running_set_entry(dnode, offset); + nb_running_set_entry(args->dnode, offset); return NB_OK; } -int ripd_instance_offset_list_destroy(enum nb_event event, - const struct lyd_node *dnode) +int ripd_instance_offset_list_destroy(struct nb_cb_destroy_args *args) { int direct; struct rip_offset_list *offset; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - direct = yang_dnode_get_enum(dnode, "./direction"); + direct = yang_dnode_get_enum(args->dnode, "./direction"); - offset = nb_running_unset_entry(dnode); + offset = nb_running_unset_entry(args->dnode); if (offset->direct[direct].alist_name) { free(offset->direct[direct].alist_name); offset->direct[direct].alist_name = NULL; @@ -458,21 +433,19 @@ int ripd_instance_offset_list_destroy(enum nb_event event, /* * XPath: /frr-ripd:ripd/instance/offset-list/access-list */ -int ripd_instance_offset_list_access_list_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_offset_list_access_list_modify(struct nb_cb_modify_args *args) { int direct; struct rip_offset_list *offset; const char *alist_name; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - direct = yang_dnode_get_enum(dnode, "../direction"); - alist_name = yang_dnode_get_string(dnode, NULL); + direct = yang_dnode_get_enum(args->dnode, "../direction"); + alist_name = yang_dnode_get_string(args->dnode, NULL); - offset = nb_running_get_entry(dnode, NULL, true); + offset = nb_running_get_entry(args->dnode, NULL, true); if (offset->direct[direct].alist_name) free(offset->direct[direct].alist_name); offset->direct[direct].alist_name = strdup(alist_name); @@ -483,21 +456,19 @@ int ripd_instance_offset_list_access_list_modify(enum nb_event event, /* * XPath: /frr-ripd:ripd/instance/offset-list/metric */ -int ripd_instance_offset_list_metric_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_offset_list_metric_modify(struct nb_cb_modify_args *args) { int direct; uint8_t metric; struct rip_offset_list *offset; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - direct = yang_dnode_get_enum(dnode, "../direction"); - metric = yang_dnode_get_uint8(dnode, NULL); + direct = yang_dnode_get_enum(args->dnode, "../direction"); + metric = yang_dnode_get_uint8(args->dnode, NULL); - offset = nb_running_get_entry(dnode, NULL, true); + offset = nb_running_get_entry(args->dnode, NULL, true); offset->direct[direct].metric = metric; return NB_OK; @@ -506,17 +477,15 @@ int ripd_instance_offset_list_metric_modify(enum nb_event event, /* * XPath: /frr-ripd:ripd/instance/passive-default */ -int ripd_instance_passive_default_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_passive_default_modify(struct nb_cb_modify_args *args) { struct rip *rip; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - rip->passive_default = yang_dnode_get_bool(dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + rip->passive_default = yang_dnode_get_bool(args->dnode, NULL); rip_passive_nondefault_clean(rip); return NB_OK; @@ -525,33 +494,30 @@ int ripd_instance_passive_default_modify(enum nb_event event, /* * XPath: /frr-ripd:ripd/instance/passive-interface */ -int ripd_instance_passive_interface_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_passive_interface_create(struct nb_cb_create_args *args) { struct rip *rip; const char *ifname; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - ifname = yang_dnode_get_string(dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + ifname = yang_dnode_get_string(args->dnode, NULL); return rip_passive_nondefault_set(rip, ifname); } -int ripd_instance_passive_interface_destroy(enum nb_event event, - const struct lyd_node *dnode) +int ripd_instance_passive_interface_destroy(struct nb_cb_destroy_args *args) { struct rip *rip; const char *ifname; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - ifname = yang_dnode_get_string(dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + ifname = yang_dnode_get_string(args->dnode, NULL); return rip_passive_nondefault_unset(rip, ifname); } @@ -559,33 +525,30 @@ int ripd_instance_passive_interface_destroy(enum nb_event event, /* * XPath: /frr-ripd:ripd/instance/non-passive-interface */ -int ripd_instance_non_passive_interface_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_non_passive_interface_create(struct nb_cb_create_args *args) { struct rip *rip; const char *ifname; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - ifname = yang_dnode_get_string(dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + ifname = yang_dnode_get_string(args->dnode, NULL); return rip_passive_nondefault_unset(rip, ifname); } -int ripd_instance_non_passive_interface_destroy(enum nb_event event, - const struct lyd_node *dnode) +int ripd_instance_non_passive_interface_destroy(struct nb_cb_destroy_args *args) { struct rip *rip; const char *ifname; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - ifname = yang_dnode_get_string(dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + ifname = yang_dnode_get_string(args->dnode, NULL); return rip_passive_nondefault_set(rip, ifname); } @@ -593,35 +556,32 @@ int ripd_instance_non_passive_interface_destroy(enum nb_event event, /* * XPath: /frr-ripd:ripd/instance/redistribute */ -int ripd_instance_redistribute_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_redistribute_create(struct nb_cb_create_args *args) { struct rip *rip; int type; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - type = yang_dnode_get_enum(dnode, "./protocol"); + rip = nb_running_get_entry(args->dnode, NULL, true); + type = yang_dnode_get_enum(args->dnode, "./protocol"); rip->redist[type].enabled = true; return NB_OK; } -int ripd_instance_redistribute_destroy(enum nb_event event, - const struct lyd_node *dnode) +int ripd_instance_redistribute_destroy(struct nb_cb_destroy_args *args) { struct rip *rip; int type; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - type = yang_dnode_get_enum(dnode, "./protocol"); + rip = nb_running_get_entry(args->dnode, NULL, true); + type = yang_dnode_get_enum(args->dnode, "./protocol"); rip->redist[type].enabled = false; if (rip->redist[type].route_map.name) { @@ -638,13 +598,14 @@ int ripd_instance_redistribute_destroy(enum nb_event event, return NB_OK; } -void ripd_instance_redistribute_apply_finish(const struct lyd_node *dnode) +void ripd_instance_redistribute_apply_finish( + struct nb_cb_apply_finish_args *args) { struct rip *rip; int type; - rip = nb_running_get_entry(dnode, NULL, true); - type = yang_dnode_get_enum(dnode, "./protocol"); + rip = nb_running_get_entry(args->dnode, NULL, true); + type = yang_dnode_get_enum(args->dnode, "./protocol"); if (rip->enabled) rip_redistribute_conf_update(rip, type); @@ -653,20 +614,18 @@ void ripd_instance_redistribute_apply_finish(const struct lyd_node *dnode) /* * XPath: /frr-ripd:ripd/instance/redistribute/route-map */ -int ripd_instance_redistribute_route_map_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_redistribute_route_map_modify(struct nb_cb_modify_args *args) { struct rip *rip; int type; const char *rmap_name; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - type = yang_dnode_get_enum(dnode, "../protocol"); - rmap_name = yang_dnode_get_string(dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + type = yang_dnode_get_enum(args->dnode, "../protocol"); + rmap_name = yang_dnode_get_string(args->dnode, NULL); if (rip->redist[type].route_map.name) free(rip->redist[type].route_map.name); @@ -676,17 +635,17 @@ int ripd_instance_redistribute_route_map_modify(enum nb_event event, return NB_OK; } -int ripd_instance_redistribute_route_map_destroy(enum nb_event event, - const struct lyd_node *dnode) +int ripd_instance_redistribute_route_map_destroy( + struct nb_cb_destroy_args *args) { struct rip *rip; int type; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - type = yang_dnode_get_enum(dnode, "../protocol"); + rip = nb_running_get_entry(args->dnode, NULL, true); + type = yang_dnode_get_enum(args->dnode, "../protocol"); free(rip->redist[type].route_map.name); rip->redist[type].route_map.name = NULL; @@ -698,20 +657,18 @@ int ripd_instance_redistribute_route_map_destroy(enum nb_event event, /* * XPath: /frr-ripd:ripd/instance/redistribute/metric */ -int ripd_instance_redistribute_metric_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_redistribute_metric_modify(struct nb_cb_modify_args *args) { struct rip *rip; int type; uint8_t metric; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - type = yang_dnode_get_enum(dnode, "../protocol"); - metric = yang_dnode_get_uint8(dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + type = yang_dnode_get_enum(args->dnode, "../protocol"); + metric = yang_dnode_get_uint8(args->dnode, NULL); rip->redist[type].metric_config = true; rip->redist[type].metric = metric; @@ -719,17 +676,16 @@ int ripd_instance_redistribute_metric_modify(enum nb_event event, return NB_OK; } -int ripd_instance_redistribute_metric_destroy(enum nb_event event, - const struct lyd_node *dnode) +int ripd_instance_redistribute_metric_destroy(struct nb_cb_destroy_args *args) { struct rip *rip; int type; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - type = yang_dnode_get_enum(dnode, "../protocol"); + rip = nb_running_get_entry(args->dnode, NULL, true); + type = yang_dnode_get_enum(args->dnode, "../protocol"); rip->redist[type].metric_config = false; rip->redist[type].metric = 0; @@ -740,19 +696,17 @@ int ripd_instance_redistribute_metric_destroy(enum nb_event event, /* * XPath: /frr-ripd:ripd/instance/static-route */ -int ripd_instance_static_route_create(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_static_route_create(struct nb_cb_create_args *args) { struct rip *rip; struct nexthop nh; struct prefix_ipv4 p; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - yang_dnode_get_ipv4p(&p, dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + yang_dnode_get_ipv4p(&p, args->dnode, NULL); apply_mask_ipv4(&p); memset(&nh, 0, sizeof(nh)); @@ -763,17 +717,16 @@ int ripd_instance_static_route_create(enum nb_event event, return NB_OK; } -int ripd_instance_static_route_destroy(enum nb_event event, - const struct lyd_node *dnode) +int ripd_instance_static_route_destroy(struct nb_cb_destroy_args *args) { struct rip *rip; struct prefix_ipv4 p; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - yang_dnode_get_ipv4p(&p, dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + yang_dnode_get_ipv4p(&p, args->dnode, NULL); apply_mask_ipv4(&p); rip_redistribute_delete(rip, ZEBRA_ROUTE_RIP, RIP_ROUTE_STATIC, &p, 0); @@ -784,11 +737,11 @@ int ripd_instance_static_route_destroy(enum nb_event event, /* * XPath: /frr-ripd:ripd/instance/timers/ */ -void ripd_instance_timers_apply_finish(const struct lyd_node *dnode) +void ripd_instance_timers_apply_finish(struct nb_cb_apply_finish_args *args) { struct rip *rip; - rip = nb_running_get_entry(dnode, NULL, true); + rip = nb_running_get_entry(args->dnode, NULL, true); /* Reset update timer thread. */ rip_event(rip, RIP_UPDATE_EVENT, 0); @@ -797,17 +750,15 @@ void ripd_instance_timers_apply_finish(const struct lyd_node *dnode) /* * XPath: /frr-ripd:ripd/instance/timers/flush-interval */ -int ripd_instance_timers_flush_interval_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_timers_flush_interval_modify(struct nb_cb_modify_args *args) { struct rip *rip; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - rip->garbage_time = yang_dnode_get_uint32(dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + rip->garbage_time = yang_dnode_get_uint32(args->dnode, NULL); return NB_OK; } @@ -815,17 +766,16 @@ int ripd_instance_timers_flush_interval_modify(enum nb_event event, /* * XPath: /frr-ripd:ripd/instance/timers/holddown-interval */ -int ripd_instance_timers_holddown_interval_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_timers_holddown_interval_modify( + struct nb_cb_modify_args *args) { struct rip *rip; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - rip->timeout_time = yang_dnode_get_uint32(dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + rip->timeout_time = yang_dnode_get_uint32(args->dnode, NULL); return NB_OK; } @@ -833,17 +783,15 @@ int ripd_instance_timers_holddown_interval_modify(enum nb_event event, /* * XPath: /frr-ripd:ripd/instance/timers/update-interval */ -int ripd_instance_timers_update_interval_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_timers_update_interval_modify(struct nb_cb_modify_args *args) { struct rip *rip; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - rip->update_time = yang_dnode_get_uint32(dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + rip->update_time = yang_dnode_get_uint32(args->dnode, NULL); return NB_OK; } @@ -851,17 +799,15 @@ int ripd_instance_timers_update_interval_modify(enum nb_event event, /* * XPath: /frr-ripd:ripd/instance/version/receive */ -int ripd_instance_version_receive_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_version_receive_modify(struct nb_cb_modify_args *args) { struct rip *rip; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - rip->version_recv = yang_dnode_get_enum(dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + rip->version_recv = yang_dnode_get_enum(args->dnode, NULL); return NB_OK; } @@ -869,17 +815,15 @@ int ripd_instance_version_receive_modify(enum nb_event event, /* * XPath: /frr-ripd:ripd/instance/version/send */ -int ripd_instance_version_send_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int ripd_instance_version_send_modify(struct nb_cb_modify_args *args) { struct rip *rip; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - rip = nb_running_get_entry(dnode, NULL, true); - rip->version_send = yang_dnode_get_enum(dnode, NULL); + rip = nb_running_get_entry(args->dnode, NULL, true); + rip->version_send = yang_dnode_get_enum(args->dnode, NULL); return NB_OK; } @@ -887,19 +831,17 @@ int ripd_instance_version_send_modify(enum nb_event event, /* * XPath: /frr-interface:lib/interface/frr-ripd:rip/split-horizon */ -int lib_interface_rip_split_horizon_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int lib_interface_rip_split_horizon_modify(struct nb_cb_modify_args *args) { struct interface *ifp; struct rip_interface *ri; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - ifp = nb_running_get_entry(dnode, NULL, true); + ifp = nb_running_get_entry(args->dnode, NULL, true); ri = ifp->info; - ri->split_horizon = yang_dnode_get_enum(dnode, NULL); + ri->split_horizon = yang_dnode_get_enum(args->dnode, NULL); return NB_OK; } @@ -907,19 +849,17 @@ int lib_interface_rip_split_horizon_modify(enum nb_event event, /* * XPath: /frr-interface:lib/interface/frr-ripd:rip/v2-broadcast */ -int lib_interface_rip_v2_broadcast_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int lib_interface_rip_v2_broadcast_modify(struct nb_cb_modify_args *args) { struct interface *ifp; struct rip_interface *ri; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - ifp = nb_running_get_entry(dnode, NULL, true); + ifp = nb_running_get_entry(args->dnode, NULL, true); ri = ifp->info; - ri->v2_broadcast = yang_dnode_get_bool(dnode, NULL); + ri->v2_broadcast = yang_dnode_get_bool(args->dnode, NULL); return NB_OK; } @@ -927,19 +867,17 @@ int lib_interface_rip_v2_broadcast_modify(enum nb_event event, /* * XPath: /frr-interface:lib/interface/frr-ripd:rip/version-receive */ -int lib_interface_rip_version_receive_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int lib_interface_rip_version_receive_modify(struct nb_cb_modify_args *args) { struct interface *ifp; struct rip_interface *ri; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - ifp = nb_running_get_entry(dnode, NULL, true); + ifp = nb_running_get_entry(args->dnode, NULL, true); ri = ifp->info; - ri->ri_receive = yang_dnode_get_enum(dnode, NULL); + ri->ri_receive = yang_dnode_get_enum(args->dnode, NULL); return NB_OK; } @@ -947,19 +885,17 @@ int lib_interface_rip_version_receive_modify(enum nb_event event, /* * XPath: /frr-interface:lib/interface/frr-ripd:rip/version-send */ -int lib_interface_rip_version_send_modify(enum nb_event event, - const struct lyd_node *dnode, - union nb_resource *resource) +int lib_interface_rip_version_send_modify(struct nb_cb_modify_args *args) { struct interface *ifp; struct rip_interface *ri; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - ifp = nb_running_get_entry(dnode, NULL, true); + ifp = nb_running_get_entry(args->dnode, NULL, true); ri = ifp->info; - ri->ri_send = yang_dnode_get_enum(dnode, NULL); + ri->ri_send = yang_dnode_get_enum(args->dnode, NULL); return NB_OK; } @@ -968,18 +904,17 @@ int lib_interface_rip_version_send_modify(enum nb_event event, * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-scheme/mode */ int lib_interface_rip_authentication_scheme_mode_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) + struct nb_cb_modify_args *args) { struct interface *ifp; struct rip_interface *ri; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - ifp = nb_running_get_entry(dnode, NULL, true); + ifp = nb_running_get_entry(args->dnode, NULL, true); ri = ifp->info; - ri->auth_type = yang_dnode_get_enum(dnode, NULL); + ri->auth_type = yang_dnode_get_enum(args->dnode, NULL); return NB_OK; } @@ -989,32 +924,31 @@ int lib_interface_rip_authentication_scheme_mode_modify( * /frr-interface:lib/interface/frr-ripd:rip/authentication-scheme/md5-auth-length */ int lib_interface_rip_authentication_scheme_md5_auth_length_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) + struct nb_cb_modify_args *args) { struct interface *ifp; struct rip_interface *ri; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - ifp = nb_running_get_entry(dnode, NULL, true); + ifp = nb_running_get_entry(args->dnode, NULL, true); ri = ifp->info; - ri->md5_auth_len = yang_dnode_get_enum(dnode, NULL); + ri->md5_auth_len = yang_dnode_get_enum(args->dnode, NULL); return NB_OK; } int lib_interface_rip_authentication_scheme_md5_auth_length_destroy( - enum nb_event event, const struct lyd_node *dnode) + struct nb_cb_destroy_args *args) { struct interface *ifp; struct rip_interface *ri; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - ifp = nb_running_get_entry(dnode, NULL, true); + ifp = nb_running_get_entry(args->dnode, NULL, true); ri = ifp->info; ri->md5_auth_len = yang_get_default_enum( "%s/authentication-scheme/md5-auth-length", RIP_IFACE); @@ -1026,34 +960,33 @@ int lib_interface_rip_authentication_scheme_md5_auth_length_destroy( * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-password */ int lib_interface_rip_authentication_password_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) + struct nb_cb_modify_args *args) { struct interface *ifp; struct rip_interface *ri; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - ifp = nb_running_get_entry(dnode, NULL, true); + ifp = nb_running_get_entry(args->dnode, NULL, true); ri = ifp->info; XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str); ri->auth_str = XSTRDUP(MTYPE_RIP_INTERFACE_STRING, - yang_dnode_get_string(dnode, NULL)); + yang_dnode_get_string(args->dnode, NULL)); return NB_OK; } int lib_interface_rip_authentication_password_destroy( - enum nb_event event, const struct lyd_node *dnode) + struct nb_cb_destroy_args *args) { struct interface *ifp; struct rip_interface *ri; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - ifp = nb_running_get_entry(dnode, NULL, true); + ifp = nb_running_get_entry(args->dnode, NULL, true); ri = ifp->info; XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str); @@ -1064,34 +997,33 @@ int lib_interface_rip_authentication_password_destroy( * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-key-chain */ int lib_interface_rip_authentication_key_chain_modify( - enum nb_event event, const struct lyd_node *dnode, - union nb_resource *resource) + struct nb_cb_modify_args *args) { struct interface *ifp; struct rip_interface *ri; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - ifp = nb_running_get_entry(dnode, NULL, true); + ifp = nb_running_get_entry(args->dnode, NULL, true); ri = ifp->info; XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain); ri->key_chain = XSTRDUP(MTYPE_RIP_INTERFACE_STRING, - yang_dnode_get_string(dnode, NULL)); + yang_dnode_get_string(args->dnode, NULL)); return NB_OK; } int lib_interface_rip_authentication_key_chain_destroy( - enum nb_event event, const struct lyd_node *dnode) + struct nb_cb_destroy_args *args) { struct interface *ifp; struct rip_interface *ri; - if (event != NB_EV_APPLY) + if (args->event != NB_EV_APPLY) return NB_OK; - ifp = nb_running_get_entry(dnode, NULL, true); + ifp = nb_running_get_entry(args->dnode, NULL, true); ri = ifp->info; XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain); diff --git a/ripd/rip_nb_rpcs.c b/ripd/rip_nb_rpcs.c index 0ca85296f..52f2985cb 100644 --- a/ripd/rip_nb_rpcs.c +++ b/ripd/rip_nb_rpcs.c @@ -78,13 +78,13 @@ static void clear_rip_route(struct rip *rip) } } -int clear_rip_route_rpc(const char *xpath, const struct list *input, - struct list *output) +int clear_rip_route_rpc(struct nb_cb_rpc_args *args) { struct rip *rip; struct yang_data *yang_vrf; - yang_vrf = yang_data_list_find(input, "%s/%s", xpath, "input/vrf"); + yang_vrf = yang_data_list_find(args->input, "%s/%s", args->xpath, + "input/vrf"); if (yang_vrf) { rip = rip_lookup_by_vrf_name(yang_vrf->value); if (rip) diff --git a/ripd/rip_nb_state.c b/ripd/rip_nb_state.c index 2f7eb3cb5..e88f33ec6 100644 --- a/ripd/rip_nb_state.c +++ b/ripd/rip_nb_state.c @@ -37,12 +37,11 @@ /* * XPath: /frr-ripd:ripd/instance */ -const void *ripd_instance_get_next(const void *parent_list_entry, - const void *list_entry) +const void *ripd_instance_get_next(struct nb_cb_get_next_args *args) { - struct rip *rip = (struct rip *)list_entry; + struct rip *rip = (struct rip *)args->list_entry; - if (list_entry == NULL) + if (args->list_entry == NULL) rip = RB_MIN(rip_instance_head, &rip_instances); else rip = RB_NEXT(rip_instance_head, rip); @@ -50,20 +49,19 @@ const void *ripd_instance_get_next(const void *parent_list_entry, return rip; } -int ripd_instance_get_keys(const void *list_entry, struct yang_list_keys *keys) +int ripd_instance_get_keys(struct nb_cb_get_keys_args *args) { - const struct rip *rip = list_entry; + const struct rip *rip = args->list_entry; - keys->num = 1; - strlcpy(keys->key[0], rip->vrf_name, sizeof(keys->key[0])); + args->keys->num = 1; + strlcpy(args->keys->key[0], rip->vrf_name, sizeof(args->keys->key[0])); return NB_OK; } -const void *ripd_instance_lookup_entry(const void *parent_list_entry, - const struct yang_list_keys *keys) +const void *ripd_instance_lookup_entry(struct nb_cb_lookup_entry_args *args) { - const char *vrf_name = keys->key[0]; + const char *vrf_name = args->keys->key[0]; return rip_lookup_by_vrf_name(vrf_name); } @@ -71,43 +69,42 @@ const void *ripd_instance_lookup_entry(const void *parent_list_entry, /* * XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor */ -const void * -ripd_instance_state_neighbors_neighbor_get_next(const void *parent_list_entry, - const void *list_entry) +const void *ripd_instance_state_neighbors_neighbor_get_next( + struct nb_cb_get_next_args *args) { - const struct rip *rip = parent_list_entry; + const struct rip *rip = args->parent_list_entry; struct listnode *node; - if (list_entry == NULL) + if (args->list_entry == NULL) node = listhead(rip->peer_list); else - node = listnextnode((struct listnode *)list_entry); + node = listnextnode((struct listnode *)args->list_entry); return node; } -int ripd_instance_state_neighbors_neighbor_get_keys(const void *list_entry, - struct yang_list_keys *keys) +int ripd_instance_state_neighbors_neighbor_get_keys( + struct nb_cb_get_keys_args *args) { - const struct listnode *node = list_entry; + const struct listnode *node = args->list_entry; const struct rip_peer *peer = listgetdata(node); - keys->num = 1; - (void)inet_ntop(AF_INET, &peer->addr, keys->key[0], - sizeof(keys->key[0])); + args->keys->num = 1; + (void)inet_ntop(AF_INET, &peer->addr, args->keys->key[0], + sizeof(args->keys->key[0])); return NB_OK; } const void *ripd_instance_state_neighbors_neighbor_lookup_entry( - const void *parent_list_entry, const struct yang_list_keys *keys) + struct nb_cb_lookup_entry_args *args) { - const struct rip *rip = parent_list_entry; + const struct rip *rip = args->parent_list_entry; struct in_addr address; struct rip_peer *peer; struct listnode *node; - yang_str2ipv4(keys->key[0], &address); + yang_str2ipv4(args->keys->key[0], &address); for (ALL_LIST_ELEMENTS_RO(rip->peer_list, node, peer)) { if (IPV4_ADDR_SAME(&peer->addr, &address)) @@ -120,21 +117,20 @@ const void *ripd_instance_state_neighbors_neighbor_lookup_entry( /* * XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor/address */ -struct yang_data * -ripd_instance_state_neighbors_neighbor_address_get_elem(const char *xpath, - const void *list_entry) +struct yang_data *ripd_instance_state_neighbors_neighbor_address_get_elem( + struct nb_cb_get_elem_args *args) { - const struct listnode *node = list_entry; + const struct listnode *node = args->list_entry; const struct rip_peer *peer = listgetdata(node); - return yang_data_new_ipv4(xpath, &peer->addr); + return yang_data_new_ipv4(args->xpath, &peer->addr); } /* * XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor/last-update */ struct yang_data *ripd_instance_state_neighbors_neighbor_last_update_get_elem( - const char *xpath, const void *list_entry) + struct nb_cb_get_elem_args *args) { /* TODO: yang:date-and-time is tricky */ return NULL; @@ -145,12 +141,12 @@ struct yang_data *ripd_instance_state_neighbors_neighbor_last_update_get_elem( */ struct yang_data * ripd_instance_state_neighbors_neighbor_bad_packets_rcvd_get_elem( - const char *xpath, const void *list_entry) + struct nb_cb_get_elem_args *args) { - const struct listnode *node = list_entry; + const struct listnode *node = args->list_entry; const struct rip_peer *peer = listgetdata(node); - return yang_data_new_uint32(xpath, peer->recv_badpackets); + return yang_data_new_uint32(args->xpath, peer->recv_badpackets); } /* @@ -158,54 +154,52 @@ ripd_instance_state_neighbors_neighbor_bad_packets_rcvd_get_elem( */ struct yang_data * ripd_instance_state_neighbors_neighbor_bad_routes_rcvd_get_elem( - const char *xpath, const void *list_entry) + struct nb_cb_get_elem_args *args) { - const struct listnode *node = list_entry; + const struct listnode *node = args->list_entry; const struct rip_peer *peer = listgetdata(node); - return yang_data_new_uint32(xpath, peer->recv_badroutes); + return yang_data_new_uint32(args->xpath, peer->recv_badroutes); } /* * XPath: /frr-ripd:ripd/instance/state/routes/route */ const void * -ripd_instance_state_routes_route_get_next(const void *parent_list_entry, - const void *list_entry) +ripd_instance_state_routes_route_get_next(struct nb_cb_get_next_args *args) { - const struct rip *rip = parent_list_entry; + const struct rip *rip = args->parent_list_entry; struct route_node *rn; - if (list_entry == NULL) + if (args->list_entry == NULL) rn = route_top(rip->table); else - rn = route_next((struct route_node *)list_entry); + rn = route_next((struct route_node *)args->list_entry); while (rn && rn->info == NULL) rn = route_next(rn); return rn; } -int ripd_instance_state_routes_route_get_keys(const void *list_entry, - struct yang_list_keys *keys) +int ripd_instance_state_routes_route_get_keys(struct nb_cb_get_keys_args *args) { - const struct route_node *rn = list_entry; + const struct route_node *rn = args->list_entry; - keys->num = 1; - (void)prefix2str(&rn->p, keys->key[0], sizeof(keys->key[0])); + args->keys->num = 1; + (void)prefix2str(&rn->p, args->keys->key[0], + sizeof(args->keys->key[0])); return NB_OK; } -const void * -ripd_instance_state_routes_route_lookup_entry(const void *parent_list_entry, - const struct yang_list_keys *keys) +const void *ripd_instance_state_routes_route_lookup_entry( + struct nb_cb_lookup_entry_args *args) { - const struct rip *rip = parent_list_entry; + const struct rip *rip = args->parent_list_entry; struct prefix prefix; struct route_node *rn; - yang_str2ipv4p(keys->key[0], &prefix); + yang_str2ipv4p(args->keys->key[0], &prefix); rn = route_node_lookup(rip->table, &prefix); if (!rn || !rn->info) @@ -219,30 +213,28 @@ ripd_instance_state_routes_route_lookup_entry(const void *parent_list_entry, /* * XPath: /frr-ripd:ripd/instance/state/routes/route/prefix */ -struct yang_data * -ripd_instance_state_routes_route_prefix_get_elem(const char *xpath, - const void *list_entry) +struct yang_data *ripd_instance_state_routes_route_prefix_get_elem( + struct nb_cb_get_elem_args *args) { - const struct route_node *rn = list_entry; + const struct route_node *rn = args->list_entry; const struct rip_info *rinfo = listnode_head(rn->info); - return yang_data_new_ipv4p(xpath, &rinfo->rp->p); + return yang_data_new_ipv4p(args->xpath, &rinfo->rp->p); } /* * XPath: /frr-ripd:ripd/instance/state/routes/route/next-hop */ -struct yang_data * -ripd_instance_state_routes_route_next_hop_get_elem(const char *xpath, - const void *list_entry) +struct yang_data *ripd_instance_state_routes_route_next_hop_get_elem( + struct nb_cb_get_elem_args *args) { - const struct route_node *rn = list_entry; + const struct route_node *rn = args->list_entry; const struct rip_info *rinfo = listnode_head(rn->info); switch (rinfo->nh.type) { case NEXTHOP_TYPE_IPV4: case NEXTHOP_TYPE_IPV4_IFINDEX: - return yang_data_new_ipv4(xpath, &rinfo->nh.gate.ipv4); + return yang_data_new_ipv4(args->xpath, &rinfo->nh.gate.ipv4); default: return NULL; } @@ -251,11 +243,10 @@ ripd_instance_state_routes_route_next_hop_get_elem(const char *xpath, /* * XPath: /frr-ripd:ripd/instance/state/routes/route/interface */ -struct yang_data * -ripd_instance_state_routes_route_interface_get_elem(const char *xpath, - const void *list_entry) +struct yang_data *ripd_instance_state_routes_route_interface_get_elem( + struct nb_cb_get_elem_args *args) { - const struct route_node *rn = list_entry; + const struct route_node *rn = args->list_entry; const struct rip_info *rinfo = listnode_head(rn->info); const struct rip *rip = rip_info_get_instance(rinfo); @@ -263,7 +254,7 @@ ripd_instance_state_routes_route_interface_get_elem(const char *xpath, case NEXTHOP_TYPE_IFINDEX: case NEXTHOP_TYPE_IPV4_IFINDEX: return yang_data_new_string( - xpath, + args->xpath, ifindex2ifname(rinfo->nh.ifindex, rip->vrf->vrf_id)); default: return NULL; @@ -273,12 +264,11 @@ ripd_instance_state_routes_route_interface_get_elem(const char *xpath, /* * XPath: /frr-ripd:ripd/instance/state/routes/route/metric */ -struct yang_data * -ripd_instance_state_routes_route_metric_get_elem(const char *xpath, - const void *list_entry) +struct yang_data *ripd_instance_state_routes_route_metric_get_elem( + struct nb_cb_get_elem_args *args) { - const struct route_node *rn = list_entry; + const struct route_node *rn = args->list_entry; const struct rip_info *rinfo = listnode_head(rn->info); - return yang_data_new_uint8(xpath, rinfo->metric); + return yang_data_new_uint8(args->xpath, rinfo->metric); } |