X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fabf%2Fabf_api.c;h=cc55b214e358c185129bc4e506b10c03d4f5f932;hb=e5d34919b;hp=9da08394fe6cdd9f4a508e44def8e3ce63394a0f;hpb=2e1c8967faf4e9f7b45471df02e4e5b07fbb520a;p=vpp.git diff --git a/src/plugins/abf/abf_api.c b/src/plugins/abf/abf_api.c index 9da08394fe6..cc55b214e35 100644 --- a/src/plugins/abf/abf_api.c +++ b/src/plugins/abf/abf_api.c @@ -29,28 +29,9 @@ #include /* define message IDs */ -#include - -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* define generated endian-swappers */ -#define vl_endianfun -#include -#undef vl_endianfun - -/* instantiate all the print functions we know about */ -#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) -#define vl_printfun -#include -#undef vl_printfun - -/* Get the API version number */ -#define vl_api_version(n,v) static u32 api_version=(v); -#include -#undef vl_api_version +#include +#include +#include /** * Base message ID fot the plugin @@ -59,15 +40,6 @@ static u32 abf_base_msg_id; #include -/* List of message types that this plugin understands */ - -#define foreach_abf_plugin_api_msg \ -_(ABF_PLUGIN_GET_VERSION, abf_plugin_get_version) \ -_(ABF_POLICY_ADD_DEL, abf_policy_add_del) \ -_(ABF_POLICY_DUMP, abf_policy_dump) \ -_(ABF_ITF_ATTACH_ADD_DEL, abf_itf_attach_add_del) \ -_(ABF_ITF_ATTACH_DUMP, abf_itf_attach_dump) - static void vl_api_abf_plugin_get_version_t_handler (vl_api_abf_plugin_get_version_t * mp) { @@ -101,7 +73,7 @@ vl_api_abf_policy_add_del_t_handler (vl_api_abf_policy_add_del_t * mp) for (pi = 0; pi < mp->policy.n_paths; pi++) { path = &paths[pi]; - rv = fib_path_api_parse (&mp->policy.paths[pi], path); + rv = fib_api_path_decode (&mp->policy.paths[pi], path); if (0 != rv) { @@ -111,12 +83,12 @@ vl_api_abf_policy_add_del_t_handler (vl_api_abf_policy_add_del_t * mp) if (mp->is_add) { - abf_policy_update (ntohl (mp->policy.policy_id), - ntohl (mp->policy.acl_index), paths); + rv = abf_policy_update (ntohl (mp->policy.policy_id), + ntohl (mp->policy.acl_index), paths); } else { - abf_policy_delete (ntohl (mp->policy.policy_id), paths); + rv = abf_policy_delete (ntohl (mp->policy.policy_id), paths); } done: vec_free (paths); @@ -158,9 +130,12 @@ typedef struct abf_dump_walk_ctx_t_ static int abf_policy_send_details (u32 api, void *args) { - fib_route_path_encode_t *api_rpaths = NULL, *api_rpath; + fib_path_encode_ctx_t walk_ctx = { + .rpaths = NULL, + }; vl_api_abf_policy_details_t *mp; abf_dump_walk_ctx_t *ctx; + fib_route_path_t *rpath; vl_api_fib_path_t *fp; size_t msg_size; abf_policy_t *ap; @@ -181,17 +156,19 @@ abf_policy_send_details (u32 api, void *args) mp->policy.acl_index = htonl (ap->ap_acl); mp->policy.policy_id = htonl (ap->ap_id); - fib_path_list_walk_w_ext (ap->ap_pl, NULL, fib_path_encode, &api_rpaths); + fib_path_list_walk_w_ext (ap->ap_pl, NULL, fib_path_encode, &walk_ctx); fp = mp->policy.paths; - vec_foreach (api_rpath, api_rpaths) + vec_foreach (rpath, walk_ctx.rpaths) { - fib_api_path_encode (api_rpath, fp); + fib_api_path_encode (rpath, fp); fp++; } vl_api_send_msg (ctx->rp, (u8 *) mp); + vec_free (walk_ctx.rpaths); + return (1); } @@ -255,56 +232,15 @@ vl_api_abf_itf_attach_dump_t_handler (vl_api_abf_itf_attach_dump_t * mp) abf_itf_attach_walk (abf_itf_attach_send_details, &ctx); } -#define vl_msg_name_crc_list -#include -#undef vl_msg_name_crc_list - -/* Set up the API message handling tables */ -static clib_error_t * -abf_plugin_api_hookup (vlib_main_t * vm) -{ -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + abf_base_msg_id), \ - #n, \ - vl_api_##n##_t_handler, \ - vl_noop_handler, \ - vl_api_##n##_t_endian, \ - vl_api_##n##_t_print, \ - sizeof(vl_api_##n##_t), 1); - foreach_abf_plugin_api_msg; -#undef _ - - return 0; -} - -static void -setup_message_id_table (api_main_t * apim) -{ -#define _(id,n,crc) \ - vl_msg_api_add_msg_name_crc (apim, #n "_" #crc, id + abf_base_msg_id); - foreach_vl_msg_name_crc_abf; -#undef _ -} +#include static clib_error_t * abf_api_init (vlib_main_t * vm) { - clib_error_t *error = 0; - - u8 *name = format (0, "abf_%08x%c", api_version, 0); - /* Ask for a correctly-sized block of API message decode slots */ - abf_base_msg_id = vl_msg_api_get_msg_ids ((char *) name, - VL_MSG_FIRST_AVAILABLE); - - error = abf_plugin_api_hookup (vm); + abf_base_msg_id = setup_message_id_table (); - /* Add our API messages to the global name_crc hash table */ - setup_message_id_table (&api_main); - - vec_free (name); - - return error; + return 0; } VLIB_INIT_FUNCTION (abf_api_init); @@ -312,7 +248,7 @@ VLIB_INIT_FUNCTION (abf_api_init); /* *INDENT-OFF* */ VLIB_PLUGIN_REGISTER () = { .version = VPP_BUILD_VER, - .description = "ACL based Forwarding", + .description = "Access Control List (ACL) Based Forwarding", }; /* *INDENT-ON* */