mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
Rewriting sim implementation to be data driven
The value for enabled should be an int, not a string
This commit is contained in:
1 parent
dda873a633
commit
eff3f42ae1
3 files changed
+24
-19
No files matched your search
+1
-1
@@ -1852,7 +1852,7 @@ function lldpLoad(){
|
|||||||
postCmd("port "+p.portNum+" lldp "+(this.checked?"permit":"block"))
|
postCmd("port "+p.portNum+" lldp "+(this.checked?"permit":"block"))
|
||||||
.then(function(){setTimeout(lldpLoad,300)}).catch(function(){});
|
.then(function(){setTimeout(lldpLoad,300)}).catch(function(){});
|
||||||
}}),h("i")]);
|
}}),h("i")]);
|
||||||
sw.firstChild.checked=p.enabled;
|
sw.firstChild.checked=p.permitted;
|
||||||
tr.insertCell().appendChild(sw);
|
tr.insertCell().appendChild(sw);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-3
@@ -755,11 +755,10 @@ void send_lldp(void)
|
|||||||
for (uint8_t j = 0; j < PORT_NAME_SIZE && port_names[i][j]; j++) {
|
for (uint8_t j = 0; j < PORT_NAME_SIZE && port_names[i][j]; j++) {
|
||||||
json_char_to_html(port_names[i][j]);
|
json_char_to_html(port_names[i][j]);
|
||||||
}
|
}
|
||||||
slen += strtox(outbuf + slen, "\"");
|
|
||||||
|
|
||||||
slen += strtox(outbuf + slen, ",\"enabled\":\"");
|
slen += strtox(outbuf + slen, "\",\"permitted\":");
|
||||||
bool_to_html(1 & (lldp_logical_port_status >> i));
|
bool_to_html(1 & (lldp_logical_port_status >> i));
|
||||||
slen += strtox(outbuf + slen, "\"}");
|
slen += strtox(outbuf + slen, "}");
|
||||||
|
|
||||||
if (i < machine.max_port)
|
if (i < machine.max_port)
|
||||||
char_to_html(',');
|
char_to_html(',');
|
||||||
|
|||||||
+21
-15
@@ -447,7 +447,7 @@ void send_mtu(int s)
|
|||||||
json_object_object_add(v, "mtu", json_object_new_string(mtu));
|
json_object_object_add(v, "mtu", json_object_new_string(mtu));
|
||||||
json_object_array_add(mtus, v);
|
json_object_array_add(mtus, v);
|
||||||
}
|
}
|
||||||
write(s, header, strlen(header));
|
write(s, header, strlen(header));
|
||||||
|
|
||||||
jstring = json_object_to_json_string_ext(mtus, JSON_C_TO_STRING_PLAIN);
|
jstring = json_object_to_json_string_ext(mtus, JSON_C_TO_STRING_PLAIN);
|
||||||
write(s, jstring, strlen(jstring));
|
write(s, jstring, strlen(jstring));
|
||||||
@@ -456,25 +456,31 @@ void send_mtu(int s)
|
|||||||
|
|
||||||
void send_lldp(int s)
|
void send_lldp(int s)
|
||||||
{
|
{
|
||||||
|
struct json_object *c, *portStatuses, *p;
|
||||||
|
const char *jstring;
|
||||||
char *header = "HTTP/1.1 200 OK\r\n"
|
char *header = "HTTP/1.1 200 OK\r\n"
|
||||||
"Content-Type: application/json; charset=UTF-8\r\n\r\n";
|
"Content-Type: application/json; charset=UTF-8\r\n\r\n";
|
||||||
|
|
||||||
//portNum represents physical ports
|
c = json_object_new_object();
|
||||||
char *body = "{\"on\": 1,\"portStatus\":[\
|
json_object_object_add(c, "on", json_object_new_int(1));
|
||||||
{\"portNum\":1,\"logPort\":1,\"name\":\"PC\",\"enabled\":1},\
|
portStatuses = json_object_new_array_ext(PORTS);
|
||||||
{\"portNum\":2,\"logPort\":2,\"name\":\"\",\"enabled\":1},\
|
|
||||||
{\"portNum\":3,\"logPort\":3,\"name\":\"\",\"enabled\":1},\
|
for (int i = 1; i <= PORTS; i++) {
|
||||||
{\"portNum\":4,\"logPort\":4,\"name\":\"\",\"enabled\":0},\
|
p = json_object_new_object();
|
||||||
{\"portNum\":5,\"logPort\":5,\"name\":\"\",\"enabled\":1},\
|
json_object_object_add(p, "portNum", json_object_new_int(i));
|
||||||
{\"portNum\":6,\"logPort\":6,\"name\":\"TV\",\"enabled\":1},\
|
json_object_object_add(p, "logPort", json_object_new_int(i-1));
|
||||||
{\"portNum\":7,\"logPort\":7,\"name\":\"\",\"enabled\":0},\
|
json_object_object_add(p, "name", json_object_new_string(""));
|
||||||
{\"portNum\":8,\"logPort\":8,\"name\":\"Router\",\"enabled\":1},\
|
json_object_object_add(p, "permitted", json_object_new_int(1));
|
||||||
{\"portNum\":9,\"logPort\":9,\"name\":\"\",\"enabled\":1},\
|
json_object_array_add(portStatuses, p);
|
||||||
{\"portNum\":10,\"logPort\":10,\"name\":\"Uplink\",\"enabled\":1}\
|
}
|
||||||
]}";
|
|
||||||
|
json_object_object_add(c, "portStatus", portStatuses);
|
||||||
|
|
||||||
write(s, header, strlen(header));
|
write(s, header, strlen(header));
|
||||||
write(s, body, strlen(body));
|
|
||||||
|
jstring = json_object_to_json_string_ext(c, JSON_C_TO_STRING_PLAIN);
|
||||||
|
write(s, jstring, strlen(jstring));
|
||||||
|
json_object_put(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_cmd_log(int s)
|
void send_cmd_log(int s)
|
||||||
|
|||||||
Reference in new issue
Block a user