summaryrefslogtreecommitdiffstats
path: root/package/base-files
diff options
context:
space:
mode:
Diffstat (limited to 'package/base-files')
-rw-r--r--package/base-files/ar7-2.4/etc/config/network29
-rw-r--r--package/base-files/aruba-2.6/etc/config/network8
-rw-r--r--package/base-files/au1000-2.6/etc/config/network17
-rw-r--r--package/base-files/brcm-2.4/etc/hotplug.d/net/09-net45
-rwxr-xr-xpackage/base-files/brcm-2.4/etc/init.d/S05netconfig70
-rw-r--r--package/base-files/brcm-2.6/etc/hotplug.d/net/09-net35
-rwxr-xr-xpackage/base-files/brcm-2.6/etc/init.d/S05netconfig70
-rw-r--r--package/base-files/default/etc/hotplug.d/net/10-net201
-rwxr-xr-xpackage/base-files/default/etc/init.d/S10boot3
-rwxr-xr-xpackage/base-files/default/etc/init.d/S40network9
-rwxr-xr-xpackage/base-files/default/etc/init.d/rcS11
-rwxr-xr-xpackage/base-files/default/lib/network/config.sh147
-rwxr-xr-xpackage/base-files/default/sbin/hotplug1
-rwxr-xr-xpackage/base-files/default/sbin/ifdown32
-rwxr-xr-xpackage/base-files/default/sbin/ifup42
-rwxr-xr-xpackage/base-files/default/sbin/wifi7
-rwxr-xr-xpackage/base-files/default/usr/share/udhcpc/default.script14
-rw-r--r--package/base-files/rb532-2.6/etc/config/network8
-rw-r--r--package/base-files/sibyte-2.6/etc/config/network17
-rw-r--r--package/base-files/x86-2.4/etc/config/network20
-rw-r--r--package/base-files/x86-2.6/etc/config/network20
-rw-r--r--package/base-files/xscale-2.6/etc/config/network7
22 files changed, 314 insertions, 499 deletions
diff --git a/package/base-files/ar7-2.4/etc/config/network b/package/base-files/ar7-2.4/etc/config/network
index 353538bf4..19a858e16 100644
--- a/package/base-files/ar7-2.4/etc/config/network
+++ b/package/base-files/ar7-2.4/etc/config/network
@@ -1,27 +1,8 @@
# Network configuration file
-# Uncomment the following statements to change the network configuration
-## LAN configuration
-lan_ifname="eth0"
-lan_proto="static"
-lan_ipaddr="192.168.1.1"
-lan_netmask="255.255.255.0"
-# lan_gateway=""
-# lan_dns=""
-
-## WAN configuration
-# wan_proto=pppoe
-wan_ifname=ppp0
-wan_device=nas0
-atm_vpi=8
-atm_vci=35
-# ppp_username=my_username
-# ppp_passwd=my_passwd
-
-## WAN configuration (pppoe)
-pppoe_atm=1
-ppp_mtu=1492
-
-## WAN configuration (pppoa)
-# ppp_mtu=1500
+config interface lan
+ option ifname eth0
+ option proto static
+ option ipaddr 192.168.1.1
+ option netmask 255.255.255.0
diff --git a/package/base-files/aruba-2.6/etc/config/network b/package/base-files/aruba-2.6/etc/config/network
index 65797797e..aadd4aa8e 100644
--- a/package/base-files/aruba-2.6/etc/config/network
+++ b/package/base-files/aruba-2.6/etc/config/network
@@ -1,7 +1,5 @@
# Network configuration file
-# Copyright (C) 2006 OpenWrt.org
-
-## LAN configuration
-lan_ifname="eth0"
-lan_proto="dhcp"
+config interface lan
+ option ifname eth0
+ option proto dhcp
diff --git a/package/base-files/au1000-2.6/etc/config/network b/package/base-files/au1000-2.6/etc/config/network
index 576677bf7..95d7575c9 100644
--- a/package/base-files/au1000-2.6/etc/config/network
+++ b/package/base-files/au1000-2.6/etc/config/network
@@ -1,13 +1,8 @@
-# Network configuration file
# Copyright (C) 2006 OpenWrt.org
-## LAN configuration
-lan_ifname="br0"
-lan_ifnames="eth0 ath0"
-lan_proto="static"
-lan_ipaddr="192.168.1.1"
-lan_netmask="255.255.255.0"
-
-## WAN configuration
-wan_ifname=""
-wan_proto="none"
+config interface lan
+ option type bridge
+ option ifnames "eth0 ath0"
+ option proto static
+ option ipaddr 192.168.1.1
+ option netmask 255.255.255.0
diff --git a/package/base-files/brcm-2.4/etc/hotplug.d/net/09-net b/package/base-files/brcm-2.4/etc/hotplug.d/net/09-net
deleted file mode 100644
index 48abdf406..000000000
--- a/package/base-files/brcm-2.4/etc/hotplug.d/net/09-net
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2006 OpenWrt.org
-
-setup_wl()
-{
- [ -f /proc/net/wl0 ] && {
- lsmod | grep wlcompat >&- || insmod wlcompat
- }
- iwconfig "$INTERFACE" 2>&- | grep -v 'no wireless' >&- && {
- /sbin/wifi
- }
-}
-setup_eth()
-{
- [ -d /proc/switch ] || {
- insmod switch-core
- insmod switch-robo || insmod switch-adm
- }
- if="$(echo "$INTERFACE" | sed s,eth,et,)"
- ifconfig "$INTERFACE" up 2>&- >&-
- [ -d "/proc/switch/$INTERFACE" ] || return 0
- echo "1" > "/proc/switch/$INTERFACE/reset"
- echo "1" > "/proc/switch/$INTERFACE/enable_vlan"
- for vlan in $(seq 0 15); do
- eval "hwname=\"\${vlan${vlan}hwname}\""
- [ "$hwname" = "$if" ] && {
- eval "vports=\"\${vlan${vlan}ports}\""
- [ -n "$vports" ] && echo "$vports" > "/proc/switch/$INTERFACE/vlan/$vlan/ports"
- $DEBUG vconfig add "$INTERFACE" "$vlan"
- }
- done
-}
-
-do_register()
-{
- case "${INTERFACE%%[0-9]*}" in
- eth) setup_eth;;
- wl) setup_wl;;
- esac
-}
-
-
-case "$ACTION" in
- add|register) do_register;;
-esac
diff --git a/package/base-files/brcm-2.4/etc/init.d/S05netconfig b/package/base-files/brcm-2.4/etc/init.d/S05netconfig
index 0f53c0c9c..82e4ab998 100755
--- a/package/base-files/brcm-2.4/etc/init.d/S05netconfig
+++ b/package/base-files/brcm-2.4/etc/init.d/S05netconfig
@@ -13,16 +13,16 @@ mkdir -p /etc/config
strings /dev/mtdblock/3
fi
) | awk '
-function p(name) {
- if (c[name] != "") print name "=\"" c[name] "\""
+function p(cfgname, name) {
+ if (c[name] != "") print " option " cfgname " \"" c[name] "\""
}
BEGIN {
FS="="
c["lan_ifname"]="br0"
- c["lan_ifnames"]="vlan0 eth1"
+ c["lan_ifnames"]="eth0.0 wl0"
c["wan_proto"]="none"
- c["wan_ifname"]="vlan1"
+ c["wan_ifname"]="eth0.1"
c["vlan0ports"]="1 2 3 4 5*"
c["vlan1ports"]="0 5"
}
@@ -34,23 +34,16 @@ BEGIN {
END {
# v1 hardware
if (nvram["boardtype"] == "bcm94710dev") {
- # Linksys WRT54G v1.x
- if (nvram["boardnum"] == "42") {
- c["vlan0ports"]=""
- c["vlan1ports"]=""
- c["lan_ifnames"]="vlan2 eth2"
- }
-
# Asus WL-500g
if (nvram["boardnum"] == "asusX") {
- c["lan_ifnames"]="eth0 eth1 eth2" # FIXME
- # wan_ifname=eth1
+ c["lan_ifnames"]="eth0 eth1 wl0" # FIXME
+ c["wan_ifname"]=""
}
}
if (nvram["boardtype"] == "wgt634u") {
c["vlan0ports"] = "0 1 2 3 5*"
c["vlan1ports"] = "4 5"
- c["lan_ifnames"] = "vlan0 ath0"
+ c["lan_ifnames"] = "eth0.0 ath0"
}
if ((nvram["boardtype"] == "0x0467") || (nvram["boardtype"] == "0x042f")) {
c["vlan0ports"] = "0 1 2 3 5*"
@@ -60,51 +53,28 @@ END {
# WAP54G
if ((nvram["boardnum"] == "2") || \
(nvram["boardnum"] == "1024")) {
- c["lan_ifnames"]="eth0 eth1"
+ c["lan_ifnames"]="eth0 wl0"
c["wan_ifname"]=""
}
print "#### VLAN configuration "
- print "vlan0hwname=et0"
- print "vlan1hwname=et0"
- p("vlan0ports")
- p("vlan1ports")
+ print "config switch eth0"
+ p("vlan0", "vlan0ports")
+ p("vlan1", "vlan1ports")
print ""
print ""
-
print "#### LAN configuration"
- print "lan_proto=\"static\""
- p("lan_ifname")
- p("lan_ifnames")
- print "lan_ipaddr=\"192.168.1.1\""
- print "lan_netmask=\"255.255.255.0\""
- print "# lan_dns=\"192.168.1.1\""
- print "# lan_gateway=\"192.168.1.1\""
-
+ print "config interface lan"
+ print " option type bridge"
+ p("ifnames", "lan_ifnames")
+ print " option proto static"
+ print " option ipaddr 192.168.1.1"
+ print " option netmask 255.255.255.0"
print ""
print ""
-
print "#### WAN configuration"
- print "# wan_proto: WAN protocol, available protocols:"
- print "# none: disable"
- print "# dhcp: DHCP"
- print "# static: Static IP"
- print "# pppoe: PPP over Ethernet"
- print "# pptp: Point-to-Point tunneling Protocol"
- print "# for pppoe and pptp you need to use wan_ifname=\"ppp0\""
- print ""
- print "wan_proto=dhcp"
- p("wan_ifname")
- print "wan_device=\"" c["wan_ifname"] "\""
- print "# wan_ipaddr=\"192.168.0.2\""
- print "# wan_netmask=\"255.255.255.0\""
- print "# wan_gateway=\"192.168.0.1\""
- print "# wan_dns=\"192.168.0.1\""
- print ""
- print "## PPP over Ethernet and PPTP"
- print "# wan_ifname=\"ppp0\""
- print "# ppp_username=\"my_username\""
- print "# ppp_passwd=\"my_password\""
- print "# pptp_server_ip=\"192.168.0.1\""
+ print "config interface wan"
+ p("ifname", "wan_ifname")
+ print " option proto dhcp"
}
' > /etc/config/network
diff --git a/package/base-files/brcm-2.6/etc/hotplug.d/net/09-net b/package/base-files/brcm-2.6/etc/hotplug.d/net/09-net
deleted file mode 100644
index 90a92bd2b..000000000
--- a/package/base-files/brcm-2.6/etc/hotplug.d/net/09-net
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2006 OpenWrt.org
-
-setup_eth()
-{
- [ -d /proc/switch ] || {
- insmod switch-core
- insmod switch-robo || insmod switch-adm
- }
- if="$(echo "$INTERFACE" | sed s,eth,et,)"
- ifconfig "$INTERFACE" up 2>&- >&-
- [ -d "/proc/switch/$INTERFACE" ] || return 0
- echo "1" > "/proc/switch/$INTERFACE/reset"
- echo "1" > "/proc/switch/$INTERFACE/enable_vlan"
- for vlan in $(seq 0 15); do
- eval "hwname=\"\${vlan${vlan}hwname}\""
- [ "$hwname" = "$if" ] && {
- eval "vports=\"\${vlan${vlan}ports}\""
- [ -n "$vports" ] && echo "$vports" > "/proc/switch/$INTERFACE/vlan/$vlan/ports"
- $DEBUG vconfig add "$INTERFACE" "$vlan"
- }
- done
-}
-
-do_register()
-{
- case "${INTERFACE%%[0-9]*}" in
- eth) setup_eth;;
- esac
-}
-
-
-case "$ACTION" in
- add|register) do_register;;
-esac
diff --git a/package/base-files/brcm-2.6/etc/init.d/S05netconfig b/package/base-files/brcm-2.6/etc/init.d/S05netconfig
index 0f53c0c9c..82e4ab998 100755
--- a/package/base-files/brcm-2.6/etc/init.d/S05netconfig
+++ b/package/base-files/brcm-2.6/etc/init.d/S05netconfig
@@ -13,16 +13,16 @@ mkdir -p /etc/config
strings /dev/mtdblock/3
fi
) | awk '
-function p(name) {
- if (c[name] != "") print name "=\"" c[name] "\""
+function p(cfgname, name) {
+ if (c[name] != "") print " option " cfgname " \"" c[name] "\""
}
BEGIN {
FS="="
c["lan_ifname"]="br0"
- c["lan_ifnames"]="vlan0 eth1"
+ c["lan_ifnames"]="eth0.0 wl0"
c["wan_proto"]="none"
- c["wan_ifname"]="vlan1"
+ c["wan_ifname"]="eth0.1"
c["vlan0ports"]="1 2 3 4 5*"
c["vlan1ports"]="0 5"
}
@@ -34,23 +34,16 @@ BEGIN {
END {
# v1 hardware
if (nvram["boardtype"] == "bcm94710dev") {
- # Linksys WRT54G v1.x
- if (nvram["boardnum"] == "42") {
- c["vlan0ports"]=""
- c["vlan1ports"]=""
- c["lan_ifnames"]="vlan2 eth2"
- }
-
# Asus WL-500g
if (nvram["boardnum"] == "asusX") {
- c["lan_ifnames"]="eth0 eth1 eth2" # FIXME
- # wan_ifname=eth1
+ c["lan_ifnames"]="eth0 eth1 wl0" # FIXME
+ c["wan_ifname"]=""
}
}
if (nvram["boardtype"] == "wgt634u") {
c["vlan0ports"] = "0 1 2 3 5*"
c["vlan1ports"] = "4 5"
- c["lan_ifnames"] = "vlan0 ath0"
+ c["lan_ifnames"] = "eth0.0 ath0"
}
if ((nvram["boardtype"] == "0x0467") || (nvram["boardtype"] == "0x042f")) {
c["vlan0ports"] = "0 1 2 3 5*"
@@ -60,51 +53,28 @@ END {
# WAP54G
if ((nvram["boardnum"] == "2") || \
(nvram["boardnum"] == "1024")) {
- c["lan_ifnames"]="eth0 eth1"
+ c["lan_ifnames"]="eth0 wl0"
c["wan_ifname"]=""
}
print "#### VLAN configuration "
- print "vlan0hwname=et0"
- print "vlan1hwname=et0"
- p("vlan0ports")
- p("vlan1ports")
+ print "config switch eth0"
+ p("vlan0", "vlan0ports")
+ p("vlan1", "vlan1ports")
print ""
print ""
-
print "#### LAN configuration"
- print "lan_proto=\"static\""
- p("lan_ifname")
- p("lan_ifnames")
- print "lan_ipaddr=\"192.168.1.1\""
- print "lan_netmask=\"255.255.255.0\""
- print "# lan_dns=\"192.168.1.1\""
- print "# lan_gateway=\"192.168.1.1\""
-
+ print "config interface lan"
+ print " option type bridge"
+ p("ifnames", "lan_ifnames")
+ print " option proto static"
+ print " option ipaddr 192.168.1.1"
+ print " option netmask 255.255.255.0"
print ""
print ""
-
print "#### WAN configuration"
- print "# wan_proto: WAN protocol, available protocols:"
- print "# none: disable"
- print "# dhcp: DHCP"
- print "# static: Static IP"
- print "# pppoe: PPP over Ethernet"
- print "# pptp: Point-to-Point tunneling Protocol"
- print "# for pppoe and pptp you need to use wan_ifname=\"ppp0\""
- print ""
- print "wan_proto=dhcp"
- p("wan_ifname")
- print "wan_device=\"" c["wan_ifname"] "\""
- print "# wan_ipaddr=\"192.168.0.2\""
- print "# wan_netmask=\"255.255.255.0\""
- print "# wan_gateway=\"192.168.0.1\""
- print "# wan_dns=\"192.168.0.1\""
- print ""
- print "## PPP over Ethernet and PPTP"
- print "# wan_ifname=\"ppp0\""
- print "# ppp_username=\"my_username\""
- print "# ppp_passwd=\"my_password\""
- print "# pptp_server_ip=\"192.168.0.1\""
+ print "config interface wan"
+ p("ifname", "wan_ifname")
+ print " option proto dhcp"
}
' > /etc/config/network
diff --git a/package/base-files/default/etc/hotplug.d/net/10-net b/package/base-files/default/etc/hotplug.d/net/10-net
index f306ae342..d5b7f6b0f 100644
--- a/package/base-files/default/etc/hotplug.d/net/10-net
+++ b/package/base-files/default/etc/hotplug.d/net/10-net
@@ -1,191 +1,28 @@
-#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
-find_name()
-{
- for ifname in lan wan wifi ${ifnames}; do
- IFTYPE="${ifname}"
- eval "IFPROTO=\"\${${IFTYPE}_proto}\""
- eval "IFACE=\"\${${IFTYPE}_ifname}\""
- case "$IFPROTO" in
- ""|none);;
- static|dhcp)
- [ "${IFACE}" = "$INTERFACE" ] && return 0
- [ "${IFACE%%[0-9]*}" = "br" ] && {
- eval "ifs=\"\${${IFTYPE}_ifnames}\""
- for part in $ifs; do
- [ "$part" = "$INTERFACE" ] && return 0
- done
- }
- ;;
- pppoa)
- [ "$INTERFACE" = "atm0" \
- -a -x /sbin/ifup.${IFPROTO} ] && return 0
- ;;
- *)
- eval "device=\"\${${IFTYPE}_device}\""
- [ "$device" = "$INTERFACE" \
- -a -x /sbin/ifup.${IFPROTO} ] && return 0
- ;;
- esac
- done
- IFACE=""
- IFTYPE=""
- IFPROTO=""
- return 255
-}
-
-do_ifup() {
- if="$3"
- eval "if_proto=\"\${${2}_proto}\""
-
- pidfile=/var/run/${if}.pid
- [ -f $pidfile ] && $DEBUG kill $(cat $pidfile)
-
- case "$1" in
- static)
- eval "ip=\"\${${2}_ipaddr}\""
- eval "ip6=\"\${${2}_ip6addr}\""
- eval "netmask=\"\${${2}_netmask}\""
- eval "gateway=\"\${${2}_gateway}\""
- eval "dns=\"\${${2}_dns}\""
- eval "static_route=\"\${${2}_static_route}\""
-
- $DEBUG ifconfig $if $ip ${netmask:+netmask $netmask} broadcast + up
- [ -n "$ip6" ] && $DEBUG ifconfig $if add $ip6
-
- [ -n "$static_route" ] && {
- for route in $static_route; do
- if [ "$(echo $route | cut -d \/ -f2)" != "32" ];
- then
- route add -net $(echo $route | cut -d \/ -f1) netmask $(echo $route | cut -d \/ -f1) dev $if
- else
- route add -host $(echo $route | cut -d \/ -f1) dev $if
- fi
- done
- }
+include network
- ${gateway:+$DEBUG route add default gw $gateway}
+addif() {
+ scan_interfaces
+ setup_interface "$INTERFACE"
- [ -f /tmp/resolv.conf ] || {
- debug "# --- creating /tmp/resolv.conf ---"
- for ns in $dns; do
- echo "nameserver $ns" >> /tmp/resolv.conf
- done
- }
-
- env -i ACTION="ifup" INTERFACE="${2}" PROTO=static /sbin/hotplug "iface" &
- ;;
- dhcp)
- eval "ip=\"\${${2}_ipaddr}\""
- eval "netmask=\"\${${2}_netmask}\""
- eval "hostname=\"\${${2}_hostname}\""
-
- $DEBUG ifconfig $if $ip ${netmask:+netmask $netmask} broadcast + up
-
- args="-i $if ${ip:+-r $ip} -b -p $pidfile"
- hostname="${hostname%%.*}"
- args="$args${hostname:+ -H $hostname}"
- [ "$if_proto" = "pptp" ] && args="$args -n -q" || args="$args -R &"
- ${DEBUG:-eval} "udhcpc $args"
- # hotplug events are handled by /usr/share/udhcpc/default.script
- ;;
- *)
- if [ -x "/sbin/ifup.$1" ]; then
- ( $DEBUG . /sbin/ifup.$1 ${2} $3 )
- fi
- ;;
- esac
-}
-
-do_register()
-{
- [ -z "$IFTYPE" -o -z "$IFPROTO" ] && {
- find_name || {
- case "${INTERFACE%%[0-9]*}" in
- wds)
- for ifname in lan wifi; do
- eval "if=\"\${${ifname}_ifname}\""
- [ -z "$IFPROTO" ] && [ "$if" = "br0" ] && {
- eval "IFPROTO=\"\${${2}_proto}\""
- IFTYPE="${tmp}"
- }
- done
- [ -z "$IFPROTO" ] && return 0
- ;;
- atm)
- for tmp in lan wan wifi ${ifnames}; do
- eval "if_proto=\"\${${2}_proto}\""
- [ "$if_proto" = "pppoa" ] && {
- do_ifup "pppoa" "$tmp" "$INTERFACE"
- return 0
- }
- done
- ;;
- *)
- return 0
- ;;
- esac
- }
- }
-
- case "${INTERFACE%%[0-9]*}" in
- ppp|atm);;
- *)
- eval "mac=\"\${${IFTYPE}_hwaddr}\""
- ${mac:+$DEBUG ifconfig $INTERFACE down hw ether $mac}
- ;;
- esac
-
- eval "if=\"\${${IFTYPE}_ifname}\""
- if [ "${if%%[0-9]}" = "br" ]; then
- if_valid "$INTERFACE" && {
- ifconfig "$if" 2>&- >&- || {
- eval "stp=\"\${${IFTYPE}_stp}\""
- $DEBUG brctl addbr "$if"
- $DEBUG brctl setfd "$if" 0
- $DEBUG brctl stp "$if" "${stp:-0}"
+ # find all vlan configurations for this interface and set them up as well
+ for ifc in $interfaces; do
+ config_get type "$ifc" type
+ case "$type" in
+ bridge) config_get ifs "$ifc" ifnames;;
+ *) config_get ifs "$ifc" ifname;;
+ esac
+ for dev in $ifs; do
+ [ "${dev%%\.*}" = "$INTERFACE" -a "$dev" != "$INTERFACE" ] && {
+ add_vlan "$dev"
}
-
- if [ "$INTERFACE" != "$if" ]; then
- $DEBUG ifconfig "$INTERFACE" 0.0.0.0 up
- $DEBUG brctl addif "$if" "$INTERFACE"
- $DEBUG ifconfig "$INTERFACE" allmulti
- else
- do_ifup "$IFPROTO" "$IFTYPE" "$if"
- fi
- }
- else
- [ "${INTERFACE%%[0-9]*}" = "ppp" ] || do_ifup "$IFPROTO" "$IFTYPE" "$if"
- fi
-}
-
-do_unregister() {
- [ -z "$IFTYPE" -o -z "$IFPROTO" ] && {
- find_name || return 0
- }
-
- [ "${IFACE%%[0-9]*}" = "br" ] && {
- if [ "$INTERFACE" != "$IFACE" ]; then
- brctl delif "$IFACE" "$INTERFACE" 2>&- >&-
- else
- brctl delbr "$IFACE" 2>&- >&-
- fi
- }
-
- case "$IFPROTO" in
- pppoe|pppoa|pptp)
- killall pppd 2>&- >&-
- ;;
- dhcp)
- [ -f /var/run/${INTERFACE}.pid ] && kill "$(cat /var/run/${INTERFACE}.pid)" 2>&- >&-
- ;;
- esac
-
- [ "${INTERFACE%%[0-9]*}" = "atm" ] || ifconfig "$INTERFACE" 0.0.0.0 down 2>&-
+ done
+ done
}
case "$ACTION" in
- add|register) do_register;;
- remove|unregister) do_unregister;;
+ add|register)
+ addif
+ ;;
esac
diff --git a/package/base-files/default/etc/init.d/S10boot b/package/base-files/default/etc/init.d/S10boot
index cb5c6ac4a..19420eda5 100755
--- a/package/base-files/default/etc/init.d/S10boot
+++ b/package/base-files/default/etc/init.d/S10boot
@@ -5,13 +5,14 @@
[ -f /proc/mounts ] || /sbin/mount_root
[ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc
-vconfig set_name_type VLAN_PLUS_VID_NO_PAD
+vconfig set_name_type DEV_PLUS_VID_NO_PAD
HOSTNAME=${wan_hostname%%.*}
echo ${HOSTNAME:=OpenWrt}>/proc/sys/kernel/hostname
mkdir -p /var/run
mkdir -p /var/log
+mkdir -p /var/lock
touch /var/log/wtmp
touch /var/log/lastlog
[ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
diff --git a/package/base-files/default/etc/init.d/S40network b/package/base-files/default/etc/init.d/S40network
new file mode 100755
index 000000000..20a11845b
--- /dev/null
+++ b/package/base-files/default/etc/init.d/S40network
@@ -0,0 +1,9 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.orga
+
+setup_switch() { return 0; }
+
+. /etc/functions.sh
+include network
+setup_switch
+/sbin/wifi
diff --git a/package/base-files/default/etc/init.d/rcS b/package/base-files/default/etc/init.d/rcS
index dad989fe0..2aa70910c 100755
--- a/package/base-files/default/etc/init.d/rcS
+++ b/package/base-files/default/etc/init.d/rcS
@@ -3,12 +3,13 @@
${FAILSAFE:+exit}
-[ -f /etc/config/network ] && . /etc/config/network
-eval $(ipcalc "$log_ipaddr")
-[ "$log_ipaddr" = "$IP" ] || log_ipaddr=""
-syslogd -C 16 ${log_ipaddr:+-L -R $log_ipaddr}
+# FIXME: add logging configuration
+#[ -f /etc/config/network ] && . /etc/config/network
+#eval $(ipcalc "$log_ipaddr")
+#[ "$log_ipaddr" = "$IP" ] || log_ipaddr=""
+syslogd -C 16 #${log_ipaddr:+-L -R $log_ipaddr}
klogd
-#${FAILSAFE:+telnetd -l /bin/login; ifup lan; exit}
+
for i in /etc/init.d/S*; do
$i start 2>&1
done | logger -s -p 6 -t '' &
diff --git a/package/base-files/default/lib/network/config.sh b/package/base-files/default/lib/network/config.sh
new file mode 100755
index 000000000..59ec84aba
--- /dev/null
+++ b/package/base-files/default/lib/network/config.sh
@@ -0,0 +1,147 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+# DEBUG="echo"
+
+find_config() {
+ local type iface ifn
+ for ifn in $interfaces; do
+ config_get type "$ifn" type
+ config_get iface "$ifn" ifname
+ case "$type" in
+ bridge)
+ config_get iface "$ifn" ifnames
+ ;;
+ esac
+ for ifc in $iface; do
+ [ "$ifc" = "$1" ] && {
+ echo "$ifn"
+ return 0
+ }
+ done
+ done
+
+ return 1;
+}
+
+scan_interfaces() {
+ local mode type iface
+ interfaces=
+ config_cb() {
+ config_get type "$CONFIG_SECTION" TYPE
+ case "$type" in
+ interface)
+ config_get type "$CONFIG_SECTION" type
+ config_get mode "$CONFIG_SECTION" proto
+ case "$type" in
+ bridge)
+ config_get iface "$CONFIG_SECTION" ifname
+ iface="${iface:-br-$CONFIG_SECTION}"
+ config_set "$CONFIG_SECTION" ifname "$iface"
+ ;;
+ esac
+ append interfaces "$CONFIG_SECTION"
+ ( type "scan_$mode" ) >/dev/null 2>/dev/null && eval "scan_$mode '$CONFIG_SECTION'"
+ ;;
+ esac
+ }
+ config_load network
+}
+
+add_vlan() {
+ local vif="${1%\.*}"
+
+ [ "$1" = "$vif" ] || ifconfig "$1" >/dev/null 2>/dev/null || {
+ ifconfig "$vif" up 2>/dev/null >/dev/null || add_vlan "$vif"
+ $DEBUG vconfig add "$vif" "${1##*\.}"
+ }
+}
+
+setup_interface() {
+ local iface="$1"
+ local config="$2"
+ local proto="$3"
+
+ [ -n "$config" ] || {
+ config=$(find_config "$iface")
+ [ "$?" = 0 ] || return 1
+ }
+
+ [ -n "$proto" ] || {
+ config_get proto "$config" proto
+ }
+
+ config_get iftype "$config" type
+
+ # Setup VLAN interfaces
+ add_vlan "$iface"
+
+ # Setup bridging
+ case "$iftype" in
+ bridge)
+ config_get bridge_ifname "$config" ifname
+ ifconfig "$iface" up 2>/dev/null >/dev/null
+ ifconfig "$bridge_ifname" 2>/dev/null >/dev/null && {
+ $DEBUG brctl addif "$bridge_ifname" "$iface"
+ return 0
+ } || {
+ $DEBUG brctl addbr "$bridge_ifname"
+ $DEBUG brctl setfd "$bridge_ifname" 0
+ $DEBUG brctl addif "$bridge_ifname" "$iface"
+ iface="$bridge_ifname"
+ }
+ ;;
+ esac
+
+ # Interface settings
+ config_get mtu "$config" mtu
+ $DEBUG ifconfig "$iface" ${mtu:+mtu $mtu} up
+
+ pidfile="/var/run/$iface.pid"
+ case "$proto" in
+ static)
+ config_get ipaddr "$config" ipaddr
+ config_get netmask "$config" netmask
+ [ -z "$ipaddr" -o -z "$netmask" ] && return 1
+
+ config_get ip6addr "$config" ip6addr
+ config_get gateway "$config" gateway
+ config_get dns "$config" dns
+
+ $DEBUG ifconfig "$iface" "$ipaddr" netmask "$netmask"
+ [ -z "$gateway" ] || route add default gw "$gateway"
+ [ -z "$dns" -o -f /tmp/resolv.conf ] || {
+ for ns in $dns; do
+ echo "nameserver $ns" >> /tmp/resolv.conf
+ done
+ }
+
+ env -i ACTION="ifup" INTERFACE="config" DEVICE="$iface" PROTO=static /sbin/hotplug "iface" &
+ ;;
+ dhcp)
+ pid="$(cat "$pidfile" 2>/dev/null)"
+ [ -n "$pid" -a -d "/proc/$pid" ] && kill -9 "$pid"
+
+ config_get ipaddr "$config" ipaddr
+ config_get netmask "$config" netmask
+ config_get hostname "$config" hostname
+ config_get proto1 "$config" proto
+
+ [ -z "$ipaddr" ] || \
+ $DEBUG ifconfig "$iface" "$ipaddr" ${netmask:+netmask "$netmask"}
+
+ # don't stay running in background if dhcp is not the main proto on the interface (e.g. when using pptp)
+ [ "$proto1" != "$proto" ] && dhcpopts="-n -q"
+ $DEBUG udhcpc -i "$iface" ${ipaddr:+-r $ipaddr} ${hostname:+-H $hostname} -b -p "$pidfile" ${dhcpopts:- -R &}
+ ;;
+ *)
+ if ( eval "type setup_interface_$proto" ) >/dev/null 2>/dev/null; then
+ eval "setup_interface_$proto '$iface' '$config' '$proto'"
+ else
+ echo "Interface type $proto not supported."
+ return 1
+ fi
+ ;;
+ esac
+}
+
diff --git a/package/base-files/default/sbin/hotplug b/package/base-files/default/sbin/hotplug
index afe52a446..b1b6f97b2 100755
--- a/package/base-files/default/sbin/hotplug
+++ b/package/base-files/default/sbin/hotplug
@@ -13,7 +13,6 @@
}
. /etc/functions.sh
-. /etc/config/network
PATH=/bin:/sbin:/usr/bin:/usr/sbin
LOGNAME=root
diff --git a/package/base-files/default/sbin/ifdown b/package/base-files/default/sbin/ifdown
index 50ffee530..7debb9559 100755
--- a/package/base-files/default/sbin/ifdown
+++ b/package/base-files/default/sbin/ifdown
@@ -3,18 +3,32 @@
[ $# = 0 ] && { echo " $0 <group>"; exit; }
. /etc/functions.sh
-. /etc/config/network
+include network
+scan_interfaces
debug "### ifdown $type ###"
type=$1
-eval "if_proto=\"\${${type}_proto}\""
-eval "if=\"\${${type}_ifname}\""
-[ "${if%%[0-9]}" = "ppp" ] && eval "if=\"\${${type}_device}\""
+config_get proto "$type" proto
+[ -z "$proto" ] && { echo "interface not found."; exit; }
-case "$if_proto" in
- pppoa) hotplug_dev unregister atm0; exit 0 ;;
- ""|none) exit 0;;
-esac
+# kill active ppp daemon
+pid="$(cat /var/run/ppp-${type}.pid 2>/dev/null)"
+[ -n "$pid" -a -d "/proc/$pid" ] && {
+ kill $pid
+ sleep 1
+ [ -d "/proc/$pid" ] && kill -9 $pid
+}
-hotplug_dev unregister "$if"
+# kill any other process associated with the interface
+config_get ifname "$type" ifname
+pid="$(cat /var/run/${ifname}.pid 2>/dev/null)"
+[ -n "$pid" -a -d "/proc/$pid" ] && kill -9 $pid
+
+config_get ifname "$type" ifname
+ifconfig "$ifname" >/dev/null 2>/dev/null && {
+ ifconfig "$ifname" 0.0.0.0 down
+
+ config_get iftype "$type" type
+ [ "$iftype" = "bridge" ] && brctl delbr "$ifname"
+}
diff --git a/package/base-files/default/sbin/ifup b/package/base-files/default/sbin/ifup
index 390f96039..c40de38ad 100755
--- a/package/base-files/default/sbin/ifup
+++ b/package/base-files/default/sbin/ifup
@@ -1,38 +1,18 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
-[ $# = 0 ] && { echo " $0 <group>"; exit; }
-. /etc/functions.sh
-. /etc/config/network
+. /sbin/ifdown "$@"
-ifdown $1
-
-debug "### ifup $type ###"
-type=$1
-
-eval "if_proto=\"\${${type}_proto}\""
-eval "if=\"\${${type}_ifname}\""
-[ "${if%%[0-9]}" = "ppp" ] && eval "if=\"\${${type}_device}\""
-
-case "$if_proto" in
- pppoa) hotplug_dev register atm0; exit 0 ;;
- pppoe)
- # PPPoE over ATM
- [ "$if" = "nas0" ] && {
- ifconfig nas0 2>&- >&- || {
- hotplug_dev register atm0
- exit 0
- }
- }
+config_get iftype "$1" type
+case "$iftype" in
+ bridge)
+ config_get ifname "$1" ifnames
+ ;;
+ *)
+ config_get ifname "$1" ifname
;;
- none|"") exit 0;;
esac
-if [ "${if%%[0-9]}" = "br" ]; then
- eval "ifnames=\"\${${type}_ifnames}\""
- for sif in $ifnames; do
- hotplug_dev register "$sif"
- done
-else
- hotplug_dev register "$if"
-fi
+for dev in $ifname; do
+ setup_interface "$dev" "$1"
+done
diff --git a/package/base-files/default/sbin/wifi b/package/base-files/default/sbin/wifi
index 63b2f121b..f1ac94fa3 100755
--- a/package/base-files/default/sbin/wifi
+++ b/package/base-files/default/sbin/wifi
@@ -30,12 +30,7 @@ config_cb() {
}
config_load wireless
-
-[ -d /lib/wifi -a -n "$(ls /lib/wifi/*.sh 2>&-)" ] && {
- for script in /lib/wifi/*.sh; do
- . $script
- done
-}
+include wifi
for device in $DEVICES; do (
config_get type "$device" type
diff --git a/package/base-files/default/usr/share/udhcpc/default.script b/package/base-files/default/usr/share/udhcpc/default.script
index 4604648e6..a244e05a1 100755
--- a/package/base-files/default/usr/share/udhcpc/default.script
+++ b/package/base-files/default/usr/share/udhcpc/default.script
@@ -1,15 +1,19 @@
#!/bin/sh
[ -z "$1" ] && echo "Error: should be run by udhcpc" && exit 1
-. /etc/config/network
+. /etc/functions.sh
+include network
RESOLV_CONF="/tmp/resolv.conf"
hotplug_event() {
- for ifname in lan wan wifi ${ifnames}; do
- eval "proto=\"\${${ifname}_proto}\""
- eval "if=\"\${${ifname}_ifname}\""
+ scan_interfaces
+ for ifc in $interfaces; do
+ config_get ifname $ifc ifname
+ [ "$ifname" = "$interface" ] || continue
+
+ config_get proto $ifc proto
[ "$proto" = "dhcp" ] || continue
- [ "$if" = "$interface" ] || continue
+
env -i ACTION="$1" INTERFACE="$ifname" PROTO=dhcp /sbin/hotplug iface
done
}
diff --git a/package/base-files/rb532-2.6/etc/config/network b/package/base-files/rb532-2.6/etc/config/network
index 2bb48b886..6f089fe99 100644
--- a/package/base-files/rb532-2.6/etc/config/network
+++ b/package/base-files/rb532-2.6/etc/config/network
@@ -1,6 +1,6 @@
-# Network configuration file
# Copyright (C) 2006 OpenWrt.org
-## LAN configuration
-lan_ifname="eth0"
-lan_proto="dhcp"
+config interface lan
+ option ifname eth0
+ option proto dhcp
+
diff --git a/package/base-files/sibyte-2.6/etc/config/network b/package/base-files/sibyte-2.6/etc/config/network
index 576677bf7..95d7575c9 100644
--- a/package/base-files/sibyte-2.6/etc/config/network
+++ b/package/base-files/sibyte-2.6/etc/config/network
@@ -1,13 +1,8 @@
-# Network configuration file
# Copyright (C) 2006 OpenWrt.org
-## LAN configuration
-lan_ifname="br0"
-lan_ifnames="eth0 ath0"
-lan_proto="static"
-lan_ipaddr="192.168.1.1"
-lan_netmask="255.255.255.0"
-
-## WAN configuration
-wan_ifname=""
-wan_proto="none"
+config interface lan
+ option type bridge
+ option ifnames "eth0 ath0"
+ option proto static
+ option ipaddr 192.168.1.1
+ option netmask 255.255.255.0
diff --git a/package/base-files/x86-2.4/etc/config/network b/package/base-files/x86-2.4/etc/config/network
index 7bcfd0870..9f521c05b 100644
--- a/package/base-files/x86-2.4/etc/config/network
+++ b/package/base-files/x86-2.4/etc/config/network
@@ -1,13 +1,13 @@
-# Network configuration file
# Copyright (C) 2006 OpenWrt.org
-## LAN configuration
-lan_ifname="br0"
-lan_ifnames="eth1 eth2"
-lan_proto="static"
-lan_ipaddr="192.168.1.1"
-lan_netmask="255.255.255.0"
+config interface lan
+ option type bridge
+ option ifnames "eth1 eth2"
+ option proto static
+ option ipaddr 192.168.1.1
+ option netmask 255.255.255.0
+
+config interface wan
+ option ifname eth0
+ option proto dhcp
-## WAN configuration
-wan_ifname="eth0"
-wan_proto="dhcp"
diff --git a/package/base-files/x86-2.6/etc/config/network b/package/base-files/x86-2.6/etc/config/network
index 7bcfd0870..9f521c05b 100644
--- a/package/base-files/x86-2.6/etc/config/network
+++ b/package/base-files/x86-2.6/etc/config/network
@@ -1,13 +1,13 @@
-# Network configuration file
# Copyright (C) 2006 OpenWrt.org
-## LAN configuration
-lan_ifname="br0"
-lan_ifnames="eth1 eth2"
-lan_proto="static"
-lan_ipaddr="192.168.1.1"
-lan_netmask="255.255.255.0"
+config interface lan
+ option type bridge
+ option ifnames "eth1 eth2"
+ option proto static
+ option ipaddr 192.168.1.1
+ option netmask 255.255.255.0
+
+config interface wan
+ option ifname eth0
+ option proto dhcp
-## WAN configuration
-wan_ifname="eth0"
-wan_proto="dhcp"
diff --git a/package/base-files/xscale-2.6/etc/config/network b/package/base-files/xscale-2.6/etc/config/network
index 2bb48b886..aadd4aa8e 100644
--- a/package/base-files/xscale-2.6/etc/config/network
+++ b/package/base-files/xscale-2.6/etc/config/network
@@ -1,6 +1,5 @@
# Network configuration file
-# Copyright (C) 2006 OpenWrt.org
-## LAN configuration
-lan_ifname="eth0"
-lan_proto="dhcp"
+config interface lan
+ option ifname eth0
+ option proto dhcp