| 1 |
#define VISUALSOURCE 1 |
|---|
| 2 |
/* |
|---|
| 3 |
* dd-wrt.c |
|---|
| 4 |
* |
|---|
| 5 |
* Copyright (C) 2005 - 2007 Sebastian Gottschall <sebastian.gottschall@newmedia-net.de> |
|---|
| 6 |
* |
|---|
| 7 |
* This program is free software; you can redistribute it and/or |
|---|
| 8 |
* modify it under the terms of the GNU General Public License |
|---|
| 9 |
* as published by the Free Software Foundation; either version 2 |
|---|
| 10 |
* of the License, or (at your option) any later version. |
|---|
| 11 |
* |
|---|
| 12 |
* This program is distributed in the hope that it will be useful, |
|---|
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 |
* GNU General Public License for more details. |
|---|
| 16 |
* |
|---|
| 17 |
* You should have received a copy of the GNU General Public License |
|---|
| 18 |
* along with this program; if not, write to the Free Software |
|---|
| 19 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 20 |
* |
|---|
| 21 |
* $Id: |
|---|
| 22 |
*/ |
|---|
| 23 |
|
|---|
| 24 |
#include <stdio.h> |
|---|
| 25 |
#include <stdlib.h> |
|---|
| 26 |
#include <stdarg.h> |
|---|
| 27 |
#include <string.h> |
|---|
| 28 |
#include <unistd.h> |
|---|
| 29 |
#include <ctype.h> |
|---|
| 30 |
#include <signal.h> |
|---|
| 31 |
|
|---|
| 32 |
#include <sys/ioctl.h> |
|---|
| 33 |
#include <sys/types.h> |
|---|
| 34 |
#include <sys/stat.h> |
|---|
| 35 |
#include <sys/socket.h> |
|---|
| 36 |
#include <sys/statfs.h> |
|---|
| 37 |
#include <netinet/in.h> |
|---|
| 38 |
#include <arpa/inet.h> |
|---|
| 39 |
#include <broadcom.h> |
|---|
| 40 |
#include <cymac.h> |
|---|
| 41 |
#include <wlutils.h> |
|---|
| 42 |
#include <bcmparams.h> |
|---|
| 43 |
#include <dirent.h> |
|---|
| 44 |
#include <netdb.h> |
|---|
| 45 |
#include <utils.h> |
|---|
| 46 |
#include <wlutils.h> |
|---|
| 47 |
#include <bcmnvram.h> |
|---|
| 48 |
#include <l7protocols.h> |
|---|
| 49 |
|
|---|
| 50 |
#ifdef HAVE_OVERCLOCKING |
|---|
| 51 |
static unsigned int type3_clocks[3] = { 150, 200, 0 }; |
|---|
| 52 |
static unsigned int type4_clocks[10] = |
|---|
| 53 |
{ 192, 200, 216, 228, 240, 252, 264, 280, 300, 0 }; |
|---|
| 54 |
static unsigned int type7_clocks[10] = |
|---|
| 55 |
{ 183, 187, 198, 200, 216, 225, 233, 237, 250, 0 }; |
|---|
| 56 |
#endif |
|---|
| 57 |
|
|---|
| 58 |
#ifdef HAVE_RT2880 |
|---|
| 59 |
#define IFMAP(a) getRADev(a) |
|---|
| 60 |
#else |
|---|
| 61 |
#define IFMAP(a) (a) |
|---|
| 62 |
#endif |
|---|
| 63 |
|
|---|
| 64 |
void show_ipnetmask(webs_t wp, char *var) |
|---|
| 65 |
{ |
|---|
| 66 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 67 |
websWrite(wp, |
|---|
| 68 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(share.ip)</script></div>\n"); |
|---|
| 69 |
|
|---|
| 70 |
char *ipv = nvram_nget("%s_ipaddr", var); |
|---|
| 71 |
|
|---|
| 72 |
websWrite(wp, |
|---|
| 73 |
"<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,1,223,share.ip)\" name=\"%s_ipaddr_0\" value=\"%d\" />.", |
|---|
| 74 |
var, get_single_ip(ipv, 0)); |
|---|
| 75 |
websWrite(wp, |
|---|
| 76 |
"<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_1\" value=\"%d\" />.", |
|---|
| 77 |
var, get_single_ip(ipv, 1)); |
|---|
| 78 |
websWrite(wp, |
|---|
| 79 |
"<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_2\" value=\"%d\" />.", |
|---|
| 80 |
var, get_single_ip(ipv, 2)); |
|---|
| 81 |
websWrite(wp, |
|---|
| 82 |
"<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_3\" value=\"%d\" />\n", |
|---|
| 83 |
var, get_single_ip(ipv, 3)); |
|---|
| 84 |
websWrite(wp, "</div>\n"); |
|---|
| 85 |
|
|---|
| 86 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 87 |
websWrite(wp, |
|---|
| 88 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(share.subnet)</script></div>\n"); |
|---|
| 89 |
ipv = nvram_nget("%s_netmask", var); |
|---|
| 90 |
|
|---|
| 91 |
websWrite(wp, |
|---|
| 92 |
"<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_0\" value=\"%d\" />.", |
|---|
| 93 |
var, get_single_ip(ipv, 0)); |
|---|
| 94 |
websWrite(wp, |
|---|
| 95 |
"<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_1\" value=\"%d\" />.", |
|---|
| 96 |
var, get_single_ip(ipv, 1)); |
|---|
| 97 |
websWrite(wp, |
|---|
| 98 |
"<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_2\" value=\"%d\" />.", |
|---|
| 99 |
var, get_single_ip(ipv, 2)); |
|---|
| 100 |
websWrite(wp, |
|---|
| 101 |
"<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_3\" value=\"%d\" />", |
|---|
| 102 |
var, get_single_ip(ipv, 3)); |
|---|
| 103 |
websWrite(wp, "</div>\n<br />\n"); |
|---|
| 104 |
|
|---|
| 105 |
} |
|---|
| 106 |
|
|---|
| 107 |
#ifdef HAVE_OVERCLOCKING |
|---|
| 108 |
void ej_show_clocks(webs_t wp, int argc, char_t ** argv) |
|---|
| 109 |
{ |
|---|
| 110 |
int tab = cpu_plltype(); |
|---|
| 111 |
unsigned int *c; |
|---|
| 112 |
|
|---|
| 113 |
if (tab == 3) |
|---|
| 114 |
c = type3_clocks; |
|---|
| 115 |
else if (tab == 4) |
|---|
| 116 |
c = type4_clocks; |
|---|
| 117 |
else if (tab == 7) |
|---|
| 118 |
c = type7_clocks; |
|---|
| 119 |
else { |
|---|
| 120 |
websWrite(wp, |
|---|
| 121 |
"<script type=\"text/javascript\">Capture(management.clock_support)</script>\n</div>\n"); |
|---|
| 122 |
return; |
|---|
| 123 |
} |
|---|
| 124 |
|
|---|
| 125 |
websWrite(wp, |
|---|
| 126 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(management.clock_frq)</script></div>\n"); |
|---|
| 127 |
websWrite(wp, "<select name=\"overclocking\">\n"); |
|---|
| 128 |
|
|---|
| 129 |
int i = 0; |
|---|
| 130 |
char clock[16]; |
|---|
| 131 |
|
|---|
| 132 |
while (c[i] != 0) { |
|---|
| 133 |
sprintf(clock, "%d", c[i]); |
|---|
| 134 |
websWrite(wp, "<option value=\"%d\" %s >%d MHz</option>\n", |
|---|
| 135 |
c[i], nvram_match("overclocking", |
|---|
| 136 |
clock) ? "selected=\"selected\"" : |
|---|
| 137 |
"", c[i]); |
|---|
| 138 |
i++; |
|---|
| 139 |
} |
|---|
| 140 |
websWrite(wp, "</select>\n</div>\n"); |
|---|
| 141 |
} |
|---|
| 142 |
#endif |
|---|
| 143 |
|
|---|
| 144 |
void ej_show_routing(webs_t wp, int argc, char_t ** argv) |
|---|
| 145 |
{ |
|---|
| 146 |
websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 147 |
websWrite(wp, |
|---|
| 148 |
"document.write(\"<option value=\\\"gateway\\\" %s >\" + share.gateway + \"</option>\");\n", |
|---|
| 149 |
nvram_selmatch(wp, "wk_mode", |
|---|
| 150 |
"gateway") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 151 |
#ifdef HAVE_BIRD |
|---|
| 152 |
websWrite(wp, |
|---|
| 153 |
"document.write(\"<option value=\\\"bgp\\\" %s >BGP</option>\");\n", |
|---|
| 154 |
nvram_selmatch(wp, "wk_mode", |
|---|
| 155 |
"bgp") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 156 |
websWrite(wp, |
|---|
| 157 |
"document.write(\"<option value=\\\"router\\\" %s >\" + route.rip2_mod + \"</option>\");\n", |
|---|
| 158 |
nvram_selmatch(wp, "wk_mode", |
|---|
| 159 |
"router") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 160 |
#endif |
|---|
| 161 |
#ifdef HAVE_QUAGGA |
|---|
| 162 |
websWrite(wp, |
|---|
| 163 |
"document.write(\"<option value=\\\"bgp\\\" %s >BGP</option>\");\n", |
|---|
| 164 |
nvram_selmatch(wp, "wk_mode", |
|---|
| 165 |
"bgp") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 166 |
websWrite(wp, |
|---|
| 167 |
"document.write(\"<option value=\\\"router\\\" %s >\" + route.rip2_mod + \"</option>\");\n", |
|---|
| 168 |
nvram_selmatch(wp, "wk_mode", |
|---|
| 169 |
"router") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 170 |
websWrite(wp, |
|---|
| 171 |
"document.write(\"<option value=\\\"ospf\\\" %s >\" + route.ospf_mod + \"</option>\");\n", |
|---|
| 172 |
nvram_selmatch(wp, "wk_mode", |
|---|
| 173 |
"ospf") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 174 |
#endif |
|---|
| 175 |
#ifdef HAVE_OLSRD |
|---|
| 176 |
websWrite(wp, |
|---|
| 177 |
"document.write(\"<option value=\\\"olsr\\\" %s >\" + route.olsrd_mod + \"</option>\");\n", |
|---|
| 178 |
nvram_selmatch(wp, "wk_mode", |
|---|
| 179 |
"olsr") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 180 |
#endif |
|---|
| 181 |
websWrite(wp, |
|---|
| 182 |
"document.write(\"<option value=\\\"static\\\" %s >\" + share.router + \"</option>\");\n", |
|---|
| 183 |
nvram_selmatch(wp, "wk_mode", |
|---|
| 184 |
"static") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 185 |
websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 186 |
return; |
|---|
| 187 |
|
|---|
| 188 |
} |
|---|
| 189 |
|
|---|
| 190 |
void ej_show_connectiontype(webs_t wp, int argc, char_t ** argv) |
|---|
| 191 |
{ |
|---|
| 192 |
|
|---|
| 193 |
websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 194 |
websWrite(wp, |
|---|
| 195 |
"document.write(\"<option value=\\\"disabled\\\" %s >\" + share.disabled + \"</option>\");\n", |
|---|
| 196 |
nvram_selmatch(wp, "wan_proto", |
|---|
| 197 |
"disabled") ? "selected=\\\"selected\\\"" : |
|---|
| 198 |
""); |
|---|
| 199 |
websWrite(wp, |
|---|
| 200 |
"document.write(\"<option value=\\\"static\\\" %s >\" + idx.static_ip + \"</option>\");\n", |
|---|
| 201 |
nvram_selmatch(wp, "wan_proto", |
|---|
| 202 |
"static") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 203 |
websWrite(wp, |
|---|
| 204 |
"document.write(\"<option value=\\\"dhcp\\\" %s >\" + idx.dhcp + \"</option>\");\n", |
|---|
| 205 |
nvram_selmatch(wp, "wan_proto", |
|---|
| 206 |
"dhcp") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 207 |
websWrite(wp, "\n//]]>\n</script>\n"); |
|---|
| 208 |
|
|---|
| 209 |
#ifdef HAVE_PPPOE |
|---|
| 210 |
websWrite(wp, "<option value=\"pppoe\" %s >PPPoE</option>\n", |
|---|
| 211 |
nvram_selmatch(wp, "wan_proto", |
|---|
| 212 |
"pppoe") ? "selected=\"selected\"" : ""); |
|---|
| 213 |
#endif |
|---|
| 214 |
#ifdef HAVE_PPTP |
|---|
| 215 |
websWrite(wp, "<option value=\"pptp\" %s >PPTP</option>\n", |
|---|
| 216 |
nvram_selmatch(wp, "wan_proto", |
|---|
| 217 |
"pptp") ? "selected=\"selected\"" : ""); |
|---|
| 218 |
#endif |
|---|
| 219 |
#ifdef HAVE_L2TP |
|---|
| 220 |
websWrite(wp, "<option value=\"l2tp\" %s >L2TP</option>\n", |
|---|
| 221 |
nvram_selmatch(wp, "wan_proto", |
|---|
| 222 |
"l2tp") ? "selected=\"selected\"" : ""); |
|---|
| 223 |
#endif |
|---|
| 224 |
#ifdef HAVE_HEARTBEAT |
|---|
| 225 |
websWrite(wp, |
|---|
| 226 |
"<option value=\"heartbeat\" %s >HeartBeat Signal</option>\n", |
|---|
| 227 |
nvram_selmatch(wp, "wan_proto", |
|---|
| 228 |
"heartbeat") ? "selected=\"selected\"" : ""); |
|---|
| 229 |
#endif |
|---|
| 230 |
#ifdef HAVE_3G |
|---|
| 231 |
websWrite(wp, |
|---|
| 232 |
"<option value=\"3g\" %s >3G/UMTS</option>\n", |
|---|
| 233 |
nvram_selmatch(wp, "wan_proto", |
|---|
| 234 |
"3g") ? "selected=\"selected\"" : ""); |
|---|
| 235 |
#endif |
|---|
| 236 |
|
|---|
| 237 |
return; |
|---|
| 238 |
} |
|---|
| 239 |
|
|---|
| 240 |
void ej_show_infopage(webs_t wp, int argc, char_t ** argv) |
|---|
| 241 |
{ |
|---|
| 242 |
/* |
|---|
| 243 |
* #ifdef HAVE_NEWMEDIA websWrite(wp,"<dl>\n"); websWrite(wp,"<dd |
|---|
| 244 |
* class=\"definition\">GGEW net GmbH</dd>\n"); websWrite(wp,"<dd |
|---|
| 245 |
* class=\"definition\">Dammstrasse 68</dd>\n"); websWrite(wp,"<dd |
|---|
| 246 |
* class=\"definition\">64625 Bensheim</dd>\n"); websWrite(wp,"<dd |
|---|
| 247 |
* class=\"definition\"><a href=\"http://ggew-net.de\"><img |
|---|
| 248 |
* src=\"images/ggewlogo.gif\" border=\"0\"/></a></dd>\n"); |
|---|
| 249 |
* websWrite(wp,"<dd class=\"definition\"> </dd>\n"); websWrite(wp,"<dd |
|---|
| 250 |
* class=\"definition\"><a href=\"http://ggew-net.de\"/></dd>\n"); |
|---|
| 251 |
* websWrite(wp,"<dd class=\"definition\"> </dd>\n"); websWrite(wp,"<dd |
|---|
| 252 |
* class=\"definition\">In Kooperation mit NewMedia-NET GmbH</dd>\n"); |
|---|
| 253 |
* websWrite(wp,"<dd class=\"definition\"><a |
|---|
| 254 |
* href=\"http://www.newmedia-net.de\"/></dd>\n"); |
|---|
| 255 |
* websWrite(wp,"</dl>\n"); #endif |
|---|
| 256 |
*/ |
|---|
| 257 |
return; |
|---|
| 258 |
} |
|---|
| 259 |
|
|---|
| 260 |
void ej_dumpmeminfo(webs_t wp, int argc, char_t ** argv) |
|---|
| 261 |
{ |
|---|
| 262 |
FILE *fcpu = fopen("/proc/meminfo", "r"); |
|---|
| 263 |
|
|---|
| 264 |
if (fcpu == NULL) { |
|---|
| 265 |
return; |
|---|
| 266 |
} |
|---|
| 267 |
char buf[128]; |
|---|
| 268 |
int n = 0; |
|---|
| 269 |
|
|---|
| 270 |
rept:; |
|---|
| 271 |
if (n == EOF) { |
|---|
| 272 |
fclose(fcpu); |
|---|
| 273 |
return; |
|---|
| 274 |
} |
|---|
| 275 |
if (n) |
|---|
| 276 |
websWrite(wp, "'%s'", buf); |
|---|
| 277 |
n = fscanf(fcpu, "%s", buf); |
|---|
| 278 |
if (n != EOF) |
|---|
| 279 |
websWrite(wp, ","); |
|---|
| 280 |
goto rept; |
|---|
| 281 |
} |
|---|
| 282 |
|
|---|
| 283 |
#ifdef HAVE_RB500 |
|---|
| 284 |
void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 285 |
{ |
|---|
| 286 |
FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 287 |
|
|---|
| 288 |
if (fp == NULL) { |
|---|
| 289 |
websWrite(wp, "unknown"); |
|---|
| 290 |
return; |
|---|
| 291 |
} |
|---|
| 292 |
int cnt = 0; |
|---|
| 293 |
int b = 0; |
|---|
| 294 |
|
|---|
| 295 |
while (b != EOF) { |
|---|
| 296 |
b = getc(fp); |
|---|
| 297 |
if (b == ':') |
|---|
| 298 |
cnt++; |
|---|
| 299 |
|
|---|
| 300 |
if (cnt == 4) { |
|---|
| 301 |
getc(fp); |
|---|
| 302 |
char cpuclk[4]; |
|---|
| 303 |
|
|---|
| 304 |
cpuclk[0] = getc(fp); |
|---|
| 305 |
cpuclk[1] = getc(fp); |
|---|
| 306 |
cpuclk[2] = getc(fp); |
|---|
| 307 |
cpuclk[3] = 0; |
|---|
| 308 |
websWrite(wp, cpuclk); |
|---|
| 309 |
fclose(fp); |
|---|
| 310 |
return; |
|---|
| 311 |
} |
|---|
| 312 |
} |
|---|
| 313 |
|
|---|
| 314 |
fclose(fp); |
|---|
| 315 |
websWrite(wp, "unknown"); |
|---|
| 316 |
return; |
|---|
| 317 |
} |
|---|
| 318 |
|
|---|
| 319 |
#elif HAVE_STORM |
|---|
| 320 |
void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 321 |
{ |
|---|
| 322 |
websWrite(wp, "300"); |
|---|
| 323 |
/* |
|---|
| 324 |
* FILE *fp = fopen ("/proc/cpuinfo", "rb"); if (fp == NULL) { websWrite |
|---|
| 325 |
* (wp, "unknown"); return; } int cnt = 0; int b = 0; while (b != EOF) { |
|---|
| 326 |
* b = getc (fp); if (b == ':') cnt++; if (cnt == 2) { getc (fp); char |
|---|
| 327 |
* cpuclk[4]; cpuclk[0] = getc (fp); cpuclk[1] = getc (fp); cpuclk[2] = |
|---|
| 328 |
* getc (fp); cpuclk[3] = 0; websWrite (wp, cpuclk); fclose (fp); return; |
|---|
| 329 |
* } } |
|---|
| 330 |
* |
|---|
| 331 |
* fclose (fp); websWrite (wp, "unknown"); |
|---|
| 332 |
*/ |
|---|
| 333 |
return; |
|---|
| 334 |
} |
|---|
| 335 |
#elif HAVE_RT3052 |
|---|
| 336 |
void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 337 |
{ |
|---|
| 338 |
websWrite(wp, "384"); |
|---|
| 339 |
return; |
|---|
| 340 |
} |
|---|
| 341 |
#elif HAVE_RT2880 |
|---|
| 342 |
void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 343 |
{ |
|---|
| 344 |
websWrite(wp, "266"); |
|---|
| 345 |
return; |
|---|
| 346 |
} |
|---|
| 347 |
#elif HAVE_XSCALE |
|---|
| 348 |
void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 349 |
{ |
|---|
| 350 |
FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 351 |
|
|---|
| 352 |
if (fp == NULL) { |
|---|
| 353 |
websWrite(wp, "unknown"); |
|---|
| 354 |
return; |
|---|
| 355 |
} |
|---|
| 356 |
int cnt = 0; |
|---|
| 357 |
int b = 0; |
|---|
| 358 |
|
|---|
| 359 |
while (b != EOF) { |
|---|
| 360 |
b = getc(fp); |
|---|
| 361 |
if (b == ':') |
|---|
| 362 |
cnt++; |
|---|
| 363 |
if (cnt == 2) { |
|---|
| 364 |
getc(fp); |
|---|
| 365 |
char cpuclk[4]; |
|---|
| 366 |
|
|---|
| 367 |
cpuclk[0] = getc(fp); |
|---|
| 368 |
cpuclk[1] = getc(fp); |
|---|
| 369 |
cpuclk[2] = getc(fp); |
|---|
| 370 |
cpuclk[3] = 0; |
|---|
| 371 |
websWrite(wp, cpuclk); |
|---|
| 372 |
fclose(fp); |
|---|
| 373 |
return; |
|---|
| 374 |
} |
|---|
| 375 |
} |
|---|
| 376 |
|
|---|
| 377 |
fclose(fp); |
|---|
| 378 |
websWrite(wp, "unknown"); |
|---|
| 379 |
return; |
|---|
| 380 |
} |
|---|
| 381 |
#elif HAVE_X86 |
|---|
| 382 |
void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 383 |
{ |
|---|
| 384 |
FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 385 |
|
|---|
| 386 |
if (fp == NULL) { |
|---|
| 387 |
websWrite(wp, "unknown"); |
|---|
| 388 |
return; |
|---|
| 389 |
} |
|---|
| 390 |
int cnt = 0; |
|---|
| 391 |
int b = 0; |
|---|
| 392 |
|
|---|
| 393 |
while (b != EOF) { |
|---|
| 394 |
b = getc(fp); |
|---|
| 395 |
if (b == ':') |
|---|
| 396 |
cnt++; |
|---|
| 397 |
if (cnt == 7) { |
|---|
| 398 |
getc(fp); |
|---|
| 399 |
char cpuclk[32]; |
|---|
| 400 |
int i = 0; |
|---|
| 401 |
|
|---|
| 402 |
b = getc(fp); |
|---|
| 403 |
while (b != 0xa && b != 0xd && b != 0x20) { |
|---|
| 404 |
cpuclk[i++] = b; |
|---|
| 405 |
b = getc(fp); |
|---|
| 406 |
} |
|---|
| 407 |
cpuclk[i++] = 0; |
|---|
| 408 |
websWrite(wp, cpuclk); |
|---|
| 409 |
fclose(fp); |
|---|
| 410 |
return; |
|---|
| 411 |
} |
|---|
| 412 |
} |
|---|
| 413 |
|
|---|
| 414 |
fclose(fp); |
|---|
| 415 |
websWrite(wp, "unknown"); |
|---|
| 416 |
return; |
|---|
| 417 |
} |
|---|
| 418 |
#elif HAVE_MAGICBOX |
|---|
| 419 |
void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 420 |
{ |
|---|
| 421 |
FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 422 |
|
|---|
| 423 |
if (fp == NULL) { |
|---|
| 424 |
websWrite(wp, "unknown"); |
|---|
| 425 |
return; |
|---|
| 426 |
} |
|---|
| 427 |
int cnt = 0; |
|---|
| 428 |
int b = 0; |
|---|
| 429 |
|
|---|
| 430 |
while (b != EOF) { |
|---|
| 431 |
b = getc(fp); |
|---|
| 432 |
if (b == ':') |
|---|
| 433 |
cnt++; |
|---|
| 434 |
if (cnt == 3) { |
|---|
| 435 |
getc(fp); |
|---|
| 436 |
char cpuclk[4]; |
|---|
| 437 |
|
|---|
| 438 |
cpuclk[0] = getc(fp); |
|---|
| 439 |
cpuclk[1] = getc(fp); |
|---|
| 440 |
cpuclk[2] = getc(fp); |
|---|
| 441 |
cpuclk[3] = 0; |
|---|
| 442 |
websWrite(wp, cpuclk); |
|---|
| 443 |
fclose(fp); |
|---|
| 444 |
return; |
|---|
| 445 |
} |
|---|
| 446 |
} |
|---|
| 447 |
|
|---|
| 448 |
fclose(fp); |
|---|
| 449 |
websWrite(wp, "unknown"); |
|---|
| 450 |
return; |
|---|
| 451 |
} |
|---|
| 452 |
#elif HAVE_FONERA |
|---|
| 453 |
void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 454 |
{ |
|---|
| 455 |
FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 456 |
|
|---|
| 457 |
if (fp == NULL) { |
|---|
| 458 |
websWrite(wp, "unknown"); |
|---|
| 459 |
return; |
|---|
| 460 |
} |
|---|
| 461 |
int cnt = 0; |
|---|
| 462 |
int b = 0; |
|---|
| 463 |
|
|---|
| 464 |
while (b != EOF) { |
|---|
| 465 |
b = getc(fp); |
|---|
| 466 |
if (b == ':') |
|---|
| 467 |
cnt++; |
|---|
| 468 |
if (cnt == 4) { |
|---|
| 469 |
getc(fp); |
|---|
| 470 |
char cpuclk[4]; |
|---|
| 471 |
|
|---|
| 472 |
cpuclk[0] = getc(fp); |
|---|
| 473 |
cpuclk[1] = getc(fp); |
|---|
| 474 |
cpuclk[2] = getc(fp); |
|---|
| 475 |
cpuclk[3] = 0; |
|---|
| 476 |
websWrite(wp, cpuclk); |
|---|
| 477 |
fclose(fp); |
|---|
| 478 |
return; |
|---|
| 479 |
} |
|---|
| 480 |
} |
|---|
| 481 |
|
|---|
| 482 |
fclose(fp); |
|---|
| 483 |
websWrite(wp, "unknown"); |
|---|
| 484 |
return; |
|---|
| 485 |
} |
|---|
| 486 |
#elif HAVE_ADM5120 |
|---|
| 487 |
void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 488 |
{ |
|---|
| 489 |
FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 490 |
|
|---|
| 491 |
if (fp == NULL) { |
|---|
| 492 |
websWrite(wp, "unknown"); |
|---|
| 493 |
return; |
|---|
| 494 |
} |
|---|
| 495 |
int cnt = 0; |
|---|
| 496 |
int b = 0; |
|---|
| 497 |
|
|---|
| 498 |
while (b != EOF) { |
|---|
| 499 |
b = getc(fp); |
|---|
| 500 |
if (b == ':') |
|---|
| 501 |
cnt++; |
|---|
| 502 |
if (cnt == 4) { |
|---|
| 503 |
getc(fp); |
|---|
| 504 |
char cpuclk[4]; |
|---|
| 505 |
|
|---|
| 506 |
cpuclk[0] = getc(fp); |
|---|
| 507 |
cpuclk[1] = getc(fp); |
|---|
| 508 |
cpuclk[2] = getc(fp); |
|---|
| 509 |
cpuclk[3] = 0; |
|---|
| 510 |
websWrite(wp, cpuclk); |
|---|
| 511 |
fclose(fp); |
|---|
| 512 |
return; |
|---|
| 513 |
} |
|---|
| 514 |
} |
|---|
| 515 |
|
|---|
| 516 |
fclose(fp); |
|---|
| 517 |
websWrite(wp, "unknown"); |
|---|
| 518 |
return; |
|---|
| 519 |
} |
|---|
| 520 |
#elif HAVE_MERAKI |
|---|
| 521 |
void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 522 |
{ |
|---|
| 523 |
FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 524 |
|
|---|
| 525 |
if (fp == NULL) { |
|---|
| 526 |
websWrite(wp, "unknown"); |
|---|
| 527 |
return; |
|---|
| 528 |
} |
|---|
| 529 |
int cnt = 0; |
|---|
| 530 |
int b = 0; |
|---|
| 531 |
|
|---|
| 532 |
while (b != EOF) { |
|---|
| 533 |
b = getc(fp); |
|---|
| 534 |
if (b == ':') |
|---|
| 535 |
cnt++; |
|---|
| 536 |
if (cnt == 4) { |
|---|
| 537 |
getc(fp); |
|---|
| 538 |
char cpuclk[4]; |
|---|
| 539 |
|
|---|
| 540 |
cpuclk[0] = getc(fp); |
|---|
| 541 |
cpuclk[1] = getc(fp); |
|---|
| 542 |
cpuclk[2] = getc(fp); |
|---|
| 543 |
cpuclk[3] = 0; |
|---|
| 544 |
websWrite(wp, cpuclk); |
|---|
| 545 |
fclose(fp); |
|---|
| 546 |
return; |
|---|
| 547 |
} |
|---|
| 548 |
} |
|---|
| 549 |
|
|---|
| 550 |
fclose(fp); |
|---|
| 551 |
websWrite(wp, "unknown"); |
|---|
| 552 |
return; |
|---|
| 553 |
} |
|---|
| 554 |
#elif HAVE_LS2 |
|---|
| 555 |
void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 556 |
{ |
|---|
| 557 |
FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 558 |
|
|---|
| 559 |
if (fp == NULL) { |
|---|
| 560 |
websWrite(wp, "unknown"); |
|---|
| 561 |
return; |
|---|
| 562 |
} |
|---|
| 563 |
int cnt = 0; |
|---|
| 564 |
int b = 0; |
|---|
| 565 |
|
|---|
| 566 |
while (b != EOF) { |
|---|
| 567 |
b = getc(fp); |
|---|
| 568 |
if (b == ':') |
|---|
| 569 |
cnt++; |
|---|
| 570 |
if (cnt == 4) { |
|---|
| 571 |
getc(fp); |
|---|
| 572 |
char cpuclk[4]; |
|---|
| 573 |
|
|---|
| 574 |
cpuclk[0] = getc(fp); |
|---|
| 575 |
cpuclk[1] = getc(fp); |
|---|
| 576 |
cpuclk[2] = getc(fp); |
|---|
| 577 |
cpuclk[3] = 0; |
|---|
| 578 |
websWrite(wp, cpuclk); |
|---|
| 579 |
fclose(fp); |
|---|
| 580 |
return; |
|---|
| 581 |
} |
|---|
| 582 |
} |
|---|
| 583 |
|
|---|
| 584 |
fclose(fp); |
|---|
| 585 |
websWrite(wp, "unknown"); |
|---|
| 586 |
return; |
|---|
| 587 |
} |
|---|
| 588 |
#elif HAVE_LS5 |
|---|
| 589 |
void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 590 |
{ |
|---|
| 591 |
FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 592 |
|
|---|
| 593 |
if (fp == NULL) { |
|---|
| 594 |
websWrite(wp, "unknown"); |
|---|
| 595 |
return; |
|---|
| 596 |
} |
|---|
| 597 |
int cnt = 0; |
|---|
| 598 |
int b = 0; |
|---|
| 599 |
|
|---|
| 600 |
while (b != EOF) { |
|---|
| 601 |
b = getc(fp); |
|---|
| 602 |
if (b == ':') |
|---|
| 603 |
cnt++; |
|---|
| 604 |
if (cnt == 4) { |
|---|
| 605 |
getc(fp); |
|---|
| 606 |
char cpuclk[4]; |
|---|
| 607 |
|
|---|
| 608 |
cpuclk[0] = getc(fp); |
|---|
| 609 |
cpuclk[1] = getc(fp); |
|---|
| 610 |
cpuclk[2] = getc(fp); |
|---|
| 611 |
cpuclk[3] = 0; |
|---|
| 612 |
websWrite(wp, cpuclk); |
|---|
| 613 |
fclose(fp); |
|---|
| 614 |
return; |
|---|
| 615 |
} |
|---|
| 616 |
} |
|---|
| 617 |
|
|---|
| 618 |
fclose(fp); |
|---|
| 619 |
websWrite(wp, "unknown"); |
|---|
| 620 |
return; |
|---|
| 621 |
} |
|---|
| 622 |
#elif HAVE_WHRAG108 |
|---|
| 623 |
void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 624 |
{ |
|---|
| 625 |
FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 626 |
|
|---|
| 627 |
if (fp == NULL) { |
|---|
| 628 |
websWrite(wp, "unknown"); |
|---|
| 629 |
return; |
|---|
| 630 |
} |
|---|
| 631 |
int cnt = 0; |
|---|
| 632 |
int b = 0; |
|---|
| 633 |
|
|---|
| 634 |
while (b != EOF) { |
|---|
| 635 |
b = getc(fp); |
|---|
| 636 |
if (b == ':') |
|---|
| 637 |
cnt++; |
|---|
| 638 |
if (cnt == 4) { |
|---|
| 639 |
getc(fp); |
|---|
| 640 |
char cpuclk[4]; |
|---|
| 641 |
|
|---|
| 642 |
cpuclk[0] = getc(fp); |
|---|
| 643 |
cpuclk[1] = getc(fp); |
|---|
| 644 |
cpuclk[2] = getc(fp); |
|---|
| 645 |
cpuclk[3] = 0; |
|---|
| 646 |
websWrite(wp, cpuclk); |
|---|
| 647 |
fclose(fp); |
|---|
| 648 |
return; |
|---|
| 649 |
} |
|---|
| 650 |
} |
|---|
| 651 |
|
|---|
| 652 |
fclose(fp); |
|---|
| 653 |
websWrite(wp, "unknown"); |
|---|
| 654 |
return; |
|---|
| 655 |
} |
|---|
| 656 |
#elif defined(HAVE_PB42) || defined(HAVE_LSX) || defined(HAVE_DANUBE) |
|---|
| 657 |
void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 658 |
{ |
|---|
| 659 |
FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 660 |
|
|---|
| 661 |
if (fp == NULL) { |
|---|
| 662 |
websWrite(wp, "unknown"); |
|---|
| 663 |
return; |
|---|
| 664 |
} |
|---|
| 665 |
int cnt = 0; |
|---|
| 666 |
int b = 0; |
|---|
| 667 |
|
|---|
| 668 |
while (b != EOF) { |
|---|
| 669 |
b = getc(fp); |
|---|
| 670 |
if (b == ':') |
|---|
| 671 |
cnt++; |
|---|
| 672 |
if (cnt == 6) { |
|---|
| 673 |
getc(fp); |
|---|
| 674 |
char cpuclk[4]; |
|---|
| 675 |
|
|---|
| 676 |
cpuclk[0] = getc(fp); |
|---|
| 677 |
cpuclk[1] = getc(fp); |
|---|
| 678 |
cpuclk[2] = getc(fp); |
|---|
| 679 |
cpuclk[3] = 0; |
|---|
| 680 |
websWrite(wp, cpuclk); |
|---|
| 681 |
fclose(fp); |
|---|
| 682 |
return; |
|---|
| 683 |
} |
|---|
| 684 |
} |
|---|
| 685 |
|
|---|
| 686 |
fclose(fp); |
|---|
| 687 |
websWrite(wp, "unknown"); |
|---|
| 688 |
return; |
|---|
| 689 |
} |
|---|
| 690 |
#elif HAVE_TW6600 |
|---|
| 691 |
void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 692 |
{ |
|---|
| 693 |
FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 694 |
|
|---|
| 695 |
if (fp == NULL) { |
|---|
| 696 |
websWrite(wp, "unknown"); |
|---|
| 697 |
return; |
|---|
| 698 |
} |
|---|
| 699 |
int cnt = 0; |
|---|
| 700 |
int b = 0; |
|---|
| 701 |
|
|---|
| 702 |
while (b != EOF) { |
|---|
| 703 |
b = getc(fp); |
|---|
| 704 |
if (b == ':') |
|---|
| 705 |
cnt++; |
|---|
| 706 |
if (cnt == 4) { |
|---|
| 707 |
getc(fp); |
|---|
| 708 |
char cpuclk[4]; |
|---|
| 709 |
|
|---|
| 710 |
cpuclk[0] = getc(fp); |
|---|
| 711 |
cpuclk[1] = getc(fp); |
|---|
| 712 |
cpuclk[2] = getc(fp); |
|---|
| 713 |
cpuclk[3] = 0; |
|---|
| 714 |
websWrite(wp, cpuclk); |
|---|
| 715 |
fclose(fp); |
|---|
| 716 |
return; |
|---|
| 717 |
} |
|---|
| 718 |
} |
|---|
| 719 |
|
|---|
| 720 |
fclose(fp); |
|---|
| 721 |
websWrite(wp, "unknown"); |
|---|
| 722 |
return; |
|---|
| 723 |
} |
|---|
| 724 |
#elif HAVE_CA8 |
|---|
| 725 |
void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 726 |
{ |
|---|
| 727 |
FILE *fp = fopen("/proc/cpuinfo", "rb"); |
|---|
| 728 |
|
|---|
| 729 |
if (fp == NULL) { |
|---|
| 730 |
websWrite(wp, "unknown"); |
|---|
| 731 |
return; |
|---|
| 732 |
} |
|---|
| 733 |
int cnt = 0; |
|---|
| 734 |
int b = 0; |
|---|
| 735 |
|
|---|
| 736 |
while (b != EOF) { |
|---|
| 737 |
b = getc(fp); |
|---|
| 738 |
if (b == ':') |
|---|
| 739 |
cnt++; |
|---|
| 740 |
if (cnt == 4) { |
|---|
| 741 |
getc(fp); |
|---|
| 742 |
char cpuclk[4]; |
|---|
| 743 |
|
|---|
| 744 |
cpuclk[0] = getc(fp); |
|---|
| 745 |
cpuclk[1] = getc(fp); |
|---|
| 746 |
cpuclk[2] = getc(fp); |
|---|
| 747 |
cpuclk[3] = 0; |
|---|
| 748 |
websWrite(wp, cpuclk); |
|---|
| 749 |
fclose(fp); |
|---|
| 750 |
return; |
|---|
| 751 |
} |
|---|
| 752 |
} |
|---|
| 753 |
|
|---|
| 754 |
fclose(fp); |
|---|
| 755 |
websWrite(wp, "unknown"); |
|---|
| 756 |
return; |
|---|
| 757 |
} |
|---|
| 758 |
|
|---|
| 759 |
#else |
|---|
| 760 |
|
|---|
| 761 |
void ej_get_clkfreq(webs_t wp, int argc, char_t ** argv) |
|---|
| 762 |
{ |
|---|
| 763 |
char *clk = nvram_get("clkfreq"); |
|---|
| 764 |
|
|---|
| 765 |
if (clk == NULL) { |
|---|
| 766 |
if (getcpurev() == 0) //BCM4710 |
|---|
| 767 |
websWrite(wp, "125"); |
|---|
| 768 |
else if (getcpurev() == 29) //BCM5354 |
|---|
| 769 |
websWrite(wp, "240"); |
|---|
| 770 |
else |
|---|
| 771 |
websWrite(wp, "unknown"); |
|---|
| 772 |
return; |
|---|
| 773 |
} |
|---|
| 774 |
char buf[64]; |
|---|
| 775 |
|
|---|
| 776 |
strcpy(buf, clk); |
|---|
| 777 |
int i = 0; |
|---|
| 778 |
|
|---|
| 779 |
while (buf[i++] != 0) { |
|---|
| 780 |
if (buf[i] == ',') |
|---|
| 781 |
buf[i] = 0; |
|---|
| 782 |
} |
|---|
| 783 |
websWrite(wp, buf); |
|---|
| 784 |
return; |
|---|
| 785 |
} |
|---|
| 786 |
#endif |
|---|
| 787 |
|
|---|
| 788 |
void ej_show_cpuinfo(webs_t wp, int argc, char_t ** argv) |
|---|
| 789 |
{ |
|---|
| 790 |
FILE *fcpu = fopen("/proc/cpuinfo", "r"); |
|---|
| 791 |
|
|---|
| 792 |
if (fcpu == NULL) { |
|---|
| 793 |
websWrite(wp, "Not Detected!\n"); |
|---|
| 794 |
return; |
|---|
| 795 |
} |
|---|
| 796 |
char buf[256]; |
|---|
| 797 |
int i; |
|---|
| 798 |
|
|---|
| 799 |
#ifdef HAVE_MAGICBOX |
|---|
| 800 |
int cnt = 0; |
|---|
| 801 |
#endif |
|---|
| 802 |
#ifdef HAVE_X86 |
|---|
| 803 |
int cnt = 0; |
|---|
| 804 |
#endif |
|---|
| 805 |
for (i = 0; i < 256; i++) { |
|---|
| 806 |
int c = getc(fcpu); |
|---|
| 807 |
|
|---|
| 808 |
if (c == EOF) { |
|---|
| 809 |
websWrite(wp, "Not Detected!\n"); |
|---|
| 810 |
fclose(fcpu); |
|---|
| 811 |
return; |
|---|
| 812 |
} |
|---|
| 813 |
if (c == ':') |
|---|
| 814 |
#ifdef HAVE_MAGICBOX |
|---|
| 815 |
cnt++; |
|---|
| 816 |
if (cnt == 2) |
|---|
| 817 |
break; |
|---|
| 818 |
#elif HAVE_X86 |
|---|
| 819 |
cnt++; |
|---|
| 820 |
if (cnt == 5) |
|---|
| 821 |
break; |
|---|
| 822 |
#else |
|---|
| 823 |
break; |
|---|
| 824 |
#endif |
|---|
| 825 |
} |
|---|
| 826 |
getc(fcpu); |
|---|
| 827 |
for (i = 0; i < 256; i++) { |
|---|
| 828 |
int c = getc(fcpu); |
|---|
| 829 |
|
|---|
| 830 |
if (c == EOF) { |
|---|
| 831 |
websWrite(wp, "Not Detected!\n"); |
|---|
| 832 |
fclose(fcpu); |
|---|
| 833 |
return; |
|---|
| 834 |
} |
|---|
| 835 |
if (c == 0xa || c == 0xd) |
|---|
| 836 |
break; |
|---|
| 837 |
buf[i] = c; |
|---|
| 838 |
} |
|---|
| 839 |
buf[i] = 0; |
|---|
| 840 |
websWrite(wp, buf); |
|---|
| 841 |
fclose(fcpu); |
|---|
| 842 |
return; |
|---|
| 843 |
} |
|---|
| 844 |
|
|---|
| 845 |
#define ASSOCLIST_TMP "/tmp/.wl_assoclist" |
|---|
| 846 |
#define RSSI_TMP "/tmp/.rssi" |
|---|
| 847 |
#define ASSOCLIST_CMD "wl assoclist" |
|---|
| 848 |
#define RSSI_CMD "wl rssi" |
|---|
| 849 |
#define NOISE_CMD "wl noise" |
|---|
| 850 |
|
|---|
| 851 |
void ej_show_wds_subnet(webs_t wp, int argc, char_t ** argv) |
|---|
| 852 |
{ |
|---|
| 853 |
int index = -1; |
|---|
| 854 |
char *interface; |
|---|
| 855 |
|
|---|
| 856 |
#ifdef FASTWEB |
|---|
| 857 |
ejArgs(argc, argv, "%d %s", &index, &interface); |
|---|
| 858 |
#else |
|---|
| 859 |
if (ejArgs(argc, argv, "%d %s", &index, &interface) < 2) { |
|---|
| 860 |
websError(wp, 400, "Insufficient args\n"); |
|---|
| 861 |
return; |
|---|
| 862 |
} |
|---|
| 863 |
#endif |
|---|
| 864 |
char br1[32]; |
|---|
| 865 |
|
|---|
| 866 |
sprintf(br1, "%s_br1_enable", interface); |
|---|
| 867 |
if (nvram_invmatch(br1, "1")) |
|---|
| 868 |
return; |
|---|
| 869 |
char buf[16]; |
|---|
| 870 |
|
|---|
| 871 |
sprintf(buf, "%s_wds%d_enable", interface, index); |
|---|
| 872 |
websWrite(wp, |
|---|
| 873 |
"<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"2\\\" %s >\" + wds.subnet + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 874 |
nvram_selmatch(wp, buf, |
|---|
| 875 |
"2") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 876 |
return; |
|---|
| 877 |
} |
|---|
| 878 |
|
|---|
| 879 |
#ifdef HAVE_SKYTRON |
|---|
| 880 |
void ej_active_wireless2(webs_t wp, int argc, char_t ** argv) |
|---|
| 881 |
{ |
|---|
| 882 |
int rssi = 0, noise = 0; |
|---|
| 883 |
FILE *fp, *fp2; |
|---|
| 884 |
char *mode; |
|---|
| 885 |
char mac[30]; |
|---|
| 886 |
char list[2][30]; |
|---|
| 887 |
char line[80]; |
|---|
| 888 |
|
|---|
| 889 |
unlink(ASSOCLIST_TMP); |
|---|
| 890 |
unlink(RSSI_TMP); |
|---|
| 891 |
|
|---|
| 892 |
mode = nvram_safe_get("wl_mode"); |
|---|
| 893 |
sysprintf("%s > %s", ASSOCLIST_CMD, ASSOCLIST_TMP); |
|---|
| 894 |
|
|---|
| 895 |
int connected = 0; |
|---|
| 896 |
|
|---|
| 897 |
if ((fp = fopen(ASSOCLIST_TMP, "r"))) { |
|---|
| 898 |
while (fgets(line, sizeof(line), fp) != NULL) { |
|---|
| 899 |
if (sscanf(line, "%s %s", list[0], mac) != 2) // assoclist |
|---|
| 900 |
// 00:11:22:33:44:55 |
|---|
| 901 |
continue; |
|---|
| 902 |
|
|---|
| 903 |
if (strcmp(list[0], "assoclist")) |
|---|
| 904 |
break; |
|---|
| 905 |
|
|---|
| 906 |
rssi = 0; |
|---|
| 907 |
noise = 0; |
|---|
| 908 |
// get rssi value |
|---|
| 909 |
if (strcmp(mode, "ap")) |
|---|
| 910 |
sysprintf("%s > %s", RSSI_CMD, RSSI_TMP); |
|---|
| 911 |
else |
|---|
| 912 |
sysprintf("%s \"%s\" > %s", RSSI_CMD, mac, |
|---|
| 913 |
RSSI_TMP); |
|---|
| 914 |
|
|---|
| 915 |
// get noise value if not ap mode |
|---|
| 916 |
if (strcmp(mode, "ap")) |
|---|
| 917 |
sysprintf("%s >> %s", NOISE_CMD, RSSI_TMP); |
|---|
| 918 |
|
|---|
| 919 |
fp2 = fopen(RSSI_TMP, "r"); |
|---|
| 920 |
if (fgets(line, sizeof(line), fp2) != NULL) { |
|---|
| 921 |
|
|---|
| 922 |
// get rssi |
|---|
| 923 |
if (sscanf |
|---|
| 924 |
(line, "%s %s %d", list[0], list[1], |
|---|
| 925 |
&rssi) != 3) |
|---|
| 926 |
continue; |
|---|
| 927 |
|
|---|
| 928 |
// get noise for client/wet mode |
|---|
| 929 |
if (strcmp(mode, "ap") && |
|---|
| 930 |
fgets(line, sizeof(line), fp2) != NULL && |
|---|
| 931 |
sscanf(line, "%s %s %d", list[0], list[1], |
|---|
| 932 |
&noise) != 3) |
|---|
| 933 |
continue; |
|---|
| 934 |
|
|---|
| 935 |
fclose(fp2); |
|---|
| 936 |
} |
|---|
| 937 |
if (nvram_match("maskmac", "1")) { |
|---|
| 938 |
mac[0] = 'x'; |
|---|
| 939 |
mac[1] = 'x'; |
|---|
| 940 |
mac[3] = 'x'; |
|---|
| 941 |
mac[4] = 'x'; |
|---|
| 942 |
mac[6] = 'x'; |
|---|
| 943 |
mac[7] = 'x'; |
|---|
| 944 |
mac[9] = 'x'; |
|---|
| 945 |
mac[10] = 'x'; |
|---|
| 946 |
} |
|---|
| 947 |
if (strcmp(mode, "ap") != 0) { |
|---|
| 948 |
connected = 1; |
|---|
| 949 |
websWrite(wp, "<tr>\n"); |
|---|
| 950 |
websWrite(wp, |
|---|
| 951 |
"<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\"><b>Verbindungsstatus</b></font></td>\n"); |
|---|
| 952 |
websWrite(wp, |
|---|
| 953 |
"<td bgcolor=\"#B2B2B2\"></td>\n"); |
|---|
| 954 |
websWrite(wp, |
|---|
| 955 |
"<td bgcolor=\"#FFFFFF\"></td>\n"); |
|---|
| 956 |
websWrite(wp, |
|---|
| 957 |
"<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Verbunden</font></td>\n"); |
|---|
| 958 |
websWrite(wp, "</tr>\n"); |
|---|
| 959 |
websWrite(wp, "<tr>\n"); |
|---|
| 960 |
websWrite(wp, |
|---|
| 961 |
"<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Signal</font></td>\n"); |
|---|
| 962 |
websWrite(wp, |
|---|
| 963 |
"<td bgcolor=\"#B2B2B2\"></td>\n"); |
|---|
| 964 |
websWrite(wp, |
|---|
| 965 |
"<td bgcolor=\"#FFFFFF\"></td>\n"); |
|---|
| 966 |
websWrite(wp, |
|---|
| 967 |
"<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">%d dBm</font></td>\n", |
|---|
| 968 |
rssi); |
|---|
| 969 |
websWrite(wp, "</tr>\n"); |
|---|
| 970 |
websWrite(wp, "<tr>\n"); |
|---|
| 971 |
websWrite(wp, |
|---|
| 972 |
"<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Rauschen</font></td>\n"); |
|---|
| 973 |
websWrite(wp, |
|---|
| 974 |
"<td bgcolor=\"#B2B2B2\"></td>\n"); |
|---|
| 975 |
websWrite(wp, |
|---|
| 976 |
"<td bgcolor=\"#FFFFFF\"></td>\n"); |
|---|
| 977 |
websWrite(wp, |
|---|
| 978 |
"<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">%d dBm</font></td>\n", |
|---|
| 979 |
noise); |
|---|
| 980 |
websWrite(wp, "</tr>\n"); |
|---|
| 981 |
} |
|---|
| 982 |
} |
|---|
| 983 |
fclose(fp); |
|---|
| 984 |
} |
|---|
| 985 |
|
|---|
| 986 |
unlink(ASSOCLIST_TMP); |
|---|
| 987 |
unlink(RSSI_TMP); |
|---|
| 988 |
if (!connected) { |
|---|
| 989 |
connected = 1; |
|---|
| 990 |
websWrite(wp, "<tr>\n"); |
|---|
| 991 |
websWrite(wp, |
|---|
| 992 |
"<td bgcolor=\"#B2B2B2\" valign=\"middle\" align=\"right\" width=\"200\" height=\"25\"><font face=\"Arial\" color=\"#000000\" size=\"2\"><b>Verbindungsstatus</b></font></td>\n"); |
|---|
| 993 |
websWrite(wp, "<td bgcolor=\"#B2B2B2\"></td>\n"); |
|---|
| 994 |
websWrite(wp, "<td bgcolor=\"#FFFFFF\"></td>\n"); |
|---|
| 995 |
websWrite(wp, |
|---|
| 996 |
"<td colspan=\"2\" bgcolor=\"#FFFFFF\" valign=\"middle\" align=\"left\"><font face=\"Arial\" color=\"#000000\" size=\"2\">Nicht Verbunden</font></td>\n"); |
|---|
| 997 |
websWrite(wp, "</tr>\n"); |
|---|
| 998 |
|
|---|
| 999 |
} |
|---|
| 1000 |
|
|---|
| 1001 |
return 0; |
|---|
| 1002 |
} |
|---|
| 1003 |
#endif |
|---|
| 1004 |
|
|---|
| 1005 |
void ej_show_paypal(webs_t wp, int argc, char_t ** argv) |
|---|
| 1006 |
{ |
|---|
| 1007 |
#ifdef HAVE_DDLAN |
|---|
| 1008 |
websWrite(wp, |
|---|
| 1009 |
"<a href=\"mailto:support@mcdd.de\">support@mcdd.de</a><br />"); |
|---|
| 1010 |
#endif |
|---|
| 1011 |
#ifdef HAVE_CORENET |
|---|
| 1012 |
websWrite(wp, |
|---|
| 1013 |
"<a href=\"http://www.corenetsolutions.com\">http://www.corenetsolutions.com</a><br />"); |
|---|
| 1014 |
#endif |
|---|
| 1015 |
|
|---|
| 1016 |
#ifndef CONFIG_BRANDING |
|---|
| 1017 |
websWrite(wp, "<a href=\"http://www.dd-wrt.com/\">DD-WRT</a><br />"); |
|---|
| 1018 |
websWrite(wp, |
|---|
| 1019 |
"<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\" target=\"_blank\">"); |
|---|
| 1020 |
websWrite(wp, |
|---|
| 1021 |
"<input type=\"hidden\" name=\"cmd\" value=\"_xclick\" />"); |
|---|
| 1022 |
websWrite(wp, |
|---|
| 1023 |
"<input type=\"hidden\" name=\"business\" value=\"paypal@dd-wrt.com\" />"); |
|---|
| 1024 |
websWrite(wp, |
|---|
| 1025 |
"<input type=\"hidden\" name=\"item_name\" value=\"DD-WRT Development Support\" />"); |
|---|
| 1026 |
websWrite(wp, "<input type=\"hidden\" name=\"no_note\" value=\"1\" />"); |
|---|
| 1027 |
websWrite(wp, |
|---|
| 1028 |
"<input type=\"hidden\" name=\"currency_code\" value=\"EUR\" />"); |
|---|
| 1029 |
websWrite(wp, "<input type=\"hidden\" name=\"lc\" value=\"en\" />"); |
|---|
| 1030 |
websWrite(wp, "<input type=\"hidden\" name=\"tax\" value=\"0\" />"); |
|---|
| 1031 |
websWrite(wp, |
|---|
| 1032 |
"<input type=\"image\" src=\"images/paypal.gif\" name=\"submit\" />"); |
|---|
| 1033 |
websWrite(wp, "</form>"); |
|---|
| 1034 |
websWrite(wp, |
|---|
| 1035 |
"<br /><script type=\"text/javascript\">Capture(donate.mb)</script><br />\n"); |
|---|
| 1036 |
websWrite(wp, |
|---|
| 1037 |
"<a href=\"https://www.moneybookers.com/app/send.pl\" target=\"_blank\">\n"); |
|---|
| 1038 |
// #ifdef HAVE_MICRO |
|---|
| 1039 |
// websWrite (wp, |
|---|
| 1040 |
// "<img style=\"border-width: 1px; border-color: #8B8583;\" |
|---|
| 1041 |
// src=\"http://www.moneybookers.com/images/banners/88_en_interpayments.gif\" |
|---|
| 1042 |
// alt=\"donate thru moneybookers\" />\n"); |
|---|
| 1043 |
// #else |
|---|
| 1044 |
websWrite(wp, |
|---|
| 1045 |
"<img style=\"border-width: 1px; border-color: #8B8583;\" src=\"images/88_en_interpayments.png\" alt=\"donate thru interpayments\" />\n"); |
|---|
| 1046 |
// #endif |
|---|
| 1047 |
websWrite(wp, "</a>\n"); |
|---|
| 1048 |
#endif |
|---|
| 1049 |
return; |
|---|
| 1050 |
} |
|---|
| 1051 |
|
|---|
| 1052 |
#ifdef HAVE_RADLOCAL |
|---|
| 1053 |
|
|---|
| 1054 |
void ej_show_iradius_check(webs_t wp, int argc, char_t ** argv) |
|---|
| 1055 |
{ |
|---|
| 1056 |
char *sln = nvram_safe_get("iradius_count"); |
|---|
| 1057 |
|
|---|
| 1058 |
if (sln == NULL || strlen(sln) == 0) |
|---|
| 1059 |
return; |
|---|
| 1060 |
int leasenum = atoi(sln); |
|---|
| 1061 |
int i; |
|---|
| 1062 |
|
|---|
| 1063 |
for (i = 0; i < leasenum; i++) { |
|---|
| 1064 |
websWrite(wp, "if(F._iradius%d_active)\n", i); |
|---|
| 1065 |
websWrite(wp, "if(F._iradius%d_active.checked == true)\n", i); |
|---|
| 1066 |
websWrite(wp, "F.iradius%d_active.value=1\n", i); |
|---|
| 1067 |
websWrite(wp, "else\n"); |
|---|
| 1068 |
websWrite(wp, "F.iradius%d_active.value=0\n", i); |
|---|
| 1069 |
|
|---|
| 1070 |
websWrite(wp, "if(F._iradius%d_delete)\n", i); |
|---|
| 1071 |
websWrite(wp, "if(F._iradius%d_delete.checked == true)\n", i); |
|---|
| 1072 |
websWrite(wp, "F.iradius%d_delete.value=1\n", i); |
|---|
| 1073 |
websWrite(wp, "else\n"); |
|---|
| 1074 |
websWrite(wp, "F.iradius%d_delete.value=0\n", i); |
|---|
| 1075 |
} |
|---|
| 1076 |
|
|---|
| 1077 |
} |
|---|
| 1078 |
|
|---|
| 1079 |
void ej_show_iradius(webs_t wp, int argc, char_t ** argv) |
|---|
| 1080 |
{ |
|---|
| 1081 |
char *sln = nvram_safe_get("iradius_count"); |
|---|
| 1082 |
|
|---|
| 1083 |
if (sln == NULL || strlen(sln) == 0) |
|---|
| 1084 |
return; |
|---|
| 1085 |
int leasenum = atoi(sln); |
|---|
| 1086 |
|
|---|
| 1087 |
if (leasenum == 0) |
|---|
| 1088 |
return; |
|---|
| 1089 |
int i; |
|---|
| 1090 |
char username[32]; |
|---|
| 1091 |
char *o, *userlist; |
|---|
| 1092 |
|
|---|
| 1093 |
cprintf("get collection\n"); |
|---|
| 1094 |
char *u = nvram_get_collection("iradius"); |
|---|
| 1095 |
|
|---|
| 1096 |
cprintf("collection result %s", u); |
|---|
| 1097 |
if (u != NULL) { |
|---|
| 1098 |
userlist = (char *)malloc(strlen(u) + 1); |
|---|
| 1099 |
strcpy(userlist, u); |
|---|
| 1100 |
free(u); |
|---|
| 1101 |
o = userlist; |
|---|
| 1102 |
} else { |
|---|
| 1103 |
userlist = NULL; |
|---|
| 1104 |
o = NULL; |
|---|
| 1105 |
} |
|---|
| 1106 |
cprintf("display = chain\n"); |
|---|
| 1107 |
struct timeval now; |
|---|
| 1108 |
|
|---|
| 1109 |
gettimeofday(&now, NULL); |
|---|
| 1110 |
for (i = 0; i < leasenum; i++) { |
|---|
| 1111 |
snprintf(username, 31, "iradius%d_name", i); |
|---|
| 1112 |
char *sep = NULL; |
|---|
| 1113 |
|
|---|
| 1114 |
if (userlist) |
|---|
| 1115 |
sep = strsep(&userlist, " "); |
|---|
| 1116 |
websWrite(wp, "<tr><td>\n"); |
|---|
| 1117 |
websWrite(wp, "<input name=\"%s\" type=\"hidden\" />", |
|---|
| 1118 |
username); |
|---|
| 1119 |
websWrite(wp, |
|---|
| 1120 |
"<input name=\"%s\" value=\"%s\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 1121 |
username, sep != NULL ? sep : ""); |
|---|
| 1122 |
websWrite(wp, "</td>\n"); |
|---|
| 1123 |
if (userlist) |
|---|
| 1124 |
sep = strsep(&userlist, " "); |
|---|
| 1125 |
|
|---|
| 1126 |
char active[32]; |
|---|
| 1127 |
|
|---|
| 1128 |
snprintf(active, 31, "iradius%d_active", i); |
|---|
| 1129 |
|
|---|
| 1130 |
websWrite(wp, "<td>\n"); |
|---|
| 1131 |
websWrite(wp, "<input name=\"%s\" type=\"hidden\" />", active); |
|---|
| 1132 |
websWrite(wp, |
|---|
| 1133 |
"<input type=\"checkbox\" value=\"%s\" name=\"_%s\" %s />\n", |
|---|
| 1134 |
sep, active, sep != NULL ? strcmp(sep, |
|---|
| 1135 |
"1") == |
|---|
| 1136 |
0 ? "checked=\"checked\"" : "" : ""); |
|---|
| 1137 |
websWrite(wp, "</td>\n"); |
|---|
| 1138 |
websWrite(wp, "<td>\n"); |
|---|
| 1139 |
if (userlist) |
|---|
| 1140 |
sep = strsep(&userlist, " "); |
|---|
| 1141 |
long t = atol(sep); |
|---|
| 1142 |
|
|---|
| 1143 |
if (t != -1) { |
|---|
| 1144 |
t -= now.tv_sec; |
|---|
| 1145 |
t /= 60; |
|---|
| 1146 |
} |
|---|
| 1147 |
|
|---|
| 1148 |
snprintf(active, 31, "iradius%d_lease", i); |
|---|
| 1149 |
char st[32]; |
|---|
| 1150 |
|
|---|
| 1151 |
if (t >= 0) |
|---|
| 1152 |
sprintf(st, "%d", t); |
|---|
| 1153 |
else |
|---|
| 1154 |
sprintf(st, "over"); |
|---|
| 1155 |
websWrite(wp, "<input type=\"num\" name=\"%s\" value='%s' />\n", |
|---|
| 1156 |
active, st); |
|---|
| 1157 |
websWrite(wp, "</td>\n"); |
|---|
| 1158 |
|
|---|
| 1159 |
websWrite(wp, "<td>\n"); |
|---|
| 1160 |
snprintf(active, 31, "iradius%d_delete", i); |
|---|
| 1161 |
websWrite(wp, "<input name=\"%s\" type=\"hidden\" />", active); |
|---|
| 1162 |
websWrite(wp, "<input type=\"checkbox\" name=\"_%s\"/>\n", |
|---|
| 1163 |
active); |
|---|
| 1164 |
websWrite(wp, "</td></tr>\n"); |
|---|
| 1165 |
} |
|---|
| 1166 |
if (o != NULL) |
|---|
| 1167 |
free(o); |
|---|
| 1168 |
return; |
|---|
| 1169 |
} |
|---|
| 1170 |
|
|---|
| 1171 |
#endif |
|---|
| 1172 |
|
|---|
| 1173 |
#ifdef HAVE_CHILLILOCAL |
|---|
| 1174 |
|
|---|
| 1175 |
void ej_show_userlist(webs_t wp, int argc, char_t ** argv) |
|---|
| 1176 |
{ |
|---|
| 1177 |
char *sln = nvram_safe_get("fon_usernames"); |
|---|
| 1178 |
|
|---|
| 1179 |
if (sln == NULL || strlen(sln) == 0) |
|---|
| 1180 |
return; |
|---|
| 1181 |
int leasenum = atoi(sln); |
|---|
| 1182 |
|
|---|
| 1183 |
if (leasenum == 0) |
|---|
| 1184 |
return; |
|---|
| 1185 |
int i; |
|---|
| 1186 |
char username[32]; |
|---|
| 1187 |
char password[32]; |
|---|
| 1188 |
char *u = nvram_safe_get("fon_userlist"); |
|---|
| 1189 |
char *userlist = (char *)malloc(strlen(u) + 1); |
|---|
| 1190 |
|
|---|
| 1191 |
strcpy(userlist, u); |
|---|
| 1192 |
char *o = userlist; |
|---|
| 1193 |
|
|---|
| 1194 |
for (i = 0; i < leasenum; i++) { |
|---|
| 1195 |
snprintf(username, 31, "fon_user%d_name", i); |
|---|
| 1196 |
char *sep = strsep(&userlist, "="); |
|---|
| 1197 |
|
|---|
| 1198 |
websWrite(wp, "<tr><td>\n"); |
|---|
| 1199 |
websWrite(wp, |
|---|
| 1200 |
"<input name=\"%s\" value=\"%s\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 1201 |
username, sep != NULL ? sep : ""); |
|---|
| 1202 |
websWrite(wp, "</td>\n"); |
|---|
| 1203 |
sep = strsep(&userlist, " "); |
|---|
| 1204 |
snprintf(password, 31, "fon_user%d_password", i); |
|---|
| 1205 |
websWrite(wp, "<td>\n"); |
|---|
| 1206 |
websWrite(wp, |
|---|
| 1207 |
"<input type=\"password\" name=\"%s\" value=\"blahblahblah\" size=\"25\" maxlength=\"63\" />\n", |
|---|
| 1208 |
password); |
|---|
| 1209 |
websWrite(wp, "</td></tr>\n"); |
|---|
| 1210 |
} |
|---|
| 1211 |
free(o); |
|---|
| 1212 |
return; |
|---|
| 1213 |
} |
|---|
| 1214 |
|
|---|
| 1215 |
#endif |
|---|
| 1216 |
|
|---|
| 1217 |
void ej_show_staticleases(webs_t wp, int argc, char_t ** argv) |
|---|
| 1218 |
{ |
|---|
| 1219 |
int i; |
|---|
| 1220 |
|
|---|
| 1221 |
// cprintf("get static leasenum"); |
|---|
| 1222 |
|
|---|
| 1223 |
char *sln = nvram_safe_get("static_leasenum"); |
|---|
| 1224 |
|
|---|
| 1225 |
// cprintf("check null"); |
|---|
| 1226 |
if (sln == NULL || strlen(sln) == 0) |
|---|
| 1227 |
return; |
|---|
| 1228 |
// cprintf("atoi"); |
|---|
| 1229 |
|
|---|
| 1230 |
int leasenum = atoi(sln); |
|---|
| 1231 |
|
|---|
| 1232 |
// cprintf("leasenum==0"); |
|---|
| 1233 |
if (leasenum == 0) |
|---|
| 1234 |
return; |
|---|
| 1235 |
// cprintf("get leases"); |
|---|
| 1236 |
char *nvleases = nvram_safe_get("static_leases"); |
|---|
| 1237 |
char *leases = (char *)malloc(strlen(nvleases) + 1); |
|---|
| 1238 |
char *originalpointer = leases; // strsep destroys the pointer by |
|---|
| 1239 |
|
|---|
| 1240 |
// moving it |
|---|
| 1241 |
strcpy(leases, nvleases); |
|---|
| 1242 |
for (i = 0; i < leasenum; i++) { |
|---|
| 1243 |
char *sep = strsep(&leases, "="); |
|---|
| 1244 |
|
|---|
| 1245 |
websWrite(wp, |
|---|
| 1246 |
"<tr><td><input name=\"lease%d_hwaddr\" value=\"%s\" size=\"18\" maxlength=\"18\" onblur=\"valid_name(this,share.mac,SPACE_NO)\" /></td>", |
|---|
| 1247 |
i, sep != NULL ? sep : ""); |
|---|
| 1248 |
sep = strsep(&leases, "="); |
|---|
| 1249 |
websWrite(wp, |
|---|
| 1250 |
"<td><input name=\"lease%d_hostname\" value=\"%s\" size=\"24\" maxlength=\"24\" onblur=\"valid_name(this,share.hostname,SPACE_NO)\" /></td>", |
|---|
| 1251 |
i, sep != NULL ? sep : ""); |
|---|
| 1252 |
sep = strsep(&leases, " "); |
|---|
| 1253 |
websWrite(wp, |
|---|
| 1254 |
"<td><input name=\"lease%d_ip\" value=\"%s\" size=\"15\" maxlength=\"15\" class=\"num\" onblur=\"valid_name(this,share.ip,SPACE_NO)\" /></td></tr>\n", |
|---|
| 1255 |
i, sep != NULL ? sep : ""); |
|---|
| 1256 |
} |
|---|
| 1257 |
free(originalpointer); |
|---|
| 1258 |
return; |
|---|
| 1259 |
} |
|---|
| 1260 |
|
|---|
| 1261 |
void ej_show_control(webs_t wp, int argc, char_t ** argv) |
|---|
| 1262 |
{ |
|---|
| 1263 |
#ifdef CONFIG_BRANDING |
|---|
| 1264 |
websWrite(wp, "Control Panel"); |
|---|
| 1265 |
#else |
|---|
| 1266 |
websWrite(wp, "DD-WRT Control Panel"); |
|---|
| 1267 |
#endif |
|---|
| 1268 |
return; |
|---|
| 1269 |
} |
|---|
| 1270 |
|
|---|
| 1271 |
#ifndef HAVE_AQOS |
|---|
| 1272 |
void ej_show_default_level(webs_t wp, int argc, char_t ** argv) |
|---|
| 1273 |
{ |
|---|
| 1274 |
return; |
|---|
| 1275 |
} |
|---|
| 1276 |
|
|---|
| 1277 |
#else |
|---|
| 1278 |
void ej_show_default_level(webs_t wp, int argc, char_t ** argv) |
|---|
| 1279 |
{ |
|---|
| 1280 |
websWrite(wp, "<fieldset>\n"); |
|---|
| 1281 |
websWrite(wp, |
|---|
| 1282 |
"<legend><script type=\"text/javascript\">Capture(qos.legend6)</script></legend>\n"); |
|---|
| 1283 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1284 |
websWrite(wp, |
|---|
| 1285 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(qos.bandwidth)</script> Up</div>\n"); |
|---|
| 1286 |
websWrite(wp, |
|---|
| 1287 |
"<input type=\"num\" name=\"default_uplevel\" size=\"6\" value=\"%s\" /> Down\n", |
|---|
| 1288 |
nvram_safe_get("default_uplevel")); |
|---|
| 1289 |
websWrite(wp, |
|---|
| 1290 |
"<input type=\"num\" name=\"default_downlevel\" size=\"6\" value=\"%s\" />\n", |
|---|
| 1291 |
nvram_safe_get("default_downlevel")); |
|---|
| 1292 |
websWrite(wp, "</div>\n"); |
|---|
| 1293 |
websWrite(wp, "</fieldset><br />\n"); |
|---|
| 1294 |
return; |
|---|
| 1295 |
} |
|---|
| 1296 |
#endif |
|---|
| 1297 |
|
|---|
| 1298 |
#ifdef HAVE_MADWIFI |
|---|
| 1299 |
struct wifi_channels { |
|---|
| 1300 |
int channel; |
|---|
| 1301 |
int freq; |
|---|
| 1302 |
int noise; |
|---|
| 1303 |
}; |
|---|
| 1304 |
extern struct wifi_channels *list_channels(char *devnr); |
|---|
| 1305 |
|
|---|
| 1306 |
// extern int getchannelcount (void); |
|---|
| 1307 |
extern int getdevicecount(void); |
|---|
| 1308 |
#endif |
|---|
| 1309 |
|
|---|
| 1310 |
static char *selmatch(char *var, char *is, char *ret) |
|---|
| 1311 |
{ |
|---|
| 1312 |
if (nvram_match(var, is)) |
|---|
| 1313 |
return ret; |
|---|
| 1314 |
return ""; |
|---|
| 1315 |
} |
|---|
| 1316 |
|
|---|
| 1317 |
static void |
|---|
| 1318 |
show_security_prefix(webs_t wp, int argc, char_t ** argv, char *prefix, |
|---|
| 1319 |
int primary) |
|---|
| 1320 |
{ |
|---|
| 1321 |
static char var[80]; |
|---|
| 1322 |
static char sta[80]; |
|---|
| 1323 |
|
|---|
| 1324 |
// char p2[80]; |
|---|
| 1325 |
cprintf("show security prefix\n"); |
|---|
| 1326 |
sprintf(var, "%s_security_mode", prefix); |
|---|
| 1327 |
// strcpy(p2,prefix); |
|---|
| 1328 |
// rep(p2,'X','.'); |
|---|
| 1329 |
// websWrite (wp, "<input type=\"hidden\" |
|---|
| 1330 |
// name=\"%s_security_mode\"/>\n",p2); |
|---|
| 1331 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1332 |
websWrite(wp, |
|---|
| 1333 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(wpa.secmode)</script></div>\n"); |
|---|
| 1334 |
websWrite(wp, |
|---|
| 1335 |
"<select name=\"%s_security_mode\" onchange=\"SelMode('%s_security_mode',this.form.%s_security_mode.selectedIndex,this.form)\">\n", |
|---|
| 1336 |
prefix, prefix, prefix); |
|---|
| 1337 |
websWrite(wp, |
|---|
| 1338 |
"<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<option value=\\\"disabled\\\" %s >\" + share.disabled + \"</option>\");\n//]]>\n</script>\n", |
|---|
| 1339 |
selmatch(var, "disabled", "selected=\\\"selected\\\"")); |
|---|
| 1340 |
websWrite(wp, "<option value=\"psk\" %s>WPA Personal</option>\n", |
|---|
| 1341 |
selmatch(var, "psk", "selected=\"selected\"")); |
|---|
| 1342 |
sprintf(sta, "%s_mode", prefix); |
|---|
| 1343 |
if (!primary || nvram_match(sta, "ap") || nvram_match(sta, "wdsap")) { |
|---|
| 1344 |
websWrite(wp, |
|---|
| 1345 |
"<option value=\"wpa\" %s>WPA Enterprise</option>\n", |
|---|
| 1346 |
selmatch(var, "wpa", "selected=\"selected\"")); |
|---|
| 1347 |
} |
|---|
| 1348 |
websWrite(wp, "<option value=\"psk2\" %s>WPA2 Personal</option>\n", |
|---|
| 1349 |
selmatch(var, "psk2", "selected=\"selected\"")); |
|---|
| 1350 |
if (!primary || nvram_match(sta, "ap") || nvram_match(sta, "wdsap")) { |
|---|
| 1351 |
websWrite(wp, |
|---|
| 1352 |
"<option value=\"wpa2\" %s>WPA2 Enterprise</option>\n", |
|---|
| 1353 |
selmatch(var, "wpa2", "selected=\"selected\"")); |
|---|
| 1354 |
} |
|---|
| 1355 |
#ifdef HAVE_RT2880 |
|---|
| 1356 |
if (!primary || nvram_match(sta, "ap")) |
|---|
| 1357 |
#endif |
|---|
| 1358 |
websWrite(wp, |
|---|
| 1359 |
"<option value=\"psk psk2\" %s>WPA2 Personal Mixed</option>\n", |
|---|
| 1360 |
selmatch(var, "psk psk2", "selected=\"selected\"")); |
|---|
| 1361 |
|
|---|
| 1362 |
if (!primary || nvram_match(sta, "ap") || nvram_match(sta, "wdsap")) { |
|---|
| 1363 |
websWrite(wp, |
|---|
| 1364 |
"<option value=\"wpa wpa2\" %s>WPA2 Enterprise Mixed</option>\n", |
|---|
| 1365 |
selmatch(var, "wpa wpa2", "selected=\"selected\"")); |
|---|
| 1366 |
|
|---|
| 1367 |
websWrite(wp, "<option value=\"radius\" %s>RADIUS</option>\n", |
|---|
| 1368 |
selmatch(var, "radius", "selected=\"selected\"")); |
|---|
| 1369 |
} |
|---|
| 1370 |
|
|---|
| 1371 |
websWrite(wp, "<option value=\"wep\" %s>WEP</option>\n", |
|---|
| 1372 |
selmatch(var, "wep", "selected=\"selected\"")); |
|---|
| 1373 |
#ifdef HAVE_WPA_SUPPLICANT |
|---|
| 1374 |
#ifndef HAVE_MICRO |
|---|
| 1375 |
#ifndef HAVE_RT2880 |
|---|
| 1376 |
if (!primary || nvram_match(sta, "sta") || nvram_match(sta, "wdssta") |
|---|
| 1377 |
|| nvram_match(sta, "apsta") || nvram_match(sta, "wet")) { |
|---|
| 1378 |
websWrite(wp, "<option value=\"8021X\" %s>802.1x</option>\n", |
|---|
| 1379 |
selmatch(var, "8021X", "selected=\"selected\"")); |
|---|
| 1380 |
} |
|---|
| 1381 |
#else |
|---|
| 1382 |
if (nvram_match(sta, "sta") || nvram_match(sta, "wet")) { |
|---|
| 1383 |
websWrite(wp, "<option value=\"8021X\" %s>802.1x</option>\n", |
|---|
| 1384 |
selmatch(var, "8021X", "selected=\"selected\"")); |
|---|
| 1385 |
} |
|---|
| 1386 |
#endif |
|---|
| 1387 |
#endif |
|---|
| 1388 |
#endif |
|---|
| 1389 |
|
|---|
| 1390 |
websWrite(wp, "</select></div>\n"); |
|---|
| 1391 |
rep(prefix, 'X', '.'); |
|---|
| 1392 |
cprintf("ej show wpa\n"); |
|---|
| 1393 |
ej_show_wpa_setting(wp, argc, argv, prefix); |
|---|
| 1394 |
|
|---|
| 1395 |
} |
|---|
| 1396 |
|
|---|
| 1397 |
static void |
|---|
| 1398 |
ej_show_security_single(webs_t wp, int argc, char_t ** argv, char *prefix) |
|---|
| 1399 |
{ |
|---|
| 1400 |
char *next; |
|---|
| 1401 |
char var[80]; |
|---|
| 1402 |
char ssid[80]; |
|---|
| 1403 |
char mac[16]; |
|---|
| 1404 |
|
|---|
| 1405 |
sprintf(mac, "%s_hwaddr", prefix); |
|---|
| 1406 |
char *vifs = nvram_nget("%s_vifs", prefix); |
|---|
| 1407 |
|
|---|
| 1408 |
if (vifs == NULL) |
|---|
| 1409 |
return; |
|---|
| 1410 |
sprintf(ssid, "%s_ssid", prefix); |
|---|
| 1411 |
websWrite(wp, |
|---|
| 1412 |
"<h2><script type=\"text/javascript\">Capture(wpa.h2)</script> %s</h2>\n", |
|---|
| 1413 |
prefix); |
|---|
| 1414 |
websWrite(wp, "<fieldset>\n"); |
|---|
| 1415 |
// cprintf("getting %s %s\n",ssid,nvram_safe_get(ssid)); |
|---|
| 1416 |
websWrite(wp, |
|---|
| 1417 |
"<legend><script type=\"text/javascript\">Capture(share.pintrface)</script> %s SSID [", |
|---|
| 1418 |
IFMAP(prefix)); |
|---|
| 1419 |
tf_webWriteESCNV(wp, ssid); // fix for broken html page if ssid |
|---|
| 1420 |
// contains html tag |
|---|
| 1421 |
websWrite(wp, "] HWAddr [%s]</legend>\n", nvram_safe_get(mac)); |
|---|
| 1422 |
show_security_prefix(wp, argc, argv, prefix, 1); |
|---|
| 1423 |
websWrite(wp, "</fieldset>\n<br />\n"); |
|---|
| 1424 |
foreach(var, vifs, next) { |
|---|
| 1425 |
sprintf(ssid, "%s_ssid", var); |
|---|
| 1426 |
websWrite(wp, "<fieldset>\n"); |
|---|
| 1427 |
// cprintf("getting %s %s\n", ssid,nvram_safe_get(ssid)); |
|---|
| 1428 |
websWrite(wp, |
|---|
| 1429 |
"<legend><script type=\"text/javascript\">Capture(share.vintrface)</script> %s SSID [", |
|---|
| 1430 |
IFMAP(var)); |
|---|
| 1431 |
tf_webWriteESCNV(wp, ssid); // fix for broken html page if ssid |
|---|
| 1432 |
// contains html tag |
|---|
| 1433 |
websWrite(wp, "]</legend>\n"); |
|---|
| 1434 |
rep(var, '.', 'X'); |
|---|
| 1435 |
show_security_prefix(wp, argc, argv, var, 0); |
|---|
| 1436 |
websWrite(wp, "</fieldset>\n<br />\n"); |
|---|
| 1437 |
} |
|---|
| 1438 |
|
|---|
| 1439 |
} |
|---|
| 1440 |
|
|---|
| 1441 |
void ej_show_security(webs_t wp, int argc, char_t ** argv) |
|---|
| 1442 |
{ |
|---|
| 1443 |
#ifndef HAVE_MADWIFI |
|---|
| 1444 |
int c = get_wl_instances(); |
|---|
| 1445 |
int i; |
|---|
| 1446 |
|
|---|
| 1447 |
for (i = 0; i < c; i++) { |
|---|
| 1448 |
char buf[16]; |
|---|
| 1449 |
|
|---|
| 1450 |
sprintf(buf, "wl%d", i); |
|---|
| 1451 |
ej_show_security_single(wp, argc, argv, buf); |
|---|
| 1452 |
} |
|---|
| 1453 |
return; |
|---|
| 1454 |
#else |
|---|
| 1455 |
int c = getdevicecount(); |
|---|
| 1456 |
int i; |
|---|
| 1457 |
|
|---|
| 1458 |
for (i = 0; i < c; i++) { |
|---|
| 1459 |
char buf[16]; |
|---|
| 1460 |
|
|---|
| 1461 |
sprintf(buf, "ath%d", i); |
|---|
| 1462 |
ej_show_security_single(wp, argc, argv, buf); |
|---|
| 1463 |
} |
|---|
| 1464 |
return; |
|---|
| 1465 |
#endif |
|---|
| 1466 |
} |
|---|
| 1467 |
|
|---|
| 1468 |
void ej_show_dhcpd_settings(webs_t wp, int argc, char_t ** argv) |
|---|
| 1469 |
{ |
|---|
| 1470 |
int i; |
|---|
| 1471 |
|
|---|
| 1472 |
if (getWET()) // dhcpd settings disabled in client bridge mode, so we wont display it |
|---|
| 1473 |
return; |
|---|
| 1474 |
|
|---|
| 1475 |
websWrite(wp, |
|---|
| 1476 |
"<fieldset><legend><script type=\"text/javascript\">Capture(idx.dhcp_legend)</script></legend>\n"); |
|---|
| 1477 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1478 |
websWrite(wp, |
|---|
| 1479 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_type)</script></div>\n"); |
|---|
| 1480 |
websWrite(wp, |
|---|
| 1481 |
"<select class=\"num\" size=\"1\" name=\"dhcpfwd_enable\" onchange=SelDHCPFWD(this.form.dhcpfwd_enable.selectedIndex,this.form)>\n"); |
|---|
| 1482 |
websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1483 |
websWrite(wp, |
|---|
| 1484 |
"document.write(\"<option value=\\\"0\\\" %s >\" + idx.dhcp_srv + \"</option>\");\n", |
|---|
| 1485 |
nvram_match("dhcpfwd_enable", |
|---|
| 1486 |
"0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1487 |
websWrite(wp, |
|---|
| 1488 |
"document.write(\"<option value=\\\"1\\\" %s >\" + idx.dhcp_fwd + \"</option>\");\n", |
|---|
| 1489 |
nvram_match("dhcpfwd_enable", |
|---|
| 1490 |
"1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1491 |
websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 1492 |
websWrite(wp, "</select>\n"); |
|---|
| 1493 |
websWrite(wp, "</div>\n"); |
|---|
| 1494 |
if (nvram_match("dhcpfwd_enable", "1")) { |
|---|
| 1495 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1496 |
websWrite(wp, |
|---|
| 1497 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_srv)</script></div>\n"); |
|---|
| 1498 |
char *ipfwd = nvram_safe_get("dhcpfwd_ip"); |
|---|
| 1499 |
|
|---|
| 1500 |
websWrite(wp, |
|---|
| 1501 |
"<input type=\"hidden\" name=\"dhcpfwd_ip\" value=\"4\" /><input class=\"num\" maxlength=\"3\" size=\"3\" name=\"dhcpfwd_ip_0\" onblur=\"valid_range(this,0,255,idx.dhcp_srv)\" value=\"%d\" />.<input class=\"num\" maxlength=\"3\" size=\"3\" name=\"dhcpfwd_ip_1\" onblur=\"valid_range(this,0,255,idx.dhcp_srv)\" value=\"%d\" />.<input class=\"num\" maxlength=\"3\" name=\"dhcpfwd_ip_2\" size=\"3\" onblur=\"valid_range(this,0,255,idx.dhcp_srv)\" value=\"%d\" />.<input class=\"num\" maxlength=\"3\" name=\"dhcpfwd_ip_3\" size=\"3\" onblur=\"valid_range(this,0,254,idx.dhcp_srv)\" value=\"%d\"\" /></div>\n", |
|---|
| 1502 |
get_single_ip(ipfwd, 0), get_single_ip(ipfwd, 1), |
|---|
| 1503 |
get_single_ip(ipfwd, 2), get_single_ip(ipfwd, 3)); |
|---|
| 1504 |
} else { |
|---|
| 1505 |
char buf[20]; |
|---|
| 1506 |
|
|---|
| 1507 |
prefix_ip_get("lan_ipaddr", buf, 1); |
|---|
| 1508 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1509 |
// char *nv = nvram_safe_get ("wan_wins"); |
|---|
| 1510 |
websWrite(wp, |
|---|
| 1511 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_srv)</script></div><input class=\"spaceradio\" type=\"radio\" name=\"lan_proto\" value=\"dhcp\" onclick=SelDHCP('dhcp',this.form) %s /><script type=\"text/javascript\">Capture(share.enable)</script> \n", |
|---|
| 1512 |
nvram_match("lan_proto", |
|---|
| 1513 |
"dhcp") ? "checked=\"checked\"" : ""); |
|---|
| 1514 |
websWrite(wp, |
|---|
| 1515 |
"<input class=\"spaceradio\" type=\"radio\" name=\"lan_proto\" value=\"static\" onclick=\"SelDHCP('static',this.form)\" %s /><script type=\"text/javascript\">Capture(share.disable)</script></div><input type=\"hidden\" name=\"dhcp_check\" /><div class=\"setting\">\n", |
|---|
| 1516 |
nvram_match("lan_proto", |
|---|
| 1517 |
"static") ? "checked=\"checked\"" : ""); |
|---|
| 1518 |
websWrite(wp, |
|---|
| 1519 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_start)</script></div>%s", |
|---|
| 1520 |
buf); |
|---|
| 1521 |
websWrite(wp, |
|---|
| 1522 |
"<input class=\"num\" name=\"dhcp_start\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,1,254,idx.dhcp_start)\" value=\"%s\" />", |
|---|
| 1523 |
nvram_safe_get("dhcp_start")); |
|---|
| 1524 |
websWrite(wp, "</div>\n"); |
|---|
| 1525 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1526 |
websWrite(wp, |
|---|
| 1527 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_maxusers)</script></div><input class=\"num\" name=\"dhcp_num\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,253,idx.dhcp_maxusers)\" value=\"%s\" /></div>\n", |
|---|
| 1528 |
nvram_safe_get("dhcp_num")); |
|---|
| 1529 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1530 |
websWrite(wp, |
|---|
| 1531 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_lease)</script></div><input class=\"num\" name=\"dhcp_lease\" size=\"5\" maxlength=\"5\" onblur=\"valid_range(this,0,99999,idx.dhcp_lease)\" value=\"%s\" > <script type=\"text/javascript\">Capture(share.minutes)</script></input></div>\n", |
|---|
| 1532 |
nvram_safe_get("dhcp_lease")); |
|---|
| 1533 |
if (nvram_invmatch("wan_proto", "static")) { |
|---|
| 1534 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1535 |
websWrite(wp, |
|---|
| 1536 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 1</div>"); |
|---|
| 1537 |
websWrite(wp, |
|---|
| 1538 |
"<input type=\"hidden\" name=\"wan_dns\" value=\"4\" />"); |
|---|
| 1539 |
for (i = 0; i < 4; i++) |
|---|
| 1540 |
websWrite(wp, |
|---|
| 1541 |
"<input class=\"num\" name=\"wan_dns0_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1542 |
i, i == 3 ? 254 : 255, |
|---|
| 1543 |
get_dns_ip("wan_dns", 0, i), |
|---|
| 1544 |
i < 3 ? "." : ""); |
|---|
| 1545 |
|
|---|
| 1546 |
websWrite(wp, "\n</div>\n<div class=\"setting\">\n"); |
|---|
| 1547 |
websWrite(wp, |
|---|
| 1548 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 2</div>"); |
|---|
| 1549 |
for (i = 0; i < 4; i++) |
|---|
| 1550 |
websWrite(wp, |
|---|
| 1551 |
"<input class=\"num\" name=\"wan_dns1_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1552 |
i, i == 3 ? 254 : 255, |
|---|
| 1553 |
get_dns_ip("wan_dns", 1, i), |
|---|
| 1554 |
i < 3 ? "." : ""); |
|---|
| 1555 |
|
|---|
| 1556 |
websWrite(wp, "\n</div>\n<div class=\"setting\">\n"); |
|---|
| 1557 |
websWrite(wp, |
|---|
| 1558 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(idx_static.dns)</script> 3</div>"); |
|---|
| 1559 |
for (i = 0; i < 4; i++) |
|---|
| 1560 |
websWrite(wp, |
|---|
| 1561 |
"<input class=\"num\" name=\"wan_dns2_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,idx_static.dns)\" value=\"%d\" />%s", |
|---|
| 1562 |
i, i == 3 ? 254 : 255, |
|---|
| 1563 |
get_dns_ip("wan_dns", 2, i), |
|---|
| 1564 |
i < 3 ? "." : ""); |
|---|
| 1565 |
websWrite(wp, "\n</div>"); |
|---|
| 1566 |
} |
|---|
| 1567 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1568 |
websWrite(wp, "<div class=\"label\">WINS</div>\n"); |
|---|
| 1569 |
websWrite(wp, |
|---|
| 1570 |
"<input type=\"hidden\" name=\"wan_wins\" value=\"4\" />\n"); |
|---|
| 1571 |
char *wins = nvram_safe_get("wan_wins"); |
|---|
| 1572 |
|
|---|
| 1573 |
for (i = 0; i < 4; i++) { |
|---|
| 1574 |
websWrite(wp, |
|---|
| 1575 |
"<input class=\"num\" name=\"wan_wins_%d\" size=\"3\" maxlength=\"3\" onblur=\"valid_range(this,0,%d,"WINS")\" value=\"%d\" />%s", |
|---|
| 1576 |
i, i == 3 ? 254 : 255, get_single_ip(wins, i), |
|---|
| 1577 |
i < 3 ? "." : ""); |
|---|
| 1578 |
} |
|---|
| 1579 |
|
|---|
| 1580 |
websWrite(wp, "</div>\n<div class=\"setting\">\n"); |
|---|
| 1581 |
websWrite(wp, |
|---|
| 1582 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dhcp_dnsmasq)</script></div>\n"); |
|---|
| 1583 |
websWrite(wp, |
|---|
| 1584 |
"<input type=\"checkbox\" name=\"_dhcp_dnsmasq\" value=\"1\" onclick=\"setDNSMasq(this.form)\" %s />\n", |
|---|
| 1585 |
nvram_match("dhcp_dnsmasq", |
|---|
| 1586 |
"1") ? "checked=\"checked\"" : ""); |
|---|
| 1587 |
websWrite(wp, "</div>\n<div class=\"setting\">\n"); |
|---|
| 1588 |
websWrite(wp, |
|---|
| 1589 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(idx.dns_dnsmasq)</script></div>\n"); |
|---|
| 1590 |
websWrite(wp, |
|---|
| 1591 |
"<input type=\"checkbox\" name=\"_dns_dnsmasq\" value=\"1\" %s />\n", |
|---|
| 1592 |
nvram_match("dns_dnsmasq", |
|---|
| 1593 |
"1") ? "checked=\"checked\"" : ""); |
|---|
| 1594 |
websWrite(wp, "</div>\n<div class=\"setting\">\n"); |
|---|
| 1595 |
websWrite(wp, |
|---|
| 1596 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(idx.auth_dnsmasq)</script></div>\n"); |
|---|
| 1597 |
websWrite(wp, |
|---|
| 1598 |
"<input type=\"checkbox\" name=\"_auth_dnsmasq\" value=\"1\" %s />\n", |
|---|
| 1599 |
nvram_match("auth_dnsmasq", |
|---|
| 1600 |
"1") ? "checked=\"checked\"" : ""); |
|---|
| 1601 |
websWrite(wp, "</div>\n"); |
|---|
| 1602 |
} |
|---|
| 1603 |
|
|---|
| 1604 |
websWrite(wp, "</fieldset><br />\n"); |
|---|
| 1605 |
return; |
|---|
| 1606 |
} |
|---|
| 1607 |
|
|---|
| 1608 |
#ifdef HAVE_MADWIFI |
|---|
| 1609 |
void ej_show_wifiselect(webs_t wp, int argc, char_t ** argv) |
|---|
| 1610 |
{ |
|---|
| 1611 |
char *next; |
|---|
| 1612 |
char var[32]; |
|---|
| 1613 |
int count = getifcount("wifi"); |
|---|
| 1614 |
|
|---|
| 1615 |
if (count < 2) |
|---|
| 1616 |
return; |
|---|
| 1617 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1618 |
websWrite(wp, |
|---|
| 1619 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(share.intrface)</script></div>\n"); |
|---|
| 1620 |
websWrite(wp, |
|---|
| 1621 |
"<select name=\"wifi_display\" onchange=\"refresh(this.form)\">\n"); |
|---|
| 1622 |
int i; |
|---|
| 1623 |
|
|---|
| 1624 |
for (i = 0; i < count; i++) { |
|---|
| 1625 |
sprintf(var, "ath%d", i); |
|---|
| 1626 |
websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 1627 |
var, nvram_match("wifi_display", |
|---|
| 1628 |
var) ? "selected=\"selected\"" : "", |
|---|
| 1629 |
var); |
|---|
| 1630 |
char *names = nvram_nget("ath%d_vifs", i); |
|---|
| 1631 |
|
|---|
| 1632 |
foreach(var, names, next) { |
|---|
| 1633 |
websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 1634 |
var, nvram_match("wifi_display", |
|---|
| 1635 |
var) ? |
|---|
| 1636 |
"selected=\"selected\"" : "", var); |
|---|
| 1637 |
} |
|---|
| 1638 |
} |
|---|
| 1639 |
websWrite(wp, "</select>\n"); |
|---|
| 1640 |
websWrite(wp, "</div>\n"); |
|---|
| 1641 |
|
|---|
| 1642 |
} |
|---|
| 1643 |
#else |
|---|
| 1644 |
void ej_show_wifiselect(webs_t wp, int argc, char_t ** argv) |
|---|
| 1645 |
{ |
|---|
| 1646 |
char *next; |
|---|
| 1647 |
char var[32]; |
|---|
| 1648 |
int count = get_wl_instances(); |
|---|
| 1649 |
|
|---|
| 1650 |
if (count < 2) |
|---|
| 1651 |
return; |
|---|
| 1652 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1653 |
websWrite(wp, |
|---|
| 1654 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(share.intrface)</script></div>\n"); |
|---|
| 1655 |
websWrite(wp, |
|---|
| 1656 |
"<select name=\"wifi_display\" onchange=\"refresh(this.form)\">\n"); |
|---|
| 1657 |
int i; |
|---|
| 1658 |
|
|---|
| 1659 |
for (i = 0; i < count; i++) { |
|---|
| 1660 |
sprintf(var, "wl%d", i); |
|---|
| 1661 |
websWrite(wp, "<option value=\"%s\" %s >%s</option>\n", |
|---|
| 1662 |
var, nvram_match("wifi_display", |
|---|
| 1663 |
var) ? "selected=\"selected\"" : "", |
|---|
| 1664 |
var); |
|---|
| 1665 |
} |
|---|
| 1666 |
websWrite(wp, "</select>\n"); |
|---|
| 1667 |
websWrite(wp, "</div>\n"); |
|---|
| 1668 |
} |
|---|
| 1669 |
|
|---|
| 1670 |
#endif |
|---|
| 1671 |
#if 0 |
|---|
| 1672 |
static void showOption(webs_t wp, char *propname, char *nvname) |
|---|
| 1673 |
{ |
|---|
| 1674 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1675 |
websWrite(wp, |
|---|
| 1676 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n<select name=\"%s\">\n", |
|---|
| 1677 |
propname, nvname); |
|---|
| 1678 |
websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1679 |
websWrite(wp, |
|---|
| 1680 |
"document.write(\"<option value=\\\"0\\\" %s >\" + share.disabled + \"</option>\");\n", |
|---|
| 1681 |
nvram_default_match(nvname, "0", |
|---|
| 1682 |
"0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1683 |
websWrite(wp, |
|---|
| 1684 |
"document.write(\"<option value=\\\"1\\\" %s >\" + share.enabled + \"</option>\");\n", |
|---|
| 1685 |
nvram_default_match(nvname, "1", |
|---|
| 1686 |
"0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1687 |
websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 1688 |
|
|---|
| 1689 |
} |
|---|
| 1690 |
#endif |
|---|
| 1691 |
static void showRadio(webs_t wp, char *propname, char *nvname) |
|---|
| 1692 |
{ |
|---|
| 1693 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1694 |
websWrite(wp, |
|---|
| 1695 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n", |
|---|
| 1696 |
propname); |
|---|
| 1697 |
websWrite(wp, |
|---|
| 1698 |
"<input class=\"spaceradio\" type=\"radio\" value=\"1\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input> \n", |
|---|
| 1699 |
nvname, nvram_default_match(nvname, "1", |
|---|
| 1700 |
"0") ? "checked=\"checked\"" : |
|---|
| 1701 |
""); |
|---|
| 1702 |
websWrite(wp, |
|---|
| 1703 |
"<input class=\"spaceradio\" type=\"radio\" value=\"0\" name=\"%s\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input> \n", |
|---|
| 1704 |
nvname, nvram_default_match(nvname, "0", |
|---|
| 1705 |
"0") ? "checked=\"checked\"" : |
|---|
| 1706 |
""); |
|---|
| 1707 |
websWrite(wp, "</div>\n"); |
|---|
| 1708 |
} |
|---|
| 1709 |
|
|---|
| 1710 |
#ifdef HAVE_MADWIFI |
|---|
| 1711 |
static void showAutoOption(webs_t wp, char *propname, char *nvname) |
|---|
| 1712 |
{ |
|---|
| 1713 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1714 |
websWrite(wp, |
|---|
| 1715 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>\n<select name=\"%s\">\n", |
|---|
| 1716 |
propname, nvname); |
|---|
| 1717 |
websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1718 |
websWrite(wp, |
|---|
| 1719 |
"document.write(\"<option value=\\\"-1\\\" %s >\" + share.auto + \"</option>\");\n", |
|---|
| 1720 |
nvram_default_match(nvname, "0", |
|---|
| 1721 |
"-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1722 |
websWrite(wp, |
|---|
| 1723 |
"document.write(\"<option value=\\\"1\\\" %s >\" + share.enabled + \"</option>\");\n", |
|---|
| 1724 |
nvram_default_match(nvname, "1", |
|---|
| 1725 |
"-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1726 |
websWrite(wp, |
|---|
| 1727 |
"document.write(\"<option value=\\\"0\\\" %s >\" + share.disabled + \"</option>\");\n", |
|---|
| 1728 |
nvram_default_match(nvname, "0", |
|---|
| 1729 |
"-1") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 1730 |
websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 1731 |
|
|---|
| 1732 |
} |
|---|
| 1733 |
#endif |
|---|
| 1734 |
|
|---|
| 1735 |
static void showOptions(webs_t wp, char *propname, char *names, char *select) |
|---|
| 1736 |
{ |
|---|
| 1737 |
char *next; |
|---|
| 1738 |
char var[80]; |
|---|
| 1739 |
|
|---|
| 1740 |
websWrite(wp, "<select name=\"%s\">\n", propname); |
|---|
| 1741 |
websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1742 |
foreach(var, names, next) { |
|---|
| 1743 |
websWrite(wp, |
|---|
| 1744 |
"document.write(\"<option value=\\\"%s\\\" %s >%s</option>\");\n", |
|---|
| 1745 |
var, !strcmp(var, |
|---|
| 1746 |
select) ? "selected=\\\"selected\\\"" : |
|---|
| 1747 |
"", var); |
|---|
| 1748 |
} |
|---|
| 1749 |
websWrite(wp, "//]]>\n</script>\n</select>\n"); |
|---|
| 1750 |
} |
|---|
| 1751 |
|
|---|
| 1752 |
static void |
|---|
| 1753 |
showOptionsChoose(webs_t wp, char *propname, char *names, char *select) |
|---|
| 1754 |
{ |
|---|
| 1755 |
char *next; |
|---|
| 1756 |
char var[80]; |
|---|
| 1757 |
|
|---|
| 1758 |
websWrite(wp, "<select name=\"%s\">\n", propname); |
|---|
| 1759 |
websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 1760 |
websWrite(wp, |
|---|
| 1761 |
"document.write(\"<option value=\\\"null\\\" >Please choose...</option>\");\n"); |
|---|
| 1762 |
foreach(var, names, next) { |
|---|
| 1763 |
websWrite(wp, |
|---|
| 1764 |
"document.write(\"<option value=\\\"%s\\\" %s >%s</option>\");\n", |
|---|
| 1765 |
var, !strcmp(var, |
|---|
| 1766 |
select) ? "selected=\\\"selected\\\"" : |
|---|
| 1767 |
"", var); |
|---|
| 1768 |
} |
|---|
| 1769 |
websWrite(wp, "//]]>\n</script>\n</select>\n"); |
|---|
| 1770 |
} |
|---|
| 1771 |
|
|---|
| 1772 |
static void |
|---|
| 1773 |
showOptionsLabel(webs_t wp, char *labelname, char *propname, char *names, |
|---|
| 1774 |
char *select) |
|---|
| 1775 |
{ |
|---|
| 1776 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1777 |
websWrite(wp, |
|---|
| 1778 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>", |
|---|
| 1779 |
labelname); |
|---|
| 1780 |
showOptions(wp, propname, names, select); |
|---|
| 1781 |
websWrite(wp, "</div>\n"); |
|---|
| 1782 |
|
|---|
| 1783 |
} |
|---|
| 1784 |
|
|---|
| 1785 |
void |
|---|
| 1786 |
show_inputlabel(webs_t wp, char *labelname, char *propertyname, |
|---|
| 1787 |
int propertysize, char *inputclassname, int inputmaxlength) |
|---|
| 1788 |
{ |
|---|
| 1789 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1790 |
websWrite(wp, |
|---|
| 1791 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(%s)</script></div>", |
|---|
| 1792 |
labelname); |
|---|
| 1793 |
websWrite(wp, |
|---|
| 1794 |
"<input class=\"%s\" size=\"%d\" maxlength=\"%d\" name=\"%s\" value=\"%s\" />\n", |
|---|
| 1795 |
inputclassname, propertysize, inputmaxlength, propertyname, |
|---|
| 1796 |
nvram_safe_get(propertyname)); |
|---|
| 1797 |
websWrite(wp, "</div>\n"); |
|---|
| 1798 |
} |
|---|
| 1799 |
|
|---|
| 1800 |
void |
|---|
| 1801 |
show_custominputlabel(webs_t wp, char *labelname, char *propertyname, |
|---|
| 1802 |
char *property, int propertysize) |
|---|
| 1803 |
{ |
|---|
| 1804 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1805 |
websWrite(wp, "<div class=\"label\">%s</div>", labelname); |
|---|
| 1806 |
websWrite(wp, "<input size=\"%d\" name=\"%s\" value=\"%s\" />\n", |
|---|
| 1807 |
propertysize, propertyname, property); |
|---|
| 1808 |
websWrite(wp, "</div>\n"); |
|---|
| 1809 |
} |
|---|
| 1810 |
|
|---|
| 1811 |
#ifdef HAVE_USB |
|---|
| 1812 |
void ej_show_usb_diskinfo(webs_t wp, int argc, char_t ** argv) |
|---|
| 1813 |
{ |
|---|
| 1814 |
char buff[512]; |
|---|
| 1815 |
FILE *fp; |
|---|
| 1816 |
|
|---|
| 1817 |
if (!nvram_match("usb_automnt", "1")) |
|---|
| 1818 |
return; |
|---|
| 1819 |
|
|---|
| 1820 |
if ((fp = fopen("/tmp/disktype.dump", "r"))) { |
|---|
| 1821 |
while (fgets(buff, sizeof(buff), fp)) { |
|---|
| 1822 |
if (strcmp(buff, "\n")) |
|---|
| 1823 |
websWrite(wp, "%s<br />", buff); |
|---|
| 1824 |
} |
|---|
| 1825 |
fclose(fp); |
|---|
| 1826 |
} else |
|---|
| 1827 |
websWrite(wp, "%s", live_translate("status_router.notavail")); |
|---|
| 1828 |
|
|---|
| 1829 |
return; |
|---|
| 1830 |
} |
|---|
| 1831 |
#endif |
|---|
| 1832 |
|
|---|
| 1833 |
void show_legend(webs_t wp, char *labelname, int translate) |
|---|
| 1834 |
{ |
|---|
| 1835 |
/* |
|---|
| 1836 |
* char buf[2]; sprintf(buf,"%d",translate); websWrite (wp, |
|---|
| 1837 |
* "<legend>%s%s%s</legend>\n", !strcmp (buf, "1") ? "<script |
|---|
| 1838 |
* type=\"text/javascript\">Capture(" : "", labelname, !strcmp (buf, "1") |
|---|
| 1839 |
* ? ")</script>" : ""); |
|---|
| 1840 |
*/ |
|---|
| 1841 |
if (translate) |
|---|
| 1842 |
websWrite(wp, |
|---|
| 1843 |
"<legend><script type=\"text/javascript\">Capture(%s)</script></legend>\n", |
|---|
| 1844 |
labelname); |
|---|
| 1845 |
else |
|---|
| 1846 |
websWrite(wp, "<legend>%s</legend>\n", labelname); |
|---|
| 1847 |
|
|---|
| 1848 |
} |
|---|
| 1849 |
|
|---|
| 1850 |
#ifdef HAVE_OLSRD |
|---|
| 1851 |
|
|---|
| 1852 |
void ej_show_olsrd(webs_t wp, int argc, char_t ** argv) |
|---|
| 1853 |
{ |
|---|
| 1854 |
char *var = websGetVar(wp, "wk_mode", NULL); |
|---|
| 1855 |
|
|---|
| 1856 |
if (var == NULL) |
|---|
| 1857 |
var = nvram_safe_get("wk_mode"); |
|---|
| 1858 |
if (!strcmp(var, "olsr")) { |
|---|
| 1859 |
websWrite(wp, "<fieldset>\n"); |
|---|
| 1860 |
show_legend(wp, "route.olsrd_legend", 1); |
|---|
| 1861 |
show_inputlabel(wp, "route.olsrd_hna", "olsrd_hna", 32, "num", |
|---|
| 1862 |
32); |
|---|
| 1863 |
show_inputlabel(wp, "route.olsrd_poll", "olsrd_pollsize", 5, |
|---|
| 1864 |
"num", 5); |
|---|
| 1865 |
showOptionsLabel(wp, "route.olsrd_tc", "olsrd_redundancy", |
|---|
| 1866 |
"0 1 2", nvram_default_get("olsrd_redundancy", |
|---|
| 1867 |
"2")); |
|---|
| 1868 |
show_inputlabel(wp, "route.olsrd_mpr", "olsrd_coverage", 5, |
|---|
| 1869 |
"num", 5); |
|---|
| 1870 |
showRadio(wp, "route.olsrd_lqfe", "olsrd_lqfisheye"); |
|---|
| 1871 |
show_inputlabel(wp, "route.olsrd_lqag", "olsrd_lqaging", 5, |
|---|
| 1872 |
"num", 5); |
|---|
| 1873 |
|
|---|
| 1874 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1875 |
websWrite(wp, |
|---|
| 1876 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_lqdmin)</script></div>"); |
|---|
| 1877 |
websWrite(wp, |
|---|
| 1878 |
"<input class=\"num\" size=\"5\" maxlength=\"5\" name=\"olsrd_lqdijkstramin\" onblur=\"olsrd_checkDijkstra(this.form)\" value=\"%s\" />\n", |
|---|
| 1879 |
nvram_safe_get("olsrd_lqdijkstramin")); |
|---|
| 1880 |
websWrite(wp, "</div>\n"); |
|---|
| 1881 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1882 |
websWrite(wp, |
|---|
| 1883 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_lqdmax)</script></div>"); |
|---|
| 1884 |
websWrite(wp, |
|---|
| 1885 |
"<input class=\"num\" size=\"5\" maxlength=\"5\" name=\"olsrd_lqdijkstramax\" onblur=\"olsrd_checkDijkstra(this.form)\" value=\"%s\" />\n", |
|---|
| 1886 |
nvram_safe_get("olsrd_lqdijkstramax")); |
|---|
| 1887 |
websWrite(wp, "</div>\n"); |
|---|
| 1888 |
|
|---|
| 1889 |
showOptionsLabel(wp, "route.olsrd_lqlvl", "olsrd_lqlevel", |
|---|
| 1890 |
"0 1 2", nvram_default_get("olsrd_lqlevel", |
|---|
| 1891 |
"2")); |
|---|
| 1892 |
showRadio(wp, "route.olsrd_hysteresis", "olsrd_hysteresis"); |
|---|
| 1893 |
char *wordlist = nvram_safe_get("olsrd_interfaces"); |
|---|
| 1894 |
char *next; |
|---|
| 1895 |
char word[128]; |
|---|
| 1896 |
int count = 0; |
|---|
| 1897 |
|
|---|
| 1898 |
foreach(word, wordlist, next) { |
|---|
| 1899 |
char *interface = word; |
|---|
| 1900 |
char *hellointerval = interface; |
|---|
| 1901 |
|
|---|
| 1902 |
strsep(&hellointerval, ">"); |
|---|
| 1903 |
char *hellovaliditytime = hellointerval; |
|---|
| 1904 |
|
|---|
| 1905 |
strsep(&hellovaliditytime, ">"); |
|---|
| 1906 |
char *tcinterval = hellovaliditytime; |
|---|
| 1907 |
|
|---|
| 1908 |
strsep(&tcinterval, ">"); |
|---|
| 1909 |
char *tcvaliditytime = tcinterval; |
|---|
| 1910 |
|
|---|
| 1911 |
strsep(&tcvaliditytime, ">"); |
|---|
| 1912 |
char *midinterval = tcvaliditytime; |
|---|
| 1913 |
|
|---|
| 1914 |
strsep(&midinterval, ">"); |
|---|
| 1915 |
char *midvaliditytime = midinterval; |
|---|
| 1916 |
|
|---|
| 1917 |
strsep(&midvaliditytime, ">"); |
|---|
| 1918 |
char *hnainterval = midvaliditytime; |
|---|
| 1919 |
|
|---|
| 1920 |
strsep(&hnainterval, ">"); |
|---|
| 1921 |
char *hnavaliditytime = hnainterval; |
|---|
| 1922 |
|
|---|
| 1923 |
strsep(&hnavaliditytime, ">"); |
|---|
| 1924 |
websWrite(wp, "<fieldset>\n"); |
|---|
| 1925 |
show_legend(wp, interface, 0); |
|---|
| 1926 |
char valuename[32]; |
|---|
| 1927 |
|
|---|
| 1928 |
sprintf(valuename, "%s_hellointerval", interface); |
|---|
| 1929 |
show_custominputlabel(wp, "Hello Interval", valuename, |
|---|
| 1930 |
hellointerval, 5); |
|---|
| 1931 |
sprintf(valuename, "%s_hellovaliditytime", interface); |
|---|
| 1932 |
show_custominputlabel(wp, "Hello Validity Time", |
|---|
| 1933 |
valuename, hellovaliditytime, 5); |
|---|
| 1934 |
|
|---|
| 1935 |
sprintf(valuename, "%s_tcinterval", interface); |
|---|
| 1936 |
show_custominputlabel(wp, "TC Interval", valuename, |
|---|
| 1937 |
tcinterval, 5); |
|---|
| 1938 |
sprintf(valuename, "%s_tcvaliditytime", interface); |
|---|
| 1939 |
show_custominputlabel(wp, "TC Validity Time", valuename, |
|---|
| 1940 |
tcvaliditytime, 5); |
|---|
| 1941 |
|
|---|
| 1942 |
sprintf(valuename, "%s_midinterval", interface); |
|---|
| 1943 |
show_custominputlabel(wp, "MID Interval", valuename, |
|---|
| 1944 |
midinterval, 5); |
|---|
| 1945 |
sprintf(valuename, "%s_midvaliditytime", interface); |
|---|
| 1946 |
show_custominputlabel(wp, "MID Validity Time", |
|---|
| 1947 |
valuename, midvaliditytime, 5); |
|---|
| 1948 |
|
|---|
| 1949 |
sprintf(valuename, "%s_hnainterval", interface); |
|---|
| 1950 |
show_custominputlabel(wp, "HNA Interval", valuename, |
|---|
| 1951 |
hnainterval, 5); |
|---|
| 1952 |
sprintf(valuename, "%s_hnavaliditytime", interface); |
|---|
| 1953 |
show_custominputlabel(wp, "HNA Validity Time", |
|---|
| 1954 |
valuename, hnavaliditytime, 5); |
|---|
| 1955 |
websWrite(wp, |
|---|
| 1956 |
"<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"olsrd_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 1957 |
count); |
|---|
| 1958 |
|
|---|
| 1959 |
websWrite(wp, "</fieldset>\n"); |
|---|
| 1960 |
count++; |
|---|
| 1961 |
} |
|---|
| 1962 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 1963 |
websWrite(wp, |
|---|
| 1964 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(route.olsrd_newiface)</script></div>\n"); |
|---|
| 1965 |
char buffer[256]; |
|---|
| 1966 |
|
|---|
| 1967 |
memset(buffer, 0, 256); |
|---|
| 1968 |
getIfList(buffer, NULL); |
|---|
| 1969 |
showOptions(wp, "olsrd_ifname", buffer, ""); |
|---|
| 1970 |
websWrite(wp, " "); |
|---|
| 1971 |
websWrite(wp, |
|---|
| 1972 |
"<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.add + \"\\\" onclick=\\\"olsrd_add_submit(this.form)\\\" />\");\n//]]>\n</script>\n"); |
|---|
| 1973 |
websWrite(wp, "</div>\n"); |
|---|
| 1974 |
websWrite(wp, "</fieldset><br />\n"); |
|---|
| 1975 |
} |
|---|
| 1976 |
} |
|---|
| 1977 |
#else //!HAVE_OLSRD |
|---|
| 1978 |
void ej_show_olsrd(webs_t wp, int argc, char_t ** argv) |
|---|
| 1979 |
{ |
|---|
| 1980 |
return; |
|---|
| 1981 |
} |
|---|
| 1982 |
#endif |
|---|
| 1983 |
|
|---|
| 1984 |
#ifdef HAVE_VLANTAGGING |
|---|
| 1985 |
#ifdef HAVE_BONDING |
|---|
| 1986 |
|
|---|
| 1987 |
void ej_show_bondings(webs_t wp, int argc, char_t ** argv) |
|---|
| 1988 |
{ |
|---|
| 1989 |
char buffer[256]; |
|---|
| 1990 |
char bufferif[512]; |
|---|
| 1991 |
char bondnames[256]; |
|---|
| 1992 |
int count = 0; |
|---|
| 1993 |
static char word[256]; |
|---|
| 1994 |
char *next, *wordlist; |
|---|
| 1995 |
|
|---|
| 1996 |
memset(buffer, 0, 256); |
|---|
| 1997 |
memset(bondnames, 0, 256); |
|---|
| 1998 |
memset(bufferif, 0, 512); |
|---|
| 1999 |
websWrite(wp, "<h2>Bonding</h2>\n"); |
|---|
| 2000 |
websWrite(wp, "<fieldset>\n"); |
|---|
| 2001 |
websWrite(wp, "<legend>Bonding</legend>\n"); |
|---|
| 2002 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2003 |
websWrite(wp, "<div class=\"label\">Bonding Type</div>\n", count); |
|---|
| 2004 |
showOptions(wp, "bonding_type", |
|---|
| 2005 |
"balance-rr active-backup balance-xor broadcast 802.3ad balance-tlb balance-alb weighted-rr duplex", |
|---|
| 2006 |
nvram_default_get("bonding_type", "balance-rr")); |
|---|
| 2007 |
websWrite(wp, " Bonding Interfaces "); |
|---|
| 2008 |
websWrite(wp, |
|---|
| 2009 |
"<input class=\"num\" name=\"bonding_number\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2010 |
nvram_default_get("bonding_number", "1")); |
|---|
| 2011 |
websWrite(wp, "</div>\n"); |
|---|
| 2012 |
|
|---|
| 2013 |
getIfList(bufferif, "eth"); |
|---|
| 2014 |
int i; |
|---|
| 2015 |
|
|---|
| 2016 |
#ifdef HAVE_XSCALE |
|---|
| 2017 |
memset(buffer, 0, 256); |
|---|
| 2018 |
getIfList(buffer, "ixp"); |
|---|
| 2019 |
sprintf(bufferif, "%s %s", bufferif, buffer); |
|---|
| 2020 |
#endif |
|---|
| 2021 |
memset(buffer, 0, 256); |
|---|
| 2022 |
getIfList(buffer, "br"); |
|---|
| 2023 |
sprintf(bufferif, "%s %s", bufferif, buffer); |
|---|
| 2024 |
#ifdef HAVE_MADWIFI |
|---|
| 2025 |
int c = getifcount("wifi"); |
|---|
| 2026 |
|
|---|
| 2027 |
for (i = 0; i < c; i++) { |
|---|
| 2028 |
char ath[32]; |
|---|
| 2029 |
|
|---|
| 2030 |
sprintf(ath, "ath%d_bridged", i); |
|---|
| 2031 |
if (nvram_default_match(ath, "0", "1")) { |
|---|
| 2032 |
sprintf(bufferif, "%s ath%d", bufferif, i); |
|---|
| 2033 |
char vifs[32]; |
|---|
| 2034 |
|
|---|
| 2035 |
sprintf(vifs, "ath%d_vifs", i); |
|---|
| 2036 |
sprintf(bufferif, "%s %s", bufferif, |
|---|
| 2037 |
nvram_safe_get(vifs)); |
|---|
| 2038 |
} |
|---|
| 2039 |
} |
|---|
| 2040 |
#endif |
|---|
| 2041 |
|
|---|
| 2042 |
for (i = 0; i < atoi(nvram_safe_get("bonding_number")); i++) { |
|---|
| 2043 |
sprintf(bondnames, "%s bond%d", bondnames, i); |
|---|
| 2044 |
} |
|---|
| 2045 |
int totalcount = 0; |
|---|
| 2046 |
int realcount = atoi(nvram_default_get("bonding_count", "0")); |
|---|
| 2047 |
|
|---|
| 2048 |
wordlist = nvram_safe_get("bondings"); |
|---|
| 2049 |
foreach(word, wordlist, next) { |
|---|
| 2050 |
char *port = word; |
|---|
| 2051 |
char *tag = strsep(&port, ">"); |
|---|
| 2052 |
|
|---|
| 2053 |
if (!tag || !port) |
|---|
| 2054 |
break; |
|---|
| 2055 |
char vlan_name[32]; |
|---|
| 2056 |
|
|---|
| 2057 |
// sprintf (vlan_name, "%s.%s", tag, port); |
|---|
| 2058 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2059 |
websWrite(wp, |
|---|
| 2060 |
"<div class=\"label\">Bonding %d Assignment</div>\n", |
|---|
| 2061 |
count); |
|---|
| 2062 |
websWrite(wp, " Bond "); |
|---|
| 2063 |
sprintf(vlan_name, "bondingifname%d", count); |
|---|
| 2064 |
showOptions(wp, vlan_name, bondnames, tag); |
|---|
| 2065 |
sprintf(vlan_name, "bondingattach%d", count); |
|---|
| 2066 |
websWrite(wp, " Slave "); |
|---|
| 2067 |
showOptions(wp, vlan_name, bufferif, port); |
|---|
| 2068 |
websWrite(wp, |
|---|
| 2069 |
"<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"bond_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 2070 |
count); |
|---|
| 2071 |
websWrite(wp, "</div>\n"); |
|---|
| 2072 |
count++; |
|---|
| 2073 |
} |
|---|
| 2074 |
totalcount = count; |
|---|
| 2075 |
for (i = count; i < realcount; i++) { |
|---|
| 2076 |
char vlan_name[32]; |
|---|
| 2077 |
|
|---|
| 2078 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2079 |
websWrite(wp, |
|---|
| 2080 |
"<div class=\"label\">Bonding %d Interface</div>\n", |
|---|
| 2081 |
i); |
|---|
| 2082 |
websWrite(wp, " Bond "); |
|---|
| 2083 |
sprintf(vlan_name, "bondingifname%d", i); |
|---|
| 2084 |
showOptions(wp, vlan_name, bondnames, ""); |
|---|
| 2085 |
sprintf(vlan_name, "bondingattach%d", i); |
|---|
| 2086 |
websWrite(wp, " Slave "); |
|---|
| 2087 |
showOptions(wp, vlan_name, bufferif, ""); |
|---|
| 2088 |
websWrite(wp, |
|---|
| 2089 |
"<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"bond_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 2090 |
i); |
|---|
| 2091 |
websWrite(wp, "</div>\n"); |
|---|
| 2092 |
totalcount++; |
|---|
| 2093 |
} |
|---|
| 2094 |
char var[32]; |
|---|
| 2095 |
|
|---|
| 2096 |
sprintf(var, "%d", totalcount); |
|---|
| 2097 |
nvram_set("bonding_count", var); |
|---|
| 2098 |
websWrite(wp, |
|---|
| 2099 |
"<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.add + \"\\\" onclick=\\\"bond_add_submit(this.form)\\\" />\");\n//]]>\n</script>\n"); |
|---|
| 2100 |
websWrite(wp, "</fieldset><br />\n"); |
|---|
| 2101 |
} |
|---|
| 2102 |
#else //!HAVE_BONDING |
|---|
| 2103 |
void ej_show_bondings(webs_t wp, int argc, char_t ** argv) |
|---|
| 2104 |
{ |
|---|
| 2105 |
return; |
|---|
| 2106 |
} |
|---|
| 2107 |
#endif |
|---|
| 2108 |
|
|---|
| 2109 |
void ej_show_vlantagging(webs_t wp, int argc, char_t ** argv) |
|---|
| 2110 |
{ |
|---|
| 2111 |
char buffer[256]; |
|---|
| 2112 |
int count = 0; |
|---|
| 2113 |
static char word[256]; |
|---|
| 2114 |
char *next, *wordlist; |
|---|
| 2115 |
|
|---|
| 2116 |
memset(buffer, 0, 256); |
|---|
| 2117 |
getIfList(buffer, NULL); |
|---|
| 2118 |
int totalcount = 0; |
|---|
| 2119 |
int realcount = atoi(nvram_default_get("vlan_tagcount", "0")); |
|---|
| 2120 |
|
|---|
| 2121 |
wordlist = nvram_safe_get("vlan_tags"); |
|---|
| 2122 |
foreach(word, wordlist, next) { |
|---|
| 2123 |
char *port = word; |
|---|
| 2124 |
char *tag = strsep(&port, ">"); |
|---|
| 2125 |
|
|---|
| 2126 |
if (!tag || !port) |
|---|
| 2127 |
break; |
|---|
| 2128 |
char vlan_name[32]; |
|---|
| 2129 |
|
|---|
| 2130 |
// sprintf (vlan_name, "%s.%s", tag, port); |
|---|
| 2131 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2132 |
websWrite(wp, "<div class=\"label\">VLAN%d Interface</div>\n", |
|---|
| 2133 |
count); |
|---|
| 2134 |
sprintf(vlan_name, "vlanifname%d", count); |
|---|
| 2135 |
showOptions(wp, vlan_name, buffer, tag); |
|---|
| 2136 |
sprintf(vlan_name, "vlantag%d", count); |
|---|
| 2137 |
websWrite(wp, " Tag Number "); |
|---|
| 2138 |
websWrite(wp, |
|---|
| 2139 |
"<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2140 |
vlan_name, port); |
|---|
| 2141 |
websWrite(wp, |
|---|
| 2142 |
"<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"vlan_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 2143 |
count); |
|---|
| 2144 |
websWrite(wp, "</div>\n"); |
|---|
| 2145 |
count++; |
|---|
| 2146 |
} |
|---|
| 2147 |
totalcount = count; |
|---|
| 2148 |
int i; |
|---|
| 2149 |
|
|---|
| 2150 |
for (i = count; i < realcount; i++) { |
|---|
| 2151 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2152 |
websWrite(wp, "<div class=\"label\">VLAN%d Interface</div>\n", |
|---|
| 2153 |
i); |
|---|
| 2154 |
char vlan_name[32]; |
|---|
| 2155 |
|
|---|
| 2156 |
sprintf(vlan_name, "vlanifname%d", i); |
|---|
| 2157 |
showOptions(wp, vlan_name, buffer, ""); |
|---|
| 2158 |
sprintf(vlan_name, "vlantag%d", i); |
|---|
| 2159 |
websWrite(wp, " Tag Number "); |
|---|
| 2160 |
websWrite(wp, |
|---|
| 2161 |
"<input class=\"num\" name=\"%s\" size=\"5\" value=\"0\" />\n", |
|---|
| 2162 |
vlan_name); |
|---|
| 2163 |
websWrite(wp, |
|---|
| 2164 |
"<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"vlan_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 2165 |
i); |
|---|
| 2166 |
websWrite(wp, "</div>\n"); |
|---|
| 2167 |
totalcount++; |
|---|
| 2168 |
} |
|---|
| 2169 |
char var[32]; |
|---|
| 2170 |
|
|---|
| 2171 |
sprintf(var, "%d", totalcount); |
|---|
| 2172 |
nvram_set("vlan_tagcount", var); |
|---|
| 2173 |
websWrite(wp, |
|---|
| 2174 |
"<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.add + \"\\\" onclick=\\\"vlan_add_submit(this.form)\\\" />\");\n//]]>\n</script>\n"); |
|---|
| 2175 |
} |
|---|
| 2176 |
|
|---|
| 2177 |
void ej_show_mdhcp(webs_t wp, int argc, char_t ** argv) |
|---|
| 2178 |
{ |
|---|
| 2179 |
char buffer[256]; |
|---|
| 2180 |
int count = 0; |
|---|
| 2181 |
static char word[256]; |
|---|
| 2182 |
char *next, *wordlist; |
|---|
| 2183 |
|
|---|
| 2184 |
websWrite(wp, "<h2>%s</h2>\n<fieldset>\n", |
|---|
| 2185 |
live_translate("networking.h5")); |
|---|
| 2186 |
websWrite(wp, "<legend>%s</legend>\n", |
|---|
| 2187 |
live_translate("networking.legend5")); |
|---|
| 2188 |
|
|---|
| 2189 |
memset(buffer, 0, 256); |
|---|
| 2190 |
getIfList(buffer, NULL); |
|---|
| 2191 |
int totalcount = 0; |
|---|
| 2192 |
int realcount = atoi(nvram_default_get("mdhcpd_count", "0")); |
|---|
| 2193 |
|
|---|
| 2194 |
wordlist = nvram_safe_get("mdhcpd"); |
|---|
| 2195 |
foreach(word, wordlist, next) { |
|---|
| 2196 |
char *interface = word; |
|---|
| 2197 |
char *dhcpon = interface; |
|---|
| 2198 |
|
|---|
| 2199 |
interface = strsep(&dhcpon, ">"); |
|---|
| 2200 |
char *start = dhcpon; |
|---|
| 2201 |
|
|---|
| 2202 |
dhcpon = strsep(&start, ">"); |
|---|
| 2203 |
char *max = start; |
|---|
| 2204 |
|
|---|
| 2205 |
start = strsep(&max, ">"); |
|---|
| 2206 |
char *leasetime = max; |
|---|
| 2207 |
|
|---|
| 2208 |
max = strsep(&leasetime, ">"); |
|---|
| 2209 |
if (!interface || !start || !dhcpon || !max || !leasetime) |
|---|
| 2210 |
break; |
|---|
| 2211 |
char vlan_name[32]; |
|---|
| 2212 |
|
|---|
| 2213 |
// interface |
|---|
| 2214 |
char *ipaddr = nvram_nget("%s_ipaddr", interface); |
|---|
| 2215 |
char *netmask = nvram_nget("%s_netmask", interface); |
|---|
| 2216 |
|
|---|
| 2217 |
if (strlen(ipaddr) > 0 && strlen(netmask) > 0) { |
|---|
| 2218 |
websWrite(wp, "Interface %s: IP %s/%s\n", interface, |
|---|
| 2219 |
ipaddr, netmask); |
|---|
| 2220 |
} |
|---|
| 2221 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2222 |
websWrite(wp, "<div class=\"label\">DHCP %d</div>\n", count); |
|---|
| 2223 |
sprintf(vlan_name, "mdhcpifname%d", count); |
|---|
| 2224 |
showOptions(wp, vlan_name, buffer, interface); |
|---|
| 2225 |
// on off |
|---|
| 2226 |
sprintf(vlan_name, "mdhcpon%d", count); |
|---|
| 2227 |
showOptions(wp, vlan_name, "On Off", dhcpon); |
|---|
| 2228 |
// start |
|---|
| 2229 |
sprintf(vlan_name, "mdhcpstart%d", count); |
|---|
| 2230 |
websWrite(wp, " Start "); |
|---|
| 2231 |
websWrite(wp, |
|---|
| 2232 |
"<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2233 |
vlan_name, start); |
|---|
| 2234 |
// max |
|---|
| 2235 |
sprintf(vlan_name, "mdhcpmax%d", count); |
|---|
| 2236 |
websWrite(wp, " Max "); |
|---|
| 2237 |
websWrite(wp, |
|---|
| 2238 |
"<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2239 |
vlan_name, max); |
|---|
| 2240 |
sprintf(vlan_name, "mdhcpleasetime%d", count); |
|---|
| 2241 |
websWrite(wp, " Leasetime "); |
|---|
| 2242 |
websWrite(wp, |
|---|
| 2243 |
"<input class=\"num\" name=\"%s\" size=\"5\" value=\"%s\" />\n", |
|---|
| 2244 |
vlan_name, leasetime); |
|---|
| 2245 |
// |
|---|
| 2246 |
websWrite(wp, |
|---|
| 2247 |
"<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"mdhcp_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 2248 |
count); |
|---|
| 2249 |
websWrite(wp, "</div>\n"); |
|---|
| 2250 |
count++; |
|---|
| 2251 |
} |
|---|
| 2252 |
totalcount = count; |
|---|
| 2253 |
int i; |
|---|
| 2254 |
|
|---|
| 2255 |
for (i = count; i < realcount; i++) { |
|---|
| 2256 |
char vlan_name[32]; |
|---|
| 2257 |
|
|---|
| 2258 |
// sprintf (mdhcp_name, "%s.%s", tag, port); |
|---|
| 2259 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2260 |
websWrite(wp, "<div class=\"label\">DHCP %d</div>\n", count); |
|---|
| 2261 |
// interface |
|---|
| 2262 |
sprintf(vlan_name, "mdhcpifname%d", count); |
|---|
| 2263 |
showOptions(wp, vlan_name, buffer, ""); |
|---|
| 2264 |
// on off |
|---|
| 2265 |
sprintf(vlan_name, "mdhcpon%d", count); |
|---|
| 2266 |
showOptions(wp, vlan_name, "On Off", ""); |
|---|
| 2267 |
// start |
|---|
| 2268 |
sprintf(vlan_name, "mdhcpstart%d", count); |
|---|
| 2269 |
websWrite(wp, " Start "); |
|---|
| 2270 |
websWrite(wp, |
|---|
| 2271 |
"<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2272 |
vlan_name, "100"); |
|---|
| 2273 |
// max |
|---|
| 2274 |
sprintf(vlan_name, "mdhcpmax%d", count); |
|---|
| 2275 |
websWrite(wp, " Max "); |
|---|
| 2276 |
websWrite(wp, |
|---|
| 2277 |
"<input class=\"num\" name=\"%s\" size=\"3\" value=\"%s\" />\n", |
|---|
| 2278 |
vlan_name, "50"); |
|---|
| 2279 |
sprintf(vlan_name, "mdhcpleasetime%d", count); |
|---|
| 2280 |
websWrite(wp, " Leasetime "); |
|---|
| 2281 |
websWrite(wp, |
|---|
| 2282 |
"<input class=\"num\" name=\"%s\" size=\"5\" value=\"%s\" />\n", |
|---|
| 2283 |
vlan_name, "3600"); |
|---|
| 2284 |
websWrite(wp, |
|---|
| 2285 |
"<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"mdhcp_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 2286 |
i); |
|---|
| 2287 |
websWrite(wp, "</div>\n"); |
|---|
| 2288 |
totalcount++; |
|---|
| 2289 |
} |
|---|
| 2290 |
char var[32]; |
|---|
| 2291 |
|
|---|
| 2292 |
sprintf(var, "%d", totalcount); |
|---|
| 2293 |
nvram_set("mdhcpd_count", var); |
|---|
| 2294 |
websWrite(wp, |
|---|
| 2295 |
"<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.add + \"\\\" onclick=\\\"mdhcp_add_submit(this.form)\\\" />\");\n//]]>\n</script>\n"); |
|---|
| 2296 |
websWrite(wp, "</fieldset><br />\n"); |
|---|
| 2297 |
|
|---|
| 2298 |
} |
|---|
| 2299 |
|
|---|
| 2300 |
void ej_show_bridgenames(webs_t wp, int argc, char_t ** argv) |
|---|
| 2301 |
{ |
|---|
| 2302 |
char buffer[256]; |
|---|
| 2303 |
int count = 0; |
|---|
| 2304 |
static char word[256]; |
|---|
| 2305 |
char *next, *wordlist; |
|---|
| 2306 |
|
|---|
| 2307 |
memset(buffer, 0, 256); |
|---|
| 2308 |
getIfList(buffer, NULL); |
|---|
| 2309 |
int realcount = atoi(nvram_default_get("bridges_count", "0")); |
|---|
| 2310 |
|
|---|
| 2311 |
wordlist = nvram_safe_get("bridges"); |
|---|
| 2312 |
foreach(word, wordlist, next) { |
|---|
| 2313 |
|
|---|
| 2314 |
char *stp = word; |
|---|
| 2315 |
char *bridge = strsep(&stp, ">"); |
|---|
| 2316 |
char *prio = stp; |
|---|
| 2317 |
|
|---|
| 2318 |
stp = strsep(&prio, ">"); |
|---|
| 2319 |
char *mtu = prio; |
|---|
| 2320 |
|
|---|
| 2321 |
prio = strsep(&mtu, ">"); |
|---|
| 2322 |
if (!prio) { |
|---|
| 2323 |
prio = mtu; |
|---|
| 2324 |
mtu = "1500"; |
|---|
| 2325 |
} |
|---|
| 2326 |
|
|---|
| 2327 |
/* char *stp = word; |
|---|
| 2328 |
char *bridge = strsep( &stp, ">" ); |
|---|
| 2329 |
char *mtu = stp; |
|---|
| 2330 |
char *prio = strsep( &mtu, ">" ); |
|---|
| 2331 |
*/ |
|---|
| 2332 |
if (!bridge || !stp) |
|---|
| 2333 |
break; |
|---|
| 2334 |
|
|---|
| 2335 |
char vlan_name[32]; |
|---|
| 2336 |
|
|---|
| 2337 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2338 |
websWrite(wp, "<div class=\"label\">Bridge %d</div>\n", count); |
|---|
| 2339 |
sprintf(vlan_name, "bridgename%d", count); |
|---|
| 2340 |
websWrite(wp, |
|---|
| 2341 |
"<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2342 |
vlan_name, bridge); |
|---|
| 2343 |
websWrite(wp, " STP "); |
|---|
| 2344 |
sprintf(vlan_name, "bridgestp%d", count); |
|---|
| 2345 |
showOptions(wp, vlan_name, "On Off", stp); |
|---|
| 2346 |
websWrite(wp, " Prio "); |
|---|
| 2347 |
sprintf(vlan_name, "bridgeprio%d", count); |
|---|
| 2348 |
websWrite(wp, |
|---|
| 2349 |
"<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2350 |
vlan_name, prio != NULL ? prio : "32768"); |
|---|
| 2351 |
websWrite(wp, " MTU "); |
|---|
| 2352 |
sprintf(vlan_name, "bridgemtu%d", count); |
|---|
| 2353 |
websWrite(wp, |
|---|
| 2354 |
"<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2355 |
vlan_name, mtu != NULL ? mtu : "1500"); |
|---|
| 2356 |
websWrite(wp, |
|---|
| 2357 |
"<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"bridge_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 2358 |
count); |
|---|
| 2359 |
websWrite(wp, "</div>\n"); |
|---|
| 2360 |
show_ipnetmask(wp, bridge); |
|---|
| 2361 |
count++; |
|---|
| 2362 |
} |
|---|
| 2363 |
int i; |
|---|
| 2364 |
int totalcount = count; |
|---|
| 2365 |
|
|---|
| 2366 |
for (i = count; i < realcount; i++) { |
|---|
| 2367 |
char vlan_name[32]; |
|---|
| 2368 |
|
|---|
| 2369 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2370 |
websWrite(wp, "<div class=\"label\">Bridge %d</div>\n", i); |
|---|
| 2371 |
sprintf(vlan_name, "bridgename%d", i); |
|---|
| 2372 |
websWrite(wp, "<input class=\"num\" name=\"%s\"size=\"5\" />\n", |
|---|
| 2373 |
vlan_name); |
|---|
| 2374 |
websWrite(wp, " STP "); |
|---|
| 2375 |
sprintf(vlan_name, "bridgestp%d", i); |
|---|
| 2376 |
showOptions(wp, vlan_name, "On Off", "On"); |
|---|
| 2377 |
websWrite(wp, " Prio "); |
|---|
| 2378 |
sprintf(vlan_name, "bridgeprio%d", i); |
|---|
| 2379 |
websWrite(wp, |
|---|
| 2380 |
"<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2381 |
vlan_name, "32768"); |
|---|
| 2382 |
websWrite(wp, " MTU "); |
|---|
| 2383 |
sprintf(vlan_name, "bridgemtu%d", count); |
|---|
| 2384 |
websWrite(wp, |
|---|
| 2385 |
"<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2386 |
vlan_name, "1500"); |
|---|
| 2387 |
websWrite(wp, |
|---|
| 2388 |
"<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"bridge_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 2389 |
i); |
|---|
| 2390 |
websWrite(wp, "</div>\n"); |
|---|
| 2391 |
totalcount++; |
|---|
| 2392 |
} |
|---|
| 2393 |
websWrite(wp, |
|---|
| 2394 |
"<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.add + \"\\\" onclick=\\\"bridge_add_submit(this.form)\\\" />\");\n//]]>\n</script>\n"); |
|---|
| 2395 |
char var[32]; |
|---|
| 2396 |
|
|---|
| 2397 |
sprintf(var, "%d", totalcount); |
|---|
| 2398 |
nvram_set("bridges_count", var); |
|---|
| 2399 |
} |
|---|
| 2400 |
|
|---|
| 2401 |
void ej_show_bridgetable(webs_t wp, int argc, char_t ** argv) |
|---|
| 2402 |
{ |
|---|
| 2403 |
//#ifdef HAVE_MICRO // brctl N/A in micro |
|---|
| 2404 |
// return; |
|---|
| 2405 |
//#endif |
|---|
| 2406 |
|
|---|
| 2407 |
FILE *f; |
|---|
| 2408 |
char buf[128]; |
|---|
| 2409 |
char brname[32]; |
|---|
| 2410 |
char brstp[8]; |
|---|
| 2411 |
char brif[16]; |
|---|
| 2412 |
int count = 0; |
|---|
| 2413 |
|
|---|
| 2414 |
system2("brctl show > /tmp/.brtable"); |
|---|
| 2415 |
|
|---|
| 2416 |
if ((f = fopen("/tmp/.brtable", "r")) != NULL) { |
|---|
| 2417 |
|
|---|
| 2418 |
while (fgets(buf, sizeof(buf), f)) { |
|---|
| 2419 |
|
|---|
| 2420 |
if (count) // skip line 0 |
|---|
| 2421 |
{ |
|---|
| 2422 |
strcpy(brname, ""); |
|---|
| 2423 |
strcpy(brstp, ""); |
|---|
| 2424 |
strcpy(brif, ""); |
|---|
| 2425 |
|
|---|
| 2426 |
if (strncmp(buf, "\t\t\t", 3) != 0) { |
|---|
| 2427 |
if (count != 1) |
|---|
| 2428 |
websWrite(wp, "\',"); // close |
|---|
| 2429 |
sscanf(buf, "%s %*s %s %s", brname, |
|---|
| 2430 |
brstp, brif); |
|---|
| 2431 |
websWrite(wp, "\'%s\',\'%s\',\'%s ", |
|---|
| 2432 |
brname, brstp, brif); |
|---|
| 2433 |
} else { |
|---|
| 2434 |
sscanf(buf, "%s", brif); |
|---|
| 2435 |
websWrite(wp, "%s ", brif); |
|---|
| 2436 |
} |
|---|
| 2437 |
} |
|---|
| 2438 |
count++; |
|---|
| 2439 |
} |
|---|
| 2440 |
|
|---|
| 2441 |
websWrite(wp, "\'"); // close |
|---|
| 2442 |
fclose(f); |
|---|
| 2443 |
unlink("/tmp/.brtable"); |
|---|
| 2444 |
} |
|---|
| 2445 |
return; |
|---|
| 2446 |
} |
|---|
| 2447 |
|
|---|
| 2448 |
void ej_show_bridgeifnames(webs_t wp, int argc, char_t ** argv) |
|---|
| 2449 |
{ |
|---|
| 2450 |
char bufferif[512]; |
|---|
| 2451 |
char bufferif2[256]; |
|---|
| 2452 |
char finalbuffer[512]; |
|---|
| 2453 |
int count = 0; |
|---|
| 2454 |
static char word[256]; |
|---|
| 2455 |
char *next, *wordlist; |
|---|
| 2456 |
|
|---|
| 2457 |
memset(bufferif, 0, 512); |
|---|
| 2458 |
memset(bufferif2, 0, 256); |
|---|
| 2459 |
getIfList(bufferif, "eth"); |
|---|
| 2460 |
#ifdef HAVE_GATEWORX |
|---|
| 2461 |
getIfList(bufferif2, "ixp"); |
|---|
| 2462 |
sprintf(bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2463 |
#endif |
|---|
| 2464 |
|
|---|
| 2465 |
memset(bufferif2, 0, 256); |
|---|
| 2466 |
getIfList(bufferif2, "vlan"); |
|---|
| 2467 |
sprintf(bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2468 |
|
|---|
| 2469 |
memset(bufferif2, 0, 256); |
|---|
| 2470 |
getIfList(bufferif2, "wl"); |
|---|
| 2471 |
sprintf(bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2472 |
|
|---|
| 2473 |
memset(bufferif2, 0, 256); |
|---|
| 2474 |
getIfList(bufferif2, "ofdm"); |
|---|
| 2475 |
sprintf(bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2476 |
|
|---|
| 2477 |
#ifdef HAVE_RT2880 |
|---|
| 2478 |
memset(bufferif2, 0, 256); |
|---|
| 2479 |
getIfList(bufferif2, "ra"); |
|---|
| 2480 |
sprintf(bufferif, "%s %s", bufferif, bufferif2); |
|---|
| 2481 |
#endif |
|---|
| 2482 |
memset(bufferif2, 0, 256); |
|---|
| 2483 |
getIfList(bufferif2, "br"); |
|---|
| 2484 |
foreach(word, bufferif2, next) { |
|---|
| 2485 |
if (contains(word, '.')) |
|---|
| 2486 |
sprintf(bufferif, "%s %s", bufferif, word); |
|---|
| 2487 |
} |
|---|
| 2488 |
int i; |
|---|
| 2489 |
|
|---|
| 2490 |
#ifdef HAVE_MADWIFI |
|---|
| 2491 |
memset(bufferif2, 0, 256); |
|---|
| 2492 |
getIfList(bufferif2, "ath"); |
|---|
| 2493 |
foreach(word, bufferif2, next) { |
|---|
| 2494 |
if (contains(word, '.')) |
|---|
| 2495 |
sprintf(bufferif, "%s %s", bufferif, word); |
|---|
| 2496 |
} |
|---|
| 2497 |
int c = getifcount("wifi"); |
|---|
| 2498 |
|
|---|
| 2499 |
for (i = 0; i < c; i++) { |
|---|
| 2500 |
char ath[32]; |
|---|
| 2501 |
|
|---|
| 2502 |
sprintf(ath, "ath%d_bridged", i); |
|---|
| 2503 |
if (nvram_default_match(ath, "1", "1")) { |
|---|
| 2504 |
sprintf(bufferif, "%s ath%d", bufferif, i); |
|---|
| 2505 |
char vifs[32]; |
|---|
| 2506 |
|
|---|
| 2507 |
sprintf(vifs, "ath%d_vifs", i); |
|---|
| 2508 |
sprintf(bufferif, "%s %s", bufferif, |
|---|
| 2509 |
nvram_safe_get(vifs)); |
|---|
| 2510 |
} |
|---|
| 2511 |
} |
|---|
| 2512 |
#endif |
|---|
| 2513 |
#ifdef HAVE_BONDING |
|---|
| 2514 |
c = atoi(nvram_default_get("bonding_number", "1")); |
|---|
| 2515 |
for (i = 0; i < c; i++) { |
|---|
| 2516 |
sprintf(bufferif, "%s bond%d", bufferif, i); |
|---|
| 2517 |
} |
|---|
| 2518 |
#endif |
|---|
| 2519 |
#ifdef HAVE_EOP_TUNNEL |
|---|
| 2520 |
for (i = 1; i < 11; i++) { |
|---|
| 2521 |
char EOP[32]; |
|---|
| 2522 |
|
|---|
| 2523 |
if (nvram_nmatch("1", "oet%d_en", i) |
|---|
| 2524 |
&& nvram_nmatch("0", "oet%d_bridged", i)) { |
|---|
| 2525 |
sprintf(EOP, "oet%d", i); |
|---|
| 2526 |
sprintf(bufferif, "%s %s", bufferif, EOP); |
|---|
| 2527 |
} |
|---|
| 2528 |
} |
|---|
| 2529 |
#endif |
|---|
| 2530 |
char buffer[256]; |
|---|
| 2531 |
|
|---|
| 2532 |
memset(buffer, 0, 256); |
|---|
| 2533 |
getIfList(buffer, "br"); |
|---|
| 2534 |
|
|---|
| 2535 |
memset(finalbuffer, 0, 256); |
|---|
| 2536 |
foreach(word, buffer, next) { |
|---|
| 2537 |
if (!contains(word, '.')) |
|---|
| 2538 |
sprintf(finalbuffer, "%s %s", finalbuffer, word); |
|---|
| 2539 |
} |
|---|
| 2540 |
char *checkbuffer = malloc(strlen(finalbuffer) + 6); |
|---|
| 2541 |
memset(checkbuffer, 0, strlen(finalbuffer) + 6); |
|---|
| 2542 |
strcpy(checkbuffer, "none "); |
|---|
| 2543 |
strcat(checkbuffer, finalbuffer); |
|---|
| 2544 |
strcpy(finalbuffer, checkbuffer); |
|---|
| 2545 |
free(checkbuffer); |
|---|
| 2546 |
int realcount = atoi(nvram_default_get("bridgesif_count", "0")); |
|---|
| 2547 |
|
|---|
| 2548 |
wordlist = nvram_safe_get("bridgesif"); |
|---|
| 2549 |
foreach(word, wordlist, next) { |
|---|
| 2550 |
char *port = word; |
|---|
| 2551 |
char *tag = strsep(&port, ">"); |
|---|
| 2552 |
char *prio = port; |
|---|
| 2553 |
|
|---|
| 2554 |
strsep(&prio, ">"); |
|---|
| 2555 |
if (!tag || !port) |
|---|
| 2556 |
break; |
|---|
| 2557 |
char vlan_name[32]; |
|---|
| 2558 |
|
|---|
| 2559 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2560 |
websWrite(wp, "<div class=\"label\">Assignment %d</div>\n", |
|---|
| 2561 |
count); |
|---|
| 2562 |
sprintf(vlan_name, "bridge%d", count); |
|---|
| 2563 |
showOptions(wp, vlan_name, finalbuffer, tag); |
|---|
| 2564 |
websWrite(wp, " Interface "); |
|---|
| 2565 |
sprintf(vlan_name, "bridgeif%d", count); |
|---|
| 2566 |
showOptions(wp, vlan_name, bufferif, port); |
|---|
| 2567 |
websWrite(wp, " Prio "); |
|---|
| 2568 |
sprintf(vlan_name, "bridgeifprio%d", count); |
|---|
| 2569 |
websWrite(wp, |
|---|
| 2570 |
"<input class=\"num\" name=\"%s\"size=\"3\" value=\"%s\" />\n", |
|---|
| 2571 |
vlan_name, prio != NULL ? prio : "63"); |
|---|
| 2572 |
websWrite(wp, |
|---|
| 2573 |
"<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"bridgeif_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 2574 |
count); |
|---|
| 2575 |
websWrite(wp, "</div>\n"); |
|---|
| 2576 |
count++; |
|---|
| 2577 |
} |
|---|
| 2578 |
int totalcount = count; |
|---|
| 2579 |
|
|---|
| 2580 |
for (i = count; i < realcount; i++) { |
|---|
| 2581 |
char vlan_name[32]; |
|---|
| 2582 |
|
|---|
| 2583 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2584 |
websWrite(wp, "<div class=\"label\">Assignment %d</div>\n", i); |
|---|
| 2585 |
sprintf(vlan_name, "bridge%d", i); |
|---|
| 2586 |
showOptions(wp, vlan_name, finalbuffer, ""); |
|---|
| 2587 |
websWrite(wp, " Interface "); |
|---|
| 2588 |
sprintf(vlan_name, "bridgeif%d", i); |
|---|
| 2589 |
showOptions(wp, vlan_name, bufferif, ""); |
|---|
| 2590 |
websWrite(wp, " Prio "); |
|---|
| 2591 |
sprintf(vlan_name, "bridgeifprio%d", i); |
|---|
| 2592 |
websWrite(wp, |
|---|
| 2593 |
"<input class=\"num\" name=\"%s\"size=\"5\" value=\"%s\" />\n", |
|---|
| 2594 |
vlan_name, "63"); |
|---|
| 2595 |
websWrite(wp, |
|---|
| 2596 |
"<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.del + \"\\\" onclick=\\\"bridgeif_del_submit(this.form,%d)\\\" />\");\n//]]>\n</script>\n", |
|---|
| 2597 |
i); |
|---|
| 2598 |
websWrite(wp, "</div>\n"); |
|---|
| 2599 |
totalcount++; |
|---|
| 2600 |
} |
|---|
| 2601 |
websWrite(wp, |
|---|
| 2602 |
"<script type=\"text/javascript\">\n//<![CDATA[\n document.write(\"<input class=\\\"button\\\" type=\\\"button\\\" value=\\\"\" + sbutton.add + \"\\\" onclick=\\\"bridgeif_add_submit(this.form)\\\" />\");\n//]]>\n</script>\n"); |
|---|
| 2603 |
char var[32]; |
|---|
| 2604 |
|
|---|
| 2605 |
sprintf(var, "%d", totalcount); |
|---|
| 2606 |
nvram_set("bridgesif_count", var); |
|---|
| 2607 |
} |
|---|
| 2608 |
|
|---|
| 2609 |
#endif |
|---|
| 2610 |
#if 0 |
|---|
| 2611 |
static void |
|---|
| 2612 |
showDynOption(webs_t wp, char *propname, char *nvname, char *options[], |
|---|
| 2613 |
char *names[]) |
|---|
| 2614 |
{ |
|---|
| 2615 |
int i; |
|---|
| 2616 |
|
|---|
| 2617 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2618 |
websWrite(wp, |
|---|
| 2619 |
"<div class=\"label\">%s</div><select name=\"%s\">\n", |
|---|
| 2620 |
propname, nvname); |
|---|
| 2621 |
for (i = 0; options[i] != NULL; i++) { |
|---|
| 2622 |
websWrite(wp, |
|---|
| 2623 |
"<option value=\"%s\" %s>Off</option>\n", |
|---|
| 2624 |
names[i], nvram_match(nvname, |
|---|
| 2625 |
options[i]) ? |
|---|
| 2626 |
"selected=\"selected\"" : ""); |
|---|
| 2627 |
} |
|---|
| 2628 |
websWrite(wp, "</div>\n"); |
|---|
| 2629 |
|
|---|
| 2630 |
} |
|---|
| 2631 |
#endif |
|---|
| 2632 |
|
|---|
| 2633 |
static void show_channel(webs_t wp, char *dev, char *prefix, int type) |
|---|
| 2634 |
{ |
|---|
| 2635 |
char wl_mode[16]; |
|---|
| 2636 |
|
|---|
| 2637 |
sprintf(wl_mode, "%s_mode", prefix); |
|---|
| 2638 |
char wl_net_mode[16]; |
|---|
| 2639 |
|
|---|
| 2640 |
sprintf(wl_net_mode, "%s_net_mode", prefix); |
|---|
| 2641 |
if (nvram_match(wl_net_mode, "disabled")) |
|---|
| 2642 |
return; |
|---|
| 2643 |
#ifdef HAVE_RT2880 |
|---|
| 2644 |
if (nvram_match(wl_mode, "ap") || nvram_match(wl_mode, "wdsap") |
|---|
| 2645 |
|| nvram_match(wl_mode, "apsta") || nvram_match(wl_mode, "apstawet") |
|---|
| 2646 |
|| nvram_match(wl_mode, "infra")) |
|---|
| 2647 |
#else |
|---|
| 2648 |
if (nvram_match(wl_mode, "ap") || nvram_match(wl_mode, "wdsap") |
|---|
| 2649 |
|| nvram_match(wl_mode, "infra")) |
|---|
| 2650 |
#endif |
|---|
| 2651 |
{ |
|---|
| 2652 |
char wl_channel[16]; |
|---|
| 2653 |
|
|---|
| 2654 |
sprintf(wl_channel, "%s_channel", prefix); |
|---|
| 2655 |
char wl_wchannel[16]; |
|---|
| 2656 |
|
|---|
| 2657 |
sprintf(wl_wchannel, "%s_wchannel", prefix); |
|---|
| 2658 |
char wl_nbw[16]; |
|---|
| 2659 |
|
|---|
| 2660 |
nvram_default_get(wl_wchannel, "0"); |
|---|
| 2661 |
sprintf(wl_nbw, "%s_nbw", prefix); |
|---|
| 2662 |
|
|---|
| 2663 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2664 |
websWrite(wp, |
|---|
| 2665 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label4)</script></div>\n<select name=\"%s\" onfocus=\"check_action(this,0)\"><script type=\"text/javascript\">\n//<![CDATA[\n", |
|---|
| 2666 |
wl_channel); |
|---|
| 2667 |
#ifdef HAVE_MADWIFI |
|---|
| 2668 |
struct wifi_channels *chan; |
|---|
| 2669 |
char cn[32]; |
|---|
| 2670 |
char fr[32]; |
|---|
| 2671 |
|
|---|
| 2672 |
chan = list_channels(prefix); |
|---|
| 2673 |
if (chan == NULL) |
|---|
| 2674 |
chan = list_channels(dev); |
|---|
| 2675 |
if (chan != NULL) { |
|---|
| 2676 |
// int cnt = getchannelcount (); |
|---|
| 2677 |
websWrite(wp, |
|---|
| 2678 |
"document.write(\"<option value=\\\"0\\\" %s>\" + share.auto + \"</option>\");\n", |
|---|
| 2679 |
nvram_match(wl_channel, |
|---|
| 2680 |
"0") ? "selected=\\\"selected\\\"" |
|---|
| 2681 |
: ""); |
|---|
| 2682 |
int i = 0; |
|---|
| 2683 |
|
|---|
| 2684 |
while (chan[i].freq != -1) { |
|---|
| 2685 |
cprintf("%d\n", chan[i].channel); |
|---|
| 2686 |
cprintf("%d\n", chan[i].freq); |
|---|
| 2687 |
|
|---|
| 2688 |
sprintf(cn, "%d", chan[i].channel); |
|---|
| 2689 |
sprintf(fr, "%d", chan[i].freq); |
|---|
| 2690 |
websWrite(wp, |
|---|
| 2691 |
"document.write(\"<option value=\\\"%s\\\" %s>%s - %d MHz</option>\");\n", |
|---|
| 2692 |
fr, nvram_match(wl_channel, |
|---|
| 2693 |
fr) ? |
|---|
| 2694 |
"selected=\\\"selected\\\"" : "", cn, |
|---|
| 2695 |
(chan[i].freq + |
|---|
| 2696 |
get_wifioffset(prefix))); |
|---|
| 2697 |
// free (chan[i].freq); |
|---|
| 2698 |
i++; |
|---|
| 2699 |
} |
|---|
| 2700 |
free(chan); |
|---|
| 2701 |
} |
|---|
| 2702 |
#else |
|---|
| 2703 |
int instance = 0; |
|---|
| 2704 |
|
|---|
| 2705 |
if (!strcmp(prefix, "wl1")) |
|---|
| 2706 |
instance = 1; |
|---|
| 2707 |
#if 0 |
|---|
| 2708 |
if (type == 1 && !nvram_match(wl_net_mode, "g-only") |
|---|
| 2709 |
&& !nvram_match(wl_net_mode, "a-only") |
|---|
| 2710 |
&& !nvram_match(wl_net_mode, "na-only") |
|---|
| 2711 |
&& !nvram_match(wl_net_mode, "bg-mixed") |
|---|
| 2712 |
&& nvram_match(wl_nbw, "40")) { |
|---|
| 2713 |
int ch = atoi(nvram_nget("wl%d_wchannel", instance)); |
|---|
| 2714 |
|
|---|
| 2715 |
websWrite(wp, "var max_channel = 2;\n"); |
|---|
| 2716 |
websWrite(wp, "var wl%d_channel = '%s';\n", instance, |
|---|
| 2717 |
nvram_safe_get(wl_wchannel)); |
|---|
| 2718 |
websWrite(wp, |
|---|
| 2719 |
"var freq = new Array(\"Auto\",\"2.412\",\"2.417\",\"2.422\",\"2.427\",\"2.432\",\"2.437\",\"2.442\",\"2.447\",\"2.452\",\"2.457\",\"2.462\",\"2.467\",\"2.472\",\"2.484\");\n"); |
|---|
| 2720 |
char *sel = ""; |
|---|
| 2721 |
|
|---|
| 2722 |
if (ch == 0) //wchannel = Auto |
|---|
| 2723 |
{ |
|---|
| 2724 |
websWrite(wp, |
|---|
| 2725 |
" document.write(\"<option value=\\\"0\\\" selected=\\\"selected\\\">\"+ share.auto +\"</option>\");\n"); |
|---|
| 2726 |
} else { |
|---|
| 2727 |
if (nvram_nmatch |
|---|
| 2728 |
("lower", "wl%d_nctrlsb", instance)) |
|---|
| 2729 |
sel = "selected=\\\"selected\\\""; |
|---|
| 2730 |
|
|---|
| 2731 |
websWrite(wp, |
|---|
| 2732 |
" document.write(\"<option value=\\\"%d\\\" %s>%d - \"+freq[%d]+\" GHz</option>\");\n", |
|---|
| 2733 |
ch - 2, sel, ch - 2, ch - 2); |
|---|
| 2734 |
sel = ""; |
|---|
| 2735 |
if (nvram_nmatch |
|---|
| 2736 |
("upper", "wl%d_nctrlsb", instance)) |
|---|
| 2737 |
sel = "selected=\\\"selected\\\""; |
|---|
| 2738 |
websWrite(wp, |
|---|
| 2739 |
" document.write(\"<option value=\\\"%d\\\" %s>%d - \"+freq[%d]+\" GHz</option>\");\n", |
|---|
| 2740 |
ch + 2, sel, ch + 2, ch + 2); |
|---|
| 2741 |
} |
|---|
| 2742 |
|
|---|
| 2743 |
} else |
|---|
| 2744 |
#endif |
|---|
| 2745 |
{ |
|---|
| 2746 |
|
|---|
| 2747 |
unsigned int chanlist[128]; |
|---|
| 2748 |
char *ifn = get_wl_instance_name(instance); |
|---|
| 2749 |
int chancount = getchannels(chanlist, ifn); |
|---|
| 2750 |
|
|---|
| 2751 |
// websWrite( wp, "var max_channel = %d;\n", chancount ); |
|---|
| 2752 |
// websWrite( wp, "var wl%d_channel = '%s';\n", instance, nvram_safe_get( wl_channel ) ); |
|---|
| 2753 |
// websWrite( wp, "var offset = %d;\n", chanlist[0] ); |
|---|
| 2754 |
// websWrite( wp, "var buf = \"\";\n" ); |
|---|
| 2755 |
// websWrite( wp, "var freq = new Array(\"Auto\"" ); |
|---|
| 2756 |
int i, j; |
|---|
| 2757 |
|
|---|
| 2758 |
// supported 5GHz channels for IEEE 802.11n 40Mhz |
|---|
| 2759 |
int na_upper[16] = |
|---|
| 2760 |
{ 40, 48, 56, 64, 104, 112, 120, 128, 136, 153, 161, |
|---|
| 2761 |
0, 0, 0, 0, 0 }; |
|---|
| 2762 |
int na_lower[16] = |
|---|
| 2763 |
{ 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157, |
|---|
| 2764 |
0, 0, 0, 0, 0 }; |
|---|
| 2765 |
|
|---|
| 2766 |
websWrite(wp, |
|---|
| 2767 |
"document.write(\"<option value=\\\"0\\\" %s>\" + share.auto + \"</option>\");\n", |
|---|
| 2768 |
nvram_nmatch("0", "%s_channel", |
|---|
| 2769 |
prefix) ? |
|---|
| 2770 |
"selected=\\\"selected\\\"" : ""); |
|---|
| 2771 |
for (i = 0; i < chancount; i++) { |
|---|
| 2772 |
float ofs; |
|---|
| 2773 |
|
|---|
| 2774 |
if (chanlist[i] < 25) |
|---|
| 2775 |
ofs = 2.407f; |
|---|
| 2776 |
else |
|---|
| 2777 |
ofs = 5.000f; |
|---|
| 2778 |
ofs += (float)(chanlist[i] * 0.005f); |
|---|
| 2779 |
if (ofs == 2.477f) |
|---|
| 2780 |
ofs = 2.484f; // fix: ch 14 is 2.484, not 2.477 GHz |
|---|
| 2781 |
// websWrite( wp, ", \"%0.3f\"", ofs ); |
|---|
| 2782 |
char channelstring[32]; |
|---|
| 2783 |
|
|---|
| 2784 |
int showit = 1; |
|---|
| 2785 |
|
|---|
| 2786 |
if (nvram_match(wl_net_mode, "a-only") |
|---|
| 2787 |
|| nvram_match(wl_net_mode, "na-only")) { |
|---|
| 2788 |
if (chanlist[i] < 25) |
|---|
| 2789 |
showit = 0; |
|---|
| 2790 |
} else { |
|---|
| 2791 |
if (chanlist[i] > 25) |
|---|
| 2792 |
showit = 0; |
|---|
| 2793 |
} |
|---|
| 2794 |
|
|---|
| 2795 |
if (nvram_match(wl_net_mode, "na-only") |
|---|
| 2796 |
&& nvram_match(wl_nbw, "40")) { |
|---|
| 2797 |
showit = 0; |
|---|
| 2798 |
j = 0; |
|---|
| 2799 |
if (nvram_nmatch |
|---|
| 2800 |
("upper", "%s_nctrlsb", prefix)) { |
|---|
| 2801 |
while (na_upper[j]) { |
|---|
| 2802 |
if (chanlist[i] == |
|---|
| 2803 |
na_upper[j]) { |
|---|
| 2804 |
showit = 1; |
|---|
| 2805 |
break; |
|---|
| 2806 |
} |
|---|
| 2807 |
j++; |
|---|
| 2808 |
} |
|---|
| 2809 |
} else |
|---|
| 2810 |
if (nvram_nmatch |
|---|
| 2811 |
("lower", "%s_nctrlsb", |
|---|
| 2812 |
prefix)) { |
|---|
| 2813 |
while (na_lower[j]) { |
|---|
| 2814 |
if (chanlist[i] == |
|---|
| 2815 |
na_lower[j]) { |
|---|
| 2816 |
showit = 1; |
|---|
| 2817 |
break; |
|---|
| 2818 |
} |
|---|
| 2819 |
j++; |
|---|
| 2820 |
} |
|---|
| 2821 |
} |
|---|
| 2822 |
} |
|---|
| 2823 |
|
|---|
| 2824 |
if ((nvram_match(wl_net_mode, "n-only") |
|---|
| 2825 |
|| nvram_match(wl_net_mode, "mixed")) |
|---|
| 2826 |
&& nvram_match(wl_nbw, "40")) { |
|---|
| 2827 |
showit = 0; |
|---|
| 2828 |
if (nvram_nmatch |
|---|
| 2829 |
("upper", "%s_nctrlsb", prefix)) { |
|---|
| 2830 |
if (chanlist[i] >= 5 |
|---|
| 2831 |
&& chanlist[i] <= 13) { |
|---|
| 2832 |
showit = 1; |
|---|
| 2833 |
} |
|---|
| 2834 |
} else |
|---|
| 2835 |
if (nvram_nmatch |
|---|
| 2836 |
("lower", "%s_nctrlsb", |
|---|
| 2837 |
prefix)) { |
|---|
| 2838 |
if (chanlist[i] <= 9) { |
|---|
| 2839 |
showit = 1; |
|---|
| 2840 |
} |
|---|
| 2841 |
} |
|---|
| 2842 |
} |
|---|
| 2843 |
|
|---|
| 2844 |
sprintf(channelstring, "%d", chanlist[i]); |
|---|
| 2845 |
if (showit) { |
|---|
| 2846 |
websWrite(wp, |
|---|
| 2847 |
"document.write(\"<option value=\\\"%d\\\" %s>%d - %0.3f GHz</option>\");\n", |
|---|
| 2848 |
chanlist[i], |
|---|
| 2849 |
nvram_nmatch(channelstring, |
|---|
| 2850 |
"%s_channel", |
|---|
| 2851 |
prefix) ? |
|---|
| 2852 |
"selected=\\\"selected\\\"" : |
|---|
| 2853 |
"", chanlist[i], ofs); |
|---|
| 2854 |
} |
|---|
| 2855 |
} |
|---|
| 2856 |
// websWrite( wp, ");\n" ); |
|---|
| 2857 |
// websWrite( wp, "for(i=0; i<=max_channel ; i++) {\n" ); |
|---|
| 2858 |
// websWrite( wp, " if(i == wl%d_channel) buf = \"selected\";\n", |
|---|
| 2859 |
// instance ); |
|---|
| 2860 |
// websWrite( wp, " else buf = \"\";\n" ); |
|---|
| 2861 |
// websWrite( wp, " if (i==0)\n" ); |
|---|
| 2862 |
// websWrite( wp, |
|---|
| 2863 |
// " document.write(\"<option value=\"+i+\" \"+buf+\">\" + share.auto + \"</option>\");\n" ); |
|---|
| 2864 |
// websWrite( wp, " else\n" ); |
|---|
| 2865 |
// websWrite( wp, |
|---|
| 2866 |
// " document.write(\"<option value=\"+i+\" \"+buf+\">\"+(i+offset-1)+\" - \"+freq[i]+\" GHz</option>\");\n" ); |
|---|
| 2867 |
// websWrite( wp, "}\n" ); |
|---|
| 2868 |
} |
|---|
| 2869 |
#endif |
|---|
| 2870 |
websWrite(wp, "//]]>\n</script></select></div>\n"); |
|---|
| 2871 |
} |
|---|
| 2872 |
} |
|---|
| 2873 |
|
|---|
| 2874 |
#ifdef HAVE_MADWIFI |
|---|
| 2875 |
static char *ag_rates[] = { "6", "9", "12", "18", "24", "36", "48", "54" }; |
|---|
| 2876 |
static char *turbo_rates[] = |
|---|
| 2877 |
{ "12", "18", "24", "36", "48", "72", "96", "108" }; |
|---|
| 2878 |
static char *b_rates[] = { "1", "2", "5.5", "11" }; |
|---|
| 2879 |
static char *bg_rates[] = |
|---|
| 2880 |
{ "1", "2", "5.5", "6", "9", "11", "12", "18", "24", "36", "48", "54" }; |
|---|
| 2881 |
// static char *g_rates[] = { "1", "2", "5.5", "11", "12", "18", "24", "36", |
|---|
| 2882 |
// "48", "54" }; |
|---|
| 2883 |
//static char *xr_rates[] = |
|---|
| 2884 |
// { "0.25", "0.5", "1", "2", "3", "6", "9", "12", "18", "24", "36", "48", |
|---|
| 2885 |
// "54" |
|---|
| 2886 |
//}; |
|---|
| 2887 |
static char *half_rates[] = { "3", "4.5", "6", "9", "12", "18", "24", "27" }; |
|---|
| 2888 |
static char *quarter_rates[] = |
|---|
| 2889 |
{ "1.5", "2", "3", "4.5", "6", "9", "12", "13.5" }; |
|---|
| 2890 |
static char *subquarter_rates[] = |
|---|
| 2891 |
{ "0.75", "1", "1.5", "2.25", "3", "4.5", "6", "6.75" }; |
|---|
| 2892 |
|
|---|
| 2893 |
void show_rates(webs_t wp, char *prefix, int maxrate) |
|---|
| 2894 |
{ |
|---|
| 2895 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 2896 |
if (maxrate) { |
|---|
| 2897 |
websWrite(wp, |
|---|
| 2898 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label21)</script></div>\n"); |
|---|
| 2899 |
websWrite(wp, "<select name=\"%s_maxrate\">\n", prefix); |
|---|
| 2900 |
} else { |
|---|
| 2901 |
websWrite(wp, |
|---|
| 2902 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(wl_adv.label23)</script></div>\n"); |
|---|
| 2903 |
websWrite(wp, "<select name=\"%s_minrate\">\n", prefix); |
|---|
| 2904 |
} |
|---|
| 2905 |
websWrite(wp, "<script type=\"text/javascript\">\n"); |
|---|
| 2906 |
websWrite(wp, "//<![CDATA[\n"); |
|---|
| 2907 |
char srate[32]; |
|---|
| 2908 |
|
|---|
| 2909 |
sprintf(srate, "%s_minrate", prefix); |
|---|
| 2910 |
char mxrate[32]; |
|---|
| 2911 |
|
|---|
| 2912 |
sprintf(mxrate, "%s_maxrate", prefix); |
|---|
| 2913 |
websWrite(wp, |
|---|
| 2914 |
"document.write(\"<option value=\\\"0\\\" %s >\" + share.auto + \"</option>\");\n", |
|---|
| 2915 |
nvram_match(srate, "0") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 2916 |
websWrite(wp, "//]]>\n"); |
|---|
| 2917 |
websWrite(wp, "</script>\n"); |
|---|
| 2918 |
char **rate; |
|---|
| 2919 |
char **showrates = NULL; |
|---|
| 2920 |
int len; |
|---|
| 2921 |
char mode[32]; |
|---|
| 2922 |
char bw[16]; |
|---|
| 2923 |
|
|---|
| 2924 |
sprintf(bw, "%s_channelbw", prefix); |
|---|
| 2925 |
|
|---|
| 2926 |
sprintf(mode, "%s_net_mode", prefix); |
|---|
| 2927 |
if (nvram_match(mode, "b-only")) { |
|---|
| 2928 |
rate = b_rates; |
|---|
| 2929 |
len = sizeof(b_rates) / sizeof(char *); |
|---|
| 2930 |
} |
|---|
| 2931 |
if (nvram_match(mode, "g-only")) { |
|---|
| 2932 |
rate = ag_rates; |
|---|
| 2933 |
len = sizeof(ag_rates) / sizeof(char *); |
|---|
| 2934 |
if (nvram_match(bw, "40")) { |
|---|
| 2935 |
showrates = turbo_rates; |
|---|
| 2936 |
} |
|---|
| 2937 |
if (nvram_match(bw, "10")) { |
|---|
| 2938 |
rate = half_rates; |
|---|
| 2939 |
len = sizeof(half_rates) / sizeof(char *); |
|---|
| 2940 |
} |
|---|
| 2941 |
if (nvram_match(bw, "5")) { |
|---|
| 2942 |
rate = quarter_rates; |
|---|
| 2943 |
len = sizeof(quarter_rates) / sizeof(char *); |
|---|
| 2944 |
} |
|---|
| 2945 |
if (nvram_match(bw, "2")) { |
|---|
| 2946 |
rate = subquarter_rates; |
|---|
| 2947 |
len = sizeof(subquarter_rates) / sizeof(char *); |
|---|
| 2948 |
} |
|---|
| 2949 |
} |
|---|
| 2950 |
if (nvram_match(mode, "a-only")) { |
|---|
| 2951 |
rate = ag_rates; |
|---|
| 2952 |
len = sizeof(ag_rates) / sizeof(char *); |
|---|
| 2953 |
if (nvram_match(bw, "40")) { |
|---|
| 2954 |
showrates = turbo_rates; |
|---|
| 2955 |
} |
|---|
| 2956 |
if (nvram_match(bw, "10")) { |
|---|
| 2957 |
rate = half_rates; |
|---|
| 2958 |
len = sizeof(half_rates) / sizeof(char *); |
|---|
| 2959 |
} |
|---|
| 2960 |
if (nvram_match(bw, "5")) { |
|---|
| 2961 |
rate = quarter_rates; |
|---|
| 2962 |
len = sizeof(quarter_rates) / sizeof(char *); |
|---|
| 2963 |
} |
|---|
| 2964 |
if (nvram_match(bw, "2")) { |
|---|
| 2965 |
rate = subquarter_rates; |
|---|
| 2966 |
len = sizeof(subquarter_rates) / sizeof(char *); |
|---|
| 2967 |
} |
|---|
| 2968 |
} |
|---|
| 2969 |
if (nvram_match(mode, "bg-mixed")) { |
|---|
| 2970 |
rate = bg_rates; |
|---|
| 2971 |
len = sizeof(bg_rates) / sizeof(char *); |
|---|
| 2972 |
if (nvram_match(bw, "10")) { |
|---|
| 2973 |
rate = half_rates; |
|---|
| 2974 |
len = sizeof(half_rates) / sizeof(char *); |
|---|
| 2975 |
} |
|---|
| 2976 |
if (nvram_match(bw, "5")) { |
|---|
| 2977 |
rate = quarter_rates; |
|---|
| 2978 |
len = sizeof(quarter_rates) / sizeof(char *); |
|---|
| 2979 |
} |
|---|
| 2980 |
if (nvram_match(bw, "2")) { |
|---|
| 2981 |
rate = subquarter_rates; |
|---|
| 2982 |
len = sizeof(subquarter_rates) / sizeof(char *); |
|---|
| 2983 |
} |
|---|
| 2984 |
} |
|---|
| 2985 |
if (nvram_match(mode, "mixed")) { |
|---|
| 2986 |
rate = bg_rates; |
|---|
| 2987 |
len = sizeof(bg_rates) / sizeof(char *); |
|---|
| 2988 |
if (nvram_match(bw, "40")) { |
|---|
| 2989 |
rate = ag_rates; |
|---|
| 2990 |
len = sizeof(ag_rates) / sizeof(char *); |
|---|
| 2991 |
showrates = turbo_rates; |
|---|
| 2992 |
} |
|---|
| 2993 |
if (nvram_match(bw, "10")) { |
|---|
| 2994 |
rate = half_rates; |
|---|
| 2995 |
len = sizeof(half_rates) / sizeof(char *); |
|---|
| 2996 |
} |
|---|
| 2997 |
if (nvram_match(bw, "5")) { |
|---|
| 2998 |
rate = quarter_rates; |
|---|
| 2999 |
len = sizeof(quarter_rates) / sizeof(char *); |
|---|
| 3000 |
} |
|---|
| 3001 |
if (nvram_match(bw, "2")) { |
|---|
| 3002 |
rate = subquarter_rates; |
|---|
| 3003 |
len = sizeof(subquarter_rates) / sizeof(char *); |
|---|
| 3004 |
} |
|---|
| 3005 |
} |
|---|
| 3006 |
int i; |
|---|
| 3007 |
|
|---|
| 3008 |
for (i = 0; i < len; i++) { |
|---|
| 3009 |
if (maxrate) { |
|---|
| 3010 |
int offset = 0; |
|---|
| 3011 |
|
|---|
| 3012 |
if (nvram_match(mode, "g-only") |
|---|
| 3013 |
&& nvram_match(bw, "20")) |
|---|
| 3014 |
offset = 4; |
|---|
| 3015 |
char comp[32]; |
|---|
| 3016 |
|
|---|
| 3017 |
sprintf(comp, "%d", i + 1 + offset); |
|---|
| 3018 |
if (showrates) |
|---|
| 3019 |
websWrite(wp, |
|---|
| 3020 |
"<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 3021 |
i + 1 + offset, nvram_match(mxrate, |
|---|
| 3022 |
comp) ? |
|---|
| 3023 |
"selected=\"selected\"" : "", |
|---|
| 3024 |
showrates[i]); |
|---|
| 3025 |
else |
|---|
| 3026 |
websWrite(wp, |
|---|
| 3027 |
"<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 3028 |
i + 1 + offset, nvram_match(mxrate, |
|---|
| 3029 |
comp) ? |
|---|
| 3030 |
"selected=\"selected\"" : "", |
|---|
| 3031 |
rate[i]); |
|---|
| 3032 |
} else { |
|---|
| 3033 |
int offset = 0; |
|---|
| 3034 |
|
|---|
| 3035 |
if (nvram_match(mode, "g-only") |
|---|
| 3036 |
&& nvram_match(bw, "20")) |
|---|
| 3037 |
offset = 4; |
|---|
| 3038 |
char comp[32]; |
|---|
| 3039 |
|
|---|
| 3040 |
sprintf(comp, "%d", i + 1 + offset); |
|---|
| 3041 |
if (showrates) |
|---|
| 3042 |
websWrite(wp, |
|---|
| 3043 |
"<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 3044 |
i + 1 + offset, nvram_match(srate, |
|---|
| 3045 |
comp) ? |
|---|
| 3046 |
"selected=\"selected\"" : "", |
|---|
| 3047 |
showrates[i]); |
|---|
| 3048 |
else |
|---|
| 3049 |
websWrite(wp, |
|---|
| 3050 |
"<option value=\"%d\" %s >%s Mbps</option>\n", |
|---|
| 3051 |
i + 1 + offset, nvram_match(srate, |
|---|
| 3052 |
comp) ? |
|---|
| 3053 |
"selected=\"selected\"" : "", |
|---|
| 3054 |
rate[i]); |
|---|
| 3055 |
|
|---|
| 3056 |
} |
|---|
| 3057 |
} |
|---|
| 3058 |
websWrite(wp, "</select>\n"); |
|---|
| 3059 |
websWrite(wp, "<span class=\"default\">\n"); |
|---|
| 3060 |
websWrite(wp, "<script type=\"text/javascript\">\n"); |
|---|
| 3061 |
websWrite(wp, "//<![CDATA[\n"); |
|---|
| 3062 |
websWrite(wp, |
|---|
| 3063 |
"document.write(\"(\" + share.deflt + \": \" + share.auto + \")\");\n"); |
|---|
| 3064 |
websWrite(wp, "//]]\n"); |
|---|
| 3065 |
websWrite(wp, "</script></span></div>\n"); |
|---|
| 3066 |
|
|---|
| 3067 |
} |
|---|
| 3068 |
#endif |
|---|
| 3069 |
static void show_netmode(webs_t wp, char *prefix) |
|---|
| 3070 |
{ |
|---|
| 3071 |
char wl_net_mode[16]; |
|---|
| 3072 |
|
|---|
| 3073 |
sprintf(wl_net_mode, "%s_net_mode", prefix); |
|---|
| 3074 |
|
|---|
| 3075 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3076 |
websWrite(wp, |
|---|
| 3077 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label2)</script></div><select name=\"%s\">\n", |
|---|
| 3078 |
wl_net_mode); |
|---|
| 3079 |
websWrite(wp, "<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3080 |
websWrite(wp, |
|---|
| 3081 |
"document.write(\"<option value=\\\"disabled\\\" %s>\" + share.disabled + \"</option>\");\n", |
|---|
| 3082 |
nvram_match(wl_net_mode, |
|---|
| 3083 |
"disabled") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3084 |
websWrite(wp, |
|---|
| 3085 |
"document.write(\"<option value=\\\"mixed\\\" %s>\" + wl_basic.mixed + \"</option>\");\n", |
|---|
| 3086 |
nvram_match(wl_net_mode, |
|---|
| 3087 |
"mixed") ? "selected=\\\"selected\\\"" : ""); |
|---|
| 3088 |
#ifdef HAVE_MADWIFI |
|---|
| 3089 |
if (has_mimo(prefix)) |
|---|
| 3090 |
#else |
|---|
| 3091 |
if (has_mimo(prefix) && !nvram_nmatch("a", "%s_bandlist", prefix)) |
|---|
| 3092 |
#endif |
|---|
| 3093 |
{ |
|---|
| 3094 |
websWrite(wp, |
|---|
| 3095 |
"document.write(\"<option value=\\\"bg-mixed\\\" %s>\" + wl_basic.bg + \"</option>\");\n", |
|---|
| 3096 |
nvram_match(wl_net_mode, |
|---|
| 3097 |
"bg-mixed") ? "selected=\\\"selected\\\"" |
|---|
| 3098 |
: ""); |
|---|
| 3099 |
} |
|---|
| 3100 |
#ifdef HAVE_WHRAG108 |
|---|
| 3101 |
if (!strcmp(prefix, "ath1")) |
|---|
| 3102 |
#endif |
|---|
| 3103 |
#ifdef HAVE_TW6600 |
|---|
| 3104 |
if (!strcmp(prefix, "ath1")) |
|---|
| 3105 |
#endif |
|---|
| 3106 |
#ifndef HAVE_MADWIFI |
|---|
| 3107 |
if (!nvram_nmatch("a", "%s_bandlist", prefix)) |
|---|
| 3108 |
#endif |
|---|
| 3109 |
{ |
|---|
| 3110 |
websWrite(wp, |
|---|
| 3111 |
"document.write(\"<option value=\\\"b-only\\\" %s>\" + wl_basic.b + \"</option>\");\n", |
|---|
| 3112 |
nvram_match(wl_net_mode, |
|---|
| 3113 |
"b-only") ? |
|---|
| 3114 |
"selected=\\\"selected\\\"" : ""); |
|---|
| 3115 |
} |
|---|
| 3116 |
#ifdef HAVE_MADWIFI |
|---|
| 3117 |
#ifdef HAVE_WHRAG108 |
|---|
| 3118 |
if (!strcmp(prefix, "ath1")) |
|---|
| 3119 |
#endif |
|---|
| 3120 |
#ifdef HAVE_TW6600 |
|---|
| 3121 |
if (!strcmp(prefix, "ath1")) |
|---|
| 3122 |
#endif |
|---|
| 3123 |
websWrite(wp, |
|---|
| 3124 |
"document.write(\"<option value=\\\"g-only\\\" %s>\" + wl_basic.g + \"</option>\");\n", |
|---|
| 3125 |
nvram_match(wl_net_mode, |
|---|
| 3126 |
"g-only") ? |
|---|
| 3127 |
"selected=\\\"selected\\\"" : ""); |
|---|
| 3128 |
#ifdef HAVE_WHRAG108 |
|---|
| 3129 |
if (!strcmp(prefix, "ath1")) |
|---|
| 3130 |
#endif |
|---|
| 3131 |
#ifdef HAVE_TW6600 |
|---|
| 3132 |
if (!strcmp(prefix, "ath1")) |
|---|
| 3133 |
#endif |
|---|
| 3134 |
#ifndef HAVE_LS5 |
|---|
| 3135 |
websWrite(wp, |
|---|
| 3136 |
"document.write(\"<option value=\\\"bg-mixed\\\" %s>\" + wl_basic.bg + \"</option>\");\n", |
|---|
| 3137 |
nvram_match(wl_net_mode, |
|---|
| 3138 |
"bg-mixed") ? |
|---|
| 3139 |
"selected=\\\"selected\\\"" : ""); |
|---|
| 3140 |
#endif |
|---|
| 3141 |
#else |
|---|
| 3142 |
#ifdef HAVE_WHRAG108 |
|---|
| 3143 |
if (!strcmp(prefix, "ath1")) |
|---|
| 3144 |
#endif |
|---|
| 3145 |
#ifndef HAVE_LS5 |
|---|
| 3146 |
#ifndef HAVE_MADWIFI |
|---|
| 3147 |
if (!nvram_nmatch("a", "%s_bandlist", prefix)) |
|---|
| 3148 |
#endif |
|---|
| 3149 |
{ |
|---|
| 3150 |
websWrite(wp, |
|---|
| 3151 |
"document.write(\"<option value=\\\"g-only\\\" %s>\" + wl_basic.g + \"</option>\");\n", |
|---|
| 3152 |
nvram_match(wl_net_mode, |
|---|
| 3153 |
"g-only") ? |
|---|
| 3154 |
"selected=\\\"selected\\\"" : ""); |
|---|
| 3155 |
} |
|---|
| 3156 |
#endif |
|---|
| 3157 |
#endif |
|---|
| 3158 |
if (has_mimo(prefix) && !nvram_nmatch("a", "%s_bandlist", prefix)) { |
|---|
| 3159 |
websWrite(wp, |
|---|
| 3160 |
"document.write(\"<option value=\\\"n-only\\\" %s>\" + wl_basic.n + \"</option>\");\n", |
|---|
| 3161 |
nvram_match(wl_net_mode, |
|---|
| 3162 |
"n-only") ? "selected=\\\"selected\\\"" : |
|---|
| 3163 |
""); |
|---|
| 3164 |
} |
|---|
| 3165 |
#if !defined(HAVE_FONERA) && !defined(HAVE_LS2) && !defined(HAVE_MERAKI) |
|---|
| 3166 |
#ifndef HAVE_MADWIFI |
|---|
| 3167 |
|
|---|
| 3168 |
if (nvram_nmatch("ga", "%s_phytypes", prefix) |
|---|
| 3169 |
|| nvram_nmatch("a", "%s_phytypes", prefix)) |
|---|
| 3170 |
websWrite(wp, |
|---|
| 3171 |
"document.write(\"<option value=\\\"a-only\\\" %s>\" + wl_basic.a + \"</option>\");\n", |
|---|
| 3172 |
nvram_match(wl_net_mode, |
|---|
| 3173 |
"a-only") ? "selected=\\\"selected\\\"" : |
|---|
| 3174 |
""); |
|---|
| 3175 |
|
|---|
| 3176 |
if (has_mimo(prefix)) { |
|---|
| 3177 |
char band[64]; |
|---|
| 3178 |
|
|---|
| 3179 |
sprintf(band, "%s_bandlist", prefix); |
|---|
| 3180 |
char *b = nvram_safe_get(band); |
|---|
| 3181 |
|
|---|
| 3182 |
if (contains(b, 'a')) { |
|---|
| 3183 |
websWrite(wp, |
|---|
| 3184 |
"document.write(\"<option value=\\\"a-only\\\" %s>\" + wl_basic.a + \"</option>\");\n", |
|---|
| 3185 |
nvram_match(wl_net_mode, |
|---|
| 3186 |
"a-only") ? |
|---|
| 3187 |
"selected=\\\"selected\\\"" : ""); |
|---|
| 3188 |
websWrite(wp, |
|---|
| 3189 |
"document.write(\"<option value=\\\"na-only\\\" %s>\" + wl_basic.na + \"</option>\");\n", |
|---|
| 3190 |
nvram_match(wl_net_mode, |
|---|
| 3191 |
"na-only") ? |
|---|
| 3192 |
"selected=\\\"selected\\\"" : ""); |
|---|
| 3193 |
} |
|---|
| 3194 |
} |
|---|
| 3195 |
#else |
|---|
| 3196 |
#if HAVE_WHRAG108 |
|---|
| 3197 |
if (!strcmp(prefix, "ath0")) |
|---|
| 3198 |
#endif |
|---|
| 3199 |
#ifdef HAVE_TW6600 |
|---|
| 3200 |
if (!strcmp(prefix, "ath0")) |
|---|
| 3201 |
#endif |
|---|
| 3202 |
websWrite(wp, |
|---|
| 3203 |
"document.write(\"<option value=\\\"a-only\\\" %s>\" + wl_basic.a + \"</option>\");\n", |
|---|
| 3204 |
nvram_match(wl_net_mode, |
|---|
| 3205 |
"a-only") ? |
|---|
| 3206 |
"selected=\\\"selected\\\"" : ""); |
|---|
| 3207 |
#endif |
|---|
| 3208 |
|
|---|
| 3209 |
#endif |
|---|
| 3210 |
websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3211 |
websWrite(wp, "</select>\n"); |
|---|
| 3212 |
websWrite(wp, "</div>\n"); |
|---|
| 3213 |
|
|---|
| 3214 |
#ifdef HAVE_RT2880 |
|---|
| 3215 |
if (nvram_nmatch("n-only", "%s_net_mode", prefix)) { |
|---|
| 3216 |
char wl_greenfield[32]; |
|---|
| 3217 |
|
|---|
| 3218 |
sprintf(wl_greenfield, "%s_greenfield", prefix); |
|---|
| 3219 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3220 |
websWrite(wp, |
|---|
| 3221 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.label7)</script></div><select name=\"%s\" >\n", |
|---|
| 3222 |
wl_greenfield); |
|---|
| 3223 |
websWrite(wp, |
|---|
| 3224 |
"<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3225 |
websWrite(wp, |
|---|
| 3226 |
"document.write(\"<option value=\\\"0\\\" %s>\" + wl_basic.mixed + \"</option>\");\n", |
|---|
| 3227 |
nvram_default_match(wl_greenfield, "0", |
|---|
| 3228 |
"0") ? "selected=\\\"selected\\\"" |
|---|
| 3229 |
: ""); |
|---|
| 3230 |
websWrite(wp, |
|---|
| 3231 |
"document.write(\"<option value=\\\"1\\\" %s>\" + wl_basic.greenfield + \"</option>\");\n", |
|---|
| 3232 |
nvram_default_match(wl_greenfield, "1", |
|---|
| 3233 |
"0") ? "selected=\\\"selected\\\"" |
|---|
| 3234 |
: ""); |
|---|
| 3235 |
websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3236 |
websWrite(wp, "</select>\n"); |
|---|
| 3237 |
websWrite(wp, "</div>\n"); |
|---|
| 3238 |
} |
|---|
| 3239 |
#endif |
|---|
| 3240 |
} |
|---|
| 3241 |
|
|---|
| 3242 |
#ifdef HAVE_MADWIFI |
|---|
| 3243 |
static void showrtssettings(webs_t wp, char *var) |
|---|
| 3244 |
{ |
|---|
| 3245 |
char ssid[32]; |
|---|
| 3246 |
char vvar[32]; |
|---|
| 3247 |
|
|---|
| 3248 |
strcpy(vvar, var); |
|---|
| 3249 |
rep(vvar, '.', 'X'); |
|---|
| 3250 |
sprintf(ssid, "%s_rts", var); |
|---|
| 3251 |
websWrite(wp, |
|---|
| 3252 |
"<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.rts)</script></div>\n"); |
|---|
| 3253 |
websWrite(wp, |
|---|
| 3254 |
"<input class=\"spaceradio\" type=\"radio\" value=\"1\" onclick=\"show_layer_ext(this, '%s_idrts', true);\" name=\"%s_rts\" %s><script type=\"text/javascript\">Capture(share.enable)</script></input>\n", |
|---|
| 3255 |
vvar, var, nvram_default_match(ssid, "1", |
|---|
| 3256 |
"0") ? "checked=\"checked\"" : |
|---|
| 3257 |
""); |
|---|
| 3258 |
websWrite(wp, |
|---|
| 3259 |
"<input class=\"spaceradio\" type=\"radio\" value=\"0\" onclick=\"show_layer_ext(this, '%s_idrts', false);\" name=\"%s_rts\" %s><script type=\"text/javascript\">Capture(share.disable)</script></input> \n", |
|---|
| 3260 |
vvar, var, nvram_default_match(ssid, "0", |
|---|
| 3261 |
"0") ? "checked=\"checked\"" : |
|---|
| 3262 |
""); |
|---|
| 3263 |
websWrite(wp, "</div>\n"); |
|---|
| 3264 |
|
|---|
| 3265 |
websWrite(wp, "<div id=\"%s_idrts\">\n", vvar); |
|---|
| 3266 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3267 |
websWrite(wp, |
|---|
| 3268 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.rtsvalue)</script></div>\n"); |
|---|
| 3269 |
char ip[32]; |
|---|
| 3270 |
|
|---|
| 3271 |
sprintf(ip, "%s_rtsvalue", var); |
|---|
| 3272 |
websWrite(wp, |
|---|
| 3273 |
"<input class=\"num\" maxlength=\"4\" size=\"4\" onblur=\"valid_range(this,1,2346,share.ip)\" name=\"%s_rtsvalue\" value=\"%s\" />", |
|---|
| 3274 |
var, nvram_default_get(ip, "2346")); |
|---|
| 3275 |
websWrite(wp, "</div>\n"); |
|---|
| 3276 |
websWrite(wp, "</div>\n"); |
|---|
| 3277 |
|
|---|
| 3278 |
websWrite(wp, "<script>\n//<![CDATA[\n "); |
|---|
| 3279 |
websWrite(wp, |
|---|
| 3280 |
"show_layer_ext(document.getElementsByName(\"%s_rts\"), \"%s_idrts\", %s);\n", |
|---|
| 3281 |
var, vvar, nvram_match(ssid, "1") ? "true" : "false"); |
|---|
| 3282 |
websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3283 |
|
|---|
| 3284 |
} |
|---|
| 3285 |
#endif |
|---|
| 3286 |
static void showbridgesettings(webs_t wp, char *var, int mcast, int dual) |
|---|
| 3287 |
{ |
|---|
| 3288 |
|
|---|
| 3289 |
char ssid[32]; |
|---|
| 3290 |
|
|---|
| 3291 |
sprintf(ssid, "%s_bridged", var); |
|---|
| 3292 |
char vvar[32]; |
|---|
| 3293 |
|
|---|
| 3294 |
strcpy(vvar, var); |
|---|
| 3295 |
rep(vvar, '.', 'X'); |
|---|
| 3296 |
websWrite(wp, |
|---|
| 3297 |
"<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.network)</script></div>\n"); |
|---|
| 3298 |
websWrite(wp, |
|---|
| 3299 |
"<input class=\"spaceradio\" type=\"radio\" value=\"0\" onclick=\"show_layer_ext(this, '%s_idnetvifs', true);\" name=\"%s_bridged\" %s><script type=\"text/javascript\">Capture(wl_basic.unbridged)</script></input> \n", |
|---|
| 3300 |
vvar, var, nvram_default_match(ssid, "0", |
|---|
| 3301 |
"1") ? "checked=\"checked\"" : |
|---|
| 3302 |
""); |
|---|
| 3303 |
websWrite(wp, |
|---|
| 3304 |
"<input class=\"spaceradio\" type=\"radio\" value=\"1\" onclick=\"show_layer_ext(this, '%s_idnetvifs', false);\" name=\"%s_bridged\" %s><script type=\"text/javascript\">Capture(wl_basic.bridged)</script></input>\n", |
|---|
| 3305 |
vvar, var, nvram_default_match(ssid, "1", |
|---|
| 3306 |
"1") ? "checked=\"checked\"" : |
|---|
| 3307 |
""); |
|---|
| 3308 |
websWrite(wp, "</div>\n"); |
|---|
| 3309 |
|
|---|
| 3310 |
websWrite(wp, "<div id=\"%s_idnetvifs\">\n", vvar); |
|---|
| 3311 |
if (mcast) { |
|---|
| 3312 |
char mcastvar[32]; |
|---|
| 3313 |
|
|---|
| 3314 |
sprintf(mcastvar, "%s_multicast", var); |
|---|
| 3315 |
nvram_default_get(mcastvar, "0"); |
|---|
| 3316 |
showRadio(wp, "wl_basic.multicast", mcastvar); |
|---|
| 3317 |
} |
|---|
| 3318 |
if (nvram_match("wk_mode", "gateway")) { |
|---|
| 3319 |
char natvar[32]; |
|---|
| 3320 |
sprintf(natvar, "%s_nat", var); |
|---|
| 3321 |
nvram_default_get(natvar, "1"); |
|---|
| 3322 |
showRadio(wp, "wl_basic.masquerade", natvar); |
|---|
| 3323 |
} |
|---|
| 3324 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3325 |
websWrite(wp, |
|---|
| 3326 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(share.ip)</script></div>\n"); |
|---|
| 3327 |
char ip[32]; |
|---|
| 3328 |
|
|---|
| 3329 |
sprintf(ip, "%s_ipaddr", var); |
|---|
| 3330 |
char *ipv = nvram_safe_get(ip); |
|---|
| 3331 |
|
|---|
| 3332 |
websWrite(wp, |
|---|
| 3333 |
"<input type=\"hidden\" name=\"%s_ipaddr\" value=\"4\" />\n", |
|---|
| 3334 |
var); |
|---|
| 3335 |
websWrite(wp, |
|---|
| 3336 |
"<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,1,223,share.ip)\" name=\"%s_ipaddr_0\" value=\"%d\" />.", |
|---|
| 3337 |
var, get_single_ip(ipv, 0)); |
|---|
| 3338 |
websWrite(wp, |
|---|
| 3339 |
"<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_1\" value=\"%d\" />.", |
|---|
| 3340 |
var, get_single_ip(ipv, 1)); |
|---|
| 3341 |
websWrite(wp, |
|---|
| 3342 |
"<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_2\" value=\"%d\" />.", |
|---|
| 3343 |
var, get_single_ip(ipv, 2)); |
|---|
| 3344 |
websWrite(wp, |
|---|
| 3345 |
"<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.ip)\" name=\"%s_ipaddr_3\" value=\"%d\" />\n", |
|---|
| 3346 |
var, get_single_ip(ipv, 3)); |
|---|
| 3347 |
websWrite(wp, "</div>\n"); |
|---|
| 3348 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3349 |
websWrite(wp, |
|---|
| 3350 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(share.subnet)</script></div>\n"); |
|---|
| 3351 |
sprintf(ip, "%s_netmask", var); |
|---|
| 3352 |
ipv = nvram_safe_get(ip); |
|---|
| 3353 |
|
|---|
| 3354 |
websWrite(wp, |
|---|
| 3355 |
"<input type=\"hidden\" name=\"%s_netmask\" value=\"4\" />\n", |
|---|
| 3356 |
var); |
|---|
| 3357 |
websWrite(wp, |
|---|
| 3358 |
"<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_0\" value=\"%d\" />.", |
|---|
| 3359 |
var, get_single_ip(ipv, 0)); |
|---|
| 3360 |
websWrite(wp, |
|---|
| 3361 |
"<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_1\" value=\"%d\" />.", |
|---|
| 3362 |
var, get_single_ip(ipv, 1)); |
|---|
| 3363 |
websWrite(wp, |
|---|
| 3364 |
"<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_2\" value=\"%d\" />.", |
|---|
| 3365 |
var, get_single_ip(ipv, 2)); |
|---|
| 3366 |
websWrite(wp, |
|---|
| 3367 |
"<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_netmask_3\" value=\"%d\" />.", |
|---|
| 3368 |
var, get_single_ip(ipv, 3)); |
|---|
| 3369 |
websWrite(wp, "</div>\n"); |
|---|
| 3370 |
|
|---|
| 3371 |
#ifdef HAVE_MADWIFI |
|---|
| 3372 |
/*if (dual) |
|---|
| 3373 |
{ |
|---|
| 3374 |
char dl[32]; |
|---|
| 3375 |
sprintf(dl,"%s_duallink",var); |
|---|
| 3376 |
websWrite( wp, |
|---|
| 3377 |
"<div class=\"setting\">\n<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.duallink)</script></div>\n" ); |
|---|
| 3378 |
websWrite( wp, |
|---|
| 3379 |
"<input class=\"spaceradio\" type=\"radio\" value=\"1\" onclick=\"show_layer_ext(this, '%s_idduallink', true);\" name=\"%s_duallink\" %s><script type=\"text/javascript\">Capture(shared.enable)</script></input> \n", |
|---|
| 3380 |
var, var, nvram_default_match( dl, "1", |
|---|
| 3381 |
"0" ) ? "checked=\"checked\"" : |
|---|
| 3382 |
"" ); |
|---|
| 3383 |
websWrite( wp, |
|---|
| 3384 |
"<input class=\"spaceradio\" type=\"radio\" value=\"0\" onclick=\"show_layer_ext(this, '%s_idduallink', false);\" name=\"%s_duallink\" %s><script type=\"text/javascript\">Capture(shared.disable)</script></input>\n", |
|---|
| 3385 |
var, var, nvram_default_match( dl, "0", |
|---|
| 3386 |
"0" ) ? "checked=\"checked\"" : |
|---|
| 3387 |
"" ); |
|---|
| 3388 |
websWrite( wp, "</div>\n" ); |
|---|
| 3389 |
|
|---|
| 3390 |
websWrite( wp, "<div id=\"%s_iddualink\">\n", var ); |
|---|
| 3391 |
|
|---|
| 3392 |
sprintf( ip, "%s_duallink_parent", var ); |
|---|
| 3393 |
websWrite( wp, "<div class=\"setting\">\n" ); |
|---|
| 3394 |
websWrite( wp,"<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.parent)</script></div>\n" ); |
|---|
| 3395 |
ipv = nvram_default_get( ip,"0.0.0.0" ); |
|---|
| 3396 |
websWrite( wp, |
|---|
| 3397 |
"<input type=\"hidden\" name=\"%s_duallink_parent\" value=\"4\" />\n", |
|---|
| 3398 |
var ); |
|---|
| 3399 |
websWrite( wp, |
|---|
| 3400 |
"<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_duallink_parent_0\" value=\"%d\" />.", |
|---|
| 3401 |
var, get_single_ip( ipv, 0 ) ); |
|---|
| 3402 |
websWrite( wp, |
|---|
| 3403 |
"<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_duallink_parent_1\" value=\"%d\" />.", |
|---|
| 3404 |
var, get_single_ip( ipv, 1 ) ); |
|---|
| 3405 |
websWrite( wp, |
|---|
| 3406 |
"<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_duallink_parent_2\" value=\"%d\" />.", |
|---|
| 3407 |
var, get_single_ip( ipv, 2 ) ); |
|---|
| 3408 |
websWrite( wp, |
|---|
| 3409 |
"<input class=\"num\" maxlength=\"3\" size=\"3\" onblur=\"valid_range(this,0,255,share.subnet)\" name=\"%s_duallink_parent_3\" value=\"%d\" />.", |
|---|
| 3410 |
var, get_single_ip( ipv, 3 ) ); |
|---|
| 3411 |
websWrite( wp, "</div>\n" ); |
|---|
| 3412 |
|
|---|
| 3413 |
websWrite( wp, "</div>\n" ); |
|---|
| 3414 |
|
|---|
| 3415 |
websWrite( wp, "<script>\n//<![CDATA[\n " ); |
|---|
| 3416 |
websWrite( wp, |
|---|
| 3417 |
"show_layer_ext(document.getElementsByName(\"%s_duallink\"), \"%s_idduallink\", %s);\n", |
|---|
| 3418 |
var, vvar, nvram_match( dl, "1" ) ? "true" : "false" ); |
|---|
| 3419 |
websWrite( wp, "//]]>\n</script>\n" ); |
|---|
| 3420 |
}*/ |
|---|
| 3421 |
#endif |
|---|
| 3422 |
|
|---|
| 3423 |
websWrite(wp, "</div>\n"); |
|---|
| 3424 |
|
|---|
| 3425 |
websWrite(wp, "<script>\n//<![CDATA[\n "); |
|---|
| 3426 |
websWrite(wp, |
|---|
| 3427 |
"show_layer_ext(document.getElementsByName(\"%s_bridged\"), \"%s_idnetvifs\", %s);\n", |
|---|
| 3428 |
var, vvar, nvram_match(ssid, "0") ? "true" : "false"); |
|---|
| 3429 |
websWrite(wp, "//]]>\n</script>\n"); |
|---|
| 3430 |
|
|---|
| 3431 |
} |
|---|
| 3432 |
|
|---|
| 3433 |
#ifdef HAVE_MADWIFI |
|---|
| 3434 |
static void show_chanshift(webs_t wp, char *prefix) |
|---|
| 3435 |
{ |
|---|
| 3436 |
char wl_chanshift[32]; |
|---|
| 3437 |
char wl_channelbw[32]; |
|---|
| 3438 |
|
|---|
| 3439 |
sprintf(wl_channelbw, "%s_channelbw", prefix); |
|---|
| 3440 |
sprintf(wl_chanshift, "%s_chanshift", prefix); |
|---|
| 3441 |
if (atoi(nvram_safe_get(wl_channelbw)) > 2 && (atoi(nvram_safe_get(wl_chanshift)) & 0xf) > 10) nvram_set(wl_chanshift, "10"); |
|---|
| 3442 |
if (atoi(nvram_safe_get(wl_channelbw)) > 5 && (atoi(nvram_safe_get(wl_chanshift)) & 0xf) > 10) nvram_set(wl_chanshift, "10"); |
|---|
| 3443 |
if (atoi(nvram_safe_get(wl_channelbw)) > 10 && (atoi(nvram_safe_get(wl_chanshift)) & 0xf) > 0) vram_set(wl_chanshift, "0"); |
|---|
| 3444 |
|
|---|
| 3445 |
if (nvram_match(wl_channelbw, "5") |
|---|
| 3446 |
|| nvram_match(wl_channelbw, "10") || nvram_match(wl_channelbw, "2")) { |
|---|
| 3447 |
|
|---|
| 3448 |
websWrite(wp, "<div class=\"setting\">\n"); |
|---|
| 3449 |
websWrite(wp, |
|---|
| 3450 |
"<div class=\"label\"><script type=\"text/javascript\">Capture(wl_basic.chanshift)</script></div>\n<select name=\"%s\">\n", |
|---|
| 3451 |
wl_chanshift); |
|---|
| 3452 |
websWrite(wp, |
|---|
| 3453 |
"<script type=\"text/javascript\">\n//<![CDATA[\n"); |
|---|
| 3454 |
if (nvram_match(wl_channelbw, "5") || nvram_match(wl_channelbw, "2")) |
|---|
| 3455 |
websWrite(wp, |
|---|
| 3456 |
"document.write(\"<option value=\\\"-15\\\" %s >-15 Mhz</option>\");\n", |
|---|
| 3457 |
nvram_default_match(wl_chanshift, "-15", |
|---|
| 3458 |
"0") ? |
|---|
| 3459 |
"selected=\\\"selected\\\"" : ""); |
|---|
| 3460 |
if (nvram_match(wl_channelbw, "5") |
|---|
| 3461 |
|| nvram_match(wl_channelbw, "10")|| nvram_match(wl_channelbw, "2")) |
|---|
| 3462 |
websWrite(wp, |
|---|
| 3463 |
"document.write(\"<option value=\\\"-10\\\" %s >-10 Mhz</option>\");\n", |
|---|
| 3464 |
nvram_default_match(wl_chanshift, "-10", |
|---|
| 3465 |
"0") ? |
|---|
| 3466 |
"selected=\\\"selected\\\"" : ""); |
|---|
| 3467 |
if (nvram_match(wl_channelbw, "5") |
|---|
| 3468 |
|| nvram_match(wl_channelbw, "10")|| nvram_match(wl_channelbw, "2")) |
|---|
| 3469 |
websWrite(wp, |
|---|
| 3470 |
"document.write(\"<option value=\\\"-5\\\" %s >-5 Mhz</option>\");\n", |
|---|
| 3471 |
nvram_default_match(wl_chanshift, "-5", |
|---|
| 3472 |
"0") ? |
|---|
| 3473 |
"selected=\\\"selected\\\"" : ""); |
|---|
| 3474 |
websWrite(wp, |
|---|
| 3475 |
"document.write(\"<option value=\\\"0\\\" %s >0 Mhz</option>\");\n", |
|---|
| 3476 |
nvram_default_match(wl_chanshift, "0", |
|---|
| 3477 |
"0") ? "selected=\\\"selected\\\"" |
|---|
| 3478 |
: ""); |
|---|
| 3479 |
if (nvram_match(wl_channelbw, "5") |
|---|
| 3480 |
|| nvram_match(wl_channelbw, "10")|| nvram_match(wl_channelbw, "2")) |
|---|
| 3481 |
websWrite(wp, |
|---|
| 3482 |
"document.write(\"<option value=\\\"5\\\" %s >+5 Mhz</option>\");\n", |
|---|
| 3483 |
nvram_default_match(wl_chanshift, "5", |
|---|
| 3484 |
"0") ? |
|---|
| 3485 |
"selected=\\\"selected\\\"" : ""); |
|---|
| 3486 |
if (nvram_match(wl_channelbw, "5") |
|---|
| 3487 |
|| nvram_match(wl_channelbw, "10")|| nvram_match(wl_channelbw, "2")) |
|---|
| 3488 |
websWrite(wp, |
|---|
| 3489 |
"document.write(\"<option value=\\\"10\\\" %s >+10 Mhz</option>\");\n", |
|---|
| 3490 |
nvram_default_match(wl_chanshift, "10", |
|---|
| 3491 |
"0") ? |
|---|
| 3492 |
"selected=\\\"selected\\\"" : ""); |
|---|
| 3493 |
if (nvram_match(wl_channelbw, "5")|| nvram_match(wl_channelbw, "2")) |
|---|
| 3494 |
websWrite(wp, |
|---|
| 3495 |
"document.write(\"<option value=\\\"15\\\" %s >+15 Mhz</option>\");\n", |
|---|
| 3496 |
nvram_default_match(wl_chanshift, "15", |
|---|
| 3497 |
"0") ? |
|---|
| 3498 |
"selected=\\\"selected\\\"" : ""); |
|---|
| 3499 |
websWrite(wp, "//]]>\n</script>\n</select>\n</div>\n"); |
|---|
| 3500 |
} |
|---|
| 3501 |
} |
|---|
| 3502 |
#endif |
|---|
| 3503 |
static int show_virtualssid(webs_t wp, char *prefix) |
|---|
| 3504 |
{ |
|---|
| 3505 |
char *next; |
|---|
| 3506 |
char var[80]; |
|---|
| 3507 |
char ssid[80]; |
|---|
| 3508 |
char vif[16]; |
|---|
| 3509 |
char power[32]; |
|---|
| 3510 |
|
|---|
| 3511 |
#ifdef HAVE_MADWIFI |
|---|
| 3512 |
char wmm[32]; |
|---|
| 3513 |
char wl_protmode[32]; |
|---|
| 3514 |
#endif |
|---|
| 3515 |
sprintf(vif, "%s_vifs", prefix); |
|---|
| 3516 |
char *vifs = nvram_safe_get(vif); |
|---|
| 3517 |
|
|---|
| 3518 |
if (vifs == NULL) |
|---|
| 3519 |
return 0; |
|---|
| 3520 |
#ifndef HAVE_MADWIFI |
|---|
| 3521 |
if (!nvram_nmatch("ap", "%s_mode", prefix) |
|---|
| 3522 |
&& !nvram_nmatch("apsta", "%s_mode", prefix) |
|---|
| 3523 |
&& !nvram_nmatch("apstawet", "%s_mode", prefix)) |
|---|
| 3524 |
return 0; |
|---|
| 3525 |
#endif |
|---|
| 3526 |
int count = 1; |
|---|
| 3527 |
|
|---|
| 3528 |
websWrite(wp, |
|---|
| 3529 |
|---|