icwmp/src/scripts/functions/device_info

490 lines
No EOL
13 KiB
Bash

#!/bin/sh
# Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
# Copyright (C) 2012 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
get_device_info_manufacturer() {
local val=""
local permissions=""
case "$action" in
get_value)
val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get cwmp.cpe.manufacturer 2> /dev/null`
;;
get_name)
permissions="0"
;;
get_notification)
freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.Manufacturer"
;;
esac
freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val" "$permissions"
}
set_device_info_manufacturer() {
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set cwmp.cpe.manufacturer="$1"
}
get_device_info_oui() {
local val=""
local permissions=""
case "$action" in
get_value)
val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get cwmp.cpe.oui 2> /dev/null`
;;
get_name)
permissions="0"
;;
get_notification)
freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.ManufacturerOUI"
;;
esac
freecwmp_output "InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val" "$permissions"
}
set_device_info_oui() {
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set cwmp.cpe.oui="$1"
}
get_device_info_product_class() {
local val=""
case "$action" in
get_value)
val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get cwmp.cpe.product_class 2> /dev/null`
;;
get_name)
permissions="0"
;;
get_notification)
freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.ProductClass"
;;
esac
freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" "$val" "$permissions"
}
set_device_info_product_class() {
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set cwmp.cpe.product_class="$1"
}
get_device_info_serial_number() {
local val=""
local permissions=""
case "$action" in
get_value)
local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get cwmp.cpe.serial_number 2> /dev/null`
;;
get_name)
permissions="0"
;;
get_notification)
freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.SerialNumber"
;;
esac
freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" "$val" "$permissions"
}
set_device_info_serial_number() {
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set cwmp.cpe.serial_number="$1"
}
get_device_info_hardware_version() {
local val=""
local permissions=""
case "$action" in
get_value)
val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get cwmp.cpe.hardware_version 2> /dev/null`
;;
get_name)
permissions="0"
;;
get_notification)
freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.HardwareVersion"
;;
esac
freecwmp_output "InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val" "$permissions"
}
set_device_info_hardware_version() {
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set cwmp.cpe.hardware_version="$1"
}
get_device_info_software_version() {
local val=""
local permissions=""
case "$action" in
get_value)
val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get cwmp.cpe.software_version 2> /dev/null`
;;
get_name)
permissions="0"
;;
get_notification)
freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.SoftwareVersion"
;;
esac
freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val" "$permissions"
}
set_device_info_software_version() {
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set cwmp.cpe.software_version="$1"
}
get_device_info_uptime() {
local val=""
local permissions=""
case "$action" in
get_value)
val=`cat /proc/uptime | awk -F "." '{ print $1 }'`
;;
get_name)
permissions="0"
;;
get_notification)
freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.UpTime"
;;
esac
freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val" "$permissions"
}
get_device_info_device_log() {
local val=""
local permissions=""
case "$action" in
get_value)
#if [ ${FLAGS_last} -eq ${FLAGS_TRUE} ]; then
# val=`dmesg | tail -n1`
#else
# val=`dmesg | tail -n10`
#fi
val=""
;;
get_name)
permissions="0"
;;
get_notification)
freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.DeviceLog"
;;
esac
freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val" "$permissions"
}
get_device_info() {
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 $FAULT_CPE_NO_FAULT
;;
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 $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.Manufacturer)
get_device_info_manufacturer
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
get_device_info_oui
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.ProductClass)
get_device_info_product_class
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.SerialNumber)
get_device_info_serial_number
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.HardwareVersion)
get_device_info_hardware_version
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.SoftwareVersion)
get_device_info_software_version
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.UpTime)
get_device_info_uptime
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.DeviceLog)
get_device_info_device_log
return $FAULT_CPE_NO_FAULT
;;
esac
return $FAULT_CPE_INVALID_PARAMETER_NAME
}
get_device_info_name() {
case "$1" in
InternetGatewayDevice.)
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.)
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
}
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 $FAULT_CPE_NO_FAULT
;;
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 $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.Manufacturer)
get_device_info_manufacturer
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
get_device_info_oui
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.ProductClass)
get_device_info_product_class
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.SerialNumber)
get_device_info_serial_number
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.HardwareVersion)
get_device_info_hardware_version
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.SoftwareVersion)
get_device_info_software_version
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.UpTime)
get_device_info_uptime
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.DeviceLog)
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)
set_device_info_manufacturer "$2"
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.ManufacturerOUI)
set_device_info_oui "$2"
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.ProductClass)
set_device_info_product_class "$2"
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.SerialNumber)
set_device_info_serial_number "$2"
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.HardwareVersion)
set_device_info_hardware_version "$2"
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.SoftwareVersion)
set_device_info_software_version "$2"
return $FAULT_CPE_NO_FAULT
;;
esac
return $FAULT_CPE_INVALID_PARAMETER_NAME
}
set_device_info_notification() {
return $FAULT_CPE_NOTIFICATION_REJECTED
}
check_parameter_device_info_generic() {
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.ProvisioningCode|\
InternetGatewayDevice.DeviceInfo.FirstUseDate)
return 0
;;
esac
return 1
}
get_device_info_generic() {
check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
freecwmp_get_parameter_value "val" "$1"
freecwmp_output "$1" "$val"
return $FAULT_CPE_NO_FAULT
}
get_device_info_generic_name() {
local val=""
local permissions=""
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)
permissions="0"
freecwmp_output "$1" "" "$permissions"
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.DeviceInfo.ProvisioningCode)
permissions="1"
freecwmp_output "$1" "" "$permissions"
return $FAULT_CPE_NO_FAULT
;;
esac
return $FAULT_CPE_INVALID_PARAMETER_NAME
}
get_device_info_generic_notification() {
check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return $FAULT_CPE_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 $FAULT_CPE_INVALID_PARAMETER_NAME; fi
freecwmp_set_parameter_value "$1" "$2"
return $FAULT_CPE_NO_FAULT
}
set_device_info_generic_notification() {
check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp" -eq 1 ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
freecwmp_set_parameter_notification "$1" "$2"
return $FAULT_CPE_NO_FAULT
}
add_device_info() { return $FAULT_CPE_INVALID_PARAMETER_NAME; }
delete_device_info() { return $FAULT_CPE_INVALID_PARAMETER_NAME; }
add_device_info_generic() { return $FAULT_CPE_INVALID_PARAMETER_NAME; }
delete_device_info_generic() { return $FAULT_CPE_INVALID_PARAMETER_NAME; }