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
] && return
46 debug
"# --- creating /etc/resolv.conf ---"
47 for dns
in $
(nvram get
${2}_dns
); do
48 echo "nameserver $dns" >> /etc
/resolv.conf
52 DHCP_IP
=$
(nvram get
${2}_ipaddr
)
53 DHCP_NETMASK
=$
(nvram get
${2}_netmask
)
54 $DEBUG ifconfig
$if $ip ${netmask:+netmask $netmask} broadcast
+ up
56 DHCP_ARGS
="-i $if ${DHCP_IP:+-r $DHCP_IP} -b -p $pidfile"
57 DHCP_HOSTNAME
=$
(nvram get
${2}_hostname
)
58 DHCP_HOSTNAME
=${DHCP_HOSTNAME%%.*}
59 [ -z $DHCP_HOSTNAME ] || DHCP_ARGS
="$DHCP_ARGS -H $DHCP_HOSTNAME"
60 [ "$if_proto" = "pptp" ] && DHCP_ARGS
="$DHCP_ARGS -n -q" || DHCP_ARGS
="$DHCP_ARGS -R &"
61 oldpid
=$
(cat $pidfile)
62 ${DEBUG:-eval} "udhcpc $DHCP_ARGS"
63 pidof udhcpc |
grep "$oldpid" >&- 2>&- && {
71 [ -x "/sbin/ifup.$1" ] && { $DEBUG /sbin
/ifup.
$1 ${2}; exit; }
72 echo "### ifup ${2}: ignored ${2}_proto=\"$1\" (not supported)"
80 c
=((c
>> 1)&0x55555555)+(c
&0x55555555),
81 c
=((c
>> 2)&0x33333333)+(c
&0x33333333),
82 c
=((c
>> 4)&0x0f0f0f0f)+(c
&0x0f0f0f0f),
83 c
=((c
>> 8)&0x00ff00ff)+(c
&0x00ff00ff),
84 c
=((c
>>16)&0x0000ffff)+(c
&0x0000ffff)
93 set $
(echo $1 |
tr '\.' ' ')
94 echo $
(($1<<24|$2<<16|$3<<8|$4))
98 echo $(($1>>24&255)).$
(($1>>16&255)).$
(($1>>8&255)).$
(($1&255))
This page took 0.04532 seconds and 5 git commands to generate.