#include <vlibmemory/api.h>
#include <vppinfra/error.h>
#include <gtpu/gtpu.h>
+#include <vnet/ip/ip_types_api.h>
#define __plugin_msg_base gtpu_test_main.msg_id_base
#include <vlibapi/vat_helper_macros.h>
+#include <vnet/format_fns.h>
#include <gtpu/gtpu.api_enum.h>
#include <gtpu/gtpu.api_types.h>
return 1;
}
+static uword
+api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
+{
+ return 0;
+}
+
static int
api_sw_interface_set_gtpu_bypass (vat_main_t * vam)
{
return 1;
}
+static int
+api_gtpu_offload_rx (vat_main_t * vam)
+{
+ unformat_input_t *line_input = vam->input;
+ vl_api_gtpu_offload_rx_t *mp;
+ u32 rx_sw_if_index = ~0;
+ u32 hw_if_index = ~0;
+ int is_add = 1;
+ int ret;
+
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam, &hw_if_index))
+ ;
+ else
+ if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
+ ;
+ else
+ if (unformat (line_input, "del"))
+ {
+ is_add = 0;
+ continue;
+ }
+ else
+ {
+ errmsg ("parse error '%U'", format_unformat_error, line_input);
+ return -99;
+ }
+ }
+
+ if (rx_sw_if_index == ~0)
+ {
+ errmsg ("missing rx interface");
+ return -99;
+ }
+
+ if (hw_if_index == ~0)
+ {
+ errmsg ("missing hw interface");
+ return -99;
+ }
+
+ M (GTPU_OFFLOAD_RX, mp);
+ mp->hw_if_index = ntohl (hw_if_index);
+ mp->sw_if_index = ntohl (rx_sw_if_index);
+ mp->enable = is_add;
+
+ S (mp);
+ W (ret);
+ return ret;
+}
+
static int
api_gtpu_add_del_tunnel (vat_main_t * vam)
{
M (GTPU_ADD_DEL_TUNNEL, mp);
- if (ipv6_set)
- {
- clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
- clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
- }
- else
- {
- clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
- clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
- }
+ ip_address_encode(&src, ipv6_set ? IP46_TYPE_IP6 : IP46_TYPE_IP4,
+ &mp->src_address);
+ ip_address_encode(&dst, ipv6_set ? IP46_TYPE_IP6 : IP46_TYPE_IP4,
+ &mp->dst_address);
mp->encap_vrf_id = ntohl (encap_vrf_id);
mp->decap_next_index = ntohl (decap_next_index);
mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
mp->teid = ntohl (teid);
mp->is_add = is_add;
- mp->is_ipv6 = ipv6_set;
S (mp);
W (ret);
(vl_api_gtpu_tunnel_details_t * mp)
{
vat_main_t *vam = &vat_main;
- ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
- ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
-
+ ip46_address_t src;
+ ip46_address_t dst;
+ ip_address_decode(&mp->dst_address, &dst);
+ ip_address_decode(&mp->src_address, &src);
print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
ntohl (mp->sw_if_index),
format_ip46_address, &src, IP46_TYPE_ANY,