diff options
Diffstat (limited to 'package')
39 files changed, 481 insertions, 649 deletions
diff --git a/package/base-files/ar7-2.4/etc/config/network b/package/base-files/ar7-2.4/etc/config/network index 353538bf49..19a858e163 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 65797797ee..aadd4aa8ed 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 576677bf7c..95d7575c92 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 48abdf4062..0000000000 --- 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 0f53c0c9c9..82e4ab9986 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 90a92bd2b0..0000000000 --- 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 0f53c0c9c9..82e4ab9986 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 f306ae342d..d5b7f6b0fa 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 cb5c6ac4a7..19420eda53 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 0000000000..20a11845b6 --- /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 dad989fe09..2aa70910c3 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 0000000000..59ec84aba8 --- /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 afe52a446f..b1b6f97b23 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 50ffee5304..7debb9559f 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 390f960395..c40de38ad8 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 63b2f121bd..f1ac94fa3a 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 4604648e6b..a244e05a15 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 2bb48b8863..6f089fe992 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 576677bf7c..95d7575c92 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 7bcfd0870a..9f521c05bf 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 7bcfd0870a..9f521c05bf 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 2bb48b8863..aadd4aa8ed 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 diff --git a/package/broadcom-wl/files/lib/wifi/broadcom.sh b/package/broadcom-wl/files/lib/wifi/broadcom.sh index 6cac60c0b7..53d1cf7925 100644 --- a/package/broadcom-wl/files/lib/wifi/broadcom.sh +++ b/package/broadcom-wl/files/lib/wifi/broadcom.sh @@ -1,3 +1,15 @@ +bridge_interface() { + ( + . /etc/functions.sh + include network + scan_interfaces + cfg="$(find_config "$1")" + [ -z "$cfg" ] && return 0 + config_get type "$cfg" type + [ "$type" = bridge ] && config_get "$type" bridge + ) +} + scan_broadcom() { local device="$1" @@ -127,7 +139,7 @@ setup_broadcom() { config_get ifname "$vif" ifname append if_up "ifconfig $ifname up" ";$N" [ -z "$nasopts" ] || { - config_get bridge "$vif" bridge # XXX: integrate with /etc/config/network later + bridge="$(bridge_interface "$ifname")" eval "${vif}_ssid=\"\$ssid\"" mode="-A" [ "$vif" = "$sta_if" ] && mode="-S" diff --git a/package/dnsmasq/files/dnsmasq.init b/package/dnsmasq/files/dnsmasq.init index 17ef43c3d5..140f727f46 100644 --- a/package/dnsmasq/files/dnsmasq.init +++ b/package/dnsmasq/files/dnsmasq.init @@ -1,5 +1,7 @@ #!/bin/sh -. /etc/config/network +. /etc/functions.sh +include network +scan_interfaces # The following is to automatically configure the DHCP settings # based on config settings. Feel free to replace all this crap @@ -10,7 +12,7 @@ args="" iface=lan -eval "ifname=\${${iface}_ifname}" +config_get ifname "$iface" ifname dhcp_enable="${dhcp_enable:-1}" dhcp_start="${dhcp_start:-100}" @@ -26,8 +28,8 @@ dhcp_lease="${dhcp_lease:-12h}" # no existing DHCP server? # calculate settings - eval "ipaddr=\${${iface}_ipaddr}" - eval "netmask=\${${iface}_netmask}" + config_get ipaddr "$iface" ipaddr + config_get netmask "$iface" netmask eval $(ipcalc $ipaddr $netmask ${dhcp_start:-100} ${dhcp_num:-150}) # and pass the args via config parser defines @@ -39,6 +41,8 @@ dhcp_lease="${dhcp_lease:-12h}" } # ignore requests from wan interface + config_get wan_proto wan proto + config_get wan_ifname wan ifname [ -z "$wan_proto" -o "$wan_proto" = "none" ] || echo "@define wan_ifname $wan_ifname" cat /etc/dnsmasq.conf diff --git a/package/iptables/files/firewall.awk b/package/iptables/files/firewall.awk index 5378330045..902c7b1888 100644 --- a/package/iptables/files/firewall.awk +++ b/package/iptables/files/firewall.awk @@ -1,10 +1,7 @@ # Copyright (C) 2006 OpenWrt.org BEGIN { - print ". /etc/config/network" - print "proto=\"$wan_proto\"" - print "[ -z \"$proto\" -o \"$proto\" = \"none\" ] && exit" - print "ifname=\"$wan_ifname\"" + print "ifname=\"$WAN\"" print "[ -z \"$ifname\" ] && exit" print "" print "iptables -X input_$ifname 2>&- >&-" diff --git a/package/iptables/files/firewall.init b/package/iptables/files/firewall.init index e174d84bb2..a0bd99ef9a 100755 --- a/package/iptables/files/firewall.init +++ b/package/iptables/files/firewall.init @@ -3,9 +3,12 @@ ## Please make changes in /etc/firewall.user -. /etc/config/network -WAN="$wan_ifname" -LAN="$lan_ifname" +. /etc/functions.sh +include network + +scan_interfaces +config_get WAN wan ifname +config_get LAN lan ifname ## CLEAR TABLES for T in filter nat; do @@ -35,7 +38,7 @@ iptables -t nat -N postrouting_rule iptables -A INPUT -j input_rule # allow - [ -z "$WAN" ] || iptables -A INPUT -i \! $WAN -j ACCEPT # allow from lan/wifi interfaces + iptables -A INPUT ${WAN:+-i \! $WAN} -j ACCEPT # allow from lan/wifi interfaces iptables -A INPUT -p icmp -j ACCEPT # allow ICMP iptables -A INPUT -p gre -j ACCEPT # allow GRE diff --git a/package/iptables/files/firewall.user b/package/iptables/files/firewall.user index 1fb862e9b0..5f295babf2 100755..100644 --- a/package/iptables/files/firewall.user +++ b/package/iptables/files/firewall.user @@ -1,11 +1,6 @@ #!/bin/sh # Copyright (C) 2006 OpenWrt.org -. /etc/config/network - -WAN="$wan_ifname" -LAN="$lan_ifname" - iptables -F input_rule iptables -F output_rule iptables -F forwarding_rule diff --git a/package/ppp/Makefile b/package/ppp/Makefile index 85d52d0542..e49b610c36 100644 --- a/package/ppp/Makefile +++ b/package/ppp/Makefile @@ -95,6 +95,8 @@ define Build/Compile endef define Package/ppp/install + install -d -m0755 $(1)/lib/network + install -m0755 ./files/ppp.sh $(1)/lib/network/ install -d -m0755 $(1)/etc/ppp install -m0600 ./files/etc/ppp/chap-secrets $(1)/etc/ppp/ install -m0644 ./files/etc/ppp/filter $(1)/etc/ppp/ @@ -110,19 +112,19 @@ define Package/ppp/install endef define Package/ppp-mod-pppoa/install + install -d -m0755 $(1)/lib/network + install -m0755 ./files/pppoa.sh $(1)/lib/network/ install -d -m0755 $(1)/usr/lib/pppd/$(PKG_VERSION) install -m0755 $(PKG_INSTALL_DIR)/usr/lib/pppd/$(PKG_VERSION)/pppoatm.so \ $(1)/usr/lib/pppd/$(PKG_VERSION)/ - install -d -m0755 $(1)/sbin - install -m0755 ./files/ifup.pppoa $(1)/sbin/ endef define Package/ppp-mod-pppoe/install + install -d -m0755 $(1)/lib/network + install -m0755 ./files/pppoe.sh $(1)/lib/network/ install -d -m0755 $(1)/usr/lib/pppd/$(PKG_VERSION) install -m0755 $(PKG_INSTALL_DIR)/usr/lib/pppd/$(PKG_VERSION)/rp-pppoe.so \ $(1)/usr/lib/pppd/$(PKG_VERSION)/ - install -d -m0755 $(1)/sbin - install -m0755 ./files/ifup.pppoe $(1)/sbin/ endef define Package/ppp-mod-radius/install diff --git a/package/ppp/files/ifup.pppoa b/package/ppp/files/ifup.pppoa deleted file mode 100644 index f78a162ce5..0000000000 --- a/package/ppp/files/ifup.pppoa +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -[ $# = 0 ] && { echo " $0 <group>"; exit; } -. /etc/config/network -type=$1 - -eval "proto=\"\${${type}_proto}\"" -[ "$proto" = "pppoa" ] || { - echo "$0: ${type}_proto isn't pppoa" - exit -} - -mkdir -p /var/lock - -for module in slhc ppp_generic pppoatm; do - /sbin/insmod $module 2>&- >&- -done - -KEEPALIVE=${ppp_redialperiod:+lcp-echo-interval $ppp_redialperiod lcp-echo-failure 5} -case "$ppp_demand" in - on|1|enabled) - DEMAND=${ppp_idletime:+demand idle $ppp_idletime} - [ -f /etc/ppp/filter ] && DEMAND=${DEMAND:+precompiled-active-filter /etc/ppp/filter $DEMAND} - ;; - *) DEMAND="persist";; -esac -MTU=${ppp_mtu:-1500} - -/usr/sbin/pppd \ - plugin pppoatm.so ${atm_vpi:-8}.${atm_vci:-35} \ - usepeerdns \ - defaultroute \ - linkname $type \ - ipparam $type \ - user "$ppp_username" \ - password "$ppp_passwd" \ - mtu $MTU mru $MTU \ - $DEMAND \ - $KEEPALIVE diff --git a/package/ppp/files/ifup.pppoe b/package/ppp/files/ifup.pppoe deleted file mode 100644 index c7019fc398..0000000000 --- a/package/ppp/files/ifup.pppoe +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -[ $# = 0 ] && { echo " $0 <group>"; exit; } -. /etc/config/network -type=$1 - -eval "proto=\"\${${type}_proto}\"" -[ "$proto" = "pppoe" ] || { - echo "$0: ${type}_proto isn't pppoe" - exit -} - -mkdir -p /var/lock - -for module in slhc ppp_generic pppox pppoe; do - /sbin/insmod $module 2>&- >&- -done - -eval "IFNAME=\"\${${type}_device}\"" -KEEPALIVE=${ppp_redialperiod:+lcp-echo-interval $ppp_redialperiod lcp-echo-failure 5} -case "$ppp_demand" in - on|1|enabled) - DEMAND=${ppp_idletime:+demand idle $ppp_idletime} - [ -f /etc/ppp/filter ] && DEMAND=${DEMAND:+precompiled-active-filter /etc/ppp/filter $DEMAND} - ;; - *) DEMAND="persist";; -esac -MTU=${ppp_mtu:-1492} - -ifconfig $IFNAME up -/usr/sbin/pppd \ - plugin rp-pppoe.so \ - connect /bin/true \ - usepeerdns \ - defaultroute \ - linkname $type \ - ipparam $type \ - user "$ppp_username" \ - password "$ppp_passwd" \ - mtu $MTU mru $MTU \ - $DEMAND \ - $KEEPALIVE \ - nic-$IFNAME - diff --git a/package/ppp/files/ppp.sh b/package/ppp/files/ppp.sh new file mode 100644 index 0000000000..0bb77b8284 --- /dev/null +++ b/package/ppp/files/ppp.sh @@ -0,0 +1,27 @@ +scan_ppp() { + config_get ifname "$1" ifname + pppdev="${pppdev:-0}" + config_set "$1" device "$ifname" + config_set "$1" ifname "ppp$pppdev" + config_set "$1" unit "$pppdev" +} + +start_pppd() { + local cfg="$1"; shift + config_get device "$cfg" device + config_get unit "$cfg" unit + config_get username "$cfg" username + config_get password "$cfg" password + config_get keepalive "$cfg" keepalive + config_get demand "$cfg" demand + [ -n "$demand" ] && echo "nameserver 1.1.1.1" > /tmp/resolv.conf + /usr/sbin/pppd "$@" \ + ${keepalive:+lcp-echo-interval 5 lcp-echo-failure $keepalive} \ + ${demand:+precompiled-active-filter /etc/ppp/filter demand idle }${demand:-persist} \ + usepeerdns \ + defaultroute \ + replacedefaultroute \ + ${username:+username "$username" password "$password"} \ + linkname "$cfg" \ + ipparam "$cfg" +} diff --git a/package/ppp/files/pppoa.sh b/package/ppp/files/pppoa.sh new file mode 100644 index 0000000000..e6530b073e --- /dev/null +++ b/package/ppp/files/pppoa.sh @@ -0,0 +1,20 @@ +scan_pppoa() { + scan_ppp "$@" +} + +setup_interface_pppoa() { + local iface="$1" + local config="$2" + + config_get device "$config" device + + for module in slhc ppp_generic pppoatm; do + /sbin/insmod $module 2>&- >&- + done + + config_get mtu "$cfg" mtu + mtu=${mtu:-1492} + start_pppd "$config" \ + plugin pppoatm.so ${atm_vpi:-8}.${atm_vci:-35} \ + mtu $mtu mru $mtu +} diff --git a/package/ppp/files/pppoe.sh b/package/ppp/files/pppoe.sh new file mode 100644 index 0000000000..f263caaeef --- /dev/null +++ b/package/ppp/files/pppoe.sh @@ -0,0 +1,21 @@ +scan_pppoe() { + scan_ppp "$@" +} + +setup_interface_pppoe() { + local iface="$1" + local config="$2" + + config_get device "$config" device + + for module in slhc ppp_generic pppox pppoe; do + /sbin/insmod $module 2>&- >&- + done + + config_get mtu "$cfg" mtu + mtu=${mtu:-1480} + start_pppd "$config" \ + plugin rp-pppoe.so \ + mtu $mtu mru $mtu \ + "nic-$device" +} diff --git a/package/ppp/files/pptp.sh b/package/ppp/files/pptp.sh new file mode 100644 index 0000000000..7b33ac1ff7 --- /dev/null +++ b/package/ppp/files/pptp.sh @@ -0,0 +1,3 @@ +scan_pptp() { + scan_ppp "$@" +} diff --git a/package/pptp/Makefile b/package/pptp/Makefile index 061e55395e..b060c12a79 100644 --- a/package/pptp/Makefile +++ b/package/pptp/Makefile @@ -31,8 +31,8 @@ endef define Package/pptp/install install -d -m0755 $(1)/etc/ppp install -m0644 ./files/options.pptp $(1)/etc/ppp/ - install -d -m0755 $(1)/sbin - install -m0755 ./files/ifup.pptp $(1)/sbin/ + install -d -m0755 $(1)/lib/network + install -m0755 ./files/pptp.sh $(1)/lib/network/ install -d -m0755 $(1)/usr/sbin install -m0755 $(PKG_BUILD_DIR)/pptp $(1)/usr/sbin/ endef diff --git a/package/pptp/files/ifup.pptp b/package/pptp/files/ifup.pptp deleted file mode 100644 index f401a36b2f..0000000000 --- a/package/pptp/files/ifup.pptp +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh -[ $# = 0 ] && { echo " $0 <group>"; exit; } -. /etc/config/network -type=$1 - -eval "proto=\"\${${type}_proto}\"" -[ "$proto" = "pptp" ] || { - echo "$0: ${type}_proto isn't pptp" - exit -} - -mkdir -p /var/lock - -for module in slhc ppp_generic ppp_async ip_gre; do - /sbin/insmod $module 2>&- >&- -done - -KEEPALIVE=${ppp_redialperiod:+lcp-echo-interval $ppp_redialperiod lcp-echo-failure 5} -case "$ppp_demand" in - on|1|enabled) - DEMAND=${ppp_idletime:+demand idle $ppp_idletime} - [ -f /etc/ppp/filter ] && DEMAND=${DEMAND:+precompiled-active-filter /etc/ppp/filter $DEMAND} - ;; - *) DEMAND="persist";; -esac -MTU=${ppp_mtu:-1452} - -[ "$pptp_proto" = "static" ] || pptp_proto="dhcp" -do_ifup $pptp_proto $type - -/usr/sbin/pppd \ - pty "/usr/sbin/pptp $pptp_server_ip --loglevel 0 --nolaunchpppd" \ - file /etc/ppp/options.pptp \ - connect /bin/true \ - usepeerdns \ - defaultroute \ - replacedefaultroute \ - linkname "$type" \ - ipparam "$type" \ - user "$ppp_username" \ - password "$ppp_passwd" \ - mtu $MTU mru $MTU \ - $DEMAND \ - $KEEPALIVE - diff --git a/package/pptp/files/pptp.sh b/package/pptp/files/pptp.sh new file mode 100644 index 0000000000..7847802041 --- /dev/null +++ b/package/pptp/files/pptp.sh @@ -0,0 +1,22 @@ +scan_pppoe() { + scan_ppp "$@" +} + +setup_interface_pppoe() { + local iface="$1" + local config="$2" + + config_get device "$config" device + + for module in slhc ppp_generic ppp_async ip_gre; do + /sbin/insmod $module 2>&- >&- + done + setup_interface "$iface" "$config" "dhcp" + + config_get mtu "$cfg" mtu + mtu=${mtu:-1452} + start_pppd "$config" \ + plugin rp-pppoe.so \ + mtu $mtu mru $mtu \ + "nic-$device" +} diff --git a/package/switch/Makefile b/package/switch/Makefile index 5513394fd6..860e530c4c 100644 --- a/package/switch/Makefile +++ b/package/switch/Makefile @@ -42,6 +42,10 @@ define Build/Compile endef define Package/kmod-switch/install + install -m0755 -d $(1)/lib/network/ + install -m0755 ./files/switch.sh $(1)/lib/network/ + install -m0755 -d $(1)/etc/modules.d/ + printf 'switch-core\nswitch-robo\nswitch-adm\n' > $(1)/etc/modules.d/20-switch install -m0755 -d $(1)/lib/modules/$(LINUX_VERSION) $(CP) $(PKG_BUILD_DIR)/*.$(LINUX_KMOD_SUFFIX) \ $(1)/lib/modules/$(LINUX_VERSION) diff --git a/package/switch/files/switch.sh b/package/switch/files/switch.sh new file mode 100644 index 0000000000..a787a8cf38 --- /dev/null +++ b/package/switch/files/switch.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org + +setup_switch_vlan() { + DIR="/proc/switch/$CONFIG_SECTION/vlan/$1" + [ -d "$DIR" ] || return 0 + + config_get ports "$CONFIG_SECTION" "vlan$1" + echo "$ports" > "$DIR/ports" +} + +setup_switch() { + config_cb() { + case "$1" in + switch) + [ -n "$2" -a -d "/proc/switch/$2" ] && { + echo 1 > "/proc/switch/$2/reset" + echo 1 > "/proc/switch/$2/enable" + echo 1 > "/proc/switch/$2/enable_vlan" + option_cb() { + case "$1" in + vlan*) setup_switch_vlan "${1##vlan}";; + esac + } + } + ;; + *) + option_cb() { return 0; } + ;; + esac + } + config_load network +} |