--- /dev/null
+/*
+ * Copyright (c) 2016 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 <lisp/lisp-cp/control.h>
+
+lisp_cp_main_t lisp_control_main;
+
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
--- /dev/null
+# Copyright (c) 2020 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.
+
+
+add_vpp_plugin(lldp
+ SOURCES
+ lldp_input.c
+ lldp_node.c
+ lldp_output.c
+ lldp_cli.c
+ lldp_api.c
+
+ API_FILES
+ lldp.api
+
+ INSTALL_HEADERS
+ lldp_protocol.h
+ lldp.h
+
+ API_TEST_SOURCES
+ lldp_test.c
+)
#include <vnet/interface.h>
#include <vnet/api_errno.h>
-#include <vnet/lldp/lldp.h>
+#include <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 message IDs */
+#include <vnet/format_fns.h>
+#include <lldp/lldp.api_enum.h>
+#include <lldp/lldp.api_types.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
+/**
+ * Base message ID fot the plugin
+ */
+static u32 lldp_base_msg_id;
+#define REPLY_MSG_ID_BASE lldp_base_msg_id
#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)
{
* * 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 _
-}
+#include <lldp/lldp.api.c>
static clib_error_t *
lldp_api_hookup (vlib_main_t * vm)
{
- api_main_t *am = vlibapi_get_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);
+ * Set up the (msg_name, crc, message-id) table
+ */
+ lldp_base_msg_id = setup_message_id_table ();
return 0;
}
VLIB_API_INIT_FUNCTION (lldp_api_hookup);
+#include <vlib/unix/plugin.h>
+#include <vpp/app/version.h>
+
+/* *INDENT-OFF* */
+VLIB_PLUGIN_REGISTER () = {
+ .version = VPP_BUILD_VER,
+ .description = "Link Layer Discovery Protocol (LLDP)",
+};
+/* *INDENT-ON* */
+
+
/*
* fd.io coding-style-patch-verification: ON
*
*
*/
#include <vnet/ethernet/ethernet.h>
-#include <vnet/lisp-cp/lisp_types.h>
-#include <vnet/lldp/lldp.h>
-#include <vnet/lldp/lldp_node.h>
+#include <vnet/ip/ip.h>
+#include <lldp/lldp.h>
+#include <lldp/lldp_node.h>
#ifndef ETHER_ADDR_LEN
#include <net/ethernet.h>
* @file
* @brief LLDP packet parsing implementation
*/
-#include <vnet/lldp/lldp_node.h>
-#include <vnet/lldp/lldp_protocol.h>
+#include <lldp/lldp_node.h>
+#include <lldp/lldp_protocol.h>
#include <vlibmemory/api.h>
typedef struct
* @file
* @brief LLDP nodes implementation
*/
-#include <vnet/lldp/lldp_node.h>
+#include <lldp/lldp_node.h>
#include <vnet/ethernet/ethernet.h>
#include <vnet/ethernet/packet.h>
#include <vppinfra/format.h>
#include <vppinfra/hash.h>
-#include <vnet/lldp/lldp_protocol.h>
+#include <lldp/lldp_protocol.h>
typedef struct lldp_intf
{
* @file
* @brief LLDP packet generation implementation
*/
-#include <vnet/lldp/lldp_node.h>
+#include <lldp/lldp_node.h>
static void
lldp_build_mgmt_addr_tlv (u8 ** t0p, u8 subtype, u8 addr_len, u8 * addr,
--- /dev/null
+/*
+ * Copyright (c) 2015 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 <vat/vat.h>
+#include <vlibapi/api.h>
+#include <vlibmemory/api.h>
+#include <vppinfra/error.h>
+
+#include <vnet/ip/ip.h>
+#include <vnet/ip/ip_format_fns.h>
+#include <vnet/ethernet/ethernet_format_fns.h>
+
+/* define message IDs */
+#include <lldp/lldp.api_enum.h>
+#include <lldp/lldp.api_types.h>
+
+typedef struct
+{
+ /* API message ID base */
+ u16 msg_id_base;
+ vat_main_t *vat_main;
+} lldp_test_main_t;
+
+lldp_test_main_t lldp_test_main;
+
+#define __plugin_msg_base lldp_test_main.msg_id_base
+#include <vlibapi/vat_helper_macros.h>
+
+/* Macro to finish up custom dump fns */
+#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
+#define FINISH \
+ vec_add1 (s, 0); \
+ vl_print (handle, (char *)s); \
+ vec_free (s); \
+ return handle;
+
+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);
+ vl_api_vec_to_api_string (sys_name, &mp->system_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, *mgmt_oid = NULL;
+ ip4_address_t ip4_addr;
+ ip6_address_t ip6_addr;
+ int ret;
+
+ clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
+ clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "disable"))
+ enable = 0;
+ else
+ if (unformat (i, "%U", 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 if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
+ ;
+ else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
+ ;
+ else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
+ ;
+ 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);
+ vec_add1 (mgmt_oid, 0);
+ M (SW_INTERFACE_SET_LLDP, mp);
+ mp->sw_if_index = ntohl (sw_if_index);
+ mp->enable = enable;
+ 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));
+ vec_free (port_desc);
+ vec_free (mgmt_oid);
+
+ S (mp);
+ W (ret);
+ return ret;
+}
+
+#include <lldp/lldp.api_test.c>
_(hw_interface_set_mtu_reply) \
_(p2p_ethernet_add_reply) \
_(p2p_ethernet_del_reply) \
-_(lldp_config_reply) \
-_(sw_interface_set_lldp_reply) \
_(tcp_configure_src_addresses_reply) \
_(session_rule_add_del_reply) \
_(ip_container_proxy_add_del_reply) \
_(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) \
-_(LLDP_CONFIG_REPLY, lldp_config_reply) \
-_(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
_(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
_(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
_(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
return ret;
}
-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);
- vl_api_vec_to_api_string (sys_name, &mp->system_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, *mgmt_oid = NULL;
- ip4_address_t ip4_addr;
- ip6_address_t ip6_addr;
- int ret;
-
- clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
- clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
-
- 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 if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
- ;
- else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
- ;
- else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
- ;
- 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);
- vec_add1 (mgmt_oid, 0);
- M (SW_INTERFACE_SET_LLDP, mp);
- mp->sw_if_index = ntohl (sw_if_index);
- mp->enable = enable;
- 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));
- vec_free (port_desc);
- vec_free (mgmt_oid);
-
- S (mp);
- W (ret);
- return ret;
-}
-
static int
api_tcp_configure_src_addresses (vat_main_t * vam)
{
_(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
_(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
_(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>]\n" \
- " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
_(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
_(sock_init_shm, "size <nnn>") \
_(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
list(APPEND VNET_MULTIARCH_SOURCES bonding/node.c bonding/device.c)
list(APPEND VNET_API_FILES bonding/bond.api)
-##############################################################################
-# Layer 2 / LLDP
-##############################################################################
-list(APPEND VNET_SOURCES
- lldp/lldp_input.c
- lldp/lldp_node.c
- lldp/lldp_output.c
- lldp/lldp_cli.c
- lldp/lldp_api.c
-)
-
-list(APPEND VNET_HEADERS
- lldp/lldp_protocol.h
- lldp/lldp.h
-)
-
-list(APPEND VNET_API_FILES lldp/lldp.api)
-
##############################################################################
# Layer 2/3 "classify"
##############################################################################
#include <vnet/span/span.api.h>
#include <vnet/ip/ip.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>
FINISH;
}
-static void *vl_api_sw_interface_set_lldp_t_print
- (vl_api_sw_interface_set_lldp_t * mp, void *handle)
-{
- u8 *s;
- u8 null_data[256];
-
- clib_memset (null_data, 0, sizeof (null_data));
-
- 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)))
- s = format (s, "port_desc %s ", mp->port_desc);
-
- if (memcmp (mp->mgmt_ip4, null_data, sizeof (mp->mgmt_ip4)))
- s = format (s, "mgmt_ip4 %U ", format_ip4_address, mp->mgmt_ip4);
-
- if (memcmp (mp->mgmt_ip6, null_data, sizeof (mp->mgmt_ip6)))
- s = format (s, "mgmt_ip6 %U ", format_ip6_address, mp->mgmt_ip6);
-
- if (memcmp (mp->mgmt_oid, null_data, sizeof (mp->mgmt_oid)))
- s = format (s, "mgmt_oid %s ", mp->mgmt_oid);
-
- if (mp->enable == 0)
- s = format (s, "disable ");
-
- FINISH;
-}
-
-static void *vl_api_lldp_config_t_print
- (vl_api_lldp_config_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: lldp_config ");
- s = format (s, "system_name %s ", mp->system_name);
- s = format (s, "tx_hold %d ", (mp->tx_hold));
- s = format (s, "tx_interval %d ", (mp->tx_interval));
- FINISH;
-}
-
static void *vl_api_session_rule_add_del_t_print
(vl_api_session_rule_add_del_t * mp, void *handle)
{
_(P2P_ETHERNET_DEL, p2p_ethernet_del) \
_(TCP_CONFIGURE_SRC_ADDRESSES, tcp_configure_src_addresses) \
_(APP_NAMESPACE_ADD_DEL, app_namespace_add_del) \
-_(LLDP_CONFIG, lldp_config) \
-_(SW_INTERFACE_SET_LLDP, sw_interface_set_lldp) \
_(SESSION_RULE_ADD_DEL, session_rule_add_del) \
_(OUTPUT_ACL_SET_INTERFACE, output_acl_set_interface) \
_(QOS_RECORD_ENABLE_DISABLE, qos_record_enable_disable) \