/*
- * Copyright (c) 2018 Cisco and/or its affiliates.
+ * Copyright (c) 2018-2019 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
vl_api_udp_encap_details_t *mp;
mp = vl_msg_api_alloc (sizeof (*mp));
- memset (mp, 0, sizeof (*mp));
+ clib_memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_UDP_ENCAP_DETAILS);
mp->context = context;
&ue->ue_hdrs.ip4.ue_ip4.src_address, 4);
clib_memcpy (&mp->udp_encap.dst_ip.un.ip4,
&ue->ue_hdrs.ip4.ue_ip4.dst_address, 4);
- mp->udp_encap.dst_ip.af = clib_host_to_net_u32 (ADDRESS_IP4);
- mp->udp_encap.src_ip.af = clib_host_to_net_u32 (ADDRESS_IP4);
+ mp->udp_encap.dst_ip.af = ip_address_family_encode (AF_IP4);
+ mp->udp_encap.src_ip.af = ip_address_family_encode (AF_IP4);
/* ports aren't byte swapped because they are stored in network
* byte order */
&ue->ue_hdrs.ip6.ue_ip6.src_address, 16);
clib_memcpy (&mp->udp_encap.dst_ip.un.ip6,
&ue->ue_hdrs.ip6.ue_ip6.dst_address, 16);
- mp->udp_encap.dst_ip.af = clib_host_to_net_u32 (ADDRESS_IP6);
- mp->udp_encap.src_ip.af = clib_host_to_net_u32 (ADDRESS_IP6);
+ mp->udp_encap.dst_ip.af = ip_address_family_encode (AF_IP6);
+ mp->udp_encap.src_ip.af = ip_address_family_encode (AF_IP6);
/* ports aren't byte swapped because they are stored in network
* byte order */
mp->udp_encap.table_id =
htonl (fib_table_get_table_id (ue->ue_fib_index, ue->ue_ip_proto));
- mp->udp_encap.id = htonl (ue->ue_id);
+ mp->udp_encap.id = htonl (ue - udp_encap_pool);
vl_api_send_msg (reg, (u8 *) mp);
}
{
vl_api_udp_encap_add_reply_t *rmp;
ip46_address_t src_ip, dst_ip;
- u32 fib_index, table_id, ue_id;
+ u32 fib_index, table_id;
fib_protocol_t fproto;
ip46_type_t itype;
+ index_t uei;
int rv = 0;
- ue_id = ntohl (mp->udp_encap.id);
+ uei = INDEX_INVALID;
table_id = ntohl (mp->udp_encap.table_id);
itype = ip_address_decode (&mp->udp_encap.src_ip, &src_ip);
goto done;
}
- udp_encap_add_and_lock (ue_id, fproto, fib_index,
- &src_ip, &dst_ip,
- ntohs (mp->udp_encap.src_port),
- ntohs (mp->udp_encap.dst_port),
- UDP_ENCAP_FIXUP_NONE);
+ uei = udp_encap_add_and_lock (fproto, fib_index,
+ &src_ip, &dst_ip,
+ ntohs (mp->udp_encap.src_port),
+ ntohs (mp->udp_encap.dst_port),
+ UDP_ENCAP_FIXUP_NONE);
done:
- REPLY_MACRO (VL_API_UDP_ENCAP_ADD_REPLY);
+ /* *INDENT-OFF* */
+ REPLY_MACRO2 (VL_API_UDP_ENCAP_ADD_REPLY,
+ ({
+ rmp->id = ntohl (uei);
+ }));
+ /* *INDENT-ON* */
+
}
static void
static clib_error_t *
udp_api_hookup (vlib_main_t * vm)
{
- api_main_t *am = &api_main;
+ api_main_t *am = vlibapi_get_main ();
#define _(N,n) \
vl_msg_api_set_handlers(VL_API_##N, #n, \