The tick rate has been changed now so we'll have to approximate

timing with ticks

Fixing up the log_to_phys_port assignment

2000 is about every 10 seconds, so scaling up to once every 30ish

Removing the attempt to block lldp frames,
This does not work however the hard work has been done for us in
the #514 so we can borrow that work later on
This commit is contained in:
Rob Emery committed 2026-10-10 09:50:38 +01:00
1 parent 2dfe531fe0
commit 9b2bd7f1b8
8 files changed
+16 -22

No files matched your search

+2 -2
View File
@@ -969,9 +969,9 @@ void parse_port(void)
phy_set_duplex();
} else if (cmd_compare(2, "lldp")) {
if (cmd_compare(3, "block")){
lldp_physical_port_status &= ~(1 << phy_settings.port);
lldp_logical_port_status &= ~(1 << phy_settings.port);
} else if (cmd_compare(3, "permit")) {
lldp_physical_port_status |= 1 << phy_settings.port;
lldp_logical_port_status |= 1 << phy_settings.port;
} else {
print_string ("Unknown port <port> lldp [block|permit] command\n");
}
+1 -3
View File
@@ -1872,10 +1872,8 @@ $("lldp_en").addEventListener("change",function(){
var el=this;
postCmd("lldp "+(el.checked?"on":"off")).catch(function(){el.checked=!el.checked});
});
tabHooks.lldp={enter:needPorts(lldpLoad)};
function eeeFlags(bits){
var b=parseInt(bits,2);
return["100M","1G","2.5G"].map(function(s,i){
@@ -2036,7 +2034,7 @@ function sysLoad(){
cfgReload();
}
function cfgParseKnown(txt){
var igmp=false,lldp=false,syslog=false;
var igmp=false,syslog=false;
txt.split(/\r?\n/).forEach(function(l){
l=l.trim();
if(/^igmp on$/.test(l))igmp=true;
+2 -2
View File
@@ -49,7 +49,7 @@ extern __xdata char sfp_module_model[2][17];
extern __xdata char sfp_module_serial[2][17];
extern __xdata uint8_t sfp_options[2];
extern __xdata uint16_t lldp_physical_port_status;
extern __xdata uint16_t lldp_logical_port_status;
extern __xdata bool lldp_enabled;
__code const uint8_t * __code const HTTP_RESPONCE_JSON = "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Type: application/json\r\n\r\n";
@@ -746,7 +746,7 @@ void send_lldp(void)
slen += strtox(outbuf + slen, ",\"port_status\":[");
for (uint8_t port = machine.min_port; port <= machine.max_port; port++) {
bool_to_html((1 << machine.log_to_phys_port[port]) & lldp_physical_port_status);
bool_to_html((1 << port) & lldp_logical_port_status);
slen += strtox(outbuf + slen, ",");
}
slen--; //overwrite the last comma
+1 -1
View File
@@ -131,7 +131,7 @@ struct flash_region_t {
};
extern __xdata char port_names[9][PORT_NAME_SIZE];
extern __xdata uint16_t lldp_physical_port_status;
extern __xdata uint16_t lldp_logical_port_status;
extern __xdata bool stp_enabled;
+8 -8
View File
@@ -13,22 +13,22 @@
extern __xdata bool lldp_enabled;
extern __code const struct machine machine;
__xdata uint8_t lldp_seconds;
__xdata uint16_t lldp_physical_port_status = 0xffff;
__xdata uint16_t lldp_ticks;
__xdata uint16_t lldp_logical_port_status = 0xffff;
void lldp_init(void) __banked
{
lldp_seconds = 0;
lldp_ticks = 0;
}
void lldp_tick(void) __banked
{
lldp_seconds++;
lldp_ticks++;
if (lldp_seconds < LLDP_TX_INTERVAL_SEC)
if (lldp_ticks < LLDP_TX_INTERVAL_TICKS)
return;
lldp_seconds = 0;
lldp_ticks = 0;
if(lldp_enabled == 1)
lldp_send();
@@ -110,9 +110,9 @@ void lldp_send(void) __banked __reentrant
for (uint8_t port = machine.min_port; port <= machine.max_port; port++) {
if ((1 << machine.log_to_phys_port[port]) & lldp_physical_port_status) {
if ((1 << port) & lldp_logical_port_status) {
LLDP_O->payload[port_position] = '0' + machine.log_to_phys_port[port];
LLDP_O->rtl_tag.pmask = HTONS((uint16_t)1 << machine.log_to_phys_port[port]);
LLDP_O->rtl_tag.pmask = HTONS((uint16_t)1 << port);
tcpip_output();
}
+1 -1
View File
@@ -8,7 +8,7 @@
#define LLDP_ETHERTYPE_LENGTH 2
#define LLDP_MAX_FRAME 256
#define MAC_ADDR_LEN 6
#define LLDP_TX_INTERVAL_SEC 30
#define LLDP_TX_INTERVAL_TICKS 6000
#define LLDP_PORT_ID_TLV_TYPE 2
#define LLDP_PORT_ID_TLV_LENGTH 0x02
-4
View File
@@ -1068,10 +1068,6 @@ void handle_rx(void)
if (uip_len) {
tcpip_output();
}
} else if (lldp_enabled && uip_buf[0] == 0x01 && uip_buf[1] == 0x80 && uip_buf[2] == 0xc2
&& uip_buf[3] == 0x00 && uip_buf[4] == 0x00 && uip_buf[5] == 0x0e && uip_buf[12] == 0x88
&& uip_buf[13] == 0xcc) { //LLDP Mac + EtherType check
// LLDP packets shouldn't be passed elsewhere
} else if (ETH_IN->ether_type == HTONS(0x0806)) { // ARP
uip_arp_arpin();
if (uip_len) {
+1 -1
View File
@@ -85,7 +85,7 @@ struct flash_region_t flash_region;
struct syslog_state syslog_state;
bool stp_enabled;
bool lldp_enabled;
uint16_t lldp_physical_port_status;
uint16_t lldp_logical_port_status;
uip_ipaddr_t uip_hostaddr, uip_draddr, uip_netmask;