mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Returns a JSON array of all configured VLANs with their IDs and names,
e.g. [{"id":1,"name":""},{"id":20,"name":"IoT"}].
The endpoint iterates VLAN IDs 1..4094 and filters by the validity bit
in sfr_data[0] (0x02), following the same pattern as vlan_create() and
vlan_setup() in rtl837x_port.c.
Also adds a small itoa16_html() helper for emitting decimal numbers
up to 4 digits (analogous to the existing 8-bit itoa_html()), used
for VLAN IDs which can reach 4094. Response builder uses the existing
vlan_name() helper for the name lookup, consistent with send_vlan().
Buffer overflow is prevented by breaking out of the iteration loop at
TCP_OUTBUF_SIZE - 60.
This endpoint is the foundation for upcoming UI improvements
(VLAN selector dropdown and overview table).
35 lines
724 B
C
35 lines
724 B
C
#ifndef __PAGE_IMPL_H__
|
|
#define __PAGE_IMPL_H__
|
|
|
|
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);
|
|
void send_mirror(void);
|
|
void send_mtu(void);
|
|
void send_config(void);
|
|
void send_cmd_log(void);
|
|
void send_lag(void);
|
|
void send_vlanlist(void);
|
|
|
|
/* Convert only the lower nibble to ascii HEX char.
|
|
For convenience the upper nibble is masked out.
|
|
*/
|
|
inline char itohex(uint8_t val) {
|
|
// Ignore upper nibble for convenience.
|
|
val &= 0x0f;
|
|
val -= 10;
|
|
|
|
// 10 or above
|
|
if ((int8_t)val >= 0)
|
|
val += ('a' - '0' - 10);
|
|
|
|
return val + ('0' + 10);
|
|
}
|
|
|
|
#endif
|