#!/bin/sh # Copyright (C) 2011-2012 Luka Perkov # Copyright (C) 2013 Inteno Broadband Technology AB # Author Ahmed Zribi get_device_info_manufacturer() { local val="" local permissions="" case "$action" in get_value) val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q 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" } get_device_info_oui() { local val="" local permissions="" case "$action" in get_value) val=`cat /proc/nvram/BaseMacAddr | awk '{ print $1$2$3}' 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" } get_device_info_product_class() { local val="" case "$action" in get_value) val=`cat /etc/iop_version | cut -d'_' -f1 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" } get_device_info_serial_number() { local val="" local permissions="" case "$action" in get_value) local val=`cat /proc/nvram/SerialNumber 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" } get_device_info_hardware_version() { local val="" local permissions="" local dslAnnex="" case "$action" in get_value) dslAnnex=`cat /proc/nvram/dslAnnex 2> /dev/null` val=`cat /etc/iop_version | cut -d'-' -f1 | sed s/$/"$dslAnnex"/ 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" } get_device_info_software_version() { local val="" local permissions="" case "$action" in get_value) val=`cat /etc/iop_version | cut -d'_' -f2 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" } get_device_info_uptime() { local val="" local permissions="" local type="xsd:unsignedInt" 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" "$type" } 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) return $FAULT_CPE_NON_WRITABLE_PARAMETER ;; InternetGatewayDevice.DeviceInfo.ManufacturerOUI) return $FAULT_CPE_NON_WRITABLE_PARAMETER ;; InternetGatewayDevice.DeviceInfo.ProductClass) return $FAULT_CPE_NON_WRITABLE_PARAMETER ;; InternetGatewayDevice.DeviceInfo.SerialNumber) return $FAULT_CPE_NON_WRITABLE_PARAMETER ;; InternetGatewayDevice.DeviceInfo.HardwareVersion) return $FAULT_CPE_NON_WRITABLE_PARAMETER ;; InternetGatewayDevice.DeviceInfo.SoftwareVersion) return $FAULT_CPE_NON_WRITABLE_PARAMETER ;; InternetGatewayDevice.DeviceInfo.UpTime) return $FAULT_CPE_NON_WRITABLE_PARAMETER ;; InternetGatewayDevice.DeviceInfo.DeviceLog) return $FAULT_CPE_NON_WRITABLE_PARAMETER ;; esac return $FAULT_CPE_INVALID_PARAMETER_NAME } set_device_info_notification() { case "$1" in InternetGatewayDevice.DeviceInfo.) return $FAULT_CPE_NOTIFICATION_REJECTED ;; InternetGatewayDevice.DeviceInfo.Manufacturer) return $FAULT_CPE_NOTIFICATION_REJECTED ;; InternetGatewayDevice.DeviceInfo.ManufacturerOUI) return $FAULT_CPE_NOTIFICATION_REJECTED ;; InternetGatewayDevice.DeviceInfo.ProductClass) return $FAULT_CPE_NOTIFICATION_REJECTED ;; InternetGatewayDevice.DeviceInfo.SerialNumber) return $FAULT_CPE_NOTIFICATION_REJECTED ;; InternetGatewayDevice.DeviceInfo.HardwareVersion) return $FAULT_CPE_NOTIFICATION_REJECTED ;; InternetGatewayDevice.DeviceInfo.SoftwareVersion) return $FAULT_CPE_NOTIFICATION_REJECTED ;; InternetGatewayDevice.DeviceInfo.UpTime) return $FAULT_CPE_NOTIFICATION_REJECTED ;; InternetGatewayDevice.DeviceInfo.DeviceLog) return $FAULT_CPE_NOTIFICATION_REJECTED ;; esac return $FAULT_CPE_INVALID_PARAMETER_NAME } 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 "value" "$1" freecwmp_output "$1" "$value" 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; }