aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extras/vom/vom/lldp_binding_cmds.cpp10
-rw-r--r--extras/vom/vom/lldp_global_cmds.cpp8
-rw-r--r--src/vat/api_format.c4
-rw-r--r--src/vnet/lldp/lldp.api19
-rw-r--r--src/vnet/lldp/lldp_api.c40
-rw-r--r--src/vpp/api/custom_dump.c2
6 files changed, 45 insertions, 38 deletions
diff --git a/extras/vom/vom/lldp_binding_cmds.cpp b/extras/vom/vom/lldp_binding_cmds.cpp
index 8c27579a643..02ed8cd450a 100644
--- a/extras/vom/vom/lldp_binding_cmds.cpp
+++ b/extras/vom/vom/lldp_binding_cmds.cpp
@@ -26,8 +26,7 @@ bind_cmd::bind_cmd(HW::item<bool>& item,
: rpc_cmd(item)
, m_itf(itf)
, m_port_desc(port_desc)
-{
-}
+{}
bool
bind_cmd::operator==(const bind_cmd& other) const
@@ -44,8 +43,8 @@ bind_cmd::issue(connection& con)
payload.sw_if_index = m_itf.value();
payload.enable = 1;
- memcpy(payload.port_desc, m_port_desc.c_str(),
- std::min(sizeof(payload.port_desc), m_port_desc.length()));
+ memcpy(payload.port_desc.buf, m_port_desc.c_str(), m_port_desc.length());
+ payload.port_desc.length = m_port_desc.length();
VAPI_CALL(req.execute());
@@ -65,8 +64,7 @@ bind_cmd::to_string() const
unbind_cmd::unbind_cmd(HW::item<bool>& item, const handle_t& itf)
: rpc_cmd(item)
, m_itf(itf)
-{
-}
+{}
bool
unbind_cmd::operator==(const unbind_cmd& other) const
diff --git a/extras/vom/vom/lldp_global_cmds.cpp b/extras/vom/vom/lldp_global_cmds.cpp
index 7ea9b7895ea..32931a621f0 100644
--- a/extras/vom/vom/lldp_global_cmds.cpp
+++ b/extras/vom/vom/lldp_global_cmds.cpp
@@ -25,8 +25,7 @@ config_cmd::config_cmd(HW::item<bool>& item,
, m_system_name(system_name)
, m_tx_hold(tx_hold)
, m_tx_interval(tx_interval)
-{
-}
+{}
bool
config_cmd::operator==(const config_cmd& other) const
@@ -43,8 +42,9 @@ config_cmd::issue(connection& con)
payload.tx_hold = m_tx_hold;
payload.tx_interval = m_tx_interval;
- memcpy(payload.system_name, m_system_name.c_str(),
- std::min(sizeof(payload.system_name), m_system_name.length()));
+ memcpy(
+ payload.system_name.buf, m_system_name.c_str(), m_system_name.length());
+ payload.system_name.length = m_system_name.length();
VAPI_CALL(req.execute());
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 404f9045ea1..2cb459b3868 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -19516,7 +19516,7 @@ api_lldp_config (vat_main_t * vam)
M (LLDP_CONFIG, mp);
mp->tx_hold = htonl (tx_hold);
mp->tx_interval = htonl (tx_interval);
- clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
+ vl_api_vec_to_api_string (sys_name, &mp->system_name);
vec_free (sys_name);
S (mp);
@@ -19572,7 +19572,7 @@ api_sw_interface_set_lldp (vat_main_t * vam)
M (SW_INTERFACE_SET_LLDP, mp);
mp->sw_if_index = ntohl (sw_if_index);
mp->enable = enable;
- clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
+ vl_api_vec_to_api_string (port_desc, &mp->port_desc);
clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
diff --git a/src/vnet/lldp/lldp.api b/src/vnet/lldp/lldp.api
index 2ad80d8108c..6be060b0dd1 100644
--- a/src/vnet/lldp/lldp.api
+++ b/src/vnet/lldp/lldp.api
@@ -13,7 +13,10 @@
* limitations under the License.
*/
-option version = "1.0.0";
+option version = "2.0.0";
+
+import "vnet/interface_types.api";
+import "vnet/ip/ip_types.api";
/** \brief configure global parameter for LLDP
@param client_index - opaque cookie to identify the sender
@@ -27,29 +30,29 @@ autoreply define lldp_config
{
u32 client_index;
u32 context;
- u8 system_name[256];
u32 tx_hold;
u32 tx_interval;
+ string system_name[];
};
/** \brief Interface set LLDP request
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param sw_if_index - interface for which to enable/disable LLDP
- @param port_desc - local port description
@param mgmt_ip4_addr - management ip4 address of the interface
@param mgmt_ip6_addr - management ip6 address of the interface
@param mgmt_oid - OID(Object Identifier) of the interface
@param enable - if non-zero enable, else disable
+ @param port_desc - local port description
*/
autoreply define sw_interface_set_lldp
{
u32 client_index;
u32 context;
- u32 sw_if_index;
- u8 port_desc[256];
- u8 mgmt_ip4[4];
- u8 mgmt_ip6[16];
+ vl_api_interface_index_t sw_if_index;
+ vl_api_ip4_address_t mgmt_ip4;
+ vl_api_ip6_address_t mgmt_ip6;
u8 mgmt_oid[128];
- u8 enable;
+ bool enable [default=true];
+ string port_desc[];
};
diff --git a/src/vnet/lldp/lldp_api.c b/src/vnet/lldp/lldp_api.c
index b28d1b10869..615f03b2050 100644
--- a/src/vnet/lldp/lldp_api.c
+++ b/src/vnet/lldp/lldp_api.c
@@ -24,6 +24,10 @@
#include <vnet/api_errno.h>
#include <vnet/lldp/lldp.h>
+#include <vnet/ip/ip4_packet.h>
+#include <vnet/ip/ip6_packet.h>
+#include <vnet/ip/ip_types_api.h>
+
#include <vnet/vnet_msg_enum.h>
#define vl_typedefs /* define message structures */
@@ -53,8 +57,7 @@ vl_api_lldp_config_t_handler (vl_api_lldp_config_t * mp)
int rv = 0;
u8 *sys_name = 0;
- vec_validate (sys_name, strlen ((char *) mp->system_name) - 1);
- strncpy ((char *) sys_name, (char *) mp->system_name, vec_len (sys_name));
+ sys_name = vl_api_from_api_to_new_vec (&mp->system_name);
if (lldp_cfg_set (&sys_name, ntohl (mp->tx_hold), ntohl (mp->tx_interval))
!= lldp_ok)
@@ -71,28 +74,31 @@ vl_api_sw_interface_set_lldp_t_handler (vl_api_sw_interface_set_lldp_t * mp)
{
vl_api_sw_interface_set_lldp_reply_t *rmp;
int rv = 0;
- u8 *port_desc = 0, *mgmt_ip4 = 0, *mgmt_ip6 = 0, *mgmt_oid = 0;
- u8 no_data[256];
-
- clib_memset (no_data, 0, 256);
+ u8 *mgmt_oid = 0, *mgmt_ip4 = 0, *mgmt_ip6 = 0;
+ char *port_desc = 0;
+ u8 no_data[128];
+ ip4_address_t ip4;
+ ip6_address_t ip6;
- if (memcmp (mp->port_desc, no_data, strlen ((char *) mp->port_desc)) != 0)
+ if (vl_api_string_len (&mp->port_desc) > 0)
{
- vec_validate (port_desc, strlen ((char *) mp->port_desc) - 1);
- strncpy ((char *) port_desc, (char *) mp->port_desc,
- vec_len (port_desc));
+ port_desc = vl_api_from_api_to_new_c_string (&mp->port_desc);
}
- if (memcmp (mp->mgmt_ip4, no_data, sizeof (mp->mgmt_ip4)) != 0)
+ ip4_address_decode (mp->mgmt_ip4, &ip4);
+
+ if (ip4.as_u32 != 0)
{
- vec_validate (mgmt_ip4, sizeof (mp->mgmt_ip4) - 1);
- clib_memcpy (mgmt_ip4, mp->mgmt_ip4, vec_len (mgmt_ip4));
+ vec_validate (mgmt_ip4, sizeof (ip4_address_t) - 1);
+ clib_memcpy (mgmt_ip4, &ip4, vec_len (mgmt_ip4));
}
- if (memcmp (mp->mgmt_ip6, no_data, sizeof (mp->mgmt_ip6)) != 0)
+ ip6_address_decode (mp->mgmt_ip6, &ip6);
+
+ if (!ip6_address_is_zero (&ip6))
{
- vec_validate (mgmt_ip6, sizeof (mp->mgmt_ip6) - 1);
- clib_memcpy (mgmt_ip6, mp->mgmt_ip6, vec_len (mgmt_ip6));
+ vec_validate (mgmt_ip6, sizeof (ip6_address_t) - 1);
+ clib_memcpy (mgmt_ip6, &ip6, vec_len (mgmt_ip6));
}
if (memcmp (mp->mgmt_oid, no_data, strlen ((char *) mp->mgmt_oid)) != 0)
@@ -103,7 +109,7 @@ vl_api_sw_interface_set_lldp_t_handler (vl_api_sw_interface_set_lldp_t * mp)
VALIDATE_SW_IF_INDEX (mp);
- if (lldp_cfg_intf_set (ntohl (mp->sw_if_index), &port_desc,
+ if (lldp_cfg_intf_set (ntohl (mp->sw_if_index), (u8 **) & port_desc,
&mgmt_ip4, &mgmt_ip6, &mgmt_oid,
mp->enable) != lldp_ok)
{
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index 91561048d8f..666daac7f1a 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -3397,7 +3397,7 @@ static void *vl_api_sw_interface_set_lldp_t_print
s = format (0, "SCRIPT: sw_interface_set_lldp ");
s = format (s, "sw_if_index %d ", (mp->sw_if_index));
- if (memcmp (mp->port_desc, null_data, sizeof (mp->port_desc)))
+ if (memcmp (&mp->port_desc, null_data, sizeof (mp->port_desc)))
s = format (s, "port_desc %s ", mp->port_desc);
if (memcmp (mp->mgmt_ip4, null_data, sizeof (mp->mgmt_ip4)))