diff --git a/cmd_parser.c b/cmd_parser.c index 8c21d9f8..9c52e1f9 100644 --- a/cmd_parser.c +++ b/cmd_parser.c @@ -881,6 +881,7 @@ void parse_port(void) cmd_error("\nUsage:" \ "\nport [show|on|off]" \ "\nport [10m|100m|1g|2g5|duplex] [half|full]" \ + "\nport lldp [block|permit]" \ "\nport name [custom port name]\n"); return; } @@ -966,6 +967,14 @@ void parse_port(void) else phy_settings.duplex = PHY_DUPLEX_HALF; phy_set_duplex(); + } else if (cmd_compare(2, "lldp")) { + if (cmd_compare(3, "block")){ + lldp_port_status &= ~(1 << phy_settings.port); + } else if (cmd_compare(3, "permit")) { + lldp_port_status |= 1 << phy_settings.port; + } else { + print_string ("Unknown port lldp [block|permit] command\n"); + } } else { cmd_error("Unknown port command\n"); } diff --git a/rtl837x_common.h b/rtl837x_common.h index 9b601730..8fa68477 100644 --- a/rtl837x_common.h +++ b/rtl837x_common.h @@ -131,6 +131,7 @@ struct flash_region_t { }; extern __xdata char port_names[9][PORT_NAME_SIZE]; +extern __xdata uint16_t lldp_port_status; extern __xdata bool stp_enabled; diff --git a/rtl837x_lldp.c b/rtl837x_lldp.c index e426fdef..57f27150 100644 --- a/rtl837x_lldp.c +++ b/rtl837x_lldp.c @@ -14,6 +14,7 @@ extern __xdata bool lldp_enabled; extern __code const struct machine machine; __xdata uint8_t lldp_seconds; +__xdata uint16_t lldp_port_status = 0xffff; void lldp_init(void) __banked { @@ -109,10 +110,12 @@ void lldp_send(void) __banked __reentrant for (uint8_t port = machine.min_port; port <= machine.max_port; port++) { - LLDP_O->payload[port_position] = '0' + machine.log_to_phys_port[port]; - LLDP_O->rtl_tag.pmask = HTONS((uint16_t)1 << port); + if ((1 << machine.log_to_phys_port[port]) & lldp_port_status) { + LLDP_O->payload[port_position] = '0' + machine.log_to_phys_port[port]; + LLDP_O->rtl_tag.pmask = HTONS((uint16_t)1 << port); - tcpip_output(); + tcpip_output(); + } } }