freecwmp
[Top] [All Lists]

Re: [PATCH 27/27] update the dm script function to communicate the outpu

To: mohamed.kallel@pivasoftware.com
Subject: Re: [PATCH 27/27] update the dm script function to communicate the output of set parameter attribute with ubus Contributed by Inteno Broadband Technology AB
From: Luka Perkov <freecwmp@lukaperkov.net>
Date: Sat, 8 Dec 2012 12:17:22 +0100
Cc: freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com, freecwmp@lukaperkov.net, jogo@openwrt.org
In-reply-to: <1354809292-2467-28-git-send-email-mohamed.kallel@pivasoftware.com>
Mail-followup-to: mohamed.kallel@pivasoftware.com, freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com, jogo@openwrt.org
Original-recipient: rfc822;freecwmp@linux-mips.org
References: <mohamed.kallel@pivasoftware.com> <1354809292-2467-1-git-send-email-mohamed.kallel@pivasoftware.com> <1354809292-2467-28-git-send-email-mohamed.kallel@pivasoftware.com>
Sender: freecwmp-bounce@linux-mips.org
User-agent: Mutt/1.5.21 (2010-09-15)
Missing commit message. Contributed by must go in commit message and not
in subject.

On Thu, Dec 06, 2012 at 04:54:52PM +0100, Mohamed wrote:
> 
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>

Why should we add support for notifications on parameters that should not be
changed in real life?

For example "InternetGatewayDevice.DeviceInfo.Manufacturer".

> ---
>  ext/openwrt/scripts/functions/device_info       |   61 +++++++++++++
>  ext/openwrt/scripts/functions/lan_device        |   30 ++++++
>  ext/openwrt/scripts/functions/management_server |  108 
> +++++++++++++++++++++++
>  ext/openwrt/scripts/functions/wan_device        |   37 ++++++++
>  4 files changed, 236 insertions(+), 0 deletions(-)
> 
> diff --git a/ext/openwrt/scripts/functions/device_info 
> b/ext/openwrt/scripts/functions/device_info
> index 5fe2823..08255de 100644
> --- a/ext/openwrt/scripts/functions/device_info
> +++ b/ext/openwrt/scripts/functions/device_info
> @@ -25,6 +25,9 @@ case "$action" in
>       set_value)
>       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
> freecwmp.@device[0].manufacturer="$val"
>       ;;
> +     set_notification)
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;

I think there is a better way to do this then it is proposed in this
patch. I'll look into this.

