Add httpd backend implementation for MIB counter requests

This commit is contained in:
logicog
2026-01-15 18:07:56 +01:00
parent 6326428406
commit 84fe44cc9a
2 changed files with 20 additions and 12 deletions
+1 -1
View File
@@ -570,7 +570,7 @@ void httpd_appcall(void)
parse_short(q + 15); parse_short(q + 15);
send_vlan(short_parsed); send_vlan(short_parsed);
} else if (is_word(q, "/counters.json")) { } else if (is_word(q, "/counters.json")) {
send_counters(q[19]-'0'); send_counters(q[20]-'0');
} else if (is_word(q, "/eee.json")) { } else if (is_word(q, "/eee.json")) {
send_eee(); send_eee();
} else if (is_word(q, "/mirror.json")) { } else if (is_word(q, "/mirror.json")) {
+19 -11
View File
@@ -143,6 +143,16 @@ void reg_to_html(register uint16_t reg)
} }
void reg_to_html_long(register uint16_t reg)
{
reg_read_m(reg);
byte_to_html(sfr_data[0]);
byte_to_html(sfr_data[1]);
byte_to_html(sfr_data[2]);
byte_to_html(sfr_data[3]);
}
void send_sfp_info(uint8_t sfp) void send_sfp_info(uint8_t sfp)
{ {
// This loops over the Vendor-name, Vendor OUI, Vendor PN and Vendor rev ASCII fields // This loops over the Vendor-name, Vendor OUI, Vendor PN and Vendor rev ASCII fields
@@ -257,21 +267,19 @@ void send_counters(char port)
dbg_string("send_counters called: "); dbg_byte(port); dbg_char('\n'); dbg_string("send_counters called: "); dbg_byte(port); dbg_char('\n');
slen = strtox(outbuf, HTTP_RESPONCE_JSON); slen = strtox(outbuf, HTTP_RESPONCE_JSON);
dbg_string("sending counters\n"); dbg_string("sending counters\n");
dbg_byte(port);
port--;
uint8_t i = machine.phys_to_log_port[port]; uint8_t i = machine.phys_to_log_port[port];
slen += strtox(outbuf + slen, "{\"portNum\":"); slen += strtox(outbuf + slen, "[");
itoa_html(i + 1); for (uint8_t counter = 0; counter < 0x37; counter++) {
for (uint8_t j = 0; j < 0x3f; j++) { STAT_GET(counter, i);
STAT_GET(j, i); slen += strtox(outbuf + slen, "\"0x");
slen += strtox(outbuf + slen, ",\"cnt_");
itoa_html(j);
slen += strtox(outbuf + slen, "\":\"0x");
reg_to_html(RTL837X_STAT_V_HIGH); reg_to_html(RTL837X_STAT_V_HIGH);
reg_to_html(RTL837X_STAT_V_LOW); reg_to_html_long(RTL837X_STAT_V_LOW);
char_to_html('\"'); char_to_html('\"');
if (counter != 0x36)
char_to_html(',');
} }
char_to_html('}'); char_to_html(']');
} }