icwmp/scripts/functions/management_server
Anis Ellouze 6e26929e87 #6030: fix the connection request error when binding an used port
Signed-off-by: Anis Ellouze <anis.ellouze@pivasoftware.com>
2015-01-23 17:32:06 +01:00

96 lines
No EOL
4.1 KiB
Bash

#!/bin/sh
# Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
# Copyright (C) 2013 Inteno Broadband Technology AB
# Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
# Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
prefix_list="$prefix_list InternetGatewayDevice.ManagementServer."
get_management_server_connection_request_url() {
local val
if [ -z "$default_management_server_connection_request_url" ]; then
local tmp_value=${FLAGS_value}
FLAGS_value=${FLAGS_TRUE}
local tmp_json=${FLAGS_json}
FLAGS_json=${FLAGS_FALSE}
local ip=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q -P /var/state get cwmp.cpe.ip`
local port=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q -P /var/state get cwmp.cpe.port`
FLAGS_value=$tmp_value
FLAGS_json=$tmp_json
if [ -n "$ip" -a -n "$port" ]; then
val="http://$ip:$port/"
fi
else
val=$default_management_server_connection_request_url
fi
echo $val
}
get_management_server_periodic_inform_time() {
local val=""
val=`$UCI_GET cwmp.acs.periodic_inform_time`
if [ "$val" != "0" -a "$val" != "" ];then
val=`date -d @$val +"%Y-%m-%dT%H:%M:%S.000Z"`
else
val="0001-01-01T00:00:00Z"
fi
echo "$val"
}
set_management_server_periodic_inform_time() {
local val="$1"
if [ "$val" != "0001-01-01T00:00:00Z" ];then
val=`echo $val|sed 's/Z//g'`
val=`echo $val|sed 's/T/ /g'`
val=${val%%.*}
val=`date -d "$val" "+%s"`
else
val=0
fi
$UCI_SET cwmp.acs.periodic_inform_time="$val"
ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 command '{ "command": "reload_end_session" }' &> /dev/null &
}
set_management_server_url() {
local val=$1
$UCI_SET cwmp.acs.dhcp_discovery="disable"
set_management_server "cwmp.acs.url" "$val"
}
set_management_server() {
local uci_name=$1
local val=$2
$UCI_SET $uci_name="$val"
ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 command '{ "command": "reload_end_session" }' &> /dev/null &
}
get_cache_InternetGatewayDevice_ManagementServer() {
get_object_cache_generic "InternetGatewayDevice.ManagementServer." "0" "0"
get_param_cache_generic "InternetGatewayDevice.ManagementServer.URL" "1" "$UCI_GET cwmp.acs.url" "set_management_server_url \$val"
get_param_cache_generic "InternetGatewayDevice.ManagementServer.Username" "1" "$UCI_GET cwmp.acs.userid" "set_management_server cwmp.acs.userid \$val"
get_param_cache_generic "InternetGatewayDevice.ManagementServer.Password" "1" "" "set_management_server cwmp.acs.passwd \$val" "" "" "" "" "" "1"
get_param_cache_generic "InternetGatewayDevice.ManagementServer.ParameterKey" "1" "$UCI_GET cwmp.acs.ParameterKey" "set_management_server cwmp.acs.ParameterKey \$val" "" "" "0" "1"
get_param_cache_generic "InternetGatewayDevice.ManagementServer.PeriodicInformEnable" "1" "$UCI_GET cwmp.acs.periodic_inform_enable" "set_management_server cwmp.acs.periodic_inform_enable \$val" "" "xsd:boolean"
get_param_cache_generic "InternetGatewayDevice.ManagementServer.PeriodicInformInterval" "1" "$UCI_GET cwmp.acs.periodic_inform_interval" "set_management_server cwmp.acs.periodic_inform_interval \$val" "" "xsd:unsignedInt"
get_param_cache_generic "InternetGatewayDevice.ManagementServer.PeriodicInformTime" "1" "get_management_server_periodic_inform_time" "set_management_server_periodic_inform_time \$val" "" "xsd:dateTime"
get_param_cache_generic "InternetGatewayDevice.ManagementServer.ConnectionRequestURL" "0" "" "" "get_management_server_connection_request_url" "" "0" "1" "2"
get_param_cache_generic "InternetGatewayDevice.ManagementServer.ConnectionRequestUsername" "1" "$UCI_GET cwmp.cpe.userid" "set_management_server cwmp.cpe.userid \$val"
get_param_cache_generic "InternetGatewayDevice.ManagementServer.ConnectionRequestPassword" "1" "" "set_management_server cwmp.cpe.passwd \$val" "" "" "" "" "" "1"
}
get_dynamic_InternetGatewayDevice_ManagementServer() {
return $FAULT_CPE_NO_FAULT
}
get_dynamic_linker_InternetGatewayDevice_ManagementServer() {
return $FAULT_CPE_NO_FAULT
}
add_object_InternetGatewayDevice_ManagementServer() {
return $FAULT_CPE_INVALID_PARAMETER_NAME
}
delete_object_InternetGatewayDevice_ManagementServer() {
return $FAULT_CPE_INVALID_PARAMETER_NAME
}