Hi Luka
As agreed, please find following the patch(s) updated (with your remarks).
As said before theses patches contains:
- communication from script to the core via ubus
- GetParameterValues method supporting many parameters
- GetParameterNames method added
Regards
Mohamed KALLEL
------------------------ubus_data_model.patch---------------------------------
>From 18e2d931a89158a69e7f25705dbf2dbb1f41d3fd Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Fri, 30 Nov 2012 18:33:01 +0100
Subject: [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
Signed-off-by: Mohamed <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);
+ 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*/
+ 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,
+ tb[GET_PARAM_VALUES_TYPE]?
blobmsg_data(tb[GET_PARAM_VALUES_TYPE]) : "xsd:string",
+ tb[GET_PARAM_VALUES_FAULT]?
blobmsg_data(tb[GET_PARAM_VALUES_FAULT]) : NULL);
+
+ 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
>From 5f74d7947e48e1d3d140f5842cbad955d0686a7e Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Fri, 30 Nov 2012 18:37:07 +0100
Subject: [PATCH 02/27] get_parameter values handler from xml is
supporting many parameters from external ubus output
Contributed by Inteno Broadband Technology AB && PIVA SOFTWARE
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
bin/Makefile.am | 3 +-
configure.ac | 3 ++
src/external.c | 95
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/external.h | 6 +++-
src/freecwmp.c | 17 ++++++++++
src/xml.c | 66 +++++++++++++++++++++++--------------
6 files changed, 163 insertions(+), 27 deletions(-)
diff --git a/bin/Makefile.am b/bin/Makefile.am
index 78cb111..ac96905 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -48,5 +48,6 @@ freecwmpd_LDADD = \
$(LIBUBUS_LIBS) \
$(MICROXML_LIBS) \
$(LIBCURL_LIBS) \
- $(LIBZSTREAM_LIBS)
+ $(LIBZSTREAM_LIBS) \
+ $(LIBPTHREAD_LIBS)
diff --git a/configure.ac b/configure.ac
index c646c3a..38d3df4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,6 +80,9 @@ AC_SUBST([LIBUBUS_LDFLAGS])
LIBUBUS_LIBS='-lubus'
AC_SUBST([LIBUBUS_LIBS])
+LIBPTHREAD_LIBS='-lpthread'
+AC_SUBST([LIBPTHREAD_LIBS])
+
AM_COND_IF([HTTP_CURL], [
AC_DEFINE(HTTP_CURL)
PKG_CHECK_MODULES(LIBCURL, [libcurl])
diff --git a/src/external.c b/src/external.c
index c9c768f..94ae9b8 100644
--- a/src/external.c
+++ b/src/external.c
@@ -25,8 +25,15 @@
#include "freecwmp.h"
static struct uloop_process uproc;
+pthread_t ubus_thread;
LIST_HEAD(external_list_parameter);
+void *thread_uloop_run (void *v)
+{
+ uloop_run();
+ return NULL;
+}
+
void external_add_list_paramameter(char *param_name, char *param_data,
char *param_type, char *fault_code)
{
struct external_parameter *external_parameter;
@@ -39,6 +46,20 @@ void external_add_list_paramameter(char *param_name,
char *param_data, char *par
if (fault_code) external_parameter->fault_code = strdup(fault_code);
}
+void external_free_list_parameter()
+{
+ struct external_parameter *external_parameter;
+ while (external_list_parameter.next!=&external_list_parameter) {
+ external_parameter = list_entry(external_list_parameter.next,
struct external_parameter, list);
+ list_del(&external_parameter->list);
+ free(external_parameter->name);
+ free(external_parameter->data);
+ free(external_parameter->type);
+ free(external_parameter->fault_code);
+ free(external_parameter);
+ }
+}
+
int external_get_action(char *action, char *name, char **value)
{
freecwmp_log_message(NAME, L_NOTICE,
@@ -121,6 +142,80 @@ error:
return -1;
}
+int external_get_action_write(char *action, char *name, char *arg)
+{
+ freecwmp_log_message(NAME, L_NOTICE,
+ "adding to get %s script '%s'\n", action, name);
+
+ FILE *fp;
+
+ if (access(fc_script_get_actions, R_OK | W_OK | X_OK) != -1) {
+ fp = fopen(fc_script_get_actions, "a");
+ if (!fp) return -1;
+ } else {
+ fp = fopen(fc_script_get_actions, "w");
+ if (!fp) return -1;
+
+ fprintf(fp, "#!/bin/sh\n");
+
+ if (chmod(fc_script_get_actions,
+ strtol("0700", 0, 8)) < 0) {
+ return -1;
+ }
+ }
+
+#ifdef DUMMY_MODE
+ fprintf(fp, "/bin/sh `pwd`/%s get %s %s %s\n", fc_script, action,
name, arg?arg:"");
+#else
+ fprintf(fp, "/bin/sh %s get %s %s %s\n", fc_script, action, name,
arg?arg:"");
+#endif
+
+ fclose(fp);
+
+ return 0;
+}
+
+int external_get_action_execute()
+{
+ freecwmp_log_message(NAME, L_NOTICE, "executing get script\n");
+
+ pthread_create(&ubus_thread, NULL, &thread_uloop_run, NULL);
+
+ if ((uproc.pid = fork()) == -1) {
+ return -1;
+ }
+
+ if (uproc.pid == 0) {
+ /* child */
+
+ const char *argv[3];
+ int i = 0;
+ argv[i++] = "/bin/sh";
+ argv[i++] = fc_script_get_actions;
+ argv[i++] = NULL;
+
+ execvp(argv[0], (char **) argv);
+ exit(ESRCH);
+
+ } else if (uproc.pid < 0)
+ return -1;
+
+ /* parent */
+ int status;
+ while (wait(&status) != uproc.pid) {
+ DD("waiting for child to exit");
+ }
+
+ pthread_cancel(ubus_thread);
+ pthread_join(ubus_thread,NULL);
+
+ // TODO: add some kind of checks
+
+ remove(fc_script_get_actions);
+
+ return 0;
+}
+
int external_set_action_write(char *action, char *name, char *value)
{
freecwmp_log_message(NAME, L_NOTICE,
diff --git a/src/external.h b/src/external.h
index 64b4c6b..c6df2ea 100644
--- a/src/external.h
+++ b/src/external.h
@@ -16,7 +16,8 @@ static char *fc_script =
"./ext/openwrt/scripts/freecwmp.sh";
#else
static char *fc_script = "/usr/sbin/freecwmp";
#endif
-static char *fc_script_set_actions = "/tmp/freecwmp_set_action_values.sh";
+static char *fc_script_set_actions = "/tmp/freecwmp_set_action.sh";
+static char *fc_script_get_actions = "/tmp/freecwmp_get_action.sh";
struct external_parameter {
struct list_head list;
@@ -27,11 +28,14 @@ struct external_parameter {
};
int external_get_action(char *action, char *name, char **value);
+int external_get_action_write(char *action, char *name, char *arg);
+int external_get_action_execute();
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);
+void external_free_list_parameter();
#endif
diff --git a/src/freecwmp.c b/src/freecwmp.c
index 4ef8395..f4c9cb1 100644
--- a/src/freecwmp.c
+++ b/src/freecwmp.c
@@ -18,6 +18,7 @@
#include <arpa/inet.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
+#include <signal.h>
#include <libfreecwmp.h>
#include <libubox/uloop.h>
@@ -194,11 +195,27 @@ netlink_init(void)
return 0;
}
+void signal_kill_all_handler(int sig)
+{
+ pthread_exit(NULL);
+}
+
+
+
int main (int argc, char **argv)
{
freecwmp_log_message(NAME, L_NOTICE, "daemon started\n");
bool foreground = false;
+ struct sigaction sigint_action;
+
+ sigint_action.sa_handler = &signal_kill_all_handler;
+ sigemptyset (&sigint_action.sa_mask);
+ /* reset handler in case when pthread_cancel didn't stop
+ threads for some reason */
+ sigint_action.sa_flags = SA_RESETHAND;
+ sigaction(SIGTERM, &sigint_action, NULL);
+
setlocale(LC_CTYPE, "");
umask(0037);
diff --git a/src/xml.c b/src/xml.c
index 9fa036b..23b9ec7 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -21,6 +21,8 @@
#include "messages.h"
#include "time.h"
+extern struct list_head external_list_parameter;
+
struct rpc_method {
const char *name;
int (*handler)(mxml_node_t *body_in, mxml_node_t *tree_in,
@@ -628,10 +630,11 @@ int xml_handle_get_parameter_values(mxml_node_t
*body_in,
mxml_node_t *tree_in,
mxml_node_t *tree_out)
{
- mxml_node_t *n, *b = body_in;
+ mxml_node_t *n, *parameter_list, *b = body_in;
+ struct external_parameter *external_parameter;
char *parameter_name = NULL;
char *parameter_value = NULL;
- char *c;
+ char *c=NULL;
int counter = 0;
n = mxmlFindElement(tree_out, tree_out, "soap_env:Body",
@@ -655,29 +658,47 @@ int xml_handle_get_parameter_values(mxml_node_t
*body_in,
!strcmp(b->parent->value.element.name, "string")) {
parameter_name = b->value.text.string;
}
-
+ if (b && b->type == MXML_ELEMENT && /* added in order to
support GetParameterValues with empty string*/
+ !strcmp(b->value.element.name, "string") &&
+ !b->child) {
+ parameter_name = "";
+ }
if (parameter_name) {
if (!config_get_cwmp(parameter_name, ¶meter_value)) {
+
external_add_list_paramameter(parameter_name,parameter_value,"xsd:string",NULL);
+ FREE(parameter_value);
// got the parameter value using libuci
- } else if (!external_get_action("value",
- parameter_name, ¶meter_value)) {
+ } else if
(!external_get_action_write("value",parameter_name, NULL)) {
// got the parameter value via external script
} else {
// error occurred when getting parameter value
goto out;
}
- counter++;
+ }
+ b = mxmlWalkNext(b, body_in, MXML_DESCEND);
+ parameter_name = NULL;
+ }
- n = mxmlFindElement(tree_out, tree_out, "ParameterList",
NULL, NULL, MXML_DESCEND);
- if (!n) goto out;
+ if (external_get_action_execute())
+ goto out;
+
+ parameter_list = mxmlFindElement(tree_out, tree_out,
"ParameterList", NULL, NULL, MXML_DESCEND);
+ if (!parameter_list) goto out;
+
+ while (external_list_parameter.next!=&external_list_parameter) {
+
+ external_parameter = list_entry(external_list_parameter.next,
struct external_parameter, list);
- n = mxmlNewElement(n, "ParameterValueStruct");
+ if (external_parameter->fault_code &&
external_parameter->fault_code[0]=='9')
+ goto out; // KMD TODO return FAULT message the fault code
is in ->fault_code
+
+ n = mxmlNewElement(parameter_list, "ParameterValueStruct");
if (!n) goto out;
n = mxmlNewElement(n, "Name");
if (!n) goto out;
- n = mxmlNewText(n, 0, parameter_name);
+ n = mxmlNewText(n, 0, external_parameter->name);
if (!n) goto out;
n = n->parent->parent;
@@ -685,23 +706,19 @@ int xml_handle_get_parameter_values(mxml_node_t
*body_in,
if (!n) goto out;
#ifdef ACS_MULTI
- mxmlElementSetAttr(n, "xsi:type", "xsd:string");
+ mxmlElementSetAttr(n, "xsi:type", external_parameter->type);
#endif
- n = mxmlNewText(n, 0, parameter_value ? parameter_value : "");
+ n = mxmlNewText(n, 0, external_parameter->data?
external_parameter->data : "");
if (!n) goto out;
- /*
- * three day's work to finally find memory leak if we
- * free parameter_name;
- * it points to: b->value.text.string
- *
- * also, parameter_value can be NULL so we don't do checks
- */
- parameter_name = NULL;
- }
+ counter++;
- FREE(parameter_value);
- b = mxmlWalkNext(b, body_in, MXML_DESCEND);
+ list_del(&external_parameter->list);
+ free(external_parameter->name);
+ free(external_parameter->data);
+ free(external_parameter->type);
+ free(external_parameter->fault_code);
+ free(external_parameter);
}
#ifdef ACS_MULTI
@@ -716,11 +733,10 @@ int xml_handle_get_parameter_values(mxml_node_t
*body_in,
FREE(c);
#endif
- FREE(parameter_value);
return 0;
out:
- FREE(parameter_value);
+ external_free_list_parameter();
return -1;
}
--
1.7.4.1
>From 9efe02b6ae49b65b6103f4f41dec23a260626e40 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 20:55:52 +0100
Subject: [PATCH 03/27] add in the scripts the functions needed to
communicate data to ubus handler for the get_parameter_values ubus handler
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
ext/openwrt/scripts/freecwmp.sh | 51
++++++++++++++++++++++++++++------
ext/openwrt/scripts/functions/common | 23 +++++++++++++++
2 files changed, 65 insertions(+), 9 deletions(-)
diff --git a/ext/openwrt/scripts/freecwmp.sh
b/ext/openwrt/scripts/freecwmp.sh
index ccab19f..f2bebc8 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -113,21 +113,54 @@ handle_scripts() {
config_load freecwmp
config_foreach handle_scripts "scripts"
+# Fault code
+
+FAULT_CPE_NO_FAULT="0"
+FAULT_CPE_REQUEST_DENIED="1"
+FAULT_CPE_INTERNAL_ERROR="2"
+FAULT_CPE_INVALID_ARGUMENTS="3"
+FAULT_CPE_RESOURCES_EXCEEDED="4"
+FAULT_CPE_INVALID_PARAMETER_NAME="5"
+FAULT_CPE_INVALID_PARAMETER_TYPE="6"
+FAULT_CPE_INVALID_PARAMETER_VALUE="7"
+FAULT_CPE_NON_WRITABLE_PARAMETER="8"
+FAULT_CPE_NOTIFICATION_REJECTED="9"
+FAULT_CPE_DOWNLOAD_FAILURE="10"
+FAULT_CPE_UPLOAD_FAILURE="11"
+FAULT_CPE_FILE_TRANSFER_AUTHENTICATION_FAILURE="12"
+FAULT_CPE_FILE_TRANSFER_UNSUPPORTED_PROTOCOL="13"
+FAULT_CPE_DOWNLOAD_FAIL_MULTICAST_GROUP="14"
+FAULT_CPE_DOWNLOAD_FAIL_CONTACT_SERVER="15"
+FAULT_CPE_DOWNLOAD_FAIL_ACCESS_FILE="16"
+FAULT_CPE_DOWNLOAD_FAIL_COMPLETE_DOWNLOAD="17"
+FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED="18"
+FAULT_CPE_DOWNLOAD_FAIL_FILE_AUTHENTICATION="19"
+
if [ "$action" = "get_value" -o "$action" = "get_all" ]; then
- if [ ${FLAGS_force} -eq ${FLAGS_FALSE} ]; then
- __tmp_arg="Device."
- # TODO: don't check only string length ; but this is only used
- # for getting correct prefix of CWMP parameter anyway
- if [ ${#__arg1} -lt ${#__tmp_arg} ]; then
- echo "CWMP parameters usualy begin with
'InternetGatewayDevice.' or 'Device.' "
- echo "if you want to force script execution with provided
parameter use '-f' flag."
- exit -1
- fi
+ no_fault="0"
+ freecwmp_check_fault "$__arg1"
+ fault_code="$?"
+ if [ "$fault_code" = "0" ]; then
+ if [ \( "$__arg1" = "InternetGatewayDevice." \) -o \( "$__arg1"
= "" \) ]; then
+ __arg1="InternetGatewayDevice."
fi
for function_name in $get_value_functions
do
$function_name "$__arg1"
+ fault_code="$?"
+ if [ "$fault_code" = "0" ]; then
+ no_fault="1"
+ fi
+ if [ "$fault_code" = "$FAULT_CPE_INVALID_ARGUMENTS" ]; then
+ break
+ fi
done
+ if [ "$no_fault" = "1" ]; then fault_code="0"; fi
+ fi
+ if [ "$fault_code" != "0" ]; then
+ let fault_code=$fault_code+9000
+ ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
+ fi
fi
if [ "$action" = "set_value" ]; then
diff --git a/ext/openwrt/scripts/functions/common
b/ext/openwrt/scripts/functions/common
index 7e3000a..082e067 100644
--- a/ext/openwrt/scripts/functions/common
+++ b/ext/openwrt/scripts/functions/common
@@ -34,6 +34,22 @@ if [ -n "$value" -o ${FLAGS_empty} -eq ${FLAGS_TRUE}
]; then
fi
}
+ubus_freecwmp_output() {
+local parameter="$1"
+local value="$2"
+local type="$3"
+local fault_code="$4"
+
+if [ "$type" = "" ]; then
+ type="xsd:string"
+fi
+
+case "$action" in
+ get_value)
+ ubus call tr069 get_parameter_values '{"parameter": "'$parameter'",
"value": "'$value'", "type": "'$type'", "fault_code":"'$fault_code'"}'
2> /dev/null
+ ;;
+esac
+}
freecwmp_value_output() {
freecwmp_output "$1" "$2" "V"
}
@@ -249,3 +265,10 @@ EOF
sh "$lock" &
fi
}
+
+freecwmp_check_fault() {
+if [ "$1" = "." ]; then
+ return $FAULT_CPE_INVALID_PARAMETER_NAME
+fi
+return $FAULT_CPE_NO_FAULT
+}
--
1.7.4.1
>From 9f3c3bea934e079853aed0ac27d91fb1bbe115d5 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 20:59:14 +0100
Subject: [PATCH 04/27] Update device_hosts to support communicte data of
get parameter values to the core via ubus
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
ext/openwrt/scripts/functions/device_hosts | 22 +++++++++++-----------
1 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/ext/openwrt/scripts/functions/device_hosts
b/ext/openwrt/scripts/functions/device_hosts
index 4c3fcd4..8909df6 100644
--- a/ext/openwrt/scripts/functions/device_hosts
+++ b/ext/openwrt/scripts/functions/device_hosts
@@ -44,7 +44,7 @@ local parameter=`echo -n $1 | sed
"s/InternetGatewayDevice\.LANDevice\.1\./Devic
case "$parameter" in
Device.Hosts.HostNumberOfEntries)
let local val=$num_static_leases+$num_dynamic_leases
- freecwmp_output "$parameter" "$val"
+ ubus_freecwmp_output "$parameter" "$val"
return
;;
esac
@@ -66,7 +66,7 @@ if [ $rc -eq 0 ]; then
local sed_cmd=`echo -n \'$num; echo p\'`
val=`eval sed -n $sed_cmd $leases_file | awk '{ print $2 }'`
fi
- freecwmp_value_output "$parameter" "$val"
+ ubus_freecwmp_output "$parameter" "$val"
return
fi
@@ -74,7 +74,7 @@ freecwmp_parse_formated_parameter "$parameter"
"Device.Hosts.Host.{i}.IPAddress"
if [ $rc -eq 0 ]; then
local val
get_device_hosts_ip_address "$leases_file" "$num"
"$num_static_leases" "$num_dynamic_leases" "val"
- freecwmp_value_output "$parameter" "$val"
+ ubus_freecwmp_output "$parameter" "$val"
return
fi
@@ -88,7 +88,7 @@ if [ $rc -eq 0 ]; then
if [ $num -gt 0 -a $num -le $num_dynamic_leases ]; then
val="DHCP"
fi
- freecwmp_value_output "$parameter" "$val"
+ ubus_freecwmp_output "$parameter" "$val"
return
fi
@@ -107,7 +107,7 @@ if [ $rc -eq 0 ]; then
local t2=`date +%s`
let val=$t1-$t2
fi
- freecwmp_value_output "$parameter" "$val"
+ ubus_freecwmp_output "$parameter" "$val"
return
fi
@@ -131,7 +131,7 @@ if [ $rc -eq 0 ]; then
val=`eval sed -n $sed_cmd $leases_file | awk '{ print $4 }'`
if [ "x$val" == "x*" ]; then val=""; fi
fi
- freecwmp_value_output "$parameter" "$val"
+ ubus_freecwmp_output "$parameter" "$val"
return
fi
@@ -144,7 +144,7 @@ if [ $rc -eq 0 ]; then
get_device_hosts_ip_address "$leases_file" "$num"
"$num_static_leases" "$num_dynamic_leases" "ip"
val=`ping -c 1 $ip 2>&1 > /dev/null ; echo $?`
let val=!$val
- freecwmp_value_output "$parameter" "$val"
+ ubus_freecwmp_output "$parameter" "$val"
return
fi
@@ -156,7 +156,7 @@ if [ $rc -eq 0 ]; then
if [ $num -le $n ]; then
val=1
fi
- freecwmp_value_output "$parameter" "$val"
+ ubus_freecwmp_output "$parameter" "$val"
return
fi
@@ -168,7 +168,7 @@ if [ $rc -eq 0 ]; then
if [ $num -le $n ]; then
val=0
fi
- freecwmp_value_output "$parameter" "$val"
+ ubus_freecwmp_output "$parameter" "$val"
return
fi
@@ -182,10 +182,10 @@ if [ $rc -eq 0 ]; then
if [ $num2 -eq 1 ]; then
get_device_hosts_ip_address "$leases_file" "$num1"
"$num_static_leases" "$num_dynamic_leases" "val"
fi
- freecwmp_value_output "$parameter" "$val"
+ ubus_freecwmp_output "$parameter" "$val"
return
fi
# TODO: Device.Hosts.Host.{i}.IPv6Address.{i}.IPAddress (no IPv6
support yet)
-
+return $FAULT_CPE_INVALID_PARAMETER_NAME
}
--
1.7.4.1
>From b61d8e55d0ef3de480a78fa088b126d5b38db152 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:01:31 +0100
Subject: [PATCH 05/27] Update device_info script to support communicte
data of get parameter values to the core via ubus
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
ext/openwrt/scripts/functions/device_info | 32
+++++++++++++++++++---------
1 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/ext/openwrt/scripts/functions/device_info
b/ext/openwrt/scripts/functions/device_info
index 4423b8b..86ff5c9 100644
--- a/ext/openwrt/scripts/functions/device_info
+++ b/ext/openwrt/scripts/functions/device_info
@@ -3,7 +3,7 @@
get_device_info_manufacturer() {
local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@device[0].manufacturer 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"
}
set_device_info_manufacturer() {
@@ -12,7 +12,7 @@ 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`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ManufacturerOUI"
"$val"
}
set_device_info_oui() {
@@ -21,7 +21,7 @@ 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`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass"
"$val"
}
set_device_info_product_class() {
@@ -30,7 +30,7 @@ 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`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber" "$val"
}
set_device_info_serial_number() {
@@ -39,7 +39,7 @@ 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`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.HardwareVersion"
"$val"
}
set_device_info_hardware_version() {
@@ -48,7 +48,7 @@ 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`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion"
"$val"
}
set_device_info_software_version() {
@@ -57,7 +57,7 @@ set_device_info_software_version() {
get_device_info_uptime() {
local val=`cat /proc/uptime | awk -F "." '{ print $1 }'`
-freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val"
}
get_device_info_device_log() {
@@ -67,7 +67,7 @@ if [ ${FLAGS_last} -eq ${FLAGS_TRUE} ]; then
else
val=`dmesg | tail -n10`
fi
-freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val"
}
get_device_info() {
@@ -81,6 +81,7 @@ case "$1" in
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
@@ -91,32 +92,42 @@ case "$1" in
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() {
@@ -161,10 +172,11 @@ return 1
}
get_device_info_generic() {
- check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp"
-eq 1 ]; then return 0; fi
+ 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_value_output "$1" "$val"
+ ubus_freecwmp_output "$1" "$val"
+ return $FAULT_CPE_NO_FAULT
}
set_device_info_generic() {
--
1.7.4.1
>From 91e36ad7421668100895447e65a4fedfba208b33 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:04:01 +0100
Subject: [PATCH 06/27] Update device_routing script to support
communicte data of get parameter values to the core via ubus
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
ext/openwrt/scripts/functions/device_routing | 33
+++++++++++++------------
1 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/ext/openwrt/scripts/functions/device_routing
b/ext/openwrt/scripts/functions/device_routing
index 3dfa418..ca6dab1 100644
--- a/ext/openwrt/scripts/functions/device_routing
+++ b/ext/openwrt/scripts/functions/device_routing
@@ -85,7 +85,7 @@ local parameter=$1
case "$parameter" in
Device.Routing.RouterNumberOfEntries)
- freecwmp_output "$parameter" "1"
+ ubus_freecwmp_output "$parameter" "1"
return
;;
esac
@@ -101,7 +101,7 @@ if [ $rc -eq 0 ]; then
else
val="0"
fi
- freecwmp_output "$parameter" "$val"
+ ubus_freecwmp_output "$parameter" "$val"
return
fi
@@ -113,7 +113,7 @@ if [ $rc -eq 0 ]; then
else
val="Disabled"
fi
- freecwmp_output "$parameter" "$val"
+ ubus_freecwmp_output "$parameter" "$val"
return
fi
@@ -134,7 +134,7 @@ if [ $rc -eq 0 ]; then
else
return
fi
- freecwmp_output "$parameter" "$total"
+ ubus_freecwmp_output "$parameter" "$total"
return
fi
@@ -146,7 +146,7 @@ if [ $rc -eq 0 ]; then
else
return
fi
- freecwmp_output "$parameter" "$val"
+ ubus_freecwmp_output "$parameter" "$val"
return
fi
@@ -166,15 +166,15 @@ if [ $rc -eq 0 ]; then
return
fi
if [ $num2 -gt $static ]; then
- freecwmp_output "$parameter" "Enabled"
+ ubus_freecwmp_output "$parameter" "Enabled"
return
fi
if [ $num2 -le $inactive ]; then
- freecwmp_output "$parameter" "Error: not active but enabled"
+ ubus_freecwmp_output "$parameter" "Error: not active but
enabled"
return
fi
if [ $num2 -le $static ]; then
- freecwmp_output "$parameter" "Enabled"
+ ubus_freecwmp_output "$parameter" "Enabled"
return
fi
else
@@ -197,11 +197,11 @@ if [ $rc -eq 0 ]; then
return
fi
if [ $num2 -gt $static ]; then
- freecwmp_output "$parameter" "0"
+ ubus_freecwmp_output "$parameter" "0"
return
fi
if [ $num2 -le $static ]; then
- freecwmp_output "$parameter" "1"
+ ubus_freecwmp_output "$parameter" "1"
return
fi
else
@@ -230,7 +230,7 @@ if [ $rc -eq 0 ]; then
let local i=$static-$num2
target=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR}
get network.@route[$i].target 2> /dev/null`
fi
- freecwmp_output "$parameter" "$target"
+ ubus_freecwmp_output "$parameter" "$target"
return
else
return
@@ -258,7 +258,7 @@ if [ $rc -eq 0 ]; then
let local i=$static-$num2
netmask=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR}
get network.@route[$i].netmask 2> /dev/null`
fi
- freecwmp_output "$parameter" "$netmask"
+ ubus_freecwmp_output "$parameter" "$netmask"
return
else
return
@@ -288,7 +288,7 @@ if [ $rc -eq 0 ]; then
let local i=$static-$num2
gateway=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR}
get network.@route[$i].gateway 2> /dev/null`
fi
- freecwmp_output "$parameter" "$gateway"
+ ubus_freecwmp_output "$parameter" "$gateway"
return
else
return
@@ -315,7 +315,7 @@ if [ $rc -eq 0 ]; then
elif [ $num2 -le $static ]; then
val="Static"
fi
- freecwmp_output "$parameter" "$val"
+ ubus_freecwmp_output "$parameter" "$val"
return
else
return
@@ -343,11 +343,12 @@ if [ $rc -eq 0 ]; then
let local i=$static-$num2
metric=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR}
get network.@route[$i].metric 2> /dev/null`
fi
- freecwmp_output "$parameter" "$metric"
+ ubus_freecwmp_output "$parameter" "$metric"
return
else
return
fi
fi
-
+return $FAULT_CPE_INVALID_PARAMETER_NAME
}
+
--
1.7.4.1
>From 33dbf86bc1acdb5b12589225de0fa1c79c51627b Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:05:26 +0100
Subject: [PATCH 07/27] Update device_users script to support communicte
data of get parameter values to the core via ubus
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
ext/openwrt/scripts/functions/device_users | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/ext/openwrt/scripts/functions/device_users
b/ext/openwrt/scripts/functions/device_users
index 0d377f7..d8dba61 100644
--- a/ext/openwrt/scripts/functions/device_users
+++ b/ext/openwrt/scripts/functions/device_users
@@ -6,7 +6,7 @@ local parameter="$1"
case "$parameter" in
Device.Users.UserNumberOfEntries)
local val=`wc -l /etc/passwd | awk '{ print $1 }'`
- freecwmp_value_output "$parameter" "$val"
+ ubus_freecwmp_output "$parameter" "$val"
return
;;
esac
@@ -21,7 +21,7 @@ if [ $rc -eq 0 ]; then
# TODO: this is very system dependent, for now just look at users
shell
local sed_cmd=`echo -n \'$num; echo p\'`
local val=`eval sed -n $sed_cmd /etc/passwd | grep -v '/bin/false'
| wc -l`
- freecwmp_value_output "$parameter" "$val"
+ ubus_freecwmp_output "$parameter" "$val"
return
fi
@@ -30,7 +30,7 @@ if [ $rc -eq 0 ]; then
# TODO: this is very system dependent, for now just look at users
shell
local sed_cmd=`echo -n \'$num; echo p\'`
local val=`eval sed -n $sed_cmd /etc/passwd | grep -v '/bin/false'
| wc -l`
- freecwmp_value_output "$parameter" "$val"
+ ubus_freecwmp_output "$parameter" "$val"
return
fi
@@ -38,7 +38,7 @@ freecwmp_parse_formated_parameter "$parameter"
"Device.Users.User.{i}.Username"
if [ $rc -eq 0 ]; then
local sed_cmd=`echo -n \'$num; echo p\'`
local val=`eval sed -n $sed_cmd /etc/passwd | awk -F ':' '{ print
$1 }'`
- freecwmp_value_output "$parameter" "$val"
+ ubus_freecwmp_output "$parameter" "$val"
return
fi
@@ -48,15 +48,16 @@ if [ $rc -eq 0 ]; then
# local sed_cmd=`echo -n \'$num; echo p\'`
# local val=`eval sed -n $sed_cmd /etc/shadow | awk -F ':' '{
print $2 }'`
# freecwmp_value_output "$parameter" "$val"
- freecwmp_value_output "$parameter" ""
+ ubus_freecwmp_output "$parameter" ""
return
fi
freecwmp_parse_formated_parameter "$parameter"
"Device.Users.User.{i}.Language" "rc" "num"
if [ $rc -eq 0 ]; then
- freecwmp_value_output "$parameter" ""
+ ubus_freecwmp_output "$parameter" ""
return
fi
+return $FAULT_CPE_INVALID_PARAMETER_NAME
}
set_device_users() {
--
1.7.4.1
>From 5d2f27eaebb4c5762a915b428b3d11e1ce6d2cff Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:07:28 +0100
Subject: [PATCH 08/27] Update lan_device script to support communicte
data of get parameter values to the core via ubus
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
ext/openwrt/scripts/functions/lan_device | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/ext/openwrt/scripts/functions/lan_device
b/ext/openwrt/scripts/functions/lan_device
index 5ba513c..fa9dda4 100644
--- a/ext/openwrt/scripts/functions/lan_device
+++ b/ext/openwrt/scripts/functions/lan_device
@@ -3,6 +3,7 @@
get_wlan_enable() {
local num="$1"
+local type="xsd:boolean"
local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
wireless.@wifi-device[$num].disabled 2> /dev/null`
let num=$num+1
if [ "$val" = "1" ]; then
@@ -10,7 +11,7 @@ if [ "$val" = "1" ]; then
else
val="1"
fi
-freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
+ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
"$type"
}
set_wlan_enable() {
@@ -29,7 +30,7 @@ get_wlan_ssid() {
local num="$1"
local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
wireless.@wifi-iface[$num].ssid 2> /dev/null`
let num=$num+1
-freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
+ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
}
set_wlan_ssid() {
@@ -44,30 +45,38 @@ case "$1" in
InternetGatewayDevice.)
get_wlan_enable 0
get_wlan_ssid 0
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.LANDevice.)
get_wlan_enable 0
get_wlan_ssid 0
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.LANDevice.1.)
get_wlan_enable 0
get_wlan_ssid 0
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.LANDevice.1.WLANConfiguration.)
get_wlan_enable 0
get_wlan_ssid 0
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
get_wlan_enable 0
get_wlan_ssid 0
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
get_wlan_enable 0
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
get_wlan_ssid 0
+ return $FAULT_CPE_NO_FAULT
;;
esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
}
set_lan_device() {
--
1.7.4.1
>From 7b88e2ac25543be6c319822d96ae379395f55fc3 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:09:08 +0100
Subject: [PATCH 09/27] Update management_server script to support
communicte data of get parameter values to the core via ubus
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
ext/openwrt/scripts/functions/management_server | 72
++++++++++++++++++-----
1 files changed, 57 insertions(+), 15 deletions(-)
diff --git a/ext/openwrt/scripts/functions/management_server
b/ext/openwrt/scripts/functions/management_server
index 9d1447e..eca3a61 100644
--- a/ext/openwrt/scripts/functions/management_server
+++ b/ext/openwrt/scripts/functions/management_server
@@ -10,7 +10,7 @@ local
port=`get_management_server_x_freecwmp_org__acs_port`
local path=`get_management_server_x_freecwmp_org__acs_path`
FLAGS_value=$tmp
local val=`echo $scheme://$hostname:$port$path`
-freecwmp_output "InternetGatewayDevice.ManagementServer.URL" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.URL" "$val"
}
set_management_server_url() {
@@ -46,7 +46,7 @@ ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 inform
'{ "event": "value_change
get_management_server_username() {
local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@acs[0].username 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.ManagementServer.Username" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.Username"
"$val"
}
set_management_server_username() {
@@ -55,7 +55,7 @@ set_management_server_username() {
get_management_server_password() {
local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@acs[0].password 2> /dev/null`
-freecwmp_output "InternetGatewayDevice.ManagementServer.Password" "$val"
+ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.Password"
"$val"
}
set_management_server_password() {
@@ -65,7 +65,7 @@ set_management_server_password() {
get_management_server_periodic_inform_enable() {
local parm="InternetGatewayDevice.ManagementServer.PeriodicInformEnable"
freecwmp_get_parameter_value "val" "$parm"
-freecwmp_output "$parm" "$val"
+ubus_freecwmp_output "$parm" "$val" "xsd:boolean"
}
set_management_server_periodic_inform_enable() {
@@ -76,7 +76,7 @@ freecwmp_set_parameter_value "$parm" "$1"
get_management_server_periodic_inform_interval() {
local parm="InternetGatewayDevice.ManagementServer.PeriodicInformInterval"
freecwmp_get_parameter_value "val" "$parm"
-freecwmp_output "$parm" "$val"
+ubus_freecwmp_output "$parm" "$val" "xsd:unsingedInt"
}
set_management_server_periodic_inform_interval() {
@@ -100,12 +100,12 @@ else
val=$default_management_server_connection_request_url
fi
-freecwmp_output
"InternetGatewayDevice.ManagementServer.ConnectionRequestURL" "$val"
+ubus_freecwmp_output
"InternetGatewayDevice.ManagementServer.ConnectionRequestURL" "$val"
}
get_management_server_connection_request_username() {
local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@local[0].username 2> /dev/null`
-freecwmp_value_output
"InternetGatewayDevice.ManagementServer.ConnectionRequestUsername" "$val"
+ubus_freecwmp_output
"InternetGatewayDevice.ManagementServer.ConnectionRequestUsername" "$val"
}
set_management_server_connection_request_username() {
@@ -114,7 +114,7 @@ set_management_server_connection_request_username() {
get_management_server_connection_request_password() {
local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@local[0].password 2> /dev/null`
-freecwmp_value_output
"InternetGatewayDevice.ManagementServer.ConnectionRequestPassword" "$val"
+ubus_freecwmp_output
"InternetGatewayDevice.ManagementServer.ConnectionRequestPassword" "$val"
}
set_management_server_connection_request_password() {
@@ -125,7 +125,12 @@ set_management_server_connection_request_password() {
get_management_server_x_freecwmp_org__acs_scheme() {
local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@acs[0].scheme 2> /dev/null`
-freecwmp_output
"InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme" "$val"
+local
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+ ubus_freecwmp_output "$parm" "$val"
+else
+ freecwmp_output "$parm" "$val"
+fi
}
set_management_server_x_freecwmp_org__acs_scheme() {
@@ -134,7 +139,12 @@ set_management_server_x_freecwmp_org__acs_scheme() {
get_management_server_x_freecwmp_org__acs_hostname() {
local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@acs[0].hostname 2> /dev/null`
-freecwmp_output
"InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname" "$val"
+local
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+ ubus_freecwmp_output "$parm" "$val"
+else
+ freecwmp_output "$parm" "$val"
+fi
}
set_management_server_x_freecwmp_org__acs_hostname() {
@@ -147,7 +157,12 @@ fi
get_management_server_x_freecwmp_org__acs_port() {
local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@acs[0].port 2> /dev/null`
-freecwmp_output
"InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port" "$val"
+local
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+ ubus_freecwmp_output "$parm" "$val"
+else
+ freecwmp_output "$parm" "$val"
+fi
}
set_management_server_x_freecwmp_org__acs_port() {
@@ -156,7 +171,12 @@ set_management_server_x_freecwmp_org__acs_port() {
get_management_server_x_freecwmp_org__acs_path() {
local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@acs[0].path 2> /dev/null`
-freecwmp_output
"InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path" "$val"
+local
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+ ubus_freecwmp_output "$parm" "$val"
+else
+ freecwmp_output "$parm" "$val"
+fi
}
set_management_server_x_freecwmp_org__acs_path() {
@@ -165,7 +185,12 @@ set_management_server_x_freecwmp_org__acs_path() {
get_management_server_x_freecwmp_org__connection_request_port() {
local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@local[0].port 2> /dev/null`
-freecwmp_output
"InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port"
"$val"
+local
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+ ubus_freecwmp_output "$parm" "$val"
+else
+ freecwmp_output "$parm" "$val"
+fi
}
set_management_server_x_freecwmp_org__connection_request_port() {
@@ -188,6 +213,7 @@ case "$1" in
get_management_server_x_freecwmp_org__acs_port
get_management_server_x_freecwmp_org__acs_path
get_management_server_x_freecwmp_org__connection_request_port
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.)
get_management_server_url
@@ -203,47 +229,62 @@ case "$1" in
get_management_server_x_freecwmp_org__acs_port
get_management_server_x_freecwmp_org__acs_path
get_management_server_x_freecwmp_org__connection_request_port
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.URL)
get_management_server_url
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.Username)
get_management_server_username
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.Password)
get_management_server_password
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.PeriodicInformEnable)
get_management_server_periodic_inform_enable
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.PeriodicInformInterval)
get_management_server_periodic_inform_interval
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
get_management_server_connection_request_url
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.ConnectionRequestUsername)
get_management_server_connection_request_username
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.ConnectionRequestPassword)
get_management_server_connection_request_password
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme)
get_management_server_x_freecwmp_org__acs_scheme
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname)
get_management_server_x_freecwmp_org__acs_hostname
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port)
get_management_server_x_freecwmp_org__acs_port
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path)
get_management_server_x_freecwmp_org__acs_path
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port)
get_management_server_x_freecwmp_org__connection_request_port
+ return $FAULT_CPE_NO_FAULT
;;
esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
}
set_management_server() {
@@ -301,10 +342,11 @@ return 1
}
get_management_server_generic() {
- check_parameter_management_server_generic "$1" ; _tmp=$? ; if [
"$_tmp" -eq 1 ]; then return 0; fi
+ check_parameter_management_server_generic "$1" ; _tmp=$? ; if [
"$_tmp" -eq 1 ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
freecwmp_get_parameter_value "val" "$1"
- freecwmp_value_output "$1" "$val"
+ ubus_freecwmp_output "$1" "$val"
+ return $FAULT_CPE_NO_FAULT
}
set_management_server_generic() {
--
1.7.4.1
>From dfb8cb80b1353170d74cb15ebf1dc0b5d0254f41 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:11:29 +0100
Subject: [PATCH 10/27] Update misc script to support communicte data of
get parameter values to the core via ubus
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
ext/openwrt/scripts/functions/misc | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/ext/openwrt/scripts/functions/misc
b/ext/openwrt/scripts/functions/misc
index 2e0210c..13f2142 100644
--- a/ext/openwrt/scripts/functions/misc
+++ b/ext/openwrt/scripts/functions/misc
@@ -3,21 +3,25 @@
get_misc_cpu_usage() {
local val=`uptime | awk -F'average: ' '{ print $2 }' | awk -F',' '{
print $1 }' | awk -F'.' '{ print $2 }'`
-freecwmp_value_output "Device.DeviceInfo.ProcessStatus.CPUUsage" "$val"
+ubus_freecwmp_output "Device.DeviceInfo.ProcessStatus.CPUUsage" "$val"
}
get_misc_process_number() {
local val=`ps | grep -v COMMAND | wc -l`
-freecwmp_value_output
"Device.DeviceInfo.ProcessStatus.ProcessNumberOfEntries" "$val"
+local type="xsd:unsignedInt"
+ubus_freecwmp_output
"Device.DeviceInfo.ProcessStatus.ProcessNumberOfEntries" "$val" "$type"
}
get_misc() {
case "$1" in
Device.DeviceInfo.ProcessStatus.CPUUsage)
get_misc_cpu_usage
+ return $FAULT_CPE_NO_FAULT
;;
Device.DeviceInfo.ProcessStatus.ProcessNumberOfEntries)
get_misc_process_number
+ return $FAULT_CPE_NO_FAULT
;;
esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
}
--
1.7.4.1
>From 1c3ddcdb4827bbecf99220963031c934a9b1fbe1 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:14:35 +0100
Subject: [PATCH 11/27] Update wan_device script to support communicte
data of get parameter values to the core via ubus
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
ext/openwrt/scripts/functions/wan_device | 39
+++++++++++++++++++++++++----
1 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/ext/openwrt/scripts/functions/wan_device
b/ext/openwrt/scripts/functions/wan_device
index 77cb63f..a8b6361 100644
--- a/ext/openwrt/scripts/functions/wan_device
+++ b/ext/openwrt/scripts/functions/wan_device
@@ -4,26 +4,37 @@
get_wan_device_mng_status() {
# TODO: Unconfigured ; Connecting ; Connected ; PendingDisconnect ;
Disconneting ; Disconnected
local val="Connected"
-freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus"
"$val"
+ubus_freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus"
"$val" "xsd:boolean"
}
get_wan_device_mng_interface_ip() {
local val
+local
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress"
if [ -z "$default_wan_device_mng_interface_ip" ]; then
val=`network_get_ipaddr val mng`
else
val=$default_wan_device_mng_interface_ip
fi
-freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress"
"$val"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+ ubus_freecwmp_output "$parm" "$val"
+else
+ freecwmp_output "$parm" "$val"
+fi
}
get_wan_device_mng_interface_mac() {
+local val=""
+local
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress"
if [ -z "$default_wan_device_mng_interface_mac" ]; then
val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
network.mng.macaddr`
else
val=$default_wan_device_mng_interface_mac
fi
-freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress"
"$val"
+if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
+ ubus_freecwmp_output "$parm" "$val"
+else
+ freecwmp_output "$parm" "$val"
+fi
}
get_wan_device_wan_ppp_enable() {
@@ -31,7 +42,7 @@ local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c
$UCI_CONFIG_DIR} get network.wan.auto
if [ -z $val ]; then
val="1"
fi
-freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable"
"$val"
+ubus_freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable"
"$val" "xsd:boolean"
}
set_wan_device_wan_ppp_enable() {
@@ -47,7 +58,7 @@ fi
get_wan_device_wan_ppp_username() {
local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
network.wan.username 2> /dev/null`
-freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username"
"$val"
+ubus_freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username"
"$val"
}
set_wan_device_wan_ppp_username() {
@@ -55,7 +66,9 @@ set_wan_device_wan_ppp_username() {
}
get_wan_device_wan_ppp_password() {
-freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password"
""
+local val=""
+val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
network.wan.password 2> /dev/null`
+ubus_freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password"
"$val"
}
set_wan_device_wan_ppp_password() {
@@ -71,6 +84,7 @@ case "$1" in
get_wan_device_wan_ppp_enable
get_wan_device_wan_ppp_username
get_wan_device_wan_ppp_password
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.WANDevice.)
get_wan_device_mng_status
@@ -79,6 +93,7 @@ case "$1" in
get_wan_device_wan_ppp_enable
get_wan_device_wan_ppp_username
get_wan_device_wan_ppp_password
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.WANDevice.1.)
get_wan_device_mng_status
@@ -87,6 +102,7 @@ case "$1" in
get_wan_device_wan_ppp_enable
get_wan_device_wan_ppp_username
get_wan_device_wan_ppp_password
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.)
get_wan_device_mng_status
@@ -95,6 +111,7 @@ case "$1" in
get_wan_device_wan_ppp_enable
get_wan_device_wan_ppp_username
get_wan_device_wan_ppp_password
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.)
get_wan_device_mng_status
@@ -103,36 +120,46 @@ case "$1" in
get_wan_device_wan_ppp_enable
get_wan_device_wan_ppp_username
get_wan_device_wan_ppp_password
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.)
get_wan_device_mng_status
get_wan_device_mng_interface_ip
get_wan_device_mng_interface_mac
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.)
get_wan_device_mng_status
get_wan_device_mng_interface_ip
get_wan_device_mng_interface_mac
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus)
get_wan_device_mng_status
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress)
get_wan_device_mng_interface_ip
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress)
get_wan_device_mng_interface_mac
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
get_wan_device_wan_ppp_enable
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
get_wan_device_wan_ppp_username
+ return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
get_wan_device_wan_ppp_password
+ return $FAULT_CPE_NO_FAULT
;;
esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
}
set_wan_device() {
--
1.7.4.1
>From 4ef165928bbd8e532f8f587ebf45789fdb44ba74 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:17:34 +0100
Subject: [PATCH 12/27] update inform in order to get parameters from
ubus instead from pipe
Contributed by PIVA SOFTWARE
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
src/xml.c | 40 ++++++++++++++++++----------------------
1 files changed, 18 insertions(+), 22 deletions(-)
diff --git a/src/xml.c b/src/xml.c
index 23b9ec7..612c0bb 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -219,6 +219,7 @@ int xml_prepare_inform_message(char **msg_out)
{
mxml_node_t *tree, *b;
char *c, *tmp;
+ struct external_parameter *external_parameter;
#ifdef DUMMY_MODE
FILE *fp;
@@ -337,37 +338,31 @@ int xml_prepare_inform_message(char **msg_out)
if (mxmlGetType(b) != MXML_ELEMENT)
goto error;
- tmp =
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress";
- b = mxmlFindElementText(tree, tree, tmp, MXML_DESCEND);
- if (!b) goto error;
-
- b = b->parent->next->next;
- if (mxmlGetType(b) != MXML_ELEMENT)
+ external_get_action_write("value",
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress",
NULL);
+ external_get_action_write("value",
"InternetGatewayDevice.ManagementServer.ConnectionRequestURL", NULL);
+ if (external_get_action_execute())
goto error;
- c = NULL;
- if (external_get_action("value", tmp, &c)) goto error;
- if (c) {
- b = mxmlNewText(b, 0, c);
- FREE(c);
- if (!b) goto error;
- }
-
- tmp = "InternetGatewayDevice.ManagementServer.ConnectionRequestURL";
- b = mxmlFindElementText(tree, tree, tmp, MXML_DESCEND);
- if (!b) goto error;
+ while (external_list_parameter.next!=&external_list_parameter) {
+ external_parameter = list_entry(external_list_parameter.next,
struct external_parameter, list);
+ b = mxmlFindElementText(tree, tree, external_parameter->name,
MXML_DESCEND);
+ if (!b) continue;
b = b->parent->next->next;
if (mxmlGetType(b) != MXML_ELEMENT)
goto error;
- c = NULL;
- if (external_get_action("value", tmp, &c)) goto error;
- if (c) {
- b = mxmlNewText(b, 0, c);
- FREE(c);
+ if (external_parameter->data) {
+ b = mxmlNewText(b, 0, external_parameter->data);
if (!b) goto error;
}
+ list_del(&external_parameter->list);
+ free(external_parameter->name);
+ free(external_parameter->data);
+ free(external_parameter->type);
+ free(external_parameter->fault_code);
+ free(external_parameter);
+ }
if (xml_prepare_notifications_inform(tree))
goto error;
@@ -378,6 +373,7 @@ int xml_prepare_inform_message(char **msg_out)
return 0;
error:
+ external_free_list_parameter();
mxmlDelete(tree);
return -1;
}
--
1.7.4.1
>From 71814340a261a18fd3002a67863ce0fcd295a0bf Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:20:12 +0100
Subject: [PATCH 13/27] Add 3rd argument in the ubus handler of
notification. The 3rd argument is the type of the parameter
This agument could be used in the response of get parameter attribute
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
src/cwmp.c | 2 +-
src/cwmp.h | 2 +-
src/ubus.c | 5 ++++-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/cwmp.c b/src/cwmp.c
index 1bf9b2a..b75c762 100644
--- a/src/cwmp.c
+++ b/src/cwmp.c
@@ -245,7 +245,7 @@ void cwmp_clear_events(void)
pthread_mutex_unlock(&event_lock);
}
-void cwmp_add_notification(char *parameter, char *value)
+void cwmp_add_notification(char *parameter, char *value, char *type)
{
char *c = NULL;
external_get_action("notification", parameter, &c);
diff --git a/src/cwmp.h b/src/cwmp.h
index 5703db0..1d8afac 100644
--- a/src/cwmp.h
+++ b/src/cwmp.h
@@ -52,7 +52,7 @@ void cwmp_add_event(int code, char *key);
void cwmp_remove_event(int code);
void cwmp_clear_events(void);
-void cwmp_add_notification(char *parameter, char *value);
+void cwmp_add_notification(char *parameter, char *value, char *type);
void cwmp_clear_notifications(void);
int cwmp_set_parameter_write_handler(char *name, char *value);
diff --git a/src/ubus.c b/src/ubus.c
index d5437f9..0fd1def 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -38,12 +38,14 @@ static void ubus_freecwmpd_stop_callback(struct
uloop_timeout *timeout)
static enum notify {
NOTIFY_PARAM,
NOTIFY_VALUE,
+ NOTIFY_TYPE,
__NOTIFY_MAX
};
static const struct blobmsg_policy notify_policy[] = {
[NOTIFY_PARAM] = { .name = "parameter", .type = BLOBMSG_TYPE_STRING },
[NOTIFY_VALUE] = { .name = "value", .type = BLOBMSG_TYPE_STRING },
+ [NOTIFY_TYPE] = { .name = "type", .type = BLOBMSG_TYPE_STRING },
};
static int
@@ -66,7 +68,8 @@ freecwmpd_handle_notify(struct ubus_context *ctx,
struct ubus_object *obj,
"triggered ubus notification parameter %s\n",
blobmsg_data(tb[NOTIFY_PARAM]));
cwmp_add_notification(blobmsg_data(tb[NOTIFY_PARAM]),
- blobmsg_data(tb[NOTIFY_VALUE]));
+ blobmsg_data(tb[NOTIFY_VALUE]),
+ tb[NOTIFY_TYPE]? blobmsg_data(tb[NOTIFY_TYPE]) : NULL);
return 0;
}
--
1.7.4.1
>From 227820f9866cb0375238b0615f32498c283a0110 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:23:07 +0100
Subject: [PATCH 14/27] add xml message get_parameter_name handler.
Contributed by Inteno Broadband Technology AB & PIVA SOFTWARE
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
src/cwmp.c | 2 +-
src/external.c | 70 +++++++++++++-----------------------
src/external.h | 3 +-
src/ubus.c | 39 ++++++++++++++++++++
src/xml.c | 111
+++++++++++++++++++++++++++++++++++++++++++++++++++++++-
src/xml.h | 4 ++
6 files changed, 181 insertions(+), 48 deletions(-)
diff --git a/src/cwmp.c b/src/cwmp.c
index b75c762..7de19e3 100644
--- a/src/cwmp.c
+++ b/src/cwmp.c
@@ -248,7 +248,7 @@ void cwmp_clear_events(void)
void cwmp_add_notification(char *parameter, char *value, char *type)
{
char *c = NULL;
- external_get_action("notification", parameter, &c);
+ external_get_action_data("notification", parameter, &c);
if (!c) return;
struct notification *n = NULL;
diff --git a/src/external.c b/src/external.c
index 94ae9b8..4973d1a 100644
--- a/src/external.c
+++ b/src/external.c
@@ -60,14 +60,32 @@ void external_free_list_parameter()
}
}
-int external_get_action(char *action, char *name, char **value)
+int external_get_action_data(char *action, char *name, char **value)
+{
+ struct external_parameter *external_parameter;
+ external_get_action(action, name, NULL);
+ if (external_list_parameter.next!=&external_list_parameter) {
+ external_parameter = list_entry(external_list_parameter.next,
struct external_parameter, list);
+ if (external_parameter->data)
+ *value = external_parameter->data;
+ list_del(&external_parameter->list);
+ free(external_parameter->name);
+ free(external_parameter->data);
+ free(external_parameter->type);
+ free(external_parameter->fault_code);
+ free(external_parameter);
+ }
+ external_free_list_parameter();
+ return 0;
+}
+
+int external_get_action(char *action, char *name, char *arg /* arg is
added for GetParameterNames NextLevel argument*/)
{
freecwmp_log_message(NAME, L_NOTICE,
"executing get %s '%s'\n", action, name);
- int pfds[2];
- if (pipe(pfds) < 0)
- return -1;
+
+ pthread_create(&ubus_thread, NULL, &thread_uloop_run, NULL);
if ((uproc.pid = fork()) == -1)
goto error;
@@ -79,66 +97,28 @@ int external_get_action(char *action, char *name,
char **value)
int i = 0;
argv[i++] = "/bin/sh";
argv[i++] = fc_script;
- argv[i++] = "--newline";
- argv[i++] = "--value";
argv[i++] = "get";
argv[i++] = action;
argv[i++] = name;
+ if(arg) argv[i++] = arg;
argv[i++] = NULL;
- close(pfds[0]);
- dup2(pfds[1], 1);
- close(pfds[1]);
-
execvp(argv[0], (char **) argv);
exit(ESRCH);
} else if (uproc.pid < 0)
goto error;
- /* parent */
- close(pfds[1]);
-
int status;
while (wait(&status) != uproc.pid) {
DD("waiting for child to exit");
}
+ pthread_cancel(ubus_thread);
+ pthread_join(ubus_thread,NULL);
- char buffer[64];
- ssize_t rxed;
- char *c;
- int t;
-
- *value = NULL;
- while ((rxed = read(pfds[0], buffer, sizeof(buffer))) > 0) {
- if (*value)
- t = asprintf(&c, "%s%.*s", *value, (int) rxed, buffer);
- else
- t = asprintf(&c, "%.*s", (int) rxed, buffer);
-
- if (t == -1) goto error;
-
- free(*value);
- *value = strdup(c);
- free(c);
- }
-
- if (!strlen(*value)) {
- FREE(*value);
- goto done;
- }
-
- if (rxed < 0)
- goto error;
-
-done:
- close(pfds[0]);
return 0;
error:
- FREE(*c);
- FREE(*value);
- close(pfds[0]);
return -1;
}
diff --git a/src/external.h b/src/external.h
index c6df2ea..8e82c39 100644
--- a/src/external.h
+++ b/src/external.h
@@ -27,7 +27,8 @@ struct external_parameter {
char *fault_code;
};
-int external_get_action(char *action, char *name, char **value);
+int external_get_action(char *action, char *name, char *arg);
+int external_get_action_data(char *action, char *name, char **value);
int external_get_action_write(char *action, char *name, char *arg);
int external_get_action_execute();
int external_set_action_write(char *action, char *name, char *value);
diff --git a/src/ubus.c b/src/ubus.c
index 0fd1def..cbf94b0 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -201,11 +201,50 @@ freecwmpd_handle_get_param_values(struct
ubus_context *ctx, struct ubus_object *
return 0;
}
+static enum get_param_names {
+ GET_PARAM_NAMES_PARAM,
+ GET_PARAM_NAMES_WRITABLE,
+ GET_PARAM_NAMES_FAULT,
+ __GET_PARAM_NAMES_MAX
+};
+
+static const struct blobmsg_policy get_param_names_policy[] = {
+ [GET_PARAM_NAMES_PARAM] = { .name = "parameter", .type =
BLOBMSG_TYPE_STRING },
+ [GET_PARAM_NAMES_WRITABLE] = { .name = "writable", .type =
BLOBMSG_TYPE_STRING },
+ [GET_PARAM_NAMES_FAULT] = { .name = "fault_code", .type =
BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_get_param_names(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_NAMES_MAX];
+
+ blobmsg_parse(get_param_names_policy,
ARRAY_SIZE(get_param_names_policy), tb,
+ blob_data(msg), blob_len(msg));
+
+ if (!tb[GET_PARAM_NAMES_PARAM])
+ return UBUS_STATUS_INVALID_ARGUMENT;
+
+ freecwmp_log_message(NAME, L_NOTICE,
+ "triggered ubus get_parameter_names for the parameter
%s\n",
+ blobmsg_data(tb[GET_PARAM_NAMES_PARAM]));
+
+ external_add_list_paramameter(blobmsg_data(tb[GET_PARAM_NAMES_PARAM]),
+ tb[GET_PARAM_NAMES_WRITABLE]?
blobmsg_data(tb[GET_PARAM_NAMES_WRITABLE]) : NULL,
+ NULL,
+ tb[GET_PARAM_NAMES_FAULT]?
blobmsg_data(tb[GET_PARAM_NAMES_FAULT]) : NULL);
+
+ 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),
+ UBUS_METHOD("get_parameter_names",
freecwmpd_handle_get_param_names, get_param_names_policy),
};
static struct ubus_object_type main_object_type =
diff --git a/src/xml.c b/src/xml.c
index 612c0bb..c735244 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -51,6 +51,7 @@ static struct cwmp_namespaces
const struct rpc_method rpc_methods[] = {
{ "SetParameterValues", xml_handle_set_parameter_values },
{ "GetParameterValues", xml_handle_get_parameter_values },
+ { "GetParameterNames", xml_handle_get_parameter_names },
{ "SetParameterAttributes", xml_handle_set_parameter_attributes },
{ "Download", xml_handle_download },
{ "FactoryReset", xml_handle_factory_reset },
@@ -716,7 +717,6 @@ int xml_handle_get_parameter_values(mxml_node_t
*body_in,
free(external_parameter->fault_code);
free(external_parameter);
}
-
#ifdef ACS_MULTI
b = mxmlFindElement(tree_out, tree_out, "ParameterList",
NULL, NULL, MXML_DESCEND);
@@ -736,6 +736,115 @@ out:
return -1;
}
+int xml_handle_get_parameter_names(mxml_node_t *body_in,
+ mxml_node_t *tree_in,
+ mxml_node_t *tree_out)
+{
+ mxml_node_t *n, *parameter_list, *b = body_in;
+ struct external_parameter *external_parameter;
+ char *parameter_name = NULL;
+ char *NextLevel = NULL;
+ char *c;
+ int counter = 0;
+
+ n = mxmlFindElement(tree_out, tree_out, "soap_env:Body",
+ NULL, NULL, MXML_DESCEND);
+ if (!n) return -1;
+
+ n = mxmlNewElement(n, "cwmp:GetParameterNamesResponse");
+ if (!n) return -1;
+
+ n = mxmlNewElement(n, "ParameterList");
+ if (!n) return -1;
+
+#ifdef ACS_MULTI
+ mxmlElementSetAttr(n, "xsi:type", "soap_enc:Array");
+#endif
+
+ while (b) {
+ if (b && b->type == MXML_TEXT &&
+ b->value.text.string &&
+ b->parent->type == MXML_ELEMENT &&
+ !strcmp(b->parent->value.element.name, "ParameterPath")) {
+ parameter_name = b->value.text.string;
+ }
+ if (b && b->type == MXML_ELEMENT && /* added in order to
support GetParameterNames with empty ParameterPath*/
+ !strcmp(b->value.element.name, "ParameterPath") &&
+ !b->child) {
+ parameter_name = "";
+ }
+ if (b && b->type == MXML_TEXT &&
+ b->value.text.string &&
+ b->parent->type == MXML_ELEMENT &&
+ !strcmp(b->parent->value.element.name, "NextLevel")) {
+ NextLevel = b->value.text.string;
+ }
+ b = mxmlWalkNext(b, body_in, MXML_DESCEND);
+ }
+ if (parameter_name && NextLevel) {
+ if (!external_get_action("name", parameter_name, NextLevel)) {
+ // got the parameter value via external script
+ } else {
+ // error occurred when getting parameter value
+ goto out;
+ }
+ }
+
+ parameter_list = mxmlFindElement(tree_out, tree_out,
"ParameterList", NULL, NULL, MXML_DESCEND);
+ if (!parameter_list) goto out;
+
+ while (external_list_parameter.next!=&external_list_parameter) {
+
+ external_parameter = list_entry(external_list_parameter.next,
struct external_parameter, list);
+
+ if (external_parameter->fault_code &&
external_parameter->fault_code[0]=='9')
+ goto out; // KMD TODO return FAULT message the fault code
is in ->fault_code
+
+ n = mxmlNewElement(parameter_list, "ParameterInfoStruct");
+ if (!n) goto out;
+
+ n = mxmlNewElement(n, "Name");
+ if (!n) goto out;
+
+ n = mxmlNewText(n, 0, external_parameter->name);
+ if (!n) goto out;
+
+ n = n->parent->parent;
+ n = mxmlNewElement(n, "Writable");
+ if (!n) goto out;
+
+ n = mxmlNewText(n, 0, external_parameter->data);
+ if (!n) goto out;
+
+ counter++;
+
+ list_del(&external_parameter->list);
+ free(external_parameter->name);
+ free(external_parameter->data);
+ free(external_parameter->type);
+ free(external_parameter->fault_code);
+ free(external_parameter);
+ }
+
+#ifdef ACS_MULTI
+ b = mxmlFindElement(tree_out, tree_out, "ParameterList",
+ NULL, NULL, MXML_DESCEND);
+ if (!b) goto out;
+
+ if (asprintf(&c, "cwmp:ParameterInfoStruct[%d]", counter) == -1)
+ goto out;
+
+ mxmlElementSetAttr(b, "soap_enc:arrayType", c);
+ FREE(c);
+#endif
+
+ return 0;
+
+out:
+ external_free_list_parameter();
+ return -1;
+}
+
static int xml_handle_set_parameter_attributes(mxml_node_t *body_in,
mxml_node_t *tree_in,
mxml_node_t *tree_out) {
diff --git a/src/xml.h b/src/xml.h
index 8f63192..a9191eb 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -26,6 +26,10 @@ static int
xml_handle_get_parameter_values(mxml_node_t *body_in,
mxml_node_t *tree_in,
mxml_node_t *tree_out);
+static int xml_handle_get_parameter_names(mxml_node_t *body_in,
+ mxml_node_t *tree_in,
+ mxml_node_t *tree_out);
+
static int xml_handle_set_parameter_attributes(mxml_node_t *body_in,
mxml_node_t *tree_in,
mxml_node_t *tree_out);
--
1.7.4.1
>From 61c6b8784a75db9f14f9f22e835e708a3a56e93c Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:25:54 +0100
Subject: [PATCH 15/27] add the common function and adapt the script
freecwmp.sh in order to support get parameter names
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
ext/openwrt/config/freecwmp | 6 ++++
ext/openwrt/scripts/freecwmp.sh | 47
++++++++++++++++++++++++++++++++++
ext/openwrt/scripts/functions/common | 4 +++
3 files changed, 57 insertions(+), 0 deletions(-)
diff --git a/ext/openwrt/config/freecwmp b/ext/openwrt/config/freecwmp
index ba6fbda..3b2b4c3 100644
--- a/ext/openwrt/config/freecwmp
+++ b/ext/openwrt/config/freecwmp
@@ -29,19 +29,25 @@ config scripts
# freecwmp specific functions
list location /usr/share/freecwmp/functions/device_info
list get_value_function get_device_info
+ list get_name_function get_device_info_name
list set_value_function set_device_info
list get_value_function get_device_info_generic
+ list get_name_function get_device_info_generic_name
list set_value_function set_device_info_generic
list location /usr/share/freecwmp/functions/lan_device
list get_value_function get_lan_device
+ list get_name_function get_lan_device_name
list set_value_function set_lan_device
list location /usr/share/freecwmp/functions/management_server
list get_value_function get_management_server
+ list get_name_function get_management_server_name
list set_value_function set_management_server
list get_value_function get_management_server_generic
+ list get_name_function get_management_server_generic_name
list set_value_function set_management_server_generic
list location /usr/share/freecwmp/functions/wan_device
list get_value_function get_wan_device
+ list get_name_function get_wan_device_name
list set_value_function set_wan_device
list location /usr/share/freecwmp/functions/misc
list get_value_function get_misc
diff --git a/ext/openwrt/scripts/freecwmp.sh
b/ext/openwrt/scripts/freecwmp.sh
index f2bebc8..c5a0d53 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -68,6 +68,10 @@ case "$1" in
elif [ "$2" = "value" ]; then
__arg1="$3"
action="get_value"
+ elif [ "$2" = "name" ]; then
+ __arg1="$3"
+ __arg2=`echo $4| tr '[A-Z]' '[a-z]'`
+ action="get_name"
elif [ "$2" = "all" ]; then
__arg1="$3"
action="get_all"
@@ -107,6 +111,7 @@ handle_scripts() {
config_get prefix "$section" "prefix"
config_list_foreach "$section" 'location' load_script
config_get get_value_functions "$section" "get_value_function"
+ config_get get_name_functions "$section" "get_name_function"
config_get set_value_functions "$section" "set_value_function"
}
@@ -163,6 +168,48 @@ if [ "$action" = "get_value" -o "$action" =
"get_all" ]; then
fi
fi
+if [ "$action" = "get_name" -o "$action" = "get_all" ]; then
+ no_fault="0"
+ freecwmp_check_fault "$__arg1"
+ fault_code="$?"
+ if [ "$fault_code" = "0" ]; then
+ if [ \( "$__arg2" != "0" \) -a \( "$__arg2" != "1" \) -a \(
"$__arg2" != "true" \) -a \( "$__arg2" != "false" \) ]; then
+ fault_code="$FAULT_CPE_INVALID_ARGUMENTS"
+ else
+ if [ "$__arg2" = "true" ]; then
+ __arg2="1"
+ elif [ "$__arg2" = "false" ]; then
+ __arg2="0"
+ fi
+ fi
+ if [ "$fault_code" = "0" ]; then
+ if [ \( "$__arg1" = "InternetGatewayDevice." \) -o \(
"$__arg1" = "" \) ]; then
+ ubus_freecwmp_output "InternetGatewayDevice." "0"
+ if [ \( "$__arg1" = "" \) -a \( "$__arg2" = "1" \) ]; then
+ exit 0
+ fi
+ __arg1="InternetGatewayDevice."
+ fi
+ for function_name in $get_name_functions
+ do
+ $function_name "$__arg1" "$__arg2"
+ fault_code="$?"
+ if [ "$fault_code" = "0" ]; then
+ no_fault="1"
+ fi
+ if [ "$fault_code" = "$FAULT_CPE_INVALID_ARGUMENTS" ]; then
+ break
+ fi
+ done
+ if [ "$no_fault" = "1" ]; then fault_code="0"; fi
+ fi
+ fi
+ if [ "$fault_code" != "0" ]; then
+ let fault_code=$fault_code+9000
+ ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
+ fi
+fi
+
if [ "$action" = "set_value" ]; then
for function_name in $set_value_functions
do
diff --git a/ext/openwrt/scripts/functions/common
b/ext/openwrt/scripts/functions/common
index 082e067..abba220 100644
--- a/ext/openwrt/scripts/functions/common
+++ b/ext/openwrt/scripts/functions/common
@@ -48,6 +48,10 @@ case "$action" in
get_value)
ubus call tr069 get_parameter_values '{"parameter":
"'$parameter'", "value": "'$value'", "type": "'$type'",
"fault_code":"'$fault_code'"}' 2> /dev/null
;;
+ get_name)
+ ubus call tr069 get_parameter_names '{"parameter": "'$parameter'",
"writable": "'$value'", "fault_code":"'$fault_code'"}' 2> /dev/null
+ ;;
+
esac
}
freecwmp_value_output() {
--
1.7.4.1
>From dca6e0b2becaf71ed40ddacf61446bb6c5989d5e Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:27:48 +0100
Subject: [PATCH 16/27] update the script device_info in order to output
parameters with ubus
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@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"
+ ;;
+esac
ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer"
"$val"
}
@@ -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
>From 23258b38a86cbe5e03c550c8e7a1a05eabfe6776 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:30:19 +0100
Subject: [PATCH 17/27] update the script lan_device in order to output
parameters with ubus
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
ext/openwrt/scripts/functions/lan_device | 98
++++++++++++++++++++++++++++-
1 files changed, 94 insertions(+), 4 deletions(-)
diff --git a/ext/openwrt/scripts/functions/lan_device
b/ext/openwrt/scripts/functions/lan_device
index fa9dda4..712b5e8 100644
--- a/ext/openwrt/scripts/functions/lan_device
+++ b/ext/openwrt/scripts/functions/lan_device
@@ -4,7 +4,10 @@
get_wlan_enable() {
local num="$1"
local type="xsd:boolean"
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
wireless.@wifi-device[$num].disabled 2> /dev/null`
+local val=""
+case "$action" in
+ get_value)
+ val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
wireless.@wifi-device[$num].disabled 2> /dev/null`
let num=$num+1
if [ "$val" = "1" ]; then
val="0"
@@ -12,6 +15,13 @@ else
val="1"
fi
ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
"$type"
+ ;;
+ get_name)
+ val="1"
+ let num=$num+1
+ ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
+ ;;
+esac
}
set_wlan_enable() {
@@ -28,9 +38,20 @@ delay_command "wifi" "wifi" "45"
get_wlan_ssid() {
local num="$1"
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
wireless.@wifi-iface[$num].ssid 2> /dev/null`
-let num=$num+1
-ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
+local val=""
+case "$action" in
+ get_value)
+ val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
wireless.@wifi-iface[$num].ssid 2> /dev/null`
+ let num=$num+1
+ ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
+ ;;
+ get_name)
+ val="1"
+ let num=$num+1
+ ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
+ ;;
+esac
+
}
set_wlan_ssid() {
@@ -79,6 +100,75 @@ esac
return $FAULT_CPE_INVALID_PARAMETER_NAME
}
+get_lan_device_name() {
+case "$1" in
+ InternetGatewayDevice.)
+ ubus_freecwmp_output "InternetGatewayDevice.LANDevice." "1"
+ if [ "$2" = "0" ]; then
+ ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1." "1"
+ ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration." "1"
+ ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
+ get_wlan_enable 0
+ get_wlan_ssid 0
+ fi
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.LANDevice.)
+ ubus_freecwmp_output "InternetGatewayDevice.LANDevice." "1"
+ ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1." "1"
+ if [ "$2" = "0" ]; then
+ ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration." "1"
+ ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
+ get_wlan_enable 0
+ get_wlan_ssid 0
+ fi
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.LANDevice.1.)
+ ubus_freecwmp_output "InternetGatewayDevice.LANDevice.1." "1"
+ ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration." "1"
+ if [ "$2" = "0" ]; then
+ ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
+ get_wlan_enable 0
+ get_wlan_ssid 0
+ fi
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.LANDevice.1.WLANConfiguration.)
+ ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration." "1"
+ ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
+ if [ "$2" = "0" ]; then
+ get_wlan_enable 0
+ get_wlan_ssid 0
+ fi
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
+ ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
+ if [ "$2" = "0" ]; then
+ get_wlan_enable 0
+ get_wlan_ssid 0
+ fi
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_wlan_enable 0
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_wlan_ssid 0
+ return $FAULT_CPE_NO_FAULT
+ ;;
+esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
set_lan_device() {
case "$1" in
InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
--
1.7.4.1
>From c07ba0be14b2491bc7046fc670a186ecec2fbc11 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:33:17 +0100
Subject: [PATCH 18/27] update the script management_server in order to
output parameters with ubus
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
ext/openwrt/config/freecwmp | 12 +-
ext/openwrt/scripts/functions/lan_device | 22 +-
ext/openwrt/scripts/functions/management_server | 323
++++++++++++++++++++---
3 files changed, 307 insertions(+), 50 deletions(-)
diff --git a/ext/openwrt/config/freecwmp b/ext/openwrt/config/freecwmp
index 3b2b4c3..1379afd 100644
--- a/ext/openwrt/config/freecwmp
+++ b/ext/openwrt/config/freecwmp
@@ -29,25 +29,25 @@ config scripts
# freecwmp specific functions
list location /usr/share/freecwmp/functions/device_info
list get_value_function get_device_info
- list get_name_function get_device_info_name
+ list get_name_function get_device_info_name
list set_value_function set_device_info
list get_value_function get_device_info_generic
- list get_name_function get_device_info_generic_name
+ list get_name_function get_device_info_generic_name
list set_value_function set_device_info_generic
list location /usr/share/freecwmp/functions/lan_device
list get_value_function get_lan_device
- list get_name_function get_lan_device_name
+ list get_name_function get_lan_device_name
list set_value_function set_lan_device
list location /usr/share/freecwmp/functions/management_server
list get_value_function get_management_server
- list get_name_function get_management_server_name
+ list get_name_function get_management_server_name
list set_value_function set_management_server
list get_value_function get_management_server_generic
- list get_name_function get_management_server_generic_name
+ list get_name_function get_management_server_generic_name
list set_value_function set_management_server_generic
list location /usr/share/freecwmp/functions/wan_device
list get_value_function get_wan_device
- list get_name_function get_wan_device_name
+ list get_name_function get_wan_device_name
list set_value_function set_wan_device
list location /usr/share/freecwmp/functions/misc
list get_value_function get_misc
diff --git a/ext/openwrt/scripts/functions/lan_device
b/ext/openwrt/scripts/functions/lan_device
index 712b5e8..64910e2 100644
--- a/ext/openwrt/scripts/functions/lan_device
+++ b/ext/openwrt/scripts/functions/lan_device
@@ -8,13 +8,13 @@ local val=""
case "$action" in
get_value)
val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
wireless.@wifi-device[$num].disabled 2> /dev/null`
-let num=$num+1
-if [ "$val" = "1" ]; then
- val="0"
-else
- val="1"
-fi
-ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
"$type"
+ let num=$num+1
+ if [ "$val" = "1" ]; then
+ val="0"
+ else
+ val="1"
+ fi
+ ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
"$type"
;;
get_name)
val="1"
@@ -138,16 +138,16 @@ case "$1" in
ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration." "1"
ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
if [ "$2" = "0" ]; then
- get_wlan_enable 0
- get_wlan_ssid 0
+ get_wlan_enable 0
+ get_wlan_ssid 0
fi
return $FAULT_CPE_NO_FAULT
;;
InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.1." "1"
if [ "$2" = "0" ]; then
- get_wlan_enable 0
- get_wlan_ssid 0
+ get_wlan_enable 0
+ get_wlan_ssid 0
fi
return $FAULT_CPE_NO_FAULT
;;
diff --git a/ext/openwrt/scripts/functions/management_server
b/ext/openwrt/scripts/functions/management_server
index eca3a61..eed16d1 100644
--- a/ext/openwrt/scripts/functions/management_server
+++ b/ext/openwrt/scripts/functions/management_server
@@ -9,8 +9,16 @@ local
hostname=`get_management_server_x_freecwmp_org__acs_hostname`
local port=`get_management_server_x_freecwmp_org__acs_port`
local path=`get_management_server_x_freecwmp_org__acs_path`
FLAGS_value=$tmp
-local val=`echo $scheme://$hostname:$port$path`
-ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.URL" "$val"
+local parm="InternetGatewayDevice.ManagementServer.URL"
+case "$action" in
+ get_value)
+ val=`echo $scheme://$hostname:$port$path`
+ ;;
+ get_name)
+ val="0"
+ ;;
+esac
+ubus_freecwmp_output "$parm" "$val"
}
set_management_server_url() {
@@ -45,8 +53,17 @@ ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069
inform '{ "event": "value_change
}
get_management_server_username() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@acs[0].username 2> /dev/null`
-ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.Username"
"$val"
+local val=""
+local parm="InternetGatewayDevice.ManagementServer.Username"
+case "$action" in
+ get_value)
+ val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@acs[0].username 2> /dev/null`
+ ;;
+ get_name)
+ val="0"
+ ;;
+esac
+ubus_freecwmp_output "$parm" "$val"
}
set_management_server_username() {
@@ -54,8 +71,17 @@ set_management_server_username() {
}
get_management_server_password() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@acs[0].password 2> /dev/null`
-ubus_freecwmp_output "InternetGatewayDevice.ManagementServer.Password"
"$val"
+local val=""
+local parm="InternetGatewayDevice.ManagementServer.Password"
+case "$action" in
+ get_value)
+ val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@acs[0].password 2> /dev/null`
+ ;;
+ get_name)
+ val="0"
+ ;;
+esac
+ubus_freecwmp_output "$parm" "$val"
}
set_management_server_password() {
@@ -63,9 +89,18 @@ set_management_server_password() {
}
get_management_server_periodic_inform_enable() {
+local val=""
+local type="xsd:boolean"
local parm="InternetGatewayDevice.ManagementServer.PeriodicInformEnable"
-freecwmp_get_parameter_value "val" "$parm"
-ubus_freecwmp_output "$parm" "$val" "xsd:boolean"
+case "$action" in
+ get_value)
+ freecwmp_get_parameter_value "val" "$parm"
+ ;;
+ get_name)
+ val="1"
+ ;;
+esac
+ubus_freecwmp_output "$parm" "$val" "$type"
}
set_management_server_periodic_inform_enable() {
@@ -74,9 +109,18 @@ freecwmp_set_parameter_value "$parm" "$1"
}
get_management_server_periodic_inform_interval() {
+local val=""
+local type="xsd:unsignedInt"
local parm="InternetGatewayDevice.ManagementServer.PeriodicInformInterval"
-freecwmp_get_parameter_value "val" "$parm"
-ubus_freecwmp_output "$parm" "$val" "xsd:unsingedInt"
+case "$action" in
+ get_value)
+ freecwmp_get_parameter_value "val" "$parm"
+ ;;
+ get_name)
+ val="1"
+ ;;
+esac
+ubus_freecwmp_output "$parm" "$val" "$type"
}
set_management_server_periodic_inform_interval() {
@@ -86,26 +130,42 @@ freecwmp_set_parameter_value "$parm" "$1"
get_management_server_connection_request_url() {
local val
-if [ -z "$default_management_server_connection_request_url" ]; then
- local tmp=${FLAGS_value}
- FLAGS_value=${FLAGS_TRUE}
- local ip=`get_wan_device_mng_interface_ip`
- local
port=`get_management_server_x_freecwmp_org__connection_request_port`
- FLAGS_value=$tmp
-
- if [ -n "$ip" -a -n "$port" ]; then
- val="http://$ip:$port/"
+local parm="InternetGatewayDevice.ManagementServer.ConnectionRequestURL"
+case "$action" in
+ get_value)
+ if [ -z "$default_management_server_connection_request_url" ]; then
+ local tmp=${FLAGS_value}
+ FLAGS_value=${FLAGS_TRUE}
+ local ip=`get_wan_device_mng_interface_ip`
+ local
port=`get_management_server_x_freecwmp_org__connection_request_port`
+ FLAGS_value=$tmp
+
+ if [ -n "$ip" -a -n "$port" ]; then
+ val="http://$ip:$port/"
+ fi
+ else
+ val=$default_management_server_connection_request_url
fi
-else
- val=$default_management_server_connection_request_url
-fi
-
-ubus_freecwmp_output
"InternetGatewayDevice.ManagementServer.ConnectionRequestURL" "$val"
+ ;;
+ get_name)
+ val="0"
+ ;;
+esac
+ubus_freecwmp_output "$parm" "$val"
}
get_management_server_connection_request_username() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@local[0].username 2> /dev/null`
-ubus_freecwmp_output
"InternetGatewayDevice.ManagementServer.ConnectionRequestUsername" "$val"
+local val=""
+local
parm="InternetGatewayDevice.ManagementServer.ConnectionRequestUsername"
+case "$action" in
+ get_value)
+ val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@local[0].username 2> /dev/null`
+ ;;
+ get_name)
+ val="0"
+ ;;
+esac
+ubus_freecwmp_output "$parm" "$val"
}
set_management_server_connection_request_username() {
@@ -113,8 +173,17 @@ set_management_server_connection_request_username() {
}
get_management_server_connection_request_password() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@local[0].password 2> /dev/null`
-ubus_freecwmp_output
"InternetGatewayDevice.ManagementServer.ConnectionRequestPassword" "$val"
+local val=""
+local
parm="InternetGatewayDevice.ManagementServer.ConnectionRequestPassword"
+case "$action" in
+ get_value)
+ val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@local[0].password 2> /dev/null`
+ ;;
+ get_name)
+ val="0"
+ ;;
+esac
+ubus_freecwmp_output "$parm" "$val"
}
set_management_server_connection_request_password() {
@@ -124,8 +193,16 @@ set_management_server_connection_request_password() {
# TODO: InternetGatewayDevice.ManagementServer.PeriodicInformTime
get_management_server_x_freecwmp_org__acs_scheme() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@acs[0].scheme 2> /dev/null`
+local val=""
local
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme"
+case "$action" in
+ get_value)
+ val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@acs[0].scheme 2> /dev/null`
+ ;;
+ get_name)
+ val="1"
+ ;;
+esac
if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
ubus_freecwmp_output "$parm" "$val"
else
@@ -138,8 +215,16 @@ set_management_server_x_freecwmp_org__acs_scheme() {
}
get_management_server_x_freecwmp_org__acs_hostname() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@acs[0].hostname 2> /dev/null`
+local val=""
local
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname"
+case "$action" in
+ get_value)
+ val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@acs[0].hostname 2> /dev/null`
+ ;;
+ get_name)
+ val="1"
+ ;;
+esac
if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
ubus_freecwmp_output "$parm" "$val"
else
@@ -156,8 +241,16 @@ fi
}
get_management_server_x_freecwmp_org__acs_port() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@acs[0].port 2> /dev/null`
+local val=""
local
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port"
+case "$action" in
+ get_value)
+ val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@acs[0].port 2> /dev/null`
+ ;;
+ get_name)
+ val="1"
+ ;;
+esac
if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
ubus_freecwmp_output "$parm" "$val"
else
@@ -170,8 +263,16 @@ set_management_server_x_freecwmp_org__acs_port() {
}
get_management_server_x_freecwmp_org__acs_path() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@acs[0].path 2> /dev/null`
+local val=""
local
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path"
+case "$action" in
+ get_value)
+ val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@acs[0].path 2> /dev/null`
+ ;;
+ get_name)
+ val="1"
+ ;;
+esac
if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
ubus_freecwmp_output "$parm" "$val"
else
@@ -184,8 +285,16 @@ set_management_server_x_freecwmp_org__acs_path() {
}
get_management_server_x_freecwmp_org__connection_request_port() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@local[0].port 2> /dev/null`
+local val=""
local
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port"
+case "$action" in
+ get_value)
+ val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
freecwmp.@local[0].port 2> /dev/null`
+ ;;
+ get_name)
+ val="1"
+ ;;
+esac
if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
ubus_freecwmp_output "$parm" "$val"
else
@@ -287,6 +396,146 @@ esac
return $FAULT_CPE_INVALID_PARAMETER_NAME
}
+get_management_server_name() {
+case "$1" in
+ InternetGatewayDevice.)
+ ubus_freecwmp_output "InternetGatewayDevice.ManagementServer." "0"
+ if [ "$2" = "0" ]; then
+ get_management_server_url
+ get_management_server_username
+ get_management_server_password
+ get_management_server_periodic_inform_enable
+ get_management_server_periodic_inform_interval
+ get_management_server_connection_request_url
+ get_management_server_connection_request_username
+ get_management_server_connection_request_password
+ get_management_server_x_freecwmp_org__acs_scheme
+ get_management_server_x_freecwmp_org__acs_hostname
+ get_management_server_x_freecwmp_org__acs_port
+ get_management_server_x_freecwmp_org__acs_path
+ get_management_server_x_freecwmp_org__connection_request_port
+ fi
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.)
+ ubus_freecwmp_output "InternetGatewayDevice.ManagementServer." "0"
+ get_management_server_url
+ get_management_server_username
+ get_management_server_password
+ get_management_server_periodic_inform_enable
+ get_management_server_periodic_inform_interval
+ get_management_server_connection_request_url
+ get_management_server_connection_request_username
+ get_management_server_connection_request_password
+ get_management_server_x_freecwmp_org__acs_scheme
+ get_management_server_x_freecwmp_org__acs_hostname
+ get_management_server_x_freecwmp_org__acs_port
+ get_management_server_x_freecwmp_org__acs_path
+ get_management_server_x_freecwmp_org__connection_request_port
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.URL)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_management_server_url
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.Username)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_management_server_username
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.Password)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_management_server_password
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.PeriodicInformEnable)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_management_server_periodic_inform_enable
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.PeriodicInformInterval)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_management_server_periodic_inform_interval
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_management_server_connection_request_url
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.ConnectionRequestUsername)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_management_server_connection_request_username
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.ConnectionRequestPassword)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_management_server_connection_request_password
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_management_server_x_freecwmp_org__acs_scheme
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_management_server_x_freecwmp_org__acs_hostname
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_management_server_x_freecwmp_org__acs_port
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_management_server_x_freecwmp_org__acs_path
+ return $FAULT_CPE_NO_FAULT
+ ;;
+
InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_management_server_x_freecwmp_org__connection_request_port
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.ParameterKey)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_management_server_parameter_key
+ return $FAULT_CPE_NO_FAULT
+ ;;
+esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
set_management_server() {
case "$1" in
InternetGatewayDevice.ManagementServer.URL)
@@ -349,6 +598,14 @@ get_management_server_generic() {
return $FAULT_CPE_NO_FAULT
}
+get_management_server_generic_name() {
+ check_parameter_management_server_generic "$1" ; _tmp=$? ; if [
"$_tmp" -eq 1 ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
+
+ local val="1"
+ ubus_freecwmp_output "$1" "$val"
+ return $FAULT_CPE_NO_FAULT
+}
+
set_management_server_generic() {
check_parameter_management_server_generic "$1" ; _tmp=$? ; if [
"$_tmp" -eq 1 ]; then return 0; fi
--
1.7.4.1
>From 56c0be1075a4964dfb83ffdc093acaa27d209550 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:40:47 +0100
Subject: [PATCH 19/27] update the script wan_device in order to output
parameters with ubus
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
ext/openwrt/scripts/freecwmp.sh | 127 +++++++++---------
ext/openwrt/scripts/functions/wan_device | 223
+++++++++++++++++++++++++++---
src/freecwmp.c | 2 +-
3 files changed, 267 insertions(+), 85 deletions(-)
diff --git a/ext/openwrt/scripts/freecwmp.sh
b/ext/openwrt/scripts/freecwmp.sh
index c5a0d53..a2f2bc1 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -1,5 +1,6 @@
#!/bin/sh
# Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
+# Copyright (C) 2012-2013 Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
. /lib/functions.sh
. /usr/share/libubox/jshn.sh
@@ -68,10 +69,10 @@ case "$1" in
elif [ "$2" = "value" ]; then
__arg1="$3"
action="get_value"
- elif [ "$2" = "name" ]; then
- __arg1="$3"
- __arg2=`echo $4| tr '[A-Z]' '[a-z]'`
- action="get_name"
+ elif [ "$2" = "name" ]; then
+ __arg1="$3"
+ __arg2=`echo $4| tr '[A-Z]' '[a-z]'`
+ action="get_name"
elif [ "$2" = "all" ]; then
__arg1="$3"
action="get_all"
@@ -111,7 +112,7 @@ handle_scripts() {
config_get prefix "$section" "prefix"
config_list_foreach "$section" 'location' load_script
config_get get_value_functions "$section" "get_value_function"
- config_get get_name_functions "$section" "get_name_function"
+ config_get get_name_functions "$section" "get_name_function"
config_get set_value_functions "$section" "set_value_function"
}
@@ -142,16 +143,57 @@ FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED="18"
FAULT_CPE_DOWNLOAD_FAIL_FILE_AUTHENTICATION="19"
if [ "$action" = "get_value" -o "$action" = "get_all" ]; then
- no_fault="0"
- freecwmp_check_fault "$__arg1"
- fault_code="$?"
- if [ "$fault_code" = "0" ]; then
- if [ \( "$__arg1" = "InternetGatewayDevice." \) -o \( "$__arg1"
= "" \) ]; then
- __arg1="InternetGatewayDevice."
+ no_fault="0"
+ freecwmp_check_fault "$__arg1"
+ fault_code="$?"
+ if [ "$fault_code" = "0" ]; then
+ if [ \( "$__arg1" = "InternetGatewayDevice." \) -o \( "$__arg1"
= "" \) ]; then
+ __arg1="InternetGatewayDevice."
+ fi
+ for function_name in $get_value_functions
+ do
+ $function_name "$__arg1"
+ fault_code="$?"
+ if [ "$fault_code" = "0" ]; then
+ no_fault="1"
+ fi
+ if [ "$fault_code" = "$FAULT_CPE_INVALID_ARGUMENTS" ]; then
+ break
+ fi
+ done
+ if [ "$no_fault" = "1" ]; then fault_code="0"; fi
fi
- for function_name in $get_value_functions
- do
- $function_name "$__arg1"
+ if [ "$fault_code" != "0" ]; then
+ let fault_code=$fault_code+9000
+ ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
+ fi
+fi
+
+if [ "$action" = "get_name" -o "$action" = "get_all" ]; then
+ no_fault="0"
+ freecwmp_check_fault "$__arg1"
+ fault_code="$?"
+ if [ "$fault_code" = "0" ]; then
+ if [ \( "$__arg2" != "0" \) -a \( "$__arg2" != "1" \) -a \(
"$__arg2" != "true" \) -a \( "$__arg2" != "false" \) ]; then
+ fault_code="$FAULT_CPE_INVALID_ARGUMENTS"
+ else
+ if [ "$__arg2" = "true" ]; then
+ __arg2="1"
+ elif [ "$__arg2" = "false" ]; then
+ __arg2="0"
+ fi
+ fi
+ if [ "$fault_code" = "0" ]; then
+ if [ \( "$__arg1" = "InternetGatewayDevice." \) -o \(
"$__arg1" = "" \) ]; then
+ ubus_freecwmp_output "InternetGatewayDevice." "0"
+ if [ \( "$__arg1" = "" \) -a \( "$__arg2" = "1" \) ]; then
+ exit 0
+ fi
+ __arg1="InternetGatewayDevice."
+ fi
+ for function_name in $get_name_functions
+ do
+ $function_name "$__arg1" "$__arg2"
fault_code="$?"
if [ "$fault_code" = "0" ]; then
no_fault="1"
@@ -159,55 +201,14 @@ if [ "$action" = "get_value" -o "$action" =
"get_all" ]; then
if [ "$fault_code" = "$FAULT_CPE_INVALID_ARGUMENTS" ];
then
break
fi
- done
- if [ "$no_fault" = "1" ]; then fault_code="0"; fi
- fi
- if [ "$fault_code" != "0" ]; then
- let fault_code=$fault_code+9000
- ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
- fi
-fi
-
-if [ "$action" = "get_name" -o "$action" = "get_all" ]; then
- no_fault="0"
- freecwmp_check_fault "$__arg1"
- fault_code="$?"
- if [ "$fault_code" = "0" ]; then
- if [ \( "$__arg2" != "0" \) -a \( "$__arg2" != "1" \) -a \(
"$__arg2" != "true" \) -a \( "$__arg2" != "false" \) ]; then
- fault_code="$FAULT_CPE_INVALID_ARGUMENTS"
- else
- if [ "$__arg2" = "true" ]; then
- __arg2="1"
- elif [ "$__arg2" = "false" ]; then
- __arg2="0"
- fi
- fi
- if [ "$fault_code" = "0" ]; then
- if [ \( "$__arg1" = "InternetGatewayDevice." \) -o \(
"$__arg1" = "" \) ]; then
- ubus_freecwmp_output "InternetGatewayDevice." "0"
- if [ \( "$__arg1" = "" \) -a \( "$__arg2" = "1" \) ]; then
- exit 0
- fi
- __arg1="InternetGatewayDevice."
- fi
- for function_name in $get_name_functions
- do
- $function_name "$__arg1" "$__arg2"
- fault_code="$?"
- if [ "$fault_code" = "0" ]; then
- no_fault="1"
- fi
- if [ "$fault_code" = "$FAULT_CPE_INVALID_ARGUMENTS" ]; then
- break
- fi
- done
- if [ "$no_fault" = "1" ]; then fault_code="0"; fi
- fi
- fi
- if [ "$fault_code" != "0" ]; then
- let fault_code=$fault_code+9000
- ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
- fi
+ done
+ if [ "$no_fault" = "1" ]; then fault_code="0"; fi
+ fi
+ fi
+ if [ "$fault_code" != "0" ]; then
+ let fault_code=$fault_code+9000
+ ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
+ fi
fi
if [ "$action" = "set_value" ]; then
diff --git a/ext/openwrt/scripts/functions/wan_device
b/ext/openwrt/scripts/functions/wan_device
index a8b6361..9c7cd14 100644
--- a/ext/openwrt/scripts/functions/wan_device
+++ b/ext/openwrt/scripts/functions/wan_device
@@ -1,20 +1,38 @@
#!/bin/sh
# Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
+# Copyright (C) 2012-2013 Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
get_wan_device_mng_status() {
# TODO: Unconfigured ; Connecting ; Connected ; PendingDisconnect ;
Disconneting ; Disconnected
-local val="Connected"
-ubus_freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus"
"$val" "xsd:boolean"
+local val=""
+local type="xsd:boolean"
+local
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus"
+case "$action" in
+ get_value)
+ val="Connected"
+ ;;
+ get_name)
+ val="0"
+ ;;
+esac
+ubus_freecwmp_output "$parm" "$val" "$type"
}
get_wan_device_mng_interface_ip() {
-local val
+local val=""
local
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress"
-if [ -z "$default_wan_device_mng_interface_ip" ]; then
- val=`network_get_ipaddr val mng`
-else
- val=$default_wan_device_mng_interface_ip
-fi
+case "$action" in
+ get_value)
+ if [ -z "$default_wan_device_mng_interface_ip" ]; then
+ val=`network_get_ipaddr val mng`
+ else
+ val=$default_wan_device_mng_interface_ip
+ fi
+ ;;
+ get_name)
+ val="0"
+ ;;
+esac
if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
ubus_freecwmp_output "$parm" "$val"
else
@@ -25,11 +43,18 @@ fi
get_wan_device_mng_interface_mac() {
local val=""
local
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress"
-if [ -z "$default_wan_device_mng_interface_mac" ]; then
- val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
network.mng.macaddr`
-else
- val=$default_wan_device_mng_interface_mac
-fi
+case "$action" in
+ get_value)
+ if [ -z "$default_wan_device_mng_interface_mac" ]; then
+ val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
network.mng.macaddr`
+ else
+ val=$default_wan_device_mng_interface_mac
+ fi
+ ;;
+ get_name)
+ val="0"
+ ;;
+esac
if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
ubus_freecwmp_output "$parm" "$val"
else
@@ -38,11 +63,21 @@ fi
}
get_wan_device_wan_ppp_enable() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
network.wan.auto 2> /dev/null`
-if [ -z $val ]; then
+local val=""
+local type="xsd:boolean"
+local
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable"
+case "$action" in
+ get_value)
+ val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
network.wan.auto 2> /dev/null`
+ if [ -z $val ]; then
+ val="1"
+ fi
+ ;;
+ get_name)
val="1"
-fi
-ubus_freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable"
"$val" "xsd:boolean"
+ ;;
+esac
+ubus_freecwmp_output "$parm" "$val" "$type"
}
set_wan_device_wan_ppp_enable() {
@@ -57,8 +92,17 @@ fi
}
get_wan_device_wan_ppp_username() {
-local val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
network.wan.username 2> /dev/null`
-ubus_freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username"
"$val"
+local val=""
+local
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username"
+case "$action" in
+ get_value)
+ val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
network.wan.username 2> /dev/null`
+ ;;
+ get_name)
+ val="1"
+ ;;
+esac
+ubus_freecwmp_output "$parm" "$val"
}
set_wan_device_wan_ppp_username() {
@@ -67,8 +111,16 @@ set_wan_device_wan_ppp_username() {
get_wan_device_wan_ppp_password() {
local val=""
-val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
network.wan.password 2> /dev/null`
-ubus_freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password"
"$val"
+local
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password"
+case "$action" in
+ get_value)
+ val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get
network.wan.password 2> /dev/null`
+ ;;
+ get_name)
+ val="1"
+ ;;
+esac
+ubus_freecwmp_output "$parm" "$val"
}
set_wan_device_wan_ppp_password() {
@@ -162,6 +214,135 @@ esac
return $FAULT_CPE_INVALID_PARAMETER_NAME
}
+get_wan_device_name() {
+case "$1" in
+ InternetGatewayDevice.)
+ ubus_freecwmp_output "InternetGatewayDevice.WANDevice." "1"
+ if [ "$2" = "0" ]; then
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ get_wan_device_wan_ppp_enable
+ get_wan_device_wan_ppp_username
+ get_wan_device_wan_ppp_password
+ fi
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.WANDevice.)
+ ubus_freecwmp_output "InternetGatewayDevice.WANDevice." "1"
+ ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1." "1"
+ if [ "$2" = "0" ]; then
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ get_wan_device_wan_ppp_enable
+ get_wan_device_wan_ppp_username
+ get_wan_device_wan_ppp_password
+ fi
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.WANDevice.1.)
+ ubus_freecwmp_output "InternetGatewayDevice.WANDevice.1." "1"
+ ubus_freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice." "1"
+ if [ "$2" = "0" ]; then
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ get_wan_device_wan_ppp_enable
+ get_wan_device_wan_ppp_username
+ get_wan_device_wan_ppp_password
+ fi
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.WANDevice.1.WANConnectionDevice.)
+ ubus_freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice." "1"
+ ubus_freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1." "1"
+ if [ "$2" = "0" ]; then
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ get_wan_device_wan_ppp_enable
+ get_wan_device_wan_ppp_username
+ get_wan_device_wan_ppp_password
+ fi
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.)
+ ubus_freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1." "1"
+ ubus_freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection."
"1"
+ if [ "$2" = "0" ]; then
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ get_wan_device_wan_ppp_enable
+ get_wan_device_wan_ppp_username
+ get_wan_device_wan_ppp_password
+ fi
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.)
+ ubus_freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection."
"1"
+ ubus_freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1."
"1"
+ if [ "$2" = "0" ]; then
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ fi
+ return $FAULT_CPE_NO_FAULT
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.)
+ ubus_freecwmp_output
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1."
"1"
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ return $FAULT_CPE_NO_FAULT
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_wan_device_mng_status
+ return $FAULT_CPE_NO_FAULT
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_wan_device_mng_interface_ip
+ return $FAULT_CPE_NO_FAULT
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_wan_device_mng_interface_mac
+ return $FAULT_CPE_NO_FAULT
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_wan_device_wan_ppp_enable
+ return $FAULT_CPE_NO_FAULT
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_wan_device_wan_ppp_username
+ return $FAULT_CPE_NO_FAULT
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
+ if [ "$2" = "1" ]; then
+ return $FAULT_CPE_INVALID_ARGUMENTS
+ fi
+ get_wan_device_wan_ppp_password
+ return $FAULT_CPE_NO_FAULT
+ ;;
+esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
set_wan_device() {
case "$1" in
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
diff --git a/src/freecwmp.c b/src/freecwmp.c
index f4c9cb1..eb2783c 100644
--- a/src/freecwmp.c
+++ b/src/freecwmp.c
@@ -197,7 +197,7 @@ netlink_init(void)
void signal_kill_all_handler(int sig)
{
- pthread_exit(NULL);
+ pthread_exit(NULL);
}
--
1.7.4.1
>From 845c72048d1986a27482f97dd2d157068533023c Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:48:25 +0100
Subject: [PATCH 20/27] update the get notification in order to put the
returned data via ubus instead of pipe
TODO: develop the xml handle message to perform send of
GetParameterAttributeResponse
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
ext/openwrt/config/freecwmp | 6 ++++
ext/openwrt/scripts/freecwmp.sh | 27 +++++++++++++++++++-
ext/openwrt/scripts/functions/common | 21 +++++++++++++++-
src/ubus.c | 43
++++++++++++++++++++++++++++++++++
4 files changed, 94 insertions(+), 3 deletions(-)
diff --git a/ext/openwrt/config/freecwmp b/ext/openwrt/config/freecwmp
index 1379afd..1f72c27 100644
--- a/ext/openwrt/config/freecwmp
+++ b/ext/openwrt/config/freecwmp
@@ -30,24 +30,30 @@ config scripts
list location /usr/share/freecwmp/functions/device_info
list get_value_function get_device_info
list get_name_function get_device_info_name
+ list get_notification_function get_device_info_notification
list set_value_function set_device_info
list get_value_function get_device_info_generic
list get_name_function get_device_info_generic_name
+ list get_notification_function get_device_info_generic_notification
list set_value_function set_device_info_generic
list location /usr/share/freecwmp/functions/lan_device
list get_value_function get_lan_device
list get_name_function get_lan_device_name
+ list get_notification_function get_lan_device_notification
list set_value_function set_lan_device
list location /usr/share/freecwmp/functions/management_server
list get_value_function get_management_server
list get_name_function get_management_server_name
+ list get_notification_function get_management_server_notification
list set_value_function set_management_server
list get_value_function get_management_server_generic
list get_name_function get_management_server_generic_name
+ list get_notification_function
get_management_server_generic_notification
list set_value_function set_management_server_generic
list location /usr/share/freecwmp/functions/wan_device
list get_value_function get_wan_device
list get_name_function get_wan_device_name
+ list get_notification_function get_wan_device_notification
list set_value_function set_wan_device
list location /usr/share/freecwmp/functions/misc
list get_value_function get_misc
diff --git a/ext/openwrt/scripts/freecwmp.sh
b/ext/openwrt/scripts/freecwmp.sh
index a2f2bc1..02a923e 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -113,6 +113,7 @@ handle_scripts() {
config_list_foreach "$section" 'location' load_script
config_get get_value_functions "$section" "get_value_function"
config_get get_name_functions "$section" "get_name_function"
+ config_get get_notification_functions "$section"
"get_notification_function"
config_get set_value_functions "$section" "set_value_function"
}
@@ -219,8 +220,30 @@ if [ "$action" = "set_value" ]; then
fi
if [ "$action" = "get_notification" -o "$action" = "get_all" ]; then
- freecwmp_get_parameter_notification "x_notification" "$__arg1"
- freecwmp_notification_output "$__arg1" "$x_notification"
+ no_fault="0"
+ freecwmp_check_fault "$__arg1"
+ fault_code="$?"
+ if [ "$fault_code" = "0" ]; then
+ if [ \( "$__arg1" = "InternetGatewayDevice." \) -o \( "$__arg1"
= "" \) ]; then
+ __arg1="InternetGatewayDevice."
+ fi
+ for function_name in $get_notification_functions
+ do
+ $function_name "$__arg1"
+ fault_code="$?"
+ if [ "$fault_code" = "0" ]; then
+ no_fault="1"
+ fi
+ if [ "$fault_code" = "$FAULT_CPE_INVALID_ARGUMENTS" ]; then
+ break
+ fi
+ done
+ if [ "$no_fault" = "1" ]; then fault_code="0"; fi
+ fi
+ if [ "$fault_code" != "0" ]; then
+ let fault_code=$fault_code+9000
+ ubus_freecwmp_output "$__arg1" "" "" "$fault_code"
+ fi
fi
if [ "$action" = "set_notification" ]; then
diff --git a/ext/openwrt/scripts/functions/common
b/ext/openwrt/scripts/functions/common
index abba220..fd98a01 100644
--- a/ext/openwrt/scripts/functions/common
+++ b/ext/openwrt/scripts/functions/common
@@ -51,7 +51,9 @@ case "$action" in
get_name)
ubus call tr069 get_parameter_names '{"parameter": "'$parameter'",
"writable": "'$value'", "fault_code":"'$fault_code'"}' 2> /dev/null
;;
-
+ get_notification)
+ ubus call tr069 get_parameter_attributes '{"parameter":
"'$parameter'", "notification": "'$value'",
"fault_code":"'$fault_code'"}' 2> /dev/null
+ ;;
esac
}
freecwmp_value_output() {
@@ -151,6 +153,9 @@ freecwmp_config_notifications() {
if [ "$item" = "$3" ]; then
eval "export -- \"$4=2\""
return 0
+ elif [ "`echo $3|grep $item`" = "$3" ]; then
+ eval "export -- \"$4=2\""
+ return 0
fi
done
for item in $__passive
@@ -158,6 +163,9 @@ freecwmp_config_notifications() {
if [ "$item" = "$3" ]; then
eval "export -- \"$4=1\""
return 0
+ elif [ "`echo $3|grep $item`" = "$3" ]; then
+ eval "export -- \"$4=1\""
+ return 0
fi
done
}
@@ -193,7 +201,18 @@ freecwmp_get_parameter_notification() {
local _dest="$1"
local _parm="$2"
local _val
+ local _parent
config_foreach freecwmp_config_notifications "notifications" "get"
"$_parm" "_val"
+ if [ "$_val" = "" ]; then
+ if [ "`echo $_parm|grep '\.$'`" = "" ]; then
+ _parent="${_parm%.*}."
+ config_foreach freecwmp_config_notifications
"notifications" "get" "$_parent" "_val"
+ else
+ _parent="${_parm%.*.}."
+ config_foreach freecwmp_config_notifications
"notifications" "get" "$_parent" "_val"
+ fi
+ fi
+ if [ "$_val" = "" ];then _val="0" ;fi
eval "export -- \"$_dest=$_val\""
}
diff --git a/src/ubus.c b/src/ubus.c
index cbf94b0..072b2a1 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -5,6 +5,7 @@
* (at your option) any later version.
*
* Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
+ * Copyright (C) 2012 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
*/
#include <unistd.h>
@@ -239,12 +240,54 @@ freecwmpd_handle_get_param_names(struct
ubus_context *ctx, struct ubus_object *o
return 0;
}
+static enum get_param_attributes {
+ GET_PARAM_ATTRIBUTES_PARAM,
+ GET_PARAM_ATTRIBUTES_NOTIF,
+ GET_PARAM_ATTRIBUTES_FAULT,
+ __GET_PARAM_ATTRIBUTES_MAX
+};
+
+static const struct blobmsg_policy get_param_attributes_policy[] = {
+ [GET_PARAM_ATTRIBUTES_PARAM] = { .name = "parameter", .type =
BLOBMSG_TYPE_STRING },
+ [GET_PARAM_ATTRIBUTES_NOTIF] = { .name = "notification", .type =
BLOBMSG_TYPE_STRING },
+ [GET_PARAM_ATTRIBUTES_FAULT] = { .name = "fault_code", .type =
BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_get_param_attributes(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_ATTRIBUTES_MAX];
+
+ blobmsg_parse(get_param_attributes_policy,
ARRAY_SIZE(get_param_attributes_policy), tb,
+ blob_data(msg), blob_len(msg));
+
+ if (!tb[GET_PARAM_ATTRIBUTES_PARAM])
+ return UBUS_STATUS_INVALID_ARGUMENT;
+
+ if (!tb[GET_PARAM_ATTRIBUTES_NOTIF])
+ return UBUS_STATUS_INVALID_ARGUMENT;
+
+ freecwmp_log_message(NAME, L_NOTICE,
+ "triggered ubus get_parameter_attributes for the
parameter %s\n",
+ blobmsg_data(tb[GET_PARAM_ATTRIBUTES_PARAM]));
+
+
external_add_list_paramameter(blobmsg_data(tb[GET_PARAM_ATTRIBUTES_PARAM]),
+ blobmsg_data(tb[GET_PARAM_ATTRIBUTES_NOTIF]),
+ NULL,
+ blobmsg_data(tb[GET_PARAM_ATTRIBUTES_FAULT]));
+
+ 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),
UBUS_METHOD("get_parameter_names",
freecwmpd_handle_get_param_names, get_param_names_policy),
+ UBUS_METHOD("get_parameter_attributes",
freecwmpd_handle_get_param_attributes, get_param_attributes_policy),
};
static struct ubus_object_type main_object_type =
--
1.7.4.1
>From c05e7e39bb9573bdfaeb58af08165746b238ba12 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:54:48 +0100
Subject: [PATCH 21/27] update the data model parameter scripts in order
to output parameter and notification values via ubus
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
ext/openwrt/scripts/functions/device_info | 94 +++++++++++++++
ext/openwrt/scripts/functions/lan_device | 50 ++++++++
ext/openwrt/scripts/functions/management_server | 143
+++++++++++++++++++++++
ext/openwrt/scripts/functions/wan_device | 105 +++++++++++++++++
4 files changed, 392 insertions(+), 0 deletions(-)
diff --git a/ext/openwrt/scripts/functions/device_info
b/ext/openwrt/scripts/functions/device_info
index c3c6c33..2be20b5 100644
--- a/ext/openwrt/scripts/functions/device_info
+++ b/ext/openwrt/scripts/functions/device_info
@@ -1,5 +1,6 @@
#!/bin/sh
# Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
+# Copyright (C) 2012-2013 Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
get_device_info_manufacturer() {
local val=""
@@ -10,6 +11,9 @@ case "$action" in
get_name)
val="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val"
"InternetGatewayDevice.DeviceInfo.Manufacturer"
+ ;;
esac
ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.Manufacturer"
"$val"
}
@@ -27,6 +31,9 @@ case "$action" in
get_name)
val="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val"
"InternetGatewayDevice.DeviceInfo.ManufacturerOUI"
+ ;;
esac
ubus_freecwmp_output
"InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val"
}
@@ -44,6 +51,9 @@ case "$action" in
get_name)
val="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val"
"InternetGatewayDevice.DeviceInfo.ProductClass"
+ ;;
esac
ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.ProductClass"
"$val"
}
@@ -61,6 +71,9 @@ case "$action" in
get_name)
local val="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val"
"InternetGatewayDevice.DeviceInfo.SerialNumber"
+ ;;
esac
ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.SerialNumber"
"$val"
}
@@ -78,6 +91,9 @@ case "$action" in
get_name)
val="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val"
"InternetGatewayDevice.DeviceInfo.HardwareVersion"
+ ;;
esac
ubus_freecwmp_output
"InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val"
}
@@ -95,6 +111,9 @@ case "$action" in
get_name)
val="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val"
"InternetGatewayDevice.DeviceInfo.SoftwareVersion"
+ ;;
esac
ubus_freecwmp_output
"InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val"
}
@@ -112,6 +131,9 @@ case "$action" in
get_name)
val="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val"
"InternetGatewayDevice.DeviceInfo.UpTime"
+ ;;
esac
ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val"
}
@@ -129,6 +151,9 @@ case "$action" in
get_name)
val="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val"
"InternetGatewayDevice.DeviceInfo.DeviceLog"
+ ;;
esac
ubus_freecwmp_output "InternetGatewayDevice.DeviceInfo.DeviceLog" "$val"
}
@@ -281,6 +306,66 @@ 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)
@@ -354,6 +439,15 @@ get_device_info_generic_name() {
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"
+ ubus_freecwmp_output "$1" "$val"
+ return $FAULT_CPE_NO_FAULT
+}
+
set_device_info_generic() {
check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp"
-eq 1 ]; then return 0; fi
diff --git a/ext/openwrt/scripts/functions/lan_device
b/ext/openwrt/scripts/functions/lan_device
index 64910e2..949f11c 100644
--- a/ext/openwrt/scripts/functions/lan_device
+++ b/ext/openwrt/scripts/functions/lan_device
@@ -1,5 +1,6 @@
#!/bin/sh
# Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
+# Copyright (C) 2013 Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
get_wlan_enable() {
local num="$1"
@@ -21,6 +22,11 @@ case "$action" in
let num=$num+1
ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
;;
+ get_notification)
+ let num=$num+1
+ freecwmp_get_parameter_notification "val"
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable"
+ ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable" "$val"
+ ;;
esac
}
@@ -50,6 +56,11 @@ case "$action" in
let num=$num+1
ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
;;
+ get_notification)
+ let num=$num+1
+ freecwmp_get_parameter_notification "val"
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID"
+ ubus_freecwmp_output
"InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID" "$val"
+ ;;
esac
}
@@ -169,6 +180,45 @@ esac
return $FAULT_CPE_INVALID_PARAMETER_NAME
}
+get_lan_device_notification() {
+case "$1" in
+ InternetGatewayDevice.)
+ get_wlan_enable 0
+ get_wlan_ssid 0
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.LANDevice.)
+ get_wlan_enable 0
+ get_wlan_ssid 0
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.LANDevice.1.)
+ get_wlan_enable 0
+ get_wlan_ssid 0
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.LANDevice.1.WLANConfiguration.)
+ get_wlan_enable 0
+ get_wlan_ssid 0
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.)
+ get_wlan_enable 0
+ get_wlan_ssid 0
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
+ get_wlan_enable 0
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID)
+ get_wlan_ssid 0
+ return $FAULT_CPE_NO_FAULT
+ ;;
+esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
set_lan_device() {
case "$1" in
InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Enable)
diff --git a/ext/openwrt/scripts/functions/management_server
b/ext/openwrt/scripts/functions/management_server
index eed16d1..b1e759d 100644
--- a/ext/openwrt/scripts/functions/management_server
+++ b/ext/openwrt/scripts/functions/management_server
@@ -1,5 +1,6 @@
#!/bin/sh
# Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
+# Copyright (C) 2012-2013 Ahmed ZRIBI <ahmed.zribi@pivasoftware.com>
get_management_server_url() {
local tmp=${FLAGS_value}
@@ -17,6 +18,9 @@ case "$action" in
get_name)
val="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
ubus_freecwmp_output "$parm" "$val"
}
@@ -62,6 +66,9 @@ case "$action" in
get_name)
val="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
ubus_freecwmp_output "$parm" "$val"
}
@@ -80,6 +87,9 @@ case "$action" in
get_name)
val="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
ubus_freecwmp_output "$parm" "$val"
}
@@ -99,6 +109,9 @@ case "$action" in
get_name)
val="1"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
ubus_freecwmp_output "$parm" "$val" "$type"
}
@@ -119,6 +132,9 @@ case "$action" in
get_name)
val="1"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
ubus_freecwmp_output "$parm" "$val" "$type"
}
@@ -150,6 +166,9 @@ case "$action" in
get_name)
val="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
ubus_freecwmp_output "$parm" "$val"
}
@@ -164,6 +183,9 @@ case "$action" in
get_name)
val="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
ubus_freecwmp_output "$parm" "$val"
}
@@ -182,6 +204,9 @@ case "$action" in
get_name)
val="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
ubus_freecwmp_output "$parm" "$val"
}
@@ -202,6 +227,9 @@ case "$action" in
get_name)
val="1"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
ubus_freecwmp_output "$parm" "$val"
@@ -224,6 +252,9 @@ case "$action" in
get_name)
val="1"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
ubus_freecwmp_output "$parm" "$val"
@@ -250,6 +281,9 @@ case "$action" in
get_name)
val="1"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
ubus_freecwmp_output "$parm" "$val"
@@ -272,6 +306,9 @@ case "$action" in
get_name)
val="1"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
ubus_freecwmp_output "$parm" "$val"
@@ -294,6 +331,9 @@ case "$action" in
get_name)
val="1"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
ubus_freecwmp_output "$parm" "$val"
@@ -536,6 +576,100 @@ esac
return $FAULT_CPE_INVALID_PARAMETER_NAME
}
+get_management_server_notification() {
+case "$1" in
+ InternetGatewayDevice.)
+ get_management_server_url
+ get_management_server_username
+ get_management_server_password
+ get_management_server_periodic_inform_enable
+ get_management_server_periodic_inform_interval
+ get_management_server_connection_request_url
+ get_management_server_connection_request_username
+ get_management_server_connection_request_password
+ get_management_server_x_freecwmp_org__acs_scheme
+ get_management_server_x_freecwmp_org__acs_hostname
+ get_management_server_x_freecwmp_org__acs_port
+ get_management_server_x_freecwmp_org__acs_path
+ get_management_server_x_freecwmp_org__connection_request_port
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.)
+ get_management_server_url
+ get_management_server_username
+ get_management_server_password
+ get_management_server_periodic_inform_enable
+ get_management_server_periodic_inform_interval
+ get_management_server_connection_request_url
+ get_management_server_connection_request_username
+ get_management_server_connection_request_password
+ get_management_server_x_freecwmp_org__acs_scheme
+ get_management_server_x_freecwmp_org__acs_hostname
+ get_management_server_x_freecwmp_org__acs_port
+ get_management_server_x_freecwmp_org__acs_path
+ get_management_server_x_freecwmp_org__connection_request_port
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.URL)
+ get_management_server_url
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.Username)
+ get_management_server_username
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.Password)
+ get_management_server_password
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.PeriodicInformEnable)
+ get_management_server_periodic_inform_enable
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.PeriodicInformInterval)
+ get_management_server_periodic_inform_interval
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.ConnectionRequestURL)
+ get_management_server_connection_request_url
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.ConnectionRequestUsername)
+ get_management_server_connection_request_username
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.ConnectionRequestPassword)
+ get_management_server_connection_request_password
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme)
+ get_management_server_x_freecwmp_org__acs_scheme
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname)
+ get_management_server_x_freecwmp_org__acs_hostname
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port)
+ get_management_server_x_freecwmp_org__acs_port
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path)
+ get_management_server_x_freecwmp_org__acs_path
+ return $FAULT_CPE_NO_FAULT
+ ;;
+
InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port)
+ get_management_server_x_freecwmp_org__connection_request_port
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.ManagementServer.ParameterKey)
+ get_management_server_parameter_key
+ return $FAULT_CPE_NO_FAULT
+ ;;
+esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
set_management_server() {
case "$1" in
InternetGatewayDevice.ManagementServer.URL)
@@ -606,6 +740,15 @@ get_management_server_generic_name() {
return $FAULT_CPE_NO_FAULT
}
+get_management_server_generic_notification() {
+ check_parameter_management_server_generic "$1" ; _tmp=$? ; if [
"$_tmp" -eq 1 ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
+
+ local val
+ freecwmp_get_parameter_notification "val" "$1"
+ ubus_freecwmp_output "$1" "$val"
+ return $FAULT_CPE_NO_FAULT
+}
+
set_management_server_generic() {
check_parameter_management_server_generic "$1" ; _tmp=$? ; if [
"$_tmp" -eq 1 ]; then return 0; fi
diff --git a/ext/openwrt/scripts/functions/wan_device
b/ext/openwrt/scripts/functions/wan_device
index 9c7cd14..02ba365 100644
--- a/ext/openwrt/scripts/functions/wan_device
+++ b/ext/openwrt/scripts/functions/wan_device
@@ -14,6 +14,9 @@ case "$action" in
get_name)
val="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
ubus_freecwmp_output "$parm" "$val" "$type"
}
@@ -32,6 +35,9 @@ case "$action" in
get_name)
val="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
ubus_freecwmp_output "$parm" "$val"
@@ -54,6 +60,9 @@ case "$action" in
get_name)
val="0"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
if [ "$FLAGS_value" != "${FLAGS_TRUE}" ]; then
ubus_freecwmp_output "$parm" "$val"
@@ -76,6 +85,9 @@ case "$action" in
get_name)
val="1"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
ubus_freecwmp_output "$parm" "$val" "$type"
}
@@ -101,6 +113,9 @@ case "$action" in
get_name)
val="1"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
ubus_freecwmp_output "$parm" "$val"
}
@@ -119,6 +134,9 @@ case "$action" in
get_name)
val="1"
;;
+ get_notification)
+ freecwmp_get_parameter_notification "val" "$parm"
+ ;;
esac
ubus_freecwmp_output "$parm" "$val"
}
@@ -343,6 +361,93 @@ esac
return $FAULT_CPE_INVALID_PARAMETER_NAME
}
+get_wan_device_notification() {
+case "$1" in
+ InternetGatewayDevice.)
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ get_wan_device_wan_ppp_enable
+ get_wan_device_wan_ppp_username
+ get_wan_device_wan_ppp_password
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.WANDevice.)
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ get_wan_device_wan_ppp_enable
+ get_wan_device_wan_ppp_username
+ get_wan_device_wan_ppp_password
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.WANDevice.1.)
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ get_wan_device_wan_ppp_enable
+ get_wan_device_wan_ppp_username
+ get_wan_device_wan_ppp_password
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.WANDevice.1.WANConnectionDevice.)
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ get_wan_device_wan_ppp_enable
+ get_wan_device_wan_ppp_username
+ get_wan_device_wan_ppp_password
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.)
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ get_wan_device_wan_ppp_enable
+ get_wan_device_wan_ppp_username
+ get_wan_device_wan_ppp_password
+ return $FAULT_CPE_NO_FAULT
+ ;;
+ InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.)
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ return $FAULT_CPE_NO_FAULT
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.)
+ get_wan_device_mng_status
+ get_wan_device_mng_interface_ip
+ get_wan_device_mng_interface_mac
+ return $FAULT_CPE_NO_FAULT
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ConnectionStatus)
+ get_wan_device_mng_status
+ return $FAULT_CPE_NO_FAULT
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress)
+ get_wan_device_mng_interface_ip
+ return $FAULT_CPE_NO_FAULT
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.MACAddress)
+ get_wan_device_mng_interface_mac
+ return $FAULT_CPE_NO_FAULT
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
+ get_wan_device_wan_ppp_enable
+ return $FAULT_CPE_NO_FAULT
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username)
+ get_wan_device_wan_ppp_username
+ return $FAULT_CPE_NO_FAULT
+ ;;
+
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password)
+ get_wan_device_wan_ppp_password
+ return $FAULT_CPE_NO_FAULT
+ ;;
+esac
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+}
+
set_wan_device() {
case "$1" in
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable)
--
1.7.4.1
>From 88b4d1d784e713e59455079dca11a7548fee2f4b Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 21:59:55 +0100
Subject: [PATCH 22/27] update xml handler set parameter values in order
to execute external command and get response via ubus
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
src/external.c | 36 ++++++++++++++++++++++++++-
src/external.h | 5 +++-
src/ubus.c | 73
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/xml.c | 25 +++++++++++++-----
4 files changed, 130 insertions(+), 9 deletions(-)
diff --git a/src/external.c b/src/external.c
index 4973d1a..7eec751 100644
--- a/src/external.c
+++ b/src/external.c
@@ -5,6 +5,7 @@
* (at your option) any later version.
*
* Copyright (C) 2011 Luka Perkov <freecwmp@lukaperkov.net>
+ * Copyright (C) 2012 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
*/
#include <errno.h>
@@ -27,6 +28,8 @@
static struct uloop_process uproc;
pthread_t ubus_thread;
LIST_HEAD(external_list_parameter);
+char *external_method_status = NULL;
+char *external_method_fault = NULL;
void *thread_uloop_run (void *v)
{
@@ -60,6 +63,18 @@ void external_free_list_parameter()
}
}
+void external_set_param_val_resp_status(char *status)
+{
+ free(external_method_status);
+ external_method_status = status ? strdup(status) : NULL;
+}
+
+void external_fetch_set_param_val_resp_status(char **status)
+{
+ *status = external_method_status;
+ external_method_status = NULL;
+}
+
int external_get_action_data(char *action, char *name, char **value)
{
struct external_parameter *external_parameter;
@@ -229,9 +244,25 @@ int external_set_action_write(char *action, char
*name, char *value)
return 0;
}
-int external_set_action_execute()
+int external_set_action_execute(char *action)
{
freecwmp_log_message(NAME, L_NOTICE, "executing set script\n");
+ FILE *fp;
+
+ if (access(fc_script_set_actions, R_OK | W_OK | F_OK) == -1)
+ return -1;
+
+ fp = fopen(fc_script_set_actions, "a");
+ if (!fp) return -1;
+
+#ifdef DUMMY_MODE
+ fprintf(fp, "/bin/sh `pwd`/%s apply %s\n", fc_script, action);
+#else
+ fprintf(fp, "/bin/sh %s apply %s\n", fc_script, action);
+#endif
+
+ fclose(fp);
+ pthread_create(&ubus_thread, NULL, &thread_uloop_run, NULL);
if ((uproc.pid = fork()) == -1) {
return -1;
@@ -258,6 +289,9 @@ int external_set_action_execute()
DD("waiting for child to exit");
}
+ pthread_cancel(ubus_thread);
+ pthread_join(ubus_thread,NULL);
+
// TODO: add some kind of checks
if (remove(fc_script_set_actions) != 0)
diff --git a/src/external.h b/src/external.h
index 8e82c39..77165ee 100644
--- a/src/external.h
+++ b/src/external.h
@@ -5,6 +5,7 @@
* (at your option) any later version.
*
* Copyright (C) 2011 Luka Perkov <freecwmp@lukaperkov.net>
+ * Copyright (C) 2012 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
*/
#ifndef _FREECWMP_EXTERNAL_H__
@@ -27,12 +28,14 @@ struct external_parameter {
char *fault_code;
};
+void external_set_param_val_resp_status (char *status);
+void external_fetch_set_param_val_resp_status (char **status);
int external_get_action(char *action, char *name, char *arg);
int external_get_action_data(char *action, char *name, char **value);
int external_get_action_write(char *action, char *name, char *arg);
int external_get_action_execute();
int external_set_action_write(char *action, char *name, char *value);
-int external_set_action_execute();
+int external_set_action_execute(char *action);
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);
diff --git a/src/ubus.c b/src/ubus.c
index 072b2a1..e852ed4 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -281,11 +281,84 @@ freecwmpd_handle_get_param_attributes(struct
ubus_context *ctx, struct ubus_obje
return 0;
}
+static enum set_param_values_fault {
+ SET_PARAM_VALUES_FAULT_PARAM,
+ SET_PARAM_VALUES_FAULT__FAULT,
+ __SET_PARAM_VALUES_FAULT_MAX
+};
+
+static const struct blobmsg_policy set_param_values_fault_policy[] = {
+ [SET_PARAM_VALUES_FAULT_PARAM] = { .name = "parameter", .type =
BLOBMSG_TYPE_STRING },
+ [SET_PARAM_VALUES_FAULT__FAULT] = { .name = "fault_code", .type =
BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_set_param_values_fault(struct ubus_context *ctx,
struct ubus_object *obj,
+ struct ubus_request_data *req, const char *method,
+ struct blob_attr *msg)
+{
+ struct blob_attr *tb[__SET_PARAM_VALUES_FAULT_MAX];
+
+ blobmsg_parse(set_param_values_fault_policy,
ARRAY_SIZE(set_param_values_fault_policy), tb,
+ blob_data(msg), blob_len(msg));
+
+ if (!tb[SET_PARAM_VALUES_FAULT_PARAM])
+ return UBUS_STATUS_INVALID_ARGUMENT;
+
+ if (!tb[SET_PARAM_VALUES_FAULT__FAULT])
+ return UBUS_STATUS_INVALID_ARGUMENT;
+
+
+ freecwmp_log_message(NAME, L_NOTICE,
+ "triggered ubus set_parameter_values_fault for the
parameter %s\n",
+ blobmsg_data(tb[SET_PARAM_VALUES_FAULT_PARAM]));
+
+
+
external_add_list_paramameter(blobmsg_data(tb[SET_PARAM_VALUES_FAULT_PARAM]),
+ NULL,
+ NULL,
+ blobmsg_data(tb[SET_PARAM_VALUES_FAULT__FAULT]));
+
+ return 0;
+}
+
+static enum set_param_values_status {
+ SET_PARAM_VALUES_STATUS_STATUS,
+ __SET_PARAM_VALUES_STATUS_MAX
+};
+
+static const struct blobmsg_policy set_param_values_status_policy[] = {
+ [SET_PARAM_VALUES_STATUS_STATUS] = { .name = "status", .type =
BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_set_param_values_status(struct ubus_context *ctx,
struct ubus_object *obj,
+ struct ubus_request_data *req, const char *method,
+ struct blob_attr *msg)
+{
+ struct blob_attr *tb[__SET_PARAM_VALUES_STATUS_MAX];
+
+ blobmsg_parse(set_param_values_status_policy,
ARRAY_SIZE(set_param_values_status_policy), tb,
+ blob_data(msg), blob_len(msg));
+
+ if (!tb[SET_PARAM_VALUES_STATUS_STATUS])
+ return UBUS_STATUS_INVALID_ARGUMENT;
+
+
+ freecwmp_log_message(NAME, L_NOTICE,
+ "triggered ubus set_parameter_values_status\n");
+
+
external_set_param_val_resp_status(blobmsg_data(tb[SET_PARAM_VALUES_STATUS_STATUS]));
+
+ 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),
+ UBUS_METHOD("set_parameter_values_fault",
freecwmpd_handle_set_param_values_fault, set_param_values_fault_policy),
+ UBUS_METHOD("set_parameter_values_status",
freecwmpd_handle_set_param_values_status, set_param_values_status_policy),
UBUS_METHOD("get_parameter_names",
freecwmpd_handle_get_param_names, get_param_names_policy),
UBUS_METHOD("get_parameter_attributes",
freecwmpd_handle_get_param_attributes, get_param_attributes_policy),
};
diff --git a/src/xml.c b/src/xml.c
index c735244..a8f82c7 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -578,6 +578,7 @@ int xml_handle_set_parameter_values(mxml_node_t
*body_in,
mxml_node_t *b = body_in;
char *parameter_name = NULL;
char *parameter_value = NULL;
+ char *status=NULL;
while (b) {
if (b && b->type == MXML_TEXT &&
@@ -602,25 +603,35 @@ int xml_handle_set_parameter_values(mxml_node_t
*body_in,
b = mxmlWalkNext(b, body_in, MXML_DESCEND);
}
- if (external_set_action_execute())
+ if (external_set_action_execute("value"))
return -1;
+ // TODO KMD add here check for fault return from ubus
+
+ external_fetch_set_param_val_resp_status(&status);
+ if(!status) return -1; //TODO KMD return a fault message here
+
config_load();
b = mxmlFindElement(tree_out, tree_out, "soap_env:Body",
NULL, NULL, MXML_DESCEND);
- if (!b) return -1;
+ if (!b) goto error;
b = mxmlNewElement(b, "cwmp:SetParameterValuesResponse");
- if (!b) return -1;
+ if (!b) goto error;
b = mxmlNewElement(b, "Status");
- if (!b) return -1;
+ if (!b) goto error;
- b = mxmlNewText(b, 0, "1");
- if (!b) return -1;
+ b = mxmlNewText(b, 0, status);
+ if (!b) goto error;
+ free(status);
return 0;
+
+error:
+ free(status);
+ return-1;
}
int xml_handle_get_parameter_values(mxml_node_t *body_in,
@@ -899,7 +910,7 @@ static int
xml_handle_set_parameter_attributes(mxml_node_t *body_in,
b = mxmlWalkNext(b, n, MXML_DESCEND);
}
- if (external_set_action_execute())
+ if (external_set_action_execute("notification"))
return -1;
b = mxmlFindElement(tree_out, tree_out, "soap_env:Body", NULL,
NULL, MXML_DESCEND);
--
1.7.4.1
>From a9c1843214b8f281e1df7136bf989f3d07e5e7bc Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 22:03:15 +0100
Subject: [PATCH 23/27] update common script and freecwmp.sh script in
order to have the functions for set parameter values working with ubus
Contributed by Inteno Broadband Technology AB & PIVA SOFTWARE
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
ext/openwrt/scripts/freecwmp.sh | 58
+++++++++++++++++++++++++++++++--
ext/openwrt/scripts/functions/common | 20 ++++++++++++
2 files changed, 74 insertions(+), 4 deletions(-)
diff --git a/ext/openwrt/scripts/freecwmp.sh
b/ext/openwrt/scripts/freecwmp.sh
index 02a923e..54c0924 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -90,6 +90,15 @@ case "$1" in
reboot)
action="reboot"
;;
+ apply)
+ if [ "$2" = "notification" ]; then
+ action="apply_notification"
+ elif [ "$2" = "value" ]; then
+ action="apply_value"
+ else
+ action="apply_value"
+ fi
+ ;;
esac
if [ -z "$action" ]; then
@@ -213,10 +222,30 @@ if [ "$action" = "get_name" -o "$action" =
"get_all" ]; then
fi
if [ "$action" = "set_value" ]; then
- for function_name in $set_value_functions
- do
- $function_name "$__arg1" "$__arg2"
- done
+ no_fault="0"
+ freecwmp_check_fault "$__arg1"
+ fault_code="$?"
+ if [ "$fault_code" = "0" ]; then
+ if [ \( "$__arg1" = "InternetGatewayDevice." \) -o \( "$__arg1"
= "" \) ]; then
+ __arg1="InternetGatewayDevice."
+ fi
+ for function_name in $set_value_functions
+ do
+ $function_name "$__arg1" "$__arg2"
+ fault_code="$?"
+ if [ "$fault_code" = "0" ]; then
+ no_fault="1"
+ fi
+ if [ "$fault_code" = "$FAULT_CPE_INVALID_ARGUMENTS" ]; then
+ break
+ fi
+ done
+ if [ "$no_fault" = "1" ]; then fault_code="0"; fi
+ fi
+ if [ "$fault_code" != "0" ]; then
+ let fault_code=$fault_code+9000
+ freecwmp_set_parameter_fault "$__arg1" "$fault_code"
+ fi
fi
if [ "$action" = "get_notification" -o "$action" = "get_all" ]; then
@@ -295,6 +324,27 @@ if [ "$action" = "reboot" ]; then
fi
fi
+if [ \( "$action" = "apply_notification" \) -o \( "$action" =
"apply_value" \) ]; then
+ __fault_count=`cat /var/state/freecwmp 2> /dev/null |wc -l 2>
/dev/null`
+ let __fault_count=$__fault_count/3
+ if [ "$__fault_count" = "0" ]; then
+ # applying
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+ if [ "$action" = "apply_value" ]; then ubus call tr069
set_parameter_values_status '{"status": "0"}'; fi
+ else
+ let n=$__fault_count-1
+ for i in `seq 0 $n`
+ do
+ local parm=`/sbin/uci -P /var/state get
freecwmp.@fault[$i].parameter 2> /dev/null`
+ local fault_code=`/sbin/uci -P /var/state get
freecwmp.@fault[$i].fault_code 2> /dev/null`
+ ubus_freecwmp_fault_output "$parm" "$fault_code"
+ done
+ rm -rf /var/state/freecwmp 2> /dev/null
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} revert freecwmp
+ fi
+fi
+
+
if [ ${FLAGS_debug} -eq ${FLAGS_TRUE} ]; then
echo "[debug] exited at \"`date`\""
fi
diff --git a/ext/openwrt/scripts/functions/common
b/ext/openwrt/scripts/functions/common
index fd98a01..f701eb9 100644
--- a/ext/openwrt/scripts/functions/common
+++ b/ext/openwrt/scripts/functions/common
@@ -56,6 +56,16 @@ case "$action" in
;;
esac
}
+
+ubus_freecwmp_fault_output() {
+local parameter="$1"
+local fault_code="$2"
+case "$action" in
+ apply_value)
+ ubus call tr069 set_parameter_values_fault '{"parameter":
"'$parameter'", "fault_code":"'$fault_code'"}' 2> /dev/null
+ ;;
+esac
+}
freecwmp_value_output() {
freecwmp_output "$1" "$2" "V"
}
@@ -295,3 +305,13 @@ if [ "$1" = "." ]; then
fi
return $FAULT_CPE_NO_FAULT
}
+
+freecwmp_set_parameter_fault() {
+ local _parm="$1"
+ local _fault="$2"
+ /sbin/uci -P /var/state batch << EOF 2>&1 >/dev/null
+ add freecwmp fault
+ set freecwmp.@fault[-1].parameter="$_parm"
+ set freecwmp.@fault[-1].fault_code="$_fault"
+EOF
+}
--
1.7.4.1
>From 329db01dec815e97e2a7e081f1f21a5b88499467 Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 22:22:09 +0100
Subject: [PATCH 24/27] update dm script to send the output of set
parameter function to the ubus
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
ext/openwrt/scripts/functions/device_info | 62 +++++++-
ext/openwrt/scripts/functions/lan_device | 33 +++--
ext/openwrt/scripts/functions/management_server | 178
+++++++++++++++++------
ext/openwrt/scripts/functions/wan_device | 41 ++++--
4 files changed, 238 insertions(+), 76 deletions(-)
diff --git a/ext/openwrt/scripts/functions/device_info
b/ext/openwrt/scripts/functions/device_info
index 2be20b5..5fe2823 100644
--- a/ext/openwrt/scripts/functions/device_info
+++ b/ext/openwrt/scripts/functions/device_info
@@ -19,7 +19,13 @@ ubus_freecwmp_output
"InternetGatewayDevice.DeviceInfo.Manufacturer" "$val"
}
set_device_info_manufacturer() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@device[0].manufacturer="$1"
+local val=$1
+local parm="InternetGatewayDevice.DeviceInfo.Manufacturer"
+case "$action" in
+ set_value)
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@device[0].manufacturer="$val"
+ ;;
+esac
}
get_device_info_oui() {
@@ -39,7 +45,13 @@ ubus_freecwmp_output
"InternetGatewayDevice.DeviceInfo.ManufacturerOUI" "$val"
}
set_device_info_oui() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@device[0].oui="$1"
+local val=$1
+local parm="InternetGatewayDevice.DeviceInfo.ManufacturerOUI"
+case "$action" in
+ set_value)
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@device[0].oui="$val"
+ ;;
+esac
}
get_device_info_product_class() {
@@ -59,7 +71,13 @@ ubus_freecwmp_output
"InternetGatewayDevice.DeviceInfo.ProductClass" "$val"
}
set_device_info_product_class() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@device[0].product_class="$1"
+local val=$1
+local parm="InternetGatewayDevice.DeviceInfo.ProductClass"
+case "$action" in
+ set_value)
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@device[0].product_class="$val"
+ ;;
+esac
}
get_device_info_serial_number() {
@@ -79,7 +97,13 @@ ubus_freecwmp_output
"InternetGatewayDevice.DeviceInfo.SerialNumber" "$val"
}
set_device_info_serial_number() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@device[0].serial_number="$1"
+local val=$1
+local parm="InternetGatewayDevice.DeviceInfo.SerialNumber"
+case "$action" in
+ set_value)
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@device[0].serial_number="$val"
+ ;;
+esac
}
get_device_info_hardware_version() {
@@ -99,7 +123,13 @@ ubus_freecwmp_output
"InternetGatewayDevice.DeviceInfo.HardwareVersion" "$val"
}
set_device_info_hardware_version() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@device[0].hardware_version="$1"
+local val=$1
+local parm="InternetGatewayDevice.DeviceInfo.HardwareVersion"
+case "$action" in
+ set_value)
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@device[0].hardware_version="$val"
+ ;;
+esac
}
get_device_info_software_version() {
@@ -119,7 +149,13 @@ ubus_freecwmp_output
"InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val"
}
set_device_info_software_version() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@device[0].software_version="$1"
+local val=$1
+local parm="InternetGatewayDevice.DeviceInfo.SoftwareVersion"
+case "$action" in
+ set_value)
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@device[0].software_version="$val"
+ ;;
+esac
}
get_device_info_uptime() {
@@ -370,24 +406,31 @@ 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
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+return $FAULT_CPE_INVALID_PARAMETER_NAME
+# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
}
check_parameter_device_info_generic() {
@@ -449,8 +492,9 @@ get_device_info_generic_notification() {
}
set_device_info_generic() {
- check_parameter_device_info_generic "$1" ; _tmp=$? ; if [ "$_tmp"
-eq 1 ]; then return 0; fi
+ 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"
- /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+ # /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 949f11c..db90021 100644
--- a/ext/openwrt/scripts/functions/lan_device
+++ b/ext/openwrt/scripts/functions/lan_device
@@ -33,13 +33,18 @@ esac
set_wlan_enable() {
local num="$1"
local val="$2"
-if [ "$val" = "1" ]; then
- val="0"
-else
- val="1"
-fi
-delay_command "wifi" "wifi" "45"
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
wireless.@wifi-device[$num].disabled="$val"
+local
parm="InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.Enable"
+case $action in
+ set_value)
+ if [ "$val" = "1" ]; then
+ val="0"
+ else
+ val="1"
+ fi
+ delay_command "wifi" "wifi" "45"
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
wireless.@wifi-device[$num].disabled="$val"
+ ;;
+esac
}
get_wlan_ssid() {
@@ -68,8 +73,13 @@ esac
set_wlan_ssid() {
local num="$1"
local val="$2"
-delay_command "wifi" "wifi" "45"
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
wireless.@wifi-iface[$num].ssid="$val"
+local parm="InternetGatewayDevice.LANDevice.1.WLANConfiguration.$num.SSID"
+case $action in
+ set_value)
+ delay_command "wifi" "wifi" "45"
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
wireless.@wifi-iface[$num].ssid="$val"
+ ;;
+esac
}
get_lan_device() {
@@ -223,10 +233,13 @@ set_lan_device() {
case "$1" in
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
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+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 b1e759d..37b1cb0 100644
--- a/ext/openwrt/scripts/functions/management_server
+++ b/ext/openwrt/scripts/functions/management_server
@@ -26,34 +26,39 @@ ubus_freecwmp_output "$parm" "$val"
}
set_management_server_url() {
-local url=$1
-local scheme
-local hostname
-local path
-local port
-
-scheme=`echo $url | awk -F "://" '{ print $1 }'`
-hostname=`echo $url | awk -F "$scheme://" '{ print $2 }' | awk -F ":"
'{ print $1 }' | awk -F "/" '{ print $1 }'`
-port=`echo $url | awk -F "$scheme://$hostname:" '{ print $2 }' | awk -F
'/' '{ print $1 }'`
-
-if [ -z "$port" ]; then
- port=80
- path=`echo $url | awk -F "$scheme://$hostname" '{ print $2 }'`
- echo 123 $path
-else
- path=`echo $url | awk -F "$scheme://$hostname:$port" '{ print $2 }'`
-fi
-
-if [ -z "$path" ]; then
- path="/"
-fi
-
-set_management_server_x_freecwmp_org__acs_scheme $scheme
-set_management_server_x_freecwmp_org__acs_hostname $hostname
-set_management_server_x_freecwmp_org__acs_port $port
-set_management_server_x_freecwmp_org__acs_path $path
-
-ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 inform '{ "event":
"value_change" }' &
+local parm="InternetGatewayDevice.ManagementServer.URL"
+case "$action" in
+ set_value)
+ local url=$1
+ local scheme
+ local hostname
+ local path
+ local port
+
+ scheme=`echo $url | awk -F "://" '{ print $1 }'`
+ hostname=`echo $url | awk -F "$scheme://" '{ print $2 }' | awk -F
":" '{ print $1 }' | awk -F "/" '{ print $1 }'`
+ port=`echo $url | awk -F "$scheme://$hostname:" '{ print $2 }' |
awk -F '/' '{ print $1 }'`
+
+ if [ -z "$port" ]; then
+ port=80
+ path=`echo $url | awk -F "$scheme://$hostname" '{ print $2 }'`
+ echo 123 $path
+ else
+ path=`echo $url | awk -F "$scheme://$hostname:$port" '{ print
$2 }'`
+ fi
+
+ if [ -z "$path" ]; then
+ path="/"
+ fi
+
+ set_management_server_x_freecwmp_org__acs_scheme $scheme
+ set_management_server_x_freecwmp_org__acs_hostname $hostname
+ set_management_server_x_freecwmp_org__acs_port $port
+ set_management_server_x_freecwmp_org__acs_path $path
+
+ ubus ${UBUS_SOCKET:+-s $UBUS_SOCKET} call tr069 inform '{ "event":
"value_change" }' &
+ ;;
+esac
}
get_management_server_username() {
@@ -74,7 +79,13 @@ ubus_freecwmp_output "$parm" "$val"
}
set_management_server_username() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@acs[0].username="$1"
+local val=$1
+local parm="InternetGatewayDevice.ManagementServer.Username"
+case "$action" in
+ set_value)
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@acs[0].username="$val"
+ ;;
+esac
}
get_management_server_password() {
@@ -95,7 +106,13 @@ ubus_freecwmp_output "$parm" "$val"
}
set_management_server_password() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@acs[0].password="$1"
+local val=$1
+local parm="InternetGatewayDevice.ManagementServer.Password"
+case "$action" in
+ set_value)
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@acs[0].password="$val"
+ ;;
+esac
}
get_management_server_periodic_inform_enable() {
@@ -117,8 +134,13 @@ ubus_freecwmp_output "$parm" "$val" "$type"
}
set_management_server_periodic_inform_enable() {
+local val=$1
local parm="InternetGatewayDevice.ManagementServer.PeriodicInformEnable"
-freecwmp_set_parameter_value "$parm" "$1"
+case "$action" in
+ set_value)
+ freecwmp_set_parameter_value "$parm" "$val"
+ ;;
+esac
}
get_management_server_periodic_inform_interval() {
@@ -140,8 +162,13 @@ ubus_freecwmp_output "$parm" "$val" "$type"
}
set_management_server_periodic_inform_interval() {
+local val=$1
local parm="InternetGatewayDevice.ManagementServer.PeriodicInformInterval"
-freecwmp_set_parameter_value "$parm" "$1"
+case "$action" in
+ set_value)
+ freecwmp_set_parameter_value "$parm" "$val"
+ ;;
+esac
}
get_management_server_connection_request_url() {
@@ -191,7 +218,13 @@ ubus_freecwmp_output "$parm" "$val"
}
set_management_server_connection_request_username() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@local[0].username="$1"
+local val=$1
+local
parm="InternetGatewayDevice.ManagementServer.ConnectionRequestUsername"
+case "$action" in
+ set_value)
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@local[0].username="$val"
+ ;;
+esac
}
get_management_server_connection_request_password() {
@@ -212,7 +245,13 @@ ubus_freecwmp_output "$parm" "$val"
}
set_management_server_connection_request_password() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@local[0].password="$1"
+local val=$1
+local
parm="InternetGatewayDevice.ManagementServer.ConnectionRequestPassword"
+case "$action" in
+ set_value)
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@local[0].password="$val"
+ ;;
+esac
}
# TODO: InternetGatewayDevice.ManagementServer.PeriodicInformTime
@@ -239,7 +278,13 @@ fi
}
set_management_server_x_freecwmp_org__acs_scheme() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@acs[0].scheme="$1"
+local val=$1
+local
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Scheme"
+case "$action" in
+ set_value)
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@acs[0].scheme="$val"
+ ;;
+esac
}
get_management_server_x_freecwmp_org__acs_hostname() {
@@ -264,11 +309,17 @@ fi
}
set_management_server_x_freecwmp_org__acs_hostname() {
-if [ -z "$default_management_server_acs_hostname" ]; then
- /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@acs[0].hostname="$1"
-else
- /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@acs[0].hostname="$default_management_server_acs_hostname"
-fi
+local val=$1
+local
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Hostname"
+case "$action" in
+ set_value)
+ if [ -z "$default_management_server_acs_hostname" ]; then
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@acs[0].hostname="$val"
+ else
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@acs[0].hostname="$default_management_server_acs_hostname"
+ fi
+ ;;
+esac
}
get_management_server_x_freecwmp_org__acs_port() {
@@ -293,7 +344,13 @@ fi
}
set_management_server_x_freecwmp_org__acs_port() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@acs[0].port="$1"
+local val=$1
+local
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Port"
+case "$action" in
+ set_value)
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@acs[0].port="$val"
+ ;;
+esac
}
get_management_server_x_freecwmp_org__acs_path() {
@@ -318,7 +375,13 @@ fi
}
set_management_server_x_freecwmp_org__acs_path() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@acs[0].path="$1"
+local val=$1
+local
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__ACS_Path"
+case "$action" in
+ set_value)
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@acs[0].path="$val"
+ ;;
+esac
}
get_management_server_x_freecwmp_org__connection_request_port() {
@@ -343,7 +406,13 @@ fi
}
set_management_server_x_freecwmp_org__connection_request_port() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@local[0].port="$1"
+local val=$1
+local
parm="InternetGatewayDevice.ManagementServer.X_freecwmp_org__Connection_Request_Port"
+case "$action" in
+ set_value)
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
freecwmp.@local[0].port="$val"
+ ;;
+esac
}
get_management_server() {
@@ -674,45 +743,59 @@ set_management_server() {
case "$1" in
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)
- get_management_server_x_freecwmp_org__acs_hostname "$2"
+ 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
+# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+return $FAULT_CPE_INVALID_PARAMETER_NAME
}
check_parameter_management_server_generic() {
@@ -750,8 +833,9 @@ get_management_server_generic_notification() {
}
set_management_server_generic() {
- check_parameter_management_server_generic "$1" ; _tmp=$? ; if [
"$_tmp" -eq 1 ]; then return 0; fi
+ check_parameter_management_server_generic "$1" ; _tmp=$? ; if [
"$_tmp" -eq 1 ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
freecwmp_set_parameter_value "$1" "$2"
- /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+ # /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 02ba365..c8f1887 100644
--- a/ext/openwrt/scripts/functions/wan_device
+++ b/ext/openwrt/scripts/functions/wan_device
@@ -94,13 +94,18 @@ ubus_freecwmp_output "$parm" "$val" "$type"
set_wan_device_wan_ppp_enable() {
local val=$1
-if [ "$val" -eq 0 ]; then
- /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.auto=0
- ifdown wan &
-elif [ "$val" -eq 1 ]; then
- /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set network.wan.auto=1
- ifup wan &
-fi
+local
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable"
+case $action in
+ set_value)
+ if [ "$val" -eq 0 ]; then
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
network.wan.auto=0
+ ifdown wan &
+ elif [ "$val" -eq 1 ]; then
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
network.wan.auto=1
+ ifup wan &
+ fi
+ ;;
+esac
}
get_wan_device_wan_ppp_username() {
@@ -121,7 +126,13 @@ ubus_freecwmp_output "$parm" "$val"
}
set_wan_device_wan_ppp_username() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
network.wan.username="$1"
+local val=$1
+local
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username"
+case $action in
+ set_value)
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
network.wan.username="$val"
+ ;;
+esac
}
get_wan_device_wan_ppp_password() {
@@ -142,7 +153,13 @@ ubus_freecwmp_output "$parm" "$val"
}
set_wan_device_wan_ppp_password() {
-/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
network.wan.password="$1"
+local val=$1
+local
parm="InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Password"
+case $action in
+ set_value)
+ /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set
network.wan.password="$1"
+ ;;
+esac
}
get_wan_device() {
@@ -452,13 +469,17 @@ set_wan_device() {
case "$1" in
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
+# /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+return $FAULT_CPE_INVALID_PARAMETER_NAME
}
--
1.7.4.1
>From 873f6809f16148a6371362717918f8e79ce19a0b Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 22:28:48 +0100
Subject: [PATCH 25/27] add ubus listner for set parameter attribute
Contributed by Inteno Broadband Technology AB & PIVA SOFTWARE
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
src/external.c | 16 ++++++++++++++++
src/external.h | 2 ++
src/ubus.c | 31 +++++++++++++++++++++++++++++++
src/xml.c | 20 +++++++++++++++++---
4 files changed, 66 insertions(+), 3 deletions(-)
diff --git a/src/external.c b/src/external.c
index 7eec751..a033781 100644
--- a/src/external.c
+++ b/src/external.c
@@ -75,6 +75,22 @@ void external_fetch_set_param_val_resp_status(char
**status)
external_method_status = NULL;
}
+void external_set_param_attr_resp (char *status, char *fault)
+{
+ free(external_method_status);
+ external_method_status = status ? strdup(status) : NULL;
+ free(external_method_fault);
+ external_method_fault = fault ? strdup(fault) : NULL;
+}
+
+void external_fetch_set_param_attr_resp (char **status, char **fault)
+{
+ *status = external_method_status;
+ external_method_status = NULL;
+ *fault = external_method_fault;
+ external_method_fault = NULL;
+}
+
int external_get_action_data(char *action, char *name, char **value)
{
struct external_parameter *external_parameter;
diff --git a/src/external.h b/src/external.h
index 77165ee..489d215 100644
--- a/src/external.h
+++ b/src/external.h
@@ -30,6 +30,8 @@ struct external_parameter {
void external_set_param_val_resp_status (char *status);
void external_fetch_set_param_val_resp_status (char **status);
+void external_set_param_attr_resp (char *status, char *fault);
+void external_fetch_set_param_attr_resp (char **status, char **fault);
int external_get_action(char *action, char *name, char *arg);
int external_get_action_data(char *action, char *name, char **value);
int external_get_action_write(char *action, char *name, char *arg);
diff --git a/src/ubus.c b/src/ubus.c
index e852ed4..8502805 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -281,6 +281,36 @@ freecwmpd_handle_get_param_attributes(struct
ubus_context *ctx, struct ubus_obje
return 0;
}
+static enum set_param_attributes {
+ SET_PARAM_ATTRIBUTES_SUCCESS,
+ SET_PARAM_ATTRIBUTES_FAULT,
+ __SET_PARAM_ATTRIBUTES_MAX
+};
+
+static const struct blobmsg_policy set_param_attributes_policy[] = {
+ [SET_PARAM_ATTRIBUTES_SUCCESS] = { .name = "success", .type =
BLOBMSG_TYPE_STRING },
+ [SET_PARAM_ATTRIBUTES_FAULT] = { .name = "fault_code", .type =
BLOBMSG_TYPE_STRING },
+};
+
+static int
+freecwmpd_handle_set_param_attributes(struct ubus_context *ctx, struct
ubus_object *obj,
+ struct ubus_request_data *req, const char *method,
+ struct blob_attr *msg)
+{
+ struct blob_attr *tb[__SET_PARAM_ATTRIBUTES_MAX];
+
+ blobmsg_parse(set_param_attributes_policy,
ARRAY_SIZE(set_param_attributes_policy), tb,
+ blob_data(msg), blob_len(msg));
+
+ freecwmp_log_message(NAME, L_NOTICE,
+ "triggered ubus set_parameter_attributes\n");
+
+ external_set_param_attr_resp(tb[SET_PARAM_ATTRIBUTES_SUCCESS] ?
blobmsg_data(tb[SET_PARAM_ATTRIBUTES_SUCCESS]) : NULL,
+ tb[SET_PARAM_ATTRIBUTES_FAULT] ?
blobmsg_data(tb[SET_PARAM_ATTRIBUTES_FAULT]) : NULL);
+
+ return 0;
+}
+
static enum set_param_values_fault {
SET_PARAM_VALUES_FAULT_PARAM,
SET_PARAM_VALUES_FAULT__FAULT,
@@ -361,6 +391,7 @@ static const struct ubus_method freecwmp_methods[] = {
UBUS_METHOD("set_parameter_values_status",
freecwmpd_handle_set_param_values_status, set_param_values_status_policy),
UBUS_METHOD("get_parameter_names",
freecwmpd_handle_get_param_names, get_param_names_policy),
UBUS_METHOD("get_parameter_attributes",
freecwmpd_handle_get_param_attributes, get_param_attributes_policy),
+ UBUS_METHOD("set_parameter_attributes",
freecwmpd_handle_set_param_attributes, set_param_attributes_policy),
};
static struct ubus_object_type main_object_type =
diff --git a/src/xml.c b/src/xml.c
index a8f82c7..e46c50c 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -6,6 +6,7 @@
*
* Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
* Copyright (C) 2012 Jonas Gorski <jonas.gorski@gmail.com>
+ * Copyright (C) 2012 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
*/
#include <stdbool.h>
@@ -861,7 +862,7 @@ static int
xml_handle_set_parameter_attributes(mxml_node_t *body_in,
mxml_node_t *tree_out) {
mxml_node_t *n, *b = body_in;
- char *c, *parameter_name, *parameter_notification;
+ char *c, *parameter_name, *parameter_notification, *success=NULL,
*fault=NULL;
uint8_t attr_notification_update;
/* handle cwmp:SetParameterAttributes */
@@ -913,15 +914,28 @@ static int
xml_handle_set_parameter_attributes(mxml_node_t *body_in,
if (external_set_action_execute("notification"))
return -1;
+ external_fetch_set_param_attr_resp(&success, &fault);
+
+ if (fault && fault[0]=='9') goto error; //TODO KMD return a fault
message here with fault indicated in the fault string
+
+ if(!success) goto error; //TODO KMD return a fault message here
+
b = mxmlFindElement(tree_out, tree_out, "soap_env:Body", NULL,
NULL, MXML_DESCEND);
- if (!b) return -1;
+ if (!b) goto error;
b = mxmlNewElement(b, "cwmp:SetParameterAttributesResponse");
- if (!b) return -1;
+ if (!b) goto error;
config_load();
+ free(success);
+ free(fault);
return 0;
+
+error:
+ free(success);
+ free(fault);
+ return -1;
}
static int xml_handle_download(mxml_node_t *body_in,
--
1.7.4.1
>From c638d7c256a7c08c4c66a8bc5564a4b6d72b145d Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 22:32:09 +0100
Subject: [PATCH 26/27] update common script and freecwmp.sh for set
parameter attributes in order to have the communication with the core
via ubus
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
ext/openwrt/config/freecwmp | 6 ++++++
ext/openwrt/scripts/freecwmp.sh | 29 +++++++++++++++++++++++++++--
ext/openwrt/scripts/functions/common | 3 +++
3 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/ext/openwrt/config/freecwmp b/ext/openwrt/config/freecwmp
index 1f72c27..68a455d 100644
--- a/ext/openwrt/config/freecwmp
+++ b/ext/openwrt/config/freecwmp
@@ -32,29 +32,35 @@ config scripts
list get_name_function get_device_info_name
list get_notification_function get_device_info_notification
list set_value_function set_device_info
+ list set_notification_function set_device_info_notification
list get_value_function get_device_info_generic
list get_name_function get_device_info_generic_name
list get_notification_function get_device_info_generic_notification
list set_value_function set_device_info_generic
+ list set_notification_function set_device_info_generic_notification
list location /usr/share/freecwmp/functions/lan_device
list get_value_function get_lan_device
list get_name_function get_lan_device_name
list get_notification_function get_lan_device_notification
list set_value_function set_lan_device
+ list set_notification_function set_lan_device_notification
list location /usr/share/freecwmp/functions/management_server
list get_value_function get_management_server
list get_name_function get_management_server_name
list get_notification_function get_management_server_notification
list set_value_function set_management_server
+ list set_notification_function set_management_server_notification
list get_value_function get_management_server_generic
list get_name_function get_management_server_generic_name
list get_notification_function
get_management_server_generic_notification
list set_value_function set_management_server_generic
+ list set_notification_function
set_management_server_generic_notification
list location /usr/share/freecwmp/functions/wan_device
list get_value_function get_wan_device
list get_name_function get_wan_device_name
list get_notification_function get_wan_device_notification
list set_value_function set_wan_device
+ list set_notification_function set_wan_device_notification
list location /usr/share/freecwmp/functions/misc
list get_value_function get_misc
list location /usr/share/freecwmp/functions/device_users
diff --git a/ext/openwrt/scripts/freecwmp.sh
b/ext/openwrt/scripts/freecwmp.sh
index 54c0924..f448c73 100644
--- a/ext/openwrt/scripts/freecwmp.sh
+++ b/ext/openwrt/scripts/freecwmp.sh
@@ -124,6 +124,7 @@ handle_scripts() {
config_get get_name_functions "$section" "get_name_function"
config_get get_notification_functions "$section"
"get_notification_function"
config_get set_value_functions "$section" "set_value_function"
+ config_get set_notification_functions "$section"
"set_notification_function"
}
config_load freecwmp
@@ -276,8 +277,30 @@ if [ "$action" = "get_notification" -o "$action" =
"get_all" ]; then
fi
if [ "$action" = "set_notification" ]; then
- freecwmp_set_parameter_notification "$__arg1" "$__arg2"
- /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
+ no_fault="0"
+ freecwmp_check_fault "$__arg1"
+ fault_code="$?"
+ if [ "$fault_code" = "0" ]; then
+ if [ \( "$__arg1" = "InternetGatewayDevice." \) -o \( "$__arg1"
= "" \) ]; then
+ __arg1="InternetGatewayDevice."
+ fi
+ for function_name in $set_notification_functions
+ do
+ $function_name "$__arg1" "$__arg2"
+ fault_code="$?"
+ if [ "$fault_code" = "0" ]; then
+ no_fault="1"
+ fi
+ if [ "$fault_code" = "$FAULT_CPE_INVALID_ARGUMENTS" ]; then
+ break
+ fi
+ done
+ if [ "$no_fault" = "1" ]; then fault_code="0"; fi
+ fi
+ if [ "$fault_code" != "0" ]; then
+ let fault_code=$fault_code+9000
+ freecwmp_set_parameter_fault "$__arg1" "$fault_code"
+ fi
fi
if [ "$action" = "get_tags" -o "$action" = "get_all" ]; then
@@ -331,6 +354,7 @@ if [ \( "$action" = "apply_notification" \) -o \(
"$action" = "apply_value" \) ]
# applying
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
if [ "$action" = "apply_value" ]; then ubus call tr069
set_parameter_values_status '{"status": "0"}'; fi
+ if [ "$action" = "apply_notification" ]; then ubus call tr069
set_parameter_attributes '{"success": "0", "fault_code":""}' 2>
/dev/null; fi
else
let n=$__fault_count-1
for i in `seq 0 $n`
@@ -338,6 +362,7 @@ if [ \( "$action" = "apply_notification" \) -o \(
"$action" = "apply_value" \) ]
local parm=`/sbin/uci -P /var/state get
freecwmp.@fault[$i].parameter 2> /dev/null`
local fault_code=`/sbin/uci -P /var/state get
freecwmp.@fault[$i].fault_code 2> /dev/null`
ubus_freecwmp_fault_output "$parm" "$fault_code"
+ if [ "$action" = "apply_notification" ]; then break; fi
done
rm -rf /var/state/freecwmp 2> /dev/null
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} revert freecwmp
diff --git a/ext/openwrt/scripts/functions/common
b/ext/openwrt/scripts/functions/common
index f701eb9..a4117d0 100644
--- a/ext/openwrt/scripts/functions/common
+++ b/ext/openwrt/scripts/functions/common
@@ -64,6 +64,9 @@ case "$action" in
apply_value)
ubus call tr069 set_parameter_values_fault '{"parameter":
"'$parameter'", "fault_code":"'$fault_code'"}' 2> /dev/null
;;
+ apply_notification)
+ ubus call tr069 set_parameter_attributes '{"success": "",
"fault_code":"'$fault_code'"}' 2> /dev/null
+ ;;
esac
}
freecwmp_value_output() {
--
1.7.4.1
>From 88706661923710a0c775178b106eb40c6cdccb1f Mon Sep 17 00:00:00 2001
From: Mohamed <mohamed.kallel@pivasoftware.com>
Date: Sat, 1 Dec 2012 22:38:00 +0100
Subject: [PATCH 27/27] update the dm script function to communicate the
output of set parameter attribute with ubus
Contributed by Inteno Broadband Technology AB
Signed-off-by: Mohamed <mohamed.kallel@pivasoftware.com>
---
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"
+ ;;
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
|