From dda873a633498aa4c27737714b49943c09cc14a6 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Tue, 6 Oct 2026 07:58:48 +0100 Subject: [PATCH] Moving lldp cmd parsing to be above the is_sfp check to take precedence Needed to increase buffer size for this to send app.js The logical port status is what is returned in the array, for non-sequential systems we need to map through physToLog rather than just subtracting 1 physToLog is 1 based! not 0; also fixing up typecasts Reimplementing using an array of objects to represent ports. The previous approach of a bitmask of logical ports, was just too simple on devices such as the SWGT024_V2_0_MANAGED which has gaps in the port assignments. --- cmd_parser.c | 16 ++++++++-------- html/app.js | 26 ++++++++------------------ httpd/page_impl.c | 30 +++++++++++++++++++++++------- tools/httpd_sim.c | 14 +++++++++++++- tools/httpd_sim.h | 2 +- 5 files changed, 53 insertions(+), 35 deletions(-) diff --git a/cmd_parser.c b/cmd_parser.c index 3cb7724c..8cfc7d4b 100644 --- a/cmd_parser.c +++ b/cmd_parser.c @@ -914,6 +914,14 @@ void parse_port(void) print_string("\nName set to: \""); print_string_x(port_names[phy_settings.port]); print_string("\"\n"); + } else if (cmd_compare(2, "lldp")) { + if (cmd_compare(3, "block")){ + 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; + } else { + print_string ("Unknown port lldp [block|permit] command\n"); + } } else if (machine.is_sfp[phy_settings.port]) { print_string(" is SFP no PHY information available.\n"); } else if (cmd_compare(2, "10m")) { @@ -967,14 +975,6 @@ 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_logical_port_status &= ~(1 << phy_settings.port); - } else if (cmd_compare(3, "permit")) { - lldp_logical_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/html/app.js b/html/app.js index 00af6434..d5391274 100644 --- a/html/app.js +++ b/html/app.js @@ -1843,36 +1843,26 @@ function lldpLoad(){ return getJSON("/lldp.json").then(function(s){ $("lldp_en").checked=s.on; var tb=$("lldp_table").tBodies[0];tb.innerHTML=""; - if(tb.rows.length!==S.n){ - tb.innerHTML=""; - for(var i=0;i> i)); + slen += strtox(outbuf + slen, "\"}"); + + if (i < machine.max_port) + char_to_html(','); + else + char_to_html(']'); + } + char_to_html('}'); } void send_eee(void) diff --git a/tools/httpd_sim.c b/tools/httpd_sim.c index 53a4d403..fba9ffae 100644 --- a/tools/httpd_sim.c +++ b/tools/httpd_sim.c @@ -459,7 +459,19 @@ void send_lldp(int s) char *header = "HTTP/1.1 200 OK\r\n" "Content-Type: application/json; charset=UTF-8\r\n\r\n"; - char *body = "{\"on\": 1,\"port_status\":[1,1,0,1,1,1,1,0,0]}"; + //portNum represents physical ports + char *body = "{\"on\": 1,\"portStatus\":[\ + {\"portNum\":1,\"logPort\":1,\"name\":\"PC\",\"enabled\":1},\ + {\"portNum\":2,\"logPort\":2,\"name\":\"\",\"enabled\":1},\ + {\"portNum\":3,\"logPort\":3,\"name\":\"\",\"enabled\":1},\ + {\"portNum\":4,\"logPort\":4,\"name\":\"\",\"enabled\":0},\ + {\"portNum\":5,\"logPort\":5,\"name\":\"\",\"enabled\":1},\ + {\"portNum\":6,\"logPort\":6,\"name\":\"TV\",\"enabled\":1},\ + {\"portNum\":7,\"logPort\":7,\"name\":\"\",\"enabled\":0},\ + {\"portNum\":8,\"logPort\":8,\"name\":\"Router\",\"enabled\":1},\ + {\"portNum\":9,\"logPort\":9,\"name\":\"\",\"enabled\":1},\ + {\"portNum\":10,\"logPort\":10,\"name\":\"Uplink\",\"enabled\":1}\ + ]}"; write(s, header, strlen(header)); write(s, body, strlen(body)); diff --git a/tools/httpd_sim.h b/tools/httpd_sim.h index 49c078aa..df59ff19 100644 --- a/tools/httpd_sim.h +++ b/tools/httpd_sim.h @@ -3,7 +3,7 @@ #include -#define BUFFER_SIZE 131072 +#define BUFFER_SIZE 262144 struct Server { int domain;