link icwmpd to libbbfdm library (data model) after separating libbbfdm into two libraries: libbbf_api (API) and libbbfdm (data model)

This commit is contained in:
Amin Ben Ramdhane 2020-01-21 22:53:06 +01:00
parent f53b68619d
commit c2aef83959
14 changed files with 290 additions and 55 deletions

View file

@ -38,6 +38,31 @@ int bulkdata_dm_ctx_clean(struct dmctx *ctx)
return 0;
}
static char **str_split(const char* str, const char* delim, size_t* numtokens)
{
char *s = strdup(str);
size_t tokens_alloc = 1;
size_t tokens_used = 0;
char **tokens = calloc(tokens_alloc, sizeof(char*));
char *token, *strtok_ctx;
for (token = strtok_r(s, delim, &strtok_ctx); token != NULL; token = strtok_r(NULL, delim, &strtok_ctx)) {
if (tokens_used == tokens_alloc) {
tokens_alloc *= 2;
tokens = realloc(tokens, tokens_alloc * sizeof(char*));
}
tokens[tokens_used++] = strdup(token);
}
// cleanup
if (tokens_used == 0) {
FREE(tokens);
} else {
tokens = realloc(tokens, tokens_used * sizeof(char*));
}
*numtokens = tokens_used;
FREE(s);
return tokens;
}
static bool match(const char *string, const char *pattern)
{
regex_t re;
@ -333,7 +358,7 @@ char *get_bulkdata_profile_parameter_name(char *paramref, char *paramname, char
if(paramname == NULL || strlen(paramname) <= 0)
return strdup(param);
paramarr = strsplit(paramref, "*", &length);
paramarr = str_split(paramref, "*", &length);
res = strdup(paramname);
for(i = 0; i < length; i++) {
if(i == length - 1)

View file

@ -23,10 +23,8 @@
#include <libubox/utils.h>
#include <libubus.h>
#include <libbbfdm/dmubus.h>
#include <libbbfdm/dmcommon.h>
#include <libbbfdm/dmentry.h>
#include <libbbfdm/dmjson.h>
#include <libbbfdm/dmbbfcommon.h>
#include "config.h"
#include "log.h"

View file

@ -57,7 +57,7 @@ static void create_json_bulkdata_report_object_hierarchy(struct profile *profile
strcpy(buf, param_name);
for (pch = strtok_r(buf, ".", &pchr); pch != NULL; pch = strtok_r(NULL, ".", &pchr)) {
argv[j] = pch;
json_obj1 = dmjson_select_obj(json_obj, argv);
json_obj1 = (json_object *)bbfdmjson_select_obj(json_obj, argv);
if (json_obj1)
json_obj2 = json_obj1;
else {

View file

@ -29,6 +29,7 @@
#include <libtr098/deviceinfo.h>
#else
#include <libbbfdm/dmentry.h>
#include <libbbfdm/dmbbfcommon.h>
#include <libbbfdm/deviceinfo.h>
#endif
#include "config.h"
@ -1061,16 +1062,32 @@ int global_env_init (int argc, char** argv, struct env *env)
case 'u':
upnpuser = optarg;
if (strcmp(upnpuser, "public") == 0) {
#ifdef TR098
upnp_in_user_mask = DM_PUBLIC_MASK;
#else
set_upnp_in_user_mask(DM_PUBLIC_MASK);
#endif
}
else if (strcmp(upnpuser, "basic") == 0) {
#ifdef TR098
upnp_in_user_mask = DM_BASIC_MASK;
#else
set_upnp_in_user_mask(DM_BASIC_MASK);
#endif
}
else if (strcmp(upnpuser, "xxxadmin") == 0) {
#ifdef TR098
upnp_in_user_mask = DM_XXXADMIN_MASK;
#else
set_upnp_in_user_mask(DM_XXXADMIN_MASK);
#endif
}
else if (strcmp(upnpuser, "superadmin") == 0) {
#ifdef TR098
upnp_in_user_mask = DM_SUPERADMIN_MASK;
#else
set_upnp_in_user_mask(DM_SUPERADMIN_MASK);
#endif
}
break;

View file

@ -45,4 +45,4 @@ config cwmp 'cpe'
config cwmp 'lwn'
option enable '1'
option hostname ''
option port ''
option port ''

View file

@ -1,4 +1,4 @@
config cwmp 'xmpp'
config cwmp 'xmpp'
option enable '0'
option id '0'
option allowed_jid ''

71
cwmp.c
View file

@ -25,15 +25,6 @@
#include "ubus.h"
#include "diagnostic.h"
#include "config.h"
#include <unistd.h>
#ifdef TR098
#include <libtr098/dmentry.h>
#include <libtr098/dmtr098.h>
#else
#include <libbbfdm/dmentry.h>
#include <libbbfdm/dmbbf.h>
#include <libbbfdm/dmdiagnostics.h>
#endif
struct cwmp cwmp_main = {0};
@ -509,9 +500,17 @@ struct session *cwmp_add_queue_session (struct cwmp *cwmp)
int run_session_end_func (struct session *session)
{
#ifndef TR098
bbf_apply_end_session();
#else
apply_end_session();
#endif
#ifndef TR098
if (set_bbf_end_session_flag(END_SESSION_EXTERNAL_ACTION))
#else
if (end_session_flag & END_SESSION_EXTERNAL_ACTION)
#endif
{
CWMP_LOG (INFO,"Executing external commands: end session request");
external_init();
@ -519,7 +518,11 @@ int run_session_end_func (struct session *session)
external_exit();
}
#ifndef TR098
if (set_bbf_end_session_flag(END_SESSION_FACTORY_RESET))
#else
if (end_session_flag & END_SESSION_FACTORY_RESET)
#endif
{
CWMP_LOG (INFO,"Executing factory reset: end session request");
external_init();
@ -528,25 +531,34 @@ int run_session_end_func (struct session *session)
exit(EXIT_SUCCESS);
}
#ifndef TR098
if (set_bbf_end_session_flag(END_SESSION_IPPING_DIAGNOSTIC))
#else
if (end_session_flag & END_SESSION_IPPING_DIAGNOSTIC)
#endif
{
CWMP_LOG (INFO,"Executing ippingdiagnostic: end session request");
cwmp_ip_ping_diagnostic();
}
#ifndef TR098
if (end_session_flag & END_SESSION_DOWNLOAD_DIAGNOSTIC)
if (set_bbf_end_session_flag(END_SESSION_DOWNLOAD_DIAGNOSTIC))
{
CWMP_LOG (INFO,"Executing download diagnostic: end session request");
cwmp_start_diagnostic(DOWNLOAD_DIAGNOSTIC);
}
if (end_session_flag & END_SESSION_UPLOAD_DIAGNOSTIC)
if (set_bbf_end_session_flag(END_SESSION_UPLOAD_DIAGNOSTIC))
{
CWMP_LOG (INFO,"Executing upload diagnostic: end session request");
cwmp_start_diagnostic(UPLOAD_DIAGNOSTIC);
}
#endif
#ifndef TR098
if (set_bbf_end_session_flag(END_SESSION_REBOOT))
#else
if (end_session_flag & END_SESSION_REBOOT)
#endif
{
CWMP_LOG (INFO,"Executing Reboot: end session request");
external_init();
@ -555,14 +567,21 @@ int run_session_end_func (struct session *session)
exit(EXIT_SUCCESS);
}
#ifndef TR098
if (set_bbf_end_session_flag(END_SESSION_RELOAD))
#else
if (end_session_flag & END_SESSION_RELOAD)
#endif
{
CWMP_LOG (INFO,"Config reload: end session request");
cwmp_apply_acs_changes();
}
#ifndef TR098
if (set_bbf_end_session_flag(END_SESSION_X_FACTORY_RESET_SOFT))
#else
if (end_session_flag & END_SESSION_X_FACTORY_RESET_SOFT)
#endif
{
CWMP_LOG (INFO,"Executing factory reset soft: end session request");
external_init();
@ -571,25 +590,41 @@ int run_session_end_func (struct session *session)
exit(EXIT_SUCCESS);
}
#ifndef TR098
if (set_bbf_end_session_flag(END_SESSION_NSLOOKUP_DIAGNOSTIC))
#else
if (end_session_flag & END_SESSION_NSLOOKUP_DIAGNOSTIC)
#endif
{
CWMP_LOG (INFO,"Executing nslookupdiagnostic: end session request");
cwmp_nslookup_diagnostic();
}
#ifndef TR098
if (set_bbf_end_session_flag(END_SESSION_TRACEROUTE_DIAGNOSTIC))
#else
if (end_session_flag & END_SESSION_TRACEROUTE_DIAGNOSTIC)
#endif
{
CWMP_LOG (INFO,"Executing traceroutediagnostic: end session request");
cwmp_traceroute_diagnostic();
}
#ifndef TR098
if (set_bbf_end_session_flag(END_SESSION_UDPECHO_DIAGNOSTIC))
#else
if (end_session_flag & END_SESSION_UDPECHO_DIAGNOSTIC)
#endif
{
CWMP_LOG (INFO,"Executing udpechodiagnostic: end session request");
cwmp_udp_echo_diagnostic();
}
#ifndef TR098
if (set_bbf_end_session_flag(END_SESSION_SERVERSELECTION_DIAGNOSTIC))
#else
if (end_session_flag & END_SESSION_SERVERSELECTION_DIAGNOSTIC)
#endif
{
CWMP_LOG (INFO,"Executing serverselectiondiagnostic: end session request");
cwmp_serverselection_diagnostic();
@ -597,7 +632,11 @@ int run_session_end_func (struct session *session)
dm_entry_restart_services();
#ifndef TR098
reset_bbf_end_session_flag();
#else
end_session_flag = 0;
#endif
return CWMP_OK;
}
@ -684,7 +723,7 @@ int main(int argc, char **argv)
struct sigaction act = {0};
#ifndef TR098
bbfdatamodel_type = BBFDM_CWMP; // To show only CWMP parameters
set_bbfdatamodel_type(BBFDM_CWMP); // To show only CWMP parameters
#endif
if (error = cwmp_init(argc, argv, cwmp))
@ -775,6 +814,8 @@ int main(int argc, char **argv)
CWMP_LOG(INFO,"EXIT ICWMP");
cwmp_exit();
free_json_dynamic_arrays();
#ifndef TR098
free_dynamic_arrays();
#endif
return CWMP_OK;
}

View file

@ -16,6 +16,7 @@
#include <getopt.h>
#include <string.h>
#include <time.h>
#include <sys/wait.h>
#include "cwmp.h"
#include "backupSession.h"
#include "xml.h"
@ -29,9 +30,89 @@
#include <libtr098/dmcommon.h>
#else
#include <libbbfdm/dmentry.h>
#include <libbbfdm/dmcommon.h>
#include <libbbfdm/dmdiagnostics.h>
#endif
static int icwmpd_cmd(char *cmd, int n, ...)
{
va_list arg;
int i, pid;
static int dmcmd_pfds[2];
char *argv[n+2];
argv[0] = cmd;
va_start(arg,n);
for (i=0; i<n; i++)
{
argv[i+1] = va_arg(arg, char*);
}
va_end(arg);
argv[n+1] = NULL;
if (pipe(dmcmd_pfds) < 0)
return -1;
if ((pid = fork()) == -1)
return -1;
if (pid == 0) {
/* child */
close(dmcmd_pfds[0]);
dup2(dmcmd_pfds[1], 1);
close(dmcmd_pfds[1]);
execvp(argv[0], (char **) argv);
exit(ESRCH);
} else if (pid < 0)
return -1;
/* parent */
close(dmcmd_pfds[1]);
int status;
while (waitpid(pid, &status, 0) != pid)
{
kill(pid, 0);
if (errno == ESRCH) {
return dmcmd_pfds[0];
}
}
return dmcmd_pfds[0];
}
static int icwmpd_cmd_no_wait(char *cmd, int n, ...)
{
va_list arg;
int i, pid;
static int dmcmd_pfds[2];
char *argv[n+2];
static char sargv[4][128];
argv[0] = cmd;
va_start(arg,n);
for (i=0; i<n; i++)
{
strcpy(sargv[i], va_arg(arg, char*));
argv[i+1] = sargv[i];
}
va_end(arg);
argv[n+1] = NULL;
if ((pid = fork()) == -1)
return -1;
if (pid == 0) {
execvp(argv[0], (char **) argv);
exit(ESRCH);
} else if (pid < 0)
return -1;
return 0;
}
#ifndef TR098
int cwmp_start_diagnostic(int diagnostic_type)
{
char *url = NULL;
@ -73,7 +154,7 @@ int cwmp_start_diagnostic(int diagnostic_type)
if (diagnostic_type == DOWNLOAD_DIAGNOSTIC)
{
CWMP_LOG(INFO,"Launch Download diagnostic with url %s", url);
dmcmd("/bin/sh", 5, DOWNLOAD_DIAGNOSTIC_PATH, "run", "cwmp", url, interface);
icwmpd_cmd("/bin/sh", 5, DOWNLOAD_DIAGNOSTIC_PATH, "run", "cwmp", url, interface);
uci_get_state_value("cwmp.@downloaddiagnostic[0].DiagnosticState", &status);
if (status && strcmp(status, "Completed") == 0)
{
@ -92,7 +173,7 @@ int cwmp_start_diagnostic(int diagnostic_type)
else
{
CWMP_LOG(INFO,"Launch Upload diagnostic with url %s", url);
dmcmd("/bin/sh", 6, UPLOAD_DIAGNOSTIC_PATH, "run", "cwmp", url, interface, size);
icwmpd_cmd("/bin/sh", 6, UPLOAD_DIAGNOSTIC_PATH, "run", "cwmp", url, interface, size);
uci_get_state_value("cwmp.@uploaddiagnostic[0].DiagnosticState", &status);
if (status && strcmp(status, "Completed") == 0)
{
@ -117,30 +198,30 @@ int cwmp_start_diagnostic(int diagnostic_type)
int cwmp_ip_ping_diagnostic()
{
dmcmd_no_wait("/bin/sh", 3, IPPING_PATH, "run", "cwmp");
icwmpd_cmd_no_wait("/bin/sh", 3, IPPING_PATH, "run", "cwmp");
return 0;
}
int cwmp_nslookup_diagnostic()
{
dmcmd_no_wait("/bin/sh", 3, NSLOOKUP_PATH, "run", "cwmp");
icwmpd_cmd_no_wait("/bin/sh", 3, NSLOOKUP_PATH, "run", "cwmp");
return 0;
}
int cwmp_traceroute_diagnostic()
{
dmcmd_no_wait("/bin/sh", 3, TRACEROUTE_PATH, "run", "cwmp");
icwmpd_cmd_no_wait("/bin/sh", 3, TRACEROUTE_PATH, "run", "cwmp");
return 0;
}
int cwmp_udp_echo_diagnostic()
{
dmcmd_no_wait("/bin/sh", 3, UDPECHO_PATH, "run", "cwmp");
icwmpd_cmd_no_wait("/bin/sh", 3, UDPECHO_PATH, "run", "cwmp");
return 0;
}
int cwmp_serverselection_diagnostic()
{
dmcmd_no_wait("/bin/sh", 3, SERVERSELECTION_PATH, "run", "cwmp");
icwmpd_cmd_no_wait("/bin/sh", 3, SERVERSELECTION_PATH, "run", "cwmp");
return 0;
}

46
event.c
View file

@ -31,12 +31,10 @@
#include <libtr098/deviceinfo.h>
#include <libtr098/dmjson.h>
#else
#include <libbbfdm/dmbbf.h>
#include <libbbfdm/dmcommon.h>
#include <libbbfdm/dmentry.h>
#include <libbbfdm/deviceinfo.h>
#include <libbbfdm/dmjson.h>
#endif
LIST_HEAD(list_value_change);
LIST_HEAD(list_lw_value_change);
pthread_mutex_t mutex_value_change = PTHREAD_MUTEX_INITIALIZER;
@ -339,6 +337,7 @@ void cwmp_add_notification(void)
int len = strlen(buf);
if (len)
buf[len-1] = '\0';
#ifdef TR098
dmjson_parse_init(buf);
dmjson_get_var("parameter", &jval);
parameter = strdup(jval);
@ -347,12 +346,28 @@ void cwmp_add_notification(void)
dmjson_get_var("notification", &jval);
notification = strdup(jval);
dmjson_parse_fini();
#else
bbfdmjson_parse_init(buf);
bbfdmjson_get_var("parameter", &jval);
parameter = strdup(jval);
bbfdmjson_get_var("value", &jval);
value = strdup(jval);
bbfdmjson_get_var("notification", &jval);
notification = strdup(jval);
bbfdmjson_parse_fini();
#endif
fault = dm_entry_param_method(&dmctx, CMD_GET_VALUE, parameter, NULL, NULL);
if (!fault && dmctx.list_parameter.next != &dmctx.list_parameter) {
dm_parameter = list_entry(dmctx.list_parameter.next, struct dm_parameter, list);
if (strcmp(dm_parameter->data, value) != 0) {
#ifdef TR098
dm_update_file_enabled_notify(parameter, dm_parameter->data);
iscopy = copy_temporary_file_to_original_file(DM_ENABLED_NOTIFY, DM_ENABLED_NOTIFY_TEMPORARY);
#else
bbfdm_update_file_enabled_notify(parameter, dm_parameter->data);
iscopy = dm_copy_temporary_file_to_original_file(DM_ENABLED_NOTIFY, DM_ENABLED_NOTIFY_TEMPORARY);
#endif
if(iscopy)
remove(DM_ENABLED_NOTIFY_TEMPORARY);
if (notification[0] == '1' || notification[0] == '2' || notification[0] == '4' || notification[0] == '6' )
@ -367,7 +382,12 @@ void cwmp_add_notification(void)
}
fclose(fp);
#ifdef TR098
list_for_each_entry(p, &list_enabled_lw_notify, list) {
#else
struct list_head bbf_list_enabled_lw_notify = get_bbf_list_enabled_lw_notify();
list_for_each_entry(p, &bbf_list_enabled_lw_notify, list) {
#endif
if (!initiate || i != 0)
dm_ctx_init_sub(&dmctx, DM_CWMP, cwmp_main.conf.amd_version, cwmp_main.conf.instance_mode);
i++;
@ -377,11 +397,13 @@ void cwmp_add_notification(void)
if (!fault && dmctx.list_parameter.next != &dmctx.list_parameter) {
dm_parameter = list_entry(dmctx.list_parameter.next, struct dm_parameter, list);
if (strcmp(dm_parameter->data, p->value) != 0) {
#ifdef TR098
dm_update_enabled_notify(p, dm_parameter->data);
if (p->notification[0] >= '3' )
add_lw_list_value_change(p->name, dm_parameter->data, dm_parameter->type);
if (p->notification[0] == '5' || p->notification[0] == '6')
lw_isactive = true;
#else
bbfdm_update_enabled_notify(p, dm_parameter->data);
#endif
if (p->notification[0] >= '3' ) add_lw_list_value_change(p->name, dm_parameter->data, dm_parameter->type);
if (p->notification[0] == '5' || p->notification[0] == '6') lw_isactive = true;
}
}
dm_ctx_clean_sub(&dmctx);
@ -481,7 +503,6 @@ int cwmp_root_cause_event_bootstrap (struct cwmp *cwmp)
int error,cmp=0;
struct event_container *event_container;
struct session *session;
char buf[64] = "";
error = cwmp_load_saved_session(cwmp, &acsurl, ACS);
@ -525,9 +546,12 @@ int cwmp_root_cause_event_bootstrap (struct cwmp *cwmp)
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return CWMP_MEM_ERR;
}
sprintf(buf, "%sManagementServer.URL", dmroot);
add_dm_parameter_tolist(&(event_container->head_dm_parameter),
buf, NULL, NULL);
#ifdef TR098
char buf[64] = "InternetGatewayDevice.ManagementServer.URL";
#else
char buf[64] = "Device.ManagementServer.URL";
#endif
add_dm_parameter_tolist(&(event_container->head_dm_parameter), buf, NULL, NULL);
cwmp_save_event_container (cwmp,event_container);
save_acs_bkp_config(cwmp);
cwmp_scheduleInform_remove_all();

View file

@ -18,6 +18,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
@ -29,12 +30,6 @@
#include "cwmp.h"
#include "xml.h"
#include "log.h"
#ifdef TR098
#include <libtr098/dmtr098.h>
#else
#include <libbbfdm/dmbbf.h>
#endif
#include <stdarg.h>
static int pid;
static json_object *json_obj_in;
@ -46,6 +41,8 @@ char *external_MethodVersion = NULL;
char *external_MethodUUID = NULL;
char *external_MethodENV = NULL;
#define ICWMP_PROMPT "icwmp>"
void external_downloadFaultResp (char *fault_code)
{
FREE(external_MethodFault);
@ -131,7 +128,7 @@ static void external_read_pipe_input(int (*external_handler)(char *msg))
value = c;
} else {
if (!value) continue;
if (strcmp(value, DM_PROMPT)==0) {
if (strcmp(value, ICWMP_PROMPT)==0) {
FREE(value);
break;
}

4
http.c
View file

@ -132,7 +132,11 @@ if (cwmp->conf.ipv6_enable) {
curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ip);
curl_easy_perform(curl);
int tmp = inet_pton(AF_INET, ip, buf);
#ifdef TR098
ip_version = (tmp == 1) ? 4 : 6;
#else
bbf_set_ip_version((tmp == 1) ? 4 : 6);
#endif
}
return 0;
}

View file

@ -15,14 +15,18 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <pthread.h>
#include <microxml.h>
#include <libubox/list.h>
#ifdef TR098
#include <libtr098/dmentry.h>
#include <libtr098/dmtr098.h>
#else
#include <libbbfdm/dmbbf.h>
#include <libbbfdm/dmentry.h>
#include <libbbfdm/dmbbfcommon.h>
#include <libbbfdm/dmdiagnostics.h>
#endif
#define MAX_EVENTS 64

21
ubus.c
View file

@ -93,14 +93,22 @@ cwmp_handle_command(struct ubus_context *ctx, struct ubus_object *obj,
if (!strcmp("reload_end_session", cmd)) {
CWMP_LOG(INFO, "triggered ubus reload_end_session");
#ifndef TR098
bbf_cwmp_set_end_session(END_SESSION_RELOAD);
#else
cwmp_set_end_session(END_SESSION_RELOAD);
#endif
blobmsg_add_u32(&b, "status", 0);
if (asprintf(&info, "icwmpd config will reload at the end of the session") == -1)
return -1;
} else if (!strcmp("reload", cmd)) {
CWMP_LOG(INFO, "triggered ubus reload");
if (cwmp_main.session_status.last_status == SESSION_RUNNING) {
#ifndef TR098
bbf_cwmp_set_end_session(END_SESSION_RELOAD);
#else
cwmp_set_end_session(END_SESSION_RELOAD);
#endif
blobmsg_add_u32(&b, "status", 0);
blobmsg_add_string(&b, "info", "Session running, reload at the end of the session");
}
@ -114,13 +122,21 @@ cwmp_handle_command(struct ubus_context *ctx, struct ubus_object *obj,
}
} else if (!strcmp("reboot_end_session", cmd)) {
CWMP_LOG(INFO, "triggered ubus reboot_end_session");
#ifndef TR098
bbf_cwmp_set_end_session(END_SESSION_REBOOT);
#else
cwmp_set_end_session(END_SESSION_REBOOT);
#endif
blobmsg_add_u32(&b, "status", 0);
if (asprintf(&info, "icwmpd will reboot at the end of the session") == -1)
return -1;
} else if (!strcmp("action_end_session", cmd)) {
CWMP_LOG(INFO, "triggered ubus action_end_session");
#ifndef TR098
bbf_cwmp_set_end_session(END_SESSION_EXTERNAL_ACTION);
#else
cwmp_set_end_session(END_SESSION_EXTERNAL_ACTION);
#endif
blobmsg_add_u32(&b, "status", 0);
if (asprintf(&info, "icwmpd will execute the scheduled action commands at the end of the session") == -1)
return -1;
@ -283,11 +299,6 @@ cwmp_handle_inform(struct ubus_context *ctx, struct ubus_object *obj,
}
else {
int event_code = cwmp_get_int_event_code(event);
if (event_code == 6)
{
CWMP_LOG(INFO,"Receive Connection Request: success authentication");
CWMP_LOG(INFO,"Connection Request thread: add connection request event in the queue");
}
pthread_mutex_lock (&(cwmp_main.mutex_session_queue));
cwmp_add_event_container (&cwmp_main, event_code, "");
pthread_mutex_unlock (&(cwmp_main.mutex_session_queue));

35
xml.c
View file

@ -30,8 +30,8 @@
#include <libtr098/softwaremodules.h>
#else
#include <libbbfdm/dmentry.h>
#include <libbbfdm/dmbbfcommon.h>
#include <libbbfdm/deviceinfo.h>
#include <libbbfdm/dmbbf.h>
#include <libbbfdm/softwaremodules.h>
#endif
LIST_HEAD(list_download);
@ -793,7 +793,12 @@ int cwmp_rpc_acs_prepare_message_inform (struct cwmp *cwmp, struct session *sess
dm_parameter = list_entry(dmctx.list_parameter.next, struct dm_parameter, list);
if (xml_prepare_parameters_inform(&dmctx, dm_parameter, parameter_list, &size))
goto error;
#ifdef TR098
del_list_parameter(dm_parameter);
#else
bbf_del_list_parameter(dm_parameter);
#endif
}
if (asprintf(&c, "cwmp:ParameterValueStruct[%d]", size) == -1)
@ -1215,7 +1220,11 @@ int cwmp_handle_rpc_cpe_get_parameter_values(struct session *session, struct rpc
counter++;
#ifdef TR098
del_list_parameter(dm_parameter);
#else
bbf_del_list_parameter(dm_parameter);
#endif
}
#ifdef ACS_MULTI
b = mxmlFindElement(session->tree_out, session->tree_out, "ParameterList",
@ -1322,7 +1331,11 @@ int cwmp_handle_rpc_cpe_get_parameter_names(struct session *session, struct rpc
counter++;
#ifdef TR098
del_list_parameter(dm_parameter);
#else
bbf_del_list_parameter(dm_parameter);
#endif
}
#ifdef ACS_MULTI
@ -1432,7 +1445,11 @@ int cwmp_handle_rpc_cpe_get_parameter_attributes(struct session *session, struct
counter++;
#ifdef TR098
del_list_parameter(dm_parameter);
#else
bbf_del_list_parameter(dm_parameter);
#endif
}
#ifdef ACS_MULTI
b = mxmlFindElement(session->tree_out, session->tree_out, "ParameterList",
@ -1925,7 +1942,11 @@ int cwmp_handle_rpc_cpe_factory_reset(struct session *session, struct rpc *rpc)
b = mxmlNewElement(b, "cwmp:FactoryResetResponse");
if (!b) goto fault;
#ifndef TR098
bbf_cwmp_set_end_session(END_SESSION_FACTORY_RESET);
#else
cwmp_set_end_session(END_SESSION_FACTORY_RESET);
#endif
return 0;
@ -1951,7 +1972,11 @@ int cwmp_handle_rpc_cpe_x_factory_reset_soft(struct session *session, struct rpc
b = mxmlNewElement(b, "cwmp:X_FactoryResetSoftResponse");
if (!b) goto fault;
#ifndef TR098
bbf_cwmp_set_end_session(END_SESSION_X_FACTORY_RESET_SOFT);
#else
cwmp_set_end_session(END_SESSION_X_FACTORY_RESET_SOFT);
#endif
return 0;
@ -2083,7 +2108,11 @@ int cwmp_handle_rpc_cpe_reboot(struct session *session, struct rpc *rpc)
b = mxmlNewElement(b, "cwmp:RebootResponse");
if (!b) goto fault;
#ifndef TR098
bbf_cwmp_set_end_session(END_SESSION_REBOOT);
#else
cwmp_set_end_session(END_SESSION_REBOOT);
#endif
return 0;
@ -4568,7 +4597,11 @@ int cwmp_handle_rpc_cpe_fault(struct session *session, struct rpc *rpc)
u = mxmlNewText(u, 0, FAULT_CPE_ARRAY[idx].DESCRIPTION);
if (!u) return -1;
}
#ifdef TR098
del_list_fault_param(param_fault);
#else
bbf_del_list_fault_param(param_fault);
#endif
}
}