4 [ -f /proc
/net
/wl0
] && {
5 lsmod |
grep wlcompat
>&- || insmod wlcompat
7 iwconfig
"$INTERFACE" 2>&- |
grep -v 'no wireless' >&- && {
10 [ -d /proc
/switch
] ||
{
12 insmod switch-robo || insmod switch-adm
14 if="$(echo "$INTERFACE" | sed s,eth,et,)"
15 ifconfig
"$INTERFACE" up
2>&- >&-
16 for vlan
in $
(seq 0 15); do
17 [ "$(nvram get vlan${vlan}hwname)" = "$if" ] && {
18 $DEBUG vconfig add
"$INTERFACE" "$vlan"
19 vports
="$(nvram get vlan${vlan}ports)"
20 [ \
! -z "$vports" -a -d "/proc/switch/$INTERFACE" ] && \
21 echo "$vports" > "/proc/switch/$INTERFACE/vlan/$vlan/ports"
28 pppoa_ifname
="atm0" # hack for ppp over atm, which has no ${proto}_ifname
29 interfaces
="lan wan wifi $(nvram get ifnames)"
30 for ifname
in $interfaces; do
32 IFPROTO
="$(nvram get ${IFTYPE}_proto)"
33 IFACE
="$(nvram get ${IFTYPE}_ifname)"
37 [ "${IFACE}" = "$INTERFACE" ] && return 0
38 [ "${IFACE%%[0-9]*}" = "br" ] && {
39 for part
in $
(nvram get
${IFTYPE}_ifnames
); do
40 [ "$part" = "$INTERFACE" ] && return 0
45 [ "$(nvram get ${IFPROTO}_ifname)" = "$INTERFACE" \
46 -a -x /sbin
/ifup.
${IFPROTO} ] && return 0
58 if_proto
="$(nvram get ${2}_proto)"
60 pidfile
=/var
/run
/${if}.pid
61 [ -f $pidfile ] && $DEBUG kill $
(cat $pidfile)
65 ip
=$
(nvram get
${2}_ipaddr
)
66 netmask
=$
(nvram get
${2}_netmask
)
67 gateway
=$
(nvram get
${2}_gateway
)
69 $DEBUG ifconfig
$if $ip ${netmask:+netmask $netmask} broadcast
+ up
70 ${gateway:+$DEBUG route add default gw $gateway}
72 [ -f /tmp
/resolv.conf
] ||
{
73 debug
"# --- creating /tmp/resolv.conf ---"
74 for dns
in $
(nvram get
${2}_dns
); do
75 echo "nameserver $dns" >> /tmp
/resolv.conf
79 env
-i ACTION
="ifup" INTERFACE
="${2}" PROTO
=static
/sbin
/hotplug
"iface" &
82 DHCP_IP
=$
(nvram get
${2}_ipaddr
)
83 DHCP_NETMASK
=$
(nvram get
${2}_netmask
)
84 $DEBUG ifconfig
$if $ip ${netmask:+netmask $netmask} broadcast
+ up
86 DHCP_ARGS
="-i $if ${DHCP_IP:+-r $DHCP_IP} -b -p $pidfile"
87 DHCP_HOSTNAME
=$
(nvram get
${2}_hostname
)
88 DHCP_HOSTNAME
=${DHCP_HOSTNAME%%.*}
89 [ -z $DHCP_HOSTNAME ] || DHCP_ARGS
="$DHCP_ARGS -H $DHCP_HOSTNAME"
90 [ "$if_proto" = "pptp" ] && DHCP_ARGS
="$DHCP_ARGS -n -q" || DHCP_ARGS
="$DHCP_ARGS -R &"
91 oldpid
=$
(cat $pidfile)
92 ${DEBUG:-eval} "udhcpc $DHCP_ARGS"
93 pidof udhcpc |
grep "$oldpid" >&- 2>&- && {
97 # hotplug events are handled by /usr/share/udhcpc/default.script
100 if [ -x "/sbin/ifup.$1" ]; then
101 ( $DEBUG .
/sbin
/ifup.
$1 ${2} $3 )
109 case "${INTERFACE%%[0-9]*}" in
113 [ -z "$IFTYPE" -o -z "$IFPROTO" ] && {
115 case "${INTERFACE%%[0-9]*}" in
117 for tmp
in lan wifi
; do
118 [ -z "$IFPROTO" ] && [ "$(nvram get ${tmp}_ifname)" = "br0" ] && {
119 IFPROTO
="$(nvram get ${tmp}_proto)"
123 [ -z "$IFPROTO" ] && return 0
126 for tmp
in lan wan wifi $
(nvram get ifnames
); do
127 [ "$(nvram get ${tmp}_proto)" = "pppoa" ] && {
128 do_ifup
"pppoa" "$tmp" "$INTERFACE"
140 case "${INTERFACE%%[0-9]*}" in
143 mac
=$
(nvram get
${IFTYPE}_hwaddr
)
144 ${mac:+$DEBUG ifconfig $INTERFACE down hw ether $mac}
148 if="$(nvram get ${IFTYPE}_ifname)"
149 if [ "${if%%[0-9]}" = "br" ]; then
150 if_valid
"$INTERFACE" && {
151 ifconfig
"$if" 2>&- >&- ||
{
152 stp
=$
(nvram get
${IFTYPE}_stp
)
153 $DEBUG brctl addbr
"$if"
154 $DEBUG brctl setfd
"$if" 0
155 $DEBUG brctl stp
"$if" "${stp:-0}"
158 if [ "$INTERFACE" != "$if" ]; then
159 $DEBUG ifconfig
"$INTERFACE" 0.0.0.0 up
160 brctl addif
"$if" "$INTERFACE"
162 do_ifup
"$IFPROTO" "$IFTYPE" "$if"
166 [ "${INTERFACE%%[0-9]*}" = "ppp" ] || do_ifup
"$IFPROTO" "$IFTYPE" "$if"
171 [ -z "$IFTYPE" -o -z "$IFPROTO" ] && find_name
172 [ -z "$IFTYPE" -o -z "$IFPROTO" ] && return 0
174 [ "${IFACE%%[0-9]*}" = "br" ] && {
175 if [ "$INTERFACE" != "$IFACE" ]; then
176 brctl delif
"$IFACE" "$INTERFACE" 2>&- >&-
178 brctl delbr
"$IFACE" 2>&- >&-
184 killall pppd
2>&- >&-
187 [ -f /var
/run
/${INTERFACE}.pid
] && kill "$(cat /var/run/${INTERFACE}.pid)" 2>&- >&-
191 [ "${INTERFACE%%[0-9]*}" = "atm" ] || ifconfig
"$INTERFACE" 0.0.0.0 down
2>&-
195 add|register
) do_register
;;
196 remove|unregister
) do_unregister
;;