| 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_OPENRISC |
|---|
| 330 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 331 | { |
|---|
| 332 | websWrite(wp, "166"); |
|---|
| 333 | return; |
|---|
| 334 | } |
|---|
| 335 | #elif HAVE_RT3052 |
|---|
| 336 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 337 | { |
|---|
| 338 | websWrite(wp, "384"); |
|---|
| 339 | return; |
|---|
| 340 | } |
|---|
| 341 | #elif HAVE_RT2880 |
|---|
| 342 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 343 | { |
|---|
| 344 | websWrite(wp, "266"); |
|---|
| 345 | return; |
|---|
| 346 | } |
|---|
| 347 | #elif HAVE_XSCALE |
|---|
| 348 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 349 | { |
|---|
| 350 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 351 | |
|---|
| 352 | if (fp == NULL) { |
|---|
| 353 | websWrite(wp, "unknown"); |
|---|
| 354 | return; |
|---|
| 355 | } |
|---|
| 356 | int cnt = 0; |
|---|
| 357 | int b = 0; |
|---|
| 358 | |
|---|
| 359 | while (b != EOF) { |
|---|
| 360 | b = getc(fp); |
|---|
| 361 | if (b == ':') |
|---|
| 362 | cnt++; |
|---|
| 363 | if (cnt == 2) { |
|---|
| 364 | getc(fp); |
|---|
| 365 | char cpuclk[4]; |
|---|
| 366 | |
|---|
| 367 | cpuclk[0] = getc(fp); |
|---|
| 368 | cpuclk[1] = getc(fp); |
|---|
| 369 | cpuclk[2] = getc(fp); |
|---|
| 370 | cpuclk[3] = 0; |
|---|
| 371 | websWrite(wp, cpuclk); |
|---|
| 372 | fclose(fp); |
|---|
| 373 | return; |
|---|
| 374 | } |
|---|
| 375 | } |
|---|
| 376 | |
|---|
| 377 | fclose(fp); |
|---|
| 378 | websWrite(wp, "unknown"); |
|---|
| 379 | return; |
|---|
| 380 | } |
|---|
| 381 | #elif HAVE_X86 |
|---|
| 382 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 383 | { |
|---|
| 384 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 385 | |
|---|
| 386 | if (fp == NULL) { |
|---|
| 387 | websWrite(wp, "unknown"); |
|---|
| 388 | return; |
|---|
| 389 | } |
|---|
| 390 | int cnt = 0; |
|---|
| 391 | int b = 0; |
|---|
| 392 | |
|---|
| 393 | while (b != EOF) { |
|---|
| 394 | b = getc(fp); |
|---|
| 395 | if (b == ':') |
|---|
| 396 | cnt++; |
|---|
| 397 | if (cnt == 7) { |
|---|
| 398 | getc(fp); |
|---|
| 399 | char cpuclk[32]; |
|---|
| 400 | int i = 0; |
|---|
| 401 | |
|---|
| 402 | b = getc(fp); |
|---|
| 403 | while (b != 0xa && b != 0xd && b != 0x20) { |
|---|
| 404 | cpuclk[i++] = b; |
|---|
| 405 | b = getc(fp); |
|---|
| 406 | } |
|---|
| 407 | cpuclk[i++] = 0; |
|---|
| 408 | websWrite(wp, cpuclk); |
|---|
| 409 | fclose(fp); |
|---|
| 410 | return; |
|---|
| 411 | } |
|---|
| 412 | } |
|---|
| 413 | |
|---|
| 414 | fclose(fp); |
|---|
| 415 | websWrite(wp, "unknown"); |
|---|
| 416 | return; |
|---|
| 417 | } |
|---|
| 418 | #elif HAVE_MAGICBOX |
|---|
| 419 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 420 | { |
|---|
| 421 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 422 | |
|---|
| 423 | if (fp == NULL) { |
|---|
| 424 | websWrite(wp, "unknown"); |
|---|
| 425 | return; |
|---|
| 426 | } |
|---|
| 427 | int cnt = 0; |
|---|
| 428 | int b = 0; |
|---|
| 429 | |
|---|
| 430 | while (b != EOF) { |
|---|
| 431 | b = getc(fp); |
|---|
| 432 | if (b == ':') |
|---|
| 433 | cnt++; |
|---|
| 434 | if (cnt == 3) { |
|---|
| 435 | getc(fp); |
|---|
| 436 | char cpuclk[4]; |
|---|
| 437 | |
|---|
| 438 | cpuclk[0] = getc(fp); |
|---|
| 439 | cpuclk[1] = getc(fp); |
|---|
| 440 | cpuclk[2] = getc(fp); |
|---|
| 441 | cpuclk[3] = 0; |
|---|
| 442 | websWrite(wp, cpuclk); |
|---|
| 443 | fclose(fp); |
|---|
| 444 | return; |
|---|
| 445 | } |
|---|
| 446 | } |
|---|
| 447 | |
|---|
| 448 | fclose(fp); |
|---|
| 449 | websWrite(wp, "unknown"); |
|---|
| 450 | return; |
|---|
| 451 | } |
|---|
| 452 | #elif HAVE_RB600 |
|---|
| 453 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 454 | { |
|---|
| 455 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 456 | |
|---|
| 457 | if (fp == NULL) { |
|---|
| 458 | websWrite(wp, "unknown"); |
|---|
| 459 | return; |
|---|
| 460 | } |
|---|
| 461 | int cnt = 0; |
|---|
| 462 | int b = 0; |
|---|
| 463 | |
|---|
| 464 | while (b != EOF) { |
|---|
| 465 | b = getc(fp); |
|---|
| 466 | if (b == ':') |
|---|
| 467 | cnt++; |
|---|
| 468 | if (cnt == 3) { |
|---|
| 469 | getc(fp); |
|---|
| 470 | char cpuclk[4]; |
|---|
| 471 | |
|---|
| 472 | cpuclk[0] = getc(fp); |
|---|
| 473 | cpuclk[1] = getc(fp); |
|---|
| 474 | cpuclk[2] = getc(fp); |
|---|
| 475 | cpuclk[3] = 0; |
|---|
| 476 | websWrite(wp, cpuclk); |
|---|
| 477 | fclose(fp); |
|---|
| 478 | return; |
|---|
| 479 | } |
|---|
| 480 | } |
|---|
| 481 | |
|---|
| 482 | fclose(fp); |
|---|
| 483 | websWrite(wp, "unknown"); |
|---|
| 484 | return; |
|---|
| 485 | } |
|---|
| 486 | #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) |
|---|
| 487 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 488 | { |
|---|
| 489 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 490 | |
|---|
| 491 | if (fp == NULL) { |
|---|
| 492 | websWrite(wp, "unknown"); |
|---|
| 493 | return; |
|---|
| 494 | } |
|---|
| 495 | int cnt = 0; |
|---|
| 496 | int b = 0; |
|---|
| 497 | |
|---|
| 498 | while (b != EOF) { |
|---|
| 499 | b = getc(fp); |
|---|
| 500 | if (b == ':') |
|---|
| 501 | cnt++; |
|---|
| 502 | if (cnt == 4) { |
|---|
| 503 | getc(fp); |
|---|
| 504 | char cpuclk[4]; |
|---|
| 505 | |
|---|
| 506 | cpuclk[0] = getc(fp); |
|---|
| 507 | cpuclk[1] = getc(fp); |
|---|
| 508 | cpuclk[2] = getc(fp); |
|---|
| 509 | cpuclk[3] = 0; |
|---|
| 510 | websWrite(wp, cpuclk); |
|---|
| 511 | fclose(fp); |
|---|
| 512 | return; |
|---|
| 513 | } |
|---|
| 514 | } |
|---|
| 515 | |
|---|
| 516 | fclose(fp); |
|---|
| 517 | websWrite(wp, "unknown"); |
|---|
| 518 | return; |
|---|
| 519 | } |
|---|
| 520 | #elif defined(HAVE_PB42) || defined(HAVE_LSX) || defined(HAVE_DANUBE) |
|---|
| 521 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 522 | { |
|---|
| 523 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 524 | |
|---|
| 525 | if (fp == NULL) { |
|---|
| 526 | websWrite(wp, "unknown"); |
|---|
| 527 | return; |
|---|
| 528 | } |
|---|
| 529 | int cnt = 0; |
|---|
| 530 | int b = 0; |
|---|
| 531 | |
|---|
| 532 | while (b != EOF) { |
|---|
| 533 | b = getc(fp); |
|---|
| 534 | if (b == ':') |
|---|
| 535 | cnt++; |
|---|
| 536 | if (cnt == 5) { |
|---|
| 537 | getc(fp); |
|---|
| 538 | char cpuclk[4]; |
|---|
| 539 | |
|---|
| 540 | cpuclk[0] = getc(fp); |
|---|
| 541 | cpuclk[1] = getc(fp); |
|---|
| 542 | cpuclk[2] = getc(fp); |
|---|
| 543 | cpuclk[3] = 0; |
|---|
| 544 | websWrite(wp, cpuclk); |
|---|
| 545 | fclose(fp); |
|---|
| 546 | return; |
|---|
| 547 | } |
|---|
| 548 | } |
|---|
| 549 | |
|---|
| 550 | fclose(fp); |
|---|
| 551 | websWrite(wp, "unknown"); |
|---|
| 552 | return; |
|---|
| 553 | } |
|---|
| 554 | |
|---|
| 555 | #else |
|---|
| 556 | |
|---|
| 557 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 558 | { |
|---|
| 559 | char *clk = nvram_get("clkfreq"); |
|---|
| 560 | |
|---|
| 561 | if (clk == NULL) { |
|---|
| 562 | if (getcpurev() == 0) //BCM4710 |
|---|
| 563 | websWrite(wp, "125"); |
|---|
| 564 | else if (getcpurev() == 29) //BCM5354 |
|---|
| 565 | websWrite(wp, "240"); |
|---|
| 566 | else |
|---|
| 567 | websWrite(wp, "unknown"); |
|---|
| 568 | return; |
|---|
| 569 | } |
|---|
| 570 | char buf[64]; |
|---|
| 571 | |
|---|
| 572 | strcpy(buf, clk); |
|---|
| 573 | int i = 0; |
|---|
| 574 | |
|---|
| 575 | while (buf[i++] != 0) { |
|---|
| 576 | if (buf[i] == ',') |
|---|
| 577 | buf[i] = 0; |
|---|
| 578 | } |
|---|
| 579 | websWrite(wp, buf); |
|---|
| 580 | return; |
|---|
| 581 | } |
|---|
| 582 | #endif |
|---|
| 583 | |
|---|
| 584 | void ej_show_cpuinfo(webs_t wp, int argc, char_t ** argv) |
|---|
| 585 | { |
|---|
| 586 | #ifdef HAVE_RB600 |
|---|
| 587 | websWrite(wp, "FreeScale MPC8343"); |
|---|
| 588 | #else |
|---|
| 589 | FILE *fcpu = fopen("/proc/cpuinfo", "r"); |
|---|
| 590 | |
|---|
| 591 | if (fcpu == NULL) { |
|---|
| 592 | websWrite(wp, "Not Detected!\n"); |
|---|
| 593 | return; |
|---|
| 594 | } |
|---|
| 595 | char buf[256]; |
|---|
| 596 | int i; |
|---|
| 597 | |
|---|
| 598 | #ifdef HAVE_MAGICBOX |
|---|
| 599 | int cnt = 0; |
|---|
| 600 | #endif |
|---|
| 601 | #ifdef HAVE_X86 |
|---|
| 602 | int cnt = 0; |
|---|
| 603 | #endif |
|---|
| 604 | for (i = 0; i < 256; i++) { |
|---|
| 605 | int c = getc(fcpu); |
|---|
| 606 | |
|---|
| 607 | if (c == EOF) { |
|---|
| 608 | websWrite(wp, "Not Detected!\n"); |
|---|
| 609 | fclose(fcpu); |
|---|
| 610 | return; |
|---|
| 611 | } |
|---|
| 612 | if (c == ':') |
|---|
| 613 | #ifdef HAVE_MAGICBOX |
|---|
| 614 | cnt++; |
|---|
| 615 | if (cnt == 2) |
|---|
| 616 | break; |
|---|
| 617 | #elif HAVE_X86 |
|---|
| 618 | cnt++; |
|---|
| 619 | if (cnt == 5) |
|---|
| 620 | break; |
|---|
| 621 | #else |
|---|
| 622 | break; |
|---|
| 623 | #endif |
|---|
| 624 | } |
|---|
| 625 | getc(fcpu); |
|---|
| 626 | for (i = 0; i < 256; i++) { |
|---|
| 627 | int c = getc(fcpu); |
|---|
| 628 | |
|---|
| 629 | if (c == EOF) { |
|---|
| 630 | websWrite(wp, "Not Detected!\n"); |
|---|
| 631 | fclose(fcpu); |
|---|
| 632 | return; |
|---|
| 633 | } |
|---|
| 634 | if (c == 0xa || c == 0xd) |
|---|
| 635 | break; |
|---|
| 636 | buf[i] = c; |
|---|
| 637 | } |
|---|
| 638 | buf[i] = 0; |
|---|
| 639 | websWrite(wp, buf); |
|---|
| 640 | fclose(fcpu); |
|---|
| 641 | return; |
|---|
| 642 | #endif |
|---|
| 643 | } |
|---|
| 644 | |
|---|
| 645 | #define ASSOCLIST_TMP "/tmp/.wl_assoclist" |
|---|
| 646 | #define RSSI_TMP "/tmp/.rssi" |
|---|
| 647 | #define ASSOCLIST_CMD "wl assoclist" |
|---|
| 648 | #define RSSI_CMD "wl rssi" |
|---|
| 649 | #define NOISE_CMD "wl noise" |
|---|
| 650 | |
|---|
| 651 | void ej_show_wds_subnet(webs_t wp, int argc, char_t ** argv) |
|---|
| 652 | { |
|---|
| 653 | int index = -1; |
|---|
| 654 | char *interface; |
|---|
| 655 | |
|---|
| 656 | #ifdef FASTWEB |
|---|
| 657 | ejArgs(argc, argv, "%d %s", &index, &interface); |
|---|
| 658 | #else |
|---|
| 659 | if (ejArgs(argc, argv, "%d %s", &index, &interface) < 2) { |
|---|
| 660 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 661 | return; |
|---|
| 662 | } |
|---|
| 663 | #endif |
|---|
| 664 | char br1[32]; |
|---|
| 665 | |
|---|
| 666 | sprintf(br1, "%s_br1_enable", interface); |
|---|
| 667 | if (nvram_invmatch(br1, "1")) |
|---|
| 668 | return; |
|---|
| 669 | char buf[16]; |
|---|
| 670 | |
|---|
| 671 | sprintf(buf, "%s_wds%d_enable", interface, index); |
|---|
| 672 | websWrite(wp, |
|---|
| 673 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"2\\\" %s >\" + wds.subnet + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 674 | nvram_selmatch(wp, buf, |
|---|
| 675 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 676 | return; |
|---|
| 677 | } |
|---|
| 678 | |
|---|
| 679 | #ifdef HAVE_SKYTRON |
|---|
| 680 | void ej_active_wireless2(webs_t wp, int argc, char_t ** argv) |
|---|
| 681 | { |
|---|
| 682 | int rssi = 0, noise = 0; |
|---|
| 683 | FILE *fp, *fp2; |
|---|
| 684 | char *mode; |
|---|
| 685 | char mac[30]; |
|---|
| 686 | char list[2][30]; |
|---|
| 687 | char line[80]; |
|---|
| 688 | |
|---|
| 689 | unlink(ASSOCLIST_TMP); |
|---|
| 690 | unlink(RSSI_TMP); |
|---|
| 691 | |
|---|
| 692 | mode = nvram_safe_get("wl_mode"); |
|---|
| 693 | sysprintf("%s > %s", ASSOCLIST_CMD, ASSOCLIST_TMP); |
|---|
| 694 | |
|---|
| 695 | int connected = 0; |
|---|
| 696 | |
|---|
| 697 | if ((fp = fopen(ASSOCLIST_TMP, "r"))) { |
|---|
| 698 | while (fgets(line, sizeof(line), fp) != NULL) { |
|---|
| 699 | if (sscanf(line, "%s %s", list[0], mac) != 2) // assoclist |
|---|
| 700 | // 00:11:22:33:44:55 |
|---|
| 701 | continue; |
|---|
| 702 | |
|---|
| 703 | if (strcmp(list[0], "assoclist")) |
|---|
| 704 | break; |
|---|
| 705 | |
|---|
| 706 | rssi = 0; |
|---|
| 707 | noise = 0; |
|---|
| 708 | // get rssi value |
|---|
| 709 | if (strcmp(mode, "ap")) |
|---|
| 710 | sysprintf("%s > %s", RSSI_CMD, RSSI_TMP); |
|---|
| 711 | else |
|---|
| 712 | sysprintf("%s \"%s\" > %s", RSSI_CMD, mac, |
|---|
| 713 | RSSI_TMP); |
|---|
| 714 | |
|---|
| 715 | // get noise value if not ap mode |
|---|
| 716 | if (strcmp(mode, "ap")) |
|---|
| 717 | sysprintf("%s >> %s", NOISE_CMD, RSSI_TMP); |
|---|
| 718 | |
|---|
| 719 | fp2 = fopen(RSSI_TMP, "r"); |
|---|
| 720 | if (fgets(line, sizeof(line), fp2) != NULL) { |
|---|
| 721 | |
|---|
| 722 | // get rssi |
|---|
| 723 | if (sscanf |
|---|
| 724 | (line, "%s %s %d", list[0], list[1], |
|---|
| 725 | &rssi) != 3) |
|---|
| 726 | continue; |
|---|
| 727 | |
|---|
| 728 | // get noise for client/wet mode |
|---|
| 729 | if (strcmp(mode, "ap") && |
|---|
| 730 | fgets(line, sizeof(line), fp2) != NULL && |
|---|
| 731 | sscanf(line, "%s %s %d", list[0], list[1], |
|---|
| 732 | &noise) != 3) |
|---|
| 733 | continue; |
|---|
| 734 | |
|---|
| 735 | fclose(fp2); |
|---|
| 736 | } |
|---|
| 737 | if (nvram_match("maskmac", "1")) { |
|---|
| 738 | mac[0] = 'x'; |
|---|
| 739 | mac[1] = 'x'; |
|---|
| 740 | mac[3] = 'x'; |
|---|
| 741 | mac[4] = 'x'; |
|---|
| 742 | mac[6] = 'x'; |
|---|
| 743 | mac[7] = 'x'; |
|---|
| 744 | mac[9] = 'x'; |
|---|
| 745 | mac[10] = 'x'; |
|---|
| 746 | } |
|---|
| 747 | if (strcmp(mode, "ap") != 0) { |
|---|
| 748 | connected = 1; |
|---|
| 749 | websWrite(wp, "<tr>\n"); |
|---|
| 750 | websWrite(wp, |
|---|
| 751 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\"><b>Verbindungsstatus</b></font></td>\n"); |
|---|
| 752 | websWrite(wp, |
|---|
| 753 | "<td bgcolor=\"#B2B2B2\"></td>\n"); |
|---|
| 754 | websWrite(wp, |
|---|
| 755 | "<td bgcolor=\"#FFFFFF\"></td>\n"); |
|---|
| 756 | websWrite(wp, |
|---|
| 757 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Verbunden</font></td>\n"); |
|---|
| 758 | websWrite(wp, "</tr>\n"); |
|---|
| 759 | websWrite(wp, "<tr>\n"); |
|---|
| 760 | websWrite(wp, |
|---|
| 761 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Signal</font></td>\n"); |
|---|
| 762 | websWrite(wp, |
|---|
| 763 | "<td bgcolor=\"#B2B2B2\"></td>\n"); |
|---|
| 764 | websWrite(wp, |
|---|
| 765 | "<td bgcolor=\"#FFFFFF\"></td>\n"); |
|---|
| 766 | websWrite(wp, |
|---|
| 767 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">%d dBm</font></td>\n", |
|---|
| 768 | rssi); |
|---|
| 769 | websWrite(wp, "</tr>\n"); |
|---|
| 770 | websWrite(wp, "<tr>\n"); |
|---|
| 771 | websWrite(wp, |
|---|
| 772 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Rauschen</font></td>\n"); |
|---|
| 773 | websWrite(wp, |
|---|
| 774 | "<td bgcolor=\"#B2B2B2\"></td>\n"); |
|---|
| 775 | websWrite(wp, |
|---|
| 776 | "<td bgcolor=\"#FFFFFF\"></td>\n"); |
|---|
| 777 | websWrite(wp, |
|---|
| 778 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">%d dBm</font></td>\n", |
|---|
| 779 | noise); |
|---|
| 780 | websWrite(wp, "</tr>\n"); |
|---|
| 781 | } |
|---|
| 782 | } |
|---|
| 783 | fclose(fp); |
|---|
| 784 | } |
|---|
| 785 | |
|---|
| 786 | unlink(ASSOCLIST_TMP); |
|---|
| 787 | unlink(RSSI_TMP); |
|---|
| 788 | if (!connected) { |
|---|
| 789 | connected = 1; |
|---|
| 790 | websWrite(wp, "<tr>\n"); |
|---|
| 791 | websWrite(wp, |
|---|
| 792 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\"><b>Verbindungsstatus</b></font></td>\n"); |
|---|
| 793 | websWrite(wp, "<td bgcolor=\"#B2B2B2\"></td>\n"); |
|---|
| 794 | websWrite(wp, "<td bgcolor=\"#FFFFFF\"></td>\n"); |
|---|
| 795 | websWrite(wp, |
|---|
| 796 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Nicht Verbunden</font></td>\n"); |
|---|
| 797 | websWrite(wp, "</tr>\n"); |
|---|
| 798 | |
|---|
| 799 | } |
|---|
| 800 | |
|---|
| 801 | return 0; |
|---|
| 802 | } |
|---|
| 803 | #endif |
|---|
| 804 | |
|---|
| 805 | void ej_show_paypal(webs_t wp, int argc, char_t ** argv) |
|---|
| 806 | { |
|---|
| 807 | #ifdef HAVE_DDLAN |
|---|
| 808 | websWrite(wp, |
|---|
| 809 | "<a href=\"mailto:support@mcdd.de\">support@mcdd.de</a><br />"); |
|---|
| 810 | #endif |
|---|
| 811 | #ifdef HAVE_CORENET |
|---|
| 812 | websWrite(wp, |
|---|
| 813 | "<a href=\"http://www.corenetsolutions.com\">http://www.corenetsolutions.com</a><br />"); |
|---|
| 814 | #endif |
|---|
| 815 | |
|---|
| 816 | #ifndef CONFIG_BRANDING |
|---|
| 817 | #ifndef HAVE_REGISTER |
|---|
| 818 | websWrite(wp, "<a href=\"http://www.dd-wrt.com/\">DD-WRT</a><br />"); |
|---|
| 819 | websWrite(wp, |
|---|
| 820 | "<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\" target=\"_blank\">"); |
|---|
| 821 | websWrite(wp, |
|---|
| 822 | "<input type=\"hidden\" name=\"cmd\" value=\"_xclick\" />"); |
|---|
| 823 | websWrite(wp, |
|---|
| 824 | "<input type=\"hidden\" name=\"business\" value=\"paypal@dd-wrt.com\" />"); |
|---|
| 825 | websWrite(wp, |
|---|
| 826 | "<input type=\"hidden\" name=\"item_name\" value=\"DD-WRT Development Support\" />"); |
|---|
| 827 | websWrite(wp, "<input type=\"hidden\" name=\"no_note\" value=\"1\" />"); |
|---|
| 828 | websWrite(wp, |
|---|
| 829 | "<input type=\"hidden\" name=\"currency_code\" value=\"EUR\" />"); |
|---|
| 830 | websWrite(wp, "<input type=\"hidden\" name=\"lc\" value=\"en\" />"); |
|---|
| 831 | websWrite(wp, "<input type=\"hidden\" name=\"tax\" value=\"0\" />"); |
|---|
| 832 | websWrite(wp, |
|---|
| 833 | "<input type=\"image\" src=\"images/paypal.gif\" name=\"submit\" />"); |
|---|
| 834 | websWrite(wp, "</form>"); |
|---|
| 835 | websWrite(wp, |
|---|
| 836 | "<br /><script type=\"text/javascript\">Capture(donate.mb)</script><br />\n"); |
|---|
| 837 | websWrite(wp, |
|---|
| 838 | "<a href=\"https://www.moneybookers.com/app/send.pl\" target=\"_blank\">\n"); |
|---|
| 839 | // #ifdef HAVE_MICRO |
|---|
| 840 | // websWrite (wp, |
|---|
| 841 | // "<img style=\"border-width: 1px; border-color: #8B8583;\" |
|---|
| 842 | // src=\"http://www.moneybookers.com/images/banners/88_en_interpayments.gif\" |
|---|
| 843 | // alt=\"donate thru moneybookers\" />\n"); |
|---|
| 844 | // #else |
|---|
| 845 | websWrite(wp, |
|---|
| 846 | "<img style=\"border-width: 1px; border-color: #8B8583;\" src=\"images/88_en_interpayments.png\" alt=\"donate thru interpayments\" />\n"); |
|---|
| 847 | // #endif |
|---|
| 848 | websWrite(wp, "</a>\n"); |
|---|
| 849 | #endif |
|---|
| 850 | #endif |
|---|
| 851 | return; |
|---|
| 852 | } |
|---|
| 853 | |
|---|
| 854 | #ifdef HAVE_RADLOCAL |
|---|
| 855 | |
|---|
| 856 | void ej_show_iradius_check(webs_t wp, int argc, char_t ** argv) |
|---|
| 857 | { |
|---|
| 858 | char *sln = nvram_safe_get("iradius_count"); |
|---|
| 859 | |
|---|
| 860 | if (sln == NULL || strlen(sln) == 0) |
|---|
| 861 | return; |
|---|
| 862 | int leasenum = atoi(sln); |
|---|
| 863 | int i; |
|---|
| 864 | |
|---|
| 865 | for (i = 0; i < leasenum; i++) { |
|---|
| 866 | websWrite(wp, "if(F._iradius%d_active)\n", i); |
|---|
| 867 | websWrite(wp, "if(F._iradius%d_active.checked == true)\n", i); |
|---|
| 868 | websWrite(wp, "F.iradius%d_active.value=1\n", i); |
|---|
| 869 | websWrite(wp, "else\n"); |
|---|
| 870 | websWrite(wp, "F.iradius%d_active.value=0\n", i); |
|---|
| 871 | |
|---|
| 872 | websWrite(wp, "if(F._iradius%d_delete)\n", i); |
|---|
| 873 | websWrite(wp, "if(F._iradius%d_delete.checked == true)\n", i); |
|---|
| 874 | websWrite(wp, "F.iradius%d_delete.value=1\n", i); |
|---|
| 875 | websWrite(wp, "else\n"); |
|---|
| 876 | websWrite(wp, "F.iradius%d_delete.value=0\n", i); |
|---|
| 877 | } |
|---|
| 878 | |
|---|
| 879 | } |
|---|
| 880 | |
|---|
| 881 | void ej_show_iradius(webs_t wp, int argc, char_t ** argv) |
|---|
| 882 | { |
|---|
| 883 | char *sln = nvram_safe_get("iradius_count"); |
|---|
| 884 | |
|---|
| 885 | if (sln == NULL || strlen(sln) == 0) |
|---|
| 886 | return; |
|---|
| 887 | int leasenum = atoi(sln); |
|---|
| 888 | |
|---|
| 889 | if (leasenum == 0) |
|---|
| 890 | return; |
|---|
| 891 | int i; |
|---|
| 892 | char username[32]; |
|---|
| 893 | char *o, *userlist; |
|---|
| 894 | |
|---|
| 895 | cprintf("get collection\n"); |
|---|
| 896 | char *u = nvram_get_collection("iradius"); |
|---|
| 897 | |
|---|
| 898 | cprintf("collection result %s", u); |
|---|
| 899 | if (u != NULL) { |
|---|
| 900 | userlist = (char *)malloc(strlen(u) + 1); |
|---|
| 901 | strcpy(userlist, u); |
|---|
| 902 | free(u); |
|---|
| 903 | o = userlist; |
|---|
| 904 | } else { |
|---|
| 905 | userlist = NULL; |
|---|
| 906 | o = NULL; |
|---|
| 907 | } |
|---|
| 908 | cprintf("display = chain\n"); |
|---|
| 909 | struct timeval now; |
|---|
| 910 | |
|---|
| 911 | gettimeofday(&now, NULL); |
|---|
| 912 | for (i = 0; i < leasenum; i++) { |
|---|
| 913 | snprintf(username, 31, "iradius%d_name", i); |
|---|
| 914 | char *sep = NULL; |
|---|
| 915 | |
|---|
| 916 | if (userlist) |
|---|
| 917 | sep = strsep(&userlist, " "); |
|---|
| 918 | websWrite(wp, "<tr><td>\n"); |
|---|
| 919 | websWrite(wp, "<input name=\"%s\" type=\"hidden\" />", |
|---|
| 920 | username); |
|---|
| 921 | websWrite(wp, |
|---|
| 922 | "<input name=\"%s\" value=\"%s\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 923 | username, sep != NULL ? sep : ""); |
|---|
| 924 | websWrite(wp, "</td>\n"); |
|---|
| 925 | if (userlist) |
|---|
| 926 | sep = strsep(&userlist, " "); |
|---|
| 927 | |
|---|
| 928 | char active[32]; |
|---|
| 929 | |
|---|
| 930 | snprintf(active, 31, "iradius%d_active", i); |
|---|
| 931 | |
|---|
| 932 | websWrite(wp, "<td>\n"); |
|---|
| 933 | websWrite(wp, "<input name=\"%s\" type=\"hidden\" />", active); |
|---|
| 934 | websWrite(wp, |
|---|
| 935 | "<input type=\"checkbox\" value=\"%s\" name=\"_%s\" %s />\n", |
|---|
| 936 | sep, active, sep != NULL ? strcmp(sep, |
|---|
| 937 | "1") == |
|---|
| 938 | 0 ? "checked=\"checked\"" : "" : ""); |
|---|
| 939 | websWrite(wp, "</td>\n"); |
|---|
| 940 | websWrite(wp, "<td>\n"); |
|---|
| 941 | if (userlist) |
|---|
| 942 | sep = strsep(&userlist, " "); |
|---|
| 943 | long t = atol(sep); |
|---|
| 944 | |
|---|
| 945 | if (t != -1) { |
|---|
| 946 | t -= now.tv_sec; |
|---|
| 947 | t /= 60; |
|---|
| 948 | } |
|---|
| 949 | |
|---|
| 950 | snprintf(active, 31, "iradius%d_lease", i); |
|---|
| 951 | char st[32]; |
|---|
| 952 | |
|---|
| 953 | if (t >= 0) |
|---|
| 954 | sprintf(st, "%d", t); |
|---|
| 955 | else |
|---|
| 956 | sprintf(st, "over"); |
|---|
| 957 | websWrite(wp, "<input type=\"num\" name=\"%s\" value='%s' />\n", |
|---|
| 958 | active, st); |
|---|
| 959 | websWrite(wp, "</td>\n"); |
|---|
| 960 | |
|---|
| 961 | websWrite(wp, "<td>\n"); |
|---|
| 962 | snprintf(active, 31, "iradius%d_delete", i); |
|---|
| 963 | websWrite(wp, "<input name=\"%s\" type=\"hidden\" />", active); |
|---|
| 964 | websWrite(wp, "<input type=\"checkbox\" name=\"_%s\"/>\n", |
|---|
| 965 | active); |
|---|
| 966 | websWrite(wp, "</td></tr>\n"); |
|---|
| 967 | } |
|---|
| 968 | if (o != NULL) |
|---|
| 969 | free(o); |
|---|
| 970 | return; |
|---|
| 971 | } |
|---|
| 972 | |
|---|
| 973 | #endif |
|---|
| 974 | |
|---|
| 975 | #ifdef HAVE_CHILLILOCAL |
|---|
| 976 | |
|---|
| 977 | void ej_show_userlist(webs_t wp, int argc, char_t ** argv) |
|---|
| 978 | { |
|---|
| 979 | char *sln = nvram_safe_get("fon_usernames"); |
|---|
| 980 | |
|---|
| 981 | if (sln == NULL || strlen(sln) == 0) |
|---|
| 982 | return; |
|---|
| 983 | int leasenum = atoi(sln); |
|---|
| 984 | |
|---|
| 985 | if (leasenum == 0) |
|---|
| 986 | return; |
|---|
| 987 | int i; |
|---|
| 988 | char username[32]; |
|---|
| 989 | char password[32]; |
|---|
| 990 | char *u = nvram_safe_get("fon_userlist"); |
|---|
| 991 | char *userlist = (char *)malloc(strlen(u) + 1); |
|---|
| 992 | |
|---|
| 993 | strcpy(userlist, u); |
|---|
| 994 | char *o = userlist; |
|---|
| 995 | |
|---|
| 996 | for (i = 0; i < leasenum; i++) { |
|---|
| 997 | snprintf(username, 31, "fon_user%d_name", i); |
|---|
| 998 | char *sep = strsep(&userlist, "="); |
|---|
| 999 | |
|---|
| 1000 | websWrite(wp, "<tr><td>\n"); |
|---|
| 1001 | websWrite(wp, |
|---|
| 1002 | "<input name=\"%s\" value=\"%s\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 1003 | username, sep != NULL ? sep : ""); |
|---|
| 1004 | websWrite(wp, "</td>\n"); |
|---|
| 1005 | sep = strsep(&userlist, " "); |
|---|
| 1006 | snprintf(password, 31, "fon_user%d_password", i); |
|---|
| 1007 | websWrite(wp, "<td>\n"); |
|---|
| 1008 | websWrite(wp, |
|---|
| 1009 | "<input type=\"password\" name=\"%s\" value=\"blahblahblah\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 1010 | password); |
|---|
| 1011 | websWrite(wp, "</td></tr>\n"); |
|---|
| 1012 | } |
|---|
| 1013 | free(o); |
|---|
| 1014 | return; |
|---|
| 1015 | } |
|---|
| 1016 | |
|---|
| 1017 | #endif |
|---|
| 1018 | |
|---|
| 1019 | void ej_show_staticleases(webs_t wp, int argc, char_t ** argv) |
|---|
| 1020 | { |
|---|
| 1021 | int i; |
|---|
| 1022 | |
|---|
| 1023 | // cprintf("get static leasenum"); |
|---|
| 1024 | |
|---|
| 1025 | char *sln = nvram_safe_get("static_leasenum"); |
|---|
| 1026 | |
|---|
| 1027 | // cprintf("check null"); |
|---|
| 1028 | if (sln == NULL || strlen(sln) == 0) |
|---|
| 1029 | return; |
|---|
| 1030 | // cprintf("atoi"); |
|---|
| 1031 | |
|---|
| 1032 | int leasenum = atoi(sln); |
|---|
| 1033 | |
|---|
| 1034 | // cprintf("leasenum==0"); |
|---|
| 1035 | if (leasenum == 0) |
|---|
| 1036 | return; |
|---|
| 1037 | // cprintf("get leases"); |
|---|
| 1038 | char *nvleases = nvram_safe_get("static_leases"); |
|---|
| 1039 | char *leases = (char *)malloc(strlen(nvleases) + 1); |
|---|
| 1040 | char *originalpointer = leases; // strsep destroys the pointer by |
|---|
| 1041 | |
|---|
| 1042 | // moving it |
|---|
| 1043 | strcpy(leases, nvleases); |
|---|
| 1044 | for (i = 0; i < leasenum; i++) { |
|---|
| 1045 | char *sep = strsep(&leases, "="); |
|---|
| 1046 | |
|---|
| 1047 | websWrite(wp, |
|---|
| 1048 | "<tr><td><input name=\"lease%d_hwaddr\" value=\"%s\" size=\"18\" maxlength=\"18\" onblur=\"valid_name(this,share.mac,SPACE_NO)\" /></td>", |
|---|
| 1049 | i, sep != NULL ? sep : ""); |
|---|
| 1050 | sep = strsep(&leases, "="); |
|---|
| 1051 | websWrite(wp, |
|---|
| 1052 | "<td><input name=\"lease%d_hostname\" value=\"%s\" size=\"24\" maxlength=\"24\" onblur=\"valid_name(this,share.hostname,SPACE_NO)\" /></td>", |
|---|
| 1053 | i, sep != NULL ? sep : ""); |
|---|
| 1054 | sep = strsep(&leases, "="); |
|---|
| 1055 | websWrite(wp, |
|---|
| 1056 | "<td><input name=\"lease%d_ip\" value=\"%s\" size=\"15\" maxlength=\"15\" class=\"num\" onblur=\"valid_name(this,share.ip,SPACE_NO)\" /></td>\n", |
|---|
| 1057 | i, sep != NULL ? sep : ""); |
|---|
| 1058 | sep = strsep(&leases, " "); |
|---|
| 1059 | websWrite(wp, |
|---|
| 1060 | "<td><input name=\"lease%d_time\" value=\"%s\" size=\"10\" maxlength=\"10\" class=\"num\" onblur=\"valid_name(this,share.time,SPACE_NO)\" /><script type=\"text/javascript\">Capture(share.minutes)</script></td></tr>\n", |
|---|
| 1061 | i, sep != NULL ? sep : ""); |
|---|
| 1062 | } |
|---|
| 1063 | free(originalpointer); |
|---|
| 1064 | return; |
|---|
| 1065 | } |
|---|
| 1066 | |
|---|
| 1067 | void ej_show_control(webs_t wp, int argc, char_t ** argv) |
|---|
| 1068 | { |
|---|
| 1069 | #ifdef CONFIG_BRANDING |
|---|
| 1070 | websWrite(wp, "Control Panel"); |
|---|
| 1071 | #else |
|---|
| 1072 | websWrite(wp, "DD-WRT Control Panel"); |
|---|
| 1073 | #endif |
|---|
| 1074 | return; |
|---|
| 1075 | } |
|---|
| 1076 | |
|---|
| 1077 | #ifndef HAVE_AQOS |
|---|
| 1078 | void ej_show_default_level(webs_t wp, int argc, char_t ** argv) |
|---|
| 1079 | { |
|---|
| 1080 | return; |
|---|
| 1081 | } |
|---|
| 1082 | |
|---|
| 1083 | #else |
|---|
| 1084 | void ej_show_default_level(webs_t wp, int argc, char_t ** argv) |
|---|
| 1085 | { |
|---|
| 1086 | websWrite(wp, "<fieldset>\n"); |
|---|
| 1087 | websWrite(wp, |
|---|
| 1088 | "<legend><script type=\"text/javascript\">Capture(qos.legend6)</script></legend>\n"); |
|---|
| 1089 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1090 | websWrite(wp, |
|---|
| 1091 | "<div class=\"label\"><script type=\"text/javascript\">Capture(qos.bandwidth)</script> Up</div>\n"); |
|---|
| 1092 | websWrite(wp, |
|---|
| 1093 | "<input type=\"num\" name=\"default_uplevel\" size=\"6\" value=\"%s\" /> Down\n", |
|---|
| 1094 | nvram_safe_get("default_uplevel")); |
|---|
| 1095 | websWrite(wp, |
|---|
| 1096 | "<input type=\"num\" name=\"default_downlevel\" size=\"6\" value=\"%s\" />\n", |
|---|
| 1097 | nvram_safe_get("default_downlevel")); |
|---|
| 1098 | websWrite(wp, "</div>\n"); |
|---|
| 1099 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 1100 | return; |
|---|
| 1101 | } |
|---|
| 1102 | #endif |
|---|
| 1103 | |
|---|
| 1104 | #ifdef HAVE_MADWIFI |
|---|
| 1105 | struct wifi_channels { |
|---|
| 1106 | int channel; |
|---|
| 1107 | int freq; |
|---|
| 1108 | int noise; |
|---|
| 1109 | }; |
|---|
| 1110 | extern struct wifi_channels *list_channels(char *devnr); |
|---|
| 1111 | extern struct wifi_channels *list_channels_11n(char *devnr); |
|---|
| 1112 | |
|---|
| 1113 | // extern int getchannelcount (void); |
|---|
| 1114 | extern int getdevicecount(void); |
|---|
| 1115 | #endif |
|---|
| 1116 | |
|---|
| 1117 | static char *selmatch(char *var, char *is, char *ret) |
|---|
| 1118 | { |
|---|
| 1119 | if (nvram_match(var, is)) |
|---|
| 1120 | return ret; |
|---|
| 1121 | return ""; |
|---|
| 1122 | } |
|---|
| 1123 | |
|---|
| 1124 | static void |
|---|
| 1125 | show_security_prefix(webs_t wp, int argc, char_t ** argv, char *prefix, |
|---|
| 1126 | int primary) |
|---|
| 1127 | { |
|---|
| 1128 | static char var[80]; |
|---|
| 1129 | static char sta[80]; |
|---|
| 1130 | |
|---|
| 1131 | // char p2[80]; |
|---|
| 1132 | cprintf("show security prefix\n"); |
|---|
| 1133 | sprintf(var, "%s_security_mode", prefix); |
|---|
| 1134 | // strcpy(p2,prefix); |
|---|
| 1135 | // rep(p2,'X','.'); |
|---|
| 1136 | // websWrite (wp, "<input type=\"hidden\" |
|---|
| 1137 | // name=\"%s_security_mode\"/>\n",p2); |
|---|
| 1138 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1139 | websWrite(wp, |
|---|
| 1140 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.secmode)</script></div>\n"); |
|---|
| 1141 | websWrite(wp, |
|---|
| 1142 | "<select name=\"%s_security_mode\" onchange=\"SelMode('%s_security_mode',this.form.%s_security_mode.selectedIndex,this.form)\">\n", |
|---|
| 1143 | prefix, prefix, prefix); |
|---|
| 1144 | websWrite(wp, |
|---|
| 1145 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"disabled\\\" %s >\" + share.disabled + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 1146 | selmatch(var, "disabled", "selected=\\\"selected\\\"")); |
|---|
| 1147 | websWrite(wp, "<option value=\"psk\" %s>WPA Personal</option>\n", |
|---|
| 1148 | selmatch(var, "psk", "selected=\"selected\"")); |
|---|
| 1149 | sprintf(sta, "%s_mode", prefix); |
|---|
| 1150 | if (!primary || nvram_match(sta, "ap") || nvram_match(sta, "wdsap")) { |
|---|
| 1151 | websWrite(wp, |
|---|
| 1152 | "<option value=\"wpa\" %s>WPA Enterprise</option>\n", |
|---|
| 1153 | selmatch(var, "wpa", "selected=\"selected\"")); |
|---|
| 1154 | } |
|---|
| 1155 | websWrite(wp, "<option value=\"psk2\" %s>WPA2 Personal</option>\n", |
|---|
| 1156 | selmatch(var, "psk2", "selected=\"selected\"")); |
|---|
| 1157 | if (!primary || nvram_match(sta, "ap") || nvram_match(sta, "wdsap")) { |
|---|
| 1158 | websWrite(wp, |
|---|
| 1159 | "<option value=\"wpa2\" %s>WPA2 Enterprise</option>\n", |
|---|
| 1160 | selmatch(var, "wpa2", "selected=\"selected\"")); |
|---|
| 1161 | } |
|---|
| 1162 | #ifdef HAVE_RT2880 |
|---|
| 1163 | if (!primary || nvram_match(sta, "ap")) |
|---|
| 1164 | #endif |
|---|
| 1165 | websWrite(wp, |
|---|
| 1166 | "<option value=\"psk psk2\" %s>WPA2 Personal Mixed</option>\n", |
|---|
| 1167 | selmatch(var, "psk psk2", "selected=\"selected\"")); |
|---|
| 1168 | |
|---|
| 1169 | if (!primary || nvram_match(sta, "ap") || nvram_match(sta, "wdsap")) { |
|---|
| 1170 | websWrite(wp, |
|---|
| 1171 | "<option value=\"wpa wpa2\" %s>WPA2 Enterprise Mixed</option>\n", |
|---|
| 1172 | selmatch(var, "wpa wpa2", "selected=\"selected\"")); |
|---|
| 1173 | |
|---|
| 1174 | websWrite(wp, "<option value=\"radius\" %s>RADIUS</option>\n", |
|---|
| 1175 | selmatch(var, "radius", "selected=\"selected\"")); |
|---|
| 1176 | } |
|---|
| 1177 | |
|---|
| 1178 | websWrite(wp, "<option value=\"wep\" %s>WEP</option>\n", |
|---|
| 1179 | selmatch(var, "wep", "selected=\"selected\"")); |
|---|
| 1180 | #ifdef HAVE_WPA_SUPPLICANT |
|---|
| 1181 | #ifndef HAVE_MICRO |
|---|
| 1182 | #ifndef HAVE_RT2880 |
|---|
| 1183 | if (!primary || nvram_match(sta, "sta") || nvram_match(sta, "wdssta") |
|---|
| 1184 | || nvram_match(sta, "apsta") || nvram_match(sta, "wet")) { |
|---|
| 1185 | websWrite(wp, "<option value=\"8021X\" %s>802.1x</option>\n", |
|---|
| 1186 | selmatch(var, "8021X", "selected=\"selected\"")); |
|---|
| 1187 | } |
|---|
| 1188 | #else |
|---|
| 1189 | if (nvram_match(sta, "sta") || nvram_match(sta, "wet")) { |
|---|
| 1190 | websWrite(wp, "<option value=\"8021X\" %s>802.1x</option>\n", |
|---|
| 1191 | selmatch(var, "8021X", "selected=\"selected\"")); |
|---|
| 1192 | } |
|---|
| 1193 | #endif |
|---|
| 1194 | #endif |
|---|
| 1195 | #endif |
|---|
| 1196 | |
|---|
| 1197 | websWrite(wp, "</select></div>\n"); |
|---|
| 1198 | rep(prefix, 'X', '.'); |
|---|
| 1199 | cprintf("ej show wpa\n"); |
|---|
| 1200 | ej_show_wpa_setting(wp, argc, argv, prefix); |
|---|
| 1201 | |
|---|
| 1202 | } |
|---|
| 1203 | |
|---|
| 1204 | static void |
|---|
| 1205 | ej_show_security_single(webs_t wp, int argc, char_t ** argv, char *prefix) |
|---|
| 1206 | { |
|---|
| 1207 | char *next; |
|---|
| 1208 | char var[80]; |
|---|
| 1209 | char ssid[80]; |
|---|
| 1210 | char mac[16]; |
|---|
| 1211 | |
|---|
| 1212 | sprintf(mac, "%s_hwaddr", prefix); |
|---|
| 1213 | char *vifs = nvram_nget("%s_vifs", prefix); |
|---|
| 1214 | |
|---|
| 1215 | if (vifs == NULL) |
|---|
| 1216 | return; |
|---|
| 1217 | sprintf(ssid, "%s_ssid", prefix); |
|---|
| 1218 | websWrite(wp, |
|---|
| 1219 | "<h2><script type=\"text/javascript\">Capture(wpa.h2)</script> %s</h2>\n", |
|---|
| 1220 | prefix); |
|---|
| 1221 | websWrite(wp, "<fieldset>\n"); |
|---|
| 1222 | // cprintf("getting %s %s\n",ssid,nvram_safe_get(ssid)); |
|---|
| 1223 | websWrite(wp, |
|---|
| 1224 | "<legend><script type=\"text/javascript\">Capture(share.pintrface)</script> %s SSID [", |
|---|
| 1225 | IFMAP(prefix)); |
|---|
| 1226 | tf_webWriteESCNV(wp, ssid); // fix for broken html page if ssid |
|---|
| 1227 | // contains html tag |
|---|
| 1228 | websWrite(wp, "] HWAddr [%s]</legend>\n", nvram_safe_get(mac)); |
|---|
| 1229 | show_security_prefix(wp, argc, argv, prefix, 1); |
|---|
| 1230 | websWrite(wp, "</fieldset>\n<br />\n"); |
|---|
| 1231 | foreach(var, vifs, next) { |
|---|
| 1232 | sprintf(ssid, "%s_ssid", var); |
|---|
| 1233 | websWrite(wp, "<fieldset>\n"); |
|---|
| 1234 | // cprintf("getting %s %s\n", ssid,nvram_safe_get(ssid)); |
|---|
| 1235 | websWrite(wp, |
|---|
| 1236 | "<legend><script type=\"text/javascript\">Capture(share.vintrface)</script> %s SSID [", |
|---|
| 1237 | IFMAP(var)); |
|---|
| 1238 | tf_webWriteESCNV(wp, ssid); // fix for broken html page if ssid |
|---|
| 1239 | // contains html tag |
|---|
| 1240 | websWrite(wp, "]</legend>\n"); |
|---|
| 1241 | rep(var, '.', 'X'); |
|---|
| 1242 | show_security_prefix(wp, argc, argv, var, 0); |
|---|
| 1243 | websWrite(wp, "</fieldset>\n<br />\n"); |
|---|
| 1244 | } |
|---|
| 1245 | |
|---|
| 1246 | } |
|---|
| 1247 | |
|---|
| 1248 | void ej_show_security(webs_t wp, int argc, char_t ** argv) |
|---|
| 1249 | { |
|---|
| 1250 | #ifndef HAVE_MADWIFI |
|---|
| 1251 | int c = get_wl_instances(); |
|---|
| 1252 | int i; |
|---|
| 1253 | |
|---|
| 1254 | for (i = 0; i < c; i++) { |
|---|
| 1255 | char buf[16]; |
|---|
| 1256 | |
|---|
| 1257 | sprintf(buf, "wl%d", i); |
|---|
| 1258 | ej_show_security_single(wp, argc, argv, buf); |
|---|
| 1259 | } |
|---|
| 1260 | return; |
|---|
| 1261 | #else |
|---|
| 1262 | int c = getdevicecount(); |
|---|
| 1263 | int i; |
|---|
| 1264 | |
|---|
| 1265 | for (i = 0; i < c; i++) { |
|---|
| 1266 | char buf[16]; |
|---|
| 1267 | |
|---|
| 1268 | sprintf(buf, "ath%d", i); |
|---|
| 1269 | ej_show_security_single(wp, argc, argv, buf); |
|---|
| 1270 | } |
|---|
| 1271 | return; |
|---|
| 1272 | #endif |
|---|
| 1273 | } |
|---|
| 1274 | |
|---|
| 1275 | void ej_show_dhcpd_settings(webs_t wp, int argc, char_t ** argv) |
|---|
| 1276 | { |
|---|
| 1277 | int i; |
|---|
| 1278 | |
|---|
| 1279 | if (getWET()) // dhcpd settings disabled in client bridge mode, so we wont display it |
|---|
| 1280 | return; |
|---|
| 1281 | |
|---|
| 1282 | websWrite(wp, |
|---|
| 1283 | "<fieldset><legend><script type=\"text/javascript\">Capture(idx.dhcp_legend)</script></legend>\n"); |
|---|
| 1284 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1285 | websWrite(wp, |
|---|
| 1286 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_type)</script></div>\n"); |
|---|
| 1287 | websWrite(wp, |
|---|
| 1288 | "<select class=\"num\" size=\"1\" name=\"dhcpfwd_enable\" onchange=SelDHCPFWD(this.form.dhcpfwd_enable.selectedIndex,this.form)>\n"); |
|---|
| 1289 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1290 | websWrite(wp, |
|---|
| 1291 | "document.write(\"<option value=\\\"0\\\" %s >\" + idx.dhcp_srv + \"</option>\");\n", |
|---|
| 1292 | nvram_match("dhcpfwd_enable", |
|---|
| 1293 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1294 | websWrite(wp, |
|---|
| 1295 | "document.write(\"<option value=\\\"1\\\" %s >\" + idx.dhcp_fwd + \"</option>\");\n", |
|---|
| 1296 | nvram_match("dhcpfwd_enable", |
|---|
| 1297 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1298 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 1299 | websWrite(wp, "</select>\n"); |
|---|
| 1300 | websWrite(wp, "</div>\n"); |
|---|
| 1301 | if (nvram_match("dhcpfwd_enable", "1")) { |
|---|
| 1302 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1303 | websWrite(wp, |
|---|
| 1304 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_srv)</script></div>\n"); |
|---|
| 1305 | char *ipfwd = nvram_safe_get("dhcpfwd_ip"); |
|---|
| 1306 | |
|---|
| 1307 | websWrite(wp, |
|---|
| 1308 | "<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", |
|---|
| 1309 | get_single_ip(ipfwd, 0), get_single_ip(ipfwd, 1), |
|---|
| 1310 | get_single_ip(ipfwd, 2), get_single_ip(ipfwd, 3)); |
|---|
| 1311 | } else { |
|---|
| 1312 | char buf[20]; |
|---|
| 1313 | |
|---|
| 1314 | prefix_ip_get("lan_ipaddr", buf, 1); |
|---|
| 1315 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1316 | // char *nv = nvram_safe_get ("wan_wins"); |
|---|
| 1317 | websWrite(wp, |
|---|
| 1318 | "<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", |
|---|
| 1319 | nvram_match("lan_proto", |
|---|
| 1320 | "dhcp") ? "checked=\"checked\"" : ""); |
|---|
| 1321 | websWrite(wp, |
|---|
| 1322 | "<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", |
|---|
| 1323 | nvram_match("lan_proto", |
|---|
| 1324 | "static") ? "checked=\"checked\"" : ""); |
|---|
| 1325 | websWrite(wp, |
|---|
| 1326 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_start)</script></div>%s", |
|---|
| 1327 | buf); |
|---|
| 1328 | websWrite(wp, |
|---|
| 1329 | "<input class=\"num\" name=\"dhcp_start\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,1,254,idx.dhcp_start)\" value=\"%s\" />", |
|---|
| 1330 | nvram_safe_get("dhcp_start")); |
|---|
| 1331 | websWrite(wp, "</div>\n"); |
|---|
| 1332 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1333 | websWrite(wp, |
|---|
| 1334 | "<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", |
|---|
| 1335 | nvram_safe_get("dhcp_num")); |
|---|
| 1336 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1337 | websWrite(wp, |
|---|
| 1338 | "<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", |
|---|
| 1339 | nvram_safe_get("dhcp_lease")); |
|---|
| 1340 | if (nvram_invmatch("wan_proto", "static")) { |
|---|
| 1341 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1342 | websWrite(wp, |
|---|
| 1343 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 1</div>"); |
|---|
| 1344 | websWrite(wp, |
|---|
| 1345 | "<input type=\"hidden\" name=\"wan_dns\" value=\"4\" />"); |
|---|
| 1346 | for (i = 0; i < 4; i++) |
|---|
| 1347 | websWrite(wp, |
|---|
| 1348 | "<input class=\"num\" name=\"wan_dns0_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1349 | i, i == 3 ? 254 : 255, |
|---|
| 1350 | get_dns_ip("wan_dns", 0, i), |
|---|
| 1351 | i < 3 ? "." : ""); |
|---|
| 1352 | |
|---|
| 1353 | websWrite(wp, "\n</div>\n<div class=\"setting\">\n"); |
|---|
| 1354 | websWrite(wp, |
|---|
| 1355 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 2</div>"); |
|---|
| 1356 | for (i = 0; i < 4; i++) |
|---|
| 1357 | websWrite(wp, |
|---|
| 1358 | "<input class=\"num\" name=\"wan_dns1_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1359 | i, i == 3 ? 254 : 255, |
|---|
| 1360 | get_dns_ip("wan_dns", 1, i), |
|---|
| 1361 | i < 3 ? "." : ""); |
|---|
| 1362 | |
|---|
| 1363 | websWrite(wp, "\n</div>\n<div class=\"setting\">\n"); |
|---|
| 1364 | websWrite(wp, |
|---|
| 1365 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 3</div>"); |
|---|
| 1366 | for (i = 0; i < 4; i++) |
|---|
| 1367 | websWrite(wp, |
|---|
| 1368 | "<input class=\"num\" name=\"wan_dns2_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1369 | i, i == 3 ? 254 : 255, |
|---|
| 1370 | get_dns_ip("wan_dns", 2, i), |
|---|
| 1371 | i < 3 ? "." : ""); |
|---|
| 1372 | websWrite(wp, "\n</div>"); |
|---|
| 1373 | } |
|---|
| 1374 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1375 | websWrite(wp, "<div class=\"label\">WINS</div>\n"); |
|---|
| 1376 | websWrite(wp, |
|---|
| 1377 | "<input type=\"hidden\" name=\"wan_wins\" value=\"4\" />\n"); |
|---|
| 1378 | char *wins = nvram_safe_get("wan_wins"); |
|---|
| 1379 | |
|---|
| 1380 | for (i = 0; i < 4; i++) { |
|---|
| 1381 | websWrite(wp, |
|---|
| 1382 | "<input class=\"num\" name=\"wan_wins_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,"WINS")\" value=\"%d\" />%s", |
|---|
| 1383 | i, i == 3 ? 254 : 255, get_single_ip(wins, i), |
|---|
| 1384 | i < 3 ? "." : ""); |
|---|
| 1385 | } |
|---|
| 1386 | |
|---|
| 1387 | websWrite(wp, "</div>\n<div class=\"setting\">\n"); |
|---|
| 1388 | websWrite(wp, |
|---|
| 1389 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_dnsmasq)</script></div>\n"); |
|---|
| 1390 | websWrite(wp, |
|---|
| 1391 | "<input type=\"checkbox\" name=\"_dhcp_dnsmasq\" value=\"1\" onclick=\"setDNSMasq(this.form)\" %s />\n", |
|---|
| 1392 | nvram_match("dhcp_dnsmasq", |
|---|
| 1393 | "1") ? "checked=\"checked\"" : ""); |
|---|
| 1394 | websWrite(wp, "</div>\n<div class=\"setting\">\n"); |
|---|
| 1395 | websWrite(wp, |
|---|
| 1396 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dns_dnsmasq)</script></div>\n"); |
|---|
| 1397 | websWrite(wp, |
|---|
| 1398 | "<input type=\"checkbox\" name=\"_dns_dnsmasq\" value=\"1\" %s />\n", |
|---|
| 1399 | nvram_match("dns_dnsmasq", |
|---|
| 1400 | "1") ? "checked=\"checked\"" : ""); |
|---|
| 1401 | websWrite(wp, "</div>\n<div class=\"setting\">\n"); |
|---|
| 1402 | websWrite(wp, |
|---|
| 1403 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.auth_dnsmasq)</script></div>\n"); |
|---|
| 1404 | websWrite(wp, |
|---|
| 1405 | "<input type=\"checkbox\" name=\"_auth_dnsmasq\" value=\"1\" %s />\n", |
|---|
| 1406 | nvram_match("auth_dnsmasq", |
|---|
| 1407 | "1") ? "checked=\"checked\"" : ""); |
|---|
| 1408 | websWrite(wp, "</div>\n"); |
|---|
| 1409 | } |
|---|
| 1410 | |
|---|
| 1411 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 1412 | return; |
|---|
| 1413 | } |
|---|
| 1414 | |
|---|
| 1415 | #ifdef HAVE_MADWIFI |
|---|
| 1416 | void ej_show_wifiselect(webs_t wp, int argc, char_t ** argv) |
|---|
| 1417 | { |
|---|
| 1418 | char *next; |
|---|
| 1419 | char var[32]; |
|---|
| 1420 | int count = getifcount("wifi"); |
|---|
| 1421 | |
|---|
| 1422 | if (count < 2) |
|---|
| 1423 | return; |
|---|
| 1424 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1425 | websWrite(wp, |
|---|
| 1426 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.intrface)</script></div>\n"); |
|---|
| 1427 | websWrite(wp, |
|---|
| 1428 | "<select name=\"wifi_display\" onchange=\"refresh(this.form)\">\n"); |
|---|
| 1429 | int i; |
|---|
| 1430 | |
|---|
| 1431 | for (i = 0; i < count; i++) { |
|---|
| 1432 | sprintf(var, "ath%d", i); |
|---|
| 1433 | websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 1434 | var, nvram_match("wifi_display", |
|---|
| 1435 | var) ? "selected=\"selected\"" : "", |
|---|
| 1436 | var); |
|---|
| 1437 | char *names = nvram_nget("ath%d_vifs", i); |
|---|
| 1438 | |
|---|
| 1439 | foreach(var, names, next) { |
|---|
| 1440 | websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 1441 | var, nvram_match("wifi_display", |
|---|
| 1442 | var) ? |
|---|
| 1443 | "selected=\"selected\"" : "", var); |
|---|
| 1444 | } |
|---|
| 1445 | } |
|---|
| 1446 | websWrite(wp, "</select>\n"); |
|---|
| 1447 | websWrite(wp, "</div>\n"); |
|---|
| 1448 | |
|---|
| 1449 | } |
|---|
| 1450 | #else |
|---|
| 1451 | void ej_show_wifiselect(webs_t wp, int argc, char_t ** argv) |
|---|
| 1452 | { |
|---|
| 1453 | char *next; |
|---|
| 1454 | char var[32]; |
|---|
| 1455 | int count = get_wl_instances(); |
|---|
| 1456 | |
|---|
| 1457 | if (count < 2) |
|---|
| 1458 | return; |
|---|
| 1459 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1460 | websWrite(wp, |
|---|
| 1461 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.intrface)</script></div>\n"); |
|---|
| 1462 | websWrite(wp, |
|---|
| 1463 | "<select name=\"wifi_display\" onchange=\"refresh(this.form)\">\n"); |
|---|
| 1464 | int i; |
|---|
| 1465 | |
|---|
| 1466 | for (i = 0; i < count; i++) { |
|---|
| 1467 | sprintf(var, "wl%d", i); |
|---|
| 1468 | websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 1469 | var, nvram_match("wifi_display", |
|---|
| 1470 | var) ? "selected=\"selected\"" : "", |
|---|
| 1471 | var); |
|---|
| 1472 | } |
|---|
| 1473 | websWrite(wp, "</select>\n"); |
|---|
| 1474 | websWrite(wp, "</div>\n"); |
|---|
| 1475 | } |
|---|
| 1476 | |
|---|
| 1477 | #endif |
|---|
| 1478 | #if 0 |
|---|
| 1479 | static void showOption(webs_t wp, char *propname, char *nvname) |
|---|
| 1480 | { |
|---|
| 1481 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1482 | websWrite(wp, |
|---|
| 1483 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n<select name=\"%s\">\n", |
|---|
| 1484 | propname, nvname); |
|---|
| 1485 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1486 | websWrite(wp, |
|---|
| 1487 | "document.write(\"<option value=\\\"0\\\" %s >\" + share.disabled + \"</option>\");\n", |
|---|
| 1488 | nvram_default_match(nvname, "0", |
|---|
| 1489 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1490 | websWrite(wp, |
|---|
| 1491 | "document.write(\"<option value=\\\"1\\\" %s >\" + share.enabled + \"</option>\");\n", |
|---|
| 1492 | nvram_default_match(nvname, "1", |
|---|
| 1493 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1494 | websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 1495 | |
|---|
| 1496 | } |
|---|
| 1497 | #endif |
|---|
| 1498 | static void showRadio(webs_t wp, char *propname, char *nvname) |
|---|
| 1499 | { |
|---|
| 1500 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1501 | websWrite(wp, |
|---|
| 1502 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n", |
|---|
| 1503 | propname); |
|---|
| 1504 | websWrite(wp, |
|---|
| 1505 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input> \n", |
|---|
| 1506 | nvname, nvram_default_match(nvname, "1", |
|---|
| 1507 | "0") ? "checked=\"checked\"" : |
|---|
| 1508 | ""); |
|---|
| 1509 | websWrite(wp, |
|---|
| 1510 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input> \n", |
|---|
| 1511 | nvname, nvram_default_match(nvname, "0", |
|---|
| 1512 | "0") ? "checked=\"checked\"" : |
|---|
| 1513 | ""); |
|---|
| 1514 | websWrite(wp, "</div>\n"); |
|---|
| 1515 | } |
|---|
| 1516 | |
|---|
| 1517 | #ifdef HAVE_MADWIFI |
|---|
| 1518 | static void showAutoOption(webs_t wp, char *propname, char *nvname) |
|---|
| 1519 | { |
|---|
| 1520 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1521 | websWrite(wp, |
|---|
| 1522 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n<select name=\"%s\">\n", |
|---|
| 1523 | propname, nvname); |
|---|
| 1524 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1525 | websWrite(wp, |
|---|
| 1526 | "document.write(\"<option value=\\\"-1\\\" %s >\" + share.auto + \"</option>\");\n", |
|---|
| 1527 | nvram_default_match(nvname, "0", |
|---|
| 1528 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1529 | websWrite(wp, |
|---|
| 1530 | "document.write(\"<option value=\\\"1\\\" %s >\" + share.enabled + \"</option>\");\n", |
|---|
| 1531 | nvram_default_match(nvname, "1", |
|---|
| 1532 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1533 | websWrite(wp, |
|---|
| 1534 | "document.write(\"<option value=\\\"0\\\" %s >\" + share.disabled + \"</option>\");\n", |
|---|
| 1535 | nvram_default_match(nvname, "0", |
|---|
| 1536 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1537 | websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 1538 | |
|---|
| 1539 | } |
|---|
| 1540 | #endif |
|---|
| 1541 | |
|---|
| 1542 | static void showOptions(webs_t wp, char *propname, char *names, char *select) |
|---|
| 1543 | { |
|---|
| 1544 | char *next; |
|---|
| 1545 | char var[80]; |
|---|
| 1546 | |
|---|
| 1547 | websWrite(wp, "<select name=\"%s\">\n", propname); |
|---|
| 1548 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1549 | foreach(var, names, next) { |
|---|
| 1550 | websWrite(wp, |
|---|
| 1551 | "document.write(\"<option value=\\\"%s\\\" %s >%s</option>\");\n", |
|---|
| 1552 | var, !strcmp(var, |
|---|
| 1553 | select) ? "selected=\\\"selected\\\"" : |
|---|
| 1554 | "", var); |
|---|
| 1555 | } |
|---|
| 1556 | websWrite(wp, "//]]>\n</script>\n</select>\n"); |
|---|
| 1557 | } |
|---|
| 1558 | |
|---|
| 1559 | static void |
|---|
| 1560 | showOptionsChoose(webs_t wp, char *propname, char *names, char *select) |
|---|
| 1561 | { |
|---|
| 1562 | char *next; |
|---|
| 1563 | char var[80]; |
|---|
| 1564 | |
|---|
| 1565 | websWrite(wp, "<select name=\"%s\">\n", propname); |
|---|
| 1566 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1567 | websWrite(wp, |
|---|
| 1568 | "document.write(\"<option value=\\\"null\\\" >Please choose...</option>\");\n"); |
|---|
| 1569 | foreach(var, names, next) { |
|---|
| 1570 | websWrite(wp, |
|---|
| 1571 | "document.write(\"<option value=\\\"%s\\\" %s >%s</option>\");\n", |
|---|
| 1572 | var, !strcmp(var, |
|---|
| 1573 | select) ? "selected=\\\"selected\\\"" : |
|---|
| 1574 | "", var); |
|---|
| 1575 | } |
|---|
| 1576 | websWrite(wp, "//]]>\n</script>\n</select>\n"); |
|---|
| 1577 | } |
|---|
| 1578 | |
|---|
| 1579 | static void |
|---|
| 1580 | showOptionsLabel(webs_t wp, char *labelname, char *propname, char *names, |
|---|
| 1581 | char *select) |
|---|
| 1582 | { |
|---|
| 1583 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1584 | websWrite(wp, |
|---|
| 1585 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>", |
|---|
| 1586 | labelname); |
|---|
| 1587 | showOptions(wp, propname, names, select); |
|---|
| 1588 | websWrite(wp, "</div>\n"); |
|---|
| 1589 | |
|---|
| 1590 | } |
|---|
| 1591 | |
|---|
| 1592 | void |
|---|
| 1593 | show_inputlabel(webs_t wp, char *labelname, char *propertyname, |
|---|
| 1594 | int propertysize, char *inputclassname, int inputmaxlength) |
|---|
| 1595 | { |
|---|
| 1596 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1597 | websWrite(wp, |
|---|
| 1598 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>", |
|---|
| 1599 | labelname); |
|---|
| 1600 | websWrite(wp, |
|---|
| 1601 | "<input class=\"%s\" size=\"%d\" maxlength=\"%d\" name=\"%s\" value=\"%s\" />\n", |
|---|
| 1602 | inputclassname, propertysize, inputmaxlength, propertyname, |
|---|
| 1603 | nvram_safe_get(propertyname)); |
|---|
| 1604 | websWrite(wp, "</div>\n"); |
|---|
| 1605 | } |
|---|
| 1606 | |
|---|
| 1607 | void |
|---|
| 1608 | show_custominputlabel(webs_t wp, char *labelname, char *propertyname, |
|---|
| 1609 | char *property, int propertysize) |
|---|
| 1610 | { |
|---|
| 1611 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1612 | websWrite(wp, "<div class=\"label\">%s</div>", labelname); |
|---|
| 1613 | websWrite(wp, "<input size=\"%d\" name=\"%s\" value=\"%s\" />\n", |
|---|
| 1614 | propertysize, propertyname, property); |
|---|
| 1615 | websWrite(wp, "</div>\n"); |
|---|
| 1616 | } |
|---|
| 1617 | |
|---|
| 1618 | #ifdef HAVE_USB |
|---|
| 1619 | void ej_show_usb_diskinfo(webs_t wp, int argc, char_t ** argv) |
|---|
| 1620 | { |
|---|
| 1621 | char buff[512]; |
|---|
| 1622 | FILE *fp; |
|---|
| 1623 | |
|---|
| 1624 | if (!nvram_match("usb_automnt", "1")) |
|---|
| 1625 | return; |
|---|
| 1626 | |
|---|
| 1627 | if ((fp = fopen("/tmp/disktype.dump", "r"))) { |
|---|
| 1628 | while (fgets(buff, sizeof(buff), fp)) { |
|---|
| 1629 | if (strcmp(buff, "\n")) |
|---|
| 1630 | websWrite(wp, "%s<br />", buff); |
|---|
| 1631 | } |
|---|
| 1632 | fclose(fp); |
|---|
| 1633 | } else |
|---|
| 1634 | websWrite(wp, "%s", live_translate("status_router.notavail")); |
|---|
| 1635 | |
|---|
| 1636 | return; |
|---|
| 1637 | } |
|---|
| 1638 | #endif |
|---|
| 1639 | |
|---|
| 1640 | #ifdef HAVE_MMC |
|---|
| 1641 | void ej_show_mmc_cardinfo(webs_t wp, int argc, char_t ** argv) |
|---|
| 1642 | { |
|---|
| 1643 | char buff[512]; |
|---|
| 1644 | FILE *fp; |
|---|
| 1645 | |
|---|
| 1646 | if (!nvram_match("mmc_enable0", "1")) |
|---|
| 1647 | return; |
|---|
| 1648 | |
|---|
| 1649 | if ((fp = fopen("/proc/mmc/status", "rb"))) { |
|---|
| 1650 | while (fgets(buff, sizeof(buff), fp)) { |
|---|
| 1651 | if (strcmp(buff, "\n")) |
|---|
| 1652 | websWrite(wp, "%s<br />", buff); |
|---|
| 1653 | } |
|---|
| 1654 | fclose(fp); |
|---|
| 1655 | } else |
|---|
| 1656 | websWrite(wp, "%s", live_translate("status_router.notavail")); |
|---|
| 1657 | |
|---|
| 1658 | return; |
|---|
| 1659 | } |
|---|
| 1660 | #endif |
|---|
| 1661 | |
|---|
| 1662 | void show_legend(webs_t wp, char *labelname, int translate) |
|---|
| 1663 | { |
|---|
| 1664 | /* |
|---|
| 1665 | * char buf[2]; sprintf(buf,"%d",translate); websWrite (wp, |
|---|
| 1666 | * "<legend>%s%s%s</legend>\n", !strcmp (buf, "1") ? "<script |
|---|
| 1667 | * type=\"text/javascript\">Capture(" : "", labelname, !strcmp (buf, "1") |
|---|
| 1668 | * ? ")</script>" : ""); |
|---|
| 1669 | */ |
|---|
| 1670 | if (translate) |
|---|
| 1671 | websWrite(wp, |
|---|
| 1672 | "<legend><script type=\"text/javascript\">Capture(%s)</script></legend>\n", |
|---|
| 1673 | labelname); |
|---|
| 1674 | else |
|---|
| 1675 | websWrite(wp, "<legend>%s</legend>\n", labelname); |
|---|
| 1676 | |
|---|
| 1677 | } |
|---|
| 1678 | |
|---|
| 1679 | #ifdef HAVE_OLSRD |
|---|
| 1680 | |
|---|
| 1681 | void ej_show_olsrd(webs_t wp, int argc, char_t ** argv) |
|---|
| 1682 | { |
|---|
| 1683 | char *var = websGetVar(wp, "wk_mode", NULL); |
|---|
| 1684 | |
|---|
| 1685 | if (var == NULL) |
|---|
| 1686 | var = nvram_safe_get("wk_mode"); |
|---|
| 1687 | if (!strcmp(var, "olsr")) { |
|---|
| 1688 | websWrite(wp, "<fieldset>\n"); |
|---|
| 1689 | show_legend(wp, "route.olsrd_legend", 1); |
|---|
| 1690 | websWrite(wp,"<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_gateway)</script></div>\n"); |
|---|
| 1691 | websWrite(wp,"<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"olsrd_gateway\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input>\n",nvram_default_match("olsrd_gateway", "1","0") ? "checked=\"checked\"" :""); |
|---|
| 1692 | websWrite(wp,"<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"olsrd_gateway\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input> \n", nvram_default_match("olsrd_gateway", "0","0") ? "checked=\"checked\"" :""); |
|---|
| 1693 | websWrite(wp, "</div>\n"); |
|---|
| 1694 | |
|---|
| 1695 | |
|---|
| 1696 | show_inputlabel(wp, "route.olsrd_hna", "olsrd_hna", 32, "num", |
|---|
| 1697 | 32); |
|---|
| 1698 | show_inputlabel(wp, "route.olsrd_poll", "olsrd_pollsize", 5, |
|---|
| 1699 | "num", 5); |
|---|
| 1700 | showOptionsLabel(wp, "route.olsrd_tc", "olsrd_redundancy", |
|---|
| 1701 | "0 1 2", nvram_default_get("olsrd_redundancy", |
|---|
| 1702 | "2")); |
|---|
| 1703 | show_inputlabel(wp, "route.olsrd_mpr", "olsrd_coverage", 5, |
|---|
| 1704 | "num", 5); |
|---|
| 1705 | showRadio(wp, "route.olsrd_lqfe", "olsrd_lqfisheye"); |
|---|
| 1706 | show_inputlabel(wp, "route.olsrd_lqag", "olsrd_lqaging", 5, |
|---|
| 1707 | "num", 5); |
|---|
| 1708 | |
|---|
| 1709 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1710 | websWrite(wp, |
|---|
| 1711 | "<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_lqdmin)</script></div>"); |
|---|
| 1712 | websWrite(wp, |
|---|
| 1713 | "<input class=\"num\" size=\"5\" maxlength=\"5\" name=\"olsrd_lqdijkstramin\" onblur=\"olsrd_checkDijkstra(this.form)\" value=\"%s\" />\n", |
|---|
| 1714 | nvram_safe_get("olsrd_lqdijkstramin")); |
|---|
| 1715 | websWrite(wp, "</div>\n"); |
|---|
| 1716 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1717 | websWrite(wp, |
|---|
| 1718 | "<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_lqdmax)</script></div>"); |
|---|
| 1719 | websWrite(wp, |
|---|
| 1720 | "<input class=\"num\" size=\"5\" maxlength=\"5\" name=\"olsrd_lqdijkstramax\" onblur=\"olsrd_checkDijkstra(this.form)\" value=\"%s\" />\n", |
|---|
| 1721 | nvram_safe_get("olsrd_lqdijkstramax")); |
|---|
| 1722 | websWrite(wp, "</div>\n"); |
|---|
| 1723 | |
|---|
| 1724 | showOptionsLabel(wp, "route.olsrd_lqlvl", "olsrd_lqlevel", |
|---|
| 1725 | "0 1 2", nvram_default_get("olsrd_lqlevel", |
|---|
| 1726 | "2")); |
|---|
| 1727 | showRadio(wp, "route.olsrd_hysteresis", "olsrd_hysteresis"); |
|---|
| 1728 | char *wordlist = nvram_safe_get("olsrd_interfaces"); |
|---|
| 1729 | char *next; |
|---|
| 1730 | char word[128]; |
|---|
| 1731 | int count = 0; |
|---|
| 1732 | |
|---|
| 1733 | foreach(word, wordlist, next) { |
|---|
| 1734 | char *interface = word; |
|---|
| 1735 | char *hellointerval = interface; |
|---|
| 1736 | |
|---|
| 1737 | strsep(&hellointerval, ">"); |
|---|
| 1738 | char *hellovaliditytime = hellointerval; |
|---|
| 1739 | |
|---|
| 1740 | strsep(&hellovaliditytime, ">"); |
|---|
| 1741 | char *tcinterval = hellovaliditytime; |
|---|
| 1742 | |
|---|
| 1743 | strsep(&tcinterval, ">"); |
|---|
| 1744 | char *tcvaliditytime = tcinterval; |
|---|
| 1745 | |
|---|
| 1746 | strsep(&tcvaliditytime, ">"); |
|---|
| 1747 | char *midinterval = tcvaliditytime; |
|---|
| 1748 | |
|---|
| 1749 | strsep(&midinterval, ">"); |
|---|
| 1750 | char *midvaliditytime = midinterval; |
|---|
| 1751 | |
|---|
| 1752 | strsep(&midvaliditytime, ">"); |
|---|
| 1753 | char *hnainterval = midvaliditytime; |
|---|
| 1754 | |
|---|
| 1755 | strsep(&hnainterval, ">"); |
|---|
| 1756 | char *hnavaliditytime = hnainterval; |
|---|
| 1757 | |
|---|
| 1758 | strsep(&hnavaliditytime, ">"); |
|---|
| 1759 | websWrite(wp, "<fieldset>\n"); |
|---|
| 1760 | show_legend(wp, interface, 0); |
|---|
| 1761 | char valuename[32]; |
|---|
| 1762 | |
|---|
| 1763 | sprintf(valuename, "%s_hellointerval", interface); |
|---|
| 1764 | show_custominputlabel(wp, "Hello Interval", valuename, |
|---|
| 1765 | hellointerval, 5); |
|---|
| 1766 | sprintf(valuename, "%s_hellovaliditytime", interface); |
|---|
| 1767 | show_custominputlabel(wp, "Hello Validity Time", |
|---|
| 1768 | valuename, hellovaliditytime, 5); |
|---|
| 1769 | |
|---|
| 1770 | sprintf(valuename, "%s_tcinterval", interface); |
|---|
| 1771 | show_custominputlabel(wp, "TC Interval", valuename, |
|---|
| 1772 | tcinterval, 5); |
|---|
| 1773 | sprintf(valuename, "%s_tcvaliditytime", interface); |
|---|
| 1774 | show_custominputlabel(wp, "TC Validity Time", valuename, |
|---|
| 1775 | tcvaliditytime, 5); |
|---|
| 1776 | |
|---|
| 1777 | sprintf(valuename, "%s_midinterval", interface); |
|---|
| 1778 | show_custominputlabel(wp, "MID Interval", valuename, |
|---|
| 1779 | midinterval, 5); |
|---|
| 1780 | sprintf(valuename, "%s_midvaliditytime", interface); |
|---|
| 1781 | show_custominputlabel(wp, "MID Validity Time", |
|---|
| 1782 | valuename, midvaliditytime, 5); |
|---|
| 1783 | |
|---|
| 1784 | sprintf(valuename, "%s_hnainterval", interface); |
|---|
| 1785 | show_custominputlabel(wp, "HNA Interval", valuename, |
|---|
| 1786 | hnainterval, 5); |
|---|
| 1787 | sprintf(valuename, "%s_hnavaliditytime", interface); |
|---|
| 1788 | show_custominputlabel(wp, "HNA Validity Time", |
|---|
| 1789 | valuename, hnavaliditytime, 5); |
|---|
| 1790 | websWrite(wp, |
|---|
| 1791 | "<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", |
|---|
| 1792 | count); |
|---|
| 1793 | |
|---|
| 1794 | websWrite(wp, "</fieldset>\n"); |
|---|
| 1795 | count++; |
|---|
| 1796 | } |
|---|
| 1797 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1798 | websWrite(wp, |
|---|
| 1799 | "<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_newiface)</script></div>\n"); |
|---|
| 1800 | char buffer[256]; |
|---|
| 1801 | |
|---|
| 1802 | memset(buffer, 0, 256); |
|---|
| 1803 | getIfList(buffer, NULL); |
|---|
| 1804 | showOptions(wp, "olsrd_ifname", buffer, ""); |
|---|
| 1805 | websWrite(wp, " "); |
|---|
| 1806 | websWrite(wp, |
|---|
| 1807 | "<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"); |
|---|
| 1808 | websWrite(wp, "</div>\n"); |
|---|
| 1809 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 1810 | } |
|---|
| 1811 | } |
|---|
| 1812 | #else //!HAVE_OLSRD |
|---|
| 1813 | void ej_show_olsrd(webs_t wp, int argc, char_t ** argv) |
|---|
| 1814 | { |
|---|
| 1815 | return; |
|---|
| 1816 | } |
|---|
| 1817 | #endif |
|---|
| 1818 | |
|---|
| 1819 | #ifdef HAVE_VLANTAGGING |
|---|
| 1820 | #ifdef HAVE_BONDING |
|---|
| 1821 | |
|---|
| 1822 | void ej_show_bondings(webs_t wp, int argc, char_t ** argv) |
|---|
| 1823 | { |
|---|
| 1824 | char buffer[256]; |
|---|
| 1825 | char bufferif[512]; |
|---|
| 1826 | char bondnames[256]; |
|---|
| 1827 | int count = 0; |
|---|
| 1828 | static char word[256]; |
|---|
| 1829 | char *next, *wordlist; |
|---|
| 1830 | |
|---|
| 1831 | memset(buffer, 0, 256); |
|---|
| 1832 | memset(bondnames, 0, 256); |
|---|
| 1833 | memset(bufferif, 0, 512); |
|---|
| 1834 | websWrite(wp, "<h2>Bonding</h2>\n"); |
|---|
| 1835 | websWrite(wp, "<fieldset>\n"); |
|---|
| 1836 | websWrite(wp, "<legend>Bonding</legend>\n"); |
|---|
| 1837 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1838 | websWrite(wp, "<div class=\"label\">Bonding Type</div>\n", count); |
|---|
| 1839 | showOptions(wp, "bonding_type", |
|---|
| 1840 | "balance-rr active-backup balance-xor broadcast 802.3ad balance-tlb balance-alb weighted-rr duplex", |
|---|
| 1841 | nvram_default_get("bonding_type", "balance-rr")); |
|---|
| 1842 | websWrite(wp, " Bonding Interfaces "); |
|---|
| 1843 | websWrite(wp, |
|---|
| 1844 | "<input class=\"num\" name=\"bonding_number\"size=\"5\" value=\"%s\" />\n", |
|---|
| 1845 | nvram_default_get("bonding_number", "1")); |
|---|
| 1846 | websWrite(wp, "</div>\n"); |
|---|
| 1847 | |
|---|
| 1848 | getIfList(bufferif, "eth"); |
|---|
| 1849 | int i; |
|---|
| 1850 | |
|---|
| 1851 | #ifdef HAVE_XSCALE |
|---|
| 1852 | memset(buffer, 0, 256); |
|---|
| 1853 | getIfList(buffer, "ixp"); |
|---|
| 1854 | sprintf(bufferif, "%s %s", bufferif, buffer); |
|---|
| 1855 | #endif |
|---|
| 1856 | memset(buffer, 0, 256); |
|---|
| 1857 | getIfList(buffer, "br"); |
|---|
| 1858 | sprintf(bufferif, "%s %s", bufferif, buffer); |
|---|
| 1859 | #ifdef HAVE_MADWIFI |
|---|
| 1860 | int c = getifcount("wifi"); |
|---|
| 1861 | |
|---|
| 1862 | for (i = 0; i < c; i++) { |
|---|
| 1863 | char ath[32]; |
|---|
| 1864 | |
|---|
| 1865 | sprintf(ath, "ath%d_bridged", i); |
|---|
| 1866 | if (nvram_default_match(ath, "0", "1")) { |
|---|
| 1867 | sprintf(bufferif, "%s ath%d", bufferif, i); |
|---|
| 1868 | char vifs[32]; |
|---|
| 1869 | |
|---|
| 1870 | sprintf(vifs, "ath%d_vifs", i); |
|---|
| 1871 | sprintf(bufferif, "%s %s", bufferif, |
|---|
| 1872 | nvram_safe_get(vifs)); |
|---|
| 1873 | } |
|---|
| 1874 | } |
|---|
| 1875 | #endif |
|---|
| 1876 | |
|---|
| 1877 | for (i = 0; i < atoi(nvram_safe_get("bonding_number")); i++) { |
|---|
| 1878 | sprintf(bondnames, "%s bond%d", bondnames, i); |
|---|
| 1879 | } |
|---|
| 1880 | int totalcount = 0; |
|---|
| 1881 | int realcount = atoi(nvram_default_get("bonding_count", "0")); |
|---|
| 1882 | |
|---|
| 1883 | wordlist = nvram_safe_get("bondings"); |
|---|
| 1884 | foreach(word, wordlist, next) { |
|---|
| 1885 | char *port = word; |
|---|
| 1886 | char *tag = strsep(&port, ">"); |
|---|
| 1887 | |
|---|
| 1888 | if (!tag || !port) |
|---|
| 1889 | break; |
|---|
| 1890 | char vlan_name[32]; |
|---|
| 1891 | |
|---|
| 1892 | // sprintf (vlan_name, "%s.%s", tag, port); |
|---|
| 1893 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1894 | websWrite(wp, |
|---|
| 1895 | "<div class=\"label\">Bonding %d Assignment</div>\n", |
|---|
| 1896 | count); |
|---|
| 1897 | websWrite(wp, " Bond "); |
|---|
| 1898 | sprintf(vlan_name, "bondingifname%d", count); |
|---|
| 1899 | showOptions(wp, vlan_name, bondnames, tag); |
|---|
| 1900 | sprintf(vlan_name, "bondingattach%d", count); |
|---|
| 1901 | websWrite(wp, " Slave "); |
|---|
| 1902 | showOptions(wp, vlan_name, bufferif, port); |
|---|
| 1903 | websWrite(wp, |
|---|
| 1904 | "<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", |
|---|
| 1905 | count); |
|---|
| 1906 | websWrite(wp, "</div>\n"); |
|---|
| 1907 | count++; |
|---|
| 1908 | } |
|---|
| 1909 | totalcount = count; |
|---|
| 1910 | for (i = count; i < realcount; i++) { |
|---|
| 1911 | char vlan_name[32]; |
|---|
| 1912 | |
|---|
| 1913 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1914 | websWrite(wp, |
|---|
| 1915 | "<div class=\"label\">Bonding %d Interface</div>\n", |
|---|
| 1916 | i); |
|---|
| 1917 | websWrite(wp, " Bond "); |
|---|
| 1918 | sprintf(vlan_name, "bondingifname%d", i); |
|---|
| 1919 | showOptions(wp, vlan_name, bondnames, ""); |
|---|
| 1920 | sprintf(vlan_name, "bondingattach%d", i); |
|---|
| 1921 | websWrite(wp, " Slave "); |
|---|
| 1922 | showOptions(wp, vlan_name, bufferif, ""); |
|---|
| 1923 | websWrite(wp, |
|---|
| 1924 | "<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", |
|---|
| 1925 | i); |
|---|
| 1926 | websWrite(wp, "</div>\n"); |
|---|
| 1927 | totalcount++; |
|---|
| 1928 | } |
|---|
| 1929 | char var[32]; |
|---|
| 1930 | |
|---|
| 1931 | sprintf(var, "%d", totalcount); |
|---|
| 1932 | nvram_set("bonding_count", var); |
|---|
| 1933 | websWrite(wp, |
|---|
| 1934 | "<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"); |
|---|
| 1935 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 1936 | } |
|---|
| 1937 | #else //!HAVE_BONDING |
|---|
| 1938 | void ej_show_bondings(webs_t wp, int argc, char_t ** argv) |
|---|
| 1939 | { |
|---|
| 1940 | return; |
|---|
| 1941 | } |
|---|
| 1942 | #endif |
|---|
| 1943 | |
|---|
| 1944 | void ej_show_vlantagging(webs_t wp, int argc, char_t ** argv) |
|---|
| 1945 | { |
|---|
| 1946 | char buffer[256]; |
|---|
| 1947 | int count = 0; |
|---|
| 1948 | static char word[256]; |
|---|
| 1949 | char *next, *wordlist; |
|---|
| 1950 | |
|---|
| 1951 | memset(buffer, 0, 256); |
|---|
| 1952 | getIfList(buffer, NULL); |
|---|
| 1953 | int totalcount = 0; |
|---|
| 1954 | int realcount = atoi(nvram_default_get("vlan_tagcount", "0")); |
|---|
| 1955 | |
|---|
| 1956 | wordlist = nvram_safe_get("vlan_tags"); |
|---|
| 1957 | foreach(word, wordlist, next) { |
|---|
| 1958 | |
|---|
| 1959 | char *port = word; |
|---|
| 1960 | char *tag = strsep(&port, ">"); |
|---|
| 1961 | char *prio = port; |
|---|
| 1962 | strsep(&prio, ">"); |
|---|
| 1963 | |
|---|
| 1964 | if (!tag || !port) |
|---|
| 1965 | break; |
|---|
| 1966 | if (!prio) |
|---|
| 1967 | prio = "0"; |
|---|
| 1968 | char vlan_name[32]; |
|---|
| 1969 | |
|---|
| 1970 | // sprintf (vlan_name, "%s.%s", tag, port); |
|---|
| 1971 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1972 | websWrite(wp, "<div class=\"label\">VLAN%d Interface</div>\n", |
|---|
| 1973 | count); |
|---|
| 1974 | sprintf(vlan_name, "vlanifname%d", count); |
|---|
| 1975 | showOptions(wp, vlan_name, buffer, tag); |
|---|
| 1976 | //tag number |
|---|
| 1977 | sprintf(vlan_name, "vlantag%d", count); |
|---|
| 1978 | websWrite(wp, " Tag Number "); |
|---|
| 1979 | websWrite(wp, |
|---|
| 1980 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 1981 | vlan_name, port); |
|---|
| 1982 | //priority |
|---|
| 1983 | sprintf(vlan_name, "vlanprio%d", count); |
|---|
| 1984 | websWrite(wp, " Prio "); |
|---|
| 1985 | showOptions(wp, vlan_name, "0 1 2 3 4 5 6 7", prio); |
|---|
| 1986 | |
|---|
| 1987 | websWrite(wp, |
|---|
| 1988 | "<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", |
|---|
| 1989 | count); |
|---|
| 1990 | websWrite(wp, "</div>\n"); |
|---|
| 1991 | count++; |
|---|
| 1992 | } |
|---|
| 1993 | totalcount = count; |
|---|
| 1994 | int i; |
|---|
| 1995 | |
|---|
| 1996 | for (i = count; i < realcount; i++) { |
|---|
| 1997 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1998 | websWrite(wp, "<div class=\"label\">VLAN%d Interface</div>\n", |
|---|
| 1999 | i); |
|---|
| 2000 | char vlan_name[32]; |
|---|
| 2001 | |
|---|
| 2002 | sprintf(vlan_name, "vlanifname%d", i); |
|---|
| 2003 | showOptions(wp, vlan_name, buffer, ""); |
|---|
| 2004 | sprintf(vlan_name, "vlantag%d", i); |
|---|
| 2005 | //tag number |
|---|
| 2006 | websWrite(wp, " Tag Number "); |
|---|
| 2007 | websWrite(wp, |
|---|
| 2008 | "<input class=\"num\" name=\"%s\" size=\"5\" value=\"0\" />\n", |
|---|
| 2009 | vlan_name); |
|---|
| 2010 | //priority |
|---|
| 2011 | sprintf(vlan_name, "vlanprio%d", count); |
|---|
| 2012 | websWrite(wp, " Prio "); |
|---|
| 2013 | showOptions(wp, vlan_name, "0 1 2 3 4 5 6 7", "0"); |
|---|
| 2014 | websWrite(wp, |
|---|
| 2015 | "<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", |
|---|
| 2016 | i); |
|---|
| 2017 | websWrite(wp, "</div>\n"); |
|---|
| 2018 | totalcount++; |
|---|
| 2019 | } |
|---|
| 2020 | char var[32]; |
|---|
| 2021 | |
|---|
| 2022 | sprintf(var, "%d", totalcount); |
|---|
| 2023 | nvram_set("vlan_tagcount", var); |
|---|
| 2024 | websWrite(wp, |
|---|
| 2025 | "<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"); |
|---|
| 2026 | } |
|---|
| 2027 | |
|---|
| 2028 | void ej_show_mdhcp(webs_t wp, int argc, char_t ** argv) |
|---|
| 2029 | { |
|---|
| 2030 | char buffer[256]; |
|---|
| 2031 | int count = 0; |
|---|
| 2032 | static char word[256]; |
|---|
| 2033 | char *next, *wordlist; |
|---|
| 2034 | |
|---|
| 2035 | websWrite(wp, "<h2>%s</h2>\n<fieldset>\n", |
|---|
| 2036 | live_translate("networking.h5")); |
|---|
| 2037 | websWrite(wp, "<legend>%s</legend>\n", |
|---|
| 2038 | live_translate("networking.legend5")); |
|---|
| 2039 | |
|---|
| 2040 | memset(buffer, 0, 256); |
|---|
| 2041 | getIfList(buffer, NULL); |
|---|
| 2042 | int totalcount = 0; |
|---|
| 2043 | int realcount = atoi(nvram_default_get("mdhcpd_count", "0")); |
|---|
| 2044 | |
|---|
| 2045 | wordlist = nvram_safe_get("mdhcpd"); |
|---|
| 2046 | foreach(word, wordlist, next) { |
|---|
| 2047 | char *interface = word; |
|---|
| 2048 | char *dhcpon = interface; |
|---|
| 2049 | |
|---|
| 2050 | interface = strsep(&dhcpon, ">"); |
|---|
| 2051 | char *start = dhcpon; |
|---|
| 2052 | |
|---|
| 2053 | dhcpon = strsep(&start, ">"); |
|---|
| 2054 | char *max = start; |
|---|
| 2055 | |
|---|
| 2056 | start = strsep(&max, ">"); |
|---|
| 2057 | char *leasetime = max; |
|---|
| 2058 | |
|---|
| 2059 | max = strsep(&leasetime, ">"); |
|---|
| 2060 | if (!interface || !start || !dhcpon || !max || !leasetime) |
|---|
| 2061 | break; |
|---|
| 2062 | char vlan_name[32]; |
|---|
| 2063 | |
|---|
| 2064 | // interface |
|---|
| 2065 | char *ipaddr = nvram_nget("%s_ipaddr", interface); |
|---|
| 2066 | char *netmask = nvram_nget("%s_netmask", interface); |
|---|
| 2067 | |
|---|
| 2068 | if (strlen(ipaddr) > 0 && strlen(netmask) > 0) { |
|---|
| 2069 | websWrite(wp, "Interface %s: IP %s/%s\n", interface, |
|---|
| 2070 | ipaddr, netmask); |
|---|
| 2071 | } |
|---|
| 2072 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2073 | websWrite(wp, "<div class=\"label\">DHCP %d</div>\n", count); |
|---|
| 2074 | sprintf(vlan_name, "mdhcpifname%d", count); |
|---|
| 2075 | showOptions(wp, vlan_name, buffer, interface); |
|---|
| 2076 | // on off |
|---|
| 2077 | sprintf(vlan_name, "mdhcpon%d", count); |
|---|
| 2078 | showOptions(wp, vlan_name, "On Off", dhcpon); |
|---|
| 2079 | // start |
|---|
| 2080 | sprintf(vlan_name, "mdhcpstart%d", count); |
|---|
| 2081 | websWrite(wp, " Start "); |
|---|
| 2082 | websWrite(wp, |
|---|
| 2083 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2084 | vlan_name, start); |
|---|
| 2085 | // max |
|---|
| 2086 | sprintf(vlan_name, "mdhcpmax%d", count); |
|---|
| 2087 | websWrite(wp, " Max "); |
|---|
| 2088 | websWrite(wp, |
|---|
| 2089 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2090 | vlan_name, max); |
|---|
| 2091 | sprintf(vlan_name, "mdhcpleasetime%d", count); |
|---|
| 2092 | websWrite(wp, " Leasetime "); |
|---|
| 2093 | websWrite(wp, |
|---|
| 2094 | "<input class=\"num\" name=\"%s\" size=\"5\" value=\"%s\" />\n", |
|---|
| 2095 | vlan_name, leasetime); |
|---|
| 2096 | // |
|---|
| 2097 | websWrite(wp, |
|---|
| 2098 | "<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", |
|---|
| 2099 | count); |
|---|
| 2100 | websWrite(wp, "</div>\n"); |
|---|
| 2101 | count++; |
|---|
| 2102 | } |
|---|
| 2103 | totalcount = count; |
|---|
| 2104 | int i; |
|---|
| 2105 | |
|---|
| 2106 | for (i = count; i < realcount; i++) { |
|---|
| 2107 | char vlan_name[32]; |
|---|
| 2108 | |
|---|
| 2109 | // sprintf (mdhcp_name, "%s.%s", tag, port); |
|---|
| 2110 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2111 | websWrite(wp, "<div class=\"label\">DHCP %d</div>\n", count); |
|---|
| 2112 | // interface |
|---|
| 2113 | sprintf(vlan_name, "mdhcpifname%d", count); |
|---|
| 2114 | showOptions(wp, vlan_name, buffer, ""); |
|---|
| 2115 | // on off |
|---|
| 2116 | sprintf(vlan_name, "mdhcpon%d", count); |
|---|
| 2117 | showOptions(wp, vlan_name, "On Off", ""); |
|---|
| 2118 | // start |
|---|
| 2119 | sprintf(vlan_name, "mdhcpstart%d", count); |
|---|
| 2120 | websWrite(wp, " Start "); |
|---|
| 2121 | websWrite(wp, |
|---|
| 2122 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2123 | vlan_name, "100"); |
|---|
| 2124 | // max |
|---|
| 2125 | sprintf(vlan_name, "mdhcpmax%d", count); |
|---|
| 2126 | websWrite(wp, " Max "); |
|---|
| 2127 | websWrite(wp, |
|---|
| 2128 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2129 | vlan_name, "50"); |
|---|
| 2130 | sprintf(vlan_name, "mdhcpleasetime%d", count); |
|---|
| 2131 | websWrite(wp, " Leasetime "); |
|---|
| 2132 | websWrite(wp, |
|---|
| 2133 | "<input class=\"num\" name=\"%s\" size=\"5\" value=\"%s\" />\n", |
|---|
| 2134 | vlan_name, "3600"); |
|---|
| 2135 | websWrite(wp, |
|---|
| 2136 | "<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", |
|---|
| 2137 | i); |
|---|
| 2138 | websWrite(wp, "</div>\n"); |
|---|
| 2139 | totalcount++; |
|---|
| 2140 | } |
|---|
| 2141 | char var[32]; |
|---|
| 2142 | |
|---|
| 2143 | sprintf(var, "%d", totalcount); |
|---|
| 2144 | nvram_set("mdhcpd_count", var); |
|---|
| 2145 | websWrite(wp, |
|---|
| 2146 | "<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"); |
|---|
| 2147 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 2148 | |
|---|
| 2149 | } |
|---|
| 2150 | |
|---|
| 2151 | void ej_show_bridgenames(webs_t wp, int argc, char_t ** argv) |
|---|
| 2152 | { |
|---|
| 2153 | char buffer[256]; |
|---|
| 2154 | int count = 0; |
|---|
| 2155 | static char word[256]; |
|---|
| 2156 | char *next, *wordlist; |
|---|
| 2157 | |
|---|
| 2158 | memset(buffer, 0, 256); |
|---|
| 2159 | getIfList(buffer, NULL); |
|---|
| 2160 | int realcount = atoi(nvram_default_get("bridges_count", "0")); |
|---|
| 2161 | |
|---|
| 2162 | wordlist = nvram_safe_get("bridges"); |
|---|
| 2163 | foreach(word, wordlist, next) { |
|---|
| 2164 | |
|---|
| 2165 | char *stp = word; |
|---|
| 2166 | char *bridge = strsep(&stp, ">"); |
|---|
| 2167 | char *prio = stp; |
|---|
| 2168 | |
|---|
| 2169 | stp = strsep(&prio, ">"); |
|---|
| 2170 | char *mtu = prio; |
|---|
| 2171 | |
|---|
| 2172 | prio = strsep(&mtu, ">"); |
|---|
| 2173 | if (!prio) { |
|---|
| 2174 | prio = mtu; |
|---|
| 2175 | mtu = "1500"; |
|---|
| 2176 | } |
|---|
| 2177 | |
|---|
| 2178 | /* char *stp = word; |
|---|
| 2179 | char *bridge = strsep( &stp, ">" ); |
|---|
| 2180 | char *mtu = stp; |
|---|
| 2181 | char *prio = strsep( &mtu, ">" ); |
|---|
| 2182 | */ |
|---|
| 2183 | if (!bridge || !stp) |
|---|
| 2184 | break; |
|---|
| 2185 | |
|---|
| 2186 | char vlan_name[32]; |
|---|
| 2187 | |
|---|
| 2188 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2189 | websWrite(wp, "<div class=\"label\">Bridge %d</div>\n", count); |
|---|
| 2190 | sprintf(vlan_name, "bridgename%d", count); |
|---|
| 2191 | websWrite(wp, |
|---|
| 2192 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2193 | vlan_name, bridge); |
|---|
| 2194 | websWrite(wp, " STP "); |
|---|
| 2195 | sprintf(vlan_name, "bridgestp%d", count); |
|---|
| 2196 | showOptions(wp, vlan_name, "On Off", stp); |
|---|
| 2197 | websWrite(wp, " Prio "); |
|---|
| 2198 | sprintf(vlan_name, "bridgeprio%d", count); |
|---|
| 2199 | websWrite(wp, |
|---|
| 2200 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2201 | vlan_name, prio != NULL ? prio : "32768"); |
|---|
| 2202 | websWrite(wp, " MTU "); |
|---|
| 2203 | sprintf(vlan_name, "bridgemtu%d", count); |
|---|
| 2204 | websWrite(wp, |
|---|
| 2205 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2206 | vlan_name, mtu != NULL ? mtu : "1500"); |
|---|
| 2207 | websWrite(wp, |
|---|
| 2208 | "<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", |
|---|
| 2209 | count); |
|---|
| 2210 | websWrite(wp, "</div>\n"); |
|---|
| 2211 | show_ipnetmask(wp, bridge); |
|---|
| 2212 | count++; |
|---|
| 2213 | } |
|---|
| 2214 | int i; |
|---|
| 2215 | int totalcount = count; |
|---|
| 2216 | |
|---|
| 2217 | for (i = count; i < realcount; i++) { |
|---|
| 2218 | char vlan_name[32]; |
|---|
| 2219 | |
|---|
| 2220 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2221 | websWrite(wp, "<div class=\"label\">Bridge %d</div>\n", i); |
|---|
| 2222 | sprintf(vlan_name, "bridgename%d", i); |
|---|
| 2223 | websWrite(wp, "<input class=\"num\" name=\"%s\"size=\"5\" />\n", |
|---|
| 2224 | vlan_name); |
|---|
| 2225 | websWrite(wp, " STP "); |
|---|
| 2226 | sprintf(vlan_name, "bridgestp%d", i); |
|---|
| 2227 | showOptions(wp, vlan_name, "On Off", "On"); |
|---|
| 2228 | websWrite(wp, " Prio "); |
|---|
| 2229 | sprintf(vlan_name, "bridgeprio%d", i); |
|---|
| 2230 | websWrite(wp, |
|---|
| 2231 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2232 | vlan_name, "32768"); |
|---|
| 2233 | websWrite(wp, " MTU "); |
|---|
| 2234 | sprintf(vlan_name, "bridgemtu%d", count); |
|---|
| 2235 | websWrite(wp, |
|---|
| 2236 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2237 | vlan_name, "1500"); |
|---|
| 2238 | websWrite(wp, |
|---|
| 2239 | "<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", |
|---|
| 2240 | i); |
|---|
| 2241 | websWrite(wp, "</div>\n"); |
|---|
| 2242 | totalcount++; |
|---|
| 2243 | } |
|---|
| 2244 | websWrite(wp, |
|---|
| 2245 | "<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"); |
|---|
| 2246 | char var[32]; |
|---|
| 2247 | |
|---|
| 2248 | sprintf(var, "%d", totalcount); |
|---|
| 2249 | nvram_set("bridges_count", var); |
|---|
| 2250 | } |
|---|
| 2251 | |
|---|
| 2252 | void ej_show_bridgetable(webs_t wp, int argc, char_t ** argv) |
|---|
| 2253 | { |
|---|
| 2254 | //#ifdef HAVE_MICRO // brctl N/A in micro |
|---|
| 2255 | // return; |
|---|
| 2256 | //#endif |
|---|
| 2257 | |
|---|
| 2258 | FILE *f; |
|---|
| 2259 | char buf[128]; |
|---|
| 2260 | char brname[32]; |
|---|
| 2261 | char brstp[8]; |
|---|
| 2262 | char brif[16]; |
|---|
| 2263 | int count = 0; |
|---|
| 2264 | |
|---|
| 2265 | system2("brctl show > /tmp/.brtable"); |
|---|
| 2266 | |
|---|
| 2267 | if ((f = fopen("/tmp/.brtable", "r")) != NULL) { |
|---|
| 2268 | |
|---|
| 2269 | while (fgets(buf, sizeof(buf), f)) { |
|---|
| 2270 | |
|---|
| 2271 | if (count) // skip line 0 |
|---|
| 2272 | { |
|---|
| 2273 | strcpy(brname, ""); |
|---|
| 2274 | strcpy(brstp, ""); |
|---|
| 2275 | strcpy(brif, ""); |
|---|
| 2276 | |
|---|
| 2277 | if (strncmp(buf, "\t\t\t", 3) != 0) { |
|---|
| 2278 | if (count != 1) |
|---|
| 2279 | websWrite(wp, "\',"); // close |
|---|
| 2280 | sscanf(buf, "%s %*s %s %s", brname, |
|---|
| 2281 | brstp, brif); |
|---|
| 2282 | websWrite(wp, "\'%s\',\'%s\',\'%s ", |
|---|
| 2283 | brname, brstp, brif); |
|---|
| 2284 | } else { |
|---|
| 2285 | sscanf(buf, "%s", brif); |
|---|
| 2286 | websWrite(wp, "%s ", brif); |
|---|
| 2287 | } |
|---|
| 2288 | } |
|---|
| 2289 | count++; |
|---|
| 2290 | } |
|---|
| 2291 | |
|---|
| 2292 | websWrite(wp, "\'"); // close |
|---|
| 2293 | fclose(f); |
|---|
| 2294 | unlink("/tmp/.brtable"); |
|---|
| 2295 | } |
|---|
| 2296 | return; |
|---|
| 2297 | } |
|---|
| 2298 | |
|---|
| 2299 | void ej_show_bridgeifnames(webs_t wp, int argc, char_t ** argv) |
|---|
| 2300 | { |
|---|
| 2301 | char bufferif[512]; |
|---|
| 2302 | char bufferif2[256]; |
|---|
| 2303 | char finalbuffer[512]; |
|---|
| 2304 | int count = 0; |
|---|
| 2305 | static char word[256]; |
|---|
| 2306 | char *next, *wordlist; |
|---|
| 2307 | |
|---|
| 2308 | memset(bufferif, 0, 512); |
|---|
| 2309 | memset(bufferif2, 0, 256); |
|---|
| 2310 | getIfList(bufferif, "eth"); |
|---|
| 2311 | #ifdef HAVE_GATEWORX |
|---|
| 2312 | getIfList(bufferif2, "ixp"); |
|---|
| 2313 | sprintf(bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2314 | #endif |
|---|
| 2315 | |
|---|
| 2316 | memset(bufferif2, 0, 256); |
|---|
| 2317 | getIfList(bufferif2, "vlan"); |
|---|
| 2318 | sprintf(bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2319 | |
|---|
| 2320 | memset(bufferif2, 0, 256); |
|---|
| 2321 | getIfList(bufferif2, "wl"); |
|---|
| 2322 | sprintf(bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2323 | |
|---|
| 2324 | memset(bufferif2, 0, 256); |
|---|
| 2325 | getIfList(bufferif2, "ofdm"); |
|---|
| 2326 | sprintf(bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2327 | |
|---|
| 2328 | #ifdef HAVE_RT2880 |
|---|
| 2329 | memset(bufferif2, 0, 256); |
|---|
| 2330 | getIfList(bufferif2, "ra"); |
|---|
| 2331 | sprintf(bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2332 | #endif |
|---|
| 2333 | memset(bufferif2, 0, 256); |
|---|
| 2334 | getIfList(bufferif2, "br"); |
|---|
| 2335 | foreach(word, bufferif2, next) { |
|---|
| 2336 | if (contains(word, '.')) |
|---|
| 2337 | sprintf(bufferif, "%s %s", bufferif, word); |
|---|
| 2338 | } |
|---|
| 2339 | int i; |
|---|
| 2340 | |
|---|
| 2341 | #ifdef HAVE_MADWIFI |
|---|
| 2342 | // memset(bufferif2, 0, 256); |
|---|
| 2343 | // getIfList(bufferif2, "ath"); |
|---|
| 2344 | // foreach(word, bufferif2, next) { |
|---|
| 2345 | // if (contains(word, '.')) |
|---|
| 2346 | // sprintf(bufferif, "%s %s", bufferif, word); |
|---|
| 2347 | // } |
|---|
| 2348 | int c = getifcount("wifi"); |
|---|
| 2349 | |
|---|
| 2350 | for (i = 0; i < c; i++) { |
|---|
| 2351 | char ath[32]; |
|---|
| 2352 | |
|---|
| 2353 | // sprintf(ath, "ath%d_bridged", i); |
|---|
| 2354 | // if (nvram_default_match(ath, "1", "1")) |
|---|
| 2355 | { |
|---|
| 2356 | sprintf(bufferif, "%s ath%d", bufferif, i); |
|---|
| 2357 | char vifs[32]; |
|---|
| 2358 | |
|---|
| 2359 | sprintf(vifs, "ath%d_vifs", i); |
|---|
| 2360 | sprintf(bufferif, "%s %s", bufferif, |
|---|
| 2361 | nvram_safe_get(vifs)); |
|---|
| 2362 | } |
|---|
| 2363 | } |
|---|
| 2364 | #endif |
|---|
| 2365 | #ifdef HAVE_BONDING |
|---|
| 2366 | c = atoi(nvram_default_get("bonding_number", "1")); |
|---|
| 2367 | for (i = 0; i < c; i++) { |
|---|
| 2368 | sprintf(bufferif, "%s bond%d", bufferif, i); |
|---|
| 2369 | } |
|---|
| 2370 | #endif |
|---|
| 2371 | #ifdef HAVE_EOP_TUNNEL |
|---|
| 2372 | for (i = 1; i < 11; i++) { |
|---|
| 2373 | char EOP[32]; |
|---|
| 2374 | |
|---|
| 2375 | if (nvram_nmatch("1", "oet%d_en", i) |
|---|
| 2376 | && nvram_nmatch("0", "oet%d_bridged", i)) { |
|---|
| 2377 | sprintf(EOP, "oet%d", i); |
|---|
| 2378 | sprintf(bufferif, "%s %s", bufferif, EOP); |
|---|
| 2379 | } |
|---|
| 2380 | } |
|---|
| 2381 | #endif |
|---|
| 2382 | char buffer[256]; |
|---|
| 2383 | |
|---|
| 2384 | memset(buffer, 0, 256); |
|---|
| 2385 | getIfList(buffer, "br"); |
|---|
| 2386 | |
|---|
| 2387 | memset(finalbuffer, 0, 256); |
|---|
| 2388 | foreach(word, buffer, next) { |
|---|
| 2389 | if (!contains(word, '.')) |
|---|
| 2390 | sprintf(finalbuffer, "%s %s", finalbuffer, word); |
|---|
| 2391 | } |
|---|
| 2392 | char *checkbuffer = malloc(strlen(finalbuffer) + 6); |
|---|
| 2393 | memset(checkbuffer, 0, strlen(finalbuffer) + 6); |
|---|
| 2394 | strcpy(checkbuffer, "none "); |
|---|
| 2395 | strcat(checkbuffer, finalbuffer); |
|---|
| 2396 | strcpy(finalbuffer, checkbuffer); |
|---|
| 2397 | free(checkbuffer); |
|---|
| 2398 | int realcount = atoi(nvram_default_get("bridgesif_count", "0")); |
|---|
| 2399 | |
|---|
| 2400 | wordlist = nvram_safe_get("bridgesif"); |
|---|
| 2401 | foreach(word, wordlist, next) { |
|---|
| 2402 | char *port = word; |
|---|
| 2403 | char *tag = strsep(&port, ">"); |
|---|
| 2404 | char *prio = port; |
|---|
| 2405 | |
|---|
| 2406 | strsep(&prio, ">"); |
|---|
| 2407 | if (!tag || !port) |
|---|
| 2408 | break; |
|---|
| 2409 | char vlan_name[32]; |
|---|
| 2410 | |
|---|
| 2411 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2412 | websWrite(wp, "<div class=\"label\">Assignment %d</div>\n", |
|---|
| 2413 | count); |
|---|
| 2414 | sprintf(vlan_name, "bridge%d", count); |
|---|
| 2415 | showOptions(wp, vlan_name, finalbuffer, tag); |
|---|
| 2416 | websWrite(wp, " Interface "); |
|---|
| 2417 | sprintf(vlan_name, "bridgeif%d", count); |
|---|
| 2418 | showOptions(wp, vlan_name, bufferif, port); |
|---|
| 2419 | websWrite(wp, " Prio "); |
|---|
| 2420 | sprintf(vlan_name, "bridgeifprio%d", count); |
|---|
| 2421 | websWrite(wp, |
|---|
| 2422 | "<input class=\"num\" name=\"%s\"size=\"3\" value=\"%s\" />\n", |
|---|
| 2423 | vlan_name, prio != NULL ? prio : "63"); |
|---|
| 2424 | websWrite(wp, |
|---|
| 2425 | "<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", |
|---|
| 2426 | count); |
|---|
| 2427 | websWrite(wp, "</div>\n"); |
|---|
| 2428 | count++; |
|---|
| 2429 | } |
|---|
| 2430 | int totalcount = count; |
|---|
| 2431 | |
|---|
| 2432 | for (i = count; i < realcount; i++) { |
|---|
| 2433 | char vlan_name[32]; |
|---|
| 2434 | |
|---|
| 2435 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2436 | websWrite(wp, "<div class=\"label\">Assignment %d</div>\n", i); |
|---|
| 2437 | sprintf(vlan_name, "bridge%d", i); |
|---|
| 2438 | showOptions(wp, vlan_name, finalbuffer, ""); |
|---|
| 2439 | websWrite(wp, " Interface "); |
|---|
| 2440 | sprintf(vlan_name, "bridgeif%d", i); |
|---|
| 2441 | showOptions(wp, vlan_name, bufferif, ""); |
|---|
| 2442 | websWrite(wp, " Prio "); |
|---|
| 2443 | sprintf(vlan_name, "bridgeifprio%d", i); |
|---|
| 2444 | websWrite(wp, |
|---|
| 2445 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2446 | vlan_name, "63"); |
|---|
| 2447 | websWrite(wp, |
|---|
| 2448 | "<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", |
|---|
| 2449 | i); |
|---|
| 2450 | websWrite(wp, "</div>\n"); |
|---|
| 2451 | totalcount++; |
|---|
| 2452 | } |
|---|
| 2453 | websWrite(wp, |
|---|
| 2454 | "<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"); |
|---|
| 2455 | char var[32]; |
|---|
| 2456 | |
|---|
| 2457 | sprintf(var, "%d", totalcount); |
|---|
| 2458 | nvram_set("bridgesif_count", var); |
|---|
| 2459 | } |
|---|
| 2460 | |
|---|
| 2461 | #endif |
|---|
| 2462 | #if 0 |
|---|
| 2463 | static void |
|---|
| 2464 | showDynOption(webs_t wp, char *propname, char *nvname, char *options[], |
|---|
| 2465 | char *names[]) |
|---|
| 2466 | { |
|---|
| 2467 | int i; |
|---|
| 2468 | |
|---|
| 2469 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2470 | websWrite(wp, |
|---|
| 2471 | "<div class=\"label\">%s</div><select name=\"%s\">\n", |
|---|
| 2472 | propname, nvname); |
|---|
| 2473 | for (i = 0; options[i] != NULL; i++) { |
|---|
| 2474 | websWrite(wp, |
|---|
| 2475 | "<option value=\"%s\" %s>Off</option>\n", |
|---|
| 2476 | names[i], nvram_match(nvname, |
|---|
| 2477 | options[i]) ? |
|---|
| 2478 | "selected=\"selected\"" : ""); |
|---|
| 2479 | } |
|---|
| 2480 | websWrite(wp, "</div>\n"); |
|---|
| 2481 | |
|---|
| 2482 | } |
|---|
| 2483 | #endif |
|---|
| 2484 | |
|---|
| 2485 | static void show_channel(webs_t wp, char *dev, char *prefix, int type) |
|---|
| 2486 | { |
|---|
| 2487 | char wl_mode[16]; |
|---|
| 2488 | |
|---|
| 2489 | sprintf(wl_mode, "%s_mode", prefix); |
|---|
| 2490 | char wl_net_mode[16]; |
|---|
| 2491 | |
|---|
| 2492 | sprintf(wl_net_mode, "%s_net_mode", prefix); |
|---|
| 2493 | if (nvram_match(wl_net_mode, "disabled")) |
|---|
| 2494 | return; |
|---|
| 2495 | #ifdef HAVE_RT2880 |
|---|
| 2496 | if (nvram_match(wl_mode, "ap") || nvram_match(wl_mode, "wdsap") |
|---|
| 2497 | || nvram_match(wl_mode, "apsta") || nvram_match(wl_mode, "apstawet") |
|---|
| 2498 | || nvram_match(wl_mode, "infra")) |
|---|
| 2499 | #else |
|---|
| 2500 | if (nvram_match(wl_mode, "ap") || nvram_match(wl_mode, "wdsap") |
|---|
| 2501 | || nvram_match(wl_mode, "infra")) |
|---|
| 2502 | #endif |
|---|
| 2503 | { |
|---|
| 2504 | char wl_channel[16]; |
|---|
| 2505 | |
|---|
| 2506 | sprintf(wl_channel, "%s_channel", prefix); |
|---|
| 2507 | char wl_wchannel[16]; |
|---|
| 2508 | |
|---|
| 2509 | sprintf(wl_wchannel, "%s_wchannel", prefix); |
|---|
| 2510 | char wl_nbw[16]; |
|---|
| 2511 | |
|---|
| 2512 | nvram_default_get(wl_wchannel, "0"); |
|---|
| 2513 | sprintf(wl_nbw, "%s_nbw", prefix); |
|---|
| 2514 | |
|---|
| 2515 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2516 | websWrite(wp, |
|---|
| 2517 | "<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", |
|---|
| 2518 | wl_channel); |
|---|
| 2519 | #ifdef HAVE_MADWIFI |
|---|
| 2520 | struct wifi_channels *chan; |
|---|
| 2521 | char cn[32]; |
|---|
| 2522 | char fr[32]; |
|---|
| 2523 | |
|---|
| 2524 | #ifdef HAVE_MADWIFI_MIMO |
|---|
| 2525 | if (is_ar5008(prefix)) { |
|---|
| 2526 | chan = list_channels_11n(prefix); |
|---|
| 2527 | if (chan == NULL) |
|---|
| 2528 | chan = list_channels_11n(dev); |
|---|
| 2529 | } else |
|---|
| 2530 | #endif |
|---|
| 2531 | { |
|---|
| 2532 | chan = list_channels(prefix); |
|---|
| 2533 | if (chan == NULL) |
|---|
| 2534 | chan = list_channels(dev); |
|---|
| 2535 | } |
|---|
| 2536 | |
|---|
| 2537 | if (chan != NULL) { |
|---|
| 2538 | // int cnt = getchannelcount (); |
|---|
| 2539 | websWrite(wp, |
|---|
| 2540 | "document.write(\"<option value=\\\"0\\\" %s>\" + share.auto + \"</option>\");\n", |
|---|
| 2541 | nvram_match(wl_channel, |
|---|
| 2542 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 2543 | : ""); |
|---|
| 2544 | int i = 0; |
|---|
| 2545 | |
|---|
| 2546 | while (chan[i].freq != -1) { |
|---|
| 2547 | cprintf("%d\n", chan[i].channel); |
|---|
| 2548 | cprintf("%d\n", chan[i].freq); |
|---|
| 2549 | |
|---|
| 2550 | sprintf(cn, "%d", chan[i].channel); |
|---|
| 2551 | sprintf(fr, "%d", chan[i].freq); |
|---|
| 2552 | int freq = get_wififreq(prefix, chan[i].freq); |
|---|
| 2553 | if (freq != -1) |
|---|
| 2554 | websWrite(wp, |
|---|
| 2555 | "document.write(\"<option value=\\\"%s\\\" %s>%s - %d MHz</option>\");\n", |
|---|
| 2556 | fr, nvram_match(wl_channel, |
|---|
| 2557 | fr) ? |
|---|
| 2558 | "selected=\\\"selected\\\"" : |
|---|
| 2559 | "", cn, (freq)); |
|---|
| 2560 | // free (chan[i].freq); |
|---|
| 2561 | i++; |
|---|
| 2562 | } |
|---|
| 2563 | free(chan); |
|---|
| 2564 | } |
|---|
| 2565 | #else |
|---|
| 2566 | int instance = 0; |
|---|
| 2567 | |
|---|
| 2568 | if (!strcmp(prefix, "wl1")) |
|---|
| 2569 | instance = 1; |
|---|
| 2570 | /* |
|---|
| 2571 | #if 0 |
|---|
| 2572 | if (type == 1 && !nvram_match(wl_net_mode, "g-only") |
|---|
| 2573 | && !nvram_match(wl_net_mode, "a-only") |
|---|
| 2574 | && !nvram_match(wl_net_mode, "na-only") |
|---|
| 2575 | && !nvram_match(wl_net_mode, "bg-mixed") |
|---|
| 2576 | && nvram_match(wl_nbw, "40")) { |
|---|
| 2577 | int ch = atoi(nvram_nget("wl%d_wchannel", instance)); |
|---|
| 2578 | |
|---|
| 2579 | websWrite(wp, "var max_channel = 2;\n"); |
|---|
| 2580 | websWrite(wp, "var wl%d_channel = '%s';\n", instance, |
|---|
| 2581 | nvram_safe_get(wl_wchannel)); |
|---|
| 2582 | websWrite(wp, |
|---|
| 2583 | "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"); |
|---|
| 2584 | char *sel = ""; |
|---|
| 2585 | |
|---|
| 2586 | if (ch == 0) //wchannel = Auto |
|---|
| 2587 | { |
|---|
| 2588 | websWrite(wp, |
|---|
| 2589 | " document.write(\"<option value=\\\"0\\\" selected=\\\"selected\\\">\"+ share.auto +\"</option>\");\n"); |
|---|
| 2590 | } else { |
|---|
| 2591 | if (nvram_nmatch |
|---|
| 2592 | ("lower", "wl%d_nctrlsb", instance)) |
|---|
| 2593 | sel = "selected=\\\"selected\\\""; |
|---|
| 2594 | |
|---|
| 2595 | websWrite(wp, |
|---|
| 2596 | " document.write(\"<option value=\\\"%d\\\" %s>%d - \"+freq[%d]+\" GHz</option>\");\n", |
|---|
| 2597 | ch - 2, sel, ch - 2, ch - 2); |
|---|
| 2598 | sel = ""; |
|---|
| 2599 | if (nvram_nmatch |
|---|
| 2600 | ("upper", "wl%d_nctrlsb", instance)) |
|---|
| 2601 | sel = "selected=\\\"selected\\\""; |
|---|
| 2602 | websWrite(wp, |
|---|
| 2603 | " document.write(\"<option value=\\\"%d\\\" %s>%d - \"+freq[%d]+\" GHz</option>\");\n", |
|---|
| 2604 | ch + 2, sel, ch + 2, ch + 2); |
|---|
| 2605 | } |
|---|
| 2606 | |
|---|
| 2607 | } else |
|---|
| 2608 | #endif |
|---|
| 2609 | */ |
|---|
| 2610 | { |
|---|
| 2611 | |
|---|
| 2612 | unsigned int chanlist[128]; |
|---|
| 2613 | char *ifn = get_wl_instance_name(instance); |
|---|
| 2614 | int chancount = getchannels(chanlist, ifn); |
|---|
| 2615 | int net_is_a = 0; |
|---|
| 2616 | |
|---|
| 2617 | if (chanlist[0] > 25) |
|---|
| 2618 | net_is_a = 1; |
|---|
| 2619 | |
|---|
| 2620 | // websWrite( wp, "var max_channel = %d;\n", chancount ); |
|---|
| 2621 | // websWrite( wp, "var wl%d_channel = '%s';\n", instance, nvram_safe_get( wl_channel ) ); |
|---|
| 2622 | // websWrite( wp, "var offset = %d;\n", chanlist[0] ); |
|---|
| 2623 | // websWrite( wp, "var buf = \"\";\n" ); |
|---|
| 2624 | // websWrite( wp, "var freq = new Array(\"Auto\"" ); |
|---|
| 2625 | int i, j; |
|---|
| 2626 | |
|---|
| 2627 | // supported 5GHz channels for IEEE 802.11n 40Mhz |
|---|
| 2628 | int na_upper[16] = |
|---|
| 2629 | { 40, 48, 56, 64, 104, 112, 120, 128, 136, 153, 161, |
|---|
| 2630 | 0, 0, 0, 0, 0 |
|---|
| 2631 | }; |
|---|
| 2632 | int na_lower[16] = |
|---|
| 2633 | { 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157, |
|---|
| 2634 | 0, 0, 0, 0, 0 |
|---|
| 2635 | }; |
|---|
| 2636 | |
|---|
| 2637 | websWrite(wp, |
|---|
| 2638 | "document.write(\"<option value=\\\"0\\\" %s>\" + share.auto + \"</option>\");\n", |
|---|
| 2639 | nvram_nmatch("0", "%s_channel", |
|---|
| 2640 | prefix) ? |
|---|
| 2641 | "selected=\\\"selected\\\"" : ""); |
|---|
| 2642 | for (i = 0; i < chancount; i++) { |
|---|
| 2643 | float ofs; |
|---|
| 2644 | |
|---|
| 2645 | if (chanlist[i] < 25) |
|---|
| 2646 | ofs = 2.407f; |
|---|
| 2647 | else |
|---|
| 2648 | ofs = 5.000f; |
|---|
| 2649 | ofs += (float)(chanlist[i] * 0.005f); |
|---|
| 2650 | if (ofs == 2.477f) |
|---|
| 2651 | ofs = 2.484f; // fix: ch 14 is 2.484, not 2.477 GHz |
|---|
| 2652 | // websWrite( wp, ", \"%0.3f\"", ofs ); |
|---|
| 2653 | char channelstring[32]; |
|---|
| 2654 | |
|---|
| 2655 | int showit = 1; |
|---|
| 2656 | |
|---|
| 2657 | if (nvram_match(wl_net_mode, "a-only") |
|---|
| 2658 | || nvram_match(wl_net_mode, "na-only") |
|---|
| 2659 | || nvram_match(wl_net_mode, "n5-only") |
|---|
| 2660 | || (net_is_a |
|---|
| 2661 | && nvram_match(wl_net_mode, "mixed"))) { |
|---|
| 2662 | if (chanlist[i] < 25) |
|---|
| 2663 | showit = 0; |
|---|
| 2664 | } else { |
|---|
| 2665 | if (chanlist[i] > 25) |
|---|
| 2666 | showit = 0; |
|---|
| 2667 | } |
|---|
| 2668 | |
|---|
| 2669 | if ((nvram_match(wl_net_mode, "na-only") |
|---|
| 2670 | || (net_is_a |
|---|
| 2671 | && nvram_match(wl_net_mode, "mixed")) |
|---|
| 2672 | || nvram_match(wl_net_mode, "n5-only")) |
|---|
| 2673 | && nvram_match(wl_nbw, "40")) { |
|---|
| 2674 | showit = 0; |
|---|
| 2675 | j = 0; |
|---|
| 2676 | if (nvram_nmatch |
|---|
| 2677 | ("upper", "%s_nctrlsb", prefix)) { |
|---|
| 2678 | while (na_upper[j]) { |
|---|
| 2679 | if (chanlist[i] == |
|---|
| 2680 | na_upper[j]) { |
|---|
| 2681 | showit = 1; |
|---|
| 2682 | break; |
|---|
| 2683 | } |
|---|
| 2684 | j++; |
|---|
| 2685 | } |
|---|
| 2686 | } else |
|---|
| 2687 | if (nvram_nmatch |
|---|
| 2688 | ("lower", "%s_nctrlsb", |
|---|
| 2689 | prefix)) { |
|---|
| 2690 | while (na_lower[j]) { |
|---|
| 2691 | if (chanlist[i] == |
|---|
| 2692 | na_lower[j]) { |
|---|
| 2693 | showit = 1; |
|---|
| 2694 | break; |
|---|
| 2695 | } |
|---|
| 2696 | j++; |
|---|
| 2697 | } |
|---|
| 2698 | } |
|---|
| 2699 | } |
|---|
| 2700 | |
|---|
| 2701 | if ((nvram_match(wl_net_mode, "n-only") |
|---|
| 2702 | || nvram_match(wl_net_mode, "n2-only") |
|---|
| 2703 | || nvram_match(wl_net_mode, "ng-only") |
|---|
| 2704 | || (!net_is_a |
|---|
| 2705 | && nvram_match(wl_net_mode, "mixed"))) |
|---|
| 2706 | && nvram_match(wl_nbw, "40")) { |
|---|
| 2707 | showit = 0; |
|---|
| 2708 | if (nvram_nmatch |
|---|
| 2709 | ("upper", "%s_nctrlsb", prefix)) { |
|---|
| 2710 | if (chanlist[i] >= 5 |
|---|
| 2711 | && chanlist[i] <= 13) { |
|---|
| 2712 | showit = 1; |
|---|
| 2713 | } |
|---|
| 2714 | } else |
|---|
| 2715 | if (nvram_nmatch |
|---|
| 2716 | ("lower", "%s_nctrlsb", |
|---|
| 2717 | prefix)) { |
|---|
| 2718 | if (chanlist[i] <= 9) { |
|---|
| 2719 | showit = 1; |
|---|
| 2720 | } |
|---|
| 2721 | } |
|---|
| 2722 | } |
|---|
| 2723 | |
|---|
| 2724 | sprintf(channelstring, "%d", chanlist[i]); |
|---|
| 2725 | if (showit) { |
|---|
| 2726 | websWrite(wp, |
|---|
| 2727 | "document.write(\"<option value=\\\"%d\\\" %s>%d - %0.3f GHz</option>\");\n", |
|---|
| 2728 | chanlist[i], |
|---|
| 2729 | nvram_nmatch(channelstring, |
|---|
| 2730 | "%s_channel", |
|---|
| 2731 | prefix) ? |
|---|
| 2732 | "selected=\\\"selected\\\"" : |
|---|
| 2733 | "", chanlist[i], ofs); |
|---|
| 2734 | } |
|---|
| 2735 | } |
|---|
| 2736 | // websWrite( wp, ");\n" ); |
|---|
| 2737 | // websWrite( wp, "for(i=0; i<=max_channel ; i++) {\n" ); |
|---|
| 2738 | // websWrite( wp, " if(i == wl%d_channel) buf = \"selected\";\n", |
|---|
| 2739 | // instance ); |
|---|
| 2740 | // websWrite( wp, " else buf = \"\";\n" ); |
|---|
| 2741 | // websWrite( wp, " if (i==0)\n" ); |
|---|
| 2742 | // websWrite( wp, |
|---|
| 2743 | // " document.write(\"<option value=\"+i+\" \"+buf+\">\" + share.auto + \"</option>\");\n" ); |
|---|
| 2744 | // websWrite( wp, " else\n" ); |
|---|
| 2745 | // websWrite( wp, |
|---|
| 2746 | // " document.write(\"<option value=\"+i+\" \"+buf+\">\"+(i+offset-1)+\" - \"+freq[i]+\" GHz</option>\");\n" ); |
|---|
| 2747 | // websWrite( wp, "}\n" ); |
|---|
| 2748 | } |
|---|
| 2749 | #endif |
|---|
| 2750 | websWrite(wp, "//]]>\n</script></select></div>\n"); |
|---|
| 2751 | } |
|---|
| 2752 | } |
|---|
| 2753 | |
|---|
| 2754 | #ifdef HAVE_MADWIFI |
|---|
| 2755 | static char *ag_rates[] = { "6", "9", "12", "18", "24", "36", "48", "54" }; |
|---|
| 2756 | static char *turbo_rates[] = |
|---|
| 2757 | { "12", "18", "24", "36", "48", "72", "96", "108" }; |
|---|
| 2758 | static char *b_rates[] = { "1", "2", "5.5", "11" }; |
|---|
| 2759 | static char *bg_rates[] = |
|---|
| 2760 | { "1", "2", "5.5", "6", "9", "11", "12", "18", "24", "36", "48", "54" }; |
|---|
| 2761 | // static char *g_rates[] = { "1", "2", "5.5", "11", "12", "18", "24", "36", |
|---|
| 2762 | // "48", "54" }; |
|---|
| 2763 | //static char *xr_rates[] = |
|---|
| 2764 | // { "0.25", "0.5", "1", "2", "3", "6", "9", "12", "18", "24", "36", "48", |
|---|
| 2765 | // "54" |
|---|
| 2766 | //}; |
|---|
| 2767 | static char *half_rates[] = { "3", "4.5", "6", "9", "12", "18", "24", "27" }; |
|---|
| 2768 | static char *quarter_rates[] = |
|---|
| 2769 | { "1.5", "2", "3", "4.5", "6", "9", "12", "13.5" }; |
|---|
| 2770 | static char *subquarter_rates[] = |
|---|
| 2771 | { "0.75", "1", "1.5", "2.25", "3", "4.5", "6", "6.75" }; |
|---|
| 2772 | |
|---|
| 2773 | void show_rates(webs_t wp, char *prefix, int maxrate) |
|---|
| 2774 | { |
|---|
| 2775 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2776 | if (maxrate) { |
|---|
| 2777 | websWrite(wp, |
|---|
| 2778 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label21)</script></div>\n"); |
|---|
| 2779 | websWrite(wp, "<select name=\"%s_maxrate\">\n", prefix); |
|---|
| 2780 | } else { |
|---|
| 2781 | websWrite(wp, |
|---|
| 2782 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label23)</script></div>\n"); |
|---|
| 2783 | websWrite(wp, "<select name=\"%s_minrate\">\n", prefix); |
|---|
| 2784 | } |
|---|
| 2785 | websWrite(wp, "<script type=\"text/javascript\">\n"); |
|---|
| 2786 | websWrite(wp, "//<![CDATA[\n"); |
|---|
| 2787 | char srate[32]; |
|---|
| 2788 | |
|---|
| 2789 | sprintf(srate, "%s_minrate", prefix); |
|---|
| 2790 | char mxrate[32]; |
|---|
| 2791 | |
|---|
| 2792 | sprintf(mxrate, "%s_maxrate", prefix); |
|---|
| 2793 | websWrite(wp, |
|---|
| 2794 | "document.write(\"<option value=\\\"0\\\" %s >\" + share.auto + \"</option>\");\n", |
|---|
| 2795 | nvram_match(srate, "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2796 | websWrite(wp, "//]]>\n"); |
|---|
| 2797 | websWrite(wp, "</script>\n"); |
|---|
| 2798 | char **rate; |
|---|
| 2799 | char **showrates = NULL; |
|---|
| 2800 | int len; |
|---|
| 2801 | char mode[32]; |
|---|
| 2802 | char bw[16]; |
|---|
| 2803 | |
|---|
| 2804 | sprintf(bw, "%s_channelbw", prefix); |
|---|
| 2805 | |
|---|
| 2806 | sprintf(mode, "%s_net_mode", prefix); |
|---|
| 2807 | if (nvram_match(mode, "b-only")) { |
|---|
| 2808 | rate = b_rates; |
|---|
| 2809 | len = sizeof(b_rates) / sizeof(char *); |
|---|
| 2810 | } |
|---|
| 2811 | if (nvram_match(mode, "g-only")) { |
|---|
| 2812 | rate = ag_rates; |
|---|
| 2813 | len = sizeof(ag_rates) / sizeof(char *); |
|---|
| 2814 | if (nvram_match(bw, "40")) { |
|---|
| 2815 | showrates = turbo_rates; |
|---|
| 2816 | } |
|---|
| 2817 | if (nvram_match(bw, "10")) { |
|---|
| 2818 | rate = half_rates; |
|---|
| 2819 | len = sizeof(half_rates) / sizeof(char *); |
|---|
| 2820 | } |
|---|
| 2821 | if (nvram_match(bw, "5")) { |
|---|
| 2822 | rate = quarter_rates; |
|---|
| 2823 | len = sizeof(quarter_rates) / sizeof(char *); |
|---|
| 2824 | } |
|---|
| 2825 | if (nvram_match(bw, "2")) { |
|---|
| 2826 | rate = subquarter_rates; |
|---|
| 2827 | len = sizeof(subquarter_rates) / sizeof(char *); |
|---|
| 2828 | } |
|---|
| 2829 | } |
|---|
| 2830 | if (nvram_match(mode, "a-only")) { |
|---|
| 2831 | rate = ag_rates; |
|---|
| 2832 | len = sizeof(ag_rates) / sizeof(char *); |
|---|
| 2833 | if (nvram_match(bw, "40")) { |
|---|
| 2834 | showrates = turbo_rates; |
|---|
| 2835 | } |
|---|
| 2836 | if (nvram_match(bw, "10")) { |
|---|
| 2837 | rate = half_rates; |
|---|
| 2838 | len = sizeof(half_rates) / sizeof(char *); |
|---|
| 2839 | } |
|---|
| 2840 | if (nvram_match(bw, "5")) { |
|---|
| 2841 | rate = quarter_rates; |
|---|
| 2842 | len = sizeof(quarter_rates) / sizeof(char *); |
|---|
| 2843 | } |
|---|
| 2844 | if (nvram_match(bw, "2")) { |
|---|
| 2845 | rate = subquarter_rates; |
|---|
| 2846 | len = sizeof(subquarter_rates) / sizeof(char *); |
|---|
| 2847 | } |
|---|
| 2848 | } |
|---|
| 2849 | if (nvram_match(mode, "bg-mixed")) { |
|---|
| 2850 | rate = bg_rates; |
|---|
| 2851 | len = sizeof(bg_rates) / sizeof(char *); |
|---|
| 2852 | if (nvram_match(bw, "10")) { |
|---|
| 2853 | rate = half_rates; |
|---|
| 2854 | len = sizeof(half_rates) / sizeof(char *); |
|---|
| 2855 | } |
|---|
| 2856 | if (nvram_match(bw, "5")) { |
|---|
| 2857 | rate = quarter_rates; |
|---|
| 2858 | len = sizeof(quarter_rates) / sizeof(char *); |
|---|
| 2859 | } |
|---|
| 2860 | if (nvram_match(bw, "2")) { |
|---|
| 2861 | rate = subquarter_rates; |
|---|
| 2862 | len = sizeof(subquarter_rates) / sizeof(char *); |
|---|
| 2863 | } |
|---|
| 2864 | } |
|---|
| 2865 | if (nvram_match(mode, "mixed")) { |
|---|
| 2866 | rate = bg_rates; |
|---|
| 2867 | len = sizeof(bg_rates) / sizeof(char *); |
|---|
| 2868 | if (nvram_match(bw, "40")) { |
|---|
| 2869 | rate = ag_rates; |
|---|
| 2870 | len = sizeof(ag_rates) / sizeof(char *); |
|---|
| 2871 | showrates = turbo_rates; |
|---|
| 2872 | } |
|---|
| 2873 | if (nvram_match(bw, "10")) { |
|---|
| 2874 | rate = half_rates; |
|---|
| 2875 | len = sizeof(half_rates) / sizeof(char *); |
|---|
| 2876 | } |
|---|
| 2877 | if (nvram_match(bw, "5")) { |
|---|
| 2878 | rate = quarter_rates; |
|---|
| 2879 | len = sizeof(quarter_rates) / sizeof(char *); |
|---|
| 2880 | } |
|---|
| 2881 | if (nvram_match(bw, "2")) { |
|---|
| 2882 | rate = subquarter_rates; |
|---|
| 2883 | len = sizeof(subquarter_rates) / sizeof(char *); |
|---|
| 2884 | } |
|---|
| 2885 | } |
|---|
| 2886 | int i; |
|---|
| 2887 | |
|---|
| 2888 | for (i = 0; i < len; i++) { |
|---|
| 2889 | if (maxrate) { |
|---|
| 2890 | int offset = 0; |
|---|
| 2891 | |
|---|
| 2892 | if (nvram_match(mode, "g-only") |
|---|
| 2893 | && nvram_match(bw, "20")) |
|---|
| 2894 | offset = 4; |
|---|
| 2895 | char comp[32]; |
|---|
| 2896 | |
|---|
| 2897 | sprintf(comp, "%d", i + 1 + offset); |
|---|
| 2898 | if (showrates) |
|---|
| 2899 | websWrite(wp, |
|---|
| 2900 | "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 2901 | i + 1 + offset, nvram_match(mxrate, |
|---|
| 2902 | comp) ? |
|---|
| 2903 | "selected=\"selected\"" : "", |
|---|
| 2904 | showrates[i]); |
|---|
| 2905 | else |
|---|
| 2906 | websWrite(wp, |
|---|
| 2907 | "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 2908 | i + 1 + offset, nvram_match(mxrate, |
|---|
| 2909 | comp) ? |
|---|
| 2910 | "selected=\"selected\"" : "", |
|---|
| 2911 | rate[i]); |
|---|
| 2912 | } else { |
|---|
| 2913 | int offset = 0; |
|---|
| 2914 | |
|---|
| 2915 | if (nvram_match(mode, "g-only") |
|---|
| 2916 | && nvram_match(bw, "20")) |
|---|
| 2917 | offset = 4; |
|---|
| 2918 | char comp[32]; |
|---|
| 2919 | |
|---|
| 2920 | sprintf(comp, "%d", i + 1 + offset); |
|---|
| 2921 | if (showrates) |
|---|
| 2922 | websWrite(wp, |
|---|
| 2923 | "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 2924 | i + 1 + offset, nvram_match(srate, |
|---|
| 2925 | comp) ? |
|---|
| 2926 | "selected=\"selected\"" : "", |
|---|
| 2927 | showrates[i]); |
|---|
| 2928 | else |
|---|
| 2929 | websWrite(wp, |
|---|
| 2930 | "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 2931 | i + 1 + offset, nvram_match(srate, |
|---|
| 2932 | comp) ? |
|---|
| 2933 | "selected=\"selected\"" : "", |
|---|
| 2934 | rate[i]); |
|---|
| 2935 | |
|---|
| 2936 | } |
|---|
| 2937 | } |
|---|
| 2938 | websWrite(wp, "</select>\n"); |
|---|
| 2939 | websWrite(wp, "<span class=\"default\">\n"); |
|---|
| 2940 | websWrite(wp, "<script type=\"text/javascript\">\n"); |
|---|
| 2941 | websWrite(wp, "//<![CDATA[\n"); |
|---|
| 2942 | websWrite(wp, |
|---|
| 2943 | "document.write(\"(\" + share.deflt + \": \" + share.auto + \")\");\n"); |
|---|
| 2944 | websWrite(wp, "//]]\n"); |
|---|
| 2945 | websWrite(wp, "</script></span></div>\n"); |
|---|
| 2946 | |
|---|
| 2947 | } |
|---|
| 2948 | #endif |
|---|
| 2949 | static void show_netmode(webs_t wp, char *prefix) |
|---|
| 2950 | { |
|---|
| 2951 | char wl_net_mode[16]; |
|---|
| 2952 | |
|---|
| 2953 | sprintf(wl_net_mode, "%s_net_mode", prefix); |
|---|
| 2954 | |
|---|
| 2955 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2956 | websWrite(wp, |
|---|
| 2957 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label2)</script></div><select name=\"%s\">\n", |
|---|
| 2958 | wl_net_mode); |
|---|
| 2959 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 2960 | websWrite(wp, |
|---|
| 2961 | "document.write(\"<option value=\\\"disabled\\\" %s>\" + share.disabled + \"</option>\");\n", |
|---|
| 2962 | nvram_match(wl_net_mode, |
|---|
| 2963 | "disabled") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2964 | websWrite(wp, |
|---|
| 2965 | "document.write(\"<option value=\\\"mixed\\\" %s>\" + wl_basic.mixed + \"</option>\");\n", |
|---|
| 2966 | nvram_match(wl_net_mode, |
|---|
| 2967 | "mixed") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2968 | |
|---|
| 2969 | if (has_mimo(prefix) && has_2ghz(prefix)) { |
|---|
| 2970 | websWrite(wp, |
|---|
| 2971 | "document.write(\"<option value=\\\"bg-mixed\\\" %s>\" + wl_basic.bg + \"</option>\");\n", |
|---|
| 2972 | nvram_match(wl_net_mode, |
|---|
| 2973 | "bg-mixed") ? "selected=\\\"selected\\\"" |
|---|
| 2974 | : ""); |
|---|
| 2975 | } |
|---|
| 2976 | #ifdef HAVE_WHRAG108 |
|---|
| 2977 | if (!strcmp(prefix, "ath1")) |
|---|
| 2978 | #endif |
|---|
| 2979 | #ifdef HAVE_TW6600 |
|---|
| 2980 | if (!strcmp(prefix, "ath1")) |
|---|
| 2981 | #endif |
|---|
| 2982 | |
|---|
| 2983 | if (has_2ghz(prefix)) { |
|---|
| 2984 | websWrite(wp, |
|---|
| 2985 | "document.write(\"<option value=\\\"b-only\\\" %s>\" + wl_basic.b + \"</option>\");\n", |
|---|
| 2986 | nvram_match(wl_net_mode, |
|---|
| 2987 | "b-only") ? |
|---|
| 2988 | "selected=\\\"selected\\\"" : ""); |
|---|
| 2989 | } |
|---|
| 2990 | #ifdef HAVE_MADWIFI |
|---|
| 2991 | if (has_2ghz(prefix)) { |
|---|
| 2992 | |
|---|
| 2993 | #ifdef HAVE_WHRAG108 |
|---|
| 2994 | if (!strcmp(prefix, "ath1")) |
|---|
| 2995 | #endif |
|---|
| 2996 | #ifdef HAVE_TW6600 |
|---|
| 2997 | if (!strcmp(prefix, "ath1")) |
|---|
| 2998 | #endif |
|---|
| 2999 | websWrite(wp, |
|---|
| 3000 | "document.write(\"<option value=\\\"g-only\\\" %s>\" + wl_basic.g + \"</option>\");\n", |
|---|
| 3001 | nvram_match(wl_net_mode, |
|---|
| 3002 | "g-only") ? |
|---|
| 3003 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3004 | #ifdef HAVE_WHRAG108 |
|---|
| 3005 | if (!strcmp(prefix, "ath1")) |
|---|
| 3006 | #endif |
|---|
| 3007 | #ifdef HAVE_TW6600 |
|---|
| 3008 | if (!strcmp(prefix, "ath1")) |
|---|
| 3009 | #endif |
|---|
| 3010 | #if !defined(HAVE_LS5) || defined(HAVE_EOC5610) |
|---|
| 3011 | websWrite(wp, |
|---|
| 3012 | "document.write(\"<option value=\\\"bg-mixed\\\" %s>\" + wl_basic.bg + \"</option>\");\n", |
|---|
| 3013 | nvram_match(wl_net_mode, |
|---|
| 3014 | "bg-mixed") ? |
|---|
| 3015 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3016 | #endif |
|---|
| 3017 | } |
|---|
| 3018 | #else |
|---|
| 3019 | #ifdef HAVE_WHRAG108 |
|---|
| 3020 | if (!strcmp(prefix, "ath1")) |
|---|
| 3021 | #endif |
|---|
| 3022 | #if !defined(HAVE_LS5) || defined(HAVE_EOC5610) |
|---|
| 3023 | |
|---|
| 3024 | if (has_2ghz(prefix)) { |
|---|
| 3025 | websWrite(wp, |
|---|
| 3026 | "document.write(\"<option value=\\\"g-only\\\" %s>\" + wl_basic.g + \"</option>\");\n", |
|---|
| 3027 | nvram_match(wl_net_mode, |
|---|
| 3028 | "g-only") ? |
|---|
| 3029 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3030 | } |
|---|
| 3031 | if (has_mimo(prefix) && has_2ghz(prefix)) { |
|---|
| 3032 | websWrite(wp, |
|---|
| 3033 | "document.write(\"<option value=\\\"ng-only\\\" %s>\" + wl_basic.ng + \"</option>\");\n", |
|---|
| 3034 | nvram_match(wl_net_mode, |
|---|
| 3035 | "ng-only") ? |
|---|
| 3036 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3037 | } |
|---|
| 3038 | #endif |
|---|
| 3039 | #endif |
|---|
| 3040 | if (has_mimo(prefix)) { |
|---|
| 3041 | if (has_5ghz(prefix)) { |
|---|
| 3042 | websWrite(wp, |
|---|
| 3043 | "document.write(\"<option value=\\\"n2-only\\\" %s>\" + wl_basic.n2 + \"</option>\");\n", |
|---|
| 3044 | nvram_match(wl_net_mode, |
|---|
| 3045 | "n2-only") ? |
|---|
| 3046 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3047 | } else { |
|---|
| 3048 | websWrite(wp, |
|---|
| 3049 | "document.write(\"<option value=\\\"n-only\\\" %s>\" + wl_basic.n + \"</option>\");\n", |
|---|
| 3050 | nvram_match(wl_net_mode, |
|---|
| 3051 | "n-only") ? |
|---|
| 3052 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3053 | } |
|---|
| 3054 | } |
|---|
| 3055 | #if !defined(HAVE_FONERA) && !defined(HAVE_LS2) && !defined(HAVE_MERAKI) |
|---|
| 3056 | #ifndef HAVE_MADWIFI |
|---|
| 3057 | |
|---|
| 3058 | if (has_5ghz(prefix)) { |
|---|
| 3059 | websWrite(wp, |
|---|
| 3060 | "document.write(\"<option value=\\\"a-only\\\" %s>\" + wl_basic.a + \"</option>\");\n", |
|---|
| 3061 | nvram_match(wl_net_mode, |
|---|
| 3062 | "a-only") ? |
|---|
| 3063 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3064 | } |
|---|
| 3065 | if (has_mimo(prefix) && has_5ghz(prefix)) { |
|---|
| 3066 | websWrite(wp, |
|---|
| 3067 | "document.write(\"<option value=\\\"na-only\\\" %s>\" + wl_basic.na + \"</option>\");\n", |
|---|
| 3068 | nvram_match(wl_net_mode, |
|---|
| 3069 | "na-only") ? |
|---|
| 3070 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3071 | websWrite(wp, |
|---|
| 3072 | "document.write(\"<option value=\\\"n5-only\\\" %s>\" + wl_basic.n5 + \"</option>\");\n", |
|---|
| 3073 | nvram_match(wl_net_mode, |
|---|
| 3074 | "n5-only") ? |
|---|
| 3075 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3076 | } |
|---|
| 3077 | #else |
|---|
| 3078 | #if HAVE_WHRAG108 |
|---|
| 3079 | if (!strcmp(prefix, "ath0")) |
|---|
| 3080 | #endif |
|---|
| 3081 | #ifdef HAVE_TW6600 |
|---|
| 3082 | if (!strcmp(prefix, "ath0")) |
|---|
| 3083 | #endif |
|---|
| 3084 | if (has_5ghz(prefix)) { |
|---|
| 3085 | websWrite(wp, |
|---|
| 3086 | "document.write(\"<option value=\\\"a-only\\\" %s>\" + wl_basic.a + \"</option>\");\n", |
|---|
| 3087 | nvram_match(wl_net_mode, |
|---|
| 3088 | "a-only") ? |
|---|
| 3089 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3090 | } |
|---|
| 3091 | #endif |
|---|
| 3092 | |
|---|
| 3093 | #endif |
|---|
| 3094 | #ifdef HAVE_MADWIFI_MIMO |
|---|
| 3095 | if (is_ar5008(prefix)) { |
|---|
| 3096 | if (has_2ghz(prefix)) { |
|---|
| 3097 | websWrite(wp, |
|---|
| 3098 | "document.write(\"<option value=\\\"ng-only\\\" %s>\" + wl_basic.ng + \"</option>\");\n", |
|---|
| 3099 | nvram_match(wl_net_mode, |
|---|
| 3100 | "ng-only") ? |
|---|
| 3101 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3102 | websWrite(wp, |
|---|
| 3103 | "document.write(\"<option value=\\\"n2-only\\\" %s>\" + wl_basic.n2 + \"</option>\");\n", |
|---|
| 3104 | nvram_match(wl_net_mode, |
|---|
| 3105 | "n2-only") ? |
|---|
| 3106 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3107 | } |
|---|
| 3108 | if (has_5ghz(prefix)) { |
|---|
| 3109 | websWrite(wp, |
|---|
| 3110 | "document.write(\"<option value=\\\"na-only\\\" %s>\" + wl_basic.na + \"</option>\");\n", |
|---|
| 3111 | nvram_match(wl_net_mode, |
|---|
| 3112 | "na-only") ? |
|---|
| 3113 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3114 | websWrite(wp, |
|---|
| 3115 | "document.write(\"<option value=\\\"n5-only\\\" %s>\" + wl_basic.n5 + \"</option>\");\n", |
|---|
| 3116 | nvram_match(wl_net_mode, |
|---|
| 3117 | "n5-only") ? |
|---|
| 3118 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3119 | } |
|---|
| 3120 | } |
|---|
| 3121 | #endif |
|---|
| 3122 | |
|---|
| 3123 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3124 | websWrite(wp, "</select>\n"); |
|---|
| 3125 | websWrite(wp, "</div>\n"); |
|---|
| 3126 | |
|---|
| 3127 | #ifdef HAVE_RT2880 |
|---|
| 3128 | if (nvram_nmatch("n-only", "%s_net_mode", prefix)) { |
|---|
| 3129 | char wl_greenfield[32]; |
|---|
| 3130 | |
|---|
| 3131 | sprintf(wl_greenfield, "%s_greenfield", prefix); |
|---|
| 3132 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3133 | websWrite(wp, |
|---|
| 3134 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label7)</script></div><select name=\"%s\" >\n", |
|---|
| 3135 | wl_greenfield); |
|---|
| 3136 | websWrite(wp, |
|---|
| 3137 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3138 | websWrite(wp, |
|---|
| 3139 | "document.write(\"<option value=\\\"0\\\" %s>\" + wl_basic.mixed + \"</option>\");\n", |
|---|
| 3140 | nvram_default_match(wl_greenfield, "0", |
|---|
| 3141 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3142 | : ""); |
|---|
| 3143 | websWrite(wp, |
|---|
| 3144 | "document.write(\"<option value=\\\"1\\\" %s>\" + wl_basic.greenfield + \"</option>\");\n", |
|---|
| 3145 | nvram_default_match(wl_greenfield, "1", |
|---|
| 3146 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3147 | : ""); |
|---|
| 3148 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3149 | websWrite(wp, "</select>\n"); |
|---|
| 3150 | websWrite(wp, "</div>\n"); |
|---|
| 3151 | } |
|---|
| 3152 | #endif |
|---|
| 3153 | } |
|---|
| 3154 | |
|---|
| 3155 | #ifdef HAVE_MADWIFI |
|---|
| 3156 | static void showrtssettings(webs_t wp, char *var) |
|---|
| 3157 | { |
|---|
| 3158 | char ssid[32]; |
|---|
| 3159 | char vvar[32]; |
|---|
| 3160 | |
|---|
| 3161 | strcpy(vvar, var); |
|---|
| 3162 | rep(vvar, '.', 'X'); |
|---|
| 3163 | sprintf(ssid, "%s_rts", var); |
|---|
| 3164 | websWrite(wp, |
|---|
| 3165 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.rts)</script></div>\n"); |
|---|
| 3166 | websWrite(wp, |
|---|
| 3167 | "<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", |
|---|
| 3168 | vvar, var, nvram_default_match(ssid, "1", |
|---|
| 3169 | "0") ? "checked=\"checked\"" : |
|---|
| 3170 | ""); |
|---|
| 3171 | websWrite(wp, |
|---|
| 3172 | "<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", |
|---|
| 3173 | vvar, var, nvram_default_match(ssid, "0", |
|---|
| 3174 | "0") ? "checked=\"checked\"" : |
|---|
| 3175 | ""); |
|---|
| 3176 | websWrite(wp, "</div>\n"); |
|---|
| 3177 | |
|---|
| 3178 | websWrite(wp, "<div id=\"%s_idrts\">\n", vvar); |
|---|
| 3179 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3180 | websWrite(wp, |
|---|
| 3181 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.rtsvalue)</script></div>\n"); |
|---|
| 3182 | char ip[32]; |
|---|
| 3183 | |
|---|
| 3184 | sprintf(ip, "%s_rtsvalue", var); |
|---|
| 3185 | websWrite(wp, |
|---|
| 3186 | "<input class=\"num\" maxlength=\"4\" size=\"4\" onblur=\"valid_range(this,1,2346,share.ip)\" name=\"%s_rtsvalue\" value=\"%s\" />", |
|---|
| 3187 | var, nvram_default_get(ip, "2346")); |
|---|
| 3188 | websWrite(wp, "</div>\n"); |
|---|
| 3189 | websWrite(wp, "</div>\n"); |
|---|
| 3190 | |
|---|
| 3191 | websWrite(wp, "<script>\n//<![CDATA[\n "); |
|---|
| 3192 | websWrite(wp, |
|---|
| 3193 | "show_layer_ext(document.getElementsByName(\"%s_rts\"), \"%s_idrts\", %s);\n", |
|---|
| 3194 | var, vvar, nvram_match(ssid, "1") ? "true" : "false"); |
|---|
| 3195 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3196 | |
|---|
| 3197 | } |
|---|
| 3198 | #endif |
|---|
| 3199 | static void showbridgesettings(webs_t wp, char *var, int mcast, int dual) |
|---|
| 3200 | { |
|---|
| 3201 | |
|---|
| 3202 | char ssid[32]; |
|---|
| 3203 | |
|---|
| 3204 | sprintf(ssid, "%s_bridged", var); |
|---|
| 3205 | char vvar[32]; |
|---|
| 3206 | |
|---|
| 3207 | strcpy(vvar, var); |
|---|
| 3208 | rep(vvar, '.', 'X'); |
|---|
| 3209 | websWrite(wp, |
|---|
| 3210 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.network)</script></div>\n"); |
|---|
| 3211 | websWrite(wp, |
|---|
| 3212 | "<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", |
|---|
| 3213 | vvar, var, nvram_default_match(ssid, "0", |
|---|
| 3214 | "1") ? "checked=\"checked\"" : |
|---|
| 3215 | ""); |
|---|
| 3216 | websWrite(wp, |
|---|
| 3217 | "<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", |
|---|
| 3218 | vvar, var, nvram_default_match(ssid, "1", |
|---|
| 3219 | "1") ? "checked=\"checked\"" : |
|---|
| 3220 | ""); |
|---|
| 3221 | websWrite(wp, "</div>\n"); |
|---|
| 3222 | |
|---|
| 3223 | websWrite(wp, "<div id=\"%s_idnetvifs\">\n", vvar); |
|---|
| 3224 | if (mcast) { |
|---|
| 3225 | char mcastvar[32]; |
|---|
| 3226 | |
|---|
| 3227 | sprintf(mcastvar, "%s_multicast", var); |
|---|
| 3228 | nvram_default_get(mcastvar, "0"); |
|---|
| 3229 | showRadio(wp, "wl_basic.multicast", mcastvar); |
|---|
| 3230 | } |
|---|
| 3231 | if (has_gateway()) { |
|---|
| 3232 | char natvar[32]; |
|---|
| 3233 | sprintf(natvar, "%s_nat", var); |
|---|
| 3234 | nvram_default_get(natvar, "1"); |
|---|
| 3235 | showRadio(wp, "wl_basic.masquerade", natvar); |
|---|
| 3236 | } |
|---|
| 3237 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3238 | websWrite(wp, |
|---|
| 3239 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.ip)</script></div>\n"); |
|---|
| 3240 | char ip[32]; |
|---|
| 3241 | |
|---|
| 3242 | sprintf(ip, "%s_ipaddr", var); |
|---|
| 3243 | char *ipv = nvram_safe_get(ip); |
|---|
| 3244 | |
|---|
| 3245 | websWrite(wp, |
|---|
| 3246 | "<input type=\"hidden\" name=\"%s_ipaddr\" value=\"4\" />\n", |
|---|
| 3247 | var); |
|---|
| 3248 | websWrite(wp, |
|---|
| 3249 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,1,223,share.ip)\" name=\"%s_ipaddr_0\" value=\"%d\" />.", |
|---|
| 3250 | var, get_single_ip(ipv, 0)); |
|---|
| 3251 | websWrite(wp, |
|---|
| 3252 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_1\" value=\"%d\" />.", |
|---|
| 3253 | var, get_single_ip(ipv, 1)); |
|---|
| 3254 | websWrite(wp, |
|---|
| 3255 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_2\" value=\"%d\" />.", |
|---|
| 3256 | var, get_single_ip(ipv, 2)); |
|---|
| 3257 | websWrite(wp, |
|---|
| 3258 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_3\" value=\"%d\" />\n", |
|---|
| 3259 | var, get_single_ip(ipv, 3)); |
|---|
| 3260 | websWrite(wp, "</div>\n"); |
|---|
| 3261 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3262 | websWrite(wp, |
|---|
| 3263 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.subnet)</script></div>\n"); |
|---|
| 3264 | sprintf(ip, "%s_netmask", var); |
|---|
| 3265 | ipv = nvram_safe_get(ip); |
|---|
| 3266 | |
|---|
| 3267 | websWrite(wp, |
|---|
| 3268 | "<input type=\"hidden\" name=\"%s_netmask\" value=\"4\" />\n", |
|---|
| 3269 | var); |
|---|
| 3270 | websWrite(wp, |
|---|
| 3271 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_0\" value=\"%d\" />.", |
|---|
| 3272 | var, get_single_ip(ipv, 0)); |
|---|
| 3273 | websWrite(wp, |
|---|
| 3274 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_1\" value=\"%d\" />.", |
|---|
| 3275 | var, get_single_ip(ipv, 1)); |
|---|
| 3276 | websWrite(wp, |
|---|
| 3277 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_2\" value=\"%d\" />.", |
|---|
| 3278 | var, get_single_ip(ipv, 2)); |
|---|
| 3279 | websWrite(wp, |
|---|
| 3280 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_3\" value=\"%d\" />.", |
|---|
| 3281 | var, get_single_ip(ipv, 3)); |
|---|
| 3282 | websWrite(wp, "</div>\n"); |
|---|
| 3283 | |
|---|
| 3284 | #ifdef HAVE_MADWIFI |
|---|
| 3285 | /*if (dual) |
|---|
| 3286 | { |
|---|
| 3287 | char dl[32]; |
|---|
| 3288 | sprintf(dl,"%s_duallink",var); |
|---|
| 3289 | websWrite( wp, |
|---|
| 3290 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.duallink)</script></div>\n" ); |
|---|
| 3291 | websWrite( wp, |
|---|
| 3292 | "<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", |
|---|
| 3293 | var, var, nvram_default_match( dl, "1", |
|---|
| 3294 | "0" ) ? "checked=\"checked\"" : |
|---|
| 3295 | "" ); |
|---|
| 3296 | websWrite( wp, |
|---|
| 3297 | "<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", |
|---|
| 3298 | var, var, nvram_default_match( dl, "0", |
|---|
| 3299 | "0" ) ? "checked=\"checked\"" : |
|---|
| 3300 | "" ); |
|---|
| 3301 | websWrite( wp, "</div>\n" ); |
|---|
| 3302 | |
|---|
| 3303 | websWrite( wp, "<div id=\"%s_iddualink\">\n", var ); |
|---|
| 3304 | |
|---|
| 3305 | sprintf( ip, "%s_duallink_parent", var ); |
|---|
| 3306 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3307 | websWrite( wp,"<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.parent)</script></div>\n" ); |
|---|
| 3308 | ipv = nvram_default_get( ip,"0.0.0.0" ); |
|---|
| 3309 | websWrite( wp, |
|---|
| 3310 | "<input type=\"hidden\" name=\"%s_duallink_parent\" value=\"4\" />\n", |
|---|
| 3311 | var ); |
|---|
| 3312 | websWrite( wp, |
|---|
| 3313 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_duallink_parent_0\" value=\"%d\" />.", |
|---|
| 3314 | var, get_single_ip( ipv, 0 ) ); |
|---|
| 3315 | websWrite( wp, |
|---|
| 3316 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_duallink_parent_1\" value=\"%d\" />.", |
|---|
| 3317 | var, get_single_ip( ipv, 1 ) ); |
|---|
| 3318 | websWrite( wp, |
|---|
| 3319 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_duallink_parent_2\" value=\"%d\" />.", |
|---|
| 3320 | var, get_single_ip( ipv, 2 ) ); |
|---|
| 3321 | websWrite( wp, |
|---|
| 3322 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_duallink_parent_3\" value=\"%d\" />.", |
|---|
| 3323 | var, get_single_ip( ipv, 3 ) ); |
|---|
| 3324 | websWrite( wp, "</div>\n" ); |
|---|
| 3325 | |
|---|
| 3326 | websWrite( wp, "</div>\n" ); |
|---|
| 3327 | |
|---|
| 3328 | websWrite( wp, "<script>\n//<![CDATA[\n " ); |
|---|
| 3329 | websWrite( wp, |
|---|
| 3330 | "show_layer_ext(document.getElementsByName(\"%s_duallink\"), \"%s_idduallink\", %s);\n", |
|---|
| 3331 | var, vvar, nvram_match( dl, "1" ) ? "true" : "false" ); |
|---|
| 3332 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3333 | }*/ |
|---|
| 3334 | #endif |
|---|
| 3335 | |
|---|
| 3336 | websWrite(wp, "</div>\n"); |
|---|
| 3337 | |
|---|
| 3338 | websWrite(wp, "<script>\n//<![CDATA[\n "); |
|---|
| 3339 | websWrite(wp, |
|---|
| 3340 | "show_layer_ext(document.getElementsByName(\"%s_bridged\"), \"%s_idnetvifs\", %s);\n", |
|---|
| 3341 | var, vvar, nvram_match(ssid, "0") ? "true" : "false"); |
|---|
| 3342 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3343 | |
|---|
| 3344 | } |
|---|
| 3345 | |
|---|
| 3346 | #ifdef HAVE_MADWIFI |
|---|
| 3347 | static void show_chanshift(webs_t wp, char *prefix) |
|---|
| 3348 | { |
|---|
| 3349 | char wl_chanshift[32]; |
|---|
| 3350 | char wl_channelbw[32]; |
|---|
| 3351 | |
|---|
| 3352 | sprintf(wl_channelbw, "%s_channelbw", prefix); |
|---|
| 3353 | sprintf(wl_chanshift, "%s_chanshift", prefix); |
|---|
| 3354 | if (atoi(nvram_safe_get(wl_channelbw)) > 2 |
|---|
| 3355 | && (atoi(nvram_safe_get(wl_chanshift)) & 0xf) > 10) |
|---|
| 3356 | nvram_set(wl_chanshift, "10"); |
|---|
| 3357 | if (atoi(nvram_safe_get(wl_channelbw)) > 5 |
|---|
| 3358 | && (atoi(nvram_safe_get(wl_chanshift)) & 0xf) > 10) |
|---|
| 3359 | nvram_set(wl_chanshift, "10"); |
|---|
| 3360 | if (atoi(nvram_safe_get(wl_channelbw)) > 10 |
|---|
| 3361 | && (atoi(nvram_safe_get(wl_chanshift)) & 0xf) > 0) |
|---|
| 3362 | nvram_set(wl_chanshift, "0"); |
|---|
| 3363 | |
|---|
| 3364 | if (nvram_match(wl_channelbw, "5") |
|---|
| 3365 | || nvram_match(wl_channelbw, "10") |
|---|
| 3366 | || nvram_match(wl_channelbw, "2")) { |
|---|
| 3367 | |
|---|
| 3368 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3369 | websWrite(wp, |
|---|
| 3370 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.chanshift)</script></div>\n<select name=\"%s\">\n", |
|---|
| 3371 | wl_chanshift); |
|---|
| 3372 | websWrite(wp, |
|---|
| 3373 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3374 | if (nvram_match(wl_channelbw, "5") |
|---|
| 3375 | || nvram_match(wl_channelbw, "2")) |
|---|
| 3376 | websWrite(wp, |
|---|
| 3377 | "document.write(\"<option value=\\\"-15\\\" %s >-15 Mhz</option>\");\n", |
|---|
| 3378 | nvram_default_match(wl_chanshift, "-15", |
|---|
| 3379 | "0") ? |
|---|
| 3380 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3381 | if (nvram_match(wl_channelbw, "5") |
|---|
| 3382 | || nvram_match(wl_channelbw, "10") |
|---|
| 3383 | || nvram_match(wl_channelbw, "2")) |
|---|
| 3384 | websWrite(wp, |
|---|
| 3385 | "document.write(\"<option value=\\\"-10\\\" %s >-10 Mhz</option>\");\n", |
|---|
| 3386 | nvram_default_match(wl_chanshift, "-10", |
|---|
| 3387 | "0") ? |
|---|
| 3388 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3389 | if (nvram_match(wl_channelbw, "5") |
|---|
| 3390 | || nvram_match(wl_channelbw, "10") |
|---|
| 3391 | || nvram_match(wl_channelbw, "2")) |
|---|
| 3392 | websWrite(wp, |
|---|
| 3393 | "document.write(\"<option value=\\\"-5\\\" %s >-5 Mhz</option>\");\n", |
|---|
| 3394 | nvram_default_match(wl_chanshift, "-5", |
|---|
| 3395 | "0") ? |
|---|
| 3396 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3397 | websWrite(wp, |
|---|
| 3398 | "document.write(\"<option value=\\\"0\\\" %s >0 Mhz</option>\");\n", |
|---|
| 3399 | nvram_default_match(wl_chanshift, "0", |
|---|
| 3400 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3401 | : ""); |
|---|
| 3402 | if (nvram_match(wl_channelbw, "5") |
|---|
| 3403 | || nvram_match(wl_channelbw, "10") |
|---|
| 3404 | || nvram_match(wl_channelbw, "2")) |
|---|
| 3405 | websWrite(wp, |
|---|
| 3406 | "document.write(\"<option value=\\\"5\\\" %s >+5 Mhz</option>\");\n", |
|---|
| 3407 | nvram_default_match(wl_chanshift, "5", |
|---|
| 3408 | "0") ? |
|---|
| 3409 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3410 | if (nvram_match(wl_channelbw, "5") |
|---|
| 3411 | || nvram_match(wl_channelbw, "10") |
|---|
| 3412 | || nvram_match(wl_channelbw, "2")) |
|---|
| 3413 | websWrite(wp, |
|---|
| 3414 | "document.write(\"<option value=\\\"10\\\" %s >+10 Mhz</option>\");\n", |
|---|
| 3415 | nvram_default_match(wl_chanshift, "10", |
|---|
| 3416 | "0") ? |
|---|
| 3417 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3418 | if (nvram_match(wl_channelbw, "5") |
|---|
| 3419 | || nvram_match(wl_channelbw, "2")) |
|---|
| 3420 | websWrite(wp, |
|---|
| 3421 | "document.write(\"<option value=\\\"15\\\" %s >+15 Mhz</option>\");\n", |
|---|
| 3422 | nvram_default_match(wl_chanshift, "15", |
|---|
| 3423 | "0") ? |
|---|
| 3424 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3425 | websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 3426 | } |
|---|
| 3427 | } |
|---|
| 3428 | #endif |
|---|
| 3429 | static int show_virtualssid(webs_t wp, char *prefix) |
|---|
| 3430 | { |
|---|
| 3431 | char *next; |
|---|
| 3432 | char var[80]; |
|---|
| 3433 | char ssid[80]; |
|---|
| 3434 | char vif[16]; |
|---|
| 3435 | char power[32]; |
|---|
| 3436 | |
|---|
| 3437 | #ifdef HAVE_MADWIFI |
|---|
| 3438 | char wmm[32]; |
|---|
| 3439 | char wl_protmode[32]; |
|---|
| 3440 | #endif |
|---|
| 3441 | sprintf(vif, "%s_vifs", prefix); |
|---|
| 3442 | char *vifs = nvram_safe_get(vif); |
|---|
| 3443 | |
|---|
| 3444 | if (vifs == NULL) |
|---|
| 3445 | return 0; |
|---|
| 3446 | #ifndef HAVE_MADWIFI |
|---|
| 3447 | if (!nvram_nmatch("ap", "%s_mode", prefix) |
|---|
| 3448 | && !nvram_nmatch("apsta", "%s_mode", prefix) |
|---|
| 3449 | && !nvram_nmatch("apstawet", "%s_mode", prefix)) |
|---|
| 3450 | return 0; |
|---|
| 3451 | #endif |
|---|
| 3452 | int count = 1; |
|---|
| 3453 | |
|---|
| 3454 | websWrite(wp, |
|---|
| 3455 | "<h2><script type=\"text/javascript\">Capture(wl_basic.h2_vi)</script></h2>\n"); |
|---|
| 3456 | foreach(var, vifs, next) { |
|---|
| 3457 | sprintf(ssid, "%s_ssid", var); |
|---|
| 3458 | websWrite(wp, |
|---|
| 3459 | "<fieldset><legend><script type=\"text/javascript\">Capture(share.vintrface)</script> %s SSID [", |
|---|
| 3460 | IFMAP(var)); |
|---|
| 3461 | tf_webWriteESCNV(wp, ssid); // fix for broken html page if ssid |
|---|
| 3462 | // contains html tag |
|---|
| 3463 | websWrite(wp, "]</legend>\n"); |
|---|
| 3464 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3465 | websWrite(wp, |
|---|
| 3466 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label3)</script></div>\n"); |
|---|
| 3467 | |
|---|
| 3468 | websWrite(wp, |
|---|
| 3469 | "<input name=\"%s_ssid\" size=\"20\" maxlength=\"32\" onblur=\"valid_name(this,wl_basic.label3)\" value=\"%s\" /></div>\n", |
|---|
| 3470 | var, nvram_safe_get(ssid)); |
|---|
| 3471 | |
|---|
| 3472 | #ifdef HAVE_MADWIFI |
|---|
| 3473 | // sprintf( wl_chanshift, "%s_chanshift", var ); |
|---|
| 3474 | // show_chanshift( wp, wl_chanshift ); |
|---|
| 3475 | |
|---|
| 3476 | sprintf(wl_protmode, "%s_protmode", var); |
|---|
| 3477 | showOptionsLabel(wp, "wl_basic.protmode", wl_protmode, |
|---|
| 3478 | "None CTS RTS/CTS", |
|---|
| 3479 | nvram_default_get(wl_protmode, "None")); |
|---|
| 3480 | showrtssettings(wp, var); |
|---|
| 3481 | #endif |
|---|
| 3482 | |
|---|
| 3483 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3484 | websWrite(wp, |
|---|
| 3485 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label5)</script></div>"); |
|---|
| 3486 | sprintf(ssid, "%s_closed", var); |
|---|
| 3487 | websWrite(wp, |
|---|
| 3488 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s_closed\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input> \n", |
|---|
| 3489 | var, nvram_match(ssid, |
|---|
| 3490 | "0") ? "checked=\"checked\"" : ""); |
|---|
| 3491 | websWrite(wp, |
|---|
| 3492 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s_closed\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input>\n", |
|---|
| 3493 | var, nvram_match(ssid, |
|---|
| 3494 | "1") ? "checked=\"checked\"" : ""); |
|---|
| 3495 | websWrite(wp, "</div>\n"); |
|---|
| 3496 | char wl_mode[16]; |
|---|
| 3497 | |
|---|
| 3498 | #ifdef HAVE_MADWIFI |
|---|
| 3499 | sprintf(wl_mode, "%s_mode", var); |
|---|
| 3500 | websWrite(wp, |
|---|
| 3501 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label)</script></div><select name=\"%s\" >\n", |
|---|
| 3502 | wl_mode); |
|---|
| 3503 | websWrite(wp, |
|---|
| 3504 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3505 | websWrite(wp, |
|---|
| 3506 | "document.write(\"<option value=\\\"ap\\\" %s >\" + wl_basic.ap + \"</option>\");\n", |
|---|
| 3507 | nvram_match(wl_mode, |
|---|
| 3508 | "ap") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3509 | // websWrite (wp, |
|---|
| 3510 | // "document.write(\"<option value=\\\"wdssta\\\" %s >\" + |
|---|
| 3511 | // wl_basic.wdssta + \"</option>\");\n", |
|---|
| 3512 | // nvram_match (wl_mode, |
|---|
| 3513 | // "wdssta") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3514 | websWrite(wp, |
|---|
| 3515 | "document.write(\"<option value=\\\"wdsap\\\" %s >\" + wl_basic.wdsap + \"</option>\");\n", |
|---|
| 3516 | nvram_match(wl_mode, |
|---|
| 3517 | "wdsap") ? "selected=\\\"selected\\\"" : |
|---|
| 3518 | ""); |
|---|
| 3519 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3520 | websWrite(wp, "</select>\n"); |
|---|
| 3521 | websWrite(wp, "</div>\n"); |
|---|
| 3522 | sprintf(wmm, "%s_wmm", var); |
|---|
| 3523 | showRadio(wp, "wl_adv.label18", wmm); |
|---|
| 3524 | #endif |
|---|
| 3525 | sprintf(ssid, "%s_ap_isolate", var); |
|---|
| 3526 | showRadio(wp, "wl_adv.label11", ssid); |
|---|
| 3527 | #ifdef HAVE_MADWIFI |
|---|
| 3528 | |
|---|
| 3529 | if (nvram_nmatch("ap", "%s_mode", var) |
|---|
| 3530 | || nvram_nmatch("wdsap", "%s_mode", var) |
|---|
| 3531 | || nvram_nmatch("infra", "%s_mode", var)) { |
|---|
| 3532 | sprintf(power, "%s_maxassoc", var); |
|---|
| 3533 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3534 | websWrite(wp, |
|---|
| 3535 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label10)</script></div>\n"); |
|---|
| 3536 | websWrite(wp, |
|---|
| 3537 | "<input class=\"num\" name=\"%s\" size=\"4\" maxlength=\"4\" onblur=\"valid_range(this,0,256,wl_adv.label10)\" value=\"%s\" />\n", |
|---|
| 3538 | power, nvram_default_get(power, "256")); |
|---|
| 3539 | |
|---|
| 3540 | websWrite(wp, |
|---|
| 3541 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 256 \" + share.user + \")\");\n//]]>\n</script></span>\n"); |
|---|
| 3542 | websWrite(wp, "</div>\n"); |
|---|
| 3543 | } |
|---|
| 3544 | |
|---|
| 3545 | sprintf(power, "%s_mtikie", var); |
|---|
| 3546 | nvram_default_get(power, "0"); |
|---|
| 3547 | showRadio(wp, "wl_basic.mtikie", power); |
|---|
| 3548 | #endif |
|---|
| 3549 | #ifdef HAVE_RT2880 |
|---|
| 3550 | showbridgesettings(wp, getRADev(var), 1, 0); |
|---|
| 3551 | #else |
|---|
| 3552 | showbridgesettings(wp, var, 1, 0); |
|---|
| 3553 | #endif |
|---|
| 3554 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 3555 | count++; |
|---|
| 3556 | } |
|---|
| 3557 | |
|---|
| 3558 | websWrite(wp, "<div class=\"center\">\n"); |
|---|
| 3559 | #ifdef HAVE_MADWIFI |
|---|
| 3560 | if (count < 8) |
|---|
| 3561 | #elif HAVE_RT2880 |
|---|
| 3562 | if (count < 7) |
|---|
| 3563 | #else |
|---|
| 3564 | if (count < WL_MAXBSSCFG) |
|---|
| 3565 | #endif |
|---|
| 3566 | websWrite(wp, |
|---|
| 3567 | "<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", |
|---|
| 3568 | prefix); |
|---|
| 3569 | |
|---|
| 3570 | if (count > 1) |
|---|
| 3571 | websWrite(wp, |
|---|
| 3572 | "<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", |
|---|
| 3573 | prefix); |
|---|
| 3574 | |
|---|
| 3575 | websWrite(wp, "</div><br />\n"); |
|---|
| 3576 | |
|---|
| 3577 | return 0; |
|---|
| 3578 | } |
|---|
| 3579 | |
|---|
| 3580 | void ej_showad(webs_t wp, int argc, char_t ** argv) |
|---|
| 3581 | { |
|---|
| 3582 | #ifndef HAVE_FON |
|---|
| 3583 | #ifndef CONFIG_BRANDING |
|---|
| 3584 | #ifdef HAVE_CHILLI |
|---|
| 3585 | // if (nvram_invmatch ("fon_enable", "1")) |
|---|
| 3586 | // websWrite (wp, |
|---|
| 3587 | // "<a href=\"fon.cgi\"><img src=\"images/turn.gif\" border=0 /></a>"); |
|---|
| 3588 | #endif |
|---|
| 3589 | #endif |
|---|
| 3590 | #endif |
|---|
| 3591 | |
|---|
| 3592 | #ifndef HAVE_NOAD |
|---|
| 3593 | /* |
|---|
| 3594 | * if (nvram_match("wanup","1")) { websWrite(wp,"<script |
|---|
| 3595 | * type=\"text/javascript\"><!--\n//<![CDATA[\n "); |
|---|
| 3596 | * websWrite(wp,"google_ad_client = \"pub-8308593183433068\";\n"); |
|---|
| 3597 | * websWrite(wp,"google_ad_width = 728;\n"); |
|---|
| 3598 | * websWrite(wp,"google_ad_height = 90;\n"); |
|---|
| 3599 | * websWrite(wp,"google_ad_format = \"728x90_as\";\n"); |
|---|
| 3600 | * websWrite(wp,"google_ad_type = \"text_image\";\n"); |
|---|
| 3601 | * websWrite(wp,"google_ad_channel =\"8866414571\";\n"); |
|---|
| 3602 | * websWrite(wp,"google_color_border = \"333333\";\n"); |
|---|
| 3603 | * websWrite(wp,"google_color_bg = \"000000\";\n"); |
|---|
| 3604 | * websWrite(wp,"google_color_link = \"FFFFFF\";\n"); |
|---|
| 3605 | * websWrite(wp,"google_color_url = \"999999\";\n"); |
|---|
| 3606 | * websWrite(wp,"google_color_text = \"CCCCCC\";\n"); |
|---|
| 3607 | * websWrite(wp,"//-->//]]>\n</script>\n"); websWrite(wp,"<script |
|---|
| 3608 | * type=\"text/javascript\"\n"); websWrite(wp," |
|---|
| 3609 | * src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\n"); |
|---|
| 3610 | * websWrite(wp,"</script>\n"); } |
|---|
| 3611 | */ |
|---|
| 3612 | #endif |
|---|
| 3613 | return; |
|---|
| 3614 | } |
|---|
| 3615 | |
|---|
| 3616 | #ifndef HAVE_SUPERCHANNEL |
|---|
| 3617 | int inline issuperchannel(void) |
|---|
| 3618 | { |
|---|
| 3619 | #if defined(HAVE_MAKSAT) && defined(HAVE_MR3202A) |
|---|
| 3620 | return 0; |
|---|
| 3621 | #elif defined(HAVE_MAKSAT) && defined(HAVE_ALPHA) |
|---|
| 3622 | return 0; |
|---|
| 3623 | #elif HAVE_MAKSAT |
|---|
| 3624 | return 1; |
|---|
| 3625 | #else |
|---|
| 3626 | return 0; |
|---|
| 3627 | #endif |
|---|
| 3628 | } |
|---|
| 3629 | #endif |
|---|
| 3630 | |
|---|
| 3631 | void ej_show_countrylist(webs_t wp, int argc, char_t ** argv) |
|---|
| 3632 | { |
|---|
| 3633 | if (argc < 1) { |
|---|
| 3634 | return; |
|---|
| 3635 | } |
|---|
| 3636 | char *list = getCountryList(); |
|---|
| 3637 | |
|---|
| 3638 | showOptionsChoose(wp, argv[0], list, nvram_safe_get(argv[0])); |
|---|
| 3639 | } |
|---|
| 3640 | |
|---|
| 3641 | void ej_show_wireless_single(webs_t wp, char *prefix) |
|---|
| 3642 | { |
|---|
| 3643 | char wl_mode[16]; |
|---|
| 3644 | char wl_macaddr[16]; |
|---|
| 3645 | char wl_ssid[16]; |
|---|
| 3646 | |
|---|
| 3647 | sprintf(wl_mode, "%s_mode", prefix); |
|---|
| 3648 | sprintf(wl_macaddr, "%s_hwaddr", prefix); |
|---|
| 3649 | sprintf(wl_ssid, "%s_ssid", prefix); |
|---|
| 3650 | |
|---|
| 3651 | // wireless mode |
|---|
| 3652 | websWrite(wp, |
|---|
| 3653 | "<h2><script type=\"text/javascript\">Capture(wl_basic.h2_v24)</script> %s</h2>\n", |
|---|
| 3654 | prefix); |
|---|
| 3655 | websWrite(wp, "<fieldset>\n"); |
|---|
| 3656 | websWrite(wp, |
|---|
| 3657 | "<legend><script type=\"text/javascript\">Capture(share.pintrface)</script> %s - SSID [", |
|---|
| 3658 | IFMAP(prefix)); |
|---|
| 3659 | tf_webWriteESCNV(wp, wl_ssid); // fix |
|---|
| 3660 | websWrite(wp, "] HWAddr [%s]</legend>\n", nvram_safe_get(wl_macaddr)); |
|---|
| 3661 | char power[16]; |
|---|
| 3662 | |
|---|
| 3663 | // char maxpower[16]; |
|---|
| 3664 | #ifdef HAVE_MADWIFI |
|---|
| 3665 | #ifndef HAVE_MAKSAT |
|---|
| 3666 | #ifndef HAVE_DDLINK |
|---|
| 3667 | |
|---|
| 3668 | if (isXR36(prefix)) { |
|---|
| 3669 | char wl_cardtype[32]; |
|---|
| 3670 | sprintf(wl_cardtype, "%s_cardtype", prefix); |
|---|
| 3671 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3672 | websWrite(wp, |
|---|
| 3673 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.cardtype)</script></div>\n<select name=\"%s\">\n", |
|---|
| 3674 | wl_cardtype); |
|---|
| 3675 | websWrite(wp, |
|---|
| 3676 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3677 | websWrite(wp, |
|---|
| 3678 | "document.write(\"<option value=\\\"0\\\" %s >Ubiquiti XR3.3</option>\");\n", |
|---|
| 3679 | nvram_default_match(wl_cardtype, "0", |
|---|
| 3680 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3681 | : ""); |
|---|
| 3682 | websWrite(wp, |
|---|
| 3683 | "document.write(\"<option value=\\\"1\\\" %s >Ubiquiti XR3.6</option>\");\n", |
|---|
| 3684 | nvram_default_match(wl_cardtype, "1", |
|---|
| 3685 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3686 | : ""); |
|---|
| 3687 | websWrite(wp, |
|---|
| 3688 | "document.write(\"<option value=\\\"2\\\" %s >Ubiquiti XR3.7</option>\");\n", |
|---|
| 3689 | nvram_default_match(wl_cardtype, "2", |
|---|
| 3690 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3691 | : ""); |
|---|
| 3692 | websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 3693 | } |
|---|
| 3694 | |
|---|
| 3695 | if (isEMP(prefix)) { |
|---|
| 3696 | char wl_cardtype[32]; |
|---|
| 3697 | sprintf(wl_cardtype, "%s_cardtype", prefix); |
|---|
| 3698 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3699 | websWrite(wp, |
|---|
| 3700 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.cardtype)</script></div>\n<select name=\"%s\">\n", |
|---|
| 3701 | wl_cardtype); |
|---|
| 3702 | websWrite(wp, |
|---|
| 3703 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3704 | websWrite(wp, |
|---|
| 3705 | "document.write(\"<option value=\\\"0\\\" %s >Atheros Generic</option>\");\n", |
|---|
| 3706 | nvram_default_match(wl_cardtype, "0", |
|---|
| 3707 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3708 | : ""); |
|---|
| 3709 | websWrite(wp, |
|---|
| 3710 | "document.write(\"<option value=\\\"5\\\" %s >Alfa Networks AWPCI085H</option>\");\n", |
|---|
| 3711 | nvram_default_match(wl_cardtype, "5", |
|---|
| 3712 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3713 | : ""); |
|---|
| 3714 | websWrite(wp, |
|---|
| 3715 | "document.write(\"<option value=\\\"6\\\" %s >Alfa Networks AWPCI085P</option>\");\n", |
|---|
| 3716 | nvram_default_match(wl_cardtype, "6", |
|---|
| 3717 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3718 | : ""); |
|---|
| 3719 | websWrite(wp, |
|---|
| 3720 | "document.write(\"<option value=\\\"7\\\" %s >Doodle Labs DLM105</option>\");\n", |
|---|
| 3721 | nvram_default_match(wl_cardtype, "7", |
|---|
| 3722 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3723 | : ""); |
|---|
| 3724 | websWrite(wp, |
|---|
| 3725 | "document.write(\"<option value=\\\"4\\\" %s >MakSat MAK27</option>\");\n", |
|---|
| 3726 | nvram_default_match(wl_cardtype, "4", |
|---|
| 3727 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3728 | : ""); |
|---|
| 3729 | websWrite(wp, |
|---|
| 3730 | "document.write(\"<option value=\\\"1\\\" %s >Senao EMP-8602</option>\");\n", |
|---|
| 3731 | nvram_default_match(wl_cardtype, "1", |
|---|
| 3732 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3733 | : ""); |
|---|
| 3734 | websWrite(wp, |
|---|
| 3735 | "document.write(\"<option value=\\\"2\\\" %s >Senao EMP-8603-S</option>\");\n", |
|---|
| 3736 | nvram_default_match(wl_cardtype, "2", |
|---|
| 3737 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3738 | : ""); |
|---|
| 3739 | websWrite(wp, |
|---|
| 3740 | "document.write(\"<option value=\\\"3\\\" %s >Senao EMP-8603</option>\");\n", |
|---|
| 3741 | nvram_default_match(wl_cardtype, "3", |
|---|
| 3742 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3743 | : ""); |
|---|
| 3744 | websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 3745 | } |
|---|
| 3746 | #endif |
|---|
| 3747 | #endif // ! HAVE MAKSAT |
|---|
| 3748 | #ifndef HAVE_NOCOUNTRYSEL |
|---|
| 3749 | char wl_regdomain[16]; |
|---|
| 3750 | |
|---|
| 3751 | sprintf(wl_regdomain, "%s_regdomain", prefix); |
|---|
| 3752 | if (nvram_nmatch("1","%s_regulatory", prefix) || !issuperchannel()) { |
|---|
| 3753 | websWrite(wp, |
|---|
| 3754 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.regdom)</script></div>\n"); |
|---|
| 3755 | char *list = getCountryList(); |
|---|
| 3756 | |
|---|
| 3757 | showOptions(wp, wl_regdomain, list, |
|---|
| 3758 | nvram_safe_get(wl_regdomain)); |
|---|
| 3759 | websWrite(wp, "</div>\n"); |
|---|
| 3760 | } |
|---|
| 3761 | #endif // ! HAVE MAKSAT |
|---|
| 3762 | /* |
|---|
| 3763 | * while (regdomains[domcount].name != NULL) { char domcode[16]; sprintf |
|---|
| 3764 | * (domcode, "%d", regdomains[domcount].code); websWrite (wp, "<option |
|---|
| 3765 | * value=\"%d\" %s>%s</option>\n", regdomains[domcount].code, nvram_match |
|---|
| 3766 | * (wl_regdomain, domcode) ? " selected=\"selected\"" : "", |
|---|
| 3767 | * regdomains[domcount].name); domcount++; } websWrite (wp, |
|---|
| 3768 | * "</select>\n"); websWrite (wp, "</div>\n"); |
|---|
| 3769 | */ |
|---|
| 3770 | // power adjustment |
|---|
| 3771 | sprintf(power, "%s_txpwrdbm", prefix); |
|---|
| 3772 | // sprintf (maxpower, "%s_maxpower", prefix); |
|---|
| 3773 | if (issuperchannel()) // show |
|---|
| 3774 | // client |
|---|
| 3775 | // only on |
|---|
| 3776 | // first |
|---|
| 3777 | // interface |
|---|
| 3778 | { |
|---|
| 3779 | |
|---|
| 3780 | char regulatory[32]; |
|---|
| 3781 | sprintf(regulatory,"%s_regulatory",prefix); |
|---|
| 3782 | nvram_default_get(regulatory,"0"); |
|---|
| 3783 | websWrite(wp, " <div class=\"setting\">\n"); |
|---|
| 3784 | websWrite(wp, |
|---|
| 3785 | " <div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.regulatory)</script></div>\n"); |
|---|
| 3786 | websWrite(wp, |
|---|
| 3787 | " <input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s_regulatory\" %s /><script type=\"text/javascript\">Capture(share.enable)</script> \n",prefix, |
|---|
| 3788 | nvram_match(regulatory,"0") ? "checked" : ""); |
|---|
| 3789 | websWrite(wp, |
|---|
| 3790 | " <input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s_regulatory\" %s /><script type=\"text/javascript\">Capture(share.disable)</script>\n",prefix, |
|---|
| 3791 | nvram_match(regulatory,"1") ? "checked" : ""); |
|---|
| 3792 | websWrite(wp, " </div>\n"); |
|---|
| 3793 | |
|---|
| 3794 | } |
|---|
| 3795 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3796 | websWrite(wp, |
|---|
| 3797 | "<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", |
|---|
| 3798 | power, |
|---|
| 3799 | atoi(nvram_safe_get(power)) + wifi_gettxpoweroffset(prefix)); |
|---|
| 3800 | websWrite(wp, "</div>\n"); |
|---|
| 3801 | sprintf(power, "%s_antgain", prefix); |
|---|
| 3802 | #ifndef HAVE_MAKSAT |
|---|
| 3803 | if (nvram_nmatch("1","%s_regulatory", prefix)) |
|---|
| 3804 | #endif |
|---|
| 3805 | { |
|---|
| 3806 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3807 | websWrite(wp, |
|---|
| 3808 | "<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", |
|---|
| 3809 | power, nvram_safe_get(power)); |
|---|
| 3810 | websWrite(wp, "</div>\n"); |
|---|
| 3811 | } |
|---|
| 3812 | #endif |
|---|
| 3813 | |
|---|
| 3814 | #ifdef HAVE_MADWIFI |
|---|
| 3815 | // if (!strcmp (prefix, "ath0")) |
|---|
| 3816 | #endif |
|---|
| 3817 | { |
|---|
| 3818 | // #ifdef HAVE_MADWIFI |
|---|
| 3819 | // if (!strcmp (prefix, "ath0")) //show client only on first |
|---|
| 3820 | // interface |
|---|
| 3821 | // #endif |
|---|
| 3822 | { |
|---|
| 3823 | #ifdef HAVE_MADWIFI |
|---|
| 3824 | // if (!strcmp (prefix, "ath0")) //show client only on first |
|---|
| 3825 | // interface |
|---|
| 3826 | // if (nvram_match ("ath0_mode", "wdsap") |
|---|
| 3827 | // || nvram_match ("ath0_mode", "wdssta")) |
|---|
| 3828 | // showOption (wp, "wl_basic.wifi_bonding", "wifi_bonding"); |
|---|
| 3829 | #endif |
|---|
| 3830 | #ifdef HAVE_REGISTER |
|---|
| 3831 | int cpeonly = iscpe(); |
|---|
| 3832 | #else |
|---|
| 3833 | int cpeonly = 0; |
|---|
| 3834 | #endif |
|---|
| 3835 | websWrite(wp, |
|---|
| 3836 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label)</script></div><select name=\"%s\" >\n", |
|---|
| 3837 | wl_mode); |
|---|
| 3838 | websWrite(wp, |
|---|
| 3839 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3840 | if (!cpeonly) { |
|---|
| 3841 | websWrite(wp, |
|---|
| 3842 | "document.write(\"<option value=\\\"ap\\\" %s >\" + wl_basic.ap + \"</option>\");\n", |
|---|
| 3843 | nvram_match(wl_mode, |
|---|
| 3844 | "ap") ? |
|---|
| 3845 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3846 | } |
|---|
| 3847 | websWrite(wp, |
|---|
| 3848 | "document.write(\"<option value=\\\"sta\\\" %s >\" + wl_basic.client + \"</option>\");\n", |
|---|
| 3849 | nvram_match(wl_mode, |
|---|
| 3850 | "sta") ? |
|---|
| 3851 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3852 | #ifndef HAVE_RT2880 |
|---|
| 3853 | websWrite(wp, |
|---|
| 3854 | "document.write(\"<option value=\\\"wet\\\" %s >\" + wl_basic.clientBridge + \"</option>\");\n", |
|---|
| 3855 | nvram_match(wl_mode, |
|---|
| 3856 | "wet") ? |
|---|
| 3857 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3858 | #endif |
|---|
| 3859 | if (!cpeonly) |
|---|
| 3860 | websWrite(wp, |
|---|
| 3861 | "document.write(\"<option value=\\\"infra\\\" %s >\" + wl_basic.adhoc + \"</option>\");\n", |
|---|
| 3862 | nvram_match(wl_mode, |
|---|
| 3863 | "infra") ? |
|---|
| 3864 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3865 | #ifndef HAVE_MADWIFI |
|---|
| 3866 | if (!cpeonly) { |
|---|
| 3867 | websWrite(wp, |
|---|
| 3868 | "document.write(\"<option value=\\\"apsta\\\" %s >\" + wl_basic.repeater + \"</option>\");\n", |
|---|
| 3869 | nvram_match(wl_mode, |
|---|
| 3870 | "apsta") ? |
|---|
| 3871 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3872 | //#ifndef HAVE_RT2880 |
|---|
| 3873 | websWrite(wp, |
|---|
| 3874 | "document.write(\"<option value=\\\"apstawet\\\" %s >\" + wl_basic.repeaterbridge + \"</option>\");\n", |
|---|
| 3875 | nvram_match(wl_mode, |
|---|
| 3876 | "apstawet") ? |
|---|
| 3877 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3878 | } |
|---|
| 3879 | //#endif |
|---|
| 3880 | #else |
|---|
| 3881 | websWrite(wp, |
|---|
| 3882 | "document.write(\"<option value=\\\"wdssta\\\" %s >\" + wl_basic.wdssta + \"</option>\");\n", |
|---|
| 3883 | nvram_match(wl_mode, |
|---|
| 3884 | "wdssta") ? |
|---|
| 3885 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3886 | if (!cpeonly) { |
|---|
| 3887 | websWrite(wp, |
|---|
| 3888 | "document.write(\"<option value=\\\"wdsap\\\" %s >\" + wl_basic.wdsap + \"</option>\");\n", |
|---|
| 3889 | nvram_match(wl_mode, |
|---|
| 3890 | "wdsap") ? |
|---|
| 3891 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3892 | } |
|---|
| 3893 | #endif |
|---|
| 3894 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3895 | websWrite(wp, "</select>\n"); |
|---|
| 3896 | websWrite(wp, "</div>\n"); |
|---|
| 3897 | } |
|---|
| 3898 | /* |
|---|
| 3899 | * #ifdef HAVE_MADWIFI else { |
|---|
| 3900 | * |
|---|
| 3901 | * |
|---|
| 3902 | * websWrite (wp, "<div class=\"setting\"><div |
|---|
| 3903 | * class=\"label\"><script |
|---|
| 3904 | * type=\"text/javascript\">Capture(wl_basic.label)</script></div><select |
|---|
| 3905 | * name=\"%s\">\n", wl_mode); websWrite (wp, "<script |
|---|
| 3906 | * type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option |
|---|
| 3907 | * value=\\\"ap\\\" %s >\" + wl_basic.ap + |
|---|
| 3908 | * \"</option>\");\n//]]>\n</script>\n", nvram_match (wl_mode, "ap") |
|---|
| 3909 | * ? "selected=\\\"selected\\\"" : ""); websWrite (wp, "<script |
|---|
| 3910 | * type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option |
|---|
| 3911 | * value=\\\"infra\\\" %s >\" + wl_basic.adhoc + |
|---|
| 3912 | * \"</option>\");\n//]]>\n</script>\n", nvram_match (wl_mode, |
|---|
| 3913 | * "infra") ? "selected=\\\"selected\\\"" : ""); websWrite (wp, |
|---|
| 3914 | * "<script type=\"text/javascript\">\n//<![CDATA[\n |
|---|
| 3915 | * document.write(\"<option value=\\\"wdssta\\\" %s >\" + |
|---|
| 3916 | * wl_basic.wdssta + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 3917 | * nvram_match (wl_mode, "wdssta") ? "selected=\\\"selected\\\"" : |
|---|
| 3918 | * ""); websWrite (wp, "<script |
|---|
| 3919 | * type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option |
|---|
| 3920 | * value=\\\"wdsap\\\" %s >\" + wl_basic.wdsap + |
|---|
| 3921 | * \"</option>\");\n//]]>\n</script>\n", nvram_match (wl_mode, |
|---|
| 3922 | * "wdsap") ? "selected=\\\"selected\\\"" : ""); websWrite (wp, |
|---|
| 3923 | * "</select>\n"); websWrite (wp, "</div>\n"); } #endif |
|---|
| 3924 | */ |
|---|
| 3925 | } |
|---|
| 3926 | // writeless net mode |
|---|
| 3927 | show_netmode(wp, prefix); |
|---|
| 3928 | // turbo options |
|---|
| 3929 | #ifdef HAVE_MADWIFI |
|---|
| 3930 | |
|---|
| 3931 | // char wl_xchanmode[16]; |
|---|
| 3932 | char wl_outdoor[16]; |
|---|
| 3933 | char wl_diversity[16]; |
|---|
| 3934 | char wl_rxantenna[16]; |
|---|
| 3935 | char wl_txantenna[16]; |
|---|
| 3936 | char wl_width[16]; |
|---|
| 3937 | char wl_preamble[16]; |
|---|
| 3938 | char wl_xr[16]; |
|---|
| 3939 | char wl_comp[32]; |
|---|
| 3940 | char wl_ff[16]; |
|---|
| 3941 | char wmm[32]; |
|---|
| 3942 | char wl_isolate[32]; |
|---|
| 3943 | char wl_sifstime[32]; |
|---|
| 3944 | char wl_preambletime[32]; |
|---|
| 3945 | char wl_intmit[32]; |
|---|
| 3946 | char wl_noise_immunity[32]; |
|---|
| 3947 | char wl_ofdm_weak_det[32]; |
|---|
| 3948 | char wl_protmode[32]; |
|---|
| 3949 | char wl_doth[32]; |
|---|
| 3950 | char wl_csma[32]; |
|---|
| 3951 | |
|---|
| 3952 | sprintf(wl_csma, "%s_csma", prefix); |
|---|
| 3953 | sprintf(wl_doth, "%s_doth", prefix); |
|---|
| 3954 | sprintf(wl_protmode, "%s_protmode", prefix); |
|---|
| 3955 | sprintf(wl_outdoor, "%s_outdoor", prefix); |
|---|
| 3956 | sprintf(wl_diversity, "%s_diversity", prefix); |
|---|
| 3957 | sprintf(wl_rxantenna, "%s_rxantenna", prefix); |
|---|
| 3958 | sprintf(wl_txantenna, "%s_txantenna", prefix); |
|---|
| 3959 | sprintf(wl_width, "%s_channelbw", prefix); |
|---|
| 3960 | // sprintf( wl_comp, "%s_compression", prefix ); |
|---|
| 3961 | sprintf(wl_ff, "%s_ff", prefix); |
|---|
| 3962 | sprintf(wl_preamble, "%s_preamble", prefix); |
|---|
| 3963 | sprintf(wl_preambletime, "%s_preambletime", prefix); |
|---|
| 3964 | sprintf(wl_sifstime, "%s_sifstime", prefix); |
|---|
| 3965 | sprintf(wl_xr, "%s_xr", prefix); |
|---|
| 3966 | |
|---|
| 3967 | sprintf(wl_intmit, "%s_intmit", prefix); |
|---|
| 3968 | sprintf(wl_noise_immunity, "%s_noise_immunity", prefix); |
|---|
| 3969 | sprintf(wl_ofdm_weak_det, "%s_ofdm_weak_det", prefix); |
|---|
| 3970 | |
|---|
| 3971 | #ifdef HAVE_MADWIFI_MIMO |
|---|
| 3972 | if (!is_ar5008(prefix)) |
|---|
| 3973 | #endif |
|---|
| 3974 | { |
|---|
| 3975 | showAutoOption(wp, "wl_basic.intmit", wl_intmit); |
|---|
| 3976 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3977 | websWrite(wp, |
|---|
| 3978 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.noise_immunity)</script></div>\n<select name=\"%s\">\n", |
|---|
| 3979 | wl_noise_immunity); |
|---|
| 3980 | websWrite(wp, |
|---|
| 3981 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3982 | websWrite(wp, |
|---|
| 3983 | "document.write(\"<option value=\\\"0\\\" %s >0</option>\");\n", |
|---|
| 3984 | nvram_default_match(wl_noise_immunity, "0", |
|---|
| 3985 | "4") ? "selected=\\\"selected\\\"" |
|---|
| 3986 | : ""); |
|---|
| 3987 | websWrite(wp, |
|---|
| 3988 | "document.write(\"<option value=\\\"1\\\" %s >1</option>\");\n", |
|---|
| 3989 | nvram_default_match(wl_noise_immunity, "1", |
|---|
| 3990 | "4") ? "selected=\\\"selected\\\"" |
|---|
| 3991 | : ""); |
|---|
| 3992 | websWrite(wp, |
|---|
| 3993 | "document.write(\"<option value=\\\"2\\\" %s >2</option>\");\n", |
|---|
| 3994 | nvram_default_match(wl_noise_immunity, "2", |
|---|
| 3995 | "4") ? "selected=\\\"selected\\\"" |
|---|
| 3996 | : ""); |
|---|
| 3997 | websWrite(wp, |
|---|
| 3998 | "document.write(\"<option value=\\\"3\\\" %s >3</option>\");\n", |
|---|
| 3999 | nvram_default_match(wl_noise_immunity, "3", |
|---|
| 4000 | "4") ? "selected=\\\"selected\\\"" |
|---|
| 4001 | : ""); |
|---|
| 4002 | websWrite(wp, |
|---|
| 4003 | "document.write(\"<option value=\\\"4\\\" %s >4</option>\");\n", |
|---|
| 4004 | nvram_default_match(wl_noise_immunity, "4", |
|---|
| 4005 | "4") ? "selected=\\\"selected\\\"" |
|---|
| 4006 | : ""); |
|---|
| 4007 | websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 4008 | |
|---|
| 4009 | showRadio(wp, "wl_basic.ofdm_weak_det", wl_ofdm_weak_det); |
|---|
| 4010 | } |
|---|
| 4011 | |
|---|
| 4012 | showOptionsLabel(wp, "wl_basic.protmode", wl_protmode, |
|---|
| 4013 | "None CTS RTS/CTS", nvram_default_get(wl_protmode, |
|---|
| 4014 | "None")); |
|---|
| 4015 | showrtssettings(wp, prefix); |
|---|
| 4016 | show_rates(wp, prefix, 0); |
|---|
| 4017 | show_rates(wp, prefix, 1); |
|---|
| 4018 | showRadio(wp, "wl_basic.preamble", wl_preamble); |
|---|
| 4019 | #ifdef HAVE_MADWIFI_MIMO |
|---|
| 4020 | if (!is_ar5008(prefix)) |
|---|
| 4021 | #endif |
|---|
| 4022 | { |
|---|
| 4023 | showRadio(wp, "wl_basic.extrange", wl_xr); |
|---|
| 4024 | showRadio(wp, "wl_basic.supergff", wl_ff); |
|---|
| 4025 | } |
|---|
| 4026 | #if 0 |
|---|
| 4027 | showRadio(wp, "wl_basic.csma", wl_csma); |
|---|
| 4028 | #endif |
|---|
| 4029 | // showOption (wp, "wl_basic.extchannel", wl_xchanmode); |
|---|
| 4030 | #if !defined(HAVE_FONERA) && !defined(HAVE_LS2) && !defined(HAVE_MERAKI) |
|---|
| 4031 | if (nvram_nmatch("1","%s_regulatory", prefix) || !issuperchannel()) { |
|---|
| 4032 | showRadio(wp, "wl_basic.outband", wl_outdoor); |
|---|
| 4033 | } |
|---|
| 4034 | #endif |
|---|
| 4035 | websWrite(wp, |
|---|
| 4036 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_width)</script></div><select name=\"%s\" >\n", |
|---|
| 4037 | wl_width); |
|---|
| 4038 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 4039 | #ifdef HAVE_MADWIFI_MIMO |
|---|
| 4040 | if (is_ar5008(prefix)) { |
|---|
| 4041 | websWrite(wp, |
|---|
| 4042 | "document.write(\"<option value=\\\"2040\\\" %s >\" + share.dynamicturbo + \"</option>\");\n", |
|---|
| 4043 | nvram_match(wl_width, |
|---|
| 4044 | "2040") ? "selected=\\\"selected\\\"" : |
|---|
| 4045 | ""); |
|---|
| 4046 | |
|---|
| 4047 | } |
|---|
| 4048 | #endif |
|---|
| 4049 | websWrite(wp, |
|---|
| 4050 | "document.write(\"<option value=\\\"40\\\" %s >\" + share.turbo + \"</option>\");\n", |
|---|
| 4051 | nvram_match(wl_width, |
|---|
| 4052 | "40") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4053 | websWrite(wp, |
|---|
| 4054 | "document.write(\"<option value=\\\"20\\\" %s >\" + share.full + \"</option>\");\n", |
|---|
| 4055 | nvram_match(wl_width, |
|---|
| 4056 | "20") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4057 | websWrite(wp, |
|---|
| 4058 | "document.write(\"<option value=\\\"10\\\" %s >\" + share.half + \"</option>\");\n", |
|---|
| 4059 | nvram_match(wl_width, |
|---|
| 4060 | "10") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4061 | websWrite(wp, |
|---|
| 4062 | "document.write(\"<option value=\\\"5\\\" %s >\" + share.quarter + \"</option>\");\n", |
|---|
| 4063 | nvram_match(wl_width, |
|---|
| 4064 | "5") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4065 | #ifdef HAVE_SUBQUARTER |
|---|
| 4066 | /* will be enabled once it is tested and the spectrum analyse is done */ |
|---|
| 4067 | websWrite(wp, |
|---|
| 4068 | "document.write(\"<option value=\\\"2\\\" %s >\" + share.subquarter + \"</option>\");\n", |
|---|
| 4069 | nvram_match(wl_width, |
|---|
| 4070 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4071 | #endif |
|---|
| 4072 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4073 | websWrite(wp, "</select>\n"); |
|---|
| 4074 | websWrite(wp, "</div>\n"); |
|---|
| 4075 | /*#if defined(HAVE_EOC5610) |
|---|
| 4076 | websWrite(wp, |
|---|
| 4077 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label25)</script></div><select name=\"%s\" >\n", |
|---|
| 4078 | wl_txantenna); |
|---|
| 4079 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 4080 | websWrite(wp, |
|---|
| 4081 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.ghz5 + \"</option>\");\n", |
|---|
| 4082 | nvram_match(wl_txantenna, |
|---|
| 4083 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4084 | websWrite(wp, |
|---|
| 4085 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.ghz24 + \"</option>\");\n", |
|---|
| 4086 | nvram_match(wl_txantenna, |
|---|
| 4087 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4088 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4089 | |
|---|
| 4090 | websWrite(wp, "</select>\n"); |
|---|
| 4091 | websWrite(wp, "</div>\n");*/ |
|---|
| 4092 | #if defined(HAVE_PICO2) || defined(HAVE_PICO2HP) || defined(HAVE_PICO5) |
|---|
| 4093 | |
|---|
| 4094 | /* websWrite( wp, |
|---|
| 4095 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label25)</script></div><select name=\"%s\" >\n", |
|---|
| 4096 | wl_txantenna ); |
|---|
| 4097 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 4098 | websWrite( wp, |
|---|
| 4099 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.internal + \"</option>\");\n", |
|---|
| 4100 | nvram_match( wl_txantenna, |
|---|
| 4101 | "1" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 4102 | websWrite( wp, |
|---|
| 4103 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.external + \"</option>\");\n", |
|---|
| 4104 | nvram_match( wl_txantenna, |
|---|
| 4105 | "2" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 4106 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4107 | |
|---|
| 4108 | websWrite( wp, "</select>\n" ); |
|---|
| 4109 | websWrite( wp, "</div>\n" );*/ |
|---|
| 4110 | //#elif defined(HAVE_EOC1650) |
|---|
| 4111 | /* websWrite( wp, |
|---|
| 4112 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label25)</script></div><select name=\"%s\" >\n", |
|---|
| 4113 | wl_txantenna ); |
|---|
| 4114 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 4115 | websWrite( wp, |
|---|
| 4116 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.internal + \"</option>\");\n", |
|---|
| 4117 | nvram_match( wl_txantenna, |
|---|
| 4118 | "2" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 4119 | websWrite( wp, |
|---|
| 4120 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.external + \"</option>\");\n", |
|---|
| 4121 | nvram_match( wl_txantenna, |
|---|
| 4122 | "1" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 4123 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4124 | |
|---|
| 4125 | websWrite( wp, "</select>\n" ); |
|---|
| 4126 | websWrite( wp, "</div>\n" );*/ |
|---|
| 4127 | #elif defined(HAVE_NS2) || defined(HAVE_NS5) || defined(HAVE_LC2) || defined(HAVE_LC5) || defined(HAVE_NS3) |
|---|
| 4128 | |
|---|
| 4129 | websWrite(wp, |
|---|
| 4130 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label24)</script></div><select name=\"%s\" >\n", |
|---|
| 4131 | wl_txantenna); |
|---|
| 4132 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 4133 | websWrite(wp, |
|---|
| 4134 | "document.write(\"<option value=\\\"0\\\" %s >\" + wl_basic.vertical + \"</option>\");\n", |
|---|
| 4135 | nvram_match(wl_txantenna, |
|---|
| 4136 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4137 | websWrite(wp, |
|---|
| 4138 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.horizontal + \"</option>\");\n", |
|---|
| 4139 | nvram_match(wl_txantenna, |
|---|
| 4140 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4141 | #if defined(HAVE_NS5) || defined(HAVE_NS2) || defined(HAVE_NS3) |
|---|
| 4142 | websWrite(wp, |
|---|
| 4143 | "document.write(\"<option value=\\\"3\\\" %s >\" + wl_basic.adaptive + \"</option>\");\n", |
|---|
| 4144 | nvram_match(wl_txantenna, |
|---|
| 4145 | "3") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4146 | websWrite(wp, |
|---|
| 4147 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.external + \"</option>\");\n", |
|---|
| 4148 | nvram_match(wl_txantenna, |
|---|
| 4149 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4150 | #endif |
|---|
| 4151 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4152 | |
|---|
| 4153 | websWrite(wp, "</select>\n"); |
|---|
| 4154 | websWrite(wp, "</div>\n"); |
|---|
| 4155 | |
|---|
| 4156 | #else |
|---|
| 4157 | #ifdef HAVE_MADWIFI_MIMO |
|---|
| 4158 | if (!is_ar5008(prefix)) |
|---|
| 4159 | #endif |
|---|
| 4160 | { |
|---|
| 4161 | showRadio(wp, "wl_basic.diversity", wl_diversity); |
|---|
| 4162 | websWrite(wp, |
|---|
| 4163 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label12)</script></div><select name=\"%s\" >\n", |
|---|
| 4164 | wl_txantenna); |
|---|
| 4165 | websWrite(wp, |
|---|
| 4166 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 4167 | websWrite(wp, |
|---|
| 4168 | "document.write(\"<option value=\\\"0\\\" %s >\" + wl_basic.diversity + \"</option>\");\n", |
|---|
| 4169 | nvram_match(wl_txantenna, |
|---|
| 4170 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4171 | websWrite(wp, |
|---|
| 4172 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.primary + \"</option>\");\n", |
|---|
| 4173 | nvram_match(wl_txantenna, |
|---|
| 4174 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4175 | websWrite(wp, |
|---|
| 4176 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.secondary + \"</option>\");\n", |
|---|
| 4177 | nvram_match(wl_txantenna, |
|---|
| 4178 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4179 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4180 | websWrite(wp, "</select>\n"); |
|---|
| 4181 | websWrite(wp, "</div>\n"); |
|---|
| 4182 | |
|---|
| 4183 | websWrite(wp, |
|---|
| 4184 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label13)</script></div><select name=\"%s\" >\n", |
|---|
| 4185 | wl_rxantenna); |
|---|
| 4186 | websWrite(wp, |
|---|
| 4187 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 4188 | websWrite(wp, |
|---|
| 4189 | "document.write(\"<option value=\\\"0\\\" %s >\" + wl_basic.diversity + \"</option>\");\n", |
|---|
| 4190 | nvram_match(wl_rxantenna, |
|---|
| 4191 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4192 | websWrite(wp, |
|---|
| 4193 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.primary + \"</option>\");\n", |
|---|
| 4194 | nvram_match(wl_rxantenna, |
|---|
| 4195 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4196 | websWrite(wp, |
|---|
| 4197 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.secondary + \"</option>\");\n", |
|---|
| 4198 | nvram_match(wl_rxantenna, |
|---|
| 4199 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4200 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4201 | websWrite(wp, "</select>\n"); |
|---|
| 4202 | websWrite(wp, "</div>\n"); |
|---|
| 4203 | } |
|---|
| 4204 | #ifdef HAVE_MADWIFI_MIMO |
|---|
| 4205 | else { |
|---|
| 4206 | websWrite(wp, |
|---|
| 4207 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.txchainmask)</script></div><select name=\"%s\" >\n", |
|---|
| 4208 | wl_txantenna); |
|---|
| 4209 | websWrite(wp, |
|---|
| 4210 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 4211 | websWrite(wp, |
|---|
| 4212 | "document.write(\"<option value=\\\"1\\\" %s >1</option>\");\n", |
|---|
| 4213 | nvram_match(wl_txantenna, |
|---|
| 4214 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4215 | // websWrite(wp, |
|---|
| 4216 | // "document.write(\"<option value=\\\"2\\\" %s >2</option>\");\n", |
|---|
| 4217 | // nvram_match(wl_txantenna, |
|---|
| 4218 | // "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4219 | websWrite(wp, |
|---|
| 4220 | "document.write(\"<option value=\\\"3\\\" %s >1+2</option>\");\n", |
|---|
| 4221 | nvram_match(wl_txantenna, |
|---|
| 4222 | "3") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4223 | // websWrite(wp, |
|---|
| 4224 | // "document.write(\"<option value=\\\"4\\\" %s >3</option>\");\n", |
|---|
| 4225 | // nvram_match(wl_txantenna, |
|---|
| 4226 | // "4") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4227 | websWrite(wp, |
|---|
| 4228 | "document.write(\"<option value=\\\"5\\\" %s >1+3</option>\");\n", |
|---|
| 4229 | nvram_match(wl_txantenna, |
|---|
| 4230 | "5") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4231 | // websWrite(wp, |
|---|
| 4232 | // "document.write(\"<option value=\\\"6\\\" %s >2+3</option>\");\n", |
|---|
| 4233 | // nvram_match(wl_txantenna, |
|---|
| 4234 | // "6") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4235 | websWrite(wp, |
|---|
| 4236 | "document.write(\"<option value=\\\"7\\\" %s >1+2+3</option>\");\n", |
|---|
| 4237 | nvram_match(wl_txantenna, |
|---|
| 4238 | "7") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4239 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4240 | websWrite(wp, "</select>\n"); |
|---|
| 4241 | websWrite(wp, "</div>\n"); |
|---|
| 4242 | |
|---|
| 4243 | websWrite(wp, |
|---|
| 4244 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.rxchainmask)</script></div><select name=\"%s\" >\n", |
|---|
| 4245 | wl_rxantenna); |
|---|
| 4246 | websWrite(wp, |
|---|
| 4247 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 4248 | websWrite(wp, |
|---|
| 4249 | "document.write(\"<option value=\\\"1\\\" %s >1</option>\");\n", |
|---|
| 4250 | nvram_match(wl_rxantenna, |
|---|
| 4251 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4252 | // websWrite(wp, |
|---|
| 4253 | // "document.write(\"<option value=\\\"2\\\" %s >2</option>\");\n", |
|---|
| 4254 | // nvram_match(wl_rxantenna, |
|---|
| 4255 | // "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4256 | websWrite(wp, |
|---|
| 4257 | "document.write(\"<option value=\\\"3\\\" %s >1+2</option>\");\n", |
|---|
| 4258 | nvram_match(wl_rxantenna, |
|---|
| 4259 | "3") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4260 | // websWrite(wp, |
|---|
| 4261 | // "document.write(\"<option value=\\\"4\\\" %s >3</option>\");\n", |
|---|
| 4262 | // nvram_match(wl_rxantenna, |
|---|
| 4263 | // "4") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4264 | websWrite(wp, |
|---|
| 4265 | "document.write(\"<option value=\\\"5\\\" %s >1+3</option>\");\n", |
|---|
| 4266 | nvram_match(wl_rxantenna, |
|---|
| 4267 | "5") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4268 | // websWrite(wp, |
|---|
| 4269 | // "document.write(\"<option value=\\\"6\\\" %s >2+3</option>\");\n", |
|---|
| 4270 | // nvram_match(wl_rxantenna, |
|---|
| 4271 | // "6") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4272 | websWrite(wp, |
|---|
| 4273 | "document.write(\"<option value=\\\"7\\\" %s >1+2+3</option>\");\n", |
|---|
| 4274 | nvram_match(wl_rxantenna, |
|---|
| 4275 | "7") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4276 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4277 | websWrite(wp, "</select>\n"); |
|---|
| 4278 | websWrite(wp, "</div>\n"); |
|---|
| 4279 | |
|---|
| 4280 | } |
|---|
| 4281 | #endif |
|---|
| 4282 | #endif |
|---|
| 4283 | #endif |
|---|
| 4284 | #ifdef HAVE_MADWIFI |
|---|
| 4285 | sprintf(wl_isolate, "%s_ap_isolate", prefix); |
|---|
| 4286 | showRadio(wp, "wl_adv.label11", wl_isolate); |
|---|
| 4287 | |
|---|
| 4288 | #if 0 |
|---|
| 4289 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4290 | websWrite(wp, |
|---|
| 4291 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.sifstime)</script></div>\n"); |
|---|
| 4292 | websWrite(wp, |
|---|
| 4293 | "<input class=\"num\" name=\"%s\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,99999999,wl_basic.sifstime)\" value=\"%s\" />\n", |
|---|
| 4294 | wl_sifstime, nvram_default_get(wl_sifstime, "16")); |
|---|
| 4295 | websWrite(wp, "</div>\n"); |
|---|
| 4296 | |
|---|
| 4297 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4298 | websWrite(wp, |
|---|
| 4299 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.preambletime)</script></div>\n"); |
|---|
| 4300 | websWrite(wp, |
|---|
| 4301 | "<input class=\"num\" name=\"%s\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,99999999,wl_basic.preambletime)\" value=\"%s\" />\n", |
|---|
| 4302 | wl_preambletime, nvram_default_get(wl_preambletime, "20")); |
|---|
| 4303 | websWrite(wp, "</div>\n"); |
|---|
| 4304 | #endif |
|---|
| 4305 | #ifdef HAVE_MADWIFI_MIMO |
|---|
| 4306 | if (!is_ar5008(prefix)) |
|---|
| 4307 | #endif |
|---|
| 4308 | { |
|---|
| 4309 | sprintf(wmm, "%s_wmm", prefix); |
|---|
| 4310 | showRadio(wp, "wl_adv.label18", wmm); |
|---|
| 4311 | } |
|---|
| 4312 | #endif |
|---|
| 4313 | |
|---|
| 4314 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4315 | websWrite(wp, |
|---|
| 4316 | "<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", |
|---|
| 4317 | wl_ssid, nvram_safe_get(wl_ssid)); |
|---|
| 4318 | |
|---|
| 4319 | #ifdef HAVE_MADWIFI |
|---|
| 4320 | showRadio(wp, "wl_basic.radar", wl_doth); |
|---|
| 4321 | show_chanshift(wp, prefix); |
|---|
| 4322 | #endif |
|---|
| 4323 | #ifdef HAVE_RT2880 |
|---|
| 4324 | if (nvram_match(wl_mode, "ap") || nvram_match(wl_mode, "wdsap") |
|---|
| 4325 | || nvram_match(wl_mode, "infra") || nvram_match(wl_mode, "apsta") |
|---|
| 4326 | || nvram_match(wl_mode, "apstawet")) |
|---|
| 4327 | #else |
|---|
| 4328 | if (nvram_match(wl_mode, "ap") || nvram_match(wl_mode, "wdsap") |
|---|
| 4329 | || nvram_match(wl_mode, "infra")) |
|---|
| 4330 | #endif |
|---|
| 4331 | { |
|---|
| 4332 | |
|---|
| 4333 | if (has_mimo(prefix) |
|---|
| 4334 | && (nvram_nmatch("n-only", "%s_net_mode", prefix) |
|---|
| 4335 | || nvram_nmatch("ng-only", "%s_net_mode", prefix) |
|---|
| 4336 | || nvram_nmatch("mixed", "%s_net_mode", prefix) |
|---|
| 4337 | || nvram_nmatch("n2-only", "%s_net_mode", prefix) |
|---|
| 4338 | || nvram_nmatch("n5-only", "%s_net_mode", prefix) |
|---|
| 4339 | || nvram_nmatch("na-only", "%s_net_mode", prefix))) { |
|---|
| 4340 | show_channel(wp, prefix, prefix, 1); |
|---|
| 4341 | |
|---|
| 4342 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4343 | websWrite(wp, |
|---|
| 4344 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_width)</script></div>\n"); |
|---|
| 4345 | websWrite(wp, "<select name=\"%s_nbw\">\n", prefix); |
|---|
| 4346 | #ifdef HAVE_RT2880 |
|---|
| 4347 | websWrite(wp, |
|---|
| 4348 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"20\\\" %s >20 Mhz</option>\");\n//]]>\n</script>\n", |
|---|
| 4349 | nvram_nmatch("20", "%s_nbw", |
|---|
| 4350 | prefix) ? |
|---|
| 4351 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4352 | websWrite(wp, "<option value=\"40\" %s>40 MHz</option>", |
|---|
| 4353 | nvram_nmatch("40", "%s_nbw", |
|---|
| 4354 | prefix) ? |
|---|
| 4355 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4356 | #else |
|---|
| 4357 | websWrite(wp, |
|---|
| 4358 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"0\\\" %s >\" + share.auto + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 4359 | nvram_nmatch("0", "%s_nbw", |
|---|
| 4360 | prefix) ? |
|---|
| 4361 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4362 | websWrite(wp, |
|---|
| 4363 | "<option value=\"10\" %s>10 MHz</option>\n", |
|---|
| 4364 | nvram_nmatch("10", "%s_nbw", |
|---|
| 4365 | prefix) ? |
|---|
| 4366 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4367 | websWrite(wp, |
|---|
| 4368 | "<option value=\"20\" %s>20 MHz</option>\n", |
|---|
| 4369 | nvram_nmatch("20", "%s_nbw", |
|---|
| 4370 | prefix) ? |
|---|
| 4371 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4372 | websWrite(wp, |
|---|
| 4373 | "<option value=\"40\" %s>40 MHz</option>\n", |
|---|
| 4374 | nvram_nmatch("40", "%s_nbw", |
|---|
| 4375 | prefix) ? |
|---|
| 4376 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4377 | #endif |
|---|
| 4378 | websWrite(wp, "</select>\n"); |
|---|
| 4379 | websWrite(wp, "</div>\n"); |
|---|
| 4380 | |
|---|
| 4381 | if (nvram_nmatch("40", "%s_nbw", prefix)) { |
|---|
| 4382 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4383 | websWrite(wp, |
|---|
| 4384 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_wide)</script></div>\n"); |
|---|
| 4385 | websWrite(wp, "<select name=\"%s_nctrlsb\" >\n", |
|---|
| 4386 | prefix); |
|---|
| 4387 | websWrite(wp, |
|---|
| 4388 | "<option value=\"upper\" %s>upper</option>\n", |
|---|
| 4389 | nvram_nmatch("upper", "%s_nctrlsb", |
|---|
| 4390 | prefix) ? |
|---|
| 4391 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4392 | websWrite(wp, |
|---|
| 4393 | "<option value=\"lower\" %s>lower</option>\n", |
|---|
| 4394 | nvram_nmatch("lower", "%s_nctrlsb", |
|---|
| 4395 | prefix) ? |
|---|
| 4396 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4397 | websWrite(wp, "</select>\n"); |
|---|
| 4398 | |
|---|
| 4399 | websWrite(wp, "</div>\n"); |
|---|
| 4400 | } |
|---|
| 4401 | } else { |
|---|
| 4402 | |
|---|
| 4403 | show_channel(wp, prefix, prefix, 0); |
|---|
| 4404 | #ifdef HAVE_MADWIFI_MIMO |
|---|
| 4405 | if (is_ar5008(prefix) |
|---|
| 4406 | && (nvram_match(wl_width, "40") |
|---|
| 4407 | || nvram_match(wl_width, "2040"))) { |
|---|
| 4408 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4409 | websWrite(wp, |
|---|
| 4410 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_wide)</script></div>\n"); |
|---|
| 4411 | websWrite(wp, "<select name=\"%s_nctrlsb\" >\n", |
|---|
| 4412 | prefix); |
|---|
| 4413 | websWrite(wp, |
|---|
| 4414 | "<option value=\"upper\" %s>upper</option>\n", |
|---|
| 4415 | nvram_nmatch("upper", "%s_nctrlsb", |
|---|
| 4416 | prefix) ? |
|---|
| 4417 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4418 | websWrite(wp, |
|---|
| 4419 | "<option value=\"lower\" %s>lower</option>\n", |
|---|
| 4420 | nvram_nmatch("lower", "%s_nctrlsb", |
|---|
| 4421 | prefix) ? |
|---|
| 4422 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4423 | websWrite(wp, "</select>\n"); |
|---|
| 4424 | |
|---|
| 4425 | websWrite(wp, "</div>\n"); |
|---|
| 4426 | } |
|---|
| 4427 | #endif |
|---|
| 4428 | } |
|---|
| 4429 | |
|---|
| 4430 | char wl_closed[16]; |
|---|
| 4431 | |
|---|
| 4432 | sprintf(wl_closed, "%s_closed", prefix); |
|---|
| 4433 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4434 | websWrite(wp, |
|---|
| 4435 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label5)</script></div>\n"); |
|---|
| 4436 | websWrite(wp, |
|---|
| 4437 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input> \n", |
|---|
| 4438 | wl_closed, nvram_match(wl_closed, |
|---|
| 4439 | "0") ? "checked=\"checked\"" : |
|---|
| 4440 | ""); |
|---|
| 4441 | websWrite(wp, |
|---|
| 4442 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input>\n", |
|---|
| 4443 | wl_closed, nvram_match(wl_closed, |
|---|
| 4444 | "1") ? "checked=\"checked\"" : |
|---|
| 4445 | ""); |
|---|
| 4446 | websWrite(wp, "</div>\n"); |
|---|
| 4447 | } |
|---|
| 4448 | #ifdef HAVE_MADWIFI |
|---|
| 4449 | // if (nvram_match (wl_mode, "sta") || nvram_match (wl_mode, "wdssta") |
|---|
| 4450 | // || nvram_match (wl_mode, "wet")) |
|---|
| 4451 | { |
|---|
| 4452 | char wl_scanlist[32]; |
|---|
| 4453 | |
|---|
| 4454 | sprintf(wl_scanlist, "%s_scanlist", prefix); |
|---|
| 4455 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4456 | websWrite(wp, |
|---|
| 4457 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.scanlist)</script></div>\n"); |
|---|
| 4458 | websWrite(wp, |
|---|
| 4459 | "<input name=\"%s\" size=\"32\" maxlength=\"512\" value=\"%s\" />\n", |
|---|
| 4460 | wl_scanlist, nvram_default_get(wl_scanlist, |
|---|
| 4461 | "default")); |
|---|
| 4462 | websWrite(wp, "</div>\n"); |
|---|
| 4463 | } |
|---|
| 4464 | #endif |
|---|
| 4465 | |
|---|
| 4466 | // ACK timing |
|---|
| 4467 | #if defined(HAVE_ACK) || defined(HAVE_MADWIFI) // temp fix for v24 broadcom |
|---|
| 4468 | // ACKnot working |
|---|
| 4469 | |
|---|
| 4470 | sprintf(power, "%s_distance", prefix); |
|---|
| 4471 | websWrite(wp, "<br />\n"); |
|---|
| 4472 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4473 | websWrite(wp, |
|---|
| 4474 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label6)</script></div>\n"); |
|---|
| 4475 | websWrite(wp, |
|---|
| 4476 | "<input class=\"num\" name=\"%s\" size=\"8\" maxlength=\"8\" onblur=\"valid_range(this,0,99999999,wl_basic.label6)\" value=\"%s\" />\n", |
|---|
| 4477 | power, nvram_default_get(power, "2000")); |
|---|
| 4478 | websWrite(wp, |
|---|
| 4479 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 2000 \" + share.meters + \")\");\n//]]>\n</script></span>\n"); |
|---|
| 4480 | websWrite(wp, "</div>\n"); |
|---|
| 4481 | // end ACK timing |
|---|
| 4482 | #endif |
|---|
| 4483 | #ifdef HAVE_MADWIFI |
|---|
| 4484 | if (nvram_nmatch("ap", "%s_mode", prefix) |
|---|
| 4485 | || nvram_nmatch("wdsap", "%s_mode", prefix) |
|---|
| 4486 | || nvram_nmatch("infra", "%s_mode", prefix)) { |
|---|
| 4487 | sprintf(power, "%s_maxassoc", prefix); |
|---|
| 4488 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4489 | websWrite(wp, |
|---|
| 4490 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label10)</script></div>\n"); |
|---|
| 4491 | websWrite(wp, |
|---|
| 4492 | "<input class=\"num\" name=\"%s\" size=\"4\" maxlength=\"4\" onblur=\"valid_range(this,0,256,wl_basic.label6)\" value=\"%s\" />\n", |
|---|
| 4493 | power, nvram_default_get(power, "256")); |
|---|
| 4494 | websWrite(wp, |
|---|
| 4495 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 256 \" + status_wireless.legend3 + \")\");\n//]]>\n</script></span>\n"); |
|---|
| 4496 | websWrite(wp, "</div>\n"); |
|---|
| 4497 | } |
|---|
| 4498 | sprintf(power, "%s_mtikie", prefix); |
|---|
| 4499 | nvram_default_get(power, "0"); |
|---|
| 4500 | showRadio(wp, "wl_basic.mtikie", power); |
|---|
| 4501 | |
|---|
| 4502 | showbridgesettings(wp, prefix, 1, 1); |
|---|
| 4503 | #elif HAVE_RT2880 |
|---|
| 4504 | showbridgesettings(wp, "ra0", 1, 1); |
|---|
| 4505 | #else |
|---|
| 4506 | if (!strcmp(prefix, "wl0")) |
|---|
| 4507 | showbridgesettings(wp, get_wl_instance_name(0), 1, 1); |
|---|
| 4508 | if (!strcmp(prefix, "wl1")) |
|---|
| 4509 | showbridgesettings(wp, get_wl_instance_name(1), 1, 1); |
|---|
| 4510 | #endif |
|---|
| 4511 | websWrite(wp, "</fieldset>\n"); |
|---|
| 4512 | websWrite(wp, "<br />\n"); |
|---|
| 4513 | #ifdef HAVE_REGISTER |
|---|
| 4514 | if (!iscpe()) |
|---|
| 4515 | #endif |
|---|
| 4516 | show_virtualssid(wp, prefix); |
|---|
| 4517 | } |
|---|
| 4518 | |
|---|
| 4519 | void ej_show_wireless(webs_t wp, int argc, char_t ** argv) |
|---|
| 4520 | { |
|---|
| 4521 | #ifdef HAVE_MADWIFI |
|---|
| 4522 | int c = getdevicecount(); |
|---|
| 4523 | int i; |
|---|
| 4524 | |
|---|
| 4525 | for (i = 0; i < c; i++) { |
|---|
| 4526 | char buf[16]; |
|---|
| 4527 | |
|---|
| 4528 | sprintf(buf, "ath%d", i); |
|---|
| 4529 | ej_show_wireless_single(wp, buf); |
|---|
| 4530 | } |
|---|
| 4531 | #else |
|---|
| 4532 | int c = get_wl_instances(); |
|---|
| 4533 | int i; |
|---|
| 4534 | |
|---|
| 4535 | for (i = 0; i < c; i++) { |
|---|
| 4536 | char buf[16]; |
|---|
| 4537 | |
|---|
| 4538 | sprintf(buf, "wl%d", i); |
|---|
| 4539 | ej_show_wireless_single(wp, buf); |
|---|
| 4540 | } |
|---|
| 4541 | #endif |
|---|
| 4542 | return; |
|---|
| 4543 | } |
|---|
| 4544 | |
|---|
| 4545 | void show_preshared(webs_t wp, char *prefix) |
|---|
| 4546 | { |
|---|
| 4547 | char var[80]; |
|---|
| 4548 | |
|---|
| 4549 | cprintf("show preshared"); |
|---|
| 4550 | sprintf(var, "%s_crypto", prefix); |
|---|
| 4551 | websWrite(wp, "<div><div class=\"setting\">\n"); |
|---|
| 4552 | websWrite(wp, |
|---|
| 4553 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.algorithms)</script></div>\n"); |
|---|
| 4554 | websWrite(wp, "<select name=\"%s_crypto\">\n", prefix); |
|---|
| 4555 | websWrite(wp, "<option value=\"tkip\" %s>TKIP</option>\n", |
|---|
| 4556 | selmatch(var, "tkip", "selected=\"selected\"")); |
|---|
| 4557 | websWrite(wp, "<option value=\"aes\" %s>AES</option>\n", |
|---|
| 4558 | selmatch(var, "aes", "selected=\"selected\"")); |
|---|
| 4559 | websWrite(wp, "<option value=\"tkip+aes\" %s>TKIP+AES</option>\n", |
|---|
| 4560 | selmatch(var, "tkip+aes", "selected=\"selected\"")); |
|---|
| 4561 | websWrite(wp, "</select>\n"); |
|---|
| 4562 | websWrite(wp, "</div>\n"); |
|---|
| 4563 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4564 | websWrite(wp, |
|---|
| 4565 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.shared_key)</script></div>\n"); |
|---|
| 4566 | sprintf(var, "%s_wpa_psk", prefix); |
|---|
| 4567 | websWrite(wp, |
|---|
| 4568 | "<input type=\"password\" id=\"%s_wpa_psk\" name=\"%s_wpa_psk\" onblur=\"valid_psk_length(this)\" maxlength=\"64\" size=\"32\" value=\"", |
|---|
| 4569 | prefix, prefix); |
|---|
| 4570 | tf_webWriteESCNV(wp, var); |
|---|
| 4571 | websWrite(wp, "\" /> \n"); |
|---|
| 4572 | websWrite(wp, |
|---|
| 4573 | "<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", |
|---|
| 4574 | prefix, prefix); |
|---|
| 4575 | websWrite(wp, "</div>\n"); |
|---|
| 4576 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4577 | websWrite(wp, |
|---|
| 4578 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.rekey)</script></div>\n"); |
|---|
| 4579 | sprintf(var, "%s_wpa_gtk_rekey", prefix); |
|---|
| 4580 | websWrite(wp, |
|---|
| 4581 | "<input class=\"num\" name=\"%s_wpa_gtk_rekey\" maxlength=\"5\" size=\"5\" onblur=\"valid_range(this,0,99999,wpa.rekey)\" value=\"%s\" />\n", |
|---|
| 4582 | prefix, nvram_default_get(var, "3600")); |
|---|
| 4583 | websWrite(wp, |
|---|
| 4584 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 3600, \" + share.range + \": 1 - 99999)\");\n//]]>\n</script></span>\n"); |
|---|
| 4585 | websWrite(wp, "</div>\n"); |
|---|
| 4586 | websWrite(wp, "</div>\n"); |
|---|
| 4587 | } |
|---|
| 4588 | |
|---|
| 4589 | void show_radius(webs_t wp, char *prefix, int showmacformat, int backup) |
|---|
| 4590 | { |
|---|
| 4591 | char var[80]; |
|---|
| 4592 | |
|---|
| 4593 | cprintf("show radius\n"); |
|---|
| 4594 | if (showmacformat) { |
|---|
| 4595 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4596 | websWrite(wp, |
|---|
| 4597 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label2)</script></div>\n"); |
|---|
| 4598 | websWrite(wp, "<select name=\"%s_radmactype\">\n", prefix); |
|---|
| 4599 | websWrite(wp, |
|---|
| 4600 | "<option value=\"0\" %s >aabbcc-ddeeff</option>\n", |
|---|
| 4601 | nvram_prefix_match("radmactype", prefix, |
|---|
| 4602 | "0") ? "selected" : ""); |
|---|
| 4603 | websWrite(wp, "<option value=\"1\" %s >aabbccddeeff</option>\n", |
|---|
| 4604 | nvram_prefix_match("radmactype", prefix, |
|---|
| 4605 | "1") ? "selected" : ""); |
|---|
| 4606 | websWrite(wp, |
|---|
| 4607 | "<option value=\"2\" %s >aa:bb:cc:dd:ee:ff</option>\n", |
|---|
| 4608 | nvram_prefix_match("radmactype", prefix, |
|---|
| 4609 | "2") ? "selected" : ""); |
|---|
| 4610 | websWrite(wp, |
|---|
| 4611 | "<option value=\"3\" %s >aa-bb-cc-dd-ee-ff</option>\n", |
|---|
| 4612 | nvram_prefix_match("radmactype", prefix, |
|---|
| 4613 | "3") ? "selected" : ""); |
|---|
| 4614 | websWrite(wp, "</select>\n"); |
|---|
| 4615 | websWrite(wp, "</div>\n"); |
|---|
| 4616 | } |
|---|
| 4617 | char *rad = nvram_nget("%s_radius_ipaddr", prefix); |
|---|
| 4618 | |
|---|
| 4619 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4620 | websWrite(wp, |
|---|
| 4621 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label3)</script></div>\n"); |
|---|
| 4622 | websWrite(wp, |
|---|
| 4623 | "<input type=\"hidden\" name=\"%s_radius_ipaddr\" value=\"4\" />\n", |
|---|
| 4624 | prefix); |
|---|
| 4625 | websWrite(wp, |
|---|
| 4626 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_0\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4627 | prefix, get_single_ip(rad, 0)); |
|---|
| 4628 | websWrite(wp, |
|---|
| 4629 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_1\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4630 | prefix, get_single_ip(rad, 1)); |
|---|
| 4631 | websWrite(wp, |
|---|
| 4632 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_2\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4633 | prefix, get_single_ip(rad, 2)); |
|---|
| 4634 | websWrite(wp, |
|---|
| 4635 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_3\" onblur=\"valid_range(this,1,254,radius.label3)\" class=\"num\" value=\"%d\" />\n", |
|---|
| 4636 | prefix, get_single_ip(rad, 3)); |
|---|
| 4637 | websWrite(wp, "</div>\n"); |
|---|
| 4638 | |
|---|
| 4639 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4640 | websWrite(wp, |
|---|
| 4641 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label4)</script></div>\n"); |
|---|
| 4642 | sprintf(var, "%s_radius_port", prefix); |
|---|
| 4643 | websWrite(wp, |
|---|
| 4644 | "<input name=\"%s_radius_port\" size=\"3\" maxlength=\"5\" onblur=\"valid_range(this,1,65535,radius.label4)\" value=\"%s\" />\n", |
|---|
| 4645 | prefix, nvram_default_get(var, "1812")); |
|---|
| 4646 | websWrite(wp, |
|---|
| 4647 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 1812)\");\n//]]>\n</script></span>\n</div>\n"); |
|---|
| 4648 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4649 | websWrite(wp, |
|---|
| 4650 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label7)</script></div>\n"); |
|---|
| 4651 | sprintf(var, "%s_radius_key", prefix); |
|---|
| 4652 | websWrite(wp, |
|---|
| 4653 | "<input type=\"password\" id=\"%s_radius_key\" name=\"%s_radius_key\" maxlength=\"79\" size=\"32\" value=\"", |
|---|
| 4654 | prefix, prefix); |
|---|
| 4655 | |
|---|
| 4656 | tf_webWriteESCNV(wp, var); |
|---|
| 4657 | websWrite(wp, "\" /> \n"); |
|---|
| 4658 | websWrite(wp, |
|---|
| 4659 | "<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", |
|---|
| 4660 | prefix, prefix); |
|---|
| 4661 | |
|---|
| 4662 | if (backup) { |
|---|
| 4663 | rad = nvram_nget("%s_radius2_ipaddr", prefix); |
|---|
| 4664 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4665 | websWrite(wp, |
|---|
| 4666 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label23)</script></div>\n"); |
|---|
| 4667 | websWrite(wp, |
|---|
| 4668 | "<input type=\"hidden\" name=\"%s_radius2_ipaddr\" value=\"4\" />\n", |
|---|
| 4669 | prefix); |
|---|
| 4670 | websWrite(wp, |
|---|
| 4671 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius2_ipaddr_0\" onblur=\"valid_range(this,0,255,radius.label23)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4672 | prefix, get_single_ip(rad, 0)); |
|---|
| 4673 | websWrite(wp, |
|---|
| 4674 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius2_ipaddr_1\" onblur=\"valid_range(this,0,255,radius.label23)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4675 | prefix, get_single_ip(rad, 1)); |
|---|
| 4676 | websWrite(wp, |
|---|
| 4677 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius2_ipaddr_2\" onblur=\"valid_range(this,0,255,radius.label23)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4678 | prefix, get_single_ip(rad, 2)); |
|---|
| 4679 | websWrite(wp, |
|---|
| 4680 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius2_ipaddr_3\" onblur=\"valid_range(this,1,254,radius.label23)\" class=\"num\" value=\"%d\" />\n", |
|---|
| 4681 | prefix, get_single_ip(rad, 3)); |
|---|
| 4682 | websWrite(wp, "</div>\n"); |
|---|
| 4683 | |
|---|
| 4684 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4685 | websWrite(wp, |
|---|
| 4686 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label24)</script></div>\n"); |
|---|
| 4687 | sprintf(var, "%s_radius2_port", prefix); |
|---|
| 4688 | websWrite(wp, |
|---|
| 4689 | "<input name=\"%s_radius2_port\" size=\"3\" maxlength=\"5\" onblur=\"valid_range(this,1,65535,radius.label24)\" value=\"%s\" />\n", |
|---|
| 4690 | prefix, nvram_default_get(var, "1812")); |
|---|
| 4691 | websWrite(wp, |
|---|
| 4692 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 1812)\");\n//]]>\n</script></span>\n</div>\n"); |
|---|
| 4693 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4694 | websWrite(wp, |
|---|
| 4695 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label27)</script></div>\n"); |
|---|
| 4696 | sprintf(var, "%s_radius2_key", prefix); |
|---|
| 4697 | websWrite(wp, |
|---|
| 4698 | "<input type=\"password\" id=\"%s_radius2_key\" name=\"%s_radius2_key\" maxlength=\"79\" size=\"32\" value=\"", |
|---|
| 4699 | prefix, prefix); |
|---|
| 4700 | |
|---|
| 4701 | tf_webWriteESCNV(wp, var); |
|---|
| 4702 | websWrite(wp, "\" /> \n"); |
|---|
| 4703 | websWrite(wp, |
|---|
| 4704 | "<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", |
|---|
| 4705 | prefix, prefix); |
|---|
| 4706 | } |
|---|
| 4707 | websWrite(wp, "</div>\n"); |
|---|
| 4708 | #ifdef HAVE_MADWIFI |
|---|
| 4709 | if (!showmacformat) { |
|---|
| 4710 | char acct[32]; |
|---|
| 4711 | char vvar[32]; |
|---|
| 4712 | |
|---|
| 4713 | strcpy(vvar, prefix); |
|---|
| 4714 | rep(vvar, '.', 'X'); |
|---|
| 4715 | sprintf(acct, "%s_acct", var); |
|---|
| 4716 | websWrite(wp, |
|---|
| 4717 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label18)</script></div>\n"); |
|---|
| 4718 | websWrite(wp, |
|---|
| 4719 | "<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", |
|---|
| 4720 | vvar, prefix, nvram_default_match(acct, "1", |
|---|
| 4721 | "0") ? |
|---|
| 4722 | "checked=\"checked\"" : ""); |
|---|
| 4723 | websWrite(wp, |
|---|
| 4724 | "<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", |
|---|
| 4725 | vvar, prefix, nvram_default_match(acct, "0", |
|---|
| 4726 | "0") ? |
|---|
| 4727 | "checked=\"checked\"" : ""); |
|---|
| 4728 | websWrite(wp, "</div>\n"); |
|---|
| 4729 | char *rad = nvram_nget("%s_acct_ipaddr", prefix); |
|---|
| 4730 | |
|---|
| 4731 | websWrite(wp, "<div id=\"%s_idacct\">\n", vvar); |
|---|
| 4732 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4733 | websWrite(wp, |
|---|
| 4734 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label13)</script></div>\n"); |
|---|
| 4735 | websWrite(wp, |
|---|
| 4736 | "<input type=\"hidden\" name=\"%s_acct_ipaddr\" value=\"4\" />\n", |
|---|
| 4737 | prefix); |
|---|
| 4738 | websWrite(wp, |
|---|
| 4739 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_0\" onblur=\"valid_range(this,0,255,radius.label13)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4740 | prefix, get_single_ip(rad, 0)); |
|---|
| 4741 | websWrite(wp, |
|---|
| 4742 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_1\" onblur=\"valid_range(this,0,255,radius.label13)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4743 | prefix, get_single_ip(rad, 1)); |
|---|
| 4744 | websWrite(wp, |
|---|
| 4745 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_2\" onblur=\"valid_range(this,0,255,radius.label13)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4746 | prefix, get_single_ip(rad, 2)); |
|---|
| 4747 | websWrite(wp, |
|---|
| 4748 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_3\" onblur=\"valid_range(this,1,254,radius.label13)\" class=\"num\" value=\"%d\" />\n", |
|---|
| 4749 | prefix, get_single_ip(rad, 3)); |
|---|
| 4750 | websWrite(wp, "</div>\n"); |
|---|
| 4751 | |
|---|
| 4752 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4753 | websWrite(wp, |
|---|
| 4754 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label14)</script></div>\n"); |
|---|
| 4755 | sprintf(var, "%s_acct_port", prefix); |
|---|
| 4756 | websWrite(wp, |
|---|
| 4757 | "<input name=\"%s_acct_port\" size=\"3\" maxlength=\"5\" onblur=\"valid_range(this,1,65535,radius.label14)\" value=\"%s\" />\n", |
|---|
| 4758 | prefix, nvram_default_get(var, "1813")); |
|---|
| 4759 | websWrite(wp, |
|---|
| 4760 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 1812)\");\n//]]>\n</script></span>\n</div>\n"); |
|---|
| 4761 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4762 | websWrite(wp, |
|---|
| 4763 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label17)</script></div>\n"); |
|---|
| 4764 | sprintf(var, "%s_acct_key", prefix); |
|---|
| 4765 | websWrite(wp, |
|---|
| 4766 | "<input type=\"password\" id=\"%s_acct_key\" name=\"%s_acct_key\" maxlength=\"79\" size=\"32\" value=\"", |
|---|
| 4767 | prefix, prefix); |
|---|
| 4768 | tf_webWriteESCNV(wp, var); |
|---|
| 4769 | websWrite(wp, "\" /> \n"); |
|---|
| 4770 | websWrite(wp, |
|---|
| 4771 | "<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", |
|---|
| 4772 | prefix, prefix); |
|---|
| 4773 | websWrite(wp, "</div>\n"); |
|---|
| 4774 | websWrite(wp, "</div>\n"); |
|---|
| 4775 | websWrite(wp, "<script>\n//<![CDATA[\n "); |
|---|
| 4776 | websWrite(wp, |
|---|
| 4777 | "show_layer_ext(document.getElementsByName(\"%s_acct\"), \"%s_idacct\", %s);\n", |
|---|
| 4778 | prefix, vvar, nvram_match(acct, |
|---|
| 4779 | "1") ? "true" : "false"); |
|---|
| 4780 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4781 | } |
|---|
| 4782 | #endif |
|---|
| 4783 | } |
|---|
| 4784 | |
|---|
| 4785 | #ifdef HAVE_WPA_SUPPLICANT |
|---|
| 4786 | |
|---|
| 4787 | static void init_80211x_layers(webs_t wp, char *prefix) |
|---|
| 4788 | { |
|---|
| 4789 | if (nvram_prefix_match("8021xtype", prefix, "tls")) { |
|---|
| 4790 | websWrite(wp, "enable_idtls(\"%s\");\n", prefix); |
|---|
| 4791 | } |
|---|
| 4792 | if (nvram_prefix_match("8021xtype", prefix, "leap")) { |
|---|
| 4793 | websWrite(wp, "enable_idleap(\"%s\");\n", prefix); |
|---|
| 4794 | } |
|---|
| 4795 | if (nvram_prefix_match("8021xtype", prefix, "ttls")) { |
|---|
| 4796 | websWrite(wp, "enable_idttls(\"%s\");\n", prefix); |
|---|
| 4797 | } |
|---|
| 4798 | if (nvram_prefix_match("8021xtype", prefix, "peap")) { |
|---|
| 4799 | websWrite(wp, "enable_idpeap(\"%s\");\n", prefix); |
|---|
| 4800 | } |
|---|
| 4801 | } |
|---|
| 4802 | |
|---|
| 4803 | void ej_init_80211x_layers(webs_t wp, int argc, char_t ** argv) |
|---|
| 4804 | { |
|---|
| 4805 | #ifndef HAVE_MADWIFI |
|---|
| 4806 | int c = get_wl_instances(); |
|---|
| 4807 | int i; |
|---|
| 4808 | |
|---|
| 4809 | for (i = 0; i < c; i++) { |
|---|
| 4810 | char buf[16]; |
|---|
| 4811 | |
|---|
| 4812 | sprintf(buf, "wl%d", i); |
|---|
| 4813 | init_80211x_layers(wp, buf); |
|---|
| 4814 | } |
|---|
| 4815 | return; |
|---|
| 4816 | #else |
|---|
| 4817 | int c = getdevicecount(); |
|---|
| 4818 | int i; |
|---|
| 4819 | |
|---|
| 4820 | for (i = 0; i < c; i++) { |
|---|
| 4821 | char buf[16]; |
|---|
| 4822 | |
|---|
| 4823 | sprintf(buf, "ath%d", i); |
|---|
| 4824 | if (nvram_nmatch("8021X", "%s_security_mode", buf)) |
|---|
| 4825 | init_80211x_layers(wp, buf); |
|---|
| 4826 | } |
|---|
| 4827 | return; |
|---|
| 4828 | #endif |
|---|
| 4829 | |
|---|
| 4830 | } |
|---|
| 4831 | |
|---|
| 4832 | void show_80211X(webs_t wp, char *prefix) |
|---|
| 4833 | { |
|---|
| 4834 | /* |
|---|
| 4835 | * fields |
|---|
| 4836 | * _8021xtype |
|---|
| 4837 | * _8021xuser |
|---|
| 4838 | * _8021xpasswd |
|---|
| 4839 | * _8021xca |
|---|
| 4840 | * _8021xpem |
|---|
| 4841 | * _8021xprv |
|---|
| 4842 | * _8021xaddopt |
|---|
| 4843 | */ |
|---|
| 4844 | char type[32]; |
|---|
| 4845 | |
|---|
| 4846 | sprintf(type, "%s_8021xtype", prefix); |
|---|
| 4847 | nvram_default_get(type, "ttls"); |
|---|
| 4848 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4849 | websWrite(wp, |
|---|
| 4850 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.xsuptype)</script></div>\n"); |
|---|
| 4851 | websWrite(wp, |
|---|
| 4852 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"peap\" onclick=\"enable_idpeap('%s')\" %s />Peap \n", |
|---|
| 4853 | prefix, prefix, nvram_prefix_match("8021xtype", prefix, |
|---|
| 4854 | "peap") ? |
|---|
| 4855 | "checked=\"checked\"" : ""); |
|---|
| 4856 | websWrite(wp, |
|---|
| 4857 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"leap\" onclick=\"enable_idleap('%s')\" %s />Leap \n", |
|---|
| 4858 | prefix, prefix, nvram_prefix_match("8021xtype", prefix, |
|---|
| 4859 | "leap") ? |
|---|
| 4860 | "checked=\"checked\"" : ""); |
|---|
| 4861 | websWrite(wp, |
|---|
| 4862 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"tls\" onclick=\"enable_idtls('%s')\" %s />TLS \n", |
|---|
| 4863 | prefix, prefix, nvram_prefix_match("8021xtype", prefix, |
|---|
| 4864 | "tls") ? |
|---|
| 4865 | "checked=\"checked\"" : ""); |
|---|
| 4866 | websWrite(wp, |
|---|
| 4867 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"ttls\" onclick=\"enable_idttls('%s')\" %s />TTLS \n", |
|---|
| 4868 | prefix, prefix, nvram_prefix_match("8021xtype", prefix, |
|---|
| 4869 | "ttls") ? |
|---|
| 4870 | "checked=\"checked\"" : ""); |
|---|
| 4871 | websWrite(wp, "</div>\n"); |
|---|
| 4872 | // ttls authentication |
|---|
| 4873 | websWrite(wp, "<div id=\"idttls%s\">\n", prefix); |
|---|
| 4874 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4875 | websWrite(wp, |
|---|
| 4876 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n"); |
|---|
| 4877 | websWrite(wp, |
|---|
| 4878 | "<input name=\"%s_ttls8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4879 | prefix, nvram_prefix_get("ttls8021xuser", prefix)); |
|---|
| 4880 | |
|---|
| 4881 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4882 | websWrite(wp, |
|---|
| 4883 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.anon)</script></div>\n"); |
|---|
| 4884 | websWrite(wp, |
|---|
| 4885 | "<input name=\"%s_ttls8021xanon\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4886 | prefix, nvram_prefix_get("ttls8021xanon", prefix)); |
|---|
| 4887 | |
|---|
| 4888 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4889 | websWrite(wp, |
|---|
| 4890 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n"); |
|---|
| 4891 | websWrite(wp, |
|---|
| 4892 | "<input name=\"%s_ttls8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4893 | prefix, nvram_prefix_get("ttls8021xpasswd", prefix)); |
|---|
| 4894 | |
|---|
| 4895 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4896 | websWrite(wp, |
|---|
| 4897 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.phase2)</script></div>\n"); |
|---|
| 4898 | websWrite(wp, |
|---|
| 4899 | "<input name=\"%s_ttls8021xphase2\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4900 | prefix, nvram_prefix_get("ttls8021xphase2", prefix)); |
|---|
| 4901 | |
|---|
| 4902 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4903 | websWrite(wp, |
|---|
| 4904 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.servercertif)</script></div>\n"); |
|---|
| 4905 | websWrite(wp, |
|---|
| 4906 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_ttls8021xca\" name=\"%s_ttls8021xca\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4907 | prefix, prefix); |
|---|
| 4908 | websWrite(wp, "var %s_ttls8021xca = fix_cr( '", prefix); |
|---|
| 4909 | char namebuf[64]; |
|---|
| 4910 | sprintf(namebuf, "%s_ttls8021xca", prefix); |
|---|
| 4911 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 4912 | websWrite(wp, "' );\n"); |
|---|
| 4913 | websWrite(wp, |
|---|
| 4914 | "document.getElementById(\"%s_ttls8021xca\").value = %s_ttls8021xca;\n", |
|---|
| 4915 | prefix, prefix); |
|---|
| 4916 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4917 | websWrite(wp, "</div>\n"); |
|---|
| 4918 | |
|---|
| 4919 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4920 | websWrite(wp, |
|---|
| 4921 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.options)</script></div>\n"); |
|---|
| 4922 | websWrite(wp, |
|---|
| 4923 | "<textarea cols=\"60\" rows=\"3\" id=\"%s_ttls8021xaddopt\" name=\"%s_ttls8021xaddopt\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4924 | prefix, prefix); |
|---|
| 4925 | websWrite(wp, "var %s_ttls8021xaddopt = fix_cr( '", prefix); |
|---|
| 4926 | sprintf(namebuf, "%s_ttls8021xaddopt", prefix); |
|---|
| 4927 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 4928 | websWrite(wp, "' );\n"); |
|---|
| 4929 | websWrite(wp, |
|---|
| 4930 | "document.getElementById(\"%s_ttls8021xaddopt\").value = %s_ttls8021xaddopt;\n", |
|---|
| 4931 | prefix, prefix); |
|---|
| 4932 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4933 | websWrite(wp, "</div>\n"); |
|---|
| 4934 | |
|---|
| 4935 | websWrite(wp, "</div>\n"); |
|---|
| 4936 | |
|---|
| 4937 | // peap authentication |
|---|
| 4938 | websWrite(wp, "<div id=\"idpeap%s\">\n", prefix); |
|---|
| 4939 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4940 | websWrite(wp, |
|---|
| 4941 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n"); |
|---|
| 4942 | websWrite(wp, |
|---|
| 4943 | "<input name=\"%s_peap8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4944 | prefix, nvram_prefix_get("peap8021xuser", prefix)); |
|---|
| 4945 | |
|---|
| 4946 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4947 | websWrite(wp, |
|---|
| 4948 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.anon)</script></div>\n"); |
|---|
| 4949 | websWrite(wp, |
|---|
| 4950 | "<input name=\"%s_peap8021xanon\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4951 | prefix, nvram_prefix_get("peap8021xanon", prefix)); |
|---|
| 4952 | |
|---|
| 4953 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4954 | websWrite(wp, |
|---|
| 4955 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n"); |
|---|
| 4956 | websWrite(wp, |
|---|
| 4957 | "<input name=\"%s_peap8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4958 | prefix, nvram_prefix_get("peap8021xpasswd", prefix)); |
|---|
| 4959 | |
|---|
| 4960 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4961 | websWrite(wp, |
|---|
| 4962 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.phase2)</script></div>\n"); |
|---|
| 4963 | websWrite(wp, |
|---|
| 4964 | "<input name=\"%s_peap8021xphase2\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4965 | prefix, nvram_prefix_get("peap8021xphase2", prefix)); |
|---|
| 4966 | |
|---|
| 4967 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4968 | websWrite(wp, |
|---|
| 4969 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.servercertif)</script></div>\n"); |
|---|
| 4970 | websWrite(wp, |
|---|
| 4971 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_peap8021xca\" name=\"%s_peap8021xca\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4972 | prefix, prefix); |
|---|
| 4973 | |
|---|
| 4974 | websWrite(wp, "var %s_peap8021xca = fix_cr( '", prefix); |
|---|
| 4975 | sprintf(namebuf, "%s_peap8021xca", prefix); |
|---|
| 4976 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 4977 | websWrite(wp, "' );\n"); |
|---|
| 4978 | websWrite(wp, |
|---|
| 4979 | "document.getElementById(\"%s_peap8021xca\").value = %s_peap8021xca;\n", |
|---|
| 4980 | prefix, prefix); |
|---|
| 4981 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4982 | websWrite(wp, "</div>\n"); |
|---|
| 4983 | |
|---|
| 4984 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4985 | websWrite(wp, |
|---|
| 4986 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.options)</script></div>\n"); |
|---|
| 4987 | websWrite(wp, |
|---|
| 4988 | "<textarea cols=\"60\" rows=\"3\" id=\"%s_peap8021xaddopt\" name=\"%s_peap8021xaddopt\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4989 | prefix, prefix); |
|---|
| 4990 | websWrite(wp, "var %s_peap8021xaddopt = fix_cr( '", prefix); |
|---|
| 4991 | sprintf(namebuf, "%s_peap8021xaddopt", prefix); |
|---|
| 4992 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 4993 | websWrite(wp, "' );\n"); |
|---|
| 4994 | websWrite(wp, |
|---|
| 4995 | "document.getElementById(\"%s_peap8021xaddopt\").value = %s_peap8021xaddopt;\n", |
|---|
| 4996 | prefix, prefix); |
|---|
| 4997 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4998 | websWrite(wp, "</div>\n"); |
|---|
| 4999 | |
|---|
| 5000 | websWrite(wp, "</div>\n"); |
|---|
| 5001 | // leap authentication |
|---|
| 5002 | websWrite(wp, "<div id=\"idleap%s\">\n", prefix); |
|---|
| 5003 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5004 | websWrite(wp, |
|---|
| 5005 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n"); |
|---|
| 5006 | websWrite(wp, |
|---|
| 5007 | "<input name=\"%s_leap8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 5008 | prefix, nvram_prefix_get("leap8021xuser", prefix)); |
|---|
| 5009 | |
|---|
| 5010 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5011 | websWrite(wp, |
|---|
| 5012 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.anon)</script></div>\n"); |
|---|
| 5013 | websWrite(wp, |
|---|
| 5014 | "<input name=\"%s_leap8021xanon\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 5015 | prefix, nvram_prefix_get("leap8021xanon", prefix)); |
|---|
| 5016 | |
|---|
| 5017 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5018 | websWrite(wp, |
|---|
| 5019 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n"); |
|---|
| 5020 | websWrite(wp, |
|---|
| 5021 | "<input name=\"%s_leap8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 5022 | prefix, nvram_prefix_get("leap8021xpasswd", prefix)); |
|---|
| 5023 | |
|---|
| 5024 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5025 | websWrite(wp, |
|---|
| 5026 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.phase2)</script></div>\n"); |
|---|
| 5027 | websWrite(wp, |
|---|
| 5028 | "<input name=\"%s_leap8021xphase2\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 5029 | prefix, nvram_prefix_get("leap8021xphase2", prefix)); |
|---|
| 5030 | |
|---|
| 5031 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5032 | websWrite(wp, |
|---|
| 5033 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.options)</script></div>\n"); |
|---|
| 5034 | websWrite(wp, |
|---|
| 5035 | "<textarea cols=\"60\" rows=\"3\" id=\"%s_leap8021xaddopt\" name=\"%s_leap8021xaddopt\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 5036 | prefix, prefix); |
|---|
| 5037 | websWrite(wp, "var %s_leap8021xaddopt = fix_cr( '", prefix); |
|---|
| 5038 | sprintf(namebuf, "%s_leap8021xaddopt", prefix); |
|---|
| 5039 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 5040 | websWrite(wp, "' );\n"); |
|---|
| 5041 | websWrite(wp, |
|---|
| 5042 | "document.getElementById(\"%s_leap8021xaddopt\").value = %s_leap8021xaddopt;\n", |
|---|
| 5043 | prefix, prefix); |
|---|
| 5044 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 5045 | websWrite(wp, "</div>\n"); |
|---|
| 5046 | |
|---|
| 5047 | websWrite(wp, "</div>\n"); |
|---|
| 5048 | |
|---|
| 5049 | // tls authentication |
|---|
| 5050 | websWrite(wp, "<div id=\"idtls%s\">\n", prefix); |
|---|
| 5051 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5052 | websWrite(wp, |
|---|
| 5053 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n"); |
|---|
| 5054 | websWrite(wp, |
|---|
| 5055 | "<input name=\"%s_tls8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 5056 | prefix, nvram_prefix_get("tls8021xuser", prefix)); |
|---|
| 5057 | |
|---|
| 5058 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5059 | websWrite(wp, |
|---|
| 5060 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.anon)</script></div>\n"); |
|---|
| 5061 | websWrite(wp, |
|---|
| 5062 | "<input name=\"%s_tls8021xanon\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 5063 | prefix, nvram_prefix_get("tls8021xanon", prefix)); |
|---|
| 5064 | |
|---|
| 5065 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5066 | websWrite(wp, |
|---|
| 5067 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n"); |
|---|
| 5068 | websWrite(wp, |
|---|
| 5069 | "<input name=\"%s_tls8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 5070 | prefix, nvram_prefix_get("tls8021xpasswd", prefix)); |
|---|
| 5071 | |
|---|
| 5072 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5073 | websWrite(wp, |
|---|
| 5074 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.phase2)</script></div>\n"); |
|---|
| 5075 | websWrite(wp, |
|---|
| 5076 | "<input name=\"%s_tls8021xphase2\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 5077 | prefix, nvram_prefix_get("tls8021xphase2", prefix)); |
|---|
| 5078 | |
|---|
| 5079 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5080 | websWrite(wp, |
|---|
| 5081 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.servercertif)</script></div>\n"); |
|---|
| 5082 | websWrite(wp, |
|---|
| 5083 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xca\" name=\"%s_tls8021xca\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 5084 | prefix, prefix); |
|---|
| 5085 | websWrite(wp, "var %s_tls8021xca = fix_cr( '", prefix); |
|---|
| 5086 | sprintf(namebuf, "%s_tls8021xca", prefix); |
|---|
| 5087 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 5088 | websWrite(wp, "' );\n"); |
|---|
| 5089 | websWrite(wp, |
|---|
| 5090 | "document.getElementById(\"%s_tls8021xca\").value = %s_tls8021xca;\n", |
|---|
| 5091 | prefix, prefix); |
|---|
| 5092 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 5093 | websWrite(wp, "</div>\n"); |
|---|
| 5094 | |
|---|
| 5095 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5096 | websWrite(wp, |
|---|
| 5097 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.clientcertif)</script></div>\n"); |
|---|
| 5098 | websWrite(wp, |
|---|
| 5099 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xpem\" name=\"%s_tls8021xpem\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 5100 | prefix, prefix); |
|---|
| 5101 | websWrite(wp, "var %s_tls8021xpem = fix_cr( '", prefix); |
|---|
| 5102 | sprintf(namebuf, "%s_tls8021xpem", prefix); |
|---|
| 5103 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 5104 | websWrite(wp, "' );\n"); |
|---|
| 5105 | websWrite(wp, |
|---|
| 5106 | "document.getElementById(\"%s_tls8021xpem\").value = %s_tls8021xpem;\n", |
|---|
| 5107 | prefix, prefix); |
|---|
| 5108 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 5109 | websWrite(wp, "</div>\n"); |
|---|
| 5110 | |
|---|
| 5111 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5112 | websWrite(wp, |
|---|
| 5113 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.privatekey)</script></div>\n"); |
|---|
| 5114 | websWrite(wp, |
|---|
| 5115 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xprv\" name=\"%s_tls8021xprv\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 5116 | prefix, prefix); |
|---|
| 5117 | websWrite(wp, "var %s_tls8021xprv = fix_cr( '", prefix); |
|---|
| 5118 | sprintf(namebuf, "%s_tls8021xprv", prefix); |
|---|
| 5119 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 5120 | websWrite(wp, "' );\n"); |
|---|
| 5121 | websWrite(wp, |
|---|
| 5122 | "document.getElementById(\"%s_tls8021xprv\").value = %s_tls8021xprv;\n", |
|---|
| 5123 | prefix, prefix); |
|---|
| 5124 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 5125 | websWrite(wp, "</div>\n"); |
|---|
| 5126 | |
|---|
| 5127 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5128 | websWrite(wp, |
|---|
| 5129 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.options)</script></div>\n"); |
|---|
| 5130 | websWrite(wp, |
|---|
| 5131 | "<textarea cols=\"60\" rows=\"3\" id=\"%s_tls8021xaddopt\" name=\"%s_tls8021xaddopt\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 5132 | prefix, prefix); |
|---|
| 5133 | websWrite(wp, "var %s_tls8021xaddopt = fix_cr( '", prefix); |
|---|
| 5134 | sprintf(namebuf, "%s_tls8021xaddopt", prefix); |
|---|
| 5135 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 5136 | websWrite(wp, "' );\n"); |
|---|
| 5137 | websWrite(wp, |
|---|
| 5138 | "document.getElementById(\"%s_tls8021xaddopt\").value = %s_tls8021xaddopt;\n", |
|---|
| 5139 | prefix, prefix); |
|---|
| 5140 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 5141 | websWrite(wp, "</div>\n"); |
|---|
| 5142 | |
|---|
| 5143 | websWrite(wp, "</div>\n"); |
|---|
| 5144 | websWrite(wp, "<script>\n//<![CDATA[\n "); |
|---|
| 5145 | // websWrite |
|---|
| 5146 | // (wp,"show_layer_ext(document.getElementsByName(\"%s_bridged\"), |
|---|
| 5147 | // \"%s_idnetvifs\", %s);\n",var, vvar, nvram_match (ssid, "0") ? "true" |
|---|
| 5148 | // : "false"); |
|---|
| 5149 | char peap[32]; |
|---|
| 5150 | |
|---|
| 5151 | sprintf(peap, "%s_8021xtype", prefix); |
|---|
| 5152 | websWrite(wp, |
|---|
| 5153 | "show_layer_ext(document.wpa.%s_8021xtype, 'idpeap%s', %s);\n", |
|---|
| 5154 | prefix, prefix, nvram_match(peap, "peap") ? "true" : "false"); |
|---|
| 5155 | websWrite(wp, |
|---|
| 5156 | "show_layer_ext(document.wpa.%s_8021xtype, 'idtls%s', %s);\n", |
|---|
| 5157 | prefix, prefix, nvram_match(peap, "tls") ? "true" : "false"); |
|---|
| 5158 | websWrite(wp, |
|---|
| 5159 | "show_layer_ext(document.wpa.%s_8021xtype, 'idleap%s', %s);\n", |
|---|
| 5160 | prefix, prefix, nvram_match(peap, "leap") ? "true" : "false"); |
|---|
| 5161 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 5162 | |
|---|
| 5163 | } |
|---|
| 5164 | #endif |
|---|
| 5165 | |
|---|
| 5166 | #ifndef HAVE_WPA_SUPPLICANT |
|---|
| 5167 | void ej_init_80211x_layers(webs_t wp, int argc, char_t ** argv) |
|---|
| 5168 | { |
|---|
| 5169 | return; |
|---|
| 5170 | } |
|---|
| 5171 | #endif |
|---|
| 5172 | |
|---|
| 5173 | void show_wparadius(webs_t wp, char *prefix) |
|---|
| 5174 | { |
|---|
| 5175 | char var[80]; |
|---|
| 5176 | |
|---|
| 5177 | websWrite(wp, "<div>\n"); |
|---|
| 5178 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5179 | websWrite(wp, |
|---|
| 5180 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.algorithms)</script></div>\n"); |
|---|
| 5181 | websWrite(wp, "<select name=\"%s_crypto\">\n", prefix); |
|---|
| 5182 | sprintf(var, "%s_crypto", prefix); |
|---|
| 5183 | websWrite(wp, "<option value=\"tkip\" %s>TKIP</option>\n", |
|---|
| 5184 | selmatch(var, "tkip", "selected=\"selected\"")); |
|---|
| 5185 | websWrite(wp, "<option value=\"aes\" %s>AES</option>\n", |
|---|
| 5186 | selmatch(var, "aes", "selected=\"selected\"")); |
|---|
| 5187 | websWrite(wp, "<option value=\"tkip+aes\" %s>TKIP+AES</option>\n", |
|---|
| 5188 | selmatch(var, "tkip+aes", "selected=\"selected\"")); |
|---|
| 5189 | websWrite(wp, "</select></div>\n"); |
|---|
| 5190 | #ifdef HAVE_MADWIFI |
|---|
| 5191 | show_radius(wp, prefix, 0, 1); |
|---|
| 5192 | #else |
|---|
| 5193 | show_radius(wp, prefix, 0, 0); |
|---|
| 5194 | #endif |
|---|
| 5195 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5196 | websWrite(wp, |
|---|
| 5197 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.rekey)</script></div>\n"); |
|---|
| 5198 | sprintf(var, "%s_wpa_gtk_rekey", prefix); |
|---|
| 5199 | websWrite(wp, |
|---|
| 5200 | "<input name=\"%s_wpa_gtk_rekey\" maxlength=\"5\" size=\"10\" onblur=\"valid_range(this,0,99999,wpa.rekey)\" value=\"%s\" />", |
|---|
| 5201 | prefix, nvram_default_get(var, "3600")); |
|---|
| 5202 | websWrite(wp, "</div>\n"); |
|---|
| 5203 | websWrite(wp, "</div>\n"); |
|---|
| 5204 | } |
|---|
| 5205 | |
|---|
| 5206 | void show_wep(webs_t wp, char *prefix) |
|---|
| 5207 | { |
|---|
| 5208 | char var[80]; |
|---|
| 5209 | char *bit; |
|---|
| 5210 | |
|---|
| 5211 | cprintf("show wep\n"); |
|---|
| 5212 | #ifdef HAVE_MADWIFI |
|---|
| 5213 | char wl_authmode[16]; |
|---|
| 5214 | |
|---|
| 5215 | sprintf(wl_authmode, "%s_authmode", prefix); |
|---|
| 5216 | nvram_default_get(wl_authmode, "open"); |
|---|
| 5217 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5218 | websWrite(wp, |
|---|
| 5219 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label)</script></div>\n"); |
|---|
| 5220 | websWrite(wp, |
|---|
| 5221 | "<input class=\"spaceradio\" type=\"radio\" value=\"open\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.openn)</script></input> \n", |
|---|
| 5222 | wl_authmode, nvram_match(wl_authmode, |
|---|
| 5223 | "open") ? "checked=\"checked\"" : |
|---|
| 5224 | ""); |
|---|
| 5225 | websWrite(wp, |
|---|
| 5226 | "<input class=\"spaceradio\" type=\"radio\" value=\"shared\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.share_key)</script></input>\n", |
|---|
| 5227 | wl_authmode, nvram_match(wl_authmode, |
|---|
| 5228 | "shared") ? "checked=\"checked\"" : |
|---|
| 5229 | ""); |
|---|
| 5230 | websWrite(wp, "</div>\n"); |
|---|
| 5231 | #endif |
|---|
| 5232 | websWrite(wp, |
|---|
| 5233 | "<div><div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wep.defkey)</script></div>"); |
|---|
| 5234 | websWrite(wp, "<input type=\"hidden\" name=\"%s_WEP_key\" />", prefix); |
|---|
| 5235 | websWrite(wp, |
|---|
| 5236 | "<input type=\"hidden\" name=\"%s_wep\" value=\"restricted\" />", |
|---|
| 5237 | prefix); |
|---|
| 5238 | sprintf(var, "%s_key", prefix); |
|---|
| 5239 | nvram_default_get(var, "1"); |
|---|
| 5240 | websWrite(wp, |
|---|
| 5241 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s_key\" %s />1 \n", |
|---|
| 5242 | prefix, selmatch(var, "1", "checked=\"checked\"")); |
|---|
| 5243 | websWrite(wp, |
|---|
| 5244 | "<input class=\"spaceradio\" type=\"radio\" value=\"2\" name=\"%s_key\" %s />2 \n", |
|---|
| 5245 | prefix, selmatch(var, "2", "checked=\"checked\"")); |
|---|
| 5246 | websWrite(wp, |
|---|
| 5247 | "<input class=\"spaceradio\" type=\"radio\" value=\"3\" name=\"%s_key\" %s />3 \n", |
|---|
| 5248 | prefix, selmatch(var, "3", "checked=\"checked\"")); |
|---|
| 5249 | websWrite(wp, |
|---|
| 5250 | "<input class=\"spaceradio\" type=\"radio\" value=\"4\" name=\"%s_key\" %s />4 \n", |
|---|
| 5251 | prefix, selmatch(var, "4", "checked=\"checked\"")); |
|---|
| 5252 | websWrite(wp, "</div>"); |
|---|
| 5253 | websWrite(wp, |
|---|
| 5254 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.encrypt)</script></div>"); |
|---|
| 5255 | |
|---|
| 5256 | sprintf(var, "%s_wep_bit", prefix); |
|---|
| 5257 | bit = nvram_safe_get(var); |
|---|
| 5258 | |
|---|
| 5259 | cprintf("bit %s\n", bit); |
|---|
| 5260 | |
|---|
| 5261 | websWrite(wp, |
|---|
| 5262 | "<select name=\"%s_wep_bit\" size=\"1\" onchange=keyMode(this.form)>", |
|---|
| 5263 | prefix); |
|---|
| 5264 | websWrite(wp, "<option value=\"64\" %s >64 bits 10 hex digits</option>", |
|---|
| 5265 | selmatch(var, "64", "selected=\"selected\"")); |
|---|
| 5266 | websWrite(wp, |
|---|
| 5267 | "<option value=\"128\" %s >128 bits 26 hex digits</option>", |
|---|
| 5268 | selmatch(var, "128", "selected=\"selected\"")); |
|---|
| 5269 | websWrite(wp, |
|---|
| 5270 | "</select>\n</div>\n<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wep.passphrase)</script></div>\n"); |
|---|
| 5271 | websWrite(wp, |
|---|
| 5272 | "<input name=%s_passphrase maxlength=\"16\" size=\"20\" value=\"", |
|---|
| 5273 | prefix); |
|---|
| 5274 | |
|---|
| 5275 | char p_temp[128]; |
|---|
| 5276 | char temp[256]; |
|---|
| 5277 | |
|---|
| 5278 | sprintf(p_temp, "%s", get_wep_value(temp, "passphrase", bit, prefix)); |
|---|
| 5279 | nvram_set("passphrase_temp", p_temp); |
|---|
| 5280 | tf_webWriteESCNV(wp, "passphrase_temp"); |
|---|
| 5281 | nvram_unset("passphrase_temp"); |
|---|
| 5282 | |
|---|
| 5283 | websWrite(wp, "\" />"); |
|---|
| 5284 | websWrite(wp, |
|---|
| 5285 | "<input type=\"hidden\" value=\"Null\" name=\"generateButton\" />\n"); |
|---|
| 5286 | websWrite(wp, |
|---|
| 5287 | "<input class=\"button\" type=\"button\" value=\"Generate\" onclick=generateKey(this.form,\"%s\") name=wepGenerate />\n</div>", |
|---|
| 5288 | prefix); |
|---|
| 5289 | |
|---|
| 5290 | char *mlen = "10"; |
|---|
| 5291 | char *mlen2 = "12"; |
|---|
| 5292 | |
|---|
| 5293 | if (!strcmp(bit, "128")) { |
|---|
| 5294 | mlen = "26"; |
|---|
| 5295 | mlen2 = "30"; |
|---|
| 5296 | } |
|---|
| 5297 | websWrite(wp, |
|---|
| 5298 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 1</div>\n"); |
|---|
| 5299 | websWrite(wp, |
|---|
| 5300 | "<input name=%s_key1 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 5301 | prefix, mlen2, mlen, get_wep_value(temp, "key1", bit, |
|---|
| 5302 | prefix)); |
|---|
| 5303 | websWrite(wp, |
|---|
| 5304 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 2</div>\n"); |
|---|
| 5305 | websWrite(wp, |
|---|
| 5306 | "<input name=%s_key2 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 5307 | prefix, mlen2, mlen, get_wep_value(temp, "key2", bit, |
|---|
| 5308 | prefix)); |
|---|
| 5309 | websWrite(wp, |
|---|
| 5310 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 3</div>\n"); |
|---|
| 5311 | websWrite(wp, |
|---|
| 5312 | "<input name=%s_key3 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 5313 | prefix, mlen2, mlen, get_wep_value(temp, "key3", bit, |
|---|
| 5314 | prefix)); |
|---|
| 5315 | websWrite(wp, |
|---|
| 5316 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 4</div>\n"); |
|---|
| 5317 | websWrite(wp, |
|---|
| 5318 | "<input name=%s_key4 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 5319 | prefix, mlen2, mlen, get_wep_value(temp, "key4", bit, |
|---|
| 5320 | prefix)); |
|---|
| 5321 | websWrite(wp, "</div>\n"); |
|---|
| 5322 | } |
|---|
| 5323 | |
|---|
| 5324 | void ej_show_defwpower(webs_t wp, int argc, char_t ** argv) |
|---|
| 5325 | { |
|---|
| 5326 | switch (getRouterBrand()) |
|---|
| 5327 | { |
|---|
| 5328 | case ROUTER_ASUS_RTN10: |
|---|
| 5329 | case ROUTER_ASUS_RTN12: |
|---|
| 5330 | case ROUTER_ASUS_RTN16: |
|---|
| 5331 | websWrite(wp, "17"); |
|---|
| 5332 | break; |
|---|
| 5333 | case ROUTER_BUFFALO_WHRG54S: |
|---|
| 5334 | case ROUTER_BUFFALO_WLI_TX4_G54HP: |
|---|
| 5335 | websWrite(wp, "28"); |
|---|
| 5336 | break; |
|---|
| 5337 | default: |
|---|
| 5338 | websWrite(wp, "71"); |
|---|
| 5339 | break; |
|---|
| 5340 | } |
|---|
| 5341 | } |
|---|
| 5342 | |
|---|
| 5343 | void ej_get_wds_mac(webs_t wp, int argc, char_t ** argv) |
|---|
| 5344 | { |
|---|
| 5345 | int mac = -1, wds_idx = -1, mac_idx = -1; |
|---|
| 5346 | char *c, wds_var[32] = ""; |
|---|
| 5347 | |
|---|
| 5348 | char *interface; |
|---|
| 5349 | |
|---|
| 5350 | if (ejArgs(argc, argv, "%d %d %s", &wds_idx, &mac_idx, &interface) < 3) { |
|---|
| 5351 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5352 | return; |
|---|
| 5353 | } else if (wds_idx < 1 || wds_idx > MAX_WDS_DEVS) |
|---|
| 5354 | return; |
|---|
| 5355 | else if (mac_idx < 0 || mac_idx > 5) |
|---|
| 5356 | return; |
|---|
| 5357 | |
|---|
| 5358 | snprintf(wds_var, 31, "%s_wds%d_hwaddr", interface, wds_idx); |
|---|
| 5359 | |
|---|
| 5360 | c = nvram_safe_get(wds_var); |
|---|
| 5361 | |
|---|
| 5362 | if (c) { |
|---|
| 5363 | mac = get_single_mac(c, mac_idx); |
|---|
| 5364 | websWrite(wp, "%02X", mac); |
|---|
| 5365 | } else |
|---|
| 5366 | websWrite(wp, "00"); |
|---|
| 5367 | |
|---|
| 5368 | return; |
|---|
| 5369 | |
|---|
| 5370 | } |
|---|
| 5371 | |
|---|
| 5372 | void ej_showbridgesettings(webs_t wp, int argc, char_t ** argv) |
|---|
| 5373 | { |
|---|
| 5374 | char *interface; |
|---|
| 5375 | int mcast; |
|---|
| 5376 | |
|---|
| 5377 | #ifdef FASTWEB |
|---|
| 5378 | ejArgs(argc, argv, "%s %d", &interface, &mcast); |
|---|
| 5379 | #else |
|---|
| 5380 | if (ejArgs(argc, argv, "%s %d", &interface, &mcast) < 2) { |
|---|
| 5381 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5382 | return; |
|---|
| 5383 | } |
|---|
| 5384 | #endif |
|---|
| 5385 | showbridgesettings(wp, interface, mcast, 0); |
|---|
| 5386 | } |
|---|
| 5387 | |
|---|
| 5388 | void ej_get_wds_ip(webs_t wp, int argc, char_t ** argv) |
|---|
| 5389 | { |
|---|
| 5390 | int ip = -1, wds_idx = -1, ip_idx = -1; |
|---|
| 5391 | char *c, wds_var[32] = ""; |
|---|
| 5392 | |
|---|
| 5393 | char *interface; |
|---|
| 5394 | |
|---|
| 5395 | #ifdef FASTWEB |
|---|
| 5396 | ejArgs(argc, argv, "%d %d %s", &wds_idx, &ip_idx, &interface); |
|---|
| 5397 | #else |
|---|
| 5398 | if (ejArgs(argc, argv, "%d %d %s", &wds_idx, &ip_idx, &interface) < 3) { |
|---|
| 5399 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5400 | return; |
|---|
| 5401 | } |
|---|
| 5402 | #endif |
|---|
| 5403 | if (wds_idx < 1 || wds_idx > MAX_WDS_DEVS) |
|---|
| 5404 | return; |
|---|
| 5405 | else if (ip_idx < 0 || ip_idx > 3) |
|---|
| 5406 | return; |
|---|
| 5407 | |
|---|
| 5408 | snprintf(wds_var, 31, "%s_wds%d_ipaddr", interface, wds_idx); |
|---|
| 5409 | |
|---|
| 5410 | c = nvram_safe_get(wds_var); |
|---|
| 5411 | |
|---|
| 5412 | if (c) { |
|---|
| 5413 | ip = get_single_ip(c, ip_idx); |
|---|
| 5414 | websWrite(wp, "%d", ip); |
|---|
| 5415 | } else |
|---|
| 5416 | websWrite(wp, "0"); |
|---|
| 5417 | |
|---|
| 5418 | return; |
|---|
| 5419 | |
|---|
| 5420 | } |
|---|
| 5421 | |
|---|
| 5422 | void ej_get_wds_netmask(webs_t wp, int argc, char_t ** argv) |
|---|
| 5423 | { |
|---|
| 5424 | int nm = -1, wds_idx = -1, nm_idx = -1; |
|---|
| 5425 | char *c, wds_var[32] = ""; |
|---|
| 5426 | |
|---|
| 5427 | char *interface; |
|---|
| 5428 | |
|---|
| 5429 | #ifdef FASTWEB |
|---|
| 5430 | ejArgs(argc, argv, "%d %d %s", &wds_idx, &nm_idx, &interface); |
|---|
| 5431 | #else |
|---|
| 5432 | if (ejArgs(argc, argv, "%d %d %s", &wds_idx, &nm_idx, &interface) < 3) { |
|---|
| 5433 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5434 | return; |
|---|
| 5435 | } |
|---|
| 5436 | #endif |
|---|
| 5437 | |
|---|
| 5438 | if (wds_idx < 1 || wds_idx > 6) |
|---|
| 5439 | return; |
|---|
| 5440 | else if (nm_idx < 0 || nm_idx > 3) |
|---|
| 5441 | return; |
|---|
| 5442 | |
|---|
| 5443 | snprintf(wds_var, 31, "%s_wds%d_netmask", interface, wds_idx); |
|---|
| 5444 | |
|---|
| 5445 | c = nvram_safe_get(wds_var); |
|---|
| 5446 | |
|---|
| 5447 | if (c) { |
|---|
| 5448 | nm = get_single_ip(c, nm_idx); |
|---|
| 5449 | websWrite(wp, "%d", nm); |
|---|
| 5450 | } else |
|---|
| 5451 | websWrite(wp, "255"); |
|---|
| 5452 | |
|---|
| 5453 | return; |
|---|
| 5454 | |
|---|
| 5455 | } |
|---|
| 5456 | |
|---|
| 5457 | void ej_get_wds_gw(webs_t wp, int argc, char_t ** argv) |
|---|
| 5458 | { |
|---|
| 5459 | int gw = -1, wds_idx = -1, gw_idx = -1; |
|---|
| 5460 | char *c, wds_var[32] = ""; |
|---|
| 5461 | |
|---|
| 5462 | char *interface; |
|---|
| 5463 | |
|---|
| 5464 | #ifdef FASTWEB |
|---|
| 5465 | ejArgs(argc, argv, "%d %d %s", &wds_idx, &gw_idx, &interface); |
|---|
| 5466 | #else |
|---|
| 5467 | if (ejArgs(argc, argv, "%d %d %s", &wds_idx, &gw_idx, &interface) < 3) { |
|---|
| 5468 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5469 | return; |
|---|
| 5470 | } |
|---|
| 5471 | #endif |
|---|
| 5472 | |
|---|
| 5473 | if (wds_idx < 1 || wds_idx > MAX_WDS_DEVS) |
|---|
| 5474 | return; |
|---|
| 5475 | else if (gw_idx < 0 || gw_idx > 3) |
|---|
| 5476 | return; |
|---|
| 5477 | |
|---|
| 5478 | snprintf(wds_var, 31, "%s_wds%d_gw", interface, wds_idx); |
|---|
| 5479 | |
|---|
| 5480 | c = nvram_safe_get(wds_var); |
|---|
| 5481 | |
|---|
| 5482 | if (c) { |
|---|
| 5483 | gw = get_single_ip(c, gw_idx); |
|---|
| 5484 | websWrite(wp, "%d", gw); |
|---|
| 5485 | } else |
|---|
| 5486 | websWrite(wp, "0"); |
|---|
| 5487 | |
|---|
| 5488 | return; |
|---|
| 5489 | |
|---|
| 5490 | } |
|---|
| 5491 | |
|---|
| 5492 | void ej_get_br1_ip(webs_t wp, int argc, char_t ** argv) |
|---|
| 5493 | { |
|---|
| 5494 | int ip = -1, ip_idx = -1; |
|---|
| 5495 | char *c; |
|---|
| 5496 | |
|---|
| 5497 | char *interface; |
|---|
| 5498 | |
|---|
| 5499 | #ifdef FASTWEB |
|---|
| 5500 | ejArgs(argc, argv, "%d %s", &ip_idx, &interface); |
|---|
| 5501 | #else |
|---|
| 5502 | if (ejArgs(argc, argv, "%d %s", &ip_idx, &interface) < 2) { |
|---|
| 5503 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5504 | return; |
|---|
| 5505 | } |
|---|
| 5506 | #endif |
|---|
| 5507 | if (ip_idx < 0 || ip_idx > 3) |
|---|
| 5508 | return; |
|---|
| 5509 | char br1[32]; |
|---|
| 5510 | |
|---|
| 5511 | sprintf(br1, "%s_br1_ipaddr", interface); |
|---|
| 5512 | c = nvram_safe_get(br1); |
|---|
| 5513 | |
|---|
| 5514 | if (c) { |
|---|
| 5515 | ip = get_single_ip(c, ip_idx); |
|---|
| 5516 | websWrite(wp, "%d", ip); |
|---|
| 5517 | } else |
|---|
| 5518 | websWrite(wp, "0"); |
|---|
| 5519 | |
|---|
| 5520 | return; |
|---|
| 5521 | |
|---|
| 5522 | } |
|---|
| 5523 | |
|---|
| 5524 | void ej_get_br1_netmask(webs_t wp, int argc, char_t ** argv) |
|---|
| 5525 | { |
|---|
| 5526 | int nm = -1, nm_idx = -1; |
|---|
| 5527 | char *c; |
|---|
| 5528 | |
|---|
| 5529 | char *interface; |
|---|
| 5530 | |
|---|
| 5531 | #ifdef FASTWEB |
|---|
| 5532 | ejArgs(argc, argv, "%d %s", &nm_idx, &interface); |
|---|
| 5533 | #else |
|---|
| 5534 | if (ejArgs(argc, argv, "%d %s", &nm_idx, &interface) < 2) { |
|---|
| 5535 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5536 | return; |
|---|
| 5537 | } |
|---|
| 5538 | #endif |
|---|
| 5539 | if (nm_idx < 0 || nm_idx > 3) |
|---|
| 5540 | return; |
|---|
| 5541 | char nms[32]; |
|---|
| 5542 | |
|---|
| 5543 | sprintf(nms, "%s_br1_netmask", interface); |
|---|
| 5544 | c = nvram_safe_get(nms); |
|---|
| 5545 | |
|---|
| 5546 | if (c) { |
|---|
| 5547 | nm = get_single_ip(c, nm_idx); |
|---|
| 5548 | websWrite(wp, "%d", nm); |
|---|
| 5549 | } else |
|---|
| 5550 | websWrite(wp, "255"); |
|---|
| 5551 | |
|---|
| 5552 | return; |
|---|
| 5553 | |
|---|
| 5554 | } |
|---|
| 5555 | |
|---|
| 5556 | void ej_get_uptime(webs_t wp, int argc, char_t ** argv) |
|---|
| 5557 | { |
|---|
| 5558 | char line[256]; |
|---|
| 5559 | FILE *fp; |
|---|
| 5560 | |
|---|
| 5561 | if ((fp = popen("uptime", "r"))) { |
|---|
| 5562 | fgets(line, sizeof(line), fp); |
|---|
| 5563 | line[strlen(line) - 1] = '\0'; // replace new line with null |
|---|
| 5564 | websWrite(wp, "%s", line); |
|---|
| 5565 | pclose(fp); |
|---|
| 5566 | } |
|---|
| 5567 | return; |
|---|
| 5568 | } |
|---|
| 5569 | |
|---|
| 5570 | void ej_get_wan_uptime(webs_t wp, int argc, char_t ** argv) |
|---|
| 5571 | { |
|---|
| 5572 | float sys_uptime; |
|---|
| 5573 | float uptime; |
|---|
| 5574 | int days, minutes; |
|---|
| 5575 | FILE *fp, *fp2; |
|---|
| 5576 | |
|---|
| 5577 | if (nvram_match("wan_proto", "disabled")) |
|---|
| 5578 | return; |
|---|
| 5579 | if (nvram_match("wan_ipaddr", "0.0.0.0")) { |
|---|
| 5580 | websWrite(wp, "%s", live_translate("status_router.notavail")); |
|---|
| 5581 | return; |
|---|
| 5582 | } |
|---|
| 5583 | if (!(fp = fopen("/tmp/.wanuptime", "r"))) { |
|---|
| 5584 | websWrite(wp, "%s", live_translate("status_router.notavail")); |
|---|
| 5585 | return; |
|---|
| 5586 | } |
|---|
| 5587 | if (!feof(fp) && fscanf(fp, "%f", &uptime) == 1) { |
|---|
| 5588 | fp2 = fopen("/proc/uptime", "r"); |
|---|
| 5589 | fscanf(fp2, "%f", &sys_uptime); |
|---|
| 5590 | fclose(fp2); |
|---|
| 5591 | uptime = sys_uptime - uptime; |
|---|
| 5592 | days = (int)uptime / (60 * 60 * 24); |
|---|
| 5593 | if (days) |
|---|
| 5594 | websWrite(wp, "%d day%s, ", days, |
|---|
| 5595 | (days == 1 ? "" : "s")); |
|---|
| 5596 | minutes = (int)uptime / 60; |
|---|
| 5597 | websWrite(wp, "%d:%02d:%02d", (minutes / 60) % 24, minutes % 60, |
|---|
| 5598 | (int)uptime % 60); |
|---|
| 5599 | } |
|---|
| 5600 | fclose(fp); |
|---|
| 5601 | |
|---|
| 5602 | return; |
|---|
| 5603 | |
|---|
| 5604 | } |
|---|
| 5605 | |
|---|
| 5606 | void ej_get_wdsp2p(webs_t wp, int argc, char_t ** argv) |
|---|
| 5607 | { |
|---|
| 5608 | int index = -1, ip[4] = { 0, 0, 0, 0 }, netmask[4] = { |
|---|
| 5609 | 0, 0, 0, 0}; |
|---|
| 5610 | char nvramvar[32] = { 0 }; |
|---|
| 5611 | char *interface; |
|---|
| 5612 | |
|---|
| 5613 | #ifdef FASTWEB |
|---|
| 5614 | ejArgs(argc, argv, "%d %s", &index, &interface); |
|---|
| 5615 | #else |
|---|
| 5616 | if (ejArgs(argc, argv, "%d %s", &index, &interface) < 2) { |
|---|
| 5617 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5618 | return; |
|---|
| 5619 | } |
|---|
| 5620 | #endif |
|---|
| 5621 | char wlwds[32]; |
|---|
| 5622 | |
|---|
| 5623 | sprintf(wlwds, "%s_wds1_enable", interface); |
|---|
| 5624 | if (nvram_selmatch(wp, "wk_mode", "ospf") && |
|---|
| 5625 | nvram_selmatch(wp, "expert_mode", "1") && |
|---|
| 5626 | nvram_selmatch(wp, wlwds, "1")) { |
|---|
| 5627 | char buf[16]; |
|---|
| 5628 | |
|---|
| 5629 | sprintf(buf, "%s_wds%d_ospf", interface, index); |
|---|
| 5630 | websWrite(wp, |
|---|
| 5631 | "<input name=\"%s\" size=\"2\" maxlength=\"5\" value=\"%s\" />\n", |
|---|
| 5632 | buf, nvram_safe_get(buf)); |
|---|
| 5633 | } |
|---|
| 5634 | |
|---|
| 5635 | snprintf(nvramvar, 31, "%s_wds%d_ipaddr", interface, index); |
|---|
| 5636 | sscanf(nvram_safe_get(nvramvar), "%d.%d.%d.%d", &ip[0], &ip[1], &ip[2], |
|---|
| 5637 | &ip[3]); |
|---|
| 5638 | snprintf(nvramvar, 31, "%s_wds%d_netmask", interface, index); |
|---|
| 5639 | sscanf(nvram_safe_get(nvramvar), "%d.%d.%d.%d", &netmask[0], |
|---|
| 5640 | &netmask[1], &netmask[2], &netmask[3]); |
|---|
| 5641 | snprintf(nvramvar, 31, "%s_wds%d_enable", interface, index); |
|---|
| 5642 | |
|---|
| 5643 | // set netmask to a suggested default if blank |
|---|
| 5644 | if (netmask[0] == 0 && |
|---|
| 5645 | netmask[1] == 0 && netmask[2] == 0 && netmask[3] == 0) { |
|---|
| 5646 | netmask[0] = 255; |
|---|
| 5647 | netmask[1] = 255; |
|---|
| 5648 | netmask[2] = 255; |
|---|
| 5649 | netmask[3] = 252; |
|---|
| 5650 | } |
|---|
| 5651 | |
|---|
| 5652 | if (nvram_match(nvramvar, "1")) { |
|---|
| 5653 | websWrite(wp, "\ |
|---|
| 5654 | <div class=\"setting\">\n\ |
|---|
| 5655 | <input type=\"hidden\" name=\"%s_wds%d_ipaddr\" value=\"4\">\n\ |
|---|
| 5656 | <div class=\"label\"><script type=\"text/javascript\">Capture(share.ip)</script></div>\n\ |
|---|
| 5657 | <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\ |
|---|
| 5658 | </div>\n", interface, index, interface, index, ip[0], interface, index, ip[1], interface, index, ip[2], interface, index, ip[3]); |
|---|
| 5659 | |
|---|
| 5660 | websWrite(wp, "\ |
|---|
| 5661 | <div class=\"setting\">\n\ |
|---|
| 5662 | <div class=\"label\"><script type=\"text/javascript\">Capture(share.subnet)</script></div>\n\ |
|---|
| 5663 | <input type=\"hidden\" name=\"%s_wds%d_netmask\" value=\"4\">\n\ |
|---|
| 5664 | <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\ |
|---|
| 5665 | </div>\n", interface, index, interface, index, netmask[0], interface, index, netmask[1], interface, index, netmask[2], interface, index, netmask[3]); |
|---|
| 5666 | |
|---|
| 5667 | } |
|---|
| 5668 | |
|---|
| 5669 | return; |
|---|
| 5670 | |
|---|
| 5671 | } |
|---|
| 5672 | |
|---|
| 5673 | /* |
|---|
| 5674 | * void ej_get_services_options (webs_t wp, int argc, char_t ** argv) { char |
|---|
| 5675 | * word[1024], *next, *services; char delim[] = "< >"; |
|---|
| 5676 | * |
|---|
| 5677 | * //services = nvram_safe_get("filter_services"); services = |
|---|
| 5678 | * get_filter_services (); |
|---|
| 5679 | * |
|---|
| 5680 | * split (word, services, next, delim) { int len = 0; char *name, *prot, |
|---|
| 5681 | * *port; char protocol[100], ports[100]; int from = 0, to = 0; //int proto; |
|---|
| 5682 | * |
|---|
| 5683 | * if ((name = strstr (word, "$NAME:")) == NULL || (prot = strstr (word, |
|---|
| 5684 | * "$PROT:")) == NULL || (port = strstr (word, "$PORT:")) == NULL) continue; |
|---|
| 5685 | * |
|---|
| 5686 | * // $NAME if (sscanf (name, "$NAME:%3d:", &len) != 1) continue; |
|---|
| 5687 | * |
|---|
| 5688 | * strncpy (name, name + sizeof ("$NAME:nnn:") - 1, len); name[len] = '\0'; |
|---|
| 5689 | * |
|---|
| 5690 | * // $PROT if (sscanf (prot, "$PROT:%3d:", &len) != 1) continue; |
|---|
| 5691 | * |
|---|
| 5692 | * strncpy (protocol, prot + sizeof ("$PROT:nnn:") - 1, len); protocol[len] = |
|---|
| 5693 | * '\0'; |
|---|
| 5694 | * |
|---|
| 5695 | * // $PORT if (sscanf (port, "$PORT:%3d:", &len) != 1) continue; |
|---|
| 5696 | * |
|---|
| 5697 | * strncpy (ports, port + sizeof ("$PORT:nnn:") - 1, len); ports[len] = '\0'; |
|---|
| 5698 | * |
|---|
| 5699 | * if (sscanf (ports, "%d:%d", &from, &to) != 2) continue; |
|---|
| 5700 | * |
|---|
| 5701 | * //cprintf("match:: name=%s, protocol=%s, ports=%s\n", // word, protocol, |
|---|
| 5702 | * ports); |
|---|
| 5703 | * |
|---|
| 5704 | * websWrite (wp, "<option value=\"%s\">%s</option>", name, name); |
|---|
| 5705 | * |
|---|
| 5706 | * } |
|---|
| 5707 | * |
|---|
| 5708 | * return; } |
|---|
| 5709 | */ |
|---|
| 5710 | |
|---|
| 5711 | void ej_get_clone_wmac(webs_t wp, int argc, char_t ** argv) |
|---|
| 5712 | { |
|---|
| 5713 | #ifdef HAVE_RB500 |
|---|
| 5714 | return 0; |
|---|
| 5715 | #else |
|---|
| 5716 | |
|---|
| 5717 | char *c; |
|---|
| 5718 | int mac, which; |
|---|
| 5719 | int dofree = 0; |
|---|
| 5720 | |
|---|
| 5721 | #ifdef FASTWEB |
|---|
| 5722 | ejArgs(argc, argv, "%d", &which); |
|---|
| 5723 | #else |
|---|
| 5724 | if (ejArgs(argc, argv, "%d", &which) < 1) { |
|---|
| 5725 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5726 | return; |
|---|
| 5727 | } |
|---|
| 5728 | #endif |
|---|
| 5729 | |
|---|
| 5730 | if (nvram_match("def_whwaddr", "00:00:00:00:00:00")) { |
|---|
| 5731 | // if (strlen (nvram_safe_get ("il0macaddr")) == 0) |
|---|
| 5732 | // { |
|---|
| 5733 | // if (nvram_match ("port_swap", "1")) |
|---|
| 5734 | // c = strdup (nvram_safe_get ("et1macaddr")); |
|---|
| 5735 | // else |
|---|
| 5736 | // c = strdup (nvram_safe_get ("et0macaddr")); |
|---|
| 5737 | // MAC_ADD (c); |
|---|
| 5738 | // } |
|---|
| 5739 | // else |
|---|
| 5740 | // { |
|---|
| 5741 | // c = strdup (nvram_safe_get ("il0macaddr")); |
|---|
| 5742 | // } |
|---|
| 5743 | // dofree = 1; |
|---|
| 5744 | |
|---|
| 5745 | if (nvram_match("port_swap", "1")) { |
|---|
| 5746 | if (strlen(nvram_safe_get("et1macaddr")) != 0) // safe: |
|---|
| 5747 | // maybe |
|---|
| 5748 | // et1macaddr |
|---|
| 5749 | // not there? |
|---|
| 5750 | { |
|---|
| 5751 | c = strdup(nvram_safe_get("et1macaddr")); |
|---|
| 5752 | } else { |
|---|
| 5753 | c = strdup(nvram_safe_get("et0macaddr")); |
|---|
| 5754 | MAC_ADD(c); // et0macaddr +3 |
|---|
| 5755 | } |
|---|
| 5756 | } else { |
|---|
| 5757 | c = strdup(nvram_safe_get("et0macaddr")); |
|---|
| 5758 | } |
|---|
| 5759 | |
|---|
| 5760 | dofree = 1; |
|---|
| 5761 | if (c) { |
|---|
| 5762 | MAC_ADD(c); |
|---|
| 5763 | MAC_ADD(c); |
|---|
| 5764 | } |
|---|
| 5765 | |
|---|
| 5766 | } else |
|---|
| 5767 | c = nvram_safe_get("def_whwaddr"); |
|---|
| 5768 | |
|---|
| 5769 | if (c) { |
|---|
| 5770 | mac = get_single_mac(c, which); |
|---|
| 5771 | websWrite(wp, "%02X", mac); |
|---|
| 5772 | if (dofree) |
|---|
| 5773 | free(c); |
|---|
| 5774 | } else |
|---|
| 5775 | websWrite(wp, "00"); |
|---|
| 5776 | |
|---|
| 5777 | return; |
|---|
| 5778 | #endif |
|---|
| 5779 | } |
|---|
| 5780 | |
|---|
| 5781 | /* |
|---|
| 5782 | * todo stylesheet compatible code |
|---|
| 5783 | */ |
|---|
| 5784 | /* |
|---|
| 5785 | * lonewolf additions |
|---|
| 5786 | */ |
|---|
| 5787 | |
|---|
| 5788 | // Note that there is no VLAN #16. It's just a convieniant way of denoting a |
|---|
| 5789 | // "Tagged" port |
|---|
| 5790 | void ej_port_vlan_table(webs_t wp, int argc, char_t ** argv) |
|---|
| 5791 | { |
|---|
| 5792 | /* |
|---|
| 5793 | * vlans[x][y] where x 0-15 are VLANS x 16 is tagging, 17 is |
|---|
| 5794 | * auto-negotiation, 18 is 100/10 Mbit, and 19 is Full/Half duplex y 0-4 |
|---|
| 5795 | * are switch ports (port 5 is set automaticly) y 5 it the bridge device |
|---|
| 5796 | * (x 16 dosn't apply) |
|---|
| 5797 | */ |
|---|
| 5798 | |
|---|
| 5799 | int i, j, vlans[21][6], tmp, wl_br; |
|---|
| 5800 | char *c, *next, buff[32], portvlan[32]; |
|---|
| 5801 | |
|---|
| 5802 | for (i = 0; i < 21; i++) |
|---|
| 5803 | for (j = 0; j < 6; j++) |
|---|
| 5804 | vlans[i][j] = -1; |
|---|
| 5805 | |
|---|
| 5806 | wl_br = -1; |
|---|
| 5807 | |
|---|
| 5808 | for (i = 0; i < 8; i++) { |
|---|
| 5809 | if (i < 5) |
|---|
| 5810 | snprintf(buff, 31, "port%dvlans", i); |
|---|
| 5811 | else if (i == 5) |
|---|
| 5812 | snprintf(buff, 31, "%s", "lan_ifnames"); |
|---|
| 5813 | else |
|---|
| 5814 | snprintf(buff, 31, "ub%d_ifnames", i - 5); |
|---|
| 5815 | |
|---|
| 5816 | c = nvram_safe_get(buff); |
|---|
| 5817 | |
|---|
| 5818 | if (c) { |
|---|
| 5819 | foreach(portvlan, c, next) { |
|---|
| 5820 | if (portvlan[0] == 'e' && portvlan[1] == 't' |
|---|
| 5821 | && portvlan[2] == 'h' && portvlan[3] == '1') |
|---|
| 5822 | wl_br = i - 5; |
|---|
| 5823 | if (ISDIGIT(portvlan, 1) |
|---|
| 5824 | || (portvlan[0] == 'v' && portvlan[1] == 'l' |
|---|
| 5825 | && portvlan[2] == 'a' |
|---|
| 5826 | && portvlan[3] == 'n')) { |
|---|
| 5827 | if (ISDIGIT(portvlan, 1)) |
|---|
| 5828 | tmp = atoi(portvlan); |
|---|
| 5829 | else { |
|---|
| 5830 | portvlan[0] = portvlan[4]; |
|---|
| 5831 | portvlan[1] = portvlan[5]; |
|---|
| 5832 | portvlan[2] = '\0'; |
|---|
| 5833 | if (ISDIGIT(portvlan, 1)) |
|---|
| 5834 | tmp = atoi(portvlan); |
|---|
| 5835 | else |
|---|
| 5836 | continue; |
|---|
| 5837 | } |
|---|
| 5838 | |
|---|
| 5839 | if (i < 5) { |
|---|
| 5840 | vlans[tmp][i] = 1; |
|---|
| 5841 | } else { |
|---|
| 5842 | vlans[tmp][5] = i - 5; |
|---|
| 5843 | } |
|---|
| 5844 | } |
|---|
| 5845 | } |
|---|
| 5846 | } |
|---|
| 5847 | } |
|---|
| 5848 | |
|---|
| 5849 | for (i = 0; i < 21; i++) { |
|---|
| 5850 | websWrite(wp, " <tr>\n"); |
|---|
| 5851 | websWrite(wp, "<td>"); |
|---|
| 5852 | |
|---|
| 5853 | switch (i) { |
|---|
| 5854 | case 16: |
|---|
| 5855 | websWrite(wp, |
|---|
| 5856 | "<script type=\"text/javascript\">Capture(vlan.tagged)</script>"); |
|---|
| 5857 | break; |
|---|
| 5858 | case 17: |
|---|
| 5859 | websWrite(wp, |
|---|
| 5860 | "<script type=\"text/javascript\">Capture(vlan.negociate)</script>"); |
|---|
| 5861 | break; |
|---|
| 5862 | case 18: |
|---|
| 5863 | websWrite(wp, "100 Mbit"); |
|---|
| 5864 | break; |
|---|
| 5865 | case 19: |
|---|
| 5866 | websWrite(wp, "Full-Duplex"); |
|---|
| 5867 | break; |
|---|
| 5868 | case 20: |
|---|
| 5869 | websWrite(wp, "Enabled"); |
|---|
| 5870 | break; |
|---|
| 5871 | default: |
|---|
| 5872 | snprintf(buff, 31, "%d", i); |
|---|
| 5873 | websWrite(wp, buff); |
|---|
| 5874 | break; |
|---|
| 5875 | } |
|---|
| 5876 | |
|---|
| 5877 | websWrite(wp, "</td>\n"); |
|---|
| 5878 | |
|---|
| 5879 | for (j = 0; j < 5; j++) { |
|---|
| 5880 | snprintf(buff, 31, "\"port%dvlan%d\"", j, i); |
|---|
| 5881 | websWrite(wp, "<td"); |
|---|
| 5882 | |
|---|
| 5883 | if (j % 2 == 0) |
|---|
| 5884 | websWrite(wp, " bgcolor=\"#CCCCCC\""); |
|---|
| 5885 | |
|---|
| 5886 | websWrite(wp, |
|---|
| 5887 | " height=\"20\"><div align=\"center\"><input type=\"checkbox\" value=\"on\" name="); |
|---|
| 5888 | websWrite(wp, buff); |
|---|
| 5889 | |
|---|
| 5890 | if (i < 17 || i > 20) { |
|---|
| 5891 | if (vlans[i][j] == 1) |
|---|
| 5892 | websWrite(wp, " checked=\"checked\""); |
|---|
| 5893 | } else { |
|---|
| 5894 | if (vlans[i][j] == -1) |
|---|
| 5895 | websWrite(wp, " checked=\"checked\""); |
|---|
| 5896 | } |
|---|
| 5897 | |
|---|
| 5898 | if (i < 17) { |
|---|
| 5899 | websWrite(wp, " onclick="); |
|---|
| 5900 | snprintf(buff, sizeof(buff), |
|---|
| 5901 | "\"SelVLAN(this.form,'port%d')\"", j); |
|---|
| 5902 | websWrite(wp, buff); |
|---|
| 5903 | } else if (i == 17 || i == 20) { |
|---|
| 5904 | websWrite(wp, " onclick="); |
|---|
| 5905 | snprintf(buff, sizeof(buff), |
|---|
| 5906 | "\"SelSpeed(this.form,'port%d')\"", j); |
|---|
| 5907 | websWrite(wp, buff); |
|---|
| 5908 | } |
|---|
| 5909 | websWrite(wp, " /></div></td>\n"); |
|---|
| 5910 | } |
|---|
| 5911 | |
|---|
| 5912 | if (i < 16) { |
|---|
| 5913 | websWrite(wp, " <td><select name="); |
|---|
| 5914 | snprintf(buff, 31, "\"vlan%d\"", i); |
|---|
| 5915 | websWrite(wp, buff); |
|---|
| 5916 | websWrite(wp, |
|---|
| 5917 | "><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"-1\\\""); |
|---|
| 5918 | if (vlans[i][5] < 0) |
|---|
| 5919 | websWrite(wp, " selected=\\\"selected\\\""); |
|---|
| 5920 | websWrite(wp, |
|---|
| 5921 | ">\" + share.none + \"</option>\");\n//]]>\n</script><option value=\"0\""); |
|---|
| 5922 | if (vlans[i][5] == 0) |
|---|
| 5923 | websWrite(wp, " selected=\"selected\""); |
|---|
| 5924 | websWrite(wp, ">LAN</option></select></td>\n"); |
|---|
| 5925 | } else { |
|---|
| 5926 | websWrite(wp, "<td> </td>\n"); |
|---|
| 5927 | } |
|---|
| 5928 | |
|---|
| 5929 | websWrite(wp, "</tr>\n"); |
|---|
| 5930 | |
|---|
| 5931 | if (i == 16 || i == 20) { |
|---|
| 5932 | websWrite(wp, "<tr><td> </td></tr>\n"); |
|---|
| 5933 | } |
|---|
| 5934 | } |
|---|
| 5935 | |
|---|
| 5936 | websWrite(wp, "<tr>\n"); |
|---|
| 5937 | websWrite(wp, |
|---|
| 5938 | "<td><script type=\"text/javascript\">Capture(share.wireless)</script></td>\n"); |
|---|
| 5939 | |
|---|
| 5940 | websWrite(wp, |
|---|
| 5941 | "<td colspan=\"6\"><select name=\"wireless\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"-1\\\""); |
|---|
| 5942 | if (wl_br < 0) |
|---|
| 5943 | websWrite(wp, " selected=\\\"selected\\\""); |
|---|
| 5944 | websWrite(wp, |
|---|
| 5945 | ">\" + share.none + \"</option>\");\n//]]>\n</script><option value=\"0\""); |
|---|
| 5946 | if (wl_br == 0) |
|---|
| 5947 | websWrite(wp, " selected=\"selected\""); |
|---|
| 5948 | websWrite(wp, ">LAN</option></select></td>\n"); |
|---|
| 5949 | websWrite(wp, "</tr>\n"); |
|---|
| 5950 | |
|---|
| 5951 | websWrite(wp, "<tr><td> </td></tr>\n"); |
|---|
| 5952 | |
|---|
| 5953 | websWrite(wp, "<tr>\n"); |
|---|
| 5954 | websWrite(wp, |
|---|
| 5955 | "<td><script type=\"text/javascript\">Capture(vlan.aggregation)</script></td>\n"); |
|---|
| 5956 | |
|---|
| 5957 | websWrite(wp, |
|---|
| 5958 | "<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\\\""); |
|---|
| 5959 | |
|---|
| 5960 | c = nvram_safe_get("trunking"); |
|---|
| 5961 | |
|---|
| 5962 | snprintf(buff, 5, "%s", c); |
|---|
| 5963 | |
|---|
| 5964 | if (atoi(buff) == 1) |
|---|
| 5965 | websWrite(wp, " selected=\\\"selected\\\""); |
|---|
| 5966 | |
|---|
| 5967 | websWrite(wp, |
|---|
| 5968 | ">\" + vlan.trunk + \"</option>\");\n//]]>\n</script></select></td>\n"); |
|---|
| 5969 | websWrite(wp, " </tr>"); |
|---|
| 5970 | |
|---|
| 5971 | return; |
|---|
| 5972 | } |
|---|
| 5973 | |
|---|
| 5974 | /* |
|---|
| 5975 | * Note: VLAN #16 designates tagging. There is no VLAN #16 (only 0-15) |
|---|
| 5976 | */ |
|---|
| 5977 | |
|---|
| 5978 | void ej_get_qossvcs(webs_t wp, int argc, char_t ** argv) |
|---|
| 5979 | { |
|---|
| 5980 | char *qos_svcs = nvram_safe_get("svqos_svcs"); |
|---|
| 5981 | char name[32], type[32], data[32], level[32]; |
|---|
| 5982 | int no_svcs = 0, i = 0; |
|---|
| 5983 | |
|---|
| 5984 | // calc # of services |
|---|
| 5985 | // no_svcs = strspn(qos_svcs,"|"); |
|---|
| 5986 | |
|---|
| 5987 | while ((qos_svcs = strpbrk(qos_svcs, "|"))) { |
|---|
| 5988 | no_svcs++; |
|---|
| 5989 | qos_svcs++; |
|---|
| 5990 | } |
|---|
| 5991 | |
|---|
| 5992 | // write HTML data |
|---|
| 5993 | |
|---|
| 5994 | websWrite(wp, |
|---|
| 5995 | "<tr><td colspan=\"3\"><input type=\"hidden\" name=\"svqos_nosvcs\" value=\"%d\" /></td></tr>", |
|---|
| 5996 | no_svcs); |
|---|
| 5997 | |
|---|
| 5998 | qos_svcs = nvram_safe_get("svqos_svcs"); |
|---|
| 5999 | |
|---|
| 6000 | /* |
|---|
| 6001 | * services format is "name type data level | name type data level |" |
|---|
| 6002 | * ..etc |
|---|
| 6003 | */ |
|---|
| 6004 | for (i = 0; i < no_svcs && qos_svcs && qos_svcs[0]; i++) { |
|---|
| 6005 | if (sscanf |
|---|
| 6006 | (qos_svcs, "%31s %31s %31s %31s ", name, type, data, |
|---|
| 6007 | level) < 4) |
|---|
| 6008 | break; |
|---|
| 6009 | |
|---|
| 6010 | websWrite(wp, "<tr>\n\ |
|---|
| 6011 | <td>\n\ |
|---|
| 6012 | <input type=\"checkbox\" name=\"svqos_svcdel%d\" />\n\ |
|---|
| 6013 | <input type=\"hidden\" name=\"svqos_svcname%d\" value=\"%s\" />\n\ |
|---|
| 6014 | <input type=\"hidden\" name=\"svqos_svctype%d\" value=\"%s\" />\n\ |
|---|
| 6015 | </td>\n\ |
|---|
| 6016 | <td><em>%s</em></td>\n\ |
|---|
| 6017 | <td >\n", i, i, name, i, type, name); |
|---|
| 6018 | websWrite(wp, "<select name=\"svqos_svcprio%d\"> \n\ |
|---|
| 6019 | <script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"100\\\" %s >\" + qos.prio_x + \"</option>\");\n\ |
|---|
| 6020 | document.write(\"<option value=\\\"10\\\" %s >\" + qos.prio_p + \"</option>\");\n\ |
|---|
| 6021 | document.write(\"<option value=\\\"20\\\" %s >\" + qos.prio_e + \"</option>\");\n\ |
|---|
| 6022 | document.write(\"<option value=\\\"30\\\" %s >\" + share.standard + \"</option>\");\n\ |
|---|
| 6023 | document.write(\"<option value=\\\"40\\\" %s >\" + qos.prio_b + \"</option>\");\n//]]>\n</script>\n\ |
|---|
| 6024 | </select>\n\ |
|---|
| 6025 | </td>\n\ |
|---|
| 6026 | </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\\\"" : ""); |
|---|
| 6027 | |
|---|
| 6028 | qos_svcs = strpbrk(++qos_svcs, "|"); |
|---|
| 6029 | qos_svcs++; |
|---|
| 6030 | |
|---|
| 6031 | } |
|---|
| 6032 | |
|---|
| 6033 | return; |
|---|
| 6034 | } |
|---|
| 6035 | |
|---|
| 6036 | #ifndef HAVE_AQOS |
|---|
| 6037 | void ej_get_qosips(webs_t wp, int argc, char_t ** argv) |
|---|
| 6038 | { |
|---|
| 6039 | char *qos_ips = nvram_safe_get("svqos_ips"); |
|---|
| 6040 | char ip[32], level[32]; |
|---|
| 6041 | int no_ips = 0, i = 0; |
|---|
| 6042 | |
|---|
| 6043 | // calc # of ips |
|---|
| 6044 | while ((qos_ips = strpbrk(qos_ips, "|"))) { |
|---|
| 6045 | no_ips++; |
|---|
| 6046 | qos_ips++; |
|---|
| 6047 | } |
|---|
| 6048 | websWrite(wp, "<tr>\n\ |
|---|
| 6049 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 6050 | <th><script type=\"text/javascript\">Capture(qos.ipmask)</script></th>\n\ |
|---|
| 6051 | <th><script type=\"text/javascript\">Capture(share.priority)</script></th>\n\ |
|---|
| 6052 | </tr>\n"); |
|---|
| 6053 | |
|---|
| 6054 | // write HTML data |
|---|
| 6055 | |
|---|
| 6056 | websWrite(wp, |
|---|
| 6057 | "<tr><td colspan=\"3\"><input type=\"hidden\" name=\"svqos_noips\" value=\"%d\" /></td></tr>", |
|---|
| 6058 | no_ips); |
|---|
| 6059 | |
|---|
| 6060 | qos_ips = nvram_safe_get("svqos_ips"); |
|---|
| 6061 | |
|---|
| 6062 | /* |
|---|
| 6063 | * IP format is "data level | data level |" ..etc |
|---|
| 6064 | */ |
|---|
| 6065 | for (i = 0; i < no_ips && qos_ips && qos_ips[0]; i++) { |
|---|
| 6066 | if (sscanf(qos_ips, "%31s %31s ", ip, level) < 2) |
|---|
| 6067 | break; |
|---|
| 6068 | |
|---|
| 6069 | websWrite(wp, "<tr>\n\ |
|---|
| 6070 | <td>\n\ |
|---|
| 6071 | <input type=\"checkbox\" name=\"svqos_ipdel%d\" />\n\ |
|---|
| 6072 | <input type=\"hidden\" name=\"svqos_ip%d\" value=\"%s\" />\n\ |
|---|
| 6073 | </td>\n\ |
|---|
| 6074 | <td><em>%s</em></td>\n\ |
|---|
| 6075 | <td>\n", i, i, ip, ip); |
|---|
| 6076 | websWrite(wp, "<select name=\"svqos_ipprio%d\"> \n\ |
|---|
| 6077 | <script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"100\\\" %s >\" + qos.prio_x + \"</option>\");\n\ |
|---|
| 6078 | document.write(\"<option value=\\\"10\\\" %s >\" + qos.prio_p + \"</option>\");\n\ |
|---|
| 6079 | document.write(\"<option value=\\\"20\\\" %s >\" + qos.prio_e + \"</option>\");\n\ |
|---|
| 6080 | document.write(\"<option value=\\\"30\\\" %s >\" + share.standard + \"</option>\");\n\ |
|---|
| 6081 | document.write(\"<option value=\\\"40\\\" %s >\" + qos.prio_b + \"</option>\");\n//]]>\n</script>\n\ |
|---|
| 6082 | </select>\n\ |
|---|
| 6083 | </td>\n\ |
|---|
| 6084 | </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\\\"" : ""); |
|---|
| 6085 | |
|---|
| 6086 | qos_ips = strpbrk(++qos_ips, "|"); |
|---|
| 6087 | qos_ips++; |
|---|
| 6088 | |
|---|
| 6089 | } |
|---|
| 6090 | |
|---|
| 6091 | return; |
|---|
| 6092 | } |
|---|
| 6093 | #else |
|---|
| 6094 | void ej_get_qosips(webs_t wp, int argc, char_t ** argv) |
|---|
| 6095 | { |
|---|
| 6096 | char *qos_ips = nvram_safe_get("svqos_ips"); |
|---|
| 6097 | char ip[32], level[32], level2[32]; |
|---|
| 6098 | int no_ips = 0, i = 0; |
|---|
| 6099 | |
|---|
| 6100 | // calc # of ips |
|---|
| 6101 | while ((qos_ips = strpbrk(qos_ips, "|"))) { |
|---|
| 6102 | no_ips++; |
|---|
| 6103 | qos_ips++; |
|---|
| 6104 | } |
|---|
| 6105 | websWrite(wp, "<tr>\n\ |
|---|
| 6106 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 6107 | <th><script type=\"text/javascript\">Capture(qos.ipmask)</script></th>\n\ |
|---|
| 6108 | <th><script type=\"text/javascript\">Capture(qos.maxuprate_b)</script></th>\n\ |
|---|
| 6109 | <th><script type=\"text/javascript\">Capture(qos.maxdownrate_b)</script></th>\n\ |
|---|
| 6110 | </tr>\n"); |
|---|
| 6111 | |
|---|
| 6112 | // write HTML data |
|---|
| 6113 | |
|---|
| 6114 | websWrite(wp, |
|---|
| 6115 | "<tr><td colspan=\"3\"><input type=\"hidden\" name=\"svqos_noips\" value=\"%d\" /></td></tr>", |
|---|
| 6116 | no_ips); |
|---|
| 6117 | |
|---|
| 6118 | qos_ips = nvram_safe_get("svqos_ips"); |
|---|
| 6119 | |
|---|
| 6120 | /* |
|---|
| 6121 | * IP format is "data level | data level |" ..etc |
|---|
| 6122 | */ |
|---|
| 6123 | for (i = 0; i < no_ips && qos_ips && qos_ips[0]; i++) { |
|---|
| 6124 | if (sscanf(qos_ips, "%31s %31s %31s ", ip, level, level2) < 3) |
|---|
| 6125 | break; |
|---|
| 6126 | websWrite(wp, "<tr>\n\ |
|---|
| 6127 | <td>\n\ |
|---|
| 6128 | <input type=\"checkbox\" name=\"svqos_ipdel%d\" />\n\ |
|---|
| 6129 | <input type=\"hidden\" name=\"svqos_ip%d\" value=\"%s\" />\n\ |
|---|
| 6130 | </td>\n\ |
|---|
| 6131 | <td><em>%s</em></td>\n\ |
|---|
| 6132 | <td>\n\ |
|---|
| 6133 | <input name=\"svqos_ipup%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 6134 | </td>\n\ |
|---|
| 6135 | <td>\n\ |
|---|
| 6136 | <input name=\"svqos_ipdown%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 6137 | </td>\n\ |
|---|
| 6138 | </tr>\n", i, i, ip, ip, i, level, i, level2); |
|---|
| 6139 | |
|---|
| 6140 | qos_ips = strpbrk(++qos_ips, "|"); |
|---|
| 6141 | qos_ips++; |
|---|
| 6142 | |
|---|
| 6143 | } |
|---|
| 6144 | |
|---|
| 6145 | return; |
|---|
| 6146 | } |
|---|
| 6147 | #endif |
|---|
| 6148 | #ifndef HAVE_AQOS |
|---|
| 6149 | void ej_get_qosmacs(webs_t wp, int argc, char_t ** argv) |
|---|
| 6150 | { |
|---|
| 6151 | char *qos_macs = nvram_safe_get("svqos_macs"); |
|---|
| 6152 | char mac[32], level[32]; |
|---|
| 6153 | int no_macs = 0, i = 0; |
|---|
| 6154 | |
|---|
| 6155 | // calc # of ips |
|---|
| 6156 | while ((qos_macs = strpbrk(qos_macs, "|"))) { |
|---|
| 6157 | no_macs++; |
|---|
| 6158 | qos_macs++; |
|---|
| 6159 | } |
|---|
| 6160 | |
|---|
| 6161 | websWrite(wp, "<tr>\n\ |
|---|
| 6162 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 6163 | <th><script type=\"text/javascript\">Capture(share.mac)</script></th>\n\ |
|---|
| 6164 | <th><script type=\"text/javascript\">Capture(share.priority)</script></th>\n\ |
|---|
| 6165 | </tr>\n"); |
|---|
| 6166 | |
|---|
| 6167 | // write HTML data |
|---|
| 6168 | websWrite(wp, |
|---|
| 6169 | "<input type=\"hidden\" name=\"svqos_nomacs\" value=\"%d\" />", |
|---|
| 6170 | no_macs); |
|---|
| 6171 | |
|---|
| 6172 | qos_macs = nvram_safe_get("svqos_macs"); |
|---|
| 6173 | |
|---|
| 6174 | /* |
|---|
| 6175 | * IP format is "data level | data level |" ..etc |
|---|
| 6176 | */ |
|---|
| 6177 | for (i = 0; i < no_macs && qos_macs && qos_macs[0]; i++) { |
|---|
| 6178 | if (sscanf(qos_macs, "%31s %31s ", mac, level) < 2) |
|---|
| 6179 | break; |
|---|
| 6180 | |
|---|
| 6181 | websWrite(wp, "<tr>\n\ |
|---|
| 6182 | <td>\n\ |
|---|
| 6183 | <input type=\"checkbox\" name=\"svqos_macdel%d\" />\n\ |
|---|
| 6184 | <input type=\"hidden\" name=\"svqos_mac%d\" value=\"%s\" />\n\ |
|---|
| 6185 | </td>\n\ |
|---|
| 6186 | <td><em>%s</em></td>\n\ |
|---|
| 6187 | <td>\n", i, i, mac, mac); |
|---|
| 6188 | websWrite(wp, "<select name=\"svqos_macprio%d\"> \n\ |
|---|
| 6189 | <script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"100\\\" %s >\" + qos.prio_x + \"</option>\");\n\ |
|---|
| 6190 | document.write(\"<option value=\\\"10\\\" %s >\" + qos.prio_p + \"</option>\");\n\ |
|---|
| 6191 | document.write(\"<option value=\\\"20\\\" %s >\" + qos.prio_e + \"</option>\");\n\ |
|---|
| 6192 | document.write(\"<option value=\\\"30\\\" %s >\" + share.standard + \"</option>\");\n\ |
|---|
| 6193 | document.write(\"<option value=\\\"40\\\" %s >\" + qos.prio_b + \"</option>\");\n//]]>\n</script>\n\ |
|---|
| 6194 | </select>\n\ |
|---|
| 6195 | </td>\n\ |
|---|
| 6196 | </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\\\"" : ""); |
|---|
| 6197 | |
|---|
| 6198 | qos_macs = strpbrk(++qos_macs, "|"); |
|---|
| 6199 | qos_macs++; |
|---|
| 6200 | |
|---|
| 6201 | } |
|---|
| 6202 | |
|---|
| 6203 | return; |
|---|
| 6204 | } |
|---|
| 6205 | |
|---|
| 6206 | #else |
|---|
| 6207 | void ej_get_qosmacs(webs_t wp, int argc, char_t ** argv) |
|---|
| 6208 | { |
|---|
| 6209 | char *qos_macs = nvram_safe_get("svqos_macs"); |
|---|
| 6210 | char mac[32], level[32], level2[32]; |
|---|
| 6211 | int no_macs = 0, i = 0; |
|---|
| 6212 | |
|---|
| 6213 | // calc # of ips |
|---|
| 6214 | while ((qos_macs = strpbrk(qos_macs, "|"))) { |
|---|
| 6215 | no_macs++; |
|---|
| 6216 | qos_macs++; |
|---|
| 6217 | } |
|---|
| 6218 | websWrite(wp, "<tr>\n\ |
|---|
| 6219 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 6220 | <th><script type=\"text/javascript\">Capture(share.mac)</script></th>\n\ |
|---|
| 6221 | <th><script type=\"text/javascript\">Capture(qos.maxuprate_b)</script></th>\n\ |
|---|
| 6222 | <th><script type=\"text/javascript\">Capture(qos.maxdownrate_b)</script></th>\n\ |
|---|
| 6223 | </tr>\n"); |
|---|
| 6224 | |
|---|
| 6225 | // write HTML data |
|---|
| 6226 | websWrite(wp, |
|---|
| 6227 | "<input type=\"hidden\" name=\"svqos_nomacs\" value=\"%d\" />", |
|---|
| 6228 | no_macs); |
|---|
| 6229 | |
|---|
| 6230 | qos_macs = nvram_safe_get("svqos_macs"); |
|---|
| 6231 | |
|---|
| 6232 | /* |
|---|
| 6233 | * IP format is "data level | data level |" ..etc |
|---|
| 6234 | */ |
|---|
| 6235 | for (i = 0; i < no_macs && qos_macs && qos_macs[0]; i++) { |
|---|
| 6236 | if (sscanf(qos_macs, "%31s %31s %31s ", mac, level, level2) < 3) |
|---|
| 6237 | break; |
|---|
| 6238 | websWrite(wp, "<tr>\n\ |
|---|
| 6239 | <td>\n\ |
|---|
| 6240 | <input type=\"checkbox\" name=\"svqos_macdel%d\" />\n\ |
|---|
| 6241 | <input type=\"hidden\" name=\"svqos_mac%d\" value=\"%s\" />\n\ |
|---|
| 6242 | </td>\n\ |
|---|
| 6243 | <td><em>%s</em></td>\n\ |
|---|
| 6244 | <td>\n\ |
|---|
| 6245 | <input name=\"svqos_macup%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 6246 | </td>\n\ |
|---|
| 6247 | <td>\n\ |
|---|
| 6248 | <input name=\"svqos_macdown%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 6249 | </td>\n\ |
|---|
| 6250 | </tr>\n", i, i, mac, mac, i, level, i, level2); |
|---|
| 6251 | |
|---|
| 6252 | qos_macs = strpbrk(++qos_macs, "|"); |
|---|
| 6253 | qos_macs++; |
|---|
| 6254 | |
|---|
| 6255 | } |
|---|
| 6256 | |
|---|
| 6257 | return; |
|---|
| 6258 | } |
|---|
| 6259 | #endif |
|---|
| 6260 | |
|---|
| 6261 | /* |
|---|
| 6262 | * Added by Botho 03.April.06 |
|---|
| 6263 | */ |
|---|
| 6264 | void ej_dumpip_conntrack(webs_t wp, int argc, char_t ** argv) |
|---|
| 6265 | { |
|---|
| 6266 | int ip_count = 0; |
|---|
| 6267 | FILE *fp; |
|---|
| 6268 | int c; |
|---|
| 6269 | |
|---|
| 6270 | fp = fopen("/proc/net/ip_conntrack", "rb"); |
|---|
| 6271 | if (fp == NULL) |
|---|
| 6272 | return; |
|---|
| 6273 | while (!feof(fp)) { |
|---|
| 6274 | c = getc(fp); |
|---|
| 6275 | if (c == EOF) |
|---|
| 6276 | break; |
|---|
| 6277 | if (c == 0xa) |
|---|
| 6278 | ip_count++; |
|---|
| 6279 | } |
|---|
| 6280 | |
|---|
| 6281 | websWrite(wp, "%d", ip_count); |
|---|
| 6282 | |
|---|
| 6283 | fclose(fp); |
|---|
| 6284 | |
|---|
| 6285 | return; |
|---|
| 6286 | } |
|---|
| 6287 | |
|---|
| 6288 | /* |
|---|
| 6289 | * Added by Botho 28.Oct.06 |
|---|
| 6290 | */ |
|---|
| 6291 | static int search_hit(char *search, char *line, char *ret) |
|---|
| 6292 | { |
|---|
| 6293 | unsigned int searchLen; |
|---|
| 6294 | unsigned int i; |
|---|
| 6295 | unsigned int j; |
|---|
| 6296 | unsigned int lineLen; |
|---|
| 6297 | |
|---|
| 6298 | if (line == NULL || search == NULL || ret == NULL) |
|---|
| 6299 | return 1; |
|---|
| 6300 | lineLen = strlen(line); |
|---|
| 6301 | searchLen = strlen(search); |
|---|
| 6302 | |
|---|
| 6303 | if (searchLen > lineLen) |
|---|
| 6304 | return (1); // this can't match, invalid data? |
|---|
| 6305 | |
|---|
| 6306 | for (i = 0; i < lineLen - searchLen; i++) { |
|---|
| 6307 | if (!strncasecmp((char *)&line[i], search, searchLen)) |
|---|
| 6308 | break; // we got hit |
|---|
| 6309 | } |
|---|
| 6310 | |
|---|
| 6311 | for (j = i + searchLen; j < i + 15 + searchLen; j++) { |
|---|
| 6312 | if (j >= lineLen) |
|---|
| 6313 | break; // end of line may be a delimiter too |
|---|
| 6314 | // return(1); // incomplete data |
|---|
| 6315 | if (line[j] == ' ') |
|---|
| 6316 | break; // we reach _space_ delimiter |
|---|
| 6317 | } |
|---|
| 6318 | memcpy(ret, &line[i + searchLen], j - (i + searchLen)); |
|---|
| 6319 | ret[j - (i + searchLen)] = 0; |
|---|
| 6320 | return (0); |
|---|
| 6321 | } |
|---|
| 6322 | |
|---|
| 6323 | static int string_search(char *string, char *search) |
|---|
| 6324 | { |
|---|
| 6325 | int searchLen; |
|---|
| 6326 | int i; |
|---|
| 6327 | |
|---|
| 6328 | if (search == NULL) |
|---|
| 6329 | return 0; |
|---|
| 6330 | searchLen = strlen(search); |
|---|
| 6331 | if (string == NULL) |
|---|
| 6332 | return 0; |
|---|
| 6333 | if (searchLen > strlen(string)) { |
|---|
| 6334 | return (0); // this can't match |
|---|
| 6335 | } |
|---|
| 6336 | int slen = strlen(string); |
|---|
| 6337 | |
|---|
| 6338 | for (i = 0; i < slen - searchLen; i++) { // +1 removed. |
|---|
| 6339 | if (!strncasecmp((char *)&string[i], search, searchLen)) { |
|---|
| 6340 | return (1); // we got hit |
|---|
| 6341 | } |
|---|
| 6342 | } |
|---|
| 6343 | return (0); |
|---|
| 6344 | } |
|---|
| 6345 | |
|---|
| 6346 | void ej_ip_conntrack_table(webs_t wp, int argc, char_t ** argv) |
|---|
| 6347 | { |
|---|
| 6348 | FILE *fp; |
|---|
| 6349 | int ip_count = 1; |
|---|
| 6350 | char line[512]; |
|---|
| 6351 | char protocol[16] = ""; |
|---|
| 6352 | int timeout = 0; |
|---|
| 6353 | char srcip[16] = ""; |
|---|
| 6354 | char dstip[16] = ""; |
|---|
| 6355 | int _dport; |
|---|
| 6356 | struct servent *servp; |
|---|
| 6357 | char dstport[6] = ""; |
|---|
| 6358 | char state[12] = ""; |
|---|
| 6359 | char dum1[32]; |
|---|
| 6360 | int dum2; |
|---|
| 6361 | char *lanip = nvram_get("lan_ipaddr"); |
|---|
| 6362 | |
|---|
| 6363 | fp = fopen("/proc/net/ip_conntrack", "rb"); |
|---|
| 6364 | if (fp == NULL) |
|---|
| 6365 | return; |
|---|
| 6366 | |
|---|
| 6367 | while (fgets(line, sizeof(line), fp) != NULL) { |
|---|
| 6368 | |
|---|
| 6369 | websWrite(wp, "<tr>\n"); |
|---|
| 6370 | |
|---|
| 6371 | // Nb |
|---|
| 6372 | websWrite(wp, "<td align=\"right\">%d</td>", ip_count); |
|---|
| 6373 | |
|---|
| 6374 | // Proto |
|---|
| 6375 | if (string_search(line, "tcp")) |
|---|
| 6376 | sprintf(protocol, "TCP"); |
|---|
| 6377 | else if (string_search(line, "udp")) |
|---|
| 6378 | sprintf(protocol, "UDP"); |
|---|
| 6379 | else if (string_search(line, "icmp")) |
|---|
| 6380 | sprintf(protocol, "ICMP"); |
|---|
| 6381 | else |
|---|
| 6382 | sprintf(protocol, live_translate("share.unknown")); |
|---|
| 6383 | websWrite(wp, "<td>%s</td>", protocol); |
|---|
| 6384 | |
|---|
| 6385 | // Timeout |
|---|
| 6386 | sscanf(line, "%s %d %d", &dum1[0], &dum2, &timeout); |
|---|
| 6387 | websWrite(wp, "<td align=\"right\">%d</td>", timeout); |
|---|
| 6388 | |
|---|
| 6389 | // src |
|---|
| 6390 | search_hit("src=", line, srcip); |
|---|
| 6391 | // char buf[200]; |
|---|
| 6392 | // getHostName (buf, srcip); |
|---|
| 6393 | // websWrite (wp, "<td align=\"right\" onmouseover='DisplayDiv(this, |
|---|
| 6394 | // event, 15, 15, \"%s\")' onmouseout=\"unDisplayDiv()\">%s</td>", |
|---|
| 6395 | // buf != "unknown" ? buf : live_translate ("share.unknown") , |
|---|
| 6396 | // srcip); |
|---|
| 6397 | if (!strcmp(srcip, lanip)) |
|---|
| 6398 | websWrite(wp, "<td align=\"right\">%s</td>", srcip); |
|---|
| 6399 | else |
|---|
| 6400 | websWrite(wp, |
|---|
| 6401 | "<td align=\"right\"><a title=\"Geotool\" href=\"javascript:openGeotool('%s')\">%s</a></td>", |
|---|
| 6402 | srcip, srcip); |
|---|
| 6403 | |
|---|
| 6404 | // dst |
|---|
| 6405 | search_hit("dst=", line, dstip); |
|---|
| 6406 | // getHostName (buf, dstip); |
|---|
| 6407 | // websWrite (wp, "<td align=\"right\" onmouseover='DisplayDiv(this, |
|---|
| 6408 | // event, 15, 15, \"%s\")' onmouseout=\"unDisplayDiv()\">%s</td>", |
|---|
| 6409 | // buf != "unknown" ? buf : live_translate ("share.unknown") , |
|---|
| 6410 | // dstip); |
|---|
| 6411 | if (!strcmp(dstip, lanip)) |
|---|
| 6412 | websWrite(wp, "<td align=\"right\">%s</td>", dstip); |
|---|
| 6413 | else |
|---|
| 6414 | websWrite(wp, |
|---|
| 6415 | "<td align=\"right\"><a title=\"Geotool\" href=\"javascript:openGeotool('%s')\">%s</a></td>", |
|---|
| 6416 | dstip, dstip); |
|---|
| 6417 | |
|---|
| 6418 | // service |
|---|
| 6419 | search_hit("dport=", line, dstport); |
|---|
| 6420 | _dport = atoi(dstport); |
|---|
| 6421 | servp = my_getservbyport(htons(_dport), protocol); |
|---|
| 6422 | websWrite(wp, "<td align=\"right\">%s</td>", |
|---|
| 6423 | servp ? servp->s_name : dstport); |
|---|
| 6424 | |
|---|
| 6425 | // State |
|---|
| 6426 | if (string_search(line, "ESTABLISHED")) |
|---|
| 6427 | sprintf(state, "ESTABLISHED"); |
|---|
| 6428 | else if (string_search(line, "TIME_WAIT")) |
|---|
| 6429 | sprintf(state, "TIME_WAIT"); |
|---|
| 6430 | else if (string_search(line, "UNREPLIED")) |
|---|
| 6431 | sprintf(state, "UNREPLIED"); |
|---|
| 6432 | else if (string_search(line, "CLOSE")) |
|---|
| 6433 | sprintf(state, "CLOSE"); |
|---|
| 6434 | else if (string_search(line, "ASSURED")) |
|---|
| 6435 | sprintf(state, "ASSURED"); |
|---|
| 6436 | else { |
|---|
| 6437 | if (string_search(line, "udp")) |
|---|
| 6438 | sprintf(state, "UNREPLIED"); |
|---|
| 6439 | else |
|---|
| 6440 | sprintf(state, " "); |
|---|
| 6441 | } |
|---|
| 6442 | websWrite(wp, "<td>%s</td>\n", state); |
|---|
| 6443 | websWrite(wp, "</tr>\n"); |
|---|
| 6444 | |
|---|
| 6445 | ip_count++; |
|---|
| 6446 | } |
|---|
| 6447 | |
|---|
| 6448 | fclose(fp); |
|---|
| 6449 | |
|---|
| 6450 | return; |
|---|
| 6451 | } |
|---|
| 6452 | |
|---|
| 6453 | void ej_gethostnamebyip(webs_t wp, int argc, char_t ** argv) |
|---|
| 6454 | { |
|---|
| 6455 | char buf[200]; |
|---|
| 6456 | char *argument; |
|---|
| 6457 | |
|---|
| 6458 | #ifdef FASTWEB |
|---|
| 6459 | ejArgs(argc, argv, "%s", &argument); |
|---|
| 6460 | #else |
|---|
| 6461 | if (ejArgs(argc, argv, "%s", &argument) < 1) { |
|---|
| 6462 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 6463 | return; |
|---|
| 6464 | } |
|---|
| 6465 | #endif |
|---|
| 6466 | |
|---|
| 6467 | if (argc == 1) { |
|---|
| 6468 | getHostName(buf, argument); |
|---|
| 6469 | websWrite(wp, "%s", |
|---|
| 6470 | strcmp(buf, |
|---|
| 6471 | "unknown") ? buf : |
|---|
| 6472 | live_translate("share.unknown")); |
|---|
| 6473 | } |
|---|
| 6474 | |
|---|
| 6475 | return; |
|---|
| 6476 | } |
|---|
| 6477 | |
|---|
| 6478 | /* |
|---|
| 6479 | * BEGIN Added by Botho 10.May.06 |
|---|
| 6480 | */ |
|---|
| 6481 | void ej_show_wan_to_switch(webs_t wp, int argc, char_t ** argv) |
|---|
| 6482 | { |
|---|
| 6483 | |
|---|
| 6484 | if (nvram_match("wan_proto", "disabled") || getSTA() || getWET()) // WAN |
|---|
| 6485 | // disabled |
|---|
| 6486 | // OR |
|---|
| 6487 | // Wirelles |
|---|
| 6488 | // is |
|---|
| 6489 | // not |
|---|
| 6490 | // AP |
|---|
| 6491 | { |
|---|
| 6492 | websWrite(wp, "<fieldset>\n\ |
|---|
| 6493 | <legend><script type=\"text/javascript\">Capture(idx.legend2)</script></legend>\n\ |
|---|
| 6494 | <div class=\"setting\">\n\ |
|---|
| 6495 | <div class=\"label\"><script type=\"text/javascript\">Capture(idx.wantoswitch)</script></div>\n\ |
|---|
| 6496 | <input class=\"spaceradio\" type=\"checkbox\" name=\"_fullswitch\" value=\"1\" %s />\n\ |
|---|
| 6497 | </div>\n\ |
|---|
| 6498 | </fieldset><br />\n", nvram_match("fullswitch", "1") ? "checked=\"checked\"" : ""); |
|---|
| 6499 | } |
|---|
| 6500 | |
|---|
| 6501 | return; |
|---|
| 6502 | } |
|---|
| 6503 | |
|---|
| 6504 | #define PROC_DEV "/proc/net/dev" |
|---|
| 6505 | |
|---|
| 6506 | void ej_wl_packet_get(webs_t wp, int argc, char_t ** argv) |
|---|
| 6507 | { |
|---|
| 6508 | char line[256]; |
|---|
| 6509 | FILE *fp; |
|---|
| 6510 | |
|---|
| 6511 | #ifdef HAVE_MADWIFI |
|---|
| 6512 | char *ifname = nvram_safe_get("wifi_display"); |
|---|
| 6513 | #elif HAVE_RT2880 |
|---|
| 6514 | char *ifname = "ra0"; |
|---|
| 6515 | #else |
|---|
| 6516 | char name[32]; |
|---|
| 6517 | sprintf(name, "%s_ifname", nvram_safe_get("wifi_display")); |
|---|
| 6518 | char *ifname = nvram_safe_get(name); |
|---|
| 6519 | #endif |
|---|
| 6520 | struct dev_info { |
|---|
| 6521 | // unsigned long rx_bytes; |
|---|
| 6522 | unsigned long rx_pks; |
|---|
| 6523 | unsigned long rx_errs; |
|---|
| 6524 | unsigned long rx_drops; |
|---|
| 6525 | // unsigned long rx_fifo; |
|---|
| 6526 | // unsigned long rx_frame; |
|---|
| 6527 | // unsigned long rx_com; |
|---|
| 6528 | // unsigned long rx_mcast; |
|---|
| 6529 | // unsigned long tx_bytes; |
|---|
| 6530 | unsigned long tx_pks; |
|---|
| 6531 | unsigned long tx_errs; |
|---|
| 6532 | unsigned long tx_drops; |
|---|
| 6533 | // unsigned long tx_fifo; |
|---|
| 6534 | unsigned long tx_colls; |
|---|
| 6535 | // unsigned long tx_carr; |
|---|
| 6536 | // unsigned long tx_com; |
|---|
| 6537 | } info; |
|---|
| 6538 | |
|---|
| 6539 | info.rx_pks = info.rx_errs = info.rx_drops = 0; |
|---|
| 6540 | info.tx_pks = info.tx_errs = info.tx_drops = info.tx_colls = 0; |
|---|
| 6541 | |
|---|
| 6542 | if ((fp = fopen(PROC_DEV, "r")) == NULL) { |
|---|
| 6543 | return; |
|---|
| 6544 | } else { |
|---|
| 6545 | /* |
|---|
| 6546 | * Inter-| Receive | Transmit face |bytes packets errs drop fifo |
|---|
| 6547 | * frame compressed multicast|bytes packets errs drop fifo colls |
|---|
| 6548 | * carrier compressed lo: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 eth0: |
|---|
| 6549 | * 674829 5501 0 0 0 0 0 0 1249130 1831 0 0 0 0 0 0 eth1: 0 0 0 0 0 0 |
|---|
| 6550 | * 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 |
|---|
| 6551 | * br0: 107114 1078 0 0 0 0 0 0 910094 1304 0 0 0 0 0 0 |
|---|
| 6552 | * |
|---|
| 6553 | */ |
|---|
| 6554 | while (fgets(line, sizeof(line), fp) != NULL) { |
|---|
| 6555 | int ifl = 0; |
|---|
| 6556 | |
|---|
| 6557 | if (!strchr(line, ':')) |
|---|
| 6558 | continue; |
|---|
| 6559 | while (line[ifl] != ':') |
|---|
| 6560 | ifl++; |
|---|
| 6561 | line[ifl] = 0; /* interface */ |
|---|
| 6562 | char ifnamecopy[32]; |
|---|
| 6563 | int l = 0; |
|---|
| 6564 | int i; |
|---|
| 6565 | int len = strlen(line); |
|---|
| 6566 | for (i = 0; i < len; i++) { |
|---|
| 6567 | if (line[i] == ' ') |
|---|
| 6568 | continue; |
|---|
| 6569 | ifnamecopy[l++] = line[i]; |
|---|
| 6570 | } |
|---|
| 6571 | ifnamecopy[l] = 0; |
|---|
| 6572 | if (!strcmp(ifnamecopy, ifname)) { |
|---|
| 6573 | /* |
|---|
| 6574 | * sscanf (line + ifl + 1, "%ld %ld %ld %ld %ld %ld %ld %ld |
|---|
| 6575 | * %ld %ld %ld %ld %ld %ld %ld %ld", &info.rx_bytes, |
|---|
| 6576 | * &info.rx_pks, &info.rx_errs, &info.rx_drops, |
|---|
| 6577 | * &info.rx_fifo, &info.rx_frame, &info.rx_com, |
|---|
| 6578 | * &info.rx_mcast, &info.tx_bytes, &info.tx_pks, |
|---|
| 6579 | * &info.tx_errs, &info.tx_drops, &info.tx_fifo, |
|---|
| 6580 | * &info.tx_colls, &info.tx_carr, &info.tx_com); |
|---|
| 6581 | */ |
|---|
| 6582 | sscanf(line + ifl + 1, |
|---|
| 6583 | "%*ld %ld %ld %ld %*ld %*ld %*ld %*ld %*ld %ld %ld %ld %*ld %ld %*ld %*ld", |
|---|
| 6584 | &info.rx_pks, &info.rx_errs, |
|---|
| 6585 | &info.rx_drops, |
|---|
| 6586 | &info.tx_pks, &info.tx_errs, |
|---|
| 6587 | &info.tx_drops, &info.tx_colls); |
|---|
| 6588 | } |
|---|
| 6589 | |
|---|
| 6590 | } |
|---|
| 6591 | fclose(fp); |
|---|
| 6592 | } |
|---|
| 6593 | |
|---|
| 6594 | websWrite(wp, "SWRXgoodPacket=%ld;", info.rx_pks); |
|---|
| 6595 | websWrite(wp, "SWRXerrorPacket=%ld;", info.rx_errs + info.rx_drops); |
|---|
| 6596 | |
|---|
| 6597 | websWrite(wp, "SWTXgoodPacket=%ld;", info.tx_pks); |
|---|
| 6598 | websWrite(wp, "SWTXerrorPacket=%ld;", |
|---|
| 6599 | info.tx_errs + info.tx_drops + info.tx_colls); |
|---|
| 6600 | |
|---|
| 6601 | return; |
|---|
| 6602 | } |
|---|
| 6603 | |
|---|
| 6604 | /* |
|---|
| 6605 | * END Added by Botho 10.May.06 |
|---|
| 6606 | */ |
|---|
| 6607 | |
|---|
| 6608 | void ej_statfs(webs_t wp, int argc, char_t ** argv) |
|---|
| 6609 | { |
|---|
| 6610 | struct statfs sizefs; |
|---|
| 6611 | |
|---|
| 6612 | if (argc != 2) |
|---|
| 6613 | return; |
|---|
| 6614 | |
|---|
| 6615 | if ((statfs(argv[0], &sizefs) != 0) |
|---|
| 6616 | || (sizefs.f_type == 0x73717368)) |
|---|
| 6617 | memset(&sizefs, 0, sizeof(sizefs)); |
|---|
| 6618 | |
|---|
| 6619 | websWrite(wp, "var %s = {\n\ |
|---|
| 6620 | size: %llu,\n\ |
|---|
| 6621 | free: %llu\n\ |
|---|
| 6622 | };\n", argv[1], ((uint64_t) sizefs.f_bsize * sizefs.f_blocks), ((uint64_t) sizefs.f_bsize * sizefs.f_bfree)); |
|---|
| 6623 | } |
|---|
| 6624 | |
|---|
| 6625 | #ifdef HAVE_RSTATS |
|---|
| 6626 | /* |
|---|
| 6627 | * |
|---|
| 6628 | * rstats Copyright (C) 2006 Jonathan Zarate |
|---|
| 6629 | * |
|---|
| 6630 | * Licensed under GNU GPL v2 or later. |
|---|
| 6631 | * |
|---|
| 6632 | */ |
|---|
| 6633 | |
|---|
| 6634 | void ej_bandwidth(webs_t wp, int argc, char_t ** argv) |
|---|
| 6635 | { |
|---|
| 6636 | char *name; |
|---|
| 6637 | int sig; |
|---|
| 6638 | char *argument; |
|---|
| 6639 | |
|---|
| 6640 | #ifdef FASTWEB |
|---|
| 6641 | ejArgs(argc, argv, "%s", &argument); |
|---|
| 6642 | #else |
|---|
| 6643 | if (ejArgs(argc, argv, "%s", &argument) < 1) { |
|---|
| 6644 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 6645 | return; |
|---|
| 6646 | } |
|---|
| 6647 | #endif |
|---|
| 6648 | |
|---|
| 6649 | if (argc == 1) { |
|---|
| 6650 | if (strcmp(argument, "speed") == 0) { |
|---|
| 6651 | sig = SIGUSR1; |
|---|
| 6652 | name = "/var/spool/rstats-speed.js"; |
|---|
| 6653 | } else { |
|---|
| 6654 | sig = SIGUSR2; |
|---|
| 6655 | name = "/var/spool/rstats-history.js"; |
|---|
| 6656 | } |
|---|
| 6657 | unlink(name); |
|---|
| 6658 | killall("rstats", sig); |
|---|
| 6659 | wait_file_exists(name, 5, 0); |
|---|
| 6660 | do_file(name, wp, NULL); |
|---|
| 6661 | unlink(name); |
|---|
| 6662 | } |
|---|
| 6663 | } |
|---|
| 6664 | #endif |
|---|
| 6665 | |
|---|
| 6666 | #ifdef HAVE_PORTSETUP |
|---|
| 6667 | void ej_portsetup(webs_t wp, int argc, char_t ** argv) |
|---|
| 6668 | { |
|---|
| 6669 | char ssid[64]; |
|---|
| 6670 | char *next; |
|---|
| 6671 | char var[64]; |
|---|
| 6672 | char eths[256]; |
|---|
| 6673 | |
|---|
| 6674 | websWrite(wp, |
|---|
| 6675 | "<h2><script type=\"text/javascript\">Capture(idx.portsetup)</script></h2>\n"); |
|---|
| 6676 | websWrite(wp, "<fieldset>\n"); |
|---|
| 6677 | |
|---|
| 6678 | char *wanifname = nvram_safe_get("wan_ifname2"); |
|---|
| 6679 | |
|---|
| 6680 | if (strlen(wanifname) == 0) |
|---|
| 6681 | wanifname = nvram_safe_get("wan_ifname"); |
|---|
| 6682 | memset(eths, 0, 256); |
|---|
| 6683 | getIfLists(eths, 256); |
|---|
| 6684 | if (strlen(wanifname) > 0) { |
|---|
| 6685 | |
|---|
| 6686 | websWrite(wp, |
|---|
| 6687 | "<legend><script type=\"text/javascript\">Capture(idx.portsetup)</script></legend>\n"); |
|---|
| 6688 | websWrite(wp, |
|---|
| 6689 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(idx.wanport)</script></div>\n"); |
|---|
| 6690 | websWrite(wp, "<select name=\"wan_ifname\">\n"); |
|---|
| 6691 | |
|---|
| 6692 | websWrite(wp, "<option value=\"\" %s >Disabled</option>\n", |
|---|
| 6693 | strlen(wanifname) == |
|---|
| 6694 | 0 ? "selected=\"selected\"" : ""); |
|---|
| 6695 | foreach(var, eths, next) { |
|---|
| 6696 | websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 6697 | var, !strcmp(wanifname, |
|---|
| 6698 | var) ? "selected=\"selected\"" : |
|---|
| 6699 | "", var); |
|---|
| 6700 | } |
|---|
| 6701 | websWrite(wp, "</select></div>\n"); |
|---|
| 6702 | } |
|---|
| 6703 | foreach(var, eths, next) { |
|---|
| 6704 | if (!strcmp(get_wan_face(), var)) |
|---|
| 6705 | continue; |
|---|
| 6706 | if (!strcmp(nvram_safe_get("lan_ifname"), var)) |
|---|
| 6707 | continue; |
|---|
| 6708 | if (!strncmp(var, "br", 2) && !contains(var, '.')) |
|---|
| 6709 | continue; |
|---|
| 6710 | |
|---|
| 6711 | sprintf(ssid, "%s_bridged", var); |
|---|
| 6712 | websWrite(wp, |
|---|
| 6713 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.network)</script> %s</div>\n", |
|---|
| 6714 | var); |
|---|
| 6715 | char layer[64]; |
|---|
| 6716 | |
|---|
| 6717 | strcpy(layer, var); |
|---|
| 6718 | rep(layer, '.', 'X'); |
|---|
| 6719 | websWrite(wp, |
|---|
| 6720 | "<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", |
|---|
| 6721 | layer, var, nvram_default_match(ssid, |
|---|
| 6722 | "0", |
|---|
| 6723 | "1") ? |
|---|
| 6724 | "checked=\"checked\"" : ""); |
|---|
| 6725 | websWrite(wp, |
|---|
| 6726 | "<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", |
|---|
| 6727 | layer, var, nvram_default_match(ssid, "1", |
|---|
| 6728 | "1") ? |
|---|
| 6729 | "checked=\"checked\"" : ""); |
|---|
| 6730 | websWrite(wp, "</div>\n"); |
|---|
| 6731 | |
|---|
| 6732 | websWrite(wp, "<div id=\"%s_idnet\">\n", layer); |
|---|
| 6733 | |
|---|
| 6734 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 6735 | websWrite(wp, "<div class=\"label\">%s</div>\n", |
|---|
| 6736 | live_translate("idx.mtu")); |
|---|
| 6737 | char mtu[32]; |
|---|
| 6738 | sprintf(mtu, "%s_mtu", var); |
|---|
| 6739 | websWrite(wp, |
|---|
| 6740 | "<input class=\"num\" maxlength=\"4\" onblur=\"valid_mtu(this)\" size=\"5\" name=\"%s_mtu\" value=\"%s\" />\n", |
|---|
| 6741 | var, nvram_default_get(mtu, "1500")); |
|---|
| 6742 | websWrite(wp, "</div>\n"); |
|---|
| 6743 | |
|---|
| 6744 | char mcast[32]; |
|---|
| 6745 | |
|---|
| 6746 | sprintf(mcast, "%s_multicast", var); |
|---|
| 6747 | nvram_default_get(mcast, "0"); |
|---|
| 6748 | showRadio(wp, "wl_basic.multicast", mcast); |
|---|
| 6749 | |
|---|
| 6750 | if (has_gateway()) { |
|---|
| 6751 | sprintf(mcast, "%s_nat", var); |
|---|
| 6752 | nvram_default_get(mcast, "1"); |
|---|
| 6753 | showRadio(wp, "wl_basic.masquerade", mcast); |
|---|
| 6754 | } |
|---|
| 6755 | show_ipnetmask(wp, var); |
|---|
| 6756 | websWrite(wp, "</div>\n"); |
|---|
| 6757 | websWrite(wp, |
|---|
| 6758 | "<script type=\"text/javascript\">\n//<![CDATA[\n "); |
|---|
| 6759 | websWrite(wp, |
|---|
| 6760 | "show_layer_ext(document.getElementsByName(\"%s_bridged\"), \"%s_idnet\", %s);\n", |
|---|
| 6761 | var, layer, nvram_match(ssid, |
|---|
| 6762 | "0") ? "true" : "false"); |
|---|
| 6763 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 6764 | } |
|---|
| 6765 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 6766 | } |
|---|
| 6767 | #endif |
|---|
| 6768 | |
|---|
| 6769 | static void show_macfilter_if(webs_t wp, char *ifname) |
|---|
| 6770 | { |
|---|
| 6771 | websWrite(wp, "<fieldset>\n"); |
|---|
| 6772 | websWrite(wp, "<legend>%s - %s</legend>\n", IFMAP(ifname), |
|---|
| 6773 | live_translate("wl_mac.legend")); |
|---|
| 6774 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 6775 | websWrite(wp, "<div class=\"label\">%s</div>\n", |
|---|
| 6776 | live_translate("wl_mac.label")); |
|---|
| 6777 | char macmode[32]; |
|---|
| 6778 | |
|---|
| 6779 | sprintf(macmode, "%s_macmode1", ifname); |
|---|
| 6780 | rep(macmode, '.', 'X'); |
|---|
| 6781 | if (nvram_get(macmode) == NULL) |
|---|
| 6782 | nvram_set(macmode, "disabled"); |
|---|
| 6783 | char id[32]; |
|---|
| 6784 | |
|---|
| 6785 | sprintf(id, "idmac%s", ifname); |
|---|
| 6786 | rep(id, '.', 'X'); |
|---|
| 6787 | char mycopy[256]; |
|---|
| 6788 | |
|---|
| 6789 | strcpy(mycopy, live_translate("share.enable")); |
|---|
| 6790 | websWrite(wp, |
|---|
| 6791 | "<input class=\"spaceradio\" type=\"radio\" value=\"other\" name=\"%s\" %s onclick=\"show_layer_ext(this, '%s', true)\" />%s \n", |
|---|
| 6792 | macmode, nvram_match(macmode, |
|---|
| 6793 | "other") ? "checked=\"checked\"" : "", |
|---|
| 6794 | id, mycopy); |
|---|
| 6795 | strcpy(mycopy, live_translate("share.disable")); |
|---|
| 6796 | websWrite(wp, |
|---|
| 6797 | "<input class=\"spaceradio\" type=\"radio\" value=\"disabled\" name=\"%s\" %s onclick=\"show_layer_ext(this, '%s', false)\" />%s\n", |
|---|
| 6798 | macmode, nvram_match(macmode, |
|---|
| 6799 | "disabled") ? "checked=\"checked\"" : |
|---|
| 6800 | "", id, mycopy); |
|---|
| 6801 | websWrite(wp, "</div>\n"); |
|---|
| 6802 | websWrite(wp, "<div class=\"setting\" id=\"%s\">\n", id); |
|---|
| 6803 | websWrite(wp, "<div class=\"label\">%s<br /> </div>\n", |
|---|
| 6804 | live_translate("wl_mac.label2")); |
|---|
| 6805 | sprintf(macmode, "%s_macmode", ifname); |
|---|
| 6806 | if (nvram_get(macmode) == NULL) |
|---|
| 6807 | nvram_set(macmode, "disabled"); |
|---|
| 6808 | strcpy(mycopy, live_translate("wl_mac.deny")); |
|---|
| 6809 | websWrite(wp, |
|---|
| 6810 | "<input class=\"spaceradio\" type=\"radio\" value=\"deny\" name=\"%s\" %s />%s \n", |
|---|
| 6811 | macmode, nvram_invmatch(macmode, |
|---|
| 6812 | "allow") ? "checked=\"checked\"" : |
|---|
| 6813 | "", mycopy); |
|---|
| 6814 | websWrite(wp, "<br />\n"); |
|---|
| 6815 | strcpy(mycopy, live_translate("wl_mac.allow")); |
|---|
| 6816 | websWrite(wp, |
|---|
| 6817 | "<input class=\"spaceradio\" type=\"radio\" value=\"allow\" name=\"%s\" %s />%s\n", |
|---|
| 6818 | macmode, nvram_match(macmode, |
|---|
| 6819 | "allow") ? "checked=\"checked\"" : "", |
|---|
| 6820 | mycopy); |
|---|
| 6821 | websWrite(wp, "</div><br />\n"); |
|---|
| 6822 | websWrite(wp, "<div class=\"center\">\n"); |
|---|
| 6823 | websWrite(wp, "<script type=\"text/javascript\">\n"); |
|---|
| 6824 | websWrite(wp, "//<![CDATA[\n"); |
|---|
| 6825 | websWrite(wp, |
|---|
| 6826 | "document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" name=\\\"mac_filter_button\\\" value=\\\"\" + sbutton.filterMac + \"\\\" onclick=\\\"openWindow('WL_FilterTable-%s.asp', 930, 740,'MACList');\\\" />\");\n", |
|---|
| 6827 | ifname); |
|---|
| 6828 | websWrite(wp, "//]]>\n"); |
|---|
| 6829 | websWrite(wp, "</script>\n"); |
|---|
| 6830 | websWrite(wp, "</div>\n"); |
|---|
| 6831 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 6832 | } |
|---|
| 6833 | |
|---|
| 6834 | void ej_list_mac_layers(webs_t wp, int argc, char_t ** argv) |
|---|
| 6835 | { |
|---|
| 6836 | #ifndef HAVE_MADWIFI |
|---|
| 6837 | int c = get_wl_instances(); |
|---|
| 6838 | char devs[32]; |
|---|
| 6839 | int i; |
|---|
| 6840 | |
|---|
| 6841 | for (i = 0; i < c; i++) { |
|---|
| 6842 | char macmode[32]; |
|---|
| 6843 | char id[32]; |
|---|
| 6844 | |
|---|
| 6845 | sprintf(devs, "wl%d", i); |
|---|
| 6846 | sprintf(macmode, "%s_macmode1", devs); |
|---|
| 6847 | sprintf(id, "idmac%s", devs); |
|---|
| 6848 | rep(id, '.', 'X'); |
|---|
| 6849 | rep(macmode, '.', 'X'); |
|---|
| 6850 | websWrite(wp, |
|---|
| 6851 | "show_layer_ext(document.wireless.%s, '%s', \"%s\" == \"other\");\n", |
|---|
| 6852 | macmode, id, nvram_match(macmode, |
|---|
| 6853 | "other") ? "other" : |
|---|
| 6854 | "disabled"); |
|---|
| 6855 | } |
|---|
| 6856 | |
|---|
| 6857 | #else |
|---|
| 6858 | |
|---|
| 6859 | int c = getdevicecount(); |
|---|
| 6860 | char devs[32]; |
|---|
| 6861 | int i; |
|---|
| 6862 | |
|---|
| 6863 | for (i = 0; i < c; i++) { |
|---|
| 6864 | char macmode[32]; |
|---|
| 6865 | char id[32]; |
|---|
| 6866 | |
|---|
| 6867 | sprintf(devs, "ath%d", i); |
|---|
| 6868 | sprintf(macmode, "%s_macmode1", devs); |
|---|
| 6869 | sprintf(id, "idmac%s", devs); |
|---|
| 6870 | rep(id, '.', 'X'); |
|---|
| 6871 | rep(macmode, '.', 'X'); |
|---|
| 6872 | websWrite(wp, |
|---|
| 6873 | "show_layer_ext(document.wireless.%s, '%s', \"%s\" == \"other\");\n", |
|---|
| 6874 | macmode, id, nvram_match(macmode, |
|---|
| 6875 | "other") ? "other" : |
|---|
| 6876 | "disabled"); |
|---|
| 6877 | // show_macfilter_if (wp, devs); |
|---|
| 6878 | char vif[32]; |
|---|
| 6879 | |
|---|
| 6880 | sprintf(vif, "%s_vifs", devs); |
|---|
| 6881 | char var[80], *next; |
|---|
| 6882 | char *vifs = nvram_safe_get(vif); |
|---|
| 6883 | |
|---|
| 6884 | if (vifs != NULL) |
|---|
| 6885 | foreach(var, vifs, next) { |
|---|
| 6886 | sprintf(macmode, "%s_macmode1", var); |
|---|
| 6887 | sprintf(id, "idmac%s", var); |
|---|
| 6888 | rep(id, '.', 'X'); |
|---|
| 6889 | rep(macmode, '.', 'X'); |
|---|
| 6890 | websWrite(wp, |
|---|
| 6891 | "show_layer_ext(document.wireless.%s, '%s', \"%s\" == \"other\");\n", |
|---|
| 6892 | macmode, id, nvram_match(macmode, |
|---|
| 6893 | "other") ? "other" : |
|---|
| 6894 | "disabled"); |
|---|
| 6895 | } |
|---|
| 6896 | } |
|---|
| 6897 | |
|---|
| 6898 | #endif |
|---|
| 6899 | } |
|---|
| 6900 | |
|---|
| 6901 | void ej_show_macfilter(webs_t wp, int argc, char_t ** argv) |
|---|
| 6902 | { |
|---|
| 6903 | #ifndef HAVE_MADWIFI |
|---|
| 6904 | int c = get_wl_instances(); |
|---|
| 6905 | char devs[32]; |
|---|
| 6906 | int i; |
|---|
| 6907 | |
|---|
| 6908 | for (i = 0; i < c; i++) { |
|---|
| 6909 | sprintf(devs, "wl%d", i); |
|---|
| 6910 | show_macfilter_if(wp, devs); |
|---|
| 6911 | } |
|---|
| 6912 | #else |
|---|
| 6913 | int c = getdevicecount(); |
|---|
| 6914 | char devs[32]; |
|---|
| 6915 | int i; |
|---|
| 6916 | |
|---|
| 6917 | for (i = 0; i < c; i++) { |
|---|
| 6918 | sprintf(devs, "ath%d", i); |
|---|
| 6919 | show_macfilter_if(wp, devs); |
|---|
| 6920 | char vif[32]; |
|---|
| 6921 | |
|---|
| 6922 | sprintf(vif, "%s_vifs", devs); |
|---|
| 6923 | char var[80], *next; |
|---|
| 6924 | char *vifs = nvram_safe_get(vif); |
|---|
| 6925 | |
|---|
| 6926 | if (vifs != NULL) |
|---|
| 6927 | foreach(var, vifs, next) { |
|---|
| 6928 | show_macfilter_if(wp, var); |
|---|
| 6929 | } |
|---|
| 6930 | } |
|---|
| 6931 | |
|---|
| 6932 | #endif |
|---|
| 6933 | } |
|---|
| 6934 | |
|---|
| 6935 | void ej_show_ifselect(webs_t wp, int argc, char_t ** argv) |
|---|
| 6936 | { |
|---|
| 6937 | if (argc < 1) |
|---|
| 6938 | return; |
|---|
| 6939 | char *ifname = argv[0]; |
|---|
| 6940 | websWrite(wp, "<select name=\"%s\">\n", ifname); |
|---|
| 6941 | websWrite(wp, "<option value=\"%s\" %s >LAN</option>\n", |
|---|
| 6942 | nvram_safe_get("lan_ifname"), |
|---|
| 6943 | nvram_match(ifname, |
|---|
| 6944 | nvram_safe_get("lan_ifname")) ? |
|---|
| 6945 | "selected=\"selected\"" : ""); |
|---|
| 6946 | char *next; |
|---|
| 6947 | char var[80]; |
|---|
| 6948 | char eths[256]; |
|---|
| 6949 | |
|---|
| 6950 | memset(eths, 0, 256); |
|---|
| 6951 | getIfLists(eths, 256); |
|---|
| 6952 | foreach(var, eths, next) { |
|---|
| 6953 | if (!strcmp(get_wan_face(), var)) |
|---|
| 6954 | continue; |
|---|
| 6955 | if (!strcmp(nvram_safe_get("lan_ifname"), var)) |
|---|
| 6956 | continue; |
|---|
| 6957 | websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", var, |
|---|
| 6958 | nvram_match(ifname, var) ? "selected" : "", var); |
|---|
| 6959 | } |
|---|
| 6960 | |
|---|
| 6961 | websWrite(wp, "</select>\n"); |
|---|
| 6962 | } |
|---|
| 6963 | |
|---|
| 6964 | #ifdef HAVE_RFLOW |
|---|
| 6965 | void ej_show_rflowif(webs_t wp, int argc, char_t ** argv) |
|---|
| 6966 | { |
|---|
| 6967 | websWrite(wp, "<option value=\"%s\" %s >LAN & WLAN</option>\n", |
|---|
| 6968 | nvram_safe_get("lan_ifname"), nvram_match("rflow_if", |
|---|
| 6969 | nvram_safe_get |
|---|
| 6970 | ("lan_ifname")) |
|---|
| 6971 | ? "selected=\"selected\"" : ""); |
|---|
| 6972 | |
|---|
| 6973 | char *lanifs = nvram_safe_get("lan_ifnames"); |
|---|
| 6974 | char *next; |
|---|
| 6975 | char var[80]; |
|---|
| 6976 | |
|---|
| 6977 | foreach(var, lanifs, next) { |
|---|
| 6978 | if (nvram_match("wan_ifname", var)) |
|---|
| 6979 | continue; |
|---|
| 6980 | if (!ifexists(var)) |
|---|
| 6981 | continue; |
|---|
| 6982 | websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 6983 | var, nvram_match("rflow_if", |
|---|
| 6984 | var) ? "selected=\"selected\"" : |
|---|
| 6985 | "", var); |
|---|
| 6986 | } |
|---|
| 6987 | #if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880) |
|---|
| 6988 | int cnt = get_wl_instances(); |
|---|
| 6989 | int c; |
|---|
| 6990 | |
|---|
| 6991 | for (c = 0; c < cnt; c++) { |
|---|
| 6992 | sprintf(var, "wl%d_ifname", c); |
|---|
| 6993 | websWrite(wp, "<option value=\"%s\" %s >WLAN%d</option>\n", |
|---|
| 6994 | nvram_safe_get(var), nvram_match("rflow_if", |
|---|
| 6995 | nvram_safe_get(var)) |
|---|
| 6996 | ? "selected=\"selected\"" : "", c); |
|---|
| 6997 | } |
|---|
| 6998 | #endif |
|---|
| 6999 | |
|---|
| 7000 | char *wanif = nvram_safe_get("wan_ifname"); |
|---|
| 7001 | |
|---|
| 7002 | if (strlen(wanif) != 0) { |
|---|
| 7003 | websWrite(wp, "<option value=\"%s\" %s >WAN</option>\n", |
|---|
| 7004 | wanif, nvram_match("rflow_if", |
|---|
| 7005 | wanif) ? "selected=\"selected\"" : |
|---|
| 7006 | ""); |
|---|
| 7007 | } |
|---|
| 7008 | } |
|---|
| 7009 | #endif |
|---|
| 7010 | |
|---|
| 7011 | #ifdef HAVE_FREERADIUS |
|---|
| 7012 | |
|---|
| 7013 | void ej_show_certificate_status(webs_t wp, int argc, char_t ** argv) |
|---|
| 7014 | { |
|---|
| 7015 | int percent = 0; |
|---|
| 7016 | if (f_exists("/jffs/etc/freeradius/certs/dh")) |
|---|
| 7017 | percent += 60; |
|---|
| 7018 | if (f_exists("/jffs/etc/freeradius/certs/server.csr")) |
|---|
| 7019 | percent += 5; |
|---|
| 7020 | if (f_exists("/jffs/etc/freeradius/certs/server.key")) |
|---|
| 7021 | percent += 5; |
|---|
| 7022 | if (f_exists("/jffs/etc/freeradius/certs/ca.pem")) |
|---|
| 7023 | percent += 5; |
|---|
| 7024 | if (f_exists("/jffs/etc/freeradius/certs/ca.key")) |
|---|
| 7025 | percent += 5; |
|---|
| 7026 | if (f_exists("/jffs/etc/freeradius/certs/server.crt")) |
|---|
| 7027 | percent += 5; |
|---|
| 7028 | if (f_exists("/jffs/etc/freeradius/certs/server.p12")) |
|---|
| 7029 | percent += 5; |
|---|
| 7030 | if (f_exists("/jffs/etc/freeradius/certs/server.pem")) |
|---|
| 7031 | percent += 5; |
|---|
| 7032 | if (f_exists("/jffs/etc/freeradius/certs/ca.der")) |
|---|
| 7033 | percent += 5; |
|---|
| 7034 | |
|---|
| 7035 | if (percent == 100) { |
|---|
| 7036 | websWrite(wp, "certicate generation done<br />\n"); |
|---|
| 7037 | } else { |
|---|
| 7038 | websWrite(wp, |
|---|
| 7039 | "generating %d%%, this may take a long time<br />\n", |
|---|
| 7040 | percent); |
|---|
| 7041 | } |
|---|
| 7042 | } |
|---|
| 7043 | |
|---|
| 7044 | #include <radiusdb.h> |
|---|
| 7045 | |
|---|
| 7046 | /*struct radiususer { |
|---|
| 7047 | unsigned int fieldlen; |
|---|
| 7048 | unsigned int usersize; |
|---|
| 7049 | unsigned char *user; |
|---|
| 7050 | unsigned int passwordsize; |
|---|
| 7051 | unsigned char *passwd; |
|---|
| 7052 | unsigned int downstream; |
|---|
| 7053 | unsigned int upstream; |
|---|
| 7054 | //more fields can be added in future |
|---|
| 7055 | }; |
|---|
| 7056 | |
|---|
| 7057 | struct radiusdb { |
|---|
| 7058 | unsigned int usercount; |
|---|
| 7059 | struct radiususer *users; |
|---|
| 7060 | }; |
|---|
| 7061 | */ |
|---|
| 7062 | void ej_show_radius_users(webs_t wp, int argc, char_t ** argv) |
|---|
| 7063 | { |
|---|
| 7064 | websWrite(wp, "<table class=\"table\" summary=\"Radius Users\">\n"); |
|---|
| 7065 | |
|---|
| 7066 | websWrite(wp, "<tr>\n\ |
|---|
| 7067 | <th><script type=\"text/javascript\">Capture(freeradius.username)</script></th>\n\ |
|---|
| 7068 | <th><script type=\"text/javascript\">Capture(freeradius.password)</script></th>\n\ |
|---|
| 7069 | <th><script type=\"text/javascript\">Capture(freeradius.downstream)</script></th>\n\ |
|---|
| 7070 | <th><script type=\"text/javascript\">Capture(freeradius.upstream)</script></th>\n\ |
|---|
| 7071 | <th><script type=\"text/javascript\">Capture(freeradius.expiration)</script></th>\n\ |
|---|
| 7072 | <th> </th>\n\ |
|---|
| 7073 | <th> </th>\n\ |
|---|
| 7074 | </tr>\n"); |
|---|
| 7075 | |
|---|
| 7076 | unsigned int i; |
|---|
| 7077 | struct radiusdb *db = loadradiusdb(); |
|---|
| 7078 | time_t tm; |
|---|
| 7079 | time(&tm); |
|---|
| 7080 | if (db != NULL) // empty |
|---|
| 7081 | { |
|---|
| 7082 | for (i = 0; i < db->usercount; i++) { |
|---|
| 7083 | websWrite(wp, "<tr>\n"); |
|---|
| 7084 | char vlan_name[32]; |
|---|
| 7085 | sprintf(vlan_name, "username%d", i); |
|---|
| 7086 | websWrite(wp, |
|---|
| 7087 | "<td><input name=\"%s\" size=\"8\" value=\"%s\" /></td>\n", |
|---|
| 7088 | vlan_name, (db->users[i].user != NULL |
|---|
| 7089 | && db->users[i]. |
|---|
| 7090 | usersize) ? db->users[i]. |
|---|
| 7091 | user : ""); |
|---|
| 7092 | |
|---|
| 7093 | sprintf(vlan_name, "password%d", i); |
|---|
| 7094 | websWrite(wp, |
|---|
| 7095 | "<td><input name=\"%s\" size=\"8\" value=\"%s\" /></td>\n", |
|---|
| 7096 | vlan_name, (db->users[i].passwd != NULL |
|---|
| 7097 | && db-> |
|---|
| 7098 | users[i].passwordsize) ? db-> |
|---|
| 7099 | users[i].passwd : ""); |
|---|
| 7100 | |
|---|
| 7101 | sprintf(vlan_name, "downstream%d", i); |
|---|
| 7102 | websWrite(wp, |
|---|
| 7103 | "<td><input class=\"num\" name=\"%s\" size=\"5\" value=\"%d\" /></td>\n", |
|---|
| 7104 | vlan_name, db->users[i].downstream); |
|---|
| 7105 | |
|---|
| 7106 | sprintf(vlan_name, "upstream%d", i); |
|---|
| 7107 | websWrite(wp, |
|---|
| 7108 | "<td><input class=\"num\" name=\"%s\" size=\"5\" value=\"%d\" /></td>\n", |
|---|
| 7109 | vlan_name, db->users[i].upstream); |
|---|
| 7110 | |
|---|
| 7111 | sprintf(vlan_name, "expiration%d", i); |
|---|
| 7112 | long expiration = 0; //never |
|---|
| 7113 | if (db->users[i].expiration) { |
|---|
| 7114 | long curtime = ((tm / 60) / 60) / 24; //in days |
|---|
| 7115 | expiration = db->users[i].expiration - curtime; |
|---|
| 7116 | } |
|---|
| 7117 | websWrite(wp, |
|---|
| 7118 | "<td><input class=\"num\" name=\"%s\" size=\"3\" value=\"%d\" /></td>\n", |
|---|
| 7119 | vlan_name, expiration); |
|---|
| 7120 | |
|---|
| 7121 | websWrite(wp, |
|---|
| 7122 | "<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>", |
|---|
| 7123 | i); |
|---|
| 7124 | websWrite(wp, |
|---|
| 7125 | "<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", |
|---|
| 7126 | i); |
|---|
| 7127 | websWrite(wp, "</tr>\n"); |
|---|
| 7128 | } |
|---|
| 7129 | freeradiusdb(db); |
|---|
| 7130 | } |
|---|
| 7131 | websWrite(wp, "</table>\n"); |
|---|
| 7132 | websWrite(wp, |
|---|
| 7133 | "<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"); |
|---|
| 7134 | } |
|---|
| 7135 | |
|---|
| 7136 | void ej_show_radius_clients(webs_t wp, int argc, char_t ** argv) |
|---|
| 7137 | { |
|---|
| 7138 | websWrite(wp, "<table class=\"table\" summary=\"Radius Clients\">\n"); |
|---|
| 7139 | |
|---|
| 7140 | websWrite(wp, "<tr>\n\ |
|---|
| 7141 | <th>IP/NET</th>\n\ |
|---|
| 7142 | <th><script type=\"text/javascript\">Capture(freeradius.sharedkey)</script></th>\n\ |
|---|
| 7143 | <th> </th>\n\ |
|---|
| 7144 | </tr>\n"); |
|---|
| 7145 | unsigned int i; |
|---|
| 7146 | struct radiusclientdb *db = loadradiusclientdb(); |
|---|
| 7147 | if (db != NULL) // empty |
|---|
| 7148 | { |
|---|
| 7149 | for (i = 0; i < db->usercount; i++) { |
|---|
| 7150 | websWrite(wp, "<tr>\n"); |
|---|
| 7151 | char vlan_name[32]; |
|---|
| 7152 | sprintf(vlan_name, "client%d", i); |
|---|
| 7153 | websWrite(wp, |
|---|
| 7154 | "<td><input name=\"%s\" size=\"20\" value=\"%s\" /></td>\n", |
|---|
| 7155 | vlan_name, (db->users[i].client != NULL |
|---|
| 7156 | && db->users[i]. |
|---|
| 7157 | clientsize) ? db->users[i]. |
|---|
| 7158 | client : ""); |
|---|
| 7159 | |
|---|
| 7160 | sprintf(vlan_name, "shared%d", i); |
|---|
| 7161 | websWrite(wp, |
|---|
| 7162 | "<td><input name=\"%s\" size=\"20\" value=\"%s\" /></td>\n", |
|---|
| 7163 | vlan_name, (db->users[i].passwd != NULL |
|---|
| 7164 | && db-> |
|---|
| 7165 | users[i].passwordsize) ? db-> |
|---|
| 7166 | users[i].passwd : ""); |
|---|
| 7167 | |
|---|
| 7168 | websWrite(wp, |
|---|
| 7169 | "<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", |
|---|
| 7170 | i); |
|---|
| 7171 | websWrite(wp, "</tr>\n"); |
|---|
| 7172 | } |
|---|
| 7173 | freeradiusclientdb(db); |
|---|
| 7174 | } |
|---|
| 7175 | websWrite(wp, "</table>\n"); |
|---|
| 7176 | websWrite(wp, |
|---|
| 7177 | "<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"); |
|---|
| 7178 | } |
|---|
| 7179 | |
|---|
| 7180 | #endif |
|---|