mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
PIVA::DELIVERY 8
script optimization Voice parameters: AddObject/DeleteObject Voice parameters: Vendor specific parameter Concerning what we did in the optimization task: 1) The main script (freecwmp) is loaded only 1 time during the session. the load is done just before the start of the session. the function scripts are loaded within the load of the main script (freecwmp) only one time. The old behaviour consist to load the main script (freecwmp) and the function scripts for each parameter treatment. Core code (C) and Scripts are changed 2) Optimize the preparing of inform message. old script take ~30s and now it takes ~2s. Core code (C) and Scripts are changed 3) Execute only the function related to the parameter. For example if the requested parameter is "InternetGatewayDevice.ManagementServer.URL" then the main script freecwmp will execute only the related function of this parameter which is get_management_server(). The old behaviour consist to execute all get functions: get_wan_device(), get_lan_device(), get_device_info()... 4) Minimize the size of the script files: Replace some blocks o othe source code by a functions
This commit is contained in:
parent
c4274242a5
commit
27b73d5af7
31 changed files with 2872 additions and 8090 deletions
|
|
@ -3,10 +3,10 @@
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* Powered by Inteno Broadband Technology AB
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
* Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
* Copyright (C) 2013 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
* Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
||||||
|
* Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
6
config.c
6
config.c
|
|
@ -3,10 +3,10 @@
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* Powered by Inteno Broadband Technology AB
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
* Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
* Copyright (C) 2013 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
* Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
||||||
|
* Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
15
config/cwmp
15
config/cwmp
|
|
@ -58,3 +58,18 @@ config notifications
|
||||||
config cwmp
|
config cwmp
|
||||||
option parameter 'InternetGatewayDevice.DeviceInfo.SpecVersion'
|
option parameter 'InternetGatewayDevice.DeviceInfo.SpecVersion'
|
||||||
option value '1.0'
|
option value '1.0'
|
||||||
|
|
||||||
|
config DeviceInfo
|
||||||
|
list function 'device_info'
|
||||||
|
|
||||||
|
config Services
|
||||||
|
list function 'voice_service'
|
||||||
|
|
||||||
|
config LANDevice
|
||||||
|
list function 'lan_device'
|
||||||
|
|
||||||
|
config ManagementServer
|
||||||
|
list function 'management_server'
|
||||||
|
|
||||||
|
config WANDevice
|
||||||
|
list function 'wan_device'
|
||||||
|
|
|
||||||
14
cwmp.c
14
cwmp.c
|
|
@ -3,10 +3,10 @@
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* Powered by Inteno Broadband Technology AB
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
* Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
* Copyright (C) 2013 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
* Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
||||||
|
* Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -136,10 +136,12 @@ void cwmp_schedule_session (struct cwmp *cwmp)
|
||||||
CWMP_LOG(EMERG,"FATAL error in the mutex process in the session scheduler!");
|
CWMP_LOG(EMERG,"FATAL error in the mutex process in the session scheduler!");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
external_init();
|
||||||
CWMP_LOG (INFO,"Start session");
|
CWMP_LOG (INFO,"Start session");
|
||||||
error = cwmp_schedule_rpc (cwmp,session);
|
error = cwmp_schedule_rpc (cwmp,session);
|
||||||
CWMP_LOG (INFO,"End session");
|
CWMP_LOG (INFO,"End session");
|
||||||
run_session_end_func(session);
|
run_session_end_func(session);
|
||||||
|
external_exit();
|
||||||
if (session->error == CWMP_RETRY_SESSION)
|
if (session->error == CWMP_RETRY_SESSION)
|
||||||
{
|
{
|
||||||
error = cwmp_move_session_to_session_queue (cwmp, session);
|
error = cwmp_move_session_to_session_queue (cwmp, session);
|
||||||
|
|
@ -440,20 +442,20 @@ int run_session_end_func (struct session *session)
|
||||||
if (session->end_session & END_SESSION_EXTERNAL_ACTION)
|
if (session->end_session & END_SESSION_EXTERNAL_ACTION)
|
||||||
{
|
{
|
||||||
CWMP_LOG (INFO,"Executing external commands: end session request");
|
CWMP_LOG (INFO,"Executing external commands: end session request");
|
||||||
external_simple("end_session", NULL);
|
external_simple("end_session");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session->end_session & END_SESSION_FACTORY_RESET)
|
if (session->end_session & END_SESSION_FACTORY_RESET)
|
||||||
{
|
{
|
||||||
CWMP_LOG (INFO,"Executing factory reset: end session request");
|
CWMP_LOG (INFO,"Executing factory reset: end session request");
|
||||||
external_simple("factory_reset", NULL);
|
external_simple("factory_reset");
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session->end_session & END_SESSION_REBOOT)
|
if (session->end_session & END_SESSION_REBOOT)
|
||||||
{
|
{
|
||||||
CWMP_LOG (INFO,"Executing Reboot: end session request");
|
CWMP_LOG (INFO,"Executing Reboot: end session request");
|
||||||
external_simple("reboot", NULL);
|
external_simple("reboot");
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
6
event.c
6
event.c
|
|
@ -3,10 +3,10 @@
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* Powered by Inteno Broadband Technology AB
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
* Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
* Copyright (C) 2013 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
* Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
||||||
|
* Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
647
external.c
647
external.c
|
|
@ -3,31 +3,38 @@
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* Contributed by Inteno Broadband Technology AB
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
* Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
* Copyright (C) 2013 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
* Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
||||||
|
* Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
* Copyright (C) 2011 Luka Perkov <freecwmp@lukaperkov.net>
|
* Copyright (C) 2011 Luka Perkov <freecwmp@lukaperkov.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
#include <poll.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#include <libubox/uloop.h>
|
#include <libubox/uloop.h>
|
||||||
|
|
||||||
|
#include <json/json.h>
|
||||||
|
|
||||||
#include "external.h"
|
#include "external.h"
|
||||||
#include "cwmp.h"
|
#include "cwmp.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
static struct uloop_process uproc;
|
static int pid;
|
||||||
static pthread_mutex_t external_mutex_exec = PTHREAD_MUTEX_INITIALIZER;
|
static json_object *json_obj_in;
|
||||||
|
static int pfds_in[2], pfds_out[2];
|
||||||
|
static FILE *fpipe;
|
||||||
|
|
||||||
LIST_HEAD(external_list_parameter);
|
LIST_HEAD(external_list_parameter);
|
||||||
LIST_HEAD(external_list_value_change);
|
LIST_HEAD(external_list_value_change);
|
||||||
|
|
@ -134,523 +141,259 @@ void external_fetch_delObjectResp (char **status, char **fault)
|
||||||
external_MethodFault = NULL;
|
external_MethodFault = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void external_action_jshn_parse(int fp, int external_handler(char *msg))
|
static void external_read_pipe_input(int (*external_handler)(char *msg))
|
||||||
{
|
{
|
||||||
char buf[1], *value = NULL, *c = NULL;
|
char buf[1], *value = NULL, *c = NULL;
|
||||||
int i=0, len;
|
int i=0, len;
|
||||||
|
struct pollfd fd = {
|
||||||
while(read(fp, buf, sizeof(buf))>0) {
|
.fd = pfds_in[0],
|
||||||
|
.events = POLLIN
|
||||||
|
};
|
||||||
|
while(1) {
|
||||||
|
poll(&fd, 1, 500000);
|
||||||
|
if (!(fd.revents & POLLIN)) break;
|
||||||
|
if (read(pfds_in[0], buf, sizeof(buf))<=0) break;
|
||||||
if (buf[0]!='\n') {
|
if (buf[0]!='\n') {
|
||||||
if (value)
|
if (value)
|
||||||
asprintf(&c,"%s%c",value,buf[0]);
|
asprintf(&c,"%s%c",value,buf[0]);
|
||||||
else
|
else
|
||||||
asprintf(&c,"%c",buf[0]);
|
asprintf(&c,"%c",buf[0]);
|
||||||
|
|
||||||
free(value);
|
FREE(value);
|
||||||
value = c;
|
value = c;
|
||||||
} else {
|
} else {
|
||||||
if (!value) continue;
|
if (!value) continue;
|
||||||
external_handler(value);
|
if (strcmp(value, "EOF")==0) break;
|
||||||
|
if(external_handler) external_handler(value);
|
||||||
FREE(value);
|
FREE(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int external_get_action(char *action, char *name, char *arg, int external_handler(char *msg))
|
static void external_write_pipe_output(const char *msg)
|
||||||
|
{
|
||||||
|
char *value = NULL;
|
||||||
|
int i=0, len;
|
||||||
|
|
||||||
|
asprintf(&value, "%s\n", msg);
|
||||||
|
if (write(pfds_out[1], value, strlen(value)) == -1) {
|
||||||
|
CWMP_LOG(ERROR,"Error occured when trying to write to the pipe");
|
||||||
|
}
|
||||||
|
free(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void json_obj_out_add(json_object *json_obj_out, char *name, char *val)
|
||||||
|
{
|
||||||
|
json_object *json_obj_tmp;
|
||||||
|
|
||||||
|
json_obj_tmp = json_object_new_string(val);
|
||||||
|
json_object_object_add(json_obj_out, name, json_obj_tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void external_init()
|
||||||
|
{
|
||||||
|
if (pipe(pfds_in) < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (pipe(pfds_out) < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ((pid = fork()) == -1)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (pid == 0) {
|
||||||
|
/* child */
|
||||||
|
|
||||||
|
close(pfds_out[1]);
|
||||||
|
close(pfds_in[0]);
|
||||||
|
|
||||||
|
dup2(pfds_out[0], STDIN_FILENO);
|
||||||
|
dup2(pfds_in[1], STDOUT_FILENO);
|
||||||
|
|
||||||
|
const char *argv[5];
|
||||||
|
int i = 0;
|
||||||
|
argv[i++] = "/bin/sh";
|
||||||
|
argv[i++] = fc_script;
|
||||||
|
argv[i++] = "--json";
|
||||||
|
argv[i++] = "json_continuous_input";
|
||||||
|
argv[i++] = NULL;
|
||||||
|
execvp(argv[0], (char **) argv);
|
||||||
|
|
||||||
|
close(pfds_out[0]);
|
||||||
|
close(pfds_in[1]);
|
||||||
|
|
||||||
|
exit(ESRCH);
|
||||||
|
}
|
||||||
|
|
||||||
|
close(pfds_in[1]);
|
||||||
|
close(pfds_out[0]);
|
||||||
|
|
||||||
|
external_read_pipe_input(NULL);
|
||||||
|
|
||||||
|
DD(INFO, "freecwmp script is listening");
|
||||||
|
return;
|
||||||
|
|
||||||
|
error:
|
||||||
|
CWMP_LOG(ERROR,"freecwmp script intialization failed");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void external_exit()
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
|
||||||
|
json_object *json_obj_out;
|
||||||
|
|
||||||
|
json_obj_out = json_object_new_object();
|
||||||
|
|
||||||
|
json_obj_out_add(json_obj_out, "command", "exit");
|
||||||
|
|
||||||
|
external_write_pipe_output(json_object_to_json_string(json_obj_out));
|
||||||
|
|
||||||
|
json_object_put(json_obj_out);
|
||||||
|
|
||||||
|
while (wait(&status) != pid) {
|
||||||
|
DD(DEBUG, "waiting for child to exit");
|
||||||
|
}
|
||||||
|
|
||||||
|
close(pfds_in[0]);
|
||||||
|
close(pfds_out[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int external_handle_action(int (*external_handler)(char *msg))
|
||||||
|
{
|
||||||
|
json_object *json_obj_out;
|
||||||
|
|
||||||
|
json_obj_out = json_object_new_object();
|
||||||
|
json_obj_out_add(json_obj_out, "command", "end");
|
||||||
|
external_write_pipe_output(json_object_to_json_string(json_obj_out));
|
||||||
|
json_object_put(json_obj_out);
|
||||||
|
external_read_pipe_input(external_handler);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int external_get_action(char *action, char *name, char *next_level)
|
||||||
{
|
{
|
||||||
int pfds[2];
|
|
||||||
if (pipe(pfds) < 0)
|
|
||||||
return -1;
|
|
||||||
pthread_mutex_lock(&external_mutex_exec);
|
|
||||||
DD(INFO,"executing get %s '%s'", action, name);
|
DD(INFO,"executing get %s '%s'", action, name);
|
||||||
|
|
||||||
if ((uproc.pid = fork()) == -1)
|
json_object *json_obj_out;
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (uproc.pid == 0) {
|
/* send data to the script */
|
||||||
/* child */
|
json_obj_out = json_object_new_object();
|
||||||
|
|
||||||
const char *argv[8];
|
json_obj_out_add(json_obj_out, "command", "get");
|
||||||
int i = 0;
|
json_obj_out_add(json_obj_out, "action", action);
|
||||||
argv[i++] = "/bin/sh";
|
json_obj_out_add(json_obj_out, "parameter", name);
|
||||||
argv[i++] = fc_script;
|
if (next_level) json_obj_out_add(json_obj_out, "next_level", next_level);
|
||||||
argv[i++] = "--json";
|
|
||||||
argv[i++] = "get";
|
|
||||||
argv[i++] = action;
|
|
||||||
argv[i++] = name;
|
|
||||||
if(arg) argv[i++] = arg;
|
|
||||||
argv[i++] = NULL;
|
|
||||||
|
|
||||||
close(pfds[0]);
|
external_write_pipe_output(json_object_to_json_string(json_obj_out));
|
||||||
dup2(pfds[1], 1);
|
|
||||||
close(pfds[1]);
|
|
||||||
|
|
||||||
execvp(argv[0], (char **) argv);
|
json_object_put(json_obj_out);
|
||||||
exit(ESRCH);
|
|
||||||
|
|
||||||
} else if (uproc.pid < 0)
|
return 0;
|
||||||
goto error;
|
|
||||||
|
|
||||||
/* parent */
|
|
||||||
close(pfds[1]);
|
|
||||||
|
|
||||||
int status;
|
|
||||||
while (wait(&status) != uproc.pid) {
|
|
||||||
DD(DEBUG,"waiting for child to exit");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
external_action_jshn_parse(pfds[0], external_handler);
|
int external_set_action(char *action, char *name, char *value, char *change)
|
||||||
|
{
|
||||||
|
DD(INFO,"executing set %s '%s'", action, name);
|
||||||
|
|
||||||
close(pfds[0]);
|
json_object *json_obj_out;
|
||||||
|
|
||||||
|
/* send data to the script */
|
||||||
|
json_obj_out = json_object_new_object();
|
||||||
|
|
||||||
|
json_obj_out_add(json_obj_out, "command", "set");
|
||||||
|
json_obj_out_add(json_obj_out, "action", action);
|
||||||
|
json_obj_out_add(json_obj_out, "parameter", name);
|
||||||
|
json_obj_out_add(json_obj_out, "value", value);
|
||||||
|
if (change) json_obj_out_add(json_obj_out, "change", change);
|
||||||
|
|
||||||
|
external_write_pipe_output(json_object_to_json_string(json_obj_out));
|
||||||
|
|
||||||
|
json_object_put(json_obj_out);
|
||||||
|
|
||||||
pthread_mutex_unlock(&external_mutex_exec);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
close(pfds[0]);
|
|
||||||
pthread_mutex_unlock(&external_mutex_exec);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int external_get_action_write(char *action, char *name, char *arg)
|
int external_object_action(char *command, char *name)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&external_mutex_exec);
|
DD(INFO,"executing %s object '%s'", action, name);
|
||||||
DD(INFO,"adding to get %s script '%s'", action, name);
|
|
||||||
|
|
||||||
FILE *fp;
|
json_object *json_obj_out;
|
||||||
|
|
||||||
if (access(fc_script_actions, R_OK | W_OK | X_OK) != -1) {
|
/* send data to the script */
|
||||||
fp = fopen(fc_script_actions, "a");
|
json_obj_out = json_object_new_object();
|
||||||
if (!fp) goto error;
|
|
||||||
} else {
|
|
||||||
fp = fopen(fc_script_actions, "w");
|
|
||||||
if (!fp) goto error;
|
|
||||||
|
|
||||||
fprintf(fp, "#!/bin/sh\n");
|
json_obj_out_add(json_obj_out, "command", command);
|
||||||
|
json_obj_out_add(json_obj_out, "action", "object");
|
||||||
|
json_obj_out_add(json_obj_out, "parameter", name);
|
||||||
|
|
||||||
if (chmod(fc_script_actions,
|
external_write_pipe_output(json_object_to_json_string(json_obj_out));
|
||||||
strtol("0700", 0, 8)) < 0) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DUMMY_MODE
|
json_object_put(json_obj_out);
|
||||||
fprintf(fp, "/bin/sh `pwd`/%s --json get %s %s %s\n", fc_script, action, name, arg?arg:"");
|
|
||||||
#else
|
|
||||||
fprintf(fp, "/bin/sh %s --json get %s %s %s\n", fc_script, action, name, arg?arg:"");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&external_mutex_exec);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
pthread_mutex_unlock(&external_mutex_exec);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int external_get_action_execute(int external_handler(char *msg))
|
int external_simple(char *command)
|
||||||
{
|
{
|
||||||
int pfds[2];
|
DD(INFO,"executing %s request", command);
|
||||||
if (pipe(pfds) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&external_mutex_exec);
|
json_object *json_obj_out;
|
||||||
|
|
||||||
if (access(fc_script_actions, F_OK) == -1)
|
/* send data to the script */
|
||||||
goto success;
|
json_obj_out = json_object_new_object();
|
||||||
|
|
||||||
DD(INFO,"executing get script");
|
json_obj_out_add(json_obj_out, "command", command);
|
||||||
|
|
||||||
if ((uproc.pid = fork()) == -1) {
|
external_write_pipe_output(json_object_to_json_string(json_obj_out));
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uproc.pid == 0) {
|
json_object_put(json_obj_out);
|
||||||
/* child */
|
|
||||||
|
|
||||||
const char *argv[3];
|
|
||||||
int i = 0;
|
|
||||||
argv[i++] = "/bin/sh";
|
|
||||||
argv[i++] = fc_script_actions;
|
|
||||||
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(DEBUG,"waiting for child to exit");
|
|
||||||
}
|
|
||||||
|
|
||||||
external_action_jshn_parse(pfds[0], external_handler);
|
|
||||||
remove(fc_script_actions);
|
|
||||||
|
|
||||||
success:
|
|
||||||
close(pfds[0]);
|
|
||||||
pthread_mutex_unlock(&external_mutex_exec);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
close(pfds[0]);
|
|
||||||
pthread_mutex_unlock(&external_mutex_exec);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int external_download(char *url, char *size, char *type, char *user, char *pass)
|
||||||
int external_set_action_write(char *action, char *name, char *value, char *change)
|
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&external_mutex_exec);
|
|
||||||
DD(INFO,"adding to set %s script '%s'", action, name);
|
|
||||||
|
|
||||||
FILE *fp;
|
|
||||||
|
|
||||||
if (access(fc_script_actions, R_OK | W_OK | X_OK) != -1) {
|
|
||||||
fp = fopen(fc_script_actions, "a");
|
|
||||||
if (!fp) goto error;
|
|
||||||
} else {
|
|
||||||
fp = fopen(fc_script_actions, "w");
|
|
||||||
if (!fp) goto error;
|
|
||||||
|
|
||||||
fprintf(fp, "#!/bin/sh\n");
|
|
||||||
|
|
||||||
if (chmod(fc_script_actions,
|
|
||||||
strtol("0700", 0, 8)) < 0) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef DUMMY_MODE
|
|
||||||
fprintf(fp, "/bin/sh `pwd`/%s --json set %s %s %s %s\n", fc_script, action, name, value, change ? change : "");
|
|
||||||
#else
|
|
||||||
fprintf(fp, "/bin/sh %s --json set %s %s %s %s\n", fc_script, action, name, value, change ? change : "");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&external_mutex_exec);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
error:
|
|
||||||
pthread_mutex_unlock(&external_mutex_exec);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int external_set_action_execute(char *action, int external_handler(char *msg))
|
|
||||||
{
|
|
||||||
int pfds[2];
|
|
||||||
if (pipe(pfds) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&external_mutex_exec);
|
|
||||||
DD(INFO,"executing set script");
|
|
||||||
|
|
||||||
FILE *fp;
|
|
||||||
|
|
||||||
if (access(fc_script_actions, R_OK | W_OK | F_OK) == -1)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
fp = fopen(fc_script_actions, "a");
|
|
||||||
if (!fp) goto error;
|
|
||||||
|
|
||||||
#ifdef DUMMY_MODE
|
|
||||||
fprintf(fp, "/bin/sh `pwd`/%s --json apply %s\n", fc_script, action);
|
|
||||||
#else
|
|
||||||
fprintf(fp, "/bin/sh %s --json apply %s\n", fc_script, action);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
if ((uproc.pid = fork()) == -1) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uproc.pid == 0) {
|
|
||||||
/* child */
|
|
||||||
|
|
||||||
const char *argv[3];
|
|
||||||
int i = 0;
|
|
||||||
argv[i++] = "/bin/sh";
|
|
||||||
argv[i++] = fc_script_actions;
|
|
||||||
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(DEBUG,"waiting for child to exit");
|
|
||||||
}
|
|
||||||
|
|
||||||
external_action_jshn_parse(pfds[0], external_handler);
|
|
||||||
|
|
||||||
if (remove(fc_script_actions) != 0)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
close(pfds[0]);
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&external_mutex_exec);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
error:
|
|
||||||
close(pfds[0]);
|
|
||||||
pthread_mutex_unlock(&external_mutex_exec);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int external_object_action(char *action, char *name, int external_handler(char *msg))
|
|
||||||
{
|
|
||||||
int pfds[2];
|
|
||||||
if (pipe(pfds) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&external_mutex_exec);
|
|
||||||
DD(INFO,"executing object %s '%s'", action, name);
|
|
||||||
|
|
||||||
if ((uproc.pid = fork()) == -1)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (uproc.pid == 0) {
|
|
||||||
/* child */
|
|
||||||
|
|
||||||
const char *argv[8];
|
|
||||||
int i = 0;
|
|
||||||
argv[i++] = "/bin/sh";
|
|
||||||
argv[i++] = fc_script;
|
|
||||||
argv[i++] = "--json";
|
|
||||||
argv[i++] = action;
|
|
||||||
argv[i++] = "object";
|
|
||||||
argv[i++] = name;
|
|
||||||
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;
|
|
||||||
|
|
||||||
close(pfds[1]);
|
|
||||||
|
|
||||||
int status;
|
|
||||||
while (wait(&status) != uproc.pid) {
|
|
||||||
DD(DEBUG, "waiting for child to exit");
|
|
||||||
}
|
|
||||||
|
|
||||||
external_action_jshn_parse(pfds[0], external_handler);
|
|
||||||
|
|
||||||
close(pfds[0]);
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&external_mutex_exec);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
error:
|
|
||||||
close(pfds[0]);
|
|
||||||
pthread_mutex_unlock(&external_mutex_exec);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int external_simple(char *arg, int external_handler(char *msg))
|
|
||||||
{
|
|
||||||
|
|
||||||
int pfds[2];
|
|
||||||
if (pipe(pfds) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&external_mutex_exec);
|
|
||||||
DD(INFO,"executing %s request", arg);
|
|
||||||
|
|
||||||
if ((uproc.pid = fork()) == -1)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (uproc.pid == 0) {
|
|
||||||
/* child */
|
|
||||||
|
|
||||||
const char *argv[6];
|
|
||||||
int i = 0;
|
|
||||||
argv[i++] = "/bin/sh";
|
|
||||||
argv[i++] = fc_script;
|
|
||||||
argv[i++] = "--json";
|
|
||||||
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(DEBUG,"waiting for child to exit");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (external_handler)
|
|
||||||
external_action_jshn_parse(pfds[0], external_handler);
|
|
||||||
close(pfds[0]);
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&external_mutex_exec);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
error:
|
|
||||||
close(pfds[0]);
|
|
||||||
pthread_mutex_unlock(&external_mutex_exec);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int external_download(char *url, char *size, char *type, char *user, char *pass, int external_handler(char *msg))
|
|
||||||
{
|
|
||||||
int pfds[2];
|
|
||||||
if (pipe(pfds) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&external_mutex_exec);
|
|
||||||
DD(INFO,"executing download url '%s'", url);
|
DD(INFO,"executing download url '%s'", url);
|
||||||
|
|
||||||
if ((uproc.pid = fork()) == -1)
|
json_object *json_obj_out;
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (uproc.pid == 0) {
|
/* send data to the script */
|
||||||
/* child */
|
json_obj_out = json_object_new_object();
|
||||||
|
|
||||||
const char *argv[20];
|
json_obj_out_add(json_obj_out, "command", "download");
|
||||||
int i = 0;
|
json_obj_out_add(json_obj_out, "url", url);
|
||||||
argv[i++] = "/bin/sh";
|
json_obj_out_add(json_obj_out, "size", size);
|
||||||
argv[i++] = fc_script;
|
json_obj_out_add(json_obj_out, "type", type);
|
||||||
argv[i++] = "download";
|
if(user) json_obj_out_add(json_obj_out, "user", user);
|
||||||
argv[i++] = "--json";
|
if(pass) json_obj_out_add(json_obj_out, "pass", pass);
|
||||||
argv[i++] = "--url";
|
|
||||||
argv[i++] = url;
|
|
||||||
argv[i++] = "--size";
|
|
||||||
argv[i++] = size;
|
|
||||||
argv[i++] = "--type";
|
|
||||||
argv[i++] = type;
|
|
||||||
if(user)
|
|
||||||
{
|
|
||||||
argv[i++] = "--user";
|
|
||||||
argv[i++] = user;
|
|
||||||
}
|
|
||||||
if(pass)
|
|
||||||
{
|
|
||||||
argv[i++] = "--pass";
|
|
||||||
argv[i++] = pass;
|
|
||||||
}
|
|
||||||
argv[i++] = NULL;
|
|
||||||
|
|
||||||
close(pfds[0]);
|
external_write_pipe_output(json_object_to_json_string(json_obj_out));
|
||||||
dup2(pfds[1], 1);
|
|
||||||
close(pfds[1]);
|
|
||||||
|
|
||||||
execvp(argv[0], (char **) argv);
|
json_object_put(json_obj_out);
|
||||||
exit(ESRCH);
|
|
||||||
|
|
||||||
} else if (uproc.pid < 0)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
/* parent */
|
|
||||||
close(pfds[1]);
|
|
||||||
|
|
||||||
int status;
|
|
||||||
while (wait(&status) != uproc.pid) {
|
|
||||||
DD(INFO,"waiting for child to exit");
|
|
||||||
}
|
|
||||||
|
|
||||||
external_action_jshn_parse(pfds[0], external_handler);
|
|
||||||
close(pfds[0]);
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&external_mutex_exec);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
close(pfds[0]);
|
|
||||||
pthread_mutex_unlock(&external_mutex_exec);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int external_apply_download(char *type, int external_handler(char *msg))
|
int external_apply(char *action, char *type)
|
||||||
{
|
{
|
||||||
int pfds[2];
|
DD(INFO,"executing apply %s", action);
|
||||||
if (pipe(pfds) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&external_mutex_exec);
|
json_object *json_obj_out;
|
||||||
DD(INFO,"applying downloaded file");
|
|
||||||
|
|
||||||
if ((uproc.pid = fork()) == -1)
|
/* send data to the script */
|
||||||
goto error;
|
json_obj_out = json_object_new_object();
|
||||||
|
|
||||||
if (uproc.pid == 0) {
|
json_obj_out_add(json_obj_out, "command", "apply");
|
||||||
/* child */
|
json_obj_out_add(json_obj_out, "action", action);
|
||||||
|
if (type) json_obj_out_add(json_obj_out, "type", type);
|
||||||
|
|
||||||
const char *argv[8];
|
external_write_pipe_output(json_object_to_json_string(json_obj_out));
|
||||||
int i = 0;
|
|
||||||
argv[i++] = "/bin/sh";
|
|
||||||
argv[i++] = fc_script;
|
|
||||||
argv[i++] = "--json";
|
|
||||||
argv[i++] = "apply";
|
|
||||||
argv[i++] = "download";
|
|
||||||
argv[i++] = "--type";
|
|
||||||
argv[i++] = type;
|
|
||||||
argv[i++] = NULL;
|
|
||||||
|
|
||||||
close(pfds[0]);
|
json_object_put(json_obj_out);
|
||||||
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(INFO,"waiting for child to exit");
|
|
||||||
}
|
|
||||||
|
|
||||||
external_action_jshn_parse(pfds[0], external_handler);
|
|
||||||
close(pfds[0]);
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&external_mutex_exec);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
close(pfds[0]);
|
|
||||||
pthread_mutex_unlock(&external_mutex_exec);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
6
http.c
6
http.c
|
|
@ -3,10 +3,10 @@
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* Contributed by Inteno Broadband Technology AB
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
* Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
* Copyright (C) 2013 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
* Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
||||||
|
* Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
* Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
|
* Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* Powered by Inteno Broadband Technology AB
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
* Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
* Copyright (C) 2013 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
* Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
||||||
|
* Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* Powered by Inteno Broadband Technology AB
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
* Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
* Copyright (C) 2013 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
* Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
||||||
|
* Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* Contributed by Inteno Broadband Technology AB
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
* Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
* Copyright (C) 2013 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
* Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
||||||
|
* Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
* Copyright (C) 2011 Luka Perkov <freecwmp@lukaperkov.net>
|
* Copyright (C) 2011 Luka Perkov <freecwmp@lukaperkov.net>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
@ -20,7 +20,6 @@ static char *fc_script = "./ext/openwrt/scripts/freecwmp.sh";
|
||||||
#else
|
#else
|
||||||
static char *fc_script = "/usr/sbin/freecwmp";
|
static char *fc_script = "/usr/sbin/freecwmp";
|
||||||
#endif
|
#endif
|
||||||
static char *fc_script_actions = "/tmp/freecwmp_action.sh";
|
|
||||||
|
|
||||||
extern pthread_mutex_t external_mutex_value_change;
|
extern pthread_mutex_t external_mutex_value_change;
|
||||||
extern struct list_head external_list_value_change;
|
extern struct list_head external_list_value_change;
|
||||||
|
|
@ -36,17 +35,17 @@ void external_addObjectResp (char *instance, char *status, char *fault);
|
||||||
void external_fetch_addObjectResp (char **instance, char **status, char **fault);
|
void external_fetch_addObjectResp (char **instance, char **status, char **fault);
|
||||||
void external_delObjectResp (char *status, char *fault);
|
void external_delObjectResp (char *status, char *fault);
|
||||||
void external_fetch_delObjectResp (char **status, char **fault);
|
void external_fetch_delObjectResp (char **status, char **fault);
|
||||||
int external_get_action(char *action, char *name, char *arg, int external_handler(char *msg));
|
int external_get_action(char *action, char *name, char *next_level);
|
||||||
int external_get_action_write(char *action, char *name, char *arg);
|
int external_set_action(char *action, char *name, char *value, char *change);
|
||||||
int external_get_action_execute(int external_handler(char *msg));
|
int external_object_action(char *command, char *name);
|
||||||
int external_set_action_write(char *action, char *name, char *value, char *change);
|
int external_simple(char *command);
|
||||||
int external_set_action_execute(char *action, int external_handler(char *msg));
|
int external_download(char *url, char *size, char *type, char *user, char *pass);
|
||||||
int external_object_action(char *action, char *name, int external_handler(char *msg));
|
int external_apply(char *action, char *type);
|
||||||
int external_simple(char *arg, int external_handler(char *msg));
|
int external_handle_action(int (*external_handler)(char *msg));
|
||||||
int external_download(char *url, char *size, char *type, char *user, char *pass, int external_handler(char *msg));
|
|
||||||
int external_apply_download(char *type, int external_handler(char *msg));
|
|
||||||
void external_add_list_paramameter(char *param_name, char *param_data, char *param_type, char *fault_code);
|
void external_add_list_paramameter(char *param_name, char *param_data, char *param_type, char *fault_code);
|
||||||
void external_free_list_parameter();
|
void external_free_list_parameter();
|
||||||
|
void external_init();
|
||||||
|
void external_exit();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* Powered by Inteno Broadband Technology AB
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
* Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
* Copyright (C) 2013 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
* Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
||||||
|
* Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* Powered by Inteno Broadband Technology AB
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
* Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
* Copyright (C) 2013 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
* Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
||||||
|
* Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* Contributed by Inteno Broadband Technology AB
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
* Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
* Copyright (C) 2013 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
* Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
||||||
|
* Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
* Copyright (C) 2011 Luka Perkov <freecwmp@lukaperkov.net>
|
* Copyright (C) 2011 Luka Perkov <freecwmp@lukaperkov.net>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -66,17 +66,17 @@ check_dhcp() {
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
set_wan_interface()
|
set_wan_interface() {
|
||||||
{
|
local l3_device=""
|
||||||
|
local default_wan_interface=""
|
||||||
local device=""
|
config_load cwmp
|
||||||
local default_wan_interface=""
|
config_get default_wan_interface cpe default_wan_interface
|
||||||
config_load cwmp
|
json_load "$(ifstatus $default_wan_interface)"
|
||||||
config_get default_wan_interface cpe default_wan_interface
|
json_get_var l3_device l3_device
|
||||||
json_load "$(ifstatus $default_wan_interface)"
|
if [ "$l3_device" != "" ];then
|
||||||
json_get_var device device
|
uci_set cwmp cpe interface "$l3_device"
|
||||||
uci_set cwmp cpe interface "$device"
|
uci_commit
|
||||||
uci_commit
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
start_msg="Start cwmpd ..."
|
start_msg="Start cwmpd ..."
|
||||||
|
|
@ -104,15 +104,6 @@ boot() {
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
local default_wan_interface
|
|
||||||
config_load cwmp
|
|
||||||
config_get default_wan_interface cpe default_wan_interface
|
|
||||||
json_load "$(ifstatus $default_wan_interface)"
|
|
||||||
json_get_var device device
|
|
||||||
if [ "$device" != "" ];then
|
|
||||||
uci -q set cwmp.cpe.interface="$device"
|
|
||||||
uci commit -q
|
|
||||||
fi
|
|
||||||
run=$(ps aux|grep /usr/sbin/cwmpd|grep -v grep|grep -v rc.common)
|
run=$(ps aux|grep /usr/sbin/cwmpd|grep -v grep|grep -v rc.common)
|
||||||
if [ "$run" = "" ]
|
if [ "$run" = "" ]
|
||||||
then
|
then
|
||||||
|
|
@ -141,19 +132,11 @@ stop() {
|
||||||
pids="`ps aux|grep /usr/sbin/cwmpd|sed 's/^ \+//g'|sed 's/ \+/:/g'|grep -v \" Z \"|grep -v grep|cut -f1 -d:|tr '\n' ' '`"
|
pids="`ps aux|grep /usr/sbin/cwmpd|sed 's/^ \+//g'|sed 's/ \+/:/g'|grep -v \" Z \"|grep -v grep|cut -f1 -d:|tr '\n' ' '`"
|
||||||
done
|
done
|
||||||
|
|
||||||
pids="`ps aux|grep /tmp/freecwmp_action.sh|sed 's/^ \+//g'|sed 's/ \+/:/g'|grep -v grep|cut -f1 -d:|tr '\n' ' '`"
|
|
||||||
while [ "_$pids" != "_" ];do
|
|
||||||
kill -9 $pids 2> /dev/null
|
|
||||||
pids="`ps aux|grep /tmp/freecwmp_action.sh|sed 's/^ \+//g'|sed 's/ \+/:/g'|grep -v grep|cut -f1 -d:|tr '\n' ' '`"
|
|
||||||
done
|
|
||||||
|
|
||||||
pids="`ps aux|grep /usr/sbin/freecwmp|sed 's/^ \+//g'|sed 's/ \+/:/g'|grep -v grep|cut -f1 -d:|tr '\n' ' '`"
|
pids="`ps aux|grep /usr/sbin/freecwmp|sed 's/^ \+//g'|sed 's/ \+/:/g'|grep -v grep|cut -f1 -d:|tr '\n' ' '`"
|
||||||
while [ "_$pids" != "_" ];do
|
while [ "_$pids" != "_" ];do
|
||||||
kill -9 $pids 2> /dev/null
|
kill -9 $pids 2> /dev/null
|
||||||
pids="`ps aux|grep /usr/sbin/freecwmp|sed 's/^ \+//g'|sed 's/ \+/:/g'|grep -v grep|cut -f1 -d:|tr '\n' ' '`"
|
pids="`ps aux|grep /usr/sbin/freecwmp|sed 's/^ \+//g'|sed 's/ \+/:/g'|grep -v grep|cut -f1 -d:|tr '\n' ' '`"
|
||||||
done
|
done
|
||||||
|
|
||||||
rm -f /tmp/freecwmp_action.sh
|
|
||||||
}
|
}
|
||||||
|
|
||||||
restart() {
|
restart() {
|
||||||
|
|
|
||||||
6
jshn.c
6
jshn.c
|
|
@ -3,10 +3,10 @@
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* Contributed by Inteno Broadband Technology AB
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
* Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
* Copyright (C) 2013 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
* Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
||||||
|
* Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
* Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
|
* Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
9
log.c
9
log.c
|
|
@ -3,10 +3,10 @@
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* Powered by Inteno Broadband Technology AB
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
* Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
* Copyright (C) 2013 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
* Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
||||||
|
* Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -108,14 +108,13 @@ void puts_log(int severity, const char *fmt, ...)
|
||||||
gettimeofday(&tv, 0);
|
gettimeofday(&tv, 0);
|
||||||
t = time((time_t*)NULL);
|
t = time((time_t*)NULL);
|
||||||
Tm= localtime(&tv.tv_sec);
|
Tm= localtime(&tv.tv_sec);
|
||||||
i = sprintf(buf,"%02d-%02d-%4d, %02d:%02d:%02d.%03d %s ",
|
i = sprintf(buf,"%02d-%02d-%4d, %02d:%02d:%02d %s ",
|
||||||
Tm->tm_mday,
|
Tm->tm_mday,
|
||||||
Tm->tm_mon+1,
|
Tm->tm_mon+1,
|
||||||
Tm->tm_year+1900,
|
Tm->tm_year+1900,
|
||||||
Tm->tm_hour,
|
Tm->tm_hour,
|
||||||
Tm->tm_min,
|
Tm->tm_min,
|
||||||
Tm->tm_sec,
|
Tm->tm_sec,
|
||||||
(int)tv.tv_usec%1000,
|
|
||||||
SEVERITY_NAMES[severity]);
|
SEVERITY_NAMES[severity]);
|
||||||
|
|
||||||
if(strlen(log_file_name) == 0)
|
if(strlen(log_file_name) == 0)
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* Contributed by Inteno Broadband Technology AB
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
* Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
* Copyright (C) 2013 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
* Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
||||||
|
* Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
* Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
|
* Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
|
# Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
|
||||||
# Copyright (C) 2012 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
# Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
|
# Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
||||||
|
# Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
|
|
||||||
. /lib/functions.sh
|
. /lib/functions.sh
|
||||||
. /usr/share/libubox/jshn.sh
|
. /usr/share/libubox/jshn.sh
|
||||||
|
|
@ -10,17 +12,12 @@
|
||||||
# define a 'name' command-line string flag
|
# define a 'name' command-line string flag
|
||||||
DEFINE_boolean 'newline' false 'do not output the trailing newline' 'n'
|
DEFINE_boolean 'newline' false 'do not output the trailing newline' 'n'
|
||||||
DEFINE_boolean 'value' false 'output values only' 'v'
|
DEFINE_boolean 'value' false 'output values only' 'v'
|
||||||
DEFINE_boolean 'json' false 'send values using ubus' 'j'
|
DEFINE_boolean 'json' false 'send values using json' 'j'
|
||||||
DEFINE_boolean 'empty' false 'output empty parameters' 'e'
|
DEFINE_boolean 'empty' false 'output empty parameters' 'e'
|
||||||
DEFINE_boolean 'last' false 'output only last line ; for parameters that tend to have huge output' 'l'
|
DEFINE_boolean 'last' false 'output only last line ; for parameters that tend to have huge output' 'l'
|
||||||
DEFINE_boolean 'debug' false 'give debug output' 'd'
|
DEFINE_boolean 'debug' false 'give debug output' 'd'
|
||||||
DEFINE_boolean 'dummy' false 'echo system commands' 'D'
|
DEFINE_boolean 'dummy' false 'echo system commands' 'D'
|
||||||
DEFINE_boolean 'force' false 'force getting values for certain parameters' 'f'
|
DEFINE_boolean 'force' false 'force getting values for certain parameters' 'f'
|
||||||
DEFINE_string 'url' '' 'file to download [download only]' 'u'
|
|
||||||
DEFINE_string 'size' '' 'size of file to download [download only]' 's'
|
|
||||||
DEFINE_string 'type' '' 'type of file to download [download only]' 't'
|
|
||||||
DEFINE_string 'user' '' 'username for downloading file [download only]' 'U'
|
|
||||||
DEFINE_string 'pass' '' 'password for downloading file [download only]' 'P'
|
|
||||||
|
|
||||||
FLAGS_HELP=`cat << EOF
|
FLAGS_HELP=`cat << EOF
|
||||||
USAGE: $0 [flags] command [parameter] [values]
|
USAGE: $0 [flags] command [parameter] [values]
|
||||||
|
|
@ -28,11 +25,15 @@ command:
|
||||||
get [value|notification|tags|name|all]
|
get [value|notification|tags|name|all]
|
||||||
set [value|notification|tag]
|
set [value|notification|tag]
|
||||||
apply [value|notification|download]
|
apply [value|notification|download]
|
||||||
|
add [object]
|
||||||
|
delete [object]
|
||||||
download
|
download
|
||||||
factory_reset
|
factory_reset
|
||||||
reboot
|
reboot
|
||||||
notify
|
notify
|
||||||
end_session
|
end_session
|
||||||
|
inform
|
||||||
|
json_continuous_input
|
||||||
EOF`
|
EOF`
|
||||||
|
|
||||||
FLAGS "$@" || exit 1
|
FLAGS "$@" || exit 1
|
||||||
|
|
@ -90,6 +91,11 @@ case "$1" in
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
download)
|
download)
|
||||||
|
__arg1="$2"
|
||||||
|
__arg2="$3"
|
||||||
|
__arg3="$4"
|
||||||
|
__arg4="$5"
|
||||||
|
__arg5="$6"
|
||||||
action="download"
|
action="download"
|
||||||
;;
|
;;
|
||||||
factory_reset)
|
factory_reset)
|
||||||
|
|
@ -104,28 +110,19 @@ case "$1" in
|
||||||
elif [ "$2" = "value" ]; then
|
elif [ "$2" = "value" ]; then
|
||||||
action="apply_value"
|
action="apply_value"
|
||||||
elif [ "$2" = "download" ]; then
|
elif [ "$2" = "download" ]; then
|
||||||
|
__arg1="$3"
|
||||||
action="apply_download"
|
action="apply_download"
|
||||||
else
|
else
|
||||||
action="apply_value"
|
action="apply_value"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
add)
|
add)
|
||||||
if [ "$2" = "object" ]; then
|
|
||||||
action="add_object"
|
|
||||||
__arg1="$3"
|
__arg1="$3"
|
||||||
else
|
|
||||||
action="add_object"
|
action="add_object"
|
||||||
__arg1="$3"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
delete)
|
delete)
|
||||||
if [ "$2" = "object" ]; then
|
|
||||||
action="delete_object"
|
|
||||||
__arg1="$3"
|
__arg1="$3"
|
||||||
else
|
|
||||||
action="delete_object"
|
action="delete_object"
|
||||||
__arg1="$3"
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
inform)
|
inform)
|
||||||
action="inform"
|
action="inform"
|
||||||
|
|
@ -139,6 +136,15 @@ case "$1" in
|
||||||
end_session)
|
end_session)
|
||||||
action="end_session"
|
action="end_session"
|
||||||
;;
|
;;
|
||||||
|
json_continuous_input)
|
||||||
|
action="json_continuous_input"
|
||||||
|
;;
|
||||||
|
end)
|
||||||
|
echo "EOF"
|
||||||
|
;;
|
||||||
|
exit)
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ -z "$action" ]; then
|
if [ -z "$action" ]; then
|
||||||
|
|
@ -181,6 +187,8 @@ handle_scripts() {
|
||||||
|
|
||||||
config_load cwmp
|
config_load cwmp
|
||||||
config_foreach handle_scripts "scripts"
|
config_foreach handle_scripts "scripts"
|
||||||
|
# load instance number for TR104
|
||||||
|
load_voice
|
||||||
|
|
||||||
# Fault code
|
# Fault code
|
||||||
|
|
||||||
|
|
@ -205,6 +213,7 @@ FAULT_CPE_DOWNLOAD_FAIL_COMPLETE_DOWNLOAD="17"
|
||||||
FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED="18"
|
FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED="18"
|
||||||
FAULT_CPE_DOWNLOAD_FAIL_FILE_AUTHENTICATION="19"
|
FAULT_CPE_DOWNLOAD_FAIL_FILE_AUTHENTICATION="19"
|
||||||
|
|
||||||
|
handle_action() {
|
||||||
if [ "$action" = "get_value" -o "$action" = "get_all" ]; then
|
if [ "$action" = "get_value" -o "$action" = "get_all" ]; then
|
||||||
if [ ${FLAGS_force} -eq ${FLAGS_FALSE} ]; then
|
if [ ${FLAGS_force} -eq ${FLAGS_FALSE} ]; then
|
||||||
__tmp_arg="Device."
|
__tmp_arg="Device."
|
||||||
|
|
@ -436,15 +445,15 @@ fi
|
||||||
|
|
||||||
if [ "$action" = "download" ]; then
|
if [ "$action" = "download" ]; then
|
||||||
local fault_code="9000"
|
local fault_code="9000"
|
||||||
if [ "${FLAGS_user}" = "" -o "${FLAGS_pass}" = "" ];then
|
if [ "$__arg4" = "" -o "$__arg5" = "" ];then
|
||||||
wget -O /tmp/freecwmp_download "${FLAGS_url}" > /dev/null
|
wget -O /tmp/freecwmp_download "$__arg1" > /dev/null
|
||||||
if [ "$?" != "0" ];then
|
if [ "$?" != "0" ];then
|
||||||
let fault_code=$fault_code+$FAULT_CPE_DOWNLOAD_FAILURE
|
let fault_code=$fault_code+$FAULT_CPE_DOWNLOAD_FAILURE
|
||||||
freecwmp_fault_output "" "$fault_code"
|
freecwmp_fault_output "" "$fault_code"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
local url="http://${FLAGS_user}:${FLAGS_pass}@`echo ${FLAGS_url}|sed 's/http:\/\///g'`"
|
local url="http://$__arg4:$__arg5@`echo $__arg1|sed 's/http:\/\///g'`"
|
||||||
wget -O /tmp/freecwmp_download "$url" > /dev/null
|
wget -O /tmp/freecwmp_download "$url" > /dev/null
|
||||||
if [ "$?" != "0" ];then
|
if [ "$?" != "0" ];then
|
||||||
let fault_code=$fault_code+$FAULT_CPE_DOWNLOAD_FAILURE
|
let fault_code=$fault_code+$FAULT_CPE_DOWNLOAD_FAILURE
|
||||||
|
|
@ -455,12 +464,12 @@ if [ "$action" = "download" ]; then
|
||||||
|
|
||||||
local flashsize="`freecwmp_check_flash_size`"
|
local flashsize="`freecwmp_check_flash_size`"
|
||||||
local filesize=`ls -l /tmp/freecwmp_download | awk '{ print $5 }'`
|
local filesize=`ls -l /tmp/freecwmp_download | awk '{ print $5 }'`
|
||||||
if [ $flashsize -gt 0 -a $flashsize -lt ${FLAGS_size} ]; then
|
if [ $flashsize -gt 0 -a $flashsize -lt $__arg2 ]; then
|
||||||
let fault_code=$fault_code+$FAULT_CPE_DOWNLOAD_FAILURE
|
let fault_code=$fault_code+$FAULT_CPE_DOWNLOAD_FAILURE
|
||||||
rm /tmp/freecwmp_download 2> /dev/null
|
rm /tmp/freecwmp_download 2> /dev/null
|
||||||
freecwmp_fault_output "" "$fault_code"
|
freecwmp_fault_output "" "$fault_code"
|
||||||
else
|
else
|
||||||
if [ "${FLAGS_type}" = "1" ];then
|
if [ "$__arg3" = "1" ];then
|
||||||
mv /tmp/freecwmp_download /tmp/firmware_upgrade_image 2> /dev/null
|
mv /tmp/freecwmp_download /tmp/firmware_upgrade_image 2> /dev/null
|
||||||
freecwmp_check_image
|
freecwmp_check_image
|
||||||
if [ "$?" = "0" ];then
|
if [ "$?" = "0" ];then
|
||||||
|
|
@ -478,10 +487,10 @@ if [ "$action" = "download" ]; then
|
||||||
rm /tmp/firmware_upgrade_image 2> /dev/null
|
rm /tmp/firmware_upgrade_image 2> /dev/null
|
||||||
freecwmp_fault_output "" "$fault_code"
|
freecwmp_fault_output "" "$fault_code"
|
||||||
fi
|
fi
|
||||||
elif [ "${FLAGS_type}" = "2" ];then
|
elif [ "$__arg3" = "2" ];then
|
||||||
mv /tmp/freecwmp_download /tmp/web_content.ipk 2> /dev/null
|
mv /tmp/freecwmp_download /tmp/web_content.ipk 2> /dev/null
|
||||||
freecwmp_fault_output "" "$FAULT_CPE_NO_FAULT"
|
freecwmp_fault_output "" "$FAULT_CPE_NO_FAULT"
|
||||||
elif [ "${FLAGS_type}" = "3" ];then
|
elif [ "$__arg3" = "3" ];then
|
||||||
mv /tmp/freecwmp_download /tmp/vendor_configuration_file.cfg 2> /dev/null
|
mv /tmp/freecwmp_download /tmp/vendor_configuration_file.cfg 2> /dev/null
|
||||||
freecwmp_fault_output "" "$FAULT_CPE_NO_FAULT"
|
freecwmp_fault_output "" "$FAULT_CPE_NO_FAULT"
|
||||||
else
|
else
|
||||||
|
|
@ -493,7 +502,7 @@ if [ "$action" = "download" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$action" = "apply_download" ]; then
|
if [ "$action" = "apply_download" ]; then
|
||||||
case "${FLAGS_type}" in
|
case "$__arg1" in
|
||||||
1) freecwmp_apply_firmware ;;
|
1) freecwmp_apply_firmware ;;
|
||||||
2) freecwmp_apply_web_content ;;
|
2) freecwmp_apply_web_content ;;
|
||||||
3) freecwmp_apply_vendor_configuration ;;
|
3) freecwmp_apply_vendor_configuration ;;
|
||||||
|
|
@ -580,6 +589,106 @@ if [ "$action" = "end_session" ]; then
|
||||||
echo 'rm -f /tmp/end_session.sh' >> /tmp/end_session.sh
|
echo 'rm -f /tmp/end_session.sh' >> /tmp/end_session.sh
|
||||||
/bin/sh /tmp/end_session.sh
|
/bin/sh /tmp/end_session.sh
|
||||||
fi
|
fi
|
||||||
|
if [ "$action" = "json_continuous_input" ]; then
|
||||||
|
echo "EOF"
|
||||||
|
while read CMD; do
|
||||||
|
[ -z "$CMD" ] && continue
|
||||||
|
result=""
|
||||||
|
json_init
|
||||||
|
json_load "$CMD"
|
||||||
|
json_get_var command command
|
||||||
|
json_get_var action action
|
||||||
|
case "$command" in
|
||||||
|
set)
|
||||||
|
if [ "$action" = "notification" ]; then
|
||||||
|
json_get_var __arg1 parameter
|
||||||
|
json_get_var __arg2 value
|
||||||
|
json_get_var __arg3 change
|
||||||
|
action="set_notification"
|
||||||
|
elif [ "$action" = "value" ]; then
|
||||||
|
json_get_var __arg1 parameter
|
||||||
|
json_get_var __arg2 value
|
||||||
|
action="set_value"
|
||||||
|
else
|
||||||
|
json_get_var __arg1 parameter
|
||||||
|
json_get_var __arg2 value
|
||||||
|
action="set_value"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
get)
|
||||||
|
if [ "$action" = "notification" ]; then
|
||||||
|
json_get_var __arg1 parameter
|
||||||
|
action="get_notification"
|
||||||
|
elif [ "$action" = "value" ]; then
|
||||||
|
json_get_var __arg1 parameter
|
||||||
|
action="get_value"
|
||||||
|
elif [ "$action" = "name" ]; then
|
||||||
|
json_get_var __arg1 parameter
|
||||||
|
json_get_var __arg2 next_level
|
||||||
|
action="get_name"
|
||||||
|
else
|
||||||
|
json_get_var __arg1 parameter
|
||||||
|
action="get_value"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
download)
|
||||||
|
json_get_var __arg1 url
|
||||||
|
json_get_var __arg2 size
|
||||||
|
json_get_var __arg3 type
|
||||||
|
json_get_var __arg4 user
|
||||||
|
json_get_var __arg5 pass
|
||||||
|
action="download"
|
||||||
|
;;
|
||||||
|
factory_reset)
|
||||||
|
action="factory_reset"
|
||||||
|
;;
|
||||||
|
reboot)
|
||||||
|
action="reboot"
|
||||||
|
;;
|
||||||
|
apply)
|
||||||
|
if [ "$action" = "notification" ]; then
|
||||||
|
action="apply_notification"
|
||||||
|
elif [ "$action" = "value" ]; then
|
||||||
|
action="apply_value"
|
||||||
|
elif [ "$action" = "download" ]; then
|
||||||
|
json_get_var __arg1 type
|
||||||
|
action="apply_download"
|
||||||
|
else
|
||||||
|
action="apply_value"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
add)
|
||||||
|
json_get_var __arg1 parameter
|
||||||
|
action="add_object"
|
||||||
|
;;
|
||||||
|
delete)
|
||||||
|
json_get_var __arg1 parameter
|
||||||
|
action="delete_object"
|
||||||
|
;;
|
||||||
|
inform)
|
||||||
|
action="inform"
|
||||||
|
;;
|
||||||
|
end_session)
|
||||||
|
action="end_session"
|
||||||
|
;;
|
||||||
|
end)
|
||||||
|
echo "EOF"
|
||||||
|
;;
|
||||||
|
exit)
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
handle_action
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_action
|
||||||
|
|
||||||
if [ ${FLAGS_debug} -eq ${FLAGS_TRUE} ]; then
|
if [ ${FLAGS_debug} -eq ${FLAGS_TRUE} ]; then
|
||||||
echo "[debug] exited at \"`date`\""
|
echo "[debug] exited at \"`date`\""
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
|
# Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
|
||||||
# Copyright (C) 2012 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
# Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
|
# Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
|
|
||||||
# TODO: merge this one somewhere in OpenWrt
|
# TODO: merge this one somewhere in OpenWrt
|
||||||
uci_remove_list_element() {
|
uci_remove_list_element() {
|
||||||
|
|
@ -293,7 +294,7 @@ freecwmp_config_notifications() {
|
||||||
if [ "$item" = "$3" ]; then
|
if [ "$item" = "$3" ]; then
|
||||||
eval "export -- \"$4=0\""
|
eval "export -- \"$4=0\""
|
||||||
return 0
|
return 0
|
||||||
elif [ "`echo $3|grep $item`" = "$3" ]; then
|
elif [ "`echo $3|grep $item`" = "$3" -a "`echo $item|grep '\.$'`" != "" ]; then
|
||||||
if [ $length -lt ${#item} ]; then
|
if [ $length -lt ${#item} ]; then
|
||||||
eval "export -- \"$4=0\""
|
eval "export -- \"$4=0\""
|
||||||
length="${#item}"
|
length="${#item}"
|
||||||
|
|
@ -305,7 +306,7 @@ freecwmp_config_notifications() {
|
||||||
if [ "$item" = "$3" ]; then
|
if [ "$item" = "$3" ]; then
|
||||||
eval "export -- \"$4=2\""
|
eval "export -- \"$4=2\""
|
||||||
return 0
|
return 0
|
||||||
elif [ "`echo $3|grep $item`" = "$3" ]; then
|
elif [ "`echo $3|grep $item`" = "$3" -a "`echo $item|grep '\.$'`" != "" ]; then
|
||||||
if [ $length -lt ${#item} ]; then
|
if [ $length -lt ${#item} ]; then
|
||||||
eval "export -- \"$4=2\""
|
eval "export -- \"$4=2\""
|
||||||
length="${#item}"
|
length="${#item}"
|
||||||
|
|
@ -317,7 +318,7 @@ freecwmp_config_notifications() {
|
||||||
if [ "$item" = "$3" ]; then
|
if [ "$item" = "$3" ]; then
|
||||||
eval "export -- \"$4=1\""
|
eval "export -- \"$4=1\""
|
||||||
return 0
|
return 0
|
||||||
elif [ "`echo $3|grep $item`" = "$3" ]; then
|
elif [ "`echo $3|grep $item`" = "$3" -a "`echo $item|grep '\.$'`" != "" ]; then
|
||||||
if [ $length -lt ${#item} ]; then
|
if [ $length -lt ${#item} ]; then
|
||||||
eval "export -- \"$4=1\""
|
eval "export -- \"$4=1\""
|
||||||
length="${#item}"
|
length="${#item}"
|
||||||
|
|
@ -385,6 +386,16 @@ freecwmp_notify() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
freecwmp_update_notification() {
|
||||||
|
local list="$1"
|
||||||
|
local __parm="$2"
|
||||||
|
for i in $(/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q get cwmp.@notifications[0].$list);do
|
||||||
|
if [ "`echo $i|grep $__parm`" != "" ];then
|
||||||
|
uci_remove_list_element "cwmp.@notifications[0].$list" "$i" 2>/dev/null
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
freecwmp_set_parameter_notification() {
|
freecwmp_set_parameter_notification() {
|
||||||
local _parm="$1"
|
local _parm="$1"
|
||||||
local _val="$2"
|
local _val="$2"
|
||||||
|
|
@ -395,13 +406,24 @@ freecwmp_set_parameter_notification() {
|
||||||
uci_remove_list_element "cwmp.@notifications[0].passive" "$_parm" 2>/dev/null
|
uci_remove_list_element "cwmp.@notifications[0].passive" "$_parm" 2>/dev/null
|
||||||
uci_remove_list_element "cwmp.@notifications[0].active" "$_parm" 2>/dev/null
|
uci_remove_list_element "cwmp.@notifications[0].active" "$_parm" 2>/dev/null
|
||||||
uci_remove_list_element "cwmp.@notifications[0].disabled" "$_parm" 2>/dev/null
|
uci_remove_list_element "cwmp.@notifications[0].disabled" "$_parm" 2>/dev/null
|
||||||
|
|
||||||
|
freecwmp_update_notification "passive" "$_parm" 2>/dev/null
|
||||||
|
freecwmp_update_notification "active" "$_parm" 2>/dev/null
|
||||||
|
freecwmp_update_notification "disabled" "$_parm" 2>/dev/null
|
||||||
|
fi
|
||||||
|
if [ "`echo $_parm|grep '\.$'`" = "" ]; then
|
||||||
|
_parent="${_parm%.*}."
|
||||||
|
config_foreach freecwmp_config_notifications "notifications" "get" "$_parent" "_val_p"
|
||||||
|
else
|
||||||
|
_parent="${_parm%.*.}."
|
||||||
|
config_foreach freecwmp_config_notifications "notifications" "get" "$_parent" "_val_p"
|
||||||
fi
|
fi
|
||||||
if [ "$_val" -eq "1" ]; then
|
if [ "$_val" -eq "1" ]; then
|
||||||
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q add_list cwmp.@notifications[0].passive="$_parm" 2>&1 >/dev/null
|
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q add_list cwmp.@notifications[0].passive="$_parm" 2>&1 >/dev/null
|
||||||
elif [ "$_val" -eq "2" ]; then
|
elif [ "$_val" -eq "2" ]; then
|
||||||
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q add_list cwmp.@notifications[0].active="$_parm" 2>&1 >/dev/null
|
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q add_list cwmp.@notifications[0].active="$_parm" 2>&1 >/dev/null
|
||||||
#elif [ "$_val" -eq "0" ]; then
|
elif [ "$_val" -eq "0" -a "$_val_p" != "" -a "$_val_p" != "0" ]; then
|
||||||
#/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q add_list cwmp.@notifications[0].disabled="$_parm" 2>&1 >/dev/null
|
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q add_list cwmp.@notifications[0].disabled="$_parm" 2>&1 >/dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -521,6 +543,9 @@ freecwmp_execute_functions()
|
||||||
|
|
||||||
for function_name in $function_list
|
for function_name in $function_list
|
||||||
do
|
do
|
||||||
|
func=$(echo "$arg1" | cut -d "." -f 2)
|
||||||
|
func_config=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} get -q cwmp.@$func[0].function`
|
||||||
|
if [ "`echo $function_name|grep \"$func_config\"`" != "" -o "$func" = "" ];then
|
||||||
$function_name "$arg1" "$arg2" "$arg3"
|
$function_name "$arg1" "$arg2" "$arg3"
|
||||||
fault_code="$?"
|
fault_code="$?"
|
||||||
if [ "$fault_code" = "0" ]; then
|
if [ "$fault_code" = "0" ]; then
|
||||||
|
|
@ -528,6 +553,7 @@ freecwmp_execute_functions()
|
||||||
fi
|
fi
|
||||||
if [ "$fault_code" != "0" -a "$fault_code" != "$FAULT_CPE_INVALID_PARAMETER_NAME" ]; then
|
if [ "$fault_code" != "0" -a "$fault_code" != "$FAULT_CPE_INVALID_PARAMETER_NAME" ]; then
|
||||||
return $fault_code
|
return $fault_code
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ "$no_fault" = "1" ]; then fault_code="0"; fi
|
if [ "$no_fault" = "1" ]; then fault_code="0"; fi
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
|
# Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
|
||||||
# Copyright (C) 2012 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
# Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
|
# Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
|
|
||||||
get_device_hosts_number_of_leases() {
|
get_device_hosts_number_of_leases() {
|
||||||
local _static=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} show dhcp 2> /dev/null | fgrep 'dhcp.' | fgrep '.mac=' | wc -l`
|
local _static=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} show dhcp 2> /dev/null | fgrep 'dhcp.' | fgrep '.mac=' | wc -l`
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
|
# Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
|
||||||
# Copyright (C) 2012 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
# Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
|
# Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
|
|
||||||
get_device_info_manufacturer() {
|
get_device_info_manufacturer() {
|
||||||
local val=""
|
local val=""
|
||||||
|
|
@ -76,7 +77,7 @@ local dslAnnex=""
|
||||||
case "$action" in
|
case "$action" in
|
||||||
get_value)
|
get_value)
|
||||||
dslAnnex=`cat /proc/nvram/dslAnnex 2> /dev/null`
|
dslAnnex=`cat /proc/nvram/dslAnnex 2> /dev/null`
|
||||||
val=`cat /etc/iop_version | cut -d'-' -f1 | sed s/$/"$dslAnnex"/ 2> /dev/null`
|
val=`cat /etc/iop_version | cut -d'-' -f1 | sed s/$/"$dslAnnex"/ 2> /dev/null`
|
||||||
;;
|
;;
|
||||||
get_name)
|
get_name)
|
||||||
permissions="0"
|
permissions="0"
|
||||||
|
|
@ -108,6 +109,7 @@ freecwmp_output "InternetGatewayDevice.DeviceInfo.SoftwareVersion" "$val" "$perm
|
||||||
get_device_info_uptime() {
|
get_device_info_uptime() {
|
||||||
local val=""
|
local val=""
|
||||||
local permissions=""
|
local permissions=""
|
||||||
|
local type="xsd:unsignedInt"
|
||||||
case "$action" in
|
case "$action" in
|
||||||
get_value)
|
get_value)
|
||||||
val=`cat /proc/uptime | awk -F "." '{ print $1 }'`
|
val=`cat /proc/uptime | awk -F "." '{ print $1 }'`
|
||||||
|
|
@ -119,7 +121,7 @@ case "$action" in
|
||||||
freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.UpTime"
|
freecwmp_get_parameter_notification "val" "InternetGatewayDevice.DeviceInfo.UpTime"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val" "$permissions"
|
freecwmp_output "InternetGatewayDevice.DeviceInfo.UpTime" "$val" "$permissions" "$type"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_device_info_device_log() {
|
get_device_info_device_log() {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
|
# Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
|
||||||
# Copyright (C) 2012 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
# Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
|
# Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
|
|
||||||
# TODO: LIMITATIONS: we only handle one device router at the moment
|
# TODO: LIMITATIONS: we only handle one device router at the moment
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
|
# Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
|
||||||
# Copyright (C) 2012 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
# Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
|
# Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
|
|
||||||
get_device_users() {
|
get_device_users() {
|
||||||
local parameter="$1"
|
local parameter="$1"
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
|
# Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
|
||||||
# Copyright (C) 2012 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
# Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
|
# Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
|
|
||||||
get_management_server_url() {
|
get_management_server_url() {
|
||||||
local tmp=${FLAGS_value}
|
local tmp=${FLAGS_value}
|
||||||
|
|
@ -78,7 +79,8 @@ local permissions=""
|
||||||
local parm="InternetGatewayDevice.ManagementServer.Password"
|
local parm="InternetGatewayDevice.ManagementServer.Password"
|
||||||
case "$action" in
|
case "$action" in
|
||||||
get_value)
|
get_value)
|
||||||
val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q get cwmp.acs.passwd 2> /dev/null`
|
# returned value must be empty
|
||||||
|
val=""
|
||||||
;;
|
;;
|
||||||
get_name)
|
get_name)
|
||||||
permissions="1"
|
permissions="1"
|
||||||
|
|
@ -275,7 +277,8 @@ local parm="InternetGatewayDevice.ManagementServer.ConnectionRequestPassword"
|
||||||
local permissions=""
|
local permissions=""
|
||||||
case "$action" in
|
case "$action" in
|
||||||
get_value)
|
get_value)
|
||||||
val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q get cwmp.cpe.passwd 2> /dev/null`
|
# returned value must be empty
|
||||||
|
val=""
|
||||||
;;
|
;;
|
||||||
get_name)
|
get_name)
|
||||||
permissions="1"
|
permissions="1"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
|
# Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
|
||||||
# Copyright (C) 2012 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
# Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
|
# Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
|
|
||||||
get_misc_cpu_usage() {
|
get_misc_cpu_usage() {
|
||||||
local val=`uptime | awk -F'average: ' '{ print $2 }' | awk -F',' '{ print $1 }' | awk -F'.' '{ print $2 }'`
|
local val=`uptime | awk -F'average: ' '{ print $2 }' | awk -F',' '{ print $1 }' | awk -F'.' '{ print $2 }'`
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
|
# Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
|
||||||
# Copyright (C) 2012 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
# Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
|
# Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
|
|
||||||
get_wan_logical_intf() {
|
get_wan_logical_intf() {
|
||||||
local intf="$1"
|
local intf="$1"
|
||||||
|
|
@ -86,6 +87,41 @@ for intf in $list_interface;do
|
||||||
$populate "$parameter" "InternetGatewayDevice.WANDevice.$dev." "get_wan_device_object_name" "" "$value" "$notification" "$next_level" "$iface"
|
$populate "$parameter" "InternetGatewayDevice.WANDevice.$dev." "get_wan_device_object_name" "" "$value" "$notification" "$next_level" "$iface"
|
||||||
$populate "$parameter" "InternetGatewayDevice.WANDevice.$dev.WANConnectionDevice." "get_wan_device_object_name" "" "$value" "$notification" "$next_level" "$iface"
|
$populate "$parameter" "InternetGatewayDevice.WANDevice.$dev.WANConnectionDevice." "get_wan_device_object_name" "" "$value" "$notification" "$next_level" "$iface"
|
||||||
$populate "$parameter" "InternetGatewayDevice.WANDevice.$dev.WANConnectionDevice.$wan." "get_wan_device_object_name" "" "$value" "$notification" "$next_level" "$iface"
|
$populate "$parameter" "InternetGatewayDevice.WANDevice.$dev.WANConnectionDevice.$wan." "get_wan_device_object_name" "" "$value" "$notification" "$next_level" "$iface"
|
||||||
|
|
||||||
|
|
||||||
|
$populate "$parameter" "InternetGatewayDevice.WANDevice.$dev.WANCommonInterfaceConfig." "get_wan_device_object_ro_name" "" "$value" "$notification" "$next_level" "$iface"
|
||||||
|
$populate "$parameter" "InternetGatewayDevice.WANDevice.$dev.WANCommonInterfaceConfig.WANAccessType" "get_wan_device_wan_access_type" "" "$value" "$notification" "$next_level" "$iface"
|
||||||
|
fault_code="$?"
|
||||||
|
if [ "$fault_code" = "$FAULT_CPE_NO_FAULT" ];then
|
||||||
|
fault_err=$FAULT_CPE_NO_FAULT
|
||||||
|
fi
|
||||||
|
if [ \( "`echo $parameter|grep '\.$'`" = "" -o "$populate" = "get_pop_inform" \) -a "$fault_code" = "$FAULT_CPE_NO_FAULT" ];then
|
||||||
|
return $fault_code
|
||||||
|
elif [ "$fault_code" != "$FAULT_CPE_INVALID_PARAMETER_NAME" -a "$fault_code" != "$FAULT_CPE_NO_FAULT" ];then
|
||||||
|
return $fault_code
|
||||||
|
fi
|
||||||
|
$populate "$parameter" "InternetGatewayDevice.WANDevice.$dev.WANDSLInterfaceConfig." "get_wan_device_object_ro_name" "" "$value" "$notification" "$next_level" "$iface"
|
||||||
|
$populate "$parameter" "InternetGatewayDevice.WANDevice.$dev.WANDSLInterfaceConfig.Status" "get_wan_device_wan_dsl_interface_config_status" "" "$value" "$notification" "$next_level" "$iface"
|
||||||
|
fault_code="$?"
|
||||||
|
if [ "$fault_code" = "$FAULT_CPE_NO_FAULT" ];then
|
||||||
|
fault_err=$FAULT_CPE_NO_FAULT
|
||||||
|
fi
|
||||||
|
if [ \( "`echo $parameter|grep '\.$'`" = "" -o "$populate" = "get_pop_inform" \) -a "$fault_code" = "$FAULT_CPE_NO_FAULT" ];then
|
||||||
|
return $fault_code
|
||||||
|
elif [ "$fault_code" != "$FAULT_CPE_INVALID_PARAMETER_NAME" -a "$fault_code" != "$FAULT_CPE_NO_FAULT" ];then
|
||||||
|
return $fault_code
|
||||||
|
fi
|
||||||
|
$populate "$parameter" "InternetGatewayDevice.WANDevice.$dev.WANDSLInterfaceConfig.ModulationType" "get_wan_device_wan_dsl_interface_config_modulation_type" "" "$value" "$notification" "$next_level" "$iface"
|
||||||
|
fault_code="$?"
|
||||||
|
if [ "$fault_code" = "$FAULT_CPE_NO_FAULT" ];then
|
||||||
|
fault_err=$FAULT_CPE_NO_FAULT
|
||||||
|
fi
|
||||||
|
if [ \( "`echo $parameter|grep '\.$'`" = "" -o "$populate" = "get_pop_inform" \) -a "$fault_code" = "$FAULT_CPE_NO_FAULT" ];then
|
||||||
|
return $fault_code
|
||||||
|
elif [ "$fault_code" != "$FAULT_CPE_INVALID_PARAMETER_NAME" -a "$fault_code" != "$FAULT_CPE_NO_FAULT" ];then
|
||||||
|
return $fault_code
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$proto" = "dhcp" -o "$proto" = "static" ];then
|
if [ "$proto" = "dhcp" -o "$proto" = "static" ];then
|
||||||
$populate "$parameter" "InternetGatewayDevice.WANDevice.$dev.WANConnectionDevice.$wan.WANIPConnection." "get_wan_device_object_name" "" "$value" "$notification" "$next_level" "$iface"
|
$populate "$parameter" "InternetGatewayDevice.WANDevice.$dev.WANConnectionDevice.$wan.WANIPConnection." "get_wan_device_object_name" "" "$value" "$notification" "$next_level" "$iface"
|
||||||
fault_code="$?"
|
fault_code="$?"
|
||||||
|
|
@ -228,6 +264,109 @@ done
|
||||||
return $fault_err
|
return $fault_err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_wan_device_wan_access_type() {
|
||||||
|
local val=""
|
||||||
|
local type="xsd:string"
|
||||||
|
local parm="$1"
|
||||||
|
local permissions=""
|
||||||
|
local intf="$2"
|
||||||
|
case "$action" in
|
||||||
|
get_value)
|
||||||
|
json_load "$(ifstatus $intf)"
|
||||||
|
json_get_var device device
|
||||||
|
if [ "${device:0:3}" = "eth" ];then
|
||||||
|
val="Ethernet"
|
||||||
|
elif [ "${device:0:3}" = "atm" -o "${device:3:3}" = "ptm" ];then
|
||||||
|
val="DSL"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
get_name)
|
||||||
|
permissions="0"
|
||||||
|
;;
|
||||||
|
get_notification)
|
||||||
|
freecwmp_get_parameter_notification "val" "$parm"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
freecwmp_output "$parm" "$val" "$permissions" "$type"
|
||||||
|
}
|
||||||
|
|
||||||
|
get_wan_device_wan_dsl_interface_config_status() {
|
||||||
|
local val=""
|
||||||
|
local type="xsd:string"
|
||||||
|
local parm="$1"
|
||||||
|
local permissions=""
|
||||||
|
local intf="$2"
|
||||||
|
case "$action" in
|
||||||
|
get_value)
|
||||||
|
adsl_shown=`adsl info --stats|grep "^Status:"|cut -f2 -d:|sed 's/\t*//g'|sed 's/^ *//g'|sed 's/ *$//g'`
|
||||||
|
case "$adsl_shown" in
|
||||||
|
"Showtime")
|
||||||
|
val="Up"
|
||||||
|
;;
|
||||||
|
"Training")
|
||||||
|
val="Initializing"
|
||||||
|
;;
|
||||||
|
"Channel Analysis")
|
||||||
|
val="EstablishingLink"
|
||||||
|
;;
|
||||||
|
"Disabled")
|
||||||
|
val="Disabled"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
get_name)
|
||||||
|
permissions="0"
|
||||||
|
;;
|
||||||
|
get_notification)
|
||||||
|
freecwmp_get_parameter_notification "val" "$parm"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
freecwmp_output "$parm" "$val" "$permissions" "$type"
|
||||||
|
}
|
||||||
|
|
||||||
|
get_wan_device_wan_dsl_interface_config_modulation_type() {
|
||||||
|
local val=""
|
||||||
|
local type="xsd:string"
|
||||||
|
local parm="$1"
|
||||||
|
local permissions=""
|
||||||
|
local intf="$2"
|
||||||
|
case "$action" in
|
||||||
|
get_value)
|
||||||
|
adsl_shown=`adsl info --stats|grep "Mode:"|cut -f2 -d:|sed 's/\t*//g'|sed 's/^ *//g'|cut -f1 -d ' '`
|
||||||
|
case "$adsl_shown" in
|
||||||
|
G.Dmt)
|
||||||
|
val="ADSL_G.dmt"
|
||||||
|
;;
|
||||||
|
G.lite)
|
||||||
|
val="ADSL_G.lite"
|
||||||
|
;;
|
||||||
|
T1.413)
|
||||||
|
val="ADSL_ANSI_T1 .413"
|
||||||
|
;;
|
||||||
|
ADSL2)
|
||||||
|
val="ADSL_G.dmt.bis"
|
||||||
|
;;
|
||||||
|
AnnexL)
|
||||||
|
val="ADSL_re-adsl"
|
||||||
|
;;
|
||||||
|
ADSL2+)
|
||||||
|
val="ADSL_2plus"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
val="$adsl_shown"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
get_name)
|
||||||
|
permissions="0"
|
||||||
|
;;
|
||||||
|
get_notification)
|
||||||
|
freecwmp_get_parameter_notification "val" "$parm"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
freecwmp_output "$parm" "$val" "$permissions" "$type"
|
||||||
|
}
|
||||||
|
|
||||||
get_wan_device_wan_mng_enable() {
|
get_wan_device_wan_mng_enable() {
|
||||||
local val=""
|
local val=""
|
||||||
local type="xsd:boolean"
|
local type="xsd:boolean"
|
||||||
|
|
@ -286,7 +425,7 @@ case "$action" in
|
||||||
fi
|
fi
|
||||||
if [ $uptime -gt 0 ];then
|
if [ $uptime -gt 0 ];then
|
||||||
val="Connected"
|
val="Connected"
|
||||||
elif [ $pending = 1 ];then
|
elif [ "$pending" = "1" ];then
|
||||||
val="Pending Disconnect"
|
val="Pending Disconnect"
|
||||||
else
|
else
|
||||||
val="Disconnected"
|
val="Disconnected"
|
||||||
|
|
@ -486,7 +625,8 @@ local permissions=""
|
||||||
local intf="$2"
|
local intf="$2"
|
||||||
case "$action" in
|
case "$action" in
|
||||||
get_value)
|
get_value)
|
||||||
val=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q get network.$intf.password 2> /dev/null`
|
# returned value must be empty
|
||||||
|
val=""
|
||||||
;;
|
;;
|
||||||
get_name)
|
get_name)
|
||||||
permissions="1"
|
permissions="1"
|
||||||
|
|
@ -534,6 +674,11 @@ freecwmp_output "$parm" "" "1"
|
||||||
return $FAULT_CPE_NO_FAULT
|
return $FAULT_CPE_NO_FAULT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_wan_device_object_ro_name() {
|
||||||
|
local parm="$1"
|
||||||
|
freecwmp_output "$parm" "" "0"
|
||||||
|
return $FAULT_CPE_NO_FAULT
|
||||||
|
}
|
||||||
get_pop_inform() {
|
get_pop_inform() {
|
||||||
local parameter="$1"
|
local parameter="$1"
|
||||||
local parm="$2"
|
local parm="$2"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
#!/usr/sbin/bash
|
#!/usr/sbin/bash
|
||||||
|
# Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
|
# Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
echo "Usage: $0 <strength> <passphrase>"
|
echo "Usage: $0 <strength> <passphrase>"
|
||||||
|
|
|
||||||
6
ubus.c
6
ubus.c
|
|
@ -3,10 +3,10 @@
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* Contributed by Inteno Broadband Technology AB
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
* Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
* Copyright (C) 2013 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
* Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
||||||
|
* Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
* Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
|
* Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
97
xml.c
97
xml.c
|
|
@ -3,10 +3,10 @@
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 2 of the License, or
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* Contributed by Inteno Broadband Technology AB
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
* Copyright (C) 2013 Inteno Broadband Technology AB
|
||||||
* Copyright (C) 2013 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
* Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
||||||
|
* Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
||||||
* Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
|
* Copyright (C) 2011-2012 Luka Perkov <freecwmp@lukaperkov.net>
|
||||||
* Copyright (C) 2012 Jonas Gorski <jonas.gorski@gmail.com>
|
* Copyright (C) 2012 Jonas Gorski <jonas.gorski@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
@ -450,7 +450,7 @@ static int xml_prepare_parameters_inform(struct parameter_container *parameter_c
|
||||||
}
|
}
|
||||||
else if (!b && parameter_container->data == NULL)
|
else if (!b && parameter_container->data == NULL)
|
||||||
{
|
{
|
||||||
external_get_action_write("value", parameter_container->name, NULL);
|
external_get_action("value", parameter_container->name, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
node = mxmlNewElement (parameter_list, "ParameterValueStruct");
|
node = mxmlNewElement (parameter_list, "ParameterValueStruct");
|
||||||
|
|
@ -506,28 +506,6 @@ int cwmp_rpc_acs_prepare_message_inform (struct cwmp *cwmp, struct session *sess
|
||||||
b = mxmlNewInteger(b, cwmp->retry_count_session);
|
b = mxmlNewInteger(b, cwmp->retry_count_session);
|
||||||
if (!b) goto error;
|
if (!b) goto error;
|
||||||
|
|
||||||
remove(fc_script_actions);
|
|
||||||
|
|
||||||
for (i=0; i<ARRAYSIZEOF(DEVICE_ID_CONST); i++)
|
|
||||||
if (external_get_action_write("value",DEVICE_ID_CONST[i].parameter_name, NULL)) return -1;
|
|
||||||
if (external_get_action_execute(cwmp_handle_getParamValues)) return -1;
|
|
||||||
while (external_list_parameter.next!=&external_list_parameter) {
|
|
||||||
parameter_container = list_entry(external_list_parameter.next, struct parameter_container, list);
|
|
||||||
for (i=0; i<ARRAYSIZEOF(DEVICE_ID_CONST); i++)
|
|
||||||
{
|
|
||||||
if(strcmp(DEVICE_ID_CONST[i].parameter_name, parameter_container->name)==0) {
|
|
||||||
if (parameter_container->fault_code && parameter_container->fault_code[0]=='9')
|
|
||||||
goto error;
|
|
||||||
b = mxmlFindElement(tree, tree, DEVICE_ID_CONST[i].device_id_name, NULL, NULL, MXML_DESCEND);
|
|
||||||
if (!b) goto error;
|
|
||||||
|
|
||||||
b = mxmlNewText(b, 0, parameter_container->data? parameter_container->data : "");
|
|
||||||
if (!b) goto error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parameter_container_delete(parameter_container);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xml_prepare_events_inform(session, tree))
|
if (xml_prepare_events_inform(session, tree))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
|
@ -551,8 +529,25 @@ int cwmp_rpc_acs_prepare_message_inform (struct cwmp *cwmp, struct session *sess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
external_get_action_execute(cwmp_handle_getParamValues);
|
external_simple("inform");
|
||||||
external_simple("inform", cwmp_handle_getParamValues);
|
|
||||||
|
external_handle_action(cwmp_handle_getParamValues);
|
||||||
|
|
||||||
|
list_for_each(ilist, &(external_list_parameter)) {
|
||||||
|
parameter_container = list_entry(ilist, struct parameter_container, list);
|
||||||
|
for (i=0; i<ARRAYSIZEOF(DEVICE_ID_CONST); i++)
|
||||||
|
{
|
||||||
|
if(strcmp(DEVICE_ID_CONST[i].parameter_name, parameter_container->name)==0) {
|
||||||
|
if (parameter_container->fault_code && parameter_container->fault_code[0]=='9')
|
||||||
|
goto error;
|
||||||
|
b = mxmlFindElement(tree, tree, DEVICE_ID_CONST[i].device_id_name, NULL, NULL, MXML_DESCEND);
|
||||||
|
if (!b) goto error;
|
||||||
|
|
||||||
|
b = mxmlNewText(b, 0, parameter_container->data? parameter_container->data : "");
|
||||||
|
if (!b) goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (external_list_parameter.next!=&external_list_parameter) {
|
while (external_list_parameter.next!=&external_list_parameter) {
|
||||||
|
|
||||||
|
|
@ -760,14 +755,14 @@ int cwmp_handle_rpc_cpe_get_parameter_values(struct session *session, struct rpc
|
||||||
parameter_name = "";
|
parameter_name = "";
|
||||||
}
|
}
|
||||||
if (parameter_name) {
|
if (parameter_name) {
|
||||||
if (external_get_action_write("value",parameter_name, NULL))
|
if (external_get_action("value", parameter_name, NULL))
|
||||||
goto fault;
|
goto fault;
|
||||||
}
|
}
|
||||||
b = mxmlWalkNext(b, session->body_in, MXML_DESCEND);
|
b = mxmlWalkNext(b, session->body_in, MXML_DESCEND);
|
||||||
parameter_name = NULL;
|
parameter_name = NULL;
|
||||||
}
|
}
|
||||||
if (external_get_action_execute(cwmp_handle_getParamValues))
|
|
||||||
goto fault;
|
external_handle_action(cwmp_handle_getParamValues);
|
||||||
|
|
||||||
while (external_list_parameter.next!=&external_list_parameter) {
|
while (external_list_parameter.next!=&external_list_parameter) {
|
||||||
parameter_container = list_entry(external_list_parameter.next, struct parameter_container, list);
|
parameter_container = list_entry(external_list_parameter.next, struct parameter_container, list);
|
||||||
|
|
@ -874,10 +869,12 @@ int cwmp_handle_rpc_cpe_get_parameter_names(struct session *session, struct rpc
|
||||||
b = mxmlWalkNext(b, session->body_in, MXML_DESCEND);
|
b = mxmlWalkNext(b, session->body_in, MXML_DESCEND);
|
||||||
}
|
}
|
||||||
if (parameter_name && NextLevel) {
|
if (parameter_name && NextLevel) {
|
||||||
if (external_get_action("name", parameter_name, NextLevel, cwmp_handle_getParamNames))
|
if (external_get_action("name", parameter_name, NextLevel))
|
||||||
goto fault;
|
goto fault;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
external_handle_action(cwmp_handle_getParamNames);
|
||||||
|
|
||||||
while (external_list_parameter.next!=&external_list_parameter) {
|
while (external_list_parameter.next!=&external_list_parameter) {
|
||||||
|
|
||||||
parameter_container = list_entry(external_list_parameter.next, struct parameter_container, list);
|
parameter_container = list_entry(external_list_parameter.next, struct parameter_container, list);
|
||||||
|
|
@ -974,14 +971,14 @@ int cwmp_handle_rpc_cpe_get_parameter_attributes(struct session *session, struct
|
||||||
parameter_name = "";
|
parameter_name = "";
|
||||||
}
|
}
|
||||||
if (parameter_name) {
|
if (parameter_name) {
|
||||||
if (external_get_action_write("notification",parameter_name, NULL))
|
if (external_get_action("notification",parameter_name, NULL))
|
||||||
goto fault;
|
goto fault;
|
||||||
}
|
}
|
||||||
b = mxmlWalkNext(b, session->body_in, MXML_DESCEND);
|
b = mxmlWalkNext(b, session->body_in, MXML_DESCEND);
|
||||||
parameter_name = NULL;
|
parameter_name = NULL;
|
||||||
}
|
}
|
||||||
if (external_get_action_execute(cwmp_handle_getParamAttributes))
|
|
||||||
goto fault;
|
external_handle_action(cwmp_handle_getParamAttributes);
|
||||||
|
|
||||||
while (external_list_parameter.next!=&external_list_parameter) {
|
while (external_list_parameter.next!=&external_list_parameter) {
|
||||||
parameter_container = list_entry(external_list_parameter.next, struct parameter_container, list);
|
parameter_container = list_entry(external_list_parameter.next, struct parameter_container, list);
|
||||||
|
|
@ -1102,8 +1099,7 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct session *session, struct rpc
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameter_name && parameter_value) {
|
if (parameter_name && parameter_value) {
|
||||||
if (external_set_action_write("value",
|
if (external_set_action("value", parameter_name, parameter_value, NULL))
|
||||||
parameter_name, parameter_value,NULL))
|
|
||||||
goto fault;
|
goto fault;
|
||||||
parameter_name = NULL;
|
parameter_name = NULL;
|
||||||
parameter_value = NULL;
|
parameter_value = NULL;
|
||||||
|
|
@ -1121,9 +1117,11 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct session *session, struct rpc
|
||||||
if (b && b->value.text.string)
|
if (b && b->value.text.string)
|
||||||
parameter_key = b->value.text.string;
|
parameter_key = b->value.text.string;
|
||||||
|
|
||||||
if (external_set_action_execute("value",cwmp_handle_setParamValues))
|
if (external_apply("value", NULL))
|
||||||
goto fault;
|
goto fault;
|
||||||
|
|
||||||
|
external_handle_action(cwmp_handle_setParamValues);
|
||||||
|
|
||||||
while (external_list_parameter.next != &external_list_parameter) {
|
while (external_list_parameter.next != &external_list_parameter) {
|
||||||
parameter_container = list_entry(external_list_parameter.next, struct parameter_container, list);
|
parameter_container = list_entry(external_list_parameter.next, struct parameter_container, list);
|
||||||
|
|
||||||
|
|
@ -1220,8 +1218,8 @@ int cwmp_handle_rpc_cpe_set_parameter_attributes(struct session *session, struct
|
||||||
parameter_notification = b->value.text.string;
|
parameter_notification = b->value.text.string;
|
||||||
}
|
}
|
||||||
if (attr_notification_update && parameter_name && parameter_notification) {
|
if (attr_notification_update && parameter_name && parameter_notification) {
|
||||||
if (external_set_action_write("notification",
|
if (external_set_action("notification", parameter_name,
|
||||||
parameter_name, parameter_notification, attr_notification_update))
|
parameter_notification, attr_notification_update))
|
||||||
goto fault;
|
goto fault;
|
||||||
attr_notification_update = NULL;
|
attr_notification_update = NULL;
|
||||||
parameter_name = NULL;
|
parameter_name = NULL;
|
||||||
|
|
@ -1230,9 +1228,11 @@ int cwmp_handle_rpc_cpe_set_parameter_attributes(struct session *session, struct
|
||||||
b = mxmlWalkNext(b, n, MXML_DESCEND);
|
b = mxmlWalkNext(b, n, MXML_DESCEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (external_set_action_execute("notification", cwmp_handle_setParamAttributes))
|
if (external_apply("notification", NULL))
|
||||||
goto fault;
|
goto fault;
|
||||||
|
|
||||||
|
external_handle_action(cwmp_handle_setParamAttributes);
|
||||||
|
|
||||||
external_fetch_setParamAttrResp(&success, &fault);
|
external_fetch_setParamAttrResp(&success, &fault);
|
||||||
|
|
||||||
if (fault && fault[0]=='9')
|
if (fault && fault[0]=='9')
|
||||||
|
|
@ -1298,13 +1298,15 @@ int cwmp_handle_rpc_cpe_add_object(struct session *session, struct rpc *rpc)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (object_name) {
|
if (object_name) {
|
||||||
if (external_object_action("add", object_name, cwmp_handle_addObject))
|
if (external_object_action("add", object_name))
|
||||||
goto fault;
|
goto fault;
|
||||||
} else {
|
} else {
|
||||||
fault_code = FAULT_CPE_INVALID_PARAMETER_NAME;
|
fault_code = FAULT_CPE_INVALID_PARAMETER_NAME;
|
||||||
goto fault;
|
goto fault;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
external_handle_action(cwmp_handle_addObject);
|
||||||
|
|
||||||
external_fetch_addObjectResp(&instance, &status, &fault);
|
external_fetch_addObjectResp(&instance, &status, &fault);
|
||||||
|
|
||||||
if (fault && fault[0]=='9')
|
if (fault && fault[0]=='9')
|
||||||
|
|
@ -1391,13 +1393,15 @@ int cwmp_handle_rpc_cpe_delete_object(struct session *session, struct rpc *rpc)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (object_name) {
|
if (object_name) {
|
||||||
if (external_object_action("delete", object_name, cwmp_handle_delObject))
|
if (external_object_action("delete", object_name))
|
||||||
goto fault;
|
goto fault;
|
||||||
} else {
|
} else {
|
||||||
fault_code = FAULT_CPE_INVALID_PARAMETER_NAME;
|
fault_code = FAULT_CPE_INVALID_PARAMETER_NAME;
|
||||||
goto fault;
|
goto fault;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
external_handle_action(cwmp_handle_delObject);
|
||||||
|
|
||||||
external_fetch_delObjectResp(&status, &fault);
|
external_fetch_delObjectResp(&status, &fault);
|
||||||
|
|
||||||
if (fault && fault[0]=='9')
|
if (fault && fault[0]=='9')
|
||||||
|
|
@ -1798,8 +1802,8 @@ int cwmp_launch_download(struct download *pdownload, struct transfer_complete **
|
||||||
|
|
||||||
sprintf(file_size,"%d",pdownload->file_size);
|
sprintf(file_size,"%d",pdownload->file_size);
|
||||||
external_download(pdownload->url, file_size, pdownload->file_type,
|
external_download(pdownload->url, file_size, pdownload->file_type,
|
||||||
pdownload->username, pdownload->password,
|
pdownload->username, pdownload->password);
|
||||||
cwmp_handle_downloadFault);
|
external_handle_action(cwmp_handle_downloadFault);
|
||||||
external_fetch_downloadFaultResp(&fault_code);
|
external_fetch_downloadFaultResp(&fault_code);
|
||||||
|
|
||||||
if(fault_code != NULL)
|
if(fault_code != NULL)
|
||||||
|
|
@ -1895,7 +1899,8 @@ void *thread_cwmp_rpc_cpe_download (void *v)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bkp_session_save();
|
bkp_session_save();
|
||||||
external_apply_download(pdownload->file_type, cwmp_handle_downloadFault);
|
external_apply("download", pdownload->file_type);
|
||||||
|
external_handle_action(cwmp_handle_downloadFault);
|
||||||
external_fetch_downloadFaultResp(&fault_code);
|
external_fetch_downloadFaultResp(&fault_code);
|
||||||
if(fault_code != NULL)
|
if(fault_code != NULL)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue