webif-changes:
authorFelix Fietkau <nbd@openwrt.org>
Wed, 18 Jan 2006 01:15:22 +0000 (01:15 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Wed, 18 Jan 2006 01:15:22 +0000 (01:15 +0000)
* removed extra files display-dhcp.awk, display-hosts.awk,
  moved the code into hosts.sh
* moved the wds list from wireless-config to wireless-advanced
  ("Advanced Wireless")
* added wireless mac filter editor

SVN-Revision: 3009

openwrt/package/webif/files/usr/lib/webif/display-dhcp.awk [deleted file]
openwrt/package/webif/files/usr/lib/webif/display-hosts.awk [deleted file]
openwrt/package/webif/files/usr/lib/webif/form.awk
openwrt/package/webif/files/usr/lib/webif/validate.awk
openwrt/package/webif/files/www/cgi-bin/webif/hosts.sh
openwrt/package/webif/files/www/cgi-bin/webif/wireless-advanced.sh [new file with mode: 0755]
openwrt/package/webif/files/www/cgi-bin/webif/wireless-config.sh
openwrt/package/webif/files/www/webif.js

diff --git a/openwrt/package/webif/files/usr/lib/webif/display-dhcp.awk b/openwrt/package/webif/files/usr/lib/webif/display-dhcp.awk
deleted file mode 100644 (file)
index 28c5067..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-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();
-}
-
diff --git a/openwrt/package/webif/files/usr/lib/webif/display-hosts.awk b/openwrt/package/webif/files/usr/lib/webif/display-hosts.awk
deleted file mode 100644 (file)
index db522a3..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-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()
-}
-
index 7f43d4f87279dea99723ca1d3527e11ea517ed04..5c5cf52c83b4468a19f0abe1fb0358ba22f73c35 100644 (file)
@@ -20,7 +20,7 @@ $1 ~ /^onchange/ {
 
 ($1 != "") && ($1 !~ /^option/) && (select_open == 1) {
        select_open = 0
-       print "</select>"
+       printf "</select>"
 }
 $1 ~ /^start_form/ {
        if ($3 != "") field_opts=" id=\"" $3 "\""
@@ -36,7 +36,10 @@ $1 ~ /^field/ {
        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/ {
@@ -63,7 +66,7 @@ $1 ~ /^select/ {
        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 "&nbsp;&nbsp;</option>"
 }
 ($1 ~ /^listedit/) {
        n = split($4 " ", items, " ")
@@ -72,6 +75,8 @@ $1 ~ /^select/ {
        }
        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 "\" />" }
index 0aca1b0c8701f15e64f54cf2268abc2f03371d4e..517ce647cbaa91052de53f591acd07673b2a24e8 100644 (file)
@@ -76,7 +76,7 @@ $1 == "wpapsk" {
                valid = 0
                verr = "String too long"
        }
-       if (length(value) < 8) {
+       if ((length(value) != 0) && (length(value) < 8)) {
                valid = 0
                verr = "String too short"
        }
index ff7d9dcbf04fce74b0b2a85ed01d142ca28815a0..fd268eb9d6d85bb77a6cfd965546217d87bf927a 100755 (executable)
@@ -84,14 +84,73 @@ header "Network" "Hosts" "Configured hosts" ''
 # 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
 -->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/wireless-advanced.sh b/openwrt/package/webif/files/www/cgi-bin/webif/wireless-advanced.sh
new file mode 100755 (executable)
index 0000000..c9a4b9e
--- /dev/null
@@ -0,0 +1,65 @@
+#!/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
+-->
index d93b077c305f78940ce1fb0dd33c802ed775d5b7..cc1f6b16b41714c4ad8f7e687f23831e72a9322c 100755 (executable)
@@ -3,14 +3,6 @@
 . /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 ;;
@@ -22,7 +14,6 @@ for ch in $CHANNELS; do
 "
 done
 
-
 if empty "$FORM_submit"; then
        FORM_mode=${wl0_mode:-$(nvram get wl0_mode)}
        infra=${wl0_infra:-$(nvram get wl0_infra)}
@@ -102,21 +93,25 @@ if empty "$FORM_submit"; then
 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"
@@ -271,11 +266,6 @@ text|key3|$FORM_key3|<br />
 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 ?>
index e906f8a856b38812d637b9c62899023a95a1013f..8bdef4dd66816b58f79548ddff231cd6fee273e7 100644 (file)
@@ -1,3 +1,8 @@
+function value(name)
+{
+       var item = document.getElementById(name);
+       return (item ? item.value : "");
+}
 function checked(name)
 {
        var item = document.getElementById(name);