4 for part
in $
(nvram get unused_ifnames
); do
5 [ "$part" = "$INTERFACE" ] && exit 0
7 ifconfig
"$INTERFACE" up
2>&- >&-
12 pppoa_ifname
="atm0" # hack for ppp over atm, which has no ${proto}_ifname
13 interfaces
="lan wan wifi $(nvram get ifnames)"
14 for ifname
in $interfaces; do
16 IFPROTO
="$(nvram get ${IFTYPE}_proto)"
17 IFACE
="$(nvram get ${IFTYPE}_ifname)"
21 [ "${IFACE}" = "$INTERFACE" ] && return 0
22 [ "${IFACE%%[0-9]*}" = "br" ] && {
23 for part
in $
(nvram get
${IFTYPE}_ifnames
); do
24 [ "$part" = "$INTERFACE" ] && return 0
29 [ "$(nvram get ${IFTYPE}_device)" = "$INTERFACE" \
30 -a -x /sbin
/ifup.
${IFPROTO} ] && return 0
42 if_proto
="$(nvram get ${2}_proto)"
44 pidfile
=/var
/run
/${if}.pid
45 [ -f $pidfile ] && $DEBUG kill $
(cat $pidfile)
49 ip
=$
(nvram get
${2}_ipaddr
)
50 ip6
=$
(nvram get
${2}_ip6addr
)
51 netmask
=$
(nvram get
${2}_netmask
)
52 gateway
=$
(nvram get
${2}_gateway
)
54 $DEBUG ifconfig
$if $ip ${netmask:+netmask $netmask} broadcast
+ up
55 [ -n "$ip6" ] && $DEBUG ifconfig
$if add
$ip6
57 ${gateway:+$DEBUG route add default gw $gateway}
59 [ -f /tmp
/resolv.conf
] ||
{
60 debug
"# --- creating /tmp/resolv.conf ---"
61 for dns
in $
(nvram get
${2}_dns
); do
62 echo "nameserver $dns" >> /tmp
/resolv.conf
66 env
-i ACTION
="ifup" INTERFACE
="${2}" PROTO
=static
/sbin
/hotplug
"iface" &
69 DHCP_IP
=$
(nvram get
${2}_ipaddr
)
70 DHCP_NETMASK
=$
(nvram get
${2}_netmask
)
71 $DEBUG ifconfig
$if $ip ${netmask:+netmask $netmask} broadcast
+ up
73 DHCP_ARGS
="-i $if ${DHCP_IP:+-r $DHCP_IP} -b -p $pidfile"
74 DHCP_HOSTNAME
=$
(nvram get
${2}_hostname
)
75 DHCP_HOSTNAME
=${DHCP_HOSTNAME%%.*}
76 [ -z $DHCP_HOSTNAME ] || DHCP_ARGS
="$DHCP_ARGS -H $DHCP_HOSTNAME"
77 [ "$if_proto" = "pptp" ] && DHCP_ARGS
="$DHCP_ARGS -n -q" || DHCP_ARGS
="$DHCP_ARGS -R &"
78 oldpid
=$
(cat $pidfile)
79 ${DEBUG:-eval} "udhcpc $DHCP_ARGS"
80 pidof udhcpc |
grep "$oldpid" >&- 2>&- && {
84 # hotplug events are handled by /usr/share/udhcpc/default.script
87 if [ -x "/sbin/ifup.$1" ]; then
88 ( $DEBUG .
/sbin
/ifup.
$1 ${2} $3 )
96 case "${INTERFACE%%[0-9]*}" in
100 [ -z "$IFTYPE" -o -z "$IFPROTO" ] && {
102 case "${INTERFACE%%[0-9]*}" in
104 for tmp
in lan wifi
; do
105 [ -z "$IFPROTO" ] && [ "$(nvram get ${tmp}_ifname)" = "br0" ] && {
106 IFPROTO
="$(nvram get ${tmp}_proto)"
110 [ -z "$IFPROTO" ] && return 0
113 for tmp
in lan wan wifi $
(nvram get ifnames
); do
114 [ "$(nvram get ${tmp}_proto)" = "pppoa" ] && {
115 do_ifup
"pppoa" "$tmp" "$INTERFACE"
127 case "${INTERFACE%%[0-9]*}" in
130 mac
=$
(nvram get
${IFTYPE}_hwaddr
)
131 ${mac:+$DEBUG ifconfig $INTERFACE down hw ether $mac}
135 if="$(nvram get ${IFTYPE}_ifname)"
136 if [ "${if%%[0-9]}" = "br" ]; then
137 if_valid
"$INTERFACE" && {
138 ifconfig
"$if" 2>&- >&- ||
{
139 stp
=$
(nvram get
${IFTYPE}_stp
)
140 $DEBUG brctl addbr
"$if"
141 $DEBUG brctl setfd
"$if" 0
142 $DEBUG brctl stp
"$if" "${stp:-0}"
145 if [ "$INTERFACE" != "$if" ]; then
146 $DEBUG ifconfig
"$INTERFACE" 0.0.0.0 up
147 brctl addif
"$if" "$INTERFACE"
149 do_ifup
"$IFPROTO" "$IFTYPE" "$if"
153 [ "${INTERFACE%%[0-9]*}" = "ppp" ] || do_ifup
"$IFPROTO" "$IFTYPE" "$if"
158 [ -z "$IFTYPE" -o -z "$IFPROTO" ] && find_name
159 [ -z "$IFTYPE" -o -z "$IFPROTO" ] && return 0
161 [ "${IFACE%%[0-9]*}" = "br" ] && {
162 if [ "$INTERFACE" != "$IFACE" ]; then
163 brctl delif
"$IFACE" "$INTERFACE" 2>&- >&-
165 brctl delbr
"$IFACE" 2>&- >&-
171 killall pppd
2>&- >&-
174 [ -f /var
/run
/${INTERFACE}.pid
] && kill "$(cat /var/run/${INTERFACE}.pid)" 2>&- >&-
178 [ "${INTERFACE%%[0-9]*}" = "atm" ] || ifconfig
"$INTERFACE" 0.0.0.0 down
2>&-
182 add|register
) do_register
;;
183 remove|unregister
) do_unregister
;;
This page took 0.050902 seconds and 5 git commands to generate.