| 1 | #define VISUALSOURCE 1 |
|---|
| 2 | /* |
|---|
| 3 | * dd-wrt.c |
|---|
| 4 | * |
|---|
| 5 | * Copyright (C) 2005 - 2007 Sebastian Gottschall <sebastian.gottschall@blueline-ag.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 <bcmnvram.h> |
|---|
| 47 | #include <l7protocols.h> |
|---|
| 48 | |
|---|
| 49 | #ifdef HAVE_OVERCLOCKING |
|---|
| 50 | static unsigned int type3_clocks[3] = { 150, 200, 0 }; |
|---|
| 51 | static unsigned int type4_clocks[10] = |
|---|
| 52 | { 192, 200, 216, 228, 240, 252, 264, 280, 300, 0 }; |
|---|
| 53 | static unsigned int type7_clocks[10] = |
|---|
| 54 | { 183, 187, 198, 200, 216, 225, 233, 237, 250, 0 }; |
|---|
| 55 | #endif |
|---|
| 56 | |
|---|
| 57 | void |
|---|
| 58 | show_ipnetmask (webs_t wp, char *var) |
|---|
| 59 | { |
|---|
| 60 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 61 | websWrite (wp, |
|---|
| 62 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.ip)</script></div>\n"); |
|---|
| 63 | |
|---|
| 64 | char *ipv = nvram_nget ("%s_ipaddr", var); |
|---|
| 65 | websWrite (wp, |
|---|
| 66 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,1,223,share.ip)\" name=\"%s_ipaddr_0\" value=\"%d\" />.", |
|---|
| 67 | var, get_single_ip (ipv, 0)); |
|---|
| 68 | websWrite (wp, |
|---|
| 69 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_1\" value=\"%d\" />.", |
|---|
| 70 | var, get_single_ip (ipv, 1)); |
|---|
| 71 | websWrite (wp, |
|---|
| 72 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_2\" value=\"%d\" />.", |
|---|
| 73 | var, get_single_ip (ipv, 2)); |
|---|
| 74 | websWrite (wp, |
|---|
| 75 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_3\" value=\"%d\" />\n", |
|---|
| 76 | var, get_single_ip (ipv, 3)); |
|---|
| 77 | websWrite (wp, "</div>\n"); |
|---|
| 78 | |
|---|
| 79 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 80 | websWrite (wp, |
|---|
| 81 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.subnet)</script></div>\n"); |
|---|
| 82 | ipv = nvram_nget ("%s_netmask", var); |
|---|
| 83 | |
|---|
| 84 | websWrite (wp, |
|---|
| 85 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_0\" value=\"%d\" />.", |
|---|
| 86 | var, get_single_ip (ipv, 0)); |
|---|
| 87 | websWrite (wp, |
|---|
| 88 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_1\" value=\"%d\" />.", |
|---|
| 89 | var, get_single_ip (ipv, 1)); |
|---|
| 90 | websWrite (wp, |
|---|
| 91 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_2\" value=\"%d\" />.", |
|---|
| 92 | var, get_single_ip (ipv, 2)); |
|---|
| 93 | websWrite (wp, |
|---|
| 94 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_3\" value=\"%d\" />", |
|---|
| 95 | var, get_single_ip (ipv, 3)); |
|---|
| 96 | websWrite (wp, "</div>\n<br />\n"); |
|---|
| 97 | |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | #ifdef HAVE_OVERCLOCKING |
|---|
| 101 | void |
|---|
| 102 | ej_show_clocks (webs_t wp, int argc, char_t ** argv) |
|---|
| 103 | { |
|---|
| 104 | int tab = cpu_plltype (); |
|---|
| 105 | unsigned int *c; |
|---|
| 106 | |
|---|
| 107 | if (tab == 3) |
|---|
| 108 | c = type3_clocks; |
|---|
| 109 | else if (tab == 4) |
|---|
| 110 | c = type4_clocks; |
|---|
| 111 | else if (tab == 7) |
|---|
| 112 | c = type7_clocks; |
|---|
| 113 | else |
|---|
| 114 | { |
|---|
| 115 | websWrite (wp, |
|---|
| 116 | "<script type=\"text/javascript\">Capture(management.clock_support)</script>\n</div>\n"); |
|---|
| 117 | return; |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | websWrite (wp, |
|---|
| 121 | "<div class=\"label\"><script type=\"text/javascript\">Capture(management.clock_frq)</script></div>\n"); |
|---|
| 122 | websWrite (wp, "<select name=\"overclocking\">\n"); |
|---|
| 123 | |
|---|
| 124 | int i = 0; |
|---|
| 125 | char clock[16]; |
|---|
| 126 | while (c[i] != 0) |
|---|
| 127 | { |
|---|
| 128 | sprintf (clock, "%d", c[i]); |
|---|
| 129 | websWrite (wp, "<option value=\"%d\" %s >%d MHz</option>\n", c[i], |
|---|
| 130 | nvram_match ("overclocking", |
|---|
| 131 | clock) ? "selected=\"selected\"" : "", c[i]); |
|---|
| 132 | i++; |
|---|
| 133 | } |
|---|
| 134 | websWrite (wp, "</select>\n</div>\n"); |
|---|
| 135 | } |
|---|
| 136 | #endif |
|---|
| 137 | |
|---|
| 138 | void |
|---|
| 139 | ej_show_routing (webs_t wp, int argc, char_t ** argv) |
|---|
| 140 | { |
|---|
| 141 | websWrite (wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 142 | websWrite (wp, |
|---|
| 143 | "document.write(\"<option value=\\\"gateway\\\" %s >\" + share.gateway + \"</option>\");\n", |
|---|
| 144 | nvram_selmatch (wp, "wk_mode", |
|---|
| 145 | "gateway") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 146 | #ifdef HAVE_BIRD |
|---|
| 147 | websWrite (wp, |
|---|
| 148 | "document.write(\"<option value=\\\"bgp\\\" %s >BGP</option>\");\n", |
|---|
| 149 | nvram_selmatch (wp, "wk_mode", |
|---|
| 150 | "bgp") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 151 | websWrite (wp, |
|---|
| 152 | "document.write(\"<option value=\\\"router\\\" %s >\" + route.rip2_mod + \"</option>\");\n", |
|---|
| 153 | nvram_selmatch (wp, "wk_mode", |
|---|
| 154 | "router") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 155 | #endif |
|---|
| 156 | #ifdef HAVE_QUAGGA |
|---|
| 157 | websWrite (wp, |
|---|
| 158 | "document.write(\"<option value=\\\"bgp\\\" %s >BGP</option>\");\n", |
|---|
| 159 | nvram_selmatch (wp, "wk_mode", |
|---|
| 160 | "bgp") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 161 | websWrite (wp, |
|---|
| 162 | "document.write(\"<option value=\\\"router\\\" %s >\" + route.rip2_mod + \"</option>\");\n", |
|---|
| 163 | nvram_selmatch (wp, "wk_mode", |
|---|
| 164 | "router") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 165 | websWrite (wp, |
|---|
| 166 | "document.write(\"<option value=\\\"ospf\\\" %s >\" + route.ospf_mod + \"</option>\");\n", |
|---|
| 167 | nvram_selmatch (wp, "wk_mode", |
|---|
| 168 | "ospf") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 169 | #endif |
|---|
| 170 | #ifdef HAVE_OLSRD |
|---|
| 171 | websWrite (wp, |
|---|
| 172 | "document.write(\"<option value=\\\"olsr\\\" %s >\" + route.olsrd_mod + \"</option>\");\n", |
|---|
| 173 | nvram_selmatch (wp, "wk_mode", |
|---|
| 174 | "olsr") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 175 | #endif |
|---|
| 176 | websWrite (wp, |
|---|
| 177 | "document.write(\"<option value=\\\"static\\\" %s >\" + share.router + \"</option>\");\n", |
|---|
| 178 | nvram_selmatch (wp, "wk_mode", |
|---|
| 179 | "static") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 180 | websWrite (wp, "//]]>\n</script>\n"); |
|---|
| 181 | return; |
|---|
| 182 | |
|---|
| 183 | } |
|---|
| 184 | |
|---|
| 185 | void |
|---|
| 186 | ej_show_connectiontype (webs_t wp, int argc, char_t ** argv) |
|---|
| 187 | { |
|---|
| 188 | |
|---|
| 189 | websWrite (wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 190 | websWrite (wp, |
|---|
| 191 | "document.write(\"<option value=\\\"disabled\\\" %s >\" + share.disabled + \"</option>\");\n", |
|---|
| 192 | nvram_selmatch (wp, "wan_proto", |
|---|
| 193 | "disabled") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 194 | websWrite (wp, |
|---|
| 195 | "document.write(\"<option value=\\\"static\\\" %s >\" + idx.static_ip + \"</option>\");\n", |
|---|
| 196 | nvram_selmatch (wp, "wan_proto", |
|---|
| 197 | "static") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 198 | websWrite (wp, |
|---|
| 199 | "document.write(\"<option value=\\\"dhcp\\\" %s >\" + idx.dhcp + \"</option>\");\n", |
|---|
| 200 | nvram_selmatch (wp, "wan_proto", |
|---|
| 201 | "dhcp") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 202 | websWrite (wp, "\n//]]>\n</script>\n"); |
|---|
| 203 | |
|---|
| 204 | #ifdef HAVE_PPPOE |
|---|
| 205 | websWrite (wp, "<option value=\"pppoe\" %s >PPPoE</option>\n", |
|---|
| 206 | nvram_selmatch (wp, "wan_proto", |
|---|
| 207 | "pppoe") ? "selected=\"selected\"" : ""); |
|---|
| 208 | #endif |
|---|
| 209 | #ifdef HAVE_PPTP |
|---|
| 210 | websWrite (wp, "<option value=\"pptp\" %s >PPTP</option>\n", |
|---|
| 211 | nvram_selmatch (wp, "wan_proto", |
|---|
| 212 | "pptp") ? "selected=\"selected\"" : ""); |
|---|
| 213 | #endif |
|---|
| 214 | #ifdef HAVE_L2TP |
|---|
| 215 | websWrite (wp, "<option value=\"l2tp\" %s >L2TP</option>\n", |
|---|
| 216 | nvram_selmatch (wp, "wan_proto", |
|---|
| 217 | "l2tp") ? "selected=\"selected\"" : ""); |
|---|
| 218 | #endif |
|---|
| 219 | #ifdef HAVE_HEARTBEAT |
|---|
| 220 | websWrite (wp, |
|---|
| 221 | "<option value=\"heartbeat\" %s >HeartBeat Signal</option>\n", |
|---|
| 222 | nvram_selmatch (wp, "wan_proto", |
|---|
| 223 | "heartbeat") ? "selected=\"selected\"" : ""); |
|---|
| 224 | #endif |
|---|
| 225 | |
|---|
| 226 | return; |
|---|
| 227 | } |
|---|
| 228 | |
|---|
| 229 | void |
|---|
| 230 | ej_show_infopage (webs_t wp, int argc, char_t ** argv) |
|---|
| 231 | { |
|---|
| 232 | /* |
|---|
| 233 | #ifdef HAVE_NEWMEDIA |
|---|
| 234 | websWrite(wp,"<dl>\n"); |
|---|
| 235 | websWrite(wp,"<dd class=\"definition\">GGEW net GmbH</dd>\n"); |
|---|
| 236 | websWrite(wp,"<dd class=\"definition\">Dammstrasse 68</dd>\n"); |
|---|
| 237 | websWrite(wp,"<dd class=\"definition\">64625 Bensheim</dd>\n"); |
|---|
| 238 | websWrite(wp,"<dd class=\"definition\"><a href=\"http://ggew-net.de\"><img src=\"images/ggewlogo.gif\" border=\"0\"/></a></dd>\n"); |
|---|
| 239 | websWrite(wp,"<dd class=\"definition\"> </dd>\n"); |
|---|
| 240 | websWrite(wp,"<dd class=\"definition\"><a href=\"http://ggew-net.de\"/></dd>\n"); |
|---|
| 241 | websWrite(wp,"<dd class=\"definition\"> </dd>\n"); |
|---|
| 242 | websWrite(wp,"<dd class=\"definition\">In Kooperation mit NewMedia-NET GmbH</dd>\n"); |
|---|
| 243 | websWrite(wp,"<dd class=\"definition\"><a href=\"http://www.newmedia-net.de\"/></dd>\n"); |
|---|
| 244 | websWrite(wp,"</dl>\n"); |
|---|
| 245 | #endif*/ |
|---|
| 246 | return; |
|---|
| 247 | } |
|---|
| 248 | |
|---|
| 249 | |
|---|
| 250 | void |
|---|
| 251 | ej_dumpmeminfo (webs_t wp, int argc, char_t ** argv) |
|---|
| 252 | { |
|---|
| 253 | FILE *fcpu = fopen ("/proc/meminfo", "r"); |
|---|
| 254 | if (fcpu == NULL) |
|---|
| 255 | { |
|---|
| 256 | return; |
|---|
| 257 | } |
|---|
| 258 | char buf[128]; |
|---|
| 259 | int n = 0; |
|---|
| 260 | rept:; |
|---|
| 261 | if (n == EOF) |
|---|
| 262 | { |
|---|
| 263 | fclose (fcpu); |
|---|
| 264 | return; |
|---|
| 265 | } |
|---|
| 266 | if (n) |
|---|
| 267 | websWrite (wp, "'%s'", buf); |
|---|
| 268 | n = fscanf (fcpu, "%s", buf); |
|---|
| 269 | if (n != EOF) |
|---|
| 270 | websWrite (wp, ","); |
|---|
| 271 | goto rept; |
|---|
| 272 | } |
|---|
| 273 | |
|---|
| 274 | #ifdef HAVE_RB500 |
|---|
| 275 | void |
|---|
| 276 | ej_get_clkfreq (webs_t wp, int argc, char_t ** argv) |
|---|
| 277 | { |
|---|
| 278 | FILE *fp = fopen ("/proc/cpuinfo", "rb"); |
|---|
| 279 | if (fp == NULL) |
|---|
| 280 | { |
|---|
| 281 | websWrite (wp, "unknown"); |
|---|
| 282 | return; |
|---|
| 283 | } |
|---|
| 284 | int cnt = 0; |
|---|
| 285 | int b = 0; |
|---|
| 286 | while (b != EOF) |
|---|
| 287 | { |
|---|
| 288 | b = getc (fp); |
|---|
| 289 | if (b == ':') |
|---|
| 290 | cnt++; |
|---|
| 291 | |
|---|
| 292 | if (cnt == 4) |
|---|
| 293 | { |
|---|
| 294 | getc (fp); |
|---|
| 295 | char cpuclk[4]; |
|---|
| 296 | cpuclk[0] = getc (fp); |
|---|
| 297 | cpuclk[1] = getc (fp); |
|---|
| 298 | cpuclk[2] = getc (fp); |
|---|
| 299 | cpuclk[3] = 0; |
|---|
| 300 | websWrite (wp, cpuclk); |
|---|
| 301 | fclose (fp); |
|---|
| 302 | return; |
|---|
| 303 | } |
|---|
| 304 | } |
|---|
| 305 | |
|---|
| 306 | fclose (fp); |
|---|
| 307 | websWrite (wp, "unknown"); |
|---|
| 308 | return; |
|---|
| 309 | } |
|---|
| 310 | |
|---|
| 311 | #elif HAVE_XSCALE |
|---|
| 312 | void |
|---|
| 313 | ej_get_clkfreq (webs_t wp, int argc, char_t ** argv) |
|---|
| 314 | { |
|---|
| 315 | FILE *fp = fopen ("/proc/cpuinfo", "rb"); |
|---|
| 316 | if (fp == NULL) |
|---|
| 317 | { |
|---|
| 318 | websWrite (wp, "unknown"); |
|---|
| 319 | return; |
|---|
| 320 | } |
|---|
| 321 | int cnt = 0; |
|---|
| 322 | int b = 0; |
|---|
| 323 | while (b != EOF) |
|---|
| 324 | { |
|---|
| 325 | b = getc (fp); |
|---|
| 326 | if (b == ':') |
|---|
| 327 | cnt++; |
|---|
| 328 | if (cnt == 2) |
|---|
| 329 | { |
|---|
| 330 | getc (fp); |
|---|
| 331 | char cpuclk[4]; |
|---|
| 332 | cpuclk[0] = getc (fp); |
|---|
| 333 | cpuclk[1] = getc (fp); |
|---|
| 334 | cpuclk[2] = getc (fp); |
|---|
| 335 | cpuclk[3] = 0; |
|---|
| 336 | websWrite (wp, cpuclk); |
|---|
| 337 | fclose (fp); |
|---|
| 338 | return; |
|---|
| 339 | } |
|---|
| 340 | } |
|---|
| 341 | |
|---|
| 342 | fclose (fp); |
|---|
| 343 | websWrite (wp, "unknown"); |
|---|
| 344 | return; |
|---|
| 345 | } |
|---|
| 346 | #elif HAVE_X86 |
|---|
| 347 | void |
|---|
| 348 | ej_get_clkfreq (webs_t wp, int argc, char_t ** argv) |
|---|
| 349 | { |
|---|
| 350 | FILE *fp = fopen ("/proc/cpuinfo", "rb"); |
|---|
| 351 | if (fp == NULL) |
|---|
| 352 | { |
|---|
| 353 | websWrite (wp, "unknown"); |
|---|
| 354 | return; |
|---|
| 355 | } |
|---|
| 356 | int cnt = 0; |
|---|
| 357 | int b = 0; |
|---|
| 358 | while (b != EOF) |
|---|
| 359 | { |
|---|
| 360 | b = getc (fp); |
|---|
| 361 | if (b == ':') |
|---|
| 362 | cnt++; |
|---|
| 363 | if (cnt == 7) |
|---|
| 364 | { |
|---|
| 365 | getc (fp); |
|---|
| 366 | char cpuclk[32]; |
|---|
| 367 | int i = 0; |
|---|
| 368 | b = getc (fp); |
|---|
| 369 | while (b != 0xa && b != 0xd && b != 0x20) |
|---|
| 370 | { |
|---|
| 371 | cpuclk[i++] = b; |
|---|
| 372 | b = getc (fp); |
|---|
| 373 | } |
|---|
| 374 | cpuclk[i++] = 0; |
|---|
| 375 | websWrite (wp, cpuclk); |
|---|
| 376 | fclose (fp); |
|---|
| 377 | return; |
|---|
| 378 | } |
|---|
| 379 | } |
|---|
| 380 | |
|---|
| 381 | fclose (fp); |
|---|
| 382 | websWrite (wp, "unknown"); |
|---|
| 383 | return; |
|---|
| 384 | } |
|---|
| 385 | #elif HAVE_MAGICBOX |
|---|
| 386 | void |
|---|
| 387 | ej_get_clkfreq (webs_t wp, int argc, char_t ** argv) |
|---|
| 388 | { |
|---|
| 389 | FILE *fp = fopen ("/proc/cpuinfo", "rb"); |
|---|
| 390 | if (fp == NULL) |
|---|
| 391 | { |
|---|
| 392 | websWrite (wp, "unknown"); |
|---|
| 393 | return; |
|---|
| 394 | } |
|---|
| 395 | int cnt = 0; |
|---|
| 396 | int b = 0; |
|---|
| 397 | while (b != EOF) |
|---|
| 398 | { |
|---|
| 399 | b = getc (fp); |
|---|
| 400 | if (b == ':') |
|---|
| 401 | cnt++; |
|---|
| 402 | if (cnt == 3) |
|---|
| 403 | { |
|---|
| 404 | getc (fp); |
|---|
| 405 | char cpuclk[4]; |
|---|
| 406 | cpuclk[0] = getc (fp); |
|---|
| 407 | cpuclk[1] = getc (fp); |
|---|
| 408 | cpuclk[2] = getc (fp); |
|---|
| 409 | cpuclk[3] = 0; |
|---|
| 410 | websWrite (wp, cpuclk); |
|---|
| 411 | fclose (fp); |
|---|
| 412 | return; |
|---|
| 413 | } |
|---|
| 414 | } |
|---|
| 415 | |
|---|
| 416 | fclose (fp); |
|---|
| 417 | websWrite (wp, "unknown"); |
|---|
| 418 | return; |
|---|
| 419 | } |
|---|
| 420 | #elif HAVE_FONERA |
|---|
| 421 | void |
|---|
| 422 | ej_get_clkfreq (webs_t wp, int argc, char_t ** argv) |
|---|
| 423 | { |
|---|
| 424 | FILE *fp = fopen ("/proc/cpuinfo", "rb"); |
|---|
| 425 | if (fp == NULL) |
|---|
| 426 | { |
|---|
| 427 | websWrite (wp, "unknown"); |
|---|
| 428 | return; |
|---|
| 429 | } |
|---|
| 430 | int cnt = 0; |
|---|
| 431 | int b = 0; |
|---|
| 432 | while (b != EOF) |
|---|
| 433 | { |
|---|
| 434 | b = getc (fp); |
|---|
| 435 | if (b == ':') |
|---|
| 436 | cnt++; |
|---|
| 437 | if (cnt == 4) |
|---|
| 438 | { |
|---|
| 439 | getc (fp); |
|---|
| 440 | char cpuclk[4]; |
|---|
| 441 | cpuclk[0] = getc (fp); |
|---|
| 442 | cpuclk[1] = getc (fp); |
|---|
| 443 | cpuclk[2] = getc (fp); |
|---|
| 444 | cpuclk[3] = 0; |
|---|
| 445 | websWrite (wp, cpuclk); |
|---|
| 446 | fclose (fp); |
|---|
| 447 | return; |
|---|
| 448 | } |
|---|
| 449 | } |
|---|
| 450 | |
|---|
| 451 | fclose (fp); |
|---|
| 452 | websWrite (wp, "unknown"); |
|---|
| 453 | return; |
|---|
| 454 | } |
|---|
| 455 | #elif HAVE_MERAKI |
|---|
| 456 | void |
|---|
| 457 | ej_get_clkfreq (webs_t wp, int argc, char_t ** argv) |
|---|
| 458 | { |
|---|
| 459 | FILE *fp = fopen ("/proc/cpuinfo", "rb"); |
|---|
| 460 | if (fp == NULL) |
|---|
| 461 | { |
|---|
| 462 | websWrite (wp, "unknown"); |
|---|
| 463 | return; |
|---|
| 464 | } |
|---|
| 465 | int cnt = 0; |
|---|
| 466 | int b = 0; |
|---|
| 467 | while (b != EOF) |
|---|
| 468 | { |
|---|
| 469 | b = getc (fp); |
|---|
| 470 | if (b == ':') |
|---|
| 471 | cnt++; |
|---|
| 472 | if (cnt == 4) |
|---|
| 473 | { |
|---|
| 474 | getc (fp); |
|---|
| 475 | char cpuclk[4]; |
|---|
| 476 | cpuclk[0] = getc (fp); |
|---|
| 477 | cpuclk[1] = getc (fp); |
|---|
| 478 | cpuclk[2] = getc (fp); |
|---|
| 479 | cpuclk[3] = 0; |
|---|
| 480 | websWrite (wp, cpuclk); |
|---|
| 481 | fclose (fp); |
|---|
| 482 | return; |
|---|
| 483 | } |
|---|
| 484 | } |
|---|
| 485 | |
|---|
| 486 | fclose (fp); |
|---|
| 487 | websWrite (wp, "unknown"); |
|---|
| 488 | return; |
|---|
| 489 | } |
|---|
| 490 | #elif HAVE_LS2 |
|---|
| 491 | void |
|---|
| 492 | ej_get_clkfreq (webs_t wp, int argc, char_t ** argv) |
|---|
| 493 | { |
|---|
| 494 | FILE *fp = fopen ("/proc/cpuinfo", "rb"); |
|---|
| 495 | if (fp == NULL) |
|---|
| 496 | { |
|---|
| 497 | websWrite (wp, "unknown"); |
|---|
| 498 | return; |
|---|
| 499 | } |
|---|
| 500 | int cnt = 0; |
|---|
| 501 | int b = 0; |
|---|
| 502 | while (b != EOF) |
|---|
| 503 | { |
|---|
| 504 | b = getc (fp); |
|---|
| 505 | if (b == ':') |
|---|
| 506 | cnt++; |
|---|
| 507 | if (cnt == 4) |
|---|
| 508 | { |
|---|
| 509 | getc (fp); |
|---|
| 510 | char cpuclk[4]; |
|---|
| 511 | cpuclk[0] = getc (fp); |
|---|
| 512 | cpuclk[1] = getc (fp); |
|---|
| 513 | cpuclk[2] = getc (fp); |
|---|
| 514 | cpuclk[3] = 0; |
|---|
| 515 | websWrite (wp, cpuclk); |
|---|
| 516 | fclose (fp); |
|---|
| 517 | return; |
|---|
| 518 | } |
|---|
| 519 | } |
|---|
| 520 | |
|---|
| 521 | fclose (fp); |
|---|
| 522 | websWrite (wp, "unknown"); |
|---|
| 523 | return; |
|---|
| 524 | } |
|---|
| 525 | #elif HAVE_LS5 |
|---|
| 526 | void |
|---|
| 527 | ej_get_clkfreq (webs_t wp, int argc, char_t ** argv) |
|---|
| 528 | { |
|---|
| 529 | FILE *fp = fopen ("/proc/cpuinfo", "rb"); |
|---|
| 530 | if (fp == NULL) |
|---|
| 531 | { |
|---|
| 532 | websWrite (wp, "unknown"); |
|---|
| 533 | return; |
|---|
| 534 | } |
|---|
| 535 | int cnt = 0; |
|---|
| 536 | int b = 0; |
|---|
| 537 | while (b != EOF) |
|---|
| 538 | { |
|---|
| 539 | b = getc (fp); |
|---|
| 540 | if (b == ':') |
|---|
| 541 | cnt++; |
|---|
| 542 | if (cnt == 4) |
|---|
| 543 | { |
|---|
| 544 | getc (fp); |
|---|
| 545 | char cpuclk[4]; |
|---|
| 546 | cpuclk[0] = getc (fp); |
|---|
| 547 | cpuclk[1] = getc (fp); |
|---|
| 548 | cpuclk[2] = getc (fp); |
|---|
| 549 | cpuclk[3] = 0; |
|---|
| 550 | websWrite (wp, cpuclk); |
|---|
| 551 | fclose (fp); |
|---|
| 552 | return; |
|---|
| 553 | } |
|---|
| 554 | } |
|---|
| 555 | |
|---|
| 556 | fclose (fp); |
|---|
| 557 | websWrite (wp, "unknown"); |
|---|
| 558 | return; |
|---|
| 559 | } |
|---|
| 560 | #elif HAVE_WHRAG108 |
|---|
| 561 | void |
|---|
| 562 | ej_get_clkfreq (webs_t wp, int argc, char_t ** argv) |
|---|
| 563 | { |
|---|
| 564 | FILE *fp = fopen ("/proc/cpuinfo", "rb"); |
|---|
| 565 | if (fp == NULL) |
|---|
| 566 | { |
|---|
| 567 | websWrite (wp, "unknown"); |
|---|
| 568 | return; |
|---|
| 569 | } |
|---|
| 570 | int cnt = 0; |
|---|
| 571 | int b = 0; |
|---|
| 572 | while (b != EOF) |
|---|
| 573 | { |
|---|
| 574 | b = getc (fp); |
|---|
| 575 | if (b == ':') |
|---|
| 576 | cnt++; |
|---|
| 577 | if (cnt == 4) |
|---|
| 578 | { |
|---|
| 579 | getc (fp); |
|---|
| 580 | char cpuclk[4]; |
|---|
| 581 | cpuclk[0] = getc (fp); |
|---|
| 582 | cpuclk[1] = getc (fp); |
|---|
| 583 | cpuclk[2] = getc (fp); |
|---|
| 584 | cpuclk[3] = 0; |
|---|
| 585 | websWrite (wp, cpuclk); |
|---|
| 586 | fclose (fp); |
|---|
| 587 | return; |
|---|
| 588 | } |
|---|
| 589 | } |
|---|
| 590 | |
|---|
| 591 | fclose (fp); |
|---|
| 592 | websWrite (wp, "unknown"); |
|---|
| 593 | return; |
|---|
| 594 | } |
|---|
| 595 | #elif defined(HAVE_PB42) || defined(HAVE_LSX) || defined(HAVE_DANUBE) |
|---|
| 596 | void |
|---|
| 597 | ej_get_clkfreq (webs_t wp, int argc, char_t ** argv) |
|---|
| 598 | { |
|---|
| 599 | FILE *fp = fopen ("/proc/cpuinfo", "rb"); |
|---|
| 600 | if (fp == NULL) |
|---|
| 601 | { |
|---|
| 602 | websWrite (wp, "unknown"); |
|---|
| 603 | return; |
|---|
| 604 | } |
|---|
| 605 | int cnt = 0; |
|---|
| 606 | int b = 0; |
|---|
| 607 | while (b != EOF) |
|---|
| 608 | { |
|---|
| 609 | b = getc (fp); |
|---|
| 610 | if (b == ':') |
|---|
| 611 | cnt++; |
|---|
| 612 | if (cnt == 5) |
|---|
| 613 | { |
|---|
| 614 | getc (fp); |
|---|
| 615 | char cpuclk[4]; |
|---|
| 616 | cpuclk[0] = getc (fp); |
|---|
| 617 | cpuclk[1] = getc (fp); |
|---|
| 618 | cpuclk[2] = getc (fp); |
|---|
| 619 | cpuclk[3] = 0; |
|---|
| 620 | websWrite (wp, cpuclk); |
|---|
| 621 | fclose (fp); |
|---|
| 622 | return; |
|---|
| 623 | } |
|---|
| 624 | } |
|---|
| 625 | |
|---|
| 626 | fclose (fp); |
|---|
| 627 | websWrite (wp, "unknown"); |
|---|
| 628 | return; |
|---|
| 629 | } |
|---|
| 630 | #elif HAVE_TW6600 |
|---|
| 631 | void |
|---|
| 632 | ej_get_clkfreq (webs_t wp, int argc, char_t ** argv) |
|---|
| 633 | { |
|---|
| 634 | FILE *fp = fopen ("/proc/cpuinfo", "rb"); |
|---|
| 635 | if (fp == NULL) |
|---|
| 636 | { |
|---|
| 637 | websWrite (wp, "unknown"); |
|---|
| 638 | return; |
|---|
| 639 | } |
|---|
| 640 | int cnt = 0; |
|---|
| 641 | int b = 0; |
|---|
| 642 | while (b != EOF) |
|---|
| 643 | { |
|---|
| 644 | b = getc (fp); |
|---|
| 645 | if (b == ':') |
|---|
| 646 | cnt++; |
|---|
| 647 | if (cnt == 4) |
|---|
| 648 | { |
|---|
| 649 | getc (fp); |
|---|
| 650 | char cpuclk[4]; |
|---|
| 651 | cpuclk[0] = getc (fp); |
|---|
| 652 | cpuclk[1] = getc (fp); |
|---|
| 653 | cpuclk[2] = getc (fp); |
|---|
| 654 | cpuclk[3] = 0; |
|---|
| 655 | websWrite (wp, cpuclk); |
|---|
| 656 | fclose (fp); |
|---|
| 657 | return; |
|---|
| 658 | } |
|---|
| 659 | } |
|---|
| 660 | |
|---|
| 661 | fclose (fp); |
|---|
| 662 | websWrite (wp, "unknown"); |
|---|
| 663 | return; |
|---|
| 664 | } |
|---|
| 665 | #elif HAVE_CA8 |
|---|
| 666 | void |
|---|
| 667 | ej_get_clkfreq (webs_t wp, int argc, char_t ** argv) |
|---|
| 668 | { |
|---|
| 669 | FILE *fp = fopen ("/proc/cpuinfo", "rb"); |
|---|
| 670 | if (fp == NULL) |
|---|
| 671 | { |
|---|
| 672 | websWrite (wp, "unknown"); |
|---|
| 673 | return; |
|---|
| 674 | } |
|---|
| 675 | int cnt = 0; |
|---|
| 676 | int b = 0; |
|---|
| 677 | while (b != EOF) |
|---|
| 678 | { |
|---|
| 679 | b = getc (fp); |
|---|
| 680 | if (b == ':') |
|---|
| 681 | cnt++; |
|---|
| 682 | if (cnt == 4) |
|---|
| 683 | { |
|---|
| 684 | getc (fp); |
|---|
| 685 | char cpuclk[4]; |
|---|
| 686 | cpuclk[0] = getc (fp); |
|---|
| 687 | cpuclk[1] = getc (fp); |
|---|
| 688 | cpuclk[2] = getc (fp); |
|---|
| 689 | cpuclk[3] = 0; |
|---|
| 690 | websWrite (wp, cpuclk); |
|---|
| 691 | fclose (fp); |
|---|
| 692 | return; |
|---|
| 693 | } |
|---|
| 694 | } |
|---|
| 695 | |
|---|
| 696 | fclose (fp); |
|---|
| 697 | websWrite (wp, "unknown"); |
|---|
| 698 | return; |
|---|
| 699 | } |
|---|
| 700 | |
|---|
| 701 | #else |
|---|
| 702 | |
|---|
| 703 | |
|---|
| 704 | void |
|---|
| 705 | ej_get_clkfreq (webs_t wp, int argc, char_t ** argv) |
|---|
| 706 | { |
|---|
| 707 | char *clk = nvram_get ("clkfreq"); |
|---|
| 708 | if (clk == NULL) |
|---|
| 709 | { |
|---|
| 710 | websWrite (wp, "125"); |
|---|
| 711 | return; |
|---|
| 712 | } |
|---|
| 713 | char buf[64]; |
|---|
| 714 | strcpy (buf, clk); |
|---|
| 715 | int i = 0; |
|---|
| 716 | while (buf[i++] != 0) |
|---|
| 717 | { |
|---|
| 718 | if (buf[i] == ',') |
|---|
| 719 | buf[i] = 0; |
|---|
| 720 | } |
|---|
| 721 | websWrite (wp, buf); |
|---|
| 722 | return; |
|---|
| 723 | } |
|---|
| 724 | #endif |
|---|
| 725 | |
|---|
| 726 | void |
|---|
| 727 | ej_show_cpuinfo (webs_t wp, int argc, char_t ** argv) |
|---|
| 728 | { |
|---|
| 729 | FILE *fcpu = fopen ("/proc/cpuinfo", "r"); |
|---|
| 730 | if (fcpu == NULL) |
|---|
| 731 | { |
|---|
| 732 | websWrite (wp, "Not Detected!\n"); |
|---|
| 733 | return; |
|---|
| 734 | } |
|---|
| 735 | char buf[256]; |
|---|
| 736 | int i; |
|---|
| 737 | #ifdef HAVE_MAGICBOX |
|---|
| 738 | int cnt = 0; |
|---|
| 739 | #endif |
|---|
| 740 | #ifdef HAVE_X86 |
|---|
| 741 | int cnt = 0; |
|---|
| 742 | #endif |
|---|
| 743 | for (i = 0; i < 256; i++) |
|---|
| 744 | { |
|---|
| 745 | int c = getc (fcpu); |
|---|
| 746 | if (c == EOF) |
|---|
| 747 | { |
|---|
| 748 | websWrite (wp, "Not Detected!\n"); |
|---|
| 749 | fclose (fcpu); |
|---|
| 750 | return; |
|---|
| 751 | } |
|---|
| 752 | if (c == ':') |
|---|
| 753 | #ifdef HAVE_MAGICBOX |
|---|
| 754 | cnt++; |
|---|
| 755 | if (cnt == 2) |
|---|
| 756 | break; |
|---|
| 757 | #elif HAVE_X86 |
|---|
| 758 | cnt++; |
|---|
| 759 | if (cnt == 5) |
|---|
| 760 | break; |
|---|
| 761 | #else |
|---|
| 762 | break; |
|---|
| 763 | #endif |
|---|
| 764 | } |
|---|
| 765 | getc (fcpu); |
|---|
| 766 | for (i = 0; i < 256; i++) |
|---|
| 767 | { |
|---|
| 768 | int c = getc (fcpu); |
|---|
| 769 | if (c == EOF) |
|---|
| 770 | { |
|---|
| 771 | websWrite (wp, "Not Detected!\n"); |
|---|
| 772 | fclose (fcpu); |
|---|
| 773 | return; |
|---|
| 774 | } |
|---|
| 775 | if (c == 0xa || c == 0xd) |
|---|
| 776 | break; |
|---|
| 777 | buf[i] = c; |
|---|
| 778 | } |
|---|
| 779 | buf[i] = 0; |
|---|
| 780 | websWrite (wp, buf); |
|---|
| 781 | fclose (fcpu); |
|---|
| 782 | return; |
|---|
| 783 | } |
|---|
| 784 | |
|---|
| 785 | #define ASSOCLIST_TMP "/tmp/.wl_assoclist" |
|---|
| 786 | #define RSSI_TMP "/tmp/.rssi" |
|---|
| 787 | #define ASSOCLIST_CMD "wl assoclist" |
|---|
| 788 | #define RSSI_CMD "wl rssi" |
|---|
| 789 | #define NOISE_CMD "wl noise" |
|---|
| 790 | |
|---|
| 791 | |
|---|
| 792 | void |
|---|
| 793 | ej_show_wds_subnet (webs_t wp, int argc, char_t ** argv) |
|---|
| 794 | { |
|---|
| 795 | int index = -1; |
|---|
| 796 | char *interface; |
|---|
| 797 | #ifdef FASTWEB |
|---|
| 798 | ejArgs (argc, argv, "%d %s", &index, &interface); |
|---|
| 799 | #else |
|---|
| 800 | if (ejArgs (argc, argv, "%d %s", &index, &interface) < 2) |
|---|
| 801 | { |
|---|
| 802 | websError (wp, 400, "Insufficient args\n"); |
|---|
| 803 | return; |
|---|
| 804 | } |
|---|
| 805 | #endif |
|---|
| 806 | char br1[32]; |
|---|
| 807 | sprintf (br1, "%s_br1_enable", interface); |
|---|
| 808 | if (nvram_invmatch (br1, "1")) |
|---|
| 809 | return; |
|---|
| 810 | char buf[16]; |
|---|
| 811 | sprintf (buf, "%s_wds%d_enable", interface, index); |
|---|
| 812 | websWrite (wp, |
|---|
| 813 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"2\\\" %s >\" + wds.subnet + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 814 | nvram_selmatch (wp, buf, |
|---|
| 815 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 816 | return; |
|---|
| 817 | } |
|---|
| 818 | |
|---|
| 819 | |
|---|
| 820 | |
|---|
| 821 | #ifdef HAVE_SKYTRON |
|---|
| 822 | void |
|---|
| 823 | ej_active_wireless2 (webs_t wp, int argc, char_t ** argv) |
|---|
| 824 | { |
|---|
| 825 | int rssi = 0, noise = 0; |
|---|
| 826 | FILE *fp, *fp2; |
|---|
| 827 | char *mode; |
|---|
| 828 | char mac[30]; |
|---|
| 829 | char list[2][30]; |
|---|
| 830 | char line[80]; |
|---|
| 831 | |
|---|
| 832 | unlink (ASSOCLIST_TMP); |
|---|
| 833 | unlink (RSSI_TMP); |
|---|
| 834 | |
|---|
| 835 | mode = nvram_safe_get ("wl_mode"); |
|---|
| 836 | sysprintf ("%s > %s", ASSOCLIST_CMD, ASSOCLIST_TMP); |
|---|
| 837 | |
|---|
| 838 | int connected = 0; |
|---|
| 839 | if ((fp = fopen (ASSOCLIST_TMP, "r"))) |
|---|
| 840 | { |
|---|
| 841 | while (fgets (line, sizeof (line), fp) != NULL) |
|---|
| 842 | { |
|---|
| 843 | if (sscanf (line, "%s %s", list[0], mac) != 2) // assoclist 00:11:22:33:44:55 |
|---|
| 844 | continue; |
|---|
| 845 | |
|---|
| 846 | if (strcmp (list[0], "assoclist")) |
|---|
| 847 | break; |
|---|
| 848 | |
|---|
| 849 | rssi = 0; |
|---|
| 850 | noise = 0; |
|---|
| 851 | // get rssi value |
|---|
| 852 | if (strcmp (mode, "ap")) |
|---|
| 853 | sysprintf ("%s > %s", RSSI_CMD, RSSI_TMP); |
|---|
| 854 | else |
|---|
| 855 | sysprintf ("%s \"%s\" > %s", RSSI_CMD, mac, RSSI_TMP); |
|---|
| 856 | |
|---|
| 857 | // get noise value if not ap mode |
|---|
| 858 | if (strcmp (mode, "ap")) |
|---|
| 859 | sysprintf ("%s >> %s", NOISE_CMD, RSSI_TMP); |
|---|
| 860 | |
|---|
| 861 | |
|---|
| 862 | fp2 = fopen (RSSI_TMP, "r"); |
|---|
| 863 | if (fgets (line, sizeof (line), fp2) != NULL) |
|---|
| 864 | { |
|---|
| 865 | |
|---|
| 866 | // get rssi |
|---|
| 867 | if (sscanf (line, "%s %s %d", list[0], list[1], &rssi) != 3) |
|---|
| 868 | continue; |
|---|
| 869 | |
|---|
| 870 | // get noise for client/wet mode |
|---|
| 871 | if (strcmp (mode, "ap") && |
|---|
| 872 | fgets (line, sizeof (line), fp2) != NULL && |
|---|
| 873 | sscanf (line, "%s %s %d", list[0], list[1], &noise) != 3) |
|---|
| 874 | continue; |
|---|
| 875 | |
|---|
| 876 | fclose (fp2); |
|---|
| 877 | } |
|---|
| 878 | if (nvram_match ("maskmac", "1")) |
|---|
| 879 | { |
|---|
| 880 | mac[0] = 'x'; |
|---|
| 881 | mac[1] = 'x'; |
|---|
| 882 | mac[3] = 'x'; |
|---|
| 883 | mac[4] = 'x'; |
|---|
| 884 | mac[6] = 'x'; |
|---|
| 885 | mac[7] = 'x'; |
|---|
| 886 | mac[9] = 'x'; |
|---|
| 887 | mac[10] = 'x'; |
|---|
| 888 | } |
|---|
| 889 | if (strcmp (mode, "ap") != 0) |
|---|
| 890 | { |
|---|
| 891 | connected = 1; |
|---|
| 892 | websWrite (wp, "<tr>\n"); |
|---|
| 893 | websWrite (wp, |
|---|
| 894 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\"><b>Verbindungsstatus</b></font></td>\n"); |
|---|
| 895 | websWrite (wp, "<td bgcolor=\"#B2B2B2\"></td>\n"); |
|---|
| 896 | websWrite (wp, "<td bgcolor=\"#FFFFFF\"></td>\n"); |
|---|
| 897 | websWrite (wp, |
|---|
| 898 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Verbunden</font></td>\n"); |
|---|
| 899 | websWrite (wp, "</tr>\n"); |
|---|
| 900 | websWrite (wp, "<tr>\n"); |
|---|
| 901 | websWrite (wp, |
|---|
| 902 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Signal</font></td>\n"); |
|---|
| 903 | websWrite (wp, "<td bgcolor=\"#B2B2B2\"></td>\n"); |
|---|
| 904 | websWrite (wp, "<td bgcolor=\"#FFFFFF\"></td>\n"); |
|---|
| 905 | websWrite (wp, |
|---|
| 906 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">%d dBm</font></td>\n", |
|---|
| 907 | rssi); |
|---|
| 908 | websWrite (wp, "</tr>\n"); |
|---|
| 909 | websWrite (wp, "<tr>\n"); |
|---|
| 910 | websWrite (wp, |
|---|
| 911 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Rauschen</font></td>\n"); |
|---|
| 912 | websWrite (wp, "<td bgcolor=\"#B2B2B2\"></td>\n"); |
|---|
| 913 | websWrite (wp, "<td bgcolor=\"#FFFFFF\"></td>\n"); |
|---|
| 914 | websWrite (wp, |
|---|
| 915 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">%d dBm</font></td>\n", |
|---|
| 916 | noise); |
|---|
| 917 | websWrite (wp, "</tr>\n"); |
|---|
| 918 | } |
|---|
| 919 | } |
|---|
| 920 | fclose (fp); |
|---|
| 921 | } |
|---|
| 922 | |
|---|
| 923 | unlink (ASSOCLIST_TMP); |
|---|
| 924 | unlink (RSSI_TMP); |
|---|
| 925 | if (!connected) |
|---|
| 926 | { |
|---|
| 927 | connected = 1; |
|---|
| 928 | websWrite (wp, "<tr>\n"); |
|---|
| 929 | websWrite (wp, |
|---|
| 930 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\"><b>Verbindungsstatus</b></font></td>\n"); |
|---|
| 931 | websWrite (wp, "<td bgcolor=\"#B2B2B2\"></td>\n"); |
|---|
| 932 | websWrite (wp, "<td bgcolor=\"#FFFFFF\"></td>\n"); |
|---|
| 933 | websWrite (wp, |
|---|
| 934 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Nicht Verbunden</font></td>\n"); |
|---|
| 935 | websWrite (wp, "</tr>\n"); |
|---|
| 936 | |
|---|
| 937 | } |
|---|
| 938 | |
|---|
| 939 | return 0; |
|---|
| 940 | } |
|---|
| 941 | #endif |
|---|
| 942 | |
|---|
| 943 | |
|---|
| 944 | |
|---|
| 945 | |
|---|
| 946 | void |
|---|
| 947 | ej_show_paypal (webs_t wp, int argc, char_t ** argv) |
|---|
| 948 | { |
|---|
| 949 | #ifdef HAVE_DDLAN |
|---|
| 950 | websWrite (wp, |
|---|
| 951 | "<a href=\"mailto:support@mcdd.de\">support@mcdd.de</a><br />"); |
|---|
| 952 | #endif |
|---|
| 953 | |
|---|
| 954 | #ifndef CONFIG_BRANDING |
|---|
| 955 | websWrite (wp, "<a href=\"http://www.dd-wrt.com/\">DD-WRT</a><br />"); |
|---|
| 956 | websWrite (wp, |
|---|
| 957 | "<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\" target=\"_blank\">"); |
|---|
| 958 | websWrite (wp, "<input type=\"hidden\" name=\"cmd\" value=\"_xclick\" />"); |
|---|
| 959 | websWrite (wp, |
|---|
| 960 | "<input type=\"hidden\" name=\"business\" value=\"paypal@dd-wrt.com\" />"); |
|---|
| 961 | websWrite (wp, |
|---|
| 962 | "<input type=\"hidden\" name=\"item_name\" value=\"DD-WRT Development Support\" />"); |
|---|
| 963 | websWrite (wp, "<input type=\"hidden\" name=\"no_note\" value=\"1\" />"); |
|---|
| 964 | websWrite (wp, |
|---|
| 965 | "<input type=\"hidden\" name=\"currency_code\" value=\"EUR\" />"); |
|---|
| 966 | websWrite (wp, "<input type=\"hidden\" name=\"lc\" value=\"en\" />"); |
|---|
| 967 | websWrite (wp, "<input type=\"hidden\" name=\"tax\" value=\"0\" />"); |
|---|
| 968 | websWrite (wp, |
|---|
| 969 | "<input type=\"image\" src=\"images/paypal.gif\" name=\"submit\" />"); |
|---|
| 970 | websWrite (wp, "</form>"); |
|---|
| 971 | websWrite (wp, |
|---|
| 972 | "<br /><script type=\"text/javascript\">Capture(donate.mb)</script><br />\n"); |
|---|
| 973 | websWrite (wp, |
|---|
| 974 | "<a href=\"https://www.moneybookers.com/app/send.pl\" target=\"_blank\">\n"); |
|---|
| 975 | //#ifdef HAVE_MICRO |
|---|
| 976 | // websWrite (wp, |
|---|
| 977 | // "<img style=\"border-width: 1px; border-color: #8B8583;\" src=\"http://www.moneybookers.com/images/banners/88_en_interpayments.gif\" alt=\"donate thru moneybookers\" />\n"); |
|---|
| 978 | //#else |
|---|
| 979 | websWrite (wp, |
|---|
| 980 | "<img style=\"border-width: 1px; border-color: #8B8583;\" src=\"images/88_en_interpayments.png\" alt=\"donate thru interpayments\" />\n"); |
|---|
| 981 | //#endif |
|---|
| 982 | websWrite (wp, "</a>\n"); |
|---|
| 983 | #endif |
|---|
| 984 | return; |
|---|
| 985 | } |
|---|
| 986 | |
|---|
| 987 | |
|---|
| 988 | |
|---|
| 989 | #ifdef HAVE_RADLOCAL |
|---|
| 990 | |
|---|
| 991 | |
|---|
| 992 | void |
|---|
| 993 | ej_show_iradius_check (webs_t wp, int argc, char_t ** argv) |
|---|
| 994 | { |
|---|
| 995 | char *sln = nvram_safe_get ("iradius_count"); |
|---|
| 996 | if (sln == NULL || strlen (sln) == 0) |
|---|
| 997 | return; |
|---|
| 998 | int leasenum = atoi (sln); |
|---|
| 999 | int i; |
|---|
| 1000 | for (i = 0; i < leasenum; i++) |
|---|
| 1001 | { |
|---|
| 1002 | websWrite (wp, "if(F._iradius%d_active)\n", i); |
|---|
| 1003 | websWrite (wp, "if(F._iradius%d_active.checked == true)\n", i); |
|---|
| 1004 | websWrite (wp, "F.iradius%d_active.value=1\n", i); |
|---|
| 1005 | websWrite (wp, "else\n"); |
|---|
| 1006 | websWrite (wp, "F.iradius%d_active.value=0\n", i); |
|---|
| 1007 | |
|---|
| 1008 | websWrite (wp, "if(F._iradius%d_delete)\n", i); |
|---|
| 1009 | websWrite (wp, "if(F._iradius%d_delete.checked == true)\n", i); |
|---|
| 1010 | websWrite (wp, "F.iradius%d_delete.value=1\n", i); |
|---|
| 1011 | websWrite (wp, "else\n"); |
|---|
| 1012 | websWrite (wp, "F.iradius%d_delete.value=0\n", i); |
|---|
| 1013 | } |
|---|
| 1014 | |
|---|
| 1015 | |
|---|
| 1016 | } |
|---|
| 1017 | void |
|---|
| 1018 | ej_show_iradius (webs_t wp, int argc, char_t ** argv) |
|---|
| 1019 | { |
|---|
| 1020 | char *sln = nvram_safe_get ("iradius_count"); |
|---|
| 1021 | if (sln == NULL || strlen (sln) == 0) |
|---|
| 1022 | return; |
|---|
| 1023 | int leasenum = atoi (sln); |
|---|
| 1024 | if (leasenum == 0) |
|---|
| 1025 | return; |
|---|
| 1026 | int i; |
|---|
| 1027 | char username[32]; |
|---|
| 1028 | char *o, *userlist; |
|---|
| 1029 | cprintf ("get collection\n"); |
|---|
| 1030 | char *u = nvram_get_collection ("iradius"); |
|---|
| 1031 | cprintf ("collection result %s", u); |
|---|
| 1032 | if (u != NULL) |
|---|
| 1033 | { |
|---|
| 1034 | userlist = (char *) malloc (strlen (u) + 1); |
|---|
| 1035 | strcpy (userlist, u); |
|---|
| 1036 | free (u); |
|---|
| 1037 | o = userlist; |
|---|
| 1038 | } |
|---|
| 1039 | else |
|---|
| 1040 | { |
|---|
| 1041 | userlist = NULL; |
|---|
| 1042 | o = NULL; |
|---|
| 1043 | } |
|---|
| 1044 | cprintf ("display = chain\n"); |
|---|
| 1045 | struct timeval now; |
|---|
| 1046 | gettimeofday (&now, NULL); |
|---|
| 1047 | for (i = 0; i < leasenum; i++) |
|---|
| 1048 | { |
|---|
| 1049 | snprintf (username, 31, "iradius%d_name", i); |
|---|
| 1050 | char *sep = NULL; |
|---|
| 1051 | if (userlist) |
|---|
| 1052 | sep = strsep (&userlist, " "); |
|---|
| 1053 | websWrite (wp, "<tr><td>\n"); |
|---|
| 1054 | websWrite (wp, "<input name=\"%s\" type=\"hidden\" />", username); |
|---|
| 1055 | websWrite (wp, |
|---|
| 1056 | "<input name=\"%s\" value=\"%s\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 1057 | username, sep != NULL ? sep : ""); |
|---|
| 1058 | websWrite (wp, "</td>\n"); |
|---|
| 1059 | if (userlist) |
|---|
| 1060 | sep = strsep (&userlist, " "); |
|---|
| 1061 | |
|---|
| 1062 | char active[32]; |
|---|
| 1063 | snprintf (active, 31, "iradius%d_active", i); |
|---|
| 1064 | |
|---|
| 1065 | websWrite (wp, "<td>\n"); |
|---|
| 1066 | websWrite (wp, "<input name=\"%s\" type=\"hidden\" />", active); |
|---|
| 1067 | websWrite (wp, |
|---|
| 1068 | "<input type=\"checkbox\" value=\"%s\" name=\"_%s\" %s />\n", |
|---|
| 1069 | sep, active, sep != NULL ? strcmp (sep, |
|---|
| 1070 | "1") == |
|---|
| 1071 | 0 ? "checked=\"checked\"" : "" : ""); |
|---|
| 1072 | websWrite (wp, "</td>\n"); |
|---|
| 1073 | websWrite (wp, "<td>\n"); |
|---|
| 1074 | if (userlist) |
|---|
| 1075 | sep = strsep (&userlist, " "); |
|---|
| 1076 | long t = atol (sep); |
|---|
| 1077 | if (t != -1) |
|---|
| 1078 | { |
|---|
| 1079 | t -= now.tv_sec; |
|---|
| 1080 | t /= 60; |
|---|
| 1081 | } |
|---|
| 1082 | |
|---|
| 1083 | snprintf (active, 31, "iradius%d_lease", i); |
|---|
| 1084 | char st[32]; |
|---|
| 1085 | if (t >= 0) |
|---|
| 1086 | sprintf (st, "%d", t); |
|---|
| 1087 | else |
|---|
| 1088 | sprintf (st, "over"); |
|---|
| 1089 | websWrite (wp, "<input type=\"num\" name=\"%s\" value='%s' />\n", |
|---|
| 1090 | active, st); |
|---|
| 1091 | websWrite (wp, "</td>\n"); |
|---|
| 1092 | |
|---|
| 1093 | websWrite (wp, "<td>\n"); |
|---|
| 1094 | snprintf (active, 31, "iradius%d_delete", i); |
|---|
| 1095 | websWrite (wp, "<input name=\"%s\" type=\"hidden\" />", active); |
|---|
| 1096 | websWrite (wp, "<input type=\"checkbox\" name=\"_%s\"/>\n", active); |
|---|
| 1097 | websWrite (wp, "</td></tr>\n"); |
|---|
| 1098 | } |
|---|
| 1099 | if (o != NULL) |
|---|
| 1100 | free (o); |
|---|
| 1101 | return; |
|---|
| 1102 | } |
|---|
| 1103 | |
|---|
| 1104 | |
|---|
| 1105 | |
|---|
| 1106 | |
|---|
| 1107 | |
|---|
| 1108 | |
|---|
| 1109 | #endif |
|---|
| 1110 | |
|---|
| 1111 | #ifdef HAVE_CHILLILOCAL |
|---|
| 1112 | |
|---|
| 1113 | |
|---|
| 1114 | void |
|---|
| 1115 | ej_show_userlist (webs_t wp, int argc, char_t ** argv) |
|---|
| 1116 | { |
|---|
| 1117 | char *sln = nvram_safe_get ("fon_usernames"); |
|---|
| 1118 | if (sln == NULL || strlen (sln) == 0) |
|---|
| 1119 | return; |
|---|
| 1120 | int leasenum = atoi (sln); |
|---|
| 1121 | if (leasenum == 0) |
|---|
| 1122 | return; |
|---|
| 1123 | int i; |
|---|
| 1124 | char username[32]; |
|---|
| 1125 | char password[32]; |
|---|
| 1126 | char *u = nvram_safe_get ("fon_userlist"); |
|---|
| 1127 | char *userlist = (char *) malloc (strlen (u) + 1); |
|---|
| 1128 | strcpy (userlist, u); |
|---|
| 1129 | char *o = userlist; |
|---|
| 1130 | for (i = 0; i < leasenum; i++) |
|---|
| 1131 | { |
|---|
| 1132 | snprintf (username, 31, "fon_user%d_name", i); |
|---|
| 1133 | char *sep = strsep (&userlist, "="); |
|---|
| 1134 | websWrite (wp, "<tr><td>\n"); |
|---|
| 1135 | websWrite (wp, |
|---|
| 1136 | "<input name=\"%s\" value=\"%s\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 1137 | username, sep != NULL ? sep : ""); |
|---|
| 1138 | websWrite (wp, "</td>\n"); |
|---|
| 1139 | sep = strsep (&userlist, " "); |
|---|
| 1140 | snprintf (password, 31, "fon_user%d_password", i); |
|---|
| 1141 | websWrite (wp, "<td>\n"); |
|---|
| 1142 | websWrite (wp, |
|---|
| 1143 | "<input type=\"password\" name=\"%s\" value=\"blahblahblah\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 1144 | password); |
|---|
| 1145 | websWrite (wp, "</td></tr>\n"); |
|---|
| 1146 | } |
|---|
| 1147 | free (o); |
|---|
| 1148 | return; |
|---|
| 1149 | } |
|---|
| 1150 | |
|---|
| 1151 | |
|---|
| 1152 | |
|---|
| 1153 | |
|---|
| 1154 | #endif |
|---|
| 1155 | |
|---|
| 1156 | |
|---|
| 1157 | |
|---|
| 1158 | |
|---|
| 1159 | void |
|---|
| 1160 | ej_show_staticleases (webs_t wp, int argc, char_t ** argv) |
|---|
| 1161 | { |
|---|
| 1162 | int i; |
|---|
| 1163 | //cprintf("get static leasenum"); |
|---|
| 1164 | |
|---|
| 1165 | char *sln = nvram_safe_get ("static_leasenum"); |
|---|
| 1166 | //cprintf("check null"); |
|---|
| 1167 | if (sln == NULL || strlen (sln) == 0) |
|---|
| 1168 | return; |
|---|
| 1169 | //cprintf("atoi"); |
|---|
| 1170 | |
|---|
| 1171 | int leasenum = atoi (sln); |
|---|
| 1172 | //cprintf("leasenum==0"); |
|---|
| 1173 | if (leasenum == 0) |
|---|
| 1174 | return; |
|---|
| 1175 | //cprintf("get leases"); |
|---|
| 1176 | char *nvleases = nvram_safe_get ("static_leases"); |
|---|
| 1177 | char *leases = (char *) malloc (strlen (nvleases) + 1); |
|---|
| 1178 | char *originalpointer = leases; //strsep destroys the pointer by moving it |
|---|
| 1179 | strcpy (leases, nvleases); |
|---|
| 1180 | for (i = 0; i < leasenum; i++) |
|---|
| 1181 | { |
|---|
| 1182 | char *sep = strsep (&leases, "="); |
|---|
| 1183 | websWrite (wp, |
|---|
| 1184 | "<tr><td><input name=\"lease%d_hwaddr\" value=\"%s\" size=\"18\" maxlength=\"18\" onblur=\"valid_name(this,share.mac,SPACE_NO)\" /></td>", |
|---|
| 1185 | i, sep != NULL ? sep : ""); |
|---|
| 1186 | sep = strsep (&leases, "="); |
|---|
| 1187 | websWrite (wp, |
|---|
| 1188 | "<td><input name=\"lease%d_hostname\" value=\"%s\" size=\"24\" maxlength=\"24\" onblur=\"valid_name(this,share.hostname,SPACE_NO)\" /></td>", |
|---|
| 1189 | i, sep != NULL ? sep : ""); |
|---|
| 1190 | sep = strsep (&leases, " "); |
|---|
| 1191 | websWrite (wp, |
|---|
| 1192 | "<td><input name=\"lease%d_ip\" value=\"%s\" size=\"15\" maxlength=\"15\" class=\"num\" onblur=\"valid_name(this,share.ip,SPACE_NO)\" /></td></tr>\n", |
|---|
| 1193 | i, sep != NULL ? sep : ""); |
|---|
| 1194 | } |
|---|
| 1195 | free (originalpointer); |
|---|
| 1196 | return; |
|---|
| 1197 | } |
|---|
| 1198 | |
|---|
| 1199 | |
|---|
| 1200 | void |
|---|
| 1201 | ej_show_control (webs_t wp, int argc, char_t ** argv) |
|---|
| 1202 | { |
|---|
| 1203 | #ifdef CONFIG_BRANDING |
|---|
| 1204 | websWrite (wp, "Control Panel"); |
|---|
| 1205 | #else |
|---|
| 1206 | websWrite (wp, "DD-WRT Control Panel"); |
|---|
| 1207 | #endif |
|---|
| 1208 | return; |
|---|
| 1209 | } |
|---|
| 1210 | |
|---|
| 1211 | |
|---|
| 1212 | #ifndef HAVE_AQOS |
|---|
| 1213 | void |
|---|
| 1214 | ej_show_default_level (webs_t wp, int argc, char_t ** argv) |
|---|
| 1215 | { |
|---|
| 1216 | return; |
|---|
| 1217 | } |
|---|
| 1218 | |
|---|
| 1219 | #else |
|---|
| 1220 | void |
|---|
| 1221 | ej_show_default_level (webs_t wp, int argc, char_t ** argv) |
|---|
| 1222 | { |
|---|
| 1223 | websWrite (wp, "<fieldset>\n"); |
|---|
| 1224 | websWrite (wp, |
|---|
| 1225 | "<legend><script type=\"text/javascript\">Capture(qos.legend6)</script></legend>\n"); |
|---|
| 1226 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1227 | websWrite (wp, |
|---|
| 1228 | "<div class=\"label\"><script type=\"text/javascript\">Capture(qos.bandwidth)</script> Up</div>\n"); |
|---|
| 1229 | websWrite (wp, |
|---|
| 1230 | "<input type=\"num\" name=\"default_uplevel\" size=\"6\" value=\"%s\" /> Down\n", |
|---|
| 1231 | nvram_safe_get ("default_uplevel")); |
|---|
| 1232 | websWrite (wp, |
|---|
| 1233 | "<input type=\"num\" name=\"default_downlevel\" size=\"6\" value=\"%s\" />\n", |
|---|
| 1234 | nvram_safe_get ("default_downlevel")); |
|---|
| 1235 | websWrite (wp, "</div>\n"); |
|---|
| 1236 | websWrite (wp, "</fieldset><br />\n"); |
|---|
| 1237 | return; |
|---|
| 1238 | } |
|---|
| 1239 | #endif |
|---|
| 1240 | |
|---|
| 1241 | |
|---|
| 1242 | |
|---|
| 1243 | #ifndef HAVE_MSSID |
|---|
| 1244 | |
|---|
| 1245 | char * |
|---|
| 1246 | selmatch (char *var, char *is, char *ret) |
|---|
| 1247 | { |
|---|
| 1248 | if (nvram_match (var, is)) |
|---|
| 1249 | return ret; |
|---|
| 1250 | return ""; |
|---|
| 1251 | } |
|---|
| 1252 | |
|---|
| 1253 | void |
|---|
| 1254 | ej_show_security (webs_t wp, int argc, char_t ** argv) |
|---|
| 1255 | { |
|---|
| 1256 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1257 | websWrite (wp, |
|---|
| 1258 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.secmode)</script></div>\n"); |
|---|
| 1259 | websWrite (wp, |
|---|
| 1260 | "<select name=\"security_mode\" onchange=\"SelMode('security_mode',this.form.security_mode.selectedIndex,this.form)\">\n"); |
|---|
| 1261 | websWrite (wp, |
|---|
| 1262 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"disabled\\\" %s >\" + share.disabled + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 1263 | selmatch ("security_mode", "disabled", |
|---|
| 1264 | "selected=\\\"selected\\\"")); |
|---|
| 1265 | websWrite (wp, "<option value=\"psk\" %s>WPA Personal</option>\n", |
|---|
| 1266 | selmatch ("security_mode", "psk", "selected=\"selected\"")); |
|---|
| 1267 | websWrite (wp, "<option value=\"wpa\" %s>WPA Enterprise</option>\n", |
|---|
| 1268 | selmatch ("security_mode", "wpa", "selected=\"selected\"")); |
|---|
| 1269 | if (!nvram_match ("wl0_mode", "wet") && nvram_match ("wl_wds1_enable", "0") && nvram_match ("wl_wds2_enable", "0") && nvram_match ("wl_wds3_enable", "0") && nvram_match ("wl_wds4_enable", "0") && nvram_match ("wl_wds5_enable", "0") && nvram_match ("wl_wds6_enable", "0") && nvram_match ("wl_wds7_enable", "0") && nvram_match ("wl_wds8_enable", "0") && nvram_match ("wl_wds9_enable", "0") && nvram_match ("wl_wds10_enable", "0")) //botho 10/04/06 : if wireless client bridge mode selected or WDS activated => we don't display WPA2 security modes |
|---|
| 1270 | { |
|---|
| 1271 | websWrite (wp, |
|---|
| 1272 | "<option value=\"psk2\" %s>WPA2 Personal</option>\n", |
|---|
| 1273 | selmatch ("security_mode", "psk2", "selected")); |
|---|
| 1274 | websWrite (wp, "<option value=\"wpa2\" %s>WPA2 Enterprise</option>\n", |
|---|
| 1275 | selmatch ("security_mode", "wpa2", "selected=\"selected\"")); |
|---|
| 1276 | } |
|---|
| 1277 | websWrite (wp, |
|---|
| 1278 | "<option value=\"psk psk2\" %s>WPA2 Personal Mixed</option>\n", |
|---|
| 1279 | selmatch ("security_mode", "psk psk2", "selected")); |
|---|
| 1280 | websWrite (wp, |
|---|
| 1281 | "<option value=\"wpa wpa2\" %s>WPA2 Enterprise Mixed</option>\n", |
|---|
| 1282 | selmatch ("security_mode", "wpa wpa2", "selected=\"selected\"")); |
|---|
| 1283 | websWrite (wp, "<option value=\"radius\" %s>RADIUS</option>\n", |
|---|
| 1284 | selmatch ("security_mode", "radius", "selected=\"selected\"")); |
|---|
| 1285 | websWrite (wp, "<option value=\"wep\" %s>WEP</option></select>\n", |
|---|
| 1286 | selmatch ("security_mode", "wep", "selected=\"selected\"")); |
|---|
| 1287 | websWrite (wp, "</div>\n"); |
|---|
| 1288 | ej_show_wpa_setting (wp, argc, argv); |
|---|
| 1289 | return; |
|---|
| 1290 | } |
|---|
| 1291 | #else |
|---|
| 1292 | #ifdef HAVE_MADWIFI |
|---|
| 1293 | struct wifi_channels |
|---|
| 1294 | { |
|---|
| 1295 | int channel; |
|---|
| 1296 | int freq; |
|---|
| 1297 | int noise}; |
|---|
| 1298 | extern struct wifi_channels *list_channels (char *devnr); |
|---|
| 1299 | //extern int getchannelcount (void); |
|---|
| 1300 | extern int getdevicecount (void); |
|---|
| 1301 | #endif |
|---|
| 1302 | |
|---|
| 1303 | |
|---|
| 1304 | |
|---|
| 1305 | char * |
|---|
| 1306 | selmatch (char *var, char *is, char *ret) |
|---|
| 1307 | { |
|---|
| 1308 | if (nvram_match (var, is)) |
|---|
| 1309 | return ret; |
|---|
| 1310 | return ""; |
|---|
| 1311 | } |
|---|
| 1312 | |
|---|
| 1313 | static void |
|---|
| 1314 | show_security_prefix (webs_t wp, int argc, char_t ** argv, char *prefix, |
|---|
| 1315 | int primary) |
|---|
| 1316 | { |
|---|
| 1317 | char var[80]; |
|---|
| 1318 | char sta[80]; |
|---|
| 1319 | //char p2[80]; |
|---|
| 1320 | cprintf ("show security prefix\n"); |
|---|
| 1321 | sprintf (var, "%s_security_mode", prefix); |
|---|
| 1322 | //strcpy(p2,prefix); |
|---|
| 1323 | //rep(p2,'X','.'); |
|---|
| 1324 | //websWrite (wp, "<input type=\"hidden\" name=\"%s_security_mode\"/>\n",p2); |
|---|
| 1325 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1326 | websWrite (wp, |
|---|
| 1327 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.secmode)</script></div>\n"); |
|---|
| 1328 | websWrite (wp, |
|---|
| 1329 | "<select name=\"%s_security_mode\" onchange=\"SelMode('%s_security_mode',this.form.%s_security_mode.selectedIndex,this.form)\">\n", |
|---|
| 1330 | prefix, prefix, prefix); |
|---|
| 1331 | websWrite (wp, |
|---|
| 1332 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"disabled\\\" %s >\" + share.disabled + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 1333 | selmatch (var, "disabled", "selected=\\\"selected\\\"")); |
|---|
| 1334 | websWrite (wp, "<option value=\"psk\" %s>WPA Personal</option>\n", |
|---|
| 1335 | selmatch (var, "psk", "selected=\"selected\"")); |
|---|
| 1336 | sprintf (sta, "%s_mode", prefix); |
|---|
| 1337 | if (!primary || nvram_match (sta, "ap") || nvram_match (sta, "wdsap")) |
|---|
| 1338 | { |
|---|
| 1339 | websWrite (wp, "<option value=\"wpa\" %s>WPA Enterprise</option>\n", |
|---|
| 1340 | selmatch (var, "wpa", "selected=\"selected\"")); |
|---|
| 1341 | } |
|---|
| 1342 | websWrite (wp, |
|---|
| 1343 | "<option value=\"psk2\" %s>WPA2 Personal</option>\n", |
|---|
| 1344 | selmatch (var, "psk2", "selected=\"selected\"")); |
|---|
| 1345 | if (!primary || nvram_match (sta, "ap") || nvram_match (sta, "wdsap")) |
|---|
| 1346 | { |
|---|
| 1347 | websWrite (wp, "<option value=\"wpa2\" %s>WPA2 Enterprise</option>\n", |
|---|
| 1348 | selmatch (var, "wpa2", "selected=\"selected\"")); |
|---|
| 1349 | } |
|---|
| 1350 | websWrite (wp, |
|---|
| 1351 | "<option value=\"psk psk2\" %s>WPA2 Personal Mixed</option>\n", |
|---|
| 1352 | selmatch (var, "psk psk2", "selected=\"selected\"")); |
|---|
| 1353 | if (!primary || nvram_match (sta, "ap") || nvram_match (sta, "wdsap")) |
|---|
| 1354 | { |
|---|
| 1355 | websWrite (wp, |
|---|
| 1356 | "<option value=\"wpa wpa2\" %s>WPA2 Enterprise Mixed</option>\n", |
|---|
| 1357 | selmatch (var, "wpa wpa2", "selected=\"selected\"")); |
|---|
| 1358 | |
|---|
| 1359 | websWrite (wp, "<option value=\"radius\" %s>RADIUS</option>\n", |
|---|
| 1360 | selmatch (var, "radius", "selected=\"selected\"")); |
|---|
| 1361 | } |
|---|
| 1362 | |
|---|
| 1363 | websWrite (wp, "<option value=\"wep\" %s>WEP</option>\n", |
|---|
| 1364 | selmatch (var, "wep", "selected=\"selected\"")); |
|---|
| 1365 | #ifdef HAVE_WPA_SUPPLICANT |
|---|
| 1366 | if (!primary || nvram_match (sta, "sta") || nvram_match (sta, "wdssta") |
|---|
| 1367 | || nvram_match (sta, "apsta") || nvram_match (sta, "wet")) |
|---|
| 1368 | { |
|---|
| 1369 | websWrite (wp, "<option value=\"8021X\" %s>802.1x</option>\n", |
|---|
| 1370 | selmatch (var, "8021X", "selected=\"selected\"")); |
|---|
| 1371 | } |
|---|
| 1372 | #endif |
|---|
| 1373 | |
|---|
| 1374 | websWrite (wp, "</select></div>\n"); |
|---|
| 1375 | rep (prefix, 'X', '.'); |
|---|
| 1376 | cprintf ("ej show wpa\n"); |
|---|
| 1377 | ej_show_wpa_setting (wp, argc, argv, prefix); |
|---|
| 1378 | |
|---|
| 1379 | } |
|---|
| 1380 | |
|---|
| 1381 | static void |
|---|
| 1382 | ej_show_security_single (webs_t wp, int argc, char_t ** argv, char *prefix) |
|---|
| 1383 | { |
|---|
| 1384 | char *next; |
|---|
| 1385 | char var[80]; |
|---|
| 1386 | char ssid[80]; |
|---|
| 1387 | char mac[16]; |
|---|
| 1388 | sprintf (mac, "%s_hwaddr", prefix); |
|---|
| 1389 | char *vifs = nvram_nget ("%s_vifs", prefix); |
|---|
| 1390 | if (vifs == NULL) |
|---|
| 1391 | return; |
|---|
| 1392 | sprintf (ssid, "%s_ssid", prefix); |
|---|
| 1393 | websWrite (wp, |
|---|
| 1394 | "<h2><script type=\"text/javascript\">Capture(wpa.h2)</script> %s</h2>\n", |
|---|
| 1395 | prefix); |
|---|
| 1396 | websWrite (wp, "<fieldset>\n"); |
|---|
| 1397 | //cprintf("getting %s %s\n",ssid,nvram_safe_get(ssid)); |
|---|
| 1398 | websWrite (wp, |
|---|
| 1399 | "<legend><script type=\"text/javascript\">Capture(share.pintrface)</script> %s SSID [", |
|---|
| 1400 | prefix); |
|---|
| 1401 | tf_webWriteESCNV (wp, ssid); //fix for broken html page if ssid contains html tag |
|---|
| 1402 | websWrite (wp, "] HWAddr [%s]</legend>\n", nvram_safe_get (mac)); |
|---|
| 1403 | show_security_prefix (wp, argc, argv, prefix, 1); |
|---|
| 1404 | websWrite (wp, "</fieldset>\n<br />\n"); |
|---|
| 1405 | foreach (var, vifs, next) |
|---|
| 1406 | { |
|---|
| 1407 | sprintf (ssid, "%s_ssid", var); |
|---|
| 1408 | websWrite (wp, "<fieldset>\n"); |
|---|
| 1409 | //cprintf("getting %s %s\n", ssid,nvram_safe_get(ssid)); |
|---|
| 1410 | websWrite (wp, |
|---|
| 1411 | "<legend><script type=\"text/javascript\">Capture(share.vintrface)</script> %s SSID [", |
|---|
| 1412 | var); |
|---|
| 1413 | tf_webWriteESCNV (wp, ssid); //fix for broken html page if ssid contains html tag |
|---|
| 1414 | websWrite (wp, "]</legend>\n"); |
|---|
| 1415 | rep (var, '.', 'X'); |
|---|
| 1416 | show_security_prefix (wp, argc, argv, var, 0); |
|---|
| 1417 | websWrite (wp, "</fieldset>\n<br />\n"); |
|---|
| 1418 | } |
|---|
| 1419 | |
|---|
| 1420 | } |
|---|
| 1421 | |
|---|
| 1422 | void |
|---|
| 1423 | ej_show_security (webs_t wp, int argc, char_t ** argv) |
|---|
| 1424 | { |
|---|
| 1425 | #ifndef HAVE_MADWIFI |
|---|
| 1426 | int c = get_wl_instances (); |
|---|
| 1427 | int i; |
|---|
| 1428 | for (i = 0; i < c; i++) |
|---|
| 1429 | { |
|---|
| 1430 | char buf[16]; |
|---|
| 1431 | sprintf (buf, "wl%d", i); |
|---|
| 1432 | ej_show_security_single (wp, argc, argv, buf); |
|---|
| 1433 | } |
|---|
| 1434 | return; |
|---|
| 1435 | #else |
|---|
| 1436 | int c = getdevicecount (); |
|---|
| 1437 | int i; |
|---|
| 1438 | for (i = 0; i < c; i++) |
|---|
| 1439 | { |
|---|
| 1440 | char buf[16]; |
|---|
| 1441 | sprintf (buf, "ath%d", i); |
|---|
| 1442 | ej_show_security_single (wp, argc, argv, buf); |
|---|
| 1443 | } |
|---|
| 1444 | return; |
|---|
| 1445 | #endif |
|---|
| 1446 | } |
|---|
| 1447 | |
|---|
| 1448 | #endif |
|---|
| 1449 | |
|---|
| 1450 | |
|---|
| 1451 | |
|---|
| 1452 | |
|---|
| 1453 | |
|---|
| 1454 | void |
|---|
| 1455 | ej_show_dhcpd_settings (webs_t wp, int argc, char_t ** argv) |
|---|
| 1456 | { |
|---|
| 1457 | int i; |
|---|
| 1458 | if (nvram_match ("wl0_mode", "wet")) //dhcpd settings disabled in client bridge mode, so we wont display it |
|---|
| 1459 | return; |
|---|
| 1460 | if (nvram_match ("wl0_mode", "apstawet")) //dhcpd settings disabled in client bridge mode, so we wont display it |
|---|
| 1461 | return; |
|---|
| 1462 | websWrite (wp, |
|---|
| 1463 | "<fieldset><legend><script type=\"text/javascript\">Capture(idx.dhcp_legend)</script></legend>\n"); |
|---|
| 1464 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1465 | websWrite (wp, |
|---|
| 1466 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_type)</script></div>\n"); |
|---|
| 1467 | websWrite (wp, |
|---|
| 1468 | "<select class=\"num\" size=\"1\" name=\"dhcpfwd_enable\" onchange=SelDHCPFWD(this.form.dhcpfwd_enable.selectedIndex,this.form)>\n"); |
|---|
| 1469 | websWrite (wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1470 | websWrite (wp, |
|---|
| 1471 | "document.write(\"<option value=\\\"0\\\" %s >\" + idx.dhcp_srv + \"</option>\");\n", |
|---|
| 1472 | nvram_match ("dhcpfwd_enable", |
|---|
| 1473 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1474 | websWrite (wp, |
|---|
| 1475 | "document.write(\"<option value=\\\"1\\\" %s >\" + idx.dhcp_fwd + \"</option>\");\n", |
|---|
| 1476 | nvram_match ("dhcpfwd_enable", |
|---|
| 1477 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1478 | websWrite (wp, "//]]>\n</script>\n"); |
|---|
| 1479 | websWrite (wp, "</select>\n"); |
|---|
| 1480 | websWrite (wp, "</div>\n"); |
|---|
| 1481 | if (nvram_match ("dhcpfwd_enable", "1")) |
|---|
| 1482 | { |
|---|
| 1483 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1484 | websWrite (wp, |
|---|
| 1485 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_srv)</script></div>\n"); |
|---|
| 1486 | char *ipfwd = nvram_safe_get ("dhcpfwd_ip"); |
|---|
| 1487 | websWrite (wp, |
|---|
| 1488 | "<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", |
|---|
| 1489 | get_single_ip (ipfwd, 0), get_single_ip (ipfwd, 1), |
|---|
| 1490 | get_single_ip (ipfwd, 2), get_single_ip (ipfwd, 3)); |
|---|
| 1491 | } |
|---|
| 1492 | else |
|---|
| 1493 | { |
|---|
| 1494 | char buf[20]; |
|---|
| 1495 | prefix_ip_get ("lan_ipaddr", buf, 1); |
|---|
| 1496 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1497 | // char *nv = nvram_safe_get ("wan_wins"); |
|---|
| 1498 | websWrite (wp, |
|---|
| 1499 | "<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", |
|---|
| 1500 | nvram_match ("lan_proto", |
|---|
| 1501 | "dhcp") ? "checked=\"checked\"" : ""); |
|---|
| 1502 | websWrite (wp, |
|---|
| 1503 | "<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", |
|---|
| 1504 | nvram_match ("lan_proto", |
|---|
| 1505 | "static") ? "checked=\"checked\"" : ""); |
|---|
| 1506 | websWrite (wp, |
|---|
| 1507 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_start)</script></div>%s", |
|---|
| 1508 | buf); |
|---|
| 1509 | websWrite (wp, |
|---|
| 1510 | "<input class=\"num\" name=\"dhcp_start\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,1,254,idx.dhcp_start)\" value=\"%s\" />", |
|---|
| 1511 | nvram_safe_get ("dhcp_start")); |
|---|
| 1512 | websWrite (wp, "</div>\n"); |
|---|
| 1513 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1514 | websWrite (wp, |
|---|
| 1515 | "<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", |
|---|
| 1516 | nvram_safe_get ("dhcp_num")); |
|---|
| 1517 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1518 | websWrite (wp, |
|---|
| 1519 | "<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", |
|---|
| 1520 | nvram_safe_get ("dhcp_lease")); |
|---|
| 1521 | if (nvram_invmatch ("wan_proto", "static")) |
|---|
| 1522 | { |
|---|
| 1523 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1524 | websWrite (wp, |
|---|
| 1525 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 1</div>"); |
|---|
| 1526 | websWrite (wp, |
|---|
| 1527 | "<input type=\"hidden\" name=\"wan_dns\" value=\"4\" />"); |
|---|
| 1528 | for (i = 0; i < 4; i++) |
|---|
| 1529 | websWrite (wp, |
|---|
| 1530 | "<input class=\"num\" name=\"wan_dns0_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1531 | i, i == 3 ? 254 : 255, get_dns_ip ("wan_dns", 0, i), |
|---|
| 1532 | i < 3 ? "." : ""); |
|---|
| 1533 | |
|---|
| 1534 | websWrite (wp, "\n</div>\n<div class=\"setting\">\n"); |
|---|
| 1535 | websWrite (wp, |
|---|
| 1536 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 2</div>"); |
|---|
| 1537 | for (i = 0; i < 4; i++) |
|---|
| 1538 | websWrite (wp, |
|---|
| 1539 | "<input class=\"num\" name=\"wan_dns1_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1540 | i, i == 3 ? 254 : 255, get_dns_ip ("wan_dns", 1, i), |
|---|
| 1541 | i < 3 ? "." : ""); |
|---|
| 1542 | |
|---|
| 1543 | websWrite (wp, "\n</div>\n<div class=\"setting\">\n"); |
|---|
| 1544 | websWrite (wp, |
|---|
| 1545 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 3</div>"); |
|---|
| 1546 | for (i = 0; i < 4; i++) |
|---|
| 1547 | websWrite (wp, |
|---|
| 1548 | "<input class=\"num\" name=\"wan_dns2_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1549 | i, i == 3 ? 254 : 255, get_dns_ip ("wan_dns", 2, i), |
|---|
| 1550 | i < 3 ? "." : ""); |
|---|
| 1551 | websWrite (wp, "\n</div>"); |
|---|
| 1552 | } |
|---|
| 1553 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1554 | websWrite (wp, "<div class=\"label\">WINS</div>\n"); |
|---|
| 1555 | websWrite (wp, |
|---|
| 1556 | "<input type=\"hidden\" name=\"wan_wins\" value=\"4\" />\n"); |
|---|
| 1557 | char *wins = nvram_safe_get ("wan_wins"); |
|---|
| 1558 | for (i = 0; i < 4; i++) |
|---|
| 1559 | { |
|---|
| 1560 | websWrite (wp, |
|---|
| 1561 | "<input class=\"num\" name=\"wan_wins_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,"WINS")\" value=\"%d\" />%s", |
|---|
| 1562 | i, i == 3 ? 254 : 255, get_single_ip (wins, i), |
|---|
| 1563 | i < 3 ? "." : ""); |
|---|
| 1564 | } |
|---|
| 1565 | |
|---|
| 1566 | websWrite (wp, "</div>\n<div class=\"setting\">\n"); |
|---|
| 1567 | websWrite (wp, |
|---|
| 1568 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_dnsmasq)</script></div>\n"); |
|---|
| 1569 | websWrite (wp, |
|---|
| 1570 | "<input type=\"checkbox\" name=\"_dhcp_dnsmasq\" value=\"1\" onclick=\"setDNSMasq(this.form)\" %s />\n", |
|---|
| 1571 | nvram_match ("dhcp_dnsmasq", |
|---|
| 1572 | "1") ? "checked=\"checked\"" : ""); |
|---|
| 1573 | websWrite (wp, "</div>\n<div class=\"setting\">\n"); |
|---|
| 1574 | websWrite (wp, |
|---|
| 1575 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dns_dnsmasq)</script></div>\n"); |
|---|
| 1576 | websWrite (wp, |
|---|
| 1577 | "<input type=\"checkbox\" name=\"_dns_dnsmasq\" value=\"1\" %s />\n", |
|---|
| 1578 | nvram_match ("dns_dnsmasq", |
|---|
| 1579 | "1") ? "checked=\"checked\"" : ""); |
|---|
| 1580 | websWrite (wp, "</div>\n<div class=\"setting\">\n"); |
|---|
| 1581 | websWrite (wp, |
|---|
| 1582 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.auth_dnsmasq)</script></div>\n"); |
|---|
| 1583 | websWrite (wp, |
|---|
| 1584 | "<input type=\"checkbox\" name=\"_auth_dnsmasq\" value=\"1\" %s />\n", |
|---|
| 1585 | nvram_match ("auth_dnsmasq", |
|---|
| 1586 | "1") ? "checked=\"checked\"" : ""); |
|---|
| 1587 | websWrite (wp, "</div>\n"); |
|---|
| 1588 | } |
|---|
| 1589 | |
|---|
| 1590 | websWrite (wp, "</fieldset><br />\n"); |
|---|
| 1591 | return; |
|---|
| 1592 | } |
|---|
| 1593 | |
|---|
| 1594 | |
|---|
| 1595 | |
|---|
| 1596 | #ifdef HAVE_MADWIFI |
|---|
| 1597 | void |
|---|
| 1598 | ej_show_wifiselect (webs_t wp, int argc, char_t ** argv) |
|---|
| 1599 | { |
|---|
| 1600 | char *next; |
|---|
| 1601 | char var[32]; |
|---|
| 1602 | int count = getifcount ("wifi"); |
|---|
| 1603 | if (count < 2) |
|---|
| 1604 | return; |
|---|
| 1605 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1606 | websWrite (wp, |
|---|
| 1607 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.intrface)</script></div>\n"); |
|---|
| 1608 | websWrite (wp, |
|---|
| 1609 | "<select name=\"wifi_display\" onchange=\"refresh(this.form)\">\n"); |
|---|
| 1610 | int i; |
|---|
| 1611 | for (i = 0; i < count; i++) |
|---|
| 1612 | { |
|---|
| 1613 | sprintf (var, "ath%d", i); |
|---|
| 1614 | websWrite (wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 1615 | var, nvram_match ("wifi_display", |
|---|
| 1616 | var) ? "selected=\"selected\"" : "", var); |
|---|
| 1617 | char *names = nvram_nget ("ath%d_vifs", i); |
|---|
| 1618 | foreach (var, names, next) |
|---|
| 1619 | { |
|---|
| 1620 | websWrite (wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 1621 | var, nvram_match ("wifi_display", |
|---|
| 1622 | var) ? "selected=\"selected\"" : "", |
|---|
| 1623 | var); |
|---|
| 1624 | } |
|---|
| 1625 | } |
|---|
| 1626 | websWrite (wp, "</select>\n"); |
|---|
| 1627 | websWrite (wp, "</div>\n"); |
|---|
| 1628 | |
|---|
| 1629 | } |
|---|
| 1630 | #else |
|---|
| 1631 | void |
|---|
| 1632 | ej_show_wifiselect (webs_t wp, int argc, char_t ** argv) |
|---|
| 1633 | { |
|---|
| 1634 | //nothing for now |
|---|
| 1635 | } |
|---|
| 1636 | |
|---|
| 1637 | |
|---|
| 1638 | #endif |
|---|
| 1639 | static void |
|---|
| 1640 | showOption (webs_t wp, char *propname, char *nvname) |
|---|
| 1641 | { |
|---|
| 1642 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1643 | websWrite (wp, |
|---|
| 1644 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n<select name=\"%s\">\n", |
|---|
| 1645 | propname, nvname); |
|---|
| 1646 | websWrite (wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1647 | websWrite (wp, |
|---|
| 1648 | "document.write(\"<option value=\\\"0\\\" %s >\" + share.disabled + \"</option>\");\n", |
|---|
| 1649 | nvram_default_match (nvname, "0", |
|---|
| 1650 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1651 | websWrite (wp, |
|---|
| 1652 | "document.write(\"<option value=\\\"1\\\" %s >\" + share.enabled + \"</option>\");\n", |
|---|
| 1653 | nvram_default_match (nvname, "1", |
|---|
| 1654 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1655 | websWrite (wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 1656 | |
|---|
| 1657 | } |
|---|
| 1658 | |
|---|
| 1659 | static void |
|---|
| 1660 | showRadio (webs_t wp, char *propname, char *nvname) |
|---|
| 1661 | { |
|---|
| 1662 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1663 | websWrite (wp, |
|---|
| 1664 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n", |
|---|
| 1665 | propname); |
|---|
| 1666 | websWrite (wp, |
|---|
| 1667 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input> \n", |
|---|
| 1668 | nvname, nvram_default_match (nvname, "0", |
|---|
| 1669 | "0") ? "checked=\"checked\"" : ""); |
|---|
| 1670 | websWrite (wp, |
|---|
| 1671 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input> \n", |
|---|
| 1672 | nvname, nvram_default_match (nvname, "1", |
|---|
| 1673 | "0") ? "checked=\"checked\"" : ""); |
|---|
| 1674 | websWrite (wp, "</div>\n"); |
|---|
| 1675 | } |
|---|
| 1676 | |
|---|
| 1677 | static void |
|---|
| 1678 | showAutoOption (webs_t wp, char *propname, char *nvname) |
|---|
| 1679 | { |
|---|
| 1680 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1681 | websWrite (wp, |
|---|
| 1682 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n<select name=\"%s\">\n", |
|---|
| 1683 | propname, nvname); |
|---|
| 1684 | websWrite (wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1685 | websWrite (wp, |
|---|
| 1686 | "document.write(\"<option value=\\\"-1\\\" %s >\" + share.auto + \"</option>\");\n", |
|---|
| 1687 | nvram_default_match (nvname, "0", |
|---|
| 1688 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1689 | websWrite (wp, |
|---|
| 1690 | "document.write(\"<option value=\\\"1\\\" %s >\" + share.enabled + \"</option>\");\n", |
|---|
| 1691 | nvram_default_match (nvname, "1", |
|---|
| 1692 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1693 | websWrite (wp, |
|---|
| 1694 | "document.write(\"<option value=\\\"0\\\" %s >\" + share.disabled + \"</option>\");\n", |
|---|
| 1695 | nvram_default_match (nvname, "0", |
|---|
| 1696 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1697 | websWrite (wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 1698 | |
|---|
| 1699 | } |
|---|
| 1700 | |
|---|
| 1701 | static void |
|---|
| 1702 | showOptions (webs_t wp, char *propname, char *names, char *select) |
|---|
| 1703 | { |
|---|
| 1704 | char *next; |
|---|
| 1705 | char var[80]; |
|---|
| 1706 | websWrite (wp, "<select name=\"%s\">\n", propname); |
|---|
| 1707 | websWrite (wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1708 | foreach (var, names, next) |
|---|
| 1709 | { |
|---|
| 1710 | websWrite (wp, |
|---|
| 1711 | "document.write(\"<option value=\\\"%s\\\" %s >%s</option>\");\n", |
|---|
| 1712 | var, !strcmp (var, select) ? "selected=\\\"selected\\\"" : "", |
|---|
| 1713 | var); |
|---|
| 1714 | } |
|---|
| 1715 | websWrite (wp, "//]]>\n</script>\n</select>\n"); |
|---|
| 1716 | } |
|---|
| 1717 | |
|---|
| 1718 | static void |
|---|
| 1719 | showOptionsChoose (webs_t wp, char *propname, char *names, char *select) |
|---|
| 1720 | { |
|---|
| 1721 | char *next; |
|---|
| 1722 | char var[80]; |
|---|
| 1723 | websWrite (wp, "<select name=\"%s\">\n", propname); |
|---|
| 1724 | websWrite (wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1725 | websWrite (wp, |
|---|
| 1726 | "document.write(\"<option value=\\\"null\\\" >Please choose...</option>\");\n"); |
|---|
| 1727 | foreach (var, names, next) |
|---|
| 1728 | { |
|---|
| 1729 | websWrite (wp, |
|---|
| 1730 | "document.write(\"<option value=\\\"%s\\\" %s >%s</option>\");\n", |
|---|
| 1731 | var, !strcmp (var, select) ? "selected=\\\"selected\\\"" : "", |
|---|
| 1732 | var); |
|---|
| 1733 | } |
|---|
| 1734 | websWrite (wp, "//]]>\n</script>\n</select>\n"); |
|---|
| 1735 | } |
|---|
| 1736 | |
|---|
| 1737 | static void |
|---|
| 1738 | showOptionsLabel (webs_t wp, char *labelname, char *propname, char *names, |
|---|
| 1739 | char *select) |
|---|
| 1740 | { |
|---|
| 1741 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1742 | websWrite (wp, |
|---|
| 1743 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>", |
|---|
| 1744 | labelname); |
|---|
| 1745 | showOptions (wp, propname, names, select); |
|---|
| 1746 | websWrite (wp, "</div>\n"); |
|---|
| 1747 | |
|---|
| 1748 | } |
|---|
| 1749 | |
|---|
| 1750 | void |
|---|
| 1751 | show_inputlabel (webs_t wp, char *labelname, char *propertyname, |
|---|
| 1752 | int propertysize, char *inputclassname, int inputmaxlength) |
|---|
| 1753 | { |
|---|
| 1754 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1755 | websWrite (wp, |
|---|
| 1756 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>", |
|---|
| 1757 | labelname); |
|---|
| 1758 | websWrite (wp, |
|---|
| 1759 | "<input class=\"%s\" size=\"%d\" maxlength=\"%d\" name=\"%s\" value=\"%s\" />\n", |
|---|
| 1760 | inputclassname, propertysize, inputmaxlength, propertyname, |
|---|
| 1761 | nvram_safe_get (propertyname)); |
|---|
| 1762 | websWrite (wp, "</div>\n"); |
|---|
| 1763 | } |
|---|
| 1764 | |
|---|
| 1765 | void |
|---|
| 1766 | show_custominputlabel (webs_t wp, char *labelname, char *propertyname, |
|---|
| 1767 | char *property, int propertysize) |
|---|
| 1768 | { |
|---|
| 1769 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1770 | websWrite (wp, "<div class=\"label\">%s</div>", labelname); |
|---|
| 1771 | websWrite (wp, "<input size=\"%d\" name=\"%s\" value=\"%s\" />\n", |
|---|
| 1772 | propertysize, propertyname, property); |
|---|
| 1773 | websWrite (wp, "</div>\n"); |
|---|
| 1774 | } |
|---|
| 1775 | |
|---|
| 1776 | void |
|---|
| 1777 | show_legend (webs_t wp, char *labelname, int translate) |
|---|
| 1778 | { |
|---|
| 1779 | /* char buf[2]; |
|---|
| 1780 | sprintf(buf,"%d",translate); |
|---|
| 1781 | websWrite (wp, "<legend>%s%s%s</legend>\n", |
|---|
| 1782 | !strcmp (buf, "1") ? "<script type=\"text/javascript\">Capture(" : "", labelname, !strcmp (buf, "1") ? ")</script>" : ""); |
|---|
| 1783 | */ |
|---|
| 1784 | if (translate) |
|---|
| 1785 | websWrite (wp, |
|---|
| 1786 | "<legend><script type=\"text/javascript\">Capture(%s)</script></legend>\n", |
|---|
| 1787 | labelname); |
|---|
| 1788 | else |
|---|
| 1789 | websWrite (wp, "<legend>%s</legend>\n", labelname); |
|---|
| 1790 | |
|---|
| 1791 | } |
|---|
| 1792 | |
|---|
| 1793 | |
|---|
| 1794 | #ifdef HAVE_OLSRD |
|---|
| 1795 | |
|---|
| 1796 | void |
|---|
| 1797 | ej_show_olsrd (webs_t wp, int argc, char_t ** argv) |
|---|
| 1798 | { |
|---|
| 1799 | char *var = websGetVar (wp, "wk_mode", NULL); |
|---|
| 1800 | if (var == NULL) |
|---|
| 1801 | var = nvram_safe_get ("wk_mode"); |
|---|
| 1802 | if (!strcmp (var, "olsr")) |
|---|
| 1803 | { |
|---|
| 1804 | websWrite (wp, "<fieldset>\n"); |
|---|
| 1805 | show_legend (wp, "route.olsrd_legend", 1); |
|---|
| 1806 | show_inputlabel (wp, "route.olsrd_hna", "olsrd_hna", 32, "num", 32); |
|---|
| 1807 | show_inputlabel (wp, "route.olsrd_poll", "olsrd_pollsize", 5, "num", 5); |
|---|
| 1808 | showOptionsLabel (wp, "route.olsrd_tc", "olsrd_redundancy", |
|---|
| 1809 | "0 1 2", nvram_default_get ("olsrd_redundancy", "2")); |
|---|
| 1810 | show_inputlabel (wp, "route.olsrd_mpr", "olsrd_coverage", 5, "num", 5); |
|---|
| 1811 | showOption (wp, "route.olsrd_lqfe", "olsrd_lqfisheye"); |
|---|
| 1812 | show_inputlabel (wp, "route.olsrd_lqag", "olsrd_lqaging", 5, "num", 5); |
|---|
| 1813 | |
|---|
| 1814 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1815 | websWrite (wp, |
|---|
| 1816 | "<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_lqdmin)</script></div>"); |
|---|
| 1817 | websWrite (wp, |
|---|
| 1818 | "<input class=\"num\" size=\"5\" maxlength=\"5\" name=\"olsrd_lqdijkstramin\" onblur=\"olsrd_checkDijkstra(this.form)\" value=\"%s\" />\n", |
|---|
| 1819 | nvram_safe_get ("olsrd_lqdijkstramin")); |
|---|
| 1820 | websWrite (wp, "</div>\n"); |
|---|
| 1821 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1822 | websWrite (wp, |
|---|
| 1823 | "<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_lqdmax)</script></div>"); |
|---|
| 1824 | websWrite (wp, |
|---|
| 1825 | "<input class=\"num\" size=\"5\" maxlength=\"5\" name=\"olsrd_lqdijkstramax\" onblur=\"olsrd_checkDijkstra(this.form)\" value=\"%s\" />\n", |
|---|
| 1826 | nvram_safe_get ("olsrd_lqdijkstramax")); |
|---|
| 1827 | websWrite (wp, "</div>\n"); |
|---|
| 1828 | |
|---|
| 1829 | showOptionsLabel (wp, "route.olsrd_lqlvl", "olsrd_lqlevel", |
|---|
| 1830 | "0 1 2", nvram_default_get ("olsrd_lqlevel", "2")); |
|---|
| 1831 | showOption (wp, "route.olsrd_hysteresis", "olsrd_hysteresis"); |
|---|
| 1832 | char *wordlist = nvram_safe_get ("olsrd_interfaces"); |
|---|
| 1833 | char *next; |
|---|
| 1834 | char word[128]; |
|---|
| 1835 | int count = 0; |
|---|
| 1836 | foreach (word, wordlist, next) |
|---|
| 1837 | { |
|---|
| 1838 | char *interface = word; |
|---|
| 1839 | char *hellointerval = interface; |
|---|
| 1840 | strsep (&hellointerval, ">"); |
|---|
| 1841 | char *hellovaliditytime = hellointerval; |
|---|
| 1842 | strsep (&hellovaliditytime, ">"); |
|---|
| 1843 | char *tcinterval = hellovaliditytime; |
|---|
| 1844 | strsep (&tcinterval, ">"); |
|---|
| 1845 | char *tcvaliditytime = tcinterval; |
|---|
| 1846 | strsep (&tcvaliditytime, ">"); |
|---|
| 1847 | char *midinterval = tcvaliditytime; |
|---|
| 1848 | strsep (&midinterval, ">"); |
|---|
| 1849 | char *midvaliditytime = midinterval; |
|---|
| 1850 | strsep (&midvaliditytime, ">"); |
|---|
| 1851 | char *hnainterval = midvaliditytime; |
|---|
| 1852 | strsep (&hnainterval, ">"); |
|---|
| 1853 | char *hnavaliditytime = hnainterval; |
|---|
| 1854 | strsep (&hnavaliditytime, ">"); |
|---|
| 1855 | websWrite (wp, "<fieldset>\n"); |
|---|
| 1856 | show_legend (wp, interface, 0); |
|---|
| 1857 | char valuename[32]; |
|---|
| 1858 | sprintf (valuename, "%s_hellointerval", interface); |
|---|
| 1859 | show_custominputlabel (wp, "Hello Interval", valuename, hellointerval, |
|---|
| 1860 | 5); |
|---|
| 1861 | sprintf (valuename, "%s_hellovaliditytime", interface); |
|---|
| 1862 | show_custominputlabel (wp, "Hello Validity Time", valuename, |
|---|
| 1863 | hellovaliditytime, 5); |
|---|
| 1864 | |
|---|
| 1865 | sprintf (valuename, "%s_tcinterval", interface); |
|---|
| 1866 | show_custominputlabel (wp, "TC Interval", valuename, tcinterval, 5); |
|---|
| 1867 | sprintf (valuename, "%s_tcvaliditytime", interface); |
|---|
| 1868 | show_custominputlabel (wp, "TC Validity Time", valuename, |
|---|
| 1869 | tcvaliditytime, 5); |
|---|
| 1870 | |
|---|
| 1871 | sprintf (valuename, "%s_midinterval", interface); |
|---|
| 1872 | show_custominputlabel (wp, "MID Interval", valuename, midinterval, 5); |
|---|
| 1873 | sprintf (valuename, "%s_midvaliditytime", interface); |
|---|
| 1874 | show_custominputlabel (wp, "MID Validity Time", valuename, |
|---|
| 1875 | midvaliditytime, 5); |
|---|
| 1876 | |
|---|
| 1877 | sprintf (valuename, "%s_hnainterval", interface); |
|---|
| 1878 | show_custominputlabel (wp, "HNA Interval", valuename, hnainterval, 5); |
|---|
| 1879 | sprintf (valuename, "%s_hnavaliditytime", interface); |
|---|
| 1880 | show_custominputlabel (wp, "HNA Validity Time", valuename, |
|---|
| 1881 | hnavaliditytime, 5); |
|---|
| 1882 | websWrite (wp, |
|---|
| 1883 | "<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", |
|---|
| 1884 | count); |
|---|
| 1885 | |
|---|
| 1886 | websWrite (wp, "</fieldset>\n"); |
|---|
| 1887 | count++; |
|---|
| 1888 | } |
|---|
| 1889 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1890 | websWrite (wp, |
|---|
| 1891 | "<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_newiface)</script></div>\n"); |
|---|
| 1892 | char buffer[256]; |
|---|
| 1893 | memset (buffer, 0, 256); |
|---|
| 1894 | getIfList (buffer, NULL); |
|---|
| 1895 | showOptions (wp, "olsrd_ifname", buffer, ""); |
|---|
| 1896 | websWrite (wp, " "); |
|---|
| 1897 | websWrite (wp, |
|---|
| 1898 | "<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"); |
|---|
| 1899 | websWrite (wp, "</div>\n"); |
|---|
| 1900 | websWrite (wp, "</fieldset><br />\n"); |
|---|
| 1901 | } |
|---|
| 1902 | } |
|---|
| 1903 | |
|---|
| 1904 | #endif |
|---|
| 1905 | #ifdef HAVE_VLANTAGGING |
|---|
| 1906 | #ifdef HAVE_BONDING |
|---|
| 1907 | |
|---|
| 1908 | |
|---|
| 1909 | |
|---|
| 1910 | void |
|---|
| 1911 | ej_show_bondings (webs_t wp, int argc, char_t ** argv) |
|---|
| 1912 | { |
|---|
| 1913 | char buffer[256]; |
|---|
| 1914 | char bufferif[512]; |
|---|
| 1915 | char bondnames[256]; |
|---|
| 1916 | int count = 0; |
|---|
| 1917 | static char word[256]; |
|---|
| 1918 | char *next, *wordlist; |
|---|
| 1919 | memset (buffer, 0, 256); |
|---|
| 1920 | memset (bondnames, 0, 256); |
|---|
| 1921 | memset (bufferif, 0, 512); |
|---|
| 1922 | websWrite (wp, "<h2>Bonding</h2>\n"); |
|---|
| 1923 | websWrite (wp, "<fieldset>\n"); |
|---|
| 1924 | websWrite (wp, "<legend>Bonding</legend>\n"); |
|---|
| 1925 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1926 | websWrite (wp, "<div class=\"label\">Bonding Type</div>\n", count); |
|---|
| 1927 | showOptions (wp, "bonding_type", |
|---|
| 1928 | "balance-rr active-backup balance-xor broadcast 802.3ad balance-tlb balance-alb", |
|---|
| 1929 | nvram_default_get ("bonding_type", "balance-rr")); |
|---|
| 1930 | websWrite (wp, " Bonding Interfaces "); |
|---|
| 1931 | websWrite (wp, |
|---|
| 1932 | "<input class=\"num\" name=\"bonding_number\"size=\"5\" value=\"%s\" />\n", |
|---|
| 1933 | nvram_default_get ("bonding_number", "1")); |
|---|
| 1934 | websWrite (wp, "</div>\n"); |
|---|
| 1935 | |
|---|
| 1936 | getIfList (bufferif, "eth"); |
|---|
| 1937 | int i; |
|---|
| 1938 | #ifdef HAVE_XSCALE |
|---|
| 1939 | memset (buffer, 0, 256); |
|---|
| 1940 | getIfList (buffer, "ixp"); |
|---|
| 1941 | sprintf (bufferif, "%s %s", bufferif, buffer); |
|---|
| 1942 | #endif |
|---|
| 1943 | memset (buffer, 0, 256); |
|---|
| 1944 | getIfList (buffer, "br"); |
|---|
| 1945 | sprintf (bufferif, "%s %s", bufferif, buffer); |
|---|
| 1946 | #ifdef HAVE_MADWIFI |
|---|
| 1947 | int c = getifcount ("wifi"); |
|---|
| 1948 | for (i = 0; i < c; i++) |
|---|
| 1949 | { |
|---|
| 1950 | char ath[32]; |
|---|
| 1951 | sprintf (ath, "ath%d_bridged", i); |
|---|
| 1952 | if (nvram_default_match (ath, "0", "1")) |
|---|
| 1953 | { |
|---|
| 1954 | sprintf (bufferif, "%s ath%d", bufferif, i); |
|---|
| 1955 | char vifs[32]; |
|---|
| 1956 | sprintf (vifs, "ath%d_vifs", i); |
|---|
| 1957 | sprintf (bufferif, "%s %s", bufferif, nvram_safe_get (vifs)); |
|---|
| 1958 | } |
|---|
| 1959 | } |
|---|
| 1960 | #endif |
|---|
| 1961 | |
|---|
| 1962 | for (i = 0; i < atoi (nvram_safe_get ("bonding_number")); i++) |
|---|
| 1963 | { |
|---|
| 1964 | sprintf (bondnames, "%s bond%d", bondnames, i); |
|---|
| 1965 | } |
|---|
| 1966 | int totalcount = 0; |
|---|
| 1967 | int realcount = atoi (nvram_default_get ("bonding_count", "0")); |
|---|
| 1968 | wordlist = nvram_safe_get ("bondings"); |
|---|
| 1969 | foreach (word, wordlist, next) |
|---|
| 1970 | { |
|---|
| 1971 | char *port = word; |
|---|
| 1972 | char *tag = strsep (&port, ">"); |
|---|
| 1973 | if (!tag || !port) |
|---|
| 1974 | break; |
|---|
| 1975 | char vlan_name[32]; |
|---|
| 1976 | // sprintf (vlan_name, "%s.%s", tag, port); |
|---|
| 1977 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1978 | websWrite (wp, "<div class=\"label\">Bonding %d Assignment</div>\n", |
|---|
| 1979 | count); |
|---|
| 1980 | websWrite (wp, " Bond "); |
|---|
| 1981 | sprintf (vlan_name, "bondingifname%d", count); |
|---|
| 1982 | showOptions (wp, vlan_name, bondnames, tag); |
|---|
| 1983 | sprintf (vlan_name, "bondingattach%d", count); |
|---|
| 1984 | websWrite (wp, " Slave "); |
|---|
| 1985 | showOptions (wp, vlan_name, bufferif, port); |
|---|
| 1986 | websWrite (wp, |
|---|
| 1987 | "<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", |
|---|
| 1988 | count); |
|---|
| 1989 | websWrite (wp, "</div>\n"); |
|---|
| 1990 | count++; |
|---|
| 1991 | } |
|---|
| 1992 | totalcount = count; |
|---|
| 1993 | for (i = count; i < realcount; i++) |
|---|
| 1994 | { |
|---|
| 1995 | char vlan_name[32]; |
|---|
| 1996 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 1997 | websWrite (wp, "<div class=\"label\">Bonding %d Interface</div>\n", i); |
|---|
| 1998 | websWrite (wp, " Bond "); |
|---|
| 1999 | sprintf (vlan_name, "bondingifname%d", i); |
|---|
| 2000 | showOptions (wp, vlan_name, bondnames, ""); |
|---|
| 2001 | sprintf (vlan_name, "bondingattach%d", i); |
|---|
| 2002 | websWrite (wp, " Slave "); |
|---|
| 2003 | showOptions (wp, vlan_name, bufferif, ""); |
|---|
| 2004 | websWrite (wp, |
|---|
| 2005 | "<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", |
|---|
| 2006 | i); |
|---|
| 2007 | websWrite (wp, "</div>\n"); |
|---|
| 2008 | totalcount++; |
|---|
| 2009 | } |
|---|
| 2010 | char var[32]; |
|---|
| 2011 | sprintf (var, "%d", totalcount); |
|---|
| 2012 | nvram_set ("bonding_count", var); |
|---|
| 2013 | websWrite (wp, |
|---|
| 2014 | "<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"); |
|---|
| 2015 | websWrite (wp, "</fieldset><br />\n"); |
|---|
| 2016 | } |
|---|
| 2017 | #endif |
|---|
| 2018 | void |
|---|
| 2019 | ej_show_vlantagging (webs_t wp, int argc, char_t ** argv) |
|---|
| 2020 | { |
|---|
| 2021 | char buffer[256]; |
|---|
| 2022 | int count = 0; |
|---|
| 2023 | static char word[256]; |
|---|
| 2024 | char *next, *wordlist; |
|---|
| 2025 | memset (buffer, 0, 256); |
|---|
| 2026 | getIfList (buffer, NULL); |
|---|
| 2027 | int totalcount = 0; |
|---|
| 2028 | int realcount = atoi (nvram_default_get ("vlan_tagcount", "0")); |
|---|
| 2029 | wordlist = nvram_safe_get ("vlan_tags"); |
|---|
| 2030 | foreach (word, wordlist, next) |
|---|
| 2031 | { |
|---|
| 2032 | char *port = word; |
|---|
| 2033 | char *tag = strsep (&port, ">"); |
|---|
| 2034 | if (!tag || !port) |
|---|
| 2035 | break; |
|---|
| 2036 | char vlan_name[32]; |
|---|
| 2037 | // sprintf (vlan_name, "%s.%s", tag, port); |
|---|
| 2038 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 2039 | websWrite (wp, "<div class=\"label\">VLAN%d Interface</div>\n", count); |
|---|
| 2040 | sprintf (vlan_name, "vlanifname%d", count); |
|---|
| 2041 | showOptions (wp, vlan_name, buffer, tag); |
|---|
| 2042 | sprintf (vlan_name, "vlantag%d", count); |
|---|
| 2043 | websWrite (wp, " Tag Number "); |
|---|
| 2044 | websWrite (wp, |
|---|
| 2045 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2046 | vlan_name, port); |
|---|
| 2047 | websWrite (wp, |
|---|
| 2048 | "<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", |
|---|
| 2049 | count); |
|---|
| 2050 | websWrite (wp, "</div>\n"); |
|---|
| 2051 | count++; |
|---|
| 2052 | } |
|---|
| 2053 | totalcount = count; |
|---|
| 2054 | int i; |
|---|
| 2055 | for (i = count; i < realcount; i++) |
|---|
| 2056 | { |
|---|
| 2057 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 2058 | websWrite (wp, "<div class=\"label\">VLAN%d Interface</div>\n", i); |
|---|
| 2059 | char vlan_name[32]; |
|---|
| 2060 | sprintf (vlan_name, "vlanifname%d", i); |
|---|
| 2061 | showOptions (wp, vlan_name, buffer, ""); |
|---|
| 2062 | sprintf (vlan_name, "vlantag%d", i); |
|---|
| 2063 | websWrite (wp, " Tag Number "); |
|---|
| 2064 | websWrite (wp, |
|---|
| 2065 | "<input class=\"num\" name=\"%s\" size=\"5\" value=\"0\" />\n", |
|---|
| 2066 | vlan_name); |
|---|
| 2067 | websWrite (wp, |
|---|
| 2068 | "<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", |
|---|
| 2069 | i); |
|---|
| 2070 | websWrite (wp, "</div>\n"); |
|---|
| 2071 | totalcount++; |
|---|
| 2072 | } |
|---|
| 2073 | char var[32]; |
|---|
| 2074 | sprintf (var, "%d", totalcount); |
|---|
| 2075 | nvram_set ("vlan_tagcount", var); |
|---|
| 2076 | websWrite (wp, |
|---|
| 2077 | "<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"); |
|---|
| 2078 | } |
|---|
| 2079 | |
|---|
| 2080 | void |
|---|
| 2081 | ej_show_mdhcp (webs_t wp, int argc, char_t ** argv) |
|---|
| 2082 | { |
|---|
| 2083 | char buffer[256]; |
|---|
| 2084 | int count = 0; |
|---|
| 2085 | static char word[256]; |
|---|
| 2086 | char *next, *wordlist; |
|---|
| 2087 | websWrite (wp, "<h2>%s</h2>\n<fieldset>\n", |
|---|
| 2088 | live_translate ("networking.h5")); |
|---|
| 2089 | websWrite (wp, "<legend>%s</legend>\n", |
|---|
| 2090 | live_translate ("networking.legend5")); |
|---|
| 2091 | |
|---|
| 2092 | |
|---|
| 2093 | |
|---|
| 2094 | memset (buffer, 0, 256); |
|---|
| 2095 | getIfList (buffer, NULL); |
|---|
| 2096 | int totalcount = 0; |
|---|
| 2097 | int realcount = atoi (nvram_default_get ("mdhcpd_count", "0")); |
|---|
| 2098 | wordlist = nvram_safe_get ("mdhcpd"); |
|---|
| 2099 | foreach (word, wordlist, next) |
|---|
| 2100 | { |
|---|
| 2101 | char *interface = word; |
|---|
| 2102 | char *dhcpon = interface; |
|---|
| 2103 | interface = strsep (&dhcpon, ">"); |
|---|
| 2104 | char *start = dhcpon; |
|---|
| 2105 | dhcpon = strsep (&start, ">"); |
|---|
| 2106 | char *max = start; |
|---|
| 2107 | start = strsep (&max, ">"); |
|---|
| 2108 | char *leasetime = max; |
|---|
| 2109 | max = strsep (&leasetime, ">"); |
|---|
| 2110 | if (!interface || !start || !dhcpon || !max || !leasetime) |
|---|
| 2111 | break; |
|---|
| 2112 | char vlan_name[32]; |
|---|
| 2113 | |
|---|
| 2114 | // interface |
|---|
| 2115 | char *ipaddr = nvram_nget ("%s_ipaddr", interface); |
|---|
| 2116 | char *netmask = nvram_nget ("%s_netmask", interface); |
|---|
| 2117 | if (strlen (ipaddr) > 0 && strlen (netmask) > 0) |
|---|
| 2118 | { |
|---|
| 2119 | websWrite (wp, "Interface %s: IP %s/%s\n", interface, ipaddr, |
|---|
| 2120 | netmask); |
|---|
| 2121 | } |
|---|
| 2122 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 2123 | websWrite (wp, "<div class=\"label\">DHCP %d</div>\n", count); |
|---|
| 2124 | sprintf (vlan_name, "mdhcpifname%d", count); |
|---|
| 2125 | showOptions (wp, vlan_name, buffer, interface); |
|---|
| 2126 | // on off |
|---|
| 2127 | sprintf (vlan_name, "mdhcpon%d", count); |
|---|
| 2128 | showOptions (wp, vlan_name, "On Off", dhcpon); |
|---|
| 2129 | // start |
|---|
| 2130 | sprintf (vlan_name, "mdhcpstart%d", count); |
|---|
| 2131 | websWrite (wp, " Start "); |
|---|
| 2132 | websWrite (wp, |
|---|
| 2133 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2134 | vlan_name, start); |
|---|
| 2135 | // max |
|---|
| 2136 | sprintf (vlan_name, "mdhcpmax%d", count); |
|---|
| 2137 | websWrite (wp, " Max "); |
|---|
| 2138 | websWrite (wp, |
|---|
| 2139 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2140 | vlan_name, max); |
|---|
| 2141 | sprintf (vlan_name, "mdhcpleasetime%d", count); |
|---|
| 2142 | websWrite (wp, " Leasetime "); |
|---|
| 2143 | websWrite (wp, |
|---|
| 2144 | "<input class=\"num\" name=\"%s\" size=\"5\" value=\"%s\" />\n", |
|---|
| 2145 | vlan_name, leasetime); |
|---|
| 2146 | // |
|---|
| 2147 | websWrite (wp, |
|---|
| 2148 | "<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", |
|---|
| 2149 | count); |
|---|
| 2150 | websWrite (wp, "</div>\n"); |
|---|
| 2151 | count++; |
|---|
| 2152 | } |
|---|
| 2153 | totalcount = count; |
|---|
| 2154 | int i; |
|---|
| 2155 | for (i = count; i < realcount; i++) |
|---|
| 2156 | { |
|---|
| 2157 | char vlan_name[32]; |
|---|
| 2158 | // sprintf (mdhcp_name, "%s.%s", tag, port); |
|---|
| 2159 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 2160 | websWrite (wp, "<div class=\"label\">DHCP %d</div>\n", count); |
|---|
| 2161 | // interface |
|---|
| 2162 | sprintf (vlan_name, "mdhcpifname%d", count); |
|---|
| 2163 | showOptions (wp, vlan_name, buffer, ""); |
|---|
| 2164 | // on off |
|---|
| 2165 | sprintf (vlan_name, "mdhcpon%d", count); |
|---|
| 2166 | showOptions (wp, vlan_name, "On Off", ""); |
|---|
| 2167 | // start |
|---|
| 2168 | sprintf (vlan_name, "mdhcpstart%d", count); |
|---|
| 2169 | websWrite (wp, " Start "); |
|---|
| 2170 | websWrite (wp, |
|---|
| 2171 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2172 | vlan_name, "100"); |
|---|
| 2173 | // max |
|---|
| 2174 | sprintf (vlan_name, "mdhcpmax%d", count); |
|---|
| 2175 | websWrite (wp, " Max "); |
|---|
| 2176 | websWrite (wp, |
|---|
| 2177 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2178 | vlan_name, "50"); |
|---|
| 2179 | sprintf (vlan_name, "mdhcpleasetime%d", count); |
|---|
| 2180 | websWrite (wp, " Leasetime "); |
|---|
| 2181 | websWrite (wp, |
|---|
| 2182 | "<input class=\"num\" name=\"%s\" size=\"5\" value=\"%s\" />\n", |
|---|
| 2183 | vlan_name, "3600"); |
|---|
| 2184 | websWrite (wp, |
|---|
| 2185 | "<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", |
|---|
| 2186 | i); |
|---|
| 2187 | websWrite (wp, "</div>\n"); |
|---|
| 2188 | totalcount++; |
|---|
| 2189 | } |
|---|
| 2190 | char var[32]; |
|---|
| 2191 | sprintf (var, "%d", totalcount); |
|---|
| 2192 | nvram_set ("mdhcpd_count", var); |
|---|
| 2193 | websWrite (wp, |
|---|
| 2194 | "<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"); |
|---|
| 2195 | websWrite (wp, "</fieldset><br />\n"); |
|---|
| 2196 | |
|---|
| 2197 | } |
|---|
| 2198 | |
|---|
| 2199 | |
|---|
| 2200 | void |
|---|
| 2201 | ej_show_bridgenames (webs_t wp, int argc, char_t ** argv) |
|---|
| 2202 | { |
|---|
| 2203 | char buffer[256]; |
|---|
| 2204 | int count = 0; |
|---|
| 2205 | static char word[256]; |
|---|
| 2206 | char *next, *wordlist; |
|---|
| 2207 | memset (buffer, 0, 256); |
|---|
| 2208 | getIfList (buffer, NULL); |
|---|
| 2209 | int realcount = atoi (nvram_default_get ("bridges_count", "0")); |
|---|
| 2210 | wordlist = nvram_safe_get ("bridges"); |
|---|
| 2211 | foreach (word, wordlist, next) |
|---|
| 2212 | { |
|---|
| 2213 | char *port = word; |
|---|
| 2214 | char *tag = strsep (&port, ">"); |
|---|
| 2215 | char *prio = port; |
|---|
| 2216 | strsep (&prio, ">"); |
|---|
| 2217 | if (!tag || !port) |
|---|
| 2218 | break; |
|---|
| 2219 | char vlan_name[32]; |
|---|
| 2220 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 2221 | websWrite (wp, "<div class=\"label\">Bridge %d</div>\n", count); |
|---|
| 2222 | sprintf (vlan_name, "bridgename%d", count); |
|---|
| 2223 | websWrite (wp, |
|---|
| 2224 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2225 | vlan_name, tag); |
|---|
| 2226 | websWrite (wp, " STP "); |
|---|
| 2227 | sprintf (vlan_name, "bridgestp%d", count); |
|---|
| 2228 | showOptions (wp, vlan_name, "On Off", port); |
|---|
| 2229 | websWrite (wp, " Prio "); |
|---|
| 2230 | sprintf (vlan_name, "bridgeprio%d", count); |
|---|
| 2231 | websWrite (wp, |
|---|
| 2232 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2233 | vlan_name, prio != NULL ? prio : "32768"); |
|---|
| 2234 | websWrite (wp, |
|---|
| 2235 | "<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", |
|---|
| 2236 | count); |
|---|
| 2237 | websWrite (wp, "</div>\n"); |
|---|
| 2238 | show_ipnetmask (wp, tag); |
|---|
| 2239 | count++; |
|---|
| 2240 | } |
|---|
| 2241 | int i; |
|---|
| 2242 | int totalcount = count; |
|---|
| 2243 | for (i = count; i < realcount; i++) |
|---|
| 2244 | { |
|---|
| 2245 | char vlan_name[32]; |
|---|
| 2246 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 2247 | websWrite (wp, "<div class=\"label\">Bridge %d</div>\n", i); |
|---|
| 2248 | sprintf (vlan_name, "bridgename%d", i); |
|---|
| 2249 | websWrite (wp, "<input class=\"num\" name=\"%s\"size=\"5\" />\n", |
|---|
| 2250 | vlan_name); |
|---|
| 2251 | websWrite (wp, " STP "); |
|---|
| 2252 | sprintf (vlan_name, "bridgestp%d", i); |
|---|
| 2253 | showOptions (wp, vlan_name, "On Off", "On"); |
|---|
| 2254 | websWrite (wp, " Prio "); |
|---|
| 2255 | sprintf (vlan_name, "bridgeprio%d", i); |
|---|
| 2256 | websWrite (wp, |
|---|
| 2257 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2258 | vlan_name, "32768"); |
|---|
| 2259 | websWrite (wp, |
|---|
| 2260 | "<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", |
|---|
| 2261 | i); |
|---|
| 2262 | websWrite (wp, "</div>\n"); |
|---|
| 2263 | totalcount++; |
|---|
| 2264 | } |
|---|
| 2265 | websWrite (wp, |
|---|
| 2266 | "<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"); |
|---|
| 2267 | char var[32]; |
|---|
| 2268 | sprintf (var, "%d", totalcount); |
|---|
| 2269 | nvram_set ("bridges_count", var); |
|---|
| 2270 | } |
|---|
| 2271 | |
|---|
| 2272 | void |
|---|
| 2273 | ej_show_bridgetable (webs_t wp, int argc, char_t ** argv) |
|---|
| 2274 | { |
|---|
| 2275 | #ifdef HAVE_MICRO //brctl N/A in micro |
|---|
| 2276 | return; |
|---|
| 2277 | #endif |
|---|
| 2278 | |
|---|
| 2279 | FILE *f; |
|---|
| 2280 | char buf[128]; |
|---|
| 2281 | char brname[32]; |
|---|
| 2282 | char brstp[8]; |
|---|
| 2283 | char brif[16]; |
|---|
| 2284 | int count = 0; |
|---|
| 2285 | |
|---|
| 2286 | system2 ("brctl show > /tmp/.brtable"); |
|---|
| 2287 | |
|---|
| 2288 | if ((f = fopen ("/tmp/.brtable", "r")) != NULL) |
|---|
| 2289 | { |
|---|
| 2290 | |
|---|
| 2291 | while (fgets (buf, sizeof (buf), f)) |
|---|
| 2292 | { |
|---|
| 2293 | |
|---|
| 2294 | if (count) //skip line 0 |
|---|
| 2295 | { |
|---|
| 2296 | strcpy (brname, ""); |
|---|
| 2297 | strcpy (brstp, ""); |
|---|
| 2298 | strcpy (brif, ""); |
|---|
| 2299 | |
|---|
| 2300 | if (strncmp (buf, "\t\t\t", 3) != 0) |
|---|
| 2301 | { |
|---|
| 2302 | if (count != 1) |
|---|
| 2303 | websWrite (wp, "\',"); //close |
|---|
| 2304 | sscanf (buf, "%s %*s %s %s", brname, brstp, brif); |
|---|
| 2305 | websWrite (wp, "\'%s\',\'%s\',\'%s ", brname, brstp, brif); |
|---|
| 2306 | } |
|---|
| 2307 | else |
|---|
| 2308 | { |
|---|
| 2309 | sscanf (buf, "%s", brif); |
|---|
| 2310 | websWrite (wp, "%s ", brif); |
|---|
| 2311 | } |
|---|
| 2312 | } |
|---|
| 2313 | count++; |
|---|
| 2314 | } |
|---|
| 2315 | |
|---|
| 2316 | websWrite (wp, "\'"); //close |
|---|
| 2317 | fclose (f); |
|---|
| 2318 | unlink ("/tmp/.brtable"); |
|---|
| 2319 | } |
|---|
| 2320 | return; |
|---|
| 2321 | } |
|---|
| 2322 | |
|---|
| 2323 | |
|---|
| 2324 | void |
|---|
| 2325 | ej_show_bridgeifnames (webs_t wp, int argc, char_t ** argv) |
|---|
| 2326 | { |
|---|
| 2327 | char bufferif[512]; |
|---|
| 2328 | char bufferif2[256]; |
|---|
| 2329 | char finalbuffer[512]; |
|---|
| 2330 | int count = 0; |
|---|
| 2331 | static char word[256]; |
|---|
| 2332 | char *next, *wordlist; |
|---|
| 2333 | memset (bufferif, 0, 512); |
|---|
| 2334 | memset (bufferif2, 0, 256); |
|---|
| 2335 | getIfList (bufferif, "eth"); |
|---|
| 2336 | #ifdef HAVE_GATEWORX |
|---|
| 2337 | getIfList (bufferif2, "ixp"); |
|---|
| 2338 | sprintf (bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2339 | #endif |
|---|
| 2340 | |
|---|
| 2341 | memset (bufferif2, 0, 256); |
|---|
| 2342 | getIfList (bufferif2, "vlan"); |
|---|
| 2343 | sprintf (bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2344 | |
|---|
| 2345 | memset (bufferif2, 0, 256); |
|---|
| 2346 | getIfList (bufferif2, "wl"); |
|---|
| 2347 | sprintf (bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2348 | |
|---|
| 2349 | memset (bufferif2, 0, 256); |
|---|
| 2350 | getIfList (bufferif2, "ofdm"); |
|---|
| 2351 | sprintf (bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2352 | |
|---|
| 2353 | memset (bufferif2, 0, 256); |
|---|
| 2354 | getIfList (bufferif2, "br"); |
|---|
| 2355 | foreach (word, bufferif2, next) |
|---|
| 2356 | { |
|---|
| 2357 | if (contains (word, '.')) |
|---|
| 2358 | sprintf (bufferif, "%s %s", bufferif, word); |
|---|
| 2359 | } |
|---|
| 2360 | int i; |
|---|
| 2361 | #ifdef HAVE_MADWIFI |
|---|
| 2362 | memset (bufferif2, 0, 256); |
|---|
| 2363 | getIfList (bufferif2, "ath"); |
|---|
| 2364 | foreach (word, bufferif2, next) |
|---|
| 2365 | { |
|---|
| 2366 | if (contains (word, '.')) |
|---|
| 2367 | sprintf (bufferif, "%s %s", bufferif, word); |
|---|
| 2368 | } |
|---|
| 2369 | int c = getifcount ("wifi"); |
|---|
| 2370 | for (i = 0; i < c; i++) |
|---|
| 2371 | { |
|---|
| 2372 | char ath[32]; |
|---|
| 2373 | sprintf (ath, "ath%d_bridged", i); |
|---|
| 2374 | if (nvram_default_match (ath, "1", "1")) |
|---|
| 2375 | { |
|---|
| 2376 | sprintf (bufferif, "%s ath%d", bufferif, i); |
|---|
| 2377 | char vifs[32]; |
|---|
| 2378 | sprintf (vifs, "ath%d_vifs", i); |
|---|
| 2379 | sprintf (bufferif, "%s %s", bufferif, nvram_safe_get (vifs)); |
|---|
| 2380 | } |
|---|
| 2381 | } |
|---|
| 2382 | #endif |
|---|
| 2383 | #ifdef HAVE_BONDING |
|---|
| 2384 | c = atoi (nvram_default_get ("bonding_number", "1")); |
|---|
| 2385 | for (i = 0; i < c; i++) |
|---|
| 2386 | { |
|---|
| 2387 | sprintf (bufferif, "%s bond%d", bufferif, i); |
|---|
| 2388 | } |
|---|
| 2389 | #endif |
|---|
| 2390 | #ifdef HAVE_EOP_TUNNEL |
|---|
| 2391 | for (i = 1; i < 11; i++) |
|---|
| 2392 | { |
|---|
| 2393 | char EOP[32]; |
|---|
| 2394 | if (nvram_nmatch ("1", "oet%d_bridged", i) |
|---|
| 2395 | && nvram_nmatch ("1", "oet%d_en", i)) |
|---|
| 2396 | { |
|---|
| 2397 | sprintf (EOP, "EOP%d", i); |
|---|
| 2398 | sprintf (bufferif, "%s %s", bufferif, EOP); |
|---|
| 2399 | } |
|---|
| 2400 | } |
|---|
| 2401 | #endif |
|---|
| 2402 | char buffer[256]; |
|---|
| 2403 | memset (buffer, 0, 256); |
|---|
| 2404 | getIfList (buffer, "br"); |
|---|
| 2405 | |
|---|
| 2406 | memset (finalbuffer, 0, 256); |
|---|
| 2407 | foreach (word, buffer, next) |
|---|
| 2408 | { |
|---|
| 2409 | if (!contains (word, '.')) |
|---|
| 2410 | sprintf (finalbuffer, "%s %s", finalbuffer, word); |
|---|
| 2411 | } |
|---|
| 2412 | |
|---|
| 2413 | |
|---|
| 2414 | int realcount = atoi (nvram_default_get ("bridgesif_count", "0")); |
|---|
| 2415 | wordlist = nvram_safe_get ("bridgesif"); |
|---|
| 2416 | foreach (word, wordlist, next) |
|---|
| 2417 | { |
|---|
| 2418 | char *port = word; |
|---|
| 2419 | char *tag = strsep (&port, ">"); |
|---|
| 2420 | char *prio = port; |
|---|
| 2421 | strsep (&prio, ">"); |
|---|
| 2422 | if (!tag || !port) |
|---|
| 2423 | break; |
|---|
| 2424 | char vlan_name[32]; |
|---|
| 2425 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 2426 | websWrite (wp, "<div class=\"label\">Assignment %d</div>\n", count); |
|---|
| 2427 | sprintf (vlan_name, "bridge%d", count); |
|---|
| 2428 | showOptions (wp, vlan_name, finalbuffer, tag); |
|---|
| 2429 | websWrite (wp, " Interface "); |
|---|
| 2430 | sprintf (vlan_name, "bridgeif%d", count); |
|---|
| 2431 | showOptions (wp, vlan_name, bufferif, port); |
|---|
| 2432 | websWrite (wp, " Prio "); |
|---|
| 2433 | sprintf (vlan_name, "bridgeifprio%d", count); |
|---|
| 2434 | websWrite (wp, |
|---|
| 2435 | "<input class=\"num\" name=\"%s\"size=\"3\" value=\"%s\" />\n", |
|---|
| 2436 | vlan_name, prio != NULL ? prio : "128"); |
|---|
| 2437 | websWrite (wp, |
|---|
| 2438 | "<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", |
|---|
| 2439 | count); |
|---|
| 2440 | websWrite (wp, "</div>\n"); |
|---|
| 2441 | count++; |
|---|
| 2442 | } |
|---|
| 2443 | int totalcount = count; |
|---|
| 2444 | for (i = count; i < realcount; i++) |
|---|
| 2445 | { |
|---|
| 2446 | char vlan_name[32]; |
|---|
| 2447 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 2448 | websWrite (wp, "<div class=\"label\">Assignment %d</div>\n", i); |
|---|
| 2449 | sprintf (vlan_name, "bridge%d", i); |
|---|
| 2450 | showOptions (wp, vlan_name, finalbuffer, ""); |
|---|
| 2451 | websWrite (wp, " Interface "); |
|---|
| 2452 | sprintf (vlan_name, "bridgeif%d", i); |
|---|
| 2453 | showOptions (wp, vlan_name, bufferif, ""); |
|---|
| 2454 | websWrite (wp, " Prio "); |
|---|
| 2455 | sprintf (vlan_name, "bridgeifprio%d", i); |
|---|
| 2456 | websWrite (wp, |
|---|
| 2457 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2458 | vlan_name, "128"); |
|---|
| 2459 | websWrite (wp, |
|---|
| 2460 | "<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", |
|---|
| 2461 | i); |
|---|
| 2462 | websWrite (wp, "</div>\n"); |
|---|
| 2463 | totalcount++; |
|---|
| 2464 | } |
|---|
| 2465 | websWrite (wp, |
|---|
| 2466 | "<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"); |
|---|
| 2467 | char var[32]; |
|---|
| 2468 | sprintf (var, "%d", totalcount); |
|---|
| 2469 | nvram_set ("bridgesif_count", var); |
|---|
| 2470 | } |
|---|
| 2471 | |
|---|
| 2472 | |
|---|
| 2473 | #endif |
|---|
| 2474 | static void |
|---|
| 2475 | showDynOption (webs_t wp, char *propname, char *nvname, char *options[], |
|---|
| 2476 | char *names[]) |
|---|
| 2477 | { |
|---|
| 2478 | int i; |
|---|
| 2479 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 2480 | websWrite (wp, |
|---|
| 2481 | "<div class=\"label\">%s</div><select name=\"%s\">\n", |
|---|
| 2482 | propname, nvname); |
|---|
| 2483 | for (i = 0; options[i] != NULL; i++) |
|---|
| 2484 | { |
|---|
| 2485 | websWrite (wp, |
|---|
| 2486 | "<option value=\"%s\" %s>Off</option>\n", |
|---|
| 2487 | names[i], nvram_match (nvname, |
|---|
| 2488 | options[i]) ? "selected=\"selected\"" |
|---|
| 2489 | : ""); |
|---|
| 2490 | } |
|---|
| 2491 | websWrite (wp, "</div>\n"); |
|---|
| 2492 | |
|---|
| 2493 | } |
|---|
| 2494 | |
|---|
| 2495 | #ifdef HAVE_MSSID |
|---|
| 2496 | |
|---|
| 2497 | |
|---|
| 2498 | |
|---|
| 2499 | |
|---|
| 2500 | static void |
|---|
| 2501 | show_channel (webs_t wp, char *dev, char *prefix, int type) |
|---|
| 2502 | { |
|---|
| 2503 | char wl_mode[16]; |
|---|
| 2504 | sprintf (wl_mode, "%s_mode", prefix); |
|---|
| 2505 | char wl_net_mode[16]; |
|---|
| 2506 | sprintf (wl_net_mode, "%s_net_mode", prefix); |
|---|
| 2507 | if (nvram_match (wl_net_mode, "disabled")) |
|---|
| 2508 | return; |
|---|
| 2509 | if (nvram_match (wl_mode, "ap") || nvram_match (wl_mode, "wdsap") |
|---|
| 2510 | || nvram_match (wl_mode, "infra")) |
|---|
| 2511 | { |
|---|
| 2512 | char wl_channel[16]; |
|---|
| 2513 | sprintf (wl_channel, "%s_channel", prefix); |
|---|
| 2514 | char wl_wchannel[16]; |
|---|
| 2515 | sprintf (wl_wchannel, "%s_wchannel", prefix); |
|---|
| 2516 | char wl_nbw[16]; |
|---|
| 2517 | sprintf (wl_nbw, "%s_nbw", prefix); |
|---|
| 2518 | |
|---|
| 2519 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 2520 | websWrite (wp, |
|---|
| 2521 | "<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", |
|---|
| 2522 | wl_channel); |
|---|
| 2523 | #ifdef HAVE_MADWIFI |
|---|
| 2524 | struct wifi_channels *chan; |
|---|
| 2525 | char cn[32]; |
|---|
| 2526 | char fr[32]; |
|---|
| 2527 | chan = list_channels (prefix); |
|---|
| 2528 | if (chan == NULL) |
|---|
| 2529 | chan = list_channels (dev); |
|---|
| 2530 | if (chan != NULL) |
|---|
| 2531 | { |
|---|
| 2532 | //int cnt = getchannelcount (); |
|---|
| 2533 | websWrite (wp, |
|---|
| 2534 | "document.write(\"<option value=\\\"0\\\" %s>\" + share.auto + \"</option>\");\n", |
|---|
| 2535 | nvram_match (wl_channel, |
|---|
| 2536 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2537 | int i = 0; |
|---|
| 2538 | while (chan[i].freq != -1) |
|---|
| 2539 | { |
|---|
| 2540 | cprintf ("%d\n", chan[i].channel); |
|---|
| 2541 | cprintf ("%d\n", chan[i].freq); |
|---|
| 2542 | |
|---|
| 2543 | sprintf (cn, "%d", chan[i].channel); |
|---|
| 2544 | sprintf (fr, "%d", chan[i].freq); |
|---|
| 2545 | #ifdef HAVE_XR4SPECIAL |
|---|
| 2546 | char ofs[32]; |
|---|
| 2547 | sprintf (ofs, "%s_offset", prefix); |
|---|
| 2548 | websWrite (wp, |
|---|
| 2549 | "document.write(\"<option value=\\\"%s\\\" %s>%s - %d MHz</option>\");\n", |
|---|
| 2550 | fr, nvram_match (wl_channel, |
|---|
| 2551 | fr) ? "selected=\\\"selected\\\"" : |
|---|
| 2552 | "", cn, |
|---|
| 2553 | chan[i].freq + atoi (nvram_default_get (ofs, "0"))); |
|---|
| 2554 | #else |
|---|
| 2555 | websWrite (wp, |
|---|
| 2556 | "document.write(\"<option value=\\\"%s\\\" %s>%s - %d MHz</option>\");\n", |
|---|
| 2557 | fr, nvram_match (wl_channel, |
|---|
| 2558 | fr) ? "selected=\\\"selected\\\"" : |
|---|
| 2559 | "", cn, (chan[i].freq + get_wifioffset (prefix))); |
|---|
| 2560 | #endif |
|---|
| 2561 | //free (chan[i].freq); |
|---|
| 2562 | i++; |
|---|
| 2563 | } |
|---|
| 2564 | free (chan); |
|---|
| 2565 | } |
|---|
| 2566 | #else |
|---|
| 2567 | int instance = 0; |
|---|
| 2568 | if (!strcmp (prefix, "wl1")) |
|---|
| 2569 | instance = 1; |
|---|
| 2570 | if (type == 1 && !nvram_match (wl_net_mode, "g-only") |
|---|
| 2571 | && !nvram_match (wl_net_mode, "a-only") |
|---|
| 2572 | && !nvram_match (wl_net_mode, "bg-mixed") |
|---|
| 2573 | && nvram_match (wl_nbw, "40")) |
|---|
| 2574 | { |
|---|
| 2575 | int ch = atoi (nvram_nget ("wl%d_wchannel", instance)); |
|---|
| 2576 | websWrite (wp, "var max_channel = 2;\n"); |
|---|
| 2577 | websWrite (wp, "var wl%d_channel = '%s';\n", instance, |
|---|
| 2578 | nvram_safe_get (wl_wchannel)); |
|---|
| 2579 | websWrite (wp, |
|---|
| 2580 | "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"); |
|---|
| 2581 | char *sel = ""; |
|---|
| 2582 | if (nvram_nmatch ("lower", "wl%d_nctrlsb", instance)) |
|---|
| 2583 | sel = "selected"; |
|---|
| 2584 | |
|---|
| 2585 | websWrite (wp, |
|---|
| 2586 | " document.write(\"<option value=%d %s>%d - \"+freq[%d]+\" GHz</option>\");\n", |
|---|
| 2587 | ch - 2, sel, ch - 2, ch - 2); |
|---|
| 2588 | if (nvram_nmatch ("upper", "wl%d_nctrlsb", instance)) |
|---|
| 2589 | sel = "selected"; |
|---|
| 2590 | websWrite (wp, |
|---|
| 2591 | " document.write(\"<option value=%d %s>%d - \"+freq[%d]+\" GHz</option>\");\n", |
|---|
| 2592 | ch + 2, sel, ch + 2, ch + 2); |
|---|
| 2593 | |
|---|
| 2594 | } |
|---|
| 2595 | else |
|---|
| 2596 | { |
|---|
| 2597 | |
|---|
| 2598 | unsigned int chanlist[128]; |
|---|
| 2599 | char *ifn = get_wl_instance_name (instance); |
|---|
| 2600 | int chancount = getchannels (chanlist, ifn); |
|---|
| 2601 | |
|---|
| 2602 | websWrite (wp, "var max_channel = %d;\n", chancount); |
|---|
| 2603 | websWrite (wp, "var wl%d_channel = '%s';\n", instance, |
|---|
| 2604 | nvram_safe_get (wl_channel)); |
|---|
| 2605 | websWrite (wp, "var offset = %d;\n", chanlist[0]); |
|---|
| 2606 | websWrite (wp, "var buf = \"\";\n"); |
|---|
| 2607 | websWrite (wp, "var freq = new Array(\"Auto\""); |
|---|
| 2608 | int i; |
|---|
| 2609 | for (i = 0; i < chancount; i++) |
|---|
| 2610 | { |
|---|
| 2611 | float ofs; |
|---|
| 2612 | if (chanlist[i] < 25) |
|---|
| 2613 | ofs = 2.407f; |
|---|
| 2614 | else |
|---|
| 2615 | ofs = 5.000f; |
|---|
| 2616 | ofs += (float) (chanlist[i] * 0.005f); |
|---|
| 2617 | if (i == 13) //ch = i+1, e.g. i=0 ch=1; i=13 ch=14 |
|---|
| 2618 | ofs = 2.484f; //ch 14 is 2.484, not 2.477 GHz |
|---|
| 2619 | websWrite (wp, ", \"%0.3f\"", ofs); |
|---|
| 2620 | } |
|---|
| 2621 | websWrite (wp, ");\n"); |
|---|
| 2622 | websWrite (wp, "for(i=0; i<=max_channel ; i++) {\n"); |
|---|
| 2623 | websWrite (wp, " if(i == wl%d_channel) buf = \"selected\";\n", |
|---|
| 2624 | instance); |
|---|
| 2625 | websWrite (wp, " else buf = \"\";\n"); |
|---|
| 2626 | websWrite (wp, " if (i==0)\n"); |
|---|
| 2627 | websWrite (wp, |
|---|
| 2628 | " document.write(\"<option value=\"+i+\" \"+buf+\">\" + share.auto + \"</option>\");\n"); |
|---|
| 2629 | websWrite (wp, " else\n"); |
|---|
| 2630 | websWrite (wp, |
|---|
| 2631 | " document.write(\"<option value=\"+i+\" \"+buf+\">\"+(i+offset-1)+\" - \"+freq[i]+\" GHz</option>\");\n"); |
|---|
| 2632 | websWrite (wp, "}\n"); |
|---|
| 2633 | } |
|---|
| 2634 | #endif |
|---|
| 2635 | websWrite (wp, "//]]>\n</script></select></div>\n"); |
|---|
| 2636 | } |
|---|
| 2637 | } |
|---|
| 2638 | |
|---|
| 2639 | #ifdef HAVE_MADWIFI |
|---|
| 2640 | static char *ag_rates[] = { "6", "9", "12", "18", "24", "36", "48", "54" }; |
|---|
| 2641 | static char *turbo_rates[] = |
|---|
| 2642 | { "12", "18", "24", "36", "48", "72", "96", "108" }; |
|---|
| 2643 | static char *b_rates[] = { "1", "2", "5.5", "11" }; |
|---|
| 2644 | static char *bg_rates[] = |
|---|
| 2645 | { "1", "2", "5.5", "6", "9", "11", "12", "18", "24", "36", "48", "54" }; |
|---|
| 2646 | //static char *g_rates[] = { "1", "2", "5.5", "11", "12", "18", "24", "36", "48", "54" }; |
|---|
| 2647 | static char *xr_rates[] = |
|---|
| 2648 | { "0.25", "0.5", "1", "2", "3", "6", "9", "12", "18", "24", "36", "48", |
|---|
| 2649 | "54" |
|---|
| 2650 | }; |
|---|
| 2651 | static char *half_rates[] = { "3", "4.5", "6", "9", "12", "18", "24", "27" }; |
|---|
| 2652 | static char *quarter_rates[] = |
|---|
| 2653 | { "1.5", "2", "3", "4.5", "6", "9", "12", "13.5" }; |
|---|
| 2654 | |
|---|
| 2655 | |
|---|
| 2656 | |
|---|
| 2657 | void |
|---|
| 2658 | show_rates (webs_t wp, char *prefix, int maxrate) |
|---|
| 2659 | { |
|---|
| 2660 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 2661 | if (maxrate) |
|---|
| 2662 | { |
|---|
| 2663 | websWrite (wp, |
|---|
| 2664 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label21)</script></div>\n"); |
|---|
| 2665 | websWrite (wp, "<select name=\"%s_maxrate\">\n", prefix); |
|---|
| 2666 | } |
|---|
| 2667 | else |
|---|
| 2668 | { |
|---|
| 2669 | websWrite (wp, |
|---|
| 2670 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label23)</script></div>\n"); |
|---|
| 2671 | websWrite (wp, "<select name=\"%s_minrate\">\n", prefix); |
|---|
| 2672 | } |
|---|
| 2673 | websWrite (wp, "<script type=\"text/javascript\">\n"); |
|---|
| 2674 | websWrite (wp, "//<![CDATA[\n"); |
|---|
| 2675 | char srate[32]; |
|---|
| 2676 | sprintf (srate, "%s_minrate", prefix); |
|---|
| 2677 | char mxrate[32]; |
|---|
| 2678 | sprintf (mxrate, "%s_maxrate", prefix); |
|---|
| 2679 | websWrite (wp, |
|---|
| 2680 | "document.write(\"<option value=\\\"0\\\" %s >\" + share.auto + \"</option>\");\n", |
|---|
| 2681 | nvram_match (srate, "0") ? "selected" : ""); |
|---|
| 2682 | websWrite (wp, "//]]>\n"); |
|---|
| 2683 | websWrite (wp, "</script>\n"); |
|---|
| 2684 | char **rate; |
|---|
| 2685 | char **showrates = NULL; |
|---|
| 2686 | int len; |
|---|
| 2687 | char turbo[32]; |
|---|
| 2688 | sprintf (turbo, "%s_turbo", prefix); |
|---|
| 2689 | char mode[32]; |
|---|
| 2690 | char bw[16]; |
|---|
| 2691 | sprintf (bw, "%s_channelbw", prefix); |
|---|
| 2692 | |
|---|
| 2693 | sprintf (mode, "%s_net_mode", prefix); |
|---|
| 2694 | if (nvram_match (mode, "b-only")) |
|---|
| 2695 | { |
|---|
| 2696 | rate = b_rates; |
|---|
| 2697 | len = sizeof (b_rates) / sizeof (char *); |
|---|
| 2698 | } |
|---|
| 2699 | if (nvram_match (mode, "g-only")) |
|---|
| 2700 | { |
|---|
| 2701 | rate = ag_rates; |
|---|
| 2702 | len = sizeof (ag_rates) / sizeof (char *); |
|---|
| 2703 | if (nvram_match (turbo, "1")) |
|---|
| 2704 | { |
|---|
| 2705 | showrates = turbo_rates; |
|---|
| 2706 | } |
|---|
| 2707 | if (nvram_match (bw, "10")) |
|---|
| 2708 | { |
|---|
| 2709 | rate = half_rates; |
|---|
| 2710 | len = sizeof (half_rates) / sizeof (char *); |
|---|
| 2711 | } |
|---|
| 2712 | if (nvram_match (bw, "5")) |
|---|
| 2713 | { |
|---|
| 2714 | rate = quarter_rates; |
|---|
| 2715 | len = sizeof (quarter_rates) / sizeof (char *); |
|---|
| 2716 | } |
|---|
| 2717 | } |
|---|
| 2718 | if (nvram_match (mode, "a-only")) |
|---|
| 2719 | { |
|---|
| 2720 | rate = ag_rates; |
|---|
| 2721 | len = sizeof (ag_rates) / sizeof (char *); |
|---|
| 2722 | if (nvram_match (turbo, "1")) |
|---|
| 2723 | { |
|---|
| 2724 | showrates = turbo_rates; |
|---|
| 2725 | } |
|---|
| 2726 | if (nvram_match (bw, "10")) |
|---|
| 2727 | { |
|---|
| 2728 | rate = half_rates; |
|---|
| 2729 | len = sizeof (half_rates) / sizeof (char *); |
|---|
| 2730 | } |
|---|
| 2731 | if (nvram_match (bw, "5")) |
|---|
| 2732 | { |
|---|
| 2733 | rate = quarter_rates; |
|---|
| 2734 | len = sizeof (quarter_rates) / sizeof (char *); |
|---|
| 2735 | } |
|---|
| 2736 | } |
|---|
| 2737 | if (nvram_match (mode, "bg-mixed")) |
|---|
| 2738 | { |
|---|
| 2739 | rate = bg_rates; |
|---|
| 2740 | len = sizeof (bg_rates) / sizeof (char *); |
|---|
| 2741 | if (nvram_match (bw, "10")) |
|---|
| 2742 | { |
|---|
| 2743 | rate = half_rates; |
|---|
| 2744 | len = sizeof (half_rates) / sizeof (char *); |
|---|
| 2745 | } |
|---|
| 2746 | if (nvram_match (bw, "5")) |
|---|
| 2747 | { |
|---|
| 2748 | rate = quarter_rates; |
|---|
| 2749 | len = sizeof (quarter_rates) / sizeof (char *); |
|---|
| 2750 | } |
|---|
| 2751 | } |
|---|
| 2752 | if (nvram_match (mode, "mixed")) |
|---|
| 2753 | { |
|---|
| 2754 | rate = bg_rates; |
|---|
| 2755 | len = sizeof (bg_rates) / sizeof (char *); |
|---|
| 2756 | if (nvram_match (turbo, "1")) |
|---|
| 2757 | { |
|---|
| 2758 | rate = ag_rates; |
|---|
| 2759 | len = sizeof (ag_rates) / sizeof (char *); |
|---|
| 2760 | showrates = turbo_rates; |
|---|
| 2761 | } |
|---|
| 2762 | if (nvram_match (bw, "10")) |
|---|
| 2763 | { |
|---|
| 2764 | rate = half_rates; |
|---|
| 2765 | len = sizeof (half_rates) / sizeof (char *); |
|---|
| 2766 | } |
|---|
| 2767 | if (nvram_match (bw, "5")) |
|---|
| 2768 | { |
|---|
| 2769 | rate = quarter_rates; |
|---|
| 2770 | len = sizeof (quarter_rates) / sizeof (char *); |
|---|
| 2771 | } |
|---|
| 2772 | } |
|---|
| 2773 | int i; |
|---|
| 2774 | for (i = 0; i < len; i++) |
|---|
| 2775 | { |
|---|
| 2776 | if (maxrate) |
|---|
| 2777 | { |
|---|
| 2778 | int offset = 0; |
|---|
| 2779 | if (nvram_match (mode, "g-only") && nvram_match (bw, "20")) |
|---|
| 2780 | offset = 4; |
|---|
| 2781 | char comp[32]; |
|---|
| 2782 | sprintf (comp, "%d", i + 1 + offset); |
|---|
| 2783 | if (showrates) |
|---|
| 2784 | websWrite (wp, "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 2785 | i + 1 + offset, nvram_match (mxrate, |
|---|
| 2786 | comp) ? "selected" : "", |
|---|
| 2787 | showrates[i]); |
|---|
| 2788 | else |
|---|
| 2789 | websWrite (wp, "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 2790 | i + 1 + offset, nvram_match (mxrate, |
|---|
| 2791 | comp) ? "selected" : "", |
|---|
| 2792 | rate[i]); |
|---|
| 2793 | } |
|---|
| 2794 | else |
|---|
| 2795 | { |
|---|
| 2796 | int offset = 0; |
|---|
| 2797 | if (nvram_match (mode, "g-only") && nvram_match (bw, "20")) |
|---|
| 2798 | offset = 4; |
|---|
| 2799 | char comp[32]; |
|---|
| 2800 | sprintf (comp, "%d", i + 1 + offset); |
|---|
| 2801 | if (showrates) |
|---|
| 2802 | websWrite (wp, "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 2803 | i + 1 + offset, nvram_match (srate, |
|---|
| 2804 | comp) ? "selected" : "", |
|---|
| 2805 | showrates[i]); |
|---|
| 2806 | else |
|---|
| 2807 | websWrite (wp, "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 2808 | i + 1 + offset, nvram_match (srate, |
|---|
| 2809 | comp) ? "selected" : "", |
|---|
| 2810 | rate[i]); |
|---|
| 2811 | |
|---|
| 2812 | } |
|---|
| 2813 | } |
|---|
| 2814 | websWrite (wp, "</select>\n"); |
|---|
| 2815 | websWrite (wp, "<span class=\"default\">\n"); |
|---|
| 2816 | websWrite (wp, "<script type=\"text/javascript\">\n"); |
|---|
| 2817 | websWrite (wp, "//<![CDATA[\n"); |
|---|
| 2818 | websWrite (wp, |
|---|
| 2819 | "document.write(\"(\" + share.deflt + \": \" + share.auto + \")\");\n"); |
|---|
| 2820 | websWrite (wp, "//]]\n"); |
|---|
| 2821 | websWrite (wp, "</script></span></div>\n"); |
|---|
| 2822 | |
|---|
| 2823 | |
|---|
| 2824 | } |
|---|
| 2825 | #endif |
|---|
| 2826 | static void |
|---|
| 2827 | show_netmode (webs_t wp, char *prefix) |
|---|
| 2828 | { |
|---|
| 2829 | char wl_net_mode[16]; |
|---|
| 2830 | sprintf (wl_net_mode, "%s_net_mode", prefix); |
|---|
| 2831 | |
|---|
| 2832 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 2833 | websWrite (wp, |
|---|
| 2834 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label2)</script></div><select name=\"%s\" onchange=\"SelWL(this.form.%s.selectedIndex,this.form)\">\n", |
|---|
| 2835 | wl_net_mode, wl_net_mode); |
|---|
| 2836 | websWrite (wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 2837 | websWrite (wp, |
|---|
| 2838 | "document.write(\"<option value=\\\"disabled\\\" %s>\" + share.disabled + \"</option>\");\n", |
|---|
| 2839 | nvram_match (wl_net_mode, |
|---|
| 2840 | "disabled") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2841 | websWrite (wp, |
|---|
| 2842 | "document.write(\"<option value=\\\"mixed\\\" %s>\" + wl_basic.mixed + \"</option>\");\n", |
|---|
| 2843 | nvram_match (wl_net_mode, |
|---|
| 2844 | "mixed") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2845 | if (has_mimo (prefix)) |
|---|
| 2846 | { |
|---|
| 2847 | websWrite (wp, |
|---|
| 2848 | "document.write(\"<option value=\\\"bg-mixed\\\" %s>\" + wl_basic.bg + \"</option>\");\n", |
|---|
| 2849 | nvram_match (wl_net_mode, |
|---|
| 2850 | "bg-mixed") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2851 | } |
|---|
| 2852 | #ifdef HAVE_WHRAG108 |
|---|
| 2853 | if (!strcmp (prefix, "ath1")) |
|---|
| 2854 | #endif |
|---|
| 2855 | #ifdef HAVE_TW6600 |
|---|
| 2856 | if (!strcmp (prefix, "ath1")) |
|---|
| 2857 | #endif |
|---|
| 2858 | websWrite (wp, |
|---|
| 2859 | "document.write(\"<option value=\\\"b-only\\\" %s>\" + wl_basic.b + \"</option>\");\n", |
|---|
| 2860 | nvram_match (wl_net_mode, |
|---|
| 2861 | "b-only") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2862 | #ifdef HAVE_MADWIFI |
|---|
| 2863 | #ifdef HAVE_WHRAG108 |
|---|
| 2864 | if (!strcmp (prefix, "ath1")) |
|---|
| 2865 | #endif |
|---|
| 2866 | #ifdef HAVE_TW6600 |
|---|
| 2867 | if (!strcmp (prefix, "ath1")) |
|---|
| 2868 | #endif |
|---|
| 2869 | websWrite (wp, |
|---|
| 2870 | "document.write(\"<option value=\\\"g-only\\\" %s>\" + wl_basic.g + \"</option>\");\n", |
|---|
| 2871 | nvram_match (wl_net_mode, |
|---|
| 2872 | "g-only") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2873 | #ifdef HAVE_WHRAG108 |
|---|
| 2874 | if (!strcmp (prefix, "ath1")) |
|---|
| 2875 | #endif |
|---|
| 2876 | #ifdef HAVE_TW6600 |
|---|
| 2877 | if (!strcmp (prefix, "ath1")) |
|---|
| 2878 | #endif |
|---|
| 2879 | #ifndef HAVE_LS5 |
|---|
| 2880 | websWrite (wp, |
|---|
| 2881 | "document.write(\"<option value=\\\"bg-mixed\\\" %s>\" + wl_basic.bg + \"</option>\");\n", |
|---|
| 2882 | nvram_match (wl_net_mode, |
|---|
| 2883 | "bg-mixed") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2884 | #endif |
|---|
| 2885 | #else |
|---|
| 2886 | #ifdef HAVE_WHRAG108 |
|---|
| 2887 | if (!strcmp (prefix, "ath1")) |
|---|
| 2888 | #endif |
|---|
| 2889 | #ifndef HAVE_LS5 |
|---|
| 2890 | websWrite (wp, |
|---|
| 2891 | "document.write(\"<option value=\\\"g-only\\\" %s>\" + wl_basic.g + \"</option>\");\n", |
|---|
| 2892 | nvram_match (wl_net_mode, |
|---|
| 2893 | "g-only") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2894 | #endif |
|---|
| 2895 | #endif |
|---|
| 2896 | if (has_mimo (prefix)) |
|---|
| 2897 | { |
|---|
| 2898 | websWrite (wp, |
|---|
| 2899 | "document.write(\"<option value=\\\"n-only\\\" %s>\" + wl_basic.n + \"</option>\");\n", |
|---|
| 2900 | nvram_match (wl_net_mode, |
|---|
| 2901 | "n-only") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2902 | } |
|---|
| 2903 | #if !defined(HAVE_FONERA) && !defined(HAVE_LS2) && !defined(HAVE_MERAKI) |
|---|
| 2904 | #ifndef HAVE_MADWIFI |
|---|
| 2905 | |
|---|
| 2906 | if (nvram_match ("wl0_phytypes", "ga") || nvram_match ("wl0_phytypes", "a")) |
|---|
| 2907 | websWrite (wp, |
|---|
| 2908 | "document.write(\"<option value=\\\"a-only\\\" %s>\" + wl_basic.a + \"</option>\");\n", |
|---|
| 2909 | nvram_match (wl_net_mode, |
|---|
| 2910 | "a-only") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2911 | #else |
|---|
| 2912 | #if HAVE_WHRAG108 |
|---|
| 2913 | if (!strcmp (prefix, "ath0")) |
|---|
| 2914 | #endif |
|---|
| 2915 | #ifdef HAVE_TW6600 |
|---|
| 2916 | if (!strcmp (prefix, "ath0")) |
|---|
| 2917 | #endif |
|---|
| 2918 | websWrite (wp, |
|---|
| 2919 | "document.write(\"<option value=\\\"a-only\\\" %s>\" + wl_basic.a + \"</option>\");\n", |
|---|
| 2920 | nvram_match (wl_net_mode, |
|---|
| 2921 | "a-only") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2922 | #endif |
|---|
| 2923 | |
|---|
| 2924 | #endif |
|---|
| 2925 | websWrite (wp, "//]]>\n</script>\n"); |
|---|
| 2926 | websWrite (wp, "</select>\n"); |
|---|
| 2927 | websWrite (wp, "</div>\n"); |
|---|
| 2928 | } |
|---|
| 2929 | static void |
|---|
| 2930 | showrtssettings (webs_t wp, char *var) |
|---|
| 2931 | { |
|---|
| 2932 | websWrite (wp, |
|---|
| 2933 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.rts)</script></div>\n"); |
|---|
| 2934 | char ssid[32]; |
|---|
| 2935 | char vvar[32]; |
|---|
| 2936 | strcpy (vvar, var); |
|---|
| 2937 | rep (vvar, '.', 'X'); |
|---|
| 2938 | sprintf (ssid, "%s_rts", var); |
|---|
| 2939 | websWrite (wp, |
|---|
| 2940 | "<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.disabled)</script></input> \n", |
|---|
| 2941 | vvar, var, nvram_default_match (ssid, "0", |
|---|
| 2942 | "0") ? "checked=\"checked\"" : |
|---|
| 2943 | ""); |
|---|
| 2944 | websWrite (wp, |
|---|
| 2945 | "<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.enabled)</script></input>\n", |
|---|
| 2946 | vvar, var, nvram_default_match (ssid, "1", |
|---|
| 2947 | "0") ? "checked=\"checked\"" : |
|---|
| 2948 | ""); |
|---|
| 2949 | websWrite (wp, "</div>\n"); |
|---|
| 2950 | |
|---|
| 2951 | websWrite (wp, "<div id=\"%s_idrts\">\n", vvar); |
|---|
| 2952 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 2953 | websWrite (wp, |
|---|
| 2954 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.rtsvalue)</script></div>\n"); |
|---|
| 2955 | char ip[32]; |
|---|
| 2956 | sprintf (ip, "%s_rtsvalue", var); |
|---|
| 2957 | websWrite (wp, |
|---|
| 2958 | "<input class=\"num\" maxlength=\"4\" size=\"4\" onblur=\"valid_range(this,1,2346,share.ip)\" name=\"%s_rtsvalue\" value=\"%s\" />", |
|---|
| 2959 | var, nvram_default_get (ip, "2346")); |
|---|
| 2960 | websWrite (wp, "</div>\n"); |
|---|
| 2961 | websWrite (wp, "</div>\n"); |
|---|
| 2962 | |
|---|
| 2963 | websWrite (wp, "<script>\n//<![CDATA[\n "); |
|---|
| 2964 | websWrite (wp, |
|---|
| 2965 | "show_layer_ext(document.getElementsByName(\"%s_rts\"), \"%s_idrts\", %s);\n", |
|---|
| 2966 | var, vvar, nvram_match (ssid, "1") ? "true" : "false"); |
|---|
| 2967 | websWrite (wp, "//]]>\n</script>\n"); |
|---|
| 2968 | |
|---|
| 2969 | |
|---|
| 2970 | } |
|---|
| 2971 | static void |
|---|
| 2972 | showbridgesettings (webs_t wp, char *var, int mcast) |
|---|
| 2973 | { |
|---|
| 2974 | |
|---|
| 2975 | websWrite (wp, |
|---|
| 2976 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.network)</script></div>\n"); |
|---|
| 2977 | char ssid[32]; |
|---|
| 2978 | sprintf (ssid, "%s_bridged", var); |
|---|
| 2979 | char vvar[32]; |
|---|
| 2980 | strcpy (vvar, var); |
|---|
| 2981 | rep (vvar, '.', 'X'); |
|---|
| 2982 | websWrite (wp, |
|---|
| 2983 | "<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", |
|---|
| 2984 | vvar, var, nvram_default_match (ssid, "0", |
|---|
| 2985 | "1") ? "checked=\"checked\"" : |
|---|
| 2986 | ""); |
|---|
| 2987 | websWrite (wp, |
|---|
| 2988 | "<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", |
|---|
| 2989 | vvar, var, nvram_default_match (ssid, "1", |
|---|
| 2990 | "1") ? "checked=\"checked\"" : |
|---|
| 2991 | ""); |
|---|
| 2992 | websWrite (wp, "</div>\n"); |
|---|
| 2993 | |
|---|
| 2994 | websWrite (wp, "<div id=\"%s_idnetvifs\">\n", vvar); |
|---|
| 2995 | if (mcast) |
|---|
| 2996 | { |
|---|
| 2997 | char mcast[32]; |
|---|
| 2998 | sprintf (mcast, "%s_multicast", var); |
|---|
| 2999 | nvram_default_get (mcast, "0"); |
|---|
| 3000 | showOption (wp, "wl_basic.multicast", mcast); |
|---|
| 3001 | } |
|---|
| 3002 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3003 | websWrite (wp, |
|---|
| 3004 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.ip)</script></div>\n"); |
|---|
| 3005 | char ip[32]; |
|---|
| 3006 | sprintf (ip, "%s_ipaddr", var); |
|---|
| 3007 | char *ipv = nvram_safe_get (ip); |
|---|
| 3008 | websWrite (wp, "<input type=\"hidden\" name=\"%s_ipaddr\" value=\"4\" />\n", |
|---|
| 3009 | var); |
|---|
| 3010 | websWrite (wp, |
|---|
| 3011 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,1,223,share.ip)\" name=\"%s_ipaddr_0\" value=\"%d\" />.", |
|---|
| 3012 | var, get_single_ip (ipv, 0)); |
|---|
| 3013 | websWrite (wp, |
|---|
| 3014 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_1\" value=\"%d\" />.", |
|---|
| 3015 | var, get_single_ip (ipv, 1)); |
|---|
| 3016 | websWrite (wp, |
|---|
| 3017 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_2\" value=\"%d\" />.", |
|---|
| 3018 | var, get_single_ip (ipv, 2)); |
|---|
| 3019 | websWrite (wp, |
|---|
| 3020 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_3\" value=\"%d\" />\n", |
|---|
| 3021 | var, get_single_ip (ipv, 3)); |
|---|
| 3022 | websWrite (wp, "</div>\n"); |
|---|
| 3023 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3024 | websWrite (wp, |
|---|
| 3025 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.subnet)</script></div>\n"); |
|---|
| 3026 | sprintf (ip, "%s_netmask", var); |
|---|
| 3027 | ipv = nvram_safe_get (ip); |
|---|
| 3028 | |
|---|
| 3029 | websWrite (wp, |
|---|
| 3030 | "<input type=\"hidden\" name=\"%s_netmask\" value=\"4\" />\n", |
|---|
| 3031 | var); |
|---|
| 3032 | websWrite (wp, |
|---|
| 3033 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_0\" value=\"%d\" />.", |
|---|
| 3034 | var, get_single_ip (ipv, 0)); |
|---|
| 3035 | websWrite (wp, |
|---|
| 3036 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_1\" value=\"%d\" />.", |
|---|
| 3037 | var, get_single_ip (ipv, 1)); |
|---|
| 3038 | websWrite (wp, |
|---|
| 3039 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_2\" value=\"%d\" />.", |
|---|
| 3040 | var, get_single_ip (ipv, 2)); |
|---|
| 3041 | websWrite (wp, |
|---|
| 3042 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_3\" value=\"%d\" />.", |
|---|
| 3043 | var, get_single_ip (ipv, 3)); |
|---|
| 3044 | websWrite (wp, "</div>\n"); |
|---|
| 3045 | websWrite (wp, "</div>\n"); |
|---|
| 3046 | |
|---|
| 3047 | websWrite (wp, "<script>\n//<![CDATA[\n "); |
|---|
| 3048 | websWrite (wp, |
|---|
| 3049 | "show_layer_ext(document.getElementsByName(\"%s_bridged\"), \"%s_idnetvifs\", %s);\n", |
|---|
| 3050 | var, vvar, nvram_match (ssid, "0") ? "true" : "false"); |
|---|
| 3051 | websWrite (wp, "//]]>\n</script>\n"); |
|---|
| 3052 | |
|---|
| 3053 | } |
|---|
| 3054 | |
|---|
| 3055 | #ifdef HAVE_MADWIFI |
|---|
| 3056 | static void |
|---|
| 3057 | show_chanshift (webs_t * wp, char *wl_chanshift) |
|---|
| 3058 | { |
|---|
| 3059 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3060 | websWrite (wp, |
|---|
| 3061 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.chanshift)</script></div>\n<select name=\"%s\">\n", |
|---|
| 3062 | wl_chanshift); |
|---|
| 3063 | websWrite (wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3064 | websWrite (wp, |
|---|
| 3065 | "document.write(\"<option value=\\\"-1\\\" %s >-1</option>\");\n", |
|---|
| 3066 | nvram_default_match (wl_chanshift, "-1", |
|---|
| 3067 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3068 | websWrite (wp, |
|---|
| 3069 | "document.write(\"<option value=\\\"0\\\" %s >0</option>\");\n", |
|---|
| 3070 | nvram_default_match (wl_chanshift, "0", |
|---|
| 3071 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3072 | websWrite (wp, |
|---|
| 3073 | "document.write(\"<option value=\\\"1\\\" %s >1</option>\");\n", |
|---|
| 3074 | nvram_default_match (wl_chanshift, "1", |
|---|
| 3075 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3076 | websWrite (wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 3077 | |
|---|
| 3078 | } |
|---|
| 3079 | #endif |
|---|
| 3080 | static int |
|---|
| 3081 | show_virtualssid (webs_t wp, char *prefix) |
|---|
| 3082 | { |
|---|
| 3083 | char *next; |
|---|
| 3084 | char var[80]; |
|---|
| 3085 | char ssid[80]; |
|---|
| 3086 | char wmm[32]; |
|---|
| 3087 | char vif[16]; |
|---|
| 3088 | char wl_protmode[32]; |
|---|
| 3089 | #ifdef HAVE_MADWIFI |
|---|
| 3090 | char wl_chanshift[16]; |
|---|
| 3091 | #endif |
|---|
| 3092 | sprintf (vif, "%s_vifs", prefix); |
|---|
| 3093 | char *vifs = nvram_safe_get (vif); |
|---|
| 3094 | if (vifs == NULL) |
|---|
| 3095 | return 0; |
|---|
| 3096 | #ifndef HAVE_MADWIFI |
|---|
| 3097 | if (!nvram_match ("wl0_mode", "ap") && !nvram_match ("wl0_mode", "apsta") |
|---|
| 3098 | && !nvram_match ("wl0_mode", "apstawet")) |
|---|
| 3099 | return 0; |
|---|
| 3100 | #endif |
|---|
| 3101 | int count = 1; |
|---|
| 3102 | websWrite (wp, |
|---|
| 3103 | "<h2><script type=\"text/javascript\">Capture(wl_basic.h2_vi)</script></h2>\n"); |
|---|
| 3104 | foreach (var, vifs, next) |
|---|
| 3105 | { |
|---|
| 3106 | sprintf (ssid, "%s_ssid", var); |
|---|
| 3107 | websWrite (wp, |
|---|
| 3108 | "<fieldset><legend><script type=\"text/javascript\">Capture(share.vintrface)</script> %s SSID [", |
|---|
| 3109 | var); |
|---|
| 3110 | tf_webWriteESCNV (wp, ssid); //fix for broken html page if ssid contains html tag |
|---|
| 3111 | websWrite (wp, "]</legend>\n"); |
|---|
| 3112 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3113 | websWrite (wp, |
|---|
| 3114 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label3)</script></div>\n"); |
|---|
| 3115 | |
|---|
| 3116 | websWrite (wp, |
|---|
| 3117 | "<input name=\"%s_ssid\" size=\"20\" maxlength=\"32\" onblur=\"valid_name(this,wl_basic.label3)\" value=\"%s\" /></div>\n", |
|---|
| 3118 | var, nvram_safe_get (ssid)); |
|---|
| 3119 | |
|---|
| 3120 | #ifdef HAVE_MADWIFI |
|---|
| 3121 | sprintf (wl_chanshift, "%s_chanshift", var); |
|---|
| 3122 | show_chanshift (wp, wl_chanshift); |
|---|
| 3123 | |
|---|
| 3124 | sprintf (wl_protmode, "%s_protmode", var); |
|---|
| 3125 | showOptionsLabel (wp, "wl_basic.protmode", wl_protmode, |
|---|
| 3126 | "None CTS RTS/CTS", nvram_default_get (wl_protmode, |
|---|
| 3127 | "None")); |
|---|
| 3128 | showrtssettings (wp, var); |
|---|
| 3129 | #endif |
|---|
| 3130 | |
|---|
| 3131 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3132 | websWrite (wp, |
|---|
| 3133 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label5)</script></div>"); |
|---|
| 3134 | sprintf (ssid, "%s_closed", var); |
|---|
| 3135 | websWrite (wp, |
|---|
| 3136 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s_closed\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input> \n", |
|---|
| 3137 | var, nvram_match (ssid, "0") ? "checked=\"checked\"" : ""); |
|---|
| 3138 | websWrite (wp, |
|---|
| 3139 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s_closed\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input>\n", |
|---|
| 3140 | var, nvram_match (ssid, "1") ? "checked=\"checked\"" : ""); |
|---|
| 3141 | websWrite (wp, "</div>\n"); |
|---|
| 3142 | char wl_mode[16]; |
|---|
| 3143 | #ifdef HAVE_MADWIFI |
|---|
| 3144 | sprintf (wl_mode, "%s_mode", var); |
|---|
| 3145 | websWrite (wp, |
|---|
| 3146 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label)</script></div><select name=\"%s\" >\n", |
|---|
| 3147 | wl_mode); |
|---|
| 3148 | websWrite (wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3149 | websWrite (wp, |
|---|
| 3150 | "document.write(\"<option value=\\\"ap\\\" %s >\" + wl_basic.ap + \"</option>\");\n", |
|---|
| 3151 | nvram_match (wl_mode, |
|---|
| 3152 | "ap") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3153 | // websWrite (wp, |
|---|
| 3154 | // "document.write(\"<option value=\\\"wdssta\\\" %s >\" + wl_basic.wdssta + \"</option>\");\n", |
|---|
| 3155 | // nvram_match (wl_mode, |
|---|
| 3156 | // "wdssta") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3157 | websWrite (wp, |
|---|
| 3158 | "document.write(\"<option value=\\\"wdsap\\\" %s >\" + wl_basic.wdsap + \"</option>\");\n", |
|---|
| 3159 | nvram_match (wl_mode, |
|---|
| 3160 | "wdsap") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3161 | websWrite (wp, "//]]>\n</script>\n"); |
|---|
| 3162 | websWrite (wp, "</select>\n"); |
|---|
| 3163 | websWrite (wp, "</div>\n"); |
|---|
| 3164 | sprintf (wmm, "%s_wmm", var); |
|---|
| 3165 | showOption (wp, "wl_adv.label18", wmm); |
|---|
| 3166 | #endif |
|---|
| 3167 | sprintf (ssid, "%s_ap_isolate", var); |
|---|
| 3168 | showOption (wp, "wl_adv.label11", ssid); |
|---|
| 3169 | sprintf (wl_mode, "%s_mode", var); |
|---|
| 3170 | showbridgesettings (wp, var, 1); |
|---|
| 3171 | websWrite (wp, "</fieldset><br />\n"); |
|---|
| 3172 | count++; |
|---|
| 3173 | } |
|---|
| 3174 | |
|---|
| 3175 | websWrite (wp, "<div class=\"center\">\n"); |
|---|
| 3176 | #ifdef HAVE_MADWIFI |
|---|
| 3177 | if (count < 8) |
|---|
| 3178 | #else |
|---|
| 3179 | if (count < WL_MAXBSSCFG) |
|---|
| 3180 | #endif |
|---|
| 3181 | websWrite (wp, |
|---|
| 3182 | "<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", |
|---|
| 3183 | prefix); |
|---|
| 3184 | |
|---|
| 3185 | if (count > 1) |
|---|
| 3186 | websWrite (wp, |
|---|
| 3187 | "<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", |
|---|
| 3188 | prefix); |
|---|
| 3189 | |
|---|
| 3190 | websWrite (wp, "</div><br />\n"); |
|---|
| 3191 | |
|---|
| 3192 | return 0; |
|---|
| 3193 | } |
|---|
| 3194 | |
|---|
| 3195 | |
|---|
| 3196 | |
|---|
| 3197 | #endif |
|---|
| 3198 | |
|---|
| 3199 | |
|---|
| 3200 | |
|---|
| 3201 | |
|---|
| 3202 | void |
|---|
| 3203 | ej_showad (webs_t wp, int argc, char_t ** argv) |
|---|
| 3204 | { |
|---|
| 3205 | #ifndef HAVE_FON |
|---|
| 3206 | #ifndef CONFIG_BRANDING |
|---|
| 3207 | #ifdef HAVE_CHILLI |
|---|
| 3208 | // if (nvram_invmatch ("fon_enable", "1")) |
|---|
| 3209 | // websWrite (wp, |
|---|
| 3210 | // "<a href=\"fon.cgi\"><img src=\"images/turn.gif\" border=0 /></a>"); |
|---|
| 3211 | #endif |
|---|
| 3212 | #endif |
|---|
| 3213 | #endif |
|---|
| 3214 | |
|---|
| 3215 | |
|---|
| 3216 | #ifndef HAVE_NOAD |
|---|
| 3217 | /* |
|---|
| 3218 | if (nvram_match("wanup","1")) |
|---|
| 3219 | { |
|---|
| 3220 | websWrite(wp,"<script type=\"text/javascript\"><!--\n//<![CDATA[\n "); |
|---|
| 3221 | websWrite(wp,"google_ad_client = \"pub-8308593183433068\";\n"); |
|---|
| 3222 | websWrite(wp,"google_ad_width = 728;\n"); |
|---|
| 3223 | websWrite(wp,"google_ad_height = 90;\n"); |
|---|
| 3224 | websWrite(wp,"google_ad_format = \"728x90_as\";\n"); |
|---|
| 3225 | websWrite(wp,"google_ad_type = \"text_image\";\n"); |
|---|
| 3226 | websWrite(wp,"google_ad_channel =\"8866414571\";\n"); |
|---|
| 3227 | websWrite(wp,"google_color_border = \"333333\";\n"); |
|---|
| 3228 | websWrite(wp,"google_color_bg = \"000000\";\n"); |
|---|
| 3229 | websWrite(wp,"google_color_link = \"FFFFFF\";\n"); |
|---|
| 3230 | websWrite(wp,"google_color_url = \"999999\";\n"); |
|---|
| 3231 | websWrite(wp,"google_color_text = \"CCCCCC\";\n"); |
|---|
| 3232 | websWrite(wp,"//-->//]]>\n</script>\n"); |
|---|
| 3233 | websWrite(wp,"<script type=\"text/javascript\"\n"); |
|---|
| 3234 | websWrite(wp," src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\n"); |
|---|
| 3235 | websWrite(wp,"</script>\n"); |
|---|
| 3236 | }*/ |
|---|
| 3237 | #endif |
|---|
| 3238 | return; |
|---|
| 3239 | } |
|---|
| 3240 | |
|---|
| 3241 | |
|---|
| 3242 | #ifdef HAVE_MSSID |
|---|
| 3243 | #ifdef HAVE_MADWIFI |
|---|
| 3244 | |
|---|
| 3245 | static int |
|---|
| 3246 | getMaxPower (char *ifname) |
|---|
| 3247 | { |
|---|
| 3248 | sysprintf ("iwlist %s txpower|grep \"Maximum Power:\" > /tmp/.power", |
|---|
| 3249 | ifname); |
|---|
| 3250 | FILE *in = fopen ("/tmp/.power", "rb"); |
|---|
| 3251 | if (in == NULL) |
|---|
| 3252 | return 1000; |
|---|
| 3253 | char buf2[16]; |
|---|
| 3254 | char buf[16]; |
|---|
| 3255 | int max; |
|---|
| 3256 | fscanf (in, "%s %s %d", buf, buf2, &max); |
|---|
| 3257 | fclose (in); |
|---|
| 3258 | return max; |
|---|
| 3259 | } |
|---|
| 3260 | |
|---|
| 3261 | |
|---|
| 3262 | #endif |
|---|
| 3263 | |
|---|
| 3264 | #ifndef HAVE_SUPERCHANNEL |
|---|
| 3265 | int inline |
|---|
| 3266 | issuperchannel (void) |
|---|
| 3267 | { |
|---|
| 3268 | #ifdef HAVE_MR3202A |
|---|
| 3269 | return 0; |
|---|
| 3270 | #elif HAVE_MAKSAT |
|---|
| 3271 | return 1; |
|---|
| 3272 | #else |
|---|
| 3273 | return 0; |
|---|
| 3274 | #endif |
|---|
| 3275 | } |
|---|
| 3276 | #endif |
|---|
| 3277 | |
|---|
| 3278 | void |
|---|
| 3279 | ej_show_countrylist (webs_t wp, int argc, char_t ** argv) |
|---|
| 3280 | { |
|---|
| 3281 | char *name; |
|---|
| 3282 | if (ejArgs (argc, argv, "%s", &name) < 1) |
|---|
| 3283 | { |
|---|
| 3284 | websError (wp, 400, "Insufficient args\n"); |
|---|
| 3285 | return; |
|---|
| 3286 | } |
|---|
| 3287 | char *list = getCountryList (); |
|---|
| 3288 | showOptionsChoose (wp, name, list, nvram_safe_get (name)); |
|---|
| 3289 | } |
|---|
| 3290 | |
|---|
| 3291 | void |
|---|
| 3292 | ej_show_wireless_single (webs_t wp, char *prefix) |
|---|
| 3293 | { |
|---|
| 3294 | char wl_mode[16]; |
|---|
| 3295 | char wl_macaddr[16]; |
|---|
| 3296 | char wl_ssid[16]; |
|---|
| 3297 | sprintf (wl_mode, "%s_mode", prefix); |
|---|
| 3298 | sprintf (wl_macaddr, "%s_hwaddr", prefix); |
|---|
| 3299 | sprintf (wl_ssid, "%s_ssid", prefix); |
|---|
| 3300 | |
|---|
| 3301 | |
|---|
| 3302 | //wireless mode |
|---|
| 3303 | websWrite (wp, |
|---|
| 3304 | "<h2><script type=\"text/javascript\">Capture(wl_basic.h2_v24)</script> %s</h2>\n", |
|---|
| 3305 | prefix); |
|---|
| 3306 | websWrite (wp, "<fieldset>\n"); |
|---|
| 3307 | websWrite (wp, "<legend><script type=\"text/javascript\">Capture(share.pintrface)</script> %s - SSID [", prefix), tf_webWriteESCNV (wp, wl_ssid); //fix for broken html page if ssid contains html tag |
|---|
| 3308 | websWrite (wp, "] HWAddr [%s]</legend>\n", nvram_safe_get (wl_macaddr)); |
|---|
| 3309 | char power[16]; |
|---|
| 3310 | // char maxpower[16]; |
|---|
| 3311 | #ifdef HAVE_MADWIFI |
|---|
| 3312 | char wl_regdomain[16]; |
|---|
| 3313 | sprintf (wl_regdomain, "%s_regdomain", prefix); |
|---|
| 3314 | if (nvram_match ("ath_regulatory", "1") || !issuperchannel ()) |
|---|
| 3315 | { |
|---|
| 3316 | websWrite (wp, |
|---|
| 3317 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.regdom)</script></div>\n"); |
|---|
| 3318 | char *list = getCountryList (); |
|---|
| 3319 | showOptions (wp, wl_regdomain, list, nvram_safe_get (wl_regdomain)); |
|---|
| 3320 | websWrite (wp, "</div>\n"); |
|---|
| 3321 | } |
|---|
| 3322 | /* while (regdomains[domcount].name != NULL) |
|---|
| 3323 | { |
|---|
| 3324 | char domcode[16]; |
|---|
| 3325 | sprintf (domcode, "%d", regdomains[domcount].code); |
|---|
| 3326 | websWrite (wp, "<option value=\"%d\" %s>%s</option>\n", |
|---|
| 3327 | regdomains[domcount].code, nvram_match (wl_regdomain, |
|---|
| 3328 | domcode) ? |
|---|
| 3329 | " selected=\"selected\"" : "", regdomains[domcount].name); |
|---|
| 3330 | domcount++; |
|---|
| 3331 | } |
|---|
| 3332 | websWrite (wp, "</select>\n"); |
|---|
| 3333 | websWrite (wp, "</div>\n");*/ |
|---|
| 3334 | //power adjustment |
|---|
| 3335 | sprintf (power, "%s_txpwrdbm", prefix); |
|---|
| 3336 | // sprintf (maxpower, "%s_maxpower", prefix); |
|---|
| 3337 | if (!strcmp (prefix, "ath0") && issuperchannel ()) //show client only on first interface |
|---|
| 3338 | { |
|---|
| 3339 | |
|---|
| 3340 | websWrite (wp, " <div class=\"setting\">\n"); |
|---|
| 3341 | websWrite (wp, |
|---|
| 3342 | " <div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.regulatory)</script></div>\n"); |
|---|
| 3343 | websWrite (wp, |
|---|
| 3344 | " <input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"ath_regulatory\" %s /><script type=\"text/javascript\">Capture(share.enable)</script> \n", |
|---|
| 3345 | nvram_match ("ath_regulatory", "0") ? "checked" : ""); |
|---|
| 3346 | websWrite (wp, |
|---|
| 3347 | " <input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"ath_regulatory\" %s /><script type=\"text/javascript\">Capture(share.disable)</script>\n", |
|---|
| 3348 | nvram_match ("ath_regulatory", "1") ? "checked" : ""); |
|---|
| 3349 | websWrite (wp, " </div>\n"); |
|---|
| 3350 | |
|---|
| 3351 | } |
|---|
| 3352 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3353 | websWrite (wp, |
|---|
| 3354 | "<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", |
|---|
| 3355 | power, |
|---|
| 3356 | atoi (nvram_safe_get (power)) + wifi_gettxpoweroffset (prefix)); |
|---|
| 3357 | websWrite (wp, "</div>\n"); |
|---|
| 3358 | sprintf (power, "%s_antgain", prefix); |
|---|
| 3359 | #ifndef HAVE_MAKSAT |
|---|
| 3360 | if (nvram_match ("ath_regulatory", "1")) |
|---|
| 3361 | #endif |
|---|
| 3362 | { |
|---|
| 3363 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3364 | websWrite (wp, |
|---|
| 3365 | "<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", |
|---|
| 3366 | power, nvram_safe_get (power)); |
|---|
| 3367 | websWrite (wp, "</div>\n"); |
|---|
| 3368 | } |
|---|
| 3369 | #endif |
|---|
| 3370 | |
|---|
| 3371 | #ifdef HAVE_MADWIFI |
|---|
| 3372 | // if (!strcmp (prefix, "ath0")) |
|---|
| 3373 | #endif |
|---|
| 3374 | { |
|---|
| 3375 | //#ifdef HAVE_MADWIFI |
|---|
| 3376 | // if (!strcmp (prefix, "ath0")) //show client only on first interface |
|---|
| 3377 | //#endif |
|---|
| 3378 | { |
|---|
| 3379 | #ifdef HAVE_MADWIFI |
|---|
| 3380 | // if (!strcmp (prefix, "ath0")) //show client only on first interface |
|---|
| 3381 | // if (nvram_match ("ath0_mode", "wdsap") |
|---|
| 3382 | // || nvram_match ("ath0_mode", "wdssta")) |
|---|
| 3383 | // showOption (wp, "wl_basic.wifi_bonding", "wifi_bonding"); |
|---|
| 3384 | #endif |
|---|
| 3385 | websWrite (wp, |
|---|
| 3386 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label)</script></div><select name=\"%s\" >\n", |
|---|
| 3387 | wl_mode); |
|---|
| 3388 | websWrite (wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3389 | websWrite (wp, |
|---|
| 3390 | "document.write(\"<option value=\\\"ap\\\" %s >\" + wl_basic.ap + \"</option>\");\n", |
|---|
| 3391 | nvram_match (wl_mode, |
|---|
| 3392 | "ap") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3393 | websWrite (wp, |
|---|
| 3394 | "document.write(\"<option value=\\\"sta\\\" %s >\" + wl_basic.client + \"</option>\");\n", |
|---|
| 3395 | nvram_match (wl_mode, |
|---|
| 3396 | "sta") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3397 | websWrite (wp, |
|---|
| 3398 | "document.write(\"<option value=\\\"wet\\\" %s >\" + wl_basic.clientBridge + \"</option>\");\n", |
|---|
| 3399 | nvram_match (wl_mode, |
|---|
| 3400 | "wet") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3401 | websWrite (wp, |
|---|
| 3402 | "document.write(\"<option value=\\\"infra\\\" %s >\" + wl_basic.adhoc + \"</option>\");\n", |
|---|
| 3403 | nvram_match (wl_mode, |
|---|
| 3404 | "infra") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3405 | #ifndef HAVE_MADWIFI |
|---|
| 3406 | websWrite (wp, |
|---|
| 3407 | "document.write(\"<option value=\\\"apsta\\\" %s >\" + wl_basic.repeater + \"</option>\");\n", |
|---|
| 3408 | nvram_match (wl_mode, |
|---|
| 3409 | "apsta") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3410 | websWrite (wp, |
|---|
| 3411 | "document.write(\"<option value=\\\"apstawet\\\" %s >\" + wl_basic.repeaterbridge + \"</option>\");\n", |
|---|
| 3412 | nvram_match (wl_mode, |
|---|
| 3413 | "apstawet") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3414 | #else |
|---|
| 3415 | websWrite (wp, |
|---|
| 3416 | "document.write(\"<option value=\\\"wdssta\\\" %s >\" + wl_basic.wdssta + \"</option>\");\n", |
|---|
| 3417 | nvram_match (wl_mode, |
|---|
| 3418 | "wdssta") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3419 | websWrite (wp, |
|---|
| 3420 | "document.write(\"<option value=\\\"wdsap\\\" %s >\" + wl_basic.wdsap + \"</option>\");\n", |
|---|
| 3421 | nvram_match (wl_mode, |
|---|
| 3422 | "wdsap") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3423 | #endif |
|---|
| 3424 | websWrite (wp, "//]]>\n</script>\n"); |
|---|
| 3425 | websWrite (wp, "</select>\n"); |
|---|
| 3426 | websWrite (wp, "</div>\n"); |
|---|
| 3427 | } |
|---|
| 3428 | /*#ifdef HAVE_MADWIFI |
|---|
| 3429 | else |
|---|
| 3430 | { |
|---|
| 3431 | |
|---|
| 3432 | |
|---|
| 3433 | websWrite (wp, |
|---|
| 3434 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label)</script></div><select name=\"%s\">\n", |
|---|
| 3435 | wl_mode); |
|---|
| 3436 | websWrite (wp, |
|---|
| 3437 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"ap\\\" %s >\" + wl_basic.ap + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 3438 | nvram_match (wl_mode, |
|---|
| 3439 | "ap") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3440 | websWrite (wp, |
|---|
| 3441 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"infra\\\" %s >\" + wl_basic.adhoc + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 3442 | nvram_match (wl_mode, |
|---|
| 3443 | "infra") ? "selected=\\\"selected\\\"" : |
|---|
| 3444 | ""); |
|---|
| 3445 | websWrite (wp, |
|---|
| 3446 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"wdssta\\\" %s >\" + wl_basic.wdssta + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 3447 | nvram_match (wl_mode, |
|---|
| 3448 | "wdssta") ? "selected=\\\"selected\\\"" : |
|---|
| 3449 | ""); |
|---|
| 3450 | websWrite (wp, |
|---|
| 3451 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"wdsap\\\" %s >\" + wl_basic.wdsap + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 3452 | nvram_match (wl_mode, |
|---|
| 3453 | "wdsap") ? "selected=\\\"selected\\\"" : |
|---|
| 3454 | ""); |
|---|
| 3455 | websWrite (wp, "</select>\n"); |
|---|
| 3456 | websWrite (wp, "</div>\n"); |
|---|
| 3457 | } |
|---|
| 3458 | #endif*/ |
|---|
| 3459 | } |
|---|
| 3460 | //writeless net mode |
|---|
| 3461 | show_netmode (wp, prefix); |
|---|
| 3462 | //turbo options |
|---|
| 3463 | #ifdef HAVE_MADWIFI |
|---|
| 3464 | char wl_turbo[16]; |
|---|
| 3465 | // char wl_xchanmode[16]; |
|---|
| 3466 | char wl_outdoor[16]; |
|---|
| 3467 | char wl_chanshift[16]; |
|---|
| 3468 | char wl_diversity[16]; |
|---|
| 3469 | char wl_rxantenna[16]; |
|---|
| 3470 | char wl_txantenna[16]; |
|---|
| 3471 | char wl_width[16]; |
|---|
| 3472 | char wl_preamble[16]; |
|---|
| 3473 | char wl_xr[16]; |
|---|
| 3474 | char wl_comp[32]; |
|---|
| 3475 | char wl_ff[16]; |
|---|
| 3476 | char wmm[32]; |
|---|
| 3477 | char wl_isolate[32]; |
|---|
| 3478 | char wl_sifstime[32]; |
|---|
| 3479 | char wl_preambletime[32]; |
|---|
| 3480 | char wl_intmit[32]; |
|---|
| 3481 | char wl_noise_immunity[32]; |
|---|
| 3482 | char wl_ofdm_weak_det[32]; |
|---|
| 3483 | char wl_protmode[32]; |
|---|
| 3484 | sprintf (wl_protmode, "%s_protmode", prefix); |
|---|
| 3485 | sprintf (wl_chanshift, "%s_chanshift", prefix); |
|---|
| 3486 | sprintf (wl_turbo, "%s_turbo", prefix); |
|---|
| 3487 | sprintf (wl_outdoor, "%s_outdoor", prefix); |
|---|
| 3488 | sprintf (wl_diversity, "%s_diversity", prefix); |
|---|
| 3489 | sprintf (wl_rxantenna, "%s_rxantenna", prefix); |
|---|
| 3490 | sprintf (wl_txantenna, "%s_txantenna", prefix); |
|---|
| 3491 | sprintf (wl_width, "%s_channelbw", prefix); |
|---|
| 3492 | sprintf (wl_comp, "%s_compression", prefix); |
|---|
| 3493 | sprintf (wl_ff, "%s_ff", prefix); |
|---|
| 3494 | sprintf (wl_preamble, "%s_preamble", prefix); |
|---|
| 3495 | sprintf (wl_preambletime, "%s_preambletime", prefix); |
|---|
| 3496 | sprintf (wl_sifstime, "%s_sifstime", prefix); |
|---|
| 3497 | sprintf (wl_xr, "%s_xr", prefix); |
|---|
| 3498 | |
|---|
| 3499 | sprintf (wl_intmit, "%s_intmit", prefix); |
|---|
| 3500 | sprintf (wl_noise_immunity, "%s_noise_immunity", prefix); |
|---|
| 3501 | sprintf (wl_ofdm_weak_det, "%s_ofdm_weak_det", prefix); |
|---|
| 3502 | showAutoOption (wp, "wl_basic.intmit", wl_intmit); |
|---|
| 3503 | |
|---|
| 3504 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3505 | websWrite (wp, |
|---|
| 3506 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.noise_immunity)</script></div>\n<select name=\"%s\">\n", |
|---|
| 3507 | wl_noise_immunity); |
|---|
| 3508 | websWrite (wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3509 | websWrite (wp, |
|---|
| 3510 | "document.write(\"<option value=\\\"-1\\\" %s >\" + share.auto + \"</option>\");\n", |
|---|
| 3511 | nvram_default_match (wl_noise_immunity, "-1", |
|---|
| 3512 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3513 | websWrite (wp, |
|---|
| 3514 | "document.write(\"<option value=\\\"0\\\" %s >0</option>\");\n", |
|---|
| 3515 | nvram_default_match (wl_noise_immunity, "0", |
|---|
| 3516 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3517 | websWrite (wp, |
|---|
| 3518 | "document.write(\"<option value=\\\"1\\\" %s >1</option>\");\n", |
|---|
| 3519 | nvram_default_match (wl_noise_immunity, "1", |
|---|
| 3520 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3521 | websWrite (wp, |
|---|
| 3522 | "document.write(\"<option value=\\\"2\\\" %s >2</option>\");\n", |
|---|
| 3523 | nvram_default_match (wl_noise_immunity, "2", |
|---|
| 3524 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3525 | websWrite (wp, |
|---|
| 3526 | "document.write(\"<option value=\\\"3\\\" %s >3</option>\");\n", |
|---|
| 3527 | nvram_default_match (wl_noise_immunity, "3", |
|---|
| 3528 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3529 | websWrite (wp, |
|---|
| 3530 | "document.write(\"<option value=\\\"4\\\" %s >4</option>\");\n", |
|---|
| 3531 | nvram_default_match (wl_noise_immunity, "4", |
|---|
| 3532 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3533 | websWrite (wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 3534 | |
|---|
| 3535 | |
|---|
| 3536 | showOption (wp, "wl_basic.ofdm_weak_det", wl_ofdm_weak_det); |
|---|
| 3537 | |
|---|
| 3538 | showOptionsLabel (wp, "wl_basic.protmode", wl_protmode, "None CTS RTS/CTS", |
|---|
| 3539 | nvram_default_get (wl_protmode, "None")); |
|---|
| 3540 | showrtssettings (wp, prefix); |
|---|
| 3541 | show_rates (wp, prefix, 0); |
|---|
| 3542 | show_rates (wp, prefix, 1); |
|---|
| 3543 | //#if !defined(HAVE_FONERA) && !defined(HAVE_LS2) && !defined(HAVE_MERAKI) |
|---|
| 3544 | showRadio (wp, "wl_basic.turbo", wl_turbo); |
|---|
| 3545 | //#endif |
|---|
| 3546 | showRadio (wp, "wl_basic.preamble", wl_preamble); |
|---|
| 3547 | showRadio (wp, "wl_basic.extrange", wl_xr); |
|---|
| 3548 | showRadio (wp, "wl_basic.supergcomp", wl_comp); |
|---|
| 3549 | showRadio (wp, "wl_basic.supergff", wl_ff); |
|---|
| 3550 | |
|---|
| 3551 | |
|---|
| 3552 | // showOption (wp, "wl_basic.extchannel", wl_xchanmode); |
|---|
| 3553 | #if !defined(HAVE_FONERA) && !defined(HAVE_LS2) && !defined(HAVE_MERAKI) |
|---|
| 3554 | if (nvram_match ("ath_regulatory", "1") || !issuperchannel ()) |
|---|
| 3555 | { |
|---|
| 3556 | showRadio (wp, "wl_basic.outband", wl_outdoor); |
|---|
| 3557 | } |
|---|
| 3558 | #endif |
|---|
| 3559 | websWrite (wp, |
|---|
| 3560 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_width)</script></div><select name=\"%s\" >\n", |
|---|
| 3561 | wl_width); |
|---|
| 3562 | websWrite (wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3563 | websWrite (wp, |
|---|
| 3564 | "document.write(\"<option value=\\\"20\\\" %s >\" + share.full + \"</option>\");\n", |
|---|
| 3565 | nvram_match (wl_width, "20") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3566 | websWrite (wp, |
|---|
| 3567 | "document.write(\"<option value=\\\"10\\\" %s >\" + share.half + \"</option>\");\n", |
|---|
| 3568 | nvram_match (wl_width, "10") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3569 | websWrite (wp, |
|---|
| 3570 | "document.write(\"<option value=\\\"5\\\" %s >\" + share.quarter + \"</option>\");\n", |
|---|
| 3571 | nvram_match (wl_width, "5") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3572 | websWrite (wp, "//]]>\n</script>\n"); |
|---|
| 3573 | websWrite (wp, "</select>\n"); |
|---|
| 3574 | websWrite (wp, "</div>\n"); |
|---|
| 3575 | |
|---|
| 3576 | #if defined(HAVE_NS2) || defined(HAVE_NS5) |
|---|
| 3577 | |
|---|
| 3578 | websWrite (wp, |
|---|
| 3579 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label24)</script></div><select name=\"%s\" >\n", |
|---|
| 3580 | wl_txantenna); |
|---|
| 3581 | websWrite (wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3582 | websWrite (wp, |
|---|
| 3583 | "document.write(\"<option value=\\\"0\\\" %s >\" + wl_basic.vertical + \"</option>\");\n", |
|---|
| 3584 | nvram_match (wl_txantenna, |
|---|
| 3585 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3586 | websWrite (wp, |
|---|
| 3587 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.horizontal + \"</option>\");\n", |
|---|
| 3588 | nvram_match (wl_txantenna, |
|---|
| 3589 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3590 | websWrite (wp, |
|---|
| 3591 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.adaptive + \"</option>\");\n", |
|---|
| 3592 | nvram_match (wl_txantenna, |
|---|
| 3593 | "3") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3594 | websWrite (wp, |
|---|
| 3595 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.external + \"</option>\");\n", |
|---|
| 3596 | nvram_match (wl_txantenna, |
|---|
| 3597 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3598 | websWrite (wp, "//]]>\n</script>\n"); |
|---|
| 3599 | websWrite (wp, "</select>\n"); |
|---|
| 3600 | websWrite (wp, "</div>\n"); |
|---|
| 3601 | |
|---|
| 3602 | |
|---|
| 3603 | |
|---|
| 3604 | |
|---|
| 3605 | #else |
|---|
| 3606 | showRadio (wp, "wl_basic.diversity", wl_diversity); |
|---|
| 3607 | websWrite (wp, |
|---|
| 3608 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label12)</script></div><select name=\"%s\" >\n", |
|---|
| 3609 | wl_txantenna); |
|---|
| 3610 | websWrite (wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3611 | websWrite (wp, |
|---|
| 3612 | "document.write(\"<option value=\\\"0\\\" %s >\" + wl_basic.diversity + \"</option>\");\n", |
|---|
| 3613 | nvram_match (wl_txantenna, |
|---|
| 3614 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3615 | websWrite (wp, |
|---|
| 3616 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.primary + \"</option>\");\n", |
|---|
| 3617 | nvram_match (wl_txantenna, |
|---|
| 3618 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3619 | websWrite (wp, |
|---|
| 3620 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.secondary + \"</option>\");\n", |
|---|
| 3621 | nvram_match (wl_txantenna, |
|---|
| 3622 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3623 | websWrite (wp, "//]]>\n</script>\n"); |
|---|
| 3624 | websWrite (wp, "</select>\n"); |
|---|
| 3625 | websWrite (wp, "</div>\n"); |
|---|
| 3626 | |
|---|
| 3627 | websWrite (wp, |
|---|
| 3628 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label13)</script></div><select name=\"%s\" >\n", |
|---|
| 3629 | wl_rxantenna); |
|---|
| 3630 | websWrite (wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3631 | websWrite (wp, |
|---|
| 3632 | "document.write(\"<option value=\\\"0\\\" %s >\" + wl_basic.diversity + \"</option>\");\n", |
|---|
| 3633 | nvram_match (wl_rxantenna, |
|---|
| 3634 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3635 | websWrite (wp, |
|---|
| 3636 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.primary + \"</option>\");\n", |
|---|
| 3637 | nvram_match (wl_rxantenna, |
|---|
| 3638 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3639 | websWrite (wp, |
|---|
| 3640 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.secondary + \"</option>\");\n", |
|---|
| 3641 | nvram_match (wl_rxantenna, |
|---|
| 3642 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3643 | websWrite (wp, "//]]>\n</script>\n"); |
|---|
| 3644 | websWrite (wp, "</select>\n"); |
|---|
| 3645 | websWrite (wp, "</div>\n"); |
|---|
| 3646 | #endif |
|---|
| 3647 | #endif |
|---|
| 3648 | #ifdef HAVE_MADWIFI |
|---|
| 3649 | sprintf (wl_isolate, "%s_ap_isolate", prefix); |
|---|
| 3650 | showRadio (wp, "wl_adv.label11", wl_isolate); |
|---|
| 3651 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3652 | websWrite (wp, |
|---|
| 3653 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.sifstime)</script></div>\n"); |
|---|
| 3654 | websWrite (wp, |
|---|
| 3655 | "<input class=\"num\" name=\"%s\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,99999999,wl_basic.sifstime)\" value=\"%s\" />\n", |
|---|
| 3656 | wl_sifstime, nvram_default_get (wl_sifstime, "16")); |
|---|
| 3657 | websWrite (wp, "</div>\n"); |
|---|
| 3658 | |
|---|
| 3659 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3660 | websWrite (wp, |
|---|
| 3661 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.preambletime)</script></div>\n"); |
|---|
| 3662 | websWrite (wp, |
|---|
| 3663 | "<input class=\"num\" name=\"%s\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,99999999,wl_basic.preambletime)\" value=\"%s\" />\n", |
|---|
| 3664 | wl_preambletime, nvram_default_get (wl_preambletime, "20")); |
|---|
| 3665 | websWrite (wp, "</div>\n"); |
|---|
| 3666 | sprintf (wmm, "%s_wmm", prefix); |
|---|
| 3667 | showRadio (wp, "wl_adv.label18", wmm); |
|---|
| 3668 | #endif |
|---|
| 3669 | |
|---|
| 3670 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3671 | websWrite (wp, |
|---|
| 3672 | "<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", |
|---|
| 3673 | wl_ssid, nvram_safe_get (wl_ssid)); |
|---|
| 3674 | |
|---|
| 3675 | #ifdef HAVE_MADWIFI |
|---|
| 3676 | show_chanshift (wp, wl_chanshift); |
|---|
| 3677 | #endif |
|---|
| 3678 | if (nvram_match (wl_mode, "ap") || nvram_match (wl_mode, "wdsap") |
|---|
| 3679 | || nvram_match (wl_mode, "infra")) |
|---|
| 3680 | { |
|---|
| 3681 | |
|---|
| 3682 | if (has_mimo (prefix) |
|---|
| 3683 | && (nvram_nmatch ("n-only", "%s_net_mode", prefix) |
|---|
| 3684 | || nvram_nmatch ("mixed," "%s_net_mode", prefix))) |
|---|
| 3685 | { |
|---|
| 3686 | |
|---|
| 3687 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3688 | websWrite (wp, |
|---|
| 3689 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_width)</script></div>\n"); |
|---|
| 3690 | websWrite (wp, "<select name=\"wl0_nbw\">\n"); |
|---|
| 3691 | websWrite (wp, |
|---|
| 3692 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"0\\\" %s >\" + share.auto + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 3693 | nvram_match ("wl0_nbw", |
|---|
| 3694 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3695 | websWrite (wp, "<option value=\"10\" %s>10 MHz</option>", |
|---|
| 3696 | nvram_match ("wl0_nbw", |
|---|
| 3697 | "10") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3698 | websWrite (wp, "<option value=\"20\" %s>20 MHz</option>", |
|---|
| 3699 | nvram_match ("wl0_nbw", |
|---|
| 3700 | "20") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3701 | websWrite (wp, "<option value=\"40\" %s>40 MHz</option>", |
|---|
| 3702 | nvram_match ("wl0_nbw", |
|---|
| 3703 | "40") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3704 | websWrite (wp, "</select>\n"); |
|---|
| 3705 | websWrite (wp, "</div>\n"); |
|---|
| 3706 | |
|---|
| 3707 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3708 | websWrite (wp, |
|---|
| 3709 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_wide)</script></div>\n"); |
|---|
| 3710 | websWrite (wp, "<select name=\"wl0_wchannel\" ></select>\n"); |
|---|
| 3711 | websWrite (wp, "</div>\n"); |
|---|
| 3712 | |
|---|
| 3713 | show_channel (wp, prefix, prefix, 1); |
|---|
| 3714 | } |
|---|
| 3715 | else |
|---|
| 3716 | |
|---|
| 3717 | show_channel (wp, prefix, prefix, 0); |
|---|
| 3718 | |
|---|
| 3719 | char wl_closed[16]; |
|---|
| 3720 | sprintf (wl_closed, "%s_closed", prefix); |
|---|
| 3721 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3722 | websWrite (wp, |
|---|
| 3723 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label5)</script></div>\n"); |
|---|
| 3724 | websWrite (wp, |
|---|
| 3725 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input> \n", |
|---|
| 3726 | wl_closed, nvram_match (wl_closed, |
|---|
| 3727 | "0") ? "checked=\"checked\"" : ""); |
|---|
| 3728 | websWrite (wp, |
|---|
| 3729 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input>\n", |
|---|
| 3730 | wl_closed, nvram_match (wl_closed, |
|---|
| 3731 | "1") ? "checked=\"checked\"" : ""); |
|---|
| 3732 | websWrite (wp, "</div>\n"); |
|---|
| 3733 | } |
|---|
| 3734 | #ifdef HAVE_MADWIFI |
|---|
| 3735 | // if (nvram_match (wl_mode, "sta") || nvram_match (wl_mode, "wdssta") |
|---|
| 3736 | // || nvram_match (wl_mode, "wet")) |
|---|
| 3737 | { |
|---|
| 3738 | char wl_scanlist[32]; |
|---|
| 3739 | sprintf (wl_scanlist, "%s_scanlist", prefix); |
|---|
| 3740 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3741 | websWrite (wp, |
|---|
| 3742 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.scanlist)</script></div>\n"); |
|---|
| 3743 | websWrite (wp, |
|---|
| 3744 | "<input name=\"%s\" size=\"32\" maxlength=\"512\" value=\"%s\" />\n", |
|---|
| 3745 | wl_scanlist, nvram_default_get (wl_scanlist, "default")); |
|---|
| 3746 | websWrite (wp, "</div>\n"); |
|---|
| 3747 | } |
|---|
| 3748 | #endif |
|---|
| 3749 | |
|---|
| 3750 | // ACK timing |
|---|
| 3751 | #if defined(HAVE_ACK) || defined(HAVE_MADWIFI) //temp fix for v24 broadcom ACKnot working |
|---|
| 3752 | |
|---|
| 3753 | sprintf (power, "%s_distance", prefix); |
|---|
| 3754 | websWrite (wp, "<br />\n"); |
|---|
| 3755 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3756 | websWrite (wp, |
|---|
| 3757 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label6)</script></div>\n"); |
|---|
| 3758 | websWrite (wp, |
|---|
| 3759 | "<input class=\"num\" name=\"%s\" size=\"8\" maxlength=\"8\" onblur=\"valid_range(this,0,99999999,wl_basic.label6)\" value=\"%s\" />\n", |
|---|
| 3760 | power, nvram_default_get (power, "2000")); |
|---|
| 3761 | websWrite (wp, |
|---|
| 3762 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 2000 \" + share.meters + \")\");\n//]]>\n</script></span>\n"); |
|---|
| 3763 | websWrite (wp, "</div>\n"); |
|---|
| 3764 | // end ACK timing |
|---|
| 3765 | #endif |
|---|
| 3766 | #ifdef HAVE_MADWIFI |
|---|
| 3767 | showbridgesettings (wp, prefix, 1); |
|---|
| 3768 | #else |
|---|
| 3769 | if (!strcmp (prefix, "wl0")) |
|---|
| 3770 | showbridgesettings (wp, get_wl_instance_name (0), 1); |
|---|
| 3771 | if (!strcmp (prefix, "wl1")) |
|---|
| 3772 | showbridgesettings (wp, get_wl_instance_name (1), 1); |
|---|
| 3773 | #endif |
|---|
| 3774 | websWrite (wp, "</fieldset>\n"); |
|---|
| 3775 | websWrite (wp, "<br />\n"); |
|---|
| 3776 | show_virtualssid (wp, prefix); |
|---|
| 3777 | } |
|---|
| 3778 | |
|---|
| 3779 | void |
|---|
| 3780 | ej_show_wireless (webs_t wp, int argc, char_t ** argv) |
|---|
| 3781 | { |
|---|
| 3782 | #ifdef HAVE_MADWIFI |
|---|
| 3783 | int c = getdevicecount (); |
|---|
| 3784 | int i; |
|---|
| 3785 | for (i = 0; i < c; i++) |
|---|
| 3786 | { |
|---|
| 3787 | char buf[16]; |
|---|
| 3788 | sprintf (buf, "ath%d", i); |
|---|
| 3789 | ej_show_wireless_single (wp, buf); |
|---|
| 3790 | } |
|---|
| 3791 | #else |
|---|
| 3792 | int c = get_wl_instances (); |
|---|
| 3793 | int i; |
|---|
| 3794 | for (i = 0; i < c; i++) |
|---|
| 3795 | { |
|---|
| 3796 | char buf[16]; |
|---|
| 3797 | sprintf (buf, "wl%d", i); |
|---|
| 3798 | ej_show_wireless_single (wp, buf); |
|---|
| 3799 | } |
|---|
| 3800 | #endif |
|---|
| 3801 | return; |
|---|
| 3802 | } |
|---|
| 3803 | |
|---|
| 3804 | |
|---|
| 3805 | void |
|---|
| 3806 | show_preshared (webs_t wp, char *prefix) |
|---|
| 3807 | { |
|---|
| 3808 | char var[80]; |
|---|
| 3809 | cprintf ("show preshared"); |
|---|
| 3810 | sprintf (var, "%s_crypto", prefix); |
|---|
| 3811 | websWrite (wp, "<div><div class=\"setting\">\n"); |
|---|
| 3812 | websWrite (wp, |
|---|
| 3813 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.algorithms)</script></div>\n"); |
|---|
| 3814 | websWrite (wp, "<select name=\"%s_crypto\">\n", prefix); |
|---|
| 3815 | websWrite (wp, "<option value=\"tkip\" %s>TKIP</option>\n", |
|---|
| 3816 | selmatch (var, "tkip", "selected=\"selected\"")); |
|---|
| 3817 | websWrite (wp, "<option value=\"aes\" %s>AES</option>\n", |
|---|
| 3818 | selmatch (var, "aes", "selected=\"selected\"")); |
|---|
| 3819 | websWrite (wp, "<option value=\"tkip+aes\" %s>TKIP+AES</option>\n", |
|---|
| 3820 | selmatch (var, "tkip+aes", "selected=\"selected\"")); |
|---|
| 3821 | websWrite (wp, "</select>\n"); |
|---|
| 3822 | websWrite (wp, "</div>\n"); |
|---|
| 3823 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3824 | websWrite (wp, |
|---|
| 3825 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.shared_key)</script></div>\n"); |
|---|
| 3826 | sprintf (var, "%s_wpa_psk", prefix); |
|---|
| 3827 | websWrite (wp, |
|---|
| 3828 | "<input type=\"password\" id=\"%s_wpa_psk\" name=\"%s_wpa_psk\" onblur=\"valid_psk_length(this)\" maxlength=\"64\" size=\"32\" value=\"", |
|---|
| 3829 | prefix, prefix); |
|---|
| 3830 | tf_webWriteESCNV (wp, var); |
|---|
| 3831 | websWrite (wp, "\" /> \n"); |
|---|
| 3832 | websWrite (wp, |
|---|
| 3833 | "<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", |
|---|
| 3834 | prefix, prefix); |
|---|
| 3835 | websWrite (wp, "</div>\n"); |
|---|
| 3836 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3837 | websWrite (wp, |
|---|
| 3838 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.rekey)</script></div>\n"); |
|---|
| 3839 | sprintf (var, "%s_wpa_gtk_rekey", prefix); |
|---|
| 3840 | websWrite (wp, |
|---|
| 3841 | "<input class=\"num\" name=\"%s_wpa_gtk_rekey\" maxlength=\"5\" size=\"5\" onblur=\"valid_range(this,0,99999,wpa.rekey)\" value=\"%s\" />\n", |
|---|
| 3842 | prefix, nvram_default_get (var, "3600")); |
|---|
| 3843 | websWrite (wp, |
|---|
| 3844 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 3600, \" + share.range + \": 1 - 99999)\");\n//]]>\n</script></span>\n"); |
|---|
| 3845 | websWrite (wp, "</div>\n"); |
|---|
| 3846 | websWrite (wp, "</div>\n"); |
|---|
| 3847 | } |
|---|
| 3848 | |
|---|
| 3849 | void |
|---|
| 3850 | show_radius (webs_t wp, char *prefix, int showmacformat) |
|---|
| 3851 | { |
|---|
| 3852 | char var[80]; |
|---|
| 3853 | cprintf ("show radius\n"); |
|---|
| 3854 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3855 | websWrite (wp, |
|---|
| 3856 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label3)</script></div>\n"); |
|---|
| 3857 | websWrite (wp, |
|---|
| 3858 | "<input type=\"hidden\" name=\"%s_radius_ipaddr\" value=\"4\" />\n", |
|---|
| 3859 | prefix); |
|---|
| 3860 | sprintf (var, "%s_radius_ipaddr", prefix); |
|---|
| 3861 | char *rad = nvram_safe_get (var); |
|---|
| 3862 | websWrite (wp, |
|---|
| 3863 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_0\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%d\" />.", |
|---|
| 3864 | prefix, get_single_ip (rad, 0)); |
|---|
| 3865 | websWrite (wp, |
|---|
| 3866 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_1\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%d\" />.", |
|---|
| 3867 | prefix, get_single_ip (rad, 1)); |
|---|
| 3868 | websWrite (wp, |
|---|
| 3869 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_2\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%d\" />.", |
|---|
| 3870 | prefix, get_single_ip (rad, 2)); |
|---|
| 3871 | websWrite (wp, |
|---|
| 3872 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_3\" onblur=\"valid_range(this,1,254,radius.label3)\" class=\"num\" value=\"%d\" />\n", |
|---|
| 3873 | prefix, get_single_ip (rad, 3)); |
|---|
| 3874 | websWrite (wp, "</div>\n"); |
|---|
| 3875 | if (showmacformat) |
|---|
| 3876 | { |
|---|
| 3877 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3878 | websWrite (wp, |
|---|
| 3879 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label2)</script></div>\n"); |
|---|
| 3880 | websWrite (wp, "<select name=\"%s_radmactype\">\n", prefix); |
|---|
| 3881 | websWrite (wp, "<option value=\"0\" %s >aabbcc-ddeeff</option>\n", |
|---|
| 3882 | nvram_prefix_match ("radmactype", prefix, |
|---|
| 3883 | "0") ? "selected" : ""); |
|---|
| 3884 | websWrite (wp, "<option value=\"1\" %s >aabbccddeeff</option>\n", |
|---|
| 3885 | nvram_prefix_match ("radmactype", prefix, |
|---|
| 3886 | "1") ? "selected" : ""); |
|---|
| 3887 | websWrite (wp, "<option value=\"2\" %s >aa:bb:cc:dd:ee:ff</option>\n", |
|---|
| 3888 | nvram_prefix_match ("radmactype", prefix, |
|---|
| 3889 | "2") ? "selected" : ""); |
|---|
| 3890 | websWrite (wp, "<option value=\"3\" %s >aa-bb-cc-dd-ee-ff</option>\n", |
|---|
| 3891 | nvram_prefix_match ("radmactype", prefix, |
|---|
| 3892 | "3") ? "selected" : ""); |
|---|
| 3893 | websWrite (wp, "</select>\n"); |
|---|
| 3894 | websWrite (wp, "</div>\n"); |
|---|
| 3895 | } |
|---|
| 3896 | |
|---|
| 3897 | |
|---|
| 3898 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3899 | websWrite (wp, |
|---|
| 3900 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label4)</script></div>\n"); |
|---|
| 3901 | sprintf (var, "%s_radius_port", prefix); |
|---|
| 3902 | websWrite (wp, |
|---|
| 3903 | "<input name=\"%s_radius_port\" size=\"3\" maxlength=\"5\" onblur=\"valid_range(this,1,65535,radius.label4)\" value=\"%s\" />\n", |
|---|
| 3904 | prefix, nvram_default_get (var, "1812")); |
|---|
| 3905 | websWrite (wp, |
|---|
| 3906 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 1812)\");\n//]]>\n</script></span>\n</div>\n"); |
|---|
| 3907 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3908 | websWrite (wp, |
|---|
| 3909 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label7)</script></div>\n"); |
|---|
| 3910 | sprintf (var, "%s_radius_key", prefix); |
|---|
| 3911 | websWrite (wp, |
|---|
| 3912 | "<input type=\"password\" id=\"%s_radius_key\" name=\"%s_radius_key\" maxlength=\"79\" size=\"32\" value=\"", |
|---|
| 3913 | prefix, prefix); |
|---|
| 3914 | tf_webWriteESCNV (wp, var); |
|---|
| 3915 | websWrite (wp, "\" /> \n"); |
|---|
| 3916 | websWrite (wp, |
|---|
| 3917 | "<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", |
|---|
| 3918 | prefix, prefix); |
|---|
| 3919 | websWrite (wp, "</div>\n"); |
|---|
| 3920 | |
|---|
| 3921 | } |
|---|
| 3922 | |
|---|
| 3923 | |
|---|
| 3924 | |
|---|
| 3925 | #ifdef HAVE_WPA_SUPPLICANT |
|---|
| 3926 | void |
|---|
| 3927 | show_80211X (webs_t wp, char *prefix) |
|---|
| 3928 | { |
|---|
| 3929 | /* |
|---|
| 3930 | * fields |
|---|
| 3931 | * _8021xtype |
|---|
| 3932 | * _8021xuser |
|---|
| 3933 | * _8021xpasswd |
|---|
| 3934 | * _8021xca |
|---|
| 3935 | * _8021xpem |
|---|
| 3936 | * _8021xprv |
|---|
| 3937 | */ |
|---|
| 3938 | /* |
|---|
| 3939 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3940 | websWrite (wp,"<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.xsuptype)</script></div>\n"); |
|---|
| 3941 | websWrite (wp, "<select name=\"%s_8021xtype\" onchange=\"change_80211x(this.form.security_mode.selectedIndex,this.form)\">\n", prefix); |
|---|
| 3942 | websWrite (wp, "<option value=\"peap\" onclick=\"enable_idpeap()\" %s >Peap</option>\n",nvram_prefix_match ("8021xtype", prefix,"peap") ? "selected" : ""); |
|---|
| 3943 | websWrite (wp, "<option value=\"leap\" onclick=\"enable_idleap()\" %s >Leap</option>\n",nvram_prefix_match ("8021xtype", prefix,"leap") ? "selected" : ""); |
|---|
| 3944 | websWrite (wp, "<option value=\"tls\" onclick=\"enable_idtls()\" %s >TLS</option>\n",nvram_prefix_match ("8021xtype", prefix,"tls") ? "selected" : ""); |
|---|
| 3945 | websWrite (wp, "</select>\n"); |
|---|
| 3946 | websWrite (wp, "</div>\n"); |
|---|
| 3947 | */ |
|---|
| 3948 | char type[32]; |
|---|
| 3949 | sprintf (type, "%s_8021xtype", prefix); |
|---|
| 3950 | nvram_default_get (type, "peap"); |
|---|
| 3951 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3952 | websWrite (wp, |
|---|
| 3953 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.xsuptype)</script></div>\n"); |
|---|
| 3954 | websWrite (wp, |
|---|
| 3955 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"peap\" onclick=\"enable_idpeap('%s')\" %s />Peap \n", |
|---|
| 3956 | prefix, prefix, nvram_prefix_match ("8021xtype", prefix, |
|---|
| 3957 | "peap") ? |
|---|
| 3958 | "checked=\"checked\"" : ""); |
|---|
| 3959 | websWrite (wp, |
|---|
| 3960 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"leap\" onclick=\"enable_idleap('%s')\" %s />Leap \n", |
|---|
| 3961 | prefix, prefix, nvram_prefix_match ("8021xtype", prefix, |
|---|
| 3962 | "leap") ? |
|---|
| 3963 | "checked=\"checked\"" : ""); |
|---|
| 3964 | websWrite (wp, |
|---|
| 3965 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"tls\" onclick=\"enable_idtls('%s')\" %s />TLS \n", |
|---|
| 3966 | prefix, prefix, nvram_prefix_match ("8021xtype", prefix, |
|---|
| 3967 | "tls") ? |
|---|
| 3968 | "checked=\"checked\"" : ""); |
|---|
| 3969 | websWrite (wp, "</div>\n"); |
|---|
| 3970 | |
|---|
| 3971 | |
|---|
| 3972 | |
|---|
| 3973 | |
|---|
| 3974 | //peap authentication |
|---|
| 3975 | websWrite (wp, "<div id=\"idpeap%s\">\n", prefix); |
|---|
| 3976 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3977 | websWrite (wp, |
|---|
| 3978 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n"); |
|---|
| 3979 | websWrite (wp, |
|---|
| 3980 | "<input name=\"%s_peap8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 3981 | prefix, nvram_prefix_get ("peap8021xuser", prefix)); |
|---|
| 3982 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3983 | websWrite (wp, |
|---|
| 3984 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n"); |
|---|
| 3985 | websWrite (wp, |
|---|
| 3986 | "<input name=\"%s_peap8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 3987 | prefix, nvram_prefix_get ("peap8021xpasswd", prefix)); |
|---|
| 3988 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 3989 | websWrite (wp, |
|---|
| 3990 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.servercertif)</script></div>\n"); |
|---|
| 3991 | websWrite (wp, |
|---|
| 3992 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_peap8021xca\" name=\"%s_peap8021xca\"></textarea><script language=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 3993 | prefix, prefix); |
|---|
| 3994 | websWrite (wp, "var %s_peap8021xca = fix_cr( '%s' );\n", prefix, |
|---|
| 3995 | nvram_prefix_get ("peap8021xca", prefix)); |
|---|
| 3996 | websWrite (wp, |
|---|
| 3997 | "document.getElementById(\"%s_peap8021xca\").value = %s_peap8021xca;\n", |
|---|
| 3998 | prefix, prefix); |
|---|
| 3999 | websWrite (wp, "//]]>\n</script>\n"); |
|---|
| 4000 | websWrite (wp, "</div>\n"); |
|---|
| 4001 | websWrite (wp, "</div>\n"); |
|---|
| 4002 | //leap authentication |
|---|
| 4003 | websWrite (wp, "<div id=\"idleap%s\">\n", prefix); |
|---|
| 4004 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 4005 | websWrite (wp, |
|---|
| 4006 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n"); |
|---|
| 4007 | websWrite (wp, |
|---|
| 4008 | "<input name=\"%s_leap8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4009 | prefix, nvram_prefix_get ("leap8021xuser", prefix)); |
|---|
| 4010 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 4011 | websWrite (wp, |
|---|
| 4012 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n"); |
|---|
| 4013 | websWrite (wp, |
|---|
| 4014 | "<input name=\"%s_leap8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4015 | prefix, nvram_prefix_get ("leap8021xpasswd", prefix)); |
|---|
| 4016 | websWrite (wp, "</div>\n"); |
|---|
| 4017 | |
|---|
| 4018 | |
|---|
| 4019 | //tls authentication |
|---|
| 4020 | websWrite (wp, "<div id=\"idtls%s\">\n", prefix); |
|---|
| 4021 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 4022 | websWrite (wp, |
|---|
| 4023 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n"); |
|---|
| 4024 | websWrite (wp, |
|---|
| 4025 | "<input name=\"%s_tls8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4026 | prefix, nvram_prefix_get ("tls8021xuser", prefix)); |
|---|
| 4027 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 4028 | websWrite (wp, |
|---|
| 4029 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n"); |
|---|
| 4030 | websWrite (wp, |
|---|
| 4031 | "<input name=\"%s_tls8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4032 | prefix, nvram_prefix_get ("tls8021xpasswd", prefix)); |
|---|
| 4033 | |
|---|
| 4034 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 4035 | websWrite (wp, |
|---|
| 4036 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.servercertif)</script></div>\n"); |
|---|
| 4037 | websWrite (wp, |
|---|
| 4038 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xca\" name=\"%s_tls8021xca\"></textarea><script language=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4039 | prefix, prefix); |
|---|
| 4040 | websWrite (wp, "var %s_tls8021xca = fix_cr( '%s' );\n", prefix, |
|---|
| 4041 | nvram_prefix_get ("tls8021xca", prefix)); |
|---|
| 4042 | websWrite (wp, |
|---|
| 4043 | "document.getElementById(\"%s_tls8021xca\").value = %s_tls8021xca;\n", |
|---|
| 4044 | prefix, prefix); |
|---|
| 4045 | websWrite (wp, "//]]>\n</script>\n"); |
|---|
| 4046 | websWrite (wp, "</div>\n"); |
|---|
| 4047 | |
|---|
| 4048 | |
|---|
| 4049 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 4050 | websWrite (wp, |
|---|
| 4051 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.clientcertif)</script></div>\n"); |
|---|
| 4052 | websWrite (wp, |
|---|
| 4053 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xpem\" name=\"%s_tls8021xpem\"></textarea><script language=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4054 | prefix, prefix); |
|---|
| 4055 | websWrite (wp, "var %s_tls8021xpem = fix_cr( '%s' );\n", prefix, |
|---|
| 4056 | nvram_prefix_get ("tls8021xpem", prefix)); |
|---|
| 4057 | websWrite (wp, |
|---|
| 4058 | "document.getElementById(\"%s_tls8021xpem\").value = %s_tls8021xpem;\n", |
|---|
| 4059 | prefix, prefix); |
|---|
| 4060 | websWrite (wp, "//]]>\n</script>\n"); |
|---|
| 4061 | websWrite (wp, "</div>\n"); |
|---|
| 4062 | |
|---|
| 4063 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 4064 | websWrite (wp, |
|---|
| 4065 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.privatekey)</script></div>\n"); |
|---|
| 4066 | websWrite (wp, |
|---|
| 4067 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xprv\" name=\"%s_tls8021xprv\"></textarea><script language=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4068 | prefix, prefix); |
|---|
| 4069 | websWrite (wp, "var %s_tls8021xprv = fix_cr( '%s' );\n", prefix, |
|---|
| 4070 | nvram_prefix_get ("tls8021xprv", prefix)); |
|---|
| 4071 | websWrite (wp, |
|---|
| 4072 | "document.getElementById(\"%s_tls8021xprv\").value = %s_tls8021xprv;\n", |
|---|
| 4073 | prefix, prefix); |
|---|
| 4074 | websWrite (wp, "//]]>\n</script>\n"); |
|---|
| 4075 | websWrite (wp, "</div>\n"); |
|---|
| 4076 | |
|---|
| 4077 | websWrite (wp, "</div>\n"); |
|---|
| 4078 | websWrite (wp, "<script>\n//<![CDATA[\n "); |
|---|
| 4079 | // websWrite (wp,"show_layer_ext(document.getElementsByName(\"%s_bridged\"), \"%s_idnetvifs\", %s);\n",var, vvar, nvram_match (ssid, "0") ? "true" : "false"); |
|---|
| 4080 | char peap[32]; |
|---|
| 4081 | sprintf (peap, "%s_8021xtype", prefix); |
|---|
| 4082 | websWrite (wp, |
|---|
| 4083 | "show_layer_ext(document.wpa.%s_8021xtype, 'idpeap%s', %s);\n", |
|---|
| 4084 | prefix, prefix, nvram_match (peap, "peap") ? "true" : "false"); |
|---|
| 4085 | websWrite (wp, |
|---|
| 4086 | "show_layer_ext(document.wpa.%s_8021xtype, 'idtls%s', %s);\n", |
|---|
| 4087 | prefix, prefix, nvram_match (peap, "tls") ? "true" : "false"); |
|---|
| 4088 | websWrite (wp, |
|---|
| 4089 | "show_layer_ext(document.wpa.%s_8021xtype, 'idleap%s', %s);\n", |
|---|
| 4090 | prefix, prefix, nvram_match (peap, "leap") ? "true" : "false"); |
|---|
| 4091 | websWrite (wp, "//]]>\n</script>\n"); |
|---|
| 4092 | |
|---|
| 4093 | } |
|---|
| 4094 | #endif |
|---|
| 4095 | |
|---|
| 4096 | void |
|---|
| 4097 | show_wparadius (webs_t wp, char *prefix) |
|---|
| 4098 | { |
|---|
| 4099 | char var[80]; |
|---|
| 4100 | websWrite (wp, "<div>\n"); |
|---|
| 4101 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 4102 | websWrite (wp, |
|---|
| 4103 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.algorithms)</script></div>\n"); |
|---|
| 4104 | websWrite (wp, "<select name=\"%s_crypto\">\n", prefix); |
|---|
| 4105 | sprintf (var, "%s_crypto", prefix); |
|---|
| 4106 | websWrite (wp, "<option value=\"tkip\" %s>TKIP</option>\n", |
|---|
| 4107 | selmatch (var, "tkip", "selected=\"selected\"")); |
|---|
| 4108 | websWrite (wp, "<option value=\"aes\" %s>AES</option>\n", |
|---|
| 4109 | selmatch (var, "aes", "selected=\"selected\"")); |
|---|
| 4110 | websWrite (wp, "<option value=\"tkip+aes\" %s>TKIP+AES</option>\n", |
|---|
| 4111 | selmatch (var, "tkip+aes", "selected=\"selected\"")); |
|---|
| 4112 | websWrite (wp, "</select></div>\n"); |
|---|
| 4113 | show_radius (wp, prefix, 0); |
|---|
| 4114 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 4115 | websWrite (wp, |
|---|
| 4116 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.rekey)</script></div>\n"); |
|---|
| 4117 | sprintf (var, "%s_wpa_gtk_rekey", prefix); |
|---|
| 4118 | websWrite (wp, |
|---|
| 4119 | "<input name=\"%s_wpa_gtk_rekey\" maxlength=\"5\" size=\"10\" onblur=\"valid_range(this,0,99999,wpa.rekey)\" value=\"%s\" />", |
|---|
| 4120 | prefix, nvram_default_get (var, "3600")); |
|---|
| 4121 | websWrite (wp, "</div>\n"); |
|---|
| 4122 | websWrite (wp, "</div>\n"); |
|---|
| 4123 | } |
|---|
| 4124 | |
|---|
| 4125 | void |
|---|
| 4126 | show_wep (webs_t wp, char *prefix) |
|---|
| 4127 | { |
|---|
| 4128 | char var[80]; |
|---|
| 4129 | char *bit; |
|---|
| 4130 | cprintf ("show wep\n"); |
|---|
| 4131 | websWrite (wp, |
|---|
| 4132 | "<div><div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wep.defkey)</script></div>"); |
|---|
| 4133 | websWrite (wp, "<input type=\"hidden\" name=\"%s_WEP_key\" />", prefix); |
|---|
| 4134 | websWrite (wp, |
|---|
| 4135 | "<input type=\"hidden\" name=\"%s_wep\" value=\"restricted\" />", |
|---|
| 4136 | prefix); |
|---|
| 4137 | sprintf (var, "%s_key", prefix); |
|---|
| 4138 | nvram_default_get (var, "1"); |
|---|
| 4139 | websWrite (wp, |
|---|
| 4140 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s_key\" %s />1 \n", |
|---|
| 4141 | prefix, selmatch (var, "1", "checked=\"checked\"")); |
|---|
| 4142 | websWrite (wp, |
|---|
| 4143 | "<input class=\"spaceradio\" type=\"radio\" value=\"2\" name=\"%s_key\" %s />2 \n", |
|---|
| 4144 | prefix, selmatch (var, "2", "checked=\"checked\"")); |
|---|
| 4145 | websWrite (wp, |
|---|
| 4146 | "<input class=\"spaceradio\" type=\"radio\" value=\"3\" name=\"%s_key\" %s />3 \n", |
|---|
| 4147 | prefix, selmatch (var, "3", "checked=\"checked\"")); |
|---|
| 4148 | websWrite (wp, |
|---|
| 4149 | "<input class=\"spaceradio\" type=\"radio\" value=\"4\" name=\"%s_key\" %s />4 \n", |
|---|
| 4150 | prefix, selmatch (var, "4", "checked=\"checked\"")); |
|---|
| 4151 | websWrite (wp, "</div>"); |
|---|
| 4152 | websWrite (wp, |
|---|
| 4153 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.encrypt)</script></div>"); |
|---|
| 4154 | |
|---|
| 4155 | sprintf (var, "%s_wep_bit", prefix); |
|---|
| 4156 | bit = nvram_safe_get (var); |
|---|
| 4157 | |
|---|
| 4158 | cprintf ("bit %s\n", bit); |
|---|
| 4159 | |
|---|
| 4160 | websWrite (wp, |
|---|
| 4161 | "<select name=\"%s_wep_bit\" size=\"1\" onchange=keyMode(this.form)>", |
|---|
| 4162 | prefix); |
|---|
| 4163 | websWrite (wp, "<option value=\"64\" %s >64 bits 10 hex digits</option>", |
|---|
| 4164 | selmatch (var, "64", "selected=\"selected\"")); |
|---|
| 4165 | websWrite (wp, "<option value=\"128\" %s >128 bits 26 hex digits</option>", |
|---|
| 4166 | selmatch (var, "128", "selected=\"selected\"")); |
|---|
| 4167 | websWrite (wp, |
|---|
| 4168 | "</select>\n</div>\n<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wep.passphrase)</script></div>\n"); |
|---|
| 4169 | websWrite (wp, |
|---|
| 4170 | "<input name=%s_passphrase maxlength=\"16\" size=\"20\" value=\"", |
|---|
| 4171 | prefix); |
|---|
| 4172 | |
|---|
| 4173 | char p_temp[128]; |
|---|
| 4174 | sprintf (p_temp, "%s", get_wep_value ("passphrase", bit, prefix)); |
|---|
| 4175 | nvram_set ("passphrase_temp", p_temp); |
|---|
| 4176 | tf_webWriteESCNV (wp, "passphrase_temp"); |
|---|
| 4177 | nvram_unset ("passphrase_temp"); |
|---|
| 4178 | |
|---|
| 4179 | websWrite (wp, "\" />"); |
|---|
| 4180 | |
|---|
| 4181 | websWrite (wp, |
|---|
| 4182 | "<input type=\"hidden\" value=\"Null\" name=\"generateButton\" />\n"); |
|---|
| 4183 | |
|---|
| 4184 | if (strcmp (bit, "64")) |
|---|
| 4185 | websWrite (wp, |
|---|
| 4186 | "<input class=\"button\" type=\"button\" value=\"Generate\" onclick=generateKey64(this.form,\"%s\") name=wepGenerate />\n</div>", |
|---|
| 4187 | prefix); |
|---|
| 4188 | else |
|---|
| 4189 | websWrite (wp, |
|---|
| 4190 | "<input class=\"button\" type=\"button\" value=\"Generate\" onclick=generateKey128(this.form,\"%s\") name=wepGenerate />\n</div>", |
|---|
| 4191 | prefix); |
|---|
| 4192 | |
|---|
| 4193 | |
|---|
| 4194 | char *mlen = "10"; |
|---|
| 4195 | char *mlen2 = "12"; |
|---|
| 4196 | if (!strcmp (bit, "128")) |
|---|
| 4197 | { |
|---|
| 4198 | mlen = "26"; |
|---|
| 4199 | mlen2 = "30"; |
|---|
| 4200 | } |
|---|
| 4201 | websWrite (wp, |
|---|
| 4202 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 1</div>\n"); |
|---|
| 4203 | websWrite (wp, |
|---|
| 4204 | "<input name=%s_key1 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 4205 | prefix, mlen2, mlen, get_wep_value ("key1", bit, prefix)); |
|---|
| 4206 | websWrite (wp, |
|---|
| 4207 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 2</div>\n"); |
|---|
| 4208 | websWrite (wp, |
|---|
| 4209 | "<input name=%s_key2 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 4210 | prefix, mlen2, mlen, get_wep_value ("key2", bit, prefix)); |
|---|
| 4211 | websWrite (wp, |
|---|
| 4212 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 3</div>\n"); |
|---|
| 4213 | websWrite (wp, |
|---|
| 4214 | "<input name=%s_key3 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 4215 | prefix, mlen2, mlen, get_wep_value ("key3", bit, prefix)); |
|---|
| 4216 | websWrite (wp, |
|---|
| 4217 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 4</div>\n"); |
|---|
| 4218 | websWrite (wp, |
|---|
| 4219 | "<input name=%s_key4 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 4220 | prefix, mlen2, mlen, get_wep_value ("key4", bit, prefix)); |
|---|
| 4221 | websWrite (wp, "</div>\n"); |
|---|
| 4222 | } |
|---|
| 4223 | |
|---|
| 4224 | #endif |
|---|
| 4225 | |
|---|
| 4226 | |
|---|
| 4227 | void |
|---|
| 4228 | ej_get_wds_mac (webs_t wp, int argc, char_t ** argv) |
|---|
| 4229 | { |
|---|
| 4230 | int mac = -1, wds_idx = -1, mac_idx = -1; |
|---|
| 4231 | char *c, wds_var[32] = ""; |
|---|
| 4232 | |
|---|
| 4233 | char *interface; |
|---|
| 4234 | if (ejArgs (argc, argv, "%d %d %s", &wds_idx, &mac_idx, &interface) < 3) |
|---|
| 4235 | { |
|---|
| 4236 | websError (wp, 400, "Insufficient args\n"); |
|---|
| 4237 | return; |
|---|
| 4238 | } |
|---|
| 4239 | else if (wds_idx < 1 || wds_idx > MAX_WDS_DEVS) |
|---|
| 4240 | return; |
|---|
| 4241 | else if (mac_idx < 0 || mac_idx > 5) |
|---|
| 4242 | return; |
|---|
| 4243 | |
|---|
| 4244 | snprintf (wds_var, 31, "%s_wds%d_hwaddr", interface, wds_idx); |
|---|
| 4245 | |
|---|
| 4246 | c = nvram_safe_get (wds_var); |
|---|
| 4247 | |
|---|
| 4248 | if (c) |
|---|
| 4249 | { |
|---|
| 4250 | mac = get_single_mac (c, mac_idx); |
|---|
| 4251 | websWrite (wp, "%02X", mac); |
|---|
| 4252 | } |
|---|
| 4253 | else |
|---|
| 4254 | websWrite (wp, "00"); |
|---|
| 4255 | |
|---|
| 4256 | return; |
|---|
| 4257 | |
|---|
| 4258 | } |
|---|
| 4259 | |
|---|
| 4260 | |
|---|
| 4261 | void |
|---|
| 4262 | ej_showbridgesettings (webs_t wp, int argc, char_t ** argv) |
|---|
| 4263 | { |
|---|
| 4264 | char *interface; |
|---|
| 4265 | int mcast; |
|---|
| 4266 | #ifdef FASTWEB |
|---|
| 4267 | ejArgs (argc, argv, "%s %d", &interface, &mcast); |
|---|
| 4268 | #else |
|---|
| 4269 | if (ejArgs (argc, argv, "%s %d", &interface, &mcast) < 2) |
|---|
| 4270 | { |
|---|
| 4271 | websError (wp, 400, "Insufficient args\n"); |
|---|
| 4272 | return; |
|---|
| 4273 | } |
|---|
| 4274 | #endif |
|---|
| 4275 | showbridgesettings (wp, interface, mcast); |
|---|
| 4276 | } |
|---|
| 4277 | |
|---|
| 4278 | void |
|---|
| 4279 | ej_get_wds_ip (webs_t wp, int argc, char_t ** argv) |
|---|
| 4280 | { |
|---|
| 4281 | int ip = -1, wds_idx = -1, ip_idx = -1; |
|---|
| 4282 | char *c, wds_var[32] = ""; |
|---|
| 4283 | |
|---|
| 4284 | char *interface; |
|---|
| 4285 | #ifdef FASTWEB |
|---|
| 4286 | ejArgs (argc, argv, "%d %d %s", &wds_idx, &ip_idx, &interface); |
|---|
| 4287 | #else |
|---|
| 4288 | if (ejArgs (argc, argv, "%d %d %s", &wds_idx, &ip_idx, &interface) < 3) |
|---|
| 4289 | { |
|---|
| 4290 | websError (wp, 400, "Insufficient args\n"); |
|---|
| 4291 | return; |
|---|
| 4292 | } |
|---|
| 4293 | #endif |
|---|
| 4294 | if (wds_idx < 1 || wds_idx > MAX_WDS_DEVS) |
|---|
| 4295 | return; |
|---|
| 4296 | else if (ip_idx < 0 || ip_idx > 3) |
|---|
| 4297 | return; |
|---|
| 4298 | |
|---|
| 4299 | snprintf (wds_var, 31, "%s_wds%d_ipaddr", interface, wds_idx); |
|---|
| 4300 | |
|---|
| 4301 | c = nvram_safe_get (wds_var); |
|---|
| 4302 | |
|---|
| 4303 | if (c) |
|---|
| 4304 | { |
|---|
| 4305 | ip = get_single_ip (c, ip_idx); |
|---|
| 4306 | websWrite (wp, "%d", ip); |
|---|
| 4307 | } |
|---|
| 4308 | else |
|---|
| 4309 | websWrite (wp, "0"); |
|---|
| 4310 | |
|---|
| 4311 | return; |
|---|
| 4312 | |
|---|
| 4313 | } |
|---|
| 4314 | |
|---|
| 4315 | void |
|---|
| 4316 | ej_get_wds_netmask (webs_t wp, int argc, char_t ** argv) |
|---|
| 4317 | { |
|---|
| 4318 | int nm = -1, wds_idx = -1, nm_idx = -1; |
|---|
| 4319 | char *c, wds_var[32] = ""; |
|---|
| 4320 | |
|---|
| 4321 | char *interface; |
|---|
| 4322 | #ifdef FASTWEB |
|---|
| 4323 | ejArgs (argc, argv, "%d %d %s", &wds_idx, &nm_idx, &interface); |
|---|
| 4324 | #else |
|---|
| 4325 | if (ejArgs (argc, argv, "%d %d %s", &wds_idx, &nm_idx, &interface) < 3) |
|---|
| 4326 | { |
|---|
| 4327 | websError (wp, 400, "Insufficient args\n"); |
|---|
| 4328 | return; |
|---|
| 4329 | } |
|---|
| 4330 | #endif |
|---|
| 4331 | |
|---|
| 4332 | if (wds_idx < 1 || wds_idx > 6) |
|---|
| 4333 | return; |
|---|
| 4334 | else if (nm_idx < 0 || nm_idx > 3) |
|---|
| 4335 | return; |
|---|
| 4336 | |
|---|
| 4337 | snprintf (wds_var, 31, "%s_wds%d_netmask", interface, wds_idx); |
|---|
| 4338 | |
|---|
| 4339 | c = nvram_safe_get (wds_var); |
|---|
| 4340 | |
|---|
| 4341 | if (c) |
|---|
| 4342 | { |
|---|
| 4343 | nm = get_single_ip (c, nm_idx); |
|---|
| 4344 | websWrite (wp, "%d", nm); |
|---|
| 4345 | } |
|---|
| 4346 | else |
|---|
| 4347 | websWrite (wp, "255"); |
|---|
| 4348 | |
|---|
| 4349 | return; |
|---|
| 4350 | |
|---|
| 4351 | } |
|---|
| 4352 | |
|---|
| 4353 | |
|---|
| 4354 | void |
|---|
| 4355 | ej_get_wds_gw (webs_t wp, int argc, char_t ** argv) |
|---|
| 4356 | { |
|---|
| 4357 | int gw = -1, wds_idx = -1, gw_idx = -1; |
|---|
| 4358 | char *c, wds_var[32] = ""; |
|---|
| 4359 | |
|---|
| 4360 | char *interface; |
|---|
| 4361 | #ifdef FASTWEB |
|---|
| 4362 | ejArgs (argc, argv, "%d %d %s", &wds_idx, &gw_idx, &interface); |
|---|
| 4363 | #else |
|---|
| 4364 | if (ejArgs (argc, argv, "%d %d %s", &wds_idx, &gw_idx, &interface) < 3) |
|---|
| 4365 | { |
|---|
| 4366 | websError (wp, 400, "Insufficient args\n"); |
|---|
| 4367 | return; |
|---|
| 4368 | } |
|---|
| 4369 | #endif |
|---|
| 4370 | |
|---|
| 4371 | if (wds_idx < 1 || wds_idx > MAX_WDS_DEVS) |
|---|
| 4372 | return; |
|---|
| 4373 | else if (gw_idx < 0 || gw_idx > 3) |
|---|
| 4374 | return; |
|---|
| 4375 | |
|---|
| 4376 | snprintf (wds_var, 31, "%s_wds%d_gw", interface, wds_idx); |
|---|
| 4377 | |
|---|
| 4378 | c = nvram_safe_get (wds_var); |
|---|
| 4379 | |
|---|
| 4380 | if (c) |
|---|
| 4381 | { |
|---|
| 4382 | gw = get_single_ip (c, gw_idx); |
|---|
| 4383 | websWrite (wp, "%d", gw); |
|---|
| 4384 | } |
|---|
| 4385 | else |
|---|
| 4386 | websWrite (wp, "0"); |
|---|
| 4387 | |
|---|
| 4388 | return; |
|---|
| 4389 | |
|---|
| 4390 | } |
|---|
| 4391 | |
|---|
| 4392 | void |
|---|
| 4393 | ej_get_br1_ip (webs_t wp, int argc, char_t ** argv) |
|---|
| 4394 | { |
|---|
| 4395 | int ip = -1, ip_idx = -1; |
|---|
| 4396 | char *c; |
|---|
| 4397 | |
|---|
| 4398 | char *interface; |
|---|
| 4399 | #ifdef FASTWEB |
|---|
| 4400 | ejArgs (argc, argv, "%d %s", &ip_idx, &interface); |
|---|
| 4401 | #else |
|---|
| 4402 | if (ejArgs (argc, argv, "%d %s", &ip_idx, &interface) < 2) |
|---|
| 4403 | { |
|---|
| 4404 | websError (wp, 400, "Insufficient args\n"); |
|---|
| 4405 | return; |
|---|
| 4406 | } |
|---|
| 4407 | #endif |
|---|
| 4408 | if (ip_idx < 0 || ip_idx > 3) |
|---|
| 4409 | return; |
|---|
| 4410 | char br1[32]; |
|---|
| 4411 | sprintf (br1, "%s_br1_ipaddr", interface); |
|---|
| 4412 | c = nvram_safe_get (br1); |
|---|
| 4413 | |
|---|
| 4414 | if (c) |
|---|
| 4415 | { |
|---|
| 4416 | ip = get_single_ip (c, ip_idx); |
|---|
| 4417 | websWrite (wp, "%d", ip); |
|---|
| 4418 | } |
|---|
| 4419 | else |
|---|
| 4420 | websWrite (wp, "0"); |
|---|
| 4421 | |
|---|
| 4422 | return; |
|---|
| 4423 | |
|---|
| 4424 | } |
|---|
| 4425 | |
|---|
| 4426 | void |
|---|
| 4427 | ej_get_br1_netmask (webs_t wp, int argc, char_t ** argv) |
|---|
| 4428 | { |
|---|
| 4429 | int nm = -1, nm_idx = -1; |
|---|
| 4430 | char *c; |
|---|
| 4431 | |
|---|
| 4432 | |
|---|
| 4433 | char *interface; |
|---|
| 4434 | #ifdef FASTWEB |
|---|
| 4435 | ejArgs (argc, argv, "%d %s", &nm_idx, &interface); |
|---|
| 4436 | #else |
|---|
| 4437 | if (ejArgs (argc, argv, "%d %s", &nm_idx, &interface) < 2) |
|---|
| 4438 | { |
|---|
| 4439 | websError (wp, 400, "Insufficient args\n"); |
|---|
| 4440 | return; |
|---|
| 4441 | } |
|---|
| 4442 | #endif |
|---|
| 4443 | if (nm_idx < 0 || nm_idx > 3) |
|---|
| 4444 | return; |
|---|
| 4445 | char nms[32]; |
|---|
| 4446 | sprintf (nms, "%s_br1_netmask", interface); |
|---|
| 4447 | c = nvram_safe_get (nms); |
|---|
| 4448 | |
|---|
| 4449 | if (c) |
|---|
| 4450 | { |
|---|
| 4451 | nm = get_single_ip (c, nm_idx); |
|---|
| 4452 | websWrite (wp, "%d", nm); |
|---|
| 4453 | } |
|---|
| 4454 | else |
|---|
| 4455 | websWrite (wp, "255"); |
|---|
| 4456 | |
|---|
| 4457 | return; |
|---|
| 4458 | |
|---|
| 4459 | } |
|---|
| 4460 | |
|---|
| 4461 | #ifndef HAVE_MADWIFI |
|---|
| 4462 | |
|---|
| 4463 | |
|---|
| 4464 | void |
|---|
| 4465 | ej_get_currate (webs_t wp, int argc, char_t ** argv) |
|---|
| 4466 | { |
|---|
| 4467 | int rate = 0; |
|---|
| 4468 | |
|---|
| 4469 | wl_ioctl (get_wdev (), WLC_GET_RATE, &rate, sizeof (rate)); |
|---|
| 4470 | |
|---|
| 4471 | if (rate > 0) |
|---|
| 4472 | websWrite (wp, "%d%s Mbps", (rate / 2), (rate & 1) ? ".5" : ""); |
|---|
| 4473 | else |
|---|
| 4474 | websWrite (wp, "%s", live_translate ("share.unknown")); |
|---|
| 4475 | |
|---|
| 4476 | return; |
|---|
| 4477 | } |
|---|
| 4478 | |
|---|
| 4479 | void |
|---|
| 4480 | ej_show_acktiming (webs_t wp, int argc, char_t ** argv) |
|---|
| 4481 | { |
|---|
| 4482 | return; |
|---|
| 4483 | } |
|---|
| 4484 | |
|---|
| 4485 | void |
|---|
| 4486 | ej_update_acktiming (webs_t wp, int argc, char_t ** argv) |
|---|
| 4487 | { |
|---|
| 4488 | return; |
|---|
| 4489 | } |
|---|
| 4490 | |
|---|
| 4491 | #else |
|---|
| 4492 | |
|---|
| 4493 | int |
|---|
| 4494 | get_acktiming (void) |
|---|
| 4495 | { |
|---|
| 4496 | char path[64]; |
|---|
| 4497 | int ifcount, ack = 0; |
|---|
| 4498 | strcpy (path, nvram_safe_get ("wifi_display")); |
|---|
| 4499 | sscanf (path, "ath%d", &ifcount); |
|---|
| 4500 | sprintf (path, "/proc/sys/dev/wifi%d/acktimeout", ifcount); |
|---|
| 4501 | FILE *in = fopen (path, "rb"); |
|---|
| 4502 | if (in != NULL) |
|---|
| 4503 | { |
|---|
| 4504 | fscanf (in, "%d", &ack); |
|---|
| 4505 | fclose (in); |
|---|
| 4506 | } |
|---|
| 4507 | return ack; |
|---|
| 4508 | } |
|---|
| 4509 | |
|---|
| 4510 | void |
|---|
| 4511 | ej_show_acktiming (webs_t wp, int argc, char_t ** argv) |
|---|
| 4512 | { |
|---|
| 4513 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 4514 | websWrite (wp, "<div class=\"label\">%s</div>\n", |
|---|
| 4515 | live_translate ("share.acktiming")); |
|---|
| 4516 | int ack = get_acktiming (); |
|---|
| 4517 | int distance = ((ack - 3) / 2) * 300; |
|---|
| 4518 | websWrite (wp, "<span id=\"wl_ack\">%dµs (%dm)</span> \n", ack, |
|---|
| 4519 | distance); |
|---|
| 4520 | websWrite (wp, "</div>\n"); |
|---|
| 4521 | } |
|---|
| 4522 | |
|---|
| 4523 | void |
|---|
| 4524 | ej_update_acktiming (webs_t wp, int argc, char_t ** argv) |
|---|
| 4525 | { |
|---|
| 4526 | int ack = get_acktiming (); |
|---|
| 4527 | int distance = ((ack - 3) / 2) * 300; |
|---|
| 4528 | websWrite (wp, "%dµs (%dm)", ack, distance); |
|---|
| 4529 | } |
|---|
| 4530 | |
|---|
| 4531 | |
|---|
| 4532 | |
|---|
| 4533 | extern float wifi_getrate (char *ifname); |
|---|
| 4534 | #define KILO 1e3 |
|---|
| 4535 | #define MEGA 1e6 |
|---|
| 4536 | #define GIGA 1e9 |
|---|
| 4537 | |
|---|
| 4538 | void |
|---|
| 4539 | ej_get_currate (webs_t wp, int argc, char_t ** argv) |
|---|
| 4540 | { |
|---|
| 4541 | char mode[32]; |
|---|
| 4542 | int state = get_radiostate (nvram_safe_get ("wifi_display")); |
|---|
| 4543 | if (state == 0 || state == -1) |
|---|
| 4544 | { |
|---|
| 4545 | websWrite (wp, "%s", live_translate ("share.disabled")); |
|---|
| 4546 | return; |
|---|
| 4547 | } |
|---|
| 4548 | float rate = wifi_getrate (nvram_safe_get ("wifi_display")); |
|---|
| 4549 | char scale; |
|---|
| 4550 | int divisor; |
|---|
| 4551 | |
|---|
| 4552 | if (rate >= GIGA) |
|---|
| 4553 | { |
|---|
| 4554 | scale = 'G'; |
|---|
| 4555 | divisor = GIGA; |
|---|
| 4556 | } |
|---|
| 4557 | else |
|---|
| 4558 | { |
|---|
| 4559 | if (rate >= MEGA) |
|---|
| 4560 | { |
|---|
| 4561 | scale = 'M'; |
|---|
| 4562 | divisor = MEGA; |
|---|
| 4563 | } |
|---|
| 4564 | else |
|---|
| 4565 | { |
|---|
| 4566 | scale = 'k'; |
|---|
| 4567 | divisor = KILO; |
|---|
| 4568 | } |
|---|
| 4569 | } |
|---|
| 4570 | sprintf (mode, "%s_turbo", nvram_safe_get ("wifi_display")); |
|---|
| 4571 | if (nvram_match (mode, "1")) |
|---|
| 4572 | rate *= 2; |
|---|
| 4573 | if (rate > 0.0) |
|---|
| 4574 | { |
|---|
| 4575 | websWrite (wp, "%g %cb/s", rate / divisor, scale); |
|---|
| 4576 | } |
|---|
| 4577 | else |
|---|
| 4578 | websWrite (wp, "%s", live_translate ("share.auto")); |
|---|
| 4579 | |
|---|
| 4580 | } |
|---|
| 4581 | #endif |
|---|
| 4582 | |
|---|
| 4583 | void |
|---|
| 4584 | ej_get_uptime (webs_t wp, int argc, char_t ** argv) |
|---|
| 4585 | { |
|---|
| 4586 | char line[256]; |
|---|
| 4587 | FILE *fp; |
|---|
| 4588 | |
|---|
| 4589 | if (fp = popen ("uptime", "r")) |
|---|
| 4590 | { |
|---|
| 4591 | fgets (line, sizeof (line), fp); |
|---|
| 4592 | line[strlen (line) - 1] = '\0'; // replace new line with null |
|---|
| 4593 | websWrite (wp, "%s", line); |
|---|
| 4594 | pclose (fp); |
|---|
| 4595 | } |
|---|
| 4596 | return; |
|---|
| 4597 | } |
|---|
| 4598 | |
|---|
| 4599 | void |
|---|
| 4600 | ej_get_wan_uptime (webs_t wp, int argc, char_t ** argv) |
|---|
| 4601 | { |
|---|
| 4602 | float sys_uptime; |
|---|
| 4603 | float uptime; |
|---|
| 4604 | int days, minutes; |
|---|
| 4605 | FILE *fp, *fp2; |
|---|
| 4606 | |
|---|
| 4607 | if (nvram_match ("wan_proto", "disabled")) |
|---|
| 4608 | return; |
|---|
| 4609 | if (!(fp = fopen ("/tmp/.wanuptime", "r"))) |
|---|
| 4610 | { |
|---|
| 4611 | websWrite (wp, "%s", live_translate ("status_router.notavail")); |
|---|
| 4612 | return; |
|---|
| 4613 | } |
|---|
| 4614 | if (!feof (fp) && fscanf (fp, "%f", &uptime) == 1) |
|---|
| 4615 | { |
|---|
| 4616 | fp2 = fopen ("/proc/uptime", "r"); |
|---|
| 4617 | fscanf (fp2, "%f", &sys_uptime); |
|---|
| 4618 | fclose (fp2); |
|---|
| 4619 | uptime = sys_uptime - uptime; |
|---|
| 4620 | days = (int) uptime / (60 * 60 * 24); |
|---|
| 4621 | if (days) |
|---|
| 4622 | websWrite (wp, "%d day%s, ", days, (days == 1 ? "" : "s")); |
|---|
| 4623 | minutes = (int) uptime / 60; |
|---|
| 4624 | websWrite (wp, "%d:%02d:%02d", (minutes / 60) % 24, minutes % 60, |
|---|
| 4625 | (int) uptime % 60); |
|---|
| 4626 | } |
|---|
| 4627 | fclose (fp); |
|---|
| 4628 | |
|---|
| 4629 | return; |
|---|
| 4630 | |
|---|
| 4631 | } |
|---|
| 4632 | |
|---|
| 4633 | #ifndef HAVE_MADWIFI |
|---|
| 4634 | |
|---|
| 4635 | void |
|---|
| 4636 | ej_get_curchannel (webs_t wp, int argc, char_t ** argv) |
|---|
| 4637 | { |
|---|
| 4638 | channel_info_t ci; |
|---|
| 4639 | |
|---|
| 4640 | memset (&ci, 0, sizeof (ci)); |
|---|
| 4641 | wl_ioctl (get_wdev (), WLC_GET_CHANNEL, &ci, sizeof (ci)); |
|---|
| 4642 | if (ci.scan_channel > 0) |
|---|
| 4643 | { |
|---|
| 4644 | websWrite (wp, "%d (scanning)", ci.scan_channel); |
|---|
| 4645 | } |
|---|
| 4646 | else if (ci.hw_channel > 0) |
|---|
| 4647 | { |
|---|
| 4648 | websWrite (wp, "%d", ci.hw_channel); |
|---|
| 4649 | } |
|---|
| 4650 | else |
|---|
| 4651 | //websWrite (wp, "unknown"); |
|---|
| 4652 | websWrite (wp, "%s", live_translate ("share.unknown")); |
|---|
| 4653 | return; |
|---|
| 4654 | |
|---|
| 4655 | } |
|---|
| 4656 | |
|---|
| 4657 | #else |
|---|
| 4658 | |
|---|
| 4659 | void |
|---|
| 4660 | ej_get_curchannel (webs_t wp, int argc, char_t ** argv) |
|---|
| 4661 | { |
|---|
| 4662 | char *dev = NULL; |
|---|
| 4663 | |
|---|
| 4664 | int channel = wifi_getchannel (nvram_safe_get ("wifi_display")); |
|---|
| 4665 | if (channel > 0 && channel < 1000) |
|---|
| 4666 | { |
|---|
| 4667 | #ifdef HAVE_XR4SPECIAL |
|---|
| 4668 | char ofs[32]; |
|---|
| 4669 | sprintf (ofs, "%s_offset", nvram_safe_get ("wifi_display")); |
|---|
| 4670 | int offset = atoi (nvram_default_get (ofs, "0")); |
|---|
| 4671 | websWrite (wp, "%d (%d Mhz)", channel, |
|---|
| 4672 | (wifi_getfreq (nvram_safe_get ("wifi_display")) + offset)); |
|---|
| 4673 | #else |
|---|
| 4674 | websWrite (wp, "%d (%d Mhz)", channel, |
|---|
| 4675 | (wifi_getfreq (nvram_safe_get ("wifi_display")) + |
|---|
| 4676 | get_wifioffset (nvram_safe_get ("wifi_display")))); |
|---|
| 4677 | #endif |
|---|
| 4678 | } |
|---|
| 4679 | else |
|---|
| 4680 | //websWrite (wp, "unknown"); |
|---|
| 4681 | websWrite (wp, "%s", live_translate ("share.unknown")); |
|---|
| 4682 | return; |
|---|
| 4683 | |
|---|
| 4684 | } |
|---|
| 4685 | #endif |
|---|
| 4686 | #ifdef HAVE_MADWIFI |
|---|
| 4687 | #include <sys/types.h> |
|---|
| 4688 | #include <sys/file.h> |
|---|
| 4689 | #include <sys/ioctl.h> |
|---|
| 4690 | #include <sys/socket.h> |
|---|
| 4691 | #include <stdio.h> |
|---|
| 4692 | #include <stdlib.h> |
|---|
| 4693 | #include <string.h> |
|---|
| 4694 | #include <stdint.h> |
|---|
| 4695 | #include <ctype.h> |
|---|
| 4696 | #include <getopt.h> |
|---|
| 4697 | #include <err.h> |
|---|
| 4698 | |
|---|
| 4699 | |
|---|
| 4700 | #include "wireless_copy.h" |
|---|
| 4701 | #include "net80211/ieee80211.h" |
|---|
| 4702 | #include "net80211/ieee80211_crypto.h" |
|---|
| 4703 | #include "net80211/ieee80211_ioctl.h" |
|---|
| 4704 | static const char * |
|---|
| 4705 | ieee80211_ntoa (const uint8_t mac[IEEE80211_ADDR_LEN]) |
|---|
| 4706 | { |
|---|
| 4707 | static char a[18]; |
|---|
| 4708 | int i; |
|---|
| 4709 | |
|---|
| 4710 | i = snprintf (a, sizeof (a), "%02x:%02x:%02x:%02x:%02x:%02x", |
|---|
| 4711 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); |
|---|
| 4712 | return (i < 17 ? NULL : a); |
|---|
| 4713 | } |
|---|
| 4714 | |
|---|
| 4715 | static u_int |
|---|
| 4716 | rssi2dbm (u_int rssi) |
|---|
| 4717 | { |
|---|
| 4718 | return rssi - 95; |
|---|
| 4719 | } |
|---|
| 4720 | |
|---|
| 4721 | int |
|---|
| 4722 | ej_active_wireless_if (webs_t wp, int argc, char_t ** argv, |
|---|
| 4723 | char *ifname, int cnt, int turbo, int macmask) |
|---|
| 4724 | { |
|---|
| 4725 | // unsigned char buf[24 * 1024]; |
|---|
| 4726 | |
|---|
| 4727 | unsigned char *cp; |
|---|
| 4728 | int s, len; |
|---|
| 4729 | struct iwreq iwr; |
|---|
| 4730 | if (!ifexists (ifname)) |
|---|
| 4731 | { |
|---|
| 4732 | printf (stderr, "IOCTL_STA_INFO ifresolv %s failed!\n", ifname); |
|---|
| 4733 | return cnt; |
|---|
| 4734 | } |
|---|
| 4735 | int state = get_radiostate (ifname); |
|---|
| 4736 | if (state == 0 || state == -1) |
|---|
| 4737 | { |
|---|
| 4738 | printf (stderr, "IOCTL_STA_INFO radio %s not enabled!\n", ifname); |
|---|
| 4739 | return cnt; |
|---|
| 4740 | } |
|---|
| 4741 | s = socket (AF_INET, SOCK_DGRAM, 0); |
|---|
| 4742 | if (s < 0) |
|---|
| 4743 | { |
|---|
| 4744 | fprintf (stderr, "socket(SOCK_DRAGM)\n"); |
|---|
| 4745 | return cnt; |
|---|
| 4746 | } |
|---|
| 4747 | (void) memset (&iwr, 0, sizeof (struct iwreq)); |
|---|
| 4748 | (void) strncpy (iwr.ifr_name, ifname, sizeof (iwr.ifr_name)); |
|---|
| 4749 | unsigned char *buf = (unsigned char *) malloc (24 * 1024); |
|---|
| 4750 | iwr.u.data.pointer = (void *) buf; |
|---|
| 4751 | iwr.u.data.length = 24 * 1024; |
|---|
| 4752 | if (ioctl (s, IEEE80211_IOCTL_STA_INFO, &iwr) < 0) |
|---|
| 4753 | { |
|---|
| 4754 | fprintf (stderr, "IOCTL_STA_INFO for %s failed!\n", ifname); |
|---|
| 4755 | close (s); |
|---|
| 4756 | free (buf); |
|---|
| 4757 | return cnt; |
|---|
| 4758 | } |
|---|
| 4759 | len = iwr.u.data.length; |
|---|
| 4760 | if (len < sizeof (struct ieee80211req_sta_info)) |
|---|
| 4761 | { |
|---|
| 4762 | // fprintf(stderr,"IOCTL_STA_INFO len<struct %s failed!\n",ifname); |
|---|
| 4763 | close (s); |
|---|
| 4764 | free (buf); |
|---|
| 4765 | return cnt; |
|---|
| 4766 | } |
|---|
| 4767 | cp = buf; |
|---|
| 4768 | do |
|---|
| 4769 | { |
|---|
| 4770 | struct ieee80211req_sta_info *si; |
|---|
| 4771 | uint8_t *vp; |
|---|
| 4772 | |
|---|
| 4773 | si = (struct ieee80211req_sta_info *) cp; |
|---|
| 4774 | vp = (u_int8_t *) (si + 1); |
|---|
| 4775 | |
|---|
| 4776 | if (cnt) |
|---|
| 4777 | websWrite (wp, ","); |
|---|
| 4778 | cnt++; |
|---|
| 4779 | char mac[32]; |
|---|
| 4780 | strcpy (mac, ieee80211_ntoa (si->isi_macaddr)); |
|---|
| 4781 | if (nvram_match ("maskmac", "1") && macmask) |
|---|
| 4782 | { |
|---|
| 4783 | mac[0] = 'x'; |
|---|
| 4784 | mac[1] = 'x'; |
|---|
| 4785 | mac[3] = 'x'; |
|---|
| 4786 | mac[4] = 'x'; |
|---|
| 4787 | mac[6] = 'x'; |
|---|
| 4788 | mac[7] = 'x'; |
|---|
| 4789 | mac[9] = 'x'; |
|---|
| 4790 | mac[10] = 'x'; |
|---|
| 4791 | } |
|---|
| 4792 | if (si->isi_noise == 0) |
|---|
| 4793 | { |
|---|
| 4794 | si->isi_noise = -95; |
|---|
| 4795 | } |
|---|
| 4796 | if (si->isi_rates) |
|---|
| 4797 | { |
|---|
| 4798 | websWrite (wp, "'%s','%s','%3dM','%3dM','%d','%d','%d'", |
|---|
| 4799 | mac, ifname, |
|---|
| 4800 | ((si->isi_rates[si->isi_txrate] & IEEE80211_RATE_VAL) / |
|---|
| 4801 | 2) * turbo, |
|---|
| 4802 | ((si->isi_rates[si->isi_rxrate] & IEEE80211_RATE_VAL) / |
|---|
| 4803 | 2) * turbo, si->isi_noise + si->isi_rssi, si->isi_noise, |
|---|
| 4804 | si->isi_rssi); |
|---|
| 4805 | } |
|---|
| 4806 | else |
|---|
| 4807 | { |
|---|
| 4808 | websWrite (wp, "'%s','%s','N/A','N/A','%d','%d','%d'", mac, ifname, |
|---|
| 4809 | si->isi_noise + si->isi_rssi, si->isi_noise, |
|---|
| 4810 | si->isi_rssi); |
|---|
| 4811 | } |
|---|
| 4812 | cp += si->isi_len; |
|---|
| 4813 | len -= si->isi_len; |
|---|
| 4814 | } |
|---|
| 4815 | while (len >= sizeof (struct ieee80211req_sta_info)); |
|---|
| 4816 | free (buf); |
|---|
| 4817 | close (s); |
|---|
| 4818 | |
|---|
| 4819 | return cnt; |
|---|
| 4820 | } |
|---|
| 4821 | extern char *getiflist (void); |
|---|
| 4822 | |
|---|
| 4823 | |
|---|
| 4824 | void |
|---|
| 4825 | ej_active_wireless (webs_t wp, int argc, char_t ** argv) |
|---|
| 4826 | { |
|---|
| 4827 | int c = getdevicecount (); |
|---|
| 4828 | char devs[32]; |
|---|
| 4829 | int i; |
|---|
| 4830 | int cnt = 0; |
|---|
| 4831 | char turbo[32]; |
|---|
| 4832 | int t; |
|---|
| 4833 | int macmask; |
|---|
| 4834 | #ifdef FASTWEB |
|---|
| 4835 | ejArgs (argc, argv, "%d", &macmask); |
|---|
| 4836 | #else |
|---|
| 4837 | if (ejArgs (argc, argv, "%d", &macmask) < 1) |
|---|
| 4838 | { |
|---|
| 4839 | websError (wp, 400, "Insufficient args\n"); |
|---|
| 4840 | return; |
|---|
| 4841 | } |
|---|
| 4842 | #endif |
|---|
| 4843 | for (i = 0; i < c; i++) |
|---|
| 4844 | { |
|---|
| 4845 | sprintf (devs, "ath%d", i); |
|---|
| 4846 | sprintf (turbo, "%s_turbo", devs); |
|---|
| 4847 | if (nvram_match (turbo, "1")) |
|---|
| 4848 | t = 2; |
|---|
| 4849 | else |
|---|
| 4850 | t = 1; |
|---|
| 4851 | cnt = ej_active_wireless_if (wp, argc, argv, devs, cnt, t, macmask); |
|---|
| 4852 | char vif[32]; |
|---|
| 4853 | sprintf (vif, "%s_vifs", devs); |
|---|
| 4854 | char var[80], *next; |
|---|
| 4855 | char *vifs = nvram_get (vif); |
|---|
| 4856 | if (vifs != NULL) |
|---|
| 4857 | foreach (var, vifs, next) |
|---|
| 4858 | { |
|---|
| 4859 | cnt = ej_active_wireless_if (wp, argc, argv, var, cnt, t, macmask); |
|---|
| 4860 | } |
|---|
| 4861 | } |
|---|
| 4862 | |
|---|
| 4863 | //show wds links |
|---|
| 4864 | for (i = 0; i < c; i++) |
|---|
| 4865 | { |
|---|
| 4866 | |
|---|
| 4867 | int s; |
|---|
| 4868 | for (s = 1; s <= 10; s++) |
|---|
| 4869 | { |
|---|
| 4870 | char wdsvarname[32] = { 0 }; |
|---|
| 4871 | char wdsdevname[32] = { 0 }; |
|---|
| 4872 | char wdsmacname[32] = { 0 }; |
|---|
| 4873 | char *dev; |
|---|
| 4874 | char *hwaddr; |
|---|
| 4875 | char var[80]; |
|---|
| 4876 | sprintf (wdsvarname, "ath%d_wds%d_enable", i, s); |
|---|
| 4877 | sprintf (wdsdevname, "ath%d_wds%d_if", i, s); |
|---|
| 4878 | sprintf (wdsmacname, "ath%d_wds%d_hwaddr", i, s); |
|---|
| 4879 | sprintf (turbo, "ath%d_turbo", i); |
|---|
| 4880 | if (nvram_match (turbo, "1")) |
|---|
| 4881 | t = 2; |
|---|
| 4882 | else |
|---|
| 4883 | t = 1; |
|---|
| 4884 | |
|---|
| 4885 | dev = nvram_safe_get (wdsdevname); |
|---|
| 4886 | if (dev == NULL || strlen (dev) == 0) |
|---|
| 4887 | continue; |
|---|
| 4888 | if (nvram_match (wdsvarname, "0")) |
|---|
| 4889 | continue; |
|---|
| 4890 | cnt = ej_active_wireless_if (wp, argc, argv, dev, cnt, t, macmask); |
|---|
| 4891 | } |
|---|
| 4892 | } |
|---|
| 4893 | } |
|---|
| 4894 | |
|---|
| 4895 | #else |
|---|
| 4896 | #define RSSI_TMP "/tmp/.rssi" |
|---|
| 4897 | #define ASSOCLIST_CMD "wl assoclist" |
|---|
| 4898 | #define RSSI_CMD "wl rssi" |
|---|
| 4899 | #define NOISE_CMD "wl noise" |
|---|
| 4900 | |
|---|
| 4901 | |
|---|
| 4902 | #ifndef HAVE_MSSID |
|---|
| 4903 | void |
|---|
| 4904 | ej_active_wireless (webs_t wp, int argc, char_t ** argv) |
|---|
| 4905 | { |
|---|
| 4906 | int rssi = 0, noise = 0; |
|---|
| 4907 | FILE *fp2; |
|---|
| 4908 | char *mode; |
|---|
| 4909 | char mac[30]; |
|---|
| 4910 | char list[2][30]; |
|---|
| 4911 | char line[80]; |
|---|
| 4912 | char cmd[80]; |
|---|
| 4913 | int macmask; |
|---|
| 4914 | #ifdef FASTWEB |
|---|
| 4915 | ejArgs (argc, argv, "%d", &macmask); |
|---|
| 4916 | #else |
|---|
| 4917 | if (ejArgs (argc, argv, "%d", &macmask) < 1) |
|---|
| 4918 | { |
|---|
| 4919 | websError (wp, 400, "Insufficient args\n"); |
|---|
| 4920 | return; |
|---|
| 4921 | } |
|---|
| 4922 | #endif |
|---|
| 4923 | |
|---|
| 4924 | unlink (RSSI_TMP); |
|---|
| 4925 | int cnt = 0; |
|---|
| 4926 | mode = nvram_safe_get ("wl_mode"); |
|---|
| 4927 | unsigned char buf[WLC_IOCTL_MAXLEN]; |
|---|
| 4928 | memset (buf, 0, WLC_IOCTL_MAXLEN); |
|---|
| 4929 | char *iface = get_wdev (); |
|---|
| 4930 | if (!ifexists (iface)) |
|---|
| 4931 | return; |
|---|
| 4932 | int r = getassoclist (iface, buf); |
|---|
| 4933 | if (r < 0) |
|---|
| 4934 | return; |
|---|
| 4935 | struct maclist *maclist = (struct maclist *) buf; |
|---|
| 4936 | int i; |
|---|
| 4937 | for (i = 0; i < maclist->count; i++) |
|---|
| 4938 | { |
|---|
| 4939 | ether_etoa ((uint8 *) & maclist->ea[i], mac); |
|---|
| 4940 | |
|---|
| 4941 | rssi = 0; |
|---|
| 4942 | noise = 0; |
|---|
| 4943 | // get rssi value |
|---|
| 4944 | if (strcmp (mode, "ap") && strcmp (mode, "apsta") |
|---|
| 4945 | && strcmp (mode, "apstawet")) |
|---|
| 4946 | sysprintf ("%s > %s", RSSI_CMD, RSSI_TMP); |
|---|
| 4947 | else |
|---|
| 4948 | sysprintf ("%s \"%s\" > %s", RSSI_CMD, mac, RSSI_TMP); |
|---|
| 4949 | |
|---|
| 4950 | // get noise value if not ap mode |
|---|
| 4951 | if (strcmp (mode, "ap")) |
|---|
| 4952 | sysprintf ("%s >> %s", NOISE_CMD, RSSI_TMP); |
|---|
| 4953 | |
|---|
| 4954 | fp2 = fopen (RSSI_TMP, "r"); |
|---|
| 4955 | if (fgets (line, sizeof (line), fp2) != NULL) |
|---|
| 4956 | { |
|---|
| 4957 | |
|---|
| 4958 | // get rssi |
|---|
| 4959 | //#ifdef HAVE_MSSID |
|---|
| 4960 | if (sscanf (line, "%d", &rssi) != 1) |
|---|
| 4961 | continue; |
|---|
| 4962 | |
|---|
| 4963 | // noise=getNoise(iface); |
|---|
| 4964 | |
|---|
| 4965 | if (strcmp (mode, "ap") && |
|---|
| 4966 | fgets (line, sizeof (line), fp2) != NULL && |
|---|
| 4967 | sscanf (line, "%d", &noise) != 1) |
|---|
| 4968 | continue; |
|---|
| 4969 | /*#else |
|---|
| 4970 | if (sscanf (line, "%s %s %d", list[0], list[1], &rssi) != 3) |
|---|
| 4971 | continue; |
|---|
| 4972 | // noise=getNoise(iface); |
|---|
| 4973 | if (strcmp (mode, "ap") && |
|---|
| 4974 | fgets (line, sizeof (line), fp2) != NULL && |
|---|
| 4975 | sscanf (line, "%s %s %d", list[0], list[1], &noise) != 3) |
|---|
| 4976 | continue; |
|---|
| 4977 | #endif*/ |
|---|
| 4978 | // get noise for client/wet mode |
|---|
| 4979 | |
|---|
| 4980 | fclose (fp2); |
|---|
| 4981 | } |
|---|
| 4982 | if (nvram_match ("maskmac", "1") && macmask) |
|---|
| 4983 | { |
|---|
| 4984 | mac[0] = 'x'; |
|---|
| 4985 | mac[1] = 'x'; |
|---|
| 4986 | mac[3] = 'x'; |
|---|
| 4987 | mac[4] = 'x'; |
|---|
| 4988 | mac[6] = 'x'; |
|---|
| 4989 | mac[7] = 'x'; |
|---|
| 4990 | mac[9] = 'x'; |
|---|
| 4991 | mac[10] = 'x'; |
|---|
| 4992 | } |
|---|
| 4993 | if (cnt) |
|---|
| 4994 | websWrite (wp, ","); |
|---|
| 4995 | cnt++; |
|---|
| 4996 | if (!strcmp (mode, "ap")) |
|---|
| 4997 | { |
|---|
| 4998 | // char *ref = nvram_get ("noise_reference"); |
|---|
| 4999 | noise = -98; |
|---|
| 5000 | //if (ref) |
|---|
| 5001 | //noise = atoi (ref); |
|---|
| 5002 | } |
|---|
| 5003 | websWrite (wp, "'%s','%d','%d','%d'", mac, rssi, noise, rssi - noise); |
|---|
| 5004 | } |
|---|
| 5005 | unlink (RSSI_TMP); |
|---|
| 5006 | |
|---|
| 5007 | return; |
|---|
| 5008 | } |
|---|
| 5009 | #else |
|---|
| 5010 | int |
|---|
| 5011 | ej_active_wireless_if (webs_t wp, int argc, char_t ** argv, |
|---|
| 5012 | char *iface, char *visible, int cnt) |
|---|
| 5013 | { |
|---|
| 5014 | int rssi = 0, noise = 0; |
|---|
| 5015 | FILE *fp2; |
|---|
| 5016 | char *mode; |
|---|
| 5017 | char mac[30]; |
|---|
| 5018 | char list[2][30]; |
|---|
| 5019 | char line[80]; |
|---|
| 5020 | int macmask; |
|---|
| 5021 | #ifdef FASTWEB |
|---|
| 5022 | ejArgs (argc, argv, "%d", &macmask); |
|---|
| 5023 | #else |
|---|
| 5024 | if (ejArgs (argc, argv, "%d", &macmask) < 1) |
|---|
| 5025 | { |
|---|
| 5026 | websError (wp, 400, "Insufficient args\n"); |
|---|
| 5027 | return 0; |
|---|
| 5028 | } |
|---|
| 5029 | #endif |
|---|
| 5030 | if (!ifexists (iface)) |
|---|
| 5031 | return cnt; |
|---|
| 5032 | unlink (RSSI_TMP); |
|---|
| 5033 | char wlmode[32]; |
|---|
| 5034 | sprintf (wlmode, "%s_mode", visible); |
|---|
| 5035 | mode = nvram_safe_get (wlmode); |
|---|
| 5036 | unsigned char buf[WLC_IOCTL_MAXLEN]; |
|---|
| 5037 | memset (buf, 0, WLC_IOCTL_MAXLEN); //get_wdev |
|---|
| 5038 | int r = getassoclist (iface, buf); |
|---|
| 5039 | if (r < 0) |
|---|
| 5040 | return cnt; |
|---|
| 5041 | struct maclist *maclist = (struct maclist *) buf; |
|---|
| 5042 | int i; |
|---|
| 5043 | for (i = 0; i < maclist->count; i++) |
|---|
| 5044 | { |
|---|
| 5045 | ether_etoa ((uint8 *) & maclist->ea[i], mac); |
|---|
| 5046 | |
|---|
| 5047 | rssi = 0; |
|---|
| 5048 | noise = 0; |
|---|
| 5049 | // get rssi value |
|---|
| 5050 | if (strcmp (mode, "ap") && strcmp (mode, "apsta") |
|---|
| 5051 | && strcmp (mode, "apstawet")) |
|---|
| 5052 | sysprintf ("wl -i %s rssi > %s", iface, RSSI_TMP); |
|---|
| 5053 | else |
|---|
| 5054 | sysprintf ("wl -i %s rssi \"%s\" > %s", iface, mac, RSSI_TMP); |
|---|
| 5055 | |
|---|
| 5056 | // get noise value if not ap mode |
|---|
| 5057 | // if (strcmp (mode, "ap")) |
|---|
| 5058 | // snprintf (cmd, sizeof (cmd), "wl -i %s noise >> %s", iface, RSSI_TMP); |
|---|
| 5059 | // system2 (cmd); // get RSSI value for mac |
|---|
| 5060 | |
|---|
| 5061 | fp2 = fopen (RSSI_TMP, "r"); |
|---|
| 5062 | if (fgets (line, sizeof (line), fp2) != NULL) |
|---|
| 5063 | { |
|---|
| 5064 | |
|---|
| 5065 | // get rssi |
|---|
| 5066 | if (sscanf (line, "%d", &rssi) != 1) |
|---|
| 5067 | continue; |
|---|
| 5068 | noise = getNoise (iface, NULL); |
|---|
| 5069 | /* if (strcmp (mode, "ap") && |
|---|
| 5070 | fgets (line, sizeof (line), fp2) != NULL && |
|---|
| 5071 | sscanf (line, "%d", &noise) != 1) |
|---|
| 5072 | continue;*/ |
|---|
| 5073 | // get noise for client/wet mode |
|---|
| 5074 | |
|---|
| 5075 | fclose (fp2); |
|---|
| 5076 | } |
|---|
| 5077 | if (nvram_match ("maskmac", "1") && macmask) |
|---|
| 5078 | { |
|---|
| 5079 | mac[0] = 'x'; |
|---|
| 5080 | mac[1] = 'x'; |
|---|
| 5081 | mac[3] = 'x'; |
|---|
| 5082 | mac[4] = 'x'; |
|---|
| 5083 | mac[6] = 'x'; |
|---|
| 5084 | mac[7] = 'x'; |
|---|
| 5085 | mac[9] = 'x'; |
|---|
| 5086 | mac[10] = 'x'; |
|---|
| 5087 | } |
|---|
| 5088 | if (cnt) |
|---|
| 5089 | websWrite (wp, ","); |
|---|
| 5090 | cnt++; |
|---|
| 5091 | /* if (!strcmp (mode, "ap")) |
|---|
| 5092 | { |
|---|
| 5093 | noise = getNoise(iface,NULL); // null only for broadcom |
|---|
| 5094 | }*/ |
|---|
| 5095 | websWrite (wp, "'%s','%s','N/A','N/A','%d','%d','%d'", mac, iface, rssi, |
|---|
| 5096 | noise, rssi - noise); |
|---|
| 5097 | } |
|---|
| 5098 | unlink (RSSI_TMP); |
|---|
| 5099 | |
|---|
| 5100 | return cnt; |
|---|
| 5101 | } |
|---|
| 5102 | |
|---|
| 5103 | void |
|---|
| 5104 | ej_active_wireless (webs_t wp, int argc, char_t ** argv) |
|---|
| 5105 | { |
|---|
| 5106 | int cnt = 0; |
|---|
| 5107 | int c = get_wl_instances (); |
|---|
| 5108 | int i; |
|---|
| 5109 | for (i = 0; i < c; i++) |
|---|
| 5110 | { |
|---|
| 5111 | char wlif[32]; |
|---|
| 5112 | sprintf (wlif, "wl%d", i); |
|---|
| 5113 | cnt = |
|---|
| 5114 | ej_active_wireless_if (wp, argc, argv, get_wl_instance_name (i), wlif, |
|---|
| 5115 | cnt); |
|---|
| 5116 | char *next; |
|---|
| 5117 | char var[80]; |
|---|
| 5118 | char *vifs = nvram_nget ("wl%d_vifs", i); |
|---|
| 5119 | if (vifs == NULL) |
|---|
| 5120 | return; |
|---|
| 5121 | |
|---|
| 5122 | foreach (var, vifs, next) |
|---|
| 5123 | { |
|---|
| 5124 | cnt = ej_active_wireless_if (wp, argc, argv, var, var, cnt); |
|---|
| 5125 | } |
|---|
| 5126 | } |
|---|
| 5127 | } |
|---|
| 5128 | |
|---|
| 5129 | |
|---|
| 5130 | #endif |
|---|
| 5131 | |
|---|
| 5132 | |
|---|
| 5133 | #endif |
|---|
| 5134 | |
|---|
| 5135 | #define WDS_RSSI_TMP "/tmp/.rssi" |
|---|
| 5136 | void ej_active_wds_instance (webs_t wp, int argc, char_t ** argv, |
|---|
| 5137 | int instance); |
|---|
| 5138 | void |
|---|
| 5139 | ej_active_wds (webs_t wp, int argc, char_t ** argv) |
|---|
| 5140 | { |
|---|
| 5141 | int cnt = get_wl_instances (); |
|---|
| 5142 | int c; |
|---|
| 5143 | for (c = 0; c < cnt; c++) |
|---|
| 5144 | ej_active_wds_instance (wp, argc, argv, c); |
|---|
| 5145 | } |
|---|
| 5146 | |
|---|
| 5147 | void |
|---|
| 5148 | ej_active_wds_instance (webs_t wp, int argc, char_t ** argv, int instance) |
|---|
| 5149 | { |
|---|
| 5150 | #ifndef HAVE_MADWIFI |
|---|
| 5151 | int rssi = 0, i; |
|---|
| 5152 | FILE *fp2; |
|---|
| 5153 | char *mode; |
|---|
| 5154 | char mac[30]; |
|---|
| 5155 | char list[2][30]; |
|---|
| 5156 | char line[80]; |
|---|
| 5157 | // char title[30]; |
|---|
| 5158 | char wdsvar[30]; |
|---|
| 5159 | char desc[30]; |
|---|
| 5160 | int cnt = 0; |
|---|
| 5161 | int macmask; |
|---|
| 5162 | if (ejArgs (argc, argv, "%d", &macmask) < 1) |
|---|
| 5163 | { |
|---|
| 5164 | websError (wp, 400, "Insufficient args\n"); |
|---|
| 5165 | return; |
|---|
| 5166 | } |
|---|
| 5167 | |
|---|
| 5168 | unlink (WDS_RSSI_TMP); |
|---|
| 5169 | |
|---|
| 5170 | mode = nvram_nget ("wl%d_mode", instance); |
|---|
| 5171 | |
|---|
| 5172 | if (strcmp (mode, "ap") && strcmp (mode, "apsta") |
|---|
| 5173 | && strcmp (mode, "apstawet")) |
|---|
| 5174 | return; |
|---|
| 5175 | unsigned char buf[WLC_IOCTL_MAXLEN]; |
|---|
| 5176 | char *iface = get_wl_instance_name (instance); |
|---|
| 5177 | if (!ifexists (iface)) |
|---|
| 5178 | return; |
|---|
| 5179 | int r = getwdslist (iface, buf); |
|---|
| 5180 | if (r < 0) |
|---|
| 5181 | return; |
|---|
| 5182 | struct maclist *maclist = (struct maclist *) buf; |
|---|
| 5183 | int e; |
|---|
| 5184 | for (e = 0; e < maclist->count; e++) |
|---|
| 5185 | { |
|---|
| 5186 | |
|---|
| 5187 | ether_etoa ((uint8 *) & maclist->ea[e], mac); |
|---|
| 5188 | |
|---|
| 5189 | |
|---|
| 5190 | rssi = 0; |
|---|
| 5191 | memset (desc, 0, 30); |
|---|
| 5192 | for (i = 1; i <= 10; i++) |
|---|
| 5193 | { |
|---|
| 5194 | snprintf (wdsvar, 30, "wl%d_wds%d_hwaddr", instance, i); |
|---|
| 5195 | if (nvram_match (wdsvar, mac)) |
|---|
| 5196 | { |
|---|
| 5197 | snprintf (wdsvar, 30, "wl%d_wds%d_desc", instance, i); |
|---|
| 5198 | snprintf (desc, sizeof (desc), "%s", nvram_get (wdsvar)); |
|---|
| 5199 | if (!strcmp (nvram_get (wdsvar), "")) |
|---|
| 5200 | strcpy (desc, " "); |
|---|
| 5201 | } |
|---|
| 5202 | } |
|---|
| 5203 | |
|---|
| 5204 | sysprintf ("%s \"%s\" > %s", RSSI_CMD, mac, RSSI_TMP); |
|---|
| 5205 | |
|---|
| 5206 | fp2 = fopen (RSSI_TMP, "r"); |
|---|
| 5207 | if (fgets (line, sizeof (line), fp2) != NULL) |
|---|
| 5208 | { |
|---|
| 5209 | |
|---|
| 5210 | // get rssi |
|---|
| 5211 | if (sscanf (line, "%d", &rssi) != 1) |
|---|
| 5212 | continue; |
|---|
| 5213 | fclose (fp2); |
|---|
| 5214 | } |
|---|
| 5215 | if (nvram_match ("maskmac", "1") && macmask) |
|---|
| 5216 | { |
|---|
| 5217 | mac[0] = 'x'; |
|---|
| 5218 | mac[1] = 'x'; |
|---|
| 5219 | mac[3] = 'x'; |
|---|
| 5220 | mac[4] = 'x'; |
|---|
| 5221 | mac[6] = 'x'; |
|---|
| 5222 | mac[7] = 'x'; |
|---|
| 5223 | mac[9] = 'x'; |
|---|
| 5224 | mac[10] = 'x'; |
|---|
| 5225 | } |
|---|
| 5226 | if (cnt) |
|---|
| 5227 | websWrite (wp, ","); |
|---|
| 5228 | cnt++; |
|---|
| 5229 | int noise = getNoise (iface, NULL); |
|---|
| 5230 | websWrite (wp, |
|---|
| 5231 | "\"%s\",\"%s\",\"%d\",\"%d\",\"%d\"", |
|---|
| 5232 | mac, desc, rssi, noise, rssi - noise); |
|---|
| 5233 | } |
|---|
| 5234 | |
|---|
| 5235 | unlink (WDS_RSSI_TMP); |
|---|
| 5236 | #endif |
|---|
| 5237 | return; |
|---|
| 5238 | } |
|---|
| 5239 | |
|---|
| 5240 | |
|---|
| 5241 | void |
|---|
| 5242 | ej_get_wdsp2p (webs_t wp, int argc, char_t ** argv) |
|---|
| 5243 | { |
|---|
| 5244 | int index = -1, ip[4] = { 0, 0, 0, 0 }, netmask[4] = |
|---|
| 5245 | { |
|---|
| 5246 | 0, 0, 0, 0}; |
|---|
| 5247 | char nvramvar[32] = { 0 }; |
|---|
| 5248 | char *interface; |
|---|
| 5249 | #ifdef FASTWEB |
|---|
| 5250 | ejArgs (argc, argv, "%d %s", &index, &interface); |
|---|
| 5251 | #else |
|---|
| 5252 | if (ejArgs (argc, argv, "%d %s", &index, &interface) < 2) |
|---|
| 5253 | { |
|---|
| 5254 | websError (wp, 400, "Insufficient args\n"); |
|---|
| 5255 | return; |
|---|
| 5256 | } |
|---|
| 5257 | #endif |
|---|
| 5258 | char wlwds[32]; |
|---|
| 5259 | sprintf (wlwds, "%s_wds1_enable", interface); |
|---|
| 5260 | if (nvram_selmatch (wp, "wk_mode", "ospf") && |
|---|
| 5261 | nvram_selmatch (wp, "expert_mode", "1") && |
|---|
| 5262 | nvram_selmatch (wp, wlwds, "1")) |
|---|
| 5263 | { |
|---|
| 5264 | char buf[16]; |
|---|
| 5265 | sprintf (buf, "%s_wds%d_ospf", interface, index); |
|---|
| 5266 | websWrite (wp, |
|---|
| 5267 | "<input name=\"%s\" size=\"2\" maxlength=\"5\" value=\"%s\" />\n", |
|---|
| 5268 | buf, nvram_safe_get (buf)); |
|---|
| 5269 | } |
|---|
| 5270 | |
|---|
| 5271 | snprintf (nvramvar, 31, "%s_wds%d_ipaddr", interface, index); |
|---|
| 5272 | sscanf (nvram_safe_get (nvramvar), "%d.%d.%d.%d", &ip[0], &ip[1], &ip[2], |
|---|
| 5273 | &ip[3]); |
|---|
| 5274 | snprintf (nvramvar, 31, "%s_wds%d_netmask", interface, index); |
|---|
| 5275 | sscanf (nvram_safe_get (nvramvar), "%d.%d.%d.%d", &netmask[0], &netmask[1], |
|---|
| 5276 | &netmask[2], &netmask[3]); |
|---|
| 5277 | snprintf (nvramvar, 31, "%s_wds%d_enable", interface, index); |
|---|
| 5278 | |
|---|
| 5279 | // set netmask to a suggested default if blank |
|---|
| 5280 | if (netmask[0] == 0 && |
|---|
| 5281 | netmask[1] == 0 && netmask[2] == 0 && netmask[3] == 0) |
|---|
| 5282 | { |
|---|
| 5283 | netmask[0] = 255; |
|---|
| 5284 | netmask[1] = 255; |
|---|
| 5285 | netmask[2] = 255; |
|---|
| 5286 | netmask[3] = 252; |
|---|
| 5287 | } |
|---|
| 5288 | |
|---|
| 5289 | if (nvram_match (nvramvar, "1")) |
|---|
| 5290 | { |
|---|
| 5291 | websWrite (wp, "\ |
|---|
| 5292 | <div class=\"setting\">\n\ |
|---|
| 5293 | <input type=\"hidden\" name=\"%s_wds%d_ipaddr\" value=\"4\">\n\ |
|---|
| 5294 | <div class=\"label\"><script type=\"text/javascript\">Capture(share.ip)</script></div>\n\ |
|---|
| 5295 | <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\ |
|---|
| 5296 | </div>\n", interface, index, interface, index, ip[0], interface, index, ip[1], interface, index, ip[2], interface, index, ip[3]); |
|---|
| 5297 | |
|---|
| 5298 | websWrite (wp, "\ |
|---|
| 5299 | <div class=\"setting\">\n\ |
|---|
| 5300 | <div class=\"label\"><script type=\"text/javascript\">Capture(share.subnet)</script></div>\n\ |
|---|
| 5301 | <input type=\"hidden\" name=\"%s_wds%d_netmask\" value=\"4\">\n\ |
|---|
| 5302 | <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\ |
|---|
| 5303 | </div>\n", interface, index, interface, index, netmask[0], interface, index, netmask[1], interface, index, netmask[2], interface, index, netmask[3]); |
|---|
| 5304 | |
|---|
| 5305 | } |
|---|
| 5306 | |
|---|
| 5307 | return; |
|---|
| 5308 | |
|---|
| 5309 | } |
|---|
| 5310 | |
|---|
| 5311 | |
|---|
| 5312 | |
|---|
| 5313 | |
|---|
| 5314 | /* |
|---|
| 5315 | void |
|---|
| 5316 | ej_get_services_options (webs_t wp, int argc, char_t ** argv) |
|---|
| 5317 | { |
|---|
| 5318 | char word[1024], *next, *services; |
|---|
| 5319 | char delim[] = "< >"; |
|---|
| 5320 | |
|---|
| 5321 | //services = nvram_safe_get("filter_services"); |
|---|
| 5322 | services = get_filter_services (); |
|---|
| 5323 | |
|---|
| 5324 | split (word, services, next, delim) |
|---|
| 5325 | { |
|---|
| 5326 | int len = 0; |
|---|
| 5327 | char *name, *prot, *port; |
|---|
| 5328 | char protocol[100], ports[100]; |
|---|
| 5329 | int from = 0, to = 0; |
|---|
| 5330 | //int proto; |
|---|
| 5331 | |
|---|
| 5332 | if ((name = strstr (word, "$NAME:")) == NULL || |
|---|
| 5333 | (prot = strstr (word, "$PROT:")) == NULL || |
|---|
| 5334 | (port = strstr (word, "$PORT:")) == NULL) |
|---|
| 5335 | continue; |
|---|
| 5336 | |
|---|
| 5337 | // $NAME |
|---|
| 5338 | if (sscanf (name, "$NAME:%3d:", &len) != 1) |
|---|
| 5339 | continue; |
|---|
| 5340 | |
|---|
| 5341 | strncpy (name, name + sizeof ("$NAME:nnn:") - 1, len); |
|---|
| 5342 | name[len] = '\0'; |
|---|
| 5343 | |
|---|
| 5344 | // $PROT |
|---|
| 5345 | if (sscanf (prot, "$PROT:%3d:", &len) != 1) |
|---|
| 5346 | continue; |
|---|
| 5347 | |
|---|
| 5348 | strncpy (protocol, prot + sizeof ("$PROT:nnn:") - 1, len); |
|---|
| 5349 | protocol[len] = '\0'; |
|---|
| 5350 | |
|---|
| 5351 | // $PORT |
|---|
| 5352 | if (sscanf (port, "$PORT:%3d:", &len) != 1) |
|---|
| 5353 | continue; |
|---|
| 5354 | |
|---|
| 5355 | strncpy (ports, port + sizeof ("$PORT:nnn:") - 1, len); |
|---|
| 5356 | ports[len] = '\0'; |
|---|
| 5357 | |
|---|
| 5358 | if (sscanf (ports, "%d:%d", &from, &to) != 2) |
|---|
| 5359 | continue; |
|---|
| 5360 | |
|---|
| 5361 | //cprintf("match:: name=%s, protocol=%s, ports=%s\n", |
|---|
| 5362 | // word, protocol, ports); |
|---|
| 5363 | |
|---|
| 5364 | websWrite (wp, "<option value=\"%s\">%s</option>", name, name); |
|---|
| 5365 | |
|---|
| 5366 | } |
|---|
| 5367 | |
|---|
| 5368 | return; |
|---|
| 5369 | } |
|---|
| 5370 | */ |
|---|
| 5371 | |
|---|
| 5372 | |
|---|
| 5373 | void |
|---|
| 5374 | ej_get_clone_wmac (webs_t wp, int argc, char_t ** argv) |
|---|
| 5375 | { |
|---|
| 5376 | #ifdef HAVE_RB500 |
|---|
| 5377 | return 0; |
|---|
| 5378 | #else |
|---|
| 5379 | |
|---|
| 5380 | char *c; |
|---|
| 5381 | int mac, which; |
|---|
| 5382 | int dofree = 0; |
|---|
| 5383 | #ifdef FASTWEB |
|---|
| 5384 | ejArgs (argc, argv, "%d", &which); |
|---|
| 5385 | #else |
|---|
| 5386 | if (ejArgs (argc, argv, "%d", &which) < 1) |
|---|
| 5387 | { |
|---|
| 5388 | websError (wp, 400, "Insufficient args\n"); |
|---|
| 5389 | return; |
|---|
| 5390 | } |
|---|
| 5391 | #endif |
|---|
| 5392 | |
|---|
| 5393 | if (nvram_match ("def_whwaddr", "00:00:00:00:00:00")) |
|---|
| 5394 | { |
|---|
| 5395 | // if (strlen (nvram_safe_get ("il0macaddr")) == 0) |
|---|
| 5396 | // { |
|---|
| 5397 | // if (nvram_match ("port_swap", "1")) |
|---|
| 5398 | // c = strdup (nvram_safe_get ("et1macaddr")); |
|---|
| 5399 | // else |
|---|
| 5400 | // c = strdup (nvram_safe_get ("et0macaddr")); |
|---|
| 5401 | // MAC_ADD (c); |
|---|
| 5402 | // } |
|---|
| 5403 | // else |
|---|
| 5404 | // { |
|---|
| 5405 | // c = strdup (nvram_safe_get ("il0macaddr")); |
|---|
| 5406 | // } |
|---|
| 5407 | // dofree = 1; |
|---|
| 5408 | |
|---|
| 5409 | if (nvram_match ("port_swap", "1")) |
|---|
| 5410 | { |
|---|
| 5411 | if (strlen (nvram_safe_get ("et1macaddr")) != 0) //safe: maybe et1macaddr not there? |
|---|
| 5412 | { |
|---|
| 5413 | c = strdup (nvram_safe_get ("et1macaddr")); |
|---|
| 5414 | } |
|---|
| 5415 | else |
|---|
| 5416 | { |
|---|
| 5417 | c = strdup (nvram_safe_get ("et0macaddr")); |
|---|
| 5418 | MAC_ADD (c); //et0macaddr +3 |
|---|
| 5419 | } |
|---|
| 5420 | } |
|---|
| 5421 | else |
|---|
| 5422 | { |
|---|
| 5423 | c = strdup (nvram_safe_get ("et0macaddr")); |
|---|
| 5424 | } |
|---|
| 5425 | |
|---|
| 5426 | dofree = 1; |
|---|
| 5427 | if (c) |
|---|
| 5428 | { |
|---|
| 5429 | MAC_ADD (c); |
|---|
| 5430 | MAC_ADD (c); |
|---|
| 5431 | } |
|---|
| 5432 | |
|---|
| 5433 | } |
|---|
| 5434 | else |
|---|
| 5435 | c = nvram_safe_get ("def_whwaddr"); |
|---|
| 5436 | |
|---|
| 5437 | if (c) |
|---|
| 5438 | { |
|---|
| 5439 | mac = get_single_mac (c, which); |
|---|
| 5440 | websWrite (wp, "%02X", mac); |
|---|
| 5441 | if (dofree) |
|---|
| 5442 | free (c); |
|---|
| 5443 | } |
|---|
| 5444 | else |
|---|
| 5445 | websWrite (wp, "00"); |
|---|
| 5446 | |
|---|
| 5447 | return; |
|---|
| 5448 | #endif |
|---|
| 5449 | } |
|---|
| 5450 | |
|---|
| 5451 | |
|---|
| 5452 | |
|---|
| 5453 | /* todo stylesheet compatible code */ |
|---|
| 5454 | /* lonewolf additions */ |
|---|
| 5455 | |
|---|
| 5456 | // Note that there is no VLAN #16. It's just a convieniant way of denoting a "Tagged" port |
|---|
| 5457 | void |
|---|
| 5458 | ej_port_vlan_table (webs_t wp, int argc, char_t ** argv) |
|---|
| 5459 | { |
|---|
| 5460 | /* |
|---|
| 5461 | vlans[x][y] where |
|---|
| 5462 | x 0-15 are VLANS |
|---|
| 5463 | x 16 is tagging, 17 is auto-negotiation, 18 is 100/10 Mbit, and 19 is Full/Half duplex |
|---|
| 5464 | y 0-4 are switch ports (port 5 is set automaticly) |
|---|
| 5465 | y 5 it the bridge device (x 16 dosn't apply) |
|---|
| 5466 | */ |
|---|
| 5467 | |
|---|
| 5468 | int i, j, vlans[21][6], tmp, wl_br; |
|---|
| 5469 | char *c, *next, buff[32], portvlan[32]; |
|---|
| 5470 | |
|---|
| 5471 | for (i = 0; i < 21; i++) |
|---|
| 5472 | for (j = 0; j < 6; j++) |
|---|
| 5473 | vlans[i][j] = -1; |
|---|
| 5474 | |
|---|
| 5475 | wl_br = -1; |
|---|
| 5476 | |
|---|
| 5477 | for (i = 0; i < 8; i++) |
|---|
| 5478 | { |
|---|
| 5479 | if (i < 5) |
|---|
| 5480 | snprintf (buff, 31, "port%dvlans", i); |
|---|
| 5481 | else if (i == 5) |
|---|
| 5482 | snprintf (buff, 31, "%s", "lan_ifnames"); |
|---|
| 5483 | else |
|---|
| 5484 | snprintf (buff, 31, "ub%d_ifnames", i - 5); |
|---|
| 5485 | |
|---|
| 5486 | c = nvram_safe_get (buff); |
|---|
| 5487 | |
|---|
| 5488 | if (c) |
|---|
| 5489 | { |
|---|
| 5490 | foreach (portvlan, c, next) |
|---|
| 5491 | { |
|---|
| 5492 | if (portvlan[0] == 'e' && portvlan[1] == 't' && portvlan[2] == 'h' |
|---|
| 5493 | && portvlan[3] == '1') |
|---|
| 5494 | wl_br = i - 5; |
|---|
| 5495 | if (ISDIGIT (portvlan, 1) |
|---|
| 5496 | || (portvlan[0] == 'v' && portvlan[1] == 'l' |
|---|
| 5497 | && portvlan[2] == 'a' && portvlan[3] == 'n')) |
|---|
| 5498 | { |
|---|
| 5499 | if (ISDIGIT (portvlan, 1)) |
|---|
| 5500 | tmp = atoi (portvlan); |
|---|
| 5501 | else |
|---|
| 5502 | { |
|---|
| 5503 | portvlan[0] = portvlan[4]; |
|---|
| 5504 | portvlan[1] = portvlan[5]; |
|---|
| 5505 | portvlan[2] = '\0'; |
|---|
| 5506 | if (ISDIGIT (portvlan, 1)) |
|---|
| 5507 | tmp = atoi (portvlan); |
|---|
| 5508 | else |
|---|
| 5509 | continue; |
|---|
| 5510 | } |
|---|
| 5511 | |
|---|
| 5512 | if (i < 5) |
|---|
| 5513 | { |
|---|
| 5514 | vlans[tmp][i] = 1; |
|---|
| 5515 | } |
|---|
| 5516 | else |
|---|
| 5517 | { |
|---|
| 5518 | vlans[tmp][5] = i - 5; |
|---|
| 5519 | } |
|---|
| 5520 | } |
|---|
| 5521 | } |
|---|
| 5522 | } |
|---|
| 5523 | } |
|---|
| 5524 | |
|---|
| 5525 | for (i = 0; i < 21; i++) |
|---|
| 5526 | { |
|---|
| 5527 | websWrite (wp, " <tr>\n"); |
|---|
| 5528 | websWrite (wp, "<td>"); |
|---|
| 5529 | |
|---|
| 5530 | switch (i) |
|---|
| 5531 | { |
|---|
| 5532 | case 16: |
|---|
| 5533 | websWrite (wp, |
|---|
| 5534 | "<script type=\"text/javascript\">Capture(vlan.tagged)</script>"); |
|---|
| 5535 | break; |
|---|
| 5536 | case 17: |
|---|
| 5537 | websWrite (wp, |
|---|
| 5538 | "<script type=\"text/javascript\">Capture(vlan.negociate)</script>"); |
|---|
| 5539 | break; |
|---|
| 5540 | case 18: |
|---|
| 5541 | websWrite (wp, "100 Mbit"); |
|---|
| 5542 | break; |
|---|
| 5543 | case 19: |
|---|
| 5544 | websWrite (wp, "Full-Duplex"); |
|---|
| 5545 | break; |
|---|
| 5546 | case 20: |
|---|
| 5547 | websWrite (wp, "Enabled"); |
|---|
| 5548 | break; |
|---|
| 5549 | default: |
|---|
| 5550 | snprintf (buff, 31, "%d", i); |
|---|
| 5551 | websWrite (wp, buff); |
|---|
| 5552 | break; |
|---|
| 5553 | } |
|---|
| 5554 | |
|---|
| 5555 | websWrite (wp, "</td>\n"); |
|---|
| 5556 | |
|---|
| 5557 | for (j = 0; j < 5; j++) |
|---|
| 5558 | { |
|---|
| 5559 | snprintf (buff, 31, "\"port%dvlan%d\"", j, i); |
|---|
| 5560 | websWrite (wp, "<td"); |
|---|
| 5561 | |
|---|
| 5562 | if (j % 2 == 0) |
|---|
| 5563 | websWrite (wp, " bgcolor=\"#CCCCCC\""); |
|---|
| 5564 | |
|---|
| 5565 | |
|---|
| 5566 | websWrite (wp, |
|---|
| 5567 | " height=\"20\"><div align=\"center\"><input type=\"checkbox\" value=\"on\" name="); |
|---|
| 5568 | websWrite (wp, buff); |
|---|
| 5569 | |
|---|
| 5570 | if (i < 17 || i > 20) |
|---|
| 5571 | { |
|---|
| 5572 | if (vlans[i][j] == 1) |
|---|
| 5573 | websWrite (wp, " checked=\"checked\""); |
|---|
| 5574 | } |
|---|
| 5575 | else |
|---|
| 5576 | { |
|---|
| 5577 | if (vlans[i][j] == -1) |
|---|
| 5578 | websWrite (wp, " checked=\"checked\""); |
|---|
| 5579 | } |
|---|
| 5580 | |
|---|
| 5581 | if (i < 17) |
|---|
| 5582 | { |
|---|
| 5583 | websWrite (wp, " onclick="); |
|---|
| 5584 | snprintf (buff, sizeof (buff), |
|---|
| 5585 | "\"SelVLAN(this.form,'port%d')\"", j); |
|---|
| 5586 | websWrite (wp, buff); |
|---|
| 5587 | } |
|---|
| 5588 | else if (i == 17 || i == 20) |
|---|
| 5589 | { |
|---|
| 5590 | websWrite (wp, " onclick="); |
|---|
| 5591 | snprintf (buff, sizeof (buff), |
|---|
| 5592 | "\"SelSpeed(this.form,'port%d')\"", j); |
|---|
| 5593 | websWrite (wp, buff); |
|---|
| 5594 | } |
|---|
| 5595 | websWrite (wp, " /></div></td>\n"); |
|---|
| 5596 | } |
|---|
| 5597 | |
|---|
| 5598 | if (i < 16) |
|---|
| 5599 | { |
|---|
| 5600 | websWrite (wp, " <td><select name="); |
|---|
| 5601 | snprintf (buff, 31, "\"vlan%d\"", i); |
|---|
| 5602 | websWrite (wp, buff); |
|---|
| 5603 | websWrite (wp, |
|---|
| 5604 | "><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"-1\\\""); |
|---|
| 5605 | if (vlans[i][5] < 0) |
|---|
| 5606 | websWrite (wp, " selected=\\\"selected\\\""); |
|---|
| 5607 | websWrite (wp, |
|---|
| 5608 | ">\" + share.none + \"</option>\");\n//]]>\n</script><option value=\"0\""); |
|---|
| 5609 | if (vlans[i][5] == 0) |
|---|
| 5610 | websWrite (wp, " selected=\"selected\""); |
|---|
| 5611 | websWrite (wp, ">LAN</option></select></td>\n"); |
|---|
| 5612 | } |
|---|
| 5613 | else |
|---|
| 5614 | { |
|---|
| 5615 | websWrite (wp, "<td> </td>\n"); |
|---|
| 5616 | } |
|---|
| 5617 | |
|---|
| 5618 | websWrite (wp, "</tr>\n"); |
|---|
| 5619 | |
|---|
| 5620 | if (i == 16 || i == 20) |
|---|
| 5621 | { |
|---|
| 5622 | websWrite (wp, "<tr><td> </td></tr>\n"); |
|---|
| 5623 | } |
|---|
| 5624 | } |
|---|
| 5625 | |
|---|
| 5626 | websWrite (wp, "<tr>\n"); |
|---|
| 5627 | websWrite (wp, |
|---|
| 5628 | "<td><script type=\"text/javascript\">Capture(share.wireless)</script></td>\n"); |
|---|
| 5629 | |
|---|
| 5630 | websWrite (wp, |
|---|
| 5631 | "<td colspan=\"6\"><select name=\"wireless\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"-1\\\""); |
|---|
| 5632 | if (wl_br < 0) |
|---|
| 5633 | websWrite (wp, " selected=\\\"selected\\\""); |
|---|
| 5634 | websWrite (wp, |
|---|
| 5635 | ">\" + share.none + \"</option>\");\n//]]>\n</script><option value=\"0\""); |
|---|
| 5636 | if (wl_br == 0) |
|---|
| 5637 | websWrite (wp, " selected=\"selected\""); |
|---|
| 5638 | websWrite (wp, ">LAN</option></select></td>\n"); |
|---|
| 5639 | websWrite (wp, "</tr>\n"); |
|---|
| 5640 | |
|---|
| 5641 | websWrite (wp, "<tr><td> </td></tr>\n"); |
|---|
| 5642 | |
|---|
| 5643 | websWrite (wp, "<tr>\n"); |
|---|
| 5644 | websWrite (wp, |
|---|
| 5645 | "<td><script type=\"text/javascript\">Capture(vlan.aggregation)</script></td>\n"); |
|---|
| 5646 | |
|---|
| 5647 | websWrite (wp, |
|---|
| 5648 | "<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\\\""); |
|---|
| 5649 | |
|---|
| 5650 | c = nvram_safe_get ("trunking"); |
|---|
| 5651 | |
|---|
| 5652 | snprintf (buff, 5, "%s", c); |
|---|
| 5653 | |
|---|
| 5654 | if (atoi (buff) == 1) |
|---|
| 5655 | websWrite (wp, " selected=\\\"selected\\\""); |
|---|
| 5656 | |
|---|
| 5657 | websWrite (wp, |
|---|
| 5658 | ">\" + vlan.trunk + \"</option>\");\n//]]>\n</script></select></td>\n"); |
|---|
| 5659 | websWrite (wp, " </tr>"); |
|---|
| 5660 | |
|---|
| 5661 | return; |
|---|
| 5662 | } |
|---|
| 5663 | |
|---|
| 5664 | /* Note: VLAN #16 designates tagging. There is no VLAN #16 (only 0-15) */ |
|---|
| 5665 | |
|---|
| 5666 | |
|---|
| 5667 | |
|---|
| 5668 | void |
|---|
| 5669 | ej_get_qossvcs (webs_t wp, int argc, char_t ** argv) |
|---|
| 5670 | { |
|---|
| 5671 | char *qos_svcs = nvram_safe_get ("svqos_svcs"); |
|---|
| 5672 | char name[32], type[32], data[32], level[32]; |
|---|
| 5673 | int no_svcs = 0, i = 0; |
|---|
| 5674 | |
|---|
| 5675 | // calc # of services |
|---|
| 5676 | // no_svcs = strspn(qos_svcs,"|"); |
|---|
| 5677 | |
|---|
| 5678 | while ((qos_svcs = strpbrk (qos_svcs, "|"))) |
|---|
| 5679 | { |
|---|
| 5680 | no_svcs++; |
|---|
| 5681 | qos_svcs++; |
|---|
| 5682 | } |
|---|
| 5683 | |
|---|
| 5684 | // write HTML data |
|---|
| 5685 | |
|---|
| 5686 | websWrite (wp, |
|---|
| 5687 | "<tr><td colspan=\"3\"><input type=\"hidden\" name=\"svqos_nosvcs\" value=\"%d\" /></td></tr>", |
|---|
| 5688 | no_svcs); |
|---|
| 5689 | |
|---|
| 5690 | qos_svcs = nvram_safe_get ("svqos_svcs"); |
|---|
| 5691 | |
|---|
| 5692 | /* services format is "name type data level | name type data level |" ..etc */ |
|---|
| 5693 | for (i = 0; i < no_svcs && qos_svcs && qos_svcs[0]; i++) |
|---|
| 5694 | { |
|---|
| 5695 | if (sscanf (qos_svcs, "%31s %31s %31s %31s ", name, type, data, level) < |
|---|
| 5696 | 4) |
|---|
| 5697 | break; |
|---|
| 5698 | |
|---|
| 5699 | websWrite (wp, "<tr>\n\ |
|---|
| 5700 | <td>\n\ |
|---|
| 5701 | <input type=\"checkbox\" name=\"svqos_svcdel%d\" />\n\ |
|---|
| 5702 | <input type=\"hidden\" name=\"svqos_svcname%d\" value=\"%s\" />\n\ |
|---|
| 5703 | <input type=\"hidden\" name=\"svqos_svctype%d\" value=\"%s\" />\n\ |
|---|
| 5704 | </td>\n\ |
|---|
| 5705 | <td><em>%s</em></td>\n\ |
|---|
| 5706 | <td >\n", i, i, name, i, type, name); |
|---|
| 5707 | websWrite (wp, "<select name=\"svqos_svcprio%d\"> \n\ |
|---|
| 5708 | <script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"100\\\" %s >\" + qos.prio_x + \"</option>\");\n\ |
|---|
| 5709 | document.write(\"<option value=\\\"10\\\" %s >\" + qos.prio_p + \"</option>\");\n\ |
|---|
| 5710 | document.write(\"<option value=\\\"20\\\" %s >\" + qos.prio_e + \"</option>\");\n\ |
|---|
| 5711 | document.write(\"<option value=\\\"30\\\" %s >\" + share.standard + \"</option>\");\n\ |
|---|
| 5712 | document.write(\"<option value=\\\"40\\\" %s >\" + qos.prio_b + \"</option>\");\n//]]>\n</script>\n\ |
|---|
| 5713 | </select>\n\ |
|---|
| 5714 | </td>\n\ |
|---|
| 5715 | </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\\\"" : ""); |
|---|
| 5716 | |
|---|
| 5717 | qos_svcs = strpbrk (++qos_svcs, "|"); |
|---|
| 5718 | qos_svcs++; |
|---|
| 5719 | |
|---|
| 5720 | } |
|---|
| 5721 | |
|---|
| 5722 | return; |
|---|
| 5723 | } |
|---|
| 5724 | |
|---|
| 5725 | #ifndef HAVE_AQOS |
|---|
| 5726 | void |
|---|
| 5727 | ej_get_qosips (webs_t wp, int argc, char_t ** argv) |
|---|
| 5728 | { |
|---|
| 5729 | char *qos_ips = nvram_safe_get ("svqos_ips"); |
|---|
| 5730 | char ip[32], level[32]; |
|---|
| 5731 | int no_ips = 0, i = 0; |
|---|
| 5732 | |
|---|
| 5733 | // calc # of ips |
|---|
| 5734 | while ((qos_ips = strpbrk (qos_ips, "|"))) |
|---|
| 5735 | { |
|---|
| 5736 | no_ips++; |
|---|
| 5737 | qos_ips++; |
|---|
| 5738 | } |
|---|
| 5739 | websWrite (wp, "<tr>\n\ |
|---|
| 5740 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 5741 | <th><script type=\"text/javascript\">Capture(qos.ipmask)</script></th>\n\ |
|---|
| 5742 | <th><script type=\"text/javascript\">Capture(share.priority)</script></th>\n\ |
|---|
| 5743 | </tr>\n"); |
|---|
| 5744 | |
|---|
| 5745 | // write HTML data |
|---|
| 5746 | |
|---|
| 5747 | websWrite (wp, |
|---|
| 5748 | "<tr><td colspan=\"3\"><input type=\"hidden\" name=\"svqos_noips\" value=\"%d\" /></td></tr>", |
|---|
| 5749 | no_ips); |
|---|
| 5750 | |
|---|
| 5751 | qos_ips = nvram_safe_get ("svqos_ips"); |
|---|
| 5752 | |
|---|
| 5753 | /* IP format is "data level | data level |" ..etc */ |
|---|
| 5754 | for (i = 0; i < no_ips && qos_ips && qos_ips[0]; i++) |
|---|
| 5755 | { |
|---|
| 5756 | if (sscanf (qos_ips, "%31s %31s ", ip, level) < 2) |
|---|
| 5757 | break; |
|---|
| 5758 | |
|---|
| 5759 | websWrite (wp, "<tr>\n\ |
|---|
| 5760 | <td>\n\ |
|---|
| 5761 | <input type=\"checkbox\" name=\"svqos_ipdel%d\" />\n\ |
|---|
| 5762 | <input type=\"hidden\" name=\"svqos_ip%d\" value=\"%s\" />\n\ |
|---|
| 5763 | </td>\n\ |
|---|
| 5764 | <td><em>%s</em></td>\n\ |
|---|
| 5765 | <td>\n", i, i, ip, ip); |
|---|
| 5766 | websWrite (wp, "<select name=\"svqos_ipprio%d\"> \n\ |
|---|
| 5767 | <script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"100\\\" %s >\" + qos.prio_x + \"</option>\");\n\ |
|---|
| 5768 | document.write(\"<option value=\\\"10\\\" %s >\" + qos.prio_p + \"</option>\");\n\ |
|---|
| 5769 | document.write(\"<option value=\\\"20\\\" %s >\" + qos.prio_e + \"</option>\");\n\ |
|---|
| 5770 | document.write(\"<option value=\\\"30\\\" %s >\" + share.standard + \"</option>\");\n\ |
|---|
| 5771 | document.write(\"<option value=\\\"40\\\" %s >\" + qos.prio_b + \"</option>\");\n//]]>\n</script>\n\ |
|---|
| 5772 | </select>\n\ |
|---|
| 5773 | </td>\n\ |
|---|
| 5774 | </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\\\"" : ""); |
|---|
| 5775 | |
|---|
| 5776 | qos_ips = strpbrk (++qos_ips, "|"); |
|---|
| 5777 | qos_ips++; |
|---|
| 5778 | |
|---|
| 5779 | } |
|---|
| 5780 | |
|---|
| 5781 | return; |
|---|
| 5782 | } |
|---|
| 5783 | #else |
|---|
| 5784 | void |
|---|
| 5785 | ej_get_qosips (webs_t wp, int argc, char_t ** argv) |
|---|
| 5786 | { |
|---|
| 5787 | char *qos_ips = nvram_safe_get ("svqos_ips"); |
|---|
| 5788 | char ip[32], level[32], level2[32]; |
|---|
| 5789 | int no_ips = 0, i = 0; |
|---|
| 5790 | |
|---|
| 5791 | // calc # of ips |
|---|
| 5792 | while ((qos_ips = strpbrk (qos_ips, "|"))) |
|---|
| 5793 | { |
|---|
| 5794 | no_ips++; |
|---|
| 5795 | qos_ips++; |
|---|
| 5796 | } |
|---|
| 5797 | websWrite (wp, "<tr>\n\ |
|---|
| 5798 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 5799 | <th><script type=\"text/javascript\">Capture(qos.ipmask)</script></th>\n\ |
|---|
| 5800 | <th><script type=\"text/javascript\">Capture(qos.maxuprate_b)</script></th>\n\ |
|---|
| 5801 | <th><script type=\"text/javascript\">Capture(qos.maxdownrate_b)</script></th>\n\ |
|---|
| 5802 | </tr>\n"); |
|---|
| 5803 | |
|---|
| 5804 | // write HTML data |
|---|
| 5805 | |
|---|
| 5806 | websWrite (wp, |
|---|
| 5807 | "<tr><td colspan=\"3\"><input type=\"hidden\" name=\"svqos_noips\" value=\"%d\" /></td></tr>", |
|---|
| 5808 | no_ips); |
|---|
| 5809 | |
|---|
| 5810 | qos_ips = nvram_safe_get ("svqos_ips"); |
|---|
| 5811 | |
|---|
| 5812 | /* IP format is "data level | data level |" ..etc */ |
|---|
| 5813 | for (i = 0; i < no_ips && qos_ips && qos_ips[0]; i++) |
|---|
| 5814 | { |
|---|
| 5815 | if (sscanf (qos_ips, "%31s %31s %31s ", ip, level, level2) < 3) |
|---|
| 5816 | break; |
|---|
| 5817 | websWrite (wp, "<tr>\n\ |
|---|
| 5818 | <td>\n\ |
|---|
| 5819 | <input type=\"checkbox\" name=\"svqos_ipdel%d\" />\n\ |
|---|
| 5820 | <input type=\"hidden\" name=\"svqos_ip%d\" value=\"%s\" />\n\ |
|---|
| 5821 | </td>\n\ |
|---|
| 5822 | <td><em>%s</em></td>\n\ |
|---|
| 5823 | <td>\n\ |
|---|
| 5824 | <input name=\"svqos_ipup%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 5825 | </td>\n\ |
|---|
| 5826 | <td>\n\ |
|---|
| 5827 | <input name=\"svqos_ipdown%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 5828 | </td>\n\ |
|---|
| 5829 | </tr>\n", i, i, ip, ip, i, level, i, level2); |
|---|
| 5830 | |
|---|
| 5831 | qos_ips = strpbrk (++qos_ips, "|"); |
|---|
| 5832 | qos_ips++; |
|---|
| 5833 | |
|---|
| 5834 | } |
|---|
| 5835 | |
|---|
| 5836 | return; |
|---|
| 5837 | } |
|---|
| 5838 | #endif |
|---|
| 5839 | #ifndef HAVE_AQOS |
|---|
| 5840 | void |
|---|
| 5841 | ej_get_qosmacs (webs_t wp, int argc, char_t ** argv) |
|---|
| 5842 | { |
|---|
| 5843 | char *qos_macs = nvram_safe_get ("svqos_macs"); |
|---|
| 5844 | char mac[32], level[32]; |
|---|
| 5845 | int no_macs = 0, i = 0; |
|---|
| 5846 | |
|---|
| 5847 | |
|---|
| 5848 | // calc # of ips |
|---|
| 5849 | while ((qos_macs = strpbrk (qos_macs, "|"))) |
|---|
| 5850 | { |
|---|
| 5851 | no_macs++; |
|---|
| 5852 | qos_macs++; |
|---|
| 5853 | } |
|---|
| 5854 | |
|---|
| 5855 | websWrite (wp, "<tr>\n\ |
|---|
| 5856 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 5857 | <th><script type=\"text/javascript\">Capture(share.mac)</script></th>\n\ |
|---|
| 5858 | <th><script type=\"text/javascript\">Capture(share.priority)</script></th>\n\ |
|---|
| 5859 | </tr>\n"); |
|---|
| 5860 | |
|---|
| 5861 | // write HTML data |
|---|
| 5862 | websWrite (wp, |
|---|
| 5863 | "<input type=\"hidden\" name=\"svqos_nomacs\" value=\"%d\" />", |
|---|
| 5864 | no_macs); |
|---|
| 5865 | |
|---|
| 5866 | qos_macs = nvram_safe_get ("svqos_macs"); |
|---|
| 5867 | |
|---|
| 5868 | /* IP format is "data level | data level |" ..etc */ |
|---|
| 5869 | for (i = 0; i < no_macs && qos_macs && qos_macs[0]; i++) |
|---|
| 5870 | { |
|---|
| 5871 | if (sscanf (qos_macs, "%31s %31s ", mac, level) < 2) |
|---|
| 5872 | break; |
|---|
| 5873 | |
|---|
| 5874 | websWrite (wp, "<tr>\n\ |
|---|
| 5875 | <td>\n\ |
|---|
| 5876 | <input type=\"checkbox\" name=\"svqos_macdel%d\" />\n\ |
|---|
| 5877 | <input type=\"hidden\" name=\"svqos_mac%d\" value=\"%s\" />\n\ |
|---|
| 5878 | </td>\n\ |
|---|
| 5879 | <td><em>%s</em></td>\n\ |
|---|
| 5880 | <td>\n", i, i, mac, mac); |
|---|
| 5881 | websWrite (wp, "<select name=\"svqos_macprio%d\"> \n\ |
|---|
| 5882 | <script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"100\\\" %s >\" + qos.prio_x + \"</option>\");\n\ |
|---|
| 5883 | document.write(\"<option value=\\\"10\\\" %s >\" + qos.prio_p + \"</option>\");\n\ |
|---|
| 5884 | document.write(\"<option value=\\\"20\\\" %s >\" + qos.prio_e + \"</option>\");\n\ |
|---|
| 5885 | document.write(\"<option value=\\\"30\\\" %s >\" + share.standard + \"</option>\");\n\ |
|---|
| 5886 | document.write(\"<option value=\\\"40\\\" %s >\" + qos.prio_b + \"</option>\");\n//]]>\n</script>\n\ |
|---|
| 5887 | </select>\n\ |
|---|
| 5888 | </td>\n\ |
|---|
| 5889 | </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\\\"" : ""); |
|---|
| 5890 | |
|---|
| 5891 | qos_macs = strpbrk (++qos_macs, "|"); |
|---|
| 5892 | qos_macs++; |
|---|
| 5893 | |
|---|
| 5894 | } |
|---|
| 5895 | |
|---|
| 5896 | return; |
|---|
| 5897 | } |
|---|
| 5898 | |
|---|
| 5899 | #else |
|---|
| 5900 | void |
|---|
| 5901 | ej_get_qosmacs (webs_t wp, int argc, char_t ** argv) |
|---|
| 5902 | { |
|---|
| 5903 | char *qos_macs = nvram_safe_get ("svqos_macs"); |
|---|
| 5904 | char mac[32], level[32], level2[32]; |
|---|
| 5905 | int no_macs = 0, i = 0; |
|---|
| 5906 | |
|---|
| 5907 | |
|---|
| 5908 | // calc # of ips |
|---|
| 5909 | while ((qos_macs = strpbrk (qos_macs, "|"))) |
|---|
| 5910 | { |
|---|
| 5911 | no_macs++; |
|---|
| 5912 | qos_macs++; |
|---|
| 5913 | } |
|---|
| 5914 | websWrite (wp, "<tr>\n\ |
|---|
| 5915 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 5916 | <th><script type=\"text/javascript\">Capture(share.mac)</script></th>\n\ |
|---|
| 5917 | <th><script type=\"text/javascript\">Capture(qos.maxuprate_b)</script></th>\n\ |
|---|
| 5918 | <th><script type=\"text/javascript\">Capture(qos.maxdownrate_b)</script></th>\n\ |
|---|
| 5919 | </tr>\n"); |
|---|
| 5920 | |
|---|
| 5921 | // write HTML data |
|---|
| 5922 | websWrite (wp, |
|---|
| 5923 | "<input type=\"hidden\" name=\"svqos_nomacs\" value=\"%d\" />", |
|---|
| 5924 | no_macs); |
|---|
| 5925 | |
|---|
| 5926 | qos_macs = nvram_safe_get ("svqos_macs"); |
|---|
| 5927 | |
|---|
| 5928 | /* IP format is "data level | data level |" ..etc */ |
|---|
| 5929 | for (i = 0; i < no_macs && qos_macs && qos_macs[0]; i++) |
|---|
| 5930 | { |
|---|
| 5931 | if (sscanf (qos_macs, "%31s %31s %31s ", mac, level, level2) < 3) |
|---|
| 5932 | break; |
|---|
| 5933 | websWrite (wp, "<tr>\n\ |
|---|
| 5934 | <td>\n\ |
|---|
| 5935 | <input type=\"checkbox\" name=\"svqos_macdel%d\" />\n\ |
|---|
| 5936 | <input type=\"hidden\" name=\"svqos_mac%d\" value=\"%s\" />\n\ |
|---|
| 5937 | </td>\n\ |
|---|
| 5938 | <td><em>%s</em></td>\n\ |
|---|
| 5939 | <td>\n\ |
|---|
| 5940 | <input name=\"svqos_macup%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 5941 | </td>\n\ |
|---|
| 5942 | <td>\n\ |
|---|
| 5943 | <input name=\"svqos_macdown%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 5944 | </td>\n\ |
|---|
| 5945 | </tr>\n", i, i, mac, mac, i, level, i, level2); |
|---|
| 5946 | |
|---|
| 5947 | qos_macs = strpbrk (++qos_macs, "|"); |
|---|
| 5948 | qos_macs++; |
|---|
| 5949 | |
|---|
| 5950 | } |
|---|
| 5951 | |
|---|
| 5952 | return; |
|---|
| 5953 | } |
|---|
| 5954 | #endif |
|---|
| 5955 | |
|---|
| 5956 | |
|---|
| 5957 | |
|---|
| 5958 | /* Added by Botho 03.April.06 */ |
|---|
| 5959 | void |
|---|
| 5960 | ej_dumpip_conntrack (webs_t wp, int argc, char_t ** argv) |
|---|
| 5961 | { |
|---|
| 5962 | int ip_count = 0; |
|---|
| 5963 | FILE *fp; |
|---|
| 5964 | int c; |
|---|
| 5965 | |
|---|
| 5966 | fp = fopen ("/proc/net/ip_conntrack", "rb"); |
|---|
| 5967 | if (fp == NULL) |
|---|
| 5968 | return; |
|---|
| 5969 | while (!feof (fp)) |
|---|
| 5970 | { |
|---|
| 5971 | c = getc (fp); |
|---|
| 5972 | if (c == EOF) |
|---|
| 5973 | break; |
|---|
| 5974 | if (c == 0xa) |
|---|
| 5975 | ip_count++; |
|---|
| 5976 | } |
|---|
| 5977 | |
|---|
| 5978 | websWrite (wp, "%d", ip_count); |
|---|
| 5979 | |
|---|
| 5980 | fclose (fp); |
|---|
| 5981 | |
|---|
| 5982 | return; |
|---|
| 5983 | } |
|---|
| 5984 | |
|---|
| 5985 | /* Added by Botho 28.Oct.06 */ |
|---|
| 5986 | static int |
|---|
| 5987 | search_hit (char *search, char *line, char *ret) |
|---|
| 5988 | { |
|---|
| 5989 | unsigned int searchLen; |
|---|
| 5990 | unsigned int i; |
|---|
| 5991 | unsigned int j; |
|---|
| 5992 | unsigned int lineLen; |
|---|
| 5993 | if (line == NULL || search == NULL || ret == NULL) |
|---|
| 5994 | return 1; |
|---|
| 5995 | lineLen = strlen (line); |
|---|
| 5996 | searchLen = strlen (search); |
|---|
| 5997 | |
|---|
| 5998 | if (searchLen > lineLen) |
|---|
| 5999 | return (1); // this can't match, invalid data? |
|---|
| 6000 | |
|---|
| 6001 | for (i = 0; i < lineLen - searchLen; i++) |
|---|
| 6002 | { |
|---|
| 6003 | if (!strncasecmp ((char *) &line[i], search, searchLen)) |
|---|
| 6004 | break; // we got hit |
|---|
| 6005 | } |
|---|
| 6006 | |
|---|
| 6007 | for (j = i + searchLen; j < i + 15 + searchLen; j++) |
|---|
| 6008 | { |
|---|
| 6009 | if (j >= lineLen) |
|---|
| 6010 | break; // end of line may be a delimiter too |
|---|
| 6011 | // return(1); // incomplete data |
|---|
| 6012 | if (line[j] == ' ') |
|---|
| 6013 | break; // we reach _space_ delimiter |
|---|
| 6014 | } |
|---|
| 6015 | memcpy (ret, &line[i + searchLen], j - (i + searchLen)); |
|---|
| 6016 | ret[j - (i + searchLen)] = 0; |
|---|
| 6017 | return (0); |
|---|
| 6018 | } |
|---|
| 6019 | |
|---|
| 6020 | static int |
|---|
| 6021 | string_search (char *string, char *search) |
|---|
| 6022 | { |
|---|
| 6023 | int searchLen; |
|---|
| 6024 | int i; |
|---|
| 6025 | if (search == NULL) |
|---|
| 6026 | return 0; |
|---|
| 6027 | searchLen = strlen (search); |
|---|
| 6028 | if (string == NULL) |
|---|
| 6029 | return 0; |
|---|
| 6030 | if (searchLen > strlen (string)) |
|---|
| 6031 | { |
|---|
| 6032 | return (0); // this can't match |
|---|
| 6033 | } |
|---|
| 6034 | int slen = strlen (string); |
|---|
| 6035 | for (i = 0; i < slen - searchLen; i++) |
|---|
| 6036 | { //+1 removed. |
|---|
| 6037 | if (!strncasecmp ((char *) &string[i], search, searchLen)) |
|---|
| 6038 | { |
|---|
| 6039 | return (1); // we got hit |
|---|
| 6040 | } |
|---|
| 6041 | } |
|---|
| 6042 | return (0); |
|---|
| 6043 | } |
|---|
| 6044 | |
|---|
| 6045 | |
|---|
| 6046 | void |
|---|
| 6047 | ej_ip_conntrack_table (webs_t wp, int argc, char_t ** argv) |
|---|
| 6048 | { |
|---|
| 6049 | FILE *fp; |
|---|
| 6050 | int ip_count = 1; |
|---|
| 6051 | char line[512]; |
|---|
| 6052 | char protocol[16] = ""; |
|---|
| 6053 | int timeout = 0; |
|---|
| 6054 | char srcip[16] = ""; |
|---|
| 6055 | char dstip[16] = ""; |
|---|
| 6056 | int _dport; |
|---|
| 6057 | struct servent *servp; |
|---|
| 6058 | char dstport[6] = ""; |
|---|
| 6059 | char state[12] = ""; |
|---|
| 6060 | char dum1[32]; |
|---|
| 6061 | int dum2; |
|---|
| 6062 | |
|---|
| 6063 | fp = fopen ("/proc/net/ip_conntrack", "rb"); |
|---|
| 6064 | if (fp == NULL) |
|---|
| 6065 | return; |
|---|
| 6066 | |
|---|
| 6067 | while (fgets (line, sizeof (line), fp) != NULL) |
|---|
| 6068 | { |
|---|
| 6069 | |
|---|
| 6070 | websWrite (wp, "<tr>\n"); |
|---|
| 6071 | |
|---|
| 6072 | // Nb |
|---|
| 6073 | websWrite (wp, "<td align=\"right\">%d</td>", ip_count); |
|---|
| 6074 | |
|---|
| 6075 | // Proto |
|---|
| 6076 | if (string_search (line, "tcp")) |
|---|
| 6077 | sprintf (protocol, "TCP"); |
|---|
| 6078 | else if (string_search (line, "udp")) |
|---|
| 6079 | sprintf (protocol, "UDP"); |
|---|
| 6080 | else if (string_search (line, "icmp")) |
|---|
| 6081 | sprintf (protocol, "ICMP"); |
|---|
| 6082 | else |
|---|
| 6083 | sprintf (protocol, live_translate ("share.unknown")); |
|---|
| 6084 | websWrite (wp, "<td>%s</td>", protocol); |
|---|
| 6085 | |
|---|
| 6086 | // Timeout |
|---|
| 6087 | sscanf (line, "%s %d %d", &dum1[0], &dum2, &timeout); |
|---|
| 6088 | websWrite (wp, "<td align=\"right\">%d</td>", timeout); |
|---|
| 6089 | |
|---|
| 6090 | // src |
|---|
| 6091 | search_hit ("src=", line, srcip); |
|---|
| 6092 | //char buf[200]; |
|---|
| 6093 | //getHostName (buf, srcip); |
|---|
| 6094 | //websWrite (wp, "<td align=\"right\" onmouseover='DisplayDiv(this, event, 15, 15, \"%s\")' onmouseout=\"unDisplayDiv()\">%s</td>", buf != "unknown" ? buf : live_translate ("share.unknown") , srcip); |
|---|
| 6095 | websWrite (wp, "<td align=\"right\">%s</td>", srcip); |
|---|
| 6096 | |
|---|
| 6097 | // dst |
|---|
| 6098 | search_hit ("dst=", line, dstip); |
|---|
| 6099 | //getHostName (buf, dstip); |
|---|
| 6100 | //websWrite (wp, "<td align=\"right\" onmouseover='DisplayDiv(this, event, 15, 15, \"%s\")' onmouseout=\"unDisplayDiv()\">%s</td>", buf != "unknown" ? buf : live_translate ("share.unknown") , dstip); |
|---|
| 6101 | websWrite (wp, "<td align=\"right\">%s</td>", dstip); |
|---|
| 6102 | |
|---|
| 6103 | // service |
|---|
| 6104 | search_hit ("dport=", line, dstport); |
|---|
| 6105 | _dport = atoi (dstport); |
|---|
| 6106 | servp = my_getservbyport (htons (_dport), protocol); |
|---|
| 6107 | websWrite (wp, "<td align=\"right\">%s</td>", |
|---|
| 6108 | servp ? servp->s_name : dstport); |
|---|
| 6109 | |
|---|
| 6110 | // State |
|---|
| 6111 | if (string_search (line, "ESTABLISHED")) |
|---|
| 6112 | sprintf (state, "ESTABLISHED"); |
|---|
| 6113 | else if (string_search (line, "TIME_WAIT")) |
|---|
| 6114 | sprintf (state, "TIME_WAIT"); |
|---|
| 6115 | else if (string_search (line, "UNREPLIED")) |
|---|
| 6116 | sprintf (state, "UNREPLIED"); |
|---|
| 6117 | else if (string_search (line, "CLOSE")) |
|---|
| 6118 | sprintf (state, "CLOSE"); |
|---|
| 6119 | else if (string_search (line, "ASSURED")) |
|---|
| 6120 | sprintf (state, "ASSURED"); |
|---|
| 6121 | else |
|---|
| 6122 | { |
|---|
| 6123 | if (string_search (line, "udp")) |
|---|
| 6124 | sprintf (state, "UNREPLIED"); |
|---|
| 6125 | else |
|---|
| 6126 | sprintf (state, " "); |
|---|
| 6127 | } |
|---|
| 6128 | websWrite (wp, "<td>%s</td>\n", state); |
|---|
| 6129 | websWrite (wp, "</tr>\n"); |
|---|
| 6130 | |
|---|
| 6131 | ip_count++; |
|---|
| 6132 | } |
|---|
| 6133 | |
|---|
| 6134 | fclose (fp); |
|---|
| 6135 | |
|---|
| 6136 | return; |
|---|
| 6137 | } |
|---|
| 6138 | |
|---|
| 6139 | |
|---|
| 6140 | void |
|---|
| 6141 | ej_gethostnamebyip (webs_t wp, int argc, char_t ** argv) |
|---|
| 6142 | { |
|---|
| 6143 | char buf[200]; |
|---|
| 6144 | char *argument; |
|---|
| 6145 | #ifdef FASTWEB |
|---|
| 6146 | ejArgs (argc, argv, "%s", &argument); |
|---|
| 6147 | #else |
|---|
| 6148 | if (ejArgs (argc, argv, "%s", &argument) < 1) |
|---|
| 6149 | { |
|---|
| 6150 | websError (wp, 400, "Insufficient args\n"); |
|---|
| 6151 | return; |
|---|
| 6152 | } |
|---|
| 6153 | #endif |
|---|
| 6154 | |
|---|
| 6155 | if (argc == 1) |
|---|
| 6156 | { |
|---|
| 6157 | getHostName (buf, argument); |
|---|
| 6158 | websWrite (wp, "%s", |
|---|
| 6159 | buf != "unknown" ? buf : live_translate ("share.unknown")); |
|---|
| 6160 | } |
|---|
| 6161 | |
|---|
| 6162 | return; |
|---|
| 6163 | } |
|---|
| 6164 | |
|---|
| 6165 | |
|---|
| 6166 | /* BEGIN Added by Botho 10.May.06 */ |
|---|
| 6167 | void |
|---|
| 6168 | ej_show_wan_to_switch (webs_t wp, int argc, char_t ** argv) |
|---|
| 6169 | { |
|---|
| 6170 | |
|---|
| 6171 | if (nvram_match ("wan_proto", "disabled") || !nvram_match ("wl_mode", "ap")) //WAN disabled OR Wirelles is not AP |
|---|
| 6172 | { |
|---|
| 6173 | websWrite (wp, "<fieldset>\n\ |
|---|
| 6174 | <legend><script type=\"text/javascript\">Capture(idx.legend2)</script></legend>\n\ |
|---|
| 6175 | <div class=\"setting\">\n\ |
|---|
| 6176 | <div class=\"label\"><script type=\"text/javascript\">Capture(idx.wantoswitch)</script></div>\n\ |
|---|
| 6177 | <input class=\"spaceradio\" type=\"checkbox\" name=\"_fullswitch\" value=\"1\" %s />\n\ |
|---|
| 6178 | </div>\n\ |
|---|
| 6179 | </fieldset><br />\n", nvram_match ("fullswitch", "1") ? "checked=\"checked\"" : ""); |
|---|
| 6180 | } |
|---|
| 6181 | |
|---|
| 6182 | return; |
|---|
| 6183 | } |
|---|
| 6184 | |
|---|
| 6185 | #define PROC_DEV "/proc/net/dev" |
|---|
| 6186 | |
|---|
| 6187 | void |
|---|
| 6188 | ej_wl_packet_get (webs_t wp, int argc, char_t ** argv) |
|---|
| 6189 | { |
|---|
| 6190 | char line[256]; |
|---|
| 6191 | FILE *fp; |
|---|
| 6192 | #ifdef HAVE_MADWIFI |
|---|
| 6193 | char *ifname = nvram_safe_get ("wifi_display"); |
|---|
| 6194 | #else |
|---|
| 6195 | char *ifname = nvram_safe_get ("wl0_ifname"); |
|---|
| 6196 | #endif |
|---|
| 6197 | struct dev_info |
|---|
| 6198 | { |
|---|
| 6199 | // unsigned long rx_bytes; |
|---|
| 6200 | unsigned long rx_pks; |
|---|
| 6201 | unsigned long rx_errs; |
|---|
| 6202 | unsigned long rx_drops; |
|---|
| 6203 | // unsigned long rx_fifo; |
|---|
| 6204 | // unsigned long rx_frame; |
|---|
| 6205 | // unsigned long rx_com; |
|---|
| 6206 | // unsigned long rx_mcast; |
|---|
| 6207 | // unsigned long tx_bytes; |
|---|
| 6208 | unsigned long tx_pks; |
|---|
| 6209 | unsigned long tx_errs; |
|---|
| 6210 | unsigned long tx_drops; |
|---|
| 6211 | // unsigned long tx_fifo; |
|---|
| 6212 | unsigned long tx_colls; |
|---|
| 6213 | // unsigned long tx_carr; |
|---|
| 6214 | // unsigned long tx_com; |
|---|
| 6215 | } info; |
|---|
| 6216 | |
|---|
| 6217 | info.rx_pks = info.rx_errs = info.rx_drops = 0; |
|---|
| 6218 | info.tx_pks = info.tx_errs = info.tx_drops = info.tx_colls = 0; |
|---|
| 6219 | |
|---|
| 6220 | if ((fp = fopen (PROC_DEV, "r")) == NULL) |
|---|
| 6221 | { |
|---|
| 6222 | websError (wp, 400, "Can't open %s\n", PROC_DEV); |
|---|
| 6223 | return; |
|---|
| 6224 | } |
|---|
| 6225 | else |
|---|
| 6226 | { |
|---|
| 6227 | /* |
|---|
| 6228 | Inter-| Receive | Transmit |
|---|
| 6229 | face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed |
|---|
| 6230 | lo: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
|---|
| 6231 | eth0: 674829 5501 0 0 0 0 0 0 1249130 1831 0 0 0 0 0 0 |
|---|
| 6232 | eth1: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
|---|
| 6233 | eth2: 0 0 0 0 0 719 0 0 1974 16 295 0 0 0 0 0 |
|---|
| 6234 | br0: 107114 1078 0 0 0 0 0 0 910094 1304 0 0 0 0 0 0 |
|---|
| 6235 | |
|---|
| 6236 | */ |
|---|
| 6237 | while (fgets (line, sizeof (line), fp) != NULL) |
|---|
| 6238 | { |
|---|
| 6239 | int ifl = 0; |
|---|
| 6240 | if (!strchr (line, ':')) |
|---|
| 6241 | continue; |
|---|
| 6242 | while (line[ifl] != ':') |
|---|
| 6243 | ifl++; |
|---|
| 6244 | line[ifl] = 0; /* interface */ |
|---|
| 6245 | |
|---|
| 6246 | if (strstr (line, ifname)) |
|---|
| 6247 | { |
|---|
| 6248 | /* sscanf (line + ifl + 1, |
|---|
| 6249 | "%ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", |
|---|
| 6250 | &info.rx_bytes, &info.rx_pks, &info.rx_errs, |
|---|
| 6251 | &info.rx_drops, &info.rx_fifo, &info.rx_frame, |
|---|
| 6252 | &info.rx_com, &info.rx_mcast, &info.tx_bytes, |
|---|
| 6253 | &info.tx_pks, &info.tx_errs, &info.tx_drops, |
|---|
| 6254 | &info.tx_fifo, &info.tx_colls, &info.tx_carr, |
|---|
| 6255 | &info.tx_com); |
|---|
| 6256 | */ |
|---|
| 6257 | sscanf (line + ifl + 1, |
|---|
| 6258 | "%*ld %ld %ld %ld %*ld %*ld %*ld %*ld %*ld %ld %ld %ld %*ld %ld %*ld %*ld", |
|---|
| 6259 | &info.rx_pks, &info.rx_errs, |
|---|
| 6260 | &info.rx_drops, |
|---|
| 6261 | &info.tx_pks, &info.tx_errs, &info.tx_drops, |
|---|
| 6262 | &info.tx_colls); |
|---|
| 6263 | } |
|---|
| 6264 | |
|---|
| 6265 | } |
|---|
| 6266 | fclose (fp); |
|---|
| 6267 | } |
|---|
| 6268 | |
|---|
| 6269 | websWrite (wp, "SWRXgoodPacket=%ld;", info.rx_pks); |
|---|
| 6270 | websWrite (wp, "SWRXerrorPacket=%ld;", info.rx_errs + info.rx_drops); |
|---|
| 6271 | |
|---|
| 6272 | websWrite (wp, "SWTXgoodPacket=%ld;", info.tx_pks); |
|---|
| 6273 | websWrite (wp, "SWTXerrorPacket=%ld;", |
|---|
| 6274 | info.tx_errs + info.tx_drops + info.tx_colls); |
|---|
| 6275 | |
|---|
| 6276 | return; |
|---|
| 6277 | } |
|---|
| 6278 | |
|---|
| 6279 | |
|---|
| 6280 | /* END Added by Botho 10.May.06 */ |
|---|
| 6281 | |
|---|
| 6282 | |
|---|
| 6283 | |
|---|
| 6284 | |
|---|
| 6285 | |
|---|
| 6286 | void |
|---|
| 6287 | ej_statfs (webs_t wp, int argc, char_t ** argv) |
|---|
| 6288 | { |
|---|
| 6289 | struct statfs sizefs; |
|---|
| 6290 | |
|---|
| 6291 | if (argc != 2) |
|---|
| 6292 | return; |
|---|
| 6293 | |
|---|
| 6294 | if ((statfs (argv[0], &sizefs) != 0) || (sizefs.f_type == 0x73717368)) |
|---|
| 6295 | memset (&sizefs, 0, sizeof (sizefs)); |
|---|
| 6296 | |
|---|
| 6297 | websWrite (wp, "var %s = {\n\ |
|---|
| 6298 | size: %llu,\n\ |
|---|
| 6299 | free: %llu\n\ |
|---|
| 6300 | };\n", argv[1], ((uint64_t) sizefs.f_bsize * sizefs.f_blocks), ((uint64_t) sizefs.f_bsize * sizefs.f_bfree)); |
|---|
| 6301 | } |
|---|
| 6302 | |
|---|
| 6303 | #ifdef HAVE_RSTATS |
|---|
| 6304 | /* |
|---|
| 6305 | |
|---|
| 6306 | rstats |
|---|
| 6307 | Copyright (C) 2006 Jonathan Zarate |
|---|
| 6308 | |
|---|
| 6309 | Licensed under GNU GPL v2 or later. |
|---|
| 6310 | |
|---|
| 6311 | */ |
|---|
| 6312 | |
|---|
| 6313 | void |
|---|
| 6314 | ej_bandwidth (webs_t wp, int argc, char_t ** argv) |
|---|
| 6315 | { |
|---|
| 6316 | char *name; |
|---|
| 6317 | int sig; |
|---|
| 6318 | char *argument; |
|---|
| 6319 | |
|---|
| 6320 | #ifdef FASTWEB |
|---|
| 6321 | ejArgs (argc, argv, "%s", &argument); |
|---|
| 6322 | #else |
|---|
| 6323 | if (ejArgs (argc, argv, "%s", &argument) < 1) |
|---|
| 6324 | { |
|---|
| 6325 | websError (wp, 400, "Insufficient args\n"); |
|---|
| 6326 | return; |
|---|
| 6327 | } |
|---|
| 6328 | #endif |
|---|
| 6329 | |
|---|
| 6330 | if (argc == 1) |
|---|
| 6331 | { |
|---|
| 6332 | if (strcmp (argument, "speed") == 0) |
|---|
| 6333 | { |
|---|
| 6334 | sig = SIGUSR1; |
|---|
| 6335 | name = "/var/spool/rstats-speed.js"; |
|---|
| 6336 | } |
|---|
| 6337 | else |
|---|
| 6338 | { |
|---|
| 6339 | sig = SIGUSR2; |
|---|
| 6340 | name = "/var/spool/rstats-history.js"; |
|---|
| 6341 | } |
|---|
| 6342 | unlink (name); |
|---|
| 6343 | killall ("rstats", sig); |
|---|
| 6344 | wait_file_exists (name, 5, 0); |
|---|
| 6345 | do_file (name, wp, NULL); |
|---|
| 6346 | unlink (name); |
|---|
| 6347 | } |
|---|
| 6348 | } |
|---|
| 6349 | #endif |
|---|
| 6350 | |
|---|
| 6351 | |
|---|
| 6352 | #ifdef HAVE_PORTSETUP |
|---|
| 6353 | void |
|---|
| 6354 | ej_portsetup (webs_t wp, int argc, char_t ** argv) |
|---|
| 6355 | { |
|---|
| 6356 | char ssid[64]; |
|---|
| 6357 | char *next; |
|---|
| 6358 | char var[64]; |
|---|
| 6359 | char eths[256]; |
|---|
| 6360 | char eths2[256]; |
|---|
| 6361 | #ifdef HAVE_XSCALE |
|---|
| 6362 | // if (getifcount ("ixp") == 1 && getifcount ("eth") == 0) |
|---|
| 6363 | // return; |
|---|
| 6364 | #else |
|---|
| 6365 | // if (getifcount ("eth") == 1) |
|---|
| 6366 | // return; |
|---|
| 6367 | #endif |
|---|
| 6368 | websWrite (wp, |
|---|
| 6369 | "<h2><script type=\"text/javascript\">Capture(idx.portsetup)</script></h2>\n"); |
|---|
| 6370 | websWrite (wp, "<fieldset>\n"); |
|---|
| 6371 | websWrite (wp, |
|---|
| 6372 | "<legend><script type=\"text/javascript\">Capture(idx.portsetup)</script></legend>\n"); |
|---|
| 6373 | memset (eths, 0, 256); |
|---|
| 6374 | getIfLists (eths, 256); |
|---|
| 6375 | websWrite (wp, |
|---|
| 6376 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(idx.wanport)</script></div>\n"); |
|---|
| 6377 | websWrite (wp, "<select name=\"wan_ifname\">\n"); |
|---|
| 6378 | websWrite (wp, "<option value=\"\" %s >Disabled</option>\n", |
|---|
| 6379 | nvram_match ("wan_ifname", "") ? "selected=\"selected\"" : ""); |
|---|
| 6380 | foreach (var, eths, next) |
|---|
| 6381 | { |
|---|
| 6382 | websWrite (wp, "<option value=\"%s\" %s >%s</option>\n", var, |
|---|
| 6383 | nvram_match ("wan_ifname", var) ? "selected=\"selected\"" : "", |
|---|
| 6384 | var); |
|---|
| 6385 | } |
|---|
| 6386 | websWrite (wp, "</select></div>\n"); |
|---|
| 6387 | |
|---|
| 6388 | foreach (var, eths, next) |
|---|
| 6389 | { |
|---|
| 6390 | if (!strcmp (get_wan_face (), var)) |
|---|
| 6391 | continue; |
|---|
| 6392 | |
|---|
| 6393 | sprintf (ssid, "%s_bridged", var); |
|---|
| 6394 | websWrite (wp, |
|---|
| 6395 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.network)</script> %s</div>\n", |
|---|
| 6396 | var); |
|---|
| 6397 | char layer[64]; |
|---|
| 6398 | strcpy (layer, var); |
|---|
| 6399 | rep (layer, '.', 'X'); |
|---|
| 6400 | websWrite (wp, |
|---|
| 6401 | "<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", |
|---|
| 6402 | layer, var, nvram_default_match (ssid, |
|---|
| 6403 | "0", |
|---|
| 6404 | "1") ? "checked=\"checked\"" : |
|---|
| 6405 | ""); |
|---|
| 6406 | websWrite (wp, |
|---|
| 6407 | "<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", |
|---|
| 6408 | layer, var, nvram_default_match (ssid, "1", |
|---|
| 6409 | "1") ? "checked=\"checked\"" : |
|---|
| 6410 | ""); |
|---|
| 6411 | websWrite (wp, "</div>\n"); |
|---|
| 6412 | |
|---|
| 6413 | websWrite (wp, "<div id=\"%s_idnet\">\n", layer); |
|---|
| 6414 | char mcast[32]; |
|---|
| 6415 | sprintf (mcast, "%s_multicast", var); |
|---|
| 6416 | nvram_default_get (mcast, "0"); |
|---|
| 6417 | showOption (wp, "wl_basic.multicast", mcast); |
|---|
| 6418 | show_ipnetmask (wp, var); |
|---|
| 6419 | websWrite (wp, "</div>\n"); |
|---|
| 6420 | websWrite (wp, "<script type=\"text/javascript\">\n//<![CDATA[\n "); |
|---|
| 6421 | websWrite (wp, |
|---|
| 6422 | "show_layer_ext(document.getElementsByName(\"%s_bridged\"), \"%s_idnet\", %s);\n", |
|---|
| 6423 | var, layer, nvram_match (ssid, "0") ? "true" : "false"); |
|---|
| 6424 | websWrite (wp, "//]]>\n</script>\n"); |
|---|
| 6425 | } |
|---|
| 6426 | websWrite (wp, "</fieldset><br />\n"); |
|---|
| 6427 | } |
|---|
| 6428 | #endif |
|---|
| 6429 | |
|---|
| 6430 | static void |
|---|
| 6431 | show_macfilter_if (webs_t wp, char *ifname) |
|---|
| 6432 | { |
|---|
| 6433 | char rifname[32]; |
|---|
| 6434 | strcpy (rifname, ifname); |
|---|
| 6435 | if (!strcmp (ifname, "wl")) |
|---|
| 6436 | strcpy (rifname, nvram_safe_get ("wl0_ifname")); |
|---|
| 6437 | if (!strcmp (ifname, "wl0")) |
|---|
| 6438 | strcpy (rifname, nvram_safe_get ("wl0_ifname")); |
|---|
| 6439 | |
|---|
| 6440 | websWrite (wp, "<fieldset>\n"); |
|---|
| 6441 | websWrite (wp, "<legend>%s - %s</legend>\n", rifname, |
|---|
| 6442 | live_translate ("wl_mac.legend")); |
|---|
| 6443 | websWrite (wp, "<div class=\"setting\">\n"); |
|---|
| 6444 | websWrite (wp, "<div class=\"label\">%s</div>\n", |
|---|
| 6445 | live_translate ("wl_mac.label")); |
|---|
| 6446 | char macmode[32]; |
|---|
| 6447 | sprintf (macmode, "%s_macmode1", ifname); |
|---|
| 6448 | rep (macmode, '.', 'X'); |
|---|
| 6449 | if (nvram_get (macmode) == NULL) |
|---|
| 6450 | nvram_set (macmode, "disabled"); |
|---|
| 6451 | char id[32]; |
|---|
| 6452 | sprintf (id, "idmac%s", ifname); |
|---|
| 6453 | rep (id, '.', 'X'); |
|---|
| 6454 | char mycopy[256]; |
|---|
| 6455 | strcpy (mycopy, live_translate ("share.enable")); |
|---|
| 6456 | websWrite (wp, |
|---|
| 6457 | "<input class=\"spaceradio\" type=\"radio\" value=\"other\" name=\"%s\" %s onclick=\"show_layer_ext(this, '%s', true)\" />%s \n", |
|---|
| 6458 | macmode, nvram_match (macmode, |
|---|
| 6459 | "other") ? "checked=\"checked\"" : "", id, |
|---|
| 6460 | mycopy); |
|---|
| 6461 | strcpy (mycopy, live_translate ("share.disable")); |
|---|
| 6462 | websWrite (wp, |
|---|
| 6463 | "<input class=\"spaceradio\" type=\"radio\" value=\"disabled\" name=\"%s\" %s onclick=\"show_layer_ext(this, '%s', false)\" />%s\n", |
|---|
| 6464 | macmode, nvram_match (macmode, |
|---|
| 6465 | "disabled") ? "checked=\"checked\"" : "", |
|---|
| 6466 | id, mycopy); |
|---|
| 6467 | websWrite (wp, "</div>\n"); |
|---|
| 6468 | websWrite (wp, "<div class=\"setting\" id=\"%s\">\n", id); |
|---|
| 6469 | websWrite (wp, "<div class=\"label\">%s<br /> </div>\n", |
|---|
| 6470 | live_translate ("wl_mac.label2")); |
|---|
| 6471 | sprintf (macmode, "%s_macmode", ifname); |
|---|
| 6472 | if (nvram_get (macmode) == NULL) |
|---|
| 6473 | nvram_set (macmode, "disabled"); |
|---|
| 6474 | strcpy (mycopy, live_translate ("wl_mac.deny")); |
|---|
| 6475 | websWrite (wp, |
|---|
| 6476 | "<input class=\"spaceradio\" type=\"radio\" value=\"deny\" name=\"%s\" %s />%s \n", |
|---|
| 6477 | macmode, nvram_invmatch (macmode, |
|---|
| 6478 | "allow") ? "checked=\"checked\"" : "", |
|---|
| 6479 | mycopy); |
|---|
| 6480 | websWrite (wp, "<br />\n"); |
|---|
| 6481 | strcpy (mycopy, live_translate ("wl_mac.allow")); |
|---|
| 6482 | websWrite (wp, |
|---|
| 6483 | "<input class=\"spaceradio\" type=\"radio\" value=\"allow\" name=\"%s\" %s />%s\n", |
|---|
| 6484 | macmode, nvram_match (macmode, |
|---|
| 6485 | "allow") ? "checked=\"checked\"" : "", |
|---|
| 6486 | mycopy); |
|---|
| 6487 | websWrite (wp, "</div><br />\n"); |
|---|
| 6488 | websWrite (wp, "<div class=\"center\">\n"); |
|---|
| 6489 | websWrite (wp, "<script type=\"text/javascript\">\n"); |
|---|
| 6490 | websWrite (wp, "//<![CDATA[\n"); |
|---|
| 6491 | websWrite (wp, |
|---|
| 6492 | "document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" name=\\\"mac_filter_button\\\" value=\\\"\" + sbutton.filterMac + \"\\\" onclick=\\\"openWindow('WL_FilterTable-%s.asp', 930, 740,'MACList');\\\" />\");\n", |
|---|
| 6493 | ifname); |
|---|
| 6494 | websWrite (wp, "//]]>\n"); |
|---|
| 6495 | websWrite (wp, "</script>\n"); |
|---|
| 6496 | websWrite (wp, "</div>\n"); |
|---|
| 6497 | websWrite (wp, "</fieldset><br />\n"); |
|---|
| 6498 | } |
|---|
| 6499 | |
|---|
| 6500 | void |
|---|
| 6501 | ej_list_mac_layers (webs_t wp, int argc, char_t ** argv) |
|---|
| 6502 | { |
|---|
| 6503 | #ifndef HAVE_MADWIFI |
|---|
| 6504 | int c = get_wl_instances (); |
|---|
| 6505 | char devs[32]; |
|---|
| 6506 | int i; |
|---|
| 6507 | for (i = 0; i < c; i++) |
|---|
| 6508 | { |
|---|
| 6509 | char macmode[32]; |
|---|
| 6510 | char id[32]; |
|---|
| 6511 | sprintf (devs, "wl%d", i); |
|---|
| 6512 | sprintf (macmode, "%s_macmode1", devs); |
|---|
| 6513 | sprintf (id, "idmac%s", devs); |
|---|
| 6514 | rep (id, '.', 'X'); |
|---|
| 6515 | rep (macmode, '.', 'X'); |
|---|
| 6516 | websWrite (wp, |
|---|
| 6517 | "show_layer_ext(document.wireless.%s, '%s', \"%s\" == \"other\");\n", |
|---|
| 6518 | macmode, id, nvram_match (macmode, |
|---|
| 6519 | "other") ? "other" : "disabled"); |
|---|
| 6520 | } |
|---|
| 6521 | |
|---|
| 6522 | #else |
|---|
| 6523 | |
|---|
| 6524 | int c = getdevicecount (); |
|---|
| 6525 | char devs[32]; |
|---|
| 6526 | int i; |
|---|
| 6527 | for (i = 0; i < c; i++) |
|---|
| 6528 | { |
|---|
| 6529 | char macmode[32]; |
|---|
| 6530 | char id[32]; |
|---|
| 6531 | sprintf (devs, "ath%d", i); |
|---|
| 6532 | sprintf (macmode, "%s_macmode1", devs); |
|---|
| 6533 | sprintf (id, "idmac%s", devs); |
|---|
| 6534 | rep (id, '.', 'X'); |
|---|
| 6535 | rep (macmode, '.', 'X'); |
|---|
| 6536 | websWrite (wp, |
|---|
| 6537 | "show_layer_ext(document.wireless.%s, '%s', \"%s\" == \"other\");\n", |
|---|
| 6538 | macmode, id, nvram_match (macmode, |
|---|
| 6539 | "other") ? "other" : "disabled"); |
|---|
| 6540 | //show_macfilter_if (wp, devs); |
|---|
| 6541 | char vif[32]; |
|---|
| 6542 | sprintf (vif, "%s_vifs", devs); |
|---|
| 6543 | char var[80], *next; |
|---|
| 6544 | char *vifs = nvram_safe_get (vif); |
|---|
| 6545 | if (vifs != NULL) |
|---|
| 6546 | foreach (var, vifs, next) |
|---|
| 6547 | { |
|---|
| 6548 | sprintf (macmode, "%s_macmode1", var); |
|---|
| 6549 | sprintf (id, "idmac%s", var); |
|---|
| 6550 | rep (id, '.', 'X'); |
|---|
| 6551 | rep (macmode, '.', 'X'); |
|---|
| 6552 | websWrite (wp, |
|---|
| 6553 | "show_layer_ext(document.wireless.%s, '%s', \"%s\" == \"other\");\n", |
|---|
| 6554 | macmode, id, nvram_match (macmode, |
|---|
| 6555 | "other") ? "other" : |
|---|
| 6556 | "disabled"); |
|---|
| 6557 | } |
|---|
| 6558 | } |
|---|
| 6559 | |
|---|
| 6560 | |
|---|
| 6561 | #endif |
|---|
| 6562 | } |
|---|
| 6563 | void |
|---|
| 6564 | ej_show_macfilter (webs_t wp, int argc, char_t ** argv) |
|---|
| 6565 | { |
|---|
| 6566 | #ifndef HAVE_MADWIFI |
|---|
| 6567 | int c = get_wl_instances (); |
|---|
| 6568 | char devs[32]; |
|---|
| 6569 | int i; |
|---|
| 6570 | for (i = 0; i < c; i++) |
|---|
| 6571 | { |
|---|
| 6572 | sprintf (devs, "wl%d", i); |
|---|
| 6573 | show_macfilter_if (wp, devs); |
|---|
| 6574 | } |
|---|
| 6575 | #else |
|---|
| 6576 | int c = getdevicecount (); |
|---|
| 6577 | char devs[32]; |
|---|
| 6578 | int i; |
|---|
| 6579 | for (i = 0; i < c; i++) |
|---|
| 6580 | { |
|---|
| 6581 | sprintf (devs, "ath%d", i); |
|---|
| 6582 | show_macfilter_if (wp, devs); |
|---|
| 6583 | char vif[32]; |
|---|
| 6584 | sprintf (vif, "%s_vifs", devs); |
|---|
| 6585 | char var[80], *next; |
|---|
| 6586 | char *vifs = nvram_safe_get (vif); |
|---|
| 6587 | if (vifs != NULL) |
|---|
| 6588 | foreach (var, vifs, next) |
|---|
| 6589 | { |
|---|
| 6590 | show_macfilter_if (wp, var); |
|---|
| 6591 | } |
|---|
| 6592 | } |
|---|
| 6593 | |
|---|
| 6594 | #endif |
|---|
| 6595 | } |
|---|
| 6596 | |
|---|
| 6597 | |
|---|
| 6598 | |
|---|
| 6599 | |
|---|
| 6600 | |
|---|
| 6601 | |
|---|
| 6602 | |
|---|
| 6603 | #ifdef HAVE_CHILLI |
|---|
| 6604 | void |
|---|
| 6605 | ej_show_chilliif (webs_t wp, int argc, char_t ** argv) |
|---|
| 6606 | { |
|---|
| 6607 | websWrite (wp, "<select name=\"chilli_interface\">\n"); |
|---|
| 6608 | websWrite (wp, "<option value=\"%s\" %s >LAN</option>\n", |
|---|
| 6609 | nvram_safe_get ("lan_ifname"), nvram_match ("chilli_interface", |
|---|
| 6610 | nvram_safe_get |
|---|
| 6611 | ("lan_ifname")) ? |
|---|
| 6612 | "selected=\"selected\"" : ""); |
|---|
| 6613 | char *next; |
|---|
| 6614 | char var[80]; |
|---|
| 6615 | #ifndef HAVE_MADWIFI |
|---|
| 6616 | websWrite (wp, "<option value=\"%s\" %s >WLAN</option>\n", |
|---|
| 6617 | nvram_safe_get ("wl0_ifname"), nvram_match ("chilli_interface", |
|---|
| 6618 | nvram_safe_get |
|---|
| 6619 | ("wl0_ifname")) ? |
|---|
| 6620 | "selected=\"selected\"" : ""); |
|---|
| 6621 | sprintf (var, "wl0_vifs"); |
|---|
| 6622 | char *names = nvram_safe_get (var); |
|---|
| 6623 | foreach (var, names, next) |
|---|
| 6624 | { |
|---|
| 6625 | websWrite (wp, "<option value=\"%s\" %s >WLAN</option>\n", var, |
|---|
| 6626 | nvram_match ("chilli_interface", |
|---|
| 6627 | var) ? "selected=\"selected\"" : ""); |
|---|
| 6628 | } |
|---|
| 6629 | #else |
|---|
| 6630 | int i; |
|---|
| 6631 | int c = getdevicecount (); |
|---|
| 6632 | for (i = 0; i < c; i++) |
|---|
| 6633 | { |
|---|
| 6634 | char ifname[32]; |
|---|
| 6635 | sprintf (ifname, "ath%d", i); |
|---|
| 6636 | websWrite (wp, "<option value=\"%s\" %s >%s</option>\n", ifname, |
|---|
| 6637 | nvram_match ("chilli_interface", ifname) ? "selected" : "", |
|---|
| 6638 | ifname); |
|---|
| 6639 | sprintf (var, "ath%d_vifs", i); |
|---|
| 6640 | char *names = nvram_safe_get (var); |
|---|
| 6641 | foreach (var, names, next) |
|---|
| 6642 | { |
|---|
| 6643 | websWrite (wp, "<option value=\"%s\" %s >%s</option>\n", var, |
|---|
| 6644 | nvram_match ("chilli_interface", var) ? "selected" : "", |
|---|
| 6645 | var); |
|---|
| 6646 | } |
|---|
| 6647 | } |
|---|
| 6648 | #endif |
|---|
| 6649 | |
|---|
| 6650 | websWrite (wp, "</select>\n"); |
|---|
| 6651 | } |
|---|
| 6652 | #endif |
|---|
| 6653 | |
|---|
| 6654 | #ifdef HAVE_RFLOW |
|---|
| 6655 | void |
|---|
| 6656 | ej_show_rflowif (webs_t wp, int argc, char_t ** argv) |
|---|
| 6657 | { |
|---|
| 6658 | websWrite (wp, "<option value=\"%s\" %s >LAN & WLAN</option>\n", |
|---|
| 6659 | nvram_safe_get ("lan_ifname"), nvram_match ("rflow_if", |
|---|
| 6660 | nvram_safe_get |
|---|
| 6661 | ("lan_ifname")) ? |
|---|
| 6662 | "selected=\"selected\"" : ""); |
|---|
| 6663 | |
|---|
| 6664 | char *lanifs = nvram_safe_get ("lan_ifnames"); |
|---|
| 6665 | char tmp[128]; |
|---|
| 6666 | char *lanif; |
|---|
| 6667 | if (strlen (lanifs) != 0) |
|---|
| 6668 | { |
|---|
| 6669 | strcpy (tmp, lanifs); |
|---|
| 6670 | lanif = strtok (tmp, " "); |
|---|
| 6671 | websWrite (wp, "<option value=\"%s\" %s >LAN</option>\n", |
|---|
| 6672 | lanif, nvram_match ("rflow_if", |
|---|
| 6673 | lanif) ? "selected=\"selected\"" : ""); |
|---|
| 6674 | } |
|---|
| 6675 | |
|---|
| 6676 | websWrite (wp, "<option value=\"%s\" %s >WLAN</option>\n", |
|---|
| 6677 | nvram_safe_get ("wl0_ifname"), nvram_match ("rflow_if", |
|---|
| 6678 | nvram_safe_get |
|---|
| 6679 | ("wl0_ifname")) ? |
|---|
| 6680 | "selected=\"selected\"" : ""); |
|---|
| 6681 | |
|---|
| 6682 | char *wanif = nvram_safe_get ("wan_ifname"); |
|---|
| 6683 | if (strlen (wanif) != 0) |
|---|
| 6684 | { |
|---|
| 6685 | websWrite (wp, "<option value=\"%s\" %s >WAN</option>\n", |
|---|
| 6686 | wanif, nvram_match ("rflow_if", |
|---|
| 6687 | wanif) ? "selected=\"selected\"" : ""); |
|---|
| 6688 | } |
|---|
| 6689 | } |
|---|
| 6690 | #endif |
|---|