mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
Fix probable segfaults
This commit is contained in:
parent
4f4a43b31d
commit
1cfb8039e6
24 changed files with 459 additions and 323 deletions
|
|
@ -35,18 +35,18 @@ struct autonomous_event {
|
||||||
static bool validate_du_state_change_data(auto_du_state_change_compl *data)
|
static bool validate_du_state_change_data(auto_du_state_change_compl *data)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (data->fault_code && cwmp_main->conf.auto_cdu_result_type && strcmp(cwmp_main->conf.auto_cdu_result_type, "Failure") != 0 && strcmp(cwmp_main->conf.auto_cdu_result_type, "Both") != 0)
|
if (data->fault_code && CWMP_STRCMP(cwmp_main->conf.auto_cdu_result_type, "Failure") != 0 && CWMP_STRCMP(cwmp_main->conf.auto_cdu_result_type, "Both") != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!data->fault_code && cwmp_main->conf.auto_cdu_result_type && strcmp(cwmp_main->conf.auto_cdu_result_type, "Success") != 0 && strcmp(cwmp_main->conf.auto_cdu_result_type, "Both") != 0)
|
if (!data->fault_code && CWMP_STRCMP(cwmp_main->conf.auto_cdu_result_type, "Success") != 0 && CWMP_STRCMP(cwmp_main->conf.auto_cdu_result_type, "Both") != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (data->operation && strstr(cwmp_main->conf.auto_cdu_oprt_type, data->operation) == NULL)
|
if (data->operation && CWMP_STRSTR(cwmp_main->conf.auto_cdu_oprt_type, data->operation) == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char fault_code[5] = {0};
|
char fault_code[5] = {0};
|
||||||
snprintf(fault_code, 4, "%d", data->fault_code);
|
snprintf(fault_code, 4, "%d", data->fault_code);
|
||||||
if (strstr(cwmp_main->conf.auto_cdu_fault_code, fault_code) == NULL)
|
if (CWMP_STRSTR(cwmp_main->conf.auto_cdu_fault_code, fault_code) == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -112,15 +112,15 @@ static void send_du_state_change_notif(struct blob_attr *msg)
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
data->uuid = strdup(uuid);
|
data->uuid = CWMP_STRDUP(uuid);
|
||||||
data->operation = strdup(oper);
|
data->operation = CWMP_STRDUP(oper);
|
||||||
|
|
||||||
if (tb1[1]) {
|
if (tb1[1]) {
|
||||||
data->ver = strdup(blobmsg_get_string(tb1[1]));
|
data->ver = CWMP_STRDUP(blobmsg_get_string(tb1[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tb1[2]) {
|
if (tb1[2]) {
|
||||||
data->current_state = strdup(blobmsg_get_string(tb1[2]));
|
data->current_state = CWMP_STRDUP(blobmsg_get_string(tb1[2]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tb1[3]) {
|
if (tb1[3]) {
|
||||||
|
|
@ -128,11 +128,11 @@ static void send_du_state_change_notif(struct blob_attr *msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tb1[4]) {
|
if (tb1[4]) {
|
||||||
data->start_time = strdup(blobmsg_get_string(tb1[4]));
|
data->start_time = CWMP_STRDUP(blobmsg_get_string(tb1[4]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tb1[5]) {
|
if (tb1[5]) {
|
||||||
data->complete_time = strdup(blobmsg_get_string(tb1[5]));
|
data->complete_time = CWMP_STRDUP(blobmsg_get_string(tb1[5]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tb1[7]) {
|
if (tb1[7]) {
|
||||||
|
|
@ -141,7 +141,7 @@ static void send_du_state_change_notif(struct blob_attr *msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tb1[8]) {
|
if (tb1[8]) {
|
||||||
data->fault_string = strdup(blobmsg_get_string(tb1[8]));
|
data->fault_string = CWMP_STRDUP(blobmsg_get_string(tb1[8]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check autonomous_du_state_change_complpolicy data
|
// Check autonomous_du_state_change_complpolicy data
|
||||||
|
|
@ -171,19 +171,19 @@ static void send_du_state_change_notif(struct blob_attr *msg)
|
||||||
|
|
||||||
bool validate_transfer_complete_data(auto_transfer_complete *data)
|
bool validate_transfer_complete_data(auto_transfer_complete *data)
|
||||||
{
|
{
|
||||||
if (data->is_download && cwmp_main->conf.auto_tc_transfer_type && strcmp(cwmp_main->conf.auto_tc_transfer_type, "Download") != 0 && strcmp(cwmp_main->conf.auto_tc_transfer_type, "Both") != 0)
|
if (data->is_download && CWMP_STRCMP(cwmp_main->conf.auto_tc_transfer_type, "Download") != 0 && CWMP_STRCMP(cwmp_main->conf.auto_tc_transfer_type, "Both") != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!data->is_download && cwmp_main->conf.auto_tc_transfer_type && strcmp(cwmp_main->conf.auto_tc_transfer_type, "Upload") != 0 && strcmp(cwmp_main->conf.auto_tc_transfer_type, "Both") != 0)
|
if (!data->is_download && CWMP_STRCMP(cwmp_main->conf.auto_tc_transfer_type, "Upload") != 0 && CWMP_STRCMP(cwmp_main->conf.auto_tc_transfer_type, "Both") != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (data->fault_code && cwmp_main->conf.auto_tc_result_type && strcmp(cwmp_main->conf.auto_tc_result_type, "Failure") != 0 && strcmp(cwmp_main->conf.auto_tc_result_type, "Both") != 0)
|
if (data->fault_code && CWMP_STRCMP(cwmp_main->conf.auto_tc_result_type, "Failure") != 0 && CWMP_STRCMP(cwmp_main->conf.auto_tc_result_type, "Both") != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!data->fault_code && cwmp_main->conf.auto_tc_result_type && strcmp(cwmp_main->conf.auto_tc_result_type, "Success") != 0 && strcmp(cwmp_main->conf.auto_tc_result_type, "Both") != 0)
|
if (!data->fault_code && CWMP_STRCMP(cwmp_main->conf.auto_tc_result_type, "Success") != 0 && CWMP_STRCMP(cwmp_main->conf.auto_tc_result_type, "Both") != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (strlen(data->file_type) == 0)
|
if (CWMP_STRLEN(data->file_type) == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//TODO check if the file_type is among the FileTypeFilter
|
//TODO check if the file_type is among the FileTypeFilter
|
||||||
|
|
@ -228,18 +228,18 @@ static void send_transfer_complete_notif(struct blob_attr *msg)
|
||||||
|
|
||||||
data->announce_url = strdup("");
|
data->announce_url = strdup("");
|
||||||
data->transfer_url = strdup(tb1[0] ? blobmsg_get_string(tb1[0]) : "");
|
data->transfer_url = strdup(tb1[0] ? blobmsg_get_string(tb1[0]) : "");
|
||||||
data->is_download = (tb1[1] && strcmp(blobmsg_get_string(tb1[1]), "Download") == 0) ? true : false;
|
data->is_download = (tb1[1] && CWMP_STRCMP(blobmsg_get_string(tb1[1]), "Download") == 0) ? true : false;
|
||||||
data->file_size = 0;
|
data->file_size = 0;
|
||||||
data->target_file_name = strdup("");
|
data->target_file_name = strdup("");
|
||||||
snprintf(file_type, sizeof(file_type), "X %s %s", cwmp_main->deviceid.oui, data->is_download ? "Download" : "Upload");
|
snprintf(file_type, sizeof(file_type), "X %s %s", cwmp_main->deviceid.oui, data->is_download ? "Download" : "Upload");
|
||||||
data->file_type = strdup(file_type);
|
data->file_type = strdup(file_type);
|
||||||
|
|
||||||
if (tb1[2]) {
|
if (tb1[2]) {
|
||||||
data->start_time = strdup(blobmsg_get_string(tb1[2]));
|
data->start_time = CWMP_STRDUP(blobmsg_get_string(tb1[2]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tb1[3]) {
|
if (tb1[3]) {
|
||||||
data->complete_time = strdup(blobmsg_get_string(tb1[3]));
|
data->complete_time = CWMP_STRDUP(blobmsg_get_string(tb1[3]));
|
||||||
}
|
}
|
||||||
|
|
||||||
data->fault_code = tb1[4] ? blobmsg_get_u32(tb1[4]) : 0;
|
data->fault_code = tb1[4] ? blobmsg_get_u32(tb1[4]) : 0;
|
||||||
|
|
@ -247,7 +247,7 @@ static void send_transfer_complete_notif(struct blob_attr *msg)
|
||||||
data->fault_code = 9001;
|
data->fault_code = 9001;
|
||||||
|
|
||||||
if (tb1[5]) {
|
if (tb1[5]) {
|
||||||
data->fault_string = strdup(blobmsg_get_string(tb1[5]));
|
data->fault_string = CWMP_STRDUP(blobmsg_get_string(tb1[5]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check autonomous_transfer_complete data
|
// Check autonomous_transfer_complete data
|
||||||
|
|
@ -288,7 +288,7 @@ static void send_autonomous_notification(char *ev_name, struct blob_attr *msg)
|
||||||
|
|
||||||
int count = sizeof(event_info)/sizeof(struct autonomous_event);
|
int count = sizeof(event_info)/sizeof(struct autonomous_event);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
if (strcmp(event_info[i].name, ev_name) == 0) {
|
if (CWMP_STRCMP(event_info[i].name, ev_name) == 0) {
|
||||||
autonomous_event_callback cb = event_info[i].cb;
|
autonomous_event_callback cb = event_info[i].cb;
|
||||||
cb(msg);
|
cb(msg);
|
||||||
return;
|
return;
|
||||||
|
|
@ -308,7 +308,7 @@ void autonomous_notification_handler(struct ubus_context *ctx __attribute__((unu
|
||||||
|
|
||||||
__blob_for_each_attr(attr, blobmsg_data(msg), len) {
|
__blob_for_each_attr(attr, blobmsg_data(msg), len) {
|
||||||
const char *attr_name = blobmsg_name(attr);
|
const char *attr_name = blobmsg_name(attr);
|
||||||
if (attr_name != NULL && strcmp(attr_name, "name") == 0) {
|
if (attr_name != NULL && CWMP_STRCMP(attr_name, "name") == 0) {
|
||||||
send_autonomous_notification(blobmsg_data(attr), msg);
|
send_autonomous_notification(blobmsg_data(attr), msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,10 @@ static mxml_node_t *bkp_tree = NULL;
|
||||||
|
|
||||||
int cwmp_init_backup_session(char **ret, enum backup_loading load)
|
int cwmp_init_backup_session(char **ret, enum backup_loading load)
|
||||||
{
|
{
|
||||||
int error;
|
|
||||||
if (bkp_session_check_file())
|
if (bkp_session_check_file())
|
||||||
return 0;
|
return 0;
|
||||||
error = cwmp_load_saved_session(ret, load);
|
|
||||||
return error;
|
return cwmp_load_saved_session(ret, load);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bkp_tree_clean(void)
|
void bkp_tree_clean(void)
|
||||||
|
|
@ -111,7 +110,7 @@ mxml_node_t *bkp_session_node_found(mxml_node_t *tree, char *name, struct search
|
||||||
if (c) {
|
if (c) {
|
||||||
i = 0;
|
i = 0;
|
||||||
while (c && i < size) {
|
while (c && i < size) {
|
||||||
if (mxmlGetType(c) == MXML_ELEMENT && strcmp(keys[i].name, (char *) mxmlGetElement(c)) == 0) {
|
if (mxmlGetType(c) == MXML_ELEMENT && CWMP_STRCMP(keys[i].name, (char *) mxmlGetElement(c)) == 0) {
|
||||||
d = c;
|
d = c;
|
||||||
d = mxmlWalkNext(d, c, MXML_DESCEND);
|
d = mxmlWalkNext(d, c, MXML_DESCEND);
|
||||||
if ((keys[i].value == NULL) || (d && mxmlGetType(d) == MXML_OPAQUE && CWMP_STRCMP(keys[i].value, mxmlGetOpaque(d)) == 0))
|
if ((keys[i].value == NULL) || (d && mxmlGetType(d) == MXML_OPAQUE && CWMP_STRCMP(keys[i].value, mxmlGetOpaque(d)) == 0))
|
||||||
|
|
@ -691,49 +690,49 @@ int cwmp_load_saved_session(char **ret, enum backup_loading load)
|
||||||
mxml_type_t ntype = mxmlGetType(b);
|
mxml_type_t ntype = mxmlGetType(b);
|
||||||
const char *elem_name = mxmlGetElement(b);
|
const char *elem_name = mxmlGetElement(b);
|
||||||
if (load == ACS) {
|
if (load == ACS) {
|
||||||
if (ntype == MXML_ELEMENT && strcmp(elem_name, "acs") == 0) {
|
if (ntype == MXML_ELEMENT && CWMP_STRCMP(elem_name, "acs") == 0) {
|
||||||
*ret = load_child_value(b, "URL");
|
*ret = load_child_value(b, "URL");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (load == CR_IP) {
|
if (load == CR_IP) {
|
||||||
if (ntype == MXML_ELEMENT && strcmp(elem_name, "connection_request") == 0) {
|
if (ntype == MXML_ELEMENT && CWMP_STRCMP(elem_name, "connection_request") == 0) {
|
||||||
*ret = load_child_value(b, "ip");
|
*ret = load_child_value(b, "ip");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (load == CR_IPv6) {
|
if (load == CR_IPv6) {
|
||||||
if (ntype == MXML_ELEMENT && strcmp(elem_name, "connection_request") == 0) {
|
if (ntype == MXML_ELEMENT && CWMP_STRCMP(elem_name, "connection_request") == 0) {
|
||||||
*ret = load_child_value(b, "ipv6");
|
*ret = load_child_value(b, "ipv6");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (load == CR_PORT) {
|
if (load == CR_PORT) {
|
||||||
if (ntype == MXML_ELEMENT && strcmp(elem_name, "connection_request") == 0) {
|
if (ntype == MXML_ELEMENT && CWMP_STRCMP(elem_name, "connection_request") == 0) {
|
||||||
*ret = load_child_value(b, "port");
|
*ret = load_child_value(b, "port");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (load == ALL) {
|
if (load == ALL) {
|
||||||
if (ntype == MXML_ELEMENT && strcmp(elem_name, "cwmp_event") == 0) {
|
if (ntype == MXML_ELEMENT && CWMP_STRCMP(elem_name, "cwmp_event") == 0) {
|
||||||
load_queue_event(b);
|
load_queue_event(b);
|
||||||
} else if (ntype == MXML_ELEMENT && strcmp(elem_name, "download") == 0) {
|
} else if (ntype == MXML_ELEMENT && CWMP_STRCMP(elem_name, "download") == 0) {
|
||||||
load_download(b);
|
load_download(b);
|
||||||
} else if (ntype == MXML_ELEMENT && strcmp(elem_name, "upload") == 0) {
|
} else if (ntype == MXML_ELEMENT && CWMP_STRCMP(elem_name, "upload") == 0) {
|
||||||
load_upload(b);
|
load_upload(b);
|
||||||
} else if (ntype == MXML_ELEMENT && strcmp(elem_name, "transfer_complete") == 0) {
|
} else if (ntype == MXML_ELEMENT && CWMP_STRCMP(elem_name, "transfer_complete") == 0) {
|
||||||
load_transfer_complete(b);
|
load_transfer_complete(b);
|
||||||
} else if (ntype == MXML_ELEMENT && strcmp(elem_name, "schedule_inform") == 0) {
|
} else if (ntype == MXML_ELEMENT && CWMP_STRCMP(elem_name, "schedule_inform") == 0) {
|
||||||
load_schedule_inform(b);
|
load_schedule_inform(b);
|
||||||
} else if (ntype == MXML_ELEMENT && strcmp(elem_name, "change_du_state") == 0) {
|
} else if (ntype == MXML_ELEMENT && CWMP_STRCMP(elem_name, "change_du_state") == 0) {
|
||||||
load_change_du_state(b);
|
load_change_du_state(b);
|
||||||
} else if (ntype == MXML_ELEMENT && strcmp(elem_name, "du_state_change_complete") == 0) {
|
} else if (ntype == MXML_ELEMENT && CWMP_STRCMP(elem_name, "du_state_change_complete") == 0) {
|
||||||
load_du_state_change_complete(b);
|
load_du_state_change_complete(b);
|
||||||
} else if (ntype == MXML_ELEMENT && strcmp(elem_name, "schedule_download") == 0) {
|
} else if (ntype == MXML_ELEMENT && CWMP_STRCMP(elem_name, "schedule_download") == 0) {
|
||||||
load_schedule_download(b);
|
load_schedule_download(b);
|
||||||
} else if (ntype == MXML_ELEMENT && strcmp(elem_name, "autonomous_du_state_change_complete") == 0) {
|
} else if (ntype == MXML_ELEMENT && CWMP_STRCMP(elem_name, "autonomous_du_state_change_complete") == 0) {
|
||||||
load_autonomous_du_state_change_complete(b);
|
load_autonomous_du_state_change_complete(b);
|
||||||
} else if (ntype == MXML_ELEMENT && strcmp(elem_name, "autonomous_transfer_complete") == 0) {
|
} else if (ntype == MXML_ELEMENT && CWMP_STRCMP(elem_name, "autonomous_transfer_complete") == 0) {
|
||||||
load_autonomous_transfer_complete(b);
|
load_autonomous_transfer_complete(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
140
src/common.c
140
src/common.c
|
|
@ -133,9 +133,9 @@ void add_dm_parameter_to_list(struct list_head *head, char *param_name, char *pa
|
||||||
|
|
||||||
list_for_each_entry(dm_parameter, head, list) {
|
list_for_each_entry(dm_parameter, head, list) {
|
||||||
|
|
||||||
if (strcmp(param_name, dm_parameter->name) == 0) {
|
if (CWMP_STRCMP(param_name, dm_parameter->name) == 0) {
|
||||||
if (param_val && strcmp(dm_parameter->value, param_val) != 0) {
|
if (param_val && CWMP_STRCMP(dm_parameter->value, param_val) != 0) {
|
||||||
free(dm_parameter->value);
|
FREE(dm_parameter->value);
|
||||||
dm_parameter->value = strdup(param_val);
|
dm_parameter->value = strdup(param_val);
|
||||||
}
|
}
|
||||||
dm_parameter->notification = notification;
|
dm_parameter->notification = notification;
|
||||||
|
|
@ -146,7 +146,7 @@ void add_dm_parameter_to_list(struct list_head *head, char *param_name, char *pa
|
||||||
dm_parameter = calloc(1, sizeof(struct cwmp_dm_parameter));
|
dm_parameter = calloc(1, sizeof(struct cwmp_dm_parameter));
|
||||||
list_add_tail(&dm_parameter->list, head);
|
list_add_tail(&dm_parameter->list, head);
|
||||||
|
|
||||||
dm_parameter->name = strdup(param_name);
|
dm_parameter->name = CWMP_STRDUP(param_name);
|
||||||
dm_parameter->value = param_val ? strdup(param_val) : NULL;
|
dm_parameter->value = param_val ? strdup(param_val) : NULL;
|
||||||
dm_parameter->type = strdup(param_type ? param_type : "xsd:string");
|
dm_parameter->type = strdup(param_type ? param_type : "xsd:string");
|
||||||
dm_parameter->access_list = NULL;
|
dm_parameter->access_list = NULL;
|
||||||
|
|
@ -178,21 +178,21 @@ void cwmp_free_all_dm_parameter_list(struct list_head *list)
|
||||||
*/
|
*/
|
||||||
void cwmp_add_list_fault_param(char *param, int fault, struct list_head *list_set_value_fault)
|
void cwmp_add_list_fault_param(char *param, int fault, struct list_head *list_set_value_fault)
|
||||||
{
|
{
|
||||||
struct cwmp_param_fault *param_fault;
|
struct cwmp_param_fault *param_fault = NULL;
|
||||||
if (param == NULL)
|
if (param == NULL)
|
||||||
param = "";
|
param = "";
|
||||||
|
|
||||||
param_fault = calloc(1, sizeof(struct cwmp_param_fault));
|
param_fault = calloc(1, sizeof(struct cwmp_param_fault));
|
||||||
list_add_tail(¶m_fault->list, list_set_value_fault);
|
list_add_tail(¶m_fault->list, list_set_value_fault);
|
||||||
param_fault->name = strdup(param);
|
param_fault->name = CWMP_STRDUP(param);
|
||||||
param_fault->fault = fault;
|
param_fault->fault = fault;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cwmp_del_list_fault_param(struct cwmp_param_fault *param_fault)
|
void cwmp_del_list_fault_param(struct cwmp_param_fault *param_fault)
|
||||||
{
|
{
|
||||||
list_del(¶m_fault->list);
|
list_del(¶m_fault->list);
|
||||||
free(param_fault->name);
|
FREE(param_fault->name);
|
||||||
free(param_fault);
|
FREE(param_fault);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cwmp_free_all_list_param_fault(struct list_head *list_param_fault)
|
void cwmp_free_all_list_param_fault(struct list_head *list_param_fault)
|
||||||
|
|
@ -221,7 +221,7 @@ int cwmp_asprintf(char **s, const char *format, ...)
|
||||||
str = (char *)calloc(sizeof(char), size + 1);
|
str = (char *)calloc(sizeof(char), size + 1);
|
||||||
vsnprintf(str, size + 1, format, arg);
|
vsnprintf(str, size + 1, format, arg);
|
||||||
va_end(arg);
|
va_end(arg);
|
||||||
*s = strdup(str);
|
*s = CWMP_STRDUP(str);
|
||||||
FREE(str);
|
FREE(str);
|
||||||
if (*s == NULL) {
|
if (*s == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -286,7 +286,7 @@ void check_firewall_restart_state()
|
||||||
if (get_firewall_restart_state(&state) != CWMP_OK)
|
if (get_firewall_restart_state(&state) != CWMP_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (state != NULL && strcmp(state, "init") == 0) {
|
if (CWMP_STRCMP(state, "init") == 0) {
|
||||||
init = true;
|
init = true;
|
||||||
FREE(state);
|
FREE(state);
|
||||||
break;
|
break;
|
||||||
|
|
@ -320,7 +320,7 @@ void cwmp_reboot(char *command_key)
|
||||||
set_rpc_parameter_key(command_key);
|
set_rpc_parameter_key(command_key);
|
||||||
|
|
||||||
struct blob_buf b = { 0 };
|
struct blob_buf b = { 0 };
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
|
|
||||||
icwmp_ubus_invoke("rpc-sys", "reboot", b.head, NULL, NULL);
|
icwmp_ubus_invoke("rpc-sys", "reboot", b.head, NULL, NULL);
|
||||||
|
|
@ -338,7 +338,7 @@ void cwmp_reboot(char *command_key)
|
||||||
void cwmp_factory_reset() //use the ubus rpc-sys factory
|
void cwmp_factory_reset() //use the ubus rpc-sys factory
|
||||||
{
|
{
|
||||||
struct blob_buf b = { 0 };
|
struct blob_buf b = { 0 };
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
|
|
||||||
icwmp_ubus_invoke("rpc-sys", "factory", b.head, NULL, NULL);
|
icwmp_ubus_invoke("rpc-sys", "factory", b.head, NULL, NULL);
|
||||||
|
|
@ -476,8 +476,9 @@ int cwmp_get_fault_code_by_string(char *fault_code)
|
||||||
|
|
||||||
if (fault_code == NULL)
|
if (fault_code == NULL)
|
||||||
return FAULT_CPE_NO_FAULT;
|
return FAULT_CPE_NO_FAULT;
|
||||||
|
|
||||||
for (i = 1; i < __FAULT_CPE_MAX; i++) {
|
for (i = 1; i < __FAULT_CPE_MAX; i++) {
|
||||||
if (strcmp(FAULT_CPE_ARRAY[i].CODE, fault_code) == 0)
|
if (CWMP_STRCMP(FAULT_CPE_ARRAY[i].CODE, fault_code) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -534,7 +535,7 @@ char *icwmp_strdup(const char *s)
|
||||||
void *new = icwmp_malloc(len);
|
void *new = icwmp_malloc(len);
|
||||||
if (new == NULL)
|
if (new == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
return (char *)memcpy(new, s, len);
|
return (char *)CWMP_MEMCPY(new, s, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int icwmp_asprintf(char **s, const char *format, ...)
|
int icwmp_asprintf(char **s, const char *format, ...)
|
||||||
|
|
@ -603,7 +604,7 @@ int icwmp_add_service(char *service)
|
||||||
{
|
{
|
||||||
if (nbre_services >= MAX_NBRE_SERVICES)
|
if (nbre_services >= MAX_NBRE_SERVICES)
|
||||||
return -1;
|
return -1;
|
||||||
list_services[nbre_services++] = strdup(service);
|
list_services[nbre_services++] = CWMP_STRDUP(service);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -625,7 +626,7 @@ void icwmp_restart_services()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
struct blob_buf b = { 0 };
|
struct blob_buf b = { 0 };
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
bb_add_string(&b, "config", list_services[i]);
|
bb_add_string(&b, "config", list_services[i]);
|
||||||
|
|
||||||
|
|
@ -633,7 +634,7 @@ void icwmp_restart_services()
|
||||||
|
|
||||||
blob_buf_free(&b);
|
blob_buf_free(&b);
|
||||||
|
|
||||||
if (list_services[i] && strcmp(list_services[i], "firewall") == 0) {
|
if (CWMP_STRCMP(list_services[i], "firewall") == 0) {
|
||||||
g_firewall_restart = true;
|
g_firewall_restart = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -657,7 +658,7 @@ bool icwmp_validate_string_length(char *arg, int max_length)
|
||||||
|
|
||||||
bool icwmp_validate_boolean_value(char *arg)
|
bool icwmp_validate_boolean_value(char *arg)
|
||||||
{
|
{
|
||||||
if (!arg ||( strcmp(arg, "1") != 0 && strcmp(arg, "0") != 0 && strcmp(arg, "true") != 0 && strcmp(arg, "false") != 0))
|
if (!arg ||( CWMP_STRCMP(arg, "1") != 0 && CWMP_STRCMP(arg, "0") != 0 && CWMP_STRCMP(arg, "true") != 0 && CWMP_STRCMP(arg, "false") != 0))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -763,7 +764,7 @@ static void ubus_network_interface_callback(struct ubus_request *req __attribute
|
||||||
if (!CWMP_STRLEN(l3_device))
|
if (!CWMP_STRLEN(l3_device))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cwmp_main->net.interface = strdup(l3_device);
|
cwmp_main->net.interface = CWMP_STRDUP(l3_device);
|
||||||
|
|
||||||
CWMP_LOG(DEBUG, "CWMP IFACE - interface: %s && device: %s", cwmp_main->conf.default_wan_iface, cwmp_main->net.interface);
|
CWMP_LOG(DEBUG, "CWMP IFACE - interface: %s && device: %s", cwmp_main->conf.default_wan_iface, cwmp_main->net.interface);
|
||||||
}
|
}
|
||||||
|
|
@ -784,7 +785,7 @@ static bool is_ipv6_addr_available(const char *device)
|
||||||
|
|
||||||
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
|
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
|
||||||
|
|
||||||
if (ifa->ifa_addr == NULL || ifa->ifa_name == NULL || strcmp(ifa->ifa_name, device) != 0)
|
if (ifa->ifa_addr == NULL || CWMP_STRCMP(ifa->ifa_name, device) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
family = ifa->ifa_addr->sa_family;
|
family = ifa->ifa_addr->sa_family;
|
||||||
|
|
@ -822,7 +823,7 @@ bool is_ipv6_enabled(void)
|
||||||
struct blob_buf b = {0};
|
struct blob_buf b = {0};
|
||||||
char network_interface[64];
|
char network_interface[64];
|
||||||
|
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
|
|
||||||
snprintf(network_interface, sizeof(network_interface), "network.interface.%s", cwmp_main->conf.default_wan_iface);
|
snprintf(network_interface, sizeof(network_interface), "network.interface.%s", cwmp_main->conf.default_wan_iface);
|
||||||
|
|
@ -931,7 +932,7 @@ void cwmp_invoke_intf_reset(char *path)
|
||||||
|
|
||||||
CWMP_LOG(DEBUG, "Reset interface: %s", path);
|
CWMP_LOG(DEBUG, "Reset interface: %s", path);
|
||||||
|
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
|
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
bb_add_string(&b, "command", command);
|
bb_add_string(&b, "command", command);
|
||||||
|
|
@ -965,3 +966,98 @@ void add_day_to_time(struct tm *time)
|
||||||
} else
|
} else
|
||||||
time->tm_mday = time->tm_mday + 1;
|
time->tm_mday = time->tm_mday + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cwmp_strcmp(const char *s1, const char *s2, const char *origin, int pos)
|
||||||
|
{
|
||||||
|
if (s1 != NULL && s2 != NULL)
|
||||||
|
return strcmp(s1, s2);
|
||||||
|
else {
|
||||||
|
CWMP_LOG(WARNING, "%s:%d NULL argument found", origin, pos);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int cwmp_strncmp(const char *s1, const char *s2, int len, const char *origin, int pos)
|
||||||
|
{
|
||||||
|
if (s1 != NULL && s2 != NULL && len > 0)
|
||||||
|
return strncmp(s1, s2, len);
|
||||||
|
else {
|
||||||
|
CWMP_LOG(WARNING, "%s:%d NULL argument found", origin, pos);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int cwmp_strlen(const char *s1, const char *origin, int pos)
|
||||||
|
{
|
||||||
|
if (s1 != NULL)
|
||||||
|
return strlen(s1);
|
||||||
|
else {
|
||||||
|
CWMP_LOG(WARNING, "%s:%d NULL argument found", origin, pos);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int cwmp_strcasecmp(const char *s1, const char *s2, const char *origin, int pos)
|
||||||
|
{
|
||||||
|
if (s1 != NULL && s2 != NULL)
|
||||||
|
return strcasecmp(s1, s2);
|
||||||
|
else {
|
||||||
|
CWMP_LOG(WARNING, "%s:%d NULL argument found", origin, pos);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char *cwmp_strstr(const char *s1, const char *s2, const char *origin, int pos)
|
||||||
|
{
|
||||||
|
if (s1 != NULL && s2 != NULL)
|
||||||
|
return strstr(s1, s2);
|
||||||
|
else {
|
||||||
|
CWMP_LOG(WARNING, "%s:%d NULL argument found", origin, pos);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char *cwmp_strncpy(char *dst, const char *src, int size, const char *origin, int pos)
|
||||||
|
{
|
||||||
|
if (size <= 0)
|
||||||
|
return dst;
|
||||||
|
|
||||||
|
if (dst != NULL && src != NULL) {
|
||||||
|
strncpy(dst, src, size - 1);
|
||||||
|
dst[size - 1] = '\0';
|
||||||
|
} else {
|
||||||
|
CWMP_LOG(WARNING, "%s:%d NULL argument found", origin, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *cwmp_strdup(const char *s1, const char *origin, int pos)
|
||||||
|
{
|
||||||
|
if (s1)
|
||||||
|
return strdup(s1);
|
||||||
|
else {
|
||||||
|
CWMP_LOG(WARNING, "%s:%d NULL argument found", origin, pos);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void *cwmp_memset(void *src, int val, size_t size, const char *origin, int pos)
|
||||||
|
{
|
||||||
|
if (src)
|
||||||
|
return memset(src, val, size);
|
||||||
|
else {
|
||||||
|
CWMP_LOG(WARNING, "%s:%d NULL argument found", origin, pos);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void *cwmp_memcpy(void *dst, const void *src, size_t size, const char *origin, int pos)
|
||||||
|
{
|
||||||
|
if (dst != NULL && src != NULL)
|
||||||
|
return memcpy(dst, src, size);
|
||||||
|
else {
|
||||||
|
CWMP_LOG(WARNING, "%s:%d NULL argument found", origin, pos);
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
28
src/common.h
28
src/common.h
|
|
@ -33,15 +33,16 @@
|
||||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CWMP_STRCMP(S1, S2) ((S1 != NULL && S2 != NULL) ? strcmp(S1, S2) : (S1 == S2))
|
#define CWMP_STRCMP(S1, S2) cwmp_strcmp(S1, S2, __func__, __LINE__)
|
||||||
#define CWMP_STRDUP(S1) ((S1 != NULL) ? strdup(S1) : NULL)
|
#define CWMP_STRNCMP(S1, S2, LEN) cwmp_strncmp(S1, S2, LEN, __func__, __LINE__)
|
||||||
#define CWMP_STRLEN(S1) ((S1 != NULL) ? strlen(S1) : 0)
|
#define CWMP_STRLEN(S1) cwmp_strlen(S1, __func__, __LINE__)
|
||||||
|
#define CWMP_STRSTR(S1, S2) cwmp_strstr(S1, S2, __func__, __LINE__)
|
||||||
|
#define CWMP_LSTRCASECMP(S1, S2) cwmp_strcasecmp(S1, S2, __func__, __LINE__)
|
||||||
|
#define CWMP_STRDUP(S1) cwmp_strdup(S1, __func__, __LINE__)
|
||||||
|
#define CWMP_STRNCPY(DST, SRC, SIZE) cwmp_strncpy(DST, SRC, SIZE, __func__, __LINE__)
|
||||||
|
|
||||||
#define CWMP_STRNCPY(DST, SRC, SIZE) \
|
#define CWMP_MEMSET(SRC, VAL, SIZE) cwmp_memset(SRC, VAL, SIZE, __func__, __LINE__)
|
||||||
do { \
|
#define CWMP_MEMCPY(DST, SRC, SIZE) cwmp_memcpy(DST, SRC, SIZE, __func__, __LINE__)
|
||||||
strncpy(DST, SRC, SIZE - 1); \
|
|
||||||
DST[SIZE - 1] = '\0'; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define BBFDM_OBJECT_NAME "bbfdm"
|
#define BBFDM_OBJECT_NAME "bbfdm"
|
||||||
#define MAX_EVENTS 64
|
#define MAX_EVENTS 64
|
||||||
|
|
@ -626,4 +627,15 @@ void check_firewall_restart_state();
|
||||||
void add_day_to_time(struct tm *time);
|
void add_day_to_time(struct tm *time);
|
||||||
int set_rpc_acs_to_supported(const char *rpc_name);
|
int set_rpc_acs_to_supported(const char *rpc_name);
|
||||||
void set_rpc_parameter_key(char *param_key);
|
void set_rpc_parameter_key(char *param_key);
|
||||||
|
|
||||||
|
int cwmp_strcmp(const char *s1, const char *s2, const char *origin, int pos);
|
||||||
|
int cwmp_strncmp(const char *s1, const char *s2, int len, const char *origin, int pos);
|
||||||
|
int cwmp_strlen(const char *s1, const char *origin, int pos);
|
||||||
|
int cwmp_strcasecmp(const char *s1, const char *s2, const char *origin, int pos);
|
||||||
|
char *cwmp_strstr(const char *s1, const char *s2, const char *origin, int pos);
|
||||||
|
char *cwmp_strncpy(char *dst, const char *src, int size, const char *origin, int pos);
|
||||||
|
char *cwmp_strdup(const char *s1, const char *origin, int pos);
|
||||||
|
void *cwmp_memset(void *src, int val, size_t size, const char *origin, int pos);
|
||||||
|
void *cwmp_memcpy(void *dst, const void *src, size_t size, const char *origin, int pos);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
32
src/config.c
32
src/config.c
|
|
@ -96,7 +96,7 @@ static void config_get_cpe_elements(struct uci_section *s)
|
||||||
CWMP_LOG(DEBUG, "CWMP CONFIG - amendement version: %d", cwmp_main->conf.amd_version);
|
CWMP_LOG(DEBUG, "CWMP CONFIG - amendement version: %d", cwmp_main->conf.amd_version);
|
||||||
|
|
||||||
if (cpe_tb[UCI_CPE_DEFAULT_WAN_IFACE])
|
if (cpe_tb[UCI_CPE_DEFAULT_WAN_IFACE])
|
||||||
cwmp_main->conf.default_wan_iface = strdup(get_value_from_uci_option(cpe_tb[UCI_CPE_DEFAULT_WAN_IFACE]));
|
cwmp_main->conf.default_wan_iface = CWMP_STRDUP(get_value_from_uci_option(cpe_tb[UCI_CPE_DEFAULT_WAN_IFACE]));
|
||||||
else
|
else
|
||||||
cwmp_main->conf.default_wan_iface = strdup("wan");
|
cwmp_main->conf.default_wan_iface = strdup("wan");
|
||||||
CWMP_LOG(DEBUG, "CWMP CONFIG - default wan interface: %s", cwmp_main->conf.default_wan_iface);
|
CWMP_LOG(DEBUG, "CWMP CONFIG - default wan interface: %s", cwmp_main->conf.default_wan_iface);
|
||||||
|
|
@ -219,7 +219,7 @@ int get_global_config()
|
||||||
if ((error = uci_get_value(UCI_ACS_USERID_PATH, &value)) == CWMP_OK) {
|
if ((error = uci_get_value(UCI_ACS_USERID_PATH, &value)) == CWMP_OK) {
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
FREE(cwmp_main->conf.acs_userid);
|
FREE(cwmp_main->conf.acs_userid);
|
||||||
cwmp_main->conf.acs_userid = strdup(value);
|
cwmp_main->conf.acs_userid = CWMP_STRDUP(value);
|
||||||
FREE(value);
|
FREE(value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -230,7 +230,7 @@ int get_global_config()
|
||||||
if ((error = uci_get_value(UCI_ACS_PASSWD_PATH, &value)) == CWMP_OK) {
|
if ((error = uci_get_value(UCI_ACS_PASSWD_PATH, &value)) == CWMP_OK) {
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
FREE(cwmp_main->conf.acs_passwd);
|
FREE(cwmp_main->conf.acs_passwd);
|
||||||
cwmp_main->conf.acs_passwd = strdup(value);
|
cwmp_main->conf.acs_passwd = CWMP_STRDUP(value);
|
||||||
FREE(value);
|
FREE(value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -297,7 +297,7 @@ int get_global_config()
|
||||||
|
|
||||||
FREE(cwmp_main->conf.cpe_userid);
|
FREE(cwmp_main->conf.cpe_userid);
|
||||||
if (uci_get_value(UCI_CPE_USERID_PATH, &value) == CWMP_OK) {
|
if (uci_get_value(UCI_CPE_USERID_PATH, &value) == CWMP_OK) {
|
||||||
cwmp_main->conf.cpe_userid = strdup(value);
|
cwmp_main->conf.cpe_userid = CWMP_STRDUP(value);
|
||||||
FREE(value);
|
FREE(value);
|
||||||
} else {
|
} else {
|
||||||
cwmp_main->conf.cpe_userid = strdup("");
|
cwmp_main->conf.cpe_userid = strdup("");
|
||||||
|
|
@ -305,7 +305,7 @@ int get_global_config()
|
||||||
|
|
||||||
FREE(cwmp_main->conf.cpe_passwd);
|
FREE(cwmp_main->conf.cpe_passwd);
|
||||||
if (uci_get_value(UCI_CPE_PASSWD_PATH, &value) == CWMP_OK) {
|
if (uci_get_value(UCI_CPE_PASSWD_PATH, &value) == CWMP_OK) {
|
||||||
cwmp_main->conf.cpe_passwd = strdup(value);
|
cwmp_main->conf.cpe_passwd = CWMP_STRDUP(value);
|
||||||
FREE(value);
|
FREE(value);
|
||||||
} else {
|
} else {
|
||||||
cwmp_main->conf.cpe_passwd = strdup("");
|
cwmp_main->conf.cpe_passwd = strdup("");
|
||||||
|
|
@ -332,14 +332,12 @@ int get_global_config()
|
||||||
|
|
||||||
FREE(cwmp_main->conf.connection_request_path);
|
FREE(cwmp_main->conf.connection_request_path);
|
||||||
if (uci_get_value(UCI_CPE_CRPATH_PATH, &value) == CWMP_OK) {
|
if (uci_get_value(UCI_CPE_CRPATH_PATH, &value) == CWMP_OK) {
|
||||||
if (value[0] == '/')
|
if (value) {
|
||||||
cwmp_main->conf.connection_request_path = strdup(value);
|
|
||||||
else {
|
|
||||||
char cr_path[512];
|
char cr_path[512];
|
||||||
snprintf(cr_path, sizeof(cr_path), "/%s", value);
|
snprintf(cr_path, sizeof(cr_path), "%s%s", (value[0] == '/') ? "" : "/", value);
|
||||||
cwmp_main->conf.connection_request_path = strdup(cr_path);
|
cwmp_main->conf.connection_request_path = strdup(cr_path);
|
||||||
|
FREE(value);
|
||||||
}
|
}
|
||||||
FREE(value);
|
|
||||||
} else {
|
} else {
|
||||||
cwmp_main->conf.connection_request_path = strdup("/");
|
cwmp_main->conf.connection_request_path = strdup("/");
|
||||||
}
|
}
|
||||||
|
|
@ -410,7 +408,7 @@ int get_global_config()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uci_get_value(UCI_CPE_INSTANCE_MODE, &value) == CWMP_OK) {
|
if (uci_get_value(UCI_CPE_INSTANCE_MODE, &value) == CWMP_OK) {
|
||||||
if (0 == strcmp(value, "InstanceNumber")) {
|
if (0 == CWMP_STRCMP(value, "InstanceNumber")) {
|
||||||
cwmp_main->conf.instance_mode = INSTANCE_MODE_NUMBER;
|
cwmp_main->conf.instance_mode = INSTANCE_MODE_NUMBER;
|
||||||
} else {
|
} else {
|
||||||
cwmp_main->conf.instance_mode = INSTANCE_MODE_ALIAS;
|
cwmp_main->conf.instance_mode = INSTANCE_MODE_ALIAS;
|
||||||
|
|
@ -561,19 +559,19 @@ int get_global_config()
|
||||||
cwmp_main->conf.auto_tc_enable = 0;
|
cwmp_main->conf.auto_tc_enable = 0;
|
||||||
}
|
}
|
||||||
if (uci_get_value(UCI_AUTONOMOUS_TC_TRANSFERTYPE, &value) == CWMP_OK) {
|
if (uci_get_value(UCI_AUTONOMOUS_TC_TRANSFERTYPE, &value) == CWMP_OK) {
|
||||||
cwmp_main->conf.auto_tc_transfer_type = strdup(value);
|
cwmp_main->conf.auto_tc_transfer_type = CWMP_STRDUP(value);
|
||||||
FREE(value);
|
FREE(value);
|
||||||
} else {
|
} else {
|
||||||
cwmp_main->conf.auto_tc_transfer_type = NULL;
|
cwmp_main->conf.auto_tc_transfer_type = NULL;
|
||||||
}
|
}
|
||||||
if (uci_get_value(UCI_AUTONOMOUS_TC_RESULTTYPE, &value) == CWMP_OK) {
|
if (uci_get_value(UCI_AUTONOMOUS_TC_RESULTTYPE, &value) == CWMP_OK) {
|
||||||
cwmp_main->conf.auto_tc_result_type = strdup(value);
|
cwmp_main->conf.auto_tc_result_type = CWMP_STRDUP(value);
|
||||||
FREE(value);
|
FREE(value);
|
||||||
} else {
|
} else {
|
||||||
cwmp_main->conf.auto_tc_result_type = NULL;
|
cwmp_main->conf.auto_tc_result_type = NULL;
|
||||||
}
|
}
|
||||||
if (uci_get_value(UCI_AUTONOMOUS_TC_FILETYPE, &value) == CWMP_OK) {
|
if (uci_get_value(UCI_AUTONOMOUS_TC_FILETYPE, &value) == CWMP_OK) {
|
||||||
cwmp_main->conf.auto_tc_file_type = strdup(value);
|
cwmp_main->conf.auto_tc_file_type = CWMP_STRDUP(value);
|
||||||
FREE(value);
|
FREE(value);
|
||||||
} else {
|
} else {
|
||||||
cwmp_main->conf.auto_tc_file_type = NULL;
|
cwmp_main->conf.auto_tc_file_type = NULL;
|
||||||
|
|
@ -586,19 +584,19 @@ int get_global_config()
|
||||||
cwmp_main->conf.auto_cdu_enable = 0;
|
cwmp_main->conf.auto_cdu_enable = 0;
|
||||||
}
|
}
|
||||||
if (uci_get_value(UCI_AUTONOMOUS_CDU_OPTYPE, &value) == CWMP_OK) {
|
if (uci_get_value(UCI_AUTONOMOUS_CDU_OPTYPE, &value) == CWMP_OK) {
|
||||||
cwmp_main->conf.auto_cdu_oprt_type = strdup(value);
|
cwmp_main->conf.auto_cdu_oprt_type = CWMP_STRDUP(value);
|
||||||
FREE(value);
|
FREE(value);
|
||||||
} else {
|
} else {
|
||||||
cwmp_main->conf.auto_cdu_oprt_type = NULL;
|
cwmp_main->conf.auto_cdu_oprt_type = NULL;
|
||||||
}
|
}
|
||||||
if (uci_get_value(UCI_AUTONOMOUS_CDU_RESULTYPE, &value) == CWMP_OK) {
|
if (uci_get_value(UCI_AUTONOMOUS_CDU_RESULTYPE, &value) == CWMP_OK) {
|
||||||
cwmp_main->conf.auto_cdu_result_type = strdup(value);
|
cwmp_main->conf.auto_cdu_result_type = CWMP_STRDUP(value);
|
||||||
FREE(value);
|
FREE(value);
|
||||||
} else {
|
} else {
|
||||||
cwmp_main->conf.auto_cdu_result_type = NULL;
|
cwmp_main->conf.auto_cdu_result_type = NULL;
|
||||||
}
|
}
|
||||||
if (uci_get_value(UCI_AUTONOMOUS_CDU_FAULTCODE, &value) == CWMP_OK) {
|
if (uci_get_value(UCI_AUTONOMOUS_CDU_FAULTCODE, &value) == CWMP_OK) {
|
||||||
cwmp_main->conf.auto_cdu_fault_code = strdup(value);
|
cwmp_main->conf.auto_cdu_fault_code = CWMP_STRDUP(value);
|
||||||
FREE(value);
|
FREE(value);
|
||||||
} else {
|
} else {
|
||||||
cwmp_main->conf.auto_cdu_fault_code = NULL;
|
cwmp_main->conf.auto_cdu_fault_code = NULL;
|
||||||
|
|
|
||||||
24
src/cwmp.c
24
src/cwmp.c
|
|
@ -56,7 +56,7 @@ static bool interface_reset_req(char *param_name, char *value)
|
||||||
if (match_reg_exp(reg_exp, param_name) == false)
|
if (match_reg_exp(reg_exp, param_name) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (strcmp(value, "1") != 0 && strcmp(value, "true") != 0)
|
if (CWMP_STRCMP(value, "1") != 0 && CWMP_STRCMP(value, "true") != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -87,7 +87,7 @@ void set_interface_reset_request(char *param_name, char *value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(node, 0, sizeof(intf_reset_node));
|
CWMP_MEMSET(node, 0, sizeof(intf_reset_node));
|
||||||
snprintf(node->path, len, "%s", param_name);
|
snprintf(node->path, len, "%s", param_name);
|
||||||
INIT_LIST_HEAD(&node->list);
|
INIT_LIST_HEAD(&node->list);
|
||||||
list_add_tail(&node->list, &intf_reset_list);
|
list_add_tail(&node->list, &intf_reset_list);
|
||||||
|
|
@ -128,7 +128,7 @@ static void lookup_event_cb(struct ubus_context *ctx __attribute__((unused)),
|
||||||
struct blob_attr *attr;
|
struct blob_attr *attr;
|
||||||
const char *path;
|
const char *path;
|
||||||
|
|
||||||
if (type && strcmp(type, "ubus.object.add") != 0)
|
if (CWMP_STRCMP(type, "ubus.object.add") != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
blobmsg_parse(&policy, 1, &attr, blob_data(msg), blob_len(msg));
|
blobmsg_parse(&policy, 1, &attr, blob_data(msg), blob_len(msg));
|
||||||
|
|
@ -136,7 +136,7 @@ static void lookup_event_cb(struct ubus_context *ctx __attribute__((unused)),
|
||||||
return;
|
return;
|
||||||
|
|
||||||
path = blobmsg_data(attr);
|
path = blobmsg_data(attr);
|
||||||
if (path && strcmp(path, BBFDM_OBJECT_NAME) == 0) {
|
if (CWMP_STRCMP(path, BBFDM_OBJECT_NAME) == 0) {
|
||||||
g_bbf_object_available = true;
|
g_bbf_object_available = true;
|
||||||
uloop_end();
|
uloop_end();
|
||||||
}
|
}
|
||||||
|
|
@ -168,7 +168,7 @@ static int wait_for_bbf_object()
|
||||||
ubus_add_uloop(uctx);
|
ubus_add_uloop(uctx);
|
||||||
|
|
||||||
// register for add event
|
// register for add event
|
||||||
memset(&add_event, 0, sizeof(struct ubus_event_handler));
|
CWMP_MEMSET(&add_event, 0, sizeof(struct ubus_event_handler));
|
||||||
add_event.cb = lookup_event_cb;
|
add_event.cb = lookup_event_cb;
|
||||||
ubus_register_event_handler(uctx, &add_event, "ubus.object.add");
|
ubus_register_event_handler(uctx, &add_event, "ubus.object.add");
|
||||||
|
|
||||||
|
|
@ -180,7 +180,7 @@ static int wait_for_bbf_object()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set timeout to expire lookup
|
// Set timeout to expire lookup
|
||||||
memset(&u_timeout, 0, sizeof(struct uloop_timeout));
|
CWMP_MEMSET(&u_timeout, 0, sizeof(struct uloop_timeout));
|
||||||
u_timeout.cb = lookup_timeout_cb;
|
u_timeout.cb = lookup_timeout_cb;
|
||||||
uloop_timeout_set(&u_timeout, BBF_WAIT_TIMEOUT * 1000);
|
uloop_timeout_set(&u_timeout, BBF_WAIT_TIMEOUT * 1000);
|
||||||
|
|
||||||
|
|
@ -222,7 +222,7 @@ static int cwmp_init(void)
|
||||||
|
|
||||||
cwmp_main = (struct cwmp *)calloc(1, sizeof(struct cwmp));
|
cwmp_main = (struct cwmp *)calloc(1, sizeof(struct cwmp));
|
||||||
|
|
||||||
memset(cwmp_main, 0, sizeof(struct cwmp));
|
CWMP_MEMSET(cwmp_main, 0, sizeof(struct cwmp));
|
||||||
|
|
||||||
error = get_preinit_config();
|
error = get_preinit_config();
|
||||||
if (error)
|
if (error)
|
||||||
|
|
@ -277,9 +277,11 @@ static int cwmp_init(void)
|
||||||
init_list_param_notify();
|
init_list_param_notify();
|
||||||
create_cwmp_session_structure();
|
create_cwmp_session_structure();
|
||||||
get_nonce_key();
|
get_nonce_key();
|
||||||
memset(&intf_reset_list, 0, sizeof(struct list_head));
|
|
||||||
|
CWMP_MEMSET(&intf_reset_list, 0, sizeof(struct list_head));
|
||||||
INIT_LIST_HEAD(&intf_reset_list);
|
INIT_LIST_HEAD(&intf_reset_list);
|
||||||
memset(&du_uuid_list, 0, sizeof(struct list_head));
|
|
||||||
|
CWMP_MEMSET(&du_uuid_list, 0, sizeof(struct list_head));
|
||||||
INIT_LIST_HEAD(&du_uuid_list);
|
INIT_LIST_HEAD(&du_uuid_list);
|
||||||
cwmp_main->start_time = time(NULL);
|
cwmp_main->start_time = time(NULL);
|
||||||
|
|
||||||
|
|
@ -357,14 +359,14 @@ int main(int argc, char **argv)
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
memset(&env, 0, sizeof(struct env));
|
CWMP_MEMSET(&env, 0, sizeof(struct env));
|
||||||
if ((error = global_env_init(argc, argv, &env)))
|
if ((error = global_env_init(argc, argv, &env)))
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
if ((error = cwmp_init()))
|
if ((error = cwmp_init()))
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
memcpy(&(cwmp_main->env), &env, sizeof(struct env));
|
CWMP_MEMCPY(&(cwmp_main->env), &env, sizeof(struct env));
|
||||||
|
|
||||||
if ((error = cwmp_init_backup_session(NULL, ALL)))
|
if ((error = cwmp_init_backup_session(NULL, ALL)))
|
||||||
return error;
|
return error;
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ const struct fault_resp faults_array[] = {
|
||||||
static char *get_fault_message_by_fault_code(char *fault_code)
|
static char *get_fault_message_by_fault_code(char *fault_code)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(faults_array); i++) {
|
for (size_t i = 0; i < ARRAY_SIZE(faults_array); i++) {
|
||||||
if (strcmp(faults_array[i].fault_code, fault_code) == 0)
|
if (CWMP_STRCMP(faults_array[i].fault_code, fault_code) == 0)
|
||||||
return faults_array[i].fault_message;
|
return faults_array[i].fault_message;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -282,7 +282,7 @@ char *execute_cwmp_cli_command(char *cmd, char *args[])
|
||||||
goto cli_help;
|
goto cli_help;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(cmd, "help") == 0)
|
if (CWMP_STRCMP(cmd, "help") == 0)
|
||||||
goto cli_help;
|
goto cli_help;
|
||||||
|
|
||||||
struct cmd_input cmd_in = {
|
struct cmd_input cmd_in = {
|
||||||
|
|
@ -296,7 +296,7 @@ char *execute_cwmp_cli_command(char *cmd, char *args[])
|
||||||
cwmp_uci_init();
|
cwmp_uci_init();
|
||||||
|
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(icwmp_commands); i++) {
|
for (size_t i = 0; i < ARRAY_SIZE(icwmp_commands); i++) {
|
||||||
if (strcmp(icwmp_commands[i].command_name, cmd) == 0) {
|
if (CWMP_STRCMP(icwmp_commands[i].command_name, cmd) == 0) {
|
||||||
fault = icwmp_commands[i].cmd_exec_func(cmd_in, &cmd_out);
|
fault = icwmp_commands[i].cmd_exec_func(cmd_in, &cmd_out);
|
||||||
if (fault)
|
if (fault)
|
||||||
fault_ret = strdup(fault);
|
fault_ret = strdup(fault);
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ void ubus_du_state_callback(struct ubus_request *req, int type __attribute__((un
|
||||||
struct blob_attr *param;
|
struct blob_attr *param;
|
||||||
__blob_for_each_attr(param, data, data_len) {
|
__blob_for_each_attr(param, data, data_len) {
|
||||||
struct blobmsg_hdr *hdr = blob_data(attr);
|
struct blobmsg_hdr *hdr = blob_data(attr);
|
||||||
if (hdr && hdr->name && strcmp((char*)hdr->name, "fault") == 0) {
|
if (hdr && CWMP_STRCMP((char*)hdr->name, "fault") == 0) {
|
||||||
*fault = strdup("9010");
|
*fault = strdup("9010");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -109,7 +109,7 @@ int cwmp_du_install(char *url, char *uuid, char *user, char *pass, char *path, c
|
||||||
{
|
{
|
||||||
int e;
|
int e;
|
||||||
struct blob_buf b = { 0 };
|
struct blob_buf b = { 0 };
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
|
|
||||||
int len = CWMP_STRLEN(env_ref);
|
int len = CWMP_STRLEN(env_ref);
|
||||||
|
|
@ -131,7 +131,7 @@ int cwmp_du_update(char *url, char *user, char *pass, char *du_path, char **faul
|
||||||
{
|
{
|
||||||
struct blob_buf b = {0};
|
struct blob_buf b = {0};
|
||||||
|
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
|
|
||||||
prepare_blob_msg(&b, url, 0, user, pass, du_path, "", DU_UPDATE);
|
prepare_blob_msg(&b, url, 0, user, pass, du_path, "", DU_UPDATE);
|
||||||
|
|
@ -150,7 +150,7 @@ int cwmp_du_uninstall(char *du_path, char **fault_code)
|
||||||
{
|
{
|
||||||
struct blob_buf b = {0};
|
struct blob_buf b = {0};
|
||||||
|
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
|
|
||||||
prepare_blob_msg(&b, "", 0, "", "", du_path, "", DU_UNINSTALL);
|
prepare_blob_msg(&b, "", 0, "", "", du_path, "", DU_UNINSTALL);
|
||||||
|
|
@ -189,10 +189,10 @@ static char *get_software_module_object_eq(char *param1, char *val1, char *param
|
||||||
}
|
}
|
||||||
|
|
||||||
list_for_each_entry (param_value, sw_parameters, list) {
|
list_for_each_entry (param_value, sw_parameters, list) {
|
||||||
if (regexec(®ex1, param_value->name, 0, NULL, 0) == 0 && param_value->value && strcmp(param_value->value, val1) == 0)
|
if (regexec(®ex1, param_value->name, 0, NULL, 0) == 0 && CWMP_STRCMP(param_value->value, val1) == 0)
|
||||||
softwaremodule_filter_param = true;
|
softwaremodule_filter_param = true;
|
||||||
|
|
||||||
if (param2 && regexec(®ex2, param_value->name, 0, NULL, 0) == 0 && param_value->value && strcmp(param_value->value, val2) == 0)
|
if (param2 && regexec(®ex2, param_value->name, 0, NULL, 0) == 0 && CWMP_STRCMP(param_value->value, val2) == 0)
|
||||||
softwaremodule_filter_param = true;
|
softwaremodule_filter_param = true;
|
||||||
|
|
||||||
if (softwaremodule_filter_param == false)
|
if (softwaremodule_filter_param == false)
|
||||||
|
|
@ -220,7 +220,7 @@ static int get_deployment_unit_name_version(char *uuid, char **name, char **vers
|
||||||
if (param_value->name == NULL)
|
if (param_value->name == NULL)
|
||||||
continue;
|
continue;
|
||||||
if (strcmp(param_value->name, name_param) == 0) {
|
if (strcmp(param_value->name, name_param) == 0) {
|
||||||
*name = strdup(param_value->value) ? param_value->value : "";
|
*name = strdup(param_value->value ? param_value->value : "");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strcmp(param_value->name, version_param) == 0) {
|
if (strcmp(param_value->name, version_param) == 0) {
|
||||||
|
|
@ -274,7 +274,7 @@ static int cwmp_launch_du_install(char *url, char *uuid, char *user, char *pass,
|
||||||
return FAULT_CPE_INTERNAL_ERROR;
|
return FAULT_CPE_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(node, 0, sizeof(du_op_uuid));
|
CWMP_MEMSET(node, 0, sizeof(du_op_uuid));
|
||||||
snprintf(node->uuid, sizeof(node->uuid), "%s", uuid);
|
snprintf(node->uuid, sizeof(node->uuid), "%s", uuid);
|
||||||
snprintf(node->operation, sizeof(node->operation), "%s", "Install");
|
snprintf(node->operation, sizeof(node->operation), "%s", "Install");
|
||||||
|
|
||||||
|
|
@ -315,7 +315,7 @@ static int cwmp_launch_du_update(char *url, char *uuid, char *user, char *pass,
|
||||||
return FAULT_CPE_INTERNAL_ERROR;
|
return FAULT_CPE_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(node, 0, sizeof(du_op_uuid));
|
CWMP_MEMSET(node, 0, sizeof(du_op_uuid));
|
||||||
snprintf(node->uuid, sizeof(node->uuid), "%s", uuid);
|
snprintf(node->uuid, sizeof(node->uuid), "%s", uuid);
|
||||||
snprintf(node->operation, sizeof(node->operation), "%s", "Update");
|
snprintf(node->operation, sizeof(node->operation), "%s", "Update");
|
||||||
|
|
||||||
|
|
@ -355,7 +355,7 @@ static int cwmp_launch_du_uninstall(char *du_path, char *uuid, struct opresult *
|
||||||
return FAULT_CPE_INTERNAL_ERROR;
|
return FAULT_CPE_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(node, 0, sizeof(du_op_uuid));
|
CWMP_MEMSET(node, 0, sizeof(du_op_uuid));
|
||||||
snprintf(node->uuid, sizeof(node->uuid), "%s", uuid);
|
snprintf(node->uuid, sizeof(node->uuid), "%s", uuid);
|
||||||
snprintf(node->operation, sizeof(node->operation), "%s", "Uninstall");
|
snprintf(node->operation, sizeof(node->operation), "%s", "Uninstall");
|
||||||
|
|
||||||
|
|
@ -407,16 +407,16 @@ int change_du_state_fault(struct change_du_state *pchange_du_state, struct du_st
|
||||||
// cppcheck-suppress uninitvar
|
// cppcheck-suppress uninitvar
|
||||||
if (CWMP_STRLEN(p->uuid) == 0) {
|
if (CWMP_STRLEN(p->uuid) == 0) {
|
||||||
char *uuid = generate_uuid();
|
char *uuid = generate_uuid();
|
||||||
res->uuid = strdup(uuid);
|
res->uuid = CWMP_STRDUP(uuid);
|
||||||
FREE(uuid);
|
FREE(uuid);
|
||||||
} else {
|
} else {
|
||||||
res->uuid = strdup(p->uuid);
|
res->uuid = CWMP_STRDUP(p->uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
res->version = strdup(p->version);
|
res->version = CWMP_STRDUP(p->version);
|
||||||
res->current_state = strdup("Failed");
|
res->current_state = strdup("Failed");
|
||||||
res->start_time = strdup(get_time(time(NULL)));
|
res->start_time = CWMP_STRDUP(get_time(time(NULL)));
|
||||||
res->complete_time = strdup(res->start_time);
|
res->complete_time = CWMP_STRDUP(res->start_time);
|
||||||
res->fault = error;
|
res->fault = error;
|
||||||
}
|
}
|
||||||
if ((cwmp_main->cdu_complete_id < 0) || (cwmp_main->cdu_complete_id >= MAX_INT_ID)) {
|
if ((cwmp_main->cdu_complete_id < 0) || (cwmp_main->cdu_complete_id >= MAX_INT_ID)) {
|
||||||
|
|
@ -467,7 +467,7 @@ void change_du_state_execute(struct uloop_timeout *utimeout)
|
||||||
|
|
||||||
error = FAULT_CPE_NO_FAULT;
|
error = FAULT_CPE_NO_FAULT;
|
||||||
INIT_LIST_HEAD(&(pdu_state_change_complete->list_opresult));
|
INIT_LIST_HEAD(&(pdu_state_change_complete->list_opresult));
|
||||||
pdu_state_change_complete->command_key = strdup(pchange_du_state->command_key);
|
pdu_state_change_complete->command_key = CWMP_STRDUP(pchange_du_state->command_key);
|
||||||
pdu_state_change_complete->timeout = pchange_du_state->timeout;
|
pdu_state_change_complete->timeout = pchange_du_state->timeout;
|
||||||
|
|
||||||
list_for_each_entry_safe (p, q, &pchange_du_state->list_operation, list) {
|
list_for_each_entry_safe (p, q, &pchange_du_state->list_operation, list) {
|
||||||
|
|
@ -501,10 +501,10 @@ void change_du_state_execute(struct uloop_timeout *utimeout)
|
||||||
package_name = get_package_name_by_url(p->url);
|
package_name = get_package_name_by_url(p->url);
|
||||||
|
|
||||||
if (error != FAULT_CPE_NO_FAULT) {
|
if (error != FAULT_CPE_NO_FAULT) {
|
||||||
res->uuid = strdup(p->uuid);
|
res->uuid = CWMP_STRDUP(p->uuid);
|
||||||
res->current_state = strdup("Failed");
|
res->current_state = strdup("Failed");
|
||||||
res->resolved = 0;
|
res->resolved = 0;
|
||||||
res->complete_time = strdup(get_time(time(NULL)));
|
res->complete_time = CWMP_STRDUP(get_time(time(NULL)));
|
||||||
res->fault = error;
|
res->fault = error;
|
||||||
/* du state change event will be scheduled here, so remove uuid from list */
|
/* du state change event will be scheduled here, so remove uuid from list */
|
||||||
remove_node_from_uuid_list(p->uuid, "Install");
|
remove_node_from_uuid_list(p->uuid, "Install");
|
||||||
|
|
@ -531,7 +531,7 @@ void change_du_state_execute(struct uloop_timeout *utimeout)
|
||||||
snprintf(du_path, sizeof(du_path), "Device.SoftwareModules.DeploymentUnit.%s.", du_ref);
|
snprintf(du_path, sizeof(du_path), "Device.SoftwareModules.DeploymentUnit.%s.", du_ref);
|
||||||
|
|
||||||
error = cwmp_launch_du_update(p->url, p->uuid, p->username, p->password, du_path, &res);
|
error = cwmp_launch_du_update(p->url, p->uuid, p->username, p->password, du_path, &res);
|
||||||
res->uuid = strdup(p->uuid);
|
res->uuid = CWMP_STRDUP(p->uuid);
|
||||||
|
|
||||||
if (error != FAULT_CPE_NO_FAULT) {
|
if (error != FAULT_CPE_NO_FAULT) {
|
||||||
struct cwmp_dm_parameter dm_param = {0};
|
struct cwmp_dm_parameter dm_param = {0};
|
||||||
|
|
@ -543,8 +543,8 @@ void change_du_state_execute(struct uloop_timeout *utimeout)
|
||||||
res->current_state = strdup("Failed");
|
res->current_state = strdup("Failed");
|
||||||
res->resolved = 0;
|
res->resolved = 0;
|
||||||
res->version = strdup(dm_param.value ? dm_param.value : "");
|
res->version = strdup(dm_param.value ? dm_param.value : "");
|
||||||
res->du_ref = strdup(du_path);
|
res->du_ref = CWMP_STRDUP(du_path);
|
||||||
res->complete_time = strdup(get_time(time(NULL)));
|
res->complete_time = CWMP_STRDUP(get_time(time(NULL)));
|
||||||
res->fault = error;
|
res->fault = error;
|
||||||
/* du state change event will be scheduled here, so remove uuid from list */
|
/* du state change event will be scheduled here, so remove uuid from list */
|
||||||
remove_node_from_uuid_list(p->uuid, "Update");
|
remove_node_from_uuid_list(p->uuid, "Update");
|
||||||
|
|
@ -588,10 +588,10 @@ void change_du_state_execute(struct uloop_timeout *utimeout)
|
||||||
if (error != FAULT_CPE_NO_FAULT) {
|
if (error != FAULT_CPE_NO_FAULT) {
|
||||||
res->current_state = strdup("Installed");
|
res->current_state = strdup("Installed");
|
||||||
res->resolved = 1;
|
res->resolved = 1;
|
||||||
res->du_ref = strdup(du_path);
|
res->du_ref = CWMP_STRDUP(du_path);
|
||||||
res->uuid = strdup(p->uuid);
|
res->uuid = CWMP_STRDUP(p->uuid);
|
||||||
res->version = strdup(package_version ? package_version : "");
|
res->version = strdup(package_version ? package_version : "");
|
||||||
res->complete_time = strdup(get_time(time(NULL)));
|
res->complete_time = CWMP_STRDUP(get_time(time(NULL)));
|
||||||
res->fault = error;
|
res->fault = error;
|
||||||
/* du state change event will be scheduled here, so remove uuid from list */
|
/* du state change event will be scheduled here, so remove uuid from list */
|
||||||
remove_node_from_uuid_list(p->uuid, "Uninstall");
|
remove_node_from_uuid_list(p->uuid, "Uninstall");
|
||||||
|
|
@ -675,7 +675,7 @@ void remove_node_from_uuid_list(char *uuid, char *operation)
|
||||||
|
|
||||||
du_op_uuid *tmp, *q;
|
du_op_uuid *tmp, *q;
|
||||||
list_for_each_entry_safe(tmp, q, &du_uuid_list, list) {
|
list_for_each_entry_safe(tmp, q, &du_uuid_list, list) {
|
||||||
if (strcmp(tmp->uuid, uuid) == 0 && strcmp(tmp->operation, operation) == 0) {
|
if (CWMP_STRCMP(tmp->uuid, uuid) == 0 && CWMP_STRCMP(tmp->operation, operation) == 0) {
|
||||||
list_del(&tmp->list);
|
list_del(&tmp->list);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
break;
|
break;
|
||||||
|
|
@ -690,7 +690,7 @@ bool exists_in_uuid_list(char *uuid, char *operation)
|
||||||
|
|
||||||
du_op_uuid *tmp, *q;
|
du_op_uuid *tmp, *q;
|
||||||
list_for_each_entry_safe(tmp, q, &du_uuid_list, list) {
|
list_for_each_entry_safe(tmp, q, &du_uuid_list, list) {
|
||||||
if (strcmp(tmp->uuid, uuid) == 0 && strcmp(tmp->operation, operation) == 0)
|
if (CWMP_STRCMP(tmp->uuid, uuid) == 0 && CWMP_STRCMP(tmp->operation, operation) == 0)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,7 @@ int cwmp_uci_get_value_by_section_string(struct uci_section *s, char *option, ch
|
||||||
uci_foreach_element(&s->options, e)
|
uci_foreach_element(&s->options, e)
|
||||||
{
|
{
|
||||||
o = (uci_to_option(e));
|
o = (uci_to_option(e));
|
||||||
if (o && o->e.name && !strcmp(o->e.name, option)) {
|
if (o && !CWMP_STRCMP(o->e.name, option)) {
|
||||||
if (o->type == UCI_TYPE_LIST) {
|
if (o->type == UCI_TYPE_LIST) {
|
||||||
*value = cwmp_uci_list_to_string(&o->v.list, " ");
|
*value = cwmp_uci_list_to_string(&o->v.list, " ");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -264,7 +264,7 @@ int cwmp_uci_get_value_by_section_list(struct uci_section *s, char *option, stru
|
||||||
uci_foreach_element(&s->options, e)
|
uci_foreach_element(&s->options, e)
|
||||||
{
|
{
|
||||||
o = (uci_to_option(e));
|
o = (uci_to_option(e));
|
||||||
if (o && o->e.name && strcmp(o->e.name, option) == 0) {
|
if (o && CWMP_STRCMP(o->e.name, option) == 0) {
|
||||||
switch (o->type) {
|
switch (o->type) {
|
||||||
case UCI_TYPE_LIST:
|
case UCI_TYPE_LIST:
|
||||||
*value = &o->v.list;
|
*value = &o->v.list;
|
||||||
|
|
@ -315,7 +315,7 @@ int cwmp_uci_set_value(char *package, char *section, char *option, char *value)
|
||||||
return cwmp_uci_set_value_string(package, section, option, value, UCI_STANDARD_CONFIG);
|
return cwmp_uci_set_value_string(package, section, option, value, UCI_STANDARD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cwmp_uci_set_varstate_value(char *package, char*section, char *option, char *value)
|
int cwmp_uci_set_varstate_value(char *package, char *section, char *option, char *value)
|
||||||
{
|
{
|
||||||
return cwmp_uci_set_value_string(package, section, option, value, UCI_VARSTATE_CONFIG);
|
return cwmp_uci_set_value_string(package, section, option, value, UCI_VARSTATE_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
@ -571,12 +571,15 @@ int cwmp_uci_add_section(char *package, char *stype, uci_config_paths uci_type ,
|
||||||
struct uci_section* get_section_by_section_name(char *package, char *stype, char* sname, uci_config_paths uci_type)
|
struct uci_section* get_section_by_section_name(char *package, char *stype, char* sname, uci_config_paths uci_type)
|
||||||
{
|
{
|
||||||
struct uci_section *s;
|
struct uci_section *s;
|
||||||
if (sname == NULL)
|
|
||||||
|
if (package == NULL || stype == NULL || sname == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
cwmp_uci_foreach_sections(package, stype, uci_type, s) {
|
cwmp_uci_foreach_sections(package, stype, uci_type, s) {
|
||||||
if (strcmp(section_name(s), sname) == 0)
|
if (CWMP_STRCMP(section_name(s), sname) == 0)
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -659,8 +662,9 @@ struct uci_section *cwmp_uci_walk_section(char *package, char *stype, void *arg1
|
||||||
struct uci_list *list_value, *list_section;
|
struct uci_list *list_value, *list_section;
|
||||||
struct uci_ptr ptr = { 0 };
|
struct uci_ptr ptr = { 0 };
|
||||||
|
|
||||||
if (package == NULL)
|
if (package == NULL || stype == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
if (walk == CWMP_GET_FIRST_SECTION) {
|
if (walk == CWMP_GET_FIRST_SECTION) {
|
||||||
if (cwmp_uci_lookup_ptr(uci_save_conf_paths[uci_type].uci_ctx, &ptr, package, NULL, NULL, NULL) != UCI_OK)
|
if (cwmp_uci_lookup_ptr(uci_save_conf_paths[uci_type].uci_ctx, &ptr, package, NULL, NULL, NULL) != UCI_OK)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
@ -674,7 +678,7 @@ struct uci_section *cwmp_uci_walk_section(char *package, char *stype, void *arg1
|
||||||
|
|
||||||
while (&e->list != list_section) {
|
while (&e->list != list_section) {
|
||||||
s = uci_to_section(e);
|
s = uci_to_section(e);
|
||||||
if (s && s->type && stype && strcmp(s->type, stype) == 0) {
|
if (s && CWMP_STRCMP(s->type, stype) == 0) {
|
||||||
switch (cmp) {
|
switch (cmp) {
|
||||||
case CWMP_CMP_SECTION:
|
case CWMP_CMP_SECTION:
|
||||||
goto end;
|
goto end;
|
||||||
|
|
@ -682,7 +686,7 @@ struct uci_section *cwmp_uci_walk_section(char *package, char *stype, void *arg1
|
||||||
if (arg1 == NULL || arg2 == NULL)
|
if (arg1 == NULL || arg2 == NULL)
|
||||||
break;
|
break;
|
||||||
cwmp_uci_get_value_by_section_string(s, (char *)arg1, &value);
|
cwmp_uci_get_value_by_section_string(s, (char *)arg1, &value);
|
||||||
if (value && strcmp(value, (char *)arg2) == 0)
|
if (value && CWMP_STRCMP(value, (char *)arg2) == 0)
|
||||||
goto end;
|
goto end;
|
||||||
break;
|
break;
|
||||||
case CWMP_CMP_OPTION_CONTAINING:
|
case CWMP_CMP_OPTION_CONTAINING:
|
||||||
|
|
@ -697,7 +701,7 @@ struct uci_section *cwmp_uci_walk_section(char *package, char *stype, void *arg1
|
||||||
snprintf(dup, sizeof(dup), "%s", value);
|
snprintf(dup, sizeof(dup), "%s", value);
|
||||||
pch = strtok_r(dup, " ", &spch);
|
pch = strtok_r(dup, " ", &spch);
|
||||||
while (pch != NULL) {
|
while (pch != NULL) {
|
||||||
if (strcmp((char *)arg2, pch) == 0)
|
if (CWMP_STRCMP((char *)arg2, pch) == 0)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
pch = strtok_r(NULL, " ", &spch);
|
pch = strtok_r(NULL, " ", &spch);
|
||||||
|
|
@ -710,7 +714,7 @@ struct uci_section *cwmp_uci_walk_section(char *package, char *stype, void *arg1
|
||||||
{
|
{
|
||||||
if (m == NULL || m->name == NULL)
|
if (m == NULL || m->name == NULL)
|
||||||
continue;
|
continue;
|
||||||
if (strcmp(m->name, (char *)arg2) == 0)
|
if (CWMP_STRCMP(m->name, (char *)arg2) == 0)
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ int zlib_compress(char *message, unsigned char **zmsg, int *zlen, int type)
|
||||||
CWMP_LOG(ERROR, "Error (re)allocating memory");
|
CWMP_LOG(ERROR, "Error (re)allocating memory");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
memcpy(*zmsg + ozlen, out, have);
|
CWMP_MEMCPY(*zmsg + ozlen, out, have);
|
||||||
} while (strm.avail_out == 0);
|
} while (strm.avail_out == 0);
|
||||||
deflateEnd(&strm);
|
deflateEnd(&strm);
|
||||||
#if 0 /*test*/
|
#if 0 /*test*/
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ static void ubus_transaction_callback(struct ubus_request *req, int type __attri
|
||||||
blobmsg_for_each_attr(service, updated_services, rem) {
|
blobmsg_for_each_attr(service, updated_services, rem) {
|
||||||
char *service_name = blobmsg_get_string(service);
|
char *service_name = blobmsg_get_string(service);
|
||||||
|
|
||||||
if (CWMP_STRLEN(service_name) == 0 || strcmp(service_name, "cwmp") == 0)
|
if (CWMP_STRLEN(service_name) == 0 || CWMP_STRCMP(service_name, "cwmp") == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CWMP_LOG(DEBUG, "Detected service: %s will be restarted in the end session", service_name);
|
CWMP_LOG(DEBUG, "Detected service: %s will be restarted in the end session", service_name);
|
||||||
|
|
@ -144,9 +144,9 @@ bool cwmp_transaction(const char *cmd, bool restart_services)
|
||||||
if (CWMP_STRLEN(cmd) == 0)
|
if (CWMP_STRLEN(cmd) == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int start_cmp = strcmp(cmd, "start");
|
int start_cmp = CWMP_STRCMP(cmd, "start");
|
||||||
int commit_cmp = strcmp(cmd, "commit");
|
int commit_cmp = CWMP_STRCMP(cmd, "commit");
|
||||||
int abort_cmp = strcmp(cmd, "abort");
|
int abort_cmp = CWMP_STRCMP(cmd, "abort");
|
||||||
|
|
||||||
if (start_cmp != 0 && commit_cmp != 0 && abort_cmp != 0)
|
if (start_cmp != 0 && commit_cmp != 0 && abort_cmp != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -157,7 +157,7 @@ bool cwmp_transaction(const char *cmd, bool restart_services)
|
||||||
|
|
||||||
CWMP_LOG(INFO, "Transaction %s ...", cmd);
|
CWMP_LOG(INFO, "Transaction %s ...", cmd);
|
||||||
|
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
|
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
bb_add_string(&b, "cmd", cmd);
|
bb_add_string(&b, "cmd", cmd);
|
||||||
|
|
@ -229,7 +229,7 @@ bool cwmp_get_parameter_value(const char *parameter_name, struct cwmp_dm_paramet
|
||||||
if (len == 0 || parameter_name[len - 1] == '.')
|
if (len == 0 || parameter_name[len - 1] == '.')
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
|
|
||||||
bb_add_string(&b, "path", parameter_name);
|
bb_add_string(&b, "path", parameter_name);
|
||||||
|
|
@ -292,7 +292,7 @@ static void ubus_get_parameter_callback(struct ubus_request *req, int type __att
|
||||||
char *param_name = blobmsg_get_string(tb[0]);
|
char *param_name = blobmsg_get_string(tb[0]);
|
||||||
char *param_value = tb[1] ? blobmsg_get_string(tb[1]) : "";
|
char *param_value = tb[1] ? blobmsg_get_string(tb[1]) : "";
|
||||||
char *param_type = tb[2] ? blobmsg_get_string(tb[2]) : "";
|
char *param_type = tb[2] ? blobmsg_get_string(tb[2]) : "";
|
||||||
bool writable = strcmp(param_value, "1") == 0 ? true : false;
|
bool writable = CWMP_STRCMP(param_value, "1") == 0 ? true : false;
|
||||||
|
|
||||||
add_dm_parameter_to_list(result->parameters_list, param_name, param_value, param_type, 0, writable);
|
add_dm_parameter_to_list(result->parameters_list, param_name, param_value, param_type, 0, writable);
|
||||||
}
|
}
|
||||||
|
|
@ -312,7 +312,7 @@ char *cwmp_get_parameter_values(const char *parameter_name, struct list_head *pa
|
||||||
|
|
||||||
const char *param = len ? parameter_name : "";
|
const char *param = len ? parameter_name : "";
|
||||||
|
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
|
|
||||||
bb_add_string(&b, "path", param);
|
bb_add_string(&b, "path", param);
|
||||||
|
|
@ -352,7 +352,7 @@ char *cwmp_get_parameter_names(const char *parameter_name, bool next_level, stru
|
||||||
|
|
||||||
const char *object = len ? parameter_name : "";
|
const char *object = len ? parameter_name : "";
|
||||||
|
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
|
|
||||||
bb_add_string(&b, "path", object);
|
bb_add_string(&b, "path", object);
|
||||||
|
|
@ -434,7 +434,7 @@ int cwmp_set_parameter_value(const char *parameter_name, const char *parameter_v
|
||||||
if (param_len == 0 || parameter_name[param_len - 1] == '.' || parameter_value == NULL)
|
if (param_len == 0 || parameter_name[param_len - 1] == '.' || parameter_value == NULL)
|
||||||
return FAULT_CPE_INVALID_ARGUMENTS;
|
return FAULT_CPE_INVALID_ARGUMENTS;
|
||||||
|
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
|
|
||||||
bb_add_string(&b, "path", parameter_name);
|
bb_add_string(&b, "path", parameter_name);
|
||||||
|
|
@ -524,7 +524,7 @@ char *cwmp_add_object(const char *object_name, char **instance)
|
||||||
};
|
};
|
||||||
struct blob_buf b = {0};
|
struct blob_buf b = {0};
|
||||||
|
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
|
|
||||||
bb_add_string(&b, "path", object_name);
|
bb_add_string(&b, "path", object_name);
|
||||||
|
|
@ -559,7 +559,7 @@ char *cwmp_delete_object(const char *object_name)
|
||||||
};
|
};
|
||||||
struct blob_buf b = {0};
|
struct blob_buf b = {0};
|
||||||
|
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
|
|
||||||
bb_add_string(&b, "path", object_name);
|
bb_add_string(&b, "path", object_name);
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ static bool set_specific_diagnostic_object_parameter_structure_value(struct diag
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (int i = 0; i < number_inputs; i++) {
|
for (int i = 0; i < number_inputs; i++) {
|
||||||
if (strcmp((*diagnostics_array)[i].parameter_name, parameter) == 0) {
|
if (CWMP_STRCMP((*diagnostics_array)[i].parameter_name, parameter) == 0) {
|
||||||
FREE((*diagnostics_array)[i].value);
|
FREE((*diagnostics_array)[i].value);
|
||||||
(*diagnostics_array)[i].value = strdup(value ? value : "");
|
(*diagnostics_array)[i].value = strdup(value ? value : "");
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -225,7 +225,7 @@ static int cwmp_diagnostics_operate(char *command, char *command_key, struct dia
|
||||||
{
|
{
|
||||||
struct blob_buf b = {0};
|
struct blob_buf b = {0};
|
||||||
|
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
|
|
||||||
bb_add_string(&b, "command", command);
|
bb_add_string(&b, "command", command);
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ static void clear_param_values(void)
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < (sizeof(param)/sizeof(param[0])); i++) {
|
for (i = 0; i < (sizeof(param)/sizeof(param[0])); i++) {
|
||||||
memset(param[i].value, 0, sizeof(param[i].value));
|
CWMP_MEMSET(param[i].value, 0, sizeof(param[i].value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,7 +95,7 @@ static int get_param_index(char *key)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
for (i = 0; i < (sizeof(param)/sizeof(param[0])); i++) {
|
for (i = 0; i < (sizeof(param)/sizeof(param[0])); i++) {
|
||||||
if (strncmp(key, param[i].key, strlen(param[i].key)) == 0)
|
if (CWMP_STRNCMP(key, param[i].key, strlen(param[i].key)) == 0)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,7 +140,7 @@ static void get_hexstring(unsigned const char *hash, int len, char *hexstr, int
|
||||||
if (buflen <= len * 2)
|
if (buflen <= len * 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
memset(hexstr, 0, buflen);
|
CWMP_MEMSET(hexstr, 0, buflen);
|
||||||
|
|
||||||
for (i = 0; i < len; ++i) {
|
for (i = 0; i < len; ++i) {
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
|
|
@ -159,8 +159,8 @@ static void get_value_from_header(const char *data)
|
||||||
|
|
||||||
int header_len = CWMP_STRLEN(data) + 1;
|
int header_len = CWMP_STRLEN(data) + 1;
|
||||||
char header[header_len];
|
char header[header_len];
|
||||||
memset(header, 0, header_len);
|
CWMP_MEMSET(header, 0, header_len);
|
||||||
strncpy(header, data, header_len);
|
CWMP_STRNCPY(header, data, header_len);
|
||||||
|
|
||||||
clear_param_values();
|
clear_param_values();
|
||||||
|
|
||||||
|
|
@ -219,8 +219,7 @@ static void get_digest_ha1(const char *algo, const char *uname, const char *rlm,
|
||||||
MD5_UPDATE(&context, (unsigned char *)a, strlen(a));
|
MD5_UPDATE(&context, (unsigned char *)a, strlen(a));
|
||||||
MD5_FINAL(digest, &context);
|
MD5_FINAL(digest, &context);
|
||||||
|
|
||||||
free(a);
|
FREE(a);
|
||||||
a = NULL;
|
|
||||||
|
|
||||||
if (0 == strcasecmp(algo, "md5-sess")) {
|
if (0 == strcasecmp(algo, "md5-sess")) {
|
||||||
len = strlen(nonce) + strlen(cnonce) + 3;
|
len = strlen(nonce) + strlen(cnonce) + 3;
|
||||||
|
|
@ -237,7 +236,7 @@ static void get_digest_ha1(const char *algo, const char *uname, const char *rlm,
|
||||||
MD5_UPDATE(&context, (unsigned char *)a, strlen(a));
|
MD5_UPDATE(&context, (unsigned char *)a, strlen(a));
|
||||||
MD5_FINAL(digest, &context);
|
MD5_FINAL(digest, &context);
|
||||||
|
|
||||||
free(a);
|
FREE(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
get_hexstring(digest, sizeof(digest), skey, skey_len);
|
get_hexstring(digest, sizeof(digest), skey, skey_len);
|
||||||
|
|
@ -267,7 +266,7 @@ static void get_digest_ha2(const char *method, const char *uri, char *ha2, int h
|
||||||
MD5_UPDATE(&context, (unsigned char *)a, strlen(a));
|
MD5_UPDATE(&context, (unsigned char *)a, strlen(a));
|
||||||
MD5_FINAL(digest, &context);
|
MD5_FINAL(digest, &context);
|
||||||
|
|
||||||
free(a);
|
FREE(a);
|
||||||
|
|
||||||
get_hexstring(digest, sizeof(digest), ha2, ha2_len);
|
get_hexstring(digest, sizeof(digest), ha2, ha2_len);
|
||||||
}
|
}
|
||||||
|
|
@ -305,7 +304,7 @@ static void get_digest_response(const char *ha1, const char *nonce, const char *
|
||||||
|
|
||||||
snprintf(b, len, "%s%s:%s:%s:", a, nonce_cnt, cnonce, qop);
|
snprintf(b, len, "%s%s:%s:%s:", a, nonce_cnt, cnonce, qop);
|
||||||
|
|
||||||
free(a);
|
FREE(a);
|
||||||
a = b;
|
a = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -315,7 +314,7 @@ static void get_digest_response(const char *ha1, const char *nonce, const char *
|
||||||
MD5_UPDATE(&context, (unsigned char *)ha2, MD5_HASH_HEX_LEN);
|
MD5_UPDATE(&context, (unsigned char *)ha2, MD5_HASH_HEX_LEN);
|
||||||
MD5_FINAL(digest, &context);
|
MD5_FINAL(digest, &context);
|
||||||
|
|
||||||
free(a);
|
FREE(a);
|
||||||
get_hexstring(digest, sizeof(digest), resp, resp_len);
|
get_hexstring(digest, sizeof(digest), resp, resp_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -371,7 +370,7 @@ static void get_nonce(uint32_t time, const char* method, const char *rand,
|
||||||
|
|
||||||
free(meth);
|
free(meth);
|
||||||
free(uri_realm);
|
free(uri_realm);
|
||||||
memset(nonce, 0, nonce_size);
|
CWMP_MEMSET(nonce, 0, nonce_size);
|
||||||
get_hexstring(digest, sizeof(digest), nonce, nonce_size);
|
get_hexstring(digest, sizeof(digest), nonce, nonce_size);
|
||||||
len = nonce_size - strlen(nonce) - 1;
|
len = nonce_size - strlen(nonce) - 1;
|
||||||
strncat(nonce, tshex, len);
|
strncat(nonce, tshex, len);
|
||||||
|
|
@ -391,7 +390,7 @@ int http_authentication_failure_resp(FILE *fp, const char *http_meth, const char
|
||||||
|
|
||||||
tm = (uint32_t)time(NULL);
|
tm = (uint32_t)time(NULL);
|
||||||
|
|
||||||
len = nonce_key ? strlen(nonce_key) : 0;
|
len = CWMP_STRLEN(nonce_key);
|
||||||
get_nonce(tm, http_meth, nonce_key, len, uri, rlm, nonce, sizeof(nonce));
|
get_nonce(tm, http_meth, nonce_key, len, uri, rlm, nonce, sizeof(nonce));
|
||||||
|
|
||||||
if (fprintf(fp, "WWW-Authenticate: Digest realm=\"%s\",qop=\"auth\",nonce=\"%s\",opaque=\"%s\"", rlm, nonce, opq) < 0)
|
if (fprintf(fp, "WWW-Authenticate: Digest realm=\"%s\",qop=\"auth\",nonce=\"%s\",opaque=\"%s\"", rlm, nonce, opq) < 0)
|
||||||
|
|
@ -405,14 +404,14 @@ static void get_relative_path(const char *uri, const char *req_host, char *req_p
|
||||||
if (uri == NULL || req_path == NULL)
|
if (uri == NULL || req_path == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
memset(req_path, 0, size);
|
CWMP_MEMSET(req_path, 0, size);
|
||||||
if (req_host == NULL || strlen(req_host) == 0) {
|
if (CWMP_STRLEN(req_host) == 0) {
|
||||||
snprintf(req_path, size, "%s", uri);
|
snprintf(req_path, size, "%s", uri);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t host_len = strlen(req_host);
|
size_t host_len = strlen(req_host);
|
||||||
if (strncmp(uri, req_host, host_len) == 0) {
|
if (CWMP_STRNCMP(uri, req_host, host_len) == 0) {
|
||||||
if (strlen(uri) == host_len) {
|
if (strlen(uri) == host_len) {
|
||||||
snprintf(req_path, size, "/");
|
snprintf(req_path, size, "/");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -430,13 +429,13 @@ int validate_http_digest_auth(const char *http_meth, const char *uri, const char
|
||||||
{
|
{
|
||||||
get_value_from_header(hdr);
|
get_value_from_header(hdr);
|
||||||
|
|
||||||
if (usr && strcmp(param[E_USERNAME].value, usr) != 0)
|
if (CWMP_STRCMP(param[E_USERNAME].value, usr) != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (strlen(param[E_REALM].value) == 0)
|
if (strlen(param[E_REALM].value) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (rlm && strcmp(param[E_REALM].value, rlm) != 0)
|
if (CWMP_STRCMP(param[E_REALM].value, rlm) != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (strlen(param[E_CNONCE].value) == 0)
|
if (strlen(param[E_CNONCE].value) == 0)
|
||||||
|
|
@ -474,7 +473,7 @@ int validate_http_digest_auth(const char *http_meth, const char *uri, const char
|
||||||
char nonce[MD5_HASH_HEX_LEN + 9];
|
char nonce[MD5_HASH_HEX_LEN + 9];
|
||||||
get_nonce(tm, http_meth, nonce_key, strlen(nonce_key), uri, rlm, nonce, sizeof(nonce));
|
get_nonce(tm, http_meth, nonce_key, strlen(nonce_key), uri, rlm, nonce, sizeof(nonce));
|
||||||
|
|
||||||
if (strcmp(param[E_NONCE].value, nonce) != 0) {
|
if (CWMP_STRCMP(param[E_NONCE].value, nonce) != 0) {
|
||||||
CWMP_LOG(ERROR, "Nonce value is probably fabricated");
|
CWMP_LOG(ERROR, "Nonce value is probably fabricated");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -489,12 +488,12 @@ int validate_http_digest_auth(const char *http_meth, const char *uri, const char
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
CWMP_LOG(DEBUG, "Abs path: (%s)", req_path);
|
CWMP_LOG(DEBUG, "Abs path: (%s)", req_path);
|
||||||
if (strncmp(req_path, uri, strlen(uri)) != 0) {
|
if (CWMP_STRNCMP(req_path, uri, strlen(uri)) != 0) {
|
||||||
CWMP_LOG(ERROR, "Authentication failed, configured uri(%s), req path(%s) not matched", uri, req_path);
|
CWMP_LOG(ERROR, "Authentication failed, configured uri(%s), req path(%s) not matched", uri, req_path);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((strcmp(param[E_QOP].value, "auth") != 0) && (strcmp(param[E_QOP].value, "") != 0)) {
|
if ((CWMP_STRCMP(param[E_QOP].value, "auth") != 0) && (CWMP_STRCMP(param[E_QOP].value, "") != 0)) {
|
||||||
CWMP_LOG(ERROR, "Authentication failed, due to qop value: (%s)", param[E_QOP].value);
|
CWMP_LOG(ERROR, "Authentication failed, due to qop value: (%s)", param[E_QOP].value);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -515,7 +514,7 @@ int validate_http_digest_auth(const char *http_meth, const char *uri, const char
|
||||||
get_digest_response(ha1, param[E_NONCE].value, param[E_NC].value, param[E_CNONCE].value,
|
get_digest_response(ha1, param[E_NONCE].value, param[E_NC].value, param[E_CNONCE].value,
|
||||||
param[E_QOP].value, ha2, resp, sizeof(resp));
|
param[E_QOP].value, ha2, resp, sizeof(resp));
|
||||||
|
|
||||||
if (strcmp(resp, param[E_RESPONSE].value) != 0) {
|
if (CWMP_STRCMP(resp, param[E_RESPONSE].value) != 0) {
|
||||||
CWMP_LOG(ERROR, "Authentication failed due to response, rec(%s) calc(%s)", param[E_RESPONSE].value, resp);
|
CWMP_LOG(ERROR, "Authentication failed due to response, rec(%s) calc(%s)", param[E_RESPONSE].value, resp);
|
||||||
CWMP_LOG(ERROR, "## received nonce:(%s) nc:(%s) usr:(%s)", param[E_NONCE].value, param[E_NC].value, usr);
|
CWMP_LOG(ERROR, "## received nonce:(%s) nc:(%s) usr:(%s)", param[E_NONCE].value, param[E_NC].value, usr);
|
||||||
CWMP_LOG(ERROR, "## rlm:(%s) psw:(%s) meth:(%s)", rlm, psw, http_meth);
|
CWMP_LOG(ERROR, "## rlm:(%s) psw:(%s) meth:(%s)", rlm, psw, http_meth);
|
||||||
|
|
|
||||||
|
|
@ -47,12 +47,12 @@ int download_file(const char *file_path, const char *url, const char *username,
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
|
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
|
||||||
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
|
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
|
||||||
if (username != NULL && strlen(username) > 0) {
|
if (CWMP_STRLEN(username) > 0) {
|
||||||
char userpass[1024];
|
char userpass[1024];
|
||||||
snprintf(userpass, sizeof(userpass), "%s:%s", username, password);
|
snprintf(userpass, sizeof(userpass), "%s:%s", username, password);
|
||||||
curl_easy_setopt(curl, CURLOPT_USERPWD, userpass);
|
curl_easy_setopt(curl, CURLOPT_USERPWD, userpass);
|
||||||
}
|
}
|
||||||
if (strncmp(url, "https://", 8) == 0)
|
if (CWMP_STRNCMP(url, "https://", 8) == 0)
|
||||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
|
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 50L);
|
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 50L);
|
||||||
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_ANY);
|
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_ANY);
|
||||||
|
|
@ -79,7 +79,7 @@ char *download_file_task_function(char *task)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct blob_buf bbuf;
|
struct blob_buf bbuf;
|
||||||
memset(&bbuf, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&bbuf, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&bbuf, 0);
|
blob_buf_init(&bbuf, 0);
|
||||||
|
|
||||||
if (task == NULL) {
|
if (task == NULL) {
|
||||||
|
|
@ -95,7 +95,7 @@ char *download_file_task_function(char *task)
|
||||||
struct blob_attr *tb[5] = { NULL, NULL, NULL, NULL, NULL};
|
struct blob_attr *tb[5] = { NULL, NULL, NULL, NULL, NULL};
|
||||||
blobmsg_parse(p, 5, tb, blobmsg_data(bbuf.head), blobmsg_len(bbuf.head));
|
blobmsg_parse(p, 5, tb, blobmsg_data(bbuf.head), blobmsg_len(bbuf.head));
|
||||||
char *task_name = blobmsg_get_string(tb[0]);
|
char *task_name = blobmsg_get_string(tb[0]);
|
||||||
if (!task_name || strcmp(task_name, "download") != 0)
|
if (CWMP_STRCMP(task_name, "download") != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
char *file_path = blobmsg_get_string(tb[1]);
|
char *file_path = blobmsg_get_string(tb[1]);
|
||||||
char *url = blobmsg_get_string(tb[2]);
|
char *url = blobmsg_get_string(tb[2]);
|
||||||
|
|
@ -121,7 +121,7 @@ int download_file_in_subprocess(const char *file_path, const char *url, const ch
|
||||||
return 500;
|
return 500;
|
||||||
}
|
}
|
||||||
struct blob_buf bbuf;
|
struct blob_buf bbuf;
|
||||||
memset(&bbuf, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&bbuf, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&bbuf, 0);
|
blob_buf_init(&bbuf, 0);
|
||||||
blobmsg_add_string(&bbuf, "task", "download");
|
blobmsg_add_string(&bbuf, "task", "download");
|
||||||
blobmsg_add_string(&bbuf, "file_path", file_path ? file_path : "");
|
blobmsg_add_string(&bbuf, "file_path", file_path ? file_path : "");
|
||||||
|
|
@ -158,7 +158,7 @@ int cwmp_check_image()
|
||||||
{
|
{
|
||||||
int code = 0, e;
|
int code = 0, e;
|
||||||
struct blob_buf b = { 0 };
|
struct blob_buf b = { 0 };
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
|
|
||||||
CWMP_LOG(INFO, "Check downloaded image ...");
|
CWMP_LOG(INFO, "Check downloaded image ...");
|
||||||
|
|
@ -214,7 +214,7 @@ int get_available_bank_id()
|
||||||
{
|
{
|
||||||
int bank_id = 0, e;
|
int bank_id = 0, e;
|
||||||
struct blob_buf b = { 0 };
|
struct blob_buf b = { 0 };
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
|
|
||||||
e = icwmp_ubus_invoke("fwbank", "dump", b.head, ubus_get_available_bank_callback, &bank_id);
|
e = icwmp_ubus_invoke("fwbank", "dump", b.head, ubus_get_available_bank_callback, &bank_id);
|
||||||
|
|
@ -262,7 +262,7 @@ void ubus_get_bank_status_callback(struct ubus_request *req, int type __attribut
|
||||||
if (blobmsg_get_u32(tb[1]) == (uint32_t)bank->bank_id) {
|
if (blobmsg_get_u32(tb[1]) == (uint32_t)bank->bank_id) {
|
||||||
bank_found = true;
|
bank_found = true;
|
||||||
char *status = blobmsg_get_string(tb[7]);
|
char *status = blobmsg_get_string(tb[7]);
|
||||||
if (status && (strcmp(status, "Available") == 0 || strcmp(status, "Active") == 0))
|
if (CWMP_STRCMP(status, "Available") == 0 || CWMP_STRCMP(status, "Active") == 0)
|
||||||
bank->status = 1;
|
bank->status = 1;
|
||||||
else
|
else
|
||||||
bank->status = 0;
|
bank->status = 0;
|
||||||
|
|
@ -276,7 +276,7 @@ int get_applied_firmware_status(struct fwbank_dump *bank)
|
||||||
{
|
{
|
||||||
int e;
|
int e;
|
||||||
struct blob_buf b = { 0 };
|
struct blob_buf b = { 0 };
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
|
|
||||||
e = icwmp_ubus_invoke("fwbank", "dump", b.head, ubus_get_available_bank_callback, &bank);
|
e = icwmp_ubus_invoke("fwbank", "dump", b.head, ubus_get_available_bank_callback, &bank);
|
||||||
|
|
@ -295,7 +295,7 @@ int cwmp_apply_firmware()
|
||||||
{
|
{
|
||||||
int e;
|
int e;
|
||||||
struct blob_buf b = { 0 };
|
struct blob_buf b = { 0 };
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
blobmsg_add_u8(&b, "keep", true);
|
blobmsg_add_u8(&b, "keep", true);
|
||||||
|
|
||||||
|
|
@ -334,7 +334,7 @@ int cwmp_apply_multiple_firmware()
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
struct blob_buf b = { 0 };
|
struct blob_buf b = { 0 };
|
||||||
memset(&b, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&b, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
bb_add_string(&b, "path", FIRMWARE_UPGRADE_IMAGE);
|
bb_add_string(&b, "path", FIRMWARE_UPGRADE_IMAGE);
|
||||||
blobmsg_add_u8(&b, "auto_activate", false);
|
blobmsg_add_u8(&b, "auto_activate", false);
|
||||||
|
|
@ -401,7 +401,7 @@ int cwmp_launch_download(struct download *pdownload, char *download_file_name, e
|
||||||
error = FAULT_CPE_INVALID_ARGUMENTS;
|
error = FAULT_CPE_INVALID_ARGUMENTS;
|
||||||
goto end_download;
|
goto end_download;
|
||||||
}
|
}
|
||||||
if (strcmp(pdownload->file_type, FIRMWARE_UPGRADE_IMAGE_FILE_TYPE) == 0 || strcmp(pdownload->file_type, STORED_FIRMWARE_IMAGE_FILE_TYPE) == 0) {
|
if (CWMP_STRCMP(pdownload->file_type, FIRMWARE_UPGRADE_IMAGE_FILE_TYPE) == 0 || CWMP_STRCMP(pdownload->file_type, STORED_FIRMWARE_IMAGE_FILE_TYPE) == 0) {
|
||||||
rename(ICWMP_DOWNLOAD_FILE, FIRMWARE_UPGRADE_IMAGE);
|
rename(ICWMP_DOWNLOAD_FILE, FIRMWARE_UPGRADE_IMAGE);
|
||||||
if (cwmp_check_image() == 0) {
|
if (cwmp_check_image() == 0) {
|
||||||
long int file_size = get_file_size(FIRMWARE_UPGRADE_IMAGE);
|
long int file_size = get_file_size(FIRMWARE_UPGRADE_IMAGE);
|
||||||
|
|
@ -417,10 +417,10 @@ int cwmp_launch_download(struct download *pdownload, char *download_file_name, e
|
||||||
error = FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED;
|
error = FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED;
|
||||||
remove(FIRMWARE_UPGRADE_IMAGE);
|
remove(FIRMWARE_UPGRADE_IMAGE);
|
||||||
}
|
}
|
||||||
} else if (strcmp(pdownload->file_type, WEB_CONTENT_FILE_TYPE) == 0) {
|
} else if (CWMP_STRCMP(pdownload->file_type, WEB_CONTENT_FILE_TYPE) == 0) {
|
||||||
//TODO Not Supported
|
//TODO Not Supported
|
||||||
error = FAULT_CPE_NO_FAULT;
|
error = FAULT_CPE_NO_FAULT;
|
||||||
} else if (strcmp(pdownload->file_type, VENDOR_CONFIG_FILE_TYPE) == 0) {
|
} else if (CWMP_STRCMP(pdownload->file_type, VENDOR_CONFIG_FILE_TYPE) == 0) {
|
||||||
if (download_file_name != NULL) {
|
if (download_file_name != NULL) {
|
||||||
char file_path[512];
|
char file_path[512];
|
||||||
snprintf(file_path, sizeof(file_path), "/tmp/%s", download_file_name);
|
snprintf(file_path, sizeof(file_path), "/tmp/%s", download_file_name);
|
||||||
|
|
@ -429,10 +429,10 @@ int cwmp_launch_download(struct download *pdownload, char *download_file_name, e
|
||||||
rename(ICWMP_DOWNLOAD_FILE, VENDOR_CONFIG_FILE);
|
rename(ICWMP_DOWNLOAD_FILE, VENDOR_CONFIG_FILE);
|
||||||
|
|
||||||
error = FAULT_CPE_NO_FAULT;
|
error = FAULT_CPE_NO_FAULT;
|
||||||
} else if (strcmp(pdownload->file_type, TONE_FILE_TYPE) == 0) {
|
} else if (CWMP_STRCMP(pdownload->file_type, TONE_FILE_TYPE) == 0) {
|
||||||
//TODO Not Supported
|
//TODO Not Supported
|
||||||
error = FAULT_CPE_NO_FAULT;
|
error = FAULT_CPE_NO_FAULT;
|
||||||
} else if (strcmp(pdownload->file_type, RINGER_FILE_TYPE) == 0) {
|
} else if (CWMP_STRCMP(pdownload->file_type, RINGER_FILE_TYPE) == 0) {
|
||||||
//TODO Not Supported
|
//TODO Not Supported
|
||||||
error = FAULT_CPE_NO_FAULT;
|
error = FAULT_CPE_NO_FAULT;
|
||||||
|
|
||||||
|
|
@ -449,10 +449,10 @@ end_download:
|
||||||
}
|
}
|
||||||
|
|
||||||
p->command_key = pdownload->command_key ? strdup(pdownload->command_key) : strdup("");
|
p->command_key = pdownload->command_key ? strdup(pdownload->command_key) : strdup("");
|
||||||
p->start_time = strdup(download_startTime);
|
p->start_time = CWMP_STRDUP(download_startTime);
|
||||||
p->complete_time = strdup(get_time(time(NULL)));
|
p->complete_time = CWMP_STRDUP(get_time(time(NULL)));
|
||||||
p->type = ltype;
|
p->type = ltype;
|
||||||
p->file_type = strdup(pdownload->file_type);
|
p->file_type = CWMP_STRDUP(pdownload->file_type);
|
||||||
if (error != FAULT_CPE_NO_FAULT) {
|
if (error != FAULT_CPE_NO_FAULT) {
|
||||||
p->fault_code = error;
|
p->fault_code = error;
|
||||||
}
|
}
|
||||||
|
|
@ -488,7 +488,7 @@ int apply_downloaded_file(struct download *pdownload, char *download_file_name,
|
||||||
}
|
}
|
||||||
bkp_session_insert_transfer_complete(ptransfer_complete);
|
bkp_session_insert_transfer_complete(ptransfer_complete);
|
||||||
bkp_session_save();
|
bkp_session_save();
|
||||||
if (strcmp(pdownload->file_type, FIRMWARE_UPGRADE_IMAGE_FILE_TYPE) == 0) {
|
if (CWMP_STRCMP(pdownload->file_type, FIRMWARE_UPGRADE_IMAGE_FILE_TYPE) == 0) {
|
||||||
cwmp_uci_set_value("cwmp", "cpe", "exec_download", "1");
|
cwmp_uci_set_value("cwmp", "cpe", "exec_download", "1");
|
||||||
cwmp_commit_package("cwmp", UCI_STANDARD_CONFIG);
|
cwmp_commit_package("cwmp", UCI_STANDARD_CONFIG);
|
||||||
if (cwmp_apply_firmware() != 0)
|
if (cwmp_apply_firmware() != 0)
|
||||||
|
|
@ -499,10 +499,10 @@ int apply_downloaded_file(struct download *pdownload, char *download_file_name,
|
||||||
error = FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED;
|
error = FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (strcmp(pdownload->file_type, WEB_CONTENT_FILE_TYPE) == 0) {
|
} else if (CWMP_STRCMP(pdownload->file_type, WEB_CONTENT_FILE_TYPE) == 0) {
|
||||||
//TODO Not Supported
|
//TODO Not Supported
|
||||||
error = FAULT_CPE_NO_FAULT;
|
error = FAULT_CPE_NO_FAULT;
|
||||||
} else if (strcmp(pdownload->file_type, VENDOR_CONFIG_FILE_TYPE) == 0) {
|
} else if (CWMP_STRCMP(pdownload->file_type, VENDOR_CONFIG_FILE_TYPE) == 0) {
|
||||||
cwmp_uci_init();
|
cwmp_uci_init();
|
||||||
int err = CWMP_OK;
|
int err = CWMP_OK;
|
||||||
if (download_file_name != NULL) {
|
if (download_file_name != NULL) {
|
||||||
|
|
@ -522,14 +522,14 @@ int apply_downloaded_file(struct download *pdownload, char *download_file_name,
|
||||||
error = FAULT_CPE_INTERNAL_ERROR;
|
error = FAULT_CPE_INTERNAL_ERROR;
|
||||||
else if (err == -1)
|
else if (err == -1)
|
||||||
error = FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED;
|
error = FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED;
|
||||||
} else if (strcmp(pdownload->file_type, TONE_FILE_TYPE) == 0) {
|
} else if (CWMP_STRCMP(pdownload->file_type, TONE_FILE_TYPE) == 0) {
|
||||||
//TODO Not Supported
|
//TODO Not Supported
|
||||||
error = FAULT_CPE_NO_FAULT;
|
error = FAULT_CPE_NO_FAULT;
|
||||||
} else if (strcmp(pdownload->file_type, RINGER_FILE_TYPE) == 0) {
|
} else if (CWMP_STRCMP(pdownload->file_type, RINGER_FILE_TYPE) == 0) {
|
||||||
//TODO Not Supported
|
//TODO Not Supported
|
||||||
error = FAULT_CPE_NO_FAULT;
|
error = FAULT_CPE_NO_FAULT;
|
||||||
|
|
||||||
} else if (strcmp(pdownload->file_type, STORED_FIRMWARE_IMAGE_FILE_TYPE) == 0) {
|
} else if (CWMP_STRCMP(pdownload->file_type, STORED_FIRMWARE_IMAGE_FILE_TYPE) == 0) {
|
||||||
int err = cwmp_apply_multiple_firmware();
|
int err = cwmp_apply_multiple_firmware();
|
||||||
//int err = cwmp_apply_multiple_firmware_in_subprocess();
|
//int err = cwmp_apply_multiple_firmware_in_subprocess();
|
||||||
if (err == CWMP_OK)
|
if (err == CWMP_OK)
|
||||||
|
|
@ -571,7 +571,7 @@ struct transfer_complete *set_download_error_transfer_complete(struct download *
|
||||||
ptransfer_complete = calloc(1, sizeof(struct transfer_complete));
|
ptransfer_complete = calloc(1, sizeof(struct transfer_complete));
|
||||||
if (ptransfer_complete != NULL) {
|
if (ptransfer_complete != NULL) {
|
||||||
ptransfer_complete->command_key = strdup(pdownload && pdownload->command_key ? pdownload->command_key : "");
|
ptransfer_complete->command_key = strdup(pdownload && pdownload->command_key ? pdownload->command_key : "");
|
||||||
ptransfer_complete->start_time = strdup(get_time(time(NULL)));
|
ptransfer_complete->start_time = CWMP_STRDUP(get_time(time(NULL)));
|
||||||
ptransfer_complete->complete_time = strdup(ptransfer_complete->start_time ? ptransfer_complete->start_time : "");
|
ptransfer_complete->complete_time = strdup(ptransfer_complete->start_time ? ptransfer_complete->start_time : "");
|
||||||
ptransfer_complete->fault_code = ltype == TYPE_DOWNLOAD ? FAULT_CPE_DOWNLOAD_FAILURE : FAULT_CPE_DOWNLOAD_FAIL_WITHIN_TIME_WINDOW;
|
ptransfer_complete->fault_code = ltype == TYPE_DOWNLOAD ? FAULT_CPE_DOWNLOAD_FAILURE : FAULT_CPE_DOWNLOAD_FAIL_WITHIN_TIME_WINDOW;
|
||||||
ptransfer_complete->type = ltype;
|
ptransfer_complete->type = ltype;
|
||||||
|
|
@ -821,8 +821,8 @@ void cwmp_start_schedule_download(struct uloop_timeout *timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
ptransfer_complete->command_key = sched_download->command_key ? strdup(sched_download->command_key) : strdup("");
|
ptransfer_complete->command_key = sched_download->command_key ? strdup(sched_download->command_key) : strdup("");
|
||||||
ptransfer_complete->start_time = strdup(get_time(now));
|
ptransfer_complete->start_time = CWMP_STRDUP(get_time(now));
|
||||||
ptransfer_complete->complete_time = strdup(get_time(now));
|
ptransfer_complete->complete_time = CWMP_STRDUP(get_time(now));
|
||||||
ptransfer_complete->type = TYPE_DOWNLOAD;
|
ptransfer_complete->type = TYPE_DOWNLOAD;
|
||||||
ptransfer_complete->fault_code = FAULT_CPE_INTERNAL_ERROR;
|
ptransfer_complete->fault_code = FAULT_CPE_INTERNAL_ERROR;
|
||||||
if (ptransfer_complete->id <= 0) {
|
if (ptransfer_complete->id <= 0) {
|
||||||
|
|
|
||||||
32
src/event.c
32
src/event.c
|
|
@ -111,7 +111,7 @@ int cwmp_root_cause_event_bootstrap()
|
||||||
|
|
||||||
cwmp_load_saved_session(&acsurl, ACS);
|
cwmp_load_saved_session(&acsurl, ACS);
|
||||||
|
|
||||||
if (acsurl == NULL || ((cmp = strcmp(cwmp_main->conf.acsurl, acsurl)) != 0)) {
|
if (acsurl == NULL || ((cmp = CWMP_STRCMP(cwmp_main->conf.acsurl, acsurl)) != 0)) {
|
||||||
struct event_container *event_container;
|
struct event_container *event_container;
|
||||||
event_container = cwmp_add_event_container(EVENT_IDX_0BOOTSTRAP, "");
|
event_container = cwmp_add_event_container(EVENT_IDX_0BOOTSTRAP, "");
|
||||||
FREE(acsurl);
|
FREE(acsurl);
|
||||||
|
|
@ -335,7 +335,7 @@ void connection_request_port_value_change(int port)
|
||||||
bkp_session_save();
|
bkp_session_save();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (strcmp(bport, bufport) != 0) {
|
if (CWMP_STRCMP(bport, bufport) != 0) {
|
||||||
struct event_container *event_container;
|
struct event_container *event_container;
|
||||||
event_container = cwmp_add_event_container(EVENT_IDX_4VALUE_CHANGE, "");
|
event_container = cwmp_add_event_container(EVENT_IDX_4VALUE_CHANGE, "");
|
||||||
if (event_container == NULL) {
|
if (event_container == NULL) {
|
||||||
|
|
@ -371,10 +371,10 @@ int cwmp_root_cause_events()
|
||||||
bool event_code_is_valid(const char *code)
|
bool event_code_is_valid(const char *code)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (code == NULL || strlen(code) == 0)
|
if (CWMP_STRLEN(code) == 0)
|
||||||
return true;
|
return true;
|
||||||
for (i=0; i < __EVENT_IDX_MAX; i++) {
|
for (i=0; i < __EVENT_IDX_MAX; i++) {
|
||||||
if (EVENT_CONST[i].CODE && strcmp(code, EVENT_CONST[i].CODE) == 0)
|
if (CWMP_STRCMP(code, EVENT_CONST[i].CODE) == 0)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -386,34 +386,34 @@ int cwmp_get_int_event_code(const char *code)
|
||||||
if (!event_code_is_valid(code))
|
if (!event_code_is_valid(code))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (code && strncmp(code, "1 ", 2) == 0)
|
if (CWMP_STRNCMP(code, "1 ", 2) == 0)
|
||||||
return EVENT_IDX_1BOOT;
|
return EVENT_IDX_1BOOT;
|
||||||
|
|
||||||
else if (code && strncmp(code, "2 ", 2) == 0)
|
else if (CWMP_STRNCMP(code, "2 ", 2) == 0)
|
||||||
return EVENT_IDX_2PERIODIC;
|
return EVENT_IDX_2PERIODIC;
|
||||||
|
|
||||||
else if (code && strncmp(code, "3 ", 2) == 0)
|
else if (CWMP_STRNCMP(code, "3 ", 2) == 0)
|
||||||
return EVENT_IDX_3SCHEDULED;
|
return EVENT_IDX_3SCHEDULED;
|
||||||
|
|
||||||
else if (code && strncmp(code, "4 ", 2) == 0)
|
else if (CWMP_STRNCMP(code, "4 ", 2) == 0)
|
||||||
return EVENT_IDX_4VALUE_CHANGE;
|
return EVENT_IDX_4VALUE_CHANGE;
|
||||||
|
|
||||||
else if (code && strncmp(code, "6 ", 2) == 0)
|
else if (CWMP_STRNCMP(code, "5 ", 2) == 0)
|
||||||
|
return EVENT_IDX_5KICKED;
|
||||||
|
|
||||||
|
else if (CWMP_STRNCMP(code, "6 ", 2) == 0)
|
||||||
return EVENT_IDX_6CONNECTION_REQUEST;
|
return EVENT_IDX_6CONNECTION_REQUEST;
|
||||||
|
|
||||||
else if (code && strncmp(code, "8 ", 2) == 0)
|
else if (CWMP_STRNCMP(code, "8 ", 2) == 0)
|
||||||
return EVENT_IDX_8DIAGNOSTICS_COMPLETE;
|
return EVENT_IDX_8DIAGNOSTICS_COMPLETE;
|
||||||
|
|
||||||
|
else if (CWMP_STRNCMP(code, "9 ", 2) == 0)
|
||||||
else if (code && strncmp(code, "9 ", 2) == 0)
|
|
||||||
return EVENT_IDX_9REQUEST_DOWNLOAD;
|
return EVENT_IDX_9REQUEST_DOWNLOAD;
|
||||||
|
|
||||||
|
else if (CWMP_STRNCMP(code, "13", 2) == 0)
|
||||||
else if (code && strncmp(code, "13", 2) == 0)
|
|
||||||
return EVENT_IDX_13WAKEUP;
|
return EVENT_IDX_13WAKEUP;
|
||||||
|
|
||||||
|
else if (CWMP_STRNCMP(code, "14", 2) == 0)
|
||||||
else if (code && strncmp(code, "14", 2) == 0)
|
|
||||||
return EVENT_IDX_14HEARTBEAT;
|
return EVENT_IDX_14HEARTBEAT;
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,7 @@ int icwmp_http_send_message(char *msg_out, int msg_out_len, char **msg_in)
|
||||||
|
|
||||||
curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ip);
|
curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ip);
|
||||||
if (CWMP_STRLEN(ip)) {
|
if (CWMP_STRLEN(ip)) {
|
||||||
if (ip_acs[0] == '\0' || strcmp(ip_acs, ip) != 0) {
|
if (ip_acs[0] == '\0' || CWMP_STRCMP(ip_acs, ip) != 0) {
|
||||||
CWMP_STRNCPY(ip_acs, ip, sizeof(ip_acs));
|
CWMP_STRNCPY(ip_acs, ip, sizeof(ip_acs));
|
||||||
tmp = inet_pton(AF_INET, ip, buf);
|
tmp = inet_pton(AF_INET, ip, buf);
|
||||||
if (tmp == 1)
|
if (tmp == 1)
|
||||||
|
|
@ -326,7 +326,7 @@ static void http_cr_new_client(int client, bool service_available)
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(cr_http_get_head, sizeof(cr_http_get_head), "GET %s HTTP/1.1", cr_path);
|
snprintf(cr_http_get_head, sizeof(cr_http_get_head), "GET %s HTTP/1.1", cr_path);
|
||||||
memset(auth_digest_buffer, 0, BUFSIZ);
|
CWMP_MEMSET(auth_digest_buffer, 0, BUFSIZ);
|
||||||
|
|
||||||
/* Initialize timeout of select, so that it will wait for specific time
|
/* Initialize timeout of select, so that it will wait for specific time
|
||||||
* period before timed out to receive data from client. Otherwise if client
|
* period before timed out to receive data from client. Otherwise if client
|
||||||
|
|
@ -437,7 +437,7 @@ static void http_cr_new_client(int client, bool service_available)
|
||||||
bool ignore = false;
|
bool ignore = false;
|
||||||
char rec_http_get_head[HTTP_GET_HDR_LEN] = {0};
|
char rec_http_get_head[HTTP_GET_HDR_LEN] = {0};
|
||||||
|
|
||||||
memset(rec_http_get_head, 0, HTTP_GET_HDR_LEN);
|
CWMP_MEMSET(rec_http_get_head, 0, HTTP_GET_HDR_LEN);
|
||||||
for (size_t i = 0; i < strlen(data) && j < (HTTP_GET_HDR_LEN - 1); i++) {
|
for (size_t i = 0; i < strlen(data) && j < (HTTP_GET_HDR_LEN - 1); i++) {
|
||||||
if (data[i] == '?')
|
if (data[i] == '?')
|
||||||
ignore = true;
|
ignore = true;
|
||||||
|
|
@ -462,7 +462,7 @@ static void http_cr_new_client(int client, bool service_available)
|
||||||
snprintf(request_host, sizeof(request_host), "http://%s", data + strlen("Host: "));
|
snprintf(request_host, sizeof(request_host), "http://%s", data + strlen("Host: "));
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(data, 0, sizeof(data));
|
CWMP_MEMSET(data, 0, sizeof(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
static char *SEVERITY_NAMES[8] = { "[EMERG] ", "[ALERT] ", "[CRITIC] ", "[ERROR] ", "[WARNING]", "[NOTICE] ", "[INFO] ", "[DEBUG] " };
|
static char *SEVERITY_NAMES[8] = { "[EMERG] ", "[ALERT] ", "[CRITIC] ", "[ERROR] ", "[WARNING]", "[NOTICE] ", "[INFO] ", "[DEBUG] " };
|
||||||
static int log_severity = DEFAULT_LOG_SEVERITY;
|
static int log_severity = DEFAULT_LOG_SEVERITY;
|
||||||
static long int log_max_size = DEFAULT_LOG_FILE_SIZE;
|
static long int log_max_size = DEFAULT_LOG_FILE_SIZE;
|
||||||
static char log_file_name[256];
|
static char log_file_name[256] = {0};
|
||||||
static bool enable_log_file = true;
|
static bool enable_log_file = true;
|
||||||
static bool enable_log_stdout = false;
|
static bool enable_log_stdout = false;
|
||||||
static bool enable_log_syslog = true;
|
static bool enable_log_syslog = true;
|
||||||
|
|
@ -47,9 +47,9 @@ int log_set_severity_idx(char *value)
|
||||||
int log_set_log_file_name(char *value)
|
int log_set_log_file_name(char *value)
|
||||||
{
|
{
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
CWMP_STRNCPY(log_file_name, value, sizeof(log_file_name));
|
snprintf(log_file_name, sizeof(log_file_name), "%s", value);
|
||||||
} else {
|
} else {
|
||||||
CWMP_STRNCPY(log_file_name, DEFAULT_LOG_FILE_NAME, sizeof(log_file_name));
|
snprintf(log_file_name, sizeof(log_file_name), "%s", DEFAULT_LOG_FILE_NAME);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -129,7 +129,7 @@ void puts_log(int severity, const char *fmt, ...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
vsprintf(buf + i, (const char *)fmt, args);
|
vsnprintf(buf + i, sizeof(buf)-i-2, (const char *)fmt, args);
|
||||||
if (enable_log_file) {
|
if (enable_log_file) {
|
||||||
CWMP_STRNCPY(buf_file, buf, sizeof(buf_file));
|
CWMP_STRNCPY(buf_file, buf, sizeof(buf_file));
|
||||||
buf_file[strlen(buf)] = '\n';
|
buf_file[strlen(buf)] = '\n';
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ char *check_valid_parameter_path(char *parameter_name)
|
||||||
/*check if parameter name is valid parameter path*/
|
/*check if parameter name is valid parameter path*/
|
||||||
error = cwmp_get_parameter_names(parameter_name, false, ¶meters_list);
|
error = cwmp_get_parameter_names(parameter_name, false, ¶meters_list);
|
||||||
|
|
||||||
if (error != NULL && strcmp(error, "9003") == 0)
|
if (error && CWMP_STRCMP(error, "9003") == 0)
|
||||||
error = cwmp_get_parameter_values(parameter_name, ¶meters_list);
|
error = cwmp_get_parameter_values(parameter_name, ¶meters_list);
|
||||||
|
|
||||||
cwmp_free_all_dm_parameter_list(¶meters_list);
|
cwmp_free_all_dm_parameter_list(¶meters_list);
|
||||||
|
|
@ -248,7 +248,7 @@ int get_parameter_family_notifications(char *parameter_name, struct list_head *c
|
||||||
parent_param = e->name;
|
parent_param = e->name;
|
||||||
notif_ret = i;
|
notif_ret = i;
|
||||||
}
|
}
|
||||||
if (strcmp(parameter_name, e->name) == 0)
|
if (CWMP_STRCMP(parameter_name, e->name) == 0)
|
||||||
notif_ret = i;
|
notif_ret = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -266,7 +266,7 @@ int get_parameter_leaf_notification_from_childs_list(char *parameter_name, struc
|
||||||
if (childs_list == NULL)
|
if (childs_list == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
list_for_each_entry (param_value, childs_list, list) {
|
list_for_each_entry (param_value, childs_list, list) {
|
||||||
if (param_value->name && strcmp(param_value->name, parameter_name) == 0) {
|
if (CWMP_STRCMP(param_value->name, parameter_name) == 0) {
|
||||||
ret_notif = param_value->notification;
|
ret_notif = param_value->notification;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -344,9 +344,9 @@ bool parameter_is_other_notif_object_child(char *parent, char *parameter)
|
||||||
list_iter.next = list_ptr->next;
|
list_iter.next = list_ptr->next;
|
||||||
if (dm_parameter->name == NULL)
|
if (dm_parameter->name == NULL)
|
||||||
continue;
|
continue;
|
||||||
if (strcmp(parent, dm_parameter->name) == 0)
|
if (CWMP_STRCMP(parent, dm_parameter->name) == 0)
|
||||||
continue;
|
continue;
|
||||||
if (strncmp(parent, dm_parameter->name, strlen(parent)) == 0 && strncmp(parameter, dm_parameter->name, strlen(dm_parameter->name)) == 0)
|
if (CWMP_STRNCMP(parent, dm_parameter->name, strlen(parent)) == 0 && CWMP_STRNCMP(parameter, dm_parameter->name, strlen(dm_parameter->name)) == 0)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -429,7 +429,7 @@ void update_notify_file_line(FILE *notify_file, char *param_name, char *param_ty
|
||||||
if (param_name == NULL)
|
if (param_name == NULL)
|
||||||
return;
|
return;
|
||||||
struct blob_buf bbuf;
|
struct blob_buf bbuf;
|
||||||
memset(&bbuf, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&bbuf, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&bbuf, 0);
|
blob_buf_init(&bbuf, 0);
|
||||||
blobmsg_add_string(&bbuf, "parameter", param_name);
|
blobmsg_add_string(&bbuf, "parameter", param_name);
|
||||||
blobmsg_add_u32(&bbuf, "notification", notification);
|
blobmsg_add_u32(&bbuf, "notification", notification);
|
||||||
|
|
@ -460,12 +460,12 @@ void cwmp_update_enabled_notify_file(void)
|
||||||
/*
|
/*
|
||||||
* Load custom notify json file
|
* Load custom notify json file
|
||||||
*/
|
*/
|
||||||
void load_custom_notify_json()
|
void load_custom_notify_json(void)
|
||||||
{
|
{
|
||||||
struct blob_buf bbuf;
|
struct blob_buf bbuf = {0};
|
||||||
struct blob_attr *cur;
|
struct blob_attr *cur = NULL;
|
||||||
struct blob_attr *custom_notify_list = NULL;
|
struct blob_attr *custom_notify_list = NULL;
|
||||||
int rem;
|
int rem = 0;
|
||||||
|
|
||||||
cwmp_main->custom_notify_active = false;
|
cwmp_main->custom_notify_active = false;
|
||||||
if (cwmp_main->conf.custom_notify_json == NULL || !file_exists(cwmp_main->conf.custom_notify_json))
|
if (cwmp_main->conf.custom_notify_json == NULL || !file_exists(cwmp_main->conf.custom_notify_json))
|
||||||
|
|
@ -475,7 +475,7 @@ void load_custom_notify_json()
|
||||||
if (file_exists(NOTIFY_MARKER) == true)
|
if (file_exists(NOTIFY_MARKER) == true)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
memset(&bbuf, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&bbuf, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&bbuf, 0);
|
blob_buf_init(&bbuf, 0);
|
||||||
|
|
||||||
// Create success marker in temp area, so that it can be in sync with backup script
|
// Create success marker in temp area, so that it can be in sync with backup script
|
||||||
|
|
@ -511,11 +511,11 @@ void load_custom_notify_json()
|
||||||
char *fault = cwmp_set_parameter_attributes(blobmsg_get_string(tb[0]), atoi(blobmsg_get_string(tb[1])));
|
char *fault = cwmp_set_parameter_attributes(blobmsg_get_string(tb[0]), atoi(blobmsg_get_string(tb[1])));
|
||||||
if (fault == NULL)
|
if (fault == NULL)
|
||||||
continue;
|
continue;
|
||||||
if (strcmp(fault, "9005") == 0) {
|
if (CWMP_STRCMP(fault, "9005") == 0) {
|
||||||
CWMP_LOG(WARNING, "The parameter %s is wrong path", blobmsg_get_string(tb[0]));
|
CWMP_LOG(WARNING, "The parameter %s is wrong path", blobmsg_get_string(tb[0]));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strcmp(fault, "9009") == 0) {
|
if (CWMP_STRCMP(fault, "9009") == 0) {
|
||||||
CWMP_LOG(WARNING, "This parameter %s is forced notification parameter, can't be changed", blobmsg_get_string(tb[0]));
|
CWMP_LOG(WARNING, "This parameter %s is forced notification parameter, can't be changed", blobmsg_get_string(tb[0]));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -532,12 +532,12 @@ void set_default_forced_active_parameters_notifications()
|
||||||
if (fault == NULL)
|
if (fault == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (strcmp(fault, "9005") == 0) {
|
if (CWMP_STRCMP(fault, "9005") == 0) {
|
||||||
CWMP_LOG(WARNING, "The parameter %s is wrong path", default_active_notifications_parameters[i]);
|
CWMP_LOG(WARNING, "The parameter %s is wrong path", default_active_notifications_parameters[i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(fault, "9009") == 0) {
|
if (CWMP_STRCMP(fault, "9009") == 0) {
|
||||||
CWMP_LOG(WARNING, "This parameter %s is forced notification parameter, can't be changed", default_active_notifications_parameters[i]);
|
CWMP_LOG(WARNING, "This parameter %s is forced notification parameter, can't be changed", default_active_notifications_parameters[i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -561,7 +561,7 @@ void get_parameter_value_from_parameters_list(struct list_head *params_list, cha
|
||||||
list_for_each_entry (param_value, params_list, list) {
|
list_for_each_entry (param_value, params_list, list) {
|
||||||
if (param_value->name == NULL)
|
if (param_value->name == NULL)
|
||||||
continue;
|
continue;
|
||||||
if (strcmp(parameter_name, param_value->name) != 0)
|
if (CWMP_STRCMP(parameter_name, param_value->name) != 0)
|
||||||
continue;
|
continue;
|
||||||
*value = strdup(param_value->value ? param_value->value : "");
|
*value = strdup(param_value->value ? param_value->value : "");
|
||||||
*type = strdup(param_value->type ? param_value->type : "");
|
*type = strdup(param_value->type ? param_value->type : "");
|
||||||
|
|
@ -589,7 +589,7 @@ int check_value_change(void)
|
||||||
if (len)
|
if (len)
|
||||||
buf[len - 1] = '\0';
|
buf[len - 1] = '\0';
|
||||||
|
|
||||||
memset(&bbuf, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&bbuf, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&bbuf, 0);
|
blob_buf_init(&bbuf, 0);
|
||||||
|
|
||||||
if (blobmsg_add_json_from_string(&bbuf, buf) == false) {
|
if (blobmsg_add_json_from_string(&bbuf, buf) == false) {
|
||||||
|
|
@ -615,7 +615,7 @@ int check_value_change(void)
|
||||||
}
|
}
|
||||||
if ((notification >= 1) && (dm_value != NULL) && value && (strcmp(dm_value, value) != 0)) {
|
if ((notification >= 1) && (dm_value != NULL) && value && (strcmp(dm_value, value) != 0)) {
|
||||||
|
|
||||||
if (cwmp_main->conf.md_notif_limit > 0 && strcmp(parameter, MANAGEABLE_DEVICES_NBRE) == 0 && notification == 2) {
|
if (cwmp_main->conf.md_notif_limit > 0 && CWMP_STRCMP(parameter, MANAGEABLE_DEVICES_NBRE) == 0 && notification == 2) {
|
||||||
unsigned int time_from_last_vc = time(NULL) - cwmp_main->md_value_change_last_time;
|
unsigned int time_from_last_vc = time(NULL) - cwmp_main->md_value_change_last_time;
|
||||||
if ((cwmp_main->md_value_change_last_time <= 0) || (time_from_last_vc >= cwmp_main->conf.md_notif_limit)) {
|
if ((cwmp_main->md_value_change_last_time <= 0) || (time_from_last_vc >= cwmp_main->conf.md_notif_limit)) {
|
||||||
cwmp_main->md_value_change_last_time = time(NULL);
|
cwmp_main->md_value_change_last_time = time(NULL);
|
||||||
|
|
|
||||||
56
src/rpc.c
56
src/rpc.c
|
|
@ -118,13 +118,13 @@ int xml_handle_message()
|
||||||
char *tmp = strchr(c, ':');
|
char *tmp = strchr(c, ':');
|
||||||
size_t ns_len = tmp - c;
|
size_t ns_len = tmp - c;
|
||||||
|
|
||||||
if (strlen(ns.cwmp) != ns_len) {
|
if (CWMP_STRLEN(ns.cwmp) != ns_len) {
|
||||||
CWMP_LOG(INFO, "Namespace length is not matched in string (%s) and expected (%s)", c, ns.cwmp);
|
CWMP_LOG(INFO, "Namespace length is not matched in string (%s) and expected (%s)", c, ns.cwmp);
|
||||||
cwmp_main->session->fault_code = FAULT_CPE_REQUEST_DENIED;
|
cwmp_main->session->fault_code = FAULT_CPE_REQUEST_DENIED;
|
||||||
goto fault;
|
goto fault;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(ns.cwmp, c, ns_len)) {
|
if (CWMP_STRNCMP(ns.cwmp, c, ns_len)) {
|
||||||
CWMP_LOG(INFO, "Namespace in string (%s) is not the expected (%s) one", c, ns.cwmp);
|
CWMP_LOG(INFO, "Namespace in string (%s) is not the expected (%s) one", c, ns.cwmp);
|
||||||
cwmp_main->session->fault_code = FAULT_CPE_REQUEST_DENIED;
|
cwmp_main->session->fault_code = FAULT_CPE_REQUEST_DENIED;
|
||||||
goto fault;
|
goto fault;
|
||||||
|
|
@ -138,7 +138,7 @@ int xml_handle_message()
|
||||||
}
|
}
|
||||||
CWMP_LOG(INFO, "SOAP RPC message: %s", c);
|
CWMP_LOG(INFO, "SOAP RPC message: %s", c);
|
||||||
for (i = 1; i < __RPC_CPE_MAX; i++) {
|
for (i = 1; i < __RPC_CPE_MAX; i++) {
|
||||||
if (i != RPC_CPE_FAULT && c && strcmp(c, rpc_cpe_methods[i].name) == 0 && rpc_cpe_methods[i].amd <= conf->supported_amd_version) {
|
if (i != RPC_CPE_FAULT && c && CWMP_STRCMP(c, rpc_cpe_methods[i].name) == 0 && rpc_cpe_methods[i].amd <= conf->supported_amd_version) {
|
||||||
CWMP_LOG(INFO, "%s RPC is supported", c);
|
CWMP_LOG(INFO, "%s RPC is supported", c);
|
||||||
cwmp_main->session->rpc_cpe = build_sessin_rcp_cpe(i);
|
cwmp_main->session->rpc_cpe = build_sessin_rcp_cpe(i);
|
||||||
if (cwmp_main->session->rpc_cpe == NULL)
|
if (cwmp_main->session->rpc_cpe == NULL)
|
||||||
|
|
@ -175,7 +175,7 @@ static int xml_prepare_parameters_inform(struct cwmp_dm_parameter *dm_parameter,
|
||||||
return 0;
|
return 0;
|
||||||
mxml_node_t *c = mxmlGetFirstChild(b);
|
mxml_node_t *c = mxmlGetFirstChild(b);
|
||||||
const char *c_opaque = c ? mxmlGetOpaque(c) : NULL;
|
const char *c_opaque = c ? mxmlGetOpaque(c) : NULL;
|
||||||
if (c && c_opaque && strcmp(dm_parameter->value, c_opaque) == 0)
|
if (c && c_opaque && CWMP_STRCMP(dm_parameter->value, c_opaque) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
mxmlDelete(b);
|
mxmlDelete(b);
|
||||||
(*size)--;
|
(*size)--;
|
||||||
|
|
@ -188,9 +188,9 @@ static int xml_prepare_parameters_inform(struct cwmp_dm_parameter *dm_parameter,
|
||||||
return -1;
|
return -1;
|
||||||
struct xml_data_struct inform_params_xml_attrs = {0};
|
struct xml_data_struct inform_params_xml_attrs = {0};
|
||||||
struct xml_list_data *xml_data = calloc(1, sizeof(struct xml_list_data));
|
struct xml_list_data *xml_data = calloc(1, sizeof(struct xml_list_data));
|
||||||
xml_data->param_name = strdup(dm_parameter->name);
|
xml_data->param_name = CWMP_STRDUP(dm_parameter->name);
|
||||||
xml_data->param_value = strdup(dm_parameter->value);
|
xml_data->param_value = CWMP_STRDUP(dm_parameter->value);
|
||||||
xml_data->param_type = strdup(type);
|
xml_data->param_type = CWMP_STRDUP(type);
|
||||||
LIST_HEAD(prameters_xml_list);
|
LIST_HEAD(prameters_xml_list);
|
||||||
list_add_tail(&xml_data->list, &prameters_xml_list);
|
list_add_tail(&xml_data->list, &prameters_xml_list);
|
||||||
inform_params_xml_attrs.data_list = &prameters_xml_list;
|
inform_params_xml_attrs.data_list = &prameters_xml_list;
|
||||||
|
|
@ -220,7 +220,7 @@ bool event_in_session_event_list(char *event, struct list_head *list_evts)
|
||||||
if (event == NULL)
|
if (event == NULL)
|
||||||
return false;
|
return false;
|
||||||
list_for_each_entry (event_container, list_evts, list) {
|
list_for_each_entry (event_container, list_evts, list) {
|
||||||
if (strcmp(event, EVENT_CONST[event_container->code].CODE) == 0)
|
if (CWMP_STRCMP(event, EVENT_CONST[event_container->code].CODE) == 0)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -328,7 +328,7 @@ static void load_inform_xml_schema(mxml_node_t **tree)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// An empty connection url cause CDR test to break
|
// An empty connection url cause CDR test to break
|
||||||
if (strcmp(forced_inform_parameters[i], "Device.ManagementServer.ConnectionRequestURL") == 0 &&
|
if (CWMP_STRCMP(forced_inform_parameters[i], "Device.ManagementServer.ConnectionRequestURL") == 0 &&
|
||||||
CWMP_STRLEN(cwmp_dm_param.value) == 0) {
|
CWMP_STRLEN(cwmp_dm_param.value) == 0) {
|
||||||
CWMP_LOG(ERROR, "# Empty CR URL[%s] value", forced_inform_parameters[i]);
|
CWMP_LOG(ERROR, "# Empty CR URL[%s] value", forced_inform_parameters[i]);
|
||||||
MXML_DELETE(xml);
|
MXML_DELETE(xml);
|
||||||
|
|
@ -410,7 +410,7 @@ static int validate_inform_parameter_name(struct list_head *parameters_values_li
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(forced_inform_parameters); i++) {
|
for (size_t i = 0; i < ARRAY_SIZE(forced_inform_parameters); i++) {
|
||||||
if (strcmp(forced_inform_parameters[i], param_value->value) == 0)
|
if (CWMP_STRCMP(forced_inform_parameters[i], param_value->value) == 0)
|
||||||
return FAULT_CPE_INVALID_PARAMETER_VALUE;
|
return FAULT_CPE_INVALID_PARAMETER_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -516,7 +516,7 @@ int set_rpc_acs_to_supported(const char *rpc_name)
|
||||||
if (rpc_name == NULL)
|
if (rpc_name == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
for (i=1; i < __RPC_ACS_MAX; i++) {
|
for (i=1; i < __RPC_ACS_MAX; i++) {
|
||||||
if (strcmp(rpc_acs_methods[i].name, rpc_name) == 0) {
|
if (CWMP_STRCMP(rpc_acs_methods[i].name, rpc_name) == 0) {
|
||||||
rpc_acs_methods[i].acs_support = RPC_ACS_SUPPORT;
|
rpc_acs_methods[i].acs_support = RPC_ACS_SUPPORT;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
@ -961,8 +961,8 @@ int is_duplicated_parameter(mxml_node_t *param_node)
|
||||||
mxml_type_t node_type = mxmlGetType(b);
|
mxml_type_t node_type = mxmlGetType(b);
|
||||||
const char *parent_name = parent ? mxmlGetElement(parent) : NULL;
|
const char *parent_name = parent ? mxmlGetElement(parent) : NULL;
|
||||||
|
|
||||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && node_name && parent_name && !strcmp(parent_name, "Name")) {
|
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && node_name && parent_name && !CWMP_STRCMP(parent_name, "Name")) {
|
||||||
if (strcmp(node_opaque, mxmlGetOpaque(param_node)) == 0)
|
if (CWMP_STRCMP(node_opaque, mxmlGetOpaque(param_node)) == 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1277,7 +1277,7 @@ int cwmp_handle_rpc_cpe_get_rpc_methods(struct rpc *rpc)
|
||||||
for (i = 1; i < __RPC_CPE_MAX; i++) {
|
for (i = 1; i < __RPC_CPE_MAX; i++) {
|
||||||
if (i != RPC_CPE_FAULT) {
|
if (i != RPC_CPE_FAULT) {
|
||||||
struct xml_list_data *xml_data = calloc(1, sizeof(struct xml_list_data));
|
struct xml_list_data *xml_data = calloc(1, sizeof(struct xml_list_data));
|
||||||
xml_data->rpc_name = strdup(rpc_cpe_methods[i].name);
|
xml_data->rpc_name = CWMP_STRDUP(rpc_cpe_methods[i].name);
|
||||||
list_add(&(xml_data->list), &rpcs_list);
|
list_add(&(xml_data->list), &rpcs_list);
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
|
@ -1408,7 +1408,7 @@ int cancel_transfer(char *key)
|
||||||
if (list_download.next != &(list_download)) {
|
if (list_download.next != &(list_download)) {
|
||||||
list_for_each_safe (ilist, q, &(list_download)) {
|
list_for_each_safe (ilist, q, &(list_download)) {
|
||||||
struct download *pdownload = list_entry(ilist, struct download, list);
|
struct download *pdownload = list_entry(ilist, struct download, list);
|
||||||
if (key && pdownload->command_key && strcmp(pdownload->command_key, key) == 0) {
|
if (CWMP_STRCMP(pdownload->command_key, key) == 0) {
|
||||||
bkp_session_delete_element("download", pdownload->id);
|
bkp_session_delete_element("download", pdownload->id);
|
||||||
bkp_session_save();
|
bkp_session_save();
|
||||||
list_del(&(pdownload->list));
|
list_del(&(pdownload->list));
|
||||||
|
|
@ -1421,7 +1421,7 @@ int cancel_transfer(char *key)
|
||||||
if (list_upload.next != &(list_upload)) {
|
if (list_upload.next != &(list_upload)) {
|
||||||
list_for_each_safe (ilist, q, &(list_upload)) {
|
list_for_each_safe (ilist, q, &(list_upload)) {
|
||||||
struct upload *pupload = list_entry(ilist, struct upload, list);
|
struct upload *pupload = list_entry(ilist, struct upload, list);
|
||||||
if (key && pupload->command_key && strcmp(pupload->command_key, key) == 0) {
|
if (CWMP_STRCMP(pupload->command_key, key) == 0) {
|
||||||
bkp_session_delete_element("upload", pupload->id);
|
bkp_session_delete_element("upload", pupload->id);
|
||||||
bkp_session_save();
|
bkp_session_save();
|
||||||
list_del(&(pupload->list));
|
list_del(&(pupload->list));
|
||||||
|
|
@ -1681,15 +1681,15 @@ int cwmp_handle_rpc_cpe_download(struct rpc *rpc)
|
||||||
if (error)
|
if (error)
|
||||||
goto fault;
|
goto fault;
|
||||||
|
|
||||||
if (strcmp(download->file_type, FIRMWARE_UPGRADE_IMAGE_FILE_TYPE) && strcmp(download->file_type, WEB_CONTENT_FILE_TYPE) && strcmp(download->file_type, VENDOR_CONFIG_FILE_TYPE) && strcmp(download->file_type, TONE_FILE_TYPE) && strcmp(download->file_type, RINGER_FILE_TYPE) && strcmp(download->file_type, STORED_FIRMWARE_IMAGE_FILE_TYPE)) {
|
if (CWMP_STRCMP(download->file_type, FIRMWARE_UPGRADE_IMAGE_FILE_TYPE) && CWMP_STRCMP(download->file_type, WEB_CONTENT_FILE_TYPE) && CWMP_STRCMP(download->file_type, VENDOR_CONFIG_FILE_TYPE) && CWMP_STRCMP(download->file_type, TONE_FILE_TYPE) && CWMP_STRCMP(download->file_type, RINGER_FILE_TYPE) && CWMP_STRCMP(download->file_type, STORED_FIRMWARE_IMAGE_FILE_TYPE)) {
|
||||||
error = FAULT_CPE_INVALID_ARGUMENTS;
|
error = FAULT_CPE_INVALID_ARGUMENTS;
|
||||||
} else if (count_download_queue >= MAX_DOWNLOAD_QUEUE) {
|
} else if (count_download_queue >= MAX_DOWNLOAD_QUEUE) {
|
||||||
error = FAULT_CPE_RESOURCES_EXCEEDED;
|
error = FAULT_CPE_RESOURCES_EXCEEDED;
|
||||||
} else if (download->url == NULL || (strcmp(download->url, "") == 0)) {
|
} else if (CWMP_STRLEN(download->url) == 0) {
|
||||||
error = FAULT_CPE_REQUEST_DENIED;
|
error = FAULT_CPE_REQUEST_DENIED;
|
||||||
} else if (strstr(download->url, "@") != NULL) {
|
} else if (CWMP_STRSTR(download->url, "@") != NULL) {
|
||||||
error = FAULT_CPE_INVALID_ARGUMENTS;
|
error = FAULT_CPE_INVALID_ARGUMENTS;
|
||||||
} else if (strncmp(download->url, DOWNLOAD_PROTOCOL_HTTP, strlen(DOWNLOAD_PROTOCOL_HTTP)) != 0 && strncmp(download->url, DOWNLOAD_PROTOCOL_HTTPS, strlen(DOWNLOAD_PROTOCOL_HTTPS)) != 0 && strncmp(download->url, DOWNLOAD_PROTOCOL_FTP, strlen(DOWNLOAD_PROTOCOL_FTP)) != 0) {
|
} else if (CWMP_STRNCMP(download->url, DOWNLOAD_PROTOCOL_HTTP, strlen(DOWNLOAD_PROTOCOL_HTTP)) != 0 && CWMP_STRNCMP(download->url, DOWNLOAD_PROTOCOL_HTTPS, strlen(DOWNLOAD_PROTOCOL_HTTPS)) != 0 && CWMP_STRNCMP(download->url, DOWNLOAD_PROTOCOL_FTP, strlen(DOWNLOAD_PROTOCOL_FTP)) != 0) {
|
||||||
error = FAULT_CPE_FILE_TRANSFER_UNSUPPORTED_PROTOCOL;
|
error = FAULT_CPE_FILE_TRANSFER_UNSUPPORTED_PROTOCOL;
|
||||||
}
|
}
|
||||||
if (error != FAULT_CPE_NO_FAULT)
|
if (error != FAULT_CPE_NO_FAULT)
|
||||||
|
|
@ -1814,17 +1814,17 @@ int cwmp_handle_rpc_cpe_schedule_download(struct rpc *rpc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(schedule_download->file_type, FIRMWARE_UPGRADE_IMAGE_FILE_TYPE) && strcmp(schedule_download->file_type, WEB_CONTENT_FILE_TYPE) && strcmp(schedule_download->file_type, VENDOR_CONFIG_FILE_TYPE) && strcmp(schedule_download->file_type, TONE_FILE_TYPE) && strcmp(schedule_download->file_type, RINGER_FILE_TYPE) && strcmp(schedule_download->file_type, STORED_FIRMWARE_IMAGE_FILE_TYPE)) {
|
if (CWMP_STRCMP(schedule_download->file_type, FIRMWARE_UPGRADE_IMAGE_FILE_TYPE) && CWMP_STRCMP(schedule_download->file_type, WEB_CONTENT_FILE_TYPE) && CWMP_STRCMP(schedule_download->file_type, VENDOR_CONFIG_FILE_TYPE) && CWMP_STRCMP(schedule_download->file_type, TONE_FILE_TYPE) && CWMP_STRCMP(schedule_download->file_type, RINGER_FILE_TYPE) && CWMP_STRCMP(schedule_download->file_type, STORED_FIRMWARE_IMAGE_FILE_TYPE)) {
|
||||||
error = FAULT_CPE_INVALID_ARGUMENTS;
|
error = FAULT_CPE_INVALID_ARGUMENTS;
|
||||||
} else if ((strcmp(schedule_download->timewindowstruct[0].windowmode, "1 At Any Time") && strcmp(schedule_download->timewindowstruct[0].windowmode, "2 Immediately") && strcmp(schedule_download->timewindowstruct[0].windowmode, "3 When Idle")) || (strcmp(schedule_download->timewindowstruct[1].windowmode, "1 At Any Time") && strcmp(schedule_download->timewindowstruct[1].windowmode, "2 Immediately") && strcmp(schedule_download->timewindowstruct[1].windowmode, "3 When Idle"))) {
|
} else if ((CWMP_STRCMP(schedule_download->timewindowstruct[0].windowmode, "1 At Any Time") && CWMP_STRCMP(schedule_download->timewindowstruct[0].windowmode, "2 Immediately") && CWMP_STRCMP(schedule_download->timewindowstruct[0].windowmode, "3 When Idle")) || (CWMP_STRCMP(schedule_download->timewindowstruct[1].windowmode, "1 At Any Time") && CWMP_STRCMP(schedule_download->timewindowstruct[1].windowmode, "2 Immediately") && CWMP_STRCMP(schedule_download->timewindowstruct[1].windowmode, "3 When Idle"))) {
|
||||||
error = FAULT_CPE_REQUEST_DENIED;
|
error = FAULT_CPE_REQUEST_DENIED;
|
||||||
} else if (count_download_queue >= MAX_DOWNLOAD_QUEUE) {
|
} else if (count_download_queue >= MAX_DOWNLOAD_QUEUE) {
|
||||||
error = FAULT_CPE_RESOURCES_EXCEEDED;
|
error = FAULT_CPE_RESOURCES_EXCEEDED;
|
||||||
} else if (schedule_download->url == NULL || (strcmp(schedule_download->url, "") == 0)) {
|
} else if (CWMP_STRLEN(schedule_download->url) == 0) {
|
||||||
error = FAULT_CPE_REQUEST_DENIED;
|
error = FAULT_CPE_REQUEST_DENIED;
|
||||||
} else if (strstr(schedule_download->url, "@") != NULL) {
|
} else if (CWMP_STRSTR(schedule_download->url, "@") != NULL) {
|
||||||
error = FAULT_CPE_INVALID_ARGUMENTS;
|
error = FAULT_CPE_INVALID_ARGUMENTS;
|
||||||
} else if (strncmp(schedule_download->url, DOWNLOAD_PROTOCOL_HTTP, strlen(DOWNLOAD_PROTOCOL_HTTP)) != 0 && strncmp(schedule_download->url, DOWNLOAD_PROTOCOL_FTP, strlen(DOWNLOAD_PROTOCOL_FTP)) != 0) {
|
} else if (CWMP_STRNCMP(schedule_download->url, DOWNLOAD_PROTOCOL_HTTP, strlen(DOWNLOAD_PROTOCOL_HTTP)) != 0 && CWMP_STRNCMP(schedule_download->url, DOWNLOAD_PROTOCOL_FTP, strlen(DOWNLOAD_PROTOCOL_FTP)) != 0) {
|
||||||
error = FAULT_CPE_FILE_TRANSFER_UNSUPPORTED_PROTOCOL;
|
error = FAULT_CPE_FILE_TRANSFER_UNSUPPORTED_PROTOCOL;
|
||||||
} else {
|
} else {
|
||||||
for (j = 0; j < 3; j++) {
|
for (j = 0; j < 3; j++) {
|
||||||
|
|
@ -1938,11 +1938,11 @@ int cwmp_handle_rpc_cpe_upload(struct rpc *rpc)
|
||||||
|
|
||||||
if (count_upload_queue >= MAX_UPLOAD_QUEUE) {
|
if (count_upload_queue >= MAX_UPLOAD_QUEUE) {
|
||||||
error = FAULT_CPE_RESOURCES_EXCEEDED;
|
error = FAULT_CPE_RESOURCES_EXCEEDED;
|
||||||
} else if (upload->url == NULL || (strcmp(upload->url, "") == 0)) {
|
} else if (CWMP_STRLEN(upload->url) == 0) {
|
||||||
error = FAULT_CPE_REQUEST_DENIED;
|
error = FAULT_CPE_REQUEST_DENIED;
|
||||||
} else if (strstr(upload->url, "@") != NULL) {
|
} else if (CWMP_STRSTR(upload->url, "@") != NULL) {
|
||||||
error = FAULT_CPE_INVALID_ARGUMENTS;
|
error = FAULT_CPE_INVALID_ARGUMENTS;
|
||||||
} else if (strncmp(upload->url, DOWNLOAD_PROTOCOL_HTTPS, strlen(DOWNLOAD_PROTOCOL_HTTPS)) != 0 && strncmp(upload->url, DOWNLOAD_PROTOCOL_HTTP, strlen(DOWNLOAD_PROTOCOL_HTTP)) != 0 && strncmp(upload->url, DOWNLOAD_PROTOCOL_FTP, strlen(DOWNLOAD_PROTOCOL_FTP)) != 0) {
|
} else if (CWMP_STRNCMP(upload->url, DOWNLOAD_PROTOCOL_HTTPS, strlen(DOWNLOAD_PROTOCOL_HTTPS)) != 0 && CWMP_STRNCMP(upload->url, DOWNLOAD_PROTOCOL_HTTP, strlen(DOWNLOAD_PROTOCOL_HTTP)) != 0 && CWMP_STRNCMP(upload->url, DOWNLOAD_PROTOCOL_FTP, strlen(DOWNLOAD_PROTOCOL_FTP)) != 0) {
|
||||||
error = FAULT_CPE_FILE_TRANSFER_UNSUPPORTED_PROTOCOL;
|
error = FAULT_CPE_FILE_TRANSFER_UNSUPPORTED_PROTOCOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -385,7 +385,7 @@ void start_cwmp_session()
|
||||||
CWMP_LOG(INFO, "Start session");
|
CWMP_LOG(INFO, "Start session");
|
||||||
|
|
||||||
uci_get_value(UCI_CPE_EXEC_DOWNLOAD, &exec_download);
|
uci_get_value(UCI_CPE_EXEC_DOWNLOAD, &exec_download);
|
||||||
if (exec_download && strcmp(exec_download, "1") == 0) {
|
if (CWMP_STRCMP(exec_download, "1") == 0) {
|
||||||
CWMP_LOG(INFO, "Firmware downloaded and applied successfully");
|
CWMP_LOG(INFO, "Firmware downloaded and applied successfully");
|
||||||
cwmp_uci_set_value("cwmp", "cpe", "exec_download", "0");
|
cwmp_uci_set_value("cwmp", "cpe", "exec_download", "0");
|
||||||
cwmp_commit_package("cwmp", UCI_STANDARD_CONFIG);
|
cwmp_commit_package("cwmp", UCI_STANDARD_CONFIG);
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,10 @@ bool check_task_name(char *task, char *name)
|
||||||
{
|
{
|
||||||
struct blob_buf bbuf;
|
struct blob_buf bbuf;
|
||||||
|
|
||||||
if (task && strcmp(task, "{}") == 0)
|
if (task && CWMP_STRCMP(task, "{}") == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
memset(&bbuf, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&bbuf, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&bbuf, 0);
|
blob_buf_init(&bbuf, 0);
|
||||||
|
|
||||||
if (blobmsg_add_json_from_string(&bbuf, task) == false) {
|
if (blobmsg_add_json_from_string(&bbuf, task) == false) {
|
||||||
|
|
@ -44,7 +44,7 @@ bool check_task_name(char *task, char *name)
|
||||||
|
|
||||||
char *task_name = blobmsg_get_string(tb[0]);
|
char *task_name = blobmsg_get_string(tb[0]);
|
||||||
|
|
||||||
if (strcmp(task_name, name) == 0) {
|
if (CWMP_STRCMP(task_name, name) == 0) {
|
||||||
blob_buf_free(&bbuf);
|
blob_buf_free(&bbuf);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -92,11 +92,12 @@ int subprocess_start(task_function task_fun)
|
||||||
char *to_child = task_fun(from_parent);
|
char *to_child = task_fun(from_parent);
|
||||||
|
|
||||||
struct blob_buf bbuf;
|
struct blob_buf bbuf;
|
||||||
memset(&bbuf, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&bbuf, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&bbuf, 0);
|
blob_buf_init(&bbuf, 0);
|
||||||
blobmsg_add_string(&bbuf, "ret", to_child ? to_child : "500");
|
blobmsg_add_string(&bbuf, "ret", to_child ? to_child : "500");
|
||||||
char *to_child_json = blobmsg_format_json(bbuf.head, true);
|
char *to_child_json = blobmsg_format_json(bbuf.head, true);
|
||||||
write(pipefd2[1], to_child_json, strlen(to_child_json)+1);
|
write(pipefd2[1], to_child_json, CWMP_STRLEN(to_child_json)+1);
|
||||||
|
|
||||||
FREE(to_child);
|
FREE(to_child);
|
||||||
FREE(to_child_json);
|
FREE(to_child_json);
|
||||||
blob_buf_free(&bbuf);
|
blob_buf_free(&bbuf);
|
||||||
|
|
@ -108,8 +109,14 @@ int subprocess_start(task_function task_fun)
|
||||||
char *execute_task_in_subprocess(char *task)
|
char *execute_task_in_subprocess(char *task)
|
||||||
{
|
{
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
|
int len = 0;
|
||||||
|
|
||||||
write(pipefd1[1], task, strlen(task) + 1);
|
len = CWMP_STRLEN(task);
|
||||||
|
|
||||||
|
if (len == 0)
|
||||||
|
write(pipefd1[1], END_TASK, strlen(END_TASK) +1);
|
||||||
|
else
|
||||||
|
write(pipefd1[1], task, len + 1);
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
char from_child[512];
|
char from_child[512];
|
||||||
|
|
@ -124,7 +131,7 @@ char *execute_task_in_subprocess(char *task)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct blob_buf bbuf;
|
struct blob_buf bbuf;
|
||||||
memset(&bbuf, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&bbuf, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&bbuf, 0);
|
blob_buf_init(&bbuf, 0);
|
||||||
if (blobmsg_add_json_from_string(&bbuf, from_child) == false) {
|
if (blobmsg_add_json_from_string(&bbuf, from_child) == false) {
|
||||||
blob_buf_free(&bbuf);
|
blob_buf_free(&bbuf);
|
||||||
|
|
@ -140,7 +147,8 @@ char *execute_task_in_subprocess(char *task)
|
||||||
ret = blobmsg_get_string(tb[0]);
|
ret = blobmsg_get_string(tb[0]);
|
||||||
write(pipefd1[1], END_TASK, strlen(END_TASK) +1);
|
write(pipefd1[1], END_TASK, strlen(END_TASK) +1);
|
||||||
}
|
}
|
||||||
close(pipefd1[0]);
|
|
||||||
close(pipefd1[1]);
|
close(pipefd1[0]);
|
||||||
return ret;
|
close(pipefd1[1]);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,7 @@ static int reload_cmd(struct blob_buf *b)
|
||||||
blobmsg_add_u32(b, "status", 0);
|
blobmsg_add_u32(b, "status", 0);
|
||||||
blobmsg_add_string(b, "info", "Session running, reload at the end of the session");
|
blobmsg_add_string(b, "info", "Session running, reload at the end of the session");
|
||||||
} else {
|
} else {
|
||||||
int error = CWMP_OK;
|
int error = cwmp_apply_acs_changes();
|
||||||
error = cwmp_apply_acs_changes();
|
|
||||||
if (error != CWMP_OK) {
|
if (error != CWMP_OK) {
|
||||||
// Failed to load cwmp config
|
// Failed to load cwmp config
|
||||||
CWMP_LOG(ERROR, "cwmp failed to reload the configuration");
|
CWMP_LOG(ERROR, "cwmp failed to reload the configuration");
|
||||||
|
|
@ -73,7 +72,7 @@ static int call_command_cb(char *cmd, struct blob_buf *b)
|
||||||
|
|
||||||
cmd_num = sizeof(cmd_cb)/sizeof(struct command_cb);
|
cmd_num = sizeof(cmd_cb)/sizeof(struct command_cb);
|
||||||
for (i = 0; i < cmd_num; i++) {
|
for (i = 0; i < cmd_num; i++) {
|
||||||
if (strcmp(cmd, cmd_cb[i].str) == 0) {
|
if (CWMP_STRCMP(cmd, cmd_cb[i].str) == 0) {
|
||||||
cb = cmd_cb[i].cb;
|
cb = cmd_cb[i].cb;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -115,7 +114,7 @@ static int icwmp_command_handler(struct ubus_context *ctx, struct ubus_object *o
|
||||||
struct blob_buf blob_command;
|
struct blob_buf blob_command;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
memset(&blob_command, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&blob_command, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&blob_command, 0);
|
blob_buf_init(&blob_command, 0);
|
||||||
|
|
||||||
ret = blobmsg_parse(icwmp_cmd_policy, ARRAY_SIZE(icwmp_cmd_policy), tb, blob_data(msg), blob_len(msg));
|
ret = blobmsg_parse(icwmp_cmd_policy, ARRAY_SIZE(icwmp_cmd_policy), tb, blob_data(msg), blob_len(msg));
|
||||||
|
|
@ -227,7 +226,7 @@ static int icwmp_status_handler(struct ubus_context *ctx, struct ubus_object *ob
|
||||||
{
|
{
|
||||||
struct blob_buf bb;
|
struct blob_buf bb;
|
||||||
|
|
||||||
memset(&bb, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&bb, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&bb, 0);
|
blob_buf_init(&bb, 0);
|
||||||
|
|
||||||
bb_add_icwmp_status(&bb);
|
bb_add_icwmp_status(&bb);
|
||||||
|
|
@ -282,7 +281,7 @@ static int icwmp_inform_event(struct blob_buf *bb, char *event)
|
||||||
static int icwmp_inform_handler(struct ubus_context *ctx, struct ubus_object *obj __attribute__((unused)), struct ubus_request_data *req, const char *method __attribute__((unused)), struct blob_attr *msg)
|
static int icwmp_inform_handler(struct ubus_context *ctx, struct ubus_object *obj __attribute__((unused)), struct ubus_request_data *req, const char *method __attribute__((unused)), struct blob_attr *msg)
|
||||||
{
|
{
|
||||||
struct blob_buf bb;
|
struct blob_buf bb;
|
||||||
memset(&bb, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&bb, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&bb, 0);
|
blob_buf_init(&bb, 0);
|
||||||
|
|
||||||
if (cwmp_main->init_complete == false) {
|
if (cwmp_main->init_complete == false) {
|
||||||
|
|
@ -424,7 +423,7 @@ int initiate_autonomous_complpolicy(void)
|
||||||
if (cwmp_main->ev == NULL)
|
if (cwmp_main->ev == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
memset(cwmp_main->ev, 0, sizeof(struct ubus_event_handler));
|
CWMP_MEMSET(cwmp_main->ev, 0, sizeof(struct ubus_event_handler));
|
||||||
cwmp_main->ev->cb = autonomous_notification_handler;
|
cwmp_main->ev->cb = autonomous_notification_handler;
|
||||||
|
|
||||||
int ret = ubus_register_event_handler(ubus_ctx, cwmp_main->ev, "bbfdm.event");
|
int ret = ubus_register_event_handler(ubus_ctx, cwmp_main->ev, "bbfdm.event");
|
||||||
|
|
|
||||||
17
src/upload.c
17
src/upload.c
|
|
@ -99,12 +99,12 @@ int upload_file(const char *file_path, const char *url, const char *username, co
|
||||||
curl = curl_easy_init();
|
curl = curl_easy_init();
|
||||||
|
|
||||||
if (curl) {
|
if (curl) {
|
||||||
if (username != NULL && strlen(username) > 0) {
|
if (CWMP_STRLEN(username) > 0) {
|
||||||
char userpass[256];
|
char userpass[256];
|
||||||
snprintf(userpass, sizeof(userpass), "%s:%s", username, password ? password : "");
|
snprintf(userpass, sizeof(userpass), "%s:%s", username, password ? password : "");
|
||||||
curl_easy_setopt(curl, CURLOPT_USERPWD, userpass);
|
curl_easy_setopt(curl, CURLOPT_USERPWD, userpass);
|
||||||
}
|
}
|
||||||
if (strncmp(url, "https://", 8) == 0)
|
if (CWMP_STRNCMP(url, "https://", 8) == 0)
|
||||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
|
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, CURL_TIMEOUT);
|
curl_easy_setopt(curl, CURLOPT_TIMEOUT, CURL_TIMEOUT);
|
||||||
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 50L);
|
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 50L);
|
||||||
|
|
@ -137,7 +137,7 @@ char *upload_file_task_function(char *task)
|
||||||
CWMP_LOG(ERROR, "upload %s: task is null", __FUNCTION__);
|
CWMP_LOG(ERROR, "upload %s: task is null", __FUNCTION__);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memset(&bbuf, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&bbuf, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&bbuf, 0);
|
blob_buf_init(&bbuf, 0);
|
||||||
|
|
||||||
if (blobmsg_add_json_from_string(&bbuf, task) == false) {
|
if (blobmsg_add_json_from_string(&bbuf, task) == false) {
|
||||||
|
|
@ -149,7 +149,7 @@ char *upload_file_task_function(char *task)
|
||||||
struct blob_attr *tb[5] = { NULL, NULL, NULL, NULL, NULL};
|
struct blob_attr *tb[5] = { NULL, NULL, NULL, NULL, NULL};
|
||||||
blobmsg_parse(p, 5, tb, blobmsg_data(bbuf.head), blobmsg_len(bbuf.head));
|
blobmsg_parse(p, 5, tb, blobmsg_data(bbuf.head), blobmsg_len(bbuf.head));
|
||||||
char *task_name = blobmsg_get_string(tb[0]);
|
char *task_name = blobmsg_get_string(tb[0]);
|
||||||
if (!task_name || strcmp(task_name, "upload") != 0)
|
if (CWMP_STRCMP(task_name, "upload") != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
char *file_path = blobmsg_get_string(tb[1]);
|
char *file_path = blobmsg_get_string(tb[1]);
|
||||||
char *url = blobmsg_get_string(tb[2]);
|
char *url = blobmsg_get_string(tb[2]);
|
||||||
|
|
@ -172,7 +172,7 @@ int upload_file_in_subprocess(const char *file_path, const char *url, const char
|
||||||
subprocess_start(upload_file_task_function);
|
subprocess_start(upload_file_task_function);
|
||||||
|
|
||||||
struct blob_buf bbuf;
|
struct blob_buf bbuf;
|
||||||
memset(&bbuf, 0, sizeof(struct blob_buf));
|
CWMP_MEMSET(&bbuf, 0, sizeof(struct blob_buf));
|
||||||
blob_buf_init(&bbuf, 0);
|
blob_buf_init(&bbuf, 0);
|
||||||
blobmsg_add_string(&bbuf, "task", "upload");
|
blobmsg_add_string(&bbuf, "task", "upload");
|
||||||
blobmsg_add_string(&bbuf, "file_path", file_path);
|
blobmsg_add_string(&bbuf, "file_path", file_path);
|
||||||
|
|
@ -214,7 +214,6 @@ int cwmp_launch_upload(struct upload *pupload, struct transfer_complete **ptrans
|
||||||
error = FAULT_CPE_UPLOAD_FAILURE;
|
error = FAULT_CPE_UPLOAD_FAILURE;
|
||||||
FREE(name);
|
FREE(name);
|
||||||
}
|
}
|
||||||
FREE(name);
|
|
||||||
} else
|
} else
|
||||||
error = FAULT_CPE_UPLOAD_FAILURE;
|
error = FAULT_CPE_UPLOAD_FAILURE;
|
||||||
} else if (pupload->file_type[0] == '3') {
|
} else if (pupload->file_type[0] == '3') {
|
||||||
|
|
@ -242,7 +241,7 @@ int cwmp_launch_upload(struct upload *pupload, struct transfer_complete **ptrans
|
||||||
error = FAULT_CPE_UPLOAD_FAILURE;
|
error = FAULT_CPE_UPLOAD_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error != FAULT_CPE_NO_FAULT || strlen(file_path) == 0) {
|
if (error != FAULT_CPE_NO_FAULT || CWMP_STRLEN(file_path) == 0) {
|
||||||
error = FAULT_CPE_UPLOAD_FAILURE;
|
error = FAULT_CPE_UPLOAD_FAILURE;
|
||||||
goto end_upload;
|
goto end_upload;
|
||||||
}
|
}
|
||||||
|
|
@ -262,8 +261,8 @@ end_upload:
|
||||||
}
|
}
|
||||||
|
|
||||||
p->command_key = pupload->command_key ? strdup(pupload->command_key) : strdup("");
|
p->command_key = pupload->command_key ? strdup(pupload->command_key) : strdup("");
|
||||||
p->start_time = strdup(upload_startTime);
|
p->start_time = CWMP_STRDUP(upload_startTime);
|
||||||
p->complete_time = strdup(get_time(time(NULL)));
|
p->complete_time = CWMP_STRDUP(get_time(time(NULL)));
|
||||||
p->type = TYPE_UPLOAD;
|
p->type = TYPE_UPLOAD;
|
||||||
if (error != FAULT_CPE_NO_FAULT) {
|
if (error != FAULT_CPE_NO_FAULT) {
|
||||||
p->fault_code = error;
|
p->fault_code = error;
|
||||||
|
|
|
||||||
68
src/xml.c
68
src/xml.c
|
|
@ -315,11 +315,11 @@ int load_upload_filetype(mxml_node_t *b, struct xml_data_struct *xml_attrs)
|
||||||
int ftype, instance = 0;
|
int ftype, instance = 0;
|
||||||
|
|
||||||
sscanf(node_opaque, "%1d Vendor %15s File %8d", &ftype, log_config, &instance);
|
sscanf(node_opaque, "%1d Vendor %15s File %8d", &ftype, log_config, &instance);
|
||||||
if (strcmp(log_config, "Configuration") != 0 && strcmp(log_config, "Log") != 0)
|
if (CWMP_STRCMP(log_config, "Configuration") != 0 && CWMP_STRCMP(log_config, "Log") != 0)
|
||||||
return FAULT_CPE_INVALID_ARGUMENTS;
|
return FAULT_CPE_INVALID_ARGUMENTS;
|
||||||
else if (strcmp(log_config, "Configuration") == 0 && ftype != 1 && ftype != 3)
|
else if (CWMP_STRCMP(log_config, "Configuration") == 0 && ftype != 1 && ftype != 3)
|
||||||
return FAULT_CPE_INVALID_ARGUMENTS;
|
return FAULT_CPE_INVALID_ARGUMENTS;
|
||||||
else if (strcmp(log_config, "Log") == 0 && ftype != 2 && ftype != 4)
|
else if (CWMP_STRCMP(log_config, "Log") == 0 && ftype != 2 && ftype != 4)
|
||||||
return FAULT_CPE_INVALID_ARGUMENTS;
|
return FAULT_CPE_INVALID_ARGUMENTS;
|
||||||
if ((ftype == 3 || ftype == 4) && (instance == 0))
|
if ((ftype == 3 || ftype == 4) && (instance == 0))
|
||||||
return FAULT_CPE_INVALID_ARGUMENTS;
|
return FAULT_CPE_INVALID_ARGUMENTS;
|
||||||
|
|
@ -398,16 +398,16 @@ int load_change_du_state_operation(mxml_node_t *b, struct xml_data_struct *xml_a
|
||||||
return FAULT_CPE_INTERNAL_ERROR;
|
return FAULT_CPE_INTERNAL_ERROR;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (strcmp(operation, "cwmp:InstallOpStruct") == 0) {
|
if (CWMP_STRCMP(operation, "cwmp:InstallOpStruct") == 0) {
|
||||||
cdu_ref = SOAP_REQ_DU_INSTALL;
|
cdu_ref = SOAP_REQ_DU_INSTALL;
|
||||||
type = DU_INSTALL;
|
type = DU_INSTALL;
|
||||||
}
|
}
|
||||||
else if (strcmp(operation, "cwmp:UpdateOpStruct") == 0) {
|
else if (CWMP_STRCMP(operation, "cwmp:UpdateOpStruct") == 0) {
|
||||||
cdu_ref = SOAP_REQ_DU_UPDATE;
|
cdu_ref = SOAP_REQ_DU_UPDATE;
|
||||||
type = DU_UPDATE;
|
type = DU_UPDATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (strcmp(operation, "cwmp:UninstallOpStruct") == 0) {
|
else if (CWMP_STRCMP(operation, "cwmp:UninstallOpStruct") == 0) {
|
||||||
cdu_ref = SOAP_REQ_DU_UNINSTALL;
|
cdu_ref = SOAP_REQ_DU_UNINSTALL;
|
||||||
type = DU_UNINSTALL;
|
type = DU_UNINSTALL;
|
||||||
}
|
}
|
||||||
|
|
@ -440,13 +440,13 @@ int load_cdu_backup_operation(mxml_node_t *b, struct xml_data_struct *xml_attrs)
|
||||||
bkp_xml_cdu_backup.url = &operat->url;
|
bkp_xml_cdu_backup.url = &operat->url;
|
||||||
bkp_xml_cdu_backup.username = &operat->username;
|
bkp_xml_cdu_backup.username = &operat->username;
|
||||||
bkp_xml_cdu_backup.password = &operat->password;
|
bkp_xml_cdu_backup.password = &operat->password;
|
||||||
if (strcmp(element, "update") == 0) {
|
if (CWMP_STRCMP(element, "update") == 0) {
|
||||||
operat->type = DU_UPDATE;
|
operat->type = DU_UPDATE;
|
||||||
fault = load_xml_node_data(BKP_CDU_UPDATE, b, &bkp_xml_cdu_backup);
|
fault = load_xml_node_data(BKP_CDU_UPDATE, b, &bkp_xml_cdu_backup);
|
||||||
} else if (strcmp(element, "install") == 0) {
|
} else if (CWMP_STRCMP(element, "install") == 0) {
|
||||||
operat->type = DU_INSTALL;
|
operat->type = DU_INSTALL;
|
||||||
fault = load_xml_node_data(BKP_CDU_INSTALL, b, &bkp_xml_cdu_backup);
|
fault = load_xml_node_data(BKP_CDU_INSTALL, b, &bkp_xml_cdu_backup);
|
||||||
} else if (strcmp(element, "uninstall") == 0) {
|
} else if (CWMP_STRCMP(element, "uninstall") == 0) {
|
||||||
operat->type = DU_UNINSTALL;
|
operat->type = DU_UNINSTALL;
|
||||||
fault = load_xml_node_data(BKP_CDU_UNINSTALL, b, &bkp_xml_cdu_backup);
|
fault = load_xml_node_data(BKP_CDU_UNINSTALL, b, &bkp_xml_cdu_backup);
|
||||||
}
|
}
|
||||||
|
|
@ -667,7 +667,10 @@ char *get_xml_node_name_switch(char *node_name)
|
||||||
size_t total_size = sizeof(xml_nodes_names_switches) / sizeof(struct xml_switch);
|
size_t total_size = sizeof(xml_nodes_names_switches) / sizeof(struct xml_switch);
|
||||||
for (i = 0; i < total_size; i++)
|
for (i = 0; i < total_size; i++)
|
||||||
{
|
{
|
||||||
if (strcmp(node_name, xml_nodes_names_switches[i].node_name) == 0)
|
if (xml_nodes_names_switches[i].node_name == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (CWMP_STRCMP(node_name, xml_nodes_names_switches[i].node_name) == 0)
|
||||||
return xml_nodes_names_switches[i].switch_node_name;
|
return xml_nodes_names_switches[i].switch_node_name;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -682,7 +685,10 @@ char *get_xml_node_name_by_switch_name(char *switch_node_name)
|
||||||
size_t total_size = sizeof(xml_nodes_names_switches) / sizeof(struct xml_switch);
|
size_t total_size = sizeof(xml_nodes_names_switches) / sizeof(struct xml_switch);
|
||||||
for (i = 0; i < total_size; i++)
|
for (i = 0; i < total_size; i++)
|
||||||
{
|
{
|
||||||
if (strcmp(switch_node_name, xml_nodes_names_switches[i].switch_node_name) == 0)
|
if (xml_nodes_names_switches[i].switch_node_name == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (CWMP_STRCMP(switch_node_name, xml_nodes_names_switches[i].switch_node_name) == 0)
|
||||||
return xml_nodes_names_switches[i].node_name;
|
return xml_nodes_names_switches[i].node_name;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -696,7 +702,10 @@ int get_xml_tag_index(const char *name)
|
||||||
|
|
||||||
size_t total_size = sizeof(xml_tags_names) / sizeof(char*);
|
size_t total_size = sizeof(xml_tags_names) / sizeof(char*);
|
||||||
for (i = 0; i < total_size; i++) {
|
for (i = 0; i < total_size; i++) {
|
||||||
if (strcmp(name, xml_tags_names[i]) == 0)
|
if (xml_tags_names[i] == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (CWMP_STRCMP(name, xml_tags_names[i]) == 0)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -708,10 +717,14 @@ int get_xml_soap_tag_index(int soap_ref, const char *name)
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
while (xml_nodes_data[soap_ref].xml_tags[i].tag_name) {
|
|
||||||
if (strcmp(name, xml_nodes_data[soap_ref].xml_tags[i].tag_name) == 0)
|
size_t total_size = sizeof(xml_nodes_data[soap_ref].xml_tags) / sizeof(struct xml_tag);
|
||||||
|
for (i = 0; i < total_size; i++) {
|
||||||
|
if (xml_nodes_data[soap_ref].xml_tags[i].tag_name == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (CWMP_STRCMP(name, xml_nodes_data[soap_ref].xml_tags[i].tag_name) == 0)
|
||||||
return i;
|
return i;
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -724,7 +737,7 @@ int load_xml_list_node_data(int node_ref, mxml_node_t *node, struct xml_data_str
|
||||||
while (b) {
|
while (b) {
|
||||||
if (mxmlGetType(b) == MXML_ELEMENT) {
|
if (mxmlGetType(b) == MXML_ELEMENT) {
|
||||||
const char *b_name = b ? mxmlGetElement(b) : NULL;
|
const char *b_name = b ? mxmlGetElement(b) : NULL;
|
||||||
if (b_name && xml_nodes_data[node_ref].tag_list_name && strcmp(xml_nodes_data[node_ref].tag_list_name, b_name) == 0) {
|
if (b_name && CWMP_STRCMP(xml_nodes_data[node_ref].tag_list_name, b_name) == 0) {
|
||||||
struct xml_list_data *xml_data = calloc(1, sizeof(struct xml_list_data));
|
struct xml_list_data *xml_data = calloc(1, sizeof(struct xml_list_data));
|
||||||
|
|
||||||
struct xml_data_struct xml_attrs_args = {0};
|
struct xml_data_struct xml_attrs_args = {0};
|
||||||
|
|
@ -775,7 +788,10 @@ bool validate_xml_node_opaque_value(char *node_name, char *opaque, struct xml_ta
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (i = 0; i < nbre_validations; i++) {
|
for (i = 0; i < nbre_validations; i++) {
|
||||||
if (strcmp(node_name, validations[i].tag_name) == 0) {
|
if (validations[i].tag_name == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (CWMP_STRCMP(node_name, validations[i].tag_name) == 0) {
|
||||||
if (validations[i].validation_type == VALIDATE_STR_SIZE) {
|
if (validations[i].validation_type == VALIDATE_STR_SIZE) {
|
||||||
if (!icwmp_validate_string_length(opaque, validations[i].max))
|
if (!icwmp_validate_string_length(opaque, validations[i].max))
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -806,7 +822,10 @@ bool check_node_is_switch_by_node_name(int node_ref, char *node_name)
|
||||||
size_t total_size = sizeof(xml_nodes_data[node_ref].xml_tags) / sizeof(struct xml_tag);
|
size_t total_size = sizeof(xml_nodes_data[node_ref].xml_tags) / sizeof(struct xml_tag);
|
||||||
for (i = 0; i < total_size; i++)
|
for (i = 0; i < total_size; i++)
|
||||||
{
|
{
|
||||||
if (strcmp(xml_nodes_data[node_ref].xml_tags[i].tag_name, node_name) == 0 && xml_nodes_data[node_ref].xml_tags[i].rec_ref == XML_SWITCH)
|
if (xml_nodes_data[node_ref].xml_tags[i].tag_name == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (CWMP_STRCMP(xml_nodes_data[node_ref].xml_tags[i].tag_name, node_name) == 0 && xml_nodes_data[node_ref].xml_tags[i].rec_ref == XML_SWITCH)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -920,6 +939,7 @@ int load_xml_node_data(int node_ref, mxml_node_t *node, struct xml_data_struct *
|
||||||
void cwmp_param_fault_list_to_xml_data_list(struct list_head *param_fault_list, struct list_head *xml_data_list)
|
void cwmp_param_fault_list_to_xml_data_list(struct list_head *param_fault_list, struct list_head *xml_data_list)
|
||||||
{
|
{
|
||||||
struct cwmp_param_fault *param_fault = NULL;
|
struct cwmp_param_fault *param_fault = NULL;
|
||||||
|
|
||||||
list_for_each_entry (param_fault, param_fault_list, list) {
|
list_for_each_entry (param_fault, param_fault_list, list) {
|
||||||
if (!param_fault->fault)
|
if (!param_fault->fault)
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -929,9 +949,9 @@ void cwmp_param_fault_list_to_xml_data_list(struct list_head *param_fault_list,
|
||||||
xml_data = calloc(1, sizeof(struct xml_list_data));
|
xml_data = calloc(1, sizeof(struct xml_list_data));
|
||||||
list_add_tail(&xml_data->list, xml_data_list);
|
list_add_tail(&xml_data->list, xml_data_list);
|
||||||
int idx = cwmp_get_fault_code(param_fault->fault);
|
int idx = cwmp_get_fault_code(param_fault->fault);
|
||||||
xml_data->param_name = strdup(param_fault->name);
|
xml_data->param_name = CWMP_STRDUP(param_fault->name);
|
||||||
xml_data->fault_code = atoi(FAULT_CPE_ARRAY[idx].CODE);
|
xml_data->fault_code = atoi(FAULT_CPE_ARRAY[idx].CODE);
|
||||||
xml_data->fault_string = strdup(FAULT_CPE_ARRAY[idx].DESCRIPTION);
|
xml_data->fault_string = CWMP_STRDUP(FAULT_CPE_ARRAY[idx].DESCRIPTION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -944,7 +964,7 @@ void dm_parameter_list_to_xml_data_list(struct list_head *dm_parameter_list, str
|
||||||
struct xml_list_data *xml_data;
|
struct xml_list_data *xml_data;
|
||||||
xml_data = calloc(1, sizeof(struct xml_list_data));
|
xml_data = calloc(1, sizeof(struct xml_list_data));
|
||||||
list_add_tail(&xml_data->list, xml_data_list);
|
list_add_tail(&xml_data->list, xml_data_list);
|
||||||
xml_data->param_name = strdup(param_value->name);
|
xml_data->param_name = CWMP_STRDUP(param_value->name);
|
||||||
xml_data->param_value = strdup(param_value->value ? param_value->value : "");
|
xml_data->param_value = strdup(param_value->value ? param_value->value : "");
|
||||||
xml_data->param_type = strdup(param_value->type ? param_value->type : "");
|
xml_data->param_type = strdup(param_value->type ? param_value->type : "");
|
||||||
xml_data->access_list = strdup(param_value->access_list ? param_value->access_list : "");
|
xml_data->access_list = strdup(param_value->access_list ? param_value->access_list : "");
|
||||||
|
|
@ -1269,7 +1289,7 @@ mxmlFindElementOpaque(mxml_node_t *node, /* I - Current node */
|
||||||
|
|
||||||
while (node != NULL) {
|
while (node != NULL) {
|
||||||
const char *op = mxmlGetOpaque(node);
|
const char *op = mxmlGetOpaque(node);
|
||||||
if (mxmlGetType(node) == MXML_OPAQUE && op && (!strcmp(op, text))) {
|
if (mxmlGetType(node) == MXML_OPAQUE && (!CWMP_STRCMP(op, text))) {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1290,7 +1310,7 @@ char *xml__get_attribute_name_by_value(mxml_node_t *node, const char *value)
|
||||||
for (i = 0; i < attributes_nbre; i++) {
|
for (i = 0; i < attributes_nbre; i++) {
|
||||||
char *attr_name = NULL;
|
char *attr_name = NULL;
|
||||||
const char *attr_value = mxmlElementGetAttrByIndex(node, i, (const char **)&attr_name);
|
const char *attr_value = mxmlElementGetAttrByIndex(node, i, (const char **)&attr_name);
|
||||||
if (attr_value && strcmp(attr_value, value) == 0)
|
if (attr_value && CWMP_STRCMP(attr_value, value) == 0)
|
||||||
return attr_name;
|
return attr_name;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -1399,7 +1419,7 @@ int xml_send_message(struct rpc *rpc)
|
||||||
}
|
}
|
||||||
if (msg_in) {
|
if (msg_in) {
|
||||||
CWMP_LOG_XML_MSG(DEBUG, msg_in, XML_MSG_IN);
|
CWMP_LOG_XML_MSG(DEBUG, msg_in, XML_MSG_IN);
|
||||||
if ((s = strstr(msg_in, "<FaultCode>")))
|
if ((s = CWMP_STRSTR(msg_in, "<FaultCode>")))
|
||||||
sscanf(s, "<FaultCode>%d</FaultCode>", &f);
|
sscanf(s, "<FaultCode>%d</FaultCode>", &f);
|
||||||
if (f) {
|
if (f) {
|
||||||
if (f == 8005) {
|
if (f == 8005) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue