- # 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()
-{
- case "${INTERFACE%%[0-9]*}" in
- eth) setup_eth;;
- esac
-
- [ -z "$IFTYPE" -o -z "$IFPROTO" ] && {
- find_name || {
- case "${INTERFACE%%[0-9]*}" in
- wds)
- for tmp in lan wifi; do
- [ -z "$IFPROTO" ] && [ "$(nvram get ${tmp}_ifname)" = "br0" ] && {
- IFPROTO="$(nvram get ${tmp}_proto)"
- IFTYPE="${tmp}"
- }
- done
- [ -z "$IFPROTO" ] && return 0
- ;;
- atm)
- for tmp in lan wan wifi $(nvram get ifnames); do
- [ "$(nvram get ${tmp}_proto)" = "pppoa" ] && {
- do_ifup "pppoa" "$tmp" "$INTERFACE"
- return 0
- }
- done
- ;;
- *)
- return 0
- ;;
- esac
- }
- }
-
- case "${INTERFACE%%[0-9]*}" in
- ppp|atm);;
- *)
- mac=$(nvram get ${IFTYPE}_hwaddr)
- ${mac:+$DEBUG ifconfig $INTERFACE down hw ether $mac}
- ;;
- esac
-
- if="$(nvram get ${IFTYPE}_ifname)"
- if [ "${if%%[0-9]}" = "br" ]; then
- if_valid "$INTERFACE" && {
- ifconfig "$if" 2>&- >&- || {
- stp=$(nvram get ${IFTYPE}_stp)
- $DEBUG brctl addbr "$if"
- $DEBUG brctl setfd "$if" 0
- $DEBUG brctl stp "$if" "${stp:-0}"
- }
-
- if [ "$INTERFACE" != "$if" ]; then
- $DEBUG ifconfig "$INTERFACE" 0.0.0.0 up
- brctl addif "$if" "$INTERFACE"
- else
- do_ifup "$IFPROTO" "$IFTYPE" "$if"
- fi
- }
- else
- do_ifup "$IFPROTO" "$IFTYPE" "$if"
- fi
-}
-
-do_unregister() {
- [ "${INTERFACE%%[0-9]*}" = "atm" ] || ifconfig "$INTERFACE" 0.0.0.0 down 2>&-
- [ -z "$IFTYPE" -o -z "$IFPROTO" ] && find_name
- [ -z "$IFTYPE" -o -z "$IFPROTO" ] && 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 ifup.${IFPROTO} 2>&- >&-
- killall pppd 2>&- >&-
- ;;
- dhcp)
- [ -f /var/run/${INTERFACE}.pid ] && kill "$(cat /var/run/${INTERFACE}.pid)" 2>&- >&-
- ;;
- esac