aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteve Shin <jonshin@cisco.com>2017-07-01 04:16:20 +0000
committerNeale Ranns <nranns@cisco.com>2017-07-08 12:34:04 +0000
commit262ca683be45ea6278ede2693d8832939b9dce14 (patch)
tree0a4ece9b522eb0f7eccba5ba2d08563eef9cfaa0 /src
parent6922bd37be2c38d1c37b47855bb920c79b891027 (diff)
Add API support for LLDP config/interface set
Add API methods to configure LLDP and set interface to enable/disable. Also add port description TLV for LLDP. Change-Id: Ib959d488c2ab8a0069f143558871f41fcc43a5d3 Signed-off-by: Steve Shin <jonshin@cisco.com> (cherry picked from commit 99a0e60eb6f6acd7eabd5a4cb7ded1e0419ccd54)
Diffstat (limited to 'src')
-rw-r--r--src/vat/api_format.c95
-rw-r--r--src/vnet.am9
-rw-r--r--src/vnet/lldp/lldp.api47
-rw-r--r--src/vnet/lldp/lldp.h32
-rw-r--r--src/vnet/lldp/lldp_api.c144
-rw-r--r--src/vnet/lldp/lldp_cli.c86
-rw-r--r--src/vnet/lldp/lldp_doc.md10
-rw-r--r--src/vnet/lldp/lldp_node.h3
-rw-r--r--src/vnet/lldp/lldp_output.c20
-rw-r--r--src/vnet/vnet_all_api_h.h1
-rw-r--r--src/vpp/api/vpe.api1
11 files changed, 401 insertions, 47 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 937d7c5da08..40eca8c5d57 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -4633,7 +4633,9 @@ _(feature_enable_disable_reply) \
_(sw_interface_tag_add_del_reply) \
_(sw_interface_set_mtu_reply) \
_(p2p_ethernet_add_reply) \
-_(p2p_ethernet_del_reply)
+_(p2p_ethernet_del_reply) \
+_(lldp_config_reply) \
+_(sw_interface_set_lldp_reply)
#define _(n) \
static void vl_api_##n##_t_handler \
@@ -4915,7 +4917,9 @@ _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
_(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
_(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
_(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
-_(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply)
+_(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
+_(LLDP_CONFIG_REPLY, lldp_config_reply) \
+_(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply)
#define foreach_standalone_reply_msg \
_(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
@@ -19233,6 +19237,88 @@ api_p2p_ethernet_del (vat_main_t * vam)
}
static int
+api_lldp_config (vat_main_t * vam)
+{
+ unformat_input_t *i = vam->input;
+ vl_api_lldp_config_t *mp;
+ int tx_hold = 0;
+ int tx_interval = 0;
+ u8 *sys_name = NULL;
+ int ret;
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "system-name %s", &sys_name))
+ ;
+ else if (unformat (i, "tx-hold %d", &tx_hold))
+ ;
+ else if (unformat (i, "tx-interval %d", &tx_interval))
+ ;
+ else
+ {
+ clib_warning ("parse error '%U'", format_unformat_error, i);
+ return -99;
+ }
+ }
+
+ vec_add1 (sys_name, 0);
+
+ 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));
+ vec_free (sys_name);
+
+ S (mp);
+ W (ret);
+ return ret;
+}
+
+static int
+api_sw_interface_set_lldp (vat_main_t * vam)
+{
+ unformat_input_t *i = vam->input;
+ vl_api_sw_interface_set_lldp_t *mp;
+ u32 sw_if_index = ~0;
+ u32 enable = 1;
+ u8 *port_desc = NULL;
+ int ret;
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "disable"))
+ enable = 0;
+ else
+ if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
+ ;
+ else if (unformat (i, "sw_if_index %d", &sw_if_index))
+ ;
+ else if (unformat (i, "port-desc %s", &port_desc))
+ ;
+ else
+ break;
+ }
+
+ if (sw_if_index == ~0)
+ {
+ errmsg ("missing interface name or sw_if_index");
+ return -99;
+ }
+
+ /* Construct the API message */
+ vec_add1 (port_desc, 0);
+ 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));
+ vec_free (port_desc);
+
+ S (mp);
+ W (ret);
+ return ret;
+}
+
+static int
q_or_quit (vat_main_t * vam)
{
#if VPP_API_TEST_BUILTIN == 0
@@ -19994,7 +20080,10 @@ _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
_(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
_(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
_(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
-_(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>")
+_(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
+_(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
+_(sw_interface_set_lldp, \
+ "<intfc> | sw_if_index <nn> [port-desc <description>] [disable]")
/* List of command functions, CLI names map directly to functions */
#define foreach_cli_function \
diff --git a/src/vnet.am b/src/vnet.am
index b5ce6d5a560..ebcf0a0a78c 100644
--- a/src/vnet.am
+++ b/src/vnet.am
@@ -269,10 +269,15 @@ libvnet_la_SOURCES += \
vnet/lldp/lldp_input.c \
vnet/lldp/lldp_node.c \
vnet/lldp/lldp_output.c \
- vnet/lldp/lldp_cli.c
+ vnet/lldp/lldp_cli.c \
+ vnet/lldp/lldp_api.c
nobase_include_HEADERS += \
- vnet/lldp/lldp_protocol.h
+ vnet/lldp/lldp_protocol.h \
+ vnet/lldp/lldp.h \
+ vnet/lldp/lldp.api.h
+
+API_FILES += vnet/lldp/lldp.api
########################################
# Layer 2/3 "classify"
diff --git a/src/vnet/lldp/lldp.api b/src/vnet/lldp/lldp.api
new file mode 100644
index 00000000000..02fe32ca742
--- /dev/null
+++ b/src/vnet/lldp/lldp.api
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017 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:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** \brief configure global parameter for LLDP
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param system_name - VPP system name
+ @param tx_hold - multiplier for tx_interval when setting time-to-live (TTL)
+ value in the LLDP packets
+ @param tx_interval - time interval, in seconds, between each LLDP frames
+*/
+autoreply define lldp_config
+{
+ u32 client_index;
+ u32 context;
+ u8 system_name[256];
+ u32 tx_hold;
+ u32 tx_interval;
+};
+
+/** \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 enable - if non-zero enable, else disable
+*/
+autoreply define sw_interface_set_lldp
+{
+ u32 client_index;
+ u32 context;
+ u32 sw_if_index;
+ u8 port_desc[256];
+ u8 enable;
+};
diff --git a/src/vnet/lldp/lldp.h b/src/vnet/lldp/lldp.h
new file mode 100644
index 00000000000..473c2021abe
--- /dev/null
+++ b/src/vnet/lldp/lldp.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2017 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:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file
+ * @brief LLDP external definition
+ */
+#ifndef __included_lldp_h__
+#define __included_lldp_h__
+
+typedef enum lldp_cfg_err
+{
+ lldp_ok,
+ lldp_not_supported,
+ lldp_invalid_arg,
+} lldp_cfg_err_t;
+
+lldp_cfg_err_t lldp_cfg_intf_set (u32 hw_if_index, u8 ** port_desc, int enable);
+lldp_cfg_err_t lldp_cfg_set (u8 ** host, int hold_time, int tx_interval);
+
+#endif /* __included_lldp_h__ */
diff --git a/src/vnet/lldp/lldp_api.c b/src/vnet/lldp/lldp_api.c
new file mode 100644
index 00000000000..bdada8970a4
--- /dev/null
+++ b/src/vnet/lldp/lldp_api.c
@@ -0,0 +1,144 @@
+/*
+ *------------------------------------------------------------------
+ * lldp_api.c - lldp api
+ *
+ * Copyright (c) 2017 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:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *------------------------------------------------------------------
+ */
+
+#include <vnet/vnet.h>
+#include <vlibmemory/api.h>
+
+#include <vnet/interface.h>
+#include <vnet/api_errno.h>
+#include <vnet/lldp/lldp.h>
+
+#include <vnet/vnet_msg_enum.h>
+
+#define vl_typedefs /* define message structures */
+#include <vnet/vnet_all_api_h.h>
+#undef vl_typedefs
+
+#define vl_endianfun /* define message structures */
+#include <vnet/vnet_all_api_h.h>
+#undef vl_endianfun
+
+/* instantiate all the print functions we know about */
+#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
+#define vl_printfun
+#include <vnet/vnet_all_api_h.h>
+#undef vl_printfun
+
+#include <vlibapi/api_helper_macros.h>
+
+#define foreach_vpe_api_msg \
+_(LLDP_CONFIG, lldp_config) \
+_(SW_INTERFACE_SET_LLDP, sw_interface_set_lldp)
+
+static void
+vl_api_lldp_config_t_handler (vl_api_lldp_config_t * mp)
+{
+ vl_api_lldp_config_reply_t *rmp;
+ 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));
+
+ if (lldp_cfg_set (&sys_name, ntohl (mp->tx_hold),
+ ntohl (mp->tx_interval)) != lldp_ok)
+ {
+ vec_free (sys_name);
+ rv = VNET_API_ERROR_INVALID_VALUE;
+ }
+
+ REPLY_MACRO (VL_API_LLDP_CONFIG_REPLY);
+}
+
+static void
+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;
+
+ vec_validate (port_desc, strlen ((char *) mp->port_desc) - 1);
+ strncpy ((char *) port_desc, (char *) mp->port_desc, vec_len (port_desc));
+
+ VALIDATE_SW_IF_INDEX (mp);
+
+ if (lldp_cfg_intf_set (ntohl (mp->sw_if_index), &port_desc,
+ mp->enable) != lldp_ok)
+ {
+ vec_free (port_desc);
+ rv = VNET_API_ERROR_INVALID_VALUE;
+ }
+
+ BAD_SW_IF_INDEX_LABEL;
+
+ REPLY_MACRO (VL_API_SW_INTERFACE_SET_LLDP_REPLY);
+}
+
+
+/*
+ * * lldp_api_hookup
+ * * Add vpe's API message handlers to the table.
+ * * vlib has alread mapped shared memory and
+ * * added the client registration handlers.
+ * * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
+ * */
+#define vl_msg_name_crc_list
+#include <vnet/vnet_all_api_h.h>
+#undef vl_msg_name_crc_list
+
+static void
+setup_message_id_table (api_main_t * am)
+{
+#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
+ foreach_vl_msg_name_crc_lldp;
+#undef _
+}
+
+static clib_error_t *
+lldp_api_hookup (vlib_main_t * vm)
+{
+ api_main_t *am = &api_main;
+
+#define _(N,n) \
+ vl_msg_api_set_handlers(VL_API_##N, #n, \
+ vl_api_##n##_t_handler, \
+ vl_noop_handler, \
+ vl_api_##n##_t_endian, \
+ vl_api_##n##_t_print, \
+ sizeof(vl_api_##n##_t), 1);
+ foreach_vpe_api_msg;
+#undef _
+
+ /*
+ * * Set up the (msg_name, crc, message-id) table
+ * */
+ setup_message_id_table (am);
+
+ return 0;
+}
+
+VLIB_API_INIT_FUNCTION (lldp_api_hookup);
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/vnet/lldp/lldp_cli.c b/src/vnet/lldp/lldp_cli.c
index 45f688c58b4..4a7ca683e1e 100644
--- a/src/vnet/lldp/lldp_cli.c
+++ b/src/vnet/lldp/lldp_cli.c
@@ -19,19 +19,13 @@
*
*/
#include <vnet/lisp-cp/lisp_types.h>
+#include <vnet/lldp/lldp.h>
#include <vnet/lldp/lldp_node.h>
#ifndef ETHER_ADDR_LEN
#include <net/ethernet.h>
#endif
-typedef enum lldp_cfg_err
-{
- lldp_ok,
- lldp_not_supported,
- lldp_invalid_arg,
-} lldp_cfg_err_t;
-
static clib_error_t *
lldp_cfg_err_to_clib_err (lldp_cfg_err_t e)
{
@@ -48,8 +42,8 @@ lldp_cfg_err_to_clib_err (lldp_cfg_err_t e)
return 0;
}
-static lldp_cfg_err_t
-lldp_cfg_intf_set (u32 hw_if_index, int enable)
+lldp_cfg_err_t
+lldp_cfg_intf_set (u32 hw_if_index, u8 ** port_desc, int enable)
{
lldp_main_t *lm = &lldp_main;
vnet_main_t *vnm = lm->vnet_main;
@@ -68,9 +62,16 @@ lldp_cfg_intf_set (u32 hw_if_index, int enable)
if (n)
{
/* already enabled */
- return 0;
+ return lldp_ok;
}
n = lldp_create_intf (lm, hw_if_index);
+
+ if (port_desc && *port_desc)
+ {
+ n->port_desc = *port_desc;
+ *port_desc = NULL;
+ }
+
const vnet_sw_interface_t *sw =
vnet_get_sw_interface (lm->vnet_main, hi->sw_if_index);
if (sw->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)
@@ -84,7 +85,7 @@ lldp_cfg_intf_set (u32 hw_if_index, int enable)
lldp_delete_intf (lm, n);
}
- return 0;
+ return lldp_ok;
}
static clib_error_t *
@@ -93,24 +94,33 @@ lldp_intf_cmd (vlib_main_t * vm, unformat_input_t * input,
{
lldp_main_t *lm = &lldp_main;
vnet_main_t *vnm = lm->vnet_main;
- u32 hw_if_index;
- int enable = 0;
+ u32 sw_if_index = (u32) ~ 0;
+ int enable = 1;
+ u8 *port_desc = NULL;
- if (unformat (input, "%U %U", unformat_vnet_hw_interface, vnm, &hw_if_index,
- unformat_vlib_enable_disable, &enable))
- {
- return
- lldp_cfg_err_to_clib_err (lldp_cfg_intf_set (hw_if_index, enable));
- }
- else
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ if (unformat (input, "sw_if_index %d", &sw_if_index))
+ ;
+ if (unformat
+ (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
+ ;
+ else if (unformat (input, "disable"))
+ enable = 0;
+ else if (unformat (input, "port-desc %s", &port_desc))
+ ;
+ else
+ break;
}
- return 0;
+
+ if (sw_if_index == (u32) ~ 0)
+ return clib_error_return (0, "Interface name is invalid!");
+
+ return lldp_cfg_err_to_clib_err (lldp_cfg_intf_set (sw_if_index,
+ &port_desc, enable));
}
-static lldp_cfg_err_t
+lldp_cfg_err_t
lldp_cfg_set (u8 ** host, int hold_time, int tx_interval)
{
lldp_main_t *lm = &lldp_main;
@@ -210,7 +220,8 @@ out:
/* *INDENT-OFF* */
VLIB_CLI_COMMAND(set_interface_lldp_cmd, static) = {
.path = "set interface lldp",
- .short_help = "set interface lldp <interface> (enable | disable) ",
+ .short_help = "set interface lldp <interface> | sw_if_index <idx>"
+ " [port-desc <string>] [disable]",
.function = lldp_intf_cmd,
};
@@ -501,23 +512,26 @@ format_lldp_intfs_detail (u8 * s, vlib_main_t * vm, const lldp_main_t * lm)
else if (now < n->last_heard + n->ttl)
{
s = format(s,
- "\nInterface name: %s\nInterface/peer state: "
- "active\nPeer chassis ID: %U\nRemote port ID: %U\nLast "
- "packet sent: %U\nLast packet received: %U\n",
- hw->name, format_lldp_chassis_id, n->chassis_id_subtype,
- n->chassis_id, vec_len(n->chassis_id), 1,
+ "\nInterface name: %s\nPort Desc: %s\nInterface/peer "
+ "state: active\nPeer chassis ID: %U\nRemote port ID:"
+ " %U\nLast packet sent: %U\nLast packet received: %U\n",
+ hw->name, n->port_desc, format_lldp_chassis_id,
+ n->chassis_id_subtype, n->chassis_id,
+ vec_len(n->chassis_id), 1,
format_lldp_port_id, n->port_id_subtype, n->port_id,
vec_len(n->port_id), 1, format_time_ago, n->last_sent,
now, format_time_ago, n->last_heard, now);
}
else
{
- s = format(s, "\nInterface name: %s\nInterface/peer state: "
- "inactive(timeout)\nLast known peer chassis ID: "
- "%U\nLast known peer port ID: %U\nLast packet sent: "
- "%U\nLast packet received: %U\n",
- hw->name, format_lldp_chassis_id, n->chassis_id_subtype,
- n->chassis_id, vec_len(n->chassis_id), 1,
+ s = format(s,
+ "\nInterface name: %s\nPort Desc: %s\nInterface/peer "
+ "state: inactive(timeout)\nLast known peer chassis ID:"
+ "%U\nLast known peer port ID: %U\nLast packet sent: "
+ "%U\nLast packet received: %U\n",
+ hw->name, n->port_desc, format_lldp_chassis_id,
+ n->chassis_id_subtype, n->chassis_id,
+ vec_len(n->chassis_id), 1,
format_lldp_port_id, n->port_id_subtype, n->port_id,
vec_len(n->port_id), 1, format_time_ago, n->last_sent,
now, format_time_ago, n->last_heard, now);
diff --git a/src/vnet/lldp/lldp_doc.md b/src/vnet/lldp/lldp_doc.md
index bac480a51d3..717de898c4e 100644
--- a/src/vnet/lldp/lldp_doc.md
+++ b/src/vnet/lldp/lldp_doc.md
@@ -27,10 +27,12 @@ tx-interval: time interval between sending out LLDP packets
Per interface setting is done using the "set interface lldp" command
-set interface lldp <interface> (enable | disable)
+set interface lldp <interface> | if_index <idx> [port-desc <string>] [disable]
interface: the name of the interface for which to enable/disable LLDP
-
+if_index: sw interface index can be used if interface name is not used.
+port-desc: port description
+disable: LLDP feature can be enabled or disabled per interface.
### Configuration example
@@ -38,9 +40,9 @@ Configure system-name as "VPP" and transmit interval to 10 seconds:
set lldp system-name VPP tx-interval 10
-Enable LLDP on interface TenGigabitEthernet5/0/1
+Enable LLDP on interface TenGigabitEthernet5/0/1 with port description
-set interface lldp TenGigabitEthernet5/0/1 enable
+set interface lldp TenGigabitEthernet5/0/1 port-desc vtf:eth0
### Operational data
diff --git a/src/vnet/lldp/lldp_node.h b/src/vnet/lldp/lldp_node.h
index 477ca7dc691..14a10e330de 100644
--- a/src/vnet/lldp/lldp_node.h
+++ b/src/vnet/lldp/lldp_node.h
@@ -43,6 +43,9 @@ typedef struct lldp_intf
lldp_port_id_subtype_t port_id_subtype;
lldp_chassis_id_subtype_t chassis_id_subtype;
+ /* Local info */
+ u8 *port_desc;
+
} lldp_intf_t;
typedef struct
diff --git a/src/vnet/lldp/lldp_output.c b/src/vnet/lldp/lldp_output.c
index 6cb2627098b..950b79aebc6 100644
--- a/src/vnet/lldp/lldp_output.c
+++ b/src/vnet/lldp/lldp_output.c
@@ -75,6 +75,20 @@ lldp_add_ttl (const lldp_main_t * lm, u8 ** t0p, int shutdown)
}
static void
+lldp_add_port_desc (const lldp_main_t * lm, lldp_intf_t * n, u8 ** t0p)
+{
+ const size_t len = vec_len (n->port_desc);
+ if (len)
+ {
+ lldp_tlv_t *t = (lldp_tlv_t *) * t0p;
+ lldp_tlv_set_code (t, LLDP_TLV_NAME (port_desc));
+ lldp_tlv_set_length (t, len);
+ clib_memcpy (t->v, n->port_desc, len);
+ *t0p += STRUCT_SIZE_OF (lldp_tlv_t, head) + len;
+ }
+}
+
+static void
lldp_add_sys_name (const lldp_main_t * lm, u8 ** t0p)
{
const size_t len = vec_len (lm->sys_name);
@@ -99,11 +113,12 @@ lldp_add_pdu_end (u8 ** t0p)
static void
lldp_add_tlvs (lldp_main_t * lm, vnet_hw_interface_t * hw, u8 ** t0p,
- int shutdown)
+ int shutdown, lldp_intf_t * n)
{
lldp_add_chassis_id (hw, t0p);
lldp_add_port_id (hw, t0p);
lldp_add_ttl (lm, t0p, shutdown);
+ lldp_add_port_desc (lm, n, t0p);
lldp_add_sys_name (lm, t0p);
lldp_add_pdu_end (t0p);
}
@@ -139,7 +154,7 @@ lldp_send_ethernet (lldp_main_t * lm, lldp_intf_t * n, int shutdown)
t0 = data;
/* add TLVs */
- lldp_add_tlvs (lm, hw, &t0, shutdown);
+ lldp_add_tlvs (lm, hw, &t0, shutdown, n);
/* Set the outbound packet length */
b0 = vlib_get_buffer (vm, bi0);
@@ -167,6 +182,7 @@ lldp_delete_intf (lldp_main_t * lm, lldp_intf_t * n)
hash_unset (lm->intf_by_hw_if_index, n->hw_if_index);
vec_free (n->chassis_id);
vec_free (n->port_id);
+ vec_free (n->port_desc);
pool_put (lm->intfs, n);
}
}
diff --git a/src/vnet/vnet_all_api_h.h b/src/vnet/vnet_all_api_h.h
index 5da2acb7ef9..c1eff61fdfb 100644
--- a/src/vnet/vnet_all_api_h.h
+++ b/src/vnet/vnet_all_api_h.h
@@ -41,6 +41,7 @@
#include <vnet/ip/ip.api.h>
#include <vnet/unix/tap.api.h>
#include <vnet/vxlan/vxlan.api.h>
+#include <vnet/lldp/lldp.api.h>
#include <vnet/vxlan-gpe/vxlan_gpe.api.h>
#include <vnet/bfd/bfd.api.h>
#include <vnet/ipsec/ipsec.api.h>
diff --git a/src/vpp/api/vpe.api b/src/vpp/api/vpe.api
index d3c7e985e42..2a763d19808 100644
--- a/src/vpp/api/vpe.api
+++ b/src/vpp/api/vpe.api
@@ -26,6 +26,7 @@
* IP APIs: see .../src/vnet/ip/{ip.api, ip_api.c}
* TAP APIs: see .../src/vnet/unix/{tap.api, tap_api.c}
* VXLAN APIs: see .../src/vnet/vxlan/{vxlan.api, vxlan_api.c}
+ * LLDP APIs: see .../src/vnet/lldp/{lldp.api, lldp_api.c}
* AF-PACKET APIs: see ... /vnet/devices/af_packet/{af_packet.api, af_packet_api.c}
* NETMAP APIs: see ... /src/vnet/devices/netmap/{netmap.api, netmap_api.c}
* VHOST-USER APIs: see .../vnet/devices/virtio/{vhost_user.api, vhost_user_api.c}