+++ /dev/null
-BEGIN {
- FS="[ \t]"
- print "<form enctype=\"multipart/form-data\" method=\"post\">"
- start_form("Static IP addresses (for DHCP)")
- print "<table width=\"70%\" summary=\"Settings\">"
- print "<tr><th>MAC address</th><th>IP</th><th></th></tr>"
-}
-
-# only for valid MAC addresses
-($1 ~ /^[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]$/) {
- gsub(/#.*$/, "");
- print "<tr><td>" $1 "</td><td>" $2 "</td><td align=\"right\" width=\"10%\"><a href=\"" url "?remove_dhcp=1&remove_mac=" $1 "\">Remove</a></td></tr>"
-}
-
-END {
- print "<tr><td><input type\"text\" name=\"dhcp_mac\" value=\"" mac "\" /></td><td><input type=\"text\" name=\"dhcp_ip\" value=\"" ip "\" /></td><td style=\"width: 10em\"><input type=\"submit\" name=\"add_dhcp\" value=\"Add\" /></td></tr>"
- print "</table>"
- print "</form>"
- end_form();
-}
-
+++ /dev/null
-BEGIN {
- FS="[ \t]"
- start_form("Hostnames")
- print "<table width=\"70%\" summary=\"Settings\">"
- print "<tr><th>IP</th><th>Hostname</th><th></th></tr>"
- print "<tr><td colspan=\"3\"><hr class=\"separator\" /></td></tr>"
-}
-
-# only for valid IPv4 addresses
-($1 ~ /^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/) {
- gsub(/#.*$/, "");
- output = ""
- names_found = 0
- n = split($0, names, "[ \t]")
- first = 1
- for (i = 2; i <= n; i++) {
- if (names[i] != "") {
- if (first != 1) output = output "<tr>"
- output = output "<td>" names[i] "</td><td align=\"right\" width=\"10%\"><a href=\"" url "?remove_host=1&remove_ip=" $1 "&remove_name=" names[i] "\">Remove</a></td></tr>"
- first = 0
- names_found++
- }
- }
- if (names_found > 0) {
- print "<tr><td rowspan=\"" names_found "\">" $1 "</td>" output
- print "<tr><td colspan=\"3\"><hr class=\"separator\" /></td></tr>"
- }
-}
-
-END {
- print "<form enctype=\"multipart/form-data\" method=\"post\">"
- print "<tr><td><input type\"text\" name=\"host_ip\" value=\"" ip "\" /></td><td><input type=\"text\" name=\"host_name\" value=\"" name "\" /></td><td style=\"width: 10em\"><input type=\"submit\" name=\"add_host\" value=\"Add\" /></td></tr>"
- print "</form>"
- print "</table>"
- end_form()
-}
-
($1 != "") && ($1 !~ /^option/) && (select_open == 1) {
select_open = 0
- print "</select>"
+ printf "</select>"
}
$1 ~ /^start_form/ {
if ($3 != "") field_opts=" id=\"" $3 "\""
if ($3 != "") field_opts=" id=\"" $3 "\""
else field_opts=""
if ($4 == "hidden") field_opts = field_opts " style=\"display: none\""
- print "<tr" field_opts "><td width=\"50%\">" $2 "</td><td width=\"50%\">"
+ print "<tr" field_opts ">"
+ if ($2 != "") print "<td width=\"50%\">" $2 "</td><td width=\"50%\">"
+ else print "<td colspan=\"2\">"
+
field_open=1
}
$1 ~ /^checkbox/ {
else option_selected=""
if ($3 != "") option_title = $3
else option_title = $2
- print "<option" option_selected " value=\"" $2 "\">" option_title "</option>"
+ print "<option" option_selected " value=\"" $2 "\">" option_title " </option>"
}
($1 ~ /^listedit/) {
n = split($4 " ", items, " ")
}
print "<tr><td width=\"100%\" colspan="2"><input type=\"text\" name=\"" $2 "add\" value=\"" $5 "\" /><input type=\"submit\" name=\"" $2 "submit\" value=\"Add\" /></td></tr>"
}
+$1 ~ /^caption/ { print "<b>" $2 "</b>" }
+$1 ~ /^string/ { print $2 }
$1 ~ /^text/ { print "<input id=\"" $2 "\" type=\"text\" name=\"" $2 "\" value=\"" $3 "\" />" $4 }
$1 ~ /^password/ { print "<input id=\"" $2 "\" type=\"password\" name=\"" $2 "\" value=\"" $3 "\" />" $4 }
$1 ~ /^submit/ { print "<input type=\"submit\" name=\"" $2 "\" value=\"" $3 "\" />" }
valid = 0
verr = "String too long"
}
- if (length(value) < 8) {
+ if ((length(value) != 0) && (length(value) < 8)) {
valid = 0
verr = "String too short"
}
# Hosts in /etc/hosts
awk -v "url=$SCRIPT_NAME" \
-v "ip=$FORM_host_ip" \
- -v "name=$FORM_host_name" -f /usr/lib/webif/common.awk -f /usr/lib/webif/display-hosts.awk $HOSTS_FILE
+ -v "name=$FORM_host_name" -f /usr/lib/webif/common.awk -f - $HOSTS_FILE <<EOF
+BEGIN {
+ FS="[ \t]"
+ start_form("Hostnames")
+ print "<table width=\"70%\" summary=\"Settings\">"
+ print "<tr><th>IP</th><th>Hostname</th><th></th></tr>"
+ print "<tr><td colspan=\"3\"><hr class=\"separator\" /></td></tr>"
+}
+
+# only for valid IPv4 addresses
+(\$1 ~ /^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/) {
+ gsub(/#.*$/, "");
+ output = ""
+ names_found = 0
+ n = split(\$0, names, "[ \\t]")
+ first = 1
+ for (i = 2; i <= n; i++) {
+ if (names[i] != "") {
+ if (first != 1) output = output "<tr>"
+ output = output "<td>" names[i] "</td><td align=\\"right\\" width=\\"10%\\"><a href=\\"" url "?remove_host=1&remove_ip=" $1 "&remove_name=" names[i] "\\">Remove</a></td></tr>"
+ first = 0
+ names_found++
+ }
+ }
+ if (names_found > 0) {
+ print "<tr><td rowspan=\\"" names_found "\\">" \$1 "</td>" output
+ print "<tr><td colspan=\\"3\\"><hr class=\\"separator\\" /></td></tr>"
+ }
+}
+
+END {
+ print "<form enctype=\\"multipart/form-data\\" method=\\"post\\">"
+ print "<tr><td><input type\\"text\\" name=\\"host_ip\\" value=\\"" ip "\\" /></td><td><input type=\\"text\\" name=\\"host_name\\" value=\\"" name "\\" /></td><td style=\\"width: 10em\\"><input type=\\"submit\\" name=\\"add_host\\" value=\\"Add\\" /></td></tr>"
+ print "</form>"
+ print "</table>"
+ end_form()
+}
+EOF
# Static DHCP mappings (/etc/ethers)
awk -v "url=$SCRIPT_NAME" \
-v "mac=$FORM_dhcp_mac" \
- -v "ip=$FORM_dhcp_ip" -f /usr/lib/webif/common.awk -f /usr/lib/webif/display-dhcp.awk $ETHERS_FILE
+ -v "ip=$FORM_dhcp_ip" -f /usr/lib/webif/common.awk -f - $ETHERS_FILE <<EOF
+
+BEGIN {
+ FS="[ \\t]"
+ print "<form enctype=\\"multipart/form-data\\" method=\\"post\\">"
+ start_form("Static IP addresses (for DHCP)")
+ print "<table width=\\"70%\\" summary=\\"Settings\\">"
+ print "<tr><th>MAC address</th><th>IP</th><th></th></tr>"
+}
+
+# only for valid MAC addresses
+(\$1 ~ /^[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]$/) {
+ gsub(/#.*$/, "");
+ print "<tr><td>" \$1 "</td><td>" \$2 "</td><td align=\\"right\\" width=\\"10%\\"><a href=\\"" url "?remove_dhcp=1&remove_mac=" \$1 "\\">Remove</a></td></tr>"
+}
+
+END {
+ print "<tr><td><input type\\"text\\" name=\\"dhcp_mac\\" value=\\"" mac "\\" /></td><td><input type=\\"text\\" name=\\"dhcp_ip\\" value=\\"" ip "\\" /></td><td style=\\"width: 10em\\"><input type=\\"submit\\" name=\\"add_dhcp\\" value=\\"Add\\" /></td></tr>"
+ print "</table>"
+ print "</form>"
+ end_form();
+}
+EOF
footer ?>
<!--
-##WEBIF:name:Network:4:Hosts
+##WEBIF:name:Network:5:Hosts
-->
--- /dev/null
+#!/usr/bin/haserl
+<?
+. /usr/lib/webif/webif.sh
+load_settings "wireless"
+
+FORM_wds="${wl0_wds:-$(nvram get wl0_wds)}"
+LISTVAL="$FORM_wds"
+handle_list "$FORM_wdsremove" "$FORM_wdsadd" "$FORM_wdssubmit" 'mac|FORM_wdsadd|WDS MAC address|required' && {
+ FORM_wds="$LISTVAL"
+ save_setting wireless wl0_wds "$FORM_wds"
+}
+FORM_wdsadd=${FORM_wdsadd:-00:00:00:00:00:00}
+
+FORM_maclist="${wl0_maclist:-$(nvram get wl0_maclist)}"
+LISTVAL="$FORM_maclist"
+handle_list "$FORM_maclistremove" "$FORM_maclistadd" "$FORM_maclistsubmit" 'mac|FORM_maclistadd|WDS MAC address|required' && {
+ FORM_maclist="$LISTVAL"
+ save_setting wireless wl0_maclist "$FORM_maclist"
+}
+FORM_maclistadd=${FORM_maclistadd:-00:00:00:00:00:00}
+
+if empty "$FORM_macmode_set"; then
+ FORM_macmode="${wl0_macmode:-$(nvram get wl0_macmode)}"
+else
+ save_setting wireless wl0_macmode "$FORM_macmode"
+fi
+
+header "Network" "Advanced Wireless" "Advanced Wireless Settings" ' onLoad="modechange()"'
+cat <<EOF
+<script type="text/javascript" src="/webif.js"></script>
+<script type="text/javascript">
+
+function modechange() {
+ var v = (value("macmode") == "allow") || (value("macmode") == "deny");
+ set_visible('mac_list', v);
+}
+
+</script>
+<form enctype="multipart/form-data" method="post" action="$SCRIPT_NAME">
+EOF
+
+display_form <<EOF
+onchange|modechange
+start_form|WDS connections
+listedit|wds|$SCRIPT_NAME?|$FORM_wds|$FORM_wdsadd
+end_form
+start_form|MAC filter list
+listedit|maclist|$SCRIPT_NAME?|$FORM_maclist|$FORM_maclistadd
+field
+caption|Filter mode:
+select|macmode|$FORM_macmode
+option|disabled
+option|allow
+option|deny
+submit|macmode_set|Set
+end_form
+EOF
+
+?>
+
+</form>
+<? footer ?>
+<!--
+##WEBIF:name:Network:4:Advanced Wireless
+-->
. /usr/lib/webif/webif.sh
load_settings "wireless"
-FORM_wds="${wl0_wds:-$(nvram get wl0_wds)}"
-LISTVAL="$FORM_wds"
-handle_list "$FORM_wdsremove" "$FORM_wdsadd" "$FORM_wdssubmit" 'mac|FORM_wdsadd|WDS MAC address|required' && {
- FORM_wds="$LISTVAL"
- save_setting wireless wl0_wds "$FORM_wds"
-}
-FORM_wdsadd=${FORM_wdsadd:-00:00:00:00:00:00}
-
CC=${wl0_country_code:-$(nvram get wl0_country_code)}
case "$CC" in
All|all|ALL) CHANNELS="1 2 3 4 5 6 7 8 9 10 11 12 13 14"; CHANNEL_MAX=14 ;;
"
done
-
if empty "$FORM_submit"; then
FORM_mode=${wl0_mode:-$(nvram get wl0_mode)}
infra=${wl0_infra:-$(nvram get wl0_infra)}
else
SAVED=1
case "$FORM_encryption" in
- wpa) V_RADIUS="required";;
+ wpa) V_RADIUS="
+string|FORM_radius_key|RADIUS server key|min=4 max=63 required|$FORM_radius_key
+ip|FORM_radius_ipaddr|RADIUS IP address|required|$FORM_radius_ipaddr";;
psk) V_PSK="wpapsk|FORM_wpa_psk|WPA pre-shared key|required|$FORM_wpa_psk";;
+ wep) V_WEP="
+int|FORM_key|WEP key number|min=1 max=4|$FORM_key
+wep|FORM_key1|WEP key 1||$FORM_key1
+wep|FORM_key2|WEP key 2||$FORM_key2
+wep|FORM_key3|WEP key 3||$FORM_key3
+wep|FORM_key4|WEP key 4||$FORM_key4";;
esac
validate <<EOF
int|FORM_radio|Radio On/Off|required min=0 max=1|$FORM_radio
-ip|FORM_radius_ipaddr|RADIUS IP address|$V_RADIUS|$FORM_radius_ipaddr
-wep|FORM_key1|WEP key 1||$FORM_key1
-wep|FORM_key2|WEP key 2||$FORM_key2
-wep|FORM_key3|WEP key 3||$FORM_key3
-wep|FORM_key4|WEP key 4||$FORM_key4
-$V_PSK
-string|FORM_radius_key|RADIUS server key|min=4 max=63 $V_RADIUS|$FORM_radius_key
string|FORM_ssid|ESSID|required|$FORM_ssid
int|FORM_channel|Channel|required min=1 max=$CHANNEL_MAX|$FORM_channel
+$V_WEP
+$V_RADIUS
+$V_PSK
EOF
equal "$?" 0 && {
save_setting wireless wl0_radio "$FORM_radio"
radio|key|$FORM_key|4
text|key4|$FORM_key4|<br />
end_form
-start_form|WDS connections
-listedit|wds|$SCRIPT_NAME?|$FORM_wds|$FORM_wdsadd
-helpitem|Note
-helptext|You should save your settings on this page before adding/removing WDS links
-end_form
EOF
footer ?>
+function value(name)
+{
+ var item = document.getElementById(name);
+ return (item ? item.value : "");
+}
function checked(name)
{
var item = document.getElementById(name);