From 8a7c847ad9d9c0368c93d6e490041c28c1a35a20 Mon Sep 17 00:00:00 2001 From: d00f <8052722+DrDoof@users.noreply.github.com> Date: Tue, 13 Oct 2026 01:35:03 +0200 Subject: [PATCH] tools: httpd_sim serves the MAC count per port The simulator answered /status.json without the "macs" field the Ports page now reads. It counts the dynamic entries of its own L2 table for the port, so the column and /l2.json agree and the two static entries show the difference. --- tools/httpd_sim.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/httpd_sim.c b/tools/httpd_sim.c index 76c088c3..fedd54f2 100644 --- a/tools/httpd_sim.c +++ b/tools/httpd_sim.c @@ -56,6 +56,7 @@ time_t last_session_use; uint64_t txG[PORTS], txB[PORTS], rxG[PORTS], rxB[PORTS]; char txG_buff[20], txB_buff[20], rxG_buff[20], rxB_buff[20], counter_buf[20], counter_name[20]; +char macs_buff[8]; char sfp_temp[8], sfp_vcc[8], sfp_txbias[8], sfp_txpower[8], sfp_rxpower[8], sfp_laser[8], sfp_options[6]; char num_buff[20]; char l2_idx_buff[20]; @@ -180,6 +181,12 @@ void send_status(int s) json_object_object_add(v, "txB", json_object_new_string(txB_buff)); json_object_object_add(v, "rxG", json_object_new_string(rxG_buff)); json_object_object_add(v, "rxB", json_object_new_string(rxB_buff)); + uint16_t macs = 0; + for (int e = 0; e < L2_ENTRY_NUM; e++) + if (l2_entries[e].port == physToLogPort[i-1] && l2_entries[e].type != 's') + macs++; + sprintf(macs_buff, "0x%04x", macs); + json_object_object_add(v, "macs", json_object_new_string(macs_buff)); if (i >= PORTS - NSFP) { uint16_t temp = 0x28fb + rand() / (RAND_MAX / 100); uint16_t vcc = 0x7eda + rand() / (RAND_MAX / 100);