| 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 | void show_ipnetmask( webs_t wp, char *var ) |
|---|
| 59 | { |
|---|
| 60 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 61 | websWrite( wp, |
|---|
| 62 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.ip)</script></div>\n" ); |
|---|
| 63 | |
|---|
| 64 | char *ipv = nvram_nget( "%s_ipaddr", var ); |
|---|
| 65 | |
|---|
| 66 | websWrite( wp, |
|---|
| 67 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,1,223,share.ip)\" name=\"%s_ipaddr_0\" value=\"%d\" />.", |
|---|
| 68 | var, get_single_ip( ipv, 0 ) ); |
|---|
| 69 | websWrite( wp, |
|---|
| 70 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_1\" value=\"%d\" />.", |
|---|
| 71 | var, get_single_ip( ipv, 1 ) ); |
|---|
| 72 | websWrite( wp, |
|---|
| 73 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_2\" value=\"%d\" />.", |
|---|
| 74 | var, get_single_ip( ipv, 2 ) ); |
|---|
| 75 | websWrite( wp, |
|---|
| 76 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_3\" value=\"%d\" />\n", |
|---|
| 77 | var, get_single_ip( ipv, 3 ) ); |
|---|
| 78 | websWrite( wp, "</div>\n" ); |
|---|
| 79 | |
|---|
| 80 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 81 | websWrite( wp, |
|---|
| 82 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.subnet)</script></div>\n" ); |
|---|
| 83 | ipv = nvram_nget( "%s_netmask", var ); |
|---|
| 84 | |
|---|
| 85 | websWrite( wp, |
|---|
| 86 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_0\" value=\"%d\" />.", |
|---|
| 87 | var, get_single_ip( ipv, 0 ) ); |
|---|
| 88 | websWrite( wp, |
|---|
| 89 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_1\" value=\"%d\" />.", |
|---|
| 90 | var, get_single_ip( ipv, 1 ) ); |
|---|
| 91 | websWrite( wp, |
|---|
| 92 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_2\" value=\"%d\" />.", |
|---|
| 93 | var, get_single_ip( ipv, 2 ) ); |
|---|
| 94 | websWrite( wp, |
|---|
| 95 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_3\" value=\"%d\" />", |
|---|
| 96 | var, get_single_ip( ipv, 3 ) ); |
|---|
| 97 | websWrite( wp, "</div>\n<br />\n" ); |
|---|
| 98 | |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | #ifdef HAVE_OVERCLOCKING |
|---|
| 102 | void ej_show_clocks( webs_t wp, int argc, char_t ** argv ) |
|---|
| 103 | { |
|---|
| 104 | int tab = cpu_plltype( ); |
|---|
| 105 | unsigned int *c; |
|---|
| 106 | |
|---|
| 107 | if( tab == 3 ) |
|---|
| 108 | c = type3_clocks; |
|---|
| 109 | else if( tab == 4 ) |
|---|
| 110 | c = type4_clocks; |
|---|
| 111 | else if( tab == 7 ) |
|---|
| 112 | c = type7_clocks; |
|---|
| 113 | else |
|---|
| 114 | { |
|---|
| 115 | websWrite( wp, |
|---|
| 116 | "<script type=\"text/javascript\">Capture(management.clock_support)</script>\n</div>\n" ); |
|---|
| 117 | return; |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | websWrite( wp, |
|---|
| 121 | "<div class=\"label\"><script type=\"text/javascript\">Capture(management.clock_frq)</script></div>\n" ); |
|---|
| 122 | websWrite( wp, "<select name=\"overclocking\">\n" ); |
|---|
| 123 | |
|---|
| 124 | int i = 0; |
|---|
| 125 | char clock[16]; |
|---|
| 126 | |
|---|
| 127 | while( c[i] != 0 ) |
|---|
| 128 | { |
|---|
| 129 | sprintf( clock, "%d", c[i] ); |
|---|
| 130 | websWrite( wp, "<option value=\"%d\" %s >%d MHz</option>\n", c[i], |
|---|
| 131 | nvram_match( "overclocking", |
|---|
| 132 | clock ) ? "selected=\"selected\"" : "", |
|---|
| 133 | c[i] ); |
|---|
| 134 | i++; |
|---|
| 135 | } |
|---|
| 136 | websWrite( wp, "</select>\n</div>\n" ); |
|---|
| 137 | } |
|---|
| 138 | #endif |
|---|
| 139 | |
|---|
| 140 | void ej_show_routing( webs_t wp, int argc, char_t ** argv ) |
|---|
| 141 | { |
|---|
| 142 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 143 | websWrite( wp, |
|---|
| 144 | "document.write(\"<option value=\\\"gateway\\\" %s >\" + share.gateway + \"</option>\");\n", |
|---|
| 145 | nvram_selmatch( wp, "wk_mode", |
|---|
| 146 | "gateway" ) ? "selected=\\\"selected\\\"" : |
|---|
| 147 | "" ); |
|---|
| 148 | #ifdef HAVE_BIRD |
|---|
| 149 | websWrite( wp, |
|---|
| 150 | "document.write(\"<option value=\\\"bgp\\\" %s >BGP</option>\");\n", |
|---|
| 151 | nvram_selmatch( wp, "wk_mode", |
|---|
| 152 | "bgp" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 153 | websWrite( wp, |
|---|
| 154 | "document.write(\"<option value=\\\"router\\\" %s >\" + route.rip2_mod + \"</option>\");\n", |
|---|
| 155 | nvram_selmatch( wp, "wk_mode", |
|---|
| 156 | "router" ) ? "selected=\\\"selected\\\"" : |
|---|
| 157 | "" ); |
|---|
| 158 | #endif |
|---|
| 159 | #ifdef HAVE_QUAGGA |
|---|
| 160 | websWrite( wp, |
|---|
| 161 | "document.write(\"<option value=\\\"bgp\\\" %s >BGP</option>\");\n", |
|---|
| 162 | nvram_selmatch( wp, "wk_mode", |
|---|
| 163 | "bgp" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 164 | websWrite( wp, |
|---|
| 165 | "document.write(\"<option value=\\\"router\\\" %s >\" + route.rip2_mod + \"</option>\");\n", |
|---|
| 166 | nvram_selmatch( wp, "wk_mode", |
|---|
| 167 | "router" ) ? "selected=\\\"selected\\\"" : |
|---|
| 168 | "" ); |
|---|
| 169 | websWrite( wp, |
|---|
| 170 | "document.write(\"<option value=\\\"ospf\\\" %s >\" + route.ospf_mod + \"</option>\");\n", |
|---|
| 171 | nvram_selmatch( wp, "wk_mode", |
|---|
| 172 | "ospf" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 173 | #endif |
|---|
| 174 | #ifdef HAVE_OLSRD |
|---|
| 175 | websWrite( wp, |
|---|
| 176 | "document.write(\"<option value=\\\"olsr\\\" %s >\" + route.olsrd_mod + \"</option>\");\n", |
|---|
| 177 | nvram_selmatch( wp, "wk_mode", |
|---|
| 178 | "olsr" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 179 | #endif |
|---|
| 180 | websWrite( wp, |
|---|
| 181 | "document.write(\"<option value=\\\"static\\\" %s >\" + share.router + \"</option>\");\n", |
|---|
| 182 | nvram_selmatch( wp, "wk_mode", |
|---|
| 183 | "static" ) ? "selected=\\\"selected\\\"" : |
|---|
| 184 | "" ); |
|---|
| 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 | "" ); |
|---|
| 204 | websWrite( wp, |
|---|
| 205 | "document.write(\"<option value=\\\"dhcp\\\" %s >\" + idx.dhcp + \"</option>\");\n", |
|---|
| 206 | nvram_selmatch( wp, "wan_proto", |
|---|
| 207 | "dhcp" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 208 | websWrite( wp, "\n//]]>\n</script>\n" ); |
|---|
| 209 | |
|---|
| 210 | #ifdef HAVE_PPPOE |
|---|
| 211 | websWrite( wp, "<option value=\"pppoe\" %s >PPPoE</option>\n", |
|---|
| 212 | nvram_selmatch( wp, "wan_proto", |
|---|
| 213 | "pppoe" ) ? "selected=\"selected\"" : "" ); |
|---|
| 214 | #endif |
|---|
| 215 | #ifdef HAVE_PPTP |
|---|
| 216 | websWrite( wp, "<option value=\"pptp\" %s >PPTP</option>\n", |
|---|
| 217 | nvram_selmatch( wp, "wan_proto", |
|---|
| 218 | "pptp" ) ? "selected=\"selected\"" : "" ); |
|---|
| 219 | #endif |
|---|
| 220 | #ifdef HAVE_L2TP |
|---|
| 221 | websWrite( wp, "<option value=\"l2tp\" %s >L2TP</option>\n", |
|---|
| 222 | nvram_selmatch( wp, "wan_proto", |
|---|
| 223 | "l2tp" ) ? "selected=\"selected\"" : "" ); |
|---|
| 224 | #endif |
|---|
| 225 | #ifdef HAVE_HEARTBEAT |
|---|
| 226 | websWrite( wp, |
|---|
| 227 | "<option value=\"heartbeat\" %s >HeartBeat Signal</option>\n", |
|---|
| 228 | nvram_selmatch( wp, "wan_proto", |
|---|
| 229 | "heartbeat" ) ? "selected=\"selected\"" : "" ); |
|---|
| 230 | #endif |
|---|
| 231 | |
|---|
| 232 | return; |
|---|
| 233 | } |
|---|
| 234 | |
|---|
| 235 | void ej_show_infopage( webs_t wp, int argc, char_t ** argv ) |
|---|
| 236 | { |
|---|
| 237 | /* |
|---|
| 238 | * #ifdef HAVE_NEWMEDIA websWrite(wp,"<dl>\n"); websWrite(wp,"<dd |
|---|
| 239 | * class=\"definition\">GGEW net GmbH</dd>\n"); websWrite(wp,"<dd |
|---|
| 240 | * class=\"definition\">Dammstrasse 68</dd>\n"); websWrite(wp,"<dd |
|---|
| 241 | * class=\"definition\">64625 Bensheim</dd>\n"); websWrite(wp,"<dd |
|---|
| 242 | * class=\"definition\"><a href=\"http://ggew-net.de\"><img |
|---|
| 243 | * src=\"images/ggewlogo.gif\" border=\"0\"/></a></dd>\n"); |
|---|
| 244 | * websWrite(wp,"<dd class=\"definition\"> </dd>\n"); websWrite(wp,"<dd |
|---|
| 245 | * class=\"definition\"><a href=\"http://ggew-net.de\"/></dd>\n"); |
|---|
| 246 | * websWrite(wp,"<dd class=\"definition\"> </dd>\n"); websWrite(wp,"<dd |
|---|
| 247 | * class=\"definition\">In Kooperation mit NewMedia-NET GmbH</dd>\n"); |
|---|
| 248 | * websWrite(wp,"<dd class=\"definition\"><a |
|---|
| 249 | * href=\"http://www.newmedia-net.de\"/></dd>\n"); |
|---|
| 250 | * websWrite(wp,"</dl>\n"); #endif |
|---|
| 251 | */ |
|---|
| 252 | return; |
|---|
| 253 | } |
|---|
| 254 | |
|---|
| 255 | void ej_dumpmeminfo( webs_t wp, int argc, char_t ** argv ) |
|---|
| 256 | { |
|---|
| 257 | FILE *fcpu = fopen( "/proc/meminfo", "r" ); |
|---|
| 258 | |
|---|
| 259 | if( fcpu == NULL ) |
|---|
| 260 | { |
|---|
| 261 | return; |
|---|
| 262 | } |
|---|
| 263 | char buf[128]; |
|---|
| 264 | int n = 0; |
|---|
| 265 | |
|---|
| 266 | rept:; |
|---|
| 267 | if( n == EOF ) |
|---|
| 268 | { |
|---|
| 269 | fclose( fcpu ); |
|---|
| 270 | return; |
|---|
| 271 | } |
|---|
| 272 | if( n ) |
|---|
| 273 | websWrite( wp, "'%s'", buf ); |
|---|
| 274 | n = fscanf( fcpu, "%s", buf ); |
|---|
| 275 | if( n != EOF ) |
|---|
| 276 | websWrite( wp, "," ); |
|---|
| 277 | goto rept; |
|---|
| 278 | } |
|---|
| 279 | |
|---|
| 280 | #ifdef HAVE_RB500 |
|---|
| 281 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 282 | { |
|---|
| 283 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 284 | |
|---|
| 285 | if( fp == NULL ) |
|---|
| 286 | { |
|---|
| 287 | websWrite( wp, "unknown" ); |
|---|
| 288 | return; |
|---|
| 289 | } |
|---|
| 290 | int cnt = 0; |
|---|
| 291 | int b = 0; |
|---|
| 292 | |
|---|
| 293 | while( b != EOF ) |
|---|
| 294 | { |
|---|
| 295 | b = getc( fp ); |
|---|
| 296 | if( b == ':' ) |
|---|
| 297 | cnt++; |
|---|
| 298 | |
|---|
| 299 | if( cnt == 4 ) |
|---|
| 300 | { |
|---|
| 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_XSCALE |
|---|
| 336 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 337 | { |
|---|
| 338 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 339 | |
|---|
| 340 | if( fp == NULL ) |
|---|
| 341 | { |
|---|
| 342 | websWrite( wp, "unknown" ); |
|---|
| 343 | return; |
|---|
| 344 | } |
|---|
| 345 | int cnt = 0; |
|---|
| 346 | int b = 0; |
|---|
| 347 | |
|---|
| 348 | while( b != EOF ) |
|---|
| 349 | { |
|---|
| 350 | b = getc( fp ); |
|---|
| 351 | if( b == ':' ) |
|---|
| 352 | cnt++; |
|---|
| 353 | if( cnt == 2 ) |
|---|
| 354 | { |
|---|
| 355 | getc( fp ); |
|---|
| 356 | char cpuclk[4]; |
|---|
| 357 | |
|---|
| 358 | cpuclk[0] = getc( fp ); |
|---|
| 359 | cpuclk[1] = getc( fp ); |
|---|
| 360 | cpuclk[2] = getc( fp ); |
|---|
| 361 | cpuclk[3] = 0; |
|---|
| 362 | websWrite( wp, cpuclk ); |
|---|
| 363 | fclose( fp ); |
|---|
| 364 | return; |
|---|
| 365 | } |
|---|
| 366 | } |
|---|
| 367 | |
|---|
| 368 | fclose( fp ); |
|---|
| 369 | websWrite( wp, "unknown" ); |
|---|
| 370 | return; |
|---|
| 371 | } |
|---|
| 372 | #elif HAVE_X86 |
|---|
| 373 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 374 | { |
|---|
| 375 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 376 | |
|---|
| 377 | if( fp == NULL ) |
|---|
| 378 | { |
|---|
| 379 | websWrite( wp, "unknown" ); |
|---|
| 380 | return; |
|---|
| 381 | } |
|---|
| 382 | int cnt = 0; |
|---|
| 383 | int b = 0; |
|---|
| 384 | |
|---|
| 385 | while( b != EOF ) |
|---|
| 386 | { |
|---|
| 387 | b = getc( fp ); |
|---|
| 388 | if( b == ':' ) |
|---|
| 389 | cnt++; |
|---|
| 390 | if( cnt == 7 ) |
|---|
| 391 | { |
|---|
| 392 | getc( fp ); |
|---|
| 393 | char cpuclk[32]; |
|---|
| 394 | int i = 0; |
|---|
| 395 | |
|---|
| 396 | b = getc( fp ); |
|---|
| 397 | while( b != 0xa && b != 0xd && b != 0x20 ) |
|---|
| 398 | { |
|---|
| 399 | cpuclk[i++] = b; |
|---|
| 400 | b = getc( fp ); |
|---|
| 401 | } |
|---|
| 402 | cpuclk[i++] = 0; |
|---|
| 403 | websWrite( wp, cpuclk ); |
|---|
| 404 | fclose( fp ); |
|---|
| 405 | return; |
|---|
| 406 | } |
|---|
| 407 | } |
|---|
| 408 | |
|---|
| 409 | fclose( fp ); |
|---|
| 410 | websWrite( wp, "unknown" ); |
|---|
| 411 | return; |
|---|
| 412 | } |
|---|
| 413 | #elif HAVE_MAGICBOX |
|---|
| 414 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 415 | { |
|---|
| 416 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 417 | |
|---|
| 418 | if( fp == NULL ) |
|---|
| 419 | { |
|---|
| 420 | websWrite( wp, "unknown" ); |
|---|
| 421 | return; |
|---|
| 422 | } |
|---|
| 423 | int cnt = 0; |
|---|
| 424 | int b = 0; |
|---|
| 425 | |
|---|
| 426 | while( b != EOF ) |
|---|
| 427 | { |
|---|
| 428 | b = getc( fp ); |
|---|
| 429 | if( b == ':' ) |
|---|
| 430 | cnt++; |
|---|
| 431 | if( cnt == 3 ) |
|---|
| 432 | { |
|---|
| 433 | getc( fp ); |
|---|
| 434 | char cpuclk[4]; |
|---|
| 435 | |
|---|
| 436 | cpuclk[0] = getc( fp ); |
|---|
| 437 | cpuclk[1] = getc( fp ); |
|---|
| 438 | cpuclk[2] = getc( fp ); |
|---|
| 439 | cpuclk[3] = 0; |
|---|
| 440 | websWrite( wp, cpuclk ); |
|---|
| 441 | fclose( fp ); |
|---|
| 442 | return; |
|---|
| 443 | } |
|---|
| 444 | } |
|---|
| 445 | |
|---|
| 446 | fclose( fp ); |
|---|
| 447 | websWrite( wp, "unknown" ); |
|---|
| 448 | return; |
|---|
| 449 | } |
|---|
| 450 | #elif HAVE_FONERA |
|---|
| 451 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 452 | { |
|---|
| 453 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 454 | |
|---|
| 455 | if( fp == NULL ) |
|---|
| 456 | { |
|---|
| 457 | websWrite( wp, "unknown" ); |
|---|
| 458 | return; |
|---|
| 459 | } |
|---|
| 460 | int cnt = 0; |
|---|
| 461 | int b = 0; |
|---|
| 462 | |
|---|
| 463 | while( b != EOF ) |
|---|
| 464 | { |
|---|
| 465 | b = getc( fp ); |
|---|
| 466 | if( b == ':' ) |
|---|
| 467 | cnt++; |
|---|
| 468 | if( cnt == 4 ) |
|---|
| 469 | { |
|---|
| 470 | getc( fp ); |
|---|
| 471 | char cpuclk[4]; |
|---|
| 472 | |
|---|
| 473 | cpuclk[0] = getc( fp ); |
|---|
| 474 | cpuclk[1] = getc( fp ); |
|---|
| 475 | cpuclk[2] = getc( fp ); |
|---|
| 476 | cpuclk[3] = 0; |
|---|
| 477 | websWrite( wp, cpuclk ); |
|---|
| 478 | fclose( fp ); |
|---|
| 479 | return; |
|---|
| 480 | } |
|---|
| 481 | } |
|---|
| 482 | |
|---|
| 483 | fclose( fp ); |
|---|
| 484 | websWrite( wp, "unknown" ); |
|---|
| 485 | return; |
|---|
| 486 | } |
|---|
| 487 | #elif HAVE_ADM5120 |
|---|
| 488 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 489 | { |
|---|
| 490 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 491 | |
|---|
| 492 | if( fp == NULL ) |
|---|
| 493 | { |
|---|
| 494 | websWrite( wp, "unknown" ); |
|---|
| 495 | return; |
|---|
| 496 | } |
|---|
| 497 | int cnt = 0; |
|---|
| 498 | int b = 0; |
|---|
| 499 | |
|---|
| 500 | while( b != EOF ) |
|---|
| 501 | { |
|---|
| 502 | b = getc( fp ); |
|---|
| 503 | if( b == ':' ) |
|---|
| 504 | cnt++; |
|---|
| 505 | if( cnt == 4 ) |
|---|
| 506 | { |
|---|
| 507 | getc( fp ); |
|---|
| 508 | char cpuclk[4]; |
|---|
| 509 | |
|---|
| 510 | cpuclk[0] = getc( fp ); |
|---|
| 511 | cpuclk[1] = getc( fp ); |
|---|
| 512 | cpuclk[2] = getc( fp ); |
|---|
| 513 | cpuclk[3] = 0; |
|---|
| 514 | websWrite( wp, cpuclk ); |
|---|
| 515 | fclose( fp ); |
|---|
| 516 | return; |
|---|
| 517 | } |
|---|
| 518 | } |
|---|
| 519 | |
|---|
| 520 | fclose( fp ); |
|---|
| 521 | websWrite( wp, "unknown" ); |
|---|
| 522 | return; |
|---|
| 523 | } |
|---|
| 524 | #elif HAVE_MERAKI |
|---|
| 525 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 526 | { |
|---|
| 527 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 528 | |
|---|
| 529 | if( fp == NULL ) |
|---|
| 530 | { |
|---|
| 531 | websWrite( wp, "unknown" ); |
|---|
| 532 | return; |
|---|
| 533 | } |
|---|
| 534 | int cnt = 0; |
|---|
| 535 | int b = 0; |
|---|
| 536 | |
|---|
| 537 | while( b != EOF ) |
|---|
| 538 | { |
|---|
| 539 | b = getc( fp ); |
|---|
| 540 | if( b == ':' ) |
|---|
| 541 | cnt++; |
|---|
| 542 | if( cnt == 4 ) |
|---|
| 543 | { |
|---|
| 544 | getc( fp ); |
|---|
| 545 | char cpuclk[4]; |
|---|
| 546 | |
|---|
| 547 | cpuclk[0] = getc( fp ); |
|---|
| 548 | cpuclk[1] = getc( fp ); |
|---|
| 549 | cpuclk[2] = getc( fp ); |
|---|
| 550 | cpuclk[3] = 0; |
|---|
| 551 | websWrite( wp, cpuclk ); |
|---|
| 552 | fclose( fp ); |
|---|
| 553 | return; |
|---|
| 554 | } |
|---|
| 555 | } |
|---|
| 556 | |
|---|
| 557 | fclose( fp ); |
|---|
| 558 | websWrite( wp, "unknown" ); |
|---|
| 559 | return; |
|---|
| 560 | } |
|---|
| 561 | #elif HAVE_LS2 |
|---|
| 562 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 563 | { |
|---|
| 564 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 565 | |
|---|
| 566 | if( fp == NULL ) |
|---|
| 567 | { |
|---|
| 568 | websWrite( wp, "unknown" ); |
|---|
| 569 | return; |
|---|
| 570 | } |
|---|
| 571 | int cnt = 0; |
|---|
| 572 | int b = 0; |
|---|
| 573 | |
|---|
| 574 | while( b != EOF ) |
|---|
| 575 | { |
|---|
| 576 | b = getc( fp ); |
|---|
| 577 | if( b == ':' ) |
|---|
| 578 | cnt++; |
|---|
| 579 | if( cnt == 4 ) |
|---|
| 580 | { |
|---|
| 581 | getc( fp ); |
|---|
| 582 | char cpuclk[4]; |
|---|
| 583 | |
|---|
| 584 | cpuclk[0] = getc( fp ); |
|---|
| 585 | cpuclk[1] = getc( fp ); |
|---|
| 586 | cpuclk[2] = getc( fp ); |
|---|
| 587 | cpuclk[3] = 0; |
|---|
| 588 | websWrite( wp, cpuclk ); |
|---|
| 589 | fclose( fp ); |
|---|
| 590 | return; |
|---|
| 591 | } |
|---|
| 592 | } |
|---|
| 593 | |
|---|
| 594 | fclose( fp ); |
|---|
| 595 | websWrite( wp, "unknown" ); |
|---|
| 596 | return; |
|---|
| 597 | } |
|---|
| 598 | #elif HAVE_LS5 |
|---|
| 599 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 600 | { |
|---|
| 601 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 602 | |
|---|
| 603 | if( fp == NULL ) |
|---|
| 604 | { |
|---|
| 605 | websWrite( wp, "unknown" ); |
|---|
| 606 | return; |
|---|
| 607 | } |
|---|
| 608 | int cnt = 0; |
|---|
| 609 | int b = 0; |
|---|
| 610 | |
|---|
| 611 | while( b != EOF ) |
|---|
| 612 | { |
|---|
| 613 | b = getc( fp ); |
|---|
| 614 | if( b == ':' ) |
|---|
| 615 | cnt++; |
|---|
| 616 | if( cnt == 4 ) |
|---|
| 617 | { |
|---|
| 618 | getc( fp ); |
|---|
| 619 | char cpuclk[4]; |
|---|
| 620 | |
|---|
| 621 | cpuclk[0] = getc( fp ); |
|---|
| 622 | cpuclk[1] = getc( fp ); |
|---|
| 623 | cpuclk[2] = getc( fp ); |
|---|
| 624 | cpuclk[3] = 0; |
|---|
| 625 | websWrite( wp, cpuclk ); |
|---|
| 626 | fclose( fp ); |
|---|
| 627 | return; |
|---|
| 628 | } |
|---|
| 629 | } |
|---|
| 630 | |
|---|
| 631 | fclose( fp ); |
|---|
| 632 | websWrite( wp, "unknown" ); |
|---|
| 633 | return; |
|---|
| 634 | } |
|---|
| 635 | #elif HAVE_WHRAG108 |
|---|
| 636 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 637 | { |
|---|
| 638 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 639 | |
|---|
| 640 | if( fp == NULL ) |
|---|
| 641 | { |
|---|
| 642 | websWrite( wp, "unknown" ); |
|---|
| 643 | return; |
|---|
| 644 | } |
|---|
| 645 | int cnt = 0; |
|---|
| 646 | int b = 0; |
|---|
| 647 | |
|---|
| 648 | while( b != EOF ) |
|---|
| 649 | { |
|---|
| 650 | b = getc( fp ); |
|---|
| 651 | if( b == ':' ) |
|---|
| 652 | cnt++; |
|---|
| 653 | if( cnt == 4 ) |
|---|
| 654 | { |
|---|
| 655 | getc( fp ); |
|---|
| 656 | char cpuclk[4]; |
|---|
| 657 | |
|---|
| 658 | cpuclk[0] = getc( fp ); |
|---|
| 659 | cpuclk[1] = getc( fp ); |
|---|
| 660 | cpuclk[2] = getc( fp ); |
|---|
| 661 | cpuclk[3] = 0; |
|---|
| 662 | websWrite( wp, cpuclk ); |
|---|
| 663 | fclose( fp ); |
|---|
| 664 | return; |
|---|
| 665 | } |
|---|
| 666 | } |
|---|
| 667 | |
|---|
| 668 | fclose( fp ); |
|---|
| 669 | websWrite( wp, "unknown" ); |
|---|
| 670 | return; |
|---|
| 671 | } |
|---|
| 672 | #elif defined(HAVE_PB42) || defined(HAVE_LSX) || defined(HAVE_DANUBE) |
|---|
| 673 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 674 | { |
|---|
| 675 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 676 | |
|---|
| 677 | if( fp == NULL ) |
|---|
| 678 | { |
|---|
| 679 | websWrite( wp, "unknown" ); |
|---|
| 680 | return; |
|---|
| 681 | } |
|---|
| 682 | int cnt = 0; |
|---|
| 683 | int b = 0; |
|---|
| 684 | |
|---|
| 685 | while( b != EOF ) |
|---|
| 686 | { |
|---|
| 687 | b = getc( fp ); |
|---|
| 688 | if( b == ':' ) |
|---|
| 689 | cnt++; |
|---|
| 690 | if( cnt == 5 ) |
|---|
| 691 | { |
|---|
| 692 | getc( fp ); |
|---|
| 693 | char cpuclk[4]; |
|---|
| 694 | |
|---|
| 695 | cpuclk[0] = getc( fp ); |
|---|
| 696 | cpuclk[1] = getc( fp ); |
|---|
| 697 | cpuclk[2] = getc( fp ); |
|---|
| 698 | cpuclk[3] = 0; |
|---|
| 699 | websWrite( wp, cpuclk ); |
|---|
| 700 | fclose( fp ); |
|---|
| 701 | return; |
|---|
| 702 | } |
|---|
| 703 | } |
|---|
| 704 | |
|---|
| 705 | fclose( fp ); |
|---|
| 706 | websWrite( wp, "unknown" ); |
|---|
| 707 | return; |
|---|
| 708 | } |
|---|
| 709 | #elif HAVE_TW6600 |
|---|
| 710 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 711 | { |
|---|
| 712 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 713 | |
|---|
| 714 | if( fp == NULL ) |
|---|
| 715 | { |
|---|
| 716 | websWrite( wp, "unknown" ); |
|---|
| 717 | return; |
|---|
| 718 | } |
|---|
| 719 | int cnt = 0; |
|---|
| 720 | int b = 0; |
|---|
| 721 | |
|---|
| 722 | while( b != EOF ) |
|---|
| 723 | { |
|---|
| 724 | b = getc( fp ); |
|---|
| 725 | if( b == ':' ) |
|---|
| 726 | cnt++; |
|---|
| 727 | if( cnt == 4 ) |
|---|
| 728 | { |
|---|
| 729 | getc( fp ); |
|---|
| 730 | char cpuclk[4]; |
|---|
| 731 | |
|---|
| 732 | cpuclk[0] = getc( fp ); |
|---|
| 733 | cpuclk[1] = getc( fp ); |
|---|
| 734 | cpuclk[2] = getc( fp ); |
|---|
| 735 | cpuclk[3] = 0; |
|---|
| 736 | websWrite( wp, cpuclk ); |
|---|
| 737 | fclose( fp ); |
|---|
| 738 | return; |
|---|
| 739 | } |
|---|
| 740 | } |
|---|
| 741 | |
|---|
| 742 | fclose( fp ); |
|---|
| 743 | websWrite( wp, "unknown" ); |
|---|
| 744 | return; |
|---|
| 745 | } |
|---|
| 746 | #elif HAVE_CA8 |
|---|
| 747 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 748 | { |
|---|
| 749 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 750 | |
|---|
| 751 | if( fp == NULL ) |
|---|
| 752 | { |
|---|
| 753 | websWrite( wp, "unknown" ); |
|---|
| 754 | return; |
|---|
| 755 | } |
|---|
| 756 | int cnt = 0; |
|---|
| 757 | int b = 0; |
|---|
| 758 | |
|---|
| 759 | while( b != EOF ) |
|---|
| 760 | { |
|---|
| 761 | b = getc( fp ); |
|---|
| 762 | if( b == ':' ) |
|---|
| 763 | cnt++; |
|---|
| 764 | if( cnt == 4 ) |
|---|
| 765 | { |
|---|
| 766 | getc( fp ); |
|---|
| 767 | char cpuclk[4]; |
|---|
| 768 | |
|---|
| 769 | cpuclk[0] = getc( fp ); |
|---|
| 770 | cpuclk[1] = getc( fp ); |
|---|
| 771 | cpuclk[2] = getc( fp ); |
|---|
| 772 | cpuclk[3] = 0; |
|---|
| 773 | websWrite( wp, cpuclk ); |
|---|
| 774 | fclose( fp ); |
|---|
| 775 | return; |
|---|
| 776 | } |
|---|
| 777 | } |
|---|
| 778 | |
|---|
| 779 | fclose( fp ); |
|---|
| 780 | websWrite( wp, "unknown" ); |
|---|
| 781 | return; |
|---|
| 782 | } |
|---|
| 783 | |
|---|
| 784 | #else |
|---|
| 785 | |
|---|
| 786 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 787 | { |
|---|
| 788 | char *clk = nvram_get( "clkfreq" ); |
|---|
| 789 | |
|---|
| 790 | if( clk == NULL ) |
|---|
| 791 | { |
|---|
| 792 | if (getcpurev( ) == 0) //BCM4710 |
|---|
| 793 | websWrite( wp, "125" ); |
|---|
| 794 | else if (getcpurev( ) == 29) //BCM5354 |
|---|
| 795 | websWrite( wp, "240" ); |
|---|
| 796 | else |
|---|
| 797 | websWrite( wp, "unknown" ); |
|---|
| 798 | return; |
|---|
| 799 | } |
|---|
| 800 | char buf[64]; |
|---|
| 801 | |
|---|
| 802 | strcpy( buf, clk ); |
|---|
| 803 | int i = 0; |
|---|
| 804 | |
|---|
| 805 | while( buf[i++] != 0 ) |
|---|
| 806 | { |
|---|
| 807 | if( buf[i] == ',' ) |
|---|
| 808 | buf[i] = 0; |
|---|
| 809 | } |
|---|
| 810 | websWrite( wp, buf ); |
|---|
| 811 | return; |
|---|
| 812 | } |
|---|
| 813 | #endif |
|---|
| 814 | |
|---|
| 815 | void ej_show_cpuinfo( webs_t wp, int argc, char_t ** argv ) |
|---|
| 816 | { |
|---|
| 817 | FILE *fcpu = fopen( "/proc/cpuinfo", "r" ); |
|---|
| 818 | |
|---|
| 819 | if( fcpu == NULL ) |
|---|
| 820 | { |
|---|
| 821 | websWrite( wp, "Not Detected!\n" ); |
|---|
| 822 | return; |
|---|
| 823 | } |
|---|
| 824 | char buf[256]; |
|---|
| 825 | int i; |
|---|
| 826 | |
|---|
| 827 | #ifdef HAVE_MAGICBOX |
|---|
| 828 | int cnt = 0; |
|---|
| 829 | #endif |
|---|
| 830 | #ifdef HAVE_X86 |
|---|
| 831 | int cnt = 0; |
|---|
| 832 | #endif |
|---|
| 833 | for( i = 0; i < 256; i++ ) |
|---|
| 834 | { |
|---|
| 835 | int c = getc( fcpu ); |
|---|
| 836 | |
|---|
| 837 | if( c == EOF ) |
|---|
| 838 | { |
|---|
| 839 | websWrite( wp, "Not Detected!\n" ); |
|---|
| 840 | fclose( fcpu ); |
|---|
| 841 | return; |
|---|
| 842 | } |
|---|
| 843 | if( c == ':' ) |
|---|
| 844 | #ifdef HAVE_MAGICBOX |
|---|
| 845 | cnt++; |
|---|
| 846 | if( cnt == 2 ) |
|---|
| 847 | break; |
|---|
| 848 | #elif HAVE_X86 |
|---|
| 849 | cnt++; |
|---|
| 850 | if( cnt == 5 ) |
|---|
| 851 | break; |
|---|
| 852 | #else |
|---|
| 853 | break; |
|---|
| 854 | #endif |
|---|
| 855 | } |
|---|
| 856 | getc( fcpu ); |
|---|
| 857 | for( i = 0; i < 256; i++ ) |
|---|
| 858 | { |
|---|
| 859 | int c = getc( fcpu ); |
|---|
| 860 | |
|---|
| 861 | if( c == EOF ) |
|---|
| 862 | { |
|---|
| 863 | websWrite( wp, "Not Detected!\n" ); |
|---|
| 864 | fclose( fcpu ); |
|---|
| 865 | return; |
|---|
| 866 | } |
|---|
| 867 | if( c == 0xa || c == 0xd ) |
|---|
| 868 | break; |
|---|
| 869 | buf[i] = c; |
|---|
| 870 | } |
|---|
| 871 | buf[i] = 0; |
|---|
| 872 | websWrite( wp, buf ); |
|---|
| 873 | fclose( fcpu ); |
|---|
| 874 | return; |
|---|
| 875 | } |
|---|
| 876 | |
|---|
| 877 | #define ASSOCLIST_TMP "/tmp/.wl_assoclist" |
|---|
| 878 | #define RSSI_TMP "/tmp/.rssi" |
|---|
| 879 | #define ASSOCLIST_CMD "wl assoclist" |
|---|
| 880 | #define RSSI_CMD "wl rssi" |
|---|
| 881 | #define NOISE_CMD "wl noise" |
|---|
| 882 | |
|---|
| 883 | void ej_show_wds_subnet( webs_t wp, int argc, char_t ** argv ) |
|---|
| 884 | { |
|---|
| 885 | int index = -1; |
|---|
| 886 | char *interface; |
|---|
| 887 | |
|---|
| 888 | #ifdef FASTWEB |
|---|
| 889 | ejArgs( argc, argv, "%d %s", &index, &interface ); |
|---|
| 890 | #else |
|---|
| 891 | if( ejArgs( argc, argv, "%d %s", &index, &interface ) < 2 ) |
|---|
| 892 | { |
|---|
| 893 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 894 | return; |
|---|
| 895 | } |
|---|
| 896 | #endif |
|---|
| 897 | char br1[32]; |
|---|
| 898 | |
|---|
| 899 | sprintf( br1, "%s_br1_enable", interface ); |
|---|
| 900 | if( nvram_invmatch( br1, "1" ) ) |
|---|
| 901 | return; |
|---|
| 902 | char buf[16]; |
|---|
| 903 | |
|---|
| 904 | sprintf( buf, "%s_wds%d_enable", interface, index ); |
|---|
| 905 | websWrite( wp, |
|---|
| 906 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"2\\\" %s >\" + wds.subnet + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 907 | nvram_selmatch( wp, buf, |
|---|
| 908 | "2" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 909 | return; |
|---|
| 910 | } |
|---|
| 911 | |
|---|
| 912 | #ifdef HAVE_SKYTRON |
|---|
| 913 | void ej_active_wireless2( webs_t wp, int argc, char_t ** argv ) |
|---|
| 914 | { |
|---|
| 915 | int rssi = 0, noise = 0; |
|---|
| 916 | FILE *fp, *fp2; |
|---|
| 917 | char *mode; |
|---|
| 918 | char mac[30]; |
|---|
| 919 | char list[2][30]; |
|---|
| 920 | char line[80]; |
|---|
| 921 | |
|---|
| 922 | unlink( ASSOCLIST_TMP ); |
|---|
| 923 | unlink( RSSI_TMP ); |
|---|
| 924 | |
|---|
| 925 | mode = nvram_safe_get( "wl_mode" ); |
|---|
| 926 | sysprintf( "%s > %s", ASSOCLIST_CMD, ASSOCLIST_TMP ); |
|---|
| 927 | |
|---|
| 928 | int connected = 0; |
|---|
| 929 | |
|---|
| 930 | if( ( fp = fopen( ASSOCLIST_TMP, "r" ) ) ) |
|---|
| 931 | { |
|---|
| 932 | while( fgets( line, sizeof( line ), fp ) != NULL ) |
|---|
| 933 | { |
|---|
| 934 | if( sscanf( line, "%s %s", list[0], mac ) != 2 ) // assoclist |
|---|
| 935 | // 00:11:22:33:44:55 |
|---|
| 936 | continue; |
|---|
| 937 | |
|---|
| 938 | if( strcmp( list[0], "assoclist" ) ) |
|---|
| 939 | break; |
|---|
| 940 | |
|---|
| 941 | rssi = 0; |
|---|
| 942 | noise = 0; |
|---|
| 943 | // get rssi value |
|---|
| 944 | if( strcmp( mode, "ap" ) ) |
|---|
| 945 | sysprintf( "%s > %s", RSSI_CMD, RSSI_TMP ); |
|---|
| 946 | else |
|---|
| 947 | sysprintf( "%s \"%s\" > %s", RSSI_CMD, mac, RSSI_TMP ); |
|---|
| 948 | |
|---|
| 949 | // get noise value if not ap mode |
|---|
| 950 | if( strcmp( mode, "ap" ) ) |
|---|
| 951 | sysprintf( "%s >> %s", NOISE_CMD, RSSI_TMP ); |
|---|
| 952 | |
|---|
| 953 | fp2 = fopen( RSSI_TMP, "r" ); |
|---|
| 954 | if( fgets( line, sizeof( line ), fp2 ) != NULL ) |
|---|
| 955 | { |
|---|
| 956 | |
|---|
| 957 | // get rssi |
|---|
| 958 | if( sscanf( line, "%s %s %d", list[0], list[1], &rssi ) != 3 ) |
|---|
| 959 | continue; |
|---|
| 960 | |
|---|
| 961 | // get noise for client/wet mode |
|---|
| 962 | if( strcmp( mode, "ap" ) && |
|---|
| 963 | fgets( line, sizeof( line ), fp2 ) != NULL && |
|---|
| 964 | sscanf( line, "%s %s %d", list[0], list[1], |
|---|
| 965 | &noise ) != 3 ) |
|---|
| 966 | continue; |
|---|
| 967 | |
|---|
| 968 | fclose( fp2 ); |
|---|
| 969 | } |
|---|
| 970 | if( nvram_match( "maskmac", "1" ) ) |
|---|
| 971 | { |
|---|
| 972 | mac[0] = 'x'; |
|---|
| 973 | mac[1] = 'x'; |
|---|
| 974 | mac[3] = 'x'; |
|---|
| 975 | mac[4] = 'x'; |
|---|
| 976 | mac[6] = 'x'; |
|---|
| 977 | mac[7] = 'x'; |
|---|
| 978 | mac[9] = 'x'; |
|---|
| 979 | mac[10] = 'x'; |
|---|
| 980 | } |
|---|
| 981 | if( strcmp( mode, "ap" ) != 0 ) |
|---|
| 982 | { |
|---|
| 983 | connected = 1; |
|---|
| 984 | websWrite( wp, "<tr>\n" ); |
|---|
| 985 | websWrite( wp, |
|---|
| 986 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\"><b>Verbindungsstatus</b></font></td>\n" ); |
|---|
| 987 | websWrite( wp, "<td bgcolor=\"#B2B2B2\"></td>\n" ); |
|---|
| 988 | websWrite( wp, "<td bgcolor=\"#FFFFFF\"></td>\n" ); |
|---|
| 989 | websWrite( wp, |
|---|
| 990 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Verbunden</font></td>\n" ); |
|---|
| 991 | websWrite( wp, "</tr>\n" ); |
|---|
| 992 | websWrite( wp, "<tr>\n" ); |
|---|
| 993 | websWrite( wp, |
|---|
| 994 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Signal</font></td>\n" ); |
|---|
| 995 | websWrite( wp, "<td bgcolor=\"#B2B2B2\"></td>\n" ); |
|---|
| 996 | websWrite( wp, "<td bgcolor=\"#FFFFFF\"></td>\n" ); |
|---|
| 997 | websWrite( wp, |
|---|
| 998 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">%d dBm</font></td>\n", |
|---|
| 999 | rssi ); |
|---|
| 1000 | websWrite( wp, "</tr>\n" ); |
|---|
| 1001 | websWrite( wp, "<tr>\n" ); |
|---|
| 1002 | websWrite( wp, |
|---|
| 1003 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Rauschen</font></td>\n" ); |
|---|
| 1004 | websWrite( wp, "<td bgcolor=\"#B2B2B2\"></td>\n" ); |
|---|
| 1005 | websWrite( wp, "<td bgcolor=\"#FFFFFF\"></td>\n" ); |
|---|
| 1006 | websWrite( wp, |
|---|
| 1007 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">%d dBm</font></td>\n", |
|---|
| 1008 | noise ); |
|---|
| 1009 | websWrite( wp, "</tr>\n" ); |
|---|
| 1010 | } |
|---|
| 1011 | } |
|---|
| 1012 | fclose( fp ); |
|---|
| 1013 | } |
|---|
| 1014 | |
|---|
| 1015 | unlink( ASSOCLIST_TMP ); |
|---|
| 1016 | unlink( RSSI_TMP ); |
|---|
| 1017 | if( !connected ) |
|---|
| 1018 | { |
|---|
| 1019 | connected = 1; |
|---|
| 1020 | websWrite( wp, "<tr>\n" ); |
|---|
| 1021 | websWrite( wp, |
|---|
| 1022 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\"><b>Verbindungsstatus</b></font></td>\n" ); |
|---|
| 1023 | websWrite( wp, "<td bgcolor=\"#B2B2B2\"></td>\n" ); |
|---|
| 1024 | websWrite( wp, "<td bgcolor=\"#FFFFFF\"></td>\n" ); |
|---|
| 1025 | websWrite( wp, |
|---|
| 1026 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Nicht Verbunden</font></td>\n" ); |
|---|
| 1027 | websWrite( wp, "</tr>\n" ); |
|---|
| 1028 | |
|---|
| 1029 | } |
|---|
| 1030 | |
|---|
| 1031 | return 0; |
|---|
| 1032 | } |
|---|
| 1033 | #endif |
|---|
| 1034 | |
|---|
| 1035 | void ej_show_paypal( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1036 | { |
|---|
| 1037 | #ifdef HAVE_DDLAN |
|---|
| 1038 | websWrite( wp, |
|---|
| 1039 | "<a href=\"mailto:support@mcdd.de\">support@mcdd.de</a><br />" ); |
|---|
| 1040 | #endif |
|---|
| 1041 | |
|---|
| 1042 | #ifndef CONFIG_BRANDING |
|---|
| 1043 | websWrite( wp, "<a href=\"http://www.dd-wrt.com/\">DD-WRT</a><br />" ); |
|---|
| 1044 | websWrite( wp, |
|---|
| 1045 | "<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\" target=\"_blank\">" ); |
|---|
| 1046 | websWrite( wp, |
|---|
| 1047 | "<input type=\"hidden\" name=\"cmd\" value=\"_xclick\" />" ); |
|---|
| 1048 | websWrite( wp, |
|---|
| 1049 | "<input type=\"hidden\" name=\"business\" value=\"paypal@dd-wrt.com\" />" ); |
|---|
| 1050 | websWrite( wp, |
|---|
| 1051 | "<input type=\"hidden\" name=\"item_name\" value=\"DD-WRT Development Support\" />" ); |
|---|
| 1052 | websWrite( wp, "<input type=\"hidden\" name=\"no_note\" value=\"1\" />" ); |
|---|
| 1053 | websWrite( wp, |
|---|
| 1054 | "<input type=\"hidden\" name=\"currency_code\" value=\"EUR\" />" ); |
|---|
| 1055 | websWrite( wp, "<input type=\"hidden\" name=\"lc\" value=\"en\" />" ); |
|---|
| 1056 | websWrite( wp, "<input type=\"hidden\" name=\"tax\" value=\"0\" />" ); |
|---|
| 1057 | websWrite( wp, |
|---|
| 1058 | "<input type=\"image\" src=\"images/paypal.gif\" name=\"submit\" />" ); |
|---|
| 1059 | websWrite( wp, "</form>" ); |
|---|
| 1060 | websWrite( wp, |
|---|
| 1061 | "<br /><script type=\"text/javascript\">Capture(donate.mb)</script><br />\n" ); |
|---|
| 1062 | websWrite( wp, |
|---|
| 1063 | "<a href=\"https://www.moneybookers.com/app/send.pl\" target=\"_blank\">\n" ); |
|---|
| 1064 | // #ifdef HAVE_MICRO |
|---|
| 1065 | // websWrite (wp, |
|---|
| 1066 | // "<img style=\"border-width: 1px; border-color: #8B8583;\" |
|---|
| 1067 | // src=\"http://www.moneybookers.com/images/banners/88_en_interpayments.gif\" |
|---|
| 1068 | // alt=\"donate thru moneybookers\" />\n"); |
|---|
| 1069 | // #else |
|---|
| 1070 | websWrite( wp, |
|---|
| 1071 | "<img style=\"border-width: 1px; border-color: #8B8583;\" src=\"images/88_en_interpayments.png\" alt=\"donate thru interpayments\" />\n" ); |
|---|
| 1072 | // #endif |
|---|
| 1073 | websWrite( wp, "</a>\n" ); |
|---|
| 1074 | #endif |
|---|
| 1075 | return; |
|---|
| 1076 | } |
|---|
| 1077 | |
|---|
| 1078 | #ifdef HAVE_RADLOCAL |
|---|
| 1079 | |
|---|
| 1080 | void ej_show_iradius_check( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1081 | { |
|---|
| 1082 | char *sln = nvram_safe_get( "iradius_count" ); |
|---|
| 1083 | |
|---|
| 1084 | if( sln == NULL || strlen( sln ) == 0 ) |
|---|
| 1085 | return; |
|---|
| 1086 | int leasenum = atoi( sln ); |
|---|
| 1087 | int i; |
|---|
| 1088 | |
|---|
| 1089 | for( i = 0; i < leasenum; i++ ) |
|---|
| 1090 | { |
|---|
| 1091 | websWrite( wp, "if(F._iradius%d_active)\n", i ); |
|---|
| 1092 | websWrite( wp, "if(F._iradius%d_active.checked == true)\n", i ); |
|---|
| 1093 | websWrite( wp, "F.iradius%d_active.value=1\n", i ); |
|---|
| 1094 | websWrite( wp, "else\n" ); |
|---|
| 1095 | websWrite( wp, "F.iradius%d_active.value=0\n", i ); |
|---|
| 1096 | |
|---|
| 1097 | websWrite( wp, "if(F._iradius%d_delete)\n", i ); |
|---|
| 1098 | websWrite( wp, "if(F._iradius%d_delete.checked == true)\n", i ); |
|---|
| 1099 | websWrite( wp, "F.iradius%d_delete.value=1\n", i ); |
|---|
| 1100 | websWrite( wp, "else\n" ); |
|---|
| 1101 | websWrite( wp, "F.iradius%d_delete.value=0\n", i ); |
|---|
| 1102 | } |
|---|
| 1103 | |
|---|
| 1104 | } |
|---|
| 1105 | void ej_show_iradius( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1106 | { |
|---|
| 1107 | char *sln = nvram_safe_get( "iradius_count" ); |
|---|
| 1108 | |
|---|
| 1109 | if( sln == NULL || strlen( sln ) == 0 ) |
|---|
| 1110 | return; |
|---|
| 1111 | int leasenum = atoi( sln ); |
|---|
| 1112 | |
|---|
| 1113 | if( leasenum == 0 ) |
|---|
| 1114 | return; |
|---|
| 1115 | int i; |
|---|
| 1116 | char username[32]; |
|---|
| 1117 | char *o, *userlist; |
|---|
| 1118 | |
|---|
| 1119 | cprintf( "get collection\n" ); |
|---|
| 1120 | char *u = nvram_get_collection( "iradius" ); |
|---|
| 1121 | |
|---|
| 1122 | cprintf( "collection result %s", u ); |
|---|
| 1123 | if( u != NULL ) |
|---|
| 1124 | { |
|---|
| 1125 | userlist = ( char * )malloc( strlen( u ) + 1 ); |
|---|
| 1126 | strcpy( userlist, u ); |
|---|
| 1127 | free( u ); |
|---|
| 1128 | o = userlist; |
|---|
| 1129 | } |
|---|
| 1130 | else |
|---|
| 1131 | { |
|---|
| 1132 | userlist = NULL; |
|---|
| 1133 | o = NULL; |
|---|
| 1134 | } |
|---|
| 1135 | cprintf( "display = chain\n" ); |
|---|
| 1136 | struct timeval now; |
|---|
| 1137 | |
|---|
| 1138 | gettimeofday( &now, NULL ); |
|---|
| 1139 | for( i = 0; i < leasenum; i++ ) |
|---|
| 1140 | { |
|---|
| 1141 | snprintf( username, 31, "iradius%d_name", i ); |
|---|
| 1142 | char *sep = NULL; |
|---|
| 1143 | |
|---|
| 1144 | if( userlist ) |
|---|
| 1145 | sep = strsep( &userlist, " " ); |
|---|
| 1146 | websWrite( wp, "<tr><td>\n" ); |
|---|
| 1147 | websWrite( wp, "<input name=\"%s\" type=\"hidden\" />", username ); |
|---|
| 1148 | websWrite( wp, |
|---|
| 1149 | "<input name=\"%s\" value=\"%s\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 1150 | username, sep != NULL ? sep : "" ); |
|---|
| 1151 | websWrite( wp, "</td>\n" ); |
|---|
| 1152 | if( userlist ) |
|---|
| 1153 | sep = strsep( &userlist, " " ); |
|---|
| 1154 | |
|---|
| 1155 | char active[32]; |
|---|
| 1156 | |
|---|
| 1157 | snprintf( active, 31, "iradius%d_active", i ); |
|---|
| 1158 | |
|---|
| 1159 | websWrite( wp, "<td>\n" ); |
|---|
| 1160 | websWrite( wp, "<input name=\"%s\" type=\"hidden\" />", active ); |
|---|
| 1161 | websWrite( wp, |
|---|
| 1162 | "<input type=\"checkbox\" value=\"%s\" name=\"_%s\" %s />\n", |
|---|
| 1163 | sep, active, sep != NULL ? strcmp( sep, |
|---|
| 1164 | "1" ) == |
|---|
| 1165 | 0 ? "checked=\"checked\"" : "" : "" ); |
|---|
| 1166 | websWrite( wp, "</td>\n" ); |
|---|
| 1167 | websWrite( wp, "<td>\n" ); |
|---|
| 1168 | if( userlist ) |
|---|
| 1169 | sep = strsep( &userlist, " " ); |
|---|
| 1170 | long t = atol( sep ); |
|---|
| 1171 | |
|---|
| 1172 | if( t != -1 ) |
|---|
| 1173 | { |
|---|
| 1174 | t -= now.tv_sec; |
|---|
| 1175 | t /= 60; |
|---|
| 1176 | } |
|---|
| 1177 | |
|---|
| 1178 | snprintf( active, 31, "iradius%d_lease", i ); |
|---|
| 1179 | char st[32]; |
|---|
| 1180 | |
|---|
| 1181 | if( t >= 0 ) |
|---|
| 1182 | sprintf( st, "%d", t ); |
|---|
| 1183 | else |
|---|
| 1184 | sprintf( st, "over" ); |
|---|
| 1185 | websWrite( wp, "<input type=\"num\" name=\"%s\" value='%s' />\n", |
|---|
| 1186 | active, st ); |
|---|
| 1187 | websWrite( wp, "</td>\n" ); |
|---|
| 1188 | |
|---|
| 1189 | websWrite( wp, "<td>\n" ); |
|---|
| 1190 | snprintf( active, 31, "iradius%d_delete", i ); |
|---|
| 1191 | websWrite( wp, "<input name=\"%s\" type=\"hidden\" />", active ); |
|---|
| 1192 | websWrite( wp, "<input type=\"checkbox\" name=\"_%s\"/>\n", active ); |
|---|
| 1193 | websWrite( wp, "</td></tr>\n" ); |
|---|
| 1194 | } |
|---|
| 1195 | if( o != NULL ) |
|---|
| 1196 | free( o ); |
|---|
| 1197 | return; |
|---|
| 1198 | } |
|---|
| 1199 | |
|---|
| 1200 | #endif |
|---|
| 1201 | |
|---|
| 1202 | #ifdef HAVE_CHILLILOCAL |
|---|
| 1203 | |
|---|
| 1204 | void ej_show_userlist( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1205 | { |
|---|
| 1206 | char *sln = nvram_safe_get( "fon_usernames" ); |
|---|
| 1207 | |
|---|
| 1208 | if( sln == NULL || strlen( sln ) == 0 ) |
|---|
| 1209 | return; |
|---|
| 1210 | int leasenum = atoi( sln ); |
|---|
| 1211 | |
|---|
| 1212 | if( leasenum == 0 ) |
|---|
| 1213 | return; |
|---|
| 1214 | int i; |
|---|
| 1215 | char username[32]; |
|---|
| 1216 | char password[32]; |
|---|
| 1217 | char *u = nvram_safe_get( "fon_userlist" ); |
|---|
| 1218 | char *userlist = ( char * )malloc( strlen( u ) + 1 ); |
|---|
| 1219 | |
|---|
| 1220 | strcpy( userlist, u ); |
|---|
| 1221 | char *o = userlist; |
|---|
| 1222 | |
|---|
| 1223 | for( i = 0; i < leasenum; i++ ) |
|---|
| 1224 | { |
|---|
| 1225 | snprintf( username, 31, "fon_user%d_name", i ); |
|---|
| 1226 | char *sep = strsep( &userlist, "=" ); |
|---|
| 1227 | |
|---|
| 1228 | websWrite( wp, "<tr><td>\n" ); |
|---|
| 1229 | websWrite( wp, |
|---|
| 1230 | "<input name=\"%s\" value=\"%s\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 1231 | username, sep != NULL ? sep : "" ); |
|---|
| 1232 | websWrite( wp, "</td>\n" ); |
|---|
| 1233 | sep = strsep( &userlist, " " ); |
|---|
| 1234 | snprintf( password, 31, "fon_user%d_password", i ); |
|---|
| 1235 | websWrite( wp, "<td>\n" ); |
|---|
| 1236 | websWrite( wp, |
|---|
| 1237 | "<input type=\"password\" name=\"%s\" value=\"blahblahblah\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 1238 | password ); |
|---|
| 1239 | websWrite( wp, "</td></tr>\n" ); |
|---|
| 1240 | } |
|---|
| 1241 | free( o ); |
|---|
| 1242 | return; |
|---|
| 1243 | } |
|---|
| 1244 | |
|---|
| 1245 | #endif |
|---|
| 1246 | |
|---|
| 1247 | void ej_show_staticleases( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1248 | { |
|---|
| 1249 | int i; |
|---|
| 1250 | |
|---|
| 1251 | // cprintf("get static leasenum"); |
|---|
| 1252 | |
|---|
| 1253 | char *sln = nvram_safe_get( "static_leasenum" ); |
|---|
| 1254 | |
|---|
| 1255 | // cprintf("check null"); |
|---|
| 1256 | if( sln == NULL || strlen( sln ) == 0 ) |
|---|
| 1257 | return; |
|---|
| 1258 | // cprintf("atoi"); |
|---|
| 1259 | |
|---|
| 1260 | int leasenum = atoi( sln ); |
|---|
| 1261 | |
|---|
| 1262 | // cprintf("leasenum==0"); |
|---|
| 1263 | if( leasenum == 0 ) |
|---|
| 1264 | return; |
|---|
| 1265 | // cprintf("get leases"); |
|---|
| 1266 | char *nvleases = nvram_safe_get( "static_leases" ); |
|---|
| 1267 | char *leases = ( char * )malloc( strlen( nvleases ) + 1 ); |
|---|
| 1268 | char *originalpointer = leases; // strsep destroys the pointer by |
|---|
| 1269 | |
|---|
| 1270 | // moving it |
|---|
| 1271 | strcpy( leases, nvleases ); |
|---|
| 1272 | for( i = 0; i < leasenum; i++ ) |
|---|
| 1273 | { |
|---|
| 1274 | char *sep = strsep( &leases, "=" ); |
|---|
| 1275 | |
|---|
| 1276 | websWrite( wp, |
|---|
| 1277 | "<tr><td><input name=\"lease%d_hwaddr\" value=\"%s\" size=\"18\" maxlength=\"18\" onblur=\"valid_name(this,share.mac,SPACE_NO)\" /></td>", |
|---|
| 1278 | i, sep != NULL ? sep : "" ); |
|---|
| 1279 | sep = strsep( &leases, "=" ); |
|---|
| 1280 | websWrite( wp, |
|---|
| 1281 | "<td><input name=\"lease%d_hostname\" value=\"%s\" size=\"24\" maxlength=\"24\" onblur=\"valid_name(this,share.hostname,SPACE_NO)\" /></td>", |
|---|
| 1282 | i, sep != NULL ? sep : "" ); |
|---|
| 1283 | sep = strsep( &leases, " " ); |
|---|
| 1284 | websWrite( wp, |
|---|
| 1285 | "<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", |
|---|
| 1286 | i, sep != NULL ? sep : "" ); |
|---|
| 1287 | } |
|---|
| 1288 | free( originalpointer ); |
|---|
| 1289 | return; |
|---|
| 1290 | } |
|---|
| 1291 | |
|---|
| 1292 | void ej_show_control( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1293 | { |
|---|
| 1294 | #ifdef CONFIG_BRANDING |
|---|
| 1295 | websWrite( wp, "Control Panel" ); |
|---|
| 1296 | #else |
|---|
| 1297 | websWrite( wp, "DD-WRT Control Panel" ); |
|---|
| 1298 | #endif |
|---|
| 1299 | return; |
|---|
| 1300 | } |
|---|
| 1301 | |
|---|
| 1302 | #ifndef HAVE_AQOS |
|---|
| 1303 | void ej_show_default_level( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1304 | { |
|---|
| 1305 | return; |
|---|
| 1306 | } |
|---|
| 1307 | |
|---|
| 1308 | #else |
|---|
| 1309 | void ej_show_default_level( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1310 | { |
|---|
| 1311 | websWrite( wp, "<fieldset>\n" ); |
|---|
| 1312 | websWrite( wp, |
|---|
| 1313 | "<legend><script type=\"text/javascript\">Capture(qos.legend6)</script></legend>\n" ); |
|---|
| 1314 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1315 | websWrite( wp, |
|---|
| 1316 | "<div class=\"label\"><script type=\"text/javascript\">Capture(qos.bandwidth)</script> Up</div>\n" ); |
|---|
| 1317 | websWrite( wp, |
|---|
| 1318 | "<input type=\"num\" name=\"default_uplevel\" size=\"6\" value=\"%s\" /> Down\n", |
|---|
| 1319 | nvram_safe_get( "default_uplevel" ) ); |
|---|
| 1320 | websWrite( wp, |
|---|
| 1321 | "<input type=\"num\" name=\"default_downlevel\" size=\"6\" value=\"%s\" />\n", |
|---|
| 1322 | nvram_safe_get( "default_downlevel" ) ); |
|---|
| 1323 | websWrite( wp, "</div>\n" ); |
|---|
| 1324 | websWrite( wp, "</fieldset><br />\n" ); |
|---|
| 1325 | return; |
|---|
| 1326 | } |
|---|
| 1327 | #endif |
|---|
| 1328 | |
|---|
| 1329 | #ifndef HAVE_MSSID |
|---|
| 1330 | |
|---|
| 1331 | char *selmatch( char *var, char *is, char *ret ) |
|---|
| 1332 | { |
|---|
| 1333 | if( nvram_match( var, is ) ) |
|---|
| 1334 | return ret; |
|---|
| 1335 | return ""; |
|---|
| 1336 | } |
|---|
| 1337 | |
|---|
| 1338 | void ej_show_security( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1339 | { |
|---|
| 1340 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1341 | websWrite( wp, |
|---|
| 1342 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.secmode)</script></div>\n" ); |
|---|
| 1343 | websWrite( wp, |
|---|
| 1344 | "<select name=\"security_mode\" onchange=\"SelMode('security_mode',this.form.security_mode.selectedIndex,this.form)\">\n" ); |
|---|
| 1345 | websWrite( wp, |
|---|
| 1346 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"disabled\\\" %s >\" + share.disabled + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 1347 | selmatch( "security_mode", "disabled", |
|---|
| 1348 | "selected=\\\"selected\\\"" ) ); |
|---|
| 1349 | websWrite( wp, "<option value=\"psk\" %s>WPA Personal</option>\n", |
|---|
| 1350 | selmatch( "security_mode", "psk", "selected=\"selected\"" ) ); |
|---|
| 1351 | websWrite( wp, "<option value=\"wpa\" %s>WPA Enterprise</option>\n", |
|---|
| 1352 | selmatch( "security_mode", "wpa", "selected=\"selected\"" ) ); |
|---|
| 1353 | if( !nvram_match( "wl0_mode", "wet" ) && nvram_match( "wl_wds1_enable", "0" ) && nvram_match( "wl_wds2_enable", "0" ) && nvram_match( "wl_wds3_enable", "0" ) && nvram_match( "wl_wds4_enable", "0" ) && nvram_match( "wl_wds5_enable", "0" ) && nvram_match( "wl_wds6_enable", "0" ) && nvram_match( "wl_wds7_enable", "0" ) && nvram_match( "wl_wds8_enable", "0" ) && nvram_match( "wl_wds9_enable", "0" ) && nvram_match( "wl_wds10_enable", "0" ) ) // botho |
|---|
| 1354 | // 10/04/06 |
|---|
| 1355 | // : |
|---|
| 1356 | // if |
|---|
| 1357 | // wireless |
|---|
| 1358 | // client |
|---|
| 1359 | // bridge |
|---|
| 1360 | // mode |
|---|
| 1361 | // selected |
|---|
| 1362 | // or |
|---|
| 1363 | // WDS |
|---|
| 1364 | // activated |
|---|
| 1365 | // => |
|---|
| 1366 | // we |
|---|
| 1367 | // don't |
|---|
| 1368 | // display |
|---|
| 1369 | // WPA2 |
|---|
| 1370 | // security |
|---|
| 1371 | // modes |
|---|
| 1372 | { |
|---|
| 1373 | websWrite( wp, |
|---|
| 1374 | "<option value=\"psk2\" %s>WPA2 Personal</option>\n", |
|---|
| 1375 | selmatch( "security_mode", "psk2", "selected" ) ); |
|---|
| 1376 | websWrite( wp, "<option value=\"wpa2\" %s>WPA2 Enterprise</option>\n", |
|---|
| 1377 | selmatch( "security_mode", "wpa2", |
|---|
| 1378 | "selected=\"selected\"" ) ); |
|---|
| 1379 | } |
|---|
| 1380 | websWrite( wp, |
|---|
| 1381 | "<option value=\"psk psk2\" %s>WPA2 Personal Mixed</option>\n", |
|---|
| 1382 | selmatch( "security_mode", "psk psk2", "selected" ) ); |
|---|
| 1383 | websWrite( wp, |
|---|
| 1384 | "<option value=\"wpa wpa2\" %s>WPA2 Enterprise Mixed</option>\n", |
|---|
| 1385 | selmatch( "security_mode", "wpa wpa2", |
|---|
| 1386 | "selected=\"selected\"" ) ); |
|---|
| 1387 | websWrite( wp, "<option value=\"radius\" %s>RADIUS</option>\n", |
|---|
| 1388 | selmatch( "security_mode", "radius", |
|---|
| 1389 | "selected=\"selected\"" ) ); |
|---|
| 1390 | websWrite( wp, "<option value=\"wep\" %s>WEP</option></select>\n", |
|---|
| 1391 | selmatch( "security_mode", "wep", "selected=\"selected\"" ) ); |
|---|
| 1392 | websWrite( wp, "</div>\n" ); |
|---|
| 1393 | ej_show_wpa_setting( wp, argc, argv ); |
|---|
| 1394 | return; |
|---|
| 1395 | } |
|---|
| 1396 | #else |
|---|
| 1397 | #ifdef HAVE_MADWIFI |
|---|
| 1398 | struct wifi_channels |
|---|
| 1399 | { |
|---|
| 1400 | int channel; |
|---|
| 1401 | int freq; |
|---|
| 1402 | int noise}; |
|---|
| 1403 | extern struct wifi_channels *list_channels( char *devnr ); |
|---|
| 1404 | |
|---|
| 1405 | // extern int getchannelcount (void); |
|---|
| 1406 | extern int getdevicecount( void ); |
|---|
| 1407 | #endif |
|---|
| 1408 | |
|---|
| 1409 | char *selmatch( char *var, char *is, char *ret ) |
|---|
| 1410 | { |
|---|
| 1411 | if( nvram_match( var, is ) ) |
|---|
| 1412 | return ret; |
|---|
| 1413 | return ""; |
|---|
| 1414 | } |
|---|
| 1415 | |
|---|
| 1416 | static void |
|---|
| 1417 | show_security_prefix( webs_t wp, int argc, char_t ** argv, char *prefix, |
|---|
| 1418 | int primary ) |
|---|
| 1419 | { |
|---|
| 1420 | char var[80]; |
|---|
| 1421 | char sta[80]; |
|---|
| 1422 | |
|---|
| 1423 | // char p2[80]; |
|---|
| 1424 | cprintf( "show security prefix\n" ); |
|---|
| 1425 | sprintf( var, "%s_security_mode", prefix ); |
|---|
| 1426 | // strcpy(p2,prefix); |
|---|
| 1427 | // rep(p2,'X','.'); |
|---|
| 1428 | // websWrite (wp, "<input type=\"hidden\" |
|---|
| 1429 | // name=\"%s_security_mode\"/>\n",p2); |
|---|
| 1430 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1431 | websWrite( wp, |
|---|
| 1432 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.secmode)</script></div>\n" ); |
|---|
| 1433 | websWrite( wp, |
|---|
| 1434 | "<select name=\"%s_security_mode\" onchange=\"SelMode('%s_security_mode',this.form.%s_security_mode.selectedIndex,this.form)\">\n", |
|---|
| 1435 | prefix, prefix, prefix ); |
|---|
| 1436 | websWrite( wp, |
|---|
| 1437 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"disabled\\\" %s >\" + share.disabled + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 1438 | selmatch( var, "disabled", "selected=\\\"selected\\\"" ) ); |
|---|
| 1439 | websWrite( wp, "<option value=\"psk\" %s>WPA Personal</option>\n", |
|---|
| 1440 | selmatch( var, "psk", "selected=\"selected\"" ) ); |
|---|
| 1441 | sprintf( sta, "%s_mode", prefix ); |
|---|
| 1442 | if( !primary || nvram_match( sta, "ap" ) || nvram_match( sta, "wdsap" ) ) |
|---|
| 1443 | { |
|---|
| 1444 | websWrite( wp, "<option value=\"wpa\" %s>WPA Enterprise</option>\n", |
|---|
| 1445 | selmatch( var, "wpa", "selected=\"selected\"" ) ); |
|---|
| 1446 | } |
|---|
| 1447 | websWrite( wp, |
|---|
| 1448 | "<option value=\"psk2\" %s>WPA2 Personal</option>\n", |
|---|
| 1449 | selmatch( var, "psk2", "selected=\"selected\"" ) ); |
|---|
| 1450 | if( !primary || nvram_match( sta, "ap" ) || nvram_match( sta, "wdsap" ) ) |
|---|
| 1451 | { |
|---|
| 1452 | websWrite( wp, "<option value=\"wpa2\" %s>WPA2 Enterprise</option>\n", |
|---|
| 1453 | selmatch( var, "wpa2", "selected=\"selected\"" ) ); |
|---|
| 1454 | } |
|---|
| 1455 | websWrite( wp, |
|---|
| 1456 | "<option value=\"psk psk2\" %s>WPA2 Personal Mixed</option>\n", |
|---|
| 1457 | selmatch( var, "psk psk2", "selected=\"selected\"" ) ); |
|---|
| 1458 | if( !primary || nvram_match( sta, "ap" ) || nvram_match( sta, "wdsap" ) ) |
|---|
| 1459 | { |
|---|
| 1460 | websWrite( wp, |
|---|
| 1461 | "<option value=\"wpa wpa2\" %s>WPA2 Enterprise Mixed</option>\n", |
|---|
| 1462 | selmatch( var, "wpa wpa2", "selected=\"selected\"" ) ); |
|---|
| 1463 | |
|---|
| 1464 | websWrite( wp, "<option value=\"radius\" %s>RADIUS</option>\n", |
|---|
| 1465 | selmatch( var, "radius", "selected=\"selected\"" ) ); |
|---|
| 1466 | } |
|---|
| 1467 | |
|---|
| 1468 | websWrite( wp, "<option value=\"wep\" %s>WEP</option>\n", |
|---|
| 1469 | selmatch( var, "wep", "selected=\"selected\"" ) ); |
|---|
| 1470 | #ifdef HAVE_WPA_SUPPLICANT |
|---|
| 1471 | #ifndef HAVE_MICRO |
|---|
| 1472 | if( !primary || nvram_match( sta, "sta" ) || nvram_match( sta, "wdssta" ) |
|---|
| 1473 | || nvram_match( sta, "apsta" ) || nvram_match( sta, "wet" ) ) |
|---|
| 1474 | { |
|---|
| 1475 | websWrite( wp, "<option value=\"8021X\" %s>802.1x</option>\n", |
|---|
| 1476 | selmatch( var, "8021X", "selected=\"selected\"" ) ); |
|---|
| 1477 | } |
|---|
| 1478 | #endif |
|---|
| 1479 | #endif |
|---|
| 1480 | |
|---|
| 1481 | websWrite( wp, "</select></div>\n" ); |
|---|
| 1482 | rep( prefix, 'X', '.' ); |
|---|
| 1483 | cprintf( "ej show wpa\n" ); |
|---|
| 1484 | ej_show_wpa_setting( wp, argc, argv, prefix ); |
|---|
| 1485 | |
|---|
| 1486 | } |
|---|
| 1487 | |
|---|
| 1488 | static void |
|---|
| 1489 | ej_show_security_single( webs_t wp, int argc, char_t ** argv, char *prefix ) |
|---|
| 1490 | { |
|---|
| 1491 | char *next; |
|---|
| 1492 | char var[80]; |
|---|
| 1493 | char ssid[80]; |
|---|
| 1494 | char mac[16]; |
|---|
| 1495 | |
|---|
| 1496 | sprintf( mac, "%s_hwaddr", prefix ); |
|---|
| 1497 | char *vifs = nvram_nget( "%s_vifs", prefix ); |
|---|
| 1498 | |
|---|
| 1499 | if( vifs == NULL ) |
|---|
| 1500 | return; |
|---|
| 1501 | sprintf( ssid, "%s_ssid", prefix ); |
|---|
| 1502 | websWrite( wp, |
|---|
| 1503 | "<h2><script type=\"text/javascript\">Capture(wpa.h2)</script> %s</h2>\n", |
|---|
| 1504 | prefix ); |
|---|
| 1505 | websWrite( wp, "<fieldset>\n" ); |
|---|
| 1506 | // cprintf("getting %s %s\n",ssid,nvram_safe_get(ssid)); |
|---|
| 1507 | websWrite( wp, |
|---|
| 1508 | "<legend><script type=\"text/javascript\">Capture(share.pintrface)</script> %s SSID [", |
|---|
| 1509 | prefix ); |
|---|
| 1510 | tf_webWriteESCNV( wp, ssid ); // fix for broken html page if ssid |
|---|
| 1511 | // contains html tag |
|---|
| 1512 | websWrite( wp, "] HWAddr [%s]</legend>\n", nvram_safe_get( mac ) ); |
|---|
| 1513 | show_security_prefix( wp, argc, argv, prefix, 1 ); |
|---|
| 1514 | websWrite( wp, "</fieldset>\n<br />\n" ); |
|---|
| 1515 | foreach( var, vifs, next ) |
|---|
| 1516 | { |
|---|
| 1517 | sprintf( ssid, "%s_ssid", var ); |
|---|
| 1518 | websWrite( wp, "<fieldset>\n" ); |
|---|
| 1519 | // cprintf("getting %s %s\n", ssid,nvram_safe_get(ssid)); |
|---|
| 1520 | websWrite( wp, |
|---|
| 1521 | "<legend><script type=\"text/javascript\">Capture(share.vintrface)</script> %s SSID [", |
|---|
| 1522 | var ); |
|---|
| 1523 | tf_webWriteESCNV( wp, ssid ); // fix for broken html page if ssid |
|---|
| 1524 | // contains html tag |
|---|
| 1525 | websWrite( wp, "]</legend>\n" ); |
|---|
| 1526 | rep( var, '.', 'X' ); |
|---|
| 1527 | show_security_prefix( wp, argc, argv, var, 0 ); |
|---|
| 1528 | websWrite( wp, "</fieldset>\n<br />\n" ); |
|---|
| 1529 | } |
|---|
| 1530 | |
|---|
| 1531 | } |
|---|
| 1532 | |
|---|
| 1533 | void ej_show_security( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1534 | { |
|---|
| 1535 | #ifndef HAVE_MADWIFI |
|---|
| 1536 | int c = get_wl_instances( ); |
|---|
| 1537 | int i; |
|---|
| 1538 | |
|---|
| 1539 | for( i = 0; i < c; i++ ) |
|---|
| 1540 | { |
|---|
| 1541 | char buf[16]; |
|---|
| 1542 | |
|---|
| 1543 | sprintf( buf, "wl%d", i ); |
|---|
| 1544 | ej_show_security_single( wp, argc, argv, buf ); |
|---|
| 1545 | } |
|---|
| 1546 | return; |
|---|
| 1547 | #else |
|---|
| 1548 | int c = getdevicecount( ); |
|---|
| 1549 | int i; |
|---|
| 1550 | |
|---|
| 1551 | for( i = 0; i < c; i++ ) |
|---|
| 1552 | { |
|---|
| 1553 | char buf[16]; |
|---|
| 1554 | |
|---|
| 1555 | sprintf( buf, "ath%d", i ); |
|---|
| 1556 | ej_show_security_single( wp, argc, argv, buf ); |
|---|
| 1557 | } |
|---|
| 1558 | return; |
|---|
| 1559 | #endif |
|---|
| 1560 | } |
|---|
| 1561 | |
|---|
| 1562 | #endif |
|---|
| 1563 | |
|---|
| 1564 | void ej_show_dhcpd_settings( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1565 | { |
|---|
| 1566 | int i; |
|---|
| 1567 | |
|---|
| 1568 | if( nvram_match( "wl0_mode", "wet" ) ) // dhcpd settings disabled in |
|---|
| 1569 | // client bridge mode, so we |
|---|
| 1570 | // wont display it |
|---|
| 1571 | return; |
|---|
| 1572 | if( nvram_match( "wl0_mode", "apstawet" ) ) // dhcpd settings disabled in |
|---|
| 1573 | // client bridge mode, so we |
|---|
| 1574 | // wont display it |
|---|
| 1575 | return; |
|---|
| 1576 | websWrite( wp, |
|---|
| 1577 | "<fieldset><legend><script type=\"text/javascript\">Capture(idx.dhcp_legend)</script></legend>\n" ); |
|---|
| 1578 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1579 | websWrite( wp, |
|---|
| 1580 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_type)</script></div>\n" ); |
|---|
| 1581 | websWrite( wp, |
|---|
| 1582 | "<select class=\"num\" size=\"1\" name=\"dhcpfwd_enable\" onchange=SelDHCPFWD(this.form.dhcpfwd_enable.selectedIndex,this.form)>\n" ); |
|---|
| 1583 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 1584 | websWrite( wp, |
|---|
| 1585 | "document.write(\"<option value=\\\"0\\\" %s >\" + idx.dhcp_srv + \"</option>\");\n", |
|---|
| 1586 | nvram_match( "dhcpfwd_enable", |
|---|
| 1587 | "0" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 1588 | websWrite( wp, |
|---|
| 1589 | "document.write(\"<option value=\\\"1\\\" %s >\" + idx.dhcp_fwd + \"</option>\");\n", |
|---|
| 1590 | nvram_match( "dhcpfwd_enable", |
|---|
| 1591 | "1" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 1592 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 1593 | websWrite( wp, "</select>\n" ); |
|---|
| 1594 | websWrite( wp, "</div>\n" ); |
|---|
| 1595 | if( nvram_match( "dhcpfwd_enable", "1" ) ) |
|---|
| 1596 | { |
|---|
| 1597 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1598 | websWrite( wp, |
|---|
| 1599 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_srv)</script></div>\n" ); |
|---|
| 1600 | char *ipfwd = nvram_safe_get( "dhcpfwd_ip" ); |
|---|
| 1601 | |
|---|
| 1602 | websWrite( wp, |
|---|
| 1603 | "<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", |
|---|
| 1604 | get_single_ip( ipfwd, 0 ), get_single_ip( ipfwd, 1 ), |
|---|
| 1605 | get_single_ip( ipfwd, 2 ), get_single_ip( ipfwd, 3 ) ); |
|---|
| 1606 | } |
|---|
| 1607 | else |
|---|
| 1608 | { |
|---|
| 1609 | char buf[20]; |
|---|
| 1610 | |
|---|
| 1611 | prefix_ip_get( "lan_ipaddr", buf, 1 ); |
|---|
| 1612 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1613 | // char *nv = nvram_safe_get ("wan_wins"); |
|---|
| 1614 | websWrite( wp, |
|---|
| 1615 | "<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", |
|---|
| 1616 | nvram_match( "lan_proto", |
|---|
| 1617 | "dhcp" ) ? "checked=\"checked\"" : "" ); |
|---|
| 1618 | websWrite( wp, |
|---|
| 1619 | "<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", |
|---|
| 1620 | nvram_match( "lan_proto", |
|---|
| 1621 | "static" ) ? "checked=\"checked\"" : "" ); |
|---|
| 1622 | websWrite( wp, |
|---|
| 1623 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_start)</script></div>%s", |
|---|
| 1624 | buf ); |
|---|
| 1625 | websWrite( wp, |
|---|
| 1626 | "<input class=\"num\" name=\"dhcp_start\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,1,254,idx.dhcp_start)\" value=\"%s\" />", |
|---|
| 1627 | nvram_safe_get( "dhcp_start" ) ); |
|---|
| 1628 | websWrite( wp, "</div>\n" ); |
|---|
| 1629 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1630 | websWrite( wp, |
|---|
| 1631 | "<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", |
|---|
| 1632 | nvram_safe_get( "dhcp_num" ) ); |
|---|
| 1633 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1634 | websWrite( wp, |
|---|
| 1635 | "<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", |
|---|
| 1636 | nvram_safe_get( "dhcp_lease" ) ); |
|---|
| 1637 | if( nvram_invmatch( "wan_proto", "static" ) ) |
|---|
| 1638 | { |
|---|
| 1639 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1640 | websWrite( wp, |
|---|
| 1641 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 1</div>" ); |
|---|
| 1642 | websWrite( wp, |
|---|
| 1643 | "<input type=\"hidden\" name=\"wan_dns\" value=\"4\" />" ); |
|---|
| 1644 | for( i = 0; i < 4; i++ ) |
|---|
| 1645 | websWrite( wp, |
|---|
| 1646 | "<input class=\"num\" name=\"wan_dns0_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1647 | i, i == 3 ? 254 : 255, get_dns_ip( "wan_dns", 0, |
|---|
| 1648 | i ), |
|---|
| 1649 | i < 3 ? "." : "" ); |
|---|
| 1650 | |
|---|
| 1651 | websWrite( wp, "\n</div>\n<div class=\"setting\">\n" ); |
|---|
| 1652 | websWrite( wp, |
|---|
| 1653 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 2</div>" ); |
|---|
| 1654 | for( i = 0; i < 4; i++ ) |
|---|
| 1655 | websWrite( wp, |
|---|
| 1656 | "<input class=\"num\" name=\"wan_dns1_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1657 | i, i == 3 ? 254 : 255, get_dns_ip( "wan_dns", 1, |
|---|
| 1658 | i ), |
|---|
| 1659 | i < 3 ? "." : "" ); |
|---|
| 1660 | |
|---|
| 1661 | websWrite( wp, "\n</div>\n<div class=\"setting\">\n" ); |
|---|
| 1662 | websWrite( wp, |
|---|
| 1663 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 3</div>" ); |
|---|
| 1664 | for( i = 0; i < 4; i++ ) |
|---|
| 1665 | websWrite( wp, |
|---|
| 1666 | "<input class=\"num\" name=\"wan_dns2_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1667 | i, i == 3 ? 254 : 255, get_dns_ip( "wan_dns", 2, |
|---|
| 1668 | i ), |
|---|
| 1669 | i < 3 ? "." : "" ); |
|---|
| 1670 | websWrite( wp, "\n</div>" ); |
|---|
| 1671 | } |
|---|
| 1672 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1673 | websWrite( wp, "<div class=\"label\">WINS</div>\n" ); |
|---|
| 1674 | websWrite( wp, |
|---|
| 1675 | "<input type=\"hidden\" name=\"wan_wins\" value=\"4\" />\n" ); |
|---|
| 1676 | char *wins = nvram_safe_get( "wan_wins" ); |
|---|
| 1677 | |
|---|
| 1678 | for( i = 0; i < 4; i++ ) |
|---|
| 1679 | { |
|---|
| 1680 | websWrite( wp, |
|---|
| 1681 | "<input class=\"num\" name=\"wan_wins_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,"WINS")\" value=\"%d\" />%s", |
|---|
| 1682 | i, i == 3 ? 254 : 255, get_single_ip( wins, i ), |
|---|
| 1683 | i < 3 ? "." : "" ); |
|---|
| 1684 | } |
|---|
| 1685 | |
|---|
| 1686 | websWrite( wp, "</div>\n<div class=\"setting\">\n" ); |
|---|
| 1687 | websWrite( wp, |
|---|
| 1688 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_dnsmasq)</script></div>\n" ); |
|---|
| 1689 | websWrite( wp, |
|---|
| 1690 | "<input type=\"checkbox\" name=\"_dhcp_dnsmasq\" value=\"1\" onclick=\"setDNSMasq(this.form)\" %s />\n", |
|---|
| 1691 | nvram_match( "dhcp_dnsmasq", |
|---|
| 1692 | "1" ) ? "checked=\"checked\"" : "" ); |
|---|
| 1693 | websWrite( wp, "</div>\n<div class=\"setting\">\n" ); |
|---|
| 1694 | websWrite( wp, |
|---|
| 1695 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dns_dnsmasq)</script></div>\n" ); |
|---|
| 1696 | websWrite( wp, |
|---|
| 1697 | "<input type=\"checkbox\" name=\"_dns_dnsmasq\" value=\"1\" %s />\n", |
|---|
| 1698 | nvram_match( "dns_dnsmasq", |
|---|
| 1699 | "1" ) ? "checked=\"checked\"" : "" ); |
|---|
| 1700 | websWrite( wp, "</div>\n<div class=\"setting\">\n" ); |
|---|
| 1701 | websWrite( wp, |
|---|
| 1702 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.auth_dnsmasq)</script></div>\n" ); |
|---|
| 1703 | websWrite( wp, |
|---|
| 1704 | "<input type=\"checkbox\" name=\"_auth_dnsmasq\" value=\"1\" %s />\n", |
|---|
| 1705 | nvram_match( "auth_dnsmasq", |
|---|
| 1706 | "1" ) ? "checked=\"checked\"" : "" ); |
|---|
| 1707 | websWrite( wp, "</div>\n" ); |
|---|
| 1708 | } |
|---|
| 1709 | |
|---|
| 1710 | websWrite( wp, "</fieldset><br />\n" ); |
|---|
| 1711 | return; |
|---|
| 1712 | } |
|---|
| 1713 | |
|---|
| 1714 | #ifdef HAVE_MADWIFI |
|---|
| 1715 | void ej_show_wifiselect( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1716 | { |
|---|
| 1717 | char *next; |
|---|
| 1718 | char var[32]; |
|---|
| 1719 | int count = getifcount( "wifi" ); |
|---|
| 1720 | |
|---|
| 1721 | if( count < 2 ) |
|---|
| 1722 | return; |
|---|
| 1723 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1724 | websWrite( wp, |
|---|
| 1725 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.intrface)</script></div>\n" ); |
|---|
| 1726 | websWrite( wp, |
|---|
| 1727 | "<select name=\"wifi_display\" onchange=\"refresh(this.form)\">\n" ); |
|---|
| 1728 | int i; |
|---|
| 1729 | |
|---|
| 1730 | for( i = 0; i < count; i++ ) |
|---|
| 1731 | { |
|---|
| 1732 | sprintf( var, "ath%d", i ); |
|---|
| 1733 | websWrite( wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 1734 | var, nvram_match( "wifi_display", |
|---|
| 1735 | var ) ? "selected=\"selected\"" : "", |
|---|
| 1736 | var ); |
|---|
| 1737 | char *names = nvram_nget( "ath%d_vifs", i ); |
|---|
| 1738 | |
|---|
| 1739 | foreach( var, names, next ) |
|---|
| 1740 | { |
|---|
| 1741 | websWrite( wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 1742 | var, nvram_match( "wifi_display", |
|---|
| 1743 | var ) ? "selected=\"selected\"" : "", |
|---|
| 1744 | var ); |
|---|
| 1745 | } |
|---|
| 1746 | } |
|---|
| 1747 | websWrite( wp, "</select>\n" ); |
|---|
| 1748 | websWrite( wp, "</div>\n" ); |
|---|
| 1749 | |
|---|
| 1750 | } |
|---|
| 1751 | #else |
|---|
| 1752 | void ej_show_wifiselect( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1753 | { |
|---|
| 1754 | // nothing for now |
|---|
| 1755 | } |
|---|
| 1756 | |
|---|
| 1757 | #endif |
|---|
| 1758 | #if 0 |
|---|
| 1759 | static void showOption( webs_t wp, char *propname, char *nvname ) |
|---|
| 1760 | { |
|---|
| 1761 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1762 | websWrite( wp, |
|---|
| 1763 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n<select name=\"%s\">\n", |
|---|
| 1764 | propname, nvname ); |
|---|
| 1765 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 1766 | websWrite( wp, |
|---|
| 1767 | "document.write(\"<option value=\\\"0\\\" %s >\" + share.disabled + \"</option>\");\n", |
|---|
| 1768 | nvram_default_match( nvname, "0", |
|---|
| 1769 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 1770 | "" ); |
|---|
| 1771 | websWrite( wp, |
|---|
| 1772 | "document.write(\"<option value=\\\"1\\\" %s >\" + share.enabled + \"</option>\");\n", |
|---|
| 1773 | nvram_default_match( nvname, "1", |
|---|
| 1774 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 1775 | "" ); |
|---|
| 1776 | websWrite( wp, "//]]>\n</script>\n</select>\n</div>\n" ); |
|---|
| 1777 | |
|---|
| 1778 | } |
|---|
| 1779 | #endif |
|---|
| 1780 | static void showRadio( webs_t wp, char *propname, char *nvname ) |
|---|
| 1781 | { |
|---|
| 1782 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1783 | websWrite( wp, |
|---|
| 1784 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n", |
|---|
| 1785 | propname ); |
|---|
| 1786 | websWrite( wp, |
|---|
| 1787 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input> \n", |
|---|
| 1788 | nvname, nvram_default_match( nvname, "1", |
|---|
| 1789 | "0" ) ? "checked=\"checked\"" : |
|---|
| 1790 | "" ); |
|---|
| 1791 | websWrite( wp, |
|---|
| 1792 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input> \n", |
|---|
| 1793 | nvname, nvram_default_match( nvname, "0", |
|---|
| 1794 | "0" ) ? "checked=\"checked\"" : |
|---|
| 1795 | "" ); |
|---|
| 1796 | websWrite( wp, "</div>\n" ); |
|---|
| 1797 | } |
|---|
| 1798 | #ifdef HAVE_MADWIFI |
|---|
| 1799 | static void showAutoOption( webs_t wp, char *propname, char *nvname ) |
|---|
| 1800 | { |
|---|
| 1801 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1802 | websWrite( wp, |
|---|
| 1803 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n<select name=\"%s\">\n", |
|---|
| 1804 | propname, nvname ); |
|---|
| 1805 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 1806 | websWrite( wp, |
|---|
| 1807 | "document.write(\"<option value=\\\"-1\\\" %s >\" + share.auto + \"</option>\");\n", |
|---|
| 1808 | nvram_default_match( nvname, "0", |
|---|
| 1809 | "-1" ) ? "selected=\\\"selected\\\"" : |
|---|
| 1810 | "" ); |
|---|
| 1811 | websWrite( wp, |
|---|
| 1812 | "document.write(\"<option value=\\\"1\\\" %s >\" + share.enabled + \"</option>\");\n", |
|---|
| 1813 | nvram_default_match( nvname, "1", |
|---|
| 1814 | "-1" ) ? "selected=\\\"selected\\\"" : |
|---|
| 1815 | "" ); |
|---|
| 1816 | websWrite( wp, |
|---|
| 1817 | "document.write(\"<option value=\\\"0\\\" %s >\" + share.disabled + \"</option>\");\n", |
|---|
| 1818 | nvram_default_match( nvname, "0", |
|---|
| 1819 | "-1" ) ? "selected=\\\"selected\\\"" : |
|---|
| 1820 | "" ); |
|---|
| 1821 | websWrite( wp, "//]]>\n</script>\n</select>\n</div>\n" ); |
|---|
| 1822 | |
|---|
| 1823 | } |
|---|
| 1824 | #endif |
|---|
| 1825 | |
|---|
| 1826 | static void |
|---|
| 1827 | showOptions( webs_t wp, char *propname, char *names, char *select ) |
|---|
| 1828 | { |
|---|
| 1829 | char *next; |
|---|
| 1830 | char var[80]; |
|---|
| 1831 | |
|---|
| 1832 | websWrite( wp, "<select name=\"%s\">\n", propname ); |
|---|
| 1833 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 1834 | foreach( var, names, next ) |
|---|
| 1835 | { |
|---|
| 1836 | websWrite( wp, |
|---|
| 1837 | "document.write(\"<option value=\\\"%s\\\" %s >%s</option>\");\n", |
|---|
| 1838 | var, !strcmp( var, |
|---|
| 1839 | select ) ? "selected=\\\"selected\\\"" : "", |
|---|
| 1840 | var ); |
|---|
| 1841 | } |
|---|
| 1842 | websWrite( wp, "//]]>\n</script>\n</select>\n" ); |
|---|
| 1843 | } |
|---|
| 1844 | #ifdef HAVE_MADWIFI |
|---|
| 1845 | static void |
|---|
| 1846 | showOptionsChoose( webs_t wp, char *propname, char *names, char *select ) |
|---|
| 1847 | { |
|---|
| 1848 | char *next; |
|---|
| 1849 | char var[80]; |
|---|
| 1850 | |
|---|
| 1851 | websWrite( wp, "<select name=\"%s\">\n", propname ); |
|---|
| 1852 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 1853 | websWrite( wp, |
|---|
| 1854 | "document.write(\"<option value=\\\"null\\\" >Please choose...</option>\");\n" ); |
|---|
| 1855 | foreach( var, names, next ) |
|---|
| 1856 | { |
|---|
| 1857 | websWrite( wp, |
|---|
| 1858 | "document.write(\"<option value=\\\"%s\\\" %s >%s</option>\");\n", |
|---|
| 1859 | var, !strcmp( var, |
|---|
| 1860 | select ) ? "selected=\\\"selected\\\"" : "", |
|---|
| 1861 | var ); |
|---|
| 1862 | } |
|---|
| 1863 | websWrite( wp, "//]]>\n</script>\n</select>\n" ); |
|---|
| 1864 | } |
|---|
| 1865 | #endif |
|---|
| 1866 | static void |
|---|
| 1867 | showOptionsLabel( webs_t wp, char *labelname, char *propname, char *names, |
|---|
| 1868 | char *select ) |
|---|
| 1869 | { |
|---|
| 1870 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1871 | websWrite( wp, |
|---|
| 1872 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>", |
|---|
| 1873 | labelname ); |
|---|
| 1874 | showOptions( wp, propname, names, select ); |
|---|
| 1875 | websWrite( wp, "</div>\n" ); |
|---|
| 1876 | |
|---|
| 1877 | } |
|---|
| 1878 | |
|---|
| 1879 | void |
|---|
| 1880 | show_inputlabel( webs_t wp, char *labelname, char *propertyname, |
|---|
| 1881 | int propertysize, char *inputclassname, int inputmaxlength ) |
|---|
| 1882 | { |
|---|
| 1883 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1884 | websWrite( wp, |
|---|
| 1885 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>", |
|---|
| 1886 | labelname ); |
|---|
| 1887 | websWrite( wp, |
|---|
| 1888 | "<input class=\"%s\" size=\"%d\" maxlength=\"%d\" name=\"%s\" value=\"%s\" />\n", |
|---|
| 1889 | inputclassname, propertysize, inputmaxlength, propertyname, |
|---|
| 1890 | nvram_safe_get( propertyname ) ); |
|---|
| 1891 | websWrite( wp, "</div>\n" ); |
|---|
| 1892 | } |
|---|
| 1893 | |
|---|
| 1894 | void |
|---|
| 1895 | show_custominputlabel( webs_t wp, char *labelname, char *propertyname, |
|---|
| 1896 | char *property, int propertysize ) |
|---|
| 1897 | { |
|---|
| 1898 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1899 | websWrite( wp, "<div class=\"label\">%s</div>", labelname ); |
|---|
| 1900 | websWrite( wp, "<input size=\"%d\" name=\"%s\" value=\"%s\" />\n", |
|---|
| 1901 | propertysize, propertyname, property ); |
|---|
| 1902 | websWrite( wp, "</div>\n" ); |
|---|
| 1903 | } |
|---|
| 1904 | |
|---|
| 1905 | void show_legend( webs_t wp, char *labelname, int translate ) |
|---|
| 1906 | { |
|---|
| 1907 | /* |
|---|
| 1908 | * char buf[2]; sprintf(buf,"%d",translate); websWrite (wp, |
|---|
| 1909 | * "<legend>%s%s%s</legend>\n", !strcmp (buf, "1") ? "<script |
|---|
| 1910 | * type=\"text/javascript\">Capture(" : "", labelname, !strcmp (buf, "1") |
|---|
| 1911 | * ? ")</script>" : ""); |
|---|
| 1912 | */ |
|---|
| 1913 | if( translate ) |
|---|
| 1914 | websWrite( wp, |
|---|
| 1915 | "<legend><script type=\"text/javascript\">Capture(%s)</script></legend>\n", |
|---|
| 1916 | labelname ); |
|---|
| 1917 | else |
|---|
| 1918 | websWrite( wp, "<legend>%s</legend>\n", labelname ); |
|---|
| 1919 | |
|---|
| 1920 | } |
|---|
| 1921 | |
|---|
| 1922 | #ifdef HAVE_OLSRD |
|---|
| 1923 | |
|---|
| 1924 | void ej_show_olsrd( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1925 | { |
|---|
| 1926 | char *var = websGetVar( wp, "wk_mode", NULL ); |
|---|
| 1927 | |
|---|
| 1928 | if( var == NULL ) |
|---|
| 1929 | var = nvram_safe_get( "wk_mode" ); |
|---|
| 1930 | if( !strcmp( var, "olsr" ) ) |
|---|
| 1931 | { |
|---|
| 1932 | websWrite( wp, "<fieldset>\n" ); |
|---|
| 1933 | show_legend( wp, "route.olsrd_legend", 1 ); |
|---|
| 1934 | show_inputlabel( wp, "route.olsrd_hna", "olsrd_hna", 32, "num", 32 ); |
|---|
| 1935 | show_inputlabel( wp, "route.olsrd_poll", "olsrd_pollsize", 5, "num", |
|---|
| 1936 | 5 ); |
|---|
| 1937 | showOptionsLabel( wp, "route.olsrd_tc", "olsrd_redundancy", "0 1 2", |
|---|
| 1938 | nvram_default_get( "olsrd_redundancy", "2" ) ); |
|---|
| 1939 | show_inputlabel( wp, "route.olsrd_mpr", "olsrd_coverage", 5, "num", |
|---|
| 1940 | 5 ); |
|---|
| 1941 | showRadio( wp, "route.olsrd_lqfe", "olsrd_lqfisheye" ); |
|---|
| 1942 | show_inputlabel( wp, "route.olsrd_lqag", "olsrd_lqaging", 5, "num", |
|---|
| 1943 | 5 ); |
|---|
| 1944 | |
|---|
| 1945 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1946 | websWrite( wp, |
|---|
| 1947 | "<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_lqdmin)</script></div>" ); |
|---|
| 1948 | websWrite( wp, |
|---|
| 1949 | "<input class=\"num\" size=\"5\" maxlength=\"5\" name=\"olsrd_lqdijkstramin\" onblur=\"olsrd_checkDijkstra(this.form)\" value=\"%s\" />\n", |
|---|
| 1950 | nvram_safe_get( "olsrd_lqdijkstramin" ) ); |
|---|
| 1951 | websWrite( wp, "</div>\n" ); |
|---|
| 1952 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1953 | websWrite( wp, |
|---|
| 1954 | "<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_lqdmax)</script></div>" ); |
|---|
| 1955 | websWrite( wp, |
|---|
| 1956 | "<input class=\"num\" size=\"5\" maxlength=\"5\" name=\"olsrd_lqdijkstramax\" onblur=\"olsrd_checkDijkstra(this.form)\" value=\"%s\" />\n", |
|---|
| 1957 | nvram_safe_get( "olsrd_lqdijkstramax" ) ); |
|---|
| 1958 | websWrite( wp, "</div>\n" ); |
|---|
| 1959 | |
|---|
| 1960 | showOptionsLabel( wp, "route.olsrd_lqlvl", "olsrd_lqlevel", |
|---|
| 1961 | "0 1 2", nvram_default_get( "olsrd_lqlevel", |
|---|
| 1962 | "2" ) ); |
|---|
| 1963 | showRadio( wp, "route.olsrd_hysteresis", "olsrd_hysteresis" ); |
|---|
| 1964 | char *wordlist = nvram_safe_get( "olsrd_interfaces" ); |
|---|
| 1965 | char *next; |
|---|
| 1966 | char word[128]; |
|---|
| 1967 | int count = 0; |
|---|
| 1968 | |
|---|
| 1969 | foreach( word, wordlist, next ) |
|---|
| 1970 | { |
|---|
| 1971 | char *interface = word; |
|---|
| 1972 | char *hellointerval = interface; |
|---|
| 1973 | |
|---|
| 1974 | strsep( &hellointerval, ">" ); |
|---|
| 1975 | char *hellovaliditytime = hellointerval; |
|---|
| 1976 | |
|---|
| 1977 | strsep( &hellovaliditytime, ">" ); |
|---|
| 1978 | char *tcinterval = hellovaliditytime; |
|---|
| 1979 | |
|---|
| 1980 | strsep( &tcinterval, ">" ); |
|---|
| 1981 | char *tcvaliditytime = tcinterval; |
|---|
| 1982 | |
|---|
| 1983 | strsep( &tcvaliditytime, ">" ); |
|---|
| 1984 | char *midinterval = tcvaliditytime; |
|---|
| 1985 | |
|---|
| 1986 | strsep( &midinterval, ">" ); |
|---|
| 1987 | char *midvaliditytime = midinterval; |
|---|
| 1988 | |
|---|
| 1989 | strsep( &midvaliditytime, ">" ); |
|---|
| 1990 | char *hnainterval = midvaliditytime; |
|---|
| 1991 | |
|---|
| 1992 | strsep( &hnainterval, ">" ); |
|---|
| 1993 | char *hnavaliditytime = hnainterval; |
|---|
| 1994 | |
|---|
| 1995 | strsep( &hnavaliditytime, ">" ); |
|---|
| 1996 | websWrite( wp, "<fieldset>\n" ); |
|---|
| 1997 | show_legend( wp, interface, 0 ); |
|---|
| 1998 | char valuename[32]; |
|---|
| 1999 | |
|---|
| 2000 | sprintf( valuename, "%s_hellointerval", interface ); |
|---|
| 2001 | show_custominputlabel( wp, "Hello Interval", valuename, |
|---|
| 2002 | hellointerval, 5 ); |
|---|
| 2003 | sprintf( valuename, "%s_hellovaliditytime", interface ); |
|---|
| 2004 | show_custominputlabel( wp, "Hello Validity Time", valuename, |
|---|
| 2005 | hellovaliditytime, 5 ); |
|---|
| 2006 | |
|---|
| 2007 | sprintf( valuename, "%s_tcinterval", interface ); |
|---|
| 2008 | show_custominputlabel( wp, "TC Interval", valuename, tcinterval, |
|---|
| 2009 | 5 ); |
|---|
| 2010 | sprintf( valuename, "%s_tcvaliditytime", interface ); |
|---|
| 2011 | show_custominputlabel( wp, "TC Validity Time", valuename, |
|---|
| 2012 | tcvaliditytime, 5 ); |
|---|
| 2013 | |
|---|
| 2014 | sprintf( valuename, "%s_midinterval", interface ); |
|---|
| 2015 | show_custominputlabel( wp, "MID Interval", valuename, midinterval, |
|---|
| 2016 | 5 ); |
|---|
| 2017 | sprintf( valuename, "%s_midvaliditytime", interface ); |
|---|
| 2018 | show_custominputlabel( wp, "MID Validity Time", valuename, |
|---|
| 2019 | midvaliditytime, 5 ); |
|---|
| 2020 | |
|---|
| 2021 | sprintf( valuename, "%s_hnainterval", interface ); |
|---|
| 2022 | show_custominputlabel( wp, "HNA Interval", valuename, hnainterval, |
|---|
| 2023 | 5 ); |
|---|
| 2024 | sprintf( valuename, "%s_hnavaliditytime", interface ); |
|---|
| 2025 | show_custominputlabel( wp, "HNA Validity Time", valuename, |
|---|
| 2026 | hnavaliditytime, 5 ); |
|---|
| 2027 | websWrite( wp, |
|---|
| 2028 | "<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", |
|---|
| 2029 | count ); |
|---|
| 2030 | |
|---|
| 2031 | websWrite( wp, "</fieldset>\n" ); |
|---|
| 2032 | count++; |
|---|
| 2033 | } |
|---|
| 2034 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2035 | websWrite( wp, |
|---|
| 2036 | "<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_newiface)</script></div>\n" ); |
|---|
| 2037 | char buffer[256]; |
|---|
| 2038 | |
|---|
| 2039 | memset( buffer, 0, 256 ); |
|---|
| 2040 | getIfList( buffer, NULL ); |
|---|
| 2041 | showOptions( wp, "olsrd_ifname", buffer, "" ); |
|---|
| 2042 | websWrite( wp, " " ); |
|---|
| 2043 | websWrite( wp, |
|---|
| 2044 | "<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" ); |
|---|
| 2045 | websWrite( wp, "</div>\n" ); |
|---|
| 2046 | websWrite( wp, "</fieldset><br />\n" ); |
|---|
| 2047 | } |
|---|
| 2048 | } |
|---|
| 2049 | #else //!HAVE_OLSRD |
|---|
| 2050 | void ej_show_olsrd( webs_t wp, int argc, char_t ** argv ) |
|---|
| 2051 | { |
|---|
| 2052 | return; |
|---|
| 2053 | } |
|---|
| 2054 | #endif |
|---|
| 2055 | |
|---|
| 2056 | #ifdef HAVE_VLANTAGGING |
|---|
| 2057 | #ifdef HAVE_BONDING |
|---|
| 2058 | |
|---|
| 2059 | void ej_show_bondings( webs_t wp, int argc, char_t ** argv ) |
|---|
| 2060 | { |
|---|
| 2061 | char buffer[256]; |
|---|
| 2062 | char bufferif[512]; |
|---|
| 2063 | char bondnames[256]; |
|---|
| 2064 | int count = 0; |
|---|
| 2065 | static char word[256]; |
|---|
| 2066 | char *next, *wordlist; |
|---|
| 2067 | |
|---|
| 2068 | memset( buffer, 0, 256 ); |
|---|
| 2069 | memset( bondnames, 0, 256 ); |
|---|
| 2070 | memset( bufferif, 0, 512 ); |
|---|
| 2071 | websWrite( wp, "<h2>Bonding</h2>\n" ); |
|---|
| 2072 | websWrite( wp, "<fieldset>\n" ); |
|---|
| 2073 | websWrite( wp, "<legend>Bonding</legend>\n" ); |
|---|
| 2074 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2075 | websWrite( wp, "<div class=\"label\">Bonding Type</div>\n", count ); |
|---|
| 2076 | showOptions( wp, "bonding_type", |
|---|
| 2077 | "balance-rr active-backup balance-xor broadcast 802.3ad balance-tlb balance-alb", |
|---|
| 2078 | nvram_default_get( "bonding_type", "balance-rr" ) ); |
|---|
| 2079 | websWrite( wp, " Bonding Interfaces " ); |
|---|
| 2080 | websWrite( wp, |
|---|
| 2081 | "<input class=\"num\" name=\"bonding_number\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2082 | nvram_default_get( "bonding_number", "1" ) ); |
|---|
| 2083 | websWrite( wp, "</div>\n" ); |
|---|
| 2084 | |
|---|
| 2085 | getIfList( bufferif, "eth" ); |
|---|
| 2086 | int i; |
|---|
| 2087 | |
|---|
| 2088 | #ifdef HAVE_XSCALE |
|---|
| 2089 | memset( buffer, 0, 256 ); |
|---|
| 2090 | getIfList( buffer, "ixp" ); |
|---|
| 2091 | sprintf( bufferif, "%s %s", bufferif, buffer ); |
|---|
| 2092 | #endif |
|---|
| 2093 | memset( buffer, 0, 256 ); |
|---|
| 2094 | getIfList( buffer, "br" ); |
|---|
| 2095 | sprintf( bufferif, "%s %s", bufferif, buffer ); |
|---|
| 2096 | #ifdef HAVE_MADWIFI |
|---|
| 2097 | int c = getifcount( "wifi" ); |
|---|
| 2098 | |
|---|
| 2099 | for( i = 0; i < c; i++ ) |
|---|
| 2100 | { |
|---|
| 2101 | char ath[32]; |
|---|
| 2102 | |
|---|
| 2103 | sprintf( ath, "ath%d_bridged", i ); |
|---|
| 2104 | if( nvram_default_match( ath, "0", "1" ) ) |
|---|
| 2105 | { |
|---|
| 2106 | sprintf( bufferif, "%s ath%d", bufferif, i ); |
|---|
| 2107 | char vifs[32]; |
|---|
| 2108 | |
|---|
| 2109 | sprintf( vifs, "ath%d_vifs", i ); |
|---|
| 2110 | sprintf( bufferif, "%s %s", bufferif, nvram_safe_get( vifs ) ); |
|---|
| 2111 | } |
|---|
| 2112 | } |
|---|
| 2113 | #endif |
|---|
| 2114 | |
|---|
| 2115 | for( i = 0; i < atoi( nvram_safe_get( "bonding_number" ) ); i++ ) |
|---|
| 2116 | { |
|---|
| 2117 | sprintf( bondnames, "%s bond%d", bondnames, i ); |
|---|
| 2118 | } |
|---|
| 2119 | int totalcount = 0; |
|---|
| 2120 | int realcount = atoi( nvram_default_get( "bonding_count", "0" ) ); |
|---|
| 2121 | |
|---|
| 2122 | wordlist = nvram_safe_get( "bondings" ); |
|---|
| 2123 | foreach( word, wordlist, next ) |
|---|
| 2124 | { |
|---|
| 2125 | char *port = word; |
|---|
| 2126 | char *tag = strsep( &port, ">" ); |
|---|
| 2127 | |
|---|
| 2128 | if( !tag || !port ) |
|---|
| 2129 | break; |
|---|
| 2130 | char vlan_name[32]; |
|---|
| 2131 | |
|---|
| 2132 | // sprintf (vlan_name, "%s.%s", tag, port); |
|---|
| 2133 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2134 | websWrite( wp, "<div class=\"label\">Bonding %d Assignment</div>\n", |
|---|
| 2135 | count ); |
|---|
| 2136 | websWrite( wp, " Bond " ); |
|---|
| 2137 | sprintf( vlan_name, "bondingifname%d", count ); |
|---|
| 2138 | showOptions( wp, vlan_name, bondnames, tag ); |
|---|
| 2139 | sprintf( vlan_name, "bondingattach%d", count ); |
|---|
| 2140 | websWrite( wp, " Slave " ); |
|---|
| 2141 | showOptions( wp, vlan_name, bufferif, port ); |
|---|
| 2142 | websWrite( wp, |
|---|
| 2143 | "<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", |
|---|
| 2144 | count ); |
|---|
| 2145 | websWrite( wp, "</div>\n" ); |
|---|
| 2146 | count++; |
|---|
| 2147 | } |
|---|
| 2148 | totalcount = count; |
|---|
| 2149 | for( i = count; i < realcount; i++ ) |
|---|
| 2150 | { |
|---|
| 2151 | char vlan_name[32]; |
|---|
| 2152 | |
|---|
| 2153 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2154 | websWrite( wp, "<div class=\"label\">Bonding %d Interface</div>\n", |
|---|
| 2155 | i ); |
|---|
| 2156 | websWrite( wp, " Bond " ); |
|---|
| 2157 | sprintf( vlan_name, "bondingifname%d", i ); |
|---|
| 2158 | showOptions( wp, vlan_name, bondnames, "" ); |
|---|
| 2159 | sprintf( vlan_name, "bondingattach%d", i ); |
|---|
| 2160 | websWrite( wp, " Slave " ); |
|---|
| 2161 | showOptions( wp, vlan_name, bufferif, "" ); |
|---|
| 2162 | websWrite( wp, |
|---|
| 2163 | "<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", |
|---|
| 2164 | i ); |
|---|
| 2165 | websWrite( wp, "</div>\n" ); |
|---|
| 2166 | totalcount++; |
|---|
| 2167 | } |
|---|
| 2168 | char var[32]; |
|---|
| 2169 | |
|---|
| 2170 | sprintf( var, "%d", totalcount ); |
|---|
| 2171 | nvram_set( "bonding_count", var ); |
|---|
| 2172 | websWrite( wp, |
|---|
| 2173 | "<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" ); |
|---|
| 2174 | websWrite( wp, "</fieldset><br />\n" ); |
|---|
| 2175 | } |
|---|
| 2176 | #else //!HAVE_BONDING |
|---|
| 2177 | void ej_show_bondings( webs_t wp, int argc, char_t ** argv ) |
|---|
| 2178 | { |
|---|
| 2179 | return; |
|---|
| 2180 | } |
|---|
| 2181 | #endif |
|---|
| 2182 | |
|---|
| 2183 | void ej_show_vlantagging( webs_t wp, int argc, char_t ** argv ) |
|---|
| 2184 | { |
|---|
| 2185 | char buffer[256]; |
|---|
| 2186 | int count = 0; |
|---|
| 2187 | static char word[256]; |
|---|
| 2188 | char *next, *wordlist; |
|---|
| 2189 | |
|---|
| 2190 | memset( buffer, 0, 256 ); |
|---|
| 2191 | getIfList( buffer, NULL ); |
|---|
| 2192 | int totalcount = 0; |
|---|
| 2193 | int realcount = atoi( nvram_default_get( "vlan_tagcount", "0" ) ); |
|---|
| 2194 | |
|---|
| 2195 | wordlist = nvram_safe_get( "vlan_tags" ); |
|---|
| 2196 | foreach( word, wordlist, next ) |
|---|
| 2197 | { |
|---|
| 2198 | char *port = word; |
|---|
| 2199 | char *tag = strsep( &port, ">" ); |
|---|
| 2200 | |
|---|
| 2201 | if( !tag || !port ) |
|---|
| 2202 | break; |
|---|
| 2203 | char vlan_name[32]; |
|---|
| 2204 | |
|---|
| 2205 | // sprintf (vlan_name, "%s.%s", tag, port); |
|---|
| 2206 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2207 | websWrite( wp, "<div class=\"label\">VLAN%d Interface</div>\n", |
|---|
| 2208 | count ); |
|---|
| 2209 | sprintf( vlan_name, "vlanifname%d", count ); |
|---|
| 2210 | showOptions( wp, vlan_name, buffer, tag ); |
|---|
| 2211 | sprintf( vlan_name, "vlantag%d", count ); |
|---|
| 2212 | websWrite( wp, " Tag Number " ); |
|---|
| 2213 | websWrite( wp, |
|---|
| 2214 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2215 | vlan_name, port ); |
|---|
| 2216 | websWrite( wp, |
|---|
| 2217 | "<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", |
|---|
| 2218 | count ); |
|---|
| 2219 | websWrite( wp, "</div>\n" ); |
|---|
| 2220 | count++; |
|---|
| 2221 | } |
|---|
| 2222 | totalcount = count; |
|---|
| 2223 | int i; |
|---|
| 2224 | |
|---|
| 2225 | for( i = count; i < realcount; i++ ) |
|---|
| 2226 | { |
|---|
| 2227 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2228 | websWrite( wp, "<div class=\"label\">VLAN%d Interface</div>\n", i ); |
|---|
| 2229 | char vlan_name[32]; |
|---|
| 2230 | |
|---|
| 2231 | sprintf( vlan_name, "vlanifname%d", i ); |
|---|
| 2232 | showOptions( wp, vlan_name, buffer, "" ); |
|---|
| 2233 | sprintf( vlan_name, "vlantag%d", i ); |
|---|
| 2234 | websWrite( wp, " Tag Number " ); |
|---|
| 2235 | websWrite( wp, |
|---|
| 2236 | "<input class=\"num\" name=\"%s\" size=\"5\" value=\"0\" />\n", |
|---|
| 2237 | vlan_name ); |
|---|
| 2238 | websWrite( wp, |
|---|
| 2239 | "<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", |
|---|
| 2240 | i ); |
|---|
| 2241 | websWrite( wp, "</div>\n" ); |
|---|
| 2242 | totalcount++; |
|---|
| 2243 | } |
|---|
| 2244 | char var[32]; |
|---|
| 2245 | |
|---|
| 2246 | sprintf( var, "%d", totalcount ); |
|---|
| 2247 | nvram_set( "vlan_tagcount", var ); |
|---|
| 2248 | websWrite( wp, |
|---|
| 2249 | "<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" ); |
|---|
| 2250 | } |
|---|
| 2251 | |
|---|
| 2252 | void ej_show_mdhcp( webs_t wp, int argc, char_t ** argv ) |
|---|
| 2253 | { |
|---|
| 2254 | char buffer[256]; |
|---|
| 2255 | int count = 0; |
|---|
| 2256 | static char word[256]; |
|---|
| 2257 | char *next, *wordlist; |
|---|
| 2258 | |
|---|
| 2259 | websWrite( wp, "<h2>%s</h2>\n<fieldset>\n", |
|---|
| 2260 | live_translate( "networking.h5" ) ); |
|---|
| 2261 | websWrite( wp, "<legend>%s</legend>\n", |
|---|
| 2262 | live_translate( "networking.legend5" ) ); |
|---|
| 2263 | |
|---|
| 2264 | memset( buffer, 0, 256 ); |
|---|
| 2265 | getIfList( buffer, NULL ); |
|---|
| 2266 | int totalcount = 0; |
|---|
| 2267 | int realcount = atoi( nvram_default_get( "mdhcpd_count", "0" ) ); |
|---|
| 2268 | |
|---|
| 2269 | wordlist = nvram_safe_get( "mdhcpd" ); |
|---|
| 2270 | foreach( word, wordlist, next ) |
|---|
| 2271 | { |
|---|
| 2272 | char *interface = word; |
|---|
| 2273 | char *dhcpon = interface; |
|---|
| 2274 | |
|---|
| 2275 | interface = strsep( &dhcpon, ">" ); |
|---|
| 2276 | char *start = dhcpon; |
|---|
| 2277 | |
|---|
| 2278 | dhcpon = strsep( &start, ">" ); |
|---|
| 2279 | char *max = start; |
|---|
| 2280 | |
|---|
| 2281 | start = strsep( &max, ">" ); |
|---|
| 2282 | char *leasetime = max; |
|---|
| 2283 | |
|---|
| 2284 | max = strsep( &leasetime, ">" ); |
|---|
| 2285 | if( !interface || !start || !dhcpon || !max || !leasetime ) |
|---|
| 2286 | break; |
|---|
| 2287 | char vlan_name[32]; |
|---|
| 2288 | |
|---|
| 2289 | // interface |
|---|
| 2290 | char *ipaddr = nvram_nget( "%s_ipaddr", interface ); |
|---|
| 2291 | char *netmask = nvram_nget( "%s_netmask", interface ); |
|---|
| 2292 | |
|---|
| 2293 | if( strlen( ipaddr ) > 0 && strlen( netmask ) > 0 ) |
|---|
| 2294 | { |
|---|
| 2295 | websWrite( wp, "Interface %s: IP %s/%s\n", interface, ipaddr, |
|---|
| 2296 | netmask ); |
|---|
| 2297 | } |
|---|
| 2298 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2299 | websWrite( wp, "<div class=\"label\">DHCP %d</div>\n", count ); |
|---|
| 2300 | sprintf( vlan_name, "mdhcpifname%d", count ); |
|---|
| 2301 | showOptions( wp, vlan_name, buffer, interface ); |
|---|
| 2302 | // on off |
|---|
| 2303 | sprintf( vlan_name, "mdhcpon%d", count ); |
|---|
| 2304 | showOptions( wp, vlan_name, "On Off", dhcpon ); |
|---|
| 2305 | // start |
|---|
| 2306 | sprintf( vlan_name, "mdhcpstart%d", count ); |
|---|
| 2307 | websWrite( wp, " Start " ); |
|---|
| 2308 | websWrite( wp, |
|---|
| 2309 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2310 | vlan_name, start ); |
|---|
| 2311 | // max |
|---|
| 2312 | sprintf( vlan_name, "mdhcpmax%d", count ); |
|---|
| 2313 | websWrite( wp, " Max " ); |
|---|
| 2314 | websWrite( wp, |
|---|
| 2315 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2316 | vlan_name, max ); |
|---|
| 2317 | sprintf( vlan_name, "mdhcpleasetime%d", count ); |
|---|
| 2318 | websWrite( wp, " Leasetime " ); |
|---|
| 2319 | websWrite( wp, |
|---|
| 2320 | "<input class=\"num\" name=\"%s\" size=\"5\" value=\"%s\" />\n", |
|---|
| 2321 | vlan_name, leasetime ); |
|---|
| 2322 | // |
|---|
| 2323 | websWrite( wp, |
|---|
| 2324 | "<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", |
|---|
| 2325 | count ); |
|---|
| 2326 | websWrite( wp, "</div>\n" ); |
|---|
| 2327 | count++; |
|---|
| 2328 | } |
|---|
| 2329 | totalcount = count; |
|---|
| 2330 | int i; |
|---|
| 2331 | |
|---|
| 2332 | for( i = count; i < realcount; i++ ) |
|---|
| 2333 | { |
|---|
| 2334 | char vlan_name[32]; |
|---|
| 2335 | |
|---|
| 2336 | // sprintf (mdhcp_name, "%s.%s", tag, port); |
|---|
| 2337 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2338 | websWrite( wp, "<div class=\"label\">DHCP %d</div>\n", count ); |
|---|
| 2339 | // interface |
|---|
| 2340 | sprintf( vlan_name, "mdhcpifname%d", count ); |
|---|
| 2341 | showOptions( wp, vlan_name, buffer, "" ); |
|---|
| 2342 | // on off |
|---|
| 2343 | sprintf( vlan_name, "mdhcpon%d", count ); |
|---|
| 2344 | showOptions( wp, vlan_name, "On Off", "" ); |
|---|
| 2345 | // start |
|---|
| 2346 | sprintf( vlan_name, "mdhcpstart%d", count ); |
|---|
| 2347 | websWrite( wp, " Start " ); |
|---|
| 2348 | websWrite( wp, |
|---|
| 2349 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2350 | vlan_name, "100" ); |
|---|
| 2351 | // max |
|---|
| 2352 | sprintf( vlan_name, "mdhcpmax%d", count ); |
|---|
| 2353 | websWrite( wp, " Max " ); |
|---|
| 2354 | websWrite( wp, |
|---|
| 2355 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2356 | vlan_name, "50" ); |
|---|
| 2357 | sprintf( vlan_name, "mdhcpleasetime%d", count ); |
|---|
| 2358 | websWrite( wp, " Leasetime " ); |
|---|
| 2359 | websWrite( wp, |
|---|
| 2360 | "<input class=\"num\" name=\"%s\" size=\"5\" value=\"%s\" />\n", |
|---|
| 2361 | vlan_name, "3600" ); |
|---|
| 2362 | websWrite( wp, |
|---|
| 2363 | "<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", |
|---|
| 2364 | i ); |
|---|
| 2365 | websWrite( wp, "</div>\n" ); |
|---|
| 2366 | totalcount++; |
|---|
| 2367 | } |
|---|
| 2368 | char var[32]; |
|---|
| 2369 | |
|---|
| 2370 | sprintf( var, "%d", totalcount ); |
|---|
| 2371 | nvram_set( "mdhcpd_count", var ); |
|---|
| 2372 | websWrite( wp, |
|---|
| 2373 | "<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" ); |
|---|
| 2374 | websWrite( wp, "</fieldset><br />\n" ); |
|---|
| 2375 | |
|---|
| 2376 | } |
|---|
| 2377 | |
|---|
| 2378 | void ej_show_bridgenames( webs_t wp, int argc, char_t ** argv ) |
|---|
| 2379 | { |
|---|
| 2380 | char buffer[256]; |
|---|
| 2381 | int count = 0; |
|---|
| 2382 | static char word[256]; |
|---|
| 2383 | char *next, *wordlist; |
|---|
| 2384 | |
|---|
| 2385 | memset( buffer, 0, 256 ); |
|---|
| 2386 | getIfList( buffer, NULL ); |
|---|
| 2387 | int realcount = atoi( nvram_default_get( "bridges_count", "0" ) ); |
|---|
| 2388 | |
|---|
| 2389 | wordlist = nvram_safe_get( "bridges" ); |
|---|
| 2390 | foreach( word, wordlist, next ) |
|---|
| 2391 | { |
|---|
| 2392 | |
|---|
| 2393 | char *stp = word; |
|---|
| 2394 | char *bridge = strsep( &stp, ">" ); |
|---|
| 2395 | char *prio = stp; |
|---|
| 2396 | stp = strsep( &prio, ">" ); |
|---|
| 2397 | char *mtu = prio; |
|---|
| 2398 | prio = strsep( &mtu, ">" ); |
|---|
| 2399 | if (!prio) |
|---|
| 2400 | { |
|---|
| 2401 | prio = mtu; |
|---|
| 2402 | mtu = "1500"; |
|---|
| 2403 | } |
|---|
| 2404 | |
|---|
| 2405 | |
|---|
| 2406 | /* char *stp = word; |
|---|
| 2407 | char *bridge = strsep( &stp, ">" ); |
|---|
| 2408 | char *mtu = stp; |
|---|
| 2409 | char *prio = strsep( &mtu, ">" ); |
|---|
| 2410 | */ |
|---|
| 2411 | if( !bridge || !stp ) |
|---|
| 2412 | break; |
|---|
| 2413 | |
|---|
| 2414 | char vlan_name[32]; |
|---|
| 2415 | |
|---|
| 2416 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2417 | websWrite( wp, "<div class=\"label\">Bridge %d</div>\n", count ); |
|---|
| 2418 | sprintf( vlan_name, "bridgename%d", count ); |
|---|
| 2419 | websWrite( wp, |
|---|
| 2420 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2421 | vlan_name, bridge ); |
|---|
| 2422 | websWrite( wp, " STP " ); |
|---|
| 2423 | sprintf( vlan_name, "bridgestp%d", count ); |
|---|
| 2424 | showOptions( wp, vlan_name, "On Off", stp ); |
|---|
| 2425 | websWrite( wp, " Prio " ); |
|---|
| 2426 | sprintf( vlan_name, "bridgeprio%d", count ); |
|---|
| 2427 | websWrite( wp, |
|---|
| 2428 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2429 | vlan_name, prio != NULL ? prio : "32768" ); |
|---|
| 2430 | websWrite( wp, " MTU " ); |
|---|
| 2431 | sprintf( vlan_name, "bridgemtu%d", count ); |
|---|
| 2432 | websWrite( wp, |
|---|
| 2433 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2434 | vlan_name, mtu != NULL ? mtu : "1500" ); |
|---|
| 2435 | websWrite( wp, |
|---|
| 2436 | "<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", |
|---|
| 2437 | count ); |
|---|
| 2438 | websWrite( wp, "</div>\n" ); |
|---|
| 2439 | show_ipnetmask( wp, bridge ); |
|---|
| 2440 | count++; |
|---|
| 2441 | } |
|---|
| 2442 | int i; |
|---|
| 2443 | int totalcount = count; |
|---|
| 2444 | |
|---|
| 2445 | for( i = count; i < realcount; i++ ) |
|---|
| 2446 | { |
|---|
| 2447 | char vlan_name[32]; |
|---|
| 2448 | |
|---|
| 2449 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2450 | websWrite( wp, "<div class=\"label\">Bridge %d</div>\n", i ); |
|---|
| 2451 | sprintf( vlan_name, "bridgename%d", i ); |
|---|
| 2452 | websWrite( wp, "<input class=\"num\" name=\"%s\"size=\"5\" />\n", |
|---|
| 2453 | vlan_name ); |
|---|
| 2454 | websWrite( wp, " STP " ); |
|---|
| 2455 | sprintf( vlan_name, "bridgestp%d", i ); |
|---|
| 2456 | showOptions( wp, vlan_name, "On Off", "On" ); |
|---|
| 2457 | websWrite( wp, " Prio " ); |
|---|
| 2458 | sprintf( vlan_name, "bridgeprio%d", i ); |
|---|
| 2459 | websWrite( wp, |
|---|
| 2460 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2461 | vlan_name, "32768" ); |
|---|
| 2462 | websWrite( wp, " MTU " ); |
|---|
| 2463 | sprintf( vlan_name, "bridgemtu%d", count ); |
|---|
| 2464 | websWrite( wp, |
|---|
| 2465 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2466 | vlan_name, "1500" ); |
|---|
| 2467 | websWrite( wp, |
|---|
| 2468 | "<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", |
|---|
| 2469 | i ); |
|---|
| 2470 | websWrite( wp, "</div>\n" ); |
|---|
| 2471 | totalcount++; |
|---|
| 2472 | } |
|---|
| 2473 | websWrite( wp, |
|---|
| 2474 | "<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" ); |
|---|
| 2475 | char var[32]; |
|---|
| 2476 | |
|---|
| 2477 | sprintf( var, "%d", totalcount ); |
|---|
| 2478 | nvram_set( "bridges_count", var ); |
|---|
| 2479 | } |
|---|
| 2480 | |
|---|
| 2481 | void ej_show_bridgetable( webs_t wp, int argc, char_t ** argv ) |
|---|
| 2482 | { |
|---|
| 2483 | #ifdef HAVE_MICRO // brctl N/A in micro |
|---|
| 2484 | return; |
|---|
| 2485 | #endif |
|---|
| 2486 | |
|---|
| 2487 | FILE *f; |
|---|
| 2488 | char buf[128]; |
|---|
| 2489 | char brname[32]; |
|---|
| 2490 | char brstp[8]; |
|---|
| 2491 | char brif[16]; |
|---|
| 2492 | int count = 0; |
|---|
| 2493 | |
|---|
| 2494 | system2( "brctl show > /tmp/.brtable" ); |
|---|
| 2495 | |
|---|
| 2496 | if( ( f = fopen( "/tmp/.brtable", "r" ) ) != NULL ) |
|---|
| 2497 | { |
|---|
| 2498 | |
|---|
| 2499 | while( fgets( buf, sizeof( buf ), f ) ) |
|---|
| 2500 | { |
|---|
| 2501 | |
|---|
| 2502 | if( count ) // skip line 0 |
|---|
| 2503 | { |
|---|
| 2504 | strcpy( brname, "" ); |
|---|
| 2505 | strcpy( brstp, "" ); |
|---|
| 2506 | strcpy( brif, "" ); |
|---|
| 2507 | |
|---|
| 2508 | if( strncmp( buf, "\t\t\t", 3 ) != 0 ) |
|---|
| 2509 | { |
|---|
| 2510 | if( count != 1 ) |
|---|
| 2511 | websWrite( wp, "\'," ); // close |
|---|
| 2512 | sscanf( buf, "%s %*s %s %s", brname, brstp, brif ); |
|---|
| 2513 | websWrite( wp, "\'%s\',\'%s\',\'%s ", brname, brstp, |
|---|
| 2514 | brif ); |
|---|
| 2515 | } |
|---|
| 2516 | else |
|---|
| 2517 | { |
|---|
| 2518 | sscanf( buf, "%s", brif ); |
|---|
| 2519 | websWrite( wp, "%s ", brif ); |
|---|
| 2520 | } |
|---|
| 2521 | } |
|---|
| 2522 | count++; |
|---|
| 2523 | } |
|---|
| 2524 | |
|---|
| 2525 | websWrite( wp, "\'" ); // close |
|---|
| 2526 | fclose( f ); |
|---|
| 2527 | unlink( "/tmp/.brtable" ); |
|---|
| 2528 | } |
|---|
| 2529 | return; |
|---|
| 2530 | } |
|---|
| 2531 | |
|---|
| 2532 | void ej_show_bridgeifnames( webs_t wp, int argc, char_t ** argv ) |
|---|
| 2533 | { |
|---|
| 2534 | char bufferif[512]; |
|---|
| 2535 | char bufferif2[256]; |
|---|
| 2536 | char finalbuffer[512]; |
|---|
| 2537 | int count = 0; |
|---|
| 2538 | static char word[256]; |
|---|
| 2539 | char *next, *wordlist; |
|---|
| 2540 | |
|---|
| 2541 | memset( bufferif, 0, 512 ); |
|---|
| 2542 | memset( bufferif2, 0, 256 ); |
|---|
| 2543 | getIfList( bufferif, "eth" ); |
|---|
| 2544 | #ifdef HAVE_GATEWORX |
|---|
| 2545 | getIfList( bufferif2, "ixp" ); |
|---|
| 2546 | sprintf( bufferif, "%s %s", bufferif, bufferif2 ); |
|---|
| 2547 | #endif |
|---|
| 2548 | |
|---|
| 2549 | memset( bufferif2, 0, 256 ); |
|---|
| 2550 | getIfList( bufferif2, "vlan" ); |
|---|
| 2551 | sprintf( bufferif, "%s %s", bufferif, bufferif2 ); |
|---|
| 2552 | |
|---|
| 2553 | memset( bufferif2, 0, 256 ); |
|---|
| 2554 | getIfList( bufferif2, "wl" ); |
|---|
| 2555 | sprintf( bufferif, "%s %s", bufferif, bufferif2 ); |
|---|
| 2556 | |
|---|
| 2557 | memset( bufferif2, 0, 256 ); |
|---|
| 2558 | getIfList( bufferif2, "ofdm" ); |
|---|
| 2559 | sprintf( bufferif, "%s %s", bufferif, bufferif2 ); |
|---|
| 2560 | |
|---|
| 2561 | memset( bufferif2, 0, 256 ); |
|---|
| 2562 | getIfList( bufferif2, "br" ); |
|---|
| 2563 | foreach( word, bufferif2, next ) |
|---|
| 2564 | { |
|---|
| 2565 | if( contains( word, '.' ) ) |
|---|
| 2566 | sprintf( bufferif, "%s %s", bufferif, word ); |
|---|
| 2567 | } |
|---|
| 2568 | int i; |
|---|
| 2569 | |
|---|
| 2570 | #ifdef HAVE_MADWIFI |
|---|
| 2571 | memset( bufferif2, 0, 256 ); |
|---|
| 2572 | getIfList( bufferif2, "ath" ); |
|---|
| 2573 | foreach( word, bufferif2, next ) |
|---|
| 2574 | { |
|---|
| 2575 | if( contains( word, '.' ) ) |
|---|
| 2576 | sprintf( bufferif, "%s %s", bufferif, word ); |
|---|
| 2577 | } |
|---|
| 2578 | int c = getifcount( "wifi" ); |
|---|
| 2579 | |
|---|
| 2580 | for( i = 0; i < c; i++ ) |
|---|
| 2581 | { |
|---|
| 2582 | char ath[32]; |
|---|
| 2583 | |
|---|
| 2584 | sprintf( ath, "ath%d_bridged", i ); |
|---|
| 2585 | if( nvram_default_match( ath, "1", "1" ) ) |
|---|
| 2586 | { |
|---|
| 2587 | sprintf( bufferif, "%s ath%d", bufferif, i ); |
|---|
| 2588 | char vifs[32]; |
|---|
| 2589 | |
|---|
| 2590 | sprintf( vifs, "ath%d_vifs", i ); |
|---|
| 2591 | sprintf( bufferif, "%s %s", bufferif, nvram_safe_get( vifs ) ); |
|---|
| 2592 | } |
|---|
| 2593 | } |
|---|
| 2594 | #endif |
|---|
| 2595 | #ifdef HAVE_BONDING |
|---|
| 2596 | c = atoi( nvram_default_get( "bonding_number", "1" ) ); |
|---|
| 2597 | for( i = 0; i < c; i++ ) |
|---|
| 2598 | { |
|---|
| 2599 | sprintf( bufferif, "%s bond%d", bufferif, i ); |
|---|
| 2600 | } |
|---|
| 2601 | #endif |
|---|
| 2602 | #ifdef HAVE_EOP_TUNNEL |
|---|
| 2603 | for( i = 1; i < 11; i++ ) |
|---|
| 2604 | { |
|---|
| 2605 | char EOP[32]; |
|---|
| 2606 | |
|---|
| 2607 | if( nvram_nmatch( "1", "oet%d_bridged", i ) |
|---|
| 2608 | && nvram_nmatch( "1", "oet%d_en", i ) ) |
|---|
| 2609 | { |
|---|
| 2610 | sprintf( EOP, "EOP%d", i ); |
|---|
| 2611 | sprintf( bufferif, "%s %s", bufferif, EOP ); |
|---|
| 2612 | } |
|---|
| 2613 | } |
|---|
| 2614 | #endif |
|---|
| 2615 | char buffer[256]; |
|---|
| 2616 | |
|---|
| 2617 | memset( buffer, 0, 256 ); |
|---|
| 2618 | getIfList( buffer, "br" ); |
|---|
| 2619 | |
|---|
| 2620 | memset( finalbuffer, 0, 256 ); |
|---|
| 2621 | foreach( word, buffer, next ) |
|---|
| 2622 | { |
|---|
| 2623 | if( !contains( word, '.' ) ) |
|---|
| 2624 | sprintf( finalbuffer, "%s %s", finalbuffer, word ); |
|---|
| 2625 | } |
|---|
| 2626 | |
|---|
| 2627 | int realcount = atoi( nvram_default_get( "bridgesif_count", "0" ) ); |
|---|
| 2628 | |
|---|
| 2629 | wordlist = nvram_safe_get( "bridgesif" ); |
|---|
| 2630 | foreach( word, wordlist, next ) |
|---|
| 2631 | { |
|---|
| 2632 | char *port = word; |
|---|
| 2633 | char *tag = strsep( &port, ">" ); |
|---|
| 2634 | char *prio = port; |
|---|
| 2635 | |
|---|
| 2636 | strsep( &prio, ">" ); |
|---|
| 2637 | if( !tag || !port ) |
|---|
| 2638 | break; |
|---|
| 2639 | char vlan_name[32]; |
|---|
| 2640 | |
|---|
| 2641 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2642 | websWrite( wp, "<div class=\"label\">Assignment %d</div>\n", count ); |
|---|
| 2643 | sprintf( vlan_name, "bridge%d", count ); |
|---|
| 2644 | showOptions( wp, vlan_name, finalbuffer, tag ); |
|---|
| 2645 | websWrite( wp, " Interface " ); |
|---|
| 2646 | sprintf( vlan_name, "bridgeif%d", count ); |
|---|
| 2647 | showOptions( wp, vlan_name, bufferif, port ); |
|---|
| 2648 | websWrite( wp, " Prio " ); |
|---|
| 2649 | sprintf( vlan_name, "bridgeifprio%d", count ); |
|---|
| 2650 | websWrite( wp, |
|---|
| 2651 | "<input class=\"num\" name=\"%s\"size=\"3\" value=\"%s\" />\n", |
|---|
| 2652 | vlan_name, prio != NULL ? prio : "63" ); |
|---|
| 2653 | websWrite( wp, |
|---|
| 2654 | "<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", |
|---|
| 2655 | count ); |
|---|
| 2656 | websWrite( wp, "</div>\n" ); |
|---|
| 2657 | count++; |
|---|
| 2658 | } |
|---|
| 2659 | int totalcount = count; |
|---|
| 2660 | |
|---|
| 2661 | for( i = count; i < realcount; i++ ) |
|---|
| 2662 | { |
|---|
| 2663 | char vlan_name[32]; |
|---|
| 2664 | |
|---|
| 2665 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2666 | websWrite( wp, "<div class=\"label\">Assignment %d</div>\n", i ); |
|---|
| 2667 | sprintf( vlan_name, "bridge%d", i ); |
|---|
| 2668 | showOptions( wp, vlan_name, finalbuffer, "" ); |
|---|
| 2669 | websWrite( wp, " Interface " ); |
|---|
| 2670 | sprintf( vlan_name, "bridgeif%d", i ); |
|---|
| 2671 | showOptions( wp, vlan_name, bufferif, "" ); |
|---|
| 2672 | websWrite( wp, " Prio " ); |
|---|
| 2673 | sprintf( vlan_name, "bridgeifprio%d", i ); |
|---|
| 2674 | websWrite( wp, |
|---|
| 2675 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2676 | vlan_name, "63" ); |
|---|
| 2677 | websWrite( wp, |
|---|
| 2678 | "<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", |
|---|
| 2679 | i ); |
|---|
| 2680 | websWrite( wp, "</div>\n" ); |
|---|
| 2681 | totalcount++; |
|---|
| 2682 | } |
|---|
| 2683 | websWrite( wp, |
|---|
| 2684 | "<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" ); |
|---|
| 2685 | char var[32]; |
|---|
| 2686 | |
|---|
| 2687 | sprintf( var, "%d", totalcount ); |
|---|
| 2688 | nvram_set( "bridgesif_count", var ); |
|---|
| 2689 | } |
|---|
| 2690 | |
|---|
| 2691 | #endif |
|---|
| 2692 | #if 0 |
|---|
| 2693 | static void |
|---|
| 2694 | showDynOption( webs_t wp, char *propname, char *nvname, char *options[], |
|---|
| 2695 | char *names[] ) |
|---|
| 2696 | { |
|---|
| 2697 | int i; |
|---|
| 2698 | |
|---|
| 2699 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2700 | websWrite( wp, |
|---|
| 2701 | "<div class=\"label\">%s</div><select name=\"%s\">\n", |
|---|
| 2702 | propname, nvname ); |
|---|
| 2703 | for( i = 0; options[i] != NULL; i++ ) |
|---|
| 2704 | { |
|---|
| 2705 | websWrite( wp, |
|---|
| 2706 | "<option value=\"%s\" %s>Off</option>\n", |
|---|
| 2707 | names[i], nvram_match( nvname, |
|---|
| 2708 | options[i] ) ? |
|---|
| 2709 | "selected=\"selected\"" : "" ); |
|---|
| 2710 | } |
|---|
| 2711 | websWrite( wp, "</div>\n" ); |
|---|
| 2712 | |
|---|
| 2713 | } |
|---|
| 2714 | #endif |
|---|
| 2715 | #ifdef HAVE_MSSID |
|---|
| 2716 | |
|---|
| 2717 | static void show_channel( webs_t wp, char *dev, char *prefix, int type ) |
|---|
| 2718 | { |
|---|
| 2719 | char wl_mode[16]; |
|---|
| 2720 | |
|---|
| 2721 | sprintf( wl_mode, "%s_mode", prefix ); |
|---|
| 2722 | char wl_net_mode[16]; |
|---|
| 2723 | |
|---|
| 2724 | sprintf( wl_net_mode, "%s_net_mode", prefix ); |
|---|
| 2725 | if( nvram_match( wl_net_mode, "disabled" ) ) |
|---|
| 2726 | return; |
|---|
| 2727 | if( nvram_match( wl_mode, "ap" ) || nvram_match( wl_mode, "wdsap" ) |
|---|
| 2728 | || nvram_match( wl_mode, "infra" ) ) |
|---|
| 2729 | { |
|---|
| 2730 | char wl_channel[16]; |
|---|
| 2731 | |
|---|
| 2732 | sprintf( wl_channel, "%s_channel", prefix ); |
|---|
| 2733 | char wl_wchannel[16]; |
|---|
| 2734 | |
|---|
| 2735 | sprintf( wl_wchannel, "%s_wchannel", prefix ); |
|---|
| 2736 | char wl_nbw[16]; |
|---|
| 2737 | |
|---|
| 2738 | sprintf( wl_nbw, "%s_nbw", prefix ); |
|---|
| 2739 | |
|---|
| 2740 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2741 | websWrite( wp, |
|---|
| 2742 | "<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", |
|---|
| 2743 | wl_channel ); |
|---|
| 2744 | #ifdef HAVE_MADWIFI |
|---|
| 2745 | struct wifi_channels *chan; |
|---|
| 2746 | char cn[32]; |
|---|
| 2747 | char fr[32]; |
|---|
| 2748 | |
|---|
| 2749 | chan = list_channels( prefix ); |
|---|
| 2750 | if( chan == NULL ) |
|---|
| 2751 | chan = list_channels( dev ); |
|---|
| 2752 | if( chan != NULL ) |
|---|
| 2753 | { |
|---|
| 2754 | // int cnt = getchannelcount (); |
|---|
| 2755 | websWrite( wp, |
|---|
| 2756 | "document.write(\"<option value=\\\"0\\\" %s>\" + share.auto + \"</option>\");\n", |
|---|
| 2757 | nvram_match( wl_channel, |
|---|
| 2758 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 2759 | "" ); |
|---|
| 2760 | int i = 0; |
|---|
| 2761 | |
|---|
| 2762 | while( chan[i].freq != -1 ) |
|---|
| 2763 | { |
|---|
| 2764 | cprintf( "%d\n", chan[i].channel ); |
|---|
| 2765 | cprintf( "%d\n", chan[i].freq ); |
|---|
| 2766 | |
|---|
| 2767 | sprintf( cn, "%d", chan[i].channel ); |
|---|
| 2768 | sprintf( fr, "%d", chan[i].freq ); |
|---|
| 2769 | #ifdef HAVE_XR4SPECIAL |
|---|
| 2770 | char ofs[32]; |
|---|
| 2771 | |
|---|
| 2772 | sprintf( ofs, "%s_offset", prefix ); |
|---|
| 2773 | websWrite( wp, |
|---|
| 2774 | "document.write(\"<option value=\\\"%s\\\" %s>%s - %d MHz</option>\");\n", |
|---|
| 2775 | fr, nvram_match( wl_channel, |
|---|
| 2776 | fr ) ? "selected=\\\"selected\\\"" |
|---|
| 2777 | : "", cn, |
|---|
| 2778 | chan[i].freq + |
|---|
| 2779 | atoi( nvram_default_get( ofs, "0" ) ) ); |
|---|
| 2780 | #else |
|---|
| 2781 | websWrite( wp, |
|---|
| 2782 | "document.write(\"<option value=\\\"%s\\\" %s>%s - %d MHz</option>\");\n", |
|---|
| 2783 | fr, nvram_match( wl_channel, |
|---|
| 2784 | fr ) ? "selected=\\\"selected\\\"" |
|---|
| 2785 | : "", cn, |
|---|
| 2786 | ( chan[i].freq + get_wifioffset( prefix ) ) ); |
|---|
| 2787 | #endif |
|---|
| 2788 | // free (chan[i].freq); |
|---|
| 2789 | i++; |
|---|
| 2790 | } |
|---|
| 2791 | free( chan ); |
|---|
| 2792 | } |
|---|
| 2793 | #else |
|---|
| 2794 | int instance = 0; |
|---|
| 2795 | |
|---|
| 2796 | if( !strcmp( prefix, "wl1" ) ) |
|---|
| 2797 | instance = 1; |
|---|
| 2798 | if( type == 1 && !nvram_match( wl_net_mode, "g-only" ) |
|---|
| 2799 | && !nvram_match( wl_net_mode, "a-only" ) |
|---|
| 2800 | && !nvram_match( wl_net_mode, "bg-mixed" ) |
|---|
| 2801 | && nvram_match( wl_nbw, "40" ) ) |
|---|
| 2802 | { |
|---|
| 2803 | int ch = atoi( nvram_nget( "wl%d_wchannel", instance ) ); |
|---|
| 2804 | |
|---|
| 2805 | websWrite( wp, "var max_channel = 2;\n" ); |
|---|
| 2806 | websWrite( wp, "var wl%d_channel = '%s';\n", instance, |
|---|
| 2807 | nvram_safe_get( wl_wchannel ) ); |
|---|
| 2808 | websWrite( wp, |
|---|
| 2809 | "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" ); |
|---|
| 2810 | char *sel = ""; |
|---|
| 2811 | |
|---|
| 2812 | if( nvram_nmatch( "lower", "wl%d_nctrlsb", instance ) ) |
|---|
| 2813 | sel = "selected"; |
|---|
| 2814 | |
|---|
| 2815 | websWrite( wp, |
|---|
| 2816 | " document.write(\"<option value=%d %s>%d - \"+freq[%d]+\" GHz</option>\");\n", |
|---|
| 2817 | ch - 2, sel, ch - 2, ch - 2 ); |
|---|
| 2818 | if( nvram_nmatch( "upper", "wl%d_nctrlsb", instance ) ) |
|---|
| 2819 | sel = "selected"; |
|---|
| 2820 | websWrite( wp, |
|---|
| 2821 | " document.write(\"<option value=%d %s>%d - \"+freq[%d]+\" GHz</option>\");\n", |
|---|
| 2822 | ch + 2, sel, ch + 2, ch + 2 ); |
|---|
| 2823 | |
|---|
| 2824 | } |
|---|
| 2825 | else |
|---|
| 2826 | { |
|---|
| 2827 | |
|---|
| 2828 | unsigned int chanlist[128]; |
|---|
| 2829 | char *ifn = get_wl_instance_name( instance ); |
|---|
| 2830 | int chancount = getchannels( chanlist, ifn ); |
|---|
| 2831 | |
|---|
| 2832 | websWrite( wp, "var max_channel = %d;\n", chancount ); |
|---|
| 2833 | websWrite( wp, "var wl%d_channel = '%s';\n", instance, |
|---|
| 2834 | nvram_safe_get( wl_channel ) ); |
|---|
| 2835 | websWrite( wp, "var offset = %d;\n", chanlist[0] ); |
|---|
| 2836 | websWrite( wp, "var buf = \"\";\n" ); |
|---|
| 2837 | websWrite( wp, "var freq = new Array(\"Auto\"" ); |
|---|
| 2838 | int i; |
|---|
| 2839 | |
|---|
| 2840 | for( i = 0; i < chancount; i++ ) |
|---|
| 2841 | { |
|---|
| 2842 | float ofs; |
|---|
| 2843 | |
|---|
| 2844 | if( chanlist[i] < 25 ) |
|---|
| 2845 | ofs = 2.407f; |
|---|
| 2846 | else |
|---|
| 2847 | ofs = 5.000f; |
|---|
| 2848 | ofs += ( float )( chanlist[i] * 0.005f ); |
|---|
| 2849 | if( ofs == 2.477f ) |
|---|
| 2850 | ofs = 2.484f; // fix: ch 14 is 2.484, not 2.477 GHz |
|---|
| 2851 | websWrite( wp, ", \"%0.3f\"", ofs ); |
|---|
| 2852 | } |
|---|
| 2853 | websWrite( wp, ");\n" ); |
|---|
| 2854 | websWrite( wp, "for(i=0; i<=max_channel ; i++) {\n" ); |
|---|
| 2855 | websWrite( wp, " if(i == wl%d_channel) buf = \"selected\";\n", |
|---|
| 2856 | instance ); |
|---|
| 2857 | websWrite( wp, " else buf = \"\";\n" ); |
|---|
| 2858 | websWrite( wp, " if (i==0)\n" ); |
|---|
| 2859 | websWrite( wp, |
|---|
| 2860 | " document.write(\"<option value=\"+i+\" \"+buf+\">\" + share.auto + \"</option>\");\n" ); |
|---|
| 2861 | websWrite( wp, " else\n" ); |
|---|
| 2862 | websWrite( wp, |
|---|
| 2863 | " document.write(\"<option value=\"+i+\" \"+buf+\">\"+(i+offset-1)+\" - \"+freq[i]+\" GHz</option>\");\n" ); |
|---|
| 2864 | websWrite( wp, "}\n" ); |
|---|
| 2865 | } |
|---|
| 2866 | #endif |
|---|
| 2867 | websWrite( wp, "//]]>\n</script></select></div>\n" ); |
|---|
| 2868 | } |
|---|
| 2869 | } |
|---|
| 2870 | |
|---|
| 2871 | #ifdef HAVE_MADWIFI |
|---|
| 2872 | static char *ag_rates[] = { "6", "9", "12", "18", "24", "36", "48", "54" }; |
|---|
| 2873 | static char *turbo_rates[] = |
|---|
| 2874 | { "12", "18", "24", "36", "48", "72", "96", "108" }; |
|---|
| 2875 | static char *b_rates[] = { "1", "2", "5.5", "11" }; |
|---|
| 2876 | static char *bg_rates[] = |
|---|
| 2877 | { "1", "2", "5.5", "6", "9", "11", "12", "18", "24", "36", "48", "54" }; |
|---|
| 2878 | // static char *g_rates[] = { "1", "2", "5.5", "11", "12", "18", "24", "36", |
|---|
| 2879 | // "48", "54" }; |
|---|
| 2880 | //static char *xr_rates[] = |
|---|
| 2881 | // { "0.25", "0.5", "1", "2", "3", "6", "9", "12", "18", "24", "36", "48", |
|---|
| 2882 | // "54" |
|---|
| 2883 | //}; |
|---|
| 2884 | static char *half_rates[] = { "3", "4.5", "6", "9", "12", "18", "24", "27" }; |
|---|
| 2885 | static char *quarter_rates[] = |
|---|
| 2886 | { "1.5", "2", "3", "4.5", "6", "9", "12", "13.5" }; |
|---|
| 2887 | |
|---|
| 2888 | void show_rates( webs_t wp, char *prefix, int maxrate ) |
|---|
| 2889 | { |
|---|
| 2890 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2891 | if( maxrate ) |
|---|
| 2892 | { |
|---|
| 2893 | websWrite( wp, |
|---|
| 2894 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label21)</script></div>\n" ); |
|---|
| 2895 | websWrite( wp, "<select name=\"%s_maxrate\">\n", prefix ); |
|---|
| 2896 | } |
|---|
| 2897 | else |
|---|
| 2898 | { |
|---|
| 2899 | websWrite( wp, |
|---|
| 2900 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label23)</script></div>\n" ); |
|---|
| 2901 | websWrite( wp, "<select name=\"%s_minrate\">\n", prefix ); |
|---|
| 2902 | } |
|---|
| 2903 | websWrite( wp, "<script type=\"text/javascript\">\n" ); |
|---|
| 2904 | websWrite( wp, "//<![CDATA[\n" ); |
|---|
| 2905 | char srate[32]; |
|---|
| 2906 | |
|---|
| 2907 | sprintf( srate, "%s_minrate", prefix ); |
|---|
| 2908 | char mxrate[32]; |
|---|
| 2909 | |
|---|
| 2910 | sprintf( mxrate, "%s_maxrate", prefix ); |
|---|
| 2911 | websWrite( wp, |
|---|
| 2912 | "document.write(\"<option value=\\\"0\\\" %s >\" + share.auto + \"</option>\");\n", |
|---|
| 2913 | nvram_match( srate, "0" ) ? "selected" : "" ); |
|---|
| 2914 | websWrite( wp, "//]]>\n" ); |
|---|
| 2915 | websWrite( wp, "</script>\n" ); |
|---|
| 2916 | char **rate; |
|---|
| 2917 | char **showrates = NULL; |
|---|
| 2918 | int len; |
|---|
| 2919 | char mode[32]; |
|---|
| 2920 | char bw[16]; |
|---|
| 2921 | |
|---|
| 2922 | sprintf( bw, "%s_channelbw", prefix ); |
|---|
| 2923 | |
|---|
| 2924 | sprintf( mode, "%s_net_mode", prefix ); |
|---|
| 2925 | if( nvram_match( mode, "b-only" ) ) |
|---|
| 2926 | { |
|---|
| 2927 | rate = b_rates; |
|---|
| 2928 | len = sizeof( b_rates ) / sizeof( char * ); |
|---|
| 2929 | } |
|---|
| 2930 | if( nvram_match( mode, "g-only" ) ) |
|---|
| 2931 | { |
|---|
| 2932 | rate = ag_rates; |
|---|
| 2933 | len = sizeof( ag_rates ) / sizeof( char * ); |
|---|
| 2934 | if( nvram_match( bw, "40" ) ) |
|---|
| 2935 | { |
|---|
| 2936 | showrates = turbo_rates; |
|---|
| 2937 | } |
|---|
| 2938 | if( nvram_match( bw, "10" ) ) |
|---|
| 2939 | { |
|---|
| 2940 | rate = half_rates; |
|---|
| 2941 | len = sizeof( half_rates ) / sizeof( char * ); |
|---|
| 2942 | } |
|---|
| 2943 | if( nvram_match( bw, "5" ) ) |
|---|
| 2944 | { |
|---|
| 2945 | rate = quarter_rates; |
|---|
| 2946 | len = sizeof( quarter_rates ) / sizeof( char * ); |
|---|
| 2947 | } |
|---|
| 2948 | } |
|---|
| 2949 | if( nvram_match( mode, "a-only" ) ) |
|---|
| 2950 | { |
|---|
| 2951 | rate = ag_rates; |
|---|
| 2952 | len = sizeof( ag_rates ) / sizeof( char * ); |
|---|
| 2953 | if( nvram_match( bw, "40" ) ) |
|---|
| 2954 | { |
|---|
| 2955 | showrates = turbo_rates; |
|---|
| 2956 | } |
|---|
| 2957 | if( nvram_match( bw, "10" ) ) |
|---|
| 2958 | { |
|---|
| 2959 | rate = half_rates; |
|---|
| 2960 | len = sizeof( half_rates ) / sizeof( char * ); |
|---|
| 2961 | } |
|---|
| 2962 | if( nvram_match( bw, "5" ) ) |
|---|
| 2963 | { |
|---|
| 2964 | rate = quarter_rates; |
|---|
| 2965 | len = sizeof( quarter_rates ) / sizeof( char * ); |
|---|
| 2966 | } |
|---|
| 2967 | } |
|---|
| 2968 | if( nvram_match( mode, "bg-mixed" ) ) |
|---|
| 2969 | { |
|---|
| 2970 | rate = bg_rates; |
|---|
| 2971 | len = sizeof( bg_rates ) / sizeof( char * ); |
|---|
| 2972 | if( nvram_match( bw, "10" ) ) |
|---|
| 2973 | { |
|---|
| 2974 | rate = half_rates; |
|---|
| 2975 | len = sizeof( half_rates ) / sizeof( char * ); |
|---|
| 2976 | } |
|---|
| 2977 | if( nvram_match( bw, "5" ) ) |
|---|
| 2978 | { |
|---|
| 2979 | rate = quarter_rates; |
|---|
| 2980 | len = sizeof( quarter_rates ) / sizeof( char * ); |
|---|
| 2981 | } |
|---|
| 2982 | } |
|---|
| 2983 | if( nvram_match( mode, "mixed" ) ) |
|---|
| 2984 | { |
|---|
| 2985 | rate = bg_rates; |
|---|
| 2986 | len = sizeof( bg_rates ) / sizeof( char * ); |
|---|
| 2987 | if( nvram_match( bw, "40" ) ) |
|---|
| 2988 | { |
|---|
| 2989 | rate = ag_rates; |
|---|
| 2990 | len = sizeof( ag_rates ) / sizeof( char * ); |
|---|
| 2991 | showrates = turbo_rates; |
|---|
| 2992 | } |
|---|
| 2993 | if( nvram_match( bw, "10" ) ) |
|---|
| 2994 | { |
|---|
| 2995 | rate = half_rates; |
|---|
| 2996 | len = sizeof( half_rates ) / sizeof( char * ); |
|---|
| 2997 | } |
|---|
| 2998 | if( nvram_match( bw, "5" ) ) |
|---|
| 2999 | { |
|---|
| 3000 | rate = quarter_rates; |
|---|
| 3001 | len = sizeof( quarter_rates ) / sizeof( char * ); |
|---|
| 3002 | } |
|---|
| 3003 | } |
|---|
| 3004 | int i; |
|---|
| 3005 | |
|---|
| 3006 | for( i = 0; i < len; i++ ) |
|---|
| 3007 | { |
|---|
| 3008 | if( maxrate ) |
|---|
| 3009 | { |
|---|
| 3010 | int offset = 0; |
|---|
| 3011 | |
|---|
| 3012 | if( nvram_match( mode, "g-only" ) && nvram_match( bw, "20" ) ) |
|---|
| 3013 | offset = 4; |
|---|
| 3014 | char comp[32]; |
|---|
| 3015 | |
|---|
| 3016 | sprintf( comp, "%d", i + 1 + offset ); |
|---|
| 3017 | if( showrates ) |
|---|
| 3018 | websWrite( wp, "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 3019 | i + 1 + offset, nvram_match( mxrate, |
|---|
| 3020 | comp ) ? "selected" : |
|---|
| 3021 | "", showrates[i] ); |
|---|
| 3022 | else |
|---|
| 3023 | websWrite( wp, "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 3024 | i + 1 + offset, nvram_match( mxrate, |
|---|
| 3025 | comp ) ? "selected" : |
|---|
| 3026 | "", rate[i] ); |
|---|
| 3027 | } |
|---|
| 3028 | else |
|---|
| 3029 | { |
|---|
| 3030 | int offset = 0; |
|---|
| 3031 | |
|---|
| 3032 | if( nvram_match( mode, "g-only" ) && nvram_match( bw, "20" ) ) |
|---|
| 3033 | offset = 4; |
|---|
| 3034 | char comp[32]; |
|---|
| 3035 | |
|---|
| 3036 | sprintf( comp, "%d", i + 1 + offset ); |
|---|
| 3037 | if( showrates ) |
|---|
| 3038 | websWrite( wp, "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 3039 | i + 1 + offset, nvram_match( srate, |
|---|
| 3040 | comp ) ? "selected" : |
|---|
| 3041 | "", showrates[i] ); |
|---|
| 3042 | else |
|---|
| 3043 | websWrite( wp, "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 3044 | i + 1 + offset, nvram_match( srate, |
|---|
| 3045 | comp ) ? "selected" : |
|---|
| 3046 | "", rate[i] ); |
|---|
| 3047 | |
|---|
| 3048 | } |
|---|
| 3049 | } |
|---|
| 3050 | websWrite( wp, "</select>\n" ); |
|---|
| 3051 | websWrite( wp, "<span class=\"default\">\n" ); |
|---|
| 3052 | websWrite( wp, "<script type=\"text/javascript\">\n" ); |
|---|
| 3053 | websWrite( wp, "//<![CDATA[\n" ); |
|---|
| 3054 | websWrite( wp, |
|---|
| 3055 | "document.write(\"(\" + share.deflt + \": \" + share.auto + \")\");\n" ); |
|---|
| 3056 | websWrite( wp, "//]]\n" ); |
|---|
| 3057 | websWrite( wp, "</script></span></div>\n" ); |
|---|
| 3058 | |
|---|
| 3059 | } |
|---|
| 3060 | #endif |
|---|
| 3061 | static void show_netmode( webs_t wp, char *prefix ) |
|---|
| 3062 | { |
|---|
| 3063 | char wl_net_mode[16]; |
|---|
| 3064 | |
|---|
| 3065 | sprintf( wl_net_mode, "%s_net_mode", prefix ); |
|---|
| 3066 | |
|---|
| 3067 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3068 | websWrite( wp, |
|---|
| 3069 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label2)</script></div><select name=\"%s\" onchange=\"SelWL(this.form.%s.selectedIndex,this.form)\">\n", |
|---|
| 3070 | wl_net_mode, wl_net_mode ); |
|---|
| 3071 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 3072 | websWrite( wp, |
|---|
| 3073 | "document.write(\"<option value=\\\"disabled\\\" %s>\" + share.disabled + \"</option>\");\n", |
|---|
| 3074 | nvram_match( wl_net_mode, |
|---|
| 3075 | "disabled" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3076 | websWrite( wp, |
|---|
| 3077 | "document.write(\"<option value=\\\"mixed\\\" %s>\" + wl_basic.mixed + \"</option>\");\n", |
|---|
| 3078 | nvram_match( wl_net_mode, |
|---|
| 3079 | "mixed" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3080 | if( has_mimo( prefix ) ) |
|---|
| 3081 | { |
|---|
| 3082 | websWrite( wp, |
|---|
| 3083 | "document.write(\"<option value=\\\"bg-mixed\\\" %s>\" + wl_basic.bg + \"</option>\");\n", |
|---|
| 3084 | nvram_match( wl_net_mode, |
|---|
| 3085 | "bg-mixed" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3086 | "" ); |
|---|
| 3087 | } |
|---|
| 3088 | #ifdef HAVE_WHRAG108 |
|---|
| 3089 | if( !strcmp( prefix, "ath1" ) ) |
|---|
| 3090 | #endif |
|---|
| 3091 | #ifdef HAVE_TW6600 |
|---|
| 3092 | if( !strcmp( prefix, "ath1" ) ) |
|---|
| 3093 | #endif |
|---|
| 3094 | websWrite( wp, |
|---|
| 3095 | "document.write(\"<option value=\\\"b-only\\\" %s>\" + wl_basic.b + \"</option>\");\n", |
|---|
| 3096 | nvram_match( wl_net_mode, |
|---|
| 3097 | "b-only" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3098 | "" ); |
|---|
| 3099 | #ifdef HAVE_MADWIFI |
|---|
| 3100 | #ifdef HAVE_WHRAG108 |
|---|
| 3101 | if( !strcmp( prefix, "ath1" ) ) |
|---|
| 3102 | #endif |
|---|
| 3103 | #ifdef HAVE_TW6600 |
|---|
| 3104 | if( !strcmp( prefix, "ath1" ) ) |
|---|
| 3105 | #endif |
|---|
| 3106 | websWrite( wp, |
|---|
| 3107 | "document.write(\"<option value=\\\"g-only\\\" %s>\" + wl_basic.g + \"</option>\");\n", |
|---|
| 3108 | nvram_match( wl_net_mode, |
|---|
| 3109 | "g-only" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3110 | "" ); |
|---|
| 3111 | #ifdef HAVE_WHRAG108 |
|---|
| 3112 | if( !strcmp( prefix, "ath1" ) ) |
|---|
| 3113 | #endif |
|---|
| 3114 | #ifdef HAVE_TW6600 |
|---|
| 3115 | if( !strcmp( prefix, "ath1" ) ) |
|---|
| 3116 | #endif |
|---|
| 3117 | #ifndef HAVE_LS5 |
|---|
| 3118 | websWrite( wp, |
|---|
| 3119 | "document.write(\"<option value=\\\"bg-mixed\\\" %s>\" + wl_basic.bg + \"</option>\");\n", |
|---|
| 3120 | nvram_match( wl_net_mode, |
|---|
| 3121 | "bg-mixed" ) ? "selected=\\\"selected\\\"" |
|---|
| 3122 | : "" ); |
|---|
| 3123 | #endif |
|---|
| 3124 | #else |
|---|
| 3125 | #ifdef HAVE_WHRAG108 |
|---|
| 3126 | if( !strcmp( prefix, "ath1" ) ) |
|---|
| 3127 | #endif |
|---|
| 3128 | #ifndef HAVE_LS5 |
|---|
| 3129 | websWrite( wp, |
|---|
| 3130 | "document.write(\"<option value=\\\"g-only\\\" %s>\" + wl_basic.g + \"</option>\");\n", |
|---|
| 3131 | nvram_match( wl_net_mode, |
|---|
| 3132 | "g-only" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3133 | "" ); |
|---|
| 3134 | #endif |
|---|
| 3135 | #endif |
|---|
| 3136 | if( has_mimo( prefix ) ) |
|---|
| 3137 | { |
|---|
| 3138 | websWrite( wp, |
|---|
| 3139 | "document.write(\"<option value=\\\"n-only\\\" %s>\" + wl_basic.n + \"</option>\");\n", |
|---|
| 3140 | nvram_match( wl_net_mode, |
|---|
| 3141 | "n-only" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3142 | "" ); |
|---|
| 3143 | } |
|---|
| 3144 | #if !defined(HAVE_FONERA) && !defined(HAVE_LS2) && !defined(HAVE_MERAKI) |
|---|
| 3145 | #ifndef HAVE_MADWIFI |
|---|
| 3146 | |
|---|
| 3147 | if( nvram_match( "wl0_phytypes", "ga" ) |
|---|
| 3148 | || nvram_match( "wl0_phytypes", "a" ) ) |
|---|
| 3149 | websWrite( wp, |
|---|
| 3150 | "document.write(\"<option value=\\\"a-only\\\" %s>\" + wl_basic.a + \"</option>\");\n", |
|---|
| 3151 | nvram_match( wl_net_mode, |
|---|
| 3152 | "a-only" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3153 | "" ); |
|---|
| 3154 | #else |
|---|
| 3155 | #if HAVE_WHRAG108 |
|---|
| 3156 | if( !strcmp( prefix, "ath0" ) ) |
|---|
| 3157 | #endif |
|---|
| 3158 | #ifdef HAVE_TW6600 |
|---|
| 3159 | if( !strcmp( prefix, "ath0" ) ) |
|---|
| 3160 | #endif |
|---|
| 3161 | websWrite( wp, |
|---|
| 3162 | "document.write(\"<option value=\\\"a-only\\\" %s>\" + wl_basic.a + \"</option>\");\n", |
|---|
| 3163 | nvram_match( wl_net_mode, |
|---|
| 3164 | "a-only" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3165 | "" ); |
|---|
| 3166 | #endif |
|---|
| 3167 | |
|---|
| 3168 | #endif |
|---|
| 3169 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3170 | websWrite( wp, "</select>\n" ); |
|---|
| 3171 | websWrite( wp, "</div>\n" ); |
|---|
| 3172 | } |
|---|
| 3173 | #ifdef HAVE_MADWIFI |
|---|
| 3174 | static void showrtssettings( webs_t wp, char *var ) |
|---|
| 3175 | { |
|---|
| 3176 | char ssid[32]; |
|---|
| 3177 | char vvar[32]; |
|---|
| 3178 | |
|---|
| 3179 | strcpy( vvar, var ); |
|---|
| 3180 | rep( vvar, '.', 'X' ); |
|---|
| 3181 | sprintf( ssid, "%s_rts", var ); |
|---|
| 3182 | websWrite( wp, |
|---|
| 3183 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.rts)</script></div>\n" ); |
|---|
| 3184 | websWrite( wp, |
|---|
| 3185 | "<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", |
|---|
| 3186 | vvar, var, nvram_default_match( ssid, "1", |
|---|
| 3187 | "0" ) ? "checked=\"checked\"" : |
|---|
| 3188 | "" ); |
|---|
| 3189 | websWrite( wp, |
|---|
| 3190 | "<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", |
|---|
| 3191 | vvar, var, nvram_default_match( ssid, "0", |
|---|
| 3192 | "0" ) ? "checked=\"checked\"" : |
|---|
| 3193 | "" ); |
|---|
| 3194 | websWrite( wp, "</div>\n" ); |
|---|
| 3195 | |
|---|
| 3196 | websWrite( wp, "<div id=\"%s_idrts\">\n", vvar ); |
|---|
| 3197 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3198 | websWrite( wp, |
|---|
| 3199 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.rtsvalue)</script></div>\n" ); |
|---|
| 3200 | char ip[32]; |
|---|
| 3201 | |
|---|
| 3202 | sprintf( ip, "%s_rtsvalue", var ); |
|---|
| 3203 | websWrite( wp, |
|---|
| 3204 | "<input class=\"num\" maxlength=\"4\" size=\"4\" onblur=\"valid_range(this,1,2346,share.ip)\" name=\"%s_rtsvalue\" value=\"%s\" />", |
|---|
| 3205 | var, nvram_default_get( ip, "2346" ) ); |
|---|
| 3206 | websWrite( wp, "</div>\n" ); |
|---|
| 3207 | websWrite( wp, "</div>\n" ); |
|---|
| 3208 | |
|---|
| 3209 | websWrite( wp, "<script>\n//<![CDATA[\n " ); |
|---|
| 3210 | websWrite( wp, |
|---|
| 3211 | "show_layer_ext(document.getElementsByName(\"%s_rts\"), \"%s_idrts\", %s);\n", |
|---|
| 3212 | var, vvar, nvram_match( ssid, "1" ) ? "true" : "false" ); |
|---|
| 3213 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3214 | |
|---|
| 3215 | } |
|---|
| 3216 | #endif |
|---|
| 3217 | static void showbridgesettings( webs_t wp, char *var, int mcast ) |
|---|
| 3218 | { |
|---|
| 3219 | |
|---|
| 3220 | websWrite( wp, |
|---|
| 3221 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.network)</script></div>\n" ); |
|---|
| 3222 | char ssid[32]; |
|---|
| 3223 | |
|---|
| 3224 | sprintf( ssid, "%s_bridged", var ); |
|---|
| 3225 | char vvar[32]; |
|---|
| 3226 | |
|---|
| 3227 | strcpy( vvar, var ); |
|---|
| 3228 | rep( vvar, '.', 'X' ); |
|---|
| 3229 | websWrite( wp, |
|---|
| 3230 | "<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", |
|---|
| 3231 | vvar, var, nvram_default_match( ssid, "0", |
|---|
| 3232 | "1" ) ? "checked=\"checked\"" : |
|---|
| 3233 | "" ); |
|---|
| 3234 | websWrite( wp, |
|---|
| 3235 | "<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", |
|---|
| 3236 | vvar, var, nvram_default_match( ssid, "1", |
|---|
| 3237 | "1" ) ? "checked=\"checked\"" : |
|---|
| 3238 | "" ); |
|---|
| 3239 | websWrite( wp, "</div>\n" ); |
|---|
| 3240 | |
|---|
| 3241 | websWrite( wp, "<div id=\"%s_idnetvifs\">\n", vvar ); |
|---|
| 3242 | if( mcast ) |
|---|
| 3243 | { |
|---|
| 3244 | char mcast[32]; |
|---|
| 3245 | |
|---|
| 3246 | sprintf( mcast, "%s_multicast", var ); |
|---|
| 3247 | nvram_default_get( mcast, "0" ); |
|---|
| 3248 | showRadio( wp, "wl_basic.multicast", mcast ); |
|---|
| 3249 | } |
|---|
| 3250 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3251 | websWrite( wp, |
|---|
| 3252 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.ip)</script></div>\n" ); |
|---|
| 3253 | char ip[32]; |
|---|
| 3254 | |
|---|
| 3255 | sprintf( ip, "%s_ipaddr", var ); |
|---|
| 3256 | char *ipv = nvram_safe_get( ip ); |
|---|
| 3257 | |
|---|
| 3258 | websWrite( wp, |
|---|
| 3259 | "<input type=\"hidden\" name=\"%s_ipaddr\" value=\"4\" />\n", |
|---|
| 3260 | var ); |
|---|
| 3261 | websWrite( wp, |
|---|
| 3262 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,1,223,share.ip)\" name=\"%s_ipaddr_0\" value=\"%d\" />.", |
|---|
| 3263 | var, get_single_ip( ipv, 0 ) ); |
|---|
| 3264 | websWrite( wp, |
|---|
| 3265 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_1\" value=\"%d\" />.", |
|---|
| 3266 | var, get_single_ip( ipv, 1 ) ); |
|---|
| 3267 | websWrite( wp, |
|---|
| 3268 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_2\" value=\"%d\" />.", |
|---|
| 3269 | var, get_single_ip( ipv, 2 ) ); |
|---|
| 3270 | websWrite( wp, |
|---|
| 3271 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_3\" value=\"%d\" />\n", |
|---|
| 3272 | var, get_single_ip( ipv, 3 ) ); |
|---|
| 3273 | websWrite( wp, "</div>\n" ); |
|---|
| 3274 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3275 | websWrite( wp, |
|---|
| 3276 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.subnet)</script></div>\n" ); |
|---|
| 3277 | sprintf( ip, "%s_netmask", var ); |
|---|
| 3278 | ipv = nvram_safe_get( ip ); |
|---|
| 3279 | |
|---|
| 3280 | websWrite( wp, |
|---|
| 3281 | "<input type=\"hidden\" name=\"%s_netmask\" value=\"4\" />\n", |
|---|
| 3282 | var ); |
|---|
| 3283 | websWrite( wp, |
|---|
| 3284 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_0\" value=\"%d\" />.", |
|---|
| 3285 | var, get_single_ip( ipv, 0 ) ); |
|---|
| 3286 | websWrite( wp, |
|---|
| 3287 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_1\" value=\"%d\" />.", |
|---|
| 3288 | var, get_single_ip( ipv, 1 ) ); |
|---|
| 3289 | websWrite( wp, |
|---|
| 3290 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_2\" value=\"%d\" />.", |
|---|
| 3291 | var, get_single_ip( ipv, 2 ) ); |
|---|
| 3292 | websWrite( wp, |
|---|
| 3293 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_3\" value=\"%d\" />.", |
|---|
| 3294 | var, get_single_ip( ipv, 3 ) ); |
|---|
| 3295 | websWrite( wp, "</div>\n" ); |
|---|
| 3296 | websWrite( wp, "</div>\n" ); |
|---|
| 3297 | |
|---|
| 3298 | websWrite( wp, "<script>\n//<![CDATA[\n " ); |
|---|
| 3299 | websWrite( wp, |
|---|
| 3300 | "show_layer_ext(document.getElementsByName(\"%s_bridged\"), \"%s_idnetvifs\", %s);\n", |
|---|
| 3301 | var, vvar, nvram_match( ssid, "0" ) ? "true" : "false" ); |
|---|
| 3302 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3303 | |
|---|
| 3304 | } |
|---|
| 3305 | |
|---|
| 3306 | #ifdef HAVE_MADWIFI |
|---|
| 3307 | static void show_chanshift( webs_t wp, char *prefix ) |
|---|
| 3308 | { |
|---|
| 3309 | char wl_chanshift[32]; |
|---|
| 3310 | char wl_channelbw[32]; |
|---|
| 3311 | |
|---|
| 3312 | sprintf( wl_channelbw, "%s_channelbw", prefix ); |
|---|
| 3313 | sprintf( wl_chanshift, "%s_chanshift", prefix ); |
|---|
| 3314 | if( atoi( nvram_safe_get( wl_channelbw ) ) > 5 |
|---|
| 3315 | && ( atoi( nvram_safe_get( wl_chanshift ) ) & 0xf ) > 10 ) |
|---|
| 3316 | nvram_set( wl_chanshift, "10" ); |
|---|
| 3317 | if( atoi( nvram_safe_get( wl_channelbw ) ) > 10 |
|---|
| 3318 | && ( atoi( nvram_safe_get( wl_chanshift ) ) & 0xf ) > 0 ) |
|---|
| 3319 | nvram_set( wl_chanshift, "0" ); |
|---|
| 3320 | |
|---|
| 3321 | if( nvram_match( wl_channelbw, "5" ) |
|---|
| 3322 | || nvram_match( wl_channelbw, "10" ) ) |
|---|
| 3323 | { |
|---|
| 3324 | |
|---|
| 3325 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3326 | websWrite( wp, |
|---|
| 3327 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.chanshift)</script></div>\n<select name=\"%s\">\n", |
|---|
| 3328 | wl_chanshift ); |
|---|
| 3329 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 3330 | if( nvram_match( wl_channelbw, "5" ) ) |
|---|
| 3331 | websWrite( wp, |
|---|
| 3332 | "document.write(\"<option value=\\\"-15\\\" %s >-15 Mhz</option>\");\n", |
|---|
| 3333 | nvram_default_match( wl_chanshift, "-15", |
|---|
| 3334 | "0" ) ? |
|---|
| 3335 | "selected=\\\"selected\\\"" : "" ); |
|---|
| 3336 | if( nvram_match( wl_channelbw, "5" ) |
|---|
| 3337 | || nvram_match( wl_channelbw, "10" ) ) |
|---|
| 3338 | websWrite( wp, |
|---|
| 3339 | "document.write(\"<option value=\\\"-10\\\" %s >-10 Mhz</option>\");\n", |
|---|
| 3340 | nvram_default_match( wl_chanshift, "-10", |
|---|
| 3341 | "0" ) ? |
|---|
| 3342 | "selected=\\\"selected\\\"" : "" ); |
|---|
| 3343 | if( nvram_match( wl_channelbw, "5" ) |
|---|
| 3344 | || nvram_match( wl_channelbw, "10" ) ) |
|---|
| 3345 | websWrite( wp, |
|---|
| 3346 | "document.write(\"<option value=\\\"-5\\\" %s >-5 Mhz</option>\");\n", |
|---|
| 3347 | nvram_default_match( wl_chanshift, "-5", |
|---|
| 3348 | "0" ) ? |
|---|
| 3349 | "selected=\\\"selected\\\"" : "" ); |
|---|
| 3350 | websWrite( wp, |
|---|
| 3351 | "document.write(\"<option value=\\\"0\\\" %s >0 Mhz</option>\");\n", |
|---|
| 3352 | nvram_default_match( wl_chanshift, "0", |
|---|
| 3353 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3354 | "" ); |
|---|
| 3355 | if( nvram_match( wl_channelbw, "5" ) |
|---|
| 3356 | || nvram_match( wl_channelbw, "10" ) ) |
|---|
| 3357 | websWrite( wp, |
|---|
| 3358 | "document.write(\"<option value=\\\"5\\\" %s >+5 Mhz</option>\");\n", |
|---|
| 3359 | nvram_default_match( wl_chanshift, "5", |
|---|
| 3360 | "0" ) ? |
|---|
| 3361 | "selected=\\\"selected\\\"" : "" ); |
|---|
| 3362 | if( nvram_match( wl_channelbw, "5" ) |
|---|
| 3363 | || nvram_match( wl_channelbw, "10" ) ) |
|---|
| 3364 | websWrite( wp, |
|---|
| 3365 | "document.write(\"<option value=\\\"10\\\" %s >+10 Mhz</option>\");\n", |
|---|
| 3366 | nvram_default_match( wl_chanshift, "10", |
|---|
| 3367 | "0" ) ? |
|---|
| 3368 | "selected=\\\"selected\\\"" : "" ); |
|---|
| 3369 | if( nvram_match( wl_channelbw, "5" ) ) |
|---|
| 3370 | websWrite( wp, |
|---|
| 3371 | "document.write(\"<option value=\\\"15\\\" %s >+15 Mhz</option>\");\n", |
|---|
| 3372 | nvram_default_match( wl_chanshift, "15", |
|---|
| 3373 | "0" ) ? |
|---|
| 3374 | "selected=\\\"selected\\\"" : "" ); |
|---|
| 3375 | websWrite( wp, "//]]>\n</script>\n</select>\n</div>\n" ); |
|---|
| 3376 | } |
|---|
| 3377 | } |
|---|
| 3378 | #endif |
|---|
| 3379 | static int show_virtualssid( webs_t wp, char *prefix ) |
|---|
| 3380 | { |
|---|
| 3381 | char *next; |
|---|
| 3382 | char var[80]; |
|---|
| 3383 | char ssid[80]; |
|---|
| 3384 | char vif[16]; |
|---|
| 3385 | |
|---|
| 3386 | #ifdef HAVE_MADWIFI |
|---|
| 3387 | char wmm[32]; |
|---|
| 3388 | char wl_protmode[32]; |
|---|
| 3389 | #endif |
|---|
| 3390 | sprintf( vif, "%s_vifs", prefix ); |
|---|
| 3391 | char *vifs = nvram_safe_get( vif ); |
|---|
| 3392 | |
|---|
| 3393 | if( vifs == NULL ) |
|---|
| 3394 | return 0; |
|---|
| 3395 | #ifndef HAVE_MADWIFI |
|---|
| 3396 | if( !nvram_match( "wl0_mode", "ap" ) |
|---|
| 3397 | && !nvram_match( "wl0_mode", "apsta" ) |
|---|
| 3398 | && !nvram_match( "wl0_mode", "apstawet" ) ) |
|---|
| 3399 | return 0; |
|---|
| 3400 | #endif |
|---|
| 3401 | int count = 1; |
|---|
| 3402 | |
|---|
| 3403 | websWrite( wp, |
|---|
| 3404 | "<h2><script type=\"text/javascript\">Capture(wl_basic.h2_vi)</script></h2>\n" ); |
|---|
| 3405 | foreach( var, vifs, next ) |
|---|
| 3406 | { |
|---|
| 3407 | sprintf( ssid, "%s_ssid", var ); |
|---|
| 3408 | websWrite( wp, |
|---|
| 3409 | "<fieldset><legend><script type=\"text/javascript\">Capture(share.vintrface)</script> %s SSID [", |
|---|
| 3410 | var ); |
|---|
| 3411 | tf_webWriteESCNV( wp, ssid ); // fix for broken html page if ssid |
|---|
| 3412 | // contains html tag |
|---|
| 3413 | websWrite( wp, "]</legend>\n" ); |
|---|
| 3414 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3415 | websWrite( wp, |
|---|
| 3416 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label3)</script></div>\n" ); |
|---|
| 3417 | |
|---|
| 3418 | websWrite( wp, |
|---|
| 3419 | "<input name=\"%s_ssid\" size=\"20\" maxlength=\"32\" onblur=\"valid_name(this,wl_basic.label3)\" value=\"%s\" /></div>\n", |
|---|
| 3420 | var, nvram_safe_get( ssid ) ); |
|---|
| 3421 | |
|---|
| 3422 | #ifdef HAVE_MADWIFI |
|---|
| 3423 | // sprintf( wl_chanshift, "%s_chanshift", var ); |
|---|
| 3424 | // show_chanshift( wp, wl_chanshift ); |
|---|
| 3425 | |
|---|
| 3426 | sprintf( wl_protmode, "%s_protmode", var ); |
|---|
| 3427 | showOptionsLabel( wp, "wl_basic.protmode", wl_protmode, |
|---|
| 3428 | "None CTS RTS/CTS", nvram_default_get( wl_protmode, |
|---|
| 3429 | "None" ) ); |
|---|
| 3430 | showrtssettings( wp, var ); |
|---|
| 3431 | #endif |
|---|
| 3432 | |
|---|
| 3433 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3434 | websWrite( wp, |
|---|
| 3435 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label5)</script></div>" ); |
|---|
| 3436 | sprintf( ssid, "%s_closed", var ); |
|---|
| 3437 | websWrite( wp, |
|---|
| 3438 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s_closed\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input> \n", |
|---|
| 3439 | var, nvram_match( ssid, |
|---|
| 3440 | "0" ) ? "checked=\"checked\"" : "" ); |
|---|
| 3441 | websWrite( wp, |
|---|
| 3442 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s_closed\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input>\n", |
|---|
| 3443 | var, nvram_match( ssid, |
|---|
| 3444 | "1" ) ? "checked=\"checked\"" : "" ); |
|---|
| 3445 | websWrite( wp, "</div>\n" ); |
|---|
| 3446 | char wl_mode[16]; |
|---|
| 3447 | |
|---|
| 3448 | #ifdef HAVE_MADWIFI |
|---|
| 3449 | sprintf( wl_mode, "%s_mode", var ); |
|---|
| 3450 | websWrite( wp, |
|---|
| 3451 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label)</script></div><select name=\"%s\" >\n", |
|---|
| 3452 | wl_mode ); |
|---|
| 3453 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 3454 | websWrite( wp, |
|---|
| 3455 | "document.write(\"<option value=\\\"ap\\\" %s >\" + wl_basic.ap + \"</option>\");\n", |
|---|
| 3456 | nvram_match( wl_mode, |
|---|
| 3457 | "ap" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3458 | // websWrite (wp, |
|---|
| 3459 | // "document.write(\"<option value=\\\"wdssta\\\" %s >\" + |
|---|
| 3460 | // wl_basic.wdssta + \"</option>\");\n", |
|---|
| 3461 | // nvram_match (wl_mode, |
|---|
| 3462 | // "wdssta") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3463 | websWrite( wp, |
|---|
| 3464 | "document.write(\"<option value=\\\"wdsap\\\" %s >\" + wl_basic.wdsap + \"</option>\");\n", |
|---|
| 3465 | nvram_match( wl_mode, |
|---|
| 3466 | "wdsap" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3467 | "" ); |
|---|
| 3468 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3469 | websWrite( wp, "</select>\n" ); |
|---|
| 3470 | websWrite( wp, "</div>\n" ); |
|---|
| 3471 | sprintf( wmm, "%s_wmm", var ); |
|---|
| 3472 | showRadio( wp, "wl_adv.label18", wmm ); |
|---|
| 3473 | #endif |
|---|
| 3474 | sprintf( ssid, "%s_ap_isolate", var ); |
|---|
| 3475 | showRadio( wp, "wl_adv.label11", ssid ); |
|---|
| 3476 | sprintf( wl_mode, "%s_mode", var ); |
|---|
| 3477 | showbridgesettings( wp, var, 1 ); |
|---|
| 3478 | websWrite( wp, "</fieldset><br />\n" ); |
|---|
| 3479 | count++; |
|---|
| 3480 | } |
|---|
| 3481 | |
|---|
| 3482 | websWrite( wp, "<div class=\"center\">\n" ); |
|---|
| 3483 | #ifdef HAVE_MADWIFI |
|---|
| 3484 | if( count < 8 ) |
|---|
| 3485 | #else |
|---|
| 3486 | if( count < WL_MAXBSSCFG ) |
|---|
| 3487 | #endif |
|---|
| 3488 | websWrite( wp, |
|---|
| 3489 | "<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", |
|---|
| 3490 | prefix ); |
|---|
| 3491 | |
|---|
| 3492 | if( count > 1 ) |
|---|
| 3493 | websWrite( wp, |
|---|
| 3494 | "<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", |
|---|
| 3495 | prefix ); |
|---|
| 3496 | |
|---|
| 3497 | websWrite( wp, "</div><br />\n" ); |
|---|
| 3498 | |
|---|
| 3499 | return 0; |
|---|
| 3500 | } |
|---|
| 3501 | |
|---|
| 3502 | #endif |
|---|
| 3503 | |
|---|
| 3504 | void ej_showad( webs_t wp, int argc, char_t ** argv ) |
|---|
| 3505 | { |
|---|
| 3506 | #ifndef HAVE_FON |
|---|
| 3507 | #ifndef CONFIG_BRANDING |
|---|
| 3508 | #ifdef HAVE_CHILLI |
|---|
| 3509 | // if (nvram_invmatch ("fon_enable", "1")) |
|---|
| 3510 | // websWrite (wp, |
|---|
| 3511 | // "<a href=\"fon.cgi\"><img src=\"images/turn.gif\" border=0 /></a>"); |
|---|
| 3512 | #endif |
|---|
| 3513 | #endif |
|---|
| 3514 | #endif |
|---|
| 3515 | |
|---|
| 3516 | #ifndef HAVE_NOAD |
|---|
| 3517 | /* |
|---|
| 3518 | * if (nvram_match("wanup","1")) { websWrite(wp,"<script |
|---|
| 3519 | * type=\"text/javascript\"><!--\n//<![CDATA[\n "); |
|---|
| 3520 | * websWrite(wp,"google_ad_client = \"pub-8308593183433068\";\n"); |
|---|
| 3521 | * websWrite(wp,"google_ad_width = 728;\n"); |
|---|
| 3522 | * websWrite(wp,"google_ad_height = 90;\n"); |
|---|
| 3523 | * websWrite(wp,"google_ad_format = \"728x90_as\";\n"); |
|---|
| 3524 | * websWrite(wp,"google_ad_type = \"text_image\";\n"); |
|---|
| 3525 | * websWrite(wp,"google_ad_channel =\"8866414571\";\n"); |
|---|
| 3526 | * websWrite(wp,"google_color_border = \"333333\";\n"); |
|---|
| 3527 | * websWrite(wp,"google_color_bg = \"000000\";\n"); |
|---|
| 3528 | * websWrite(wp,"google_color_link = \"FFFFFF\";\n"); |
|---|
| 3529 | * websWrite(wp,"google_color_url = \"999999\";\n"); |
|---|
| 3530 | * websWrite(wp,"google_color_text = \"CCCCCC\";\n"); |
|---|
| 3531 | * websWrite(wp,"//-->//]]>\n</script>\n"); websWrite(wp,"<script |
|---|
| 3532 | * type=\"text/javascript\"\n"); websWrite(wp," |
|---|
| 3533 | * src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\n"); |
|---|
| 3534 | * websWrite(wp,"</script>\n"); } |
|---|
| 3535 | */ |
|---|
| 3536 | #endif |
|---|
| 3537 | return; |
|---|
| 3538 | } |
|---|
| 3539 | |
|---|
| 3540 | #ifdef HAVE_MSSID |
|---|
| 3541 | |
|---|
| 3542 | #ifndef HAVE_SUPERCHANNEL |
|---|
| 3543 | int inline issuperchannel( void ) |
|---|
| 3544 | { |
|---|
| 3545 | #ifdef HAVE_MR3202A |
|---|
| 3546 | return 0; |
|---|
| 3547 | #elif HAVE_MAKSAT |
|---|
| 3548 | return 1; |
|---|
| 3549 | #else |
|---|
| 3550 | return 0; |
|---|
| 3551 | #endif |
|---|
| 3552 | } |
|---|
| 3553 | #endif |
|---|
| 3554 | |
|---|
| 3555 | #ifdef HAVE_MADWIFI |
|---|
| 3556 | void ej_show_countrylist( webs_t wp, int argc, char_t ** argv ) |
|---|
| 3557 | { |
|---|
| 3558 | if( argc < 1 ) |
|---|
| 3559 | { |
|---|
| 3560 | return; |
|---|
| 3561 | } |
|---|
| 3562 | char *list = getCountryList( ); |
|---|
| 3563 | |
|---|
| 3564 | showOptionsChoose( wp, argv[0], list, nvram_safe_get( argv[0] ) ); |
|---|
| 3565 | } |
|---|
| 3566 | #endif |
|---|
| 3567 | void ej_show_wireless_single( webs_t wp, char *prefix ) |
|---|
| 3568 | { |
|---|
| 3569 | char wl_mode[16]; |
|---|
| 3570 | char wl_macaddr[16]; |
|---|
| 3571 | char wl_ssid[16]; |
|---|
| 3572 | |
|---|
| 3573 | sprintf( wl_mode, "%s_mode", prefix ); |
|---|
| 3574 | sprintf( wl_macaddr, "%s_hwaddr", prefix ); |
|---|
| 3575 | sprintf( wl_ssid, "%s_ssid", prefix ); |
|---|
| 3576 | |
|---|
| 3577 | // wireless mode |
|---|
| 3578 | websWrite( wp, |
|---|
| 3579 | "<h2><script type=\"text/javascript\">Capture(wl_basic.h2_v24)</script> %s</h2>\n", |
|---|
| 3580 | prefix ); |
|---|
| 3581 | websWrite( wp, "<fieldset>\n" ); |
|---|
| 3582 | websWrite( wp, "<legend><script type=\"text/javascript\">Capture(share.pintrface)</script> %s - SSID [", prefix ), tf_webWriteESCNV( wp, wl_ssid ); // fix |
|---|
| 3583 | // for |
|---|
| 3584 | // broken |
|---|
| 3585 | // html |
|---|
| 3586 | // page |
|---|
| 3587 | // if |
|---|
| 3588 | // ssid |
|---|
| 3589 | // contains |
|---|
| 3590 | // html |
|---|
| 3591 | // tag |
|---|
| 3592 | websWrite( wp, "] HWAddr [%s]</legend>\n", nvram_safe_get( wl_macaddr ) ); |
|---|
| 3593 | char power[16]; |
|---|
| 3594 | |
|---|
| 3595 | // char maxpower[16]; |
|---|
| 3596 | #ifdef HAVE_MADWIFI |
|---|
| 3597 | char wl_regdomain[16]; |
|---|
| 3598 | |
|---|
| 3599 | sprintf( wl_regdomain, "%s_regdomain", prefix ); |
|---|
| 3600 | if( nvram_match( "ath_regulatory", "1" ) || !issuperchannel( ) ) |
|---|
| 3601 | { |
|---|
| 3602 | websWrite( wp, |
|---|
| 3603 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.regdom)</script></div>\n" ); |
|---|
| 3604 | char *list = getCountryList( ); |
|---|
| 3605 | |
|---|
| 3606 | showOptions( wp, wl_regdomain, list, nvram_safe_get( wl_regdomain ) ); |
|---|
| 3607 | websWrite( wp, "</div>\n" ); |
|---|
| 3608 | } |
|---|
| 3609 | /* |
|---|
| 3610 | * while (regdomains[domcount].name != NULL) { char domcode[16]; sprintf |
|---|
| 3611 | * (domcode, "%d", regdomains[domcount].code); websWrite (wp, "<option |
|---|
| 3612 | * value=\"%d\" %s>%s</option>\n", regdomains[domcount].code, nvram_match |
|---|
| 3613 | * (wl_regdomain, domcode) ? " selected=\"selected\"" : "", |
|---|
| 3614 | * regdomains[domcount].name); domcount++; } websWrite (wp, |
|---|
| 3615 | * "</select>\n"); websWrite (wp, "</div>\n"); |
|---|
| 3616 | */ |
|---|
| 3617 | // power adjustment |
|---|
| 3618 | sprintf( power, "%s_txpwrdbm", prefix ); |
|---|
| 3619 | // sprintf (maxpower, "%s_maxpower", prefix); |
|---|
| 3620 | if( !strcmp( prefix, "ath0" ) && issuperchannel( ) ) // show |
|---|
| 3621 | // client |
|---|
| 3622 | // only on |
|---|
| 3623 | // first |
|---|
| 3624 | // interface |
|---|
| 3625 | { |
|---|
| 3626 | |
|---|
| 3627 | websWrite( wp, " <div class=\"setting\">\n" ); |
|---|
| 3628 | websWrite( wp, |
|---|
| 3629 | " <div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.regulatory)</script></div>\n" ); |
|---|
| 3630 | websWrite( wp, |
|---|
| 3631 | " <input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"ath_regulatory\" %s /><script type=\"text/javascript\">Capture(share.enable)</script> \n", |
|---|
| 3632 | nvram_match( "ath_regulatory", "0" ) ? "checked" : "" ); |
|---|
| 3633 | websWrite( wp, |
|---|
| 3634 | " <input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"ath_regulatory\" %s /><script type=\"text/javascript\">Capture(share.disable)</script>\n", |
|---|
| 3635 | nvram_match( "ath_regulatory", "1" ) ? "checked" : "" ); |
|---|
| 3636 | websWrite( wp, " </div>\n" ); |
|---|
| 3637 | |
|---|
| 3638 | } |
|---|
| 3639 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3640 | websWrite( wp, |
|---|
| 3641 | "<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", |
|---|
| 3642 | power, |
|---|
| 3643 | atoi( nvram_safe_get( power ) ) + |
|---|
| 3644 | wifi_gettxpoweroffset( prefix ) ); |
|---|
| 3645 | websWrite( wp, "</div>\n" ); |
|---|
| 3646 | sprintf( power, "%s_antgain", prefix ); |
|---|
| 3647 | #ifndef HAVE_MAKSAT |
|---|
| 3648 | if( nvram_match( "ath_regulatory", "1" ) ) |
|---|
| 3649 | #endif |
|---|
| 3650 | { |
|---|
| 3651 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3652 | websWrite( wp, |
|---|
| 3653 | "<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", |
|---|
| 3654 | power, nvram_safe_get( power ) ); |
|---|
| 3655 | websWrite( wp, "</div>\n" ); |
|---|
| 3656 | } |
|---|
| 3657 | #endif |
|---|
| 3658 | |
|---|
| 3659 | #ifdef HAVE_MADWIFI |
|---|
| 3660 | // if (!strcmp (prefix, "ath0")) |
|---|
| 3661 | #endif |
|---|
| 3662 | { |
|---|
| 3663 | // #ifdef HAVE_MADWIFI |
|---|
| 3664 | // if (!strcmp (prefix, "ath0")) //show client only on first |
|---|
| 3665 | // interface |
|---|
| 3666 | // #endif |
|---|
| 3667 | { |
|---|
| 3668 | #ifdef HAVE_MADWIFI |
|---|
| 3669 | // if (!strcmp (prefix, "ath0")) //show client only on first |
|---|
| 3670 | // interface |
|---|
| 3671 | // if (nvram_match ("ath0_mode", "wdsap") |
|---|
| 3672 | // || nvram_match ("ath0_mode", "wdssta")) |
|---|
| 3673 | // showOption (wp, "wl_basic.wifi_bonding", "wifi_bonding"); |
|---|
| 3674 | #endif |
|---|
| 3675 | websWrite( wp, |
|---|
| 3676 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label)</script></div><select name=\"%s\" >\n", |
|---|
| 3677 | wl_mode ); |
|---|
| 3678 | websWrite( wp, |
|---|
| 3679 | "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 3680 | websWrite( wp, |
|---|
| 3681 | "document.write(\"<option value=\\\"ap\\\" %s >\" + wl_basic.ap + \"</option>\");\n", |
|---|
| 3682 | nvram_match( wl_mode, |
|---|
| 3683 | "ap" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3684 | "" ); |
|---|
| 3685 | websWrite( wp, |
|---|
| 3686 | "document.write(\"<option value=\\\"sta\\\" %s >\" + wl_basic.client + \"</option>\");\n", |
|---|
| 3687 | nvram_match( wl_mode, |
|---|
| 3688 | "sta" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3689 | "" ); |
|---|
| 3690 | websWrite( wp, |
|---|
| 3691 | "document.write(\"<option value=\\\"wet\\\" %s >\" + wl_basic.clientBridge + \"</option>\");\n", |
|---|
| 3692 | nvram_match( wl_mode, |
|---|
| 3693 | "wet" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3694 | "" ); |
|---|
| 3695 | websWrite( wp, |
|---|
| 3696 | "document.write(\"<option value=\\\"infra\\\" %s >\" + wl_basic.adhoc + \"</option>\");\n", |
|---|
| 3697 | nvram_match( wl_mode, |
|---|
| 3698 | "infra" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3699 | "" ); |
|---|
| 3700 | #ifndef HAVE_MADWIFI |
|---|
| 3701 | websWrite( wp, |
|---|
| 3702 | "document.write(\"<option value=\\\"apsta\\\" %s >\" + wl_basic.repeater + \"</option>\");\n", |
|---|
| 3703 | nvram_match( wl_mode, |
|---|
| 3704 | "apsta" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3705 | "" ); |
|---|
| 3706 | websWrite( wp, |
|---|
| 3707 | "document.write(\"<option value=\\\"apstawet\\\" %s >\" + wl_basic.repeaterbridge + \"</option>\");\n", |
|---|
| 3708 | nvram_match( wl_mode, |
|---|
| 3709 | "apstawet" ) ? "selected=\\\"selected\\\"" |
|---|
| 3710 | : "" ); |
|---|
| 3711 | #else |
|---|
| 3712 | websWrite( wp, |
|---|
| 3713 | "document.write(\"<option value=\\\"wdssta\\\" %s >\" + wl_basic.wdssta + \"</option>\");\n", |
|---|
| 3714 | nvram_match( wl_mode, |
|---|
| 3715 | "wdssta" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3716 | "" ); |
|---|
| 3717 | websWrite( wp, |
|---|
| 3718 | "document.write(\"<option value=\\\"wdsap\\\" %s >\" + wl_basic.wdsap + \"</option>\");\n", |
|---|
| 3719 | nvram_match( wl_mode, |
|---|
| 3720 | "wdsap" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3721 | "" ); |
|---|
| 3722 | #endif |
|---|
| 3723 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3724 | websWrite( wp, "</select>\n" ); |
|---|
| 3725 | websWrite( wp, "</div>\n" ); |
|---|
| 3726 | } |
|---|
| 3727 | /* |
|---|
| 3728 | * #ifdef HAVE_MADWIFI else { |
|---|
| 3729 | * |
|---|
| 3730 | * |
|---|
| 3731 | * websWrite (wp, "<div class=\"setting\"><div |
|---|
| 3732 | * class=\"label\"><script |
|---|
| 3733 | * type=\"text/javascript\">Capture(wl_basic.label)</script></div><select |
|---|
| 3734 | * name=\"%s\">\n", wl_mode); websWrite (wp, "<script |
|---|
| 3735 | * type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option |
|---|
| 3736 | * value=\\\"ap\\\" %s >\" + wl_basic.ap + |
|---|
| 3737 | * \"</option>\");\n//]]>\n</script>\n", nvram_match (wl_mode, "ap") |
|---|
| 3738 | * ? "selected=\\\"selected\\\"" : ""); websWrite (wp, "<script |
|---|
| 3739 | * type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option |
|---|
| 3740 | * value=\\\"infra\\\" %s >\" + wl_basic.adhoc + |
|---|
| 3741 | * \"</option>\");\n//]]>\n</script>\n", nvram_match (wl_mode, |
|---|
| 3742 | * "infra") ? "selected=\\\"selected\\\"" : ""); websWrite (wp, |
|---|
| 3743 | * "<script type=\"text/javascript\">\n//<![CDATA[\n |
|---|
| 3744 | * document.write(\"<option value=\\\"wdssta\\\" %s >\" + |
|---|
| 3745 | * wl_basic.wdssta + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 3746 | * nvram_match (wl_mode, "wdssta") ? "selected=\\\"selected\\\"" : |
|---|
| 3747 | * ""); websWrite (wp, "<script |
|---|
| 3748 | * type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option |
|---|
| 3749 | * value=\\\"wdsap\\\" %s >\" + wl_basic.wdsap + |
|---|
| 3750 | * \"</option>\");\n//]]>\n</script>\n", nvram_match (wl_mode, |
|---|
| 3751 | * "wdsap") ? "selected=\\\"selected\\\"" : ""); websWrite (wp, |
|---|
| 3752 | * "</select>\n"); websWrite (wp, "</div>\n"); } #endif |
|---|
| 3753 | */ |
|---|
| 3754 | } |
|---|
| 3755 | // writeless net mode |
|---|
| 3756 | show_netmode( wp, prefix ); |
|---|
| 3757 | // turbo options |
|---|
| 3758 | #ifdef HAVE_MADWIFI |
|---|
| 3759 | |
|---|
| 3760 | // char wl_xchanmode[16]; |
|---|
| 3761 | char wl_outdoor[16]; |
|---|
| 3762 | char wl_diversity[16]; |
|---|
| 3763 | char wl_rxantenna[16]; |
|---|
| 3764 | char wl_txantenna[16]; |
|---|
| 3765 | char wl_width[16]; |
|---|
| 3766 | char wl_preamble[16]; |
|---|
| 3767 | char wl_xr[16]; |
|---|
| 3768 | char wl_comp[32]; |
|---|
| 3769 | char wl_ff[16]; |
|---|
| 3770 | char wmm[32]; |
|---|
| 3771 | char wl_isolate[32]; |
|---|
| 3772 | char wl_sifstime[32]; |
|---|
| 3773 | char wl_preambletime[32]; |
|---|
| 3774 | char wl_intmit[32]; |
|---|
| 3775 | char wl_noise_immunity[32]; |
|---|
| 3776 | char wl_ofdm_weak_det[32]; |
|---|
| 3777 | char wl_protmode[32]; |
|---|
| 3778 | char wl_doth[32]; |
|---|
| 3779 | |
|---|
| 3780 | sprintf( wl_doth, "%s_doth", prefix ); |
|---|
| 3781 | sprintf( wl_protmode, "%s_protmode", prefix ); |
|---|
| 3782 | sprintf( wl_outdoor, "%s_outdoor", prefix ); |
|---|
| 3783 | sprintf( wl_diversity, "%s_diversity", prefix ); |
|---|
| 3784 | sprintf( wl_rxantenna, "%s_rxantenna", prefix ); |
|---|
| 3785 | sprintf( wl_txantenna, "%s_txantenna", prefix ); |
|---|
| 3786 | sprintf( wl_width, "%s_channelbw", prefix ); |
|---|
| 3787 | sprintf( wl_comp, "%s_compression", prefix ); |
|---|
| 3788 | sprintf( wl_ff, "%s_ff", prefix ); |
|---|
| 3789 | sprintf( wl_preamble, "%s_preamble", prefix ); |
|---|
| 3790 | sprintf( wl_preambletime, "%s_preambletime", prefix ); |
|---|
| 3791 | sprintf( wl_sifstime, "%s_sifstime", prefix ); |
|---|
| 3792 | sprintf( wl_xr, "%s_xr", prefix ); |
|---|
| 3793 | |
|---|
| 3794 | sprintf( wl_intmit, "%s_intmit", prefix ); |
|---|
| 3795 | sprintf( wl_noise_immunity, "%s_noise_immunity", prefix ); |
|---|
| 3796 | sprintf( wl_ofdm_weak_det, "%s_ofdm_weak_det", prefix ); |
|---|
| 3797 | showAutoOption( wp, "wl_basic.intmit", wl_intmit ); |
|---|
| 3798 | |
|---|
| 3799 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3800 | websWrite( wp, |
|---|
| 3801 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.noise_immunity)</script></div>\n<select name=\"%s\">\n", |
|---|
| 3802 | wl_noise_immunity ); |
|---|
| 3803 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 3804 | websWrite( wp, |
|---|
| 3805 | "document.write(\"<option value=\\\"-1\\\" %s >\" + share.auto + \"</option>\");\n", |
|---|
| 3806 | nvram_default_match( wl_noise_immunity, "-1", |
|---|
| 3807 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3808 | "" ); |
|---|
| 3809 | websWrite( wp, |
|---|
| 3810 | "document.write(\"<option value=\\\"0\\\" %s >0</option>\");\n", |
|---|
| 3811 | nvram_default_match( wl_noise_immunity, "0", |
|---|
| 3812 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3813 | "" ); |
|---|
| 3814 | websWrite( wp, |
|---|
| 3815 | "document.write(\"<option value=\\\"1\\\" %s >1</option>\");\n", |
|---|
| 3816 | nvram_default_match( wl_noise_immunity, "1", |
|---|
| 3817 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3818 | "" ); |
|---|
| 3819 | websWrite( wp, |
|---|
| 3820 | "document.write(\"<option value=\\\"2\\\" %s >2</option>\");\n", |
|---|
| 3821 | nvram_default_match( wl_noise_immunity, "2", |
|---|
| 3822 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3823 | "" ); |
|---|
| 3824 | websWrite( wp, |
|---|
| 3825 | "document.write(\"<option value=\\\"3\\\" %s >3</option>\");\n", |
|---|
| 3826 | nvram_default_match( wl_noise_immunity, "3", |
|---|
| 3827 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3828 | "" ); |
|---|
| 3829 | websWrite( wp, |
|---|
| 3830 | "document.write(\"<option value=\\\"4\\\" %s >4</option>\");\n", |
|---|
| 3831 | nvram_default_match( wl_noise_immunity, "4", |
|---|
| 3832 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3833 | "" ); |
|---|
| 3834 | websWrite( wp, "//]]>\n</script>\n</select>\n</div>\n" ); |
|---|
| 3835 | |
|---|
| 3836 | showRadio( wp, "wl_basic.ofdm_weak_det", wl_ofdm_weak_det ); |
|---|
| 3837 | |
|---|
| 3838 | showOptionsLabel( wp, "wl_basic.protmode", wl_protmode, |
|---|
| 3839 | "None CTS RTS/CTS", nvram_default_get( wl_protmode, |
|---|
| 3840 | "None" ) ); |
|---|
| 3841 | showrtssettings( wp, prefix ); |
|---|
| 3842 | show_rates( wp, prefix, 0 ); |
|---|
| 3843 | show_rates( wp, prefix, 1 ); |
|---|
| 3844 | showRadio( wp, "wl_basic.preamble", wl_preamble ); |
|---|
| 3845 | showRadio( wp, "wl_basic.extrange", wl_xr ); |
|---|
| 3846 | showRadio( wp, "wl_basic.supergcomp", wl_comp ); |
|---|
| 3847 | showRadio( wp, "wl_basic.supergff", wl_ff ); |
|---|
| 3848 | |
|---|
| 3849 | // showOption (wp, "wl_basic.extchannel", wl_xchanmode); |
|---|
| 3850 | #if !defined(HAVE_FONERA) && !defined(HAVE_LS2) && !defined(HAVE_MERAKI) |
|---|
| 3851 | if( nvram_match( "ath_regulatory", "1" ) || !issuperchannel( ) ) |
|---|
| 3852 | { |
|---|
| 3853 | showRadio( wp, "wl_basic.outband", wl_outdoor ); |
|---|
| 3854 | } |
|---|
| 3855 | #endif |
|---|
| 3856 | websWrite( wp, |
|---|
| 3857 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_width)</script></div><select name=\"%s\" >\n", |
|---|
| 3858 | wl_width ); |
|---|
| 3859 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 3860 | websWrite( wp, |
|---|
| 3861 | "document.write(\"<option value=\\\"40\\\" %s >\" + share.turbo + \"</option>\");\n", |
|---|
| 3862 | nvram_match( wl_width, |
|---|
| 3863 | "40" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3864 | websWrite( wp, |
|---|
| 3865 | "document.write(\"<option value=\\\"20\\\" %s >\" + share.full + \"</option>\");\n", |
|---|
| 3866 | nvram_match( wl_width, |
|---|
| 3867 | "20" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3868 | websWrite( wp, |
|---|
| 3869 | "document.write(\"<option value=\\\"10\\\" %s >\" + share.half + \"</option>\");\n", |
|---|
| 3870 | nvram_match( wl_width, |
|---|
| 3871 | "10" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3872 | websWrite( wp, |
|---|
| 3873 | "document.write(\"<option value=\\\"5\\\" %s >\" + share.quarter + \"</option>\");\n", |
|---|
| 3874 | nvram_match( wl_width, |
|---|
| 3875 | "5" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3876 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3877 | websWrite( wp, "</select>\n" ); |
|---|
| 3878 | websWrite( wp, "</div>\n" ); |
|---|
| 3879 | |
|---|
| 3880 | #if defined(HAVE_NS2) || defined(HAVE_NS5) |
|---|
| 3881 | |
|---|
| 3882 | websWrite( wp, |
|---|
| 3883 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label24)</script></div><select name=\"%s\" >\n", |
|---|
| 3884 | wl_txantenna ); |
|---|
| 3885 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 3886 | websWrite( wp, |
|---|
| 3887 | "document.write(\"<option value=\\\"0\\\" %s >\" + wl_basic.vertical + \"</option>\");\n", |
|---|
| 3888 | nvram_match( wl_txantenna, |
|---|
| 3889 | "0" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3890 | websWrite( wp, |
|---|
| 3891 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.horizontal + \"</option>\");\n", |
|---|
| 3892 | nvram_match( wl_txantenna, |
|---|
| 3893 | "1" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3894 | websWrite( wp, |
|---|
| 3895 | "document.write(\"<option value=\\\"3\\\" %s >\" + wl_basic.adaptive + \"</option>\");\n", |
|---|
| 3896 | nvram_match( wl_txantenna, |
|---|
| 3897 | "3" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3898 | websWrite( wp, |
|---|
| 3899 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.external + \"</option>\");\n", |
|---|
| 3900 | nvram_match( wl_txantenna, |
|---|
| 3901 | "2" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3902 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3903 | websWrite( wp, "</select>\n" ); |
|---|
| 3904 | websWrite( wp, "</div>\n" ); |
|---|
| 3905 | |
|---|
| 3906 | #else |
|---|
| 3907 | showRadio( wp, "wl_basic.diversity", wl_diversity ); |
|---|
| 3908 | websWrite( wp, |
|---|
| 3909 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label12)</script></div><select name=\"%s\" >\n", |
|---|
| 3910 | wl_txantenna ); |
|---|
| 3911 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 3912 | websWrite( wp, |
|---|
| 3913 | "document.write(\"<option value=\\\"0\\\" %s >\" + wl_basic.diversity + \"</option>\");\n", |
|---|
| 3914 | nvram_match( wl_txantenna, |
|---|
| 3915 | "0" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3916 | websWrite( wp, |
|---|
| 3917 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.primary + \"</option>\");\n", |
|---|
| 3918 | nvram_match( wl_txantenna, |
|---|
| 3919 | "1" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3920 | websWrite( wp, |
|---|
| 3921 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.secondary + \"</option>\");\n", |
|---|
| 3922 | nvram_match( wl_txantenna, |
|---|
| 3923 | "2" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3924 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3925 | websWrite( wp, "</select>\n" ); |
|---|
| 3926 | websWrite( wp, "</div>\n" ); |
|---|
| 3927 | |
|---|
| 3928 | websWrite( wp, |
|---|
| 3929 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label13)</script></div><select name=\"%s\" >\n", |
|---|
| 3930 | wl_rxantenna ); |
|---|
| 3931 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 3932 | websWrite( wp, |
|---|
| 3933 | "document.write(\"<option value=\\\"0\\\" %s >\" + wl_basic.diversity + \"</option>\");\n", |
|---|
| 3934 | nvram_match( wl_rxantenna, |
|---|
| 3935 | "0" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3936 | websWrite( wp, |
|---|
| 3937 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.primary + \"</option>\");\n", |
|---|
| 3938 | nvram_match( wl_rxantenna, |
|---|
| 3939 | "1" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3940 | websWrite( wp, |
|---|
| 3941 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.secondary + \"</option>\");\n", |
|---|
| 3942 | nvram_match( wl_rxantenna, |
|---|
| 3943 | "2" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3944 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3945 | websWrite( wp, "</select>\n" ); |
|---|
| 3946 | websWrite( wp, "</div>\n" ); |
|---|
| 3947 | #endif |
|---|
| 3948 | #endif |
|---|
| 3949 | #ifdef HAVE_MADWIFI |
|---|
| 3950 | sprintf( wl_isolate, "%s_ap_isolate", prefix ); |
|---|
| 3951 | showRadio( wp, "wl_adv.label11", wl_isolate ); |
|---|
| 3952 | |
|---|
| 3953 | #if 0 |
|---|
| 3954 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3955 | websWrite( wp, |
|---|
| 3956 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.sifstime)</script></div>\n" ); |
|---|
| 3957 | websWrite( wp, |
|---|
| 3958 | "<input class=\"num\" name=\"%s\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,99999999,wl_basic.sifstime)\" value=\"%s\" />\n", |
|---|
| 3959 | wl_sifstime, nvram_default_get( wl_sifstime, "16" ) ); |
|---|
| 3960 | websWrite( wp, "</div>\n" ); |
|---|
| 3961 | |
|---|
| 3962 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3963 | websWrite( wp, |
|---|
| 3964 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.preambletime)</script></div>\n" ); |
|---|
| 3965 | websWrite( wp, |
|---|
| 3966 | "<input class=\"num\" name=\"%s\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,99999999,wl_basic.preambletime)\" value=\"%s\" />\n", |
|---|
| 3967 | wl_preambletime, nvram_default_get( wl_preambletime, "20" ) ); |
|---|
| 3968 | websWrite( wp, "</div>\n" ); |
|---|
| 3969 | #endif |
|---|
| 3970 | sprintf( wmm, "%s_wmm", prefix ); |
|---|
| 3971 | showRadio( wp, "wl_adv.label18", wmm ); |
|---|
| 3972 | #endif |
|---|
| 3973 | |
|---|
| 3974 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3975 | websWrite( wp, |
|---|
| 3976 | "<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", |
|---|
| 3977 | wl_ssid, nvram_safe_get( wl_ssid ) ); |
|---|
| 3978 | |
|---|
| 3979 | #ifdef HAVE_MADWIFI |
|---|
| 3980 | showRadio( wp, "wl_basic.radar", wl_doth ); |
|---|
| 3981 | show_chanshift( wp, prefix ); |
|---|
| 3982 | #endif |
|---|
| 3983 | if( nvram_match( wl_mode, "ap" ) || nvram_match( wl_mode, "wdsap" ) |
|---|
| 3984 | || nvram_match( wl_mode, "infra" ) ) |
|---|
| 3985 | { |
|---|
| 3986 | |
|---|
| 3987 | if( has_mimo( prefix ) |
|---|
| 3988 | && ( nvram_nmatch( "n-only", "%s_net_mode", prefix ) |
|---|
| 3989 | || nvram_nmatch( "mixed," "%s_net_mode", prefix ) ) ) |
|---|
| 3990 | { |
|---|
| 3991 | |
|---|
| 3992 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3993 | websWrite( wp, |
|---|
| 3994 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_width)</script></div>\n" ); |
|---|
| 3995 | websWrite( wp, "<select name=\"wl0_nbw\">\n" ); |
|---|
| 3996 | websWrite( wp, |
|---|
| 3997 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"0\\\" %s >\" + share.auto + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 3998 | nvram_match( "wl0_nbw", |
|---|
| 3999 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 4000 | "" ); |
|---|
| 4001 | websWrite( wp, "<option value=\"10\" %s>10 MHz</option>", |
|---|
| 4002 | nvram_match( "wl0_nbw", |
|---|
| 4003 | "10" ) ? "selected=\\\"selected\\\"" : |
|---|
| 4004 | "" ); |
|---|
| 4005 | websWrite( wp, "<option value=\"20\" %s>20 MHz</option>", |
|---|
| 4006 | nvram_match( "wl0_nbw", |
|---|
| 4007 | "20" ) ? "selected=\\\"selected\\\"" : |
|---|
| 4008 | "" ); |
|---|
| 4009 | websWrite( wp, "<option value=\"40\" %s>40 MHz</option>", |
|---|
| 4010 | nvram_match( "wl0_nbw", |
|---|
| 4011 | "40" ) ? "selected=\\\"selected\\\"" : |
|---|
| 4012 | "" ); |
|---|
| 4013 | websWrite( wp, "</select>\n" ); |
|---|
| 4014 | websWrite( wp, "</div>\n" ); |
|---|
| 4015 | |
|---|
| 4016 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4017 | websWrite( wp, |
|---|
| 4018 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_wide)</script></div>\n" ); |
|---|
| 4019 | websWrite( wp, "<select name=\"wl0_wchannel\" ></select>\n" ); |
|---|
| 4020 | websWrite( wp, "</div>\n" ); |
|---|
| 4021 | |
|---|
| 4022 | show_channel( wp, prefix, prefix, 1 ); |
|---|
| 4023 | } |
|---|
| 4024 | else |
|---|
| 4025 | |
|---|
| 4026 | show_channel( wp, prefix, prefix, 0 ); |
|---|
| 4027 | |
|---|
| 4028 | char wl_closed[16]; |
|---|
| 4029 | |
|---|
| 4030 | sprintf( wl_closed, "%s_closed", prefix ); |
|---|
| 4031 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4032 | websWrite( wp, |
|---|
| 4033 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label5)</script></div>\n" ); |
|---|
| 4034 | websWrite( wp, |
|---|
| 4035 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input> \n", |
|---|
| 4036 | wl_closed, nvram_match( wl_closed, |
|---|
| 4037 | "0" ) ? "checked=\"checked\"" : |
|---|
| 4038 | "" ); |
|---|
| 4039 | websWrite( wp, |
|---|
| 4040 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input>\n", |
|---|
| 4041 | wl_closed, nvram_match( wl_closed, |
|---|
| 4042 | "1" ) ? "checked=\"checked\"" : |
|---|
| 4043 | "" ); |
|---|
| 4044 | websWrite( wp, "</div>\n" ); |
|---|
| 4045 | } |
|---|
| 4046 | #ifdef HAVE_MADWIFI |
|---|
| 4047 | // if (nvram_match (wl_mode, "sta") || nvram_match (wl_mode, "wdssta") |
|---|
| 4048 | // || nvram_match (wl_mode, "wet")) |
|---|
| 4049 | { |
|---|
| 4050 | char wl_scanlist[32]; |
|---|
| 4051 | |
|---|
| 4052 | sprintf( wl_scanlist, "%s_scanlist", prefix ); |
|---|
| 4053 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4054 | websWrite( wp, |
|---|
| 4055 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.scanlist)</script></div>\n" ); |
|---|
| 4056 | websWrite( wp, |
|---|
| 4057 | "<input name=\"%s\" size=\"32\" maxlength=\"512\" value=\"%s\" />\n", |
|---|
| 4058 | wl_scanlist, nvram_default_get( wl_scanlist, "default" ) ); |
|---|
| 4059 | websWrite( wp, "</div>\n" ); |
|---|
| 4060 | } |
|---|
| 4061 | #endif |
|---|
| 4062 | |
|---|
| 4063 | // ACK timing |
|---|
| 4064 | #if defined(HAVE_ACK) || defined(HAVE_MADWIFI) // temp fix for v24 broadcom |
|---|
| 4065 | // ACKnot working |
|---|
| 4066 | |
|---|
| 4067 | sprintf( power, "%s_distance", prefix ); |
|---|
| 4068 | websWrite( wp, "<br />\n" ); |
|---|
| 4069 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4070 | websWrite( wp, |
|---|
| 4071 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label6)</script></div>\n" ); |
|---|
| 4072 | websWrite( wp, |
|---|
| 4073 | "<input class=\"num\" name=\"%s\" size=\"8\" maxlength=\"8\" onblur=\"valid_range(this,0,99999999,wl_basic.label6)\" value=\"%s\" />\n", |
|---|
| 4074 | power, nvram_default_get( power, "2000" ) ); |
|---|
| 4075 | websWrite( wp, |
|---|
| 4076 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 2000 \" + share.meters + \")\");\n//]]>\n</script></span>\n" ); |
|---|
| 4077 | websWrite( wp, "</div>\n" ); |
|---|
| 4078 | // end ACK timing |
|---|
| 4079 | #endif |
|---|
| 4080 | #ifdef HAVE_MADWIFI |
|---|
| 4081 | showbridgesettings( wp, prefix, 1 ); |
|---|
| 4082 | #else |
|---|
| 4083 | if( !strcmp( prefix, "wl0" ) ) |
|---|
| 4084 | showbridgesettings( wp, get_wl_instance_name( 0 ), 1 ); |
|---|
| 4085 | if( !strcmp( prefix, "wl1" ) ) |
|---|
| 4086 | showbridgesettings( wp, get_wl_instance_name( 1 ), 1 ); |
|---|
| 4087 | #endif |
|---|
| 4088 | websWrite( wp, "</fieldset>\n" ); |
|---|
| 4089 | websWrite( wp, "<br />\n" ); |
|---|
| 4090 | show_virtualssid( wp, prefix ); |
|---|
| 4091 | } |
|---|
| 4092 | |
|---|
| 4093 | void ej_show_wireless( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4094 | { |
|---|
| 4095 | #ifdef HAVE_MADWIFI |
|---|
| 4096 | int c = getdevicecount( ); |
|---|
| 4097 | int i; |
|---|
| 4098 | |
|---|
| 4099 | for( i = 0; i < c; i++ ) |
|---|
| 4100 | { |
|---|
| 4101 | char buf[16]; |
|---|
| 4102 | |
|---|
| 4103 | sprintf( buf, "ath%d", i ); |
|---|
| 4104 | ej_show_wireless_single( wp, buf ); |
|---|
| 4105 | } |
|---|
| 4106 | #else |
|---|
| 4107 | int c = get_wl_instances( ); |
|---|
| 4108 | int i; |
|---|
| 4109 | |
|---|
| 4110 | for( i = 0; i < c; i++ ) |
|---|
| 4111 | { |
|---|
| 4112 | char buf[16]; |
|---|
| 4113 | |
|---|
| 4114 | sprintf( buf, "wl%d", i ); |
|---|
| 4115 | ej_show_wireless_single( wp, buf ); |
|---|
| 4116 | } |
|---|
| 4117 | #endif |
|---|
| 4118 | return; |
|---|
| 4119 | } |
|---|
| 4120 | |
|---|
| 4121 | void show_preshared( webs_t wp, char *prefix ) |
|---|
| 4122 | { |
|---|
| 4123 | char var[80]; |
|---|
| 4124 | |
|---|
| 4125 | cprintf( "show preshared" ); |
|---|
| 4126 | sprintf( var, "%s_crypto", prefix ); |
|---|
| 4127 | websWrite( wp, "<div><div class=\"setting\">\n" ); |
|---|
| 4128 | websWrite( wp, |
|---|
| 4129 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.algorithms)</script></div>\n" ); |
|---|
| 4130 | websWrite( wp, "<select name=\"%s_crypto\">\n", prefix ); |
|---|
| 4131 | websWrite( wp, "<option value=\"tkip\" %s>TKIP</option>\n", |
|---|
| 4132 | selmatch( var, "tkip", "selected=\"selected\"" ) ); |
|---|
| 4133 | websWrite( wp, "<option value=\"aes\" %s>AES</option>\n", |
|---|
| 4134 | selmatch( var, "aes", "selected=\"selected\"" ) ); |
|---|
| 4135 | websWrite( wp, "<option value=\"tkip+aes\" %s>TKIP+AES</option>\n", |
|---|
| 4136 | selmatch( var, "tkip+aes", "selected=\"selected\"" ) ); |
|---|
| 4137 | websWrite( wp, "</select>\n" ); |
|---|
| 4138 | websWrite( wp, "</div>\n" ); |
|---|
| 4139 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4140 | websWrite( wp, |
|---|
| 4141 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.shared_key)</script></div>\n" ); |
|---|
| 4142 | sprintf( var, "%s_wpa_psk", prefix ); |
|---|
| 4143 | websWrite( wp, |
|---|
| 4144 | "<input type=\"password\" id=\"%s_wpa_psk\" name=\"%s_wpa_psk\" onblur=\"valid_psk_length(this)\" maxlength=\"64\" size=\"32\" value=\"", |
|---|
| 4145 | prefix, prefix ); |
|---|
| 4146 | tf_webWriteESCNV( wp, var ); |
|---|
| 4147 | websWrite( wp, "\" /> \n" ); |
|---|
| 4148 | websWrite( wp, |
|---|
| 4149 | "<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", |
|---|
| 4150 | prefix, prefix ); |
|---|
| 4151 | websWrite( wp, "</div>\n" ); |
|---|
| 4152 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4153 | websWrite( wp, |
|---|
| 4154 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.rekey)</script></div>\n" ); |
|---|
| 4155 | sprintf( var, "%s_wpa_gtk_rekey", prefix ); |
|---|
| 4156 | websWrite( wp, |
|---|
| 4157 | "<input class=\"num\" name=\"%s_wpa_gtk_rekey\" maxlength=\"5\" size=\"5\" onblur=\"valid_range(this,0,99999,wpa.rekey)\" value=\"%s\" />\n", |
|---|
| 4158 | prefix, nvram_default_get( var, "3600" ) ); |
|---|
| 4159 | websWrite( wp, |
|---|
| 4160 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 3600, \" + share.range + \": 1 - 99999)\");\n//]]>\n</script></span>\n" ); |
|---|
| 4161 | websWrite( wp, "</div>\n" ); |
|---|
| 4162 | websWrite( wp, "</div>\n" ); |
|---|
| 4163 | } |
|---|
| 4164 | |
|---|
| 4165 | void show_radius( webs_t wp, char *prefix, int showmacformat ) |
|---|
| 4166 | { |
|---|
| 4167 | char var[80]; |
|---|
| 4168 | |
|---|
| 4169 | cprintf( "show radius\n" ); |
|---|
| 4170 | if( showmacformat ) |
|---|
| 4171 | { |
|---|
| 4172 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4173 | websWrite( wp, |
|---|
| 4174 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label2)</script></div>\n" ); |
|---|
| 4175 | websWrite( wp, "<select name=\"%s_radmactype\">\n", prefix ); |
|---|
| 4176 | websWrite( wp, "<option value=\"0\" %s >aabbcc-ddeeff</option>\n", |
|---|
| 4177 | nvram_prefix_match( "radmactype", prefix, |
|---|
| 4178 | "0" ) ? "selected" : "" ); |
|---|
| 4179 | websWrite( wp, "<option value=\"1\" %s >aabbccddeeff</option>\n", |
|---|
| 4180 | nvram_prefix_match( "radmactype", prefix, |
|---|
| 4181 | "1" ) ? "selected" : "" ); |
|---|
| 4182 | websWrite( wp, "<option value=\"2\" %s >aa:bb:cc:dd:ee:ff</option>\n", |
|---|
| 4183 | nvram_prefix_match( "radmactype", prefix, |
|---|
| 4184 | "2" ) ? "selected" : "" ); |
|---|
| 4185 | websWrite( wp, "<option value=\"3\" %s >aa-bb-cc-dd-ee-ff</option>\n", |
|---|
| 4186 | nvram_prefix_match( "radmactype", prefix, |
|---|
| 4187 | "3" ) ? "selected" : "" ); |
|---|
| 4188 | websWrite( wp, "</select>\n" ); |
|---|
| 4189 | websWrite( wp, "</div>\n" ); |
|---|
| 4190 | } |
|---|
| 4191 | char *rad = nvram_nget( "%s_radius_ipaddr", prefix ); |
|---|
| 4192 | |
|---|
| 4193 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4194 | websWrite( wp, |
|---|
| 4195 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label3)</script></div>\n" ); |
|---|
| 4196 | websWrite( wp, |
|---|
| 4197 | "<input type=\"hidden\" name=\"%s_radius_ipaddr\" value=\"4\" />\n", |
|---|
| 4198 | prefix ); |
|---|
| 4199 | websWrite( wp, |
|---|
| 4200 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_0\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4201 | prefix, get_single_ip( rad, 0 ) ); |
|---|
| 4202 | websWrite( wp, |
|---|
| 4203 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_1\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4204 | prefix, get_single_ip( rad, 1 ) ); |
|---|
| 4205 | websWrite( wp, |
|---|
| 4206 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_2\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4207 | prefix, get_single_ip( rad, 2 ) ); |
|---|
| 4208 | websWrite( wp, |
|---|
| 4209 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_3\" onblur=\"valid_range(this,1,254,radius.label3)\" class=\"num\" value=\"%d\" />\n", |
|---|
| 4210 | prefix, get_single_ip( rad, 3 ) ); |
|---|
| 4211 | websWrite( wp, "</div>\n" ); |
|---|
| 4212 | |
|---|
| 4213 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4214 | websWrite( wp, |
|---|
| 4215 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label4)</script></div>\n" ); |
|---|
| 4216 | sprintf( var, "%s_radius_port", prefix ); |
|---|
| 4217 | websWrite( wp, |
|---|
| 4218 | "<input name=\"%s_radius_port\" size=\"3\" maxlength=\"5\" onblur=\"valid_range(this,1,65535,radius.label4)\" value=\"%s\" />\n", |
|---|
| 4219 | prefix, nvram_default_get( var, "1812" ) ); |
|---|
| 4220 | websWrite( wp, |
|---|
| 4221 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 1812)\");\n//]]>\n</script></span>\n</div>\n" ); |
|---|
| 4222 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4223 | websWrite( wp, |
|---|
| 4224 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label7)</script></div>\n" ); |
|---|
| 4225 | sprintf( var, "%s_radius_key", prefix ); |
|---|
| 4226 | websWrite( wp, |
|---|
| 4227 | "<input type=\"password\" id=\"%s_radius_key\" name=\"%s_radius_key\" maxlength=\"79\" size=\"32\" value=\"", |
|---|
| 4228 | prefix, prefix ); |
|---|
| 4229 | tf_webWriteESCNV( wp, var ); |
|---|
| 4230 | websWrite( wp, "\" /> \n" ); |
|---|
| 4231 | websWrite( wp, |
|---|
| 4232 | "<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", |
|---|
| 4233 | prefix, prefix ); |
|---|
| 4234 | websWrite( wp, "</div>\n" ); |
|---|
| 4235 | #ifdef HAVE_MADWIFI |
|---|
| 4236 | if( !showmacformat ) |
|---|
| 4237 | { |
|---|
| 4238 | char acct[32]; |
|---|
| 4239 | char vvar[32]; |
|---|
| 4240 | |
|---|
| 4241 | strcpy( vvar, var ); |
|---|
| 4242 | rep( vvar, '.', 'X' ); |
|---|
| 4243 | sprintf( acct, "%s_acct", prefix ); |
|---|
| 4244 | websWrite( wp, |
|---|
| 4245 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label18)</script></div>\n" ); |
|---|
| 4246 | websWrite( wp, |
|---|
| 4247 | "<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", |
|---|
| 4248 | vvar, prefix, nvram_default_match( acct, "1", |
|---|
| 4249 | "0" ) ? |
|---|
| 4250 | "checked=\"checked\"" : "" ); |
|---|
| 4251 | websWrite( wp, |
|---|
| 4252 | "<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", |
|---|
| 4253 | vvar, prefix, nvram_default_match( acct, "0", |
|---|
| 4254 | "0" ) ? |
|---|
| 4255 | "checked=\"checked\"" : "" ); |
|---|
| 4256 | websWrite( wp, "</div>\n" ); |
|---|
| 4257 | char *rad = nvram_nget( "%s_acct_ipaddr", prefix ); |
|---|
| 4258 | |
|---|
| 4259 | websWrite( wp, "<div id=\"%s_idacct\">\n", vvar ); |
|---|
| 4260 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4261 | websWrite( wp, |
|---|
| 4262 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label13)</script></div>\n" ); |
|---|
| 4263 | websWrite( wp, |
|---|
| 4264 | "<input type=\"hidden\" name=\"%s_acct_ipaddr\" value=\"4\" />\n", |
|---|
| 4265 | prefix ); |
|---|
| 4266 | websWrite( wp, |
|---|
| 4267 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_0\" onblur=\"valid_range(this,0,255,radius.label13)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4268 | prefix, get_single_ip( rad, 0 ) ); |
|---|
| 4269 | websWrite( wp, |
|---|
| 4270 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_1\" onblur=\"valid_range(this,0,255,radius.label13)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4271 | prefix, get_single_ip( rad, 1 ) ); |
|---|
| 4272 | websWrite( wp, |
|---|
| 4273 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_2\" onblur=\"valid_range(this,0,255,radius.label13)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4274 | prefix, get_single_ip( rad, 2 ) ); |
|---|
| 4275 | websWrite( wp, |
|---|
| 4276 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_3\" onblur=\"valid_range(this,1,254,radius.label13)\" class=\"num\" value=\"%d\" />\n", |
|---|
| 4277 | prefix, get_single_ip( rad, 3 ) ); |
|---|
| 4278 | websWrite( wp, "</div>\n" ); |
|---|
| 4279 | |
|---|
| 4280 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4281 | websWrite( wp, |
|---|
| 4282 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label14)</script></div>\n" ); |
|---|
| 4283 | sprintf( var, "%s_acct_port", prefix ); |
|---|
| 4284 | websWrite( wp, |
|---|
| 4285 | "<input name=\"%s_acct_port\" size=\"3\" maxlength=\"5\" onblur=\"valid_range(this,1,65535,radius.label14)\" value=\"%s\" />\n", |
|---|
| 4286 | prefix, nvram_default_get( var, "1813" ) ); |
|---|
| 4287 | websWrite( wp, |
|---|
| 4288 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 1812)\");\n//]]>\n</script></span>\n</div>\n" ); |
|---|
| 4289 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4290 | websWrite( wp, |
|---|
| 4291 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label17)</script></div>\n" ); |
|---|
| 4292 | sprintf( var, "%s_acct_key", prefix ); |
|---|
| 4293 | websWrite( wp, |
|---|
| 4294 | "<input type=\"password\" id=\"%s_acct_key\" name=\"%s_acct_key\" maxlength=\"79\" size=\"32\" value=\"", |
|---|
| 4295 | prefix, prefix ); |
|---|
| 4296 | tf_webWriteESCNV( wp, var ); |
|---|
| 4297 | websWrite( wp, "\" /> \n" ); |
|---|
| 4298 | websWrite( wp, |
|---|
| 4299 | "<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", |
|---|
| 4300 | prefix, prefix ); |
|---|
| 4301 | websWrite( wp, "</div>\n" ); |
|---|
| 4302 | websWrite( wp, "</div>\n" ); |
|---|
| 4303 | websWrite( wp, "<script>\n//<![CDATA[\n " ); |
|---|
| 4304 | websWrite( wp, |
|---|
| 4305 | "show_layer_ext(document.getElementsByName(\"%s_acct\"), \"%s_idacct\", %s);\n", |
|---|
| 4306 | prefix, vvar, nvram_match( acct, |
|---|
| 4307 | "1" ) ? "true" : "false" ); |
|---|
| 4308 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4309 | } |
|---|
| 4310 | #endif |
|---|
| 4311 | } |
|---|
| 4312 | |
|---|
| 4313 | #ifdef HAVE_WPA_SUPPLICANT |
|---|
| 4314 | #ifndef HAVE_MICRO |
|---|
| 4315 | |
|---|
| 4316 | static void init_80211x_layers( webs_t wp, char *prefix ) |
|---|
| 4317 | { |
|---|
| 4318 | if (nvram_prefix_match( "8021xtype", prefix, "tls")) |
|---|
| 4319 | { |
|---|
| 4320 | websWrite(wp,"enable_idtls(%s);\n",prefix); |
|---|
| 4321 | } |
|---|
| 4322 | if (nvram_prefix_match( "8021xtype", prefix, "leap")) |
|---|
| 4323 | { |
|---|
| 4324 | websWrite(wp,"enable_idleap(%s);\n",prefix); |
|---|
| 4325 | } |
|---|
| 4326 | if (nvram_prefix_match( "8021xtype", prefix, "ttls")) |
|---|
| 4327 | { |
|---|
| 4328 | websWrite(wp,"enable_idttls(%s);\n",prefix); |
|---|
| 4329 | } |
|---|
| 4330 | if (nvram_prefix_match( "8021xtype", prefix, "peap")) |
|---|
| 4331 | { |
|---|
| 4332 | websWrite(wp,"enable_idpeap(%s);\n",prefix); |
|---|
| 4333 | } |
|---|
| 4334 | } |
|---|
| 4335 | |
|---|
| 4336 | void ej_init_80211x_layers( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4337 | { |
|---|
| 4338 | #ifndef HAVE_MADWIFI |
|---|
| 4339 | int c = get_wl_instances( ); |
|---|
| 4340 | int i; |
|---|
| 4341 | |
|---|
| 4342 | for( i = 0; i < c; i++ ) |
|---|
| 4343 | { |
|---|
| 4344 | char buf[16]; |
|---|
| 4345 | |
|---|
| 4346 | sprintf( buf, "wl%d", i ); |
|---|
| 4347 | init_80211x_layers( wp, buf ); |
|---|
| 4348 | } |
|---|
| 4349 | return; |
|---|
| 4350 | #else |
|---|
| 4351 | int c = getdevicecount( ); |
|---|
| 4352 | int i; |
|---|
| 4353 | |
|---|
| 4354 | for( i = 0; i < c; i++ ) |
|---|
| 4355 | { |
|---|
| 4356 | char buf[16]; |
|---|
| 4357 | |
|---|
| 4358 | sprintf( buf, "ath%d", i ); |
|---|
| 4359 | init_80211x_layers( wp, buf ); |
|---|
| 4360 | } |
|---|
| 4361 | return; |
|---|
| 4362 | #endif |
|---|
| 4363 | |
|---|
| 4364 | } |
|---|
| 4365 | |
|---|
| 4366 | void show_80211X( webs_t wp, char *prefix ) |
|---|
| 4367 | { |
|---|
| 4368 | /* |
|---|
| 4369 | * fields |
|---|
| 4370 | * _8021xtype |
|---|
| 4371 | * _8021xuser |
|---|
| 4372 | * _8021xpasswd |
|---|
| 4373 | * _8021xca |
|---|
| 4374 | * _8021xpem |
|---|
| 4375 | * _8021xprv |
|---|
| 4376 | */ |
|---|
| 4377 | char type[32]; |
|---|
| 4378 | |
|---|
| 4379 | sprintf( type, "%s_8021xtype", prefix ); |
|---|
| 4380 | nvram_default_get( type, "ttls" ); |
|---|
| 4381 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4382 | websWrite( wp, |
|---|
| 4383 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.xsuptype)</script></div>\n" ); |
|---|
| 4384 | websWrite( wp, |
|---|
| 4385 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"peap\" onclick=\"enable_idpeap('%s')\" %s />Peap \n", |
|---|
| 4386 | prefix, prefix, nvram_prefix_match( "8021xtype", prefix, |
|---|
| 4387 | "peap" ) ? |
|---|
| 4388 | "checked=\"checked\"" : "" ); |
|---|
| 4389 | websWrite( wp, |
|---|
| 4390 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"leap\" onclick=\"enable_idleap('%s')\" %s />Leap \n", |
|---|
| 4391 | prefix, prefix, nvram_prefix_match( "8021xtype", prefix, |
|---|
| 4392 | "leap" ) ? |
|---|
| 4393 | "checked=\"checked\"" : "" ); |
|---|
| 4394 | websWrite( wp, |
|---|
| 4395 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"tls\" onclick=\"enable_idtls('%s')\" %s />TLS \n", |
|---|
| 4396 | prefix, prefix, nvram_prefix_match( "8021xtype", prefix, |
|---|
| 4397 | "tls" ) ? |
|---|
| 4398 | "checked=\"checked\"" : "" ); |
|---|
| 4399 | websWrite( wp, |
|---|
| 4400 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"ttls\" onclick=\"enable_idttls('%s')\" %s />TTLS \n", |
|---|
| 4401 | prefix, prefix, nvram_prefix_match( "8021xtype", prefix, |
|---|
| 4402 | "ttls" ) ? |
|---|
| 4403 | "checked=\"checked\"" : "" ); |
|---|
| 4404 | websWrite( wp, "</div>\n" ); |
|---|
| 4405 | // ttls authentication |
|---|
| 4406 | websWrite( wp, "<div id=\"idttls%s\">\n", prefix ); |
|---|
| 4407 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4408 | websWrite( wp, |
|---|
| 4409 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n" ); |
|---|
| 4410 | websWrite( wp, |
|---|
| 4411 | "<input name=\"%s_ttls8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4412 | prefix, nvram_prefix_get( "ttls8021xuser", prefix ) ); |
|---|
| 4413 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4414 | websWrite( wp, |
|---|
| 4415 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n" ); |
|---|
| 4416 | websWrite( wp, |
|---|
| 4417 | "<input name=\"%s_ttls8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4418 | prefix, nvram_prefix_get( "ttls8021xpasswd", prefix ) ); |
|---|
| 4419 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4420 | websWrite( wp, |
|---|
| 4421 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.servercertif)</script></div>\n" ); |
|---|
| 4422 | websWrite( wp, |
|---|
| 4423 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_ttls8021xca\" name=\"%s_ttls8021xca\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4424 | prefix, prefix ); |
|---|
| 4425 | websWrite( wp, "var %s_ttls8021xca = fix_cr( '%s' );\n", prefix, |
|---|
| 4426 | nvram_prefix_get( "ttls8021xca", prefix ) ); |
|---|
| 4427 | websWrite( wp, |
|---|
| 4428 | "document.getElementById(\"%s_ttls8021xca\").value = %s_ttls8021xca;\n", |
|---|
| 4429 | prefix, prefix ); |
|---|
| 4430 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4431 | websWrite( wp, "</div>\n" ); |
|---|
| 4432 | websWrite( wp, "</div>\n" ); |
|---|
| 4433 | |
|---|
| 4434 | // peap authentication |
|---|
| 4435 | websWrite( wp, "<div id=\"idpeap%s\">\n", prefix ); |
|---|
| 4436 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4437 | websWrite( wp, |
|---|
| 4438 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n" ); |
|---|
| 4439 | websWrite( wp, |
|---|
| 4440 | "<input name=\"%s_peap8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4441 | prefix, nvram_prefix_get( "peap8021xuser", prefix ) ); |
|---|
| 4442 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4443 | websWrite( wp, |
|---|
| 4444 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n" ); |
|---|
| 4445 | websWrite( wp, |
|---|
| 4446 | "<input name=\"%s_peap8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4447 | prefix, nvram_prefix_get( "peap8021xpasswd", prefix ) ); |
|---|
| 4448 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4449 | websWrite( wp, |
|---|
| 4450 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.servercertif)</script></div>\n" ); |
|---|
| 4451 | websWrite( wp, |
|---|
| 4452 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_peap8021xca\" name=\"%s_peap8021xca\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4453 | prefix, prefix ); |
|---|
| 4454 | websWrite( wp, "var %s_peap8021xca = fix_cr( '%s' );\n", prefix, |
|---|
| 4455 | nvram_prefix_get( "peap8021xca", prefix ) ); |
|---|
| 4456 | websWrite( wp, |
|---|
| 4457 | "document.getElementById(\"%s_peap8021xca\").value = %s_peap8021xca;\n", |
|---|
| 4458 | prefix, prefix ); |
|---|
| 4459 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4460 | websWrite( wp, "</div>\n" ); |
|---|
| 4461 | websWrite( wp, "</div>\n" ); |
|---|
| 4462 | // leap authentication |
|---|
| 4463 | websWrite( wp, "<div id=\"idleap%s\">\n", prefix ); |
|---|
| 4464 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4465 | websWrite( wp, |
|---|
| 4466 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n" ); |
|---|
| 4467 | websWrite( wp, |
|---|
| 4468 | "<input name=\"%s_leap8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4469 | prefix, nvram_prefix_get( "leap8021xuser", prefix ) ); |
|---|
| 4470 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4471 | websWrite( wp, |
|---|
| 4472 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n" ); |
|---|
| 4473 | websWrite( wp, |
|---|
| 4474 | "<input name=\"%s_leap8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4475 | prefix, nvram_prefix_get( "leap8021xpasswd", prefix ) ); |
|---|
| 4476 | websWrite( wp, "</div>\n" ); |
|---|
| 4477 | |
|---|
| 4478 | // tls authentication |
|---|
| 4479 | websWrite( wp, "<div id=\"idtls%s\">\n", prefix ); |
|---|
| 4480 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4481 | websWrite( wp, |
|---|
| 4482 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n" ); |
|---|
| 4483 | websWrite( wp, |
|---|
| 4484 | "<input name=\"%s_tls8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4485 | prefix, nvram_prefix_get( "tls8021xuser", prefix ) ); |
|---|
| 4486 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4487 | websWrite( wp, |
|---|
| 4488 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n" ); |
|---|
| 4489 | websWrite( wp, |
|---|
| 4490 | "<input name=\"%s_tls8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4491 | prefix, nvram_prefix_get( "tls8021xpasswd", prefix ) ); |
|---|
| 4492 | |
|---|
| 4493 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4494 | websWrite( wp, |
|---|
| 4495 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.servercertif)</script></div>\n" ); |
|---|
| 4496 | websWrite( wp, |
|---|
| 4497 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xca\" name=\"%s_tls8021xca\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4498 | prefix, prefix ); |
|---|
| 4499 | websWrite( wp, "var %s_tls8021xca = fix_cr( '%s' );\n", prefix, |
|---|
| 4500 | nvram_prefix_get( "tls8021xca", prefix ) ); |
|---|
| 4501 | websWrite( wp, |
|---|
| 4502 | "document.getElementById(\"%s_tls8021xca\").value = %s_tls8021xca;\n", |
|---|
| 4503 | prefix, prefix ); |
|---|
| 4504 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4505 | websWrite( wp, "</div>\n" ); |
|---|
| 4506 | |
|---|
| 4507 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4508 | websWrite( wp, |
|---|
| 4509 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.clientcertif)</script></div>\n" ); |
|---|
| 4510 | websWrite( wp, |
|---|
| 4511 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xpem\" name=\"%s_tls8021xpem\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4512 | prefix, prefix ); |
|---|
| 4513 | websWrite( wp, "var %s_tls8021xpem = fix_cr( '%s' );\n", prefix, |
|---|
| 4514 | nvram_prefix_get( "tls8021xpem", prefix ) ); |
|---|
| 4515 | websWrite( wp, |
|---|
| 4516 | "document.getElementById(\"%s_tls8021xpem\").value = %s_tls8021xpem;\n", |
|---|
| 4517 | prefix, prefix ); |
|---|
| 4518 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4519 | websWrite( wp, "</div>\n" ); |
|---|
| 4520 | |
|---|
| 4521 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4522 | websWrite( wp, |
|---|
| 4523 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.privatekey)</script></div>\n" ); |
|---|
| 4524 | websWrite( wp, |
|---|
| 4525 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xprv\" name=\"%s_tls8021xprv\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4526 | prefix, prefix ); |
|---|
| 4527 | websWrite( wp, "var %s_tls8021xprv = fix_cr( '%s' );\n", prefix, |
|---|
| 4528 | nvram_prefix_get( "tls8021xprv", prefix ) ); |
|---|
| 4529 | websWrite( wp, |
|---|
| 4530 | "document.getElementById(\"%s_tls8021xprv\").value = %s_tls8021xprv;\n", |
|---|
| 4531 | prefix, prefix ); |
|---|
| 4532 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4533 | websWrite( wp, "</div>\n" ); |
|---|
| 4534 | |
|---|
| 4535 | websWrite( wp, "</div>\n" ); |
|---|
| 4536 | websWrite( wp, "<script>\n//<![CDATA[\n " ); |
|---|
| 4537 | // websWrite |
|---|
| 4538 | // (wp,"show_layer_ext(document.getElementsByName(\"%s_bridged\"), |
|---|
| 4539 | // \"%s_idnetvifs\", %s);\n",var, vvar, nvram_match (ssid, "0") ? "true" |
|---|
| 4540 | // : "false"); |
|---|
| 4541 | char peap[32]; |
|---|
| 4542 | |
|---|
| 4543 | sprintf( peap, "%s_8021xtype", prefix ); |
|---|
| 4544 | websWrite( wp, |
|---|
| 4545 | "show_layer_ext(document.wpa.%s_8021xtype, 'idpeap%s', %s);\n", |
|---|
| 4546 | prefix, prefix, nvram_match( peap, |
|---|
| 4547 | "peap" ) ? "true" : "false" ); |
|---|
| 4548 | websWrite( wp, |
|---|
| 4549 | "show_layer_ext(document.wpa.%s_8021xtype, 'idtls%s', %s);\n", |
|---|
| 4550 | prefix, prefix, nvram_match( peap, |
|---|
| 4551 | "tls" ) ? "true" : "false" ); |
|---|
| 4552 | websWrite( wp, |
|---|
| 4553 | "show_layer_ext(document.wpa.%s_8021xtype, 'idleap%s', %s);\n", |
|---|
| 4554 | prefix, prefix, nvram_match( peap, |
|---|
| 4555 | "leap" ) ? "true" : "false" ); |
|---|
| 4556 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4557 | |
|---|
| 4558 | } |
|---|
| 4559 | #endif |
|---|
| 4560 | #endif |
|---|
| 4561 | |
|---|
| 4562 | void show_wparadius( webs_t wp, char *prefix ) |
|---|
| 4563 | { |
|---|
| 4564 | char var[80]; |
|---|
| 4565 | |
|---|
| 4566 | websWrite( wp, "<div>\n" ); |
|---|
| 4567 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4568 | websWrite( wp, |
|---|
| 4569 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.algorithms)</script></div>\n" ); |
|---|
| 4570 | websWrite( wp, "<select name=\"%s_crypto\">\n", prefix ); |
|---|
| 4571 | sprintf( var, "%s_crypto", prefix ); |
|---|
| 4572 | websWrite( wp, "<option value=\"tkip\" %s>TKIP</option>\n", |
|---|
| 4573 | selmatch( var, "tkip", "selected=\"selected\"" ) ); |
|---|
| 4574 | websWrite( wp, "<option value=\"aes\" %s>AES</option>\n", |
|---|
| 4575 | selmatch( var, "aes", "selected=\"selected\"" ) ); |
|---|
| 4576 | websWrite( wp, "<option value=\"tkip+aes\" %s>TKIP+AES</option>\n", |
|---|
| 4577 | selmatch( var, "tkip+aes", "selected=\"selected\"" ) ); |
|---|
| 4578 | websWrite( wp, "</select></div>\n" ); |
|---|
| 4579 | show_radius( wp, prefix, 0 ); |
|---|
| 4580 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4581 | websWrite( wp, |
|---|
| 4582 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.rekey)</script></div>\n" ); |
|---|
| 4583 | sprintf( var, "%s_wpa_gtk_rekey", prefix ); |
|---|
| 4584 | websWrite( wp, |
|---|
| 4585 | "<input name=\"%s_wpa_gtk_rekey\" maxlength=\"5\" size=\"10\" onblur=\"valid_range(this,0,99999,wpa.rekey)\" value=\"%s\" />", |
|---|
| 4586 | prefix, nvram_default_get( var, "3600" ) ); |
|---|
| 4587 | websWrite( wp, "</div>\n" ); |
|---|
| 4588 | websWrite( wp, "</div>\n" ); |
|---|
| 4589 | } |
|---|
| 4590 | |
|---|
| 4591 | void show_wep( webs_t wp, char *prefix ) |
|---|
| 4592 | { |
|---|
| 4593 | char var[80]; |
|---|
| 4594 | char *bit; |
|---|
| 4595 | |
|---|
| 4596 | cprintf( "show wep\n" ); |
|---|
| 4597 | websWrite( wp, |
|---|
| 4598 | "<div><div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wep.defkey)</script></div>" ); |
|---|
| 4599 | websWrite( wp, "<input type=\"hidden\" name=\"%s_WEP_key\" />", prefix ); |
|---|
| 4600 | websWrite( wp, |
|---|
| 4601 | "<input type=\"hidden\" name=\"%s_wep\" value=\"restricted\" />", |
|---|
| 4602 | prefix ); |
|---|
| 4603 | sprintf( var, "%s_key", prefix ); |
|---|
| 4604 | nvram_default_get( var, "1" ); |
|---|
| 4605 | websWrite( wp, |
|---|
| 4606 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s_key\" %s />1 \n", |
|---|
| 4607 | prefix, selmatch( var, "1", "checked=\"checked\"" ) ); |
|---|
| 4608 | websWrite( wp, |
|---|
| 4609 | "<input class=\"spaceradio\" type=\"radio\" value=\"2\" name=\"%s_key\" %s />2 \n", |
|---|
| 4610 | prefix, selmatch( var, "2", "checked=\"checked\"" ) ); |
|---|
| 4611 | websWrite( wp, |
|---|
| 4612 | "<input class=\"spaceradio\" type=\"radio\" value=\"3\" name=\"%s_key\" %s />3 \n", |
|---|
| 4613 | prefix, selmatch( var, "3", "checked=\"checked\"" ) ); |
|---|
| 4614 | websWrite( wp, |
|---|
| 4615 | "<input class=\"spaceradio\" type=\"radio\" value=\"4\" name=\"%s_key\" %s />4 \n", |
|---|
| 4616 | prefix, selmatch( var, "4", "checked=\"checked\"" ) ); |
|---|
| 4617 | websWrite( wp, "</div>" ); |
|---|
| 4618 | websWrite( wp, |
|---|
| 4619 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.encrypt)</script></div>" ); |
|---|
| 4620 | |
|---|
| 4621 | sprintf( var, "%s_wep_bit", prefix ); |
|---|
| 4622 | bit = nvram_safe_get( var ); |
|---|
| 4623 | |
|---|
| 4624 | cprintf( "bit %s\n", bit ); |
|---|
| 4625 | |
|---|
| 4626 | websWrite( wp, |
|---|
| 4627 | "<select name=\"%s_wep_bit\" size=\"1\" onchange=keyMode(this.form)>", |
|---|
| 4628 | prefix ); |
|---|
| 4629 | websWrite( wp, "<option value=\"64\" %s >64 bits 10 hex digits</option>", |
|---|
| 4630 | selmatch( var, "64", "selected=\"selected\"" ) ); |
|---|
| 4631 | websWrite( wp, |
|---|
| 4632 | "<option value=\"128\" %s >128 bits 26 hex digits</option>", |
|---|
| 4633 | selmatch( var, "128", "selected=\"selected\"" ) ); |
|---|
| 4634 | websWrite( wp, |
|---|
| 4635 | "</select>\n</div>\n<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wep.passphrase)</script></div>\n" ); |
|---|
| 4636 | websWrite( wp, |
|---|
| 4637 | "<input name=%s_passphrase maxlength=\"16\" size=\"20\" value=\"", |
|---|
| 4638 | prefix ); |
|---|
| 4639 | |
|---|
| 4640 | char p_temp[128]; |
|---|
| 4641 | char temp[256]; |
|---|
| 4642 | sprintf( p_temp, "%s", get_wep_value(temp, "passphrase", bit, prefix ) ); |
|---|
| 4643 | nvram_set( "passphrase_temp", p_temp ); |
|---|
| 4644 | tf_webWriteESCNV( wp, "passphrase_temp" ); |
|---|
| 4645 | nvram_unset( "passphrase_temp" ); |
|---|
| 4646 | |
|---|
| 4647 | websWrite( wp, "\" />" ); |
|---|
| 4648 | websWrite( wp, |
|---|
| 4649 | "<input type=\"hidden\" value=\"Null\" name=\"generateButton\" />\n" ); |
|---|
| 4650 | websWrite( wp, |
|---|
| 4651 | "<input class=\"button\" type=\"button\" value=\"Generate\" onclick=generateKey(this.form,\"%s\") name=wepGenerate />\n</div>", |
|---|
| 4652 | prefix ); |
|---|
| 4653 | |
|---|
| 4654 | char *mlen = "10"; |
|---|
| 4655 | char *mlen2 = "12"; |
|---|
| 4656 | |
|---|
| 4657 | if( !strcmp( bit, "128" ) ) |
|---|
| 4658 | { |
|---|
| 4659 | mlen = "26"; |
|---|
| 4660 | mlen2 = "30"; |
|---|
| 4661 | } |
|---|
| 4662 | websWrite( wp, |
|---|
| 4663 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 1</div>\n" ); |
|---|
| 4664 | websWrite( wp, |
|---|
| 4665 | "<input name=%s_key1 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 4666 | prefix, mlen2, mlen, get_wep_value(temp, "key1", bit, prefix ) ); |
|---|
| 4667 | websWrite( wp, |
|---|
| 4668 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 2</div>\n" ); |
|---|
| 4669 | websWrite( wp, |
|---|
| 4670 | "<input name=%s_key2 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 4671 | prefix, mlen2, mlen, get_wep_value(temp, "key2", bit, prefix ) ); |
|---|
| 4672 | websWrite( wp, |
|---|
| 4673 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 3</div>\n" ); |
|---|
| 4674 | websWrite( wp, |
|---|
| 4675 | "<input name=%s_key3 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 4676 | prefix, mlen2, mlen, get_wep_value(temp, "key3", bit, prefix ) ); |
|---|
| 4677 | websWrite( wp, |
|---|
| 4678 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 4</div>\n" ); |
|---|
| 4679 | websWrite( wp, |
|---|
| 4680 | "<input name=%s_key4 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 4681 | prefix, mlen2, mlen, get_wep_value(temp, "key4", bit, prefix ) ); |
|---|
| 4682 | websWrite( wp, "</div>\n" ); |
|---|
| 4683 | } |
|---|
| 4684 | |
|---|
| 4685 | #endif |
|---|
| 4686 | |
|---|
| 4687 | void ej_get_wds_mac( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4688 | { |
|---|
| 4689 | int mac = -1, wds_idx = -1, mac_idx = -1; |
|---|
| 4690 | char *c, wds_var[32] = ""; |
|---|
| 4691 | |
|---|
| 4692 | char *interface; |
|---|
| 4693 | |
|---|
| 4694 | if( ejArgs( argc, argv, "%d %d %s", &wds_idx, &mac_idx, &interface ) < 3 ) |
|---|
| 4695 | { |
|---|
| 4696 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 4697 | return; |
|---|
| 4698 | } |
|---|
| 4699 | else if( wds_idx < 1 || wds_idx > MAX_WDS_DEVS ) |
|---|
| 4700 | return; |
|---|
| 4701 | else if( mac_idx < 0 || mac_idx > 5 ) |
|---|
| 4702 | return; |
|---|
| 4703 | |
|---|
| 4704 | snprintf( wds_var, 31, "%s_wds%d_hwaddr", interface, wds_idx ); |
|---|
| 4705 | |
|---|
| 4706 | c = nvram_safe_get( wds_var ); |
|---|
| 4707 | |
|---|
| 4708 | if( c ) |
|---|
| 4709 | { |
|---|
| 4710 | mac = get_single_mac( c, mac_idx ); |
|---|
| 4711 | websWrite( wp, "%02X", mac ); |
|---|
| 4712 | } |
|---|
| 4713 | else |
|---|
| 4714 | websWrite( wp, "00" ); |
|---|
| 4715 | |
|---|
| 4716 | return; |
|---|
| 4717 | |
|---|
| 4718 | } |
|---|
| 4719 | |
|---|
| 4720 | void ej_showbridgesettings( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4721 | { |
|---|
| 4722 | char *interface; |
|---|
| 4723 | int mcast; |
|---|
| 4724 | |
|---|
| 4725 | #ifdef FASTWEB |
|---|
| 4726 | ejArgs( argc, argv, "%s %d", &interface, &mcast ); |
|---|
| 4727 | #else |
|---|
| 4728 | if( ejArgs( argc, argv, "%s %d", &interface, &mcast ) < 2 ) |
|---|
| 4729 | { |
|---|
| 4730 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 4731 | return; |
|---|
| 4732 | } |
|---|
| 4733 | #endif |
|---|
| 4734 | showbridgesettings( wp, interface, mcast ); |
|---|
| 4735 | } |
|---|
| 4736 | |
|---|
| 4737 | void ej_get_wds_ip( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4738 | { |
|---|
| 4739 | int ip = -1, wds_idx = -1, ip_idx = -1; |
|---|
| 4740 | char *c, wds_var[32] = ""; |
|---|
| 4741 | |
|---|
| 4742 | char *interface; |
|---|
| 4743 | |
|---|
| 4744 | #ifdef FASTWEB |
|---|
| 4745 | ejArgs( argc, argv, "%d %d %s", &wds_idx, &ip_idx, &interface ); |
|---|
| 4746 | #else |
|---|
| 4747 | if( ejArgs( argc, argv, "%d %d %s", &wds_idx, &ip_idx, &interface ) < 3 ) |
|---|
| 4748 | { |
|---|
| 4749 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 4750 | return; |
|---|
| 4751 | } |
|---|
| 4752 | #endif |
|---|
| 4753 | if( wds_idx < 1 || wds_idx > MAX_WDS_DEVS ) |
|---|
| 4754 | return; |
|---|
| 4755 | else if( ip_idx < 0 || ip_idx > 3 ) |
|---|
| 4756 | return; |
|---|
| 4757 | |
|---|
| 4758 | snprintf( wds_var, 31, "%s_wds%d_ipaddr", interface, wds_idx ); |
|---|
| 4759 | |
|---|
| 4760 | c = nvram_safe_get( wds_var ); |
|---|
| 4761 | |
|---|
| 4762 | if( c ) |
|---|
| 4763 | { |
|---|
| 4764 | ip = get_single_ip( c, ip_idx ); |
|---|
| 4765 | websWrite( wp, "%d", ip ); |
|---|
| 4766 | } |
|---|
| 4767 | else |
|---|
| 4768 | websWrite( wp, "0" ); |
|---|
| 4769 | |
|---|
| 4770 | return; |
|---|
| 4771 | |
|---|
| 4772 | } |
|---|
| 4773 | |
|---|
| 4774 | void ej_get_wds_netmask( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4775 | { |
|---|
| 4776 | int nm = -1, wds_idx = -1, nm_idx = -1; |
|---|
| 4777 | char *c, wds_var[32] = ""; |
|---|
| 4778 | |
|---|
| 4779 | char *interface; |
|---|
| 4780 | |
|---|
| 4781 | #ifdef FASTWEB |
|---|
| 4782 | ejArgs( argc, argv, "%d %d %s", &wds_idx, &nm_idx, &interface ); |
|---|
| 4783 | #else |
|---|
| 4784 | if( ejArgs( argc, argv, "%d %d %s", &wds_idx, &nm_idx, &interface ) < 3 ) |
|---|
| 4785 | { |
|---|
| 4786 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 4787 | return; |
|---|
| 4788 | } |
|---|
| 4789 | #endif |
|---|
| 4790 | |
|---|
| 4791 | if( wds_idx < 1 || wds_idx > 6 ) |
|---|
| 4792 | return; |
|---|
| 4793 | else if( nm_idx < 0 || nm_idx > 3 ) |
|---|
| 4794 | return; |
|---|
| 4795 | |
|---|
| 4796 | snprintf( wds_var, 31, "%s_wds%d_netmask", interface, wds_idx ); |
|---|
| 4797 | |
|---|
| 4798 | c = nvram_safe_get( wds_var ); |
|---|
| 4799 | |
|---|
| 4800 | if( c ) |
|---|
| 4801 | { |
|---|
| 4802 | nm = get_single_ip( c, nm_idx ); |
|---|
| 4803 | websWrite( wp, "%d", nm ); |
|---|
| 4804 | } |
|---|
| 4805 | else |
|---|
| 4806 | websWrite( wp, "255" ); |
|---|
| 4807 | |
|---|
| 4808 | return; |
|---|
| 4809 | |
|---|
| 4810 | } |
|---|
| 4811 | |
|---|
| 4812 | void ej_get_wds_gw( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4813 | { |
|---|
| 4814 | int gw = -1, wds_idx = -1, gw_idx = -1; |
|---|
| 4815 | char *c, wds_var[32] = ""; |
|---|
| 4816 | |
|---|
| 4817 | char *interface; |
|---|
| 4818 | |
|---|
| 4819 | #ifdef FASTWEB |
|---|
| 4820 | ejArgs( argc, argv, "%d %d %s", &wds_idx, &gw_idx, &interface ); |
|---|
| 4821 | #else |
|---|
| 4822 | if( ejArgs( argc, argv, "%d %d %s", &wds_idx, &gw_idx, &interface ) < 3 ) |
|---|
| 4823 | { |
|---|
| 4824 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 4825 | return; |
|---|
| 4826 | } |
|---|
| 4827 | #endif |
|---|
| 4828 | |
|---|
| 4829 | if( wds_idx < 1 || wds_idx > MAX_WDS_DEVS ) |
|---|
| 4830 | return; |
|---|
| 4831 | else if( gw_idx < 0 || gw_idx > 3 ) |
|---|
| 4832 | return; |
|---|
| 4833 | |
|---|
| 4834 | snprintf( wds_var, 31, "%s_wds%d_gw", interface, wds_idx ); |
|---|
| 4835 | |
|---|
| 4836 | c = nvram_safe_get( wds_var ); |
|---|
| 4837 | |
|---|
| 4838 | if( c ) |
|---|
| 4839 | { |
|---|
| 4840 | gw = get_single_ip( c, gw_idx ); |
|---|
| 4841 | websWrite( wp, "%d", gw ); |
|---|
| 4842 | } |
|---|
| 4843 | else |
|---|
| 4844 | websWrite( wp, "0" ); |
|---|
| 4845 | |
|---|
| 4846 | return; |
|---|
| 4847 | |
|---|
| 4848 | } |
|---|
| 4849 | |
|---|
| 4850 | void ej_get_br1_ip( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4851 | { |
|---|
| 4852 | int ip = -1, ip_idx = -1; |
|---|
| 4853 | char *c; |
|---|
| 4854 | |
|---|
| 4855 | char *interface; |
|---|
| 4856 | |
|---|
| 4857 | #ifdef FASTWEB |
|---|
| 4858 | ejArgs( argc, argv, "%d %s", &ip_idx, &interface ); |
|---|
| 4859 | #else |
|---|
| 4860 | if( ejArgs( argc, argv, "%d %s", &ip_idx, &interface ) < 2 ) |
|---|
| 4861 | { |
|---|
| 4862 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 4863 | return; |
|---|
| 4864 | } |
|---|
| 4865 | #endif |
|---|
| 4866 | if( ip_idx < 0 || ip_idx > 3 ) |
|---|
| 4867 | return; |
|---|
| 4868 | char br1[32]; |
|---|
| 4869 | |
|---|
| 4870 | sprintf( br1, "%s_br1_ipaddr", interface ); |
|---|
| 4871 | c = nvram_safe_get( br1 ); |
|---|
| 4872 | |
|---|
| 4873 | if( c ) |
|---|
| 4874 | { |
|---|
| 4875 | ip = get_single_ip( c, ip_idx ); |
|---|
| 4876 | websWrite( wp, "%d", ip ); |
|---|
| 4877 | } |
|---|
| 4878 | else |
|---|
| 4879 | websWrite( wp, "0" ); |
|---|
| 4880 | |
|---|
| 4881 | return; |
|---|
| 4882 | |
|---|
| 4883 | } |
|---|
| 4884 | |
|---|
| 4885 | void ej_get_br1_netmask( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4886 | { |
|---|
| 4887 | int nm = -1, nm_idx = -1; |
|---|
| 4888 | char *c; |
|---|
| 4889 | |
|---|
| 4890 | char *interface; |
|---|
| 4891 | |
|---|
| 4892 | #ifdef FASTWEB |
|---|
| 4893 | ejArgs( argc, argv, "%d %s", &nm_idx, &interface ); |
|---|
| 4894 | #else |
|---|
| 4895 | if( ejArgs( argc, argv, "%d %s", &nm_idx, &interface ) < 2 ) |
|---|
| 4896 | { |
|---|
| 4897 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 4898 | return; |
|---|
| 4899 | } |
|---|
| 4900 | #endif |
|---|
| 4901 | if( nm_idx < 0 || nm_idx > 3 ) |
|---|
| 4902 | return; |
|---|
| 4903 | char nms[32]; |
|---|
| 4904 | |
|---|
| 4905 | sprintf( nms, "%s_br1_netmask", interface ); |
|---|
| 4906 | c = nvram_safe_get( nms ); |
|---|
| 4907 | |
|---|
| 4908 | if( c ) |
|---|
| 4909 | { |
|---|
| 4910 | nm = get_single_ip( c, nm_idx ); |
|---|
| 4911 | websWrite( wp, "%d", nm ); |
|---|
| 4912 | } |
|---|
| 4913 | else |
|---|
| 4914 | websWrite( wp, "255" ); |
|---|
| 4915 | |
|---|
| 4916 | return; |
|---|
| 4917 | |
|---|
| 4918 | } |
|---|
| 4919 | |
|---|
| 4920 | #ifndef HAVE_MADWIFI |
|---|
| 4921 | |
|---|
| 4922 | void ej_get_currate( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4923 | { |
|---|
| 4924 | int rate = 0; |
|---|
| 4925 | |
|---|
| 4926 | wl_ioctl( get_wdev( ), WLC_GET_RATE, &rate, sizeof( rate ) ); |
|---|
| 4927 | |
|---|
| 4928 | if( rate > 0 ) |
|---|
| 4929 | websWrite( wp, "%d%s Mbps", ( rate / 2 ), ( rate & 1 ) ? ".5" : "" ); |
|---|
| 4930 | else |
|---|
| 4931 | websWrite( wp, "%s", live_translate( "share.unknown" ) ); |
|---|
| 4932 | |
|---|
| 4933 | return; |
|---|
| 4934 | } |
|---|
| 4935 | |
|---|
| 4936 | void ej_show_acktiming( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4937 | { |
|---|
| 4938 | return; |
|---|
| 4939 | } |
|---|
| 4940 | |
|---|
| 4941 | void ej_update_acktiming( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4942 | { |
|---|
| 4943 | return; |
|---|
| 4944 | } |
|---|
| 4945 | |
|---|
| 4946 | #else |
|---|
| 4947 | |
|---|
| 4948 | int get_acktiming( void ) |
|---|
| 4949 | { |
|---|
| 4950 | char path[64]; |
|---|
| 4951 | int ifcount, ack = 0; |
|---|
| 4952 | |
|---|
| 4953 | strcpy( path, nvram_safe_get( "wifi_display" ) ); |
|---|
| 4954 | sscanf( path, "ath%d", &ifcount ); |
|---|
| 4955 | sprintf( path, "/proc/sys/dev/wifi%d/acktimeout", ifcount ); |
|---|
| 4956 | FILE *in = fopen( path, "rb" ); |
|---|
| 4957 | |
|---|
| 4958 | if( in != NULL ) |
|---|
| 4959 | { |
|---|
| 4960 | fscanf( in, "%d", &ack ); |
|---|
| 4961 | fclose( in ); |
|---|
| 4962 | } |
|---|
| 4963 | return ack; |
|---|
| 4964 | } |
|---|
| 4965 | |
|---|
| 4966 | void ej_show_acktiming( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4967 | { |
|---|
| 4968 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4969 | websWrite( wp, "<div class=\"label\">%s</div>\n", |
|---|
| 4970 | live_translate( "share.acktiming" ) ); |
|---|
| 4971 | int ack = get_acktiming( ); |
|---|
| 4972 | int distance = ( ( ack - 3 ) / 2 ) * 300; |
|---|
| 4973 | |
|---|
| 4974 | websWrite( wp, "<span id=\"wl_ack\">%dµs (%dm)</span> \n", ack, |
|---|
| 4975 | distance ); |
|---|
| 4976 | websWrite( wp, "</div>\n" ); |
|---|
| 4977 | } |
|---|
| 4978 | |
|---|
| 4979 | void ej_update_acktiming( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4980 | { |
|---|
| 4981 | int ack = get_acktiming( ); |
|---|
| 4982 | int distance = ( ( ack - 3 ) / 2 ) * 300; |
|---|
| 4983 | |
|---|
| 4984 | websWrite( wp, "%dµs (%dm)", ack, distance ); |
|---|
| 4985 | } |
|---|
| 4986 | |
|---|
| 4987 | extern float wifi_getrate( char *ifname ); |
|---|
| 4988 | |
|---|
| 4989 | #define KILO 1e3 |
|---|
| 4990 | #define MEGA 1e6 |
|---|
| 4991 | #define GIGA 1e9 |
|---|
| 4992 | |
|---|
| 4993 | void ej_get_currate( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4994 | { |
|---|
| 4995 | char mode[32]; |
|---|
| 4996 | int state = get_radiostate( nvram_safe_get( "wifi_display" ) ); |
|---|
| 4997 | |
|---|
| 4998 | if( state == 0 || state == -1 ) |
|---|
| 4999 | { |
|---|
| 5000 | websWrite( wp, "%s", live_translate( "share.disabled" ) ); |
|---|
| 5001 | return; |
|---|
| 5002 | } |
|---|
| 5003 | float rate = wifi_getrate( nvram_safe_get( "wifi_display" ) ); |
|---|
| 5004 | char scale; |
|---|
| 5005 | int divisor; |
|---|
| 5006 | |
|---|
| 5007 | if( rate >= GIGA ) |
|---|
| 5008 | { |
|---|
| 5009 | scale = 'G'; |
|---|
| 5010 | divisor = GIGA; |
|---|
| 5011 | } |
|---|
| 5012 | else |
|---|
| 5013 | { |
|---|
| 5014 | if( rate >= MEGA ) |
|---|
| 5015 | { |
|---|
| 5016 | scale = 'M'; |
|---|
| 5017 | divisor = MEGA; |
|---|
| 5018 | } |
|---|
| 5019 | else |
|---|
| 5020 | { |
|---|
| 5021 | scale = 'k'; |
|---|
| 5022 | divisor = KILO; |
|---|
| 5023 | } |
|---|
| 5024 | } |
|---|
| 5025 | sprintf( mode, "%s_channelbw", nvram_safe_get( "wifi_display" ) ); |
|---|
| 5026 | if( nvram_match( mode, "40" ) ) |
|---|
| 5027 | rate *= 2; |
|---|
| 5028 | if( rate > 0.0 ) |
|---|
| 5029 | { |
|---|
| 5030 | websWrite( wp, "%g %cb/s", rate / divisor, scale ); |
|---|
| 5031 | } |
|---|
| 5032 | else |
|---|
| 5033 | websWrite( wp, "%s", live_translate( "share.auto" ) ); |
|---|
| 5034 | |
|---|
| 5035 | } |
|---|
| 5036 | #endif |
|---|
| 5037 | |
|---|
| 5038 | void ej_get_uptime( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5039 | { |
|---|
| 5040 | char line[256]; |
|---|
| 5041 | FILE *fp; |
|---|
| 5042 | |
|---|
| 5043 | if( ( fp = popen( "uptime", "r" ) ) ) |
|---|
| 5044 | { |
|---|
| 5045 | fgets( line, sizeof( line ), fp ); |
|---|
| 5046 | line[strlen( line ) - 1] = '\0'; // replace new line with null |
|---|
| 5047 | websWrite( wp, "%s", line ); |
|---|
| 5048 | pclose( fp ); |
|---|
| 5049 | } |
|---|
| 5050 | return; |
|---|
| 5051 | } |
|---|
| 5052 | |
|---|
| 5053 | void ej_get_wan_uptime( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5054 | { |
|---|
| 5055 | float sys_uptime; |
|---|
| 5056 | float uptime; |
|---|
| 5057 | int days, minutes; |
|---|
| 5058 | FILE *fp, *fp2; |
|---|
| 5059 | |
|---|
| 5060 | if( nvram_match( "wan_proto", "disabled" ) ) |
|---|
| 5061 | return; |
|---|
| 5062 | if( !( fp = fopen( "/tmp/.wanuptime", "r" ) ) ) |
|---|
| 5063 | { |
|---|
| 5064 | websWrite( wp, "%s", live_translate( "status_router.notavail" ) ); |
|---|
| 5065 | return; |
|---|
| 5066 | } |
|---|
| 5067 | if( !feof( fp ) && fscanf( fp, "%f", &uptime ) == 1 ) |
|---|
| 5068 | { |
|---|
| 5069 | fp2 = fopen( "/proc/uptime", "r" ); |
|---|
| 5070 | fscanf( fp2, "%f", &sys_uptime ); |
|---|
| 5071 | fclose( fp2 ); |
|---|
| 5072 | uptime = sys_uptime - uptime; |
|---|
| 5073 | days = ( int )uptime / ( 60 * 60 * 24 ); |
|---|
| 5074 | if( days ) |
|---|
| 5075 | websWrite( wp, "%d day%s, ", days, ( days == 1 ? "" : "s" ) ); |
|---|
| 5076 | minutes = ( int )uptime / 60; |
|---|
| 5077 | websWrite( wp, "%d:%02d:%02d", ( minutes / 60 ) % 24, minutes % 60, |
|---|
| 5078 | ( int )uptime % 60 ); |
|---|
| 5079 | } |
|---|
| 5080 | fclose( fp ); |
|---|
| 5081 | |
|---|
| 5082 | return; |
|---|
| 5083 | |
|---|
| 5084 | } |
|---|
| 5085 | |
|---|
| 5086 | #ifndef HAVE_MADWIFI |
|---|
| 5087 | |
|---|
| 5088 | void ej_get_curchannel( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5089 | { |
|---|
| 5090 | channel_info_t ci; |
|---|
| 5091 | |
|---|
| 5092 | memset( &ci, 0, sizeof( ci ) ); |
|---|
| 5093 | wl_ioctl( get_wdev( ), WLC_GET_CHANNEL, &ci, sizeof( ci ) ); |
|---|
| 5094 | if( ci.scan_channel > 0 ) |
|---|
| 5095 | { |
|---|
| 5096 | websWrite( wp, "%d (scanning)", ci.scan_channel ); |
|---|
| 5097 | } |
|---|
| 5098 | else if( ci.hw_channel > 0 ) |
|---|
| 5099 | { |
|---|
| 5100 | websWrite( wp, "%d", ci.hw_channel ); |
|---|
| 5101 | } |
|---|
| 5102 | else |
|---|
| 5103 | // websWrite (wp, "unknown"); |
|---|
| 5104 | websWrite( wp, "%s", live_translate( "share.unknown" ) ); |
|---|
| 5105 | return; |
|---|
| 5106 | |
|---|
| 5107 | } |
|---|
| 5108 | |
|---|
| 5109 | #else |
|---|
| 5110 | |
|---|
| 5111 | void ej_get_curchannel( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5112 | { |
|---|
| 5113 | int channel = wifi_getchannel( nvram_safe_get( "wifi_display" ) ); |
|---|
| 5114 | |
|---|
| 5115 | if( channel > 0 && channel < 1000 ) |
|---|
| 5116 | { |
|---|
| 5117 | #ifdef HAVE_XR4SPECIAL |
|---|
| 5118 | char ofs[32]; |
|---|
| 5119 | |
|---|
| 5120 | sprintf( ofs, "%s_offset", nvram_safe_get( "wifi_display" ) ); |
|---|
| 5121 | int offset = atoi( nvram_default_get( ofs, "0" ) ); |
|---|
| 5122 | |
|---|
| 5123 | websWrite( wp, "%d (%d Mhz)", channel, |
|---|
| 5124 | ( wifi_getfreq( nvram_safe_get( "wifi_display" ) ) + |
|---|
| 5125 | offset ) ); |
|---|
| 5126 | #else |
|---|
| 5127 | websWrite( wp, "%d (%d Mhz)", channel, |
|---|
| 5128 | ( wifi_getfreq( nvram_safe_get( "wifi_display" ) ) + |
|---|
| 5129 | get_wifioffset( nvram_safe_get( "wifi_display" ) ) ) ); |
|---|
| 5130 | #endif |
|---|
| 5131 | } |
|---|
| 5132 | else |
|---|
| 5133 | // websWrite (wp, "unknown"); |
|---|
| 5134 | websWrite( wp, "%s", live_translate( "share.unknown" ) ); |
|---|
| 5135 | return; |
|---|
| 5136 | |
|---|
| 5137 | } |
|---|
| 5138 | #endif |
|---|
| 5139 | #ifdef HAVE_MADWIFI |
|---|
| 5140 | #include <sys/types.h> |
|---|
| 5141 | #include <sys/file.h> |
|---|
| 5142 | #include <sys/ioctl.h> |
|---|
| 5143 | #include <sys/socket.h> |
|---|
| 5144 | #include <stdio.h> |
|---|
| 5145 | #include <stdlib.h> |
|---|
| 5146 | #include <string.h> |
|---|
| 5147 | #include <stdint.h> |
|---|
| 5148 | #include <ctype.h> |
|---|
| 5149 | #include <getopt.h> |
|---|
| 5150 | #include <err.h> |
|---|
| 5151 | |
|---|
| 5152 | #include "wireless_copy.h" |
|---|
| 5153 | #include "net80211/ieee80211.h" |
|---|
| 5154 | #include "net80211/ieee80211_crypto.h" |
|---|
| 5155 | #include "net80211/ieee80211_ioctl.h" |
|---|
| 5156 | static const char *ieee80211_ntoa( const uint8_t mac[IEEE80211_ADDR_LEN] ) |
|---|
| 5157 | { |
|---|
| 5158 | static char a[18]; |
|---|
| 5159 | int i; |
|---|
| 5160 | |
|---|
| 5161 | i = snprintf( a, sizeof( a ), "%02x:%02x:%02x:%02x:%02x:%02x", |
|---|
| 5162 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] ); |
|---|
| 5163 | return ( i < 17 ? NULL : a ); |
|---|
| 5164 | } |
|---|
| 5165 | |
|---|
| 5166 | int |
|---|
| 5167 | ej_active_wireless_if( webs_t wp, int argc, char_t ** argv, |
|---|
| 5168 | char *ifname, int cnt, int turbo, int macmask ) |
|---|
| 5169 | { |
|---|
| 5170 | // unsigned char buf[24 * 1024]; |
|---|
| 5171 | |
|---|
| 5172 | unsigned char *cp; |
|---|
| 5173 | int s, len; |
|---|
| 5174 | struct iwreq iwr; |
|---|
| 5175 | |
|---|
| 5176 | if( !ifexists( ifname ) ) |
|---|
| 5177 | { |
|---|
| 5178 | printf( "IOCTL_STA_INFO ifresolv %s failed!\n", ifname ); |
|---|
| 5179 | return cnt; |
|---|
| 5180 | } |
|---|
| 5181 | int state = get_radiostate( ifname ); |
|---|
| 5182 | |
|---|
| 5183 | if( state == 0 || state == -1 ) |
|---|
| 5184 | { |
|---|
| 5185 | printf( "IOCTL_STA_INFO radio %s not enabled!\n", ifname ); |
|---|
| 5186 | return cnt; |
|---|
| 5187 | } |
|---|
| 5188 | s = socket( AF_INET, SOCK_DGRAM, 0 ); |
|---|
| 5189 | if( s < 0 ) |
|---|
| 5190 | { |
|---|
| 5191 | fprintf( stderr, "socket(SOCK_DRAGM)\n" ); |
|---|
| 5192 | return cnt; |
|---|
| 5193 | } |
|---|
| 5194 | ( void )memset( &iwr, 0, sizeof( struct iwreq ) ); |
|---|
| 5195 | ( void )strncpy( iwr.ifr_name, ifname, sizeof( iwr.ifr_name ) ); |
|---|
| 5196 | unsigned char *buf = ( unsigned char * )malloc( 24 * 1024 ); |
|---|
| 5197 | |
|---|
| 5198 | iwr.u.data.pointer = ( void * )buf; |
|---|
| 5199 | iwr.u.data.length = 24 * 1024; |
|---|
| 5200 | if( ioctl( s, IEEE80211_IOCTL_STA_INFO, &iwr ) < 0 ) |
|---|
| 5201 | { |
|---|
| 5202 | fprintf( stderr, "IOCTL_STA_INFO for %s failed!\n", ifname ); |
|---|
| 5203 | close( s ); |
|---|
| 5204 | free( buf ); |
|---|
| 5205 | return cnt; |
|---|
| 5206 | } |
|---|
| 5207 | len = iwr.u.data.length; |
|---|
| 5208 | if( len < sizeof( struct ieee80211req_sta_info ) ) |
|---|
| 5209 | { |
|---|
| 5210 | // fprintf(stderr,"IOCTL_STA_INFO len<struct %s failed!\n",ifname); |
|---|
| 5211 | close( s ); |
|---|
| 5212 | free( buf ); |
|---|
| 5213 | return cnt; |
|---|
| 5214 | } |
|---|
| 5215 | cp = buf; |
|---|
| 5216 | do |
|---|
| 5217 | { |
|---|
| 5218 | struct ieee80211req_sta_info *si; |
|---|
| 5219 | uint8_t *vp; |
|---|
| 5220 | |
|---|
| 5221 | si = ( struct ieee80211req_sta_info * )cp; |
|---|
| 5222 | vp = ( u_int8_t * ) ( si + 1 ); |
|---|
| 5223 | |
|---|
| 5224 | if( cnt ) |
|---|
| 5225 | websWrite( wp, "," ); |
|---|
| 5226 | cnt++; |
|---|
| 5227 | char mac[32]; |
|---|
| 5228 | |
|---|
| 5229 | strcpy( mac, ieee80211_ntoa( si->isi_macaddr ) ); |
|---|
| 5230 | if( nvram_match( "maskmac", "1" ) && macmask ) |
|---|
| 5231 | { |
|---|
| 5232 | mac[0] = 'x'; |
|---|
| 5233 | mac[1] = 'x'; |
|---|
| 5234 | mac[3] = 'x'; |
|---|
| 5235 | mac[4] = 'x'; |
|---|
| 5236 | mac[6] = 'x'; |
|---|
| 5237 | mac[7] = 'x'; |
|---|
| 5238 | mac[9] = 'x'; |
|---|
| 5239 | mac[10] = 'x'; |
|---|
| 5240 | } |
|---|
| 5241 | if( si->isi_noise == 0 ) |
|---|
| 5242 | { |
|---|
| 5243 | si->isi_noise = -95; |
|---|
| 5244 | } |
|---|
| 5245 | if( si->isi_rates ) |
|---|
| 5246 | { |
|---|
| 5247 | websWrite( wp, "'%s','%s','%3dM','%3dM','%d','%d','%d'", |
|---|
| 5248 | mac, ifname, |
|---|
| 5249 | ( ( si-> |
|---|
| 5250 | isi_rates[si->isi_txrate] & IEEE80211_RATE_VAL ) / |
|---|
| 5251 | 2 ) * turbo, |
|---|
| 5252 | ( ( si-> |
|---|
| 5253 | isi_rates[si->isi_rxrate] & IEEE80211_RATE_VAL ) / |
|---|
| 5254 | 2 ) * turbo, si->isi_noise + si->isi_rssi, |
|---|
| 5255 | si->isi_noise, si->isi_rssi ); |
|---|
| 5256 | } |
|---|
| 5257 | else |
|---|
| 5258 | { |
|---|
| 5259 | websWrite( wp, "'%s','%s','N/A','N/A','%d','%d','%d'", mac, |
|---|
| 5260 | ifname, si->isi_noise + si->isi_rssi, si->isi_noise, |
|---|
| 5261 | si->isi_rssi ); |
|---|
| 5262 | } |
|---|
| 5263 | cp += si->isi_len; |
|---|
| 5264 | len -= si->isi_len; |
|---|
| 5265 | } |
|---|
| 5266 | while( len >= sizeof( struct ieee80211req_sta_info ) ); |
|---|
| 5267 | free( buf ); |
|---|
| 5268 | close( s ); |
|---|
| 5269 | |
|---|
| 5270 | return cnt; |
|---|
| 5271 | } |
|---|
| 5272 | extern char *getiflist( void ); |
|---|
| 5273 | |
|---|
| 5274 | void ej_active_wireless( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5275 | { |
|---|
| 5276 | int c = getdevicecount( ); |
|---|
| 5277 | char devs[32]; |
|---|
| 5278 | int i; |
|---|
| 5279 | int cnt = 0; |
|---|
| 5280 | char turbo[32]; |
|---|
| 5281 | int t; |
|---|
| 5282 | int macmask; |
|---|
| 5283 | |
|---|
| 5284 | #ifdef FASTWEB |
|---|
| 5285 | ejArgs( argc, argv, "%d", &macmask ); |
|---|
| 5286 | #else |
|---|
| 5287 | if( ejArgs( argc, argv, "%d", &macmask ) < 1 ) |
|---|
| 5288 | { |
|---|
| 5289 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 5290 | return; |
|---|
| 5291 | } |
|---|
| 5292 | #endif |
|---|
| 5293 | for( i = 0; i < c; i++ ) |
|---|
| 5294 | { |
|---|
| 5295 | sprintf( devs, "ath%d", i ); |
|---|
| 5296 | sprintf( turbo, "%s_channelbw", devs ); |
|---|
| 5297 | if( nvram_match( turbo, "40" ) ) |
|---|
| 5298 | t = 2; |
|---|
| 5299 | else |
|---|
| 5300 | t = 1; |
|---|
| 5301 | cnt = ej_active_wireless_if( wp, argc, argv, devs, cnt, t, macmask ); |
|---|
| 5302 | char vif[32]; |
|---|
| 5303 | |
|---|
| 5304 | sprintf( vif, "%s_vifs", devs ); |
|---|
| 5305 | char var[80], *next; |
|---|
| 5306 | char *vifs = nvram_get( vif ); |
|---|
| 5307 | |
|---|
| 5308 | if( vifs != NULL ) |
|---|
| 5309 | foreach( var, vifs, next ) |
|---|
| 5310 | { |
|---|
| 5311 | cnt = |
|---|
| 5312 | ej_active_wireless_if( wp, argc, argv, var, cnt, t, macmask ); |
|---|
| 5313 | } |
|---|
| 5314 | } |
|---|
| 5315 | |
|---|
| 5316 | // show wds links |
|---|
| 5317 | for( i = 0; i < c; i++ ) |
|---|
| 5318 | { |
|---|
| 5319 | |
|---|
| 5320 | int s; |
|---|
| 5321 | |
|---|
| 5322 | for( s = 1; s <= 10; s++ ) |
|---|
| 5323 | { |
|---|
| 5324 | char wdsvarname[32] = { 0 }; |
|---|
| 5325 | char wdsdevname[32] = { 0 }; |
|---|
| 5326 | char wdsmacname[32] = { 0 }; |
|---|
| 5327 | char *dev; |
|---|
| 5328 | char *hwaddr; |
|---|
| 5329 | char var[80]; |
|---|
| 5330 | |
|---|
| 5331 | sprintf( wdsvarname, "ath%d_wds%d_enable", i, s ); |
|---|
| 5332 | sprintf( wdsdevname, "ath%d_wds%d_if", i, s ); |
|---|
| 5333 | sprintf( wdsmacname, "ath%d_wds%d_hwaddr", i, s ); |
|---|
| 5334 | sprintf( turbo, "ath%d_channelbw", i ); |
|---|
| 5335 | if( nvram_match( turbo, "40" ) ) |
|---|
| 5336 | t = 2; |
|---|
| 5337 | else |
|---|
| 5338 | t = 1; |
|---|
| 5339 | |
|---|
| 5340 | dev = nvram_safe_get( wdsdevname ); |
|---|
| 5341 | if( dev == NULL || strlen( dev ) == 0 ) |
|---|
| 5342 | continue; |
|---|
| 5343 | if( nvram_match( wdsvarname, "0" ) ) |
|---|
| 5344 | continue; |
|---|
| 5345 | cnt = |
|---|
| 5346 | ej_active_wireless_if( wp, argc, argv, dev, cnt, t, macmask ); |
|---|
| 5347 | } |
|---|
| 5348 | } |
|---|
| 5349 | } |
|---|
| 5350 | |
|---|
| 5351 | #else |
|---|
| 5352 | #define RSSI_TMP "/tmp/.rssi" |
|---|
| 5353 | #define ASSOCLIST_CMD "wl assoclist" |
|---|
| 5354 | #define RSSI_CMD "wl rssi" |
|---|
| 5355 | #define NOISE_CMD "wl noise" |
|---|
| 5356 | |
|---|
| 5357 | #ifndef HAVE_MSSID |
|---|
| 5358 | void ej_active_wireless( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5359 | { |
|---|
| 5360 | int rssi = 0, noise = 0; |
|---|
| 5361 | FILE *fp2; |
|---|
| 5362 | char *mode; |
|---|
| 5363 | char mac[30]; |
|---|
| 5364 | char list[2][30]; |
|---|
| 5365 | char line[80]; |
|---|
| 5366 | char cmd[80]; |
|---|
| 5367 | int macmask; |
|---|
| 5368 | |
|---|
| 5369 | #ifdef FASTWEB |
|---|
| 5370 | ejArgs( argc, argv, "%d", &macmask ); |
|---|
| 5371 | #else |
|---|
| 5372 | if( ejArgs( argc, argv, "%d", &macmask ) < 1 ) |
|---|
| 5373 | { |
|---|
| 5374 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 5375 | return; |
|---|
| 5376 | } |
|---|
| 5377 | #endif |
|---|
| 5378 | |
|---|
| 5379 | unlink( RSSI_TMP ); |
|---|
| 5380 | int cnt = 0; |
|---|
| 5381 | |
|---|
| 5382 | mode = nvram_safe_get( "wl_mode" ); |
|---|
| 5383 | unsigned char buf[WLC_IOCTL_MAXLEN]; |
|---|
| 5384 | |
|---|
| 5385 | memset( buf, 0, WLC_IOCTL_MAXLEN ); |
|---|
| 5386 | char *iface = get_wdev( ); |
|---|
| 5387 | |
|---|
| 5388 | if( !ifexists( iface ) ) |
|---|
| 5389 | return; |
|---|
| 5390 | int r = getassoclist( iface, buf ); |
|---|
| 5391 | |
|---|
| 5392 | if( r < 0 ) |
|---|
| 5393 | return; |
|---|
| 5394 | struct maclist *maclist = ( struct maclist * )buf; |
|---|
| 5395 | int i; |
|---|
| 5396 | |
|---|
| 5397 | for( i = 0; i < maclist->count; i++ ) |
|---|
| 5398 | { |
|---|
| 5399 | ether_etoa( ( uint8 * ) & maclist->ea[i], mac ); |
|---|
| 5400 | |
|---|
| 5401 | rssi = 0; |
|---|
| 5402 | noise = 0; |
|---|
| 5403 | // get rssi value |
|---|
| 5404 | if( strcmp( mode, "ap" ) && strcmp( mode, "apsta" ) |
|---|
| 5405 | && strcmp( mode, "apstawet" ) ) |
|---|
| 5406 | sysprintf( "%s > %s", RSSI_CMD, RSSI_TMP ); |
|---|
| 5407 | else |
|---|
| 5408 | sysprintf( "%s \"%s\" > %s", RSSI_CMD, mac, RSSI_TMP ); |
|---|
| 5409 | |
|---|
| 5410 | // get noise value if not ap mode |
|---|
| 5411 | if( strcmp( mode, "ap" ) ) |
|---|
| 5412 | sysprintf( "%s >> %s", NOISE_CMD, RSSI_TMP ); |
|---|
| 5413 | |
|---|
| 5414 | fp2 = fopen( RSSI_TMP, "r" ); |
|---|
| 5415 | if( fgets( line, sizeof( line ), fp2 ) != NULL ) |
|---|
| 5416 | { |
|---|
| 5417 | |
|---|
| 5418 | // get rssi |
|---|
| 5419 | // #ifdef HAVE_MSSID |
|---|
| 5420 | if( sscanf( line, "%d", &rssi ) != 1 ) |
|---|
| 5421 | continue; |
|---|
| 5422 | |
|---|
| 5423 | // noise=getNoise(iface); |
|---|
| 5424 | |
|---|
| 5425 | if( strcmp( mode, "ap" ) && |
|---|
| 5426 | fgets( line, sizeof( line ), fp2 ) != NULL && |
|---|
| 5427 | sscanf( line, "%d", &noise ) != 1 ) |
|---|
| 5428 | continue; |
|---|
| 5429 | /* |
|---|
| 5430 | * #else if (sscanf (line, "%s %s %d", list[0], list[1], &rssi) |
|---|
| 5431 | * != 3) continue; // noise=getNoise(iface); if (strcmp (mode, |
|---|
| 5432 | * "ap") && fgets (line, sizeof (line), fp2) != NULL && sscanf |
|---|
| 5433 | * (line, "%s %s %d", list[0], list[1], &noise) != 3) continue; |
|---|
| 5434 | * #endif |
|---|
| 5435 | */ |
|---|
| 5436 | // get noise for client/wet mode |
|---|
| 5437 | |
|---|
| 5438 | fclose( fp2 ); |
|---|
| 5439 | } |
|---|
| 5440 | if( nvram_match( "maskmac", "1" ) && macmask ) |
|---|
| 5441 | { |
|---|
| 5442 | mac[0] = 'x'; |
|---|
| 5443 | mac[1] = 'x'; |
|---|
| 5444 | mac[3] = 'x'; |
|---|
| 5445 | mac[4] = 'x'; |
|---|
| 5446 | mac[6] = 'x'; |
|---|
| 5447 | mac[7] = 'x'; |
|---|
| 5448 | mac[9] = 'x'; |
|---|
| 5449 | mac[10] = 'x'; |
|---|
| 5450 | } |
|---|
| 5451 | if( cnt ) |
|---|
| 5452 | websWrite( wp, "," ); |
|---|
| 5453 | cnt++; |
|---|
| 5454 | if( !strcmp( mode, "ap" ) ) |
|---|
| 5455 | { |
|---|
| 5456 | // char *ref = nvram_get ("noise_reference"); |
|---|
| 5457 | noise = -98; |
|---|
| 5458 | // if (ref) |
|---|
| 5459 | // noise = atoi (ref); |
|---|
| 5460 | } |
|---|
| 5461 | websWrite( wp, "'%s','%d','%d','%d'", mac, rssi, noise, |
|---|
| 5462 | rssi - noise ); |
|---|
| 5463 | } |
|---|
| 5464 | unlink( RSSI_TMP ); |
|---|
| 5465 | |
|---|
| 5466 | return; |
|---|
| 5467 | } |
|---|
| 5468 | #else |
|---|
| 5469 | int |
|---|
| 5470 | ej_active_wireless_if( webs_t wp, int argc, char_t ** argv, |
|---|
| 5471 | char *iface, char *visible, int cnt ) |
|---|
| 5472 | { |
|---|
| 5473 | int rssi = 0, noise = 0; |
|---|
| 5474 | FILE *fp2; |
|---|
| 5475 | char *mode; |
|---|
| 5476 | char mac[30]; |
|---|
| 5477 | char line[80]; |
|---|
| 5478 | int macmask; |
|---|
| 5479 | |
|---|
| 5480 | #ifdef FASTWEB |
|---|
| 5481 | ejArgs( argc, argv, "%d", &macmask ); |
|---|
| 5482 | #else |
|---|
| 5483 | if( ejArgs( argc, argv, "%d", &macmask ) < 1 ) |
|---|
| 5484 | { |
|---|
| 5485 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 5486 | return 0; |
|---|
| 5487 | } |
|---|
| 5488 | #endif |
|---|
| 5489 | if( !ifexists( iface ) ) |
|---|
| 5490 | return cnt; |
|---|
| 5491 | unlink( RSSI_TMP ); |
|---|
| 5492 | char wlmode[32]; |
|---|
| 5493 | |
|---|
| 5494 | sprintf( wlmode, "%s_mode", visible ); |
|---|
| 5495 | mode = nvram_safe_get( wlmode ); |
|---|
| 5496 | unsigned char buf[WLC_IOCTL_MAXLEN]; |
|---|
| 5497 | |
|---|
| 5498 | memset( buf, 0, WLC_IOCTL_MAXLEN ); // get_wdev |
|---|
| 5499 | int r = getassoclist( iface, buf ); |
|---|
| 5500 | |
|---|
| 5501 | if( r < 0 ) |
|---|
| 5502 | return cnt; |
|---|
| 5503 | struct maclist *maclist = ( struct maclist * )buf; |
|---|
| 5504 | int i; |
|---|
| 5505 | |
|---|
| 5506 | for( i = 0; i < maclist->count; i++ ) |
|---|
| 5507 | { |
|---|
| 5508 | ether_etoa( ( uint8 * ) & maclist->ea[i], mac ); |
|---|
| 5509 | |
|---|
| 5510 | rssi = 0; |
|---|
| 5511 | noise = 0; |
|---|
| 5512 | // get rssi value |
|---|
| 5513 | if( strcmp( mode, "ap" ) && strcmp( mode, "apsta" ) |
|---|
| 5514 | && strcmp( mode, "apstawet" ) ) |
|---|
| 5515 | sysprintf( "wl -i %s rssi > %s", iface, RSSI_TMP ); |
|---|
| 5516 | else |
|---|
| 5517 | sysprintf( "wl -i %s rssi \"%s\" > %s", iface, mac, RSSI_TMP ); |
|---|
| 5518 | |
|---|
| 5519 | // get noise value if not ap mode |
|---|
| 5520 | // if (strcmp (mode, "ap")) |
|---|
| 5521 | // snprintf (cmd, sizeof (cmd), "wl -i %s noise >> %s", iface, |
|---|
| 5522 | // RSSI_TMP); |
|---|
| 5523 | // system2 (cmd); // get RSSI value for mac |
|---|
| 5524 | |
|---|
| 5525 | fp2 = fopen( RSSI_TMP, "r" ); |
|---|
| 5526 | if( fgets( line, sizeof( line ), fp2 ) != NULL ) |
|---|
| 5527 | { |
|---|
| 5528 | |
|---|
| 5529 | // get rssi |
|---|
| 5530 | if( sscanf( line, "%d", &rssi ) != 1 ) |
|---|
| 5531 | continue; |
|---|
| 5532 | noise = getNoise( iface, NULL ); |
|---|
| 5533 | /* |
|---|
| 5534 | * if (strcmp (mode, "ap") && fgets (line, sizeof (line), fp2) != |
|---|
| 5535 | * NULL && sscanf (line, "%d", &noise) != 1) continue; |
|---|
| 5536 | */ |
|---|
| 5537 | // get noise for client/wet mode |
|---|
| 5538 | |
|---|
| 5539 | fclose( fp2 ); |
|---|
| 5540 | } |
|---|
| 5541 | if( nvram_match( "maskmac", "1" ) && macmask ) |
|---|
| 5542 | { |
|---|
| 5543 | mac[0] = 'x'; |
|---|
| 5544 | mac[1] = 'x'; |
|---|
| 5545 | mac[3] = 'x'; |
|---|
| 5546 | mac[4] = 'x'; |
|---|
| 5547 | mac[6] = 'x'; |
|---|
| 5548 | mac[7] = 'x'; |
|---|
| 5549 | mac[9] = 'x'; |
|---|
| 5550 | mac[10] = 'x'; |
|---|
| 5551 | } |
|---|
| 5552 | if( cnt ) |
|---|
| 5553 | websWrite( wp, "," ); |
|---|
| 5554 | cnt++; |
|---|
| 5555 | /* |
|---|
| 5556 | * if (!strcmp (mode, "ap")) { noise = getNoise(iface,NULL); // null |
|---|
| 5557 | * only for broadcom } |
|---|
| 5558 | */ |
|---|
| 5559 | websWrite( wp, "'%s','%s','N/A','N/A','%d','%d','%d'", mac, iface, |
|---|
| 5560 | rssi, noise, rssi - noise ); |
|---|
| 5561 | } |
|---|
| 5562 | unlink( RSSI_TMP ); |
|---|
| 5563 | |
|---|
| 5564 | return cnt; |
|---|
| 5565 | } |
|---|
| 5566 | |
|---|
| 5567 | void ej_active_wireless( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5568 | { |
|---|
| 5569 | int cnt = 0; |
|---|
| 5570 | int c = get_wl_instances( ); |
|---|
| 5571 | int i; |
|---|
| 5572 | |
|---|
| 5573 | for( i = 0; i < c; i++ ) |
|---|
| 5574 | { |
|---|
| 5575 | char wlif[32]; |
|---|
| 5576 | |
|---|
| 5577 | sprintf( wlif, "wl%d", i ); |
|---|
| 5578 | cnt = |
|---|
| 5579 | ej_active_wireless_if( wp, argc, argv, get_wl_instance_name( i ), |
|---|
| 5580 | wlif, cnt ); |
|---|
| 5581 | char *next; |
|---|
| 5582 | char var[80]; |
|---|
| 5583 | char *vifs = nvram_nget( "wl%d_vifs", i ); |
|---|
| 5584 | |
|---|
| 5585 | if( vifs == NULL ) |
|---|
| 5586 | return; |
|---|
| 5587 | |
|---|
| 5588 | foreach( var, vifs, next ) |
|---|
| 5589 | { |
|---|
| 5590 | cnt = ej_active_wireless_if( wp, argc, argv, var, var, cnt ); |
|---|
| 5591 | } |
|---|
| 5592 | } |
|---|
| 5593 | } |
|---|
| 5594 | |
|---|
| 5595 | #endif |
|---|
| 5596 | |
|---|
| 5597 | #endif |
|---|
| 5598 | |
|---|
| 5599 | #define WDS_RSSI_TMP "/tmp/.rssi" |
|---|
| 5600 | void ej_active_wds_instance( webs_t wp, int argc, char_t ** argv, |
|---|
| 5601 | int instance ); |
|---|
| 5602 | void ej_active_wds( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5603 | { |
|---|
| 5604 | int cnt = get_wl_instances( ); |
|---|
| 5605 | int c; |
|---|
| 5606 | |
|---|
| 5607 | for( c = 0; c < cnt; c++ ) |
|---|
| 5608 | ej_active_wds_instance( wp, argc, argv, c ); |
|---|
| 5609 | } |
|---|
| 5610 | |
|---|
| 5611 | void |
|---|
| 5612 | ej_active_wds_instance( webs_t wp, int argc, char_t ** argv, int instance ) |
|---|
| 5613 | { |
|---|
| 5614 | #ifndef HAVE_MADWIFI |
|---|
| 5615 | int rssi = 0, i; |
|---|
| 5616 | FILE *fp2; |
|---|
| 5617 | char *mode; |
|---|
| 5618 | char mac[30]; |
|---|
| 5619 | char line[80]; |
|---|
| 5620 | |
|---|
| 5621 | // char title[30]; |
|---|
| 5622 | char wdsvar[30]; |
|---|
| 5623 | char desc[30]; |
|---|
| 5624 | int cnt = 0; |
|---|
| 5625 | int macmask; |
|---|
| 5626 | |
|---|
| 5627 | if( ejArgs( argc, argv, "%d", &macmask ) < 1 ) |
|---|
| 5628 | { |
|---|
| 5629 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 5630 | return; |
|---|
| 5631 | } |
|---|
| 5632 | |
|---|
| 5633 | unlink( WDS_RSSI_TMP ); |
|---|
| 5634 | |
|---|
| 5635 | mode = nvram_nget( "wl%d_mode", instance ); |
|---|
| 5636 | |
|---|
| 5637 | if( strcmp( mode, "ap" ) && strcmp( mode, "apsta" ) |
|---|
| 5638 | && strcmp( mode, "apstawet" ) ) |
|---|
| 5639 | return; |
|---|
| 5640 | unsigned char buf[WLC_IOCTL_MAXLEN]; |
|---|
| 5641 | char *iface = get_wl_instance_name( instance ); |
|---|
| 5642 | |
|---|
| 5643 | if( !ifexists( iface ) ) |
|---|
| 5644 | return; |
|---|
| 5645 | int r = getwdslist( iface, buf ); |
|---|
| 5646 | |
|---|
| 5647 | if( r < 0 ) |
|---|
| 5648 | return; |
|---|
| 5649 | struct maclist *maclist = ( struct maclist * )buf; |
|---|
| 5650 | int e; |
|---|
| 5651 | |
|---|
| 5652 | for( e = 0; e < maclist->count; e++ ) |
|---|
| 5653 | { |
|---|
| 5654 | |
|---|
| 5655 | ether_etoa( ( uint8 * ) & maclist->ea[e], mac ); |
|---|
| 5656 | |
|---|
| 5657 | rssi = 0; |
|---|
| 5658 | memset( desc, 0, 30 ); |
|---|
| 5659 | for( i = 1; i <= 10; i++ ) |
|---|
| 5660 | { |
|---|
| 5661 | snprintf( wdsvar, 30, "wl%d_wds%d_hwaddr", instance, i ); |
|---|
| 5662 | if( nvram_match( wdsvar, mac ) ) |
|---|
| 5663 | { |
|---|
| 5664 | snprintf( wdsvar, 30, "wl%d_wds%d_desc", instance, i ); |
|---|
| 5665 | snprintf( desc, sizeof( desc ), "%s", nvram_get( wdsvar ) ); |
|---|
| 5666 | if( !strcmp( nvram_get( wdsvar ), "" ) ) |
|---|
| 5667 | strcpy( desc, " " ); |
|---|
| 5668 | } |
|---|
| 5669 | } |
|---|
| 5670 | |
|---|
| 5671 | sysprintf( "%s \"%s\" > %s", RSSI_CMD, mac, RSSI_TMP ); |
|---|
| 5672 | |
|---|
| 5673 | fp2 = fopen( RSSI_TMP, "r" ); |
|---|
| 5674 | if( fgets( line, sizeof( line ), fp2 ) != NULL ) |
|---|
| 5675 | { |
|---|
| 5676 | |
|---|
| 5677 | // get rssi |
|---|
| 5678 | if( sscanf( line, "%d", &rssi ) != 1 ) |
|---|
| 5679 | continue; |
|---|
| 5680 | fclose( fp2 ); |
|---|
| 5681 | } |
|---|
| 5682 | if( nvram_match( "maskmac", "1" ) && macmask ) |
|---|
| 5683 | { |
|---|
| 5684 | mac[0] = 'x'; |
|---|
| 5685 | mac[1] = 'x'; |
|---|
| 5686 | mac[3] = 'x'; |
|---|
| 5687 | mac[4] = 'x'; |
|---|
| 5688 | mac[6] = 'x'; |
|---|
| 5689 | mac[7] = 'x'; |
|---|
| 5690 | mac[9] = 'x'; |
|---|
| 5691 | mac[10] = 'x'; |
|---|
| 5692 | } |
|---|
| 5693 | if( cnt ) |
|---|
| 5694 | websWrite( wp, "," ); |
|---|
| 5695 | cnt++; |
|---|
| 5696 | int noise = getNoise( iface, NULL ); |
|---|
| 5697 | |
|---|
| 5698 | websWrite( wp, |
|---|
| 5699 | "\"%s\",\"%s\",\"%d\",\"%d\",\"%d\"", |
|---|
| 5700 | mac, desc, rssi, noise, rssi - noise ); |
|---|
| 5701 | } |
|---|
| 5702 | |
|---|
| 5703 | unlink( WDS_RSSI_TMP ); |
|---|
| 5704 | #endif |
|---|
| 5705 | return; |
|---|
| 5706 | } |
|---|
| 5707 | |
|---|
| 5708 | void ej_get_wdsp2p( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5709 | { |
|---|
| 5710 | int index = -1, ip[4] = { 0, 0, 0, 0 }, netmask[4] = |
|---|
| 5711 | { |
|---|
| 5712 | 0, 0, 0, 0}; |
|---|
| 5713 | char nvramvar[32] = { 0 }; |
|---|
| 5714 | char *interface; |
|---|
| 5715 | |
|---|
| 5716 | #ifdef FASTWEB |
|---|
| 5717 | ejArgs( argc, argv, "%d %s", &index, &interface ); |
|---|
| 5718 | #else |
|---|
| 5719 | if( ejArgs( argc, argv, "%d %s", &index, &interface ) < 2 ) |
|---|
| 5720 | { |
|---|
| 5721 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 5722 | return; |
|---|
| 5723 | } |
|---|
| 5724 | #endif |
|---|
| 5725 | char wlwds[32]; |
|---|
| 5726 | |
|---|
| 5727 | sprintf( wlwds, "%s_wds1_enable", interface ); |
|---|
| 5728 | if( nvram_selmatch( wp, "wk_mode", "ospf" ) && |
|---|
| 5729 | nvram_selmatch( wp, "expert_mode", "1" ) && |
|---|
| 5730 | nvram_selmatch( wp, wlwds, "1" ) ) |
|---|
| 5731 | { |
|---|
| 5732 | char buf[16]; |
|---|
| 5733 | |
|---|
| 5734 | sprintf( buf, "%s_wds%d_ospf", interface, index ); |
|---|
| 5735 | websWrite( wp, |
|---|
| 5736 | "<input name=\"%s\" size=\"2\" maxlength=\"5\" value=\"%s\" />\n", |
|---|
| 5737 | buf, nvram_safe_get( buf ) ); |
|---|
| 5738 | } |
|---|
| 5739 | |
|---|
| 5740 | snprintf( nvramvar, 31, "%s_wds%d_ipaddr", interface, index ); |
|---|
| 5741 | sscanf( nvram_safe_get( nvramvar ), "%d.%d.%d.%d", &ip[0], &ip[1], &ip[2], |
|---|
| 5742 | &ip[3] ); |
|---|
| 5743 | snprintf( nvramvar, 31, "%s_wds%d_netmask", interface, index ); |
|---|
| 5744 | sscanf( nvram_safe_get( nvramvar ), "%d.%d.%d.%d", &netmask[0], |
|---|
| 5745 | &netmask[1], &netmask[2], &netmask[3] ); |
|---|
| 5746 | snprintf( nvramvar, 31, "%s_wds%d_enable", interface, index ); |
|---|
| 5747 | |
|---|
| 5748 | // set netmask to a suggested default if blank |
|---|
| 5749 | if( netmask[0] == 0 && |
|---|
| 5750 | netmask[1] == 0 && netmask[2] == 0 && netmask[3] == 0 ) |
|---|
| 5751 | { |
|---|
| 5752 | netmask[0] = 255; |
|---|
| 5753 | netmask[1] = 255; |
|---|
| 5754 | netmask[2] = 255; |
|---|
| 5755 | netmask[3] = 252; |
|---|
| 5756 | } |
|---|
| 5757 | |
|---|
| 5758 | if( nvram_match( nvramvar, "1" ) ) |
|---|
| 5759 | { |
|---|
| 5760 | websWrite( wp, "\ |
|---|
| 5761 | <div class=\"setting\">\n\ |
|---|
| 5762 | <input type=\"hidden\" name=\"%s_wds%d_ipaddr\" value=\"4\">\n\ |
|---|
| 5763 | <div class=\"label\"><script type=\"text/javascript\">Capture(share.ip)</script></div>\n\ |
|---|
| 5764 | <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\ |
|---|
| 5765 | </div>\n", interface, index, interface, index, ip[0], interface, index, ip[1], interface, index, ip[2], interface, index, ip[3] ); |
|---|
| 5766 | |
|---|
| 5767 | websWrite( wp, "\ |
|---|
| 5768 | <div class=\"setting\">\n\ |
|---|
| 5769 | <div class=\"label\"><script type=\"text/javascript\">Capture(share.subnet)</script></div>\n\ |
|---|
| 5770 | <input type=\"hidden\" name=\"%s_wds%d_netmask\" value=\"4\">\n\ |
|---|
| 5771 | <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\ |
|---|
| 5772 | </div>\n", interface, index, interface, index, netmask[0], interface, index, netmask[1], interface, index, netmask[2], interface, index, netmask[3] ); |
|---|
| 5773 | |
|---|
| 5774 | } |
|---|
| 5775 | |
|---|
| 5776 | return; |
|---|
| 5777 | |
|---|
| 5778 | } |
|---|
| 5779 | |
|---|
| 5780 | /* |
|---|
| 5781 | * void ej_get_services_options (webs_t wp, int argc, char_t ** argv) { char |
|---|
| 5782 | * word[1024], *next, *services; char delim[] = "< >"; |
|---|
| 5783 | * |
|---|
| 5784 | * //services = nvram_safe_get("filter_services"); services = |
|---|
| 5785 | * get_filter_services (); |
|---|
| 5786 | * |
|---|
| 5787 | * split (word, services, next, delim) { int len = 0; char *name, *prot, |
|---|
| 5788 | * *port; char protocol[100], ports[100]; int from = 0, to = 0; //int proto; |
|---|
| 5789 | * |
|---|
| 5790 | * if ((name = strstr (word, "$NAME:")) == NULL || (prot = strstr (word, |
|---|
| 5791 | * "$PROT:")) == NULL || (port = strstr (word, "$PORT:")) == NULL) continue; |
|---|
| 5792 | * |
|---|
| 5793 | * // $NAME if (sscanf (name, "$NAME:%3d:", &len) != 1) continue; |
|---|
| 5794 | * |
|---|
| 5795 | * strncpy (name, name + sizeof ("$NAME:nnn:") - 1, len); name[len] = '\0'; |
|---|
| 5796 | * |
|---|
| 5797 | * // $PROT if (sscanf (prot, "$PROT:%3d:", &len) != 1) continue; |
|---|
| 5798 | * |
|---|
| 5799 | * strncpy (protocol, prot + sizeof ("$PROT:nnn:") - 1, len); protocol[len] = |
|---|
| 5800 | * '\0'; |
|---|
| 5801 | * |
|---|
| 5802 | * // $PORT if (sscanf (port, "$PORT:%3d:", &len) != 1) continue; |
|---|
| 5803 | * |
|---|
| 5804 | * strncpy (ports, port + sizeof ("$PORT:nnn:") - 1, len); ports[len] = '\0'; |
|---|
| 5805 | * |
|---|
| 5806 | * if (sscanf (ports, "%d:%d", &from, &to) != 2) continue; |
|---|
| 5807 | * |
|---|
| 5808 | * //cprintf("match:: name=%s, protocol=%s, ports=%s\n", // word, protocol, |
|---|
| 5809 | * ports); |
|---|
| 5810 | * |
|---|
| 5811 | * websWrite (wp, "<option value=\"%s\">%s</option>", name, name); |
|---|
| 5812 | * |
|---|
| 5813 | * } |
|---|
| 5814 | * |
|---|
| 5815 | * return; } |
|---|
| 5816 | */ |
|---|
| 5817 | |
|---|
| 5818 | void ej_get_clone_wmac( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5819 | { |
|---|
| 5820 | #ifdef HAVE_RB500 |
|---|
| 5821 | return 0; |
|---|
| 5822 | #else |
|---|
| 5823 | |
|---|
| 5824 | char *c; |
|---|
| 5825 | int mac, which; |
|---|
| 5826 | int dofree = 0; |
|---|
| 5827 | |
|---|
| 5828 | #ifdef FASTWEB |
|---|
| 5829 | ejArgs( argc, argv, "%d", &which ); |
|---|
| 5830 | #else |
|---|
| 5831 | if( ejArgs( argc, argv, "%d", &which ) < 1 ) |
|---|
| 5832 | { |
|---|
| 5833 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 5834 | return; |
|---|
| 5835 | } |
|---|
| 5836 | #endif |
|---|
| 5837 | |
|---|
| 5838 | if( nvram_match( "def_whwaddr", "00:00:00:00:00:00" ) ) |
|---|
| 5839 | { |
|---|
| 5840 | // if (strlen (nvram_safe_get ("il0macaddr")) == 0) |
|---|
| 5841 | // { |
|---|
| 5842 | // if (nvram_match ("port_swap", "1")) |
|---|
| 5843 | // c = strdup (nvram_safe_get ("et1macaddr")); |
|---|
| 5844 | // else |
|---|
| 5845 | // c = strdup (nvram_safe_get ("et0macaddr")); |
|---|
| 5846 | // MAC_ADD (c); |
|---|
| 5847 | // } |
|---|
| 5848 | // else |
|---|
| 5849 | // { |
|---|
| 5850 | // c = strdup (nvram_safe_get ("il0macaddr")); |
|---|
| 5851 | // } |
|---|
| 5852 | // dofree = 1; |
|---|
| 5853 | |
|---|
| 5854 | if( nvram_match( "port_swap", "1" ) ) |
|---|
| 5855 | { |
|---|
| 5856 | if( strlen( nvram_safe_get( "et1macaddr" ) ) != 0 ) // safe: |
|---|
| 5857 | // maybe |
|---|
| 5858 | // et1macaddr |
|---|
| 5859 | // not there? |
|---|
| 5860 | { |
|---|
| 5861 | c = strdup( nvram_safe_get( "et1macaddr" ) ); |
|---|
| 5862 | } |
|---|
| 5863 | else |
|---|
| 5864 | { |
|---|
| 5865 | c = strdup( nvram_safe_get( "et0macaddr" ) ); |
|---|
| 5866 | MAC_ADD( c ); // et0macaddr +3 |
|---|
| 5867 | } |
|---|
| 5868 | } |
|---|
| 5869 | else |
|---|
| 5870 | { |
|---|
| 5871 | c = strdup( nvram_safe_get( "et0macaddr" ) ); |
|---|
| 5872 | } |
|---|
| 5873 | |
|---|
| 5874 | dofree = 1; |
|---|
| 5875 | if( c ) |
|---|
| 5876 | { |
|---|
| 5877 | MAC_ADD( c ); |
|---|
| 5878 | MAC_ADD( c ); |
|---|
| 5879 | } |
|---|
| 5880 | |
|---|
| 5881 | } |
|---|
| 5882 | else |
|---|
| 5883 | c = nvram_safe_get( "def_whwaddr" ); |
|---|
| 5884 | |
|---|
| 5885 | if( c ) |
|---|
| 5886 | { |
|---|
| 5887 | mac = get_single_mac( c, which ); |
|---|
| 5888 | websWrite( wp, "%02X", mac ); |
|---|
| 5889 | if( dofree ) |
|---|
| 5890 | free( c ); |
|---|
| 5891 | } |
|---|
| 5892 | else |
|---|
| 5893 | websWrite( wp, "00" ); |
|---|
| 5894 | |
|---|
| 5895 | return; |
|---|
| 5896 | #endif |
|---|
| 5897 | } |
|---|
| 5898 | |
|---|
| 5899 | /* |
|---|
| 5900 | * todo stylesheet compatible code |
|---|
| 5901 | */ |
|---|
| 5902 | /* |
|---|
| 5903 | * lonewolf additions |
|---|
| 5904 | */ |
|---|
| 5905 | |
|---|
| 5906 | // Note that there is no VLAN #16. It's just a convieniant way of denoting a |
|---|
| 5907 | // "Tagged" port |
|---|
| 5908 | void ej_port_vlan_table( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5909 | { |
|---|
| 5910 | /* |
|---|
| 5911 | * vlans[x][y] where x 0-15 are VLANS x 16 is tagging, 17 is |
|---|
| 5912 | * auto-negotiation, 18 is 100/10 Mbit, and 19 is Full/Half duplex y 0-4 |
|---|
| 5913 | * are switch ports (port 5 is set automaticly) y 5 it the bridge device |
|---|
| 5914 | * (x 16 dosn't apply) |
|---|
| 5915 | */ |
|---|
| 5916 | |
|---|
| 5917 | int i, j, vlans[21][6], tmp, wl_br; |
|---|
| 5918 | char *c, *next, buff[32], portvlan[32]; |
|---|
| 5919 | |
|---|
| 5920 | for( i = 0; i < 21; i++ ) |
|---|
| 5921 | for( j = 0; j < 6; j++ ) |
|---|
| 5922 | vlans[i][j] = -1; |
|---|
| 5923 | |
|---|
| 5924 | wl_br = -1; |
|---|
| 5925 | |
|---|
| 5926 | for( i = 0; i < 8; i++ ) |
|---|
| 5927 | { |
|---|
| 5928 | if( i < 5 ) |
|---|
| 5929 | snprintf( buff, 31, "port%dvlans", i ); |
|---|
| 5930 | else if( i == 5 ) |
|---|
| 5931 | snprintf( buff, 31, "%s", "lan_ifnames" ); |
|---|
| 5932 | else |
|---|
| 5933 | snprintf( buff, 31, "ub%d_ifnames", i - 5 ); |
|---|
| 5934 | |
|---|
| 5935 | c = nvram_safe_get( buff ); |
|---|
| 5936 | |
|---|
| 5937 | if( c ) |
|---|
| 5938 | { |
|---|
| 5939 | foreach( portvlan, c, next ) |
|---|
| 5940 | { |
|---|
| 5941 | if( portvlan[0] == 'e' && portvlan[1] == 't' |
|---|
| 5942 | && portvlan[2] == 'h' && portvlan[3] == '1' ) |
|---|
| 5943 | wl_br = i - 5; |
|---|
| 5944 | if( ISDIGIT( portvlan, 1 ) |
|---|
| 5945 | || ( portvlan[0] == 'v' && portvlan[1] == 'l' |
|---|
| 5946 | && portvlan[2] == 'a' && portvlan[3] == 'n' ) ) |
|---|
| 5947 | { |
|---|
| 5948 | if( ISDIGIT( portvlan, 1 ) ) |
|---|
| 5949 | tmp = atoi( portvlan ); |
|---|
| 5950 | else |
|---|
| 5951 | { |
|---|
| 5952 | portvlan[0] = portvlan[4]; |
|---|
| 5953 | portvlan[1] = portvlan[5]; |
|---|
| 5954 | portvlan[2] = '\0'; |
|---|
| 5955 | if( ISDIGIT( portvlan, 1 ) ) |
|---|
| 5956 | tmp = atoi( portvlan ); |
|---|
| 5957 | else |
|---|
| 5958 | continue; |
|---|
| 5959 | } |
|---|
| 5960 | |
|---|
| 5961 | if( i < 5 ) |
|---|
| 5962 | { |
|---|
| 5963 | vlans[tmp][i] = 1; |
|---|
| 5964 | } |
|---|
| 5965 | else |
|---|
| 5966 | { |
|---|
| 5967 | vlans[tmp][5] = i - 5; |
|---|
| 5968 | } |
|---|
| 5969 | } |
|---|
| 5970 | } |
|---|
| 5971 | } |
|---|
| 5972 | } |
|---|
| 5973 | |
|---|
| 5974 | for( i = 0; i < 21; i++ ) |
|---|
| 5975 | { |
|---|
| 5976 | websWrite( wp, " <tr>\n" ); |
|---|
| 5977 | websWrite( wp, "<td>" ); |
|---|
| 5978 | |
|---|
| 5979 | switch ( i ) |
|---|
| 5980 | { |
|---|
| 5981 | case 16: |
|---|
| 5982 | websWrite( wp, |
|---|
| 5983 | "<script type=\"text/javascript\">Capture(vlan.tagged)</script>" ); |
|---|
| 5984 | break; |
|---|
| 5985 | case 17: |
|---|
| 5986 | websWrite( wp, |
|---|
| 5987 | "<script type=\"text/javascript\">Capture(vlan.negociate)</script>" ); |
|---|
| 5988 | break; |
|---|
| 5989 | case 18: |
|---|
| 5990 | websWrite( wp, "100 Mbit" ); |
|---|
| 5991 | break; |
|---|
| 5992 | case 19: |
|---|
| 5993 | websWrite( wp, "Full-Duplex" ); |
|---|
| 5994 | break; |
|---|
| 5995 | case 20: |
|---|
| 5996 | websWrite( wp, "Enabled" ); |
|---|
| 5997 | break; |
|---|
| 5998 | default: |
|---|
| 5999 | snprintf( buff, 31, "%d", i ); |
|---|
| 6000 | websWrite( wp, buff ); |
|---|
| 6001 | break; |
|---|
| 6002 | } |
|---|
| 6003 | |
|---|
| 6004 | websWrite( wp, "</td>\n" ); |
|---|
| 6005 | |
|---|
| 6006 | for( j = 0; j < 5; j++ ) |
|---|
| 6007 | { |
|---|
| 6008 | snprintf( buff, 31, "\"port%dvlan%d\"", j, i ); |
|---|
| 6009 | websWrite( wp, "<td" ); |
|---|
| 6010 | |
|---|
| 6011 | if( j % 2 == 0 ) |
|---|
| 6012 | websWrite( wp, " bgcolor=\"#CCCCCC\"" ); |
|---|
| 6013 | |
|---|
| 6014 | websWrite( wp, |
|---|
| 6015 | " height=\"20\"><div align=\"center\"><input type=\"checkbox\" value=\"on\" name=" ); |
|---|
| 6016 | websWrite( wp, buff ); |
|---|
| 6017 | |
|---|
| 6018 | if( i < 17 || i > 20 ) |
|---|
| 6019 | { |
|---|
| 6020 | if( vlans[i][j] == 1 ) |
|---|
| 6021 | websWrite( wp, " checked=\"checked\"" ); |
|---|
| 6022 | } |
|---|
| 6023 | else |
|---|
| 6024 | { |
|---|
| 6025 | if( vlans[i][j] == -1 ) |
|---|
| 6026 | websWrite( wp, " checked=\"checked\"" ); |
|---|
| 6027 | } |
|---|
| 6028 | |
|---|
| 6029 | if( i < 17 ) |
|---|
| 6030 | { |
|---|
| 6031 | websWrite( wp, " onclick=" ); |
|---|
| 6032 | snprintf( buff, sizeof( buff ), |
|---|
| 6033 | "\"SelVLAN(this.form,'port%d')\"", j ); |
|---|
| 6034 | websWrite( wp, buff ); |
|---|
| 6035 | } |
|---|
| 6036 | else if( i == 17 || i == 20 ) |
|---|
| 6037 | { |
|---|
| 6038 | websWrite( wp, " onclick=" ); |
|---|
| 6039 | snprintf( buff, sizeof( buff ), |
|---|
| 6040 | "\"SelSpeed(this.form,'port%d')\"", j ); |
|---|
| 6041 | websWrite( wp, buff ); |
|---|
| 6042 | } |
|---|
| 6043 | websWrite( wp, " /></div></td>\n" ); |
|---|
| 6044 | } |
|---|
| 6045 | |
|---|
| 6046 | if( i < 16 ) |
|---|
| 6047 | { |
|---|
| 6048 | websWrite( wp, " <td><select name=" ); |
|---|
| 6049 | snprintf( buff, 31, "\"vlan%d\"", i ); |
|---|
| 6050 | websWrite( wp, buff ); |
|---|
| 6051 | websWrite( wp, |
|---|
| 6052 | "><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"-1\\\"" ); |
|---|
| 6053 | if( vlans[i][5] < 0 ) |
|---|
| 6054 | websWrite( wp, " selected=\\\"selected\\\"" ); |
|---|
| 6055 | websWrite( wp, |
|---|
| 6056 | ">\" + share.none + \"</option>\");\n//]]>\n</script><option value=\"0\"" ); |
|---|
| 6057 | if( vlans[i][5] == 0 ) |
|---|
| 6058 | websWrite( wp, " selected=\"selected\"" ); |
|---|
| 6059 | websWrite( wp, ">LAN</option></select></td>\n" ); |
|---|
| 6060 | } |
|---|
| 6061 | else |
|---|
| 6062 | { |
|---|
| 6063 | websWrite( wp, "<td> </td>\n" ); |
|---|
| 6064 | } |
|---|
| 6065 | |
|---|
| 6066 | websWrite( wp, "</tr>\n" ); |
|---|
| 6067 | |
|---|
| 6068 | if( i == 16 || i == 20 ) |
|---|
| 6069 | { |
|---|
| 6070 | websWrite( wp, "<tr><td> </td></tr>\n" ); |
|---|
| 6071 | } |
|---|
| 6072 | } |
|---|
| 6073 | |
|---|
| 6074 | websWrite( wp, "<tr>\n" ); |
|---|
| 6075 | websWrite( wp, |
|---|
| 6076 | "<td><script type=\"text/javascript\">Capture(share.wireless)</script></td>\n" ); |
|---|
| 6077 | |
|---|
| 6078 | websWrite( wp, |
|---|
| 6079 | "<td colspan=\"6\"><select name=\"wireless\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"-1\\\"" ); |
|---|
| 6080 | if( wl_br < 0 ) |
|---|
| 6081 | websWrite( wp, " selected=\\\"selected\\\"" ); |
|---|
| 6082 | websWrite( wp, |
|---|
| 6083 | ">\" + share.none + \"</option>\");\n//]]>\n</script><option value=\"0\"" ); |
|---|
| 6084 | if( wl_br == 0 ) |
|---|
| 6085 | websWrite( wp, " selected=\"selected\"" ); |
|---|
| 6086 | websWrite( wp, ">LAN</option></select></td>\n" ); |
|---|
| 6087 | websWrite( wp, "</tr>\n" ); |
|---|
| 6088 | |
|---|
| 6089 | websWrite( wp, "<tr><td> </td></tr>\n" ); |
|---|
| 6090 | |
|---|
| 6091 | websWrite( wp, "<tr>\n" ); |
|---|
| 6092 | websWrite( wp, |
|---|
| 6093 | "<td><script type=\"text/javascript\">Capture(vlan.aggregation)</script></td>\n" ); |
|---|
| 6094 | |
|---|
| 6095 | websWrite( wp, |
|---|
| 6096 | "<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\\\"" ); |
|---|
| 6097 | |
|---|
| 6098 | c = nvram_safe_get( "trunking" ); |
|---|
| 6099 | |
|---|
| 6100 | snprintf( buff, 5, "%s", c ); |
|---|
| 6101 | |
|---|
| 6102 | if( atoi( buff ) == 1 ) |
|---|
| 6103 | websWrite( wp, " selected=\\\"selected\\\"" ); |
|---|
| 6104 | |
|---|
| 6105 | websWrite( wp, |
|---|
| 6106 | ">\" + vlan.trunk + \"</option>\");\n//]]>\n</script></select></td>\n" ); |
|---|
| 6107 | websWrite( wp, " </tr>" ); |
|---|
| 6108 | |
|---|
| 6109 | return; |
|---|
| 6110 | } |
|---|
| 6111 | |
|---|
| 6112 | /* |
|---|
| 6113 | * Note: VLAN #16 designates tagging. There is no VLAN #16 (only 0-15) |
|---|
| 6114 | */ |
|---|
| 6115 | |
|---|
| 6116 | void ej_get_qossvcs( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6117 | { |
|---|
| 6118 | char *qos_svcs = nvram_safe_get( "svqos_svcs" ); |
|---|
| 6119 | char name[32], type[32], data[32], level[32]; |
|---|
| 6120 | int no_svcs = 0, i = 0; |
|---|
| 6121 | |
|---|
| 6122 | // calc # of services |
|---|
| 6123 | // no_svcs = strspn(qos_svcs,"|"); |
|---|
| 6124 | |
|---|
| 6125 | while( ( qos_svcs = strpbrk( qos_svcs, "|" ) ) ) |
|---|
| 6126 | { |
|---|
| 6127 | no_svcs++; |
|---|
| 6128 | qos_svcs++; |
|---|
| 6129 | } |
|---|
| 6130 | |
|---|
| 6131 | // write HTML data |
|---|
| 6132 | |
|---|
| 6133 | websWrite( wp, |
|---|
| 6134 | "<tr><td colspan=\"3\"><input type=\"hidden\" name=\"svqos_nosvcs\" value=\"%d\" /></td></tr>", |
|---|
| 6135 | no_svcs ); |
|---|
| 6136 | |
|---|
| 6137 | qos_svcs = nvram_safe_get( "svqos_svcs" ); |
|---|
| 6138 | |
|---|
| 6139 | /* |
|---|
| 6140 | * services format is "name type data level | name type data level |" |
|---|
| 6141 | * ..etc |
|---|
| 6142 | */ |
|---|
| 6143 | for( i = 0; i < no_svcs && qos_svcs && qos_svcs[0]; i++ ) |
|---|
| 6144 | { |
|---|
| 6145 | if( sscanf |
|---|
| 6146 | ( qos_svcs, "%31s %31s %31s %31s ", name, type, data, |
|---|
| 6147 | level ) < 4 ) |
|---|
| 6148 | break; |
|---|
| 6149 | |
|---|
| 6150 | websWrite( wp, "<tr>\n\ |
|---|
| 6151 | <td>\n\ |
|---|
| 6152 | <input type=\"checkbox\" name=\"svqos_svcdel%d\" />\n\ |
|---|
| 6153 | <input type=\"hidden\" name=\"svqos_svcname%d\" value=\"%s\" />\n\ |
|---|
| 6154 | <input type=\"hidden\" name=\"svqos_svctype%d\" value=\"%s\" />\n\ |
|---|
| 6155 | </td>\n\ |
|---|
| 6156 | <td><em>%s</em></td>\n\ |
|---|
| 6157 | <td >\n", i, i, name, i, type, name ); |
|---|
| 6158 | websWrite( wp, "<select name=\"svqos_svcprio%d\"> \n\ |
|---|
| 6159 | <script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"100\\\" %s >\" + qos.prio_x + \"</option>\");\n\ |
|---|
| 6160 | document.write(\"<option value=\\\"10\\\" %s >\" + qos.prio_p + \"</option>\");\n\ |
|---|
| 6161 | document.write(\"<option value=\\\"20\\\" %s >\" + qos.prio_e + \"</option>\");\n\ |
|---|
| 6162 | document.write(\"<option value=\\\"30\\\" %s >\" + share.standard + \"</option>\");\n\ |
|---|
| 6163 | document.write(\"<option value=\\\"40\\\" %s >\" + qos.prio_b + \"</option>\");\n//]]>\n</script>\n\ |
|---|
| 6164 | </select>\n\ |
|---|
| 6165 | </td>\n\ |
|---|
| 6166 | </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\\\"" : "" ); |
|---|
| 6167 | |
|---|
| 6168 | qos_svcs = strpbrk( ++qos_svcs, "|" ); |
|---|
| 6169 | qos_svcs++; |
|---|
| 6170 | |
|---|
| 6171 | } |
|---|
| 6172 | |
|---|
| 6173 | return; |
|---|
| 6174 | } |
|---|
| 6175 | |
|---|
| 6176 | #ifndef HAVE_AQOS |
|---|
| 6177 | void ej_get_qosips( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6178 | { |
|---|
| 6179 | char *qos_ips = nvram_safe_get( "svqos_ips" ); |
|---|
| 6180 | char ip[32], level[32]; |
|---|
| 6181 | int no_ips = 0, i = 0; |
|---|
| 6182 | |
|---|
| 6183 | // calc # of ips |
|---|
| 6184 | while( ( qos_ips = strpbrk( qos_ips, "|" ) ) ) |
|---|
| 6185 | { |
|---|
| 6186 | no_ips++; |
|---|
| 6187 | qos_ips++; |
|---|
| 6188 | } |
|---|
| 6189 | websWrite( wp, "<tr>\n\ |
|---|
| 6190 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 6191 | <th><script type=\"text/javascript\">Capture(qos.ipmask)</script></th>\n\ |
|---|
| 6192 | <th><script type=\"text/javascript\">Capture(share.priority)</script></th>\n\ |
|---|
| 6193 | </tr>\n" ); |
|---|
| 6194 | |
|---|
| 6195 | // write HTML data |
|---|
| 6196 | |
|---|
| 6197 | websWrite( wp, |
|---|
| 6198 | "<tr><td colspan=\"3\"><input type=\"hidden\" name=\"svqos_noips\" value=\"%d\" /></td></tr>", |
|---|
| 6199 | no_ips ); |
|---|
| 6200 | |
|---|
| 6201 | qos_ips = nvram_safe_get( "svqos_ips" ); |
|---|
| 6202 | |
|---|
| 6203 | /* |
|---|
| 6204 | * IP format is "data level | data level |" ..etc |
|---|
| 6205 | */ |
|---|
| 6206 | for( i = 0; i < no_ips && qos_ips && qos_ips[0]; i++ ) |
|---|
| 6207 | { |
|---|
| 6208 | if( sscanf( qos_ips, "%31s %31s ", ip, level ) < 2 ) |
|---|
| 6209 | break; |
|---|
| 6210 | |
|---|
| 6211 | websWrite( wp, "<tr>\n\ |
|---|
| 6212 | <td>\n\ |
|---|
| 6213 | <input type=\"checkbox\" name=\"svqos_ipdel%d\" />\n\ |
|---|
| 6214 | <input type=\"hidden\" name=\"svqos_ip%d\" value=\"%s\" />\n\ |
|---|
| 6215 | </td>\n\ |
|---|
| 6216 | <td><em>%s</em></td>\n\ |
|---|
| 6217 | <td>\n", i, i, ip, ip ); |
|---|
| 6218 | websWrite( wp, "<select name=\"svqos_ipprio%d\"> \n\ |
|---|
| 6219 | <script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"100\\\" %s >\" + qos.prio_x + \"</option>\");\n\ |
|---|
| 6220 | document.write(\"<option value=\\\"10\\\" %s >\" + qos.prio_p + \"</option>\");\n\ |
|---|
| 6221 | document.write(\"<option value=\\\"20\\\" %s >\" + qos.prio_e + \"</option>\");\n\ |
|---|
| 6222 | document.write(\"<option value=\\\"30\\\" %s >\" + share.standard + \"</option>\");\n\ |
|---|
| 6223 | document.write(\"<option value=\\\"40\\\" %s >\" + qos.prio_b + \"</option>\");\n//]]>\n</script>\n\ |
|---|
| 6224 | </select>\n\ |
|---|
| 6225 | </td>\n\ |
|---|
| 6226 | </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\\\"" : "" ); |
|---|
| 6227 | |
|---|
| 6228 | qos_ips = strpbrk( ++qos_ips, "|" ); |
|---|
| 6229 | qos_ips++; |
|---|
| 6230 | |
|---|
| 6231 | } |
|---|
| 6232 | |
|---|
| 6233 | return; |
|---|
| 6234 | } |
|---|
| 6235 | #else |
|---|
| 6236 | void ej_get_qosips( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6237 | { |
|---|
| 6238 | char *qos_ips = nvram_safe_get( "svqos_ips" ); |
|---|
| 6239 | char ip[32], level[32], level2[32]; |
|---|
| 6240 | int no_ips = 0, i = 0; |
|---|
| 6241 | |
|---|
| 6242 | // calc # of ips |
|---|
| 6243 | while( ( qos_ips = strpbrk( qos_ips, "|" ) ) ) |
|---|
| 6244 | { |
|---|
| 6245 | no_ips++; |
|---|
| 6246 | qos_ips++; |
|---|
| 6247 | } |
|---|
| 6248 | websWrite( wp, "<tr>\n\ |
|---|
| 6249 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 6250 | <th><script type=\"text/javascript\">Capture(qos.ipmask)</script></th>\n\ |
|---|
| 6251 | <th><script type=\"text/javascript\">Capture(qos.maxuprate_b)</script></th>\n\ |
|---|
| 6252 | <th><script type=\"text/javascript\">Capture(qos.maxdownrate_b)</script></th>\n\ |
|---|
| 6253 | </tr>\n" ); |
|---|
| 6254 | |
|---|
| 6255 | // write HTML data |
|---|
| 6256 | |
|---|
| 6257 | websWrite( wp, |
|---|
| 6258 | "<tr><td colspan=\"3\"><input type=\"hidden\" name=\"svqos_noips\" value=\"%d\" /></td></tr>", |
|---|
| 6259 | no_ips ); |
|---|
| 6260 | |
|---|
| 6261 | qos_ips = nvram_safe_get( "svqos_ips" ); |
|---|
| 6262 | |
|---|
| 6263 | /* |
|---|
| 6264 | * IP format is "data level | data level |" ..etc |
|---|
| 6265 | */ |
|---|
| 6266 | for( i = 0; i < no_ips && qos_ips && qos_ips[0]; i++ ) |
|---|
| 6267 | { |
|---|
| 6268 | if( sscanf( qos_ips, "%31s %31s %31s ", ip, level, level2 ) < 3 ) |
|---|
| 6269 | break; |
|---|
| 6270 | websWrite( wp, "<tr>\n\ |
|---|
| 6271 | <td>\n\ |
|---|
| 6272 | <input type=\"checkbox\" name=\"svqos_ipdel%d\" />\n\ |
|---|
| 6273 | <input type=\"hidden\" name=\"svqos_ip%d\" value=\"%s\" />\n\ |
|---|
| 6274 | </td>\n\ |
|---|
| 6275 | <td><em>%s</em></td>\n\ |
|---|
| 6276 | <td>\n\ |
|---|
| 6277 | <input name=\"svqos_ipup%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 6278 | </td>\n\ |
|---|
| 6279 | <td>\n\ |
|---|
| 6280 | <input name=\"svqos_ipdown%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 6281 | </td>\n\ |
|---|
| 6282 | </tr>\n", i, i, ip, ip, i, level, i, level2 ); |
|---|
| 6283 | |
|---|
| 6284 | qos_ips = strpbrk( ++qos_ips, "|" ); |
|---|
| 6285 | qos_ips++; |
|---|
| 6286 | |
|---|
| 6287 | } |
|---|
| 6288 | |
|---|
| 6289 | return; |
|---|
| 6290 | } |
|---|
| 6291 | #endif |
|---|
| 6292 | #ifndef HAVE_AQOS |
|---|
| 6293 | void ej_get_qosmacs( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6294 | { |
|---|
| 6295 | char *qos_macs = nvram_safe_get( "svqos_macs" ); |
|---|
| 6296 | char mac[32], level[32]; |
|---|
| 6297 | int no_macs = 0, i = 0; |
|---|
| 6298 | |
|---|
| 6299 | // calc # of ips |
|---|
| 6300 | while( ( qos_macs = strpbrk( qos_macs, "|" ) ) ) |
|---|
| 6301 | { |
|---|
| 6302 | no_macs++; |
|---|
| 6303 | qos_macs++; |
|---|
| 6304 | } |
|---|
| 6305 | |
|---|
| 6306 | websWrite( wp, "<tr>\n\ |
|---|
| 6307 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 6308 | <th><script type=\"text/javascript\">Capture(share.mac)</script></th>\n\ |
|---|
| 6309 | <th><script type=\"text/javascript\">Capture(share.priority)</script></th>\n\ |
|---|
| 6310 | </tr>\n" ); |
|---|
| 6311 | |
|---|
| 6312 | // write HTML data |
|---|
| 6313 | websWrite( wp, |
|---|
| 6314 | "<input type=\"hidden\" name=\"svqos_nomacs\" value=\"%d\" />", |
|---|
| 6315 | no_macs ); |
|---|
| 6316 | |
|---|
| 6317 | qos_macs = nvram_safe_get( "svqos_macs" ); |
|---|
| 6318 | |
|---|
| 6319 | /* |
|---|
| 6320 | * IP format is "data level | data level |" ..etc |
|---|
| 6321 | */ |
|---|
| 6322 | for( i = 0; i < no_macs && qos_macs && qos_macs[0]; i++ ) |
|---|
| 6323 | { |
|---|
| 6324 | if( sscanf( qos_macs, "%31s %31s ", mac, level ) < 2 ) |
|---|
| 6325 | break; |
|---|
| 6326 | |
|---|
| 6327 | websWrite( wp, "<tr>\n\ |
|---|
| 6328 | <td>\n\ |
|---|
| 6329 | <input type=\"checkbox\" name=\"svqos_macdel%d\" />\n\ |
|---|
| 6330 | <input type=\"hidden\" name=\"svqos_mac%d\" value=\"%s\" />\n\ |
|---|
| 6331 | </td>\n\ |
|---|
| 6332 | <td><em>%s</em></td>\n\ |
|---|
| 6333 | <td>\n", i, i, mac, mac ); |
|---|
| 6334 | websWrite( wp, "<select name=\"svqos_macprio%d\"> \n\ |
|---|
| 6335 | <script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"100\\\" %s >\" + qos.prio_x + \"</option>\");\n\ |
|---|
| 6336 | document.write(\"<option value=\\\"10\\\" %s >\" + qos.prio_p + \"</option>\");\n\ |
|---|
| 6337 | document.write(\"<option value=\\\"20\\\" %s >\" + qos.prio_e + \"</option>\");\n\ |
|---|
| 6338 | document.write(\"<option value=\\\"30\\\" %s >\" + share.standard + \"</option>\");\n\ |
|---|
| 6339 | document.write(\"<option value=\\\"40\\\" %s >\" + qos.prio_b + \"</option>\");\n//]]>\n</script>\n\ |
|---|
| 6340 | </select>\n\ |
|---|
| 6341 | </td>\n\ |
|---|
| 6342 | </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\\\"" : "" ); |
|---|
| 6343 | |
|---|
| 6344 | qos_macs = strpbrk( ++qos_macs, "|" ); |
|---|
| 6345 | qos_macs++; |
|---|
| 6346 | |
|---|
| 6347 | } |
|---|
| 6348 | |
|---|
| 6349 | return; |
|---|
| 6350 | } |
|---|
| 6351 | |
|---|
| 6352 | #else |
|---|
| 6353 | void ej_get_qosmacs( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6354 | { |
|---|
| 6355 | char *qos_macs = nvram_safe_get( "svqos_macs" ); |
|---|
| 6356 | char mac[32], level[32], level2[32]; |
|---|
| 6357 | int no_macs = 0, i = 0; |
|---|
| 6358 | |
|---|
| 6359 | // calc # of ips |
|---|
| 6360 | while( ( qos_macs = strpbrk( qos_macs, "|" ) ) ) |
|---|
| 6361 | { |
|---|
| 6362 | no_macs++; |
|---|
| 6363 | qos_macs++; |
|---|
| 6364 | } |
|---|
| 6365 | websWrite( wp, "<tr>\n\ |
|---|
| 6366 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 6367 | <th><script type=\"text/javascript\">Capture(share.mac)</script></th>\n\ |
|---|
| 6368 | <th><script type=\"text/javascript\">Capture(qos.maxuprate_b)</script></th>\n\ |
|---|
| 6369 | <th><script type=\"text/javascript\">Capture(qos.maxdownrate_b)</script></th>\n\ |
|---|
| 6370 | </tr>\n" ); |
|---|
| 6371 | |
|---|
| 6372 | // write HTML data |
|---|
| 6373 | websWrite( wp, |
|---|
| 6374 | "<input type=\"hidden\" name=\"svqos_nomacs\" value=\"%d\" />", |
|---|
| 6375 | no_macs ); |
|---|
| 6376 | |
|---|
| 6377 | qos_macs = nvram_safe_get( "svqos_macs" ); |
|---|
| 6378 | |
|---|
| 6379 | /* |
|---|
| 6380 | * IP format is "data level | data level |" ..etc |
|---|
| 6381 | */ |
|---|
| 6382 | for( i = 0; i < no_macs && qos_macs && qos_macs[0]; i++ ) |
|---|
| 6383 | { |
|---|
| 6384 | if( sscanf( qos_macs, "%31s %31s %31s ", mac, level, level2 ) < 3 ) |
|---|
| 6385 | break; |
|---|
| 6386 | websWrite( wp, "<tr>\n\ |
|---|
| 6387 | <td>\n\ |
|---|
| 6388 | <input type=\"checkbox\" name=\"svqos_macdel%d\" />\n\ |
|---|
| 6389 | <input type=\"hidden\" name=\"svqos_mac%d\" value=\"%s\" />\n\ |
|---|
| 6390 | </td>\n\ |
|---|
| 6391 | <td><em>%s</em></td>\n\ |
|---|
| 6392 | <td>\n\ |
|---|
| 6393 | <input name=\"svqos_macup%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 6394 | </td>\n\ |
|---|
| 6395 | <td>\n\ |
|---|
| 6396 | <input name=\"svqos_macdown%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 6397 | </td>\n\ |
|---|
| 6398 | </tr>\n", i, i, mac, mac, i, level, i, level2 ); |
|---|
| 6399 | |
|---|
| 6400 | qos_macs = strpbrk( ++qos_macs, "|" ); |
|---|
| 6401 | qos_macs++; |
|---|
| 6402 | |
|---|
| 6403 | } |
|---|
| 6404 | |
|---|
| 6405 | return; |
|---|
| 6406 | } |
|---|
| 6407 | #endif |
|---|
| 6408 | |
|---|
| 6409 | /* |
|---|
| 6410 | * Added by Botho 03.April.06 |
|---|
| 6411 | */ |
|---|
| 6412 | void ej_dumpip_conntrack( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6413 | { |
|---|
| 6414 | int ip_count = 0; |
|---|
| 6415 | FILE *fp; |
|---|
| 6416 | int c; |
|---|
| 6417 | |
|---|
| 6418 | fp = fopen( "/proc/net/ip_conntrack", "rb" ); |
|---|
| 6419 | if( fp == NULL ) |
|---|
| 6420 | return; |
|---|
| 6421 | while( !feof( fp ) ) |
|---|
| 6422 | { |
|---|
| 6423 | c = getc( fp ); |
|---|
| 6424 | if( c == EOF ) |
|---|
| 6425 | break; |
|---|
| 6426 | if( c == 0xa ) |
|---|
| 6427 | ip_count++; |
|---|
| 6428 | } |
|---|
| 6429 | |
|---|
| 6430 | websWrite( wp, "%d", ip_count ); |
|---|
| 6431 | |
|---|
| 6432 | fclose( fp ); |
|---|
| 6433 | |
|---|
| 6434 | return; |
|---|
| 6435 | } |
|---|
| 6436 | |
|---|
| 6437 | /* |
|---|
| 6438 | * Added by Botho 28.Oct.06 |
|---|
| 6439 | */ |
|---|
| 6440 | static int search_hit( char *search, char *line, char *ret ) |
|---|
| 6441 | { |
|---|
| 6442 | unsigned int searchLen; |
|---|
| 6443 | unsigned int i; |
|---|
| 6444 | unsigned int j; |
|---|
| 6445 | unsigned int lineLen; |
|---|
| 6446 | |
|---|
| 6447 | if( line == NULL || search == NULL || ret == NULL ) |
|---|
| 6448 | return 1; |
|---|
| 6449 | lineLen = strlen( line ); |
|---|
| 6450 | searchLen = strlen( search ); |
|---|
| 6451 | |
|---|
| 6452 | if( searchLen > lineLen ) |
|---|
| 6453 | return ( 1 ); // this can't match, invalid data? |
|---|
| 6454 | |
|---|
| 6455 | for( i = 0; i < lineLen - searchLen; i++ ) |
|---|
| 6456 | { |
|---|
| 6457 | if( !strncasecmp( ( char * )&line[i], search, searchLen ) ) |
|---|
| 6458 | break; // we got hit |
|---|
| 6459 | } |
|---|
| 6460 | |
|---|
| 6461 | for( j = i + searchLen; j < i + 15 + searchLen; j++ ) |
|---|
| 6462 | { |
|---|
| 6463 | if( j >= lineLen ) |
|---|
| 6464 | break; // end of line may be a delimiter too |
|---|
| 6465 | // return(1); // incomplete data |
|---|
| 6466 | if( line[j] == ' ' ) |
|---|
| 6467 | break; // we reach _space_ delimiter |
|---|
| 6468 | } |
|---|
| 6469 | memcpy( ret, &line[i + searchLen], j - ( i + searchLen ) ); |
|---|
| 6470 | ret[j - ( i + searchLen )] = 0; |
|---|
| 6471 | return ( 0 ); |
|---|
| 6472 | } |
|---|
| 6473 | |
|---|
| 6474 | static int string_search( char *string, char *search ) |
|---|
| 6475 | { |
|---|
| 6476 | int searchLen; |
|---|
| 6477 | int i; |
|---|
| 6478 | |
|---|
| 6479 | if( search == NULL ) |
|---|
| 6480 | return 0; |
|---|
| 6481 | searchLen = strlen( search ); |
|---|
| 6482 | if( string == NULL ) |
|---|
| 6483 | return 0; |
|---|
| 6484 | if( searchLen > strlen( string ) ) |
|---|
| 6485 | { |
|---|
| 6486 | return ( 0 ); // this can't match |
|---|
| 6487 | } |
|---|
| 6488 | int slen = strlen( string ); |
|---|
| 6489 | |
|---|
| 6490 | for( i = 0; i < slen - searchLen; i++ ) |
|---|
| 6491 | { // +1 removed. |
|---|
| 6492 | if( !strncasecmp( ( char * )&string[i], search, searchLen ) ) |
|---|
| 6493 | { |
|---|
| 6494 | return ( 1 ); // we got hit |
|---|
| 6495 | } |
|---|
| 6496 | } |
|---|
| 6497 | return ( 0 ); |
|---|
| 6498 | } |
|---|
| 6499 | |
|---|
| 6500 | void ej_ip_conntrack_table( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6501 | { |
|---|
| 6502 | FILE *fp; |
|---|
| 6503 | int ip_count = 1; |
|---|
| 6504 | char line[512]; |
|---|
| 6505 | char protocol[16] = ""; |
|---|
| 6506 | int timeout = 0; |
|---|
| 6507 | char srcip[16] = ""; |
|---|
| 6508 | char dstip[16] = ""; |
|---|
| 6509 | int _dport; |
|---|
| 6510 | struct servent *servp; |
|---|
| 6511 | char dstport[6] = ""; |
|---|
| 6512 | char state[12] = ""; |
|---|
| 6513 | char dum1[32]; |
|---|
| 6514 | int dum2; |
|---|
| 6515 | |
|---|
| 6516 | fp = fopen( "/proc/net/ip_conntrack", "rb" ); |
|---|
| 6517 | if( fp == NULL ) |
|---|
| 6518 | return; |
|---|
| 6519 | |
|---|
| 6520 | while( fgets( line, sizeof( line ), fp ) != NULL ) |
|---|
| 6521 | { |
|---|
| 6522 | |
|---|
| 6523 | websWrite( wp, "<tr>\n" ); |
|---|
| 6524 | |
|---|
| 6525 | // Nb |
|---|
| 6526 | websWrite( wp, "<td align=\"right\">%d</td>", ip_count ); |
|---|
| 6527 | |
|---|
| 6528 | // Proto |
|---|
| 6529 | if( string_search( line, "tcp" ) ) |
|---|
| 6530 | sprintf( protocol, "TCP" ); |
|---|
| 6531 | else if( string_search( line, "udp" ) ) |
|---|
| 6532 | sprintf( protocol, "UDP" ); |
|---|
| 6533 | else if( string_search( line, "icmp" ) ) |
|---|
| 6534 | sprintf( protocol, "ICMP" ); |
|---|
| 6535 | else |
|---|
| 6536 | sprintf( protocol, live_translate( "share.unknown" ) ); |
|---|
| 6537 | websWrite( wp, "<td>%s</td>", protocol ); |
|---|
| 6538 | |
|---|
| 6539 | // Timeout |
|---|
| 6540 | sscanf( line, "%s %d %d", &dum1[0], &dum2, &timeout ); |
|---|
| 6541 | websWrite( wp, "<td align=\"right\">%d</td>", timeout ); |
|---|
| 6542 | |
|---|
| 6543 | // src |
|---|
| 6544 | search_hit( "src=", line, srcip ); |
|---|
| 6545 | // char buf[200]; |
|---|
| 6546 | // getHostName (buf, srcip); |
|---|
| 6547 | // websWrite (wp, "<td align=\"right\" onmouseover='DisplayDiv(this, |
|---|
| 6548 | // event, 15, 15, \"%s\")' onmouseout=\"unDisplayDiv()\">%s</td>", |
|---|
| 6549 | // buf != "unknown" ? buf : live_translate ("share.unknown") , |
|---|
| 6550 | // srcip); |
|---|
| 6551 | websWrite( wp, "<td align=\"right\">%s</td>", srcip ); |
|---|
| 6552 | |
|---|
| 6553 | // dst |
|---|
| 6554 | search_hit( "dst=", line, dstip ); |
|---|
| 6555 | // getHostName (buf, dstip); |
|---|
| 6556 | // websWrite (wp, "<td align=\"right\" onmouseover='DisplayDiv(this, |
|---|
| 6557 | // event, 15, 15, \"%s\")' onmouseout=\"unDisplayDiv()\">%s</td>", |
|---|
| 6558 | // buf != "unknown" ? buf : live_translate ("share.unknown") , |
|---|
| 6559 | // dstip); |
|---|
| 6560 | websWrite( wp, "<td align=\"right\">%s</td>", dstip ); |
|---|
| 6561 | |
|---|
| 6562 | // service |
|---|
| 6563 | search_hit( "dport=", line, dstport ); |
|---|
| 6564 | _dport = atoi( dstport ); |
|---|
| 6565 | servp = my_getservbyport( htons( _dport ), protocol ); |
|---|
| 6566 | websWrite( wp, "<td align=\"right\">%s</td>", |
|---|
| 6567 | servp ? servp->s_name : dstport ); |
|---|
| 6568 | |
|---|
| 6569 | // State |
|---|
| 6570 | if( string_search( line, "ESTABLISHED" ) ) |
|---|
| 6571 | sprintf( state, "ESTABLISHED" ); |
|---|
| 6572 | else if( string_search( line, "TIME_WAIT" ) ) |
|---|
| 6573 | sprintf( state, "TIME_WAIT" ); |
|---|
| 6574 | else if( string_search( line, "UNREPLIED" ) ) |
|---|
| 6575 | sprintf( state, "UNREPLIED" ); |
|---|
| 6576 | else if( string_search( line, "CLOSE" ) ) |
|---|
| 6577 | sprintf( state, "CLOSE" ); |
|---|
| 6578 | else if( string_search( line, "ASSURED" ) ) |
|---|
| 6579 | sprintf( state, "ASSURED" ); |
|---|
| 6580 | else |
|---|
| 6581 | { |
|---|
| 6582 | if( string_search( line, "udp" ) ) |
|---|
| 6583 | sprintf( state, "UNREPLIED" ); |
|---|
| 6584 | else |
|---|
| 6585 | sprintf( state, " " ); |
|---|
| 6586 | } |
|---|
| 6587 | websWrite( wp, "<td>%s</td>\n", state ); |
|---|
| 6588 | websWrite( wp, "</tr>\n" ); |
|---|
| 6589 | |
|---|
| 6590 | ip_count++; |
|---|
| 6591 | } |
|---|
| 6592 | |
|---|
| 6593 | fclose( fp ); |
|---|
| 6594 | |
|---|
| 6595 | return; |
|---|
| 6596 | } |
|---|
| 6597 | |
|---|
| 6598 | void ej_gethostnamebyip( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6599 | { |
|---|
| 6600 | char buf[200]; |
|---|
| 6601 | char *argument; |
|---|
| 6602 | |
|---|
| 6603 | #ifdef FASTWEB |
|---|
| 6604 | ejArgs( argc, argv, "%s", &argument ); |
|---|
| 6605 | #else |
|---|
| 6606 | if( ejArgs( argc, argv, "%s", &argument ) < 1 ) |
|---|
| 6607 | { |
|---|
| 6608 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 6609 | return; |
|---|
| 6610 | } |
|---|
| 6611 | #endif |
|---|
| 6612 | |
|---|
| 6613 | if( argc == 1 ) |
|---|
| 6614 | { |
|---|
| 6615 | getHostName( buf, argument ); |
|---|
| 6616 | websWrite( wp, "%s", |
|---|
| 6617 | buf != |
|---|
| 6618 | "unknown" ? buf : live_translate( "share.unknown" ) ); |
|---|
| 6619 | } |
|---|
| 6620 | |
|---|
| 6621 | return; |
|---|
| 6622 | } |
|---|
| 6623 | |
|---|
| 6624 | /* |
|---|
| 6625 | * BEGIN Added by Botho 10.May.06 |
|---|
| 6626 | */ |
|---|
| 6627 | void ej_show_wan_to_switch( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6628 | { |
|---|
| 6629 | |
|---|
| 6630 | if( nvram_match( "wan_proto", "disabled" ) || !nvram_match( "wl_mode", "ap" ) ) // WAN |
|---|
| 6631 | // disabled |
|---|
| 6632 | // OR |
|---|
| 6633 | // Wirelles |
|---|
| 6634 | // is |
|---|
| 6635 | // not |
|---|
| 6636 | // AP |
|---|
| 6637 | { |
|---|
| 6638 | websWrite( wp, "<fieldset>\n\ |
|---|
| 6639 | <legend><script type=\"text/javascript\">Capture(idx.legend2)</script></legend>\n\ |
|---|
| 6640 | <div class=\"setting\">\n\ |
|---|
| 6641 | <div class=\"label\"><script type=\"text/javascript\">Capture(idx.wantoswitch)</script></div>\n\ |
|---|
| 6642 | <input class=\"spaceradio\" type=\"checkbox\" name=\"_fullswitch\" value=\"1\" %s />\n\ |
|---|
| 6643 | </div>\n\ |
|---|
| 6644 | </fieldset><br />\n", nvram_match( "fullswitch", "1" ) ? "checked=\"checked\"" : "" ); |
|---|
| 6645 | } |
|---|
| 6646 | |
|---|
| 6647 | return; |
|---|
| 6648 | } |
|---|
| 6649 | |
|---|
| 6650 | #define PROC_DEV "/proc/net/dev" |
|---|
| 6651 | |
|---|
| 6652 | void ej_wl_packet_get( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6653 | { |
|---|
| 6654 | char line[256]; |
|---|
| 6655 | FILE *fp; |
|---|
| 6656 | |
|---|
| 6657 | #ifdef HAVE_MADWIFI |
|---|
| 6658 | char *ifname = nvram_safe_get( "wifi_display" ); |
|---|
| 6659 | #else |
|---|
| 6660 | char *ifname = nvram_safe_get( "wl0_ifname" ); |
|---|
| 6661 | #endif |
|---|
| 6662 | struct dev_info |
|---|
| 6663 | { |
|---|
| 6664 | // unsigned long rx_bytes; |
|---|
| 6665 | unsigned long rx_pks; |
|---|
| 6666 | unsigned long rx_errs; |
|---|
| 6667 | unsigned long rx_drops; |
|---|
| 6668 | // unsigned long rx_fifo; |
|---|
| 6669 | // unsigned long rx_frame; |
|---|
| 6670 | // unsigned long rx_com; |
|---|
| 6671 | // unsigned long rx_mcast; |
|---|
| 6672 | // unsigned long tx_bytes; |
|---|
| 6673 | unsigned long tx_pks; |
|---|
| 6674 | unsigned long tx_errs; |
|---|
| 6675 | unsigned long tx_drops; |
|---|
| 6676 | // unsigned long tx_fifo; |
|---|
| 6677 | unsigned long tx_colls; |
|---|
| 6678 | // unsigned long tx_carr; |
|---|
| 6679 | // unsigned long tx_com; |
|---|
| 6680 | } info; |
|---|
| 6681 | |
|---|
| 6682 | info.rx_pks = info.rx_errs = info.rx_drops = 0; |
|---|
| 6683 | info.tx_pks = info.tx_errs = info.tx_drops = info.tx_colls = 0; |
|---|
| 6684 | |
|---|
| 6685 | if( ( fp = fopen( PROC_DEV, "r" ) ) == NULL ) |
|---|
| 6686 | { |
|---|
| 6687 | websError( wp, 400, "Can't open %s\n", PROC_DEV ); |
|---|
| 6688 | return; |
|---|
| 6689 | } |
|---|
| 6690 | else |
|---|
| 6691 | { |
|---|
| 6692 | /* |
|---|
| 6693 | * Inter-| Receive | Transmit face |bytes packets errs drop fifo |
|---|
| 6694 | * frame compressed multicast|bytes packets errs drop fifo colls |
|---|
| 6695 | * carrier compressed lo: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 eth0: |
|---|
| 6696 | * 674829 5501 0 0 0 0 0 0 1249130 1831 0 0 0 0 0 0 eth1: 0 0 0 0 0 0 |
|---|
| 6697 | * 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 |
|---|
| 6698 | * br0: 107114 1078 0 0 0 0 0 0 910094 1304 0 0 0 0 0 0 |
|---|
| 6699 | * |
|---|
| 6700 | */ |
|---|
| 6701 | while( fgets( line, sizeof( line ), fp ) != NULL ) |
|---|
| 6702 | { |
|---|
| 6703 | int ifl = 0; |
|---|
| 6704 | |
|---|
| 6705 | if( !strchr( line, ':' ) ) |
|---|
| 6706 | continue; |
|---|
| 6707 | while( line[ifl] != ':' ) |
|---|
| 6708 | ifl++; |
|---|
| 6709 | line[ifl] = 0; /* interface */ |
|---|
| 6710 | |
|---|
| 6711 | if( strstr( line, ifname ) ) |
|---|
| 6712 | { |
|---|
| 6713 | /* |
|---|
| 6714 | * sscanf (line + ifl + 1, "%ld %ld %ld %ld %ld %ld %ld %ld |
|---|
| 6715 | * %ld %ld %ld %ld %ld %ld %ld %ld", &info.rx_bytes, |
|---|
| 6716 | * &info.rx_pks, &info.rx_errs, &info.rx_drops, |
|---|
| 6717 | * &info.rx_fifo, &info.rx_frame, &info.rx_com, |
|---|
| 6718 | * &info.rx_mcast, &info.tx_bytes, &info.tx_pks, |
|---|
| 6719 | * &info.tx_errs, &info.tx_drops, &info.tx_fifo, |
|---|
| 6720 | * &info.tx_colls, &info.tx_carr, &info.tx_com); |
|---|
| 6721 | */ |
|---|
| 6722 | sscanf( line + ifl + 1, |
|---|
| 6723 | "%*ld %ld %ld %ld %*ld %*ld %*ld %*ld %*ld %ld %ld %ld %*ld %ld %*ld %*ld", |
|---|
| 6724 | &info.rx_pks, &info.rx_errs, |
|---|
| 6725 | &info.rx_drops, |
|---|
| 6726 | &info.tx_pks, &info.tx_errs, &info.tx_drops, |
|---|
| 6727 | &info.tx_colls ); |
|---|
| 6728 | } |
|---|
| 6729 | |
|---|
| 6730 | } |
|---|
| 6731 | fclose( fp ); |
|---|
| 6732 | } |
|---|
| 6733 | |
|---|
| 6734 | websWrite( wp, "SWRXgoodPacket=%ld;", info.rx_pks ); |
|---|
| 6735 | websWrite( wp, "SWRXerrorPacket=%ld;", info.rx_errs + info.rx_drops ); |
|---|
| 6736 | |
|---|
| 6737 | websWrite( wp, "SWTXgoodPacket=%ld;", info.tx_pks ); |
|---|
| 6738 | websWrite( wp, "SWTXerrorPacket=%ld;", |
|---|
| 6739 | info.tx_errs + info.tx_drops + info.tx_colls ); |
|---|
| 6740 | |
|---|
| 6741 | return; |
|---|
| 6742 | } |
|---|
| 6743 | |
|---|
| 6744 | /* |
|---|
| 6745 | * END Added by Botho 10.May.06 |
|---|
| 6746 | */ |
|---|
| 6747 | |
|---|
| 6748 | void ej_statfs( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6749 | { |
|---|
| 6750 | struct statfs sizefs; |
|---|
| 6751 | |
|---|
| 6752 | if( argc != 2 ) |
|---|
| 6753 | return; |
|---|
| 6754 | |
|---|
| 6755 | if( ( statfs( argv[0], &sizefs ) != 0 ) |
|---|
| 6756 | || ( sizefs.f_type == 0x73717368 ) ) |
|---|
| 6757 | memset( &sizefs, 0, sizeof( sizefs ) ); |
|---|
| 6758 | |
|---|
| 6759 | websWrite( wp, "var %s = {\n\ |
|---|
| 6760 | size: %llu,\n\ |
|---|
| 6761 | free: %llu\n\ |
|---|
| 6762 | };\n", argv[1], ( ( uint64_t ) sizefs.f_bsize * sizefs.f_blocks ), ( ( uint64_t ) sizefs.f_bsize * sizefs.f_bfree ) ); |
|---|
| 6763 | } |
|---|
| 6764 | |
|---|
| 6765 | #ifdef HAVE_RSTATS |
|---|
| 6766 | /* |
|---|
| 6767 | * |
|---|
| 6768 | * rstats Copyright (C) 2006 Jonathan Zarate |
|---|
| 6769 | * |
|---|
| 6770 | * Licensed under GNU GPL v2 or later. |
|---|
| 6771 | * |
|---|
| 6772 | */ |
|---|
| 6773 | |
|---|
| 6774 | void ej_bandwidth( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6775 | { |
|---|
| 6776 | char *name; |
|---|
| 6777 | int sig; |
|---|
| 6778 | char *argument; |
|---|
| 6779 | |
|---|
| 6780 | #ifdef FASTWEB |
|---|
| 6781 | ejArgs( argc, argv, "%s", &argument ); |
|---|
| 6782 | #else |
|---|
| 6783 | if( ejArgs( argc, argv, "%s", &argument ) < 1 ) |
|---|
| 6784 | { |
|---|
| 6785 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 6786 | return; |
|---|
| 6787 | } |
|---|
| 6788 | #endif |
|---|
| 6789 | |
|---|
| 6790 | if( argc == 1 ) |
|---|
| 6791 | { |
|---|
| 6792 | if( strcmp( argument, "speed" ) == 0 ) |
|---|
| 6793 | { |
|---|
| 6794 | sig = SIGUSR1; |
|---|
| 6795 | name = "/var/spool/rstats-speed.js"; |
|---|
| 6796 | } |
|---|
| 6797 | else |
|---|
| 6798 | { |
|---|
| 6799 | sig = SIGUSR2; |
|---|
| 6800 | name = "/var/spool/rstats-history.js"; |
|---|
| 6801 | } |
|---|
| 6802 | unlink( name ); |
|---|
| 6803 | killall( "rstats", sig ); |
|---|
| 6804 | wait_file_exists( name, 5, 0 ); |
|---|
| 6805 | do_file( name, wp, NULL ); |
|---|
| 6806 | unlink( name ); |
|---|
| 6807 | } |
|---|
| 6808 | } |
|---|
| 6809 | #endif |
|---|
| 6810 | |
|---|
| 6811 | #ifdef HAVE_PORTSETUP |
|---|
| 6812 | void ej_portsetup( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6813 | { |
|---|
| 6814 | char ssid[64]; |
|---|
| 6815 | char *next; |
|---|
| 6816 | char var[64]; |
|---|
| 6817 | char eths[256]; |
|---|
| 6818 | |
|---|
| 6819 | websWrite( wp, |
|---|
| 6820 | "<h2><script type=\"text/javascript\">Capture(idx.portsetup)</script></h2>\n" ); |
|---|
| 6821 | websWrite( wp, "<fieldset>\n" ); |
|---|
| 6822 | websWrite( wp, |
|---|
| 6823 | "<legend><script type=\"text/javascript\">Capture(idx.portsetup)</script></legend>\n" ); |
|---|
| 6824 | memset( eths, 0, 256 ); |
|---|
| 6825 | getIfLists( eths, 256 ); |
|---|
| 6826 | websWrite( wp, |
|---|
| 6827 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(idx.wanport)</script></div>\n" ); |
|---|
| 6828 | websWrite( wp, "<select name=\"wan_ifname\">\n" ); |
|---|
| 6829 | websWrite( wp, "<option value=\"\" %s >Disabled</option>\n", |
|---|
| 6830 | nvram_match( "wan_ifname", |
|---|
| 6831 | "" ) ? "selected=\"selected\"" : "" ); |
|---|
| 6832 | foreach( var, eths, next ) |
|---|
| 6833 | { |
|---|
| 6834 | websWrite( wp, "<option value=\"%s\" %s >%s</option>\n", var, |
|---|
| 6835 | nvram_match( "wan_ifname", |
|---|
| 6836 | var ) ? "selected=\"selected\"" : "", var ); |
|---|
| 6837 | } |
|---|
| 6838 | websWrite( wp, "</select></div>\n" ); |
|---|
| 6839 | |
|---|
| 6840 | foreach( var, eths, next ) |
|---|
| 6841 | { |
|---|
| 6842 | if( !strcmp( get_wan_face( ), var ) ) |
|---|
| 6843 | continue; |
|---|
| 6844 | if( !strcmp( nvram_safe_get( "lan_ifname" ), var ) ) |
|---|
| 6845 | continue; |
|---|
| 6846 | if( !strncmp( var, "br", 2 ) && !contains( var, '.' ) ) |
|---|
| 6847 | continue; |
|---|
| 6848 | |
|---|
| 6849 | sprintf( ssid, "%s_bridged", var ); |
|---|
| 6850 | websWrite( wp, |
|---|
| 6851 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.network)</script> %s</div>\n", |
|---|
| 6852 | var ); |
|---|
| 6853 | char layer[64]; |
|---|
| 6854 | |
|---|
| 6855 | strcpy( layer, var ); |
|---|
| 6856 | rep( layer, '.', 'X' ); |
|---|
| 6857 | websWrite( wp, |
|---|
| 6858 | "<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", |
|---|
| 6859 | layer, var, nvram_default_match( ssid, |
|---|
| 6860 | "0", |
|---|
| 6861 | "1" ) ? |
|---|
| 6862 | "checked=\"checked\"" : "" ); |
|---|
| 6863 | websWrite( wp, |
|---|
| 6864 | "<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", |
|---|
| 6865 | layer, var, nvram_default_match( ssid, "1", |
|---|
| 6866 | "1" ) ? |
|---|
| 6867 | "checked=\"checked\"" : "" ); |
|---|
| 6868 | websWrite( wp, "</div>\n" ); |
|---|
| 6869 | |
|---|
| 6870 | websWrite( wp, "<div id=\"%s_idnet\">\n", layer ); |
|---|
| 6871 | char mcast[32]; |
|---|
| 6872 | |
|---|
| 6873 | sprintf( mcast, "%s_multicast", var ); |
|---|
| 6874 | nvram_default_get( mcast, "0" ); |
|---|
| 6875 | showRadio( wp, "wl_basic.multicast", mcast ); |
|---|
| 6876 | show_ipnetmask( wp, var ); |
|---|
| 6877 | websWrite( wp, "</div>\n" ); |
|---|
| 6878 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n " ); |
|---|
| 6879 | websWrite( wp, |
|---|
| 6880 | "show_layer_ext(document.getElementsByName(\"%s_bridged\"), \"%s_idnet\", %s);\n", |
|---|
| 6881 | var, layer, nvram_match( ssid, "0" ) ? "true" : "false" ); |
|---|
| 6882 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 6883 | } |
|---|
| 6884 | websWrite( wp, "</fieldset><br />\n" ); |
|---|
| 6885 | } |
|---|
| 6886 | #endif |
|---|
| 6887 | |
|---|
| 6888 | static void show_macfilter_if( webs_t wp, char *ifname ) |
|---|
| 6889 | { |
|---|
| 6890 | char rifname[32]; |
|---|
| 6891 | |
|---|
| 6892 | strcpy( rifname, ifname ); |
|---|
| 6893 | if( !strcmp( ifname, "wl" ) ) |
|---|
| 6894 | strcpy( rifname, nvram_safe_get( "wl0_ifname" ) ); |
|---|
| 6895 | if( !strcmp( ifname, "wl0" ) ) |
|---|
| 6896 | strcpy( rifname, nvram_safe_get( "wl0_ifname" ) ); |
|---|
| 6897 | |
|---|
| 6898 | websWrite( wp, "<fieldset>\n" ); |
|---|
| 6899 | websWrite( wp, "<legend>%s - %s</legend>\n", rifname, |
|---|
| 6900 | live_translate( "wl_mac.legend" ) ); |
|---|
| 6901 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 6902 | websWrite( wp, "<div class=\"label\">%s</div>\n", |
|---|
| 6903 | live_translate( "wl_mac.label" ) ); |
|---|
| 6904 | char macmode[32]; |
|---|
| 6905 | |
|---|
| 6906 | sprintf( macmode, "%s_macmode1", ifname ); |
|---|
| 6907 | rep( macmode, '.', 'X' ); |
|---|
| 6908 | if( nvram_get( macmode ) == NULL ) |
|---|
| 6909 | nvram_set( macmode, "disabled" ); |
|---|
| 6910 | char id[32]; |
|---|
| 6911 | |
|---|
| 6912 | sprintf( id, "idmac%s", ifname ); |
|---|
| 6913 | rep( id, '.', 'X' ); |
|---|
| 6914 | char mycopy[256]; |
|---|
| 6915 | |
|---|
| 6916 | strcpy( mycopy, live_translate( "share.enable" ) ); |
|---|
| 6917 | websWrite( wp, |
|---|
| 6918 | "<input class=\"spaceradio\" type=\"radio\" value=\"other\" name=\"%s\" %s onclick=\"show_layer_ext(this, '%s', true)\" />%s \n", |
|---|
| 6919 | macmode, nvram_match( macmode, |
|---|
| 6920 | "other" ) ? "checked=\"checked\"" : "", |
|---|
| 6921 | id, mycopy ); |
|---|
| 6922 | strcpy( mycopy, live_translate( "share.disable" ) ); |
|---|
| 6923 | websWrite( wp, |
|---|
| 6924 | "<input class=\"spaceradio\" type=\"radio\" value=\"disabled\" name=\"%s\" %s onclick=\"show_layer_ext(this, '%s', false)\" />%s\n", |
|---|
| 6925 | macmode, nvram_match( macmode, |
|---|
| 6926 | "disabled" ) ? "checked=\"checked\"" : |
|---|
| 6927 | "", id, mycopy ); |
|---|
| 6928 | websWrite( wp, "</div>\n" ); |
|---|
| 6929 | websWrite( wp, "<div class=\"setting\" id=\"%s\">\n", id ); |
|---|
| 6930 | websWrite( wp, "<div class=\"label\">%s<br /> </div>\n", |
|---|
| 6931 | live_translate( "wl_mac.label2" ) ); |
|---|
| 6932 | sprintf( macmode, "%s_macmode", ifname ); |
|---|
| 6933 | if( nvram_get( macmode ) == NULL ) |
|---|
| 6934 | nvram_set( macmode, "disabled" ); |
|---|
| 6935 | strcpy( mycopy, live_translate( "wl_mac.deny" ) ); |
|---|
| 6936 | websWrite( wp, |
|---|
| 6937 | "<input class=\"spaceradio\" type=\"radio\" value=\"deny\" name=\"%s\" %s />%s \n", |
|---|
| 6938 | macmode, nvram_invmatch( macmode, |
|---|
| 6939 | "allow" ) ? "checked=\"checked\"" : |
|---|
| 6940 | "", mycopy ); |
|---|
| 6941 | websWrite( wp, "<br />\n" ); |
|---|
| 6942 | strcpy( mycopy, live_translate( "wl_mac.allow" ) ); |
|---|
| 6943 | websWrite( wp, |
|---|
| 6944 | "<input class=\"spaceradio\" type=\"radio\" value=\"allow\" name=\"%s\" %s />%s\n", |
|---|
| 6945 | macmode, nvram_match( macmode, |
|---|
| 6946 | "allow" ) ? "checked=\"checked\"" : "", |
|---|
| 6947 | mycopy ); |
|---|
| 6948 | websWrite( wp, "</div><br />\n" ); |
|---|
| 6949 | websWrite( wp, "<div class=\"center\">\n" ); |
|---|
| 6950 | websWrite( wp, "<script type=\"text/javascript\">\n" ); |
|---|
| 6951 | websWrite( wp, "//<![CDATA[\n" ); |
|---|
| 6952 | websWrite( wp, |
|---|
| 6953 | "document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" name=\\\"mac_filter_button\\\" value=\\\"\" + sbutton.filterMac + \"\\\" onclick=\\\"openWindow('WL_FilterTable-%s.asp', 930, 740,'MACList');\\\" />\");\n", |
|---|
| 6954 | ifname ); |
|---|
| 6955 | websWrite( wp, "//]]>\n" ); |
|---|
| 6956 | websWrite( wp, "</script>\n" ); |
|---|
| 6957 | websWrite( wp, "</div>\n" ); |
|---|
| 6958 | websWrite( wp, "</fieldset><br />\n" ); |
|---|
| 6959 | } |
|---|
| 6960 | |
|---|
| 6961 | void ej_list_mac_layers( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6962 | { |
|---|
| 6963 | #ifndef HAVE_MADWIFI |
|---|
| 6964 | int c = get_wl_instances( ); |
|---|
| 6965 | char devs[32]; |
|---|
| 6966 | int i; |
|---|
| 6967 | |
|---|
| 6968 | for( i = 0; i < c; i++ ) |
|---|
| 6969 | { |
|---|
| 6970 | char macmode[32]; |
|---|
| 6971 | char id[32]; |
|---|
| 6972 | |
|---|
| 6973 | sprintf( devs, "wl%d", i ); |
|---|
| 6974 | sprintf( macmode, "%s_macmode1", devs ); |
|---|
| 6975 | sprintf( id, "idmac%s", devs ); |
|---|
| 6976 | rep( id, '.', 'X' ); |
|---|
| 6977 | rep( macmode, '.', 'X' ); |
|---|
| 6978 | websWrite( wp, |
|---|
| 6979 | "show_layer_ext(document.wireless.%s, '%s', \"%s\" == \"other\");\n", |
|---|
| 6980 | macmode, id, nvram_match( macmode, |
|---|
| 6981 | "other" ) ? "other" : |
|---|
| 6982 | "disabled" ); |
|---|
| 6983 | } |
|---|
| 6984 | |
|---|
| 6985 | #else |
|---|
| 6986 | |
|---|
| 6987 | int c = getdevicecount( ); |
|---|
| 6988 | char devs[32]; |
|---|
| 6989 | int i; |
|---|
| 6990 | |
|---|
| 6991 | for( i = 0; i < c; i++ ) |
|---|
| 6992 | { |
|---|
| 6993 | char macmode[32]; |
|---|
| 6994 | char id[32]; |
|---|
| 6995 | |
|---|
| 6996 | sprintf( devs, "ath%d", i ); |
|---|
| 6997 | sprintf( macmode, "%s_macmode1", devs ); |
|---|
| 6998 | sprintf( id, "idmac%s", devs ); |
|---|
| 6999 | rep( id, '.', 'X' ); |
|---|
| 7000 | rep( macmode, '.', 'X' ); |
|---|
| 7001 | websWrite( wp, |
|---|
| 7002 | "show_layer_ext(document.wireless.%s, '%s', \"%s\" == \"other\");\n", |
|---|
| 7003 | macmode, id, nvram_match( macmode, |
|---|
| 7004 | "other" ) ? "other" : |
|---|
| 7005 | "disabled" ); |
|---|
| 7006 | // show_macfilter_if (wp, devs); |
|---|
| 7007 | char vif[32]; |
|---|
| 7008 | |
|---|
| 7009 | sprintf( vif, "%s_vifs", devs ); |
|---|
| 7010 | char var[80], *next; |
|---|
| 7011 | char *vifs = nvram_safe_get( vif ); |
|---|
| 7012 | |
|---|
| 7013 | if( vifs != NULL ) |
|---|
| 7014 | foreach( var, vifs, next ) |
|---|
| 7015 | { |
|---|
| 7016 | sprintf( macmode, "%s_macmode1", var ); |
|---|
| 7017 | sprintf( id, "idmac%s", var ); |
|---|
| 7018 | rep( id, '.', 'X' ); |
|---|
| 7019 | rep( macmode, '.', 'X' ); |
|---|
| 7020 | websWrite( wp, |
|---|
| 7021 | "show_layer_ext(document.wireless.%s, '%s', \"%s\" == \"other\");\n", |
|---|
| 7022 | macmode, id, nvram_match( macmode, |
|---|
| 7023 | "other" ) ? "other" : |
|---|
| 7024 | "disabled" ); |
|---|
| 7025 | } |
|---|
| 7026 | } |
|---|
| 7027 | |
|---|
| 7028 | #endif |
|---|
| 7029 | } |
|---|
| 7030 | void ej_show_macfilter( webs_t wp, int argc, char_t ** argv ) |
|---|
| 7031 | { |
|---|
| 7032 | #ifndef HAVE_MADWIFI |
|---|
| 7033 | int c = get_wl_instances( ); |
|---|
| 7034 | char devs[32]; |
|---|
| 7035 | int i; |
|---|
| 7036 | |
|---|
| 7037 | for( i = 0; i < c; i++ ) |
|---|
| 7038 | { |
|---|
| 7039 | sprintf( devs, "wl%d", i ); |
|---|
| 7040 | show_macfilter_if( wp, devs ); |
|---|
| 7041 | } |
|---|
| 7042 | #else |
|---|
| 7043 | int c = getdevicecount( ); |
|---|
| 7044 | char devs[32]; |
|---|
| 7045 | int i; |
|---|
| 7046 | |
|---|
| 7047 | for( i = 0; i < c; i++ ) |
|---|
| 7048 | { |
|---|
| 7049 | sprintf( devs, "ath%d", i ); |
|---|
| 7050 | show_macfilter_if( wp, devs ); |
|---|
| 7051 | char vif[32]; |
|---|
| 7052 | |
|---|
| 7053 | sprintf( vif, "%s_vifs", devs ); |
|---|
| 7054 | char var[80], *next; |
|---|
| 7055 | char *vifs = nvram_safe_get( vif ); |
|---|
| 7056 | |
|---|
| 7057 | if( vifs != NULL ) |
|---|
| 7058 | foreach( var, vifs, next ) |
|---|
| 7059 | { |
|---|
| 7060 | show_macfilter_if( wp, var ); |
|---|
| 7061 | } |
|---|
| 7062 | } |
|---|
| 7063 | |
|---|
| 7064 | #endif |
|---|
| 7065 | } |
|---|
| 7066 | |
|---|
| 7067 | #ifdef HAVE_CHILLI |
|---|
| 7068 | void ej_show_chilliif( webs_t wp, int argc, char_t ** argv ) |
|---|
| 7069 | { |
|---|
| 7070 | websWrite( wp, "<select name=\"chilli_interface\">\n" ); |
|---|
| 7071 | websWrite( wp, "<option value=\"%s\" %s >LAN</option>\n", |
|---|
| 7072 | nvram_safe_get( "lan_ifname" ), |
|---|
| 7073 | nvram_match( "chilli_interface", |
|---|
| 7074 | nvram_safe_get( "lan_ifname" ) ) ? |
|---|
| 7075 | "selected=\"selected\"" : "" ); |
|---|
| 7076 | char *next; |
|---|
| 7077 | char var[80]; |
|---|
| 7078 | char eths[256]; |
|---|
| 7079 | |
|---|
| 7080 | memset( eths, 0, 256 ); |
|---|
| 7081 | getIfLists( eths, 256 ); |
|---|
| 7082 | foreach( var, eths, next ) |
|---|
| 7083 | { |
|---|
| 7084 | if( !strcmp( get_wan_face( ), var ) ) |
|---|
| 7085 | continue; |
|---|
| 7086 | if( !strcmp( nvram_safe_get( "lan_ifname" ), var ) ) |
|---|
| 7087 | continue; |
|---|
| 7088 | websWrite( wp, "<option value=\"%s\" %s >%s</option>\n", var, |
|---|
| 7089 | nvram_match( "chilli_interface", var ) ? "selected" : "", |
|---|
| 7090 | var ); |
|---|
| 7091 | } |
|---|
| 7092 | |
|---|
| 7093 | websWrite( wp, "</select>\n" ); |
|---|
| 7094 | } |
|---|
| 7095 | #endif |
|---|
| 7096 | |
|---|
| 7097 | #ifdef HAVE_RFLOW |
|---|
| 7098 | void ej_show_rflowif( webs_t wp, int argc, char_t ** argv ) |
|---|
| 7099 | { |
|---|
| 7100 | websWrite( wp, "<option value=\"%s\" %s >LAN & WLAN</option>\n", |
|---|
| 7101 | nvram_safe_get( "lan_ifname" ), nvram_match( "rflow_if", |
|---|
| 7102 | nvram_safe_get |
|---|
| 7103 | ( "lan_ifname" ) ) |
|---|
| 7104 | ? "selected=\"selected\"" : "" ); |
|---|
| 7105 | |
|---|
| 7106 | char *lanifs = nvram_safe_get( "lan_ifnames" ); |
|---|
| 7107 | char tmp[128]; |
|---|
| 7108 | char *lanif; |
|---|
| 7109 | |
|---|
| 7110 | if( strlen( lanifs ) != 0 ) |
|---|
| 7111 | { |
|---|
| 7112 | strcpy( tmp, lanifs ); |
|---|
| 7113 | lanif = strtok( tmp, " " ); |
|---|
| 7114 | websWrite( wp, "<option value=\"%s\" %s >LAN</option>\n", |
|---|
| 7115 | lanif, nvram_match( "rflow_if", |
|---|
| 7116 | lanif ) ? "selected=\"selected\"" : |
|---|
| 7117 | "" ); |
|---|
| 7118 | } |
|---|
| 7119 | |
|---|
| 7120 | websWrite( wp, "<option value=\"%s\" %s >WLAN</option>\n", |
|---|
| 7121 | nvram_safe_get( "wl0_ifname" ), nvram_match( "rflow_if", |
|---|
| 7122 | nvram_safe_get |
|---|
| 7123 | ( "wl0_ifname" ) ) |
|---|
| 7124 | ? "selected=\"selected\"" : "" ); |
|---|
| 7125 | |
|---|
| 7126 | char *wanif = nvram_safe_get( "wan_ifname" ); |
|---|
| 7127 | |
|---|
| 7128 | if( strlen( wanif ) != 0 ) |
|---|
| 7129 | { |
|---|
| 7130 | websWrite( wp, "<option value=\"%s\" %s >WAN</option>\n", |
|---|
| 7131 | wanif, nvram_match( "rflow_if", |
|---|
| 7132 | wanif ) ? "selected=\"selected\"" : |
|---|
| 7133 | "" ); |
|---|
| 7134 | } |
|---|
| 7135 | } |
|---|
| 7136 | #endif |
|---|