4 [ -f /proc
/net
/wl0
] && {
5 lsmod |
grep wlcompat
>&- || insmod wlcompat
7 iwconfig
"$INTERFACE" 2>&- |
grep -v 'no wireless' >&- && {
10 if="$(echo "$INTERFACE" | sed s,eth,et,)"
11 ifconfig
"$INTERFACE" up
2>&- >&-
12 for vlan
in $
(seq 0 15); do
13 [ "$(nvram get vlan${vlan}hwname)" = "$if" ] && \
14 $DEBUG vconfig add
"$INTERFACE" "$vlan"
20 pppoa_ifname
="atm0" # hack for ppp over atm, which has no ${proto}_ifname
21 interfaces
="lan wan wifi $(nvram get ifnames)"
22 for ifname
in $interfaces; do
24 IFPROTO
="$(nvram get ${IFTYPE}_proto)"
25 IFACE
="$(nvram get ${IFTYPE}_ifname)"
29 [ "${IFACE}" = "$INTERFACE" ] && return 0
30 [ "${IFACE%%[0-9]*}" = "br" ] && {
31 for part
in $
(nvram get
${IFTYPE}_ifnames
); do
32 [ "$part" = "$INTERFACE" ] && return 0
37 [ "$(nvram get ${IFPROTO}_ifname)" = "$INTERFACE" \
38 -a -x /sbin
/ifup.
${IFPROTO} ] && return 0
50 if_proto
="$(nvram get ${2}_proto)"
52 pidfile
=/var
/run
/${if}.pid
53 [ -f $pidfile ] && $DEBUG kill $
(cat $pidfile)
57 ip
=$
(nvram get
${2}_ipaddr
)
58 netmask
=$
(nvram get
${2}_netmask
)
59 gateway
=$
(nvram get
${2}_gateway
)
61 $DEBUG ifconfig
$if $ip ${netmask:+netmask $netmask} broadcast
+ up
62 ${gateway:+$DEBUG route add default gw $gateway}
64 [ -f /etc
/resolv.conf
] ||
{
65 debug
"# --- creating /etc/resolv.conf ---"
66 for dns
in $
(nvram get
${2}_dns
); do
67 echo "nameserver $dns" >> /etc
/resolv.conf
71 env
-i ACTION
="ifup" INTERFACE
="${2}" PROTO
=static
/sbin
/hotplug
"iface" &
74 DHCP_IP
=$
(nvram get
${2}_ipaddr
)
75 DHCP_NETMASK
=$
(nvram get
${2}_netmask
)
76 $DEBUG ifconfig
$if $ip ${netmask:+netmask $netmask} broadcast
+ up
78 DHCP_ARGS
="-i $if ${DHCP_IP:+-r $DHCP_IP} -b -p $pidfile"
79 DHCP_HOSTNAME
=$
(nvram get
${2}_hostname
)
80 DHCP_HOSTNAME
=${DHCP_HOSTNAME%%.*}
81 [ -z $DHCP_HOSTNAME ] || DHCP_ARGS
="$DHCP_ARGS -H $DHCP_HOSTNAME"
82 [ "$if_proto" = "pptp" ] && DHCP_ARGS
="$DHCP_ARGS -n -q" || DHCP_ARGS
="$DHCP_ARGS -R &"
83 oldpid
=$
(cat $pidfile)
84 ${DEBUG:-eval} "udhcpc $DHCP_ARGS"
85 pidof udhcpc |
grep "$oldpid" >&- 2>&- && {
89 # hotplug events are handled by /usr/share/udhcpc/default.script
92 if [ -x "/sbin/ifup.$1" ]; then
93 ( $DEBUG .
/sbin
/ifup.
$1 ${2} $3 )
101 case "${INTERFACE%%[0-9]*}" in
105 [ -z "$IFTYPE" -o -z "$IFPROTO" ] && {
107 case "${INTERFACE%%[0-9]*}" in
109 for tmp
in lan wifi
; do
110 [ -z "$IFPROTO" ] && [ "$(nvram get ${tmp}_ifname)" = "br0" ] && {
111 IFPROTO
="$(nvram get ${tmp}_proto)"
115 [ -z "$IFPROTO" ] && return 0
118 for tmp
in lan wan wifi $
(nvram get ifnames
); do
119 [ "$(nvram get ${tmp}_proto)" = "pppoa" ] && {
120 do_ifup
"pppoa" "$tmp" "$INTERFACE"
132 case "${INTERFACE%%[0-9]*}" in
135 mac
=$
(nvram get
${IFTYPE}_hwaddr
)
136 ${mac:+$DEBUG ifconfig $INTERFACE down hw ether $mac}
140 if="$(nvram get ${IFTYPE}_ifname)"
141 if [ "${if%%[0-9]}" = "br" ]; then
142 if_valid
"$INTERFACE" && {
143 ifconfig
"$if" 2>&- >&- ||
{
144 stp
=$
(nvram get
${IFTYPE}_stp
)
145 $DEBUG brctl addbr
"$if"
146 $DEBUG brctl setfd
"$if" 0
147 $DEBUG brctl stp
"$if" "${stp:-0}"
150 if [ "$INTERFACE" != "$if" ]; then
151 $DEBUG ifconfig
"$INTERFACE" 0.0.0.0 up
152 brctl addif
"$if" "$INTERFACE"
154 do_ifup
"$IFPROTO" "$IFTYPE" "$if"
158 [ "${INTERFACE%%[0-9]*}" = "ppp" ] || do_ifup
"$IFPROTO" "$IFTYPE" "$if"
163 [ -z "$IFTYPE" -o -z "$IFPROTO" ] && find_name
164 [ -z "$IFTYPE" -o -z "$IFPROTO" ] && return 0
166 [ "${IFACE%%[0-9]*}" = "br" ] && {
167 if [ "$INTERFACE" != "$IFACE" ]; then
168 brctl delif
"$IFACE" "$INTERFACE" 2>&- >&-
170 brctl delbr
"$IFACE" 2>&- >&-
176 killall pppd
2>&- >&-
179 [ -f /var
/run
/${INTERFACE}.pid
] && kill "$(cat /var/run/${INTERFACE}.pid)" 2>&- >&-
183 [ "${INTERFACE%%[0-9]*}" = "atm" ] || ifconfig
"$INTERFACE" 0.0.0.0 down
2>&-
187 add|register
) do_register
;;
188 remove|unregister
) do_unregister
;;
This page took 0.074404 seconds and 5 git commands to generate.