mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-09-02 15:02:51 +08:00
Merge upstream/main into the Spanning Tree branch
cmd_parser.c conflicted twice: main rewrote the pvid command around the new port-separator and atoi helpers, next to the line where this branch delegates "stp" to stp_parse(). Both belong, so the STP delegation keeps main's pvid body. The linker caught what the merge could not see: main changed atoi_byte() to return the digit count and leave the value in atoi_results_u8, where it used to return non-zero on failure and write through a pointer. Note the sense is inverted, so the three calls in rtl837x_stp.c are adjusted rather than just re-arranged.
This commit is contained in:
+11
-18
@@ -120,8 +120,8 @@ bool is_word(__xdata uint8_t *xdata_str_p, __code uint8_t * __xdata code_str_p)
|
||||
u = *xdata_str_p++;
|
||||
c = *code_str_p++;
|
||||
|
||||
if (c == '\0') {
|
||||
if (u != '\0' && u != ' ' && u != '\t' && u != ':' && u != '?' && u != '=' && u != '\n' && u != '\r')
|
||||
if (c == NUL) {
|
||||
if (u != NUL && u != ' ' && u != '\t' && u != ':' && u != '?' && u != '=' && u != '\n' && u != '\r')
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -141,8 +141,8 @@ bool is_url_word_x(__xdata uint8_t *uri_str_p, __xdata uint8_t *src_str_p)
|
||||
u = *uri_str_p++;
|
||||
s = *src_str_p++;
|
||||
|
||||
if (s == '\0') {
|
||||
if (u != '\0' && u != ' ' && u != '\t' && u != ':' && u != '?' && u != '=' && u != '\n' && u != '\r')
|
||||
if (s == NUL) {
|
||||
if (u != NUL && u != ' ' && u != '\t' && u != ':' && u != '?' && u != '=' && u != '\n' && u != '\r')
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -184,9 +184,9 @@ bool is_word_x(__xdata uint8_t *lhs_str_p, __xdata uint8_t *rhs_str_p)
|
||||
u = *lhs_str_p++;
|
||||
c = *rhs_str_p++;
|
||||
|
||||
if (c == '\0') {
|
||||
if (c == NUL) {
|
||||
/* ';' separates cookies in a Cookie header, so it ends a value too. */
|
||||
if (u != '\0' && u != ' ' && u != '\t' && u != ':' && u != '?' && u != '=' && u != '\n' && u != '\r' && u != ';')
|
||||
if (u != NUL && u != ' ' && u != '\t' && u != ':' && u != '?' && u != '=' && u != '\n' && u != '\r' && u != ';')
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -488,10 +488,10 @@ void handle_post(void)
|
||||
// Find end of request path
|
||||
while (*p && !is_separator(*p))
|
||||
p++;
|
||||
*p++ = '\0';
|
||||
*p++ = NUL;
|
||||
|
||||
// Find end of request header
|
||||
boundary[0] ='\0';
|
||||
boundary[0] =NUL;
|
||||
p = scan_header(p);
|
||||
dbg_string("Boundary: >"); dbg_string_x(boundary); dbg_string("<\n");
|
||||
if (!*p || !content_type) {
|
||||
@@ -551,7 +551,7 @@ void handle_post(void)
|
||||
dbg_string("Password accepted!\n");
|
||||
read_reg_timer(&last_session_use);
|
||||
gen_random_bytes(session_id, SESSION_ID_LENGTH);
|
||||
session_id[SESSION_ID_LENGTH] = '\0';
|
||||
session_id[SESSION_ID_LENGTH] = NUL;
|
||||
slen = strtox(outbuf, "HTTP/1.1 302 Found\r\nConnection: close\r\nLocation: index.html\r\n" \
|
||||
"Set-Cookie: session=");
|
||||
for (register uint8_t i = 0; i < SESSION_ID_LENGTH; i++)
|
||||
@@ -737,7 +737,7 @@ void httpd_appcall(void)
|
||||
__xdata uint8_t *q = p;
|
||||
while (*p && !is_separator(*p))
|
||||
p++;
|
||||
*p = '\0';
|
||||
*p = NUL;
|
||||
dbg_string_x(q);
|
||||
dbg_char('\n');
|
||||
|
||||
@@ -759,16 +759,9 @@ void httpd_appcall(void)
|
||||
parse_short(q + 15);
|
||||
send_vlan(short_parsed);
|
||||
} else if (is_word(q, "/counters.json")) {
|
||||
/* The port is one raw character of the request line and
|
||||
* indexes a nine entry table, so bound it here instead
|
||||
* of trusting the client to have sent a digit. Anything
|
||||
* below '0' wraps well past eight, so the one test
|
||||
* covers both ends. */
|
||||
uint8_t cport = q[20] - '0';
|
||||
if (cport > 8)
|
||||
if (send_counters(cport))
|
||||
send_bad_request();
|
||||
else
|
||||
send_counters(cport);
|
||||
} else if (is_word(q, "/eee.json")) {
|
||||
send_eee();
|
||||
} else if (is_word(q, "/bandwidth.json")) {
|
||||
|
||||
+23
-8
@@ -290,17 +290,26 @@ void send_vlan(uint16_t vlan)
|
||||
slen += strtox(outbuf + slen, "\"}");
|
||||
}
|
||||
|
||||
|
||||
void send_counters(char port)
|
||||
/* Send counters
|
||||
* Only accepts physical port 1..9.
|
||||
* Returns an error if the port physical don't exists.
|
||||
*/
|
||||
bool send_counters(uint8_t phys_port)
|
||||
{
|
||||
dbg_string("send_counters called: "); dbg_byte(port); dbg_char('\n');
|
||||
uint8_t phys_port_idx = phys_port - 1;
|
||||
if (phys_port_idx > 8)
|
||||
goto err;
|
||||
uint8_t log_port = machine.phys_to_log_port[phys_port_idx];
|
||||
if (log_port == 0)
|
||||
goto err;
|
||||
|
||||
dbg_string("send_counters called: "); dbg_byte(phys_port_idx); dbg_char('\n');
|
||||
slen = strtox(outbuf, HTTP_RESPONCE_JSON);
|
||||
dbg_string("sending counters\n");
|
||||
dbg_byte(port);
|
||||
uint8_t i = machine.phys_to_log_port[port];
|
||||
slen += strtox(outbuf + slen, "[");
|
||||
dbg_string("sending counters\n"); dbg_byte(phys_port_idx);
|
||||
|
||||
char_to_html('[');
|
||||
for (uint8_t counter = 0; counter < 0x37; counter++) {
|
||||
STAT_GET(counter, i);
|
||||
STAT_GET(counter, log_port);
|
||||
slen += strtox(outbuf + slen, "\"0x");
|
||||
reg_to_html(RTL837X_STAT_V_HIGH);
|
||||
reg_to_html_long(RTL837X_STAT_V_LOW);
|
||||
@@ -309,6 +318,12 @@ void send_counters(char port)
|
||||
char_to_html(',');
|
||||
}
|
||||
char_to_html(']');
|
||||
|
||||
return false;
|
||||
|
||||
err:
|
||||
dbg_string("Error: counters: phy_port_idx don't exists\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-1
@@ -1,7 +1,9 @@
|
||||
#ifndef __PAGE_IMPL_H__
|
||||
#define __PAGE_IMPL_H__
|
||||
|
||||
void send_counters(char port);
|
||||
#include <stdbool.h>
|
||||
|
||||
bool send_counters(uint8_t phys_port);
|
||||
void send_status(void);
|
||||
void send_vlan(uint16_t vlan);
|
||||
void send_basic_info(void);
|
||||
|
||||
Reference in New Issue
Block a user