freecwmp
[Top] [All Lists]

Re: [PATCH 01/27] add ubus listner get_parameter_values. This listener a

To: mohamed.kallel@pivasoftware.com
Subject: Re: [PATCH 01/27] add ubus listner get_parameter_values. This listener allows to get the freecwmp output from extenal command. Contributed by Inteno Broadband Technology AB
From: Luka Perkov <freecwmp@lukaperkov.net>
Date: Sat, 8 Dec 2012 10:34:12 +0100
Cc: freecwmp@linux-mips.org, ahmed.zribi@pivasoftware.com, freecwmp@lukaperkov.net, jogo@openwrt.org
In-reply-to: <1354809292-2467-2-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-2-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:26PM +0100, Mohamed wrote:
> Signed-off-by: Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>

There is no need to spell ZRIBI so in all patches please change the
above to:

Signed-off-by: Ahmed Zribi <ahmed.zribi@pivasoftware.com>

Or is there a specific reason to spell it ZRIBI?

> Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>

Add your last name to all patches:

Signed-off-by: Mohamed Kallel <mohamed.kallel@pivasoftware.com>

> ---
>  src/external.c |   13 +++++++++++++
>  src/external.h |   10 ++++++++++
>  src/ubus.c     |   42 ++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 65 insertions(+), 0 deletions(-)
> 
> diff --git a/src/external.c b/src/external.c
> index 9ac7b36..c9c768f 100644
> --- a/src/external.c
> +++ b/src/external.c
> @@ -25,6 +25,19 @@
>  #include "freecwmp.h"
>  
>  static struct uloop_process uproc;
> +LIST_HEAD(external_list_parameter);
> +
> +void external_add_list_paramameter(char *param_name, char *param_data, char 
> *param_type, char *fault_code)
> +{
> +     struct external_parameter *external_parameter;
> +     struct list_head *ilist; int i =0;
> +     external_parameter = calloc(1, sizeof(struct external_parameter));
> +     list_add_tail(&external_parameter->list,&external_list_parameter);

Missing space, should be "list, &external_list_parameter".

> +     if (param_name) external_parameter->name = strdup(param_name);
> +     if (param_data) external_parameter->data = strdup(param_data);
> +     if (param_type) external_parameter->type = strdup(param_type);
> +     if (fault_code) external_parameter->fault_code = strdup(fault_code);
> +}
>  
>  int external_get_action(char *action, char *name, char **value)
>  {
> diff --git a/src/external.h b/src/external.h
> index 8606266..64b4c6b 100644
> --- a/src/external.h
> +++ b/src/external.h
> @@ -9,6 +9,7 @@
>  
>  #ifndef _FREECWMP_EXTERNAL_H__
>  #define _FREECWMP_EXTERNAL_H__
> +#include <libubox/list.h>
>  
>  #ifdef DUMMY_MODE
>  static char *fc_script = "./ext/openwrt/scripts/freecwmp.sh";
> @@ -17,11 +18,20 @@ static char *fc_script = "/usr/sbin/freecwmp";
>  #endif
>  static char *fc_script_set_actions = "/tmp/freecwmp_set_action_values.sh";
>  
> +struct external_parameter {
> +     struct list_head list;
> +     char *name;
> +     char *data; /* notification for GetParameterAttribute; writable for 
> GetParameterNames; value for GetParameterValues*/

Make comment above the struct for every element. Use u-boot multiline
comments.

> +     char *type;
> +     char *fault_code;
> +};
> +
>  int external_get_action(char *action, char *name, char **value);
>  int external_set_action_write(char *action, char *name, char *value);
>  int external_set_action_execute();
>  int external_simple(char *arg);
>  int external_download(char *url, char *size);
> +void external_add_list_paramameter(char *param_name, char *param_data, char 
> *param_type, char *fault_code);
>  
>  #endif
>  
> diff --git a/src/ubus.c b/src/ubus.c
> index c10170d..d5437f9 100644
> --- a/src/ubus.c
> +++ b/src/ubus.c
> @@ -16,6 +16,7 @@
>  #include "config.h"
>  #include "cwmp.h"
>  #include "freecwmp.h"
> +#include "external.h"
>  
>  static struct ubus_context *ctx = NULL;
>  static struct ubus_object main_object;
> @@ -157,10 +158,51 @@ freecwmpd_handle_command(struct ubus_context *ctx, 
> struct ubus_object *obj,
>       return 0;
>  }
>  
> +static enum get_param_values {
> +     GET_PARAM_VALUES_PARAM,
> +     GET_PARAM_VALUES_VALUE,
> +     GET_PARAM_VALUES_TYPE,
> +     GET_PARAM_VALUES_FAULT,
> +     __GET_PARAM_VALUES_MAX
> +};
> +
> +static const struct blobmsg_policy get_param_values_policy[] = {
> +     [GET_PARAM_VALUES_PARAM] = { .name = "parameter", .type = 
> BLOBMSG_TYPE_STRING },
> +     [GET_PARAM_VALUES_VALUE] = { .name = "value", .type = 
> BLOBMSG_TYPE_STRING },
> +     [GET_PARAM_VALUES_TYPE] = { .name = "type", .type = BLOBMSG_TYPE_STRING 
> },
> +     [GET_PARAM_VALUES_FAULT] = { .name = "fault_code", .type = 
> BLOBMSG_TYPE_STRING },
> +};
> +
> +static int
> +freecwmpd_handle_get_param_values(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_VALUES_MAX];
> +
> +     blobmsg_parse(get_param_values_policy, 
> ARRAY_SIZE(get_param_values_policy), tb,
> +                   blob_data(msg), blob_len(msg));
> +
> +     if (!tb[GET_PARAM_VALUES_PARAM])
> +             return UBUS_STATUS_INVALID_ARGUMENT;
> +
> +     freecwmp_log_message(NAME, L_NOTICE,
> +                          "triggered ubus get_parameter_values for the 
> parameter %s\n",
> +                          blobmsg_data(tb[GET_PARAM_VALUES_PARAM]));
> +
> +     external_add_list_paramameter(blobmsg_data(tb[GET_PARAM_VALUES_PARAM]),
> +                     tb[GET_PARAM_VALUES_VALUE]? 
> blobmsg_data(tb[GET_PARAM_VALUES_VALUE]) : NULL,

Add missing space before char "?".

> +                     tb[GET_PARAM_VALUES_TYPE]? 
> blobmsg_data(tb[GET_PARAM_VALUES_TYPE]) : "xsd:string",

Add missing space before char "?".

> +                     tb[GET_PARAM_VALUES_FAULT]? 
> blobmsg_data(tb[GET_PARAM_VALUES_FAULT]) : NULL);

Add missing space before char "?".

> +
> +     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),
>  };
>  
>  static struct ubus_object_type main_object_type =
> -- 
> 1.7.4.1

Luka 

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