diff --git a/httpd/httpd.c b/httpd/httpd.c index 2812524..6649b36 100644 --- a/httpd/httpd.c +++ b/httpd/httpd.c @@ -586,6 +586,8 @@ void httpd_appcall(void) send_counters(q[20]-'0'); } else if (is_word(q, "/eee.json")) { send_eee(); + } else if (is_word(q, "/bandwidth.json")) { + send_bandwidth(); } else if (is_word(q, "/l2.json")) { parse_short(q + 13); // e.g.: /l2.json?idx=10 send_l2(short_parsed); diff --git a/httpd/page_impl.c b/httpd/page_impl.c index 9769311..82e5314 100644 --- a/httpd/page_impl.c +++ b/httpd/page_impl.c @@ -546,6 +546,50 @@ void send_eee(void) } } + +void send_bandwidth(void) +{ + dbg_string("send_bandwidth called\n"); + slen = strtox(outbuf, HTTP_RESPONCE_JSON); + char_to_html('['); + for (uint8_t i = machine.min_port; i <= machine.max_port; i++) { + slen += strtox(outbuf + slen, "{\"portNum\":"); + itoa_html(machine.log_to_phys_port[i]); + slen += strtox(outbuf + slen, ",\"iLimited\":"); + reg_read_m(RTL837X_IGBW_PORT_CTRL + i * 4); + if (sfr_data[1] & 0x10) + char_to_html('1'); + else + char_to_html('0'); + slen += strtox(outbuf + slen, ",\"iBW\":\""); + byte_to_html(sfr_data[1] & 0x0f); + byte_to_html(sfr_data[2]); + byte_to_html(sfr_data[3]); + slen += strtox(outbuf + slen, "\",\"iFC\":"); + if (reg_bit_test(RTL837X_IGBW_PORT_FC_CTRL, i)) + char_to_html('1'); + else + char_to_html('0'); + reg_read_m(RTL837X_EGBW_PORT_CTRL + i * 1024); + slen += strtox(outbuf + slen, ",\"eLimited\":"); + if (sfr_data[1] & 0x10) + char_to_html('1'); + else + char_to_html('0'); + slen += strtox(outbuf + slen, ",\"eBW\":\""); + byte_to_html(sfr_data[1] & 0x0f); + byte_to_html(sfr_data[2]); + byte_to_html(sfr_data[3]); + char_to_html('"'); + char_to_html('}'); + if (i < machine.max_port) + char_to_html(','); + else + char_to_html(']'); + } +} + + void send_mtu(void) { dbg_string("send_mtu called\n"); diff --git a/httpd/page_impl.h b/httpd/page_impl.h index 00c178c..5591e14 100644 --- a/httpd/page_impl.h +++ b/httpd/page_impl.h @@ -5,6 +5,7 @@ void send_counters(char port); void send_status(void); void send_vlan(uint16_t vlan); void send_basic_info(void); +void send_bandwidth(void); void send_eee(void); void send_l2(uint16_t idx); void l2_delete(uint16_t idx);