summaryrefslogtreecommitdiff
path: root/openwrt/target/default/target_skeleton/etc/functions.sh
diff options
context:
space:
mode:
authormbm <mbm@3c298f89-4303-0410-b956-a3cf2f4a3e73>2005-05-30 09:09:58 +0000
committermbm <mbm@3c298f89-4303-0410-b956-a3cf2f4a3e73>2005-05-30 09:09:58 +0000
commitb544d69e19c1c2f5261aad4c0795dcf297d47e4c (patch)
treea84b0b29ad86ed5bca304a5a794de7090bd702fe /openwrt/target/default/target_skeleton/etc/functions.sh
parentc9c732afbfa99fbc3ef3209e04e9162d0a346098 (diff)
make dnsmasq probe for dhcp servers before starting a dhcp server
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@1110 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'openwrt/target/default/target_skeleton/etc/functions.sh')
-rwxr-xr-xopenwrt/target/default/target_skeleton/etc/functions.sh28
1 files changed, 26 insertions, 2 deletions
diff --git a/openwrt/target/default/target_skeleton/etc/functions.sh b/openwrt/target/default/target_skeleton/etc/functions.sh
index 48f1191cc4..60d6231f8a 100755
--- a/openwrt/target/default/target_skeleton/etc/functions.sh
+++ b/openwrt/target/default/target_skeleton/etc/functions.sh
@@ -12,7 +12,7 @@ nvram () {
. /etc/nvram.overrides
# valid interface?
-if_valid () {
+if_valid () (
ifconfig "$1" >&- 2>&- ||
[ "${1%%[0-9]}" = "br" ] ||
{
@@ -29,5 +29,29 @@ if_valid () {
$DEBUG vconfig add $vif $i 2>&-
)
} ||
- { debug "# missing interface '$if' ignored"; false; }
+ { debug "# missing interface '$1' ignored"; false; }
+)
+
+bitcount () {
+ local c=$1
+ echo $((
+ c=((c>> 1)&0x55555555)+(c&0x55555555),
+ c=((c>> 2)&0x33333333)+(c&0x33333333),
+ c=((c>> 4)&0x0f0f0f0f)+(c&0x0f0f0f0f),
+ c=((c>> 8)&0x00ff00ff)+(c&0x00ff00ff),
+ c=((c>>16)&0x0000ffff)+(c&0x0000ffff)
+ ))
+}
+
+valid_netmask () {
+ return $((-($1)&~$1))
+}
+
+ip2int () (
+ set $(echo $1 | tr '\.' ' ')
+ echo $(($1<<24|$2<<16|$3<<8|$4))
+)
+
+int2ip () {
+ echo $(($1>>24&255)).$(($1>>16&255)).$(($1>>8&255)).$(($1&255))
}