4 alias debug
=${DEBUG:-:}
8 ifconfig
"$1" >&- 2>&- ||
9 [ "${1%%[0-9]}" = "br" ] ||
11 [ "${1%%[0-9]}" = "vlan" ] && (
13 hwname
=$
(nvram get vlan
${i}hwname
)
14 hwaddr
=$
(nvram get
${hwname}macaddr
)
15 [ -z "$hwaddr" ] && return 1
17 vif
=$
(ifconfig
-a |
awk '/^eth.*'$hwaddr'/ {print $1; exit}' IGNORECASE
=1)
18 debug
"# vlan$i => $vif"
20 $DEBUG ifconfig
$vif up
21 $DEBUG vconfig add
$vif $i 2>&-
24 { debug
"# missing interface '$1' ignored"; false
; }
28 if_proto
=$
(nvram get
${2}_proto
)
29 if=$
(nvram get
${2}_ifname
)
30 [ "${if%%[0-9]}" = "ppp" ] && if=$
(nvram get
${if_proto}_ifname
)
32 pidfile
=/var
/run
/${if}.pid
33 [ -f $pidfile ] && $DEBUG kill $
(cat $pidfile)
37 ip
=$
(nvram get
${2}_ipaddr
)
38 netmask
=$
(nvram get
${2}_netmask
)
39 gateway
=$
(nvram get
${2}_gateway
)
41 $DEBUG ifconfig
$if $ip ${netmask:+netmask $netmask} broadcast
+ up
42 ${gateway:+$DEBUG route add default gw $gateway}
44 [ -f /etc
/resolv.conf
] ||
{
45 debug
"# --- creating /etc/resolv.conf ---"
46 for dns
in $
(nvram get
${2}_dns
); do
47 echo "nameserver $dns" >> /etc
/resolv.conf
51 env
-i ACTION
="ifup" INTERFACE
="${2}" PROTO
=static
/sbin
/hotplug
"iface" &
54 DHCP_IP
=$
(nvram get
${2}_ipaddr
)
55 DHCP_NETMASK
=$
(nvram get
${2}_netmask
)
56 $DEBUG ifconfig
$if $ip ${netmask:+netmask $netmask} broadcast
+ up
58 DHCP_ARGS
="-i $if ${DHCP_IP:+-r $DHCP_IP} -b -p $pidfile"
59 DHCP_HOSTNAME
=$
(nvram get
${2}_hostname
)
60 DHCP_HOSTNAME
=${DHCP_HOSTNAME%%.*}
61 [ -z $DHCP_HOSTNAME ] || DHCP_ARGS
="$DHCP_ARGS -H $DHCP_HOSTNAME"
62 [ "$if_proto" = "pptp" ] && DHCP_ARGS
="$DHCP_ARGS -n -q" || DHCP_ARGS
="$DHCP_ARGS -R &"
63 oldpid
=$
(cat $pidfile)
64 ${DEBUG:-eval} "udhcpc $DHCP_ARGS"
65 pidof udhcpc |
grep "$oldpid" >&- 2>&- && {
69 # hotplug events are handled by /usr/share/udhcpc/default.script
74 [ -x "/sbin/ifup.$1" ] && { $DEBUG /sbin
/ifup.
$1 ${2}; exit; }
75 echo "### ifup ${2}: ignored ${2}_proto=\"$1\" (not supported)"
83 c
=((c
>> 1)&0x55555555)+(c
&0x55555555),
84 c
=((c
>> 2)&0x33333333)+(c
&0x33333333),
85 c
=((c
>> 4)&0x0f0f0f0f)+(c
&0x0f0f0f0f),
86 c
=((c
>> 8)&0x00ff00ff)+(c
&0x00ff00ff),
87 c
=((c
>>16)&0x0000ffff)+(c
&0x0000ffff)
96 set $
(echo $1 |
tr '\.' ' ')
97 echo $
(($1<<24|$2<<16|$3<<8|$4))
101 echo $(($1>>24&255)).$
(($1>>16&255)).$
(($1>>8&255)).$
(($1&255))
This page took 0.055978 seconds and 5 git commands to generate.