stn: use explicit types in api
Type: fix Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: Ifba4ff0e0f61641ca3f5e7bb72086cb4f32f1909
This commit is contained in:
committed by
Andrew Yourtchenko
parent
277f03f067
commit
7929f9f5c6
@@ -19,12 +19,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
option version = "1.0.0";
|
||||
option version = "2.0.0";
|
||||
import "vnet/interface_types.api";
|
||||
import "vnet/ip/ip_types.api";
|
||||
|
||||
/** \brief Add/del STN rules
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param is_ip4 - 1 if address type is IPv4
|
||||
@param ip_address - STN rule IP address
|
||||
@param sw_if_index - Interface index
|
||||
@param is_add - 1 if add, 0 if delete
|
||||
@@ -32,10 +33,9 @@ option version = "1.0.0";
|
||||
autoreply manual_print define stn_add_del_rule {
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u8 is_ip4;
|
||||
u8 ip_address[16];
|
||||
u32 sw_if_index;
|
||||
u8 is_add;
|
||||
vl_api_address_t ip_address;
|
||||
vl_api_interface_index_t sw_if_index;
|
||||
bool is_add;
|
||||
};
|
||||
|
||||
/** \brief Dump STN rules
|
||||
@@ -55,8 +55,7 @@ define stn_rules_dump {
|
||||
*/
|
||||
define stn_rules_details {
|
||||
u32 context;
|
||||
u8 is_ip4;
|
||||
u8 ip_address[16];
|
||||
u32 sw_if_index;
|
||||
vl_api_address_t ip_address;
|
||||
vl_api_interface_index_t sw_if_index;
|
||||
};
|
||||
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
|
||||
#include <plugins/stn/stn.h>
|
||||
#include <vnet/ip/format.h>
|
||||
|
||||
#include <vnet/format_fns.h>
|
||||
#include <vnet/ip/ip_types_api.h>
|
||||
#include <vppinfra/byte_order.h>
|
||||
|
||||
/* define message IDs */
|
||||
@@ -48,10 +49,7 @@ static void *vl_api_stn_add_del_rule_t_print
|
||||
u8 *s;
|
||||
|
||||
s = format (0, "SCRIPT: stn_add_del_rule ");
|
||||
if (mp->is_ip4)
|
||||
s = format (s, "address %U ", format_ip4_address, mp->ip_address);
|
||||
else
|
||||
s = format (s, "address %U ", format_ip6_address, mp->ip_address);
|
||||
s = format (s, "address %U ", format_ip46_address, mp->ip_address);
|
||||
s = format (s, "sw_if_index %d is_add %d", mp->sw_if_index, mp->is_add);
|
||||
|
||||
FINISH;
|
||||
@@ -64,15 +62,7 @@ vl_api_stn_add_del_rule_t_handler (vl_api_stn_add_del_rule_t * mp)
|
||||
vl_api_stn_add_del_rule_reply_t *rmp;
|
||||
int rv = 0;
|
||||
|
||||
if (mp->is_ip4)
|
||||
{
|
||||
ip4_address_t a;
|
||||
memcpy (&a, mp->ip_address, sizeof (a));
|
||||
ip46_address_set_ip4 (&args.address, &a);
|
||||
}
|
||||
else
|
||||
memcpy (&args.address.ip6, mp->ip_address, sizeof (ip6_address_t));
|
||||
|
||||
ip_address_decode (&mp->ip_address, &args.address);
|
||||
args.sw_if_index = clib_net_to_host_u32 (mp->sw_if_index);
|
||||
args.del = !mp->is_add;
|
||||
|
||||
@@ -92,16 +82,9 @@ send_stn_rules_details (stn_rule_t * r, vl_api_registration_t * reg,
|
||||
rmp->_vl_msg_id =
|
||||
clib_host_to_net_u16 (VL_API_STN_RULES_DETAILS + stn_main.msg_id_base);
|
||||
|
||||
if (ip46_address_is_ip4 (&r->address))
|
||||
{
|
||||
clib_memcpy (rmp->ip_address, &r->address.ip4, sizeof (ip4_address_t));
|
||||
rmp->is_ip4 = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
clib_memcpy (rmp->ip_address, &r->address.ip6, sizeof (ip6_address_t));
|
||||
}
|
||||
|
||||
ip_address_encode (&r->address,
|
||||
ip46_address_is_ip4 (&r->address) ? IP46_TYPE_IP4 :
|
||||
IP46_TYPE_IP6, &rmp->ip_address);
|
||||
rmp->context = context;
|
||||
rmp->sw_if_index = clib_host_to_net_u32 (r->sw_if_index);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <vlibapi/api.h>
|
||||
#include <vlibmemory/api.h>
|
||||
#include <vppinfra/error.h>
|
||||
|
||||
#include <vnet/format_fns.h>
|
||||
#include <stn/stn.h>
|
||||
|
||||
#define __plugin_msg_base stn_test_main.msg_id_base
|
||||
@@ -81,7 +81,7 @@ vl_api_stn_rules_details_t_handler (vl_api_stn_rules_details_t * mp)
|
||||
{
|
||||
vat_main_t *vam = stn_test_main.vat_main;
|
||||
fformat (vam->ofp, "addr: %U sw_if_index: %u\n",
|
||||
mp->is_ip4 ? format_ip4_address : format_ip6_address,
|
||||
format_ip46_address,
|
||||
mp->ip_address, clib_net_to_host_u32 (mp->sw_if_index));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user