| 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_RT2880 |
|---|
| 336 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 337 | { |
|---|
| 338 | websWrite( wp, "384" ); |
|---|
| 339 | /* |
|---|
| 340 | * FILE *fp = fopen ("/proc/cpuinfo", "rb"); if (fp == NULL) { websWrite |
|---|
| 341 | * (wp, "unknown"); return; } int cnt = 0; int b = 0; while (b != EOF) { |
|---|
| 342 | * b = getc (fp); if (b == ':') cnt++; if (cnt == 2) { getc (fp); char |
|---|
| 343 | * cpuclk[4]; cpuclk[0] = getc (fp); cpuclk[1] = getc (fp); cpuclk[2] = |
|---|
| 344 | * getc (fp); cpuclk[3] = 0; websWrite (wp, cpuclk); fclose (fp); return; |
|---|
| 345 | * } } |
|---|
| 346 | * |
|---|
| 347 | * fclose (fp); websWrite (wp, "unknown"); |
|---|
| 348 | */ |
|---|
| 349 | return; |
|---|
| 350 | } |
|---|
| 351 | #elif HAVE_XSCALE |
|---|
| 352 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 353 | { |
|---|
| 354 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 355 | |
|---|
| 356 | if( fp == NULL ) |
|---|
| 357 | { |
|---|
| 358 | websWrite( wp, "unknown" ); |
|---|
| 359 | return; |
|---|
| 360 | } |
|---|
| 361 | int cnt = 0; |
|---|
| 362 | int b = 0; |
|---|
| 363 | |
|---|
| 364 | while( b != EOF ) |
|---|
| 365 | { |
|---|
| 366 | b = getc( fp ); |
|---|
| 367 | if( b == ':' ) |
|---|
| 368 | cnt++; |
|---|
| 369 | if( cnt == 2 ) |
|---|
| 370 | { |
|---|
| 371 | getc( fp ); |
|---|
| 372 | char cpuclk[4]; |
|---|
| 373 | |
|---|
| 374 | cpuclk[0] = getc( fp ); |
|---|
| 375 | cpuclk[1] = getc( fp ); |
|---|
| 376 | cpuclk[2] = getc( fp ); |
|---|
| 377 | cpuclk[3] = 0; |
|---|
| 378 | websWrite( wp, cpuclk ); |
|---|
| 379 | fclose( fp ); |
|---|
| 380 | return; |
|---|
| 381 | } |
|---|
| 382 | } |
|---|
| 383 | |
|---|
| 384 | fclose( fp ); |
|---|
| 385 | websWrite( wp, "unknown" ); |
|---|
| 386 | return; |
|---|
| 387 | } |
|---|
| 388 | #elif HAVE_X86 |
|---|
| 389 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 390 | { |
|---|
| 391 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 392 | |
|---|
| 393 | if( fp == NULL ) |
|---|
| 394 | { |
|---|
| 395 | websWrite( wp, "unknown" ); |
|---|
| 396 | return; |
|---|
| 397 | } |
|---|
| 398 | int cnt = 0; |
|---|
| 399 | int b = 0; |
|---|
| 400 | |
|---|
| 401 | while( b != EOF ) |
|---|
| 402 | { |
|---|
| 403 | b = getc( fp ); |
|---|
| 404 | if( b == ':' ) |
|---|
| 405 | cnt++; |
|---|
| 406 | if( cnt == 7 ) |
|---|
| 407 | { |
|---|
| 408 | getc( fp ); |
|---|
| 409 | char cpuclk[32]; |
|---|
| 410 | int i = 0; |
|---|
| 411 | |
|---|
| 412 | b = getc( fp ); |
|---|
| 413 | while( b != 0xa && b != 0xd && b != 0x20 ) |
|---|
| 414 | { |
|---|
| 415 | cpuclk[i++] = b; |
|---|
| 416 | b = getc( fp ); |
|---|
| 417 | } |
|---|
| 418 | cpuclk[i++] = 0; |
|---|
| 419 | websWrite( wp, cpuclk ); |
|---|
| 420 | fclose( fp ); |
|---|
| 421 | return; |
|---|
| 422 | } |
|---|
| 423 | } |
|---|
| 424 | |
|---|
| 425 | fclose( fp ); |
|---|
| 426 | websWrite( wp, "unknown" ); |
|---|
| 427 | return; |
|---|
| 428 | } |
|---|
| 429 | #elif HAVE_MAGICBOX |
|---|
| 430 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 431 | { |
|---|
| 432 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 433 | |
|---|
| 434 | if( fp == NULL ) |
|---|
| 435 | { |
|---|
| 436 | websWrite( wp, "unknown" ); |
|---|
| 437 | return; |
|---|
| 438 | } |
|---|
| 439 | int cnt = 0; |
|---|
| 440 | int b = 0; |
|---|
| 441 | |
|---|
| 442 | while( b != EOF ) |
|---|
| 443 | { |
|---|
| 444 | b = getc( fp ); |
|---|
| 445 | if( b == ':' ) |
|---|
| 446 | cnt++; |
|---|
| 447 | if( cnt == 3 ) |
|---|
| 448 | { |
|---|
| 449 | getc( fp ); |
|---|
| 450 | char cpuclk[4]; |
|---|
| 451 | |
|---|
| 452 | cpuclk[0] = getc( fp ); |
|---|
| 453 | cpuclk[1] = getc( fp ); |
|---|
| 454 | cpuclk[2] = getc( fp ); |
|---|
| 455 | cpuclk[3] = 0; |
|---|
| 456 | websWrite( wp, cpuclk ); |
|---|
| 457 | fclose( fp ); |
|---|
| 458 | return; |
|---|
| 459 | } |
|---|
| 460 | } |
|---|
| 461 | |
|---|
| 462 | fclose( fp ); |
|---|
| 463 | websWrite( wp, "unknown" ); |
|---|
| 464 | return; |
|---|
| 465 | } |
|---|
| 466 | #elif HAVE_FONERA |
|---|
| 467 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 468 | { |
|---|
| 469 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 470 | |
|---|
| 471 | if( fp == NULL ) |
|---|
| 472 | { |
|---|
| 473 | websWrite( wp, "unknown" ); |
|---|
| 474 | return; |
|---|
| 475 | } |
|---|
| 476 | int cnt = 0; |
|---|
| 477 | int b = 0; |
|---|
| 478 | |
|---|
| 479 | while( b != EOF ) |
|---|
| 480 | { |
|---|
| 481 | b = getc( fp ); |
|---|
| 482 | if( b == ':' ) |
|---|
| 483 | cnt++; |
|---|
| 484 | if( cnt == 4 ) |
|---|
| 485 | { |
|---|
| 486 | getc( fp ); |
|---|
| 487 | char cpuclk[4]; |
|---|
| 488 | |
|---|
| 489 | cpuclk[0] = getc( fp ); |
|---|
| 490 | cpuclk[1] = getc( fp ); |
|---|
| 491 | cpuclk[2] = getc( fp ); |
|---|
| 492 | cpuclk[3] = 0; |
|---|
| 493 | websWrite( wp, cpuclk ); |
|---|
| 494 | fclose( fp ); |
|---|
| 495 | return; |
|---|
| 496 | } |
|---|
| 497 | } |
|---|
| 498 | |
|---|
| 499 | fclose( fp ); |
|---|
| 500 | websWrite( wp, "unknown" ); |
|---|
| 501 | return; |
|---|
| 502 | } |
|---|
| 503 | #elif HAVE_ADM5120 |
|---|
| 504 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 505 | { |
|---|
| 506 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 507 | |
|---|
| 508 | if( fp == NULL ) |
|---|
| 509 | { |
|---|
| 510 | websWrite( wp, "unknown" ); |
|---|
| 511 | return; |
|---|
| 512 | } |
|---|
| 513 | int cnt = 0; |
|---|
| 514 | int b = 0; |
|---|
| 515 | |
|---|
| 516 | while( b != EOF ) |
|---|
| 517 | { |
|---|
| 518 | b = getc( fp ); |
|---|
| 519 | if( b == ':' ) |
|---|
| 520 | cnt++; |
|---|
| 521 | if( cnt == 4 ) |
|---|
| 522 | { |
|---|
| 523 | getc( fp ); |
|---|
| 524 | char cpuclk[4]; |
|---|
| 525 | |
|---|
| 526 | cpuclk[0] = getc( fp ); |
|---|
| 527 | cpuclk[1] = getc( fp ); |
|---|
| 528 | cpuclk[2] = getc( fp ); |
|---|
| 529 | cpuclk[3] = 0; |
|---|
| 530 | websWrite( wp, cpuclk ); |
|---|
| 531 | fclose( fp ); |
|---|
| 532 | return; |
|---|
| 533 | } |
|---|
| 534 | } |
|---|
| 535 | |
|---|
| 536 | fclose( fp ); |
|---|
| 537 | websWrite( wp, "unknown" ); |
|---|
| 538 | return; |
|---|
| 539 | } |
|---|
| 540 | #elif HAVE_MERAKI |
|---|
| 541 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 542 | { |
|---|
| 543 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 544 | |
|---|
| 545 | if( fp == NULL ) |
|---|
| 546 | { |
|---|
| 547 | websWrite( wp, "unknown" ); |
|---|
| 548 | return; |
|---|
| 549 | } |
|---|
| 550 | int cnt = 0; |
|---|
| 551 | int b = 0; |
|---|
| 552 | |
|---|
| 553 | while( b != EOF ) |
|---|
| 554 | { |
|---|
| 555 | b = getc( fp ); |
|---|
| 556 | if( b == ':' ) |
|---|
| 557 | cnt++; |
|---|
| 558 | if( cnt == 4 ) |
|---|
| 559 | { |
|---|
| 560 | getc( fp ); |
|---|
| 561 | char cpuclk[4]; |
|---|
| 562 | |
|---|
| 563 | cpuclk[0] = getc( fp ); |
|---|
| 564 | cpuclk[1] = getc( fp ); |
|---|
| 565 | cpuclk[2] = getc( fp ); |
|---|
| 566 | cpuclk[3] = 0; |
|---|
| 567 | websWrite( wp, cpuclk ); |
|---|
| 568 | fclose( fp ); |
|---|
| 569 | return; |
|---|
| 570 | } |
|---|
| 571 | } |
|---|
| 572 | |
|---|
| 573 | fclose( fp ); |
|---|
| 574 | websWrite( wp, "unknown" ); |
|---|
| 575 | return; |
|---|
| 576 | } |
|---|
| 577 | #elif HAVE_LS2 |
|---|
| 578 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 579 | { |
|---|
| 580 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 581 | |
|---|
| 582 | if( fp == NULL ) |
|---|
| 583 | { |
|---|
| 584 | websWrite( wp, "unknown" ); |
|---|
| 585 | return; |
|---|
| 586 | } |
|---|
| 587 | int cnt = 0; |
|---|
| 588 | int b = 0; |
|---|
| 589 | |
|---|
| 590 | while( b != EOF ) |
|---|
| 591 | { |
|---|
| 592 | b = getc( fp ); |
|---|
| 593 | if( b == ':' ) |
|---|
| 594 | cnt++; |
|---|
| 595 | if( cnt == 4 ) |
|---|
| 596 | { |
|---|
| 597 | getc( fp ); |
|---|
| 598 | char cpuclk[4]; |
|---|
| 599 | |
|---|
| 600 | cpuclk[0] = getc( fp ); |
|---|
| 601 | cpuclk[1] = getc( fp ); |
|---|
| 602 | cpuclk[2] = getc( fp ); |
|---|
| 603 | cpuclk[3] = 0; |
|---|
| 604 | websWrite( wp, cpuclk ); |
|---|
| 605 | fclose( fp ); |
|---|
| 606 | return; |
|---|
| 607 | } |
|---|
| 608 | } |
|---|
| 609 | |
|---|
| 610 | fclose( fp ); |
|---|
| 611 | websWrite( wp, "unknown" ); |
|---|
| 612 | return; |
|---|
| 613 | } |
|---|
| 614 | #elif HAVE_LS5 |
|---|
| 615 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 616 | { |
|---|
| 617 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 618 | |
|---|
| 619 | if( fp == NULL ) |
|---|
| 620 | { |
|---|
| 621 | websWrite( wp, "unknown" ); |
|---|
| 622 | return; |
|---|
| 623 | } |
|---|
| 624 | int cnt = 0; |
|---|
| 625 | int b = 0; |
|---|
| 626 | |
|---|
| 627 | while( b != EOF ) |
|---|
| 628 | { |
|---|
| 629 | b = getc( fp ); |
|---|
| 630 | if( b == ':' ) |
|---|
| 631 | cnt++; |
|---|
| 632 | if( cnt == 4 ) |
|---|
| 633 | { |
|---|
| 634 | getc( fp ); |
|---|
| 635 | char cpuclk[4]; |
|---|
| 636 | |
|---|
| 637 | cpuclk[0] = getc( fp ); |
|---|
| 638 | cpuclk[1] = getc( fp ); |
|---|
| 639 | cpuclk[2] = getc( fp ); |
|---|
| 640 | cpuclk[3] = 0; |
|---|
| 641 | websWrite( wp, cpuclk ); |
|---|
| 642 | fclose( fp ); |
|---|
| 643 | return; |
|---|
| 644 | } |
|---|
| 645 | } |
|---|
| 646 | |
|---|
| 647 | fclose( fp ); |
|---|
| 648 | websWrite( wp, "unknown" ); |
|---|
| 649 | return; |
|---|
| 650 | } |
|---|
| 651 | #elif HAVE_WHRAG108 |
|---|
| 652 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 653 | { |
|---|
| 654 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 655 | |
|---|
| 656 | if( fp == NULL ) |
|---|
| 657 | { |
|---|
| 658 | websWrite( wp, "unknown" ); |
|---|
| 659 | return; |
|---|
| 660 | } |
|---|
| 661 | int cnt = 0; |
|---|
| 662 | int b = 0; |
|---|
| 663 | |
|---|
| 664 | while( b != EOF ) |
|---|
| 665 | { |
|---|
| 666 | b = getc( fp ); |
|---|
| 667 | if( b == ':' ) |
|---|
| 668 | cnt++; |
|---|
| 669 | if( cnt == 4 ) |
|---|
| 670 | { |
|---|
| 671 | getc( fp ); |
|---|
| 672 | char cpuclk[4]; |
|---|
| 673 | |
|---|
| 674 | cpuclk[0] = getc( fp ); |
|---|
| 675 | cpuclk[1] = getc( fp ); |
|---|
| 676 | cpuclk[2] = getc( fp ); |
|---|
| 677 | cpuclk[3] = 0; |
|---|
| 678 | websWrite( wp, cpuclk ); |
|---|
| 679 | fclose( fp ); |
|---|
| 680 | return; |
|---|
| 681 | } |
|---|
| 682 | } |
|---|
| 683 | |
|---|
| 684 | fclose( fp ); |
|---|
| 685 | websWrite( wp, "unknown" ); |
|---|
| 686 | return; |
|---|
| 687 | } |
|---|
| 688 | #elif defined(HAVE_PB42) || defined(HAVE_LSX) || defined(HAVE_DANUBE) |
|---|
| 689 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 690 | { |
|---|
| 691 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 692 | |
|---|
| 693 | if( fp == NULL ) |
|---|
| 694 | { |
|---|
| 695 | websWrite( wp, "unknown" ); |
|---|
| 696 | return; |
|---|
| 697 | } |
|---|
| 698 | int cnt = 0; |
|---|
| 699 | int b = 0; |
|---|
| 700 | |
|---|
| 701 | while( b != EOF ) |
|---|
| 702 | { |
|---|
| 703 | b = getc( fp ); |
|---|
| 704 | if( b == ':' ) |
|---|
| 705 | cnt++; |
|---|
| 706 | if( cnt == 5 ) |
|---|
| 707 | { |
|---|
| 708 | getc( fp ); |
|---|
| 709 | char cpuclk[4]; |
|---|
| 710 | |
|---|
| 711 | cpuclk[0] = getc( fp ); |
|---|
| 712 | cpuclk[1] = getc( fp ); |
|---|
| 713 | cpuclk[2] = getc( fp ); |
|---|
| 714 | cpuclk[3] = 0; |
|---|
| 715 | websWrite( wp, cpuclk ); |
|---|
| 716 | fclose( fp ); |
|---|
| 717 | return; |
|---|
| 718 | } |
|---|
| 719 | } |
|---|
| 720 | |
|---|
| 721 | fclose( fp ); |
|---|
| 722 | websWrite( wp, "unknown" ); |
|---|
| 723 | return; |
|---|
| 724 | } |
|---|
| 725 | #elif HAVE_TW6600 |
|---|
| 726 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 727 | { |
|---|
| 728 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 729 | |
|---|
| 730 | if( fp == NULL ) |
|---|
| 731 | { |
|---|
| 732 | websWrite( wp, "unknown" ); |
|---|
| 733 | return; |
|---|
| 734 | } |
|---|
| 735 | int cnt = 0; |
|---|
| 736 | int b = 0; |
|---|
| 737 | |
|---|
| 738 | while( b != EOF ) |
|---|
| 739 | { |
|---|
| 740 | b = getc( fp ); |
|---|
| 741 | if( b == ':' ) |
|---|
| 742 | cnt++; |
|---|
| 743 | if( cnt == 4 ) |
|---|
| 744 | { |
|---|
| 745 | getc( fp ); |
|---|
| 746 | char cpuclk[4]; |
|---|
| 747 | |
|---|
| 748 | cpuclk[0] = getc( fp ); |
|---|
| 749 | cpuclk[1] = getc( fp ); |
|---|
| 750 | cpuclk[2] = getc( fp ); |
|---|
| 751 | cpuclk[3] = 0; |
|---|
| 752 | websWrite( wp, cpuclk ); |
|---|
| 753 | fclose( fp ); |
|---|
| 754 | return; |
|---|
| 755 | } |
|---|
| 756 | } |
|---|
| 757 | |
|---|
| 758 | fclose( fp ); |
|---|
| 759 | websWrite( wp, "unknown" ); |
|---|
| 760 | return; |
|---|
| 761 | } |
|---|
| 762 | #elif HAVE_CA8 |
|---|
| 763 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 764 | { |
|---|
| 765 | FILE *fp = fopen( "/proc/cpuinfo", "rb" ); |
|---|
| 766 | |
|---|
| 767 | if( fp == NULL ) |
|---|
| 768 | { |
|---|
| 769 | websWrite( wp, "unknown" ); |
|---|
| 770 | return; |
|---|
| 771 | } |
|---|
| 772 | int cnt = 0; |
|---|
| 773 | int b = 0; |
|---|
| 774 | |
|---|
| 775 | while( b != EOF ) |
|---|
| 776 | { |
|---|
| 777 | b = getc( fp ); |
|---|
| 778 | if( b == ':' ) |
|---|
| 779 | cnt++; |
|---|
| 780 | if( cnt == 4 ) |
|---|
| 781 | { |
|---|
| 782 | getc( fp ); |
|---|
| 783 | char cpuclk[4]; |
|---|
| 784 | |
|---|
| 785 | cpuclk[0] = getc( fp ); |
|---|
| 786 | cpuclk[1] = getc( fp ); |
|---|
| 787 | cpuclk[2] = getc( fp ); |
|---|
| 788 | cpuclk[3] = 0; |
|---|
| 789 | websWrite( wp, cpuclk ); |
|---|
| 790 | fclose( fp ); |
|---|
| 791 | return; |
|---|
| 792 | } |
|---|
| 793 | } |
|---|
| 794 | |
|---|
| 795 | fclose( fp ); |
|---|
| 796 | websWrite( wp, "unknown" ); |
|---|
| 797 | return; |
|---|
| 798 | } |
|---|
| 799 | |
|---|
| 800 | #else |
|---|
| 801 | |
|---|
| 802 | void ej_get_clkfreq( webs_t wp, int argc, char_t ** argv ) |
|---|
| 803 | { |
|---|
| 804 | char *clk = nvram_get( "clkfreq" ); |
|---|
| 805 | |
|---|
| 806 | if( clk == NULL ) |
|---|
| 807 | { |
|---|
| 808 | if( getcpurev( ) == 0 ) //BCM4710 |
|---|
| 809 | websWrite( wp, "125" ); |
|---|
| 810 | else if( getcpurev( ) == 29 ) //BCM5354 |
|---|
| 811 | websWrite( wp, "240" ); |
|---|
| 812 | else |
|---|
| 813 | websWrite( wp, "unknown" ); |
|---|
| 814 | return; |
|---|
| 815 | } |
|---|
| 816 | char buf[64]; |
|---|
| 817 | |
|---|
| 818 | strcpy( buf, clk ); |
|---|
| 819 | int i = 0; |
|---|
| 820 | |
|---|
| 821 | while( buf[i++] != 0 ) |
|---|
| 822 | { |
|---|
| 823 | if( buf[i] == ',' ) |
|---|
| 824 | buf[i] = 0; |
|---|
| 825 | } |
|---|
| 826 | websWrite( wp, buf ); |
|---|
| 827 | return; |
|---|
| 828 | } |
|---|
| 829 | #endif |
|---|
| 830 | |
|---|
| 831 | void ej_show_cpuinfo( webs_t wp, int argc, char_t ** argv ) |
|---|
| 832 | { |
|---|
| 833 | FILE *fcpu = fopen( "/proc/cpuinfo", "r" ); |
|---|
| 834 | |
|---|
| 835 | if( fcpu == NULL ) |
|---|
| 836 | { |
|---|
| 837 | websWrite( wp, "Not Detected!\n" ); |
|---|
| 838 | return; |
|---|
| 839 | } |
|---|
| 840 | char buf[256]; |
|---|
| 841 | int i; |
|---|
| 842 | |
|---|
| 843 | #ifdef HAVE_MAGICBOX |
|---|
| 844 | int cnt = 0; |
|---|
| 845 | #endif |
|---|
| 846 | #ifdef HAVE_X86 |
|---|
| 847 | int cnt = 0; |
|---|
| 848 | #endif |
|---|
| 849 | for( i = 0; i < 256; i++ ) |
|---|
| 850 | { |
|---|
| 851 | int c = getc( fcpu ); |
|---|
| 852 | |
|---|
| 853 | if( c == EOF ) |
|---|
| 854 | { |
|---|
| 855 | websWrite( wp, "Not Detected!\n" ); |
|---|
| 856 | fclose( fcpu ); |
|---|
| 857 | return; |
|---|
| 858 | } |
|---|
| 859 | if( c == ':' ) |
|---|
| 860 | #ifdef HAVE_MAGICBOX |
|---|
| 861 | cnt++; |
|---|
| 862 | if( cnt == 2 ) |
|---|
| 863 | break; |
|---|
| 864 | #elif HAVE_X86 |
|---|
| 865 | cnt++; |
|---|
| 866 | if( cnt == 5 ) |
|---|
| 867 | break; |
|---|
| 868 | #else |
|---|
| 869 | break; |
|---|
| 870 | #endif |
|---|
| 871 | } |
|---|
| 872 | getc( fcpu ); |
|---|
| 873 | for( i = 0; i < 256; i++ ) |
|---|
| 874 | { |
|---|
| 875 | int c = getc( fcpu ); |
|---|
| 876 | |
|---|
| 877 | if( c == EOF ) |
|---|
| 878 | { |
|---|
| 879 | websWrite( wp, "Not Detected!\n" ); |
|---|
| 880 | fclose( fcpu ); |
|---|
| 881 | return; |
|---|
| 882 | } |
|---|
| 883 | if( c == 0xa || c == 0xd ) |
|---|
| 884 | break; |
|---|
| 885 | buf[i] = c; |
|---|
| 886 | } |
|---|
| 887 | buf[i] = 0; |
|---|
| 888 | websWrite( wp, buf ); |
|---|
| 889 | fclose( fcpu ); |
|---|
| 890 | return; |
|---|
| 891 | } |
|---|
| 892 | |
|---|
| 893 | #define ASSOCLIST_TMP "/tmp/.wl_assoclist" |
|---|
| 894 | #define RSSI_TMP "/tmp/.rssi" |
|---|
| 895 | #define ASSOCLIST_CMD "wl assoclist" |
|---|
| 896 | #define RSSI_CMD "wl rssi" |
|---|
| 897 | #define NOISE_CMD "wl noise" |
|---|
| 898 | |
|---|
| 899 | void ej_show_wds_subnet( webs_t wp, int argc, char_t ** argv ) |
|---|
| 900 | { |
|---|
| 901 | int index = -1; |
|---|
| 902 | char *interface; |
|---|
| 903 | |
|---|
| 904 | #ifdef FASTWEB |
|---|
| 905 | ejArgs( argc, argv, "%d %s", &index, &interface ); |
|---|
| 906 | #else |
|---|
| 907 | if( ejArgs( argc, argv, "%d %s", &index, &interface ) < 2 ) |
|---|
| 908 | { |
|---|
| 909 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 910 | return; |
|---|
| 911 | } |
|---|
| 912 | #endif |
|---|
| 913 | char br1[32]; |
|---|
| 914 | |
|---|
| 915 | sprintf( br1, "%s_br1_enable", interface ); |
|---|
| 916 | if( nvram_invmatch( br1, "1" ) ) |
|---|
| 917 | return; |
|---|
| 918 | char buf[16]; |
|---|
| 919 | |
|---|
| 920 | sprintf( buf, "%s_wds%d_enable", interface, index ); |
|---|
| 921 | websWrite( wp, |
|---|
| 922 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"2\\\" %s >\" + wds.subnet + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 923 | nvram_selmatch( wp, buf, |
|---|
| 924 | "2" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 925 | return; |
|---|
| 926 | } |
|---|
| 927 | |
|---|
| 928 | #ifdef HAVE_SKYTRON |
|---|
| 929 | void ej_active_wireless2( webs_t wp, int argc, char_t ** argv ) |
|---|
| 930 | { |
|---|
| 931 | int rssi = 0, noise = 0; |
|---|
| 932 | FILE *fp, *fp2; |
|---|
| 933 | char *mode; |
|---|
| 934 | char mac[30]; |
|---|
| 935 | char list[2][30]; |
|---|
| 936 | char line[80]; |
|---|
| 937 | |
|---|
| 938 | unlink( ASSOCLIST_TMP ); |
|---|
| 939 | unlink( RSSI_TMP ); |
|---|
| 940 | |
|---|
| 941 | mode = nvram_safe_get( "wl_mode" ); |
|---|
| 942 | sysprintf( "%s > %s", ASSOCLIST_CMD, ASSOCLIST_TMP ); |
|---|
| 943 | |
|---|
| 944 | int connected = 0; |
|---|
| 945 | |
|---|
| 946 | if( ( fp = fopen( ASSOCLIST_TMP, "r" ) ) ) |
|---|
| 947 | { |
|---|
| 948 | while( fgets( line, sizeof( line ), fp ) != NULL ) |
|---|
| 949 | { |
|---|
| 950 | if( sscanf( line, "%s %s", list[0], mac ) != 2 ) // assoclist |
|---|
| 951 | // 00:11:22:33:44:55 |
|---|
| 952 | continue; |
|---|
| 953 | |
|---|
| 954 | if( strcmp( list[0], "assoclist" ) ) |
|---|
| 955 | break; |
|---|
| 956 | |
|---|
| 957 | rssi = 0; |
|---|
| 958 | noise = 0; |
|---|
| 959 | // get rssi value |
|---|
| 960 | if( strcmp( mode, "ap" ) ) |
|---|
| 961 | sysprintf( "%s > %s", RSSI_CMD, RSSI_TMP ); |
|---|
| 962 | else |
|---|
| 963 | sysprintf( "%s \"%s\" > %s", RSSI_CMD, mac, RSSI_TMP ); |
|---|
| 964 | |
|---|
| 965 | // get noise value if not ap mode |
|---|
| 966 | if( strcmp( mode, "ap" ) ) |
|---|
| 967 | sysprintf( "%s >> %s", NOISE_CMD, RSSI_TMP ); |
|---|
| 968 | |
|---|
| 969 | fp2 = fopen( RSSI_TMP, "r" ); |
|---|
| 970 | if( fgets( line, sizeof( line ), fp2 ) != NULL ) |
|---|
| 971 | { |
|---|
| 972 | |
|---|
| 973 | // get rssi |
|---|
| 974 | if( sscanf( line, "%s %s %d", list[0], list[1], &rssi ) != 3 ) |
|---|
| 975 | continue; |
|---|
| 976 | |
|---|
| 977 | // get noise for client/wet mode |
|---|
| 978 | if( strcmp( mode, "ap" ) && |
|---|
| 979 | fgets( line, sizeof( line ), fp2 ) != NULL && |
|---|
| 980 | sscanf( line, "%s %s %d", list[0], list[1], |
|---|
| 981 | &noise ) != 3 ) |
|---|
| 982 | continue; |
|---|
| 983 | |
|---|
| 984 | fclose( fp2 ); |
|---|
| 985 | } |
|---|
| 986 | if( nvram_match( "maskmac", "1" ) ) |
|---|
| 987 | { |
|---|
| 988 | mac[0] = 'x'; |
|---|
| 989 | mac[1] = 'x'; |
|---|
| 990 | mac[3] = 'x'; |
|---|
| 991 | mac[4] = 'x'; |
|---|
| 992 | mac[6] = 'x'; |
|---|
| 993 | mac[7] = 'x'; |
|---|
| 994 | mac[9] = 'x'; |
|---|
| 995 | mac[10] = 'x'; |
|---|
| 996 | } |
|---|
| 997 | if( strcmp( mode, "ap" ) != 0 ) |
|---|
| 998 | { |
|---|
| 999 | connected = 1; |
|---|
| 1000 | websWrite( wp, "<tr>\n" ); |
|---|
| 1001 | websWrite( wp, |
|---|
| 1002 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\"><b>Verbindungsstatus</b></font></td>\n" ); |
|---|
| 1003 | websWrite( wp, "<td bgcolor=\"#B2B2B2\"></td>\n" ); |
|---|
| 1004 | websWrite( wp, "<td bgcolor=\"#FFFFFF\"></td>\n" ); |
|---|
| 1005 | websWrite( wp, |
|---|
| 1006 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Verbunden</font></td>\n" ); |
|---|
| 1007 | websWrite( wp, "</tr>\n" ); |
|---|
| 1008 | websWrite( wp, "<tr>\n" ); |
|---|
| 1009 | websWrite( wp, |
|---|
| 1010 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Signal</font></td>\n" ); |
|---|
| 1011 | websWrite( wp, "<td bgcolor=\"#B2B2B2\"></td>\n" ); |
|---|
| 1012 | websWrite( wp, "<td bgcolor=\"#FFFFFF\"></td>\n" ); |
|---|
| 1013 | websWrite( wp, |
|---|
| 1014 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">%d dBm</font></td>\n", |
|---|
| 1015 | rssi ); |
|---|
| 1016 | websWrite( wp, "</tr>\n" ); |
|---|
| 1017 | websWrite( wp, "<tr>\n" ); |
|---|
| 1018 | websWrite( wp, |
|---|
| 1019 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Rauschen</font></td>\n" ); |
|---|
| 1020 | websWrite( wp, "<td bgcolor=\"#B2B2B2\"></td>\n" ); |
|---|
| 1021 | websWrite( wp, "<td bgcolor=\"#FFFFFF\"></td>\n" ); |
|---|
| 1022 | websWrite( wp, |
|---|
| 1023 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">%d dBm</font></td>\n", |
|---|
| 1024 | noise ); |
|---|
| 1025 | websWrite( wp, "</tr>\n" ); |
|---|
| 1026 | } |
|---|
| 1027 | } |
|---|
| 1028 | fclose( fp ); |
|---|
| 1029 | } |
|---|
| 1030 | |
|---|
| 1031 | unlink( ASSOCLIST_TMP ); |
|---|
| 1032 | unlink( RSSI_TMP ); |
|---|
| 1033 | if( !connected ) |
|---|
| 1034 | { |
|---|
| 1035 | connected = 1; |
|---|
| 1036 | websWrite( wp, "<tr>\n" ); |
|---|
| 1037 | websWrite( wp, |
|---|
| 1038 | "<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\"><b>Verbindungsstatus</b></font></td>\n" ); |
|---|
| 1039 | websWrite( wp, "<td bgcolor=\"#B2B2B2\"></td>\n" ); |
|---|
| 1040 | websWrite( wp, "<td bgcolor=\"#FFFFFF\"></td>\n" ); |
|---|
| 1041 | websWrite( wp, |
|---|
| 1042 | "<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Nicht Verbunden</font></td>\n" ); |
|---|
| 1043 | websWrite( wp, "</tr>\n" ); |
|---|
| 1044 | |
|---|
| 1045 | } |
|---|
| 1046 | |
|---|
| 1047 | return 0; |
|---|
| 1048 | } |
|---|
| 1049 | #endif |
|---|
| 1050 | |
|---|
| 1051 | void ej_show_paypal( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1052 | { |
|---|
| 1053 | #ifdef HAVE_DDLAN |
|---|
| 1054 | websWrite( wp, |
|---|
| 1055 | "<a href=\"mailto:support@mcdd.de\">support@mcdd.de</a><br />" ); |
|---|
| 1056 | #endif |
|---|
| 1057 | |
|---|
| 1058 | #ifndef CONFIG_BRANDING |
|---|
| 1059 | websWrite( wp, "<a href=\"http://www.dd-wrt.com/\">DD-WRT</a><br />" ); |
|---|
| 1060 | websWrite( wp, |
|---|
| 1061 | "<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\" target=\"_blank\">" ); |
|---|
| 1062 | websWrite( wp, |
|---|
| 1063 | "<input type=\"hidden\" name=\"cmd\" value=\"_xclick\" />" ); |
|---|
| 1064 | websWrite( wp, |
|---|
| 1065 | "<input type=\"hidden\" name=\"business\" value=\"paypal@dd-wrt.com\" />" ); |
|---|
| 1066 | websWrite( wp, |
|---|
| 1067 | "<input type=\"hidden\" name=\"item_name\" value=\"DD-WRT Development Support\" />" ); |
|---|
| 1068 | websWrite( wp, "<input type=\"hidden\" name=\"no_note\" value=\"1\" />" ); |
|---|
| 1069 | websWrite( wp, |
|---|
| 1070 | "<input type=\"hidden\" name=\"currency_code\" value=\"EUR\" />" ); |
|---|
| 1071 | websWrite( wp, "<input type=\"hidden\" name=\"lc\" value=\"en\" />" ); |
|---|
| 1072 | websWrite( wp, "<input type=\"hidden\" name=\"tax\" value=\"0\" />" ); |
|---|
| 1073 | websWrite( wp, |
|---|
| 1074 | "<input type=\"image\" src=\"images/paypal.gif\" name=\"submit\" />" ); |
|---|
| 1075 | websWrite( wp, "</form>" ); |
|---|
| 1076 | websWrite( wp, |
|---|
| 1077 | "<br /><script type=\"text/javascript\">Capture(donate.mb)</script><br />\n" ); |
|---|
| 1078 | websWrite( wp, |
|---|
| 1079 | "<a href=\"https://www.moneybookers.com/app/send.pl\" target=\"_blank\">\n" ); |
|---|
| 1080 | // #ifdef HAVE_MICRO |
|---|
| 1081 | // websWrite (wp, |
|---|
| 1082 | // "<img style=\"border-width: 1px; border-color: #8B8583;\" |
|---|
| 1083 | // src=\"http://www.moneybookers.com/images/banners/88_en_interpayments.gif\" |
|---|
| 1084 | // alt=\"donate thru moneybookers\" />\n"); |
|---|
| 1085 | // #else |
|---|
| 1086 | websWrite( wp, |
|---|
| 1087 | "<img style=\"border-width: 1px; border-color: #8B8583;\" src=\"images/88_en_interpayments.png\" alt=\"donate thru interpayments\" />\n" ); |
|---|
| 1088 | // #endif |
|---|
| 1089 | websWrite( wp, "</a>\n" ); |
|---|
| 1090 | #endif |
|---|
| 1091 | return; |
|---|
| 1092 | } |
|---|
| 1093 | |
|---|
| 1094 | #ifdef HAVE_RADLOCAL |
|---|
| 1095 | |
|---|
| 1096 | void ej_show_iradius_check( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1097 | { |
|---|
| 1098 | char *sln = nvram_safe_get( "iradius_count" ); |
|---|
| 1099 | |
|---|
| 1100 | if( sln == NULL || strlen( sln ) == 0 ) |
|---|
| 1101 | return; |
|---|
| 1102 | int leasenum = atoi( sln ); |
|---|
| 1103 | int i; |
|---|
| 1104 | |
|---|
| 1105 | for( i = 0; i < leasenum; i++ ) |
|---|
| 1106 | { |
|---|
| 1107 | websWrite( wp, "if(F._iradius%d_active)\n", i ); |
|---|
| 1108 | websWrite( wp, "if(F._iradius%d_active.checked == true)\n", i ); |
|---|
| 1109 | websWrite( wp, "F.iradius%d_active.value=1\n", i ); |
|---|
| 1110 | websWrite( wp, "else\n" ); |
|---|
| 1111 | websWrite( wp, "F.iradius%d_active.value=0\n", i ); |
|---|
| 1112 | |
|---|
| 1113 | websWrite( wp, "if(F._iradius%d_delete)\n", i ); |
|---|
| 1114 | websWrite( wp, "if(F._iradius%d_delete.checked == true)\n", i ); |
|---|
| 1115 | websWrite( wp, "F.iradius%d_delete.value=1\n", i ); |
|---|
| 1116 | websWrite( wp, "else\n" ); |
|---|
| 1117 | websWrite( wp, "F.iradius%d_delete.value=0\n", i ); |
|---|
| 1118 | } |
|---|
| 1119 | |
|---|
| 1120 | } |
|---|
| 1121 | void ej_show_iradius( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1122 | { |
|---|
| 1123 | char *sln = nvram_safe_get( "iradius_count" ); |
|---|
| 1124 | |
|---|
| 1125 | if( sln == NULL || strlen( sln ) == 0 ) |
|---|
| 1126 | return; |
|---|
| 1127 | int leasenum = atoi( sln ); |
|---|
| 1128 | |
|---|
| 1129 | if( leasenum == 0 ) |
|---|
| 1130 | return; |
|---|
| 1131 | int i; |
|---|
| 1132 | char username[32]; |
|---|
| 1133 | char *o, *userlist; |
|---|
| 1134 | |
|---|
| 1135 | cprintf( "get collection\n" ); |
|---|
| 1136 | char *u = nvram_get_collection( "iradius" ); |
|---|
| 1137 | |
|---|
| 1138 | cprintf( "collection result %s", u ); |
|---|
| 1139 | if( u != NULL ) |
|---|
| 1140 | { |
|---|
| 1141 | userlist = ( char * )malloc( strlen( u ) + 1 ); |
|---|
| 1142 | strcpy( userlist, u ); |
|---|
| 1143 | free( u ); |
|---|
| 1144 | o = userlist; |
|---|
| 1145 | } |
|---|
| 1146 | else |
|---|
| 1147 | { |
|---|
| 1148 | userlist = NULL; |
|---|
| 1149 | o = NULL; |
|---|
| 1150 | } |
|---|
| 1151 | cprintf( "display = chain\n" ); |
|---|
| 1152 | struct timeval now; |
|---|
| 1153 | |
|---|
| 1154 | gettimeofday( &now, NULL ); |
|---|
| 1155 | for( i = 0; i < leasenum; i++ ) |
|---|
| 1156 | { |
|---|
| 1157 | snprintf( username, 31, "iradius%d_name", i ); |
|---|
| 1158 | char *sep = NULL; |
|---|
| 1159 | |
|---|
| 1160 | if( userlist ) |
|---|
| 1161 | sep = strsep( &userlist, " " ); |
|---|
| 1162 | websWrite( wp, "<tr><td>\n" ); |
|---|
| 1163 | websWrite( wp, "<input name=\"%s\" type=\"hidden\" />", username ); |
|---|
| 1164 | websWrite( wp, |
|---|
| 1165 | "<input name=\"%s\" value=\"%s\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 1166 | username, sep != NULL ? sep : "" ); |
|---|
| 1167 | websWrite( wp, "</td>\n" ); |
|---|
| 1168 | if( userlist ) |
|---|
| 1169 | sep = strsep( &userlist, " " ); |
|---|
| 1170 | |
|---|
| 1171 | char active[32]; |
|---|
| 1172 | |
|---|
| 1173 | snprintf( active, 31, "iradius%d_active", i ); |
|---|
| 1174 | |
|---|
| 1175 | websWrite( wp, "<td>\n" ); |
|---|
| 1176 | websWrite( wp, "<input name=\"%s\" type=\"hidden\" />", active ); |
|---|
| 1177 | websWrite( wp, |
|---|
| 1178 | "<input type=\"checkbox\" value=\"%s\" name=\"_%s\" %s />\n", |
|---|
| 1179 | sep, active, sep != NULL ? strcmp( sep, |
|---|
| 1180 | "1" ) == |
|---|
| 1181 | 0 ? "checked=\"checked\"" : "" : "" ); |
|---|
| 1182 | websWrite( wp, "</td>\n" ); |
|---|
| 1183 | websWrite( wp, "<td>\n" ); |
|---|
| 1184 | if( userlist ) |
|---|
| 1185 | sep = strsep( &userlist, " " ); |
|---|
| 1186 | long t = atol( sep ); |
|---|
| 1187 | |
|---|
| 1188 | if( t != -1 ) |
|---|
| 1189 | { |
|---|
| 1190 | t -= now.tv_sec; |
|---|
| 1191 | t /= 60; |
|---|
| 1192 | } |
|---|
| 1193 | |
|---|
| 1194 | snprintf( active, 31, "iradius%d_lease", i ); |
|---|
| 1195 | char st[32]; |
|---|
| 1196 | |
|---|
| 1197 | if( t >= 0 ) |
|---|
| 1198 | sprintf( st, "%d", t ); |
|---|
| 1199 | else |
|---|
| 1200 | sprintf( st, "over" ); |
|---|
| 1201 | websWrite( wp, "<input type=\"num\" name=\"%s\" value='%s' />\n", |
|---|
| 1202 | active, st ); |
|---|
| 1203 | websWrite( wp, "</td>\n" ); |
|---|
| 1204 | |
|---|
| 1205 | websWrite( wp, "<td>\n" ); |
|---|
| 1206 | snprintf( active, 31, "iradius%d_delete", i ); |
|---|
| 1207 | websWrite( wp, "<input name=\"%s\" type=\"hidden\" />", active ); |
|---|
| 1208 | websWrite( wp, "<input type=\"checkbox\" name=\"_%s\"/>\n", active ); |
|---|
| 1209 | websWrite( wp, "</td></tr>\n" ); |
|---|
| 1210 | } |
|---|
| 1211 | if( o != NULL ) |
|---|
| 1212 | free( o ); |
|---|
| 1213 | return; |
|---|
| 1214 | } |
|---|
| 1215 | |
|---|
| 1216 | #endif |
|---|
| 1217 | |
|---|
| 1218 | #ifdef HAVE_CHILLILOCAL |
|---|
| 1219 | |
|---|
| 1220 | void ej_show_userlist( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1221 | { |
|---|
| 1222 | char *sln = nvram_safe_get( "fon_usernames" ); |
|---|
| 1223 | |
|---|
| 1224 | if( sln == NULL || strlen( sln ) == 0 ) |
|---|
| 1225 | return; |
|---|
| 1226 | int leasenum = atoi( sln ); |
|---|
| 1227 | |
|---|
| 1228 | if( leasenum == 0 ) |
|---|
| 1229 | return; |
|---|
| 1230 | int i; |
|---|
| 1231 | char username[32]; |
|---|
| 1232 | char password[32]; |
|---|
| 1233 | char *u = nvram_safe_get( "fon_userlist" ); |
|---|
| 1234 | char *userlist = ( char * )malloc( strlen( u ) + 1 ); |
|---|
| 1235 | |
|---|
| 1236 | strcpy( userlist, u ); |
|---|
| 1237 | char *o = userlist; |
|---|
| 1238 | |
|---|
| 1239 | for( i = 0; i < leasenum; i++ ) |
|---|
| 1240 | { |
|---|
| 1241 | snprintf( username, 31, "fon_user%d_name", i ); |
|---|
| 1242 | char *sep = strsep( &userlist, "=" ); |
|---|
| 1243 | |
|---|
| 1244 | websWrite( wp, "<tr><td>\n" ); |
|---|
| 1245 | websWrite( wp, |
|---|
| 1246 | "<input name=\"%s\" value=\"%s\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 1247 | username, sep != NULL ? sep : "" ); |
|---|
| 1248 | websWrite( wp, "</td>\n" ); |
|---|
| 1249 | sep = strsep( &userlist, " " ); |
|---|
| 1250 | snprintf( password, 31, "fon_user%d_password", i ); |
|---|
| 1251 | websWrite( wp, "<td>\n" ); |
|---|
| 1252 | websWrite( wp, |
|---|
| 1253 | "<input type=\"password\" name=\"%s\" value=\"blahblahblah\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 1254 | password ); |
|---|
| 1255 | websWrite( wp, "</td></tr>\n" ); |
|---|
| 1256 | } |
|---|
| 1257 | free( o ); |
|---|
| 1258 | return; |
|---|
| 1259 | } |
|---|
| 1260 | |
|---|
| 1261 | #endif |
|---|
| 1262 | |
|---|
| 1263 | void ej_show_staticleases( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1264 | { |
|---|
| 1265 | int i; |
|---|
| 1266 | |
|---|
| 1267 | // cprintf("get static leasenum"); |
|---|
| 1268 | |
|---|
| 1269 | char *sln = nvram_safe_get( "static_leasenum" ); |
|---|
| 1270 | |
|---|
| 1271 | // cprintf("check null"); |
|---|
| 1272 | if( sln == NULL || strlen( sln ) == 0 ) |
|---|
| 1273 | return; |
|---|
| 1274 | // cprintf("atoi"); |
|---|
| 1275 | |
|---|
| 1276 | int leasenum = atoi( sln ); |
|---|
| 1277 | |
|---|
| 1278 | // cprintf("leasenum==0"); |
|---|
| 1279 | if( leasenum == 0 ) |
|---|
| 1280 | return; |
|---|
| 1281 | // cprintf("get leases"); |
|---|
| 1282 | char *nvleases = nvram_safe_get( "static_leases" ); |
|---|
| 1283 | char *leases = ( char * )malloc( strlen( nvleases ) + 1 ); |
|---|
| 1284 | char *originalpointer = leases; // strsep destroys the pointer by |
|---|
| 1285 | |
|---|
| 1286 | // moving it |
|---|
| 1287 | strcpy( leases, nvleases ); |
|---|
| 1288 | for( i = 0; i < leasenum; i++ ) |
|---|
| 1289 | { |
|---|
| 1290 | char *sep = strsep( &leases, "=" ); |
|---|
| 1291 | |
|---|
| 1292 | websWrite( wp, |
|---|
| 1293 | "<tr><td><input name=\"lease%d_hwaddr\" value=\"%s\" size=\"18\" maxlength=\"18\" onblur=\"valid_name(this,share.mac,SPACE_NO)\" /></td>", |
|---|
| 1294 | i, sep != NULL ? sep : "" ); |
|---|
| 1295 | sep = strsep( &leases, "=" ); |
|---|
| 1296 | websWrite( wp, |
|---|
| 1297 | "<td><input name=\"lease%d_hostname\" value=\"%s\" size=\"24\" maxlength=\"24\" onblur=\"valid_name(this,share.hostname,SPACE_NO)\" /></td>", |
|---|
| 1298 | i, sep != NULL ? sep : "" ); |
|---|
| 1299 | sep = strsep( &leases, " " ); |
|---|
| 1300 | websWrite( wp, |
|---|
| 1301 | "<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", |
|---|
| 1302 | i, sep != NULL ? sep : "" ); |
|---|
| 1303 | } |
|---|
| 1304 | free( originalpointer ); |
|---|
| 1305 | return; |
|---|
| 1306 | } |
|---|
| 1307 | |
|---|
| 1308 | void ej_show_control( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1309 | { |
|---|
| 1310 | #ifdef CONFIG_BRANDING |
|---|
| 1311 | websWrite( wp, "Control Panel" ); |
|---|
| 1312 | #else |
|---|
| 1313 | websWrite( wp, "DD-WRT Control Panel" ); |
|---|
| 1314 | #endif |
|---|
| 1315 | return; |
|---|
| 1316 | } |
|---|
| 1317 | |
|---|
| 1318 | #ifndef HAVE_AQOS |
|---|
| 1319 | void ej_show_default_level( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1320 | { |
|---|
| 1321 | return; |
|---|
| 1322 | } |
|---|
| 1323 | |
|---|
| 1324 | #else |
|---|
| 1325 | void ej_show_default_level( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1326 | { |
|---|
| 1327 | websWrite( wp, "<fieldset>\n" ); |
|---|
| 1328 | websWrite( wp, |
|---|
| 1329 | "<legend><script type=\"text/javascript\">Capture(qos.legend6)</script></legend>\n" ); |
|---|
| 1330 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1331 | websWrite( wp, |
|---|
| 1332 | "<div class=\"label\"><script type=\"text/javascript\">Capture(qos.bandwidth)</script> Up</div>\n" ); |
|---|
| 1333 | websWrite( wp, |
|---|
| 1334 | "<input type=\"num\" name=\"default_uplevel\" size=\"6\" value=\"%s\" /> Down\n", |
|---|
| 1335 | nvram_safe_get( "default_uplevel" ) ); |
|---|
| 1336 | websWrite( wp, |
|---|
| 1337 | "<input type=\"num\" name=\"default_downlevel\" size=\"6\" value=\"%s\" />\n", |
|---|
| 1338 | nvram_safe_get( "default_downlevel" ) ); |
|---|
| 1339 | websWrite( wp, "</div>\n" ); |
|---|
| 1340 | websWrite( wp, "</fieldset><br />\n" ); |
|---|
| 1341 | return; |
|---|
| 1342 | } |
|---|
| 1343 | #endif |
|---|
| 1344 | |
|---|
| 1345 | #ifndef HAVE_MSSID |
|---|
| 1346 | |
|---|
| 1347 | char *selmatch( char *var, char *is, char *ret ) |
|---|
| 1348 | { |
|---|
| 1349 | if( nvram_match( var, is ) ) |
|---|
| 1350 | return ret; |
|---|
| 1351 | return ""; |
|---|
| 1352 | } |
|---|
| 1353 | |
|---|
| 1354 | void ej_show_security( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1355 | { |
|---|
| 1356 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1357 | websWrite( wp, |
|---|
| 1358 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.secmode)</script></div>\n" ); |
|---|
| 1359 | websWrite( wp, |
|---|
| 1360 | "<select name=\"security_mode\" onchange=\"SelMode('security_mode',this.form.security_mode.selectedIndex,this.form)\">\n" ); |
|---|
| 1361 | websWrite( wp, |
|---|
| 1362 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"disabled\\\" %s >\" + share.disabled + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 1363 | selmatch( "security_mode", "disabled", |
|---|
| 1364 | "selected=\\\"selected\\\"" ) ); |
|---|
| 1365 | websWrite( wp, "<option value=\"psk\" %s>WPA Personal</option>\n", |
|---|
| 1366 | selmatch( "security_mode", "psk", "selected=\"selected\"" ) ); |
|---|
| 1367 | websWrite( wp, "<option value=\"wpa\" %s>WPA Enterprise</option>\n", |
|---|
| 1368 | selmatch( "security_mode", "wpa", "selected=\"selected\"" ) ); |
|---|
| 1369 | 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 |
|---|
| 1370 | // 10/04/06 |
|---|
| 1371 | // : |
|---|
| 1372 | // if |
|---|
| 1373 | // wireless |
|---|
| 1374 | // client |
|---|
| 1375 | // bridge |
|---|
| 1376 | // mode |
|---|
| 1377 | // selected |
|---|
| 1378 | // or |
|---|
| 1379 | // WDS |
|---|
| 1380 | // activated |
|---|
| 1381 | // => |
|---|
| 1382 | // we |
|---|
| 1383 | // don't |
|---|
| 1384 | // display |
|---|
| 1385 | // WPA2 |
|---|
| 1386 | // security |
|---|
| 1387 | // modes |
|---|
| 1388 | { |
|---|
| 1389 | websWrite( wp, |
|---|
| 1390 | "<option value=\"psk2\" %s>WPA2 Personal</option>\n", |
|---|
| 1391 | selmatch( "security_mode", "psk2", "selected" ) ); |
|---|
| 1392 | websWrite( wp, "<option value=\"wpa2\" %s>WPA2 Enterprise</option>\n", |
|---|
| 1393 | selmatch( "security_mode", "wpa2", |
|---|
| 1394 | "selected=\"selected\"" ) ); |
|---|
| 1395 | } |
|---|
| 1396 | websWrite( wp, |
|---|
| 1397 | "<option value=\"psk psk2\" %s>WPA2 Personal Mixed</option>\n", |
|---|
| 1398 | selmatch( "security_mode", "psk psk2", "selected" ) ); |
|---|
| 1399 | websWrite( wp, |
|---|
| 1400 | "<option value=\"wpa wpa2\" %s>WPA2 Enterprise Mixed</option>\n", |
|---|
| 1401 | selmatch( "security_mode", "wpa wpa2", |
|---|
| 1402 | "selected=\"selected\"" ) ); |
|---|
| 1403 | websWrite( wp, "<option value=\"radius\" %s>RADIUS</option>\n", |
|---|
| 1404 | selmatch( "security_mode", "radius", |
|---|
| 1405 | "selected=\"selected\"" ) ); |
|---|
| 1406 | websWrite( wp, "<option value=\"wep\" %s>WEP</option></select>\n", |
|---|
| 1407 | selmatch( "security_mode", "wep", "selected=\"selected\"" ) ); |
|---|
| 1408 | websWrite( wp, "</div>\n" ); |
|---|
| 1409 | ej_show_wpa_setting( wp, argc, argv ); |
|---|
| 1410 | return; |
|---|
| 1411 | } |
|---|
| 1412 | #else |
|---|
| 1413 | #ifdef HAVE_MADWIFI |
|---|
| 1414 | struct wifi_channels |
|---|
| 1415 | { |
|---|
| 1416 | int channel; |
|---|
| 1417 | int freq; |
|---|
| 1418 | int noise}; |
|---|
| 1419 | extern struct wifi_channels *list_channels( char *devnr ); |
|---|
| 1420 | |
|---|
| 1421 | // extern int getchannelcount (void); |
|---|
| 1422 | extern int getdevicecount( void ); |
|---|
| 1423 | #endif |
|---|
| 1424 | |
|---|
| 1425 | char *selmatch( char *var, char *is, char *ret ) |
|---|
| 1426 | { |
|---|
| 1427 | if( nvram_match( var, is ) ) |
|---|
| 1428 | return ret; |
|---|
| 1429 | return ""; |
|---|
| 1430 | } |
|---|
| 1431 | |
|---|
| 1432 | static void |
|---|
| 1433 | show_security_prefix( webs_t wp, int argc, char_t ** argv, char *prefix, |
|---|
| 1434 | int primary ) |
|---|
| 1435 | { |
|---|
| 1436 | char var[80]; |
|---|
| 1437 | char sta[80]; |
|---|
| 1438 | |
|---|
| 1439 | // char p2[80]; |
|---|
| 1440 | cprintf( "show security prefix\n" ); |
|---|
| 1441 | sprintf( var, "%s_security_mode", prefix ); |
|---|
| 1442 | // strcpy(p2,prefix); |
|---|
| 1443 | // rep(p2,'X','.'); |
|---|
| 1444 | // websWrite (wp, "<input type=\"hidden\" |
|---|
| 1445 | // name=\"%s_security_mode\"/>\n",p2); |
|---|
| 1446 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1447 | websWrite( wp, |
|---|
| 1448 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.secmode)</script></div>\n" ); |
|---|
| 1449 | websWrite( wp, |
|---|
| 1450 | "<select name=\"%s_security_mode\" onchange=\"SelMode('%s_security_mode',this.form.%s_security_mode.selectedIndex,this.form)\">\n", |
|---|
| 1451 | prefix, prefix, prefix ); |
|---|
| 1452 | websWrite( wp, |
|---|
| 1453 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"disabled\\\" %s >\" + share.disabled + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 1454 | selmatch( var, "disabled", "selected=\\\"selected\\\"" ) ); |
|---|
| 1455 | websWrite( wp, "<option value=\"psk\" %s>WPA Personal</option>\n", |
|---|
| 1456 | selmatch( var, "psk", "selected=\"selected\"" ) ); |
|---|
| 1457 | sprintf( sta, "%s_mode", prefix ); |
|---|
| 1458 | if( !primary || nvram_match( sta, "ap" ) || nvram_match( sta, "wdsap" ) ) |
|---|
| 1459 | { |
|---|
| 1460 | websWrite( wp, "<option value=\"wpa\" %s>WPA Enterprise</option>\n", |
|---|
| 1461 | selmatch( var, "wpa", "selected=\"selected\"" ) ); |
|---|
| 1462 | } |
|---|
| 1463 | websWrite( wp, |
|---|
| 1464 | "<option value=\"psk2\" %s>WPA2 Personal</option>\n", |
|---|
| 1465 | selmatch( var, "psk2", "selected=\"selected\"" ) ); |
|---|
| 1466 | if( !primary || nvram_match( sta, "ap" ) || nvram_match( sta, "wdsap" ) ) |
|---|
| 1467 | { |
|---|
| 1468 | websWrite( wp, "<option value=\"wpa2\" %s>WPA2 Enterprise</option>\n", |
|---|
| 1469 | selmatch( var, "wpa2", "selected=\"selected\"" ) ); |
|---|
| 1470 | } |
|---|
| 1471 | websWrite( wp, |
|---|
| 1472 | "<option value=\"psk psk2\" %s>WPA2 Personal Mixed</option>\n", |
|---|
| 1473 | selmatch( var, "psk psk2", "selected=\"selected\"" ) ); |
|---|
| 1474 | if( !primary || nvram_match( sta, "ap" ) || nvram_match( sta, "wdsap" ) ) |
|---|
| 1475 | { |
|---|
| 1476 | websWrite( wp, |
|---|
| 1477 | "<option value=\"wpa wpa2\" %s>WPA2 Enterprise Mixed</option>\n", |
|---|
| 1478 | selmatch( var, "wpa wpa2", "selected=\"selected\"" ) ); |
|---|
| 1479 | |
|---|
| 1480 | websWrite( wp, "<option value=\"radius\" %s>RADIUS</option>\n", |
|---|
| 1481 | selmatch( var, "radius", "selected=\"selected\"" ) ); |
|---|
| 1482 | } |
|---|
| 1483 | |
|---|
| 1484 | websWrite( wp, "<option value=\"wep\" %s>WEP</option>\n", |
|---|
| 1485 | selmatch( var, "wep", "selected=\"selected\"" ) ); |
|---|
| 1486 | #ifdef HAVE_WPA_SUPPLICANT |
|---|
| 1487 | #ifndef HAVE_MICRO |
|---|
| 1488 | if( !primary || nvram_match( sta, "sta" ) || nvram_match( sta, "wdssta" ) |
|---|
| 1489 | || nvram_match( sta, "apsta" ) || nvram_match( sta, "wet" ) ) |
|---|
| 1490 | { |
|---|
| 1491 | websWrite( wp, "<option value=\"8021X\" %s>802.1x</option>\n", |
|---|
| 1492 | selmatch( var, "8021X", "selected=\"selected\"" ) ); |
|---|
| 1493 | } |
|---|
| 1494 | #endif |
|---|
| 1495 | #endif |
|---|
| 1496 | |
|---|
| 1497 | websWrite( wp, "</select></div>\n" ); |
|---|
| 1498 | rep( prefix, 'X', '.' ); |
|---|
| 1499 | cprintf( "ej show wpa\n" ); |
|---|
| 1500 | ej_show_wpa_setting( wp, argc, argv, prefix ); |
|---|
| 1501 | |
|---|
| 1502 | } |
|---|
| 1503 | |
|---|
| 1504 | static void |
|---|
| 1505 | ej_show_security_single( webs_t wp, int argc, char_t ** argv, char *prefix ) |
|---|
| 1506 | { |
|---|
| 1507 | char *next; |
|---|
| 1508 | char var[80]; |
|---|
| 1509 | char ssid[80]; |
|---|
| 1510 | char mac[16]; |
|---|
| 1511 | |
|---|
| 1512 | sprintf( mac, "%s_hwaddr", prefix ); |
|---|
| 1513 | char *vifs = nvram_nget( "%s_vifs", prefix ); |
|---|
| 1514 | |
|---|
| 1515 | if( vifs == NULL ) |
|---|
| 1516 | return; |
|---|
| 1517 | sprintf( ssid, "%s_ssid", prefix ); |
|---|
| 1518 | websWrite( wp, |
|---|
| 1519 | "<h2><script type=\"text/javascript\">Capture(wpa.h2)</script> %s</h2>\n", |
|---|
| 1520 | prefix ); |
|---|
| 1521 | websWrite( wp, "<fieldset>\n" ); |
|---|
| 1522 | // cprintf("getting %s %s\n",ssid,nvram_safe_get(ssid)); |
|---|
| 1523 | websWrite( wp, |
|---|
| 1524 | "<legend><script type=\"text/javascript\">Capture(share.pintrface)</script> %s SSID [", |
|---|
| 1525 | prefix ); |
|---|
| 1526 | tf_webWriteESCNV( wp, ssid ); // fix for broken html page if ssid |
|---|
| 1527 | // contains html tag |
|---|
| 1528 | websWrite( wp, "] HWAddr [%s]</legend>\n", nvram_safe_get( mac ) ); |
|---|
| 1529 | show_security_prefix( wp, argc, argv, prefix, 1 ); |
|---|
| 1530 | websWrite( wp, "</fieldset>\n<br />\n" ); |
|---|
| 1531 | foreach( var, vifs, next ) |
|---|
| 1532 | { |
|---|
| 1533 | sprintf( ssid, "%s_ssid", var ); |
|---|
| 1534 | websWrite( wp, "<fieldset>\n" ); |
|---|
| 1535 | // cprintf("getting %s %s\n", ssid,nvram_safe_get(ssid)); |
|---|
| 1536 | websWrite( wp, |
|---|
| 1537 | "<legend><script type=\"text/javascript\">Capture(share.vintrface)</script> %s SSID [", |
|---|
| 1538 | var ); |
|---|
| 1539 | tf_webWriteESCNV( wp, ssid ); // fix for broken html page if ssid |
|---|
| 1540 | // contains html tag |
|---|
| 1541 | websWrite( wp, "]</legend>\n" ); |
|---|
| 1542 | rep( var, '.', 'X' ); |
|---|
| 1543 | show_security_prefix( wp, argc, argv, var, 0 ); |
|---|
| 1544 | websWrite( wp, "</fieldset>\n<br />\n" ); |
|---|
| 1545 | } |
|---|
| 1546 | |
|---|
| 1547 | } |
|---|
| 1548 | |
|---|
| 1549 | void ej_show_security( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1550 | { |
|---|
| 1551 | #ifndef HAVE_MADWIFI |
|---|
| 1552 | int c = get_wl_instances( ); |
|---|
| 1553 | int i; |
|---|
| 1554 | |
|---|
| 1555 | for( i = 0; i < c; i++ ) |
|---|
| 1556 | { |
|---|
| 1557 | char buf[16]; |
|---|
| 1558 | |
|---|
| 1559 | sprintf( buf, "wl%d", i ); |
|---|
| 1560 | ej_show_security_single( wp, argc, argv, buf ); |
|---|
| 1561 | } |
|---|
| 1562 | return; |
|---|
| 1563 | #else |
|---|
| 1564 | int c = getdevicecount( ); |
|---|
| 1565 | int i; |
|---|
| 1566 | |
|---|
| 1567 | for( i = 0; i < c; i++ ) |
|---|
| 1568 | { |
|---|
| 1569 | char buf[16]; |
|---|
| 1570 | |
|---|
| 1571 | sprintf( buf, "ath%d", i ); |
|---|
| 1572 | ej_show_security_single( wp, argc, argv, buf ); |
|---|
| 1573 | } |
|---|
| 1574 | return; |
|---|
| 1575 | #endif |
|---|
| 1576 | } |
|---|
| 1577 | |
|---|
| 1578 | #endif |
|---|
| 1579 | |
|---|
| 1580 | void ej_show_dhcpd_settings( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1581 | { |
|---|
| 1582 | int i; |
|---|
| 1583 | |
|---|
| 1584 | if( nvram_match( "wl0_mode", "wet" ) ) // dhcpd settings disabled in |
|---|
| 1585 | // client bridge mode, so we |
|---|
| 1586 | // wont display it |
|---|
| 1587 | return; |
|---|
| 1588 | if( nvram_match( "wl0_mode", "apstawet" ) ) // dhcpd settings disabled in |
|---|
| 1589 | // client bridge mode, so we |
|---|
| 1590 | // wont display it |
|---|
| 1591 | return; |
|---|
| 1592 | websWrite( wp, |
|---|
| 1593 | "<fieldset><legend><script type=\"text/javascript\">Capture(idx.dhcp_legend)</script></legend>\n" ); |
|---|
| 1594 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1595 | websWrite( wp, |
|---|
| 1596 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_type)</script></div>\n" ); |
|---|
| 1597 | websWrite( wp, |
|---|
| 1598 | "<select class=\"num\" size=\"1\" name=\"dhcpfwd_enable\" onchange=SelDHCPFWD(this.form.dhcpfwd_enable.selectedIndex,this.form)>\n" ); |
|---|
| 1599 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 1600 | websWrite( wp, |
|---|
| 1601 | "document.write(\"<option value=\\\"0\\\" %s >\" + idx.dhcp_srv + \"</option>\");\n", |
|---|
| 1602 | nvram_match( "dhcpfwd_enable", |
|---|
| 1603 | "0" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 1604 | websWrite( wp, |
|---|
| 1605 | "document.write(\"<option value=\\\"1\\\" %s >\" + idx.dhcp_fwd + \"</option>\");\n", |
|---|
| 1606 | nvram_match( "dhcpfwd_enable", |
|---|
| 1607 | "1" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 1608 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 1609 | websWrite( wp, "</select>\n" ); |
|---|
| 1610 | websWrite( wp, "</div>\n" ); |
|---|
| 1611 | if( nvram_match( "dhcpfwd_enable", "1" ) ) |
|---|
| 1612 | { |
|---|
| 1613 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1614 | websWrite( wp, |
|---|
| 1615 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_srv)</script></div>\n" ); |
|---|
| 1616 | char *ipfwd = nvram_safe_get( "dhcpfwd_ip" ); |
|---|
| 1617 | |
|---|
| 1618 | websWrite( wp, |
|---|
| 1619 | "<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", |
|---|
| 1620 | get_single_ip( ipfwd, 0 ), get_single_ip( ipfwd, 1 ), |
|---|
| 1621 | get_single_ip( ipfwd, 2 ), get_single_ip( ipfwd, 3 ) ); |
|---|
| 1622 | } |
|---|
| 1623 | else |
|---|
| 1624 | { |
|---|
| 1625 | char buf[20]; |
|---|
| 1626 | |
|---|
| 1627 | prefix_ip_get( "lan_ipaddr", buf, 1 ); |
|---|
| 1628 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1629 | // char *nv = nvram_safe_get ("wan_wins"); |
|---|
| 1630 | websWrite( wp, |
|---|
| 1631 | "<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", |
|---|
| 1632 | nvram_match( "lan_proto", |
|---|
| 1633 | "dhcp" ) ? "checked=\"checked\"" : "" ); |
|---|
| 1634 | websWrite( wp, |
|---|
| 1635 | "<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", |
|---|
| 1636 | nvram_match( "lan_proto", |
|---|
| 1637 | "static" ) ? "checked=\"checked\"" : "" ); |
|---|
| 1638 | websWrite( wp, |
|---|
| 1639 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_start)</script></div>%s", |
|---|
| 1640 | buf ); |
|---|
| 1641 | websWrite( wp, |
|---|
| 1642 | "<input class=\"num\" name=\"dhcp_start\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,1,254,idx.dhcp_start)\" value=\"%s\" />", |
|---|
| 1643 | nvram_safe_get( "dhcp_start" ) ); |
|---|
| 1644 | websWrite( wp, "</div>\n" ); |
|---|
| 1645 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1646 | websWrite( wp, |
|---|
| 1647 | "<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", |
|---|
| 1648 | nvram_safe_get( "dhcp_num" ) ); |
|---|
| 1649 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1650 | websWrite( wp, |
|---|
| 1651 | "<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", |
|---|
| 1652 | nvram_safe_get( "dhcp_lease" ) ); |
|---|
| 1653 | if( nvram_invmatch( "wan_proto", "static" ) ) |
|---|
| 1654 | { |
|---|
| 1655 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1656 | websWrite( wp, |
|---|
| 1657 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 1</div>" ); |
|---|
| 1658 | websWrite( wp, |
|---|
| 1659 | "<input type=\"hidden\" name=\"wan_dns\" value=\"4\" />" ); |
|---|
| 1660 | for( i = 0; i < 4; i++ ) |
|---|
| 1661 | websWrite( wp, |
|---|
| 1662 | "<input class=\"num\" name=\"wan_dns0_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1663 | i, i == 3 ? 254 : 255, get_dns_ip( "wan_dns", 0, |
|---|
| 1664 | i ), |
|---|
| 1665 | i < 3 ? "." : "" ); |
|---|
| 1666 | |
|---|
| 1667 | websWrite( wp, "\n</div>\n<div class=\"setting\">\n" ); |
|---|
| 1668 | websWrite( wp, |
|---|
| 1669 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 2</div>" ); |
|---|
| 1670 | for( i = 0; i < 4; i++ ) |
|---|
| 1671 | websWrite( wp, |
|---|
| 1672 | "<input class=\"num\" name=\"wan_dns1_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1673 | i, i == 3 ? 254 : 255, get_dns_ip( "wan_dns", 1, |
|---|
| 1674 | i ), |
|---|
| 1675 | i < 3 ? "." : "" ); |
|---|
| 1676 | |
|---|
| 1677 | websWrite( wp, "\n</div>\n<div class=\"setting\">\n" ); |
|---|
| 1678 | websWrite( wp, |
|---|
| 1679 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 3</div>" ); |
|---|
| 1680 | for( i = 0; i < 4; i++ ) |
|---|
| 1681 | websWrite( wp, |
|---|
| 1682 | "<input class=\"num\" name=\"wan_dns2_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1683 | i, i == 3 ? 254 : 255, get_dns_ip( "wan_dns", 2, |
|---|
| 1684 | i ), |
|---|
| 1685 | i < 3 ? "." : "" ); |
|---|
| 1686 | websWrite( wp, "\n</div>" ); |
|---|
| 1687 | } |
|---|
| 1688 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1689 | websWrite( wp, "<div class=\"label\">WINS</div>\n" ); |
|---|
| 1690 | websWrite( wp, |
|---|
| 1691 | "<input type=\"hidden\" name=\"wan_wins\" value=\"4\" />\n" ); |
|---|
| 1692 | char *wins = nvram_safe_get( "wan_wins" ); |
|---|
| 1693 | |
|---|
| 1694 | for( i = 0; i < 4; i++ ) |
|---|
| 1695 | { |
|---|
| 1696 | websWrite( wp, |
|---|
| 1697 | "<input class=\"num\" name=\"wan_wins_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,"WINS")\" value=\"%d\" />%s", |
|---|
| 1698 | i, i == 3 ? 254 : 255, get_single_ip( wins, i ), |
|---|
| 1699 | i < 3 ? "." : "" ); |
|---|
| 1700 | } |
|---|
| 1701 | |
|---|
| 1702 | websWrite( wp, "</div>\n<div class=\"setting\">\n" ); |
|---|
| 1703 | websWrite( wp, |
|---|
| 1704 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_dnsmasq)</script></div>\n" ); |
|---|
| 1705 | websWrite( wp, |
|---|
| 1706 | "<input type=\"checkbox\" name=\"_dhcp_dnsmasq\" value=\"1\" onclick=\"setDNSMasq(this.form)\" %s />\n", |
|---|
| 1707 | nvram_match( "dhcp_dnsmasq", |
|---|
| 1708 | "1" ) ? "checked=\"checked\"" : "" ); |
|---|
| 1709 | websWrite( wp, "</div>\n<div class=\"setting\">\n" ); |
|---|
| 1710 | websWrite( wp, |
|---|
| 1711 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dns_dnsmasq)</script></div>\n" ); |
|---|
| 1712 | websWrite( wp, |
|---|
| 1713 | "<input type=\"checkbox\" name=\"_dns_dnsmasq\" value=\"1\" %s />\n", |
|---|
| 1714 | nvram_match( "dns_dnsmasq", |
|---|
| 1715 | "1" ) ? "checked=\"checked\"" : "" ); |
|---|
| 1716 | websWrite( wp, "</div>\n<div class=\"setting\">\n" ); |
|---|
| 1717 | websWrite( wp, |
|---|
| 1718 | "<div class=\"label\"><script type=\"text/javascript\">Capture(idx.auth_dnsmasq)</script></div>\n" ); |
|---|
| 1719 | websWrite( wp, |
|---|
| 1720 | "<input type=\"checkbox\" name=\"_auth_dnsmasq\" value=\"1\" %s />\n", |
|---|
| 1721 | nvram_match( "auth_dnsmasq", |
|---|
| 1722 | "1" ) ? "checked=\"checked\"" : "" ); |
|---|
| 1723 | websWrite( wp, "</div>\n" ); |
|---|
| 1724 | } |
|---|
| 1725 | |
|---|
| 1726 | websWrite( wp, "</fieldset><br />\n" ); |
|---|
| 1727 | return; |
|---|
| 1728 | } |
|---|
| 1729 | |
|---|
| 1730 | #ifdef HAVE_MADWIFI |
|---|
| 1731 | void ej_show_wifiselect( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1732 | { |
|---|
| 1733 | char *next; |
|---|
| 1734 | char var[32]; |
|---|
| 1735 | int count = getifcount( "wifi" ); |
|---|
| 1736 | |
|---|
| 1737 | if( count < 2 ) |
|---|
| 1738 | return; |
|---|
| 1739 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1740 | websWrite( wp, |
|---|
| 1741 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.intrface)</script></div>\n" ); |
|---|
| 1742 | websWrite( wp, |
|---|
| 1743 | "<select name=\"wifi_display\" onchange=\"refresh(this.form)\">\n" ); |
|---|
| 1744 | int i; |
|---|
| 1745 | |
|---|
| 1746 | for( i = 0; i < count; i++ ) |
|---|
| 1747 | { |
|---|
| 1748 | sprintf( var, "ath%d", i ); |
|---|
| 1749 | websWrite( wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 1750 | var, nvram_match( "wifi_display", |
|---|
| 1751 | var ) ? "selected=\"selected\"" : "", |
|---|
| 1752 | var ); |
|---|
| 1753 | char *names = nvram_nget( "ath%d_vifs", i ); |
|---|
| 1754 | |
|---|
| 1755 | foreach( var, names, next ) |
|---|
| 1756 | { |
|---|
| 1757 | websWrite( wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 1758 | var, nvram_match( "wifi_display", |
|---|
| 1759 | var ) ? "selected=\"selected\"" : "", |
|---|
| 1760 | var ); |
|---|
| 1761 | } |
|---|
| 1762 | } |
|---|
| 1763 | websWrite( wp, "</select>\n" ); |
|---|
| 1764 | websWrite( wp, "</div>\n" ); |
|---|
| 1765 | |
|---|
| 1766 | } |
|---|
| 1767 | #else |
|---|
| 1768 | void ej_show_wifiselect( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1769 | { |
|---|
| 1770 | // nothing for now |
|---|
| 1771 | } |
|---|
| 1772 | |
|---|
| 1773 | #endif |
|---|
| 1774 | #if 0 |
|---|
| 1775 | static void showOption( webs_t wp, char *propname, char *nvname ) |
|---|
| 1776 | { |
|---|
| 1777 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1778 | websWrite( wp, |
|---|
| 1779 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n<select name=\"%s\">\n", |
|---|
| 1780 | propname, nvname ); |
|---|
| 1781 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 1782 | websWrite( wp, |
|---|
| 1783 | "document.write(\"<option value=\\\"0\\\" %s >\" + share.disabled + \"</option>\");\n", |
|---|
| 1784 | nvram_default_match( nvname, "0", |
|---|
| 1785 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 1786 | "" ); |
|---|
| 1787 | websWrite( wp, |
|---|
| 1788 | "document.write(\"<option value=\\\"1\\\" %s >\" + share.enabled + \"</option>\");\n", |
|---|
| 1789 | nvram_default_match( nvname, "1", |
|---|
| 1790 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 1791 | "" ); |
|---|
| 1792 | websWrite( wp, "//]]>\n</script>\n</select>\n</div>\n" ); |
|---|
| 1793 | |
|---|
| 1794 | } |
|---|
| 1795 | #endif |
|---|
| 1796 | static void showRadio( webs_t wp, char *propname, char *nvname ) |
|---|
| 1797 | { |
|---|
| 1798 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1799 | websWrite( wp, |
|---|
| 1800 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n", |
|---|
| 1801 | propname ); |
|---|
| 1802 | websWrite( wp, |
|---|
| 1803 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input> \n", |
|---|
| 1804 | nvname, nvram_default_match( nvname, "1", |
|---|
| 1805 | "0" ) ? "checked=\"checked\"" : |
|---|
| 1806 | "" ); |
|---|
| 1807 | websWrite( wp, |
|---|
| 1808 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input> \n", |
|---|
| 1809 | nvname, nvram_default_match( nvname, "0", |
|---|
| 1810 | "0" ) ? "checked=\"checked\"" : |
|---|
| 1811 | "" ); |
|---|
| 1812 | websWrite( wp, "</div>\n" ); |
|---|
| 1813 | } |
|---|
| 1814 | |
|---|
| 1815 | #ifdef HAVE_MADWIFI |
|---|
| 1816 | static void showAutoOption( webs_t wp, char *propname, char *nvname ) |
|---|
| 1817 | { |
|---|
| 1818 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1819 | websWrite( wp, |
|---|
| 1820 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n<select name=\"%s\">\n", |
|---|
| 1821 | propname, nvname ); |
|---|
| 1822 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 1823 | websWrite( wp, |
|---|
| 1824 | "document.write(\"<option value=\\\"-1\\\" %s >\" + share.auto + \"</option>\");\n", |
|---|
| 1825 | nvram_default_match( nvname, "0", |
|---|
| 1826 | "-1" ) ? "selected=\\\"selected\\\"" : |
|---|
| 1827 | "" ); |
|---|
| 1828 | websWrite( wp, |
|---|
| 1829 | "document.write(\"<option value=\\\"1\\\" %s >\" + share.enabled + \"</option>\");\n", |
|---|
| 1830 | nvram_default_match( nvname, "1", |
|---|
| 1831 | "-1" ) ? "selected=\\\"selected\\\"" : |
|---|
| 1832 | "" ); |
|---|
| 1833 | websWrite( wp, |
|---|
| 1834 | "document.write(\"<option value=\\\"0\\\" %s >\" + share.disabled + \"</option>\");\n", |
|---|
| 1835 | nvram_default_match( nvname, "0", |
|---|
| 1836 | "-1" ) ? "selected=\\\"selected\\\"" : |
|---|
| 1837 | "" ); |
|---|
| 1838 | websWrite( wp, "//]]>\n</script>\n</select>\n</div>\n" ); |
|---|
| 1839 | |
|---|
| 1840 | } |
|---|
| 1841 | #endif |
|---|
| 1842 | |
|---|
| 1843 | static void |
|---|
| 1844 | showOptions( webs_t wp, char *propname, char *names, char *select ) |
|---|
| 1845 | { |
|---|
| 1846 | char *next; |
|---|
| 1847 | char var[80]; |
|---|
| 1848 | |
|---|
| 1849 | websWrite( wp, "<select name=\"%s\">\n", propname ); |
|---|
| 1850 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 1851 | foreach( var, names, next ) |
|---|
| 1852 | { |
|---|
| 1853 | websWrite( wp, |
|---|
| 1854 | "document.write(\"<option value=\\\"%s\\\" %s >%s</option>\");\n", |
|---|
| 1855 | var, !strcmp( var, |
|---|
| 1856 | select ) ? "selected=\\\"selected\\\"" : "", |
|---|
| 1857 | var ); |
|---|
| 1858 | } |
|---|
| 1859 | websWrite( wp, "//]]>\n</script>\n</select>\n" ); |
|---|
| 1860 | } |
|---|
| 1861 | |
|---|
| 1862 | #ifdef HAVE_MADWIFI |
|---|
| 1863 | static void |
|---|
| 1864 | showOptionsChoose( webs_t wp, char *propname, char *names, char *select ) |
|---|
| 1865 | { |
|---|
| 1866 | char *next; |
|---|
| 1867 | char var[80]; |
|---|
| 1868 | |
|---|
| 1869 | websWrite( wp, "<select name=\"%s\">\n", propname ); |
|---|
| 1870 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 1871 | websWrite( wp, |
|---|
| 1872 | "document.write(\"<option value=\\\"null\\\" >Please choose...</option>\");\n" ); |
|---|
| 1873 | foreach( var, names, next ) |
|---|
| 1874 | { |
|---|
| 1875 | websWrite( wp, |
|---|
| 1876 | "document.write(\"<option value=\\\"%s\\\" %s >%s</option>\");\n", |
|---|
| 1877 | var, !strcmp( var, |
|---|
| 1878 | select ) ? "selected=\\\"selected\\\"" : "", |
|---|
| 1879 | var ); |
|---|
| 1880 | } |
|---|
| 1881 | websWrite( wp, "//]]>\n</script>\n</select>\n" ); |
|---|
| 1882 | } |
|---|
| 1883 | #endif |
|---|
| 1884 | static void |
|---|
| 1885 | showOptionsLabel( webs_t wp, char *labelname, char *propname, char *names, |
|---|
| 1886 | char *select ) |
|---|
| 1887 | { |
|---|
| 1888 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1889 | websWrite( wp, |
|---|
| 1890 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>", |
|---|
| 1891 | labelname ); |
|---|
| 1892 | showOptions( wp, propname, names, select ); |
|---|
| 1893 | websWrite( wp, "</div>\n" ); |
|---|
| 1894 | |
|---|
| 1895 | } |
|---|
| 1896 | |
|---|
| 1897 | void |
|---|
| 1898 | show_inputlabel( webs_t wp, char *labelname, char *propertyname, |
|---|
| 1899 | int propertysize, char *inputclassname, int inputmaxlength ) |
|---|
| 1900 | { |
|---|
| 1901 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1902 | websWrite( wp, |
|---|
| 1903 | "<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>", |
|---|
| 1904 | labelname ); |
|---|
| 1905 | websWrite( wp, |
|---|
| 1906 | "<input class=\"%s\" size=\"%d\" maxlength=\"%d\" name=\"%s\" value=\"%s\" />\n", |
|---|
| 1907 | inputclassname, propertysize, inputmaxlength, propertyname, |
|---|
| 1908 | nvram_safe_get( propertyname ) ); |
|---|
| 1909 | websWrite( wp, "</div>\n" ); |
|---|
| 1910 | } |
|---|
| 1911 | |
|---|
| 1912 | void |
|---|
| 1913 | show_custominputlabel( webs_t wp, char *labelname, char *propertyname, |
|---|
| 1914 | char *property, int propertysize ) |
|---|
| 1915 | { |
|---|
| 1916 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1917 | websWrite( wp, "<div class=\"label\">%s</div>", labelname ); |
|---|
| 1918 | websWrite( wp, "<input size=\"%d\" name=\"%s\" value=\"%s\" />\n", |
|---|
| 1919 | propertysize, propertyname, property ); |
|---|
| 1920 | websWrite( wp, "</div>\n" ); |
|---|
| 1921 | } |
|---|
| 1922 | |
|---|
| 1923 | void show_legend( webs_t wp, char *labelname, int translate ) |
|---|
| 1924 | { |
|---|
| 1925 | /* |
|---|
| 1926 | * char buf[2]; sprintf(buf,"%d",translate); websWrite (wp, |
|---|
| 1927 | * "<legend>%s%s%s</legend>\n", !strcmp (buf, "1") ? "<script |
|---|
| 1928 | * type=\"text/javascript\">Capture(" : "", labelname, !strcmp (buf, "1") |
|---|
| 1929 | * ? ")</script>" : ""); |
|---|
| 1930 | */ |
|---|
| 1931 | if( translate ) |
|---|
| 1932 | websWrite( wp, |
|---|
| 1933 | "<legend><script type=\"text/javascript\">Capture(%s)</script></legend>\n", |
|---|
| 1934 | labelname ); |
|---|
| 1935 | else |
|---|
| 1936 | websWrite( wp, "<legend>%s</legend>\n", labelname ); |
|---|
| 1937 | |
|---|
| 1938 | } |
|---|
| 1939 | |
|---|
| 1940 | #ifdef HAVE_OLSRD |
|---|
| 1941 | |
|---|
| 1942 | void ej_show_olsrd( webs_t wp, int argc, char_t ** argv ) |
|---|
| 1943 | { |
|---|
| 1944 | char *var = websGetVar( wp, "wk_mode", NULL ); |
|---|
| 1945 | |
|---|
| 1946 | if( var == NULL ) |
|---|
| 1947 | var = nvram_safe_get( "wk_mode" ); |
|---|
| 1948 | if( !strcmp( var, "olsr" ) ) |
|---|
| 1949 | { |
|---|
| 1950 | websWrite( wp, "<fieldset>\n" ); |
|---|
| 1951 | show_legend( wp, "route.olsrd_legend", 1 ); |
|---|
| 1952 | show_inputlabel( wp, "route.olsrd_hna", "olsrd_hna", 32, "num", 32 ); |
|---|
| 1953 | show_inputlabel( wp, "route.olsrd_poll", "olsrd_pollsize", 5, "num", |
|---|
| 1954 | 5 ); |
|---|
| 1955 | showOptionsLabel( wp, "route.olsrd_tc", "olsrd_redundancy", "0 1 2", |
|---|
| 1956 | nvram_default_get( "olsrd_redundancy", "2" ) ); |
|---|
| 1957 | show_inputlabel( wp, "route.olsrd_mpr", "olsrd_coverage", 5, "num", |
|---|
| 1958 | 5 ); |
|---|
| 1959 | showRadio( wp, "route.olsrd_lqfe", "olsrd_lqfisheye" ); |
|---|
| 1960 | show_inputlabel( wp, "route.olsrd_lqag", "olsrd_lqaging", 5, "num", |
|---|
| 1961 | 5 ); |
|---|
| 1962 | |
|---|
| 1963 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1964 | websWrite( wp, |
|---|
| 1965 | "<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_lqdmin)</script></div>" ); |
|---|
| 1966 | websWrite( wp, |
|---|
| 1967 | "<input class=\"num\" size=\"5\" maxlength=\"5\" name=\"olsrd_lqdijkstramin\" onblur=\"olsrd_checkDijkstra(this.form)\" value=\"%s\" />\n", |
|---|
| 1968 | nvram_safe_get( "olsrd_lqdijkstramin" ) ); |
|---|
| 1969 | websWrite( wp, "</div>\n" ); |
|---|
| 1970 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 1971 | websWrite( wp, |
|---|
| 1972 | "<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_lqdmax)</script></div>" ); |
|---|
| 1973 | websWrite( wp, |
|---|
| 1974 | "<input class=\"num\" size=\"5\" maxlength=\"5\" name=\"olsrd_lqdijkstramax\" onblur=\"olsrd_checkDijkstra(this.form)\" value=\"%s\" />\n", |
|---|
| 1975 | nvram_safe_get( "olsrd_lqdijkstramax" ) ); |
|---|
| 1976 | websWrite( wp, "</div>\n" ); |
|---|
| 1977 | |
|---|
| 1978 | showOptionsLabel( wp, "route.olsrd_lqlvl", "olsrd_lqlevel", |
|---|
| 1979 | "0 1 2", nvram_default_get( "olsrd_lqlevel", |
|---|
| 1980 | "2" ) ); |
|---|
| 1981 | showRadio( wp, "route.olsrd_hysteresis", "olsrd_hysteresis" ); |
|---|
| 1982 | char *wordlist = nvram_safe_get( "olsrd_interfaces" ); |
|---|
| 1983 | char *next; |
|---|
| 1984 | char word[128]; |
|---|
| 1985 | int count = 0; |
|---|
| 1986 | |
|---|
| 1987 | foreach( word, wordlist, next ) |
|---|
| 1988 | { |
|---|
| 1989 | char *interface = word; |
|---|
| 1990 | char *hellointerval = interface; |
|---|
| 1991 | |
|---|
| 1992 | strsep( &hellointerval, ">" ); |
|---|
| 1993 | char *hellovaliditytime = hellointerval; |
|---|
| 1994 | |
|---|
| 1995 | strsep( &hellovaliditytime, ">" ); |
|---|
| 1996 | char *tcinterval = hellovaliditytime; |
|---|
| 1997 | |
|---|
| 1998 | strsep( &tcinterval, ">" ); |
|---|
| 1999 | char *tcvaliditytime = tcinterval; |
|---|
| 2000 | |
|---|
| 2001 | strsep( &tcvaliditytime, ">" ); |
|---|
| 2002 | char *midinterval = tcvaliditytime; |
|---|
| 2003 | |
|---|
| 2004 | strsep( &midinterval, ">" ); |
|---|
| 2005 | char *midvaliditytime = midinterval; |
|---|
| 2006 | |
|---|
| 2007 | strsep( &midvaliditytime, ">" ); |
|---|
| 2008 | char *hnainterval = midvaliditytime; |
|---|
| 2009 | |
|---|
| 2010 | strsep( &hnainterval, ">" ); |
|---|
| 2011 | char *hnavaliditytime = hnainterval; |
|---|
| 2012 | |
|---|
| 2013 | strsep( &hnavaliditytime, ">" ); |
|---|
| 2014 | websWrite( wp, "<fieldset>\n" ); |
|---|
| 2015 | show_legend( wp, interface, 0 ); |
|---|
| 2016 | char valuename[32]; |
|---|
| 2017 | |
|---|
| 2018 | sprintf( valuename, "%s_hellointerval", interface ); |
|---|
| 2019 | show_custominputlabel( wp, "Hello Interval", valuename, |
|---|
| 2020 | hellointerval, 5 ); |
|---|
| 2021 | sprintf( valuename, "%s_hellovaliditytime", interface ); |
|---|
| 2022 | show_custominputlabel( wp, "Hello Validity Time", valuename, |
|---|
| 2023 | hellovaliditytime, 5 ); |
|---|
| 2024 | |
|---|
| 2025 | sprintf( valuename, "%s_tcinterval", interface ); |
|---|
| 2026 | show_custominputlabel( wp, "TC Interval", valuename, tcinterval, |
|---|
| 2027 | 5 ); |
|---|
| 2028 | sprintf( valuename, "%s_tcvaliditytime", interface ); |
|---|
| 2029 | show_custominputlabel( wp, "TC Validity Time", valuename, |
|---|
| 2030 | tcvaliditytime, 5 ); |
|---|
| 2031 | |
|---|
| 2032 | sprintf( valuename, "%s_midinterval", interface ); |
|---|
| 2033 | show_custominputlabel( wp, "MID Interval", valuename, midinterval, |
|---|
| 2034 | 5 ); |
|---|
| 2035 | sprintf( valuename, "%s_midvaliditytime", interface ); |
|---|
| 2036 | show_custominputlabel( wp, "MID Validity Time", valuename, |
|---|
| 2037 | midvaliditytime, 5 ); |
|---|
| 2038 | |
|---|
| 2039 | sprintf( valuename, "%s_hnainterval", interface ); |
|---|
| 2040 | show_custominputlabel( wp, "HNA Interval", valuename, hnainterval, |
|---|
| 2041 | 5 ); |
|---|
| 2042 | sprintf( valuename, "%s_hnavaliditytime", interface ); |
|---|
| 2043 | show_custominputlabel( wp, "HNA Validity Time", valuename, |
|---|
| 2044 | hnavaliditytime, 5 ); |
|---|
| 2045 | websWrite( wp, |
|---|
| 2046 | "<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", |
|---|
| 2047 | count ); |
|---|
| 2048 | |
|---|
| 2049 | websWrite( wp, "</fieldset>\n" ); |
|---|
| 2050 | count++; |
|---|
| 2051 | } |
|---|
| 2052 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2053 | websWrite( wp, |
|---|
| 2054 | "<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_newiface)</script></div>\n" ); |
|---|
| 2055 | char buffer[256]; |
|---|
| 2056 | |
|---|
| 2057 | memset( buffer, 0, 256 ); |
|---|
| 2058 | getIfList( buffer, NULL ); |
|---|
| 2059 | showOptions( wp, "olsrd_ifname", buffer, "" ); |
|---|
| 2060 | websWrite( wp, " " ); |
|---|
| 2061 | websWrite( wp, |
|---|
| 2062 | "<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" ); |
|---|
| 2063 | websWrite( wp, "</div>\n" ); |
|---|
| 2064 | websWrite( wp, "</fieldset><br />\n" ); |
|---|
| 2065 | } |
|---|
| 2066 | } |
|---|
| 2067 | #else //!HAVE_OLSRD |
|---|
| 2068 | void ej_show_olsrd( webs_t wp, int argc, char_t ** argv ) |
|---|
| 2069 | { |
|---|
| 2070 | return; |
|---|
| 2071 | } |
|---|
| 2072 | #endif |
|---|
| 2073 | |
|---|
| 2074 | #ifdef HAVE_VLANTAGGING |
|---|
| 2075 | #ifdef HAVE_BONDING |
|---|
| 2076 | |
|---|
| 2077 | void ej_show_bondings( webs_t wp, int argc, char_t ** argv ) |
|---|
| 2078 | { |
|---|
| 2079 | char buffer[256]; |
|---|
| 2080 | char bufferif[512]; |
|---|
| 2081 | char bondnames[256]; |
|---|
| 2082 | int count = 0; |
|---|
| 2083 | static char word[256]; |
|---|
| 2084 | char *next, *wordlist; |
|---|
| 2085 | |
|---|
| 2086 | memset( buffer, 0, 256 ); |
|---|
| 2087 | memset( bondnames, 0, 256 ); |
|---|
| 2088 | memset( bufferif, 0, 512 ); |
|---|
| 2089 | websWrite( wp, "<h2>Bonding</h2>\n" ); |
|---|
| 2090 | websWrite( wp, "<fieldset>\n" ); |
|---|
| 2091 | websWrite( wp, "<legend>Bonding</legend>\n" ); |
|---|
| 2092 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2093 | websWrite( wp, "<div class=\"label\">Bonding Type</div>\n", count ); |
|---|
| 2094 | showOptions( wp, "bonding_type", |
|---|
| 2095 | "balance-rr active-backup balance-xor broadcast 802.3ad balance-tlb balance-alb", |
|---|
| 2096 | nvram_default_get( "bonding_type", "balance-rr" ) ); |
|---|
| 2097 | websWrite( wp, " Bonding Interfaces " ); |
|---|
| 2098 | websWrite( wp, |
|---|
| 2099 | "<input class=\"num\" name=\"bonding_number\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2100 | nvram_default_get( "bonding_number", "1" ) ); |
|---|
| 2101 | websWrite( wp, "</div>\n" ); |
|---|
| 2102 | |
|---|
| 2103 | getIfList( bufferif, "eth" ); |
|---|
| 2104 | int i; |
|---|
| 2105 | |
|---|
| 2106 | #ifdef HAVE_XSCALE |
|---|
| 2107 | memset( buffer, 0, 256 ); |
|---|
| 2108 | getIfList( buffer, "ixp" ); |
|---|
| 2109 | sprintf( bufferif, "%s %s", bufferif, buffer ); |
|---|
| 2110 | #endif |
|---|
| 2111 | memset( buffer, 0, 256 ); |
|---|
| 2112 | getIfList( buffer, "br" ); |
|---|
| 2113 | sprintf( bufferif, "%s %s", bufferif, buffer ); |
|---|
| 2114 | #ifdef HAVE_MADWIFI |
|---|
| 2115 | int c = getifcount( "wifi" ); |
|---|
| 2116 | |
|---|
| 2117 | for( i = 0; i < c; i++ ) |
|---|
| 2118 | { |
|---|
| 2119 | char ath[32]; |
|---|
| 2120 | |
|---|
| 2121 | sprintf( ath, "ath%d_bridged", i ); |
|---|
| 2122 | if( nvram_default_match( ath, "0", "1" ) ) |
|---|
| 2123 | { |
|---|
| 2124 | sprintf( bufferif, "%s ath%d", bufferif, i ); |
|---|
| 2125 | char vifs[32]; |
|---|
| 2126 | |
|---|
| 2127 | sprintf( vifs, "ath%d_vifs", i ); |
|---|
| 2128 | sprintf( bufferif, "%s %s", bufferif, nvram_safe_get( vifs ) ); |
|---|
| 2129 | } |
|---|
| 2130 | } |
|---|
| 2131 | #endif |
|---|
| 2132 | |
|---|
| 2133 | for( i = 0; i < atoi( nvram_safe_get( "bonding_number" ) ); i++ ) |
|---|
| 2134 | { |
|---|
| 2135 | sprintf( bondnames, "%s bond%d", bondnames, i ); |
|---|
| 2136 | } |
|---|
| 2137 | int totalcount = 0; |
|---|
| 2138 | int realcount = atoi( nvram_default_get( "bonding_count", "0" ) ); |
|---|
| 2139 | |
|---|
| 2140 | wordlist = nvram_safe_get( "bondings" ); |
|---|
| 2141 | foreach( word, wordlist, next ) |
|---|
| 2142 | { |
|---|
| 2143 | char *port = word; |
|---|
| 2144 | char *tag = strsep( &port, ">" ); |
|---|
| 2145 | |
|---|
| 2146 | if( !tag || !port ) |
|---|
| 2147 | break; |
|---|
| 2148 | char vlan_name[32]; |
|---|
| 2149 | |
|---|
| 2150 | // sprintf (vlan_name, "%s.%s", tag, port); |
|---|
| 2151 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2152 | websWrite( wp, "<div class=\"label\">Bonding %d Assignment</div>\n", |
|---|
| 2153 | count ); |
|---|
| 2154 | websWrite( wp, " Bond " ); |
|---|
| 2155 | sprintf( vlan_name, "bondingifname%d", count ); |
|---|
| 2156 | showOptions( wp, vlan_name, bondnames, tag ); |
|---|
| 2157 | sprintf( vlan_name, "bondingattach%d", count ); |
|---|
| 2158 | websWrite( wp, " Slave " ); |
|---|
| 2159 | showOptions( wp, vlan_name, bufferif, port ); |
|---|
| 2160 | websWrite( wp, |
|---|
| 2161 | "<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", |
|---|
| 2162 | count ); |
|---|
| 2163 | websWrite( wp, "</div>\n" ); |
|---|
| 2164 | count++; |
|---|
| 2165 | } |
|---|
| 2166 | totalcount = count; |
|---|
| 2167 | for( i = count; i < realcount; i++ ) |
|---|
| 2168 | { |
|---|
| 2169 | char vlan_name[32]; |
|---|
| 2170 | |
|---|
| 2171 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2172 | websWrite( wp, "<div class=\"label\">Bonding %d Interface</div>\n", |
|---|
| 2173 | i ); |
|---|
| 2174 | websWrite( wp, " Bond " ); |
|---|
| 2175 | sprintf( vlan_name, "bondingifname%d", i ); |
|---|
| 2176 | showOptions( wp, vlan_name, bondnames, "" ); |
|---|
| 2177 | sprintf( vlan_name, "bondingattach%d", i ); |
|---|
| 2178 | websWrite( wp, " Slave " ); |
|---|
| 2179 | showOptions( wp, vlan_name, bufferif, "" ); |
|---|
| 2180 | websWrite( wp, |
|---|
| 2181 | "<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", |
|---|
| 2182 | i ); |
|---|
| 2183 | websWrite( wp, "</div>\n" ); |
|---|
| 2184 | totalcount++; |
|---|
| 2185 | } |
|---|
| 2186 | char var[32]; |
|---|
| 2187 | |
|---|
| 2188 | sprintf( var, "%d", totalcount ); |
|---|
| 2189 | nvram_set( "bonding_count", var ); |
|---|
| 2190 | websWrite( wp, |
|---|
| 2191 | "<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" ); |
|---|
| 2192 | websWrite( wp, "</fieldset><br />\n" ); |
|---|
| 2193 | } |
|---|
| 2194 | #else //!HAVE_BONDING |
|---|
| 2195 | void ej_show_bondings( webs_t wp, int argc, char_t ** argv ) |
|---|
| 2196 | { |
|---|
| 2197 | return; |
|---|
| 2198 | } |
|---|
| 2199 | #endif |
|---|
| 2200 | |
|---|
| 2201 | void ej_show_vlantagging( webs_t wp, int argc, char_t ** argv ) |
|---|
| 2202 | { |
|---|
| 2203 | char buffer[256]; |
|---|
| 2204 | int count = 0; |
|---|
| 2205 | static char word[256]; |
|---|
| 2206 | char *next, *wordlist; |
|---|
| 2207 | |
|---|
| 2208 | memset( buffer, 0, 256 ); |
|---|
| 2209 | getIfList( buffer, NULL ); |
|---|
| 2210 | int totalcount = 0; |
|---|
| 2211 | int realcount = atoi( nvram_default_get( "vlan_tagcount", "0" ) ); |
|---|
| 2212 | |
|---|
| 2213 | wordlist = nvram_safe_get( "vlan_tags" ); |
|---|
| 2214 | foreach( word, wordlist, next ) |
|---|
| 2215 | { |
|---|
| 2216 | char *port = word; |
|---|
| 2217 | char *tag = strsep( &port, ">" ); |
|---|
| 2218 | |
|---|
| 2219 | if( !tag || !port ) |
|---|
| 2220 | break; |
|---|
| 2221 | char vlan_name[32]; |
|---|
| 2222 | |
|---|
| 2223 | // sprintf (vlan_name, "%s.%s", tag, port); |
|---|
| 2224 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2225 | websWrite( wp, "<div class=\"label\">VLAN%d Interface</div>\n", |
|---|
| 2226 | count ); |
|---|
| 2227 | sprintf( vlan_name, "vlanifname%d", count ); |
|---|
| 2228 | showOptions( wp, vlan_name, buffer, tag ); |
|---|
| 2229 | sprintf( vlan_name, "vlantag%d", count ); |
|---|
| 2230 | websWrite( wp, " Tag Number " ); |
|---|
| 2231 | websWrite( wp, |
|---|
| 2232 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2233 | vlan_name, port ); |
|---|
| 2234 | websWrite( wp, |
|---|
| 2235 | "<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", |
|---|
| 2236 | count ); |
|---|
| 2237 | websWrite( wp, "</div>\n" ); |
|---|
| 2238 | count++; |
|---|
| 2239 | } |
|---|
| 2240 | totalcount = count; |
|---|
| 2241 | int i; |
|---|
| 2242 | |
|---|
| 2243 | for( i = count; i < realcount; i++ ) |
|---|
| 2244 | { |
|---|
| 2245 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2246 | websWrite( wp, "<div class=\"label\">VLAN%d Interface</div>\n", i ); |
|---|
| 2247 | char vlan_name[32]; |
|---|
| 2248 | |
|---|
| 2249 | sprintf( vlan_name, "vlanifname%d", i ); |
|---|
| 2250 | showOptions( wp, vlan_name, buffer, "" ); |
|---|
| 2251 | sprintf( vlan_name, "vlantag%d", i ); |
|---|
| 2252 | websWrite( wp, " Tag Number " ); |
|---|
| 2253 | websWrite( wp, |
|---|
| 2254 | "<input class=\"num\" name=\"%s\" size=\"5\" value=\"0\" />\n", |
|---|
| 2255 | vlan_name ); |
|---|
| 2256 | websWrite( wp, |
|---|
| 2257 | "<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", |
|---|
| 2258 | i ); |
|---|
| 2259 | websWrite( wp, "</div>\n" ); |
|---|
| 2260 | totalcount++; |
|---|
| 2261 | } |
|---|
| 2262 | char var[32]; |
|---|
| 2263 | |
|---|
| 2264 | sprintf( var, "%d", totalcount ); |
|---|
| 2265 | nvram_set( "vlan_tagcount", var ); |
|---|
| 2266 | websWrite( wp, |
|---|
| 2267 | "<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" ); |
|---|
| 2268 | } |
|---|
| 2269 | |
|---|
| 2270 | void ej_show_mdhcp( webs_t wp, int argc, char_t ** argv ) |
|---|
| 2271 | { |
|---|
| 2272 | char buffer[256]; |
|---|
| 2273 | int count = 0; |
|---|
| 2274 | static char word[256]; |
|---|
| 2275 | char *next, *wordlist; |
|---|
| 2276 | |
|---|
| 2277 | websWrite( wp, "<h2>%s</h2>\n<fieldset>\n", |
|---|
| 2278 | live_translate( "networking.h5" ) ); |
|---|
| 2279 | websWrite( wp, "<legend>%s</legend>\n", |
|---|
| 2280 | live_translate( "networking.legend5" ) ); |
|---|
| 2281 | |
|---|
| 2282 | memset( buffer, 0, 256 ); |
|---|
| 2283 | getIfList( buffer, NULL ); |
|---|
| 2284 | int totalcount = 0; |
|---|
| 2285 | int realcount = atoi( nvram_default_get( "mdhcpd_count", "0" ) ); |
|---|
| 2286 | |
|---|
| 2287 | wordlist = nvram_safe_get( "mdhcpd" ); |
|---|
| 2288 | foreach( word, wordlist, next ) |
|---|
| 2289 | { |
|---|
| 2290 | char *interface = word; |
|---|
| 2291 | char *dhcpon = interface; |
|---|
| 2292 | |
|---|
| 2293 | interface = strsep( &dhcpon, ">" ); |
|---|
| 2294 | char *start = dhcpon; |
|---|
| 2295 | |
|---|
| 2296 | dhcpon = strsep( &start, ">" ); |
|---|
| 2297 | char *max = start; |
|---|
| 2298 | |
|---|
| 2299 | start = strsep( &max, ">" ); |
|---|
| 2300 | char *leasetime = max; |
|---|
| 2301 | |
|---|
| 2302 | max = strsep( &leasetime, ">" ); |
|---|
| 2303 | if( !interface || !start || !dhcpon || !max || !leasetime ) |
|---|
| 2304 | break; |
|---|
| 2305 | char vlan_name[32]; |
|---|
| 2306 | |
|---|
| 2307 | // interface |
|---|
| 2308 | char *ipaddr = nvram_nget( "%s_ipaddr", interface ); |
|---|
| 2309 | char *netmask = nvram_nget( "%s_netmask", interface ); |
|---|
| 2310 | |
|---|
| 2311 | if( strlen( ipaddr ) > 0 && strlen( netmask ) > 0 ) |
|---|
| 2312 | { |
|---|
| 2313 | websWrite( wp, "Interface %s: IP %s/%s\n", interface, ipaddr, |
|---|
| 2314 | netmask ); |
|---|
| 2315 | } |
|---|
| 2316 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2317 | websWrite( wp, "<div class=\"label\">DHCP %d</div>\n", count ); |
|---|
| 2318 | sprintf( vlan_name, "mdhcpifname%d", count ); |
|---|
| 2319 | showOptions( wp, vlan_name, buffer, interface ); |
|---|
| 2320 | // on off |
|---|
| 2321 | sprintf( vlan_name, "mdhcpon%d", count ); |
|---|
| 2322 | showOptions( wp, vlan_name, "On Off", dhcpon ); |
|---|
| 2323 | // start |
|---|
| 2324 | sprintf( vlan_name, "mdhcpstart%d", count ); |
|---|
| 2325 | websWrite( wp, " Start " ); |
|---|
| 2326 | websWrite( wp, |
|---|
| 2327 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2328 | vlan_name, start ); |
|---|
| 2329 | // max |
|---|
| 2330 | sprintf( vlan_name, "mdhcpmax%d", count ); |
|---|
| 2331 | websWrite( wp, " Max " ); |
|---|
| 2332 | websWrite( wp, |
|---|
| 2333 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2334 | vlan_name, max ); |
|---|
| 2335 | sprintf( vlan_name, "mdhcpleasetime%d", count ); |
|---|
| 2336 | websWrite( wp, " Leasetime " ); |
|---|
| 2337 | websWrite( wp, |
|---|
| 2338 | "<input class=\"num\" name=\"%s\" size=\"5\" value=\"%s\" />\n", |
|---|
| 2339 | vlan_name, leasetime ); |
|---|
| 2340 | // |
|---|
| 2341 | websWrite( wp, |
|---|
| 2342 | "<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", |
|---|
| 2343 | count ); |
|---|
| 2344 | websWrite( wp, "</div>\n" ); |
|---|
| 2345 | count++; |
|---|
| 2346 | } |
|---|
| 2347 | totalcount = count; |
|---|
| 2348 | int i; |
|---|
| 2349 | |
|---|
| 2350 | for( i = count; i < realcount; i++ ) |
|---|
| 2351 | { |
|---|
| 2352 | char vlan_name[32]; |
|---|
| 2353 | |
|---|
| 2354 | // sprintf (mdhcp_name, "%s.%s", tag, port); |
|---|
| 2355 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2356 | websWrite( wp, "<div class=\"label\">DHCP %d</div>\n", count ); |
|---|
| 2357 | // interface |
|---|
| 2358 | sprintf( vlan_name, "mdhcpifname%d", count ); |
|---|
| 2359 | showOptions( wp, vlan_name, buffer, "" ); |
|---|
| 2360 | // on off |
|---|
| 2361 | sprintf( vlan_name, "mdhcpon%d", count ); |
|---|
| 2362 | showOptions( wp, vlan_name, "On Off", "" ); |
|---|
| 2363 | // start |
|---|
| 2364 | sprintf( vlan_name, "mdhcpstart%d", count ); |
|---|
| 2365 | websWrite( wp, " Start " ); |
|---|
| 2366 | websWrite( wp, |
|---|
| 2367 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2368 | vlan_name, "100" ); |
|---|
| 2369 | // max |
|---|
| 2370 | sprintf( vlan_name, "mdhcpmax%d", count ); |
|---|
| 2371 | websWrite( wp, " Max " ); |
|---|
| 2372 | websWrite( wp, |
|---|
| 2373 | "<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2374 | vlan_name, "50" ); |
|---|
| 2375 | sprintf( vlan_name, "mdhcpleasetime%d", count ); |
|---|
| 2376 | websWrite( wp, " Leasetime " ); |
|---|
| 2377 | websWrite( wp, |
|---|
| 2378 | "<input class=\"num\" name=\"%s\" size=\"5\" value=\"%s\" />\n", |
|---|
| 2379 | vlan_name, "3600" ); |
|---|
| 2380 | websWrite( wp, |
|---|
| 2381 | "<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", |
|---|
| 2382 | i ); |
|---|
| 2383 | websWrite( wp, "</div>\n" ); |
|---|
| 2384 | totalcount++; |
|---|
| 2385 | } |
|---|
| 2386 | char var[32]; |
|---|
| 2387 | |
|---|
| 2388 | sprintf( var, "%d", totalcount ); |
|---|
| 2389 | nvram_set( "mdhcpd_count", var ); |
|---|
| 2390 | websWrite( wp, |
|---|
| 2391 | "<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" ); |
|---|
| 2392 | websWrite( wp, "</fieldset><br />\n" ); |
|---|
| 2393 | |
|---|
| 2394 | } |
|---|
| 2395 | |
|---|
| 2396 | void ej_show_bridgenames( webs_t wp, int argc, char_t ** argv ) |
|---|
| 2397 | { |
|---|
| 2398 | char buffer[256]; |
|---|
| 2399 | int count = 0; |
|---|
| 2400 | static char word[256]; |
|---|
| 2401 | char *next, *wordlist; |
|---|
| 2402 | |
|---|
| 2403 | memset( buffer, 0, 256 ); |
|---|
| 2404 | getIfList( buffer, NULL ); |
|---|
| 2405 | int realcount = atoi( nvram_default_get( "bridges_count", "0" ) ); |
|---|
| 2406 | |
|---|
| 2407 | wordlist = nvram_safe_get( "bridges" ); |
|---|
| 2408 | foreach( word, wordlist, next ) |
|---|
| 2409 | { |
|---|
| 2410 | |
|---|
| 2411 | char *stp = word; |
|---|
| 2412 | char *bridge = strsep( &stp, ">" ); |
|---|
| 2413 | char *prio = stp; |
|---|
| 2414 | |
|---|
| 2415 | stp = strsep( &prio, ">" ); |
|---|
| 2416 | char *mtu = prio; |
|---|
| 2417 | |
|---|
| 2418 | prio = strsep( &mtu, ">" ); |
|---|
| 2419 | if( !prio ) |
|---|
| 2420 | { |
|---|
| 2421 | prio = mtu; |
|---|
| 2422 | mtu = "1500"; |
|---|
| 2423 | } |
|---|
| 2424 | |
|---|
| 2425 | /* char *stp = word; |
|---|
| 2426 | char *bridge = strsep( &stp, ">" ); |
|---|
| 2427 | char *mtu = stp; |
|---|
| 2428 | char *prio = strsep( &mtu, ">" ); |
|---|
| 2429 | */ |
|---|
| 2430 | if( !bridge || !stp ) |
|---|
| 2431 | break; |
|---|
| 2432 | |
|---|
| 2433 | char vlan_name[32]; |
|---|
| 2434 | |
|---|
| 2435 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2436 | websWrite( wp, "<div class=\"label\">Bridge %d</div>\n", count ); |
|---|
| 2437 | sprintf( vlan_name, "bridgename%d", count ); |
|---|
| 2438 | websWrite( wp, |
|---|
| 2439 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2440 | vlan_name, bridge ); |
|---|
| 2441 | websWrite( wp, " STP " ); |
|---|
| 2442 | sprintf( vlan_name, "bridgestp%d", count ); |
|---|
| 2443 | showOptions( wp, vlan_name, "On Off", stp ); |
|---|
| 2444 | websWrite( wp, " Prio " ); |
|---|
| 2445 | sprintf( vlan_name, "bridgeprio%d", count ); |
|---|
| 2446 | websWrite( wp, |
|---|
| 2447 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2448 | vlan_name, prio != NULL ? prio : "32768" ); |
|---|
| 2449 | websWrite( wp, " MTU " ); |
|---|
| 2450 | sprintf( vlan_name, "bridgemtu%d", count ); |
|---|
| 2451 | websWrite( wp, |
|---|
| 2452 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2453 | vlan_name, mtu != NULL ? mtu : "1500" ); |
|---|
| 2454 | websWrite( wp, |
|---|
| 2455 | "<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", |
|---|
| 2456 | count ); |
|---|
| 2457 | websWrite( wp, "</div>\n" ); |
|---|
| 2458 | show_ipnetmask( wp, bridge ); |
|---|
| 2459 | count++; |
|---|
| 2460 | } |
|---|
| 2461 | int i; |
|---|
| 2462 | int totalcount = count; |
|---|
| 2463 | |
|---|
| 2464 | for( i = count; i < realcount; i++ ) |
|---|
| 2465 | { |
|---|
| 2466 | char vlan_name[32]; |
|---|
| 2467 | |
|---|
| 2468 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2469 | websWrite( wp, "<div class=\"label\">Bridge %d</div>\n", i ); |
|---|
| 2470 | sprintf( vlan_name, "bridgename%d", i ); |
|---|
| 2471 | websWrite( wp, "<input class=\"num\" name=\"%s\"size=\"5\" />\n", |
|---|
| 2472 | vlan_name ); |
|---|
| 2473 | websWrite( wp, " STP " ); |
|---|
| 2474 | sprintf( vlan_name, "bridgestp%d", i ); |
|---|
| 2475 | showOptions( wp, vlan_name, "On Off", "On" ); |
|---|
| 2476 | websWrite( wp, " Prio " ); |
|---|
| 2477 | sprintf( vlan_name, "bridgeprio%d", i ); |
|---|
| 2478 | websWrite( wp, |
|---|
| 2479 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2480 | vlan_name, "32768" ); |
|---|
| 2481 | websWrite( wp, " MTU " ); |
|---|
| 2482 | sprintf( vlan_name, "bridgemtu%d", count ); |
|---|
| 2483 | websWrite( wp, |
|---|
| 2484 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2485 | vlan_name, "1500" ); |
|---|
| 2486 | websWrite( wp, |
|---|
| 2487 | "<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", |
|---|
| 2488 | i ); |
|---|
| 2489 | websWrite( wp, "</div>\n" ); |
|---|
| 2490 | totalcount++; |
|---|
| 2491 | } |
|---|
| 2492 | websWrite( wp, |
|---|
| 2493 | "<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" ); |
|---|
| 2494 | char var[32]; |
|---|
| 2495 | |
|---|
| 2496 | sprintf( var, "%d", totalcount ); |
|---|
| 2497 | nvram_set( "bridges_count", var ); |
|---|
| 2498 | } |
|---|
| 2499 | |
|---|
| 2500 | void ej_show_bridgetable( webs_t wp, int argc, char_t ** argv ) |
|---|
| 2501 | { |
|---|
| 2502 | #ifdef HAVE_MICRO // brctl N/A in micro |
|---|
| 2503 | return; |
|---|
| 2504 | #endif |
|---|
| 2505 | |
|---|
| 2506 | FILE *f; |
|---|
| 2507 | char buf[128]; |
|---|
| 2508 | char brname[32]; |
|---|
| 2509 | char brstp[8]; |
|---|
| 2510 | char brif[16]; |
|---|
| 2511 | int count = 0; |
|---|
| 2512 | |
|---|
| 2513 | system2( "brctl show > /tmp/.brtable" ); |
|---|
| 2514 | |
|---|
| 2515 | if( ( f = fopen( "/tmp/.brtable", "r" ) ) != NULL ) |
|---|
| 2516 | { |
|---|
| 2517 | |
|---|
| 2518 | while( fgets( buf, sizeof( buf ), f ) ) |
|---|
| 2519 | { |
|---|
| 2520 | |
|---|
| 2521 | if( count ) // skip line 0 |
|---|
| 2522 | { |
|---|
| 2523 | strcpy( brname, "" ); |
|---|
| 2524 | strcpy( brstp, "" ); |
|---|
| 2525 | strcpy( brif, "" ); |
|---|
| 2526 | |
|---|
| 2527 | if( strncmp( buf, "\t\t\t", 3 ) != 0 ) |
|---|
| 2528 | { |
|---|
| 2529 | if( count != 1 ) |
|---|
| 2530 | websWrite( wp, "\'," ); // close |
|---|
| 2531 | sscanf( buf, "%s %*s %s %s", brname, brstp, brif ); |
|---|
| 2532 | websWrite( wp, "\'%s\',\'%s\',\'%s ", brname, brstp, |
|---|
| 2533 | brif ); |
|---|
| 2534 | } |
|---|
| 2535 | else |
|---|
| 2536 | { |
|---|
| 2537 | sscanf( buf, "%s", brif ); |
|---|
| 2538 | websWrite( wp, "%s ", brif ); |
|---|
| 2539 | } |
|---|
| 2540 | } |
|---|
| 2541 | count++; |
|---|
| 2542 | } |
|---|
| 2543 | |
|---|
| 2544 | websWrite( wp, "\'" ); // close |
|---|
| 2545 | fclose( f ); |
|---|
| 2546 | unlink( "/tmp/.brtable" ); |
|---|
| 2547 | } |
|---|
| 2548 | return; |
|---|
| 2549 | } |
|---|
| 2550 | |
|---|
| 2551 | void ej_show_bridgeifnames( webs_t wp, int argc, char_t ** argv ) |
|---|
| 2552 | { |
|---|
| 2553 | char bufferif[512]; |
|---|
| 2554 | char bufferif2[256]; |
|---|
| 2555 | char finalbuffer[512]; |
|---|
| 2556 | int count = 0; |
|---|
| 2557 | static char word[256]; |
|---|
| 2558 | char *next, *wordlist; |
|---|
| 2559 | |
|---|
| 2560 | memset( bufferif, 0, 512 ); |
|---|
| 2561 | memset( bufferif2, 0, 256 ); |
|---|
| 2562 | getIfList( bufferif, "eth" ); |
|---|
| 2563 | #ifdef HAVE_GATEWORX |
|---|
| 2564 | getIfList( bufferif2, "ixp" ); |
|---|
| 2565 | sprintf( bufferif, "%s %s", bufferif, bufferif2 ); |
|---|
| 2566 | #endif |
|---|
| 2567 | |
|---|
| 2568 | memset( bufferif2, 0, 256 ); |
|---|
| 2569 | getIfList( bufferif2, "vlan" ); |
|---|
| 2570 | sprintf( bufferif, "%s %s", bufferif, bufferif2 ); |
|---|
| 2571 | |
|---|
| 2572 | memset( bufferif2, 0, 256 ); |
|---|
| 2573 | getIfList( bufferif2, "wl" ); |
|---|
| 2574 | sprintf( bufferif, "%s %s", bufferif, bufferif2 ); |
|---|
| 2575 | |
|---|
| 2576 | memset( bufferif2, 0, 256 ); |
|---|
| 2577 | getIfList( bufferif2, "ofdm" ); |
|---|
| 2578 | sprintf( bufferif, "%s %s", bufferif, bufferif2 ); |
|---|
| 2579 | |
|---|
| 2580 | memset( bufferif2, 0, 256 ); |
|---|
| 2581 | getIfList( bufferif2, "br" ); |
|---|
| 2582 | foreach( word, bufferif2, next ) |
|---|
| 2583 | { |
|---|
| 2584 | if( contains( word, '.' ) ) |
|---|
| 2585 | sprintf( bufferif, "%s %s", bufferif, word ); |
|---|
| 2586 | } |
|---|
| 2587 | int i; |
|---|
| 2588 | |
|---|
| 2589 | #ifdef HAVE_MADWIFI |
|---|
| 2590 | memset( bufferif2, 0, 256 ); |
|---|
| 2591 | getIfList( bufferif2, "ath" ); |
|---|
| 2592 | foreach( word, bufferif2, next ) |
|---|
| 2593 | { |
|---|
| 2594 | if( contains( word, '.' ) ) |
|---|
| 2595 | sprintf( bufferif, "%s %s", bufferif, word ); |
|---|
| 2596 | } |
|---|
| 2597 | int c = getifcount( "wifi" ); |
|---|
| 2598 | |
|---|
| 2599 | for( i = 0; i < c; i++ ) |
|---|
| 2600 | { |
|---|
| 2601 | char ath[32]; |
|---|
| 2602 | |
|---|
| 2603 | sprintf( ath, "ath%d_bridged", i ); |
|---|
| 2604 | if( nvram_default_match( ath, "1", "1" ) ) |
|---|
| 2605 | { |
|---|
| 2606 | sprintf( bufferif, "%s ath%d", bufferif, i ); |
|---|
| 2607 | char vifs[32]; |
|---|
| 2608 | |
|---|
| 2609 | sprintf( vifs, "ath%d_vifs", i ); |
|---|
| 2610 | sprintf( bufferif, "%s %s", bufferif, nvram_safe_get( vifs ) ); |
|---|
| 2611 | } |
|---|
| 2612 | } |
|---|
| 2613 | #endif |
|---|
| 2614 | #ifdef HAVE_BONDING |
|---|
| 2615 | c = atoi( nvram_default_get( "bonding_number", "1" ) ); |
|---|
| 2616 | for( i = 0; i < c; i++ ) |
|---|
| 2617 | { |
|---|
| 2618 | sprintf( bufferif, "%s bond%d", bufferif, i ); |
|---|
| 2619 | } |
|---|
| 2620 | #endif |
|---|
| 2621 | #ifdef HAVE_EOP_TUNNEL |
|---|
| 2622 | for( i = 1; i < 11; i++ ) |
|---|
| 2623 | { |
|---|
| 2624 | char EOP[32]; |
|---|
| 2625 | |
|---|
| 2626 | if( nvram_nmatch( "1", "oet%d_bridged", i ) |
|---|
| 2627 | && nvram_nmatch( "1", "oet%d_en", i ) ) |
|---|
| 2628 | { |
|---|
| 2629 | sprintf( EOP, "EOP%d", i ); |
|---|
| 2630 | sprintf( bufferif, "%s %s", bufferif, EOP ); |
|---|
| 2631 | } |
|---|
| 2632 | } |
|---|
| 2633 | #endif |
|---|
| 2634 | char buffer[256]; |
|---|
| 2635 | |
|---|
| 2636 | memset( buffer, 0, 256 ); |
|---|
| 2637 | getIfList( buffer, "br" ); |
|---|
| 2638 | |
|---|
| 2639 | memset( finalbuffer, 0, 256 ); |
|---|
| 2640 | foreach( word, buffer, next ) |
|---|
| 2641 | { |
|---|
| 2642 | if( !contains( word, '.' ) ) |
|---|
| 2643 | sprintf( finalbuffer, "%s %s", finalbuffer, word ); |
|---|
| 2644 | } |
|---|
| 2645 | |
|---|
| 2646 | int realcount = atoi( nvram_default_get( "bridgesif_count", "0" ) ); |
|---|
| 2647 | |
|---|
| 2648 | wordlist = nvram_safe_get( "bridgesif" ); |
|---|
| 2649 | foreach( word, wordlist, next ) |
|---|
| 2650 | { |
|---|
| 2651 | char *port = word; |
|---|
| 2652 | char *tag = strsep( &port, ">" ); |
|---|
| 2653 | char *prio = port; |
|---|
| 2654 | |
|---|
| 2655 | strsep( &prio, ">" ); |
|---|
| 2656 | if( !tag || !port ) |
|---|
| 2657 | break; |
|---|
| 2658 | char vlan_name[32]; |
|---|
| 2659 | |
|---|
| 2660 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2661 | websWrite( wp, "<div class=\"label\">Assignment %d</div>\n", count ); |
|---|
| 2662 | sprintf( vlan_name, "bridge%d", count ); |
|---|
| 2663 | showOptions( wp, vlan_name, finalbuffer, tag ); |
|---|
| 2664 | websWrite( wp, " Interface " ); |
|---|
| 2665 | sprintf( vlan_name, "bridgeif%d", count ); |
|---|
| 2666 | showOptions( wp, vlan_name, bufferif, port ); |
|---|
| 2667 | websWrite( wp, " Prio " ); |
|---|
| 2668 | sprintf( vlan_name, "bridgeifprio%d", count ); |
|---|
| 2669 | websWrite( wp, |
|---|
| 2670 | "<input class=\"num\" name=\"%s\"size=\"3\" value=\"%s\" />\n", |
|---|
| 2671 | vlan_name, prio != NULL ? prio : "63" ); |
|---|
| 2672 | websWrite( wp, |
|---|
| 2673 | "<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", |
|---|
| 2674 | count ); |
|---|
| 2675 | websWrite( wp, "</div>\n" ); |
|---|
| 2676 | count++; |
|---|
| 2677 | } |
|---|
| 2678 | int totalcount = count; |
|---|
| 2679 | |
|---|
| 2680 | for( i = count; i < realcount; i++ ) |
|---|
| 2681 | { |
|---|
| 2682 | char vlan_name[32]; |
|---|
| 2683 | |
|---|
| 2684 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2685 | websWrite( wp, "<div class=\"label\">Assignment %d</div>\n", i ); |
|---|
| 2686 | sprintf( vlan_name, "bridge%d", i ); |
|---|
| 2687 | showOptions( wp, vlan_name, finalbuffer, "" ); |
|---|
| 2688 | websWrite( wp, " Interface " ); |
|---|
| 2689 | sprintf( vlan_name, "bridgeif%d", i ); |
|---|
| 2690 | showOptions( wp, vlan_name, bufferif, "" ); |
|---|
| 2691 | websWrite( wp, " Prio " ); |
|---|
| 2692 | sprintf( vlan_name, "bridgeifprio%d", i ); |
|---|
| 2693 | websWrite( wp, |
|---|
| 2694 | "<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2695 | vlan_name, "63" ); |
|---|
| 2696 | websWrite( wp, |
|---|
| 2697 | "<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", |
|---|
| 2698 | i ); |
|---|
| 2699 | websWrite( wp, "</div>\n" ); |
|---|
| 2700 | totalcount++; |
|---|
| 2701 | } |
|---|
| 2702 | websWrite( wp, |
|---|
| 2703 | "<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" ); |
|---|
| 2704 | char var[32]; |
|---|
| 2705 | |
|---|
| 2706 | sprintf( var, "%d", totalcount ); |
|---|
| 2707 | nvram_set( "bridgesif_count", var ); |
|---|
| 2708 | } |
|---|
| 2709 | |
|---|
| 2710 | #endif |
|---|
| 2711 | #if 0 |
|---|
| 2712 | static void |
|---|
| 2713 | showDynOption( webs_t wp, char *propname, char *nvname, char *options[], |
|---|
| 2714 | char *names[] ) |
|---|
| 2715 | { |
|---|
| 2716 | int i; |
|---|
| 2717 | |
|---|
| 2718 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2719 | websWrite( wp, |
|---|
| 2720 | "<div class=\"label\">%s</div><select name=\"%s\">\n", |
|---|
| 2721 | propname, nvname ); |
|---|
| 2722 | for( i = 0; options[i] != NULL; i++ ) |
|---|
| 2723 | { |
|---|
| 2724 | websWrite( wp, |
|---|
| 2725 | "<option value=\"%s\" %s>Off</option>\n", |
|---|
| 2726 | names[i], nvram_match( nvname, |
|---|
| 2727 | options[i] ) ? |
|---|
| 2728 | "selected=\"selected\"" : "" ); |
|---|
| 2729 | } |
|---|
| 2730 | websWrite( wp, "</div>\n" ); |
|---|
| 2731 | |
|---|
| 2732 | } |
|---|
| 2733 | #endif |
|---|
| 2734 | #ifdef HAVE_MSSID |
|---|
| 2735 | |
|---|
| 2736 | static void show_channel( webs_t wp, char *dev, char *prefix, int type ) |
|---|
| 2737 | { |
|---|
| 2738 | char wl_mode[16]; |
|---|
| 2739 | |
|---|
| 2740 | sprintf( wl_mode, "%s_mode", prefix ); |
|---|
| 2741 | char wl_net_mode[16]; |
|---|
| 2742 | |
|---|
| 2743 | sprintf( wl_net_mode, "%s_net_mode", prefix ); |
|---|
| 2744 | if( nvram_match( wl_net_mode, "disabled" ) ) |
|---|
| 2745 | return; |
|---|
| 2746 | if( nvram_match( wl_mode, "ap" ) || nvram_match( wl_mode, "wdsap" ) |
|---|
| 2747 | || nvram_match( wl_mode, "infra" ) ) |
|---|
| 2748 | { |
|---|
| 2749 | char wl_channel[16]; |
|---|
| 2750 | |
|---|
| 2751 | sprintf( wl_channel, "%s_channel", prefix ); |
|---|
| 2752 | char wl_wchannel[16]; |
|---|
| 2753 | |
|---|
| 2754 | sprintf( wl_wchannel, "%s_wchannel", prefix ); |
|---|
| 2755 | char wl_nbw[16]; |
|---|
| 2756 | |
|---|
| 2757 | sprintf( wl_nbw, "%s_nbw", prefix ); |
|---|
| 2758 | |
|---|
| 2759 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2760 | websWrite( wp, |
|---|
| 2761 | "<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", |
|---|
| 2762 | wl_channel ); |
|---|
| 2763 | #ifdef HAVE_MADWIFI |
|---|
| 2764 | struct wifi_channels *chan; |
|---|
| 2765 | char cn[32]; |
|---|
| 2766 | char fr[32]; |
|---|
| 2767 | |
|---|
| 2768 | chan = list_channels( prefix ); |
|---|
| 2769 | if( chan == NULL ) |
|---|
| 2770 | chan = list_channels( dev ); |
|---|
| 2771 | if( chan != NULL ) |
|---|
| 2772 | { |
|---|
| 2773 | // int cnt = getchannelcount (); |
|---|
| 2774 | websWrite( wp, |
|---|
| 2775 | "document.write(\"<option value=\\\"0\\\" %s>\" + share.auto + \"</option>\");\n", |
|---|
| 2776 | nvram_match( wl_channel, |
|---|
| 2777 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 2778 | "" ); |
|---|
| 2779 | int i = 0; |
|---|
| 2780 | |
|---|
| 2781 | while( chan[i].freq != -1 ) |
|---|
| 2782 | { |
|---|
| 2783 | cprintf( "%d\n", chan[i].channel ); |
|---|
| 2784 | cprintf( "%d\n", chan[i].freq ); |
|---|
| 2785 | |
|---|
| 2786 | sprintf( cn, "%d", chan[i].channel ); |
|---|
| 2787 | sprintf( fr, "%d", chan[i].freq ); |
|---|
| 2788 | #ifdef HAVE_XR4SPECIAL |
|---|
| 2789 | char ofs[32]; |
|---|
| 2790 | |
|---|
| 2791 | sprintf( ofs, "%s_offset", prefix ); |
|---|
| 2792 | websWrite( wp, |
|---|
| 2793 | "document.write(\"<option value=\\\"%s\\\" %s>%s - %d MHz</option>\");\n", |
|---|
| 2794 | fr, nvram_match( wl_channel, |
|---|
| 2795 | fr ) ? "selected=\\\"selected\\\"" |
|---|
| 2796 | : "", cn, |
|---|
| 2797 | chan[i].freq + |
|---|
| 2798 | atoi( nvram_default_get( ofs, "0" ) ) ); |
|---|
| 2799 | #else |
|---|
| 2800 | websWrite( wp, |
|---|
| 2801 | "document.write(\"<option value=\\\"%s\\\" %s>%s - %d MHz</option>\");\n", |
|---|
| 2802 | fr, nvram_match( wl_channel, |
|---|
| 2803 | fr ) ? "selected=\\\"selected\\\"" |
|---|
| 2804 | : "", cn, |
|---|
| 2805 | ( chan[i].freq + get_wifioffset( prefix ) ) ); |
|---|
| 2806 | #endif |
|---|
| 2807 | // free (chan[i].freq); |
|---|
| 2808 | i++; |
|---|
| 2809 | } |
|---|
| 2810 | free( chan ); |
|---|
| 2811 | } |
|---|
| 2812 | #else |
|---|
| 2813 | int instance = 0; |
|---|
| 2814 | |
|---|
| 2815 | if( !strcmp( prefix, "wl1" ) ) |
|---|
| 2816 | instance = 1; |
|---|
| 2817 | if( type == 1 && !nvram_match( wl_net_mode, "g-only" ) |
|---|
| 2818 | && !nvram_match( wl_net_mode, "a-only" ) |
|---|
| 2819 | && !nvram_match( wl_net_mode, "na-only" ) |
|---|
| 2820 | && !nvram_match( wl_net_mode, "bg-mixed" ) |
|---|
| 2821 | && nvram_match( wl_nbw, "40" ) ) |
|---|
| 2822 | { |
|---|
| 2823 | int ch = atoi( nvram_nget( "wl%d_wchannel", instance ) ); |
|---|
| 2824 | |
|---|
| 2825 | websWrite( wp, "var max_channel = 2;\n" ); |
|---|
| 2826 | websWrite( wp, "var wl%d_channel = '%s';\n", instance, |
|---|
| 2827 | nvram_safe_get( wl_wchannel ) ); |
|---|
| 2828 | websWrite( wp, |
|---|
| 2829 | "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" ); |
|---|
| 2830 | char *sel = ""; |
|---|
| 2831 | |
|---|
| 2832 | if( nvram_nmatch( "lower", "wl%d_nctrlsb", instance ) ) |
|---|
| 2833 | sel = "selected"; |
|---|
| 2834 | |
|---|
| 2835 | websWrite( wp, |
|---|
| 2836 | " document.write(\"<option value=%d %s>%d - \"+freq[%d]+\" GHz</option>\");\n", |
|---|
| 2837 | ch - 2, sel, ch - 2, ch - 2 ); |
|---|
| 2838 | if( nvram_nmatch( "upper", "wl%d_nctrlsb", instance ) ) |
|---|
| 2839 | sel = "selected"; |
|---|
| 2840 | websWrite( wp, |
|---|
| 2841 | " document.write(\"<option value=%d %s>%d - \"+freq[%d]+\" GHz</option>\");\n", |
|---|
| 2842 | ch + 2, sel, ch + 2, ch + 2 ); |
|---|
| 2843 | |
|---|
| 2844 | } |
|---|
| 2845 | else |
|---|
| 2846 | { |
|---|
| 2847 | |
|---|
| 2848 | unsigned int chanlist[128]; |
|---|
| 2849 | char *ifn = get_wl_instance_name( instance ); |
|---|
| 2850 | int chancount = getchannels( chanlist, ifn ); |
|---|
| 2851 | |
|---|
| 2852 | // websWrite( wp, "var max_channel = %d;\n", chancount ); |
|---|
| 2853 | // websWrite( wp, "var wl%d_channel = '%s';\n", instance, nvram_safe_get( wl_channel ) ); |
|---|
| 2854 | // websWrite( wp, "var offset = %d;\n", chanlist[0] ); |
|---|
| 2855 | // websWrite( wp, "var buf = \"\";\n" ); |
|---|
| 2856 | // websWrite( wp, "var freq = new Array(\"Auto\"" ); |
|---|
| 2857 | int i; |
|---|
| 2858 | |
|---|
| 2859 | websWrite( wp, |
|---|
| 2860 | "document.write(\"<option value=\\\"0\\\" %s>\" + share.auto + \"</option>\");\n", |
|---|
| 2861 | nvram_nmatch( "0", "%s_channel", |
|---|
| 2862 | prefix ) ? "selected=\\\"selected\\\"" : |
|---|
| 2863 | "" ); |
|---|
| 2864 | for( i = 0; i < chancount; i++ ) |
|---|
| 2865 | { |
|---|
| 2866 | float ofs; |
|---|
| 2867 | |
|---|
| 2868 | if( chanlist[i] < 25 ) |
|---|
| 2869 | ofs = 2.407f; |
|---|
| 2870 | else |
|---|
| 2871 | ofs = 5.000f; |
|---|
| 2872 | ofs += ( float )( chanlist[i] * 0.005f ); |
|---|
| 2873 | if( ofs == 2.477f ) |
|---|
| 2874 | ofs = 2.484f; // fix: ch 14 is 2.484, not 2.477 GHz |
|---|
| 2875 | // websWrite( wp, ", \"%0.3f\"", ofs ); |
|---|
| 2876 | char channelstring[32]; |
|---|
| 2877 | |
|---|
| 2878 | sprintf( channelstring, "%d", chanlist[i] ); |
|---|
| 2879 | websWrite( wp, |
|---|
| 2880 | "document.write(\"<option value=\\\"%d\\\" %s>%d - %0.3f GHz</option>\");\n", |
|---|
| 2881 | chanlist[i], nvram_nmatch( channelstring, |
|---|
| 2882 | "%s_channel", |
|---|
| 2883 | prefix ) ? |
|---|
| 2884 | "selected=\\\"selected\\\"" : "", chanlist[i], |
|---|
| 2885 | ofs ); |
|---|
| 2886 | } |
|---|
| 2887 | // websWrite( wp, ");\n" ); |
|---|
| 2888 | // websWrite( wp, "for(i=0; i<=max_channel ; i++) {\n" ); |
|---|
| 2889 | // websWrite( wp, " if(i == wl%d_channel) buf = \"selected\";\n", |
|---|
| 2890 | // instance ); |
|---|
| 2891 | // websWrite( wp, " else buf = \"\";\n" ); |
|---|
| 2892 | // websWrite( wp, " if (i==0)\n" ); |
|---|
| 2893 | // websWrite( wp, |
|---|
| 2894 | // " document.write(\"<option value=\"+i+\" \"+buf+\">\" + share.auto + \"</option>\");\n" ); |
|---|
| 2895 | // websWrite( wp, " else\n" ); |
|---|
| 2896 | // websWrite( wp, |
|---|
| 2897 | // " document.write(\"<option value=\"+i+\" \"+buf+\">\"+(i+offset-1)+\" - \"+freq[i]+\" GHz</option>\");\n" ); |
|---|
| 2898 | // websWrite( wp, "}\n" ); |
|---|
| 2899 | } |
|---|
| 2900 | #endif |
|---|
| 2901 | websWrite( wp, "//]]>\n</script></select></div>\n" ); |
|---|
| 2902 | } |
|---|
| 2903 | } |
|---|
| 2904 | |
|---|
| 2905 | #ifdef HAVE_MADWIFI |
|---|
| 2906 | static char *ag_rates[] = { "6", "9", "12", "18", "24", "36", "48", "54" }; |
|---|
| 2907 | static char *turbo_rates[] = |
|---|
| 2908 | { "12", "18", "24", "36", "48", "72", "96", "108" }; |
|---|
| 2909 | static char *b_rates[] = { "1", "2", "5.5", "11" }; |
|---|
| 2910 | static char *bg_rates[] = |
|---|
| 2911 | { "1", "2", "5.5", "6", "9", "11", "12", "18", "24", "36", "48", "54" }; |
|---|
| 2912 | // static char *g_rates[] = { "1", "2", "5.5", "11", "12", "18", "24", "36", |
|---|
| 2913 | // "48", "54" }; |
|---|
| 2914 | //static char *xr_rates[] = |
|---|
| 2915 | // { "0.25", "0.5", "1", "2", "3", "6", "9", "12", "18", "24", "36", "48", |
|---|
| 2916 | // "54" |
|---|
| 2917 | //}; |
|---|
| 2918 | static char *half_rates[] = { "3", "4.5", "6", "9", "12", "18", "24", "27" }; |
|---|
| 2919 | static char *quarter_rates[] = |
|---|
| 2920 | { "1.5", "2", "3", "4.5", "6", "9", "12", "13.5" }; |
|---|
| 2921 | |
|---|
| 2922 | void show_rates( webs_t wp, char *prefix, int maxrate ) |
|---|
| 2923 | { |
|---|
| 2924 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 2925 | if( maxrate ) |
|---|
| 2926 | { |
|---|
| 2927 | websWrite( wp, |
|---|
| 2928 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label21)</script></div>\n" ); |
|---|
| 2929 | websWrite( wp, "<select name=\"%s_maxrate\">\n", prefix ); |
|---|
| 2930 | } |
|---|
| 2931 | else |
|---|
| 2932 | { |
|---|
| 2933 | websWrite( wp, |
|---|
| 2934 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label23)</script></div>\n" ); |
|---|
| 2935 | websWrite( wp, "<select name=\"%s_minrate\">\n", prefix ); |
|---|
| 2936 | } |
|---|
| 2937 | websWrite( wp, "<script type=\"text/javascript\">\n" ); |
|---|
| 2938 | websWrite( wp, "//<![CDATA[\n" ); |
|---|
| 2939 | char srate[32]; |
|---|
| 2940 | |
|---|
| 2941 | sprintf( srate, "%s_minrate", prefix ); |
|---|
| 2942 | char mxrate[32]; |
|---|
| 2943 | |
|---|
| 2944 | sprintf( mxrate, "%s_maxrate", prefix ); |
|---|
| 2945 | websWrite( wp, |
|---|
| 2946 | "document.write(\"<option value=\\\"0\\\" %s >\" + share.auto + \"</option>\");\n", |
|---|
| 2947 | nvram_match( srate, "0" ) ? "selected" : "" ); |
|---|
| 2948 | websWrite( wp, "//]]>\n" ); |
|---|
| 2949 | websWrite( wp, "</script>\n" ); |
|---|
| 2950 | char **rate; |
|---|
| 2951 | char **showrates = NULL; |
|---|
| 2952 | int len; |
|---|
| 2953 | char mode[32]; |
|---|
| 2954 | char bw[16]; |
|---|
| 2955 | |
|---|
| 2956 | sprintf( bw, "%s_channelbw", prefix ); |
|---|
| 2957 | |
|---|
| 2958 | sprintf( mode, "%s_net_mode", prefix ); |
|---|
| 2959 | if( nvram_match( mode, "b-only" ) ) |
|---|
| 2960 | { |
|---|
| 2961 | rate = b_rates; |
|---|
| 2962 | len = sizeof( b_rates ) / sizeof( char * ); |
|---|
| 2963 | } |
|---|
| 2964 | if( nvram_match( mode, "g-only" ) ) |
|---|
| 2965 | { |
|---|
| 2966 | rate = ag_rates; |
|---|
| 2967 | len = sizeof( ag_rates ) / sizeof( char * ); |
|---|
| 2968 | if( nvram_match( bw, "40" ) ) |
|---|
| 2969 | { |
|---|
| 2970 | showrates = turbo_rates; |
|---|
| 2971 | } |
|---|
| 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, "a-only" ) ) |
|---|
| 2984 | { |
|---|
| 2985 | rate = ag_rates; |
|---|
| 2986 | len = sizeof( ag_rates ) / sizeof( char * ); |
|---|
| 2987 | if( nvram_match( bw, "40" ) ) |
|---|
| 2988 | { |
|---|
| 2989 | showrates = turbo_rates; |
|---|
| 2990 | } |
|---|
| 2991 | if( nvram_match( bw, "10" ) ) |
|---|
| 2992 | { |
|---|
| 2993 | rate = half_rates; |
|---|
| 2994 | len = sizeof( half_rates ) / sizeof( char * ); |
|---|
| 2995 | } |
|---|
| 2996 | if( nvram_match( bw, "5" ) ) |
|---|
| 2997 | { |
|---|
| 2998 | rate = quarter_rates; |
|---|
| 2999 | len = sizeof( quarter_rates ) / sizeof( char * ); |
|---|
| 3000 | } |
|---|
| 3001 | } |
|---|
| 3002 | if( nvram_match( mode, "bg-mixed" ) ) |
|---|
| 3003 | { |
|---|
| 3004 | rate = bg_rates; |
|---|
| 3005 | len = sizeof( bg_rates ) / sizeof( char * ); |
|---|
| 3006 | if( nvram_match( bw, "10" ) ) |
|---|
| 3007 | { |
|---|
| 3008 | rate = half_rates; |
|---|
| 3009 | len = sizeof( half_rates ) / sizeof( char * ); |
|---|
| 3010 | } |
|---|
| 3011 | if( nvram_match( bw, "5" ) ) |
|---|
| 3012 | { |
|---|
| 3013 | rate = quarter_rates; |
|---|
| 3014 | len = sizeof( quarter_rates ) / sizeof( char * ); |
|---|
| 3015 | } |
|---|
| 3016 | } |
|---|
| 3017 | if( nvram_match( mode, "mixed" ) ) |
|---|
| 3018 | { |
|---|
| 3019 | rate = bg_rates; |
|---|
| 3020 | len = sizeof( bg_rates ) / sizeof( char * ); |
|---|
| 3021 | if( nvram_match( bw, "40" ) ) |
|---|
| 3022 | { |
|---|
| 3023 | rate = ag_rates; |
|---|
| 3024 | len = sizeof( ag_rates ) / sizeof( char * ); |
|---|
| 3025 | showrates = turbo_rates; |
|---|
| 3026 | } |
|---|
| 3027 | if( nvram_match( bw, "10" ) ) |
|---|
| 3028 | { |
|---|
| 3029 | rate = half_rates; |
|---|
| 3030 | len = sizeof( half_rates ) / sizeof( char * ); |
|---|
| 3031 | } |
|---|
| 3032 | if( nvram_match( bw, "5" ) ) |
|---|
| 3033 | { |
|---|
| 3034 | rate = quarter_rates; |
|---|
| 3035 | len = sizeof( quarter_rates ) / sizeof( char * ); |
|---|
| 3036 | } |
|---|
| 3037 | } |
|---|
| 3038 | int i; |
|---|
| 3039 | |
|---|
| 3040 | for( i = 0; i < len; i++ ) |
|---|
| 3041 | { |
|---|
| 3042 | if( maxrate ) |
|---|
| 3043 | { |
|---|
| 3044 | int offset = 0; |
|---|
| 3045 | |
|---|
| 3046 | if( nvram_match( mode, "g-only" ) && nvram_match( bw, "20" ) ) |
|---|
| 3047 | offset = 4; |
|---|
| 3048 | char comp[32]; |
|---|
| 3049 | |
|---|
| 3050 | sprintf( comp, "%d", i + 1 + offset ); |
|---|
| 3051 | if( showrates ) |
|---|
| 3052 | websWrite( wp, "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 3053 | i + 1 + offset, nvram_match( mxrate, |
|---|
| 3054 | comp ) ? "selected" : |
|---|
| 3055 | "", showrates[i] ); |
|---|
| 3056 | else |
|---|
| 3057 | websWrite( wp, "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 3058 | i + 1 + offset, nvram_match( mxrate, |
|---|
| 3059 | comp ) ? "selected" : |
|---|
| 3060 | "", rate[i] ); |
|---|
| 3061 | } |
|---|
| 3062 | else |
|---|
| 3063 | { |
|---|
| 3064 | int offset = 0; |
|---|
| 3065 | |
|---|
| 3066 | if( nvram_match( mode, "g-only" ) && nvram_match( bw, "20" ) ) |
|---|
| 3067 | offset = 4; |
|---|
| 3068 | char comp[32]; |
|---|
| 3069 | |
|---|
| 3070 | sprintf( comp, "%d", i + 1 + offset ); |
|---|
| 3071 | if( showrates ) |
|---|
| 3072 | websWrite( wp, "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 3073 | i + 1 + offset, nvram_match( srate, |
|---|
| 3074 | comp ) ? "selected" : |
|---|
| 3075 | "", showrates[i] ); |
|---|
| 3076 | else |
|---|
| 3077 | websWrite( wp, "<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 3078 | i + 1 + offset, nvram_match( srate, |
|---|
| 3079 | comp ) ? "selected" : |
|---|
| 3080 | "", rate[i] ); |
|---|
| 3081 | |
|---|
| 3082 | } |
|---|
| 3083 | } |
|---|
| 3084 | websWrite( wp, "</select>\n" ); |
|---|
| 3085 | websWrite( wp, "<span class=\"default\">\n" ); |
|---|
| 3086 | websWrite( wp, "<script type=\"text/javascript\">\n" ); |
|---|
| 3087 | websWrite( wp, "//<![CDATA[\n" ); |
|---|
| 3088 | websWrite( wp, |
|---|
| 3089 | "document.write(\"(\" + share.deflt + \": \" + share.auto + \")\");\n" ); |
|---|
| 3090 | websWrite( wp, "//]]\n" ); |
|---|
| 3091 | websWrite( wp, "</script></span></div>\n" ); |
|---|
| 3092 | |
|---|
| 3093 | } |
|---|
| 3094 | #endif |
|---|
| 3095 | static void show_netmode( webs_t wp, char *prefix ) |
|---|
| 3096 | { |
|---|
| 3097 | char wl_net_mode[16]; |
|---|
| 3098 | |
|---|
| 3099 | sprintf( wl_net_mode, "%s_net_mode", prefix ); |
|---|
| 3100 | |
|---|
| 3101 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3102 | websWrite( wp, |
|---|
| 3103 | "<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", |
|---|
| 3104 | wl_net_mode, wl_net_mode ); |
|---|
| 3105 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 3106 | websWrite( wp, |
|---|
| 3107 | "document.write(\"<option value=\\\"disabled\\\" %s>\" + share.disabled + \"</option>\");\n", |
|---|
| 3108 | nvram_match( wl_net_mode, |
|---|
| 3109 | "disabled" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3110 | websWrite( wp, |
|---|
| 3111 | "document.write(\"<option value=\\\"mixed\\\" %s>\" + wl_basic.mixed + \"</option>\");\n", |
|---|
| 3112 | nvram_match( wl_net_mode, |
|---|
| 3113 | "mixed" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3114 | if( has_mimo( prefix ) ) |
|---|
| 3115 | { |
|---|
| 3116 | websWrite( wp, |
|---|
| 3117 | "document.write(\"<option value=\\\"bg-mixed\\\" %s>\" + wl_basic.bg + \"</option>\");\n", |
|---|
| 3118 | nvram_match( wl_net_mode, |
|---|
| 3119 | "bg-mixed" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3120 | "" ); |
|---|
| 3121 | } |
|---|
| 3122 | #ifdef HAVE_WHRAG108 |
|---|
| 3123 | if( !strcmp( prefix, "ath1" ) ) |
|---|
| 3124 | #endif |
|---|
| 3125 | #ifdef HAVE_TW6600 |
|---|
| 3126 | if( !strcmp( prefix, "ath1" ) ) |
|---|
| 3127 | #endif |
|---|
| 3128 | websWrite( wp, |
|---|
| 3129 | "document.write(\"<option value=\\\"b-only\\\" %s>\" + wl_basic.b + \"</option>\");\n", |
|---|
| 3130 | nvram_match( wl_net_mode, |
|---|
| 3131 | "b-only" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3132 | "" ); |
|---|
| 3133 | #ifdef HAVE_MADWIFI |
|---|
| 3134 | #ifdef HAVE_WHRAG108 |
|---|
| 3135 | if( !strcmp( prefix, "ath1" ) ) |
|---|
| 3136 | #endif |
|---|
| 3137 | #ifdef HAVE_TW6600 |
|---|
| 3138 | if( !strcmp( prefix, "ath1" ) ) |
|---|
| 3139 | #endif |
|---|
| 3140 | websWrite( wp, |
|---|
| 3141 | "document.write(\"<option value=\\\"g-only\\\" %s>\" + wl_basic.g + \"</option>\");\n", |
|---|
| 3142 | nvram_match( wl_net_mode, |
|---|
| 3143 | "g-only" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3144 | "" ); |
|---|
| 3145 | #ifdef HAVE_WHRAG108 |
|---|
| 3146 | if( !strcmp( prefix, "ath1" ) ) |
|---|
| 3147 | #endif |
|---|
| 3148 | #ifdef HAVE_TW6600 |
|---|
| 3149 | if( !strcmp( prefix, "ath1" ) ) |
|---|
| 3150 | #endif |
|---|
| 3151 | #ifndef HAVE_LS5 |
|---|
| 3152 | websWrite( wp, |
|---|
| 3153 | "document.write(\"<option value=\\\"bg-mixed\\\" %s>\" + wl_basic.bg + \"</option>\");\n", |
|---|
| 3154 | nvram_match( wl_net_mode, |
|---|
| 3155 | "bg-mixed" ) ? "selected=\\\"selected\\\"" |
|---|
| 3156 | : "" ); |
|---|
| 3157 | #endif |
|---|
| 3158 | #else |
|---|
| 3159 | #ifdef HAVE_WHRAG108 |
|---|
| 3160 | if( !strcmp( prefix, "ath1" ) ) |
|---|
| 3161 | #endif |
|---|
| 3162 | #ifndef HAVE_LS5 |
|---|
| 3163 | websWrite( wp, |
|---|
| 3164 | "document.write(\"<option value=\\\"g-only\\\" %s>\" + wl_basic.g + \"</option>\");\n", |
|---|
| 3165 | nvram_match( wl_net_mode, |
|---|
| 3166 | "g-only" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3167 | "" ); |
|---|
| 3168 | #endif |
|---|
| 3169 | #endif |
|---|
| 3170 | if( has_mimo( prefix ) ) |
|---|
| 3171 | { |
|---|
| 3172 | websWrite( wp, |
|---|
| 3173 | "document.write(\"<option value=\\\"n-only\\\" %s>\" + wl_basic.n + \"</option>\");\n", |
|---|
| 3174 | nvram_match( wl_net_mode, |
|---|
| 3175 | "n-only" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3176 | "" ); |
|---|
| 3177 | } |
|---|
| 3178 | #if !defined(HAVE_FONERA) && !defined(HAVE_LS2) && !defined(HAVE_MERAKI) |
|---|
| 3179 | #ifndef HAVE_MADWIFI |
|---|
| 3180 | |
|---|
| 3181 | if( nvram_nmatch( "ga", "%s_phytypes", prefix ) |
|---|
| 3182 | || nvram_nmatch( "a", "%s_phytypes", prefix ) ) |
|---|
| 3183 | websWrite( wp, |
|---|
| 3184 | "document.write(\"<option value=\\\"a-only\\\" %s>\" + wl_basic.a + \"</option>\");\n", |
|---|
| 3185 | nvram_match( wl_net_mode, |
|---|
| 3186 | "a-only" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3187 | "" ); |
|---|
| 3188 | |
|---|
| 3189 | if( has_mimo( prefix ) ) |
|---|
| 3190 | { |
|---|
| 3191 | char band[64]; |
|---|
| 3192 | |
|---|
| 3193 | sprintf( band, "%s_bandlist", prefix ); |
|---|
| 3194 | char *b = nvram_safe_get( band ); |
|---|
| 3195 | |
|---|
| 3196 | if( contains( b, 'a' ) ) |
|---|
| 3197 | { |
|---|
| 3198 | websWrite( wp, |
|---|
| 3199 | "document.write(\"<option value=\\\"a-only\\\" %s>\" + wl_basic.a + \"</option>\");\n", |
|---|
| 3200 | nvram_match( wl_net_mode, |
|---|
| 3201 | "a-only" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3202 | "" ); |
|---|
| 3203 | websWrite( wp, |
|---|
| 3204 | "document.write(\"<option value=\\\"na-only\\\" %s>\" + wl_basic.na + \"</option>\");\n", |
|---|
| 3205 | nvram_match( wl_net_mode, |
|---|
| 3206 | "na-only" ) ? "selected=\\\"selected\\\"" |
|---|
| 3207 | : "" ); |
|---|
| 3208 | } |
|---|
| 3209 | } |
|---|
| 3210 | #else |
|---|
| 3211 | #if HAVE_WHRAG108 |
|---|
| 3212 | if( !strcmp( prefix, "ath0" ) ) |
|---|
| 3213 | #endif |
|---|
| 3214 | #ifdef HAVE_TW6600 |
|---|
| 3215 | if( !strcmp( prefix, "ath0" ) ) |
|---|
| 3216 | #endif |
|---|
| 3217 | websWrite( wp, |
|---|
| 3218 | "document.write(\"<option value=\\\"a-only\\\" %s>\" + wl_basic.a + \"</option>\");\n", |
|---|
| 3219 | nvram_match( wl_net_mode, |
|---|
| 3220 | "a-only" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3221 | "" ); |
|---|
| 3222 | #endif |
|---|
| 3223 | |
|---|
| 3224 | #endif |
|---|
| 3225 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3226 | websWrite( wp, "</select>\n" ); |
|---|
| 3227 | websWrite( wp, "</div>\n" ); |
|---|
| 3228 | |
|---|
| 3229 | #ifdef HAVE_RT2880 |
|---|
| 3230 | if (nvram_nmatch("n-only","%s_net_mode",prefix)) |
|---|
| 3231 | { |
|---|
| 3232 | char wl_greenfield[32]; |
|---|
| 3233 | sprintf(wl_greenfield,"%s_greenfield",prefix); |
|---|
| 3234 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3235 | websWrite( wp, |
|---|
| 3236 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label2)</script></div><select name=\"%s\" >\n", |
|---|
| 3237 | wl_greenfield ); |
|---|
| 3238 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 3239 | websWrite( wp, |
|---|
| 3240 | "document.write(\"<option value=\\\"0\\\" %s>\" + wl_basic.mixed + \"</option>\");\n", |
|---|
| 3241 | nvram_default_match( wl_greenfield,"0","0" ) ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3242 | websWrite( wp, |
|---|
| 3243 | "document.write(\"<option value=\\\"1\\\" %s>\" + wl_basic.greenfield + \"</option>\");\n", |
|---|
| 3244 | nvram_default_match( wl_greenfield, |
|---|
| 3245 | "1","0" ) ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3246 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3247 | websWrite( wp, "</select>\n" ); |
|---|
| 3248 | websWrite( wp, "</div>\n" ); |
|---|
| 3249 | } |
|---|
| 3250 | #endif |
|---|
| 3251 | } |
|---|
| 3252 | |
|---|
| 3253 | #ifdef HAVE_MADWIFI |
|---|
| 3254 | static void showrtssettings( webs_t wp, char *var ) |
|---|
| 3255 | { |
|---|
| 3256 | char ssid[32]; |
|---|
| 3257 | char vvar[32]; |
|---|
| 3258 | |
|---|
| 3259 | strcpy( vvar, var ); |
|---|
| 3260 | rep( vvar, '.', 'X' ); |
|---|
| 3261 | sprintf( ssid, "%s_rts", var ); |
|---|
| 3262 | websWrite( wp, |
|---|
| 3263 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.rts)</script></div>\n" ); |
|---|
| 3264 | websWrite( wp, |
|---|
| 3265 | "<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", |
|---|
| 3266 | vvar, var, nvram_default_match( ssid, "1", |
|---|
| 3267 | "0" ) ? "checked=\"checked\"" : |
|---|
| 3268 | "" ); |
|---|
| 3269 | websWrite( wp, |
|---|
| 3270 | "<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", |
|---|
| 3271 | vvar, var, nvram_default_match( ssid, "0", |
|---|
| 3272 | "0" ) ? "checked=\"checked\"" : |
|---|
| 3273 | "" ); |
|---|
| 3274 | websWrite( wp, "</div>\n" ); |
|---|
| 3275 | |
|---|
| 3276 | websWrite( wp, "<div id=\"%s_idrts\">\n", vvar ); |
|---|
| 3277 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3278 | websWrite( wp, |
|---|
| 3279 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.rtsvalue)</script></div>\n" ); |
|---|
| 3280 | char ip[32]; |
|---|
| 3281 | |
|---|
| 3282 | sprintf( ip, "%s_rtsvalue", var ); |
|---|
| 3283 | websWrite( wp, |
|---|
| 3284 | "<input class=\"num\" maxlength=\"4\" size=\"4\" onblur=\"valid_range(this,1,2346,share.ip)\" name=\"%s_rtsvalue\" value=\"%s\" />", |
|---|
| 3285 | var, nvram_default_get( ip, "2346" ) ); |
|---|
| 3286 | websWrite( wp, "</div>\n" ); |
|---|
| 3287 | websWrite( wp, "</div>\n" ); |
|---|
| 3288 | |
|---|
| 3289 | websWrite( wp, "<script>\n//<![CDATA[\n " ); |
|---|
| 3290 | websWrite( wp, |
|---|
| 3291 | "show_layer_ext(document.getElementsByName(\"%s_rts\"), \"%s_idrts\", %s);\n", |
|---|
| 3292 | var, vvar, nvram_match( ssid, "1" ) ? "true" : "false" ); |
|---|
| 3293 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3294 | |
|---|
| 3295 | } |
|---|
| 3296 | #endif |
|---|
| 3297 | static void showbridgesettings( webs_t wp, char *var, int mcast ) |
|---|
| 3298 | { |
|---|
| 3299 | |
|---|
| 3300 | websWrite( wp, |
|---|
| 3301 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.network)</script></div>\n" ); |
|---|
| 3302 | char ssid[32]; |
|---|
| 3303 | |
|---|
| 3304 | sprintf( ssid, "%s_bridged", var ); |
|---|
| 3305 | char vvar[32]; |
|---|
| 3306 | |
|---|
| 3307 | strcpy( vvar, var ); |
|---|
| 3308 | rep( vvar, '.', 'X' ); |
|---|
| 3309 | websWrite( wp, |
|---|
| 3310 | "<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", |
|---|
| 3311 | vvar, var, nvram_default_match( ssid, "0", |
|---|
| 3312 | "1" ) ? "checked=\"checked\"" : |
|---|
| 3313 | "" ); |
|---|
| 3314 | websWrite( wp, |
|---|
| 3315 | "<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", |
|---|
| 3316 | vvar, var, nvram_default_match( ssid, "1", |
|---|
| 3317 | "1" ) ? "checked=\"checked\"" : |
|---|
| 3318 | "" ); |
|---|
| 3319 | websWrite( wp, "</div>\n" ); |
|---|
| 3320 | |
|---|
| 3321 | websWrite( wp, "<div id=\"%s_idnetvifs\">\n", vvar ); |
|---|
| 3322 | if( mcast ) |
|---|
| 3323 | { |
|---|
| 3324 | char mcast[32]; |
|---|
| 3325 | |
|---|
| 3326 | sprintf( mcast, "%s_multicast", var ); |
|---|
| 3327 | nvram_default_get( mcast, "0" ); |
|---|
| 3328 | showRadio( wp, "wl_basic.multicast", mcast ); |
|---|
| 3329 | } |
|---|
| 3330 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3331 | websWrite( wp, |
|---|
| 3332 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.ip)</script></div>\n" ); |
|---|
| 3333 | char ip[32]; |
|---|
| 3334 | |
|---|
| 3335 | sprintf( ip, "%s_ipaddr", var ); |
|---|
| 3336 | char *ipv = nvram_safe_get( ip ); |
|---|
| 3337 | |
|---|
| 3338 | websWrite( wp, |
|---|
| 3339 | "<input type=\"hidden\" name=\"%s_ipaddr\" value=\"4\" />\n", |
|---|
| 3340 | var ); |
|---|
| 3341 | websWrite( wp, |
|---|
| 3342 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,1,223,share.ip)\" name=\"%s_ipaddr_0\" value=\"%d\" />.", |
|---|
| 3343 | var, get_single_ip( ipv, 0 ) ); |
|---|
| 3344 | websWrite( wp, |
|---|
| 3345 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_1\" value=\"%d\" />.", |
|---|
| 3346 | var, get_single_ip( ipv, 1 ) ); |
|---|
| 3347 | websWrite( wp, |
|---|
| 3348 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_2\" value=\"%d\" />.", |
|---|
| 3349 | var, get_single_ip( ipv, 2 ) ); |
|---|
| 3350 | websWrite( wp, |
|---|
| 3351 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_3\" value=\"%d\" />\n", |
|---|
| 3352 | var, get_single_ip( ipv, 3 ) ); |
|---|
| 3353 | websWrite( wp, "</div>\n" ); |
|---|
| 3354 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3355 | websWrite( wp, |
|---|
| 3356 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.subnet)</script></div>\n" ); |
|---|
| 3357 | sprintf( ip, "%s_netmask", var ); |
|---|
| 3358 | ipv = nvram_safe_get( ip ); |
|---|
| 3359 | |
|---|
| 3360 | websWrite( wp, |
|---|
| 3361 | "<input type=\"hidden\" name=\"%s_netmask\" value=\"4\" />\n", |
|---|
| 3362 | var ); |
|---|
| 3363 | websWrite( wp, |
|---|
| 3364 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_0\" value=\"%d\" />.", |
|---|
| 3365 | var, get_single_ip( ipv, 0 ) ); |
|---|
| 3366 | websWrite( wp, |
|---|
| 3367 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_1\" value=\"%d\" />.", |
|---|
| 3368 | var, get_single_ip( ipv, 1 ) ); |
|---|
| 3369 | websWrite( wp, |
|---|
| 3370 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_2\" value=\"%d\" />.", |
|---|
| 3371 | var, get_single_ip( ipv, 2 ) ); |
|---|
| 3372 | websWrite( wp, |
|---|
| 3373 | "<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_3\" value=\"%d\" />.", |
|---|
| 3374 | var, get_single_ip( ipv, 3 ) ); |
|---|
| 3375 | websWrite( wp, "</div>\n" ); |
|---|
| 3376 | websWrite( wp, "</div>\n" ); |
|---|
| 3377 | |
|---|
| 3378 | websWrite( wp, "<script>\n//<![CDATA[\n " ); |
|---|
| 3379 | websWrite( wp, |
|---|
| 3380 | "show_layer_ext(document.getElementsByName(\"%s_bridged\"), \"%s_idnetvifs\", %s);\n", |
|---|
| 3381 | var, vvar, nvram_match( ssid, "0" ) ? "true" : "false" ); |
|---|
| 3382 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3383 | |
|---|
| 3384 | } |
|---|
| 3385 | |
|---|
| 3386 | #ifdef HAVE_MADWIFI |
|---|
| 3387 | static void show_chanshift( webs_t wp, char *prefix ) |
|---|
| 3388 | { |
|---|
| 3389 | char wl_chanshift[32]; |
|---|
| 3390 | char wl_channelbw[32]; |
|---|
| 3391 | |
|---|
| 3392 | sprintf( wl_channelbw, "%s_channelbw", prefix ); |
|---|
| 3393 | sprintf( wl_chanshift, "%s_chanshift", prefix ); |
|---|
| 3394 | if( atoi( nvram_safe_get( wl_channelbw ) ) > 5 |
|---|
| 3395 | && ( atoi( nvram_safe_get( wl_chanshift ) ) & 0xf ) > 10 ) |
|---|
| 3396 | nvram_set( wl_chanshift, "10" ); |
|---|
| 3397 | if( atoi( nvram_safe_get( wl_channelbw ) ) > 10 |
|---|
| 3398 | && ( atoi( nvram_safe_get( wl_chanshift ) ) & 0xf ) > 0 ) |
|---|
| 3399 | nvram_set( wl_chanshift, "0" ); |
|---|
| 3400 | |
|---|
| 3401 | if( nvram_match( wl_channelbw, "5" ) |
|---|
| 3402 | || nvram_match( wl_channelbw, "10" ) ) |
|---|
| 3403 | { |
|---|
| 3404 | |
|---|
| 3405 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3406 | websWrite( wp, |
|---|
| 3407 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.chanshift)</script></div>\n<select name=\"%s\">\n", |
|---|
| 3408 | wl_chanshift ); |
|---|
| 3409 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 3410 | if( nvram_match( wl_channelbw, "5" ) ) |
|---|
| 3411 | websWrite( wp, |
|---|
| 3412 | "document.write(\"<option value=\\\"-15\\\" %s >-15 Mhz</option>\");\n", |
|---|
| 3413 | nvram_default_match( wl_chanshift, "-15", |
|---|
| 3414 | "0" ) ? |
|---|
| 3415 | "selected=\\\"selected\\\"" : "" ); |
|---|
| 3416 | if( nvram_match( wl_channelbw, "5" ) |
|---|
| 3417 | || nvram_match( wl_channelbw, "10" ) ) |
|---|
| 3418 | websWrite( wp, |
|---|
| 3419 | "document.write(\"<option value=\\\"-10\\\" %s >-10 Mhz</option>\");\n", |
|---|
| 3420 | nvram_default_match( wl_chanshift, "-10", |
|---|
| 3421 | "0" ) ? |
|---|
| 3422 | "selected=\\\"selected\\\"" : "" ); |
|---|
| 3423 | if( nvram_match( wl_channelbw, "5" ) |
|---|
| 3424 | || nvram_match( wl_channelbw, "10" ) ) |
|---|
| 3425 | websWrite( wp, |
|---|
| 3426 | "document.write(\"<option value=\\\"-5\\\" %s >-5 Mhz</option>\");\n", |
|---|
| 3427 | nvram_default_match( wl_chanshift, "-5", |
|---|
| 3428 | "0" ) ? |
|---|
| 3429 | "selected=\\\"selected\\\"" : "" ); |
|---|
| 3430 | websWrite( wp, |
|---|
| 3431 | "document.write(\"<option value=\\\"0\\\" %s >0 Mhz</option>\");\n", |
|---|
| 3432 | nvram_default_match( wl_chanshift, "0", |
|---|
| 3433 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3434 | "" ); |
|---|
| 3435 | if( nvram_match( wl_channelbw, "5" ) |
|---|
| 3436 | || nvram_match( wl_channelbw, "10" ) ) |
|---|
| 3437 | websWrite( wp, |
|---|
| 3438 | "document.write(\"<option value=\\\"5\\\" %s >+5 Mhz</option>\");\n", |
|---|
| 3439 | nvram_default_match( wl_chanshift, "5", |
|---|
| 3440 | "0" ) ? |
|---|
| 3441 | "selected=\\\"selected\\\"" : "" ); |
|---|
| 3442 | if( nvram_match( wl_channelbw, "5" ) |
|---|
| 3443 | || nvram_match( wl_channelbw, "10" ) ) |
|---|
| 3444 | websWrite( wp, |
|---|
| 3445 | "document.write(\"<option value=\\\"10\\\" %s >+10 Mhz</option>\");\n", |
|---|
| 3446 | nvram_default_match( wl_chanshift, "10", |
|---|
| 3447 | "0" ) ? |
|---|
| 3448 | "selected=\\\"selected\\\"" : "" ); |
|---|
| 3449 | if( nvram_match( wl_channelbw, "5" ) ) |
|---|
| 3450 | websWrite( wp, |
|---|
| 3451 | "document.write(\"<option value=\\\"15\\\" %s >+15 Mhz</option>\");\n", |
|---|
| 3452 | nvram_default_match( wl_chanshift, "15", |
|---|
| 3453 | "0" ) ? |
|---|
| 3454 | "selected=\\\"selected\\\"" : "" ); |
|---|
| 3455 | websWrite( wp, "//]]>\n</script>\n</select>\n</div>\n" ); |
|---|
| 3456 | } |
|---|
| 3457 | } |
|---|
| 3458 | #endif |
|---|
| 3459 | static int show_virtualssid( webs_t wp, char *prefix ) |
|---|
| 3460 | { |
|---|
| 3461 | char *next; |
|---|
| 3462 | char var[80]; |
|---|
| 3463 | char ssid[80]; |
|---|
| 3464 | char vif[16]; |
|---|
| 3465 | |
|---|
| 3466 | #ifdef HAVE_MADWIFI |
|---|
| 3467 | char wmm[32]; |
|---|
| 3468 | char wl_protmode[32]; |
|---|
| 3469 | #endif |
|---|
| 3470 | sprintf( vif, "%s_vifs", prefix ); |
|---|
| 3471 | char *vifs = nvram_safe_get( vif ); |
|---|
| 3472 | |
|---|
| 3473 | if( vifs == NULL ) |
|---|
| 3474 | return 0; |
|---|
| 3475 | #ifndef HAVE_MADWIFI |
|---|
| 3476 | if( !nvram_match( "wl0_mode", "ap" ) |
|---|
| 3477 | && !nvram_match( "wl0_mode", "apsta" ) |
|---|
| 3478 | && !nvram_match( "wl0_mode", "apstawet" ) ) |
|---|
| 3479 | return 0; |
|---|
| 3480 | #endif |
|---|
| 3481 | int count = 1; |
|---|
| 3482 | |
|---|
| 3483 | websWrite( wp, |
|---|
| 3484 | "<h2><script type=\"text/javascript\">Capture(wl_basic.h2_vi)</script></h2>\n" ); |
|---|
| 3485 | foreach( var, vifs, next ) |
|---|
| 3486 | { |
|---|
| 3487 | sprintf( ssid, "%s_ssid", var ); |
|---|
| 3488 | websWrite( wp, |
|---|
| 3489 | "<fieldset><legend><script type=\"text/javascript\">Capture(share.vintrface)</script> %s SSID [", |
|---|
| 3490 | var ); |
|---|
| 3491 | tf_webWriteESCNV( wp, ssid ); // fix for broken html page if ssid |
|---|
| 3492 | // contains html tag |
|---|
| 3493 | websWrite( wp, "]</legend>\n" ); |
|---|
| 3494 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3495 | websWrite( wp, |
|---|
| 3496 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label3)</script></div>\n" ); |
|---|
| 3497 | |
|---|
| 3498 | websWrite( wp, |
|---|
| 3499 | "<input name=\"%s_ssid\" size=\"20\" maxlength=\"32\" onblur=\"valid_name(this,wl_basic.label3)\" value=\"%s\" /></div>\n", |
|---|
| 3500 | var, nvram_safe_get( ssid ) ); |
|---|
| 3501 | |
|---|
| 3502 | #ifdef HAVE_MADWIFI |
|---|
| 3503 | // sprintf( wl_chanshift, "%s_chanshift", var ); |
|---|
| 3504 | // show_chanshift( wp, wl_chanshift ); |
|---|
| 3505 | |
|---|
| 3506 | sprintf( wl_protmode, "%s_protmode", var ); |
|---|
| 3507 | showOptionsLabel( wp, "wl_basic.protmode", wl_protmode, |
|---|
| 3508 | "None CTS RTS/CTS", nvram_default_get( wl_protmode, |
|---|
| 3509 | "None" ) ); |
|---|
| 3510 | showrtssettings( wp, var ); |
|---|
| 3511 | #endif |
|---|
| 3512 | |
|---|
| 3513 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3514 | websWrite( wp, |
|---|
| 3515 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label5)</script></div>" ); |
|---|
| 3516 | sprintf( ssid, "%s_closed", var ); |
|---|
| 3517 | websWrite( wp, |
|---|
| 3518 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s_closed\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input> \n", |
|---|
| 3519 | var, nvram_match( ssid, |
|---|
| 3520 | "0" ) ? "checked=\"checked\"" : "" ); |
|---|
| 3521 | websWrite( wp, |
|---|
| 3522 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s_closed\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input>\n", |
|---|
| 3523 | var, nvram_match( ssid, |
|---|
| 3524 | "1" ) ? "checked=\"checked\"" : "" ); |
|---|
| 3525 | websWrite( wp, "</div>\n" ); |
|---|
| 3526 | char wl_mode[16]; |
|---|
| 3527 | |
|---|
| 3528 | #ifdef HAVE_MADWIFI |
|---|
| 3529 | sprintf( wl_mode, "%s_mode", var ); |
|---|
| 3530 | websWrite( wp, |
|---|
| 3531 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label)</script></div><select name=\"%s\" >\n", |
|---|
| 3532 | wl_mode ); |
|---|
| 3533 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 3534 | websWrite( wp, |
|---|
| 3535 | "document.write(\"<option value=\\\"ap\\\" %s >\" + wl_basic.ap + \"</option>\");\n", |
|---|
| 3536 | nvram_match( wl_mode, |
|---|
| 3537 | "ap" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3538 | // websWrite (wp, |
|---|
| 3539 | // "document.write(\"<option value=\\\"wdssta\\\" %s >\" + |
|---|
| 3540 | // wl_basic.wdssta + \"</option>\");\n", |
|---|
| 3541 | // nvram_match (wl_mode, |
|---|
| 3542 | // "wdssta") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3543 | websWrite( wp, |
|---|
| 3544 | "document.write(\"<option value=\\\"wdsap\\\" %s >\" + wl_basic.wdsap + \"</option>\");\n", |
|---|
| 3545 | nvram_match( wl_mode, |
|---|
| 3546 | "wdsap" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3547 | "" ); |
|---|
| 3548 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3549 | websWrite( wp, "</select>\n" ); |
|---|
| 3550 | websWrite( wp, "</div>\n" ); |
|---|
| 3551 | sprintf( wmm, "%s_wmm", var ); |
|---|
| 3552 | showRadio( wp, "wl_adv.label18", wmm ); |
|---|
| 3553 | #endif |
|---|
| 3554 | sprintf( ssid, "%s_ap_isolate", var ); |
|---|
| 3555 | showRadio( wp, "wl_adv.label11", ssid ); |
|---|
| 3556 | sprintf( wl_mode, "%s_mode", var ); |
|---|
| 3557 | #ifdef HAVE_RT2880 |
|---|
| 3558 | showbridgesettings( wp, getRADev(var), 1 ); |
|---|
| 3559 | #else |
|---|
| 3560 | showbridgesettings( wp, var, 1 ); |
|---|
| 3561 | #endif |
|---|
| 3562 | websWrite( wp, "</fieldset><br />\n" ); |
|---|
| 3563 | count++; |
|---|
| 3564 | } |
|---|
| 3565 | |
|---|
| 3566 | websWrite( wp, "<div class=\"center\">\n" ); |
|---|
| 3567 | #ifdef HAVE_MADWIFI |
|---|
| 3568 | if( count < 8 ) |
|---|
| 3569 | #elif HAVE_RT2880 |
|---|
| 3570 | if( count < 7 ) |
|---|
| 3571 | #else |
|---|
| 3572 | if( count < WL_MAXBSSCFG ) |
|---|
| 3573 | #endif |
|---|
| 3574 | websWrite( wp, |
|---|
| 3575 | "<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", |
|---|
| 3576 | prefix ); |
|---|
| 3577 | |
|---|
| 3578 | if( count > 1 ) |
|---|
| 3579 | websWrite( wp, |
|---|
| 3580 | "<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", |
|---|
| 3581 | prefix ); |
|---|
| 3582 | |
|---|
| 3583 | websWrite( wp, "</div><br />\n" ); |
|---|
| 3584 | |
|---|
| 3585 | return 0; |
|---|
| 3586 | } |
|---|
| 3587 | |
|---|
| 3588 | #endif |
|---|
| 3589 | |
|---|
| 3590 | void ej_showad( webs_t wp, int argc, char_t ** argv ) |
|---|
| 3591 | { |
|---|
| 3592 | #ifndef HAVE_FON |
|---|
| 3593 | #ifndef CONFIG_BRANDING |
|---|
| 3594 | #ifdef HAVE_CHILLI |
|---|
| 3595 | // if (nvram_invmatch ("fon_enable", "1")) |
|---|
| 3596 | // websWrite (wp, |
|---|
| 3597 | // "<a href=\"fon.cgi\"><img src=\"images/turn.gif\" border=0 /></a>"); |
|---|
| 3598 | #endif |
|---|
| 3599 | #endif |
|---|
| 3600 | #endif |
|---|
| 3601 | |
|---|
| 3602 | #ifndef HAVE_NOAD |
|---|
| 3603 | /* |
|---|
| 3604 | * if (nvram_match("wanup","1")) { websWrite(wp,"<script |
|---|
| 3605 | * type=\"text/javascript\"><!--\n//<![CDATA[\n "); |
|---|
| 3606 | * websWrite(wp,"google_ad_client = \"pub-8308593183433068\";\n"); |
|---|
| 3607 | * websWrite(wp,"google_ad_width = 728;\n"); |
|---|
| 3608 | * websWrite(wp,"google_ad_height = 90;\n"); |
|---|
| 3609 | * websWrite(wp,"google_ad_format = \"728x90_as\";\n"); |
|---|
| 3610 | * websWrite(wp,"google_ad_type = \"text_image\";\n"); |
|---|
| 3611 | * websWrite(wp,"google_ad_channel =\"8866414571\";\n"); |
|---|
| 3612 | * websWrite(wp,"google_color_border = \"333333\";\n"); |
|---|
| 3613 | * websWrite(wp,"google_color_bg = \"000000\";\n"); |
|---|
| 3614 | * websWrite(wp,"google_color_link = \"FFFFFF\";\n"); |
|---|
| 3615 | * websWrite(wp,"google_color_url = \"999999\";\n"); |
|---|
| 3616 | * websWrite(wp,"google_color_text = \"CCCCCC\";\n"); |
|---|
| 3617 | * websWrite(wp,"//-->//]]>\n</script>\n"); websWrite(wp,"<script |
|---|
| 3618 | * type=\"text/javascript\"\n"); websWrite(wp," |
|---|
| 3619 | * src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\n"); |
|---|
| 3620 | * websWrite(wp,"</script>\n"); } |
|---|
| 3621 | */ |
|---|
| 3622 | #endif |
|---|
| 3623 | return; |
|---|
| 3624 | } |
|---|
| 3625 | |
|---|
| 3626 | #ifdef HAVE_MSSID |
|---|
| 3627 | |
|---|
| 3628 | #ifndef HAVE_SUPERCHANNEL |
|---|
| 3629 | int inline issuperchannel( void ) |
|---|
| 3630 | { |
|---|
| 3631 | #ifdef HAVE_MR3202A |
|---|
| 3632 | return 0; |
|---|
| 3633 | #elif HAVE_MAKSAT |
|---|
| 3634 | return 1; |
|---|
| 3635 | #else |
|---|
| 3636 | return 0; |
|---|
| 3637 | #endif |
|---|
| 3638 | } |
|---|
| 3639 | #endif |
|---|
| 3640 | |
|---|
| 3641 | #ifdef HAVE_MADWIFI |
|---|
| 3642 | void ej_show_countrylist( webs_t wp, int argc, char_t ** argv ) |
|---|
| 3643 | { |
|---|
| 3644 | if( argc < 1 ) |
|---|
| 3645 | { |
|---|
| 3646 | return; |
|---|
| 3647 | } |
|---|
| 3648 | char *list = getCountryList( ); |
|---|
| 3649 | |
|---|
| 3650 | showOptionsChoose( wp, argv[0], list, nvram_safe_get( argv[0] ) ); |
|---|
| 3651 | } |
|---|
| 3652 | #endif |
|---|
| 3653 | void ej_show_wireless_single( webs_t wp, char *prefix ) |
|---|
| 3654 | { |
|---|
| 3655 | char wl_mode[16]; |
|---|
| 3656 | char wl_macaddr[16]; |
|---|
| 3657 | char wl_ssid[16]; |
|---|
| 3658 | |
|---|
| 3659 | sprintf( wl_mode, "%s_mode", prefix ); |
|---|
| 3660 | sprintf( wl_macaddr, "%s_hwaddr", prefix ); |
|---|
| 3661 | sprintf( wl_ssid, "%s_ssid", prefix ); |
|---|
| 3662 | |
|---|
| 3663 | // wireless mode |
|---|
| 3664 | websWrite( wp, |
|---|
| 3665 | "<h2><script type=\"text/javascript\">Capture(wl_basic.h2_v24)</script> %s</h2>\n", |
|---|
| 3666 | prefix ); |
|---|
| 3667 | websWrite( wp, "<fieldset>\n" ); |
|---|
| 3668 | websWrite( wp, "<legend><script type=\"text/javascript\">Capture(share.pintrface)</script> %s - SSID [", prefix ), tf_webWriteESCNV( wp, wl_ssid ); // fix |
|---|
| 3669 | // for |
|---|
| 3670 | // broken |
|---|
| 3671 | // html |
|---|
| 3672 | // page |
|---|
| 3673 | // if |
|---|
| 3674 | // ssid |
|---|
| 3675 | // contains |
|---|
| 3676 | // html |
|---|
| 3677 | // tag |
|---|
| 3678 | websWrite( wp, "] HWAddr [%s]</legend>\n", nvram_safe_get( wl_macaddr ) ); |
|---|
| 3679 | char power[16]; |
|---|
| 3680 | |
|---|
| 3681 | // char maxpower[16]; |
|---|
| 3682 | #ifdef HAVE_MADWIFI |
|---|
| 3683 | char wl_regdomain[16]; |
|---|
| 3684 | |
|---|
| 3685 | sprintf( wl_regdomain, "%s_regdomain", prefix ); |
|---|
| 3686 | if( nvram_match( "ath_regulatory", "1" ) || !issuperchannel( ) ) |
|---|
| 3687 | { |
|---|
| 3688 | websWrite( wp, |
|---|
| 3689 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.regdom)</script></div>\n" ); |
|---|
| 3690 | char *list = getCountryList( ); |
|---|
| 3691 | |
|---|
| 3692 | showOptions( wp, wl_regdomain, list, nvram_safe_get( wl_regdomain ) ); |
|---|
| 3693 | websWrite( wp, "</div>\n" ); |
|---|
| 3694 | } |
|---|
| 3695 | /* |
|---|
| 3696 | * while (regdomains[domcount].name != NULL) { char domcode[16]; sprintf |
|---|
| 3697 | * (domcode, "%d", regdomains[domcount].code); websWrite (wp, "<option |
|---|
| 3698 | * value=\"%d\" %s>%s</option>\n", regdomains[domcount].code, nvram_match |
|---|
| 3699 | * (wl_regdomain, domcode) ? " selected=\"selected\"" : "", |
|---|
| 3700 | * regdomains[domcount].name); domcount++; } websWrite (wp, |
|---|
| 3701 | * "</select>\n"); websWrite (wp, "</div>\n"); |
|---|
| 3702 | */ |
|---|
| 3703 | // power adjustment |
|---|
| 3704 | sprintf( power, "%s_txpwrdbm", prefix ); |
|---|
| 3705 | // sprintf (maxpower, "%s_maxpower", prefix); |
|---|
| 3706 | if( !strcmp( prefix, "ath0" ) && issuperchannel( ) ) // show |
|---|
| 3707 | // client |
|---|
| 3708 | // only on |
|---|
| 3709 | // first |
|---|
| 3710 | // interface |
|---|
| 3711 | { |
|---|
| 3712 | |
|---|
| 3713 | websWrite( wp, " <div class=\"setting\">\n" ); |
|---|
| 3714 | websWrite( wp, |
|---|
| 3715 | " <div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.regulatory)</script></div>\n" ); |
|---|
| 3716 | websWrite( wp, |
|---|
| 3717 | " <input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"ath_regulatory\" %s /><script type=\"text/javascript\">Capture(share.enable)</script> \n", |
|---|
| 3718 | nvram_match( "ath_regulatory", "0" ) ? "checked" : "" ); |
|---|
| 3719 | websWrite( wp, |
|---|
| 3720 | " <input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"ath_regulatory\" %s /><script type=\"text/javascript\">Capture(share.disable)</script>\n", |
|---|
| 3721 | nvram_match( "ath_regulatory", "1" ) ? "checked" : "" ); |
|---|
| 3722 | websWrite( wp, " </div>\n" ); |
|---|
| 3723 | |
|---|
| 3724 | } |
|---|
| 3725 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3726 | websWrite( wp, |
|---|
| 3727 | "<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", |
|---|
| 3728 | power, |
|---|
| 3729 | atoi( nvram_safe_get( power ) ) + |
|---|
| 3730 | wifi_gettxpoweroffset( prefix ) ); |
|---|
| 3731 | websWrite( wp, "</div>\n" ); |
|---|
| 3732 | sprintf( power, "%s_antgain", prefix ); |
|---|
| 3733 | #ifndef HAVE_MAKSAT |
|---|
| 3734 | if( nvram_match( "ath_regulatory", "1" ) ) |
|---|
| 3735 | #endif |
|---|
| 3736 | { |
|---|
| 3737 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3738 | websWrite( wp, |
|---|
| 3739 | "<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", |
|---|
| 3740 | power, nvram_safe_get( power ) ); |
|---|
| 3741 | websWrite( wp, "</div>\n" ); |
|---|
| 3742 | } |
|---|
| 3743 | #endif |
|---|
| 3744 | |
|---|
| 3745 | #ifdef HAVE_MADWIFI |
|---|
| 3746 | // if (!strcmp (prefix, "ath0")) |
|---|
| 3747 | #endif |
|---|
| 3748 | { |
|---|
| 3749 | // #ifdef HAVE_MADWIFI |
|---|
| 3750 | // if (!strcmp (prefix, "ath0")) //show client only on first |
|---|
| 3751 | // interface |
|---|
| 3752 | // #endif |
|---|
| 3753 | { |
|---|
| 3754 | #ifdef HAVE_MADWIFI |
|---|
| 3755 | // if (!strcmp (prefix, "ath0")) //show client only on first |
|---|
| 3756 | // interface |
|---|
| 3757 | // if (nvram_match ("ath0_mode", "wdsap") |
|---|
| 3758 | // || nvram_match ("ath0_mode", "wdssta")) |
|---|
| 3759 | // showOption (wp, "wl_basic.wifi_bonding", "wifi_bonding"); |
|---|
| 3760 | #endif |
|---|
| 3761 | websWrite( wp, |
|---|
| 3762 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label)</script></div><select name=\"%s\" >\n", |
|---|
| 3763 | wl_mode ); |
|---|
| 3764 | websWrite( wp, |
|---|
| 3765 | "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 3766 | websWrite( wp, |
|---|
| 3767 | "document.write(\"<option value=\\\"ap\\\" %s >\" + wl_basic.ap + \"</option>\");\n", |
|---|
| 3768 | nvram_match( wl_mode, |
|---|
| 3769 | "ap" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3770 | "" ); |
|---|
| 3771 | #ifndef HAVE_RT2880 |
|---|
| 3772 | websWrite( wp, |
|---|
| 3773 | "document.write(\"<option value=\\\"sta\\\" %s >\" + wl_basic.client + \"</option>\");\n", |
|---|
| 3774 | nvram_match( wl_mode, |
|---|
| 3775 | "sta" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3776 | "" ); |
|---|
| 3777 | websWrite( wp, |
|---|
| 3778 | "document.write(\"<option value=\\\"wet\\\" %s >\" + wl_basic.clientBridge + \"</option>\");\n", |
|---|
| 3779 | nvram_match( wl_mode, |
|---|
| 3780 | "wet" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3781 | "" ); |
|---|
| 3782 | websWrite( wp, |
|---|
| 3783 | "document.write(\"<option value=\\\"infra\\\" %s >\" + wl_basic.adhoc + \"</option>\");\n", |
|---|
| 3784 | nvram_match( wl_mode, |
|---|
| 3785 | "infra" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3786 | "" ); |
|---|
| 3787 | #endif |
|---|
| 3788 | #ifndef HAVE_MADWIFI |
|---|
| 3789 | websWrite( wp, |
|---|
| 3790 | "document.write(\"<option value=\\\"apsta\\\" %s >\" + wl_basic.repeater + \"</option>\");\n", |
|---|
| 3791 | nvram_match( wl_mode, |
|---|
| 3792 | "apsta" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3793 | "" ); |
|---|
| 3794 | #ifndef HAVE_RT2880 |
|---|
| 3795 | websWrite( wp, |
|---|
| 3796 | "document.write(\"<option value=\\\"apstawet\\\" %s >\" + wl_basic.repeaterbridge + \"</option>\");\n", |
|---|
| 3797 | nvram_match( wl_mode, |
|---|
| 3798 | "apstawet" ) ? "selected=\\\"selected\\\"" |
|---|
| 3799 | : "" ); |
|---|
| 3800 | #endif |
|---|
| 3801 | #else |
|---|
| 3802 | websWrite( wp, |
|---|
| 3803 | "document.write(\"<option value=\\\"wdssta\\\" %s >\" + wl_basic.wdssta + \"</option>\");\n", |
|---|
| 3804 | nvram_match( wl_mode, |
|---|
| 3805 | "wdssta" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3806 | "" ); |
|---|
| 3807 | websWrite( wp, |
|---|
| 3808 | "document.write(\"<option value=\\\"wdsap\\\" %s >\" + wl_basic.wdsap + \"</option>\");\n", |
|---|
| 3809 | nvram_match( wl_mode, |
|---|
| 3810 | "wdsap" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3811 | "" ); |
|---|
| 3812 | #endif |
|---|
| 3813 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3814 | websWrite( wp, "</select>\n" ); |
|---|
| 3815 | websWrite( wp, "</div>\n" ); |
|---|
| 3816 | } |
|---|
| 3817 | /* |
|---|
| 3818 | * #ifdef HAVE_MADWIFI else { |
|---|
| 3819 | * |
|---|
| 3820 | * |
|---|
| 3821 | * websWrite (wp, "<div class=\"setting\"><div |
|---|
| 3822 | * class=\"label\"><script |
|---|
| 3823 | * type=\"text/javascript\">Capture(wl_basic.label)</script></div><select |
|---|
| 3824 | * name=\"%s\">\n", wl_mode); websWrite (wp, "<script |
|---|
| 3825 | * type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option |
|---|
| 3826 | * value=\\\"ap\\\" %s >\" + wl_basic.ap + |
|---|
| 3827 | * \"</option>\");\n//]]>\n</script>\n", nvram_match (wl_mode, "ap") |
|---|
| 3828 | * ? "selected=\\\"selected\\\"" : ""); websWrite (wp, "<script |
|---|
| 3829 | * type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option |
|---|
| 3830 | * value=\\\"infra\\\" %s >\" + wl_basic.adhoc + |
|---|
| 3831 | * \"</option>\");\n//]]>\n</script>\n", nvram_match (wl_mode, |
|---|
| 3832 | * "infra") ? "selected=\\\"selected\\\"" : ""); websWrite (wp, |
|---|
| 3833 | * "<script type=\"text/javascript\">\n//<![CDATA[\n |
|---|
| 3834 | * document.write(\"<option value=\\\"wdssta\\\" %s >\" + |
|---|
| 3835 | * wl_basic.wdssta + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 3836 | * nvram_match (wl_mode, "wdssta") ? "selected=\\\"selected\\\"" : |
|---|
| 3837 | * ""); websWrite (wp, "<script |
|---|
| 3838 | * type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option |
|---|
| 3839 | * value=\\\"wdsap\\\" %s >\" + wl_basic.wdsap + |
|---|
| 3840 | * \"</option>\");\n//]]>\n</script>\n", nvram_match (wl_mode, |
|---|
| 3841 | * "wdsap") ? "selected=\\\"selected\\\"" : ""); websWrite (wp, |
|---|
| 3842 | * "</select>\n"); websWrite (wp, "</div>\n"); } #endif |
|---|
| 3843 | */ |
|---|
| 3844 | } |
|---|
| 3845 | // writeless net mode |
|---|
| 3846 | show_netmode( wp, prefix ); |
|---|
| 3847 | // turbo options |
|---|
| 3848 | #ifdef HAVE_MADWIFI |
|---|
| 3849 | |
|---|
| 3850 | // char wl_xchanmode[16]; |
|---|
| 3851 | char wl_outdoor[16]; |
|---|
| 3852 | char wl_diversity[16]; |
|---|
| 3853 | char wl_rxantenna[16]; |
|---|
| 3854 | char wl_txantenna[16]; |
|---|
| 3855 | char wl_width[16]; |
|---|
| 3856 | char wl_preamble[16]; |
|---|
| 3857 | char wl_xr[16]; |
|---|
| 3858 | char wl_comp[32]; |
|---|
| 3859 | char wl_ff[16]; |
|---|
| 3860 | char wmm[32]; |
|---|
| 3861 | char wl_isolate[32]; |
|---|
| 3862 | char wl_sifstime[32]; |
|---|
| 3863 | char wl_preambletime[32]; |
|---|
| 3864 | char wl_intmit[32]; |
|---|
| 3865 | char wl_noise_immunity[32]; |
|---|
| 3866 | char wl_ofdm_weak_det[32]; |
|---|
| 3867 | char wl_protmode[32]; |
|---|
| 3868 | char wl_doth[32]; |
|---|
| 3869 | |
|---|
| 3870 | sprintf( wl_doth, "%s_doth", prefix ); |
|---|
| 3871 | sprintf( wl_protmode, "%s_protmode", prefix ); |
|---|
| 3872 | sprintf( wl_outdoor, "%s_outdoor", prefix ); |
|---|
| 3873 | sprintf( wl_diversity, "%s_diversity", prefix ); |
|---|
| 3874 | sprintf( wl_rxantenna, "%s_rxantenna", prefix ); |
|---|
| 3875 | sprintf( wl_txantenna, "%s_txantenna", prefix ); |
|---|
| 3876 | sprintf( wl_width, "%s_channelbw", prefix ); |
|---|
| 3877 | // sprintf( wl_comp, "%s_compression", prefix ); |
|---|
| 3878 | sprintf( wl_ff, "%s_ff", prefix ); |
|---|
| 3879 | sprintf( wl_preamble, "%s_preamble", prefix ); |
|---|
| 3880 | sprintf( wl_preambletime, "%s_preambletime", prefix ); |
|---|
| 3881 | sprintf( wl_sifstime, "%s_sifstime", prefix ); |
|---|
| 3882 | sprintf( wl_xr, "%s_xr", prefix ); |
|---|
| 3883 | |
|---|
| 3884 | sprintf( wl_intmit, "%s_intmit", prefix ); |
|---|
| 3885 | sprintf( wl_noise_immunity, "%s_noise_immunity", prefix ); |
|---|
| 3886 | sprintf( wl_ofdm_weak_det, "%s_ofdm_weak_det", prefix ); |
|---|
| 3887 | showAutoOption( wp, "wl_basic.intmit", wl_intmit ); |
|---|
| 3888 | |
|---|
| 3889 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3890 | websWrite( wp, |
|---|
| 3891 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.noise_immunity)</script></div>\n<select name=\"%s\">\n", |
|---|
| 3892 | wl_noise_immunity ); |
|---|
| 3893 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 3894 | websWrite( wp, |
|---|
| 3895 | "document.write(\"<option value=\\\"-1\\\" %s >\" + share.auto + \"</option>\");\n", |
|---|
| 3896 | nvram_default_match( wl_noise_immunity, "-1", |
|---|
| 3897 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3898 | "" ); |
|---|
| 3899 | websWrite( wp, |
|---|
| 3900 | "document.write(\"<option value=\\\"0\\\" %s >0</option>\");\n", |
|---|
| 3901 | nvram_default_match( wl_noise_immunity, "0", |
|---|
| 3902 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3903 | "" ); |
|---|
| 3904 | websWrite( wp, |
|---|
| 3905 | "document.write(\"<option value=\\\"1\\\" %s >1</option>\");\n", |
|---|
| 3906 | nvram_default_match( wl_noise_immunity, "1", |
|---|
| 3907 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3908 | "" ); |
|---|
| 3909 | websWrite( wp, |
|---|
| 3910 | "document.write(\"<option value=\\\"2\\\" %s >2</option>\");\n", |
|---|
| 3911 | nvram_default_match( wl_noise_immunity, "2", |
|---|
| 3912 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3913 | "" ); |
|---|
| 3914 | websWrite( wp, |
|---|
| 3915 | "document.write(\"<option value=\\\"3\\\" %s >3</option>\");\n", |
|---|
| 3916 | nvram_default_match( wl_noise_immunity, "3", |
|---|
| 3917 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3918 | "" ); |
|---|
| 3919 | websWrite( wp, |
|---|
| 3920 | "document.write(\"<option value=\\\"4\\\" %s >4</option>\");\n", |
|---|
| 3921 | nvram_default_match( wl_noise_immunity, "4", |
|---|
| 3922 | "0" ) ? "selected=\\\"selected\\\"" : |
|---|
| 3923 | "" ); |
|---|
| 3924 | websWrite( wp, "//]]>\n</script>\n</select>\n</div>\n" ); |
|---|
| 3925 | |
|---|
| 3926 | showRadio( wp, "wl_basic.ofdm_weak_det", wl_ofdm_weak_det ); |
|---|
| 3927 | |
|---|
| 3928 | showOptionsLabel( wp, "wl_basic.protmode", wl_protmode, |
|---|
| 3929 | "None CTS RTS/CTS", nvram_default_get( wl_protmode, |
|---|
| 3930 | "None" ) ); |
|---|
| 3931 | showrtssettings( wp, prefix ); |
|---|
| 3932 | show_rates( wp, prefix, 0 ); |
|---|
| 3933 | show_rates( wp, prefix, 1 ); |
|---|
| 3934 | showRadio( wp, "wl_basic.preamble", wl_preamble ); |
|---|
| 3935 | showRadio( wp, "wl_basic.extrange", wl_xr ); |
|---|
| 3936 | // showRadio( wp, "wl_basic.supergcomp", wl_comp ); |
|---|
| 3937 | showRadio( wp, "wl_basic.supergff", wl_ff ); |
|---|
| 3938 | |
|---|
| 3939 | // showOption (wp, "wl_basic.extchannel", wl_xchanmode); |
|---|
| 3940 | #if !defined(HAVE_FONERA) && !defined(HAVE_LS2) && !defined(HAVE_MERAKI) |
|---|
| 3941 | if( nvram_match( "ath_regulatory", "1" ) || !issuperchannel( ) ) |
|---|
| 3942 | { |
|---|
| 3943 | showRadio( wp, "wl_basic.outband", wl_outdoor ); |
|---|
| 3944 | } |
|---|
| 3945 | #endif |
|---|
| 3946 | websWrite( wp, |
|---|
| 3947 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_width)</script></div><select name=\"%s\" >\n", |
|---|
| 3948 | wl_width ); |
|---|
| 3949 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 3950 | websWrite( wp, |
|---|
| 3951 | "document.write(\"<option value=\\\"40\\\" %s >\" + share.turbo + \"</option>\");\n", |
|---|
| 3952 | nvram_match( wl_width, |
|---|
| 3953 | "40" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3954 | websWrite( wp, |
|---|
| 3955 | "document.write(\"<option value=\\\"20\\\" %s >\" + share.full + \"</option>\");\n", |
|---|
| 3956 | nvram_match( wl_width, |
|---|
| 3957 | "20" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3958 | websWrite( wp, |
|---|
| 3959 | "document.write(\"<option value=\\\"10\\\" %s >\" + share.half + \"</option>\");\n", |
|---|
| 3960 | nvram_match( wl_width, |
|---|
| 3961 | "10" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3962 | websWrite( wp, |
|---|
| 3963 | "document.write(\"<option value=\\\"5\\\" %s >\" + share.quarter + \"</option>\");\n", |
|---|
| 3964 | nvram_match( wl_width, |
|---|
| 3965 | "5" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3966 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3967 | websWrite( wp, "</select>\n" ); |
|---|
| 3968 | websWrite( wp, "</div>\n" ); |
|---|
| 3969 | |
|---|
| 3970 | #if defined(HAVE_NS2) || defined(HAVE_NS5) |
|---|
| 3971 | |
|---|
| 3972 | websWrite( wp, |
|---|
| 3973 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label24)</script></div><select name=\"%s\" >\n", |
|---|
| 3974 | wl_txantenna ); |
|---|
| 3975 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 3976 | websWrite( wp, |
|---|
| 3977 | "document.write(\"<option value=\\\"0\\\" %s >\" + wl_basic.vertical + \"</option>\");\n", |
|---|
| 3978 | nvram_match( wl_txantenna, |
|---|
| 3979 | "0" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3980 | websWrite( wp, |
|---|
| 3981 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.horizontal + \"</option>\");\n", |
|---|
| 3982 | nvram_match( wl_txantenna, |
|---|
| 3983 | "1" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3984 | websWrite( wp, |
|---|
| 3985 | "document.write(\"<option value=\\\"3\\\" %s >\" + wl_basic.adaptive + \"</option>\");\n", |
|---|
| 3986 | nvram_match( wl_txantenna, |
|---|
| 3987 | "3" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3988 | websWrite( wp, |
|---|
| 3989 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.external + \"</option>\");\n", |
|---|
| 3990 | nvram_match( wl_txantenna, |
|---|
| 3991 | "2" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 3992 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3993 | websWrite( wp, "</select>\n" ); |
|---|
| 3994 | websWrite( wp, "</div>\n" ); |
|---|
| 3995 | |
|---|
| 3996 | #else |
|---|
| 3997 | showRadio( wp, "wl_basic.diversity", wl_diversity ); |
|---|
| 3998 | websWrite( wp, |
|---|
| 3999 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label12)</script></div><select name=\"%s\" >\n", |
|---|
| 4000 | wl_txantenna ); |
|---|
| 4001 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 4002 | websWrite( wp, |
|---|
| 4003 | "document.write(\"<option value=\\\"0\\\" %s >\" + wl_basic.diversity + \"</option>\");\n", |
|---|
| 4004 | nvram_match( wl_txantenna, |
|---|
| 4005 | "0" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 4006 | websWrite( wp, |
|---|
| 4007 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.primary + \"</option>\");\n", |
|---|
| 4008 | nvram_match( wl_txantenna, |
|---|
| 4009 | "1" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 4010 | websWrite( wp, |
|---|
| 4011 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.secondary + \"</option>\");\n", |
|---|
| 4012 | nvram_match( wl_txantenna, |
|---|
| 4013 | "2" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 4014 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4015 | websWrite( wp, "</select>\n" ); |
|---|
| 4016 | websWrite( wp, "</div>\n" ); |
|---|
| 4017 | |
|---|
| 4018 | websWrite( wp, |
|---|
| 4019 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label13)</script></div><select name=\"%s\" >\n", |
|---|
| 4020 | wl_rxantenna ); |
|---|
| 4021 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n" ); |
|---|
| 4022 | websWrite( wp, |
|---|
| 4023 | "document.write(\"<option value=\\\"0\\\" %s >\" + wl_basic.diversity + \"</option>\");\n", |
|---|
| 4024 | nvram_match( wl_rxantenna, |
|---|
| 4025 | "0" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 4026 | websWrite( wp, |
|---|
| 4027 | "document.write(\"<option value=\\\"1\\\" %s >\" + wl_basic.primary + \"</option>\");\n", |
|---|
| 4028 | nvram_match( wl_rxantenna, |
|---|
| 4029 | "1" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 4030 | websWrite( wp, |
|---|
| 4031 | "document.write(\"<option value=\\\"2\\\" %s >\" + wl_basic.secondary + \"</option>\");\n", |
|---|
| 4032 | nvram_match( wl_rxantenna, |
|---|
| 4033 | "2" ) ? "selected=\\\"selected\\\"" : "" ); |
|---|
| 4034 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4035 | websWrite( wp, "</select>\n" ); |
|---|
| 4036 | websWrite( wp, "</div>\n" ); |
|---|
| 4037 | #endif |
|---|
| 4038 | #endif |
|---|
| 4039 | #ifdef HAVE_MADWIFI |
|---|
| 4040 | sprintf( wl_isolate, "%s_ap_isolate", prefix ); |
|---|
| 4041 | showRadio( wp, "wl_adv.label11", wl_isolate ); |
|---|
| 4042 | |
|---|
| 4043 | #if 0 |
|---|
| 4044 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4045 | websWrite( wp, |
|---|
| 4046 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.sifstime)</script></div>\n" ); |
|---|
| 4047 | websWrite( wp, |
|---|
| 4048 | "<input class=\"num\" name=\"%s\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,99999999,wl_basic.sifstime)\" value=\"%s\" />\n", |
|---|
| 4049 | wl_sifstime, nvram_default_get( wl_sifstime, "16" ) ); |
|---|
| 4050 | websWrite( wp, "</div>\n" ); |
|---|
| 4051 | |
|---|
| 4052 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4053 | websWrite( wp, |
|---|
| 4054 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.preambletime)</script></div>\n" ); |
|---|
| 4055 | websWrite( wp, |
|---|
| 4056 | "<input class=\"num\" name=\"%s\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,99999999,wl_basic.preambletime)\" value=\"%s\" />\n", |
|---|
| 4057 | wl_preambletime, nvram_default_get( wl_preambletime, "20" ) ); |
|---|
| 4058 | websWrite( wp, "</div>\n" ); |
|---|
| 4059 | #endif |
|---|
| 4060 | sprintf( wmm, "%s_wmm", prefix ); |
|---|
| 4061 | showRadio( wp, "wl_adv.label18", wmm ); |
|---|
| 4062 | #endif |
|---|
| 4063 | |
|---|
| 4064 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4065 | websWrite( wp, |
|---|
| 4066 | "<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", |
|---|
| 4067 | wl_ssid, nvram_safe_get( wl_ssid ) ); |
|---|
| 4068 | |
|---|
| 4069 | #ifdef HAVE_MADWIFI |
|---|
| 4070 | showRadio( wp, "wl_basic.radar", wl_doth ); |
|---|
| 4071 | show_chanshift( wp, prefix ); |
|---|
| 4072 | #endif |
|---|
| 4073 | if( nvram_match( wl_mode, "ap" ) || nvram_match( wl_mode, "wdsap" ) |
|---|
| 4074 | || nvram_match( wl_mode, "infra" ) ) |
|---|
| 4075 | { |
|---|
| 4076 | |
|---|
| 4077 | if( has_mimo( prefix ) |
|---|
| 4078 | && ( nvram_nmatch( "n-only", "%s_net_mode", prefix ) |
|---|
| 4079 | || nvram_nmatch( "mixed," "%s_net_mode", prefix ) |
|---|
| 4080 | || nvram_nmatch( "na-only", "%s_net_mode", prefix ) ) ) |
|---|
| 4081 | { |
|---|
| 4082 | |
|---|
| 4083 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4084 | websWrite( wp, |
|---|
| 4085 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_width)</script></div>\n" ); |
|---|
| 4086 | websWrite( wp, "<select name=\"%s_nbw\">\n", prefix ); |
|---|
| 4087 | #ifdef HAVE_RT2880 |
|---|
| 4088 | websWrite( wp, |
|---|
| 4089 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"20\\\" %s >20 Mhz</option>\");\n//]]>\n</script>\n", |
|---|
| 4090 | nvram_nmatch( "20", "%s_nbw", |
|---|
| 4091 | prefix ) ? "selected=\\\"selected\\\"" : |
|---|
| 4092 | "" ); |
|---|
| 4093 | websWrite( wp, "<option value=\"40\" %s>40 MHz</option>", |
|---|
| 4094 | nvram_nmatch( "40", "%s_nbw", |
|---|
| 4095 | prefix ) ? "selected=\\\"selected\\\"" : |
|---|
| 4096 | "" ); |
|---|
| 4097 | #else |
|---|
| 4098 | websWrite( wp, |
|---|
| 4099 | "<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"0\\\" %s >\" + share.auto + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 4100 | nvram_nmatch( "0", "%s_nbw", |
|---|
| 4101 | prefix ) ? "selected=\\\"selected\\\"" : |
|---|
| 4102 | "" ); |
|---|
| 4103 | websWrite( wp, "<option value=\"10\" %s>10 MHz</option>", |
|---|
| 4104 | nvram_nmatch( "10", "%s_nbw", |
|---|
| 4105 | prefix ) ? "selected=\\\"selected\\\"" : |
|---|
| 4106 | "" ); |
|---|
| 4107 | websWrite( wp, "<option value=\"20\" %s>20 MHz</option>", |
|---|
| 4108 | nvram_nmatch( "20", "%s_nbw", |
|---|
| 4109 | prefix ) ? "selected=\\\"selected\\\"" : |
|---|
| 4110 | "" ); |
|---|
| 4111 | websWrite( wp, "<option value=\"40\" %s>40 MHz</option>", |
|---|
| 4112 | nvram_nmatch( "40", "%s_nbw", |
|---|
| 4113 | prefix ) ? "selected=\\\"selected\\\"" : |
|---|
| 4114 | "" ); |
|---|
| 4115 | #endif |
|---|
| 4116 | websWrite( wp, "</select>\n" ); |
|---|
| 4117 | websWrite( wp, "</div>\n" ); |
|---|
| 4118 | |
|---|
| 4119 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4120 | websWrite( wp, |
|---|
| 4121 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.channel_wide)</script></div>\n" ); |
|---|
| 4122 | websWrite( wp, "<select name=\"%s_wchannel\" ></select>\n", |
|---|
| 4123 | prefix ); |
|---|
| 4124 | websWrite( wp, "</div>\n" ); |
|---|
| 4125 | |
|---|
| 4126 | show_channel( wp, prefix, prefix, 1 ); |
|---|
| 4127 | } |
|---|
| 4128 | else |
|---|
| 4129 | |
|---|
| 4130 | show_channel( wp, prefix, prefix, 0 ); |
|---|
| 4131 | |
|---|
| 4132 | char wl_closed[16]; |
|---|
| 4133 | |
|---|
| 4134 | sprintf( wl_closed, "%s_closed", prefix ); |
|---|
| 4135 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4136 | websWrite( wp, |
|---|
| 4137 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label5)</script></div>\n" ); |
|---|
| 4138 | websWrite( wp, |
|---|
| 4139 | "<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input> \n", |
|---|
| 4140 | wl_closed, nvram_match( wl_closed, |
|---|
| 4141 | "0" ) ? "checked=\"checked\"" : |
|---|
| 4142 | "" ); |
|---|
| 4143 | websWrite( wp, |
|---|
| 4144 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input>\n", |
|---|
| 4145 | wl_closed, nvram_match( wl_closed, |
|---|
| 4146 | "1" ) ? "checked=\"checked\"" : |
|---|
| 4147 | "" ); |
|---|
| 4148 | websWrite( wp, "</div>\n" ); |
|---|
| 4149 | } |
|---|
| 4150 | #ifdef HAVE_MADWIFI |
|---|
| 4151 | // if (nvram_match (wl_mode, "sta") || nvram_match (wl_mode, "wdssta") |
|---|
| 4152 | // || nvram_match (wl_mode, "wet")) |
|---|
| 4153 | { |
|---|
| 4154 | char wl_scanlist[32]; |
|---|
| 4155 | |
|---|
| 4156 | sprintf( wl_scanlist, "%s_scanlist", prefix ); |
|---|
| 4157 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4158 | websWrite( wp, |
|---|
| 4159 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.scanlist)</script></div>\n" ); |
|---|
| 4160 | websWrite( wp, |
|---|
| 4161 | "<input name=\"%s\" size=\"32\" maxlength=\"512\" value=\"%s\" />\n", |
|---|
| 4162 | wl_scanlist, nvram_default_get( wl_scanlist, "default" ) ); |
|---|
| 4163 | websWrite( wp, "</div>\n" ); |
|---|
| 4164 | } |
|---|
| 4165 | #endif |
|---|
| 4166 | |
|---|
| 4167 | // ACK timing |
|---|
| 4168 | #if defined(HAVE_ACK) || defined(HAVE_MADWIFI) // temp fix for v24 broadcom |
|---|
| 4169 | // ACKnot working |
|---|
| 4170 | |
|---|
| 4171 | sprintf( power, "%s_distance", prefix ); |
|---|
| 4172 | websWrite( wp, "<br />\n" ); |
|---|
| 4173 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4174 | websWrite( wp, |
|---|
| 4175 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label6)</script></div>\n" ); |
|---|
| 4176 | websWrite( wp, |
|---|
| 4177 | "<input class=\"num\" name=\"%s\" size=\"8\" maxlength=\"8\" onblur=\"valid_range(this,0,99999999,wl_basic.label6)\" value=\"%s\" />\n", |
|---|
| 4178 | power, nvram_default_get( power, "2000" ) ); |
|---|
| 4179 | websWrite( wp, |
|---|
| 4180 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 2000 \" + share.meters + \")\");\n//]]>\n</script></span>\n" ); |
|---|
| 4181 | websWrite( wp, "</div>\n" ); |
|---|
| 4182 | // end ACK timing |
|---|
| 4183 | #endif |
|---|
| 4184 | #ifdef HAVE_MADWIFI |
|---|
| 4185 | showbridgesettings( wp, prefix, 1 ); |
|---|
| 4186 | #elif HAVE_RT2880 |
|---|
| 4187 | showbridgesettings( wp, "ra0", 1 ); |
|---|
| 4188 | #else |
|---|
| 4189 | if( !strcmp( prefix, "wl0" ) ) |
|---|
| 4190 | showbridgesettings( wp, get_wl_instance_name( 0 ), 1 ); |
|---|
| 4191 | if( !strcmp( prefix, "wl1" ) ) |
|---|
| 4192 | showbridgesettings( wp, get_wl_instance_name( 1 ), 1 ); |
|---|
| 4193 | #endif |
|---|
| 4194 | websWrite( wp, "</fieldset>\n" ); |
|---|
| 4195 | websWrite( wp, "<br />\n" ); |
|---|
| 4196 | show_virtualssid( wp, prefix ); |
|---|
| 4197 | } |
|---|
| 4198 | |
|---|
| 4199 | void ej_show_wireless( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4200 | { |
|---|
| 4201 | #ifdef HAVE_MADWIFI |
|---|
| 4202 | int c = getdevicecount( ); |
|---|
| 4203 | int i; |
|---|
| 4204 | |
|---|
| 4205 | for( i = 0; i < c; i++ ) |
|---|
| 4206 | { |
|---|
| 4207 | char buf[16]; |
|---|
| 4208 | |
|---|
| 4209 | sprintf( buf, "ath%d", i ); |
|---|
| 4210 | ej_show_wireless_single( wp, buf ); |
|---|
| 4211 | } |
|---|
| 4212 | #else |
|---|
| 4213 | int c = get_wl_instances( ); |
|---|
| 4214 | int i; |
|---|
| 4215 | |
|---|
| 4216 | for( i = 0; i < c; i++ ) |
|---|
| 4217 | { |
|---|
| 4218 | char buf[16]; |
|---|
| 4219 | |
|---|
| 4220 | sprintf( buf, "wl%d", i ); |
|---|
| 4221 | ej_show_wireless_single( wp, buf ); |
|---|
| 4222 | } |
|---|
| 4223 | #endif |
|---|
| 4224 | return; |
|---|
| 4225 | } |
|---|
| 4226 | |
|---|
| 4227 | void show_preshared( webs_t wp, char *prefix ) |
|---|
| 4228 | { |
|---|
| 4229 | char var[80]; |
|---|
| 4230 | |
|---|
| 4231 | cprintf( "show preshared" ); |
|---|
| 4232 | sprintf( var, "%s_crypto", prefix ); |
|---|
| 4233 | websWrite( wp, "<div><div class=\"setting\">\n" ); |
|---|
| 4234 | websWrite( wp, |
|---|
| 4235 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.algorithms)</script></div>\n" ); |
|---|
| 4236 | websWrite( wp, "<select name=\"%s_crypto\">\n", prefix ); |
|---|
| 4237 | websWrite( wp, "<option value=\"tkip\" %s>TKIP</option>\n", |
|---|
| 4238 | selmatch( var, "tkip", "selected=\"selected\"" ) ); |
|---|
| 4239 | websWrite( wp, "<option value=\"aes\" %s>AES</option>\n", |
|---|
| 4240 | selmatch( var, "aes", "selected=\"selected\"" ) ); |
|---|
| 4241 | websWrite( wp, "<option value=\"tkip+aes\" %s>TKIP+AES</option>\n", |
|---|
| 4242 | selmatch( var, "tkip+aes", "selected=\"selected\"" ) ); |
|---|
| 4243 | websWrite( wp, "</select>\n" ); |
|---|
| 4244 | websWrite( wp, "</div>\n" ); |
|---|
| 4245 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4246 | websWrite( wp, |
|---|
| 4247 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.shared_key)</script></div>\n" ); |
|---|
| 4248 | sprintf( var, "%s_wpa_psk", prefix ); |
|---|
| 4249 | websWrite( wp, |
|---|
| 4250 | "<input type=\"password\" id=\"%s_wpa_psk\" name=\"%s_wpa_psk\" onblur=\"valid_psk_length(this)\" maxlength=\"64\" size=\"32\" value=\"", |
|---|
| 4251 | prefix, prefix ); |
|---|
| 4252 | tf_webWriteESCNV( wp, var ); |
|---|
| 4253 | websWrite( wp, "\" /> \n" ); |
|---|
| 4254 | websWrite( wp, |
|---|
| 4255 | "<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", |
|---|
| 4256 | prefix, prefix ); |
|---|
| 4257 | websWrite( wp, "</div>\n" ); |
|---|
| 4258 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4259 | websWrite( wp, |
|---|
| 4260 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.rekey)</script></div>\n" ); |
|---|
| 4261 | sprintf( var, "%s_wpa_gtk_rekey", prefix ); |
|---|
| 4262 | websWrite( wp, |
|---|
| 4263 | "<input class=\"num\" name=\"%s_wpa_gtk_rekey\" maxlength=\"5\" size=\"5\" onblur=\"valid_range(this,0,99999,wpa.rekey)\" value=\"%s\" />\n", |
|---|
| 4264 | prefix, nvram_default_get( var, "3600" ) ); |
|---|
| 4265 | websWrite( wp, |
|---|
| 4266 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 3600, \" + share.range + \": 1 - 99999)\");\n//]]>\n</script></span>\n" ); |
|---|
| 4267 | websWrite( wp, "</div>\n" ); |
|---|
| 4268 | websWrite( wp, "</div>\n" ); |
|---|
| 4269 | } |
|---|
| 4270 | |
|---|
| 4271 | void show_radius( webs_t wp, char *prefix, int showmacformat ) |
|---|
| 4272 | { |
|---|
| 4273 | char var[80]; |
|---|
| 4274 | |
|---|
| 4275 | cprintf( "show radius\n" ); |
|---|
| 4276 | if( showmacformat ) |
|---|
| 4277 | { |
|---|
| 4278 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4279 | websWrite( wp, |
|---|
| 4280 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label2)</script></div>\n" ); |
|---|
| 4281 | websWrite( wp, "<select name=\"%s_radmactype\">\n", prefix ); |
|---|
| 4282 | websWrite( wp, "<option value=\"0\" %s >aabbcc-ddeeff</option>\n", |
|---|
| 4283 | nvram_prefix_match( "radmactype", prefix, |
|---|
| 4284 | "0" ) ? "selected" : "" ); |
|---|
| 4285 | websWrite( wp, "<option value=\"1\" %s >aabbccddeeff</option>\n", |
|---|
| 4286 | nvram_prefix_match( "radmactype", prefix, |
|---|
| 4287 | "1" ) ? "selected" : "" ); |
|---|
| 4288 | websWrite( wp, "<option value=\"2\" %s >aa:bb:cc:dd:ee:ff</option>\n", |
|---|
| 4289 | nvram_prefix_match( "radmactype", prefix, |
|---|
| 4290 | "2" ) ? "selected" : "" ); |
|---|
| 4291 | websWrite( wp, "<option value=\"3\" %s >aa-bb-cc-dd-ee-ff</option>\n", |
|---|
| 4292 | nvram_prefix_match( "radmactype", prefix, |
|---|
| 4293 | "3" ) ? "selected" : "" ); |
|---|
| 4294 | websWrite( wp, "</select>\n" ); |
|---|
| 4295 | websWrite( wp, "</div>\n" ); |
|---|
| 4296 | } |
|---|
| 4297 | char *rad = nvram_nget( "%s_radius_ipaddr", prefix ); |
|---|
| 4298 | |
|---|
| 4299 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4300 | websWrite( wp, |
|---|
| 4301 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label3)</script></div>\n" ); |
|---|
| 4302 | websWrite( wp, |
|---|
| 4303 | "<input type=\"hidden\" name=\"%s_radius_ipaddr\" value=\"4\" />\n", |
|---|
| 4304 | prefix ); |
|---|
| 4305 | websWrite( wp, |
|---|
| 4306 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_0\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4307 | prefix, get_single_ip( rad, 0 ) ); |
|---|
| 4308 | websWrite( wp, |
|---|
| 4309 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_1\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4310 | prefix, get_single_ip( rad, 1 ) ); |
|---|
| 4311 | websWrite( wp, |
|---|
| 4312 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_2\" onblur=\"valid_range(this,0,255,radius.label3)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4313 | prefix, get_single_ip( rad, 2 ) ); |
|---|
| 4314 | websWrite( wp, |
|---|
| 4315 | "<input size=\"3\" maxlength=\"3\" name=\"%s_radius_ipaddr_3\" onblur=\"valid_range(this,1,254,radius.label3)\" class=\"num\" value=\"%d\" />\n", |
|---|
| 4316 | prefix, get_single_ip( rad, 3 ) ); |
|---|
| 4317 | websWrite( wp, "</div>\n" ); |
|---|
| 4318 | |
|---|
| 4319 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4320 | websWrite( wp, |
|---|
| 4321 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label4)</script></div>\n" ); |
|---|
| 4322 | sprintf( var, "%s_radius_port", prefix ); |
|---|
| 4323 | websWrite( wp, |
|---|
| 4324 | "<input name=\"%s_radius_port\" size=\"3\" maxlength=\"5\" onblur=\"valid_range(this,1,65535,radius.label4)\" value=\"%s\" />\n", |
|---|
| 4325 | prefix, nvram_default_get( var, "1812" ) ); |
|---|
| 4326 | websWrite( wp, |
|---|
| 4327 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 1812)\");\n//]]>\n</script></span>\n</div>\n" ); |
|---|
| 4328 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4329 | websWrite( wp, |
|---|
| 4330 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label7)</script></div>\n" ); |
|---|
| 4331 | sprintf( var, "%s_radius_key", prefix ); |
|---|
| 4332 | websWrite( wp, |
|---|
| 4333 | "<input type=\"password\" id=\"%s_radius_key\" name=\"%s_radius_key\" maxlength=\"79\" size=\"32\" value=\"", |
|---|
| 4334 | prefix, prefix ); |
|---|
| 4335 | tf_webWriteESCNV( wp, var ); |
|---|
| 4336 | websWrite( wp, "\" /> \n" ); |
|---|
| 4337 | websWrite( wp, |
|---|
| 4338 | "<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", |
|---|
| 4339 | prefix, prefix ); |
|---|
| 4340 | websWrite( wp, "</div>\n" ); |
|---|
| 4341 | #ifdef HAVE_MADWIFI |
|---|
| 4342 | if( !showmacformat ) |
|---|
| 4343 | { |
|---|
| 4344 | char acct[32]; |
|---|
| 4345 | char vvar[32]; |
|---|
| 4346 | |
|---|
| 4347 | strcpy( vvar, var ); |
|---|
| 4348 | rep( vvar, '.', 'X' ); |
|---|
| 4349 | sprintf( acct, "%s_acct", prefix ); |
|---|
| 4350 | websWrite( wp, |
|---|
| 4351 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label18)</script></div>\n" ); |
|---|
| 4352 | websWrite( wp, |
|---|
| 4353 | "<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", |
|---|
| 4354 | vvar, prefix, nvram_default_match( acct, "1", |
|---|
| 4355 | "0" ) ? |
|---|
| 4356 | "checked=\"checked\"" : "" ); |
|---|
| 4357 | websWrite( wp, |
|---|
| 4358 | "<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", |
|---|
| 4359 | vvar, prefix, nvram_default_match( acct, "0", |
|---|
| 4360 | "0" ) ? |
|---|
| 4361 | "checked=\"checked\"" : "" ); |
|---|
| 4362 | websWrite( wp, "</div>\n" ); |
|---|
| 4363 | char *rad = nvram_nget( "%s_acct_ipaddr", prefix ); |
|---|
| 4364 | |
|---|
| 4365 | websWrite( wp, "<div id=\"%s_idacct\">\n", vvar ); |
|---|
| 4366 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4367 | websWrite( wp, |
|---|
| 4368 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label13)</script></div>\n" ); |
|---|
| 4369 | websWrite( wp, |
|---|
| 4370 | "<input type=\"hidden\" name=\"%s_acct_ipaddr\" value=\"4\" />\n", |
|---|
| 4371 | prefix ); |
|---|
| 4372 | websWrite( wp, |
|---|
| 4373 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_0\" onblur=\"valid_range(this,0,255,radius.label13)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4374 | prefix, get_single_ip( rad, 0 ) ); |
|---|
| 4375 | websWrite( wp, |
|---|
| 4376 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_1\" onblur=\"valid_range(this,0,255,radius.label13)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4377 | prefix, get_single_ip( rad, 1 ) ); |
|---|
| 4378 | websWrite( wp, |
|---|
| 4379 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_2\" onblur=\"valid_range(this,0,255,radius.label13)\" class=\"num\" value=\"%d\" />.", |
|---|
| 4380 | prefix, get_single_ip( rad, 2 ) ); |
|---|
| 4381 | websWrite( wp, |
|---|
| 4382 | "<input size=\"3\" maxlength=\"3\" name=\"%s_acct_ipaddr_3\" onblur=\"valid_range(this,1,254,radius.label13)\" class=\"num\" value=\"%d\" />\n", |
|---|
| 4383 | prefix, get_single_ip( rad, 3 ) ); |
|---|
| 4384 | websWrite( wp, "</div>\n" ); |
|---|
| 4385 | |
|---|
| 4386 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4387 | websWrite( wp, |
|---|
| 4388 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label14)</script></div>\n" ); |
|---|
| 4389 | sprintf( var, "%s_acct_port", prefix ); |
|---|
| 4390 | websWrite( wp, |
|---|
| 4391 | "<input name=\"%s_acct_port\" size=\"3\" maxlength=\"5\" onblur=\"valid_range(this,1,65535,radius.label14)\" value=\"%s\" />\n", |
|---|
| 4392 | prefix, nvram_default_get( var, "1813" ) ); |
|---|
| 4393 | websWrite( wp, |
|---|
| 4394 | "<span class=\"default\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"(\" + share.deflt + \": 1812)\");\n//]]>\n</script></span>\n</div>\n" ); |
|---|
| 4395 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4396 | websWrite( wp, |
|---|
| 4397 | "<div class=\"label\"><script type=\"text/javascript\">Capture(radius.label17)</script></div>\n" ); |
|---|
| 4398 | sprintf( var, "%s_acct_key", prefix ); |
|---|
| 4399 | websWrite( wp, |
|---|
| 4400 | "<input type=\"password\" id=\"%s_acct_key\" name=\"%s_acct_key\" maxlength=\"79\" size=\"32\" value=\"", |
|---|
| 4401 | prefix, prefix ); |
|---|
| 4402 | tf_webWriteESCNV( wp, var ); |
|---|
| 4403 | websWrite( wp, "\" /> \n" ); |
|---|
| 4404 | websWrite( wp, |
|---|
| 4405 | "<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", |
|---|
| 4406 | prefix, prefix ); |
|---|
| 4407 | websWrite( wp, "</div>\n" ); |
|---|
| 4408 | websWrite( wp, "</div>\n" ); |
|---|
| 4409 | websWrite( wp, "<script>\n//<![CDATA[\n " ); |
|---|
| 4410 | websWrite( wp, |
|---|
| 4411 | "show_layer_ext(document.getElementsByName(\"%s_acct\"), \"%s_idacct\", %s);\n", |
|---|
| 4412 | prefix, vvar, nvram_match( acct, |
|---|
| 4413 | "1" ) ? "true" : "false" ); |
|---|
| 4414 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4415 | } |
|---|
| 4416 | #endif |
|---|
| 4417 | } |
|---|
| 4418 | |
|---|
| 4419 | #ifdef HAVE_WPA_SUPPLICANT |
|---|
| 4420 | |
|---|
| 4421 | static void init_80211x_layers( webs_t wp, char *prefix ) |
|---|
| 4422 | { |
|---|
| 4423 | if( nvram_prefix_match( "8021xtype", prefix, "tls" ) ) |
|---|
| 4424 | { |
|---|
| 4425 | websWrite( wp, "enable_idtls(\"%s\");\n", prefix ); |
|---|
| 4426 | } |
|---|
| 4427 | if( nvram_prefix_match( "8021xtype", prefix, "leap" ) ) |
|---|
| 4428 | { |
|---|
| 4429 | websWrite( wp, "enable_idleap(\"%s\");\n", prefix ); |
|---|
| 4430 | } |
|---|
| 4431 | if( nvram_prefix_match( "8021xtype", prefix, "ttls" ) ) |
|---|
| 4432 | { |
|---|
| 4433 | websWrite( wp, "enable_idttls(\"%s\");\n", prefix ); |
|---|
| 4434 | } |
|---|
| 4435 | if( nvram_prefix_match( "8021xtype", prefix, "peap" ) ) |
|---|
| 4436 | { |
|---|
| 4437 | websWrite( wp, "enable_idpeap(\"%s\");\n", prefix ); |
|---|
| 4438 | } |
|---|
| 4439 | } |
|---|
| 4440 | |
|---|
| 4441 | void ej_init_80211x_layers( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4442 | { |
|---|
| 4443 | #ifndef HAVE_MADWIFI |
|---|
| 4444 | int c = get_wl_instances( ); |
|---|
| 4445 | int i; |
|---|
| 4446 | |
|---|
| 4447 | for( i = 0; i < c; i++ ) |
|---|
| 4448 | { |
|---|
| 4449 | char buf[16]; |
|---|
| 4450 | |
|---|
| 4451 | sprintf( buf, "wl%d", i ); |
|---|
| 4452 | init_80211x_layers( wp, buf ); |
|---|
| 4453 | } |
|---|
| 4454 | return; |
|---|
| 4455 | #else |
|---|
| 4456 | int c = getdevicecount( ); |
|---|
| 4457 | int i; |
|---|
| 4458 | |
|---|
| 4459 | for( i = 0; i < c; i++ ) |
|---|
| 4460 | { |
|---|
| 4461 | char buf[16]; |
|---|
| 4462 | |
|---|
| 4463 | sprintf( buf, "ath%d", i ); |
|---|
| 4464 | init_80211x_layers( wp, buf ); |
|---|
| 4465 | } |
|---|
| 4466 | return; |
|---|
| 4467 | #endif |
|---|
| 4468 | |
|---|
| 4469 | } |
|---|
| 4470 | |
|---|
| 4471 | void show_80211X( webs_t wp, char *prefix ) |
|---|
| 4472 | { |
|---|
| 4473 | /* |
|---|
| 4474 | * fields |
|---|
| 4475 | * _8021xtype |
|---|
| 4476 | * _8021xuser |
|---|
| 4477 | * _8021xpasswd |
|---|
| 4478 | * _8021xca |
|---|
| 4479 | * _8021xpem |
|---|
| 4480 | * _8021xprv |
|---|
| 4481 | */ |
|---|
| 4482 | char type[32]; |
|---|
| 4483 | |
|---|
| 4484 | sprintf( type, "%s_8021xtype", prefix ); |
|---|
| 4485 | nvram_default_get( type, "ttls" ); |
|---|
| 4486 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4487 | websWrite( wp, |
|---|
| 4488 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.xsuptype)</script></div>\n" ); |
|---|
| 4489 | websWrite( wp, |
|---|
| 4490 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"peap\" onclick=\"enable_idpeap('%s')\" %s />Peap \n", |
|---|
| 4491 | prefix, prefix, nvram_prefix_match( "8021xtype", prefix, |
|---|
| 4492 | "peap" ) ? |
|---|
| 4493 | "checked=\"checked\"" : "" ); |
|---|
| 4494 | websWrite( wp, |
|---|
| 4495 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"leap\" onclick=\"enable_idleap('%s')\" %s />Leap \n", |
|---|
| 4496 | prefix, prefix, nvram_prefix_match( "8021xtype", prefix, |
|---|
| 4497 | "leap" ) ? |
|---|
| 4498 | "checked=\"checked\"" : "" ); |
|---|
| 4499 | websWrite( wp, |
|---|
| 4500 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"tls\" onclick=\"enable_idtls('%s')\" %s />TLS \n", |
|---|
| 4501 | prefix, prefix, nvram_prefix_match( "8021xtype", prefix, |
|---|
| 4502 | "tls" ) ? |
|---|
| 4503 | "checked=\"checked\"" : "" ); |
|---|
| 4504 | websWrite( wp, |
|---|
| 4505 | "<input class=\"spaceradio\" type=\"radio\" name=\"%s_8021xtype\" value=\"ttls\" onclick=\"enable_idttls('%s')\" %s />TTLS \n", |
|---|
| 4506 | prefix, prefix, nvram_prefix_match( "8021xtype", prefix, |
|---|
| 4507 | "ttls" ) ? |
|---|
| 4508 | "checked=\"checked\"" : "" ); |
|---|
| 4509 | websWrite( wp, "</div>\n" ); |
|---|
| 4510 | // ttls authentication |
|---|
| 4511 | websWrite( wp, "<div id=\"idttls%s\">\n", prefix ); |
|---|
| 4512 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4513 | websWrite( wp, |
|---|
| 4514 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n" ); |
|---|
| 4515 | websWrite( wp, |
|---|
| 4516 | "<input name=\"%s_ttls8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4517 | prefix, nvram_prefix_get( "ttls8021xuser", prefix ) ); |
|---|
| 4518 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4519 | websWrite( wp, |
|---|
| 4520 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n" ); |
|---|
| 4521 | websWrite( wp, |
|---|
| 4522 | "<input name=\"%s_ttls8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4523 | prefix, nvram_prefix_get( "ttls8021xpasswd", prefix ) ); |
|---|
| 4524 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4525 | websWrite( wp, |
|---|
| 4526 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.servercertif)</script></div>\n" ); |
|---|
| 4527 | websWrite( wp, |
|---|
| 4528 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_ttls8021xca\" name=\"%s_ttls8021xca\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4529 | prefix, prefix ); |
|---|
| 4530 | websWrite( wp, "var %s_ttls8021xca = fix_cr( '%s' );\n", prefix, |
|---|
| 4531 | nvram_prefix_get( "ttls8021xca", prefix ) ); |
|---|
| 4532 | websWrite( wp, |
|---|
| 4533 | "document.getElementById(\"%s_ttls8021xca\").value = %s_ttls8021xca;\n", |
|---|
| 4534 | prefix, prefix ); |
|---|
| 4535 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4536 | websWrite( wp, "</div>\n" ); |
|---|
| 4537 | websWrite( wp, "</div>\n" ); |
|---|
| 4538 | |
|---|
| 4539 | // peap authentication |
|---|
| 4540 | websWrite( wp, "<div id=\"idpeap%s\">\n", prefix ); |
|---|
| 4541 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4542 | websWrite( wp, |
|---|
| 4543 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n" ); |
|---|
| 4544 | websWrite( wp, |
|---|
| 4545 | "<input name=\"%s_peap8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4546 | prefix, nvram_prefix_get( "peap8021xuser", prefix ) ); |
|---|
| 4547 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4548 | websWrite( wp, |
|---|
| 4549 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n" ); |
|---|
| 4550 | websWrite( wp, |
|---|
| 4551 | "<input name=\"%s_peap8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4552 | prefix, nvram_prefix_get( "peap8021xpasswd", prefix ) ); |
|---|
| 4553 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4554 | websWrite( wp, |
|---|
| 4555 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.servercertif)</script></div>\n" ); |
|---|
| 4556 | websWrite( wp, |
|---|
| 4557 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_peap8021xca\" name=\"%s_peap8021xca\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4558 | prefix, prefix ); |
|---|
| 4559 | websWrite( wp, "var %s_peap8021xca = fix_cr( '%s' );\n", prefix, |
|---|
| 4560 | nvram_prefix_get( "peap8021xca", prefix ) ); |
|---|
| 4561 | websWrite( wp, |
|---|
| 4562 | "document.getElementById(\"%s_peap8021xca\").value = %s_peap8021xca;\n", |
|---|
| 4563 | prefix, prefix ); |
|---|
| 4564 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4565 | websWrite( wp, "</div>\n" ); |
|---|
| 4566 | websWrite( wp, "</div>\n" ); |
|---|
| 4567 | // leap authentication |
|---|
| 4568 | websWrite( wp, "<div id=\"idleap%s\">\n", prefix ); |
|---|
| 4569 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4570 | websWrite( wp, |
|---|
| 4571 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n" ); |
|---|
| 4572 | websWrite( wp, |
|---|
| 4573 | "<input name=\"%s_leap8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4574 | prefix, nvram_prefix_get( "leap8021xuser", prefix ) ); |
|---|
| 4575 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4576 | websWrite( wp, |
|---|
| 4577 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n" ); |
|---|
| 4578 | websWrite( wp, |
|---|
| 4579 | "<input name=\"%s_leap8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4580 | prefix, nvram_prefix_get( "leap8021xpasswd", prefix ) ); |
|---|
| 4581 | websWrite( wp, "</div>\n" ); |
|---|
| 4582 | |
|---|
| 4583 | // tls authentication |
|---|
| 4584 | websWrite( wp, "<div id=\"idtls%s\">\n", prefix ); |
|---|
| 4585 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4586 | websWrite( wp, |
|---|
| 4587 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.user)</script></div>\n" ); |
|---|
| 4588 | websWrite( wp, |
|---|
| 4589 | "<input name=\"%s_tls8021xuser\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4590 | prefix, nvram_prefix_get( "tls8021xuser", prefix ) ); |
|---|
| 4591 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4592 | websWrite( wp, |
|---|
| 4593 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.passwd)</script></div>\n" ); |
|---|
| 4594 | websWrite( wp, |
|---|
| 4595 | "<input name=\"%s_tls8021xpasswd\" type=\"password\" size=\"20\" maxlength=\"79\" value=\"%s\" /></div>\n", |
|---|
| 4596 | prefix, nvram_prefix_get( "tls8021xpasswd", prefix ) ); |
|---|
| 4597 | |
|---|
| 4598 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4599 | websWrite( wp, |
|---|
| 4600 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.servercertif)</script></div>\n" ); |
|---|
| 4601 | websWrite( wp, |
|---|
| 4602 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xca\" name=\"%s_tls8021xca\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4603 | prefix, prefix ); |
|---|
| 4604 | websWrite( wp, "var %s_tls8021xca = fix_cr( '%s' );\n", prefix, |
|---|
| 4605 | nvram_prefix_get( "tls8021xca", prefix ) ); |
|---|
| 4606 | websWrite( wp, |
|---|
| 4607 | "document.getElementById(\"%s_tls8021xca\").value = %s_tls8021xca;\n", |
|---|
| 4608 | prefix, prefix ); |
|---|
| 4609 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4610 | websWrite( wp, "</div>\n" ); |
|---|
| 4611 | |
|---|
| 4612 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4613 | websWrite( wp, |
|---|
| 4614 | "<div class=\"label\"><script type=\"text/javascript\">Capture(sec80211x.clientcertif)</script></div>\n" ); |
|---|
| 4615 | websWrite( wp, |
|---|
| 4616 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xpem\" name=\"%s_tls8021xpem\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4617 | prefix, prefix ); |
|---|
| 4618 | websWrite( wp, "var %s_tls8021xpem = fix_cr( '%s' );\n", prefix, |
|---|
| 4619 | nvram_prefix_get( "tls8021xpem", prefix ) ); |
|---|
| 4620 | websWrite( wp, |
|---|
| 4621 | "document.getElementById(\"%s_tls8021xpem\").value = %s_tls8021xpem;\n", |
|---|
| 4622 | prefix, prefix ); |
|---|
| 4623 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4624 | websWrite( wp, "</div>\n" ); |
|---|
| 4625 | |
|---|
| 4626 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4627 | websWrite( wp, |
|---|
| 4628 | "<div class=\"label\"><script type=\"text/javascript\">Capture(share.privatekey)</script></div>\n" ); |
|---|
| 4629 | websWrite( wp, |
|---|
| 4630 | "<textarea cols=\"60\" rows=\"6\" id=\"%s_tls8021xprv\" name=\"%s_tls8021xprv\"></textarea>\n<script type=\"text/javascript\">\n//<![CDATA[\n ", |
|---|
| 4631 | prefix, prefix ); |
|---|
| 4632 | websWrite( wp, "var %s_tls8021xprv = fix_cr( '%s' );\n", prefix, |
|---|
| 4633 | nvram_prefix_get( "tls8021xprv", prefix ) ); |
|---|
| 4634 | websWrite( wp, |
|---|
| 4635 | "document.getElementById(\"%s_tls8021xprv\").value = %s_tls8021xprv;\n", |
|---|
| 4636 | prefix, prefix ); |
|---|
| 4637 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4638 | websWrite( wp, "</div>\n" ); |
|---|
| 4639 | |
|---|
| 4640 | websWrite( wp, "</div>\n" ); |
|---|
| 4641 | websWrite( wp, "<script>\n//<![CDATA[\n " ); |
|---|
| 4642 | // websWrite |
|---|
| 4643 | // (wp,"show_layer_ext(document.getElementsByName(\"%s_bridged\"), |
|---|
| 4644 | // \"%s_idnetvifs\", %s);\n",var, vvar, nvram_match (ssid, "0") ? "true" |
|---|
| 4645 | // : "false"); |
|---|
| 4646 | char peap[32]; |
|---|
| 4647 | |
|---|
| 4648 | sprintf( peap, "%s_8021xtype", prefix ); |
|---|
| 4649 | websWrite( wp, |
|---|
| 4650 | "show_layer_ext(document.wpa.%s_8021xtype, 'idpeap%s', %s);\n", |
|---|
| 4651 | prefix, prefix, nvram_match( peap, |
|---|
| 4652 | "peap" ) ? "true" : "false" ); |
|---|
| 4653 | websWrite( wp, |
|---|
| 4654 | "show_layer_ext(document.wpa.%s_8021xtype, 'idtls%s', %s);\n", |
|---|
| 4655 | prefix, prefix, nvram_match( peap, |
|---|
| 4656 | "tls" ) ? "true" : "false" ); |
|---|
| 4657 | websWrite( wp, |
|---|
| 4658 | "show_layer_ext(document.wpa.%s_8021xtype, 'idleap%s', %s);\n", |
|---|
| 4659 | prefix, prefix, nvram_match( peap, |
|---|
| 4660 | "leap" ) ? "true" : "false" ); |
|---|
| 4661 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 4662 | |
|---|
| 4663 | } |
|---|
| 4664 | #endif |
|---|
| 4665 | |
|---|
| 4666 | #ifndef HAVE_WPA_SUPPLICANT |
|---|
| 4667 | void ej_init_80211x_layers( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4668 | { |
|---|
| 4669 | return; |
|---|
| 4670 | } |
|---|
| 4671 | #endif |
|---|
| 4672 | |
|---|
| 4673 | void show_wparadius( webs_t wp, char *prefix ) |
|---|
| 4674 | { |
|---|
| 4675 | char var[80]; |
|---|
| 4676 | |
|---|
| 4677 | websWrite( wp, "<div>\n" ); |
|---|
| 4678 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4679 | websWrite( wp, |
|---|
| 4680 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.algorithms)</script></div>\n" ); |
|---|
| 4681 | websWrite( wp, "<select name=\"%s_crypto\">\n", prefix ); |
|---|
| 4682 | sprintf( var, "%s_crypto", prefix ); |
|---|
| 4683 | websWrite( wp, "<option value=\"tkip\" %s>TKIP</option>\n", |
|---|
| 4684 | selmatch( var, "tkip", "selected=\"selected\"" ) ); |
|---|
| 4685 | websWrite( wp, "<option value=\"aes\" %s>AES</option>\n", |
|---|
| 4686 | selmatch( var, "aes", "selected=\"selected\"" ) ); |
|---|
| 4687 | websWrite( wp, "<option value=\"tkip+aes\" %s>TKIP+AES</option>\n", |
|---|
| 4688 | selmatch( var, "tkip+aes", "selected=\"selected\"" ) ); |
|---|
| 4689 | websWrite( wp, "</select></div>\n" ); |
|---|
| 4690 | show_radius( wp, prefix, 0 ); |
|---|
| 4691 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 4692 | websWrite( wp, |
|---|
| 4693 | "<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.rekey)</script></div>\n" ); |
|---|
| 4694 | sprintf( var, "%s_wpa_gtk_rekey", prefix ); |
|---|
| 4695 | websWrite( wp, |
|---|
| 4696 | "<input name=\"%s_wpa_gtk_rekey\" maxlength=\"5\" size=\"10\" onblur=\"valid_range(this,0,99999,wpa.rekey)\" value=\"%s\" />", |
|---|
| 4697 | prefix, nvram_default_get( var, "3600" ) ); |
|---|
| 4698 | websWrite( wp, "</div>\n" ); |
|---|
| 4699 | websWrite( wp, "</div>\n" ); |
|---|
| 4700 | } |
|---|
| 4701 | |
|---|
| 4702 | void show_wep( webs_t wp, char *prefix ) |
|---|
| 4703 | { |
|---|
| 4704 | char var[80]; |
|---|
| 4705 | char *bit; |
|---|
| 4706 | |
|---|
| 4707 | cprintf( "show wep\n" ); |
|---|
| 4708 | websWrite( wp, |
|---|
| 4709 | "<div><div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(wep.defkey)</script></div>" ); |
|---|
| 4710 | websWrite( wp, "<input type=\"hidden\" name=\"%s_WEP_key\" />", prefix ); |
|---|
| 4711 | websWrite( wp, |
|---|
| 4712 | "<input type=\"hidden\" name=\"%s_wep\" value=\"restricted\" />", |
|---|
| 4713 | prefix ); |
|---|
| 4714 | sprintf( var, "%s_key", prefix ); |
|---|
| 4715 | nvram_default_get( var, "1" ); |
|---|
| 4716 | websWrite( wp, |
|---|
| 4717 | "<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s_key\" %s />1 \n", |
|---|
| 4718 | prefix, selmatch( var, "1", "checked=\"checked\"" ) ); |
|---|
| 4719 | websWrite( wp, |
|---|
| 4720 | "<input class=\"spaceradio\" type=\"radio\" value=\"2\" name=\"%s_key\" %s />2 \n", |
|---|
| 4721 | prefix, selmatch( var, "2", "checked=\"checked\"" ) ); |
|---|
| 4722 | websWrite( wp, |
|---|
| 4723 | "<input class=\"spaceradio\" type=\"radio\" value=\"3\" name=\"%s_key\" %s />3 \n", |
|---|
| 4724 | prefix, selmatch( var, "3", "checked=\"checked\"" ) ); |
|---|
| 4725 | websWrite( wp, |
|---|
| 4726 | "<input class=\"spaceradio\" type=\"radio\" value=\"4\" name=\"%s_key\" %s />4 \n", |
|---|
| 4727 | prefix, selmatch( var, "4", "checked=\"checked\"" ) ); |
|---|
| 4728 | websWrite( wp, "</div>" ); |
|---|
| 4729 | websWrite( wp, |
|---|
| 4730 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.encrypt)</script></div>" ); |
|---|
| 4731 | |
|---|
| 4732 | sprintf( var, "%s_wep_bit", prefix ); |
|---|
| 4733 | bit = nvram_safe_get( var ); |
|---|
| 4734 | |
|---|
| 4735 | cprintf( "bit %s\n", bit ); |
|---|
| 4736 | |
|---|
| 4737 | websWrite( wp, |
|---|
| 4738 | "<select name=\"%s_wep_bit\" size=\"1\" onchange=keyMode(this.form)>", |
|---|
| 4739 | prefix ); |
|---|
| 4740 | websWrite( wp, "<option value=\"64\" %s >64 bits 10 hex digits</option>", |
|---|
| 4741 | selmatch( var, "64", "selected=\"selected\"" ) ); |
|---|
| 4742 | websWrite( wp, |
|---|
| 4743 | "<option value=\"128\" %s >128 bits 26 hex digits</option>", |
|---|
| 4744 | selmatch( var, "128", "selected=\"selected\"" ) ); |
|---|
| 4745 | websWrite( wp, |
|---|
| 4746 | "</select>\n</div>\n<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wep.passphrase)</script></div>\n" ); |
|---|
| 4747 | websWrite( wp, |
|---|
| 4748 | "<input name=%s_passphrase maxlength=\"16\" size=\"20\" value=\"", |
|---|
| 4749 | prefix ); |
|---|
| 4750 | |
|---|
| 4751 | char p_temp[128]; |
|---|
| 4752 | char temp[256]; |
|---|
| 4753 | |
|---|
| 4754 | sprintf( p_temp, "%s", get_wep_value( temp, "passphrase", bit, prefix ) ); |
|---|
| 4755 | nvram_set( "passphrase_temp", p_temp ); |
|---|
| 4756 | tf_webWriteESCNV( wp, "passphrase_temp" ); |
|---|
| 4757 | nvram_unset( "passphrase_temp" ); |
|---|
| 4758 | |
|---|
| 4759 | websWrite( wp, "\" />" ); |
|---|
| 4760 | websWrite( wp, |
|---|
| 4761 | "<input type=\"hidden\" value=\"Null\" name=\"generateButton\" />\n" ); |
|---|
| 4762 | websWrite( wp, |
|---|
| 4763 | "<input class=\"button\" type=\"button\" value=\"Generate\" onclick=generateKey(this.form,\"%s\") name=wepGenerate />\n</div>", |
|---|
| 4764 | prefix ); |
|---|
| 4765 | |
|---|
| 4766 | char *mlen = "10"; |
|---|
| 4767 | char *mlen2 = "12"; |
|---|
| 4768 | |
|---|
| 4769 | if( !strcmp( bit, "128" ) ) |
|---|
| 4770 | { |
|---|
| 4771 | mlen = "26"; |
|---|
| 4772 | mlen2 = "30"; |
|---|
| 4773 | } |
|---|
| 4774 | websWrite( wp, |
|---|
| 4775 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 1</div>\n" ); |
|---|
| 4776 | websWrite( wp, |
|---|
| 4777 | "<input name=%s_key1 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 4778 | prefix, mlen2, mlen, get_wep_value( temp, "key1", bit, |
|---|
| 4779 | prefix ) ); |
|---|
| 4780 | websWrite( wp, |
|---|
| 4781 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 2</div>\n" ); |
|---|
| 4782 | websWrite( wp, |
|---|
| 4783 | "<input name=%s_key2 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 4784 | prefix, mlen2, mlen, get_wep_value( temp, "key2", bit, |
|---|
| 4785 | prefix ) ); |
|---|
| 4786 | websWrite( wp, |
|---|
| 4787 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 3</div>\n" ); |
|---|
| 4788 | websWrite( wp, |
|---|
| 4789 | "<input name=%s_key3 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 4790 | prefix, mlen2, mlen, get_wep_value( temp, "key3", bit, |
|---|
| 4791 | prefix ) ); |
|---|
| 4792 | websWrite( wp, |
|---|
| 4793 | "<div class=\"setting\"><div class=\"label\"><script type=\"text/javascript\">Capture(share.key)</script> 4</div>\n" ); |
|---|
| 4794 | websWrite( wp, |
|---|
| 4795 | "<input name=%s_key4 size=\"%s\" maxlength=\"%s\" value=\"%s\" /></div>\n", |
|---|
| 4796 | prefix, mlen2, mlen, get_wep_value( temp, "key4", bit, |
|---|
| 4797 | prefix ) ); |
|---|
| 4798 | websWrite( wp, "</div>\n" ); |
|---|
| 4799 | } |
|---|
| 4800 | |
|---|
| 4801 | #endif |
|---|
| 4802 | |
|---|
| 4803 | void ej_get_wds_mac( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4804 | { |
|---|
| 4805 | int mac = -1, wds_idx = -1, mac_idx = -1; |
|---|
| 4806 | char *c, wds_var[32] = ""; |
|---|
| 4807 | |
|---|
| 4808 | char *interface; |
|---|
| 4809 | |
|---|
| 4810 | if( ejArgs( argc, argv, "%d %d %s", &wds_idx, &mac_idx, &interface ) < 3 ) |
|---|
| 4811 | { |
|---|
| 4812 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 4813 | return; |
|---|
| 4814 | } |
|---|
| 4815 | else if( wds_idx < 1 || wds_idx > MAX_WDS_DEVS ) |
|---|
| 4816 | return; |
|---|
| 4817 | else if( mac_idx < 0 || mac_idx > 5 ) |
|---|
| 4818 | return; |
|---|
| 4819 | |
|---|
| 4820 | snprintf( wds_var, 31, "%s_wds%d_hwaddr", interface, wds_idx ); |
|---|
| 4821 | |
|---|
| 4822 | c = nvram_safe_get( wds_var ); |
|---|
| 4823 | |
|---|
| 4824 | if( c ) |
|---|
| 4825 | { |
|---|
| 4826 | mac = get_single_mac( c, mac_idx ); |
|---|
| 4827 | websWrite( wp, "%02X", mac ); |
|---|
| 4828 | } |
|---|
| 4829 | else |
|---|
| 4830 | websWrite( wp, "00" ); |
|---|
| 4831 | |
|---|
| 4832 | return; |
|---|
| 4833 | |
|---|
| 4834 | } |
|---|
| 4835 | |
|---|
| 4836 | void ej_showbridgesettings( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4837 | { |
|---|
| 4838 | char *interface; |
|---|
| 4839 | int mcast; |
|---|
| 4840 | |
|---|
| 4841 | #ifdef FASTWEB |
|---|
| 4842 | ejArgs( argc, argv, "%s %d", &interface, &mcast ); |
|---|
| 4843 | #else |
|---|
| 4844 | if( ejArgs( argc, argv, "%s %d", &interface, &mcast ) < 2 ) |
|---|
| 4845 | { |
|---|
| 4846 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 4847 | return; |
|---|
| 4848 | } |
|---|
| 4849 | #endif |
|---|
| 4850 | showbridgesettings( wp, interface, mcast ); |
|---|
| 4851 | } |
|---|
| 4852 | |
|---|
| 4853 | void ej_get_wds_ip( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4854 | { |
|---|
| 4855 | int ip = -1, wds_idx = -1, ip_idx = -1; |
|---|
| 4856 | char *c, wds_var[32] = ""; |
|---|
| 4857 | |
|---|
| 4858 | char *interface; |
|---|
| 4859 | |
|---|
| 4860 | #ifdef FASTWEB |
|---|
| 4861 | ejArgs( argc, argv, "%d %d %s", &wds_idx, &ip_idx, &interface ); |
|---|
| 4862 | #else |
|---|
| 4863 | if( ejArgs( argc, argv, "%d %d %s", &wds_idx, &ip_idx, &interface ) < 3 ) |
|---|
| 4864 | { |
|---|
| 4865 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 4866 | return; |
|---|
| 4867 | } |
|---|
| 4868 | #endif |
|---|
| 4869 | if( wds_idx < 1 || wds_idx > MAX_WDS_DEVS ) |
|---|
| 4870 | return; |
|---|
| 4871 | else if( ip_idx < 0 || ip_idx > 3 ) |
|---|
| 4872 | return; |
|---|
| 4873 | |
|---|
| 4874 | snprintf( wds_var, 31, "%s_wds%d_ipaddr", interface, wds_idx ); |
|---|
| 4875 | |
|---|
| 4876 | c = nvram_safe_get( wds_var ); |
|---|
| 4877 | |
|---|
| 4878 | if( c ) |
|---|
| 4879 | { |
|---|
| 4880 | ip = get_single_ip( c, ip_idx ); |
|---|
| 4881 | websWrite( wp, "%d", ip ); |
|---|
| 4882 | } |
|---|
| 4883 | else |
|---|
| 4884 | websWrite( wp, "0" ); |
|---|
| 4885 | |
|---|
| 4886 | return; |
|---|
| 4887 | |
|---|
| 4888 | } |
|---|
| 4889 | |
|---|
| 4890 | void ej_get_wds_netmask( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4891 | { |
|---|
| 4892 | int nm = -1, wds_idx = -1, nm_idx = -1; |
|---|
| 4893 | char *c, wds_var[32] = ""; |
|---|
| 4894 | |
|---|
| 4895 | char *interface; |
|---|
| 4896 | |
|---|
| 4897 | #ifdef FASTWEB |
|---|
| 4898 | ejArgs( argc, argv, "%d %d %s", &wds_idx, &nm_idx, &interface ); |
|---|
| 4899 | #else |
|---|
| 4900 | if( ejArgs( argc, argv, "%d %d %s", &wds_idx, &nm_idx, &interface ) < 3 ) |
|---|
| 4901 | { |
|---|
| 4902 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 4903 | return; |
|---|
| 4904 | } |
|---|
| 4905 | #endif |
|---|
| 4906 | |
|---|
| 4907 | if( wds_idx < 1 || wds_idx > 6 ) |
|---|
| 4908 | return; |
|---|
| 4909 | else if( nm_idx < 0 || nm_idx > 3 ) |
|---|
| 4910 | return; |
|---|
| 4911 | |
|---|
| 4912 | snprintf( wds_var, 31, "%s_wds%d_netmask", interface, wds_idx ); |
|---|
| 4913 | |
|---|
| 4914 | c = nvram_safe_get( wds_var ); |
|---|
| 4915 | |
|---|
| 4916 | if( c ) |
|---|
| 4917 | { |
|---|
| 4918 | nm = get_single_ip( c, nm_idx ); |
|---|
| 4919 | websWrite( wp, "%d", nm ); |
|---|
| 4920 | } |
|---|
| 4921 | else |
|---|
| 4922 | websWrite( wp, "255" ); |
|---|
| 4923 | |
|---|
| 4924 | return; |
|---|
| 4925 | |
|---|
| 4926 | } |
|---|
| 4927 | |
|---|
| 4928 | void ej_get_wds_gw( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4929 | { |
|---|
| 4930 | int gw = -1, wds_idx = -1, gw_idx = -1; |
|---|
| 4931 | char *c, wds_var[32] = ""; |
|---|
| 4932 | |
|---|
| 4933 | char *interface; |
|---|
| 4934 | |
|---|
| 4935 | #ifdef FASTWEB |
|---|
| 4936 | ejArgs( argc, argv, "%d %d %s", &wds_idx, &gw_idx, &interface ); |
|---|
| 4937 | #else |
|---|
| 4938 | if( ejArgs( argc, argv, "%d %d %s", &wds_idx, &gw_idx, &interface ) < 3 ) |
|---|
| 4939 | { |
|---|
| 4940 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 4941 | return; |
|---|
| 4942 | } |
|---|
| 4943 | #endif |
|---|
| 4944 | |
|---|
| 4945 | if( wds_idx < 1 || wds_idx > MAX_WDS_DEVS ) |
|---|
| 4946 | return; |
|---|
| 4947 | else if( gw_idx < 0 || gw_idx > 3 ) |
|---|
| 4948 | return; |
|---|
| 4949 | |
|---|
| 4950 | snprintf( wds_var, 31, "%s_wds%d_gw", interface, wds_idx ); |
|---|
| 4951 | |
|---|
| 4952 | c = nvram_safe_get( wds_var ); |
|---|
| 4953 | |
|---|
| 4954 | if( c ) |
|---|
| 4955 | { |
|---|
| 4956 | gw = get_single_ip( c, gw_idx ); |
|---|
| 4957 | websWrite( wp, "%d", gw ); |
|---|
| 4958 | } |
|---|
| 4959 | else |
|---|
| 4960 | websWrite( wp, "0" ); |
|---|
| 4961 | |
|---|
| 4962 | return; |
|---|
| 4963 | |
|---|
| 4964 | } |
|---|
| 4965 | |
|---|
| 4966 | void ej_get_br1_ip( webs_t wp, int argc, char_t ** argv ) |
|---|
| 4967 | { |
|---|
| 4968 | int ip = -1, ip_idx = -1; |
|---|
| 4969 | char *c; |
|---|
| 4970 | |
|---|
| 4971 | char *interface; |
|---|
| 4972 | |
|---|
| 4973 | #ifdef FASTWEB |
|---|
| 4974 | ejArgs( argc, argv, "%d %s", &ip_idx, &interface ); |
|---|
| 4975 | #else |
|---|
| 4976 | if( ejArgs( argc, argv, "%d %s", &ip_idx, &interface ) < 2 ) |
|---|
| 4977 | { |
|---|
| 4978 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 4979 | return; |
|---|
| 4980 | } |
|---|
| 4981 | #endif |
|---|
| 4982 | if( ip_idx < 0 || ip_idx > 3 ) |
|---|
| 4983 | return; |
|---|
| 4984 | char br1[32]; |
|---|
| 4985 | |
|---|
| 4986 | sprintf( br1, "%s_br1_ipaddr", interface ); |
|---|
| 4987 | c = nvram_safe_get( br1 ); |
|---|
| 4988 | |
|---|
| 4989 | if( c ) |
|---|
| 4990 | { |
|---|
| 4991 | ip = get_single_ip( c, ip_idx ); |
|---|
| 4992 | websWrite( wp, "%d", ip ); |
|---|
| 4993 | } |
|---|
| 4994 | else |
|---|
| 4995 | websWrite( wp, "0" ); |
|---|
| 4996 | |
|---|
| 4997 | return; |
|---|
| 4998 | |
|---|
| 4999 | } |
|---|
| 5000 | |
|---|
| 5001 | void ej_get_br1_netmask( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5002 | { |
|---|
| 5003 | int nm = -1, nm_idx = -1; |
|---|
| 5004 | char *c; |
|---|
| 5005 | |
|---|
| 5006 | char *interface; |
|---|
| 5007 | |
|---|
| 5008 | #ifdef FASTWEB |
|---|
| 5009 | ejArgs( argc, argv, "%d %s", &nm_idx, &interface ); |
|---|
| 5010 | #else |
|---|
| 5011 | if( ejArgs( argc, argv, "%d %s", &nm_idx, &interface ) < 2 ) |
|---|
| 5012 | { |
|---|
| 5013 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 5014 | return; |
|---|
| 5015 | } |
|---|
| 5016 | #endif |
|---|
| 5017 | if( nm_idx < 0 || nm_idx > 3 ) |
|---|
| 5018 | return; |
|---|
| 5019 | char nms[32]; |
|---|
| 5020 | |
|---|
| 5021 | sprintf( nms, "%s_br1_netmask", interface ); |
|---|
| 5022 | c = nvram_safe_get( nms ); |
|---|
| 5023 | |
|---|
| 5024 | if( c ) |
|---|
| 5025 | { |
|---|
| 5026 | nm = get_single_ip( c, nm_idx ); |
|---|
| 5027 | websWrite( wp, "%d", nm ); |
|---|
| 5028 | } |
|---|
| 5029 | else |
|---|
| 5030 | websWrite( wp, "255" ); |
|---|
| 5031 | |
|---|
| 5032 | return; |
|---|
| 5033 | |
|---|
| 5034 | } |
|---|
| 5035 | |
|---|
| 5036 | #ifdef HAVE_MADWIFI |
|---|
| 5037 | |
|---|
| 5038 | int get_acktiming( void ) |
|---|
| 5039 | { |
|---|
| 5040 | char path[64]; |
|---|
| 5041 | int ifcount, ack = 0; |
|---|
| 5042 | |
|---|
| 5043 | strcpy( path, nvram_safe_get( "wifi_display" ) ); |
|---|
| 5044 | sscanf( path, "ath%d", &ifcount ); |
|---|
| 5045 | sprintf( path, "/proc/sys/dev/wifi%d/acktimeout", ifcount ); |
|---|
| 5046 | FILE *in = fopen( path, "rb" ); |
|---|
| 5047 | |
|---|
| 5048 | if( in != NULL ) |
|---|
| 5049 | { |
|---|
| 5050 | fscanf( in, "%d", &ack ); |
|---|
| 5051 | fclose( in ); |
|---|
| 5052 | } |
|---|
| 5053 | return ack; |
|---|
| 5054 | } |
|---|
| 5055 | |
|---|
| 5056 | void ej_show_acktiming( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5057 | { |
|---|
| 5058 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 5059 | websWrite( wp, "<div class=\"label\">%s</div>\n", |
|---|
| 5060 | live_translate( "share.acktiming" ) ); |
|---|
| 5061 | int ack = get_acktiming( ); |
|---|
| 5062 | int distance = ( ( ack - 3 ) / 2 ) * 300; |
|---|
| 5063 | |
|---|
| 5064 | websWrite( wp, "<span id=\"wl_ack\">%dµs (%dm)</span> \n", ack, |
|---|
| 5065 | distance ); |
|---|
| 5066 | websWrite( wp, "</div>\n" ); |
|---|
| 5067 | } |
|---|
| 5068 | |
|---|
| 5069 | void ej_update_acktiming( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5070 | { |
|---|
| 5071 | int ack = get_acktiming( ); |
|---|
| 5072 | int distance = ( ( ack - 3 ) / 2 ) * 300; |
|---|
| 5073 | |
|---|
| 5074 | websWrite( wp, "%dµs (%dm)", ack, distance ); |
|---|
| 5075 | } |
|---|
| 5076 | |
|---|
| 5077 | extern float wifi_getrate( char *ifname ); |
|---|
| 5078 | |
|---|
| 5079 | #define KILO 1e3 |
|---|
| 5080 | #define MEGA 1e6 |
|---|
| 5081 | #define GIGA 1e9 |
|---|
| 5082 | |
|---|
| 5083 | void ej_get_currate( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5084 | { |
|---|
| 5085 | char mode[32]; |
|---|
| 5086 | int state = get_radiostate( nvram_safe_get( "wifi_display" ) ); |
|---|
| 5087 | |
|---|
| 5088 | if( state == 0 || state == -1 ) |
|---|
| 5089 | { |
|---|
| 5090 | websWrite( wp, "%s", live_translate( "share.disabled" ) ); |
|---|
| 5091 | return; |
|---|
| 5092 | } |
|---|
| 5093 | float rate = wifi_getrate( nvram_safe_get( "wifi_display" ) ); |
|---|
| 5094 | char scale; |
|---|
| 5095 | int divisor; |
|---|
| 5096 | |
|---|
| 5097 | if( rate >= GIGA ) |
|---|
| 5098 | { |
|---|
| 5099 | scale = 'G'; |
|---|
| 5100 | divisor = GIGA; |
|---|
| 5101 | } |
|---|
| 5102 | else |
|---|
| 5103 | { |
|---|
| 5104 | if( rate >= MEGA ) |
|---|
| 5105 | { |
|---|
| 5106 | scale = 'M'; |
|---|
| 5107 | divisor = MEGA; |
|---|
| 5108 | } |
|---|
| 5109 | else |
|---|
| 5110 | { |
|---|
| 5111 | scale = 'k'; |
|---|
| 5112 | divisor = KILO; |
|---|
| 5113 | } |
|---|
| 5114 | } |
|---|
| 5115 | sprintf( mode, "%s_channelbw", nvram_safe_get( "wifi_display" ) ); |
|---|
| 5116 | if( nvram_match( mode, "40" ) ) |
|---|
| 5117 | rate *= 2; |
|---|
| 5118 | if( rate > 0.0 ) |
|---|
| 5119 | { |
|---|
| 5120 | websWrite( wp, "%g %cb/s", rate / divisor, scale ); |
|---|
| 5121 | } |
|---|
| 5122 | else |
|---|
| 5123 | websWrite( wp, "%s", live_translate( "share.auto" ) ); |
|---|
| 5124 | |
|---|
| 5125 | } |
|---|
| 5126 | |
|---|
| 5127 | #elif HAVE_RT2880 |
|---|
| 5128 | extern float wifi_getrate( char *ifname ); |
|---|
| 5129 | |
|---|
| 5130 | #define KILO 1e3 |
|---|
| 5131 | #define MEGA 1e6 |
|---|
| 5132 | #define GIGA 1e9 |
|---|
| 5133 | |
|---|
| 5134 | void ej_get_currate( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5135 | { |
|---|
| 5136 | char mode[32]; |
|---|
| 5137 | int state = get_radiostate( "wl0" ); |
|---|
| 5138 | |
|---|
| 5139 | if( state == 0 || state == -1 ) |
|---|
| 5140 | { |
|---|
| 5141 | websWrite( wp, "%s", live_translate( "share.disabled" ) ); |
|---|
| 5142 | return; |
|---|
| 5143 | } |
|---|
| 5144 | float rate = wifi_getrate( "ra0" ); |
|---|
| 5145 | char scale; |
|---|
| 5146 | int divisor; |
|---|
| 5147 | |
|---|
| 5148 | if( rate >= GIGA ) |
|---|
| 5149 | { |
|---|
| 5150 | scale = 'G'; |
|---|
| 5151 | divisor = GIGA; |
|---|
| 5152 | } |
|---|
| 5153 | else |
|---|
| 5154 | { |
|---|
| 5155 | if( rate >= MEGA ) |
|---|
| 5156 | { |
|---|
| 5157 | scale = 'M'; |
|---|
| 5158 | divisor = MEGA; |
|---|
| 5159 | } |
|---|
| 5160 | else |
|---|
| 5161 | { |
|---|
| 5162 | scale = 'k'; |
|---|
| 5163 | divisor = KILO; |
|---|
| 5164 | } |
|---|
| 5165 | } |
|---|
| 5166 | if( rate > 0.0 ) |
|---|
| 5167 | { |
|---|
| 5168 | websWrite( wp, "%g %cb/s", rate / divisor, scale ); |
|---|
| 5169 | } |
|---|
| 5170 | else |
|---|
| 5171 | websWrite( wp, "%s", live_translate( "share.auto" ) ); |
|---|
| 5172 | |
|---|
| 5173 | } |
|---|
| 5174 | |
|---|
| 5175 | |
|---|
| 5176 | void ej_show_acktiming( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5177 | { |
|---|
| 5178 | return; |
|---|
| 5179 | } |
|---|
| 5180 | |
|---|
| 5181 | void ej_update_acktiming( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5182 | { |
|---|
| 5183 | return; |
|---|
| 5184 | } |
|---|
| 5185 | |
|---|
| 5186 | |
|---|
| 5187 | #else |
|---|
| 5188 | |
|---|
| 5189 | void ej_get_currate( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5190 | { |
|---|
| 5191 | int rate = 0; |
|---|
| 5192 | |
|---|
| 5193 | wl_ioctl( get_wdev( ), WLC_GET_RATE, &rate, sizeof( rate ) ); |
|---|
| 5194 | |
|---|
| 5195 | if( rate > 0 ) |
|---|
| 5196 | websWrite( wp, "%d%s Mbps", ( rate / 2 ), ( rate & 1 ) ? ".5" : "" ); |
|---|
| 5197 | else |
|---|
| 5198 | websWrite( wp, "%s", live_translate( "share.unknown" ) ); |
|---|
| 5199 | |
|---|
| 5200 | return; |
|---|
| 5201 | } |
|---|
| 5202 | |
|---|
| 5203 | void ej_show_acktiming( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5204 | { |
|---|
| 5205 | return; |
|---|
| 5206 | } |
|---|
| 5207 | |
|---|
| 5208 | void ej_update_acktiming( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5209 | { |
|---|
| 5210 | return; |
|---|
| 5211 | } |
|---|
| 5212 | |
|---|
| 5213 | |
|---|
| 5214 | #endif |
|---|
| 5215 | |
|---|
| 5216 | void ej_get_uptime( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5217 | { |
|---|
| 5218 | char line[256]; |
|---|
| 5219 | FILE *fp; |
|---|
| 5220 | |
|---|
| 5221 | if( ( fp = popen( "uptime", "r" ) ) ) |
|---|
| 5222 | { |
|---|
| 5223 | fgets( line, sizeof( line ), fp ); |
|---|
| 5224 | line[strlen( line ) - 1] = '\0'; // replace new line with null |
|---|
| 5225 | websWrite( wp, "%s", line ); |
|---|
| 5226 | pclose( fp ); |
|---|
| 5227 | } |
|---|
| 5228 | return; |
|---|
| 5229 | } |
|---|
| 5230 | |
|---|
| 5231 | void ej_get_wan_uptime( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5232 | { |
|---|
| 5233 | float sys_uptime; |
|---|
| 5234 | float uptime; |
|---|
| 5235 | int days, minutes; |
|---|
| 5236 | FILE *fp, *fp2; |
|---|
| 5237 | |
|---|
| 5238 | if( nvram_match( "wan_proto", "disabled" ) ) |
|---|
| 5239 | return; |
|---|
| 5240 | if( !( fp = fopen( "/tmp/.wanuptime", "r" ) ) ) |
|---|
| 5241 | { |
|---|
| 5242 | websWrite( wp, "%s", live_translate( "status_router.notavail" ) ); |
|---|
| 5243 | return; |
|---|
| 5244 | } |
|---|
| 5245 | if( !feof( fp ) && fscanf( fp, "%f", &uptime ) == 1 ) |
|---|
| 5246 | { |
|---|
| 5247 | fp2 = fopen( "/proc/uptime", "r" ); |
|---|
| 5248 | fscanf( fp2, "%f", &sys_uptime ); |
|---|
| 5249 | fclose( fp2 ); |
|---|
| 5250 | uptime = sys_uptime - uptime; |
|---|
| 5251 | days = ( int )uptime / ( 60 * 60 * 24 ); |
|---|
| 5252 | if( days ) |
|---|
| 5253 | websWrite( wp, "%d day%s, ", days, ( days == 1 ? "" : "s" ) ); |
|---|
| 5254 | minutes = ( int )uptime / 60; |
|---|
| 5255 | websWrite( wp, "%d:%02d:%02d", ( minutes / 60 ) % 24, minutes % 60, |
|---|
| 5256 | ( int )uptime % 60 ); |
|---|
| 5257 | } |
|---|
| 5258 | fclose( fp ); |
|---|
| 5259 | |
|---|
| 5260 | return; |
|---|
| 5261 | |
|---|
| 5262 | } |
|---|
| 5263 | |
|---|
| 5264 | #ifdef HAVE_MADWIFI |
|---|
| 5265 | |
|---|
| 5266 | void ej_get_curchannel( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5267 | { |
|---|
| 5268 | int channel = wifi_getchannel( nvram_safe_get( "wifi_display" ) ); |
|---|
| 5269 | |
|---|
| 5270 | if( channel > 0 && channel < 1000 ) |
|---|
| 5271 | { |
|---|
| 5272 | #ifdef HAVE_XR4SPECIAL |
|---|
| 5273 | char ofs[32]; |
|---|
| 5274 | |
|---|
| 5275 | sprintf( ofs, "%s_offset", nvram_safe_get( "wifi_display" ) ); |
|---|
| 5276 | int offset = atoi( nvram_default_get( ofs, "0" ) ); |
|---|
| 5277 | |
|---|
| 5278 | websWrite( wp, "%d (%d Mhz)", channel, |
|---|
| 5279 | ( wifi_getfreq( nvram_safe_get( "wifi_display" ) ) + |
|---|
| 5280 | offset ) ); |
|---|
| 5281 | #else |
|---|
| 5282 | websWrite( wp, "%d (%d Mhz)", channel, |
|---|
| 5283 | ( wifi_getfreq( nvram_safe_get( "wifi_display" ) ) + |
|---|
| 5284 | get_wifioffset( nvram_safe_get( "wifi_display" ) ) ) ); |
|---|
| 5285 | #endif |
|---|
| 5286 | } |
|---|
| 5287 | else |
|---|
| 5288 | // websWrite (wp, "unknown"); |
|---|
| 5289 | websWrite( wp, "%s", live_translate( "share.unknown" ) ); |
|---|
| 5290 | return; |
|---|
| 5291 | } |
|---|
| 5292 | |
|---|
| 5293 | #elif HAVE_RT2880 |
|---|
| 5294 | void ej_get_curchannel( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5295 | { |
|---|
| 5296 | int channel = wifi_getchannel( "ra0"); |
|---|
| 5297 | |
|---|
| 5298 | if( channel > 0 && channel < 1000 ) |
|---|
| 5299 | { |
|---|
| 5300 | websWrite( wp, "%d (%d Mhz)", channel,wifi_getfreq( "ra0" ) ); |
|---|
| 5301 | } |
|---|
| 5302 | else |
|---|
| 5303 | // websWrite (wp, "unknown"); |
|---|
| 5304 | websWrite( wp, "%s", live_translate( "share.unknown" ) ); |
|---|
| 5305 | return; |
|---|
| 5306 | } |
|---|
| 5307 | |
|---|
| 5308 | |
|---|
| 5309 | #else |
|---|
| 5310 | |
|---|
| 5311 | void ej_get_curchannel( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5312 | { |
|---|
| 5313 | channel_info_t ci; |
|---|
| 5314 | |
|---|
| 5315 | memset( &ci, 0, sizeof( ci ) ); |
|---|
| 5316 | wl_ioctl( get_wdev( ), WLC_GET_CHANNEL, &ci, sizeof( ci ) ); |
|---|
| 5317 | if( ci.scan_channel > 0 ) |
|---|
| 5318 | { |
|---|
| 5319 | websWrite( wp, "%d (scanning)", ci.scan_channel ); |
|---|
| 5320 | } |
|---|
| 5321 | else if( ci.hw_channel > 0 ) |
|---|
| 5322 | { |
|---|
| 5323 | websWrite( wp, "%d", ci.hw_channel ); |
|---|
| 5324 | } |
|---|
| 5325 | else |
|---|
| 5326 | // websWrite (wp, "unknown"); |
|---|
| 5327 | websWrite( wp, "%s", live_translate( "share.unknown" ) ); |
|---|
| 5328 | return; |
|---|
| 5329 | |
|---|
| 5330 | } |
|---|
| 5331 | |
|---|
| 5332 | #endif |
|---|
| 5333 | #ifdef HAVE_MADWIFI |
|---|
| 5334 | #include <sys/types.h> |
|---|
| 5335 | #include <sys/file.h> |
|---|
| 5336 | #include <sys/ioctl.h> |
|---|
| 5337 | #include <sys/socket.h> |
|---|
| 5338 | #include <stdio.h> |
|---|
| 5339 | #include <stdlib.h> |
|---|
| 5340 | #include <string.h> |
|---|
| 5341 | #include <stdint.h> |
|---|
| 5342 | #include <ctype.h> |
|---|
| 5343 | #include <getopt.h> |
|---|
| 5344 | #include <err.h> |
|---|
| 5345 | |
|---|
| 5346 | #include "wireless_copy.h" |
|---|
| 5347 | #include "net80211/ieee80211.h" |
|---|
| 5348 | #include "net80211/ieee80211_crypto.h" |
|---|
| 5349 | #include "net80211/ieee80211_ioctl.h" |
|---|
| 5350 | static const char *ieee80211_ntoa( const uint8_t mac[IEEE80211_ADDR_LEN] ) |
|---|
| 5351 | { |
|---|
| 5352 | static char a[18]; |
|---|
| 5353 | int i; |
|---|
| 5354 | |
|---|
| 5355 | i = snprintf( a, sizeof( a ), "%02x:%02x:%02x:%02x:%02x:%02x", |
|---|
| 5356 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] ); |
|---|
| 5357 | return ( i < 17 ? NULL : a ); |
|---|
| 5358 | } |
|---|
| 5359 | |
|---|
| 5360 | int |
|---|
| 5361 | ej_active_wireless_if( webs_t wp, int argc, char_t ** argv, |
|---|
| 5362 | char *ifname, int cnt, int turbo, int macmask ) |
|---|
| 5363 | { |
|---|
| 5364 | // unsigned char buf[24 * 1024]; |
|---|
| 5365 | |
|---|
| 5366 | unsigned char *cp; |
|---|
| 5367 | int s, len; |
|---|
| 5368 | struct iwreq iwr; |
|---|
| 5369 | |
|---|
| 5370 | if( !ifexists( ifname ) ) |
|---|
| 5371 | { |
|---|
| 5372 | printf( "IOCTL_STA_INFO ifresolv %s failed!\n", ifname ); |
|---|
| 5373 | return cnt; |
|---|
| 5374 | } |
|---|
| 5375 | int state = get_radiostate( ifname ); |
|---|
| 5376 | |
|---|
| 5377 | if( state == 0 || state == -1 ) |
|---|
| 5378 | { |
|---|
| 5379 | printf( "IOCTL_STA_INFO radio %s not enabled!\n", ifname ); |
|---|
| 5380 | return cnt; |
|---|
| 5381 | } |
|---|
| 5382 | s = socket( AF_INET, SOCK_DGRAM, 0 ); |
|---|
| 5383 | if( s < 0 ) |
|---|
| 5384 | { |
|---|
| 5385 | fprintf( stderr, "socket(SOCK_DRAGM)\n" ); |
|---|
| 5386 | return cnt; |
|---|
| 5387 | } |
|---|
| 5388 | ( void )memset( &iwr, 0, sizeof( struct iwreq ) ); |
|---|
| 5389 | ( void )strncpy( iwr.ifr_name, ifname, sizeof( iwr.ifr_name ) ); |
|---|
| 5390 | unsigned char *buf = ( unsigned char * )malloc( 24 * 1024 ); |
|---|
| 5391 | |
|---|
| 5392 | iwr.u.data.pointer = ( void * )buf; |
|---|
| 5393 | iwr.u.data.length = 24 * 1024; |
|---|
| 5394 | if( ioctl( s, IEEE80211_IOCTL_STA_INFO, &iwr ) < 0 ) |
|---|
| 5395 | { |
|---|
| 5396 | fprintf( stderr, "IOCTL_STA_INFO for %s failed!\n", ifname ); |
|---|
| 5397 | close( s ); |
|---|
| 5398 | free( buf ); |
|---|
| 5399 | return cnt; |
|---|
| 5400 | } |
|---|
| 5401 | len = iwr.u.data.length; |
|---|
| 5402 | if( len < sizeof( struct ieee80211req_sta_info ) ) |
|---|
| 5403 | { |
|---|
| 5404 | // fprintf(stderr,"IOCTL_STA_INFO len<struct %s failed!\n",ifname); |
|---|
| 5405 | close( s ); |
|---|
| 5406 | free( buf ); |
|---|
| 5407 | return cnt; |
|---|
| 5408 | } |
|---|
| 5409 | cp = buf; |
|---|
| 5410 | do |
|---|
| 5411 | { |
|---|
| 5412 | struct ieee80211req_sta_info *si; |
|---|
| 5413 | uint8_t *vp; |
|---|
| 5414 | |
|---|
| 5415 | si = ( struct ieee80211req_sta_info * )cp; |
|---|
| 5416 | vp = ( u_int8_t * ) ( si + 1 ); |
|---|
| 5417 | |
|---|
| 5418 | if( cnt ) |
|---|
| 5419 | websWrite( wp, "," ); |
|---|
| 5420 | cnt++; |
|---|
| 5421 | char mac[32]; |
|---|
| 5422 | |
|---|
| 5423 | strcpy( mac, ieee80211_ntoa( si->isi_macaddr ) ); |
|---|
| 5424 | if( nvram_match( "maskmac", "1" ) && macmask ) |
|---|
| 5425 | { |
|---|
| 5426 | mac[0] = 'x'; |
|---|
| 5427 | mac[1] = 'x'; |
|---|
| 5428 | mac[3] = 'x'; |
|---|
| 5429 | mac[4] = 'x'; |
|---|
| 5430 | mac[6] = 'x'; |
|---|
| 5431 | mac[7] = 'x'; |
|---|
| 5432 | mac[9] = 'x'; |
|---|
| 5433 | mac[10] = 'x'; |
|---|
| 5434 | } |
|---|
| 5435 | if( si->isi_noise == 0 ) |
|---|
| 5436 | { |
|---|
| 5437 | si->isi_noise = -95; |
|---|
| 5438 | } |
|---|
| 5439 | if( si->isi_rates |
|---|
| 5440 | && ( ( si->isi_rates[si->isi_txrate] & IEEE80211_RATE_VAL ) != 0 ) |
|---|
| 5441 | && ( ( si->isi_rates[si->isi_rxrate] & IEEE80211_RATE_VAL ) != |
|---|
| 5442 | 0 ) ) |
|---|
| 5443 | { |
|---|
| 5444 | websWrite( wp, "'%s','%s','%3dM','%3dM','%d','%d','%d'", |
|---|
| 5445 | mac, ifname, |
|---|
| 5446 | ( ( si-> |
|---|
| 5447 | isi_rates[si->isi_txrate] & IEEE80211_RATE_VAL ) / |
|---|
| 5448 | 2 ) * turbo, |
|---|
| 5449 | ( ( si-> |
|---|
| 5450 | isi_rates[si->isi_rxrate] & IEEE80211_RATE_VAL ) / |
|---|
| 5451 | 2 ) * turbo, si->isi_noise + si->isi_rssi, |
|---|
| 5452 | si->isi_noise, si->isi_rssi ); |
|---|
| 5453 | } |
|---|
| 5454 | else |
|---|
| 5455 | { |
|---|
| 5456 | websWrite( wp, "'%s','%s','N/A','N/A','%d','%d','%d'", mac, |
|---|
| 5457 | ifname, si->isi_noise + si->isi_rssi, si->isi_noise, |
|---|
| 5458 | si->isi_rssi ); |
|---|
| 5459 | } |
|---|
| 5460 | cp += si->isi_len; |
|---|
| 5461 | len -= si->isi_len; |
|---|
| 5462 | } |
|---|
| 5463 | while( len >= sizeof( struct ieee80211req_sta_info ) ); |
|---|
| 5464 | free( buf ); |
|---|
| 5465 | close( s ); |
|---|
| 5466 | |
|---|
| 5467 | return cnt; |
|---|
| 5468 | } |
|---|
| 5469 | extern char *getiflist( void ); |
|---|
| 5470 | |
|---|
| 5471 | void ej_active_wireless( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5472 | { |
|---|
| 5473 | int c = getdevicecount( ); |
|---|
| 5474 | char devs[32]; |
|---|
| 5475 | int i; |
|---|
| 5476 | int cnt = 0; |
|---|
| 5477 | char turbo[32]; |
|---|
| 5478 | int t; |
|---|
| 5479 | int macmask; |
|---|
| 5480 | |
|---|
| 5481 | #ifdef FASTWEB |
|---|
| 5482 | ejArgs( argc, argv, "%d", &macmask ); |
|---|
| 5483 | #else |
|---|
| 5484 | if( ejArgs( argc, argv, "%d", &macmask ) < 1 ) |
|---|
| 5485 | { |
|---|
| 5486 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 5487 | return; |
|---|
| 5488 | } |
|---|
| 5489 | #endif |
|---|
| 5490 | for( i = 0; i < c; i++ ) |
|---|
| 5491 | { |
|---|
| 5492 | sprintf( devs, "ath%d", i ); |
|---|
| 5493 | sprintf( turbo, "%s_channelbw", devs ); |
|---|
| 5494 | if( nvram_match( turbo, "40" ) ) |
|---|
| 5495 | t = 2; |
|---|
| 5496 | else |
|---|
| 5497 | t = 1; |
|---|
| 5498 | cnt = ej_active_wireless_if( wp, argc, argv, devs, cnt, t, macmask ); |
|---|
| 5499 | char vif[32]; |
|---|
| 5500 | |
|---|
| 5501 | sprintf( vif, "%s_vifs", devs ); |
|---|
| 5502 | char var[80], *next; |
|---|
| 5503 | char *vifs = nvram_get( vif ); |
|---|
| 5504 | |
|---|
| 5505 | if( vifs != NULL ) |
|---|
| 5506 | foreach( var, vifs, next ) |
|---|
| 5507 | { |
|---|
| 5508 | cnt = |
|---|
| 5509 | ej_active_wireless_if( wp, argc, argv, var, cnt, t, macmask ); |
|---|
| 5510 | } |
|---|
| 5511 | } |
|---|
| 5512 | |
|---|
| 5513 | // show wds links |
|---|
| 5514 | for( i = 0; i < c; i++ ) |
|---|
| 5515 | { |
|---|
| 5516 | |
|---|
| 5517 | int s; |
|---|
| 5518 | |
|---|
| 5519 | for( s = 1; s <= 10; s++ ) |
|---|
| 5520 | { |
|---|
| 5521 | char wdsvarname[32] = { 0 }; |
|---|
| 5522 | char wdsdevname[32] = { 0 }; |
|---|
| 5523 | char wdsmacname[32] = { 0 }; |
|---|
| 5524 | char *dev; |
|---|
| 5525 | char *hwaddr; |
|---|
| 5526 | char var[80]; |
|---|
| 5527 | |
|---|
| 5528 | sprintf( wdsvarname, "ath%d_wds%d_enable", i, s ); |
|---|
| 5529 | sprintf( wdsdevname, "ath%d_wds%d_if", i, s ); |
|---|
| 5530 | sprintf( wdsmacname, "ath%d_wds%d_hwaddr", i, s ); |
|---|
| 5531 | sprintf( turbo, "ath%d_channelbw", i ); |
|---|
| 5532 | if( nvram_match( turbo, "40" ) ) |
|---|
| 5533 | t = 2; |
|---|
| 5534 | else |
|---|
| 5535 | t = 1; |
|---|
| 5536 | |
|---|
| 5537 | dev = nvram_safe_get( wdsdevname ); |
|---|
| 5538 | if( dev == NULL || strlen( dev ) == 0 ) |
|---|
| 5539 | continue; |
|---|
| 5540 | if( nvram_match( wdsvarname, "0" ) ) |
|---|
| 5541 | continue; |
|---|
| 5542 | cnt = |
|---|
| 5543 | ej_active_wireless_if( wp, argc, argv, dev, cnt, t, macmask ); |
|---|
| 5544 | } |
|---|
| 5545 | } |
|---|
| 5546 | } |
|---|
| 5547 | |
|---|
| 5548 | #elif HAVE_RT2880 |
|---|
| 5549 | |
|---|
| 5550 | #include <sys/types.h> |
|---|
| 5551 | #include <sys/file.h> |
|---|
| 5552 | #include <sys/ioctl.h> |
|---|
| 5553 | #include <sys/socket.h> |
|---|
| 5554 | #include <stdio.h> |
|---|
| 5555 | #include <stdlib.h> |
|---|
| 5556 | #include <string.h> |
|---|
| 5557 | #include <stdint.h> |
|---|
| 5558 | #include <ctype.h> |
|---|
| 5559 | #include <getopt.h> |
|---|
| 5560 | #include <err.h> |
|---|
| 5561 | |
|---|
| 5562 | #include "wireless_copy.h" |
|---|
| 5563 | static const char *ieee80211_ntoa( const uint8_t mac[6] ) |
|---|
| 5564 | { |
|---|
| 5565 | static char a[18]; |
|---|
| 5566 | int i; |
|---|
| 5567 | |
|---|
| 5568 | i = snprintf( a, sizeof( a ), "%02x:%02x:%02x:%02x:%02x:%02x", |
|---|
| 5569 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] ); |
|---|
| 5570 | return ( i < 17 ? NULL : a ); |
|---|
| 5571 | } |
|---|
| 5572 | typedef union _MACHTTRANSMIT_SETTING { |
|---|
| 5573 | struct { |
|---|
| 5574 | unsigned short MCS:7; // MCS |
|---|
| 5575 | unsigned short BW:1; //channel bandwidth 20MHz or 40 MHz |
|---|
| 5576 | unsigned short ShortGI:1; |
|---|
| 5577 | unsigned short STBC:2; //SPACE |
|---|
| 5578 | unsigned short rsv:3; |
|---|
| 5579 | unsigned short MODE:2; // Use definition MODE_xxx. |
|---|
| 5580 | } field; |
|---|
| 5581 | unsigned short word; |
|---|
| 5582 | } MACHTTRANSMIT_SETTING; |
|---|
| 5583 | |
|---|
| 5584 | typedef struct _RT_802_11_MAC_ENTRY { |
|---|
| 5585 | unsigned char Addr[6]; |
|---|
| 5586 | unsigned char Aid; |
|---|
| 5587 | unsigned char Psm; // 0:PWR_ACTIVE, 1:PWR_SAVE |
|---|
| 5588 | unsigned char MimoPs; // 0:MMPS_STATIC, 1:MMPS_DYNAMIC, 3:MMPS_Enabled |
|---|
| 5589 | char AvgRssi0; |
|---|
| 5590 | char AvgRssi1; |
|---|
| 5591 | char AvgRssi2; |
|---|
| 5592 | unsigned int ConnectedTime; |
|---|
| 5593 | MACHTTRANSMIT_SETTING TxRate; |
|---|
| 5594 | } RT_802_11_MAC_ENTRY; |
|---|
| 5595 | |
|---|
| 5596 | typedef struct _RT_802_11_MAC_TABLE { |
|---|
| 5597 | unsigned long Num; |
|---|
| 5598 | RT_802_11_MAC_ENTRY Entry[32]; //MAX_LEN_OF_MAC_TABLE = 32 |
|---|
| 5599 | } RT_802_11_MAC_TABLE; |
|---|
| 5600 | |
|---|
| 5601 | #define RTPRIV_IOCTL_GET_MAC_TABLE (SIOCIWFIRSTPRIV + 0x0F)
|
|---|
| 5602 | |
|---|
| 5603 | int |
|---|
| 5604 | ej_active_wireless_if( webs_t wp, int argc, char_t ** argv, |
|---|
| 5605 | char *ifname, int cnt, int turbo, int macmask ) |
|---|
| 5606 | { |
|---|
| 5607 | |
|---|
| 5608 | RT_802_11_MAC_TABLE table = {0}; |
|---|
| 5609 | |
|---|
| 5610 | unsigned char *cp; |
|---|
| 5611 | int s, len,i; |
|---|
| 5612 | struct iwreq iwr; |
|---|
| 5613 | |
|---|
| 5614 | if( !ifexists( ifname ) ) |
|---|
| 5615 | { |
|---|
| 5616 | printf( "IOCTL_STA_INFO ifresolv %s failed!\n", ifname ); |
|---|
| 5617 | return cnt; |
|---|
| 5618 | } |
|---|
| 5619 | int state = get_radiostate( ifname ); |
|---|
| 5620 | |
|---|
| 5621 | if( state == 0 || state == -1 ) |
|---|
| 5622 | { |
|---|
| 5623 | printf( "IOCTL_STA_INFO radio %s not enabled!\n", ifname ); |
|---|
| 5624 | return cnt; |
|---|
| 5625 | } |
|---|
| 5626 | s = socket( AF_INET, SOCK_DGRAM, 0 ); |
|---|
| 5627 | if( s < 0 ) |
|---|
| 5628 | { |
|---|
| 5629 | fprintf( stderr, "socket(SOCK_DRAGM)\n" ); |
|---|
| 5630 | return cnt; |
|---|
| 5631 | } |
|---|
| 5632 | ( void )memset( &iwr, 0, sizeof( struct iwreq ) ); |
|---|
| 5633 | ( void )strncpy( iwr.ifr_name, ifname, sizeof( iwr.ifr_name ) ); |
|---|
| 5634 | |
|---|
| 5635 | iwr.u.data.pointer = (caddr_t) &table; |
|---|
| 5636 | // iwr.u.data.length = 24 * 1024; |
|---|
| 5637 | if( ioctl( s, RTPRIV_IOCTL_GET_MAC_TABLE, &iwr ) < 0 ) |
|---|
| 5638 | { |
|---|
| 5639 | fprintf( stderr, "IOCTL_STA_INFO for %s failed!\n", ifname ); |
|---|
| 5640 | close( s ); |
|---|
| 5641 | return cnt; |
|---|
| 5642 | } |
|---|
| 5643 | |
|---|
| 5644 | |
|---|
| 5645 | for (i = 0; i < table.Num; i++) { |
|---|
| 5646 | if( cnt ) |
|---|
| 5647 | websWrite( wp, "," ); |
|---|
| 5648 | cnt++; |
|---|
| 5649 | char mac[32]; |
|---|
| 5650 | strcpy( mac, ieee80211_ntoa( table.Entry[i].Addr ) ); |
|---|
| 5651 | if( nvram_match( "maskmac", "1" ) && macmask ) |
|---|
| 5652 | { |
|---|
| 5653 | mac[0] = 'x'; |
|---|
| 5654 | mac[1] = 'x'; |
|---|
| 5655 | mac[3] = 'x'; |
|---|
| 5656 | mac[4] = 'x'; |
|---|
| 5657 | mac[6] = 'x'; |
|---|
| 5658 | mac[7] = 'x'; |
|---|
| 5659 | mac[9] = 'x'; |
|---|
| 5660 | mac[10] = 'x'; |
|---|
| 5661 | } |
|---|
| 5662 | #if 0 |
|---|
| 5663 | if( si->isi_rates |
|---|
| 5664 | && ( ( si->isi_rates[si->isi_txrate] & IEEE80211_RATE_VAL ) != 0 ) |
|---|
| 5665 | && ( ( si->isi_rates[si->isi_rxrate] & IEEE80211_RATE_VAL ) != |
|---|
| 5666 | 0 ) ) |
|---|
| 5667 | { |
|---|
| 5668 | websWrite( wp, "'%s','%s','%3dM','%3dM','%d','%d','%d'", |
|---|
| 5669 | mac, ifname, |
|---|
| 5670 | ( ( si-> |
|---|
| 5671 | isi_rates[si->isi_txrate] & IEEE80211_RATE_VAL ) / |
|---|
| 5672 | 2 ) * turbo, |
|---|
| 5673 | ( ( si-> |
|---|
| 5674 | isi_rates[si->isi_rxrate] & IEEE80211_RATE_VAL ) / |
|---|
| 5675 | 2 ) * turbo, -95 + table.Entry[i].AvgRssi0, |
|---|
| 5676 | -95, table.Entry[i].AvgRssi0 ); |
|---|
| 5677 | } |
|---|
| 5678 | else |
|---|
| 5679 | #endif |
|---|
| 5680 | { |
|---|
| 5681 | websWrite( wp, "'%s','%s','N/A','N/A','%d','%d','%d'", mac, |
|---|
| 5682 | ifname, table.Entry[i].AvgRssi0, -95, |
|---|
| 5683 | (table.Entry[i].AvgRssi0 - (-95)) ); |
|---|
| 5684 | } |
|---|
| 5685 | } |
|---|
| 5686 | close( s ); |
|---|
| 5687 | |
|---|
| 5688 | return cnt; |
|---|
| 5689 | } |
|---|
| 5690 | extern char *getiflist( void ); |
|---|
| 5691 | |
|---|
| 5692 | void ej_active_wireless( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5693 | { |
|---|
| 5694 | char devs[32]; |
|---|
| 5695 | int i; |
|---|
| 5696 | int cnt = 0; |
|---|
| 5697 | char turbo[32]; |
|---|
| 5698 | int t; |
|---|
| 5699 | int macmask; |
|---|
| 5700 | |
|---|
| 5701 | #ifdef FASTWEB |
|---|
| 5702 | ejArgs( argc, argv, "%d", &macmask ); |
|---|
| 5703 | #else |
|---|
| 5704 | if( ejArgs( argc, argv, "%d", &macmask ) < 1 ) |
|---|
| 5705 | { |
|---|
| 5706 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 5707 | return; |
|---|
| 5708 | } |
|---|
| 5709 | #endif |
|---|
| 5710 | sprintf( devs, "ra0"); |
|---|
| 5711 | t = 1; |
|---|
| 5712 | cnt = ej_active_wireless_if( wp, argc, argv, "ra0", cnt, t, macmask ); |
|---|
| 5713 | |
|---|
| 5714 | } |
|---|
| 5715 | |
|---|
| 5716 | |
|---|
| 5717 | #else |
|---|
| 5718 | |
|---|
| 5719 | #define RSSI_TMP "/tmp/.rssi" |
|---|
| 5720 | #define ASSOCLIST_CMD "wl assoclist" |
|---|
| 5721 | #define RSSI_CMD "wl rssi" |
|---|
| 5722 | #define NOISE_CMD "wl noise" |
|---|
| 5723 | |
|---|
| 5724 | #ifndef HAVE_MSSID |
|---|
| 5725 | void ej_active_wireless( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5726 | { |
|---|
| 5727 | int rssi = 0, noise = 0; |
|---|
| 5728 | FILE *fp2; |
|---|
| 5729 | char *mode; |
|---|
| 5730 | char mac[30]; |
|---|
| 5731 | char list[2][30]; |
|---|
| 5732 | char line[80]; |
|---|
| 5733 | char cmd[80]; |
|---|
| 5734 | int macmask; |
|---|
| 5735 | |
|---|
| 5736 | #ifdef FASTWEB |
|---|
| 5737 | ejArgs( argc, argv, "%d", &macmask ); |
|---|
| 5738 | #else |
|---|
| 5739 | if( ejArgs( argc, argv, "%d", &macmask ) < 1 ) |
|---|
| 5740 | { |
|---|
| 5741 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 5742 | return; |
|---|
| 5743 | } |
|---|
| 5744 | #endif |
|---|
| 5745 | |
|---|
| 5746 | unlink( RSSI_TMP ); |
|---|
| 5747 | int cnt = 0; |
|---|
| 5748 | |
|---|
| 5749 | mode = nvram_safe_get( "wl_mode" ); |
|---|
| 5750 | unsigned char buf[WLC_IOCTL_MAXLEN]; |
|---|
| 5751 | |
|---|
| 5752 | memset( buf, 0, WLC_IOCTL_MAXLEN ); |
|---|
| 5753 | char *iface = get_wdev( ); |
|---|
| 5754 | |
|---|
| 5755 | if( !ifexists( iface ) ) |
|---|
| 5756 | return; |
|---|
| 5757 | int r = getassoclist( iface, buf ); |
|---|
| 5758 | |
|---|
| 5759 | if( r < 0 ) |
|---|
| 5760 | return; |
|---|
| 5761 | struct maclist *maclist = ( struct maclist * )buf; |
|---|
| 5762 | int i; |
|---|
| 5763 | |
|---|
| 5764 | for( i = 0; i < maclist->count; i++ ) |
|---|
| 5765 | { |
|---|
| 5766 | ether_etoa( ( uint8 * ) & maclist->ea[i], mac ); |
|---|
| 5767 | |
|---|
| 5768 | rssi = 0; |
|---|
| 5769 | noise = 0; |
|---|
| 5770 | // get rssi value |
|---|
| 5771 | if( strcmp( mode, "ap" ) && strcmp( mode, "apsta" ) |
|---|
| 5772 | && strcmp( mode, "apstawet" ) ) |
|---|
| 5773 | sysprintf( "%s > %s", RSSI_CMD, RSSI_TMP ); |
|---|
| 5774 | else |
|---|
| 5775 | sysprintf( "%s \"%s\" > %s", RSSI_CMD, mac, RSSI_TMP ); |
|---|
| 5776 | |
|---|
| 5777 | // get noise value if not ap mode |
|---|
| 5778 | if( strcmp( mode, "ap" ) ) |
|---|
| 5779 | sysprintf( "%s >> %s", NOISE_CMD, RSSI_TMP ); |
|---|
| 5780 | |
|---|
| 5781 | fp2 = fopen( RSSI_TMP, "r" ); |
|---|
| 5782 | if( fgets( line, sizeof( line ), fp2 ) != NULL ) |
|---|
| 5783 | { |
|---|
| 5784 | |
|---|
| 5785 | // get rssi |
|---|
| 5786 | // #ifdef HAVE_MSSID |
|---|
| 5787 | if( sscanf( line, "%d", &rssi ) != 1 ) |
|---|
| 5788 | continue; |
|---|
| 5789 | |
|---|
| 5790 | // noise=getNoise(iface); |
|---|
| 5791 | |
|---|
| 5792 | if( strcmp( mode, "ap" ) && |
|---|
| 5793 | fgets( line, sizeof( line ), fp2 ) != NULL && |
|---|
| 5794 | sscanf( line, "%d", &noise ) != 1 ) |
|---|
| 5795 | continue; |
|---|
| 5796 | /* |
|---|
| 5797 | * #else if (sscanf (line, "%s %s %d", list[0], list[1], &rssi) |
|---|
| 5798 | * != 3) continue; // noise=getNoise(iface); if (strcmp (mode, |
|---|
| 5799 | * "ap") && fgets (line, sizeof (line), fp2) != NULL && sscanf |
|---|
| 5800 | * (line, "%s %s %d", list[0], list[1], &noise) != 3) continue; |
|---|
| 5801 | * #endif |
|---|
| 5802 | */ |
|---|
| 5803 | // get noise for client/wet mode |
|---|
| 5804 | |
|---|
| 5805 | fclose( fp2 ); |
|---|
| 5806 | } |
|---|
| 5807 | if( nvram_match( "maskmac", "1" ) && macmask ) |
|---|
| 5808 | { |
|---|
| 5809 | mac[0] = 'x'; |
|---|
| 5810 | mac[1] = 'x'; |
|---|
| 5811 | mac[3] = 'x'; |
|---|
| 5812 | mac[4] = 'x'; |
|---|
| 5813 | mac[6] = 'x'; |
|---|
| 5814 | mac[7] = 'x'; |
|---|
| 5815 | mac[9] = 'x'; |
|---|
| 5816 | mac[10] = 'x'; |
|---|
| 5817 | } |
|---|
| 5818 | if( cnt ) |
|---|
| 5819 | websWrite( wp, "," ); |
|---|
| 5820 | cnt++; |
|---|
| 5821 | if( !strcmp( mode, "ap" ) ) |
|---|
| 5822 | { |
|---|
| 5823 | // char *ref = nvram_get ("noise_reference"); |
|---|
| 5824 | noise = -98; |
|---|
| 5825 | // if (ref) |
|---|
| 5826 | // noise = atoi (ref); |
|---|
| 5827 | } |
|---|
| 5828 | websWrite( wp, "'%s','%d','%d','%d'", mac, rssi, noise, |
|---|
| 5829 | rssi - noise ); |
|---|
| 5830 | } |
|---|
| 5831 | unlink( RSSI_TMP ); |
|---|
| 5832 | |
|---|
| 5833 | return; |
|---|
| 5834 | } |
|---|
| 5835 | #else |
|---|
| 5836 | int |
|---|
| 5837 | ej_active_wireless_if( webs_t wp, int argc, char_t ** argv, |
|---|
| 5838 | char *iface, char *visible, int cnt ) |
|---|
| 5839 | { |
|---|
| 5840 | int rssi = 0, noise = 0; |
|---|
| 5841 | FILE *fp2; |
|---|
| 5842 | char *mode; |
|---|
| 5843 | char mac[30]; |
|---|
| 5844 | char line[80]; |
|---|
| 5845 | int macmask; |
|---|
| 5846 | |
|---|
| 5847 | #ifdef FASTWEB |
|---|
| 5848 | ejArgs( argc, argv, "%d", &macmask ); |
|---|
| 5849 | #else |
|---|
| 5850 | if( ejArgs( argc, argv, "%d", &macmask ) < 1 ) |
|---|
| 5851 | { |
|---|
| 5852 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 5853 | return 0; |
|---|
| 5854 | } |
|---|
| 5855 | #endif |
|---|
| 5856 | if( !ifexists( iface ) ) |
|---|
| 5857 | return cnt; |
|---|
| 5858 | unlink( RSSI_TMP ); |
|---|
| 5859 | char wlmode[32]; |
|---|
| 5860 | |
|---|
| 5861 | sprintf( wlmode, "%s_mode", visible ); |
|---|
| 5862 | mode = nvram_safe_get( wlmode ); |
|---|
| 5863 | unsigned char buf[WLC_IOCTL_MAXLEN]; |
|---|
| 5864 | |
|---|
| 5865 | memset( buf, 0, WLC_IOCTL_MAXLEN ); // get_wdev |
|---|
| 5866 | int r = getassoclist( iface, buf ); |
|---|
| 5867 | |
|---|
| 5868 | if( r < 0 ) |
|---|
| 5869 | return cnt; |
|---|
| 5870 | struct maclist *maclist = ( struct maclist * )buf; |
|---|
| 5871 | int i; |
|---|
| 5872 | |
|---|
| 5873 | for( i = 0; i < maclist->count; i++ ) |
|---|
| 5874 | { |
|---|
| 5875 | ether_etoa( ( uint8 * ) & maclist->ea[i], mac ); |
|---|
| 5876 | |
|---|
| 5877 | rssi = 0; |
|---|
| 5878 | noise = 0; |
|---|
| 5879 | // get rssi value |
|---|
| 5880 | if( strcmp( mode, "ap" ) && strcmp( mode, "apsta" ) |
|---|
| 5881 | && strcmp( mode, "apstawet" ) ) |
|---|
| 5882 | sysprintf( "wl -i %s rssi > %s", iface, RSSI_TMP ); |
|---|
| 5883 | else |
|---|
| 5884 | sysprintf( "wl -i %s rssi \"%s\" > %s", iface, mac, RSSI_TMP ); |
|---|
| 5885 | |
|---|
| 5886 | // get noise value if not ap mode |
|---|
| 5887 | // if (strcmp (mode, "ap")) |
|---|
| 5888 | // snprintf (cmd, sizeof (cmd), "wl -i %s noise >> %s", iface, |
|---|
| 5889 | // RSSI_TMP); |
|---|
| 5890 | // system2 (cmd); // get RSSI value for mac |
|---|
| 5891 | |
|---|
| 5892 | fp2 = fopen( RSSI_TMP, "r" ); |
|---|
| 5893 | if( fgets( line, sizeof( line ), fp2 ) != NULL ) |
|---|
| 5894 | { |
|---|
| 5895 | |
|---|
| 5896 | // get rssi |
|---|
| 5897 | if( sscanf( line, "%d", &rssi ) != 1 ) |
|---|
| 5898 | continue; |
|---|
| 5899 | noise = getNoise( iface, NULL ); |
|---|
| 5900 | /* |
|---|
| 5901 | * if (strcmp (mode, "ap") && fgets (line, sizeof (line), fp2) != |
|---|
| 5902 | * NULL && sscanf (line, "%d", &noise) != 1) continue; |
|---|
| 5903 | */ |
|---|
| 5904 | // get noise for client/wet mode |
|---|
| 5905 | |
|---|
| 5906 | fclose( fp2 ); |
|---|
| 5907 | } |
|---|
| 5908 | if( nvram_match( "maskmac", "1" ) && macmask ) |
|---|
| 5909 | { |
|---|
| 5910 | mac[0] = 'x'; |
|---|
| 5911 | mac[1] = 'x'; |
|---|
| 5912 | mac[3] = 'x'; |
|---|
| 5913 | mac[4] = 'x'; |
|---|
| 5914 | mac[6] = 'x'; |
|---|
| 5915 | mac[7] = 'x'; |
|---|
| 5916 | mac[9] = 'x'; |
|---|
| 5917 | mac[10] = 'x'; |
|---|
| 5918 | } |
|---|
| 5919 | if( cnt ) |
|---|
| 5920 | websWrite( wp, "," ); |
|---|
| 5921 | cnt++; |
|---|
| 5922 | /* |
|---|
| 5923 | * if (!strcmp (mode, "ap")) { noise = getNoise(iface,NULL); // null |
|---|
| 5924 | * only for broadcom } |
|---|
| 5925 | */ |
|---|
| 5926 | websWrite( wp, "'%s','%s','N/A','N/A','%d','%d','%d'", mac, iface, |
|---|
| 5927 | rssi, noise, rssi - noise ); |
|---|
| 5928 | } |
|---|
| 5929 | unlink( RSSI_TMP ); |
|---|
| 5930 | |
|---|
| 5931 | return cnt; |
|---|
| 5932 | } |
|---|
| 5933 | |
|---|
| 5934 | void ej_active_wireless( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5935 | { |
|---|
| 5936 | int cnt = 0; |
|---|
| 5937 | int c = get_wl_instances( ); |
|---|
| 5938 | int i; |
|---|
| 5939 | |
|---|
| 5940 | for( i = 0; i < c; i++ ) |
|---|
| 5941 | { |
|---|
| 5942 | char wlif[32]; |
|---|
| 5943 | |
|---|
| 5944 | sprintf( wlif, "wl%d", i ); |
|---|
| 5945 | cnt = |
|---|
| 5946 | ej_active_wireless_if( wp, argc, argv, get_wl_instance_name( i ), |
|---|
| 5947 | wlif, cnt ); |
|---|
| 5948 | char *next; |
|---|
| 5949 | char var[80]; |
|---|
| 5950 | char *vifs = nvram_nget( "wl%d_vifs", i ); |
|---|
| 5951 | |
|---|
| 5952 | if( vifs == NULL ) |
|---|
| 5953 | return; |
|---|
| 5954 | |
|---|
| 5955 | foreach( var, vifs, next ) |
|---|
| 5956 | { |
|---|
| 5957 | cnt = ej_active_wireless_if( wp, argc, argv, var, var, cnt ); |
|---|
| 5958 | } |
|---|
| 5959 | } |
|---|
| 5960 | } |
|---|
| 5961 | |
|---|
| 5962 | #endif |
|---|
| 5963 | |
|---|
| 5964 | #endif |
|---|
| 5965 | |
|---|
| 5966 | #define WDS_RSSI_TMP "/tmp/.rssi" |
|---|
| 5967 | void ej_active_wds_instance( webs_t wp, int argc, char_t ** argv, |
|---|
| 5968 | int instance ); |
|---|
| 5969 | void ej_active_wds( webs_t wp, int argc, char_t ** argv ) |
|---|
| 5970 | { |
|---|
| 5971 | int cnt = get_wl_instances( ); |
|---|
| 5972 | int c; |
|---|
| 5973 | |
|---|
| 5974 | for( c = 0; c < cnt; c++ ) |
|---|
| 5975 | ej_active_wds_instance( wp, argc, argv, c ); |
|---|
| 5976 | } |
|---|
| 5977 | |
|---|
| 5978 | void |
|---|
| 5979 | ej_active_wds_instance( webs_t wp, int argc, char_t ** argv, int instance ) |
|---|
| 5980 | { |
|---|
| 5981 | #if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880) |
|---|
| 5982 | int rssi = 0, i; |
|---|
| 5983 | FILE *fp2; |
|---|
| 5984 | char *mode; |
|---|
| 5985 | char mac[30]; |
|---|
| 5986 | char line[80]; |
|---|
| 5987 | |
|---|
| 5988 | // char title[30]; |
|---|
| 5989 | char wdsvar[30]; |
|---|
| 5990 | char desc[30]; |
|---|
| 5991 | int cnt = 0; |
|---|
| 5992 | int macmask; |
|---|
| 5993 | |
|---|
| 5994 | if( ejArgs( argc, argv, "%d", &macmask ) < 1 ) |
|---|
| 5995 | { |
|---|
| 5996 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 5997 | return; |
|---|
| 5998 | } |
|---|
| 5999 | |
|---|
| 6000 | unlink( WDS_RSSI_TMP ); |
|---|
| 6001 | |
|---|
| 6002 | mode = nvram_nget( "wl%d_mode", instance ); |
|---|
| 6003 | |
|---|
| 6004 | if( strcmp( mode, "ap" ) && strcmp( mode, "apsta" ) |
|---|
| 6005 | && strcmp( mode, "apstawet" ) ) |
|---|
| 6006 | return; |
|---|
| 6007 | unsigned char buf[WLC_IOCTL_MAXLEN]; |
|---|
| 6008 | char *iface = get_wl_instance_name( instance ); |
|---|
| 6009 | |
|---|
| 6010 | if( !ifexists( iface ) ) |
|---|
| 6011 | return; |
|---|
| 6012 | int r = getwdslist( iface, buf ); |
|---|
| 6013 | |
|---|
| 6014 | if( r < 0 ) |
|---|
| 6015 | return; |
|---|
| 6016 | struct maclist *maclist = ( struct maclist * )buf; |
|---|
| 6017 | int e; |
|---|
| 6018 | |
|---|
| 6019 | for( e = 0; e < maclist->count; e++ ) |
|---|
| 6020 | { |
|---|
| 6021 | |
|---|
| 6022 | ether_etoa( ( uint8 * ) & maclist->ea[e], mac ); |
|---|
| 6023 | |
|---|
| 6024 | rssi = 0; |
|---|
| 6025 | memset( desc, 0, 30 ); |
|---|
| 6026 | for( i = 1; i <= 10; i++ ) |
|---|
| 6027 | { |
|---|
| 6028 | snprintf( wdsvar, 30, "wl%d_wds%d_hwaddr", instance, i ); |
|---|
| 6029 | if( nvram_match( wdsvar, mac ) ) |
|---|
| 6030 | { |
|---|
| 6031 | snprintf( wdsvar, 30, "wl%d_wds%d_desc", instance, i ); |
|---|
| 6032 | snprintf( desc, sizeof( desc ), "%s", nvram_get( wdsvar ) ); |
|---|
| 6033 | if( !strcmp( nvram_get( wdsvar ), "" ) ) |
|---|
| 6034 | strcpy( desc, " " ); |
|---|
| 6035 | } |
|---|
| 6036 | } |
|---|
| 6037 | |
|---|
| 6038 | sysprintf( "%s \"%s\" > %s", RSSI_CMD, mac, RSSI_TMP ); |
|---|
| 6039 | |
|---|
| 6040 | fp2 = fopen( RSSI_TMP, "r" ); |
|---|
| 6041 | if( fgets( line, sizeof( line ), fp2 ) != NULL ) |
|---|
| 6042 | { |
|---|
| 6043 | |
|---|
| 6044 | // get rssi |
|---|
| 6045 | if( sscanf( line, "%d", &rssi ) != 1 ) |
|---|
| 6046 | continue; |
|---|
| 6047 | fclose( fp2 ); |
|---|
| 6048 | } |
|---|
| 6049 | if( nvram_match( "maskmac", "1" ) && macmask ) |
|---|
| 6050 | { |
|---|
| 6051 | mac[0] = 'x'; |
|---|
| 6052 | mac[1] = 'x'; |
|---|
| 6053 | mac[3] = 'x'; |
|---|
| 6054 | mac[4] = 'x'; |
|---|
| 6055 | mac[6] = 'x'; |
|---|
| 6056 | mac[7] = 'x'; |
|---|
| 6057 | mac[9] = 'x'; |
|---|
| 6058 | mac[10] = 'x'; |
|---|
| 6059 | } |
|---|
| 6060 | if( cnt ) |
|---|
| 6061 | websWrite( wp, "," ); |
|---|
| 6062 | cnt++; |
|---|
| 6063 | int noise = getNoise( iface, NULL ); |
|---|
| 6064 | |
|---|
| 6065 | websWrite( wp, |
|---|
| 6066 | "\"%s\",\"%s\",\"%d\",\"%d\",\"%d\"", |
|---|
| 6067 | mac, desc, rssi, noise, rssi - noise ); |
|---|
| 6068 | } |
|---|
| 6069 | |
|---|
| 6070 | unlink( WDS_RSSI_TMP ); |
|---|
| 6071 | #endif |
|---|
| 6072 | return; |
|---|
| 6073 | } |
|---|
| 6074 | |
|---|
| 6075 | void ej_get_wdsp2p( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6076 | { |
|---|
| 6077 | int index = -1, ip[4] = { 0, 0, 0, 0 }, netmask[4] = |
|---|
| 6078 | { |
|---|
| 6079 | 0, 0, 0, 0}; |
|---|
| 6080 | char nvramvar[32] = { 0 }; |
|---|
| 6081 | char *interface; |
|---|
| 6082 | |
|---|
| 6083 | #ifdef FASTWEB |
|---|
| 6084 | ejArgs( argc, argv, "%d %s", &index, &interface ); |
|---|
| 6085 | #else |
|---|
| 6086 | if( ejArgs( argc, argv, "%d %s", &index, &interface ) < 2 ) |
|---|
| 6087 | { |
|---|
| 6088 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 6089 | return; |
|---|
| 6090 | } |
|---|
| 6091 | #endif |
|---|
| 6092 | char wlwds[32]; |
|---|
| 6093 | |
|---|
| 6094 | sprintf( wlwds, "%s_wds1_enable", interface ); |
|---|
| 6095 | if( nvram_selmatch( wp, "wk_mode", "ospf" ) && |
|---|
| 6096 | nvram_selmatch( wp, "expert_mode", "1" ) && |
|---|
| 6097 | nvram_selmatch( wp, wlwds, "1" ) ) |
|---|
| 6098 | { |
|---|
| 6099 | char buf[16]; |
|---|
| 6100 | |
|---|
| 6101 | sprintf( buf, "%s_wds%d_ospf", interface, index ); |
|---|
| 6102 | websWrite( wp, |
|---|
| 6103 | "<input name=\"%s\" size=\"2\" maxlength=\"5\" value=\"%s\" />\n", |
|---|
| 6104 | buf, nvram_safe_get( buf ) ); |
|---|
| 6105 | } |
|---|
| 6106 | |
|---|
| 6107 | snprintf( nvramvar, 31, "%s_wds%d_ipaddr", interface, index ); |
|---|
| 6108 | sscanf( nvram_safe_get( nvramvar ), "%d.%d.%d.%d", &ip[0], &ip[1], &ip[2], |
|---|
| 6109 | &ip[3] ); |
|---|
| 6110 | snprintf( nvramvar, 31, "%s_wds%d_netmask", interface, index ); |
|---|
| 6111 | sscanf( nvram_safe_get( nvramvar ), "%d.%d.%d.%d", &netmask[0], |
|---|
| 6112 | &netmask[1], &netmask[2], &netmask[3] ); |
|---|
| 6113 | snprintf( nvramvar, 31, "%s_wds%d_enable", interface, index ); |
|---|
| 6114 | |
|---|
| 6115 | // set netmask to a suggested default if blank |
|---|
| 6116 | if( netmask[0] == 0 && |
|---|
| 6117 | netmask[1] == 0 && netmask[2] == 0 && netmask[3] == 0 ) |
|---|
| 6118 | { |
|---|
| 6119 | netmask[0] = 255; |
|---|
| 6120 | netmask[1] = 255; |
|---|
| 6121 | netmask[2] = 255; |
|---|
| 6122 | netmask[3] = 252; |
|---|
| 6123 | } |
|---|
| 6124 | |
|---|
| 6125 | if( nvram_match( nvramvar, "1" ) ) |
|---|
| 6126 | { |
|---|
| 6127 | websWrite( wp, "\ |
|---|
| 6128 | <div class=\"setting\">\n\ |
|---|
| 6129 | <input type=\"hidden\" name=\"%s_wds%d_ipaddr\" value=\"4\">\n\ |
|---|
| 6130 | <div class=\"label\"><script type=\"text/javascript\">Capture(share.ip)</script></div>\n\ |
|---|
| 6131 | <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\ |
|---|
| 6132 | </div>\n", interface, index, interface, index, ip[0], interface, index, ip[1], interface, index, ip[2], interface, index, ip[3] ); |
|---|
| 6133 | |
|---|
| 6134 | websWrite( wp, "\ |
|---|
| 6135 | <div class=\"setting\">\n\ |
|---|
| 6136 | <div class=\"label\"><script type=\"text/javascript\">Capture(share.subnet)</script></div>\n\ |
|---|
| 6137 | <input type=\"hidden\" name=\"%s_wds%d_netmask\" value=\"4\">\n\ |
|---|
| 6138 | <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\ |
|---|
| 6139 | </div>\n", interface, index, interface, index, netmask[0], interface, index, netmask[1], interface, index, netmask[2], interface, index, netmask[3] ); |
|---|
| 6140 | |
|---|
| 6141 | } |
|---|
| 6142 | |
|---|
| 6143 | return; |
|---|
| 6144 | |
|---|
| 6145 | } |
|---|
| 6146 | |
|---|
| 6147 | /* |
|---|
| 6148 | * void ej_get_services_options (webs_t wp, int argc, char_t ** argv) { char |
|---|
| 6149 | * word[1024], *next, *services; char delim[] = "< >"; |
|---|
| 6150 | * |
|---|
| 6151 | * //services = nvram_safe_get("filter_services"); services = |
|---|
| 6152 | * get_filter_services (); |
|---|
| 6153 | * |
|---|
| 6154 | * split (word, services, next, delim) { int len = 0; char *name, *prot, |
|---|
| 6155 | * *port; char protocol[100], ports[100]; int from = 0, to = 0; //int proto; |
|---|
| 6156 | * |
|---|
| 6157 | * if ((name = strstr (word, "$NAME:")) == NULL || (prot = strstr (word, |
|---|
| 6158 | * "$PROT:")) == NULL || (port = strstr (word, "$PORT:")) == NULL) continue; |
|---|
| 6159 | * |
|---|
| 6160 | * // $NAME if (sscanf (name, "$NAME:%3d:", &len) != 1) continue; |
|---|
| 6161 | * |
|---|
| 6162 | * strncpy (name, name + sizeof ("$NAME:nnn:") - 1, len); name[len] = '\0'; |
|---|
| 6163 | * |
|---|
| 6164 | * // $PROT if (sscanf (prot, "$PROT:%3d:", &len) != 1) continue; |
|---|
| 6165 | * |
|---|
| 6166 | * strncpy (protocol, prot + sizeof ("$PROT:nnn:") - 1, len); protocol[len] = |
|---|
| 6167 | * '\0'; |
|---|
| 6168 | * |
|---|
| 6169 | * // $PORT if (sscanf (port, "$PORT:%3d:", &len) != 1) continue; |
|---|
| 6170 | * |
|---|
| 6171 | * strncpy (ports, port + sizeof ("$PORT:nnn:") - 1, len); ports[len] = '\0'; |
|---|
| 6172 | * |
|---|
| 6173 | * if (sscanf (ports, "%d:%d", &from, &to) != 2) continue; |
|---|
| 6174 | * |
|---|
| 6175 | * //cprintf("match:: name=%s, protocol=%s, ports=%s\n", // word, protocol, |
|---|
| 6176 | * ports); |
|---|
| 6177 | * |
|---|
| 6178 | * websWrite (wp, "<option value=\"%s\">%s</option>", name, name); |
|---|
| 6179 | * |
|---|
| 6180 | * } |
|---|
| 6181 | * |
|---|
| 6182 | * return; } |
|---|
| 6183 | */ |
|---|
| 6184 | |
|---|
| 6185 | void ej_get_clone_wmac( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6186 | { |
|---|
| 6187 | #ifdef HAVE_RB500 |
|---|
| 6188 | return 0; |
|---|
| 6189 | #else |
|---|
| 6190 | |
|---|
| 6191 | char *c; |
|---|
| 6192 | int mac, which; |
|---|
| 6193 | int dofree = 0; |
|---|
| 6194 | |
|---|
| 6195 | #ifdef FASTWEB |
|---|
| 6196 | ejArgs( argc, argv, "%d", &which ); |
|---|
| 6197 | #else |
|---|
| 6198 | if( ejArgs( argc, argv, "%d", &which ) < 1 ) |
|---|
| 6199 | { |
|---|
| 6200 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 6201 | return; |
|---|
| 6202 | } |
|---|
| 6203 | #endif |
|---|
| 6204 | |
|---|
| 6205 | if( nvram_match( "def_whwaddr", "00:00:00:00:00:00" ) ) |
|---|
| 6206 | { |
|---|
| 6207 | // if (strlen (nvram_safe_get ("il0macaddr")) == 0) |
|---|
| 6208 | // { |
|---|
| 6209 | // if (nvram_match ("port_swap", "1")) |
|---|
| 6210 | // c = strdup (nvram_safe_get ("et1macaddr")); |
|---|
| 6211 | // else |
|---|
| 6212 | // c = strdup (nvram_safe_get ("et0macaddr")); |
|---|
| 6213 | // MAC_ADD (c); |
|---|
| 6214 | // } |
|---|
| 6215 | // else |
|---|
| 6216 | // { |
|---|
| 6217 | // c = strdup (nvram_safe_get ("il0macaddr")); |
|---|
| 6218 | // } |
|---|
| 6219 | // dofree = 1; |
|---|
| 6220 | |
|---|
| 6221 | if( nvram_match( "port_swap", "1" ) ) |
|---|
| 6222 | { |
|---|
| 6223 | if( strlen( nvram_safe_get( "et1macaddr" ) ) != 0 ) // safe: |
|---|
| 6224 | // maybe |
|---|
| 6225 | // et1macaddr |
|---|
| 6226 | // not there? |
|---|
| 6227 | { |
|---|
| 6228 | c = strdup( nvram_safe_get( "et1macaddr" ) ); |
|---|
| 6229 | } |
|---|
| 6230 | else |
|---|
| 6231 | { |
|---|
| 6232 | c = strdup( nvram_safe_get( "et0macaddr" ) ); |
|---|
| 6233 | MAC_ADD( c ); // et0macaddr +3 |
|---|
| 6234 | } |
|---|
| 6235 | } |
|---|
| 6236 | else |
|---|
| 6237 | { |
|---|
| 6238 | c = strdup( nvram_safe_get( "et0macaddr" ) ); |
|---|
| 6239 | } |
|---|
| 6240 | |
|---|
| 6241 | dofree = 1; |
|---|
| 6242 | if( c ) |
|---|
| 6243 | { |
|---|
| 6244 | MAC_ADD( c ); |
|---|
| 6245 | MAC_ADD( c ); |
|---|
| 6246 | } |
|---|
| 6247 | |
|---|
| 6248 | } |
|---|
| 6249 | else |
|---|
| 6250 | c = nvram_safe_get( "def_whwaddr" ); |
|---|
| 6251 | |
|---|
| 6252 | if( c ) |
|---|
| 6253 | { |
|---|
| 6254 | mac = get_single_mac( c, which ); |
|---|
| 6255 | websWrite( wp, "%02X", mac ); |
|---|
| 6256 | if( dofree ) |
|---|
| 6257 | free( c ); |
|---|
| 6258 | } |
|---|
| 6259 | else |
|---|
| 6260 | websWrite( wp, "00" ); |
|---|
| 6261 | |
|---|
| 6262 | return; |
|---|
| 6263 | #endif |
|---|
| 6264 | } |
|---|
| 6265 | |
|---|
| 6266 | /* |
|---|
| 6267 | * todo stylesheet compatible code |
|---|
| 6268 | */ |
|---|
| 6269 | /* |
|---|
| 6270 | * lonewolf additions |
|---|
| 6271 | */ |
|---|
| 6272 | |
|---|
| 6273 | // Note that there is no VLAN #16. It's just a convieniant way of denoting a |
|---|
| 6274 | // "Tagged" port |
|---|
| 6275 | void ej_port_vlan_table( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6276 | { |
|---|
| 6277 | /* |
|---|
| 6278 | * vlans[x][y] where x 0-15 are VLANS x 16 is tagging, 17 is |
|---|
| 6279 | * auto-negotiation, 18 is 100/10 Mbit, and 19 is Full/Half duplex y 0-4 |
|---|
| 6280 | * are switch ports (port 5 is set automaticly) y 5 it the bridge device |
|---|
| 6281 | * (x 16 dosn't apply) |
|---|
| 6282 | */ |
|---|
| 6283 | |
|---|
| 6284 | int i, j, vlans[21][6], tmp, wl_br; |
|---|
| 6285 | char *c, *next, buff[32], portvlan[32]; |
|---|
| 6286 | |
|---|
| 6287 | for( i = 0; i < 21; i++ ) |
|---|
| 6288 | for( j = 0; j < 6; j++ ) |
|---|
| 6289 | vlans[i][j] = -1; |
|---|
| 6290 | |
|---|
| 6291 | wl_br = -1; |
|---|
| 6292 | |
|---|
| 6293 | for( i = 0; i < 8; i++ ) |
|---|
| 6294 | { |
|---|
| 6295 | if( i < 5 ) |
|---|
| 6296 | snprintf( buff, 31, "port%dvlans", i ); |
|---|
| 6297 | else if( i == 5 ) |
|---|
| 6298 | snprintf( buff, 31, "%s", "lan_ifnames" ); |
|---|
| 6299 | else |
|---|
| 6300 | snprintf( buff, 31, "ub%d_ifnames", i - 5 ); |
|---|
| 6301 | |
|---|
| 6302 | c = nvram_safe_get( buff ); |
|---|
| 6303 | |
|---|
| 6304 | if( c ) |
|---|
| 6305 | { |
|---|
| 6306 | foreach( portvlan, c, next ) |
|---|
| 6307 | { |
|---|
| 6308 | if( portvlan[0] == 'e' && portvlan[1] == 't' |
|---|
| 6309 | && portvlan[2] == 'h' && portvlan[3] == '1' ) |
|---|
| 6310 | wl_br = i - 5; |
|---|
| 6311 | if( ISDIGIT( portvlan, 1 ) |
|---|
| 6312 | || ( portvlan[0] == 'v' && portvlan[1] == 'l' |
|---|
| 6313 | && portvlan[2] == 'a' && portvlan[3] == 'n' ) ) |
|---|
| 6314 | { |
|---|
| 6315 | if( ISDIGIT( portvlan, 1 ) ) |
|---|
| 6316 | tmp = atoi( portvlan ); |
|---|
| 6317 | else |
|---|
| 6318 | { |
|---|
| 6319 | portvlan[0] = portvlan[4]; |
|---|
| 6320 | portvlan[1] = portvlan[5]; |
|---|
| 6321 | portvlan[2] = '\0'; |
|---|
| 6322 | if( ISDIGIT( portvlan, 1 ) ) |
|---|
| 6323 | tmp = atoi( portvlan ); |
|---|
| 6324 | else |
|---|
| 6325 | continue; |
|---|
| 6326 | } |
|---|
| 6327 | |
|---|
| 6328 | if( i < 5 ) |
|---|
| 6329 | { |
|---|
| 6330 | vlans[tmp][i] = 1; |
|---|
| 6331 | } |
|---|
| 6332 | else |
|---|
| 6333 | { |
|---|
| 6334 | vlans[tmp][5] = i - 5; |
|---|
| 6335 | } |
|---|
| 6336 | } |
|---|
| 6337 | } |
|---|
| 6338 | } |
|---|
| 6339 | } |
|---|
| 6340 | |
|---|
| 6341 | for( i = 0; i < 21; i++ ) |
|---|
| 6342 | { |
|---|
| 6343 | websWrite( wp, " <tr>\n" ); |
|---|
| 6344 | websWrite( wp, "<td>" ); |
|---|
| 6345 | |
|---|
| 6346 | switch ( i ) |
|---|
| 6347 | { |
|---|
| 6348 | case 16: |
|---|
| 6349 | websWrite( wp, |
|---|
| 6350 | "<script type=\"text/javascript\">Capture(vlan.tagged)</script>" ); |
|---|
| 6351 | break; |
|---|
| 6352 | case 17: |
|---|
| 6353 | websWrite( wp, |
|---|
| 6354 | "<script type=\"text/javascript\">Capture(vlan.negociate)</script>" ); |
|---|
| 6355 | break; |
|---|
| 6356 | case 18: |
|---|
| 6357 | websWrite( wp, "100 Mbit" ); |
|---|
| 6358 | break; |
|---|
| 6359 | case 19: |
|---|
| 6360 | websWrite( wp, "Full-Duplex" ); |
|---|
| 6361 | break; |
|---|
| 6362 | case 20: |
|---|
| 6363 | websWrite( wp, "Enabled" ); |
|---|
| 6364 | break; |
|---|
| 6365 | default: |
|---|
| 6366 | snprintf( buff, 31, "%d", i ); |
|---|
| 6367 | websWrite( wp, buff ); |
|---|
| 6368 | break; |
|---|
| 6369 | } |
|---|
| 6370 | |
|---|
| 6371 | websWrite( wp, "</td>\n" ); |
|---|
| 6372 | |
|---|
| 6373 | for( j = 0; j < 5; j++ ) |
|---|
| 6374 | { |
|---|
| 6375 | snprintf( buff, 31, "\"port%dvlan%d\"", j, i ); |
|---|
| 6376 | websWrite( wp, "<td" ); |
|---|
| 6377 | |
|---|
| 6378 | if( j % 2 == 0 ) |
|---|
| 6379 | websWrite( wp, " bgcolor=\"#CCCCCC\"" ); |
|---|
| 6380 | |
|---|
| 6381 | websWrite( wp, |
|---|
| 6382 | " height=\"20\"><div align=\"center\"><input type=\"checkbox\" value=\"on\" name=" ); |
|---|
| 6383 | websWrite( wp, buff ); |
|---|
| 6384 | |
|---|
| 6385 | if( i < 17 || i > 20 ) |
|---|
| 6386 | { |
|---|
| 6387 | if( vlans[i][j] == 1 ) |
|---|
| 6388 | websWrite( wp, " checked=\"checked\"" ); |
|---|
| 6389 | } |
|---|
| 6390 | else |
|---|
| 6391 | { |
|---|
| 6392 | if( vlans[i][j] == -1 ) |
|---|
| 6393 | websWrite( wp, " checked=\"checked\"" ); |
|---|
| 6394 | } |
|---|
| 6395 | |
|---|
| 6396 | if( i < 17 ) |
|---|
| 6397 | { |
|---|
| 6398 | websWrite( wp, " onclick=" ); |
|---|
| 6399 | snprintf( buff, sizeof( buff ), |
|---|
| 6400 | "\"SelVLAN(this.form,'port%d')\"", j ); |
|---|
| 6401 | websWrite( wp, buff ); |
|---|
| 6402 | } |
|---|
| 6403 | else if( i == 17 || i == 20 ) |
|---|
| 6404 | { |
|---|
| 6405 | websWrite( wp, " onclick=" ); |
|---|
| 6406 | snprintf( buff, sizeof( buff ), |
|---|
| 6407 | "\"SelSpeed(this.form,'port%d')\"", j ); |
|---|
| 6408 | websWrite( wp, buff ); |
|---|
| 6409 | } |
|---|
| 6410 | websWrite( wp, " /></div></td>\n" ); |
|---|
| 6411 | } |
|---|
| 6412 | |
|---|
| 6413 | if( i < 16 ) |
|---|
| 6414 | { |
|---|
| 6415 | websWrite( wp, " <td><select name=" ); |
|---|
| 6416 | snprintf( buff, 31, "\"vlan%d\"", i ); |
|---|
| 6417 | websWrite( wp, buff ); |
|---|
| 6418 | websWrite( wp, |
|---|
| 6419 | "><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"-1\\\"" ); |
|---|
| 6420 | if( vlans[i][5] < 0 ) |
|---|
| 6421 | websWrite( wp, " selected=\\\"selected\\\"" ); |
|---|
| 6422 | websWrite( wp, |
|---|
| 6423 | ">\" + share.none + \"</option>\");\n//]]>\n</script><option value=\"0\"" ); |
|---|
| 6424 | if( vlans[i][5] == 0 ) |
|---|
| 6425 | websWrite( wp, " selected=\"selected\"" ); |
|---|
| 6426 | websWrite( wp, ">LAN</option></select></td>\n" ); |
|---|
| 6427 | } |
|---|
| 6428 | else |
|---|
| 6429 | { |
|---|
| 6430 | websWrite( wp, "<td> </td>\n" ); |
|---|
| 6431 | } |
|---|
| 6432 | |
|---|
| 6433 | websWrite( wp, "</tr>\n" ); |
|---|
| 6434 | |
|---|
| 6435 | if( i == 16 || i == 20 ) |
|---|
| 6436 | { |
|---|
| 6437 | websWrite( wp, "<tr><td> </td></tr>\n" ); |
|---|
| 6438 | } |
|---|
| 6439 | } |
|---|
| 6440 | |
|---|
| 6441 | websWrite( wp, "<tr>\n" ); |
|---|
| 6442 | websWrite( wp, |
|---|
| 6443 | "<td><script type=\"text/javascript\">Capture(share.wireless)</script></td>\n" ); |
|---|
| 6444 | |
|---|
| 6445 | websWrite( wp, |
|---|
| 6446 | "<td colspan=\"6\"><select name=\"wireless\"><script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"-1\\\"" ); |
|---|
| 6447 | if( wl_br < 0 ) |
|---|
| 6448 | websWrite( wp, " selected=\\\"selected\\\"" ); |
|---|
| 6449 | websWrite( wp, |
|---|
| 6450 | ">\" + share.none + \"</option>\");\n//]]>\n</script><option value=\"0\"" ); |
|---|
| 6451 | if( wl_br == 0 ) |
|---|
| 6452 | websWrite( wp, " selected=\"selected\"" ); |
|---|
| 6453 | websWrite( wp, ">LAN</option></select></td>\n" ); |
|---|
| 6454 | websWrite( wp, "</tr>\n" ); |
|---|
| 6455 | |
|---|
| 6456 | websWrite( wp, "<tr><td> </td></tr>\n" ); |
|---|
| 6457 | |
|---|
| 6458 | websWrite( wp, "<tr>\n" ); |
|---|
| 6459 | websWrite( wp, |
|---|
| 6460 | "<td><script type=\"text/javascript\">Capture(vlan.aggregation)</script></td>\n" ); |
|---|
| 6461 | |
|---|
| 6462 | websWrite( wp, |
|---|
| 6463 | "<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\\\"" ); |
|---|
| 6464 | |
|---|
| 6465 | c = nvram_safe_get( "trunking" ); |
|---|
| 6466 | |
|---|
| 6467 | snprintf( buff, 5, "%s", c ); |
|---|
| 6468 | |
|---|
| 6469 | if( atoi( buff ) == 1 ) |
|---|
| 6470 | websWrite( wp, " selected=\\\"selected\\\"" ); |
|---|
| 6471 | |
|---|
| 6472 | websWrite( wp, |
|---|
| 6473 | ">\" + vlan.trunk + \"</option>\");\n//]]>\n</script></select></td>\n" ); |
|---|
| 6474 | websWrite( wp, " </tr>" ); |
|---|
| 6475 | |
|---|
| 6476 | return; |
|---|
| 6477 | } |
|---|
| 6478 | |
|---|
| 6479 | /* |
|---|
| 6480 | * Note: VLAN #16 designates tagging. There is no VLAN #16 (only 0-15) |
|---|
| 6481 | */ |
|---|
| 6482 | |
|---|
| 6483 | void ej_get_qossvcs( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6484 | { |
|---|
| 6485 | char *qos_svcs = nvram_safe_get( "svqos_svcs" ); |
|---|
| 6486 | char name[32], type[32], data[32], level[32]; |
|---|
| 6487 | int no_svcs = 0, i = 0; |
|---|
| 6488 | |
|---|
| 6489 | // calc # of services |
|---|
| 6490 | // no_svcs = strspn(qos_svcs,"|"); |
|---|
| 6491 | |
|---|
| 6492 | while( ( qos_svcs = strpbrk( qos_svcs, "|" ) ) ) |
|---|
| 6493 | { |
|---|
| 6494 | no_svcs++; |
|---|
| 6495 | qos_svcs++; |
|---|
| 6496 | } |
|---|
| 6497 | |
|---|
| 6498 | // write HTML data |
|---|
| 6499 | |
|---|
| 6500 | websWrite( wp, |
|---|
| 6501 | "<tr><td colspan=\"3\"><input type=\"hidden\" name=\"svqos_nosvcs\" value=\"%d\" /></td></tr>", |
|---|
| 6502 | no_svcs ); |
|---|
| 6503 | |
|---|
| 6504 | qos_svcs = nvram_safe_get( "svqos_svcs" ); |
|---|
| 6505 | |
|---|
| 6506 | /* |
|---|
| 6507 | * services format is "name type data level | name type data level |" |
|---|
| 6508 | * ..etc |
|---|
| 6509 | */ |
|---|
| 6510 | for( i = 0; i < no_svcs && qos_svcs && qos_svcs[0]; i++ ) |
|---|
| 6511 | { |
|---|
| 6512 | if( sscanf |
|---|
| 6513 | ( qos_svcs, "%31s %31s %31s %31s ", name, type, data, |
|---|
| 6514 | level ) < 4 ) |
|---|
| 6515 | break; |
|---|
| 6516 | |
|---|
| 6517 | websWrite( wp, "<tr>\n\ |
|---|
| 6518 | <td>\n\ |
|---|
| 6519 | <input type=\"checkbox\" name=\"svqos_svcdel%d\" />\n\ |
|---|
| 6520 | <input type=\"hidden\" name=\"svqos_svcname%d\" value=\"%s\" />\n\ |
|---|
| 6521 | <input type=\"hidden\" name=\"svqos_svctype%d\" value=\"%s\" />\n\ |
|---|
| 6522 | </td>\n\ |
|---|
| 6523 | <td><em>%s</em></td>\n\ |
|---|
| 6524 | <td >\n", i, i, name, i, type, name ); |
|---|
| 6525 | websWrite( wp, "<select name=\"svqos_svcprio%d\"> \n\ |
|---|
| 6526 | <script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"100\\\" %s >\" + qos.prio_x + \"</option>\");\n\ |
|---|
| 6527 | document.write(\"<option value=\\\"10\\\" %s >\" + qos.prio_p + \"</option>\");\n\ |
|---|
| 6528 | document.write(\"<option value=\\\"20\\\" %s >\" + qos.prio_e + \"</option>\");\n\ |
|---|
| 6529 | document.write(\"<option value=\\\"30\\\" %s >\" + share.standard + \"</option>\");\n\ |
|---|
| 6530 | document.write(\"<option value=\\\"40\\\" %s >\" + qos.prio_b + \"</option>\");\n//]]>\n</script>\n\ |
|---|
| 6531 | </select>\n\ |
|---|
| 6532 | </td>\n\ |
|---|
| 6533 | </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\\\"" : "" ); |
|---|
| 6534 | |
|---|
| 6535 | qos_svcs = strpbrk( ++qos_svcs, "|" ); |
|---|
| 6536 | qos_svcs++; |
|---|
| 6537 | |
|---|
| 6538 | } |
|---|
| 6539 | |
|---|
| 6540 | return; |
|---|
| 6541 | } |
|---|
| 6542 | |
|---|
| 6543 | #ifndef HAVE_AQOS |
|---|
| 6544 | void ej_get_qosips( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6545 | { |
|---|
| 6546 | char *qos_ips = nvram_safe_get( "svqos_ips" ); |
|---|
| 6547 | char ip[32], level[32]; |
|---|
| 6548 | int no_ips = 0, i = 0; |
|---|
| 6549 | |
|---|
| 6550 | // calc # of ips |
|---|
| 6551 | while( ( qos_ips = strpbrk( qos_ips, "|" ) ) ) |
|---|
| 6552 | { |
|---|
| 6553 | no_ips++; |
|---|
| 6554 | qos_ips++; |
|---|
| 6555 | } |
|---|
| 6556 | websWrite( wp, "<tr>\n\ |
|---|
| 6557 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 6558 | <th><script type=\"text/javascript\">Capture(qos.ipmask)</script></th>\n\ |
|---|
| 6559 | <th><script type=\"text/javascript\">Capture(share.priority)</script></th>\n\ |
|---|
| 6560 | </tr>\n" ); |
|---|
| 6561 | |
|---|
| 6562 | // write HTML data |
|---|
| 6563 | |
|---|
| 6564 | websWrite( wp, |
|---|
| 6565 | "<tr><td colspan=\"3\"><input type=\"hidden\" name=\"svqos_noips\" value=\"%d\" /></td></tr>", |
|---|
| 6566 | no_ips ); |
|---|
| 6567 | |
|---|
| 6568 | qos_ips = nvram_safe_get( "svqos_ips" ); |
|---|
| 6569 | |
|---|
| 6570 | /* |
|---|
| 6571 | * IP format is "data level | data level |" ..etc |
|---|
| 6572 | */ |
|---|
| 6573 | for( i = 0; i < no_ips && qos_ips && qos_ips[0]; i++ ) |
|---|
| 6574 | { |
|---|
| 6575 | if( sscanf( qos_ips, "%31s %31s ", ip, level ) < 2 ) |
|---|
| 6576 | break; |
|---|
| 6577 | |
|---|
| 6578 | websWrite( wp, "<tr>\n\ |
|---|
| 6579 | <td>\n\ |
|---|
| 6580 | <input type=\"checkbox\" name=\"svqos_ipdel%d\" />\n\ |
|---|
| 6581 | <input type=\"hidden\" name=\"svqos_ip%d\" value=\"%s\" />\n\ |
|---|
| 6582 | </td>\n\ |
|---|
| 6583 | <td><em>%s</em></td>\n\ |
|---|
| 6584 | <td>\n", i, i, ip, ip ); |
|---|
| 6585 | websWrite( wp, "<select name=\"svqos_ipprio%d\"> \n\ |
|---|
| 6586 | <script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"100\\\" %s >\" + qos.prio_x + \"</option>\");\n\ |
|---|
| 6587 | document.write(\"<option value=\\\"10\\\" %s >\" + qos.prio_p + \"</option>\");\n\ |
|---|
| 6588 | document.write(\"<option value=\\\"20\\\" %s >\" + qos.prio_e + \"</option>\");\n\ |
|---|
| 6589 | document.write(\"<option value=\\\"30\\\" %s >\" + share.standard + \"</option>\");\n\ |
|---|
| 6590 | document.write(\"<option value=\\\"40\\\" %s >\" + qos.prio_b + \"</option>\");\n//]]>\n</script>\n\ |
|---|
| 6591 | </select>\n\ |
|---|
| 6592 | </td>\n\ |
|---|
| 6593 | </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\\\"" : "" ); |
|---|
| 6594 | |
|---|
| 6595 | qos_ips = strpbrk( ++qos_ips, "|" ); |
|---|
| 6596 | qos_ips++; |
|---|
| 6597 | |
|---|
| 6598 | } |
|---|
| 6599 | |
|---|
| 6600 | return; |
|---|
| 6601 | } |
|---|
| 6602 | #else |
|---|
| 6603 | void ej_get_qosips( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6604 | { |
|---|
| 6605 | char *qos_ips = nvram_safe_get( "svqos_ips" ); |
|---|
| 6606 | char ip[32], level[32], level2[32]; |
|---|
| 6607 | int no_ips = 0, i = 0; |
|---|
| 6608 | |
|---|
| 6609 | // calc # of ips |
|---|
| 6610 | while( ( qos_ips = strpbrk( qos_ips, "|" ) ) ) |
|---|
| 6611 | { |
|---|
| 6612 | no_ips++; |
|---|
| 6613 | qos_ips++; |
|---|
| 6614 | } |
|---|
| 6615 | websWrite( wp, "<tr>\n\ |
|---|
| 6616 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 6617 | <th><script type=\"text/javascript\">Capture(qos.ipmask)</script></th>\n\ |
|---|
| 6618 | <th><script type=\"text/javascript\">Capture(qos.maxuprate_b)</script></th>\n\ |
|---|
| 6619 | <th><script type=\"text/javascript\">Capture(qos.maxdownrate_b)</script></th>\n\ |
|---|
| 6620 | </tr>\n" ); |
|---|
| 6621 | |
|---|
| 6622 | // write HTML data |
|---|
| 6623 | |
|---|
| 6624 | websWrite( wp, |
|---|
| 6625 | "<tr><td colspan=\"3\"><input type=\"hidden\" name=\"svqos_noips\" value=\"%d\" /></td></tr>", |
|---|
| 6626 | no_ips ); |
|---|
| 6627 | |
|---|
| 6628 | qos_ips = nvram_safe_get( "svqos_ips" ); |
|---|
| 6629 | |
|---|
| 6630 | /* |
|---|
| 6631 | * IP format is "data level | data level |" ..etc |
|---|
| 6632 | */ |
|---|
| 6633 | for( i = 0; i < no_ips && qos_ips && qos_ips[0]; i++ ) |
|---|
| 6634 | { |
|---|
| 6635 | if( sscanf( qos_ips, "%31s %31s %31s ", ip, level, level2 ) < 3 ) |
|---|
| 6636 | break; |
|---|
| 6637 | websWrite( wp, "<tr>\n\ |
|---|
| 6638 | <td>\n\ |
|---|
| 6639 | <input type=\"checkbox\" name=\"svqos_ipdel%d\" />\n\ |
|---|
| 6640 | <input type=\"hidden\" name=\"svqos_ip%d\" value=\"%s\" />\n\ |
|---|
| 6641 | </td>\n\ |
|---|
| 6642 | <td><em>%s</em></td>\n\ |
|---|
| 6643 | <td>\n\ |
|---|
| 6644 | <input name=\"svqos_ipup%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 6645 | </td>\n\ |
|---|
| 6646 | <td>\n\ |
|---|
| 6647 | <input name=\"svqos_ipdown%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 6648 | </td>\n\ |
|---|
| 6649 | </tr>\n", i, i, ip, ip, i, level, i, level2 ); |
|---|
| 6650 | |
|---|
| 6651 | qos_ips = strpbrk( ++qos_ips, "|" ); |
|---|
| 6652 | qos_ips++; |
|---|
| 6653 | |
|---|
| 6654 | } |
|---|
| 6655 | |
|---|
| 6656 | return; |
|---|
| 6657 | } |
|---|
| 6658 | #endif |
|---|
| 6659 | #ifndef HAVE_AQOS |
|---|
| 6660 | void ej_get_qosmacs( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6661 | { |
|---|
| 6662 | char *qos_macs = nvram_safe_get( "svqos_macs" ); |
|---|
| 6663 | char mac[32], level[32]; |
|---|
| 6664 | int no_macs = 0, i = 0; |
|---|
| 6665 | |
|---|
| 6666 | // calc # of ips |
|---|
| 6667 | while( ( qos_macs = strpbrk( qos_macs, "|" ) ) ) |
|---|
| 6668 | { |
|---|
| 6669 | no_macs++; |
|---|
| 6670 | qos_macs++; |
|---|
| 6671 | } |
|---|
| 6672 | |
|---|
| 6673 | websWrite( wp, "<tr>\n\ |
|---|
| 6674 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 6675 | <th><script type=\"text/javascript\">Capture(share.mac)</script></th>\n\ |
|---|
| 6676 | <th><script type=\"text/javascript\">Capture(share.priority)</script></th>\n\ |
|---|
| 6677 | </tr>\n" ); |
|---|
| 6678 | |
|---|
| 6679 | // write HTML data |
|---|
| 6680 | websWrite( wp, |
|---|
| 6681 | "<input type=\"hidden\" name=\"svqos_nomacs\" value=\"%d\" />", |
|---|
| 6682 | no_macs ); |
|---|
| 6683 | |
|---|
| 6684 | qos_macs = nvram_safe_get( "svqos_macs" ); |
|---|
| 6685 | |
|---|
| 6686 | /* |
|---|
| 6687 | * IP format is "data level | data level |" ..etc |
|---|
| 6688 | */ |
|---|
| 6689 | for( i = 0; i < no_macs && qos_macs && qos_macs[0]; i++ ) |
|---|
| 6690 | { |
|---|
| 6691 | if( sscanf( qos_macs, "%31s %31s ", mac, level ) < 2 ) |
|---|
| 6692 | break; |
|---|
| 6693 | |
|---|
| 6694 | websWrite( wp, "<tr>\n\ |
|---|
| 6695 | <td>\n\ |
|---|
| 6696 | <input type=\"checkbox\" name=\"svqos_macdel%d\" />\n\ |
|---|
| 6697 | <input type=\"hidden\" name=\"svqos_mac%d\" value=\"%s\" />\n\ |
|---|
| 6698 | </td>\n\ |
|---|
| 6699 | <td><em>%s</em></td>\n\ |
|---|
| 6700 | <td>\n", i, i, mac, mac ); |
|---|
| 6701 | websWrite( wp, "<select name=\"svqos_macprio%d\"> \n\ |
|---|
| 6702 | <script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"100\\\" %s >\" + qos.prio_x + \"</option>\");\n\ |
|---|
| 6703 | document.write(\"<option value=\\\"10\\\" %s >\" + qos.prio_p + \"</option>\");\n\ |
|---|
| 6704 | document.write(\"<option value=\\\"20\\\" %s >\" + qos.prio_e + \"</option>\");\n\ |
|---|
| 6705 | document.write(\"<option value=\\\"30\\\" %s >\" + share.standard + \"</option>\");\n\ |
|---|
| 6706 | document.write(\"<option value=\\\"40\\\" %s >\" + qos.prio_b + \"</option>\");\n//]]>\n</script>\n\ |
|---|
| 6707 | </select>\n\ |
|---|
| 6708 | </td>\n\ |
|---|
| 6709 | </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\\\"" : "" ); |
|---|
| 6710 | |
|---|
| 6711 | qos_macs = strpbrk( ++qos_macs, "|" ); |
|---|
| 6712 | qos_macs++; |
|---|
| 6713 | |
|---|
| 6714 | } |
|---|
| 6715 | |
|---|
| 6716 | return; |
|---|
| 6717 | } |
|---|
| 6718 | |
|---|
| 6719 | #else |
|---|
| 6720 | void ej_get_qosmacs( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6721 | { |
|---|
| 6722 | char *qos_macs = nvram_safe_get( "svqos_macs" ); |
|---|
| 6723 | char mac[32], level[32], level2[32]; |
|---|
| 6724 | int no_macs = 0, i = 0; |
|---|
| 6725 | |
|---|
| 6726 | // calc # of ips |
|---|
| 6727 | while( ( qos_macs = strpbrk( qos_macs, "|" ) ) ) |
|---|
| 6728 | { |
|---|
| 6729 | no_macs++; |
|---|
| 6730 | qos_macs++; |
|---|
| 6731 | } |
|---|
| 6732 | websWrite( wp, "<tr>\n\ |
|---|
| 6733 | <th><script type=\"text/javascript\">Capture(share.del)</script></th>\n\ |
|---|
| 6734 | <th><script type=\"text/javascript\">Capture(share.mac)</script></th>\n\ |
|---|
| 6735 | <th><script type=\"text/javascript\">Capture(qos.maxuprate_b)</script></th>\n\ |
|---|
| 6736 | <th><script type=\"text/javascript\">Capture(qos.maxdownrate_b)</script></th>\n\ |
|---|
| 6737 | </tr>\n" ); |
|---|
| 6738 | |
|---|
| 6739 | // write HTML data |
|---|
| 6740 | websWrite( wp, |
|---|
| 6741 | "<input type=\"hidden\" name=\"svqos_nomacs\" value=\"%d\" />", |
|---|
| 6742 | no_macs ); |
|---|
| 6743 | |
|---|
| 6744 | qos_macs = nvram_safe_get( "svqos_macs" ); |
|---|
| 6745 | |
|---|
| 6746 | /* |
|---|
| 6747 | * IP format is "data level | data level |" ..etc |
|---|
| 6748 | */ |
|---|
| 6749 | for( i = 0; i < no_macs && qos_macs && qos_macs[0]; i++ ) |
|---|
| 6750 | { |
|---|
| 6751 | if( sscanf( qos_macs, "%31s %31s %31s ", mac, level, level2 ) < 3 ) |
|---|
| 6752 | break; |
|---|
| 6753 | websWrite( wp, "<tr>\n\ |
|---|
| 6754 | <td>\n\ |
|---|
| 6755 | <input type=\"checkbox\" name=\"svqos_macdel%d\" />\n\ |
|---|
| 6756 | <input type=\"hidden\" name=\"svqos_mac%d\" value=\"%s\" />\n\ |
|---|
| 6757 | </td>\n\ |
|---|
| 6758 | <td><em>%s</em></td>\n\ |
|---|
| 6759 | <td>\n\ |
|---|
| 6760 | <input name=\"svqos_macup%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 6761 | </td>\n\ |
|---|
| 6762 | <td>\n\ |
|---|
| 6763 | <input name=\"svqos_macdown%d\" class=\"num\" size=\"5\" maxlength=\"5\" value=\"%s\" /> \n\ |
|---|
| 6764 | </td>\n\ |
|---|
| 6765 | </tr>\n", i, i, mac, mac, i, level, i, level2 ); |
|---|
| 6766 | |
|---|
| 6767 | qos_macs = strpbrk( ++qos_macs, "|" ); |
|---|
| 6768 | qos_macs++; |
|---|
| 6769 | |
|---|
| 6770 | } |
|---|
| 6771 | |
|---|
| 6772 | return; |
|---|
| 6773 | } |
|---|
| 6774 | #endif |
|---|
| 6775 | |
|---|
| 6776 | /* |
|---|
| 6777 | * Added by Botho 03.April.06 |
|---|
| 6778 | */ |
|---|
| 6779 | void ej_dumpip_conntrack( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6780 | { |
|---|
| 6781 | int ip_count = 0; |
|---|
| 6782 | FILE *fp; |
|---|
| 6783 | int c; |
|---|
| 6784 | |
|---|
| 6785 | fp = fopen( "/proc/net/ip_conntrack", "rb" ); |
|---|
| 6786 | if( fp == NULL ) |
|---|
| 6787 | return; |
|---|
| 6788 | while( !feof( fp ) ) |
|---|
| 6789 | { |
|---|
| 6790 | c = getc( fp ); |
|---|
| 6791 | if( c == EOF ) |
|---|
| 6792 | break; |
|---|
| 6793 | if( c == 0xa ) |
|---|
| 6794 | ip_count++; |
|---|
| 6795 | } |
|---|
| 6796 | |
|---|
| 6797 | websWrite( wp, "%d", ip_count ); |
|---|
| 6798 | |
|---|
| 6799 | fclose( fp ); |
|---|
| 6800 | |
|---|
| 6801 | return; |
|---|
| 6802 | } |
|---|
| 6803 | |
|---|
| 6804 | /* |
|---|
| 6805 | * Added by Botho 28.Oct.06 |
|---|
| 6806 | */ |
|---|
| 6807 | static int search_hit( char *search, char *line, char *ret ) |
|---|
| 6808 | { |
|---|
| 6809 | unsigned int searchLen; |
|---|
| 6810 | unsigned int i; |
|---|
| 6811 | unsigned int j; |
|---|
| 6812 | unsigned int lineLen; |
|---|
| 6813 | |
|---|
| 6814 | if( line == NULL || search == NULL || ret == NULL ) |
|---|
| 6815 | return 1; |
|---|
| 6816 | lineLen = strlen( line ); |
|---|
| 6817 | searchLen = strlen( search ); |
|---|
| 6818 | |
|---|
| 6819 | if( searchLen > lineLen ) |
|---|
| 6820 | return ( 1 ); // this can't match, invalid data? |
|---|
| 6821 | |
|---|
| 6822 | for( i = 0; i < lineLen - searchLen; i++ ) |
|---|
| 6823 | { |
|---|
| 6824 | if( !strncasecmp( ( char * )&line[i], search, searchLen ) ) |
|---|
| 6825 | break; // we got hit |
|---|
| 6826 | } |
|---|
| 6827 | |
|---|
| 6828 | for( j = i + searchLen; j < i + 15 + searchLen; j++ ) |
|---|
| 6829 | { |
|---|
| 6830 | if( j >= lineLen ) |
|---|
| 6831 | break; // end of line may be a delimiter too |
|---|
| 6832 | // return(1); // incomplete data |
|---|
| 6833 | if( line[j] == ' ' ) |
|---|
| 6834 | break; // we reach _space_ delimiter |
|---|
| 6835 | } |
|---|
| 6836 | memcpy( ret, &line[i + searchLen], j - ( i + searchLen ) ); |
|---|
| 6837 | ret[j - ( i + searchLen )] = 0; |
|---|
| 6838 | return ( 0 ); |
|---|
| 6839 | } |
|---|
| 6840 | |
|---|
| 6841 | static int string_search( char *string, char *search ) |
|---|
| 6842 | { |
|---|
| 6843 | int searchLen; |
|---|
| 6844 | int i; |
|---|
| 6845 | |
|---|
| 6846 | if( search == NULL ) |
|---|
| 6847 | return 0; |
|---|
| 6848 | searchLen = strlen( search ); |
|---|
| 6849 | if( string == NULL ) |
|---|
| 6850 | return 0; |
|---|
| 6851 | if( searchLen > strlen( string ) ) |
|---|
| 6852 | { |
|---|
| 6853 | return ( 0 ); // this can't match |
|---|
| 6854 | } |
|---|
| 6855 | int slen = strlen( string ); |
|---|
| 6856 | |
|---|
| 6857 | for( i = 0; i < slen - searchLen; i++ ) |
|---|
| 6858 | { // +1 removed. |
|---|
| 6859 | if( !strncasecmp( ( char * )&string[i], search, searchLen ) ) |
|---|
| 6860 | { |
|---|
| 6861 | return ( 1 ); // we got hit |
|---|
| 6862 | } |
|---|
| 6863 | } |
|---|
| 6864 | return ( 0 ); |
|---|
| 6865 | } |
|---|
| 6866 | |
|---|
| 6867 | void ej_ip_conntrack_table( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6868 | { |
|---|
| 6869 | FILE *fp; |
|---|
| 6870 | int ip_count = 1; |
|---|
| 6871 | char line[512]; |
|---|
| 6872 | char protocol[16] = ""; |
|---|
| 6873 | int timeout = 0; |
|---|
| 6874 | char srcip[16] = ""; |
|---|
| 6875 | char dstip[16] = ""; |
|---|
| 6876 | int _dport; |
|---|
| 6877 | struct servent *servp; |
|---|
| 6878 | char dstport[6] = ""; |
|---|
| 6879 | char state[12] = ""; |
|---|
| 6880 | char dum1[32]; |
|---|
| 6881 | int dum2; |
|---|
| 6882 | |
|---|
| 6883 | fp = fopen( "/proc/net/ip_conntrack", "rb" ); |
|---|
| 6884 | if( fp == NULL ) |
|---|
| 6885 | return; |
|---|
| 6886 | |
|---|
| 6887 | while( fgets( line, sizeof( line ), fp ) != NULL ) |
|---|
| 6888 | { |
|---|
| 6889 | |
|---|
| 6890 | websWrite( wp, "<tr>\n" ); |
|---|
| 6891 | |
|---|
| 6892 | // Nb |
|---|
| 6893 | websWrite( wp, "<td align=\"right\">%d</td>", ip_count ); |
|---|
| 6894 | |
|---|
| 6895 | // Proto |
|---|
| 6896 | if( string_search( line, "tcp" ) ) |
|---|
| 6897 | sprintf( protocol, "TCP" ); |
|---|
| 6898 | else if( string_search( line, "udp" ) ) |
|---|
| 6899 | sprintf( protocol, "UDP" ); |
|---|
| 6900 | else if( string_search( line, "icmp" ) ) |
|---|
| 6901 | sprintf( protocol, "ICMP" ); |
|---|
| 6902 | else |
|---|
| 6903 | sprintf( protocol, live_translate( "share.unknown" ) ); |
|---|
| 6904 | websWrite( wp, "<td>%s</td>", protocol ); |
|---|
| 6905 | |
|---|
| 6906 | // Timeout |
|---|
| 6907 | sscanf( line, "%s %d %d", &dum1[0], &dum2, &timeout ); |
|---|
| 6908 | websWrite( wp, "<td align=\"right\">%d</td>", timeout ); |
|---|
| 6909 | |
|---|
| 6910 | // src |
|---|
| 6911 | search_hit( "src=", line, srcip ); |
|---|
| 6912 | // char buf[200]; |
|---|
| 6913 | // getHostName (buf, srcip); |
|---|
| 6914 | // websWrite (wp, "<td align=\"right\" onmouseover='DisplayDiv(this, |
|---|
| 6915 | // event, 15, 15, \"%s\")' onmouseout=\"unDisplayDiv()\">%s</td>", |
|---|
| 6916 | // buf != "unknown" ? buf : live_translate ("share.unknown") , |
|---|
| 6917 | // srcip); |
|---|
| 6918 | websWrite( wp, "<td align=\"right\">%s</td>", srcip ); |
|---|
| 6919 | |
|---|
| 6920 | // dst |
|---|
| 6921 | search_hit( "dst=", line, dstip ); |
|---|
| 6922 | // getHostName (buf, dstip); |
|---|
| 6923 | // websWrite (wp, "<td align=\"right\" onmouseover='DisplayDiv(this, |
|---|
| 6924 | // event, 15, 15, \"%s\")' onmouseout=\"unDisplayDiv()\">%s</td>", |
|---|
| 6925 | // buf != "unknown" ? buf : live_translate ("share.unknown") , |
|---|
| 6926 | // dstip); |
|---|
| 6927 | websWrite( wp, "<td align=\"right\">%s</td>", dstip ); |
|---|
| 6928 | |
|---|
| 6929 | // service |
|---|
| 6930 | search_hit( "dport=", line, dstport ); |
|---|
| 6931 | _dport = atoi( dstport ); |
|---|
| 6932 | servp = my_getservbyport( htons( _dport ), protocol ); |
|---|
| 6933 | websWrite( wp, "<td align=\"right\">%s</td>", |
|---|
| 6934 | servp ? servp->s_name : dstport ); |
|---|
| 6935 | |
|---|
| 6936 | // State |
|---|
| 6937 | if( string_search( line, "ESTABLISHED" ) ) |
|---|
| 6938 | sprintf( state, "ESTABLISHED" ); |
|---|
| 6939 | else if( string_search( line, "TIME_WAIT" ) ) |
|---|
| 6940 | sprintf( state, "TIME_WAIT" ); |
|---|
| 6941 | else if( string_search( line, "UNREPLIED" ) ) |
|---|
| 6942 | sprintf( state, "UNREPLIED" ); |
|---|
| 6943 | else if( string_search( line, "CLOSE" ) ) |
|---|
| 6944 | sprintf( state, "CLOSE" ); |
|---|
| 6945 | else if( string_search( line, "ASSURED" ) ) |
|---|
| 6946 | sprintf( state, "ASSURED" ); |
|---|
| 6947 | else |
|---|
| 6948 | { |
|---|
| 6949 | if( string_search( line, "udp" ) ) |
|---|
| 6950 | sprintf( state, "UNREPLIED" ); |
|---|
| 6951 | else |
|---|
| 6952 | sprintf( state, " " ); |
|---|
| 6953 | } |
|---|
| 6954 | websWrite( wp, "<td>%s</td>\n", state ); |
|---|
| 6955 | websWrite( wp, "</tr>\n" ); |
|---|
| 6956 | |
|---|
| 6957 | ip_count++; |
|---|
| 6958 | } |
|---|
| 6959 | |
|---|
| 6960 | fclose( fp ); |
|---|
| 6961 | |
|---|
| 6962 | return; |
|---|
| 6963 | } |
|---|
| 6964 | |
|---|
| 6965 | void ej_gethostnamebyip( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6966 | { |
|---|
| 6967 | char buf[200]; |
|---|
| 6968 | char *argument; |
|---|
| 6969 | |
|---|
| 6970 | #ifdef FASTWEB |
|---|
| 6971 | ejArgs( argc, argv, "%s", &argument ); |
|---|
| 6972 | #else |
|---|
| 6973 | if( ejArgs( argc, argv, "%s", &argument ) < 1 ) |
|---|
| 6974 | { |
|---|
| 6975 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 6976 | return; |
|---|
| 6977 | } |
|---|
| 6978 | #endif |
|---|
| 6979 | |
|---|
| 6980 | if( argc == 1 ) |
|---|
| 6981 | { |
|---|
| 6982 | getHostName( buf, argument ); |
|---|
| 6983 | websWrite( wp, "%s", |
|---|
| 6984 | buf != |
|---|
| 6985 | "unknown" ? buf : live_translate( "share.unknown" ) ); |
|---|
| 6986 | } |
|---|
| 6987 | |
|---|
| 6988 | return; |
|---|
| 6989 | } |
|---|
| 6990 | |
|---|
| 6991 | /* |
|---|
| 6992 | * BEGIN Added by Botho 10.May.06 |
|---|
| 6993 | */ |
|---|
| 6994 | void ej_show_wan_to_switch( webs_t wp, int argc, char_t ** argv ) |
|---|
| 6995 | { |
|---|
| 6996 | |
|---|
| 6997 | if( nvram_match( "wan_proto", "disabled" ) || !nvram_match( "wl_mode", "ap" ) ) // WAN |
|---|
| 6998 | // disabled |
|---|
| 6999 | // OR |
|---|
| 7000 | // Wirelles |
|---|
| 7001 | // is |
|---|
| 7002 | // not |
|---|
| 7003 | // AP |
|---|
| 7004 | { |
|---|
| 7005 | websWrite( wp, "<fieldset>\n\ |
|---|
| 7006 | <legend><script type=\"text/javascript\">Capture(idx.legend2)</script></legend>\n\ |
|---|
| 7007 | <div class=\"setting\">\n\ |
|---|
| 7008 | <div class=\"label\"><script type=\"text/javascript\">Capture(idx.wantoswitch)</script></div>\n\ |
|---|
| 7009 | <input class=\"spaceradio\" type=\"checkbox\" name=\"_fullswitch\" value=\"1\" %s />\n\ |
|---|
| 7010 | </div>\n\ |
|---|
| 7011 | </fieldset><br />\n", nvram_match( "fullswitch", "1" ) ? "checked=\"checked\"" : "" ); |
|---|
| 7012 | } |
|---|
| 7013 | |
|---|
| 7014 | return; |
|---|
| 7015 | } |
|---|
| 7016 | |
|---|
| 7017 | #define PROC_DEV "/proc/net/dev" |
|---|
| 7018 | |
|---|
| 7019 | void ej_wl_packet_get( webs_t wp, int argc, char_t ** argv ) |
|---|
| 7020 | { |
|---|
| 7021 | char line[256]; |
|---|
| 7022 | FILE *fp; |
|---|
| 7023 | |
|---|
| 7024 | #ifdef HAVE_MADWIFI |
|---|
| 7025 | char *ifname = nvram_safe_get( "wifi_display" ); |
|---|
| 7026 | #elif HAVE_RT2880 |
|---|
| 7027 | char *ifname = "ra0"; |
|---|
| 7028 | #else |
|---|
| 7029 | char *ifname = nvram_safe_get( "wl0_ifname" ); |
|---|
| 7030 | #endif |
|---|
| 7031 | struct dev_info |
|---|
| 7032 | { |
|---|
| 7033 | // unsigned long rx_bytes; |
|---|
| 7034 | unsigned long rx_pks; |
|---|
| 7035 | unsigned long rx_errs; |
|---|
| 7036 | unsigned long rx_drops; |
|---|
| 7037 | // unsigned long rx_fifo; |
|---|
| 7038 | // unsigned long rx_frame; |
|---|
| 7039 | // unsigned long rx_com; |
|---|
| 7040 | // unsigned long rx_mcast; |
|---|
| 7041 | // unsigned long tx_bytes; |
|---|
| 7042 | unsigned long tx_pks; |
|---|
| 7043 | unsigned long tx_errs; |
|---|
| 7044 | unsigned long tx_drops; |
|---|
| 7045 | // unsigned long tx_fifo; |
|---|
| 7046 | unsigned long tx_colls; |
|---|
| 7047 | // unsigned long tx_carr; |
|---|
| 7048 | // unsigned long tx_com; |
|---|
| 7049 | } info; |
|---|
| 7050 | |
|---|
| 7051 | info.rx_pks = info.rx_errs = info.rx_drops = 0; |
|---|
| 7052 | info.tx_pks = info.tx_errs = info.tx_drops = info.tx_colls = 0; |
|---|
| 7053 | |
|---|
| 7054 | if( ( fp = fopen( PROC_DEV, "r" ) ) == NULL ) |
|---|
| 7055 | { |
|---|
| 7056 | websError( wp, 400, "Can't open %s\n", PROC_DEV ); |
|---|
| 7057 | return; |
|---|
| 7058 | } |
|---|
| 7059 | else |
|---|
| 7060 | { |
|---|
| 7061 | /* |
|---|
| 7062 | * Inter-| Receive | Transmit face |bytes packets errs drop fifo |
|---|
| 7063 | * frame compressed multicast|bytes packets errs drop fifo colls |
|---|
| 7064 | * carrier compressed lo: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 eth0: |
|---|
| 7065 | * 674829 5501 0 0 0 0 0 0 1249130 1831 0 0 0 0 0 0 eth1: 0 0 0 0 0 0 |
|---|
| 7066 | * 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 |
|---|
| 7067 | * br0: 107114 1078 0 0 0 0 0 0 910094 1304 0 0 0 0 0 0 |
|---|
| 7068 | * |
|---|
| 7069 | */ |
|---|
| 7070 | while( fgets( line, sizeof( line ), fp ) != NULL ) |
|---|
| 7071 | { |
|---|
| 7072 | int ifl = 0; |
|---|
| 7073 | |
|---|
| 7074 | if( !strchr( line, ':' ) ) |
|---|
| 7075 | continue; |
|---|
| 7076 | while( line[ifl] != ':' ) |
|---|
| 7077 | ifl++; |
|---|
| 7078 | line[ifl] = 0; /* interface */ |
|---|
| 7079 | |
|---|
| 7080 | if( strstr( line, ifname ) ) |
|---|
| 7081 | { |
|---|
| 7082 | /* |
|---|
| 7083 | * sscanf (line + ifl + 1, "%ld %ld %ld %ld %ld %ld %ld %ld |
|---|
| 7084 | * %ld %ld %ld %ld %ld %ld %ld %ld", &info.rx_bytes, |
|---|
| 7085 | * &info.rx_pks, &info.rx_errs, &info.rx_drops, |
|---|
| 7086 | * &info.rx_fifo, &info.rx_frame, &info.rx_com, |
|---|
| 7087 | * &info.rx_mcast, &info.tx_bytes, &info.tx_pks, |
|---|
| 7088 | * &info.tx_errs, &info.tx_drops, &info.tx_fifo, |
|---|
| 7089 | * &info.tx_colls, &info.tx_carr, &info.tx_com); |
|---|
| 7090 | */ |
|---|
| 7091 | sscanf( line + ifl + 1, |
|---|
| 7092 | "%*ld %ld %ld %ld %*ld %*ld %*ld %*ld %*ld %ld %ld %ld %*ld %ld %*ld %*ld", |
|---|
| 7093 | &info.rx_pks, &info.rx_errs, |
|---|
| 7094 | &info.rx_drops, |
|---|
| 7095 | &info.tx_pks, &info.tx_errs, &info.tx_drops, |
|---|
| 7096 | &info.tx_colls ); |
|---|
| 7097 | } |
|---|
| 7098 | |
|---|
| 7099 | } |
|---|
| 7100 | fclose( fp ); |
|---|
| 7101 | } |
|---|
| 7102 | |
|---|
| 7103 | websWrite( wp, "SWRXgoodPacket=%ld;", info.rx_pks ); |
|---|
| 7104 | websWrite( wp, "SWRXerrorPacket=%ld;", info.rx_errs + info.rx_drops ); |
|---|
| 7105 | |
|---|
| 7106 | websWrite( wp, "SWTXgoodPacket=%ld;", info.tx_pks ); |
|---|
| 7107 | websWrite( wp, "SWTXerrorPacket=%ld;", |
|---|
| 7108 | info.tx_errs + info.tx_drops + info.tx_colls ); |
|---|
| 7109 | |
|---|
| 7110 | return; |
|---|
| 7111 | } |
|---|
| 7112 | |
|---|
| 7113 | /* |
|---|
| 7114 | * END Added by Botho 10.May.06 |
|---|
| 7115 | */ |
|---|
| 7116 | |
|---|
| 7117 | void ej_statfs( webs_t wp, int argc, char_t ** argv ) |
|---|
| 7118 | { |
|---|
| 7119 | struct statfs sizefs; |
|---|
| 7120 | |
|---|
| 7121 | if( argc != 2 ) |
|---|
| 7122 | return; |
|---|
| 7123 | |
|---|
| 7124 | if( ( statfs( argv[0], &sizefs ) != 0 ) |
|---|
| 7125 | || ( sizefs.f_type == 0x73717368 ) ) |
|---|
| 7126 | memset( &sizefs, 0, sizeof( sizefs ) ); |
|---|
| 7127 | |
|---|
| 7128 | websWrite( wp, "var %s = {\n\ |
|---|
| 7129 | size: %llu,\n\ |
|---|
| 7130 | free: %llu\n\ |
|---|
| 7131 | };\n", argv[1], ( ( uint64_t ) sizefs.f_bsize * sizefs.f_blocks ), ( ( uint64_t ) sizefs.f_bsize * sizefs.f_bfree ) ); |
|---|
| 7132 | } |
|---|
| 7133 | |
|---|
| 7134 | #ifdef HAVE_RSTATS |
|---|
| 7135 | /* |
|---|
| 7136 | * |
|---|
| 7137 | * rstats Copyright (C) 2006 Jonathan Zarate |
|---|
| 7138 | * |
|---|
| 7139 | * Licensed under GNU GPL v2 or later. |
|---|
| 7140 | * |
|---|
| 7141 | */ |
|---|
| 7142 | |
|---|
| 7143 | void ej_bandwidth( webs_t wp, int argc, char_t ** argv ) |
|---|
| 7144 | { |
|---|
| 7145 | char *name; |
|---|
| 7146 | int sig; |
|---|
| 7147 | char *argument; |
|---|
| 7148 | |
|---|
| 7149 | #ifdef FASTWEB |
|---|
| 7150 | ejArgs( argc, argv, "%s", &argument ); |
|---|
| 7151 | #else |
|---|
| 7152 | if( ejArgs( argc, argv, "%s", &argument ) < 1 ) |
|---|
| 7153 | { |
|---|
| 7154 | websError( wp, 400, "Insufficient args\n" ); |
|---|
| 7155 | return; |
|---|
| 7156 | } |
|---|
| 7157 | #endif |
|---|
| 7158 | |
|---|
| 7159 | if( argc == 1 ) |
|---|
| 7160 | { |
|---|
| 7161 | if( strcmp( argument, "speed" ) == 0 ) |
|---|
| 7162 | { |
|---|
| 7163 | sig = SIGUSR1; |
|---|
| 7164 | name = "/var/spool/rstats-speed.js"; |
|---|
| 7165 | } |
|---|
| 7166 | else |
|---|
| 7167 | { |
|---|
| 7168 | sig = SIGUSR2; |
|---|
| 7169 | name = "/var/spool/rstats-history.js"; |
|---|
| 7170 | } |
|---|
| 7171 | unlink( name ); |
|---|
| 7172 | killall( "rstats", sig ); |
|---|
| 7173 | wait_file_exists( name, 5, 0 ); |
|---|
| 7174 | do_file( name, wp, NULL ); |
|---|
| 7175 | unlink( name ); |
|---|
| 7176 | } |
|---|
| 7177 | } |
|---|
| 7178 | #endif |
|---|
| 7179 | |
|---|
| 7180 | #ifdef HAVE_PORTSETUP |
|---|
| 7181 | void ej_portsetup( webs_t wp, int argc, char_t ** argv ) |
|---|
| 7182 | { |
|---|
| 7183 | char ssid[64]; |
|---|
| 7184 | char *next; |
|---|
| 7185 | char var[64]; |
|---|
| 7186 | char eths[256]; |
|---|
| 7187 | |
|---|
| 7188 | websWrite( wp, |
|---|
| 7189 | "<h2><script type=\"text/javascript\">Capture(idx.portsetup)</script></h2>\n" ); |
|---|
| 7190 | websWrite( wp, "<fieldset>\n" ); |
|---|
| 7191 | |
|---|
| 7192 | char *wanifname = nvram_safe_get( "wan_ifname2" ); |
|---|
| 7193 | |
|---|
| 7194 | if( strlen( wanifname ) == 0 ) |
|---|
| 7195 | wanifname = nvram_safe_get( "wan_ifname" ); |
|---|
| 7196 | if( strlen( wanifname ) > 0 ) |
|---|
| 7197 | { |
|---|
| 7198 | |
|---|
| 7199 | websWrite( wp, |
|---|
| 7200 | "<legend><script type=\"text/javascript\">Capture(idx.portsetup)</script></legend>\n" ); |
|---|
| 7201 | memset( eths, 0, 256 ); |
|---|
| 7202 | getIfLists( eths, 256 ); |
|---|
| 7203 | websWrite( wp, |
|---|
| 7204 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(idx.wanport)</script></div>\n" ); |
|---|
| 7205 | websWrite( wp, "<select name=\"wan_ifname\">\n" ); |
|---|
| 7206 | |
|---|
| 7207 | websWrite( wp, "<option value=\"\" %s >Disabled</option>\n", |
|---|
| 7208 | strlen( wanifname ) == 0 ? "selected=\"selected\"" : "" ); |
|---|
| 7209 | foreach( var, eths, next ) |
|---|
| 7210 | { |
|---|
| 7211 | websWrite( wp, "<option value=\"%s\" %s >%s</option>\n", var, |
|---|
| 7212 | !strcmp( wanifname, |
|---|
| 7213 | var ) ? "selected=\"selected\"" : "", var ); |
|---|
| 7214 | } |
|---|
| 7215 | websWrite( wp, "</select></div>\n" ); |
|---|
| 7216 | } |
|---|
| 7217 | foreach( var, eths, next ) |
|---|
| 7218 | { |
|---|
| 7219 | if( !strcmp( get_wan_face( ), var ) ) |
|---|
| 7220 | continue; |
|---|
| 7221 | if( !strcmp( nvram_safe_get( "lan_ifname" ), var ) ) |
|---|
| 7222 | continue; |
|---|
| 7223 | if( !strncmp( var, "br", 2 ) && !contains( var, '.' ) ) |
|---|
| 7224 | continue; |
|---|
| 7225 | |
|---|
| 7226 | sprintf( ssid, "%s_bridged", var ); |
|---|
| 7227 | websWrite( wp, |
|---|
| 7228 | "<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.network)</script> %s</div>\n", |
|---|
| 7229 | var ); |
|---|
| 7230 | char layer[64]; |
|---|
| 7231 | |
|---|
| 7232 | strcpy( layer, var ); |
|---|
| 7233 | rep( layer, '.', 'X' ); |
|---|
| 7234 | websWrite( wp, |
|---|
| 7235 | "<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", |
|---|
| 7236 | layer, var, nvram_default_match( ssid, |
|---|
| 7237 | "0", |
|---|
| 7238 | "1" ) ? |
|---|
| 7239 | "checked=\"checked\"" : "" ); |
|---|
| 7240 | websWrite( wp, |
|---|
| 7241 | "<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", |
|---|
| 7242 | layer, var, nvram_default_match( ssid, "1", |
|---|
| 7243 | "1" ) ? |
|---|
| 7244 | "checked=\"checked\"" : "" ); |
|---|
| 7245 | websWrite( wp, "</div>\n" ); |
|---|
| 7246 | |
|---|
| 7247 | websWrite( wp, "<div id=\"%s_idnet\">\n", layer ); |
|---|
| 7248 | char mcast[32]; |
|---|
| 7249 | |
|---|
| 7250 | sprintf( mcast, "%s_multicast", var ); |
|---|
| 7251 | nvram_default_get( mcast, "0" ); |
|---|
| 7252 | showRadio( wp, "wl_basic.multicast", mcast ); |
|---|
| 7253 | show_ipnetmask( wp, var ); |
|---|
| 7254 | websWrite( wp, "</div>\n" ); |
|---|
| 7255 | websWrite( wp, "<script type=\"text/javascript\">\n//<![CDATA[\n " ); |
|---|
| 7256 | websWrite( wp, |
|---|
| 7257 | "show_layer_ext(document.getElementsByName(\"%s_bridged\"), \"%s_idnet\", %s);\n", |
|---|
| 7258 | var, layer, nvram_match( ssid, "0" ) ? "true" : "false" ); |
|---|
| 7259 | websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 7260 | } |
|---|
| 7261 | websWrite( wp, "</fieldset><br />\n" ); |
|---|
| 7262 | } |
|---|
| 7263 | #endif |
|---|
| 7264 | |
|---|
| 7265 | static void show_macfilter_if( webs_t wp, char *ifname ) |
|---|
| 7266 | { |
|---|
| 7267 | char rifname[32]; |
|---|
| 7268 | |
|---|
| 7269 | strcpy( rifname, ifname ); |
|---|
| 7270 | if( !strcmp( ifname, "wl" ) ) |
|---|
| 7271 | strcpy( rifname, nvram_safe_get( "wl0_ifname" ) ); |
|---|
| 7272 | if( !strcmp( ifname, "wl0" ) ) |
|---|
| 7273 | strcpy( rifname, nvram_safe_get( "wl0_ifname" ) ); |
|---|
| 7274 | |
|---|
| 7275 | websWrite( wp, "<fieldset>\n" ); |
|---|
| 7276 | websWrite( wp, "<legend>%s - %s</legend>\n", rifname, |
|---|
| 7277 | live_translate( "wl_mac.legend" ) ); |
|---|
| 7278 | websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 7279 | websWrite( wp, "<div class=\"label\">%s</div>\n", |
|---|
| 7280 | live_translate( "wl_mac.label" ) ); |
|---|
| 7281 | char macmode[32]; |
|---|
| 7282 | |
|---|
| 7283 | sprintf( macmode, "%s_macmode1", ifname ); |
|---|
| 7284 | rep( macmode, '.', 'X' ); |
|---|
| 7285 | if( nvram_get( macmode ) == NULL ) |
|---|
| 7286 | nvram_set( macmode, "disabled" ); |
|---|
| 7287 | char id[32]; |
|---|
| 7288 | |
|---|
| 7289 | sprintf( id, "idmac%s", ifname ); |
|---|
| 7290 | rep( id, '.', 'X' ); |
|---|
| 7291 | char mycopy[256]; |
|---|
| 7292 | |
|---|
| 7293 | strcpy( mycopy, live_translate( "share.enable" ) ); |
|---|
| 7294 | websWrite( wp, |
|---|
| 7295 | "<input class=\"spaceradio\" type=\"radio\" value=\"other\" name=\"%s\" %s onclick=\"show_layer_ext(this, '%s', true)\" />%s \n", |
|---|
| 7296 | macmode, nvram_match( macmode, |
|---|
| 7297 | "other" ) ? "checked=\"checked\"" : "", |
|---|
| 7298 | id, mycopy ); |
|---|
| 7299 | strcpy( mycopy, live_translate( "share.disable" ) ); |
|---|
| 7300 | websWrite( wp, |
|---|
| 7301 | "<input class=\"spaceradio\" type=\"radio\" value=\"disabled\" name=\"%s\" %s onclick=\"show_layer_ext(this, '%s', false)\" />%s\n", |
|---|
| 7302 | macmode, nvram_match( macmode, |
|---|
| 7303 | "disabled" ) ? "checked=\"checked\"" : |
|---|
| 7304 | "", id, mycopy ); |
|---|
| 7305 | websWrite( wp, "</div>\n" ); |
|---|
| 7306 | websWrite( wp, "<div class=\"setting\" id=\"%s\">\n", id ); |
|---|
| 7307 | websWrite( wp, "<div class=\"label\">%s<br /> </div>\n", |
|---|
| 7308 | live_translate( "wl_mac.label2" ) ); |
|---|
| 7309 | sprintf( macmode, "%s_macmode", ifname ); |
|---|
| 7310 | if( nvram_get( macmode ) == NULL ) |
|---|
| 7311 | nvram_set( macmode, "disabled" ); |
|---|
| 7312 | strcpy( mycopy, live_translate( "wl_mac.deny" ) ); |
|---|
| 7313 | websWrite( wp, |
|---|
| 7314 | "<input class=\"spaceradio\" type=\"radio\" value=\"deny\" name=\"%s\" %s />%s \n", |
|---|
| 7315 | macmode, nvram_invmatch( macmode, |
|---|
| 7316 | "allow" ) ? "checked=\"checked\"" : |
|---|
| 7317 | "", mycopy ); |
|---|
| 7318 | websWrite( wp, "<br />\n" ); |
|---|
| 7319 | strcpy( mycopy, live_translate( "wl_mac.allow" ) ); |
|---|
| 7320 | websWrite( wp, |
|---|
| 7321 | "<input class=\"spaceradio\" type=\"radio\" value=\"allow\" name=\"%s\" %s />%s\n", |
|---|
| 7322 | macmode, nvram_match( macmode, |
|---|
| 7323 | "allow" ) ? "checked=\"checked\"" : "", |
|---|
| 7324 | mycopy ); |
|---|
| 7325 | websWrite( wp, "</div><br />\n" ); |
|---|
| 7326 | websWrite( wp, "<div class=\"center\">\n" ); |
|---|
| 7327 | websWrite( wp, "<script type=\"text/javascript\">\n" ); |
|---|
| 7328 | websWrite( wp, "//<![CDATA[\n" ); |
|---|
| 7329 | websWrite( wp, |
|---|
| 7330 | "document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" name=\\\"mac_filter_button\\\" value=\\\"\" + sbutton.filterMac + \"\\\" onclick=\\\"openWindow('WL_FilterTable-%s.asp', 930, 740,'MACList');\\\" />\");\n", |
|---|
| 7331 | ifname ); |
|---|
| 7332 | websWrite( wp, "//]]>\n" ); |
|---|
| 7333 | websWrite( wp, "</script>\n" ); |
|---|
| 7334 | websWrite( wp, "</div>\n" ); |
|---|
| 7335 | websWrite( wp, "</fieldset><br />\n" ); |
|---|
| 7336 | } |
|---|
| 7337 | |
|---|
| 7338 | void ej_list_mac_layers( webs_t wp, int argc, char_t ** argv ) |
|---|
| 7339 | { |
|---|
| 7340 | #ifndef HAVE_MADWIFI |
|---|
| 7341 | int c = get_wl_instances( ); |
|---|
| 7342 | char devs[32]; |
|---|
| 7343 | int i; |
|---|
| 7344 | |
|---|
| 7345 | for( i = 0; i < c; i++ ) |
|---|
| 7346 | { |
|---|
| 7347 | char macmode[32]; |
|---|
| 7348 | char id[32]; |
|---|
| 7349 | |
|---|
| 7350 | sprintf( devs, "wl%d", i ); |
|---|
| 7351 | sprintf( macmode, "%s_macmode1", devs ); |
|---|
| 7352 | sprintf( id, "idmac%s", devs ); |
|---|
| 7353 | rep( id, '.', 'X' ); |
|---|
| 7354 | rep( macmode, '.', 'X' ); |
|---|
| 7355 | websWrite( wp, |
|---|
| 7356 | "show_layer_ext(document.wireless.%s, '%s', \"%s\" == \"other\");\n", |
|---|
| 7357 | macmode, id, nvram_match( macmode, |
|---|
| 7358 | "other" ) ? "other" : |
|---|
| 7359 | "disabled" ); |
|---|
| 7360 | } |
|---|
| 7361 | |
|---|
| 7362 | #else |
|---|
| 7363 | |
|---|
| 7364 | int c = getdevicecount( ); |
|---|
| 7365 | char devs[32]; |
|---|
| 7366 | int i; |
|---|
| 7367 | |
|---|
| 7368 | for( i = 0; i < c; i++ ) |
|---|
| 7369 | { |
|---|
| 7370 | char macmode[32]; |
|---|
| 7371 | char id[32]; |
|---|
| 7372 | |
|---|
| 7373 | sprintf( devs, "ath%d", i ); |
|---|
| 7374 | sprintf( macmode, "%s_macmode1", devs ); |
|---|
| 7375 | sprintf( id, "idmac%s", devs ); |
|---|
| 7376 | rep( id, '.', 'X' ); |
|---|
| 7377 | rep( macmode, '.', 'X' ); |
|---|
| 7378 | websWrite( wp, |
|---|
| 7379 | "show_layer_ext(document.wireless.%s, '%s', \"%s\" == \"other\");\n", |
|---|
| 7380 | macmode, id, nvram_match( macmode, |
|---|
| 7381 | "other" ) ? "other" : |
|---|
| 7382 | "disabled" ); |
|---|
| 7383 | // show_macfilter_if (wp, devs); |
|---|
| 7384 | char vif[32]; |
|---|
| 7385 | |
|---|
| 7386 | sprintf( vif, "%s_vifs", devs ); |
|---|
| 7387 | char var[80], *next; |
|---|
| 7388 | char *vifs = nvram_safe_get( vif ); |
|---|
| 7389 | |
|---|
| 7390 | if( vifs != NULL ) |
|---|
| 7391 | foreach( var, vifs, next ) |
|---|
| 7392 | { |
|---|
| 7393 | sprintf( macmode, "%s_macmode1", var ); |
|---|
| 7394 | sprintf( id, "idmac%s", var ); |
|---|
| 7395 | rep( id, '.', 'X' ); |
|---|
| 7396 | rep( macmode, '.', 'X' ); |
|---|
| 7397 | websWrite( wp, |
|---|
| 7398 | "show_layer_ext(document.wireless.%s, '%s', \"%s\" == \"other\");\n", |
|---|
| 7399 | macmode, id, nvram_match( macmode, |
|---|
| 7400 | "other" ) ? "other" : |
|---|
| 7401 | "disabled" ); |
|---|
| 7402 | } |
|---|
| 7403 | } |
|---|
| 7404 | |
|---|
| 7405 | #endif |
|---|
| 7406 | } |
|---|
| 7407 | void ej_show_macfilter( webs_t wp, int argc, char_t ** argv ) |
|---|
| 7408 | { |
|---|
| 7409 | #ifndef HAVE_MADWIFI |
|---|
| 7410 | int c = get_wl_instances( ); |
|---|
| 7411 | char devs[32]; |
|---|
| 7412 | int i; |
|---|
| 7413 | |
|---|
| 7414 | for( i = 0; i < c; i++ ) |
|---|
| 7415 | { |
|---|
| 7416 | sprintf( devs, "wl%d", i ); |
|---|
| 7417 | show_macfilter_if( wp, devs ); |
|---|
| 7418 | } |
|---|
| 7419 | #else |
|---|
| 7420 | int c = getdevicecount( ); |
|---|
| 7421 | char devs[32]; |
|---|
| 7422 | int i; |
|---|
| 7423 | |
|---|
| 7424 | for( i = 0; i < c; i++ ) |
|---|
| 7425 | { |
|---|
| 7426 | sprintf( devs, "ath%d", i ); |
|---|
| 7427 | show_macfilter_if( wp, devs ); |
|---|
| 7428 | char vif[32]; |
|---|
| 7429 | |
|---|
| 7430 | sprintf( vif, "%s_vifs", devs ); |
|---|
| 7431 | char var[80], *next; |
|---|
| 7432 | char *vifs = nvram_safe_get( vif ); |
|---|
| 7433 | |
|---|
| 7434 | if( vifs != NULL ) |
|---|
| 7435 | foreach( var, vifs, next ) |
|---|
| 7436 | { |
|---|
| 7437 | show_macfilter_if( wp, var ); |
|---|
| 7438 | } |
|---|
| 7439 | } |
|---|
| 7440 | |
|---|
| 7441 | #endif |
|---|
| 7442 | } |
|---|
| 7443 | |
|---|
| 7444 | #ifdef HAVE_CHILLI |
|---|
| 7445 | void ej_show_chilliif( webs_t wp, int argc, char_t ** argv ) |
|---|
| 7446 | { |
|---|
| 7447 | websWrite( wp, "<select name=\"chilli_interface\">\n" ); |
|---|
| 7448 | websWrite( wp, "<option value=\"%s\" %s >LAN</option>\n", |
|---|
| 7449 | nvram_safe_get( "lan_ifname" ), |
|---|
| 7450 | nvram_match( "chilli_interface", |
|---|
| 7451 | nvram_safe_get( "lan_ifname" ) ) ? |
|---|
| 7452 | "selected=\"selected\"" : "" ); |
|---|
| 7453 | char *next; |
|---|
| 7454 | char var[80]; |
|---|
| 7455 | char eths[256]; |
|---|
| 7456 | |
|---|
| 7457 | memset( eths, 0, 256 ); |
|---|
| 7458 | getIfLists( eths, 256 ); |
|---|
| 7459 | foreach( var, eths, next ) |
|---|
| 7460 | { |
|---|
| 7461 | if( !strcmp( get_wan_face( ), var ) ) |
|---|
| 7462 | continue; |
|---|
| 7463 | if( !strcmp( nvram_safe_get( "lan_ifname" ), var ) ) |
|---|
| 7464 | continue; |
|---|
| 7465 | websWrite( wp, "<option value=\"%s\" %s >%s</option>\n", var, |
|---|
| 7466 | nvram_match( "chilli_interface", var ) ? "selected" : "", |
|---|
| 7467 | var ); |
|---|
| 7468 | } |
|---|
| 7469 | |
|---|
| 7470 | websWrite( wp, "</select>\n" ); |
|---|
| 7471 | } |
|---|
| 7472 | #endif |
|---|
| 7473 | |
|---|
| 7474 | #ifdef HAVE_RFLOW |
|---|
| 7475 | void ej_show_rflowif( webs_t wp, int argc, char_t ** argv ) |
|---|
| 7476 | { |
|---|
| 7477 | websWrite( wp, "<option value=\"%s\" %s >LAN & WLAN</option>\n", |
|---|
| 7478 | nvram_safe_get( "lan_ifname" ), nvram_match( "rflow_if", |
|---|
| 7479 | nvram_safe_get |
|---|
| 7480 | ( "lan_ifname" ) ) |
|---|
| 7481 | ? "selected=\"selected\"" : "" ); |
|---|
| 7482 | |
|---|
| 7483 | char *lanifs = nvram_safe_get( "lan_ifnames" ); |
|---|
| 7484 | char tmp[128]; |
|---|
| 7485 | char *lanif; |
|---|
| 7486 | |
|---|
| 7487 | if( strlen( lanifs ) != 0 ) |
|---|
| 7488 | { |
|---|
| 7489 | strcpy( tmp, lanifs ); |
|---|
| 7490 | lanif = strtok( tmp, " " ); |
|---|
| 7491 | websWrite( wp, "<option value=\"%s\" %s >LAN</option>\n", |
|---|
| 7492 | lanif, nvram_match( "rflow_if", |
|---|
| 7493 | lanif ) ? "selected=\"selected\"" : |
|---|
| 7494 | "" ); |
|---|
| 7495 | } |
|---|
| 7496 | |
|---|
| 7497 | websWrite( wp, "<option value=\"%s\" %s >WLAN</option>\n", |
|---|
| 7498 | nvram_safe_get( "wl0_ifname" ), nvram_match( "rflow_if", |
|---|
| 7499 | nvram_safe_get |
|---|
| 7500 | ( "wl0_ifname" ) ) |
|---|
| 7501 | ? "selected=\"selected\"" : "" ); |
|---|
| 7502 | |
|---|
| 7503 | char *wanif = nvram_safe_get( "wan_ifname" ); |
|---|
| 7504 | |
|---|
| 7505 | if( strlen( wanif ) != 0 ) |
|---|
| 7506 | { |
|---|
| 7507 | websWrite( wp, "<option value=\"%s\" %s >WAN</option>\n", |
|---|
| 7508 | wanif, nvram_match( "rflow_if", |
|---|
| 7509 | wanif ) ? "selected=\"selected\"" : |
|---|
| 7510 | "" ); |
|---|
| 7511 | } |
|---|
| 7512 | } |
|---|
| 7513 | #endif |
|---|