| 1 | #define VISUALSOURCE 1 |
|---|
| 2 | /* |
|---|
| 3 | * dd-wrt.c |
|---|
| 4 | * |
|---|
| 5 | * Copyright (C) 2005 - 2007 Sebastian Gottschall <sebastian.gottschall@newmedia-net.de> |
|---|
| 6 | * |
|---|
| 7 | * This program is free software; you can redistribute it and/or |
|---|
| 8 | * modify it under the terms of the GNU General Public License |
|---|
| 9 | * as published by the Free Software Foundation; either version 2 |
|---|
| 10 | * of the License, or (at your option) any later version. |
|---|
| 11 | * |
|---|
| 12 | * This program is distributed in the hope that it will be useful, |
|---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | * GNU General Public License for more details. |
|---|
| 16 | * |
|---|
| 17 | * You should have received a copy of the GNU General Public License |
|---|
| 18 | * along with this program; if not, write to the Free Software |
|---|
| 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 20 | * |
|---|
| 21 | * $Id: |
|---|
| 22 | */ |
|---|
| 23 | |
|---|
| 24 | #include <stdio.h> |
|---|
| 25 | #include <stdlib.h> |
|---|
| 26 | #include <stdarg.h> |
|---|
| 27 | #include <string.h> |
|---|
| 28 | #include <unistd.h> |
|---|
| 29 | #include <ctype.h> |
|---|
| 30 | #include <signal.h> |
|---|
| 31 | |
|---|
| 32 | #include <sys/ioctl.h> |
|---|
| 33 | #include <sys/types.h> |
|---|
| 34 | #include <sys/stat.h> |
|---|
| 35 | #include <sys/socket.h> |
|---|
| 36 | #include <sys/statfs.h> |
|---|
| 37 | #include <netinet/in.h> |
|---|
| 38 | #include <arpa/inet.h> |
|---|
| 39 | #include <broadcom.h> |
|---|
| 40 | #include <cymac.h> |
|---|
| 41 | #include <wlutils.h> |
|---|
| 42 | #include <bcmparams.h> |
|---|
| 43 | #include <dirent.h> |
|---|
| 44 | #include <netdb.h> |
|---|
| 45 | #include <utils.h> |
|---|
| 46 | #include <wlutils.h> |
|---|
| 47 | #include <bcmnvram.h> |
|---|
| 48 | #include <l7protocols.h> |
|---|
| 49 | |
|---|
| 50 | #ifdef HAVE_OVERCLOCKING |
|---|
| 51 | static unsigned int type2_clocks[7] = { 200, 240, 252, 264, 300, 330, 0 }; |
|---|
| 52 | static unsigned int type3_clocks[3] = { 150, 200, 0 }; |
|---|
| 53 | static unsigned int type4_clocks[10] = |
|---|
| 54 | { 192, 200, 216, 228, 240, 252, 264, 280, 300, 0 }; |
|---|
| 55 | static unsigned int type7_clocks[10] = |
|---|
| 56 | { 183, 187, 198, 200, 216, 225, 233, 237, 250, 0 }; |
|---|
| 57 | #endif |
|---|
| 58 | |
|---|
| 59 | #ifdef HAVE_RT2880 |
|---|
| 60 | #define IFMAP(a) getRADev(a) |
|---|
| 61 | #else |
|---|
| 62 | #define IFMAP(a) (a) |
|---|
| 63 | #endif |
|---|
| 64 | |
|---|
| 65 | void show_ipnetmask(webs_t wp, char *var) |
|---|
| 66 | { |
|---|
| 67 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 68 | websWrite(wp, |
|---|
| 69 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.ip)</script></div>\n"); |
|---|
| 70 | |
|---|
| 71 | char *ipv = nvram_nget("%s_ipaddr", var); |
|---|
| 72 | |
|---|
| 73 | websWrite(wp, |
|---|
| 74 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,1,223,share.ip)\" name=\"%s_ipaddr_0\" value=\"%d\" />.", |
|---|
| 75 | var, get_single_ip(ipv, 0)); |
|---|
| 76 | websWrite(wp, |
|---|
| 77 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_1\" value=\"%d\" />.", |
|---|
| 78 | var, get_single_ip(ipv, 1)); |
|---|
| 79 | websWrite(wp, |
|---|
| 80 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_2\" value=\"%d\" />.", |
|---|
| 81 | var, get_single_ip(ipv, 2)); |
|---|
| 82 | websWrite(wp, |
|---|
| 83 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_3\" value=\"%d\" />\n", |
|---|
| 84 | var, get_single_ip(ipv, 3)); |
|---|
| 85 | websWrite(wp, "</div>\n"); |
|---|
| 86 | |
|---|
| 87 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 88 | websWrite(wp, |
|---|
| 89 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.subnet)</script></div>\n"); |
|---|
| 90 | ipv = nvram_nget("%s_netmask", var); |
|---|
| 91 | |
|---|
| 92 | websWrite(wp, |
|---|
| 93 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_0\" value=\"%d\" />.", |
|---|
| 94 | var, get_single_ip(ipv, 0)); |
|---|
| 95 | websWrite(wp, |
|---|
| 96 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_1\" value=\"%d\" />.", |
|---|
| 97 | var, get_single_ip(ipv, 1)); |
|---|
| 98 | websWrite(wp, |
|---|
| 99 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_2\" value=\"%d\" />.", |
|---|
| 100 | var, get_single_ip(ipv, 2)); |
|---|
| 101 | websWrite(wp, |
|---|
| 102 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_3\" value=\"%d\" />", |
|---|
| 103 | var, get_single_ip(ipv, 3)); |
|---|
| 104 | websWrite(wp, "</div>\n<br />\n"); |
|---|
| 105 | |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | #ifdef HAVE_OVERCLOCKING |
|---|
| 109 | void ej_show_clocks(webs_t wp, int argc, char_t ** argv) |
|---|
| 110 | { |
|---|
| 111 | int rev = cpu_plltype(); |
|---|
| 112 | unsigned int *c; |
|---|
| 113 | |
|---|
| 114 | if (rev == 2) |
|---|
| 115 | c = type2_clocks; |
|---|
| 116 | else if (rev == 3) |
|---|
| 117 | c = type3_clocks; |
|---|
| 118 | else if (rev == 4) |
|---|
| 119 | c = type4_clocks; |
|---|
| 120 | else if (rev == 7) |
|---|
| 121 | c = type7_clocks; |
|---|
| 122 | else { |
|---|
| 123 | websWrite(wp, |
|---|
| 124 | "<script type=\"text/javascript\">Capture(management.clock_support)</script>\n</div>\n"); |
|---|
| 125 | return; |
|---|
| 126 | } |
|---|
| 127 | |
|---|
| 128 | websWrite(wp, |
|---|
| 129 | "<div class=\"label\"><script type=\"text/javascript\">Capture(management.clock_frq)</script></div>\n"); |
|---|
| 130 | websWrite(wp, "<select name=\"overclocking\">\n"); |
|---|
| 131 | |
|---|
| 132 | char *oclk = nvram_safe_get("overclocking"); |
|---|
| 133 | |
|---|
| 134 | int cclk = atoi(oclk); |
|---|
| 135 | |
|---|
| 136 | int i = 0; |
|---|
| 137 | |
|---|
| 138 | while (c[i] != 0) { |
|---|
| 139 | websWrite(wp, "<option value=\"%d\" %s >%d MHz</option>\n", |
|---|
| 140 | c[i], c[i] == cclk ? "selected=\"selected\"" : |
|---|
| 141 | "", c[i]); |
|---|
| 142 | i++; |
|---|
| 143 | } |
|---|
| 144 | websWrite(wp, "</select>\n</div>\n"); |
|---|
| 145 | } |
|---|
| 146 | #endif |
|---|
| 147 | |
|---|
| 148 | void ej_show_routing(webs_t wp, int argc, char_t ** argv) |
|---|
| 149 | { |
|---|
| 150 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 151 | websWrite(wp, |
|---|
| 152 | "document.write(\"<option value=\\\"gateway\\\" %s >\" + share.gateway + \"</option>\");\n", |
|---|
| 153 | nvram_selmatch(wp, "wk_mode", |
|---|
| 154 | "gateway") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 155 | #ifdef HAVE_BIRD |
|---|
| 156 | websWrite(wp, |
|---|
| 157 | "document.write(\"<option value=\\\"bgp\\\" %s >BGP</option>\");\n", |
|---|
| 158 | nvram_selmatch(wp, "wk_mode", |
|---|
| 159 | "bgp") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 160 | websWrite(wp, |
|---|
| 161 | "document.write(\"<option value=\\\"router\\\" %s >\" + route.rip2_mod + \"</option>\");\n", |
|---|
| 162 | nvram_selmatch(wp, "wk_mode", |
|---|
| 163 | "router") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 164 | #endif |
|---|
| 165 | #ifdef HAVE_QUAGGA |
|---|
| 166 | websWrite(wp, |
|---|
| 167 | "document.write(\"<option value=\\\"bgp\\\" %s >BGP</option>\");\n", |
|---|
| 168 | nvram_selmatch(wp, "wk_mode", |
|---|
| 169 | "bgp") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 170 | websWrite(wp, |
|---|
| 171 | "document.write(\"<option value=\\\"router\\\" %s >\" + route.rip2_mod + \"</option>\");\n", |
|---|
| 172 | nvram_selmatch(wp, "wk_mode", |
|---|
| 173 | "router") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 174 | websWrite(wp, |
|---|
| 175 | "document.write(\"<option value=\\\"ospf\\\" %s >\" + route.ospf_mod + \"</option>\");\n", |
|---|
| 176 | nvram_selmatch(wp, "wk_mode", |
|---|
| 177 | "ospf") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 178 | #endif |
|---|
| 179 | #ifdef HAVE_OLSRD |
|---|
| 180 | websWrite(wp, |
|---|
| 181 | "document.write(\"<option value=\\\"olsr\\\" %s >\" + route.olsrd_mod + \"</option>\");\n", |
|---|
| 182 | nvram_selmatch(wp, "wk_mode", |
|---|
| 183 | "olsr") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 184 | #endif |
|---|
| 185 | websWrite(wp, |
|---|
| 186 | "document.write(\"<option value=\\\"static\\\" %s >\" + share.router + \"</option>\");\n", |
|---|
| 187 | nvram_selmatch(wp, "wk_mode", |
|---|
| 188 | "static") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 189 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 190 | return; |
|---|
| 191 | |
|---|
| 192 | } |
|---|
| 193 | |
|---|
| 194 | void ej_show_connectiontype(webs_t wp, int argc, char_t ** argv) |
|---|
| 195 | { |
|---|
| 196 | |
|---|
| 197 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 198 | websWrite(wp, |
|---|
| 199 | "document.write(\"<option value=\\\"disabled\\\" %s >\" + share.disabled + \"</option>\");\n", |
|---|
| 200 | nvram_selmatch(wp, "wan_proto", |
|---|
| 201 | "disabled") ? "selected=\\\"selected\\\"" : |
|---|
| 202 | ""); |
|---|
| 203 | websWrite(wp, |
|---|
| 204 | "document.write(\"<option value=\\\"static\\\" %s >\" + idx.static_ip + \"</option>\");\n", |
|---|
| 205 | nvram_selmatch(wp, "wan_proto", |
|---|
| 206 | "static") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 207 | websWrite(wp, |
|---|
| 208 | "document.write(\"<option value=\\\"dhcp\\\" %s >\" + idx.dhcp + \"</option>\");\n", |
|---|
| 209 | nvram_selmatch(wp, "wan_proto", |
|---|
| 210 | "dhcp") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 211 | websWrite(wp, "\n//]]>\n</script>\n"); |
|---|
| 212 | |
|---|
| 213 | #ifdef HAVE_PPPOE |
|---|
| 214 | websWrite(wp, "<option value=\"pppoe\" %s >PPPoE</option>\n", |
|---|
| 215 | nvram_selmatch(wp, "wan_proto", |
|---|
| 216 | "pppoe") ? "selected=\"selected\"" : ""); |
|---|
| 217 | #endif |
|---|
| 218 | #ifdef HAVE_PPTP |
|---|
| 219 | websWrite(wp, "<option value=\"pptp\" %s >PPTP</option>\n", |
|---|
| 220 | nvram_selmatch(wp, "wan_proto", |
|---|
| 221 | "pptp") ? "selected=\"selected\"" : ""); |
|---|
| 222 | #endif |
|---|
| 223 | #ifdef HAVE_L2TP |
|---|
| 224 | websWrite(wp, "<option value=\"l2tp\" %s >L2TP</option>\n", |
|---|
| 225 | nvram_selmatch(wp, "wan_proto", |
|---|
| 226 | "l2tp") ? "selected=\"selected\"" : ""); |
|---|
| 227 | #endif |
|---|
| 228 | #ifdef HAVE_HEARTBEAT |
|---|
| 229 | websWrite(wp, |
|---|
| 230 | "<option value=\"heartbeat\" %s >HeartBeat Signal</option>\n", |
|---|
| 231 | nvram_selmatch(wp, "wan_proto", |
|---|
| 232 | "heartbeat") ? "selected=\"selected\"" : ""); |
|---|
| 233 | #endif |
|---|
| 234 | #ifdef HAVE_3G |
|---|
| 235 | websWrite(wp, |
|---|
| 236 | "<option value=\"3g\" %s >3G/UMTS</option>\n", |
|---|
| 237 | nvram_selmatch(wp, "wan_proto", |
|---|
| 238 | "3g") ? "selected=\"selected\"" : ""); |
|---|
| 239 | #endif |
|---|
| 240 | |
|---|
| 241 | return; |
|---|
| 242 | } |
|---|
| 243 | |
|---|
| 244 | void ej_show_infopage(webs_t wp, int argc, char_t ** argv) |
|---|
| 245 | { |
|---|
| 246 | /* |
|---|
| 247 | * #ifdef HAVE_NEWMEDIA websWrite(wp,"<dl>\n"); websWrite(wp,"<dd |
|---|
| 248 | * class=\"definition\">GGEW net GmbH</dd>\n"); websWrite(wp,"<dd |
|---|
| 249 | * class=\"definition\">Dammstrasse 68</dd>\n"); websWrite(wp,"<dd |
|---|
| 250 | * class=\"definition\">64625 Bensheim</dd>\n"); websWrite(wp,"<dd |
|---|
| 251 | * class=\"definition\"><a href=\"http://ggew-net.de\"><img |
|---|
| 252 | * src=\"images/ggewlogo.gif\" border=\"0\"/></a></dd>\n"); |
|---|
| 253 | * websWrite(wp,"<dd class=\"definition\"> </dd>\n"); websWrite(wp,"<dd |
|---|
| 254 | * class=\"definition\"><a href=\"http://ggew-net.de\"/></dd>\n"); |
|---|
| 255 | * websWrite(wp,"<dd class=\"definition\"> </dd>\n"); websWrite(wp,"<dd |
|---|
| 256 | * class=\"definition\">In Kooperation mit NewMedia-NET GmbH</dd>\n"); |
|---|
| 257 | * websWrite(wp,"<dd class=\"definition\"><a |
|---|
| 258 | * href=\"http://www.newmedia-net.de\"/></dd>\n"); |
|---|
| 259 | * websWrite(wp,"</dl>\n"); #endif |
|---|
| 260 | */ |
|---|
| 261 | return; |
|---|
| 262 | } |
|---|
| 263 | |
|---|
| 264 | void ej_dumpmeminfo(webs_t wp, int argc, char_t ** argv) |
|---|
| 265 | { |
|---|
| 266 | FILE *fcpu = fopen("/proc/meminfo", "r"); |
|---|
| 267 | |
|---|
| 268 | if (fcpu == NULL) { |
|---|
| 269 | return; |
|---|
| 270 | } |
|---|
| 271 | char buf[128]; |
|---|
| 272 | int n = 0; |
|---|
| 273 | |
|---|
| 274 | rept:; |
|---|
| 275 | if (n == EOF) { |
|---|
| 276 | fclose(fcpu); |
|---|
| 277 | return; |
|---|
| 278 | } |
|---|
| 279 | if (n) |
|---|
| 280 | websWrite(wp, "'%s'", buf); |
|---|
| 281 | n = fscanf(fcpu, "%s", buf); |
|---|
| 282 | if (n != EOF) |
|---|
| 283 | websWrite(wp, ","); |
|---|
| 284 | goto rept; |
|---|
| 285 | } |
|---|
| 286 | |
|---|
| 287 | #ifdef HAVE_RB500 |
|---|
| 288 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 289 | { |
|---|
| 290 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 291 | |
|---|
| 292 | if (fp == NULL) { |
|---|
| 293 | websWrite(wp, "unknown"); |
|---|
| 294 | return; |
|---|
| 295 | } |
|---|
| 296 | int cnt = 0; |
|---|
| 297 | int b = 0; |
|---|
| 298 | |
|---|
| 299 | while (b != EOF) { |
|---|
| 300 | b = getc(fp); |
|---|
| 301 | if (b == ':') |
|---|
| 302 | cnt++; |
|---|
| 303 | |
|---|
| 304 | if (cnt == 4) { |
|---|
| 305 | getc(fp); |
|---|
| 306 | char cpuclk[4]; |
|---|
| 307 | |
|---|
| 308 | cpuclk[0] = getc(fp); |
|---|
| 309 | cpuclk[1] = getc(fp); |
|---|
| 310 | cpuclk[2] = getc(fp); |
|---|
| 311 | cpuclk[3] = 0; |
|---|
| 312 | websWrite(wp, cpuclk); |
|---|
| 313 | fclose(fp); |
|---|
| 314 | return; |
|---|
| 315 | } |
|---|
| 316 | } |
|---|
| 317 | |
|---|
| 318 | fclose(fp); |
|---|
| 319 | websWrite(wp, "unknown"); |
|---|
| 320 | return; |
|---|
| 321 | } |
|---|
| 322 | |
|---|
| 323 | #elif HAVE_STORM |
|---|
| 324 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 325 | { |
|---|
| 326 | websWrite(wp, "300"); |
|---|
| 327 | return; |
|---|
| 328 | } |
|---|
| 329 | #elif HAVE_RT3052 |
|---|
| 330 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 331 | { |
|---|
| 332 | websWrite(wp, "384"); |
|---|
| 333 | return; |
|---|
| 334 | } |
|---|
| 335 | #elif HAVE_RT2880 |
|---|
| 336 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 337 | { |
|---|
| 338 | websWrite(wp, "266"); |
|---|
| 339 | return; |
|---|
| 340 | } |
|---|
| 341 | #elif HAVE_XSCALE |
|---|
| 342 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 343 | { |
|---|
| 344 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 345 | |
|---|
| 346 | if (fp == NULL) { |
|---|
| 347 | websWrite(wp, "unknown"); |
|---|
| 348 | return; |
|---|
| 349 | } |
|---|
| 350 | int cnt = 0; |
|---|
| 351 | int b = 0; |
|---|
| 352 | |
|---|
| 353 | while (b != EOF) { |
|---|
| 354 | b = getc(fp); |
|---|
| 355 | if (b == ':') |
|---|
| 356 | cnt++; |
|---|
| 357 | if (cnt == 2) { |
|---|
| 358 | getc(fp); |
|---|
| 359 | char cpuclk[4]; |
|---|
| 360 | |
|---|
| 361 | cpuclk[0] = getc(fp); |
|---|
| 362 | cpuclk[1] = getc(fp); |
|---|
| 363 | cpuclk[2] = getc(fp); |
|---|
| 364 | cpuclk[3] = 0; |
|---|
| 365 | websWrite(wp, cpuclk); |
|---|
| 366 | fclose(fp); |
|---|
| 367 | return; |
|---|
| 368 | } |
|---|
| 369 | } |
|---|
| 370 | |
|---|
| 371 | fclose(fp); |
|---|
| 372 | websWrite(wp, "unknown"); |
|---|
| 373 | return; |
|---|
| 374 | } |
|---|
| 375 | #elif HAVE_X86 |
|---|
| 376 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 377 | { |
|---|
| 378 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 379 | |
|---|
| 380 | if (fp == NULL) { |
|---|
| 381 | websWrite(wp, "unknown"); |
|---|
| 382 | return; |
|---|
| 383 | } |
|---|
| 384 | int cnt = 0; |
|---|
| 385 | int b = 0; |
|---|
| 386 | |
|---|
| 387 | while (b != EOF) { |
|---|
| 388 | b = getc(fp); |
|---|
| 389 | if (b == ':') |
|---|
| 390 | cnt++; |
|---|
| 391 | if (cnt == 7) { |
|---|
| 392 | getc(fp); |
|---|
| 393 | char cpuclk[32]; |
|---|
| 394 | int i = 0; |
|---|
| 395 | |
|---|
| 396 | b = getc(fp); |
|---|
| 397 | while (b != 0xa && b != 0xd && b != 0x20) { |
|---|
| 398 | cpuclk[i++] = b; |
|---|
| 399 | b = getc(fp); |
|---|
| 400 | } |
|---|
| 401 | cpuclk[i++] = 0; |
|---|
| 402 | websWrite(wp, cpuclk); |
|---|
| 403 | fclose(fp); |
|---|
| 404 | return; |
|---|
| 405 | } |
|---|
| 406 | } |
|---|
| 407 | |
|---|
| 408 | fclose(fp); |
|---|
| 409 | websWrite(wp, "unknown"); |
|---|
| 410 | return; |
|---|
| 411 | } |
|---|
| 412 | #elif HAVE_MAGICBOX |
|---|
| 413 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 414 | { |
|---|
| 415 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 416 | |
|---|
| 417 | if (fp == NULL) { |
|---|
| 418 | websWrite(wp, "unknown"); |
|---|
| 419 | return; |
|---|
| 420 | } |
|---|
| 421 | int cnt = 0; |
|---|
| 422 | int b = 0; |
|---|
| 423 | |
|---|
| 424 | while (b != EOF) { |
|---|
| 425 | b = getc(fp); |
|---|
| 426 | if (b == ':') |
|---|
| 427 | cnt++; |
|---|
| 428 | if (cnt == 3) { |
|---|
| 429 | getc(fp); |
|---|
| 430 | char cpuclk[4]; |
|---|
| 431 | |
|---|
| 432 | cpuclk[0] = getc(fp); |
|---|
| 433 | cpuclk[1] = getc(fp); |
|---|
| 434 | cpuclk[2] = getc(fp); |
|---|
| 435 | cpuclk[3] = 0; |
|---|
| 436 | websWrite(wp, cpuclk); |
|---|
| 437 | fclose(fp); |
|---|
| 438 | return; |
|---|
| 439 | } |
|---|
| 440 | } |
|---|
| 441 | |
|---|
| 442 | fclose(fp); |
|---|
| 443 | websWrite(wp, "unknown"); |
|---|
| 444 | return; |
|---|
| 445 | } |
|---|
| 446 | #elif defined(HAVE_FONERA) || defined(HAVE_SOLO51) || defined(HAVE_ADM5120) || defined(HAVE_MERAKI) || defined(HAVE_LS2) || defined(HAVE_LS5) || defined(HAVE_WHRAG108) || defined(HAVE_TW6600) || defined(HAVE_CA8) |
|---|
| 447 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 448 | { |
|---|
| 449 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 450 | |
|---|
| 451 | if (fp == NULL) { |
|---|
| 452 | websWrite(wp, "unknown"); |
|---|
| 453 | return; |
|---|
| 454 | } |
|---|
| 455 | int cnt = 0; |
|---|
| 456 | int b = 0; |
|---|
| 457 | |
|---|
| 458 | while (b != EOF) { |
|---|
| 459 | b = getc(fp); |
|---|
| 460 | if (b == ':') |
|---|
| 461 | cnt++; |
|---|
| 462 | if (cnt == 4) { |
|---|
| 463 | getc(fp); |
|---|
| 464 | char cpuclk[4]; |
|---|
| 465 | |
|---|
| 466 | cpuclk[0] = getc(fp); |
|---|
| 467 | cpuclk[1] = getc(fp); |
|---|
| 468 | cpuclk[2] = getc(fp); |
|---|
| 469 | cpuclk[3] = 0; |
|---|
| 470 | websWrite(wp, cpuclk); |
|---|
| 471 | fclose(fp); |
|---|
| 472 | return; |
|---|
| 473 | } |
|---|
| 474 | } |
|---|
| 475 | |
|---|
| 476 | fclose(fp); |
|---|
| 477 | websWrite(wp, "unknown"); |
|---|
| 478 | return; |
|---|
| 479 | } |
|---|
| 480 | #elif defined(HAVE_PB42) || defined(HAVE_LSX) || defined(HAVE_DANUBE) |
|---|
| 481 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 482 | { |
|---|
| 483 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 484 | |
|---|
| 485 | if (fp == NULL) { |
|---|
| 486 | websWrite(wp, "unknown"); |
|---|
| 487 | return; |
|---|
| 488 | } |
|---|
| 489 | int cnt = 0; |
|---|
| 490 | int b = 0; |
|---|
| 491 | |
|---|
| 492 | while (b != EOF) { |
|---|
| 493 | b = getc(fp); |
|---|
| 494 | if (b == ':') |
|---|
| 495 | cnt++; |
|---|
| 496 | if (cnt == 5) { |
|---|
| 497 | getc(fp); |
|---|
| 498 | char cpuclk[4]; |
|---|
| 499 | |
|---|
| 500 | cpuclk[0] = getc(fp); |
|---|
| 501 | cpuclk[1] = getc(fp); |
|---|
| 502 | cpuclk[2] = getc(fp); |
|---|
| 503 | cpuclk[3] = 0; |
|---|
| 504 | websWrite(wp, cpuclk); |
|---|
| 505 | fclose(fp); |
|---|
| 506 | return; |
|---|
| 507 | } |
|---|
| 508 | } |
|---|
| 509 | |
|---|
| 510 | fclose(fp); |
|---|
| 511 | websWrite(wp, "unknown"); |
|---|
| 512 | return; |
|---|
| 513 | } |
|---|
| 514 | |
|---|
| 515 | #else |
|---|
| 516 | |
|---|
| 517 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 518 | { |
|---|
| 519 | char *clk = nvram_get("clkfreq"); |
|---|
| 520 | |
|---|
| 521 | if (clk == NULL) { |
|---|
| 522 | if (getcpurev() == 0) //BCM4710 |
|---|
| 523 | websWrite(wp, "125"); |
|---|
| 524 | else if (getcpurev() == 29) //BCM5354 |
|---|
| 525 | websWrite(wp, "240"); |
|---|
| 526 | else |
|---|
| 527 | websWrite(wp, "unknown"); |
|---|
| 528 | return; |
|---|
| 529 | } |
|---|
| 530 | char buf[64]; |
|---|
| 531 | |
|---|
| 532 | strcpy(buf, clk); |
|---|
| 533 | int i = 0; |
|---|
| 534 | |
|---|
| 535 | while (buf[i++] != 0) { |
|---|
| 536 | if (buf[i] == ',') |
|---|
| 537 | buf[i] = 0; |
|---|
| 538 | } |
|---|
| 539 | websWrite(wp, buf); |
|---|
| 540 | return; |
|---|
| 541 | } |
|---|
| 542 | #endif |
|---|
| 543 | |
|---|
| 544 | void ej_show_cpuinfo(webs_t wp, int argc, char_t ** argv) |
|---|
| 545 | { |
|---|
| 546 | FILE *fcpu = fopen("/proc/cpuinfo", "r"); |
|---|
| 547 | |
|---|
| 548 | if (fcpu == NULL) { |
|---|
| 549 | websWrite(wp, "Not Detected!\n"); |
|---|
| 550 | return; |
|---|
| 551 | } |
|---|
| 552 | char buf[256]; |
|---|
| 553 | int i; |
|---|
| 554 | |
|---|
| 555 | #ifdef HAVE_MAGICBOX |
|---|
| 556 | int cnt = 0; |
|---|
| 557 | #endif |
|---|
| 558 | #ifdef HAVE_X86 |
|---|
| 559 | int cnt = 0; |
|---|
| 560 | #endif |
|---|
| 561 | for (i = 0; i < 256; i++) { |
|---|
| 562 | int c = getc(fcpu); |
|---|
| 563 | |
|---|
| 564 | if (c == EOF) { |
|---|
| 565 | websWrite(wp, "Not Detected!\n"); |
|---|
| 566 | fclose(fcpu); |
|---|
| 567 | return; |
|---|
| 568 | } |
|---|
| 569 | if (c == ':') |
|---|
| 570 | #ifdef HAVE_MAGICBOX |
|---|
| 571 | cnt++; |
|---|
| 572 | if (cnt == 2) |
|---|
| 573 | break; |
|---|
| 574 | #elif HAVE_X86 |
|---|
| 575 | cnt++; |
|---|
| 576 | if (cnt == 5) |
|---|
| 577 | break; |
|---|
| 578 | #else |
|---|
| 579 | break; |
|---|
| 580 | #endif |
|---|
| 581 | } |
|---|
| 582 | getc(fcpu); |
|---|
| 583 | for (i = 0; i < 256; i++) { |
|---|
| 584 | int c = getc(fcpu); |
|---|
| 585 | |
|---|
| 586 | if (c == EOF) { |
|---|
| 587 | websWrite(wp, "Not Detected!\n"); |
|---|
| 588 | fclose(fcpu); |
|---|
| 589 | return; |
|---|
| 590 | } |
|---|
| 591 | if (c == 0xa || c == 0xd) |
|---|
| 592 | break; |
|---|
| 593 | buf[i] = c; |
|---|
| 594 | } |
|---|
| 595 | buf[i] = 0; |
|---|
| 596 | websWrite(wp, buf); |
|---|
| 597 | fclose(fcpu); |
|---|
| 598 | return; |
|---|
| 599 | } |
|---|
| 600 | |
|---|
| 601 | #define ASSOCLIST_TMP "/tmp/.wl_assoclist" |
|---|
| 602 | #define RSSI_TMP "/tmp/.rssi" |
|---|
| 603 | #define ASSOCLIST_CMD "wl assoclist" |
|---|
| 604 | #define RSSI_CMD "wl rssi" |
|---|
| 605 | #define NOISE_CMD "wl noise" |
|---|
| 606 | |
|---|
| 607 | void ej_show_wds_subnet(webs_t wp, int argc, char_t ** argv) |
|---|
| 608 | { |
|---|
| 609 | int index = -1; |
|---|
| 610 | char *interface; |
|---|
| 611 | |
|---|
| 612 | #ifdef FASTWEB |
|---|
| 613 | ejArgs(argc, argv, "%d %s", &index, &interface); |
|---|
| 614 | #else |
|---|
| 615 | if (ejArgs(argc, argv, "%d %s", &index, &interface) < 2) { |
|---|
| 616 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 617 | return; |
|---|
| 618 | } |
|---|
| 619 | #endif |
|---|
| 620 | char br1[32]; |
|---|
| 621 | |
|---|
| 622 | sprintf(br1, "%s_br1_enable", interface); |
|---|
| 623 | if (nvram_invmatch(br1, "1")) |
|---|
| 624 | return; |
|---|
| 625 | char buf[16]; |
|---|
| 626 | |
|---|
| 627 | sprintf(buf, "%s_wds%d_enable", interface, index); |
|---|
| 628 | websWrite(wp, |
|---|
| 629 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"2\\\" %s >\" + wds.subnet + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 630 | nvram_selmatch(wp, buf, |
|---|
| 631 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 632 | return; |
|---|
| 633 | } |
|---|
| 634 | |
|---|
| 635 | #ifdef HAVE_SKYTRON |
|---|
| 636 | void ej_active_wireless2(webs_t wp, int argc, char_t ** argv) |
|---|
| 637 | { |
|---|
| 638 | int rssi = 0, noise = 0; |
|---|
| 639 | FILE *fp, *fp2; |
|---|
| 640 | char *mode; |
|---|
| 641 | char mac[30]; |
|---|
| 642 | char list[2][30]; |
|---|
| 643 | char line[80]; |
|---|
| 644 | |
|---|
| 645 | unlink(ASSOCLIST_TMP); |
|---|
| 646 | unlink(RSSI_TMP); |
|---|
| 647 | |
|---|
| 648 | mode = nvram_safe_get("wl_mode"); |
|---|
| 649 | sysprintf("%s > %s", ASSOCLIST_CMD, ASSOCLIST_TMP); |
|---|
| 650 | |
|---|
| 651 | int connected = 0; |
|---|
| 652 | |
|---|
| 653 | if ((fp = fopen(ASSOCLIST_TMP, "r"))) { |
|---|
| 654 | while (fgets(line, sizeof(line), fp) != NULL) { |
|---|
| 655 | if (sscanf(line, "%s %s", list[0], mac) != 2) // assoclist |
|---|
| 656 | // 00:11:22:33:44:55 |
|---|
| 657 | continue; |
|---|
| 658 | |
|---|
| 659 | if (strcmp(list[0], "assoclist")) |
|---|
| 660 | break; |
|---|
| 661 | |
|---|
| 662 | rssi = 0; |
|---|
| 663 | noise = 0; |
|---|
| 664 | // get rssi value |
|---|
| 665 | if (strcmp(mode, "ap")) |
|---|
| 666 | sysprintf("%s > %s", RSSI_CMD, RSSI_TMP); |
|---|
| 667 | else |
|---|
| 668 | sysprintf("%s \"%s\" > %s", RSSI_CMD, mac, |
|---|
| 669 | RSSI_TMP); |
|---|
| 670 | |
|---|
| 671 | // get noise value if not ap mode |
|---|
| 672 | if (strcmp(mode, "ap")) |
|---|
| 673 | sysprintf("%s >> %s", NOISE_CMD, RSSI_TMP); |
|---|
| 674 | |
|---|
| 675 | fp2 = fopen(RSSI_TMP, "r"); |
|---|
| 676 | if (fgets(line, sizeof(line), fp2) != NULL) { |
|---|
| 677 | |
|---|
| 678 | // get rssi |
|---|
| 679 | if (sscanf |
|---|
| 680 | (line, "%s %s %d", list[0], list[1], |
|---|
| 681 | &rssi) != 3) |
|---|
| 682 | continue; |
|---|
| 683 | |
|---|
| 684 | // get noise for client/wet mode |
|---|
| 685 | if (strcmp(mode, "ap") && |
|---|
| 686 | fgets(line, sizeof(line), fp2) != NULL && |
|---|
| 687 | sscanf(line, "%s %s %d", list[0], list[1], |
|---|
| 688 | &noise) != 3) |
|---|
| 689 | continue; |
|---|
| 690 | |
|---|
| 691 | fclose(fp2); |
|---|
| 692 | } |
|---|
| 693 | if (nvram_match("maskmac", "1")) { |
|---|
| 694 | mac[0] = 'x'; |
|---|
| 695 | mac[1] = 'x'; |
|---|
| 696 | mac[3] = 'x'; |
|---|
| 697 | mac[4] = 'x'; |
|---|
| 698 | mac[6] = 'x'; |
|---|
| 699 | mac[7] = 'x'; |
|---|
| 700 | mac[9] = 'x'; |
|---|
| 701 | mac[10] = 'x'; |
|---|
| 702 | } |
|---|
| 703 | if (strcmp(mode, "ap") != 0) { |
|---|
| 704 | connected = 1; |
|---|
| 705 | websWrite(wp, "<tr>\n"); |
|---|
| 706 | websWrite(wp, |
|---|
| 707 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\"><b>Verbindungsstatus</b></font></td>\n"); |
|---|
| 708 | websWrite(wp, |
|---|
| 709 | "<td bgcolor=\"#B2B2B2\"></td>\n"); |
|---|
| 710 | websWrite(wp, |
|---|
| 711 | "<td bgcolor=\"#FFFFFF\"></td>\n"); |
|---|
| 712 | websWrite(wp, |
|---|
| 713 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Verbunden</font></td>\n"); |
|---|
| 714 | websWrite(wp, "</tr>\n"); |
|---|
| 715 | websWrite(wp, "<tr>\n"); |
|---|
| 716 | websWrite(wp, |
|---|
| 717 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Signal</font></td>\n"); |
|---|
| 718 | websWrite(wp, |
|---|
| 719 | "<td bgcolor=\"#B2B2B2\"></td>\n"); |
|---|
| 720 | websWrite(wp, |
|---|
| 721 | "<td bgcolor=\"#FFFFFF\"></td>\n"); |
|---|
| 722 | websWrite(wp, |
|---|
| 723 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">%d dBm</font></td>\n", |
|---|
| 724 | rssi); |
|---|
| 725 | websWrite(wp, "</tr>\n"); |
|---|
| 726 | websWrite(wp, "<tr>\n"); |
|---|
| 727 | websWrite(wp, |
|---|
| 728 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Rauschen</font></td>\n"); |
|---|
| 729 | websWrite(wp, |
|---|
| 730 | "<td bgcolor=\"#B2B2B2\"></td>\n"); |
|---|
| 731 | websWrite(wp, |
|---|
| 732 | "<td bgcolor=\"#FFFFFF\"></td>\n"); |
|---|
| 733 | websWrite(wp, |
|---|
| 734 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">%d dBm</font></td>\n", |
|---|
| 735 | noise); |
|---|
| 736 | websWrite(wp, "</tr>\n"); |
|---|
| 737 | } |
|---|
| 738 | } |
|---|
| 739 | fclose(fp); |
|---|
| 740 | } |
|---|
| 741 | |
|---|
| 742 | unlink(ASSOCLIST_TMP); |
|---|
| 743 | unlink(RSSI_TMP); |
|---|
| 744 | if (!connected) { |
|---|
| 745 | connected = 1; |
|---|
| 746 | websWrite(wp, "<tr>\n"); |
|---|
| 747 | websWrite(wp, |
|---|
| 748 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\"><b>Verbindungsstatus</b></font></td>\n"); |
|---|
| 749 | websWrite(wp, "<td bgcolor=\"#B2B2B2\"></td>\n"); |
|---|
| 750 | websWrite(wp, "<td bgcolor=\"#FFFFFF\"></td>\n"); |
|---|
| 751 | websWrite(wp, |
|---|
| 752 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Nicht Verbunden</font></td>\n"); |
|---|
| 753 | websWrite(wp, "</tr>\n"); |
|---|
| 754 | |
|---|
| 755 | } |
|---|
| 756 | |
|---|
| 757 | return 0; |
|---|
| 758 | } |
|---|
| 759 | #endif |
|---|
| 760 | |
|---|
| 761 | void ej_show_paypal(webs_t wp, int argc, char_t ** argv) |
|---|
| 762 | { |
|---|
| 763 | #ifdef HAVE_DDLAN |
|---|
| 764 | websWrite(wp, |
|---|
| 765 | "<a href=\"mailto:support@mcdd.de\">support@mcdd.de</a><br />"); |
|---|
| 766 | #endif |
|---|
| 767 | #ifdef HAVE_CORENET |
|---|
| 768 | websWrite(wp, |
|---|
| 769 | "<a href=\"http://www.corenetsolutions.com\">http://www.corenetsolutions.com</a><br />"); |
|---|
| 770 | #endif |
|---|
| 771 | |
|---|
| 772 | #ifndef CONFIG_BRANDING |
|---|
| 773 | #ifndef HAVE_REGISTER |
|---|
| 774 | websWrite(wp, "<a href=\"http://www.dd-wrt.com/\">DD-WRT</a><br />"); |
|---|
| 775 | websWrite(wp, |
|---|
| 776 | "<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\" target=\"_blank\">"); |
|---|
| 777 | websWrite(wp, |
|---|
| 778 | "<input type=\"hidden\" name=\"cmd\" value=\"_xclick\" />"); |
|---|
| 779 | websWrite(wp, |
|---|
| 780 | "<input type=\"hidden\" name=\"business\" value=\"paypal@dd-wrt.com\" />"); |
|---|
| 781 | websWrite(wp, |
|---|
| 782 | "<input type=\"hidden\" name=\"item_name\" value=\"DD-WRT Development Support\" />"); |
|---|
| 783 | websWrite(wp, "<input type=\"hidden\" name=\"no_note\" value=\"1\" />"); |
|---|
| 784 | websWrite(wp, |
|---|
| 785 | "<input type=\"hidden\" name=\"currency_code\" value=\"EUR\" />"); |
|---|
| 786 | websWrite(wp, "<input type=\"hidden\" name=\"lc\" value=\"en\" />"); |
|---|
| 787 | websWrite(wp, "<input type=\"hidden\" name=\"tax\" value=\"0\" />"); |
|---|
| 788 | websWrite(wp, |
|---|
| 789 | "<input type=\"image\" src=\"images/paypal.gif\" name=\"submit\" />"); |
|---|
| 790 | websWrite(wp, "</form>"); |
|---|
| 791 | websWrite(wp, |
|---|
| 792 | "<br /><script type=\"text/javascript\">Capture(donate.mb)</script><br />\n"); |
|---|
| 793 | websWrite(wp, |
|---|
| 794 | "<a href=\"https://www.moneybookers.com/app/send.pl\" target=\"_blank\">\n"); |
|---|
| 795 | // #ifdef HAVE_MICRO |
|---|
| 796 | // websWrite (wp, |
|---|
| 797 | // "<img style=\"border-width: 1px; border-color: #8B8583;\" |
|---|
| 798 | // src=\"http://www.moneybookers.com/images/banners/88_en_interpayments.gif\" |
|---|
| 799 | // alt=\"donate thru moneybookers\" />\n"); |
|---|
| 800 | // #else |
|---|
| 801 | websWrite(wp, |
|---|
| 802 | "<img style=\"border-width: 1px; border-color: #8B8583;\" src=\"images/88_en_interpayments.png\" alt=\"donate thru interpayments\" />\n"); |
|---|
| 803 | // #endif |
|---|
| 804 | websWrite(wp, "</a>\n"); |
|---|
| 805 | #endif |
|---|
| 806 | #endif |
|---|
| 807 | return; |
|---|
| 808 | } |
|---|
| 809 | |
|---|
| 810 | #ifdef HAVE_RADLOCAL |
|---|
| 811 | |
|---|
| 812 | void ej_show_iradius_check(webs_t wp, int argc, char_t ** argv) |
|---|
| 813 | { |
|---|
| 814 | char *sln = nvram_safe_get("iradius_count"); |
|---|
| 815 | |
|---|
| 816 | if (sln == NULL || strlen(sln) == 0) |
|---|
| 817 | return; |
|---|
| 818 | int leasenum = atoi(sln); |
|---|
| 819 | int i; |
|---|
| 820 | |
|---|
| 821 | for (i = 0; i < leasenum; i++) { |
|---|
| 822 | websWrite(wp, "if(F._iradius%d_active)\n", i); |
|---|
| 823 | websWrite(wp, "if(F._iradius%d_active.checked == true)\n", i); |
|---|
| 824 | websWrite(wp, "F.iradius%d_active.value=1\n", i); |
|---|
| 825 | websWrite(wp, "else\n"); |
|---|
| 826 | websWrite(wp, "F.iradius%d_active.value=0\n", i); |
|---|
| 827 | |
|---|
| 828 | websWrite(wp, "if(F._iradius%d_delete)\n", i); |
|---|
| 829 | websWrite(wp, "if(F._iradius%d_delete.checked == true)\n", i); |
|---|
| 830 | websWrite(wp, "F.iradius%d_delete.value=1\n", i); |
|---|
| 831 | websWrite(wp, "else\n"); |
|---|
| 832 | websWrite(wp, "F.iradius%d_delete.value=0\n", i); |
|---|
| 833 | } |
|---|
| 834 | |
|---|
| 835 | } |
|---|
| 836 | |
|---|
| 837 | void ej_show_iradius(webs_t wp, int argc, char_t ** argv) |
|---|
| 838 | { |
|---|
| 839 | char *sln = nvram_safe_get("iradius_count"); |
|---|
| 840 | |
|---|
| 841 | if (sln == NULL || strlen(sln) == 0) |
|---|
| 842 | return; |
|---|
| 843 | int leasenum = atoi(sln); |
|---|
| 844 | |
|---|
| 845 | if (leasenum == 0) |
|---|
| 846 | return; |
|---|
| 847 | int i; |
|---|
| 848 | char username[32]; |
|---|
| 849 | char *o, *userlist; |
|---|
| 850 | |
|---|
| 851 | cprintf("get collection\n"); |
|---|
| 852 | char *u = nvram_get_collection("iradius"); |
|---|
| 853 | |
|---|
| 854 | cprintf("collection result %s", u); |
|---|
| 855 | if (u != NULL) { |
|---|
| 856 | userlist = (char *)malloc(strlen(u) + 1); |
|---|
| 857 | strcpy(userlist, u); |
|---|
| 858 | free(u); |
|---|
| 859 | o = userlist; |
|---|
| 860 | } else { |
|---|
| 861 | userlist = NULL; |
|---|
| 862 | o = NULL; |
|---|
| 863 | } |
|---|
| 864 | cprintf("display = chain\n"); |
|---|
| 865 | struct timeval now; |
|---|
| 866 | |
|---|
| 867 | gettimeofday(&now, NULL); |
|---|
| 868 | for (i = 0; i < leasenum; i++) { |
|---|
| 869 | snprintf(username, 31, "iradius%d_name", i); |
|---|
| 870 | char *sep = NULL; |
|---|
| 871 | |
|---|
| 872 | if (userlist) |
|---|
| 873 | sep = strsep(&userlist, " "); |
|---|
| 874 | websWrite(wp, "<tr><td>\n"); |
|---|
| 875 | websWrite(wp, "<input name=\"%s\" type=\"hidden\" />", |
|---|
| 876 | username); |
|---|
| 877 | websWrite(wp, |
|---|
| 878 | "<input name=\"%s\" value=\"%s\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 879 | username, sep != NULL ? sep : ""); |
|---|
| 880 | websWrite(wp, "</td>\n"); |
|---|
| 881 | if (userlist) |
|---|
| 882 | sep = strsep(&userlist, " "); |
|---|
| 883 | |
|---|
| 884 | char active[32]; |
|---|
| 885 | |
|---|
| 886 | snprintf(active, 31, "iradius%d_active", i); |
|---|
| 887 | |
|---|
| 888 | websWrite(wp, "<td>\n"); |
|---|
| 889 | websWrite(wp, "<input name=\"%s\" type=\"hidden\" />", active); |
|---|
| 890 | websWrite(wp, |
|---|
| 891 | "<input type=\"checkbox\" value=\"%s\" name=\"_%s\" %s />\n", |
|---|
| 892 | sep, active, sep != NULL ? strcmp(sep, |
|---|
| 893 | "1") == |
|---|
| 894 | 0 ? "checked=\"checked\"" : "" : ""); |
|---|
| 895 | websWrite(wp, "</td>\n"); |
|---|
| 896 | websWrite(wp, "<td>\n"); |
|---|
| 897 | if (userlist) |
|---|
| 898 | sep = strsep(&userlist, " "); |
|---|
| 899 | long t = atol(sep); |
|---|
| 900 | |
|---|
| 901 | if (t != -1) { |
|---|
| 902 | t -= now.tv_sec; |
|---|
| 903 | t /= 60; |
|---|
| 904 | } |
|---|
| 905 | |
|---|
| 906 | snprintf(active, 31, "iradius%d_lease", i); |
|---|
| 907 | char st[32]; |
|---|
| 908 | |
|---|
| 909 | if (t >= 0) |
|---|
| 910 | sprintf(st, "%d", t); |
|---|
| 911 | else |
|---|
| 912 | sprintf(st, "over"); |
|---|
| 913 | websWrite(wp, "<input type=\"num\" name=\"%s\" value='%s' />\n", |
|---|
| 914 | active, st); |
|---|
| 915 | websWrite(wp, "</td>\n"); |
|---|
| 916 | |
|---|
| 917 | websWrite(wp, "<td>\n"); |
|---|
| 918 | snprintf(active, 31, "iradius%d_delete", i); |
|---|
| 919 | websWrite(wp, "<input name=\"%s\" type=\"hidden\" />", active); |
|---|
| 920 | websWrite(wp, "<input type=\"checkbox\" name=\"_%s\"/>\n", |
|---|
| 921 | active); |
|---|
| 922 | websWrite(wp, "</td></tr>\n"); |
|---|
| 923 | } |
|---|
| 924 | if (o != NULL) |
|---|
| 925 | free(o); |
|---|
| 926 | return; |
|---|
| 927 | } |
|---|
| 928 | |
|---|
| 929 | #endif |
|---|
| 930 | |
|---|
| 931 | #ifdef HAVE_CHILLILOCAL |
|---|
| 932 | |
|---|
| 933 | void ej_show_userlist(webs_t wp, int argc, char_t ** argv) |
|---|
| 934 | { |
|---|
| 935 | char *sln = nvram_safe_get("fon_usernames"); |
|---|
| 936 | |
|---|
| 937 | if (sln == NULL || strlen(sln) == 0) |
|---|
| 938 | return; |
|---|
| 939 | int leasenum = atoi(sln); |
|---|
| 940 | |
|---|
| 941 | if (leasenum == 0) |
|---|
| 942 | return; |
|---|
| 943 | int i; |
|---|
| 944 | char username[32]; |
|---|
| 945 | char password[32]; |
|---|
| 946 | char *u = nvram_safe_get("fon_userlist"); |
|---|
| 947 | char *userlist = (char *)malloc(strlen(u) + 1); |
|---|
| 948 | |
|---|
| 949 | strcpy(userlist, u); |
|---|
| 950 | char *o = userlist; |
|---|
| 951 | |
|---|
| 952 | for (i = 0; i < leasenum; i++) { |
|---|
| 953 | snprintf(username, 31, "fon_user%d_name", i); |
|---|
| 954 | char *sep = strsep(&userlist, "="); |
|---|
| 955 | |
|---|
| 956 | websWrite(wp, "<tr><td>\n"); |
|---|
| 957 | websWrite(wp, |
|---|
| 958 | "<input name=\"%s\" value=\"%s\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 959 | username, sep != NULL ? sep : ""); |
|---|
| 960 | websWrite(wp, "</td>\n"); |
|---|
| 961 | sep = strsep(&userlist, " "); |
|---|
| 962 | snprintf(password, 31, "fon_user%d_password", i); |
|---|
| 963 | websWrite(wp, "<td>\n"); |
|---|
| 964 | websWrite(wp, |
|---|
| 965 | "<input type=\"password\" name=\"%s\" value=\"blahblahblah\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 966 | password); |
|---|
| 967 | websWrite(wp, "</td></tr>\n"); |
|---|
| 968 | } |
|---|
| 969 | free(o); |
|---|
| 970 | return; |
|---|
| 971 | } |
|---|
| 972 | |
|---|
| 973 | #endif |
|---|
| 974 | |
|---|
| 975 | void ej_show_staticleases(webs_t wp, int argc, char_t ** argv) |
|---|
| 976 | { |
|---|
| 977 | int i; |
|---|
| 978 | |
|---|
| 979 | // cprintf("get static leasenum"); |
|---|
| 980 | |
|---|
| 981 | char *sln = nvram_safe_get("static_leasenum"); |
|---|
| 982 | |
|---|
| 983 | // cprintf("check null"); |
|---|
| 984 | if (sln == NULL || strlen(sln) == 0) |
|---|
| 985 | return; |
|---|
| 986 | // cprintf("atoi"); |
|---|
| 987 | |
|---|
| 988 | int leasenum = atoi(sln); |
|---|
| 989 | |
|---|
| 990 | // cprintf("leasenum==0"); |
|---|
| 991 | if (leasenum == 0) |
|---|
| 992 | return; |
|---|
| 993 | // cprintf("get leases"); |
|---|
| 994 | char *nvleases = nvram_safe_get("static_leases"); |
|---|
| 995 | char *leases = (char *)malloc(strlen(nvleases) + 1); |
|---|
| 996 | char *originalpointer = leases; // strsep destroys the pointer by |
|---|
| 997 | |
|---|
| 998 | // moving it |
|---|
| 999 | strcpy(leases, nvleases); |
|---|
| 1000 | for (i = 0; i < leasenum; i++) { |
|---|
| 1001 | char *sep = strsep(&leases, "="); |
|---|
| 1002 | |
|---|
| 1003 | websWrite(wp, |
|---|
| 1004 | "<tr><td><input name=\"lease%d_hwaddr\" value=\"%s\" size=\"18\" maxlength=\"18\" onblur=\"valid_name(this,share.mac,SPACE_NO)\" /></td>", |
|---|
| 1005 | i, sep != NULL ? sep : ""); |
|---|
| 1006 | sep = strsep(&leases, "="); |
|---|
| 1007 | websWrite(wp, |
|---|
| 1008 | "<td><input name=\"lease%d_hostname\" value=\"%s\" size=\"24\" maxlength=\"24\" onblur=\"valid_name(this,share.hostname,SPACE_NO)\" /></td>", |
|---|
| 1009 | i, sep != NULL ? sep : ""); |
|---|
| 1010 | sep = strsep(&leases, " "); |
|---|
| 1011 | websWrite(wp, |
|---|
| 1012 | "<td><input name=\"lease%d_ip\" value=\"%s\" size=\"15\" maxlength=\"15\" class=\"num\" onblur=\"valid_name(this,share.ip,SPACE_NO)\" /></td></tr>\n", |
|---|
| 1013 | i, sep != NULL ? sep : ""); |
|---|
| 1014 | } |
|---|
| 1015 | free(originalpointer); |
|---|
| 1016 | return; |
|---|
| 1017 | } |
|---|
| 1018 | |
|---|
| 1019 | void ej_show_control(webs_t wp, int argc, char_t ** argv) |
|---|
| 1020 | { |
|---|
| 1021 | #ifdef CONFIG_BRANDING |
|---|
| 1022 | websWrite(wp, "Control Panel"); |
|---|
| 1023 | #else |
|---|
| 1024 | websWrite(wp, "DD-WRT Control Panel"); |
|---|
| 1025 | #endif |
|---|
| 1026 | return; |
|---|
| 1027 | } |
|---|
| 1028 | |
|---|
| 1029 | #ifndef HAVE_AQOS |
|---|
| 1030 | void ej_show_default_level(webs_t wp, int argc, char_t ** argv) |
|---|
| 1031 | { |
|---|
| 1032 | return; |
|---|
| 1033 | } |
|---|
| 1034 | |
|---|
| 1035 | #else |
|---|
| 1036 | void ej_show_default_level(webs_t wp, int argc, char_t ** argv) |
|---|
| 1037 | { |
|---|
| 1038 | websWrite(wp, "<fieldset>\n"); |
|---|
| 1039 | websWrite(wp, |
|---|
| 1040 | "<legend><script type=\"text/javascript\">Capture(qos.legend6)</script></legend>\n"); |
|---|
| 1041 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1042 | websWrite(wp, |
|---|
| 1043 | "<div class=\"label\"><script type=\"text/javascript\">Capture(qos.bandwidth)</script> Up</div>\n"); |
|---|
| 1044 | websWrite(wp, |
|---|
| 1045 | "<input type=\"num\" name=\"default_uplevel\" size=\"6\" value=\"%s\" /> Down\n", |
|---|
| 1046 | nvram_safe_get("default_uplevel")); |
|---|
| 1047 | websWrite(wp, |
|---|
| 1048 | "<input type=\"num\" name=\"default_downlevel\" size=\"6\" value=\"%s\" />\n", |
|---|
| 1049 | nvram_safe_get("default_downlevel")); |
|---|
| 1050 | websWrite(wp, "</div>\n"); |
|---|
| 1051 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 1052 | return; |
|---|
| 1053 | } |
|---|
| 1054 | #endif |
|---|
| 1055 | |
|---|
| 1056 | #ifdef HAVE_MADWIFI |
|---|
| 1057 | struct wifi_channels { |
|---|
| 1058 | int channel; |
|---|
| 1059 | int freq; |
|---|
| 1060 | int noise; |
|---|
| 1061 | }; |
|---|
| 1062 | extern struct wifi_channels *list_channels(char *devnr); |
|---|
| 1063 | extern struct wifi_channels *list_channels_11n(char *devnr); |
|---|
| 1064 | |
|---|
| 1065 | // extern int getchannelcount (void); |
|---|
| 1066 | extern int getdevicecount(void); |
|---|
| 1067 | #endif |
|---|
| 1068 | |
|---|
| 1069 | static char *selmatch(char *var, char *is, char *ret) |
|---|
| 1070 | { |
|---|
| 1071 | if (nvram_match(var, is)) |
|---|
| 1072 | return ret; |
|---|
| 1073 | return ""; |
|---|
| 1074 | } |
|---|
| 1075 | |
|---|
| 1076 | static void |
|---|
| 1077 | show_security_prefix(webs_t wp, int argc, char_t ** argv, char *prefix, |
|---|
| 1078 | int primary) |
|---|
| 1079 | { |
|---|
| 1080 | static char var[80]; |
|---|
| 1081 | static char sta[80]; |
|---|
| 1082 | |
|---|
| 1083 | // char p2[80]; |
|---|
| 1084 | cprintf("show security prefix\n"); |
|---|
| 1085 | sprintf(var, "%s_security_mode", prefix); |
|---|
| 1086 | // strcpy(p2,prefix); |
|---|
| 1087 | // rep(p2,'X','.'); |
|---|
| 1088 | // websWrite (wp, "<input type=\"hidden\" |
|---|
| 1089 | // name=\"%s_security_mode\"/>\n",p2); |
|---|
| 1090 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1091 | websWrite(wp, |
|---|
| 1092 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.secmode)</script></div>\n"); |
|---|
| 1093 | websWrite(wp, |
|---|
| 1094 | "<select name=\"%s_security_mode\" onchange=\"SelMode('%s_security_mode',this.form.%s_security_mode.selectedIndex,this.form)\">\n", |
|---|
| 1095 | prefix, prefix, prefix); |
|---|
| 1096 | websWrite(wp, |
|---|
| 1097 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"disabled\\\" %s >\" + share.disabled + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 1098 | selmatch(var, "disabled", "selected=\\\"selected\\\"")); |
|---|
| 1099 | websWrite(wp, "<option value=\"psk\" %s>WPA Personal</option>\n", |
|---|
| 1100 | selmatch(var, "psk", "selected=\"selected\"")); |
|---|
| 1101 | sprintf(sta, "%s_mode", prefix); |
|---|
| 1102 | if (!primary || nvram_match(sta, "ap") || nvram_match(sta, "wdsap")) { |
|---|
| 1103 | websWrite(wp, |
|---|
| 1104 | "<option value=\"wpa\" %s>WPA Enterprise</option>\n", |
|---|
| 1105 | selmatch(var, "wpa", "selected=\"selected\"")); |
|---|
| 1106 | } |
|---|
| 1107 | websWrite(wp, "<option value=\"psk2\" %s>WPA2 Personal</option>\n", |
|---|
| 1108 | selmatch(var, "psk2", "selected=\"selected\"")); |
|---|
| 1109 | if (!primary || nvram_match(sta, "ap") || nvram_match(sta, "wdsap")) { |
|---|
| 1110 | websWrite(wp, |
|---|
| 1111 | "<option value=\"wpa2\" %s>WPA2 Enterprise</option>\n", |
|---|
| 1112 | selmatch(var, "wpa2", "selected=\"selected\"")); |
|---|
| 1113 | } |
|---|
| 1114 | #ifdef HAVE_RT2880 |
|---|
| 1115 | if (!primary || nvram_match(sta, "ap")) |
|---|
| 1116 | #endif |
|---|
| 1117 | websWrite(wp, |
|---|
| 1118 | "<option value=\"psk psk2\" %s>WPA2 Personal Mixed</option>\n", |
|---|
| 1119 | selmatch(var, "psk psk2", "selected=\"selected\"")); |
|---|
| 1120 | |
|---|
| 1121 | if (!primary || nvram_match(sta, "ap") || nvram_match(sta, "wdsap")) { |
|---|
| 1122 | websWrite(wp, |
|---|
| 1123 | "<option value=\"wpa wpa2\" %s>WPA2 Enterprise Mixed</option>\n", |
|---|
| 1124 | selmatch(var, "wpa wpa2", "selected=\"selected\"")); |
|---|
| 1125 | |
|---|
| 1126 | websWrite(wp, "<option value=\"radius\" %s>RADIUS</option>\n", |
|---|
| 1127 | selmatch(var, "radius", "selected=\"selected\"")); |
|---|
| 1128 | } |
|---|
| 1129 | |
|---|
| 1130 | websWrite(wp, "<option value=\"wep\" %s>WEP</option>\n", |
|---|
| 1131 | selmatch(var, "wep", "selected=\"selected\"")); |
|---|
| 1132 | #ifdef HAVE_WPA_SUPPLICANT |
|---|
| 1133 | #ifndef HAVE_MICRO |
|---|
| 1134 | #ifndef HAVE_RT2880 |
|---|
| 1135 | if (!primary || nvram_match(sta, "sta") || nvram_match(sta, "wdssta") |
|---|
| 1136 | || nvram_match(sta, "apsta") || nvram_match(sta, "wet")) { |
|---|
| 1137 | websWrite(wp, "<option value=\"8021X\" %s>802.1x</option>\n", |
|---|
| 1138 | selmatch(var, "8021X", "selected=\"selected\"")); |
|---|
| 1139 | } |
|---|
| 1140 | #else |
|---|
| 1141 | if (nvram_match(sta, "sta") || nvram_match(sta, "wet")) { |
|---|
| 1142 | websWrite(wp, "<option value=\"8021X\" %s>802.1x</option>\n", |
|---|
| 1143 | selmatch(var, "8021X", "selected=\"selected\"")); |
|---|
| 1144 | } |
|---|
| 1145 | #endif |
|---|
| 1146 | #endif |
|---|
| 1147 | #endif |
|---|
| 1148 | |
|---|
| 1149 | websWrite(wp, "</select></div>\n"); |
|---|
| 1150 | rep(prefix, 'X', '.'); |
|---|
| 1151 | cprintf("ej show wpa\n"); |
|---|
| 1152 | ej_show_wpa_setting(wp, argc, argv, prefix); |
|---|
| 1153 | |
|---|
| 1154 | } |
|---|
| 1155 | |
|---|
| 1156 | static void |
|---|
| 1157 | ej_show_security_single(webs_t wp, int argc, char_t ** argv, char *prefix) |
|---|
| 1158 | { |
|---|
| 1159 | char *next; |
|---|
| 1160 | char var[80]; |
|---|
| 1161 | char ssid[80]; |
|---|
| 1162 | char mac[16]; |
|---|
| 1163 | |
|---|
| 1164 | sprintf(mac, "%s_hwaddr", prefix); |
|---|
| 1165 | char *vifs = nvram_nget("%s_vifs", prefix); |
|---|
| 1166 | |
|---|
| 1167 | if (vifs == NULL) |
|---|
| 1168 | return; |
|---|
| 1169 | sprintf(ssid, "%s_ssid", prefix); |
|---|
| 1170 | websWrite(wp, |
|---|
| 1171 | "<h2><script type=\"text/javascript\">Capture(wpa.h2)</script> %s</h2>\n", |
|---|
| 1172 | prefix); |
|---|
| 1173 | websWrite(wp, "<fieldset>\n"); |
|---|
| 1174 | // cprintf("getting %s %s\n",ssid,nvram_safe_get(ssid)); |
|---|
| 1175 | websWrite(wp, |
|---|
| 1176 | "<legend><script type=\"text/javascript\">Capture(share.pintrface)</script> %s SSID [", |
|---|
| 1177 | IFMAP(prefix)); |
|---|
| 1178 | tf_webWriteESCNV(wp, ssid); // fix for broken html page if ssid |
|---|
| 1179 | // contains html tag |
|---|
| 1180 | websWrite(wp, "] HWAddr [%s]</legend>\n", nvram_safe_get(mac)); |
|---|
| 1181 | show_security_prefix(wp, argc, argv, prefix, 1); |
|---|
| 1182 | websWrite(wp, "</fieldset>\n<br />\n"); |
|---|
| 1183 | foreach(var, vifs, next) { |
|---|
| 1184 | sprintf(ssid, "%s_ssid", var); |
|---|
| 1185 | websWrite(wp, "<fieldset>\n"); |
|---|
| 1186 | // cprintf("getting %s %s\n", ssid,nvram_safe_get(ssid)); |
|---|
| 1187 | websWrite(wp, |
|---|
| 1188 | "<legend><script type=\"text/javascript\">Capture(share.vintrface)</script> %s SSID [", |
|---|
| 1189 | IFMAP(var)); |
|---|
| 1190 | tf_webWriteESCNV(wp, ssid); // fix for broken html page if ssid |
|---|
| 1191 | // contains html tag |
|---|
| 1192 | websWrite(wp, "]</legend>\n"); |
|---|
| 1193 | rep(var, '.', 'X'); |
|---|
| 1194 | show_security_prefix(wp, argc, argv, var, 0); |
|---|
| 1195 | websWrite(wp, "</fieldset>\n<br />\n"); |
|---|
| 1196 | } |
|---|
| 1197 | |
|---|
| 1198 | } |
|---|
| 1199 | |
|---|
| 1200 | void ej_show_security(webs_t wp, int argc, char_t ** argv) |
|---|
| 1201 | { |
|---|
| 1202 | #ifndef HAVE_MADWIFI |
|---|
| 1203 | int c = get_wl_instances(); |
|---|
| 1204 | int i; |
|---|
| 1205 | |
|---|
| 1206 | for (i = 0; i < c; i++) { |
|---|
| 1207 | char buf[16]; |
|---|
| 1208 | |
|---|
| 1209 | sprintf(buf, "wl%d", i); |
|---|
| 1210 | ej_show_security_single(wp, argc, argv, buf); |
|---|
| 1211 | } |
|---|
| 1212 | return; |
|---|
| 1213 | #else |
|---|
| 1214 | int c = getdevicecount(); |
|---|
| 1215 | int i; |
|---|
| 1216 | |
|---|
| 1217 | for (i = 0; i < c; i++) { |
|---|
| 1218 | char buf[16]; |
|---|
| 1219 | |
|---|
| 1220 | sprintf(buf, "ath%d", i); |
|---|
| 1221 | ej_show_security_single(wp, argc, argv, buf); |
|---|
| 1222 | } |
|---|
| 1223 | return; |
|---|
| 1224 | #endif |
|---|
| 1225 | } |
|---|
| 1226 | |
|---|
| 1227 | void ej_show_dhcpd_settings(webs_t wp, int argc, char_t ** argv) |
|---|
| 1228 | { |
|---|
| 1229 | int i; |
|---|
| 1230 | |
|---|
| 1231 | if (getWET()) // dhcpd settings disabled in client bridge mode, so we wont display it |
|---|
| 1232 | return; |
|---|
| 1233 | |
|---|
| 1234 | websWrite(wp, |
|---|
| 1235 | "<fieldset><legend><script type=\"text/javascript\">Capture(idx.dhcp_legend)</script></legend>\n"); |
|---|
| 1236 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1237 | websWrite(wp, |
|---|
| 1238 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_type)</script></div>\n"); |
|---|
| 1239 | websWrite(wp, |
|---|
| 1240 | "<select class=\"num\" size=\"1\" name=\"dhcpfwd_enable\" onchange=SelDHCPFWD(this.form.dhcpfwd_enable.selectedIndex,this.form)>\n"); |
|---|
| 1241 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1242 | websWrite(wp, |
|---|
| 1243 | "document.write(\"<option value=\\\"0\\\" %s >\" + idx.dhcp_srv + \"</option>\");\n", |
|---|
| 1244 | nvram_match("dhcpfwd_enable", |
|---|
| 1245 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1246 | websWrite(wp, |
|---|
| 1247 | "document.write(\"<option value=\\\"1\\\" %s >\" + idx.dhcp_fwd + \"</option>\");\n", |
|---|
| 1248 | nvram_match("dhcpfwd_enable", |
|---|
| 1249 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1250 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 1251 | websWrite(wp, "</select>\n"); |
|---|
| 1252 | websWrite(wp, "</div>\n"); |
|---|
| 1253 | if (nvram_match("dhcpfwd_enable", "1")) { |
|---|
| 1254 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1255 | websWrite(wp, |
|---|
| 1256 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_srv)</script></div>\n"); |
|---|
| 1257 | char *ipfwd = nvram_safe_get("dhcpfwd_ip"); |
|---|
| 1258 | |
|---|
| 1259 | websWrite(wp, |
|---|
| 1260 | "<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", |
|---|
| 1261 | get_single_ip(ipfwd, 0), get_single_ip(ipfwd, 1), |
|---|
| 1262 | get_single_ip(ipfwd, 2), get_single_ip(ipfwd, 3)); |
|---|
| 1263 | } else { |
|---|
| 1264 | char buf[20]; |
|---|
| 1265 | |
|---|
| 1266 | prefix_ip_get("lan_ipaddr", buf, 1); |
|---|
| 1267 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1268 | // char *nv = nvram_safe_get ("wan_wins"); |
|---|
| 1269 | websWrite(wp, |
|---|
| 1270 | "<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", |
|---|
| 1271 | nvram_match("lan_proto", |
|---|
| 1272 | "dhcp") ? "checked=\"checked\"" : ""); |
|---|
| 1273 | websWrite(wp, |
|---|
| 1274 | "<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", |
|---|
| 1275 | nvram_match("lan_proto", |
|---|
| 1276 | "static") ? "checked=\"checked\"" : ""); |
|---|
| 1277 | websWrite(wp, |
|---|
| 1278 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_start)</script></div>%s", |
|---|
| 1279 | buf); |
|---|
| 1280 | websWrite(wp, |
|---|
| 1281 | "<input class=\"num\" name=\"dhcp_start\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,1,254,idx.dhcp_start)\" value=\"%s\" />", |
|---|
| 1282 | nvram_safe_get("dhcp_start")); |
|---|
| 1283 | websWrite(wp, "</div>\n"); |
|---|
| 1284 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1285 | websWrite(wp, |
|---|
| 1286 | "<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\" /></div>\n", |
|---|
| 1287 | nvram_safe_get("dhcp_num")); |
|---|
| 1288 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1289 | websWrite(wp, |
|---|
| 1290 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_lease)</script></div><input class=\"num\" name=\"dhcp_lease\" size=\"5\" maxlength=\"5\" onblur=\"valid_range(this,0,99999,idx.dhcp_lease)\" value=\"%s\" > <script type=\"text/javascript\">Capture(share.minutes)</script></input></div>\n", |
|---|
| 1291 | nvram_safe_get("dhcp_lease")); |
|---|
| 1292 | if (nvram_invmatch("wan_proto", "static")) { |
|---|
| 1293 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1294 | websWrite(wp, |
|---|
| 1295 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 1</div>"); |
|---|
| 1296 | websWrite(wp, |
|---|
| 1297 | "<input type=\"hidden\" name=\"wan_dns\" value=\"4\" />"); |
|---|
| 1298 | for (i = 0; i < 4; i++) |
|---|
| 1299 | websWrite(wp, |
|---|
| 1300 | "<input class=\"num\" name=\"wan_dns0_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1301 | i, i == 3 ? 254 : 255, |
|---|
| 1302 | get_dns_ip("wan_dns", 0, i), |
|---|
| 1303 | i < 3 ? "." : ""); |
|---|
| 1304 | |
|---|
| 1305 | websWrite(wp, "\n</div>\n<div class=\"setting\">\n"); |
|---|
| 1306 | websWrite(wp, |
|---|
| 1307 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 2</div>"); |
|---|
| 1308 | for (i = 0; i < 4; i++) |
|---|
| 1309 | websWrite(wp, |
|---|
| 1310 | "<input class=\"num\" name=\"wan_dns1_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1311 | i, i == 3 ? 254 : 255, |
|---|
| 1312 | get_dns_ip("wan_dns", 1, i), |
|---|
| 1313 | i < 3 ? "." : ""); |
|---|
| 1314 | |
|---|
| 1315 | websWrite(wp, "\n</div>\n<div class=\"setting\">\n"); |
|---|
| 1316 | websWrite(wp, |
|---|
| 1317 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 3</div>"); |
|---|
| 1318 | for (i = 0; i < 4; i++) |
|---|
| 1319 | websWrite(wp, |
|---|
| 1320 | "<input class=\"num\" name=\"wan_dns2_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1321 | i, i == 3 ? 254 : 255, |
|---|
| 1322 | get_dns_ip("wan_dns", 2, i), |
|---|
| 1323 | i < 3 ? "." : ""); |
|---|
| 1324 | websWrite(wp, "\n</div>"); |
|---|
| 1325 | } |
|---|
| 1326 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1327 | websWrite(wp, "<div class=\"label\">WINS</div>\n"); |
|---|
| 1328 | websWrite(wp, |
|---|
| 1329 | "<input type=\"hidden\" name=\"wan_wins\" value=\"4\" />\n"); |
|---|
| 1330 | char *wins = nvram_safe_get("wan_wins"); |
|---|
| 1331 | |
|---|
| 1332 | for (i = 0; i < 4; i++) { |
|---|
| 1333 | websWrite(wp, |
|---|
| 1334 | "<input class=\"num\" name=\"wan_wins_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,"WINS")\" value=\"%d\" />%s", |
|---|
| 1335 | i, i == 3 ? 254 : 255, get_single_ip(wins, i), |
|---|
| 1336 | i < 3 ? "." : ""); |
|---|
| 1337 | } |
|---|
| 1338 | |
|---|
| 1339 | websWrite(wp, "</div>\n<div class=\"setting\">\n"); |
|---|
| 1340 | websWrite(wp, |
|---|
| 1341 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_dnsmasq)</script></div>\n"); |
|---|
| 1342 | websWrite(wp, |
|---|
| 1343 | "<input type=\"checkbox\" name=\"_dhcp_dnsmasq\" value=\"1\" onclick=\"setDNSMasq(this.form)\" %s />\n", |
|---|
| 1344 | nvram_match("dhcp_dnsmasq", |
|---|
| 1345 | "1") ? "checked=\"checked\"" : ""); |
|---|
| 1346 | websWrite(wp, "</div>\n<div class=\"setting\">\n"); |
|---|
| 1347 | websWrite(wp, |
|---|
| 1348 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dns_dnsmasq)</script></div>\n"); |
|---|
| 1349 | websWrite(wp, |
|---|
| 1350 | "<input type=\"checkbox\" name=\"_dns_dnsmasq\" value=\"1\" %s />\n", |
|---|
| 1351 | nvram_match("dns_dnsmasq", |
|---|
| 1352 | "1") ? "checked=\"checked\"" : ""); |
|---|
| 1353 | websWrite(wp, "</div>\n<div class=\"setting\">\n"); |
|---|
| 1354 | websWrite(wp, |
|---|
| 1355 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.auth_dnsmasq)</script></div>\n"); |
|---|
| 1356 | websWrite(wp, |
|---|
| 1357 | "<input type=\"checkbox\" name=\"_auth_dnsmasq\" value=\"1\" %s />\n", |
|---|
| 1358 | nvram_match("auth_dnsmasq", |
|---|
| 1359 | "1") ? "checked=\"checked\"" : ""); |
|---|
| 1360 | websWrite(wp, "</div>\n"); |
|---|
| 1361 | } |
|---|
| 1362 | |
|---|
| 1363 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 1364 | return; |
|---|
| 1365 | } |
|---|
| 1366 | |
|---|
| 1367 | #ifdef HAVE_MADWIFI |
|---|
| 1368 | void ej_show_wifiselect(webs_t wp, int argc, char_t ** argv) |
|---|
| 1369 | { |
|---|
| 1370 | char *next; |
|---|
| 1371 | char var[32]; |
|---|
| 1372 | int count = getifcount("wifi"); |
|---|
| 1373 | |
|---|
| 1374 | if (count < 2) |
|---|
| 1375 | return; |
|---|
| 1376 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1377 | websWrite(wp, |
|---|
| 1378 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.intrface)</script></div>\n"); |
|---|
| 1379 | websWrite(wp, |
|---|
| 1380 | "<select name=\"wifi_display\" onchange=\"refresh(this.form)\">\n"); |
|---|
| 1381 | int i; |
|---|
| 1382 | |
|---|
| 1383 | for (i = 0; i < count; i++) { |
|---|
| 1384 | sprintf(var, "ath%d", i); |
|---|
| 1385 | websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 1386 | var, nvram_match("wifi_display", |
|---|
| 1387 | var) ? "selected=\"selected\"" : "", |
|---|
| 1388 | var); |
|---|
| 1389 | char *names = nvram_nget("ath%d_vifs", i); |
|---|
| 1390 | |
|---|
| 1391 | foreach(var, names, next) { |
|---|
| 1392 | websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 1393 | var, nvram_match("wifi_display", |
|---|
| 1394 | var) ? |
|---|
| 1395 | "selected=\"selected\"" : "", var); |
|---|
| 1396 | } |
|---|
| 1397 | } |
|---|
| 1398 | websWrite(wp, "</select>\n"); |
|---|
| 1399 | websWrite(wp, "</div>\n"); |
|---|
| 1400 | |
|---|
| 1401 | } |
|---|
| 1402 | #else |
|---|
| 1403 | void ej_show_wifiselect(webs_t wp, int argc, char_t ** argv) |
|---|
| 1404 | { |
|---|
| 1405 | char *next; |
|---|
| 1406 | char var[32]; |
|---|
| 1407 | int count = get_wl_instances(); |
|---|
| 1408 | |
|---|
| 1409 | if (count < 2) |
|---|
| 1410 | return; |
|---|
| 1411 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1412 | websWrite(wp, |
|---|
| 1413 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.intrface)</script></div>\n"); |
|---|
| 1414 | websWrite(wp, |
|---|
| 1415 | "<select name=\"wifi_display\" onchange=\"refresh(this.form)\">\n"); |
|---|
| 1416 | int i; |
|---|
| 1417 | |
|---|
| 1418 | for (i = 0; i < count; i++) { |
|---|
| 1419 | sprintf(var, "wl%d", i); |
|---|
| 1420 | websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 1421 | var, nvram_match("wifi_display", |
|---|
| 1422 | var) ? "selected=\"selected\"" : "", |
|---|
| 1423 | var); |
|---|
| 1424 | } |
|---|
| 1425 | websWrite(wp, "</select>\n"); |
|---|
| 1426 | websWrite(wp, "</div>\n"); |
|---|
| 1427 | } |
|---|
| 1428 | |
|---|
| 1429 | #endif |
|---|
| 1430 | #if 0 |
|---|
| 1431 | static void showOption(webs_t wp, char *propname, char *nvname) |
|---|
| 1432 | { |
|---|
| 1433 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1434 | websWrite(wp, |
|---|
| 1435 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n<select name=\"%s\">\n", |
|---|
| 1436 | propname, nvname); |
|---|
| 1437 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1438 | websWrite(wp, |
|---|
| 1439 | "document.write(\"<option value=\\\"0\\\" %s >\" + share.disabled + \"</option>\");\n", |
|---|
| 1440 | nvram_default_match(nvname, "0", |
|---|
| 1441 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1442 | websWrite(wp, |
|---|
| 1443 | "document.write(\"<option value=\\\"1\\\" %s >\" + share.enabled + \"</option>\");\n", |
|---|
| 1444 | nvram_default_match(nvname, "1", |
|---|
| 1445 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1446 | websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 1447 | |
|---|
| 1448 | } |
|---|
| 1449 | #endif |
|---|
| 1450 | static void showRadio(webs_t wp, char *propname, char *nvname) |
|---|
| 1451 | { |
|---|
| 1452 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1453 | websWrite(wp, |
|---|
| 1454 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n", |
|---|
| 1455 | propname); |
|---|
| 1456 | websWrite(wp, |
|---|
| 1457 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input> \n", |
|---|
| 1458 | nvname, nvram_default_match(nvname, "1", |
|---|
| 1459 | "0") ? "checked=\"checked\"" : |
|---|
| 1460 | ""); |
|---|
| 1461 | websWrite(wp, |
|---|
| 1462 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input> \n", |
|---|
| 1463 | nvname, nvram_default_match(nvname, "0", |
|---|
| 1464 | "0") ? "checked=\"checked\"" : |
|---|
| 1465 | ""); |
|---|
| 1466 | websWrite(wp, "</div>\n"); |
|---|
| 1467 | } |
|---|
| 1468 | |
|---|
| 1469 | #ifdef HAVE_MADWIFI |
|---|
| 1470 | static void showAutoOption(webs_t wp, char *propname, char *nvname) |
|---|
| 1471 | { |
|---|
| 1472 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1473 | websWrite(wp, |
|---|
| 1474 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n<select name=\"%s\">\n", |
|---|
| 1475 | propname, nvname); |
|---|
| 1476 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1477 | websWrite(wp, |
|---|
| 1478 | "document.write(\"<option value=\\\"-1\\\" %s >\" + share.auto + \"</option>\");\n", |
|---|
| 1479 | nvram_default_match(nvname, "0", |
|---|
| 1480 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1481 | websWrite(wp, |
|---|
| 1482 | "document.write(\"<option value=\\\"1\\\" %s >\" + share.enabled + \"</option>\");\n", |
|---|
| 1483 | nvram_default_match(nvname, "1", |
|---|
| 1484 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1485 | websWrite(wp, |
|---|
| 1486 | "document.write(\"<option value=\\\"0\\\" %s >\" + share.disabled + \"</option>\");\n", |
|---|
| 1487 | nvram_default_match(nvname, "0", |
|---|
| 1488 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1489 | websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 1490 | |
|---|
| 1491 | } |
|---|
| 1492 | #endif |
|---|
| 1493 | |
|---|
| 1494 | static void showOptions(webs_t wp, char *propname, char *names, char *select) |
|---|
| 1495 | { |
|---|
| 1496 | char *next; |
|---|
| 1497 | char var[80]; |
|---|
| 1498 | |
|---|
| 1499 | websWrite(wp, "<select name=\"%s\">\n", propname); |
|---|
| 1500 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1501 | foreach(var, names, next) { |
|---|
| 1502 | websWrite(wp, |
|---|
| 1503 | "document.write(\"<option value=\\\"%s\\\" %s >%s</option>\");\n", |
|---|
| 1504 | var, !strcmp(var, |
|---|
| 1505 | select) ? "selected=\\\"selected\\\"" : |
|---|
| 1506 | "", var); |
|---|
| 1507 | } |
|---|
| 1508 | websWrite(wp, "//]]>\n</script>\n</select>\n"); |
|---|
| 1509 | } |
|---|
| 1510 | |
|---|
| 1511 | static void |
|---|
| 1512 | showOptionsChoose(webs_t wp, char *propname, char *names, char *select) |
|---|
| 1513 | { |
|---|
| 1514 | char *next; |
|---|
| 1515 | char var[80]; |
|---|
| 1516 | |
|---|
| 1517 | websWrite(wp, "<select name=\"%s\">\n", propname); |
|---|
| 1518 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1519 | websWrite(wp, |
|---|
| 1520 | "document.write(\"<option value=\\\"null\\\" >Please choose...</option>\");\n"); |
|---|
| 1521 | foreach(var, names, next) { |
|---|
| 1522 | websWrite(wp, |
|---|
| 1523 | "document.write(\"<option value=\\\"%s\\\" %s >%s</option>\");\n", |
|---|
| 1524 | var, !strcmp(var, |
|---|
| 1525 | select) ? "selected=\\\"selected\\\"" : |
|---|
| 1526 | "", var); |
|---|
| 1527 | } |
|---|
| 1528 | websWrite(wp, "//]]>\n</script>\n</select>\n"); |
|---|
| 1529 | } |
|---|
| 1530 | |
|---|
| 1531 | static void |
|---|
| 1532 | showOptionsLabel(webs_t wp, char *labelname, char *propname, char *names, |
|---|
| 1533 | char *select) |
|---|
| 1534 | { |
|---|
| 1535 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1536 | websWrite(wp, |
|---|
| 1537 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>", |
|---|
| 1538 | labelname); |
|---|
| 1539 | showOptions(wp, propname, names, select); |
|---|
| 1540 | websWrite(wp, "</div>\n"); |
|---|
| 1541 | |
|---|
| 1542 | } |
|---|
| 1543 | |
|---|
| 1544 | void |
|---|
| 1545 | show_inputlabel(webs_t wp, char *labelname, char *propertyname, |
|---|
| 1546 | int propertysize, char *inputclassname, int inputmaxlength) |
|---|
| 1547 | { |
|---|
| 1548 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1549 | websWrite(wp, |
|---|
| 1550 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>", |
|---|
| 1551 | labelname); |
|---|
| 1552 | websWrite(wp, |
|---|
| 1553 | "<input class=\"%s\" size=\"%d\" maxlength=\"%d\" name=\"%s\" value=\"%s\" />\n", |
|---|
| 1554 | inputclassname, propertysize, inputmaxlength, propertyname, |
|---|
| 1555 | nvram_safe_get(propertyname)); |
|---|
| 1556 | websWrite(wp, "</div>\n"); |
|---|
| 1557 | } |
|---|
| 1558 | |
|---|
| 1559 | void |
|---|
| 1560 | show_custominputlabel(webs_t wp, char *labelname, char *propertyname, |
|---|
| 1561 | char *property, int propertysize) |
|---|
| 1562 | { |
|---|
| 1563 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1564 | websWrite(wp, "<div class=\"label\">%s</div>", labelname); |
|---|
| 1565 | websWrite(wp, "<input size=\"%d\" name=\"%s\" value=\"%s\" />\n", |
|---|
| 1566 | propertysize, propertyname, property); |
|---|
| 1567 | websWrite(wp, "</div>\n"); |
|---|
| 1568 | } |
|---|
| 1569 | |
|---|
| 1570 | #ifdef HAVE_USB |
|---|
| 1571 | void ej_show_usb_diskinfo(webs_t wp, int argc, char_t ** argv) |
|---|
| 1572 | { |
|---|
| 1573 | char buff[512]; |
|---|
| 1574 | FILE *fp; |
|---|
| 1575 | |
|---|
| 1576 | if (!nvram_match("usb_automnt", "1")) |
|---|
| 1577 | return; |
|---|
| 1578 | |
|---|
| 1579 | if ((fp = fopen("/tmp/disktype.dump", "r"))) { |
|---|
| 1580 | while (fgets(buff, sizeof(buff), fp)) { |
|---|
| 1581 | if (strcmp(buff, "\n")) |
|---|
| 1582 | websWrite(wp, "%s<br />", buff); |
|---|
| 1583 | } |
|---|
| 1584 | fclose(fp); |
|---|
| 1585 | } else |
|---|
| 1586 | websWrite(wp, "%s", live_translate("status_router.notavail")); |
|---|
| 1587 | |
|---|
| 1588 | return; |
|---|
| 1589 | } |
|---|
| 1590 | #endif |
|---|
| 1591 | |
|---|
| 1592 | #ifdef HAVE_MMC |
|---|
| 1593 | void ej_show_mmc_cardinfo(webs_t wp, int argc, char_t ** argv) |
|---|
| 1594 | { |
|---|
| 1595 | char buff[512]; |
|---|
| 1596 | FILE *fp; |
|---|
| 1597 | |
|---|
| 1598 | if (!nvram_match("mmc_enable0", "1")) |
|---|
| 1599 | return; |
|---|
| 1600 | |
|---|
| 1601 | if ((fp = fopen("/proc/mmc/status", "rb"))) { |
|---|
| 1602 | while (fgets(buff, sizeof(buff), fp)) { |
|---|
| 1603 | if (strcmp(buff, "\n")) |
|---|
| 1604 | websWrite(wp, "%s<br />", buff); |
|---|
| 1605 | } |
|---|
| 1606 | fclose(fp); |
|---|
| 1607 | } else |
|---|
| 1608 | websWrite(wp, "%s", live_translate("status_router.notavail")); |
|---|
| 1609 | |
|---|
| 1610 | return; |
|---|
| 1611 | } |
|---|
| 1612 | #endif |
|---|
| 1613 | |
|---|
| 1614 | void show_legend(webs_t wp, char *labelname, int translate) |
|---|
| 1615 | { |
|---|
| 1616 | /* |
|---|
| 1617 | * char buf[2]; sprintf(buf,"%d",translate); websWrite (wp, |
|---|
| 1618 | * "<legend>%s%s%s</legend>\n", !strcmp (buf, "1") ? "<script |
|---|
| 1619 | * type=\"text/javascript\">Capture(" : "", labelname, !strcmp (buf, "1") |
|---|
| 1620 | * ? ")</script>" : ""); |
|---|
| 1621 | */ |
|---|
| 1622 | if (translate) |
|---|
| 1623 | websWrite(wp, |
|---|
| 1624 | "<legend><script type=\"text/javascript\">Capture(%s)</script></legend>\n", |
|---|
| 1625 | labelname); |
|---|
| 1626 | else |
|---|
| 1627 | websWrite(wp, "<legend>%s</legend>\n", labelname); |
|---|
| 1628 | |
|---|
| 1629 | } |
|---|
| 1630 | |
|---|
| 1631 | #ifdef HAVE_OLSRD |
|---|
| 1632 | |
|---|
| 1633 | void ej_show_olsrd(webs_t wp, int argc, char_t ** argv) |
|---|
| 1634 | { |
|---|
| 1635 | char *var = websGetVar(wp, "wk_mode", NULL); |
|---|
| 1636 | |
|---|
| 1637 | if (var == NULL) |
|---|
| 1638 | var = nvram_safe_get("wk_mode"); |
|---|
| 1639 | if (!strcmp(var, "olsr")) { |
|---|
| 1640 | websWrite(wp, "<fieldset>\n"); |
|---|
| 1641 | show_legend(wp, "route.olsrd_legend", 1); |
|---|
| 1642 | show_inputlabel(wp, "route.olsrd_hna", "olsrd_hna", 32, "num", |
|---|
| 1643 | 32); |
|---|
| 1644 | show_inputlabel(wp, "route.olsrd_poll", "olsrd_pollsize", 5, |
|---|
| 1645 | "num", 5); |
|---|
| 1646 | showOptionsLabel(wp, "route.olsrd_tc", "olsrd_redundancy", |
|---|
| 1647 | "0 1 2", nvram_default_get("olsrd_redundancy", |
|---|
| 1648 | "2")); |
|---|
| 1649 | show_inputlabel(wp, "route.olsrd_mpr", "olsrd_coverage", 5, |
|---|
| 1650 | "num", 5); |
|---|
| 1651 | showRadio(wp, "route.olsrd_lqfe", "olsrd_lqfisheye"); |
|---|
| 1652 | show_inputlabel(wp, "route.olsrd_lqag", "olsrd_lqaging", 5, |
|---|
| 1653 | "num", 5); |
|---|
| 1654 | |
|---|
| 1655 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1656 | websWrite(wp, |
|---|
| 1657 | "<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_lqdmin)</script></div>"); |
|---|
| 1658 | websWrite(wp, |
|---|
| 1659 | "<input class=\"num\" size=\"5\" maxlength=\"5\" name=\"olsrd_lqdijkstramin\" onblur=\"olsrd_checkDijkstra(this.form)\" value=\"%s\" />\n", |
|---|
| 1660 | nvram_safe_get("olsrd_lqdijkstramin")); |
|---|
| 1661 | websWrite(wp, "</div>\n"); |
|---|
| 1662 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1663 | websWrite(wp, |
|---|
| 1664 | "<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_lqdmax)</script></div>"); |
|---|
| 1665 | websWrite(wp, |
|---|
| 1666 | "<input class=\"num\" size=\"5\" maxlength=\"5\" name=\"olsrd_lqdijkstramax\" onblur=\"olsrd_checkDijkstra(this.form)\" value=\"%s\" />\n", |
|---|
| 1667 | nvram_safe_get("olsrd_lqdijkstramax")); |
|---|
| 1668 | websWrite(wp, "</div>\n"); |
|---|
| 1669 | |
|---|
| 1670 | showOptionsLabel(wp, "route.olsrd_lqlvl", "olsrd_lqlevel", |
|---|
| 1671 | "0 1 2", nvram_default_get("olsrd_lqlevel", |
|---|
| 1672 | "2")); |
|---|
| 1673 | showRadio(wp, "route.olsrd_hysteresis", "olsrd_hysteresis"); |
|---|
| 1674 | char *wordlist = nvram_safe_get("olsrd_interfaces"); |
|---|
| 1675 | char *next; |
|---|
| 1676 | char word[128]; |
|---|
| 1677 | int count = 0; |
|---|
| 1678 | |
|---|
| 1679 | foreach(word, wordlist, next) { |
|---|
| 1680 | char *interface = word; |
|---|
| 1681 | char *hellointerval = interface; |
|---|
| 1682 | |
|---|
| 1683 | strsep(&hellointerval, ">"); |
|---|
| 1684 | char *hellovaliditytime = hellointerval; |
|---|
| 1685 | |
|---|
| 1686 | strsep(&hellovaliditytime, ">"); |
|---|
| 1687 | char *tcinterval = hellovaliditytime; |
|---|
| 1688 | |
|---|
| 1689 | strsep(&tcinterval, ">"); |
|---|
| 1690 | char *tcvaliditytime = tcinterval; |
|---|
| 1691 | |
|---|
| 1692 | strsep(&tcvaliditytime, ">"); |
|---|
| 1693 | char *midinterval = tcvaliditytime; |
|---|
| 1694 | |
|---|
| 1695 | strsep(&midinterval, ">"); |
|---|
| 1696 | char *midvaliditytime = midinterval; |
|---|
| 1697 | |
|---|
| 1698 | strsep(&midvaliditytime, ">"); |
|---|
| 1699 | char *hnainterval = midvaliditytime; |
|---|
| 1700 | |
|---|
| 1701 | strsep(&hnainterval, ">"); |
|---|
| 1702 | char *hnavaliditytime = hnainterval; |
|---|
| 1703 | |
|---|
| 1704 | strsep(&hnavaliditytime, ">"); |
|---|
| 1705 | websWrite(wp, "<fieldset>\n"); |
|---|
| 1706 | show_legend(wp, interface, 0); |
|---|
| 1707 | char valuename[32]; |
|---|
| 1708 | |
|---|
| 1709 | sprintf(valuename, "%s_hellointerval", interface); |
|---|
| 1710 | show_custominputlabel(wp, "Hello Interval", valuename, |
|---|
| 1711 | hellointerval, 5); |
|---|
| 1712 | sprintf(valuename, "%s_hellovaliditytime", interface); |
|---|
| 1713 | show_custominputlabel(wp, "Hello Validity Time", |
|---|
| 1714 | valuename, hellovaliditytime, 5); |
|---|
| 1715 | |
|---|
| 1716 | sprintf(valuename, "%s_tcinterval", interface); |
|---|
| 1717 | show_custominputlabel(wp, "TC Interval", valuename, |
|---|
| 1718 | tcinterval, 5); |
|---|
| 1719 | sprintf(valuename, "%s_tcvaliditytime", interface); |
|---|
| 1720 | show_custominputlabel(wp, "TC Validity Time", valuename, |
|---|
| 1721 | tcvaliditytime, 5); |
|---|
| 1722 | |
|---|
| 1723 | sprintf(valuename, "%s_midinterval", interface); |
|---|
| 1724 | show_custominputlabel(wp, "MID Interval", valuename, |
|---|
| 1725 | midinterval, 5); |
|---|
| 1726 | sprintf(valuename, "%s_midvaliditytime", interface); |
|---|
| 1727 | show_custominputlabel(wp, "MID Validity Time", |
|---|
| 1728 | valuename, midvaliditytime, 5); |
|---|
| 1729 | |
|---|
| 1730 | sprintf(valuename, "%s_hnainterval", interface); |
|---|
| 1731 | show_custominputlabel(wp, "HNA Interval", valuename, |
|---|
| 1732 | hnainterval, 5); |
|---|
| 1733 | sprintf(valuename, "%s_hnavaliditytime", interface); |
|---|
| 1734 | show_custominputlabel(wp, "HNA Validity Time", |
|---|
| 1735 | valuename, hnavaliditytime, 5); |
|---|
| 1736 | websWrite(wp, |
|---|
| 1737 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"olsrd_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 1738 | count); |
|---|
| 1739 | |
|---|
| 1740 | websWrite(wp, "</fieldset>\n"); |
|---|
| 1741 | count++; |
|---|
| 1742 | } |
|---|
| 1743 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1744 | websWrite(wp, |
|---|
| 1745 | "<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_newiface)</script></div>\n"); |
|---|
| 1746 | char buffer[256]; |
|---|
| 1747 | |
|---|
| 1748 | memset(buffer, 0, 256); |
|---|
| 1749 | getIfList(buffer, NULL); |
|---|
| 1750 | showOptions(wp, "olsrd_ifname", buffer, ""); |
|---|
| 1751 | websWrite(wp, " "); |
|---|
| 1752 | websWrite(wp, |
|---|
| 1753 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.add + \"\\\" onclick=\\\"olsrd_add_submit(this.form)\\\" />\");\n//]]>\n</script>\n"); |
|---|
| 1754 | websWrite(wp, "</div>\n"); |
|---|
| 1755 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 1756 | } |
|---|
| 1757 | } |
|---|
| 1758 | #else //!HAVE_OLSRD |
|---|
| 1759 | void ej_show_olsrd(webs_t wp, int argc, char_t ** argv) |
|---|
| 1760 | { |
|---|
| 1761 | return; |
|---|
| 1762 | } |
|---|
| 1763 | #endif |
|---|
| 1764 | |
|---|
| 1765 | #ifdef HAVE_VLANTAGGING |
|---|
| 1766 | #ifdef HAVE_BONDING |
|---|
| 1767 | |
|---|
| 1768 | void ej_show_bondings(webs_t wp, int argc, char_t ** argv) |
|---|
| 1769 | { |
|---|
| 1770 | char buffer[256]; |
|---|
| 1771 | char bufferif[512]; |
|---|
| 1772 | char bondnames[256]; |
|---|
| 1773 | int count = 0; |
|---|
| 1774 | static char word[256]; |
|---|
| 1775 | char *next, *wordlist; |
|---|
| 1776 | |
|---|
| 1777 | memset(buffer, 0, 256); |
|---|
| 1778 | memset(bondnames, 0, 256); |
|---|
| 1779 | memset(bufferif, 0, 512); |
|---|
| 1780 | websWrite(wp, "<h2>Bonding</h2>\n"); |
|---|
| 1781 | websWrite(wp, "<fieldset>\n"); |
|---|
| 1782 | websWrite(wp, "<legend>Bonding</legend>\n"); |
|---|
| 1783 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1784 | websWrite(wp, "<div class=\"label\">Bonding Type</div>\n", count); |
|---|
| 1785 | showOptions(wp, "bonding_type", |
|---|
| 1786 | "balance-rr active-backup balance-xor broadcast 802.3ad balance-tlb balance-alb weighted-rr duplex", |
|---|
| 1787 | nvram_default_get("bonding_type", "balance-rr")); |
|---|
| 1788 | websWrite(wp, " Bonding Interfaces "); |
|---|
| 1789 | websWrite(wp, |
|---|
| 1790 | "<input class=\"num\" name=\"bonding_number\"size=\"5\" value=\"%s\" />\n", |
|---|
| 1791 | nvram_default_get("bonding_number", "1")); |
|---|
| 1792 | websWrite(wp, "</div>\n"); |
|---|
| 1793 | |
|---|
| 1794 | getIfList(bufferif, "eth"); |
|---|
| 1795 | int i; |
|---|
| 1796 | |
|---|
| 1797 | #ifdef HAVE_XSCALE |
|---|
| 1798 | memset(buffer, 0, 256); |
|---|
| 1799 | getIfList(buffer, "ixp"); |
|---|
| 1800 | sprintf(bufferif, "%s %s", bufferif, buffer); |
|---|
| 1801 | #endif |
|---|
| 1802 | memset(buffer, 0, 256); |
|---|
| 1803 | getIfList(buffer, "br"); |
|---|
| 1804 | sprintf(bufferif, "%s %s", bufferif, buffer); |
|---|
| 1805 | #ifdef HAVE_MADWIFI |
|---|
| 1806 | int c = getifcount("wifi"); |
|---|
| 1807 | |
|---|
| 1808 | for (i = 0; i < c; i++) { |
|---|
| 1809 | char ath[32]; |
|---|
| 1810 | |
|---|
| 1811 | sprintf(ath, "ath%d_bridged", i); |
|---|
| 1812 | if (nvram_default_match(ath, "0", "1")) { |
|---|
| 1813 | sprintf(bufferif, "%s ath%d", bufferif, i); |
|---|
| 1814 | char vifs[32]; |
|---|
| 1815 | |
|---|
| 1816 | sprintf(vifs, "ath%d_vifs", i); |
|---|
| 1817 | sprintf(bufferif, "%s %s", bufferif, |
|---|
| 1818 | nvram_safe_get(vifs)); |
|---|
| 1819 | } |
|---|
| 1820 | } |
|---|
| 1821 | #endif |
|---|
| 1822 | |
|---|
| 1823 | for (i = 0; i < atoi(nvram_safe_get("bonding_number")); i++) { |
|---|
| 1824 | sprintf(bondnames, "%s bond%d", bondnames, i); |
|---|
| 1825 | } |
|---|
| 1826 | int totalcount = 0; |
|---|
| 1827 | int realcount = atoi(nvram_default_get("bonding_count", "0")); |
|---|
| 1828 | |
|---|
| 1829 | wordlist = nvram_safe_get("bondings"); |
|---|
| 1830 | foreach(word, wordlist, next) { |
|---|
| 1831 | char *port = word; |
|---|
| 1832 | char *tag = strsep(&port, ">"); |
|---|
| 1833 | |
|---|
| 1834 | if (!tag || !port) |
|---|
| 1835 | break; |
|---|
| 1836 | char vlan_name[32]; |
|---|
| 1837 | |
|---|
| 1838 | // sprintf (vlan_name, "%s.%s", tag, port); |
|---|
| 1839 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1840 | websWrite(wp, |
|---|
| 1841 | "<div class=\"label\">Bonding %d Assignment</div>\n", |
|---|
| 1842 | count); |
|---|
| 1843 | websWrite(wp, " Bond "); |
|---|
| 1844 | sprintf(vlan_name, "bondingifname%d", count); |
|---|
| 1845 | showOptions(wp, vlan_name, bondnames, tag); |
|---|
| 1846 | sprintf(vlan_name, "bondingattach%d", count); |
|---|
| 1847 | websWrite(wp, " Slave "); |
|---|
| 1848 | showOptions(wp, vlan_name, bufferif, port); |
|---|
| 1849 | websWrite(wp, |
|---|
| 1850 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"bond_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 1851 | count); |
|---|
| 1852 | websWrite(wp, "</div>\n"); |
|---|
| 1853 | count++; |
|---|
| 1854 | } |
|---|
| 1855 | totalcount = count; |
|---|
| 1856 | for (i = count; i < realcount; i++) { |
|---|
| 1857 | char vlan_name[32]; |
|---|
| 1858 | |
|---|
| 1859 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1860 | websWrite(wp, |
|---|
| 1861 | "<div class=\"label\">Bonding %d Interface</div>\n", |
|---|
| 1862 | i); |
|---|
| 1863 | websWrite(wp, " Bond "); |
|---|
| 1864 | sprintf(vlan_name, "bondingifname%d", i); |
|---|
| 1865 | showOptions(wp, vlan_name, bondnames, ""); |
|---|
| 1866 | sprintf(vlan_name, "bondingattach%d", i); |
|---|
| 1867 | websWrite(wp, " Slave "); |
|---|
| 1868 | showOptions(wp, vlan_name, bufferif, ""); |
|---|
| 1869 | websWrite(wp, |
|---|
| 1870 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"bond_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 1871 | i); |
|---|
| 1872 | websWrite(wp, "</div>\n"); |
|---|
| 1873 | totalcount++; |
|---|
| 1874 | } |
|---|
| 1875 | char var[32]; |
|---|
| 1876 | |
|---|
| 1877 | sprintf(var, "%d", totalcount); |
|---|
| 1878 | nvram_set("bonding_count", var); |
|---|
| 1879 | websWrite(wp, |
|---|
| 1880 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.add + \"\\\" onclick=\\\"bond_add_submit(this.form)\\\" />\");\n//]]>\n</script>\n"); |
|---|
| 1881 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 1882 | } |
|---|
| 1883 | #else //!HAVE_BONDING |
|---|
| 1884 | void ej_show_bondings(webs_t wp, int argc, char_t ** argv) |
|---|
| 1885 | { |
|---|
| 1886 | return; |
|---|
| 1887 | } |
|---|
| 1888 | #endif |
|---|
| 1889 | |
|---|
| 1890 | void ej_show_vlantagging(webs_t wp, int argc, char_t ** argv) |
|---|
| 1891 | { |
|---|
| 1892 | char buffer[256]; |
|---|
| 1893 | int count = 0; |
|---|
| 1894 | static char word[256]; |
|---|
| 1895 | char *next, *wordlist; |
|---|
| 1896 | |
|---|
| 1897 | memset(buffer, 0, 256); |
|---|
| 1898 | getIfList(buffer, NULL); |
|---|
| 1899 | int totalcount = 0; |
|---|
| 1900 | int realcount = atoi(nvram_default_get("vlan_tagcount", "0")); |
|---|
| 1901 | |
|---|
| 1902 | wordlist = nvram_safe_get("vlan_tags"); |
|---|
| 1903 | foreach(word, wordlist, next) { |
|---|
| 1904 | |
|---|
| 1905 | char *port = word; |
|---|
| 1906 | char *tag = strsep(&port, ">"); |
|---|
| 1907 | char *prio = port; |
|---|
| 1908 | strsep(&prio, ">"); |
|---|
| 1909 | |
|---|
| 1910 | if (!tag || !port) |
|---|
| 1911 | break; |
|---|
| 1912 | if (!prio) |
|---|
| 1913 | prio = "0"; |
|---|
| 1914 | char vlan_name[32]; |
|---|
| 1915 | |
|---|
| 1916 | // sprintf (vlan_name, "%s.%s", tag, port); |
|---|
| 1917 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1918 | websWrite(wp, "<div class=\"label\">VLAN%d Interface</div>\n", |
|---|
| 1919 | count); |
|---|
| 1920 | sprintf(vlan_name, "vlanifname%d", count); |
|---|
| 1921 | showOptions(wp, vlan_name, buffer, tag); |
|---|
| 1922 | //tag number |
|---|
| 1923 | sprintf(vlan_name, "vlantag%d", count); |
|---|
| 1924 | websWrite(wp, " Tag Number "); |
|---|
| 1925 | websWrite(wp, |
|---|
| 1926 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 1927 | vlan_name, port); |
|---|
| 1928 | //priority |
|---|
| 1929 | sprintf(vlan_name, "vlanprio%d", count); |
|---|
| 1930 | websWrite(wp, " Prio "); |
|---|
| 1931 | showOptions(wp, vlan_name, "0 1 2 3 4 5 6 7", prio); |
|---|
| 1932 | |
|---|
| 1933 | websWrite(wp, |
|---|
| 1934 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"vlan_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 1935 | count); |
|---|
| 1936 | websWrite(wp, "</div>\n"); |
|---|
| 1937 | count++; |
|---|
| 1938 | } |
|---|
| 1939 | totalcount = count; |
|---|
| 1940 | int i; |
|---|
| 1941 | |
|---|
| 1942 | for (i = count; i < realcount; i++) { |
|---|
| 1943 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1944 | websWrite(wp, "<div class=\"label\">VLAN%d Interface</div>\n", |
|---|
| 1945 | i); |
|---|
| 1946 | char vlan_name[32]; |
|---|
| 1947 | |
|---|
| 1948 | sprintf(vlan_name, "vlanifname%d", i); |
|---|
| 1949 | showOptions(wp, vlan_name, buffer, ""); |
|---|
| 1950 | sprintf(vlan_name, "vlantag%d", i); |
|---|
| 1951 | //tag number |
|---|
| 1952 | websWrite(wp, " Tag Number "); |
|---|
| 1953 | websWrite(wp, |
|---|
| 1954 | "<input class=\"num\" name=\"%s\" size=\"5\" value=\"0\" />\n", |
|---|
| 1955 | vlan_name); |
|---|
| 1956 | //priority |
|---|
| 1957 | sprintf(vlan_name, "vlanprio%d", count); |
|---|
| 1958 | websWrite(wp, " Prio "); |
|---|
| 1959 | showOptions(wp, vlan_name, "0 1 2 3 4 5 6 7", "0"); |
|---|
| 1960 | websWrite(wp, |
|---|
| 1961 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"vlan_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 1962 | i); |
|---|
| 1963 | websWrite(wp, "</div>\n"); |
|---|
| 1964 | totalcount++; |
|---|
| 1965 | } |
|---|
| 1966 | char var[32]; |
|---|
| 1967 | |
|---|
| 1968 | sprintf(var, "%d", totalcount); |
|---|
| 1969 | nvram_set("vlan_tagcount", var); |
|---|
| 1970 | websWrite(wp, |
|---|
| 1971 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.add + \"\\\" onclick=\\\"vlan_add_submit(this.form)\\\" />\");\n//]]>\n</script>\n"); |
|---|
| 1972 | } |
|---|
| 1973 | |
|---|
| 1974 | void ej_show_mdhcp(webs_t wp, int argc, char_t ** argv) |
|---|
| 1975 | { |
|---|
| 1976 | char buffer[256]; |
|---|
| 1977 | int count = 0; |
|---|
| 1978 | static char word[256]; |
|---|
| 1979 | char *next, *wordlist; |
|---|
| 1980 | |
|---|
| 1981 | websWrite(wp, "<h2>%s</h2>\n<fieldset>\n", |
|---|
| 1982 | live_translate("networking.h5")); |
|---|
| 1983 | websWrite(wp, "<legend>%s</legend>\n", |
|---|
| 1984 | live_translate("networking.legend5")); |
|---|
| 1985 | |
|---|
| 1986 | memset(buffer, 0, 256); |
|---|
| 1987 | getIfList(buffer, NULL); |
|---|
| 1988 | int totalcount = 0; |
|---|
| 1989 | int realcount = atoi(nvram_default_get("mdhcpd_count", "0")); |
|---|
| 1990 | |
|---|
| 1991 | wordlist = nvram_safe_get("mdhcpd"); |
|---|
| 1992 | foreach(word, wordlist, next) { |
|---|
| 1993 | char *interface = word; |
|---|
| 1994 | char *dhcpon = interface; |
|---|
| 1995 | |
|---|
| 1996 | interface = strsep(&dhcpon, ">"); |
|---|
| 1997 | char *start = dhcpon; |
|---|
| 1998 | |
|---|
| 1999 | dhcpon = strsep(&start, ">"); |
|---|
| 2000 | char *max = start; |
|---|
| 2001 | |
|---|
| 2002 | start = strsep(&max, ">"); |
|---|
| 2003 | char *leasetime = max; |
|---|
| 2004 | |
|---|
| 2005 | max = strsep(&leasetime, ">"); |
|---|
| 2006 | if (!interface || !start || !dhcpon || !max || !leasetime) |
|---|
| 2007 | break; |
|---|
| 2008 | char vlan_name[32]; |
|---|
| 2009 | |
|---|
| 2010 | // interface |
|---|
| 2011 | char *ipaddr = nvram_nget("%s_ipaddr", interface); |
|---|
| 2012 | char *netmask = nvram_nget("%s_netmask", interface); |
|---|
| 2013 | |
|---|
| 2014 | if (strlen(ipaddr) > 0 && strlen(netmask) > 0) { |
|---|
| 2015 | websWrite(wp, "Interface %s: IP %s/%s\n", interface, |
|---|
| 2016 | ipaddr, netmask); |
|---|
| 2017 | } |
|---|
| 2018 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2019 | websWrite(wp, "<div class=\"label\">DHCP %d</div>\n", count); |
|---|
| 2020 | sprintf(vlan_name, "mdhcpifname%d", count); |
|---|
| 2021 | showOptions(wp, vlan_name, buffer, interface); |
|---|
| 2022 | // on off |
|---|
| 2023 | sprintf(vlan_name, "mdhcpon%d", count); |
|---|
| 2024 | showOptions(wp, vlan_name, "On Off", dhcpon); |
|---|
| 2025 | // start |
|---|
| 2026 | sprintf(vlan_name, "mdhcpstart%d", count); |
|---|
| 2027 | websWrite(wp, " Start "); |
|---|
| 2028 | websWrite(wp, |
|---|
| 2029 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2030 | vlan_name, start); |
|---|
| 2031 | // max |
|---|
| 2032 | sprintf(vlan_name, "mdhcpmax%d", count); |
|---|
| 2033 | websWrite(wp, " Max "); |
|---|
| 2034 | websWrite(wp, |
|---|
| 2035 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2036 | vlan_name, max); |
|---|
| 2037 | sprintf(vlan_name, "mdhcpleasetime%d", count); |
|---|
| 2038 | websWrite(wp, " Leasetime "); |
|---|
| 2039 | websWrite(wp, |
|---|
| 2040 | "<input class=\"num\" name=\"%s\" size=\"5\" value=\"%s\" />\n", |
|---|
| 2041 | vlan_name, leasetime); |
|---|
| 2042 | // |
|---|
| 2043 | websWrite(wp, |
|---|
| 2044 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"mdhcp_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 2045 | count); |
|---|
| 2046 | websWrite(wp, "</div>\n"); |
|---|
| 2047 | count++; |
|---|
| 2048 | } |
|---|
| 2049 | totalcount = count; |
|---|
| 2050 | int i; |
|---|
| 2051 | |
|---|
| 2052 | for (i = count; i < realcount; i++) { |
|---|
| 2053 | char vlan_name[32]; |
|---|
| 2054 | |
|---|
| 2055 | // sprintf (mdhcp_name, "%s.%s", tag, port); |
|---|
| 2056 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2057 | websWrite(wp, "<div class=\"label\">DHCP %d</div>\n", count); |
|---|
| 2058 | // interface |
|---|
| 2059 | sprintf(vlan_name, "mdhcpifname%d", count); |
|---|
| 2060 | showOptions(wp, vlan_name, buffer, ""); |
|---|
| 2061 | // on off |
|---|
| 2062 | sprintf(vlan_name, "mdhcpon%d", count); |
|---|
| 2063 | showOptions(wp, vlan_name, "On Off", ""); |
|---|
| 2064 | // start |
|---|
| 2065 | sprintf(vlan_name, "mdhcpstart%d", count); |
|---|
| 2066 | websWrite(wp, " Start "); |
|---|
| 2067 | websWrite(wp, |
|---|
| 2068 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2069 | vlan_name, "100"); |
|---|
| 2070 | // max |
|---|
| 2071 | sprintf(vlan_name, "mdhcpmax%d", count); |
|---|
| 2072 | websWrite(wp, " Max "); |
|---|
| 2073 | websWrite(wp, |
|---|
| 2074 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2075 | vlan_name, "50"); |
|---|
| 2076 | sprintf(vlan_name, "mdhcpleasetime%d", count); |
|---|
| 2077 | websWrite(wp, " Leasetime "); |
|---|
| 2078 | websWrite(wp, |
|---|
| 2079 | "<input class=\"num\" name=\"%s\" size=\"5\" value=\"%s\" />\n", |
|---|
| 2080 | vlan_name, "3600"); |
|---|
| 2081 | websWrite(wp, |
|---|
| 2082 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"mdhcp_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 2083 | i); |
|---|
| 2084 | websWrite(wp, "</div>\n"); |
|---|
| 2085 | totalcount++; |
|---|
| 2086 | } |
|---|
| 2087 | char var[32]; |
|---|
| 2088 | |
|---|
| 2089 | sprintf(var, "%d", totalcount); |
|---|
| 2090 | nvram_set("mdhcpd_count", var); |
|---|
| 2091 | websWrite(wp, |
|---|
| 2092 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.add + \"\\\" onclick=\\\"mdhcp_add_submit(this.form)\\\" />\");\n//]]>\n</script>\n"); |
|---|
| 2093 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 2094 | |
|---|
| 2095 | } |
|---|
| 2096 | |
|---|
| 2097 | void ej_show_bridgenames(webs_t wp, int argc, char_t ** argv) |
|---|
| 2098 | { |
|---|
| 2099 | char buffer[256]; |
|---|
| 2100 | int count = 0; |
|---|
| 2101 | static char word[256]; |
|---|
| 2102 | char *next, *wordlist; |
|---|
| 2103 | |
|---|
| 2104 | memset(buffer, 0, 256); |
|---|
| 2105 | getIfList(buffer, NULL); |
|---|
| 2106 | int realcount = atoi(nvram_default_get("bridges_count", "0")); |
|---|
| 2107 | |
|---|
| 2108 | wordlist = nvram_safe_get("bridges"); |
|---|
| 2109 | foreach(word, wordlist, next) { |
|---|
| 2110 | |
|---|
| 2111 | char *stp = word; |
|---|
| 2112 | char *bridge = strsep(&stp, ">"); |
|---|
| 2113 | char *prio = stp; |
|---|
| 2114 | |
|---|
| 2115 | stp = strsep(&prio, ">"); |
|---|
| 2116 | char *mtu = prio; |
|---|
| 2117 | |
|---|
| 2118 | prio = strsep(&mtu, ">"); |
|---|
| 2119 | if (!prio) { |
|---|
| 2120 | prio = mtu; |
|---|
| 2121 | mtu = "1500"; |
|---|
| 2122 | } |
|---|
| 2123 | |
|---|
| 2124 | /* char *stp = word; |
|---|
| 2125 | char *bridge = strsep( &stp, ">" ); |
|---|
| 2126 | char *mtu = stp; |
|---|
| 2127 | char *prio = strsep( &mtu, ">" ); |
|---|
| 2128 | */ |
|---|
| 2129 | if (!bridge || !stp) |
|---|
| 2130 | break; |
|---|
| 2131 | |
|---|
| 2132 | char vlan_name[32]; |
|---|
| 2133 | |
|---|
| 2134 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2135 | websWrite(wp, "<div class=\"label\">Bridge %d</div>\n", count); |
|---|
| 2136 | sprintf(vlan_name, "bridgename%d", count); |
|---|
| 2137 | websWrite(wp, |
|---|
| 2138 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2139 | vlan_name, bridge); |
|---|
| 2140 | websWrite(wp, " STP "); |
|---|
| 2141 | sprintf(vlan_name, "bridgestp%d", count); |
|---|
| 2142 | showOptions(wp, vlan_name, "On Off", stp); |
|---|
| 2143 | websWrite(wp, " Prio "); |
|---|
| 2144 | sprintf(vlan_name, "bridgeprio%d", count); |
|---|
| 2145 | websWrite(wp, |
|---|
| 2146 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2147 | vlan_name, prio != NULL ? prio : "32768"); |
|---|
| 2148 | websWrite(wp, " MTU "); |
|---|
| 2149 | sprintf(vlan_name, "bridgemtu%d", count); |
|---|
| 2150 | websWrite(wp, |
|---|
| 2151 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2152 | vlan_name, mtu != NULL ? mtu : "1500"); |
|---|
| 2153 | websWrite(wp, |
|---|
| 2154 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"bridge_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 2155 | count); |
|---|
| 2156 | websWrite(wp, "</div>\n"); |
|---|
| 2157 | show_ipnetmask(wp, bridge); |
|---|
| 2158 | count++; |
|---|
| 2159 | } |
|---|
| 2160 | int i; |
|---|
| 2161 | int totalcount = count; |
|---|
| 2162 | |
|---|
| 2163 | for (i = count; i < realcount; i++) { |
|---|
| 2164 | char vlan_name[32]; |
|---|
| 2165 | |
|---|
| 2166 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2167 | websWrite(wp, "<div class=\"label\">Bridge %d</div>\n", i); |
|---|
| 2168 | sprintf(vlan_name, "bridgename%d", i); |
|---|
| 2169 | websWrite(wp, "<input class=\"num\" name=\"%s\"size=\"5\" />\n", |
|---|
| 2170 | vlan_name); |
|---|
| 2171 | websWrite(wp, " STP "); |
|---|
| 2172 | sprintf(vlan_name, "bridgestp%d", i); |
|---|
| 2173 | showOptions(wp, vlan_name, "On Off", "On"); |
|---|
| 2174 | websWrite(wp, " Prio "); |
|---|
| 2175 | sprintf(vlan_name, "bridgeprio%d", i); |
|---|
| 2176 | websWrite(wp, |
|---|
| 2177 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2178 | vlan_name, "32768"); |
|---|
| 2179 | websWrite(wp, " MTU "); |
|---|
| 2180 | sprintf(vlan_name, "bridgemtu%d", count); |
|---|
| 2181 | websWrite(wp, |
|---|
| 2182 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2183 | vlan_name, "1500"); |
|---|
| 2184 | websWrite(wp, |
|---|
| 2185 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"bridge_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 2186 | i); |
|---|
| 2187 | websWrite(wp, "</div>\n"); |
|---|
| 2188 | totalcount++; |
|---|
| 2189 | } |
|---|
| 2190 | websWrite(wp, |
|---|
| 2191 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.add + \"\\\" onclick=\\\"bridge_add_submit(this.form)\\\" />\");\n//]]>\n</script>\n"); |
|---|
| 2192 | char var[32]; |
|---|
| 2193 | |
|---|
| 2194 | sprintf(var, "%d", totalcount); |
|---|
| 2195 | nvram_set("bridges_count", var); |
|---|
| 2196 | } |
|---|
| 2197 | |
|---|
| 2198 | void ej_show_bridgetable(webs_t wp, int argc, char_t ** argv) |
|---|
| 2199 | { |
|---|
| 2200 | //#ifdef HAVE_MICRO // brctl N/A in micro |
|---|
| 2201 | // return; |
|---|
| 2202 | //#endif |
|---|
| 2203 | |
|---|
| 2204 | FILE *f; |
|---|
| 2205 | char buf[128]; |
|---|
| 2206 | char brname[32]; |
|---|
| 2207 | char brstp[8]; |
|---|
| 2208 | char brif[16]; |
|---|
| 2209 | int count = 0; |
|---|
| 2210 | |
|---|
| 2211 | system2("brctl show > /tmp/.brtable"); |
|---|
| 2212 | |
|---|
| 2213 | if ((f = fopen("/tmp/.brtable", "r")) != NULL) { |
|---|
| 2214 | |
|---|
| 2215 | while (fgets(buf, sizeof(buf), f)) { |
|---|
| 2216 | |
|---|
| 2217 | if (count) // skip line 0 |
|---|
| 2218 | { |
|---|
| 2219 | strcpy(brname, ""); |
|---|
| 2220 | strcpy(brstp, ""); |
|---|
| 2221 | strcpy(brif, ""); |
|---|
| 2222 | |
|---|
| 2223 | if (strncmp(buf, "\t\t\t", 3) != 0) { |
|---|
| 2224 | if (count != 1) |
|---|
| 2225 | websWrite(wp, "\',"); // close |
|---|
| 2226 | sscanf(buf, "%s %*s %s %s", brname, |
|---|
| 2227 | brstp, brif); |
|---|
| 2228 | websWrite(wp, "\'%s\',\'%s\',\'%s ", |
|---|
| 2229 | brname, brstp, brif); |
|---|
| 2230 | } else { |
|---|
| 2231 | sscanf(buf, "%s", brif); |
|---|
| 2232 | websWrite(wp, "%s ", brif); |
|---|
| 2233 | } |
|---|
| 2234 | } |
|---|
| 2235 | count++; |
|---|
| 2236 | } |
|---|
| 2237 | |
|---|
| 2238 | websWrite(wp, "\'"); // close |
|---|
| 2239 | fclose(f); |
|---|
| 2240 | unlink("/tmp/.brtable"); |
|---|
| 2241 | } |
|---|
| 2242 | return; |
|---|
| 2243 | } |
|---|
| 2244 | |
|---|
| 2245 | void ej_show_bridgeifnames(webs_t wp, int argc, char_t ** argv) |
|---|
| 2246 | { |
|---|
| 2247 | char bufferif[512]; |
|---|
| 2248 | char bufferif2[256]; |
|---|
| 2249 | char finalbuffer[512]; |
|---|
| 2250 | int count = 0; |
|---|
| 2251 | static char word[256]; |
|---|
| 2252 | char *next, *wordlist; |
|---|
| 2253 | |
|---|
| 2254 | memset(bufferif, 0, 512); |
|---|
| 2255 | memset(bufferif2, 0, 256); |
|---|
| 2256 | getIfList(bufferif, "eth"); |
|---|
| 2257 | #ifdef HAVE_GATEWORX |
|---|
| 2258 | getIfList(bufferif2, "ixp"); |
|---|
| 2259 | sprintf(bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2260 | #endif |
|---|
| 2261 | |
|---|
| 2262 | memset(bufferif2, 0, 256); |
|---|
| 2263 | getIfList(bufferif2, "vlan"); |
|---|
| 2264 | sprintf(bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2265 | |
|---|
| 2266 | memset(bufferif2, 0, 256); |
|---|
| 2267 | getIfList(bufferif2, "wl"); |
|---|
| 2268 | sprintf(bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2269 | |
|---|
| 2270 | memset(bufferif2, 0, 256); |
|---|
| 2271 | getIfList(bufferif2, "ofdm"); |
|---|
| 2272 | sprintf(bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2273 | |
|---|
| 2274 | #ifdef HAVE_RT2880 |
|---|
| 2275 | memset(bufferif2, 0, 256); |
|---|
| 2276 | getIfList(bufferif2, "ra"); |
|---|
| 2277 | sprintf(bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2278 | #endif |
|---|
| 2279 | memset(bufferif2, 0, 256); |
|---|
| 2280 | getIfList(bufferif2, "br"); |
|---|
| 2281 | foreach(word, bufferif2, next) { |
|---|
| 2282 | if (contains(word, '.')) |
|---|
| 2283 | sprintf(bufferif, "%s %s", bufferif, word); |
|---|
| 2284 | } |
|---|
| 2285 | int i; |
|---|
| 2286 | |
|---|
| 2287 | #ifdef HAVE_MADWIFI |
|---|
| 2288 | // memset(bufferif2, 0, 256); |
|---|
| 2289 | // getIfList(bufferif2, "ath"); |
|---|
| 2290 | // foreach(word, bufferif2, next) { |
|---|
| 2291 | // if (contains(word, '.')) |
|---|
| 2292 | // sprintf(bufferif, "%s %s", bufferif, word); |
|---|
| 2293 | // } |
|---|
| 2294 | int c = getifcount("wifi"); |
|---|
| 2295 | |
|---|
| 2296 | for (i = 0; i < c; i++) { |
|---|
| 2297 | char ath[32]; |
|---|
| 2298 | |
|---|
| 2299 | // sprintf(ath, "ath%d_bridged", i); |
|---|
| 2300 | // if (nvram_default_match(ath, "1", "1")) |
|---|
| 2301 | { |
|---|
| 2302 | sprintf(bufferif, "%s ath%d", bufferif, i); |
|---|
| 2303 | char vifs[32]; |
|---|
| 2304 | |
|---|
| 2305 | sprintf(vifs, "ath%d_vifs", i); |
|---|
| 2306 | sprintf(bufferif, "%s %s", bufferif, |
|---|
| 2307 | nvram_safe_get(vifs)); |
|---|
| 2308 | } |
|---|
| 2309 | } |
|---|
| 2310 | #endif |
|---|
| 2311 | #ifdef HAVE_BONDING |
|---|
| 2312 | c = atoi(nvram_default_get("bonding_number", "1")); |
|---|
| 2313 | for (i = 0; i < c; i++) { |
|---|
| 2314 | sprintf(bufferif, "%s bond%d", bufferif, i); |
|---|
| 2315 | } |
|---|
| 2316 | #endif |
|---|
| 2317 | #ifdef HAVE_EOP_TUNNEL |
|---|
| 2318 | for (i = 1; i < 11; i++) { |
|---|
| 2319 | char EOP[32]; |
|---|
| 2320 | |
|---|
| 2321 | if (nvram_nmatch("1", "oet%d_en", i) |
|---|
| 2322 | && nvram_nmatch("0", "oet%d_bridged", i)) { |
|---|
| 2323 | sprintf(EOP, "oet%d", i); |
|---|
| 2324 | sprintf(bufferif, "%s %s", bufferif, EOP); |
|---|
| 2325 | } |
|---|
| 2326 | } |
|---|
| 2327 | #endif |
|---|
| 2328 | char buffer[256]; |
|---|
| 2329 | |
|---|
| 2330 | memset(buffer, 0, 256); |
|---|
| 2331 | getIfList(buffer, "br"); |
|---|
| 2332 | |
|---|
| 2333 | memset(finalbuffer, 0, 256); |
|---|
| 2334 | foreach(word, buffer, next) { |
|---|
| 2335 | if (!contains(word, '.')) |
|---|
| 2336 | sprintf(finalbuffer, "%s %s", finalbuffer, word); |
|---|
| 2337 | } |
|---|
| 2338 | char *checkbuffer = malloc(strlen(finalbuffer) + 6); |
|---|
| 2339 | memset(checkbuffer, 0, strlen(finalbuffer) + 6); |
|---|
| 2340 | strcpy(checkbuffer, "none "); |
|---|
| 2341 | strcat(checkbuffer, finalbuffer); |
|---|
| 2342 | strcpy(finalbuffer, checkbuffer); |
|---|
| 2343 | free(checkbuffer); |
|---|
| 2344 | int realcount = atoi(nvram_default_get("bridgesif_count", "0")); |
|---|
| 2345 | |
|---|
| 2346 | wordlist = nvram_safe_get("bridgesif"); |
|---|
| 2347 | foreach(word, wordlist, next) { |
|---|
| 2348 | char *port = word; |
|---|
| 2349 | char *tag = strsep(&port, ">"); |
|---|
| 2350 | char *prio = port; |
|---|
| 2351 | |
|---|
| 2352 | strsep(&prio, ">"); |
|---|
| 2353 | if (!tag || !port) |
|---|
| 2354 | break; |
|---|
| 2355 | char vlan_name[32]; |
|---|
| 2356 | |
|---|
| 2357 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2358 | websWrite(wp, "<div class=\"label\">Assignment %d</div>\n", |
|---|
| 2359 | count); |
|---|
| 2360 | sprintf(vlan_name, "bridge%d", count); |
|---|
| 2361 | showOptions(wp, vlan_name, finalbuffer, tag); |
|---|
| 2362 | websWrite(wp, " Interface "); |
|---|
| 2363 | sprintf(vlan_name, "bridgeif%d", count); |
|---|
| 2364 | showOptions(wp, vlan_name, bufferif, port); |
|---|
| 2365 | websWrite(wp, " Prio "); |
|---|
| 2366 | sprintf(vlan_name, "bridgeifprio%d", count); |
|---|
| 2367 | websWrite(wp, |
|---|
| 2368 | "<input class=\"num\" name=\"%s\"size=\"3\" value=\"%s\" />\n", |
|---|
| 2369 | vlan_name, prio != NULL ? prio : "63"); |
|---|
| 2370 | websWrite(wp, |
|---|
| 2371 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"bridgeif_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 2372 | count); |
|---|
| 2373 | websWrite(wp, "</div>\n"); |
|---|
| 2374 | count++; |
|---|
| 2375 | } |
|---|
| 2376 | int totalcount = count; |
|---|
| 2377 | |
|---|
| 2378 | for (i = count; i < realcount; i++) { |
|---|
| 2379 | char vlan_name[32]; |
|---|
| 2380 | |
|---|
| 2381 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2382 | websWrite(wp, "<div class=\"label\">Assignment %d</div>\n", i); |
|---|
| 2383 | sprintf(vlan_name, "bridge%d", i); |
|---|
| 2384 | showOptions(wp, vlan_name, finalbuffer, ""); |
|---|
| 2385 | websWrite(wp, " Interface "); |
|---|
| 2386 | sprintf(vlan_name, "bridgeif%d", i); |
|---|
| 2387 | showOptions(wp, vlan_name, bufferif, ""); |
|---|
| 2388 | websWrite(wp, " Prio "); |
|---|
| 2389 | sprintf(vlan_name, "bridgeifprio%d", i); |
|---|
| 2390 | websWrite(wp, |
|---|
| 2391 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2392 | vlan_name, "63"); |
|---|
| 2393 | websWrite(wp, |
|---|
| 2394 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"bridgeif_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 2395 | i); |
|---|
| 2396 | websWrite(wp, "</div>\n"); |
|---|
| 2397 | totalcount++; |
|---|
| 2398 | } |
|---|
| 2399 | websWrite(wp, |
|---|
| 2400 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.add + \"\\\" onclick=\\\"bridgeif_add_submit(this.form)\\\" />\");\n//]]>\n</script>\n"); |
|---|
| 2401 | char var[32]; |
|---|
| 2402 | |
|---|
| 2403 | sprintf(var, "%d", totalcount); |
|---|
| 2404 | nvram_set("bridgesif_count", var); |
|---|
| 2405 | } |
|---|
| 2406 | |
|---|
| 2407 | #endif |
|---|
| 2408 | #if 0 |
|---|
| 2409 | static void |
|---|
| 2410 | showDynOption(webs_t wp, char *propname, char *nvname, char *options[], |
|---|
| 2411 | char *names[]) |
|---|
| 2412 | { |
|---|
| 2413 | int i; |
|---|
| 2414 | |
|---|
| 2415 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2416 | websWrite(wp, |
|---|
| 2417 | "<div class=\"label\">%s</div><select name=\"%s\">\n", |
|---|
| 2418 | propname, nvname); |
|---|
| 2419 | for (i = 0; options[i] != NULL; i++) { |
|---|
| 2420 | websWrite(wp, |
|---|
| 2421 | "<option value=\"%s\" %s>Off</option>\n", |
|---|
| 2422 | names[i], nvram_match(nvname, |
|---|
| 2423 | options[i]) ? |
|---|
| 2424 | "selected=\"selected\"" : ""); |
|---|
| 2425 | } |
|---|
| 2426 | websWrite(wp, "</div>\n"); |
|---|
| 2427 | |
|---|
| 2428 | } |
|---|
| 2429 | #endif |
|---|
| 2430 | |
|---|
| 2431 | static void show_channel(webs_t wp, char *dev, char *prefix, int type) |
|---|
| 2432 | { |
|---|
| 2433 | char wl_mode[16]; |
|---|
| 2434 | |
|---|
| 2435 | sprintf(wl_mode, "%s_mode", prefix); |
|---|
| 2436 | char wl_net_mode[16]; |
|---|
| 2437 | |
|---|
| 2438 | sprintf(wl_net_mode, "%s_net_mode", prefix); |
|---|
| 2439 | if (nvram_match(wl_net_mode, "disabled")) |
|---|
| 2440 | return; |
|---|
| 2441 | #ifdef HAVE_RT2880 |
|---|
| 2442 | if (nvram_match(wl_mode, "ap") || nvram_match(wl_mode, "wdsap") |
|---|
| 2443 | || nvram_match(wl_mode, "apsta") || nvram_match(wl_mode, "apstawet") |
|---|
| 2444 | || nvram_match(wl_mode, "infra")) |
|---|
| 2445 | #else |
|---|
| 2446 | if (nvram_match(wl_mode, "ap") || nvram_match(wl_mode, "wdsap") |
|---|
| 2447 | || nvram_match(wl_mode, "infra")) |
|---|
| 2448 | #endif |
|---|
| 2449 | { |
|---|
| 2450 | char wl_channel[16]; |
|---|
| 2451 | |
|---|
| 2452 | sprintf(wl_channel, "%s_channel", prefix); |
|---|
| 2453 | char wl_wchannel[16]; |
|---|
| 2454 | |
|---|
| 2455 | sprintf(wl_wchannel, "%s_wchannel", prefix); |
|---|
| 2456 | char wl_nbw[16]; |
|---|
| 2457 | |
|---|
| 2458 | nvram_default_get(wl_wchannel, "0"); |
|---|
| 2459 | sprintf(wl_nbw, "%s_nbw", prefix); |
|---|
| 2460 | |
|---|
| 2461 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2462 | websWrite(wp, |
|---|
| 2463 | "<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", |
|---|
| 2464 | wl_channel); |
|---|
| 2465 | #ifdef HAVE_MADWIFI |
|---|
| 2466 | struct wifi_channels *chan; |
|---|
| 2467 | char cn[32]; |
|---|
| 2468 | char fr[32]; |
|---|
| 2469 | |
|---|
| 2470 | #ifdef HAVE_MADWIFI_MIMO |
|---|
| 2471 | if (is_ar5008(prefix)) { |
|---|
| 2472 | chan = list_channels_11n(prefix); |
|---|
| 2473 | if (chan == NULL) |
|---|
| 2474 | chan = list_channels_11n(dev); |
|---|
| 2475 | } else |
|---|
| 2476 | #endif |
|---|
| 2477 | { |
|---|
| 2478 | chan = list_channels(prefix); |
|---|
| 2479 | if (chan == NULL) |
|---|
| 2480 | chan = list_channels(dev); |
|---|
| 2481 | } |
|---|
| 2482 | |
|---|
| 2483 | if (chan != NULL) { |
|---|
| 2484 | // int cnt = getchannelcount (); |
|---|
| 2485 | websWrite(wp, |
|---|
| 2486 | "document.write(\"<option value=\\\"0\\\" %s>\" + share.auto + \"</option>\");\n", |
|---|
| 2487 | nvram_match(wl_channel, |
|---|
| 2488 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 2489 | : ""); |
|---|
| 2490 | int i = 0; |
|---|
| 2491 | |
|---|
| 2492 | while (chan[i].freq != -1) { |
|---|
| 2493 | cprintf("%d\n", chan[i].channel); |
|---|
| 2494 | cprintf("%d\n", chan[i].freq); |
|---|
| 2495 | |
|---|
| 2496 | sprintf(cn, "%d", chan[i].channel); |
|---|
| 2497 | sprintf(fr, "%d", chan[i].freq); |
|---|
| 2498 | int freq = get_wififreq(prefix, chan[i].freq); |
|---|
| 2499 | if (freq != -1) |
|---|
| 2500 | websWrite(wp, |
|---|
| 2501 | "document.write(\"<option value=\\\"%s\\\" %s>%s - %d MHz</option>\");\n", |
|---|
| 2502 | fr, nvram_match(wl_channel, |
|---|
| 2503 | fr) ? |
|---|
| 2504 | "selected=\\\"selected\\\"" : |
|---|
| 2505 | "", cn, (freq)); |
|---|
| 2506 | // free (chan[i].freq); |
|---|
| 2507 | i++; |
|---|
| 2508 | } |
|---|
| 2509 | free(chan); |
|---|
| 2510 | } |
|---|
| 2511 | #else |
|---|
| 2512 | int instance = 0; |
|---|
| 2513 | |
|---|
| 2514 | if (!strcmp(prefix, "wl1")) |
|---|
| 2515 | instance = 1; |
|---|
| 2516 | /* |
|---|
| 2517 | #if 0 |
|---|
| 2518 | if (type == 1 && !nvram_match(wl_net_mode, "g-only") |
|---|
| 2519 | && !nvram_match(wl_net_mode, "a-only") |
|---|
| 2520 | && !nvram_match(wl_net_mode, "na-only") |
|---|
| 2521 | && !nvram_match(wl_net_mode, "bg-mixed") |
|---|
| 2522 | && nvram_match(wl_nbw, "40")) { |
|---|
| 2523 | int ch = atoi(nvram_nget("wl%d_wchannel", instance)); |
|---|
| 2524 | |
|---|
| 2525 | websWrite(wp, "var max_channel = 2;\n"); |
|---|
| 2526 | websWrite(wp, "var wl%d_channel = '%s';\n", instance, |
|---|
| 2527 | nvram_safe_get(wl_wchannel)); |
|---|
| 2528 | websWrite(wp, |
|---|
| 2529 | "var freq = new Array(\"Auto\",\"2.412\",\"2.417\",\"2.422\",\"2.427\",\"2.432\",\"2.437\",\"2.442\",\"2.447\",\"2.452\",\"2.457\",\"2.462\",\"2.467\",\"2.472\",\"2.484\");\n"); |
|---|
| 2530 | char *sel = ""; |
|---|
| 2531 | |
|---|
| 2532 | if (ch == 0) //wchannel = Auto |
|---|
| 2533 | { |
|---|
| 2534 | websWrite(wp, |
|---|
| 2535 | " document.write(\"<option value=\\\"0\\\" selected=\\\"selected\\\">\"+ share.auto +\"</option>\");\n"); |
|---|
| 2536 | } else { |
|---|
| 2537 | if (nvram_nmatch |
|---|
| 2538 | ("lower", "wl%d_nctrlsb", instance)) |
|---|
| 2539 | sel = "selected=\\\"selected\\\""; |
|---|
| 2540 | |
|---|
| 2541 | websWrite(wp, |
|---|
| 2542 | " document.write(\"<option value=\\\"%d\\\" %s>%d - \"+freq[%d]+\" GHz</option>\");\n", |
|---|
| 2543 | ch - 2, sel, ch - 2, ch - 2); |
|---|
| 2544 | sel = ""; |
|---|
| 2545 | if (nvram_nmatch |
|---|
| 2546 | ("upper", "wl%d_nctrlsb", instance)) |
|---|
| 2547 | sel = "selected=\\\"selected\\\""; |
|---|
| 2548 | websWrite(wp, |
|---|
| 2549 | " document.write(\"<option value=\\\"%d\\\" %s>%d - \"+freq[%d]+\" GHz</option>\");\n", |
|---|
| 2550 | ch + 2, sel, ch + 2, ch + 2); |
|---|
| 2551 | } |
|---|
| 2552 | |
|---|
| 2553 | } else |
|---|
| 2554 | #endif |
|---|
| 2555 | */ |
|---|
| 2556 | { |
|---|
| 2557 | |
|---|
| 2558 | unsigned int chanlist[128]; |
|---|
| 2559 | char *ifn = get_wl_instance_name(instance); |
|---|
| 2560 | int chancount = getchannels(chanlist, ifn); |
|---|
| 2561 | int net_is_a = 0; |
|---|
| 2562 | |
|---|
| 2563 | if (chanlist[0] > 25) |
|---|
| 2564 | net_is_a = 1; |
|---|
| 2565 | |
|---|
| 2566 | // websWrite( wp, "var max_channel = %d;\n", chancount ); |
|---|
| 2567 | // websWrite( wp, "var wl%d_channel = '%s';\n", instance, nvram_safe_get( wl_channel ) ); |
|---|
| 2568 | // websWrite( wp, "var offset = %d;\n", chanlist[0] ); |
|---|
| 2569 | // websWrite( wp, "var buf = \"\";\n" ); |
|---|
| 2570 | // websWrite( wp, "var freq = new Array(\"Auto\"" ); |
|---|
| 2571 | int i, j; |
|---|
| 2572 | |
|---|
| 2573 | // supported 5GHz channels for IEEE 802.11n 40Mhz |
|---|
| 2574 | int na_upper[16] = |
|---|
| 2575 | { 40, 48, 56, 64, 104, 112, 120, 128, 136, 153, 161, |
|---|
| 2576 | 0, 0, 0, 0, 0 |
|---|
| 2577 | }; |
|---|
| 2578 | int na_lower[16] = |
|---|
| 2579 | { 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157, |
|---|
| 2580 | 0, 0, 0, 0, 0 |
|---|
| 2581 | }; |
|---|
| 2582 | |
|---|
| 2583 | websWrite(wp, |
|---|
| 2584 | "document.write(\"<option value=\\\"0\\\" %s>\" + share.auto + \"</option>\");\n", |
|---|
| 2585 | nvram_nmatch("0", "%s_channel", |
|---|
| 2586 | prefix) ? |
|---|
| 2587 | "selected=\\\"selected\\\"" : ""); |
|---|
| 2588 | for (i = 0; i < chancount; i++) { |
|---|
| 2589 | float ofs; |
|---|
| 2590 | |
|---|
| 2591 | if (chanlist[i] < 25) |
|---|
| 2592 | ofs = 2.407f; |
|---|
| 2593 | else |
|---|
| 2594 | ofs = 5.000f; |
|---|
| 2595 | ofs += (float)(chanlist[i] * 0.005f); |
|---|
| 2596 | if (ofs == 2.477f) |
|---|
| 2597 | ofs = 2.484f; // fix: ch 14 is 2.484, not 2.477 GHz |
|---|
| 2598 | // websWrite( wp, ", \"%0.3f\"", ofs ); |
|---|
| 2599 | char channelstring[32]; |
|---|
| 2600 | |
|---|
| 2601 | int showit = 1; |
|---|
| 2602 | |
|---|
| 2603 | if (nvram_match(wl_net_mode, "a-only") |
|---|
| 2604 | || nvram_match(wl_net_mode, "na-only") |
|---|
| 2605 | || nvram_match(wl_net_mode, "n5-only") |
|---|
| 2606 | || (net_is_a |
|---|
| 2607 | && nvram_match(wl_net_mode, "mixed"))) { |
|---|
| 2608 | if (chanlist[i] < 25) |
|---|
| 2609 | showit = 0; |
|---|
| 2610 | } else { |
|---|
| 2611 | if (chanlist[i] > 25) |
|---|
| 2612 | showit = 0; |
|---|
| 2613 | } |
|---|
| 2614 | |
|---|
| 2615 | if ((nvram_match(wl_net_mode, "na-only") |
|---|
| 2616 | || (net_is_a |
|---|
| 2617 | && nvram_match(wl_net_mode, "mixed")) |
|---|
| 2618 | || nvram_match(wl_net_mode, "n5-only")) |
|---|
| 2619 | && nvram_match(wl_nbw, "40")) { |
|---|
| 2620 | showit = 0; |
|---|
| 2621 | j = 0; |
|---|
| 2622 | if (nvram_nmatch |
|---|
| 2623 | ("upper", "%s_nctrlsb", prefix)) { |
|---|
| 2624 | while (na_upper[j]) { |
|---|
| 2625 | if (chanlist[i] == |
|---|
| 2626 | na_upper[j]) { |
|---|
| 2627 | showit = 1; |
|---|
| 2628 | break; |
|---|
| 2629 | } |
|---|
| 2630 | j++; |
|---|
| 2631 | } |
|---|
| 2632 | } else |
|---|
| 2633 | if (nvram_nmatch |
|---|
| 2634 | ("lower", "%s_nctrlsb", |
|---|
| 2635 | prefix)) { |
|---|
| 2636 | while (na_lower[j]) { |
|---|
| 2637 | if (chanlist[i] == |
|---|
| 2638 | na_lower[j]) { |
|---|
| 2639 | showit = 1; |
|---|
| 2640 | break; |
|---|
| 2641 | } |
|---|
| 2642 | j++; |
|---|
| 2643 | } |
|---|
| 2644 | } |
|---|
| 2645 | } |
|---|
| 2646 | |
|---|
| 2647 | if ((nvram_match(wl_net_mode, "n-only") |
|---|
| 2648 | || nvram_match(wl_net_mode, "n2-only") |
|---|
| 2649 | || (!net_is_a |
|---|
| 2650 | && nvram_match(wl_net_mode, "mixed"))) |
|---|
| 2651 | && nvram_match(wl_nbw, "40")) { |
|---|
| 2652 | showit = 0; |
|---|
| 2653 | if (nvram_nmatch |
|---|
| 2654 | ("upper", "%s_nctrlsb", prefix)) { |
|---|
| 2655 | if (chanlist[i] >= 5 |
|---|
| 2656 | && chanlist[i] <= 13) { |
|---|
| 2657 | showit = 1; |
|---|
| 2658 | } |
|---|
| 2659 | } else |
|---|
| 2660 | if (nvram_nmatch |
|---|
| 2661 | ("lower", "%s_nctrlsb", |
|---|
| 2662 | prefix)) { |
|---|
| 2663 | if (chanlist[i] <= 9) { |
|---|
| 2664 | showit = 1; |
|---|
| 2665 | } |
|---|
| 2666 | } |
|---|
| 2667 | } |
|---|
| 2668 | |
|---|
| 2669 | sprintf(channelstring, "%d", chanlist[i]); |
|---|
| 2670 | if (showit) { |
|---|
| 2671 | websWrite(wp, |
|---|
| 2672 | "document.write(\"<option value=\\\"%d\\\" %s>%d - %0.3f GHz</option>\");\n", |
|---|
| 2673 | chanlist[i], |
|---|
| 2674 | nvram_nmatch(channelstring, |
|---|
| 2675 | "%s_channel", |
|---|
| 2676 | prefix) ? |
|---|
| 2677 | "selected=\\\"selected\\\"" : |
|---|
| 2678 | "", chanlist[i], ofs); |
|---|
| 2679 | } |
|---|
| 2680 | } |
|---|
| 2681 | // websWrite( wp, ");\n" ); |
|---|
| 2682 | // websWrite( wp, "for(i=0; i<=max_channel ; i++) {\n" ); |
|---|
| 2683 | // websWrite( wp, " if(i == wl%d_channel) buf = \"selected\";\n", |
|---|
| 2684 | // instance ); |
|---|
| 2685 | // websWrite( wp, " else buf = \"\";\n" ); |
|---|
| 2686 | // websWrite( wp, " if (i==0)\n" ); |
|---|
| 2687 | // websWrite( wp, |
|---|
| 2688 | // " document.write(\"<option value=\"+i+\" \"+buf+\">\" + share.auto + \"</option>\");\n" ); |
|---|
| 2689 | // websWrite( wp, " else\n" ); |
|---|
| 2690 | // websWrite( wp, |
|---|
| 2691 | // " document.write(\"<option value=\"+i+\" \"+buf+\">\"+(i+offset-1)+\" - \"+freq[i]+\" GHz</option>\");\n" ); |
|---|
| 2692 | // websWrite( wp, "}\n" ); |
|---|
| 2693 | } |
|---|
| 2694 | #endif |
|---|
| 2695 | websWrite(wp, "//]]>\n</script></select></div>\n"); |
|---|
| 2696 | } |
|---|
| 2697 | } |
|---|
| 2698 | |
|---|
| 2699 | #ifdef HAVE_MADWIFI |
|---|
| 2700 | static char *ag_rates[] = { "6", "9", "12", "18", "24", "36", "48", "54" }; |
|---|
| 2701 | static char *turbo_rates[] = |
|---|
| 2702 | { "12", "18", "24", "36", "48", "72", "96", "108" }; |
|---|
| 2703 | static char *b_rates[] = { "1", "2", "5.5", "11" }; |
|---|
| 2704 | static char *bg_rates[] = |
|---|
| 2705 | { "1", "2", "5.5", "6", "9", "11", "12", "18", "24", "36", "48", "54" }; |
|---|
| 2706 | // static char *g_rates[] = { "1", "2", "5.5", "11", "12", "18", "24", "36", |
|---|
| 2707 | // "48", "54" }; |
|---|
| 2708 | //static char *xr_rates[] = |
|---|
| 2709 | // { "0.25", "0.5", "1", "2", "3", "6", "9", "12", "18", "24", "36", "48", |
|---|
| 2710 | // "54" |
|---|
| 2711 | //}; |
|---|
| 2712 | static char *half_rates[] = { "3", "4.5", "6", "9", "12", "18", "24", "27" }; |
|---|
| 2713 | static char *quarter_rates[] = |
|---|
| 2714 | { "1.5", "2", "3", "4.5", "6", "9", "12", "13.5" }; |
|---|
| 2715 | static char *subquarter_rates[] = |
|---|
| 2716 | { "0.75", "1", "1.5", "2.25", "3", "4.5", "6", "6.75" }; |
|---|
| 2717 | |
|---|
| 2718 | void show_rates(webs_t wp, char *prefix, int maxrate) |
|---|
| 2719 | { |
|---|
| 2720 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2721 | if (maxrate) { |
|---|
| 2722 | websWrite(wp, |
|---|
| 2723 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label21)</script></div>\n"); |
|---|
| 2724 | websWrite(wp, "<select name=\"%s_maxrate\">\n", prefix); |
|---|
| 2725 | } else { |
|---|
| 2726 | websWrite(wp, |
|---|
| 2727 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label23)</script></div>\n"); |
|---|
| 2728 | websWrite(wp, "<select name=\"%s_minrate\">\n", prefix); |
|---|
| 2729 | } |
|---|
| 2730 | websWrite(wp, "<script type=\"text/javascript\">\n"); |
|---|
| 2731 | websWrite(wp, "//<![CDATA[\n"); |
|---|
| 2732 | char srate[32]; |
|---|
| 2733 | |
|---|
| 2734 | sprintf(srate, "%s_minrate", prefix); |
|---|
| 2735 | char mxrate[32]; |
|---|
| 2736 | |
|---|
| 2737 | sprintf(mxrate, "%s_maxrate", prefix); |
|---|
| 2738 | websWrite(wp, |
|---|
| 2739 | "document.write(\"<option value=\\\"0\\\" %s >\" + share.auto + \"</option>\");\n", |
|---|
| 2740 | nvram_match(srate, "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2741 | websWrite(wp, "//]]>\n"); |
|---|
| 2742 | websWrite(wp, "</script>\n"); |
|---|
| 2743 | char **rate; |
|---|
| 2744 | char **showrates = NULL; |
|---|
| 2745 | int len; |
|---|
| 2746 | char mode[32]; |
|---|
| 2747 | char bw[16]; |
|---|
| 2748 | |
|---|
| 2749 | sprintf(bw, "%s_channelbw", prefix); |
|---|
| 2750 | |
|---|
| 2751 | sprintf(mode, "%s_net_mode", prefix); |
|---|
| 2752 | if (nvram_match(mode, "b-only")) { |
|---|
| 2753 | rate = b_rates; |
|---|
| 2754 | len = sizeof(b_rates) / sizeof(char *); |
|---|
| 2755 | } |
|---|
| 2756 | if (nvram_match(mode, "g-only")) { |
|---|
| 2757 | rate = ag_rates; |
|---|
| 2758 | len = sizeof(ag_rates) / sizeof(char *); |
|---|
| 2759 | if (nvram_match(bw, "40")) { |
|---|
| 2760 | showrates = turbo_rates; |
|---|
| 2761 | } |
|---|
| 2762 | if (nvram_match(bw, "10")) { |
|---|
| 2763 | rate = half_rates; |
|---|
| 2764 | len = sizeof(half_rates) / sizeof(char *); |
|---|
| 2765 | } |
|---|
| 2766 | if (nvram_match(bw, "5")) { |
|---|
| 2767 | rate = quarter_rates; |
|---|
| 2768 | len = sizeof(quarter_rates) / sizeof(char *); |
|---|
| 2769 | } |
|---|
| 2770 | if (nvram_match(bw, "2")) { |
|---|
| 2771 | rate = subquarter_rates; |
|---|
| 2772 | len = sizeof(subquarter_rates) / sizeof(char *); |
|---|
| 2773 | } |
|---|
| 2774 | } |
|---|
| 2775 | if (nvram_match(mode, "a-only")) { |
|---|
| 2776 | rate = ag_rates; |
|---|
| 2777 | len = sizeof(ag_rates) / sizeof(char *); |
|---|
| 2778 | if (nvram_match(bw, "40")) { |
|---|
| 2779 | showrates = turbo_rates; |
|---|
| 2780 | } |
|---|
| 2781 | if (nvram_match(bw, "10")) { |
|---|
| 2782 | rate = half_rates; |
|---|
| 2783 | len = sizeof(half_rates) / sizeof(char *); |
|---|
| 2784 | } |
|---|
| 2785 | if (nvram_match(bw, "5")) { |
|---|
| 2786 | rate = quarter_rates; |
|---|
| 2787 | len = sizeof(quarter_rates) / sizeof(char *); |
|---|
| 2788 | } |
|---|
| 2789 | if (nvram_match(bw, "2")) { |
|---|
| 2790 | rate = subquarter_rates; |
|---|
| 2791 | len = sizeof(subquarter_rates) / sizeof(char *); |
|---|
| 2792 | } |
|---|
| 2793 | } |
|---|
| 2794 | if (nvram_match(mode, "bg-mixed")) { |
|---|
| 2795 | rate = bg_rates; |
|---|
| 2796 | len = sizeof(bg_rates) / sizeof(char *); |
|---|
| 2797 | if (nvram_match(bw, "10")) { |
|---|
| 2798 | rate = half_rates; |
|---|
| 2799 | len = sizeof(half_rates) / sizeof(char *); |
|---|
| 2800 | } |
|---|
| 2801 | if (nvram_match(bw, "5")) { |
|---|
| 2802 | rate = quarter_rates; |
|---|
| 2803 | len = sizeof(quarter_rates) / sizeof(char *); |
|---|
| 2804 | } |
|---|
| 2805 | if (nvram_match(bw, "2")) { |
|---|
| 2806 | rate = subquarter_rates; |
|---|
| 2807 | len = sizeof(subquarter_rates) / sizeof(char *); |
|---|
| 2808 | } |
|---|
| 2809 | } |
|---|
| 2810 | if (nvram_match(mode, "mixed")) { |
|---|
| 2811 | rate = bg_rates; |
|---|
| 2812 | len = sizeof(bg_rates) / sizeof(char *); |
|---|
| 2813 | if (nvram_match(bw, "40")) { |
|---|
| 2814 | rate = ag_rates; |
|---|
| 2815 | len = sizeof(ag_rates) / sizeof(char *); |
|---|
| 2816 | showrates = turbo_rates; |
|---|
| 2817 | } |
|---|
| 2818 | if (nvram_match(bw, "10")) { |
|---|
| 2819 | rate = half_rates; |
|---|
| 2820 | len = sizeof(half_rates) / sizeof(char *); |
|---|
| 2821 | } |
|---|
| 2822 | if (nvram_match(bw, "5")) { |
|---|
| 2823 | rate = quarter_rates; |
|---|
| 2824 | len = sizeof(quarter_rates) / sizeof(char *); |
|---|
| 2825 | } |
|---|
| 2826 | if (nvram_match(bw, "2")) { |
|---|
| 2827 | rate = subquarter_rates; |
|---|
| 2828 | len = sizeof(subquarter_rates) / sizeof(char *); |
|---|
| 2829 | } |
|---|
| 2830 | } |
|---|
| 2831 | int i; |
|---|
| 2832 | |
|---|
| 2833 | for (i = 0; i < len; i++) { |
|---|
| 2834 | if (maxrate) { |
|---|
| 2835 | int offset = 0; |
|---|
| 2836 | |
|---|
| 2837 | if (nvram_match(mode, "g-only") |
|---|
| 2838 | && nvram_match(bw, "20")) |
|---|
| 2839 | offset = 4; |
|---|
| 2840 | char comp[32]; |
|---|
| 2841 | |
|---|
| 2842 | sprintf(comp, "%d", i + 1 + offset); |
|---|
| 2843 | if (showrates) |
|---|
| 2844 | websWrite(wp, |
|---|
| 2845 | "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 2846 | i + 1 + offset, nvram_match(mxrate, |
|---|
| 2847 | comp) ? |
|---|
| 2848 | "selected=\"selected\"" : "", |
|---|
| 2849 | showrates[i]); |
|---|
| 2850 | else |
|---|
| 2851 | websWrite(wp, |
|---|
| 2852 | "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 2853 | i + 1 + offset, nvram_match(mxrate, |
|---|
| 2854 | comp) ? |
|---|
| 2855 | "selected=\"selected\"" : "", |
|---|
| 2856 | rate[i]); |
|---|
| 2857 | } else { |
|---|
| 2858 | int offset = 0; |
|---|
| 2859 | |
|---|
| 2860 | if (nvram_match(mode, "g-only") |
|---|
| 2861 | && nvram_match(bw, "20")) |
|---|
| 2862 | offset = 4; |
|---|
| 2863 | char comp[32]; |
|---|
| 2864 | |
|---|
| 2865 | sprintf(comp, "%d", i + 1 + offset); |
|---|
| 2866 | if (showrates) |
|---|
| 2867 | websWrite(wp, |
|---|
| 2868 | "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 2869 | i + 1 + offset, nvram_match(srate, |
|---|
| 2870 | comp) ? |
|---|
| 2871 | "selected=\"selected\"" : "", |
|---|
| 2872 | showrates[i]); |
|---|
| 2873 | else |
|---|
| 2874 | websWrite(wp, |
|---|
| 2875 | "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 2876 | i + 1 + offset, nvram_match(srate, |
|---|
| 2877 | comp) ? |
|---|
| 2878 | "selected=\"selected\"" : "", |
|---|
| 2879 | rate[i]); |
|---|
| 2880 | |
|---|
| 2881 | } |
|---|
| 2882 | } |
|---|
| 2883 | websWrite(wp, "</select>\n"); |
|---|
| 2884 | websWrite(wp, "<span class=\"default\">\n"); |
|---|
| 2885 | websWrite(wp, "<script type=\"text/javascript\">\n"); |
|---|
| 2886 | websWrite(wp, "//<![CDATA[\n"); |
|---|
| 2887 | websWrite(wp, |
|---|
| 2888 | "document.write(\"(\" + share.deflt + \": \" + share.auto + \")\");\n"); |
|---|
| 2889 | websWrite(wp, "//]]\n"); |
|---|
| 2890 | websWrite(wp, "</script></span></div>\n"); |
|---|
| 2891 | |
|---|
| 2892 | } |
|---|
| 2893 | #endif |
|---|
| 2894 | static void show_netmode(webs_t wp, char *prefix) |
|---|
| 2895 | { |
|---|
| 2896 | char wl_net_mode[16]; |
|---|
| 2897 | |
|---|
| 2898 | sprintf(wl_net_mode, "%s_net_mode", prefix); |
|---|
| 2899 | |
|---|
| 2900 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2901 | websWrite(wp, |
|---|
| 2902 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label2)</script></div><select name=\"%s\">\n", |
|---|
| 2903 | wl_net_mode); |
|---|
| 2904 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 2905 | websWrite(wp, |
|---|
| 2906 | "document.write(\"<option value=\\\"disabled\\\" %s>\" + share.disabled + \"</option>\");\n", |
|---|
| 2907 | nvram_match(wl_net_mode, |
|---|
| 2908 | "disabled") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2909 | websWrite(wp, |
|---|
| 2910 | "document.write(\"<option value=\\\"mixed\\\" %s>\" + wl_basic.mixed + \"</option>\");\n", |
|---|
| 2911 | nvram_match(wl_net_mode, |
|---|
| 2912 | "mixed") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2913 | |
|---|
| 2914 | if (has_mimo(prefix) && has_2ghz(prefix)) { |
|---|
| 2915 | websWrite(wp, |
|---|
| 2916 | "document.write(\"<option value=\\\"bg-mixed\\\" %s>\" + wl_basic.bg + \"</option>\");\n", |
|---|
| 2917 | nvram_match(wl_net_mode, |
|---|
| 2918 | "bg-mixed") ? "selected=\\\"selected\\\"" |
|---|
| 2919 | : ""); |
|---|
| 2920 | } |
|---|
| 2921 | #ifdef HAVE_WHRAG108 |
|---|
| 2922 | if (!strcmp(prefix, "ath1")) |
|---|
| 2923 | #endif |
|---|
| 2924 | #ifdef HAVE_TW6600 |
|---|
| 2925 | if (!strcmp(prefix, "ath1")) |
|---|
| 2926 | #endif |
|---|
| 2927 | |
|---|
| 2928 | if (has_2ghz(prefix)) { |
|---|
| 2929 | websWrite(wp, |
|---|
| 2930 | "document.write(\"<option value=\\\"b-only\\\" %s>\" + wl_basic.b + \"</option>\");\n", |
|---|
| 2931 | nvram_match(wl_net_mode, |
|---|
| 2932 | "b-only") ? |
|---|
| 2933 | "selected=\\\"selected\\\"" : ""); |
|---|
| 2934 | } |
|---|
| 2935 | #ifdef HAVE_MADWIFI |
|---|
| 2936 | if (has_2ghz(prefix)) { |
|---|
| 2937 | |
|---|
| 2938 | #ifdef HAVE_WHRAG108 |
|---|
| 2939 | if (!strcmp(prefix, "ath1")) |
|---|
| 2940 | #endif |
|---|
| 2941 | #ifdef HAVE_TW6600 |
|---|
| 2942 | if (!strcmp(prefix, "ath1")) |
|---|
| 2943 | #endif |
|---|
| 2944 | websWrite(wp, |
|---|
| 2945 | "document.write(\"<option value=\\\"g-only\\\" %s>\" + wl_basic.g + \"</option>\");\n", |
|---|
| 2946 | nvram_match(wl_net_mode, |
|---|
| 2947 | "g-only") ? |
|---|
| 2948 | "selected=\\\"selected\\\"" : ""); |
|---|
| 2949 | #ifdef HAVE_WHRAG108 |
|---|
| 2950 | if (!strcmp(prefix, "ath1")) |
|---|
| 2951 | #endif |
|---|
| 2952 | #ifdef HAVE_TW6600 |
|---|
| 2953 | if (!strcmp(prefix, "ath1")) |
|---|
| 2954 | #endif |
|---|
| 2955 | #if !defined(HAVE_LS5) || defined(HAVE_EOC5610) |
|---|
| 2956 | websWrite(wp, |
|---|
| 2957 | "document.write(\"<option value=\\\"bg-mixed\\\" %s>\" + wl_basic.bg + \"</option>\");\n", |
|---|
| 2958 | nvram_match(wl_net_mode, |
|---|
| 2959 | "bg-mixed") ? |
|---|
| 2960 | "selected=\\\"selected\\\"" : ""); |
|---|
| 2961 | #endif |
|---|
| 2962 | } |
|---|
| 2963 | #else |
|---|
| 2964 | #ifdef HAVE_WHRAG108 |
|---|
| 2965 | if (!strcmp(prefix, "ath1")) |
|---|
| 2966 | #endif |
|---|
| 2967 | #if !defined(HAVE_LS5) || defined(HAVE_EOC5610) |
|---|
| 2968 | |
|---|
| 2969 | if (has_2ghz(prefix)) { |
|---|
| 2970 | websWrite(wp, |
|---|
| 2971 | "document.write(\"<option value=\\\"g-only\\\" %s>\" + wl_basic.g + \"</option>\");\n", |
|---|
| 2972 | nvram_match(wl_net_mode, |
|---|
| 2973 | "g-only") ? |
|---|
| 2974 | "selected=\\\"selected\\\"" : ""); |
|---|
| 2975 | } |
|---|
| 2976 | if (has_mimo(prefix) && has_2ghz(prefix)) { |
|---|
| 2977 | websWrite(wp, |
|---|
| 2978 | "document.write(\"<option value=\\\"ng-only\\\" %s>\" + wl_basic.ng + \"</option>\");\n", |
|---|
| 2979 | nvram_match(wl_net_mode, |
|---|
| 2980 | "ng-only") ? |
|---|
| 2981 | "selected=\\\"selected\\\"" : ""); |
|---|
| 2982 | } |
|---|
| 2983 | #endif |
|---|
| 2984 | #endif |
|---|
| 2985 | if (has_mimo(prefix)) { |
|---|
| 2986 | if (has_5ghz(prefix)) { |
|---|
| 2987 | websWrite(wp, |
|---|
| 2988 | "document.write(\"<option value=\\\"n2-only\\\" %s>\" + wl_basic.n2 + \"</option>\");\n", |
|---|
| 2989 | nvram_match(wl_net_mode, |
|---|
| 2990 | "n2-only") ? |
|---|
| 2991 | "selected=\\\"selected\\\"" : ""); |
|---|
| 2992 | } else { |
|---|
| 2993 | websWrite(wp, |
|---|
| 2994 | "document.write(\"<option value=\\\"n-only\\\" %s>\" + wl_basic.n + \"</option>\");\n", |
|---|
| 2995 | nvram_match(wl_net_mode, |
|---|
| 2996 | "n-only") ? |
|---|
| 2997 | "selected=\\\"selected\\\"" : ""); |
|---|
| 2998 | } |
|---|
| 2999 | } |
|---|
| 3000 | #if !defined(HAVE_FONERA) && !defined(HAVE_LS2) && !defined(HAVE_MERAKI) |
|---|
| 3001 | #ifndef HAVE_MADWIFI |
|---|
| 3002 | |
|---|
| 3003 | if (has_5ghz(prefix)) { |
|---|
| 3004 | websWrite(wp, |
|---|
| 3005 | "document.write(\"<option value=\\\"a-only\\\" %s>\" + wl_basic.a + \"</option>\");\n", |
|---|
| 3006 | nvram_match(wl_net_mode, |
|---|
| 3007 | "a-only") ? |
|---|
| 3008 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3009 | } |
|---|
| 3010 | if (has_mimo(prefix) && has_5ghz(prefix)) { |
|---|
| 3011 | websWrite(wp, |
|---|
| 3012 | "document.write(\"<option value=\\\"na-only\\\" %s>\" + wl_basic.na + \"</option>\");\n", |
|---|
| 3013 | nvram_match(wl_net_mode, |
|---|
| 3014 | "na-only") ? |
|---|
| 3015 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3016 | websWrite(wp, |
|---|
| 3017 | "document.write(\"<option value=\\\"n5-only\\\" %s>\" + wl_basic.n5 + \"</option>\");\n", |
|---|
| 3018 | nvram_match(wl_net_mode, |
|---|
| 3019 | "n5-only") ? |
|---|
| 3020 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3021 | } |
|---|
| 3022 | #else |
|---|
| 3023 | #if HAVE_WHRAG108 |
|---|
| 3024 | if (!strcmp(prefix, "ath0")) |
|---|
| 3025 | #endif |
|---|
| 3026 | #ifdef HAVE_TW6600 |
|---|
| 3027 | if (!strcmp(prefix, "ath0")) |
|---|
| 3028 | #endif |
|---|
| 3029 | if (has_5ghz(prefix)) { |
|---|
| 3030 | websWrite(wp, |
|---|
| 3031 | "document.write(\"<option value=\\\"a-only\\\" %s>\" + wl_basic.a + \"</option>\");\n", |
|---|
| 3032 | nvram_match(wl_net_mode, |
|---|
| 3033 | "a-only") ? |
|---|
| 3034 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3035 | } |
|---|
| 3036 | #endif |
|---|
| 3037 | |
|---|
| 3038 | #endif |
|---|
| 3039 | #ifdef HAVE_MADWIFI_MIMO |
|---|
| 3040 | if (is_ar5008(prefix)) { |
|---|
| 3041 | if (has_2ghz(prefix)) { |
|---|
| 3042 | websWrite(wp, |
|---|
| 3043 | "document.write(\"<option value=\\\"ng-only\\\" %s>\" + wl_basic.ng + \"</option>\");\n", |
|---|
| 3044 | nvram_match(wl_net_mode, |
|---|
| 3045 | "ng-only") ? |
|---|
| 3046 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3047 | websWrite(wp, |
|---|
| 3048 | "document.write(\"<option value=\\\"n2-only\\\" %s>\" + wl_basic.n2 + \"</option>\");\n", |
|---|
| 3049 | nvram_match(wl_net_mode, |
|---|
| 3050 | "n2-only") ? |
|---|
| 3051 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3052 | } |
|---|
| 3053 | if (has_5ghz(prefix)) { |
|---|
| 3054 | websWrite(wp, |
|---|
| 3055 | "document.write(\"<option value=\\\"na-only\\\" %s>\" + wl_basic.na + \"</option>\");\n", |
|---|
| 3056 | nvram_match(wl_net_mode, |
|---|
| 3057 | "na-only") ? |
|---|
| 3058 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3059 | websWrite(wp, |
|---|
| 3060 | "document.write(\"<option value=\\\"n5-only\\\" %s>\" + wl_basic.n5 + \"</option>\");\n", |
|---|
| 3061 | nvram_match(wl_net_mode, |
|---|
| 3062 | "n5-only") ? |
|---|
| 3063 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3064 | } |
|---|
| 3065 | } |
|---|
| 3066 | #endif |
|---|
| 3067 | |
|---|
| 3068 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3069 | websWrite(wp, "</select>\n"); |
|---|
| 3070 | websWrite(wp, "</div>\n"); |
|---|
| 3071 | |
|---|
| 3072 | #ifdef HAVE_RT2880 |
|---|
| 3073 | if (nvram_nmatch("n-only", "%s_net_mode", prefix)) { |
|---|
| 3074 | char wl_greenfield[32]; |
|---|
| 3075 | |
|---|
| 3076 | sprintf(wl_greenfield, "%s_greenfield", prefix); |
|---|
| 3077 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3078 | websWrite(wp, |
|---|
| 3079 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label7)</script></div><select name=\"%s\" >\n", |
|---|
| 3080 | wl_greenfield); |
|---|
| 3081 | websWrite(wp, |
|---|
| 3082 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3083 | websWrite(wp, |
|---|
| 3084 | "document.write(\"<option value=\\\"0\\\" %s>\" + wl_basic.mixed + \"</option>\");\n", |
|---|
| 3085 | nvram_default_match(wl_greenfield, "0", |
|---|
| 3086 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3087 | : ""); |
|---|
| 3088 | websWrite(wp, |
|---|
| 3089 | "document.write(\"<option value=\\\"1\\\" %s>\" + wl_basic.greenfield + \"</option>\");\n", |
|---|
| 3090 | nvram_default_match(wl_greenfield, "1", |
|---|
| 3091 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3092 | : ""); |
|---|
| 3093 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3094 | websWrite(wp, "</select>\n"); |
|---|
| 3095 | websWrite(wp, "</div>\n"); |
|---|
| 3096 | } |
|---|
| 3097 | #endif |
|---|
| 3098 | } |
|---|
| 3099 | |
|---|
| 3100 | #ifdef HAVE_MADWIFI |
|---|
| 3101 | static void showrtssettings(webs_t wp, char *var) |
|---|
| 3102 | { |
|---|
| 3103 | char ssid[32]; |
|---|
| 3104 | char vvar[32]; |
|---|
| 3105 | |
|---|
| 3106 | strcpy(vvar, var); |
|---|
| 3107 | rep(vvar, '.', 'X'); |
|---|
| 3108 | sprintf(ssid, "%s_rts", var); |
|---|
| 3109 | websWrite(wp, |
|---|
| 3110 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.rts)</script></div>\n"); |
|---|
| 3111 | websWrite(wp, |
|---|
| 3112 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" onclick=\"show_layer_ext(this, '%s_idrts', true);\" name=\"%s_rts\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input>\n", |
|---|
| 3113 | vvar, var, nvram_default_match(ssid, "1", |
|---|
| 3114 | "0") ? "checked=\"checked\"" : |
|---|
| 3115 | ""); |
|---|
| 3116 | websWrite(wp, |
|---|
| 3117 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" onclick=\"show_layer_ext(this, '%s_idrts', false);\" name=\"%s_rts\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input> \n", |
|---|
| 3118 | vvar, var, nvram_default_match(ssid, "0", |
|---|
| 3119 | "0") ? "checked=\"checked\"" : |
|---|
| 3120 | ""); |
|---|
| 3121 | websWrite(wp, "</div>\n"); |
|---|
| 3122 | |
|---|
| 3123 | websWrite(wp, "<div id=\"%s_idrts\">\n", vvar); |
|---|
| 3124 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3125 | websWrite(wp, |
|---|
| 3126 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.rtsvalue)</script></div>\n"); |
|---|
| 3127 | char ip[32]; |
|---|
| 3128 | |
|---|
| 3129 | sprintf(ip, "%s_rtsvalue", var); |
|---|
| 3130 | websWrite(wp, |
|---|
| 3131 | "<input class=\"num\" maxlength=\"4\" size=\"4\" onblur=\"valid_range(this,1,2346,share.ip)\" name=\"%s_rtsvalue\" value=\"%s\" />", |
|---|
| 3132 | var, nvram_default_get(ip, "2346")); |
|---|
| 3133 | websWrite(wp, "</div>\n"); |
|---|
| 3134 | websWrite(wp, "</div>\n"); |
|---|
| 3135 | |
|---|
| 3136 | websWrite(wp, "<script>\n//<![CDATA[\n "); |
|---|
| 3137 | websWrite(wp, |
|---|
| 3138 | "show_layer_ext(document.getElementsByName(\"%s_rts\"), \"%s_idrts\", %s);\n", |
|---|
| 3139 | var, vvar, nvram_match(ssid, "1") ? "true" : "false"); |
|---|
| 3140 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3141 | |
|---|
| 3142 | } |
|---|
| 3143 | #endif |
|---|
| 3144 | static void showbridgesettings(webs_t wp, char *var, int mcast, int dual) |
|---|
| 3145 | { |
|---|
| 3146 | |
|---|
| 3147 | char ssid[32]; |
|---|
| 3148 | |
|---|
| 3149 | sprintf(ssid, "%s_bridged", var); |
|---|
| 3150 | char vvar[32]; |
|---|
| 3151 | |
|---|
| 3152 | strcpy(vvar, var); |
|---|
| 3153 | rep(vvar, '.', 'X'); |
|---|
| 3154 | websWrite(wp, |
|---|
| 3155 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.network)</script></div>\n"); |
|---|
| 3156 | websWrite(wp, |
|---|
| 3157 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" onclick=\"show_layer_ext(this, '%s_idnetvifs', true);\" name=\"%s_bridged\" %s><script type=\"text/javascript\">Capture(wl_basic.unbridged)</script></input> \n", |
|---|
| 3158 | vvar, var, nvram_default_match(ssid, "0", |
|---|
| 3159 | "1") ? "checked=\"checked\"" : |
|---|
| 3160 | ""); |
|---|
| 3161 | websWrite(wp, |
|---|
| 3162 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" onclick=\"show_layer_ext(this, '%s_idnetvifs', false);\" name=\"%s_bridged\" %s><script type=\"text/javascript\">Capture(wl_basic.bridged)</script></input>\n", |
|---|
| 3163 | vvar, var, nvram_default_match(ssid, "1", |
|---|
| 3164 | "1") ? "checked=\"checked\"" : |
|---|
| 3165 | ""); |
|---|
| 3166 | websWrite(wp, "</div>\n"); |
|---|
| 3167 | |
|---|
| 3168 | websWrite(wp, "<div id=\"%s_idnetvifs\">\n", vvar); |
|---|
| 3169 | if (mcast) { |
|---|
| 3170 | char mcastvar[32]; |
|---|
| 3171 | |
|---|
| 3172 | sprintf(mcastvar, "%s_multicast", var); |
|---|
| 3173 | nvram_default_get(mcastvar, "0"); |
|---|
| 3174 | showRadio(wp, "wl_basic.multicast", mcastvar); |
|---|
| 3175 | } |
|---|
| 3176 | if (nvram_match("wk_mode", "gateway")) { |
|---|
| 3177 | char natvar[32]; |
|---|
| 3178 | sprintf(natvar, "%s_nat", var); |
|---|
| 3179 | nvram_default_get(natvar, "1"); |
|---|
| 3180 | showRadio(wp, "wl_basic.masquerade", natvar); |
|---|
| 3181 | } |
|---|
| 3182 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3183 | websWrite(wp, |
|---|
| 3184 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.ip)</script></div>\n"); |
|---|
| 3185 | char ip[32]; |
|---|
| 3186 | |
|---|
| 3187 | sprintf(ip, "%s_ipaddr", var); |
|---|
| 3188 | char *ipv = nvram_safe_get(ip); |
|---|
| 3189 | |
|---|
| 3190 | websWrite(wp, |
|---|
| 3191 | "<input type=\"hidden\" name=\"%s_ipaddr\" value=\"4\" />\n", |
|---|
| 3192 | var); |
|---|
| 3193 | websWrite(wp, |
|---|
| 3194 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,1,223,share.ip)\" name=\"%s_ipaddr_0\" value=\"%d\" />.", |
|---|
| 3195 | var, get_single_ip(ipv, 0)); |
|---|
| 3196 | websWrite(wp, |
|---|
| 3197 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_1\" value=\"%d\" />.", |
|---|
| 3198 | var, get_single_ip(ipv, 1)); |
|---|
| 3199 | websWrite(wp, |
|---|
| 3200 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_2\" value=\"%d\" />.", |
|---|
| 3201 | var, get_single_ip(ipv, 2)); |
|---|
| 3202 | websWrite(wp, |
|---|
| 3203 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_3\" value=\"%d\" />\n", |
|---|
| 3204 | var, get_single_ip(ipv, 3)); |
|---|
| 3205 | websWrite(wp, "</div>\n"); |
|---|
| 3206 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3207 | websWrite(wp, |
|---|
| 3208 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.subnet)</script></div>\n"); |
|---|
| 3209 | sprintf(ip, "%s_netmask", var); |
|---|
| 3210 | ipv = nvram_safe_get(ip); |
|---|
| 3211 | |
|---|
| 3212 | websWrite(wp, |
|---|
| 3213 | "<input type=\"hidden\" name=\"%s_netmask\" value=\"4\" />\n", |
|---|
| 3214 | var); |
|---|
| 3215 | websWrite(wp, |
|---|
| 3216 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_0\" value=\"%d\" />.", |
|---|
| 3217 | var, get_single_ip(ipv, 0)); |
|---|
| 3218 | websWrite(wp, |
|---|
| 3219 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_1\" value=\"%d\" />.", |
|---|
| 3220 | var, get_single_ip(ipv, 1)); |
|---|
| 3221 | websWrite(wp, |
|---|
| 3222 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_2\" value=\"%d\" />.", |
|---|
| 3223 | var, get_single_ip(ipv, 2)); |
|---|
| 3224 | websWrite(wp, |
|---|
| 3225 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_3\" value=\"%d\" />.", |
|---|
| 3226 | var, get_single_ip(ipv, 3)); |
|---|
| 3227 | websWrite(wp, "</div>\n"); |
|---|
| 3228 | |
|---|
| 3229 | #ifdef HAVE_MADWIFI |
|---|
| 3230 | /*if (dual) |
|---|
| 3231 | { |
|---|
| 3232 | char dl[32]; |
|---|
| 3233 | sprintf(dl,"%s_duallink",var); |
|---|
| 3234 | websWrite( wp, |
|---|
| 3235 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.duallink)</script></div>\n" ); |
|---|
| 3236 | websWrite( wp, |
|---|
| 3237 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" onclick=\"show_layer_ext(this, '%s_idduallink', true);\" name=\"%s_duallink\" %s><script type=\"text/javascript\">Capture(shared.enable)</script></input> \n", |
|---|
| 3238 | var, var, nvram_default_match( dl, "1", |
|---|
| 3239 | "0" ) ? "checked=\"checked\"" : |
|---|
| 3240 | "" ); |
|---|
| 3241 | websWrite( wp, |
|---|
| 3242 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" onclick=\"show_layer_ext(this, '%s_idduallink', false);\" name=\"%s_duallink\" %s><script type=\"text/javascript\">Capture(shared.disable)</script></input>\n", |
|---|
| 3243 | var, var, nvram_default_match( dl, "0", |
|---|
| 3244 | "0" ) ? "checked=\"checked\"" : |
|---|
| 3245 | "" ); |
|---|
| 3246 | websWrite( wp, "</div>\n" ); |
|---|
| 3247 | |
|---|
| 3248 | websWrite( wp, "<div id=\"%s_iddualink\">\n", var ); |
|---|
| 3249 | |
|---|
| 3250 | sprintf( ip, "%s_duallink_parent", var ); |
|---|
| 3251 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3252 | websWrite( wp,"<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.parent)</script></div>\n" ); |
|---|
| 3253 | ipv = nvram_default_get( ip,"0.0.0.0" ); |
|---|
| 3254 | websWrite( wp, |
|---|
| 3255 | "<input type=\"hidden\" name=\"%s_duallink_parent\" value=\"4\" />\n", |
|---|
| 3256 | var ); |
|---|
| 3257 | websWrite( wp, |
|---|
| 3258 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_duallink_parent_0\" value=\"%d\" />.", |
|---|
| 3259 | var, get_single_ip( ipv, 0 ) ); |
|---|
| 3260 | websWrite( wp, |
|---|
| 3261 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_duallink_parent_1\" value=\"%d\" />.", |
|---|
| 3262 | var, get_single_ip( ipv, 1 ) ); |
|---|
| 3263 | websWrite( wp, |
|---|
| 3264 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_duallink_parent_2\" value=\"%d\" />.", |
|---|
| 3265 | var, get_single_ip( ipv, 2 ) ); |
|---|
| 3266 | websWrite( wp, |
|---|
| 3267 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_duallink_parent_3\" value=\"%d\" />.", |
|---|
| 3268 | var, get_single_ip( ipv, 3 ) ); |
|---|
| 3269 | websWrite( wp, "</div>\n" ); |
|---|
| 3270 | |
|---|
| 3271 | websWrite( wp, "</div>\n" ); |
|---|
| 3272 | |
|---|
| 3273 | websWrite( wp, "<script>\n//<![CDATA[\n " ); |
|---|
| 3274 | websWrite( wp, |
|---|
| 3275 | "show_layer_ext(document.getElementsByName(\"%s_duallink\"), \"%s_idduallink\", %s);\n", |
|---|
| 3276 | var, vvar, nvram_match( dl, "1" ) ? "true" : "false" ); |
|---|
| 3277 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3278 | }*/ |
|---|
| 3279 | #endif |
|---|
| 3280 | |
|---|
| 3281 | websWrite(wp, "</div>\n"); |
|---|
| 3282 | |
|---|
| 3283 | websWrite(wp, "<script>\n//<![CDATA[\n "); |
|---|
| 3284 | websWrite(wp, |
|---|
| 3285 | "show_layer_ext(document.getElementsByName(\"%s_bridged\"), \"%s_idnetvifs\", %s);\n", |
|---|
| 3286 | var, vvar, nvram_match(ssid, "0") ? "true" : "false"); |
|---|
| 3287 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3288 | |
|---|
| 3289 | } |
|---|
| 3290 | |
|---|
| 3291 | #ifdef HAVE_MADWIFI |
|---|
| 3292 | static void show_chanshift(webs_t wp, char *prefix) |
|---|
| 3293 | { |
|---|
| 3294 | char wl_chanshift[32]; |
|---|
| 3295 | char wl_channelbw[32]; |
|---|
| 3296 | |
|---|
| 3297 | sprintf(wl_channelbw, "%s_channelbw", prefix); |
|---|
| 3298 | sprintf(wl_chanshift, "%s_chanshift", prefix); |
|---|
| 3299 | if (atoi(nvram_safe_get(wl_channelbw)) > 2 |
|---|
| 3300 | && (atoi(nvram_safe_get(wl_chanshift)) & 0xf) > 10) |
|---|
| 3301 | nvram_set(wl_chanshift, "10"); |
|---|
| 3302 | if (atoi(nvram_safe_get(wl_channelbw)) > 5 |
|---|
| 3303 | && (atoi(nvram_safe_get(wl_chanshift)) & 0xf) > 10) |
|---|
| 3304 | nvram_set(wl_chanshift, "10"); |
|---|
| 3305 | if (atoi(nvram_safe_get(wl_channelbw)) > 10 |
|---|
| 3306 | && (atoi(nvram_safe_get(wl_chanshift)) & 0xf) > 0) |
|---|
| 3307 | nvram_set(wl_chanshift, "0"); |
|---|
| 3308 | |
|---|
| 3309 | if (nvram_match(wl_channelbw, "5") |
|---|
| 3310 | || nvram_match(wl_channelbw, "10") |
|---|
| 3311 | || nvram_match(wl_channelbw, "2")) { |
|---|
| 3312 | |
|---|
| 3313 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3314 | websWrite(wp, |
|---|
| 3315 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.chanshift)</script></div>\n<select name=\"%s\">\n", |
|---|
| 3316 | wl_chanshift); |
|---|
| 3317 | websWrite(wp, |
|---|
| 3318 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3319 | if (nvram_match(wl_channelbw, "5") |
|---|
| 3320 | || nvram_match(wl_channelbw, "2")) |
|---|
| 3321 | websWrite(wp, |
|---|
| 3322 | "document.write(\"<option value=\\\"-15\\\" %s >-15 Mhz</option>\");\n", |
|---|
| 3323 | nvram_default_match(wl_chanshift, "-15", |
|---|
| 3324 | "0") ? |
|---|
| 3325 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3326 | if (nvram_match(wl_channelbw, "5") |
|---|
| 3327 | || nvram_match(wl_channelbw, "10") |
|---|
| 3328 | || nvram_match(wl_channelbw, "2")) |
|---|
| 3329 | websWrite(wp, |
|---|
| 3330 | "document.write(\"<option value=\\\"-10\\\" %s >-10 Mhz</option>\");\n", |
|---|
| 3331 | nvram_default_match(wl_chanshift, "-10", |
|---|
| 3332 | "0") ? |
|---|
| 3333 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3334 | if (nvram_match(wl_channelbw, "5") |
|---|
| 3335 | || nvram_match(wl_channelbw, "10") |
|---|
| 3336 | || nvram_match(wl_channelbw, "2")) |
|---|
| 3337 | websWrite(wp, |
|---|
| 3338 | "document.write(\"<option value=\\\"-5\\\" %s >-5 Mhz</option>\");\n", |
|---|
| 3339 | nvram_default_match(wl_chanshift, "-5", |
|---|
| 3340 | "0") ? |
|---|
| 3341 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3342 | websWrite(wp, |
|---|
| 3343 | "document.write(\"<option value=\\\"0\\\" %s >0 Mhz</option>\");\n", |
|---|
| 3344 | nvram_default_match(wl_chanshift, "0", |
|---|
| 3345 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3346 | : ""); |
|---|
| 3347 | if (nvram_match(wl_channelbw, "5") |
|---|
| 3348 | || nvram_match(wl_channelbw, "10") |
|---|
| 3349 | || nvram_match(wl_channelbw, "2")) |
|---|
| 3350 | websWrite(wp, |
|---|
| 3351 | "document.write(\"<option value=\\\"5\\\" %s >+5 Mhz</option>\");\n", |
|---|
| 3352 | nvram_default_match(wl_chanshift, "5", |
|---|
| 3353 | "0") ? |
|---|
| 3354 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3355 | if (nvram_match(wl_channelbw, "5") |
|---|
| 3356 | || nvram_match(wl_channelbw, "10") |
|---|
| 3357 | || nvram_match(wl_channelbw, "2")) |
|---|
| 3358 | websWrite(wp, |
|---|
| 3359 | "document.write(\"<option value=\\\"10\\\" %s >+10 Mhz</option>\");\n", |
|---|
| 3360 | nvram_default_match(wl_chanshift, "10", |
|---|
| 3361 | "0") ? |
|---|
| 3362 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3363 | if (nvram_match(wl_channelbw, "5") |
|---|
| 3364 | || nvram_match(wl_channelbw, "2")) |
|---|
| 3365 | websWrite(wp, |
|---|
| 3366 | "document.write(\"<option value=\\\"15\\\" %s >+15 Mhz</option>\");\n", |
|---|
| 3367 | nvram_default_match(wl_chanshift, "15", |
|---|
| 3368 | "0") ? |
|---|
| 3369 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3370 | websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 3371 | } |
|---|
| 3372 | } |
|---|
| 3373 | #endif |
|---|
| 3374 | static int show_virtualssid(webs_t wp, char *prefix) |
|---|
| 3375 | { |
|---|
| 3376 | char *next; |
|---|
| 3377 | char var[80]; |
|---|
| 3378 | char ssid[80]; |
|---|
| 3379 | char vif[16]; |
|---|
| 3380 | char power[32]; |
|---|
| 3381 | |
|---|
| 3382 | #ifdef HAVE_MADWIFI |
|---|
| 3383 | char wmm[32]; |
|---|
| 3384 | char wl_protmode[32]; |
|---|
| 3385 | #endif |
|---|
| 3386 | sprintf(vif, "%s_vifs", prefix); |
|---|
| 3387 | char *vifs = nvram_safe_get(vif); |
|---|
| 3388 | |
|---|
| 3389 | if (vifs == NULL) |
|---|
| 3390 | return 0; |
|---|
| 3391 | #ifndef HAVE_MADWIFI |
|---|
| 3392 | if (!nvram_nmatch("ap", "%s_mode", prefix) |
|---|
| 3393 | && !nvram_nmatch("apsta", "%s_mode", prefix) |
|---|
| 3394 | && !nvram_nmatch("apstawet", "%s_mode", prefix)) |
|---|
| 3395 | return 0; |
|---|
| 3396 | #endif |
|---|
| 3397 | int count = 1; |
|---|
| 3398 | |
|---|
| 3399 | websWrite(wp, |
|---|
| 3400 | "<h2><script type=\"text/javascript\">Capture(wl_basic.h2_vi)</script></h2>\n"); |
|---|
| 3401 | foreach(var, vifs, next) { |
|---|
| 3402 | sprintf(ssid, "%s_ssid", var); |
|---|
| 3403 | websWrite(wp, |
|---|
| 3404 | "<fieldset><legend><script type=\"text/javascript\">Capture(share.vintrface)</script> %s SSID [", |
|---|
| 3405 | IFMAP(var)); |
|---|
| 3406 | tf_webWriteESCNV(wp, ssid); // fix for broken html page if ssid |
|---|
| 3407 | // contains html tag |
|---|
| 3408 | websWrite(wp, "]</legend>\n"); |
|---|
| 3409 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3410 | websWrite(wp, |
|---|
| 3411 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label3)</script></div>\n"); |
|---|
| 3412 | |
|---|
| 3413 | websWrite(wp, |
|---|
| 3414 | "<input name=\"%s_ssid\" size=\"20\" maxlength=\"32\" onblur=\"valid_name(this,wl_basic.label3)\" value=\"%s\" /></div>\n", |
|---|
| 3415 | var, nvram_safe_get(ssid)); |
|---|
| 3416 | |
|---|
| 3417 | #ifdef HAVE_MADWIFI |
|---|
| 3418 | // sprintf( wl_chanshift, "%s_chanshift", var ); |
|---|
| 3419 | // show_chanshift( wp, wl_chanshift ); |
|---|
| 3420 | |
|---|
| 3421 | sprintf(wl_protmode, "%s_protmode", var); |
|---|
| 3422 | showOptionsLabel(wp, "wl_basic.protmode", wl_protmode, |
|---|
| 3423 | "None CTS RTS/CTS", |
|---|
| 3424 | nvram_default_get(wl_protmode, "None")); |
|---|
| 3425 | showrtssettings(wp, var); |
|---|
| 3426 | #endif |
|---|
| 3427 | |
|---|
| 3428 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3429 | websWrite(wp, |
|---|
| 3430 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label5)</script></div>"); |
|---|
| 3431 | sprintf(ssid, "%s_closed", var); |
|---|
| 3432 | websWrite(wp, |
|---|
| 3433 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s_closed\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input> \n", |
|---|
| 3434 | var, nvram_match(ssid, |
|---|
| 3435 | "0") ? "checked=\"checked\"" : ""); |
|---|
| 3436 | websWrite(wp, |
|---|
| 3437 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s_closed\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input>\n", |
|---|
| 3438 | var, nvram_match(ssid, |
|---|
| 3439 | "1") ? "checked=\"checked\"" : ""); |
|---|
| 3440 | websWrite(wp, "</div>\n"); |
|---|
| 3441 | char wl_mode[16]; |
|---|
| 3442 | |
|---|
| 3443 | #ifdef HAVE_MADWIFI |
|---|
| 3444 | sprintf(wl_mode, "%s_mode", var); |
|---|
| 3445 | websWrite(wp, |
|---|
| 3446 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label)</script></div><select name=\"%s\" >\n", |
|---|
| 3447 | wl_mode); |
|---|
| 3448 | websWrite(wp, |
|---|
| 3449 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3450 | websWrite(wp, |
|---|
| 3451 | "document.write(\"<option value=\\\"ap\\\" %s >\" + wl_basic.ap + \"</option>\");\n", |
|---|
| 3452 | nvram_match(wl_mode, |
|---|
| 3453 | "ap") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3454 | // websWrite (wp, |
|---|
| 3455 | // "document.write(\"<option value=\\\"wdssta\\\" %s >\" + |
|---|
| 3456 | // wl_basic.wdssta + \"</option>\");\n", |
|---|
| 3457 | // nvram_match (wl_mode, |
|---|
| 3458 | // "wdssta") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3459 | websWrite(wp, |
|---|
| 3460 | "document.write(\"<option value=\\\"wdsap\\\" %s >\" + wl_basic.wdsap + \"</option>\");\n", |
|---|
| 3461 | nvram_match(wl_mode, |
|---|
| 3462 | "wdsap") ? "selected=\\\"selected\\\"" : |
|---|
| 3463 | ""); |
|---|
| 3464 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3465 | websWrite(wp, "</select>\n"); |
|---|
| 3466 | websWrite(wp, "</div>\n"); |
|---|
| 3467 | sprintf(wmm, "%s_wmm", var); |
|---|
| 3468 | showRadio(wp, "wl_adv.label18", wmm); |
|---|
| 3469 | #endif |
|---|
| 3470 | sprintf(ssid, "%s_ap_isolate", var); |
|---|
| 3471 | showRadio(wp, "wl_adv.label11", ssid); |
|---|
| 3472 | #ifdef HAVE_MADWIFI |
|---|
| 3473 | |
|---|
| 3474 | if (nvram_nmatch("ap", "%s_mode", var) |
|---|
| 3475 | || nvram_nmatch("wdsap", "%s_mode", var) |
|---|
| 3476 | || nvram_nmatch("infra", "%s_mode", var)) { |
|---|
| 3477 | sprintf(power, "%s_maxassoc", var); |
|---|
| 3478 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3479 | websWrite(wp, |
|---|
| 3480 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label10)</script></div>\n"); |
|---|
| 3481 | websWrite(wp, |
|---|
| 3482 | "<input class=\"num\" name=\"%s\" size=\"4\" maxlength=\"4\" onblur=\"valid_range(this,0,256,wl_adv.label10)\" value=\"%s\" />\n", |
|---|
| 3483 | power, nvram_default_get(power, "256")); |
|---|
| 3484 | |
|---|
| 3485 | websWrite(wp, |
|---|
| 3486 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 256 \" + share.user + \")\");\n//]]>\n</script></span>\n"); |
|---|
| 3487 | websWrite(wp, "</div>\n"); |
|---|
| 3488 | } |
|---|
| 3489 | |
|---|
| 3490 | sprintf(power, "%s_mtikie", var); |
|---|
| 3491 | nvram_default_get(power, "0"); |
|---|
| 3492 | showRadio(wp, "wl_basic.mtikie", power); |
|---|
| 3493 | #endif |
|---|
| 3494 | #ifdef HAVE_RT2880 |
|---|
| 3495 | showbridgesettings(wp, getRADev(var), 1, 0); |
|---|
| 3496 | #else |
|---|
| 3497 | showbridgesettings(wp, var, 1, 0); |
|---|
| 3498 | #endif |
|---|
| 3499 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 3500 | count++; |
|---|
| 3501 | } |
|---|
| 3502 | |
|---|
| 3503 | websWrite(wp, "<div class=\"center\">\n"); |
|---|
| 3504 | #ifdef HAVE_MADWIFI |
|---|
| 3505 | if (count < 8) |
|---|
| 3506 | #elif HAVE_RT2880 |
|---|
| 3507 | if (count < 7) |
|---|
| 3508 | #else |
|---|
| 3509 | if (count < WL_MAXBSSCFG) |
|---|
| 3510 | #endif |
|---|
| 3511 | websWrite(wp, |
|---|
| 3512 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.add + \"\\\" onclick=\\\"vifs_add_submit(this.form,'%s')\\\" />\");\n//]]>\n</script>\n", |
|---|
| 3513 | prefix); |
|---|
| 3514 | |
|---|
| 3515 | if (count > 1) |
|---|
| 3516 | websWrite(wp, |
|---|
| 3517 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.remove + \"\\\" onclick=\\\"vifs_remove_submit(this.form,'%s')\\\" />\");\n//]]>\n</script>\n", |
|---|
| 3518 | prefix); |
|---|
| 3519 | |
|---|
| 3520 | websWrite(wp, "</div><br />\n"); |
|---|
| 3521 | |
|---|
| 3522 | return 0; |
|---|
| 3523 | } |
|---|
| 3524 | |
|---|
| 3525 | void ej_showad(webs_t wp, int argc, char_t ** argv) |
|---|
| 3526 | { |
|---|
| 3527 | #ifndef HAVE_FON |
|---|
| 3528 | #ifndef CONFIG_BRANDING |
|---|
| 3529 | #ifdef HAVE_CHILLI |
|---|
| 3530 | // if (nvram_invmatch ("fon_enable", "1")) |
|---|
| 3531 | // websWrite (wp, |
|---|
| 3532 | // "<a href=\"fon.cgi\"><img src=\"images/turn.gif\" border=0 /></a>"); |
|---|
| 3533 | #endif |
|---|
| 3534 | #endif |
|---|
| 3535 | #endif |
|---|
| 3536 | |
|---|
| 3537 | #ifndef HAVE_NOAD |
|---|
| 3538 | /* |
|---|
| 3539 | * if (nvram_match("wanup","1")) { websWrite(wp,"<script |
|---|
| 3540 | * type=\"text/javascript\"><!--\n//<![CDATA[\n "); |
|---|
| 3541 | * websWrite(wp,"google_ad_client = \"pub-8308593183433068\";\n"); |
|---|
| 3542 | * websWrite(wp,"google_ad_width = 728;\n"); |
|---|
| 3543 | * websWrite(wp,"google_ad_height = 90;\n"); |
|---|
| 3544 | * websWrite(wp,"google_ad_format = \"728x90_as\";\n"); |
|---|
| 3545 | * websWrite(wp,"google_ad_type = \"text_image\";\n"); |
|---|
| 3546 | * websWrite(wp,"google_ad_channel =\"8866414571\";\n"); |
|---|
| 3547 | * websWrite(wp,"google_color_border = \"333333\";\n"); |
|---|
| 3548 | * websWrite(wp,"google_color_bg = \"000000\";\n"); |
|---|
| 3549 | * websWrite(wp,"google_color_link = \"FFFFFF\";\n"); |
|---|
| 3550 | * websWrite(wp,"google_color_url = \"999999\";\n"); |
|---|
| 3551 | * websWrite(wp,"google_color_text = \"CCCCCC\";\n"); |
|---|
| 3552 | * websWrite(wp,"//-->//]]>\n</script>\n"); websWrite(wp,"<script |
|---|
| 3553 | * type=\"text/javascript\"\n"); websWrite(wp," |
|---|
| 3554 | * src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\n"); |
|---|
| 3555 | * websWrite(wp,"</script>\n"); } |
|---|
| 3556 | */ |
|---|
| 3557 | #endif |
|---|
| 3558 | return; |
|---|
| 3559 | } |
|---|
| 3560 | |
|---|
| 3561 | #ifndef HAVE_SUPERCHANNEL |
|---|
| 3562 | int inline issuperchannel(void) |
|---|
| 3563 | { |
|---|
| 3564 | #if defined(HAVE_MAKSAT) && defined(HAVE_MR3202A) |
|---|
| 3565 | return 0; |
|---|
| 3566 | #elif defined(HAVE_MAKSAT) && defined(HAVE_ALPHA) |
|---|
| 3567 | return 0; |
|---|
| 3568 | #elif HAVE_MAKSAT |
|---|
| 3569 | return 1; |
|---|
| 3570 | #else |
|---|
| 3571 | return 0; |
|---|
| 3572 | #endif |
|---|
| 3573 | } |
|---|
| 3574 | #endif |
|---|
| 3575 | |
|---|
| 3576 | void ej_show_countrylist(webs_t wp, int argc, char_t ** argv) |
|---|
| 3577 | { |
|---|
| 3578 | if (argc < 1) { |
|---|
| 3579 | return; |
|---|
| 3580 | } |
|---|
| 3581 | char *list = getCountryList(); |
|---|
| 3582 | |
|---|
| 3583 | showOptionsChoose(wp, argv[0], list, nvram_safe_get(argv[0])); |
|---|
| 3584 | } |
|---|
| 3585 | |
|---|
| 3586 | void ej_show_wireless_single(webs_t wp, char *prefix) |
|---|
| 3587 | { |
|---|
| 3588 | char wl_mode[16]; |
|---|
| 3589 | char wl_macaddr[16]; |
|---|
| 3590 | char wl_ssid[16]; |
|---|
| 3591 | |
|---|
| 3592 | sprintf(wl_mode, "%s_mode", prefix); |
|---|
| 3593 | sprintf(wl_macaddr, "%s_hwaddr", prefix); |
|---|
| 3594 | sprintf(wl_ssid, "%s_ssid", prefix); |
|---|
| 3595 | |
|---|
| 3596 | // wireless mode |
|---|
| 3597 | websWrite(wp, |
|---|
| 3598 | "<h2><script type=\"text/javascript\">Capture(wl_basic.h2_v24)</script> %s</h2>\n", |
|---|
| 3599 | prefix); |
|---|
| 3600 | websWrite(wp, "<fieldset>\n"); |
|---|
| 3601 | websWrite(wp, |
|---|
| 3602 | "<legend><script type=\"text/javascript\">Capture(share.pintrface)</script> %s - SSID [", |
|---|
| 3603 | IFMAP(prefix)); |
|---|
| 3604 | tf_webWriteESCNV(wp, wl_ssid); // fix |
|---|
| 3605 | websWrite(wp, "] HWAddr [%s]</legend>\n", nvram_safe_get(wl_macaddr)); |
|---|
| 3606 | char power[16]; |
|---|
| 3607 | |
|---|
| 3608 | // char maxpower[16]; |
|---|
| 3609 | #ifdef HAVE_MADWIFI |
|---|
| 3610 | #ifndef HAVE_MAKSAT |
|---|
| 3611 | #ifndef HAVE_DDLINK |
|---|
| 3612 | |
|---|
| 3613 | if (isXR36(prefix)) { |
|---|
| 3614 | char wl_cardtype[32]; |
|---|
| 3615 | sprintf(wl_cardtype, "%s_cardtype", prefix); |
|---|
| 3616 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3617 | websWrite(wp, |
|---|
| 3618 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.cardtype)</script></div>\n<select name=\"%s\">\n", |
|---|
| 3619 | wl_cardtype); |
|---|
| 3620 | websWrite(wp, |
|---|
| 3621 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3622 | websWrite(wp, |
|---|
| 3623 | "document.write(\"<option value=\\\"0\\\" %s >Ubiquiti XR3.3</option>\");\n", |
|---|
| 3624 | nvram_default_match(wl_cardtype, "0", |
|---|
| 3625 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3626 | : ""); |
|---|
| 3627 | websWrite(wp, |
|---|
| 3628 | "document.write(\"<option value=\\\"1\\\" %s >Ubiquiti XR3.6</option>\");\n", |
|---|
| 3629 | nvram_default_match(wl_cardtype, "1", |
|---|
| 3630 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3631 | : ""); |
|---|
| 3632 | websWrite(wp, |
|---|
| 3633 | "document.write(\"<option value=\\\"2\\\" %s >Ubiquiti XR3.7</option>\");\n", |
|---|
| 3634 | nvram_default_match(wl_cardtype, "2", |
|---|
| 3635 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3636 | : ""); |
|---|
| 3637 | websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 3638 | } |
|---|
| 3639 | |
|---|
| 3640 | if (isEMP(prefix)) { |
|---|
| 3641 | char wl_cardtype[32]; |
|---|
| 3642 | sprintf(wl_cardtype, "%s_cardtype", prefix); |
|---|
| 3643 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3644 | websWrite(wp, |
|---|
| 3645 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.cardtype)</script></div>\n<select name=\"%s\">\n", |
|---|
| 3646 | wl_cardtype); |
|---|
| 3647 | websWrite(wp, |
|---|
| 3648 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3649 | websWrite(wp, |
|---|
| 3650 | "document.write(\"<option value=\\\"0\\\" %s >Atheros Generic</option>\");\n", |
|---|
| 3651 | nvram_default_match(wl_cardtype, "0", |
|---|
| 3652 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3653 | : ""); |
|---|
| 3654 | websWrite(wp, |
|---|
| 3655 | "document.write(\"<option value=\\\"5\\\" %s >Alfa Networks AWPCI085H</option>\");\n", |
|---|
| 3656 | nvram_default_match(wl_cardtype, "5", |
|---|
| 3657 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3658 | : ""); |
|---|
| 3659 | websWrite(wp, |
|---|
| 3660 | "document.write(\"<option value=\\\"6\\\" %s >Alfa Networks AWPCI085P</option>\");\n", |
|---|
| 3661 | nvram_default_match(wl_cardtype, "6", |
|---|
| 3662 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3663 | : ""); |
|---|
| 3664 | websWrite(wp, |
|---|
| 3665 | "document.write(\"<option value=\\\"7\\\" %s >Doodle Labs DLM105</option>\");\n", |
|---|
| 3666 | nvram_default_match(wl_cardtype, "7", |
|---|
| 3667 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3668 | : ""); |
|---|
| 3669 | websWrite(wp, |
|---|
| 3670 | "document.write(\"<option value=\\\"4\\\" %s >MakSat MAK27</option>\");\n", |
|---|
| 3671 | nvram_default_match(wl_cardtype, "4", |
|---|
| 3672 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3673 | : ""); |
|---|
| 3674 | websWrite(wp, |
|---|
| 3675 | "document.write(\"<option value=\\\"1\\\" %s >Senao EMP-8602</option>\");\n", |
|---|
| 3676 | nvram_default_match(wl_cardtype, "1", |
|---|
| 3677 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3678 | : ""); |
|---|
| 3679 | websWrite(wp, |
|---|
| 3680 | "document.write(\"<option value=\\\"2\\\" %s >Senao EMP-8603-S</option>\");\n", |
|---|
| 3681 | nvram_default_match(wl_cardtype, "2", |
|---|
| 3682 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3683 | : ""); |
|---|
| 3684 | websWrite(wp, |
|---|
| 3685 | "document.write(\"<option value=\\\"3\\\" %s >Senao EMP-8603</option>\");\n", |
|---|
| 3686 | nvram_default_match(wl_cardtype, "3", |
|---|
| 3687 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3688 | : ""); |
|---|
| 3689 | websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 3690 | } |
|---|
| 3691 | #endif |
|---|
| 3692 | #endif // ! HAVE MAKSAT |
|---|
| 3693 | #ifndef HAVE_NOCOUNTRYSEL |
|---|
| 3694 | char wl_regdomain[16]; |
|---|
| 3695 | |
|---|
| 3696 | sprintf(wl_regdomain, "%s_regdomain", prefix); |
|---|
| 3697 | if (nvram_match("ath_regulatory", "1") || !issuperchannel()) { |
|---|
| 3698 | websWrite(wp, |
|---|
| 3699 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.regdom)</script></div>\n"); |
|---|
| 3700 | char *list = getCountryList(); |
|---|
| 3701 | |
|---|
| 3702 | showOptions(wp, wl_regdomain, list, |
|---|
| 3703 | nvram_safe_get(wl_regdomain)); |
|---|
| 3704 | websWrite(wp, "</div>\n"); |
|---|
| 3705 | } |
|---|
| 3706 | #endif // ! HAVE MAKSAT |
|---|
| 3707 | /* |
|---|
| 3708 | * while (regdomains[domcount].name != NULL) { char domcode[16]; sprintf |
|---|
| 3709 | * (domcode, "%d", regdomains[domcount].code); websWrite (wp, "<option |
|---|
| 3710 | * value=\"%d\" %s>%s</option>\n", regdomains[domcount].code, nvram_match |
|---|
| 3711 | * (wl_regdomain, domcode) ? " selected=\"selected\"" : "", |
|---|
| 3712 | * regdomains[domcount].name); domcount++; } websWrite (wp, |
|---|
| 3713 | * "</select>\n"); websWrite (wp, "</div>\n"); |
|---|
| 3714 | */ |
|---|
| 3715 | // power adjustment |
|---|
| 3716 | sprintf(power, "%s_txpwrdbm", prefix); |
|---|
| 3717 | // sprintf (maxpower, "%s_maxpower", prefix); |
|---|
| 3718 | if (!strcmp(prefix, "ath0") && issuperchannel()) // show |
|---|
| 3719 | // client |
|---|
| 3720 | // only on |
|---|
| 3721 | // first |
|---|
| 3722 | // interface |
|---|
| 3723 | { |
|---|
| 3724 | |
|---|
| 3725 | websWrite(wp, " <div class=\"setting\">\n"); |
|---|
| 3726 | websWrite(wp, |
|---|
| 3727 | " <div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.regulatory)</script></div>\n"); |
|---|
| 3728 | websWrite(wp, |
|---|
| 3729 | " <input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"ath_regulatory\" %s /><script type=\"text/javascript\">Capture(share.enable)</script> \n", |
|---|
| 3730 | nvram_match("ath_regulatory", "0") ? "checked" : ""); |
|---|
| 3731 | websWrite(wp, |
|---|
| 3732 | " <input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"ath_regulatory\" %s /><script type=\"text/javascript\">Capture(share.disable)</script>\n", |
|---|
| 3733 | nvram_match("ath_regulatory", "1") ? "checked" : ""); |
|---|
| 3734 | websWrite(wp, " </div>\n"); |
|---|
| 3735 | |
|---|
| 3736 | } |
|---|
| 3737 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3738 | websWrite(wp, |
|---|
| 3739 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.TXpower)</script></div><input class=\"num\" name=\"%s\" size=\"6\" maxlength=\"3\" value=\"%d\" /> dBm\n", |
|---|
| 3740 | power, |
|---|
| 3741 | atoi(nvram_safe_get(power)) + wifi_gettxpoweroffset(prefix)); |
|---|
| 3742 | websWrite(wp, "</div>\n"); |
|---|
| 3743 | sprintf(power, "%s_antgain", prefix); |
|---|
| 3744 | #ifndef HAVE_MAKSAT |
|---|
| 3745 | if (nvram_match("ath_regulatory", "1")) |
|---|
| 3746 | #endif |
|---|
| 3747 | { |
|---|
| 3748 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3749 | websWrite(wp, |
|---|
| 3750 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.AntGain)</script></div><input class=\"num\" name=\"%s\" size=\"6\" maxlength=\"3\" value=\"%s\" /> dBi\n", |
|---|
| 3751 | power, nvram_safe_get(power)); |
|---|
| 3752 | websWrite(wp, "</div>\n"); |
|---|
| 3753 | } |
|---|
| 3754 | #endif |
|---|
| 3755 | |
|---|
| 3756 | #ifdef HAVE_MADWIFI |
|---|
| 3757 | // if (!strcmp (prefix, "ath0")) |
|---|
| 3758 | #endif |
|---|
| 3759 | { |
|---|
| 3760 | // #ifdef HAVE_MADWIFI |
|---|
| 3761 | // if (!strcmp (prefix, "ath0")) //show client only on first |
|---|
| 3762 | // interface |
|---|
| 3763 | // #endif |
|---|
| 3764 | { |
|---|
| 3765 | #ifdef HAVE_MADWIFI |
|---|
| 3766 | // if (!strcmp (prefix, "ath0")) //show client only on first |
|---|
| 3767 | // interface |
|---|
| 3768 | // if (nvram_match ("ath0_mode", "wdsap") |
|---|
| 3769 | // || nvram_match ("ath0_mode", "wdssta")) |
|---|
| 3770 | // showOption (wp, "wl_basic.wifi_bonding", "wifi_bonding"); |
|---|
| 3771 | #endif |
|---|
| 3772 | #ifdef HAVE_REGISTER |
|---|
| 3773 | int cpeonly = iscpe(); |
|---|
| 3774 | #else |
|---|
| 3775 | int cpeonly = 0; |
|---|
| 3776 | #endif |
|---|
| 3777 | websWrite(wp, |
|---|
| 3778 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label)</script></div><select name=\"%s\" >\n", |
|---|
| 3779 | wl_mode); |
|---|
| 3780 | websWrite(wp, |
|---|
| 3781 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3782 | if (!cpeonly) { |
|---|
| 3783 | websWrite(wp, |
|---|
| 3784 | "document.write(\"<option value=\\\"ap\\\" %s >\" + wl_basic.ap + \"</option>\");\n", |
|---|
| 3785 | nvram_match(wl_mode, |
|---|
| 3786 | "ap") ? |
|---|
| 3787 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3788 | } |
|---|
| 3789 | websWrite(wp, |
|---|
| 3790 | "document.write(\"<option value=\\\"sta\\\" %s >\" + wl_basic.client + \"</option>\");\n", |
|---|
| 3791 | nvram_match(wl_mode, |
|---|
| 3792 | "sta") ? |
|---|
| 3793 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3794 | #ifndef HAVE_RT2880 |
|---|
| 3795 | websWrite(wp, |
|---|
| 3796 | "document.write(\"<option value=\\\"wet\\\" %s >\" + wl_basic.clientBridge + \"</option>\");\n", |
|---|
| 3797 | nvram_match(wl_mode, |
|---|
| 3798 | "wet") ? |
|---|
| 3799 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3800 | #endif |
|---|
| 3801 | if (!cpeonly) |
|---|
| 3802 | websWrite(wp, |
|---|
| 3803 | "document.write(\"<option value=\\\"infra\\\" %s >\" + wl_basic.adhoc + \"</option>\");\n", |
|---|
| 3804 | nvram_match(wl_mode, |
|---|
| 3805 | "infra") ? |
|---|
| 3806 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3807 | #ifndef HAVE_MADWIFI |
|---|
| 3808 | if (!cpeonly) { |
|---|
| 3809 | websWrite(wp, |
|---|
| 3810 | "document.write(\"<option value=\\\"apsta\\\" %s >\" + wl_basic.repeater + \"</option>\");\n", |
|---|
| 3811 | nvram_match(wl_mode, |
|---|
| 3812 | "apsta") ? |
|---|
| 3813 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3814 | //#ifndef HAVE_RT2880 |
|---|
| 3815 | websWrite(wp, |
|---|
| 3816 | "document.write(\"<option value=\\\"apstawet\\\" %s >\" + wl_basic.repeaterbridge + \"</option>\");\n", |
|---|
| 3817 | nvram_match(wl_mode, |
|---|
| 3818 | "apstawet") ? |
|---|
| 3819 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3820 | } |
|---|
| 3821 | //#endif |
|---|
| 3822 | #else |
|---|
| 3823 | websWrite(wp, |
|---|
| 3824 | "document.write(\"<option value=\\\"wdssta\\\" %s >\" + wl_basic.wdssta + \"</option>\");\n", |
|---|
| 3825 | nvram_match(wl_mode, |
|---|
| 3826 | "wdssta") ? |
|---|
| 3827 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3828 | if (!cpeonly) { |
|---|
| 3829 | websWrite(wp, |
|---|
| 3830 | "document.write(\"<option value=\\\"wdsap\\\" %s >\" + wl_basic.wdsap + \"</option>\");\n", |
|---|
| 3831 | nvram_match(wl_mode, |
|---|
| 3832 | "wdsap") ? |
|---|
| 3833 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3834 | } |
|---|
| 3835 | #endif |
|---|
| 3836 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3837 | websWrite(wp, "</select>\n"); |
|---|
| 3838 | websWrite(wp, "</div>\n"); |
|---|
| 3839 | } |
|---|
| 3840 | /* |
|---|
| 3841 | * #ifdef HAVE_MADWIFI else { |
|---|
| 3842 | * |
|---|
| 3843 | * |
|---|
| 3844 | * websWrite (wp, "<div class=\"setting\"><div |
|---|
| 3845 | * class=\"label\"><script |
|---|
| 3846 | * type=\"text/javascript\">Capture(wl_basic.label)</script></div><select |
|---|
| 3847 | * name=\"%s\">\n", wl_mode); websWrite (wp, "<script |
|---|
| 3848 | * type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option |
|---|
| 3849 | * value=\\\"ap\\\" %s >\" + wl_basic.ap + |
|---|
| 3850 | * \"</option>\");\n//]]>\n</script>\n", nvram_match (wl_mode, "ap") |
|---|
| 3851 | * ? "selected=\\\"selected\\\"" : ""); websWrite (wp, "<script |
|---|
| 3852 | * type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option |
|---|
| 3853 | * value=\\\"infra\\\" %s >\" + wl_basic.adhoc + |
|---|
| 3854 | * \"</option>\");\n//]]>\n</script>\n", nvram_match (wl_mode, |
|---|
| 3855 | * "infra") ? "selected=\\\"selected\\\"" : ""); websWrite (wp, |
|---|
| 3856 | * "<script type=\"text/javascript\">\n//<![CDATA[\n |
|---|
| 3857 | * document.write(\"<option value=\\\"wdssta\\\" %s >\" + |
|---|
| 3858 | * wl_basic.wdssta + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 3859 | * nvram_match (wl_mode, "wdssta") ? "selected=\\\"selected\\\"" : |
|---|
| 3860 | * ""); websWrite (wp, "<script |
|---|
| 3861 | * type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option |
|---|
| 3862 | * value=\\\"wdsap\\\" %s >\" + wl_basic.wdsap + |
|---|
| 3863 | * \"</option>\");\n//]]>\n</script>\n", nvram_match (wl_mode, |
|---|
| 3864 | * "wdsap") ? "selected=\\\"selected\\\"" : ""); websWrite (wp, |
|---|
| 3865 | * "</select>\n"); websWrite (wp, "</div>\n"); } #endif |
|---|
| 3866 | */ |
|---|
| 3867 | } |
|---|
| 3868 | // writeless net mode |
|---|
| 3869 | show_netmode(wp, prefix); |
|---|
| 3870 | // turbo options |
|---|
| 3871 | #ifdef HAVE_MADWIFI |
|---|
| 3872 | |
|---|
| 3873 | // char wl_xchanmode[16]; |
|---|
| 3874 | char wl_outdoor[16]; |
|---|
| 3875 | char wl_diversity[16]; |
|---|
| 3876 | char wl_rxantenna[16]; |
|---|
| 3877 | char wl_txantenna[16]; |
|---|
| 3878 | char wl_width[16]; |
|---|
| 3879 | char wl_preamble[16]; |
|---|
| 3880 | char wl_xr[16]; |
|---|
| 3881 | char wl_comp[32]; |
|---|
| 3882 | char wl_ff[16]; |
|---|
| 3883 | char wmm[32]; |
|---|
| 3884 | char wl_isolate[32]; |
|---|
| 3885 | char wl_sifstime[32]; |
|---|
| 3886 | char wl_preambletime[32]; |
|---|
| 3887 | char wl_intmit[32]; |
|---|
| 3888 | char wl_noise_immunity[32]; |
|---|
| 3889 | char wl_ofdm_weak_det[32]; |
|---|
| 3890 | char wl_protmode[32]; |
|---|
| 3891 | char wl_doth[32]; |
|---|
| 3892 | char wl_csma[32]; |
|---|
| 3893 | |
|---|
| 3894 | sprintf(wl_csma, "%s_csma", prefix); |
|---|
| 3895 | sprintf(wl_doth, "%s_doth", prefix); |
|---|
| 3896 | sprintf(wl_protmode, "%s_protmode", prefix); |
|---|
| 3897 | sprintf(wl_outdoor, "%s_outdoor", prefix); |
|---|
| 3898 | sprintf(wl_diversity, "%s_diversity", prefix); |
|---|
| 3899 | sprintf(wl_rxantenna, "%s_rxantenna", prefix); |
|---|
| 3900 | sprintf(wl_txantenna, "%s_txantenna", prefix); |
|---|
| 3901 | sprintf(wl_width, "%s_channelbw", prefix); |
|---|
| 3902 | // sprintf( wl_comp, "%s_compression", prefix ); |
|---|
| 3903 | sprintf(wl_ff, "%s_ff", prefix); |
|---|
| 3904 | sprintf(wl_preamble, "%s_preamble", prefix); |
|---|
| 3905 | sprintf(wl_preambletime, "%s_preambletime", prefix); |
|---|
| 3906 | sprintf(wl_sifstime, "%s_sifstime", prefix); |
|---|
| 3907 | sprintf(wl_xr, "%s_xr", prefix); |
|---|
| 3908 | |
|---|
| 3909 | sprintf(wl_intmit, "%s_intmit", prefix); |
|---|
| 3910 | sprintf(wl_noise_immunity, "%s_noise_immunity", prefix); |
|---|
| 3911 | sprintf(wl_ofdm_weak_det, "%s_ofdm_weak_det", prefix); |
|---|
| 3912 | |
|---|
| 3913 | #ifdef HAVE_MADWIFI_MIMO |
|---|
| 3914 | if (!is_ar5008(prefix)) |
|---|
| 3915 | #endif |
|---|
| 3916 | { |
|---|
| 3917 | showAutoOption(wp, "wl_basic.intmit", wl_intmit); |
|---|
| 3918 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3919 | websWrite(wp, |
|---|
| 3920 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.noise_immunity)</script></div>\n<select name=\"%s\">\n", |
|---|
| 3921 | wl_noise_immunity); |
|---|
| 3922 | websWrite(wp, |
|---|
| 3923 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3924 | websWrite(wp, |
|---|
| 3925 | "document.write(\"<option value=\\\"0\\\" %s >0</option>\");\n", |
|---|
| 3926 | nvram_default_match(wl_noise_immunity, "0", |
|---|
| 3927 | "4") ? "selected=\\\"selected\\\"" |
|---|
| 3928 | : ""); |
|---|
| 3929 | websWrite(wp, |
|---|
| 3930 | "document.write(\"<option value=\\\"1\\\" %s >1</option>\");\n", |
|---|
| 3931 | nvram_default_match(wl_noise_immunity, "1", |
|---|
| 3932 | "4") ? "selected=\\\"selected\\\"" |
|---|
| 3933 | : ""); |
|---|
| 3934 | websWrite(wp, |
|---|
| 3935 | "document.write(\"<option value=\\\"2\\\" %s >2</option>\");\n", |
|---|
| 3936 | nvram_default_match(wl_noise_immunity, "2", |
|---|
| 3937 | "4") ? "selected=\\\"selected\\\"" |
|---|
| 3938 | : ""); |
|---|
| 3939 | websWrite(wp, |
|---|
| 3940 | "document.write(\"<option value=\\\"3\\\" %s >3</option>\");\n", |
|---|
| 3941 | nvram_default_match(wl_noise_immunity, "3", |
|---|
| 3942 | "4") ? "selected=\\\"selected\\\"" |
|---|
| 3943 | : ""); |
|---|
| 3944 | websWrite(wp, |
|---|
| 3945 | "document.write(\"<option value=\\\"4\\\" %s >4</option>\");\n", |
|---|
| 3946 | nvram_default_match(wl_noise_immunity, "4", |
|---|
| 3947 | "4") ? "selected=\\\"selected\\\"" |
|---|
| 3948 | : ""); |
|---|
| 3949 | websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 3950 | |
|---|
| 3951 | showRadio(wp, "wl_basic.ofdm_weak_det", wl_ofdm_weak_det); |
|---|
| 3952 | } |
|---|
| 3953 | |
|---|
| 3954 | showOptionsLabel(wp, "wl_basic.protmode", wl_protmode, |
|---|
| 3955 | "None CTS RTS/CTS", nvram_default_get(wl_protmode, |
|---|
| 3956 | "None")); |
|---|
| 3957 | showrtssettings(wp, prefix); |
|---|
| 3958 | show_rates(wp, prefix, 0); |
|---|
| 3959 | show_rates(wp, prefix, 1); |
|---|
| 3960 | showRadio(wp, "wl_basic.preamble", wl_preamble); |
|---|
| 3961 | #ifdef HAVE_MADWIFI_MIMO |
|---|
| 3962 | if (!is_ar5008(prefix)) |
|---|
| 3963 | #endif |
|---|
| 3964 | { |
|---|
| 3965 | showRadio(wp, "wl_basic.extrange", wl_xr); |
|---|
| 3966 | showRadio(wp, "wl_basic.supergff", wl_ff); |
|---|
| 3967 | } |
|---|
| 3968 | #if 0 |
|---|
| 3969 | showRadio(wp, "wl_basic.csma", wl_csma); |
|---|
| 3970 | #endif |
|---|
| 3971 | // showOption (wp, "wl_basic.extchannel", wl_xchanmode); |
|---|
| 3972 | #if !defined(HAVE_FONERA) && !defined(HAVE_LS2) && !defined(HAVE_MERAKI) |
|---|
| 3973 | if (nvram_match("ath_regulatory", "1") || !issuperchannel()) { |
|---|
| 3974 | showRadio(wp, "wl_basic.outband", wl_outdoor); |
|---|
| 3975 | } |
|---|
| 3976 | #endif |
|---|
| 3977 | websWrite(wp, |
|---|
| 3978 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_width)</script></div><select name=\"%s\" >\n", |
|---|
| 3979 | wl_width); |
|---|
| 3980 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3981 | #ifdef HAVE_MADWIFI_MIMO |
|---|
| 3982 | if (is_ar5008(prefix)) { |
|---|
| 3983 | websWrite(wp, |
|---|
| 3984 | "document.write(\"<option value=\\\"2040\\\" %s >\" + share.dynamicturbo + \"</option>\");\n", |
|---|
| 3985 | nvram_match(wl_width, |
|---|
| 3986 | "2040") ? "selected=\\\"selected\\\"" : |
|---|
| 3987 | ""); |
|---|
| 3988 | |
|---|
| 3989 | } |
|---|
| 3990 | #endif |
|---|
| 3991 | websWrite(wp, |
|---|
| 3992 | "document.write(\"<option value=\\\"40\\\" %s >\" + share.turbo + \"</option>\");\n", |
|---|
| 3993 | nvram_match(wl_width, |
|---|
| 3994 | "40") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3995 | websWrite(wp, |
|---|
| 3996 | "document.write(\"<option value=\\\"20\\\" %s >\" + share.full + \"</option>\");\n", |
|---|
| 3997 | nvram_match(wl_width, |
|---|
| 3998 | "20") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3999 | websWrite(wp, |
|---|
| 4000 | "document.write(\"<option value=\\\"10\\\" %s >\" + share.half + \"</option>\");\n", |
|---|
| 4001 | nvram_match(wl_width, |
|---|
| 4002 | "10") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4003 | websWrite(wp, |
|---|
| 4004 | "document.write(\"<option value=\\\"5\\\" %s >\" + share.quarter + \"</option>\");\n", |
|---|
| 4005 | nvram_match(wl_width, |
|---|
| 4006 | "5") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4007 | #ifdef HAVE_SUBQUARTER |
|---|
| 4008 | /* will be enabled once it is tested and the spectrum analyse is done */ |
|---|
| 4009 | websWrite(wp, |
|---|
| 4010 | "document.write(\"<option value=\\\"2\\\" %s >\" + share.subquarter + \"</option>\");\n", |
|---|
| 4011 | nvram_match(wl_width, |
|---|
| 4012 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4013 | #endif |
|---|
| 4014 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4015 | websWrite(wp, "</select>\n"); |
|---|
| 4016 | websWrite(wp, "</div>\n"); |
|---|
| 4017 | /*#if defined(HAVE_EOC5610) |
|---|
| 4018 | websWrite(wp, |
|---|
| 4019 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label25)</script></div><select name=\"%s\" >\n", |
|---|
| 4020 | wl_txantenna); |
|---|
| 4021 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 4022 | websWrite(wp, |
|---|
| 4023 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.ghz5 + \"</option>\");\n", |
|---|
| 4024 | nvram_match(wl_txantenna, |
|---|
| 4025 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4026 | websWrite(wp, |
|---|
| 4027 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.ghz24 + \"</option>\");\n", |
|---|
| 4028 | nvram_match(wl_txantenna, |
|---|
| 4029 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4030 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4031 | |
|---|
| 4032 | websWrite(wp, "</select>\n"); |
|---|
| 4033 | websWrite(wp, "</div>\n");*/ |
|---|
| 4034 | #if defined(HAVE_PICO2) || defined(HAVE_PICO2HP) || defined(HAVE_PICO5) |
|---|
| 4035 | |
|---|
| 4036 | /* websWrite( wp, |
|---|
| 4037 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label25)</script></div><select name=\"%s\" >\n", |
|---|
| 4038 | wl_txantenna ); |
|---|
| 4039 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 4040 | websWrite( wp, |
|---|
| 4041 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.internal + \"</option>\");\n", |
|---|
| 4042 | nvram_match( wl_txantenna, |
|---|
| 4043 | "1" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 4044 | websWrite( wp, |
|---|
| 4045 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.external + \"</option>\");\n", |
|---|
| 4046 | nvram_match( wl_txantenna, |
|---|
| 4047 | "2" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 4048 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4049 | |
|---|
| 4050 | websWrite( wp, "</select>\n" ); |
|---|
| 4051 | websWrite( wp, "</div>\n" );*/ |
|---|
| 4052 | //#elif defined(HAVE_EOC1650) |
|---|
| 4053 | /* websWrite( wp, |
|---|
| 4054 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label25)</script></div><select name=\"%s\" >\n", |
|---|
| 4055 | wl_txantenna ); |
|---|
| 4056 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 4057 | websWrite( wp, |
|---|
| 4058 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.internal + \"</option>\");\n", |
|---|
| 4059 | nvram_match( wl_txantenna, |
|---|
| 4060 | "2" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 4061 | websWrite( wp, |
|---|
| 4062 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.external + \"</option>\");\n", |
|---|
| 4063 | nvram_match( wl_txantenna, |
|---|
| 4064 | "1" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 4065 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4066 | |
|---|
| 4067 | websWrite( wp, "</select>\n" ); |
|---|
| 4068 | websWrite( wp, "</div>\n" );*/ |
|---|
| 4069 | #elif defined(HAVE_NS2) || defined(HAVE_NS5) || defined(HAVE_LC2) || defined(HAVE_LC5) || defined(HAVE_NS3) |
|---|
| 4070 | |
|---|
| 4071 | websWrite(wp, |
|---|
| 4072 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label24)</script></div><select name=\"%s\" >\n", |
|---|
| 4073 | wl_txantenna); |
|---|
| 4074 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 4075 | websWrite(wp, |
|---|
| 4076 | "document.write(\"<option value=\\\"0\\\" %s >\" + wl_basic.vertical + \"</option>\");\n", |
|---|
| 4077 | nvram_match(wl_txantenna, |
|---|
| 4078 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4079 | websWrite(wp, |
|---|
| 4080 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.horizontal + \"</option>\");\n", |
|---|
| 4081 | nvram_match(wl_txantenna, |
|---|
| 4082 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4083 | #if defined(HAVE_NS5) || defined(HAVE_NS2) || defined(HAVE_NS3) |
|---|
| 4084 | websWrite(wp, |
|---|
| 4085 | "document.write(\"<option value=\\\"3\\\" %s >\" + wl_basic.adaptive + \"</option>\");\n", |
|---|
| 4086 | nvram_match(wl_txantenna, |
|---|
| 4087 | "3") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4088 | websWrite(wp, |
|---|
| 4089 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.external + \"</option>\");\n", |
|---|
| 4090 | nvram_match(wl_txantenna, |
|---|
| 4091 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4092 | #endif |
|---|
| 4093 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4094 | |
|---|
| 4095 | websWrite(wp, "</select>\n"); |
|---|
| 4096 | websWrite(wp, "</div>\n"); |
|---|
| 4097 | |
|---|
| 4098 | #else |
|---|
| 4099 | #ifdef HAVE_MADWIFI_MIMO |
|---|
| 4100 | if (!is_ar5008(prefix)) |
|---|
| 4101 | #endif |
|---|
| 4102 | { |
|---|
| 4103 | showRadio(wp, "wl_basic.diversity", wl_diversity); |
|---|
| 4104 | websWrite(wp, |
|---|
| 4105 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label12)</script></div><select name=\"%s\" >\n", |
|---|
| 4106 | wl_txantenna); |
|---|
| 4107 | websWrite(wp, |
|---|
| 4108 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 4109 | websWrite(wp, |
|---|
| 4110 | "document.write(\"<option value=\\\"0\\\" %s >\" + wl_basic.diversity + \"</option>\");\n", |
|---|
| 4111 | nvram_match(wl_txantenna, |
|---|
| 4112 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4113 | websWrite(wp, |
|---|
| 4114 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.primary + \"</option>\");\n", |
|---|
| 4115 | nvram_match(wl_txantenna, |
|---|
| 4116 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4117 | websWrite(wp, |
|---|
| 4118 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.secondary + \"</option>\");\n", |
|---|
| 4119 | nvram_match(wl_txantenna, |
|---|
| 4120 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4121 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4122 | websWrite(wp, "</select>\n"); |
|---|
| 4123 | websWrite(wp, "</div>\n"); |
|---|
| 4124 | |
|---|
| 4125 | websWrite(wp, |
|---|
| 4126 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label13)</script></div><select name=\"%s\" >\n", |
|---|
| 4127 | wl_rxantenna); |
|---|
| 4128 | websWrite(wp, |
|---|
| 4129 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 4130 | websWrite(wp, |
|---|
| 4131 | "document.write(\"<option value=\\\"0\\\" %s >\" + wl_basic.diversity + \"</option>\");\n", |
|---|
| 4132 | nvram_match(wl_rxantenna, |
|---|
| 4133 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4134 | websWrite(wp, |
|---|
| 4135 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.primary + \"</option>\");\n", |
|---|
| 4136 | nvram_match(wl_rxantenna, |
|---|
| 4137 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4138 | websWrite(wp, |
|---|
| 4139 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.secondary + \"</option>\");\n", |
|---|
| 4140 | nvram_match(wl_rxantenna, |
|---|
| 4141 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4142 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4143 | websWrite(wp, "</select>\n"); |
|---|
| 4144 | websWrite(wp, "</div>\n"); |
|---|
| 4145 | } |
|---|
| 4146 | #ifdef HAVE_MADWIFI_MIMO |
|---|
| 4147 | else { |
|---|
| 4148 | websWrite(wp, |
|---|
| 4149 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.txchainmask)</script></div><select name=\"%s\" >\n", |
|---|
| 4150 | wl_txantenna); |
|---|
| 4151 | websWrite(wp, |
|---|
| 4152 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 4153 | websWrite(wp, |
|---|
| 4154 | "document.write(\"<option value=\\\"1\\\" %s >1</option>\");\n", |
|---|
| 4155 | nvram_match(wl_txantenna, |
|---|
| 4156 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4157 | // websWrite(wp, |
|---|
| 4158 | // "document.write(\"<option value=\\\"2\\\" %s >2</option>\");\n", |
|---|
| 4159 | // nvram_match(wl_txantenna, |
|---|
| 4160 | // "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4161 | websWrite(wp, |
|---|
| 4162 | "document.write(\"<option value=\\\"3\\\" %s >1+2</option>\");\n", |
|---|
| 4163 | nvram_match(wl_txantenna, |
|---|
| 4164 | "3") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4165 | // websWrite(wp, |
|---|
| 4166 | // "document.write(\"<option value=\\\"4\\\" %s >3</option>\");\n", |
|---|
| 4167 | // nvram_match(wl_txantenna, |
|---|
| 4168 | // "4") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4169 | websWrite(wp, |
|---|
| 4170 | "document.write(\"<option value=\\\"5\\\" %s >1+3</option>\");\n", |
|---|
| 4171 | nvram_match(wl_txantenna, |
|---|
| 4172 | "5") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4173 | // websWrite(wp, |
|---|
| 4174 | // "document.write(\"<option value=\\\"6\\\" %s >2+3</option>\");\n", |
|---|
| 4175 | // nvram_match(wl_txantenna, |
|---|
| 4176 | // "6") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4177 | websWrite(wp, |
|---|
| 4178 | "document.write(\"<option value=\\\"7\\\" %s >1+2+3</option>\");\n", |
|---|
| 4179 | nvram_match(wl_txantenna, |
|---|
| 4180 | "7") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4181 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4182 | websWrite(wp, "</select>\n"); |
|---|
| 4183 | websWrite(wp, "</div>\n"); |
|---|
| 4184 | |
|---|
| 4185 | websWrite(wp, |
|---|
| 4186 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.rxchainmask)</script></div><select name=\"%s\" >\n", |
|---|
| 4187 | wl_rxantenna); |
|---|
| 4188 | websWrite(wp, |
|---|
| 4189 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 4190 | websWrite(wp, |
|---|
| 4191 | "document.write(\"<option value=\\\"1\\\" %s >1</option>\");\n", |
|---|
| 4192 | nvram_match(wl_rxantenna, |
|---|
| 4193 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4194 | // websWrite(wp, |
|---|
| 4195 | // "document.write(\"<option value=\\\"2\\\" %s >2</option>\");\n", |
|---|
| 4196 | // nvram_match(wl_rxantenna, |
|---|
| 4197 | // "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4198 | websWrite(wp, |
|---|
| 4199 | "document.write(\"<option value=\\\"3\\\" %s >1+2</option>\");\n", |
|---|
| 4200 | nvram_match(wl_rxantenna, |
|---|
| 4201 | "3") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4202 | // websWrite(wp, |
|---|
| 4203 | // "document.write(\"<option value=\\\"4\\\" %s >3</option>\");\n", |
|---|
| 4204 | // nvram_match(wl_rxantenna, |
|---|
| 4205 | // "4") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4206 | websWrite(wp, |
|---|
| 4207 | "document.write(\"<option value=\\\"5\\\" %s >1+3</option>\");\n", |
|---|
| 4208 | nvram_match(wl_rxantenna, |
|---|
| 4209 | "5") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4210 | // websWrite(wp, |
|---|
| 4211 | // "document.write(\"<option value=\\\"6\\\" %s >2+3</option>\");\n", |
|---|
| 4212 | // nvram_match(wl_rxantenna, |
|---|
| 4213 | // "6") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4214 | websWrite(wp, |
|---|
| 4215 | "document.write(\"<option value=\\\"7\\\" %s >1+2+3</option>\");\n", |
|---|
| 4216 | nvram_match(wl_rxantenna, |
|---|
| 4217 | "7") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4218 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4219 | websWrite(wp, "</select>\n"); |
|---|
| 4220 | websWrite(wp, "</div>\n"); |
|---|
| 4221 | |
|---|
| 4222 | } |
|---|
| 4223 | #endif |
|---|
| 4224 | #endif |
|---|
| 4225 | #endif |
|---|
| 4226 | #ifdef HAVE_MADWIFI |
|---|
| 4227 | sprintf(wl_isolate, "%s_ap_isolate", prefix); |
|---|
| 4228 | showRadio(wp, "wl_adv.label11", wl_isolate); |
|---|
| 4229 | |
|---|
| 4230 | #if 0 |
|---|
| 4231 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4232 | websWrite(wp, |
|---|
| 4233 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.sifstime)</script></div>\n"); |
|---|
| 4234 | websWrite(wp, |
|---|
| 4235 | "<input class=\"num\" name=\"%s\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,99999999,wl_basic.sifstime)\" value=\"%s\" />\n", |
|---|
| 4236 | wl_sifstime, nvram_default_get(wl_sifstime, "16")); |
|---|
| 4237 | websWrite(wp, "</div>\n"); |
|---|
| 4238 | |
|---|
| 4239 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4240 | websWrite(wp, |
|---|
| 4241 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.preambletime)</script></div>\n"); |
|---|
| 4242 | websWrite(wp, |
|---|
| 4243 | "<input class=\"num\" name=\"%s\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,99999999,wl_basic.preambletime)\" value=\"%s\" />\n", |
|---|
| 4244 | wl_preambletime, nvram_default_get(wl_preambletime, "20")); |
|---|
| 4245 | websWrite(wp, "</div>\n"); |
|---|
| 4246 | #endif |
|---|
| 4247 | #ifdef HAVE_MADWIFI_MIMO |
|---|
| 4248 | if (!is_ar5008(prefix)) |
|---|
| 4249 | #endif |
|---|
| 4250 | { |
|---|
| 4251 | sprintf(wmm, "%s_wmm", prefix); |
|---|
| 4252 | showRadio(wp, "wl_adv.label18", wmm); |
|---|
| 4253 | } |
|---|
| 4254 | #endif |
|---|
| 4255 | |
|---|
| 4256 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4257 | websWrite(wp, |
|---|
| 4258 | "<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", |
|---|
| 4259 | wl_ssid, nvram_safe_get(wl_ssid)); |
|---|
| 4260 | |
|---|
| 4261 | #ifdef HAVE_MADWIFI |
|---|
| 4262 | showRadio(wp, "wl_basic.radar", wl_doth); |
|---|
| 4263 | show_chanshift(wp, prefix); |
|---|
| 4264 | #endif |
|---|
| 4265 | #ifdef HAVE_RT2880 |
|---|
| 4266 | if (nvram_match(wl_mode, "ap") || nvram_match(wl_mode, "wdsap") |
|---|
| 4267 | || nvram_match(wl_mode, "infra") || nvram_match(wl_mode, "apsta") |
|---|
| 4268 | || nvram_match(wl_mode, "apstawet")) |
|---|
| 4269 | #else |
|---|
| 4270 | if (nvram_match(wl_mode, "ap") || nvram_match(wl_mode, "wdsap") |
|---|
| 4271 | || nvram_match(wl_mode, "infra")) |
|---|
| 4272 | #endif |
|---|
| 4273 | { |
|---|
| 4274 | |
|---|
| 4275 | if (has_mimo(prefix) |
|---|
| 4276 | && (nvram_nmatch("n-only", "%s_net_mode", prefix) |
|---|
| 4277 | || nvram_nmatch("ng-only", "%s_net_mode", prefix) |
|---|
| 4278 | || nvram_nmatch("mixed", "%s_net_mode", prefix) |
|---|
| 4279 | || nvram_nmatch("n2-only", "%s_net_mode", prefix) |
|---|
| 4280 | || nvram_nmatch("n5-only", "%s_net_mode", prefix) |
|---|
| 4281 | || nvram_nmatch("na-only", "%s_net_mode", prefix))) { |
|---|
| 4282 | show_channel(wp, prefix, prefix, 1); |
|---|
| 4283 | |
|---|
| 4284 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4285 | websWrite(wp, |
|---|
| 4286 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_width)</script></div>\n"); |
|---|
| 4287 | websWrite(wp, "<select name=\"%s_nbw\">\n", prefix); |
|---|
| 4288 | #ifdef HAVE_RT2880 |
|---|
| 4289 | websWrite(wp, |
|---|
| 4290 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"20\\\" %s >20 Mhz</option>\");\n//]]>\n</script>\n", |
|---|
| 4291 | nvram_nmatch("20", "%s_nbw", |
|---|
| 4292 | prefix) ? |
|---|
| 4293 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4294 | websWrite(wp, "<option value=\"40\" %s>40 MHz</option>", |
|---|
| 4295 | nvram_nmatch("40", "%s_nbw", |
|---|
| 4296 | prefix) ? |
|---|
| 4297 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4298 | #else |
|---|
| 4299 | websWrite(wp, |
|---|
| 4300 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"0\\\" %s >\" + share.auto + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 4301 | nvram_nmatch("0", "%s_nbw", |
|---|
| 4302 | prefix) ? |
|---|
| 4303 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4304 | websWrite(wp, |
|---|
| 4305 | "<option value=\"10\" %s>10 MHz</option>\n", |
|---|
| 4306 | nvram_nmatch("10", "%s_nbw", |
|---|
| 4307 | prefix) ? |
|---|
| 4308 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4309 | websWrite(wp, |
|---|
| 4310 | "<option value=\"20\" %s>20 MHz</option>\n", |
|---|
| 4311 | nvram_nmatch("20", "%s_nbw", |
|---|
| 4312 | prefix) ? |
|---|
| 4313 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4314 | websWrite(wp, |
|---|
| 4315 | "<option value=\"40\" %s>40 MHz</option>\n", |
|---|
| 4316 | nvram_nmatch("40", "%s_nbw", |
|---|
| 4317 | prefix) ? |
|---|
| 4318 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4319 | #endif |
|---|
| 4320 | websWrite(wp, "</select>\n"); |
|---|
| 4321 | websWrite(wp, "</div>\n"); |
|---|
| 4322 | |
|---|
| 4323 | if (nvram_nmatch("40", "%s_nbw", prefix)) { |
|---|
| 4324 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4325 | websWrite(wp, |
|---|
| 4326 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_wide)</script></div>\n"); |
|---|
| 4327 | websWrite(wp, "<select name=\"%s_nctrlsb\" >\n", |
|---|
| 4328 | prefix); |
|---|
| 4329 | websWrite(wp, |
|---|
| 4330 | "<option value=\"upper\" %s>upper</option>\n", |
|---|
| 4331 | nvram_nmatch("upper", "%s_nctrlsb", |
|---|
| 4332 | prefix) ? |
|---|
| 4333 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4334 | websWrite(wp, |
|---|
| 4335 | "<option value=\"lower\" %s>lower</option>\n", |
|---|
| 4336 | nvram_nmatch("lower", "%s_nctrlsb", |
|---|
| 4337 | prefix) ? |
|---|
| 4338 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4339 | websWrite(wp, "</select>\n"); |
|---|
| 4340 | |
|---|
| 4341 | websWrite(wp, "</div>\n"); |
|---|
| 4342 | } |
|---|
| 4343 | } else { |
|---|
| 4344 | |
|---|
| 4345 | show_channel(wp, prefix, prefix, 0); |
|---|
| 4346 | #ifdef HAVE_MADWIFI_MIMO |
|---|
| 4347 | if (is_ar5008(prefix) |
|---|
| 4348 | && (nvram_match(wl_width, "40") |
|---|
| 4349 | || nvram_match(wl_width, "2040"))) { |
|---|
| 4350 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4351 | websWrite(wp, |
|---|
| 4352 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_wide)</script></div>\n"); |
|---|
| 4353 | websWrite(wp, "<select name=\"%s_nctrlsb\" >\n", |
|---|
| 4354 | prefix); |
|---|
| 4355 | websWrite(wp, |
|---|
| 4356 | "<option value=\"upper\" %s>upper</option>\n", |
|---|
| 4357 | nvram_nmatch("upper", "%s_nctrlsb", |
|---|
| 4358 | prefix) ? |
|---|
| 4359 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4360 | websWrite(wp, |
|---|
| 4361 | "<option value=\"lower\" %s>lower</option>\n", |
|---|
| 4362 | nvram_nmatch("lower", "%s_nctrlsb", |
|---|
| 4363 | prefix) ? |
|---|
| 4364 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4365 | websWrite(wp, "</select>\n"); |
|---|
| 4366 | |
|---|
| 4367 | websWrite(wp, "</div>\n"); |
|---|
| 4368 | } |
|---|
| 4369 | #endif |
|---|
| 4370 | } |
|---|
| 4371 | |
|---|
| 4372 | char wl_closed[16]; |
|---|
| 4373 | |
|---|
| 4374 | sprintf(wl_closed, "%s_closed", prefix); |
|---|
| 4375 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4376 | websWrite(wp, |
|---|
| 4377 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label5)</script></div>\n"); |
|---|
| 4378 | websWrite(wp, |
|---|
| 4379 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input> \n", |
|---|
| 4380 | wl_closed, nvram_match(wl_closed, |
|---|
| 4381 | "0") ? "checked=\"checked\"" : |
|---|
| 4382 | ""); |
|---|
| 4383 | websWrite(wp, |
|---|
| 4384 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input>\n", |
|---|
| 4385 | wl_closed, nvram_match(wl_closed, |
|---|
| 4386 | "1") ? "checked=\"checked\"" : |
|---|
| 4387 | ""); |
|---|
| 4388 | websWrite(wp, "</div>\n"); |
|---|
| 4389 | } |
|---|
| 4390 | #ifdef HAVE_MADWIFI |
|---|
| 4391 | // if (nvram_match (wl_mode, "sta") || nvram_match (wl_mode, "wdssta") |
|---|
| 4392 | // || nvram_match (wl_mode, "wet")) |
|---|
| 4393 | { |
|---|
| 4394 | char wl_scanlist[32]; |
|---|
| 4395 | |
|---|
| 4396 | sprintf(wl_scanlist, "%s_scanlist", prefix); |
|---|
| 4397 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4398 | websWrite(wp, |
|---|
| 4399 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.scanlist)</script></div>\n"); |
|---|
| 4400 | websWrite(wp, |
|---|
| 4401 | "<input name=\"%s\" size=\"32\" maxlength=\"512\" value=\"%s\" />\n", |
|---|
| 4402 | wl_scanlist, nvram_default_get(wl_scanlist, |
|---|
| 4403 | "default")); |
|---|
| 4404 | websWrite(wp, "</div>\n"); |
|---|
| 4405 | } |
|---|
| 4406 | #endif |
|---|
| 4407 | |
|---|
| 4408 | // ACK timing |
|---|
| 4409 | #if defined(HAVE_ACK) || defined(HAVE_MADWIFI) // temp fix for v24 broadcom |
|---|
| 4410 | // ACKnot working |
|---|
| 4411 | |
|---|
| 4412 | sprintf(power, "%s_distance", prefix); |
|---|
| 4413 | websWrite(wp, "<br />\n"); |
|---|
| 4414 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4415 | websWrite(wp, |
|---|
| 4416 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label6)</script></div>\n"); |
|---|
| 4417 | websWrite(wp, |
|---|
| 4418 | "<input class=\"num\" name=\"%s\" size=\"8\" maxlength=\"8\" onblur=\"valid_range(this,0,99999999,wl_basic.label6)\" value=\"%s\" />\n", |
|---|
| 4419 | power, nvram_default_get(power, "2000")); |
|---|
| 4420 | websWrite(wp, |
|---|
| 4421 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 2000 \" + share.meters + \")\");\n//]]>\n</script></span>\n"); |
|---|
| 4422 | websWrite(wp, "</div>\n"); |
|---|
| 4423 | // end ACK timing |
|---|
| 4424 | #endif |
|---|
| 4425 | #ifdef HAVE_MADWIFI |
|---|
| 4426 | if (nvram_nmatch("ap", "%s_mode", prefix) |
|---|
| 4427 | || nvram_nmatch("wdsap", "%s_mode", prefix) |
|---|
| 4428 | || nvram_nmatch("infra", "%s_mode", prefix)) { |
|---|
| 4429 | sprintf(power, "%s_maxassoc", prefix); |
|---|
| 4430 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4431 | websWrite(wp, |
|---|
| 4432 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label10)</script></div>\n"); |
|---|
| 4433 | websWrite(wp, |
|---|
| 4434 | "<input class=\"num\" name=\"%s\" size=\"4\" maxlength=\"4\" onblur=\"valid_range(this,0,256,wl_basic.label6)\" value=\"%s\" />\n", |
|---|
| 4435 | power, nvram_default_get(power, "256")); |
|---|
| 4436 | websWrite(wp, |
|---|
| 4437 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 256 \" + status_wireless.legend3 + \")\");\n//]]>\n</script></span>\n"); |
|---|
| 4438 | websWrite(wp, "</div>\n"); |
|---|
| 4439 | } |
|---|
| 4440 | sprintf(power, "%s_mtikie", prefix); |
|---|
| 4441 | nvram_default_get(power, "0"); |
|---|
| 4442 | showRadio(wp, "wl_basic.mtikie", power); |
|---|
| 4443 | |
|---|
| 4444 | showbridgesettings(wp, prefix, 1, 1); |
|---|
| 4445 | #elif HAVE_RT2880 |
|---|
| 4446 | showbridgesettings(wp, "ra0", 1, 1); |
|---|
| 4447 | #else |
|---|
| 4448 | if (!strcmp(prefix, "wl0")) |
|---|
| 4449 | showbridgesettings(wp, get_wl_instance_name(0), 1, 1); |
|---|
| 4450 | if (!strcmp(prefix, "wl1")) |
|---|
| 4451 | showbridgesettings(wp, get_wl_instance_name(1), 1, 1); |
|---|
| 4452 | #endif |
|---|
| 4453 | websWrite(wp, "</fieldset>\n"); |
|---|
| 4454 | websWrite(wp, "<br />\n"); |
|---|
| 4455 | #ifdef HAVE_REGISTER |
|---|
| 4456 | if (!iscpe()) |
|---|
| 4457 | #endif |
|---|
| 4458 | show_virtualssid(wp, prefix); |
|---|
| 4459 | } |
|---|
| 4460 | |
|---|
| 4461 | void ej_show_wireless(webs_t wp, int argc, char_t ** argv) |
|---|
| 4462 | { |
|---|
| 4463 | #ifdef HAVE_MADWIFI |
|---|
| 4464 | int c = getdevicecount(); |
|---|
| 4465 | int i; |
|---|
| 4466 | |
|---|
| 4467 | for (i = 0; i < c; i++) { |
|---|
| 4468 | char buf[16]; |
|---|
| 4469 | |
|---|
| 4470 | sprintf(buf, "ath%d", i); |
|---|
| 4471 | ej_show_wireless_single(wp, buf); |
|---|
| 4472 | } |
|---|
| 4473 | #else |
|---|
| 4474 | int c = get_wl_instances(); |
|---|
| 4475 | int i; |
|---|
| 4476 | |
|---|
| 4477 | for (i = 0; i < c; i++) { |
|---|
| 4478 | char buf[16]; |
|---|
| 4479 | |
|---|
| 4480 | sprintf(buf, "wl%d", i); |
|---|
| 4481 | ej_show_wireless_single(wp, buf); |
|---|
| 4482 | } |
|---|
| 4483 | #endif |
|---|
| 4484 | return; |
|---|
| 4485 | } |
|---|
| 4486 | |
|---|
| 4487 | void show_preshared(webs_t wp, char *prefix) |
|---|
| 4488 | { |
|---|
| 4489 | char var[80]; |
|---|
| 4490 | |
|---|
| 4491 | cprintf("show preshared"); |
|---|
| 4492 | sprintf(var, "%s_crypto", prefix); |
|---|
| 4493 | websWrite(wp, "<div><div class=\"setting\">\n"); |
|---|
| 4494 | websWrite(wp, |
|---|
| 4495 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.algorithms)</script></div>\n"); |
|---|
| 4496 | websWrite(wp, "<select name=\"%s_crypto\">\n", prefix); |
|---|
| 4497 | websWrite(wp, "<option value=\"tkip\" %s>TKIP</option>\n", |
|---|
| 4498 | selmatch(var, "tkip", "selected=\"selected\"")); |
|---|
| 4499 | websWrite(wp, "<option value=\"aes\" %s>AES</option>\n", |
|---|
| 4500 | selmatch(var, "aes", "selected=\"selected\"")); |
|---|
| 4501 | websWrite(wp, "<option value=\"tkip+aes\" %s>TKIP+AES</option>\n", |
|---|
| 4502 | selmatch(var, "tkip+aes", "selected=\"selected\"")); |
|---|
| 4503 | websWrite(wp, "</select>\n"); |
|---|
| 4504 | websWrite(wp, "</div>\n"); |
|---|
| 4505 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4506 | websWrite(wp, |
|---|
| 4507 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.shared_key)</script></div>\n"); |
|---|
| 4508 | sprintf(var, "%s_wpa_psk", prefix); |
|---|
| 4509 | websWrite(wp, |
|---|
| 4510 | "<input type=\"password\" id=\"%s_wpa_psk\" name=\"%s_wpa_psk\" onblur=\"valid_psk_length(this)\" maxlength=\"64\" size=\"32\" value=\"", |
|---|
| 4511 | prefix, prefix); |
|---|
| 4512 | tf_webWriteESCNV(wp, var); |
|---|
| 4513 | websWrite(wp, "\" /> \n"); |
|---|
| 4514 | websWrite(wp, |
|---|
| 4515 | "<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", |
|---|
| 4516 | prefix, prefix); |
|---|
| 4517 | websWrite(wp, "</div>\n"); |
|---|
| 4518 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4519 | websWrite(wp, |
|---|
| 4520 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.rekey)</script></div>\n"); |
|---|
| 4521 | sprintf(var, "%s_wpa_gtk_rekey", prefix); |
|---|
| 4522 | websWrite(wp, |
|---|
| 4523 | "<input class=\"num\" name=\"%s_wpa_gtk_rekey\" maxlength=\"5\" size=\"5\" onblur=\"valid_range(this,0,99999,wpa.rekey)\" value=\"%s\" />\n", |
|---|
| 4524 | prefix, nvram_default_get(var, "3600")); |
|---|
| 4525 | websWrite(wp, |
|---|
| 4526 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 3600, \" + share.range + \": 1 - 99999)\");\n//]]>\n</script></span>\n"); |
|---|
| 4527 | websWrite(wp, "</div>\n"); |
|---|
| 4528 | websWrite(wp, "</div>\n"); |
|---|
| 4529 | } |
|---|
| 4530 | |
|---|
| 4531 | void show_radius(webs_t wp, char *prefix, int showmacformat, int backup) |
|---|
| 4532 | { |
|---|
| 4533 | char var[80]; |
|---|
| 4534 | |
|---|
| 4535 | cprintf("show radius\n"); |
|---|
| 4536 | if (showmacformat) { |
|---|
| 4537 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4538 | websWrite(wp, |
|---|
| 4539 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label2)</script></div>\n"); |
|---|
| 4540 | websWrite(wp, "<select name=\"%s_radmactype\">\n", prefix); |
|---|
| 4541 | websWrite(wp, |
|---|
| 4542 | "<option value=\"0\" %s >aabbcc-ddeeff</option>\n", |
|---|
| 4543 | nvram_prefix_match("radmactype", prefix, |
|---|
| 4544 | "0") ? "selected" : ""); |
|---|
| 4545 | websWrite(wp, "<option value=\"1\" %s >aabbccddeeff</option>\n", |
|---|
| 4546 | nvram_prefix_match("radmactype", prefix, |
|---|
| 4547 | "1") ? "selected" : ""); |
|---|
| 4548 | websWrite(wp, |
|---|
| 4549 | "<option value=\"2\" %s >aa:bb:cc:dd:ee:ff</option>\n", |
|---|
| 4550 | nvram_prefix_match("radmactype", prefix, |
|---|
| 4551 | "2") ? "selected" : ""); |
|---|
| 4552 | websWrite(wp, |
|---|
| 4553 | "<option value=\"3\" %s >aa-bb-cc-dd-ee-ff</option>\n", |
|---|
| 4554 | nvram_prefix_match("radmactype", prefix, |
|---|
| 4555 | "3") ? "selected" : ""); |
|---|
| 4556 | websWrite(wp, "</select>\n"); |
|---|
| 4557 | websWrite(wp, "</div>\n"); |
|---|
| 4558 | } |
|---|
| 4559 | char *rad = nvram_nget("%s_radius_ipaddr", prefix); |
|---|
| 4560 | |
|---|
| 4561 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4562 | websWrite(wp, |
|---|
| 4563 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label3)</script></div>\n"); |
|---|
| 4564 | websWrite(wp, |
|---|
| 4565 | "<input type=\"hidden\" name=\"%s_radius_ipaddr\" value=\"4\" />\n", |
|---|
| 4566 | prefix); |
|---|
| 4567 | websWrite(wp, |
|---|
| 4568 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_0\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4569 | prefix, get_single_ip(rad, 0)); |
|---|
| 4570 | websWrite(wp, |
|---|
| 4571 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_1\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4572 | prefix, get_single_ip(rad, 1)); |
|---|
| 4573 | websWrite(wp, |
|---|
| 4574 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_2\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4575 | prefix, get_single_ip(rad, 2)); |
|---|
| 4576 | websWrite(wp, |
|---|
| 4577 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_3\" onblur=\"valid_range(this,1,254,radius.label3)\" class=\"num\" value=\"%d\" />\n", |
|---|
| 4578 | prefix, get_single_ip(rad, 3)); |
|---|
| 4579 | websWrite(wp, "</div>\n"); |
|---|
| 4580 | |
|---|
| 4581 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4582 | websWrite(wp, |
|---|
| 4583 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label4)</script></div>\n"); |
|---|
| 4584 | sprintf(var, "%s_radius_port", prefix); |
|---|
| 4585 | websWrite(wp, |
|---|
| 4586 | "<input name=\"%s_radius_port\" size=\"3\" maxlength=\"5\" onblur=\"valid_range(this,1,65535,radius.label4)\" value=\"%s\" />\n", |
|---|
| 4587 | prefix, nvram_default_get(var, "1812")); |
|---|
| 4588 | websWrite(wp, |
|---|
| 4589 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 1812)\");\n//]]>\n</script></span>\n</div>\n"); |
|---|
| 4590 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4591 | websWrite(wp, |
|---|
| 4592 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label7)</script></div>\n"); |
|---|
| 4593 | sprintf(var, "%s_radius_key", prefix); |
|---|
| 4594 | websWrite(wp, |
|---|
| 4595 | "<input type=\"password\" id=\"%s_radius_key\" name=\"%s_radius_key\" maxlength=\"79\" size=\"32\" value=\"", |
|---|
| 4596 | prefix, prefix); |
|---|
| 4597 | |
|---|
| 4598 | tf_webWriteESCNV(wp, var); |
|---|
| 4599 | websWrite(wp, "\" /> \n"); |
|---|
| 4600 | websWrite(wp, |
|---|
| 4601 | "<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", |
|---|
| 4602 | prefix, prefix); |
|---|
| 4603 | |
|---|
| 4604 | if (backup) { |
|---|
| 4605 | rad = nvram_nget("%s_radius2_ipaddr", prefix); |
|---|
| 4606 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4607 | websWrite(wp, |
|---|
| 4608 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label23)</script></div>\n"); |
|---|
| 4609 | websWrite(wp, |
|---|
| 4610 | "<input type=\"hidden\" name=\"%s_radius2_ipaddr\" value=\"4\" />\n", |
|---|
| 4611 | prefix); |
|---|
| 4612 | websWrite(wp, |
|---|
| 4613 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius2_ipaddr_0\" onblur=\"valid_range(this,0,255,radius.label23)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4614 | prefix, get_single_ip(rad, 0)); |
|---|
| 4615 | websWrite(wp, |
|---|
| 4616 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius2_ipaddr_1\" onblur=\"valid_range(this,0,255,radius.label23)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4617 | prefix, get_single_ip(rad, 1)); |
|---|
| 4618 | websWrite(wp, |
|---|
| 4619 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius2_ipaddr_2\" onblur=\"valid_range(this,0,255,radius.label23)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4620 | prefix, get_single_ip(rad, 2)); |
|---|
| 4621 | websWrite(wp, |
|---|
| 4622 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius2_ipaddr_3\" onblur=\"valid_range(this,1,254,radius.label23)\" class=\"num\" value=\"%d\" />\n", |
|---|
| 4623 | prefix, get_single_ip(rad, 3)); |
|---|
| 4624 | websWrite(wp, "</div>\n"); |
|---|
| 4625 | |
|---|
| 4626 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4627 | websWrite(wp, |
|---|
| 4628 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label24)</script></div>\n"); |
|---|
| 4629 | sprintf(var, "%s_radius2_port", prefix); |
|---|
| 4630 | websWrite(wp, |
|---|
| 4631 | "<input name=\"%s_radius2_port\" size=\"3\" maxlength=\"5\" onblur=\"valid_range(this,1,65535,radius.label24)\" value=\"%s\" />\n", |
|---|
| 4632 | prefix, nvram_default_get(var, "1812")); |
|---|
| 4633 | websWrite(wp, |
|---|
| 4634 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 1812)\");\n//]]>\n</script></span>\n</div>\n"); |
|---|
| 4635 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4636 | websWrite(wp, |
|---|
| 4637 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label27)</script></div>\n"); |
|---|
| 4638 | sprintf(var, "%s_radius2_key", prefix); |
|---|
| 4639 | websWrite(wp, |
|---|
| 4640 | "<input type=\"password\" id=\"%s_radius2_key\" name=\"%s_radius2_key\" maxlength=\"79\" size=\"32\" value=\"", |
|---|
| 4641 | prefix, prefix); |
|---|
| 4642 | |
|---|
| 4643 | tf_webWriteESCNV(wp, var); |
|---|
| 4644 | websWrite(wp, "\" /> \n"); |
|---|
| 4645 | } |
|---|
| 4646 | websWrite(wp, |
|---|
| 4647 | "<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", |
|---|
| 4648 | prefix, prefix); |
|---|
| 4649 | websWrite(wp, "</div>\n"); |
|---|
| 4650 | #ifdef HAVE_MADWIFI |
|---|
| 4651 | if (!showmacformat) { |
|---|
| 4652 | char acct[32]; |
|---|
| 4653 | char vvar[32]; |
|---|
| 4654 | |
|---|
| 4655 | strcpy(vvar, prefix); |
|---|
| 4656 | rep(vvar, '.', 'X'); |
|---|
| 4657 | sprintf(acct, "%s_acct", var); |
|---|
| 4658 | websWrite(wp, |
|---|
| 4659 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label18)</script></div>\n"); |
|---|
| 4660 | websWrite(wp, |
|---|
| 4661 | "<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", |
|---|
| 4662 | vvar, prefix, nvram_default_match(acct, "1", |
|---|
| 4663 | "0") ? |
|---|
| 4664 | "checked=\"checked\"" : ""); |
|---|
| 4665 | websWrite(wp, |
|---|
| 4666 | "<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", |
|---|
| 4667 | vvar, prefix, nvram_default_match(acct, "0", |
|---|
| 4668 | "0") ? |
|---|
| 4669 | "checked=\"checked\"" : ""); |
|---|
| 4670 | websWrite(wp, "</div>\n"); |
|---|
| 4671 | char *rad = nvram_nget("%s_acct_ipaddr", prefix); |
|---|
| 4672 | |
|---|
| 4673 | websWrite(wp, "<div id=\"%s_idacct\">\n", vvar); |
|---|
| 4674 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4675 | websWrite(wp, |
|---|
| 4676 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label13)</script></div>\n"); |
|---|
| 4677 | websWrite(wp, |
|---|
| 4678 | "<input type=\"hidden\" name=\"%s_acct_ipaddr\" value=\"4\" />\n", |
|---|
| 4679 | prefix); |
|---|
| 4680 | websWrite(wp, |
|---|
| 4681 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_0\" onblur=\"valid_range(this,0,255,radius.label13)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4682 | prefix, get_single_ip(rad, 0)); |
|---|
| 4683 | websWrite(wp, |
|---|
| 4684 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_1\" onblur=\"valid_range(this,0,255,radius.label13)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4685 | prefix, get_single_ip(rad, 1)); |
|---|
| 4686 | websWrite(wp, |
|---|
| 4687 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_2\" onblur=\"valid_range(this,0,255,radius.label13)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4688 | prefix, get_single_ip(rad, 2)); |
|---|
| 4689 | websWrite(wp, |
|---|
| 4690 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_3\" onblur=\"valid_range(this,1,254,radius.label13)\" class=\"num\" value=\"%d\" />\n", |
|---|
| 4691 | prefix, get_single_ip(rad, 3)); |
|---|
| 4692 | websWrite(wp, "</div>\n"); |
|---|
| 4693 | |
|---|
| 4694 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4695 | websWrite(wp, |
|---|
| 4696 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label14)</script></div>\n"); |
|---|
| 4697 | sprintf(var, "%s_acct_port", prefix); |
|---|
| 4698 | websWrite(wp, |
|---|
| 4699 | "<input name=\"%s_acct_port\" size=\"3\" maxlength=\"5\" onblur=\"valid_range(this,1,65535,radius.label14)\" value=\"%s\" />\n", |
|---|
| 4700 | prefix, nvram_default_get(var, "1813")); |
|---|
| 4701 | websWrite(wp, |
|---|
| 4702 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 1812)\");\n//]]>\n</script></span>\n</div>\n"); |
|---|
| 4703 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4704 | websWrite(wp, |
|---|
| 4705 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label17)</script></div>\n"); |
|---|
| 4706 | sprintf(var, "%s_acct_key", prefix); |
|---|
| 4707 | websWrite(wp, |
|---|
| 4708 | "<input type=\"password\" id=\"%s_acct_key\" name=\"%s_acct_key\" maxlength=\"79\" size=\"32\" value=\"", |
|---|
| 4709 | prefix, prefix); |
|---|
| 4710 | tf_webWriteESCNV(wp, var); |
|---|
| 4711 | websWrite(wp, "\" /> \n"); |
|---|
| 4712 | websWrite(wp, |
|---|
| 4713 | "<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", |
|---|
| 4714 | prefix, prefix); |
|---|
| 4715 | websWrite(wp, "</div>\n"); |
|---|
| 4716 | websWrite(wp, "</div>\n"); |
|---|
| 4717 | websWrite(wp, "<script>\n//<![CDATA[\n "); |
|---|
| 4718 | websWrite(wp, |
|---|
| 4719 | "show_layer_ext(document.getElementsByName(\"%s_acct\"), \"%s_idacct\", %s);\n", |
|---|
| 4720 | prefix, vvar, nvram_match(acct, |
|---|
| 4721 | "1") ? "true" : "false"); |
|---|
| 4722 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4723 | } |
|---|
| 4724 | #endif |
|---|
| 4725 | } |
|---|
| 4726 | |
|---|
| 4727 | #ifdef HAVE_WPA_SUPPLICANT |
|---|
| 4728 | |
|---|
| 4729 | static void init_80211x_layers(webs_t wp, char *prefix) |
|---|
| 4730 | { |
|---|
| 4731 | if (nvram_prefix_match("8021xtype", prefix, "tls")) { |
|---|
| 4732 | websWrite(wp, "enable_idtls(\"%s\");\n", prefix); |
|---|
| 4733 | } |
|---|
| 4734 | if (nvram_prefix_match("8021xtype", prefix, "leap")) { |
|---|
| 4735 | websWrite(wp, "enable_idleap(\"%s\");\n", prefix); |
|---|
| 4736 | } |
|---|
| 4737 | if (nvram_prefix_match("8021xtype", prefix, "ttls")) { |
|---|
| 4738 | websWrite(wp, "enable_idttls(\"%s\");\n", prefix); |
|---|
| 4739 | } |
|---|
| 4740 | if (nvram_prefix_match("8021xtype", prefix, "peap")) { |
|---|
| 4741 | websWrite(wp, "enable_idpeap(\"%s\");\n", prefix); |
|---|
| 4742 | } |
|---|
| 4743 | } |
|---|
| 4744 | |
|---|
| 4745 | void ej_init_80211x_layers(webs_t wp, int argc, char_t ** argv) |
|---|
| 4746 | { |
|---|
| 4747 | #ifndef HAVE_MADWIFI |
|---|
| 4748 | int c = get_wl_instances(); |
|---|
| 4749 | int i; |
|---|
| 4750 | |
|---|
| 4751 | for (i = 0; i < c; i++) { |
|---|
| 4752 | char buf[16]; |
|---|
| 4753 | |
|---|
| 4754 | sprintf(buf, "wl%d", i); |
|---|
| 4755 | init_80211x_layers(wp, buf); |
|---|
| 4756 | } |
|---|
| 4757 | return; |
|---|
| 4758 | #else |
|---|
| 4759 | int c = getdevicecount(); |
|---|
| 4760 | int i; |
|---|
| 4761 | |
|---|
| 4762 | for (i = 0; i < c; i++) { |
|---|
| 4763 | char buf[16]; |
|---|
| 4764 | |
|---|
| 4765 | sprintf(buf, "ath%d", i); |
|---|
| 4766 | if (nvram_nmatch("8021X", "%s_security_mode", buf)) |
|---|
| 4767 | init_80211x_layers(wp, buf); |
|---|
| 4768 | } |
|---|
| 4769 | return; |
|---|
| 4770 | #endif |
|---|
| 4771 | |
|---|
| 4772 | } |
|---|
| 4773 | |
|---|
| 4774 | void show_80211X(webs_t wp, char *prefix) |
|---|
| 4775 | { |
|---|
| 4776 | /* |
|---|
| 4777 | * fields |
|---|
| 4778 | * _8021xtype |
|---|
| 4779 | * _8021xuser |
|---|
| 4780 | * _8021xpasswd |
|---|
| 4781 | * _8021xca |
|---|
| 4782 | * _8021xpem |
|---|
| 4783 | * _8021xprv |
|---|
| 4784 | * _8021xaddopt |
|---|
| 4785 | */ |
|---|
| 4786 | char type[32]; |
|---|
| 4787 | |
|---|
| 4788 | sprintf(type, "%s_8021xtype", prefix); |
|---|
| 4789 | nvram_default_get(type, "ttls"); |
|---|
| 4790 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4791 | websWrite(wp, |
|---|
| 4792 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.xsuptype)</script></div>\n"); |
|---|
| 4793 | websWrite(wp, |
|---|
| 4794 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"peap\" onclick=\"enable_idpeap('%s')\" %s />Peap \n", |
|---|
| 4795 | prefix, prefix, nvram_prefix_match("8021xtype", prefix, |
|---|
| 4796 | "peap") ? |
|---|
| 4797 | "checked=\"checked\"" : ""); |
|---|
| 4798 | websWrite(wp, |
|---|
| 4799 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"leap\" onclick=\"enable_idleap('%s')\" %s />Leap \n", |
|---|
| 4800 | prefix, prefix, nvram_prefix_match("8021xtype", prefix, |
|---|
| 4801 | "leap") ? |
|---|
| 4802 | "checked=\"checked\"" : ""); |
|---|
| 4803 | websWrite(wp, |
|---|
| 4804 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"tls\" onclick=\"enable_idtls('%s')\" %s />TLS \n", |
|---|
| 4805 | prefix, prefix, nvram_prefix_match("8021xtype", prefix, |
|---|
| 4806 | "tls") ? |
|---|
| 4807 | "checked=\"checked\"" : ""); |
|---|
| 4808 | websWrite(wp, |
|---|
| 4809 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"ttls\" onclick=\"enable_idttls('%s')\" %s />TTLS \n", |
|---|
| 4810 | prefix, prefix, nvram_prefix_match("8021xtype", prefix, |
|---|
| 4811 | "ttls") ? |
|---|
| 4812 | "checked=\"checked\"" : ""); |
|---|
| 4813 | websWrite(wp, "</div>\n"); |
|---|
| 4814 | // ttls authentication |
|---|
| 4815 | websWrite(wp, "<div id=\"idttls%s\">\n", prefix); |
|---|
| 4816 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4817 | websWrite(wp, |
|---|
| 4818 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n"); |
|---|
| 4819 | websWrite(wp, |
|---|
| 4820 | "<input name=\"%s_ttls8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4821 | prefix, nvram_prefix_get("ttls8021xuser", prefix)); |
|---|
| 4822 | |
|---|
| 4823 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4824 | websWrite(wp, |
|---|
| 4825 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.anon)</script></div>\n"); |
|---|
| 4826 | websWrite(wp, |
|---|
| 4827 | "<input name=\"%s_ttls8021xanon\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4828 | prefix, nvram_prefix_get("ttls8021xanon", prefix)); |
|---|
| 4829 | |
|---|
| 4830 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4831 | websWrite(wp, |
|---|
| 4832 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n"); |
|---|
| 4833 | websWrite(wp, |
|---|
| 4834 | "<input name=\"%s_ttls8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4835 | prefix, nvram_prefix_get("ttls8021xpasswd", prefix)); |
|---|
| 4836 | |
|---|
| 4837 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4838 | websWrite(wp, |
|---|
| 4839 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.phase2)</script></div>\n"); |
|---|
| 4840 | websWrite(wp, |
|---|
| 4841 | "<input name=\"%s_ttls8021xphase2\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4842 | prefix, nvram_prefix_get("ttls8021xphase2", prefix)); |
|---|
| 4843 | |
|---|
| 4844 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4845 | websWrite(wp, |
|---|
| 4846 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.servercertif)</script></div>\n"); |
|---|
| 4847 | websWrite(wp, |
|---|
| 4848 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_ttls8021xca\" name=\"%s_ttls8021xca\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4849 | prefix, prefix); |
|---|
| 4850 | websWrite(wp, "var %s_ttls8021xca = fix_cr( '", prefix); |
|---|
| 4851 | char namebuf[64]; |
|---|
| 4852 | sprintf(namebuf, "%s_ttls8021xca", prefix); |
|---|
| 4853 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 4854 | websWrite(wp, "' );\n"); |
|---|
| 4855 | websWrite(wp, |
|---|
| 4856 | "document.getElementById(\"%s_ttls8021xca\").value = %s_ttls8021xca;\n", |
|---|
| 4857 | prefix, prefix); |
|---|
| 4858 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4859 | websWrite(wp, "</div>\n"); |
|---|
| 4860 | |
|---|
| 4861 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4862 | websWrite(wp, |
|---|
| 4863 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.options)</script></div>\n"); |
|---|
| 4864 | websWrite(wp, |
|---|
| 4865 | "<textarea cols=\"60\" rows=\"3\" id=\"%s_ttls8021xaddopt\" name=\"%s_ttls8021xaddopt\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4866 | prefix, prefix); |
|---|
| 4867 | websWrite(wp, "var %s_ttls8021xaddopt = fix_cr( '", prefix); |
|---|
| 4868 | sprintf(namebuf, "%s_ttls8021xaddopt", prefix); |
|---|
| 4869 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 4870 | websWrite(wp, "' );\n"); |
|---|
| 4871 | websWrite(wp, |
|---|
| 4872 | "document.getElementById(\"%s_ttls8021xaddopt\").value = %s_ttls8021xaddopt;\n", |
|---|
| 4873 | prefix, prefix); |
|---|
| 4874 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4875 | websWrite(wp, "</div>\n"); |
|---|
| 4876 | |
|---|
| 4877 | websWrite(wp, "</div>\n"); |
|---|
| 4878 | |
|---|
| 4879 | // peap authentication |
|---|
| 4880 | websWrite(wp, "<div id=\"idpeap%s\">\n", prefix); |
|---|
| 4881 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4882 | websWrite(wp, |
|---|
| 4883 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n"); |
|---|
| 4884 | websWrite(wp, |
|---|
| 4885 | "<input name=\"%s_peap8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4886 | prefix, nvram_prefix_get("peap8021xuser", prefix)); |
|---|
| 4887 | |
|---|
| 4888 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4889 | websWrite(wp, |
|---|
| 4890 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.anon)</script></div>\n"); |
|---|
| 4891 | websWrite(wp, |
|---|
| 4892 | "<input name=\"%s_peap8021xanon\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4893 | prefix, nvram_prefix_get("peap8021xanon", prefix)); |
|---|
| 4894 | |
|---|
| 4895 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4896 | websWrite(wp, |
|---|
| 4897 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n"); |
|---|
| 4898 | websWrite(wp, |
|---|
| 4899 | "<input name=\"%s_peap8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4900 | prefix, nvram_prefix_get("peap8021xpasswd", prefix)); |
|---|
| 4901 | |
|---|
| 4902 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4903 | websWrite(wp, |
|---|
| 4904 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.phase2)</script></div>\n"); |
|---|
| 4905 | websWrite(wp, |
|---|
| 4906 | "<input name=\"%s_peap8021xphase2\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4907 | prefix, nvram_prefix_get("peap8021xphase2", prefix)); |
|---|
| 4908 | |
|---|
| 4909 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4910 | websWrite(wp, |
|---|
| 4911 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.servercertif)</script></div>\n"); |
|---|
| 4912 | websWrite(wp, |
|---|
| 4913 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_peap8021xca\" name=\"%s_peap8021xca\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4914 | prefix, prefix); |
|---|
| 4915 | |
|---|
| 4916 | websWrite(wp, "var %s_peap8021xca = fix_cr( '", prefix); |
|---|
| 4917 | sprintf(namebuf, "%s_peap8021xca", prefix); |
|---|
| 4918 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 4919 | websWrite(wp, "' );\n"); |
|---|
| 4920 | websWrite(wp, |
|---|
| 4921 | "document.getElementById(\"%s_peap8021xca\").value = %s_peap8021xca;\n", |
|---|
| 4922 | prefix, prefix); |
|---|
| 4923 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4924 | websWrite(wp, "</div>\n"); |
|---|
| 4925 | |
|---|
| 4926 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4927 | websWrite(wp, |
|---|
| 4928 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.options)</script></div>\n"); |
|---|
| 4929 | websWrite(wp, |
|---|
| 4930 | "<textarea cols=\"60\" rows=\"3\" id=\"%s_peap8021xaddopt\" name=\"%s_peap8021xaddopt\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4931 | prefix, prefix); |
|---|
| 4932 | websWrite(wp, "var %s_peap8021xaddopt = fix_cr( '", prefix); |
|---|
| 4933 | sprintf(namebuf, "%s_peap8021xaddopt", prefix); |
|---|
| 4934 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 4935 | websWrite(wp, "' );\n"); |
|---|
| 4936 | websWrite(wp, |
|---|
| 4937 | "document.getElementById(\"%s_peap8021xaddopt\").value = %s_peap8021xaddopt;\n", |
|---|
| 4938 | prefix, prefix); |
|---|
| 4939 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4940 | websWrite(wp, "</div>\n"); |
|---|
| 4941 | |
|---|
| 4942 | websWrite(wp, "</div>\n"); |
|---|
| 4943 | // leap authentication |
|---|
| 4944 | websWrite(wp, "<div id=\"idleap%s\">\n", prefix); |
|---|
| 4945 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4946 | websWrite(wp, |
|---|
| 4947 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n"); |
|---|
| 4948 | websWrite(wp, |
|---|
| 4949 | "<input name=\"%s_leap8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4950 | prefix, nvram_prefix_get("leap8021xuser", prefix)); |
|---|
| 4951 | |
|---|
| 4952 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4953 | websWrite(wp, |
|---|
| 4954 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.anon)</script></div>\n"); |
|---|
| 4955 | websWrite(wp, |
|---|
| 4956 | "<input name=\"%s_leap8021xanon\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4957 | prefix, nvram_prefix_get("leap8021xanon", prefix)); |
|---|
| 4958 | |
|---|
| 4959 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4960 | websWrite(wp, |
|---|
| 4961 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n"); |
|---|
| 4962 | websWrite(wp, |
|---|
| 4963 | "<input name=\"%s_leap8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4964 | prefix, nvram_prefix_get("leap8021xpasswd", prefix)); |
|---|
| 4965 | |
|---|
| 4966 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4967 | websWrite(wp, |
|---|
| 4968 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.phase2)</script></div>\n"); |
|---|
| 4969 | websWrite(wp, |
|---|
| 4970 | "<input name=\"%s_leap8021xphase2\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4971 | prefix, nvram_prefix_get("leap8021xphase2", prefix)); |
|---|
| 4972 | |
|---|
| 4973 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4974 | websWrite(wp, |
|---|
| 4975 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.options)</script></div>\n"); |
|---|
| 4976 | websWrite(wp, |
|---|
| 4977 | "<textarea cols=\"60\" rows=\"3\" id=\"%s_leap8021xaddopt\" name=\"%s_leap8021xaddopt\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4978 | prefix, prefix); |
|---|
| 4979 | websWrite(wp, "var %s_leap8021xaddopt = fix_cr( '", prefix); |
|---|
| 4980 | sprintf(namebuf, "%s_leap8021xaddopt", prefix); |
|---|
| 4981 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 4982 | websWrite(wp, "' );\n"); |
|---|
| 4983 | websWrite(wp, |
|---|
| 4984 | "document.getElementById(\"%s_leap8021xaddopt\").value = %s_leap8021xaddopt;\n", |
|---|
| 4985 | prefix, prefix); |
|---|
| 4986 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4987 | websWrite(wp, "</div>\n"); |
|---|
| 4988 | |
|---|
| 4989 | websWrite(wp, "</div>\n"); |
|---|
| 4990 | |
|---|
| 4991 | // tls authentication |
|---|
| 4992 | websWrite(wp, "<div id=\"idtls%s\">\n", prefix); |
|---|
| 4993 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4994 | websWrite(wp, |
|---|
| 4995 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n"); |
|---|
| 4996 | websWrite(wp, |
|---|
| 4997 | "<input name=\"%s_tls8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4998 | prefix, nvram_prefix_get("tls8021xuser", prefix)); |
|---|
| 4999 | |
|---|
| 5000 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5001 | websWrite(wp, |
|---|
| 5002 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.anon)</script></div>\n"); |
|---|
| 5003 | websWrite(wp, |
|---|
| 5004 | "<input name=\"%s_tls8021xanon\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 5005 | prefix, nvram_prefix_get("tls8021xanon", prefix)); |
|---|
| 5006 | |
|---|
| 5007 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5008 | websWrite(wp, |
|---|
| 5009 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n"); |
|---|
| 5010 | websWrite(wp, |
|---|
| 5011 | "<input name=\"%s_tls8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 5012 | prefix, nvram_prefix_get("tls8021xpasswd", prefix)); |
|---|
| 5013 | |
|---|
| 5014 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5015 | websWrite(wp, |
|---|
| 5016 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.phase2)</script></div>\n"); |
|---|
| 5017 | websWrite(wp, |
|---|
| 5018 | "<input name=\"%s_tls8021xphase2\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 5019 | prefix, nvram_prefix_get("tls8021xphase2", prefix)); |
|---|
| 5020 | |
|---|
| 5021 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5022 | websWrite(wp, |
|---|
| 5023 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.servercertif)</script></div>\n"); |
|---|
| 5024 | websWrite(wp, |
|---|
| 5025 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xca\" name=\"%s_tls8021xca\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 5026 | prefix, prefix); |
|---|
| 5027 | websWrite(wp, "var %s_tls8021xca = fix_cr( '", prefix); |
|---|
| 5028 | sprintf(namebuf, "%s_tls8021xca", prefix); |
|---|
| 5029 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 5030 | websWrite(wp, "' );\n"); |
|---|
| 5031 | websWrite(wp, |
|---|
| 5032 | "document.getElementById(\"%s_tls8021xca\").value = %s_tls8021xca;\n", |
|---|
| 5033 | prefix, prefix); |
|---|
| 5034 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 5035 | websWrite(wp, "</div>\n"); |
|---|
| 5036 | |
|---|
| 5037 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5038 | websWrite(wp, |
|---|
| 5039 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.clientcertif)</script></div>\n"); |
|---|
| 5040 | websWrite(wp, |
|---|
| 5041 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xpem\" name=\"%s_tls8021xpem\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 5042 | prefix, prefix); |
|---|
| 5043 | websWrite(wp, "var %s_tls8021xpem = fix_cr( '", prefix); |
|---|
| 5044 | sprintf(namebuf, "%s_tls8021xpem", prefix); |
|---|
| 5045 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 5046 | websWrite(wp, "' );\n"); |
|---|
| 5047 | websWrite(wp, |
|---|
| 5048 | "document.getElementById(\"%s_tls8021xpem\").value = %s_tls8021xpem;\n", |
|---|
| 5049 | prefix, prefix); |
|---|
| 5050 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 5051 | websWrite(wp, "</div>\n"); |
|---|
| 5052 | |
|---|
| 5053 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5054 | websWrite(wp, |
|---|
| 5055 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.privatekey)</script></div>\n"); |
|---|
| 5056 | websWrite(wp, |
|---|
| 5057 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xprv\" name=\"%s_tls8021xprv\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 5058 | prefix, prefix); |
|---|
| 5059 | websWrite(wp, "var %s_tls8021xprv = fix_cr( '", prefix); |
|---|
| 5060 | sprintf(namebuf, "%s_tls8021xprv", prefix); |
|---|
| 5061 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 5062 | websWrite(wp, "' );\n"); |
|---|
| 5063 | websWrite(wp, |
|---|
| 5064 | "document.getElementById(\"%s_tls8021xprv\").value = %s_tls8021xprv;\n", |
|---|
| 5065 | prefix, prefix); |
|---|
| 5066 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 5067 | websWrite(wp, "</div>\n"); |
|---|
| 5068 | |
|---|
| 5069 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5070 | websWrite(wp, |
|---|
| 5071 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.options)</script></div>\n"); |
|---|
| 5072 | websWrite(wp, |
|---|
| 5073 | "<textarea cols=\"60\" rows=\"3\" id=\"%s_tls8021xaddopt\" name=\"%s_tls8021xaddopt\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 5074 | prefix, prefix); |
|---|
| 5075 | websWrite(wp, "var %s_tls8021xaddopt = fix_cr( '", prefix); |
|---|
| 5076 | sprintf(namebuf, "%s_tls8021xaddopt", prefix); |
|---|
| 5077 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 5078 | websWrite(wp, "' );\n"); |
|---|
| 5079 | websWrite(wp, |
|---|
| 5080 | "document.getElementById(\"%s_tls8021xaddopt\").value = %s_tls8021xaddopt;\n", |
|---|
| 5081 | prefix, prefix); |
|---|
| 5082 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 5083 | websWrite(wp, "</div>\n"); |
|---|
| 5084 | |
|---|
| 5085 | websWrite(wp, "</div>\n"); |
|---|
| 5086 | websWrite(wp, "<script>\n//<![CDATA[\n "); |
|---|
| 5087 | // websWrite |
|---|
| 5088 | // (wp,"show_layer_ext(document.getElementsByName(\"%s_bridged\"), |
|---|
| 5089 | // \"%s_idnetvifs\", %s);\n",var, vvar, nvram_match (ssid, "0") ? "true" |
|---|
| 5090 | // : "false"); |
|---|
| 5091 | char peap[32]; |
|---|
| 5092 | |
|---|
| 5093 | sprintf(peap, "%s_8021xtype", prefix); |
|---|
| 5094 | websWrite(wp, |
|---|
| 5095 | "show_layer_ext(document.wpa.%s_8021xtype, 'idpeap%s', %s);\n", |
|---|
| 5096 | prefix, prefix, nvram_match(peap, "peap") ? "true" : "false"); |
|---|
| 5097 | websWrite(wp, |
|---|
| 5098 | "show_layer_ext(document.wpa.%s_8021xtype, 'idtls%s', %s);\n", |
|---|
| 5099 | prefix, prefix, nvram_match(peap, "tls") ? "true" : "false"); |
|---|
| 5100 | websWrite(wp, |
|---|
| 5101 | "show_layer_ext(document.wpa.%s_8021xtype, 'idleap%s', %s);\n", |
|---|
| 5102 | prefix, prefix, nvram_match(peap, "leap") ? "true" : "false"); |
|---|
| 5103 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 5104 | |
|---|
| 5105 | } |
|---|
| 5106 | #endif |
|---|
| 5107 | |
|---|
| 5108 | #ifndef HAVE_WPA_SUPPLICANT |
|---|
| 5109 | void ej_init_80211x_layers(webs_t wp, int argc, char_t ** argv) |
|---|
| 5110 | { |
|---|
| 5111 | return; |
|---|
| 5112 | } |
|---|
| 5113 | #endif |
|---|
| 5114 | |
|---|
| 5115 | void show_wparadius(webs_t wp, char *prefix) |
|---|
| 5116 | { |
|---|
| 5117 | char var[80]; |
|---|
| 5118 | |
|---|
| 5119 | websWrite(wp, "<div>\n"); |
|---|
| 5120 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5121 | websWrite(wp, |
|---|
| 5122 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.algorithms)</script></div>\n"); |
|---|
| 5123 | websWrite(wp, "<select name=\"%s_crypto\">\n", prefix); |
|---|
| 5124 | sprintf(var, "%s_crypto", prefix); |
|---|
| 5125 | websWrite(wp, "<option value=\"tkip\" %s>TKIP</option>\n", |
|---|
| 5126 | selmatch(var, "tkip", "selected=\"selected\"")); |
|---|
| 5127 | websWrite(wp, "<option value=\"aes\" %s>AES</option>\n", |
|---|
| 5128 | selmatch(var, "aes", "selected=\"selected\"")); |
|---|
| 5129 | websWrite(wp, "<option value=\"tkip+aes\" %s>TKIP+AES</option>\n", |
|---|
| 5130 | selmatch(var, "tkip+aes", "selected=\"selected\"")); |
|---|
| 5131 | websWrite(wp, "</select></div>\n"); |
|---|
| 5132 | #ifdef HAVE_MADWIFI |
|---|
| 5133 | show_radius(wp, prefix, 0, 1); |
|---|
| 5134 | #else |
|---|
| 5135 | show_radius(wp, prefix, 0, 0); |
|---|
| 5136 | #endif |
|---|
| 5137 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5138 | websWrite(wp, |
|---|
| 5139 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.rekey)</script></div>\n"); |
|---|
| 5140 | sprintf(var, "%s_wpa_gtk_rekey", prefix); |
|---|
| 5141 | websWrite(wp, |
|---|
| 5142 | "<input name=\"%s_wpa_gtk_rekey\" maxlength=\"5\" size=\"10\" onblur=\"valid_range(this,0,99999,wpa.rekey)\" value=\"%s\" />", |
|---|
| 5143 | prefix, nvram_default_get(var, "3600")); |
|---|
| 5144 | websWrite(wp, "</div>\n"); |
|---|
| 5145 | websWrite(wp, "</div>\n"); |
|---|
| 5146 | } |
|---|
| 5147 | |
|---|
| 5148 | void show_wep(webs_t wp, char *prefix) |
|---|
| 5149 | { |
|---|
| 5150 | char var[80]; |
|---|
| 5151 | char *bit; |
|---|
| 5152 | |
|---|
| 5153 | cprintf("show wep\n"); |
|---|
| 5154 | #ifdef HAVE_MADWIFI |
|---|
| 5155 | char wl_authmode[16]; |
|---|
| 5156 | |
|---|
| 5157 | sprintf(wl_authmode, "%s_authmode", prefix); |
|---|
| 5158 | nvram_default_get(wl_authmode, "open"); |
|---|
| 5159 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5160 | websWrite(wp, |
|---|
| 5161 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label)</script></div>\n"); |
|---|
| 5162 | websWrite(wp, |
|---|
| 5163 | "<input class=\"spaceradio\" type=\"radio\" value=\"open\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.openn)</script></input> \n", |
|---|
| 5164 | wl_authmode, nvram_match(wl_authmode, |
|---|
| 5165 | "open") ? "checked=\"checked\"" : |
|---|
| 5166 | ""); |
|---|
| 5167 | websWrite(wp, |
|---|
| 5168 | "<input class=\"spaceradio\" type=\"radio\" value=\"shared\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.share_key)</script></input>\n", |
|---|
| 5169 | wl_authmode, nvram_match(wl_authmode, |
|---|
| 5170 | "shared") ? "checked=\"checked\"" : |
|---|
| 5171 | ""); |
|---|
| 5172 | websWrite(wp, "</div>\n"); |
|---|
| 5173 | #endif |
|---|
| 5174 | websWrite(wp, |
|---|
| 5175 | "<div><div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wep.defkey)</script></div>"); |
|---|
| 5176 | websWrite(wp, "<input type=\"hidden\" name=\"%s_WEP_key\" />", prefix); |
|---|
| 5177 | websWrite(wp, |
|---|
| 5178 | "<input type=\"hidden\" name=\"%s_wep\" value=\"restricted\" />", |
|---|
| 5179 | prefix); |
|---|
| 5180 | sprintf(var, "%s_key", prefix); |
|---|
| 5181 | nvram_default_get(var, "1"); |
|---|
| 5182 | websWrite(wp, |
|---|
| 5183 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s_key\" %s />1 \n", |
|---|
| 5184 | prefix, selmatch(var, "1", "checked=\"checked\"")); |
|---|
| 5185 | websWrite(wp, |
|---|
| 5186 | "<input class=\"spaceradio\" type=\"radio\" value=\"2\" name=\"%s_key\" %s />2 \n", |
|---|
| 5187 | prefix, selmatch(var, "2", "checked=\"checked\"")); |
|---|
| 5188 | websWrite(wp, |
|---|
| 5189 | "<input class=\"spaceradio\" type=\"radio\" value=\"3\" name=\"%s_key\" %s />3 \n", |
|---|
| 5190 | prefix, selmatch(var, "3", "checked=\"checked\"")); |
|---|
| 5191 | websWrite(wp, |
|---|
| 5192 | "<input class=\"spaceradio\" type=\"radio\" value=\"4\" name=\"%s_key\" %s />4 \n", |
|---|
| 5193 | prefix, selmatch(var, "4", "checked=\"checked\"")); |
|---|
| 5194 | websWrite(wp, "</div>"); |
|---|
| 5195 | websWrite(wp, |
|---|
| 5196 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.encrypt)</script></div>"); |
|---|
| 5197 | |
|---|
| 5198 | sprintf(var, "%s_wep_bit", prefix); |
|---|
| 5199 | bit = nvram_safe_get(var); |
|---|
| 5200 | |
|---|
| 5201 | cprintf("bit %s\n", bit); |
|---|
| 5202 | |
|---|
| 5203 | websWrite(wp, |
|---|
| 5204 | "<select name=\"%s_wep_bit\" size=\"1\" onchange=keyMode(this.form)>", |
|---|
| 5205 | prefix); |
|---|
| 5206 | websWrite(wp, "<option value=\"64\" %s >64 bits 10 hex digits</option>", |
|---|
| 5207 | selmatch(var, "64", "selected=\"selected\"")); |
|---|
| 5208 | websWrite(wp, |
|---|
| 5209 | "<option value=\"128\" %s >128 bits 26 hex digits</option>", |
|---|
| 5210 | selmatch(var, "128", "selected=\"selected\"")); |
|---|
| 5211 | websWrite(wp, |
|---|
| 5212 | "</select>\n</div>\n<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wep.passphrase)</script></div>\n"); |
|---|
| 5213 | websWrite(wp, |
|---|
| 5214 | "<input name=%s_passphrase maxlength=\"16\" size=\"20\" value=\"", |
|---|
| 5215 | prefix); |
|---|
| 5216 | |
|---|
| 5217 | char p_temp[128]; |
|---|
| 5218 | char temp[256]; |
|---|
| 5219 | |
|---|
| 5220 | sprintf(p_temp, "%s", get_wep_value(temp, "passphrase", bit, prefix)); |
|---|
| 5221 | nvram_set("passphrase_temp", p_temp); |
|---|
| 5222 | tf_webWriteESCNV(wp, "passphrase_temp"); |
|---|
| 5223 | nvram_unset("passphrase_temp"); |
|---|
| 5224 | |
|---|
| 5225 | websWrite(wp, "\" />"); |
|---|
| 5226 | websWrite(wp, |
|---|
| 5227 | "<input type=\"hidden\" value=\"Null\" name=\"generateButton\" />\n"); |
|---|
| 5228 | websWrite(wp, |
|---|
| 5229 | "<input class=\"button\" type=\"button\" value=\"Generate\" onclick=generateKey(this.form,\"%s\") name=wepGenerate />\n</div>", |
|---|
| 5230 | prefix); |
|---|
| 5231 | |
|---|
| 5232 | char *mlen = "10"; |
|---|
| 5233 | char *mlen2 = "12"; |
|---|
| 5234 | |
|---|
| 5235 | if (!strcmp(bit, "128")) { |
|---|
| 5236 | mlen = "26"; |
|---|
| 5237 | mlen2 = "30"; |
|---|
| 5238 | } |
|---|
| 5239 | websWrite(wp, |
|---|
| 5240 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 1</div>\n"); |
|---|
| 5241 | websWrite(wp, |
|---|
| 5242 | "<input name=%s_key1 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 5243 | prefix, mlen2, mlen, get_wep_value(temp, "key1", bit, |
|---|
| 5244 | prefix)); |
|---|
| 5245 | websWrite(wp, |
|---|
| 5246 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 2</div>\n"); |
|---|
| 5247 | websWrite(wp, |
|---|
| 5248 | "<input name=%s_key2 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 5249 | prefix, mlen2, mlen, get_wep_value(temp, "key2", bit, |
|---|
| 5250 | prefix)); |
|---|
| 5251 | websWrite(wp, |
|---|
| 5252 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 3</div>\n"); |
|---|
| 5253 | websWrite(wp, |
|---|
| 5254 | "<input name=%s_key3 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 5255 | prefix, mlen2, mlen, get_wep_value(temp, "key3", bit, |
|---|
| 5256 | prefix)); |
|---|
| 5257 | websWrite(wp, |
|---|
| 5258 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 4</div>\n"); |
|---|
| 5259 | websWrite(wp, |
|---|
| 5260 | "<input name=%s_key4 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 5261 | prefix, mlen2, mlen, get_wep_value(temp, "key4", bit, |
|---|
| 5262 | prefix)); |
|---|
| 5263 | websWrite(wp, "</div>\n"); |
|---|
| 5264 | } |
|---|
| 5265 | |
|---|
| 5266 | void ej_get_wds_mac(webs_t wp, int argc, char_t ** argv) |
|---|
| 5267 | { |
|---|
| 5268 | int mac = -1, wds_idx = -1, mac_idx = -1; |
|---|
| 5269 | char *c, wds_var[32] = ""; |
|---|
| 5270 | |
|---|
| 5271 | char *interface; |
|---|
| 5272 | |
|---|
| 5273 | if (ejArgs(argc, argv, "%d %d %s", &wds_idx, &mac_idx, &interface) < 3) { |
|---|
| 5274 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5275 | return; |
|---|
| 5276 | } else if (wds_idx < 1 || wds_idx > MAX_WDS_DEVS) |
|---|
| 5277 | return; |
|---|
| 5278 | else if (mac_idx < 0 || mac_idx > 5) |
|---|
| 5279 | return; |
|---|
| 5280 | |
|---|
| 5281 | snprintf(wds_var, 31, "%s_wds%d_hwaddr", interface, wds_idx); |
|---|
| 5282 | |
|---|
| 5283 | c = nvram_safe_get(wds_var); |
|---|
| 5284 | |
|---|
| 5285 | if (c) { |
|---|
| 5286 | mac = get_single_mac(c, mac_idx); |
|---|
| 5287 | websWrite(wp, "%02X", mac); |
|---|
| 5288 | } else |
|---|
| 5289 | websWrite(wp, "00"); |
|---|
| 5290 | |
|---|
| 5291 | return; |
|---|
| 5292 | |
|---|
| 5293 | } |
|---|
| 5294 | |
|---|
| 5295 | void ej_showbridgesettings(webs_t wp, int argc, char_t ** argv) |
|---|
| 5296 | { |
|---|
| 5297 | char *interface; |
|---|
| 5298 | int mcast; |
|---|
| 5299 | |
|---|
| 5300 | #ifdef FASTWEB |
|---|
| 5301 | ejArgs(argc, argv, "%s %d", &interface, &mcast); |
|---|
| 5302 | #else |
|---|
| 5303 | if (ejArgs(argc, argv, "%s %d", &interface, &mcast) < 2) { |
|---|
| 5304 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5305 | return; |
|---|
| 5306 | } |
|---|
| 5307 | #endif |
|---|
| 5308 | showbridgesettings(wp, interface, mcast, 0); |
|---|
| 5309 | } |
|---|
| 5310 | |
|---|
| 5311 | void ej_get_wds_ip(webs_t wp, int argc, char_t ** argv) |
|---|
| 5312 | { |
|---|
| 5313 | int ip = -1, wds_idx = -1, ip_idx = -1; |
|---|
| 5314 | char *c, wds_var[32] = ""; |
|---|
| 5315 | |
|---|
| 5316 | char *interface; |
|---|
| 5317 | |
|---|
| 5318 | #ifdef FASTWEB |
|---|
| 5319 | ejArgs(argc, argv, "%d %d %s", &wds_idx, &ip_idx, &interface); |
|---|
| 5320 | #else |
|---|
| 5321 | if (ejArgs(argc, argv, "%d %d %s", &wds_idx, &ip_idx, &interface) < 3) { |
|---|
| 5322 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5323 | return; |
|---|
| 5324 | } |
|---|
| 5325 | #endif |
|---|
| 5326 | if (wds_idx < 1 || wds_idx > MAX_WDS_DEVS) |
|---|
| 5327 | return; |
|---|
| 5328 | else if (ip_idx < 0 || ip_idx > 3) |
|---|
| 5329 | return; |
|---|
| 5330 | |
|---|
| 5331 | snprintf(wds_var, 31, "%s_wds%d_ipaddr", interface, wds_idx); |
|---|
| 5332 | |
|---|
| 5333 | c = nvram_safe_get(wds_var); |
|---|
| 5334 | |
|---|
| 5335 | if (c) { |
|---|
| 5336 | ip = get_single_ip(c, ip_idx); |
|---|
| 5337 | websWrite(wp, "%d", ip); |
|---|
| 5338 | } else |
|---|
| 5339 | websWrite(wp, "0"); |
|---|
| 5340 | |
|---|
| 5341 | return; |
|---|
| 5342 | |
|---|
| 5343 | } |
|---|
| 5344 | |
|---|
| 5345 | void ej_get_wds_netmask(webs_t wp, int argc, char_t ** argv) |
|---|
| 5346 | { |
|---|
| 5347 | int nm = -1, wds_idx = -1, nm_idx = -1; |
|---|
| 5348 | char *c, wds_var[32] = ""; |
|---|
| 5349 | |
|---|
| 5350 | char *interface; |
|---|
| 5351 | |
|---|
| 5352 | #ifdef FASTWEB |
|---|
| 5353 | ejArgs(argc, argv, "%d %d %s", &wds_idx, &nm_idx, &interface); |
|---|
| 5354 | #else |
|---|
| 5355 | if (ejArgs(argc, argv, "%d %d %s", &wds_idx, &nm_idx, &interface) < 3) { |
|---|
| 5356 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5357 | return; |
|---|
| 5358 | } |
|---|
| 5359 | #endif |
|---|
| 5360 | |
|---|
| 5361 | if (wds_idx < 1 || wds_idx > 6) |
|---|
| 5362 | return; |
|---|
| 5363 | else if (nm_idx < 0 || nm_idx > 3) |
|---|
| 5364 | return; |
|---|
| 5365 | |
|---|
| 5366 | snprintf(wds_var, 31, "%s_wds%d_netmask", interface, wds_idx); |
|---|
| 5367 | |
|---|
| 5368 | c = nvram_safe_get(wds_var); |
|---|
| 5369 | |
|---|
| 5370 | if (c) { |
|---|
| 5371 | nm = get_single_ip(c, nm_idx); |
|---|
| 5372 | websWrite(wp, "%d", nm); |
|---|
| 5373 | } else |
|---|
| 5374 | websWrite(wp, "255"); |
|---|
| 5375 | |
|---|
| 5376 | return; |
|---|
| 5377 | |
|---|
| 5378 | } |
|---|
| 5379 | |
|---|
| 5380 | void ej_get_wds_gw(webs_t wp, int argc, char_t ** argv) |
|---|
| 5381 | { |
|---|
| 5382 | int gw = -1, wds_idx = -1, gw_idx = -1; |
|---|
| 5383 | char *c, wds_var[32] = ""; |
|---|
| 5384 | |
|---|
| 5385 | char *interface; |
|---|
| 5386 | |
|---|
| 5387 | #ifdef FASTWEB |
|---|
| 5388 | ejArgs(argc, argv, "%d %d %s", &wds_idx, &gw_idx, &interface); |
|---|
| 5389 | #else |
|---|
| 5390 | if (ejArgs(argc, argv, "%d %d %s", &wds_idx, &gw_idx, &interface) < 3) { |
|---|
| 5391 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5392 | return; |
|---|
| 5393 | } |
|---|
| 5394 | #endif |
|---|
| 5395 | |
|---|
| 5396 | if (wds_idx < 1 || wds_idx > MAX_WDS_DEVS) |
|---|
| 5397 | return; |
|---|
| 5398 | else if (gw_idx < 0 || gw_idx > 3) |
|---|
| 5399 | return; |
|---|
| 5400 | |
|---|
| 5401 | snprintf(wds_var, 31, "%s_wds%d_gw", interface, wds_idx); |
|---|
| 5402 | |
|---|
| 5403 | c = nvram_safe_get(wds_var); |
|---|
| 5404 | |
|---|
| 5405 | if (c) { |
|---|
| 5406 | gw = get_single_ip(c, gw_idx); |
|---|
| 5407 | websWrite(wp, "%d", gw); |
|---|
| 5408 | } else |
|---|
| 5409 | websWrite(wp, "0"); |
|---|
| 5410 | |
|---|
| 5411 | return; |
|---|
| 5412 | |
|---|
| 5413 | } |
|---|
| 5414 | |
|---|
| 5415 | void ej_get_br1_ip(webs_t wp, int argc, char_t ** argv) |
|---|
| 5416 | { |
|---|
| 5417 | int ip = -1, ip_idx = -1; |
|---|
| 5418 | char *c; |
|---|
| 5419 | |
|---|
| 5420 | char *interface; |
|---|
| 5421 | |
|---|
| 5422 | #ifdef FASTWEB |
|---|
| 5423 | ejArgs(argc, argv, "%d %s", &ip_idx, &interface); |
|---|
| 5424 | #else |
|---|
| 5425 | if (ejArgs(argc, argv, "%d %s", &ip_idx, &interface) < 2) { |
|---|
| 5426 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5427 | return; |
|---|
| 5428 | } |
|---|
| 5429 | #endif |
|---|
| 5430 | if (ip_idx < 0 || ip_idx > 3) |
|---|
| 5431 | return; |
|---|
| 5432 | char br1[32]; |
|---|
| 5433 | |
|---|
| 5434 | sprintf(br1, "%s_br1_ipaddr", interface); |
|---|
| 5435 | c = nvram_safe_get(br1); |
|---|
| 5436 | |
|---|
| 5437 | if (c) { |
|---|
| 5438 | ip = get_single_ip(c, ip_idx); |
|---|
| 5439 | websWrite(wp, "%d", ip); |
|---|
| 5440 | } else |
|---|
| 5441 | websWrite(wp, "0"); |
|---|
| 5442 | |
|---|
| 5443 | return; |
|---|
| 5444 | |
|---|
| 5445 | } |
|---|
| 5446 | |
|---|
| 5447 | void ej_get_br1_netmask(webs_t wp, int argc, char_t ** argv) |
|---|
| 5448 | { |
|---|
| 5449 | int nm = -1, nm_idx = -1; |
|---|
| 5450 | char *c; |
|---|
| 5451 | |
|---|
| 5452 | char *interface; |
|---|
| 5453 | |
|---|
| 5454 | #ifdef FASTWEB |
|---|
| 5455 | ejArgs(argc, argv, "%d %s", &nm_idx, &interface); |
|---|
| 5456 | #else |
|---|
| 5457 | if (ejArgs(argc, argv, "%d %s", &nm_idx, &interface) < 2) { |
|---|
| 5458 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5459 | return; |
|---|
| 5460 | } |
|---|
| 5461 | #endif |
|---|
| 5462 | if (nm_idx < 0 || nm_idx > 3) |
|---|
| 5463 | return; |
|---|
| 5464 | char nms[32]; |
|---|
| 5465 | |
|---|
| 5466 | sprintf(nms, "%s_br1_netmask", interface); |
|---|
| 5467 | c = nvram_safe_get(nms); |
|---|
| 5468 | |
|---|
| 5469 | if (c) { |
|---|
| 5470 | nm = get_single_ip(c, nm_idx); |
|---|
| 5471 | websWrite(wp, "%d", nm); |
|---|
| 5472 | } else |
|---|
| 5473 | websWrite(wp, "255"); |
|---|
| 5474 | |
|---|
| 5475 | return; |
|---|
| 5476 | |
|---|
| 5477 | } |
|---|
| 5478 | |
|---|
| 5479 | void ej_get_uptime(webs_t wp, int argc, char_t ** argv) |
|---|
| 5480 | { |
|---|
| 5481 | char line[256]; |
|---|
| 5482 | FILE *fp; |
|---|
| 5483 | |
|---|
| 5484 | if ((fp = popen("uptime", "r"))) { |
|---|
| 5485 | fgets(line, sizeof(line), fp); |
|---|
| 5486 | line[strlen(line) - 1] = '\0'; // replace new line with null |
|---|
| 5487 | websWrite(wp, "%s", line); |
|---|
| 5488 | pclose(fp); |
|---|
| 5489 | } |
|---|
| 5490 | return; |
|---|
| 5491 | } |
|---|
| 5492 | |
|---|
| 5493 | void ej_get_wan_uptime(webs_t wp, int argc, char_t ** argv) |
|---|
| 5494 | { |
|---|
| 5495 | float sys_uptime; |
|---|
| 5496 | float uptime; |
|---|
| 5497 | int days, minutes; |
|---|
| 5498 | FILE *fp, *fp2; |
|---|
| 5499 | |
|---|
| 5500 | if (nvram_match("wan_proto", "disabled")) |
|---|
| 5501 | return; |
|---|
| 5502 | if (nvram_match("wan_ipaddr", "0.0.0.0")) { |
|---|
| 5503 | websWrite(wp, "%s", live_translate("status_router.notavail")); |
|---|
| 5504 | return; |
|---|
| 5505 | } |
|---|
| 5506 | if (!(fp = fopen("/tmp/.wanuptime", "r"))) { |
|---|
| 5507 | websWrite(wp, "%s", live_translate("status_router.notavail")); |
|---|
| 5508 | return; |
|---|
| 5509 | } |
|---|
| 5510 | if (!feof(fp) && fscanf(fp, "%f", &uptime) == 1) { |
|---|
| 5511 | fp2 = fopen("/proc/uptime", "r"); |
|---|
| 5512 | fscanf(fp2, "%f", &sys_uptime); |
|---|
| 5513 | fclose(fp2); |
|---|
| 5514 | uptime = sys_uptime - uptime; |
|---|
| 5515 | days = (int)uptime / (60 * 60 * 24); |
|---|
| 5516 | if (days) |
|---|
| 5517 | websWrite(wp, "%d day%s, ", days, |
|---|
| 5518 | (days == 1 ? "" : "s")); |
|---|
| 5519 | minutes = (int)uptime / 60; |
|---|
| 5520 | websWrite(wp, "%d:%02d:%02d", (minutes / 60) % 24, minutes % 60, |
|---|
| 5521 | (int)uptime % 60); |
|---|
| 5522 | } |
|---|
| 5523 | fclose(fp); |
|---|
| 5524 | |
|---|
| 5525 | return; |
|---|
| 5526 | |
|---|
| 5527 | } |
|---|
| 5528 | |
|---|
| 5529 | void ej_get_wdsp2p(webs_t wp, int argc, char_t ** argv) |
|---|
| 5530 | { |
|---|
| 5531 | int index = -1, ip[4] = { 0, 0, 0, 0 }, netmask[4] = { |
|---|
| 5532 | 0, 0, 0, 0}; |
|---|
| 5533 | char nvramvar[32] = { 0 }; |
|---|
| 5534 | char *interface; |
|---|
| 5535 | |
|---|
| 5536 | #ifdef FASTWEB |
|---|
| 5537 | ejArgs(argc, argv, "%d %s", &index, &interface); |
|---|
| 5538 | #else |
|---|
| 5539 | if (ejArgs(argc, argv, "%d %s", &index, &interface) < 2) { |
|---|
| 5540 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5541 | return; |
|---|
| 5542 | } |
|---|
| 5543 | #endif |
|---|
| 5544 | char wlwds[32]; |
|---|
| 5545 | |
|---|
| 5546 | sprintf(wlwds, "%s_wds1_enable", interface); |
|---|
| 5547 | if (nvram_selmatch(wp, "wk_mode", "ospf") && |
|---|
| 5548 | nvram_selmatch(wp, "expert_mode", "1") && |
|---|
| 5549 | nvram_selmatch(wp, wlwds, "1")) { |
|---|
| 5550 | char buf[16]; |
|---|
| 5551 | |
|---|
| 5552 | sprintf(buf, "%s_wds%d_ospf", interface, index); |
|---|
| 5553 | websWrite(wp, |
|---|
| 5554 | "<input name=\"%s\" size=\"2\" maxlength=\"5\" value=\"%s\" />\n", |
|---|
| 5555 | buf, nvram_safe_get(buf)); |
|---|
| 5556 | } |
|---|
| 5557 | |
|---|
| 5558 | snprintf(nvramvar, 31, "%s_wds%d_ipaddr", interface, index); |
|---|
| 5559 | sscanf(nvram_safe_get(nvramvar), "%d.%d.%d.%d", &ip[0], &ip[1], &ip[2], |
|---|
| 5560 | &ip[3]); |
|---|
| 5561 | snprintf(nvramvar, 31, "%s_wds%d_netmask", interface, index); |
|---|
| 5562 | sscanf(nvram_safe_get(nvramvar), "%d.%d.%d.%d", &netmask[0], |
|---|
| 5563 | &netmask[1], &netmask[2], &netmask[3]); |
|---|
| 5564 | snprintf(nvramvar, 31, "%s_wds%d_enable", interface, index); |
|---|
| 5565 | |
|---|
| 5566 | // set netmask to a suggested default if blank |
|---|
| 5567 | if (netmask[0] == 0 && |
|---|
| 5568 | netmask[1] == 0 && netmask[2] == 0 && netmask[3] == 0) { |
|---|
| 5569 | netmask[0] = 255; |
|---|
| 5570 | netmask[1] = 255; |
|---|
| 5571 | netmask[2] = 255; |
|---|
| 5572 | netmask[3] = 252; |
|---|
| 5573 | } |
|---|
| 5574 | |
|---|
| 5575 | if (nvram_match(nvramvar, "1")) { |
|---|
| 5576 | websWrite(wp, "\ |
|---|
| 5577 | <div class=\"setting\">\n\ |
|---|
| 5578 | <input type=\"hidden\" name=\"%s_wds%d_ipaddr\" value=\"4\">\n\ |
|---|
| 5579 | <div class=\"label\"><script type=\"text/javascript\">Capture(share.ip)</script></div>\n\ |
|---|
| 5580 | <input size=\"3\" maxlength=\"3\" name=\"%s_wds%d_ipaddr0\" value=\"%d\" onblur=\"valid_range(this,0,255,'IP')\" class=\"num\">.<input size=\"3\" maxlength=\"3\" name=\"%s_wds%d_ipaddr1\" value=\"%d\" onblur=\"valid_range(this,0,255,'IP')\" class=\"num\">.<input size=\"3\" maxlength=\"3\" name=\"%s_wds%d_ipaddr2\" value=\"%d\" onblur=\"valid_range(this,0,255,'IP')\" class=\"num\">.<input size=\"3\" maxlength=\"3\" name=\"%s_wds%d_ipaddr3\" value=\"%d\" onblur=\"valid_range(this,1,254,'IP')\" class=\"num\">\n\ |
|---|
| 5581 | </div>\n", interface, index, interface, index, ip[0], interface, index, ip[1], interface, index, ip[2], interface, index, ip[3]); |
|---|
| 5582 | |
|---|
| 5583 | websWrite(wp, "\ |
|---|
| 5584 | <div class=\"setting\">\n\ |
|---|
| 5585 | <div class=\"label\"><script type=\"text/javascript\">Capture(share.subnet)</script></div>\n\ |
|---|
| 5586 | <input type=\"hidden\" name=\"%s_wds%d_netmask\" value=\"4\">\n\ |
|---|
| 5587 | <input name=\"%s_wds%d_netmask0\" value=\"%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,255,'IP')\" class=num>.<input name=\"%s_wds%d_netmask1\" value=\"%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,255,'IP')\" class=num>.<input name=\"%s_wds%d_netmask2\" value=\"%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,255,'IP')\" class=num>.<input name=\"%s_wds%d_netmask3\" value=\"%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,255,'IP')\" class=num>\n\ |
|---|
| 5588 | </div>\n", interface, index, interface, index, netmask[0], interface, index, netmask[1], interface, index, netmask[2], interface, index, netmask[3]); |
|---|
| 5589 | |
|---|
| 5590 | } |
|---|
| 5591 | |
|---|
| 5592 | return; |
|---|
| 5593 | |
|---|
| 5594 | } |
|---|
| 5595 | |
|---|
| 5596 | /* |
|---|
| 5597 | * void ej_get_services_options (webs_t wp, int argc, char_t ** argv) { char |
|---|
| 5598 | * word[1024], *next, *services; char delim[] = "< >"; |
|---|
| 5599 | * |
|---|
| 5600 | * //services = nvram_safe_get("filter_services"); services = |
|---|
| 5601 | * get_filter_services (); |
|---|
| 5602 | * |
|---|
| 5603 | * split (word, services, next, delim) { int len = 0; char *name, *prot, |
|---|
| 5604 | * *port; char protocol[100], ports[100]; int from = 0, to = 0; //int proto; |
|---|
| 5605 | * |
|---|
| 5606 | * if ((name = strstr (word, "$NAME:")) == NULL || (prot = strstr (word, |
|---|
| 5607 | * "$PROT:")) == NULL || (port = strstr (word, "$PORT:")) == NULL) continue; |
|---|
| 5608 | * |
|---|
| 5609 | * // $NAME if (sscanf (name, "$NAME:%3d:", &len) != 1) continue; |
|---|
| 5610 | * |
|---|
| 5611 | * strncpy (name, name + sizeof ("$NAME:nnn:") - 1, len); name[len] = '\0'; |
|---|
| 5612 | * |
|---|
| 5613 | * // $PROT if (sscanf (prot, "$PROT:%3d:", &len) != 1) continue; |
|---|
| 5614 | * |
|---|
| 5615 | * strncpy (protocol, prot + sizeof ("$PROT:nnn:") - 1, len); protocol[len] = |
|---|
| 5616 | * '\0'; |
|---|
| 5617 | * |
|---|
| 5618 | * // $PORT if (sscanf (port, "$PORT:%3d:", &len) != 1) continue; |
|---|
| 5619 | * |
|---|
| 5620 | * strncpy (ports, port + sizeof ("$PORT:nnn:") - 1, len); ports[len] = '\0'; |
|---|
| 5621 | * |
|---|
| 5622 | * if (sscanf (ports, "%d:%d", &from, &to) != 2) continue; |
|---|
| 5623 | * |
|---|
| 5624 | * //cprintf("match:: name=%s, protocol=%s, ports=%s\n", // word, protocol, |
|---|
| 5625 | * ports); |
|---|
| 5626 | * |
|---|
| 5627 | * websWrite (wp, "<option value=\"%s\">%s</option>", name, name); |
|---|
| 5628 | * |
|---|
| 5629 | * } |
|---|
| 5630 | * |
|---|
| 5631 | * return; } |
|---|
| 5632 | */ |
|---|
| 5633 | |
|---|
| 5634 | void ej_get_clone_wmac(webs_t wp, int argc, char_t ** argv) |
|---|
| 5635 | { |
|---|
| 5636 | #ifdef HAVE_RB500 |
|---|
| 5637 | return 0; |
|---|
| 5638 | #else |
|---|
| 5639 | |
|---|
| 5640 | char *c; |
|---|
| 5641 | int mac, which; |
|---|
| 5642 | int dofree = 0; |
|---|
| 5643 | |
|---|
| 5644 | #ifdef FASTWEB |
|---|
| 5645 | ejArgs(argc, argv, "%d", &which); |
|---|
| 5646 | #else |
|---|
| 5647 | if (ejArgs(argc, argv, "%d", &which) < 1) { |
|---|
| 5648 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5649 | return; |
|---|
| 5650 | } |
|---|
| 5651 | #endif |
|---|
| 5652 | |
|---|
| 5653 | if (nvram_match("def_whwaddr", "00:00:00:00:00:00")) { |
|---|
| 5654 | // if (strlen (nvram_safe_get ("il0macaddr")) == 0) |
|---|
| 5655 | // { |
|---|
| 5656 | // if (nvram_match ("port_swap", "1")) |
|---|
| 5657 | // c = strdup (nvram_safe_get ("et1macaddr")); |
|---|
| 5658 | // else |
|---|
| 5659 | // c = strdup (nvram_safe_get ("et0macaddr")); |
|---|
| 5660 | // MAC_ADD (c); |
|---|
| 5661 | // } |
|---|
| 5662 | // else |
|---|
| 5663 | // { |
|---|
| 5664 | // c = strdup (nvram_safe_get ("il0macaddr")); |
|---|
| 5665 | // } |
|---|
| 5666 | // dofree = 1; |
|---|
| 5667 | |
|---|
| 5668 | if (nvram_match("port_swap", "1")) { |
|---|
| 5669 | if (strlen(nvram_safe_get("et1macaddr")) != 0) // safe: |
|---|
| 5670 | // maybe |
|---|
| 5671 | // et1macaddr |
|---|
| 5672 | // not there? |
|---|
| 5673 | { |
|---|
| 5674 | c = strdup(nvram_safe_get("et1macaddr")); |
|---|
| 5675 | } else { |
|---|
| 5676 | c = strdup(nvram_safe_get("et0macaddr")); |
|---|
| 5677 | MAC_ADD(c); // et0macaddr +3 |
|---|
| 5678 | } |
|---|
| 5679 | } else { |
|---|
| 5680 | c = strdup(nvram_safe_get("et0macaddr")); |
|---|
| 5681 | } |
|---|
| 5682 | |
|---|
| 5683 | dofree = 1; |
|---|
| 5684 | if (c) { |
|---|
| 5685 | MAC_ADD(c); |
|---|
| 5686 | MAC_ADD(c); |
|---|
| 5687 | } |
|---|
| 5688 | |
|---|
| 5689 | } else |
|---|
| 5690 | c = nvram_safe_get("def_whwaddr"); |
|---|
| 5691 | |
|---|
| 5692 | if (c) { |
|---|
| 5693 | mac = get_single_mac(c, which); |
|---|
| 5694 | websWrite(wp, "%02X", mac); |
|---|
| 5695 | if (dofree) |
|---|
| 5696 | free(c); |
|---|
| 5697 | } else |
|---|
| 5698 | websWrite(wp, "00"); |
|---|
| 5699 | |
|---|
| 5700 | return; |
|---|
| 5701 | #endif |
|---|
| 5702 | } |
|---|
| 5703 | |
|---|
| 5704 | /* |
|---|
| 5705 | * todo stylesheet compatible code |
|---|
| 5706 | */ |
|---|
| 5707 | /* |
|---|
| 5708 | * lonewolf additions |
|---|
| 5709 | */ |
|---|
| 5710 | |
|---|
| 5711 | // Note that there is no VLAN #16. It's just a convieniant way of denoting a |
|---|
| 5712 | // "Tagged" port |
|---|
| 5713 | void ej_port_vlan_table(webs_t wp, int argc, char_t ** argv) |
|---|
| 5714 | { |
|---|
| 5715 | /* |
|---|
| 5716 | * vlans[x][y] where x 0-15 are VLANS x 16 is tagging, 17 is |
|---|
| 5717 | * auto-negotiation, 18 is 100/10 Mbit, and 19 is Full/Half duplex y 0-4 |
|---|
| 5718 | * are switch ports (port 5 is set automaticly) y 5 it the bridge device |
|---|
| 5719 | * (x 16 dosn't apply) |
|---|
| 5720 | */ |
|---|
| 5721 | |
|---|
| 5722 | int i, j, vlans[21][6], tmp, wl_br; |
|---|
| 5723 | char *c, *next, buff[32], portvlan[32]; |
|---|
| 5724 | |
|---|
| 5725 | for (i = 0; i < 21; i++) |
|---|
| 5726 | for (j = 0; j < 6; j++) |
|---|
| 5727 | vlans[i][j] = -1; |
|---|
| 5728 | |
|---|
| 5729 | wl_br = -1; |
|---|
| 5730 | |
|---|
| 5731 | for (i = 0; i < 8; i++) { |
|---|
| 5732 | if (i < 5) |
|---|
| 5733 | snprintf(buff, 31, "port%dvlans", i); |
|---|
| 5734 | else if (i == 5) |
|---|
| 5735 | snprintf(buff, 31, "%s", "lan_ifnames"); |
|---|
| 5736 | else |
|---|
| 5737 | snprintf(buff, 31, "ub%d_ifnames", i - 5); |
|---|
| 5738 | |
|---|
| 5739 | c = nvram_safe_get(buff); |
|---|
| 5740 | |
|---|
| 5741 | if (c) { |
|---|
| 5742 | foreach(portvlan, c, next) { |
|---|
| 5743 | if (portvlan[0] == 'e' && portvlan[1] == 't' |
|---|
| 5744 | && portvlan[2] == 'h' && portvlan[3] == '1') |
|---|
| 5745 | wl_br = i - 5; |
|---|
| 5746 | if (ISDIGIT(portvlan, 1) |
|---|
| 5747 | || (portvlan[0] == 'v' && portvlan[1] == 'l' |
|---|
| 5748 | && portvlan[2] == 'a' |
|---|
| 5749 | && portvlan[3] == 'n')) { |
|---|
| 5750 | if (ISDIGIT(portvlan, 1)) |
|---|
| 5751 | tmp = atoi(portvlan); |
|---|
| 5752 | else { |
|---|
| 5753 | portvlan[0] = portvlan[4]; |
|---|
| 5754 | portvlan[1] = portvlan[5]; |
|---|
| 5755 | portvlan[2] = '\0'; |
|---|
| 5756 | if (ISDIGIT(portvlan, 1)) |
|---|
| 5757 | tmp = atoi(portvlan); |
|---|
| 5758 | else |
|---|
| 5759 | continue; |
|---|
| 5760 | } |
|---|
| 5761 | |
|---|
| 5762 | if (i < 5) { |
|---|
| 5763 | vlans[tmp][i] = 1; |
|---|
| 5764 | } else { |
|---|
| 5765 | vlans[tmp][5] = i - 5; |
|---|
| 5766 | } |
|---|
| 5767 | } |
|---|
| 5768 | } |
|---|
| 5769 | } |
|---|
| 5770 | } |
|---|
| 5771 | |
|---|
| 5772 | for (i = 0; i < 21; i++) { |
|---|
| 5773 | websWrite(wp, " <tr>\n"); |
|---|
| 5774 | websWrite(wp, "<td>"); |
|---|
| 5775 | |
|---|
| 5776 | switch (i) { |
|---|
| 5777 | case 16: |
|---|
| 5778 | websWrite(wp, |
|---|
| 5779 | "<script type=\"text/javascript\">Capture(vlan.tagged)</script>"); |
|---|
| 5780 | break; |
|---|
| 5781 | case 17: |
|---|
| 5782 | websWrite(wp, |
|---|
| 5783 | "<script type=\"text/javascript\">Capture(vlan.negociate)</script>"); |
|---|
| 5784 | break; |
|---|
| 5785 | case 18: |
|---|
| 5786 | websWrite(wp, "100 Mbit"); |
|---|
| 5787 | break; |
|---|
| 5788 | case 19: |
|---|
| 5789 | websWrite(wp, "Full-Duplex"); |
|---|
| 5790 | break; |
|---|
| 5791 | case 20: |
|---|
| 5792 | websWrite(wp, "Enabled"); |
|---|
| 5793 | break; |
|---|
| 5794 | default: |
|---|
| 5795 | snprintf(buff, 31, "%d", i); |
|---|
| 5796 | websWrite(wp, buff); |
|---|
| 5797 | break; |
|---|
| 5798 | } |
|---|
| 5799 | |
|---|
| 5800 | websWrite(wp, "</td>\n"); |
|---|
| 5801 | |
|---|
| 5802 | for (j = 0; j < 5; j++) { |
|---|
| 5803 | snprintf(buff, 31, "\"port%dvlan%d\"", j, i); |
|---|
| 5804 | websWrite(wp, "<td"); |
|---|
| 5805 | |
|---|
| 5806 | if (j % 2 == 0) |
|---|
| 5807 | websWrite(wp, " bgcolor=\"#CCCCCC\""); |
|---|
| 5808 | |
|---|
| 5809 | websWrite(wp, |
|---|
| 5810 | " height=\"20\"><div align=\"center\"><input type=\"checkbox\" value=\"on\" name="); |
|---|
| 5811 | websWrite(wp, buff); |
|---|
| 5812 | |
|---|
| 5813 | if (i < 17 || i > 20) { |
|---|
| 5814 | if (vlans[i][j] == 1) |
|---|
| 5815 | websWrite(wp, " checked=\"checked\""); |
|---|
| 5816 | } else { |
|---|
| 5817 | if (vlans[i][j] == -1) |
|---|
| 5818 | websWrite(wp, " checked=\"checked\""); |
|---|
| 5819 | } |
|---|
| 5820 | |
|---|
| 5821 | if (i < 17) { |
|---|
| 5822 | websWrite(wp, " onclick="); |
|---|
| 5823 | snprintf(buff, sizeof(buff), |
|---|
| 5824 | "\"SelVLAN(this.form,'port%d')\"", j); |
|---|
| 5825 | websWrite(wp, buff); |
|---|
| 5826 | } else if (i == 17 || i == 20) { |
|---|
| 5827 | websWrite(wp, " onclick="); |
|---|
| 5828 | snprintf(buff, sizeof(buff), |
|---|
| 5829 | "\"SelSpeed(this.form,'port%d')\"", j); |
|---|
| 5830 | websWrite(wp, buff); |
|---|
| 5831 | } |
|---|
| 5832 | websWrite(wp, " /></div></td>\n"); |
|---|
| 5833 | } |
|---|
| 5834 | |
|---|
| 5835 | if (i < 16) { |
|---|
| 5836 | websWrite(wp, " <td><select name="); |
|---|
| 5837 | snprintf(buff, 31, "\"vlan%d\"", i); |
|---|
| 5838 | websWrite(wp, buff); |
|---|
| 5839 | websWrite(wp, |
|---|
| 5840 | "><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"-1\\\""); |
|---|
| 5841 | if (vlans[i][5] < 0) |
|---|
| 5842 | websWrite(wp, " selected=\\\"selected\\\""); |
|---|
| 5843 | websWrite(wp, |
|---|
| 5844 | ">\" + share.none + \"</option>\");\n//]]>\n</script><option value=\"0\""); |
|---|
| 5845 | if (vlans[i][5] == 0) |
|---|
| 5846 | websWrite(wp, " selected=\"selected\""); |
|---|
| 5847 | websWrite(wp, ">LAN</option></select></td>\n"); |
|---|
| 5848 | } else { |
|---|
| 5849 | websWrite(wp, "<td> </td>\n"); |
|---|
| 5850 | } |
|---|
| 5851 | |
|---|
| 5852 | websWrite(wp, "</tr>\n"); |
|---|
| 5853 | |
|---|
| 5854 | if (i == 16 || i == 20) { |
|---|
| 5855 | websWrite(wp, "<tr><td> </td></tr>\n"); |
|---|
| 5856 | } |
|---|
| 5857 | } |
|---|
| 5858 | |
|---|
| 5859 | websWrite(wp, "<tr>\n"); |
|---|
| 5860 | websWrite(wp, |
|---|
| 5861 | "<td><script type=\"text/javascript\">Capture(share.wireless)</script></td>\n"); |
|---|
| 5862 | |
|---|
| 5863 | websWrite(wp, |
|---|
| 5864 | "<td colspan=\"6\"><select name=\"wireless\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"-1\\\""); |
|---|
| 5865 | if (wl_br < 0) |
|---|
| 5866 | websWrite(wp, " selected=\\\"selected\\\""); |
|---|
| 5867 | websWrite(wp, |
|---|
| 5868 | ">\" + share.none + \"</option>\");\n//]]>\n</script><option value=\"0\""); |
|---|
| 5869 | if (wl_br == 0) |
|---|
| 5870 | websWrite(wp, " selected=\"selected\""); |
|---|
| 5871 | websWrite(wp, ">LAN</option></select></td>\n"); |
|---|
| 5872 | websWrite(wp, "</tr>\n"); |
|---|
| 5873 | |
|---|
| 5874 | websWrite(wp, "<tr><td> </td></tr>\n"); |
|---|
| 5875 | |
|---|
| 5876 | websWrite(wp, "<tr>\n"); |
|---|
| 5877 | websWrite(wp, |
|---|
| 5878 | "<td><script type=\"text/javascript\">Capture(vlan.aggregation)</script></td>\n"); |
|---|
| 5879 | |
|---|
| 5880 | websWrite(wp, |
|---|
| 5881 | "<td colspan=\"6\"><select name=\"trunking\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"0\\\">\" + share.no + \"</option>\");\n//]]>\n</script><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"1\\\""); |
|---|
| 5882 | |
|---|
| 5883 | c = nvram_safe_get("trunking"); |
|---|
| 5884 | |
|---|
| 5885 | snprintf(buff, 5, "%s", c); |
|---|
| 5886 | |
|---|
| 5887 | if (atoi(buff) == 1) |
|---|
| 5888 | websWrite(wp, " selected=\\\"selected\\\""); |
|---|
| 5889 | |
|---|
| 5890 | websWrite(wp, |
|---|
| 5891 | ">\" + vlan.trunk + \"</option>\");\n//]]>\n</script></select></td>\n"); |
|---|
| 5892 | websWrite(wp, " </tr>"); |
|---|
| 5893 | |
|---|
| 5894 | return; |
|---|
| 5895 | } |
|---|
| 5896 | |
|---|
| 5897 | /* |
|---|
| 5898 | * Note: VLAN #16 designates tagging. There is no VLAN #16 (only 0-15) |
|---|
| 5899 | */ |
|---|
| 5900 | |
|---|
| 5901 | void ej_get_qossvcs(webs_t wp, int argc, char_t ** argv) |
|---|
| 5902 | { |
|---|
| 5903 | char *qos_svcs = nvram_safe_get("svqos_svcs"); |
|---|
| 5904 | char name[32], type[32], data[32], level[32]; |
|---|
| 5905 | int no_svcs = 0, i = 0; |
|---|
| 5906 | |
|---|
| 5907 | // calc # of services |
|---|
| 5908 | // no_svcs = strspn(qos_svcs,"|"); |
|---|
| 5909 | |
|---|
| 5910 | while ((qos_svcs = strpbrk(qos_svcs, "|"))) { |
|---|
| 5911 | no_svcs++; |
|---|
| 5912 | qos_svcs++; |
|---|
| 5913 | } |
|---|
| 5914 | |
|---|
| 5915 | // write HTML data |
|---|
| 5916 | |
|---|
| 5917 | websWrite(wp, |
|---|
| 5918 | "<tr><td colspan=\"3\"><input type=\"hidden\" name=\"svqos_nosvcs\" value=\"%d\" /></td></tr>", |
|---|
| 5919 | no_svcs); |
|---|
| 5920 | |
|---|
| 5921 | qos_svcs = nvram_safe_get("svqos_svcs"); |
|---|
| 5922 | |
|---|
| 5923 | /* |
|---|
| 5924 | * services format is "name type data level | name type data level |" |
|---|
| 5925 | * ..etc |
|---|
| 5926 | */ |
|---|
| 5927 | for (i = 0; i < no_svcs && qos_svcs && qos_svcs[0]; i++) { |
|---|
| 5928 | if (sscanf |
|---|
| 5929 | (qos_svcs, "%31s %31s %31s %31s ", name, type, data, |
|---|
| 5930 | level) < 4) |
|---|
| 5931 | break; |
|---|
| 5932 | |
|---|
| 5933 | websWrite(wp, "<tr>\n\ |
|---|
| 5934 | <td>\n\ |
|---|
| 5935 | <input type=\"checkbox\" name=\"svqos_svcdel%d\" />\n\ |
|---|
| 5936 | <input type=\"hidden\" name=\"svqos_svcname%d\" value=\"%s\" />\n\ |
|---|
| 5937 | <input type=\"hidden\" name=\"svqos_svctype%d\" value=\"%s\" />\n\ |
|---|
| 5938 | </td>\n\ |
|---|
| 5939 | <td><em>%s</em></td>\n\ |
|---|
| 5940 | <td >\n", i, i, name, i, type, name); |
|---|
| 5941 | websWrite(wp, "<select name=\"svqos_svcprio%d\"> \n\ |
|---|
| 5942 | <script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"100\\\" %s >\" + qos.prio_x + \"</option>\");\n\ |
|---|
| 5943 | document.write(\"<option value=\\\"10\\\" %s >\" + qos.prio_p + \"</option>\");\n\ |
|---|
| 5944 | document.write(\"<option value=\\\"20\\\" %s >\" + qos.prio_e + \"</option>\");\n\ |
|---|
| 5945 | document.write(\"<option value=\\\"30\\\" %s >\" + share.standard + \"</option>\");\n\ |
|---|
| 5946 | document.write(\"<option value=\\\"40\\\" %s >\" + qos.prio_b + \"</option>\");\n//]]>\n</script>\n\ |
|---|
| 5947 | </select>\n\ |
|---|
| 5948 | </td>\n\ |
|---|
| 5949 | </tr>\n", i, strcmp(level, "100") == 0 ? "selected=\\\"selected\\\"" : "", strcmp(level, "10") == 0 ? "selected=\\\"selected\\\"" : "", strcmp(level, "20") == 0 ? "selected=\\\"selected\\\"" : "", strcmp(level, "30") == 0 ? "selected=\\\"selected\\\"" : "", strcmp(level, "40") == 0 ? "selected=\\\"selected\\\"" : ""); |
|---|
| 5950 | |
|---|
| 5951 | qos_svcs = strpbrk(++qos_svcs, "|"); |
|---|
| 5952 | qos_svcs++; |
|---|
| 5953 | |
|---|
| 5954 | } |
|---|
| 5955 | |
|---|
| 5956 | return; |
|---|
| 5957 | } |
|---|
| 5958 | |
|---|
| 5959 | #ifndef HAVE_AQOS |
|---|
| 5960 | void ej_get_qosips(webs_t wp, int argc, char_t ** argv) |
|---|
| 5961 | { |
|---|
| 5962 | char *qos_ips = nvram_safe_get("svqos_ips"); |
|---|
| 5963 | char ip[32], level[32]; |
|---|
| 5964 | int no_ips = 0, i = 0; |
|---|
| 5965 | |
|---|
| 5966 | // calc # of ips |
|---|
| 5967 | while ((qos_ips = strpbrk(qos_ips, "|"))) { |
|---|
| 5968 | no_ips++; |
|---|
| 5969 | qos_ips++; |
|---|
| 5970 | } |
|---|
| 5971 | websWrite(wp, "<tr>\n\ |
|---|
| 5972 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 5973 | <th><script type=\"text/javascript\">Capture(qos.ipmask)</script></th>\n\ |
|---|
| 5974 | <th><script type=\"text/javascript\">Capture(share.priority)</script></th>\n\ |
|---|
| 5975 | </tr>\n"); |
|---|
| 5976 | |
|---|
| 5977 | // write HTML data |
|---|
| 5978 | |
|---|
| 5979 | websWrite(wp, |
|---|
| 5980 | "<tr><td colspan=\"3\"><input type=\"hidden\" name=\"svqos_noips\" value=\"%d\" /></td></tr>", |
|---|
| 5981 | no_ips); |
|---|
| 5982 | |
|---|
| 5983 | qos_ips = nvram_safe_get("svqos_ips"); |
|---|
| 5984 | |
|---|
| 5985 | /* |
|---|
| 5986 | * IP format is "data level | data level |" ..etc |
|---|
| 5987 | */ |
|---|
| 5988 | for (i = 0; i < no_ips && qos_ips && qos_ips[0]; i++) { |
|---|
| 5989 | if (sscanf(qos_ips, "%31s %31s ", ip, level) < 2) |
|---|
| 5990 | break; |
|---|
| 5991 | |
|---|
| 5992 | websWrite(wp, "<tr>\n\ |
|---|
| 5993 | <td>\n\ |
|---|
| 5994 | <input type=\"checkbox\" name=\"svqos_ipdel%d\" />\n\ |
|---|
| 5995 | <input type=\"hidden\" name=\"svqos_ip%d\" value=\"%s\" />\n\ |
|---|
| 5996 | </td>\n\ |
|---|
| 5997 | <td><em>%s</em></td>\n\ |
|---|
| 5998 | <td>\n", i, i, ip, ip); |
|---|
| 5999 | websWrite(wp, "<select name=\"svqos_ipprio%d\"> \n\ |
|---|
| 6000 | <script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"100\\\" %s >\" + qos.prio_x + \"</option>\");\n\ |
|---|
| 6001 | document.write(\"<option value=\\\"10\\\" %s >\" + qos.prio_p + \"</option>\");\n\ |
|---|
| 6002 | document.write(\"<option value=\\\"20\\\" %s >\" + qos.prio_e + \"</option>\");\n\ |
|---|
| 6003 | document.write(\"<option value=\\\"30\\\" %s >\" + share.standard + \"</option>\");\n\ |
|---|
| 6004 | document.write(\"<option value=\\\"40\\\" %s >\" + qos.prio_b + \"</option>\");\n//]]>\n</script>\n\ |
|---|
| 6005 | </select>\n\ |
|---|
| 6006 | </td>\n\ |
|---|
| 6007 | </tr>\n", i, strcmp(level, "100") == 0 ? "selected=\\\"selected\\\"" : "", strcmp(level, "10") == 0 ? "selected=\\\"selected\\\"" : "", strcmp(level, "20") == 0 ? "selected=\\\"selected\\\"" : "", strcmp(level, "30") == 0 ? "selected=\\\"selected\\\"" : "", strcmp(level, "40") == 0 ? "selected=\\\"selected\\\"" : ""); |
|---|
| 6008 | |
|---|
| 6009 | qos_ips = strpbrk(++qos_ips, "|"); |
|---|
| 6010 | qos_ips++; |
|---|
| 6011 | |
|---|
| 6012 | } |
|---|
| 6013 | |
|---|
| 6014 | return; |
|---|
| 6015 | } |
|---|
| 6016 | #else |
|---|
| 6017 | void ej_get_qosips(webs_t wp, int argc, char_t ** argv) |
|---|
| 6018 | { |
|---|
| 6019 | char *qos_ips = nvram_safe_get("svqos_ips"); |
|---|
| 6020 | char ip[32], level[32], level2[32]; |
|---|
| 6021 | int no_ips = 0, i = 0; |
|---|
| 6022 | |
|---|
| 6023 | // calc # of ips |
|---|
| 6024 | while ((qos_ips = strpbrk(qos_ips, "|"))) { |
|---|
| 6025 | no_ips++; |
|---|
| 6026 | qos_ips++; |
|---|
| 6027 | } |
|---|
| 6028 | websWrite(wp, "<tr>\n\ |
|---|
| 6029 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 6030 | <th><script type=\"text/javascript\">Capture(qos.ipmask)</script></th>\n\ |
|---|
| 6031 | <th><script type=\"text/javascript\">Capture(qos.maxuprate_b)</script></th>\n\ |
|---|
| 6032 | <th><script type=\"text/javascript\">Capture(qos.maxdownrate_b)</script></th>\n\ |
|---|
| 6033 | </tr>\n"); |
|---|
| 6034 | |
|---|
| 6035 | // write HTML data |
|---|
| 6036 | |
|---|
| 6037 | websWrite(wp, |
|---|
| 6038 | "<tr><td colspan=\"3\"><input type=\"hidden\" name=\"svqos_noips\" value=\"%d\" /></td></tr>", |
|---|
| 6039 | no_ips); |
|---|
| 6040 | |
|---|
| 6041 | qos_ips = nvram_safe_get("svqos_ips"); |
|---|
| 6042 | |
|---|
| 6043 | /* |
|---|
| 6044 | * IP format is "data level | data level |" ..etc |
|---|
| 6045 | */ |
|---|
| 6046 | for (i = 0; i < no_ips && qos_ips && qos_ips[0]; i++) { |
|---|
| 6047 | if (sscanf(qos_ips, "%31s %31s %31s ", ip, level, level2) < 3) |
|---|
| 6048 | break; |
|---|
| 6049 | websWrite(wp, "<tr>\n\ |
|---|
| 6050 | <td>\n\ |
|---|
| 6051 | <input type=\"checkbox\" name=\"svqos_ipdel%d\" />\n\ |
|---|
| 6052 | <input type=\"hidden\" name=\"svqos_ip%d\" value=\"%s\" />\n\ |
|---|
| 6053 | </td>\n\ |
|---|
| 6054 | <td><em>%s</em></td>\n\ |
|---|
| 6055 | <td>\n\ |
|---|
| 6056 | <input name=\"svqos_ipup%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 6057 | </td>\n\ |
|---|
| 6058 | <td>\n\ |
|---|
| 6059 | <input name=\"svqos_ipdown%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 6060 | </td>\n\ |
|---|
| 6061 | </tr>\n", i, i, ip, ip, i, level, i, level2); |
|---|
| 6062 | |
|---|
| 6063 | qos_ips = strpbrk(++qos_ips, "|"); |
|---|
| 6064 | qos_ips++; |
|---|
| 6065 | |
|---|
| 6066 | } |
|---|
| 6067 | |
|---|
| 6068 | return; |
|---|
| 6069 | } |
|---|
| 6070 | #endif |
|---|
| 6071 | #ifndef HAVE_AQOS |
|---|
| 6072 | void ej_get_qosmacs(webs_t wp, int argc, char_t ** argv) |
|---|
| 6073 | { |
|---|
| 6074 | char *qos_macs = nvram_safe_get("svqos_macs"); |
|---|
| 6075 | char mac[32], level[32]; |
|---|
| 6076 | int no_macs = 0, i = 0; |
|---|
| 6077 | |
|---|
| 6078 | // calc # of ips |
|---|
| 6079 | while ((qos_macs = strpbrk(qos_macs, "|"))) { |
|---|
| 6080 | no_macs++; |
|---|
| 6081 | qos_macs++; |
|---|
| 6082 | } |
|---|
| 6083 | |
|---|
| 6084 | websWrite(wp, "<tr>\n\ |
|---|
| 6085 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 6086 | <th><script type=\"text/javascript\">Capture(share.mac)</script></th>\n\ |
|---|
| 6087 | <th><script type=\"text/javascript\">Capture(share.priority)</script></th>\n\ |
|---|
| 6088 | </tr>\n"); |
|---|
| 6089 | |
|---|
| 6090 | // write HTML data |
|---|
| 6091 | websWrite(wp, |
|---|
| 6092 | "<input type=\"hidden\" name=\"svqos_nomacs\" value=\"%d\" />", |
|---|
| 6093 | no_macs); |
|---|
| 6094 | |
|---|
| 6095 | qos_macs = nvram_safe_get("svqos_macs"); |
|---|
| 6096 | |
|---|
| 6097 | /* |
|---|
| 6098 | * IP format is "data level | data level |" ..etc |
|---|
| 6099 | */ |
|---|
| 6100 | for (i = 0; i < no_macs && qos_macs && qos_macs[0]; i++) { |
|---|
| 6101 | if (sscanf(qos_macs, "%31s %31s ", mac, level) < 2) |
|---|
| 6102 | break; |
|---|
| 6103 | |
|---|
| 6104 | websWrite(wp, "<tr>\n\ |
|---|
| 6105 | <td>\n\ |
|---|
| 6106 | <input type=\"checkbox\" name=\"svqos_macdel%d\" />\n\ |
|---|
| 6107 | <input type=\"hidden\" name=\"svqos_mac%d\" value=\"%s\" />\n\ |
|---|
| 6108 | </td>\n\ |
|---|
| 6109 | <td><em>%s</em></td>\n\ |
|---|
| 6110 | <td>\n", i, i, mac, mac); |
|---|
| 6111 | websWrite(wp, "<select name=\"svqos_macprio%d\"> \n\ |
|---|
| 6112 | <script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"100\\\" %s >\" + qos.prio_x + \"</option>\");\n\ |
|---|
| 6113 | document.write(\"<option value=\\\"10\\\" %s >\" + qos.prio_p + \"</option>\");\n\ |
|---|
| 6114 | document.write(\"<option value=\\\"20\\\" %s >\" + qos.prio_e + \"</option>\");\n\ |
|---|
| 6115 | document.write(\"<option value=\\\"30\\\" %s >\" + share.standard + \"</option>\");\n\ |
|---|
| 6116 | document.write(\"<option value=\\\"40\\\" %s >\" + qos.prio_b + \"</option>\");\n//]]>\n</script>\n\ |
|---|
| 6117 | </select>\n\ |
|---|
| 6118 | </td>\n\ |
|---|
| 6119 | </tr>\n", i, strcmp(level, "100") == 0 ? "selected=\\\"selected\\\"" : "", strcmp(level, "10") == 0 ? "selected=\\\"selected\\\"" : "", strcmp(level, "20") == 0 ? "selected=\\\"selected\\\"" : "", strcmp(level, "30") == 0 ? "selected=\\\"selected\\\"" : "", strcmp(level, "40") == 0 ? "selected=\\\"selected\\\"" : ""); |
|---|
| 6120 | |
|---|
| 6121 | qos_macs = strpbrk(++qos_macs, "|"); |
|---|
| 6122 | qos_macs++; |
|---|
| 6123 | |
|---|
| 6124 | } |
|---|
| 6125 | |
|---|
| 6126 | return; |
|---|
| 6127 | } |
|---|
| 6128 | |
|---|
| 6129 | #else |
|---|
| 6130 | void ej_get_qosmacs(webs_t wp, int argc, char_t ** argv) |
|---|
| 6131 | { |
|---|
| 6132 | char *qos_macs = nvram_safe_get("svqos_macs"); |
|---|
| 6133 | char mac[32], level[32], level2[32]; |
|---|
| 6134 | int no_macs = 0, i = 0; |
|---|
| 6135 | |
|---|
| 6136 | // calc # of ips |
|---|
| 6137 | while ((qos_macs = strpbrk(qos_macs, "|"))) { |
|---|
| 6138 | no_macs++; |
|---|
| 6139 | qos_macs++; |
|---|
| 6140 | } |
|---|
| 6141 | websWrite(wp, "<tr>\n\ |
|---|
| 6142 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 6143 | <th><script type=\"text/javascript\">Capture(share.mac)</script></th>\n\ |
|---|
| 6144 | <th><script type=\"text/javascript\">Capture(qos.maxuprate_b)</script></th>\n\ |
|---|
| 6145 | <th><script type=\"text/javascript\">Capture(qos.maxdownrate_b)</script></th>\n\ |
|---|
| 6146 | </tr>\n"); |
|---|
| 6147 | |
|---|
| 6148 | // write HTML data |
|---|
| 6149 | websWrite(wp, |
|---|
| 6150 | "<input type=\"hidden\" name=\"svqos_nomacs\" value=\"%d\" />", |
|---|
| 6151 | no_macs); |
|---|
| 6152 | |
|---|
| 6153 | qos_macs = nvram_safe_get("svqos_macs"); |
|---|
| 6154 | |
|---|
| 6155 | /* |
|---|
| 6156 | * IP format is "data level | data level |" ..etc |
|---|
| 6157 | */ |
|---|
| 6158 | for (i = 0; i < no_macs && qos_macs && qos_macs[0]; i++) { |
|---|
| 6159 | if (sscanf(qos_macs, "%31s %31s %31s ", mac, level, level2) < 3) |
|---|
| 6160 | break; |
|---|
| 6161 | websWrite(wp, "<tr>\n\ |
|---|
| 6162 | <td>\n\ |
|---|
| 6163 | <input type=\"checkbox\" name=\"svqos_macdel%d\" />\n\ |
|---|
| 6164 | <input type=\"hidden\" name=\"svqos_mac%d\" value=\"%s\" />\n\ |
|---|
| 6165 | </td>\n\ |
|---|
| 6166 | <td><em>%s</em></td>\n\ |
|---|
| 6167 | <td>\n\ |
|---|
| 6168 | <input name=\"svqos_macup%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 6169 | </td>\n\ |
|---|
| 6170 | <td>\n\ |
|---|
| 6171 | <input name=\"svqos_macdown%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 6172 | </td>\n\ |
|---|
| 6173 | </tr>\n", i, i, mac, mac, i, level, i, level2); |
|---|
| 6174 | |
|---|
| 6175 | qos_macs = strpbrk(++qos_macs, "|"); |
|---|
| 6176 | qos_macs++; |
|---|
| 6177 | |
|---|
| 6178 | } |
|---|
| 6179 | |
|---|
| 6180 | return; |
|---|
| 6181 | } |
|---|
| 6182 | #endif |
|---|
| 6183 | |
|---|
| 6184 | /* |
|---|
| 6185 | * Added by Botho 03.April.06 |
|---|
| 6186 | */ |
|---|
| 6187 | void ej_dumpip_conntrack(webs_t wp, int argc, char_t ** argv) |
|---|
| 6188 | { |
|---|
| 6189 | int ip_count = 0; |
|---|
| 6190 | FILE *fp; |
|---|
| 6191 | int c; |
|---|
| 6192 | |
|---|
| 6193 | fp = fopen("/proc/net/ip_conntrack", "rb"); |
|---|
| 6194 | if (fp == NULL) |
|---|
| 6195 | return; |
|---|
| 6196 | while (!feof(fp)) { |
|---|
| 6197 | c = getc(fp); |
|---|
| 6198 | if (c == EOF) |
|---|
| 6199 | break; |
|---|
| 6200 | if (c == 0xa) |
|---|
| 6201 | ip_count++; |
|---|
| 6202 | } |
|---|
| 6203 | |
|---|
| 6204 | websWrite(wp, "%d", ip_count); |
|---|
| 6205 | |
|---|
| 6206 | fclose(fp); |
|---|
| 6207 | |
|---|
| 6208 | return; |
|---|
| 6209 | } |
|---|
| 6210 | |
|---|
| 6211 | /* |
|---|
| 6212 | * Added by Botho 28.Oct.06 |
|---|
| 6213 | */ |
|---|
| 6214 | static int search_hit(char *search, char *line, char *ret) |
|---|
| 6215 | { |
|---|
| 6216 | unsigned int searchLen; |
|---|
| 6217 | unsigned int i; |
|---|
| 6218 | unsigned int j; |
|---|
| 6219 | unsigned int lineLen; |
|---|
| 6220 | |
|---|
| 6221 | if (line == NULL || search == NULL || ret == NULL) |
|---|
| 6222 | return 1; |
|---|
| 6223 | lineLen = strlen(line); |
|---|
| 6224 | searchLen = strlen(search); |
|---|
| 6225 | |
|---|
| 6226 | if (searchLen > lineLen) |
|---|
| 6227 | return (1); // this can't match, invalid data? |
|---|
| 6228 | |
|---|
| 6229 | for (i = 0; i < lineLen - searchLen; i++) { |
|---|
| 6230 | if (!strncasecmp((char *)&line[i], search, searchLen)) |
|---|
| 6231 | break; // we got hit |
|---|
| 6232 | } |
|---|
| 6233 | |
|---|
| 6234 | for (j = i + searchLen; j < i + 15 + searchLen; j++) { |
|---|
| 6235 | if (j >= lineLen) |
|---|
| 6236 | break; // end of line may be a delimiter too |
|---|
| 6237 | // return(1); // incomplete data |
|---|
| 6238 | if (line[j] == ' ') |
|---|
| 6239 | break; // we reach _space_ delimiter |
|---|
| 6240 | } |
|---|
| 6241 | memcpy(ret, &line[i + searchLen], j - (i + searchLen)); |
|---|
| 6242 | ret[j - (i + searchLen)] = 0; |
|---|
| 6243 | return (0); |
|---|
| 6244 | } |
|---|
| 6245 | |
|---|
| 6246 | static int string_search(char *string, char *search) |
|---|
| 6247 | { |
|---|
| 6248 | int searchLen; |
|---|
| 6249 | int i; |
|---|
| 6250 | |
|---|
| 6251 | if (search == NULL) |
|---|
| 6252 | return 0; |
|---|
| 6253 | searchLen = strlen(search); |
|---|
| 6254 | if (string == NULL) |
|---|
| 6255 | return 0; |
|---|
| 6256 | if (searchLen > strlen(string)) { |
|---|
| 6257 | return (0); // this can't match |
|---|
| 6258 | } |
|---|
| 6259 | int slen = strlen(string); |
|---|
| 6260 | |
|---|
| 6261 | for (i = 0; i < slen - searchLen; i++) { // +1 removed. |
|---|
| 6262 | if (!strncasecmp((char *)&string[i], search, searchLen)) { |
|---|
| 6263 | return (1); // we got hit |
|---|
| 6264 | } |
|---|
| 6265 | } |
|---|
| 6266 | return (0); |
|---|
| 6267 | } |
|---|
| 6268 | |
|---|
| 6269 | void ej_ip_conntrack_table(webs_t wp, int argc, char_t ** argv) |
|---|
| 6270 | { |
|---|
| 6271 | FILE *fp; |
|---|
| 6272 | int ip_count = 1; |
|---|
| 6273 | char line[512]; |
|---|
| 6274 | char protocol[16] = ""; |
|---|
| 6275 | int timeout = 0; |
|---|
| 6276 | char srcip[16] = ""; |
|---|
| 6277 | char dstip[16] = ""; |
|---|
| 6278 | int _dport; |
|---|
| 6279 | struct servent *servp; |
|---|
| 6280 | char dstport[6] = ""; |
|---|
| 6281 | char state[12] = ""; |
|---|
| 6282 | char dum1[32]; |
|---|
| 6283 | int dum2; |
|---|
| 6284 | char *lanip = nvram_get("lan_ipaddr"); |
|---|
| 6285 | |
|---|
| 6286 | fp = fopen("/proc/net/ip_conntrack", "rb"); |
|---|
| 6287 | if (fp == NULL) |
|---|
| 6288 | return; |
|---|
| 6289 | |
|---|
| 6290 | while (fgets(line, sizeof(line), fp) != NULL) { |
|---|
| 6291 | |
|---|
| 6292 | websWrite(wp, "<tr>\n"); |
|---|
| 6293 | |
|---|
| 6294 | // Nb |
|---|
| 6295 | websWrite(wp, "<td align=\"right\">%d</td>", ip_count); |
|---|
| 6296 | |
|---|
| 6297 | // Proto |
|---|
| 6298 | if (string_search(line, "tcp")) |
|---|
| 6299 | sprintf(protocol, "TCP"); |
|---|
| 6300 | else if (string_search(line, "udp")) |
|---|
| 6301 | sprintf(protocol, "UDP"); |
|---|
| 6302 | else if (string_search(line, "icmp")) |
|---|
| 6303 | sprintf(protocol, "ICMP"); |
|---|
| 6304 | else |
|---|
| 6305 | sprintf(protocol, live_translate("share.unknown")); |
|---|
| 6306 | websWrite(wp, "<td>%s</td>", protocol); |
|---|
| 6307 | |
|---|
| 6308 | // Timeout |
|---|
| 6309 | sscanf(line, "%s %d %d", &dum1[0], &dum2, &timeout); |
|---|
| 6310 | websWrite(wp, "<td align=\"right\">%d</td>", timeout); |
|---|
| 6311 | |
|---|
| 6312 | // src |
|---|
| 6313 | search_hit("src=", line, srcip); |
|---|
| 6314 | // char buf[200]; |
|---|
| 6315 | // getHostName (buf, srcip); |
|---|
| 6316 | // websWrite (wp, "<td align=\"right\" onmouseover='DisplayDiv(this, |
|---|
| 6317 | // event, 15, 15, \"%s\")' onmouseout=\"unDisplayDiv()\">%s</td>", |
|---|
| 6318 | // buf != "unknown" ? buf : live_translate ("share.unknown") , |
|---|
| 6319 | // srcip); |
|---|
| 6320 | if (!strcmp(srcip, lanip)) |
|---|
| 6321 | websWrite(wp, "<td align=\"right\">%s</td>", srcip); |
|---|
| 6322 | else |
|---|
| 6323 | websWrite(wp, |
|---|
| 6324 | "<td align=\"right\"><a title=\"Geotool\" href=\"javascript:openGeotool('%s')\">%s</a></td>", |
|---|
| 6325 | srcip, srcip); |
|---|
| 6326 | |
|---|
| 6327 | // dst |
|---|
| 6328 | search_hit("dst=", line, dstip); |
|---|
| 6329 | // getHostName (buf, dstip); |
|---|
| 6330 | // websWrite (wp, "<td align=\"right\" onmouseover='DisplayDiv(this, |
|---|
| 6331 | // event, 15, 15, \"%s\")' onmouseout=\"unDisplayDiv()\">%s</td>", |
|---|
| 6332 | // buf != "unknown" ? buf : live_translate ("share.unknown") , |
|---|
| 6333 | // dstip); |
|---|
| 6334 | if (!strcmp(dstip, lanip)) |
|---|
| 6335 | websWrite(wp, "<td align=\"right\">%s</td>", dstip); |
|---|
| 6336 | else |
|---|
| 6337 | websWrite(wp, |
|---|
| 6338 | "<td align=\"right\"><a title=\"Geotool\" href=\"javascript:openGeotool('%s')\">%s</a></td>", |
|---|
| 6339 | dstip, dstip); |
|---|
| 6340 | |
|---|
| 6341 | // service |
|---|
| 6342 | search_hit("dport=", line, dstport); |
|---|
| 6343 | _dport = atoi(dstport); |
|---|
| 6344 | servp = my_getservbyport(htons(_dport), protocol); |
|---|
| 6345 | websWrite(wp, "<td align=\"right\">%s</td>", |
|---|
| 6346 | servp ? servp->s_name : dstport); |
|---|
| 6347 | |
|---|
| 6348 | // State |
|---|
| 6349 | if (string_search(line, "ESTABLISHED")) |
|---|
| 6350 | sprintf(state, "ESTABLISHED"); |
|---|
| 6351 | else if (string_search(line, "TIME_WAIT")) |
|---|
| 6352 | sprintf(state, "TIME_WAIT"); |
|---|
| 6353 | else if (string_search(line, "UNREPLIED")) |
|---|
| 6354 | sprintf(state, "UNREPLIED"); |
|---|
| 6355 | else if (string_search(line, "CLOSE")) |
|---|
| 6356 | sprintf(state, "CLOSE"); |
|---|
| 6357 | else if (string_search(line, "ASSURED")) |
|---|
| 6358 | sprintf(state, "ASSURED"); |
|---|
| 6359 | else { |
|---|
| 6360 | if (string_search(line, "udp")) |
|---|
| 6361 | sprintf(state, "UNREPLIED"); |
|---|
| 6362 | else |
|---|
| 6363 | sprintf(state, " "); |
|---|
| 6364 | } |
|---|
| 6365 | websWrite(wp, "<td>%s</td>\n", state); |
|---|
| 6366 | websWrite(wp, "</tr>\n"); |
|---|
| 6367 | |
|---|
| 6368 | ip_count++; |
|---|
| 6369 | } |
|---|
| 6370 | |
|---|
| 6371 | fclose(fp); |
|---|
| 6372 | |
|---|
| 6373 | return; |
|---|
| 6374 | } |
|---|
| 6375 | |
|---|
| 6376 | void ej_gethostnamebyip(webs_t wp, int argc, char_t ** argv) |
|---|
| 6377 | { |
|---|
| 6378 | char buf[200]; |
|---|
| 6379 | char *argument; |
|---|
| 6380 | |
|---|
| 6381 | #ifdef FASTWEB |
|---|
| 6382 | ejArgs(argc, argv, "%s", &argument); |
|---|
| 6383 | #else |
|---|
| 6384 | if (ejArgs(argc, argv, "%s", &argument) < 1) { |
|---|
| 6385 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 6386 | return; |
|---|
| 6387 | } |
|---|
| 6388 | #endif |
|---|
| 6389 | |
|---|
| 6390 | if (argc == 1) { |
|---|
| 6391 | getHostName(buf, argument); |
|---|
| 6392 | websWrite(wp, "%s", |
|---|
| 6393 | strcmp(buf, |
|---|
| 6394 | "unknown") ? buf : |
|---|
| 6395 | live_translate("share.unknown")); |
|---|
| 6396 | } |
|---|
| 6397 | |
|---|
| 6398 | return; |
|---|
| 6399 | } |
|---|
| 6400 | |
|---|
| 6401 | /* |
|---|
| 6402 | * BEGIN Added by Botho 10.May.06 |
|---|
| 6403 | */ |
|---|
| 6404 | void ej_show_wan_to_switch(webs_t wp, int argc, char_t ** argv) |
|---|
| 6405 | { |
|---|
| 6406 | |
|---|
| 6407 | if (nvram_match("wan_proto", "disabled") || getSTA() || getWET()) // WAN |
|---|
| 6408 | // disabled |
|---|
| 6409 | // OR |
|---|
| 6410 | // Wirelles |
|---|
| 6411 | // is |
|---|
| 6412 | // not |
|---|
| 6413 | // AP |
|---|
| 6414 | { |
|---|
| 6415 | websWrite(wp, "<fieldset>\n\ |
|---|
| 6416 | <legend><script type=\"text/javascript\">Capture(idx.legend2)</script></legend>\n\ |
|---|
| 6417 | <div class=\"setting\">\n\ |
|---|
| 6418 | <div class=\"label\"><script type=\"text/javascript\">Capture(idx.wantoswitch)</script></div>\n\ |
|---|
| 6419 | <input class=\"spaceradio\" type=\"checkbox\" name=\"_fullswitch\" value=\"1\" %s />\n\ |
|---|
| 6420 | </div>\n\ |
|---|
| 6421 | </fieldset><br />\n", nvram_match("fullswitch", "1") ? "checked=\"checked\"" : ""); |
|---|
| 6422 | } |
|---|
| 6423 | |
|---|
| 6424 | return; |
|---|
| 6425 | } |
|---|
| 6426 | |
|---|
| 6427 | #define PROC_DEV "/proc/net/dev" |
|---|
| 6428 | |
|---|
| 6429 | void ej_wl_packet_get(webs_t wp, int argc, char_t ** argv) |
|---|
| 6430 | { |
|---|
| 6431 | char line[256]; |
|---|
| 6432 | FILE *fp; |
|---|
| 6433 | |
|---|
| 6434 | #ifdef HAVE_MADWIFI |
|---|
| 6435 | char *ifname = nvram_safe_get("wifi_display"); |
|---|
| 6436 | #elif HAVE_RT2880 |
|---|
| 6437 | char *ifname = "ra0"; |
|---|
| 6438 | #else |
|---|
| 6439 | char name[32]; |
|---|
| 6440 | sprintf(name, "%s_ifname", nvram_safe_get("wifi_display")); |
|---|
| 6441 | char *ifname = nvram_safe_get(name); |
|---|
| 6442 | #endif |
|---|
| 6443 | struct dev_info { |
|---|
| 6444 | // unsigned long rx_bytes; |
|---|
| 6445 | unsigned long rx_pks; |
|---|
| 6446 | unsigned long rx_errs; |
|---|
| 6447 | unsigned long rx_drops; |
|---|
| 6448 | // unsigned long rx_fifo; |
|---|
| 6449 | // unsigned long rx_frame; |
|---|
| 6450 | // unsigned long rx_com; |
|---|
| 6451 | // unsigned long rx_mcast; |
|---|
| 6452 | // unsigned long tx_bytes; |
|---|
| 6453 | unsigned long tx_pks; |
|---|
| 6454 | unsigned long tx_errs; |
|---|
| 6455 | unsigned long tx_drops; |
|---|
| 6456 | // unsigned long tx_fifo; |
|---|
| 6457 | unsigned long tx_colls; |
|---|
| 6458 | // unsigned long tx_carr; |
|---|
| 6459 | // unsigned long tx_com; |
|---|
| 6460 | } info; |
|---|
| 6461 | |
|---|
| 6462 | info.rx_pks = info.rx_errs = info.rx_drops = 0; |
|---|
| 6463 | info.tx_pks = info.tx_errs = info.tx_drops = info.tx_colls = 0; |
|---|
| 6464 | |
|---|
| 6465 | if ((fp = fopen(PROC_DEV, "r")) == NULL) { |
|---|
| 6466 | return; |
|---|
| 6467 | } else { |
|---|
| 6468 | /* |
|---|
| 6469 | * Inter-| Receive | Transmit face |bytes packets errs drop fifo |
|---|
| 6470 | * frame compressed multicast|bytes packets errs drop fifo colls |
|---|
| 6471 | * carrier compressed lo: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 eth0: |
|---|
| 6472 | * 674829 5501 0 0 0 0 0 0 1249130 1831 0 0 0 0 0 0 eth1: 0 0 0 0 0 0 |
|---|
| 6473 | * 0 0 0 0 0 0 0 0 0 0 eth2: 0 0 0 0 0 719 0 0 1974 16 295 0 0 0 0 0 |
|---|
| 6474 | * br0: 107114 1078 0 0 0 0 0 0 910094 1304 0 0 0 0 0 0 |
|---|
| 6475 | * |
|---|
| 6476 | */ |
|---|
| 6477 | while (fgets(line, sizeof(line), fp) != NULL) { |
|---|
| 6478 | int ifl = 0; |
|---|
| 6479 | |
|---|
| 6480 | if (!strchr(line, ':')) |
|---|
| 6481 | continue; |
|---|
| 6482 | while (line[ifl] != ':') |
|---|
| 6483 | ifl++; |
|---|
| 6484 | line[ifl] = 0; /* interface */ |
|---|
| 6485 | char ifnamecopy[32]; |
|---|
| 6486 | int l = 0; |
|---|
| 6487 | int i; |
|---|
| 6488 | int len = strlen(line); |
|---|
| 6489 | for (i = 0; i < len; i++) { |
|---|
| 6490 | if (line[i] == ' ') |
|---|
| 6491 | continue; |
|---|
| 6492 | ifnamecopy[l++] = line[i]; |
|---|
| 6493 | } |
|---|
| 6494 | ifnamecopy[l] = 0; |
|---|
| 6495 | if (!strcmp(ifnamecopy, ifname)) { |
|---|
| 6496 | /* |
|---|
| 6497 | * sscanf (line + ifl + 1, "%ld %ld %ld %ld %ld %ld %ld %ld |
|---|
| 6498 | * %ld %ld %ld %ld %ld %ld %ld %ld", &info.rx_bytes, |
|---|
| 6499 | * &info.rx_pks, &info.rx_errs, &info.rx_drops, |
|---|
| 6500 | * &info.rx_fifo, &info.rx_frame, &info.rx_com, |
|---|
| 6501 | * &info.rx_mcast, &info.tx_bytes, &info.tx_pks, |
|---|
| 6502 | * &info.tx_errs, &info.tx_drops, &info.tx_fifo, |
|---|
| 6503 | * &info.tx_colls, &info.tx_carr, &info.tx_com); |
|---|
| 6504 | */ |
|---|
| 6505 | sscanf(line + ifl + 1, |
|---|
| 6506 | "%*ld %ld %ld %ld %*ld %*ld %*ld %*ld %*ld %ld %ld %ld %*ld %ld %*ld %*ld", |
|---|
| 6507 | &info.rx_pks, &info.rx_errs, |
|---|
| 6508 | &info.rx_drops, |
|---|
| 6509 | &info.tx_pks, &info.tx_errs, |
|---|
| 6510 | &info.tx_drops, &info.tx_colls); |
|---|
| 6511 | } |
|---|
| 6512 | |
|---|
| 6513 | } |
|---|
| 6514 | fclose(fp); |
|---|
| 6515 | } |
|---|
| 6516 | |
|---|
| 6517 | websWrite(wp, "SWRXgoodPacket=%ld;", info.rx_pks); |
|---|
| 6518 | websWrite(wp, "SWRXerrorPacket=%ld;", info.rx_errs + info.rx_drops); |
|---|
| 6519 | |
|---|
| 6520 | websWrite(wp, "SWTXgoodPacket=%ld;", info.tx_pks); |
|---|
| 6521 | websWrite(wp, "SWTXerrorPacket=%ld;", |
|---|
| 6522 | info.tx_errs + info.tx_drops + info.tx_colls); |
|---|
| 6523 | |
|---|
| 6524 | return; |
|---|
| 6525 | } |
|---|
| 6526 | |
|---|
| 6527 | /* |
|---|
| 6528 | * END Added by Botho 10.May.06 |
|---|
| 6529 | */ |
|---|
| 6530 | |
|---|
| 6531 | void ej_statfs(webs_t wp, int argc, char_t ** argv) |
|---|
| 6532 | { |
|---|
| 6533 | struct statfs sizefs; |
|---|
| 6534 | |
|---|
| 6535 | if (argc != 2) |
|---|
| 6536 | return; |
|---|
| 6537 | |
|---|
| 6538 | if ((statfs(argv[0], &sizefs) != 0) |
|---|
| 6539 | || (sizefs.f_type == 0x73717368)) |
|---|
| 6540 | memset(&sizefs, 0, sizeof(sizefs)); |
|---|
| 6541 | |
|---|
| 6542 | websWrite(wp, "var %s = {\n\ |
|---|
| 6543 | size: %llu,\n\ |
|---|
| 6544 | free: %llu\n\ |
|---|
| 6545 | };\n", argv[1], ((uint64_t) sizefs.f_bsize * sizefs.f_blocks), ((uint64_t) sizefs.f_bsize * sizefs.f_bfree)); |
|---|
| 6546 | } |
|---|
| 6547 | |
|---|
| 6548 | #ifdef HAVE_RSTATS |
|---|
| 6549 | /* |
|---|
| 6550 | * |
|---|
| 6551 | * rstats Copyright (C) 2006 Jonathan Zarate |
|---|
| 6552 | * |
|---|
| 6553 | * Licensed under GNU GPL v2 or later. |
|---|
| 6554 | * |
|---|
| 6555 | */ |
|---|
| 6556 | |
|---|
| 6557 | void ej_bandwidth(webs_t wp, int argc, char_t ** argv) |
|---|
| 6558 | { |
|---|
| 6559 | char *name; |
|---|
| 6560 | int sig; |
|---|
| 6561 | char *argument; |
|---|
| 6562 | |
|---|
| 6563 | #ifdef FASTWEB |
|---|
| 6564 | ejArgs(argc, argv, "%s", &argument); |
|---|
| 6565 | #else |
|---|
| 6566 | if (ejArgs(argc, argv, "%s", &argument) < 1) { |
|---|
| 6567 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 6568 | return; |
|---|
| 6569 | } |
|---|
| 6570 | #endif |
|---|
| 6571 | |
|---|
| 6572 | if (argc == 1) { |
|---|
| 6573 | if (strcmp(argument, "speed") == 0) { |
|---|
| 6574 | sig = SIGUSR1; |
|---|
| 6575 | name = "/var/spool/rstats-speed.js"; |
|---|
| 6576 | } else { |
|---|
| 6577 | sig = SIGUSR2; |
|---|
| 6578 | name = "/var/spool/rstats-history.js"; |
|---|
| 6579 | } |
|---|
| 6580 | unlink(name); |
|---|
| 6581 | killall("rstats", sig); |
|---|
| 6582 | wait_file_exists(name, 5, 0); |
|---|
| 6583 | do_file(name, wp, NULL); |
|---|
| 6584 | unlink(name); |
|---|
| 6585 | } |
|---|
| 6586 | } |
|---|
| 6587 | #endif |
|---|
| 6588 | |
|---|
| 6589 | #ifdef HAVE_PORTSETUP |
|---|
| 6590 | void ej_portsetup(webs_t wp, int argc, char_t ** argv) |
|---|
| 6591 | { |
|---|
| 6592 | char ssid[64]; |
|---|
| 6593 | char *next; |
|---|
| 6594 | char var[64]; |
|---|
| 6595 | char eths[256]; |
|---|
| 6596 | |
|---|
| 6597 | websWrite(wp, |
|---|
| 6598 | "<h2><script type=\"text/javascript\">Capture(idx.portsetup)</script></h2>\n"); |
|---|
| 6599 | websWrite(wp, "<fieldset>\n"); |
|---|
| 6600 | |
|---|
| 6601 | char *wanifname = nvram_safe_get("wan_ifname2"); |
|---|
| 6602 | |
|---|
| 6603 | if (strlen(wanifname) == 0) |
|---|
| 6604 | wanifname = nvram_safe_get("wan_ifname"); |
|---|
| 6605 | memset(eths, 0, 256); |
|---|
| 6606 | getIfLists(eths, 256); |
|---|
| 6607 | if (strlen(wanifname) > 0) { |
|---|
| 6608 | |
|---|
| 6609 | websWrite(wp, |
|---|
| 6610 | "<legend><script type=\"text/javascript\">Capture(idx.portsetup)</script></legend>\n"); |
|---|
| 6611 | websWrite(wp, |
|---|
| 6612 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(idx.wanport)</script></div>\n"); |
|---|
| 6613 | websWrite(wp, "<select name=\"wan_ifname\">\n"); |
|---|
| 6614 | |
|---|
| 6615 | websWrite(wp, "<option value=\"\" %s >Disabled</option>\n", |
|---|
| 6616 | strlen(wanifname) == |
|---|
| 6617 | 0 ? "selected=\"selected\"" : ""); |
|---|
| 6618 | foreach(var, eths, next) { |
|---|
| 6619 | websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 6620 | var, !strcmp(wanifname, |
|---|
| 6621 | var) ? "selected=\"selected\"" : |
|---|
| 6622 | "", var); |
|---|
| 6623 | } |
|---|
| 6624 | websWrite(wp, "</select></div>\n"); |
|---|
| 6625 | } |
|---|
| 6626 | foreach(var, eths, next) { |
|---|
| 6627 | if (!strcmp(get_wan_face(), var)) |
|---|
| 6628 | continue; |
|---|
| 6629 | if (!strcmp(nvram_safe_get("lan_ifname"), var)) |
|---|
| 6630 | continue; |
|---|
| 6631 | if (!strncmp(var, "br", 2) && !contains(var, '.')) |
|---|
| 6632 | continue; |
|---|
| 6633 | |
|---|
| 6634 | sprintf(ssid, "%s_bridged", var); |
|---|
| 6635 | websWrite(wp, |
|---|
| 6636 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.network)</script> %s</div>\n", |
|---|
| 6637 | var); |
|---|
| 6638 | char layer[64]; |
|---|
| 6639 | |
|---|
| 6640 | strcpy(layer, var); |
|---|
| 6641 | rep(layer, '.', 'X'); |
|---|
| 6642 | websWrite(wp, |
|---|
| 6643 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" onclick=\"show_layer_ext(this, '%s_idnet', true);\" name=\"%s_bridged\" %s /><script type=\"text/javascript\">Capture(wl_basic.unbridged)</script> \n", |
|---|
| 6644 | layer, var, nvram_default_match(ssid, |
|---|
| 6645 | "0", |
|---|
| 6646 | "1") ? |
|---|
| 6647 | "checked=\"checked\"" : ""); |
|---|
| 6648 | websWrite(wp, |
|---|
| 6649 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" onclick=\"show_layer_ext(this, '%s_idnet', false);\" name=\"%s_bridged\" %s /><script type=\"text/javascript\">Capture(share.deflt)</script>\n", |
|---|
| 6650 | layer, var, nvram_default_match(ssid, "1", |
|---|
| 6651 | "1") ? |
|---|
| 6652 | "checked=\"checked\"" : ""); |
|---|
| 6653 | websWrite(wp, "</div>\n"); |
|---|
| 6654 | |
|---|
| 6655 | websWrite(wp, "<div id=\"%s_idnet\">\n", layer); |
|---|
| 6656 | |
|---|
| 6657 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 6658 | websWrite(wp, "<div class=\"label\">%s</div>\n", |
|---|
| 6659 | live_translate("idx.mtu")); |
|---|
| 6660 | char mtu[32]; |
|---|
| 6661 | sprintf(mtu, "%s_mtu", var); |
|---|
| 6662 | websWrite(wp, |
|---|
| 6663 | "<input class=\"num\" maxlength=\"4\" onblur=\"valid_mtu(this)\" size=\"5\" name=\"%s_mtu\" value=\"%s\" />\n", |
|---|
| 6664 | var, nvram_default_get(mtu, "1500")); |
|---|
| 6665 | websWrite(wp, "</div>\n"); |
|---|
| 6666 | |
|---|
| 6667 | char mcast[32]; |
|---|
| 6668 | |
|---|
| 6669 | sprintf(mcast, "%s_multicast", var); |
|---|
| 6670 | nvram_default_get(mcast, "0"); |
|---|
| 6671 | showRadio(wp, "wl_basic.multicast", mcast); |
|---|
| 6672 | |
|---|
| 6673 | if (nvram_match("wk_mode", "gateway")) { |
|---|
| 6674 | sprintf(mcast, "%s_nat", var); |
|---|
| 6675 | nvram_default_get(mcast, "1"); |
|---|
| 6676 | showRadio(wp, "wl_basic.masquerade", mcast); |
|---|
| 6677 | } |
|---|
| 6678 | show_ipnetmask(wp, var); |
|---|
| 6679 | websWrite(wp, "</div>\n"); |
|---|
| 6680 | websWrite(wp, |
|---|
| 6681 | "<script type=\"text/javascript\">\n//<![CDATA[\n "); |
|---|
| 6682 | websWrite(wp, |
|---|
| 6683 | "show_layer_ext(document.getElementsByName(\"%s_bridged\"), \"%s_idnet\", %s);\n", |
|---|
| 6684 | var, layer, nvram_match(ssid, |
|---|
| 6685 | "0") ? "true" : "false"); |
|---|
| 6686 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 6687 | } |
|---|
| 6688 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 6689 | } |
|---|
| 6690 | #endif |
|---|
| 6691 | |
|---|
| 6692 | static void show_macfilter_if(webs_t wp, char *ifname) |
|---|
| 6693 | { |
|---|
| 6694 | websWrite(wp, "<fieldset>\n"); |
|---|
| 6695 | websWrite(wp, "<legend>%s - %s</legend>\n", IFMAP(ifname), |
|---|
| 6696 | live_translate("wl_mac.legend")); |
|---|
| 6697 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 6698 | websWrite(wp, "<div class=\"label\">%s</div>\n", |
|---|
| 6699 | live_translate("wl_mac.label")); |
|---|
| 6700 | char macmode[32]; |
|---|
| 6701 | |
|---|
| 6702 | sprintf(macmode, "%s_macmode1", ifname); |
|---|
| 6703 | rep(macmode, '.', 'X'); |
|---|
| 6704 | if (nvram_get(macmode) == NULL) |
|---|
| 6705 | nvram_set(macmode, "disabled"); |
|---|
| 6706 | char id[32]; |
|---|
| 6707 | |
|---|
| 6708 | sprintf(id, "idmac%s", ifname); |
|---|
| 6709 | rep(id, '.', 'X'); |
|---|
| 6710 | char mycopy[256]; |
|---|
| 6711 | |
|---|
| 6712 | strcpy(mycopy, live_translate("share.enable")); |
|---|
| 6713 | websWrite(wp, |
|---|
| 6714 | "<input class=\"spaceradio\" type=\"radio\" value=\"other\" name=\"%s\" %s onclick=\"show_layer_ext(this, '%s', true)\" />%s \n", |
|---|
| 6715 | macmode, nvram_match(macmode, |
|---|
| 6716 | "other") ? "checked=\"checked\"" : "", |
|---|
| 6717 | id, mycopy); |
|---|
| 6718 | strcpy(mycopy, live_translate("share.disable")); |
|---|
| 6719 | websWrite(wp, |
|---|
| 6720 | "<input class=\"spaceradio\" type=\"radio\" value=\"disabled\" name=\"%s\" %s onclick=\"show_layer_ext(this, '%s', false)\" />%s\n", |
|---|
| 6721 | macmode, nvram_match(macmode, |
|---|
| 6722 | "disabled") ? "checked=\"checked\"" : |
|---|
| 6723 | "", id, mycopy); |
|---|
| 6724 | websWrite(wp, "</div>\n"); |
|---|
| 6725 | websWrite(wp, "<div class=\"setting\" id=\"%s\">\n", id); |
|---|
| 6726 | websWrite(wp, "<div class=\"label\">%s<br /> </div>\n", |
|---|
| 6727 | live_translate("wl_mac.label2")); |
|---|
| 6728 | sprintf(macmode, "%s_macmode", ifname); |
|---|
| 6729 | if (nvram_get(macmode) == NULL) |
|---|
| 6730 | nvram_set(macmode, "disabled"); |
|---|
| 6731 | strcpy(mycopy, live_translate("wl_mac.deny")); |
|---|
| 6732 | websWrite(wp, |
|---|
| 6733 | "<input class=\"spaceradio\" type=\"radio\" value=\"deny\" name=\"%s\" %s />%s \n", |
|---|
| 6734 | macmode, nvram_invmatch(macmode, |
|---|
| 6735 | "allow") ? "checked=\"checked\"" : |
|---|
| 6736 | "", mycopy); |
|---|
| 6737 | websWrite(wp, "<br />\n"); |
|---|
| 6738 | strcpy(mycopy, live_translate("wl_mac.allow")); |
|---|
| 6739 | websWrite(wp, |
|---|
| 6740 | "<input class=\"spaceradio\" type=\"radio\" value=\"allow\" name=\"%s\" %s />%s\n", |
|---|
| 6741 | macmode, nvram_match(macmode, |
|---|
| 6742 | "allow") ? "checked=\"checked\"" : "", |
|---|
| 6743 | mycopy); |
|---|
| 6744 | websWrite(wp, "</div><br />\n"); |
|---|
| 6745 | websWrite(wp, "<div class=\"center\">\n"); |
|---|
| 6746 | websWrite(wp, "<script type=\"text/javascript\">\n"); |
|---|
| 6747 | websWrite(wp, "//<![CDATA[\n"); |
|---|
| 6748 | websWrite(wp, |
|---|
| 6749 | "document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" name=\\\"mac_filter_button\\\" value=\\\"\" + sbutton.filterMac + \"\\\" onclick=\\\"openWindow('WL_FilterTable-%s.asp', 930, 740,'MACList');\\\" />\");\n", |
|---|
| 6750 | ifname); |
|---|
| 6751 | websWrite(wp, "//]]>\n"); |
|---|
| 6752 | websWrite(wp, "</script>\n"); |
|---|
| 6753 | websWrite(wp, "</div>\n"); |
|---|
| 6754 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 6755 | } |
|---|
| 6756 | |
|---|
| 6757 | void ej_list_mac_layers(webs_t wp, int argc, char_t ** argv) |
|---|
| 6758 | { |
|---|
| 6759 | #ifndef HAVE_MADWIFI |
|---|
| 6760 | int c = get_wl_instances(); |
|---|
| 6761 | char devs[32]; |
|---|
| 6762 | int i; |
|---|
| 6763 | |
|---|
| 6764 | for (i = 0; i < c; i++) { |
|---|
| 6765 | char macmode[32]; |
|---|
| 6766 | char id[32]; |
|---|
| 6767 | |
|---|
| 6768 | sprintf(devs, "wl%d", i); |
|---|
| 6769 | sprintf(macmode, "%s_macmode1", devs); |
|---|
| 6770 | sprintf(id, "idmac%s", devs); |
|---|
| 6771 | rep(id, '.', 'X'); |
|---|
| 6772 | rep(macmode, '.', 'X'); |
|---|
| 6773 | websWrite(wp, |
|---|
| 6774 | "show_layer_ext(document.wireless.%s, '%s', \"%s\" == \"other\");\n", |
|---|
| 6775 | macmode, id, nvram_match(macmode, |
|---|
| 6776 | "other") ? "other" : |
|---|
| 6777 | "disabled"); |
|---|
| 6778 | } |
|---|
| 6779 | |
|---|
| 6780 | #else |
|---|
| 6781 | |
|---|
| 6782 | int c = getdevicecount(); |
|---|
| 6783 | char devs[32]; |
|---|
| 6784 | int i; |
|---|
| 6785 | |
|---|
| 6786 | for (i = 0; i < c; i++) { |
|---|
| 6787 | char macmode[32]; |
|---|
| 6788 | char id[32]; |
|---|
| 6789 | |
|---|
| 6790 | sprintf(devs, "ath%d", i); |
|---|
| 6791 | sprintf(macmode, "%s_macmode1", devs); |
|---|
| 6792 | sprintf(id, "idmac%s", devs); |
|---|
| 6793 | rep(id, '.', 'X'); |
|---|
| 6794 | rep(macmode, '.', 'X'); |
|---|
| 6795 | websWrite(wp, |
|---|
| 6796 | "show_layer_ext(document.wireless.%s, '%s', \"%s\" == \"other\");\n", |
|---|
| 6797 | macmode, id, nvram_match(macmode, |
|---|
| 6798 | "other") ? "other" : |
|---|
| 6799 | "disabled"); |
|---|
| 6800 | // show_macfilter_if (wp, devs); |
|---|
| 6801 | char vif[32]; |
|---|
| 6802 | |
|---|
| 6803 | sprintf(vif, "%s_vifs", devs); |
|---|
| 6804 | char var[80], *next; |
|---|
| 6805 | char *vifs = nvram_safe_get(vif); |
|---|
| 6806 | |
|---|
| 6807 | if (vifs != NULL) |
|---|
| 6808 | foreach(var, vifs, next) { |
|---|
| 6809 | sprintf(macmode, "%s_macmode1", var); |
|---|
| 6810 | sprintf(id, "idmac%s", var); |
|---|
| 6811 | rep(id, '.', 'X'); |
|---|
| 6812 | rep(macmode, '.', 'X'); |
|---|
| 6813 | websWrite(wp, |
|---|
| 6814 | "show_layer_ext(document.wireless.%s, '%s', \"%s\" == \"other\");\n", |
|---|
| 6815 | macmode, id, nvram_match(macmode, |
|---|
| 6816 | "other") ? "other" : |
|---|
| 6817 | "disabled"); |
|---|
| 6818 | } |
|---|
| 6819 | } |
|---|
| 6820 | |
|---|
| 6821 | #endif |
|---|
| 6822 | } |
|---|
| 6823 | |
|---|
| 6824 | void ej_show_macfilter(webs_t wp, int argc, char_t ** argv) |
|---|
| 6825 | { |
|---|
| 6826 | #ifndef HAVE_MADWIFI |
|---|
| 6827 | int c = get_wl_instances(); |
|---|
| 6828 | char devs[32]; |
|---|
| 6829 | int i; |
|---|
| 6830 | |
|---|
| 6831 | for (i = 0; i < c; i++) { |
|---|
| 6832 | sprintf(devs, "wl%d", i); |
|---|
| 6833 | show_macfilter_if(wp, devs); |
|---|
| 6834 | } |
|---|
| 6835 | #else |
|---|
| 6836 | int c = getdevicecount(); |
|---|
| 6837 | char devs[32]; |
|---|
| 6838 | int i; |
|---|
| 6839 | |
|---|
| 6840 | for (i = 0; i < c; i++) { |
|---|
| 6841 | sprintf(devs, "ath%d", i); |
|---|
| 6842 | show_macfilter_if(wp, devs); |
|---|
| 6843 | char vif[32]; |
|---|
| 6844 | |
|---|
| 6845 | sprintf(vif, "%s_vifs", devs); |
|---|
| 6846 | char var[80], *next; |
|---|
| 6847 | char *vifs = nvram_safe_get(vif); |
|---|
| 6848 | |
|---|
| 6849 | if (vifs != NULL) |
|---|
| 6850 | foreach(var, vifs, next) { |
|---|
| 6851 | show_macfilter_if(wp, var); |
|---|
| 6852 | } |
|---|
| 6853 | } |
|---|
| 6854 | |
|---|
| 6855 | #endif |
|---|
| 6856 | } |
|---|
| 6857 | |
|---|
| 6858 | void ej_show_ifselect(webs_t wp, int argc, char_t ** argv) |
|---|
| 6859 | { |
|---|
| 6860 | if (argc < 1) |
|---|
| 6861 | return; |
|---|
| 6862 | char *ifname = argv[0]; |
|---|
| 6863 | websWrite(wp, "<select name=\"%s\">\n", ifname); |
|---|
| 6864 | websWrite(wp, "<option value=\"%s\" %s >LAN</option>\n", |
|---|
| 6865 | nvram_safe_get("lan_ifname"), |
|---|
| 6866 | nvram_match(ifname, |
|---|
| 6867 | nvram_safe_get("lan_ifname")) ? |
|---|
| 6868 | "selected=\"selected\"" : ""); |
|---|
| 6869 | char *next; |
|---|
| 6870 | char var[80]; |
|---|
| 6871 | char eths[256]; |
|---|
| 6872 | |
|---|
| 6873 | memset(eths, 0, 256); |
|---|
| 6874 | getIfLists(eths, 256); |
|---|
| 6875 | foreach(var, eths, next) { |
|---|
| 6876 | if (!strcmp(get_wan_face(), var)) |
|---|
| 6877 | continue; |
|---|
| 6878 | if (!strcmp(nvram_safe_get("lan_ifname"), var)) |
|---|
| 6879 | continue; |
|---|
| 6880 | websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", var, |
|---|
| 6881 | nvram_match(ifname, var) ? "selected" : "", var); |
|---|
| 6882 | } |
|---|
| 6883 | |
|---|
| 6884 | websWrite(wp, "</select>\n"); |
|---|
| 6885 | } |
|---|
| 6886 | |
|---|
| 6887 | #ifdef HAVE_RFLOW |
|---|
| 6888 | void ej_show_rflowif(webs_t wp, int argc, char_t ** argv) |
|---|
| 6889 | { |
|---|
| 6890 | websWrite(wp, "<option value=\"%s\" %s >LAN & WLAN</option>\n", |
|---|
| 6891 | nvram_safe_get("lan_ifname"), nvram_match("rflow_if", |
|---|
| 6892 | nvram_safe_get |
|---|
| 6893 | ("lan_ifname")) |
|---|
| 6894 | ? "selected=\"selected\"" : ""); |
|---|
| 6895 | |
|---|
| 6896 | char *lanifs = nvram_safe_get("lan_ifnames"); |
|---|
| 6897 | char *next; |
|---|
| 6898 | char var[80]; |
|---|
| 6899 | |
|---|
| 6900 | foreach(var, lanifs, next) { |
|---|
| 6901 | if (nvram_match("wan_ifname", var)) |
|---|
| 6902 | continue; |
|---|
| 6903 | if (!ifexists(var)) |
|---|
| 6904 | continue; |
|---|
| 6905 | websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 6906 | var, nvram_match("rflow_if", |
|---|
| 6907 | var) ? "selected=\"selected\"" : |
|---|
| 6908 | "", var); |
|---|
| 6909 | } |
|---|
| 6910 | #if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880) |
|---|
| 6911 | int cnt = get_wl_instances(); |
|---|
| 6912 | int c; |
|---|
| 6913 | |
|---|
| 6914 | for (c = 0; c < cnt; c++) { |
|---|
| 6915 | sprintf(var, "wl%d_ifname", c); |
|---|
| 6916 | websWrite(wp, "<option value=\"%s\" %s >WLAN%d</option>\n", |
|---|
| 6917 | nvram_safe_get(var), nvram_match("rflow_if", |
|---|
| 6918 | nvram_safe_get(var)) |
|---|
| 6919 | ? "selected=\"selected\"" : "", c); |
|---|
| 6920 | } |
|---|
| 6921 | #endif |
|---|
| 6922 | |
|---|
| 6923 | char *wanif = nvram_safe_get("wan_ifname"); |
|---|
| 6924 | |
|---|
| 6925 | if (strlen(wanif) != 0) { |
|---|
| 6926 | websWrite(wp, "<option value=\"%s\" %s >WAN</option>\n", |
|---|
| 6927 | wanif, nvram_match("rflow_if", |
|---|
| 6928 | wanif) ? "selected=\"selected\"" : |
|---|
| 6929 | ""); |
|---|
| 6930 | } |
|---|
| 6931 | } |
|---|
| 6932 | #endif |
|---|
| 6933 | |
|---|
| 6934 | #ifdef HAVE_FREERADIUS |
|---|
| 6935 | |
|---|
| 6936 | void ej_show_certificate_status(webs_t wp, int argc, char_t ** argv) |
|---|
| 6937 | { |
|---|
| 6938 | int percent = 0; |
|---|
| 6939 | if (f_exists("/jffs/etc/freeradius/certs/dh")) |
|---|
| 6940 | percent += 60; |
|---|
| 6941 | if (f_exists("/jffs/etc/freeradius/certs/server.csr")) |
|---|
| 6942 | percent += 5; |
|---|
| 6943 | if (f_exists("/jffs/etc/freeradius/certs/server.key")) |
|---|
| 6944 | percent += 5; |
|---|
| 6945 | if (f_exists("/jffs/etc/freeradius/certs/ca.pem")) |
|---|
| 6946 | percent += 5; |
|---|
| 6947 | if (f_exists("/jffs/etc/freeradius/certs/ca.key")) |
|---|
| 6948 | percent += 5; |
|---|
| 6949 | if (f_exists("/jffs/etc/freeradius/certs/server.crt")) |
|---|
| 6950 | percent += 5; |
|---|
| 6951 | if (f_exists("/jffs/etc/freeradius/certs/server.p12")) |
|---|
| 6952 | percent += 5; |
|---|
| 6953 | if (f_exists("/jffs/etc/freeradius/certs/server.pem")) |
|---|
| 6954 | percent += 5; |
|---|
| 6955 | if (f_exists("/jffs/etc/freeradius/certs/ca.der")) |
|---|
| 6956 | percent += 5; |
|---|
| 6957 | |
|---|
| 6958 | if (percent == 100) { |
|---|
| 6959 | websWrite(wp, "certicate generation done<br />\n"); |
|---|
| 6960 | } else { |
|---|
| 6961 | websWrite(wp, |
|---|
| 6962 | "generating %d%%, this may take a long time<br />\n", |
|---|
| 6963 | percent); |
|---|
| 6964 | } |
|---|
| 6965 | } |
|---|
| 6966 | |
|---|
| 6967 | #include <radiusdb.h> |
|---|
| 6968 | |
|---|
| 6969 | /*struct radiususer { |
|---|
| 6970 | unsigned int fieldlen; |
|---|
| 6971 | unsigned int usersize; |
|---|
| 6972 | unsigned char *user; |
|---|
| 6973 | unsigned int passwordsize; |
|---|
| 6974 | unsigned char *passwd; |
|---|
| 6975 | unsigned int downstream; |
|---|
| 6976 | unsigned int upstream; |
|---|
| 6977 | //more fields can be added in future |
|---|
| 6978 | }; |
|---|
| 6979 | |
|---|
| 6980 | struct radiusdb { |
|---|
| 6981 | unsigned int usercount; |
|---|
| 6982 | struct radiususer *users; |
|---|
| 6983 | }; |
|---|
| 6984 | */ |
|---|
| 6985 | void ej_show_radius_users(webs_t wp, int argc, char_t ** argv) |
|---|
| 6986 | { |
|---|
| 6987 | websWrite(wp, "<table class=\"table\" summary=\"Radius Users\">\n"); |
|---|
| 6988 | |
|---|
| 6989 | websWrite(wp, "<tr>\n\ |
|---|
| 6990 | <th><script type=\"text/javascript\">Capture(freeradius.username)</script></th>\n\ |
|---|
| 6991 | <th><script type=\"text/javascript\">Capture(freeradius.password)</script></th>\n\ |
|---|
| 6992 | <th><script type=\"text/javascript\">Capture(freeradius.downstream)</script></th>\n\ |
|---|
| 6993 | <th><script type=\"text/javascript\">Capture(freeradius.upstream)</script></th>\n\ |
|---|
| 6994 | <th><script type=\"text/javascript\">Capture(freeradius.expiration)</script></th>\n\ |
|---|
| 6995 | <th> </th>\n\ |
|---|
| 6996 | <th> </th>\n\ |
|---|
| 6997 | </tr>\n"); |
|---|
| 6998 | |
|---|
| 6999 | unsigned int i; |
|---|
| 7000 | struct radiusdb *db = loadradiusdb(); |
|---|
| 7001 | time_t tm; |
|---|
| 7002 | time(&tm); |
|---|
| 7003 | if (db != NULL) // empty |
|---|
| 7004 | { |
|---|
| 7005 | for (i = 0; i < db->usercount; i++) { |
|---|
| 7006 | websWrite(wp, "<tr>\n"); |
|---|
| 7007 | char vlan_name[32]; |
|---|
| 7008 | sprintf(vlan_name, "username%d", i); |
|---|
| 7009 | websWrite(wp, |
|---|
| 7010 | "<td><input name=\"%s\" size=\"8\" value=\"%s\" /></td>\n", |
|---|
| 7011 | vlan_name, (db->users[i].user != NULL |
|---|
| 7012 | && db->users[i]. |
|---|
| 7013 | usersize) ? db->users[i]. |
|---|
| 7014 | user : ""); |
|---|
| 7015 | |
|---|
| 7016 | sprintf(vlan_name, "password%d", i); |
|---|
| 7017 | websWrite(wp, |
|---|
| 7018 | "<td><input name=\"%s\" size=\"8\" value=\"%s\" /></td>\n", |
|---|
| 7019 | vlan_name, (db->users[i].passwd != NULL |
|---|
| 7020 | && db-> |
|---|
| 7021 | users[i].passwordsize) ? db-> |
|---|
| 7022 | users[i].passwd : ""); |
|---|
| 7023 | |
|---|
| 7024 | sprintf(vlan_name, "downstream%d", i); |
|---|
| 7025 | websWrite(wp, |
|---|
| 7026 | "<td><input class=\"num\" name=\"%s\" size=\"5\" value=\"%d\" /></td>\n", |
|---|
| 7027 | vlan_name, db->users[i].downstream); |
|---|
| 7028 | |
|---|
| 7029 | sprintf(vlan_name, "upstream%d", i); |
|---|
| 7030 | websWrite(wp, |
|---|
| 7031 | "<td><input class=\"num\" name=\"%s\" size=\"5\" value=\"%d\" /></td>\n", |
|---|
| 7032 | vlan_name, db->users[i].upstream); |
|---|
| 7033 | |
|---|
| 7034 | sprintf(vlan_name, "expiration%d", i); |
|---|
| 7035 | long expiration = 0; //never |
|---|
| 7036 | if (db->users[i].expiration) { |
|---|
| 7037 | long curtime = ((tm / 60) / 60) / 24; //in days |
|---|
| 7038 | expiration = db->users[i].expiration - curtime; |
|---|
| 7039 | } |
|---|
| 7040 | websWrite(wp, |
|---|
| 7041 | "<td><input class=\"num\" name=\"%s\" size=\"3\" value=\"%d\" /></td>\n", |
|---|
| 7042 | vlan_name, expiration); |
|---|
| 7043 | |
|---|
| 7044 | websWrite(wp, |
|---|
| 7045 | "<td><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"user_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n</td>", |
|---|
| 7046 | i); |
|---|
| 7047 | websWrite(wp, |
|---|
| 7048 | "<td><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + freeradius.cert + \"\\\" onclick=\\\"openWindow('FreeRadiusCert-%d.asp', 630, 430,'Certificate');\\\" />\");\n//]]>\n</script></td>\n", |
|---|
| 7049 | i); |
|---|
| 7050 | websWrite(wp, "</tr>\n"); |
|---|
| 7051 | } |
|---|
| 7052 | freeradiusdb(db); |
|---|
| 7053 | } |
|---|
| 7054 | websWrite(wp, "</table>\n"); |
|---|
| 7055 | websWrite(wp, |
|---|
| 7056 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.add + \"\\\" onclick=\\\"user_add_submit(this.form)\\\" />\");\n//]]>\n</script>\n"); |
|---|
| 7057 | } |
|---|
| 7058 | |
|---|
| 7059 | void ej_show_radius_clients(webs_t wp, int argc, char_t ** argv) |
|---|
| 7060 | { |
|---|
| 7061 | websWrite(wp, "<table class=\"table\" summary=\"Radius Clients\">\n"); |
|---|
| 7062 | |
|---|
| 7063 | websWrite(wp, "<tr>\n\ |
|---|
| 7064 | <th>IP/NET</th>\n\ |
|---|
| 7065 | <th><script type=\"text/javascript\">Capture(freeradius.sharedkey)</script></th>\n\ |
|---|
| 7066 | <th> </th>\n\ |
|---|
| 7067 | </tr>\n"); |
|---|
| 7068 | unsigned int i; |
|---|
| 7069 | struct radiusclientdb *db = loadradiusclientdb(); |
|---|
| 7070 | if (db != NULL) // empty |
|---|
| 7071 | { |
|---|
| 7072 | for (i = 0; i < db->usercount; i++) { |
|---|
| 7073 | websWrite(wp, "<tr>\n"); |
|---|
| 7074 | char vlan_name[32]; |
|---|
| 7075 | sprintf(vlan_name, "client%d", i); |
|---|
| 7076 | websWrite(wp, |
|---|
| 7077 | "<td><input name=\"%s\" size=\"20\" value=\"%s\" /></td>\n", |
|---|
| 7078 | vlan_name, (db->users[i].client != NULL |
|---|
| 7079 | && db->users[i]. |
|---|
| 7080 | clientsize) ? db->users[i]. |
|---|
| 7081 | client : ""); |
|---|
| 7082 | |
|---|
| 7083 | sprintf(vlan_name, "shared%d", i); |
|---|
| 7084 | websWrite(wp, |
|---|
| 7085 | "<td><input name=\"%s\" size=\"20\" value=\"%s\" /></td>\n", |
|---|
| 7086 | vlan_name, (db->users[i].passwd != NULL |
|---|
| 7087 | && db-> |
|---|
| 7088 | users[i].passwordsize) ? db-> |
|---|
| 7089 | users[i].passwd : ""); |
|---|
| 7090 | |
|---|
| 7091 | websWrite(wp, |
|---|
| 7092 | "<td><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"client_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script></td>\n", |
|---|
| 7093 | i); |
|---|
| 7094 | websWrite(wp, "</tr>\n"); |
|---|
| 7095 | } |
|---|
| 7096 | freeradiusclientdb(db); |
|---|
| 7097 | } |
|---|
| 7098 | websWrite(wp, "</table>\n"); |
|---|
| 7099 | websWrite(wp, |
|---|
| 7100 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.add + \"\\\" onclick=\\\"client_add_submit(this.form)\\\" />\");\n//]]>\n</script>\n"); |
|---|
| 7101 | } |
|---|
| 7102 | |
|---|
| 7103 | #endif |
|---|