mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-11-01 18:04:12 +08:00
lldp: announce shutdown with a TTL of 0
lldp off and port <n> lldp block went silent and left the neighbour holding our entry until its TTL ran out, 120 s later. Send one LLDPDU with a TTL of 0 on the ports that stop, the shutdown form 802.1AB defines for this, before the transmit mask changes.
This commit is contained in:
1 parent
0e2d940765
commit
12b85025e3
3 files changed
+19
-4
No files matched your search
@@ -920,6 +920,8 @@ void parse_port(void)
|
||||
print_string("\"\n");
|
||||
} else if (cmd_compare(2, "lldp")) {
|
||||
if (cmd_compare(3, "block")){
|
||||
if (lldp_enabled)
|
||||
lldp_shutdown((uint16_t)1 << phy_settings.port);
|
||||
lldp_logical_port_status &= ~((uint16_t)1 << phy_settings.port);
|
||||
} else if (cmd_compare(3, "permit")) {
|
||||
lldp_logical_port_status |= (uint16_t)1 << phy_settings.port;
|
||||
@@ -2046,6 +2048,8 @@ void cmd_parser(void) __banked
|
||||
lldp_enabled = 1;
|
||||
} else {
|
||||
print_string("LLDP disabled\n");
|
||||
if (lldp_enabled)
|
||||
lldp_shutdown(lldp_logical_port_status);
|
||||
lldp_enabled = 0;
|
||||
}
|
||||
}
|
||||
|
||||
+14
-4
@@ -54,7 +54,7 @@ struct lldp_pkt {
|
||||
// the length at any point
|
||||
#define LLDP_TYPE(value) (value << 1)
|
||||
|
||||
void lldp_send(void) __banked __reentrant
|
||||
static void lldp_send_ports(uint16_t ttl, uint16_t ports) __reentrant
|
||||
{
|
||||
__xdata uint8_t *p;
|
||||
uint8_t port_position;
|
||||
@@ -84,8 +84,8 @@ void lldp_send(void) __banked __reentrant
|
||||
//TTL
|
||||
*p++ = LLDP_TYPE(LLDP_TTL_TLV_TYPE);
|
||||
*p++ = LLDP_TTL_TLV_LENGTH;
|
||||
*p++ = 0x00; //padding
|
||||
*p++ = LLDP_TTL_TTL_SECONDS;
|
||||
*p++ = ttl >> 8;
|
||||
*p++ = ttl & 0xff;
|
||||
|
||||
p += lldp_sysname(p);
|
||||
p += lldp_sysdesc(p);
|
||||
@@ -136,7 +136,7 @@ void lldp_send(void) __banked __reentrant
|
||||
|
||||
for (uint8_t port = machine.min_port; port <= machine.max_port; port++) {
|
||||
|
||||
if ((1 << port) & lldp_logical_port_status) {
|
||||
if ((1 << port) & ports) {
|
||||
LLDP_O->payload[port_position] = '0' + machine.log_to_phys_port[port];
|
||||
LLDP_O->rtl_tag.pmask = HTONS((uint16_t)1 << port);
|
||||
|
||||
@@ -145,6 +145,16 @@ void lldp_send(void) __banked __reentrant
|
||||
}
|
||||
}
|
||||
|
||||
void lldp_send(void) __banked __reentrant
|
||||
{
|
||||
lldp_send_ports(LLDP_TTL_TTL_SECONDS, lldp_logical_port_status);
|
||||
}
|
||||
|
||||
void lldp_shutdown(uint16_t ports) __banked __reentrant
|
||||
{
|
||||
lldp_send_ports(0, ports);
|
||||
}
|
||||
|
||||
void lldp_set_addresses(void) __banked {
|
||||
// LLDP destination multicast addr: 01:80:c2:00:00:0e
|
||||
memcpyc(LLDP_O->dst.addr, "\x01\x80\xc2\x00\x00\x0e", MAC_ADDR_LEN);
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
void lldp_init(void) __banked;
|
||||
void lldp_tick(void) __banked;
|
||||
void lldp_send(void) __banked;
|
||||
void lldp_shutdown(uint16_t ports) __banked;
|
||||
void lldp_set_addresses(void) __banked;
|
||||
void lldp_set_rtl_wrapper(void) __banked;
|
||||
uint8_t lldp_sysname(__xdata uint8_t *p) __banked;
|
||||
|
||||
Reference in new issue
Block a user