2006-06-27 03:36:13 +03:00
|
|
|
# Copyright (C) 2006 OpenWrt.org
|
|
|
|
|
2006-09-24 16:32:18 +03:00
|
|
|
include /lib/network
|
2006-04-13 14:39:20 +03:00
|
|
|
|
2006-07-30 06:09:09 +03:00
|
|
|
addif() {
|
2009-08-11 02:48:10 +03:00
|
|
|
# Ensure that ipv6 is loaded, autoloading happens later but ipv6 might be
|
|
|
|
# required now for interface setup.
|
|
|
|
[ -d /proc/sys/net/ipv6 ] || {
|
|
|
|
grep -q '^ipv6' /etc/modules.d/* && insmod ipv6
|
|
|
|
}
|
|
|
|
|
2007-02-25 15:45:45 +02:00
|
|
|
# PPP devices are configured by pppd, no need to run setup_interface here
|
|
|
|
case "$INTERFACE" in
|
2010-05-28 03:35:54 +03:00
|
|
|
ppp*|3g-*) return 0;;
|
2010-05-05 18:56:58 +03:00
|
|
|
ath*) return 0;;
|
|
|
|
wlan*) return 0;;
|
2007-02-25 15:45:45 +02:00
|
|
|
esac
|
|
|
|
|
2006-07-30 06:09:09 +03:00
|
|
|
scan_interfaces
|
2006-11-03 23:57:35 +02:00
|
|
|
local cfg="$(find_config "$INTERFACE")"
|
|
|
|
|
|
|
|
# check the autoload setting
|
|
|
|
config_get auto "$cfg" auto
|
|
|
|
case "$auto" in
|
|
|
|
1|on|enabled) setup_interface "$INTERFACE";;
|
|
|
|
esac
|
|
|
|
|
2006-08-24 15:20:02 +03:00
|
|
|
|
2006-07-30 06:09:09 +03:00
|
|
|
# find all vlan configurations for this interface and set them up as well
|
|
|
|
for ifc in $interfaces; do
|
2006-07-30 16:21:18 +03:00
|
|
|
config_get iftype "$ifc" type
|
2006-10-09 15:35:31 +03:00
|
|
|
config_get ifs "$ifc" device
|
2006-07-30 06:09:09 +03:00
|
|
|
for dev in $ifs; do
|
|
|
|
[ "${dev%%\.*}" = "$INTERFACE" -a "$dev" != "$INTERFACE" ] && {
|
|
|
|
add_vlan "$dev"
|
2005-11-19 05:17:20 +02:00
|
|
|
}
|
2006-07-30 06:09:09 +03:00
|
|
|
done
|
|
|
|
done
|
2005-11-19 05:17:20 +02:00
|
|
|
}
|
|
|
|
|
2008-07-31 01:39:56 +03:00
|
|
|
|
|
|
|
delif() {
|
|
|
|
scan_interfaces
|
|
|
|
|
|
|
|
# find all vlan configurations for this interface and nuke 'em
|
|
|
|
for ifc in $interfaces; do
|
|
|
|
config_get iftype "$ifc" type
|
|
|
|
config_get ifs "$ifc" device
|
2010-05-17 22:34:08 +03:00
|
|
|
confdevs="$(uci_get network.$ifc.ifname)"
|
2008-07-31 01:39:56 +03:00
|
|
|
for dev in $ifs; do
|
|
|
|
[ "${dev%%\.*}" = "$INTERFACE" ] && {
|
|
|
|
list_contains confdevs "$dev" || list_remove ifs "$dev"
|
|
|
|
}
|
|
|
|
done
|
|
|
|
uci_set_state "network" "$ifc" device "$ifs"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2005-11-19 05:17:20 +02:00
|
|
|
case "$ACTION" in
|
2006-07-30 06:09:09 +03:00
|
|
|
add|register)
|
2006-10-09 07:01:36 +03:00
|
|
|
case "$PHYSDEVDRIVER" in
|
|
|
|
natsemi) sleep 1;;
|
|
|
|
esac
|
2006-07-30 06:09:09 +03:00
|
|
|
addif
|
|
|
|
;;
|
2008-07-31 01:39:56 +03:00
|
|
|
remove|unregister)
|
|
|
|
delif
|
|
|
|
;;
|
2005-11-19 05:17:20 +02:00
|
|
|
esac
|