enable dhcp option 43 only if dhcp discovery is enabled

This commit is contained in:
Sukru Senli 2016-02-04 15:35:18 +01:00
parent 3c50e58774
commit e2b34c2b6a

View file

@ -53,12 +53,57 @@ check_acs_url() {
fi
}
enable_dhcp_option43() {
local wan=$1
local discovery=0
case $2 in
enable|1) discovery=1 ;;
esac
### Ask for DHCP Option 43 only if CWMP is enabled ###
local enabled
local newreqopts=
local baseopts=
local reqopts="$(uci -q get network.$wan.reqopts)"
local proto="$(uci -q get network.$wan.proto)"
local tropts="43"
local ropt iopt
for ropt in $reqopts; do
case $ropt in
43) ;;
*) baseopts="$baseopts $ropt" ;;
esac
done
ropt=""
reqopts="$baseopts $tropts"
for ropt in $reqopts; do
case $ropt in
43) [ $discovery -eq 1 ] && newreqopts="$newreqopts $ropt" ;;
*) newreqopts="$newreqopts $ropt" ;;
esac
done
if [ $proto == "dhcp" ]; then
newreqopts="$(echo $newreqopts | tr ' ' '\n' | sort -n | tr '\n' ' ' | sed 's/^[ \t]*//;s/[ \t]*$//')"
uci -q set network.$wan.reqopts="$newreqopts"
uci commit network
ubus call network reload
fi
########################################################
}
check_dhcp() {
local default_wan_interface dhcp_discovery url dhcp_url_path
# config_load cwmp is called in set_wan_interface function
config_get default_wan_interface cpe default_wan_interface "wan"
config_get dhcp_discovery acs dhcp_discovery "0"
config_get url acs url
config_get dhcp_url_path acs dhcp_url_path
enable_dhcp_option43 $default_wan_interface $dhcp_discovery
i=0
dhcp_discovery=`uci -q get cwmp.acs.dhcp_discovery`
url=`uci -q get cwmp.acs.url`
dhcp_url_path=`uci -q get cwmp.acs.dhcp_url_path`
if [ \( "_$acs_dhcp_discovery" = "_enable" \) -o \( "_$url" = "_" \) ]
#if [ \( "_$dhcp_discovery" = "_enable" \) -o \( "_$url" = "_" \) ] # this is the old way, below we wait for DHCP discovery only if it is enabled
if [ "$dhcp_discovery" == "enable" -o "$dhcp_discovery" == "1" ]
then
while [ $i -le 10 ]
do
@ -79,7 +124,7 @@ set_wan_interface() {
local l3_device=""
local default_wan_interface=""
config_load cwmp
config_get default_wan_interface cpe default_wan_interface
config_get default_wan_interface cpe default_wan_interface "wan"
json_load "$(ifstatus $default_wan_interface)"
json_get_var l3_device l3_device
if [ "$l3_device" != "" ];then