drivers: slip: Add LLDP support
Enable LLDP TX support on the slip ethernet driver. Now when CONFIG_NET_LLDP is enabled, one can easily verify on a sniffer (i.e. wireshark) that LLDP frames are being sent at the configured interval with all mandatory TLVs enabled. Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
This commit is contained in:
parent
598276262c
commit
34ff437b53
@ -22,10 +22,12 @@
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <misc/util.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <net/buf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_if.h>
|
||||
#include <net/net_core.h>
|
||||
#include <net/lldp.h>
|
||||
#include <console/uart_pipe.h>
|
||||
#include <net/ethernet.h>
|
||||
|
||||
@ -63,6 +65,35 @@ struct slip_context {
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(CONFIG_NET_LLDP)
|
||||
static const struct net_lldpdu lldpdu = {
|
||||
.chassis_id = {
|
||||
.type_length = htons((LLDP_TLV_CHASSIS_ID << 9) |
|
||||
NET_LLDP_CHASSIS_ID_TLV_LEN),
|
||||
.subtype = CONFIG_NET_LLDP_CHASSIS_ID_SUBTYPE,
|
||||
.value = NET_LLDP_CHASSIS_ID_VALUE
|
||||
},
|
||||
.port_id = {
|
||||
.type_length = htons((LLDP_TLV_PORT_ID << 9) |
|
||||
NET_LLDP_PORT_ID_TLV_LEN),
|
||||
.subtype = CONFIG_NET_LLDP_PORT_ID_SUBTYPE,
|
||||
.value = NET_LLDP_PORT_ID_VALUE
|
||||
},
|
||||
.ttl = {
|
||||
.type_length = htons((LLDP_TLV_TTL << 9) |
|
||||
NET_LLDP_TTL_TLV_LEN),
|
||||
.ttl = htons(NET_LLDP_TTL)
|
||||
},
|
||||
#if defined(CONFIG_NET_LLDP_END_LLDPDU_TLV_ENABLED)
|
||||
.end_lldpdu_tlv = NET_LLDP_END_LLDPDU_VALUE
|
||||
#endif /* CONFIG_NET_LLDP_END_LLDPDU_TLV_ENABLED */
|
||||
};
|
||||
|
||||
#define lldpdu_ptr (&lldpdu)
|
||||
#else
|
||||
#define lldpdu_ptr NULL
|
||||
#endif /* CONFIG_NET_LLDP */
|
||||
|
||||
#if SYS_LOG_LEVEL >= SYS_LOG_LEVEL_DEBUG
|
||||
#if defined(CONFIG_SYS_LOG_SHOW_COLOR)
|
||||
#define COLOR_OFF "\x1B[0m"
|
||||
@ -479,11 +510,14 @@ static void slip_iface_init(struct net_if *iface)
|
||||
|
||||
ethernet_init(iface);
|
||||
|
||||
net_eth_set_lldpdu(iface, lldpdu_ptr);
|
||||
|
||||
if (slip->init_done) {
|
||||
return;
|
||||
}
|
||||
|
||||
ll_addr = slip_get_mac(slip);
|
||||
|
||||
slip->init_done = true;
|
||||
slip->iface = iface;
|
||||
|
||||
@ -512,7 +546,11 @@ static enum ethernet_hw_caps eth_capabilities(struct device *dev)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
return ETHERNET_HW_VLAN;
|
||||
return ETHERNET_HW_VLAN
|
||||
#if defined(CONFIG_NET_LLDP)
|
||||
| ETHERNET_LLDP
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_SLIP_TAP) && defined(CONFIG_NET_L2_ETHERNET)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user