| 1 | #define VISUALSOURCE 1 |
|---|
| 2 | /* |
|---|
| 3 | * dd-wrt.c |
|---|
| 4 | * |
|---|
| 5 | * Copyright (C) 2005 - 2007 Sebastian Gottschall <sebastian.gottschall@newmedia-net.de> |
|---|
| 6 | * |
|---|
| 7 | * This program is free software; you can redistribute it and/or |
|---|
| 8 | * modify it under the terms of the GNU General Public License |
|---|
| 9 | * as published by the Free Software Foundation; either version 2 |
|---|
| 10 | * of the License, or (at your option) any later version. |
|---|
| 11 | * |
|---|
| 12 | * This program is distributed in the hope that it will be useful, |
|---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | * GNU General Public License for more details. |
|---|
| 16 | * |
|---|
| 17 | * You should have received a copy of the GNU General Public License |
|---|
| 18 | * along with this program; if not, write to the Free Software |
|---|
| 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 20 | * |
|---|
| 21 | * $Id: |
|---|
| 22 | */ |
|---|
| 23 | |
|---|
| 24 | #include <stdio.h> |
|---|
| 25 | #include <stdlib.h> |
|---|
| 26 | #include <stdarg.h> |
|---|
| 27 | #include <string.h> |
|---|
| 28 | #include <unistd.h> |
|---|
| 29 | #include <ctype.h> |
|---|
| 30 | #include <signal.h> |
|---|
| 31 | |
|---|
| 32 | #include <sys/ioctl.h> |
|---|
| 33 | #include <sys/types.h> |
|---|
| 34 | #include <sys/stat.h> |
|---|
| 35 | #include <sys/socket.h> |
|---|
| 36 | #include <sys/statfs.h> |
|---|
| 37 | #include <netinet/in.h> |
|---|
| 38 | #include <arpa/inet.h> |
|---|
| 39 | #include <broadcom.h> |
|---|
| 40 | #include <cymac.h> |
|---|
| 41 | #include <wlutils.h> |
|---|
| 42 | #include <bcmparams.h> |
|---|
| 43 | #include <dirent.h> |
|---|
| 44 | #include <netdb.h> |
|---|
| 45 | #include <utils.h> |
|---|
| 46 | #include <wlutils.h> |
|---|
| 47 | #include <bcmnvram.h> |
|---|
| 48 | #include <l7protocols.h> |
|---|
| 49 | |
|---|
| 50 | #ifdef HAVE_OVERCLOCKING |
|---|
| 51 | static unsigned int type3_clocks[3] = { 150, 200, 0 }; |
|---|
| 52 | static unsigned int type4_clocks[10] = |
|---|
| 53 | { 192, 200, 216, 228, 240, 252, 264, 280, 300, 0 }; |
|---|
| 54 | static unsigned int type7_clocks[10] = |
|---|
| 55 | { 183, 187, 198, 200, 216, 225, 233, 237, 250, 0 }; |
|---|
| 56 | #endif |
|---|
| 57 | |
|---|
| 58 | #ifdef HAVE_RT2880 |
|---|
| 59 | #define IFMAP(a) getRADev(a) |
|---|
| 60 | #else |
|---|
| 61 | #define IFMAP(a) (a) |
|---|
| 62 | #endif |
|---|
| 63 | |
|---|
| 64 | void show_ipnetmask(webs_t wp, char *var) |
|---|
| 65 | { |
|---|
| 66 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 67 | websWrite(wp, |
|---|
| 68 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.ip)</script></div>\n"); |
|---|
| 69 | |
|---|
| 70 | char *ipv = nvram_nget("%s_ipaddr", var); |
|---|
| 71 | |
|---|
| 72 | websWrite(wp, |
|---|
| 73 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,1,223,share.ip)\" name=\"%s_ipaddr_0\" value=\"%d\" />.", |
|---|
| 74 | var, get_single_ip(ipv, 0)); |
|---|
| 75 | websWrite(wp, |
|---|
| 76 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_1\" value=\"%d\" />.", |
|---|
| 77 | var, get_single_ip(ipv, 1)); |
|---|
| 78 | websWrite(wp, |
|---|
| 79 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_2\" value=\"%d\" />.", |
|---|
| 80 | var, get_single_ip(ipv, 2)); |
|---|
| 81 | websWrite(wp, |
|---|
| 82 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_3\" value=\"%d\" />\n", |
|---|
| 83 | var, get_single_ip(ipv, 3)); |
|---|
| 84 | websWrite(wp, "</div>\n"); |
|---|
| 85 | |
|---|
| 86 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 87 | websWrite(wp, |
|---|
| 88 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.subnet)</script></div>\n"); |
|---|
| 89 | ipv = nvram_nget("%s_netmask", var); |
|---|
| 90 | |
|---|
| 91 | websWrite(wp, |
|---|
| 92 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_0\" value=\"%d\" />.", |
|---|
| 93 | var, get_single_ip(ipv, 0)); |
|---|
| 94 | websWrite(wp, |
|---|
| 95 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_1\" value=\"%d\" />.", |
|---|
| 96 | var, get_single_ip(ipv, 1)); |
|---|
| 97 | websWrite(wp, |
|---|
| 98 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_2\" value=\"%d\" />.", |
|---|
| 99 | var, get_single_ip(ipv, 2)); |
|---|
| 100 | websWrite(wp, |
|---|
| 101 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_3\" value=\"%d\" />", |
|---|
| 102 | var, get_single_ip(ipv, 3)); |
|---|
| 103 | websWrite(wp, "</div>\n<br />\n"); |
|---|
| 104 | |
|---|
| 105 | } |
|---|
| 106 | |
|---|
| 107 | #ifdef HAVE_OVERCLOCKING |
|---|
| 108 | void ej_show_clocks(webs_t wp, int argc, char_t ** argv) |
|---|
| 109 | { |
|---|
| 110 | int tab = cpu_plltype(); |
|---|
| 111 | unsigned int *c; |
|---|
| 112 | |
|---|
| 113 | if (tab == 3) |
|---|
| 114 | c = type3_clocks; |
|---|
| 115 | else if (tab == 4) |
|---|
| 116 | c = type4_clocks; |
|---|
| 117 | else if (tab == 7) |
|---|
| 118 | c = type7_clocks; |
|---|
| 119 | else { |
|---|
| 120 | websWrite(wp, |
|---|
| 121 | "<script type=\"text/javascript\">Capture(management.clock_support)</script>\n</div>\n"); |
|---|
| 122 | return; |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | websWrite(wp, |
|---|
| 126 | "<div class=\"label\"><script type=\"text/javascript\">Capture(management.clock_frq)</script></div>\n"); |
|---|
| 127 | websWrite(wp, "<select name=\"overclocking\">\n"); |
|---|
| 128 | |
|---|
| 129 | int i = 0; |
|---|
| 130 | char clock[16]; |
|---|
| 131 | |
|---|
| 132 | while (c[i] != 0) { |
|---|
| 133 | sprintf(clock, "%d", c[i]); |
|---|
| 134 | websWrite(wp, "<option value=\"%d\" %s >%d MHz</option>\n", |
|---|
| 135 | c[i], nvram_match("overclocking", |
|---|
| 136 | clock) ? "selected=\"selected\"" : |
|---|
| 137 | "", c[i]); |
|---|
| 138 | i++; |
|---|
| 139 | } |
|---|
| 140 | websWrite(wp, "</select>\n</div>\n"); |
|---|
| 141 | } |
|---|
| 142 | #endif |
|---|
| 143 | |
|---|
| 144 | void ej_show_routing(webs_t wp, int argc, char_t ** argv) |
|---|
| 145 | { |
|---|
| 146 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 147 | websWrite(wp, |
|---|
| 148 | "document.write(\"<option value=\\\"gateway\\\" %s >\" + share.gateway + \"</option>\");\n", |
|---|
| 149 | nvram_selmatch(wp, "wk_mode", |
|---|
| 150 | "gateway") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 151 | #ifdef HAVE_BIRD |
|---|
| 152 | websWrite(wp, |
|---|
| 153 | "document.write(\"<option value=\\\"bgp\\\" %s >BGP</option>\");\n", |
|---|
| 154 | nvram_selmatch(wp, "wk_mode", |
|---|
| 155 | "bgp") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 156 | websWrite(wp, |
|---|
| 157 | "document.write(\"<option value=\\\"router\\\" %s >\" + route.rip2_mod + \"</option>\");\n", |
|---|
| 158 | nvram_selmatch(wp, "wk_mode", |
|---|
| 159 | "router") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 160 | #endif |
|---|
| 161 | #ifdef HAVE_QUAGGA |
|---|
| 162 | websWrite(wp, |
|---|
| 163 | "document.write(\"<option value=\\\"bgp\\\" %s >BGP</option>\");\n", |
|---|
| 164 | nvram_selmatch(wp, "wk_mode", |
|---|
| 165 | "bgp") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 166 | websWrite(wp, |
|---|
| 167 | "document.write(\"<option value=\\\"router\\\" %s >\" + route.rip2_mod + \"</option>\");\n", |
|---|
| 168 | nvram_selmatch(wp, "wk_mode", |
|---|
| 169 | "router") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 170 | websWrite(wp, |
|---|
| 171 | "document.write(\"<option value=\\\"ospf\\\" %s >\" + route.ospf_mod + \"</option>\");\n", |
|---|
| 172 | nvram_selmatch(wp, "wk_mode", |
|---|
| 173 | "ospf") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 174 | #endif |
|---|
| 175 | #ifdef HAVE_OLSRD |
|---|
| 176 | websWrite(wp, |
|---|
| 177 | "document.write(\"<option value=\\\"olsr\\\" %s >\" + route.olsrd_mod + \"</option>\");\n", |
|---|
| 178 | nvram_selmatch(wp, "wk_mode", |
|---|
| 179 | "olsr") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 180 | #endif |
|---|
| 181 | websWrite(wp, |
|---|
| 182 | "document.write(\"<option value=\\\"static\\\" %s >\" + share.router + \"</option>\");\n", |
|---|
| 183 | nvram_selmatch(wp, "wk_mode", |
|---|
| 184 | "static") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 185 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 186 | return; |
|---|
| 187 | |
|---|
| 188 | } |
|---|
| 189 | |
|---|
| 190 | void ej_show_connectiontype(webs_t wp, int argc, char_t ** argv) |
|---|
| 191 | { |
|---|
| 192 | |
|---|
| 193 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 194 | websWrite(wp, |
|---|
| 195 | "document.write(\"<option value=\\\"disabled\\\" %s >\" + share.disabled + \"</option>\");\n", |
|---|
| 196 | nvram_selmatch(wp, "wan_proto", |
|---|
| 197 | "disabled") ? "selected=\\\"selected\\\"" : |
|---|
| 198 | ""); |
|---|
| 199 | websWrite(wp, |
|---|
| 200 | "document.write(\"<option value=\\\"static\\\" %s >\" + idx.static_ip + \"</option>\");\n", |
|---|
| 201 | nvram_selmatch(wp, "wan_proto", |
|---|
| 202 | "static") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 203 | websWrite(wp, |
|---|
| 204 | "document.write(\"<option value=\\\"dhcp\\\" %s >\" + idx.dhcp + \"</option>\");\n", |
|---|
| 205 | nvram_selmatch(wp, "wan_proto", |
|---|
| 206 | "dhcp") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 207 | websWrite(wp, "\n//]]>\n</script>\n"); |
|---|
| 208 | |
|---|
| 209 | #ifdef HAVE_PPPOE |
|---|
| 210 | websWrite(wp, "<option value=\"pppoe\" %s >PPPoE</option>\n", |
|---|
| 211 | nvram_selmatch(wp, "wan_proto", |
|---|
| 212 | "pppoe") ? "selected=\"selected\"" : ""); |
|---|
| 213 | #endif |
|---|
| 214 | #ifdef HAVE_PPTP |
|---|
| 215 | websWrite(wp, "<option value=\"pptp\" %s >PPTP</option>\n", |
|---|
| 216 | nvram_selmatch(wp, "wan_proto", |
|---|
| 217 | "pptp") ? "selected=\"selected\"" : ""); |
|---|
| 218 | #endif |
|---|
| 219 | #ifdef HAVE_L2TP |
|---|
| 220 | websWrite(wp, "<option value=\"l2tp\" %s >L2TP</option>\n", |
|---|
| 221 | nvram_selmatch(wp, "wan_proto", |
|---|
| 222 | "l2tp") ? "selected=\"selected\"" : ""); |
|---|
| 223 | #endif |
|---|
| 224 | #ifdef HAVE_HEARTBEAT |
|---|
| 225 | websWrite(wp, |
|---|
| 226 | "<option value=\"heartbeat\" %s >HeartBeat Signal</option>\n", |
|---|
| 227 | nvram_selmatch(wp, "wan_proto", |
|---|
| 228 | "heartbeat") ? "selected=\"selected\"" : ""); |
|---|
| 229 | #endif |
|---|
| 230 | #ifdef HAVE_3G |
|---|
| 231 | websWrite(wp, |
|---|
| 232 | "<option value=\"3g\" %s >3G/UMTS</option>\n", |
|---|
| 233 | nvram_selmatch(wp, "wan_proto", |
|---|
| 234 | "3g") ? "selected=\"selected\"" : ""); |
|---|
| 235 | #endif |
|---|
| 236 | |
|---|
| 237 | return; |
|---|
| 238 | } |
|---|
| 239 | |
|---|
| 240 | void ej_show_infopage(webs_t wp, int argc, char_t ** argv) |
|---|
| 241 | { |
|---|
| 242 | /* |
|---|
| 243 | * #ifdef HAVE_NEWMEDIA websWrite(wp,"<dl>\n"); websWrite(wp,"<dd |
|---|
| 244 | * class=\"definition\">GGEW net GmbH</dd>\n"); websWrite(wp,"<dd |
|---|
| 245 | * class=\"definition\">Dammstrasse 68</dd>\n"); websWrite(wp,"<dd |
|---|
| 246 | * class=\"definition\">64625 Bensheim</dd>\n"); websWrite(wp,"<dd |
|---|
| 247 | * class=\"definition\"><a href=\"http://ggew-net.de\"><img |
|---|
| 248 | * src=\"images/ggewlogo.gif\" border=\"0\"/></a></dd>\n"); |
|---|
| 249 | * websWrite(wp,"<dd class=\"definition\"> </dd>\n"); websWrite(wp,"<dd |
|---|
| 250 | * class=\"definition\"><a href=\"http://ggew-net.de\"/></dd>\n"); |
|---|
| 251 | * websWrite(wp,"<dd class=\"definition\"> </dd>\n"); websWrite(wp,"<dd |
|---|
| 252 | * class=\"definition\">In Kooperation mit NewMedia-NET GmbH</dd>\n"); |
|---|
| 253 | * websWrite(wp,"<dd class=\"definition\"><a |
|---|
| 254 | * href=\"http://www.newmedia-net.de\"/></dd>\n"); |
|---|
| 255 | * websWrite(wp,"</dl>\n"); #endif |
|---|
| 256 | */ |
|---|
| 257 | return; |
|---|
| 258 | } |
|---|
| 259 | |
|---|
| 260 | void ej_dumpmeminfo(webs_t wp, int argc, char_t ** argv) |
|---|
| 261 | { |
|---|
| 262 | FILE *fcpu = fopen("/proc/meminfo", "r"); |
|---|
| 263 | |
|---|
| 264 | if (fcpu == NULL) { |
|---|
| 265 | return; |
|---|
| 266 | } |
|---|
| 267 | char buf[128]; |
|---|
| 268 | int n = 0; |
|---|
| 269 | |
|---|
| 270 | rept:; |
|---|
| 271 | if (n == EOF) { |
|---|
| 272 | fclose(fcpu); |
|---|
| 273 | return; |
|---|
| 274 | } |
|---|
| 275 | if (n) |
|---|
| 276 | websWrite(wp, "'%s'", buf); |
|---|
| 277 | n = fscanf(fcpu, "%s", buf); |
|---|
| 278 | if (n != EOF) |
|---|
| 279 | websWrite(wp, ","); |
|---|
| 280 | goto rept; |
|---|
| 281 | } |
|---|
| 282 | |
|---|
| 283 | #ifdef HAVE_RB500 |
|---|
| 284 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 285 | { |
|---|
| 286 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 287 | |
|---|
| 288 | if (fp == NULL) { |
|---|
| 289 | websWrite(wp, "unknown"); |
|---|
| 290 | return; |
|---|
| 291 | } |
|---|
| 292 | int cnt = 0; |
|---|
| 293 | int b = 0; |
|---|
| 294 | |
|---|
| 295 | while (b != EOF) { |
|---|
| 296 | b = getc(fp); |
|---|
| 297 | if (b == ':') |
|---|
| 298 | cnt++; |
|---|
| 299 | |
|---|
| 300 | if (cnt == 4) { |
|---|
| 301 | getc(fp); |
|---|
| 302 | char cpuclk[4]; |
|---|
| 303 | |
|---|
| 304 | cpuclk[0] = getc(fp); |
|---|
| 305 | cpuclk[1] = getc(fp); |
|---|
| 306 | cpuclk[2] = getc(fp); |
|---|
| 307 | cpuclk[3] = 0; |
|---|
| 308 | websWrite(wp, cpuclk); |
|---|
| 309 | fclose(fp); |
|---|
| 310 | return; |
|---|
| 311 | } |
|---|
| 312 | } |
|---|
| 313 | |
|---|
| 314 | fclose(fp); |
|---|
| 315 | websWrite(wp, "unknown"); |
|---|
| 316 | return; |
|---|
| 317 | } |
|---|
| 318 | |
|---|
| 319 | #elif HAVE_STORM |
|---|
| 320 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 321 | { |
|---|
| 322 | websWrite(wp, "300"); |
|---|
| 323 | /* |
|---|
| 324 | * FILE *fp = fopen ("/proc/cpuinfo", "rb"); if (fp == NULL) { websWrite |
|---|
| 325 | * (wp, "unknown"); return; } int cnt = 0; int b = 0; while (b != EOF) { |
|---|
| 326 | * b = getc (fp); if (b == ':') cnt++; if (cnt == 2) { getc (fp); char |
|---|
| 327 | * cpuclk[4]; cpuclk[0] = getc (fp); cpuclk[1] = getc (fp); cpuclk[2] = |
|---|
| 328 | * getc (fp); cpuclk[3] = 0; websWrite (wp, cpuclk); fclose (fp); return; |
|---|
| 329 | * } } |
|---|
| 330 | * |
|---|
| 331 | * fclose (fp); websWrite (wp, "unknown"); |
|---|
| 332 | */ |
|---|
| 333 | return; |
|---|
| 334 | } |
|---|
| 335 | #elif HAVE_RT3052 |
|---|
| 336 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 337 | { |
|---|
| 338 | websWrite(wp, "384"); |
|---|
| 339 | return; |
|---|
| 340 | } |
|---|
| 341 | #elif HAVE_RT2880 |
|---|
| 342 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 343 | { |
|---|
| 344 | websWrite(wp, "266"); |
|---|
| 345 | return; |
|---|
| 346 | } |
|---|
| 347 | #elif HAVE_XSCALE |
|---|
| 348 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 349 | { |
|---|
| 350 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 351 | |
|---|
| 352 | if (fp == NULL) { |
|---|
| 353 | websWrite(wp, "unknown"); |
|---|
| 354 | return; |
|---|
| 355 | } |
|---|
| 356 | int cnt = 0; |
|---|
| 357 | int b = 0; |
|---|
| 358 | |
|---|
| 359 | while (b != EOF) { |
|---|
| 360 | b = getc(fp); |
|---|
| 361 | if (b == ':') |
|---|
| 362 | cnt++; |
|---|
| 363 | if (cnt == 2) { |
|---|
| 364 | getc(fp); |
|---|
| 365 | char cpuclk[4]; |
|---|
| 366 | |
|---|
| 367 | cpuclk[0] = getc(fp); |
|---|
| 368 | cpuclk[1] = getc(fp); |
|---|
| 369 | cpuclk[2] = getc(fp); |
|---|
| 370 | cpuclk[3] = 0; |
|---|
| 371 | websWrite(wp, cpuclk); |
|---|
| 372 | fclose(fp); |
|---|
| 373 | return; |
|---|
| 374 | } |
|---|
| 375 | } |
|---|
| 376 | |
|---|
| 377 | fclose(fp); |
|---|
| 378 | websWrite(wp, "unknown"); |
|---|
| 379 | return; |
|---|
| 380 | } |
|---|
| 381 | #elif HAVE_X86 |
|---|
| 382 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 383 | { |
|---|
| 384 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 385 | |
|---|
| 386 | if (fp == NULL) { |
|---|
| 387 | websWrite(wp, "unknown"); |
|---|
| 388 | return; |
|---|
| 389 | } |
|---|
| 390 | int cnt = 0; |
|---|
| 391 | int b = 0; |
|---|
| 392 | |
|---|
| 393 | while (b != EOF) { |
|---|
| 394 | b = getc(fp); |
|---|
| 395 | if (b == ':') |
|---|
| 396 | cnt++; |
|---|
| 397 | if (cnt == 7) { |
|---|
| 398 | getc(fp); |
|---|
| 399 | char cpuclk[32]; |
|---|
| 400 | int i = 0; |
|---|
| 401 | |
|---|
| 402 | b = getc(fp); |
|---|
| 403 | while (b != 0xa && b != 0xd && b != 0x20) { |
|---|
| 404 | cpuclk[i++] = b; |
|---|
| 405 | b = getc(fp); |
|---|
| 406 | } |
|---|
| 407 | cpuclk[i++] = 0; |
|---|
| 408 | websWrite(wp, cpuclk); |
|---|
| 409 | fclose(fp); |
|---|
| 410 | return; |
|---|
| 411 | } |
|---|
| 412 | } |
|---|
| 413 | |
|---|
| 414 | fclose(fp); |
|---|
| 415 | websWrite(wp, "unknown"); |
|---|
| 416 | return; |
|---|
| 417 | } |
|---|
| 418 | #elif HAVE_MAGICBOX |
|---|
| 419 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 420 | { |
|---|
| 421 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 422 | |
|---|
| 423 | if (fp == NULL) { |
|---|
| 424 | websWrite(wp, "unknown"); |
|---|
| 425 | return; |
|---|
| 426 | } |
|---|
| 427 | int cnt = 0; |
|---|
| 428 | int b = 0; |
|---|
| 429 | |
|---|
| 430 | while (b != EOF) { |
|---|
| 431 | b = getc(fp); |
|---|
| 432 | if (b == ':') |
|---|
| 433 | cnt++; |
|---|
| 434 | if (cnt == 3) { |
|---|
| 435 | getc(fp); |
|---|
| 436 | char cpuclk[4]; |
|---|
| 437 | |
|---|
| 438 | cpuclk[0] = getc(fp); |
|---|
| 439 | cpuclk[1] = getc(fp); |
|---|
| 440 | cpuclk[2] = getc(fp); |
|---|
| 441 | cpuclk[3] = 0; |
|---|
| 442 | websWrite(wp, cpuclk); |
|---|
| 443 | fclose(fp); |
|---|
| 444 | return; |
|---|
| 445 | } |
|---|
| 446 | } |
|---|
| 447 | |
|---|
| 448 | fclose(fp); |
|---|
| 449 | websWrite(wp, "unknown"); |
|---|
| 450 | return; |
|---|
| 451 | } |
|---|
| 452 | #elif HAVE_FONERA |
|---|
| 453 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 454 | { |
|---|
| 455 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 456 | |
|---|
| 457 | if (fp == NULL) { |
|---|
| 458 | websWrite(wp, "unknown"); |
|---|
| 459 | return; |
|---|
| 460 | } |
|---|
| 461 | int cnt = 0; |
|---|
| 462 | int b = 0; |
|---|
| 463 | |
|---|
| 464 | while (b != EOF) { |
|---|
| 465 | b = getc(fp); |
|---|
| 466 | if (b == ':') |
|---|
| 467 | cnt++; |
|---|
| 468 | if (cnt == 4) { |
|---|
| 469 | getc(fp); |
|---|
| 470 | char cpuclk[4]; |
|---|
| 471 | |
|---|
| 472 | cpuclk[0] = getc(fp); |
|---|
| 473 | cpuclk[1] = getc(fp); |
|---|
| 474 | cpuclk[2] = getc(fp); |
|---|
| 475 | cpuclk[3] = 0; |
|---|
| 476 | websWrite(wp, cpuclk); |
|---|
| 477 | fclose(fp); |
|---|
| 478 | return; |
|---|
| 479 | } |
|---|
| 480 | } |
|---|
| 481 | |
|---|
| 482 | fclose(fp); |
|---|
| 483 | websWrite(wp, "unknown"); |
|---|
| 484 | return; |
|---|
| 485 | } |
|---|
| 486 | #elif HAVE_ADM5120 |
|---|
| 487 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 488 | { |
|---|
| 489 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 490 | |
|---|
| 491 | if (fp == NULL) { |
|---|
| 492 | websWrite(wp, "unknown"); |
|---|
| 493 | return; |
|---|
| 494 | } |
|---|
| 495 | int cnt = 0; |
|---|
| 496 | int b = 0; |
|---|
| 497 | |
|---|
| 498 | while (b != EOF) { |
|---|
| 499 | b = getc(fp); |
|---|
| 500 | if (b == ':') |
|---|
| 501 | cnt++; |
|---|
| 502 | if (cnt == 4) { |
|---|
| 503 | getc(fp); |
|---|
| 504 | char cpuclk[4]; |
|---|
| 505 | |
|---|
| 506 | cpuclk[0] = getc(fp); |
|---|
| 507 | cpuclk[1] = getc(fp); |
|---|
| 508 | cpuclk[2] = getc(fp); |
|---|
| 509 | cpuclk[3] = 0; |
|---|
| 510 | websWrite(wp, cpuclk); |
|---|
| 511 | fclose(fp); |
|---|
| 512 | return; |
|---|
| 513 | } |
|---|
| 514 | } |
|---|
| 515 | |
|---|
| 516 | fclose(fp); |
|---|
| 517 | websWrite(wp, "unknown"); |
|---|
| 518 | return; |
|---|
| 519 | } |
|---|
| 520 | #elif HAVE_MERAKI |
|---|
| 521 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 522 | { |
|---|
| 523 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 524 | |
|---|
| 525 | if (fp == NULL) { |
|---|
| 526 | websWrite(wp, "unknown"); |
|---|
| 527 | return; |
|---|
| 528 | } |
|---|
| 529 | int cnt = 0; |
|---|
| 530 | int b = 0; |
|---|
| 531 | |
|---|
| 532 | while (b != EOF) { |
|---|
| 533 | b = getc(fp); |
|---|
| 534 | if (b == ':') |
|---|
| 535 | cnt++; |
|---|
| 536 | if (cnt == 4) { |
|---|
| 537 | getc(fp); |
|---|
| 538 | char cpuclk[4]; |
|---|
| 539 | |
|---|
| 540 | cpuclk[0] = getc(fp); |
|---|
| 541 | cpuclk[1] = getc(fp); |
|---|
| 542 | cpuclk[2] = getc(fp); |
|---|
| 543 | cpuclk[3] = 0; |
|---|
| 544 | websWrite(wp, cpuclk); |
|---|
| 545 | fclose(fp); |
|---|
| 546 | return; |
|---|
| 547 | } |
|---|
| 548 | } |
|---|
| 549 | |
|---|
| 550 | fclose(fp); |
|---|
| 551 | websWrite(wp, "unknown"); |
|---|
| 552 | return; |
|---|
| 553 | } |
|---|
| 554 | #elif HAVE_LS2 |
|---|
| 555 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 556 | { |
|---|
| 557 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 558 | |
|---|
| 559 | if (fp == NULL) { |
|---|
| 560 | websWrite(wp, "unknown"); |
|---|
| 561 | return; |
|---|
| 562 | } |
|---|
| 563 | int cnt = 0; |
|---|
| 564 | int b = 0; |
|---|
| 565 | |
|---|
| 566 | while (b != EOF) { |
|---|
| 567 | b = getc(fp); |
|---|
| 568 | if (b == ':') |
|---|
| 569 | cnt++; |
|---|
| 570 | if (cnt == 4) { |
|---|
| 571 | getc(fp); |
|---|
| 572 | char cpuclk[4]; |
|---|
| 573 | |
|---|
| 574 | cpuclk[0] = getc(fp); |
|---|
| 575 | cpuclk[1] = getc(fp); |
|---|
| 576 | cpuclk[2] = getc(fp); |
|---|
| 577 | cpuclk[3] = 0; |
|---|
| 578 | websWrite(wp, cpuclk); |
|---|
| 579 | fclose(fp); |
|---|
| 580 | return; |
|---|
| 581 | } |
|---|
| 582 | } |
|---|
| 583 | |
|---|
| 584 | fclose(fp); |
|---|
| 585 | websWrite(wp, "unknown"); |
|---|
| 586 | return; |
|---|
| 587 | } |
|---|
| 588 | #elif HAVE_LS5 |
|---|
| 589 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 590 | { |
|---|
| 591 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 592 | |
|---|
| 593 | if (fp == NULL) { |
|---|
| 594 | websWrite(wp, "unknown"); |
|---|
| 595 | return; |
|---|
| 596 | } |
|---|
| 597 | int cnt = 0; |
|---|
| 598 | int b = 0; |
|---|
| 599 | |
|---|
| 600 | while (b != EOF) { |
|---|
| 601 | b = getc(fp); |
|---|
| 602 | if (b == ':') |
|---|
| 603 | cnt++; |
|---|
| 604 | if (cnt == 4) { |
|---|
| 605 | getc(fp); |
|---|
| 606 | char cpuclk[4]; |
|---|
| 607 | |
|---|
| 608 | cpuclk[0] = getc(fp); |
|---|
| 609 | cpuclk[1] = getc(fp); |
|---|
| 610 | cpuclk[2] = getc(fp); |
|---|
| 611 | cpuclk[3] = 0; |
|---|
| 612 | websWrite(wp, cpuclk); |
|---|
| 613 | fclose(fp); |
|---|
| 614 | return; |
|---|
| 615 | } |
|---|
| 616 | } |
|---|
| 617 | |
|---|
| 618 | fclose(fp); |
|---|
| 619 | websWrite(wp, "unknown"); |
|---|
| 620 | return; |
|---|
| 621 | } |
|---|
| 622 | #elif HAVE_WHRAG108 |
|---|
| 623 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 624 | { |
|---|
| 625 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 626 | |
|---|
| 627 | if (fp == NULL) { |
|---|
| 628 | websWrite(wp, "unknown"); |
|---|
| 629 | return; |
|---|
| 630 | } |
|---|
| 631 | int cnt = 0; |
|---|
| 632 | int b = 0; |
|---|
| 633 | |
|---|
| 634 | while (b != EOF) { |
|---|
| 635 | b = getc(fp); |
|---|
| 636 | if (b == ':') |
|---|
| 637 | cnt++; |
|---|
| 638 | if (cnt == 4) { |
|---|
| 639 | getc(fp); |
|---|
| 640 | char cpuclk[4]; |
|---|
| 641 | |
|---|
| 642 | cpuclk[0] = getc(fp); |
|---|
| 643 | cpuclk[1] = getc(fp); |
|---|
| 644 | cpuclk[2] = getc(fp); |
|---|
| 645 | cpuclk[3] = 0; |
|---|
| 646 | websWrite(wp, cpuclk); |
|---|
| 647 | fclose(fp); |
|---|
| 648 | return; |
|---|
| 649 | } |
|---|
| 650 | } |
|---|
| 651 | |
|---|
| 652 | fclose(fp); |
|---|
| 653 | websWrite(wp, "unknown"); |
|---|
| 654 | return; |
|---|
| 655 | } |
|---|
| 656 | #elif defined(HAVE_PB42) || defined(HAVE_LSX) || defined(HAVE_DANUBE) |
|---|
| 657 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 658 | { |
|---|
| 659 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 660 | |
|---|
| 661 | if (fp == NULL) { |
|---|
| 662 | websWrite(wp, "unknown"); |
|---|
| 663 | return; |
|---|
| 664 | } |
|---|
| 665 | int cnt = 0; |
|---|
| 666 | int b = 0; |
|---|
| 667 | |
|---|
| 668 | while (b != EOF) { |
|---|
| 669 | b = getc(fp); |
|---|
| 670 | if (b == ':') |
|---|
| 671 | cnt++; |
|---|
| 672 | if (cnt == 6) { |
|---|
| 673 | getc(fp); |
|---|
| 674 | char cpuclk[4]; |
|---|
| 675 | |
|---|
| 676 | cpuclk[0] = getc(fp); |
|---|
| 677 | cpuclk[1] = getc(fp); |
|---|
| 678 | cpuclk[2] = getc(fp); |
|---|
| 679 | cpuclk[3] = 0; |
|---|
| 680 | websWrite(wp, cpuclk); |
|---|
| 681 | fclose(fp); |
|---|
| 682 | return; |
|---|
| 683 | } |
|---|
| 684 | } |
|---|
| 685 | |
|---|
| 686 | fclose(fp); |
|---|
| 687 | websWrite(wp, "unknown"); |
|---|
| 688 | return; |
|---|
| 689 | } |
|---|
| 690 | #elif HAVE_TW6600 |
|---|
| 691 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 692 | { |
|---|
| 693 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 694 | |
|---|
| 695 | if (fp == NULL) { |
|---|
| 696 | websWrite(wp, "unknown"); |
|---|
| 697 | return; |
|---|
| 698 | } |
|---|
| 699 | int cnt = 0; |
|---|
| 700 | int b = 0; |
|---|
| 701 | |
|---|
| 702 | while (b != EOF) { |
|---|
| 703 | b = getc(fp); |
|---|
| 704 | if (b == ':') |
|---|
| 705 | cnt++; |
|---|
| 706 | if (cnt == 4) { |
|---|
| 707 | getc(fp); |
|---|
| 708 | char cpuclk[4]; |
|---|
| 709 | |
|---|
| 710 | cpuclk[0] = getc(fp); |
|---|
| 711 | cpuclk[1] = getc(fp); |
|---|
| 712 | cpuclk[2] = getc(fp); |
|---|
| 713 | cpuclk[3] = 0; |
|---|
| 714 | websWrite(wp, cpuclk); |
|---|
| 715 | fclose(fp); |
|---|
| 716 | return; |
|---|
| 717 | } |
|---|
| 718 | } |
|---|
| 719 | |
|---|
| 720 | fclose(fp); |
|---|
| 721 | websWrite(wp, "unknown"); |
|---|
| 722 | return; |
|---|
| 723 | } |
|---|
| 724 | #elif HAVE_CA8 |
|---|
| 725 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 726 | { |
|---|
| 727 | FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 728 | |
|---|
| 729 | if (fp == NULL) { |
|---|
| 730 | websWrite(wp, "unknown"); |
|---|
| 731 | return; |
|---|
| 732 | } |
|---|
| 733 | int cnt = 0; |
|---|
| 734 | int b = 0; |
|---|
| 735 | |
|---|
| 736 | while (b != EOF) { |
|---|
| 737 | b = getc(fp); |
|---|
| 738 | if (b == ':') |
|---|
| 739 | cnt++; |
|---|
| 740 | if (cnt == 4) { |
|---|
| 741 | getc(fp); |
|---|
| 742 | char cpuclk[4]; |
|---|
| 743 | |
|---|
| 744 | cpuclk[0] = getc(fp); |
|---|
| 745 | cpuclk[1] = getc(fp); |
|---|
| 746 | cpuclk[2] = getc(fp); |
|---|
| 747 | cpuclk[3] = 0; |
|---|
| 748 | websWrite(wp, cpuclk); |
|---|
| 749 | fclose(fp); |
|---|
| 750 | return; |
|---|
| 751 | } |
|---|
| 752 | } |
|---|
| 753 | |
|---|
| 754 | fclose(fp); |
|---|
| 755 | websWrite(wp, "unknown"); |
|---|
| 756 | return; |
|---|
| 757 | } |
|---|
| 758 | |
|---|
| 759 | #else |
|---|
| 760 | |
|---|
| 761 | void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 762 | { |
|---|
| 763 | char *clk = nvram_get("clkfreq"); |
|---|
| 764 | |
|---|
| 765 | if (clk == NULL) { |
|---|
| 766 | if (getcpurev() == 0) //BCM4710 |
|---|
| 767 | websWrite(wp, "125"); |
|---|
| 768 | else if (getcpurev() == 29) //BCM5354 |
|---|
| 769 | websWrite(wp, "240"); |
|---|
| 770 | else |
|---|
| 771 | websWrite(wp, "unknown"); |
|---|
| 772 | return; |
|---|
| 773 | } |
|---|
| 774 | char buf[64]; |
|---|
| 775 | |
|---|
| 776 | strcpy(buf, clk); |
|---|
| 777 | int i = 0; |
|---|
| 778 | |
|---|
| 779 | while (buf[i++] != 0) { |
|---|
| 780 | if (buf[i] == ',') |
|---|
| 781 | buf[i] = 0; |
|---|
| 782 | } |
|---|
| 783 | websWrite(wp, buf); |
|---|
| 784 | return; |
|---|
| 785 | } |
|---|
| 786 | #endif |
|---|
| 787 | |
|---|
| 788 | void ej_show_cpuinfo(webs_t wp, int argc, char_t ** argv) |
|---|
| 789 | { |
|---|
| 790 | FILE *fcpu = fopen("/proc/cpuinfo", "r"); |
|---|
| 791 | |
|---|
| 792 | if (fcpu == NULL) { |
|---|
| 793 | websWrite(wp, "Not Detected!\n"); |
|---|
| 794 | return; |
|---|
| 795 | } |
|---|
| 796 | char buf[256]; |
|---|
| 797 | int i; |
|---|
| 798 | |
|---|
| 799 | #ifdef HAVE_MAGICBOX |
|---|
| 800 | int cnt = 0; |
|---|
| 801 | #endif |
|---|
| 802 | #ifdef HAVE_X86 |
|---|
| 803 | int cnt = 0; |
|---|
| 804 | #endif |
|---|
| 805 | for (i = 0; i < 256; i++) { |
|---|
| 806 | int c = getc(fcpu); |
|---|
| 807 | |
|---|
| 808 | if (c == EOF) { |
|---|
| 809 | websWrite(wp, "Not Detected!\n"); |
|---|
| 810 | fclose(fcpu); |
|---|
| 811 | return; |
|---|
| 812 | } |
|---|
| 813 | if (c == ':') |
|---|
| 814 | #ifdef HAVE_MAGICBOX |
|---|
| 815 | cnt++; |
|---|
| 816 | if (cnt == 2) |
|---|
| 817 | break; |
|---|
| 818 | #elif HAVE_X86 |
|---|
| 819 | cnt++; |
|---|
| 820 | if (cnt == 5) |
|---|
| 821 | break; |
|---|
| 822 | #else |
|---|
| 823 | break; |
|---|
| 824 | #endif |
|---|
| 825 | } |
|---|
| 826 | getc(fcpu); |
|---|
| 827 | for (i = 0; i < 256; i++) { |
|---|
| 828 | int c = getc(fcpu); |
|---|
| 829 | |
|---|
| 830 | if (c == EOF) { |
|---|
| 831 | websWrite(wp, "Not Detected!\n"); |
|---|
| 832 | fclose(fcpu); |
|---|
| 833 | return; |
|---|
| 834 | } |
|---|
| 835 | if (c == 0xa || c == 0xd) |
|---|
| 836 | break; |
|---|
| 837 | buf[i] = c; |
|---|
| 838 | } |
|---|
| 839 | buf[i] = 0; |
|---|
| 840 | websWrite(wp, buf); |
|---|
| 841 | fclose(fcpu); |
|---|
| 842 | return; |
|---|
| 843 | } |
|---|
| 844 | |
|---|
| 845 | #define ASSOCLIST_TMP "/tmp/.wl_assoclist" |
|---|
| 846 | #define RSSI_TMP "/tmp/.rssi" |
|---|
| 847 | #define ASSOCLIST_CMD "wl assoclist" |
|---|
| 848 | #define RSSI_CMD "wl rssi" |
|---|
| 849 | #define NOISE_CMD "wl noise" |
|---|
| 850 | |
|---|
| 851 | void ej_show_wds_subnet(webs_t wp, int argc, char_t ** argv) |
|---|
| 852 | { |
|---|
| 853 | int index = -1; |
|---|
| 854 | char *interface; |
|---|
| 855 | |
|---|
| 856 | #ifdef FASTWEB |
|---|
| 857 | ejArgs(argc, argv, "%d %s", &index, &interface); |
|---|
| 858 | #else |
|---|
| 859 | if (ejArgs(argc, argv, "%d %s", &index, &interface) < 2) { |
|---|
| 860 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 861 | return; |
|---|
| 862 | } |
|---|
| 863 | #endif |
|---|
| 864 | char br1[32]; |
|---|
| 865 | |
|---|
| 866 | sprintf(br1, "%s_br1_enable", interface); |
|---|
| 867 | if (nvram_invmatch(br1, "1")) |
|---|
| 868 | return; |
|---|
| 869 | char buf[16]; |
|---|
| 870 | |
|---|
| 871 | sprintf(buf, "%s_wds%d_enable", interface, index); |
|---|
| 872 | websWrite(wp, |
|---|
| 873 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"2\\\" %s >\" + wds.subnet + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 874 | nvram_selmatch(wp, buf, |
|---|
| 875 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 876 | return; |
|---|
| 877 | } |
|---|
| 878 | |
|---|
| 879 | #ifdef HAVE_SKYTRON |
|---|
| 880 | void ej_active_wireless2(webs_t wp, int argc, char_t ** argv) |
|---|
| 881 | { |
|---|
| 882 | int rssi = 0, noise = 0; |
|---|
| 883 | FILE *fp, *fp2; |
|---|
| 884 | char *mode; |
|---|
| 885 | char mac[30]; |
|---|
| 886 | char list[2][30]; |
|---|
| 887 | char line[80]; |
|---|
| 888 | |
|---|
| 889 | unlink(ASSOCLIST_TMP); |
|---|
| 890 | unlink(RSSI_TMP); |
|---|
| 891 | |
|---|
| 892 | mode = nvram_safe_get("wl_mode"); |
|---|
| 893 | sysprintf("%s > %s", ASSOCLIST_CMD, ASSOCLIST_TMP); |
|---|
| 894 | |
|---|
| 895 | int connected = 0; |
|---|
| 896 | |
|---|
| 897 | if ((fp = fopen(ASSOCLIST_TMP, "r"))) { |
|---|
| 898 | while (fgets(line, sizeof(line), fp) != NULL) { |
|---|
| 899 | if (sscanf(line, "%s %s", list[0], mac) != 2) // assoclist |
|---|
| 900 | // 00:11:22:33:44:55 |
|---|
| 901 | continue; |
|---|
| 902 | |
|---|
| 903 | if (strcmp(list[0], "assoclist")) |
|---|
| 904 | break; |
|---|
| 905 | |
|---|
| 906 | rssi = 0; |
|---|
| 907 | noise = 0; |
|---|
| 908 | // get rssi value |
|---|
| 909 | if (strcmp(mode, "ap")) |
|---|
| 910 | sysprintf("%s > %s", RSSI_CMD, RSSI_TMP); |
|---|
| 911 | else |
|---|
| 912 | sysprintf("%s \"%s\" > %s", RSSI_CMD, mac, |
|---|
| 913 | RSSI_TMP); |
|---|
| 914 | |
|---|
| 915 | // get noise value if not ap mode |
|---|
| 916 | if (strcmp(mode, "ap")) |
|---|
| 917 | sysprintf("%s >> %s", NOISE_CMD, RSSI_TMP); |
|---|
| 918 | |
|---|
| 919 | fp2 = fopen(RSSI_TMP, "r"); |
|---|
| 920 | if (fgets(line, sizeof(line), fp2) != NULL) { |
|---|
| 921 | |
|---|
| 922 | // get rssi |
|---|
| 923 | if (sscanf |
|---|
| 924 | (line, "%s %s %d", list[0], list[1], |
|---|
| 925 | &rssi) != 3) |
|---|
| 926 | continue; |
|---|
| 927 | |
|---|
| 928 | // get noise for client/wet mode |
|---|
| 929 | if (strcmp(mode, "ap") && |
|---|
| 930 | fgets(line, sizeof(line), fp2) != NULL && |
|---|
| 931 | sscanf(line, "%s %s %d", list[0], list[1], |
|---|
| 932 | &noise) != 3) |
|---|
| 933 | continue; |
|---|
| 934 | |
|---|
| 935 | fclose(fp2); |
|---|
| 936 | } |
|---|
| 937 | if (nvram_match("maskmac", "1")) { |
|---|
| 938 | mac[0] = 'x'; |
|---|
| 939 | mac[1] = 'x'; |
|---|
| 940 | mac[3] = 'x'; |
|---|
| 941 | mac[4] = 'x'; |
|---|
| 942 | mac[6] = 'x'; |
|---|
| 943 | mac[7] = 'x'; |
|---|
| 944 | mac[9] = 'x'; |
|---|
| 945 | mac[10] = 'x'; |
|---|
| 946 | } |
|---|
| 947 | if (strcmp(mode, "ap") != 0) { |
|---|
| 948 | connected = 1; |
|---|
| 949 | websWrite(wp, "<tr>\n"); |
|---|
| 950 | websWrite(wp, |
|---|
| 951 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\"><b>Verbindungsstatus</b></font></td>\n"); |
|---|
| 952 | websWrite(wp, |
|---|
| 953 | "<td bgcolor=\"#B2B2B2\"></td>\n"); |
|---|
| 954 | websWrite(wp, |
|---|
| 955 | "<td bgcolor=\"#FFFFFF\"></td>\n"); |
|---|
| 956 | websWrite(wp, |
|---|
| 957 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Verbunden</font></td>\n"); |
|---|
| 958 | websWrite(wp, "</tr>\n"); |
|---|
| 959 | websWrite(wp, "<tr>\n"); |
|---|
| 960 | websWrite(wp, |
|---|
| 961 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Signal</font></td>\n"); |
|---|
| 962 | websWrite(wp, |
|---|
| 963 | "<td bgcolor=\"#B2B2B2\"></td>\n"); |
|---|
| 964 | websWrite(wp, |
|---|
| 965 | "<td bgcolor=\"#FFFFFF\"></td>\n"); |
|---|
| 966 | websWrite(wp, |
|---|
| 967 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">%d dBm</font></td>\n", |
|---|
| 968 | rssi); |
|---|
| 969 | websWrite(wp, "</tr>\n"); |
|---|
| 970 | websWrite(wp, "<tr>\n"); |
|---|
| 971 | websWrite(wp, |
|---|
| 972 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Rauschen</font></td>\n"); |
|---|
| 973 | websWrite(wp, |
|---|
| 974 | "<td bgcolor=\"#B2B2B2\"></td>\n"); |
|---|
| 975 | websWrite(wp, |
|---|
| 976 | "<td bgcolor=\"#FFFFFF\"></td>\n"); |
|---|
| 977 | websWrite(wp, |
|---|
| 978 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">%d dBm</font></td>\n", |
|---|
| 979 | noise); |
|---|
| 980 | websWrite(wp, "</tr>\n"); |
|---|
| 981 | } |
|---|
| 982 | } |
|---|
| 983 | fclose(fp); |
|---|
| 984 | } |
|---|
| 985 | |
|---|
| 986 | unlink(ASSOCLIST_TMP); |
|---|
| 987 | unlink(RSSI_TMP); |
|---|
| 988 | if (!connected) { |
|---|
| 989 | connected = 1; |
|---|
| 990 | websWrite(wp, "<tr>\n"); |
|---|
| 991 | websWrite(wp, |
|---|
| 992 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\"><b>Verbindungsstatus</b></font></td>\n"); |
|---|
| 993 | websWrite(wp, "<td bgcolor=\"#B2B2B2\"></td>\n"); |
|---|
| 994 | websWrite(wp, "<td bgcolor=\"#FFFFFF\"></td>\n"); |
|---|
| 995 | websWrite(wp, |
|---|
| 996 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Nicht Verbunden</font></td>\n"); |
|---|
| 997 | websWrite(wp, "</tr>\n"); |
|---|
| 998 | |
|---|
| 999 | } |
|---|
| 1000 | |
|---|
| 1001 | return 0; |
|---|
| 1002 | } |
|---|
| 1003 | #endif |
|---|
| 1004 | |
|---|
| 1005 | void ej_show_paypal(webs_t wp, int argc, char_t ** argv) |
|---|
| 1006 | { |
|---|
| 1007 | #ifdef HAVE_DDLAN |
|---|
| 1008 | websWrite(wp, |
|---|
| 1009 | "<a href=\"mailto:support@mcdd.de\">support@mcdd.de</a><br />"); |
|---|
| 1010 | #endif |
|---|
| 1011 | #ifdef HAVE_CORENET |
|---|
| 1012 | websWrite(wp, |
|---|
| 1013 | "<a href=\"http://www.corenetsolutions.com\">http://www.corenetsolutions.com</a><br />"); |
|---|
| 1014 | #endif |
|---|
| 1015 | |
|---|
| 1016 | #ifndef CONFIG_BRANDING |
|---|
| 1017 | websWrite(wp, "<a href=\"http://www.dd-wrt.com/\">DD-WRT</a><br />"); |
|---|
| 1018 | websWrite(wp, |
|---|
| 1019 | "<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\" target=\"_blank\">"); |
|---|
| 1020 | websWrite(wp, |
|---|
| 1021 | "<input type=\"hidden\" name=\"cmd\" value=\"_xclick\" />"); |
|---|
| 1022 | websWrite(wp, |
|---|
| 1023 | "<input type=\"hidden\" name=\"business\" value=\"paypal@dd-wrt.com\" />"); |
|---|
| 1024 | websWrite(wp, |
|---|
| 1025 | "<input type=\"hidden\" name=\"item_name\" value=\"DD-WRT Development Support\" />"); |
|---|
| 1026 | websWrite(wp, "<input type=\"hidden\" name=\"no_note\" value=\"1\" />"); |
|---|
| 1027 | websWrite(wp, |
|---|
| 1028 | "<input type=\"hidden\" name=\"currency_code\" value=\"EUR\" />"); |
|---|
| 1029 | websWrite(wp, "<input type=\"hidden\" name=\"lc\" value=\"en\" />"); |
|---|
| 1030 | websWrite(wp, "<input type=\"hidden\" name=\"tax\" value=\"0\" />"); |
|---|
| 1031 | websWrite(wp, |
|---|
| 1032 | "<input type=\"image\" src=\"images/paypal.gif\" name=\"submit\" />"); |
|---|
| 1033 | websWrite(wp, "</form>"); |
|---|
| 1034 | websWrite(wp, |
|---|
| 1035 | "<br /><script type=\"text/javascript\">Capture(donate.mb)</script><br />\n"); |
|---|
| 1036 | websWrite(wp, |
|---|
| 1037 | "<a href=\"https://www.moneybookers.com/app/send.pl\" target=\"_blank\">\n"); |
|---|
| 1038 | // #ifdef HAVE_MICRO |
|---|
| 1039 | // websWrite (wp, |
|---|
| 1040 | // "<img style=\"border-width: 1px; border-color: #8B8583;\" |
|---|
| 1041 | // src=\"http://www.moneybookers.com/images/banners/88_en_interpayments.gif\" |
|---|
| 1042 | // alt=\"donate thru moneybookers\" />\n"); |
|---|
| 1043 | // #else |
|---|
| 1044 | websWrite(wp, |
|---|
| 1045 | "<img style=\"border-width: 1px; border-color: #8B8583;\" src=\"images/88_en_interpayments.png\" alt=\"donate thru interpayments\" />\n"); |
|---|
| 1046 | // #endif |
|---|
| 1047 | websWrite(wp, "</a>\n"); |
|---|
| 1048 | #endif |
|---|
| 1049 | return; |
|---|
| 1050 | } |
|---|
| 1051 | |
|---|
| 1052 | #ifdef HAVE_RADLOCAL |
|---|
| 1053 | |
|---|
| 1054 | void ej_show_iradius_check(webs_t wp, int argc, char_t ** argv) |
|---|
| 1055 | { |
|---|
| 1056 | char *sln = nvram_safe_get("iradius_count"); |
|---|
| 1057 | |
|---|
| 1058 | if (sln == NULL || strlen(sln) == 0) |
|---|
| 1059 | return; |
|---|
| 1060 | int leasenum = atoi(sln); |
|---|
| 1061 | int i; |
|---|
| 1062 | |
|---|
| 1063 | for (i = 0; i < leasenum; i++) { |
|---|
| 1064 | websWrite(wp, "if(F._iradius%d_active)\n", i); |
|---|
| 1065 | websWrite(wp, "if(F._iradius%d_active.checked == true)\n", i); |
|---|
| 1066 | websWrite(wp, "F.iradius%d_active.value=1\n", i); |
|---|
| 1067 | websWrite(wp, "else\n"); |
|---|
| 1068 | websWrite(wp, "F.iradius%d_active.value=0\n", i); |
|---|
| 1069 | |
|---|
| 1070 | websWrite(wp, "if(F._iradius%d_delete)\n", i); |
|---|
| 1071 | websWrite(wp, "if(F._iradius%d_delete.checked == true)\n", i); |
|---|
| 1072 | websWrite(wp, "F.iradius%d_delete.value=1\n", i); |
|---|
| 1073 | websWrite(wp, "else\n"); |
|---|
| 1074 | websWrite(wp, "F.iradius%d_delete.value=0\n", i); |
|---|
| 1075 | } |
|---|
| 1076 | |
|---|
| 1077 | } |
|---|
| 1078 | |
|---|
| 1079 | void ej_show_iradius(webs_t wp, int argc, char_t ** argv) |
|---|
| 1080 | { |
|---|
| 1081 | char *sln = nvram_safe_get("iradius_count"); |
|---|
| 1082 | |
|---|
| 1083 | if (sln == NULL || strlen(sln) == 0) |
|---|
| 1084 | return; |
|---|
| 1085 | int leasenum = atoi(sln); |
|---|
| 1086 | |
|---|
| 1087 | if (leasenum == 0) |
|---|
| 1088 | return; |
|---|
| 1089 | int i; |
|---|
| 1090 | char username[32]; |
|---|
| 1091 | char *o, *userlist; |
|---|
| 1092 | |
|---|
| 1093 | cprintf("get collection\n"); |
|---|
| 1094 | char *u = nvram_get_collection("iradius"); |
|---|
| 1095 | |
|---|
| 1096 | cprintf("collection result %s", u); |
|---|
| 1097 | if (u != NULL) { |
|---|
| 1098 | userlist = (char *)malloc(strlen(u) + 1); |
|---|
| 1099 | strcpy(userlist, u); |
|---|
| 1100 | free(u); |
|---|
| 1101 | o = userlist; |
|---|
| 1102 | } else { |
|---|
| 1103 | userlist = NULL; |
|---|
| 1104 | o = NULL; |
|---|
| 1105 | } |
|---|
| 1106 | cprintf("display = chain\n"); |
|---|
| 1107 | struct timeval now; |
|---|
| 1108 | |
|---|
| 1109 | gettimeofday(&now, NULL); |
|---|
| 1110 | for (i = 0; i < leasenum; i++) { |
|---|
| 1111 | snprintf(username, 31, "iradius%d_name", i); |
|---|
| 1112 | char *sep = NULL; |
|---|
| 1113 | |
|---|
| 1114 | if (userlist) |
|---|
| 1115 | sep = strsep(&userlist, " "); |
|---|
| 1116 | websWrite(wp, "<tr><td>\n"); |
|---|
| 1117 | websWrite(wp, "<input name=\"%s\" type=\"hidden\" />", |
|---|
| 1118 | username); |
|---|
| 1119 | websWrite(wp, |
|---|
| 1120 | "<input name=\"%s\" value=\"%s\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 1121 | username, sep != NULL ? sep : ""); |
|---|
| 1122 | websWrite(wp, "</td>\n"); |
|---|
| 1123 | if (userlist) |
|---|
| 1124 | sep = strsep(&userlist, " "); |
|---|
| 1125 | |
|---|
| 1126 | char active[32]; |
|---|
| 1127 | |
|---|
| 1128 | snprintf(active, 31, "iradius%d_active", i); |
|---|
| 1129 | |
|---|
| 1130 | websWrite(wp, "<td>\n"); |
|---|
| 1131 | websWrite(wp, "<input name=\"%s\" type=\"hidden\" />", active); |
|---|
| 1132 | websWrite(wp, |
|---|
| 1133 | "<input type=\"checkbox\" value=\"%s\" name=\"_%s\" %s />\n", |
|---|
| 1134 | sep, active, sep != NULL ? strcmp(sep, |
|---|
| 1135 | "1") == |
|---|
| 1136 | 0 ? "checked=\"checked\"" : "" : ""); |
|---|
| 1137 | websWrite(wp, "</td>\n"); |
|---|
| 1138 | websWrite(wp, "<td>\n"); |
|---|
| 1139 | if (userlist) |
|---|
| 1140 | sep = strsep(&userlist, " "); |
|---|
| 1141 | long t = atol(sep); |
|---|
| 1142 | |
|---|
| 1143 | if (t != -1) { |
|---|
| 1144 | t -= now.tv_sec; |
|---|
| 1145 | t /= 60; |
|---|
| 1146 | } |
|---|
| 1147 | |
|---|
| 1148 | snprintf(active, 31, "iradius%d_lease", i); |
|---|
| 1149 | char st[32]; |
|---|
| 1150 | |
|---|
| 1151 | if (t >= 0) |
|---|
| 1152 | sprintf(st, "%d", t); |
|---|
| 1153 | else |
|---|
| 1154 | sprintf(st, "over"); |
|---|
| 1155 | websWrite(wp, "<input type=\"num\" name=\"%s\" value='%s' />\n", |
|---|
| 1156 | active, st); |
|---|
| 1157 | websWrite(wp, "</td>\n"); |
|---|
| 1158 | |
|---|
| 1159 | websWrite(wp, "<td>\n"); |
|---|
| 1160 | snprintf(active, 31, "iradius%d_delete", i); |
|---|
| 1161 | websWrite(wp, "<input name=\"%s\" type=\"hidden\" />", active); |
|---|
| 1162 | websWrite(wp, "<input type=\"checkbox\" name=\"_%s\"/>\n", |
|---|
| 1163 | active); |
|---|
| 1164 | websWrite(wp, "</td></tr>\n"); |
|---|
| 1165 | } |
|---|
| 1166 | if (o != NULL) |
|---|
| 1167 | free(o); |
|---|
| 1168 | return; |
|---|
| 1169 | } |
|---|
| 1170 | |
|---|
| 1171 | #endif |
|---|
| 1172 | |
|---|
| 1173 | #ifdef HAVE_CHILLILOCAL |
|---|
| 1174 | |
|---|
| 1175 | void ej_show_userlist(webs_t wp, int argc, char_t ** argv) |
|---|
| 1176 | { |
|---|
| 1177 | char *sln = nvram_safe_get("fon_usernames"); |
|---|
| 1178 | |
|---|
| 1179 | if (sln == NULL || strlen(sln) == 0) |
|---|
| 1180 | return; |
|---|
| 1181 | int leasenum = atoi(sln); |
|---|
| 1182 | |
|---|
| 1183 | if (leasenum == 0) |
|---|
| 1184 | return; |
|---|
| 1185 | int i; |
|---|
| 1186 | char username[32]; |
|---|
| 1187 | char password[32]; |
|---|
| 1188 | char *u = nvram_safe_get("fon_userlist"); |
|---|
| 1189 | char *userlist = (char *)malloc(strlen(u) + 1); |
|---|
| 1190 | |
|---|
| 1191 | strcpy(userlist, u); |
|---|
| 1192 | char *o = userlist; |
|---|
| 1193 | |
|---|
| 1194 | for (i = 0; i < leasenum; i++) { |
|---|
| 1195 | snprintf(username, 31, "fon_user%d_name", i); |
|---|
| 1196 | char *sep = strsep(&userlist, "="); |
|---|
| 1197 | |
|---|
| 1198 | websWrite(wp, "<tr><td>\n"); |
|---|
| 1199 | websWrite(wp, |
|---|
| 1200 | "<input name=\"%s\" value=\"%s\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 1201 | username, sep != NULL ? sep : ""); |
|---|
| 1202 | websWrite(wp, "</td>\n"); |
|---|
| 1203 | sep = strsep(&userlist, " "); |
|---|
| 1204 | snprintf(password, 31, "fon_user%d_password", i); |
|---|
| 1205 | websWrite(wp, "<td>\n"); |
|---|
| 1206 | websWrite(wp, |
|---|
| 1207 | "<input type=\"password\" name=\"%s\" value=\"blahblahblah\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 1208 | password); |
|---|
| 1209 | websWrite(wp, "</td></tr>\n"); |
|---|
| 1210 | } |
|---|
| 1211 | free(o); |
|---|
| 1212 | return; |
|---|
| 1213 | } |
|---|
| 1214 | |
|---|
| 1215 | #endif |
|---|
| 1216 | |
|---|
| 1217 | void ej_show_staticleases(webs_t wp, int argc, char_t ** argv) |
|---|
| 1218 | { |
|---|
| 1219 | int i; |
|---|
| 1220 | |
|---|
| 1221 | // cprintf("get static leasenum"); |
|---|
| 1222 | |
|---|
| 1223 | char *sln = nvram_safe_get("static_leasenum"); |
|---|
| 1224 | |
|---|
| 1225 | // cprintf("check null"); |
|---|
| 1226 | if (sln == NULL || strlen(sln) == 0) |
|---|
| 1227 | return; |
|---|
| 1228 | // cprintf("atoi"); |
|---|
| 1229 | |
|---|
| 1230 | int leasenum = atoi(sln); |
|---|
| 1231 | |
|---|
| 1232 | // cprintf("leasenum==0"); |
|---|
| 1233 | if (leasenum == 0) |
|---|
| 1234 | return; |
|---|
| 1235 | // cprintf("get leases"); |
|---|
| 1236 | char *nvleases = nvram_safe_get("static_leases"); |
|---|
| 1237 | char *leases = (char *)malloc(strlen(nvleases) + 1); |
|---|
| 1238 | char *originalpointer = leases; // strsep destroys the pointer by |
|---|
| 1239 | |
|---|
| 1240 | // moving it |
|---|
| 1241 | strcpy(leases, nvleases); |
|---|
| 1242 | for (i = 0; i < leasenum; i++) { |
|---|
| 1243 | char *sep = strsep(&leases, "="); |
|---|
| 1244 | |
|---|
| 1245 | websWrite(wp, |
|---|
| 1246 | "<tr><td><input name=\"lease%d_hwaddr\" value=\"%s\" size=\"18\" maxlength=\"18\" onblur=\"valid_name(this,share.mac,SPACE_NO)\" /></td>", |
|---|
| 1247 | i, sep != NULL ? sep : ""); |
|---|
| 1248 | sep = strsep(&leases, "="); |
|---|
| 1249 | websWrite(wp, |
|---|
| 1250 | "<td><input name=\"lease%d_hostname\" value=\"%s\" size=\"24\" maxlength=\"24\" onblur=\"valid_name(this,share.hostname,SPACE_NO)\" /></td>", |
|---|
| 1251 | i, sep != NULL ? sep : ""); |
|---|
| 1252 | sep = strsep(&leases, " "); |
|---|
| 1253 | websWrite(wp, |
|---|
| 1254 | "<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", |
|---|
| 1255 | i, sep != NULL ? sep : ""); |
|---|
| 1256 | } |
|---|
| 1257 | free(originalpointer); |
|---|
| 1258 | return; |
|---|
| 1259 | } |
|---|
| 1260 | |
|---|
| 1261 | void ej_show_control(webs_t wp, int argc, char_t ** argv) |
|---|
| 1262 | { |
|---|
| 1263 | #ifdef CONFIG_BRANDING |
|---|
| 1264 | websWrite(wp, "Control Panel"); |
|---|
| 1265 | #else |
|---|
| 1266 | websWrite(wp, "DD-WRT Control Panel"); |
|---|
| 1267 | #endif |
|---|
| 1268 | return; |
|---|
| 1269 | } |
|---|
| 1270 | |
|---|
| 1271 | #ifndef HAVE_AQOS |
|---|
| 1272 | void ej_show_default_level(webs_t wp, int argc, char_t ** argv) |
|---|
| 1273 | { |
|---|
| 1274 | return; |
|---|
| 1275 | } |
|---|
| 1276 | |
|---|
| 1277 | #else |
|---|
| 1278 | void ej_show_default_level(webs_t wp, int argc, char_t ** argv) |
|---|
| 1279 | { |
|---|
| 1280 | websWrite(wp, "<fieldset>\n"); |
|---|
| 1281 | websWrite(wp, |
|---|
| 1282 | "<legend><script type=\"text/javascript\">Capture(qos.legend6)</script></legend>\n"); |
|---|
| 1283 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1284 | websWrite(wp, |
|---|
| 1285 | "<div class=\"label\"><script type=\"text/javascript\">Capture(qos.bandwidth)</script> Up</div>\n"); |
|---|
| 1286 | websWrite(wp, |
|---|
| 1287 | "<input type=\"num\" name=\"default_uplevel\" size=\"6\" value=\"%s\" /> Down\n", |
|---|
| 1288 | nvram_safe_get("default_uplevel")); |
|---|
| 1289 | websWrite(wp, |
|---|
| 1290 | "<input type=\"num\" name=\"default_downlevel\" size=\"6\" value=\"%s\" />\n", |
|---|
| 1291 | nvram_safe_get("default_downlevel")); |
|---|
| 1292 | websWrite(wp, "</div>\n"); |
|---|
| 1293 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 1294 | return; |
|---|
| 1295 | } |
|---|
| 1296 | #endif |
|---|
| 1297 | |
|---|
| 1298 | #ifdef HAVE_MADWIFI |
|---|
| 1299 | struct wifi_channels { |
|---|
| 1300 | int channel; |
|---|
| 1301 | int freq; |
|---|
| 1302 | int noise; |
|---|
| 1303 | }; |
|---|
| 1304 | extern struct wifi_channels *list_channels(char *devnr); |
|---|
| 1305 | |
|---|
| 1306 | // extern int getchannelcount (void); |
|---|
| 1307 | extern int getdevicecount(void); |
|---|
| 1308 | #endif |
|---|
| 1309 | |
|---|
| 1310 | static char *selmatch(char *var, char *is, char *ret) |
|---|
| 1311 | { |
|---|
| 1312 | if (nvram_match(var, is)) |
|---|
| 1313 | return ret; |
|---|
| 1314 | return ""; |
|---|
| 1315 | } |
|---|
| 1316 | |
|---|
| 1317 | static void |
|---|
| 1318 | show_security_prefix(webs_t wp, int argc, char_t ** argv, char *prefix, |
|---|
| 1319 | int primary) |
|---|
| 1320 | { |
|---|
| 1321 | static char var[80]; |
|---|
| 1322 | static char sta[80]; |
|---|
| 1323 | |
|---|
| 1324 | // char p2[80]; |
|---|
| 1325 | cprintf("show security prefix\n"); |
|---|
| 1326 | sprintf(var, "%s_security_mode", prefix); |
|---|
| 1327 | // strcpy(p2,prefix); |
|---|
| 1328 | // rep(p2,'X','.'); |
|---|
| 1329 | // websWrite (wp, "<input type=\"hidden\" |
|---|
| 1330 | // name=\"%s_security_mode\"/>\n",p2); |
|---|
| 1331 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1332 | websWrite(wp, |
|---|
| 1333 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.secmode)</script></div>\n"); |
|---|
| 1334 | websWrite(wp, |
|---|
| 1335 | "<select name=\"%s_security_mode\" onchange=\"SelMode('%s_security_mode',this.form.%s_security_mode.selectedIndex,this.form)\">\n", |
|---|
| 1336 | prefix, prefix, prefix); |
|---|
| 1337 | websWrite(wp, |
|---|
| 1338 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"disabled\\\" %s >\" + share.disabled + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 1339 | selmatch(var, "disabled", "selected=\\\"selected\\\"")); |
|---|
| 1340 | websWrite(wp, "<option value=\"psk\" %s>WPA Personal</option>\n", |
|---|
| 1341 | selmatch(var, "psk", "selected=\"selected\"")); |
|---|
| 1342 | sprintf(sta, "%s_mode", prefix); |
|---|
| 1343 | if (!primary || nvram_match(sta, "ap") || nvram_match(sta, "wdsap")) { |
|---|
| 1344 | websWrite(wp, |
|---|
| 1345 | "<option value=\"wpa\" %s>WPA Enterprise</option>\n", |
|---|
| 1346 | selmatch(var, "wpa", "selected=\"selected\"")); |
|---|
| 1347 | } |
|---|
| 1348 | websWrite(wp, "<option value=\"psk2\" %s>WPA2 Personal</option>\n", |
|---|
| 1349 | selmatch(var, "psk2", "selected=\"selected\"")); |
|---|
| 1350 | if (!primary || nvram_match(sta, "ap") || nvram_match(sta, "wdsap")) { |
|---|
| 1351 | websWrite(wp, |
|---|
| 1352 | "<option value=\"wpa2\" %s>WPA2 Enterprise</option>\n", |
|---|
| 1353 | selmatch(var, "wpa2", "selected=\"selected\"")); |
|---|
| 1354 | } |
|---|
| 1355 | #ifdef HAVE_RT2880 |
|---|
| 1356 | if (!primary || nvram_match(sta, "ap")) |
|---|
| 1357 | #endif |
|---|
| 1358 | websWrite(wp, |
|---|
| 1359 | "<option value=\"psk psk2\" %s>WPA2 Personal Mixed</option>\n", |
|---|
| 1360 | selmatch(var, "psk psk2", "selected=\"selected\"")); |
|---|
| 1361 | |
|---|
| 1362 | if (!primary || nvram_match(sta, "ap") || nvram_match(sta, "wdsap")) { |
|---|
| 1363 | websWrite(wp, |
|---|
| 1364 | "<option value=\"wpa wpa2\" %s>WPA2 Enterprise Mixed</option>\n", |
|---|
| 1365 | selmatch(var, "wpa wpa2", "selected=\"selected\"")); |
|---|
| 1366 | |
|---|
| 1367 | websWrite(wp, "<option value=\"radius\" %s>RADIUS</option>\n", |
|---|
| 1368 | selmatch(var, "radius", "selected=\"selected\"")); |
|---|
| 1369 | } |
|---|
| 1370 | |
|---|
| 1371 | websWrite(wp, "<option value=\"wep\" %s>WEP</option>\n", |
|---|
| 1372 | selmatch(var, "wep", "selected=\"selected\"")); |
|---|
| 1373 | #ifdef HAVE_WPA_SUPPLICANT |
|---|
| 1374 | #ifndef HAVE_MICRO |
|---|
| 1375 | #ifndef HAVE_RT2880 |
|---|
| 1376 | if (!primary || nvram_match(sta, "sta") || nvram_match(sta, "wdssta") |
|---|
| 1377 | || nvram_match(sta, "apsta") || nvram_match(sta, "wet")) { |
|---|
| 1378 | websWrite(wp, "<option value=\"8021X\" %s>802.1x</option>\n", |
|---|
| 1379 | selmatch(var, "8021X", "selected=\"selected\"")); |
|---|
| 1380 | } |
|---|
| 1381 | #else |
|---|
| 1382 | if (nvram_match(sta, "sta") || nvram_match(sta, "wet")) { |
|---|
| 1383 | websWrite(wp, "<option value=\"8021X\" %s>802.1x</option>\n", |
|---|
| 1384 | selmatch(var, "8021X", "selected=\"selected\"")); |
|---|
| 1385 | } |
|---|
| 1386 | #endif |
|---|
| 1387 | #endif |
|---|
| 1388 | #endif |
|---|
| 1389 | |
|---|
| 1390 | websWrite(wp, "</select></div>\n"); |
|---|
| 1391 | rep(prefix, 'X', '.'); |
|---|
| 1392 | cprintf("ej show wpa\n"); |
|---|
| 1393 | ej_show_wpa_setting(wp, argc, argv, prefix); |
|---|
| 1394 | |
|---|
| 1395 | } |
|---|
| 1396 | |
|---|
| 1397 | static void |
|---|
| 1398 | ej_show_security_single(webs_t wp, int argc, char_t ** argv, char *prefix) |
|---|
| 1399 | { |
|---|
| 1400 | char *next; |
|---|
| 1401 | char var[80]; |
|---|
| 1402 | char ssid[80]; |
|---|
| 1403 | char mac[16]; |
|---|
| 1404 | |
|---|
| 1405 | sprintf(mac, "%s_hwaddr", prefix); |
|---|
| 1406 | char *vifs = nvram_nget("%s_vifs", prefix); |
|---|
| 1407 | |
|---|
| 1408 | if (vifs == NULL) |
|---|
| 1409 | return; |
|---|
| 1410 | sprintf(ssid, "%s_ssid", prefix); |
|---|
| 1411 | websWrite(wp, |
|---|
| 1412 | "<h2><script type=\"text/javascript\">Capture(wpa.h2)</script> %s</h2>\n", |
|---|
| 1413 | prefix); |
|---|
| 1414 | websWrite(wp, "<fieldset>\n"); |
|---|
| 1415 | // cprintf("getting %s %s\n",ssid,nvram_safe_get(ssid)); |
|---|
| 1416 | websWrite(wp, |
|---|
| 1417 | "<legend><script type=\"text/javascript\">Capture(share.pintrface)</script> %s SSID [", |
|---|
| 1418 | IFMAP(prefix)); |
|---|
| 1419 | tf_webWriteESCNV(wp, ssid); // fix for broken html page if ssid |
|---|
| 1420 | // contains html tag |
|---|
| 1421 | websWrite(wp, "] HWAddr [%s]</legend>\n", nvram_safe_get(mac)); |
|---|
| 1422 | show_security_prefix(wp, argc, argv, prefix, 1); |
|---|
| 1423 | websWrite(wp, "</fieldset>\n<br />\n"); |
|---|
| 1424 | foreach(var, vifs, next) { |
|---|
| 1425 | sprintf(ssid, "%s_ssid", var); |
|---|
| 1426 | websWrite(wp, "<fieldset>\n"); |
|---|
| 1427 | // cprintf("getting %s %s\n", ssid,nvram_safe_get(ssid)); |
|---|
| 1428 | websWrite(wp, |
|---|
| 1429 | "<legend><script type=\"text/javascript\">Capture(share.vintrface)</script> %s SSID [", |
|---|
| 1430 | IFMAP(var)); |
|---|
| 1431 | tf_webWriteESCNV(wp, ssid); // fix for broken html page if ssid |
|---|
| 1432 | // contains html tag |
|---|
| 1433 | websWrite(wp, "]</legend>\n"); |
|---|
| 1434 | rep(var, '.', 'X'); |
|---|
| 1435 | show_security_prefix(wp, argc, argv, var, 0); |
|---|
| 1436 | websWrite(wp, "</fieldset>\n<br />\n"); |
|---|
| 1437 | } |
|---|
| 1438 | |
|---|
| 1439 | } |
|---|
| 1440 | |
|---|
| 1441 | void ej_show_security(webs_t wp, int argc, char_t ** argv) |
|---|
| 1442 | { |
|---|
| 1443 | #ifndef HAVE_MADWIFI |
|---|
| 1444 | int c = get_wl_instances(); |
|---|
| 1445 | int i; |
|---|
| 1446 | |
|---|
| 1447 | for (i = 0; i < c; i++) { |
|---|
| 1448 | char buf[16]; |
|---|
| 1449 | |
|---|
| 1450 | sprintf(buf, "wl%d", i); |
|---|
| 1451 | ej_show_security_single(wp, argc, argv, buf); |
|---|
| 1452 | } |
|---|
| 1453 | return; |
|---|
| 1454 | #else |
|---|
| 1455 | int c = getdevicecount(); |
|---|
| 1456 | int i; |
|---|
| 1457 | |
|---|
| 1458 | for (i = 0; i < c; i++) { |
|---|
| 1459 | char buf[16]; |
|---|
| 1460 | |
|---|
| 1461 | sprintf(buf, "ath%d", i); |
|---|
| 1462 | ej_show_security_single(wp, argc, argv, buf); |
|---|
| 1463 | } |
|---|
| 1464 | return; |
|---|
| 1465 | #endif |
|---|
| 1466 | } |
|---|
| 1467 | |
|---|
| 1468 | void ej_show_dhcpd_settings(webs_t wp, int argc, char_t ** argv) |
|---|
| 1469 | { |
|---|
| 1470 | int i; |
|---|
| 1471 | |
|---|
| 1472 | if (getWET()) // dhcpd settings disabled in client bridge mode, so we wont display it |
|---|
| 1473 | return; |
|---|
| 1474 | |
|---|
| 1475 | websWrite(wp, |
|---|
| 1476 | "<fieldset><legend><script type=\"text/javascript\">Capture(idx.dhcp_legend)</script></legend>\n"); |
|---|
| 1477 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1478 | websWrite(wp, |
|---|
| 1479 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_type)</script></div>\n"); |
|---|
| 1480 | websWrite(wp, |
|---|
| 1481 | "<select class=\"num\" size=\"1\" name=\"dhcpfwd_enable\" onchange=SelDHCPFWD(this.form.dhcpfwd_enable.selectedIndex,this.form)>\n"); |
|---|
| 1482 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1483 | websWrite(wp, |
|---|
| 1484 | "document.write(\"<option value=\\\"0\\\" %s >\" + idx.dhcp_srv + \"</option>\");\n", |
|---|
| 1485 | nvram_match("dhcpfwd_enable", |
|---|
| 1486 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1487 | websWrite(wp, |
|---|
| 1488 | "document.write(\"<option value=\\\"1\\\" %s >\" + idx.dhcp_fwd + \"</option>\");\n", |
|---|
| 1489 | nvram_match("dhcpfwd_enable", |
|---|
| 1490 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1491 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 1492 | websWrite(wp, "</select>\n"); |
|---|
| 1493 | websWrite(wp, "</div>\n"); |
|---|
| 1494 | if (nvram_match("dhcpfwd_enable", "1")) { |
|---|
| 1495 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1496 | websWrite(wp, |
|---|
| 1497 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_srv)</script></div>\n"); |
|---|
| 1498 | char *ipfwd = nvram_safe_get("dhcpfwd_ip"); |
|---|
| 1499 | |
|---|
| 1500 | websWrite(wp, |
|---|
| 1501 | "<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", |
|---|
| 1502 | get_single_ip(ipfwd, 0), get_single_ip(ipfwd, 1), |
|---|
| 1503 | get_single_ip(ipfwd, 2), get_single_ip(ipfwd, 3)); |
|---|
| 1504 | } else { |
|---|
| 1505 | char buf[20]; |
|---|
| 1506 | |
|---|
| 1507 | prefix_ip_get("lan_ipaddr", buf, 1); |
|---|
| 1508 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1509 | // char *nv = nvram_safe_get ("wan_wins"); |
|---|
| 1510 | websWrite(wp, |
|---|
| 1511 | "<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", |
|---|
| 1512 | nvram_match("lan_proto", |
|---|
| 1513 | "dhcp") ? "checked=\"checked\"" : ""); |
|---|
| 1514 | websWrite(wp, |
|---|
| 1515 | "<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", |
|---|
| 1516 | nvram_match("lan_proto", |
|---|
| 1517 | "static") ? "checked=\"checked\"" : ""); |
|---|
| 1518 | websWrite(wp, |
|---|
| 1519 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_start)</script></div>%s", |
|---|
| 1520 | buf); |
|---|
| 1521 | websWrite(wp, |
|---|
| 1522 | "<input class=\"num\" name=\"dhcp_start\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,1,254,idx.dhcp_start)\" value=\"%s\" />", |
|---|
| 1523 | nvram_safe_get("dhcp_start")); |
|---|
| 1524 | websWrite(wp, "</div>\n"); |
|---|
| 1525 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1526 | websWrite(wp, |
|---|
| 1527 | "<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", |
|---|
| 1528 | nvram_safe_get("dhcp_num")); |
|---|
| 1529 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1530 | websWrite(wp, |
|---|
| 1531 | "<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", |
|---|
| 1532 | nvram_safe_get("dhcp_lease")); |
|---|
| 1533 | if (nvram_invmatch("wan_proto", "static")) { |
|---|
| 1534 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1535 | websWrite(wp, |
|---|
| 1536 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 1</div>"); |
|---|
| 1537 | websWrite(wp, |
|---|
| 1538 | "<input type=\"hidden\" name=\"wan_dns\" value=\"4\" />"); |
|---|
| 1539 | for (i = 0; i < 4; i++) |
|---|
| 1540 | websWrite(wp, |
|---|
| 1541 | "<input class=\"num\" name=\"wan_dns0_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1542 | i, i == 3 ? 254 : 255, |
|---|
| 1543 | get_dns_ip("wan_dns", 0, i), |
|---|
| 1544 | i < 3 ? "." : ""); |
|---|
| 1545 | |
|---|
| 1546 | websWrite(wp, "\n</div>\n<div class=\"setting\">\n"); |
|---|
| 1547 | websWrite(wp, |
|---|
| 1548 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 2</div>"); |
|---|
| 1549 | for (i = 0; i < 4; i++) |
|---|
| 1550 | websWrite(wp, |
|---|
| 1551 | "<input class=\"num\" name=\"wan_dns1_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1552 | i, i == 3 ? 254 : 255, |
|---|
| 1553 | get_dns_ip("wan_dns", 1, i), |
|---|
| 1554 | i < 3 ? "." : ""); |
|---|
| 1555 | |
|---|
| 1556 | websWrite(wp, "\n</div>\n<div class=\"setting\">\n"); |
|---|
| 1557 | websWrite(wp, |
|---|
| 1558 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 3</div>"); |
|---|
| 1559 | for (i = 0; i < 4; i++) |
|---|
| 1560 | websWrite(wp, |
|---|
| 1561 | "<input class=\"num\" name=\"wan_dns2_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1562 | i, i == 3 ? 254 : 255, |
|---|
| 1563 | get_dns_ip("wan_dns", 2, i), |
|---|
| 1564 | i < 3 ? "." : ""); |
|---|
| 1565 | websWrite(wp, "\n</div>"); |
|---|
| 1566 | } |
|---|
| 1567 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1568 | websWrite(wp, "<div class=\"label\">WINS</div>\n"); |
|---|
| 1569 | websWrite(wp, |
|---|
| 1570 | "<input type=\"hidden\" name=\"wan_wins\" value=\"4\" />\n"); |
|---|
| 1571 | char *wins = nvram_safe_get("wan_wins"); |
|---|
| 1572 | |
|---|
| 1573 | for (i = 0; i < 4; i++) { |
|---|
| 1574 | websWrite(wp, |
|---|
| 1575 | "<input class=\"num\" name=\"wan_wins_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,"WINS")\" value=\"%d\" />%s", |
|---|
| 1576 | i, i == 3 ? 254 : 255, get_single_ip(wins, i), |
|---|
| 1577 | i < 3 ? "." : ""); |
|---|
| 1578 | } |
|---|
| 1579 | |
|---|
| 1580 | websWrite(wp, "</div>\n<div class=\"setting\">\n"); |
|---|
| 1581 | websWrite(wp, |
|---|
| 1582 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_dnsmasq)</script></div>\n"); |
|---|
| 1583 | websWrite(wp, |
|---|
| 1584 | "<input type=\"checkbox\" name=\"_dhcp_dnsmasq\" value=\"1\" onclick=\"setDNSMasq(this.form)\" %s />\n", |
|---|
| 1585 | nvram_match("dhcp_dnsmasq", |
|---|
| 1586 | "1") ? "checked=\"checked\"" : ""); |
|---|
| 1587 | websWrite(wp, "</div>\n<div class=\"setting\">\n"); |
|---|
| 1588 | websWrite(wp, |
|---|
| 1589 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dns_dnsmasq)</script></div>\n"); |
|---|
| 1590 | websWrite(wp, |
|---|
| 1591 | "<input type=\"checkbox\" name=\"_dns_dnsmasq\" value=\"1\" %s />\n", |
|---|
| 1592 | nvram_match("dns_dnsmasq", |
|---|
| 1593 | "1") ? "checked=\"checked\"" : ""); |
|---|
| 1594 | websWrite(wp, "</div>\n<div class=\"setting\">\n"); |
|---|
| 1595 | websWrite(wp, |
|---|
| 1596 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.auth_dnsmasq)</script></div>\n"); |
|---|
| 1597 | websWrite(wp, |
|---|
| 1598 | "<input type=\"checkbox\" name=\"_auth_dnsmasq\" value=\"1\" %s />\n", |
|---|
| 1599 | nvram_match("auth_dnsmasq", |
|---|
| 1600 | "1") ? "checked=\"checked\"" : ""); |
|---|
| 1601 | websWrite(wp, "</div>\n"); |
|---|
| 1602 | } |
|---|
| 1603 | |
|---|
| 1604 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 1605 | return; |
|---|
| 1606 | } |
|---|
| 1607 | |
|---|
| 1608 | #ifdef HAVE_MADWIFI |
|---|
| 1609 | void ej_show_wifiselect(webs_t wp, int argc, char_t ** argv) |
|---|
| 1610 | { |
|---|
| 1611 | char *next; |
|---|
| 1612 | char var[32]; |
|---|
| 1613 | int count = getifcount("wifi"); |
|---|
| 1614 | |
|---|
| 1615 | if (count < 2) |
|---|
| 1616 | return; |
|---|
| 1617 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1618 | websWrite(wp, |
|---|
| 1619 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.intrface)</script></div>\n"); |
|---|
| 1620 | websWrite(wp, |
|---|
| 1621 | "<select name=\"wifi_display\" onchange=\"refresh(this.form)\">\n"); |
|---|
| 1622 | int i; |
|---|
| 1623 | |
|---|
| 1624 | for (i = 0; i < count; i++) { |
|---|
| 1625 | sprintf(var, "ath%d", i); |
|---|
| 1626 | websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 1627 | var, nvram_match("wifi_display", |
|---|
| 1628 | var) ? "selected=\"selected\"" : "", |
|---|
| 1629 | var); |
|---|
| 1630 | char *names = nvram_nget("ath%d_vifs", i); |
|---|
| 1631 | |
|---|
| 1632 | foreach(var, names, next) { |
|---|
| 1633 | websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 1634 | var, nvram_match("wifi_display", |
|---|
| 1635 | var) ? |
|---|
| 1636 | "selected=\"selected\"" : "", var); |
|---|
| 1637 | } |
|---|
| 1638 | } |
|---|
| 1639 | websWrite(wp, "</select>\n"); |
|---|
| 1640 | websWrite(wp, "</div>\n"); |
|---|
| 1641 | |
|---|
| 1642 | } |
|---|
| 1643 | #else |
|---|
| 1644 | void ej_show_wifiselect(webs_t wp, int argc, char_t ** argv) |
|---|
| 1645 | { |
|---|
| 1646 | char *next; |
|---|
| 1647 | char var[32]; |
|---|
| 1648 | int count = get_wl_instances(); |
|---|
| 1649 | |
|---|
| 1650 | if (count < 2) |
|---|
| 1651 | return; |
|---|
| 1652 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1653 | websWrite(wp, |
|---|
| 1654 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.intrface)</script></div>\n"); |
|---|
| 1655 | websWrite(wp, |
|---|
| 1656 | "<select name=\"wifi_display\" onchange=\"refresh(this.form)\">\n"); |
|---|
| 1657 | int i; |
|---|
| 1658 | |
|---|
| 1659 | for (i = 0; i < count; i++) { |
|---|
| 1660 | sprintf(var, "wl%d", i); |
|---|
| 1661 | websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 1662 | var, nvram_match("wifi_display", |
|---|
| 1663 | var) ? "selected=\"selected\"" : "", |
|---|
| 1664 | var); |
|---|
| 1665 | } |
|---|
| 1666 | websWrite(wp, "</select>\n"); |
|---|
| 1667 | websWrite(wp, "</div>\n"); |
|---|
| 1668 | } |
|---|
| 1669 | |
|---|
| 1670 | #endif |
|---|
| 1671 | #if 0 |
|---|
| 1672 | static void showOption(webs_t wp, char *propname, char *nvname) |
|---|
| 1673 | { |
|---|
| 1674 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1675 | websWrite(wp, |
|---|
| 1676 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n<select name=\"%s\">\n", |
|---|
| 1677 | propname, nvname); |
|---|
| 1678 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1679 | websWrite(wp, |
|---|
| 1680 | "document.write(\"<option value=\\\"0\\\" %s >\" + share.disabled + \"</option>\");\n", |
|---|
| 1681 | nvram_default_match(nvname, "0", |
|---|
| 1682 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1683 | websWrite(wp, |
|---|
| 1684 | "document.write(\"<option value=\\\"1\\\" %s >\" + share.enabled + \"</option>\");\n", |
|---|
| 1685 | nvram_default_match(nvname, "1", |
|---|
| 1686 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1687 | websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 1688 | |
|---|
| 1689 | } |
|---|
| 1690 | #endif |
|---|
| 1691 | static void showRadio(webs_t wp, char *propname, char *nvname) |
|---|
| 1692 | { |
|---|
| 1693 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1694 | websWrite(wp, |
|---|
| 1695 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n", |
|---|
| 1696 | propname); |
|---|
| 1697 | websWrite(wp, |
|---|
| 1698 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input> \n", |
|---|
| 1699 | nvname, nvram_default_match(nvname, "1", |
|---|
| 1700 | "0") ? "checked=\"checked\"" : |
|---|
| 1701 | ""); |
|---|
| 1702 | websWrite(wp, |
|---|
| 1703 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input> \n", |
|---|
| 1704 | nvname, nvram_default_match(nvname, "0", |
|---|
| 1705 | "0") ? "checked=\"checked\"" : |
|---|
| 1706 | ""); |
|---|
| 1707 | websWrite(wp, "</div>\n"); |
|---|
| 1708 | } |
|---|
| 1709 | |
|---|
| 1710 | #ifdef HAVE_MADWIFI |
|---|
| 1711 | static void showAutoOption(webs_t wp, char *propname, char *nvname) |
|---|
| 1712 | { |
|---|
| 1713 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1714 | websWrite(wp, |
|---|
| 1715 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n<select name=\"%s\">\n", |
|---|
| 1716 | propname, nvname); |
|---|
| 1717 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1718 | websWrite(wp, |
|---|
| 1719 | "document.write(\"<option value=\\\"-1\\\" %s >\" + share.auto + \"</option>\");\n", |
|---|
| 1720 | nvram_default_match(nvname, "0", |
|---|
| 1721 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1722 | websWrite(wp, |
|---|
| 1723 | "document.write(\"<option value=\\\"1\\\" %s >\" + share.enabled + \"</option>\");\n", |
|---|
| 1724 | nvram_default_match(nvname, "1", |
|---|
| 1725 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1726 | websWrite(wp, |
|---|
| 1727 | "document.write(\"<option value=\\\"0\\\" %s >\" + share.disabled + \"</option>\");\n", |
|---|
| 1728 | nvram_default_match(nvname, "0", |
|---|
| 1729 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1730 | websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 1731 | |
|---|
| 1732 | } |
|---|
| 1733 | #endif |
|---|
| 1734 | |
|---|
| 1735 | static void showOptions(webs_t wp, char *propname, char *names, char *select) |
|---|
| 1736 | { |
|---|
| 1737 | char *next; |
|---|
| 1738 | char var[80]; |
|---|
| 1739 | |
|---|
| 1740 | websWrite(wp, "<select name=\"%s\">\n", propname); |
|---|
| 1741 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1742 | foreach(var, names, next) { |
|---|
| 1743 | websWrite(wp, |
|---|
| 1744 | "document.write(\"<option value=\\\"%s\\\" %s >%s</option>\");\n", |
|---|
| 1745 | var, !strcmp(var, |
|---|
| 1746 | select) ? "selected=\\\"selected\\\"" : |
|---|
| 1747 | "", var); |
|---|
| 1748 | } |
|---|
| 1749 | websWrite(wp, "//]]>\n</script>\n</select>\n"); |
|---|
| 1750 | } |
|---|
| 1751 | |
|---|
| 1752 | static void |
|---|
| 1753 | showOptionsChoose(webs_t wp, char *propname, char *names, char *select) |
|---|
| 1754 | { |
|---|
| 1755 | char *next; |
|---|
| 1756 | char var[80]; |
|---|
| 1757 | |
|---|
| 1758 | websWrite(wp, "<select name=\"%s\">\n", propname); |
|---|
| 1759 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1760 | websWrite(wp, |
|---|
| 1761 | "document.write(\"<option value=\\\"null\\\" >Please choose...</option>\");\n"); |
|---|
| 1762 | foreach(var, names, next) { |
|---|
| 1763 | websWrite(wp, |
|---|
| 1764 | "document.write(\"<option value=\\\"%s\\\" %s >%s</option>\");\n", |
|---|
| 1765 | var, !strcmp(var, |
|---|
| 1766 | select) ? "selected=\\\"selected\\\"" : |
|---|
| 1767 | "", var); |
|---|
| 1768 | } |
|---|
| 1769 | websWrite(wp, "//]]>\n</script>\n</select>\n"); |
|---|
| 1770 | } |
|---|
| 1771 | |
|---|
| 1772 | static void |
|---|
| 1773 | showOptionsLabel(webs_t wp, char *labelname, char *propname, char *names, |
|---|
| 1774 | char *select) |
|---|
| 1775 | { |
|---|
| 1776 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1777 | websWrite(wp, |
|---|
| 1778 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>", |
|---|
| 1779 | labelname); |
|---|
| 1780 | showOptions(wp, propname, names, select); |
|---|
| 1781 | websWrite(wp, "</div>\n"); |
|---|
| 1782 | |
|---|
| 1783 | } |
|---|
| 1784 | |
|---|
| 1785 | void |
|---|
| 1786 | show_inputlabel(webs_t wp, char *labelname, char *propertyname, |
|---|
| 1787 | int propertysize, char *inputclassname, int inputmaxlength) |
|---|
| 1788 | { |
|---|
| 1789 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1790 | websWrite(wp, |
|---|
| 1791 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>", |
|---|
| 1792 | labelname); |
|---|
| 1793 | websWrite(wp, |
|---|
| 1794 | "<input class=\"%s\" size=\"%d\" maxlength=\"%d\" name=\"%s\" value=\"%s\" />\n", |
|---|
| 1795 | inputclassname, propertysize, inputmaxlength, propertyname, |
|---|
| 1796 | nvram_safe_get(propertyname)); |
|---|
| 1797 | websWrite(wp, "</div>\n"); |
|---|
| 1798 | } |
|---|
| 1799 | |
|---|
| 1800 | void |
|---|
| 1801 | show_custominputlabel(webs_t wp, char *labelname, char *propertyname, |
|---|
| 1802 | char *property, int propertysize) |
|---|
| 1803 | { |
|---|
| 1804 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1805 | websWrite(wp, "<div class=\"label\">%s</div>", labelname); |
|---|
| 1806 | websWrite(wp, "<input size=\"%d\" name=\"%s\" value=\"%s\" />\n", |
|---|
| 1807 | propertysize, propertyname, property); |
|---|
| 1808 | websWrite(wp, "</div>\n"); |
|---|
| 1809 | } |
|---|
| 1810 | |
|---|
| 1811 | #ifdef HAVE_USB |
|---|
| 1812 | void ej_show_usb_diskinfo(webs_t wp, int argc, char_t ** argv) |
|---|
| 1813 | { |
|---|
| 1814 | char buff[512]; |
|---|
| 1815 | FILE *fp; |
|---|
| 1816 | |
|---|
| 1817 | if (!nvram_match("usb_automnt", "1")) |
|---|
| 1818 | return; |
|---|
| 1819 | |
|---|
| 1820 | if ((fp = fopen("/tmp/disktype.dump", "r"))) { |
|---|
| 1821 | while (fgets(buff, sizeof(buff), fp)) { |
|---|
| 1822 | if (strcmp(buff, "\n")) |
|---|
| 1823 | websWrite(wp, "%s<br />", buff); |
|---|
| 1824 | } |
|---|
| 1825 | fclose(fp); |
|---|
| 1826 | } else |
|---|
| 1827 | websWrite(wp, "%s", live_translate("status_router.notavail")); |
|---|
| 1828 | |
|---|
| 1829 | return; |
|---|
| 1830 | } |
|---|
| 1831 | #endif |
|---|
| 1832 | |
|---|
| 1833 | void show_legend(webs_t wp, char *labelname, int translate) |
|---|
| 1834 | { |
|---|
| 1835 | /* |
|---|
| 1836 | * char buf[2]; sprintf(buf,"%d",translate); websWrite (wp, |
|---|
| 1837 | * "<legend>%s%s%s</legend>\n", !strcmp (buf, "1") ? "<script |
|---|
| 1838 | * type=\"text/javascript\">Capture(" : "", labelname, !strcmp (buf, "1") |
|---|
| 1839 | * ? ")</script>" : ""); |
|---|
| 1840 | */ |
|---|
| 1841 | if (translate) |
|---|
| 1842 | websWrite(wp, |
|---|
| 1843 | "<legend><script type=\"text/javascript\">Capture(%s)</script></legend>\n", |
|---|
| 1844 | labelname); |
|---|
| 1845 | else |
|---|
| 1846 | websWrite(wp, "<legend>%s</legend>\n", labelname); |
|---|
| 1847 | |
|---|
| 1848 | } |
|---|
| 1849 | |
|---|
| 1850 | #ifdef HAVE_OLSRD |
|---|
| 1851 | |
|---|
| 1852 | void ej_show_olsrd(webs_t wp, int argc, char_t ** argv) |
|---|
| 1853 | { |
|---|
| 1854 | char *var = websGetVar(wp, "wk_mode", NULL); |
|---|
| 1855 | |
|---|
| 1856 | if (var == NULL) |
|---|
| 1857 | var = nvram_safe_get("wk_mode"); |
|---|
| 1858 | if (!strcmp(var, "olsr")) { |
|---|
| 1859 | websWrite(wp, "<fieldset>\n"); |
|---|
| 1860 | show_legend(wp, "route.olsrd_legend", 1); |
|---|
| 1861 | show_inputlabel(wp, "route.olsrd_hna", "olsrd_hna", 32, "num", |
|---|
| 1862 | 32); |
|---|
| 1863 | show_inputlabel(wp, "route.olsrd_poll", "olsrd_pollsize", 5, |
|---|
| 1864 | "num", 5); |
|---|
| 1865 | showOptionsLabel(wp, "route.olsrd_tc", "olsrd_redundancy", |
|---|
| 1866 | "0 1 2", nvram_default_get("olsrd_redundancy", |
|---|
| 1867 | "2")); |
|---|
| 1868 | show_inputlabel(wp, "route.olsrd_mpr", "olsrd_coverage", 5, |
|---|
| 1869 | "num", 5); |
|---|
| 1870 | showRadio(wp, "route.olsrd_lqfe", "olsrd_lqfisheye"); |
|---|
| 1871 | show_inputlabel(wp, "route.olsrd_lqag", "olsrd_lqaging", 5, |
|---|
| 1872 | "num", 5); |
|---|
| 1873 | |
|---|
| 1874 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1875 | websWrite(wp, |
|---|
| 1876 | "<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_lqdmin)</script></div>"); |
|---|
| 1877 | websWrite(wp, |
|---|
| 1878 | "<input class=\"num\" size=\"5\" maxlength=\"5\" name=\"olsrd_lqdijkstramin\" onblur=\"olsrd_checkDijkstra(this.form)\" value=\"%s\" />\n", |
|---|
| 1879 | nvram_safe_get("olsrd_lqdijkstramin")); |
|---|
| 1880 | websWrite(wp, "</div>\n"); |
|---|
| 1881 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1882 | websWrite(wp, |
|---|
| 1883 | "<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_lqdmax)</script></div>"); |
|---|
| 1884 | websWrite(wp, |
|---|
| 1885 | "<input class=\"num\" size=\"5\" maxlength=\"5\" name=\"olsrd_lqdijkstramax\" onblur=\"olsrd_checkDijkstra(this.form)\" value=\"%s\" />\n", |
|---|
| 1886 | nvram_safe_get("olsrd_lqdijkstramax")); |
|---|
| 1887 | websWrite(wp, "</div>\n"); |
|---|
| 1888 | |
|---|
| 1889 | showOptionsLabel(wp, "route.olsrd_lqlvl", "olsrd_lqlevel", |
|---|
| 1890 | "0 1 2", nvram_default_get("olsrd_lqlevel", |
|---|
| 1891 | "2")); |
|---|
| 1892 | showRadio(wp, "route.olsrd_hysteresis", "olsrd_hysteresis"); |
|---|
| 1893 | char *wordlist = nvram_safe_get("olsrd_interfaces"); |
|---|
| 1894 | char *next; |
|---|
| 1895 | char word[128]; |
|---|
| 1896 | int count = 0; |
|---|
| 1897 | |
|---|
| 1898 | foreach(word, wordlist, next) { |
|---|
| 1899 | char *interface = word; |
|---|
| 1900 | char *hellointerval = interface; |
|---|
| 1901 | |
|---|
| 1902 | strsep(&hellointerval, ">"); |
|---|
| 1903 | char *hellovaliditytime = hellointerval; |
|---|
| 1904 | |
|---|
| 1905 | strsep(&hellovaliditytime, ">"); |
|---|
| 1906 | char *tcinterval = hellovaliditytime; |
|---|
| 1907 | |
|---|
| 1908 | strsep(&tcinterval, ">"); |
|---|
| 1909 | char *tcvaliditytime = tcinterval; |
|---|
| 1910 | |
|---|
| 1911 | strsep(&tcvaliditytime, ">"); |
|---|
| 1912 | char *midinterval = tcvaliditytime; |
|---|
| 1913 | |
|---|
| 1914 | strsep(&midinterval, ">"); |
|---|
| 1915 | char *midvaliditytime = midinterval; |
|---|
| 1916 | |
|---|
| 1917 | strsep(&midvaliditytime, ">"); |
|---|
| 1918 | char *hnainterval = midvaliditytime; |
|---|
| 1919 | |
|---|
| 1920 | strsep(&hnainterval, ">"); |
|---|
| 1921 | char *hnavaliditytime = hnainterval; |
|---|
| 1922 | |
|---|
| 1923 | strsep(&hnavaliditytime, ">"); |
|---|
| 1924 | websWrite(wp, "<fieldset>\n"); |
|---|
| 1925 | show_legend(wp, interface, 0); |
|---|
| 1926 | char valuename[32]; |
|---|
| 1927 | |
|---|
| 1928 | sprintf(valuename, "%s_hellointerval", interface); |
|---|
| 1929 | show_custominputlabel(wp, "Hello Interval", valuename, |
|---|
| 1930 | hellointerval, 5); |
|---|
| 1931 | sprintf(valuename, "%s_hellovaliditytime", interface); |
|---|
| 1932 | show_custominputlabel(wp, "Hello Validity Time", |
|---|
| 1933 | valuename, hellovaliditytime, 5); |
|---|
| 1934 | |
|---|
| 1935 | sprintf(valuename, "%s_tcinterval", interface); |
|---|
| 1936 | show_custominputlabel(wp, "TC Interval", valuename, |
|---|
| 1937 | tcinterval, 5); |
|---|
| 1938 | sprintf(valuename, "%s_tcvaliditytime", interface); |
|---|
| 1939 | show_custominputlabel(wp, "TC Validity Time", valuename, |
|---|
| 1940 | tcvaliditytime, 5); |
|---|
| 1941 | |
|---|
| 1942 | sprintf(valuename, "%s_midinterval", interface); |
|---|
| 1943 | show_custominputlabel(wp, "MID Interval", valuename, |
|---|
| 1944 | midinterval, 5); |
|---|
| 1945 | sprintf(valuename, "%s_midvaliditytime", interface); |
|---|
| 1946 | show_custominputlabel(wp, "MID Validity Time", |
|---|
| 1947 | valuename, midvaliditytime, 5); |
|---|
| 1948 | |
|---|
| 1949 | sprintf(valuename, "%s_hnainterval", interface); |
|---|
| 1950 | show_custominputlabel(wp, "HNA Interval", valuename, |
|---|
| 1951 | hnainterval, 5); |
|---|
| 1952 | sprintf(valuename, "%s_hnavaliditytime", interface); |
|---|
| 1953 | show_custominputlabel(wp, "HNA Validity Time", |
|---|
| 1954 | valuename, hnavaliditytime, 5); |
|---|
| 1955 | websWrite(wp, |
|---|
| 1956 | "<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", |
|---|
| 1957 | count); |
|---|
| 1958 | |
|---|
| 1959 | websWrite(wp, "</fieldset>\n"); |
|---|
| 1960 | count++; |
|---|
| 1961 | } |
|---|
| 1962 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1963 | websWrite(wp, |
|---|
| 1964 | "<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_newiface)</script></div>\n"); |
|---|
| 1965 | char buffer[256]; |
|---|
| 1966 | |
|---|
| 1967 | memset(buffer, 0, 256); |
|---|
| 1968 | getIfList(buffer, NULL); |
|---|
| 1969 | showOptions(wp, "olsrd_ifname", buffer, ""); |
|---|
| 1970 | websWrite(wp, " "); |
|---|
| 1971 | websWrite(wp, |
|---|
| 1972 | "<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"); |
|---|
| 1973 | websWrite(wp, "</div>\n"); |
|---|
| 1974 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 1975 | } |
|---|
| 1976 | } |
|---|
| 1977 | #else //!HAVE_OLSRD |
|---|
| 1978 | void ej_show_olsrd(webs_t wp, int argc, char_t ** argv) |
|---|
| 1979 | { |
|---|
| 1980 | return; |
|---|
| 1981 | } |
|---|
| 1982 | #endif |
|---|
| 1983 | |
|---|
| 1984 | #ifdef HAVE_VLANTAGGING |
|---|
| 1985 | #ifdef HAVE_BONDING |
|---|
| 1986 | |
|---|
| 1987 | void ej_show_bondings(webs_t wp, int argc, char_t ** argv) |
|---|
| 1988 | { |
|---|
| 1989 | char buffer[256]; |
|---|
| 1990 | char bufferif[512]; |
|---|
| 1991 | char bondnames[256]; |
|---|
| 1992 | int count = 0; |
|---|
| 1993 | static char word[256]; |
|---|
| 1994 | char *next, *wordlist; |
|---|
| 1995 | |
|---|
| 1996 | memset(buffer, 0, 256); |
|---|
| 1997 | memset(bondnames, 0, 256); |
|---|
| 1998 | memset(bufferif, 0, 512); |
|---|
| 1999 | websWrite(wp, "<h2>Bonding</h2>\n"); |
|---|
| 2000 | websWrite(wp, "<fieldset>\n"); |
|---|
| 2001 | websWrite(wp, "<legend>Bonding</legend>\n"); |
|---|
| 2002 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2003 | websWrite(wp, "<div class=\"label\">Bonding Type</div>\n", count); |
|---|
| 2004 | showOptions(wp, "bonding_type", |
|---|
| 2005 | "balance-rr active-backup balance-xor broadcast 802.3ad balance-tlb balance-alb weighted-rr duplex", |
|---|
| 2006 | nvram_default_get("bonding_type", "balance-rr")); |
|---|
| 2007 | websWrite(wp, " Bonding Interfaces "); |
|---|
| 2008 | websWrite(wp, |
|---|
| 2009 | "<input class=\"num\" name=\"bonding_number\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2010 | nvram_default_get("bonding_number", "1")); |
|---|
| 2011 | websWrite(wp, "</div>\n"); |
|---|
| 2012 | |
|---|
| 2013 | getIfList(bufferif, "eth"); |
|---|
| 2014 | int i; |
|---|
| 2015 | |
|---|
| 2016 | #ifdef HAVE_XSCALE |
|---|
| 2017 | memset(buffer, 0, 256); |
|---|
| 2018 | getIfList(buffer, "ixp"); |
|---|
| 2019 | sprintf(bufferif, "%s %s", bufferif, buffer); |
|---|
| 2020 | #endif |
|---|
| 2021 | memset(buffer, 0, 256); |
|---|
| 2022 | getIfList(buffer, "br"); |
|---|
| 2023 | sprintf(bufferif, "%s %s", bufferif, buffer); |
|---|
| 2024 | #ifdef HAVE_MADWIFI |
|---|
| 2025 | int c = getifcount("wifi"); |
|---|
| 2026 | |
|---|
| 2027 | for (i = 0; i < c; i++) { |
|---|
| 2028 | char ath[32]; |
|---|
| 2029 | |
|---|
| 2030 | sprintf(ath, "ath%d_bridged", i); |
|---|
| 2031 | if (nvram_default_match(ath, "0", "1")) { |
|---|
| 2032 | sprintf(bufferif, "%s ath%d", bufferif, i); |
|---|
| 2033 | char vifs[32]; |
|---|
| 2034 | |
|---|
| 2035 | sprintf(vifs, "ath%d_vifs", i); |
|---|
| 2036 | sprintf(bufferif, "%s %s", bufferif, |
|---|
| 2037 | nvram_safe_get(vifs)); |
|---|
| 2038 | } |
|---|
| 2039 | } |
|---|
| 2040 | #endif |
|---|
| 2041 | |
|---|
| 2042 | for (i = 0; i < atoi(nvram_safe_get("bonding_number")); i++) { |
|---|
| 2043 | sprintf(bondnames, "%s bond%d", bondnames, i); |
|---|
| 2044 | } |
|---|
| 2045 | int totalcount = 0; |
|---|
| 2046 | int realcount = atoi(nvram_default_get("bonding_count", "0")); |
|---|
| 2047 | |
|---|
| 2048 | wordlist = nvram_safe_get("bondings"); |
|---|
| 2049 | foreach(word, wordlist, next) { |
|---|
| 2050 | char *port = word; |
|---|
| 2051 | char *tag = strsep(&port, ">"); |
|---|
| 2052 | |
|---|
| 2053 | if (!tag || !port) |
|---|
| 2054 | break; |
|---|
| 2055 | char vlan_name[32]; |
|---|
| 2056 | |
|---|
| 2057 | // sprintf (vlan_name, "%s.%s", tag, port); |
|---|
| 2058 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2059 | websWrite(wp, |
|---|
| 2060 | "<div class=\"label\">Bonding %d Assignment</div>\n", |
|---|
| 2061 | count); |
|---|
| 2062 | websWrite(wp, " Bond "); |
|---|
| 2063 | sprintf(vlan_name, "bondingifname%d", count); |
|---|
| 2064 | showOptions(wp, vlan_name, bondnames, tag); |
|---|
| 2065 | sprintf(vlan_name, "bondingattach%d", count); |
|---|
| 2066 | websWrite(wp, " Slave "); |
|---|
| 2067 | showOptions(wp, vlan_name, bufferif, port); |
|---|
| 2068 | websWrite(wp, |
|---|
| 2069 | "<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", |
|---|
| 2070 | count); |
|---|
| 2071 | websWrite(wp, "</div>\n"); |
|---|
| 2072 | count++; |
|---|
| 2073 | } |
|---|
| 2074 | totalcount = count; |
|---|
| 2075 | for (i = count; i < realcount; i++) { |
|---|
| 2076 | char vlan_name[32]; |
|---|
| 2077 | |
|---|
| 2078 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2079 | websWrite(wp, |
|---|
| 2080 | "<div class=\"label\">Bonding %d Interface</div>\n", |
|---|
| 2081 | i); |
|---|
| 2082 | websWrite(wp, " Bond "); |
|---|
| 2083 | sprintf(vlan_name, "bondingifname%d", i); |
|---|
| 2084 | showOptions(wp, vlan_name, bondnames, ""); |
|---|
| 2085 | sprintf(vlan_name, "bondingattach%d", i); |
|---|
| 2086 | websWrite(wp, " Slave "); |
|---|
| 2087 | showOptions(wp, vlan_name, bufferif, ""); |
|---|
| 2088 | websWrite(wp, |
|---|
| 2089 | "<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", |
|---|
| 2090 | i); |
|---|
| 2091 | websWrite(wp, "</div>\n"); |
|---|
| 2092 | totalcount++; |
|---|
| 2093 | } |
|---|
| 2094 | char var[32]; |
|---|
| 2095 | |
|---|
| 2096 | sprintf(var, "%d", totalcount); |
|---|
| 2097 | nvram_set("bonding_count", var); |
|---|
| 2098 | websWrite(wp, |
|---|
| 2099 | "<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"); |
|---|
| 2100 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 2101 | } |
|---|
| 2102 | #else //!HAVE_BONDING |
|---|
| 2103 | void ej_show_bondings(webs_t wp, int argc, char_t ** argv) |
|---|
| 2104 | { |
|---|
| 2105 | return; |
|---|
| 2106 | } |
|---|
| 2107 | #endif |
|---|
| 2108 | |
|---|
| 2109 | void ej_show_vlantagging(webs_t wp, int argc, char_t ** argv) |
|---|
| 2110 | { |
|---|
| 2111 | char buffer[256]; |
|---|
| 2112 | int count = 0; |
|---|
| 2113 | static char word[256]; |
|---|
| 2114 | char *next, *wordlist; |
|---|
| 2115 | |
|---|
| 2116 | memset(buffer, 0, 256); |
|---|
| 2117 | getIfList(buffer, NULL); |
|---|
| 2118 | int totalcount = 0; |
|---|
| 2119 | int realcount = atoi(nvram_default_get("vlan_tagcount", "0")); |
|---|
| 2120 | |
|---|
| 2121 | wordlist = nvram_safe_get("vlan_tags"); |
|---|
| 2122 | foreach(word, wordlist, next) { |
|---|
| 2123 | char *port = word; |
|---|
| 2124 | char *tag = strsep(&port, ">"); |
|---|
| 2125 | |
|---|
| 2126 | if (!tag || !port) |
|---|
| 2127 | break; |
|---|
| 2128 | char vlan_name[32]; |
|---|
| 2129 | |
|---|
| 2130 | // sprintf (vlan_name, "%s.%s", tag, port); |
|---|
| 2131 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2132 | websWrite(wp, "<div class=\"label\">VLAN%d Interface</div>\n", |
|---|
| 2133 | count); |
|---|
| 2134 | sprintf(vlan_name, "vlanifname%d", count); |
|---|
| 2135 | showOptions(wp, vlan_name, buffer, tag); |
|---|
| 2136 | sprintf(vlan_name, "vlantag%d", count); |
|---|
| 2137 | websWrite(wp, " Tag Number "); |
|---|
| 2138 | websWrite(wp, |
|---|
| 2139 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2140 | vlan_name, port); |
|---|
| 2141 | websWrite(wp, |
|---|
| 2142 | "<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", |
|---|
| 2143 | count); |
|---|
| 2144 | websWrite(wp, "</div>\n"); |
|---|
| 2145 | count++; |
|---|
| 2146 | } |
|---|
| 2147 | totalcount = count; |
|---|
| 2148 | int i; |
|---|
| 2149 | |
|---|
| 2150 | for (i = count; i < realcount; i++) { |
|---|
| 2151 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2152 | websWrite(wp, "<div class=\"label\">VLAN%d Interface</div>\n", |
|---|
| 2153 | i); |
|---|
| 2154 | char vlan_name[32]; |
|---|
| 2155 | |
|---|
| 2156 | sprintf(vlan_name, "vlanifname%d", i); |
|---|
| 2157 | showOptions(wp, vlan_name, buffer, ""); |
|---|
| 2158 | sprintf(vlan_name, "vlantag%d", i); |
|---|
| 2159 | websWrite(wp, " Tag Number "); |
|---|
| 2160 | websWrite(wp, |
|---|
| 2161 | "<input class=\"num\" name=\"%s\" size=\"5\" value=\"0\" />\n", |
|---|
| 2162 | vlan_name); |
|---|
| 2163 | websWrite(wp, |
|---|
| 2164 | "<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", |
|---|
| 2165 | i); |
|---|
| 2166 | websWrite(wp, "</div>\n"); |
|---|
| 2167 | totalcount++; |
|---|
| 2168 | } |
|---|
| 2169 | char var[32]; |
|---|
| 2170 | |
|---|
| 2171 | sprintf(var, "%d", totalcount); |
|---|
| 2172 | nvram_set("vlan_tagcount", var); |
|---|
| 2173 | websWrite(wp, |
|---|
| 2174 | "<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"); |
|---|
| 2175 | } |
|---|
| 2176 | |
|---|
| 2177 | void ej_show_mdhcp(webs_t wp, int argc, char_t ** argv) |
|---|
| 2178 | { |
|---|
| 2179 | char buffer[256]; |
|---|
| 2180 | int count = 0; |
|---|
| 2181 | static char word[256]; |
|---|
| 2182 | char *next, *wordlist; |
|---|
| 2183 | |
|---|
| 2184 | websWrite(wp, "<h2>%s</h2>\n<fieldset>\n", |
|---|
| 2185 | live_translate("networking.h5")); |
|---|
| 2186 | websWrite(wp, "<legend>%s</legend>\n", |
|---|
| 2187 | live_translate("networking.legend5")); |
|---|
| 2188 | |
|---|
| 2189 | memset(buffer, 0, 256); |
|---|
| 2190 | getIfList(buffer, NULL); |
|---|
| 2191 | int totalcount = 0; |
|---|
| 2192 | int realcount = atoi(nvram_default_get("mdhcpd_count", "0")); |
|---|
| 2193 | |
|---|
| 2194 | wordlist = nvram_safe_get("mdhcpd"); |
|---|
| 2195 | foreach(word, wordlist, next) { |
|---|
| 2196 | char *interface = word; |
|---|
| 2197 | char *dhcpon = interface; |
|---|
| 2198 | |
|---|
| 2199 | interface = strsep(&dhcpon, ">"); |
|---|
| 2200 | char *start = dhcpon; |
|---|
| 2201 | |
|---|
| 2202 | dhcpon = strsep(&start, ">"); |
|---|
| 2203 | char *max = start; |
|---|
| 2204 | |
|---|
| 2205 | start = strsep(&max, ">"); |
|---|
| 2206 | char *leasetime = max; |
|---|
| 2207 | |
|---|
| 2208 | max = strsep(&leasetime, ">"); |
|---|
| 2209 | if (!interface || !start || !dhcpon || !max || !leasetime) |
|---|
| 2210 | break; |
|---|
| 2211 | char vlan_name[32]; |
|---|
| 2212 | |
|---|
| 2213 | // interface |
|---|
| 2214 | char *ipaddr = nvram_nget("%s_ipaddr", interface); |
|---|
| 2215 | char *netmask = nvram_nget("%s_netmask", interface); |
|---|
| 2216 | |
|---|
| 2217 | if (strlen(ipaddr) > 0 && strlen(netmask) > 0) { |
|---|
| 2218 | websWrite(wp, "Interface %s: IP %s/%s\n", interface, |
|---|
| 2219 | ipaddr, netmask); |
|---|
| 2220 | } |
|---|
| 2221 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2222 | websWrite(wp, "<div class=\"label\">DHCP %d</div>\n", count); |
|---|
| 2223 | sprintf(vlan_name, "mdhcpifname%d", count); |
|---|
| 2224 | showOptions(wp, vlan_name, buffer, interface); |
|---|
| 2225 | // on off |
|---|
| 2226 | sprintf(vlan_name, "mdhcpon%d", count); |
|---|
| 2227 | showOptions(wp, vlan_name, "On Off", dhcpon); |
|---|
| 2228 | // start |
|---|
| 2229 | sprintf(vlan_name, "mdhcpstart%d", count); |
|---|
| 2230 | websWrite(wp, " Start "); |
|---|
| 2231 | websWrite(wp, |
|---|
| 2232 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2233 | vlan_name, start); |
|---|
| 2234 | // max |
|---|
| 2235 | sprintf(vlan_name, "mdhcpmax%d", count); |
|---|
| 2236 | websWrite(wp, " Max "); |
|---|
| 2237 | websWrite(wp, |
|---|
| 2238 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2239 | vlan_name, max); |
|---|
| 2240 | sprintf(vlan_name, "mdhcpleasetime%d", count); |
|---|
| 2241 | websWrite(wp, " Leasetime "); |
|---|
| 2242 | websWrite(wp, |
|---|
| 2243 | "<input class=\"num\" name=\"%s\" size=\"5\" value=\"%s\" />\n", |
|---|
| 2244 | vlan_name, leasetime); |
|---|
| 2245 | // |
|---|
| 2246 | websWrite(wp, |
|---|
| 2247 | "<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", |
|---|
| 2248 | count); |
|---|
| 2249 | websWrite(wp, "</div>\n"); |
|---|
| 2250 | count++; |
|---|
| 2251 | } |
|---|
| 2252 | totalcount = count; |
|---|
| 2253 | int i; |
|---|
| 2254 | |
|---|
| 2255 | for (i = count; i < realcount; i++) { |
|---|
| 2256 | char vlan_name[32]; |
|---|
| 2257 | |
|---|
| 2258 | // sprintf (mdhcp_name, "%s.%s", tag, port); |
|---|
| 2259 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2260 | websWrite(wp, "<div class=\"label\">DHCP %d</div>\n", count); |
|---|
| 2261 | // interface |
|---|
| 2262 | sprintf(vlan_name, "mdhcpifname%d", count); |
|---|
| 2263 | showOptions(wp, vlan_name, buffer, ""); |
|---|
| 2264 | // on off |
|---|
| 2265 | sprintf(vlan_name, "mdhcpon%d", count); |
|---|
| 2266 | showOptions(wp, vlan_name, "On Off", ""); |
|---|
| 2267 | // start |
|---|
| 2268 | sprintf(vlan_name, "mdhcpstart%d", count); |
|---|
| 2269 | websWrite(wp, " Start "); |
|---|
| 2270 | websWrite(wp, |
|---|
| 2271 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2272 | vlan_name, "100"); |
|---|
| 2273 | // max |
|---|
| 2274 | sprintf(vlan_name, "mdhcpmax%d", count); |
|---|
| 2275 | websWrite(wp, " Max "); |
|---|
| 2276 | websWrite(wp, |
|---|
| 2277 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2278 | vlan_name, "50"); |
|---|
| 2279 | sprintf(vlan_name, "mdhcpleasetime%d", count); |
|---|
| 2280 | websWrite(wp, " Leasetime "); |
|---|
| 2281 | websWrite(wp, |
|---|
| 2282 | "<input class=\"num\" name=\"%s\" size=\"5\" value=\"%s\" />\n", |
|---|
| 2283 | vlan_name, "3600"); |
|---|
| 2284 | websWrite(wp, |
|---|
| 2285 | "<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", |
|---|
| 2286 | i); |
|---|
| 2287 | websWrite(wp, "</div>\n"); |
|---|
| 2288 | totalcount++; |
|---|
| 2289 | } |
|---|
| 2290 | char var[32]; |
|---|
| 2291 | |
|---|
| 2292 | sprintf(var, "%d", totalcount); |
|---|
| 2293 | nvram_set("mdhcpd_count", var); |
|---|
| 2294 | websWrite(wp, |
|---|
| 2295 | "<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"); |
|---|
| 2296 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 2297 | |
|---|
| 2298 | } |
|---|
| 2299 | |
|---|
| 2300 | void ej_show_bridgenames(webs_t wp, int argc, char_t ** argv) |
|---|
| 2301 | { |
|---|
| 2302 | char buffer[256]; |
|---|
| 2303 | int count = 0; |
|---|
| 2304 | static char word[256]; |
|---|
| 2305 | char *next, *wordlist; |
|---|
| 2306 | |
|---|
| 2307 | memset(buffer, 0, 256); |
|---|
| 2308 | getIfList(buffer, NULL); |
|---|
| 2309 | int realcount = atoi(nvram_default_get("bridges_count", "0")); |
|---|
| 2310 | |
|---|
| 2311 | wordlist = nvram_safe_get("bridges"); |
|---|
| 2312 | foreach(word, wordlist, next) { |
|---|
| 2313 | |
|---|
| 2314 | char *stp = word; |
|---|
| 2315 | char *bridge = strsep(&stp, ">"); |
|---|
| 2316 | char *prio = stp; |
|---|
| 2317 | |
|---|
| 2318 | stp = strsep(&prio, ">"); |
|---|
| 2319 | char *mtu = prio; |
|---|
| 2320 | |
|---|
| 2321 | prio = strsep(&mtu, ">"); |
|---|
| 2322 | if (!prio) { |
|---|
| 2323 | prio = mtu; |
|---|
| 2324 | mtu = "1500"; |
|---|
| 2325 | } |
|---|
| 2326 | |
|---|
| 2327 | /* char *stp = word; |
|---|
| 2328 | char *bridge = strsep( &stp, ">" ); |
|---|
| 2329 | char *mtu = stp; |
|---|
| 2330 | char *prio = strsep( &mtu, ">" ); |
|---|
| 2331 | */ |
|---|
| 2332 | if (!bridge || !stp) |
|---|
| 2333 | break; |
|---|
| 2334 | |
|---|
| 2335 | char vlan_name[32]; |
|---|
| 2336 | |
|---|
| 2337 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2338 | websWrite(wp, "<div class=\"label\">Bridge %d</div>\n", count); |
|---|
| 2339 | sprintf(vlan_name, "bridgename%d", count); |
|---|
| 2340 | websWrite(wp, |
|---|
| 2341 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2342 | vlan_name, bridge); |
|---|
| 2343 | websWrite(wp, " STP "); |
|---|
| 2344 | sprintf(vlan_name, "bridgestp%d", count); |
|---|
| 2345 | showOptions(wp, vlan_name, "On Off", stp); |
|---|
| 2346 | websWrite(wp, " Prio "); |
|---|
| 2347 | sprintf(vlan_name, "bridgeprio%d", count); |
|---|
| 2348 | websWrite(wp, |
|---|
| 2349 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2350 | vlan_name, prio != NULL ? prio : "32768"); |
|---|
| 2351 | websWrite(wp, " MTU "); |
|---|
| 2352 | sprintf(vlan_name, "bridgemtu%d", count); |
|---|
| 2353 | websWrite(wp, |
|---|
| 2354 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2355 | vlan_name, mtu != NULL ? mtu : "1500"); |
|---|
| 2356 | websWrite(wp, |
|---|
| 2357 | "<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", |
|---|
| 2358 | count); |
|---|
| 2359 | websWrite(wp, "</div>\n"); |
|---|
| 2360 | show_ipnetmask(wp, bridge); |
|---|
| 2361 | count++; |
|---|
| 2362 | } |
|---|
| 2363 | int i; |
|---|
| 2364 | int totalcount = count; |
|---|
| 2365 | |
|---|
| 2366 | for (i = count; i < realcount; i++) { |
|---|
| 2367 | char vlan_name[32]; |
|---|
| 2368 | |
|---|
| 2369 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2370 | websWrite(wp, "<div class=\"label\">Bridge %d</div>\n", i); |
|---|
| 2371 | sprintf(vlan_name, "bridgename%d", i); |
|---|
| 2372 | websWrite(wp, "<input class=\"num\" name=\"%s\"size=\"5\" />\n", |
|---|
| 2373 | vlan_name); |
|---|
| 2374 | websWrite(wp, " STP "); |
|---|
| 2375 | sprintf(vlan_name, "bridgestp%d", i); |
|---|
| 2376 | showOptions(wp, vlan_name, "On Off", "On"); |
|---|
| 2377 | websWrite(wp, " Prio "); |
|---|
| 2378 | sprintf(vlan_name, "bridgeprio%d", i); |
|---|
| 2379 | websWrite(wp, |
|---|
| 2380 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2381 | vlan_name, "32768"); |
|---|
| 2382 | websWrite(wp, " MTU "); |
|---|
| 2383 | sprintf(vlan_name, "bridgemtu%d", count); |
|---|
| 2384 | websWrite(wp, |
|---|
| 2385 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2386 | vlan_name, "1500"); |
|---|
| 2387 | websWrite(wp, |
|---|
| 2388 | "<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", |
|---|
| 2389 | i); |
|---|
| 2390 | websWrite(wp, "</div>\n"); |
|---|
| 2391 | totalcount++; |
|---|
| 2392 | } |
|---|
| 2393 | websWrite(wp, |
|---|
| 2394 | "<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"); |
|---|
| 2395 | char var[32]; |
|---|
| 2396 | |
|---|
| 2397 | sprintf(var, "%d", totalcount); |
|---|
| 2398 | nvram_set("bridges_count", var); |
|---|
| 2399 | } |
|---|
| 2400 | |
|---|
| 2401 | void ej_show_bridgetable(webs_t wp, int argc, char_t ** argv) |
|---|
| 2402 | { |
|---|
| 2403 | //#ifdef HAVE_MICRO // brctl N/A in micro |
|---|
| 2404 | // return; |
|---|
| 2405 | //#endif |
|---|
| 2406 | |
|---|
| 2407 | FILE *f; |
|---|
| 2408 | char buf[128]; |
|---|
| 2409 | char brname[32]; |
|---|
| 2410 | char brstp[8]; |
|---|
| 2411 | char brif[16]; |
|---|
| 2412 | int count = 0; |
|---|
| 2413 | |
|---|
| 2414 | system2("brctl show > /tmp/.brtable"); |
|---|
| 2415 | |
|---|
| 2416 | if ((f = fopen("/tmp/.brtable", "r")) != NULL) { |
|---|
| 2417 | |
|---|
| 2418 | while (fgets(buf, sizeof(buf), f)) { |
|---|
| 2419 | |
|---|
| 2420 | if (count) // skip line 0 |
|---|
| 2421 | { |
|---|
| 2422 | strcpy(brname, ""); |
|---|
| 2423 | strcpy(brstp, ""); |
|---|
| 2424 | strcpy(brif, ""); |
|---|
| 2425 | |
|---|
| 2426 | if (strncmp(buf, "\t\t\t", 3) != 0) { |
|---|
| 2427 | if (count != 1) |
|---|
| 2428 | websWrite(wp, "\',"); // close |
|---|
| 2429 | sscanf(buf, "%s %*s %s %s", brname, |
|---|
| 2430 | brstp, brif); |
|---|
| 2431 | websWrite(wp, "\'%s\',\'%s\',\'%s ", |
|---|
| 2432 | brname, brstp, brif); |
|---|
| 2433 | } else { |
|---|
| 2434 | sscanf(buf, "%s", brif); |
|---|
| 2435 | websWrite(wp, "%s ", brif); |
|---|
| 2436 | } |
|---|
| 2437 | } |
|---|
| 2438 | count++; |
|---|
| 2439 | } |
|---|
| 2440 | |
|---|
| 2441 | websWrite(wp, "\'"); // close |
|---|
| 2442 | fclose(f); |
|---|
| 2443 | unlink("/tmp/.brtable"); |
|---|
| 2444 | } |
|---|
| 2445 | return; |
|---|
| 2446 | } |
|---|
| 2447 | |
|---|
| 2448 | void ej_show_bridgeifnames(webs_t wp, int argc, char_t ** argv) |
|---|
| 2449 | { |
|---|
| 2450 | char bufferif[512]; |
|---|
| 2451 | char bufferif2[256]; |
|---|
| 2452 | char finalbuffer[512]; |
|---|
| 2453 | int count = 0; |
|---|
| 2454 | static char word[256]; |
|---|
| 2455 | char *next, *wordlist; |
|---|
| 2456 | |
|---|
| 2457 | memset(bufferif, 0, 512); |
|---|
| 2458 | memset(bufferif2, 0, 256); |
|---|
| 2459 | getIfList(bufferif, "eth"); |
|---|
| 2460 | #ifdef HAVE_GATEWORX |
|---|
| 2461 | getIfList(bufferif2, "ixp"); |
|---|
| 2462 | sprintf(bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2463 | #endif |
|---|
| 2464 | |
|---|
| 2465 | memset(bufferif2, 0, 256); |
|---|
| 2466 | getIfList(bufferif2, "vlan"); |
|---|
| 2467 | sprintf(bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2468 | |
|---|
| 2469 | memset(bufferif2, 0, 256); |
|---|
| 2470 | getIfList(bufferif2, "wl"); |
|---|
| 2471 | sprintf(bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2472 | |
|---|
| 2473 | memset(bufferif2, 0, 256); |
|---|
| 2474 | getIfList(bufferif2, "ofdm"); |
|---|
| 2475 | sprintf(bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2476 | |
|---|
| 2477 | #ifdef HAVE_RT2880 |
|---|
| 2478 | memset(bufferif2, 0, 256); |
|---|
| 2479 | getIfList(bufferif2, "ra"); |
|---|
| 2480 | sprintf(bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2481 | #endif |
|---|
| 2482 | memset(bufferif2, 0, 256); |
|---|
| 2483 | getIfList(bufferif2, "br"); |
|---|
| 2484 | foreach(word, bufferif2, next) { |
|---|
| 2485 | if (contains(word, '.')) |
|---|
| 2486 | sprintf(bufferif, "%s %s", bufferif, word); |
|---|
| 2487 | } |
|---|
| 2488 | int i; |
|---|
| 2489 | |
|---|
| 2490 | #ifdef HAVE_MADWIFI |
|---|
| 2491 | memset(bufferif2, 0, 256); |
|---|
| 2492 | getIfList(bufferif2, "ath"); |
|---|
| 2493 | foreach(word, bufferif2, next) { |
|---|
| 2494 | if (contains(word, '.')) |
|---|
| 2495 | sprintf(bufferif, "%s %s", bufferif, word); |
|---|
| 2496 | } |
|---|
| 2497 | int c = getifcount("wifi"); |
|---|
| 2498 | |
|---|
| 2499 | for (i = 0; i < c; i++) { |
|---|
| 2500 | char ath[32]; |
|---|
| 2501 | |
|---|
| 2502 | sprintf(ath, "ath%d_bridged", i); |
|---|
| 2503 | if (nvram_default_match(ath, "1", "1")) { |
|---|
| 2504 | sprintf(bufferif, "%s ath%d", bufferif, i); |
|---|
| 2505 | char vifs[32]; |
|---|
| 2506 | |
|---|
| 2507 | sprintf(vifs, "ath%d_vifs", i); |
|---|
| 2508 | sprintf(bufferif, "%s %s", bufferif, |
|---|
| 2509 | nvram_safe_get(vifs)); |
|---|
| 2510 | } |
|---|
| 2511 | } |
|---|
| 2512 | #endif |
|---|
| 2513 | #ifdef HAVE_BONDING |
|---|
| 2514 | c = atoi(nvram_default_get("bonding_number", "1")); |
|---|
| 2515 | for (i = 0; i < c; i++) { |
|---|
| 2516 | sprintf(bufferif, "%s bond%d", bufferif, i); |
|---|
| 2517 | } |
|---|
| 2518 | #endif |
|---|
| 2519 | #ifdef HAVE_EOP_TUNNEL |
|---|
| 2520 | for (i = 1; i < 11; i++) { |
|---|
| 2521 | char EOP[32]; |
|---|
| 2522 | |
|---|
| 2523 | if (nvram_nmatch("1", "oet%d_en", i) |
|---|
| 2524 | && nvram_nmatch("0", "oet%d_bridged", i)) { |
|---|
| 2525 | sprintf(EOP, "oet%d", i); |
|---|
| 2526 | sprintf(bufferif, "%s %s", bufferif, EOP); |
|---|
| 2527 | } |
|---|
| 2528 | } |
|---|
| 2529 | #endif |
|---|
| 2530 | char buffer[256]; |
|---|
| 2531 | |
|---|
| 2532 | memset(buffer, 0, 256); |
|---|
| 2533 | getIfList(buffer, "br"); |
|---|
| 2534 | |
|---|
| 2535 | memset(finalbuffer, 0, 256); |
|---|
| 2536 | foreach(word, buffer, next) { |
|---|
| 2537 | if (!contains(word, '.')) |
|---|
| 2538 | sprintf(finalbuffer, "%s %s", finalbuffer, word); |
|---|
| 2539 | } |
|---|
| 2540 | char *checkbuffer = malloc(strlen(finalbuffer) + 6); |
|---|
| 2541 | memset(checkbuffer, 0, strlen(finalbuffer) + 6); |
|---|
| 2542 | strcpy(checkbuffer, "none "); |
|---|
| 2543 | strcat(checkbuffer, finalbuffer); |
|---|
| 2544 | strcpy(finalbuffer, checkbuffer); |
|---|
| 2545 | free(checkbuffer); |
|---|
| 2546 | int realcount = atoi(nvram_default_get("bridgesif_count", "0")); |
|---|
| 2547 | |
|---|
| 2548 | wordlist = nvram_safe_get("bridgesif"); |
|---|
| 2549 | foreach(word, wordlist, next) { |
|---|
| 2550 | char *port = word; |
|---|
| 2551 | char *tag = strsep(&port, ">"); |
|---|
| 2552 | char *prio = port; |
|---|
| 2553 | |
|---|
| 2554 | strsep(&prio, ">"); |
|---|
| 2555 | if (!tag || !port) |
|---|
| 2556 | break; |
|---|
| 2557 | char vlan_name[32]; |
|---|
| 2558 | |
|---|
| 2559 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2560 | websWrite(wp, "<div class=\"label\">Assignment %d</div>\n", |
|---|
| 2561 | count); |
|---|
| 2562 | sprintf(vlan_name, "bridge%d", count); |
|---|
| 2563 | showOptions(wp, vlan_name, finalbuffer, tag); |
|---|
| 2564 | websWrite(wp, " Interface "); |
|---|
| 2565 | sprintf(vlan_name, "bridgeif%d", count); |
|---|
| 2566 | showOptions(wp, vlan_name, bufferif, port); |
|---|
| 2567 | websWrite(wp, " Prio "); |
|---|
| 2568 | sprintf(vlan_name, "bridgeifprio%d", count); |
|---|
| 2569 | websWrite(wp, |
|---|
| 2570 | "<input class=\"num\" name=\"%s\"size=\"3\" value=\"%s\" />\n", |
|---|
| 2571 | vlan_name, prio != NULL ? prio : "63"); |
|---|
| 2572 | websWrite(wp, |
|---|
| 2573 | "<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", |
|---|
| 2574 | count); |
|---|
| 2575 | websWrite(wp, "</div>\n"); |
|---|
| 2576 | count++; |
|---|
| 2577 | } |
|---|
| 2578 | int totalcount = count; |
|---|
| 2579 | |
|---|
| 2580 | for (i = count; i < realcount; i++) { |
|---|
| 2581 | char vlan_name[32]; |
|---|
| 2582 | |
|---|
| 2583 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2584 | websWrite(wp, "<div class=\"label\">Assignment %d</div>\n", i); |
|---|
| 2585 | sprintf(vlan_name, "bridge%d", i); |
|---|
| 2586 | showOptions(wp, vlan_name, finalbuffer, ""); |
|---|
| 2587 | websWrite(wp, " Interface "); |
|---|
| 2588 | sprintf(vlan_name, "bridgeif%d", i); |
|---|
| 2589 | showOptions(wp, vlan_name, bufferif, ""); |
|---|
| 2590 | websWrite(wp, " Prio "); |
|---|
| 2591 | sprintf(vlan_name, "bridgeifprio%d", i); |
|---|
| 2592 | websWrite(wp, |
|---|
| 2593 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2594 | vlan_name, "63"); |
|---|
| 2595 | websWrite(wp, |
|---|
| 2596 | "<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", |
|---|
| 2597 | i); |
|---|
| 2598 | websWrite(wp, "</div>\n"); |
|---|
| 2599 | totalcount++; |
|---|
| 2600 | } |
|---|
| 2601 | websWrite(wp, |
|---|
| 2602 | "<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"); |
|---|
| 2603 | char var[32]; |
|---|
| 2604 | |
|---|
| 2605 | sprintf(var, "%d", totalcount); |
|---|
| 2606 | nvram_set("bridgesif_count", var); |
|---|
| 2607 | } |
|---|
| 2608 | |
|---|
| 2609 | #endif |
|---|
| 2610 | #if 0 |
|---|
| 2611 | static void |
|---|
| 2612 | showDynOption(webs_t wp, char *propname, char *nvname, char *options[], |
|---|
| 2613 | char *names[]) |
|---|
| 2614 | { |
|---|
| 2615 | int i; |
|---|
| 2616 | |
|---|
| 2617 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2618 | websWrite(wp, |
|---|
| 2619 | "<div class=\"label\">%s</div><select name=\"%s\">\n", |
|---|
| 2620 | propname, nvname); |
|---|
| 2621 | for (i = 0; options[i] != NULL; i++) { |
|---|
| 2622 | websWrite(wp, |
|---|
| 2623 | "<option value=\"%s\" %s>Off</option>\n", |
|---|
| 2624 | names[i], nvram_match(nvname, |
|---|
| 2625 | options[i]) ? |
|---|
| 2626 | "selected=\"selected\"" : ""); |
|---|
| 2627 | } |
|---|
| 2628 | websWrite(wp, "</div>\n"); |
|---|
| 2629 | |
|---|
| 2630 | } |
|---|
| 2631 | #endif |
|---|
| 2632 | |
|---|
| 2633 | static void show_channel(webs_t wp, char *dev, char *prefix, int type) |
|---|
| 2634 | { |
|---|
| 2635 | char wl_mode[16]; |
|---|
| 2636 | |
|---|
| 2637 | sprintf(wl_mode, "%s_mode", prefix); |
|---|
| 2638 | char wl_net_mode[16]; |
|---|
| 2639 | |
|---|
| 2640 | sprintf(wl_net_mode, "%s_net_mode", prefix); |
|---|
| 2641 | if (nvram_match(wl_net_mode, "disabled")) |
|---|
| 2642 | return; |
|---|
| 2643 | #ifdef HAVE_RT2880 |
|---|
| 2644 | if (nvram_match(wl_mode, "ap") || nvram_match(wl_mode, "wdsap") |
|---|
| 2645 | || nvram_match(wl_mode, "apsta") || nvram_match(wl_mode, "apstawet") |
|---|
| 2646 | || nvram_match(wl_mode, "infra")) |
|---|
| 2647 | #else |
|---|
| 2648 | if (nvram_match(wl_mode, "ap") || nvram_match(wl_mode, "wdsap") |
|---|
| 2649 | || nvram_match(wl_mode, "infra")) |
|---|
| 2650 | #endif |
|---|
| 2651 | { |
|---|
| 2652 | char wl_channel[16]; |
|---|
| 2653 | |
|---|
| 2654 | sprintf(wl_channel, "%s_channel", prefix); |
|---|
| 2655 | char wl_wchannel[16]; |
|---|
| 2656 | |
|---|
| 2657 | sprintf(wl_wchannel, "%s_wchannel", prefix); |
|---|
| 2658 | char wl_nbw[16]; |
|---|
| 2659 | |
|---|
| 2660 | nvram_default_get(wl_wchannel, "0"); |
|---|
| 2661 | sprintf(wl_nbw, "%s_nbw", prefix); |
|---|
| 2662 | |
|---|
| 2663 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2664 | websWrite(wp, |
|---|
| 2665 | "<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", |
|---|
| 2666 | wl_channel); |
|---|
| 2667 | #ifdef HAVE_MADWIFI |
|---|
| 2668 | struct wifi_channels *chan; |
|---|
| 2669 | char cn[32]; |
|---|
| 2670 | char fr[32]; |
|---|
| 2671 | |
|---|
| 2672 | chan = list_channels(prefix); |
|---|
| 2673 | if (chan == NULL) |
|---|
| 2674 | chan = list_channels(dev); |
|---|
| 2675 | if (chan != NULL) { |
|---|
| 2676 | // int cnt = getchannelcount (); |
|---|
| 2677 | websWrite(wp, |
|---|
| 2678 | "document.write(\"<option value=\\\"0\\\" %s>\" + share.auto + \"</option>\");\n", |
|---|
| 2679 | nvram_match(wl_channel, |
|---|
| 2680 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 2681 | : ""); |
|---|
| 2682 | int i = 0; |
|---|
| 2683 | |
|---|
| 2684 | while (chan[i].freq != -1) { |
|---|
| 2685 | cprintf("%d\n", chan[i].channel); |
|---|
| 2686 | cprintf("%d\n", chan[i].freq); |
|---|
| 2687 | |
|---|
| 2688 | sprintf(cn, "%d", chan[i].channel); |
|---|
| 2689 | sprintf(fr, "%d", chan[i].freq); |
|---|
| 2690 | websWrite(wp, |
|---|
| 2691 | "document.write(\"<option value=\\\"%s\\\" %s>%s - %d MHz</option>\");\n", |
|---|
| 2692 | fr, nvram_match(wl_channel, |
|---|
| 2693 | fr) ? |
|---|
| 2694 | "selected=\\\"selected\\\"" : "", cn, |
|---|
| 2695 | (chan[i].freq + |
|---|
| 2696 | get_wifioffset(prefix))); |
|---|
| 2697 | // free (chan[i].freq); |
|---|
| 2698 | i++; |
|---|
| 2699 | } |
|---|
| 2700 | free(chan); |
|---|
| 2701 | } |
|---|
| 2702 | #else |
|---|
| 2703 | int instance = 0; |
|---|
| 2704 | |
|---|
| 2705 | if (!strcmp(prefix, "wl1")) |
|---|
| 2706 | instance = 1; |
|---|
| 2707 | #if 0 |
|---|
| 2708 | if (type == 1 && !nvram_match(wl_net_mode, "g-only") |
|---|
| 2709 | && !nvram_match(wl_net_mode, "a-only") |
|---|
| 2710 | && !nvram_match(wl_net_mode, "na-only") |
|---|
| 2711 | && !nvram_match(wl_net_mode, "bg-mixed") |
|---|
| 2712 | && nvram_match(wl_nbw, "40")) { |
|---|
| 2713 | int ch = atoi(nvram_nget("wl%d_wchannel", instance)); |
|---|
| 2714 | |
|---|
| 2715 | websWrite(wp, "var max_channel = 2;\n"); |
|---|
| 2716 | websWrite(wp, "var wl%d_channel = '%s';\n", instance, |
|---|
| 2717 | nvram_safe_get(wl_wchannel)); |
|---|
| 2718 | websWrite(wp, |
|---|
| 2719 | "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"); |
|---|
| 2720 | char *sel = ""; |
|---|
| 2721 | |
|---|
| 2722 | if (ch == 0) //wchannel = Auto |
|---|
| 2723 | { |
|---|
| 2724 | websWrite(wp, |
|---|
| 2725 | " document.write(\"<option value=\\\"0\\\" selected=\\\"selected\\\">\"+ share.auto +\"</option>\");\n"); |
|---|
| 2726 | } else { |
|---|
| 2727 | if (nvram_nmatch |
|---|
| 2728 | ("lower", "wl%d_nctrlsb", instance)) |
|---|
| 2729 | sel = "selected=\\\"selected\\\""; |
|---|
| 2730 | |
|---|
| 2731 | websWrite(wp, |
|---|
| 2732 | " document.write(\"<option value=\\\"%d\\\" %s>%d - \"+freq[%d]+\" GHz</option>\");\n", |
|---|
| 2733 | ch - 2, sel, ch - 2, ch - 2); |
|---|
| 2734 | sel = ""; |
|---|
| 2735 | if (nvram_nmatch |
|---|
| 2736 | ("upper", "wl%d_nctrlsb", instance)) |
|---|
| 2737 | sel = "selected=\\\"selected\\\""; |
|---|
| 2738 | websWrite(wp, |
|---|
| 2739 | " document.write(\"<option value=\\\"%d\\\" %s>%d - \"+freq[%d]+\" GHz</option>\");\n", |
|---|
| 2740 | ch + 2, sel, ch + 2, ch + 2); |
|---|
| 2741 | } |
|---|
| 2742 | |
|---|
| 2743 | } else |
|---|
| 2744 | #endif |
|---|
| 2745 | { |
|---|
| 2746 | |
|---|
| 2747 | unsigned int chanlist[128]; |
|---|
| 2748 | char *ifn = get_wl_instance_name(instance); |
|---|
| 2749 | int chancount = getchannels(chanlist, ifn); |
|---|
| 2750 | |
|---|
| 2751 | // websWrite( wp, "var max_channel = %d;\n", chancount ); |
|---|
| 2752 | // websWrite( wp, "var wl%d_channel = '%s';\n", instance, nvram_safe_get( wl_channel ) ); |
|---|
| 2753 | // websWrite( wp, "var offset = %d;\n", chanlist[0] ); |
|---|
| 2754 | // websWrite( wp, "var buf = \"\";\n" ); |
|---|
| 2755 | // websWrite( wp, "var freq = new Array(\"Auto\"" ); |
|---|
| 2756 | int i, j; |
|---|
| 2757 | |
|---|
| 2758 | // supported 5GHz channels for IEEE 802.11n 40Mhz |
|---|
| 2759 | int na_upper[16] = |
|---|
| 2760 | { 40, 48, 56, 64, 104, 112, 120, 128, 136, 153, 161, |
|---|
| 2761 | 0, 0, 0, 0, 0 }; |
|---|
| 2762 | int na_lower[16] = |
|---|
| 2763 | { 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157, |
|---|
| 2764 | 0, 0, 0, 0, 0 }; |
|---|
| 2765 | |
|---|
| 2766 | websWrite(wp, |
|---|
| 2767 | "document.write(\"<option value=\\\"0\\\" %s>\" + share.auto + \"</option>\");\n", |
|---|
| 2768 | nvram_nmatch("0", "%s_channel", |
|---|
| 2769 | prefix) ? |
|---|
| 2770 | "selected=\\\"selected\\\"" : ""); |
|---|
| 2771 | for (i = 0; i < chancount; i++) { |
|---|
| 2772 | float ofs; |
|---|
| 2773 | |
|---|
| 2774 | if (chanlist[i] < 25) |
|---|
| 2775 | ofs = 2.407f; |
|---|
| 2776 | else |
|---|
| 2777 | ofs = 5.000f; |
|---|
| 2778 | ofs += (float)(chanlist[i] * 0.005f); |
|---|
| 2779 | if (ofs == 2.477f) |
|---|
| 2780 | ofs = 2.484f; // fix: ch 14 is 2.484, not 2.477 GHz |
|---|
| 2781 | // websWrite( wp, ", \"%0.3f\"", ofs ); |
|---|
| 2782 | char channelstring[32]; |
|---|
| 2783 | |
|---|
| 2784 | int showit = 1; |
|---|
| 2785 | |
|---|
| 2786 | if (nvram_match(wl_net_mode, "a-only") |
|---|
| 2787 | || nvram_match(wl_net_mode, "na-only")) { |
|---|
| 2788 | if (chanlist[i] < 25) |
|---|
| 2789 | showit = 0; |
|---|
| 2790 | } else { |
|---|
| 2791 | if (chanlist[i] > 25) |
|---|
| 2792 | showit = 0; |
|---|
| 2793 | } |
|---|
| 2794 | |
|---|
| 2795 | if (nvram_match(wl_net_mode, "na-only") |
|---|
| 2796 | && nvram_match(wl_nbw, "40")) { |
|---|
| 2797 | showit = 0; |
|---|
| 2798 | j = 0; |
|---|
| 2799 | if (nvram_nmatch |
|---|
| 2800 | ("upper", "%s_nctrlsb", prefix)) { |
|---|
| 2801 | while (na_upper[j]) { |
|---|
| 2802 | if (chanlist[i] == |
|---|
| 2803 | na_upper[j]) { |
|---|
| 2804 | showit = 1; |
|---|
| 2805 | break; |
|---|
| 2806 | } |
|---|
| 2807 | j++; |
|---|
| 2808 | } |
|---|
| 2809 | } else |
|---|
| 2810 | if (nvram_nmatch |
|---|
| 2811 | ("lower", "%s_nctrlsb", |
|---|
| 2812 | prefix)) { |
|---|
| 2813 | while (na_lower[j]) { |
|---|
| 2814 | if (chanlist[i] == |
|---|
| 2815 | na_lower[j]) { |
|---|
| 2816 | showit = 1; |
|---|
| 2817 | break; |
|---|
| 2818 | } |
|---|
| 2819 | j++; |
|---|
| 2820 | } |
|---|
| 2821 | } |
|---|
| 2822 | } |
|---|
| 2823 | |
|---|
| 2824 | if ((nvram_match(wl_net_mode, "n-only") |
|---|
| 2825 | || nvram_match(wl_net_mode, "mixed")) |
|---|
| 2826 | && nvram_match(wl_nbw, "40")) { |
|---|
| 2827 | showit = 0; |
|---|
| 2828 | if (nvram_nmatch |
|---|
| 2829 | ("upper", "%s_nctrlsb", prefix)) { |
|---|
| 2830 | if (chanlist[i] >= 5 |
|---|
| 2831 | && chanlist[i] <= 13) { |
|---|
| 2832 | showit = 1; |
|---|
| 2833 | } |
|---|
| 2834 | } else |
|---|
| 2835 | if (nvram_nmatch |
|---|
| 2836 | ("lower", "%s_nctrlsb", |
|---|
| 2837 | prefix)) { |
|---|
| 2838 | if (chanlist[i] <= 9) { |
|---|
| 2839 | showit = 1; |
|---|
| 2840 | } |
|---|
| 2841 | } |
|---|
| 2842 | } |
|---|
| 2843 | |
|---|
| 2844 | sprintf(channelstring, "%d", chanlist[i]); |
|---|
| 2845 | if (showit) { |
|---|
| 2846 | websWrite(wp, |
|---|
| 2847 | "document.write(\"<option value=\\\"%d\\\" %s>%d - %0.3f GHz</option>\");\n", |
|---|
| 2848 | chanlist[i], |
|---|
| 2849 | nvram_nmatch(channelstring, |
|---|
| 2850 | "%s_channel", |
|---|
| 2851 | prefix) ? |
|---|
| 2852 | "selected=\\\"selected\\\"" : |
|---|
| 2853 | "", chanlist[i], ofs); |
|---|
| 2854 | } |
|---|
| 2855 | } |
|---|
| 2856 | // websWrite( wp, ");\n" ); |
|---|
| 2857 | // websWrite( wp, "for(i=0; i<=max_channel ; i++) {\n" ); |
|---|
| 2858 | // websWrite( wp, " if(i == wl%d_channel) buf = \"selected\";\n", |
|---|
| 2859 | // instance ); |
|---|
| 2860 | // websWrite( wp, " else buf = \"\";\n" ); |
|---|
| 2861 | // websWrite( wp, " if (i==0)\n" ); |
|---|
| 2862 | // websWrite( wp, |
|---|
| 2863 | // " document.write(\"<option value=\"+i+\" \"+buf+\">\" + share.auto + \"</option>\");\n" ); |
|---|
| 2864 | // websWrite( wp, " else\n" ); |
|---|
| 2865 | // websWrite( wp, |
|---|
| 2866 | // " document.write(\"<option value=\"+i+\" \"+buf+\">\"+(i+offset-1)+\" - \"+freq[i]+\" GHz</option>\");\n" ); |
|---|
| 2867 | // websWrite( wp, "}\n" ); |
|---|
| 2868 | } |
|---|
| 2869 | #endif |
|---|
| 2870 | websWrite(wp, "//]]>\n</script></select></div>\n"); |
|---|
| 2871 | } |
|---|
| 2872 | } |
|---|
| 2873 | |
|---|
| 2874 | #ifdef HAVE_MADWIFI |
|---|
| 2875 | static char *ag_rates[] = { "6", "9", "12", "18", "24", "36", "48", "54" }; |
|---|
| 2876 | static char *turbo_rates[] = |
|---|
| 2877 | { "12", "18", "24", "36", "48", "72", "96", "108" }; |
|---|
| 2878 | static char *b_rates[] = { "1", "2", "5.5", "11" }; |
|---|
| 2879 | static char *bg_rates[] = |
|---|
| 2880 | { "1", "2", "5.5", "6", "9", "11", "12", "18", "24", "36", "48", "54" }; |
|---|
| 2881 | // static char *g_rates[] = { "1", "2", "5.5", "11", "12", "18", "24", "36", |
|---|
| 2882 | // "48", "54" }; |
|---|
| 2883 | //static char *xr_rates[] = |
|---|
| 2884 | // { "0.25", "0.5", "1", "2", "3", "6", "9", "12", "18", "24", "36", "48", |
|---|
| 2885 | // "54" |
|---|
| 2886 | //}; |
|---|
| 2887 | static char *half_rates[] = { "3", "4.5", "6", "9", "12", "18", "24", "27" }; |
|---|
| 2888 | static char *quarter_rates[] = |
|---|
| 2889 | { "1.5", "2", "3", "4.5", "6", "9", "12", "13.5" }; |
|---|
| 2890 | static char *subquarter_rates[] = |
|---|
| 2891 | { "0.75", "1", "1.5", "2.25", "3", "4.5", "6", "6.75" }; |
|---|
| 2892 | |
|---|
| 2893 | void show_rates(webs_t wp, char *prefix, int maxrate) |
|---|
| 2894 | { |
|---|
| 2895 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2896 | if (maxrate) { |
|---|
| 2897 | websWrite(wp, |
|---|
| 2898 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label21)</script></div>\n"); |
|---|
| 2899 | websWrite(wp, "<select name=\"%s_maxrate\">\n", prefix); |
|---|
| 2900 | } else { |
|---|
| 2901 | websWrite(wp, |
|---|
| 2902 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label23)</script></div>\n"); |
|---|
| 2903 | websWrite(wp, "<select name=\"%s_minrate\">\n", prefix); |
|---|
| 2904 | } |
|---|
| 2905 | websWrite(wp, "<script type=\"text/javascript\">\n"); |
|---|
| 2906 | websWrite(wp, "//<![CDATA[\n"); |
|---|
| 2907 | char srate[32]; |
|---|
| 2908 | |
|---|
| 2909 | sprintf(srate, "%s_minrate", prefix); |
|---|
| 2910 | char mxrate[32]; |
|---|
| 2911 | |
|---|
| 2912 | sprintf(mxrate, "%s_maxrate", prefix); |
|---|
| 2913 | websWrite(wp, |
|---|
| 2914 | "document.write(\"<option value=\\\"0\\\" %s >\" + share.auto + \"</option>\");\n", |
|---|
| 2915 | nvram_match(srate, "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2916 | websWrite(wp, "//]]>\n"); |
|---|
| 2917 | websWrite(wp, "</script>\n"); |
|---|
| 2918 | char **rate; |
|---|
| 2919 | char **showrates = NULL; |
|---|
| 2920 | int len; |
|---|
| 2921 | char mode[32]; |
|---|
| 2922 | char bw[16]; |
|---|
| 2923 | |
|---|
| 2924 | sprintf(bw, "%s_channelbw", prefix); |
|---|
| 2925 | |
|---|
| 2926 | sprintf(mode, "%s_net_mode", prefix); |
|---|
| 2927 | if (nvram_match(mode, "b-only")) { |
|---|
| 2928 | rate = b_rates; |
|---|
| 2929 | len = sizeof(b_rates) / sizeof(char *); |
|---|
| 2930 | } |
|---|
| 2931 | if (nvram_match(mode, "g-only")) { |
|---|
| 2932 | rate = ag_rates; |
|---|
| 2933 | len = sizeof(ag_rates) / sizeof(char *); |
|---|
| 2934 | if (nvram_match(bw, "40")) { |
|---|
| 2935 | showrates = turbo_rates; |
|---|
| 2936 | } |
|---|
| 2937 | if (nvram_match(bw, "10")) { |
|---|
| 2938 | rate = half_rates; |
|---|
| 2939 | len = sizeof(half_rates) / sizeof(char *); |
|---|
| 2940 | } |
|---|
| 2941 | if (nvram_match(bw, "5")) { |
|---|
| 2942 | rate = quarter_rates; |
|---|
| 2943 | len = sizeof(quarter_rates) / sizeof(char *); |
|---|
| 2944 | } |
|---|
| 2945 | if (nvram_match(bw, "2")) { |
|---|
| 2946 | rate = subquarter_rates; |
|---|
| 2947 | len = sizeof(subquarter_rates) / sizeof(char *); |
|---|
| 2948 | } |
|---|
| 2949 | } |
|---|
| 2950 | if (nvram_match(mode, "a-only")) { |
|---|
| 2951 | rate = ag_rates; |
|---|
| 2952 | len = sizeof(ag_rates) / sizeof(char *); |
|---|
| 2953 | if (nvram_match(bw, "40")) { |
|---|
| 2954 | showrates = turbo_rates; |
|---|
| 2955 | } |
|---|
| 2956 | if (nvram_match(bw, "10")) { |
|---|
| 2957 | rate = half_rates; |
|---|
| 2958 | len = sizeof(half_rates) / sizeof(char *); |
|---|
| 2959 | } |
|---|
| 2960 | if (nvram_match(bw, "5")) { |
|---|
| 2961 | rate = quarter_rates; |
|---|
| 2962 | len = sizeof(quarter_rates) / sizeof(char *); |
|---|
| 2963 | } |
|---|
| 2964 | if (nvram_match(bw, "2")) { |
|---|
| 2965 | rate = subquarter_rates; |
|---|
| 2966 | len = sizeof(subquarter_rates) / sizeof(char *); |
|---|
| 2967 | } |
|---|
| 2968 | } |
|---|
| 2969 | if (nvram_match(mode, "bg-mixed")) { |
|---|
| 2970 | rate = bg_rates; |
|---|
| 2971 | len = sizeof(bg_rates) / sizeof(char *); |
|---|
| 2972 | if (nvram_match(bw, "10")) { |
|---|
| 2973 | rate = half_rates; |
|---|
| 2974 | len = sizeof(half_rates) / sizeof(char *); |
|---|
| 2975 | } |
|---|
| 2976 | if (nvram_match(bw, "5")) { |
|---|
| 2977 | rate = quarter_rates; |
|---|
| 2978 | len = sizeof(quarter_rates) / sizeof(char *); |
|---|
| 2979 | } |
|---|
| 2980 | if (nvram_match(bw, "2")) { |
|---|
| 2981 | rate = subquarter_rates; |
|---|
| 2982 | len = sizeof(subquarter_rates) / sizeof(char *); |
|---|
| 2983 | } |
|---|
| 2984 | } |
|---|
| 2985 | if (nvram_match(mode, "mixed")) { |
|---|
| 2986 | rate = bg_rates; |
|---|
| 2987 | len = sizeof(bg_rates) / sizeof(char *); |
|---|
| 2988 | if (nvram_match(bw, "40")) { |
|---|
| 2989 | rate = ag_rates; |
|---|
| 2990 | len = sizeof(ag_rates) / sizeof(char *); |
|---|
| 2991 | showrates = turbo_rates; |
|---|
| 2992 | } |
|---|
| 2993 | if (nvram_match(bw, "10")) { |
|---|
| 2994 | rate = half_rates; |
|---|
| 2995 | len = sizeof(half_rates) / sizeof(char *); |
|---|
| 2996 | } |
|---|
| 2997 | if (nvram_match(bw, "5")) { |
|---|
| 2998 | rate = quarter_rates; |
|---|
| 2999 | len = sizeof(quarter_rates) / sizeof(char *); |
|---|
| 3000 | } |
|---|
| 3001 | if (nvram_match(bw, "2")) { |
|---|
| 3002 | rate = subquarter_rates; |
|---|
| 3003 | len = sizeof(subquarter_rates) / sizeof(char *); |
|---|
| 3004 | } |
|---|
| 3005 | } |
|---|
| 3006 | int i; |
|---|
| 3007 | |
|---|
| 3008 | for (i = 0; i < len; i++) { |
|---|
| 3009 | if (maxrate) { |
|---|
| 3010 | int offset = 0; |
|---|
| 3011 | |
|---|
| 3012 | if (nvram_match(mode, "g-only") |
|---|
| 3013 | && nvram_match(bw, "20")) |
|---|
| 3014 | offset = 4; |
|---|
| 3015 | char comp[32]; |
|---|
| 3016 | |
|---|
| 3017 | sprintf(comp, "%d", i + 1 + offset); |
|---|
| 3018 | if (showrates) |
|---|
| 3019 | websWrite(wp, |
|---|
| 3020 | "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 3021 | i + 1 + offset, nvram_match(mxrate, |
|---|
| 3022 | comp) ? |
|---|
| 3023 | "selected=\"selected\"" : "", |
|---|
| 3024 | showrates[i]); |
|---|
| 3025 | else |
|---|
| 3026 | websWrite(wp, |
|---|
| 3027 | "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 3028 | i + 1 + offset, nvram_match(mxrate, |
|---|
| 3029 | comp) ? |
|---|
| 3030 | "selected=\"selected\"" : "", |
|---|
| 3031 | rate[i]); |
|---|
| 3032 | } else { |
|---|
| 3033 | int offset = 0; |
|---|
| 3034 | |
|---|
| 3035 | if (nvram_match(mode, "g-only") |
|---|
| 3036 | && nvram_match(bw, "20")) |
|---|
| 3037 | offset = 4; |
|---|
| 3038 | char comp[32]; |
|---|
| 3039 | |
|---|
| 3040 | sprintf(comp, "%d", i + 1 + offset); |
|---|
| 3041 | if (showrates) |
|---|
| 3042 | websWrite(wp, |
|---|
| 3043 | "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 3044 | i + 1 + offset, nvram_match(srate, |
|---|
| 3045 | comp) ? |
|---|
| 3046 | "selected=\"selected\"" : "", |
|---|
| 3047 | showrates[i]); |
|---|
| 3048 | else |
|---|
| 3049 | websWrite(wp, |
|---|
| 3050 | "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 3051 | i + 1 + offset, nvram_match(srate, |
|---|
| 3052 | comp) ? |
|---|
| 3053 | "selected=\"selected\"" : "", |
|---|
| 3054 | rate[i]); |
|---|
| 3055 | |
|---|
| 3056 | } |
|---|
| 3057 | } |
|---|
| 3058 | websWrite(wp, "</select>\n"); |
|---|
| 3059 | websWrite(wp, "<span class=\"default\">\n"); |
|---|
| 3060 | websWrite(wp, "<script type=\"text/javascript\">\n"); |
|---|
| 3061 | websWrite(wp, "//<![CDATA[\n"); |
|---|
| 3062 | websWrite(wp, |
|---|
| 3063 | "document.write(\"(\" + share.deflt + \": \" + share.auto + \")\");\n"); |
|---|
| 3064 | websWrite(wp, "//]]\n"); |
|---|
| 3065 | websWrite(wp, "</script></span></div>\n"); |
|---|
| 3066 | |
|---|
| 3067 | } |
|---|
| 3068 | #endif |
|---|
| 3069 | static void show_netmode(webs_t wp, char *prefix) |
|---|
| 3070 | { |
|---|
| 3071 | char wl_net_mode[16]; |
|---|
| 3072 | |
|---|
| 3073 | sprintf(wl_net_mode, "%s_net_mode", prefix); |
|---|
| 3074 | |
|---|
| 3075 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3076 | websWrite(wp, |
|---|
| 3077 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label2)</script></div><select name=\"%s\">\n", |
|---|
| 3078 | wl_net_mode); |
|---|
| 3079 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3080 | websWrite(wp, |
|---|
| 3081 | "document.write(\"<option value=\\\"disabled\\\" %s>\" + share.disabled + \"</option>\");\n", |
|---|
| 3082 | nvram_match(wl_net_mode, |
|---|
| 3083 | "disabled") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3084 | websWrite(wp, |
|---|
| 3085 | "document.write(\"<option value=\\\"mixed\\\" %s>\" + wl_basic.mixed + \"</option>\");\n", |
|---|
| 3086 | nvram_match(wl_net_mode, |
|---|
| 3087 | "mixed") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3088 | #ifdef HAVE_MADWIFI |
|---|
| 3089 | if (has_mimo(prefix)) |
|---|
| 3090 | #else |
|---|
| 3091 | if (has_mimo(prefix) && !nvram_nmatch("a", "%s_bandlist", prefix)) |
|---|
| 3092 | #endif |
|---|
| 3093 | { |
|---|
| 3094 | websWrite(wp, |
|---|
| 3095 | "document.write(\"<option value=\\\"bg-mixed\\\" %s>\" + wl_basic.bg + \"</option>\");\n", |
|---|
| 3096 | nvram_match(wl_net_mode, |
|---|
| 3097 | "bg-mixed") ? "selected=\\\"selected\\\"" |
|---|
| 3098 | : ""); |
|---|
| 3099 | } |
|---|
| 3100 | #ifdef HAVE_WHRAG108 |
|---|
| 3101 | if (!strcmp(prefix, "ath1")) |
|---|
| 3102 | #endif |
|---|
| 3103 | #ifdef HAVE_TW6600 |
|---|
| 3104 | if (!strcmp(prefix, "ath1")) |
|---|
| 3105 | #endif |
|---|
| 3106 | #ifndef HAVE_MADWIFI |
|---|
| 3107 | if (!nvram_nmatch("a", "%s_bandlist", prefix)) |
|---|
| 3108 | #endif |
|---|
| 3109 | { |
|---|
| 3110 | websWrite(wp, |
|---|
| 3111 | "document.write(\"<option value=\\\"b-only\\\" %s>\" + wl_basic.b + \"</option>\");\n", |
|---|
| 3112 | nvram_match(wl_net_mode, |
|---|
| 3113 | "b-only") ? |
|---|
| 3114 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3115 | } |
|---|
| 3116 | #ifdef HAVE_MADWIFI |
|---|
| 3117 | #ifdef HAVE_WHRAG108 |
|---|
| 3118 | if (!strcmp(prefix, "ath1")) |
|---|
| 3119 | #endif |
|---|
| 3120 | #ifdef HAVE_TW6600 |
|---|
| 3121 | if (!strcmp(prefix, "ath1")) |
|---|
| 3122 | #endif |
|---|
| 3123 | websWrite(wp, |
|---|
| 3124 | "document.write(\"<option value=\\\"g-only\\\" %s>\" + wl_basic.g + \"</option>\");\n", |
|---|
| 3125 | nvram_match(wl_net_mode, |
|---|
| 3126 | "g-only") ? |
|---|
| 3127 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3128 | #ifdef HAVE_WHRAG108 |
|---|
| 3129 | if (!strcmp(prefix, "ath1")) |
|---|
| 3130 | #endif |
|---|
| 3131 | #ifdef HAVE_TW6600 |
|---|
| 3132 | if (!strcmp(prefix, "ath1")) |
|---|
| 3133 | #endif |
|---|
| 3134 | #ifndef HAVE_LS5 |
|---|
| 3135 | websWrite(wp, |
|---|
| 3136 | "document.write(\"<option value=\\\"bg-mixed\\\" %s>\" + wl_basic.bg + \"</option>\");\n", |
|---|
| 3137 | nvram_match(wl_net_mode, |
|---|
| 3138 | "bg-mixed") ? |
|---|
| 3139 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3140 | #endif |
|---|
| 3141 | #else |
|---|
| 3142 | #ifdef HAVE_WHRAG108 |
|---|
| 3143 | if (!strcmp(prefix, "ath1")) |
|---|
| 3144 | #endif |
|---|
| 3145 | #ifndef HAVE_LS5 |
|---|
| 3146 | #ifndef HAVE_MADWIFI |
|---|
| 3147 | if (!nvram_nmatch("a", "%s_bandlist", prefix)) |
|---|
| 3148 | #endif |
|---|
| 3149 | { |
|---|
| 3150 | websWrite(wp, |
|---|
| 3151 | "document.write(\"<option value=\\\"g-only\\\" %s>\" + wl_basic.g + \"</option>\");\n", |
|---|
| 3152 | nvram_match(wl_net_mode, |
|---|
| 3153 | "g-only") ? |
|---|
| 3154 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3155 | } |
|---|
| 3156 | #endif |
|---|
| 3157 | #endif |
|---|
| 3158 | if (has_mimo(prefix) && !nvram_nmatch("a", "%s_bandlist", prefix)) { |
|---|
| 3159 | websWrite(wp, |
|---|
| 3160 | "document.write(\"<option value=\\\"n-only\\\" %s>\" + wl_basic.n + \"</option>\");\n", |
|---|
| 3161 | nvram_match(wl_net_mode, |
|---|
| 3162 | "n-only") ? "selected=\\\"selected\\\"" : |
|---|
| 3163 | ""); |
|---|
| 3164 | } |
|---|
| 3165 | #if !defined(HAVE_FONERA) && !defined(HAVE_LS2) && !defined(HAVE_MERAKI) |
|---|
| 3166 | #ifndef HAVE_MADWIFI |
|---|
| 3167 | |
|---|
| 3168 | if (nvram_nmatch("ga", "%s_phytypes", prefix) |
|---|
| 3169 | || nvram_nmatch("a", "%s_phytypes", prefix)) |
|---|
| 3170 | websWrite(wp, |
|---|
| 3171 | "document.write(\"<option value=\\\"a-only\\\" %s>\" + wl_basic.a + \"</option>\");\n", |
|---|
| 3172 | nvram_match(wl_net_mode, |
|---|
| 3173 | "a-only") ? "selected=\\\"selected\\\"" : |
|---|
| 3174 | ""); |
|---|
| 3175 | |
|---|
| 3176 | if (has_mimo(prefix)) { |
|---|
| 3177 | char band[64]; |
|---|
| 3178 | |
|---|
| 3179 | sprintf(band, "%s_bandlist", prefix); |
|---|
| 3180 | char *b = nvram_safe_get(band); |
|---|
| 3181 | |
|---|
| 3182 | if (contains(b, 'a')) { |
|---|
| 3183 | websWrite(wp, |
|---|
| 3184 | "document.write(\"<option value=\\\"a-only\\\" %s>\" + wl_basic.a + \"</option>\");\n", |
|---|
| 3185 | nvram_match(wl_net_mode, |
|---|
| 3186 | "a-only") ? |
|---|
| 3187 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3188 | websWrite(wp, |
|---|
| 3189 | "document.write(\"<option value=\\\"na-only\\\" %s>\" + wl_basic.na + \"</option>\");\n", |
|---|
| 3190 | nvram_match(wl_net_mode, |
|---|
| 3191 | "na-only") ? |
|---|
| 3192 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3193 | } |
|---|
| 3194 | } |
|---|
| 3195 | #else |
|---|
| 3196 | #if HAVE_WHRAG108 |
|---|
| 3197 | if (!strcmp(prefix, "ath0")) |
|---|
| 3198 | #endif |
|---|
| 3199 | #ifdef HAVE_TW6600 |
|---|
| 3200 | if (!strcmp(prefix, "ath0")) |
|---|
| 3201 | #endif |
|---|
| 3202 | websWrite(wp, |
|---|
| 3203 | "document.write(\"<option value=\\\"a-only\\\" %s>\" + wl_basic.a + \"</option>\");\n", |
|---|
| 3204 | nvram_match(wl_net_mode, |
|---|
| 3205 | "a-only") ? |
|---|
| 3206 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3207 | #endif |
|---|
| 3208 | |
|---|
| 3209 | #endif |
|---|
| 3210 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3211 | websWrite(wp, "</select>\n"); |
|---|
| 3212 | websWrite(wp, "</div>\n"); |
|---|
| 3213 | |
|---|
| 3214 | #ifdef HAVE_RT2880 |
|---|
| 3215 | if (nvram_nmatch("n-only", "%s_net_mode", prefix)) { |
|---|
| 3216 | char wl_greenfield[32]; |
|---|
| 3217 | |
|---|
| 3218 | sprintf(wl_greenfield, "%s_greenfield", prefix); |
|---|
| 3219 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3220 | websWrite(wp, |
|---|
| 3221 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label7)</script></div><select name=\"%s\" >\n", |
|---|
| 3222 | wl_greenfield); |
|---|
| 3223 | websWrite(wp, |
|---|
| 3224 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3225 | websWrite(wp, |
|---|
| 3226 | "document.write(\"<option value=\\\"0\\\" %s>\" + wl_basic.mixed + \"</option>\");\n", |
|---|
| 3227 | nvram_default_match(wl_greenfield, "0", |
|---|
| 3228 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3229 | : ""); |
|---|
| 3230 | websWrite(wp, |
|---|
| 3231 | "document.write(\"<option value=\\\"1\\\" %s>\" + wl_basic.greenfield + \"</option>\");\n", |
|---|
| 3232 | nvram_default_match(wl_greenfield, "1", |
|---|
| 3233 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3234 | : ""); |
|---|
| 3235 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3236 | websWrite(wp, "</select>\n"); |
|---|
| 3237 | websWrite(wp, "</div>\n"); |
|---|
| 3238 | } |
|---|
| 3239 | #endif |
|---|
| 3240 | } |
|---|
| 3241 | |
|---|
| 3242 | #ifdef HAVE_MADWIFI |
|---|
| 3243 | static void showrtssettings(webs_t wp, char *var) |
|---|
| 3244 | { |
|---|
| 3245 | char ssid[32]; |
|---|
| 3246 | char vvar[32]; |
|---|
| 3247 | |
|---|
| 3248 | strcpy(vvar, var); |
|---|
| 3249 | rep(vvar, '.', 'X'); |
|---|
| 3250 | sprintf(ssid, "%s_rts", var); |
|---|
| 3251 | websWrite(wp, |
|---|
| 3252 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.rts)</script></div>\n"); |
|---|
| 3253 | websWrite(wp, |
|---|
| 3254 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" onclick=\"show_layer_ext(this, '%s_idrts', true);\" name=\"%s_rts\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input>\n", |
|---|
| 3255 | vvar, var, nvram_default_match(ssid, "1", |
|---|
| 3256 | "0") ? "checked=\"checked\"" : |
|---|
| 3257 | ""); |
|---|
| 3258 | websWrite(wp, |
|---|
| 3259 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" onclick=\"show_layer_ext(this, '%s_idrts', false);\" name=\"%s_rts\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input> \n", |
|---|
| 3260 | vvar, var, nvram_default_match(ssid, "0", |
|---|
| 3261 | "0") ? "checked=\"checked\"" : |
|---|
| 3262 | ""); |
|---|
| 3263 | websWrite(wp, "</div>\n"); |
|---|
| 3264 | |
|---|
| 3265 | websWrite(wp, "<div id=\"%s_idrts\">\n", vvar); |
|---|
| 3266 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3267 | websWrite(wp, |
|---|
| 3268 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.rtsvalue)</script></div>\n"); |
|---|
| 3269 | char ip[32]; |
|---|
| 3270 | |
|---|
| 3271 | sprintf(ip, "%s_rtsvalue", var); |
|---|
| 3272 | websWrite(wp, |
|---|
| 3273 | "<input class=\"num\" maxlength=\"4\" size=\"4\" onblur=\"valid_range(this,1,2346,share.ip)\" name=\"%s_rtsvalue\" value=\"%s\" />", |
|---|
| 3274 | var, nvram_default_get(ip, "2346")); |
|---|
| 3275 | websWrite(wp, "</div>\n"); |
|---|
| 3276 | websWrite(wp, "</div>\n"); |
|---|
| 3277 | |
|---|
| 3278 | websWrite(wp, "<script>\n//<![CDATA[\n "); |
|---|
| 3279 | websWrite(wp, |
|---|
| 3280 | "show_layer_ext(document.getElementsByName(\"%s_rts\"), \"%s_idrts\", %s);\n", |
|---|
| 3281 | var, vvar, nvram_match(ssid, "1") ? "true" : "false"); |
|---|
| 3282 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3283 | |
|---|
| 3284 | } |
|---|
| 3285 | #endif |
|---|
| 3286 | static void showbridgesettings(webs_t wp, char *var, int mcast, int dual) |
|---|
| 3287 | { |
|---|
| 3288 | |
|---|
| 3289 | char ssid[32]; |
|---|
| 3290 | |
|---|
| 3291 | sprintf(ssid, "%s_bridged", var); |
|---|
| 3292 | char vvar[32]; |
|---|
| 3293 | |
|---|
| 3294 | strcpy(vvar, var); |
|---|
| 3295 | rep(vvar, '.', 'X'); |
|---|
| 3296 | websWrite(wp, |
|---|
| 3297 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.network)</script></div>\n"); |
|---|
| 3298 | websWrite(wp, |
|---|
| 3299 | "<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", |
|---|
| 3300 | vvar, var, nvram_default_match(ssid, "0", |
|---|
| 3301 | "1") ? "checked=\"checked\"" : |
|---|
| 3302 | ""); |
|---|
| 3303 | websWrite(wp, |
|---|
| 3304 | "<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", |
|---|
| 3305 | vvar, var, nvram_default_match(ssid, "1", |
|---|
| 3306 | "1") ? "checked=\"checked\"" : |
|---|
| 3307 | ""); |
|---|
| 3308 | websWrite(wp, "</div>\n"); |
|---|
| 3309 | |
|---|
| 3310 | websWrite(wp, "<div id=\"%s_idnetvifs\">\n", vvar); |
|---|
| 3311 | if (mcast) { |
|---|
| 3312 | char mcastvar[32]; |
|---|
| 3313 | |
|---|
| 3314 | sprintf(mcastvar, "%s_multicast", var); |
|---|
| 3315 | nvram_default_get(mcastvar, "0"); |
|---|
| 3316 | showRadio(wp, "wl_basic.multicast", mcastvar); |
|---|
| 3317 | } |
|---|
| 3318 | if (nvram_match("wk_mode", "gateway")) { |
|---|
| 3319 | char natvar[32]; |
|---|
| 3320 | sprintf(natvar, "%s_nat", var); |
|---|
| 3321 | nvram_default_get(natvar, "1"); |
|---|
| 3322 | showRadio(wp, "wl_basic.masquerade", natvar); |
|---|
| 3323 | } |
|---|
| 3324 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3325 | websWrite(wp, |
|---|
| 3326 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.ip)</script></div>\n"); |
|---|
| 3327 | char ip[32]; |
|---|
| 3328 | |
|---|
| 3329 | sprintf(ip, "%s_ipaddr", var); |
|---|
| 3330 | char *ipv = nvram_safe_get(ip); |
|---|
| 3331 | |
|---|
| 3332 | websWrite(wp, |
|---|
| 3333 | "<input type=\"hidden\" name=\"%s_ipaddr\" value=\"4\" />\n", |
|---|
| 3334 | var); |
|---|
| 3335 | websWrite(wp, |
|---|
| 3336 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,1,223,share.ip)\" name=\"%s_ipaddr_0\" value=\"%d\" />.", |
|---|
| 3337 | var, get_single_ip(ipv, 0)); |
|---|
| 3338 | websWrite(wp, |
|---|
| 3339 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_1\" value=\"%d\" />.", |
|---|
| 3340 | var, get_single_ip(ipv, 1)); |
|---|
| 3341 | websWrite(wp, |
|---|
| 3342 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_2\" value=\"%d\" />.", |
|---|
| 3343 | var, get_single_ip(ipv, 2)); |
|---|
| 3344 | websWrite(wp, |
|---|
| 3345 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_3\" value=\"%d\" />\n", |
|---|
| 3346 | var, get_single_ip(ipv, 3)); |
|---|
| 3347 | websWrite(wp, "</div>\n"); |
|---|
| 3348 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3349 | websWrite(wp, |
|---|
| 3350 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.subnet)</script></div>\n"); |
|---|
| 3351 | sprintf(ip, "%s_netmask", var); |
|---|
| 3352 | ipv = nvram_safe_get(ip); |
|---|
| 3353 | |
|---|
| 3354 | websWrite(wp, |
|---|
| 3355 | "<input type=\"hidden\" name=\"%s_netmask\" value=\"4\" />\n", |
|---|
| 3356 | var); |
|---|
| 3357 | websWrite(wp, |
|---|
| 3358 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_0\" value=\"%d\" />.", |
|---|
| 3359 | var, get_single_ip(ipv, 0)); |
|---|
| 3360 | websWrite(wp, |
|---|
| 3361 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_1\" value=\"%d\" />.", |
|---|
| 3362 | var, get_single_ip(ipv, 1)); |
|---|
| 3363 | websWrite(wp, |
|---|
| 3364 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_2\" value=\"%d\" />.", |
|---|
| 3365 | var, get_single_ip(ipv, 2)); |
|---|
| 3366 | websWrite(wp, |
|---|
| 3367 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_3\" value=\"%d\" />.", |
|---|
| 3368 | var, get_single_ip(ipv, 3)); |
|---|
| 3369 | websWrite(wp, "</div>\n"); |
|---|
| 3370 | |
|---|
| 3371 | #ifdef HAVE_MADWIFI |
|---|
| 3372 | /*if (dual) |
|---|
| 3373 | { |
|---|
| 3374 | char dl[32]; |
|---|
| 3375 | sprintf(dl,"%s_duallink",var); |
|---|
| 3376 | websWrite( wp, |
|---|
| 3377 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.duallink)</script></div>\n" ); |
|---|
| 3378 | websWrite( wp, |
|---|
| 3379 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" onclick=\"show_layer_ext(this, '%s_idduallink', true);\" name=\"%s_duallink\" %s><script type=\"text/javascript\">Capture(shared.enable)</script></input> \n", |
|---|
| 3380 | var, var, nvram_default_match( dl, "1", |
|---|
| 3381 | "0" ) ? "checked=\"checked\"" : |
|---|
| 3382 | "" ); |
|---|
| 3383 | websWrite( wp, |
|---|
| 3384 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" onclick=\"show_layer_ext(this, '%s_idduallink', false);\" name=\"%s_duallink\" %s><script type=\"text/javascript\">Capture(shared.disable)</script></input>\n", |
|---|
| 3385 | var, var, nvram_default_match( dl, "0", |
|---|
| 3386 | "0" ) ? "checked=\"checked\"" : |
|---|
| 3387 | "" ); |
|---|
| 3388 | websWrite( wp, "</div>\n" ); |
|---|
| 3389 | |
|---|
| 3390 | websWrite( wp, "<div id=\"%s_iddualink\">\n", var ); |
|---|
| 3391 | |
|---|
| 3392 | sprintf( ip, "%s_duallink_parent", var ); |
|---|
| 3393 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3394 | websWrite( wp,"<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.parent)</script></div>\n" ); |
|---|
| 3395 | ipv = nvram_default_get( ip,"0.0.0.0" ); |
|---|
| 3396 | websWrite( wp, |
|---|
| 3397 | "<input type=\"hidden\" name=\"%s_duallink_parent\" value=\"4\" />\n", |
|---|
| 3398 | var ); |
|---|
| 3399 | websWrite( wp, |
|---|
| 3400 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_duallink_parent_0\" value=\"%d\" />.", |
|---|
| 3401 | var, get_single_ip( ipv, 0 ) ); |
|---|
| 3402 | websWrite( wp, |
|---|
| 3403 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_duallink_parent_1\" value=\"%d\" />.", |
|---|
| 3404 | var, get_single_ip( ipv, 1 ) ); |
|---|
| 3405 | websWrite( wp, |
|---|
| 3406 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_duallink_parent_2\" value=\"%d\" />.", |
|---|
| 3407 | var, get_single_ip( ipv, 2 ) ); |
|---|
| 3408 | websWrite( wp, |
|---|
| 3409 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_duallink_parent_3\" value=\"%d\" />.", |
|---|
| 3410 | var, get_single_ip( ipv, 3 ) ); |
|---|
| 3411 | websWrite( wp, "</div>\n" ); |
|---|
| 3412 | |
|---|
| 3413 | websWrite( wp, "</div>\n" ); |
|---|
| 3414 | |
|---|
| 3415 | websWrite( wp, "<script>\n//<![CDATA[\n " ); |
|---|
| 3416 | websWrite( wp, |
|---|
| 3417 | "show_layer_ext(document.getElementsByName(\"%s_duallink\"), \"%s_idduallink\", %s);\n", |
|---|
| 3418 | var, vvar, nvram_match( dl, "1" ) ? "true" : "false" ); |
|---|
| 3419 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3420 | }*/ |
|---|
| 3421 | #endif |
|---|
| 3422 | |
|---|
| 3423 | websWrite(wp, "</div>\n"); |
|---|
| 3424 | |
|---|
| 3425 | websWrite(wp, "<script>\n//<![CDATA[\n "); |
|---|
| 3426 | websWrite(wp, |
|---|
| 3427 | "show_layer_ext(document.getElementsByName(\"%s_bridged\"), \"%s_idnetvifs\", %s);\n", |
|---|
| 3428 | var, vvar, nvram_match(ssid, "0") ? "true" : "false"); |
|---|
| 3429 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3430 | |
|---|
| 3431 | } |
|---|
| 3432 | |
|---|
| 3433 | #ifdef HAVE_MADWIFI |
|---|
| 3434 | static void show_chanshift(webs_t wp, char *prefix) |
|---|
| 3435 | { |
|---|
| 3436 | char wl_chanshift[32]; |
|---|
| 3437 | char wl_channelbw[32]; |
|---|
| 3438 | |
|---|
| 3439 | sprintf(wl_channelbw, "%s_channelbw", prefix); |
|---|
| 3440 | sprintf(wl_chanshift, "%s_chanshift", prefix); |
|---|
| 3441 | if (atoi(nvram_safe_get(wl_channelbw)) > 2 && (atoi(nvram_safe_get(wl_chanshift)) & 0xf) > 10) nvram_set(wl_chanshift, "10"); |
|---|
| 3442 | if (atoi(nvram_safe_get(wl_channelbw)) > 5 && (atoi(nvram_safe_get(wl_chanshift)) & 0xf) > 10) nvram_set(wl_chanshift, "10"); |
|---|
| 3443 | if (atoi(nvram_safe_get(wl_channelbw)) > 10 && (atoi(nvram_safe_get(wl_chanshift)) & 0xf) > 0) vram_set(wl_chanshift, "0"); |
|---|
| 3444 | |
|---|
| 3445 | if (nvram_match(wl_channelbw, "5") |
|---|
| 3446 | || nvram_match(wl_channelbw, "10") || nvram_match(wl_channelbw, "2")) { |
|---|
| 3447 | |
|---|
| 3448 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3449 | websWrite(wp, |
|---|
| 3450 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.chanshift)</script></div>\n<select name=\"%s\">\n", |
|---|
| 3451 | wl_chanshift); |
|---|
| 3452 | websWrite(wp, |
|---|
| 3453 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3454 | if (nvram_match(wl_channelbw, "5") || nvram_match(wl_channelbw, "2")) |
|---|
| 3455 | websWrite(wp, |
|---|
| 3456 | "document.write(\"<option value=\\\"-15\\\" %s >-15 Mhz</option>\");\n", |
|---|
| 3457 | nvram_default_match(wl_chanshift, "-15", |
|---|
| 3458 | "0") ? |
|---|
| 3459 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3460 | if (nvram_match(wl_channelbw, "5") |
|---|
| 3461 | || nvram_match(wl_channelbw, "10")|| nvram_match(wl_channelbw, "2")) |
|---|
| 3462 | websWrite(wp, |
|---|
| 3463 | "document.write(\"<option value=\\\"-10\\\" %s >-10 Mhz</option>\");\n", |
|---|
| 3464 | nvram_default_match(wl_chanshift, "-10", |
|---|
| 3465 | "0") ? |
|---|
| 3466 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3467 | if (nvram_match(wl_channelbw, "5") |
|---|
| 3468 | || nvram_match(wl_channelbw, "10")|| nvram_match(wl_channelbw, "2")) |
|---|
| 3469 | websWrite(wp, |
|---|
| 3470 | "document.write(\"<option value=\\\"-5\\\" %s >-5 Mhz</option>\");\n", |
|---|
| 3471 | nvram_default_match(wl_chanshift, "-5", |
|---|
| 3472 | "0") ? |
|---|
| 3473 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3474 | websWrite(wp, |
|---|
| 3475 | "document.write(\"<option value=\\\"0\\\" %s >0 Mhz</option>\");\n", |
|---|
| 3476 | nvram_default_match(wl_chanshift, "0", |
|---|
| 3477 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3478 | : ""); |
|---|
| 3479 | if (nvram_match(wl_channelbw, "5") |
|---|
| 3480 | || nvram_match(wl_channelbw, "10")|| nvram_match(wl_channelbw, "2")) |
|---|
| 3481 | websWrite(wp, |
|---|
| 3482 | "document.write(\"<option value=\\\"5\\\" %s >+5 Mhz</option>\");\n", |
|---|
| 3483 | nvram_default_match(wl_chanshift, "5", |
|---|
| 3484 | "0") ? |
|---|
| 3485 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3486 | if (nvram_match(wl_channelbw, "5") |
|---|
| 3487 | || nvram_match(wl_channelbw, "10")|| nvram_match(wl_channelbw, "2")) |
|---|
| 3488 | websWrite(wp, |
|---|
| 3489 | "document.write(\"<option value=\\\"10\\\" %s >+10 Mhz</option>\");\n", |
|---|
| 3490 | nvram_default_match(wl_chanshift, "10", |
|---|
| 3491 | "0") ? |
|---|
| 3492 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3493 | if (nvram_match(wl_channelbw, "5")|| nvram_match(wl_channelbw, "2")) |
|---|
| 3494 | websWrite(wp, |
|---|
| 3495 | "document.write(\"<option value=\\\"15\\\" %s >+15 Mhz</option>\");\n", |
|---|
| 3496 | nvram_default_match(wl_chanshift, "15", |
|---|
| 3497 | "0") ? |
|---|
| 3498 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3499 | websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 3500 | } |
|---|
| 3501 | } |
|---|
| 3502 | #endif |
|---|
| 3503 | static int show_virtualssid(webs_t wp, char *prefix) |
|---|
| 3504 | { |
|---|
| 3505 | char *next; |
|---|
| 3506 | char var[80]; |
|---|
| 3507 | char ssid[80]; |
|---|
| 3508 | char vif[16]; |
|---|
| 3509 | char power[32]; |
|---|
| 3510 | |
|---|
| 3511 | #ifdef HAVE_MADWIFI |
|---|
| 3512 | char wmm[32]; |
|---|
| 3513 | char wl_protmode[32]; |
|---|
| 3514 | #endif |
|---|
| 3515 | sprintf(vif, "%s_vifs", prefix); |
|---|
| 3516 | char *vifs = nvram_safe_get(vif); |
|---|
| 3517 | |
|---|
| 3518 | if (vifs == NULL) |
|---|
| 3519 | return 0; |
|---|
| 3520 | #ifndef HAVE_MADWIFI |
|---|
| 3521 | if (!nvram_nmatch("ap", "%s_mode", prefix) |
|---|
| 3522 | && !nvram_nmatch("apsta", "%s_mode", prefix) |
|---|
| 3523 | && !nvram_nmatch("apstawet", "%s_mode", prefix)) |
|---|
| 3524 | return 0; |
|---|
| 3525 | #endif |
|---|
| 3526 | int count = 1; |
|---|
| 3527 | |
|---|
| 3528 | websWrite(wp, |
|---|
| 3529 | "<h2><script type=\"text/javascript\">Capture(wl_basic.h2_vi)</script></h2>\n"); |
|---|
| 3530 | foreach(var, vifs, next) { |
|---|
| 3531 | sprintf(ssid, "%s_ssid", var); |
|---|
| 3532 | websWrite(wp, |
|---|
| 3533 | "<fieldset><legend><script type=\"text/javascript\">Capture(share.vintrface)</script> %s SSID [", |
|---|
| 3534 | IFMAP(var)); |
|---|
| 3535 | tf_webWriteESCNV(wp, ssid); // fix for broken html page if ssid |
|---|
| 3536 | // contains html tag |
|---|
| 3537 | websWrite(wp, "]</legend>\n"); |
|---|
| 3538 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3539 | websWrite(wp, |
|---|
| 3540 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label3)</script></div>\n"); |
|---|
| 3541 | |
|---|
| 3542 | websWrite(wp, |
|---|
| 3543 | "<input name=\"%s_ssid\" size=\"20\" maxlength=\"32\" onblur=\"valid_name(this,wl_basic.label3)\" value=\"%s\" /></div>\n", |
|---|
| 3544 | var, nvram_safe_get(ssid)); |
|---|
| 3545 | |
|---|
| 3546 | #ifdef HAVE_MADWIFI |
|---|
| 3547 | // sprintf( wl_chanshift, "%s_chanshift", var ); |
|---|
| 3548 | // show_chanshift( wp, wl_chanshift ); |
|---|
| 3549 | |
|---|
| 3550 | sprintf(wl_protmode, "%s_protmode", var); |
|---|
| 3551 | showOptionsLabel(wp, "wl_basic.protmode", wl_protmode, |
|---|
| 3552 | "None CTS RTS/CTS", |
|---|
| 3553 | nvram_default_get(wl_protmode, "None")); |
|---|
| 3554 | showrtssettings(wp, var); |
|---|
| 3555 | #endif |
|---|
| 3556 | |
|---|
| 3557 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3558 | websWrite(wp, |
|---|
| 3559 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label5)</script></div>"); |
|---|
| 3560 | sprintf(ssid, "%s_closed", var); |
|---|
| 3561 | websWrite(wp, |
|---|
| 3562 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s_closed\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input> \n", |
|---|
| 3563 | var, nvram_match(ssid, |
|---|
| 3564 | "0") ? "checked=\"checked\"" : ""); |
|---|
| 3565 | websWrite(wp, |
|---|
| 3566 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s_closed\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input>\n", |
|---|
| 3567 | var, nvram_match(ssid, |
|---|
| 3568 | "1") ? "checked=\"checked\"" : ""); |
|---|
| 3569 | websWrite(wp, "</div>\n"); |
|---|
| 3570 | char wl_mode[16]; |
|---|
| 3571 | |
|---|
| 3572 | #ifdef HAVE_MADWIFI |
|---|
| 3573 | sprintf(wl_mode, "%s_mode", var); |
|---|
| 3574 | websWrite(wp, |
|---|
| 3575 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label)</script></div><select name=\"%s\" >\n", |
|---|
| 3576 | wl_mode); |
|---|
| 3577 | websWrite(wp, |
|---|
| 3578 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3579 | websWrite(wp, |
|---|
| 3580 | "document.write(\"<option value=\\\"ap\\\" %s >\" + wl_basic.ap + \"</option>\");\n", |
|---|
| 3581 | nvram_match(wl_mode, |
|---|
| 3582 | "ap") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3583 | // websWrite (wp, |
|---|
| 3584 | // "document.write(\"<option value=\\\"wdssta\\\" %s >\" + |
|---|
| 3585 | // wl_basic.wdssta + \"</option>\");\n", |
|---|
| 3586 | // nvram_match (wl_mode, |
|---|
| 3587 | // "wdssta") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3588 | websWrite(wp, |
|---|
| 3589 | "document.write(\"<option value=\\\"wdsap\\\" %s >\" + wl_basic.wdsap + \"</option>\");\n", |
|---|
| 3590 | nvram_match(wl_mode, |
|---|
| 3591 | "wdsap") ? "selected=\\\"selected\\\"" : |
|---|
| 3592 | ""); |
|---|
| 3593 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3594 | websWrite(wp, "</select>\n"); |
|---|
| 3595 | websWrite(wp, "</div>\n"); |
|---|
| 3596 | sprintf(wmm, "%s_wmm", var); |
|---|
| 3597 | showRadio(wp, "wl_adv.label18", wmm); |
|---|
| 3598 | #endif |
|---|
| 3599 | sprintf(ssid, "%s_ap_isolate", var); |
|---|
| 3600 | showRadio(wp, "wl_adv.label11", ssid); |
|---|
| 3601 | #ifdef HAVE_MADWIFI |
|---|
| 3602 | |
|---|
| 3603 | if (nvram_nmatch("ap", "%s_mode", prefix) |
|---|
| 3604 | || nvram_nmatch("wdsap", "%s_mode", prefix) |
|---|
| 3605 | || nvram_nmatch("infra", "%s_mode", prefix)) { |
|---|
| 3606 | sprintf(power, "%s_maxassoc", prefix); |
|---|
| 3607 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3608 | websWrite(wp, |
|---|
| 3609 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label10)</script></div>\n"); |
|---|
| 3610 | websWrite(wp, |
|---|
| 3611 | "<input class=\"num\" name=\"%s\" size=\"4\" maxlength=\"4\" onblur=\"valid_range(this,0,256,wl_adv.label10)\" value=\"%s\" />\n", |
|---|
| 3612 | power, nvram_default_get(power, "256")); |
|---|
| 3613 | |
|---|
| 3614 | websWrite(wp, |
|---|
| 3615 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 256 \" + share.user + \")\");\n//]]>\n</script></span>\n"); |
|---|
| 3616 | websWrite(wp, "</div>\n"); |
|---|
| 3617 | } |
|---|
| 3618 | |
|---|
| 3619 | sprintf(power, "%s_mtikie", prefix); |
|---|
| 3620 | nvram_default_get(power, "0"); |
|---|
| 3621 | showRadio(wp, "wl_basic.mtikie", power); |
|---|
| 3622 | #endif |
|---|
| 3623 | #ifdef HAVE_RT2880 |
|---|
| 3624 | showbridgesettings(wp, getRADev(var), 1, 0); |
|---|
| 3625 | #else |
|---|
| 3626 | showbridgesettings(wp, var, 1, 0); |
|---|
| 3627 | #endif |
|---|
| 3628 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 3629 | count++; |
|---|
| 3630 | } |
|---|
| 3631 | |
|---|
| 3632 | websWrite(wp, "<div class=\"center\">\n"); |
|---|
| 3633 | #ifdef HAVE_MADWIFI |
|---|
| 3634 | if (count < 8) |
|---|
| 3635 | #elif HAVE_RT2880 |
|---|
| 3636 | if (count < 7) |
|---|
| 3637 | #else |
|---|
| 3638 | if (count < WL_MAXBSSCFG) |
|---|
| 3639 | #endif |
|---|
| 3640 | websWrite(wp, |
|---|
| 3641 | "<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", |
|---|
| 3642 | prefix); |
|---|
| 3643 | |
|---|
| 3644 | if (count > 1) |
|---|
| 3645 | websWrite(wp, |
|---|
| 3646 | "<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", |
|---|
| 3647 | prefix); |
|---|
| 3648 | |
|---|
| 3649 | websWrite(wp, "</div><br />\n"); |
|---|
| 3650 | |
|---|
| 3651 | return 0; |
|---|
| 3652 | } |
|---|
| 3653 | |
|---|
| 3654 | void ej_showad(webs_t wp, int argc, char_t ** argv) |
|---|
| 3655 | { |
|---|
| 3656 | #ifndef HAVE_FON |
|---|
| 3657 | #ifndef CONFIG_BRANDING |
|---|
| 3658 | #ifdef HAVE_CHILLI |
|---|
| 3659 | // if (nvram_invmatch ("fon_enable", "1")) |
|---|
| 3660 | // websWrite (wp, |
|---|
| 3661 | // "<a href=\"fon.cgi\"><img src=\"images/turn.gif\" border=0 /></a>"); |
|---|
| 3662 | #endif |
|---|
| 3663 | #endif |
|---|
| 3664 | #endif |
|---|
| 3665 | |
|---|
| 3666 | #ifndef HAVE_NOAD |
|---|
| 3667 | /* |
|---|
| 3668 | * if (nvram_match("wanup","1")) { websWrite(wp,"<script |
|---|
| 3669 | * type=\"text/javascript\"><!--\n//<![CDATA[\n "); |
|---|
| 3670 | * websWrite(wp,"google_ad_client = \"pub-8308593183433068\";\n"); |
|---|
| 3671 | * websWrite(wp,"google_ad_width = 728;\n"); |
|---|
| 3672 | * websWrite(wp,"google_ad_height = 90;\n"); |
|---|
| 3673 | * websWrite(wp,"google_ad_format = \"728x90_as\";\n"); |
|---|
| 3674 | * websWrite(wp,"google_ad_type = \"text_image\";\n"); |
|---|
| 3675 | * websWrite(wp,"google_ad_channel =\"8866414571\";\n"); |
|---|
| 3676 | * websWrite(wp,"google_color_border = \"333333\";\n"); |
|---|
| 3677 | * websWrite(wp,"google_color_bg = \"000000\";\n"); |
|---|
| 3678 | * websWrite(wp,"google_color_link = \"FFFFFF\";\n"); |
|---|
| 3679 | * websWrite(wp,"google_color_url = \"999999\";\n"); |
|---|
| 3680 | * websWrite(wp,"google_color_text = \"CCCCCC\";\n"); |
|---|
| 3681 | * websWrite(wp,"//-->//]]>\n</script>\n"); websWrite(wp,"<script |
|---|
| 3682 | * type=\"text/javascript\"\n"); websWrite(wp," |
|---|
| 3683 | * src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\n"); |
|---|
| 3684 | * websWrite(wp,"</script>\n"); } |
|---|
| 3685 | */ |
|---|
| 3686 | #endif |
|---|
| 3687 | return; |
|---|
| 3688 | } |
|---|
| 3689 | |
|---|
| 3690 | #ifndef HAVE_SUPERCHANNEL |
|---|
| 3691 | int inline issuperchannel(void) |
|---|
| 3692 | { |
|---|
| 3693 | #if defined(HAVE_MAKSAT) && defined(HAVE_MR3202A) |
|---|
| 3694 | return 0; |
|---|
| 3695 | #elif defined(HAVE_MAKSAT) && defined(HAVE_ALPHA) |
|---|
| 3696 | return 0; |
|---|
| 3697 | #elif HAVE_MAKSAT |
|---|
| 3698 | return 1; |
|---|
| 3699 | #else |
|---|
| 3700 | return 0; |
|---|
| 3701 | #endif |
|---|
| 3702 | } |
|---|
| 3703 | #endif |
|---|
| 3704 | |
|---|
| 3705 | void ej_show_countrylist(webs_t wp, int argc, char_t ** argv) |
|---|
| 3706 | { |
|---|
| 3707 | if (argc < 1) { |
|---|
| 3708 | return; |
|---|
| 3709 | } |
|---|
| 3710 | char *list = getCountryList(); |
|---|
| 3711 | |
|---|
| 3712 | showOptionsChoose(wp, argv[0], list, nvram_safe_get(argv[0])); |
|---|
| 3713 | } |
|---|
| 3714 | |
|---|
| 3715 | void ej_show_wireless_single(webs_t wp, char *prefix) |
|---|
| 3716 | { |
|---|
| 3717 | char wl_mode[16]; |
|---|
| 3718 | char wl_macaddr[16]; |
|---|
| 3719 | char wl_ssid[16]; |
|---|
| 3720 | |
|---|
| 3721 | sprintf(wl_mode, "%s_mode", prefix); |
|---|
| 3722 | sprintf(wl_macaddr, "%s_hwaddr", prefix); |
|---|
| 3723 | sprintf(wl_ssid, "%s_ssid", prefix); |
|---|
| 3724 | |
|---|
| 3725 | // wireless mode |
|---|
| 3726 | websWrite(wp, |
|---|
| 3727 | "<h2><script type=\"text/javascript\">Capture(wl_basic.h2_v24)</script> %s</h2>\n", |
|---|
| 3728 | prefix); |
|---|
| 3729 | websWrite(wp, "<fieldset>\n"); |
|---|
| 3730 | websWrite(wp, |
|---|
| 3731 | "<legend><script type=\"text/javascript\">Capture(share.pintrface)</script> %s - SSID [", |
|---|
| 3732 | IFMAP(prefix)); |
|---|
| 3733 | tf_webWriteESCNV(wp, wl_ssid); // fix |
|---|
| 3734 | websWrite(wp, "] HWAddr [%s]</legend>\n", nvram_safe_get(wl_macaddr)); |
|---|
| 3735 | char power[16]; |
|---|
| 3736 | |
|---|
| 3737 | // char maxpower[16]; |
|---|
| 3738 | #ifdef HAVE_MADWIFI |
|---|
| 3739 | #ifndef HAVE_MAKSAT |
|---|
| 3740 | #ifndef HAVE_DDLINK |
|---|
| 3741 | if (isEMP(prefix)) { |
|---|
| 3742 | char wl_cardtype[32]; |
|---|
| 3743 | sprintf(wl_cardtype, "%s_cardtype", prefix); |
|---|
| 3744 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3745 | websWrite(wp, |
|---|
| 3746 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.cardtype)</script></div>\n<select name=\"%s\">\n", |
|---|
| 3747 | wl_cardtype); |
|---|
| 3748 | websWrite(wp, |
|---|
| 3749 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3750 | websWrite(wp, |
|---|
| 3751 | "document.write(\"<option value=\\\"0\\\" %s >Atheros Generic</option>\");\n", |
|---|
| 3752 | nvram_default_match(wl_cardtype, "0", |
|---|
| 3753 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3754 | : ""); |
|---|
| 3755 | websWrite(wp, |
|---|
| 3756 | "document.write(\"<option value=\\\"5\\\" %s >Alfa Networks AWPCI085H</option>\");\n", |
|---|
| 3757 | nvram_default_match(wl_cardtype, "5", |
|---|
| 3758 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3759 | : ""); |
|---|
| 3760 | websWrite(wp, |
|---|
| 3761 | "document.write(\"<option value=\\\"6\\\" %s >Alfa Networks AWPCI085P</option>\");\n", |
|---|
| 3762 | nvram_default_match(wl_cardtype, "6", |
|---|
| 3763 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3764 | : ""); |
|---|
| 3765 | websWrite(wp, |
|---|
| 3766 | "document.write(\"<option value=\\\"7\\\" %s >Doodle Labs DLM105</option>\");\n", |
|---|
| 3767 | nvram_default_match(wl_cardtype, "7", |
|---|
| 3768 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3769 | : ""); |
|---|
| 3770 | websWrite(wp, |
|---|
| 3771 | "document.write(\"<option value=\\\"4\\\" %s >MakSat MAK27</option>\");\n", |
|---|
| 3772 | nvram_default_match(wl_cardtype, "4", |
|---|
| 3773 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3774 | : ""); |
|---|
| 3775 | websWrite(wp, |
|---|
| 3776 | "document.write(\"<option value=\\\"1\\\" %s >Senao EMP-8602</option>\");\n", |
|---|
| 3777 | nvram_default_match(wl_cardtype, "1", |
|---|
| 3778 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3779 | : ""); |
|---|
| 3780 | websWrite(wp, |
|---|
| 3781 | "document.write(\"<option value=\\\"2\\\" %s >Senao EMP-8603-S</option>\");\n", |
|---|
| 3782 | nvram_default_match(wl_cardtype, "2", |
|---|
| 3783 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3784 | : ""); |
|---|
| 3785 | websWrite(wp, |
|---|
| 3786 | "document.write(\"<option value=\\\"3\\\" %s >Senao EMP-8603</option>\");\n", |
|---|
| 3787 | nvram_default_match(wl_cardtype, "3", |
|---|
| 3788 | "0") ? "selected=\\\"selected\\\"" |
|---|
| 3789 | : ""); |
|---|
| 3790 | websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 3791 | } |
|---|
| 3792 | #endif |
|---|
| 3793 | #endif // ! HAVE MAKSAT |
|---|
| 3794 | char wl_regdomain[16]; |
|---|
| 3795 | |
|---|
| 3796 | sprintf(wl_regdomain, "%s_regdomain", prefix); |
|---|
| 3797 | if (nvram_match("ath_regulatory", "1") || !issuperchannel()) { |
|---|
| 3798 | websWrite(wp, |
|---|
| 3799 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.regdom)</script></div>\n"); |
|---|
| 3800 | char *list = getCountryList(); |
|---|
| 3801 | |
|---|
| 3802 | showOptions(wp, wl_regdomain, list, |
|---|
| 3803 | nvram_safe_get(wl_regdomain)); |
|---|
| 3804 | websWrite(wp, "</div>\n"); |
|---|
| 3805 | } |
|---|
| 3806 | /* |
|---|
| 3807 | * while (regdomains[domcount].name != NULL) { char domcode[16]; sprintf |
|---|
| 3808 | * (domcode, "%d", regdomains[domcount].code); websWrite (wp, "<option |
|---|
| 3809 | * value=\"%d\" %s>%s</option>\n", regdomains[domcount].code, nvram_match |
|---|
| 3810 | * (wl_regdomain, domcode) ? " selected=\"selected\"" : "", |
|---|
| 3811 | * regdomains[domcount].name); domcount++; } websWrite (wp, |
|---|
| 3812 | * "</select>\n"); websWrite (wp, "</div>\n"); |
|---|
| 3813 | */ |
|---|
| 3814 | // power adjustment |
|---|
| 3815 | sprintf(power, "%s_txpwrdbm", prefix); |
|---|
| 3816 | // sprintf (maxpower, "%s_maxpower", prefix); |
|---|
| 3817 | if (!strcmp(prefix, "ath0") && issuperchannel()) // show |
|---|
| 3818 | // client |
|---|
| 3819 | // only on |
|---|
| 3820 | // first |
|---|
| 3821 | // interface |
|---|
| 3822 | { |
|---|
| 3823 | |
|---|
| 3824 | websWrite(wp, " <div class=\"setting\">\n"); |
|---|
| 3825 | websWrite(wp, |
|---|
| 3826 | " <div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.regulatory)</script></div>\n"); |
|---|
| 3827 | websWrite(wp, |
|---|
| 3828 | " <input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"ath_regulatory\" %s /><script type=\"text/javascript\">Capture(share.enable)</script> \n", |
|---|
| 3829 | nvram_match("ath_regulatory", "0") ? "checked" : ""); |
|---|
| 3830 | websWrite(wp, |
|---|
| 3831 | " <input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"ath_regulatory\" %s /><script type=\"text/javascript\">Capture(share.disable)</script>\n", |
|---|
| 3832 | nvram_match("ath_regulatory", "1") ? "checked" : ""); |
|---|
| 3833 | websWrite(wp, " </div>\n"); |
|---|
| 3834 | |
|---|
| 3835 | } |
|---|
| 3836 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3837 | websWrite(wp, |
|---|
| 3838 | "<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", |
|---|
| 3839 | power, |
|---|
| 3840 | atoi(nvram_safe_get(power)) + wifi_gettxpoweroffset(prefix)); |
|---|
| 3841 | websWrite(wp, "</div>\n"); |
|---|
| 3842 | sprintf(power, "%s_antgain", prefix); |
|---|
| 3843 | #ifndef HAVE_MAKSAT |
|---|
| 3844 | if (nvram_match("ath_regulatory", "1")) |
|---|
| 3845 | #endif |
|---|
| 3846 | { |
|---|
| 3847 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3848 | websWrite(wp, |
|---|
| 3849 | "<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", |
|---|
| 3850 | power, nvram_safe_get(power)); |
|---|
| 3851 | websWrite(wp, "</div>\n"); |
|---|
| 3852 | } |
|---|
| 3853 | #endif |
|---|
| 3854 | |
|---|
| 3855 | #ifdef HAVE_MADWIFI |
|---|
| 3856 | // if (!strcmp (prefix, "ath0")) |
|---|
| 3857 | #endif |
|---|
| 3858 | { |
|---|
| 3859 | // #ifdef HAVE_MADWIFI |
|---|
| 3860 | // if (!strcmp (prefix, "ath0")) //show client only on first |
|---|
| 3861 | // interface |
|---|
| 3862 | // #endif |
|---|
| 3863 | { |
|---|
| 3864 | #ifdef HAVE_MADWIFI |
|---|
| 3865 | // if (!strcmp (prefix, "ath0")) //show client only on first |
|---|
| 3866 | // interface |
|---|
| 3867 | // if (nvram_match ("ath0_mode", "wdsap") |
|---|
| 3868 | // || nvram_match ("ath0_mode", "wdssta")) |
|---|
| 3869 | // showOption (wp, "wl_basic.wifi_bonding", "wifi_bonding"); |
|---|
| 3870 | #endif |
|---|
| 3871 | #ifdef HAVE_REGISTER |
|---|
| 3872 | int cpeonly = iscpe(); |
|---|
| 3873 | #else |
|---|
| 3874 | int cpeonly = 0; |
|---|
| 3875 | #endif |
|---|
| 3876 | websWrite(wp, |
|---|
| 3877 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label)</script></div><select name=\"%s\" >\n", |
|---|
| 3878 | wl_mode); |
|---|
| 3879 | websWrite(wp, |
|---|
| 3880 | "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3881 | if (!cpeonly) |
|---|
| 3882 | { |
|---|
| 3883 | websWrite(wp, |
|---|
| 3884 | "document.write(\"<option value=\\\"ap\\\" %s >\" + wl_basic.ap + \"</option>\");\n", |
|---|
| 3885 | nvram_match(wl_mode, |
|---|
| 3886 | "ap") ? |
|---|
| 3887 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3888 | } |
|---|
| 3889 | websWrite(wp, |
|---|
| 3890 | "document.write(\"<option value=\\\"sta\\\" %s >\" + wl_basic.client + \"</option>\");\n", |
|---|
| 3891 | nvram_match(wl_mode, |
|---|
| 3892 | "sta") ? |
|---|
| 3893 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3894 | #ifndef HAVE_RT2880 |
|---|
| 3895 | websWrite(wp, |
|---|
| 3896 | "document.write(\"<option value=\\\"wet\\\" %s >\" + wl_basic.clientBridge + \"</option>\");\n", |
|---|
| 3897 | nvram_match(wl_mode, |
|---|
| 3898 | "wet") ? |
|---|
| 3899 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3900 | #endif |
|---|
| 3901 | if (!cpeonly) |
|---|
| 3902 | websWrite(wp, |
|---|
| 3903 | "document.write(\"<option value=\\\"infra\\\" %s >\" + wl_basic.adhoc + \"</option>\");\n", |
|---|
| 3904 | nvram_match(wl_mode, |
|---|
| 3905 | "infra") ? |
|---|
| 3906 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3907 | #ifndef HAVE_MADWIFI |
|---|
| 3908 | if (!cpeonly) |
|---|
| 3909 | { |
|---|
| 3910 | websWrite(wp, |
|---|
| 3911 | "document.write(\"<option value=\\\"apsta\\\" %s >\" + wl_basic.repeater + \"</option>\");\n", |
|---|
| 3912 | nvram_match(wl_mode, |
|---|
| 3913 | "apsta") ? |
|---|
| 3914 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3915 | //#ifndef HAVE_RT2880 |
|---|
| 3916 | websWrite(wp, |
|---|
| 3917 | "document.write(\"<option value=\\\"apstawet\\\" %s >\" + wl_basic.repeaterbridge + \"</option>\");\n", |
|---|
| 3918 | nvram_match(wl_mode, |
|---|
| 3919 | "apstawet") ? |
|---|
| 3920 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3921 | } |
|---|
| 3922 | //#endif |
|---|
| 3923 | #else |
|---|
| 3924 | websWrite(wp, |
|---|
| 3925 | "document.write(\"<option value=\\\"wdssta\\\" %s >\" + wl_basic.wdssta + \"</option>\");\n", |
|---|
| 3926 | nvram_match(wl_mode, |
|---|
| 3927 | "wdssta") ? |
|---|
| 3928 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3929 | if (!cpeonly) |
|---|
| 3930 | { |
|---|
| 3931 | websWrite(wp, |
|---|
| 3932 | "document.write(\"<option value=\\\"wdsap\\\" %s >\" + wl_basic.wdsap + \"</option>\");\n", |
|---|
| 3933 | nvram_match(wl_mode, |
|---|
| 3934 | "wdsap") ? |
|---|
| 3935 | "selected=\\\"selected\\\"" : ""); |
|---|
| 3936 | } |
|---|
| 3937 | #endif |
|---|
| 3938 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3939 | websWrite(wp, "</select>\n"); |
|---|
| 3940 | websWrite(wp, "</div>\n"); |
|---|
| 3941 | } |
|---|
| 3942 | /* |
|---|
| 3943 | * #ifdef HAVE_MADWIFI else { |
|---|
| 3944 | * |
|---|
| 3945 | * |
|---|
| 3946 | * websWrite (wp, "<div class=\"setting\"><div |
|---|
| 3947 | * class=\"label\"><script |
|---|
| 3948 | * type=\"text/javascript\">Capture(wl_basic.label)</script></div><select |
|---|
| 3949 | * name=\"%s\">\n", wl_mode); websWrite (wp, "<script |
|---|
| 3950 | * type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option |
|---|
| 3951 | * value=\\\"ap\\\" %s >\" + wl_basic.ap + |
|---|
| 3952 | * \"</option>\");\n//]]>\n</script>\n", nvram_match (wl_mode, "ap") |
|---|
| 3953 | * ? "selected=\\\"selected\\\"" : ""); websWrite (wp, "<script |
|---|
| 3954 | * type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option |
|---|
| 3955 | * value=\\\"infra\\\" %s >\" + wl_basic.adhoc + |
|---|
| 3956 | * \"</option>\");\n//]]>\n</script>\n", nvram_match (wl_mode, |
|---|
| 3957 | * "infra") ? "selected=\\\"selected\\\"" : ""); websWrite (wp, |
|---|
| 3958 | * "<script type=\"text/javascript\">\n//<![CDATA[\n |
|---|
| 3959 | * document.write(\"<option value=\\\"wdssta\\\" %s >\" + |
|---|
| 3960 | * wl_basic.wdssta + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 3961 | * nvram_match (wl_mode, "wdssta") ? "selected=\\\"selected\\\"" : |
|---|
| 3962 | * ""); websWrite (wp, "<script |
|---|
| 3963 | * type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option |
|---|
| 3964 | * value=\\\"wdsap\\\" %s >\" + wl_basic.wdsap + |
|---|
| 3965 | * \"</option>\");\n//]]>\n</script>\n", nvram_match (wl_mode, |
|---|
| 3966 | * "wdsap") ? "selected=\\\"selected\\\"" : ""); websWrite (wp, |
|---|
| 3967 | * "</select>\n"); websWrite (wp, "</div>\n"); } #endif |
|---|
| 3968 | */ |
|---|
| 3969 | } |
|---|
| 3970 | // writeless net mode |
|---|
| 3971 | show_netmode(wp, prefix); |
|---|
| 3972 | // turbo options |
|---|
| 3973 | #ifdef HAVE_MADWIFI |
|---|
| 3974 | |
|---|
| 3975 | // char wl_xchanmode[16]; |
|---|
| 3976 | char wl_outdoor[16]; |
|---|
| 3977 | char wl_diversity[16]; |
|---|
| 3978 | char wl_rxantenna[16]; |
|---|
| 3979 | char wl_txantenna[16]; |
|---|
| 3980 | char wl_width[16]; |
|---|
| 3981 | char wl_preamble[16]; |
|---|
| 3982 | char wl_xr[16]; |
|---|
| 3983 | char wl_comp[32]; |
|---|
| 3984 | char wl_ff[16]; |
|---|
| 3985 | char wmm[32]; |
|---|
| 3986 | char wl_isolate[32]; |
|---|
| 3987 | char wl_sifstime[32]; |
|---|
| 3988 | char wl_preambletime[32]; |
|---|
| 3989 | char wl_intmit[32]; |
|---|
| 3990 | char wl_noise_immunity[32]; |
|---|
| 3991 | char wl_ofdm_weak_det[32]; |
|---|
| 3992 | char wl_protmode[32]; |
|---|
| 3993 | char wl_doth[32]; |
|---|
| 3994 | char wl_csma[32]; |
|---|
| 3995 | |
|---|
| 3996 | sprintf(wl_csma, "%s_csma", prefix); |
|---|
| 3997 | sprintf(wl_doth, "%s_doth", prefix); |
|---|
| 3998 | sprintf(wl_protmode, "%s_protmode", prefix); |
|---|
| 3999 | sprintf(wl_outdoor, "%s_outdoor", prefix); |
|---|
| 4000 | sprintf(wl_diversity, "%s_diversity", prefix); |
|---|
| 4001 | sprintf(wl_rxantenna, "%s_rxantenna", prefix); |
|---|
| 4002 | sprintf(wl_txantenna, "%s_txantenna", prefix); |
|---|
| 4003 | sprintf(wl_width, "%s_channelbw", prefix); |
|---|
| 4004 | // sprintf( wl_comp, "%s_compression", prefix ); |
|---|
| 4005 | sprintf(wl_ff, "%s_ff", prefix); |
|---|
| 4006 | sprintf(wl_preamble, "%s_preamble", prefix); |
|---|
| 4007 | sprintf(wl_preambletime, "%s_preambletime", prefix); |
|---|
| 4008 | sprintf(wl_sifstime, "%s_sifstime", prefix); |
|---|
| 4009 | sprintf(wl_xr, "%s_xr", prefix); |
|---|
| 4010 | |
|---|
| 4011 | sprintf(wl_intmit, "%s_intmit", prefix); |
|---|
| 4012 | sprintf(wl_noise_immunity, "%s_noise_immunity", prefix); |
|---|
| 4013 | sprintf(wl_ofdm_weak_det, "%s_ofdm_weak_det", prefix); |
|---|
| 4014 | showAutoOption(wp, "wl_basic.intmit", wl_intmit); |
|---|
| 4015 | |
|---|
| 4016 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4017 | websWrite(wp, |
|---|
| 4018 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.noise_immunity)</script></div>\n<select name=\"%s\">\n", |
|---|
| 4019 | wl_noise_immunity); |
|---|
| 4020 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 4021 | websWrite(wp, |
|---|
| 4022 | "document.write(\"<option value=\\\"-1\\\" %s >\" + share.auto + \"</option>\");\n", |
|---|
| 4023 | nvram_default_match(wl_noise_immunity, "-1", |
|---|
| 4024 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4025 | websWrite(wp, |
|---|
| 4026 | "document.write(\"<option value=\\\"0\\\" %s >0</option>\");\n", |
|---|
| 4027 | nvram_default_match(wl_noise_immunity, "0", |
|---|
| 4028 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4029 | websWrite(wp, |
|---|
| 4030 | "document.write(\"<option value=\\\"1\\\" %s >1</option>\");\n", |
|---|
| 4031 | nvram_default_match(wl_noise_immunity, "1", |
|---|
| 4032 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4033 | websWrite(wp, |
|---|
| 4034 | "document.write(\"<option value=\\\"2\\\" %s >2</option>\");\n", |
|---|
| 4035 | nvram_default_match(wl_noise_immunity, "2", |
|---|
| 4036 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4037 | websWrite(wp, |
|---|
| 4038 | "document.write(\"<option value=\\\"3\\\" %s >3</option>\");\n", |
|---|
| 4039 | nvram_default_match(wl_noise_immunity, "3", |
|---|
| 4040 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4041 | websWrite(wp, |
|---|
| 4042 | "document.write(\"<option value=\\\"4\\\" %s >4</option>\");\n", |
|---|
| 4043 | nvram_default_match(wl_noise_immunity, "4", |
|---|
| 4044 | "-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4045 | websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 4046 | |
|---|
| 4047 | showRadio(wp, "wl_basic.ofdm_weak_det", wl_ofdm_weak_det); |
|---|
| 4048 | |
|---|
| 4049 | showOptionsLabel(wp, "wl_basic.protmode", wl_protmode, |
|---|
| 4050 | "None CTS RTS/CTS", nvram_default_get(wl_protmode, |
|---|
| 4051 | "None")); |
|---|
| 4052 | showrtssettings(wp, prefix); |
|---|
| 4053 | show_rates(wp, prefix, 0); |
|---|
| 4054 | show_rates(wp, prefix, 1); |
|---|
| 4055 | showRadio(wp, "wl_basic.preamble", wl_preamble); |
|---|
| 4056 | showRadio(wp, "wl_basic.extrange", wl_xr); |
|---|
| 4057 | // showRadio( wp, "wl_basic.supergcomp", wl_comp ); |
|---|
| 4058 | showRadio(wp, "wl_basic.supergff", wl_ff); |
|---|
| 4059 | #if 0 |
|---|
| 4060 | showRadio(wp, "wl_basic.csma", wl_csma); |
|---|
| 4061 | #endif |
|---|
| 4062 | // showOption (wp, "wl_basic.extchannel", wl_xchanmode); |
|---|
| 4063 | #if !defined(HAVE_FONERA) && !defined(HAVE_LS2) && !defined(HAVE_MERAKI) |
|---|
| 4064 | if (nvram_match("ath_regulatory", "1") || !issuperchannel()) { |
|---|
| 4065 | showRadio(wp, "wl_basic.outband", wl_outdoor); |
|---|
| 4066 | } |
|---|
| 4067 | #endif |
|---|
| 4068 | websWrite(wp, |
|---|
| 4069 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_width)</script></div><select name=\"%s\" >\n", |
|---|
| 4070 | wl_width); |
|---|
| 4071 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 4072 | websWrite(wp, |
|---|
| 4073 | "document.write(\"<option value=\\\"40\\\" %s >\" + share.turbo + \"</option>\");\n", |
|---|
| 4074 | nvram_match(wl_width, |
|---|
| 4075 | "40") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4076 | websWrite(wp, |
|---|
| 4077 | "document.write(\"<option value=\\\"20\\\" %s >\" + share.full + \"</option>\");\n", |
|---|
| 4078 | nvram_match(wl_width, |
|---|
| 4079 | "20") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4080 | websWrite(wp, |
|---|
| 4081 | "document.write(\"<option value=\\\"10\\\" %s >\" + share.half + \"</option>\");\n", |
|---|
| 4082 | nvram_match(wl_width, |
|---|
| 4083 | "10") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4084 | websWrite(wp, |
|---|
| 4085 | "document.write(\"<option value=\\\"5\\\" %s >\" + share.quarter + \"</option>\");\n", |
|---|
| 4086 | nvram_match(wl_width, |
|---|
| 4087 | "5") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4088 | #ifdef HAVE_SUBQUARTER |
|---|
| 4089 | /* will be enabled once it is tested and the spectrum analyse is done */ |
|---|
| 4090 | websWrite(wp, |
|---|
| 4091 | "document.write(\"<option value=\\\"2\\\" %s >\" + share.subquarter + \"</option>\");\n", |
|---|
| 4092 | nvram_match(wl_width, |
|---|
| 4093 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4094 | #endif |
|---|
| 4095 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4096 | websWrite(wp, "</select>\n"); |
|---|
| 4097 | websWrite(wp, "</div>\n"); |
|---|
| 4098 | #if defined(HAVE_EOC5610) |
|---|
| 4099 | /* websWrite(wp, |
|---|
| 4100 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label25)</script></div><select name=\"%s\" >\n", |
|---|
| 4101 | wl_txantenna); |
|---|
| 4102 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 4103 | websWrite(wp, |
|---|
| 4104 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.ghz5 + \"</option>\");\n", |
|---|
| 4105 | nvram_match(wl_txantenna, |
|---|
| 4106 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4107 | websWrite(wp, |
|---|
| 4108 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.ghz24 + \"</option>\");\n", |
|---|
| 4109 | nvram_match(wl_txantenna, |
|---|
| 4110 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4111 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4112 | |
|---|
| 4113 | websWrite(wp, "</select>\n"); |
|---|
| 4114 | websWrite(wp, "</div>\n");*/ |
|---|
| 4115 | #elif defined(HAVE_EOC2610) || defined(HAVE_PICO2) || defined(HAVE_PICO2HP) || defined(HAVE_PICO5) |
|---|
| 4116 | |
|---|
| 4117 | /* websWrite( wp, |
|---|
| 4118 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label25)</script></div><select name=\"%s\" >\n", |
|---|
| 4119 | wl_txantenna ); |
|---|
| 4120 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 4121 | websWrite( wp, |
|---|
| 4122 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.internal + \"</option>\");\n", |
|---|
| 4123 | nvram_match( wl_txantenna, |
|---|
| 4124 | "1" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 4125 | websWrite( wp, |
|---|
| 4126 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.external + \"</option>\");\n", |
|---|
| 4127 | nvram_match( wl_txantenna, |
|---|
| 4128 | "2" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 4129 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4130 | |
|---|
| 4131 | websWrite( wp, "</select>\n" ); |
|---|
| 4132 | websWrite( wp, "</div>\n" );*/ |
|---|
| 4133 | #elif defined(HAVE_EOC1650) |
|---|
| 4134 | /* websWrite( wp, |
|---|
| 4135 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label25)</script></div><select name=\"%s\" >\n", |
|---|
| 4136 | wl_txantenna ); |
|---|
| 4137 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 4138 | websWrite( wp, |
|---|
| 4139 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.internal + \"</option>\");\n", |
|---|
| 4140 | nvram_match( wl_txantenna, |
|---|
| 4141 | "2" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 4142 | websWrite( wp, |
|---|
| 4143 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.external + \"</option>\");\n", |
|---|
| 4144 | nvram_match( wl_txantenna, |
|---|
| 4145 | "1" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 4146 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4147 | |
|---|
| 4148 | websWrite( wp, "</select>\n" ); |
|---|
| 4149 | websWrite( wp, "</div>\n" );*/ |
|---|
| 4150 | #elif defined(HAVE_NS2) || defined(HAVE_NS5) || defined(HAVE_LC2) || defined(HAVE_LC5) || defined(HAVE_NS3) |
|---|
| 4151 | |
|---|
| 4152 | websWrite(wp, |
|---|
| 4153 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label24)</script></div><select name=\"%s\" >\n", |
|---|
| 4154 | wl_txantenna); |
|---|
| 4155 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 4156 | websWrite(wp, |
|---|
| 4157 | "document.write(\"<option value=\\\"0\\\" %s >\" + wl_basic.vertical + \"</option>\");\n", |
|---|
| 4158 | nvram_match(wl_txantenna, |
|---|
| 4159 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4160 | websWrite(wp, |
|---|
| 4161 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.horizontal + \"</option>\");\n", |
|---|
| 4162 | nvram_match(wl_txantenna, |
|---|
| 4163 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4164 | #if defined(HAVE_NS5) || defined(HAVE_NS2) || defined(HAVE_NS3) |
|---|
| 4165 | websWrite(wp, |
|---|
| 4166 | "document.write(\"<option value=\\\"3\\\" %s >\" + wl_basic.adaptive + \"</option>\");\n", |
|---|
| 4167 | nvram_match(wl_txantenna, |
|---|
| 4168 | "3") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4169 | websWrite(wp, |
|---|
| 4170 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.external + \"</option>\");\n", |
|---|
| 4171 | nvram_match(wl_txantenna, |
|---|
| 4172 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4173 | #endif |
|---|
| 4174 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4175 | |
|---|
| 4176 | websWrite(wp, "</select>\n"); |
|---|
| 4177 | websWrite(wp, "</div>\n"); |
|---|
| 4178 | |
|---|
| 4179 | #else |
|---|
| 4180 | showRadio(wp, "wl_basic.diversity", wl_diversity); |
|---|
| 4181 | websWrite(wp, |
|---|
| 4182 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label12)</script></div><select name=\"%s\" >\n", |
|---|
| 4183 | wl_txantenna); |
|---|
| 4184 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 4185 | websWrite(wp, |
|---|
| 4186 | "document.write(\"<option value=\\\"0\\\" %s >\" + wl_basic.diversity + \"</option>\");\n", |
|---|
| 4187 | nvram_match(wl_txantenna, |
|---|
| 4188 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4189 | websWrite(wp, |
|---|
| 4190 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.primary + \"</option>\");\n", |
|---|
| 4191 | nvram_match(wl_txantenna, |
|---|
| 4192 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4193 | websWrite(wp, |
|---|
| 4194 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.secondary + \"</option>\");\n", |
|---|
| 4195 | nvram_match(wl_txantenna, |
|---|
| 4196 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4197 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4198 | websWrite(wp, "</select>\n"); |
|---|
| 4199 | websWrite(wp, "</div>\n"); |
|---|
| 4200 | |
|---|
| 4201 | websWrite(wp, |
|---|
| 4202 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label13)</script></div><select name=\"%s\" >\n", |
|---|
| 4203 | wl_rxantenna); |
|---|
| 4204 | websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 4205 | websWrite(wp, |
|---|
| 4206 | "document.write(\"<option value=\\\"0\\\" %s >\" + wl_basic.diversity + \"</option>\");\n", |
|---|
| 4207 | nvram_match(wl_rxantenna, |
|---|
| 4208 | "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4209 | websWrite(wp, |
|---|
| 4210 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.primary + \"</option>\");\n", |
|---|
| 4211 | nvram_match(wl_rxantenna, |
|---|
| 4212 | "1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4213 | websWrite(wp, |
|---|
| 4214 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.secondary + \"</option>\");\n", |
|---|
| 4215 | nvram_match(wl_rxantenna, |
|---|
| 4216 | "2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 4217 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4218 | websWrite(wp, "</select>\n"); |
|---|
| 4219 | websWrite(wp, "</div>\n"); |
|---|
| 4220 | #endif |
|---|
| 4221 | #endif |
|---|
| 4222 | #ifdef HAVE_MADWIFI |
|---|
| 4223 | sprintf(wl_isolate, "%s_ap_isolate", prefix); |
|---|
| 4224 | showRadio(wp, "wl_adv.label11", wl_isolate); |
|---|
| 4225 | |
|---|
| 4226 | #if 0 |
|---|
| 4227 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4228 | websWrite(wp, |
|---|
| 4229 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.sifstime)</script></div>\n"); |
|---|
| 4230 | websWrite(wp, |
|---|
| 4231 | "<input class=\"num\" name=\"%s\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,99999999,wl_basic.sifstime)\" value=\"%s\" />\n", |
|---|
| 4232 | wl_sifstime, nvram_default_get(wl_sifstime, "16")); |
|---|
| 4233 | websWrite(wp, "</div>\n"); |
|---|
| 4234 | |
|---|
| 4235 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4236 | websWrite(wp, |
|---|
| 4237 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.preambletime)</script></div>\n"); |
|---|
| 4238 | websWrite(wp, |
|---|
| 4239 | "<input class=\"num\" name=\"%s\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,99999999,wl_basic.preambletime)\" value=\"%s\" />\n", |
|---|
| 4240 | wl_preambletime, nvram_default_get(wl_preambletime, "20")); |
|---|
| 4241 | websWrite(wp, "</div>\n"); |
|---|
| 4242 | #endif |
|---|
| 4243 | sprintf(wmm, "%s_wmm", prefix); |
|---|
| 4244 | showRadio(wp, "wl_adv.label18", wmm); |
|---|
| 4245 | #endif |
|---|
| 4246 | |
|---|
| 4247 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4248 | websWrite(wp, |
|---|
| 4249 | "<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", |
|---|
| 4250 | wl_ssid, nvram_safe_get(wl_ssid)); |
|---|
| 4251 | |
|---|
| 4252 | #ifdef HAVE_MADWIFI |
|---|
| 4253 | showRadio(wp, "wl_basic.radar", wl_doth); |
|---|
| 4254 | show_chanshift(wp, prefix); |
|---|
| 4255 | #endif |
|---|
| 4256 | #ifdef HAVE_RT2880 |
|---|
| 4257 | if (nvram_match(wl_mode, "ap") || nvram_match(wl_mode, "wdsap") |
|---|
| 4258 | || nvram_match(wl_mode, "infra") || nvram_match(wl_mode, "apsta") |
|---|
| 4259 | || nvram_match(wl_mode, "apstawet")) |
|---|
| 4260 | #else |
|---|
| 4261 | if (nvram_match(wl_mode, "ap") || nvram_match(wl_mode, "wdsap") |
|---|
| 4262 | || nvram_match(wl_mode, "infra")) |
|---|
| 4263 | #endif |
|---|
| 4264 | { |
|---|
| 4265 | |
|---|
| 4266 | if (has_mimo(prefix) |
|---|
| 4267 | && (nvram_nmatch("n-only", "%s_net_mode", prefix) |
|---|
| 4268 | || nvram_nmatch("mixed", "%s_net_mode", prefix) |
|---|
| 4269 | || nvram_nmatch("na-only", "%s_net_mode", prefix))) { |
|---|
| 4270 | show_channel(wp, prefix, prefix, 1); |
|---|
| 4271 | |
|---|
| 4272 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4273 | websWrite(wp, |
|---|
| 4274 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_width)</script></div>\n"); |
|---|
| 4275 | websWrite(wp, "<select name=\"%s_nbw\">\n", prefix); |
|---|
| 4276 | #ifdef HAVE_RT2880 |
|---|
| 4277 | websWrite(wp, |
|---|
| 4278 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"20\\\" %s >20 Mhz</option>\");\n//]]>\n</script>\n", |
|---|
| 4279 | nvram_nmatch("20", "%s_nbw", |
|---|
| 4280 | prefix) ? |
|---|
| 4281 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4282 | websWrite(wp, "<option value=\"40\" %s>40 MHz</option>", |
|---|
| 4283 | nvram_nmatch("40", "%s_nbw", |
|---|
| 4284 | prefix) ? |
|---|
| 4285 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4286 | #else |
|---|
| 4287 | websWrite(wp, |
|---|
| 4288 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"0\\\" %s >\" + share.auto + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 4289 | nvram_nmatch("0", "%s_nbw", |
|---|
| 4290 | prefix) ? |
|---|
| 4291 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4292 | websWrite(wp, |
|---|
| 4293 | "<option value=\"10\" %s>10 MHz</option>\n", |
|---|
| 4294 | nvram_nmatch("10", "%s_nbw", |
|---|
| 4295 | prefix) ? |
|---|
| 4296 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4297 | websWrite(wp, |
|---|
| 4298 | "<option value=\"20\" %s>20 MHz</option>\n", |
|---|
| 4299 | nvram_nmatch("20", "%s_nbw", |
|---|
| 4300 | prefix) ? |
|---|
| 4301 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4302 | websWrite(wp, |
|---|
| 4303 | "<option value=\"40\" %s>40 MHz</option>\n", |
|---|
| 4304 | nvram_nmatch("40", "%s_nbw", |
|---|
| 4305 | prefix) ? |
|---|
| 4306 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4307 | #endif |
|---|
| 4308 | websWrite(wp, "</select>\n"); |
|---|
| 4309 | websWrite(wp, "</div>\n"); |
|---|
| 4310 | |
|---|
| 4311 | if (nvram_nmatch("40", "%s_nbw", prefix)) { |
|---|
| 4312 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4313 | // websWrite( wp, |
|---|
| 4314 | // "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_wide)</script></div>\n" ); |
|---|
| 4315 | // websWrite( wp, "<select name=\"%s_wchannel\" ></select>\n", |
|---|
| 4316 | // prefix ); |
|---|
| 4317 | |
|---|
| 4318 | //////////////////////// |
|---|
| 4319 | websWrite(wp, |
|---|
| 4320 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_wide)</script></div>\n"); |
|---|
| 4321 | websWrite(wp, "<select name=\"%s_nctrlsb\" >\n", |
|---|
| 4322 | prefix); |
|---|
| 4323 | websWrite(wp, |
|---|
| 4324 | "<option value=\"upper\" %s>lower</option>\n", |
|---|
| 4325 | nvram_nmatch("upper", "%s_nctrlsb", |
|---|
| 4326 | prefix) ? |
|---|
| 4327 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4328 | websWrite(wp, |
|---|
| 4329 | "<option value=\"lower\" %s>upper</option>\n", |
|---|
| 4330 | nvram_nmatch("lower", "%s_nctrlsb", |
|---|
| 4331 | prefix) ? |
|---|
| 4332 | "selected=\\\"selected\\\"" : ""); |
|---|
| 4333 | websWrite(wp, "</select>\n"); |
|---|
| 4334 | //////////////////////// |
|---|
| 4335 | |
|---|
| 4336 | websWrite(wp, "</div>\n"); |
|---|
| 4337 | } |
|---|
| 4338 | } else |
|---|
| 4339 | |
|---|
| 4340 | show_channel(wp, prefix, prefix, 0); |
|---|
| 4341 | |
|---|
| 4342 | char wl_closed[16]; |
|---|
| 4343 | |
|---|
| 4344 | sprintf(wl_closed, "%s_closed", prefix); |
|---|
| 4345 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4346 | websWrite(wp, |
|---|
| 4347 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label5)</script></div>\n"); |
|---|
| 4348 | websWrite(wp, |
|---|
| 4349 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input> \n", |
|---|
| 4350 | wl_closed, nvram_match(wl_closed, |
|---|
| 4351 | "0") ? "checked=\"checked\"" : |
|---|
| 4352 | ""); |
|---|
| 4353 | websWrite(wp, |
|---|
| 4354 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input>\n", |
|---|
| 4355 | wl_closed, nvram_match(wl_closed, |
|---|
| 4356 | "1") ? "checked=\"checked\"" : |
|---|
| 4357 | ""); |
|---|
| 4358 | websWrite(wp, "</div>\n"); |
|---|
| 4359 | } |
|---|
| 4360 | #ifdef HAVE_MADWIFI |
|---|
| 4361 | // if (nvram_match (wl_mode, "sta") || nvram_match (wl_mode, "wdssta") |
|---|
| 4362 | // || nvram_match (wl_mode, "wet")) |
|---|
| 4363 | { |
|---|
| 4364 | char wl_scanlist[32]; |
|---|
| 4365 | |
|---|
| 4366 | sprintf(wl_scanlist, "%s_scanlist", prefix); |
|---|
| 4367 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4368 | websWrite(wp, |
|---|
| 4369 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.scanlist)</script></div>\n"); |
|---|
| 4370 | websWrite(wp, |
|---|
| 4371 | "<input name=\"%s\" size=\"32\" maxlength=\"512\" value=\"%s\" />\n", |
|---|
| 4372 | wl_scanlist, nvram_default_get(wl_scanlist, |
|---|
| 4373 | "default")); |
|---|
| 4374 | websWrite(wp, "</div>\n"); |
|---|
| 4375 | } |
|---|
| 4376 | #endif |
|---|
| 4377 | |
|---|
| 4378 | // ACK timing |
|---|
| 4379 | #if defined(HAVE_ACK) || defined(HAVE_MADWIFI) // temp fix for v24 broadcom |
|---|
| 4380 | // ACKnot working |
|---|
| 4381 | |
|---|
| 4382 | sprintf(power, "%s_distance", prefix); |
|---|
| 4383 | websWrite(wp, "<br />\n"); |
|---|
| 4384 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4385 | websWrite(wp, |
|---|
| 4386 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label6)</script></div>\n"); |
|---|
| 4387 | websWrite(wp, |
|---|
| 4388 | "<input class=\"num\" name=\"%s\" size=\"8\" maxlength=\"8\" onblur=\"valid_range(this,0,99999999,wl_basic.label6)\" value=\"%s\" />\n", |
|---|
| 4389 | power, nvram_default_get(power, "2000")); |
|---|
| 4390 | websWrite(wp, |
|---|
| 4391 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 2000 \" + share.meters + \")\");\n//]]>\n</script></span>\n"); |
|---|
| 4392 | websWrite(wp, "</div>\n"); |
|---|
| 4393 | // end ACK timing |
|---|
| 4394 | #endif |
|---|
| 4395 | #ifdef HAVE_MADWIFI |
|---|
| 4396 | if (nvram_nmatch("ap", "%s_mode", prefix) |
|---|
| 4397 | || nvram_nmatch("wdsap", "%s_mode", prefix) |
|---|
| 4398 | || nvram_nmatch("infra", "%s_mode", prefix)) { |
|---|
| 4399 | sprintf(power, "%s_maxassoc", prefix); |
|---|
| 4400 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4401 | websWrite(wp, |
|---|
| 4402 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label10)</script></div>\n"); |
|---|
| 4403 | websWrite(wp, |
|---|
| 4404 | "<input class=\"num\" name=\"%s\" size=\"4\" maxlength=\"4\" onblur=\"valid_range(this,0,256,wl_basic.label6)\" value=\"%s\" />\n", |
|---|
| 4405 | power, nvram_default_get(power, "256")); |
|---|
| 4406 | websWrite(wp, |
|---|
| 4407 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 256 \" + share.user + \")\");\n//]]>\n</script></span>\n"); |
|---|
| 4408 | websWrite(wp, "</div>\n"); |
|---|
| 4409 | } |
|---|
| 4410 | sprintf(power, "%s_mtikie", prefix); |
|---|
| 4411 | nvram_default_get(power, "0"); |
|---|
| 4412 | showRadio(wp, "wl_basic.mtikie", power); |
|---|
| 4413 | |
|---|
| 4414 | showbridgesettings(wp, prefix, 1, 1); |
|---|
| 4415 | #elif HAVE_RT2880 |
|---|
| 4416 | showbridgesettings(wp, "ra0", 1, 1); |
|---|
| 4417 | #else |
|---|
| 4418 | if (!strcmp(prefix, "wl0")) |
|---|
| 4419 | showbridgesettings(wp, get_wl_instance_name(0), 1, 1); |
|---|
| 4420 | if (!strcmp(prefix, "wl1")) |
|---|
| 4421 | showbridgesettings(wp, get_wl_instance_name(1), 1, 1); |
|---|
| 4422 | #endif |
|---|
| 4423 | websWrite(wp, "</fieldset>\n"); |
|---|
| 4424 | websWrite(wp, "<br />\n"); |
|---|
| 4425 | if (!iscpe()) |
|---|
| 4426 | show_virtualssid(wp, prefix); |
|---|
| 4427 | } |
|---|
| 4428 | |
|---|
| 4429 | void ej_show_wireless(webs_t wp, int argc, char_t ** argv) |
|---|
| 4430 | { |
|---|
| 4431 | #ifdef HAVE_MADWIFI |
|---|
| 4432 | int c = getdevicecount(); |
|---|
| 4433 | int i; |
|---|
| 4434 | |
|---|
| 4435 | for (i = 0; i < c; i++) { |
|---|
| 4436 | char buf[16]; |
|---|
| 4437 | |
|---|
| 4438 | sprintf(buf, "ath%d", i); |
|---|
| 4439 | ej_show_wireless_single(wp, buf); |
|---|
| 4440 | } |
|---|
| 4441 | #else |
|---|
| 4442 | int c = get_wl_instances(); |
|---|
| 4443 | int i; |
|---|
| 4444 | |
|---|
| 4445 | for (i = 0; i < c; i++) { |
|---|
| 4446 | char buf[16]; |
|---|
| 4447 | |
|---|
| 4448 | sprintf(buf, "wl%d", i); |
|---|
| 4449 | ej_show_wireless_single(wp, buf); |
|---|
| 4450 | } |
|---|
| 4451 | #endif |
|---|
| 4452 | return; |
|---|
| 4453 | } |
|---|
| 4454 | |
|---|
| 4455 | void show_preshared(webs_t wp, char *prefix) |
|---|
| 4456 | { |
|---|
| 4457 | char var[80]; |
|---|
| 4458 | |
|---|
| 4459 | cprintf("show preshared"); |
|---|
| 4460 | sprintf(var, "%s_crypto", prefix); |
|---|
| 4461 | websWrite(wp, "<div><div class=\"setting\">\n"); |
|---|
| 4462 | websWrite(wp, |
|---|
| 4463 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.algorithms)</script></div>\n"); |
|---|
| 4464 | websWrite(wp, "<select name=\"%s_crypto\">\n", prefix); |
|---|
| 4465 | websWrite(wp, "<option value=\"tkip\" %s>TKIP</option>\n", |
|---|
| 4466 | selmatch(var, "tkip", "selected=\"selected\"")); |
|---|
| 4467 | websWrite(wp, "<option value=\"aes\" %s>AES</option>\n", |
|---|
| 4468 | selmatch(var, "aes", "selected=\"selected\"")); |
|---|
| 4469 | websWrite(wp, "<option value=\"tkip+aes\" %s>TKIP+AES</option>\n", |
|---|
| 4470 | selmatch(var, "tkip+aes", "selected=\"selected\"")); |
|---|
| 4471 | websWrite(wp, "</select>\n"); |
|---|
| 4472 | websWrite(wp, "</div>\n"); |
|---|
| 4473 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4474 | websWrite(wp, |
|---|
| 4475 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.shared_key)</script></div>\n"); |
|---|
| 4476 | sprintf(var, "%s_wpa_psk", prefix); |
|---|
| 4477 | websWrite(wp, |
|---|
| 4478 | "<input type=\"password\" id=\"%s_wpa_psk\" name=\"%s_wpa_psk\" onblur=\"valid_psk_length(this)\" maxlength=\"64\" size=\"32\" value=\"", |
|---|
| 4479 | prefix, prefix); |
|---|
| 4480 | tf_webWriteESCNV(wp, var); |
|---|
| 4481 | websWrite(wp, "\" /> \n"); |
|---|
| 4482 | websWrite(wp, |
|---|
| 4483 | "<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", |
|---|
| 4484 | prefix, prefix); |
|---|
| 4485 | websWrite(wp, "</div>\n"); |
|---|
| 4486 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4487 | websWrite(wp, |
|---|
| 4488 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.rekey)</script></div>\n"); |
|---|
| 4489 | sprintf(var, "%s_wpa_gtk_rekey", prefix); |
|---|
| 4490 | websWrite(wp, |
|---|
| 4491 | "<input class=\"num\" name=\"%s_wpa_gtk_rekey\" maxlength=\"5\" size=\"5\" onblur=\"valid_range(this,0,99999,wpa.rekey)\" value=\"%s\" />\n", |
|---|
| 4492 | prefix, nvram_default_get(var, "3600")); |
|---|
| 4493 | websWrite(wp, |
|---|
| 4494 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 3600, \" + share.range + \": 1 - 99999)\");\n//]]>\n</script></span>\n"); |
|---|
| 4495 | websWrite(wp, "</div>\n"); |
|---|
| 4496 | websWrite(wp, "</div>\n"); |
|---|
| 4497 | } |
|---|
| 4498 | |
|---|
| 4499 | void show_radius(webs_t wp, char *prefix, int showmacformat) |
|---|
| 4500 | { |
|---|
| 4501 | char var[80]; |
|---|
| 4502 | |
|---|
| 4503 | cprintf("show radius\n"); |
|---|
| 4504 | if (showmacformat) { |
|---|
| 4505 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4506 | websWrite(wp, |
|---|
| 4507 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label2)</script></div>\n"); |
|---|
| 4508 | websWrite(wp, "<select name=\"%s_radmactype\">\n", prefix); |
|---|
| 4509 | websWrite(wp, |
|---|
| 4510 | "<option value=\"0\" %s >aabbcc-ddeeff</option>\n", |
|---|
| 4511 | nvram_prefix_match("radmactype", prefix, |
|---|
| 4512 | "0") ? "selected" : ""); |
|---|
| 4513 | websWrite(wp, "<option value=\"1\" %s >aabbccddeeff</option>\n", |
|---|
| 4514 | nvram_prefix_match("radmactype", prefix, |
|---|
| 4515 | "1") ? "selected" : ""); |
|---|
| 4516 | websWrite(wp, |
|---|
| 4517 | "<option value=\"2\" %s >aa:bb:cc:dd:ee:ff</option>\n", |
|---|
| 4518 | nvram_prefix_match("radmactype", prefix, |
|---|
| 4519 | "2") ? "selected" : ""); |
|---|
| 4520 | websWrite(wp, |
|---|
| 4521 | "<option value=\"3\" %s >aa-bb-cc-dd-ee-ff</option>\n", |
|---|
| 4522 | nvram_prefix_match("radmactype", prefix, |
|---|
| 4523 | "3") ? "selected" : ""); |
|---|
| 4524 | websWrite(wp, "</select>\n"); |
|---|
| 4525 | websWrite(wp, "</div>\n"); |
|---|
| 4526 | } |
|---|
| 4527 | char *rad = nvram_nget("%s_radius_ipaddr", prefix); |
|---|
| 4528 | |
|---|
| 4529 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4530 | websWrite(wp, |
|---|
| 4531 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label3)</script></div>\n"); |
|---|
| 4532 | websWrite(wp, |
|---|
| 4533 | "<input type=\"hidden\" name=\"%s_radius_ipaddr\" value=\"4\" />\n", |
|---|
| 4534 | prefix); |
|---|
| 4535 | websWrite(wp, |
|---|
| 4536 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_0\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4537 | prefix, get_single_ip(rad, 0)); |
|---|
| 4538 | websWrite(wp, |
|---|
| 4539 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_1\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4540 | prefix, get_single_ip(rad, 1)); |
|---|
| 4541 | websWrite(wp, |
|---|
| 4542 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_2\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4543 | prefix, get_single_ip(rad, 2)); |
|---|
| 4544 | websWrite(wp, |
|---|
| 4545 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_3\" onblur=\"valid_range(this,1,254,radius.label3)\" class=\"num\" value=\"%d\" />\n", |
|---|
| 4546 | prefix, get_single_ip(rad, 3)); |
|---|
| 4547 | websWrite(wp, "</div>\n"); |
|---|
| 4548 | |
|---|
| 4549 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4550 | websWrite(wp, |
|---|
| 4551 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label4)</script></div>\n"); |
|---|
| 4552 | sprintf(var, "%s_radius_port", prefix); |
|---|
| 4553 | websWrite(wp, |
|---|
| 4554 | "<input name=\"%s_radius_port\" size=\"3\" maxlength=\"5\" onblur=\"valid_range(this,1,65535,radius.label4)\" value=\"%s\" />\n", |
|---|
| 4555 | prefix, nvram_default_get(var, "1812")); |
|---|
| 4556 | websWrite(wp, |
|---|
| 4557 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 1812)\");\n//]]>\n</script></span>\n</div>\n"); |
|---|
| 4558 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4559 | websWrite(wp, |
|---|
| 4560 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label7)</script></div>\n"); |
|---|
| 4561 | sprintf(var, "%s_radius_key", prefix); |
|---|
| 4562 | websWrite(wp, |
|---|
| 4563 | "<input type=\"password\" id=\"%s_radius_key\" name=\"%s_radius_key\" maxlength=\"79\" size=\"32\" value=\"", |
|---|
| 4564 | prefix, prefix); |
|---|
| 4565 | tf_webWriteESCNV(wp, var); |
|---|
| 4566 | websWrite(wp, "\" /> \n"); |
|---|
| 4567 | websWrite(wp, |
|---|
| 4568 | "<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", |
|---|
| 4569 | prefix, prefix); |
|---|
| 4570 | websWrite(wp, "</div>\n"); |
|---|
| 4571 | #ifdef HAVE_MADWIFI |
|---|
| 4572 | if (!showmacformat) { |
|---|
| 4573 | char acct[32]; |
|---|
| 4574 | char vvar[32]; |
|---|
| 4575 | |
|---|
| 4576 | strcpy(vvar, var); |
|---|
| 4577 | rep(vvar, '.', 'X'); |
|---|
| 4578 | sprintf(acct, "%s_acct", prefix); |
|---|
| 4579 | websWrite(wp, |
|---|
| 4580 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label18)</script></div>\n"); |
|---|
| 4581 | websWrite(wp, |
|---|
| 4582 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" onclick=\"show_layer_ext(this, '%s_idacct', true);\" name=\"%s_acct\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input>\n", |
|---|
| 4583 | vvar, prefix, nvram_default_match(acct, "1", |
|---|
| 4584 | "0") ? |
|---|
| 4585 | "checked=\"checked\"" : ""); |
|---|
| 4586 | websWrite(wp, |
|---|
| 4587 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" onclick=\"show_layer_ext(this, '%s_idacct, false);\" name=\"%s_acct\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input> \n", |
|---|
| 4588 | vvar, prefix, nvram_default_match(acct, "0", |
|---|
| 4589 | "0") ? |
|---|
| 4590 | "checked=\"checked\"" : ""); |
|---|
| 4591 | websWrite(wp, "</div>\n"); |
|---|
| 4592 | char *rad = nvram_nget("%s_acct_ipaddr", prefix); |
|---|
| 4593 | |
|---|
| 4594 | websWrite(wp, "<div id=\"%s_idacct\">\n", vvar); |
|---|
| 4595 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4596 | websWrite(wp, |
|---|
| 4597 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label13)</script></div>\n"); |
|---|
| 4598 | websWrite(wp, |
|---|
| 4599 | "<input type=\"hidden\" name=\"%s_acct_ipaddr\" value=\"4\" />\n", |
|---|
| 4600 | prefix); |
|---|
| 4601 | websWrite(wp, |
|---|
| 4602 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_0\" onblur=\"valid_range(this,0,255,radius.label13)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4603 | prefix, get_single_ip(rad, 0)); |
|---|
| 4604 | websWrite(wp, |
|---|
| 4605 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_1\" onblur=\"valid_range(this,0,255,radius.label13)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4606 | prefix, get_single_ip(rad, 1)); |
|---|
| 4607 | websWrite(wp, |
|---|
| 4608 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_2\" onblur=\"valid_range(this,0,255,radius.label13)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4609 | prefix, get_single_ip(rad, 2)); |
|---|
| 4610 | websWrite(wp, |
|---|
| 4611 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_3\" onblur=\"valid_range(this,1,254,radius.label13)\" class=\"num\" value=\"%d\" />\n", |
|---|
| 4612 | prefix, get_single_ip(rad, 3)); |
|---|
| 4613 | websWrite(wp, "</div>\n"); |
|---|
| 4614 | |
|---|
| 4615 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4616 | websWrite(wp, |
|---|
| 4617 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label14)</script></div>\n"); |
|---|
| 4618 | sprintf(var, "%s_acct_port", prefix); |
|---|
| 4619 | websWrite(wp, |
|---|
| 4620 | "<input name=\"%s_acct_port\" size=\"3\" maxlength=\"5\" onblur=\"valid_range(this,1,65535,radius.label14)\" value=\"%s\" />\n", |
|---|
| 4621 | prefix, nvram_default_get(var, "1813")); |
|---|
| 4622 | websWrite(wp, |
|---|
| 4623 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 1812)\");\n//]]>\n</script></span>\n</div>\n"); |
|---|
| 4624 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4625 | websWrite(wp, |
|---|
| 4626 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label17)</script></div>\n"); |
|---|
| 4627 | sprintf(var, "%s_acct_key", prefix); |
|---|
| 4628 | websWrite(wp, |
|---|
| 4629 | "<input type=\"password\" id=\"%s_acct_key\" name=\"%s_acct_key\" maxlength=\"79\" size=\"32\" value=\"", |
|---|
| 4630 | prefix, prefix); |
|---|
| 4631 | tf_webWriteESCNV(wp, var); |
|---|
| 4632 | websWrite(wp, "\" /> \n"); |
|---|
| 4633 | websWrite(wp, |
|---|
| 4634 | "<input type=\"checkbox\" name=\"%s_acct_unmask\" value=\"0\" onclick=\"setElementMask('%s_acct_key', this.checked)\" > <script type=\"text/javascript\">Capture(share.unmask)</script></input>\n", |
|---|
| 4635 | prefix, prefix); |
|---|
| 4636 | websWrite(wp, "</div>\n"); |
|---|
| 4637 | websWrite(wp, "</div>\n"); |
|---|
| 4638 | websWrite(wp, "<script>\n//<![CDATA[\n "); |
|---|
| 4639 | websWrite(wp, |
|---|
| 4640 | "show_layer_ext(document.getElementsByName(\"%s_acct\"), \"%s_idacct\", %s);\n", |
|---|
| 4641 | prefix, vvar, nvram_match(acct, |
|---|
| 4642 | "1") ? "true" : "false"); |
|---|
| 4643 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4644 | } |
|---|
| 4645 | #endif |
|---|
| 4646 | } |
|---|
| 4647 | |
|---|
| 4648 | #ifdef HAVE_WPA_SUPPLICANT |
|---|
| 4649 | |
|---|
| 4650 | static void init_80211x_layers(webs_t wp, char *prefix) |
|---|
| 4651 | { |
|---|
| 4652 | if (nvram_prefix_match("8021xtype", prefix, "tls")) { |
|---|
| 4653 | websWrite(wp, "enable_idtls(\"%s\");\n", prefix); |
|---|
| 4654 | } |
|---|
| 4655 | if (nvram_prefix_match("8021xtype", prefix, "leap")) { |
|---|
| 4656 | websWrite(wp, "enable_idleap(\"%s\");\n", prefix); |
|---|
| 4657 | } |
|---|
| 4658 | if (nvram_prefix_match("8021xtype", prefix, "ttls")) { |
|---|
| 4659 | websWrite(wp, "enable_idttls(\"%s\");\n", prefix); |
|---|
| 4660 | } |
|---|
| 4661 | if (nvram_prefix_match("8021xtype", prefix, "peap")) { |
|---|
| 4662 | websWrite(wp, "enable_idpeap(\"%s\");\n", prefix); |
|---|
| 4663 | } |
|---|
| 4664 | } |
|---|
| 4665 | |
|---|
| 4666 | void ej_init_80211x_layers(webs_t wp, int argc, char_t ** argv) |
|---|
| 4667 | { |
|---|
| 4668 | #ifndef HAVE_MADWIFI |
|---|
| 4669 | int c = get_wl_instances(); |
|---|
| 4670 | int i; |
|---|
| 4671 | |
|---|
| 4672 | for (i = 0; i < c; i++) { |
|---|
| 4673 | char buf[16]; |
|---|
| 4674 | |
|---|
| 4675 | sprintf(buf, "wl%d", i); |
|---|
| 4676 | init_80211x_layers(wp, buf); |
|---|
| 4677 | } |
|---|
| 4678 | return; |
|---|
| 4679 | #else |
|---|
| 4680 | int c = getdevicecount(); |
|---|
| 4681 | int i; |
|---|
| 4682 | |
|---|
| 4683 | for (i = 0; i < c; i++) { |
|---|
| 4684 | char buf[16]; |
|---|
| 4685 | |
|---|
| 4686 | sprintf(buf, "ath%d", i); |
|---|
| 4687 | if (nvram_nmatch("8021X", "%s_security_mode", buf)) |
|---|
| 4688 | init_80211x_layers(wp, buf); |
|---|
| 4689 | } |
|---|
| 4690 | return; |
|---|
| 4691 | #endif |
|---|
| 4692 | |
|---|
| 4693 | } |
|---|
| 4694 | |
|---|
| 4695 | void show_80211X(webs_t wp, char *prefix) |
|---|
| 4696 | { |
|---|
| 4697 | /* |
|---|
| 4698 | * fields |
|---|
| 4699 | * _8021xtype |
|---|
| 4700 | * _8021xuser |
|---|
| 4701 | * _8021xpasswd |
|---|
| 4702 | * _8021xca |
|---|
| 4703 | * _8021xpem |
|---|
| 4704 | * _8021xprv |
|---|
| 4705 | */ |
|---|
| 4706 | char type[32]; |
|---|
| 4707 | |
|---|
| 4708 | sprintf(type, "%s_8021xtype", prefix); |
|---|
| 4709 | nvram_default_get(type, "ttls"); |
|---|
| 4710 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4711 | websWrite(wp, |
|---|
| 4712 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.xsuptype)</script></div>\n"); |
|---|
| 4713 | websWrite(wp, |
|---|
| 4714 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"peap\" onclick=\"enable_idpeap('%s')\" %s />Peap \n", |
|---|
| 4715 | prefix, prefix, nvram_prefix_match("8021xtype", prefix, |
|---|
| 4716 | "peap") ? |
|---|
| 4717 | "checked=\"checked\"" : ""); |
|---|
| 4718 | websWrite(wp, |
|---|
| 4719 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"leap\" onclick=\"enable_idleap('%s')\" %s />Leap \n", |
|---|
| 4720 | prefix, prefix, nvram_prefix_match("8021xtype", prefix, |
|---|
| 4721 | "leap") ? |
|---|
| 4722 | "checked=\"checked\"" : ""); |
|---|
| 4723 | websWrite(wp, |
|---|
| 4724 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"tls\" onclick=\"enable_idtls('%s')\" %s />TLS \n", |
|---|
| 4725 | prefix, prefix, nvram_prefix_match("8021xtype", prefix, |
|---|
| 4726 | "tls") ? |
|---|
| 4727 | "checked=\"checked\"" : ""); |
|---|
| 4728 | websWrite(wp, |
|---|
| 4729 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"ttls\" onclick=\"enable_idttls('%s')\" %s />TTLS \n", |
|---|
| 4730 | prefix, prefix, nvram_prefix_match("8021xtype", prefix, |
|---|
| 4731 | "ttls") ? |
|---|
| 4732 | "checked=\"checked\"" : ""); |
|---|
| 4733 | websWrite(wp, "</div>\n"); |
|---|
| 4734 | // ttls authentication |
|---|
| 4735 | websWrite(wp, "<div id=\"idttls%s\">\n", prefix); |
|---|
| 4736 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4737 | websWrite(wp, |
|---|
| 4738 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n"); |
|---|
| 4739 | websWrite(wp, |
|---|
| 4740 | "<input name=\"%s_ttls8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4741 | prefix, nvram_prefix_get("ttls8021xuser", prefix)); |
|---|
| 4742 | |
|---|
| 4743 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4744 | websWrite(wp, |
|---|
| 4745 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.anon)</script></div>\n"); |
|---|
| 4746 | websWrite(wp, |
|---|
| 4747 | "<input name=\"%s_ttls8021xanon\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4748 | prefix, nvram_prefix_get("ttls8021xanon", prefix)); |
|---|
| 4749 | |
|---|
| 4750 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4751 | websWrite(wp, |
|---|
| 4752 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n"); |
|---|
| 4753 | websWrite(wp, |
|---|
| 4754 | "<input name=\"%s_ttls8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4755 | prefix, nvram_prefix_get("ttls8021xpasswd", prefix)); |
|---|
| 4756 | |
|---|
| 4757 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4758 | websWrite(wp, |
|---|
| 4759 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.phase2)</script></div>\n"); |
|---|
| 4760 | websWrite(wp, |
|---|
| 4761 | "<input name=\"%s_ttls8021xphase2\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4762 | prefix, nvram_prefix_get("ttls8021xphase2", prefix)); |
|---|
| 4763 | |
|---|
| 4764 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4765 | websWrite(wp, |
|---|
| 4766 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.servercertif)</script></div>\n"); |
|---|
| 4767 | websWrite(wp, |
|---|
| 4768 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_ttls8021xca\" name=\"%s_ttls8021xca\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4769 | prefix, prefix); |
|---|
| 4770 | websWrite(wp, "var %s_ttls8021xca = fix_cr( '", prefix); |
|---|
| 4771 | char namebuf[64]; |
|---|
| 4772 | sprintf(namebuf, "%s_ttls8021xca", prefix); |
|---|
| 4773 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 4774 | websWrite(wp, "' );\n"); |
|---|
| 4775 | websWrite(wp, |
|---|
| 4776 | "document.getElementById(\"%s_ttls8021xca\").value = %s_ttls8021xca;\n", |
|---|
| 4777 | prefix, prefix); |
|---|
| 4778 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4779 | websWrite(wp, "</div>\n"); |
|---|
| 4780 | websWrite(wp, "</div>\n"); |
|---|
| 4781 | |
|---|
| 4782 | // peap authentication |
|---|
| 4783 | websWrite(wp, "<div id=\"idpeap%s\">\n", prefix); |
|---|
| 4784 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4785 | websWrite(wp, |
|---|
| 4786 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n"); |
|---|
| 4787 | websWrite(wp, |
|---|
| 4788 | "<input name=\"%s_peap8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4789 | prefix, nvram_prefix_get("peap8021xuser", prefix)); |
|---|
| 4790 | |
|---|
| 4791 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4792 | websWrite(wp, |
|---|
| 4793 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.anon)</script></div>\n"); |
|---|
| 4794 | websWrite(wp, |
|---|
| 4795 | "<input name=\"%s_peap8021xanon\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4796 | prefix, nvram_prefix_get("peap8021xanon", prefix)); |
|---|
| 4797 | |
|---|
| 4798 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4799 | websWrite(wp, |
|---|
| 4800 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n"); |
|---|
| 4801 | websWrite(wp, |
|---|
| 4802 | "<input name=\"%s_peap8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4803 | prefix, nvram_prefix_get("peap8021xpasswd", prefix)); |
|---|
| 4804 | |
|---|
| 4805 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4806 | websWrite(wp, |
|---|
| 4807 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.phase2)</script></div>\n"); |
|---|
| 4808 | websWrite(wp, |
|---|
| 4809 | "<input name=\"%s_peap8021xphase2\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4810 | prefix, nvram_prefix_get("peap8021xphase2", prefix)); |
|---|
| 4811 | |
|---|
| 4812 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4813 | websWrite(wp, |
|---|
| 4814 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.servercertif)</script></div>\n"); |
|---|
| 4815 | websWrite(wp, |
|---|
| 4816 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_peap8021xca\" name=\"%s_peap8021xca\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4817 | prefix, prefix); |
|---|
| 4818 | |
|---|
| 4819 | websWrite(wp, "var %s_peap8021xca = fix_cr( '", prefix); |
|---|
| 4820 | sprintf(namebuf, "%s_peap8021xca", prefix); |
|---|
| 4821 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 4822 | websWrite(wp, "' );\n"); |
|---|
| 4823 | |
|---|
| 4824 | websWrite(wp, |
|---|
| 4825 | "document.getElementById(\"%s_peap8021xca\").value = %s_peap8021xca;\n", |
|---|
| 4826 | prefix, prefix); |
|---|
| 4827 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4828 | websWrite(wp, "</div>\n"); |
|---|
| 4829 | websWrite(wp, "</div>\n"); |
|---|
| 4830 | // leap authentication |
|---|
| 4831 | websWrite(wp, "<div id=\"idleap%s\">\n", prefix); |
|---|
| 4832 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4833 | websWrite(wp, |
|---|
| 4834 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n"); |
|---|
| 4835 | websWrite(wp, |
|---|
| 4836 | "<input name=\"%s_leap8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4837 | prefix, nvram_prefix_get("leap8021xuser", prefix)); |
|---|
| 4838 | |
|---|
| 4839 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4840 | websWrite(wp, |
|---|
| 4841 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.anon)</script></div>\n"); |
|---|
| 4842 | websWrite(wp, |
|---|
| 4843 | "<input name=\"%s_leap8021xanon\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4844 | prefix, nvram_prefix_get("leap8021xanon", prefix)); |
|---|
| 4845 | |
|---|
| 4846 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4847 | websWrite(wp, |
|---|
| 4848 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n"); |
|---|
| 4849 | websWrite(wp, |
|---|
| 4850 | "<input name=\"%s_leap8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4851 | prefix, nvram_prefix_get("leap8021xpasswd", prefix)); |
|---|
| 4852 | |
|---|
| 4853 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4854 | websWrite(wp, |
|---|
| 4855 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.phase2)</script></div>\n"); |
|---|
| 4856 | websWrite(wp, |
|---|
| 4857 | "<input name=\"%s_leap8021xphase2\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4858 | prefix, nvram_prefix_get("leap8021xphase2", prefix)); |
|---|
| 4859 | |
|---|
| 4860 | websWrite(wp, "</div>\n"); |
|---|
| 4861 | |
|---|
| 4862 | // tls authentication |
|---|
| 4863 | websWrite(wp, "<div id=\"idtls%s\">\n", prefix); |
|---|
| 4864 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4865 | websWrite(wp, |
|---|
| 4866 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n"); |
|---|
| 4867 | websWrite(wp, |
|---|
| 4868 | "<input name=\"%s_tls8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4869 | prefix, nvram_prefix_get("tls8021xuser", prefix)); |
|---|
| 4870 | |
|---|
| 4871 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4872 | websWrite(wp, |
|---|
| 4873 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.anon)</script></div>\n"); |
|---|
| 4874 | websWrite(wp, |
|---|
| 4875 | "<input name=\"%s_tls8021xanon\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4876 | prefix, nvram_prefix_get("tls8021xanon", prefix)); |
|---|
| 4877 | |
|---|
| 4878 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4879 | websWrite(wp, |
|---|
| 4880 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n"); |
|---|
| 4881 | websWrite(wp, |
|---|
| 4882 | "<input name=\"%s_tls8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4883 | prefix, nvram_prefix_get("tls8021xpasswd", prefix)); |
|---|
| 4884 | |
|---|
| 4885 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4886 | websWrite(wp, |
|---|
| 4887 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.phase2)</script></div>\n"); |
|---|
| 4888 | websWrite(wp, |
|---|
| 4889 | "<input name=\"%s_tls8021xphase2\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4890 | prefix, nvram_prefix_get("tls8021xphase2", prefix)); |
|---|
| 4891 | |
|---|
| 4892 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4893 | websWrite(wp, |
|---|
| 4894 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.servercertif)</script></div>\n"); |
|---|
| 4895 | websWrite(wp, |
|---|
| 4896 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xca\" name=\"%s_tls8021xca\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4897 | prefix, prefix); |
|---|
| 4898 | websWrite(wp, "var %s_tls8021xca = fix_cr( '", prefix); |
|---|
| 4899 | sprintf(namebuf, "%s_tls8021xca", prefix); |
|---|
| 4900 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 4901 | websWrite(wp, "' );\n"); |
|---|
| 4902 | |
|---|
| 4903 | websWrite(wp, |
|---|
| 4904 | "document.getElementById(\"%s_tls8021xca\").value = %s_tls8021xca;\n", |
|---|
| 4905 | prefix, prefix); |
|---|
| 4906 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4907 | websWrite(wp, "</div>\n"); |
|---|
| 4908 | |
|---|
| 4909 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4910 | websWrite(wp, |
|---|
| 4911 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.clientcertif)</script></div>\n"); |
|---|
| 4912 | websWrite(wp, |
|---|
| 4913 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xpem\" name=\"%s_tls8021xpem\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4914 | prefix, prefix); |
|---|
| 4915 | |
|---|
| 4916 | websWrite(wp, "var %s_tls8021xpem = fix_cr( '", prefix); |
|---|
| 4917 | sprintf(namebuf, "%s_tls8021xpem", prefix); |
|---|
| 4918 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 4919 | websWrite(wp, "' );\n"); |
|---|
| 4920 | |
|---|
| 4921 | websWrite(wp, |
|---|
| 4922 | "document.getElementById(\"%s_tls8021xpem\").value = %s_tls8021xpem;\n", |
|---|
| 4923 | prefix, prefix); |
|---|
| 4924 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4925 | websWrite(wp, "</div>\n"); |
|---|
| 4926 | |
|---|
| 4927 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4928 | websWrite(wp, |
|---|
| 4929 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.privatekey)</script></div>\n"); |
|---|
| 4930 | websWrite(wp, |
|---|
| 4931 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xprv\" name=\"%s_tls8021xprv\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4932 | prefix, prefix); |
|---|
| 4933 | |
|---|
| 4934 | websWrite(wp, "var %s_tls8021xprv = fix_cr( '", prefix); |
|---|
| 4935 | sprintf(namebuf, "%s_tls8021xprv", prefix); |
|---|
| 4936 | tf_webWriteESCNV(wp, namebuf); |
|---|
| 4937 | websWrite(wp, "' );\n"); |
|---|
| 4938 | |
|---|
| 4939 | websWrite(wp, |
|---|
| 4940 | "document.getElementById(\"%s_tls8021xprv\").value = %s_tls8021xprv;\n", |
|---|
| 4941 | prefix, prefix); |
|---|
| 4942 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4943 | websWrite(wp, "</div>\n"); |
|---|
| 4944 | |
|---|
| 4945 | websWrite(wp, "</div>\n"); |
|---|
| 4946 | websWrite(wp, "<script>\n//<![CDATA[\n "); |
|---|
| 4947 | // websWrite |
|---|
| 4948 | // (wp,"show_layer_ext(document.getElementsByName(\"%s_bridged\"), |
|---|
| 4949 | // \"%s_idnetvifs\", %s);\n",var, vvar, nvram_match (ssid, "0") ? "true" |
|---|
| 4950 | // : "false"); |
|---|
| 4951 | char peap[32]; |
|---|
| 4952 | |
|---|
| 4953 | sprintf(peap, "%s_8021xtype", prefix); |
|---|
| 4954 | websWrite(wp, |
|---|
| 4955 | "show_layer_ext(document.wpa.%s_8021xtype, 'idpeap%s', %s);\n", |
|---|
| 4956 | prefix, prefix, nvram_match(peap, "peap") ? "true" : "false"); |
|---|
| 4957 | websWrite(wp, |
|---|
| 4958 | "show_layer_ext(document.wpa.%s_8021xtype, 'idtls%s', %s);\n", |
|---|
| 4959 | prefix, prefix, nvram_match(peap, "tls") ? "true" : "false"); |
|---|
| 4960 | websWrite(wp, |
|---|
| 4961 | "show_layer_ext(document.wpa.%s_8021xtype, 'idleap%s', %s);\n", |
|---|
| 4962 | prefix, prefix, nvram_match(peap, "leap") ? "true" : "false"); |
|---|
| 4963 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 4964 | |
|---|
| 4965 | } |
|---|
| 4966 | #endif |
|---|
| 4967 | |
|---|
| 4968 | #ifndef HAVE_WPA_SUPPLICANT |
|---|
| 4969 | void ej_init_80211x_layers(webs_t wp, int argc, char_t ** argv) |
|---|
| 4970 | { |
|---|
| 4971 | return; |
|---|
| 4972 | } |
|---|
| 4973 | #endif |
|---|
| 4974 | |
|---|
| 4975 | void show_wparadius(webs_t wp, char *prefix) |
|---|
| 4976 | { |
|---|
| 4977 | char var[80]; |
|---|
| 4978 | |
|---|
| 4979 | websWrite(wp, "<div>\n"); |
|---|
| 4980 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4981 | websWrite(wp, |
|---|
| 4982 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.algorithms)</script></div>\n"); |
|---|
| 4983 | websWrite(wp, "<select name=\"%s_crypto\">\n", prefix); |
|---|
| 4984 | sprintf(var, "%s_crypto", prefix); |
|---|
| 4985 | websWrite(wp, "<option value=\"tkip\" %s>TKIP</option>\n", |
|---|
| 4986 | selmatch(var, "tkip", "selected=\"selected\"")); |
|---|
| 4987 | websWrite(wp, "<option value=\"aes\" %s>AES</option>\n", |
|---|
| 4988 | selmatch(var, "aes", "selected=\"selected\"")); |
|---|
| 4989 | websWrite(wp, "<option value=\"tkip+aes\" %s>TKIP+AES</option>\n", |
|---|
| 4990 | selmatch(var, "tkip+aes", "selected=\"selected\"")); |
|---|
| 4991 | websWrite(wp, "</select></div>\n"); |
|---|
| 4992 | show_radius(wp, prefix, 0); |
|---|
| 4993 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 4994 | websWrite(wp, |
|---|
| 4995 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.rekey)</script></div>\n"); |
|---|
| 4996 | sprintf(var, "%s_wpa_gtk_rekey", prefix); |
|---|
| 4997 | websWrite(wp, |
|---|
| 4998 | "<input name=\"%s_wpa_gtk_rekey\" maxlength=\"5\" size=\"10\" onblur=\"valid_range(this,0,99999,wpa.rekey)\" value=\"%s\" />", |
|---|
| 4999 | prefix, nvram_default_get(var, "3600")); |
|---|
| 5000 | websWrite(wp, "</div>\n"); |
|---|
| 5001 | websWrite(wp, "</div>\n"); |
|---|
| 5002 | } |
|---|
| 5003 | |
|---|
| 5004 | void show_wep(webs_t wp, char *prefix) |
|---|
| 5005 | { |
|---|
| 5006 | char var[80]; |
|---|
| 5007 | char *bit; |
|---|
| 5008 | |
|---|
| 5009 | cprintf("show wep\n"); |
|---|
| 5010 | #ifdef HAVE_MADWIFI |
|---|
| 5011 | char wl_authmode[16]; |
|---|
| 5012 | |
|---|
| 5013 | sprintf(wl_authmode, "%s_authmode", prefix); |
|---|
| 5014 | nvram_default_get(wl_authmode, "open"); |
|---|
| 5015 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5016 | websWrite(wp, |
|---|
| 5017 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label)</script></div>\n"); |
|---|
| 5018 | websWrite(wp, |
|---|
| 5019 | "<input class=\"spaceradio\" type=\"radio\" value=\"open\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.openn)</script></input> \n", |
|---|
| 5020 | wl_authmode, nvram_match(wl_authmode, |
|---|
| 5021 | "open") ? "checked=\"checked\"" : |
|---|
| 5022 | ""); |
|---|
| 5023 | websWrite(wp, |
|---|
| 5024 | "<input class=\"spaceradio\" type=\"radio\" value=\"shared\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.share_key)</script></input>\n", |
|---|
| 5025 | wl_authmode, nvram_match(wl_authmode, |
|---|
| 5026 | "shared") ? "checked=\"checked\"" : |
|---|
| 5027 | ""); |
|---|
| 5028 | websWrite(wp, "</div>\n"); |
|---|
| 5029 | #endif |
|---|
| 5030 | websWrite(wp, |
|---|
| 5031 | "<div><div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wep.defkey)</script></div>"); |
|---|
| 5032 | websWrite(wp, "<input type=\"hidden\" name=\"%s_WEP_key\" />", prefix); |
|---|
| 5033 | websWrite(wp, |
|---|
| 5034 | "<input type=\"hidden\" name=\"%s_wep\" value=\"restricted\" />", |
|---|
| 5035 | prefix); |
|---|
| 5036 | sprintf(var, "%s_key", prefix); |
|---|
| 5037 | nvram_default_get(var, "1"); |
|---|
| 5038 | websWrite(wp, |
|---|
| 5039 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s_key\" %s />1 \n", |
|---|
| 5040 | prefix, selmatch(var, "1", "checked=\"checked\"")); |
|---|
| 5041 | websWrite(wp, |
|---|
| 5042 | "<input class=\"spaceradio\" type=\"radio\" value=\"2\" name=\"%s_key\" %s />2 \n", |
|---|
| 5043 | prefix, selmatch(var, "2", "checked=\"checked\"")); |
|---|
| 5044 | websWrite(wp, |
|---|
| 5045 | "<input class=\"spaceradio\" type=\"radio\" value=\"3\" name=\"%s_key\" %s />3 \n", |
|---|
| 5046 | prefix, selmatch(var, "3", "checked=\"checked\"")); |
|---|
| 5047 | websWrite(wp, |
|---|
| 5048 | "<input class=\"spaceradio\" type=\"radio\" value=\"4\" name=\"%s_key\" %s />4 \n", |
|---|
| 5049 | prefix, selmatch(var, "4", "checked=\"checked\"")); |
|---|
| 5050 | websWrite(wp, "</div>"); |
|---|
| 5051 | websWrite(wp, |
|---|
| 5052 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.encrypt)</script></div>"); |
|---|
| 5053 | |
|---|
| 5054 | sprintf(var, "%s_wep_bit", prefix); |
|---|
| 5055 | bit = nvram_safe_get(var); |
|---|
| 5056 | |
|---|
| 5057 | cprintf("bit %s\n", bit); |
|---|
| 5058 | |
|---|
| 5059 | websWrite(wp, |
|---|
| 5060 | "<select name=\"%s_wep_bit\" size=\"1\" onchange=keyMode(this.form)>", |
|---|
| 5061 | prefix); |
|---|
| 5062 | websWrite(wp, "<option value=\"64\" %s >64 bits 10 hex digits</option>", |
|---|
| 5063 | selmatch(var, "64", "selected=\"selected\"")); |
|---|
| 5064 | websWrite(wp, |
|---|
| 5065 | "<option value=\"128\" %s >128 bits 26 hex digits</option>", |
|---|
| 5066 | selmatch(var, "128", "selected=\"selected\"")); |
|---|
| 5067 | websWrite(wp, |
|---|
| 5068 | "</select>\n</div>\n<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wep.passphrase)</script></div>\n"); |
|---|
| 5069 | websWrite(wp, |
|---|
| 5070 | "<input name=%s_passphrase maxlength=\"16\" size=\"20\" value=\"", |
|---|
| 5071 | prefix); |
|---|
| 5072 | |
|---|
| 5073 | char p_temp[128]; |
|---|
| 5074 | char temp[256]; |
|---|
| 5075 | |
|---|
| 5076 | sprintf(p_temp, "%s", get_wep_value(temp, "passphrase", bit, prefix)); |
|---|
| 5077 | nvram_set("passphrase_temp", p_temp); |
|---|
| 5078 | tf_webWriteESCNV(wp, "passphrase_temp"); |
|---|
| 5079 | nvram_unset("passphrase_temp"); |
|---|
| 5080 | |
|---|
| 5081 | websWrite(wp, "\" />"); |
|---|
| 5082 | websWrite(wp, |
|---|
| 5083 | "<input type=\"hidden\" value=\"Null\" name=\"generateButton\" />\n"); |
|---|
| 5084 | websWrite(wp, |
|---|
| 5085 | "<input class=\"button\" type=\"button\" value=\"Generate\" onclick=generateKey(this.form,\"%s\") name=wepGenerate />\n</div>", |
|---|
| 5086 | prefix); |
|---|
| 5087 | |
|---|
| 5088 | char *mlen = "10"; |
|---|
| 5089 | char *mlen2 = "12"; |
|---|
| 5090 | |
|---|
| 5091 | if (!strcmp(bit, "128")) { |
|---|
| 5092 | mlen = "26"; |
|---|
| 5093 | mlen2 = "30"; |
|---|
| 5094 | } |
|---|
| 5095 | websWrite(wp, |
|---|
| 5096 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 1</div>\n"); |
|---|
| 5097 | websWrite(wp, |
|---|
| 5098 | "<input name=%s_key1 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 5099 | prefix, mlen2, mlen, get_wep_value(temp, "key1", bit, |
|---|
| 5100 | prefix)); |
|---|
| 5101 | websWrite(wp, |
|---|
| 5102 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 2</div>\n"); |
|---|
| 5103 | websWrite(wp, |
|---|
| 5104 | "<input name=%s_key2 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 5105 | prefix, mlen2, mlen, get_wep_value(temp, "key2", bit, |
|---|
| 5106 | prefix)); |
|---|
| 5107 | websWrite(wp, |
|---|
| 5108 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 3</div>\n"); |
|---|
| 5109 | websWrite(wp, |
|---|
| 5110 | "<input name=%s_key3 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 5111 | prefix, mlen2, mlen, get_wep_value(temp, "key3", bit, |
|---|
| 5112 | prefix)); |
|---|
| 5113 | websWrite(wp, |
|---|
| 5114 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 4</div>\n"); |
|---|
| 5115 | websWrite(wp, |
|---|
| 5116 | "<input name=%s_key4 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 5117 | prefix, mlen2, mlen, get_wep_value(temp, "key4", bit, |
|---|
| 5118 | prefix)); |
|---|
| 5119 | websWrite(wp, "</div>\n"); |
|---|
| 5120 | } |
|---|
| 5121 | |
|---|
| 5122 | void ej_get_wds_mac(webs_t wp, int argc, char_t ** argv) |
|---|
| 5123 | { |
|---|
| 5124 | int mac = -1, wds_idx = -1, mac_idx = -1; |
|---|
| 5125 | char *c, wds_var[32] = ""; |
|---|
| 5126 | |
|---|
| 5127 | char *interface; |
|---|
| 5128 | |
|---|
| 5129 | if (ejArgs(argc, argv, "%d %d %s", &wds_idx, &mac_idx, &interface) < 3) { |
|---|
| 5130 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5131 | return; |
|---|
| 5132 | } else if (wds_idx < 1 || wds_idx > MAX_WDS_DEVS) |
|---|
| 5133 | return; |
|---|
| 5134 | else if (mac_idx < 0 || mac_idx > 5) |
|---|
| 5135 | return; |
|---|
| 5136 | |
|---|
| 5137 | snprintf(wds_var, 31, "%s_wds%d_hwaddr", interface, wds_idx); |
|---|
| 5138 | |
|---|
| 5139 | c = nvram_safe_get(wds_var); |
|---|
| 5140 | |
|---|
| 5141 | if (c) { |
|---|
| 5142 | mac = get_single_mac(c, mac_idx); |
|---|
| 5143 | websWrite(wp, "%02X", mac); |
|---|
| 5144 | } else |
|---|
| 5145 | websWrite(wp, "00"); |
|---|
| 5146 | |
|---|
| 5147 | return; |
|---|
| 5148 | |
|---|
| 5149 | } |
|---|
| 5150 | |
|---|
| 5151 | void ej_showbridgesettings(webs_t wp, int argc, char_t ** argv) |
|---|
| 5152 | { |
|---|
| 5153 | char *interface; |
|---|
| 5154 | int mcast; |
|---|
| 5155 | |
|---|
| 5156 | #ifdef FASTWEB |
|---|
| 5157 | ejArgs(argc, argv, "%s %d", &interface, &mcast); |
|---|
| 5158 | #else |
|---|
| 5159 | if (ejArgs(argc, argv, "%s %d", &interface, &mcast) < 2) { |
|---|
| 5160 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5161 | return; |
|---|
| 5162 | } |
|---|
| 5163 | #endif |
|---|
| 5164 | showbridgesettings(wp, interface, mcast, 0); |
|---|
| 5165 | } |
|---|
| 5166 | |
|---|
| 5167 | void ej_get_wds_ip(webs_t wp, int argc, char_t ** argv) |
|---|
| 5168 | { |
|---|
| 5169 | int ip = -1, wds_idx = -1, ip_idx = -1; |
|---|
| 5170 | char *c, wds_var[32] = ""; |
|---|
| 5171 | |
|---|
| 5172 | char *interface; |
|---|
| 5173 | |
|---|
| 5174 | #ifdef FASTWEB |
|---|
| 5175 | ejArgs(argc, argv, "%d %d %s", &wds_idx, &ip_idx, &interface); |
|---|
| 5176 | #else |
|---|
| 5177 | if (ejArgs(argc, argv, "%d %d %s", &wds_idx, &ip_idx, &interface) < 3) { |
|---|
| 5178 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5179 | return; |
|---|
| 5180 | } |
|---|
| 5181 | #endif |
|---|
| 5182 | if (wds_idx < 1 || wds_idx > MAX_WDS_DEVS) |
|---|
| 5183 | return; |
|---|
| 5184 | else if (ip_idx < 0 || ip_idx > 3) |
|---|
| 5185 | return; |
|---|
| 5186 | |
|---|
| 5187 | snprintf(wds_var, 31, "%s_wds%d_ipaddr", interface, wds_idx); |
|---|
| 5188 | |
|---|
| 5189 | c = nvram_safe_get(wds_var); |
|---|
| 5190 | |
|---|
| 5191 | if (c) { |
|---|
| 5192 | ip = get_single_ip(c, ip_idx); |
|---|
| 5193 | websWrite(wp, "%d", ip); |
|---|
| 5194 | } else |
|---|
| 5195 | websWrite(wp, "0"); |
|---|
| 5196 | |
|---|
| 5197 | return; |
|---|
| 5198 | |
|---|
| 5199 | } |
|---|
| 5200 | |
|---|
| 5201 | void ej_get_wds_netmask(webs_t wp, int argc, char_t ** argv) |
|---|
| 5202 | { |
|---|
| 5203 | int nm = -1, wds_idx = -1, nm_idx = -1; |
|---|
| 5204 | char *c, wds_var[32] = ""; |
|---|
| 5205 | |
|---|
| 5206 | char *interface; |
|---|
| 5207 | |
|---|
| 5208 | #ifdef FASTWEB |
|---|
| 5209 | ejArgs(argc, argv, "%d %d %s", &wds_idx, &nm_idx, &interface); |
|---|
| 5210 | #else |
|---|
| 5211 | if (ejArgs(argc, argv, "%d %d %s", &wds_idx, &nm_idx, &interface) < 3) { |
|---|
| 5212 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5213 | return; |
|---|
| 5214 | } |
|---|
| 5215 | #endif |
|---|
| 5216 | |
|---|
| 5217 | if (wds_idx < 1 || wds_idx > 6) |
|---|
| 5218 | return; |
|---|
| 5219 | else if (nm_idx < 0 || nm_idx > 3) |
|---|
| 5220 | return; |
|---|
| 5221 | |
|---|
| 5222 | snprintf(wds_var, 31, "%s_wds%d_netmask", interface, wds_idx); |
|---|
| 5223 | |
|---|
| 5224 | c = nvram_safe_get(wds_var); |
|---|
| 5225 | |
|---|
| 5226 | if (c) { |
|---|
| 5227 | nm = get_single_ip(c, nm_idx); |
|---|
| 5228 | websWrite(wp, "%d", nm); |
|---|
| 5229 | } else |
|---|
| 5230 | websWrite(wp, "255"); |
|---|
| 5231 | |
|---|
| 5232 | return; |
|---|
| 5233 | |
|---|
| 5234 | } |
|---|
| 5235 | |
|---|
| 5236 | void ej_get_wds_gw(webs_t wp, int argc, char_t ** argv) |
|---|
| 5237 | { |
|---|
| 5238 | int gw = -1, wds_idx = -1, gw_idx = -1; |
|---|
| 5239 | char *c, wds_var[32] = ""; |
|---|
| 5240 | |
|---|
| 5241 | char *interface; |
|---|
| 5242 | |
|---|
| 5243 | #ifdef FASTWEB |
|---|
| 5244 | ejArgs(argc, argv, "%d %d %s", &wds_idx, &gw_idx, &interface); |
|---|
| 5245 | #else |
|---|
| 5246 | if (ejArgs(argc, argv, "%d %d %s", &wds_idx, &gw_idx, &interface) < 3) { |
|---|
| 5247 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5248 | return; |
|---|
| 5249 | } |
|---|
| 5250 | #endif |
|---|
| 5251 | |
|---|
| 5252 | if (wds_idx < 1 || wds_idx > MAX_WDS_DEVS) |
|---|
| 5253 | return; |
|---|
| 5254 | else if (gw_idx < 0 || gw_idx > 3) |
|---|
| 5255 | return; |
|---|
| 5256 | |
|---|
| 5257 | snprintf(wds_var, 31, "%s_wds%d_gw", interface, wds_idx); |
|---|
| 5258 | |
|---|
| 5259 | c = nvram_safe_get(wds_var); |
|---|
| 5260 | |
|---|
| 5261 | if (c) { |
|---|
| 5262 | gw = get_single_ip(c, gw_idx); |
|---|
| 5263 | websWrite(wp, "%d", gw); |
|---|
| 5264 | } else |
|---|
| 5265 | websWrite(wp, "0"); |
|---|
| 5266 | |
|---|
| 5267 | return; |
|---|
| 5268 | |
|---|
| 5269 | } |
|---|
| 5270 | |
|---|
| 5271 | void ej_get_br1_ip(webs_t wp, int argc, char_t ** argv) |
|---|
| 5272 | { |
|---|
| 5273 | int ip = -1, ip_idx = -1; |
|---|
| 5274 | char *c; |
|---|
| 5275 | |
|---|
| 5276 | char *interface; |
|---|
| 5277 | |
|---|
| 5278 | #ifdef FASTWEB |
|---|
| 5279 | ejArgs(argc, argv, "%d %s", &ip_idx, &interface); |
|---|
| 5280 | #else |
|---|
| 5281 | if (ejArgs(argc, argv, "%d %s", &ip_idx, &interface) < 2) { |
|---|
| 5282 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5283 | return; |
|---|
| 5284 | } |
|---|
| 5285 | #endif |
|---|
| 5286 | if (ip_idx < 0 || ip_idx > 3) |
|---|
| 5287 | return; |
|---|
| 5288 | char br1[32]; |
|---|
| 5289 | |
|---|
| 5290 | sprintf(br1, "%s_br1_ipaddr", interface); |
|---|
| 5291 | c = nvram_safe_get(br1); |
|---|
| 5292 | |
|---|
| 5293 | if (c) { |
|---|
| 5294 | ip = get_single_ip(c, ip_idx); |
|---|
| 5295 | websWrite(wp, "%d", ip); |
|---|
| 5296 | } else |
|---|
| 5297 | websWrite(wp, "0"); |
|---|
| 5298 | |
|---|
| 5299 | return; |
|---|
| 5300 | |
|---|
| 5301 | } |
|---|
| 5302 | |
|---|
| 5303 | void ej_get_br1_netmask(webs_t wp, int argc, char_t ** argv) |
|---|
| 5304 | { |
|---|
| 5305 | int nm = -1, nm_idx = -1; |
|---|
| 5306 | char *c; |
|---|
| 5307 | |
|---|
| 5308 | char *interface; |
|---|
| 5309 | |
|---|
| 5310 | #ifdef FASTWEB |
|---|
| 5311 | ejArgs(argc, argv, "%d %s", &nm_idx, &interface); |
|---|
| 5312 | #else |
|---|
| 5313 | if (ejArgs(argc, argv, "%d %s", &nm_idx, &interface) < 2) { |
|---|
| 5314 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5315 | return; |
|---|
| 5316 | } |
|---|
| 5317 | #endif |
|---|
| 5318 | if (nm_idx < 0 || nm_idx > 3) |
|---|
| 5319 | return; |
|---|
| 5320 | char nms[32]; |
|---|
| 5321 | |
|---|
| 5322 | sprintf(nms, "%s_br1_netmask", interface); |
|---|
| 5323 | c = nvram_safe_get(nms); |
|---|
| 5324 | |
|---|
| 5325 | if (c) { |
|---|
| 5326 | nm = get_single_ip(c, nm_idx); |
|---|
| 5327 | websWrite(wp, "%d", nm); |
|---|
| 5328 | } else |
|---|
| 5329 | websWrite(wp, "255"); |
|---|
| 5330 | |
|---|
| 5331 | return; |
|---|
| 5332 | |
|---|
| 5333 | } |
|---|
| 5334 | |
|---|
| 5335 | #ifdef HAVE_MADWIFI |
|---|
| 5336 | |
|---|
| 5337 | int get_acktiming(void) |
|---|
| 5338 | { |
|---|
| 5339 | char path[64]; |
|---|
| 5340 | int ifcount, ack = 0, tim = 0; |
|---|
| 5341 | |
|---|
| 5342 | strcpy(path, nvram_safe_get("wifi_display")); |
|---|
| 5343 | sscanf(path, "ath%d", &ifcount); |
|---|
| 5344 | sprintf(path, "/proc/sys/dev/wifi%d/acktimeout", ifcount); |
|---|
| 5345 | FILE *in = fopen(path, "rb"); |
|---|
| 5346 | |
|---|
| 5347 | if (in != NULL) { |
|---|
| 5348 | fscanf(in, "%d", &ack); |
|---|
| 5349 | fclose(in); |
|---|
| 5350 | } |
|---|
| 5351 | |
|---|
| 5352 | sprintf(path, "/proc/sys/dev/wifi%d/timingoffset", ifcount); |
|---|
| 5353 | in = fopen(path, "rb"); |
|---|
| 5354 | |
|---|
| 5355 | if (in != NULL) { |
|---|
| 5356 | fscanf(in, "%d", &tim); |
|---|
| 5357 | fclose(in); |
|---|
| 5358 | } |
|---|
| 5359 | ack -= tim * 2; |
|---|
| 5360 | |
|---|
| 5361 | return ack; |
|---|
| 5362 | } |
|---|
| 5363 | |
|---|
| 5364 | void ej_show_acktiming(webs_t wp, int argc, char_t ** argv) |
|---|
| 5365 | { |
|---|
| 5366 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 5367 | websWrite(wp, "<div class=\"label\">%s</div>\n", |
|---|
| 5368 | live_translate("share.acktiming")); |
|---|
| 5369 | int ack = get_acktiming(); |
|---|
| 5370 | int distance = ((ack - 3) / 2) * 300; |
|---|
| 5371 | |
|---|
| 5372 | websWrite(wp, "<span id=\"wl_ack\">%dµs (%dm)</span> \n", |
|---|
| 5373 | ack, distance); |
|---|
| 5374 | websWrite(wp, "</div>\n"); |
|---|
| 5375 | } |
|---|
| 5376 | |
|---|
| 5377 | void ej_update_acktiming(webs_t wp, int argc, char_t ** argv) |
|---|
| 5378 | { |
|---|
| 5379 | int ack = get_acktiming(); |
|---|
| 5380 | int distance = ((ack - 3) / 2) * 300; |
|---|
| 5381 | |
|---|
| 5382 | websWrite(wp, "%dµs (%dm)", ack, distance); |
|---|
| 5383 | } |
|---|
| 5384 | |
|---|
| 5385 | extern float wifi_getrate(char *ifname); |
|---|
| 5386 | |
|---|
| 5387 | #define KILO 1e3 |
|---|
| 5388 | #define MEGA 1e6 |
|---|
| 5389 | #define GIGA 1e9 |
|---|
| 5390 | |
|---|
| 5391 | void ej_get_currate(webs_t wp, int argc, char_t ** argv) |
|---|
| 5392 | { |
|---|
| 5393 | char mode[32]; |
|---|
| 5394 | int state = get_radiostate(nvram_safe_get("wifi_display")); |
|---|
| 5395 | |
|---|
| 5396 | if (state == 0 || state == -1) { |
|---|
| 5397 | websWrite(wp, "%s", live_translate("share.disabled")); |
|---|
| 5398 | return; |
|---|
| 5399 | } |
|---|
| 5400 | float rate = wifi_getrate(nvram_safe_get("wifi_display")); |
|---|
| 5401 | char scale; |
|---|
| 5402 | int divisor; |
|---|
| 5403 | |
|---|
| 5404 | if (rate >= GIGA) { |
|---|
| 5405 | scale = 'G'; |
|---|
| 5406 | divisor = GIGA; |
|---|
| 5407 | } else { |
|---|
| 5408 | if (rate >= MEGA) { |
|---|
| 5409 | scale = 'M'; |
|---|
| 5410 | divisor = MEGA; |
|---|
| 5411 | } else { |
|---|
| 5412 | scale = 'k'; |
|---|
| 5413 | divisor = KILO; |
|---|
| 5414 | } |
|---|
| 5415 | } |
|---|
| 5416 | sprintf(mode, "%s_channelbw", nvram_safe_get("wifi_display")); |
|---|
| 5417 | if (nvram_match(mode, "40")) |
|---|
| 5418 | rate *= 2; |
|---|
| 5419 | if (rate > 0.0) { |
|---|
| 5420 | websWrite(wp, "%g %cb/s", rate / divisor, scale); |
|---|
| 5421 | } else |
|---|
| 5422 | websWrite(wp, "%s", live_translate("share.auto")); |
|---|
| 5423 | |
|---|
| 5424 | } |
|---|
| 5425 | |
|---|
| 5426 | #elif HAVE_RT2880 |
|---|
| 5427 | extern float wifi_getrate(char *ifname); |
|---|
| 5428 | |
|---|
| 5429 | #define KILO 1e3 |
|---|
| 5430 | #define MEGA 1e6 |
|---|
| 5431 | #define GIGA 1e9 |
|---|
| 5432 | |
|---|
| 5433 | void ej_get_currate(webs_t wp, int argc, char_t ** argv) |
|---|
| 5434 | { |
|---|
| 5435 | char mode[32]; |
|---|
| 5436 | int state = get_radiostate("wl0"); |
|---|
| 5437 | |
|---|
| 5438 | if (state == 0 || state == -1) { |
|---|
| 5439 | websWrite(wp, "%s", live_translate("share.disabled")); |
|---|
| 5440 | return; |
|---|
| 5441 | } |
|---|
| 5442 | float rate = wifi_getrate("ra0"); |
|---|
| 5443 | char scale; |
|---|
| 5444 | int divisor; |
|---|
| 5445 | |
|---|
| 5446 | if (rate >= GIGA) { |
|---|
| 5447 | scale = 'G'; |
|---|
| 5448 | divisor = GIGA; |
|---|
| 5449 | } else { |
|---|
| 5450 | if (rate >= MEGA) { |
|---|
| 5451 | scale = 'M'; |
|---|
| 5452 | divisor = MEGA; |
|---|
| 5453 | } else { |
|---|
| 5454 | scale = 'k'; |
|---|
| 5455 | divisor = KILO; |
|---|
| 5456 | } |
|---|
| 5457 | } |
|---|
| 5458 | if (rate > 0.0) { |
|---|
| 5459 | websWrite(wp, "%g %cb/s", rate / divisor, scale); |
|---|
| 5460 | } else |
|---|
| 5461 | websWrite(wp, "%s", live_translate("share.auto")); |
|---|
| 5462 | |
|---|
| 5463 | } |
|---|
| 5464 | |
|---|
| 5465 | void ej_show_acktiming(webs_t wp, int argc, char_t ** argv) |
|---|
| 5466 | { |
|---|
| 5467 | return; |
|---|
| 5468 | } |
|---|
| 5469 | |
|---|
| 5470 | void ej_update_acktiming(webs_t wp, int argc, char_t ** argv) |
|---|
| 5471 | { |
|---|
| 5472 | return; |
|---|
| 5473 | } |
|---|
| 5474 | |
|---|
| 5475 | #else |
|---|
| 5476 | |
|---|
| 5477 | void ej_get_currate(webs_t wp, int argc, char_t ** argv) |
|---|
| 5478 | { |
|---|
| 5479 | int rate = 0; |
|---|
| 5480 | char name[32]; |
|---|
| 5481 | |
|---|
| 5482 | sprintf(name, "%s_ifname", nvram_safe_get("wifi_display")); |
|---|
| 5483 | char *ifname = nvram_safe_get(name); |
|---|
| 5484 | |
|---|
| 5485 | wl_ioctl(ifname, WLC_GET_RATE, &rate, sizeof(rate)); |
|---|
| 5486 | |
|---|
| 5487 | if (rate > 0) |
|---|
| 5488 | websWrite(wp, "%d%s Mbps", (rate / 2), (rate & 1) ? ".5" : ""); |
|---|
| 5489 | else |
|---|
| 5490 | websWrite(wp, "%s", live_translate("share.unknown")); |
|---|
| 5491 | |
|---|
| 5492 | return; |
|---|
| 5493 | } |
|---|
| 5494 | |
|---|
| 5495 | void ej_show_acktiming(webs_t wp, int argc, char_t ** argv) |
|---|
| 5496 | { |
|---|
| 5497 | return; |
|---|
| 5498 | } |
|---|
| 5499 | |
|---|
| 5500 | void ej_update_acktiming(webs_t wp, int argc, char_t ** argv) |
|---|
| 5501 | { |
|---|
| 5502 | return; |
|---|
| 5503 | } |
|---|
| 5504 | |
|---|
| 5505 | #endif |
|---|
| 5506 | |
|---|
| 5507 | void ej_get_uptime(webs_t wp, int argc, char_t ** argv) |
|---|
| 5508 | { |
|---|
| 5509 | char line[256]; |
|---|
| 5510 | FILE *fp; |
|---|
| 5511 | |
|---|
| 5512 | if ((fp = popen("uptime", "r"))) { |
|---|
| 5513 | fgets(line, sizeof(line), fp); |
|---|
| 5514 | line[strlen(line) - 1] = '\0'; // replace new line with null |
|---|
| 5515 | websWrite(wp, "%s", line); |
|---|
| 5516 | pclose(fp); |
|---|
| 5517 | } |
|---|
| 5518 | return; |
|---|
| 5519 | } |
|---|
| 5520 | |
|---|
| 5521 | void ej_get_wan_uptime(webs_t wp, int argc, char_t ** argv) |
|---|
| 5522 | { |
|---|
| 5523 | float sys_uptime; |
|---|
| 5524 | float uptime; |
|---|
| 5525 | int days, minutes; |
|---|
| 5526 | FILE *fp, *fp2; |
|---|
| 5527 | |
|---|
| 5528 | if (nvram_match("wan_proto", "disabled")) |
|---|
| 5529 | return; |
|---|
| 5530 | if (nvram_match("wan_ipaddr", "0.0.0.0")) { |
|---|
| 5531 | websWrite(wp, "%s", live_translate("status_router.notavail")); |
|---|
| 5532 | return; |
|---|
| 5533 | } |
|---|
| 5534 | if (!(fp = fopen("/tmp/.wanuptime", "r"))) { |
|---|
| 5535 | websWrite(wp, "%s", live_translate("status_router.notavail")); |
|---|
| 5536 | return; |
|---|
| 5537 | } |
|---|
| 5538 | if (!feof(fp) && fscanf(fp, "%f", &uptime) == 1) { |
|---|
| 5539 | fp2 = fopen("/proc/uptime", "r"); |
|---|
| 5540 | fscanf(fp2, "%f", &sys_uptime); |
|---|
| 5541 | fclose(fp2); |
|---|
| 5542 | uptime = sys_uptime - uptime; |
|---|
| 5543 | days = (int)uptime / (60 * 60 * 24); |
|---|
| 5544 | if (days) |
|---|
| 5545 | websWrite(wp, "%d day%s, ", days, |
|---|
| 5546 | (days == 1 ? "" : "s")); |
|---|
| 5547 | minutes = (int)uptime / 60; |
|---|
| 5548 | websWrite(wp, "%d:%02d:%02d", (minutes / 60) % 24, minutes % 60, |
|---|
| 5549 | (int)uptime % 60); |
|---|
| 5550 | } |
|---|
| 5551 | fclose(fp); |
|---|
| 5552 | |
|---|
| 5553 | return; |
|---|
| 5554 | |
|---|
| 5555 | } |
|---|
| 5556 | |
|---|
| 5557 | #ifdef HAVE_MADWIFI |
|---|
| 5558 | |
|---|
| 5559 | void ej_get_curchannel(webs_t wp, int argc, char_t ** argv) |
|---|
| 5560 | { |
|---|
| 5561 | int channel = wifi_getchannel(nvram_safe_get("wifi_display")); |
|---|
| 5562 | |
|---|
| 5563 | if (channel > 0 && channel < 1000) { |
|---|
| 5564 | websWrite(wp, "%d (%d Mhz)", channel, |
|---|
| 5565 | (wifi_getfreq(nvram_safe_get("wifi_display")) + |
|---|
| 5566 | get_wifioffset(nvram_safe_get("wifi_display")))); |
|---|
| 5567 | } else |
|---|
| 5568 | // websWrite (wp, "unknown"); |
|---|
| 5569 | websWrite(wp, "%s", live_translate("share.unknown")); |
|---|
| 5570 | return; |
|---|
| 5571 | } |
|---|
| 5572 | |
|---|
| 5573 | #elif HAVE_RT2880 |
|---|
| 5574 | void ej_get_curchannel(webs_t wp, int argc, char_t ** argv) |
|---|
| 5575 | { |
|---|
| 5576 | int channel = wifi_getchannel("ra0"); |
|---|
| 5577 | |
|---|
| 5578 | if (channel > 0 && channel < 1000) { |
|---|
| 5579 | websWrite(wp, "%d (%d Mhz)", channel, wifi_getfreq("ra0")); |
|---|
| 5580 | } else |
|---|
| 5581 | // websWrite (wp, "unknown"); |
|---|
| 5582 | websWrite(wp, "%s", live_translate("share.unknown")); |
|---|
| 5583 | return; |
|---|
| 5584 | } |
|---|
| 5585 | |
|---|
| 5586 | #else |
|---|
| 5587 | |
|---|
| 5588 | void ej_get_curchannel(webs_t wp, int argc, char_t ** argv) |
|---|
| 5589 | { |
|---|
| 5590 | channel_info_t ci; |
|---|
| 5591 | char name[32]; |
|---|
| 5592 | |
|---|
| 5593 | char *prefix = nvram_safe_get("wifi_display"); |
|---|
| 5594 | sprintf(name, "%s_ifname", prefix); |
|---|
| 5595 | char *ifname = nvram_safe_get(name); |
|---|
| 5596 | |
|---|
| 5597 | memset(&ci, 0, sizeof(ci)); |
|---|
| 5598 | wl_ioctl(ifname, WLC_GET_CHANNEL, &ci, sizeof(ci)); |
|---|
| 5599 | if (ci.scan_channel > 0) { |
|---|
| 5600 | websWrite(wp, "%d (scanning)", ci.scan_channel); |
|---|
| 5601 | } else if (ci.hw_channel > 0) { |
|---|
| 5602 | if (has_mimo(prefix) |
|---|
| 5603 | && (nvram_nmatch("n-only", "%s_net_mode", prefix) |
|---|
| 5604 | || nvram_nmatch("mixed", "%s_net_mode", prefix) |
|---|
| 5605 | || nvram_nmatch("na-only", "%s_net_mode", prefix)) |
|---|
| 5606 | && (nvram_nmatch("40", "%s_nbw", prefix)) |
|---|
| 5607 | && (nvram_nmatch("ap", "%s_mode", prefix) |
|---|
| 5608 | || nvram_nmatch("wdsap", "%s_mode", prefix) |
|---|
| 5609 | || nvram_nmatch("infra", "%s_mode", prefix))) { |
|---|
| 5610 | websWrite(wp, "%d + ", |
|---|
| 5611 | nvram_nmatch("upper", "%s_nctrlsb", |
|---|
| 5612 | prefix) ? ci.hw_channel + |
|---|
| 5613 | 2 : ci.hw_channel - 2); |
|---|
| 5614 | } |
|---|
| 5615 | websWrite(wp, "%d", ci.hw_channel); |
|---|
| 5616 | } else |
|---|
| 5617 | // websWrite (wp, "unknown"); |
|---|
| 5618 | websWrite(wp, "%s", live_translate("share.unknown")); |
|---|
| 5619 | return; |
|---|
| 5620 | |
|---|
| 5621 | } |
|---|
| 5622 | |
|---|
| 5623 | #endif |
|---|
| 5624 | |
|---|
| 5625 | static char *UPTIME(int uptime) |
|---|
| 5626 | { |
|---|
| 5627 | int days, minutes; |
|---|
| 5628 | static char str[64] = { 0 }; |
|---|
| 5629 | memset(str, 0, 64); |
|---|
| 5630 | days = uptime / (60 * 60 * 24); |
|---|
| 5631 | if (days) |
|---|
| 5632 | sprintf(str, "%d day%s, ", days, (days == 1 ? "" : "s")); |
|---|
| 5633 | minutes = uptime / 60; |
|---|
| 5634 | if (strlen(str) > 0) |
|---|
| 5635 | sprintf(str, "%s %d:%02d:%02d", str, (minutes / 60) % 24, |
|---|
| 5636 | minutes % 60, uptime % 60); |
|---|
| 5637 | else |
|---|
| 5638 | sprintf(str, "%d:%02d:%02d", (minutes / 60) % 24, minutes % 60, |
|---|
| 5639 | uptime % 60); |
|---|
| 5640 | return str; |
|---|
| 5641 | } |
|---|
| 5642 | |
|---|
| 5643 | #ifdef HAVE_MADWIFI |
|---|
| 5644 | #include <sys/types.h> |
|---|
| 5645 | #include <sys/file.h> |
|---|
| 5646 | #include <sys/ioctl.h> |
|---|
| 5647 | #include <sys/socket.h> |
|---|
| 5648 | #include <stdio.h> |
|---|
| 5649 | #include <stdlib.h> |
|---|
| 5650 | #include <string.h> |
|---|
| 5651 | #include <stdint.h> |
|---|
| 5652 | #include <ctype.h> |
|---|
| 5653 | #include <getopt.h> |
|---|
| 5654 | #include <err.h> |
|---|
| 5655 | |
|---|
| 5656 | #include "wireless_copy.h" |
|---|
| 5657 | #include "net80211/ieee80211.h" |
|---|
| 5658 | #include "net80211/ieee80211_crypto.h" |
|---|
| 5659 | #include "net80211/ieee80211_ioctl.h" |
|---|
| 5660 | static const char *ieee80211_ntoa(const uint8_t mac[IEEE80211_ADDR_LEN]) |
|---|
| 5661 | { |
|---|
| 5662 | static char a[18]; |
|---|
| 5663 | int i; |
|---|
| 5664 | |
|---|
| 5665 | i = snprintf(a, sizeof(a), "%02x:%02x:%02x:%02x:%02x:%02x", |
|---|
| 5666 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); |
|---|
| 5667 | return (i < 17 ? NULL : a); |
|---|
| 5668 | } |
|---|
| 5669 | |
|---|
| 5670 | int |
|---|
| 5671 | ej_active_wireless_if(webs_t wp, int argc, char_t ** argv, |
|---|
| 5672 | char *ifname, int cnt, int turbo, int macmask) |
|---|
| 5673 | { |
|---|
| 5674 | // unsigned char buf[24 * 1024]; |
|---|
| 5675 | |
|---|
| 5676 | unsigned char *cp; |
|---|
| 5677 | int s, len; |
|---|
| 5678 | struct iwreq iwr; |
|---|
| 5679 | char nb[32]; |
|---|
| 5680 | sprintf(nb,"%s_bias",ifname); |
|---|
| 5681 | int bias = atoi(nvram_default_get(nb,"0")); |
|---|
| 5682 | if (!ifexists(ifname)) { |
|---|
| 5683 | printf("IOCTL_STA_INFO ifresolv %s failed!\n", ifname); |
|---|
| 5684 | return cnt; |
|---|
| 5685 | } |
|---|
| 5686 | int state = get_radiostate(ifname); |
|---|
| 5687 | |
|---|
| 5688 | if (state == 0 || state == -1) { |
|---|
| 5689 | printf("IOCTL_STA_INFO radio %s not enabled!\n", ifname); |
|---|
| 5690 | return cnt; |
|---|
| 5691 | } |
|---|
| 5692 | s = socket(AF_INET, SOCK_DGRAM, 0); |
|---|
| 5693 | if (s < 0) { |
|---|
| 5694 | fprintf(stderr, "socket(SOCK_DRAGM)\n"); |
|---|
| 5695 | return cnt; |
|---|
| 5696 | } |
|---|
| 5697 | (void)memset(&iwr, 0, sizeof(struct iwreq)); |
|---|
| 5698 | (void)strncpy(iwr.ifr_name, ifname, sizeof(iwr.ifr_name)); |
|---|
| 5699 | unsigned char *buf = (unsigned char *)malloc(24 * 1024); |
|---|
| 5700 | |
|---|
| 5701 | iwr.u.data.pointer = (void *)buf; |
|---|
| 5702 | iwr.u.data.length = 24 * 1024; |
|---|
| 5703 | if (ioctl(s, IEEE80211_IOCTL_STA_INFO, &iwr) < 0) { |
|---|
| 5704 | fprintf(stderr, "IOCTL_STA_INFO for %s failed!\n", ifname); |
|---|
| 5705 | close(s); |
|---|
| 5706 | free(buf); |
|---|
| 5707 | return cnt; |
|---|
| 5708 | } |
|---|
| 5709 | len = iwr.u.data.length; |
|---|
| 5710 | if (len < sizeof(struct ieee80211req_sta_info)) { |
|---|
| 5711 | // fprintf(stderr,"IOCTL_STA_INFO len<struct %s failed!\n",ifname); |
|---|
| 5712 | close(s); |
|---|
| 5713 | free(buf); |
|---|
| 5714 | return cnt; |
|---|
| 5715 | } |
|---|
| 5716 | cp = buf; |
|---|
| 5717 | do { |
|---|
| 5718 | struct ieee80211req_sta_info *si; |
|---|
| 5719 | uint8_t *vp; |
|---|
| 5720 | |
|---|
| 5721 | si = (struct ieee80211req_sta_info *)cp; |
|---|
| 5722 | vp = (u_int8_t *)(si + 1); |
|---|
| 5723 | |
|---|
| 5724 | if (cnt) |
|---|
| 5725 | websWrite(wp, ","); |
|---|
| 5726 | cnt++; |
|---|
| 5727 | char mac[32]; |
|---|
| 5728 | |
|---|
| 5729 | strcpy(mac, ieee80211_ntoa(si->isi_macaddr)); |
|---|
| 5730 | if (nvram_match("maskmac", "1") && macmask) { |
|---|
| 5731 | mac[0] = 'x'; |
|---|
| 5732 | mac[1] = 'x'; |
|---|
| 5733 | mac[3] = 'x'; |
|---|
| 5734 | mac[4] = 'x'; |
|---|
| 5735 | mac[6] = 'x'; |
|---|
| 5736 | mac[7] = 'x'; |
|---|
| 5737 | mac[9] = 'x'; |
|---|
| 5738 | mac[10] = 'x'; |
|---|
| 5739 | } |
|---|
| 5740 | if (si->isi_noise == 0) { |
|---|
| 5741 | si->isi_noise = -95; |
|---|
| 5742 | } |
|---|
| 5743 | int qual = (si->isi_noise + si->isi_rssi) * 124 + 11600; |
|---|
| 5744 | qual /= 10; |
|---|
| 5745 | |
|---|
| 5746 | if (si->isi_rates |
|---|
| 5747 | && ((si->isi_rates[si->isi_txrate] & IEEE80211_RATE_VAL) != |
|---|
| 5748 | 0) |
|---|
| 5749 | && ((si->isi_rates[si->isi_rxrate] & IEEE80211_RATE_VAL) != |
|---|
| 5750 | 0)) { |
|---|
| 5751 | websWrite(wp, |
|---|
| 5752 | "'%s','%s','%s','%3dM','%3dM','%d','%d','%d','%d'", |
|---|
| 5753 | mac, ifname, UPTIME(si->isi_uptime), |
|---|
| 5754 | ((si->isi_rates[si->isi_txrate] & |
|---|
| 5755 | IEEE80211_RATE_VAL) / 2) * turbo, |
|---|
| 5756 | ((si->isi_rates[si->isi_rxrate] & |
|---|
| 5757 | IEEE80211_RATE_VAL) / 2) * turbo, |
|---|
| 5758 | si->isi_noise + si->isi_rssi, si->isi_noise + bias, |
|---|
| 5759 | si->isi_rssi + bias, qual); |
|---|
| 5760 | } else { |
|---|
| 5761 | websWrite(wp, |
|---|
| 5762 | "'%s','%s','%s','N/A','N/A','%d','%d','%d','%d'", |
|---|
| 5763 | mac, ifname, UPTIME(si->isi_uptime), |
|---|
| 5764 | si->isi_noise + si->isi_rssi, si->isi_noise + bias, |
|---|
| 5765 | si->isi_rssi + bias, qual); |
|---|
| 5766 | } |
|---|
| 5767 | cp += si->isi_len; |
|---|
| 5768 | len -= si->isi_len; |
|---|
| 5769 | } |
|---|
| 5770 | while (len >= sizeof(struct ieee80211req_sta_info)); |
|---|
| 5771 | free(buf); |
|---|
| 5772 | close(s); |
|---|
| 5773 | |
|---|
| 5774 | return cnt; |
|---|
| 5775 | } |
|---|
| 5776 | |
|---|
| 5777 | extern char *getiflist(void); |
|---|
| 5778 | |
|---|
| 5779 | void ej_active_wireless(webs_t wp, int argc, char_t ** argv) |
|---|
| 5780 | { |
|---|
| 5781 | int c = getdevicecount(); |
|---|
| 5782 | char devs[32]; |
|---|
| 5783 | int i; |
|---|
| 5784 | int cnt = 0; |
|---|
| 5785 | char turbo[32]; |
|---|
| 5786 | int t; |
|---|
| 5787 | int macmask; |
|---|
| 5788 | |
|---|
| 5789 | #ifdef FASTWEB |
|---|
| 5790 | ejArgs(argc, argv, "%d", &macmask); |
|---|
| 5791 | #else |
|---|
| 5792 | if (ejArgs(argc, argv, "%d", &macmask) < 1) { |
|---|
| 5793 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 5794 | return; |
|---|
| 5795 | } |
|---|
| 5796 | #endif |
|---|
| 5797 | for (i = 0; i < c; i++) { |
|---|
| 5798 | sprintf(devs, "ath%d", i); |
|---|
| 5799 | sprintf(turbo, "%s_channelbw", devs); |
|---|
| 5800 | if (nvram_match(turbo, "40")) |
|---|
| 5801 | t = 2; |
|---|
| 5802 | else |
|---|
| 5803 | t = 1; |
|---|
| 5804 | cnt = |
|---|
| 5805 | ej_active_wireless_if(wp, argc, argv, devs, cnt, t, |
|---|
| 5806 | macmask); |
|---|
| 5807 | char vif[32]; |
|---|
| 5808 | |
|---|
| 5809 | sprintf(vif, "%s_vifs", devs); |
|---|
| 5810 | char var[80], *next; |
|---|
| 5811 | char *vifs = nvram_get(vif); |
|---|
| 5812 | |
|---|
| 5813 | if (vifs != NULL) |
|---|
| 5814 | foreach(var, vifs, next) { |
|---|
| 5815 | cnt = |
|---|
| 5816 | ej_active_wireless_if(wp, argc, argv, var, cnt, t, |
|---|
| 5817 | macmask); |
|---|
| 5818 | } |
|---|
| 5819 | } |
|---|
| 5820 | |
|---|
| 5821 | // show wds links |
|---|
| 5822 | for (i = 0; i < c; i++) { |
|---|
| 5823 | |
|---|
| 5824 | int s; |
|---|
| 5825 | |
|---|
| 5826 | for (s = 1; s <= 10; s++) { |
|---|
| 5827 | char wdsvarname[32] = { 0 }; |
|---|
| 5828 | char wdsdevname[32] = { 0 }; |
|---|
| 5829 | char wdsmacname[32] = { 0 }; |
|---|
| 5830 | char *dev; |
|---|
| 5831 | char *hwaddr; |
|---|
| 5832 | char var[80]; |
|---|
| 5833 | |
|---|
| 5834 | sprintf(wdsvarname, "ath%d_wds%d_enable", i, s); |
|---|
| 5835 | sprintf(wdsdevname, "ath%d_wds%d_if", i, s); |
|---|
| 5836 | sprintf(wdsmacname, "ath%d_wds%d_hwaddr", i, s); |
|---|
| 5837 | sprintf(turbo, "ath%d_channelbw", i); |
|---|
| 5838 | if (nvram_match(turbo, "40")) |
|---|
| 5839 | t = 2; |
|---|
| 5840 | else |
|---|
| 5841 | t = 1; |
|---|
| 5842 | |
|---|
| 5843 | dev = nvram_safe_get(wdsdevname); |
|---|
| 5844 | if (dev == NULL || strlen(dev) == 0) |
|---|
| 5845 | continue; |
|---|
| 5846 | if (nvram_match(wdsvarname, "0")) |
|---|
| 5847 | continue; |
|---|
| 5848 | cnt = |
|---|
| 5849 | ej_active_wireless_if(wp, argc, argv, dev, cnt, t, |
|---|
| 5850 | macmask); |
|---|
| 5851 | } |
|---|
| 5852 | } |
|---|
| 5853 | } |
|---|
| 5854 | |
|---|
| 5855 | #elif HAVE_RT2880 |
|---|
| 5856 | |
|---|
| 5857 | #include <sys/types.h> |
|---|
| 5858 | #include <sys/file.h> |
|---|
| 5859 | #include <sys/ioctl.h> |
|---|
| 5860 | #include <sys/socket.h> |
|---|
| 5861 | #include <stdio.h> |
|---|
| 5862 | #include <stdlib.h> |
|---|
| 5863 | #include <string.h> |
|---|
| 5864 | #include <stdint.h> |
|---|
| 5865 | #include <ctype.h> |
|---|
| 5866 | #include <getopt.h> |
|---|
| 5867 | #include <err.h> |
|---|
| 5868 | |
|---|
| 5869 | #include "wireless_copy.h" |
|---|
| 5870 | static const char *ieee80211_ntoa(const uint8_t mac[6]) |
|---|
| 5871 | { |
|---|
| 5872 | static char a[18]; |
|---|
| 5873 | int i; |
|---|
| 5874 | |
|---|
| 5875 | i = snprintf(a, sizeof(a), "%02x:%02x:%02x:%02x:%02x:%02x", |
|---|
| 5876 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); |
|---|
| 5877 | return (i < 17 ? NULL : a); |
|---|
| 5878 | } |
|---|
| 5879 | |
|---|
| 5880 | |
|---|
| 5881 | typedef union _MACHTTRANSMIT_SETTING { |
|---|
| 5882 | struct { |
|---|
| 5883 | unsigned short MCS:7; // MCS |
|---|
| 5884 | unsigned short BW:1; //channel bandwidth 20MHz or 40 MHz |
|---|
| 5885 | unsigned short ShortGI:1; |
|---|
| 5886 | unsigned short STBC:2; //SPACE |
|---|
| 5887 | unsigned short rsv:3; |
|---|
| 5888 | unsigned short MODE:2; // Use definition MODE_xxx. |
|---|
| 5889 | } field; |
|---|
| 5890 | unsigned short word; |
|---|
| 5891 | } MACHTTRANSMIT_SETTING; |
|---|
| 5892 | |
|---|
| 5893 | typedef struct _RT_802_11_MAC_ENTRY { |
|---|
| 5894 | unsigned char Addr[6]; |
|---|
| 5895 | unsigned char Aid; |
|---|
| 5896 | unsigned char Psm; // 0:PWR_ACTIVE, 1:PWR_SAVE |
|---|
| 5897 | unsigned char MimoPs; // 0:MMPS_STATIC, 1:MMPS_DYNAMIC, 3:MMPS_Enabled |
|---|
| 5898 | char AvgRssi0; |
|---|
| 5899 | char AvgRssi1; |
|---|
| 5900 | char AvgRssi2; |
|---|
| 5901 | unsigned int ConnectedTime; |
|---|
| 5902 | MACHTTRANSMIT_SETTING TxRate; |
|---|
| 5903 | } RT_802_11_MAC_ENTRY; |
|---|
| 5904 | |
|---|
| 5905 | |
|---|
| 5906 | typedef struct _RT_802_11_MAC_TABLE { |
|---|
| 5907 | unsigned long Num; |
|---|
| 5908 | RT_802_11_MAC_ENTRY Entry[128]; //MAX_LEN_OF_MAC_TABLE = 32 |
|---|
| 5909 | } RT_802_11_MAC_TABLE; |
|---|
| 5910 | |
|---|
| 5911 | #define RTPRIV_IOCTL_GET_MAC_TABLE (SIOCIWFIRSTPRIV + 0x0F) |
|---|
| 5912 | |
|---|
| 5913 | typedef struct STAINFO { |
|---|
| 5914 | char mac[6]; |
|---|
| 5915 | char rssi; |
|---|
| 5916 | char noise; |
|---|
| 5917 | char ifname[32]; |
|---|
| 5918 | } STAINFO; |
|---|
| 5919 | |
|---|
| 5920 | int |
|---|
| 5921 | ej_active_wireless_if(webs_t wp, int argc, char_t ** argv, |
|---|
| 5922 | char *ifname, int cnt, int turbo, int macmask) |
|---|
| 5923 | { |
|---|
| 5924 | |
|---|
| 5925 | RT_802_11_MAC_TABLE table = { 0 }; |
|---|
| 5926 | |
|---|
| 5927 | unsigned char *cp; |
|---|
| 5928 | int s, len, i; |
|---|
| 5929 | struct iwreq iwr; |
|---|
| 5930 | int ignore = 0; |
|---|
| 5931 | |
|---|
| 5932 | if (!ifexists(ifname)) { |
|---|
| 5933 | printf("IOCTL_STA_INFO ifresolv %s failed!\n", ifname); |
|---|
| 5934 | return cnt; |
|---|
| 5935 | } |
|---|
| 5936 | int state = get_radiostate(ifname); |
|---|
| 5937 | |
|---|
| 5938 | if (state == 0 || state == -1) { |
|---|
| 5939 | return cnt; |
|---|
| 5940 | } |
|---|
| 5941 | s = socket(AF_INET, SOCK_DGRAM, 0); |
|---|
| 5942 | if (s < 0) { |
|---|
| 5943 | return cnt; |
|---|
| 5944 | } |
|---|
| 5945 | (void)memset(&iwr, 0, sizeof(struct iwreq)); |
|---|
| 5946 | (void)strncpy(iwr.ifr_name, ifname, sizeof(iwr.ifr_name)); |
|---|
| 5947 | |
|---|
| 5948 | iwr.u.data.pointer = (caddr_t) & table; |
|---|
| 5949 | // iwr.u.data.length = 24 * 1024; |
|---|
| 5950 | if (ioctl(s, RTPRIV_IOCTL_GET_MAC_TABLE, &iwr) < 0) { |
|---|
| 5951 | ignore = 1; |
|---|
| 5952 | } |
|---|
| 5953 | |
|---|
| 5954 | if (!ignore && table.Num < 128) |
|---|
| 5955 | for (i = 0; i < table.Num; i++) { |
|---|
| 5956 | if (cnt) |
|---|
| 5957 | websWrite(wp, ","); |
|---|
| 5958 | cnt++; |
|---|
| 5959 | char mac[32]; |
|---|
| 5960 | strcpy(mac, ieee80211_ntoa(table.Entry[i].Addr)); |
|---|
| 5961 | if (nvram_match("maskmac", "1") && macmask) { |
|---|
| 5962 | mac[0] = 'x'; |
|---|
| 5963 | mac[1] = 'x'; |
|---|
| 5964 | mac[3] = 'x'; |
|---|
| 5965 | mac[4] = 'x'; |
|---|
| 5966 | mac[6] = 'x'; |
|---|
| 5967 | mac[7] = 'x'; |
|---|
| 5968 | mac[9] = 'x'; |
|---|
| 5969 | mac[10] = 'x'; |
|---|
| 5970 | } |
|---|
| 5971 | #if 0 |
|---|
| 5972 | if (si->isi_rates |
|---|
| 5973 | && |
|---|
| 5974 | ((si-> |
|---|
| 5975 | isi_rates[si->isi_txrate] & IEEE80211_RATE_VAL) != |
|---|
| 5976 | 0) |
|---|
| 5977 | && |
|---|
| 5978 | ((si-> |
|---|
| 5979 | isi_rates[si->isi_rxrate] & IEEE80211_RATE_VAL) != |
|---|
| 5980 | 0)) { |
|---|
| 5981 | websWrite(wp, |
|---|
| 5982 | "'%s','%s','%3dM','%3dM','%d','%d','%d'", |
|---|
| 5983 | mac, ifname, |
|---|
| 5984 | ((si->isi_rates[si->isi_txrate] & |
|---|
| 5985 | IEEE80211_RATE_VAL) / 2) * turbo, |
|---|
| 5986 | ((si->isi_rates[si->isi_rxrate] & |
|---|
| 5987 | IEEE80211_RATE_VAL) / 2) * turbo, |
|---|
| 5988 | -95 + table.Entry[i].AvgRssi0, -95, |
|---|
| 5989 | table.Entry[i].AvgRssi0); |
|---|
| 5990 | } else |
|---|
| 5991 | //* 1.24 + 116 |
|---|
| 5992 | #endif |
|---|
| 5993 | { |
|---|
| 5994 | int qual = |
|---|
| 5995 | table.Entry[i].AvgRssi0 * 124 + 11600; |
|---|
| 5996 | qual /= 10; |
|---|
| 5997 | |
|---|
| 5998 | websWrite(wp, |
|---|
| 5999 | "'%s','%s','N/A','N/A','N/A','%d','%d','%d','%d'", |
|---|
| 6000 | mac, ifname, table.Entry[i].AvgRssi0, |
|---|
| 6001 | -95, |
|---|
| 6002 | (table.Entry[i].AvgRssi0 - (-95)), |
|---|
| 6003 | qual); |
|---|
| 6004 | } |
|---|
| 6005 | } |
|---|
| 6006 | STAINFO *sta = getRaStaInfo("wl0"); |
|---|
| 6007 | |
|---|
| 6008 | if (sta) { |
|---|
| 6009 | char mac[32]; |
|---|
| 6010 | |
|---|
| 6011 | int qual = sta->rssi * 124 + 11600; |
|---|
| 6012 | qual /= 10; |
|---|
| 6013 | strcpy(mac, ieee80211_ntoa(sta->mac)); |
|---|
| 6014 | websWrite(wp, "'%s','%s','N/A','N/A','N/A','%d','%d','%d','%d'", |
|---|
| 6015 | mac, sta->ifname, sta->rssi, sta->noise, |
|---|
| 6016 | (sta->rssi - (sta->noise)), qual); |
|---|
| 6017 | free(sta); |
|---|
| 6018 | |
|---|
| 6019 | } |
|---|
| 6020 | |
|---|
| 6021 | close(s); |
|---|
| 6022 | return cnt; |
|---|
| 6023 | } |
|---|
| 6024 | |
|---|
| 6025 | extern char *getiflist(void); |
|---|
| 6026 | |
|---|
| 6027 | void ej_active_wireless(webs_t wp, int argc, char_t ** argv) |
|---|
| 6028 | { |
|---|
| 6029 | char devs[32]; |
|---|
| 6030 | int i; |
|---|
| 6031 | int cnt = 0; |
|---|
| 6032 | char turbo[32]; |
|---|
| 6033 | int t; |
|---|
| 6034 | int macmask; |
|---|
| 6035 | |
|---|
| 6036 | #ifdef FASTWEB |
|---|
| 6037 | ejArgs(argc, argv, "%d", &macmask); |
|---|
| 6038 | #else |
|---|
| 6039 | if (ejArgs(argc, argv, "%d", &macmask) < 1) { |
|---|
| 6040 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 6041 | return; |
|---|
| 6042 | } |
|---|
| 6043 | #endif |
|---|
| 6044 | sprintf(devs, "ra0"); |
|---|
| 6045 | t = 1; |
|---|
| 6046 | cnt = ej_active_wireless_if(wp, argc, argv, "ra0", cnt, t, macmask); |
|---|
| 6047 | |
|---|
| 6048 | } |
|---|
| 6049 | |
|---|
| 6050 | #else |
|---|
| 6051 | |
|---|
| 6052 | #define RSSI_TMP "/tmp/.rssi" |
|---|
| 6053 | #define ASSOCLIST_CMD "wl assoclist" |
|---|
| 6054 | #define RSSI_CMD "wl rssi" |
|---|
| 6055 | #define NOISE_CMD "wl noise" |
|---|
| 6056 | |
|---|
| 6057 | int |
|---|
| 6058 | ej_active_wireless_if(webs_t wp, int argc, char_t ** argv, |
|---|
| 6059 | char *iface, char *visible, int cnt) |
|---|
| 6060 | { |
|---|
| 6061 | int rssi = 0, noise = 0; |
|---|
| 6062 | FILE *fp2; |
|---|
| 6063 | char *mode; |
|---|
| 6064 | char mac[30]; |
|---|
| 6065 | char line[80]; |
|---|
| 6066 | int macmask; |
|---|
| 6067 | macmask = atoi(argv[0]); |
|---|
| 6068 | if (!ifexists(iface)) |
|---|
| 6069 | return cnt; |
|---|
| 6070 | unlink(RSSI_TMP); |
|---|
| 6071 | char wlmode[32]; |
|---|
| 6072 | |
|---|
| 6073 | sprintf(wlmode, "%s_mode", visible); |
|---|
| 6074 | mode = nvram_safe_get(wlmode); |
|---|
| 6075 | unsigned char buf[WLC_IOCTL_MAXLEN]; |
|---|
| 6076 | |
|---|
| 6077 | memset(buf, 0, WLC_IOCTL_MAXLEN); // get_wdev |
|---|
| 6078 | int r = getassoclist(iface, buf); |
|---|
| 6079 | |
|---|
| 6080 | if (r < 0) |
|---|
| 6081 | return cnt; |
|---|
| 6082 | struct maclist *maclist = (struct maclist *)buf; |
|---|
| 6083 | int i; |
|---|
| 6084 | |
|---|
| 6085 | for (i = 0; i < maclist->count; i++) { |
|---|
| 6086 | ether_etoa((uint8 *) & maclist->ea[i], mac); |
|---|
| 6087 | |
|---|
| 6088 | rssi = 0; |
|---|
| 6089 | noise = 0; |
|---|
| 6090 | // get rssi value |
|---|
| 6091 | if (strcmp(mode, "ap") && strcmp(mode, "apsta") |
|---|
| 6092 | && strcmp(mode, "apstawet")) |
|---|
| 6093 | sysprintf("wl -i %s rssi > %s", iface, RSSI_TMP); |
|---|
| 6094 | else |
|---|
| 6095 | sysprintf("wl -i %s rssi \"%s\" > %s", iface, mac, |
|---|
| 6096 | RSSI_TMP); |
|---|
| 6097 | |
|---|
| 6098 | // get noise value if not ap mode |
|---|
| 6099 | // if (strcmp (mode, "ap")) |
|---|
| 6100 | // snprintf (cmd, sizeof (cmd), "wl -i %s noise >> %s", iface, |
|---|
| 6101 | // RSSI_TMP); |
|---|
| 6102 | // system2 (cmd); // get RSSI value for mac |
|---|
| 6103 | |
|---|
| 6104 | fp2 = fopen(RSSI_TMP, "r"); |
|---|
| 6105 | if (fgets(line, sizeof(line), fp2) != NULL) { |
|---|
| 6106 | |
|---|
| 6107 | // get rssi |
|---|
| 6108 | if (sscanf(line, "%d", &rssi) != 1) |
|---|
| 6109 | continue; |
|---|
| 6110 | noise = getNoise(iface, NULL); |
|---|
| 6111 | /* |
|---|
| 6112 | * if (strcmp (mode, "ap") && fgets (line, sizeof (line), fp2) != |
|---|
| 6113 | * NULL && sscanf (line, "%d", &noise) != 1) continue; |
|---|
| 6114 | */ |
|---|
| 6115 | // get noise for client/wet mode |
|---|
| 6116 | |
|---|
| 6117 | fclose(fp2); |
|---|
| 6118 | } |
|---|
| 6119 | if (nvram_match("maskmac", "1") && macmask) { |
|---|
| 6120 | mac[0] = 'x'; |
|---|
| 6121 | mac[1] = 'x'; |
|---|
| 6122 | mac[3] = 'x'; |
|---|
| 6123 | mac[4] = 'x'; |
|---|
| 6124 | mac[6] = 'x'; |
|---|
| 6125 | mac[7] = 'x'; |
|---|
| 6126 | mac[9] = 'x'; |
|---|
| 6127 | mac[10] = 'x'; |
|---|
| 6128 | } |
|---|
| 6129 | if (cnt) |
|---|
| 6130 | websWrite(wp, ","); |
|---|
| 6131 | cnt++; |
|---|
| 6132 | /* |
|---|
| 6133 | * if (!strcmp (mode, "ap")) { noise = getNoise(iface,NULL); // null |
|---|
| 6134 | * only for broadcom } |
|---|
| 6135 | */ |
|---|
| 6136 | int qual = rssi * 124 + 11600; |
|---|
| 6137 | qual /= 10; |
|---|
| 6138 | websWrite(wp, "'%s','%s','N/A','N/A','N/A','%d','%d','%d','%d'", |
|---|
| 6139 | mac, iface, rssi, noise, rssi - noise, qual); |
|---|
| 6140 | } |
|---|
| 6141 | unlink(RSSI_TMP); |
|---|
| 6142 | |
|---|
| 6143 | return cnt; |
|---|
| 6144 | } |
|---|
| 6145 | |
|---|
| 6146 | void ej_active_wireless(webs_t wp, int argc, char_t ** argv) |
|---|
| 6147 | { |
|---|
| 6148 | int cnt = 0; |
|---|
| 6149 | int c = get_wl_instances(); |
|---|
| 6150 | int i; |
|---|
| 6151 | |
|---|
| 6152 | for (i = 0; i < c; i++) { |
|---|
| 6153 | char wlif[32]; |
|---|
| 6154 | |
|---|
| 6155 | sprintf(wlif, "wl%d", i); |
|---|
| 6156 | cnt = |
|---|
| 6157 | ej_active_wireless_if(wp, argc, argv, |
|---|
| 6158 | get_wl_instance_name(i), wlif, cnt); |
|---|
| 6159 | char *next; |
|---|
| 6160 | char var[80]; |
|---|
| 6161 | char *vifs = nvram_nget("wl%d_vifs", i); |
|---|
| 6162 | |
|---|
| 6163 | if (vifs == NULL) |
|---|
| 6164 | return; |
|---|
| 6165 | |
|---|
| 6166 | foreach(var, vifs, next) { |
|---|
| 6167 | cnt = |
|---|
| 6168 | ej_active_wireless_if(wp, argc, argv, var, var, |
|---|
| 6169 | cnt); |
|---|
| 6170 | } |
|---|
| 6171 | } |
|---|
| 6172 | } |
|---|
| 6173 | |
|---|
| 6174 | #endif |
|---|
| 6175 | |
|---|
| 6176 | #define WDS_RSSI_TMP "/tmp/.rssi" |
|---|
| 6177 | int ej_active_wds_instance(webs_t wp, int argc, char_t ** argv, |
|---|
| 6178 | int instance, int cnt); |
|---|
| 6179 | void ej_active_wds(webs_t wp, int argc, char_t ** argv) |
|---|
| 6180 | { |
|---|
| 6181 | int cnt = 0; |
|---|
| 6182 | int c = get_wl_instances(); |
|---|
| 6183 | int i; |
|---|
| 6184 | |
|---|
| 6185 | for (i = 0; i < c; i++) { |
|---|
| 6186 | cnt = ej_active_wds_instance(wp, argc, argv, i, cnt); |
|---|
| 6187 | } |
|---|
| 6188 | } |
|---|
| 6189 | |
|---|
| 6190 | int |
|---|
| 6191 | ej_active_wds_instance(webs_t wp, int argc, char_t ** argv, int instance, |
|---|
| 6192 | int cnt) |
|---|
| 6193 | { |
|---|
| 6194 | #if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880) |
|---|
| 6195 | int rssi = 0, i; |
|---|
| 6196 | FILE *fp2; |
|---|
| 6197 | char *mode; |
|---|
| 6198 | char mac[30]; |
|---|
| 6199 | char line[80]; |
|---|
| 6200 | |
|---|
| 6201 | // char title[30]; |
|---|
| 6202 | char wdsvar[30]; |
|---|
| 6203 | char desc[30]; |
|---|
| 6204 | int macmask; |
|---|
| 6205 | |
|---|
| 6206 | if (ejArgs(argc, argv, "%d", &macmask) < 1) { |
|---|
| 6207 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 6208 | return cnt; |
|---|
| 6209 | } |
|---|
| 6210 | |
|---|
| 6211 | unlink(WDS_RSSI_TMP); |
|---|
| 6212 | |
|---|
| 6213 | mode = nvram_nget("wl%d_mode", instance); |
|---|
| 6214 | |
|---|
| 6215 | if (strcmp(mode, "ap") && strcmp(mode, "apsta") |
|---|
| 6216 | && strcmp(mode, "apstawet")) |
|---|
| 6217 | return cnt; |
|---|
| 6218 | unsigned char buf[WLC_IOCTL_MAXLEN]; |
|---|
| 6219 | char *iface = get_wl_instance_name(instance); |
|---|
| 6220 | |
|---|
| 6221 | if (!ifexists(iface)) |
|---|
| 6222 | return cnt; |
|---|
| 6223 | int r = getwdslist(iface, buf); |
|---|
| 6224 | |
|---|
| 6225 | if (r < 0) |
|---|
| 6226 | return cnt; |
|---|
| 6227 | struct maclist *maclist = (struct maclist *)buf; |
|---|
| 6228 | int e; |
|---|
| 6229 | |
|---|
| 6230 | for (e = 0; e < maclist->count; e++) { |
|---|
| 6231 | |
|---|
| 6232 | ether_etoa((uint8 *) & maclist->ea[e], mac); |
|---|
| 6233 | |
|---|
| 6234 | rssi = 0; |
|---|
| 6235 | memset(desc, 0, 30); |
|---|
| 6236 | for (i = 1; i <= 10; i++) { |
|---|
| 6237 | snprintf(wdsvar, 30, "wl%d_wds%d_hwaddr", instance, i); |
|---|
| 6238 | if (nvram_match(wdsvar, mac)) { |
|---|
| 6239 | snprintf(wdsvar, 30, "wl%d_wds%d_desc", |
|---|
| 6240 | instance, i); |
|---|
| 6241 | snprintf(desc, sizeof(desc), "%s", |
|---|
| 6242 | nvram_get(wdsvar)); |
|---|
| 6243 | if (!strcmp(nvram_get(wdsvar), "")) |
|---|
| 6244 | strcpy(desc, " "); |
|---|
| 6245 | } |
|---|
| 6246 | } |
|---|
| 6247 | |
|---|
| 6248 | sysprintf("wl -i %s rssi \"%s\" > %s", iface, mac, RSSI_TMP); |
|---|
| 6249 | |
|---|
| 6250 | fp2 = fopen(RSSI_TMP, "r"); |
|---|
| 6251 | if (fgets(line, sizeof(line), fp2) != NULL) { |
|---|
| 6252 | |
|---|
| 6253 | // get rssi |
|---|
| 6254 | if (sscanf(line, "%d", &rssi) != 1) |
|---|
| 6255 | continue; |
|---|
| 6256 | fclose(fp2); |
|---|
| 6257 | } |
|---|
| 6258 | if (nvram_match("maskmac", "1") && macmask) { |
|---|
| 6259 | mac[0] = 'x'; |
|---|
| 6260 | mac[1] = 'x'; |
|---|
| 6261 | mac[3] = 'x'; |
|---|
| 6262 | mac[4] = 'x'; |
|---|
| 6263 | mac[6] = 'x'; |
|---|
| 6264 | mac[7] = 'x'; |
|---|
| 6265 | mac[9] = 'x'; |
|---|
| 6266 | mac[10] = 'x'; |
|---|
| 6267 | } |
|---|
| 6268 | if (cnt) |
|---|
| 6269 | websWrite(wp, ","); |
|---|
| 6270 | cnt++; |
|---|
| 6271 | int noise = getNoise(iface, NULL); |
|---|
| 6272 | |
|---|
| 6273 | websWrite(wp, |
|---|
| 6274 | "\"%s\",\"%s\",\"%s\",\"%d\",\"%d\",\"%d\"", |
|---|
| 6275 | mac, iface, desc, rssi, noise, rssi - noise); |
|---|
| 6276 | } |
|---|
| 6277 | |
|---|
| 6278 | unlink(WDS_RSSI_TMP); |
|---|
| 6279 | #endif |
|---|
| 6280 | return cnt; |
|---|
| 6281 | } |
|---|
| 6282 | |
|---|
| 6283 | void ej_get_wdsp2p(webs_t wp, int argc, char_t ** argv) |
|---|
| 6284 | { |
|---|
| 6285 | int index = -1, ip[4] = { 0, 0, 0, 0 }, netmask[4] = { |
|---|
| 6286 | 0, 0, 0, 0}; |
|---|
| 6287 | char nvramvar[32] = { 0 }; |
|---|
| 6288 | char *interface; |
|---|
| 6289 | |
|---|
| 6290 | #ifdef FASTWEB |
|---|
| 6291 | ejArgs(argc, argv, "%d %s", &index, &interface); |
|---|
| 6292 | #else |
|---|
| 6293 | if (ejArgs(argc, argv, "%d %s", &index, &interface) < 2) { |
|---|
| 6294 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 6295 | return; |
|---|
| 6296 | } |
|---|
| 6297 | #endif |
|---|
| 6298 | char wlwds[32]; |
|---|
| 6299 | |
|---|
| 6300 | sprintf(wlwds, "%s_wds1_enable", interface); |
|---|
| 6301 | if (nvram_selmatch(wp, "wk_mode", "ospf") && |
|---|
| 6302 | nvram_selmatch(wp, "expert_mode", "1") && |
|---|
| 6303 | nvram_selmatch(wp, wlwds, "1")) { |
|---|
| 6304 | char buf[16]; |
|---|
| 6305 | |
|---|
| 6306 | sprintf(buf, "%s_wds%d_ospf", interface, index); |
|---|
| 6307 | websWrite(wp, |
|---|
| 6308 | "<input name=\"%s\" size=\"2\" maxlength=\"5\" value=\"%s\" />\n", |
|---|
| 6309 | buf, nvram_safe_get(buf)); |
|---|
| 6310 | } |
|---|
| 6311 | |
|---|
| 6312 | snprintf(nvramvar, 31, "%s_wds%d_ipaddr", interface, index); |
|---|
| 6313 | sscanf(nvram_safe_get(nvramvar), "%d.%d.%d.%d", &ip[0], &ip[1], &ip[2], |
|---|
| 6314 | &ip[3]); |
|---|
| 6315 | snprintf(nvramvar, 31, "%s_wds%d_netmask", interface, index); |
|---|
| 6316 | sscanf(nvram_safe_get(nvramvar), "%d.%d.%d.%d", &netmask[0], |
|---|
| 6317 | &netmask[1], &netmask[2], &netmask[3]); |
|---|
| 6318 | snprintf(nvramvar, 31, "%s_wds%d_enable", interface, index); |
|---|
| 6319 | |
|---|
| 6320 | // set netmask to a suggested default if blank |
|---|
| 6321 | if (netmask[0] == 0 && |
|---|
| 6322 | netmask[1] == 0 && netmask[2] == 0 && netmask[3] == 0) { |
|---|
| 6323 | netmask[0] = 255; |
|---|
| 6324 | netmask[1] = 255; |
|---|
| 6325 | netmask[2] = 255; |
|---|
| 6326 | netmask[3] = 252; |
|---|
| 6327 | } |
|---|
| 6328 | |
|---|
| 6329 | if (nvram_match(nvramvar, "1")) { |
|---|
| 6330 | websWrite(wp, "\ |
|---|
| 6331 | <div class=\"setting\">\n\ |
|---|
| 6332 | <input type=\"hidden\" name=\"%s_wds%d_ipaddr\" value=\"4\">\n\ |
|---|
| 6333 | <div class=\"label\"><script type=\"text/javascript\">Capture(share.ip)</script></div>\n\ |
|---|
| 6334 | <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\ |
|---|
| 6335 | </div>\n", interface, index, interface, index, ip[0], interface, index, ip[1], interface, index, ip[2], interface, index, ip[3]); |
|---|
| 6336 | |
|---|
| 6337 | websWrite(wp, "\ |
|---|
| 6338 | <div class=\"setting\">\n\ |
|---|
| 6339 | <div class=\"label\"><script type=\"text/javascript\">Capture(share.subnet)</script></div>\n\ |
|---|
| 6340 | <input type=\"hidden\" name=\"%s_wds%d_netmask\" value=\"4\">\n\ |
|---|
| 6341 | <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\ |
|---|
| 6342 | </div>\n", interface, index, interface, index, netmask[0], interface, index, netmask[1], interface, index, netmask[2], interface, index, netmask[3]); |
|---|
| 6343 | |
|---|
| 6344 | } |
|---|
| 6345 | |
|---|
| 6346 | return; |
|---|
| 6347 | |
|---|
| 6348 | } |
|---|
| 6349 | |
|---|
| 6350 | /* |
|---|
| 6351 | * void ej_get_services_options (webs_t wp, int argc, char_t ** argv) { char |
|---|
| 6352 | * word[1024], *next, *services; char delim[] = "< >"; |
|---|
| 6353 | * |
|---|
| 6354 | * //services = nvram_safe_get("filter_services"); services = |
|---|
| 6355 | * get_filter_services (); |
|---|
| 6356 | * |
|---|
| 6357 | * split (word, services, next, delim) { int len = 0; char *name, *prot, |
|---|
| 6358 | * *port; char protocol[100], ports[100]; int from = 0, to = 0; //int proto; |
|---|
| 6359 | * |
|---|
| 6360 | * if ((name = strstr (word, "$NAME:")) == NULL || (prot = strstr (word, |
|---|
| 6361 | * "$PROT:")) == NULL || (port = strstr (word, "$PORT:")) == NULL) continue; |
|---|
| 6362 | * |
|---|
| 6363 | * // $NAME if (sscanf (name, "$NAME:%3d:", &len) != 1) continue; |
|---|
| 6364 | * |
|---|
| 6365 | * strncpy (name, name + sizeof ("$NAME:nnn:") - 1, len); name[len] = '\0'; |
|---|
| 6366 | * |
|---|
| 6367 | * // $PROT if (sscanf (prot, "$PROT:%3d:", &len) != 1) continue; |
|---|
| 6368 | * |
|---|
| 6369 | * strncpy (protocol, prot + sizeof ("$PROT:nnn:") - 1, len); protocol[len] = |
|---|
| 6370 | * '\0'; |
|---|
| 6371 | * |
|---|
| 6372 | * // $PORT if (sscanf (port, "$PORT:%3d:", &len) != 1) continue; |
|---|
| 6373 | * |
|---|
| 6374 | * strncpy (ports, port + sizeof ("$PORT:nnn:") - 1, len); ports[len] = '\0'; |
|---|
| 6375 | * |
|---|
| 6376 | * if (sscanf (ports, "%d:%d", &from, &to) != 2) continue; |
|---|
| 6377 | * |
|---|
| 6378 | * //cprintf("match:: name=%s, protocol=%s, ports=%s\n", // word, protocol, |
|---|
| 6379 | * ports); |
|---|
| 6380 | * |
|---|
| 6381 | * websWrite (wp, "<option value=\"%s\">%s</option>", name, name); |
|---|
| 6382 | * |
|---|
| 6383 | * } |
|---|
| 6384 | * |
|---|
| 6385 | * return; } |
|---|
| 6386 | */ |
|---|
| 6387 | |
|---|
| 6388 | void ej_get_clone_wmac(webs_t wp, int argc, char_t ** argv) |
|---|
| 6389 | { |
|---|
| 6390 | #ifdef HAVE_RB500 |
|---|
| 6391 | return 0; |
|---|
| 6392 | #else |
|---|
| 6393 | |
|---|
| 6394 | char *c; |
|---|
| 6395 | int mac, which; |
|---|
| 6396 | int dofree = 0; |
|---|
| 6397 | |
|---|
| 6398 | #ifdef FASTWEB |
|---|
| 6399 | ejArgs(argc, argv, "%d", &which); |
|---|
| 6400 | #else |
|---|
| 6401 | if (ejArgs(argc, argv, "%d", &which) < 1) { |
|---|
| 6402 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 6403 | return; |
|---|
| 6404 | } |
|---|
| 6405 | #endif |
|---|
| 6406 | |
|---|
| 6407 | if (nvram_match("def_whwaddr", "00:00:00:00:00:00")) { |
|---|
| 6408 | // if (strlen (nvram_safe_get ("il0macaddr")) == 0) |
|---|
| 6409 | // { |
|---|
| 6410 | // if (nvram_match ("port_swap", "1")) |
|---|
| 6411 | // c = strdup (nvram_safe_get ("et1macaddr")); |
|---|
| 6412 | // else |
|---|
| 6413 | // c = strdup (nvram_safe_get ("et0macaddr")); |
|---|
| 6414 | // MAC_ADD (c); |
|---|
| 6415 | // } |
|---|
| 6416 | // else |
|---|
| 6417 | // { |
|---|
| 6418 | // c = strdup (nvram_safe_get ("il0macaddr")); |
|---|
| 6419 | // } |
|---|
| 6420 | // dofree = 1; |
|---|
| 6421 | |
|---|
| 6422 | if (nvram_match("port_swap", "1")) { |
|---|
| 6423 | if (strlen(nvram_safe_get("et1macaddr")) != 0) // safe: |
|---|
| 6424 | // maybe |
|---|
| 6425 | // et1macaddr |
|---|
| 6426 | // not there? |
|---|
| 6427 | { |
|---|
| 6428 | c = strdup(nvram_safe_get("et1macaddr")); |
|---|
| 6429 | } else { |
|---|
| 6430 | c = strdup(nvram_safe_get("et0macaddr")); |
|---|
| 6431 | MAC_ADD(c); // et0macaddr +3 |
|---|
| 6432 | } |
|---|
| 6433 | } else { |
|---|
| 6434 | c = strdup(nvram_safe_get("et0macaddr")); |
|---|
| 6435 | } |
|---|
| 6436 | |
|---|
| 6437 | dofree = 1; |
|---|
| 6438 | if (c) { |
|---|
| 6439 | MAC_ADD(c); |
|---|
| 6440 | MAC_ADD(c); |
|---|
| 6441 | } |
|---|
| 6442 | |
|---|
| 6443 | } else |
|---|
| 6444 | c = nvram_safe_get("def_whwaddr"); |
|---|
| 6445 | |
|---|
| 6446 | if (c) { |
|---|
| 6447 | mac = get_single_mac(c, which); |
|---|
| 6448 | websWrite(wp, "%02X", mac); |
|---|
| 6449 | if (dofree) |
|---|
| 6450 | free(c); |
|---|
| 6451 | } else |
|---|
| 6452 | websWrite(wp, "00"); |
|---|
| 6453 | |
|---|
| 6454 | return; |
|---|
| 6455 | #endif |
|---|
| 6456 | } |
|---|
| 6457 | |
|---|
| 6458 | /* |
|---|
| 6459 | * todo stylesheet compatible code |
|---|
| 6460 | */ |
|---|
| 6461 | /* |
|---|
| 6462 | * lonewolf additions |
|---|
| 6463 | */ |
|---|
| 6464 | |
|---|
| 6465 | // Note that there is no VLAN #16. It's just a convieniant way of denoting a |
|---|
| 6466 | // "Tagged" port |
|---|
| 6467 | void ej_port_vlan_table(webs_t wp, int argc, char_t ** argv) |
|---|
| 6468 | { |
|---|
| 6469 | /* |
|---|
| 6470 | * vlans[x][y] where x 0-15 are VLANS x 16 is tagging, 17 is |
|---|
| 6471 | * auto-negotiation, 18 is 100/10 Mbit, and 19 is Full/Half duplex y 0-4 |
|---|
| 6472 | * are switch ports (port 5 is set automaticly) y 5 it the bridge device |
|---|
| 6473 | * (x 16 dosn't apply) |
|---|
| 6474 | */ |
|---|
| 6475 | |
|---|
| 6476 | int i, j, vlans[21][6], tmp, wl_br; |
|---|
| 6477 | char *c, *next, buff[32], portvlan[32]; |
|---|
| 6478 | |
|---|
| 6479 | for (i = 0; i < 21; i++) |
|---|
| 6480 | for (j = 0; j < 6; j++) |
|---|
| 6481 | vlans[i][j] = -1; |
|---|
| 6482 | |
|---|
| 6483 | wl_br = -1; |
|---|
| 6484 | |
|---|
| 6485 | for (i = 0; i < 8; i++) { |
|---|
| 6486 | if (i < 5) |
|---|
| 6487 | snprintf(buff, 31, "port%dvlans", i); |
|---|
| 6488 | else if (i == 5) |
|---|
| 6489 | snprintf(buff, 31, "%s", "lan_ifnames"); |
|---|
| 6490 | else |
|---|
| 6491 | snprintf(buff, 31, "ub%d_ifnames", i - 5); |
|---|
| 6492 | |
|---|
| 6493 | c = nvram_safe_get(buff); |
|---|
| 6494 | |
|---|
| 6495 | if (c) { |
|---|
| 6496 | foreach(portvlan, c, next) { |
|---|
| 6497 | if (portvlan[0] == 'e' && portvlan[1] == 't' |
|---|
| 6498 | && portvlan[2] == 'h' && portvlan[3] == '1') |
|---|
| 6499 | wl_br = i - 5; |
|---|
| 6500 | if (ISDIGIT(portvlan, 1) |
|---|
| 6501 | || (portvlan[0] == 'v' && portvlan[1] == 'l' |
|---|
| 6502 | && portvlan[2] == 'a' |
|---|
| 6503 | && portvlan[3] == 'n')) { |
|---|
| 6504 | if (ISDIGIT(portvlan, 1)) |
|---|
| 6505 | tmp = atoi(portvlan); |
|---|
| 6506 | else { |
|---|
| 6507 | portvlan[0] = portvlan[4]; |
|---|
| 6508 | portvlan[1] = portvlan[5]; |
|---|
| 6509 | portvlan[2] = '\0'; |
|---|
| 6510 | if (ISDIGIT(portvlan, 1)) |
|---|
| 6511 | tmp = atoi(portvlan); |
|---|
| 6512 | else |
|---|
| 6513 | continue; |
|---|
| 6514 | } |
|---|
| 6515 | |
|---|
| 6516 | if (i < 5) { |
|---|
| 6517 | vlans[tmp][i] = 1; |
|---|
| 6518 | } else { |
|---|
| 6519 | vlans[tmp][5] = i - 5; |
|---|
| 6520 | } |
|---|
| 6521 | } |
|---|
| 6522 | } |
|---|
| 6523 | } |
|---|
| 6524 | } |
|---|
| 6525 | |
|---|
| 6526 | for (i = 0; i < 21; i++) { |
|---|
| 6527 | websWrite(wp, " <tr>\n"); |
|---|
| 6528 | websWrite(wp, "<td>"); |
|---|
| 6529 | |
|---|
| 6530 | switch (i) { |
|---|
| 6531 | case 16: |
|---|
| 6532 | websWrite(wp, |
|---|
| 6533 | "<script type=\"text/javascript\">Capture(vlan.tagged)</script>"); |
|---|
| 6534 | break; |
|---|
| 6535 | case 17: |
|---|
| 6536 | websWrite(wp, |
|---|
| 6537 | "<script type=\"text/javascript\">Capture(vlan.negociate)</script>"); |
|---|
| 6538 | break; |
|---|
| 6539 | case 18: |
|---|
| 6540 | websWrite(wp, "100 Mbit"); |
|---|
| 6541 | break; |
|---|
| 6542 | case 19: |
|---|
| 6543 | websWrite(wp, "Full-Duplex"); |
|---|
| 6544 | break; |
|---|
| 6545 | case 20: |
|---|
| 6546 | websWrite(wp, "Enabled"); |
|---|
| 6547 | break; |
|---|
| 6548 | default: |
|---|
| 6549 | snprintf(buff, 31, "%d", i); |
|---|
| 6550 | websWrite(wp, buff); |
|---|
| 6551 | break; |
|---|
| 6552 | } |
|---|
| 6553 | |
|---|
| 6554 | websWrite(wp, "</td>\n"); |
|---|
| 6555 | |
|---|
| 6556 | for (j = 0; j < 5; j++) { |
|---|
| 6557 | snprintf(buff, 31, "\"port%dvlan%d\"", j, i); |
|---|
| 6558 | websWrite(wp, "<td"); |
|---|
| 6559 | |
|---|
| 6560 | if (j % 2 == 0) |
|---|
| 6561 | websWrite(wp, " bgcolor=\"#CCCCCC\""); |
|---|
| 6562 | |
|---|
| 6563 | websWrite(wp, |
|---|
| 6564 | " height=\"20\"><div align=\"center\"><input type=\"checkbox\" value=\"on\" name="); |
|---|
| 6565 | websWrite(wp, buff); |
|---|
| 6566 | |
|---|
| 6567 | if (i < 17 || i > 20) { |
|---|
| 6568 | if (vlans[i][j] == 1) |
|---|
| 6569 | websWrite(wp, " checked=\"checked\""); |
|---|
| 6570 | } else { |
|---|
| 6571 | if (vlans[i][j] == -1) |
|---|
| 6572 | websWrite(wp, " checked=\"checked\""); |
|---|
| 6573 | } |
|---|
| 6574 | |
|---|
| 6575 | if (i < 17) { |
|---|
| 6576 | websWrite(wp, " onclick="); |
|---|
| 6577 | snprintf(buff, sizeof(buff), |
|---|
| 6578 | "\"SelVLAN(this.form,'port%d')\"", j); |
|---|
| 6579 | websWrite(wp, buff); |
|---|
| 6580 | } else if (i == 17 || i == 20) { |
|---|
| 6581 | websWrite(wp, " onclick="); |
|---|
| 6582 | snprintf(buff, sizeof(buff), |
|---|
| 6583 | "\"SelSpeed(this.form,'port%d')\"", j); |
|---|
| 6584 | websWrite(wp, buff); |
|---|
| 6585 | } |
|---|
| 6586 | websWrite(wp, " /></div></td>\n"); |
|---|
| 6587 | } |
|---|
| 6588 | |
|---|
| 6589 | if (i < 16) { |
|---|
| 6590 | websWrite(wp, " <td><select name="); |
|---|
| 6591 | snprintf(buff, 31, "\"vlan%d\"", i); |
|---|
| 6592 | websWrite(wp, buff); |
|---|
| 6593 | websWrite(wp, |
|---|
| 6594 | "><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"-1\\\""); |
|---|
| 6595 | if (vlans[i][5] < 0) |
|---|
| 6596 | websWrite(wp, " selected=\\\"selected\\\""); |
|---|
| 6597 | websWrite(wp, |
|---|
| 6598 | ">\" + share.none + \"</option>\");\n//]]>\n</script><option value=\"0\""); |
|---|
| 6599 | if (vlans[i][5] == 0) |
|---|
| 6600 | websWrite(wp, " selected=\"selected\""); |
|---|
| 6601 | websWrite(wp, ">LAN</option></select></td>\n"); |
|---|
| 6602 | } else { |
|---|
| 6603 | websWrite(wp, "<td> </td>\n"); |
|---|
| 6604 | } |
|---|
| 6605 | |
|---|
| 6606 | websWrite(wp, "</tr>\n"); |
|---|
| 6607 | |
|---|
| 6608 | if (i == 16 || i == 20) { |
|---|
| 6609 | websWrite(wp, "<tr><td> </td></tr>\n"); |
|---|
| 6610 | } |
|---|
| 6611 | } |
|---|
| 6612 | |
|---|
| 6613 | websWrite(wp, "<tr>\n"); |
|---|
| 6614 | websWrite(wp, |
|---|
| 6615 | "<td><script type=\"text/javascript\">Capture(share.wireless)</script></td>\n"); |
|---|
| 6616 | |
|---|
| 6617 | websWrite(wp, |
|---|
| 6618 | "<td colspan=\"6\"><select name=\"wireless\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"-1\\\""); |
|---|
| 6619 | if (wl_br < 0) |
|---|
| 6620 | websWrite(wp, " selected=\\\"selected\\\""); |
|---|
| 6621 | websWrite(wp, |
|---|
| 6622 | ">\" + share.none + \"</option>\");\n//]]>\n</script><option value=\"0\""); |
|---|
| 6623 | if (wl_br == 0) |
|---|
| 6624 | websWrite(wp, " selected=\"selected\""); |
|---|
| 6625 | websWrite(wp, ">LAN</option></select></td>\n"); |
|---|
| 6626 | websWrite(wp, "</tr>\n"); |
|---|
| 6627 | |
|---|
| 6628 | websWrite(wp, "<tr><td> </td></tr>\n"); |
|---|
| 6629 | |
|---|
| 6630 | websWrite(wp, "<tr>\n"); |
|---|
| 6631 | websWrite(wp, |
|---|
| 6632 | "<td><script type=\"text/javascript\">Capture(vlan.aggregation)</script></td>\n"); |
|---|
| 6633 | |
|---|
| 6634 | websWrite(wp, |
|---|
| 6635 | "<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\\\""); |
|---|
| 6636 | |
|---|
| 6637 | c = nvram_safe_get("trunking"); |
|---|
| 6638 | |
|---|
| 6639 | snprintf(buff, 5, "%s", c); |
|---|
| 6640 | |
|---|
| 6641 | if (atoi(buff) == 1) |
|---|
| 6642 | websWrite(wp, " selected=\\\"selected\\\""); |
|---|
| 6643 | |
|---|
| 6644 | websWrite(wp, |
|---|
| 6645 | ">\" + vlan.trunk + \"</option>\");\n//]]>\n</script></select></td>\n"); |
|---|
| 6646 | websWrite(wp, " </tr>"); |
|---|
| 6647 | |
|---|
| 6648 | return; |
|---|
| 6649 | } |
|---|
| 6650 | |
|---|
| 6651 | /* |
|---|
| 6652 | * Note: VLAN #16 designates tagging. There is no VLAN #16 (only 0-15) |
|---|
| 6653 | */ |
|---|
| 6654 | |
|---|
| 6655 | void ej_get_qossvcs(webs_t wp, int argc, char_t ** argv) |
|---|
| 6656 | { |
|---|
| 6657 | char *qos_svcs = nvram_safe_get("svqos_svcs"); |
|---|
| 6658 | char name[32], type[32], data[32], level[32]; |
|---|
| 6659 | int no_svcs = 0, i = 0; |
|---|
| 6660 | |
|---|
| 6661 | // calc # of services |
|---|
| 6662 | // no_svcs = strspn(qos_svcs,"|"); |
|---|
| 6663 | |
|---|
| 6664 | while ((qos_svcs = strpbrk(qos_svcs, "|"))) { |
|---|
| 6665 | no_svcs++; |
|---|
| 6666 | qos_svcs++; |
|---|
| 6667 | } |
|---|
| 6668 | |
|---|
| 6669 | // write HTML data |
|---|
| 6670 | |
|---|
| 6671 | websWrite(wp, |
|---|
| 6672 | "<tr><td colspan=\"3\"><input type=\"hidden\" name=\"svqos_nosvcs\" value=\"%d\" /></td></tr>", |
|---|
| 6673 | no_svcs); |
|---|
| 6674 | |
|---|
| 6675 | qos_svcs = nvram_safe_get("svqos_svcs"); |
|---|
| 6676 | |
|---|
| 6677 | /* |
|---|
| 6678 | * services format is "name type data level | name type data level |" |
|---|
| 6679 | * ..etc |
|---|
| 6680 | */ |
|---|
| 6681 | for (i = 0; i < no_svcs && qos_svcs && qos_svcs[0]; i++) { |
|---|
| 6682 | if (sscanf |
|---|
| 6683 | (qos_svcs, "%31s %31s %31s %31s ", name, type, data, |
|---|
| 6684 | level) < 4) |
|---|
| 6685 | break; |
|---|
| 6686 | |
|---|
| 6687 | websWrite(wp, "<tr>\n\ |
|---|
| 6688 | <td>\n\ |
|---|
| 6689 | <input type=\"checkbox\" name=\"svqos_svcdel%d\" />\n\ |
|---|
| 6690 | <input type=\"hidden\" name=\"svqos_svcname%d\" value=\"%s\" />\n\ |
|---|
| 6691 | <input type=\"hidden\" name=\"svqos_svctype%d\" value=\"%s\" />\n\ |
|---|
| 6692 | </td>\n\ |
|---|
| 6693 | <td><em>%s</em></td>\n\ |
|---|
| 6694 | <td >\n", i, i, name, i, type, name); |
|---|
| 6695 | websWrite(wp, "<select name=\"svqos_svcprio%d\"> \n\ |
|---|
| 6696 | <script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"100\\\" %s >\" + qos.prio_x + \"</option>\");\n\ |
|---|
| 6697 | document.write(\"<option value=\\\"10\\\" %s >\" + qos.prio_p + \"</option>\");\n\ |
|---|
| 6698 | document.write(\"<option value=\\\"20\\\" %s >\" + qos.prio_e + \"</option>\");\n\ |
|---|
| 6699 | document.write(\"<option value=\\\"30\\\" %s >\" + share.standard + \"</option>\");\n\ |
|---|
| 6700 | document.write(\"<option value=\\\"40\\\" %s >\" + qos.prio_b + \"</option>\");\n//]]>\n</script>\n\ |
|---|
| 6701 | </select>\n\ |
|---|
| 6702 | </td>\n\ |
|---|
| 6703 | </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\\\"" : ""); |
|---|
| 6704 | |
|---|
| 6705 | qos_svcs = strpbrk(++qos_svcs, "|"); |
|---|
| 6706 | qos_svcs++; |
|---|
| 6707 | |
|---|
| 6708 | } |
|---|
| 6709 | |
|---|
| 6710 | return; |
|---|
| 6711 | } |
|---|
| 6712 | |
|---|
| 6713 | #ifndef HAVE_AQOS |
|---|
| 6714 | void ej_get_qosips(webs_t wp, int argc, char_t ** argv) |
|---|
| 6715 | { |
|---|
| 6716 | char *qos_ips = nvram_safe_get("svqos_ips"); |
|---|
| 6717 | char ip[32], level[32]; |
|---|
| 6718 | int no_ips = 0, i = 0; |
|---|
| 6719 | |
|---|
| 6720 | // calc # of ips |
|---|
| 6721 | while ((qos_ips = strpbrk(qos_ips, "|"))) { |
|---|
| 6722 | no_ips++; |
|---|
| 6723 | qos_ips++; |
|---|
| 6724 | } |
|---|
| 6725 | websWrite(wp, "<tr>\n\ |
|---|
| 6726 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 6727 | <th><script type=\"text/javascript\">Capture(qos.ipmask)</script></th>\n\ |
|---|
| 6728 | <th><script type=\"text/javascript\">Capture(share.priority)</script></th>\n\ |
|---|
| 6729 | </tr>\n"); |
|---|
| 6730 | |
|---|
| 6731 | // write HTML data |
|---|
| 6732 | |
|---|
| 6733 | websWrite(wp, |
|---|
| 6734 | "<tr><td colspan=\"3\"><input type=\"hidden\" name=\"svqos_noips\" value=\"%d\" /></td></tr>", |
|---|
| 6735 | no_ips); |
|---|
| 6736 | |
|---|
| 6737 | qos_ips = nvram_safe_get("svqos_ips"); |
|---|
| 6738 | |
|---|
| 6739 | /* |
|---|
| 6740 | * IP format is "data level | data level |" ..etc |
|---|
| 6741 | */ |
|---|
| 6742 | for (i = 0; i < no_ips && qos_ips && qos_ips[0]; i++) { |
|---|
| 6743 | if (sscanf(qos_ips, "%31s %31s ", ip, level) < 2) |
|---|
| 6744 | break; |
|---|
| 6745 | |
|---|
| 6746 | websWrite(wp, "<tr>\n\ |
|---|
| 6747 | <td>\n\ |
|---|
| 6748 | <input type=\"checkbox\" name=\"svqos_ipdel%d\" />\n\ |
|---|
| 6749 | <input type=\"hidden\" name=\"svqos_ip%d\" value=\"%s\" />\n\ |
|---|
| 6750 | </td>\n\ |
|---|
| 6751 | <td><em>%s</em></td>\n\ |
|---|
| 6752 | <td>\n", i, i, ip, ip); |
|---|
| 6753 | websWrite(wp, "<select name=\"svqos_ipprio%d\"> \n\ |
|---|
| 6754 | <script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"100\\\" %s >\" + qos.prio_x + \"</option>\");\n\ |
|---|
| 6755 | document.write(\"<option value=\\\"10\\\" %s >\" + qos.prio_p + \"</option>\");\n\ |
|---|
| 6756 | document.write(\"<option value=\\\"20\\\" %s >\" + qos.prio_e + \"</option>\");\n\ |
|---|
| 6757 | document.write(\"<option value=\\\"30\\\" %s >\" + share.standard + \"</option>\");\n\ |
|---|
| 6758 | document.write(\"<option value=\\\"40\\\" %s >\" + qos.prio_b + \"</option>\");\n//]]>\n</script>\n\ |
|---|
| 6759 | </select>\n\ |
|---|
| 6760 | </td>\n\ |
|---|
| 6761 | </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\\\"" : ""); |
|---|
| 6762 | |
|---|
| 6763 | qos_ips = strpbrk(++qos_ips, "|"); |
|---|
| 6764 | qos_ips++; |
|---|
| 6765 | |
|---|
| 6766 | } |
|---|
| 6767 | |
|---|
| 6768 | return; |
|---|
| 6769 | } |
|---|
| 6770 | #else |
|---|
| 6771 | void ej_get_qosips(webs_t wp, int argc, char_t ** argv) |
|---|
| 6772 | { |
|---|
| 6773 | char *qos_ips = nvram_safe_get("svqos_ips"); |
|---|
| 6774 | char ip[32], level[32], level2[32]; |
|---|
| 6775 | int no_ips = 0, i = 0; |
|---|
| 6776 | |
|---|
| 6777 | // calc # of ips |
|---|
| 6778 | while ((qos_ips = strpbrk(qos_ips, "|"))) { |
|---|
| 6779 | no_ips++; |
|---|
| 6780 | qos_ips++; |
|---|
| 6781 | } |
|---|
| 6782 | websWrite(wp, "<tr>\n\ |
|---|
| 6783 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 6784 | <th><script type=\"text/javascript\">Capture(qos.ipmask)</script></th>\n\ |
|---|
| 6785 | <th><script type=\"text/javascript\">Capture(qos.maxuprate_b)</script></th>\n\ |
|---|
| 6786 | <th><script type=\"text/javascript\">Capture(qos.maxdownrate_b)</script></th>\n\ |
|---|
| 6787 | </tr>\n"); |
|---|
| 6788 | |
|---|
| 6789 | // write HTML data |
|---|
| 6790 | |
|---|
| 6791 | websWrite(wp, |
|---|
| 6792 | "<tr><td colspan=\"3\"><input type=\"hidden\" name=\"svqos_noips\" value=\"%d\" /></td></tr>", |
|---|
| 6793 | no_ips); |
|---|
| 6794 | |
|---|
| 6795 | qos_ips = nvram_safe_get("svqos_ips"); |
|---|
| 6796 | |
|---|
| 6797 | /* |
|---|
| 6798 | * IP format is "data level | data level |" ..etc |
|---|
| 6799 | */ |
|---|
| 6800 | for (i = 0; i < no_ips && qos_ips && qos_ips[0]; i++) { |
|---|
| 6801 | if (sscanf(qos_ips, "%31s %31s %31s ", ip, level, level2) < 3) |
|---|
| 6802 | break; |
|---|
| 6803 | websWrite(wp, "<tr>\n\ |
|---|
| 6804 | <td>\n\ |
|---|
| 6805 | <input type=\"checkbox\" name=\"svqos_ipdel%d\" />\n\ |
|---|
| 6806 | <input type=\"hidden\" name=\"svqos_ip%d\" value=\"%s\" />\n\ |
|---|
| 6807 | </td>\n\ |
|---|
| 6808 | <td><em>%s</em></td>\n\ |
|---|
| 6809 | <td>\n\ |
|---|
| 6810 | <input name=\"svqos_ipup%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 6811 | </td>\n\ |
|---|
| 6812 | <td>\n\ |
|---|
| 6813 | <input name=\"svqos_ipdown%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 6814 | </td>\n\ |
|---|
| 6815 | </tr>\n", i, i, ip, ip, i, level, i, level2); |
|---|
| 6816 | |
|---|
| 6817 | qos_ips = strpbrk(++qos_ips, "|"); |
|---|
| 6818 | qos_ips++; |
|---|
| 6819 | |
|---|
| 6820 | } |
|---|
| 6821 | |
|---|
| 6822 | return; |
|---|
| 6823 | } |
|---|
| 6824 | #endif |
|---|
| 6825 | #ifndef HAVE_AQOS |
|---|
| 6826 | void ej_get_qosmacs(webs_t wp, int argc, char_t ** argv) |
|---|
| 6827 | { |
|---|
| 6828 | char *qos_macs = nvram_safe_get("svqos_macs"); |
|---|
| 6829 | char mac[32], level[32]; |
|---|
| 6830 | int no_macs = 0, i = 0; |
|---|
| 6831 | |
|---|
| 6832 | // calc # of ips |
|---|
| 6833 | while ((qos_macs = strpbrk(qos_macs, "|"))) { |
|---|
| 6834 | no_macs++; |
|---|
| 6835 | qos_macs++; |
|---|
| 6836 | } |
|---|
| 6837 | |
|---|
| 6838 | websWrite(wp, "<tr>\n\ |
|---|
| 6839 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 6840 | <th><script type=\"text/javascript\">Capture(share.mac)</script></th>\n\ |
|---|
| 6841 | <th><script type=\"text/javascript\">Capture(share.priority)</script></th>\n\ |
|---|
| 6842 | </tr>\n"); |
|---|
| 6843 | |
|---|
| 6844 | // write HTML data |
|---|
| 6845 | websWrite(wp, |
|---|
| 6846 | "<input type=\"hidden\" name=\"svqos_nomacs\" value=\"%d\" />", |
|---|
| 6847 | no_macs); |
|---|
| 6848 | |
|---|
| 6849 | qos_macs = nvram_safe_get("svqos_macs"); |
|---|
| 6850 | |
|---|
| 6851 | /* |
|---|
| 6852 | * IP format is "data level | data level |" ..etc |
|---|
| 6853 | */ |
|---|
| 6854 | for (i = 0; i < no_macs && qos_macs && qos_macs[0]; i++) { |
|---|
| 6855 | if (sscanf(qos_macs, "%31s %31s ", mac, level) < 2) |
|---|
| 6856 | break; |
|---|
| 6857 | |
|---|
| 6858 | websWrite(wp, "<tr>\n\ |
|---|
| 6859 | <td>\n\ |
|---|
| 6860 | <input type=\"checkbox\" name=\"svqos_macdel%d\" />\n\ |
|---|
| 6861 | <input type=\"hidden\" name=\"svqos_mac%d\" value=\"%s\" />\n\ |
|---|
| 6862 | </td>\n\ |
|---|
| 6863 | <td><em>%s</em></td>\n\ |
|---|
| 6864 | <td>\n", i, i, mac, mac); |
|---|
| 6865 | websWrite(wp, "<select name=\"svqos_macprio%d\"> \n\ |
|---|
| 6866 | <script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"100\\\" %s >\" + qos.prio_x + \"</option>\");\n\ |
|---|
| 6867 | document.write(\"<option value=\\\"10\\\" %s >\" + qos.prio_p + \"</option>\");\n\ |
|---|
| 6868 | document.write(\"<option value=\\\"20\\\" %s >\" + qos.prio_e + \"</option>\");\n\ |
|---|
| 6869 | document.write(\"<option value=\\\"30\\\" %s >\" + share.standard + \"</option>\");\n\ |
|---|
| 6870 | document.write(\"<option value=\\\"40\\\" %s >\" + qos.prio_b + \"</option>\");\n//]]>\n</script>\n\ |
|---|
| 6871 | </select>\n\ |
|---|
| 6872 | </td>\n\ |
|---|
| 6873 | </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\\\"" : ""); |
|---|
| 6874 | |
|---|
| 6875 | qos_macs = strpbrk(++qos_macs, "|"); |
|---|
| 6876 | qos_macs++; |
|---|
| 6877 | |
|---|
| 6878 | } |
|---|
| 6879 | |
|---|
| 6880 | return; |
|---|
| 6881 | } |
|---|
| 6882 | |
|---|
| 6883 | #else |
|---|
| 6884 | void ej_get_qosmacs(webs_t wp, int argc, char_t ** argv) |
|---|
| 6885 | { |
|---|
| 6886 | char *qos_macs = nvram_safe_get("svqos_macs"); |
|---|
| 6887 | char mac[32], level[32], level2[32]; |
|---|
| 6888 | int no_macs = 0, i = 0; |
|---|
| 6889 | |
|---|
| 6890 | // calc # of ips |
|---|
| 6891 | while ((qos_macs = strpbrk(qos_macs, "|"))) { |
|---|
| 6892 | no_macs++; |
|---|
| 6893 | qos_macs++; |
|---|
| 6894 | } |
|---|
| 6895 | websWrite(wp, "<tr>\n\ |
|---|
| 6896 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 6897 | <th><script type=\"text/javascript\">Capture(share.mac)</script></th>\n\ |
|---|
| 6898 | <th><script type=\"text/javascript\">Capture(qos.maxuprate_b)</script></th>\n\ |
|---|
| 6899 | <th><script type=\"text/javascript\">Capture(qos.maxdownrate_b)</script></th>\n\ |
|---|
| 6900 | </tr>\n"); |
|---|
| 6901 | |
|---|
| 6902 | // write HTML data |
|---|
| 6903 | websWrite(wp, |
|---|
| 6904 | "<input type=\"hidden\" name=\"svqos_nomacs\" value=\"%d\" />", |
|---|
| 6905 | no_macs); |
|---|
| 6906 | |
|---|
| 6907 | qos_macs = nvram_safe_get("svqos_macs"); |
|---|
| 6908 | |
|---|
| 6909 | /* |
|---|
| 6910 | * IP format is "data level | data level |" ..etc |
|---|
| 6911 | */ |
|---|
| 6912 | for (i = 0; i < no_macs && qos_macs && qos_macs[0]; i++) { |
|---|
| 6913 | if (sscanf(qos_macs, "%31s %31s %31s ", mac, level, level2) < 3) |
|---|
| 6914 | break; |
|---|
| 6915 | websWrite(wp, "<tr>\n\ |
|---|
| 6916 | <td>\n\ |
|---|
| 6917 | <input type=\"checkbox\" name=\"svqos_macdel%d\" />\n\ |
|---|
| 6918 | <input type=\"hidden\" name=\"svqos_mac%d\" value=\"%s\" />\n\ |
|---|
| 6919 | </td>\n\ |
|---|
| 6920 | <td><em>%s</em></td>\n\ |
|---|
| 6921 | <td>\n\ |
|---|
| 6922 | <input name=\"svqos_macup%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 6923 | </td>\n\ |
|---|
| 6924 | <td>\n\ |
|---|
| 6925 | <input name=\"svqos_macdown%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 6926 | </td>\n\ |
|---|
| 6927 | </tr>\n", i, i, mac, mac, i, level, i, level2); |
|---|
| 6928 | |
|---|
| 6929 | qos_macs = strpbrk(++qos_macs, "|"); |
|---|
| 6930 | qos_macs++; |
|---|
| 6931 | |
|---|
| 6932 | } |
|---|
| 6933 | |
|---|
| 6934 | return; |
|---|
| 6935 | } |
|---|
| 6936 | #endif |
|---|
| 6937 | |
|---|
| 6938 | /* |
|---|
| 6939 | * Added by Botho 03.April.06 |
|---|
| 6940 | */ |
|---|
| 6941 | void ej_dumpip_conntrack(webs_t wp, int argc, char_t ** argv) |
|---|
| 6942 | { |
|---|
| 6943 | int ip_count = 0; |
|---|
| 6944 | FILE *fp; |
|---|
| 6945 | int c; |
|---|
| 6946 | |
|---|
| 6947 | fp = fopen("/proc/net/ip_conntrack", "rb"); |
|---|
| 6948 | if (fp == NULL) |
|---|
| 6949 | return; |
|---|
| 6950 | while (!feof(fp)) { |
|---|
| 6951 | c = getc(fp); |
|---|
| 6952 | if (c == EOF) |
|---|
| 6953 | break; |
|---|
| 6954 | if (c == 0xa) |
|---|
| 6955 | ip_count++; |
|---|
| 6956 | } |
|---|
| 6957 | |
|---|
| 6958 | websWrite(wp, "%d", ip_count); |
|---|
| 6959 | |
|---|
| 6960 | fclose(fp); |
|---|
| 6961 | |
|---|
| 6962 | return; |
|---|
| 6963 | } |
|---|
| 6964 | |
|---|
| 6965 | /* |
|---|
| 6966 | * Added by Botho 28.Oct.06 |
|---|
| 6967 | */ |
|---|
| 6968 | static int search_hit(char *search, char *line, char *ret) |
|---|
| 6969 | { |
|---|
| 6970 | unsigned int searchLen; |
|---|
| 6971 | unsigned int i; |
|---|
| 6972 | unsigned int j; |
|---|
| 6973 | unsigned int lineLen; |
|---|
| 6974 | |
|---|
| 6975 | if (line == NULL || search == NULL || ret == NULL) |
|---|
| 6976 | return 1; |
|---|
| 6977 | lineLen = strlen(line); |
|---|
| 6978 | searchLen = strlen(search); |
|---|
| 6979 | |
|---|
| 6980 | if (searchLen > lineLen) |
|---|
| 6981 | return (1); // this can't match, invalid data? |
|---|
| 6982 | |
|---|
| 6983 | for (i = 0; i < lineLen - searchLen; i++) { |
|---|
| 6984 | if (!strncasecmp((char *)&line[i], search, searchLen)) |
|---|
| 6985 | break; // we got hit |
|---|
| 6986 | } |
|---|
| 6987 | |
|---|
| 6988 | for (j = i + searchLen; j < i + 15 + searchLen; j++) { |
|---|
| 6989 | if (j >= lineLen) |
|---|
| 6990 | break; // end of line may be a delimiter too |
|---|
| 6991 | // return(1); // incomplete data |
|---|
| 6992 | if (line[j] == ' ') |
|---|
| 6993 | break; // we reach _space_ delimiter |
|---|
| 6994 | } |
|---|
| 6995 | memcpy(ret, &line[i + searchLen], j - (i + searchLen)); |
|---|
| 6996 | ret[j - (i + searchLen)] = 0; |
|---|
| 6997 | return (0); |
|---|
| 6998 | } |
|---|
| 6999 | |
|---|
| 7000 | static int string_search(char *string, char *search) |
|---|
| 7001 | { |
|---|
| 7002 | int searchLen; |
|---|
| 7003 | int i; |
|---|
| 7004 | |
|---|
| 7005 | if (search == NULL) |
|---|
| 7006 | return 0; |
|---|
| 7007 | searchLen = strlen(search); |
|---|
| 7008 | if (string == NULL) |
|---|
| 7009 | return 0; |
|---|
| 7010 | if (searchLen > strlen(string)) { |
|---|
| 7011 | return (0); // this can't match |
|---|
| 7012 | } |
|---|
| 7013 | int slen = strlen(string); |
|---|
| 7014 | |
|---|
| 7015 | for (i = 0; i < slen - searchLen; i++) { // +1 removed. |
|---|
| 7016 | if (!strncasecmp((char *)&string[i], search, searchLen)) { |
|---|
| 7017 | return (1); // we got hit |
|---|
| 7018 | } |
|---|
| 7019 | } |
|---|
| 7020 | return (0); |
|---|
| 7021 | } |
|---|
| 7022 | |
|---|
| 7023 | void ej_ip_conntrack_table(webs_t wp, int argc, char_t ** argv) |
|---|
| 7024 | { |
|---|
| 7025 | FILE *fp; |
|---|
| 7026 | int ip_count = 1; |
|---|
| 7027 | char line[512]; |
|---|
| 7028 | char protocol[16] = ""; |
|---|
| 7029 | int timeout = 0; |
|---|
| 7030 | char srcip[16] = ""; |
|---|
| 7031 | char dstip[16] = ""; |
|---|
| 7032 | int _dport; |
|---|
| 7033 | struct servent *servp; |
|---|
| 7034 | char dstport[6] = ""; |
|---|
| 7035 | char state[12] = ""; |
|---|
| 7036 | char dum1[32]; |
|---|
| 7037 | int dum2; |
|---|
| 7038 | char *lanip = nvram_get("lan_ipaddr"); |
|---|
| 7039 | |
|---|
| 7040 | fp = fopen("/proc/net/ip_conntrack", "rb"); |
|---|
| 7041 | if (fp == NULL) |
|---|
| 7042 | return; |
|---|
| 7043 | |
|---|
| 7044 | while (fgets(line, sizeof(line), fp) != NULL) { |
|---|
| 7045 | |
|---|
| 7046 | websWrite(wp, "<tr>\n"); |
|---|
| 7047 | |
|---|
| 7048 | // Nb |
|---|
| 7049 | websWrite(wp, "<td align=\"right\">%d</td>", ip_count); |
|---|
| 7050 | |
|---|
| 7051 | // Proto |
|---|
| 7052 | if (string_search(line, "tcp")) |
|---|
| 7053 | sprintf(protocol, "TCP"); |
|---|
| 7054 | else if (string_search(line, "udp")) |
|---|
| 7055 | sprintf(protocol, "UDP"); |
|---|
| 7056 | else if (string_search(line, "icmp")) |
|---|
| 7057 | sprintf(protocol, "ICMP"); |
|---|
| 7058 | else |
|---|
| 7059 | sprintf(protocol, live_translate("share.unknown")); |
|---|
| 7060 | websWrite(wp, "<td>%s</td>", protocol); |
|---|
| 7061 | |
|---|
| 7062 | // Timeout |
|---|
| 7063 | sscanf(line, "%s %d %d", &dum1[0], &dum2, &timeout); |
|---|
| 7064 | websWrite(wp, "<td align=\"right\">%d</td>", timeout); |
|---|
| 7065 | |
|---|
| 7066 | // src |
|---|
| 7067 | search_hit("src=", line, srcip); |
|---|
| 7068 | // char buf[200]; |
|---|
| 7069 | // getHostName (buf, srcip); |
|---|
| 7070 | // websWrite (wp, "<td align=\"right\" onmouseover='DisplayDiv(this, |
|---|
| 7071 | // event, 15, 15, \"%s\")' onmouseout=\"unDisplayDiv()\">%s</td>", |
|---|
| 7072 | // buf != "unknown" ? buf : live_translate ("share.unknown") , |
|---|
| 7073 | // srcip); |
|---|
| 7074 | if (!strcmp(srcip, lanip)) |
|---|
| 7075 | websWrite(wp, "<td align=\"right\">%s</td>", srcip); |
|---|
| 7076 | else |
|---|
| 7077 | websWrite(wp, "<td align=\"right\"><a title=\"Geotool\" href=\"javascript:openGeotool('%s')\">%s</a></td>", srcip, srcip); |
|---|
| 7078 | |
|---|
| 7079 | // dst |
|---|
| 7080 | search_hit("dst=", line, dstip); |
|---|
| 7081 | // getHostName (buf, dstip); |
|---|
| 7082 | // websWrite (wp, "<td align=\"right\" onmouseover='DisplayDiv(this, |
|---|
| 7083 | // event, 15, 15, \"%s\")' onmouseout=\"unDisplayDiv()\">%s</td>", |
|---|
| 7084 | // buf != "unknown" ? buf : live_translate ("share.unknown") , |
|---|
| 7085 | // dstip); |
|---|
| 7086 | if (!strcmp(dstip, lanip)) |
|---|
| 7087 | websWrite(wp, "<td align=\"right\">%s</td>", dstip); |
|---|
| 7088 | else |
|---|
| 7089 | websWrite(wp, "<td align=\"right\"><a title=\"Geotool\" href=\"javascript:openGeotool('%s')\">%s</a></td>", dstip, dstip); |
|---|
| 7090 | |
|---|
| 7091 | |
|---|
| 7092 | // service |
|---|
| 7093 | search_hit("dport=", line, dstport); |
|---|
| 7094 | _dport = atoi(dstport); |
|---|
| 7095 | servp = my_getservbyport(htons(_dport), protocol); |
|---|
| 7096 | websWrite(wp, "<td align=\"right\">%s</td>", |
|---|
| 7097 | servp ? servp->s_name : dstport); |
|---|
| 7098 | |
|---|
| 7099 | // State |
|---|
| 7100 | if (string_search(line, "ESTABLISHED")) |
|---|
| 7101 | sprintf(state, "ESTABLISHED"); |
|---|
| 7102 | else if (string_search(line, "TIME_WAIT")) |
|---|
| 7103 | sprintf(state, "TIME_WAIT"); |
|---|
| 7104 | else if (string_search(line, "UNREPLIED")) |
|---|
| 7105 | sprintf(state, "UNREPLIED"); |
|---|
| 7106 | else if (string_search(line, "CLOSE")) |
|---|
| 7107 | sprintf(state, "CLOSE"); |
|---|
| 7108 | else if (string_search(line, "ASSURED")) |
|---|
| 7109 | sprintf(state, "ASSURED"); |
|---|
| 7110 | else { |
|---|
| 7111 | if (string_search(line, "udp")) |
|---|
| 7112 | sprintf(state, "UNREPLIED"); |
|---|
| 7113 | else |
|---|
| 7114 | sprintf(state, " "); |
|---|
| 7115 | } |
|---|
| 7116 | websWrite(wp, "<td>%s</td>\n", state); |
|---|
| 7117 | websWrite(wp, "</tr>\n"); |
|---|
| 7118 | |
|---|
| 7119 | ip_count++; |
|---|
| 7120 | } |
|---|
| 7121 | |
|---|
| 7122 | fclose(fp); |
|---|
| 7123 | |
|---|
| 7124 | return; |
|---|
| 7125 | } |
|---|
| 7126 | |
|---|
| 7127 | void ej_gethostnamebyip(webs_t wp, int argc, char_t ** argv) |
|---|
| 7128 | { |
|---|
| 7129 | char buf[200]; |
|---|
| 7130 | char *argument; |
|---|
| 7131 | |
|---|
| 7132 | #ifdef FASTWEB |
|---|
| 7133 | ejArgs(argc, argv, "%s", &argument); |
|---|
| 7134 | #else |
|---|
| 7135 | if (ejArgs(argc, argv, "%s", &argument) < 1) { |
|---|
| 7136 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 7137 | return; |
|---|
| 7138 | } |
|---|
| 7139 | #endif |
|---|
| 7140 | |
|---|
| 7141 | if (argc == 1) { |
|---|
| 7142 | getHostName(buf, argument); |
|---|
| 7143 | websWrite(wp, "%s", |
|---|
| 7144 | strcmp(buf, |
|---|
| 7145 | "unknown") ? buf : |
|---|
| 7146 | live_translate("share.unknown")); |
|---|
| 7147 | } |
|---|
| 7148 | |
|---|
| 7149 | return; |
|---|
| 7150 | } |
|---|
| 7151 | |
|---|
| 7152 | /* |
|---|
| 7153 | * BEGIN Added by Botho 10.May.06 |
|---|
| 7154 | */ |
|---|
| 7155 | void ej_show_wan_to_switch(webs_t wp, int argc, char_t ** argv) |
|---|
| 7156 | { |
|---|
| 7157 | |
|---|
| 7158 | if (nvram_match("wan_proto", "disabled") || getSTA() || getWET()) // WAN |
|---|
| 7159 | // disabled |
|---|
| 7160 | // OR |
|---|
| 7161 | // Wirelles |
|---|
| 7162 | // is |
|---|
| 7163 | // not |
|---|
| 7164 | // AP |
|---|
| 7165 | { |
|---|
| 7166 | websWrite(wp, "<fieldset>\n\ |
|---|
| 7167 | <legend><script type=\"text/javascript\">Capture(idx.legend2)</script></legend>\n\ |
|---|
| 7168 | <div class=\"setting\">\n\ |
|---|
| 7169 | <div class=\"label\"><script type=\"text/javascript\">Capture(idx.wantoswitch)</script></div>\n\ |
|---|
| 7170 | <input class=\"spaceradio\" type=\"checkbox\" name=\"_fullswitch\" value=\"1\" %s />\n\ |
|---|
| 7171 | </div>\n\ |
|---|
| 7172 | </fieldset><br />\n", nvram_match("fullswitch", "1") ? "checked=\"checked\"" : ""); |
|---|
| 7173 | } |
|---|
| 7174 | |
|---|
| 7175 | return; |
|---|
| 7176 | } |
|---|
| 7177 | |
|---|
| 7178 | #define PROC_DEV "/proc/net/dev" |
|---|
| 7179 | |
|---|
| 7180 | void ej_wl_packet_get(webs_t wp, int argc, char_t ** argv) |
|---|
| 7181 | { |
|---|
| 7182 | char line[256]; |
|---|
| 7183 | FILE *fp; |
|---|
| 7184 | |
|---|
| 7185 | #ifdef HAVE_MADWIFI |
|---|
| 7186 | char *ifname = nvram_safe_get("wifi_display"); |
|---|
| 7187 | #elif HAVE_RT2880 |
|---|
| 7188 | char *ifname = "ra0"; |
|---|
| 7189 | #else |
|---|
| 7190 | char name[32]; |
|---|
| 7191 | sprintf(name, "%s_ifname", nvram_safe_get("wifi_display")); |
|---|
| 7192 | char *ifname = nvram_safe_get(name); |
|---|
| 7193 | #endif |
|---|
| 7194 | struct dev_info { |
|---|
| 7195 | // unsigned long rx_bytes; |
|---|
| 7196 | unsigned long rx_pks; |
|---|
| 7197 | unsigned long rx_errs; |
|---|
| 7198 | unsigned long rx_drops; |
|---|
| 7199 | // unsigned long rx_fifo; |
|---|
| 7200 | // unsigned long rx_frame; |
|---|
| 7201 | // unsigned long rx_com; |
|---|
| 7202 | // unsigned long rx_mcast; |
|---|
| 7203 | // unsigned long tx_bytes; |
|---|
| 7204 | unsigned long tx_pks; |
|---|
| 7205 | unsigned long tx_errs; |
|---|
| 7206 | unsigned long tx_drops; |
|---|
| 7207 | // unsigned long tx_fifo; |
|---|
| 7208 | unsigned long tx_colls; |
|---|
| 7209 | // unsigned long tx_carr; |
|---|
| 7210 | // unsigned long tx_com; |
|---|
| 7211 | } info; |
|---|
| 7212 | |
|---|
| 7213 | info.rx_pks = info.rx_errs = info.rx_drops = 0; |
|---|
| 7214 | info.tx_pks = info.tx_errs = info.tx_drops = info.tx_colls = 0; |
|---|
| 7215 | |
|---|
| 7216 | if ((fp = fopen(PROC_DEV, "r")) == NULL) { |
|---|
| 7217 | websError(wp, 400, "Can't open %s\n", PROC_DEV); |
|---|
| 7218 | return; |
|---|
| 7219 | } else { |
|---|
| 7220 | /* |
|---|
| 7221 | * Inter-| Receive | Transmit face |bytes packets errs drop fifo |
|---|
| 7222 | * frame compressed multicast|bytes packets errs drop fifo colls |
|---|
| 7223 | * carrier compressed lo: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 eth0: |
|---|
| 7224 | * 674829 5501 0 0 0 0 0 0 1249130 1831 0 0 0 0 0 0 eth1: 0 0 0 0 0 0 |
|---|
| 7225 | * 0 0 0 0 0 0 0 0 0 0 eth2: 0 0 0 0 0 719 0 0 1974 16 295 0 0 0 0 0 |
|---|
| 7226 | * br0: 107114 1078 0 0 0 0 0 0 910094 1304 0 0 0 0 0 0 |
|---|
| 7227 | * |
|---|
| 7228 | */ |
|---|
| 7229 | while (fgets(line, sizeof(line), fp) != NULL) { |
|---|
| 7230 | int ifl = 0; |
|---|
| 7231 | |
|---|
| 7232 | if (!strchr(line, ':')) |
|---|
| 7233 | continue; |
|---|
| 7234 | while (line[ifl] != ':') |
|---|
| 7235 | ifl++; |
|---|
| 7236 | line[ifl] = 0; /* interface */ |
|---|
| 7237 | |
|---|
| 7238 | if (strstr(line, ifname)) { |
|---|
| 7239 | /* |
|---|
| 7240 | * sscanf (line + ifl + 1, "%ld %ld %ld %ld %ld %ld %ld %ld |
|---|
| 7241 | * %ld %ld %ld %ld %ld %ld %ld %ld", &info.rx_bytes, |
|---|
| 7242 | * &info.rx_pks, &info.rx_errs, &info.rx_drops, |
|---|
| 7243 | * &info.rx_fifo, &info.rx_frame, &info.rx_com, |
|---|
| 7244 | * &info.rx_mcast, &info.tx_bytes, &info.tx_pks, |
|---|
| 7245 | * &info.tx_errs, &info.tx_drops, &info.tx_fifo, |
|---|
| 7246 | * &info.tx_colls, &info.tx_carr, &info.tx_com); |
|---|
| 7247 | */ |
|---|
| 7248 | sscanf(line + ifl + 1, |
|---|
| 7249 | "%*ld %ld %ld %ld %*ld %*ld %*ld %*ld %*ld %ld %ld %ld %*ld %ld %*ld %*ld", |
|---|
| 7250 | &info.rx_pks, &info.rx_errs, |
|---|
| 7251 | &info.rx_drops, |
|---|
| 7252 | &info.tx_pks, &info.tx_errs, |
|---|
| 7253 | &info.tx_drops, &info.tx_colls); |
|---|
| 7254 | } |
|---|
| 7255 | |
|---|
| 7256 | } |
|---|
| 7257 | fclose(fp); |
|---|
| 7258 | } |
|---|
| 7259 | |
|---|
| 7260 | websWrite(wp, "SWRXgoodPacket=%ld;", info.rx_pks); |
|---|
| 7261 | websWrite(wp, "SWRXerrorPacket=%ld;", info.rx_errs + info.rx_drops); |
|---|
| 7262 | |
|---|
| 7263 | websWrite(wp, "SWTXgoodPacket=%ld;", info.tx_pks); |
|---|
| 7264 | websWrite(wp, "SWTXerrorPacket=%ld;", |
|---|
| 7265 | info.tx_errs + info.tx_drops + info.tx_colls); |
|---|
| 7266 | |
|---|
| 7267 | return; |
|---|
| 7268 | } |
|---|
| 7269 | |
|---|
| 7270 | /* |
|---|
| 7271 | * END Added by Botho 10.May.06 |
|---|
| 7272 | */ |
|---|
| 7273 | |
|---|
| 7274 | void ej_statfs(webs_t wp, int argc, char_t ** argv) |
|---|
| 7275 | { |
|---|
| 7276 | struct statfs sizefs; |
|---|
| 7277 | |
|---|
| 7278 | if (argc != 2) |
|---|
| 7279 | return; |
|---|
| 7280 | |
|---|
| 7281 | if ((statfs(argv[0], &sizefs) != 0) |
|---|
| 7282 | || (sizefs.f_type == 0x73717368)) |
|---|
| 7283 | memset(&sizefs, 0, sizeof(sizefs)); |
|---|
| 7284 | |
|---|
| 7285 | websWrite(wp, "var %s = {\n\ |
|---|
| 7286 | size: %llu,\n\ |
|---|
| 7287 | free: %llu\n\ |
|---|
| 7288 | };\n", argv[1], ((uint64_t) sizefs.f_bsize * sizefs.f_blocks), ((uint64_t) sizefs.f_bsize * sizefs.f_bfree)); |
|---|
| 7289 | } |
|---|
| 7290 | |
|---|
| 7291 | #ifdef HAVE_RSTATS |
|---|
| 7292 | /* |
|---|
| 7293 | * |
|---|
| 7294 | * rstats Copyright (C) 2006 Jonathan Zarate |
|---|
| 7295 | * |
|---|
| 7296 | * Licensed under GNU GPL v2 or later. |
|---|
| 7297 | * |
|---|
| 7298 | */ |
|---|
| 7299 | |
|---|
| 7300 | void ej_bandwidth(webs_t wp, int argc, char_t ** argv) |
|---|
| 7301 | { |
|---|
| 7302 | char *name; |
|---|
| 7303 | int sig; |
|---|
| 7304 | char *argument; |
|---|
| 7305 | |
|---|
| 7306 | #ifdef FASTWEB |
|---|
| 7307 | ejArgs(argc, argv, "%s", &argument); |
|---|
| 7308 | #else |
|---|
| 7309 | if (ejArgs(argc, argv, "%s", &argument) < 1) { |
|---|
| 7310 | websError(wp, 400, "Insufficient args\n"); |
|---|
| 7311 | return; |
|---|
| 7312 | } |
|---|
| 7313 | #endif |
|---|
| 7314 | |
|---|
| 7315 | if (argc == 1) { |
|---|
| 7316 | if (strcmp(argument, "speed") == 0) { |
|---|
| 7317 | sig = SIGUSR1; |
|---|
| 7318 | name = "/var/spool/rstats-speed.js"; |
|---|
| 7319 | } else { |
|---|
| 7320 | sig = SIGUSR2; |
|---|
| 7321 | name = "/var/spool/rstats-history.js"; |
|---|
| 7322 | } |
|---|
| 7323 | unlink(name); |
|---|
| 7324 | killall("rstats", sig); |
|---|
| 7325 | wait_file_exists(name, 5, 0); |
|---|
| 7326 | do_file(name, wp, NULL); |
|---|
| 7327 | unlink(name); |
|---|
| 7328 | } |
|---|
| 7329 | } |
|---|
| 7330 | #endif |
|---|
| 7331 | |
|---|
| 7332 | #ifdef HAVE_PORTSETUP |
|---|
| 7333 | void ej_portsetup(webs_t wp, int argc, char_t ** argv) |
|---|
| 7334 | { |
|---|
| 7335 | char ssid[64]; |
|---|
| 7336 | char *next; |
|---|
| 7337 | char var[64]; |
|---|
| 7338 | char eths[256]; |
|---|
| 7339 | |
|---|
| 7340 | websWrite(wp, |
|---|
| 7341 | "<h2><script type=\"text/javascript\">Capture(idx.portsetup)</script></h2>\n"); |
|---|
| 7342 | websWrite(wp, "<fieldset>\n"); |
|---|
| 7343 | |
|---|
| 7344 | char *wanifname = nvram_safe_get("wan_ifname2"); |
|---|
| 7345 | |
|---|
| 7346 | if (strlen(wanifname) == 0) |
|---|
| 7347 | wanifname = nvram_safe_get("wan_ifname"); |
|---|
| 7348 | memset(eths, 0, 256); |
|---|
| 7349 | getIfLists(eths, 256); |
|---|
| 7350 | if (strlen(wanifname) > 0) { |
|---|
| 7351 | |
|---|
| 7352 | websWrite(wp, |
|---|
| 7353 | "<legend><script type=\"text/javascript\">Capture(idx.portsetup)</script></legend>\n"); |
|---|
| 7354 | websWrite(wp, |
|---|
| 7355 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(idx.wanport)</script></div>\n"); |
|---|
| 7356 | websWrite(wp, "<select name=\"wan_ifname\">\n"); |
|---|
| 7357 | |
|---|
| 7358 | websWrite(wp, "<option value=\"\" %s >Disabled</option>\n", |
|---|
| 7359 | strlen(wanifname) == |
|---|
| 7360 | 0 ? "selected=\"selected\"" : ""); |
|---|
| 7361 | foreach(var, eths, next) { |
|---|
| 7362 | websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 7363 | var, !strcmp(wanifname, |
|---|
| 7364 | var) ? "selected=\"selected\"" : |
|---|
| 7365 | "", var); |
|---|
| 7366 | } |
|---|
| 7367 | websWrite(wp, "</select></div>\n"); |
|---|
| 7368 | } |
|---|
| 7369 | foreach(var, eths, next) { |
|---|
| 7370 | if (!strcmp(get_wan_face(), var)) |
|---|
| 7371 | continue; |
|---|
| 7372 | if (!strcmp(nvram_safe_get("lan_ifname"), var)) |
|---|
| 7373 | continue; |
|---|
| 7374 | if (!strncmp(var, "br", 2) && !contains(var, '.')) |
|---|
| 7375 | continue; |
|---|
| 7376 | |
|---|
| 7377 | sprintf(ssid, "%s_bridged", var); |
|---|
| 7378 | websWrite(wp, |
|---|
| 7379 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.network)</script> %s</div>\n", |
|---|
| 7380 | var); |
|---|
| 7381 | char layer[64]; |
|---|
| 7382 | |
|---|
| 7383 | strcpy(layer, var); |
|---|
| 7384 | rep(layer, '.', 'X'); |
|---|
| 7385 | websWrite(wp, |
|---|
| 7386 | "<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", |
|---|
| 7387 | layer, var, nvram_default_match(ssid, |
|---|
| 7388 | "0", |
|---|
| 7389 | "1") ? |
|---|
| 7390 | "checked=\"checked\"" : ""); |
|---|
| 7391 | websWrite(wp, |
|---|
| 7392 | "<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", |
|---|
| 7393 | layer, var, nvram_default_match(ssid, "1", |
|---|
| 7394 | "1") ? |
|---|
| 7395 | "checked=\"checked\"" : ""); |
|---|
| 7396 | websWrite(wp, "</div>\n"); |
|---|
| 7397 | |
|---|
| 7398 | websWrite(wp, "<div id=\"%s_idnet\">\n", layer); |
|---|
| 7399 | |
|---|
| 7400 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 7401 | websWrite(wp, "<div class=\"label\">%s</div>\n", |
|---|
| 7402 | live_translate("idx.mtu")); |
|---|
| 7403 | char mtu[32]; |
|---|
| 7404 | sprintf(mtu, "%s_mtu", var); |
|---|
| 7405 | websWrite(wp, |
|---|
| 7406 | "<input class=\"num\" maxlength=\"4\" onblur=\"valid_mtu(this)\" size=\"5\" name=\"%s_mtu\" value=\"%s\" />\n", |
|---|
| 7407 | var, nvram_default_get(mtu, "1500")); |
|---|
| 7408 | websWrite(wp, "</div>\n"); |
|---|
| 7409 | |
|---|
| 7410 | char mcast[32]; |
|---|
| 7411 | |
|---|
| 7412 | sprintf(mcast, "%s_multicast", var); |
|---|
| 7413 | nvram_default_get(mcast, "0"); |
|---|
| 7414 | showRadio(wp, "wl_basic.multicast", mcast); |
|---|
| 7415 | |
|---|
| 7416 | if (nvram_match("wk_mode", "gateway")) { |
|---|
| 7417 | sprintf(mcast, "%s_nat", var); |
|---|
| 7418 | nvram_default_get(mcast, "1"); |
|---|
| 7419 | showRadio(wp, "wl_basic.masquerade", mcast); |
|---|
| 7420 | } |
|---|
| 7421 | show_ipnetmask(wp, var); |
|---|
| 7422 | websWrite(wp, "</div>\n"); |
|---|
| 7423 | websWrite(wp, |
|---|
| 7424 | "<script type=\"text/javascript\">\n//<![CDATA[\n "); |
|---|
| 7425 | websWrite(wp, |
|---|
| 7426 | "show_layer_ext(document.getElementsByName(\"%s_bridged\"), \"%s_idnet\", %s);\n", |
|---|
| 7427 | var, layer, nvram_match(ssid, |
|---|
| 7428 | "0") ? "true" : "false"); |
|---|
| 7429 | websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 7430 | } |
|---|
| 7431 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 7432 | } |
|---|
| 7433 | #endif |
|---|
| 7434 | |
|---|
| 7435 | static void show_macfilter_if(webs_t wp, char *ifname) |
|---|
| 7436 | { |
|---|
| 7437 | websWrite(wp, "<fieldset>\n"); |
|---|
| 7438 | websWrite(wp, "<legend>%s - %s</legend>\n", IFMAP(ifname), |
|---|
| 7439 | live_translate("wl_mac.legend")); |
|---|
| 7440 | websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 7441 | websWrite(wp, "<div class=\"label\">%s</div>\n", |
|---|
| 7442 | live_translate("wl_mac.label")); |
|---|
| 7443 | char macmode[32]; |
|---|
| 7444 | |
|---|
| 7445 | sprintf(macmode, "%s_macmode1", ifname); |
|---|
| 7446 | rep(macmode, '.', 'X'); |
|---|
| 7447 | if (nvram_get(macmode) == NULL) |
|---|
| 7448 | nvram_set(macmode, "disabled"); |
|---|
| 7449 | char id[32]; |
|---|
| 7450 | |
|---|
| 7451 | sprintf(id, "idmac%s", ifname); |
|---|
| 7452 | rep(id, '.', 'X'); |
|---|
| 7453 | char mycopy[256]; |
|---|
| 7454 | |
|---|
| 7455 | strcpy(mycopy, live_translate("share.enable")); |
|---|
| 7456 | websWrite(wp, |
|---|
| 7457 | "<input class=\"spaceradio\" type=\"radio\" value=\"other\" name=\"%s\" %s onclick=\"show_layer_ext(this, '%s', true)\" />%s \n", |
|---|
| 7458 | macmode, nvram_match(macmode, |
|---|
| 7459 | "other") ? "checked=\"checked\"" : "", |
|---|
| 7460 | id, mycopy); |
|---|
| 7461 | strcpy(mycopy, live_translate("share.disable")); |
|---|
| 7462 | websWrite(wp, |
|---|
| 7463 | "<input class=\"spaceradio\" type=\"radio\" value=\"disabled\" name=\"%s\" %s onclick=\"show_layer_ext(this, '%s', false)\" />%s\n", |
|---|
| 7464 | macmode, nvram_match(macmode, |
|---|
| 7465 | "disabled") ? "checked=\"checked\"" : |
|---|
| 7466 | "", id, mycopy); |
|---|
| 7467 | websWrite(wp, "</div>\n"); |
|---|
| 7468 | websWrite(wp, "<div class=\"setting\" id=\"%s\">\n", id); |
|---|
| 7469 | websWrite(wp, "<div class=\"label\">%s<br /> </div>\n", |
|---|
| 7470 | live_translate("wl_mac.label2")); |
|---|
| 7471 | sprintf(macmode, "%s_macmode", ifname); |
|---|
| 7472 | if (nvram_get(macmode) == NULL) |
|---|
| 7473 | nvram_set(macmode, "disabled"); |
|---|
| 7474 | strcpy(mycopy, live_translate("wl_mac.deny")); |
|---|
| 7475 | websWrite(wp, |
|---|
| 7476 | "<input class=\"spaceradio\" type=\"radio\" value=\"deny\" name=\"%s\" %s />%s \n", |
|---|
| 7477 | macmode, nvram_invmatch(macmode, |
|---|
| 7478 | "allow") ? "checked=\"checked\"" : |
|---|
| 7479 | "", mycopy); |
|---|
| 7480 | websWrite(wp, "<br />\n"); |
|---|
| 7481 | strcpy(mycopy, live_translate("wl_mac.allow")); |
|---|
| 7482 | websWrite(wp, |
|---|
| 7483 | "<input class=\"spaceradio\" type=\"radio\" value=\"allow\" name=\"%s\" %s />%s\n", |
|---|
| 7484 | macmode, nvram_match(macmode, |
|---|
| 7485 | "allow") ? "checked=\"checked\"" : "", |
|---|
| 7486 | mycopy); |
|---|
| 7487 | websWrite(wp, "</div><br />\n"); |
|---|
| 7488 | websWrite(wp, "<div class=\"center\">\n"); |
|---|
| 7489 | websWrite(wp, "<script type=\"text/javascript\">\n"); |
|---|
| 7490 | websWrite(wp, "//<![CDATA[\n"); |
|---|
| 7491 | websWrite(wp, |
|---|
| 7492 | "document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" name=\\\"mac_filter_button\\\" value=\\\"\" + sbutton.filterMac + \"\\\" onclick=\\\"openWindow('WL_FilterTable-%s.asp', 930, 740,'MACList');\\\" />\");\n", |
|---|
| 7493 | ifname); |
|---|
| 7494 | websWrite(wp, "//]]>\n"); |
|---|
| 7495 | websWrite(wp, "</script>\n"); |
|---|
| 7496 | websWrite(wp, "</div>\n"); |
|---|
| 7497 | websWrite(wp, "</fieldset><br />\n"); |
|---|
| 7498 | } |
|---|
| 7499 | |
|---|
| 7500 | void ej_list_mac_layers(webs_t wp, int argc, char_t ** argv) |
|---|
| 7501 | { |
|---|
| 7502 | #ifndef HAVE_MADWIFI |
|---|
| 7503 | int c = get_wl_instances(); |
|---|
| 7504 | char devs[32]; |
|---|
| 7505 | int i; |
|---|
| 7506 | |
|---|
| 7507 | for (i = 0; i < c; i++) { |
|---|
| 7508 | char macmode[32]; |
|---|
| 7509 | char id[32]; |
|---|
| 7510 | |
|---|
| 7511 | sprintf(devs, "wl%d", i); |
|---|
| 7512 | sprintf(macmode, "%s_macmode1", devs); |
|---|
| 7513 | sprintf(id, "idmac%s", devs); |
|---|
| 7514 | rep(id, '.', 'X'); |
|---|
| 7515 | rep(macmode, '.', 'X'); |
|---|
| 7516 | websWrite(wp, |
|---|
| 7517 | "show_layer_ext(document.wireless.%s, '%s', \"%s\" == \"other\");\n", |
|---|
| 7518 | macmode, id, nvram_match(macmode, |
|---|
| 7519 | "other") ? "other" : |
|---|
| 7520 | "disabled"); |
|---|
| 7521 | } |
|---|
| 7522 | |
|---|
| 7523 | #else |
|---|
| 7524 | |
|---|
| 7525 | int c = getdevicecount(); |
|---|
| 7526 | char devs[32]; |
|---|
| 7527 | int i; |
|---|
| 7528 | |
|---|
| 7529 | for (i = 0; i < c; i++) { |
|---|
| 7530 | char macmode[32]; |
|---|
| 7531 | char id[32]; |
|---|
| 7532 | |
|---|
| 7533 | sprintf(devs, "ath%d", i); |
|---|
| 7534 | sprintf(macmode, "%s_macmode1", devs); |
|---|
| 7535 | sprintf(id, "idmac%s", devs); |
|---|
| 7536 | rep(id, '.', 'X'); |
|---|
| 7537 | rep(macmode, '.', 'X'); |
|---|
| 7538 | websWrite(wp, |
|---|
| 7539 | "show_layer_ext(document.wireless.%s, '%s', \"%s\" == \"other\");\n", |
|---|
| 7540 | macmode, id, nvram_match(macmode, |
|---|
| 7541 | "other") ? "other" : |
|---|
| 7542 | "disabled"); |
|---|
| 7543 | // show_macfilter_if (wp, devs); |
|---|
| 7544 | char vif[32]; |
|---|
| 7545 | |
|---|
| 7546 | sprintf(vif, "%s_vifs", devs); |
|---|
| 7547 | char var[80], *next; |
|---|
| 7548 | char *vifs = nvram_safe_get(vif); |
|---|
| 7549 | |
|---|
| 7550 | if (vifs != NULL) |
|---|
| 7551 | foreach(var, vifs, next) { |
|---|
| 7552 | sprintf(macmode, "%s_macmode1", var); |
|---|
| 7553 | sprintf(id, "idmac%s", var); |
|---|
| 7554 | rep(id, '.', 'X'); |
|---|
| 7555 | rep(macmode, '.', 'X'); |
|---|
| 7556 | websWrite(wp, |
|---|
| 7557 | "show_layer_ext(document.wireless.%s, '%s', \"%s\" == \"other\");\n", |
|---|
| 7558 | macmode, id, nvram_match(macmode, |
|---|
| 7559 | "other") ? "other" : |
|---|
| 7560 | "disabled"); |
|---|
| 7561 | } |
|---|
| 7562 | } |
|---|
| 7563 | |
|---|
| 7564 | #endif |
|---|
| 7565 | } |
|---|
| 7566 | |
|---|
| 7567 | void ej_show_macfilter(webs_t wp, int argc, char_t ** argv) |
|---|
| 7568 | { |
|---|
| 7569 | #ifndef HAVE_MADWIFI |
|---|
| 7570 | int c = get_wl_instances(); |
|---|
| 7571 | char devs[32]; |
|---|
| 7572 | int i; |
|---|
| 7573 | |
|---|
| 7574 | for (i = 0; i < c; i++) { |
|---|
| 7575 | sprintf(devs, "wl%d", i); |
|---|
| 7576 | show_macfilter_if(wp, devs); |
|---|
| 7577 | } |
|---|
| 7578 | #else |
|---|
| 7579 | int c = getdevicecount(); |
|---|
| 7580 | char devs[32]; |
|---|
| 7581 | int i; |
|---|
| 7582 | |
|---|
| 7583 | for (i = 0; i < c; i++) { |
|---|
| 7584 | sprintf(devs, "ath%d", i); |
|---|
| 7585 | show_macfilter_if(wp, devs); |
|---|
| 7586 | char vif[32]; |
|---|
| 7587 | |
|---|
| 7588 | sprintf(vif, "%s_vifs", devs); |
|---|
| 7589 | char var[80], *next; |
|---|
| 7590 | char *vifs = nvram_safe_get(vif); |
|---|
| 7591 | |
|---|
| 7592 | if (vifs != NULL) |
|---|
| 7593 | foreach(var, vifs, next) { |
|---|
| 7594 | show_macfilter_if(wp, var); |
|---|
| 7595 | } |
|---|
| 7596 | } |
|---|
| 7597 | |
|---|
| 7598 | #endif |
|---|
| 7599 | } |
|---|
| 7600 | |
|---|
| 7601 | void ej_show_ifselect(webs_t wp, int argc, char_t ** argv) |
|---|
| 7602 | { |
|---|
| 7603 | if (argc < 1) |
|---|
| 7604 | return; |
|---|
| 7605 | char *ifname = argv[0]; |
|---|
| 7606 | websWrite(wp, "<select name=\"%s\">\n", ifname); |
|---|
| 7607 | websWrite(wp, "<option value=\"%s\" %s >LAN</option>\n", |
|---|
| 7608 | nvram_safe_get("lan_ifname"), |
|---|
| 7609 | nvram_match(ifname, |
|---|
| 7610 | nvram_safe_get("lan_ifname")) ? |
|---|
| 7611 | "selected=\"selected\"" : ""); |
|---|
| 7612 | char *next; |
|---|
| 7613 | char var[80]; |
|---|
| 7614 | char eths[256]; |
|---|
| 7615 | |
|---|
| 7616 | memset(eths, 0, 256); |
|---|
| 7617 | getIfLists(eths, 256); |
|---|
| 7618 | foreach(var, eths, next) { |
|---|
| 7619 | if (!strcmp(get_wan_face(), var)) |
|---|
| 7620 | continue; |
|---|
| 7621 | if (!strcmp(nvram_safe_get("lan_ifname"), var)) |
|---|
| 7622 | continue; |
|---|
| 7623 | websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", var, |
|---|
| 7624 | nvram_match(ifname, var) ? "selected" : "", var); |
|---|
| 7625 | } |
|---|
| 7626 | |
|---|
| 7627 | websWrite(wp, "</select>\n"); |
|---|
| 7628 | } |
|---|
| 7629 | |
|---|
| 7630 | #ifdef HAVE_RFLOW |
|---|
| 7631 | void ej_show_rflowif(webs_t wp, int argc, char_t ** argv) |
|---|
| 7632 | { |
|---|
| 7633 | websWrite(wp, "<option value=\"%s\" %s >LAN & WLAN</option>\n", |
|---|
| 7634 | nvram_safe_get("lan_ifname"), nvram_match("rflow_if", |
|---|
| 7635 | nvram_safe_get |
|---|
| 7636 | ("lan_ifname")) |
|---|
| 7637 | ? "selected=\"selected\"" : ""); |
|---|
| 7638 | |
|---|
| 7639 | char *lanifs = nvram_safe_get("lan_ifnames"); |
|---|
| 7640 | char *next; |
|---|
| 7641 | char var[80]; |
|---|
| 7642 | |
|---|
| 7643 | foreach(var, lanifs, next) { |
|---|
| 7644 | if (nvram_match("wan_ifname", var)) |
|---|
| 7645 | continue; |
|---|
| 7646 | if (!ifexists(var)) |
|---|
| 7647 | continue; |
|---|
| 7648 | websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 7649 | var, nvram_match("rflow_if", |
|---|
| 7650 | var) ? "selected=\"selected\"" : |
|---|
| 7651 | "", var); |
|---|
| 7652 | } |
|---|
| 7653 | |
|---|
| 7654 | int cnt = get_wl_instances(); |
|---|
| 7655 | int c; |
|---|
| 7656 | |
|---|
| 7657 | for (c = 0; c < cnt; c++) { |
|---|
| 7658 | sprintf(var, "wl%d_ifname", c); |
|---|
| 7659 | websWrite(wp, "<option value=\"%s\" %s >WLAN%d</option>\n", |
|---|
| 7660 | nvram_safe_get(var), nvram_match("rflow_if", |
|---|
| 7661 | nvram_safe_get(var)) |
|---|
| 7662 | ? "selected=\"selected\"" : "", c); |
|---|
| 7663 | } |
|---|
| 7664 | |
|---|
| 7665 | char *wanif = nvram_safe_get("wan_ifname"); |
|---|
| 7666 | |
|---|
| 7667 | if (strlen(wanif) != 0) { |
|---|
| 7668 | websWrite(wp, "<option value=\"%s\" %s >WAN</option>\n", |
|---|
| 7669 | wanif, nvram_match("rflow_if", |
|---|
| 7670 | wanif) ? "selected=\"selected\"" : |
|---|
| 7671 | ""); |
|---|
| 7672 | } |
|---|
| 7673 | } |
|---|
| 7674 | #endif |
|---|