| 1 | |
|---|
| 2 | /* |
|---|
| 3 | * Broadcom Home Gateway Reference Design |
|---|
| 4 | * Web Page Configuration Support Routines |
|---|
| 5 | * |
|---|
| 6 | * Copyright 2001-2003, Broadcom Corporation |
|---|
| 7 | * All Rights Reserved. |
|---|
| 8 | * |
|---|
| 9 | * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY |
|---|
| 10 | * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM |
|---|
| 11 | * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS |
|---|
| 12 | * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. |
|---|
| 13 | * $Id: broadcom.c,v 1.9 2005/11/30 11:53:42 seg Exp $ |
|---|
| 14 | */ |
|---|
| 15 | |
|---|
| 16 | #ifdef WEBS |
|---|
| 17 | #include <webs.h> |
|---|
| 18 | #include <uemf.h> |
|---|
| 19 | #include <ej.h> |
|---|
| 20 | #else /* !WEBS */ |
|---|
| 21 | #include <stdio.h> |
|---|
| 22 | #include <stdlib.h> |
|---|
| 23 | #include <string.h> |
|---|
| 24 | #include <ctype.h> |
|---|
| 25 | #include <unistd.h> |
|---|
| 26 | #include <limits.h> |
|---|
| 27 | #include <sys/types.h> |
|---|
| 28 | #include <sys/stat.h> |
|---|
| 29 | #include <sys/socket.h> |
|---|
| 30 | #include <netinet/in.h> |
|---|
| 31 | #include <arpa/inet.h> |
|---|
| 32 | #include <httpd.h> |
|---|
| 33 | #include <errno.h> |
|---|
| 34 | #endif /* WEBS */ |
|---|
| 35 | |
|---|
| 36 | #include <proto/ethernet.h> |
|---|
| 37 | #include <fcntl.h> |
|---|
| 38 | #include <signal.h> |
|---|
| 39 | #include <time.h> |
|---|
| 40 | #include <sys/klog.h> |
|---|
| 41 | #include <sys/wait.h> |
|---|
| 42 | #include <cyutils.h> |
|---|
| 43 | #include <support.h> |
|---|
| 44 | #include <cy_conf.h> |
|---|
| 45 | // #ifdef EZC_SUPPORT |
|---|
| 46 | #include <ezc.h> |
|---|
| 47 | // #endif |
|---|
| 48 | #include <broadcom.h> |
|---|
| 49 | #include <wlutils.h> |
|---|
| 50 | #include <netdb.h> |
|---|
| 51 | #include <utils.h> |
|---|
| 52 | #include <dlfcn.h> |
|---|
| 53 | |
|---|
| 54 | int debug_value = 0; |
|---|
| 55 | |
|---|
| 56 | // static char * rfctime(const time_t *timep); |
|---|
| 57 | // static char * reltime(unsigned int seconds); |
|---|
| 58 | |
|---|
| 59 | // #if defined(linux) |
|---|
| 60 | |
|---|
| 61 | #include <fcntl.h> |
|---|
| 62 | #include <signal.h> |
|---|
| 63 | #include <time.h> |
|---|
| 64 | #include <sys/klog.h> |
|---|
| 65 | #include <sys/wait.h> |
|---|
| 66 | #define sys_stats(url) eval("stats", (url)) |
|---|
| 67 | |
|---|
| 68 | // tofu |
|---|
| 69 | |
|---|
| 70 | /* |
|---|
| 71 | * Deal with side effects before committing |
|---|
| 72 | */ |
|---|
| 73 | int sys_commit(void) |
|---|
| 74 | { |
|---|
| 75 | if (nvram_match("dhcpnvram", "1")) { |
|---|
| 76 | killall("dnsmasq", SIGUSR2); // update lease -- tofu |
|---|
| 77 | sleep(1); |
|---|
| 78 | } |
|---|
| 79 | // if (nvram_match("wan_proto", "pppoe") || nvram_match("wan_proto", |
|---|
| 80 | // "pptp") ) |
|---|
| 81 | // nvram_set("wan_ifname", "ppp0"); |
|---|
| 82 | // else |
|---|
| 83 | // nvram_set("wan_ifname", nvram_get("pppoe_ifname")); |
|---|
| 84 | return nvram_commit(); |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | /* |
|---|
| 88 | * Variables are set in order (put dependent variables later). Set |
|---|
| 89 | * nullok to TRUE to ignore zero-length values of the variable itself. |
|---|
| 90 | * For more complicated validation that cannot be done in one pass or |
|---|
| 91 | * depends on additional form components or can throw an error in a |
|---|
| 92 | * unique painful way, write your own validation routine and assign it |
|---|
| 93 | * to a hidden variable (e.g. filter_ip). |
|---|
| 94 | */ |
|---|
| 95 | /* |
|---|
| 96 | * DD-WRT enhancement by seg This functions parses all |
|---|
| 97 | * /etc/config/xxxxx.nvramconfig files and creates the web var tab. so these |
|---|
| 98 | * vars arent defined anymore staticly |
|---|
| 99 | */ |
|---|
| 100 | |
|---|
| 101 | #include <stdlib.h> |
|---|
| 102 | #include <malloc.h> |
|---|
| 103 | #include <dirent.h> |
|---|
| 104 | #include <stdlib.h> |
|---|
| 105 | |
|---|
| 106 | char *toUP(char *a) |
|---|
| 107 | { |
|---|
| 108 | int i; |
|---|
| 109 | int slen = strlen(a); |
|---|
| 110 | |
|---|
| 111 | for (i = 0; i < slen; i++) { |
|---|
| 112 | if (a[i] > 'a' - 1 && a[i] < 'z' + 1) |
|---|
| 113 | a[i] -= 'a' + 'A'; |
|---|
| 114 | } |
|---|
| 115 | return a; |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | int stricmp(char *a, char *b) |
|---|
| 119 | { |
|---|
| 120 | if (strlen(a) != strlen(b)) |
|---|
| 121 | return -1; |
|---|
| 122 | return strcmp(toUP(a), toUP(b)); |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | void StringStart(FILE * in) |
|---|
| 126 | { |
|---|
| 127 | while (getc(in) != '"') { |
|---|
| 128 | if (feof(in)) |
|---|
| 129 | return; |
|---|
| 130 | } |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | char *getFileString(FILE * in) |
|---|
| 134 | { |
|---|
| 135 | char *buf; |
|---|
| 136 | int i, b; |
|---|
| 137 | |
|---|
| 138 | buf = malloc(1024); |
|---|
| 139 | StringStart(in); |
|---|
| 140 | for (i = 0; i < 1024; i++) { |
|---|
| 141 | b = getc(in); |
|---|
| 142 | if (b == EOF) |
|---|
| 143 | return NULL; |
|---|
| 144 | if (b == '"') { |
|---|
| 145 | buf[i] = 0; |
|---|
| 146 | buf = realloc(buf, strlen(buf) + 1); |
|---|
| 147 | return buf; |
|---|
| 148 | } |
|---|
| 149 | buf[i] = b; |
|---|
| 150 | } |
|---|
| 151 | return buf; |
|---|
| 152 | } |
|---|
| 153 | |
|---|
| 154 | void skipFileString(FILE * in) |
|---|
| 155 | { |
|---|
| 156 | int i, b; |
|---|
| 157 | |
|---|
| 158 | StringStart(in); |
|---|
| 159 | for (i = 0; i < 1024; i++) { |
|---|
| 160 | b = getc(in); |
|---|
| 161 | if (b == EOF) |
|---|
| 162 | return; |
|---|
| 163 | if (b == '"') { |
|---|
| 164 | return; |
|---|
| 165 | } |
|---|
| 166 | } |
|---|
| 167 | return; |
|---|
| 168 | } |
|---|
| 169 | |
|---|
| 170 | static char *directories[] = { |
|---|
| 171 | "/etc/config", |
|---|
| 172 | "/jffs/etc/config", |
|---|
| 173 | "/mmc/etc/config" |
|---|
| 174 | }; |
|---|
| 175 | |
|---|
| 176 | struct variable **variables; |
|---|
| 177 | void Initnvramtab() |
|---|
| 178 | { |
|---|
| 179 | struct dirent *entry; |
|---|
| 180 | DIR *directory; |
|---|
| 181 | FILE *in; |
|---|
| 182 | int varcount = 0, len, i; |
|---|
| 183 | char *tmpstr; |
|---|
| 184 | struct variable *tmp; |
|---|
| 185 | |
|---|
| 186 | variables = NULL; |
|---|
| 187 | char buf[1024]; |
|---|
| 188 | |
|---|
| 189 | // format = VARNAME VARDESC VARVALID VARVALIDARGS FLAGS FLAGS |
|---|
| 190 | // open config directory directory = |
|---|
| 191 | int idx; |
|---|
| 192 | |
|---|
| 193 | for (idx = 0; idx < 3; idx++) { |
|---|
| 194 | directory = opendir(directories[idx]); |
|---|
| 195 | if (directory == NULL) |
|---|
| 196 | continue; |
|---|
| 197 | // list all files in this directory |
|---|
| 198 | while ((entry = readdir(directory)) != NULL) { |
|---|
| 199 | if (endswith(entry->d_name, ".nvramconfig")) { |
|---|
| 200 | sprintf(buf, "%s/%s", directories[idx], |
|---|
| 201 | entry->d_name); |
|---|
| 202 | in = fopen(buf, "rb"); |
|---|
| 203 | if (in == NULL) { |
|---|
| 204 | return; |
|---|
| 205 | } |
|---|
| 206 | while (1) { |
|---|
| 207 | tmp = (struct variable *) |
|---|
| 208 | malloc(sizeof(struct variable)); |
|---|
| 209 | memset(tmp, 0, sizeof(struct variable)); |
|---|
| 210 | tmp->name = getFileString(in); |
|---|
| 211 | if (tmp->name == NULL) |
|---|
| 212 | break; |
|---|
| 213 | skipFileString(in); // long string |
|---|
| 214 | tmpstr = getFileString(in); |
|---|
| 215 | tmp->argv = NULL; |
|---|
| 216 | if (!stricmp(tmpstr, "RANGE")) { |
|---|
| 217 | tmp->validatename = |
|---|
| 218 | "validate_range"; |
|---|
| 219 | tmp->argv = (char **) |
|---|
| 220 | malloc(sizeof(char **) * 3); |
|---|
| 221 | tmp->argv[0] = |
|---|
| 222 | getFileString(in); |
|---|
| 223 | tmp->argv[1] = |
|---|
| 224 | getFileString(in); |
|---|
| 225 | tmp->argv[2] = NULL; |
|---|
| 226 | } |
|---|
| 227 | if (!stricmp(tmpstr, "CHOICE")) { |
|---|
| 228 | tmp->validatename = |
|---|
| 229 | "validate_choice"; |
|---|
| 230 | free(tmpstr); |
|---|
| 231 | tmpstr = getFileString(in); |
|---|
| 232 | len = atoi(tmpstr); |
|---|
| 233 | tmp->argv = (char **) |
|---|
| 234 | malloc(sizeof(char **) * |
|---|
| 235 | (len + 1)); |
|---|
| 236 | for (i = 0; i < len; i++) { |
|---|
| 237 | tmp->argv[i] = |
|---|
| 238 | getFileString(in); |
|---|
| 239 | } |
|---|
| 240 | tmp->argv[i] = NULL; |
|---|
| 241 | } |
|---|
| 242 | #ifdef HAVE_SPUTNIK_APD |
|---|
| 243 | if (!stricmp(tmpstr, "MJIDTYPE")) { |
|---|
| 244 | tmp->validatename = |
|---|
| 245 | "validate_choice"; |
|---|
| 246 | free(tmpstr); |
|---|
| 247 | tmpstr = getFileString(in); |
|---|
| 248 | len = atoi(tmpstr); |
|---|
| 249 | tmp->argv = (char **) |
|---|
| 250 | malloc(sizeof(char **) * |
|---|
| 251 | (len + 1)); |
|---|
| 252 | for (i = 0; i < len; i++) { |
|---|
| 253 | tmp->argv[i] = |
|---|
| 254 | getFileString(in); |
|---|
| 255 | } |
|---|
| 256 | tmp->argv[i] = NULL; |
|---|
| 257 | nvram_set("sputnik_rereg", "1"); |
|---|
| 258 | } |
|---|
| 259 | #endif |
|---|
| 260 | if (!stricmp(tmpstr, "NOACK")) { |
|---|
| 261 | tmp->validatename = |
|---|
| 262 | "validate_noack"; |
|---|
| 263 | len = 2; |
|---|
| 264 | tmp->argv = (char **) |
|---|
| 265 | malloc(sizeof(char **) * |
|---|
| 266 | (len + 1)); |
|---|
| 267 | for (i = 0; i < len; i++) { |
|---|
| 268 | tmp->argv[i] = |
|---|
| 269 | getFileString(in); |
|---|
| 270 | } |
|---|
| 271 | tmp->argv[i] = NULL; |
|---|
| 272 | } |
|---|
| 273 | if (!stricmp(tmpstr, "NAME")) { |
|---|
| 274 | tmp->validatename = |
|---|
| 275 | "validate_name"; |
|---|
| 276 | tmp->argv = (char **) |
|---|
| 277 | malloc(sizeof(char **) * 2); |
|---|
| 278 | tmp->argv[0] = |
|---|
| 279 | getFileString(in); |
|---|
| 280 | tmp->argv[1] = NULL; |
|---|
| 281 | } |
|---|
| 282 | if (!stricmp(tmpstr, "NULL")) { |
|---|
| 283 | } |
|---|
| 284 | if (!stricmp(tmpstr, "WMEPARAM")) { |
|---|
| 285 | tmp->validatename = |
|---|
| 286 | "validate_wl_wme_params"; |
|---|
| 287 | } |
|---|
| 288 | if (!stricmp(tmpstr, "WMETXPARAM")) { |
|---|
| 289 | tmp->validatename = |
|---|
| 290 | "validate_wl_wme_tx_params"; |
|---|
| 291 | } |
|---|
| 292 | if (!stricmp(tmpstr, "PASSWORD")) { |
|---|
| 293 | tmp->validatename = |
|---|
| 294 | "validate_password"; |
|---|
| 295 | tmp->argv = (char **) |
|---|
| 296 | malloc(sizeof(char **) * 2); |
|---|
| 297 | tmp->argv[0] = |
|---|
| 298 | getFileString(in); |
|---|
| 299 | tmp->argv[1] = NULL; |
|---|
| 300 | } |
|---|
| 301 | if (!stricmp(tmpstr, "PASSWORD2")) { |
|---|
| 302 | tmp->validatename = |
|---|
| 303 | "validate_password2"; |
|---|
| 304 | tmp->argv = (char **) |
|---|
| 305 | malloc(sizeof(char **) * 2); |
|---|
| 306 | tmp->argv[0] = |
|---|
| 307 | getFileString(in); |
|---|
| 308 | tmp->argv[1] = NULL; |
|---|
| 309 | } |
|---|
| 310 | if (!stricmp(tmpstr, "LANIPADDR")) { |
|---|
| 311 | tmp->validatename = |
|---|
| 312 | "validate_lan_ipaddr"; |
|---|
| 313 | tmp->argv = (char **) |
|---|
| 314 | malloc(sizeof(char **) * 2); |
|---|
| 315 | tmp->argv[0] = |
|---|
| 316 | getFileString(in); |
|---|
| 317 | tmp->argv[1] = NULL; |
|---|
| 318 | } |
|---|
| 319 | if (!stricmp(tmpstr, "WANIPADDR")) { |
|---|
| 320 | tmp->validatename = |
|---|
| 321 | "validate_wan_ipaddr"; |
|---|
| 322 | } |
|---|
| 323 | if (!stricmp(tmpstr, "MERGEREMOTEIP")) { |
|---|
| 324 | tmp->validatename = |
|---|
| 325 | "validate_remote_ip"; |
|---|
| 326 | } |
|---|
| 327 | if (!stricmp(tmpstr, "MERGEIPADDRS")) { |
|---|
| 328 | tmp->validatename = |
|---|
| 329 | "validate_merge_ipaddrs"; |
|---|
| 330 | } |
|---|
| 331 | if (!stricmp(tmpstr, "DNS")) { |
|---|
| 332 | tmp->validatename = |
|---|
| 333 | "validate_dns"; |
|---|
| 334 | } |
|---|
| 335 | if (!stricmp(tmpstr, "SAVEWDS")) { |
|---|
| 336 | tmp->validate2name = "save_wds"; |
|---|
| 337 | } |
|---|
| 338 | if (!stricmp(tmpstr, "DHCP")) { |
|---|
| 339 | tmp->validatename = |
|---|
| 340 | "dhcp_check"; |
|---|
| 341 | } |
|---|
| 342 | if (!stricmp(tmpstr, "WPAPSK")) { |
|---|
| 343 | tmp->validatename = |
|---|
| 344 | "validate_wpa_psk"; |
|---|
| 345 | tmp->argv = (char **) |
|---|
| 346 | malloc(sizeof(char **) * 2); |
|---|
| 347 | tmp->argv[0] = |
|---|
| 348 | getFileString(in); |
|---|
| 349 | tmp->argv[1] = NULL; |
|---|
| 350 | } |
|---|
| 351 | if (!stricmp(tmpstr, "STATICS")) { |
|---|
| 352 | tmp->validatename = |
|---|
| 353 | "validate_statics"; |
|---|
| 354 | } |
|---|
| 355 | #ifdef HAVE_PORTSETUP |
|---|
| 356 | if (!stricmp(tmpstr, "PORTSETUP")) { |
|---|
| 357 | tmp->validatename = |
|---|
| 358 | "validate_portsetup"; |
|---|
| 359 | } |
|---|
| 360 | #endif |
|---|
| 361 | if (!stricmp(tmpstr, "REBOOT")) { |
|---|
| 362 | tmp->validatename = |
|---|
| 363 | "validate_reboot"; |
|---|
| 364 | } |
|---|
| 365 | if (!stricmp(tmpstr, "IPADDR")) { |
|---|
| 366 | tmp->validatename = |
|---|
| 367 | "validate_ipaddr"; |
|---|
| 368 | } |
|---|
| 369 | if (!stricmp(tmpstr, "STATICLEASES")) { |
|---|
| 370 | tmp->validatename = |
|---|
| 371 | "validate_staticleases"; |
|---|
| 372 | } |
|---|
| 373 | #ifdef HAVE_CHILLILOCAL |
|---|
| 374 | if (!stricmp(tmpstr, "USERLIST")) { |
|---|
| 375 | tmp->validatename = |
|---|
| 376 | "validate_userlist"; |
|---|
| 377 | } |
|---|
| 378 | #endif |
|---|
| 379 | #ifdef HAVE_RADLOCAL |
|---|
| 380 | if (!stricmp(tmpstr, "IRADIUSUSERLIST")) { |
|---|
| 381 | tmp->validatename = |
|---|
| 382 | "validate_iradius"; |
|---|
| 383 | } |
|---|
| 384 | #endif |
|---|
| 385 | if (!stricmp(tmpstr, "IPADDRS")) { |
|---|
| 386 | tmp->validatename = |
|---|
| 387 | "validate_ipaddrs"; |
|---|
| 388 | } |
|---|
| 389 | if (!stricmp(tmpstr, "NETMASK")) { |
|---|
| 390 | tmp->validatename = |
|---|
| 391 | "validate_netmask"; |
|---|
| 392 | } |
|---|
| 393 | if (!stricmp(tmpstr, "MERGENETMASK")) { |
|---|
| 394 | tmp->validatename = |
|---|
| 395 | "validate_merge_netmask"; |
|---|
| 396 | } |
|---|
| 397 | if (!stricmp(tmpstr, "WDS")) { |
|---|
| 398 | tmp->validatename = |
|---|
| 399 | "validate_wds"; |
|---|
| 400 | } |
|---|
| 401 | if (!stricmp(tmpstr, "STATICROUTE")) { |
|---|
| 402 | tmp->validatename = |
|---|
| 403 | "validate_static_route"; |
|---|
| 404 | } |
|---|
| 405 | if (!stricmp(tmpstr, "MERGEMAC")) { |
|---|
| 406 | tmp->validatename = |
|---|
| 407 | "validate_merge_mac"; |
|---|
| 408 | } |
|---|
| 409 | if (!stricmp(tmpstr, "FILTERPOLICY")) { |
|---|
| 410 | tmp->validatename = |
|---|
| 411 | "validate_filter_policy"; |
|---|
| 412 | } |
|---|
| 413 | if (!stricmp(tmpstr, "FILTERIPGRP")) { |
|---|
| 414 | tmp->validatename = |
|---|
| 415 | "validate_filter_ip_grp"; |
|---|
| 416 | } |
|---|
| 417 | if (!stricmp(tmpstr, "FILTERPORT")) { |
|---|
| 418 | tmp->validatename = |
|---|
| 419 | "validate_filter_port"; |
|---|
| 420 | } |
|---|
| 421 | if (!stricmp(tmpstr, "FILTERDPORTGRP")) { |
|---|
| 422 | tmp->validatename = |
|---|
| 423 | "validate_filter_dport_grp"; |
|---|
| 424 | } |
|---|
| 425 | if (!stricmp(tmpstr, "BLOCKEDSERVICE")) { |
|---|
| 426 | tmp->validatename = |
|---|
| 427 | "validate_blocked_service"; |
|---|
| 428 | } |
|---|
| 429 | if (!stricmp(tmpstr, "FILTERP2P")) { |
|---|
| 430 | tmp->validatename = |
|---|
| 431 | "validate_catchall"; |
|---|
| 432 | } |
|---|
| 433 | if (!stricmp(tmpstr, "FILTERMACGRP")) { |
|---|
| 434 | tmp->validatename = |
|---|
| 435 | "validate_filter_mac_grp"; |
|---|
| 436 | } |
|---|
| 437 | if (!stricmp(tmpstr, "FILTERWEB")) { |
|---|
| 438 | tmp->validatename = |
|---|
| 439 | "validate_filter_web"; |
|---|
| 440 | } |
|---|
| 441 | if (!stricmp(tmpstr, "WLHWADDRS")) { |
|---|
| 442 | tmp->validatename = |
|---|
| 443 | "validate_wl_hwaddrs"; |
|---|
| 444 | } |
|---|
| 445 | if (!stricmp(tmpstr, "FORWARDPROTO")) { |
|---|
| 446 | tmp->validatename = |
|---|
| 447 | "validate_forward_proto"; |
|---|
| 448 | } |
|---|
| 449 | if (!stricmp(tmpstr, "FORWARDSPEC")) { |
|---|
| 450 | tmp->validatename = |
|---|
| 451 | "validate_forward_spec"; |
|---|
| 452 | } |
|---|
| 453 | // changed by steve |
|---|
| 454 | /* |
|---|
| 455 | * if (!stricmp (tmpstr, "FORWARDUPNP")) { tmp->validate |
|---|
| 456 | * = validate_forward_upnp; } |
|---|
| 457 | */ |
|---|
| 458 | // end changed by steve |
|---|
| 459 | if (!stricmp(tmpstr, "PORTTRIGGER")) { |
|---|
| 460 | tmp->validatename = |
|---|
| 461 | "validate_port_trigger"; |
|---|
| 462 | } |
|---|
| 463 | if (!stricmp(tmpstr, "HWADDR")) { |
|---|
| 464 | tmp->validatename = |
|---|
| 465 | "validate_hwaddr"; |
|---|
| 466 | } |
|---|
| 467 | if (!stricmp(tmpstr, "HWADDRS")) { |
|---|
| 468 | tmp->validatename = |
|---|
| 469 | "validate_hwaddrs"; |
|---|
| 470 | } |
|---|
| 471 | if (!stricmp(tmpstr, "WLWEPKEY")) { |
|---|
| 472 | tmp->validatename = |
|---|
| 473 | "validate_wl_wep_key"; |
|---|
| 474 | } |
|---|
| 475 | |
|---|
| 476 | if (!stricmp(tmpstr, "WLAUTH")) { |
|---|
| 477 | tmp->validatename = |
|---|
| 478 | "validate_wl_auth"; |
|---|
| 479 | tmp->argv = (char **) |
|---|
| 480 | malloc(sizeof(char **) * 3); |
|---|
| 481 | tmp->argv[0] = |
|---|
| 482 | getFileString(in); |
|---|
| 483 | tmp->argv[1] = |
|---|
| 484 | getFileString(in); |
|---|
| 485 | tmp->argv[2] = NULL; |
|---|
| 486 | } |
|---|
| 487 | if (!stricmp(tmpstr, "WLWEP")) { |
|---|
| 488 | tmp->validatename = |
|---|
| 489 | "validate_wl_wep"; |
|---|
| 490 | free(tmpstr); |
|---|
| 491 | tmpstr = getFileString(in); |
|---|
| 492 | len = atoi(tmpstr); |
|---|
| 493 | tmp->argv = (char **) |
|---|
| 494 | malloc(sizeof(char **) * |
|---|
| 495 | (len + 1)); |
|---|
| 496 | for (i = 0; i < len; i++) { |
|---|
| 497 | tmp->argv[i] = |
|---|
| 498 | getFileString(in); |
|---|
| 499 | } |
|---|
| 500 | tmp->argv[i] = NULL; |
|---|
| 501 | } |
|---|
| 502 | |
|---|
| 503 | if (!stricmp(tmpstr, "DYNAMICROUTE")) { |
|---|
| 504 | tmp->validatename = |
|---|
| 505 | "validate_dynamic_route"; |
|---|
| 506 | free(tmpstr); |
|---|
| 507 | tmpstr = getFileString(in); |
|---|
| 508 | len = atoi(tmpstr); |
|---|
| 509 | tmp->argv = (char **) |
|---|
| 510 | malloc(sizeof(char **) * |
|---|
| 511 | (len + 1)); |
|---|
| 512 | for (i = 0; i < len; i++) { |
|---|
| 513 | tmp->argv[i] = |
|---|
| 514 | getFileString(in); |
|---|
| 515 | } |
|---|
| 516 | tmp->argv[i] = NULL; |
|---|
| 517 | } |
|---|
| 518 | if (!stricmp(tmpstr, "WLGMODE")) { |
|---|
| 519 | tmp->validatename = |
|---|
| 520 | "validate_wl_gmode"; |
|---|
| 521 | free(tmpstr); |
|---|
| 522 | tmpstr = getFileString(in); |
|---|
| 523 | len = atoi(tmpstr); |
|---|
| 524 | tmp->argv = (char **) |
|---|
| 525 | malloc(sizeof(char **) * |
|---|
| 526 | (len + 1)); |
|---|
| 527 | for (i = 0; i < len; i++) { |
|---|
| 528 | tmp->argv[i] = |
|---|
| 529 | getFileString(in); |
|---|
| 530 | } |
|---|
| 531 | tmp->argv[i] = NULL; |
|---|
| 532 | } |
|---|
| 533 | if (!stricmp(tmpstr, "WLNETMODE")) { |
|---|
| 534 | tmp->validatename = |
|---|
| 535 | "validate_wl_net_mode"; |
|---|
| 536 | free(tmpstr); |
|---|
| 537 | tmpstr = getFileString(in); |
|---|
| 538 | len = atoi(tmpstr); |
|---|
| 539 | tmp->argv = (char **) |
|---|
| 540 | malloc(sizeof(char **) * |
|---|
| 541 | (len + 1)); |
|---|
| 542 | for (i = 0; i < len; i++) { |
|---|
| 543 | tmp->argv[i] = |
|---|
| 544 | getFileString(in); |
|---|
| 545 | } |
|---|
| 546 | tmp->argv[i] = NULL; |
|---|
| 547 | } |
|---|
| 548 | if (!stricmp(tmpstr, "AUTHMODE")) { |
|---|
| 549 | tmp->validatename = |
|---|
| 550 | "validate_auth_mode"; |
|---|
| 551 | free(tmpstr); |
|---|
| 552 | tmpstr = getFileString(in); |
|---|
| 553 | len = atoi(tmpstr); |
|---|
| 554 | tmp->argv = (char **) |
|---|
| 555 | malloc(sizeof(char **) * |
|---|
| 556 | (len + 1)); |
|---|
| 557 | for (i = 0; i < len; i++) { |
|---|
| 558 | tmp->argv[i] = |
|---|
| 559 | getFileString(in); |
|---|
| 560 | } |
|---|
| 561 | tmp->argv[i] = NULL; |
|---|
| 562 | } |
|---|
| 563 | #ifdef HAVE_PPPOESERVER |
|---|
| 564 | if (!stricmp(tmpstr, "CHAPTABLE")) { |
|---|
| 565 | tmp->validatename = |
|---|
| 566 | "validate_chaps"; |
|---|
| 567 | } |
|---|
| 568 | #endif |
|---|
| 569 | |
|---|
| 570 | #ifdef HAVE_MILKFISH |
|---|
| 571 | if (!stricmp(tmpstr, "MFSUBSCRIBERS")) { |
|---|
| 572 | tmp->validatename = |
|---|
| 573 | "validate_subscribers"; |
|---|
| 574 | } |
|---|
| 575 | if (!stricmp(tmpstr, "MFALIASES")) { |
|---|
| 576 | tmp->validatename = |
|---|
| 577 | "validate_aliases"; |
|---|
| 578 | } |
|---|
| 579 | #endif |
|---|
| 580 | |
|---|
| 581 | free(tmpstr); |
|---|
| 582 | tmpstr = getFileString(in); |
|---|
| 583 | if (!stricmp(tmpstr, "TRUE")) { |
|---|
| 584 | tmp->nullok = TRUE; |
|---|
| 585 | } else { |
|---|
| 586 | tmp->nullok = FALSE; |
|---|
| 587 | } |
|---|
| 588 | free(tmpstr); |
|---|
| 589 | skipFileString(in); // todo: remove it |
|---|
| 590 | // tmpstr = getFileString (in); |
|---|
| 591 | // tmp->ezc_flags = atoi (tmpstr); |
|---|
| 592 | // free (tmpstr); |
|---|
| 593 | variables = (struct variable **) |
|---|
| 594 | realloc(variables, |
|---|
| 595 | sizeof(struct variable **) * |
|---|
| 596 | (varcount + 2)); |
|---|
| 597 | variables[varcount++] = tmp; |
|---|
| 598 | variables[varcount] = NULL; |
|---|
| 599 | } |
|---|
| 600 | fclose(in); |
|---|
| 601 | } |
|---|
| 602 | } |
|---|
| 603 | closedir(directory); |
|---|
| 604 | } |
|---|
| 605 | } |
|---|
| 606 | |
|---|
| 607 | #ifdef HAVE_MACBIND |
|---|
| 608 | #include "../../../opt/mac.h" |
|---|
| 609 | #endif |
|---|
| 610 | // Added by Daniel(2004-07-29) for EZC |
|---|
| 611 | int variables_arraysize(void) |
|---|
| 612 | { |
|---|
| 613 | int varcount = 0; |
|---|
| 614 | |
|---|
| 615 | if (variables == NULL) |
|---|
| 616 | return 0; |
|---|
| 617 | while (variables[varcount] != NULL) { |
|---|
| 618 | varcount++; |
|---|
| 619 | } |
|---|
| 620 | // return ARRAYSIZE(variables); |
|---|
| 621 | return varcount; |
|---|
| 622 | } |
|---|
| 623 | |
|---|
| 624 | // and now the tricky part (more dirty as dirty) |
|---|
| 625 | void do_filtertable(struct mime_handler *handler, char *path, webs_t stream, |
|---|
| 626 | char *query) |
|---|
| 627 | { |
|---|
| 628 | char *temp2 = &path[indexof(path, '-') + 1]; |
|---|
| 629 | char ifname[16]; |
|---|
| 630 | |
|---|
| 631 | strcpy(ifname, temp2); |
|---|
| 632 | ifname[indexof(ifname, '.')] = 0; |
|---|
| 633 | FILE *web = getWebsFile("WL_FilterTable.asp"); |
|---|
| 634 | char temp[4096]; |
|---|
| 635 | |
|---|
| 636 | memset(temp, 0, 4096); |
|---|
| 637 | unsigned int len = getWebsFileLen("WL_FilterTable.asp"); |
|---|
| 638 | char *webfile = (char *)malloc(len + 1); |
|---|
| 639 | |
|---|
| 640 | fread(webfile, len, 1, web); |
|---|
| 641 | webfile[len] = 0; |
|---|
| 642 | sprintf(temp, webfile, ifname, ifname, ifname, ifname, ifname, ifname); |
|---|
| 643 | free(webfile); |
|---|
| 644 | fclose(web); |
|---|
| 645 | do_ej_buffer(temp, stream); |
|---|
| 646 | } |
|---|
| 647 | |
|---|
| 648 | void do_activetable(struct mime_handler *handler, char *path, webs_t stream, |
|---|
| 649 | char *query) |
|---|
| 650 | { |
|---|
| 651 | char *temp2 = &path[indexof(path, '-') + 1]; |
|---|
| 652 | char ifname[16]; |
|---|
| 653 | |
|---|
| 654 | strcpy(ifname, temp2); |
|---|
| 655 | ifname[indexof(ifname, '.')] = 0; |
|---|
| 656 | FILE *web = getWebsFile("WL_ActiveTable.asp"); |
|---|
| 657 | unsigned int len = getWebsFileLen("WL_ActiveTable.asp"); |
|---|
| 658 | char *webfile = (char *)malloc(len + 1); |
|---|
| 659 | |
|---|
| 660 | fread(webfile, len, 1, web); |
|---|
| 661 | webfile[len] = 0; |
|---|
| 662 | fclose(web); |
|---|
| 663 | |
|---|
| 664 | char temp[32768]; |
|---|
| 665 | |
|---|
| 666 | memset(temp, 0, 32768); |
|---|
| 667 | int ai = 0; |
|---|
| 668 | int i = 0; |
|---|
| 669 | int weblen = strlen(webfile); |
|---|
| 670 | |
|---|
| 671 | for (i = 0; i < weblen; i++) { |
|---|
| 672 | if (webfile[i] == '%') { |
|---|
| 673 | i++; |
|---|
| 674 | switch (webfile[i]) { |
|---|
| 675 | case '%': |
|---|
| 676 | temp[ai++] = '%'; |
|---|
| 677 | break; |
|---|
| 678 | case 's': |
|---|
| 679 | strcpy(&temp[ai], ifname); |
|---|
| 680 | ai += strlen(ifname); |
|---|
| 681 | break; |
|---|
| 682 | default: |
|---|
| 683 | temp[ai++] = webfile[i]; |
|---|
| 684 | break; |
|---|
| 685 | } |
|---|
| 686 | } else |
|---|
| 687 | temp[ai++] = webfile[i]; |
|---|
| 688 | } |
|---|
| 689 | free(webfile); |
|---|
| 690 | do_ej_buffer(temp, stream); |
|---|
| 691 | } |
|---|
| 692 | |
|---|
| 693 | void do_wds(struct mime_handler *handler, char *path, webs_t stream, |
|---|
| 694 | char *query) |
|---|
| 695 | { |
|---|
| 696 | char *temp2 = &path[indexof(path, '-') + 1]; |
|---|
| 697 | char ifname[16]; |
|---|
| 698 | |
|---|
| 699 | strcpy(ifname, temp2); |
|---|
| 700 | ifname[indexof(ifname, '.')] = 0; |
|---|
| 701 | FILE *web = getWebsFile("Wireless_WDS.asp"); |
|---|
| 702 | unsigned int len = getWebsFileLen("Wireless_WDS.asp"); |
|---|
| 703 | char *webfile = (char *)malloc(len + 1); |
|---|
| 704 | |
|---|
| 705 | fread(webfile, len, 1, web); |
|---|
| 706 | webfile[len] = 0; |
|---|
| 707 | fclose(web); |
|---|
| 708 | |
|---|
| 709 | char temp[32768]; |
|---|
| 710 | |
|---|
| 711 | memset(temp, 0, 32768); |
|---|
| 712 | int ai = 0; |
|---|
| 713 | int i = 0; |
|---|
| 714 | int weblen = strlen(webfile); |
|---|
| 715 | |
|---|
| 716 | for (i = 0; i < weblen; i++) { |
|---|
| 717 | if (webfile[i] == '%') { |
|---|
| 718 | i++; |
|---|
| 719 | switch (webfile[i]) { |
|---|
| 720 | case '%': |
|---|
| 721 | temp[ai++] = '%'; |
|---|
| 722 | break; |
|---|
| 723 | case 's': |
|---|
| 724 | strcpy(&temp[ai], ifname); |
|---|
| 725 | ai += strlen(ifname); |
|---|
| 726 | break; |
|---|
| 727 | default: |
|---|
| 728 | temp[ai++] = webfile[i]; |
|---|
| 729 | break; |
|---|
| 730 | } |
|---|
| 731 | } else |
|---|
| 732 | temp[ai++] = webfile[i]; |
|---|
| 733 | } |
|---|
| 734 | free(webfile); |
|---|
| 735 | do_ej_buffer(temp, stream); |
|---|
| 736 | } |
|---|
| 737 | |
|---|
| 738 | void do_wireless_adv(struct mime_handler *handler, char *path, webs_t stream, |
|---|
| 739 | char *query) |
|---|
| 740 | { |
|---|
| 741 | char *temp2 = &path[indexof(path, '-') + 1]; |
|---|
| 742 | char ifname[16]; |
|---|
| 743 | |
|---|
| 744 | strcpy(ifname, temp2); |
|---|
| 745 | ifname[indexof(ifname, '.')] = 0; |
|---|
| 746 | FILE *web = getWebsFile("Wireless_Advanced.asp"); |
|---|
| 747 | unsigned int len = getWebsFileLen("Wireless_Advanced.asp"); |
|---|
| 748 | char *webfile = (char *)malloc(len + 1); |
|---|
| 749 | |
|---|
| 750 | char index[2]; |
|---|
| 751 | substring(strlen(ifname) - 1, strlen(ifname), ifname, index); |
|---|
| 752 | |
|---|
| 753 | fread(webfile, len, 1, web); |
|---|
| 754 | webfile[len] = 0; |
|---|
| 755 | fclose(web); |
|---|
| 756 | |
|---|
| 757 | char temp[65536]; |
|---|
| 758 | |
|---|
| 759 | memset(temp, 0, 65536); |
|---|
| 760 | int ai = 0; |
|---|
| 761 | int i = 0; |
|---|
| 762 | int weblen = strlen(webfile); |
|---|
| 763 | |
|---|
| 764 | for (i = 0; i < weblen; i++) { |
|---|
| 765 | if (webfile[i] == '%') { |
|---|
| 766 | i++; |
|---|
| 767 | switch (webfile[i]) { |
|---|
| 768 | case '%': |
|---|
| 769 | temp[ai++] = '%'; |
|---|
| 770 | break; |
|---|
| 771 | case 'd': |
|---|
| 772 | strcpy(&temp[ai], index); |
|---|
| 773 | ai++; |
|---|
| 774 | break; |
|---|
| 775 | case 's': |
|---|
| 776 | strcpy(&temp[ai], ifname); |
|---|
| 777 | ai += strlen(ifname); |
|---|
| 778 | break; |
|---|
| 779 | default: |
|---|
| 780 | temp[ai++] = webfile[i]; |
|---|
| 781 | break; |
|---|
| 782 | } |
|---|
| 783 | } else |
|---|
| 784 | temp[ai++] = webfile[i]; |
|---|
| 785 | } |
|---|
| 786 | free(webfile); |
|---|
| 787 | do_ej_buffer(temp, stream); |
|---|
| 788 | } |
|---|
| 789 | |
|---|
| 790 | static void validate_cgi(webs_t wp) |
|---|
| 791 | { |
|---|
| 792 | char *value; |
|---|
| 793 | int i; |
|---|
| 794 | |
|---|
| 795 | #ifdef HAVE_MACBIND |
|---|
| 796 | if (!nvram_match("et0macaddr", MACBRAND)) |
|---|
| 797 | return; |
|---|
| 798 | #endif |
|---|
| 799 | int alen = variables_arraysize(); |
|---|
| 800 | void *handle = NULL; |
|---|
| 801 | |
|---|
| 802 | for (i = 0; i < alen; i++) { |
|---|
| 803 | if (variables[i] == NULL) |
|---|
| 804 | return; |
|---|
| 805 | value = websGetVar(wp, variables[i]->name, NULL); |
|---|
| 806 | if (!value) |
|---|
| 807 | continue; |
|---|
| 808 | if ((!*value && variables[i]->nullok) |
|---|
| 809 | || (!variables[i]->validate2name |
|---|
| 810 | && !variables[i]->validatename)) |
|---|
| 811 | nvram_set(variables[i]->name, value); |
|---|
| 812 | else { |
|---|
| 813 | if (variables[i]->validatename) { |
|---|
| 814 | cprintf("call validator_nofree %s\n", |
|---|
| 815 | variables[i]->validatename); |
|---|
| 816 | handle = |
|---|
| 817 | start_validator_nofree(variables |
|---|
| 818 | [i]->validatename, |
|---|
| 819 | handle, wp, value, |
|---|
| 820 | variables[i]); |
|---|
| 821 | } else if (variables[i]->validate2name) { |
|---|
| 822 | cprintf("call gozila %s\n", |
|---|
| 823 | variables[i]->validate2name); |
|---|
| 824 | start_gozila(variables[i]->validate2name, wp); |
|---|
| 825 | // fprintf(stderr,"validating %s = |
|---|
| 826 | // %s\n",variables[i]->name,value); |
|---|
| 827 | // variables[i]->validate (wp, value, variables[i]); |
|---|
| 828 | } else { |
|---|
| 829 | // variables[i]->validate2 (wp); |
|---|
| 830 | } |
|---|
| 831 | } |
|---|
| 832 | |
|---|
| 833 | } |
|---|
| 834 | cprintf("close handle\n"); |
|---|
| 835 | if (handle) |
|---|
| 836 | dlclose(handle); |
|---|
| 837 | cprintf("all vars validated\n"); |
|---|
| 838 | } |
|---|
| 839 | |
|---|
| 840 | enum { |
|---|
| 841 | NOTHING, |
|---|
| 842 | REBOOT, |
|---|
| 843 | RESTART, |
|---|
| 844 | SERVICE_RESTART, |
|---|
| 845 | SYS_RESTART, |
|---|
| 846 | REFRESH, |
|---|
| 847 | }; |
|---|
| 848 | |
|---|
| 849 | static struct gozila_action gozila_actions[] = { |
|---|
| 850 | /* |
|---|
| 851 | * SETUP |
|---|
| 852 | */ |
|---|
| 853 | {"index", "wan_proto", "", 1, REFRESH, "wan_proto"}, |
|---|
| 854 | {"index", "dhcpfwd", "", 1, REFRESH, "dhcpfwd"}, |
|---|
| 855 | // {"index", "clone_mac", "", 1, REFRESH, clone_mac}, //OBSOLETE |
|---|
| 856 | #ifdef HAVE_CCONTROL |
|---|
| 857 | {"ccontrol", "execute", "", 1, REFRESH, "execute"}, |
|---|
| 858 | #endif |
|---|
| 859 | {"WanMAC", "clone_mac", "", 1, REFRESH, "clone_mac"}, // for cisco |
|---|
| 860 | // style |
|---|
| 861 | {"DHCPTable", "delete", "", 2, REFRESH, "delete_leases"}, |
|---|
| 862 | {"Info", "refresh", "", 0, REFRESH, "save_wifi"}, |
|---|
| 863 | {"Status_Wireless", "refresh", "", 0, REFRESH, "save_wifi"}, |
|---|
| 864 | // {"Status", "release", "dhcp_release", 0, SYS_RESTART, "dhcp_release"}, |
|---|
| 865 | // {"Status", "renew", "", 3, REFRESH, "dhcp_renew"}, |
|---|
| 866 | // {"Status", "Connect", "start_pppoe", 1, RESTART, NULL}, |
|---|
| 867 | {"Status_Internet", "release", "dhcp_release", 0, SERVICE_RESTART, "dhcp_release"}, // for |
|---|
| 868 | {"Status_Internet", "renew", "", 3, REFRESH, "dhcp_renew"}, // for cisco |
|---|
| 869 | {"Status_Internet", "Disconnect", "stop_pppoe", 2, SERVICE_RESTART, "stop_ppp"}, // for |
|---|
| 870 | #ifdef HAVE_3G |
|---|
| 871 | {"Status_Internet", "Connect_3g", "start_3g", 1, RESTART, NULL}, // for |
|---|
| 872 | {"Status_Internet", "Disconnect_3g", "stop_3g", 2, SERVICE_RESTART, "stop_ppp"}, // for |
|---|
| 873 | #endif |
|---|
| 874 | {"Status_Internet", "Connect_pppoe", "start_pppoe", 1, RESTART, NULL}, // for |
|---|
| 875 | {"Status_Internet", "Disconnect_pppoe", "stop_pppoe", 2, SERVICE_RESTART, "stop_ppp"}, // for |
|---|
| 876 | |
|---|
| 877 | {"Status_Internet", "Connect_pptp", "start_pptp", 1, RESTART, NULL}, // for |
|---|
| 878 | {"Status_Internet", "Disconnect_pptp", "stop_pptp", 2, SERVICE_RESTART, "stop_ppp"}, // for |
|---|
| 879 | {"Status_Internet", "Connect_l2tp", "start_l2tp", 1, RESTART, NULL}, // for |
|---|
| 880 | {"Status_Internet", "Disconnect_l2tp", "stop_l2tp", 2, SERVICE_RESTART, "stop_ppp"}, // for |
|---|
| 881 | // cisco |
|---|
| 882 | // style{ |
|---|
| 883 | // "Status_Router", |
|---|
| 884 | // "Connect_heartbeat", |
|---|
| 885 | // "start_heartbeat", |
|---|
| 886 | // 1, |
|---|
| 887 | // RESTART, |
|---|
| 888 | // NULL}, |
|---|
| 889 | // // |
|---|
| 890 | // for |
|---|
| 891 | // cisco |
|---|
| 892 | // style |
|---|
| 893 | {"Status_Internet", "Disconnect_heartbeat", "stop_heartbeat", 2, SERVICE_RESTART, "stop_ppp"}, // for |
|---|
| 894 | // cisco |
|---|
| 895 | // style |
|---|
| 896 | {"Status_Internet", "delete_ttraffdata", "", 0, REFRESH, |
|---|
| 897 | "ttraff_erase"}, |
|---|
| 898 | {"Filters", "save", "filters", 1, REFRESH, "save_policy"}, |
|---|
| 899 | {"Filters", "delete", "filters", 1, REFRESH, "single_delete_policy"}, |
|---|
| 900 | {"FilterSummary", "delete", "filters", 1, REFRESH, |
|---|
| 901 | "summary_delete_policy"}, |
|---|
| 902 | {"Routing", "del", "static_route_del", 1, REFRESH, |
|---|
| 903 | "delete_static_route"}, |
|---|
| 904 | {"RouteStatic", "del", "static_route_del", 1, REFRESH, |
|---|
| 905 | "delete_static_route"}, |
|---|
| 906 | {"WL_WPATable", "wep_key_generate", "", 1, REFRESH, "generate_wep_key"}, |
|---|
| 907 | {"WL_WPATable", "security", "", 1, REFRESH, "set_security"}, |
|---|
| 908 | {"WL_WPATable", "save", "wireless_2", 1, REFRESH, "security_save"}, |
|---|
| 909 | {"WL_WPATable", "keysize", "wireless_2", 1, REFRESH, "security_save"}, |
|---|
| 910 | {"WL_ActiveTable-wl0", "add_mac", "", 1, REFRESH, "add_active_mac"}, |
|---|
| 911 | {"WL_ActiveTable-wl1", "add_mac", "", 1, REFRESH, "add_active_mac"}, |
|---|
| 912 | /* |
|---|
| 913 | * Siafu addition |
|---|
| 914 | */ |
|---|
| 915 | {"Ping", "wol", "", 1, REFRESH, "ping_wol"}, |
|---|
| 916 | /* |
|---|
| 917 | * Sveasoft addition |
|---|
| 918 | */ |
|---|
| 919 | // {"Wireless_WDS", "save", "", 0, REFRESH, save_wds}, |
|---|
| 920 | #ifndef HAVE_MADWIFI |
|---|
| 921 | {"Wireless_WDS-wl0", "save", "wireless_2", 0, REFRESH, "save_wds"}, |
|---|
| 922 | {"Wireless_WDS-wl1", "save", "wireless_2", 0, REFRESH, "save_wds"}, |
|---|
| 923 | {"Wireless_Advanced-wl0", "save", "wireless_2", 0, REFRESH, |
|---|
| 924 | "save_wireless_advanced"}, |
|---|
| 925 | {"Wireless_Advanced-wl1", "save", "wireless_2", 0, REFRESH, |
|---|
| 926 | "save_wireless_advanced"}, |
|---|
| 927 | #else |
|---|
| 928 | {"Wireless_WDS-ath0", "save", "wireless_2", 0, REFRESH, "save_wds"}, |
|---|
| 929 | {"Wireless_WDS-ath1", "save", "wireless_2", 0, REFRESH, "save_wds"}, |
|---|
| 930 | {"Wireless_WDS-ath2", "save", "wireless_2", 0, REFRESH, "save_wds"}, |
|---|
| 931 | {"Wireless_WDS-ath3", "save", "wireless_2", 0, REFRESH, "save_wds"}, |
|---|
| 932 | #endif |
|---|
| 933 | {"Ping", "startup", "", 1, SYS_RESTART, "ping_startup"}, |
|---|
| 934 | {"Ping", "shutdown", "", 1, SYS_RESTART, "ping_shutdown"}, |
|---|
| 935 | {"Ping", "firewall", "", 1, SYS_RESTART, "ping_firewall"}, |
|---|
| 936 | {"Ping", "custom", "", 0, REFRESH, "ping_custom"}, |
|---|
| 937 | {"QoS", "add_svc", "", 0, REFRESH, "qos_add_svc"}, |
|---|
| 938 | {"QoS", "add_ip", "", 0, REFRESH, "qos_add_ip"}, |
|---|
| 939 | {"QoS", "add_mac", "", 0, REFRESH, "qos_add_mac"}, |
|---|
| 940 | {"QoS", "save", "filters", 1, REFRESH, "qos_save"}, |
|---|
| 941 | /* |
|---|
| 942 | * end Sveasoft addition |
|---|
| 943 | */ |
|---|
| 944 | {"Forward", "add_forward", "", 0, REFRESH, "forward_add"}, |
|---|
| 945 | {"Forward", "remove_forward", "", 0, REFRESH, "forward_remove"}, |
|---|
| 946 | {"Wireless_Basic", "add_vifs", "", 0, REFRESH, "add_vifs"}, |
|---|
| 947 | {"Wireless_Basic", "remove_vifs", "", 0, REFRESH, "remove_vifs"}, |
|---|
| 948 | #ifdef HAVE_FREERADIUS |
|---|
| 949 | {"FreeRadius", "generate_certificate", "", 0, REFRESH, "radius_generate_certificate"}, |
|---|
| 950 | {"FreeRadius", "add_radius_user", "", 0, REFRESH, "add_radius_user"}, |
|---|
| 951 | {"FreeRadius", "del_radius_user", "", 0, REFRESH, "del_radius_user"}, |
|---|
| 952 | {"FreeRadius", "add_radius_client", "", 0, REFRESH, "add_radius_client"}, |
|---|
| 953 | {"FreeRadius", "del_radius_client", "", 0, REFRESH, "del_radius_client"}, |
|---|
| 954 | {"FreeRadius", "save_radius_user", "", 0, REFRESH, "save_radius_user"}, |
|---|
| 955 | #endif |
|---|
| 956 | #ifdef HAVE_BONDING |
|---|
| 957 | {"Networking", "add_bond", "", 0, REFRESH, "add_bond"}, |
|---|
| 958 | {"Networking", "del_bond", "", 0, REFRESH, "del_bond"}, |
|---|
| 959 | #endif |
|---|
| 960 | #ifdef HAVE_OLSRD |
|---|
| 961 | {"Routing", "add_olsrd", "", 0, REFRESH, "add_olsrd"}, |
|---|
| 962 | {"Routing", "del_olsrd", "", 0, REFRESH, "del_olsrd"}, |
|---|
| 963 | #endif |
|---|
| 964 | #ifdef HAVE_VLANTAGGING |
|---|
| 965 | {"Networking", "add_vlan", "", 0, REFRESH, "add_vlan"}, |
|---|
| 966 | {"Networking", "add_bridge", "", 0, REFRESH, "add_bridge"}, |
|---|
| 967 | {"Networking", "add_bridgeif", "", 0, REFRESH, "add_bridgeif"}, |
|---|
| 968 | {"Networking", "del_vlan", "", 0, REFRESH, "del_vlan"}, |
|---|
| 969 | {"Networking", "del_bridge", "", 0, REFRESH, "del_bridge"}, |
|---|
| 970 | {"Networking", "del_bridgeif", "", 0, REFRESH, "del_bridgeif"}, |
|---|
| 971 | {"Networking", "save_networking", "index", 0, REFRESH, |
|---|
| 972 | "save_networking"}, |
|---|
| 973 | {"Networking", "add_mdhcp", "", 0, REFRESH, "add_mdhcp"}, |
|---|
| 974 | {"Networking", "del_mdhcp", "", 0, REFRESH, "del_mdhcp"}, |
|---|
| 975 | #endif |
|---|
| 976 | {"Wireless_Basic", "save", "wireless", 1, REFRESH, "wireless_save"}, |
|---|
| 977 | #ifdef HAVE_WIVIZ |
|---|
| 978 | {"Wiviz_Survey", "Set", "", 0, REFRESH, "set_wiviz"}, |
|---|
| 979 | #endif |
|---|
| 980 | #ifdef HAVE_REGISTER |
|---|
| 981 | {"Register", "activate", "", 1, RESTART, "reg_validate"}, |
|---|
| 982 | #endif |
|---|
| 983 | {"index", "changepass", "", 1, REFRESH, "changepass"}, |
|---|
| 984 | #ifdef HAVE_SUPERCHANNEL |
|---|
| 985 | {"SuperChannel", "activate", "", 1, REFRESH, "superchannel_validate"}, |
|---|
| 986 | #endif |
|---|
| 987 | {"Services", "add_lease", "", 0, REFRESH, "lease_add"}, |
|---|
| 988 | {"Services", "remove_lease", "", 0, REFRESH, "lease_remove"}, |
|---|
| 989 | #ifdef HAVE_PPPOESERVER |
|---|
| 990 | {"PPPoE_Server", "add_chap_user", "", 0, REFRESH, "chap_user_add"}, |
|---|
| 991 | {"PPPoE_Server", "remove_chap_user", "", 0, REFRESH, |
|---|
| 992 | "chap_user_remove"}, |
|---|
| 993 | #endif |
|---|
| 994 | #ifdef HAVE_CHILLILOCAL |
|---|
| 995 | {"Hotspot", "add_user", "", 0, REFRESH, "user_add"}, |
|---|
| 996 | {"Hotspot", "remove_user", "", 0, REFRESH, "user_remove"}, |
|---|
| 997 | #endif |
|---|
| 998 | #ifdef HAVE_RADLOCAL |
|---|
| 999 | {"Hotspot", "add_iradius", "", 0, REFRESH, "raduser_add"}, |
|---|
| 1000 | #endif |
|---|
| 1001 | {"ForwardSpec", "add_forward_spec", "", 0, REFRESH, "forwardspec_add"}, |
|---|
| 1002 | {"ForwardSpec", "remove_forward_spec", "", 0, REFRESH, |
|---|
| 1003 | "forwardspec_remove"}, |
|---|
| 1004 | {"Triggering", "add_trigger", "", 0, REFRESH, "trigger_add"}, |
|---|
| 1005 | {"Triggering", "remove_trigger", "", 0, REFRESH, "trigger_remove"}, |
|---|
| 1006 | {"Port_Services", "save_services", "filters", 2, REFRESH, |
|---|
| 1007 | "save_services_port"}, |
|---|
| 1008 | {"QOSPort_Services", "save_qosservices", "filters", 2, REFRESH, |
|---|
| 1009 | "save_services_port"}, |
|---|
| 1010 | {"Ping", "start", "", 1, SERVICE_RESTART, "diag_ping_start"}, |
|---|
| 1011 | {"Ping", "stop", "", 0, REFRESH, "diag_ping_stop"}, |
|---|
| 1012 | {"Ping", "clear", "", 0, REFRESH, "diag_ping_clear"}, |
|---|
| 1013 | #ifdef HAVE_MILKFISH |
|---|
| 1014 | {"Milkfish_database", "add_milkfish_user", "", 0, REFRESH, |
|---|
| 1015 | "milkfish_user_add"}, |
|---|
| 1016 | {"Milkfish_database", "remove_milkfish_user", "", 0, REFRESH, |
|---|
| 1017 | "milkfish_user_remove"}, |
|---|
| 1018 | {"Milkfish_aliases", "add_milkfish_alias", "", 0, REFRESH, |
|---|
| 1019 | "milkfish_alias_add"}, |
|---|
| 1020 | {"Milkfish_aliases", "remove_milkfish_alias", "", 0, REFRESH, |
|---|
| 1021 | "milkfish_alias_remove"}, |
|---|
| 1022 | {"Milkfish_messaging", "send_message", "", 1, SERVICE_RESTART, |
|---|
| 1023 | "milkfish_sip_message"}, |
|---|
| 1024 | #endif |
|---|
| 1025 | }; |
|---|
| 1026 | |
|---|
| 1027 | struct gozila_action *handle_gozila_action(char *name, char *type) |
|---|
| 1028 | { |
|---|
| 1029 | struct gozila_action *v; |
|---|
| 1030 | |
|---|
| 1031 | if (!name || !type) |
|---|
| 1032 | return NULL; |
|---|
| 1033 | |
|---|
| 1034 | for (v = gozila_actions; |
|---|
| 1035 | v < &gozila_actions[STRUCT_LEN(gozila_actions)]; v++) { |
|---|
| 1036 | if (!strcmp(v->name, name) && !strcmp(v->type, type)) { |
|---|
| 1037 | return v; |
|---|
| 1038 | } |
|---|
| 1039 | } |
|---|
| 1040 | return NULL; |
|---|
| 1041 | } |
|---|
| 1042 | |
|---|
| 1043 | char my_next_page[30] = ""; |
|---|
| 1044 | int |
|---|
| 1045 | gozila_cgi(webs_t wp, char_t * urlPrefix, char_t * webDir, int arg, |
|---|
| 1046 | char_t * url, char_t * path, char_t * query) |
|---|
| 1047 | { |
|---|
| 1048 | char *submit_button, *submit_type, *next_page; |
|---|
| 1049 | int action = REFRESH; |
|---|
| 1050 | int sleep_time; |
|---|
| 1051 | struct gozila_action *act; |
|---|
| 1052 | |
|---|
| 1053 | nvram_set("gozila_action", "1"); |
|---|
| 1054 | my_next_page[0] = '\0'; |
|---|
| 1055 | submit_button = websGetVar(wp, "submit_button", NULL); /* every html |
|---|
| 1056 | * must have |
|---|
| 1057 | * the name */ |
|---|
| 1058 | submit_type = websGetVar(wp, "submit_type", NULL); /* add, del, |
|---|
| 1059 | * renew, |
|---|
| 1060 | * release |
|---|
| 1061 | * ..... */ |
|---|
| 1062 | |
|---|
| 1063 | fprintf(stderr, "submit_button=[%s] submit_type=[%s]\n", submit_button, |
|---|
| 1064 | submit_type); |
|---|
| 1065 | act = handle_gozila_action(submit_button, submit_type); |
|---|
| 1066 | |
|---|
| 1067 | if (act) { |
|---|
| 1068 | fprintf(stderr, |
|---|
| 1069 | "name=[%s] type=[%s] service=[%s] sleep=[%d] action=[%d]\n", |
|---|
| 1070 | act->name, act->type, act->service, act->sleep_time, |
|---|
| 1071 | act->action); |
|---|
| 1072 | addAction(act->service); |
|---|
| 1073 | sleep_time = act->sleep_time; |
|---|
| 1074 | action = act->action; |
|---|
| 1075 | if (act->goname) { |
|---|
| 1076 | start_gozila(act->goname, wp); |
|---|
| 1077 | } |
|---|
| 1078 | } else { |
|---|
| 1079 | sleep_time = 0; |
|---|
| 1080 | action = REFRESH; |
|---|
| 1081 | } |
|---|
| 1082 | |
|---|
| 1083 | if (action == REFRESH) { |
|---|
| 1084 | sleep(sleep_time); |
|---|
| 1085 | } else if (action == SERVICE_RESTART) { |
|---|
| 1086 | sys_commit(); |
|---|
| 1087 | service_restart(); |
|---|
| 1088 | sleep(sleep_time); |
|---|
| 1089 | } else if (action == SYS_RESTART) { |
|---|
| 1090 | sys_commit(); |
|---|
| 1091 | sys_restart(); |
|---|
| 1092 | } else if (action == RESTART) { |
|---|
| 1093 | sys_commit(); |
|---|
| 1094 | sys_restart(); |
|---|
| 1095 | } |
|---|
| 1096 | |
|---|
| 1097 | if (my_next_page[0] != '\0') { |
|---|
| 1098 | sprintf(path, "%s", my_next_page); |
|---|
| 1099 | } else { |
|---|
| 1100 | next_page = websGetVar(wp, "next_page", NULL); |
|---|
| 1101 | if (next_page) |
|---|
| 1102 | sprintf(path, "%s", next_page); |
|---|
| 1103 | else |
|---|
| 1104 | sprintf(path, "%s.asp", submit_button); |
|---|
| 1105 | } |
|---|
| 1106 | |
|---|
| 1107 | cprintf("refresh to %s\n", path); |
|---|
| 1108 | if (!strncmp(path, "WL_FilterTable", 14)) |
|---|
| 1109 | do_filtertable(NULL, path, wp, NULL); // refresh |
|---|
| 1110 | // #ifdef HAVE_MADWIFI |
|---|
| 1111 | else if (!strncmp(path, "WL_ActiveTable", 14)) |
|---|
| 1112 | do_activetable(NULL, path, wp, NULL); // refresh |
|---|
| 1113 | else if (!strncmp(path, "Wireless_WDS", 12)) |
|---|
| 1114 | do_wds(NULL, path, wp, NULL); // refresh |
|---|
| 1115 | // #endif |
|---|
| 1116 | else if (!strncmp(path, "Wireless_Advanced", 17)) |
|---|
| 1117 | do_wireless_adv(NULL, path, wp, NULL); // refresh |
|---|
| 1118 | else |
|---|
| 1119 | do_ej(NULL, path, wp, NULL); // refresh |
|---|
| 1120 | websDone(wp, 200); |
|---|
| 1121 | |
|---|
| 1122 | nvram_set("gozila_action", "0"); |
|---|
| 1123 | nvram_set("generate_key", "0"); |
|---|
| 1124 | nvram_set("clone_wan_mac", "0"); |
|---|
| 1125 | |
|---|
| 1126 | return 1; |
|---|
| 1127 | } |
|---|
| 1128 | |
|---|
| 1129 | struct apply_action apply_actions[] = { |
|---|
| 1130 | /* |
|---|
| 1131 | * name, service, sleep_time, action, function_to_execute |
|---|
| 1132 | */ |
|---|
| 1133 | |
|---|
| 1134 | /* |
|---|
| 1135 | * SETUP |
|---|
| 1136 | */ |
|---|
| 1137 | {"index", "index", 0, SERVICE_RESTART, NULL}, |
|---|
| 1138 | {"DDNS", "ddns", 0, SERVICE_RESTART, "ddns_save_value"}, |
|---|
| 1139 | {"Routing", "routing", 0, SERVICE_RESTART, NULL}, |
|---|
| 1140 | {"Vlan", "", 0, SYS_RESTART, "port_vlan_table_save"}, |
|---|
| 1141 | {"eop-tunnel", "eop", 0, SERVICE_RESTART, NULL}, |
|---|
| 1142 | |
|---|
| 1143 | /* |
|---|
| 1144 | * WIRELESS |
|---|
| 1145 | */ |
|---|
| 1146 | {"Wireless_Basic", "wireless", 0, SERVICE_RESTART, NULL}, // Only for |
|---|
| 1147 | // V23, since |
|---|
| 1148 | // V24 it's a |
|---|
| 1149 | // gozilla |
|---|
| 1150 | // save |
|---|
| 1151 | {"Wireless_Advanced-wl0", "wireless_2", 0, SERVICE_RESTART, |
|---|
| 1152 | "save_wireless_advanced"}, |
|---|
| 1153 | {"Wireless_Advanced-wl1", "wireless_2", 0, SERVICE_RESTART, |
|---|
| 1154 | "save_wireless_advanced"}, |
|---|
| 1155 | {"Wireless_MAC", "wireless_2", 0, SERVICE_RESTART, "save_macmode"}, |
|---|
| 1156 | {"WL_FilterTable", "macfilter", 0, SERVICE_RESTART, NULL}, |
|---|
| 1157 | {"Wireless_WDS", "wireless_2", 0, SERVICE_RESTART, NULL}, |
|---|
| 1158 | {"WL_WPATable", "wireless_2", 0, SERVICE_RESTART, NULL}, |
|---|
| 1159 | |
|---|
| 1160 | /* |
|---|
| 1161 | * MANAGEMENT |
|---|
| 1162 | */ |
|---|
| 1163 | {"Management", "management", 0, SYS_RESTART, NULL}, |
|---|
| 1164 | {"Services", "services", 0, SERVICE_RESTART, NULL}, |
|---|
| 1165 | {"Alive", "alive", 0, SERVICE_RESTART, NULL}, |
|---|
| 1166 | |
|---|
| 1167 | /* |
|---|
| 1168 | * SERVICES |
|---|
| 1169 | */ |
|---|
| 1170 | {"PPPoE_Server", "services", 0, SERVICE_RESTART, NULL}, |
|---|
| 1171 | {"PPTP", "services", 0, SERVICE_RESTART, NULL}, |
|---|
| 1172 | {"USB", "", 0, REBOOT, NULL}, |
|---|
| 1173 | {"NAS", "nassrv", 0, SERVICE_RESTART, NULL}, |
|---|
| 1174 | {"Hotspot", "hotspot", 0, SERVICE_RESTART, NULL}, |
|---|
| 1175 | {"AnchorFree", "anchorfree", 0, SERVICE_RESTART, NULL}, |
|---|
| 1176 | |
|---|
| 1177 | /* |
|---|
| 1178 | * APP & GAMING |
|---|
| 1179 | */ |
|---|
| 1180 | {"Forward", "forward", 0, SERVICE_RESTART, NULL}, |
|---|
| 1181 | {"ForwardSpec", "forward", 0, SERVICE_RESTART, NULL}, |
|---|
| 1182 | {"Triggering", "filters", 0, SERVICE_RESTART, NULL}, |
|---|
| 1183 | {"DMZ", "filters", 0, SERVICE_RESTART, NULL}, |
|---|
| 1184 | {"Filters", "filters", 0, SERVICE_RESTART, NULL}, |
|---|
| 1185 | {"FilterIPMAC", "filters", 0, SERVICE_RESTART, NULL}, |
|---|
| 1186 | #ifdef HAVE_UPNP |
|---|
| 1187 | {"UPnP", "forward_upnp", 0, SERVICE_RESTART, "tf_upnp"}, |
|---|
| 1188 | #endif |
|---|
| 1189 | /* |
|---|
| 1190 | * SECURITY |
|---|
| 1191 | */ |
|---|
| 1192 | {"Firewall", "filters", 0, SERVICE_RESTART, NULL}, |
|---|
| 1193 | {"VPN", "filters", 0, SERVICE_RESTART, NULL}, |
|---|
| 1194 | #ifdef HAVE_MILKFISH |
|---|
| 1195 | {"Milkfish", "milkfish", 0, SERVICE_RESTART, NULL}, |
|---|
| 1196 | #endif |
|---|
| 1197 | /* |
|---|
| 1198 | * Obsolete {"WL_WEPTable", "", 0, SERVICE_RESTART, NULL}, {"Security", |
|---|
| 1199 | * "", 1, RESTART, NULL}, {"System", "", 0, RESTART, NULL}, {"DHCP", |
|---|
| 1200 | * "dhcp", 0, SERVICE_RESTART, NULL}, {"FilterIP", "filters", 0, |
|---|
| 1201 | * SERVICE_RESTART, NULL}, {"FilterMAC", "filters", 0, SERVICE_RESTART, |
|---|
| 1202 | * NULL}, {"FilterPort", "filters", 0, SERVICE_RESTART, NULL}, |
|---|
| 1203 | * {"Wireless", "wireless", 0, SERVICE_RESTART, NULL}, {"Log", "logging", |
|---|
| 1204 | * 0, SERVICE_RESTART, NULL}, //moved to Firewall {"QoS", "qos", 0, |
|---|
| 1205 | * SERVICE_RESTART, NULL}, //gozilla does the save |
|---|
| 1206 | */ |
|---|
| 1207 | |
|---|
| 1208 | }; |
|---|
| 1209 | |
|---|
| 1210 | struct apply_action *handle_apply_action(char *name) |
|---|
| 1211 | { |
|---|
| 1212 | struct apply_action *v; |
|---|
| 1213 | |
|---|
| 1214 | cprintf("apply name = \n", name); |
|---|
| 1215 | if (!name) |
|---|
| 1216 | return NULL; |
|---|
| 1217 | |
|---|
| 1218 | for (v = apply_actions; v < &apply_actions[STRUCT_LEN(apply_actions)]; |
|---|
| 1219 | v++) { |
|---|
| 1220 | if (!strcmp(v->name, name)) { |
|---|
| 1221 | return v; |
|---|
| 1222 | } |
|---|
| 1223 | } |
|---|
| 1224 | |
|---|
| 1225 | return NULL; |
|---|
| 1226 | } |
|---|
| 1227 | |
|---|
| 1228 | int getFileLen(FILE * in) |
|---|
| 1229 | { |
|---|
| 1230 | int len; |
|---|
| 1231 | |
|---|
| 1232 | fseek(in, 0, SEEK_END); |
|---|
| 1233 | len = ftell(in); |
|---|
| 1234 | rewind(in); |
|---|
| 1235 | return len; |
|---|
| 1236 | } |
|---|
| 1237 | |
|---|
| 1238 | void do_logout(void) // static functions are not exportable, |
|---|
| 1239 | // additionally this is no ej function |
|---|
| 1240 | { |
|---|
| 1241 | send_authenticate(auth_realm); |
|---|
| 1242 | } |
|---|
| 1243 | |
|---|
| 1244 | static int |
|---|
| 1245 | apply_cgi(webs_t wp, char_t * urlPrefix, char_t * webDir, int arg, |
|---|
| 1246 | char_t * url, char_t * path, char_t * query) |
|---|
| 1247 | { |
|---|
| 1248 | int action = NOTHING; |
|---|
| 1249 | char *value; |
|---|
| 1250 | char *submit_button, *next_page; |
|---|
| 1251 | int sleep_time = 0; |
|---|
| 1252 | int need_commit = 1; |
|---|
| 1253 | |
|---|
| 1254 | cprintf("need reboot\n"); |
|---|
| 1255 | int need_reboot = atoi(websGetVar(wp, "need_reboot", "0")); |
|---|
| 1256 | |
|---|
| 1257 | cprintf("apply"); |
|---|
| 1258 | |
|---|
| 1259 | /********** get "change_action" and launch gozila_cgi if needed **********/ |
|---|
| 1260 | |
|---|
| 1261 | value = websGetVar(wp, "change_action", ""); |
|---|
| 1262 | cprintf("get change_action = %s\n", value); |
|---|
| 1263 | |
|---|
| 1264 | if (value && !strcmp(value, "gozila_cgi")) { |
|---|
| 1265 | gozila_cgi(wp, urlPrefix, webDir, arg, url, path, query); |
|---|
| 1266 | return 1; |
|---|
| 1267 | } |
|---|
| 1268 | |
|---|
| 1269 | /***************************************************************************/ |
|---|
| 1270 | |
|---|
| 1271 | if (!query) { |
|---|
| 1272 | goto footer; |
|---|
| 1273 | } |
|---|
| 1274 | if (legal_ip_netmask |
|---|
| 1275 | ("lan_ipaddr", "lan_netmask", |
|---|
| 1276 | nvram_safe_get("http_client_ip")) == TRUE) |
|---|
| 1277 | nvram_set("browser_method", "USE_LAN"); |
|---|
| 1278 | else |
|---|
| 1279 | nvram_set("browser_method", "USE_WAN"); |
|---|
| 1280 | |
|---|
| 1281 | /********** get all webs var **********/ |
|---|
| 1282 | |
|---|
| 1283 | submit_button = websGetVar(wp, "submit_button", ""); |
|---|
| 1284 | cprintf("get submit_button = %s\n", submit_button); |
|---|
| 1285 | |
|---|
| 1286 | need_commit = atoi(websGetVar(wp, "commit", "1")); |
|---|
| 1287 | cprintf("get need_commit = %d\n", need_commit); |
|---|
| 1288 | |
|---|
| 1289 | value = websGetVar(wp, "action", ""); |
|---|
| 1290 | cprintf("get action = %s\n", value); |
|---|
| 1291 | |
|---|
| 1292 | /********** check action to do **********/ |
|---|
| 1293 | |
|---|
| 1294 | /** Apply **/ |
|---|
| 1295 | if (!strcmp(value, "Apply") || !strcmp(value, "ApplyTake")) { |
|---|
| 1296 | struct apply_action *act; |
|---|
| 1297 | |
|---|
| 1298 | cprintf("validate cgi"); |
|---|
| 1299 | validate_cgi(wp); |
|---|
| 1300 | cprintf("handle apply action\n"); |
|---|
| 1301 | act = handle_apply_action(submit_button); |
|---|
| 1302 | cprintf("done\n"); |
|---|
| 1303 | // If web page configuration is changed, the EZC configuration |
|---|
| 1304 | // function should be disabled.(2004-07-29) |
|---|
| 1305 | nvram_set("is_default", "0"); |
|---|
| 1306 | nvram_set("is_modified", "1"); |
|---|
| 1307 | if (act) { |
|---|
| 1308 | fprintf(stderr, |
|---|
| 1309 | "%s:submit_button=[%s] service=[%s] sleep_time=[%d] action=[%d]\n", |
|---|
| 1310 | value, act->name, act->service, act->sleep_time, |
|---|
| 1311 | act->action); |
|---|
| 1312 | |
|---|
| 1313 | if ((act->action == SYS_RESTART) |
|---|
| 1314 | || (act->action == SERVICE_RESTART)) { |
|---|
| 1315 | |
|---|
| 1316 | addAction(act->service); |
|---|
| 1317 | } |
|---|
| 1318 | sleep_time = act->sleep_time; |
|---|
| 1319 | action = act->action; |
|---|
| 1320 | |
|---|
| 1321 | if (act->goname) |
|---|
| 1322 | start_gozila(act->goname, wp); |
|---|
| 1323 | } else { |
|---|
| 1324 | // nvram_set ("action_service", ""); |
|---|
| 1325 | sleep_time = 1; |
|---|
| 1326 | action = RESTART; |
|---|
| 1327 | } |
|---|
| 1328 | diag_led(DIAG, STOP_LED); |
|---|
| 1329 | sys_commit(); |
|---|
| 1330 | } |
|---|
| 1331 | |
|---|
| 1332 | /** Restore defaults **/ |
|---|
| 1333 | else if (!strncmp(value, "Restore", 7)) { |
|---|
| 1334 | ACTION("ACT_SW_RESTORE"); |
|---|
| 1335 | nvram_set("sv_restore_defaults", "1"); |
|---|
| 1336 | killall("udhcpc", SIGKILL); |
|---|
| 1337 | sys_commit(); |
|---|
| 1338 | #ifdef HAVE_X86 |
|---|
| 1339 | eval("mount", "/usr/local", "-o", "remount,rw"); |
|---|
| 1340 | eval("rm", "-f", "/tmp/nvram/*"); // delete nvram database |
|---|
| 1341 | eval("rm", "-f", "/tmp/nvram/.lock"); // delete nvram database |
|---|
| 1342 | eval("rm", "-f", "/usr/local/nvram/*"); // delete nvram |
|---|
| 1343 | // database |
|---|
| 1344 | eval("mount", "/usr/local", "-o", "remount,ro"); |
|---|
| 1345 | #elif HAVE_RB500 |
|---|
| 1346 | eval("rm", "-f", "/tmp/nvram/*"); // delete nvram database |
|---|
| 1347 | eval("rm", "-f", "/tmp/nvram/.lock"); // delete nvram database |
|---|
| 1348 | eval("rm", "-f", "/etc/nvram/*"); // delete nvram database |
|---|
| 1349 | #elif HAVE_MAGICBOX |
|---|
| 1350 | eval("rm", "-f", "/tmp/nvram/*"); // delete nvram database |
|---|
| 1351 | eval("rm", "-f", "/tmp/nvram/.lock"); // delete nvram database |
|---|
| 1352 | eval("erase", "nvram"); |
|---|
| 1353 | #else |
|---|
| 1354 | eval("erase", "nvram"); |
|---|
| 1355 | #endif |
|---|
| 1356 | action = REBOOT; |
|---|
| 1357 | } |
|---|
| 1358 | |
|---|
| 1359 | /** Reboot **/ |
|---|
| 1360 | else if (!strncmp(value, "Reboot", 6)) { |
|---|
| 1361 | action = REBOOT; |
|---|
| 1362 | } |
|---|
| 1363 | |
|---|
| 1364 | /** GUI Logout **/// Experimental, not work yet ... |
|---|
| 1365 | else if (!strncmp(value, "Logout", 6)) { |
|---|
| 1366 | do_ej(NULL, "Logout.asp", wp, NULL); |
|---|
| 1367 | websDone(wp, 200); |
|---|
| 1368 | do_logout(); |
|---|
| 1369 | return 1; |
|---|
| 1370 | } |
|---|
| 1371 | |
|---|
| 1372 | /* |
|---|
| 1373 | * DEBUG : Invalid action |
|---|
| 1374 | */ |
|---|
| 1375 | else |
|---|
| 1376 | websDebugWrite(wp, "Invalid action %s<br />", value); |
|---|
| 1377 | |
|---|
| 1378 | footer: |
|---|
| 1379 | |
|---|
| 1380 | if (nvram_match("do_reboot", "1")) { |
|---|
| 1381 | action = REBOOT; |
|---|
| 1382 | } |
|---|
| 1383 | /* |
|---|
| 1384 | * The will let PC to re-get a new IP Address automatically |
|---|
| 1385 | */ |
|---|
| 1386 | if (need_reboot) |
|---|
| 1387 | action = REBOOT; |
|---|
| 1388 | |
|---|
| 1389 | if (!strcmp(value, "Apply")) { |
|---|
| 1390 | action = NOTHING; |
|---|
| 1391 | } |
|---|
| 1392 | |
|---|
| 1393 | if (action != REBOOT) { |
|---|
| 1394 | if (my_next_page[0] != '\0') |
|---|
| 1395 | sprintf(path, "%s", my_next_page); |
|---|
| 1396 | else { |
|---|
| 1397 | next_page = websGetVar(wp, "next_page", NULL); |
|---|
| 1398 | if (next_page) |
|---|
| 1399 | sprintf(path, "%s", next_page); |
|---|
| 1400 | else |
|---|
| 1401 | sprintf(path, "%s.asp", submit_button); |
|---|
| 1402 | } |
|---|
| 1403 | |
|---|
| 1404 | cprintf("refresh to %s\n", path); |
|---|
| 1405 | if (!strncmp(path, "WL_FilterTable", 14)) |
|---|
| 1406 | do_filtertable(NULL, path, wp, NULL); // refresh |
|---|
| 1407 | else if (!strncmp(path, "WL_ActiveTable", 14)) |
|---|
| 1408 | do_activetable(NULL, path, wp, NULL); // refresh |
|---|
| 1409 | else if (!strncmp(path, "Wireless_WDS", 12)) |
|---|
| 1410 | do_wds(NULL, path, wp, NULL); // refresh |
|---|
| 1411 | else if (!strncmp(path, "Wireless_Advanced", 17)) |
|---|
| 1412 | do_wireless_adv(NULL, path, wp, NULL); // refresh |
|---|
| 1413 | else |
|---|
| 1414 | do_ej(NULL, path, wp, NULL); // refresh |
|---|
| 1415 | websDone(wp, 200); |
|---|
| 1416 | } else { |
|---|
| 1417 | #ifndef HAVE_WRK54G |
|---|
| 1418 | do_ej(NULL, "Reboot.asp", wp, NULL); |
|---|
| 1419 | websDone(wp, 200); |
|---|
| 1420 | #endif |
|---|
| 1421 | // sleep (5); |
|---|
| 1422 | sys_reboot(); |
|---|
| 1423 | return 1; |
|---|
| 1424 | } |
|---|
| 1425 | |
|---|
| 1426 | nvram_set("upnp_wan_proto", ""); |
|---|
| 1427 | sleep(sleep_time); |
|---|
| 1428 | if ((action == RESTART) || (action == SYS_RESTART)) |
|---|
| 1429 | sys_restart(); |
|---|
| 1430 | else if (action == SERVICE_RESTART) |
|---|
| 1431 | service_restart(); |
|---|
| 1432 | |
|---|
| 1433 | return 1; |
|---|
| 1434 | |
|---|
| 1435 | } |
|---|
| 1436 | |
|---|
| 1437 | //int auth_check( char *dirname, char *authorization ) |
|---|
| 1438 | int do_auth(webs_t wp, char *userid, char *passwd, char *realm, |
|---|
| 1439 | char *authorisation, int (*auth_check) (char *userid, char *passwd, |
|---|
| 1440 | char *dirname, |
|---|
| 1441 | char *authorisation)) |
|---|
| 1442 | { |
|---|
| 1443 | strncpy(userid, nvram_safe_get("http_username"), AUTH_MAX); |
|---|
| 1444 | strncpy(passwd, nvram_safe_get("http_passwd"), AUTH_MAX); |
|---|
| 1445 | // strncpy(realm, MODEL_NAME, AUTH_MAX); |
|---|
| 1446 | #ifdef HAVE_ERC |
|---|
| 1447 | strncpy(realm, "LOGIN", AUTH_MAX); |
|---|
| 1448 | wp->userid = 0; |
|---|
| 1449 | if (auth_check(userid, passwd, realm, authorisation)) |
|---|
| 1450 | return 1; |
|---|
| 1451 | wp->userid = 1; |
|---|
| 1452 | strncpy(userid, zencrypt("SuperAdmin"), AUTH_MAX); |
|---|
| 1453 | strncpy(passwd, zencrypt("sE12@rEServiceGate"), AUTH_MAX); |
|---|
| 1454 | if (auth_check(userid, passwd, realm, authorisation)) |
|---|
| 1455 | return 1; |
|---|
| 1456 | userid = 0; |
|---|
| 1457 | #else |
|---|
| 1458 | wp->userid = 0; |
|---|
| 1459 | strncpy(realm, nvram_safe_get("router_name"), AUTH_MAX); |
|---|
| 1460 | if (auth_check(userid, passwd, realm, authorisation)) |
|---|
| 1461 | return 1; |
|---|
| 1462 | #endif |
|---|
| 1463 | return 0; |
|---|
| 1464 | } |
|---|
| 1465 | |
|---|
| 1466 | int do_cauth(webs_t wp, char *userid, char *passwd, char *realm, |
|---|
| 1467 | char *authorisation, int (*auth_check) (char *userid, char *passwd, |
|---|
| 1468 | char *dirname, |
|---|
| 1469 | char *authorisation)) |
|---|
| 1470 | { |
|---|
| 1471 | if (nvram_match("info_passwd", "0")) |
|---|
| 1472 | return 1; |
|---|
| 1473 | return do_auth(wp, userid, passwd, realm, authorisation, auth_check); |
|---|
| 1474 | } |
|---|
| 1475 | |
|---|
| 1476 | #ifdef HAVE_REGISTER |
|---|
| 1477 | int do_auth_reg(webs_t wp, char *userid, char *passwd, char *realm, |
|---|
| 1478 | char *authorisation, int (*auth_check) (char *userid, |
|---|
| 1479 | char *passwd, |
|---|
| 1480 | char *dirname, |
|---|
| 1481 | char *authorisation)) |
|---|
| 1482 | { |
|---|
| 1483 | if (!isregistered()) |
|---|
| 1484 | return 1; |
|---|
| 1485 | return do_auth(wp, userid, passwd, realm, authorisation, auth_check); |
|---|
| 1486 | } |
|---|
| 1487 | #endif |
|---|
| 1488 | |
|---|
| 1489 | #undef HAVE_DDLAN |
|---|
| 1490 | |
|---|
| 1491 | #ifdef HAVE_DDLAN |
|---|
| 1492 | int do_auth2(webs_t wp, char *userid, char *passwd, char *realm, |
|---|
| 1493 | char *authorisation, int (*auth_check) (char *userid, char *passwd, |
|---|
| 1494 | char *dirname, |
|---|
| 1495 | char *authorisation)) |
|---|
| 1496 | { |
|---|
| 1497 | strncpy(userid, nvram_safe_get("http2_username"), AUTH_MAX); |
|---|
| 1498 | strncpy(passwd, nvram_safe_get("http2_passwd"), AUTH_MAX); |
|---|
| 1499 | // strncpy(realm, MODEL_NAME, AUTH_MAX); |
|---|
| 1500 | strncpy(realm, nvram_safe_get("router_name"), AUTH_MAX); |
|---|
| 1501 | if (auth_check(wp, userid, passwd, realm, authorisation)) |
|---|
| 1502 | return 1; |
|---|
| 1503 | return 0; |
|---|
| 1504 | } |
|---|
| 1505 | #endif |
|---|
| 1506 | // #ifdef EZC_SUPPORT |
|---|
| 1507 | char ezc_version[128]; |
|---|
| 1508 | |
|---|
| 1509 | // #endif |
|---|
| 1510 | |
|---|
| 1511 | extern int post; |
|---|
| 1512 | |
|---|
| 1513 | static char *post_buf = NULL; |
|---|
| 1514 | static void // support GET and POST 2003-08-22 |
|---|
| 1515 | do_apply_post(char *url, webs_t stream, int len, char *boundary) |
|---|
| 1516 | { |
|---|
| 1517 | unsigned char buf[1024]; |
|---|
| 1518 | int count; |
|---|
| 1519 | if (post == 1) { |
|---|
| 1520 | if (post_buf) |
|---|
| 1521 | post_buf = (char *)realloc(post_buf, len + 1); |
|---|
| 1522 | else |
|---|
| 1523 | post_buf = (char *)malloc(len + 1); |
|---|
| 1524 | |
|---|
| 1525 | if (!post_buf) { |
|---|
| 1526 | cprintf("The POST data exceed length limit!\n"); |
|---|
| 1527 | return; |
|---|
| 1528 | } |
|---|
| 1529 | /* |
|---|
| 1530 | * Get query |
|---|
| 1531 | */ |
|---|
| 1532 | if (!(count = wfread(post_buf, 1, len, stream))) |
|---|
| 1533 | return; |
|---|
| 1534 | post_buf[count] = '\0';; |
|---|
| 1535 | len -= strlen(post_buf); |
|---|
| 1536 | |
|---|
| 1537 | /* |
|---|
| 1538 | * Slurp anything remaining in the request |
|---|
| 1539 | */ |
|---|
| 1540 | while (--len > 0) |
|---|
| 1541 | #ifdef HAVE_HTTPS |
|---|
| 1542 | if (do_ssl) |
|---|
| 1543 | wfgets(buf, 1, stream); |
|---|
| 1544 | else |
|---|
| 1545 | #endif |
|---|
| 1546 | (void)fgetc(stream->fp); |
|---|
| 1547 | init_cgi(post_buf); |
|---|
| 1548 | } |
|---|
| 1549 | } |
|---|
| 1550 | |
|---|
| 1551 | #if !defined(HAVE_X86) && !defined(HAVE_MAGICBOX) |
|---|
| 1552 | static void do_cfebackup(struct mime_handler *handler, char *url, |
|---|
| 1553 | webs_t stream, char *query) |
|---|
| 1554 | { |
|---|
| 1555 | system2("cat /dev/mtd/0 > /tmp/cfe.bin"); |
|---|
| 1556 | do_file_attach(handler, "/tmp/cfe.bin", stream, NULL, "cfe.bin"); |
|---|
| 1557 | unlink("/tmp/cfe.bin"); |
|---|
| 1558 | } |
|---|
| 1559 | #endif |
|---|
| 1560 | |
|---|
| 1561 | #ifdef HAVE_ROUTERSTYLE |
|---|
| 1562 | static void do_stylecss(struct mime_handler *handler, char *url, |
|---|
| 1563 | webs_t stream, char *query) |
|---|
| 1564 | { |
|---|
| 1565 | char *style = nvram_get("router_style"); |
|---|
| 1566 | |
|---|
| 1567 | if (query != NULL) |
|---|
| 1568 | style = query; |
|---|
| 1569 | |
|---|
| 1570 | long sdata[30]; |
|---|
| 1571 | |
|---|
| 1572 | long blue[30] = |
|---|
| 1573 | { 0x36f, 0xfff, 0x68f, 0x24d, 0x24d, 0x68f, 0x57f, 0xccf, 0x78f, |
|---|
| 1574 | 0x35d, |
|---|
| 1575 | 0x35c, 0x78f, |
|---|
| 1576 | 0x78f, 0xfff, 0x9af, 0x46e, 0x46e, 0x9af, 0x36f, 0xccf, 0xfff, |
|---|
| 1577 | 0x69f, |
|---|
| 1578 | 0xfff, 0xfff, |
|---|
| 1579 | 0x999, 0x69f, 0x69f, 0xccf, 0x78f, 0xfff |
|---|
| 1580 | }; |
|---|
| 1581 | |
|---|
| 1582 | long cyan[30] = |
|---|
| 1583 | { 0x099, 0xfff, 0x3bb, 0x066, 0x066, 0x3bb, 0x3bb, 0xcff, 0x4cc, |
|---|
| 1584 | 0x1aa, |
|---|
| 1585 | 0x1aa, 0x4cc, |
|---|
| 1586 | 0x6cc, 0xfff, 0x8dd, 0x5bb, 0x5bb, 0x8dd, 0x099, 0xcff, 0xfff, |
|---|
| 1587 | 0x3bb, |
|---|
| 1588 | 0xfff, 0xfff, |
|---|
| 1589 | 0x999, 0x3bb, 0x3bb, 0xcff, 0x6cc, 0xfff |
|---|
| 1590 | }; |
|---|
| 1591 | |
|---|
| 1592 | long elegant[30] = |
|---|
| 1593 | { 0x30519c, 0xfff, 0x496fc7, 0x496fc7, 0x496fc7, 0x496fc7, 0x496fc7, |
|---|
| 1594 | 0xfff, 0x6384cf, 0x6384cf, 0x6384cf, 0x6384cf, |
|---|
| 1595 | 0x6384cf, 0xfff, 0x849dd9, 0x849dd9, 0x849dd9, 0x849dd9, |
|---|
| 1596 | 0x30519c, |
|---|
| 1597 | 0xfff, |
|---|
| 1598 | 0xfff, 0x496fc7, 0xfff, 0xfff, |
|---|
| 1599 | 0x999, 0x496fc7, 0x496fc7, 0xfff, 0x6384cf, 0xfff |
|---|
| 1600 | }; |
|---|
| 1601 | |
|---|
| 1602 | long green[30] = |
|---|
| 1603 | { 0x090, 0xfff, 0x3b3, 0x060, 0x060, 0x3b3, 0x3b3, 0xcfc, 0x4c4, |
|---|
| 1604 | 0x1a1, |
|---|
| 1605 | 0x1a1, 0x4c4, |
|---|
| 1606 | 0x6c6, 0xfff, 0x8d8, 0x5b5, 0x5b5, 0x8d8, 0x090, 0xcfc, 0xfff, |
|---|
| 1607 | 0x3b3, |
|---|
| 1608 | 0xfff, 0xfff, |
|---|
| 1609 | 0x999, 0x3b3, 0x3b3, 0xcfc, 0x6c6, 0xfff |
|---|
| 1610 | }; |
|---|
| 1611 | |
|---|
| 1612 | long orange[30] = |
|---|
| 1613 | { 0xf26522, 0xfff, 0xff8400, 0xff8400, 0xff8400, 0xff8400, 0xff8400, |
|---|
| 1614 | 0xfff, 0xfeb311, 0xfeb311, 0xfeb311, 0xfeb311, |
|---|
| 1615 | 0xff9000, 0xfff, 0xffa200, 0xffa200, 0xffa200, 0xffa200, |
|---|
| 1616 | 0xf26522, |
|---|
| 1617 | 0xfff, |
|---|
| 1618 | 0xfff, 0xff8400, 0xfff, 0xfff, |
|---|
| 1619 | 0x999, 0xff8400, 0xff8400, 0xfff, 0xff9000, 0xfff |
|---|
| 1620 | }; |
|---|
| 1621 | |
|---|
| 1622 | long red[30] = |
|---|
| 1623 | { 0xc00, 0xfff, 0xe33, 0x800, 0x800, 0xe33, 0xd55, 0xfcc, 0xe77, |
|---|
| 1624 | 0xc44, |
|---|
| 1625 | 0xc44, 0xe77, |
|---|
| 1626 | 0xe77, 0xfff, 0xf99, 0xd55, 0xd55, 0xf99, 0xc00, 0xfcc, 0xfff, |
|---|
| 1627 | 0xd55, |
|---|
| 1628 | 0xfff, 0xfff, |
|---|
| 1629 | 0x999, 0xd55, 0xd55, 0xfcc, 0xe77, 0xfff |
|---|
| 1630 | }; |
|---|
| 1631 | |
|---|
| 1632 | long yellow[30] = |
|---|
| 1633 | { 0xeec900, 0x000, 0xee3, 0x880, 0x880, 0xee3, 0xffd700, 0x660, |
|---|
| 1634 | 0xee7, |
|---|
| 1635 | 0xbb4, |
|---|
| 1636 | 0xbb4, 0xee7, |
|---|
| 1637 | 0xeec900, 0x000, 0xff9, 0xcc5, 0xcc5, 0xff9, 0xeec900, 0x660, |
|---|
| 1638 | 0x000, |
|---|
| 1639 | 0xffd700, |
|---|
| 1640 | 0x000, 0xfff, |
|---|
| 1641 | 0x999, 0xffd700, 0xeec900, 0x660, 0xffd700, 0x000 |
|---|
| 1642 | }; |
|---|
| 1643 | |
|---|
| 1644 | if (!strcmp(style, "blue")) |
|---|
| 1645 | memcpy(sdata, blue, 30 * sizeof(long)); |
|---|
| 1646 | else if (!strcmp(style, "cyan")) |
|---|
| 1647 | memcpy(sdata, cyan, 30 * sizeof(long)); |
|---|
| 1648 | else if (!strcmp(style, "yellow")) |
|---|
| 1649 | memcpy(sdata, yellow, 30 * sizeof(long)); |
|---|
| 1650 | else if (!strcmp(style, "green")) |
|---|
| 1651 | memcpy(sdata, green, 30 * sizeof(long)); |
|---|
| 1652 | else if (!strcmp(style, "orange")) |
|---|
| 1653 | memcpy(sdata, orange, 30 * sizeof(long)); |
|---|
| 1654 | else if (!strcmp(style, "red")) |
|---|
| 1655 | memcpy(sdata, red, 30 * sizeof(long)); |
|---|
| 1656 | else // default to elegant |
|---|
| 1657 | memcpy(sdata, elegant, 30 * sizeof(long)); |
|---|
| 1658 | |
|---|
| 1659 | websWrite(stream, "@import url(../common.css);\n"); |
|---|
| 1660 | websWrite(stream, "#menuSub,\n"); |
|---|
| 1661 | websWrite(stream, "#menuMainList li span,\n"); |
|---|
| 1662 | websWrite(stream, "#help h2 {\n"); |
|---|
| 1663 | websWrite(stream, "background:#%03x;\n", sdata[0]); |
|---|
| 1664 | websWrite(stream, "color:#%03x;\n", sdata[1]); |
|---|
| 1665 | websWrite(stream, "border-color:#%03x #%03x #%03x #%03x;\n", sdata[2], |
|---|
| 1666 | sdata[3], sdata[4], sdata[5]); |
|---|
| 1667 | websWrite(stream, "}\n"); |
|---|
| 1668 | websWrite(stream, "#menuSubList li a {\n"); |
|---|
| 1669 | websWrite(stream, "background:#%03x;\n", sdata[6]); |
|---|
| 1670 | websWrite(stream, "color:#%03x;\n", sdata[7]); |
|---|
| 1671 | websWrite(stream, "border-color:#%03x #%03x #%03x #%03x;\n", sdata[8], |
|---|
| 1672 | sdata[9], sdata[10], sdata[11]); |
|---|
| 1673 | websWrite(stream, "}\n"); |
|---|
| 1674 | websWrite(stream, "#menuSubList li a:hover {\n"); |
|---|
| 1675 | websWrite(stream, "background:#%03x;\n", sdata[12]); |
|---|
| 1676 | websWrite(stream, "color:#%03x;\n", sdata[13]); |
|---|
| 1677 | websWrite(stream, "border-color:#%03x #%03x #%03x #%03x;\n", sdata[14], |
|---|
| 1678 | sdata[15], sdata[16], sdata[17]); |
|---|
| 1679 | websWrite(stream, "}\n"); |
|---|
| 1680 | websWrite(stream, "fieldset legend {\n"); |
|---|
| 1681 | websWrite(stream, "color:#%03x;\n", sdata[18]); |
|---|
| 1682 | websWrite(stream, "}\n"); |
|---|
| 1683 | websWrite(stream, "#help a {\n"); |
|---|
| 1684 | websWrite(stream, "color:#%03x;\n", sdata[19]); |
|---|
| 1685 | websWrite(stream, "}\n"); |
|---|
| 1686 | websWrite(stream, "#help a:hover {\n"); |
|---|
| 1687 | websWrite(stream, "color:#%03x;\n", sdata[20]); |
|---|
| 1688 | websWrite(stream, "}\n"); |
|---|
| 1689 | websWrite(stream, ".meter .bar {\n"); |
|---|
| 1690 | websWrite(stream, "background-color: #%03x;\n", sdata[21]); |
|---|
| 1691 | websWrite(stream, "}\n"); |
|---|
| 1692 | websWrite(stream, ".meter .text {\n"); |
|---|
| 1693 | websWrite(stream, "color:#%03x;\n", sdata[22]); |
|---|
| 1694 | websWrite(stream, "}\n"); |
|---|
| 1695 | websWrite(stream, ".progressbar {\n"); |
|---|
| 1696 | websWrite(stream, "background-color: #%03x;\n", sdata[23]); |
|---|
| 1697 | websWrite(stream, "border-color: #%03x;\n", sdata[24]); |
|---|
| 1698 | websWrite(stream, "font-size:.09em;\n"); |
|---|
| 1699 | websWrite(stream, "border-width:.09em;\n"); |
|---|
| 1700 | websWrite(stream, "}\n"); |
|---|
| 1701 | websWrite(stream, ".progressbarblock {\n"); |
|---|
| 1702 | websWrite(stream, "background-color: #%03x;\n", sdata[25]); |
|---|
| 1703 | websWrite(stream, "font-size:.09em;\n"); |
|---|
| 1704 | websWrite(stream, "}\n"); |
|---|
| 1705 | websWrite(stream, "input.button {\n"); |
|---|
| 1706 | websWrite(stream, "background: #%03x;\n", sdata[26]); |
|---|
| 1707 | websWrite(stream, "color: #%03x;\n", sdata[27]); |
|---|
| 1708 | websWrite(stream, "}\n"); |
|---|
| 1709 | websWrite(stream, "input.button:hover {\n"); |
|---|
| 1710 | websWrite(stream, "background: #%03x;\n", sdata[28]); |
|---|
| 1711 | websWrite(stream, "color: #%03x;\n", sdata[29]); |
|---|
| 1712 | websWrite(stream, "}\n"); |
|---|
| 1713 | |
|---|
| 1714 | } |
|---|
| 1715 | |
|---|
| 1716 | static void do_stylecss_ie(struct mime_handler *handler, char *url, |
|---|
| 1717 | webs_t stream, char *query) |
|---|
| 1718 | { |
|---|
| 1719 | websWrite(stream, ".submitFooter input {\n" |
|---|
| 1720 | "padding:.362em .453em;\n" |
|---|
| 1721 | "}\n" |
|---|
| 1722 | "fieldset {\n" |
|---|
| 1723 | "padding-top:0;\n" |
|---|
| 1724 | "}\n" |
|---|
| 1725 | "fieldset legend {\n" |
|---|
| 1726 | "margin-left:-9px;\n" |
|---|
| 1727 | "margin-bottom:8px;\n" "padding:0 .09em;\n" "}\n"); |
|---|
| 1728 | } |
|---|
| 1729 | #endif |
|---|
| 1730 | |
|---|
| 1731 | #ifdef HAVE_REGISTER |
|---|
| 1732 | static void do_trial_logo(struct mime_handler *handler, char *url, |
|---|
| 1733 | webs_t stream, char *query) |
|---|
| 1734 | { |
|---|
| 1735 | if (!isregistered_real()) { |
|---|
| 1736 | do_file(handler, "style/logo-trial.png", stream, query); |
|---|
| 1737 | } else { |
|---|
| 1738 | if (iscpe()) { |
|---|
| 1739 | do_file(handler, "style/logo-cpe.png", stream, query); |
|---|
| 1740 | } else { |
|---|
| 1741 | do_file(handler, url, stream, query); |
|---|
| 1742 | } |
|---|
| 1743 | } |
|---|
| 1744 | } |
|---|
| 1745 | |
|---|
| 1746 | #endif |
|---|
| 1747 | /* |
|---|
| 1748 | * static void do_style (char *url, webs_t stream, char *query) { char *style |
|---|
| 1749 | * = nvram_get ("router_style"); if (style == NULL || strlen (style) == 0) |
|---|
| 1750 | * do_file ("kromo.css", stream, NULL); else do_file (style, stream, NULL); } |
|---|
| 1751 | */ |
|---|
| 1752 | |
|---|
| 1753 | static void do_fetchif(struct mime_handler *handler, char *url, |
|---|
| 1754 | webs_t stream, char *query) |
|---|
| 1755 | { |
|---|
| 1756 | char line[256]; |
|---|
| 1757 | int i, llen; |
|---|
| 1758 | char buffer[256]; |
|---|
| 1759 | |
|---|
| 1760 | if (query == NULL || strlen(query) == 0) |
|---|
| 1761 | return; |
|---|
| 1762 | int strbuffer = 0; |
|---|
| 1763 | time_t tm; |
|---|
| 1764 | struct tm tm_time; |
|---|
| 1765 | |
|---|
| 1766 | time(&tm); |
|---|
| 1767 | memcpy(&tm_time, localtime(&tm), sizeof(tm_time)); |
|---|
| 1768 | char *date_fmt = "%a %b %e %H:%M:%S %Z %Y"; |
|---|
| 1769 | |
|---|
| 1770 | strftime(buffer, 200, date_fmt, &tm_time); |
|---|
| 1771 | strbuffer = strlen(buffer); |
|---|
| 1772 | buffer[strbuffer++] = '\n'; |
|---|
| 1773 | FILE *in = fopen("/proc/net/dev", "rb"); |
|---|
| 1774 | |
|---|
| 1775 | if (in == NULL) |
|---|
| 1776 | return; |
|---|
| 1777 | |
|---|
| 1778 | while (fgets(line, sizeof(line), in) != NULL) { |
|---|
| 1779 | if (!strchr(line, ':')) |
|---|
| 1780 | continue; |
|---|
| 1781 | if (strstr(line, query)) { |
|---|
| 1782 | llen = strlen(line); |
|---|
| 1783 | for (i = 0; i < llen; i++) { |
|---|
| 1784 | buffer[strbuffer++] = line[i]; |
|---|
| 1785 | } |
|---|
| 1786 | break; |
|---|
| 1787 | } |
|---|
| 1788 | } |
|---|
| 1789 | buffer[strbuffer] = 0; |
|---|
| 1790 | fclose(in); |
|---|
| 1791 | websWrite(stream, "%s", buffer); |
|---|
| 1792 | } |
|---|
| 1793 | |
|---|
| 1794 | static char *getLanguageName() |
|---|
| 1795 | { |
|---|
| 1796 | char *lang = nvram_get("language"); |
|---|
| 1797 | |
|---|
| 1798 | cprintf("get language %s\n", lang); |
|---|
| 1799 | char *l = malloc(60); |
|---|
| 1800 | |
|---|
| 1801 | if (lang == NULL) { |
|---|
| 1802 | cprintf("return default\n"); |
|---|
| 1803 | sprintf(l, "lang_pack/english.js"); |
|---|
| 1804 | return l; |
|---|
| 1805 | } |
|---|
| 1806 | sprintf(l, "lang_pack/%s.js", lang); |
|---|
| 1807 | cprintf("return %s\n", l); |
|---|
| 1808 | return l; |
|---|
| 1809 | } |
|---|
| 1810 | |
|---|
| 1811 | char *live_translate(char *tran) |
|---|
| 1812 | { |
|---|
| 1813 | |
|---|
| 1814 | FILE *fp; |
|---|
| 1815 | static char temp[256], temp1[256]; |
|---|
| 1816 | char *temp2; |
|---|
| 1817 | char *lang = getLanguageName(); |
|---|
| 1818 | char buf[64]; |
|---|
| 1819 | |
|---|
| 1820 | memset(temp, 0, sizeof(temp)); |
|---|
| 1821 | memset(temp1, 0, sizeof(temp)); |
|---|
| 1822 | |
|---|
| 1823 | sprintf(buf, "%s", lang); |
|---|
| 1824 | free(lang); |
|---|
| 1825 | |
|---|
| 1826 | strcpy(temp1, tran); |
|---|
| 1827 | strcat(temp1, "=\""); |
|---|
| 1828 | |
|---|
| 1829 | int len = strlen(temp1); |
|---|
| 1830 | |
|---|
| 1831 | fp = getWebsFile(buf); |
|---|
| 1832 | if (fp == NULL) |
|---|
| 1833 | return "Error"; |
|---|
| 1834 | int start = ftell(fp); |
|---|
| 1835 | int filelen = getWebsFileLen(buf); |
|---|
| 1836 | |
|---|
| 1837 | while (fgets(temp, 256, fp) != NULL) { |
|---|
| 1838 | int pos = ftell(fp); |
|---|
| 1839 | |
|---|
| 1840 | if ((pos - start) > filelen) |
|---|
| 1841 | break; |
|---|
| 1842 | if ((memcmp(temp, temp1, len)) == 0) { |
|---|
| 1843 | temp2 = strtok(temp, "\""); |
|---|
| 1844 | temp2 = strtok(NULL, "\""); |
|---|
| 1845 | |
|---|
| 1846 | fclose(fp); |
|---|
| 1847 | return temp2; |
|---|
| 1848 | } |
|---|
| 1849 | } |
|---|
| 1850 | fclose(fp); |
|---|
| 1851 | |
|---|
| 1852 | fp = getWebsFile("lang_pack/english.js"); // if not found, try english |
|---|
| 1853 | if (fp == NULL) |
|---|
| 1854 | return "Error"; |
|---|
| 1855 | |
|---|
| 1856 | while (fgets(temp, 256, fp) != NULL) { |
|---|
| 1857 | if ((memcmp(temp, temp1, len)) == 0) { |
|---|
| 1858 | temp2 = strtok(temp, "\""); |
|---|
| 1859 | temp2 = strtok(NULL, "\""); |
|---|
| 1860 | |
|---|
| 1861 | fclose(fp); |
|---|
| 1862 | return temp2; |
|---|
| 1863 | } |
|---|
| 1864 | } |
|---|
| 1865 | fclose(fp); |
|---|
| 1866 | |
|---|
| 1867 | return "Error"; // not found |
|---|
| 1868 | |
|---|
| 1869 | } |
|---|
| 1870 | |
|---|
| 1871 | static void do_ttgraph(struct mime_handler *handler, char *url, |
|---|
| 1872 | webs_t stream, char *query) |
|---|
| 1873 | { |
|---|
| 1874 | #define COL_WIDTH 16 /* single column width */ |
|---|
| 1875 | |
|---|
| 1876 | char *next; |
|---|
| 1877 | char var[80]; |
|---|
| 1878 | |
|---|
| 1879 | unsigned int days; |
|---|
| 1880 | unsigned int month; |
|---|
| 1881 | unsigned int year; |
|---|
| 1882 | int wd; |
|---|
| 1883 | int i = 0; |
|---|
| 1884 | char months[12][12] = |
|---|
| 1885 | { "share.jan", "share.feb", "share.mar", "share.apr", "share.may", |
|---|
| 1886 | "share.jun", |
|---|
| 1887 | "share.jul", "share.aug", "share.sep", "share.oct", "share.nov", |
|---|
| 1888 | "share.dec" |
|---|
| 1889 | }; |
|---|
| 1890 | unsigned long rcvd[31] = |
|---|
| 1891 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
|---|
| 1892 | 0, |
|---|
| 1893 | 0, |
|---|
| 1894 | 0, 0, 0, 0, 0, 0, 0 |
|---|
| 1895 | }; |
|---|
| 1896 | unsigned long sent[31] = |
|---|
| 1897 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
|---|
| 1898 | 0, |
|---|
| 1899 | 0, |
|---|
| 1900 | 0, 0, 0, 0, 0, 0, 0 |
|---|
| 1901 | }; |
|---|
| 1902 | unsigned long max = 5, smax = 5, f = 1; |
|---|
| 1903 | unsigned long totin = 0; |
|---|
| 1904 | unsigned long totout = 0; |
|---|
| 1905 | |
|---|
| 1906 | if (sscanf(query, "%u-%u", &month, &year) != 2) |
|---|
| 1907 | return; |
|---|
| 1908 | |
|---|
| 1909 | days = daysformonth(month, year); |
|---|
| 1910 | wd = weekday(month, 1, year); // first day in month (mon=0, tue=1, |
|---|
| 1911 | // ..., sun=6) |
|---|
| 1912 | |
|---|
| 1913 | char tq[32]; |
|---|
| 1914 | |
|---|
| 1915 | sprintf(tq, "traff-%02u-%u", month, year); |
|---|
| 1916 | char *tdata = nvram_safe_get(tq); |
|---|
| 1917 | |
|---|
| 1918 | if (tdata != NULL || strlen(tdata)) { |
|---|
| 1919 | foreach(var, tdata, next) { |
|---|
| 1920 | if (i == days) |
|---|
| 1921 | break; //skip monthly total |
|---|
| 1922 | sscanf(var, "%lu:%lu", &rcvd[i], &sent[i]); |
|---|
| 1923 | totin += rcvd[i]; |
|---|
| 1924 | totout += sent[i]; |
|---|
| 1925 | if (rcvd[i] > max) |
|---|
| 1926 | max = rcvd[i]; |
|---|
| 1927 | if (sent[i] > max) |
|---|
| 1928 | max = sent[i]; |
|---|
| 1929 | i++; |
|---|
| 1930 | } |
|---|
| 1931 | } |
|---|
| 1932 | |
|---|
| 1933 | while (max > smax) { |
|---|
| 1934 | if (max > (f * 5)) |
|---|
| 1935 | smax = f * 10; |
|---|
| 1936 | if (max > (f * 10)) |
|---|
| 1937 | smax = f * 25; |
|---|
| 1938 | if (max > (f * 25)) |
|---|
| 1939 | smax = f * 50; |
|---|
| 1940 | f = f * 10; |
|---|
| 1941 | } |
|---|
| 1942 | |
|---|
| 1943 | char incom[32]; |
|---|
| 1944 | |
|---|
| 1945 | sprintf(incom, "%s", live_translate("status_inet.traffin")); |
|---|
| 1946 | char outcom[32]; |
|---|
| 1947 | |
|---|
| 1948 | sprintf(outcom, "%s", live_translate("status_inet.traffout")); |
|---|
| 1949 | char monthname[32]; |
|---|
| 1950 | |
|---|
| 1951 | sprintf(monthname, "%s", live_translate(months[month - 1])); |
|---|
| 1952 | |
|---|
| 1953 | websWrite(stream, |
|---|
| 1954 | "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"); |
|---|
| 1955 | websWrite(stream, "<html>\n"); |
|---|
| 1956 | websWrite(stream, "<head>\n"); |
|---|
| 1957 | websWrite(stream, |
|---|
| 1958 | "<meta http-equiv=\"Content-Type\" content=\"application/xhtml+xml; charset=%s\" />\n", |
|---|
| 1959 | live_translate("lang_charset.set")); |
|---|
| 1960 | websWrite(stream, "<title>dd-wrt traffic graph</title>\n"); |
|---|
| 1961 | |
|---|
| 1962 | websWrite(stream, "<script type=\"text/javascript\">\n"); |
|---|
| 1963 | websWrite(stream, "//<![CDATA[\n"); |
|---|
| 1964 | websWrite(stream, "function Show(label) {\n"); |
|---|
| 1965 | websWrite(stream, |
|---|
| 1966 | "document.getElementById(\"label\").innerHTML = label;\n"); |
|---|
| 1967 | websWrite(stream, "}\n"); |
|---|
| 1968 | websWrite(stream, "//]]>\n"); |
|---|
| 1969 | websWrite(stream, "</script>\n"); |
|---|
| 1970 | |
|---|
| 1971 | websWrite(stream, "<style type=\"text/css\">\n\n"); |
|---|
| 1972 | websWrite(stream, |
|---|
| 1973 | "#t-graph {position: relative; width: %upx; height: 300px;\n", |
|---|
| 1974 | days * COL_WIDTH); |
|---|
| 1975 | websWrite(stream, " margin: 1.1em 0 3.5em; padding: 0;\n"); |
|---|
| 1976 | websWrite(stream, " border: 1px solid gray; list-style: none;\n"); |
|---|
| 1977 | websWrite(stream, " font: 9px Tahoma, Arial, sans-serif;}\n"); |
|---|
| 1978 | websWrite(stream, |
|---|
| 1979 | "#t-graph ul {margin: 0; padding: 0; list-style: none;}\n"); |
|---|
| 1980 | websWrite(stream, |
|---|
| 1981 | "#t-graph li {position: absolute; bottom: 0; width: %dpx; z-index: 2;\n", |
|---|
| 1982 | COL_WIDTH); |
|---|
| 1983 | websWrite(stream, " margin: 0; padding: 0;\n"); |
|---|
| 1984 | websWrite(stream, " text-align: center; list-style: none;}\n"); |
|---|
| 1985 | websWrite(stream, |
|---|
| 1986 | "#t-graph li.day {height: 298px; padding-top: 2px; border-right: 1px dotted #C4C4C4; color: #AAA;}\n"); |
|---|
| 1987 | websWrite(stream, |
|---|
| 1988 | "#t-graph li.day_sun {height: 298px; padding-top: 2px; border-right: 1px dotted #C4C4C4; color: #E00;}\n"); |
|---|
| 1989 | websWrite(stream, |
|---|
| 1990 | "#t-graph li.bar {width: 4px; border: 1px solid; border-bottom: none; color: #000;}\n"); |
|---|
| 1991 | websWrite(stream, "#t-graph li.bar p {margin: 5px 0 0; padding: 0;}\n"); |
|---|
| 1992 | websWrite(stream, "#t-graph li.rcvd {left: 3px; background: #228B22;}\n"); // set |
|---|
| 1993 | // rcvd |
|---|
| 1994 | // bar |
|---|
| 1995 | // colour |
|---|
| 1996 | // here |
|---|
| 1997 | // (green) |
|---|
| 1998 | websWrite(stream, "#t-graph li.sent {left: 8px; background: #CD0000;}\n"); // set |
|---|
| 1999 | // sent |
|---|
| 2000 | // bar |
|---|
| 2001 | // colour |
|---|
| 2002 | // here |
|---|
| 2003 | // (red) |
|---|
| 2004 | |
|---|
| 2005 | for (i = 0; i < days - 1; i++) { |
|---|
| 2006 | websWrite(stream, "#t-graph #d%d {left: %dpx;}\n", i + 1, |
|---|
| 2007 | i * COL_WIDTH); |
|---|
| 2008 | } |
|---|
| 2009 | websWrite(stream, "#t-graph #d%u {left: %upx; border-right: none;}\n", |
|---|
| 2010 | days, (days - 1) * COL_WIDTH); |
|---|
| 2011 | |
|---|
| 2012 | websWrite(stream, |
|---|
| 2013 | "#t-graph #ticks {width: %upx; height: 300px; z-index: 1;}\n", |
|---|
| 2014 | days * COL_WIDTH); |
|---|
| 2015 | websWrite(stream, |
|---|
| 2016 | "#t-graph #ticks .tick {position: relative; border-bottom: 1px solid #BBB; width: %upx;}\n", |
|---|
| 2017 | days * COL_WIDTH); |
|---|
| 2018 | websWrite(stream, |
|---|
| 2019 | "#t-graph #ticks .tick p {position: absolute; left: 100%%; top: -0.67em; margin: 0 0 0 0.5em;}\n"); |
|---|
| 2020 | websWrite(stream, |
|---|
| 2021 | "#t-graph #label {width: 500px; bottom: -20px; z-index: 1; font: 12px Tahoma, Arial, sans-serif; font-weight: bold;}\n"); |
|---|
| 2022 | websWrite(stream, "</style>\n"); |
|---|
| 2023 | websWrite(stream, "</head>\n\n"); |
|---|
| 2024 | websWrite(stream, "<body>\n"); |
|---|
| 2025 | websWrite(stream, "<ul id=\"t-graph\">\n"); |
|---|
| 2026 | |
|---|
| 2027 | for (i = 0; i < days; i++) { |
|---|
| 2028 | websWrite(stream, "<li class=\"day%s\" id=\"d%d\" ", |
|---|
| 2029 | (wd % 7) == 6 ? "_sun" : "", i + 1); |
|---|
| 2030 | wd++; |
|---|
| 2031 | websWrite(stream, |
|---|
| 2032 | "onmouseover=\"Show(\'%s %d, %d (%s: %lu MB / %s: %lu MB)\')\" ", |
|---|
| 2033 | monthname, i + 1, year, incom, rcvd[i], outcom, |
|---|
| 2034 | sent[i]); |
|---|
| 2035 | websWrite(stream, |
|---|
| 2036 | "onmouseout=\"Show(\'%s %d (%s: %lu MB / %s: %lu MB)\')\"", |
|---|
| 2037 | monthname, year, incom, totin, outcom, totout); |
|---|
| 2038 | websWrite(stream, ">%d\n", i + 1); |
|---|
| 2039 | websWrite(stream, "<ul>\n"); |
|---|
| 2040 | websWrite(stream, |
|---|
| 2041 | "<li class=\"rcvd bar\" style=\"height: %lupx;\"><p></p></li>\n", |
|---|
| 2042 | rcvd[i] * 300 / smax); |
|---|
| 2043 | websWrite(stream, |
|---|
| 2044 | "<li class=\"sent bar\" style=\"height: %lupx;\"><p></p></li>\n", |
|---|
| 2045 | sent[i] * 300 / smax); |
|---|
| 2046 | websWrite(stream, "</ul>\n"); |
|---|
| 2047 | websWrite(stream, "</li>\n"); |
|---|
| 2048 | } |
|---|
| 2049 | |
|---|
| 2050 | websWrite(stream, "<li id=\"ticks\">\n"); |
|---|
| 2051 | for (i = 5; i; i--) // scale |
|---|
| 2052 | { |
|---|
| 2053 | websWrite(stream, |
|---|
| 2054 | "<div class=\"tick\" style=\"height: 59px;\"><p>%d%sMB</p></div>\n", |
|---|
| 2055 | smax * i / 5, (smax > 10000) ? " " : " "); |
|---|
| 2056 | } |
|---|
| 2057 | websWrite(stream, "</li>\n\n"); |
|---|
| 2058 | |
|---|
| 2059 | websWrite(stream, "<li id=\"label\">\n"); |
|---|
| 2060 | websWrite(stream, "%s %d (%s: %lu MB / %s: %lu MB)\n", monthname, year, |
|---|
| 2061 | incom, totin, outcom, totout); |
|---|
| 2062 | websWrite(stream, "</li>\n"); |
|---|
| 2063 | |
|---|
| 2064 | websWrite(stream, "</ul>\n\n"); |
|---|
| 2065 | websWrite(stream, "</body>\n"); |
|---|
| 2066 | websWrite(stream, "</html>\n"); |
|---|
| 2067 | |
|---|
| 2068 | } |
|---|
| 2069 | |
|---|
| 2070 | static void ttraff_backup(struct mime_handler *handler, char *url, |
|---|
| 2071 | webs_t stream, char *query) |
|---|
| 2072 | { |
|---|
| 2073 | system2("echo TRAFF-DATA > /tmp/traffdata.bak"); |
|---|
| 2074 | system2("nvram show | grep traff- >> /tmp/traffdata.bak"); |
|---|
| 2075 | do_file_attach(handler, "/tmp/traffdata.bak", stream, NULL, |
|---|
| 2076 | "traffdata.bak"); |
|---|
| 2077 | unlink("/tmp/traffdata.bak"); |
|---|
| 2078 | } |
|---|
| 2079 | |
|---|
| 2080 | static void do_apply_cgi(struct mime_handler *handler, char *url, |
|---|
| 2081 | webs_t stream, char *q) |
|---|
| 2082 | { |
|---|
| 2083 | char *path, *query; |
|---|
| 2084 | |
|---|
| 2085 | if (post == 1) { |
|---|
| 2086 | query = post_buf; |
|---|
| 2087 | path = url; |
|---|
| 2088 | } else { |
|---|
| 2089 | query = url; |
|---|
| 2090 | path = strsep(&query, "?") ? : url; |
|---|
| 2091 | init_cgi(query); |
|---|
| 2092 | } |
|---|
| 2093 | |
|---|
| 2094 | if (!query) |
|---|
| 2095 | return; |
|---|
| 2096 | |
|---|
| 2097 | apply_cgi(stream, NULL, NULL, 0, url, path, query); |
|---|
| 2098 | init_cgi(NULL); |
|---|
| 2099 | } |
|---|
| 2100 | |
|---|
| 2101 | #ifdef HAVE_MADWIFI |
|---|
| 2102 | extern int getdevicecount(void); |
|---|
| 2103 | #endif |
|---|
| 2104 | |
|---|
| 2105 | #ifdef HAVE_LANGUAGE |
|---|
| 2106 | static void do_language(struct mime_handler *handler, char *path, webs_t stream, char *query) // jimmy, |
|---|
| 2107 | // https, |
|---|
| 2108 | // 8/4/2003 |
|---|
| 2109 | { |
|---|
| 2110 | char *lang = getLanguageName(); |
|---|
| 2111 | |
|---|
| 2112 | do_file(handler, lang, stream, NULL); |
|---|
| 2113 | free(lang); |
|---|
| 2114 | return; |
|---|
| 2115 | } |
|---|
| 2116 | #endif |
|---|
| 2117 | |
|---|
| 2118 | extern int issuperchannel(void); |
|---|
| 2119 | |
|---|
| 2120 | static char no_cache[] = |
|---|
| 2121 | "Cache-Control: no-cache\r\n" "Pragma: no-cache\r\n" "Expires: 0"; |
|---|
| 2122 | |
|---|
| 2123 | struct mime_handler mime_handlers[] = { |
|---|
| 2124 | // { "ezconfig.asp", "text/html", ezc_version, do_apply_ezconfig_post, |
|---|
| 2125 | // do_ezconfig_asp, do_auth }, |
|---|
| 2126 | #ifdef HAVE_SKYTRON |
|---|
| 2127 | {"setupindex*", "text/html", no_cache, NULL, do_ej, do_auth2, 1}, |
|---|
| 2128 | #endif |
|---|
| 2129 | #ifdef HAVE_DDLAN |
|---|
| 2130 | {"Upgrade*", "text/html", no_cache, NULL, do_ej, do_auth2, 1}, |
|---|
| 2131 | {"Management*", "text/html", no_cache, NULL, do_ej, do_auth2, 1}, |
|---|
| 2132 | {"Services*", "text/html", no_cache, NULL, do_ej, do_auth2, 1}, |
|---|
| 2133 | {"Hotspot*", "text/html", no_cache, NULL, do_ej, do_auth2, 1}, |
|---|
| 2134 | {"Wireless*", "text/html", no_cache, NULL, do_ej, do_auth2, 1}, |
|---|
| 2135 | {"WL_*", "text/html", no_cache, NULL, do_ej, do_auth2, 1}, |
|---|
| 2136 | {"WPA*", "text/html", no_cache, NULL, do_ej, do_auth2, 1}, |
|---|
| 2137 | {"Log*", "text/html", no_cache, NULL, do_ej, do_auth2, 1}, |
|---|
| 2138 | {"Alive*", "text/html", no_cache, NULL, do_ej, do_auth2, 1}, |
|---|
| 2139 | {"Diagnostics*", "text/html", no_cache, NULL, do_ej, do_auth2, 1}, |
|---|
| 2140 | {"Wol*", "text/html", no_cache, NULL, do_ej, do_auth2, 1}, |
|---|
| 2141 | {"Factory_Defaults*", "text/html", no_cache, NULL, do_ej, do_auth2, 1}, |
|---|
| 2142 | {"config*", "text/html", no_cache, NULL, do_ej, do_auth2, 1}, |
|---|
| 2143 | #endif |
|---|
| 2144 | |
|---|
| 2145 | {"changepass.asp", "text/html", no_cache, NULL, do_ej, NULL, 1}, |
|---|
| 2146 | #ifdef HAVE_REGISTER |
|---|
| 2147 | {"register.asp", "text/html", no_cache, NULL, do_ej, do_auth_reg, 1}, |
|---|
| 2148 | #endif |
|---|
| 2149 | {"WL_FilterTable*", "text/html", no_cache, NULL, do_filtertable, |
|---|
| 2150 | do_auth, |
|---|
| 2151 | 1}, |
|---|
| 2152 | // #endif |
|---|
| 2153 | // #ifdef HAVE_MADWIFI |
|---|
| 2154 | {"Wireless_WDS*", "text/html", no_cache, NULL, do_wds, do_auth, 1}, |
|---|
| 2155 | {"WL_ActiveTable*", "text/html", no_cache, NULL, do_activetable, |
|---|
| 2156 | do_auth, 1}, |
|---|
| 2157 | {"Wireless_Advanced*", "text/html", no_cache, NULL, do_wireless_adv, |
|---|
| 2158 | do_auth, 1}, |
|---|
| 2159 | // #endif |
|---|
| 2160 | {"**.asp", "text/html", no_cache, NULL, do_ej, do_auth, 1}, |
|---|
| 2161 | {"**.JPG", "image/jpeg", no_cache, NULL, do_file, NULL, 0}, |
|---|
| 2162 | // {"style.css", "text/css", NULL, NULL, do_style, NULL}, |
|---|
| 2163 | {"common.js", "text/javascript", NULL, NULL, do_file, NULL, 0}, |
|---|
| 2164 | #ifdef HAVE_LANGUAGE |
|---|
| 2165 | {"lang_pack/language.js", "text/javascript", NULL, NULL, do_language, |
|---|
| 2166 | NULL, 0}, |
|---|
| 2167 | #endif |
|---|
| 2168 | {"SysInfo.htm*", "text/plain", no_cache, NULL, do_ej, do_auth, 1}, |
|---|
| 2169 | #ifdef HAVE_SKYTRON |
|---|
| 2170 | {"Info.htm*", "text/html", no_cache, NULL, do_ej, do_auth2, 1}, |
|---|
| 2171 | {"Info.live.htm", "text/html", no_cache, NULL, do_ej, do_auth, 1}, |
|---|
| 2172 | {"**.htm", "text/html", no_cache, NULL, do_ej, do_auth2, 1}, |
|---|
| 2173 | {"**.html", "text/html", no_cache, NULL, do_ej, do_auth2, 1}, |
|---|
| 2174 | #else |
|---|
| 2175 | {"Info.htm*", "text/html", no_cache, NULL, do_ej, do_cauth, 1}, |
|---|
| 2176 | {"Info.live.htm", "text/html", no_cache, NULL, do_ej, do_cauth, 1}, |
|---|
| 2177 | {"**.htm", "text/html", no_cache, NULL, do_ej, NULL, 1}, |
|---|
| 2178 | {"**.html", "text/html", no_cache, NULL, do_ej, NULL, 1}, |
|---|
| 2179 | |
|---|
| 2180 | #endif |
|---|
| 2181 | #ifdef HAVE_ROUTERSTYLE |
|---|
| 2182 | {"style/blue/style.css", "text/css", NULL, NULL, do_stylecss, NULL, 1}, |
|---|
| 2183 | {"style/cyan/style.css", "text/css", NULL, NULL, do_stylecss, NULL, 1}, |
|---|
| 2184 | {"style/elegant/style.css", "text/css", NULL, NULL, do_stylecss, NULL, |
|---|
| 2185 | 1}, |
|---|
| 2186 | {"style/green/style.css", "text/css", NULL, NULL, do_stylecss, NULL, 1}, |
|---|
| 2187 | {"style/orange/style.css", "text/css", NULL, NULL, do_stylecss, NULL, |
|---|
| 2188 | 1}, |
|---|
| 2189 | {"style/red/style.css", "text/css", NULL, NULL, do_stylecss, NULL, 1}, |
|---|
| 2190 | {"style/yellow/style.css", "text/css", NULL, NULL, do_stylecss, NULL, |
|---|
| 2191 | 1}, |
|---|
| 2192 | {"style/blue/style_ie.css", "text/css", NULL, NULL, do_stylecss_ie, |
|---|
| 2193 | NULL, |
|---|
| 2194 | 1}, |
|---|
| 2195 | {"style/cyan/style_ie.css", "text/css", NULL, NULL, do_stylecss_ie, |
|---|
| 2196 | NULL, |
|---|
| 2197 | 1}, |
|---|
| 2198 | {"style/elegant/style_ie.css", "text/css", NULL, NULL, do_stylecss_ie, |
|---|
| 2199 | NULL, 1}, |
|---|
| 2200 | {"style/green/style_ie.css", "text/css", NULL, NULL, do_stylecss_ie, |
|---|
| 2201 | NULL, |
|---|
| 2202 | 1}, |
|---|
| 2203 | {"style/orange/style_ie.css", "text/css", NULL, NULL, do_stylecss_ie, |
|---|
| 2204 | NULL, 1}, |
|---|
| 2205 | {"style/red/style_ie.css", "text/css", NULL, NULL, do_stylecss_ie, NULL, |
|---|
| 2206 | 1}, |
|---|
| 2207 | {"style/yellow/style_ie.css", "text/css", NULL, NULL, do_stylecss_ie, |
|---|
| 2208 | NULL, 1}, |
|---|
| 2209 | #endif |
|---|
| 2210 | #ifdef HAVE_REGISTER |
|---|
| 2211 | {"style/logo.png", "image/png", NULL, NULL, do_trial_logo, NULL, 0}, |
|---|
| 2212 | #endif |
|---|
| 2213 | {"**.css", "text/css", NULL, NULL, do_file, NULL, 0}, |
|---|
| 2214 | {"**.svg", "image/svg+xml", NULL, NULL, do_file, NULL, 0}, |
|---|
| 2215 | {"**.gif", "image/gif", NULL, NULL, do_file, NULL, 0}, |
|---|
| 2216 | {"**.png", "image/png", NULL, NULL, do_file, NULL, 0}, |
|---|
| 2217 | {"**.jpg", "image/jpeg", NULL, NULL, do_file, NULL, 0}, |
|---|
| 2218 | {"**.ico", "image/x-icon", NULL, NULL, do_file, NULL, 0}, |
|---|
| 2219 | {"**.js", "text/javascript", NULL, NULL, do_file, NULL, 0}, |
|---|
| 2220 | {"**.swf", "application/x-shockwave-flash", NULL, NULL, do_file, NULL, |
|---|
| 2221 | 0}, |
|---|
| 2222 | {"**.pdf", "application/pdf", NULL, NULL, do_file, NULL, 0}, |
|---|
| 2223 | {"**.mp4", "video/mp4", NULL, NULL, do_file, NULL, 0}, |
|---|
| 2224 | {"**.mp3", "audio/mpeg3", NULL, NULL, do_file, NULL, 0}, |
|---|
| 2225 | {"**.mpg", "video/mpeg", NULL, NULL, do_file, NULL, 0}, |
|---|
| 2226 | {"**.avi", "video/x-msvideo", NULL, NULL, do_file, NULL, 0}, |
|---|
| 2227 | {"**.wma", "audio/x-ms-wma", NULL, NULL, do_file, NULL, 0}, |
|---|
| 2228 | {"**.wmv", "video/x-ms-wmv", NULL, NULL, do_file, NULL, 0}, |
|---|
| 2229 | {"**.flv", "video/x-flv", NULL, NULL, do_file, NULL, 0}, |
|---|
| 2230 | #ifdef HAVE_SKYTRON |
|---|
| 2231 | {"applyuser.cgi*", "text/html", no_cache, do_apply_post, do_apply_cgi, |
|---|
| 2232 | do_auth2, 1}, |
|---|
| 2233 | #elif HAVE_DDLAN |
|---|
| 2234 | {"applyuser.cgi*", "text/html", no_cache, do_apply_post, do_apply_cgi, |
|---|
| 2235 | NULL, 1}, |
|---|
| 2236 | #else |
|---|
| 2237 | {"applyuser.cgi*", "text/html", no_cache, do_apply_post, do_apply_cgi, |
|---|
| 2238 | do_auth, 1}, |
|---|
| 2239 | #endif |
|---|
| 2240 | {"fetchif.cgi*", "text/html", no_cache, NULL, do_fetchif, do_auth, 1}, |
|---|
| 2241 | #ifdef HAVE_DDLAN |
|---|
| 2242 | {"apply.cgi*", "text/html", no_cache, do_apply_post, do_apply_cgi, NULL, |
|---|
| 2243 | 1}, |
|---|
| 2244 | {"upgrade.cgi*", "text/html", no_cache, do_upgrade_post, do_upgrade_cgi, |
|---|
| 2245 | NULL, 1}, |
|---|
| 2246 | #else |
|---|
| 2247 | {"apply.cgi*", "text/html", no_cache, do_apply_post, do_apply_cgi, |
|---|
| 2248 | do_auth, 1}, |
|---|
| 2249 | {"upgrade.cgi*", "text/html", no_cache, do_upgrade_post, do_upgrade_cgi, |
|---|
| 2250 | do_auth, 1}, |
|---|
| 2251 | #endif |
|---|
| 2252 | // {"Gozila.cgi*", "text/html", no_cache, NULL, do_setup_wizard, |
|---|
| 2253 | // do_auth}, // for setup wizard |
|---|
| 2254 | /* |
|---|
| 2255 | * { "**.cfg", "application/octet-stream", no_cache, NULL, do_backup, |
|---|
| 2256 | * do_auth }, |
|---|
| 2257 | */ |
|---|
| 2258 | #ifdef HAVE_DDLAN |
|---|
| 2259 | {"restore.cgi**", "text/html", no_cache, do_upgrade_post, |
|---|
| 2260 | do_upgrade_cgi, |
|---|
| 2261 | NULL, 1}, |
|---|
| 2262 | #else |
|---|
| 2263 | {"restore.cgi**", "text/html", no_cache, do_upgrade_post, |
|---|
| 2264 | do_upgrade_cgi, |
|---|
| 2265 | do_auth, 1}, |
|---|
| 2266 | #endif |
|---|
| 2267 | {"test.bin**", "application/octet-stream", no_cache, NULL, do_file, |
|---|
| 2268 | do_auth, 0}, |
|---|
| 2269 | |
|---|
| 2270 | #ifdef HAVE_DDLAN |
|---|
| 2271 | {"nvrambak.bin*", "application/octet-stream", no_cache, NULL, |
|---|
| 2272 | nv_file_out, |
|---|
| 2273 | do_auth2, 0}, |
|---|
| 2274 | {"nvrambak**.bin*", "application/octet-stream", no_cache, NULL, |
|---|
| 2275 | nv_file_out, |
|---|
| 2276 | do_auth2, 0}, |
|---|
| 2277 | {"nvram.cgi*", "text/html", no_cache, nv_file_in, sr_config_cgi, NULL, |
|---|
| 2278 | 1}, |
|---|
| 2279 | #else |
|---|
| 2280 | {"nvrambak.bin*", "application/octet-stream", no_cache, NULL, |
|---|
| 2281 | nv_file_out, |
|---|
| 2282 | do_auth, 0}, |
|---|
| 2283 | {"nvrambak**.bin*", "application/octet-stream", no_cache, NULL, |
|---|
| 2284 | nv_file_out, |
|---|
| 2285 | do_auth, 0}, |
|---|
| 2286 | {"nvram.cgi*", "text/html", no_cache, nv_file_in, sr_config_cgi, |
|---|
| 2287 | do_auth, |
|---|
| 2288 | 1}, |
|---|
| 2289 | #endif |
|---|
| 2290 | #if !defined(HAVE_X86) && !defined(HAVE_MAGICBOX) |
|---|
| 2291 | {"backup/cfe.bin", "application/octet-stream", no_cache, NULL, |
|---|
| 2292 | do_cfebackup, |
|---|
| 2293 | do_auth, 0}, |
|---|
| 2294 | #endif |
|---|
| 2295 | {"ttgraph.cgi*", "text/html", no_cache, NULL, do_ttgraph, do_auth, 1}, |
|---|
| 2296 | {"traffdata.bak*", "text/html", no_cache, NULL, ttraff_backup, |
|---|
| 2297 | do_auth, 0}, |
|---|
| 2298 | {"tadmin.cgi*", "text/html", no_cache, td_file_in, td_config_cgi, |
|---|
| 2299 | NULL, 1}, |
|---|
| 2300 | {"*", "application/octet-stream", no_cache, NULL, do_file, do_auth, 1}, |
|---|
| 2301 | // for ddm |
|---|
| 2302 | {NULL, NULL, NULL, NULL, NULL, NULL, 0} |
|---|
| 2303 | }; |
|---|
| 2304 | |
|---|
| 2305 | /* |
|---|
| 2306 | * Format: type = SET : " " => " " , ":" => ";" type = GET : |
|---|
| 2307 | * " " => " " , ";" => ":" Example: name1 = test 123:abc |
|---|
| 2308 | * filter_name("name1", new_name, SET); new_name="test 123;abc" |
|---|
| 2309 | * name2 = test 123;abc filter_name("name2", new_name, GET); |
|---|
| 2310 | * new_name="test 123:abc" |
|---|
| 2311 | */ |
|---|
| 2312 | int httpd_filter_name(char *old_name, char *new_name, size_t size, int type) |
|---|
| 2313 | { |
|---|
| 2314 | int i, j, match; |
|---|
| 2315 | |
|---|
| 2316 | cprintf("httpd_filter_name\n"); |
|---|
| 2317 | |
|---|
| 2318 | struct pattern { |
|---|
| 2319 | char ch; |
|---|
| 2320 | char *string; |
|---|
| 2321 | }; |
|---|
| 2322 | |
|---|
| 2323 | struct pattern patterns[] = { |
|---|
| 2324 | {' ', " "}, |
|---|
| 2325 | {':', ";"}, |
|---|
| 2326 | }; |
|---|
| 2327 | |
|---|
| 2328 | struct pattern *v; |
|---|
| 2329 | |
|---|
| 2330 | strcpy(new_name, ""); |
|---|
| 2331 | |
|---|
| 2332 | switch (type) { |
|---|
| 2333 | case SET: |
|---|
| 2334 | for (i = 0; *(old_name + i); i++) { |
|---|
| 2335 | match = 0; |
|---|
| 2336 | for (v = patterns; v < &patterns[STRUCT_LEN(patterns)]; |
|---|
| 2337 | v++) { |
|---|
| 2338 | if (*(old_name + i) == v->ch) { |
|---|
| 2339 | if (strlen(new_name) + strlen(v->string) > size) { // avoid overflow |
|---|
| 2340 | cprintf("%s(): overflow\n", |
|---|
| 2341 | __FUNCTION__); |
|---|
| 2342 | new_name[strlen(new_name)] = |
|---|
| 2343 | '\0'; |
|---|
| 2344 | return 1; |
|---|
| 2345 | } |
|---|
| 2346 | sprintf(new_name + strlen(new_name), |
|---|
| 2347 | "%s", v->string); |
|---|
| 2348 | match = 1; |
|---|
| 2349 | break; |
|---|
| 2350 | } |
|---|
| 2351 | } |
|---|
| 2352 | if (!match) { |
|---|
| 2353 | if (strlen(new_name) + 1 > size) { |
|---|
| 2354 | cprintf("%s(): overflow\n", __FUNCTION__); // avoid |
|---|
| 2355 | // overflow |
|---|
| 2356 | new_name[strlen(new_name)] = '\0'; |
|---|
| 2357 | return 1; |
|---|
| 2358 | } |
|---|
| 2359 | sprintf(new_name + strlen(new_name), "%c", |
|---|
| 2360 | *(old_name + i)); |
|---|
| 2361 | } |
|---|
| 2362 | } |
|---|
| 2363 | |
|---|
| 2364 | break; |
|---|
| 2365 | case GET: |
|---|
| 2366 | for (i = 0, j = 0; *(old_name + j); j++) { |
|---|
| 2367 | match = 0; |
|---|
| 2368 | for (v = patterns; v < &patterns[STRUCT_LEN(patterns)]; |
|---|
| 2369 | v++) { |
|---|
| 2370 | if (!memcmp |
|---|
| 2371 | (old_name + j, v->string, |
|---|
| 2372 | strlen(v->string))) { |
|---|
| 2373 | *(new_name + i) = v->ch; |
|---|
| 2374 | j = j + strlen(v->string) - 1; |
|---|
| 2375 | match = 1; |
|---|
| 2376 | break; |
|---|
| 2377 | } |
|---|
| 2378 | } |
|---|
| 2379 | if (!match) |
|---|
| 2380 | *(new_name + i) = *(old_name + j); |
|---|
| 2381 | |
|---|
| 2382 | i++; |
|---|
| 2383 | } |
|---|
| 2384 | *(new_name + i) = '\0'; |
|---|
| 2385 | break; |
|---|
| 2386 | default: |
|---|
| 2387 | cprintf("%s():Invalid type!\n", __FUNCTION__); |
|---|
| 2388 | break; |
|---|
| 2389 | } |
|---|
| 2390 | // cprintf("%s():new_name=[%s]\n", __FUNCTION__, new_name); |
|---|
| 2391 | |
|---|
| 2392 | return 1; |
|---|
| 2393 | } |
|---|
| 2394 | |
|---|
| 2395 | #if 0 |
|---|
| 2396 | struct ej_handler ej_handlers[] = { |
|---|
| 2397 | /* |
|---|
| 2398 | * for all |
|---|
| 2399 | */ |
|---|
| 2400 | {"nvram_get", ej_nvram_get}, |
|---|
| 2401 | /* |
|---|
| 2402 | * { "nvram_get_len", ej_nvram_get_len }, |
|---|
| 2403 | */ |
|---|
| 2404 | {"nvram_selget", ej_nvram_selget}, |
|---|
| 2405 | {"nvram_match", ej_nvram_match}, |
|---|
| 2406 | {"nvram_invmatch", ej_nvram_invmatch}, |
|---|
| 2407 | {"nvram_selmatch", ej_nvram_selmatch}, |
|---|
| 2408 | {"nvram_else_selmatch", ej_nvram_else_selmatch}, |
|---|
| 2409 | {"nvram_else_match", ej_nvram_else_match}, |
|---|
| 2410 | {"tran", ej_tran}, |
|---|
| 2411 | {"nvram_list", ej_nvram_list}, |
|---|
| 2412 | {"nvram_mac_get", ej_nvram_mac_get}, |
|---|
| 2413 | {"nvram_gozila_get", ej_nvram_gozila_get}, |
|---|
| 2414 | {"nvram_status_get", ej_nvram_status_get}, |
|---|
| 2415 | {"nvram_real_get", ej_nvram_real_get}, |
|---|
| 2416 | {"webs_get", ej_webs_get}, |
|---|
| 2417 | {"get_firmware_version", ej_get_firmware_version}, |
|---|
| 2418 | {"get_firmware_title", ej_get_firmware_title}, |
|---|
| 2419 | {"get_firmware_svnrev", ej_get_firmware_svnrev}, |
|---|
| 2420 | {"get_model_name", ej_get_model_name}, |
|---|
| 2421 | {"showad", ej_showad}, |
|---|
| 2422 | {"get_single_ip", ej_get_single_ip}, |
|---|
| 2423 | {"get_single_mac", ej_get_single_mac}, |
|---|
| 2424 | {"prefix_ip_get", ej_prefix_ip_get}, |
|---|
| 2425 | {"no_cache", ej_no_cache}, |
|---|
| 2426 | // {"scroll", ej_scroll}, |
|---|
| 2427 | {"get_dns_ip", ej_get_dns_ip}, |
|---|
| 2428 | {"onload", ej_onload}, |
|---|
| 2429 | {"get_web_page_name", ej_get_web_page_name}, |
|---|
| 2430 | {"show_logo", ej_show_logo}, |
|---|
| 2431 | {"get_clone_mac", ej_get_clone_mac}, |
|---|
| 2432 | /* |
|---|
| 2433 | * for index |
|---|
| 2434 | */ |
|---|
| 2435 | {"show_index_setting", ej_show_index_setting}, |
|---|
| 2436 | {"compile_date", ej_compile_date}, |
|---|
| 2437 | {"compile_time", ej_compile_time}, |
|---|
| 2438 | {"get_wl_max_channel", ej_get_wl_max_channel}, |
|---|
| 2439 | {"get_wl_domain", ej_get_wl_domain}, |
|---|
| 2440 | /* |
|---|
| 2441 | * for status |
|---|
| 2442 | */ |
|---|
| 2443 | {"show_status", ej_show_status}, |
|---|
| 2444 | {"show_status_setting", ej_show_status_setting}, |
|---|
| 2445 | {"localtime", ej_localtime}, |
|---|
| 2446 | {"dhcp_remaining_time", ej_dhcp_remaining_time}, |
|---|
| 2447 | {"show_wan_domain", ej_show_wan_domain}, |
|---|
| 2448 | {"show_wl_mac", ej_show_wl_mac}, |
|---|
| 2449 | {"dumpip_conntrack", ej_dumpip_conntrack}, |
|---|
| 2450 | {"ip_conntrack_table", ej_ip_conntrack_table}, |
|---|
| 2451 | {"gethostnamebyip", ej_gethostnamebyip}, |
|---|
| 2452 | /* |
|---|
| 2453 | * for dhcp |
|---|
| 2454 | */ |
|---|
| 2455 | {"dumpleases", ej_dumpleases}, |
|---|
| 2456 | /* |
|---|
| 2457 | * for ddm |
|---|
| 2458 | */ |
|---|
| 2459 | /* |
|---|
| 2460 | * for log |
|---|
| 2461 | */ |
|---|
| 2462 | {"dumplog", ej_dumplog}, |
|---|
| 2463 | #ifdef HAVE_SPUTNIK_APD |
|---|
| 2464 | {"sputnik_apd_status", ej_sputnik_apd_status}, |
|---|
| 2465 | // {"show_sputnik", ej_show_sputnik}, |
|---|
| 2466 | #endif |
|---|
| 2467 | // {"show_openvpn", ej_show_openvpn}, |
|---|
| 2468 | {"show_openvpn_status", ej_show_openvpn_status}, |
|---|
| 2469 | /* |
|---|
| 2470 | * for filter |
|---|
| 2471 | */ |
|---|
| 2472 | {"filter_init", ej_filter_init}, |
|---|
| 2473 | {"filter_summary_show", ej_filter_summary_show}, |
|---|
| 2474 | {"filter_ip_get", ej_filter_ip_get}, |
|---|
| 2475 | {"filter_port_get", ej_filter_port_get}, |
|---|
| 2476 | {"filter_dport_get", ej_filter_dport_get}, |
|---|
| 2477 | {"filter_mac_get", ej_filter_mac_get}, |
|---|
| 2478 | {"filter_policy_select", ej_filter_policy_select}, |
|---|
| 2479 | {"filter_policy_get", ej_filter_policy_get}, |
|---|
| 2480 | {"filter_tod_get", ej_filter_tod_get}, |
|---|
| 2481 | {"filter_web_get", ej_filter_web_get}, |
|---|
| 2482 | {"filter_port_services_get", ej_filter_port_services_get}, |
|---|
| 2483 | /* |
|---|
| 2484 | * for forward |
|---|
| 2485 | */ |
|---|
| 2486 | // {"port_forward_table", ej_port_forward_table}, |
|---|
| 2487 | // {"port_forward_spec", ej_port_forward_spec}, |
|---|
| 2488 | // changed by steve |
|---|
| 2489 | // {"forward_upnp", ej_forward_upnp}, |
|---|
| 2490 | // end changed by steve |
|---|
| 2491 | /* |
|---|
| 2492 | * for route |
|---|
| 2493 | */ |
|---|
| 2494 | {"static_route_table", ej_static_route_table}, |
|---|
| 2495 | {"static_route_setting", ej_static_route_setting}, |
|---|
| 2496 | {"dump_route_table", ej_dump_route_table}, |
|---|
| 2497 | /* |
|---|
| 2498 | * for ddns |
|---|
| 2499 | */ |
|---|
| 2500 | {"show_ddns_status", ej_show_ddns_status}, |
|---|
| 2501 | {"show_usb_diskinfo", ej_show_usb_diskinfo}, |
|---|
| 2502 | // {"show_ddns_ip", ej_show_ddns_ip}, |
|---|
| 2503 | /* |
|---|
| 2504 | * for wireless |
|---|
| 2505 | */ |
|---|
| 2506 | {"wireless_active_table", ej_wireless_active_table}, |
|---|
| 2507 | {"wireless_filter_table", ej_wireless_filter_table}, |
|---|
| 2508 | {"show_wl_wep_setting", ej_show_wl_wep_setting}, |
|---|
| 2509 | {"get_wep_value", ej_get_wep_value}, |
|---|
| 2510 | {"get_wl_active_mac", ej_get_wl_active_mac}, |
|---|
| 2511 | {"get_wl_value", ej_get_wl_value}, |
|---|
| 2512 | |
|---|
| 2513 | // {"show_wpa_setting", ej_show_wpa_setting}, |
|---|
| 2514 | /* |
|---|
| 2515 | * for test |
|---|
| 2516 | */ |
|---|
| 2517 | {"wl_packet_get", ej_wl_packet_get}, |
|---|
| 2518 | {"wl_ioctl", ej_wl_ioctl}, |
|---|
| 2519 | {"dump_ping_log", ej_dump_ping_log}, |
|---|
| 2520 | // {"dump_traceroute_log", ej_dump_traceroute_log}, |
|---|
| 2521 | // {"get_http_method", ej_get_http_method}, |
|---|
| 2522 | /* |
|---|
| 2523 | * { "get_backup_name", ej_get_backup_name }, |
|---|
| 2524 | */ |
|---|
| 2525 | /* |
|---|
| 2526 | * { "per_port_option", ej_per_port_option}, |
|---|
| 2527 | */ |
|---|
| 2528 | {"get_http_prefix", ej_get_http_prefix}, |
|---|
| 2529 | {"dump_site_survey", ej_dump_site_survey}, |
|---|
| 2530 | // {"show_meminfo", ej_show_meminfo}, |
|---|
| 2531 | {"get_mtu", ej_get_mtu}, |
|---|
| 2532 | {"get_url", ej_get_url}, |
|---|
| 2533 | /* |
|---|
| 2534 | * Sveasoft additions |
|---|
| 2535 | */ |
|---|
| 2536 | {"get_wdsp2p", ej_get_wdsp2p}, |
|---|
| 2537 | {"active_wireless", ej_active_wireless}, |
|---|
| 2538 | #ifdef HAVE_SKYTRON |
|---|
| 2539 | {"active_wireless2", ej_active_wireless2}, |
|---|
| 2540 | #endif |
|---|
| 2541 | {"active_wds", ej_active_wds}, |
|---|
| 2542 | {"get_wds_mac", ej_get_wds_mac}, |
|---|
| 2543 | {"get_wds_ip", ej_get_wds_ip}, |
|---|
| 2544 | {"get_wds_netmask", ej_get_wds_netmask}, |
|---|
| 2545 | {"get_wds_gw", ej_get_wds_gw}, |
|---|
| 2546 | {"get_br1_ip", ej_get_br1_ip}, |
|---|
| 2547 | {"get_br1_netmask", ej_get_br1_netmask}, |
|---|
| 2548 | {"get_curchannel", ej_get_curchannel}, |
|---|
| 2549 | {"get_currate", ej_get_currate}, |
|---|
| 2550 | {"get_uptime", ej_get_uptime}, |
|---|
| 2551 | {"get_wan_uptime", ej_get_wan_uptime}, |
|---|
| 2552 | // {"get_services_options", ej_get_services_options}, |
|---|
| 2553 | {"get_clone_wmac", ej_get_clone_wmac}, |
|---|
| 2554 | {"show_modules", ej_show_modules}, |
|---|
| 2555 | {"show_styles", ej_show_styles}, |
|---|
| 2556 | #ifdef HAVE_LANGUAGE |
|---|
| 2557 | {"show_languages", ej_show_languages}, |
|---|
| 2558 | #endif |
|---|
| 2559 | {"show_forward", ej_show_forward}, |
|---|
| 2560 | {"show_forward_spec", ej_show_forward_spec}, |
|---|
| 2561 | {"show_triggering", ej_show_triggering}, |
|---|
| 2562 | {"nvram_selected", ej_nvram_selected}, |
|---|
| 2563 | {"nvram_selected_js", ej_nvram_selected_js}, |
|---|
| 2564 | {"nvram_checked", ej_nvram_checked}, |
|---|
| 2565 | {"nvram_checked_js", ej_nvram_checked_js}, |
|---|
| 2566 | {"get_qossvcs", ej_get_qossvcs}, |
|---|
| 2567 | {"get_qosips", ej_get_qosips}, |
|---|
| 2568 | {"get_qosmacs", ej_get_qosmacs}, |
|---|
| 2569 | // { "if_config_table",ej_if_config_table}, |
|---|
| 2570 | {"wme_match_op", ej_wme_match_op}, |
|---|
| 2571 | // { "show_advanced_qos", ej_show_advanced_qos }, |
|---|
| 2572 | #ifdef FBNFW |
|---|
| 2573 | {"list_fbn", ej_list_fbn}, |
|---|
| 2574 | #endif |
|---|
| 2575 | {"show_control", ej_show_control}, |
|---|
| 2576 | {"show_paypal", ej_show_paypal}, |
|---|
| 2577 | {"show_default_level", ej_show_default_level}, |
|---|
| 2578 | {"show_staticleases", ej_show_staticleases}, |
|---|
| 2579 | {"show_security", ej_show_security}, |
|---|
| 2580 | {"show_dhcpd_settings", ej_show_dhcpd_settings}, |
|---|
| 2581 | {"show_wds_subnet", ej_show_wds_subnet}, |
|---|
| 2582 | {"show_infopage", ej_show_infopage}, |
|---|
| 2583 | {"show_connectiontype", ej_show_connectiontype}, |
|---|
| 2584 | {"show_routing", ej_show_routing}, |
|---|
| 2585 | {"show_wireless", ej_show_wireless}, |
|---|
| 2586 | #ifdef HAVE_RADLOCAL |
|---|
| 2587 | {"show_iradius_check", ej_show_iradius_check}, |
|---|
| 2588 | {"show_iradius", ej_show_iradius}, |
|---|
| 2589 | #endif |
|---|
| 2590 | |
|---|
| 2591 | #ifdef HAVE_CHILLILOCAL |
|---|
| 2592 | {"show_userlist", ej_show_userlist}, |
|---|
| 2593 | #endif |
|---|
| 2594 | {"show_cpuinfo", ej_show_cpuinfo}, |
|---|
| 2595 | {"get_clkfreq", ej_get_clkfreq}, |
|---|
| 2596 | {"dumpmeminfo", ej_dumpmeminfo}, |
|---|
| 2597 | |
|---|
| 2598 | /* |
|---|
| 2599 | * Added by Botho 10.May.06 |
|---|
| 2600 | */ |
|---|
| 2601 | {"show_wan_to_switch", ej_show_wan_to_switch}, |
|---|
| 2602 | {"statfs", ej_statfs}, |
|---|
| 2603 | |
|---|
| 2604 | /* |
|---|
| 2605 | * lonewolf additions |
|---|
| 2606 | */ |
|---|
| 2607 | {"port_vlan_table", ej_port_vlan_table}, |
|---|
| 2608 | /* |
|---|
| 2609 | * end lonewolf additions |
|---|
| 2610 | */ |
|---|
| 2611 | #ifdef HAVE_UPNP |
|---|
| 2612 | {"tf_upnp", ej_tf_upnp}, |
|---|
| 2613 | #endif |
|---|
| 2614 | // {"charset", ej_charset}, |
|---|
| 2615 | {"do_menu", ej_do_menu}, // Eko |
|---|
| 2616 | {"do_pagehead", ej_do_pagehead}, // Eko |
|---|
| 2617 | {"do_hpagehead", ej_do_hpagehead}, // Eko |
|---|
| 2618 | {"show_timeoptions", ej_show_timeoptions}, // Eko |
|---|
| 2619 | {"show_wanipinfo", ej_show_wanipinfo}, // Eko |
|---|
| 2620 | #ifdef HAVE_OVERCLOCKING |
|---|
| 2621 | {"show_clocks", ej_show_clocks}, |
|---|
| 2622 | #endif |
|---|
| 2623 | {"make_time_list", ej_make_time_list}, // Eko |
|---|
| 2624 | {"getrebootflags", ej_getrebootflags}, |
|---|
| 2625 | {"getwirelessmode", ej_getwirelessmode}, |
|---|
| 2626 | {"getwirelessnetmode", ej_getwirelessnetmode}, |
|---|
| 2627 | {"getwirelessssid", ej_getwirelessssid}, |
|---|
| 2628 | {"radio_on", ej_radio_on}, |
|---|
| 2629 | {"get_radio_state", ej_get_radio_state}, |
|---|
| 2630 | {"dumparptable", ej_dumparptable}, |
|---|
| 2631 | #ifdef HAVE_WIVIZ |
|---|
| 2632 | {"dump_wiviz_data", ej_dump_wiviz_data}, // Eko, for testing only |
|---|
| 2633 | #endif |
|---|
| 2634 | #ifdef HAVE_EOP_TUNNEL |
|---|
| 2635 | {"show_eop_tunnels", ej_show_eop_tunnels}, |
|---|
| 2636 | #endif |
|---|
| 2637 | {"getwirelessstatus", ej_getwirelessstatus}, |
|---|
| 2638 | {"getencryptionstatus", ej_getencryptionstatus}, |
|---|
| 2639 | {"get_txpower", ej_get_txpower}, |
|---|
| 2640 | #ifdef HAVE_CPUTEMP |
|---|
| 2641 | {"get_cputemp", ej_get_cputemp}, |
|---|
| 2642 | {"show_cpu_temperature", ej_show_cpu_temperature}, |
|---|
| 2643 | #endif |
|---|
| 2644 | #ifdef HAVE_VOLT |
|---|
| 2645 | {"get_voltage", ej_get_voltage}, |
|---|
| 2646 | {"show_voltage", ej_show_voltage}, |
|---|
| 2647 | #endif |
|---|
| 2648 | #if defined(HAVE_REGISTER) || defined(HAVE_SUPERCHANNEL) |
|---|
| 2649 | {"getregcode", ej_getregcode}, |
|---|
| 2650 | #endif |
|---|
| 2651 | #ifdef HAVE_RSTATS |
|---|
| 2652 | {"bandwidth", ej_bandwidth}, |
|---|
| 2653 | #endif |
|---|
| 2654 | {"show_bandwidth", ej_show_bandwidth}, |
|---|
| 2655 | {"get_totaltraff", ej_get_totaltraff}, |
|---|
| 2656 | #ifdef HAVE_PORTSETUP |
|---|
| 2657 | {"portsetup", ej_portsetup}, |
|---|
| 2658 | #endif |
|---|
| 2659 | {"show_macfilter", ej_show_macfilter}, |
|---|
| 2660 | {"list_mac_layers", ej_list_mac_layers}, |
|---|
| 2661 | #ifdef HAVE_VLANTAGGING |
|---|
| 2662 | {"show_vlantagging", ej_show_vlantagging}, |
|---|
| 2663 | {"show_bridgenames", ej_show_bridgenames}, |
|---|
| 2664 | {"show_bridgeifnames", ej_show_bridgeifnames}, |
|---|
| 2665 | {"show_bridgetable", ej_show_bridgetable}, |
|---|
| 2666 | {"show_mdhcp", ej_show_mdhcp}, |
|---|
| 2667 | #endif |
|---|
| 2668 | #ifdef HAVE_BONDING |
|---|
| 2669 | {"show_bondings", ej_show_bondings}, |
|---|
| 2670 | #endif |
|---|
| 2671 | #ifdef HAVE_MADWIFI |
|---|
| 2672 | {"show_wifiselect", ej_show_wifiselect}, |
|---|
| 2673 | #endif |
|---|
| 2674 | #ifdef HAVE_PPPOESERVER |
|---|
| 2675 | {"show_chaps", ej_show_chaps}, |
|---|
| 2676 | #endif |
|---|
| 2677 | #ifdef HAVE_OLSRD |
|---|
| 2678 | {"show_olsrd", ej_show_olsrd}, |
|---|
| 2679 | #endif |
|---|
| 2680 | {"show_routeif", ej_show_routeif}, |
|---|
| 2681 | #ifdef HAVE_MILKFISH |
|---|
| 2682 | {"exec_milkfish_service", ej_exec_milkfish_service}, |
|---|
| 2683 | {"exec_milkfish_phonebook", ej_exec_milkfish_phonebook}, |
|---|
| 2684 | {"exec_show_subscribers", ej_exec_show_subscribers}, |
|---|
| 2685 | {"exec_show_aliases", ej_exec_show_aliases}, |
|---|
| 2686 | {"exec_show_registrations", ej_exec_show_registrations}, |
|---|
| 2687 | #endif |
|---|
| 2688 | {"show_ifselect", ej_show_ifselect}, |
|---|
| 2689 | #ifdef HAVE_RFLOW |
|---|
| 2690 | {"show_rflowif", ej_show_rflowif}, |
|---|
| 2691 | #endif |
|---|
| 2692 | {"startswith", ej_startswith}, |
|---|
| 2693 | {"ifdef", ej_ifdef}, |
|---|
| 2694 | {"ifndef", ej_ifndef}, |
|---|
| 2695 | {"show_countrylist", ej_show_countrylist}, |
|---|
| 2696 | #ifdef HAVE_MADWIFI |
|---|
| 2697 | {"show_acktiming", ej_show_acktiming}, |
|---|
| 2698 | {"update_acktiming", ej_update_acktiming}, |
|---|
| 2699 | #endif |
|---|
| 2700 | {"showbridgesettings", ej_showbridgesettings}, |
|---|
| 2701 | {NULL, NULL} |
|---|
| 2702 | }; |
|---|
| 2703 | |
|---|
| 2704 | #endif |
|---|