>  esac
>  }
>  
> @@ -51,6 +54,9 @@ case "$action" in
>       set_value)
>       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
> freecwmp.@device[0].oui="$val"
>       ;;
> +     set_notification)
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -77,6 +83,9 @@ case "$action" in
>       set_value)
>       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
> freecwmp.@device[0].product_class="$val"
>       ;;
> +     set_notification)
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -103,6 +112,9 @@ case "$action" in
>       set_value)
>       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
> freecwmp.@device[0].serial_number="$val"
>       ;;
> +     set_notification)
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -129,6 +141,9 @@ case "$action" in
>       set_value)
>       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
> freecwmp.@device[0].hardware_version="$val"
>       ;;
> +     set_notification)
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -155,6 +170,9 @@ case "$action" in
>       set_value)
>       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
> freecwmp.@device[0].software_version="$val"
>       ;;
> +     set_notification)
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -433,6 +451,41 @@ return $FAULT_CPE_INVALID_PARAMETER_NAME
>  # /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
>  }
>  
> +set_device_info_notification() {
> +case "$1" in
> +     InternetGatewayDevice.DeviceInfo.)
> +     freecwmp_set_parameter_notification "$1" "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +     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
> +# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +}
> +
>  check_parameter_device_info_generic() {
>  case "$1" in
>       InternetGatewayDevice.DeviceInfo.ModelName|\
> @@ -498,3 +551,11 @@ set_device_info_generic() {
>       # /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
>       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"
> +     # /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +     return $FAULT_CPE_NO_FAULT
> +}
> diff --git a/ext/openwrt/scripts/functions/lan_device 
> b/ext/openwrt/scripts/functions/lan_device
> index db90021..a8a94e5 100644
> --- a/ext/openwrt/scripts/functions/lan_device
> +++ b/ext/openwrt/scripts/functions/lan_device
> @@ -44,6 +44,10 @@ case $action in
>       delay_command "wifi" "wifi" "45"
>       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
> wireless.@wifi-device[$num].disabled="$val"
>       ;;
> +     set_notification)
> +     let num=$num+1
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -79,6 +83,10 @@ case $action in
>       delay_command "wifi" "wifi" "45"
>       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
> wireless.@wifi-iface[$num].ssid="$val"
>       ;;
> +     set_notification)
> +     let num=$num+1
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -243,3 +251,25 @@ esac
>  return $FAULT_CPE_INVALID_PARAMETER_NAME
>  # /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
>  }
> +
> +set_lan_device_notification() {
> +case "$1" in
> +     InternetGatewayDevice.LANDevice.|\
> +     InternetGatewayDevice.LANDevice.1.|\
> +     InternetGatewayDevice.LANDevice.1.WLANConfiguration.|\
> +     InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
> +     freecwmp_set_parameter_notification "$1" "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +     InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
> +     set_wlan_enable 0 "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +     InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
> +     set_wlan_ssid 0 "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +esac
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
> +# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +}
> diff --git a/ext/openwrt/scripts/functions/management_server 
> b/ext/openwrt/scripts/functions/management_server
> index 37b1cb0..532addd 100644
> --- a/ext/openwrt/scripts/functions/management_server
> +++ b/ext/openwrt/scripts/functions/management_server
> @@ -58,6 +58,10 @@ case "$action" in
>       
>       ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 inform '{ "event": 
> "value_change" }' &
>       ;;
> +     set_notification)
> +     local val=$1
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -85,6 +89,9 @@ case "$action" in
>       set_value)
>       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
> freecwmp.@acs[0].username="$val"
>       ;;
> +     set_notification)
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -112,6 +119,9 @@ case "$action" in
>       set_value)
>       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
> freecwmp.@acs[0].password="$val"
>       ;;
> +     set_notification)
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -140,6 +150,9 @@ case "$action" in
>       set_value)
>       freecwmp_set_parameter_value "$parm" "$val"
>       ;;
> +     set_notification)
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -168,6 +181,9 @@ case "$action" in
>       set_value)
>       freecwmp_set_parameter_value "$parm" "$val"
>       ;;
> +     set_notification)
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -224,6 +240,9 @@ case "$action" in
>       set_value)
>       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
> freecwmp.@local[0].username="$val"
>       ;;
> +     set_notification)
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -251,6 +270,9 @@ case "$action" in
>       set_value)
>       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
> freecwmp.@local[0].password="$val"
>       ;;
> +     set_notification)
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -284,6 +306,9 @@ case "$action" in
>       set_value)
>       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
> freecwmp.@acs[0].scheme="$val"
>       ;;
> +     set_notification)
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -319,6 +344,9 @@ case "$action" in
>               /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
> freecwmp.@acs[0].hostname="$default_management_server_acs_hostname"
>       fi
>       ;;
> +     set_notification)
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -350,6 +378,9 @@ case "$action" in
>       set_value)
>       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
> freecwmp.@acs[0].port="$val"
>       ;;
> +     set_notification)
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -381,6 +412,9 @@ case "$action" in
>       set_value)
>       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
> freecwmp.@acs[0].path="$val"
>       ;;
> +     set_notification)
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -412,6 +446,9 @@ case "$action" in
>       set_value)
>       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
> freecwmp.@local[0].port="$val"
>       ;;
> +     set_notification)
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -798,6 +835,69 @@ esac
>  return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
>  
> +set_management_server_notification() {
> +case "$1" in
> +     InternetGatewayDevice.ManagementServer.)
> +     freecwmp_set_parameter_notification "$1" "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +     InternetGatewayDevice.ManagementServer.URL)
> +     set_management_server_url "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +     InternetGatewayDevice.ManagementServer.Username)
> +     set_management_server_username "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +     InternetGatewayDevice.ManagementServer.Password)
> +     set_management_server_password "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +     InternetGatewayDevice.ManagementServer.PeriodicInformEnable)
> +     set_management_server_periodic_inform_enable "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +     InternetGatewayDevice.ManagementServer.PeriodicInformInterval)
> +     set_management_server_periodic_inform_interval "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +     InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
> +     set_management_server_connection_request_url "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +     InternetGatewayDevice.ManagementServer.ConnectionRequestUsername)
> +     set_management_server_connection_request_username "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +     InternetGatewayDevice.ManagementServer.ConnectionRequestPassword)
> +     set_management_server_connection_request_password "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +     InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme)
> +     set_management_server_x_freecwmp_org__acs_scheme "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +     InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname)
> +     set_management_server_x_freecwmp_org__acs_hostname "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +     InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port)
> +     set_management_server_x_freecwmp_org__acs_port "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +     InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path)
> +     set_management_server_x_freecwmp_org__acs_path "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +     
> InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port)
> +     set_management_server_x_freecwmp_org__connection_request_port "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +esac
> +# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
> +}
> +
>  check_parameter_management_server_generic() {
>  case "$1" in
>       InternetGatewayDevice.ManagementServer.UpgradesManaged)
> @@ -839,3 +939,11 @@ set_management_server_generic() {
>       # /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
>       return $FAULT_CPE_NO_FAULT
>  }
> +
> +set_management_server_generic_notification() {
> +     check_parameter_management_server_generic "$1" ; _tmp=$? ; if [ "$_tmp" 
> -eq 1 ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
> +
> +     freecwmp_set_parameter_notification "$1" "$2"
> +     # /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +     return $FAULT_CPE_NO_FAULT
> +}
> diff --git a/ext/openwrt/scripts/functions/wan_device 
> b/ext/openwrt/scripts/functions/wan_device
> index c8f1887..7a12eb5 100644
> --- a/ext/openwrt/scripts/functions/wan_device
> +++ b/ext/openwrt/scripts/functions/wan_device
> @@ -105,6 +105,9 @@ case $action in
>               ifup wan &
>       fi
>       ;;
> +     set_notification)
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -132,6 +135,9 @@ case $action in
>       set_value)
>       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
> network.wan.username="$val"
>       ;;
> +     set_notification)
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -159,6 +165,9 @@ case $action in
>       set_value)
>       /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set 
> network.wan.password="$1"
>       ;;
> +     set_notification)
> +     freecwmp_set_parameter_notification "$parm" "$val"
> +     ;;
>  esac
>  }
>  
> @@ -483,3 +492,31 @@ esac
>  # /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
>  return $FAULT_CPE_INVALID_PARAMETER_NAME
>  }
> +
> +set_wan_device_notification() {
> +case "$1" in
> +     InternetGatewayDevice.WANDevice.|\
> +     InternetGatewayDevice.WANDevice.1.|\
> +     InternetGatewayDevice.WANDevice.1.WANConnectionDevice.|\
> +     InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.|\
> +     
> InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.|\
> +     
> InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.)
> +     freecwmp_set_parameter_notification "$1" "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +     
> InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
> +     set_wan_device_wan_ppp_enable "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +     
> InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
> +     set_wan_device_wan_ppp_username "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +     
> InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
> +     set_wan_device_wan_ppp_password "$2"
> +     return $FAULT_CPE_NO_FAULT
> +     ;;
> +esac
> +# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
> +return $FAULT_CPE_INVALID_PARAMETER_NAME
> +}
> -- 
> 1.7.4.1

Luka 

<Prev in Thread] Current Thread [Next in Thread>