version 1.1.1.2, 2016/11/01 09:56:12
|
version 1.1.1.3, 2021/03/17 00:39:23
|
Line 28
|
Line 28
|
* INTERNAL FUNCTIONS |
* INTERNAL FUNCTIONS |
*/ |
*/ |
|
|
static int WebSetCommand(Context ctx, int ac, char *av[], void *arg); | static int WebSetCommand(Context ctx, int ac, const char *const av[], const void *arg); |
|
|
static int WebServletRun(struct http_servlet *servlet, |
static int WebServletRun(struct http_servlet *servlet, |
struct http_request *req, struct http_response *resp); |
struct http_request *req, struct http_response *resp); |
Line 60
|
Line 60
|
WebSetCommand, NULL, 2, (void *) SET_ENABLE }, |
WebSetCommand, NULL, 2, (void *) SET_ENABLE }, |
{ "disable [opt ...]", "Disable web option" , |
{ "disable [opt ...]", "Disable web option" , |
WebSetCommand, NULL, 2, (void *) SET_DISABLE }, |
WebSetCommand, NULL, 2, (void *) SET_DISABLE }, |
{ NULL }, | { NULL, NULL, NULL, NULL, 0, NULL }, |
}; |
}; |
|
|
|
|
Line 157 WebClose(Web w)
|
Line 157 WebClose(Web w)
|
*/ |
*/ |
|
|
int |
int |
WebStat(Context ctx, int ac, char *av[], void *arg) | WebStat(Context ctx, int ac, const char *const av[], const void *arg) |
{ |
{ |
Web w = &gWeb; |
Web w = &gWeb; |
char addrstr[64]; |
char addrstr[64]; |
|
|
|
(void)ac; |
|
(void)av; |
|
(void)arg; |
|
|
Printf("Web configuration:\r\n"); |
Printf("Web configuration:\r\n"); |
Printf("\tState : %s\r\n", w->srv ? "OPENED" : "CLOSED"); |
Printf("\tState : %s\r\n", w->srv ? "OPENED" : "CLOSED"); |
Printf("\tIP-Address : %s\r\n", u_addrtoa(&w->addr,addrstr,sizeof(addrstr))); |
Printf("\tIP-Address : %s\r\n", u_addrtoa(&w->addr,addrstr,sizeof(addrstr))); |
Line 446 WebShowJSONSummary(FILE *f, int priv)
|
Line 450 WebShowJSONSummary(FILE *f, int priv)
|
Rep R; |
Rep R; |
char buf[64],buf2[64]; |
char buf[64],buf2[64]; |
|
|
|
(void)priv; |
int first_l = 1; |
int first_l = 1; |
fprintf(f, "{\"links\":[\n"); |
fprintf(f, "{\"links\":[\n"); |
for (b = 0; b<gNumLinks; b++) { |
for (b = 0; b<gNumLinks; b++) { |
Line 502 WebShowJSONSummary(FILE *f, int priv)
|
Line 507 WebShowJSONSummary(FILE *f, int priv)
|
fprintf(f, "\"ccp\": \"%s\",\n", FsmStateName(B->ccp.fsm.state)); |
fprintf(f, "\"ccp\": \"%s\",\n", FsmStateName(B->ccp.fsm.state)); |
fprintf(f, "\"ecp\": \"%s\",\n", FsmStateName(B->ecp.fsm.state)); |
fprintf(f, "\"ecp\": \"%s\",\n", FsmStateName(B->ecp.fsm.state)); |
|
|
int first_l = 1; | first_l = 1; |
fprintf(f, "\"links\":[\n"); |
fprintf(f, "\"links\":[\n"); |
for (l = 0; l < NG_PPP_MAX_LINKS; l++) { |
for (l = 0; l < NG_PPP_MAX_LINKS; l++) { |
if ((L=B->links[l]) != NULL) { |
if ((L=B->links[l]) != NULL) { |
Line 560 WebShowJSONSummary(FILE *f, int priv)
|
Line 565 WebShowJSONSummary(FILE *f, int priv)
|
|
|
fprintf(f, "\"repeater\": \"%s\",\n", R->name); |
fprintf(f, "\"repeater\": \"%s\",\n", R->name); |
|
|
int first_l = 1; | first_l = 1; |
fprintf(f, "\"links\":[\n"); |
fprintf(f, "\"links\":[\n"); |
for (l = 0; l < 2; l++) { |
for (l = 0; l < 2; l++) { |
if ((L=R->links[l]) != NULL) { |
if ((L=R->links[l]) != NULL) { |
Line 641 WebRunBinCmd(FILE *f, const char *query, int priv)
|
Line 646 WebRunBinCmd(FILE *f, const char *query, int priv)
|
|
|
for (k = 0; k < argc; k++) { |
for (k = 0; k < argc; k++) { |
int ac, rtn; |
int ac, rtn; |
char *av[MAX_CONSOLE_ARGS]; | char *av[MAX_CONSOLE_ARGS]; |
char *buf1; |
char *buf1; |
|
|
buf1 = Malloc(MB_WEB, strlen(argv[k]) + 1); |
buf1 = Malloc(MB_WEB, strlen(argv[k]) + 1); |
Line 652 WebRunBinCmd(FILE *f, const char *query, int priv)
|
Line 657 WebRunBinCmd(FILE *f, const char *query, int priv)
|
buf1)); |
buf1)); |
ac = ParseLine(buf1, av, sizeof(av) / sizeof(*av), 0); |
ac = ParseLine(buf1, av, sizeof(av) / sizeof(*av), 0); |
cs->context.errmsg[0] = 0; |
cs->context.errmsg[0] = 0; |
rtn = DoCommandTab(&cs->context, gCommands, ac, av); | rtn = DoCommandTab(&cs->context, gCommands, ac, (const char *const *)av); |
Freee(buf1); |
Freee(buf1); |
fprintf(f, "RESULT: %d %s\n", rtn, cs->context.errmsg); |
fprintf(f, "RESULT: %d %s\n", rtn, cs->context.errmsg); |
} |
} |
Line 700 WebRunCmd(FILE *f, const char *query, int priv)
|
Line 705 WebRunCmd(FILE *f, const char *query, int priv)
|
fprintf(f, "<pre>\n"); |
fprintf(f, "<pre>\n"); |
for (k = 0; k < argc; k++) { |
for (k = 0; k < argc; k++) { |
int ac; |
int ac; |
char *av[MAX_CONSOLE_ARGS]; | char *av[MAX_CONSOLE_ARGS]; |
char *buf1; |
char *buf1; |
|
|
buf1 = Malloc(MB_WEB, strlen(argv[k]) + 1); |
buf1 = Malloc(MB_WEB, strlen(argv[k]) + 1); |
Line 714 WebRunCmd(FILE *f, const char *query, int priv)
|
Line 719 WebRunCmd(FILE *f, const char *query, int priv)
|
cs->write(cs, "%s\n", buf1); |
cs->write(cs, "%s\n", buf1); |
|
|
ac = ParseLine(buf1, av, sizeof(av) / sizeof(*av), 0); |
ac = ParseLine(buf1, av, sizeof(av) / sizeof(*av), 0); |
DoCommand(&cs->context, ac, av, NULL, 0); | DoCommand(&cs->context, ac, (const char *const *)av, NULL, 0); |
Freee(buf1); |
Freee(buf1); |
} |
} |
fprintf(f, "</pre>\n"); |
fprintf(f, "</pre>\n"); |
Line 727 done:
|
Line 732 done:
|
} |
} |
|
|
static void |
static void |
WebServletRunCleanup(void *cookie) { | WebServletRunCleanup(void *cookie) NO_THREAD_SAFETY_ANALYSIS |
| { |
| (void)cookie; |
GIANT_MUTEX_UNLOCK(); |
GIANT_MUTEX_UNLOCK(); |
} |
} |
|
|
Line 740 WebServletRun(struct http_servlet *servlet,
|
Line 747 WebServletRun(struct http_servlet *servlet,
|
const char *query; |
const char *query; |
int priv = 0; |
int priv = 0; |
|
|
|
(void)servlet; |
if (Enabled(&gWeb.options, WEB_AUTH)) { |
if (Enabled(&gWeb.options, WEB_AUTH)) { |
const char *username; |
const char *username; |
const char *password; |
const char *password; |
Line 824 WebServletRun(struct http_servlet *servlet,
|
Line 832 WebServletRun(struct http_servlet *servlet,
|
static void |
static void |
WebServletDestroy(struct http_servlet *servlet) |
WebServletDestroy(struct http_servlet *servlet) |
{ |
{ |
|
(void)servlet; |
} |
} |
|
|
static void |
static void |
Line 831 WebLogger(int sev, const char *fmt, ...)
|
Line 840 WebLogger(int sev, const char *fmt, ...)
|
{ |
{ |
va_list args; |
va_list args; |
|
|
|
(void)sev; |
va_start(args, fmt); |
va_start(args, fmt); |
vLogPrintf(fmt, args); |
vLogPrintf(fmt, args); |
va_end(args); |
va_end(args); |
Line 841 WebLogger(int sev, const char *fmt, ...)
|
Line 851 WebLogger(int sev, const char *fmt, ...)
|
*/ |
*/ |
|
|
static int |
static int |
WebSetCommand(Context ctx, int ac, char *av[], void *arg) | WebSetCommand(Context ctx, int ac, const char *const av[], const void *arg) |
{ |
{ |
Web w = &gWeb; |
Web w = &gWeb; |
int port; |
int port; |