mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-11-01 18:04:12 +08:00
lldp: advertise system capabilities and the management address
Neighbours could not tell a bridge from a host and had no address to reach us on. Add the System Capabilities TLV (bridge, enabled) and a Management Address TLV with the IPv4 address, left out while the address is still 0.0.0.0. Size the payload buffer for the frame it can now hold: 64 bytes did not cover a 23 character hostname next to the longer model names.
This commit is contained in:
1 parent
677536dd74
commit
0e2d940765
2 files changed
+37
-1
No files matched your search
+25
-1
@@ -42,7 +42,7 @@ struct lldp_pkt {
|
|||||||
struct rtl_tag rtl_tag;
|
struct rtl_tag rtl_tag;
|
||||||
uint16_t ether_type;
|
uint16_t ether_type;
|
||||||
|
|
||||||
uint8_t payload[64];
|
uint8_t payload[LLDP_MAX_PAYLOAD];
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LLDP_O ((__xdata struct lldp_pkt *)&uip_buf[RTL_FRAME_DESC_SIZE])
|
#define LLDP_O ((__xdata struct lldp_pkt *)&uip_buf[RTL_FRAME_DESC_SIZE])
|
||||||
@@ -90,6 +90,30 @@ void lldp_send(void) __banked __reentrant
|
|||||||
p += lldp_sysname(p);
|
p += lldp_sysname(p);
|
||||||
p += lldp_sysdesc(p);
|
p += lldp_sysdesc(p);
|
||||||
|
|
||||||
|
//System Capabilities: supported, enabled
|
||||||
|
*p++ = LLDP_TYPE(LLDP_CAPABILITIES_TLV_TYPE);
|
||||||
|
*p++ = LLDP_CAPABILITIES_TLV_LENGTH;
|
||||||
|
*p++ = LLDP_CAPABILITY_BRIDGE >> 8;
|
||||||
|
*p++ = LLDP_CAPABILITY_BRIDGE & 0xff;
|
||||||
|
*p++ = LLDP_CAPABILITY_BRIDGE >> 8;
|
||||||
|
*p++ = LLDP_CAPABILITY_BRIDGE & 0xff;
|
||||||
|
|
||||||
|
//Management Address: IPv4
|
||||||
|
if (uip_hostaddr[0] | uip_hostaddr[1]) {
|
||||||
|
*p++ = LLDP_TYPE(LLDP_MGMT_ADDR_TLV_TYPE);
|
||||||
|
*p++ = LLDP_MGMT_ADDR_TLV_LENGTH;
|
||||||
|
*p++ = LLDP_MGMT_ADDR_STR_LENGTH;
|
||||||
|
*p++ = LLDP_MGMT_ADDR_SUBTYPE_IPV4;
|
||||||
|
memcpy(p, (__xdata uint8_t *)uip_hostaddr, sizeof(uip_ipaddr_t));
|
||||||
|
p += sizeof(uip_ipaddr_t);
|
||||||
|
*p++ = LLDP_MGMT_IF_NUMBERING_UNKNOWN;
|
||||||
|
*p++ = 0; //interface number
|
||||||
|
*p++ = 0;
|
||||||
|
*p++ = 0;
|
||||||
|
*p++ = 0;
|
||||||
|
*p++ = 0; //OID length
|
||||||
|
}
|
||||||
|
|
||||||
// End of LLDPDU TLV
|
// End of LLDPDU TLV
|
||||||
*p++ = 0x00; //padding
|
*p++ = 0x00; //padding
|
||||||
*p++ = 0x00; //padding
|
*p++ = 0x00; //padding
|
||||||
|
|||||||
@@ -27,6 +27,18 @@
|
|||||||
#define LLDP_SYSNAME_TLV_TYPE 5
|
#define LLDP_SYSNAME_TLV_TYPE 5
|
||||||
#define LLDP_SYSDESC_TLV_TYPE 6
|
#define LLDP_SYSDESC_TLV_TYPE 6
|
||||||
|
|
||||||
|
#define LLDP_CAPABILITIES_TLV_TYPE 7
|
||||||
|
#define LLDP_CAPABILITIES_TLV_LENGTH 4
|
||||||
|
#define LLDP_CAPABILITY_BRIDGE 0x0004
|
||||||
|
|
||||||
|
#define LLDP_MGMT_ADDR_TLV_TYPE 8
|
||||||
|
#define LLDP_MGMT_ADDR_TLV_LENGTH 12
|
||||||
|
#define LLDP_MGMT_ADDR_STR_LENGTH 5
|
||||||
|
#define LLDP_MGMT_ADDR_SUBTYPE_IPV4 1
|
||||||
|
#define LLDP_MGMT_IF_NUMBERING_UNKNOWN 1
|
||||||
|
|
||||||
|
#define LLDP_MAX_PAYLOAD 128
|
||||||
|
|
||||||
void lldp_init(void) __banked;
|
void lldp_init(void) __banked;
|
||||||
void lldp_tick(void) __banked;
|
void lldp_tick(void) __banked;
|
||||||
void lldp_send(void) __banked;
|
void lldp_send(void) __banked;
|
||||||
|
|||||||
Reference in new issue
Block a user