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 ${DEBUG:-eval} "udhcpc $DHCP_ARGS"
79 # hotplug events are handled by /usr/share/udhcpc/default.script
82 if [ -x "/sbin/ifup.$1" ]; then
83 ( $DEBUG .
/sbin
/ifup.
$1 ${2} $3 )
91 case "${INTERFACE%%[0-9]*}" in
95 [ -z "$IFTYPE" -o -z "$IFPROTO" ] && {
97 case "${INTERFACE%%[0-9]*}" in
99 for tmp
in lan wifi
; do
100 [ -z "$IFPROTO" ] && [ "$(nvram get ${tmp}_ifname)" = "br0" ] && {
101 IFPROTO
="$(nvram get ${tmp}_proto)"
105 [ -z "$IFPROTO" ] && return 0
108 for tmp
in lan wan wifi $
(nvram get ifnames
); do
109 [ "$(nvram get ${tmp}_proto)" = "pppoa" ] && {
110 do_ifup
"pppoa" "$tmp" "$INTERFACE"
122 case "${INTERFACE%%[0-9]*}" in
125 mac
=$
(nvram get
${IFTYPE}_hwaddr
)
126 ${mac:+$DEBUG ifconfig $INTERFACE down hw ether $mac}
130 if="$(nvram get ${IFTYPE}_ifname)"
131 if [ "${if%%[0-9]}" = "br" ]; then
132 if_valid
"$INTERFACE" && {
133 ifconfig
"$if" 2>&- >&- ||
{
134 stp
=$
(nvram get
${IFTYPE}_stp
)
135 $DEBUG brctl addbr
"$if"
136 $DEBUG brctl setfd
"$if" 0
137 $DEBUG brctl stp
"$if" "${stp:-0}"
140 if [ "$INTERFACE" != "$if" ]; then
141 $DEBUG ifconfig
"$INTERFACE" 0.0.0.0 up
142 $DEBUG brctl addif
"$if" "$INTERFACE"
143 $DEBUG ifconfig
"$INTERFACE" allmulti
145 do_ifup
"$IFPROTO" "$IFTYPE" "$if"
149 [ "${INTERFACE%%[0-9]*}" = "ppp" ] || do_ifup
"$IFPROTO" "$IFTYPE" "$if"
154 [ -z "$IFTYPE" -o -z "$IFPROTO" ] && find_name
155 [ -z "$IFTYPE" -o -z "$IFPROTO" ] && return 0
157 [ "${IFACE%%[0-9]*}" = "br" ] && {
158 if [ "$INTERFACE" != "$IFACE" ]; then
159 brctl delif
"$IFACE" "$INTERFACE" 2>&- >&-
161 brctl delbr
"$IFACE" 2>&- >&-
167 killall pppd
2>&- >&-
170 [ -f /var
/run
/${INTERFACE}.pid
] && kill "$(cat /var/run/${INTERFACE}.pid)" 2>&- >&-
174 [ "${INTERFACE%%[0-9]*}" = "atm" ] || ifconfig
"$INTERFACE" 0.0.0.0 down
2>&-
178 add|register
) do_register
;;
179 remove|unregister
) do_unregister
;;
This page took 0.06262 seconds and 5 git commands to generate.