Missing commit message. Contributed by must go in commit message and not
in subject.
On Thu, Dec 06, 2012 at 04:54:41PM +0100, Mohamed wrote:
>
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> ---
> ext/openwrt/scripts/functions/device_info | 199
> +++++++++++++++++++++++++++--
> 1 files changed, 187 insertions(+), 12 deletions(-)
>
> diff --git a/ext/openwrt/scripts/functions/device_info
> b/ext/openwrt/scripts/functions/device_info
> index 86ff5c9..c3c6c33 100644
> --- a/ext/openwrt/scripts/functions/device_info
> +++ b/ext/openwrt/scripts/functions/device_info
> @@ -2,7 +2,15 @@
> # Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
>
> get_device_info_manufacturer() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
> freecwmp.@device[0].manufacturer 2> /dev/null`
> +local val=""
> +case "$action" in
> + get_value)
> + val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
> freecwmp.@device[0].manufacturer 2> /dev/null`
> + ;;
> + get_name)
> + val="0"
> + ;;
I don't like this... Tell us what why you use val? Why is it 0? What does that
mean? Generally all this information must go in commit message.
> +esac
> ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"
We should have something like:
freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"
"$permissions" "$type" "$fault_code"
Same goes for all other changes.
> }
>
> @@ -11,7 +19,15 @@ set_device_info_manufacturer() {
> }
>
> get_device_info_oui() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
> freecwmp.@device[0].oui 2> /dev/null`
> +local val=""
> +case "$action" in
> + get_value)
> + val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
> freecwmp.@device[0].oui 2> /dev/null`
> + ;;
> + get_name)
> + val="0"
> + ;;
> +esac
> ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ManufacturerOUI"
> "$val"
> }
>
> @@ -20,7 +36,15 @@ set_device_info_oui() {
> }
>
> get_device_info_product_class() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
> freecwmp.@device[0].product_class 2> /dev/null`
> +local val=""
> +case "$action" in
> + get_value)
> + val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
> freecwmp.@device[0].product_class 2> /dev/null`
> + ;;
> + get_name)
> + val="0"
> + ;;
> +esac
> ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" "$val"
> }
>
> @@ -29,7 +53,15 @@ set_device_info_product_class() {
> }
>
> get_device_info_serial_number() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
> freecwmp.@device[0].serial_number 2> /dev/null`
> +local val=""
> +case "$action" in
> + get_value)
> + local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
> freecwmp.@device[0].serial_number 2> /dev/null`
> + ;;
> + get_name)
> + local val="0"
> + ;;
> +esac
> ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" "$val"
> }
>
> @@ -38,7 +70,15 @@ set_device_info_serial_number() {
> }
>
> get_device_info_hardware_version() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
> freecwmp.@device[0].hardware_version 2> /dev/null`
> +local val=""
> +case "$action" in
> + get_value)
> + val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
> freecwmp.@device[0].hardware_version 2> /dev/null`
> + ;;
> + get_name)
> + val="0"
> + ;;
> +esac
> ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.HardwareVersion"
> "$val"
> }
>
> @@ -47,7 +87,15 @@ set_device_info_hardware_version() {
> }
>
> get_device_info_software_version() {
> -local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
> freecwmp.@device[0].software_version 2> /dev/null`
> +local val=""
> +case "$action" in
> + get_value)
> + val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
> freecwmp.@device[0].software_version 2> /dev/null`
> + ;;
> + get_name)
> + val="0"
> + ;;
> +esac
> ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion"
> "$val"
> }
>
> @@ -56,17 +104,32 @@ set_device_info_software_version() {
> }
>
> get_device_info_uptime() {
> -local val=`cat /proc/uptime | awk -F "." '{ print $1 }'`
> +local val=""
> +case "$action" in
> + get_value)
> + val=`cat /proc/uptime | awk -F "." '{ print $1 }'`
> + ;;
> + get_name)
> + val="0"
> + ;;
> +esac
> ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val"
> }
>
> get_device_info_device_log() {
> local val=""
> -if [ ${FLAGS_last} -eq ${FLAGS_TRUE} ]; then
> - val=`dmesg | tail -n1`
> -else
> - val=`dmesg | tail -n10`
> -fi
> +case "$action" in
> + get_value)
> + if [ ${FLAGS_last} -eq ${FLAGS_TRUE} ]; then
> + val=`dmesg | tail -n1`
> + else
> + val=`dmesg | tail -n10`
> + fi
> + ;;
> + get_name)
> + val="0"
> + ;;
> +esac
> ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val"
> }
>
> @@ -130,6 +193,94 @@ esac
> return $FAULT_CPE_INVALID_PARAMETER_NAME
> }
>
> +get_device_info_name() {
> +case "$1" in
> + InternetGatewayDevice.)
> + ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo." "0"
> + if [ "$2" = "0" ]; then
> + 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
> + fi
> + return $FAULT_CPE_NO_FAULT
> + ;;
> + InternetGatewayDevice.DeviceInfo.)
> + ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo." "0"
> + 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 $FAULT_CPE_NO_FAULT
> + ;;
> + InternetGatewayDevice.DeviceInfo.Manufacturer)
> + if [ "$2" = "1" ]; then
> + return $FAULT_CPE_INVALID_ARGUMENTS
> + fi
> + get_device_info_manufacturer
> + return $FAULT_CPE_NO_FAULT
> + ;;
> + InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
> + if [ "$2" = "1" ]; then
> + return $FAULT_CPE_INVALID_ARGUMENTS
> + fi
> + get_device_info_oui
> + return $FAULT_CPE_NO_FAULT
> + ;;
> + InternetGatewayDevice.DeviceInfo.ProductClass)
> + if [ "$2" = "1" ]; then
> + return $FAULT_CPE_INVALID_ARGUMENTS
> + fi
> + get_device_info_product_class
> + return $FAULT_CPE_NO_FAULT
> + ;;
> + InternetGatewayDevice.DeviceInfo.SerialNumber)
> + if [ "$2" = "1" ]; then
> + return $FAULT_CPE_INVALID_ARGUMENTS
> + fi
> + get_device_info_serial_number
> + return $FAULT_CPE_NO_FAULT
> + ;;
> + InternetGatewayDevice.DeviceInfo.HardwareVersion)
> + if [ "$2" = "1" ]; then
> + return $FAULT_CPE_INVALID_ARGUMENTS
> + fi
> + get_device_info_hardware_version
> + return $FAULT_CPE_NO_FAULT
> + ;;
> + InternetGatewayDevice.DeviceInfo.SoftwareVersion)
> + if [ "$2" = "1" ]; then
> + return $FAULT_CPE_INVALID_ARGUMENTS
> + fi
> + get_device_info_software_version
> + return $FAULT_CPE_NO_FAULT
> + ;;
> + InternetGatewayDevice.DeviceInfo.UpTime)
> + if [ "$2" = "1" ]; then
> + return $FAULT_CPE_INVALID_ARGUMENTS
> + fi
> + get_device_info_uptime
> + return $FAULT_CPE_NO_FAULT
> + ;;
> + InternetGatewayDevice.DeviceInfo.DeviceLog)
> + if [ "$2" = "1" ]; then
> + return $FAULT_CPE_INVALID_ARGUMENTS
> + fi
> + get_device_info_device_log
> + return $FAULT_CPE_NO_FAULT
> + ;;
> +esac
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
> +}
> +
> set_device_info() {
> case "$1" in
> InternetGatewayDevice.DeviceInfo.Manufacturer)
> @@ -179,6 +330,30 @@ get_device_info_generic() {
> return $FAULT_CPE_NO_FAULT
> }
>
> +get_device_info_generic_name() {
> + local val=""
> + case "$1" in
> + InternetGatewayDevice.DeviceInfo.ModelName|\
> + InternetGatewayDevice.DeviceInfo.Description|\
> + InternetGatewayDevice.DeviceInfo.ModemFirmwareVersion|\
> + InternetGatewayDevice.DeviceInfo.EnabledOptions|\
> + InternetGatewayDevice.DeviceInfo.AdditionalHardwareVersion|\
> + InternetGatewayDevice.DeviceInfo.AdditionalSoftwareVersion|\
> + InternetGatewayDevice.DeviceInfo.SpecVersion|\
> + InternetGatewayDevice.DeviceInfo.FirstUseDate)
> + val="0"
> + ubus_freecwmp_output "$1" "$val"
> + return $FAULT_CPE_NO_FAULT
> + ;;
> + InternetGatewayDevice.DeviceInfo.ProvisioningCode)
> + val="1"
> + ubus_freecwmp_output "$1" "$val"
> + return $FAULT_CPE_NO_FAULT
> + ;;
> + esac
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
> +}
> +
> set_device_info_generic() {
> check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1
> ]; then return 0; fi
>
> --
> 1.7.4.1
Luka
|