X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fbonding%2Fbond_api.c;fp=src%2Fvnet%2Fbonding%2Fbond_api.c;h=3fd73d7995f416a426bdcf1fabe230a244a270ab;hb=116a1e52772c3a2dba61f8f2ac9c919f0623153c;hp=8b8385d82059426f44773d973f5ebeabfafb8247;hpb=79699b00c155f9f5b776451a55e151befa3ba33b;p=vpp.git diff --git a/src/vnet/bonding/bond_api.c b/src/vnet/bonding/bond_api.c index 8b8385d8205..3fd73d7995f 100644 --- a/src/vnet/bonding/bond_api.c +++ b/src/vnet/bonding/bond_api.c @@ -24,39 +24,16 @@ #include #include #include +#include -#include - -#define vl_typedefs /* define message structures */ -#include -#undef vl_typedefs - -#define vl_endianfun /* define message structures */ -#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 +#include +#include +#include +#define REPLY_MSG_ID_BASE msg_id_base #include -#include -#define foreach_bond_api_msg \ -_(BOND_CREATE, bond_create) \ -_(BOND_CREATE2, bond_create2) \ -_(BOND_DELETE, bond_delete) \ -_(BOND_ENSLAVE, bond_enslave) \ -_(BOND_ADD_MEMBER, bond_add_member) \ -_(SW_INTERFACE_SET_BOND_WEIGHT, sw_interface_set_bond_weight) \ -_(BOND_DETACH_SLAVE, bond_detach_slave) \ -_(BOND_DETACH_MEMBER, bond_detach_member) \ -_(SW_INTERFACE_BOND_DUMP, sw_interface_bond_dump) \ -_(SW_BOND_INTERFACE_DUMP, sw_bond_interface_dump) \ -_(SW_INTERFACE_SLAVE_DUMP, sw_interface_slave_dump) \ -_(SW_MEMBER_INTERFACE_DUMP, sw_member_interface_dump) +static u16 msg_id_base; static void vl_api_bond_delete_t_handler (vl_api_bond_delete_t * mp) @@ -246,7 +223,8 @@ bond_send_sw_interface_details (vpe_api_main_t * am, mp = vl_msg_api_alloc (sizeof (*mp)); clib_memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = htons (VL_API_SW_INTERFACE_BOND_DETAILS); + mp->_vl_msg_id = + htons (REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_BOND_DETAILS); mp->sw_if_index = htonl (bond_if->sw_if_index); mp->id = htonl (bond_if->id); clib_memcpy (mp->interface_name, bond_if->interface_name, @@ -297,7 +275,8 @@ bond_send_sw_bond_interface_details (vpe_api_main_t * am, mp = vl_msg_api_alloc (sizeof (*mp)); clib_memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = htons (VL_API_SW_BOND_INTERFACE_DETAILS); + mp->_vl_msg_id = + htons (REPLY_MSG_ID_BASE + VL_API_SW_BOND_INTERFACE_DETAILS); mp->sw_if_index = htonl (bond_if->sw_if_index); mp->id = htonl (bond_if->id); clib_memcpy (mp->interface_name, bond_if->interface_name, @@ -356,7 +335,8 @@ bond_send_sw_member_interface_details (vpe_api_main_t * am, mp = vl_msg_api_alloc (sizeof (*mp)); clib_memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = htons (VL_API_SW_INTERFACE_SLAVE_DETAILS); + mp->_vl_msg_id = + htons (REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_SLAVE_DETAILS); mp->sw_if_index = htonl (member_if->sw_if_index); clib_memcpy (mp->interface_name, member_if->interface_name, MIN (ARRAY_LEN (mp->interface_name) - 1, @@ -406,7 +386,8 @@ bond_send_member_interface_details (vpe_api_main_t * am, mp = vl_msg_api_alloc (sizeof (*mp)); clib_memset (mp, 0, sizeof (*mp)); - mp->_vl_msg_id = htons (VL_API_SW_MEMBER_INTERFACE_DETAILS); + mp->_vl_msg_id = + htons (REPLY_MSG_ID_BASE + VL_API_SW_MEMBER_INTERFACE_DETAILS); mp->sw_if_index = htonl (member_if->sw_if_index); clib_memcpy (mp->interface_name, member_if->interface_name, MIN (ARRAY_LEN (mp->interface_name) - 1, @@ -446,37 +427,14 @@ vl_api_sw_member_interface_dump_t_handler (vl_api_sw_member_interface_dump_t * vec_free (memberifs); } -#define vl_msg_name_crc_list -#include -#undef vl_msg_name_crc_list - -static void -bond_setup_message_id_table (api_main_t * am) -{ -#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id); - foreach_vl_msg_name_crc_bond; -#undef _ -} - +#include static clib_error_t * bond_api_hookup (vlib_main_t * vm) { - api_main_t *am = vlibapi_get_main (); - -#define _(N,n) \ - vl_msg_api_set_handlers(VL_API_##N, #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_bond_api_msg; -#undef _ - /* * Set up the (msg_name, crc, message-id) table */ - bond_setup_message_id_table (am); + REPLY_MSG_ID_BASE = setup_message_id_table (); return 0; }