OpenWrt Kamikaze uses a seperate ipcalc shell script (/bin/ipcalc.sh). Here is a example with UCI. The shell script below reads the LAN IP address and the netmask from /etc/config/network, calculates and finally prints the network number.
/ipcalc-test.sh
#!/bin/sh
. /etc/functions.sh
config_load "network"
local section="lan"
config_get "ipaddr" "$section" "ipaddr"
config_get "netmask" "$section" "netmask"
eval "$(/bin/ipcalc.sh $ipaddr $netmask)"
echo "Network: $NETWORK"
Test it
root@OpenWrt:/# ./ipcalc-test.sh
Network: 192.168.178.0
root@OpenWrt:/#
My configuration (uci show network.lan):
network.lan=interface
network.lan.type=bridge
network.lan.ifname=eth0.0
network.lan.proto=static
network.lan.ipaddr=192.168.178.3
network.lan.netmask=255.255.255.0
network.lan.dns=192.168.178.1
network.lan.gateway=192.168.178.1
Have fun
(Last edited by forum2006 on 25 Sep 2007, 17:03)