mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2026-03-13 12:32:20 +01:00
Fix set_values: parameterkey
This commit is contained in:
parent
5ea6e2e411
commit
31e806bc82
6 changed files with 68 additions and 16 deletions
|
|
@ -16,7 +16,7 @@ icwmpd_SOURCES = \
|
|||
../ubus.c \
|
||||
../xml.c \
|
||||
../diagnostic.c \
|
||||
../datamodelIface.c \
|
||||
../datamodel_interface.c \
|
||||
../zlib.c
|
||||
|
||||
icwmpd_CFLAGS = \
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "datamodelIface.h"
|
||||
#include "datamodel_interface.h"
|
||||
|
||||
char* cwmp_get_parameter_values(char *parameter_name, json_object **parameters)
|
||||
{
|
||||
|
|
@ -21,7 +21,7 @@ char* cwmp_get_parameter_values(char *parameter_name, json_object **parameters)
|
|||
char* cwmp_set_parameter_value(char* parameter_name, char* value, char* parameter_key)
|
||||
{
|
||||
json_object *set_res;
|
||||
int e = cwmp_ubus_call("usp.raw", "set", CWMP_UBUS_ARGS{{"path", {.str_val=parameter_name}, UBUS_String},{"value", value, UBUS_String}, {"key", parameter_key, UBUS_String}}, 2, &set_res);
|
||||
int e = cwmp_ubus_call("usp.raw", "set", CWMP_UBUS_ARGS{{"path", {.str_val=parameter_name}, UBUS_String},{"value", {.str_val=value}, UBUS_String}, {"key", {.str_val=parameter_key}, UBUS_String}}, 3, &set_res);
|
||||
if (e < 0 || set_res == NULL)
|
||||
return "9002";
|
||||
|
||||
14
inc/ubus.h
14
inc/ubus.h
|
|
@ -1,5 +1,15 @@
|
|||
#ifndef UBUS_H_
|
||||
#define UBUS_H_
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _FREECWMP_UBUS_H__
|
||||
#define _FREECWMP_UBUS_H__
|
||||
#include <stdbool.h>
|
||||
|
||||
#define ARRAY_MAX 8
|
||||
|
|
|
|||
|
|
@ -120,6 +120,12 @@ struct cwmp_param_fault {
|
|||
int fault;
|
||||
};
|
||||
|
||||
struct cwmp_param_value {
|
||||
struct list_head list;
|
||||
char *param;
|
||||
char *value;
|
||||
};
|
||||
|
||||
struct rpc_cpe_method {
|
||||
const char *name;
|
||||
int (*handler)(struct session *session, struct rpc *rpc);
|
||||
|
|
|
|||
58
xml.c
58
xml.c
|
|
@ -34,7 +34,7 @@
|
|||
#include <libbbfdm/deviceinfo.h>
|
||||
#include <libbbfdm/softwaremodules.h>
|
||||
#endif
|
||||
#include "datamodelIface.h"
|
||||
#include "datamodel_interface.h"
|
||||
|
||||
LIST_HEAD(list_download);
|
||||
LIST_HEAD(list_upload);
|
||||
|
|
@ -158,6 +158,36 @@ void cwmp_del_list_fault_param(struct cwmp_param_fault *param_fault)
|
|||
free(param_fault->name);
|
||||
free(param_fault);
|
||||
}
|
||||
|
||||
void cwmp_add_list_param_value(char *param, char* value, struct list_head *list_param_value)
|
||||
{
|
||||
struct cwmp_param_value *param_value = NULL;
|
||||
if (param == NULL)
|
||||
param = "";
|
||||
|
||||
param_value = calloc(1, sizeof(struct cwmp_param_value));
|
||||
list_add_tail(¶m_value->list, list_param_value);
|
||||
param_value->param = strdup(param);
|
||||
param_value->value = strdup(value);
|
||||
}
|
||||
|
||||
void cwmp_del_list_param_value(struct cwmp_param_value *param_value)
|
||||
{
|
||||
list_del(¶m_value->list);
|
||||
free(param_value->param);
|
||||
free(param_value->value);
|
||||
free(param_value);
|
||||
}
|
||||
|
||||
void cwmp_free_all_list_param_value(struct list_head *list_param_value)
|
||||
{
|
||||
struct cwmp_param_value *param_value;
|
||||
while (list_param_value->next != list_param_value) {
|
||||
param_value = list_entry(list_param_value->next, struct cwmp_param_value, list);
|
||||
cwmp_del_list_param_value(param_value);
|
||||
}
|
||||
}
|
||||
|
||||
static mxml_node_t * /* O - Element node or NULL */
|
||||
mxmlFindElementOpaque(mxml_node_t *node, /* I - Current node */
|
||||
mxml_node_t *top, /* I - Top node */
|
||||
|
|
@ -1537,6 +1567,7 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct session *session, struct rpc
|
|||
|
||||
LIST_HEAD(list_fault_param);
|
||||
rpc->list_set_value_fault = &list_fault_param;
|
||||
LIST_HEAD(list_param_value);
|
||||
while (b) {
|
||||
if (b && b->type == MXML_OPAQUE &&
|
||||
b->value.opaque &&
|
||||
|
|
@ -1578,30 +1609,35 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct session *session, struct rpc
|
|||
parameter_value = strdup("");
|
||||
}
|
||||
if (parameter_name && parameter_value) {
|
||||
char *err = cwmp_set_parameter_value(parameter_name, parameter_value, parameter_key);
|
||||
if (err) {
|
||||
cwmp_add_list_fault_param(parameter_name, atoi(err), rpc->list_set_value_fault);
|
||||
fault_code = FAULT_CPE_INVALID_ARGUMENTS;
|
||||
}
|
||||
cwmp_add_list_param_value(parameter_name, parameter_value, &list_param_value);
|
||||
parameter_name = NULL;
|
||||
FREE(parameter_value);
|
||||
}
|
||||
b = mxmlWalkNext(b, session->body_in, MXML_DESCEND);
|
||||
}
|
||||
|
||||
if (fault_code == FAULT_CPE_INVALID_ARGUMENTS) {
|
||||
goto fault;
|
||||
}
|
||||
|
||||
b = mxmlFindElement(session->body_in, session->body_in, "ParameterKey", NULL, NULL, MXML_DESCEND);
|
||||
if(!b) {
|
||||
fault_code = FAULT_CPE_REQUEST_DENIED;
|
||||
goto fault;
|
||||
}
|
||||
|
||||
b = mxmlWalkNext(b, session->tree_in, MXML_DESCEND_FIRST);
|
||||
if (b && b->type == MXML_OPAQUE && b->value.opaque)
|
||||
parameter_key = b->value.opaque;
|
||||
struct cwmp_param_value *param_value;
|
||||
|
||||
list_for_each_entry(param_value, &list_param_value, list) {
|
||||
char *err = cwmp_set_parameter_value(param_value->param, param_value->value, parameter_key);
|
||||
if (err) {
|
||||
cwmp_add_list_fault_param(parameter_name, atoi(err), rpc->list_set_value_fault);
|
||||
fault_code = FAULT_CPE_INVALID_ARGUMENTS;
|
||||
}
|
||||
}
|
||||
|
||||
cwmp_free_all_list_param_value(&list_param_value);
|
||||
if (fault_code == FAULT_CPE_INVALID_ARGUMENTS) {
|
||||
goto fault;
|
||||
}
|
||||
|
||||
b = mxmlFindElement(session->tree_out, session->tree_out, "soap_env:Body",
|
||||
NULL, NULL, MXML_DESCEND);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue