| 1 | #ifdef HAVE_BUFFALO |
|---|
| 2 | |
|---|
| 3 | #define VISUALSOURCE 1 |
|---|
| 4 | |
|---|
| 5 | #include <stdio.h> |
|---|
| 6 | #include <stdlib.h> |
|---|
| 7 | #include <string.h> |
|---|
| 8 | #include <unistd.h> |
|---|
| 9 | #include <stdarg.h> |
|---|
| 10 | |
|---|
| 11 | #include <broadcom.h> |
|---|
| 12 | #include <wlutils.h> |
|---|
| 13 | #include <cymac.h> |
|---|
| 14 | |
|---|
| 15 | char *nvram_selget(webs_t wp, char *name) |
|---|
| 16 | { |
|---|
| 17 | if (nvram_match("gozila_action", "1")) { |
|---|
| 18 | char *buf = GOZILA_GET(wp, name); |
|---|
| 19 | |
|---|
| 20 | if (buf) { |
|---|
| 21 | return buf; |
|---|
| 22 | // return sprintf("%s", buf); |
|---|
| 23 | } |
|---|
| 24 | } |
|---|
| 25 | return nvram_safe_get(name); |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | char *nvram_selnmatch(webs_t wp, char *match, const char *fmt, ...) |
|---|
| 29 | { |
|---|
| 30 | |
|---|
| 31 | char varbuf[64]; |
|---|
| 32 | va_list args; |
|---|
| 33 | va_start(args, (char *)fmt); |
|---|
| 34 | vsnprintf(varbuf, sizeof(varbuf), fmt, args); |
|---|
| 35 | va_end(args); |
|---|
| 36 | return nvram_selmatch(wp, varbuf, match); |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | static char *selmatch(webs_t wp, char *var, char *is, char *ret) |
|---|
| 40 | { |
|---|
| 41 | if (nvram_selmatch(wp, var, is)) |
|---|
| 42 | return ret; |
|---|
| 43 | return ""; |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | static char *sas_nvram_prefix_get(webs_t wp, const char *name, |
|---|
| 47 | const char *prefix) |
|---|
| 48 | { |
|---|
| 49 | char p[64]; |
|---|
| 50 | sprintf(p, "%s_%s", prefix, name); |
|---|
| 51 | return nvram_selget(wp, p); |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | static int sas_nvram_prefix_match(webs_t wp, const char *name, |
|---|
| 55 | const char *prefix, char *match) |
|---|
| 56 | { |
|---|
| 57 | char p[64]; |
|---|
| 58 | sprintf(p, "%s_%s", prefix, name); |
|---|
| 59 | return nvram_selmatch(wp, p, match); |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | static char *sas_nvram_nget(webs_t wp, const char *fmt, ...) |
|---|
| 63 | { |
|---|
| 64 | char varbuf[64]; |
|---|
| 65 | va_list args; |
|---|
| 66 | va_start(args, (char *)fmt); |
|---|
| 67 | vsnprintf(varbuf, sizeof(varbuf), fmt, args); |
|---|
| 68 | va_end(args); |
|---|
| 69 | return nvram_selget(wp, varbuf); |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | static char *sas_nvram_default_get(webs_t wp, char *var, char *def) |
|---|
| 73 | { |
|---|
| 74 | if (nvram_match("gozila_action", "1")) { |
|---|
| 75 | char *buf = GOZILA_GET(wp, var); |
|---|
| 76 | if (buf) { |
|---|
| 77 | return buf; |
|---|
| 78 | } |
|---|
| 79 | } |
|---|
| 80 | return nvram_default_get(var, def); |
|---|
| 81 | /*char *v = nvram_get(var); |
|---|
| 82 | if (v == NULL || strlen(v) == 0) { |
|---|
| 83 | nvram_set(var, def); |
|---|
| 84 | return def; |
|---|
| 85 | } |
|---|
| 86 | return nvram_selget(wp, var); */ |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | static int sas_nvram_default_match(webs_t wp, char *var, char *match, char *def) |
|---|
| 90 | { |
|---|
| 91 | fprintf(stderr, "[sas_nvram_default_match] %s\n", var); |
|---|
| 92 | if (nvram_match("gozila_action", "1")) { |
|---|
| 93 | fprintf(stderr, "[sas_nvram_default_match] %s gozila\n", var); |
|---|
| 94 | char *buf = GOZILA_GET(wp, var); |
|---|
| 95 | if (buf) { |
|---|
| 96 | fprintf(stderr, |
|---|
| 97 | "[sas_nvram_default_match] %s: %s - %s\n", var, |
|---|
| 98 | buf, match); |
|---|
| 99 | return !strcmp(buf, match); |
|---|
| 100 | } |
|---|
| 101 | } |
|---|
| 102 | return nvram_default_match(var, match, def); |
|---|
| 103 | /*char *v = nvram_get(var); |
|---|
| 104 | if (v == NULL || strlen(v) == 0) { |
|---|
| 105 | nvram_set(var, def); |
|---|
| 106 | return !strcmp(match, def); |
|---|
| 107 | } |
|---|
| 108 | return nvram_selmatch(wp, var, match); */ |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | void ej_sas_nvram_checked(webs_t wp, int argc, char_t ** argv) |
|---|
| 112 | { |
|---|
| 113 | |
|---|
| 114 | #ifdef FASTWEB |
|---|
| 115 | if (argc < 2) { |
|---|
| 116 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 117 | return; |
|---|
| 118 | } |
|---|
| 119 | #endif |
|---|
| 120 | |
|---|
| 121 | if (nvram_selmatch(wp, argv[0], argv[1])) { |
|---|
| 122 | websWrite(wp, "checked=\"checked\""); |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | return; |
|---|
| 126 | } |
|---|
| 127 | |
|---|
| 128 | void ej_sas_make_time_list(webs_t wp, int argc, char_t ** argv) |
|---|
| 129 | { |
|---|
| 130 | int i, st, en; |
|---|
| 131 | char ic[16]; |
|---|
| 132 | |
|---|
| 133 | #ifndef FASTWEB |
|---|
| 134 | if (argc < 3) { |
|---|
| 135 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 136 | return; |
|---|
| 137 | } |
|---|
| 138 | #endif |
|---|
| 139 | |
|---|
| 140 | st = atoi(argv[1]); |
|---|
| 141 | en = atoi(argv[2]); |
|---|
| 142 | |
|---|
| 143 | for (i = st; i <= en; i++) { |
|---|
| 144 | sprintf(ic, "%d", i); |
|---|
| 145 | websWrite(wp, "<option value=\"%d\" %s >%02d</option>\n", i, |
|---|
| 146 | nvram_selmatch(wp, argv[0], |
|---|
| 147 | ic) ? "selected=\"selected\"" : "", i); |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | return; |
|---|
| 151 | } |
|---|
| 152 | |
|---|
| 153 | /* |
|---|
| 154 | * Example: |
|---|
| 155 | * wan_proto=dhcp |
|---|
| 156 | * <% nvram_else_match("wan_proto", "dhcp", "0","1"); %> produces "0" |
|---|
| 157 | * <% nvram_else_match("wan_proto", "static", "0","1"); %> produces "1" |
|---|
| 158 | */ |
|---|
| 159 | void ej_sas_nvram_else_match(webs_t wp, int argc, char_t ** argv) |
|---|
| 160 | { |
|---|
| 161 | |
|---|
| 162 | #ifndef FASTWEB |
|---|
| 163 | if (argc < 4) { |
|---|
| 164 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 165 | return; |
|---|
| 166 | } |
|---|
| 167 | #endif |
|---|
| 168 | if (nvram_selmatch(wp, argv[0], argv[1])) { |
|---|
| 169 | websWrite(wp, argv[2]); |
|---|
| 170 | } else { |
|---|
| 171 | websWrite(wp, argv[3]); |
|---|
| 172 | } |
|---|
| 173 | return; |
|---|
| 174 | } |
|---|
| 175 | |
|---|
| 176 | void ej_show_sas_stage(webs_t wp, int argc, char_t ** argv) |
|---|
| 177 | { |
|---|
| 178 | do_ej(NULL, "sas_stage_1.asp", wp, NULL); |
|---|
| 179 | } |
|---|
| 180 | |
|---|
| 181 | void ej_show_sas_wan_setting(webs_t wp, int argc, char_t ** argv) |
|---|
| 182 | { |
|---|
| 183 | char *type; |
|---|
| 184 | |
|---|
| 185 | type = GOZILA_GET(wp, "wan_proto"); |
|---|
| 186 | if (type == NULL) |
|---|
| 187 | type = nvram_safe_get("wan_proto"); |
|---|
| 188 | char ejname[32]; |
|---|
| 189 | snprintf(ejname, 31, "sas_%s.asp", type); |
|---|
| 190 | do_ej(NULL, ejname, wp, NULL); |
|---|
| 191 | } |
|---|
| 192 | |
|---|
| 193 | char *ej_get_sas_stage(webs_t wp, int argc, char_t ** argv) |
|---|
| 194 | { |
|---|
| 195 | |
|---|
| 196 | char *stage; |
|---|
| 197 | |
|---|
| 198 | stage = GOZILA_GET(wp, "sas_stage"); |
|---|
| 199 | |
|---|
| 200 | if (stage == NULL) |
|---|
| 201 | stage = "0"; |
|---|
| 202 | |
|---|
| 203 | if (atoi(stage) == 0) { |
|---|
| 204 | stage = "1"; |
|---|
| 205 | } |
|---|
| 206 | |
|---|
| 207 | return stage; |
|---|
| 208 | } |
|---|
| 209 | |
|---|
| 210 | void ej_visible_css(webs_t wp, int argc, char_t ** argv) |
|---|
| 211 | { |
|---|
| 212 | if (!strcmp(nvram_selget(wp, argv[0]), argv[1])) { |
|---|
| 213 | websWrite(wp, ""); |
|---|
| 214 | } else { |
|---|
| 215 | websWrite(wp, "display: none;"); |
|---|
| 216 | } |
|---|
| 217 | } |
|---|
| 218 | |
|---|
| 219 | void ej_print_sas_stage(webs_t wp, int argc, char_t ** argv) |
|---|
| 220 | { |
|---|
| 221 | |
|---|
| 222 | char *stage; |
|---|
| 223 | stage = ej_get_sas_stage(wp, argc, argv); |
|---|
| 224 | websWrite(wp, stage); |
|---|
| 225 | } |
|---|
| 226 | |
|---|
| 227 | int ej_sas_stage_is_visible(webs_t wp, int argc, char_t ** argv) |
|---|
| 228 | { |
|---|
| 229 | char *stage; |
|---|
| 230 | stage = ej_get_sas_stage(wp, argc, argv); |
|---|
| 231 | if (strcmp(stage, argv[0])) { |
|---|
| 232 | return 1; |
|---|
| 233 | } else { |
|---|
| 234 | return 0; |
|---|
| 235 | } |
|---|
| 236 | } |
|---|
| 237 | |
|---|
| 238 | void ej_sas_stage_visible_css(webs_t wp, int argc, char_t ** argv) |
|---|
| 239 | { |
|---|
| 240 | if (ej_sas_stage_is_visible(wp, argc, argv) == 1) { |
|---|
| 241 | websWrite(wp, "display: none"); |
|---|
| 242 | } |
|---|
| 243 | } |
|---|
| 244 | |
|---|
| 245 | void ej_do_sas_stage_menu(webs_t wp, int argc, char_t ** argv) |
|---|
| 246 | { |
|---|
| 247 | |
|---|
| 248 | int i; |
|---|
| 249 | static char labels[5][32] = { |
|---|
| 250 | "", |
|---|
| 251 | "sas.internet_connection", |
|---|
| 252 | "sas.network_settings", |
|---|
| 253 | "sas.wireless_settings", |
|---|
| 254 | "sas.other_settings" |
|---|
| 255 | }; |
|---|
| 256 | char *stage; |
|---|
| 257 | |
|---|
| 258 | stage = ej_get_sas_stage(wp, argc, argv); |
|---|
| 259 | |
|---|
| 260 | websWrite(wp, "<div id=\"sas_menu\">\n"); |
|---|
| 261 | websWrite(wp, " <div class=\"wrapper\">\n"); |
|---|
| 262 | websWrite(wp, " <ul>\n"); |
|---|
| 263 | for (i = 1; i < 5; i++) { |
|---|
| 264 | if (i + 1 < 5) { |
|---|
| 265 | if (atoi(stage) == i) { |
|---|
| 266 | websWrite(wp, |
|---|
| 267 | " <li class=\"active\"><span><strong class=\"step_%s\">%s</strong></span></li>\n", |
|---|
| 268 | stage, |
|---|
| 269 | live_translate(labels[atoi(stage)])); |
|---|
| 270 | } else { |
|---|
| 271 | websWrite(wp, |
|---|
| 272 | " <li><span><strong class=\"step_%i\">%s</strong></span></li>\n", |
|---|
| 273 | i, live_translate(labels[i])); |
|---|
| 274 | } |
|---|
| 275 | } else { |
|---|
| 276 | if (atoi(stage) == i) { |
|---|
| 277 | websWrite(wp, |
|---|
| 278 | " <li class=\"active last\"><span class=\"last\"><strong class=\"step_%s\">%s</strong></span></li>\n", |
|---|
| 279 | stage, |
|---|
| 280 | live_translate(labels[atoi(stage)])); |
|---|
| 281 | } else { |
|---|
| 282 | websWrite(wp, |
|---|
| 283 | " <li class=\"last\"><span class=\"last\"><strong class=\"step_%i\">%s</strong></span></li>\n", |
|---|
| 284 | i, live_translate(labels[i])); |
|---|
| 285 | } |
|---|
| 286 | } |
|---|
| 287 | } |
|---|
| 288 | websWrite(wp, " </ul>\n"); |
|---|
| 289 | websWrite(wp, " </div>\n"); |
|---|
| 290 | websWrite(wp, "</div>\n"); |
|---|
| 291 | } |
|---|
| 292 | |
|---|
| 293 | void ej_sas_show_wireless(webs_t wp, int argc, char_t ** argv) |
|---|
| 294 | { |
|---|
| 295 | #ifdef HAVE_MADWIFI |
|---|
| 296 | int c = getdevicecount(); |
|---|
| 297 | int i; |
|---|
| 298 | |
|---|
| 299 | for (i = 0; i < c; i++) { |
|---|
| 300 | char buf[16]; |
|---|
| 301 | |
|---|
| 302 | sprintf(buf, "ath%d", i); |
|---|
| 303 | ej_sas_show_wireless_single(wp, buf); |
|---|
| 304 | sas_show_security_single(wp, argc, argv, buf); |
|---|
| 305 | } |
|---|
| 306 | #else |
|---|
| 307 | int c = get_wl_instances(); |
|---|
| 308 | int i; |
|---|
| 309 | |
|---|
| 310 | for (i = 0; i < c; i++) { |
|---|
| 311 | char buf[16]; |
|---|
| 312 | |
|---|
| 313 | sprintf(buf, "wl%d", i); |
|---|
| 314 | ej_sas_show_wireless_single(wp, buf); |
|---|
| 315 | sas_show_security_single(wp, argc, argv, buf); |
|---|
| 316 | } |
|---|
| 317 | #endif |
|---|
| 318 | } |
|---|
| 319 | |
|---|
| 320 | /* |
|---|
| 321 | * Example: |
|---|
| 322 | * lan_ipaddr = 192.168.1.1 |
|---|
| 323 | * <% get_single_ip("lan_ipaddr","1"); %> produces "168" |
|---|
| 324 | */ |
|---|
| 325 | char *sas_get_single_ip(webs_t wp, char *label, int position) |
|---|
| 326 | { |
|---|
| 327 | char *c; |
|---|
| 328 | char name[32]; |
|---|
| 329 | char d[32]; |
|---|
| 330 | char *g; |
|---|
| 331 | |
|---|
| 332 | if (nvram_match("gozila_action", "1")) { |
|---|
| 333 | sprintf(name, "%s_%i", label, position); |
|---|
| 334 | g = GOZILA_GET(wp, name); |
|---|
| 335 | fprintf(stderr, "[sas_get_single_ip] %s %s %i\n", name, g, |
|---|
| 336 | position); |
|---|
| 337 | if (g) { |
|---|
| 338 | return g; |
|---|
| 339 | } else { |
|---|
| 340 | return "0"; |
|---|
| 341 | } |
|---|
| 342 | } |
|---|
| 343 | |
|---|
| 344 | c = nvram_selget(wp, label); |
|---|
| 345 | if (c) { |
|---|
| 346 | if (!strcmp(c, PPP_PSEUDO_IP) || !strcmp(c, PPP_PSEUDO_GW)) |
|---|
| 347 | c = "0.0.0.0"; |
|---|
| 348 | else if (!strcmp(c, PPP_PSEUDO_NM)) |
|---|
| 349 | c = "255.255.255.0"; |
|---|
| 350 | |
|---|
| 351 | sprintf(d, "%i", get_single_ip(c, position)); |
|---|
| 352 | return d; |
|---|
| 353 | } else { |
|---|
| 354 | return "0"; |
|---|
| 355 | } |
|---|
| 356 | } |
|---|
| 357 | |
|---|
| 358 | void ej_sas_get_single_ip(webs_t wp, int argc, char_t ** argv) |
|---|
| 359 | { |
|---|
| 360 | /* char *c; |
|---|
| 361 | char name[32]; |
|---|
| 362 | */ |
|---|
| 363 | #ifndef FASTWEB |
|---|
| 364 | if (argc < 1) { |
|---|
| 365 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 366 | return; |
|---|
| 367 | } |
|---|
| 368 | #endif |
|---|
| 369 | |
|---|
| 370 | websWrite(wp, sas_get_single_ip(wp, argv[0], atoi(argv[1]))); |
|---|
| 371 | /* if (nvram_match("gozila_action", "1")) { |
|---|
| 372 | sprintf(name, "%s_%i", argv[0], atoi(argv[1])); |
|---|
| 373 | websWrite(wp, GOZILA_GET(wp, name)); |
|---|
| 374 | return; |
|---|
| 375 | } |
|---|
| 376 | c = nvram_selget(wp, argv[0]); |
|---|
| 377 | if (c) { |
|---|
| 378 | if (!strcmp(c, PPP_PSEUDO_IP) || !strcmp(c, PPP_PSEUDO_GW)) |
|---|
| 379 | c = "0.0.0.0"; |
|---|
| 380 | else if (!strcmp(c, PPP_PSEUDO_NM)) |
|---|
| 381 | c = "255.255.255.0"; |
|---|
| 382 | |
|---|
| 383 | websWrite(wp, "%d", get_single_ip(c, atoi(argv[1]))); |
|---|
| 384 | } else |
|---|
| 385 | websWrite(wp, "0"); |
|---|
| 386 | */ |
|---|
| 387 | return; |
|---|
| 388 | } |
|---|
| 389 | |
|---|
| 390 | void ej_sas_get_single_nm(webs_t wp, int argc, char_t ** argv) |
|---|
| 391 | { |
|---|
| 392 | /* char *c; |
|---|
| 393 | char name[32]; |
|---|
| 394 | */ |
|---|
| 395 | #ifndef FASTWEB |
|---|
| 396 | if (argc < 1) { |
|---|
| 397 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 398 | return; |
|---|
| 399 | } |
|---|
| 400 | #endif |
|---|
| 401 | websWrite(wp, sas_get_single_ip(wp, argv[0], atoi(argv[1]))); |
|---|
| 402 | /* if (nvram_match("gozila_action", "1")) { |
|---|
| 403 | sprintf(name, "%s_%i", argv[0], atoi(argv[1])); |
|---|
| 404 | websWrite(wp, GOZILA_GET(wp, name)); |
|---|
| 405 | return; |
|---|
| 406 | } |
|---|
| 407 | c = nvram_safe_get(argv[0]); |
|---|
| 408 | if (c) { |
|---|
| 409 | websWrite(wp, "%d", get_single_ip(c, atoi(argv[1]))); |
|---|
| 410 | } else |
|---|
| 411 | websWrite(wp, "0"); |
|---|
| 412 | |
|---|
| 413 | return;*/ |
|---|
| 414 | } |
|---|
| 415 | |
|---|
| 416 | char *sas_get_dns_ip(webs_t wp, char *label, int entry, int position) |
|---|
| 417 | { |
|---|
| 418 | |
|---|
| 419 | int which; |
|---|
| 420 | char name[32]; |
|---|
| 421 | char word[256], *next; |
|---|
| 422 | char d[32]; |
|---|
| 423 | char *g; |
|---|
| 424 | |
|---|
| 425 | if (nvram_match("gozila_action", "1")) { |
|---|
| 426 | sprintf(name, "%s%i_%i", label, entry, position); |
|---|
| 427 | g = GOZILA_GET(wp, name); |
|---|
| 428 | if (g) { |
|---|
| 429 | return g; |
|---|
| 430 | } |
|---|
| 431 | } |
|---|
| 432 | |
|---|
| 433 | which = entry; |
|---|
| 434 | char *list = nvram_safe_get(label); |
|---|
| 435 | |
|---|
| 436 | foreach(word, list, next) { |
|---|
| 437 | if (which-- == 0) { |
|---|
| 438 | sprintf(d, "%i", get_single_ip(word, position)); |
|---|
| 439 | return d; |
|---|
| 440 | } |
|---|
| 441 | } |
|---|
| 442 | |
|---|
| 443 | return "0"; |
|---|
| 444 | } |
|---|
| 445 | |
|---|
| 446 | /* |
|---|
| 447 | * Example: wan_dns = 168.95.1.1 210.66.161.125 168.95.192.1 <% |
|---|
| 448 | * get_dns_ip("wan_dns", "1", "2"); %> produces "161" <% |
|---|
| 449 | * get_dns_ip("wan_dns", "2", "3"); %> produces "1" |
|---|
| 450 | */ |
|---|
| 451 | void ej_sas_get_dns_ip(webs_t wp, int argc, char_t ** argv) |
|---|
| 452 | { |
|---|
| 453 | #ifndef FASTWEB |
|---|
| 454 | if (argc < 3) { |
|---|
| 455 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 456 | return; |
|---|
| 457 | } |
|---|
| 458 | #endif |
|---|
| 459 | websWrite(wp, "%s", |
|---|
| 460 | sas_get_dns_ip(wp, argv[0], atoi(argv[1]), atoi(argv[2]))); |
|---|
| 461 | } |
|---|
| 462 | |
|---|
| 463 | void ej_sas_show_wireless_single(webs_t wp, char *prefix) |
|---|
| 464 | { |
|---|
| 465 | |
|---|
| 466 | char wl_mode[16]; |
|---|
| 467 | char wl_macaddr[16]; |
|---|
| 468 | char wl_ssid[16]; |
|---|
| 469 | char power[16]; |
|---|
| 470 | #ifdef HAVE_REGISTER |
|---|
| 471 | int cpeonly = iscpe(); |
|---|
| 472 | #else |
|---|
| 473 | int cpeonly = 0; |
|---|
| 474 | #endif |
|---|
| 475 | |
|---|
| 476 | #ifdef HAVE_RT2880 |
|---|
| 477 | #define IFMAP(a) getRADev(a) |
|---|
| 478 | #else |
|---|
| 479 | #define IFMAP(a) (a) |
|---|
| 480 | #endif |
|---|
| 481 | |
|---|
| 482 | int argc = 1; |
|---|
| 483 | char *argv[] = { "3" }; |
|---|
| 484 | char *stage_visible_css = "display: none;"; |
|---|
| 485 | char frequencies[16]; |
|---|
| 486 | |
|---|
| 487 | if (ej_sas_stage_is_visible(wp, argc, argv) == 0) { |
|---|
| 488 | stage_visible_css = ""; |
|---|
| 489 | } |
|---|
| 490 | |
|---|
| 491 | sprintf(wl_mode, "%s_mode", prefix); |
|---|
| 492 | sprintf(wl_macaddr, "%s_hwaddr", prefix); |
|---|
| 493 | sprintf(wl_ssid, "%s_ssid", prefix); |
|---|
| 494 | |
|---|
| 495 | // check the frequency capabilities; |
|---|
| 496 | if (has_5ghz(prefix) && has_2ghz(prefix)) { |
|---|
| 497 | sprintf(frequencies, " [2.4/5 GHz]"); |
|---|
| 498 | } else if (has_5ghz(prefix)) { |
|---|
| 499 | sprintf(frequencies, " [5 GHz]"); |
|---|
| 500 | } else if (has_2ghz(prefix)) { |
|---|
| 501 | sprintf(frequencies, " [2.4 GHz]"); |
|---|
| 502 | } else { |
|---|
| 503 | sprintf(frequencies, ""); |
|---|
| 504 | } |
|---|
| 505 | |
|---|
| 506 | // wireless mode |
|---|
| 507 | websWrite(wp, |
|---|
| 508 | "<h2 style=\"%s\"><script type=\"text/javascript\">Capture(wl_basic.h2_v24)</script> %s%s</h2>\n", |
|---|
| 509 | stage_visible_css, prefix, frequencies); |
|---|
| 510 | websWrite(wp, "<fieldset style=\"%s\">\n", stage_visible_css); |
|---|
| 511 | websWrite(wp, |
|---|
| 512 | "<legend><script type=\"text/javascript\">Capture(share.pintrface)</script> %s - SSID [", |
|---|
| 513 | IFMAP(prefix)); |
|---|
| 514 | tf_webWriteESCNV(wp, wl_ssid); // fix |
|---|
| 515 | websWrite(wp, "] HWAddr [%s]</legend>\n", nvram_safe_get(wl_macaddr)); |
|---|
| 516 | |
|---|
| 517 | websWrite(wp, |
|---|
| 518 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label)</script></div><select name=\"%s\" onchange=\"refresh(this.form);\">\n", |
|---|
| 519 | wl_mode); |
|---|
| 520 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 521 | if (!cpeonly) { |
|---|
| 522 | websWrite(wp, |
|---|
| 523 | "document.write(\"<option value=\\\"ap\\\" %s >\" + wl_basic.ap + \"</option>\");\n", |
|---|
| 524 | nvram_selmatch(wp, wl_mode, |
|---|
| 525 | "ap") ? |
|---|
| 526 | "selected=\\\"selected\\\"" : ""); |
|---|
| 527 | } |
|---|
| 528 | #ifndef HAVE_RT61 |
|---|
| 529 | websWrite(wp, |
|---|
| 530 | "document.write(\"<option value=\\\"sta\\\" %s >\" + wl_basic.client + \"</option>\");\n", |
|---|
| 531 | nvram_selmatch(wp, wl_mode, |
|---|
| 532 | "sta") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 533 | #endif |
|---|
| 534 | #ifndef HAVE_RT2880 |
|---|
| 535 | #ifdef HAVE_RELAYD |
|---|
| 536 | websWrite(wp, |
|---|
| 537 | "document.write(\"<option value=\\\"wet\\\" %s >\" + wl_basic.clientRelayd + \"</option>\");\n", |
|---|
| 538 | #else |
|---|
| 539 | websWrite(wp, |
|---|
| 540 | "document.write(\"<option value=\\\"wet\\\" %s >\" + wl_basic.clientBridge + \"</option>\");\n", |
|---|
| 541 | #endif |
|---|
| 542 | nvram_selmatch(wp, wl_mode, |
|---|
| 543 | "wet") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 544 | #endif |
|---|
| 545 | if (!cpeonly) |
|---|
| 546 | websWrite(wp, |
|---|
| 547 | "document.write(\"<option value=\\\"infra\\\" %s >\" + wl_basic.adhoc + \"</option>\");\n", |
|---|
| 548 | nvram_selmatch(wp, wl_mode, |
|---|
| 549 | "infra") ? |
|---|
| 550 | "selected=\\\"selected\\\"" : ""); |
|---|
| 551 | #ifndef HAVE_MADWIFI |
|---|
| 552 | if (!cpeonly) { |
|---|
| 553 | websWrite(wp, |
|---|
| 554 | "document.write(\"<option value=\\\"apsta\\\" %s >\" + wl_basic.repeater + \"</option>\");\n", |
|---|
| 555 | nvram_selmatch(wp, wl_mode, |
|---|
| 556 | "apsta") ? |
|---|
| 557 | "selected=\\\"selected\\\"" : ""); |
|---|
| 558 | websWrite(wp, |
|---|
| 559 | "document.write(\"<option value=\\\"apstawet\\\" %s >\" + wl_basic.repeaterbridge + \"</option>\");\n", |
|---|
| 560 | nvram_selmatch(wp, wl_mode, |
|---|
| 561 | "apstawet") ? |
|---|
| 562 | "selected=\\\"selected\\\"" : ""); |
|---|
| 563 | } |
|---|
| 564 | #else |
|---|
| 565 | websWrite(wp, |
|---|
| 566 | "document.write(\"<option value=\\\"wdssta\\\" %s >\" + wl_basic.wdssta + \"</option>\");\n", |
|---|
| 567 | nvram_selmatch(wp, wl_mode, |
|---|
| 568 | "wdssta") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 569 | if (!cpeonly) { |
|---|
| 570 | websWrite(wp, |
|---|
| 571 | "document.write(\"<option value=\\\"wdsap\\\" %s >\" + wl_basic.wdsap + \"</option>\");\n", |
|---|
| 572 | nvram_selmatch(wp, wl_mode, |
|---|
| 573 | "wdsap") ? |
|---|
| 574 | "selected=\\\"selected\\\"" : ""); |
|---|
| 575 | } |
|---|
| 576 | #endif |
|---|
| 577 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 578 | websWrite(wp, "</select>\n"); |
|---|
| 579 | websWrite(wp, "</div>\n"); |
|---|
| 580 | |
|---|
| 581 | // RELAYD OPTIONAL SETTINGS |
|---|
| 582 | #ifdef HAVE_RELAYD |
|---|
| 583 | if (nvram_selmatch(wp, wl_mode, "wet")) { |
|---|
| 584 | char wl_relayd[32]; |
|---|
| 585 | int ip[4] = { 0, 0, 0, 0 }; |
|---|
| 586 | websWrite(wp, |
|---|
| 587 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.clientRelaydDefaultGwMode)</script></div>"); |
|---|
| 588 | sprintf(wl_relayd, "%s_relayd_gw_auto", prefix); |
|---|
| 589 | nvram_default_get(wl_relayd, "1"); |
|---|
| 590 | websWrite(wp, |
|---|
| 591 | " <input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s_relayd_gw_auto\" onclick=\"show_layer_ext(this, '%s_relayd_gw_ipaddr', false)\" %s /><script type=\"text/javascript\">Capture(share.auto)</script> (DHCP) \n", |
|---|
| 592 | prefix, prefix, |
|---|
| 593 | nvram_selmatch(wp, wl_relayd, "1") ? "checked" : ""); |
|---|
| 594 | websWrite(wp, |
|---|
| 595 | " <input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s_relayd_gw_auto\" onclick=\"show_layer_ext(this, '%s_relayd_gw_ipaddr', true)\" %s/><script type=\"text/javascript\">Capture(share.manual)</script>\n", |
|---|
| 596 | prefix, prefix, |
|---|
| 597 | nvram_selmatch(wp, wl_relayd, "0") ? "checked" : ""); |
|---|
| 598 | websWrite(wp, "</div>\n"); |
|---|
| 599 | |
|---|
| 600 | sprintf(wl_relayd, "%s_relayd_gw_ipaddr", prefix); |
|---|
| 601 | sscanf(nvram_safe_get(wl_relayd), "%d.%d.%d.%d", &ip[0], &ip[1], |
|---|
| 602 | &ip[2], &ip[3]); |
|---|
| 603 | sprintf(wl_relayd, "%s_relayd_gw_auto", prefix); |
|---|
| 604 | websWrite(wp, "\ |
|---|
| 605 | <div id=\"%s_relayd_gw_ipaddr\" class=\"setting\"%s>\n\ |
|---|
| 606 | <input type=\"hidden\" name=\"%s_relayd_gw_ipaddr\" value=\"4\">\n\ |
|---|
| 607 | <div class=\"label\"><script type=\"text/javascript\">Capture(share.gateway)</script></div>\n\ |
|---|
| 608 | <input size=\"3\" maxlength=\"3\" name=\"%s_relayd_gw_ipaddr_0\" value=\"%d\" onblur=\"valid_range(this,0,255,'IP')\" class=\"num\">.<input size=\"3\" maxlength=\"3\" name=\"%s_relayd_gw_ipaddr_1\" value=\"%d\" onblur=\"valid_range(this,0,255,'IP')\" class=\"num\">.<input size=\"3\" maxlength=\"3\" name=\"%s_relayd_gw_ipaddr_2\" value=\"%d\" onblur=\"valid_range(this,0,255,'IP')\" class=\"num\">.<input size=\"3\" maxlength=\"3\" name=\"%s_relayd_gw_ipaddr_3\" value=\"%d\" onblur=\"valid_range(this,1,254,'IP')\" class=\"num\">\n\ |
|---|
| 609 | </div>\n", prefix, nvram_selmatch(wp, wl_relayd, "1") ? " style=\"display: none; visibility: hidden;\"" : "", prefix, prefix, ip[0], prefix, ip[1], prefix, ip[2], prefix, ip[3]); |
|---|
| 610 | } |
|---|
| 611 | #endif |
|---|
| 612 | |
|---|
| 613 | // writeless net mode |
|---|
| 614 | sas_show_netmode(wp, prefix); |
|---|
| 615 | #ifdef HAVE_MADWIFI |
|---|
| 616 | |
|---|
| 617 | // char wl_xchanmode[16]; |
|---|
| 618 | char wl_outdoor[16]; |
|---|
| 619 | char wl_diversity[16]; |
|---|
| 620 | char wl_rxantenna[16]; |
|---|
| 621 | char wl_txantenna[16]; |
|---|
| 622 | char wl_width[16]; |
|---|
| 623 | char wl_preamble[16]; |
|---|
| 624 | char wl_xr[16]; |
|---|
| 625 | char wl_comp[32]; |
|---|
| 626 | char wl_ff[16]; |
|---|
| 627 | char wmm[32]; |
|---|
| 628 | char wl_isolate[32]; |
|---|
| 629 | char wl_sifstime[32]; |
|---|
| 630 | char wl_preambletime[32]; |
|---|
| 631 | char wl_intmit[32]; |
|---|
| 632 | char wl_noise_immunity[32]; |
|---|
| 633 | char wl_ofdm_weak_det[32]; |
|---|
| 634 | char wl_protmode[32]; |
|---|
| 635 | char wl_doth[32]; |
|---|
| 636 | char wl_csma[32]; |
|---|
| 637 | |
|---|
| 638 | sprintf(wl_csma, "%s_csma", prefix); |
|---|
| 639 | sprintf(wl_doth, "%s_doth", prefix); |
|---|
| 640 | sprintf(wl_protmode, "%s_protmode", prefix); |
|---|
| 641 | sprintf(wl_outdoor, "%s_outdoor", prefix); |
|---|
| 642 | sprintf(wl_diversity, "%s_diversity", prefix); |
|---|
| 643 | sprintf(wl_rxantenna, "%s_rxantenna", prefix); |
|---|
| 644 | sprintf(wl_txantenna, "%s_txantenna", prefix); |
|---|
| 645 | sprintf(wl_width, "%s_channelbw", prefix); |
|---|
| 646 | // sprintf( wl_comp, "%s_compression", prefix ); |
|---|
| 647 | sprintf(wl_ff, "%s_ff", prefix); |
|---|
| 648 | sprintf(wl_preamble, "%s_preamble", prefix); |
|---|
| 649 | sprintf(wl_preambletime, "%s_preambletime", prefix); |
|---|
| 650 | sprintf(wl_sifstime, "%s_sifstime", prefix); |
|---|
| 651 | sprintf(wl_xr, "%s_xr", prefix); |
|---|
| 652 | |
|---|
| 653 | sprintf(wl_intmit, "%s_intmit", prefix); |
|---|
| 654 | sprintf(wl_noise_immunity, "%s_noise_immunity", prefix); |
|---|
| 655 | sprintf(wl_ofdm_weak_det, "%s_ofdm_weak_det", prefix); |
|---|
| 656 | |
|---|
| 657 | #if defined(HAVE_MADWIFI_MIMO) || defined(HAVE_ATH9K) |
|---|
| 658 | if (!is_ath11n(prefix)) |
|---|
| 659 | #endif |
|---|
| 660 | { |
|---|
| 661 | showAutoOption(wp, "wl_basic.intmit", wl_intmit); |
|---|
| 662 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 663 | websWrite(wp, |
|---|
| 664 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.noise_immunity)</script></div>\n<select name=\"%s\">\n", |
|---|
| 665 | wl_noise_immunity); |
|---|
| 666 | websWrite(wp, |
|---|
| 667 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 668 | websWrite(wp, |
|---|
| 669 | "document.write(\"<option value=\\\"0\\\" %s >0</option>\");\n", |
|---|
| 670 | sas_nvram_default_match(wp, wl_noise_immunity, "0", |
|---|
| 671 | "4") ? |
|---|
| 672 | "selected=\\\"selected\\\"" : ""); |
|---|
| 673 | websWrite(wp, |
|---|
| 674 | "document.write(\"<option value=\\\"1\\\" %s >1</option>\");\n", |
|---|
| 675 | sas_nvram_default_match(wp, wl_noise_immunity, "1", |
|---|
| 676 | "4") ? |
|---|
| 677 | "selected=\\\"selected\\\"" : ""); |
|---|
| 678 | websWrite(wp, |
|---|
| 679 | "document.write(\"<option value=\\\"2\\\" %s >2</option>\");\n", |
|---|
| 680 | sas_nvram_default_match(wp, wl_noise_immunity, "2", |
|---|
| 681 | "4") ? |
|---|
| 682 | "selected=\\\"selected\\\"" : ""); |
|---|
| 683 | websWrite(wp, |
|---|
| 684 | "document.write(\"<option value=\\\"3\\\" %s >3</option>\");\n", |
|---|
| 685 | sas_nvram_default_match(wp, wl_noise_immunity, "3", |
|---|
| 686 | "4") ? |
|---|
| 687 | "selected=\\\"selected\\\"" : ""); |
|---|
| 688 | websWrite(wp, |
|---|
| 689 | "document.write(\"<option value=\\\"4\\\" %s >4</option>\");\n", |
|---|
| 690 | sas_nvram_default_match(wp, wl_noise_immunity, "4", |
|---|
| 691 | "4") ? |
|---|
| 692 | "selected=\\\"selected\\\"" : ""); |
|---|
| 693 | websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 694 | |
|---|
| 695 | showRadio(wp, "wl_basic.ofdm_weak_det", wl_ofdm_weak_det); |
|---|
| 696 | } |
|---|
| 697 | |
|---|
| 698 | websWrite(wp, |
|---|
| 699 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_width)</script></div><select name=\"%s\" onchange=\"refresh(this.form);\">\n", |
|---|
| 700 | wl_width); |
|---|
| 701 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 702 | |
|---|
| 703 | #if defined(HAVE_MADWIFI_MIMO) || defined(HAVE_ATH9K) |
|---|
| 704 | fprintf(stderr, "[MADWIFI MIMO] %s\n", prefix); |
|---|
| 705 | /* limit channel options by mode */ |
|---|
| 706 | if (is_ath11n(prefix)) { |
|---|
| 707 | if ((nvram_selnmatch(wp, "n-only", "%s_net_mode", prefix) |
|---|
| 708 | || nvram_selnmatch(wp, "ng-only", "%s_net_mode", prefix) |
|---|
| 709 | || nvram_selnmatch(wp, "n2-only", "%s_net_mode", prefix) |
|---|
| 710 | || nvram_selnmatch(wp, "n5-only", "%s_net_mode", prefix) |
|---|
| 711 | || nvram_selnmatch(wp, "na-only", "%s_net_mode", prefix))) |
|---|
| 712 | websWrite(wp, |
|---|
| 713 | "document.write(\"<option value=\\\"2040\\\" %s >\" + share.dynamicturbo + \"</option>\");\n", |
|---|
| 714 | nvram_selmatch(wp, wl_width, |
|---|
| 715 | "2040") ? |
|---|
| 716 | "selected=\\\"selected\\\"" : ""); |
|---|
| 717 | } |
|---|
| 718 | if (!is_ath11n(prefix) |
|---|
| 719 | || (is_ath11n(prefix) |
|---|
| 720 | && (nvram_selnmatch(wp, "n-only", "%s_net_mode", prefix) |
|---|
| 721 | || nvram_selnmatch(wp, "ng-only", "%s_net_mode", prefix) |
|---|
| 722 | || nvram_selnmatch(wp, "n2-only", "%s_net_mode", prefix) |
|---|
| 723 | || nvram_selnmatch(wp, "n5-only", "%s_net_mode", prefix) |
|---|
| 724 | || nvram_selnmatch(wp, "na-only", "%s_net_mode", prefix)))) |
|---|
| 725 | #endif |
|---|
| 726 | websWrite(wp, |
|---|
| 727 | "document.write(\"<option value=\\\"40\\\" %s >\" + share.turbo + \"</option>\");\n", |
|---|
| 728 | nvram_selmatch(wp, wl_width, |
|---|
| 729 | "40") ? "selected=\\\"selected\\\"" : |
|---|
| 730 | ""); |
|---|
| 731 | websWrite(wp, |
|---|
| 732 | "document.write(\"<option value=\\\"20\\\" %s >\" + share.full + \"</option>\");\n", |
|---|
| 733 | nvram_selmatch(wp, wl_width, |
|---|
| 734 | "20") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 735 | #ifdef HAVE_ATH9K |
|---|
| 736 | if (!is_ath9k(prefix)) |
|---|
| 737 | #endif |
|---|
| 738 | { |
|---|
| 739 | websWrite(wp, |
|---|
| 740 | "document.write(\"<option value=\\\"10\\\" %s >\" + share.half + \"</option>\");\n", |
|---|
| 741 | nvram_selmatch(wp, wl_width, |
|---|
| 742 | "10") ? "selected=\\\"selected\\\"" : |
|---|
| 743 | ""); |
|---|
| 744 | websWrite(wp, |
|---|
| 745 | "document.write(\"<option value=\\\"5\\\" %s >\" + share.quarter + \"</option>\");\n", |
|---|
| 746 | nvram_selmatch(wp, wl_width, |
|---|
| 747 | "5") ? "selected=\\\"selected\\\"" : |
|---|
| 748 | ""); |
|---|
| 749 | #ifdef HAVE_SUBQUARTER |
|---|
| 750 | /* will be enabled once it is tested and the spectrum analyse is done */ |
|---|
| 751 | websWrite(wp, |
|---|
| 752 | "document.write(\"<option value=\\\"2\\\" %s >\" + share.subquarter + \"</option>\");\n", |
|---|
| 753 | nvram_selmatch(wp, wl_width, |
|---|
| 754 | "2") ? "selected=\\\"selected\\\"" : |
|---|
| 755 | ""); |
|---|
| 756 | #endif |
|---|
| 757 | } |
|---|
| 758 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 759 | websWrite(wp, "</select>\n"); |
|---|
| 760 | websWrite(wp, "</div>\n"); |
|---|
| 761 | #if defined(HAVE_NS2) || defined(HAVE_NS5) || defined(HAVE_LC2) || defined(HAVE_LC5) || defined(HAVE_NS3) |
|---|
| 762 | |
|---|
| 763 | websWrite(wp, |
|---|
| 764 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label24)</script></div><select name=\"%s\" >\n", |
|---|
| 765 | wl_txantenna); |
|---|
| 766 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 767 | websWrite(wp, |
|---|
| 768 | "document.write(\"<option value=\\\"0\\\" %s >\" + wl_basic.vertical + \"</option>\");\n", |
|---|
| 769 | nvram_selmatch(wp, wl_txantenna, |
|---|
| 770 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 771 | websWrite(wp, |
|---|
| 772 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.horizontal + \"</option>\");\n", |
|---|
| 773 | nvram_selmatch(wp, wl_txantenna, |
|---|
| 774 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 775 | websWrite(wp, |
|---|
| 776 | "document.write(\"<option value=\\\"3\\\" %s >\" + wl_basic.adaptive + \"</option>\");\n", |
|---|
| 777 | nvram_selmatch(wp, wl_txantenna, |
|---|
| 778 | "3") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 779 | #if defined(HAVE_NS5) || defined(HAVE_NS2) || defined(HAVE_NS3) |
|---|
| 780 | websWrite(wp, |
|---|
| 781 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.external + \"</option>\");\n", |
|---|
| 782 | nvram_selmatch(wp, wl_txantenna, |
|---|
| 783 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 784 | #endif |
|---|
| 785 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 786 | |
|---|
| 787 | websWrite(wp, "</select>\n"); |
|---|
| 788 | websWrite(wp, "</div>\n"); |
|---|
| 789 | #endif |
|---|
| 790 | |
|---|
| 791 | #endif |
|---|
| 792 | |
|---|
| 793 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 794 | websWrite(wp, |
|---|
| 795 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label3)</script></div><input name=\"%s\" size=\"20\" maxlength=\"32\" onblur=\"valid_name(this,wl_basic.label3)\" value=\"%s\" /></div>\n", |
|---|
| 796 | wl_ssid, nvram_selget(wp, wl_ssid)); |
|---|
| 797 | |
|---|
| 798 | #ifdef HAVE_RT2880 |
|---|
| 799 | if (nvram_selmatch(wp, wl_mode, "ap") |
|---|
| 800 | || nvram_selmatch(wp, wl_mode, "wdsap") |
|---|
| 801 | || nvram_selmatch(wp, wl_mode, "infra") |
|---|
| 802 | || nvram_selmatch(wp, wl_mode, "apsta") |
|---|
| 803 | || nvram_selmatch(wp, wl_mode, "apstawet")) |
|---|
| 804 | #else |
|---|
| 805 | if (nvram_selmatch(wp, wl_mode, "ap") |
|---|
| 806 | || nvram_selmatch(wp, wl_mode, "wdsap") |
|---|
| 807 | || nvram_selmatch(wp, wl_mode, "infra")) |
|---|
| 808 | #endif |
|---|
| 809 | { |
|---|
| 810 | |
|---|
| 811 | if (has_mimo(prefix) |
|---|
| 812 | && (nvram_selnmatch(wp, "n-only", "%s_net_mode", prefix) |
|---|
| 813 | || nvram_selnmatch(wp, "ng-only", "%s_net_mode", prefix) |
|---|
| 814 | || nvram_selnmatch(wp, "mixed", "%s_net_mode", prefix) |
|---|
| 815 | || nvram_selnmatch(wp, "n2-only", "%s_net_mode", prefix) |
|---|
| 816 | || nvram_selnmatch(wp, "n5-only", "%s_net_mode", prefix) |
|---|
| 817 | || nvram_selnmatch(wp, "na-only", "%s_net_mode", |
|---|
| 818 | prefix))) { |
|---|
| 819 | |
|---|
| 820 | sas_show_channel(wp, prefix, prefix, 1); |
|---|
| 821 | |
|---|
| 822 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 823 | websWrite(wp, |
|---|
| 824 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_width)</script></div>\n"); |
|---|
| 825 | websWrite(wp, "<select name=\"%s_nbw\">\n", prefix); |
|---|
| 826 | #ifdef HAVE_RT2880 |
|---|
| 827 | websWrite(wp, |
|---|
| 828 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"20\\\" %s >20 MHz</option>\");\n//]]>\n</script>\n", |
|---|
| 829 | nvram_selnmatch(wp, "20", "%s_nbw", |
|---|
| 830 | prefix) ? |
|---|
| 831 | "selected=\\\"selected\\\"" : ""); |
|---|
| 832 | websWrite(wp, "<option value=\"40\" %s>40 MHz</option>", |
|---|
| 833 | nvram_selnmatch(wp, "40", "%s_nbw", |
|---|
| 834 | prefix) ? |
|---|
| 835 | "selected=\\\"selected\\\"" : ""); |
|---|
| 836 | #else |
|---|
| 837 | websWrite(wp, |
|---|
| 838 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"0\\\" %s >\" + share.auto + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 839 | nvram_selnmatch(wp, "0", "%s_nbw", |
|---|
| 840 | prefix) ? |
|---|
| 841 | "selected=\\\"selected\\\"" : ""); |
|---|
| 842 | websWrite(wp, |
|---|
| 843 | "<option value=\"10\" %s>10 MHz</option>\n", |
|---|
| 844 | nvram_selnmatch(wp, "10", "%s_nbw", |
|---|
| 845 | prefix) ? |
|---|
| 846 | "selected=\\\"selected\\\"" : ""); |
|---|
| 847 | websWrite(wp, |
|---|
| 848 | "<option value=\"20\" %s>20 MHz</option>\n", |
|---|
| 849 | nvram_selnmatch(wp, "20", "%s_nbw", |
|---|
| 850 | prefix) ? |
|---|
| 851 | "selected=\\\"selected\\\"" : ""); |
|---|
| 852 | websWrite(wp, |
|---|
| 853 | "<option value=\"40\" %s>40 MHz</option>\n", |
|---|
| 854 | nvram_selnmatch(wp, "40", "%s_nbw", |
|---|
| 855 | prefix) ? |
|---|
| 856 | "selected=\\\"selected\\\"" : ""); |
|---|
| 857 | #endif |
|---|
| 858 | websWrite(wp, "</select>\n"); |
|---|
| 859 | websWrite(wp, "</div>\n"); |
|---|
| 860 | |
|---|
| 861 | if (nvram_selnmatch(wp, "40", "%s_nbw", prefix)) { |
|---|
| 862 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 863 | websWrite(wp, |
|---|
| 864 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_wide)</script></div>\n"); |
|---|
| 865 | websWrite(wp, "<select name=\"%s_nctrlsb\" >\n", |
|---|
| 866 | prefix); |
|---|
| 867 | websWrite(wp, |
|---|
| 868 | "<option value=\"upper\" %s>upper</option>\n", |
|---|
| 869 | nvram_selnmatch(wp, "upper", |
|---|
| 870 | "%s_nctrlsb", |
|---|
| 871 | prefix) ? |
|---|
| 872 | "selected=\\\"selected\\\"" : ""); |
|---|
| 873 | websWrite(wp, |
|---|
| 874 | "<option value=\"lower\" %s>lower</option>\n", |
|---|
| 875 | nvram_selnmatch(wp, "lower", |
|---|
| 876 | "%s_nctrlsb", |
|---|
| 877 | prefix) ? |
|---|
| 878 | "selected=\\\"selected\\\"" : ""); |
|---|
| 879 | websWrite(wp, "</select>\n"); |
|---|
| 880 | |
|---|
| 881 | websWrite(wp, "</div>\n"); |
|---|
| 882 | } |
|---|
| 883 | } else { |
|---|
| 884 | sas_show_channel(wp, prefix, prefix, 0); |
|---|
| 885 | #if defined(HAVE_MADWIFI_MIMO) || defined(HAVE_ATH9K) |
|---|
| 886 | if (is_ath11n(prefix) |
|---|
| 887 | && (nvram_selmatch(wp, wl_width, "40") |
|---|
| 888 | || nvram_selmatch(wp, wl_width, "2040"))) { |
|---|
| 889 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 890 | websWrite(wp, |
|---|
| 891 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_wide)</script></div>\n"); |
|---|
| 892 | websWrite(wp, "<select name=\"%s_nctrlsb\" >\n", |
|---|
| 893 | prefix); |
|---|
| 894 | websWrite(wp, |
|---|
| 895 | "<option value=\"upper\" %s>upper</option>\n", |
|---|
| 896 | nvram_selnmatch(wp, "upper", |
|---|
| 897 | "%s_nctrlsb", |
|---|
| 898 | prefix) ? |
|---|
| 899 | "selected=\\\"selected\\\"" : ""); |
|---|
| 900 | websWrite(wp, |
|---|
| 901 | "<option value=\"lower\" %s>lower</option>\n", |
|---|
| 902 | nvram_selnmatch(wp, "lower", |
|---|
| 903 | "%s_nctrlsb", |
|---|
| 904 | prefix) ? |
|---|
| 905 | "selected=\\\"selected\\\"" : ""); |
|---|
| 906 | websWrite(wp, "</select>\n"); |
|---|
| 907 | |
|---|
| 908 | websWrite(wp, "</div>\n"); |
|---|
| 909 | } |
|---|
| 910 | #endif |
|---|
| 911 | } |
|---|
| 912 | |
|---|
| 913 | char wl_closed[16]; |
|---|
| 914 | sprintf(wl_closed, "%s_closed", prefix); |
|---|
| 915 | |
|---|
| 916 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 917 | websWrite(wp, |
|---|
| 918 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label5)</script></div>\n"); |
|---|
| 919 | websWrite(wp, |
|---|
| 920 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.enable)</script> \n", |
|---|
| 921 | wl_closed, nvram_selmatch(wp, wl_closed, |
|---|
| 922 | "0") ? "checked=\"checked\"" |
|---|
| 923 | : ""); |
|---|
| 924 | websWrite(wp, |
|---|
| 925 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.disable)</script>\n", |
|---|
| 926 | wl_closed, nvram_selmatch(wp, wl_closed, |
|---|
| 927 | "1") ? "checked=\"checked\"" |
|---|
| 928 | : ""); |
|---|
| 929 | websWrite(wp, "</div>\n"); |
|---|
| 930 | } |
|---|
| 931 | |
|---|
| 932 | websWrite(wp, "</fieldset>\n"); |
|---|
| 933 | |
|---|
| 934 | websWrite(wp, "<br style=\"%s\" />", stage_visible_css); |
|---|
| 935 | } |
|---|
| 936 | |
|---|
| 937 | void sas_show_netmode(webs_t wp, char *prefix) |
|---|
| 938 | { |
|---|
| 939 | char wl_net_mode[16]; |
|---|
| 940 | |
|---|
| 941 | sprintf(wl_net_mode, "%s_net_mode", prefix); |
|---|
| 942 | |
|---|
| 943 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 944 | websWrite(wp, |
|---|
| 945 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label2)</script></div><select name=\"%s\" onchange=\"refresh(this.form);\">\n", |
|---|
| 946 | wl_net_mode); |
|---|
| 947 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 948 | websWrite(wp, |
|---|
| 949 | "document.write(\"<option value=\\\"disabled\\\" %s>\" + share.disabled + \"</option>\");\n", |
|---|
| 950 | nvram_selmatch(wp, wl_net_mode, |
|---|
| 951 | "disabled") ? "selected=\\\"selected\\\"" : |
|---|
| 952 | ""); |
|---|
| 953 | websWrite(wp, |
|---|
| 954 | "document.write(\"<option value=\\\"mixed\\\" %s>\" + wl_basic.mixed + \"</option>\");\n", |
|---|
| 955 | nvram_selmatch(wp, wl_net_mode, |
|---|
| 956 | "mixed") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 957 | if (has_mimo(prefix) && has_2ghz(prefix)) { |
|---|
| 958 | websWrite(wp, |
|---|
| 959 | "document.write(\"<option value=\\\"bg-mixed\\\" %s>\" + wl_basic.bg + \"</option>\");\n", |
|---|
| 960 | nvram_selmatch(wp, wl_net_mode, |
|---|
| 961 | "bg-mixed") ? |
|---|
| 962 | "selected=\\\"selected\\\"" : ""); |
|---|
| 963 | } |
|---|
| 964 | #ifdef HAVE_WHRAG108 |
|---|
| 965 | if (!strcmp(prefix, "ath1")) |
|---|
| 966 | #endif |
|---|
| 967 | #ifdef HAVE_TW6600 |
|---|
| 968 | if (!strcmp(prefix, "ath1")) |
|---|
| 969 | #endif |
|---|
| 970 | if (has_2ghz(prefix)) { |
|---|
| 971 | websWrite(wp, |
|---|
| 972 | "document.write(\"<option value=\\\"b-only\\\" %s>\" + wl_basic.b + \"</option>\");\n", |
|---|
| 973 | nvram_selmatch(wp, wl_net_mode, |
|---|
| 974 | "b-only") ? |
|---|
| 975 | "selected=\\\"selected\\\"" : ""); |
|---|
| 976 | } |
|---|
| 977 | #ifdef HAVE_MADWIFI |
|---|
| 978 | if (has_2ghz(prefix)) { |
|---|
| 979 | #ifdef HAVE_WHRAG108 |
|---|
| 980 | if (!strcmp(prefix, "ath1")) |
|---|
| 981 | #endif |
|---|
| 982 | #ifdef HAVE_TW6600 |
|---|
| 983 | if (!strcmp(prefix, "ath1")) |
|---|
| 984 | #endif |
|---|
| 985 | websWrite(wp, |
|---|
| 986 | "document.write(\"<option value=\\\"g-only\\\" %s>\" + wl_basic.g + \"</option>\");\n", |
|---|
| 987 | nvram_selmatch(wp, wl_net_mode, |
|---|
| 988 | "g-only") ? |
|---|
| 989 | "selected=\\\"selected\\\"" : ""); |
|---|
| 990 | #ifdef HAVE_WHRAG108 |
|---|
| 991 | if (!strcmp(prefix, "ath1")) |
|---|
| 992 | #endif |
|---|
| 993 | #ifdef HAVE_TW6600 |
|---|
| 994 | if (!strcmp(prefix, "ath1")) |
|---|
| 995 | #endif |
|---|
| 996 | #if !defined(HAVE_LS5) || defined(HAVE_EOC5610) |
|---|
| 997 | websWrite(wp, |
|---|
| 998 | "document.write(\"<option value=\\\"bg-mixed\\\" %s>\" + wl_basic.bg + \"</option>\");\n", |
|---|
| 999 | nvram_selmatch(wp, wl_net_mode, |
|---|
| 1000 | "bg-mixed") ? |
|---|
| 1001 | "selected=\\\"selected\\\"" : ""); |
|---|
| 1002 | #endif |
|---|
| 1003 | } |
|---|
| 1004 | #else |
|---|
| 1005 | #ifdef HAVE_WHRAG108 |
|---|
| 1006 | if (!strcmp(prefix, "ath1")) |
|---|
| 1007 | #endif |
|---|
| 1008 | #if !defined(HAVE_LS5) || defined(HAVE_EOC5610) |
|---|
| 1009 | if (has_2ghz(prefix)) { |
|---|
| 1010 | websWrite(wp, |
|---|
| 1011 | "document.write(\"<option value=\\\"g-only\\\" %s>\" + wl_basic.g + \"</option>\");\n", |
|---|
| 1012 | nvram_selmatch(wp, wl_net_mode, |
|---|
| 1013 | "g-only") ? |
|---|
| 1014 | "selected=\\\"selected\\\"" : ""); |
|---|
| 1015 | } |
|---|
| 1016 | if (has_mimo(prefix) && has_2ghz(prefix)) { |
|---|
| 1017 | websWrite(wp, |
|---|
| 1018 | "document.write(\"<option value=\\\"ng-only\\\" %s>\" + wl_basic.ng + \"</option>\");\n", |
|---|
| 1019 | nvram_selmatch(wp, wl_net_mode, |
|---|
| 1020 | "ng-only") ? |
|---|
| 1021 | "selected=\\\"selected\\\"" : ""); |
|---|
| 1022 | } |
|---|
| 1023 | #endif |
|---|
| 1024 | #endif |
|---|
| 1025 | if (has_mimo(prefix) && has_2ghz(prefix)) { |
|---|
| 1026 | if (has_5ghz(prefix)) { |
|---|
| 1027 | websWrite(wp, |
|---|
| 1028 | "document.write(\"<option value=\\\"n2-only\\\" %s>\" + wl_basic.n2 + \"</option>\");\n", |
|---|
| 1029 | nvram_selmatch(wp, wl_net_mode, |
|---|
| 1030 | "n2-only") ? |
|---|
| 1031 | "selected=\\\"selected\\\"" : ""); |
|---|
| 1032 | } else { |
|---|
| 1033 | websWrite(wp, |
|---|
| 1034 | "document.write(\"<option value=\\\"n-only\\\" %s>\" + wl_basic.n + \"</option>\");\n", |
|---|
| 1035 | nvram_selmatch(wp, wl_net_mode, |
|---|
| 1036 | "n-only") ? |
|---|
| 1037 | "selected=\\\"selected\\\"" : ""); |
|---|
| 1038 | } |
|---|
| 1039 | } |
|---|
| 1040 | #if !defined(HAVE_FONERA) && !defined(HAVE_LS2) && !defined(HAVE_MERAKI) |
|---|
| 1041 | #ifndef HAVE_MADWIFI |
|---|
| 1042 | if (has_5ghz(prefix)) { |
|---|
| 1043 | websWrite(wp, |
|---|
| 1044 | "document.write(\"<option value=\\\"a-only\\\" %s>\" + wl_basic.a + \"</option>\");\n", |
|---|
| 1045 | nvram_selmatch(wp, wl_net_mode, |
|---|
| 1046 | "a-only") ? |
|---|
| 1047 | "selected=\\\"selected\\\"" : ""); |
|---|
| 1048 | } |
|---|
| 1049 | if (has_mimo(prefix) && has_5ghz(prefix)) { |
|---|
| 1050 | websWrite(wp, |
|---|
| 1051 | "document.write(\"<option value=\\\"na-only\\\" %s>\" + wl_basic.na + \"</option>\");\n", |
|---|
| 1052 | nvram_selmatch(wp, wl_net_mode, |
|---|
| 1053 | "na-only") ? |
|---|
| 1054 | "selected=\\\"selected\\\"" : ""); |
|---|
| 1055 | websWrite(wp, |
|---|
| 1056 | "document.write(\"<option value=\\\"n5-only\\\" %s>\" + wl_basic.n5 + \"</option>\");\n", |
|---|
| 1057 | nvram_selmatch(wp, wl_net_mode, |
|---|
| 1058 | "n5-only") ? |
|---|
| 1059 | "selected=\\\"selected\\\"" : ""); |
|---|
| 1060 | } |
|---|
| 1061 | #else |
|---|
| 1062 | #if HAVE_WHRAG108 |
|---|
| 1063 | if (!strcmp(prefix, "ath0")) |
|---|
| 1064 | #endif |
|---|
| 1065 | #ifdef HAVE_TW6600 |
|---|
| 1066 | if (!strcmp(prefix, "ath0")) |
|---|
| 1067 | #endif |
|---|
| 1068 | if (has_5ghz(prefix)) { |
|---|
| 1069 | websWrite(wp, |
|---|
| 1070 | "document.write(\"<option value=\\\"a-only\\\" %s>\" + wl_basic.a + \"</option>\");\n", |
|---|
| 1071 | nvram_selmatch(wp, wl_net_mode, |
|---|
| 1072 | "a-only") ? |
|---|
| 1073 | "selected=\\\"selected\\\"" : ""); |
|---|
| 1074 | } |
|---|
| 1075 | #endif |
|---|
| 1076 | |
|---|
| 1077 | #endif |
|---|
| 1078 | #if defined(HAVE_MADWIFI_MIMO) || defined(HAVE_ATH9K) |
|---|
| 1079 | if (is_ath11n(prefix)) { |
|---|
| 1080 | if (has_2ghz(prefix)) { |
|---|
| 1081 | websWrite(wp, |
|---|
| 1082 | "document.write(\"<option value=\\\"ng-only\\\" %s>\" + wl_basic.ng + \"</option>\");\n", |
|---|
| 1083 | nvram_selmatch(wp, wl_net_mode, |
|---|
| 1084 | "ng-only") ? |
|---|
| 1085 | "selected=\\\"selected\\\"" : ""); |
|---|
| 1086 | websWrite(wp, |
|---|
| 1087 | "document.write(\"<option value=\\\"n2-only\\\" %s>\" + wl_basic.n2 + \"</option>\");\n", |
|---|
| 1088 | nvram_selmatch(wp, wl_net_mode, |
|---|
| 1089 | "n2-only") ? |
|---|
| 1090 | "selected=\\\"selected\\\"" : ""); |
|---|
| 1091 | } |
|---|
| 1092 | if (has_5ghz(prefix)) { |
|---|
| 1093 | websWrite(wp, |
|---|
| 1094 | "document.write(\"<option value=\\\"na-only\\\" %s>\" + wl_basic.na + \"</option>\");\n", |
|---|
| 1095 | nvram_selmatch(wp, wl_net_mode, |
|---|
| 1096 | "na-only") ? |
|---|
| 1097 | "selected=\\\"selected\\\"" : ""); |
|---|
| 1098 | websWrite(wp, |
|---|
| 1099 | "document.write(\"<option value=\\\"n5-only\\\" %s>\" + wl_basic.n5 + \"</option>\");\n", |
|---|
| 1100 | nvram_selmatch(wp, wl_net_mode, |
|---|
| 1101 | "n5-only") ? |
|---|
| 1102 | "selected=\\\"selected\\\"" : ""); |
|---|
| 1103 | } |
|---|
| 1104 | } |
|---|
| 1105 | #endif |
|---|
| 1106 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 1107 | websWrite(wp, "</select>\n"); |
|---|
| 1108 | websWrite(wp, "</div>\n"); |
|---|
| 1109 | |
|---|
| 1110 | #ifdef HAVE_RT2880 |
|---|
| 1111 | if (nvram_selnmatch(wp, "n-only", "%s_net_mode", prefix)) { |
|---|
| 1112 | char wl_greenfield[32]; |
|---|
| 1113 | |
|---|
| 1114 | sprintf(wl_greenfield, "%s_greenfield", prefix); |
|---|
| 1115 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1116 | websWrite(wp, |
|---|
| 1117 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label7)</script></div><select name=\"%s\" >\n", |
|---|
| 1118 | wl_greenfield); |
|---|
| 1119 | websWrite(wp, |
|---|
| 1120 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1121 | websWrite(wp, |
|---|
| 1122 | "document.write(\"<option value=\\\"0\\\" %s>\" + wl_basic.mixed + \"</option>\");\n", |
|---|
| 1123 | sas_nvram_default_match(wp, wl_greenfield, "0", |
|---|
| 1124 | "0") ? |
|---|
| 1125 | "selected=\\\"selected\\\"" : ""); |
|---|
| 1126 | websWrite(wp, |
|---|
| 1127 | "document.write(\"<option value=\\\"1\\\" %s>\" + wl_basic.greenfield + \"</option>\");\n", |
|---|
| 1128 | sas_nvram_default_match(wp, wl_greenfield, "1", |
|---|
| 1129 | "0") ? |
|---|
| 1130 | "selected=\\\"selected\\\"" : ""); |
|---|
| 1131 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 1132 | websWrite(wp, "</select>\n"); |
|---|
| 1133 | websWrite(wp, "</div>\n"); |
|---|
| 1134 | } |
|---|
| 1135 | #endif |
|---|
| 1136 | } |
|---|
| 1137 | |
|---|
| 1138 | /** |
|---|
| 1139 | * displays the wireless channels |
|---|
| 1140 | */ |
|---|
| 1141 | void sas_show_channel(webs_t wp, char *dev, char *prefix, int type) |
|---|
| 1142 | { |
|---|
| 1143 | |
|---|
| 1144 | char wl_mode[16]; |
|---|
| 1145 | sprintf(wl_mode, "%s_mode", prefix); |
|---|
| 1146 | int instance = 0; |
|---|
| 1147 | char wl_nbw[16]; |
|---|
| 1148 | |
|---|
| 1149 | char wl_net_mode[16]; |
|---|
| 1150 | sprintf(wl_net_mode, "%s_net_mode", prefix); |
|---|
| 1151 | |
|---|
| 1152 | if (nvram_selmatch(wp, wl_net_mode, "disabled")) { |
|---|
| 1153 | return; |
|---|
| 1154 | } |
|---|
| 1155 | if (nvram_selmatch(wp, wl_mode, "ap") |
|---|
| 1156 | || nvram_selmatch(wp, wl_mode, "wdsap") |
|---|
| 1157 | || nvram_selmatch(wp, wl_mode, "infra")) { |
|---|
| 1158 | char wl_channel[16]; |
|---|
| 1159 | sprintf(wl_channel, "%s_channel", prefix); |
|---|
| 1160 | |
|---|
| 1161 | char wl_wchannel[16]; |
|---|
| 1162 | sprintf(wl_wchannel, "%s_wchannel", prefix); |
|---|
| 1163 | |
|---|
| 1164 | sas_nvram_default_get(wp, wl_wchannel, "0"); |
|---|
| 1165 | sprintf(wl_nbw, "%s_nbw", prefix); |
|---|
| 1166 | |
|---|
| 1167 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1168 | websWrite(wp, |
|---|
| 1169 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label4)</script></div>\n<select name=\"%s\" onfocus=\"check_action(this,0)\"><script type=\"text/javascript\">\n//<![CDATA[\n", |
|---|
| 1170 | wl_channel); |
|---|
| 1171 | #ifdef HAVE_MADWIFI |
|---|
| 1172 | struct wifi_channels *chan; |
|---|
| 1173 | char cn[32]; |
|---|
| 1174 | char fr[32]; |
|---|
| 1175 | int gotchannels = 0; |
|---|
| 1176 | |
|---|
| 1177 | #if defined(HAVE_MADWIFI_MIMO) || defined(HAVE_ATH9K) |
|---|
| 1178 | if (is_ath11n(prefix)) { |
|---|
| 1179 | #ifdef HAVE_MADWIFI_MIMO |
|---|
| 1180 | if (is_ar5008(prefix)) { |
|---|
| 1181 | chan = list_channels_11n(prefix); |
|---|
| 1182 | if (chan == NULL) |
|---|
| 1183 | chan = list_channels_11n(dev); |
|---|
| 1184 | gotchannels = 1; |
|---|
| 1185 | } |
|---|
| 1186 | #endif |
|---|
| 1187 | #ifdef HAVE_ATH9K |
|---|
| 1188 | if (is_ath9k(prefix)) { |
|---|
| 1189 | // temp must be replaced with the actual selected country |
|---|
| 1190 | char regdomain[16]; |
|---|
| 1191 | char *country; |
|---|
| 1192 | sprintf(regdomain, "%s_regdomain", prefix); |
|---|
| 1193 | country = |
|---|
| 1194 | nvram_default_get(regdomain, |
|---|
| 1195 | "UNITED_STATES"); |
|---|
| 1196 | // temp end |
|---|
| 1197 | chan = |
|---|
| 1198 | mac80211_get_channels(prefix, |
|---|
| 1199 | getIsoName(country), |
|---|
| 1200 | 40, 0xff); |
|---|
| 1201 | /* if (chan == NULL) |
|---|
| 1202 | chan = |
|---|
| 1203 | list_channels_ath9k(dev, "DE", 40, |
|---|
| 1204 | 0xff); */ |
|---|
| 1205 | gotchannels = 1; |
|---|
| 1206 | } |
|---|
| 1207 | #endif |
|---|
| 1208 | } |
|---|
| 1209 | #endif |
|---|
| 1210 | if (!gotchannels) { |
|---|
| 1211 | chan = list_channels(prefix); |
|---|
| 1212 | if (chan == NULL) |
|---|
| 1213 | chan = list_channels(dev); |
|---|
| 1214 | } |
|---|
| 1215 | if (chan != NULL) { |
|---|
| 1216 | // int cnt = getchannelcount (); |
|---|
| 1217 | websWrite(wp, |
|---|
| 1218 | "document.write(\"<option value=\\\"0\\\" %s>\" + share.auto + \"</option>\");\n", |
|---|
| 1219 | nvram_selmatch(wp, wl_channel, |
|---|
| 1220 | "0") ? |
|---|
| 1221 | "selected=\\\"selected\\\"" : ""); |
|---|
| 1222 | int i = 0; |
|---|
| 1223 | |
|---|
| 1224 | while (chan[i].freq != -1) { |
|---|
| 1225 | cprintf("%d\n", chan[i].channel); |
|---|
| 1226 | cprintf("%d\n", chan[i].freq); |
|---|
| 1227 | |
|---|
| 1228 | sprintf(cn, "%d", chan[i].channel); |
|---|
| 1229 | sprintf(fr, "%d", chan[i].freq); |
|---|
| 1230 | int freq = get_wififreq(prefix, chan[i].freq); |
|---|
| 1231 | if (freq != -1) |
|---|
| 1232 | websWrite(wp, |
|---|
| 1233 | "document.write(\"<option value=\\\"%s\\\" %s>%s - %d MHz</option>\");\n", |
|---|
| 1234 | fr, nvram_selmatch(wp, |
|---|
| 1235 | wl_channel, |
|---|
| 1236 | fr) ? |
|---|
| 1237 | "selected=\\\"selected\\\"" : |
|---|
| 1238 | "", cn, (freq)); |
|---|
| 1239 | // free (chan[i].freq); |
|---|
| 1240 | i++; |
|---|
| 1241 | } |
|---|
| 1242 | free(chan); |
|---|
| 1243 | } |
|---|
| 1244 | #else |
|---|
| 1245 | |
|---|
| 1246 | if (!strcmp(prefix, "wl1")) |
|---|
| 1247 | instance = 1; |
|---|
| 1248 | |
|---|
| 1249 | unsigned int chanlist[128]; |
|---|
| 1250 | char *ifn = get_wl_instance_name(instance); |
|---|
| 1251 | int chancount = getchannels(chanlist, ifn); |
|---|
| 1252 | int net_is_a = 0; |
|---|
| 1253 | |
|---|
| 1254 | if (chanlist[0] > 25) |
|---|
| 1255 | net_is_a = 1; |
|---|
| 1256 | |
|---|
| 1257 | int i, j; |
|---|
| 1258 | |
|---|
| 1259 | // supported 5GHz channels for IEEE 802.11n 40MHz |
|---|
| 1260 | int na_upper[16] = |
|---|
| 1261 | { 40, 48, 56, 64, 104, 112, 120, 128, 136, 153, 161, |
|---|
| 1262 | 0, 0, 0, 0, 0 |
|---|
| 1263 | }; |
|---|
| 1264 | int na_lower[16] = |
|---|
| 1265 | { 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157, |
|---|
| 1266 | 0, 0, 0, 0, 0 |
|---|
| 1267 | }; |
|---|
| 1268 | |
|---|
| 1269 | websWrite(wp, |
|---|
| 1270 | "document.write(\"<option value=\\\"0\\\" %s>\" + share.auto + \"</option>\");\n", |
|---|
| 1271 | nvram_selnmatch(wp, "0", "%s_channel", |
|---|
| 1272 | prefix) ? "selected=\\\"selected\\\"" |
|---|
| 1273 | : ""); |
|---|
| 1274 | for (i = 0; i < chancount; i++) { |
|---|
| 1275 | float ofs; |
|---|
| 1276 | |
|---|
| 1277 | if (chanlist[i] < 25) |
|---|
| 1278 | ofs = 2.407f; |
|---|
| 1279 | else |
|---|
| 1280 | ofs = 5.000f; |
|---|
| 1281 | ofs += (float)(chanlist[i] * 0.005f); |
|---|
| 1282 | if (ofs == 2.477f) |
|---|
| 1283 | ofs = 2.484f; // fix: ch 14 is 2.484, not 2.477 GHz |
|---|
| 1284 | |
|---|
| 1285 | char channelstring[32]; |
|---|
| 1286 | int showit = 1; |
|---|
| 1287 | |
|---|
| 1288 | if (nvram_selmatch(wp, wl_net_mode, "a-only") |
|---|
| 1289 | || nvram_selmatch(wp, wl_net_mode, "na-only") |
|---|
| 1290 | || nvram_selmatch(wp, wl_net_mode, "n5-only") |
|---|
| 1291 | || (net_is_a |
|---|
| 1292 | && nvram_selmatch(wp, wl_net_mode, "mixed"))) { |
|---|
| 1293 | if (chanlist[i] < 25) |
|---|
| 1294 | showit = 0; |
|---|
| 1295 | } else { |
|---|
| 1296 | if (chanlist[i] > 25) |
|---|
| 1297 | showit = 0; |
|---|
| 1298 | } |
|---|
| 1299 | |
|---|
| 1300 | if ((nvram_selmatch(wp, wl_net_mode, "na-only") |
|---|
| 1301 | || (net_is_a |
|---|
| 1302 | && nvram_selmatch(wp, wl_net_mode, "mixed")) |
|---|
| 1303 | || nvram_selmatch(wp, wl_net_mode, "n5-only")) |
|---|
| 1304 | && nvram_selmatch(wp, wl_nbw, "40")) { |
|---|
| 1305 | showit = 0; |
|---|
| 1306 | j = 0; |
|---|
| 1307 | if (nvram_selnmatch |
|---|
| 1308 | (wp, "upper", "%s_nctrlsb", prefix)) { |
|---|
| 1309 | while (na_upper[j]) { |
|---|
| 1310 | if (chanlist[i] == na_upper[j]) { |
|---|
| 1311 | showit = 1; |
|---|
| 1312 | break; |
|---|
| 1313 | } |
|---|
| 1314 | j++; |
|---|
| 1315 | } |
|---|
| 1316 | } else |
|---|
| 1317 | if (nvram_selnmatch |
|---|
| 1318 | (wp, "lower", "%s_nctrlsb", prefix)) { |
|---|
| 1319 | while (na_lower[j]) { |
|---|
| 1320 | if (chanlist[i] == na_lower[j]) { |
|---|
| 1321 | showit = 1; |
|---|
| 1322 | break; |
|---|
| 1323 | } |
|---|
| 1324 | j++; |
|---|
| 1325 | } |
|---|
| 1326 | } |
|---|
| 1327 | } |
|---|
| 1328 | |
|---|
| 1329 | if ((nvram_selmatch(wp, wl_net_mode, "n-only") |
|---|
| 1330 | || nvram_selmatch(wp, wl_net_mode, "n2-only") |
|---|
| 1331 | || nvram_selmatch(wp, wl_net_mode, "ng-only") |
|---|
| 1332 | || (!net_is_a |
|---|
| 1333 | && nvram_selmatch(wp, wl_net_mode, "mixed"))) |
|---|
| 1334 | && nvram_selmatch(wp, wl_nbw, "40")) { |
|---|
| 1335 | showit = 0; |
|---|
| 1336 | if (nvram_selnmatch |
|---|
| 1337 | (wp, "upper", "%s_nctrlsb", prefix)) { |
|---|
| 1338 | if (chanlist[i] >= 5 |
|---|
| 1339 | && chanlist[i] <= 13) { |
|---|
| 1340 | showit = 1; |
|---|
| 1341 | } |
|---|
| 1342 | } else |
|---|
| 1343 | if (nvram_selnmatch |
|---|
| 1344 | (wp, "lower", "%s_nctrlsb", prefix)) { |
|---|
| 1345 | if (chanlist[i] <= 9) { |
|---|
| 1346 | showit = 1; |
|---|
| 1347 | } |
|---|
| 1348 | } |
|---|
| 1349 | } |
|---|
| 1350 | |
|---|
| 1351 | sprintf(channelstring, "%d", chanlist[i]); |
|---|
| 1352 | if (showit) { |
|---|
| 1353 | websWrite(wp, |
|---|
| 1354 | "document.write(\"<option value=\\\"%d\\\" %s>%d - %0.3f GHz</option>\");\n", |
|---|
| 1355 | chanlist[i], |
|---|
| 1356 | nvram_selnmatch(wp, channelstring, |
|---|
| 1357 | "%s_channel", |
|---|
| 1358 | prefix) ? |
|---|
| 1359 | "selected=\\\"selected\\\"" : |
|---|
| 1360 | "", chanlist[i], ofs); |
|---|
| 1361 | } |
|---|
| 1362 | } |
|---|
| 1363 | #endif |
|---|
| 1364 | websWrite(wp, "//]]>\n</script></select></div>\n"); |
|---|
| 1365 | } |
|---|
| 1366 | } |
|---|
| 1367 | |
|---|
| 1368 | void ej_sas_show_security(webs_t wp, int argc, char_t ** argv) |
|---|
| 1369 | { |
|---|
| 1370 | int i = 0; |
|---|
| 1371 | #ifndef HAVE_MADWIFI |
|---|
| 1372 | int c = get_wl_instances(); |
|---|
| 1373 | |
|---|
| 1374 | for (i = 0; i < c; i++) { |
|---|
| 1375 | char buf[16]; |
|---|
| 1376 | |
|---|
| 1377 | sprintf(buf, "wl%d", i); |
|---|
| 1378 | sas_show_security_single(wp, argc, argv, buf); |
|---|
| 1379 | } |
|---|
| 1380 | return; |
|---|
| 1381 | #else |
|---|
| 1382 | int c = getdevicecount(); |
|---|
| 1383 | |
|---|
| 1384 | for (i = 0; i < c; i++) { |
|---|
| 1385 | char buf[16]; |
|---|
| 1386 | |
|---|
| 1387 | sprintf(buf, "ath%d", i); |
|---|
| 1388 | sas_show_security_single(wp, argc, argv, buf); |
|---|
| 1389 | } |
|---|
| 1390 | return; |
|---|
| 1391 | #endif |
|---|
| 1392 | } |
|---|
| 1393 | |
|---|
| 1394 | sas_show_security_single(webs_t wp, int argc, char_t ** argv, char *prefix) |
|---|
| 1395 | { |
|---|
| 1396 | char *next; |
|---|
| 1397 | char var[80]; |
|---|
| 1398 | char ssid[80]; |
|---|
| 1399 | char mac[16]; |
|---|
| 1400 | |
|---|
| 1401 | char *stage_visible_css = "display: none;"; |
|---|
| 1402 | if (ej_sas_stage_is_visible(wp, argc, argv) == 0) { |
|---|
| 1403 | stage_visible_css = ""; |
|---|
| 1404 | } |
|---|
| 1405 | |
|---|
| 1406 | sprintf(mac, "%s_hwaddr", prefix); |
|---|
| 1407 | char *vifs = sas_nvram_nget(wp, "%s_vifs", prefix); |
|---|
| 1408 | |
|---|
| 1409 | if (vifs == NULL) |
|---|
| 1410 | return; |
|---|
| 1411 | sprintf(ssid, "%s_ssid", prefix); |
|---|
| 1412 | /*websWrite(wp, |
|---|
| 1413 | "<h2 style=\"%s\"><script type=\"text/javascript\">Capture(wpa.h2)</script> %s</h2>\n", |
|---|
| 1414 | stage_visible_css, prefix); */ |
|---|
| 1415 | websWrite(wp, "<fieldset style=\"%s\">\n", stage_visible_css); |
|---|
| 1416 | // cprintf("getting %s %s\n",ssid,nvram_safe_get(ssid)); |
|---|
| 1417 | websWrite(wp, |
|---|
| 1418 | "<legend><script type=\"text/javascript\">Capture(wpa.h2)</script></legend>"); |
|---|
| 1419 | /* "<legend><script type=\"text/javascript\">Capture(share.pintrface)</script> %s SSID [", |
|---|
| 1420 | IFMAP(prefix)); |
|---|
| 1421 | tf_webWriteESCNV(wp, ssid); |
|---|
| 1422 | // contains html tag |
|---|
| 1423 | websWrite(wp, "] HWAddr [%s]</legend>\n", nvram_safe_get(mac)); */ |
|---|
| 1424 | sas_show_security_prefix(wp, argc, argv, prefix, 1); |
|---|
| 1425 | websWrite(wp, "</fieldset>\n<br style=\"%s\"/>\n", stage_visible_css); |
|---|
| 1426 | /*foreach(var, vifs, next) { |
|---|
| 1427 | sprintf(ssid, "%s_ssid", var); |
|---|
| 1428 | websWrite(wp, "<fieldset>\n"); |
|---|
| 1429 | // cprintf("getting %s %s\n", ssid,nvram_safe_get(ssid)); |
|---|
| 1430 | websWrite(wp, |
|---|
| 1431 | "<legend><script type=\"text/javascript\">Capture(share.vintrface)</script> %s SSID [", |
|---|
| 1432 | IFMAP(var)); |
|---|
| 1433 | tf_webWriteESCNV(wp, ssid); // fix for broken html page if ssid |
|---|
| 1434 | // contains html tag |
|---|
| 1435 | websWrite(wp, "]</legend>\n"); |
|---|
| 1436 | rep(var, '.', 'X'); |
|---|
| 1437 | sas_show_security_prefix(wp, argc, argv, var, 0); |
|---|
| 1438 | websWrite(wp, "</fieldset>\n<br />\n"); |
|---|
| 1439 | } */ |
|---|
| 1440 | |
|---|
| 1441 | } |
|---|
| 1442 | |
|---|
| 1443 | void sas_show_security_prefix(webs_t wp, int argc, char_t ** argv, char *prefix, |
|---|
| 1444 | int primary) |
|---|
| 1445 | { |
|---|
| 1446 | static char var[80]; |
|---|
| 1447 | static char sta[80]; |
|---|
| 1448 | static char spf[80]; |
|---|
| 1449 | |
|---|
| 1450 | // char p2[80]; |
|---|
| 1451 | cprintf("show security prefix\n"); |
|---|
| 1452 | sprintf(var, "%s_security_mode", prefix); |
|---|
| 1453 | sprintf(spf, "disabled"); |
|---|
| 1454 | // strcpy(p2,prefix); |
|---|
| 1455 | // rep(p2,'X','.'); |
|---|
| 1456 | // websWrite (wp, "<input type=\"hidden\" |
|---|
| 1457 | // name=\"%s_security_mode\"/>\n",p2); |
|---|
| 1458 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1459 | websWrite(wp, |
|---|
| 1460 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.secmode)</script></div>\n"); |
|---|
| 1461 | websWrite(wp, |
|---|
| 1462 | "<select name=\"%s_security_mode\" onchange=\"SelMode('%s_security_mode',this.form.%s_security_mode.selectedIndex,this.form)\">\n", |
|---|
| 1463 | prefix, prefix, prefix); |
|---|
| 1464 | websWrite(wp, |
|---|
| 1465 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"disabled\\\" %s >\" + share.disabled + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 1466 | selmatch(wp, var, "disabled", "selected=\\\"selected\\\"")); |
|---|
| 1467 | websWrite(wp, "<option value=\"psk\" %s>WPA Personal</option>\n", |
|---|
| 1468 | selmatch(wp, var, "psk", "selected=\"selected\"")); |
|---|
| 1469 | if (!strcmp(nvram_selget(wp, var), "psk")) { |
|---|
| 1470 | sprintf(spf, "psk"); |
|---|
| 1471 | } |
|---|
| 1472 | sprintf(sta, "%s_mode", prefix); |
|---|
| 1473 | if (!primary || nvram_selmatch(wp, sta, "ap") |
|---|
| 1474 | || nvram_selmatch(wp, sta, "wdsap")) { |
|---|
| 1475 | websWrite(wp, |
|---|
| 1476 | "<option value=\"wpa\" %s>WPA Enterprise</option>\n", |
|---|
| 1477 | selmatch(wp, var, "wpa", "selected=\"selected\"")); |
|---|
| 1478 | if (!strcmp(nvram_selget(wp, var), "wpa")) { |
|---|
| 1479 | sprintf(spf, "wpa"); |
|---|
| 1480 | } |
|---|
| 1481 | } |
|---|
| 1482 | websWrite(wp, "<option value=\"psk2\" %s>WPA2 Personal</option>\n", |
|---|
| 1483 | selmatch(wp, var, "psk2", "selected=\"selected\"")); |
|---|
| 1484 | if (!strcmp(nvram_selget(wp, var), "psk2")) { |
|---|
| 1485 | sprintf(spf, "psk2"); |
|---|
| 1486 | } |
|---|
| 1487 | if (!primary || nvram_selmatch(wp, sta, "ap") |
|---|
| 1488 | || nvram_selmatch(wp, sta, "wdsap")) { |
|---|
| 1489 | websWrite(wp, |
|---|
| 1490 | "<option value=\"wpa2\" %s>WPA2 Enterprise</option>\n", |
|---|
| 1491 | selmatch(wp, var, "wpa2", "selected=\"selected\"")); |
|---|
| 1492 | if (!strcmp(nvram_selget(wp, var), "wpa2")) { |
|---|
| 1493 | sprintf(spf, "wpa2"); |
|---|
| 1494 | } |
|---|
| 1495 | } |
|---|
| 1496 | #ifdef HAVE_RT2880 |
|---|
| 1497 | if (!primary || nvram_selmatch(wp, sta, "ap")) |
|---|
| 1498 | #endif |
|---|
| 1499 | websWrite(wp, |
|---|
| 1500 | "<option value=\"psk psk2\" %s>WPA2 Personal Mixed</option>\n", |
|---|
| 1501 | selmatch(wp, var, "psk psk2", |
|---|
| 1502 | "selected=\"selected\"")); |
|---|
| 1503 | #ifdef HAVE_RT2880 |
|---|
| 1504 | if (!primary || nvram_selmatch(wp, sta, "ap")) |
|---|
| 1505 | #endif |
|---|
| 1506 | if (!strcmp(nvram_selget(wp, var), "psk psk2")) { |
|---|
| 1507 | sprintf(spf, "psk psk2"); |
|---|
| 1508 | } |
|---|
| 1509 | |
|---|
| 1510 | if (!primary || nvram_selmatch(wp, sta, "ap") |
|---|
| 1511 | || nvram_selmatch(wp, sta, "wdsap")) { |
|---|
| 1512 | websWrite(wp, |
|---|
| 1513 | "<option value=\"wpa wpa2\" %s>WPA2 Enterprise Mixed</option>\n", |
|---|
| 1514 | selmatch(wp, var, "wpa wpa2", |
|---|
| 1515 | "selected=\"selected\"")); |
|---|
| 1516 | if (!strcmp(nvram_selget(wp, var), "wpa wpa2")) { |
|---|
| 1517 | sprintf(spf, "wpa wpa2"); |
|---|
| 1518 | } |
|---|
| 1519 | |
|---|
| 1520 | websWrite(wp, "<option value=\"radius\" %s>RADIUS</option>\n", |
|---|
| 1521 | selmatch(wp, var, "radius", "selected=\"selected\"")); |
|---|
| 1522 | if (!strcmp(nvram_selget(wp, var), "radius")) { |
|---|
| 1523 | sprintf(spf, "radius"); |
|---|
| 1524 | } |
|---|
| 1525 | } |
|---|
| 1526 | |
|---|
| 1527 | websWrite(wp, "<option value=\"wep\" %s>WEP</option>\n", |
|---|
| 1528 | selmatch(wp, var, "wep", "selected=\"selected\"")); |
|---|
| 1529 | if (!strcmp(nvram_selget(wp, var), "wep")) { |
|---|
| 1530 | sprintf(spf, "wep"); |
|---|
| 1531 | } |
|---|
| 1532 | #ifdef HAVE_WPA_SUPPLICANT |
|---|
| 1533 | #ifndef HAVE_MICRO |
|---|
| 1534 | #ifndef HAVE_RT2880 |
|---|
| 1535 | if (nvram_selmatch(wp, sta, "sta") |
|---|
| 1536 | || nvram_selmatch(wp, sta, "wdssta") |
|---|
| 1537 | || nvram_match(sta, "apsta") || nvram_match(sta, "wet")) { |
|---|
| 1538 | websWrite(wp, "<option value=\"8021X\" %s>802.1x</option>\n", |
|---|
| 1539 | selmatch(wp, var, "8021X", "selected=\"selected\"")); |
|---|
| 1540 | if (!strcmp(nvram_selget(wp, var), "8021X")) { |
|---|
| 1541 | sprintf(spf, "8021X"); |
|---|
| 1542 | } |
|---|
| 1543 | } |
|---|
| 1544 | #else |
|---|
| 1545 | #ifndef HAVE_RT61 |
|---|
| 1546 | if (nvram_selmatch(wp, sta, "sta") || nvram_match(wp, sta, "wet")) { |
|---|
| 1547 | websWrite(wp, "<option value=\"8021X\" %s>802.1x</option>\n", |
|---|
| 1548 | selmatch(wp, var, "8021X", "selected=\"selected\"")); |
|---|
| 1549 | if (!strcmp(nvram_selget(wp, var), "8021X")) { |
|---|
| 1550 | sprintf(spf, "8021X"); |
|---|
| 1551 | } |
|---|
| 1552 | } |
|---|
| 1553 | #endif |
|---|
| 1554 | #endif |
|---|
| 1555 | #endif |
|---|
| 1556 | #endif |
|---|
| 1557 | |
|---|
| 1558 | websWrite(wp, "</select></div>\n"); |
|---|
| 1559 | rep(prefix, 'X', '.'); |
|---|
| 1560 | cprintf("ej show wpa\n"); |
|---|
| 1561 | sas_show_wpa_setting(wp, argc, argv, prefix, spf); |
|---|
| 1562 | } |
|---|
| 1563 | |
|---|
| 1564 | void sas_show_wparadius(webs_t wp, char *prefix) |
|---|
| 1565 | { |
|---|
| 1566 | char var[80]; |
|---|
| 1567 | |
|---|
| 1568 | websWrite(wp, "<div>\n"); |
|---|
| 1569 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1570 | websWrite(wp, |
|---|
| 1571 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.algorithms)</script></div>\n"); |
|---|
| 1572 | websWrite(wp, "<select name=\"%s_crypto\">\n", prefix); |
|---|
| 1573 | sprintf(var, "%s_crypto", prefix); |
|---|
| 1574 | websWrite(wp, "<option value=\"tkip\" %s>TKIP</option>\n", |
|---|
| 1575 | selmatch(wp, var, "tkip", "selected=\"selected\"")); |
|---|
| 1576 | websWrite(wp, "<option value=\"aes\" %s>AES</option>\n", |
|---|
| 1577 | selmatch(wp, var, "aes", "selected=\"selected\"")); |
|---|
| 1578 | websWrite(wp, "<option value=\"tkip+aes\" %s>TKIP+AES</option>\n", |
|---|
| 1579 | selmatch(wp, var, "tkip+aes", "selected=\"selected\"")); |
|---|
| 1580 | websWrite(wp, "</select></div>\n"); |
|---|
| 1581 | #ifdef HAVE_MADWIFI |
|---|
| 1582 | sas_show_radius(wp, prefix, 0, 1); |
|---|
| 1583 | #else |
|---|
| 1584 | sas_show_radius(wp, prefix, 0, 0); |
|---|
| 1585 | #endif |
|---|
| 1586 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1587 | websWrite(wp, |
|---|
| 1588 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.rekey)</script></div>\n"); |
|---|
| 1589 | sprintf(var, "%s_wpa_gtk_rekey", prefix); |
|---|
| 1590 | websWrite(wp, |
|---|
| 1591 | "<input name=\"%s_wpa_gtk_rekey\" maxlength=\"5\" size=\"10\" onblur=\"valid_range(this,0,99999,wpa.rekey)\" value=\"%s\" />", |
|---|
| 1592 | prefix, sas_nvram_default_get(wp, var, "3600")); |
|---|
| 1593 | websWrite(wp, "</div>\n"); |
|---|
| 1594 | websWrite(wp, "</div>\n"); |
|---|
| 1595 | } |
|---|
| 1596 | |
|---|
| 1597 | #ifdef HAVE_WPA_SUPPLICANT |
|---|
| 1598 | |
|---|
| 1599 | static void sas_init_80211x_layers(webs_t wp, char *prefix) |
|---|
| 1600 | { |
|---|
| 1601 | char var[80]; |
|---|
| 1602 | sprintf(var, "%s_security_mode", prefix); |
|---|
| 1603 | fprintf(stderr, "[init] %s %s\n", var, nvram_selget(wp, var)); |
|---|
| 1604 | if (!strcmp(nvram_selget(wp, var), "8021X")) { |
|---|
| 1605 | if (sas_nvram_prefix_match(wp, "8021xtype", prefix, "tls")) { |
|---|
| 1606 | websWrite(wp, "enable_idtls(\"%s\");\n", prefix); |
|---|
| 1607 | } else |
|---|
| 1608 | if (sas_nvram_prefix_match(wp, "8021xtype", prefix, "leap")) |
|---|
| 1609 | { |
|---|
| 1610 | websWrite(wp, "enable_idleap(\"%s\");\n", prefix); |
|---|
| 1611 | } else |
|---|
| 1612 | if (sas_nvram_prefix_match(wp, "8021xtype", prefix, "ttls")) |
|---|
| 1613 | { |
|---|
| 1614 | websWrite(wp, "enable_idttls(\"%s\");\n", prefix); |
|---|
| 1615 | } else { |
|---|
| 1616 | //if (sas_nvram_prefix_match(wp, "8021xtype", prefix, "peap")) { |
|---|
| 1617 | websWrite(wp, "enable_idpeap(\"%s\");\n", prefix); |
|---|
| 1618 | } |
|---|
| 1619 | } |
|---|
| 1620 | } |
|---|
| 1621 | |
|---|
| 1622 | void ej_sas_init_80211x_layers(webs_t wp, int argc, char_t ** argv) |
|---|
| 1623 | { |
|---|
| 1624 | #ifndef HAVE_MADWIFI |
|---|
| 1625 | int c = get_wl_instances(); |
|---|
| 1626 | int i = 0; |
|---|
| 1627 | |
|---|
| 1628 | for (i = 0; i < c; i++) { |
|---|
| 1629 | char buf[16]; |
|---|
| 1630 | |
|---|
| 1631 | sprintf(buf, "wl%d", i); |
|---|
| 1632 | sas_init_80211x_layers(wp, buf); |
|---|
| 1633 | } |
|---|
| 1634 | return; |
|---|
| 1635 | #else |
|---|
| 1636 | int c = getdevicecount(); |
|---|
| 1637 | int i = 0; |
|---|
| 1638 | |
|---|
| 1639 | for (i = 0; i < c; i++) { |
|---|
| 1640 | char buf[16]; |
|---|
| 1641 | |
|---|
| 1642 | sprintf(buf, "ath%d", i); |
|---|
| 1643 | if (nvram_selnmatch(wp, "8021X", "%s_security_mode", buf)) |
|---|
| 1644 | sas_init_80211x_layers(wp, buf); |
|---|
| 1645 | } |
|---|
| 1646 | return; |
|---|
| 1647 | #endif |
|---|
| 1648 | |
|---|
| 1649 | } |
|---|
| 1650 | |
|---|
| 1651 | void sas_show_80211X(webs_t wp, char *prefix) |
|---|
| 1652 | { |
|---|
| 1653 | |
|---|
| 1654 | /* |
|---|
| 1655 | * fields |
|---|
| 1656 | * _8021xtype |
|---|
| 1657 | * _8021xuser |
|---|
| 1658 | * _8021xpasswd |
|---|
| 1659 | * _8021xca |
|---|
| 1660 | * _8021xpem |
|---|
| 1661 | * _8021xprv |
|---|
| 1662 | * _8021xaddopt |
|---|
| 1663 | */ |
|---|
| 1664 | char type[32]; |
|---|
| 1665 | sas_nvram_default_get(wp, type, "ttls"); |
|---|
| 1666 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1667 | websWrite(wp, |
|---|
| 1668 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.xsuptype)</script></div>\n"); |
|---|
| 1669 | websWrite(wp, |
|---|
| 1670 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"peap\" onclick=\"enable_idpeap('%s')\" %s />Peap \n", |
|---|
| 1671 | prefix, prefix, sas_nvram_prefix_match(wp, "8021xtype", |
|---|
| 1672 | prefix, |
|---|
| 1673 | "peap") ? |
|---|
| 1674 | "checked=\"checked\"" : ""); |
|---|
| 1675 | websWrite(wp, |
|---|
| 1676 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"leap\" onclick=\"enable_idleap('%s')\" %s />Leap \n", |
|---|
| 1677 | prefix, prefix, sas_nvram_prefix_match(wp, "8021xtype", |
|---|
| 1678 | prefix, |
|---|
| 1679 | "leap") ? |
|---|
| 1680 | "checked=\"checked\"" : ""); |
|---|
| 1681 | websWrite(wp, |
|---|
| 1682 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"tls\" onclick=\"enable_idtls('%s')\" %s />TLS \n", |
|---|
| 1683 | prefix, prefix, sas_nvram_prefix_match(wp, "8021xtype", |
|---|
| 1684 | prefix, |
|---|
| 1685 | "tls") ? |
|---|
| 1686 | "checked=\"checked\"" : ""); |
|---|
| 1687 | websWrite(wp, |
|---|
| 1688 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"ttls\" onclick=\"enable_idttls('%s')\" %s />TTLS \n", |
|---|
| 1689 | prefix, prefix, sas_nvram_prefix_match(wp, "8021xtype", |
|---|
| 1690 | prefix, |
|---|
| 1691 | "ttls") ? |
|---|
| 1692 | "checked=\"checked\"" : ""); |
|---|
| 1693 | websWrite(wp, "</div>\n"); |
|---|
| 1694 | |
|---|
| 1695 | // ttls authentication |
|---|
| 1696 | websWrite(wp, "<div id=\"idttls%s\">\n", prefix); |
|---|
| 1697 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1698 | websWrite(wp, |
|---|
| 1699 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n"); |
|---|
| 1700 | websWrite(wp, |
|---|
| 1701 | "<input name=\"%s_ttls8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 1702 | prefix, sas_nvram_prefix_get(wp, "ttls8021xuser", prefix)); |
|---|
| 1703 | |
|---|
| 1704 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1705 | websWrite(wp, |
|---|
| 1706 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.anon)</script></div>\n"); |
|---|
| 1707 | websWrite(wp, |
|---|
| 1708 | "<input name=\"%s_ttls8021xanon\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 1709 | prefix, sas_nvram_prefix_get(wp, "ttls8021xanon", prefix)); |
|---|
| 1710 | |
|---|
| 1711 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1712 | websWrite(wp, |
|---|
| 1713 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n"); |
|---|
| 1714 | websWrite(wp, |
|---|
| 1715 | "<input name=\"%s_ttls8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 1716 | prefix, sas_nvram_prefix_get(wp, "ttls8021xpasswd", prefix)); |
|---|
| 1717 | |
|---|
| 1718 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1719 | websWrite(wp, |
|---|
| 1720 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.phase2)</script></div>\n"); |
|---|
| 1721 | websWrite(wp, |
|---|
| 1722 | "<input name=\"%s_ttls8021xphase2\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 1723 | prefix, sas_nvram_prefix_get(wp, "ttls8021xphase2", prefix)); |
|---|
| 1724 | |
|---|
| 1725 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1726 | websWrite(wp, |
|---|
| 1727 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.servercertif)</script></div>\n"); |
|---|
| 1728 | websWrite(wp, |
|---|
| 1729 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_ttls8021xca\" name=\"%s_ttls8021xca\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 1730 | prefix, prefix); |
|---|
| 1731 | websWrite(wp, "var %s_ttls8021xca = fix_cr( '", prefix); |
|---|
| 1732 | char namebuf[64]; |
|---|
| 1733 | sprintf(namebuf, "%s_ttls8021xca", prefix); |
|---|
| 1734 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 1735 | websWrite(wp, "' );\n"); |
|---|
| 1736 | websWrite(wp, |
|---|
| 1737 | "document.getElementById(\"%s_ttls8021xca\").value = %s_ttls8021xca;\n", |
|---|
| 1738 | prefix, prefix); |
|---|
| 1739 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 1740 | websWrite(wp, "</div>\n"); |
|---|
| 1741 | |
|---|
| 1742 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1743 | websWrite(wp, |
|---|
| 1744 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.options)</script></div>\n"); |
|---|
| 1745 | websWrite(wp, |
|---|
| 1746 | "<textarea cols=\"60\" rows=\"3\" id=\"%s_ttls8021xaddopt\" name=\"%s_ttls8021xaddopt\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 1747 | prefix, prefix); |
|---|
| 1748 | websWrite(wp, "var %s_ttls8021xaddopt = fix_cr( '", prefix); |
|---|
| 1749 | sprintf(namebuf, "%s_ttls8021xaddopt", prefix); |
|---|
| 1750 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 1751 | websWrite(wp, "' );\n"); |
|---|
| 1752 | websWrite(wp, |
|---|
| 1753 | "document.getElementById(\"%s_ttls8021xaddopt\").value = %s_ttls8021xaddopt;\n", |
|---|
| 1754 | prefix, prefix); |
|---|
| 1755 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 1756 | websWrite(wp, "</div>\n"); |
|---|
| 1757 | |
|---|
| 1758 | websWrite(wp, "</div>\n"); |
|---|
| 1759 | |
|---|
| 1760 | // peap authentication |
|---|
| 1761 | websWrite(wp, "<div id=\"idpeap%s\">\n", prefix); |
|---|
| 1762 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1763 | websWrite(wp, |
|---|
| 1764 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n"); |
|---|
| 1765 | websWrite(wp, |
|---|
| 1766 | "<input name=\"%s_peap8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 1767 | prefix, sas_nvram_prefix_get(wp, "peap8021xuser", prefix)); |
|---|
| 1768 | |
|---|
| 1769 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1770 | websWrite(wp, |
|---|
| 1771 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.anon)</script></div>\n"); |
|---|
| 1772 | websWrite(wp, |
|---|
| 1773 | "<input name=\"%s_peap8021xanon\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 1774 | prefix, sas_nvram_prefix_get(wp, "peap8021xanon", prefix)); |
|---|
| 1775 | |
|---|
| 1776 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1777 | websWrite(wp, |
|---|
| 1778 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n"); |
|---|
| 1779 | websWrite(wp, |
|---|
| 1780 | "<input name=\"%s_peap8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 1781 | prefix, sas_nvram_prefix_get(wp, "peap8021xpasswd", prefix)); |
|---|
| 1782 | |
|---|
| 1783 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1784 | websWrite(wp, |
|---|
| 1785 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.phase2)</script></div>\n"); |
|---|
| 1786 | websWrite(wp, |
|---|
| 1787 | "<input name=\"%s_peap8021xphase2\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 1788 | prefix, sas_nvram_prefix_get(wp, "peap8021xphase2", prefix)); |
|---|
| 1789 | |
|---|
| 1790 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1791 | websWrite(wp, |
|---|
| 1792 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.servercertif)</script></div>\n"); |
|---|
| 1793 | websWrite(wp, |
|---|
| 1794 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_peap8021xca\" name=\"%s_peap8021xca\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 1795 | prefix, prefix); |
|---|
| 1796 | |
|---|
| 1797 | websWrite(wp, "var %s_peap8021xca = fix_cr( '", prefix); |
|---|
| 1798 | sprintf(namebuf, "%s_peap8021xca", prefix); |
|---|
| 1799 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 1800 | websWrite(wp, "' );\n"); |
|---|
| 1801 | websWrite(wp, |
|---|
| 1802 | "document.getElementById(\"%s_peap8021xca\").value = %s_peap8021xca;\n", |
|---|
| 1803 | prefix, prefix); |
|---|
| 1804 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 1805 | websWrite(wp, "</div>\n"); |
|---|
| 1806 | |
|---|
| 1807 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1808 | websWrite(wp, |
|---|
| 1809 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.options)</script></div>\n"); |
|---|
| 1810 | websWrite(wp, |
|---|
| 1811 | "<textarea cols=\"60\" rows=\"3\" id=\"%s_peap8021xaddopt\" name=\"%s_peap8021xaddopt\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 1812 | prefix, prefix); |
|---|
| 1813 | websWrite(wp, "var %s_peap8021xaddopt = fix_cr( '", prefix); |
|---|
| 1814 | sprintf(namebuf, "%s_peap8021xaddopt", prefix); |
|---|
| 1815 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 1816 | websWrite(wp, "' );\n"); |
|---|
| 1817 | websWrite(wp, |
|---|
| 1818 | "document.getElementById(\"%s_peap8021xaddopt\").value = %s_peap8021xaddopt;\n", |
|---|
| 1819 | prefix, prefix); |
|---|
| 1820 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 1821 | websWrite(wp, "</div>\n"); |
|---|
| 1822 | |
|---|
| 1823 | websWrite(wp, "</div>\n"); |
|---|
| 1824 | |
|---|
| 1825 | // leap authentication |
|---|
| 1826 | websWrite(wp, "<div id=\"idleap%s\">\n", prefix); |
|---|
| 1827 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1828 | websWrite(wp, |
|---|
| 1829 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n"); |
|---|
| 1830 | websWrite(wp, |
|---|
| 1831 | "<input name=\"%s_leap8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 1832 | prefix, sas_nvram_prefix_get(wp, "leap8021xuser", prefix)); |
|---|
| 1833 | |
|---|
| 1834 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1835 | websWrite(wp, |
|---|
| 1836 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.anon)</script></div>\n"); |
|---|
| 1837 | websWrite(wp, |
|---|
| 1838 | "<input name=\"%s_leap8021xanon\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 1839 | prefix, sas_nvram_prefix_get(wp, "leap8021xanon", prefix)); |
|---|
| 1840 | |
|---|
| 1841 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1842 | websWrite(wp, |
|---|
| 1843 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n"); |
|---|
| 1844 | websWrite(wp, |
|---|
| 1845 | "<input name=\"%s_leap8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 1846 | prefix, sas_nvram_prefix_get(wp, "leap8021xpasswd", prefix)); |
|---|
| 1847 | |
|---|
| 1848 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1849 | websWrite(wp, |
|---|
| 1850 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.phase2)</script></div>\n"); |
|---|
| 1851 | websWrite(wp, |
|---|
| 1852 | "<input name=\"%s_leap8021xphase2\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 1853 | prefix, sas_nvram_prefix_get(wp, "leap8021xphase2", prefix)); |
|---|
| 1854 | |
|---|
| 1855 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1856 | websWrite(wp, |
|---|
| 1857 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.options)</script></div>\n"); |
|---|
| 1858 | websWrite(wp, |
|---|
| 1859 | "<textarea cols=\"60\" rows=\"3\" id=\"%s_leap8021xaddopt\" name=\"%s_leap8021xaddopt\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 1860 | prefix, prefix); |
|---|
| 1861 | websWrite(wp, "var %s_leap8021xaddopt = fix_cr( '", prefix); |
|---|
| 1862 | sprintf(namebuf, "%s_leap8021xaddopt", prefix); |
|---|
| 1863 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 1864 | websWrite(wp, "' );\n"); |
|---|
| 1865 | websWrite(wp, |
|---|
| 1866 | "document.getElementById(\"%s_leap8021xaddopt\").value = %s_leap8021xaddopt;\n", |
|---|
| 1867 | prefix, prefix); |
|---|
| 1868 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 1869 | websWrite(wp, "</div>\n"); |
|---|
| 1870 | |
|---|
| 1871 | websWrite(wp, "</div>\n"); |
|---|
| 1872 | |
|---|
| 1873 | // tls authentication |
|---|
| 1874 | websWrite(wp, "<div id=\"idtls%s\">\n", prefix); |
|---|
| 1875 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1876 | websWrite(wp, |
|---|
| 1877 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n"); |
|---|
| 1878 | websWrite(wp, |
|---|
| 1879 | "<input name=\"%s_tls8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 1880 | prefix, nvram_prefix_get("tls8021xuser", prefix)); |
|---|
| 1881 | |
|---|
| 1882 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1883 | websWrite(wp, |
|---|
| 1884 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.anon)</script></div>\n"); |
|---|
| 1885 | websWrite(wp, |
|---|
| 1886 | "<input name=\"%s_tls8021xanon\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 1887 | prefix, sas_nvram_prefix_get(wp, "tls8021xanon", prefix)); |
|---|
| 1888 | |
|---|
| 1889 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1890 | websWrite(wp, |
|---|
| 1891 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n"); |
|---|
| 1892 | websWrite(wp, |
|---|
| 1893 | "<input name=\"%s_tls8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 1894 | prefix, sas_nvram_prefix_get(wp, "tls8021xpasswd", prefix)); |
|---|
| 1895 | |
|---|
| 1896 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1897 | websWrite(wp, |
|---|
| 1898 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.phase2)</script></div>\n"); |
|---|
| 1899 | websWrite(wp, |
|---|
| 1900 | "<input name=\"%s_tls8021xphase2\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 1901 | prefix, sas_nvram_prefix_get(wp, "tls8021xphase2", prefix)); |
|---|
| 1902 | |
|---|
| 1903 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1904 | websWrite(wp, |
|---|
| 1905 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.servercertif)</script></div>\n"); |
|---|
| 1906 | websWrite(wp, |
|---|
| 1907 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xca\" name=\"%s_tls8021xca\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 1908 | prefix, prefix); |
|---|
| 1909 | websWrite(wp, "var %s_tls8021xca = fix_cr( '", prefix); |
|---|
| 1910 | sprintf(namebuf, "%s_tls8021xca", prefix); |
|---|
| 1911 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 1912 | websWrite(wp, "' );\n"); |
|---|
| 1913 | websWrite(wp, |
|---|
| 1914 | "document.getElementById(\"%s_tls8021xca\").value = %s_tls8021xca;\n", |
|---|
| 1915 | prefix, prefix); |
|---|
| 1916 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 1917 | websWrite(wp, "</div>\n"); |
|---|
| 1918 | |
|---|
| 1919 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1920 | websWrite(wp, |
|---|
| 1921 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.clientcertif)</script></div>\n"); |
|---|
| 1922 | websWrite(wp, |
|---|
| 1923 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xpem\" name=\"%s_tls8021xpem\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 1924 | prefix, prefix); |
|---|
| 1925 | websWrite(wp, "var %s_tls8021xpem = fix_cr( '", prefix); |
|---|
| 1926 | sprintf(namebuf, "%s_tls8021xpem", prefix); |
|---|
| 1927 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 1928 | websWrite(wp, "' );\n"); |
|---|
| 1929 | websWrite(wp, |
|---|
| 1930 | "document.getElementById(\"%s_tls8021xpem\").value = %s_tls8021xpem;\n", |
|---|
| 1931 | prefix, prefix); |
|---|
| 1932 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 1933 | websWrite(wp, "</div>\n"); |
|---|
| 1934 | |
|---|
| 1935 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1936 | websWrite(wp, |
|---|
| 1937 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.privatekey)</script></div>\n"); |
|---|
| 1938 | websWrite(wp, |
|---|
| 1939 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xprv\" name=\"%s_tls8021xprv\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 1940 | prefix, prefix); |
|---|
| 1941 | websWrite(wp, "var %s_tls8021xprv = fix_cr( '", prefix); |
|---|
| 1942 | sprintf(namebuf, "%s_tls8021xprv", prefix); |
|---|
| 1943 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 1944 | websWrite(wp, "' );\n"); |
|---|
| 1945 | websWrite(wp, |
|---|
| 1946 | "document.getElementById(\"%s_tls8021xprv\").value = %s_tls8021xprv;\n", |
|---|
| 1947 | prefix, prefix); |
|---|
| 1948 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 1949 | websWrite(wp, "</div>\n"); |
|---|
| 1950 | |
|---|
| 1951 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1952 | websWrite(wp, |
|---|
| 1953 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.options)</script></div>\n"); |
|---|
| 1954 | websWrite(wp, |
|---|
| 1955 | "<textarea cols=\"60\" rows=\"3\" id=\"%s_tls8021xaddopt\" name=\"%s_tls8021xaddopt\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 1956 | prefix, prefix); |
|---|
| 1957 | websWrite(wp, "var %s_tls8021xaddopt = fix_cr( '", prefix); |
|---|
| 1958 | sprintf(namebuf, "%s_tls8021xaddopt", prefix); |
|---|
| 1959 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 1960 | websWrite(wp, "' );\n"); |
|---|
| 1961 | websWrite(wp, |
|---|
| 1962 | "document.getElementById(\"%s_tls8021xaddopt\").value = %s_tls8021xaddopt;\n", |
|---|
| 1963 | prefix, prefix); |
|---|
| 1964 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 1965 | websWrite(wp, "</div>\n"); |
|---|
| 1966 | |
|---|
| 1967 | websWrite(wp, "</div>\n"); |
|---|
| 1968 | websWrite(wp, "<script>\n//<![CDATA[\n "); |
|---|
| 1969 | char peap[32]; |
|---|
| 1970 | sprintf(peap, "%s_8021xtype", prefix); |
|---|
| 1971 | websWrite(wp, |
|---|
| 1972 | "show_layer_ext(document.wpa.%s_8021xtype, 'idpeap%s', %s);\n", |
|---|
| 1973 | prefix, prefix, nvram_selmatch(wp, peap, |
|---|
| 1974 | "peap") ? "true" : "false"); |
|---|
| 1975 | websWrite(wp, |
|---|
| 1976 | "show_layer_ext(document.wpa.%s_8021xtype, 'idtls%s', %s);\n", |
|---|
| 1977 | prefix, prefix, nvram_selmatch(wp, peap, |
|---|
| 1978 | "tls") ? "true" : "false"); |
|---|
| 1979 | websWrite(wp, |
|---|
| 1980 | "show_layer_ext(document.wpa.%s_8021xtype, 'idleap%s', %s);\n", |
|---|
| 1981 | prefix, prefix, nvram_selmatch(wp, peap, |
|---|
| 1982 | "leap") ? "true" : "false"); |
|---|
| 1983 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 1984 | } |
|---|
| 1985 | #endif |
|---|
| 1986 | |
|---|
| 1987 | void sas_show_wpa_setting(webs_t wp, int argc, char_t ** argv, char *prefix, |
|---|
| 1988 | char *security_prefix) |
|---|
| 1989 | { |
|---|
| 1990 | char *type, *security_mode; |
|---|
| 1991 | char var[80]; |
|---|
| 1992 | |
|---|
| 1993 | fprintf(stderr, "[security prefix] %s\n", security_prefix); |
|---|
| 1994 | sprintf(var, "%s_security_mode", prefix); |
|---|
| 1995 | cprintf("show wpa setting\n"); |
|---|
| 1996 | #ifdef FASTWEB |
|---|
| 1997 | ejArgs(argc, argv, "%s", &type); |
|---|
| 1998 | #else |
|---|
| 1999 | if (ejArgs(argc, argv, "%s", &type) < 1) { |
|---|
| 2000 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 2001 | return; |
|---|
| 2002 | } |
|---|
| 2003 | #endif |
|---|
| 2004 | rep(var, '.', 'X'); |
|---|
| 2005 | security_mode = GOZILA_GET(wp, var); |
|---|
| 2006 | if (security_mode == NULL) |
|---|
| 2007 | //security_mode = nvram_safe_get(var); |
|---|
| 2008 | security_mode = nvram_selget(wp, var); |
|---|
| 2009 | if (strcmp(security_mode, security_prefix)) { |
|---|
| 2010 | if (strlen(security_prefix) > strlen(security_mode)) { |
|---|
| 2011 | security_mode = |
|---|
| 2012 | (char *)safe_malloc(strlen(security_prefix)); |
|---|
| 2013 | } |
|---|
| 2014 | sprintf(security_mode, "%s", security_prefix); |
|---|
| 2015 | } |
|---|
| 2016 | rep(var, 'X', '.'); |
|---|
| 2017 | cprintf("security mode %s = %s\n", security_mode, var); |
|---|
| 2018 | fprintf(stderr, "security mode %s = %s\n", security_mode, var); |
|---|
| 2019 | if (!strcmp(security_mode, "psk") |
|---|
| 2020 | || !strcmp(security_mode, "psk2") |
|---|
| 2021 | || !strcmp(security_mode, "psk psk2")) |
|---|
| 2022 | sas_show_preshared(wp, prefix); |
|---|
| 2023 | #if UI_STYLE != CISCO |
|---|
| 2024 | else if (!strcmp(security_mode, "disabled")) |
|---|
| 2025 | sas_show_preshared(wp, prefix); |
|---|
| 2026 | #endif |
|---|
| 2027 | else if (!strcmp(security_mode, "radius")) |
|---|
| 2028 | sas_show_radius(wp, prefix, 1, 0); |
|---|
| 2029 | else if (!strcmp(security_mode, "wpa") |
|---|
| 2030 | || !strcmp(security_mode, "wpa2") |
|---|
| 2031 | || !strcmp(security_mode, "wpa wpa2")) |
|---|
| 2032 | sas_show_wparadius(wp, prefix); |
|---|
| 2033 | else if (!strcmp(security_mode, "wep")) |
|---|
| 2034 | sas_show_wep(wp, prefix); |
|---|
| 2035 | #ifdef HAVE_WPA_SUPPLICANT |
|---|
| 2036 | #ifndef HAVE_MICRO |
|---|
| 2037 | else if (!strcmp(security_mode, "8021X")) |
|---|
| 2038 | sas_show_80211X(wp, prefix); |
|---|
| 2039 | #endif |
|---|
| 2040 | #endif |
|---|
| 2041 | return; |
|---|
| 2042 | } |
|---|
| 2043 | |
|---|
| 2044 | char *sas_get_wep_value(char *temp, char *type, char *_bit, char *prefix) |
|---|
| 2045 | { |
|---|
| 2046 | int cnt; |
|---|
| 2047 | char *wordlist; |
|---|
| 2048 | char wl_wep[] = "wlX.XX_wep_XXXXXX"; |
|---|
| 2049 | |
|---|
| 2050 | // check for httpd post values |
|---|
| 2051 | if (nvram_match("gozila_action", "1") |
|---|
| 2052 | && !nvram_match("generate_key", "1")) { |
|---|
| 2053 | char label[32]; |
|---|
| 2054 | sprintf(label, "%s_%s", prefix, type); |
|---|
| 2055 | return nvram_selget(temp, label); |
|---|
| 2056 | } |
|---|
| 2057 | |
|---|
| 2058 | if (nvram_match("generate_key", "1")) { |
|---|
| 2059 | snprintf(wl_wep, sizeof(wl_wep), "%s_wep_gen", prefix); |
|---|
| 2060 | } else { |
|---|
| 2061 | snprintf(wl_wep, sizeof(wl_wep), "%s_wep_buf", prefix); |
|---|
| 2062 | } |
|---|
| 2063 | |
|---|
| 2064 | wordlist = nvram_safe_get(wl_wep); |
|---|
| 2065 | |
|---|
| 2066 | if (!strcmp(wordlist, "")) |
|---|
| 2067 | return ""; |
|---|
| 2068 | |
|---|
| 2069 | cnt = count_occurences(wordlist, ':'); |
|---|
| 2070 | |
|---|
| 2071 | if (!strcmp(type, "passphrase")) { |
|---|
| 2072 | if (wordlist[0] == ':') |
|---|
| 2073 | return ""; |
|---|
| 2074 | substring(0, pos_nthoccurence(wordlist, ':', cnt - 4), wordlist, |
|---|
| 2075 | temp); |
|---|
| 2076 | return temp; |
|---|
| 2077 | } else if (!strcmp(type, "key1")) { |
|---|
| 2078 | substring(pos_nthoccurence(wordlist, ':', cnt - 4) + 1, |
|---|
| 2079 | pos_nthoccurence(wordlist, ':', cnt - 3), wordlist, |
|---|
| 2080 | temp); |
|---|
| 2081 | return temp; |
|---|
| 2082 | } else if (!strcmp(type, "key2")) { |
|---|
| 2083 | substring(pos_nthoccurence(wordlist, ':', cnt - 3) + 1, |
|---|
| 2084 | pos_nthoccurence(wordlist, ':', cnt - 2), wordlist, |
|---|
| 2085 | temp); |
|---|
| 2086 | return temp; |
|---|
| 2087 | } else if (!strcmp(type, "key3")) { |
|---|
| 2088 | substring(pos_nthoccurence(wordlist, ':', cnt - 2) + 1, |
|---|
| 2089 | pos_nthoccurence(wordlist, ':', cnt - 1), wordlist, |
|---|
| 2090 | temp); |
|---|
| 2091 | return temp; |
|---|
| 2092 | } else if (!strcmp(type, "key4")) { |
|---|
| 2093 | substring(pos_nthoccurence(wordlist, ':', cnt - 1) + 1, |
|---|
| 2094 | pos_nthoccurence(wordlist, ':', cnt), wordlist, temp); |
|---|
| 2095 | return temp; |
|---|
| 2096 | } else if (!strcmp(type, "tx")) { |
|---|
| 2097 | substring(pos_nthoccurence(wordlist, ':', cnt) + 1, |
|---|
| 2098 | strlen(wordlist), wordlist, temp); |
|---|
| 2099 | return temp; |
|---|
| 2100 | } |
|---|
| 2101 | |
|---|
| 2102 | return ""; |
|---|
| 2103 | } |
|---|
| 2104 | |
|---|
| 2105 | void sas_show_wep(webs_t wp, char *prefix) |
|---|
| 2106 | { |
|---|
| 2107 | |
|---|
| 2108 | char var[80]; |
|---|
| 2109 | char *bit; |
|---|
| 2110 | |
|---|
| 2111 | cprintf("show wep\n"); |
|---|
| 2112 | #if defined(HAVE_MADWIFI) || defined(HAVE_RT2880) |
|---|
| 2113 | char wl_authmode[16]; |
|---|
| 2114 | |
|---|
| 2115 | sprintf(wl_authmode, "%s_authmode", prefix); |
|---|
| 2116 | sas_nvram_default_get(wp, wl_authmode, "open"); |
|---|
| 2117 | if (nvram_invmatch(wl_authmode, "auto")) { |
|---|
| 2118 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2119 | websWrite(wp, |
|---|
| 2120 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label)</script></div>\n"); |
|---|
| 2121 | websWrite(wp, |
|---|
| 2122 | "<input class=\"spaceradio\" type=\"radio\" value=\"open\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.openn)</script></input> \n", |
|---|
| 2123 | wl_authmode, nvram_selmatch(wp, wl_authmode, |
|---|
| 2124 | "open") ? |
|---|
| 2125 | "checked=\"checked\"" : ""); |
|---|
| 2126 | websWrite(wp, |
|---|
| 2127 | "<input class=\"spaceradio\" type=\"radio\" value=\"shared\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.share_key)</script></input>\n", |
|---|
| 2128 | wl_authmode, nvram_selmatch(wp, wl_authmode, |
|---|
| 2129 | "shared") ? |
|---|
| 2130 | "checked=\"checked\"" : ""); |
|---|
| 2131 | websWrite(wp, "</div>\n"); |
|---|
| 2132 | } |
|---|
| 2133 | #endif |
|---|
| 2134 | websWrite(wp, |
|---|
| 2135 | "<div><div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wep.defkey)</script></div>"); |
|---|
| 2136 | websWrite(wp, "<input type=\"hidden\" name=\"%s_WEP_key\" />", prefix); |
|---|
| 2137 | websWrite(wp, |
|---|
| 2138 | "<input type=\"hidden\" name=\"%s_wep\" value=\"restricted\" />", |
|---|
| 2139 | prefix); |
|---|
| 2140 | sprintf(var, "%s_key", prefix); |
|---|
| 2141 | sas_nvram_default_get(wp, var, "1"); |
|---|
| 2142 | websWrite(wp, |
|---|
| 2143 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s_key\" %s />1 \n", |
|---|
| 2144 | prefix, selmatch(wp, var, "1", "checked=\"checked\"")); |
|---|
| 2145 | websWrite(wp, |
|---|
| 2146 | "<input class=\"spaceradio\" type=\"radio\" value=\"2\" name=\"%s_key\" %s />2 \n", |
|---|
| 2147 | prefix, selmatch(wp, var, "2", "checked=\"checked\"")); |
|---|
| 2148 | websWrite(wp, |
|---|
| 2149 | "<input class=\"spaceradio\" type=\"radio\" value=\"3\" name=\"%s_key\" %s />3 \n", |
|---|
| 2150 | prefix, selmatch(wp, var, "3", "checked=\"checked\"")); |
|---|
| 2151 | websWrite(wp, |
|---|
| 2152 | "<input class=\"spaceradio\" type=\"radio\" value=\"4\" name=\"%s_key\" %s />4 \n", |
|---|
| 2153 | prefix, selmatch(wp, var, "4", "checked=\"checked\"")); |
|---|
| 2154 | websWrite(wp, "</div>"); |
|---|
| 2155 | websWrite(wp, |
|---|
| 2156 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.encrypt)</script></div>"); |
|---|
| 2157 | |
|---|
| 2158 | sprintf(var, "%s_wep_bit", prefix); |
|---|
| 2159 | //bit = nvram_safe_get(var); |
|---|
| 2160 | bit = nvram_selget(wp, var); |
|---|
| 2161 | |
|---|
| 2162 | cprintf("bit %s\n", bit); |
|---|
| 2163 | |
|---|
| 2164 | websWrite(wp, |
|---|
| 2165 | "<select name=\"%s_wep_bit\" size=\"1\" onchange=keyMode(this.form)>", |
|---|
| 2166 | prefix); |
|---|
| 2167 | websWrite(wp, "<option value=\"64\" %s >64 bits 10 hex digits</option>", |
|---|
| 2168 | selmatch(wp, var, "64", "selected=\"selected\"")); |
|---|
| 2169 | websWrite(wp, |
|---|
| 2170 | "<option value=\"128\" %s >128 bits 26 hex digits</option>", |
|---|
| 2171 | selmatch(wp, var, "128", "selected=\"selected\"")); |
|---|
| 2172 | websWrite(wp, |
|---|
| 2173 | "</select>\n</div>\n<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wep.passphrase)</script></div>\n"); |
|---|
| 2174 | websWrite(wp, |
|---|
| 2175 | "<input name=%s_passphrase maxlength=\"16\" size=\"20\" value=\"", |
|---|
| 2176 | prefix); |
|---|
| 2177 | |
|---|
| 2178 | char p_temp[128]; |
|---|
| 2179 | char temp[256]; |
|---|
| 2180 | |
|---|
| 2181 | sprintf(p_temp, "%s", |
|---|
| 2182 | sas_get_wep_value(temp, "passphrase", bit, prefix)); |
|---|
| 2183 | nvram_set("passphrase_temp", p_temp); |
|---|
| 2184 | tf_webWriteESCNV(wp, "passphrase_temp"); |
|---|
| 2185 | nvram_unset("passphrase_temp"); |
|---|
| 2186 | |
|---|
| 2187 | websWrite(wp, "\" />"); |
|---|
| 2188 | websWrite(wp, |
|---|
| 2189 | "<input type=\"hidden\" value=\"Null\" name=\"generateButton\" />\n"); |
|---|
| 2190 | websWrite(wp, |
|---|
| 2191 | "<input class=\"button\" type=\"button\" value=\"Generate\" onclick=generateKey(this.form,\"%s\") name=wepGenerate />\n</div>", |
|---|
| 2192 | prefix); |
|---|
| 2193 | |
|---|
| 2194 | char *mlen = "10"; |
|---|
| 2195 | char *mlen2 = "12"; |
|---|
| 2196 | |
|---|
| 2197 | if (!strcmp(bit, "128")) { |
|---|
| 2198 | mlen = "26"; |
|---|
| 2199 | mlen2 = "30"; |
|---|
| 2200 | } |
|---|
| 2201 | websWrite(wp, |
|---|
| 2202 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 1</div>\n"); |
|---|
| 2203 | websWrite(wp, |
|---|
| 2204 | "<input name=%s_key1 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 2205 | prefix, mlen2, mlen, sas_get_wep_value(temp, "key1", bit, |
|---|
| 2206 | prefix)); |
|---|
| 2207 | websWrite(wp, |
|---|
| 2208 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 2</div>\n"); |
|---|
| 2209 | websWrite(wp, |
|---|
| 2210 | "<input name=%s_key2 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 2211 | prefix, mlen2, mlen, sas_get_wep_value(temp, "key2", bit, |
|---|
| 2212 | prefix)); |
|---|
| 2213 | websWrite(wp, |
|---|
| 2214 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 3</div>\n"); |
|---|
| 2215 | websWrite(wp, |
|---|
| 2216 | "<input name=%s_key3 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 2217 | prefix, mlen2, mlen, sas_get_wep_value(temp, "key3", bit, |
|---|
| 2218 | prefix)); |
|---|
| 2219 | websWrite(wp, |
|---|
| 2220 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 4</div>\n"); |
|---|
| 2221 | websWrite(wp, |
|---|
| 2222 | "<input name=%s_key4 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 2223 | prefix, mlen2, mlen, sas_get_wep_value(temp, "key4", bit, |
|---|
| 2224 | prefix)); |
|---|
| 2225 | websWrite(wp, "</div>\n"); |
|---|
| 2226 | } |
|---|
| 2227 | |
|---|
| 2228 | void sas_show_preshared(webs_t wp, char *prefix) |
|---|
| 2229 | { |
|---|
| 2230 | |
|---|
| 2231 | char var[80]; |
|---|
| 2232 | |
|---|
| 2233 | cprintf("show preshared"); |
|---|
| 2234 | sprintf(var, "%s_crypto", prefix); |
|---|
| 2235 | websWrite(wp, "<div><div class=\"setting\">\n"); |
|---|
| 2236 | websWrite(wp, |
|---|
| 2237 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.algorithms)</script></div>\n"); |
|---|
| 2238 | websWrite(wp, "<select name=\"%s_crypto\">\n", prefix); |
|---|
| 2239 | websWrite(wp, "<option value=\"tkip\" %s>TKIP</option>\n", |
|---|
| 2240 | selmatch(wp, var, "tkip", "selected=\"selected\"")); |
|---|
| 2241 | websWrite(wp, "<option value=\"aes\" %s>AES</option>\n", |
|---|
| 2242 | selmatch(wp, var, "aes", "selected=\"selected\"")); |
|---|
| 2243 | websWrite(wp, "<option value=\"tkip+aes\" %s>TKIP+AES</option>\n", |
|---|
| 2244 | selmatch(wp, var, "tkip+aes", "selected=\"selected\"")); |
|---|
| 2245 | websWrite(wp, "</select>\n"); |
|---|
| 2246 | websWrite(wp, "</div>\n"); |
|---|
| 2247 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2248 | websWrite(wp, |
|---|
| 2249 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.shared_key)</script></div>\n"); |
|---|
| 2250 | |
|---|
| 2251 | sprintf(var, "%s_wpa_psk", prefix); |
|---|
| 2252 | websWrite(wp, |
|---|
| 2253 | "<input type=\"password\" id=\"%s_wpa_psk\" name=\"%s_wpa_psk\" onblur=\"valid_psk_length(this)\" maxlength=\"64\" size=\"32\" value=\"", |
|---|
| 2254 | prefix, prefix); |
|---|
| 2255 | //tf_webWriteESCNV(wp, var); |
|---|
| 2256 | websWrite(wp, "%s", nvram_selget(wp, var)); |
|---|
| 2257 | websWrite(wp, "\" /> \n"); |
|---|
| 2258 | websWrite(wp, |
|---|
| 2259 | "<input type=\"checkbox\" name=\"%s_wl_unmask\" value=\"0\" onclick=\"setElementMask('%s_wpa_psk', this.checked)\" > <script type=\"text/javascript\">Capture(share.unmask)</script></input>\n", |
|---|
| 2260 | prefix, prefix); |
|---|
| 2261 | websWrite(wp, "</div>\n"); |
|---|
| 2262 | /* websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2263 | websWrite(wp, |
|---|
| 2264 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.rekey)</script></div>\n"); |
|---|
| 2265 | |
|---|
| 2266 | sprintf(var, "%s_wpa_gtk_rekey", prefix); |
|---|
| 2267 | websWrite(wp, |
|---|
| 2268 | "<input class=\"num\" name=\"%s_wpa_gtk_rekey\" maxlength=\"5\" size=\"5\" onblur=\"valid_range(this,0,99999,wpa.rekey)\" value=\"%s\" />\n", |
|---|
| 2269 | prefix, nvram_default_get(var, "3600")); |
|---|
| 2270 | websWrite(wp, |
|---|
| 2271 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 3600, \" + share.range + \": 1 - 99999)\");\n//]]>\n</script></span>\n"); |
|---|
| 2272 | websWrite(wp, "</div>\n");*/ |
|---|
| 2273 | websWrite(wp, "</div>\n"); |
|---|
| 2274 | } |
|---|
| 2275 | |
|---|
| 2276 | void sas_show_radius(webs_t wp, char *prefix, int showmacformat, int backup) |
|---|
| 2277 | { |
|---|
| 2278 | |
|---|
| 2279 | char var[80]; |
|---|
| 2280 | |
|---|
| 2281 | cprintf("show radius\n"); |
|---|
| 2282 | if (showmacformat) { |
|---|
| 2283 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2284 | websWrite(wp, |
|---|
| 2285 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label2)</script></div>\n"); |
|---|
| 2286 | websWrite(wp, "<select name=\"%s_radmactype\">\n", prefix); |
|---|
| 2287 | websWrite(wp, |
|---|
| 2288 | "<option value=\"0\" %s >aabbcc-ddeeff</option>\n", |
|---|
| 2289 | sas_nvram_prefix_match(wp, "radmactype", prefix, |
|---|
| 2290 | "0") ? "selected" : ""); |
|---|
| 2291 | websWrite(wp, "<option value=\"1\" %s >aabbccddeeff</option>\n", |
|---|
| 2292 | sas_nvram_prefix_match(wp, "radmactype", prefix, |
|---|
| 2293 | "1") ? "selected" : ""); |
|---|
| 2294 | websWrite(wp, |
|---|
| 2295 | "<option value=\"2\" %s >aa:bb:cc:dd:ee:ff</option>\n", |
|---|
| 2296 | sas_nvram_prefix_match(wp, "radmactype", prefix, |
|---|
| 2297 | "2") ? "selected" : ""); |
|---|
| 2298 | websWrite(wp, |
|---|
| 2299 | "<option value=\"3\" %s >aa-bb-cc-dd-ee-ff</option>\n", |
|---|
| 2300 | sas_nvram_prefix_match(wp, "radmactype", prefix, |
|---|
| 2301 | "3") ? "selected" : ""); |
|---|
| 2302 | websWrite(wp, "</select>\n"); |
|---|
| 2303 | websWrite(wp, "</div>\n"); |
|---|
| 2304 | } |
|---|
| 2305 | //char *rad = sas_nvram_nget(wp, "%s_radius_ipaddr", prefix); |
|---|
| 2306 | //char *rad = printf("%s_radius_ipaddr", prefix); |
|---|
| 2307 | char rad[32]; |
|---|
| 2308 | sprintf(rad, "%s_radius_ipaddr", prefix); |
|---|
| 2309 | |
|---|
| 2310 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2311 | websWrite(wp, |
|---|
| 2312 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label3)</script></div>\n"); |
|---|
| 2313 | websWrite(wp, |
|---|
| 2314 | "<input type=\"hidden\" name=\"%s_radius_ipaddr\" value=\"%s\" />\n", |
|---|
| 2315 | prefix, rad); |
|---|
| 2316 | websWrite(wp, |
|---|
| 2317 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_0\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%s\" />.", |
|---|
| 2318 | prefix, sas_get_single_ip(wp, rad, 0)); |
|---|
| 2319 | websWrite(wp, |
|---|
| 2320 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_1\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%s\" />.", |
|---|
| 2321 | prefix, sas_get_single_ip(wp, rad, 1)); |
|---|
| 2322 | websWrite(wp, |
|---|
| 2323 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_2\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%s\" />.", |
|---|
| 2324 | prefix, sas_get_single_ip(wp, rad, 2)); |
|---|
| 2325 | websWrite(wp, |
|---|
| 2326 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_3\" onblur=\"valid_range(this,1,254,radius.label3)\" class=\"num\" value=\"%s\" />\n", |
|---|
| 2327 | prefix, sas_get_single_ip(wp, rad, 3)); |
|---|
| 2328 | websWrite(wp, "</div>\n"); |
|---|
| 2329 | |
|---|
| 2330 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2331 | websWrite(wp, |
|---|
| 2332 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label4)</script></div>\n"); |
|---|
| 2333 | sprintf(var, "%s_radius_port", prefix); |
|---|
| 2334 | websWrite(wp, |
|---|
| 2335 | "<input name=\"%s_radius_port\" size=\"3\" maxlength=\"5\" onblur=\"valid_range(this,1,65535,radius.label4)\" value=\"%s\" />\n", |
|---|
| 2336 | prefix, sas_nvram_default_get(wp, var, "1812")); |
|---|
| 2337 | websWrite(wp, |
|---|
| 2338 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 1812)\");\n//]]>\n</script></span>\n</div>\n"); |
|---|
| 2339 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2340 | websWrite(wp, |
|---|
| 2341 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label7)</script></div>\n"); |
|---|
| 2342 | sprintf(var, "%s_radius_key", prefix); |
|---|
| 2343 | websWrite(wp, |
|---|
| 2344 | "<input type=\"password\" id=\"%s_radius_key\" name=\"%s_radius_key\" maxlength=\"79\" size=\"32\" value=\"", |
|---|
| 2345 | prefix, prefix); |
|---|
| 2346 | |
|---|
| 2347 | //tf_webWriteESCNV(wp, var); |
|---|
| 2348 | websWrite(wp, "%s", nvram_selget(wp, var)); |
|---|
| 2349 | websWrite(wp, "\" /> \n"); |
|---|
| 2350 | websWrite(wp, |
|---|
| 2351 | "<input type=\"checkbox\" name=\"%s_radius_unmask\" value=\"0\" onclick=\"setElementMask('%s_radius_key', this.checked)\" > <script type=\"text/javascript\">Capture(share.unmask)</script></input>\n", |
|---|
| 2352 | prefix, prefix); |
|---|
| 2353 | |
|---|
| 2354 | if (backup) { |
|---|
| 2355 | //rad = sas_nvram_nget(wp, "%s_radius2_ipaddr", prefix); |
|---|
| 2356 | sprintf(rad, "%s_radius2_ipaddr", prefix); |
|---|
| 2357 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2358 | websWrite(wp, |
|---|
| 2359 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label23)</script></div>\n"); |
|---|
| 2360 | websWrite(wp, |
|---|
| 2361 | "<input type=\"hidden\" name=\"%s_radius2_ipaddr\" value=\"4\" />\n", |
|---|
| 2362 | prefix); |
|---|
| 2363 | websWrite(wp, |
|---|
| 2364 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius2_ipaddr_0\" onblur=\"valid_range(this,0,255,radius.label23)\" class=\"num\" value=\"%s\" />.", |
|---|
| 2365 | prefix, sas_get_single_ip(wp, rad, 0)); |
|---|
| 2366 | websWrite(wp, |
|---|
| 2367 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius2_ipaddr_1\" onblur=\"valid_range(this,0,255,radius.label23)\" class=\"num\" value=\"%s\" />.", |
|---|
| 2368 | prefix, sas_get_single_ip(wp, rad, 1)); |
|---|
| 2369 | websWrite(wp, |
|---|
| 2370 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius2_ipaddr_2\" onblur=\"valid_range(this,0,255,radius.label23)\" class=\"num\" value=\"%s\" />.", |
|---|
| 2371 | prefix, sas_get_single_ip(wp, rad, 2)); |
|---|
| 2372 | websWrite(wp, |
|---|
| 2373 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius2_ipaddr_3\" onblur=\"valid_range(this,1,254,radius.label23)\" class=\"num\" value=\"%s\" />\n", |
|---|
| 2374 | prefix, sas_get_single_ip(wp, rad, 3)); |
|---|
| 2375 | websWrite(wp, "</div>\n"); |
|---|
| 2376 | |
|---|
| 2377 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2378 | websWrite(wp, |
|---|
| 2379 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label24)</script></div>\n"); |
|---|
| 2380 | sprintf(var, "%s_radius2_port", prefix); |
|---|
| 2381 | websWrite(wp, |
|---|
| 2382 | "<input name=\"%s_radius2_port\" size=\"3\" maxlength=\"5\" onblur=\"valid_range(this,1,65535,radius.label24)\" value=\"%s\" />\n", |
|---|
| 2383 | prefix, sas_nvram_default_get(wp, var, "1812")); |
|---|
| 2384 | websWrite(wp, |
|---|
| 2385 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 1812)\");\n//]]>\n</script></span>\n</div>\n"); |
|---|
| 2386 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2387 | websWrite(wp, |
|---|
| 2388 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label27)</script></div>\n"); |
|---|
| 2389 | sprintf(var, "%s_radius2_key", prefix); |
|---|
| 2390 | websWrite(wp, |
|---|
| 2391 | "<input type=\"password\" id=\"%s_radius2_key\" name=\"%s_radius2_key\" maxlength=\"79\" size=\"32\" value=\"", |
|---|
| 2392 | prefix, prefix); |
|---|
| 2393 | |
|---|
| 2394 | //tf_webWriteESCNV(wp, var); |
|---|
| 2395 | websWrite(wp, "%s", nvram_selget(wp, var)); |
|---|
| 2396 | websWrite(wp, "\" /> \n"); |
|---|
| 2397 | websWrite(wp, |
|---|
| 2398 | "<input type=\"checkbox\" name=\"%s_radius2_unmask\" value=\"0\" onclick=\"setElementMask('%s_radius2_key', this.checked)\" > <script type=\"text/javascript\">Capture(share.unmask)</script></input>\n", |
|---|
| 2399 | prefix, prefix); |
|---|
| 2400 | } |
|---|
| 2401 | #ifdef HAVE_MADWIFI |
|---|
| 2402 | if (!showmacformat) { |
|---|
| 2403 | char acct[32]; |
|---|
| 2404 | char vvar[32]; |
|---|
| 2405 | |
|---|
| 2406 | strcpy(vvar, prefix); |
|---|
| 2407 | rep(vvar, '.', 'X'); |
|---|
| 2408 | sprintf(acct, "%s_acct", prefix); //var); |
|---|
| 2409 | websWrite(wp, |
|---|
| 2410 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label18)</script></div>\n"); |
|---|
| 2411 | websWrite(wp, |
|---|
| 2412 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" onclick=\"show_layer_ext(this, '%s_idacct', true);\" name=\"%s_acct\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input>\n", |
|---|
| 2413 | vvar, prefix, sas_nvram_default_match(wp, acct, "1", |
|---|
| 2414 | "0") ? |
|---|
| 2415 | "checked=\"checked\"" : ""); |
|---|
| 2416 | websWrite(wp, |
|---|
| 2417 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" onclick=\"show_layer_ext(this, '%s_idacct', false);\" name=\"%s_acct\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input> \n", |
|---|
| 2418 | vvar, prefix, sas_nvram_default_match(wp, acct, "0", |
|---|
| 2419 | "0") ? |
|---|
| 2420 | "checked=\"checked\"" : ""); |
|---|
| 2421 | websWrite(wp, "</div>\n"); |
|---|
| 2422 | //char *rad = sas_nvram_nget(wp, "%s_acct_ipaddr", prefix); |
|---|
| 2423 | sprintf(rad, "%s_acct_ipaddr", prefix); |
|---|
| 2424 | |
|---|
| 2425 | websWrite(wp, "<div id=\"%s_idacct\">\n", vvar); |
|---|
| 2426 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2427 | websWrite(wp, |
|---|
| 2428 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label13)</script></div>\n"); |
|---|
| 2429 | websWrite(wp, |
|---|
| 2430 | "<input type=\"hidden\" name=\"%s_acct_ipaddr\" value=\"4\" />\n", |
|---|
| 2431 | prefix); |
|---|
| 2432 | websWrite(wp, |
|---|
| 2433 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_0\" onblur=\"valid_range(this,0,255,radius.label13)\" class=\"num\" value=\"%s\" />.", |
|---|
| 2434 | prefix, sas_get_single_ip(wp, rad, 0)); |
|---|
| 2435 | websWrite(wp, |
|---|
| 2436 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_1\" onblur=\"valid_range(this,0,255,radius.label13)\" class=\"num\" value=\"%s\" />.", |
|---|
| 2437 | prefix, sas_get_single_ip(wp, rad, 1)); |
|---|
| 2438 | websWrite(wp, |
|---|
| 2439 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_2\" onblur=\"valid_range(this,0,255,radius.label13)\" class=\"num\" value=\"%s\" />.", |
|---|
| 2440 | prefix, sas_get_single_ip(wp, rad, 2)); |
|---|
| 2441 | websWrite(wp, |
|---|
| 2442 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_3\" onblur=\"valid_range(this,1,254,radius.label13)\" class=\"num\" value=\"%s\" />\n", |
|---|
| 2443 | prefix, sas_get_single_ip(wp, rad, 3)); |
|---|
| 2444 | websWrite(wp, "</div>\n"); |
|---|
| 2445 | |
|---|
| 2446 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2447 | websWrite(wp, |
|---|
| 2448 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label14)</script></div>\n"); |
|---|
| 2449 | sprintf(var, "%s_acct_port", prefix); |
|---|
| 2450 | websWrite(wp, |
|---|
| 2451 | "<input name=\"%s_acct_port\" size=\"3\" maxlength=\"5\" onblur=\"valid_range(this,1,65535,radius.label14)\" value=\"%s\" />\n", |
|---|
| 2452 | prefix, sas_nvram_default_get(wp, var, "1813")); |
|---|
| 2453 | websWrite(wp, |
|---|
| 2454 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 1813)\");\n//]]>\n</script></span>\n</div>\n"); |
|---|
| 2455 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2456 | websWrite(wp, |
|---|
| 2457 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label17)</script></div>\n"); |
|---|
| 2458 | sprintf(var, "%s_acct_key", prefix); |
|---|
| 2459 | websWrite(wp, |
|---|
| 2460 | "<input type=\"password\" id=\"%s_acct_key\" name=\"%s_acct_key\" maxlength=\"79\" size=\"32\" value=\"", |
|---|
| 2461 | prefix, prefix); |
|---|
| 2462 | //tf_webWriteESCNV(wp, var); |
|---|
| 2463 | websWrite(wp, "%s", nvram_selget(wp, var)); |
|---|
| 2464 | websWrite(wp, "\" /> \n"); |
|---|
| 2465 | websWrite(wp, |
|---|
| 2466 | "<input type=\"checkbox\" name=\"%s_acct_unmask\" value=\"0\" onclick=\"setElementMask('%s_acct_key', this.checked)\" > <script type=\"text/javascript\">Capture(share.unmask)</script></input>\n", |
|---|
| 2467 | prefix, prefix); |
|---|
| 2468 | websWrite(wp, "</div>\n"); |
|---|
| 2469 | websWrite(wp, "</div>\n"); |
|---|
| 2470 | websWrite(wp, "<script>\n//<![CDATA[\n "); |
|---|
| 2471 | websWrite(wp, |
|---|
| 2472 | "show_layer_ext(document.getElementsByName(\"%s_acct\"), \"%s_idacct\", %s);\n", |
|---|
| 2473 | prefix, vvar, nvram_selmatch(wp, acct, |
|---|
| 2474 | "1") ? "true" : "false"); |
|---|
| 2475 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 2476 | } |
|---|
| 2477 | #endif |
|---|
| 2478 | } |
|---|
| 2479 | |
|---|
| 2480 | void ej_sas_show_dhcpd_settings(webs_t wp, int argc, char_t ** argv) |
|---|
| 2481 | { |
|---|
| 2482 | |
|---|
| 2483 | char *stage_visible_css = "display: none;"; |
|---|
| 2484 | |
|---|
| 2485 | if (ej_sas_stage_is_visible(wp, argc, argv) == 0) { |
|---|
| 2486 | stage_visible_css = ""; |
|---|
| 2487 | } |
|---|
| 2488 | |
|---|
| 2489 | if (getWET()) // dhcpd settings disabled in client bridge mode, so we wont display it |
|---|
| 2490 | return; |
|---|
| 2491 | websWrite(wp, |
|---|
| 2492 | "<fieldset style=\"%s\"><legend><script type=\"text/javascript\">Capture(idx.dhcp_legend)</script></legend>\n", |
|---|
| 2493 | stage_visible_css); |
|---|
| 2494 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2495 | websWrite(wp, |
|---|
| 2496 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_type)</script></div>\n"); |
|---|
| 2497 | websWrite(wp, |
|---|
| 2498 | "<select class=\"num\" size=\"1\" name=\"dhcpfwd_enable\" onchange=SelDHCPFWD(this.form.dhcpfwd_enable.selectedIndex,this.form)>\n"); |
|---|
| 2499 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 2500 | websWrite(wp, |
|---|
| 2501 | "document.write(\"<option value=\\\"0\\\" %s >\" + idx.dhcp_srv + \"</option>\");\n", |
|---|
| 2502 | nvram_selmatch(wp, "dhcpfwd_enable", |
|---|
| 2503 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2504 | websWrite(wp, |
|---|
| 2505 | "document.write(\"<option value=\\\"1\\\" %s >\" + idx.dhcp_fwd + \"</option>\");\n", |
|---|
| 2506 | nvram_selmatch(wp, "dhcpfwd_enable", |
|---|
| 2507 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2508 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 2509 | websWrite(wp, "</select>\n"); |
|---|
| 2510 | websWrite(wp, "</div>\n"); |
|---|
| 2511 | if (nvram_selmatch(wp, "dhcpfwd_enable", "1")) { |
|---|
| 2512 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2513 | websWrite(wp, |
|---|
| 2514 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_srv)</script></div>\n"); |
|---|
| 2515 | char *ipfwd = nvram_selget(wp, "dhcpfwd_ip"); |
|---|
| 2516 | |
|---|
| 2517 | websWrite(wp, |
|---|
| 2518 | "<input type=\"hidden\" name=\"dhcpfwd_ip\" value=\"4\" /><input class=\"num\" maxlength=\"3\" size=\"3\" name=\"dhcpfwd_ip_0\" onblur=\"valid_range(this,0,255,idx.dhcp_srv)\" value=\"%d\" />.<input class=\"num\" maxlength=\"3\" size=\"3\" name=\"dhcpfwd_ip_1\" onblur=\"valid_range(this,0,255,idx.dhcp_srv)\" value=\"%d\" />.<input class=\"num\" maxlength=\"3\" name=\"dhcpfwd_ip_2\" size=\"3\" onblur=\"valid_range(this,0,255,idx.dhcp_srv)\" value=\"%d\" />.<input class=\"num\" maxlength=\"3\" name=\"dhcpfwd_ip_3\" size=\"3\" onblur=\"valid_range(this,0,254,idx.dhcp_srv)\" value=\"%d\"\" /></div>\n", |
|---|
| 2519 | sas_get_single_ip(wp, ipfwd, 0), sas_get_single_ip(wp, |
|---|
| 2520 | ipfwd, |
|---|
| 2521 | 1), |
|---|
| 2522 | sas_get_single_ip(wp, ipfwd, 2), sas_get_single_ip(wp, |
|---|
| 2523 | ipfwd, |
|---|
| 2524 | 3)); |
|---|
| 2525 | |
|---|
| 2526 | } else { |
|---|
| 2527 | char buf[20]; |
|---|
| 2528 | prefix_ip_get("lan_ipaddr", buf, 1); |
|---|
| 2529 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2530 | // char *nv = nvram_safe_get ("wan_wins"); |
|---|
| 2531 | websWrite(wp, |
|---|
| 2532 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_srv)</script></div><input class=\"spaceradio\" type=\"radio\" name=\"lan_proto\" value=\"dhcp\" onclick=SelDHCP('dhcp',this.form) %s /><script type=\"text/javascript\">Capture(share.enable)</script> \n", |
|---|
| 2533 | nvram_selmatch(wp, "lan_proto", |
|---|
| 2534 | "dhcp") ? "checked=\"checked\"" : ""); |
|---|
| 2535 | websWrite(wp, |
|---|
| 2536 | "<input class=\"spaceradio\" type=\"radio\" name=\"lan_proto\" value=\"static\" onclick=\"SelDHCP('static',this.form)\" %s /><script type=\"text/javascript\">Capture(share.disable)</script></div><input type=\"hidden\" name=\"dhcp_check\" /><div class=\"setting\">\n", |
|---|
| 2537 | nvram_selmatch(wp, "lan_proto", |
|---|
| 2538 | "static") ? "checked=\"checked\"" : |
|---|
| 2539 | ""); |
|---|
| 2540 | websWrite(wp, |
|---|
| 2541 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_start)</script></div>%s", |
|---|
| 2542 | buf); |
|---|
| 2543 | websWrite(wp, |
|---|
| 2544 | "<input class=\"num\" name=\"dhcp_start\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,1,254,idx.dhcp_start)\" value=\"%s\" %s />", |
|---|
| 2545 | nvram_selget(wp, "dhcp_start"), nvram_selmatch(wp, |
|---|
| 2546 | "lan_proto", |
|---|
| 2547 | "static") |
|---|
| 2548 | ? "disabled style=\"background: #e0e0e0\"" : ""); |
|---|
| 2549 | websWrite(wp, "</div>\n"); |
|---|
| 2550 | |
|---|
| 2551 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2552 | websWrite(wp, |
|---|
| 2553 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_maxusers)</script></div><input class=\"num\" name=\"dhcp_num\"size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,253,idx.dhcp_maxusers)\" value=\"%s\" %s/></div>\n", |
|---|
| 2554 | nvram_selget(wp, "dhcp_num"), |
|---|
| 2555 | nvram_selmatch(wp, "lan_proto", |
|---|
| 2556 | "static") ? |
|---|
| 2557 | "disabled style=\"background: #e0e0e0\"" : ""); |
|---|
| 2558 | } |
|---|
| 2559 | |
|---|
| 2560 | websWrite(wp, "</fieldset><br style=\"%s\"/>\n", stage_visible_css); |
|---|
| 2561 | return; |
|---|
| 2562 | } |
|---|
| 2563 | #endif |
|---|