From: Mohamed <mohamed.kallel@pivasoftware.com>
update the get notification in order to put the returned data via ubus instead
of pipe TODO: develop the xml handle message to perform send of
GetParameterAttributeResponse
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed Kallel <mohamed.kallel@pivasoftware.com>
Signed-off-by: Ahmed Zribi <ahmed.zribi@pivasoftware.com>
---
ext/openwrt/scripts/freecwmp.sh | 31 +++++-
ext/openwrt/scripts/functions/common | 20 +++
ext/openwrt/scripts/functions/device_hosts | 2 +
ext/openwrt/scripts/functions/device_info | 93 +++++++++++++++
ext/openwrt/scripts/functions/device_ip | 2 +
ext/openwrt/scripts/functions/device_routing | 2 +
ext/openwrt/scripts/functions/device_users | 2 +
ext/openwrt/scripts/functions/lan_device | 49 ++++++++
ext/openwrt/scripts/functions/management_server | 142 +++++++++++++++++++++++
ext/openwrt/scripts/functions/misc | 2 +
ext/openwrt/scripts/functions/wan_device | 102 ++++++++++++++++
src/ubus.c | 42 +++++++
12 files changed, 487 insertions(+), 2 deletions(-)
diff --git a/ext/openwrt/scripts/freecwmp.sh b/ext/openwrt/scripts/freecwmp.sh
index b2a2e40..efc4cc0 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -105,6 +105,7 @@ fi
get_value_functions=""
set_value_functions=""
get_name_functions=""
+get_notification_functions=""
load_script() {
. $1
@@ -114,6 +115,7 @@ load_function() {
get_value_functions="$get_value_functions get_$1"
set_value_functions="$set_value_functions set_$1"
get_name_functions="$get_name_functions get_$1_name"
+ get_notification_functions="$get_notification_functions
get_$1_notification"
}
handle_scripts() {
@@ -225,8 +227,33 @@ if [ "$action" = "set_value" ]; then
fi
if [ "$action" = "get_notification" -o "$action" = "get_all" ]; then
- freecwmp_get_parameter_notification "x_notification" "$__arg1"
- freecwmp_notification_output "$__arg1" "$x_notification"
+ if [ ${FLAGS_force} -eq ${FLAGS_FALSE} ]; then
+ __tmp_arg="Device."
+ # TODO: don't check only string length ; but this is only used
+ # for getting correct prefix of CWMP parameter anyway and
accepting empty string
+ if [ ${#__arg1} -lt ${#__tmp_arg} -a ${#__arg1} -ne 0 ]; then
+ echo "CWMP parameters usualy begin with
'InternetGatewayDevice.' or 'Device.' or '' "
+ echo "if you want to force script execution with
provided parameter use '-f' flag."
+ exit -1
+ fi
+ fi
+ freecwmp_check_fault "$__arg1"
+ fault_code="$?"
+ if [ "$fault_code" = "0" ]; then
+ # TODO: don't return only 'InternetGatewayDevice.' when getting
an empty string; but we should both
+ # parameters with prefix 'InternetGatewayDevice.' and
'Device.'
+ if [ "$__arg1" = "InternetGatewayDevice." -a "$__arg1" = "" ];
then
+ __param="InternetGatewayDevice."
+ else
+ __param="$__arg1"
+ fi
+ freecwmp_execute_functions "$get_notification_functions"
"$__param"
+ fault_code="$?"
+ fi
+ if [ "$fault_code" != "0" ]; then
+ let fault_code=$fault_code+9000
+ freecwmp_output "$__arg1" "" "" "" "$fault_code"
+ fi
fi
if [ "$action" = "set_notification" ]; then
diff --git a/ext/openwrt/scripts/functions/common
b/ext/openwrt/scripts/functions/common
index 5cd02b3..2bfba9a 100644
--- a/ext/openwrt/scripts/functions/common
+++ b/ext/openwrt/scripts/functions/common
@@ -64,6 +64,9 @@ freecwmp_ubus_output() {
get_name)
ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069
get_parameter_names '{ "parameter": "'$parameter'", "writable":
"'$permissions'", "fault_code": "'$fault_code'" }' 2> /dev/null
;;
+ get_notification)
+ ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069
get_parameter_attributes '{ "parameter": "'$parameter'", "notification":
"'$value'", "fault_code": "'$fault_code'" }' 2> /dev/null
+ ;;
esac
}
freecwmp_value_output() {
@@ -195,6 +198,9 @@ freecwmp_config_notifications() {
if [ "$item" = "$3" ]; then
eval "export -- \"$4=2\""
return 0
+ elif [ "`echo $3|grep $item`" = "$3" ]; then
+ eval "export -- \"$4=2\""
+ return 0
fi
done
for item in $__passive
@@ -202,6 +208,9 @@ freecwmp_config_notifications() {
if [ "$item" = "$3" ]; then
eval "export -- \"$4=1\""
return 0
+ elif [ "`echo $3|grep $item`" = "$3" ]; then
+ eval "export -- \"$4=1\""
+ return 0
fi
done
}
@@ -237,7 +246,18 @@ freecwmp_get_parameter_notification() {
local _dest="$1"
local _parm="$2"
local _val
+ local _parent
config_foreach freecwmp_config_notifications "notifications" "get"
"$_parm" "_val"
+ if [ "$_val" = "" ]; then
+ if [ "`echo $_parm|grep '\.$'`" = "" ]; then
+ _parent="${_parm%.*}."
+ config_foreach freecwmp_config_notifications
"notifications" "get" "$_parent" "_val"
+ else
+ _parent="${_parm%.*.}."
+ config_foreach freecwmp_config_notifications
"notifications" "get" "$_parent" "_val"
+ fi
+ fi
+ if [ "$_val" = "" ];then _val="0" ;fi
eval "export -- \"$_dest=$_val\""
}
diff --git a/ext/openwrt/scripts/functions/device_hosts
b/ext/openwrt/scripts/functions/device_hosts
index 5f63c38..2365c88 100644
--- a/ext/openwrt/scripts/functions/device_hosts
+++ b/ext/openwrt/scripts/functions/device_hosts
@@ -192,4 +192,6 @@ return $E_INVALID_PARAMETER_NAME
get_device_hosts_name() { return $E_INVALID_PARAMETER_NAME; }
+get_device_hosts_notification() { return $E_INVALID_PARAMETER_NAME; }
+
set_device_hosts() { return; }
diff --git a/ext/openwrt/scripts/functions/device_info
b/ext/openwrt/scripts/functions/device_info
index 3509d9d..e9de6d2 100644
--- a/ext/openwrt/scripts/functions/device_info
+++ b/ext/openwrt/scripts/functions/device_info
@@ -12,6 +12,9 @@ case "$action" in
get_name)
permissions="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val"
"InternetGatewayDevice.DeviceInfo.Manufacturer"
+ ;;
esac
freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"
"$permissions"
}
@@ -30,6 +33,9 @@ case "$action" in
get_name)
permissions="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val"
"InternetGatewayDevice.DeviceInfo.ManufacturerOUI"
+ ;;
esac
freecwmp_output "InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val"
"$permissions"
}
@@ -47,6 +53,9 @@ case "$action" in
get_name)
permissions="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val"
"InternetGatewayDevice.DeviceInfo.ProductClass"
+ ;;
esac
freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" "$val"
"$permissions"
}
@@ -65,6 +74,9 @@ case "$action" in
get_name)
permissions="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val"
"InternetGatewayDevice.DeviceInfo.SerialNumber"
+ ;;
esac
freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" "$val"
"$permissions"
}
@@ -83,6 +95,9 @@ case "$action" in
get_name)
permissions="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val"
"InternetGatewayDevice.DeviceInfo.HardwareVersion"
+ ;;
esac
freecwmp_output "InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val"
"$permissions"
}
@@ -101,6 +116,9 @@ case "$action" in
get_name)
permissions="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val"
"InternetGatewayDevice.DeviceInfo.SoftwareVersion"
+ ;;
esac
freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val"
"$permissions"
}
@@ -119,6 +137,9 @@ case "$action" in
get_name)
permissions="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val"
"InternetGatewayDevice.DeviceInfo.UpTime"
+ ;;
esac
freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val" "$permissions"
}
@@ -137,6 +158,9 @@ case "$action" in
get_name)
permissions="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val"
"InternetGatewayDevice.DeviceInfo.DeviceLog"
+ ;;
esac
freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val"
"$permissions"
}
@@ -289,6 +313,66 @@ esac
return $E_INVALID_PARAMETER_NAME
}
+get_device_info_notification() {
+case "$1" in
+ InternetGatewayDevice.)
+ get_device_info_manufacturer
+ get_device_info_oui
+ get_device_info_product_class
+ get_device_info_serial_number
+ get_device_info_hardware_version
+ get_device_info_software_version
+ get_device_info_uptime
+ get_device_info_device_log
+ return 0
+ ;;
+ InternetGatewayDevice.DeviceInfo.)
+ get_device_info_manufacturer
+ get_device_info_oui
+ get_device_info_product_class
+ get_device_info_serial_number
+ get_device_info_hardware_version
+ get_device_info_software_version
+ get_device_info_uptime
+ get_device_info_device_log
+ return 0
+ ;;
+ InternetGatewayDevice.DeviceInfo.Manufacturer)
+ get_device_info_manufacturer
+ return 0
+ ;;
+ InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
+ get_device_info_oui
+ return 0
+ ;;
+ InternetGatewayDevice.DeviceInfo.ProductClass)
+ get_device_info_product_class
+ return 0
+ ;;
+ InternetGatewayDevice.DeviceInfo.SerialNumber)
+ get_device_info_serial_number
+ return 0
+ ;;
+ InternetGatewayDevice.DeviceInfo.HardwareVersion)
+ get_device_info_hardware_version
+ return 0
+ ;;
+ InternetGatewayDevice.DeviceInfo.SoftwareVersion)
+ get_device_info_software_version
+ return 0
+ ;;
+ InternetGatewayDevice.DeviceInfo.UpTime)
+ get_device_info_uptime
+ return 0
+ ;;
+ InternetGatewayDevice.DeviceInfo.DeviceLog)
+ get_device_info_device_log
+ return 0
+ ;;
+esac
+return $E_INVALID_PARAMETER_NAME
+}
+
set_device_info() {
case "$1" in
InternetGatewayDevice.DeviceInfo.Manufacturer)
@@ -363,6 +447,15 @@ get_device_info_generic_name() {
return $E_INVALID_PARAMETER_NAME
}
+get_device_info_generic_notification() {
+ check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1
]; then return $E_INVALID_PARAMETER_NAME; fi
+
+ local val
+ freecwmp_get_parameter_notification "val" "$1"
+ freecwmp_output "$1" "$val"
+ return 0
+}
+
set_device_info_generic() {
check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1
]; then return 0; fi
diff --git a/ext/openwrt/scripts/functions/device_ip
b/ext/openwrt/scripts/functions/device_ip
index c4fbab6..0be4860 100644
--- a/ext/openwrt/scripts/functions/device_ip
+++ b/ext/openwrt/scripts/functions/device_ip
@@ -125,4 +125,6 @@ return $E_INVALID_PARAMETER_NAME;
get_device_ip_name() { return $E_INVALID_PARAMETER_NAME; }
+get_device_ip_notification() { return $E_INVALID_PARAMETER_NAME; }
+
set_device_ip() { return; }
diff --git a/ext/openwrt/scripts/functions/device_routing
b/ext/openwrt/scripts/functions/device_routing
index 7e76be3..f3b186c 100644
--- a/ext/openwrt/scripts/functions/device_routing
+++ b/ext/openwrt/scripts/functions/device_routing
@@ -355,4 +355,6 @@ return $E_INVALID_PARAMETER_NAME
get_device_routing_name() { return $E_INVALID_PARAMETER_NAME; }
+get_device_routing_notification() { return $E_INVALID_PARAMETER_NAME; }
+
set_device_routing() { return; }
diff --git a/ext/openwrt/scripts/functions/device_users
b/ext/openwrt/scripts/functions/device_users
index 1926208..7988df5 100644
--- a/ext/openwrt/scripts/functions/device_users
+++ b/ext/openwrt/scripts/functions/device_users
@@ -129,4 +129,6 @@ fi
get_device_users_name() { return $E_INVALID_PARAMETER_NAME; }
+get_device_users_notification() { return $E_INVALID_PARAMETER_NAME; }
+
set_device_users() { return; }
diff --git a/ext/openwrt/scripts/functions/lan_device
b/ext/openwrt/scripts/functions/lan_device
index 1d00558..8fdf12b 100644
--- a/ext/openwrt/scripts/functions/lan_device
+++ b/ext/openwrt/scripts/functions/lan_device
@@ -23,6 +23,11 @@ case "$action" in
let num=$num+1
freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
"$permissions"
;;
+ get_notification)
+ let num=$num+1
+ freecwmp_get_parameter_notification "val"
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable"
+ freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
+ ;;
esac
}
@@ -53,6 +58,11 @@ case "$action" in
let num=$num+1
freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
"$permissions"
;;
+ get_notification)
+ let num=$num+1
+ freecwmp_get_parameter_notification "val"
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID"
+ freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
+ ;;
esac
}
@@ -171,6 +181,45 @@ esac
return $E_INVALID_PARAMETER_NAME
}
+get_lan_device_notification() {
+case "$1" in
+ InternetGatewayDevice.)
+ get_wlan_enable 0
+ get_wlan_ssid 0
+ return 0
+ ;;
+ InternetGatewayDevice.LANDevice.)
+ get_wlan_enable 0
+ get_wlan_ssid 0
+ return 0
+ ;;
+ InternetGatewayDevice.LANDevice.1.)
+ get_wlan_enable 0
+ get_wlan_ssid 0
+ return 0
+ ;;
+ InternetGatewayDevice.LANDevice.1.WLANConfiguration.)
+ get_wlan_enable 0
+ get_wlan_ssid 0
+ return 0
+ ;;
+ InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
+ get_wlan_enable 0
+ get_wlan_ssid 0
+ return 0
+ ;;
+ InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
+ get_wlan_enable 0
+ return 0
+ ;;
+ InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
+ get_wlan_ssid 0
+ return 0
+ ;;
+esac
+return $E_INVALID_PARAMETER_NAME
+}
+
set_lan_device() {
case "$1" in
InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
diff --git a/ext/openwrt/scripts/functions/management_server
b/ext/openwrt/scripts/functions/management_server
index 0ecdf26..e40758c 100644
--- a/ext/openwrt/scripts/functions/management_server
+++ b/ext/openwrt/scripts/functions/management_server
@@ -23,6 +23,9 @@ case "$action" in
get_name)
permissions="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
freecwmp_output "$parm" "$val" "$permissions"
}
@@ -68,6 +71,9 @@ case "$action" in
get_name)
permissions="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
freecwmp_output "$parm" "$val" "$permissions"
}
@@ -87,6 +93,9 @@ case "$action" in
get_name)
permissions="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
freecwmp_output "$parm" "$val" "$permissions"
}
@@ -107,6 +116,9 @@ case "$action" in
get_name)
permissions="1"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
freecwmp_output "$parm" "$val" "$permissions" "$type"
}
@@ -128,6 +140,9 @@ case "$action" in
get_name)
permissions="1"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
freecwmp_output "$parm" "$val" "$permissions" "$type"
}
@@ -163,6 +178,9 @@ case "$action" in
get_name)
permissions="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
freecwmp_output "$parm" "$val" "$permissions"
}
@@ -178,6 +196,9 @@ case "$action" in
get_name)
permissions="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
freecwmp_output "$parm" "$val" "$permissions"
}
@@ -197,6 +218,9 @@ case "$action" in
get_name)
permissions="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
freecwmp_output "$parm" "$val" "$permissions"
}
@@ -217,6 +241,9 @@ case "$action" in
get_name)
permissions="1"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
freecwmp_output "$parm" "$val" "$permissions"
}
@@ -236,6 +263,9 @@ case "$action" in
get_name)
permissions="1"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
freecwmp_output "$parm" "$val" "$permissions"
}
@@ -259,6 +289,9 @@ case "$action" in
get_name)
permissions="1"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
freecwmp_output "$parm" "$val" "$permissions"
}
@@ -278,6 +311,9 @@ case "$action" in
get_name)
permissions="1"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
freecwmp_output "$parm" "$val" "$permissions"
}
@@ -297,6 +333,9 @@ case "$action" in
get_name)
permissions="1"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
freecwmp_output "$parm" "$val" "$permissions"
}
@@ -535,6 +574,100 @@ esac
return $E_INVALID_PARAMETER_NAME
}
+get_management_server_notification() {
+case "$1" in
+ InternetGatewayDevice.)
+ get_management_server_url
+ get_management_server_username
+ get_management_server_password
+ get_management_server_periodic_inform_enable
+ get_management_server_periodic_inform_interval
+ get_management_server_connection_request_url
+ get_management_server_connection_request_username
+ get_management_server_connection_request_password
+ get_management_server_x_freecwmp_org__acs_scheme
+ get_management_server_x_freecwmp_org__acs_hostname
+ get_management_server_x_freecwmp_org__acs_port
+ get_management_server_x_freecwmp_org__acs_path
+ get_management_server_x_freecwmp_org__connection_request_port
+ return 0
+ ;;
+ InternetGatewayDevice.ManagementServer.)
+ get_management_server_url
+ get_management_server_username
+ get_management_server_password
+ get_management_server_periodic_inform_enable
+ get_management_server_periodic_inform_interval
+ get_management_server_connection_request_url
+ get_management_server_connection_request_username
+ get_management_server_connection_request_password
+ get_management_server_x_freecwmp_org__acs_scheme
+ get_management_server_x_freecwmp_org__acs_hostname
+ get_management_server_x_freecwmp_org__acs_port
+ get_management_server_x_freecwmp_org__acs_path
+ get_management_server_x_freecwmp_org__connection_request_port
+ return 0
+ ;;
+ InternetGatewayDevice.ManagementServer.URL)
+ get_management_server_url
+ return 0
+ ;;
+ InternetGatewayDevice.ManagementServer.Username)
+ get_management_server_username
+ return 0
+ ;;
+ InternetGatewayDevice.ManagementServer.Password)
+ get_management_server_password
+ return 0
+ ;;
+ InternetGatewayDevice.ManagementServer.PeriodicInformEnable)
+ get_management_server_periodic_inform_enable
+ return 0
+ ;;
+ InternetGatewayDevice.ManagementServer.PeriodicInformInterval)
+ get_management_server_periodic_inform_interval
+ return 0
+ ;;
+ InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
+ get_management_server_connection_request_url
+ return 0
+ ;;
+ InternetGatewayDevice.ManagementServer.ConnectionRequestUsername)
+ get_management_server_connection_request_username
+ return 0
+ ;;
+ InternetGatewayDevice.ManagementServer.ConnectionRequestPassword)
+ get_management_server_connection_request_password
+ return 0
+ ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme)
+ get_management_server_x_freecwmp_org__acs_scheme
+ return 0
+ ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname)
+ get_management_server_x_freecwmp_org__acs_hostname
+ return 0
+ ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port)
+ get_management_server_x_freecwmp_org__acs_port
+ return 0
+ ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path)
+ get_management_server_x_freecwmp_org__acs_path
+ return 0
+ ;;
+
InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port)
+ get_management_server_x_freecwmp_org__connection_request_port
+ return 0
+ ;;
+ InternetGatewayDevice.ManagementServer.ParameterKey)
+ get_management_server_parameter_key
+ return 0
+ ;;
+esac
+return $E_INVALID_PARAMETER_NAME
+}
+
set_management_server() {
case "$1" in
InternetGatewayDevice.ManagementServer.URL)
@@ -605,6 +738,15 @@ get_management_server_generic_name() {
return 0
}
+get_management_server_generic_notification() {
+ check_parameter_management_server_generic "$1" ; _tmp=$? ; if [ "$_tmp"
-eq 1 ]; then return $E_INVALID_PARAMETER_NAME; fi
+
+ local val
+ freecwmp_get_parameter_notification "val" "$1"
+ freecwmp_output "$1" "$val"
+ return 0
+}
+
set_management_server_generic() {
check_parameter_management_server_generic "$1" ; _tmp=$? ; if [ "$_tmp"
-eq 1 ]; then return 0; fi
diff --git a/ext/openwrt/scripts/functions/misc
b/ext/openwrt/scripts/functions/misc
index bf48308..fe0686f 100644
--- a/ext/openwrt/scripts/functions/misc
+++ b/ext/openwrt/scripts/functions/misc
@@ -29,4 +29,6 @@ return $E_INVALID_PARAMETER_NAME
get_misc_name () { return $E_INVALID_PARAMETER_NAME; }
+get_misc_notification () { return $E_INVALID_PARAMETER_NAME; }
+
set_misc() { return; }
diff --git a/ext/openwrt/scripts/functions/wan_device
b/ext/openwrt/scripts/functions/wan_device
index b3b456b..0944bca 100644
--- a/ext/openwrt/scripts/functions/wan_device
+++ b/ext/openwrt/scripts/functions/wan_device
@@ -15,6 +15,9 @@ case "$action" in
get_name)
permissions="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
freecwmp_output "$parm" "$val" "$permissions" "$type"
}
@@ -34,6 +37,9 @@ case "$action" in
get_name)
permissions="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
freecwmp_output "$parm" "$val" "$permissions"
}
@@ -53,6 +59,9 @@ case "$action" in
get_name)
permissions="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
freecwmp_output "$parm" "$val" "$permissions"
}
@@ -101,6 +110,9 @@ case "$action" in
get_name)
permissions="1"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
freecwmp_output "$parm" "$val" "$permissions"
}
@@ -120,6 +132,9 @@ case "$action" in
get_name)
permissions="1"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
freecwmp_output "$parm" "$val" "$permissions"
}
@@ -344,6 +359,93 @@ esac
return $E_INVALID_PARAMETER_NAME
}
+get_wan_device_notification() {
+case "$1" in
+ InternetGatewayDevice.)
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ get_wan_device_wan_ppp_enable
+ get_wan_device_wan_ppp_username
+ get_wan_device_wan_ppp_password
+ return 0
+ ;;
+ InternetGatewayDevice.WANDevice.)
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ get_wan_device_wan_ppp_enable
+ get_wan_device_wan_ppp_username
+ get_wan_device_wan_ppp_password
+ return 0
+ ;;
+ InternetGatewayDevice.WANDevice.1.)
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ get_wan_device_wan_ppp_enable
+ get_wan_device_wan_ppp_username
+ get_wan_device_wan_ppp_password
+ return 0
+ ;;
+ InternetGatewayDevice.WANDevice.1.WANConnectionDevice.)
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ get_wan_device_wan_ppp_enable
+ get_wan_device_wan_ppp_username
+ get_wan_device_wan_ppp_password
+ return 0
+ ;;
+ InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.)
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ get_wan_device_wan_ppp_enable
+ get_wan_device_wan_ppp_username
+ get_wan_device_wan_ppp_password
+ return 0
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.)
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ return 0
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.)
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ return 0
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus)
+ get_wan_device_mng_status
+ return 0
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress)
+ get_wan_device_mng_interface_ip
+ return 0
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress)
+ get_wan_device_mng_interface_mac
+ return 0
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
+ get_wan_device_wan_ppp_enable
+ return 0
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
+ get_wan_device_wan_ppp_username
+ return 0
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
+ get_wan_device_wan_ppp_password
+ return 0
+ ;;
+esac
+return $E_INVALID_PARAMETER_NAME
+}
+
set_wan_device() {
case "$1" in
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
diff --git a/src/ubus.c b/src/ubus.c
index 4c741a5..4825b5f 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -238,12 +238,54 @@ freecwmpd_handle_get_param_names(struct ubus_context
*ctx, struct ubus_object *o
return 0;
}
+static enum get_param_attributes {
+ GET_PARAM_ATTRIBUTES_PARAM,
+ GET_PARAM_ATTRIBUTES_NOTIF,
+ GET_PARAM_ATTRIBUTES_FAULT,
+ __GET_PARAM_ATTRIBUTES_MAX
+};
+
+static const struct blobmsg_policy get_param_attributes_policy[] = {
+ [GET_PARAM_ATTRIBUTES_PARAM] = { .name = "parameter", .type =
BLOBMSG_TYPE_STRING },
+ [GET_PARAM_ATTRIBUTES_NOTIF] = { .name = "notification", .type =
BLOBMSG_TYPE_STRING },
+ [GET_PARAM_ATTRIBUTES_FAULT] = { .name = "fault_code", .type =
BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_get_param_attributes(struct ubus_context *ctx, struct
ubus_object *obj,
+ struct ubus_request_data *req, const char *method,
+ struct blob_attr *msg)
+{
+ struct blob_attr *tb[__GET_PARAM_ATTRIBUTES_MAX];
+
+ blobmsg_parse(get_param_attributes_policy,
ARRAY_SIZE(get_param_attributes_policy), tb,
+ blob_data(msg), blob_len(msg));
+
+ if (!tb[GET_PARAM_ATTRIBUTES_PARAM])
+ return UBUS_STATUS_INVALID_ARGUMENT;
+
+ if (!tb[GET_PARAM_ATTRIBUTES_NOTIF])
+ return UBUS_STATUS_INVALID_ARGUMENT;
+
+ lfc_log_message(NAME, L_NOTICE,
+ "triggered ubus get_parameter_attributes for the
parameter %s\n",
+ blobmsg_data(tb[GET_PARAM_ATTRIBUTES_PARAM]));
+
+
external_add_list_paramameter(blobmsg_data(tb[GET_PARAM_ATTRIBUTES_PARAM]),
+
blobmsg_data(tb[GET_PARAM_ATTRIBUTES_NOTIF]),
+ NULL,
+
blobmsg_data(tb[GET_PARAM_ATTRIBUTES_FAULT]));
+
+ return 0;
+}
+
static const struct ubus_method freecwmp_methods[] = {
UBUS_METHOD("notify", freecwmpd_handle_notify, notify_policy),
UBUS_METHOD("inform", freecwmpd_handle_inform, inform_policy),
UBUS_METHOD("command", freecwmpd_handle_command, command_policy),
UBUS_METHOD("get_parameter_values", freecwmpd_handle_get_param_values,
get_param_values_policy),
UBUS_METHOD("get_parameter_names", freecwmpd_handle_get_param_names,
get_param_names_policy),
+ UBUS_METHOD("get_parameter_attributes",
freecwmpd_handle_get_param_attributes, get_param_attributes_policy),
};
static struct ubus_object_type main_object_type =
--
1.7.4.1
|