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)"
26 [ -z "$IFPROTO" -o "$IFPROTO" = "none" ] ||
{
27 [ "${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
51 if_proto
="$(nvram get ${2}_proto)"
53 pidfile
=/var
/run
/${if}.pid
54 [ -f $pidfile ] && $DEBUG kill $
(cat $pidfile)
58 ip
=$
(nvram get
${2}_ipaddr
)
59 netmask
=$
(nvram get
${2}_netmask
)
60 gateway
=$
(nvram get
${2}_gateway
)
62 $DEBUG ifconfig
$if $ip ${netmask:+netmask $netmask} broadcast
+ up
63 ${gateway:+$DEBUG route add default gw $gateway}
65 [ -f /etc
/resolv.conf
] ||
{
66 debug
"# --- creating /etc/resolv.conf ---"
67 for dns
in $
(nvram get
${2}_dns
); do
68 echo "nameserver $dns" >> /etc
/resolv.conf
72 env
-i ACTION
="ifup" INTERFACE
="${2}" PROTO
=static
/sbin
/hotplug
"iface" &
75 DHCP_IP
=$
(nvram get
${2}_ipaddr
)
76 DHCP_NETMASK
=$
(nvram get
${2}_netmask
)
77 $DEBUG ifconfig
$if $ip ${netmask:+netmask $netmask} broadcast
+ up
79 DHCP_ARGS
="-i $if ${DHCP_IP:+-r $DHCP_IP} -b -p $pidfile"
80 DHCP_HOSTNAME
=$
(nvram get
${2}_hostname
)
81 DHCP_HOSTNAME
=${DHCP_HOSTNAME%%.*}
82 [ -z $DHCP_HOSTNAME ] || DHCP_ARGS
="$DHCP_ARGS -H $DHCP_HOSTNAME"
83 [ "$if_proto" = "pptp" ] && DHCP_ARGS
="$DHCP_ARGS -n -q" || DHCP_ARGS
="$DHCP_ARGS -R &"
84 oldpid
=$
(cat $pidfile)
85 ${DEBUG:-eval} "udhcpc $DHCP_ARGS"
86 pidof udhcpc |
grep "$oldpid" >&- 2>&- && {
90 # hotplug events are handled by /usr/share/udhcpc/default.script
93 if [ -x "/sbin/ifup.$1" ]; then
94 ( $DEBUG .
/sbin
/ifup.
$1 ${2} $3 )
102 case "${INTERFACE%%[0-9]*}" in
106 [ -z "$IFTYPE" -o -z "$IFPROTO" ] && {
108 case "${INTERFACE%%[0-9]*}" in
110 for tmp
in lan wifi
; do
111 [ -z "$IFPROTO" ] && [ "$(nvram get ${tmp}_ifname)" = "br0" ] && {
112 IFPROTO
="$(nvram get ${tmp}_proto)"
116 [ -z "$IFPROTO" ] && return 0
119 for tmp
in lan wan wifi $
(nvram get ifnames
); do
120 [ "$(nvram get ${tmp}_proto)" = "pppoa" ] && {
121 do_ifup
"pppoa" "$tmp" "$INTERFACE"
133 case "${INTERFACE%%[0-9]*}" in
136 mac
=$
(nvram get
${IFTYPE}_hwaddr
)
137 ${mac:+$DEBUG ifconfig $INTERFACE down hw ether $mac}
141 if="$(nvram get ${IFTYPE}_ifname)"
142 if [ "${if%%[0-9]}" = "br" ]; then
143 if_valid
"$INTERFACE" && {
144 ifconfig
"$if" 2>&- >&- ||
{
145 stp
=$
(nvram get
${IFTYPE}_stp
)
146 $DEBUG brctl addbr
"$if"
147 $DEBUG brctl setfd
"$if" 0
148 $DEBUG brctl stp
"$if" "${stp:-0}"
151 if [ "$INTERFACE" != "$if" ]; then
152 $DEBUG ifconfig
"$INTERFACE" 0.0.0.0 up
153 brctl addif
"$if" "$INTERFACE"
155 do_ifup
"$IFPROTO" "$IFTYPE" "$if"
159 do_ifup
"$IFPROTO" "$IFTYPE" "$if"
164 [ "${INTERFACE%%[0-9]*}" = "atm" ] || ifconfig
"$INTERFACE" 0.0.0.0 down
2>&-
165 [ -z "$IFTYPE" -o -z "$IFPROTO" ] && find_name
166 [ -z "$IFTYPE" -o -z "$IFPROTO" ] && return 0
168 [ "${IFACE%%[0-9]*}" = "br" ] && {
169 if [ "$INTERFACE" != "$IFACE" ]; then
170 brctl delif
"$IFACE" "$INTERFACE" 2>&- >&-
172 brctl delbr
"$IFACE" 2>&- >&-
178 killall ifup.
${IFPROTO}
182 [ -f /var
/run
/${INTERFACE}.pid
] && kill "$(cat /var/run/${INTERFACE}.pid)" 2>&- >&-
188 register
) do_register
;;
189 unregister
) do_unregister
;;
This page took 0.063972 seconds and 5 git commands to generate.