SNAT: user_session_dump is_ip4 and vat unformating added

Change-Id: I0ffab147c3218a75b7c3bb829983f538c7b637ee
Signed-off-by: Martin <magalik@cisco.com>
This commit is contained in:
Martin
2017-03-08 03:31:02 -08:00
parent 3f844d0bc9
commit 6b7fcda466
4 changed files with 24 additions and 2 deletions

View File

@ -387,12 +387,14 @@ define snat_user_details {
/** \brief S-NAT user's sessions
@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 user_ip - IP address of the user to dump
@param vrf_id - VRF_ID
*/
define snat_user_session_dump {
u32 client_index;
u32 context;
u8 is_ip4;
u8 ip_address[16];
u32 vrf_id;
};

View File

@ -1539,6 +1539,8 @@ vl_api_snat_user_session_dump_t_handler
q = vl_api_client_index_to_input_queue (mp->client_index);
if (q == 0)
return;
if (!mp->is_ip4)
return;
clib_memcpy (&ukey.addr, mp->ip_address, 4);
ukey.fib_index = ip4_fib_index_from_table_id (ntohl(mp->vrf_id));

View File

@ -667,8 +667,11 @@ static void vl_api_snat_user_session_details_t_handler
static int api_snat_user_session_dump(vat_main_t * vam)
{
unformat_input_t* i = vam->input;
vl_api_snat_user_session_dump_t * mp;
vl_api_snat_control_ping_t *mp_ping;
ip4_address_t addr;
u32 vrf_id = ~0;
int ret;
if (vam->json_output)
@ -677,11 +680,24 @@ static int api_snat_user_session_dump(vat_main_t * vam)
return -99;
}
if (unformat (i, "ip_address %U vrf_id %d",
unformat_ip4_address, &addr, &vrf_id))
;
else
{
clib_warning("unknown input '%U'", format_unformat_error, i);
return -99;
}
M(SNAT_USER_SESSION_DUMP, mp);
S(mp);
/* Use a control ping for synchronization */
M(SNAT_CONTROL_PING, mp_ping);
memset(mp->ip_address, 0, 16);
clib_memcpy(mp->ip_address, &addr, 4);
mp->vrf_id = htonl(vrf_id);
mp->is_ip4 = 1;
S(mp_ping);
W (ret);

View File

@ -1109,7 +1109,8 @@ class VppPapiProvider(object):
def snat_user_session_dump(
self,
ip_address,
vrf_id):
vrf_id,
is_ip4=1):
"""Dump S-NAT user's sessions
:param ip_address: ip adress of the user to be dumped
@ -1120,7 +1121,8 @@ class VppPapiProvider(object):
return self.api(
self.papi.snat_user_session_dump,
{'ip_address': ip_address,
'vrf_id': vrf_id})
'vrf_id': vrf_id,
'is_ip4': is_ip4})
def snat_user_dump(self):
"""Dump S-NAT users