u32 sw_if_index = ~0;
u8 sw_if_index_set = 0;
u32 proto = ~0;
+ u8 proto_set = 0;
int ret;
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
else if (unformat (i, "vrf %u", &vrf_id))
;
else if (unformat (i, "protocol %u", &proto))
- ;
+ proto_set = 1;
else if (unformat (i, "del"))
is_add = 0;
else
}
}
+ if (!addr_only && !proto_set)
+ {
+ errmsg ("protocol required\n");
+ return -99;
+ }
+
if (!local_addr_set)
{
errmsg ("local addr required\n");
snat_test_main_t * sm = &snat_test_main;
vat_main_t *vam = sm->vat_main;
- if (mp->addr_only)
+ if (mp->addr_only && mp->external_sw_if_index != ~0)
+ fformat (vam->ofp, "%15U%6s%15d%6s%11d%6d\n",
+ format_ip4_address, &mp->local_ip_address, "",
+ ntohl (mp->external_sw_if_index), "",
+ ntohl (mp->vrf_id),
+ mp->protocol);
+ else if (mp->addr_only && mp->external_sw_if_index == ~0)
fformat (vam->ofp, "%15U%6s%15U%6s%11d%6d\n",
format_ip4_address, &mp->local_ip_address, "",
format_ip4_address, &mp->external_ip_address, "",
ntohl (mp->vrf_id),
mp->protocol);
+ else if (!mp->addr_only && mp->external_sw_if_index != ~0)
+ fformat (vam->ofp, "%15U%6d%15d%6d%11d%6d\n",
+ format_ip4_address, &mp->local_ip_address,
+ ntohs (mp->local_port),
+ ntohl (mp->external_sw_if_index),
+ ntohs (mp->external_port),
+ ntohl (mp->vrf_id),
+ mp->protocol);
else
fformat (vam->ofp, "%15U%6d%15U%6d%11d%6d\n",
format_ip4_address, &mp->local_ip_address,
}
fformat (vam->ofp, "%21s%21s\n", "local", "external");
- fformat (vam->ofp, "%15s%6s%15s%6s%11s%6s\n", "address", "port", "address",
- "port", "vrf", "proto");
+ fformat (vam->ofp, "%15s%6s%15s%6s%11s%6s\n", "address", "port",
+ "address/if_idx", "port", "vrf", "proto");
M(SNAT_STATIC_MAPPING_DUMP, mp);
S(mp);
return ret;
}
-static int api_snat_ipfix_enable_disable (vat_main_t * vam)
+static int api_snat_add_del_interface_addr (vat_main_t * vam)
{
unformat_input_t * i = vam->input;
vl_api_snat_add_del_interface_addr_t * mp;
return ret;
}
-static int api_snat_add_del_interface_addr (vat_main_t * vam)
+static int api_snat_ipfix_enable_disable (vat_main_t * vam)
{
unformat_input_t * i = vam->input;
vl_api_snat_ipfix_enable_disable_t * mp;