mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2026-01-28 01:27:16 +01:00
Fix string operations
This commit is contained in:
parent
cbfff1b644
commit
5cb85ba5b6
23 changed files with 494 additions and 428 deletions
|
|
@ -112,7 +112,7 @@ int get_bkp_attribute_index_type(const char *name)
|
|||
return -1;
|
||||
size_t total_size = sizeof(bkp_attrs_names) / sizeof(struct backup_attributes_name_type);
|
||||
for (i = 0; i < total_size; i++) {
|
||||
if (strcmp(name, bkp_attrs_names[i].name) == 0)
|
||||
if (CWMP_STRCMP(name, bkp_attrs_names[i].name) == 0)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
|
|
@ -141,7 +141,7 @@ void load_specific_backup_attributes(mxml_node_t *tree, struct backup_attributes
|
|||
switch (bkp_attrs_names[idx].bkp_type) {
|
||||
case BKP_STRING:
|
||||
str = (char **)(*ptr);
|
||||
*str = strdup(opaque);
|
||||
*str = CWMP_STRDUP(opaque);
|
||||
break;
|
||||
case BKP_INTEGER:
|
||||
intgr = (int *)(*ptr);
|
||||
|
|
@ -210,7 +210,7 @@ mxml_node_t *bkp_session_node_found(mxml_node_t *tree, char *name, struct search
|
|||
if (c) {
|
||||
i = 0;
|
||||
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 = mxmlWalkNext(d, c, MXML_DESCEND);
|
||||
if ((keys[i].value == NULL) || (d && mxmlGetType(d) == MXML_OPAQUE && CWMP_STRCMP(keys[i].value, mxmlGetOpaque(d)) == 0))
|
||||
|
|
@ -312,7 +312,7 @@ void bkp_session_move_inform_to_inform_send()
|
|||
pthread_mutex_lock(&mutex_backup_session);
|
||||
while (b) {
|
||||
mxml_node_t *p = mxmlGetParent(b);
|
||||
if (mxmlGetType(b) == MXML_ELEMENT && !strcmp(mxmlGetElement(b), "queue_event") && mxmlGetType(p) == MXML_ELEMENT && !strcmp(mxmlGetElement(p), "cwmp"))
|
||||
if (mxmlGetType(b) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(b), "queue_event") && mxmlGetType(p) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(p), "cwmp"))
|
||||
mxmlSetElement(b, "send_event");
|
||||
|
||||
b = mxmlWalkNext(b, bkp_tree, MXML_DESCEND);
|
||||
|
|
@ -327,7 +327,7 @@ void bkp_session_move_inform_to_inform_queue()
|
|||
pthread_mutex_lock(&mutex_backup_session);
|
||||
while (b) {
|
||||
mxml_node_t *p = mxmlGetParent(b);
|
||||
if (mxmlGetType(b) == MXML_ELEMENT && !strcmp(mxmlGetElement(b), "send_event") && mxmlGetType(p) == MXML_ELEMENT && !strcmp(mxmlGetElement(p), "cwmp"))
|
||||
if (mxmlGetType(b) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(b), "send_event") && mxmlGetType(p) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(p), "cwmp"))
|
||||
mxmlSetElement(b, "queue_event");
|
||||
|
||||
b = mxmlWalkNext(b, bkp_tree, MXML_DESCEND);
|
||||
|
|
@ -775,10 +775,7 @@ char *load_child_value(mxml_node_t *tree, char *sub_name)
|
|||
if (b) {
|
||||
b = mxmlWalkNext(b, tree, MXML_DESCEND);
|
||||
if (b && mxmlGetType(b) == MXML_OPAQUE) {
|
||||
const char *opaque = mxmlGetOpaque(b);
|
||||
if (opaque != NULL) {
|
||||
value = strdup(opaque);
|
||||
}
|
||||
value = CWMP_STRDUP(mxmlGetOpaque(b));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -801,7 +798,7 @@ void load_queue_event(mxml_node_t *tree, struct cwmp *cwmp)
|
|||
if (mxmlGetType(b) == MXML_ELEMENT) {
|
||||
const char *element = mxmlGetElement(b);
|
||||
|
||||
if (strcmp(element, "command_key") == 0) {
|
||||
if (CWMP_STRCMP(element, "command_key") == 0) {
|
||||
if (idx != -1) {
|
||||
if (EVENT_CONST[idx].RETRY & EVENT_RETRY_AFTER_REBOOT) {
|
||||
event_container_save = cwmp_add_event_container(cwmp, idx, ((command_key != NULL) ? command_key : ""));
|
||||
|
|
@ -811,7 +808,7 @@ void load_queue_event(mxml_node_t *tree, struct cwmp *cwmp)
|
|||
}
|
||||
}
|
||||
FREE(command_key);
|
||||
} else if (strcmp(element, "parameter") == 0) {
|
||||
} else if (CWMP_STRCMP(element, "parameter") == 0) {
|
||||
c = mxmlWalkNext(b, b, MXML_DESCEND);
|
||||
if (c && mxmlGetType(c) == MXML_OPAQUE) {
|
||||
const char *op = mxmlGetOpaque(c);
|
||||
|
|
@ -981,20 +978,20 @@ void load_change_du_state(mxml_node_t *tree)
|
|||
while (b) {
|
||||
if (mxmlGetType(b) == MXML_ELEMENT) {
|
||||
const char *element = mxmlGetElement(b);
|
||||
if (strcmp(element, "update") == 0) {
|
||||
if (CWMP_STRCMP(element, "update") == 0) {
|
||||
elem = (operations *)calloc(1, sizeof(operations));
|
||||
elem->type = DU_UPDATE;
|
||||
list_add_tail(&(elem->list), &(change_du_state_request->list_operation));
|
||||
struct backup_attributes update_bkp_attrs = { .uuid = &elem->uuid, .version = &elem->version, .url = &elem->url, .username = &elem->username, .password = &elem->password };
|
||||
load_specific_backup_attributes(b, &update_bkp_attrs);
|
||||
} else if (strcmp(element, "install") == 0) {
|
||||
} else if (CWMP_STRCMP(element, "install") == 0) {
|
||||
elem = (operations *)calloc(1, sizeof(operations));
|
||||
elem->type = DU_INSTALL;
|
||||
list_add_tail(&(elem->list), &(change_du_state_request->list_operation));
|
||||
|
||||
struct backup_attributes install_bkp_attrs = { .uuid = &elem->uuid, .executionenvref = &elem->executionenvref, .url = &elem->url, .username = &elem->username, .password = &elem->password };
|
||||
load_specific_backup_attributes(b, &install_bkp_attrs);
|
||||
} else if (strcmp(element, "uninstall") == 0) {
|
||||
} else if (CWMP_STRCMP(element, "uninstall") == 0) {
|
||||
elem = (operations *)calloc(1, sizeof(operations));
|
||||
elem->type = DU_UNINSTALL;
|
||||
list_add_tail(&(elem->list), &(change_du_state_request->list_operation));
|
||||
|
|
@ -1023,7 +1020,7 @@ void load_du_state_change_complete(mxml_node_t *tree, struct cwmp *cwmp)
|
|||
|
||||
while (b) {
|
||||
if (mxmlGetType(b) == MXML_ELEMENT) {
|
||||
if (strcmp(mxmlGetElement(b), "opresult") == 0) {
|
||||
if (CWMP_STRCMP(mxmlGetElement(b), "opresult") == 0) {
|
||||
elem = (opresult *)calloc(1, sizeof(opresult));
|
||||
list_add_tail(&(elem->list), &(du_state_change_complete_request->list_opresult));
|
||||
|
||||
|
|
@ -1123,47 +1120,47 @@ int cwmp_load_saved_session(struct cwmp *cwmp, char **ret, enum backup_loading l
|
|||
mxml_type_t ntype = mxmlGetType(b);
|
||||
const char *elem_name = mxmlGetElement(b);
|
||||
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");
|
||||
break;
|
||||
}
|
||||
}
|
||||
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");
|
||||
break;
|
||||
}
|
||||
}
|
||||
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");
|
||||
break;
|
||||
}
|
||||
}
|
||||
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");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (load == ALL) {
|
||||
if (ntype == MXML_ELEMENT && strcmp(elem_name, "queue_event") == 0) {
|
||||
if (ntype == MXML_ELEMENT && CWMP_STRCMP(elem_name, "queue_event") == 0) {
|
||||
load_queue_event(b, cwmp);
|
||||
} else if (ntype == MXML_ELEMENT && strcmp(elem_name, "download") == 0) {
|
||||
} else if (ntype == MXML_ELEMENT && CWMP_STRCMP(elem_name, "download") == 0) {
|
||||
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);
|
||||
} 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, cwmp);
|
||||
} 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);
|
||||
} 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);
|
||||
} 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, cwmp);
|
||||
} 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);
|
||||
} else if (ntype == MXML_ELEMENT && strcmp(elem_name, "apply_schedule_download") == 0) {
|
||||
} else if (ntype == MXML_ELEMENT && CWMP_STRCMP(elem_name, "apply_schedule_download") == 0) {
|
||||
load_apply_schedule_download(b);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
63
common.c
63
common.c
|
|
@ -145,11 +145,11 @@ void add_dm_parameter_to_list(struct list_head *head, char *param_name, char *pa
|
|||
list_for_each (ilist, head) {
|
||||
int cmp;
|
||||
dm_parameter = list_entry(ilist, struct cwmp_dm_parameter, list);
|
||||
cmp = strcmp(dm_parameter->name, param_name);
|
||||
cmp = CWMP_STRCMP(dm_parameter->name, param_name);
|
||||
if (cmp == 0) {
|
||||
if (param_val && strcmp(dm_parameter->value, param_val) != 0) {
|
||||
if (CWMP_STRCMP(dm_parameter->value, param_val) != 0) {
|
||||
free(dm_parameter->value);
|
||||
dm_parameter->value = strdup(param_val);
|
||||
dm_parameter->value = CWMP_STRDUP(param_val);
|
||||
}
|
||||
dm_parameter->notification = notification;
|
||||
return;
|
||||
|
|
@ -159,12 +159,10 @@ void add_dm_parameter_to_list(struct list_head *head, char *param_name, char *pa
|
|||
}
|
||||
dm_parameter = calloc(1, sizeof(struct cwmp_dm_parameter));
|
||||
_list_add(&dm_parameter->list, ilist->prev, ilist);
|
||||
if (param_name)
|
||||
dm_parameter->name = strdup(param_name);
|
||||
if (param_val)
|
||||
dm_parameter->value = strdup(param_val);
|
||||
dm_parameter->name = CWMP_STRDUP(param_name);
|
||||
dm_parameter->value = CWMP_STRDUP(param_val);
|
||||
|
||||
dm_parameter->type = strdup(param_type ? param_type : "xsd:string");
|
||||
dm_parameter->type = CWMP_STRDUP_DEF(param_type, "xsd:string");
|
||||
dm_parameter->notification = notification;
|
||||
dm_parameter->writable = writable;
|
||||
}
|
||||
|
|
@ -198,7 +196,7 @@ void cwmp_add_list_fault_param(char *param, int fault, struct list_head *list_se
|
|||
|
||||
param_fault = calloc(1, sizeof(struct cwmp_param_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;
|
||||
}
|
||||
|
||||
|
|
@ -233,9 +231,14 @@ int cwmp_asprintf(char **s, const char *format, ...)
|
|||
}
|
||||
va_end(argcopy);
|
||||
str = (char *)calloc(sizeof(char), size + 1);
|
||||
if (str == NULL) {
|
||||
va_end(arg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
vsnprintf(str, size + 1, format, arg);
|
||||
va_end(arg);
|
||||
*s = strdup(str);
|
||||
*s = CWMP_STRDUP(str);
|
||||
FREE(str);
|
||||
if (*s == NULL) {
|
||||
return -1;
|
||||
|
|
@ -266,7 +269,7 @@ void get_firewall_zone_name_by_wan_iface(char *if_wan, char **zone_name)
|
|||
cwmp_uci_get_value_by_section_string(s, "network", &network);
|
||||
char *net = strtok(network, " ");
|
||||
while (net != NULL) {
|
||||
if (strcmp(net, if_wan) == 0) {
|
||||
if (CWMP_STRCMP(net, if_wan) == 0) {
|
||||
cwmp_uci_get_value_by_section_string(s, "name", zone_name);
|
||||
icwmp_free(network);
|
||||
return;
|
||||
|
|
@ -433,7 +436,7 @@ int cwmp_get_fault_code_by_string(char *fault_code)
|
|||
int 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;
|
||||
}
|
||||
|
||||
|
|
@ -484,6 +487,9 @@ void *icwmp_realloc(void *n, size_t size)
|
|||
|
||||
char *icwmp_strdup(const char *s)
|
||||
{
|
||||
if (s == NULL)
|
||||
return NULL;
|
||||
|
||||
size_t len = strlen(s) + 1;
|
||||
void *new = icwmp_malloc(len);
|
||||
if (new == NULL)
|
||||
|
|
@ -553,7 +559,7 @@ int icwmp_add_service(char *service)
|
|||
{
|
||||
if (nbre_services >= MAX_NBRE_SERVICES)
|
||||
return -1;
|
||||
list_services[nbre_services++] = strdup(service);
|
||||
list_services[nbre_services++] = CWMP_STRDUP(service);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -583,7 +589,7 @@ void icwmp_restart_services()
|
|||
|
||||
blob_buf_free(&b);
|
||||
|
||||
if (strcmp(list_services[i], "firewall") == 0) {
|
||||
if (CWMP_STRCMP(list_services[i], "firewall") == 0) {
|
||||
g_firewall_restart = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -600,7 +606,7 @@ void icwmp_restart_services()
|
|||
*/
|
||||
bool icwmp_validate_string_length(char *arg, int max_length)
|
||||
{
|
||||
if (arg != NULL && strlen(arg) > (size_t)max_length)
|
||||
if (CWMP_STRLEN(arg) > (size_t)max_length)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -657,7 +663,7 @@ char *string_to_hex(const unsigned char *str, size_t size)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (size == 0) {
|
||||
if (size == 0 || str == NULL) {
|
||||
return hex;
|
||||
}
|
||||
|
||||
|
|
@ -671,6 +677,12 @@ int copy_file(char *source_file, char *target_file)
|
|||
{
|
||||
char ch;
|
||||
FILE *source, *target;
|
||||
|
||||
if (source_file == NULL || target_file == NULL) {
|
||||
CWMP_LOG(ERROR, "file path not mentioned");
|
||||
return -1;
|
||||
}
|
||||
|
||||
source = fopen(source_file, "r");
|
||||
if (source == NULL) {
|
||||
CWMP_LOG(ERROR, "Not able to open the source file: %s\n", source_file);
|
||||
|
|
@ -707,7 +719,7 @@ void ubus_network_interface_callback(struct ubus_request *req __attribute__((unu
|
|||
|
||||
// Only update the interface if its not empty
|
||||
if (CWMP_STRLEN(l3_device)) {
|
||||
cwmp_main.conf.interface = strdup(l3_device);
|
||||
cwmp_main.conf.interface = CWMP_STRDUP(l3_device);
|
||||
}
|
||||
|
||||
CWMP_LOG(DEBUG, "CWMP IFACE - interface: %s", cwmp_main.conf.interface);
|
||||
|
|
@ -764,7 +776,7 @@ bool is_obj_excluded(const char *object_name)
|
|||
unsigned int i = 0;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(Obj_Excluded); i++) {
|
||||
if (strncmp(Obj_Excluded[i], object_name, strlen(Obj_Excluded[i])) == 0)
|
||||
if (CWMP_STRNCMP(Obj_Excluded[i], object_name, CWMP_STRLEN(Obj_Excluded[i])) == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -786,16 +798,13 @@ time_t convert_datetime_to_timestamp(char *value)
|
|||
return mktime(&tm);
|
||||
}
|
||||
|
||||
bool uci_str_to_bool(char *value)
|
||||
bool cwmp_str_to_bool(char *value)
|
||||
{
|
||||
if (!value)
|
||||
return false;
|
||||
|
||||
if (strncasecmp(value, "true", 4) == 0 ||
|
||||
value[0] == '1' ||
|
||||
strncasecmp(value, "on", 2) == 0 ||
|
||||
strncasecmp(value, "yes", 3) == 0 ||
|
||||
strncasecmp(value, "enable", 6) == 0)
|
||||
if (CWMP_STRNCASECMP(value, "true", 4) == 0 ||
|
||||
(value != NULL && value[0] == '1') ||
|
||||
CWMP_STRNCASECMP(value, "on", 2) == 0 ||
|
||||
CWMP_STRNCASECMP(value, "yes", 3) == 0 ||
|
||||
CWMP_STRNCASECMP(value, "enable", 6) == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
|
|
|||
44
config.c
44
config.c
|
|
@ -45,7 +45,7 @@ void get_dhcp_vend_info_cb(struct ubus_request *req, int type __attribute__((unu
|
|||
};
|
||||
|
||||
blobmsg_for_each_attr(param, msg, rem) {
|
||||
if (strcmp(blobmsg_name(param), "data") == 0) {
|
||||
if (CWMP_STRCMP(blobmsg_name(param), "data") == 0) {
|
||||
struct blob_attr *tb[__E_MAX] = {NULL};
|
||||
if (blobmsg_parse(p, __E_MAX, tb, blobmsg_data(param), blobmsg_len(param)) != 0) {
|
||||
return;
|
||||
|
|
@ -53,7 +53,7 @@ void get_dhcp_vend_info_cb(struct ubus_request *req, int type __attribute__((unu
|
|||
|
||||
if (tb[E_VENDOR_INFO]) {
|
||||
char *info = blobmsg_get_string(tb[E_VENDOR_INFO]);
|
||||
int len = strlen(info) + 1;
|
||||
int len = CWMP_STRLEN(info) + 1;
|
||||
*v_info = (char *)malloc(len);
|
||||
if (*v_info == NULL)
|
||||
return;
|
||||
|
|
@ -82,7 +82,7 @@ bool configure_dhcp_options(char *vendspecinf)
|
|||
memset(vend_info, 0, len);
|
||||
snprintf(vend_info, len, "%s", vendspecinf);
|
||||
|
||||
if (strncmp(vend_info, "http://", 7) == 0 || strncmp(vend_info, "https://", 8) == 0) {
|
||||
if (CWMP_STRNCMP(vend_info, "http://", 7) == 0 || CWMP_STRNCMP(vend_info, "https://", 8) == 0) {
|
||||
uci_set_value_by_path(UCI_DHCP_ACS_URL, vend_info, UCI_STANDARD_CONFIG);
|
||||
CWMP_LOG(DEBUG, "dhcp url: %s", vend_info);
|
||||
cwmp_commit_package("cwmp", UCI_STANDARD_CONFIG);
|
||||
|
|
@ -93,7 +93,7 @@ bool configure_dhcp_options(char *vendspecinf)
|
|||
bool update_uci = false;
|
||||
char *temp = strtok(vend_info, " ");
|
||||
while (temp) {
|
||||
if (strncmp(temp, "1=", 2) == 0) {
|
||||
if (CWMP_STRNCMP(temp, "1=", 2) == 0) {
|
||||
char *pos = temp + 2;
|
||||
if (CWMP_STRLEN(pos)) {
|
||||
uci_set_value_by_path(UCI_DHCP_ACS_URL, pos, UCI_STANDARD_CONFIG);
|
||||
|
|
@ -102,7 +102,7 @@ bool configure_dhcp_options(char *vendspecinf)
|
|||
}
|
||||
}
|
||||
|
||||
if (strncmp(temp, "2=", 2) == 0) {
|
||||
if (CWMP_STRNCMP(temp, "2=", 2) == 0) {
|
||||
char *pos = temp + 2;
|
||||
if (CWMP_STRLEN(pos)) {
|
||||
uci_set_value_by_path(UCI_DHCP_CPE_PROV_CODE, pos, UCI_STANDARD_CONFIG);
|
||||
|
|
@ -110,7 +110,7 @@ bool configure_dhcp_options(char *vendspecinf)
|
|||
}
|
||||
}
|
||||
|
||||
if (strncmp(temp, "3=", 2) == 0) {
|
||||
if (CWMP_STRNCMP(temp, "3=", 2) == 0) {
|
||||
char *pos = temp + 2;
|
||||
if (CWMP_STRLEN(pos)) {
|
||||
uci_set_value_by_path(UCI_DHCP_ACS_RETRY_MIN_WAIT_INTERVAL, pos, UCI_STANDARD_CONFIG);
|
||||
|
|
@ -118,7 +118,7 @@ bool configure_dhcp_options(char *vendspecinf)
|
|||
}
|
||||
}
|
||||
|
||||
if (strncmp(temp, "4=", 2) == 0) {
|
||||
if (CWMP_STRNCMP(temp, "4=", 2) == 0) {
|
||||
char *pos = temp + 2;
|
||||
if (CWMP_STRLEN(pos)) {
|
||||
uci_set_value_by_path(UCI_DHCP_ACS_RETRY_INTERVAL_MULTIPLIER, pos, UCI_STANDARD_CONFIG);
|
||||
|
|
@ -254,16 +254,16 @@ static void config_get_acs_elements(struct config *conf, struct uci_section *s)
|
|||
memset(acs_tb, 0, sizeof(acs_tb));
|
||||
uci_parse_section(s, acs_opts, __MAX_NUM_UCI_ACS_ATTRS, acs_tb);
|
||||
|
||||
conf->ipv6_enable = uci_str_to_bool(get_value_from_uci_option(acs_tb[UCI_ACS_IPV6_ENABLE]));
|
||||
conf->ipv6_enable = cwmp_str_to_bool(get_value_from_uci_option(acs_tb[UCI_ACS_IPV6_ENABLE]));
|
||||
CWMP_LOG(DEBUG, "CWMP CONFIG - ipv6 enable: %d", conf->ipv6_enable);
|
||||
|
||||
conf->acs_ssl_capath = CWMP_STRDUP(get_value_from_uci_option(acs_tb[UCI_ACS_SSL_CAPATH]));
|
||||
CWMP_LOG(DEBUG, "CWMP CONFIG - acs ssl cpath: %s", conf->acs_ssl_capath ? conf->acs_ssl_capath : "");
|
||||
|
||||
conf->http_disable_100continue = uci_str_to_bool(get_value_from_uci_option(acs_tb[HTTP_DISABLE_100CONTINUE]));
|
||||
conf->http_disable_100continue = cwmp_str_to_bool(get_value_from_uci_option(acs_tb[HTTP_DISABLE_100CONTINUE]));
|
||||
CWMP_LOG(DEBUG, "CWMP CONFIG - http disable 100continue: %d", conf->http_disable_100continue);
|
||||
|
||||
conf->insecure_enable = uci_str_to_bool(get_value_from_uci_option(acs_tb[UCI_ACS_INSECURE_ENABLE]));
|
||||
conf->insecure_enable = cwmp_str_to_bool(get_value_from_uci_option(acs_tb[UCI_ACS_INSECURE_ENABLE]));
|
||||
CWMP_LOG(DEBUG, "CWMP CONFIG - acs insecure enable: %d", conf->insecure_enable);
|
||||
}
|
||||
|
||||
|
|
@ -284,9 +284,9 @@ int get_preinit_config(struct config *conf)
|
|||
|
||||
uci_foreach_element(&pkg->sections, e) {
|
||||
struct uci_section *s = uci_to_section(e);
|
||||
if (strcmp(s->type, "acs") == 0) {
|
||||
if (CWMP_STRCMP(s->type, "acs") == 0) {
|
||||
config_get_acs_elements(conf, s);
|
||||
} else if (strcmp(s->type, "cpe") == 0) {
|
||||
} else if (CWMP_STRCMP(s->type, "cpe") == 0) {
|
||||
config_get_cpe_elements(conf, s);
|
||||
}
|
||||
}
|
||||
|
|
@ -312,7 +312,7 @@ int get_global_config(struct config *conf)
|
|||
char *value = NULL, *value2 = NULL, *value3 = NULL;
|
||||
|
||||
if ((error = uci_get_value(UCI_CPE_CWMP_ENABLE, &value)) == CWMP_OK) {
|
||||
if (value != NULL && uci_str_to_bool(value) == false) {
|
||||
if (value != NULL && cwmp_str_to_bool(value) == false) {
|
||||
FREE(value);
|
||||
CWMP_LOG(ERROR, "CWMP service is disabled");
|
||||
exit(0);
|
||||
|
|
@ -331,7 +331,7 @@ int get_global_config(struct config *conf)
|
|||
|
||||
// now read the vendor info from ifstatus before reading the DHCP_ACS_URL from uci
|
||||
if (error == CWMP_OK && value != NULL) {
|
||||
discovery_enable = uci_str_to_bool(value);
|
||||
discovery_enable = cwmp_str_to_bool(value);
|
||||
if (discovery_enable == true && conf->default_wan_iface != NULL) {
|
||||
get_dhcp_vendor_info(conf->default_wan_iface);
|
||||
}
|
||||
|
|
@ -373,10 +373,10 @@ int get_global_config(struct config *conf)
|
|||
|
||||
if ((error = uci_get_value(UCI_ACS_COMPRESSION, &value)) == CWMP_OK) {
|
||||
conf->compression = COMP_NONE;
|
||||
if (conf->amd_version >= AMD_5 && value != NULL) {
|
||||
if (0 == strcasecmp(value, "gzip")) {
|
||||
if (conf->amd_version >= AMD_5) {
|
||||
if (0 == CWMP_STRCASECMP(value, "gzip")) {
|
||||
conf->compression = COMP_GZIP;
|
||||
} else if (0 == strcasecmp(value, "deflate")) {
|
||||
} else if (0 == CWMP_STRCASECMP(value, "deflate")) {
|
||||
conf->compression = COMP_DEFLATE;
|
||||
} else {
|
||||
conf->compression = COMP_NONE;
|
||||
|
|
@ -484,7 +484,7 @@ int get_global_config(struct config *conf)
|
|||
if ((error = uci_get_value(UCI_CPE_NOTIFY_PERIODIC_ENABLE, &value)) == CWMP_OK) {
|
||||
bool a = true;
|
||||
if (value != NULL) {
|
||||
a = uci_str_to_bool(value);
|
||||
a = cwmp_str_to_bool(value);
|
||||
FREE(value);
|
||||
}
|
||||
conf->periodic_notify_enable = a;
|
||||
|
|
@ -546,7 +546,7 @@ int get_global_config(struct config *conf)
|
|||
}
|
||||
|
||||
if ((error = uci_get_value(UCI_PERIODIC_INFORM_ENABLE_PATH, &value)) == CWMP_OK) {
|
||||
conf->periodic_enable = uci_str_to_bool(value);
|
||||
conf->periodic_enable = cwmp_str_to_bool(value);
|
||||
FREE(value);
|
||||
} else {
|
||||
return error;
|
||||
|
|
@ -554,7 +554,7 @@ int get_global_config(struct config *conf)
|
|||
|
||||
if ((error = uci_get_value(UCI_CPE_INSTANCE_MODE, &value)) == CWMP_OK) {
|
||||
if (value != NULL) {
|
||||
if (0 == strcmp(value, "InstanceNumber")) {
|
||||
if (0 == CWMP_STRCMP(value, "InstanceNumber")) {
|
||||
conf->instance_mode = INSTANCE_MODE_NUMBER;
|
||||
} else {
|
||||
conf->instance_mode = INSTANCE_MODE_ALIAS;
|
||||
|
|
@ -581,7 +581,7 @@ int get_global_config(struct config *conf)
|
|||
}
|
||||
|
||||
if ((error = uci_get_value(LW_NOTIFICATION_ENABLE, &value)) == CWMP_OK) {
|
||||
conf->lw_notification_enable = uci_str_to_bool(value);
|
||||
conf->lw_notification_enable = cwmp_str_to_bool(value);
|
||||
FREE(value);
|
||||
} else {
|
||||
return error;
|
||||
|
|
@ -664,7 +664,7 @@ int get_global_config(struct config *conf)
|
|||
}
|
||||
|
||||
if ((error = uci_get_value(UCI_ACS_HEARTBEAT_ENABLE, &value)) == CWMP_OK) {
|
||||
conf->heart_beat_enable = uci_str_to_bool(value);
|
||||
conf->heart_beat_enable = cwmp_str_to_bool(value);
|
||||
FREE(value);
|
||||
} else {
|
||||
return error;
|
||||
|
|
|
|||
36
cwmp.c
36
cwmp.c
|
|
@ -91,10 +91,7 @@ static bool interface_reset_req(char *param_name, char *value)
|
|||
if (ret != 0)
|
||||
return false;
|
||||
|
||||
if (strcmp(value, "1") != 0 && strcmp(value, "true") != 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return cwmp_str_to_bool(value);
|
||||
}
|
||||
|
||||
void set_interface_reset_request(char *param_name, char *value)
|
||||
|
|
@ -205,7 +202,7 @@ void check_firewall_restart_state()
|
|||
if (get_firewall_restart_state(&state) != CWMP_OK)
|
||||
break;
|
||||
|
||||
if (state != NULL && strcmp(state, "init") == 0) {
|
||||
if (CWMP_STRCMP(state, "init") == 0) {
|
||||
init = true;
|
||||
FREE(state);
|
||||
break;
|
||||
|
|
@ -501,7 +498,7 @@ static void cwmp_schedule_session(struct cwmp *cwmp)
|
|||
CWMP_LOG(INFO, "Start session");
|
||||
|
||||
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_uci_set_value("cwmp", "cpe", "exec_download", "0");
|
||||
cwmp_commit_package("cwmp", UCI_STANDARD_CONFIG);
|
||||
|
|
@ -638,10 +635,17 @@ void load_forced_inform_json_file(struct cwmp *cwmp)
|
|||
|
||||
blobmsg_for_each_attr(cur, custom_forced_inform_list, rem)
|
||||
{
|
||||
char parameter_path[128];
|
||||
char parameter_path[128] = {0};
|
||||
char *val = NULL;
|
||||
snprintf(parameter_path, sizeof(parameter_path), "%s", blobmsg_get_string(cur));
|
||||
if (parameter_path[strlen(parameter_path)-1] == '.') {
|
||||
|
||||
int len = CWMP_STRLEN(parameter_path);
|
||||
if (len == 0) {
|
||||
CWMP_LOG(WARNING, "parameter path is empty so rejected ad inform parameter");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (parameter_path[len - 1] == '.') {
|
||||
CWMP_LOG(WARNING, "%s is rejected as inform parameter. Only leaf parameters are allowed.", parameter_path);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -650,7 +654,7 @@ void load_forced_inform_json_file(struct cwmp *cwmp)
|
|||
CWMP_LOG(WARNING, "%s is rejected as inform parameter. Wrong parameter path.", parameter_path);
|
||||
continue;
|
||||
}
|
||||
custom_forced_inform_parameters[nbre_custom_inform++] = strdup(parameter_path);
|
||||
custom_forced_inform_parameters[nbre_custom_inform++] = CWMP_STRDUP(parameter_path);
|
||||
FREE(val);
|
||||
}
|
||||
blob_buf_free(&bbuf);
|
||||
|
|
@ -694,7 +698,13 @@ void load_boot_inform_json_file(struct cwmp *cwmp)
|
|||
char *val = NULL;
|
||||
|
||||
snprintf(parameter_path, sizeof(parameter_path), "%s", blobmsg_get_string(cur));
|
||||
if (parameter_path[strlen(parameter_path)-1] == '.') {
|
||||
int len = CWMP_STRLEN(parameter_path);
|
||||
if (len == 0) {
|
||||
CWMP_LOG(WARNING, "parameter path is empty so rejected ad inform parameter");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (parameter_path[len - 1] == '.') {
|
||||
CWMP_LOG(WARNING, "%s is rejected as inform parameter. Only leaf parameters are allowed.", parameter_path);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -703,7 +713,7 @@ void load_boot_inform_json_file(struct cwmp *cwmp)
|
|||
CWMP_LOG(WARNING, "%s is rejected as inform parameter. Wrong parameter path.", parameter_path);
|
||||
continue;
|
||||
}
|
||||
boot_inform_parameters[nbre_boot_inform++] = strdup(parameter_path);
|
||||
boot_inform_parameters[nbre_boot_inform++] = CWMP_STRDUP(parameter_path);
|
||||
FREE(val);
|
||||
}
|
||||
blob_buf_free(&bbuf);
|
||||
|
|
@ -757,7 +767,7 @@ static void lookup_event_cb(struct ubus_context *ctx __attribute__((unused)),
|
|||
struct blob_attr *attr;
|
||||
const char *path;
|
||||
|
||||
if (strcmp(type, "ubus.object.add") != 0)
|
||||
if (CWMP_STRCMP(type, "ubus.object.add") != 0)
|
||||
return;
|
||||
|
||||
blobmsg_parse(&policy, 1, &attr, blob_data(msg), blob_len(msg));
|
||||
|
|
@ -765,7 +775,7 @@ static void lookup_event_cb(struct ubus_context *ctx __attribute__((unused)),
|
|||
return;
|
||||
|
||||
path = blobmsg_data(attr);
|
||||
if (strcmp(path, USP_OBJECT_NAME) == 0) {
|
||||
if (CWMP_STRCMP(path, USP_OBJECT_NAME) == 0) {
|
||||
g_usp_object_available = true;
|
||||
uloop_end();
|
||||
}
|
||||
|
|
|
|||
26
cwmp_cli.c
26
cwmp_cli.c
|
|
@ -42,7 +42,7 @@ char *get_fault_message_by_fault_code(char *fault_code)
|
|||
size_t i;
|
||||
size_t faults_array_size = sizeof(faults_array) / sizeof(struct fault_resp);
|
||||
for (i = 0; i < faults_array_size; 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 NULL;
|
||||
|
|
@ -77,7 +77,7 @@ void display_get_cmd_result(struct cmd_input in __attribute__((unused)), union c
|
|||
char *cmd_set_exec_func(struct cmd_input in, union cmd_result *res __attribute__((unused)))
|
||||
{
|
||||
int flag;
|
||||
if (in.first_input == NULL || in.second_input == NULL || strlen(in.first_input) == 0 || strlen(in.second_input) == 0)
|
||||
if (CWMP_STRLEN(in.first_input) == 0 || CWMP_STRLEN(in.second_input) == 0)
|
||||
return "9003";
|
||||
if (transaction_id == 0) {
|
||||
if (!cwmp_transaction_start("cwmp"))
|
||||
|
|
@ -145,7 +145,15 @@ void display_add_cmd_result(struct cmd_input in, union cmd_result res, char *fau
|
|||
fprintf(stderr, "Fault %s: %s\n", fault, get_fault_message_by_fault_code(fault));
|
||||
return;
|
||||
}
|
||||
if (in.first_input[strlen(in.first_input) - 1] == '.')
|
||||
|
||||
int len = CWMP_STRLEN(in.first_input);
|
||||
if (len == 0) {
|
||||
fprintf(stderr, "Fault DM Path is \"\".\n");
|
||||
FREE(res.instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (in.first_input[len - 1] == '.')
|
||||
fprintf(stdout, "Added %s%s.\n", in.first_input, res.instance);
|
||||
else
|
||||
fprintf(stdout, "Added %s.%s.\n", in.first_input, res.instance);
|
||||
|
|
@ -255,7 +263,7 @@ char *cmd_get_names_exec_func(struct cmd_input in, union cmd_result *res)
|
|||
if (in.first_input == NULL)
|
||||
in.first_input = "";
|
||||
res->param_list = ¶meters_list;
|
||||
bool next_level = in.second_input && (strcmp(in.second_input, "1") == 0 || strcasecmp(in.second_input, "true") == 0) ? true : false;
|
||||
bool next_level = cwmp_str_to_bool(in.second_input);
|
||||
char *fault = cwmp_get_parameter_names(in.first_input, next_level, res->param_list);
|
||||
return fault;
|
||||
}
|
||||
|
|
@ -301,11 +309,12 @@ const struct cwmp_cli_command_struct icwmp_commands[] = {
|
|||
|
||||
char* execute_cwmp_cli_command(char *cmd, char *args[])
|
||||
{
|
||||
if (!cmd || strlen(cmd) == 0) {
|
||||
if (CWMP_STRLEN(cmd) == 0) {
|
||||
printf("You must add a command as input: \n\n");
|
||||
goto cli_help;
|
||||
}
|
||||
if (strcmp(cmd, "help") == 0)
|
||||
|
||||
if (CWMP_STRCMP(cmd, "help") == 0)
|
||||
goto cli_help;
|
||||
struct cmd_input cmd_in = { args[0] ? args[0] : NULL, args[0] && args[1] ? args[1] : NULL };
|
||||
union cmd_result cmd_out = { 0 };
|
||||
|
|
@ -314,10 +323,9 @@ char* execute_cwmp_cli_command(char *cmd, char *args[])
|
|||
size_t commands_array_size = sizeof(icwmp_commands) / sizeof(struct cwmp_cli_command_struct);
|
||||
cwmp_uci_init();
|
||||
for (i = 0; i < commands_array_size; 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);
|
||||
if (fault)
|
||||
fault_ret = strdup(fault);
|
||||
fault_ret = CWMP_STRDUP(fault);
|
||||
icwmp_commands[i].display_cmd_result(cmd_in, cmd_out, fault);
|
||||
goto cli_end;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ void ubus_du_state_callback(struct ubus_request *req, int type __attribute__((un
|
|||
if (tb[0] && blobmsg_get_bool(tb[0])) {
|
||||
*fault = NULL;
|
||||
} else {
|
||||
*fault = strdup("9010");
|
||||
*fault = CWMP_STRDUP("9010");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -130,10 +130,10 @@ static char *get_software_module_object_eq(char *param1, char *val1, char *param
|
|||
}
|
||||
|
||||
list_for_each_entry (param_value, sw_parameters, list) {
|
||||
if (regexec(®ex1, param_value->name, 0, NULL, 0) == 0 && 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;
|
||||
|
||||
if (param2 && regexec(®ex2, param_value->name, 0, NULL, 0) == 0 && 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;
|
||||
|
||||
if (softwaremodule_filter_param == false)
|
||||
|
|
@ -142,7 +142,7 @@ static char *get_software_module_object_eq(char *param1, char *val1, char *param
|
|||
snprintf(instance, (size_t)(strchr(param_value->name + strlen("Device.SoftwareModules.DeploymentUnit."), '.') - param_value->name - strlen("Device.SoftwareModules.DeploymentUnit.") + 1), "%s", (char *)(param_value->name + strlen("Device.SoftwareModules.DeploymentUnit.")));
|
||||
break;
|
||||
}
|
||||
return (strlen(instance) > 0) ? strdup(instance) : NULL;
|
||||
return (CWMP_STRLEN(instance) > 0) ? CWMP_STRDUP(instance) : NULL;
|
||||
}
|
||||
|
||||
static int get_deployment_unit_name_version(char *uuid, char **name, char **version, char **env)
|
||||
|
|
@ -158,16 +158,16 @@ static int get_deployment_unit_name_version(char *uuid, char **name, char **vers
|
|||
snprintf(environment_param, sizeof(environment_param), "Device.SoftwareModules.DeploymentUnit.%s.ExecutionEnvRef", sw_by_uuid_instance);
|
||||
struct cwmp_dm_parameter *param_value;
|
||||
list_for_each_entry (param_value, &sw_parameters, list) {
|
||||
if (strcmp(param_value->name, name_param) == 0) {
|
||||
*name = strdup(param_value->value);
|
||||
if (CWMP_STRCMP(param_value->name, name_param) == 0) {
|
||||
*name = CWMP_STRDUP(param_value->value);
|
||||
continue;
|
||||
}
|
||||
if (strcmp(param_value->name, version_param) == 0) {
|
||||
*version = strdup(param_value->value);
|
||||
if (CWMP_STRCMP(param_value->name, version_param) == 0) {
|
||||
*version = CWMP_STRDUP(param_value->value);
|
||||
continue;
|
||||
}
|
||||
if (strcmp(param_value->name, environment_param) == 0) {
|
||||
*env = strdup(param_value->value);
|
||||
if (CWMP_STRCMP(param_value->name, environment_param) == 0) {
|
||||
*env = CWMP_STRDUP(param_value->value);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
@ -216,13 +216,13 @@ static char *get_exec_env_name(char *environment_path)
|
|||
LIST_HEAD(environment_list);
|
||||
char *err = cwmp_get_parameter_values(environment_path, &environment_list);
|
||||
if (err)
|
||||
return strdup("");
|
||||
return CWMP_STRDUP("");
|
||||
|
||||
struct cwmp_dm_parameter *param_value;
|
||||
snprintf(env_param, sizeof(env_param), "%sName", environment_path);
|
||||
list_for_each_entry (param_value, &environment_list, list) {
|
||||
if (strcmp(param_value->name, env_param) == 0) {
|
||||
env_name = strdup(param_value->value);
|
||||
if (CWMP_STRCMP(param_value->name, env_param) == 0) {
|
||||
env_name = CWMP_STRDUP(param_value->value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -235,14 +235,14 @@ static int cwmp_launch_du_install(char *url, char *uuid, char *user, char *pass,
|
|||
int error = FAULT_CPE_NO_FAULT;
|
||||
char *fault_code;
|
||||
|
||||
(*pchange_du_state_complete)->start_time = strdup(get_time(time(NULL)));
|
||||
(*pchange_du_state_complete)->start_time = CWMP_STRDUP(get_time(time(NULL)));
|
||||
cwmp_du_install(url, uuid, user, pass, env_name, env_id, &fault_code);
|
||||
|
||||
if (fault_code != NULL) {
|
||||
if (fault_code[0] == '9') {
|
||||
int 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) {
|
||||
error = i;
|
||||
break;
|
||||
}
|
||||
|
|
@ -258,14 +258,14 @@ static int cwmp_launch_du_update(char *uuid, char *url, char *user, char *pass,
|
|||
int error = FAULT_CPE_NO_FAULT;
|
||||
char *fault_code;
|
||||
|
||||
(*pchange_du_state_complete)->start_time = strdup(get_time(time(NULL)));
|
||||
(*pchange_du_state_complete)->start_time = CWMP_STRDUP(get_time(time(NULL)));
|
||||
|
||||
cwmp_du_update(url, uuid, user, pass, env_name, env_id, &fault_code);
|
||||
if (fault_code != NULL) {
|
||||
if (fault_code[0] == '9') {
|
||||
int 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) {
|
||||
error = i;
|
||||
break;
|
||||
}
|
||||
|
|
@ -281,7 +281,7 @@ static int cwmp_launch_du_uninstall(char *package_name, char *env_name, int env_
|
|||
int error = FAULT_CPE_NO_FAULT;
|
||||
char *fault_code;
|
||||
|
||||
(*pchange_du_state_complete)->start_time = strdup(get_time(time(NULL)));
|
||||
(*pchange_du_state_complete)->start_time = CWMP_STRDUP(get_time(time(NULL)));
|
||||
|
||||
cwmp_du_uninstall(package_name, env_name, env_id, &fault_code);
|
||||
|
||||
|
|
@ -289,7 +289,7 @@ static int cwmp_launch_du_uninstall(char *package_name, char *env_name, int env_
|
|||
if (fault_code[0] == '9') {
|
||||
int 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) {
|
||||
error = i;
|
||||
break;
|
||||
}
|
||||
|
|
@ -351,16 +351,16 @@ void *thread_cwmp_rpc_cpe_change_du_state(void *v)
|
|||
if (pdu_state_change_complete != NULL) {
|
||||
error = FAULT_CPE_DOWNLOAD_FAILURE;
|
||||
INIT_LIST_HEAD(&(pdu_state_change_complete->list_opresult));
|
||||
pdu_state_change_complete->command_key = strdup(pchange_du_state->command_key ? pchange_du_state->command_key : "");
|
||||
pdu_state_change_complete->command_key = CWMP_STRDUP_DEF(pchange_du_state->command_key, "");
|
||||
pdu_state_change_complete->timeout = pchange_du_state->timeout;
|
||||
list_for_each_entry_safe (p, q, &pchange_du_state->list_operation, list) {
|
||||
res = calloc(1, sizeof(struct opresult));
|
||||
list_add_tail(&(res->list), &(pdu_state_change_complete->list_opresult));
|
||||
res->uuid = strdup(p->uuid);
|
||||
res->version = strdup(p->version);
|
||||
res->current_state = strdup("Failed");
|
||||
res->start_time = strdup(get_time(time(NULL)));
|
||||
res->complete_time = strdup(res->start_time);
|
||||
res->uuid = CWMP_STRDUP(p->uuid);
|
||||
res->version = CWMP_STRDUP(p->version);
|
||||
res->current_state = CWMP_STRDUP("Failed");
|
||||
res->start_time = CWMP_STRDUP(get_time(time(NULL)));
|
||||
res->complete_time = CWMP_STRDUP(res->start_time);
|
||||
res->fault = error;
|
||||
}
|
||||
bkp_session_insert_du_state_change_complete(pdu_state_change_complete);
|
||||
|
|
@ -379,12 +379,13 @@ void *thread_cwmp_rpc_cpe_change_du_state(void *v)
|
|||
if (pdu_state_change_complete != NULL) {
|
||||
error = FAULT_CPE_NO_FAULT;
|
||||
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;
|
||||
|
||||
list_for_each_entry_safe (p, q, &pchange_du_state->list_operation, list) {
|
||||
res = calloc(1, sizeof(struct opresult));
|
||||
list_add_tail(&(res->list), &(pdu_state_change_complete->list_opresult));
|
||||
char *end_time = NULL;
|
||||
switch (p->type) {
|
||||
case DU_INSTALL:
|
||||
if (!environment_exists(p->executionenvref)) {
|
||||
|
|
@ -399,19 +400,20 @@ void *thread_cwmp_rpc_cpe_change_du_state(void *v)
|
|||
if (error == FAULT_CPE_NO_FAULT) {
|
||||
du_ref = (package_name && p->executionenvref) ? get_deployment_unit_reference(package_name, p->executionenvref) : NULL;
|
||||
get_du_version(du_ref, &package_version);
|
||||
res->du_ref = strdup("");
|
||||
res->uuid = strdup("");
|
||||
res->current_state = strdup("Installed");
|
||||
res->du_ref = CWMP_STRDUP("");
|
||||
res->uuid = CWMP_STRDUP("");
|
||||
res->current_state = CWMP_STRDUP("Installed");
|
||||
res->resolved = 1;
|
||||
res->version = strdup("");
|
||||
res->version = CWMP_STRDUP("");
|
||||
FREE(du_ref);
|
||||
} else {
|
||||
res->uuid = strdup(p->uuid ? p->uuid : "");
|
||||
res->current_state = strdup("Failed");
|
||||
res->uuid = CWMP_STRDUP_DEF(p->uuid, "");
|
||||
res->current_state = CWMP_STRDUP("Failed");
|
||||
res->resolved = 0;
|
||||
}
|
||||
|
||||
res->complete_time = strdup(get_time(time(NULL)));
|
||||
end_time = get_time(time(NULL));
|
||||
res->complete_time = CWMP_STRDUP(end_time);
|
||||
res->fault = error;
|
||||
break;
|
||||
|
||||
|
|
@ -431,20 +433,21 @@ void *thread_cwmp_rpc_cpe_change_du_state(void *v)
|
|||
snprintf(execenv, 40, "Device.SoftwareModules.ExecEnv.%s.", du_ref);
|
||||
error = cwmp_launch_du_update(p->uuid, p->url, p->username, p->password, get_exec_env_name(execenv), get_exec_env_id(execenv), &res);
|
||||
|
||||
res->uuid = strdup(p->uuid ? p->uuid : "");
|
||||
res->uuid = CWMP_STRDUP_DEF(p->uuid, "");
|
||||
|
||||
if (error == FAULT_CPE_NO_FAULT) {
|
||||
res->current_state = strdup("Installed");
|
||||
res->current_state = CWMP_STRDUP("Installed");
|
||||
res->resolved = 1;
|
||||
} else {
|
||||
res->current_state = strdup("Failed");
|
||||
res->current_state = CWMP_STRDUP("Failed");
|
||||
res->resolved = 0;
|
||||
}
|
||||
|
||||
get_du_version(du_ref, &package_version);
|
||||
res->version = strdup(package_version ? package_version : "");
|
||||
res->du_ref = strdup(du_ref ? du_ref : "");
|
||||
res->complete_time = strdup(get_time(time(NULL)));
|
||||
res->version = CWMP_STRDUP_DEF(package_version, "");
|
||||
res->du_ref = CWMP_STRDUP_DEF(du_ref, "");
|
||||
end_time = get_time(time(NULL));
|
||||
res->complete_time = CWMP_STRDUP(end_time);
|
||||
res->fault = error;
|
||||
FREE(du_ref);
|
||||
break;
|
||||
|
|
@ -464,17 +467,18 @@ void *thread_cwmp_rpc_cpe_change_du_state(void *v)
|
|||
get_du_version(du_ref, &package_version);
|
||||
error = cwmp_launch_du_uninstall(package_name, get_exec_env_name(package_env), get_exec_env_id(package_env), &res);
|
||||
if (error == FAULT_CPE_NO_FAULT) {
|
||||
res->current_state = strdup("Uninstalled");
|
||||
res->current_state = CWMP_STRDUP("Uninstalled");
|
||||
res->resolved = 1;
|
||||
} else {
|
||||
res->current_state = strdup("Installed");
|
||||
res->current_state = CWMP_STRDUP("Installed");
|
||||
res->resolved = 0;
|
||||
}
|
||||
|
||||
res->du_ref = strdup(du_ref ? du_ref : "");
|
||||
res->uuid = strdup(p->uuid);
|
||||
res->version = strdup(package_version);
|
||||
res->complete_time = strdup(get_time(time(NULL)));
|
||||
res->du_ref = CWMP_STRDUP_DEF(du_ref, "");
|
||||
res->uuid = CWMP_STRDUP(p->uuid);
|
||||
res->version = CWMP_STRDUP(package_version);
|
||||
end_time = get_time(time(NULL));
|
||||
res->complete_time = CWMP_STRDUP(end_time);
|
||||
res->fault = error;
|
||||
FREE(du_ref);
|
||||
FREE(package_name);
|
||||
|
|
|
|||
43
cwmp_uci.c
43
cwmp_uci.c
|
|
@ -175,11 +175,20 @@ int cwmp_uci_get_option_value_string(char *package, char *section, char *option,
|
|||
int cwmp_uci_get_value_by_path(char *path, uci_config_paths uci_type, char **value)
|
||||
{
|
||||
struct uci_ptr ptr;
|
||||
char *s;
|
||||
|
||||
*value = NULL;
|
||||
|
||||
s = strdup(path);
|
||||
if (CWMP_STRLEN(path) == 0) {
|
||||
CWMP_LOG(DEBUG, "uci get with empty path");
|
||||
return UCI_OK;
|
||||
}
|
||||
|
||||
char *s = CWMP_STRDUP(path);
|
||||
if (s == NULL) {
|
||||
CWMP_LOG(DEBUG, "uci get failed, memory faiure");
|
||||
return UCI_OK;
|
||||
}
|
||||
|
||||
if (uci_lookup_ptr(uci_save_conf_paths[uci_type].uci_ctx, &ptr, s, true) != UCI_OK) {
|
||||
CWMP_LOG(ERROR, "Error occurred in uci get %s", path);
|
||||
free(s);
|
||||
|
|
@ -191,7 +200,7 @@ int cwmp_uci_get_value_by_path(char *path, uci_config_paths uci_type, char **val
|
|||
CWMP_LOG(INFO, "%s not found or empty value", path);
|
||||
return UCI_OK;
|
||||
}
|
||||
*value = strdup(ptr.o->v.string);
|
||||
*value = CWMP_STRDUP(ptr.o->v.string);
|
||||
}
|
||||
return UCI_OK;
|
||||
}
|
||||
|
|
@ -222,7 +231,7 @@ int cwmp_uci_get_value_by_section_string(struct uci_section *s, char *option, ch
|
|||
uci_foreach_element(&s->options, e)
|
||||
{
|
||||
o = (uci_to_option(e));
|
||||
if (!strcmp(o->e.name, option)) {
|
||||
if (!CWMP_STRCMP(o->e.name, option)) {
|
||||
if (o->type == UCI_TYPE_LIST) {
|
||||
*value = cwmp_uci_list_to_string(&o->v.list, " ");
|
||||
} else {
|
||||
|
|
@ -253,7 +262,7 @@ int cwmp_uci_get_value_by_section_list(struct uci_section *s, char *option, stru
|
|||
uci_foreach_element(&s->options, e)
|
||||
{
|
||||
o = (uci_to_option(e));
|
||||
if (strcmp(o->e.name, option) == 0) {
|
||||
if (CWMP_STRCMP(o->e.name, option) == 0) {
|
||||
switch (o->type) {
|
||||
case UCI_TYPE_LIST:
|
||||
*value = &o->v.list;
|
||||
|
|
@ -428,12 +437,21 @@ int cwmp_uci_get_option_value_list(char *package, char *section, char *option, u
|
|||
option_type = UCI_TYPE_LIST;
|
||||
break;
|
||||
case UCI_TYPE_STRING:
|
||||
if (!ptr.o->v.string || (ptr.o->v.string)[0] == '\0') {
|
||||
if (CWMP_STRLEN(ptr.o->v.string) == 0) {
|
||||
return UCI_TYPE_STRING;
|
||||
}
|
||||
list = calloc(1, sizeof(struct uci_list));
|
||||
if (list == NULL) {
|
||||
return UCI_TYPE_STRING;
|
||||
}
|
||||
|
||||
cwmp_uci_list_init(list);
|
||||
dup = strdup(ptr.o->v.string);
|
||||
dup = CWMP_STRDUP(ptr.o->v.string);
|
||||
if (dup == NULL) {
|
||||
free(list);
|
||||
return UCI_TYPE_STRING;
|
||||
}
|
||||
|
||||
pch = strtok_r(dup, " ", &spch);
|
||||
while (pch != NULL) {
|
||||
e = calloc(1, sizeof(struct uci_element));
|
||||
|
|
@ -545,7 +563,8 @@ struct uci_section* get_section_by_section_name(char *package, char *stype, char
|
|||
{
|
||||
struct uci_section *s;
|
||||
cwmp_uci_foreach_sections(package, stype, uci_type, s) {
|
||||
if (strcmp(section_name(s), sname) == 0)
|
||||
char *s_name = section_name(s);
|
||||
if (CWMP_STRCMP(s_name, sname) == 0)
|
||||
return s;
|
||||
}
|
||||
return NULL;
|
||||
|
|
@ -635,13 +654,13 @@ struct uci_section *cwmp_uci_walk_section(char *package, char *stype, void *arg1
|
|||
|
||||
while (&e->list != list_section) {
|
||||
s = uci_to_section(e);
|
||||
if (s && s->type && strcmp(s->type, stype) == 0) {
|
||||
if (s && CWMP_STRCMP(s->type, stype) == 0) {
|
||||
switch (cmp) {
|
||||
case CWMP_CMP_SECTION:
|
||||
goto end;
|
||||
case CWMP_CMP_OPTION_EQUAL:
|
||||
cwmp_uci_get_value_by_section_string(s, (char *)arg1, &value);
|
||||
if (strcmp(value, (char *)arg2) == 0)
|
||||
if (CWMP_STRCMP(value, (char *)arg2) == 0)
|
||||
goto end;
|
||||
break;
|
||||
case CWMP_CMP_OPTION_CONTAINING:
|
||||
|
|
@ -654,7 +673,7 @@ struct uci_section *cwmp_uci_walk_section(char *package, char *stype, void *arg1
|
|||
snprintf(dup, sizeof(dup), "%s", value);
|
||||
pch = strtok_r(dup, " ", &spch);
|
||||
while (pch != NULL) {
|
||||
if (strcmp((char *)arg2, pch) == 0)
|
||||
if (CWMP_STRCMP((char *)arg2, pch) == 0)
|
||||
goto end;
|
||||
|
||||
pch = strtok_r(NULL, " ", &spch);
|
||||
|
|
@ -665,7 +684,7 @@ struct uci_section *cwmp_uci_walk_section(char *package, char *stype, void *arg1
|
|||
if (list_value != NULL) {
|
||||
uci_foreach_element(list_value, m)
|
||||
{
|
||||
if (strcmp(m->name, (char *)arg2) == 0)
|
||||
if (CWMP_STRCMP(m->name, (char *)arg2) == 0)
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ int zlib_compress(char *message, unsigned char **zmsg, int *zlen, int type)
|
|||
if (strm_init(&strm, type))
|
||||
return -1;
|
||||
strm.next_in = (unsigned char *)message;
|
||||
strm.avail_in = strlen(message);
|
||||
strm.avail_in = CWMP_STRLEN(message);
|
||||
do {
|
||||
int have;
|
||||
strm.avail_out = CHUNK;
|
||||
|
|
|
|||
|
|
@ -98,11 +98,11 @@ int get_parameters_list_from_parameters_blob_array(struct blob_attr *parameters,
|
|||
continue;
|
||||
int notification = 0;
|
||||
bool writable = 0;
|
||||
if (tb[1] && strncmp(blobmsg_get_string(tb[1]), "1", 1) == 0)
|
||||
if (tb[1] && CWMP_STRNCMP(blobmsg_get_string(tb[1]), "1", 1) == 0)
|
||||
notification = 1;
|
||||
else if (tb[1] && strncmp(blobmsg_get_string(tb[1]), "2", 1) == 0)
|
||||
else if (tb[1] && CWMP_STRNCMP(blobmsg_get_string(tb[1]), "2", 1) == 0)
|
||||
notification = 2;
|
||||
if (tb[4] && (strncmp(blobmsg_get_string(tb[4]), "1", 1) == 0 || strcasecmp(blobmsg_get_string(tb[4]), "true") == 0))
|
||||
if (tb[4] && cwmp_str_to_bool(blobmsg_get_string(tb[4])) == true)
|
||||
writable = true;
|
||||
add_dm_parameter_to_list(parameters_list, blobmsg_get_string(tb[0]), tb[1] ? blobmsg_get_string(tb[1]) : "", tb[2] ? blobmsg_get_string(tb[2]) : "", notification, writable);
|
||||
}
|
||||
|
|
@ -161,12 +161,11 @@ void ubus_transaction_commit_callback(struct ubus_request *req __attribute__((un
|
|||
blobmsg_for_each_attr(cur, updated_services, rem)
|
||||
{
|
||||
char *service_name = blobmsg_get_string(cur);
|
||||
if (!service_name || strlen(service_name) == 0 || strcmp(service_name, "cwmp") == 0)
|
||||
if (!service_name || CWMP_STRLEN(service_name) == 0 || CWMP_STRCMP(service_name, "cwmp") == 0)
|
||||
continue;
|
||||
CWMP_LOG(INFO, "Detected service: %s will be restarted in the end session", service_name);
|
||||
/*Add the service to the list*/
|
||||
if (strcmp(service_name, "cwmp") != 0)
|
||||
icwmp_add_service(service_name);
|
||||
icwmp_add_service(service_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -190,7 +189,7 @@ void ubus_transaction_status_callback(struct ubus_request *req __attribute__((un
|
|||
struct blob_attr *tb[2] = { NULL, NULL };
|
||||
blobmsg_parse(p, 2, tb, blobmsg_data(msg), blobmsg_len(msg));
|
||||
status_str = blobmsg_get_string(tb[0]);
|
||||
if (strcmp(status_str, "on-going") == 0)
|
||||
if (CWMP_STRCMP(status_str, "on-going") == 0)
|
||||
*status = true;
|
||||
else
|
||||
*status = false;
|
||||
|
|
@ -353,12 +352,12 @@ int cwmp_get_leaf_value(char *leaf, char **value)
|
|||
struct cwmp_dm_parameter dm_param = {0};
|
||||
size_t llen;
|
||||
|
||||
if (leaf == NULL || value == NULL) {
|
||||
if (value == NULL) {
|
||||
CWMP_LOG(INFO, "Empty parameter/value in arguments")
|
||||
return FAULT_CPE_INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
llen = strlen(leaf);
|
||||
llen = CWMP_STRLEN(leaf);
|
||||
if (llen == 0) {
|
||||
CWMP_LOG(INFO, "Empty parameter in arguments")
|
||||
return FAULT_CPE_INVALID_ARGUMENTS;
|
||||
|
|
@ -375,8 +374,8 @@ int cwmp_get_leaf_value(char *leaf, char **value)
|
|||
return FAULT_CPE_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
if (strncmp(leaf, dm_param.name, llen) == 0) {
|
||||
*value = (dm_param.value) ? strdup(dm_param.value) : strdup("");
|
||||
if (CWMP_STRNCMP(leaf, dm_param.name, llen) == 0) {
|
||||
*value = CWMP_STRDUP_DEF(dm_param.value, "");
|
||||
} else {
|
||||
CWMP_LOG(WARNING, "Param %s, does not return a value", leaf);
|
||||
return FAULT_CPE_INTERNAL_ERROR;
|
||||
|
|
@ -465,7 +464,7 @@ char *cwmp_get_multiple_parameters_values(struct list_head *arg_params_list, str
|
|||
|
||||
if (get_result.type == FAULT) {
|
||||
CWMP_LOG(INFO, "Get multiple parameters values failed: fault_code: %s", get_result.fault);
|
||||
return strdup(get_result.fault);
|
||||
return CWMP_STRDUP(get_result.fault);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -599,7 +598,8 @@ void ubus_objects_callback(struct ubus_request *req, int type __attribute__((unu
|
|||
result->status = blobmsg_get_u8(tb[0]);
|
||||
if (tb[1]) {
|
||||
char **instance = result->instance;
|
||||
*instance = strdup(blobmsg_get_string(tb[1]));
|
||||
char *val = blobmsg_get_string(tb[1]);
|
||||
*instance = CWMP_STRDUP(val);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,9 +124,9 @@ static bool set_specific_diagnostic_object_parameter_structure_value(struct diag
|
|||
{
|
||||
int i;
|
||||
for (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);
|
||||
(*diagnostics_array)[i].value = strdup(value);
|
||||
(*diagnostics_array)[i].value = CWMP_STRDUP(value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
41
digauth.c
41
digauth.c
|
|
@ -91,7 +91,8 @@ static int get_param_index(char *key)
|
|||
unsigned int i;
|
||||
|
||||
for (i = 0; i < (sizeof(param)/sizeof(param[0])); i++) {
|
||||
if (strncmp(key, param[i].key, strlen(param[i].key)) == 0)
|
||||
int key_len = CWMP_STRLEN(param[i].key);
|
||||
if (CWMP_STRNCMP(key, param[i].key, key_len) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
|
|
@ -100,6 +101,9 @@ static int get_param_index(char *key)
|
|||
|
||||
static void strip_lead_trail_char(char *str, char ch)
|
||||
{
|
||||
if (str == NULL)
|
||||
return;
|
||||
|
||||
/* First remove leading strip-char */
|
||||
const char* first_valid = str;
|
||||
|
||||
|
|
@ -107,12 +111,12 @@ static void strip_lead_trail_char(char *str, char ch)
|
|||
++first_valid;
|
||||
}
|
||||
|
||||
size_t len = strlen(first_valid) + 1;
|
||||
size_t len = CWMP_STRLEN(first_valid) + 1;
|
||||
|
||||
memmove(str, first_valid, len);
|
||||
|
||||
/* Now remove trailing strip-char */
|
||||
char* end_str = str + strlen(str) - 1;
|
||||
char* end_str = str + CWMP_STRLEN(str) - 1;
|
||||
|
||||
while(str < end_str && *end_str == ch) {
|
||||
*end_str = '\0';
|
||||
|
|
@ -167,7 +171,7 @@ static void get_value_from_header(const char *data)
|
|||
strip_lead_trail_char(key, '\"');
|
||||
|
||||
eq = eq + 1;
|
||||
char *end = eq + strlen(eq) - 1;
|
||||
char *end = eq + CWMP_STRLEN(eq) - 1;
|
||||
len = end - eq + 2;
|
||||
char val[len];
|
||||
snprintf(val, len, "%s", eq);
|
||||
|
|
@ -208,7 +212,7 @@ static void get_digest_ha1(const char *algo, const char *uname, const char *rlm,
|
|||
free(a);
|
||||
a = NULL;
|
||||
|
||||
if (0 == strcasecmp(algo, "md5-sess")) {
|
||||
if (0 == CWMP_STRCASECMP(algo, "md5-sess")) {
|
||||
len = strlen(nonce) + strlen(cnonce) + 3;
|
||||
a = (char *)calloc(sizeof(char), len);
|
||||
if (a == NULL)
|
||||
|
|
@ -372,28 +376,28 @@ int validate_http_digest_auth(const char *http_meth, const char *uri, const char
|
|||
{
|
||||
get_value_from_header(hdr);
|
||||
|
||||
if (strcmp(param[E_USERNAME].value, usr) != 0)
|
||||
if (CWMP_STRCMP(param[E_USERNAME].value, usr) != 0)
|
||||
return 0;
|
||||
|
||||
if (strlen(param[E_REALM].value) == 0)
|
||||
if (CWMP_STRLEN(param[E_REALM].value) == 0)
|
||||
return 0;
|
||||
|
||||
if (strcmp(param[E_REALM].value, rlm) != 0)
|
||||
if (CWMP_STRCMP(param[E_REALM].value, rlm) != 0)
|
||||
return 0;
|
||||
|
||||
if (strlen(param[E_CNONCE].value) == 0)
|
||||
if (CWMP_STRLEN(param[E_CNONCE].value) == 0)
|
||||
return 0;
|
||||
|
||||
if (strlen(param[E_QOP].value) == 0)
|
||||
if (CWMP_STRLEN(param[E_QOP].value) == 0)
|
||||
return 0;
|
||||
|
||||
if (strlen(param[E_NC].value) == 0)
|
||||
if (CWMP_STRLEN(param[E_NC].value) == 0)
|
||||
return 0;
|
||||
|
||||
if (strlen(param[E_RESPONSE].value) == 0)
|
||||
if (CWMP_STRLEN(param[E_RESPONSE].value) == 0)
|
||||
return 0;
|
||||
|
||||
int len = strlen(param[E_NONCE].value);
|
||||
int len = CWMP_STRLEN(param[E_NONCE].value);
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
|
|
@ -414,20 +418,21 @@ int validate_http_digest_auth(const char *http_meth, const char *uri, const char
|
|||
char nonce[MD5_HASH_HEX_LEN + 9];
|
||||
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");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strlen(param[E_URI].value) == 0)
|
||||
if (CWMP_STRLEN(param[E_URI].value) == 0)
|
||||
return 0;
|
||||
|
||||
if (strncmp(param[E_URI].value, uri, strlen(uri)) != 0) {
|
||||
int uri_len = CWMP_STRLEN(uri);
|
||||
if (CWMP_STRNCMP(param[E_URI].value, uri, uri_len) != 0) {
|
||||
CWMP_LOG(ERROR, "Authentication failed, URI is not matched");
|
||||
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))
|
||||
return 0;
|
||||
|
||||
char *tmp;
|
||||
|
|
@ -446,7 +451,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,
|
||||
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)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
|
|
|
|||
59
download.c
59
download.c
|
|
@ -43,12 +43,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_NOPROGRESS, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
|
||||
if (username != NULL && strlen(username) > 0) {
|
||||
if (CWMP_STRLEN(username) > 0) {
|
||||
char userpass[1024];
|
||||
snprintf(userpass, sizeof(userpass), "%s:%s", username, password);
|
||||
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_MAXREDIRS, 50L);
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_ANY);
|
||||
|
|
@ -223,7 +223,7 @@ int cwmp_launch_download(struct download *pdownload, char *download_file_name, e
|
|||
if (error != FAULT_CPE_NO_FAULT)
|
||||
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);
|
||||
if (cwmp_check_image() == 0) {
|
||||
long int file_size = get_file_size(FIRMWARE_UPGRADE_IMAGE);
|
||||
|
|
@ -239,10 +239,10 @@ int cwmp_launch_download(struct download *pdownload, char *download_file_name, e
|
|||
error = FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED;
|
||||
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
|
||||
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) {
|
||||
char file_path[512];
|
||||
snprintf(file_path, sizeof(file_path), "/tmp/%s", download_file_name);
|
||||
|
|
@ -251,10 +251,10 @@ int cwmp_launch_download(struct download *pdownload, char *download_file_name, e
|
|||
rename(ICWMP_DOWNLOAD_FILE, VENDOR_CONFIG_FILE);
|
||||
|
||||
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
|
||||
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
|
||||
error = FAULT_CPE_NO_FAULT;
|
||||
|
||||
|
|
@ -270,9 +270,10 @@ end_download:
|
|||
return error;
|
||||
}
|
||||
|
||||
p->command_key = pdownload->command_key ? strdup(pdownload->command_key) : strdup("");
|
||||
p->start_time = strdup(download_startTime);
|
||||
p->complete_time = strdup(get_time(time(NULL)));
|
||||
p->command_key = CWMP_STRDUP_DEF(pdownload->command_key, "");
|
||||
p->start_time = CWMP_STRDUP(download_startTime);
|
||||
char *end_time = get_time(time(NULL));
|
||||
p->complete_time = CWMP_STRDUP(end_time);
|
||||
p->type = ltype;
|
||||
if (error != FAULT_CPE_NO_FAULT) {
|
||||
p->fault_code = error;
|
||||
|
|
@ -298,7 +299,7 @@ int apply_downloaded_file(struct cwmp *cwmp, struct download *pdownload, char *d
|
|||
}
|
||||
bkp_session_insert_transfer_complete(ptransfer_complete);
|
||||
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_commit_package("cwmp", UCI_STANDARD_CONFIG);
|
||||
if (cwmp_apply_firmware() != 0)
|
||||
|
|
@ -309,10 +310,10 @@ int apply_downloaded_file(struct cwmp *cwmp, struct download *pdownload, char *d
|
|||
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
|
||||
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();
|
||||
int err = CWMP_OK;
|
||||
if (download_file_name != NULL) {
|
||||
|
|
@ -332,14 +333,14 @@ int apply_downloaded_file(struct cwmp *cwmp, struct download *pdownload, char *d
|
|||
error = FAULT_CPE_INTERNAL_ERROR;
|
||||
else if (err == -1)
|
||||
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
|
||||
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
|
||||
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();
|
||||
if (err == CWMP_OK)
|
||||
error = FAULT_CPE_NO_FAULT;
|
||||
|
|
@ -373,9 +374,10 @@ struct transfer_complete *set_download_error_transfer_complete(struct cwmp *cwmp
|
|||
struct transfer_complete *ptransfer_complete;
|
||||
ptransfer_complete = calloc(1, sizeof(struct transfer_complete));
|
||||
if (ptransfer_complete != NULL) {
|
||||
ptransfer_complete->command_key = strdup(pdownload->command_key);
|
||||
ptransfer_complete->start_time = strdup(get_time(time(NULL)));
|
||||
ptransfer_complete->complete_time = strdup(ptransfer_complete->start_time);
|
||||
ptransfer_complete->command_key = CWMP_STRDUP(pdownload->command_key);
|
||||
char *start_time = get_time(time(NULL));
|
||||
ptransfer_complete->start_time = CWMP_STRDUP(start_time);
|
||||
ptransfer_complete->complete_time = CWMP_STRDUP(ptransfer_complete->start_time);
|
||||
ptransfer_complete->fault_code = ltype == TYPE_DOWNLOAD ? FAULT_CPE_DOWNLOAD_FAILURE : FAULT_CPE_DOWNLOAD_FAIL_WITHIN_TIME_WINDOW;
|
||||
ptransfer_complete->type = ltype;
|
||||
bkp_session_insert_transfer_complete(ptransfer_complete);
|
||||
|
|
@ -474,9 +476,9 @@ int cwmp_add_apply_schedule_download(struct download *schedule_download, char *s
|
|||
}
|
||||
if (error == FAULT_CPE_NO_FAULT) {
|
||||
pthread_mutex_lock(&mutex_apply_schedule_download);
|
||||
apply_schedule_download->command_key = strdup(schedule_download->command_key);
|
||||
apply_schedule_download->file_type = strdup(schedule_download->file_type);
|
||||
apply_schedule_download->start_time = strdup(start_time);
|
||||
apply_schedule_download->command_key = CWMP_STRDUP(schedule_download->command_key);
|
||||
apply_schedule_download->file_type = CWMP_STRDUP(schedule_download->file_type);
|
||||
apply_schedule_download->start_time = CWMP_STRDUP(start_time);
|
||||
for (i = 0; i < 2; i++) {
|
||||
apply_schedule_download->timeintervals[i].windowstart = schedule_download->timewindowstruct[i].windowstart;
|
||||
apply_schedule_download->timeintervals[i].windowend = schedule_download->timewindowstruct[i].windowend;
|
||||
|
|
@ -725,24 +727,25 @@ void *thread_cwmp_rpc_cpe_apply_schedule_download(void *v)
|
|||
if (apply_download->file_type[0] == '1') {
|
||||
ptransfer_complete->old_software_version = cwmp->deviceid.softwareversion;
|
||||
}
|
||||
ptransfer_complete->command_key = strdup(apply_download->command_key);
|
||||
ptransfer_complete->start_time = strdup(apply_download->start_time);
|
||||
ptransfer_complete->complete_time = strdup(get_time(time(NULL)));
|
||||
ptransfer_complete->command_key = CWMP_STRDUP(apply_download->command_key);
|
||||
ptransfer_complete->start_time = CWMP_STRDUP(apply_download->start_time);
|
||||
char *end_time = get_time(time(NULL));
|
||||
ptransfer_complete->complete_time = CWMP_STRDUP(end_time);
|
||||
ptransfer_complete->fault_code = error;
|
||||
ptransfer_complete->type = TYPE_SCHEDULE_DOWNLOAD;
|
||||
bkp_session_insert_transfer_complete(ptransfer_complete);
|
||||
bkp_session_save();
|
||||
|
||||
if (strcmp(apply_download->file_type, FIRMWARE_UPGRADE_IMAGE_FILE_TYPE) == 0) {
|
||||
if (CWMP_STRCMP(apply_download->file_type, FIRMWARE_UPGRADE_IMAGE_FILE_TYPE) == 0) {
|
||||
cwmp_uci_set_value("cwmp", "cpe", "exec_download", "1");
|
||||
cwmp_commit_package("cwmp", UCI_STANDARD_CONFIG);
|
||||
cwmp_apply_firmware();
|
||||
sleep(70);
|
||||
error = FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED;
|
||||
} else if (strcmp(apply_download->file_type, WEB_CONTENT_FILE_TYPE) == 0) {
|
||||
} else if (CWMP_STRCMP(apply_download->file_type, WEB_CONTENT_FILE_TYPE) == 0) {
|
||||
//TODO Not Supported
|
||||
error = FAULT_CPE_NO_FAULT;
|
||||
} else if (strcmp(apply_download->file_type, VENDOR_CONFIG_FILE_TYPE) == 0) {
|
||||
} else if (CWMP_STRCMP(apply_download->file_type, VENDOR_CONFIG_FILE_TYPE) == 0) {
|
||||
cwmp_uci_init();
|
||||
int err = cwmp_uci_import(NULL, VENDOR_CONFIG_FILE, UCI_STANDARD_CONFIG);
|
||||
cwmp_uci_exit();
|
||||
|
|
|
|||
6
event.c
6
event.c
|
|
@ -85,7 +85,7 @@ struct event_container *cwmp_add_event_container(struct cwmp *cwmp, int event_co
|
|||
INIT_LIST_HEAD(&(event_container->head_dm_parameter));
|
||||
list_add(&(event_container->list), ilist->prev);
|
||||
event_container->code = event_code;
|
||||
event_container->command_key = command_key ? strdup(command_key) : strdup("");
|
||||
event_container->command_key = CWMP_STRDUP_DEF(command_key, "");
|
||||
if ((cwmp->event_id < 0) || (cwmp->event_id >= MAX_INT_ID)) {
|
||||
cwmp->event_id = 0;
|
||||
}
|
||||
|
|
@ -445,7 +445,7 @@ void connection_request_ip_value_change(struct cwmp *cwmp, int version)
|
|||
bkp_session_save();
|
||||
return;
|
||||
}
|
||||
if (strcmp(bip, ip_value) != 0) {
|
||||
if (CWMP_STRCMP(bip, ip_value) != 0) {
|
||||
struct event_container *event_container;
|
||||
pthread_mutex_lock(&(cwmp->mutex_session_queue));
|
||||
event_container = cwmp_add_event_container(cwmp, EVENT_IDX_4VALUE_CHANGE, "");
|
||||
|
|
@ -477,7 +477,7 @@ void connection_request_port_value_change(struct cwmp *cwmp, int port)
|
|||
bkp_session_save();
|
||||
return;
|
||||
}
|
||||
if (strcmp(bport, bufport) != 0) {
|
||||
if (CWMP_STRCMP(bport, bufport) != 0) {
|
||||
struct event_container *event_container;
|
||||
event_container = cwmp_add_event_container(cwmp, EVENT_IDX_4VALUE_CHANGE, "");
|
||||
if (event_container == NULL) {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ int add_heart_beat_event(struct session *heartbeat_session)
|
|||
INIT_LIST_HEAD(&(event_container->head_dm_parameter));
|
||||
list_add(&(event_container->list), heartbeat_session->head_event_container.prev);
|
||||
event_container->code = EVENT_IDX_14HEARTBEAT;
|
||||
event_container->command_key = strdup("");
|
||||
event_container->command_key = CWMP_STRDUP("");
|
||||
event_container->id = 1;
|
||||
/*
|
||||
* event_container will be freed in the destruction of the session heartbeat_session
|
||||
|
|
|
|||
16
http.c
16
http.c
|
|
@ -46,7 +46,7 @@ int http_client_init(struct cwmp *cwmp)
|
|||
|
||||
uci_get_value(UCI_DHCP_DISCOVERY_PATH, &dhcp_dis);
|
||||
|
||||
if (dhcp_dis && cwmp->retry_count_session > 0 && strcmp(dhcp_dis, "enable") == 0) {
|
||||
if (cwmp->retry_count_session > 0 && cwmp_str_to_bool(dhcp_dis) == true) {
|
||||
uci_get_state_value(UCI_DHCP_ACS_URL, &acs_var_stat);
|
||||
if (acs_var_stat) {
|
||||
if (icwmp_asprintf(&http_c.url, "%s", acs_var_stat) == -1) {
|
||||
|
|
@ -210,7 +210,7 @@ int http_send_message(struct cwmp *cwmp, char *msg_out, int msg_out_len, char **
|
|||
res = curl_easy_perform(curl);
|
||||
|
||||
if (res != CURLE_OK) {
|
||||
size_t len = strlen(errbuf);
|
||||
size_t len = CWMP_STRLEN(errbuf);
|
||||
if (len) {
|
||||
if (errbuf[len - 1] == '\n')
|
||||
errbuf[len - 1] = '\0';
|
||||
|
|
@ -220,12 +220,12 @@ int http_send_message(struct cwmp *cwmp, char *msg_out, int msg_out_len, char **
|
|||
}
|
||||
}
|
||||
|
||||
if (!strlen(*msg_in))
|
||||
if (!CWMP_STRLEN(*msg_in))
|
||||
FREE(*msg_in);
|
||||
|
||||
curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ip);
|
||||
if (ip && ip[0] != '\0') {
|
||||
if (ip_acs[0] == '\0' || strcmp(ip_acs, ip) != 0) {
|
||||
if (CWMP_STRLEN(ip) > 0) {
|
||||
if (CWMP_STRCMP(ip_acs, ip) != 0) {
|
||||
CWMP_STRNCPY(ip_acs, ip, sizeof(ip_acs));
|
||||
tmp = inet_pton(AF_INET, ip, buf);
|
||||
if (tmp == 1)
|
||||
|
|
@ -319,7 +319,7 @@ static void http_cr_new_client(int client, bool service_available)
|
|||
int j = 0;
|
||||
bool ignore = false;
|
||||
memset(rec_http_get_head, 0, HTTP_GET_HDR_LEN);
|
||||
for (size_t i = 0; i < strlen(buffer) && j < (HTTP_GET_HDR_LEN - 1); i++) {
|
||||
for (size_t i = 0; i < CWMP_STRLEN(buffer) && j < (HTTP_GET_HDR_LEN - 1); i++) {
|
||||
if (buffer[i] == '?')
|
||||
ignore = true;
|
||||
if (buffer[i] == ' ')
|
||||
|
|
@ -330,11 +330,11 @@ static void http_cr_new_client(int client, bool service_available)
|
|||
}
|
||||
}
|
||||
|
||||
if (!strncasecmp(rec_http_get_head, cr_http_get_head, strlen(cr_http_get_head)))
|
||||
if (!CWMP_STRNCASECMP(rec_http_get_head, cr_http_get_head, CWMP_STRLEN(cr_http_get_head)))
|
||||
method_is_get = true;
|
||||
}
|
||||
|
||||
if (!strncasecmp(buffer, "Authorization: Digest ", strlen("Authorization: Digest "))) {
|
||||
if (!CWMP_STRNCASECMP(buffer, "Authorization: Digest ", CWMP_STRLEN("Authorization: Digest "))) {
|
||||
auth_digest_checked = true;
|
||||
CWMP_STRNCPY(auth_digest_buffer, buffer, BUFSIZ);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,11 @@
|
|||
#endif
|
||||
|
||||
#define CWMP_STRCMP(S1, S2) ((S1 != NULL && S2 != NULL) ? strcmp(S1, S2) : -1)
|
||||
#define CWMP_STRNCMP(S1, S2, SIZE) ((S1 != NULL && S2 != NULL) ? strncmp(S1, S2, SIZE) : -1)
|
||||
#define CWMP_STRCASECMP(S1, S2) ((S1 != NULL && S2 != NULL) ? strcasecmp(S1, S2) : -1)
|
||||
#define CWMP_STRNCASECMP(S1, S2, SIZE) ((S1 != NULL && S2 != NULL) ? strncasecmp(S1, S2, SIZE) : -1)
|
||||
#define CWMP_STRDUP(S1) ((S1 != NULL) ? strdup(S1) : NULL)
|
||||
#define CWMP_STRDUP_DEF(S1, DEF) ((S1 != NULL) ? strdup(S1) : strdup(DEF))
|
||||
#define CWMP_STRLEN(S1) ((S1 != NULL) ? strlen(S1) : 0)
|
||||
|
||||
#define CWMP_STRNCPY(DST, SRC, SIZE) \
|
||||
|
|
@ -545,6 +549,6 @@ int cwmp_get_retry_interval(struct cwmp *cwmp, bool heart_beat);
|
|||
int cwmp_schedule_rpc(struct cwmp *cwmp, struct session *session);
|
||||
int run_session_end_func(void);
|
||||
void set_interface_reset_request(char *param_name, char *value);
|
||||
bool uci_str_to_bool(char *value);
|
||||
bool cwmp_str_to_bool(char *value);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
24
log.c
24
log.c
|
|
@ -68,7 +68,7 @@ int log_set_on_console(char *value)
|
|||
if (value == NULL)
|
||||
return 1;
|
||||
|
||||
enable_log_stdout = uci_str_to_bool(value);
|
||||
enable_log_stdout = cwmp_str_to_bool(value);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ int log_set_on_file(char *value)
|
|||
if (value == NULL)
|
||||
return 1;
|
||||
|
||||
enable_log_file = uci_str_to_bool(value);
|
||||
enable_log_file = cwmp_str_to_bool(value);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ int log_set_on_syslog(char *value)
|
|||
if (value == NULL)
|
||||
return 1;
|
||||
|
||||
enable_log_syslog = uci_str_to_bool(value);
|
||||
enable_log_syslog = cwmp_str_to_bool(value);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ void puts_log(int severity, const char *fmt, ...)
|
|||
gettimeofday(&tv, 0);
|
||||
Tm = localtime(&tv.tv_sec);
|
||||
i = snprintf(buf, sizeof(buf), "%02d-%02d-%4d, %02d:%02d:%02d %s ", Tm->tm_mday, Tm->tm_mon + 1, Tm->tm_year + 1900, Tm->tm_hour, Tm->tm_min, Tm->tm_sec, SEVERITY_NAMES[severity]);
|
||||
if (strlen(log_file_name) == 0) {
|
||||
if (CWMP_STRLEN(log_file_name) == 0) {
|
||||
CWMP_STRNCPY(log_file_name, DEFAULT_LOG_FILE_NAME, sizeof(log_file_name));
|
||||
}
|
||||
if (enable_log_file) {
|
||||
|
|
@ -131,8 +131,8 @@ void puts_log(int severity, const char *fmt, ...)
|
|||
vsprintf(buf + i, (const char *)fmt, args);
|
||||
if (enable_log_file) {
|
||||
CWMP_STRNCPY(buf_file, buf, sizeof(buf_file));
|
||||
buf_file[strlen(buf)] = '\n';
|
||||
buf_file[strlen(buf) + 1] = '\0';
|
||||
buf_file[CWMP_STRLEN(buf)] = '\n';
|
||||
buf_file[CWMP_STRLEN(buf) + 1] = '\0';
|
||||
fputs(buf_file, pLog);
|
||||
}
|
||||
va_end(args);
|
||||
|
|
@ -172,7 +172,7 @@ void puts_log_xmlmsg(int severity, char *msg, int msgtype)
|
|||
gettimeofday(&tv, 0);
|
||||
Tm = localtime(&tv.tv_sec);
|
||||
snprintf(buf, sizeof(buf), "%02d-%02d-%4d, %02d:%02d:%02d %s ", Tm->tm_mday, Tm->tm_mon + 1, Tm->tm_year + 1900, Tm->tm_hour, Tm->tm_min, Tm->tm_sec, SEVERITY_NAMES[severity]);
|
||||
if (strlen(log_file_name) == 0) {
|
||||
if (CWMP_STRLEN(log_file_name) == 0) {
|
||||
CWMP_STRNCPY(log_file_name, DEFAULT_LOG_FILE_NAME, sizeof(log_file_name));
|
||||
}
|
||||
|
||||
|
|
@ -198,7 +198,8 @@ void puts_log_xmlmsg(int severity, char *msg, int msgtype)
|
|||
fputs(buf, pLog);
|
||||
fputs(description, pLog);
|
||||
fputs(separator, pLog);
|
||||
fputs(msg, pLog);
|
||||
if (CWMP_STRLEN(msg) > 0)
|
||||
fputs(msg, pLog);
|
||||
fputs("\n", pLog);
|
||||
fputs(separator, pLog);
|
||||
fclose(pLog);
|
||||
|
|
@ -207,15 +208,16 @@ void puts_log_xmlmsg(int severity, char *msg, int msgtype)
|
|||
puts(buf);
|
||||
puts(description);
|
||||
puts(separator);
|
||||
puts(msg);
|
||||
if (CWMP_STRLEN(msg) > 0)
|
||||
puts(msg);
|
||||
puts("\n");
|
||||
puts(separator);
|
||||
}
|
||||
|
||||
if (enable_log_syslog) {
|
||||
syslog(severity, "%s: %s", ((msgtype == XML_MSG_IN) ? "IN" : "OUT"), msg);
|
||||
if (sizeof(buf) < strlen(msg))
|
||||
syslog(severity, "Truncated message at %zu characters", strlen(msg));
|
||||
if (sizeof(buf) < CWMP_STRLEN(msg))
|
||||
syslog(severity, "Truncated message at %zu characters", CWMP_STRLEN(msg));
|
||||
}
|
||||
end:
|
||||
pthread_mutex_unlock(&mutex_log);
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ static int itfcmp(char *itf1, char *itf2)
|
|||
strncpy(buf2, itf1, index);
|
||||
buf2[index] = '\0';
|
||||
|
||||
if (strcmp(buf1, buf2) == 0)
|
||||
if (CWMP_STRCMP(buf1, buf2) == 0)
|
||||
status = 0;
|
||||
end:
|
||||
if (buf1)
|
||||
|
|
@ -119,7 +119,7 @@ static void freecwmp_netlink_interface(struct nlmsghdr *nlh)
|
|||
inet_ntop(AF_INET, &(addr), if_addr, INET_ADDRSTRLEN);
|
||||
|
||||
FREE(cwmp_main.conf.ip);
|
||||
cwmp_main.conf.ip = strdup(if_addr);
|
||||
cwmp_main.conf.ip = CWMP_STRDUP(if_addr);
|
||||
cwmp_uci_set_varstate_value("cwmp", "cpe", "ip", cwmp_main.conf.ip);
|
||||
cwmp_commit_package("cwmp", UCI_VARSTATE_CONFIG);
|
||||
connection_request_ip_value_change(&cwmp_main, IPv4);
|
||||
|
|
@ -134,13 +134,13 @@ static void freecwmp_netlink_interface(struct nlmsghdr *nlh)
|
|||
}
|
||||
inet_ntop(AF_INET6, RTA_DATA(rth), pradd_v6, sizeof(pradd_v6));
|
||||
if_indextoname(ifa->ifa_index, if_name);
|
||||
if (strncmp(cwmp_main.conf.interface, if_name, IFNAMSIZ)) {
|
||||
if (CWMP_STRNCMP(cwmp_main.conf.interface, if_name, IFNAMSIZ)) {
|
||||
rth = RTA_NEXT(rth, rtl);
|
||||
continue;
|
||||
}
|
||||
|
||||
FREE(cwmp_main.conf.ipv6);
|
||||
cwmp_main.conf.ipv6 = strdup(pradd_v6);
|
||||
cwmp_main.conf.ipv6 = CWMP_STRDUP(pradd_v6);
|
||||
cwmp_uci_set_varstate_value("cwmp", "cpe", "ipv6", cwmp_main.conf.ip);
|
||||
cwmp_commit_package("cwmp", UCI_VARSTATE_CONFIG);
|
||||
connection_request_ip_value_change(&cwmp_main, IPv6);
|
||||
|
|
|
|||
|
|
@ -38,10 +38,13 @@ struct cwmp_dm_parameter forced_notifications_parameters[] = {
|
|||
*/
|
||||
static bool parameter_is_subobject_of_parameter(char *parent, char *child)
|
||||
{
|
||||
if (strcmp(parent, child) == 0)
|
||||
if (CWMP_STRCMP(parent, child) == 0)
|
||||
return false;
|
||||
if (strncmp(parent, child, strlen(parent)) == 0)
|
||||
|
||||
int len = CWMP_STRLEN(parent);
|
||||
if (CWMP_STRNCMP(parent, child, len) == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -50,7 +53,7 @@ int check_parameter_forced_notification(const char *parameter)
|
|||
int i;
|
||||
|
||||
for (i = 0; i < (int)ARRAY_SIZE(forced_notifications_parameters); i++) {
|
||||
if (strcmp(forced_notifications_parameters[i].name, parameter) == 0)
|
||||
if (CWMP_STRCMP(forced_notifications_parameters[i].name, parameter) == 0)
|
||||
return forced_notifications_parameters[i].notification;
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +67,7 @@ char *check_valid_parameter_path(char *parameter_name)
|
|||
|
||||
error = cwmp_get_parameter_names(parameter_name, true, ¶meters_list);
|
||||
|
||||
if (error != NULL && strcmp(error, "9003") == 0)
|
||||
if (CWMP_STRCMP(error, "9003") == 0)
|
||||
error = cwmp_get_parameter_values(parameter_name, ¶meters_list);
|
||||
|
||||
cwmp_free_all_dm_parameter_list(¶meters_list);
|
||||
|
|
@ -134,10 +137,10 @@ bool update_notifications_list(char *parameter_name, int notification)
|
|||
uci_foreach_element_safe(list_notif, tmp, e) {
|
||||
if (e->name == NULL)
|
||||
continue;
|
||||
ename = strdup(e->name);
|
||||
if ((strcmp(parameter_name, e->name) == 0 && (i != notification)) || parameter_is_subobject_of_parameter(parameter_name, e->name))
|
||||
ename = CWMP_STRDUP(e->name);
|
||||
if ((CWMP_STRCMP(parameter_name, e->name) == 0 && (i != notification)) || parameter_is_subobject_of_parameter(parameter_name, e->name))
|
||||
cwmp_uci_del_list_value("cwmp", "@notifications[0]", notifications[i], e->name, UCI_VARSTATE_CONFIG);
|
||||
if (ename && (strcmp(parameter_name, ename) == 0 || parameter_is_subobject_of_parameter(ename, parameter_name) ) && (i == notification))
|
||||
if (ename && (CWMP_STRCMP(parameter_name, ename) == 0 || parameter_is_subobject_of_parameter(ename, parameter_name) ) && (i == notification))
|
||||
update_ret = false;
|
||||
FREE(ename);
|
||||
}
|
||||
|
|
@ -193,7 +196,7 @@ int get_parameter_family_notifications(char *parameter_name, struct list_head *c
|
|||
parent_param = e->name;
|
||||
notif_ret = i;
|
||||
}
|
||||
if (strcmp(parameter_name, e->name) == 0)
|
||||
if (CWMP_STRCMP(parameter_name, e->name) == 0)
|
||||
notif_ret = i;
|
||||
}
|
||||
}
|
||||
|
|
@ -211,7 +214,7 @@ int get_parameter_leaf_notification_from_childs_list(char *parameter_name, struc
|
|||
if (childs_list == NULL)
|
||||
return -1;
|
||||
list_for_each_entry (param_value, childs_list, list) {
|
||||
if (strcmp(param_value->name, parameter_name) == 0) {
|
||||
if (CWMP_STRCMP(param_value->name, parameter_name) == 0) {
|
||||
ret_notif = param_value->notification;
|
||||
break;
|
||||
}
|
||||
|
|
@ -277,9 +280,11 @@ bool parameter_is_other_notif_object_child(char *parent, char *parameter)
|
|||
list_ptr = list_iter.prev;
|
||||
list_iter.prev = list_ptr->prev;
|
||||
list_iter.next = list_ptr->next;
|
||||
if (strcmp(parent, dm_parameter->name) == 0)
|
||||
if (CWMP_STRCMP(parent, dm_parameter->name) == 0)
|
||||
continue;
|
||||
if (strncmp(parent, dm_parameter->name, strlen(parent)) == 0 && strncmp(parameter, dm_parameter->name, strlen(dm_parameter->name)) == 0)
|
||||
int p_len = CWMP_STRLEN(parent);
|
||||
int n_len = CWMP_STRLEN(dm_parameter->name);
|
||||
if (CWMP_STRNCMP(parent, dm_parameter->name, p_len) == 0 && CWMP_STRNCMP(parameter, dm_parameter->name, n_len) == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -441,13 +446,11 @@ void load_custom_notify_json(struct cwmp *cwmp)
|
|||
continue;
|
||||
}
|
||||
char *fault = cwmp_set_parameter_attributes(blobmsg_get_string(tb[0]), atoi(blobmsg_get_string(tb[1])));
|
||||
if (fault == NULL)
|
||||
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]));
|
||||
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]));
|
||||
continue;
|
||||
}
|
||||
|
|
@ -464,9 +467,7 @@ void get_parameter_value_from_parameters_list(struct list_head *params_list, cha
|
|||
{
|
||||
struct cwmp_dm_parameter *param_value;
|
||||
list_for_each_entry (param_value, params_list, list) {
|
||||
if (param_value->name == NULL)
|
||||
continue;
|
||||
if (strcmp(parameter_name, param_value->name) != 0)
|
||||
if (CWMP_STRCMP(parameter_name, param_value->name) != 0)
|
||||
continue;
|
||||
*value = strdup(param_value->value ? param_value->value : "");
|
||||
*type = strdup(param_value->type ? param_value->type : "");
|
||||
|
|
@ -490,7 +491,7 @@ int check_value_change(void)
|
|||
LIST_HEAD(list_notify_params);
|
||||
create_list_param_leaf_notify(&list_notify_params, NULL, NULL);
|
||||
while (fgets(buf, 1280, fp) != NULL) {
|
||||
int len = strlen(buf);
|
||||
int len = CWMP_STRLEN(buf);
|
||||
if (len)
|
||||
buf[len - 1] = '\0';
|
||||
|
||||
|
|
@ -518,7 +519,7 @@ int check_value_change(void)
|
|||
value = NULL;
|
||||
continue;
|
||||
}
|
||||
if ((notification >= 1) && (dm_value != NULL) && (strcmp(dm_value, value) != 0)) {
|
||||
if ((notification >= 1) && (dm_value != NULL) && (CWMP_STRCMP(dm_value, value) != 0)) {
|
||||
if (notification == 1 || notification == 2)
|
||||
add_list_value_change(parameter, dm_value, dm_type);
|
||||
if (notification >= 3)
|
||||
|
|
@ -553,7 +554,7 @@ void sotfware_version_value_change(struct cwmp *cwmp, struct transfer_complete *
|
|||
return;
|
||||
|
||||
current_software_version = cwmp->deviceid.softwareversion;
|
||||
if (p->old_software_version && current_software_version && strcmp(p->old_software_version, current_software_version) != 0) {
|
||||
if (p->old_software_version && current_software_version && CWMP_STRCMP(p->old_software_version, current_software_version) != 0) {
|
||||
pthread_mutex_lock(&(cwmp->mutex_session_queue));
|
||||
cwmp_add_event_container(cwmp, EVENT_IDX_4VALUE_CHANGE, "");
|
||||
pthread_mutex_unlock(&(cwmp->mutex_session_queue));
|
||||
|
|
@ -675,7 +676,9 @@ static void send_udp_message(struct addrinfo *servaddr, char *msg)
|
|||
fd = socket(servaddr->ai_family, SOCK_DGRAM, 0);
|
||||
|
||||
if (fd >= 0) {
|
||||
sendto(fd, msg, strlen(msg), 0, servaddr->ai_addr, servaddr->ai_addrlen);
|
||||
int msg_len = CWMP_STRLEN(msg);
|
||||
if (msg_len > 0)
|
||||
sendto(fd, msg, msg_len, 0, servaddr->ai_addr, servaddr->ai_addrlen);
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
|
@ -700,8 +703,8 @@ static void free_all_list_lw_notify()
|
|||
|
||||
void cwmp_lwnotification()
|
||||
{
|
||||
char msg[1024], *msg_out;
|
||||
char signature[41];
|
||||
char msg[1024] = {0}, *msg_out = NULL;
|
||||
char signature[41] = {0};
|
||||
struct addrinfo *servaddr;
|
||||
struct cwmp *cwmp = &cwmp_main;
|
||||
struct config *conf;
|
||||
|
|
@ -710,7 +713,7 @@ void cwmp_lwnotification()
|
|||
udplw_server_param(&servaddr);
|
||||
xml_prepare_lwnotification_message(&msg_out);
|
||||
message_compute_signature(msg_out, signature, sizeof(signature));
|
||||
snprintf(msg, sizeof(msg), "%s \n %s: %s \n %s: %s \n %s: %zu\n %s: %s\n\n%s", "POST /HTTPS/1.1", "HOST", conf->lw_notification_hostname, "Content-Type", "test/xml; charset=utf-8", "Content-Lenght", strlen(msg_out), "Signature", signature, msg_out);
|
||||
snprintf(msg, sizeof(msg), "%s \n %s: %s \n %s: %s \n %s: %zu\n %s: %s\n\n%s", "POST /HTTPS/1.1", "HOST", conf->lw_notification_hostname, "Content-Type", "test/xml; charset=utf-8", "Content-Lenght", CWMP_STRLEN(msg_out), "Signature", signature, msg_out);
|
||||
|
||||
send_udp_message(servaddr, msg);
|
||||
free_all_list_lw_notify();
|
||||
|
|
|
|||
271
rpc_soap.c
271
rpc_soap.c
|
|
@ -110,13 +110,13 @@ int xml_handle_message(struct session *session)
|
|||
char *tmp = strchr(c, ':');
|
||||
size_t ns_len = tmp - c;
|
||||
|
||||
if (strlen(ns.cwmp) != ns_len) {
|
||||
if (CWMP_STRLEN(ns.cwmp) != ns_len) {
|
||||
CWMP_LOG(INFO, "Invalid received message");
|
||||
session->fault_code = FAULT_CPE_REQUEST_DENIED;
|
||||
goto fault;
|
||||
}
|
||||
|
||||
if (strncmp(ns.cwmp, c, ns_len)) {
|
||||
if (CWMP_STRNCMP(ns.cwmp, c, ns_len)) {
|
||||
CWMP_LOG(INFO, "Invalid received message");
|
||||
session->fault_code = FAULT_CPE_REQUEST_DENIED;
|
||||
goto fault;
|
||||
|
|
@ -131,7 +131,7 @@ int xml_handle_message(struct session *session)
|
|||
CWMP_LOG(INFO, "SOAP RPC message: %s", c);
|
||||
rpc_cpe = NULL;
|
||||
for (i = 1; i < __RPC_CPE_MAX; i++) {
|
||||
if (i != RPC_CPE_FAULT && strcmp(c, rpc_cpe_methods[i].name) == 0 && rpc_cpe_methods[i].amd <= conf->supported_amd_version) {
|
||||
if (i != RPC_CPE_FAULT && 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);
|
||||
rpc_cpe = cwmp_add_session_rpc_cpe(session, i);
|
||||
if (rpc_cpe == NULL)
|
||||
|
|
@ -216,7 +216,7 @@ static int xml_prepare_parameters_inform(struct cwmp_dm_parameter *dm_parameter,
|
|||
if (!b)
|
||||
return 0;
|
||||
mxml_node_t *c = mxmlGetFirstChild(b);
|
||||
if (c && strcmp(dm_parameter->value, mxmlGetOpaque(c)) == 0)
|
||||
if (c && CWMP_STRCMP(dm_parameter->value, mxmlGetOpaque(c)) == 0)
|
||||
return 0;
|
||||
mxmlDelete(b);
|
||||
(*size)--;
|
||||
|
|
@ -463,7 +463,7 @@ static void load_inform_xml_schema(mxml_node_t **tree, struct cwmp *cwmp, struct
|
|||
continue;
|
||||
|
||||
// An empty connection url cause CDR test to break
|
||||
if (strcmp(forced_inform_parameters[i], DM_CONN_REQ_URL) == 0 && cwmp_dm_param.value != NULL && strlen(cwmp_dm_param.value) == 0) {
|
||||
if (CWMP_STRCMP(forced_inform_parameters[i], DM_CONN_REQ_URL) == 0 && cwmp_dm_param.value != NULL && CWMP_STRLEN(cwmp_dm_param.value) == 0) {
|
||||
CWMP_LOG(ERROR, "# Empty CR URL[%s] value", forced_inform_parameters[i]);
|
||||
MXML_DELETE(xml);
|
||||
return;
|
||||
|
|
@ -605,7 +605,7 @@ int set_rpc_acs_to_supported(char *rpc_name)
|
|||
int 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;
|
||||
return i;
|
||||
}
|
||||
|
|
@ -635,7 +635,7 @@ int cwmp_rpc_acs_parse_response_get_rpc_methods(struct cwmp *cwmp __attribute__(
|
|||
mxml_node_t *parent_node = mxmlGetParent(b);
|
||||
mxml_type_t node_type = mxmlGetType(b);
|
||||
|
||||
if (node_type == MXML_OPAQUE && mxmlGetType(parent_node) == MXML_ELEMENT && node_opaque && strcmp((char *) mxmlGetElement(parent_node), "string") == 0)
|
||||
if (node_type == MXML_OPAQUE && mxmlGetType(parent_node) == MXML_ELEMENT && node_opaque && CWMP_STRCMP((char *) mxmlGetElement(parent_node), "string") == 0)
|
||||
set_rpc_acs_to_supported((char*)node_opaque);
|
||||
|
||||
b = mxmlWalkNext(b, session->body_in, MXML_DESCEND);
|
||||
|
|
@ -832,7 +832,7 @@ int cwmp_rpc_acs_prepare_du_state_change_complete(struct cwmp *cwmp, struct sess
|
|||
if (!b)
|
||||
goto error;
|
||||
|
||||
c = q->uuid ? strdup(q->uuid) : strdup("");
|
||||
c = CWMP_STRDUP_DEF(q->uuid, "");
|
||||
b = mxmlNewOpaque(b, c);
|
||||
FREE(c);
|
||||
if (!b)
|
||||
|
|
@ -842,7 +842,7 @@ int cwmp_rpc_acs_prepare_du_state_change_complete(struct cwmp *cwmp, struct sess
|
|||
if (!b)
|
||||
goto error;
|
||||
|
||||
c = q->du_ref ? strdup(q->du_ref) : strdup("");
|
||||
c = CWMP_STRDUP_DEF(q->du_ref, "");
|
||||
b = mxmlNewOpaque(b, c);
|
||||
FREE(c);
|
||||
if (!b)
|
||||
|
|
@ -852,7 +852,7 @@ int cwmp_rpc_acs_prepare_du_state_change_complete(struct cwmp *cwmp, struct sess
|
|||
if (!b)
|
||||
goto error;
|
||||
|
||||
c = q->version ? strdup(q->version) : strdup("");
|
||||
c = CWMP_STRDUP_DEF(q->version, "");
|
||||
b = mxmlNewOpaque(b, c);
|
||||
FREE(c);
|
||||
if (!b)
|
||||
|
|
@ -862,7 +862,7 @@ int cwmp_rpc_acs_prepare_du_state_change_complete(struct cwmp *cwmp, struct sess
|
|||
if (!b)
|
||||
goto error;
|
||||
|
||||
c = q->current_state ? strdup(q->current_state) : strdup("");
|
||||
c = CWMP_STRDUP_DEF(q->current_state, "");
|
||||
b = mxmlNewOpaque(b, c);
|
||||
FREE(c);
|
||||
if (!b)
|
||||
|
|
@ -872,7 +872,7 @@ int cwmp_rpc_acs_prepare_du_state_change_complete(struct cwmp *cwmp, struct sess
|
|||
if (!b)
|
||||
goto error;
|
||||
|
||||
c = q->start_time ? strdup(q->start_time) : strdup("");
|
||||
c = CWMP_STRDUP_DEF(q->start_time, "");
|
||||
b = mxmlNewOpaque(b, c);
|
||||
FREE(c);
|
||||
if (!b)
|
||||
|
|
@ -882,7 +882,7 @@ int cwmp_rpc_acs_prepare_du_state_change_complete(struct cwmp *cwmp, struct sess
|
|||
if (!b)
|
||||
goto error;
|
||||
|
||||
c = q->complete_time ? strdup(q->complete_time) : strdup("");
|
||||
c = CWMP_STRDUP_DEF(q->complete_time, "");
|
||||
b = mxmlNewOpaque(b, c);
|
||||
FREE(c);
|
||||
if (!b)
|
||||
|
|
@ -957,11 +957,11 @@ int cwmp_handle_rpc_cpe_get_parameter_values(struct session *session, struct rpc
|
|||
mxml_node_t *parent_node = mxmlGetParent(b);
|
||||
mxml_type_t node_type = mxmlGetType(b);
|
||||
mxml_node_t *firstchild = mxmlGetFirstChild(b);
|
||||
if (node_type == MXML_OPAQUE && mxmlGetType(parent_node) == MXML_ELEMENT && node_value && !strcmp((char *) mxmlGetElement(parent_node), "string")) {
|
||||
if (node_type == MXML_OPAQUE && mxmlGetType(parent_node) == MXML_ELEMENT && node_value && !CWMP_STRCMP((char *) mxmlGetElement(parent_node), "string")) {
|
||||
parameter_name = icwmp_strdup(node_value);
|
||||
}
|
||||
if (node_type == MXML_ELEMENT && /* added in order to support GetParameterValues with empty string*/
|
||||
node_name != NULL && !strcmp(node_name, "string") && !firstchild) {
|
||||
!CWMP_STRCMP(node_name, "string") && !firstchild) {
|
||||
parameter_name = icwmp_strdup("");
|
||||
}
|
||||
if (parameter_name) {
|
||||
|
|
@ -1071,13 +1071,13 @@ int cwmp_handle_rpc_cpe_get_parameter_names(struct session *session, struct rpc
|
|||
mxml_type_t node_type = mxmlGetType(b);
|
||||
mxml_node_t *firstchild = mxmlGetFirstChild(b);
|
||||
|
||||
if (node_type == MXML_OPAQUE && node_value && mxmlGetType(parent) == MXML_ELEMENT && !strcmp((char *) mxmlGetElement(parent), "ParameterPath")) {
|
||||
if (node_type == MXML_OPAQUE && node_value && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP((char *) mxmlGetElement(parent), "ParameterPath")) {
|
||||
parameter_name = icwmp_strdup(node_value);
|
||||
}
|
||||
if (node_type == MXML_ELEMENT && node_name && !strcmp(node_name, "ParameterPath") && !firstchild) {
|
||||
if (node_type == MXML_ELEMENT && !CWMP_STRCMP(node_name, "ParameterPath") && !firstchild) {
|
||||
parameter_name = icwmp_strdup("");
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_value && mxmlGetType(parent) == MXML_ELEMENT && !strcmp((char *) mxmlGetElement(parent), "NextLevel")) {
|
||||
if (node_type == MXML_OPAQUE && node_value && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP((char *) mxmlGetElement(parent), "NextLevel")) {
|
||||
NextLevel = icwmp_strdup(node_value);
|
||||
}
|
||||
b = mxmlWalkNext(b, session->body_in, MXML_DESCEND);
|
||||
|
|
@ -1089,7 +1089,7 @@ int cwmp_handle_rpc_cpe_get_parameter_names(struct session *session, struct rpc
|
|||
}
|
||||
|
||||
if (parameter_name && NextLevel) {
|
||||
char *err = cwmp_get_parameter_names(parameter_name, strcmp(NextLevel, "true") == 0 || strcmp(NextLevel, "1") == 0 ? true : false, ¶meters_list);
|
||||
char *err = cwmp_get_parameter_names(parameter_name, cwmp_str_to_bool(NextLevel), ¶meters_list);
|
||||
if (err && !is_obj_excluded(parameter_name)) {
|
||||
fault_code = cwmp_get_fault_code_by_string(err);
|
||||
goto fault;
|
||||
|
|
@ -1186,10 +1186,10 @@ int cwmp_handle_rpc_cpe_get_parameter_attributes(struct session *session, struct
|
|||
mxml_type_t node_type = mxmlGetType(b);
|
||||
mxml_node_t *firstchild = mxmlGetFirstChild(b);
|
||||
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "string")) {
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "string")) {
|
||||
parameter_name = icwmp_strdup(node_opaque);
|
||||
}
|
||||
if (node_type == MXML_ELEMENT && !strcmp(node_name, "string") && !firstchild) {
|
||||
if (node_type == MXML_ELEMENT && !CWMP_STRCMP(node_name, "string") && !firstchild) {
|
||||
parameter_name = icwmp_strdup("");
|
||||
}
|
||||
if (parameter_name) {
|
||||
|
|
@ -1274,8 +1274,9 @@ static int is_duplicated_parameter(mxml_node_t *param_node, struct session *sess
|
|||
mxml_node_t *parent = mxmlGetParent(b);
|
||||
mxml_type_t node_type = mxmlGetType(b);
|
||||
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "Name")) {
|
||||
if (strcmp(node_opaque, mxmlGetOpaque(param_node)) == 0)
|
||||
if (node_type == MXML_OPAQUE && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "Name")) {
|
||||
const char *p_node = mxmlGetOpaque(param_node);
|
||||
if (CWMP_STRCMP(node_opaque, p_node) == 0)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -1307,7 +1308,7 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct session *session, struct rpc
|
|||
mxml_type_t node_type = mxmlGetType(b);
|
||||
mxml_node_t *child = mxmlGetFirstChild(b);
|
||||
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "Name")) {
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "Name")) {
|
||||
parameter_name = icwmp_strdup(node_opaque);
|
||||
if (is_duplicated_parameter(b, session)) {
|
||||
fault_code = FAULT_CPE_INVALID_ARGUMENTS;
|
||||
|
|
@ -1315,10 +1316,10 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct session *session, struct rpc
|
|||
}
|
||||
}
|
||||
|
||||
if (node_type == MXML_ELEMENT && !strcmp(node_name, "Name") && !child) {
|
||||
if (node_type == MXML_ELEMENT && !CWMP_STRCMP(node_name, "Name") && !child) {
|
||||
parameter_name = icwmp_strdup("");
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "Value")) {
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "Value")) {
|
||||
parameter_value = icwmp_strdup((char *)mxmlGetOpaque(b));
|
||||
while ((b = mxmlWalkNext(b, parent, MXML_DESCEND))) {
|
||||
v = (char *)mxmlGetOpaque(b);
|
||||
|
|
@ -1327,7 +1328,7 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct session *session, struct rpc
|
|||
}
|
||||
b = mxmlGetLastChild(parent);
|
||||
}
|
||||
if (node_type == MXML_ELEMENT && !strcmp(node_name, "Value") && !child) {
|
||||
if (node_type == MXML_ELEMENT && !CWMP_STRCMP(node_name, "Value") && !child) {
|
||||
parameter_value = icwmp_strdup("");
|
||||
}
|
||||
if (parameter_name && parameter_value) {
|
||||
|
|
@ -1433,27 +1434,27 @@ int cwmp_handle_rpc_cpe_set_parameter_attributes(struct session *session, struct
|
|||
mxml_type_t node_type = mxmlGetType(b);
|
||||
mxml_node_t *child = mxmlGetFirstChild(b);
|
||||
|
||||
if (node_type == MXML_ELEMENT && !strcmp(node_name, "SetParameterAttributesStruct")) {
|
||||
if (node_type == MXML_ELEMENT && !CWMP_STRCMP(node_name, "SetParameterAttributesStruct")) {
|
||||
parameter_name = NULL;
|
||||
parameter_notification = NULL;
|
||||
notification_change = NULL;
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "Name")) {
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "Name")) {
|
||||
parameter_name = icwmp_strdup(node_opaque);
|
||||
}
|
||||
if (node_type == MXML_ELEMENT && !strcmp(node_name, "Name") && !child) {
|
||||
if (node_type == MXML_ELEMENT && !CWMP_STRCMP(node_name, "Name") && !child) {
|
||||
parameter_name = icwmp_strdup("");
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "NotificationChange")) {
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "NotificationChange")) {
|
||||
notification_change = icwmp_strdup(node_opaque);
|
||||
}
|
||||
if (node_type == MXML_ELEMENT && !strcmp(node_name, "NotificationChange") && !child) {
|
||||
if (node_type == MXML_ELEMENT && !CWMP_STRCMP(node_name, "NotificationChange") && !child) {
|
||||
notification_change = icwmp_strdup("");
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "Notification")) {
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "Notification")) {
|
||||
parameter_notification = icwmp_strdup(node_opaque);
|
||||
}
|
||||
if (node_type == MXML_ELEMENT && !strcmp(node_name, "Notification") && !child) {
|
||||
if (node_type == MXML_ELEMENT && !CWMP_STRCMP(node_name, "Notification") && !child) {
|
||||
parameter_notification = icwmp_strdup("");
|
||||
}
|
||||
if (parameter_name && parameter_notification && notification_change) {
|
||||
|
|
@ -1513,10 +1514,10 @@ int cwmp_handle_rpc_cpe_add_object(struct session *session, struct rpc *rpc)
|
|||
mxml_node_t *parent = mxmlGetParent(b);
|
||||
mxml_type_t node_type = mxmlGetType(b);
|
||||
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "ParameterKey")) {
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "ParameterKey")) {
|
||||
parameter_key = icwmp_strdup(node_opaque);
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "ObjectName")) {
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "ObjectName")) {
|
||||
object_name = icwmp_strdup(node_opaque);
|
||||
}
|
||||
b = mxmlWalkNext(b, session->body_in, MXML_DESCEND);
|
||||
|
|
@ -1617,10 +1618,10 @@ int cwmp_handle_rpc_cpe_delete_object(struct session *session, struct rpc *rpc)
|
|||
mxml_node_t *parent = mxmlGetParent(b);
|
||||
mxml_type_t node_type = mxmlGetType(b);
|
||||
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "ObjectName")) {
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "ObjectName")) {
|
||||
object_name = icwmp_strdup(node_opaque);
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "ParameterKey")) {
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "ParameterKey")) {
|
||||
parameter_key = icwmp_strdup(node_opaque);
|
||||
}
|
||||
b = mxmlWalkNext(b, session->body_in, MXML_DESCEND);
|
||||
|
|
@ -1811,7 +1812,7 @@ int cwmp_handle_rpc_cpe_cancel_transfer(struct session *session, struct rpc *rpc
|
|||
mxml_node_t *parent = mxmlGetParent(b);
|
||||
mxml_type_t node_type = mxmlGetType(b);
|
||||
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "CommandKey")) {
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "CommandKey")) {
|
||||
command_key = icwmp_strdup(node_opaque);
|
||||
}
|
||||
b = mxmlWalkNext(b, session->body_in, MXML_DESCEND);
|
||||
|
|
@ -1847,7 +1848,7 @@ int cancel_transfer(char *key)
|
|||
if (list_download.next != &(list_download)) {
|
||||
list_for_each_safe (ilist, q, &(list_download)) {
|
||||
struct download *pdownload = list_entry(ilist, struct download, list);
|
||||
if (strcmp(pdownload->command_key, key) == 0) {
|
||||
if (CWMP_STRCMP(pdownload->command_key, key) == 0) {
|
||||
pthread_mutex_lock(&mutex_download);
|
||||
bkp_session_delete_download(pdownload);
|
||||
bkp_session_save();
|
||||
|
|
@ -1862,7 +1863,7 @@ int cancel_transfer(char *key)
|
|||
if (list_upload.next != &(list_upload)) {
|
||||
list_for_each_safe (ilist, q, &(list_upload)) {
|
||||
struct upload *pupload = list_entry(ilist, struct upload, list);
|
||||
if (strcmp(pupload->command_key, key) == 0) {
|
||||
if (CWMP_STRCMP(pupload->command_key, key) == 0) {
|
||||
pthread_mutex_lock(&mutex_upload);
|
||||
bkp_session_delete_upload(pupload);
|
||||
bkp_session_save();
|
||||
|
|
@ -1895,7 +1896,7 @@ int cwmp_handle_rpc_cpe_reboot(struct session *session, struct rpc *rpc)
|
|||
mxml_node_t *parent = mxmlGetParent(b);
|
||||
mxml_type_t node_type = mxmlGetType(b);
|
||||
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "CommandKey")) {
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "CommandKey")) {
|
||||
command_key = icwmp_strdup(node_opaque);
|
||||
commandKey = icwmp_strdup(node_opaque);
|
||||
}
|
||||
|
|
@ -1956,11 +1957,11 @@ int cwmp_handle_rpc_cpe_schedule_inform(struct session *session, struct rpc *rpc
|
|||
mxml_node_t *parent = mxmlGetParent(b);
|
||||
mxml_type_t node_type = mxmlGetType(b);
|
||||
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "CommandKey")) {
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "CommandKey")) {
|
||||
command_key = icwmp_strdup(node_opaque);
|
||||
}
|
||||
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "DelaySeconds")) {
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "DelaySeconds")) {
|
||||
delay_seconds = atoi(node_opaque);
|
||||
}
|
||||
b = mxmlWalkNext(b, session->body_in, MXML_DESCEND);
|
||||
|
|
@ -2005,7 +2006,7 @@ int cwmp_handle_rpc_cpe_schedule_inform(struct session *session, struct rpc *rpc
|
|||
pthread_mutex_unlock(&mutex_schedule_inform);
|
||||
goto fault;
|
||||
}
|
||||
schedule_inform->commandKey = strdup(command_key);
|
||||
schedule_inform->commandKey = CWMP_STRDUP(command_key);
|
||||
schedule_inform->scheduled_time = scheduled_time;
|
||||
list_add(&(schedule_inform->list), ilist->prev);
|
||||
bkp_session_insert_schedule_inform(schedule_inform->scheduled_time, schedule_inform->commandKey);
|
||||
|
|
@ -2062,9 +2063,9 @@ int cwmp_handle_rpc_cpe_change_du_state(struct session *session, struct rpc *rpc
|
|||
mxml_type_t node_type = mxmlGetType(b);
|
||||
mxml_node_t *parent = mxmlGetParent(b);
|
||||
t = b;
|
||||
if (node_type == MXML_ELEMENT && strcmp(node_name, "Operations") == 0) {
|
||||
if (node_type == MXML_ELEMENT && CWMP_STRCMP(node_name, "Operations") == 0) {
|
||||
char *operation = (char *)mxmlElementGetAttr(b, "xsi:type");
|
||||
if (!strcmp(operation, "cwmp:InstallOpStruct")) {
|
||||
if (!CWMP_STRCMP(operation, "cwmp:InstallOpStruct")) {
|
||||
elem = (operations *)calloc(1, sizeof(operations));
|
||||
elem->type = DU_INSTALL;
|
||||
list_add_tail(&(elem->list), &(change_du_state->list_operation));
|
||||
|
|
@ -2074,24 +2075,24 @@ int cwmp_handle_rpc_cpe_change_du_state(struct session *session, struct rpc *rpc
|
|||
mxml_node_t *prt = mxmlGetParent(t);
|
||||
mxml_type_t type = mxmlGetType(t);
|
||||
|
||||
if (type == MXML_OPAQUE && opaque && mxmlGetType(prt) == MXML_ELEMENT && !strcmp(mxmlGetElement(prt), "URL")) {
|
||||
elem->url = strdup(opaque);
|
||||
if (type == MXML_OPAQUE && mxmlGetType(prt) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(prt), "URL")) {
|
||||
elem->url = CWMP_STRDUP(opaque);
|
||||
}
|
||||
if (type == MXML_OPAQUE && opaque && mxmlGetType(prt) == MXML_ELEMENT && !strcmp(mxmlGetElement(prt), "UUID")) {
|
||||
elem->uuid = strdup(opaque);
|
||||
if (type == MXML_OPAQUE && mxmlGetType(prt) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(prt), "UUID")) {
|
||||
elem->uuid = CWMP_STRDUP(opaque);
|
||||
}
|
||||
if (type == MXML_OPAQUE && opaque && mxmlGetType(prt) == MXML_ELEMENT && !strcmp(mxmlGetElement(prt), "Username")) {
|
||||
elem->username = strdup(opaque);
|
||||
if (type == MXML_OPAQUE && mxmlGetType(prt) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(prt), "Username")) {
|
||||
elem->username = CWMP_STRDUP(opaque);
|
||||
}
|
||||
if (type == MXML_OPAQUE && opaque && mxmlGetType(prt) == MXML_ELEMENT && !strcmp(mxmlGetElement(prt), "Password")) {
|
||||
elem->password = strdup(opaque);
|
||||
if (type == MXML_OPAQUE && mxmlGetType(prt) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(prt), "Password")) {
|
||||
elem->password = CWMP_STRDUP(opaque);
|
||||
}
|
||||
if (type == MXML_OPAQUE && opaque && mxmlGetType(prt) == MXML_ELEMENT && !strcmp(mxmlGetElement(prt), "ExecutionEnvRef")) {
|
||||
elem->executionenvref = strdup(opaque);
|
||||
if (type == MXML_OPAQUE && mxmlGetType(prt) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(prt), "ExecutionEnvRef")) {
|
||||
elem->executionenvref = CWMP_STRDUP(opaque);
|
||||
}
|
||||
t = mxmlWalkNext(t, b, MXML_DESCEND);
|
||||
}
|
||||
} else if (!strcmp(operation, "cwmp:UpdateOpStruct")) {
|
||||
} else if (!CWMP_STRCMP(operation, "cwmp:UpdateOpStruct")) {
|
||||
elem = (operations *)calloc(1, sizeof(operations));
|
||||
elem->type = DU_UPDATE;
|
||||
list_add_tail(&(elem->list), &(change_du_state->list_operation));
|
||||
|
|
@ -2101,25 +2102,25 @@ int cwmp_handle_rpc_cpe_change_du_state(struct session *session, struct rpc *rpc
|
|||
mxml_node_t *prt = mxmlGetParent(t);
|
||||
mxml_type_t type = mxmlGetType(t);
|
||||
|
||||
if (type == MXML_OPAQUE && opaque && mxmlGetType(prt) == MXML_ELEMENT && !strcmp(mxmlGetElement(prt), "Username")) {
|
||||
elem->url = strdup(opaque);
|
||||
if (type == MXML_OPAQUE && mxmlGetType(prt) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(prt), "Username")) {
|
||||
elem->url = CWMP_STRDUP(opaque);
|
||||
}
|
||||
if (type == MXML_OPAQUE && opaque && mxmlGetType(prt) == MXML_ELEMENT && !strcmp(mxmlGetElement(prt), "Version")) {
|
||||
elem->uuid = strdup(opaque);
|
||||
if (type == MXML_OPAQUE && mxmlGetType(prt) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(prt), "Version")) {
|
||||
elem->uuid = CWMP_STRDUP(opaque);
|
||||
}
|
||||
if (type == MXML_OPAQUE && opaque && mxmlGetType(prt) == MXML_ELEMENT && !strcmp(mxmlGetElement(prt), "URL")) {
|
||||
elem->username = strdup(opaque);
|
||||
if (type == MXML_OPAQUE && mxmlGetType(prt) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(prt), "URL")) {
|
||||
elem->username = CWMP_STRDUP(opaque);
|
||||
}
|
||||
if (type == MXML_OPAQUE && opaque && mxmlGetType(prt) == MXML_ELEMENT && !strcmp(mxmlGetElement(prt), "Password")) {
|
||||
elem->password = strdup(opaque);
|
||||
if (type == MXML_OPAQUE && mxmlGetType(prt) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(prt), "Password")) {
|
||||
elem->password = CWMP_STRDUP(opaque);
|
||||
}
|
||||
if (type == MXML_OPAQUE && opaque && mxmlGetType(prt) == MXML_ELEMENT && !strcmp(mxmlGetElement(prt), "UUID")) {
|
||||
elem->executionenvref = strdup(opaque);
|
||||
if (type == MXML_OPAQUE && mxmlGetType(prt) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(prt), "UUID")) {
|
||||
elem->executionenvref = CWMP_STRDUP(opaque);
|
||||
}
|
||||
|
||||
t = mxmlWalkNext(t, b, MXML_DESCEND);
|
||||
}
|
||||
} else if (!strcmp(operation, "cwmp:UninstallOpStruct")) {
|
||||
} else if (!CWMP_STRCMP(operation, "cwmp:UninstallOpStruct")) {
|
||||
elem = (operations *)calloc(1, sizeof(operations));
|
||||
elem->type = DU_UNINSTALL;
|
||||
list_add_tail(&(elem->list), &(change_du_state->list_operation));
|
||||
|
|
@ -2129,22 +2130,22 @@ int cwmp_handle_rpc_cpe_change_du_state(struct session *session, struct rpc *rpc
|
|||
mxml_node_t *prt = mxmlGetParent(t);
|
||||
mxml_type_t type = mxmlGetType(t);
|
||||
|
||||
if (type == MXML_OPAQUE && opaque && mxmlGetType(prt) == MXML_ELEMENT && !strcmp(mxmlGetElement(prt), "Version")) {
|
||||
elem->url = strdup(opaque);
|
||||
if (type == MXML_OPAQUE && mxmlGetType(prt) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(prt), "Version")) {
|
||||
elem->url = CWMP_STRDUP(opaque);
|
||||
}
|
||||
if (type == MXML_OPAQUE && opaque && mxmlGetType(prt) == MXML_ELEMENT && !strcmp(mxmlGetElement(prt), "ExecutionEnvRef")) {
|
||||
elem->uuid = strdup(opaque);
|
||||
if (type == MXML_OPAQUE && mxmlGetType(prt) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(prt), "ExecutionEnvRef")) {
|
||||
elem->uuid = CWMP_STRDUP(opaque);
|
||||
}
|
||||
if (type == MXML_OPAQUE && opaque && mxmlGetType(prt) == MXML_ELEMENT && !strcmp(mxmlGetElement(prt), "URL")) {
|
||||
elem->username = strdup(opaque);
|
||||
if (type == MXML_OPAQUE && mxmlGetType(prt) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(prt), "URL")) {
|
||||
elem->username = CWMP_STRDUP(opaque);
|
||||
}
|
||||
|
||||
t = mxmlWalkNext(t, b, MXML_DESCEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "CommandKey")) {
|
||||
change_du_state->command_key = strdup(node_opaque);
|
||||
if (node_type == MXML_OPAQUE && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "CommandKey")) {
|
||||
change_du_state->command_key = CWMP_STRDUP(node_opaque);
|
||||
}
|
||||
b = mxmlWalkNext(b, n, MXML_DESCEND);
|
||||
}
|
||||
|
|
@ -2259,12 +2260,12 @@ int cwmp_handle_rpc_cpe_download(struct session *session, struct rpc *rpc)
|
|||
mxml_node_t *parent = mxmlGetParent(b);
|
||||
mxml_type_t node_type = mxmlGetType(b);
|
||||
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "CommandKey")) {
|
||||
download->command_key = strdup(node_opaque);
|
||||
if (node_type == MXML_OPAQUE && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "CommandKey")) {
|
||||
download->command_key = CWMP_STRDUP(node_opaque);
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "FileType")) {
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "FileType")) {
|
||||
if (download->file_type == NULL) {
|
||||
download->file_type = strdup(node_opaque);
|
||||
download->file_type = CWMP_STRDUP(node_opaque);
|
||||
file_type = icwmp_strdup(node_opaque);
|
||||
} else {
|
||||
tmp = file_type;
|
||||
|
|
@ -2274,21 +2275,21 @@ int cwmp_handle_rpc_cpe_download(struct session *session, struct rpc *rpc)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "URL")) {
|
||||
download->url = strdup(node_opaque);
|
||||
if (node_type == MXML_OPAQUE && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "URL")) {
|
||||
download->url = CWMP_STRDUP(node_opaque);
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "Username")) {
|
||||
download->username = strdup(node_opaque);
|
||||
if (node_type == MXML_OPAQUE && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "Username")) {
|
||||
download->username = CWMP_STRDUP(node_opaque);
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "Password")) {
|
||||
download->password = strdup(node_opaque);
|
||||
if (node_type == MXML_OPAQUE && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "Password")) {
|
||||
download->password = CWMP_STRDUP(node_opaque);
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "FileSize")) {
|
||||
str_file_size = strdup(node_opaque ? node_opaque: "0");
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "FileSize")) {
|
||||
str_file_size = CWMP_STRDUP_DEF(node_opaque, "0");
|
||||
download->file_size = atoi(node_opaque);
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "DelaySeconds")) {
|
||||
str_download_delay = strdup(node_opaque ? node_opaque: "0");
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "DelaySeconds")) {
|
||||
str_download_delay = CWMP_STRDUP_DEF(node_opaque, "0");
|
||||
download_delay = atol(node_opaque);
|
||||
}
|
||||
b = mxmlWalkNext(b, n, MXML_DESCEND);
|
||||
|
|
@ -2322,15 +2323,15 @@ int cwmp_handle_rpc_cpe_download(struct session *session, struct rpc *rpc)
|
|||
}
|
||||
FREE(str_download_delay);
|
||||
|
||||
if (strcmp(file_type, FIRMWARE_UPGRADE_IMAGE_FILE_TYPE) && strcmp(file_type, WEB_CONTENT_FILE_TYPE) && strcmp(file_type, VENDOR_CONFIG_FILE_TYPE) && strcmp(file_type, TONE_FILE_TYPE) && strcmp(file_type, RINGER_FILE_TYPE) && strcmp(file_type, STORED_FIRMWARE_IMAGE_FILE_TYPE)) {
|
||||
if (CWMP_STRCMP(file_type, FIRMWARE_UPGRADE_IMAGE_FILE_TYPE) && CWMP_STRCMP(file_type, WEB_CONTENT_FILE_TYPE) && CWMP_STRCMP(file_type, VENDOR_CONFIG_FILE_TYPE) && CWMP_STRCMP(file_type, TONE_FILE_TYPE) && CWMP_STRCMP(file_type, RINGER_FILE_TYPE) && CWMP_STRCMP(file_type, STORED_FIRMWARE_IMAGE_FILE_TYPE)) {
|
||||
error = FAULT_CPE_INVALID_ARGUMENTS;
|
||||
} else if (count_download_queue >= MAX_DOWNLOAD_QUEUE) {
|
||||
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;
|
||||
} else if (strstr(download->url, "@") != NULL) {
|
||||
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, CWMP_STRLEN(DOWNLOAD_PROTOCOL_HTTP)) != 0 && CWMP_STRNCMP(download->url, DOWNLOAD_PROTOCOL_HTTPS, CWMP_STRLEN(DOWNLOAD_PROTOCOL_HTTPS)) != 0 && CWMP_STRNCMP(download->url, DOWNLOAD_PROTOCOL_FTP, CWMP_STRLEN(DOWNLOAD_PROTOCOL_FTP)) != 0) {
|
||||
error = FAULT_CPE_FILE_TRANSFER_UNSUPPORTED_PROTOCOL;
|
||||
}
|
||||
if (error != FAULT_CPE_NO_FAULT)
|
||||
|
|
@ -2413,10 +2414,10 @@ int cwmp_handle_rpc_cpe_schedule_download(struct session *session, struct rpc *r
|
|||
mxml_node_t *parent = mxmlGetParent(b);
|
||||
mxml_type_t node_type = mxmlGetType(b);
|
||||
t = b;
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "CommandKey")) {
|
||||
schedule_download->command_key = strdup(node_opaque);
|
||||
if (node_type == MXML_OPAQUE && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "CommandKey")) {
|
||||
schedule_download->command_key = CWMP_STRDUP(node_opaque);
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "FileType")) {
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "FileType")) {
|
||||
if (schedule_download->file_type != NULL) {
|
||||
tmp = file_type;
|
||||
if (cwmp_asprintf(&file_type, "%s %s", tmp, node_opaque) == -1) {
|
||||
|
|
@ -2424,24 +2425,24 @@ int cwmp_handle_rpc_cpe_schedule_download(struct session *session, struct rpc *r
|
|||
goto fault;
|
||||
}
|
||||
} else {
|
||||
schedule_download->file_type = strdup(node_opaque);
|
||||
schedule_download->file_type = CWMP_STRDUP(node_opaque);
|
||||
file_type = icwmp_strdup(node_opaque);
|
||||
}
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "URL")) {
|
||||
schedule_download->url = strdup(node_opaque);
|
||||
if (node_type == MXML_OPAQUE && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "URL")) {
|
||||
schedule_download->url = CWMP_STRDUP(node_opaque);
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "Username")) {
|
||||
schedule_download->username = strdup(node_opaque);
|
||||
if (node_type == MXML_OPAQUE && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "Username")) {
|
||||
schedule_download->username = CWMP_STRDUP(node_opaque);
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "Password")) {
|
||||
schedule_download->password = strdup(node_opaque);
|
||||
if (node_type == MXML_OPAQUE && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "Password")) {
|
||||
schedule_download->password = CWMP_STRDUP(node_opaque);
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "FileSize")) {
|
||||
str_file_size = strdup(node_opaque);
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "FileSize")) {
|
||||
str_file_size = CWMP_STRDUP(node_opaque);
|
||||
schedule_download->file_size = atoi(node_opaque);
|
||||
}
|
||||
if (node_type== MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "TimeWindowList")) {
|
||||
if (node_type== MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "TimeWindowList")) {
|
||||
if (!t)
|
||||
return -1; //TO CHECK*/
|
||||
t = mxmlWalkNext(t, b, MXML_DESCEND);
|
||||
|
|
@ -2450,17 +2451,17 @@ int cwmp_handle_rpc_cpe_schedule_download(struct session *session, struct rpc *r
|
|||
mxml_node_t *prt = mxmlGetParent(t);
|
||||
mxml_type_t type = mxmlGetType(t);
|
||||
|
||||
if (type == MXML_OPAQUE && node_opaque && mxmlGetType(prt) == MXML_ELEMENT && !strcmp(mxmlGetElement(prt), "WindowStart")) {
|
||||
if (type == MXML_OPAQUE && node_opaque && mxmlGetType(prt) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(prt), "WindowStart")) {
|
||||
schedule_download_delay[j] = atol(opaque);
|
||||
j++;
|
||||
}
|
||||
if (type == MXML_OPAQUE && opaque && mxmlGetType(prt) == MXML_ELEMENT && !strcmp(mxmlGetElement(prt), "WindowEnd")) {
|
||||
if (type == MXML_OPAQUE && opaque && mxmlGetType(prt) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(prt), "WindowEnd")) {
|
||||
schedule_download_delay[j] = atol(opaque);
|
||||
j++;
|
||||
}
|
||||
if (type == MXML_OPAQUE && opaque && mxmlGetType(prt) == MXML_ELEMENT && !strcmp(mxmlGetElement(prt), "WindowMode")) {
|
||||
if (type == MXML_OPAQUE && opaque && mxmlGetType(prt) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(prt), "WindowMode")) {
|
||||
if (schedule_download->timewindowstruct[i].windowmode == NULL) {
|
||||
schedule_download->timewindowstruct[i].windowmode = strdup(opaque);
|
||||
schedule_download->timewindowstruct[i].windowmode = CWMP_STRDUP(opaque);
|
||||
if (i == 0)
|
||||
windowmode0 = icwmp_strdup(opaque);
|
||||
else
|
||||
|
|
@ -2479,10 +2480,10 @@ int cwmp_handle_rpc_cpe_schedule_download(struct session *session, struct rpc *r
|
|||
}
|
||||
}
|
||||
}
|
||||
if (type == MXML_OPAQUE && opaque && mxmlGetType(prt) == MXML_ELEMENT && !strcmp(mxmlGetElement(prt), "UserMessage")) {
|
||||
schedule_download->timewindowstruct[i].usermessage = strdup(opaque);
|
||||
if (type == MXML_OPAQUE && mxmlGetType(prt) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(prt), "UserMessage")) {
|
||||
schedule_download->timewindowstruct[i].usermessage = CWMP_STRDUP(opaque);
|
||||
}
|
||||
if (type == MXML_OPAQUE && opaque && mxmlGetType(prt) == MXML_ELEMENT && !strcmp(mxmlGetElement(prt), "MaxRetries")) {
|
||||
if (type == MXML_OPAQUE && opaque && mxmlGetType(prt) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(prt), "MaxRetries")) {
|
||||
schedule_download->timewindowstruct[i].maxretries = atoi(opaque);
|
||||
}
|
||||
t = mxmlWalkNext(t, b, MXML_DESCEND);
|
||||
|
|
@ -2513,17 +2514,17 @@ int cwmp_handle_rpc_cpe_schedule_download(struct session *session, struct rpc *r
|
|||
goto fault;
|
||||
}
|
||||
FREE(str_file_size);
|
||||
if (strcmp(file_type, FIRMWARE_UPGRADE_IMAGE_FILE_TYPE) && strcmp(file_type, WEB_CONTENT_FILE_TYPE) && strcmp(file_type, VENDOR_CONFIG_FILE_TYPE) && strcmp(file_type, TONE_FILE_TYPE) && strcmp(file_type, RINGER_FILE_TYPE) && strcmp(file_type, STORED_FIRMWARE_IMAGE_FILE_TYPE)) {
|
||||
if (CWMP_STRCMP(file_type, FIRMWARE_UPGRADE_IMAGE_FILE_TYPE) && CWMP_STRCMP(file_type, WEB_CONTENT_FILE_TYPE) && CWMP_STRCMP(file_type, VENDOR_CONFIG_FILE_TYPE) && CWMP_STRCMP(file_type, TONE_FILE_TYPE) && CWMP_STRCMP(file_type, RINGER_FILE_TYPE) && CWMP_STRCMP(file_type, STORED_FIRMWARE_IMAGE_FILE_TYPE)) {
|
||||
error = FAULT_CPE_INVALID_ARGUMENTS;
|
||||
} else if ((strcmp(windowmode0, "1 At Any Time") && strcmp(windowmode0, "2 Immediately") && strcmp(windowmode0, "3 When Idle")) || (strcmp(windowmode1, "1 At Any Time") && strcmp(windowmode1, "2 Immediately") && strcmp(windowmode1, "3 When Idle"))) {
|
||||
} else if ((CWMP_STRCMP(windowmode0, "1 At Any Time") && CWMP_STRCMP(windowmode0, "2 Immediately") && CWMP_STRCMP(windowmode0, "3 When Idle")) || (CWMP_STRCMP(windowmode1, "1 At Any Time") && CWMP_STRCMP(windowmode1, "2 Immediately") && CWMP_STRCMP(windowmode1, "3 When Idle"))) {
|
||||
error = FAULT_CPE_REQUEST_DENIED;
|
||||
} else if (count_download_queue >= MAX_DOWNLOAD_QUEUE) {
|
||||
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;
|
||||
} else if (strstr(schedule_download->url, "@") != NULL) {
|
||||
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, CWMP_STRLEN(DOWNLOAD_PROTOCOL_HTTP)) != 0 && CWMP_STRNCMP(schedule_download->url, DOWNLOAD_PROTOCOL_FTP, CWMP_STRLEN(DOWNLOAD_PROTOCOL_FTP)) != 0) {
|
||||
error = FAULT_CPE_FILE_TRANSFER_UNSUPPORTED_PROTOCOL;
|
||||
} else {
|
||||
for (j = 0; j < 3; j++) {
|
||||
|
|
@ -2614,20 +2615,20 @@ int cwmp_handle_rpc_cpe_upload(struct session *session, struct rpc *rpc)
|
|||
mxml_node_t *parent = mxmlGetParent(b);
|
||||
mxml_type_t node_type = mxmlGetType(b);
|
||||
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "CommandKey")) {
|
||||
upload->command_key = strdup(node_opaque);
|
||||
if (node_type == MXML_OPAQUE && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "CommandKey")) {
|
||||
upload->command_key = CWMP_STRDUP(node_opaque);
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "FileType")) {
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "FileType")) {
|
||||
char log_config[16]={0};
|
||||
int ftype, instance = 0;
|
||||
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) {
|
||||
error = FAULT_CPE_INVALID_ARGUMENTS;
|
||||
goto fault;
|
||||
} else if (strcmp(log_config, "Configuration") == 0 && ftype != 1 && ftype != 3) {
|
||||
} else if (CWMP_STRCMP(log_config, "Configuration") == 0 && ftype != 1 && ftype != 3) {
|
||||
error = FAULT_CPE_INVALID_ARGUMENTS;
|
||||
goto fault;
|
||||
} else if (strcmp(log_config, "Log") == 0 && ftype != 2 && ftype != 4) {
|
||||
} else if (CWMP_STRCMP(log_config, "Log") == 0 && ftype != 2 && ftype != 4) {
|
||||
error = FAULT_CPE_INVALID_ARGUMENTS;
|
||||
goto fault;
|
||||
}
|
||||
|
|
@ -2639,20 +2640,20 @@ int cwmp_handle_rpc_cpe_upload(struct session *session, struct rpc *rpc)
|
|||
error = FAULT_CPE_INVALID_ARGUMENTS;
|
||||
goto fault;
|
||||
}
|
||||
upload->file_type = strdup(node_opaque);
|
||||
upload->file_type = CWMP_STRDUP(node_opaque);
|
||||
upload->f_instance = instance;
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "URL")) {
|
||||
upload->url = strdup(node_opaque);
|
||||
if (node_type == MXML_OPAQUE && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "URL")) {
|
||||
upload->url = CWMP_STRDUP(node_opaque);
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "Username")) {
|
||||
upload->username = strdup(node_opaque);
|
||||
if (node_type == MXML_OPAQUE && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "Username")) {
|
||||
upload->username = CWMP_STRDUP(node_opaque);
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "Password")) {
|
||||
upload->password = strdup(node_opaque);
|
||||
if (node_type == MXML_OPAQUE && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "Password")) {
|
||||
upload->password = CWMP_STRDUP(node_opaque);
|
||||
}
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !strcmp(mxmlGetElement(parent), "DelaySeconds")) {
|
||||
str_upload_delay = strdup(node_opaque);
|
||||
if (node_type == MXML_OPAQUE && node_opaque && mxmlGetType(parent) == MXML_ELEMENT && !CWMP_STRCMP(mxmlGetElement(parent), "DelaySeconds")) {
|
||||
str_upload_delay = CWMP_STRDUP(node_opaque);
|
||||
upload_delay = atol(node_opaque);
|
||||
}
|
||||
b = mxmlWalkNext(b, n, MXML_DESCEND);
|
||||
|
|
@ -2682,11 +2683,11 @@ int cwmp_handle_rpc_cpe_upload(struct session *session, struct rpc *rpc)
|
|||
|
||||
if (count_download_queue >= MAX_DOWNLOAD_QUEUE) {
|
||||
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;
|
||||
} else if (strstr(upload->url, "@") != NULL) {
|
||||
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, CWMP_STRLEN(DOWNLOAD_PROTOCOL_HTTPS)) != 0 && CWMP_STRNCMP(upload->url, DOWNLOAD_PROTOCOL_HTTP, CWMP_STRLEN(DOWNLOAD_PROTOCOL_HTTP)) != 0 && CWMP_STRNCMP(upload->url, DOWNLOAD_PROTOCOL_FTP, CWMP_STRLEN(DOWNLOAD_PROTOCOL_FTP)) != 0) {
|
||||
error = FAULT_CPE_FILE_TRANSFER_UNSUPPORTED_PROTOCOL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ static int call_command_cb(char *cmd, struct blob_buf *b)
|
|||
|
||||
cmd_num = sizeof(cmd_cb)/sizeof(struct command_cb);
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
27
upload.c
27
upload.c
|
|
@ -38,7 +38,7 @@ int lookup_vcf_name(int instance, char **value)
|
|||
}
|
||||
struct cwmp_dm_parameter *param_value;
|
||||
list_for_each_entry (param_value, &vcf_parameters, list) {
|
||||
*value = param_value->value ? strdup(param_value->value) : NULL;
|
||||
*value = CWMP_STRDUP(param_value->value);
|
||||
break;
|
||||
}
|
||||
cwmp_free_all_dm_parameter_list(&vcf_parameters);
|
||||
|
|
@ -56,7 +56,7 @@ int lookup_vlf_name(int instance, char **value)
|
|||
}
|
||||
struct cwmp_dm_parameter *param_value;
|
||||
list_for_each_entry (param_value, &vlf_parameters, list) {
|
||||
*value = param_value->value ? strdup(param_value->value) : NULL;
|
||||
*value = CWMP_STRDUP(param_value->value);
|
||||
break;
|
||||
}
|
||||
cwmp_free_all_dm_parameter_list(&vlf_parameters);
|
||||
|
|
@ -85,7 +85,7 @@ int upload_file(const char *file_path, const char *url, const char *username, co
|
|||
|
||||
snprintf(userpass, sizeof(userpass), "%s:%s", username, password);
|
||||
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_TIMEOUT, CURL_TIMEOUT);
|
||||
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 50L);
|
||||
|
|
@ -129,8 +129,7 @@ int cwmp_launch_upload(struct upload *pupload, struct transfer_complete **ptrans
|
|||
copy("/var/log/syslog", file_path);
|
||||
} else if (pupload->file_type[0] == '3') {
|
||||
lookup_vcf_name(pupload->f_instance, &name);
|
||||
if (name && strlen(name) > 0) {
|
||||
// cppcheck-suppress uninitvar
|
||||
if (CWMP_STRLEN(name) > 0) {
|
||||
snprintf(file_path, sizeof(file_path), "/tmp/%s", name);
|
||||
cwmp_uci_init();
|
||||
cwmp_uci_export_package(name, file_path, UCI_STANDARD_CONFIG);
|
||||
|
|
@ -142,7 +141,7 @@ int cwmp_launch_upload(struct upload *pupload, struct transfer_complete **ptrans
|
|||
}
|
||||
} else { //file_type is 4
|
||||
lookup_vlf_name(pupload->f_instance, &name);
|
||||
if (name && strlen(name) > 0) {
|
||||
if (CWMP_STRLEN(name) > 0) {
|
||||
snprintf(file_path, sizeof(file_path), "/tmp/%s", name);
|
||||
copy(name, file_path);
|
||||
FREE(name);
|
||||
|
|
@ -150,7 +149,7 @@ int cwmp_launch_upload(struct upload *pupload, struct transfer_complete **ptrans
|
|||
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;
|
||||
goto end_upload;
|
||||
}
|
||||
|
|
@ -169,9 +168,10 @@ end_upload:
|
|||
return error;
|
||||
}
|
||||
|
||||
p->command_key = pupload->command_key ? strdup(pupload->command_key) : strdup("");
|
||||
p->start_time = strdup(upload_startTime);
|
||||
p->complete_time = strdup(get_time(time(NULL)));
|
||||
p->command_key = CWMP_STRDUP_DEF(pupload->command_key, "");
|
||||
p->start_time = CWMP_STRDUP(upload_startTime);
|
||||
char *end_time = get_time(time(NULL));
|
||||
p->complete_time = CWMP_STRDUP(end_time);
|
||||
p->type = TYPE_UPLOAD;
|
||||
if (error != FAULT_CPE_NO_FAULT) {
|
||||
p->fault_code = error;
|
||||
|
|
@ -211,9 +211,10 @@ void *thread_cwmp_rpc_cpe_upload(void *v)
|
|||
if (ptransfer_complete != NULL) {
|
||||
error = FAULT_CPE_DOWNLOAD_FAILURE;
|
||||
|
||||
ptransfer_complete->command_key = strdup(pupload->command_key);
|
||||
ptransfer_complete->start_time = strdup(get_time(time(NULL)));
|
||||
ptransfer_complete->complete_time = strdup(ptransfer_complete->start_time);
|
||||
ptransfer_complete->command_key = CWMP_STRDUP(pupload->command_key);
|
||||
char *start_time = get_time(time(NULL));
|
||||
ptransfer_complete->start_time = CWMP_STRDUP(start_time);
|
||||
ptransfer_complete->complete_time = CWMP_STRDUP(ptransfer_complete->start_time);
|
||||
ptransfer_complete->fault_code = error;
|
||||
ptransfer_complete->type = TYPE_UPLOAD;
|
||||
bkp_session_insert_transfer_complete(ptransfer_complete);
|
||||
|
|
|
|||
16
xml.c
16
xml.c
|
|
@ -36,7 +36,7 @@ mxmlFindElementOpaque(mxml_node_t *node, /* I - Current node */
|
|||
|
||||
while (node != NULL) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ char *xml__get_attribute_name_by_value(mxml_node_t *node, const char *value)
|
|||
for (i = 0; i < attributes_nbre; i++) {
|
||||
char *attr_name = NULL;
|
||||
const char *attr_value = mxmlElementGetAttrByIndex(node, i, (const char **)&attr_name);
|
||||
if (strcmp(attr_value, value) == 0)
|
||||
if (CWMP_STRCMP(attr_value, value) == 0)
|
||||
return attr_name;
|
||||
}
|
||||
return NULL;
|
||||
|
|
@ -77,28 +77,28 @@ int xml_recreate_namespace(mxml_node_t *tree)
|
|||
|
||||
c = (char *)xml__get_attribute_name_by_value(b, soap_env_url);
|
||||
if (c && *(c + 5) == ':') {
|
||||
ns.soap_env = strdup((c + 6));
|
||||
ns.soap_env = CWMP_STRDUP((c + 6));
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
c = (char *)xml__get_attribute_name_by_value(b, soap_enc_url);
|
||||
if (c && *(c + 5) == ':') {
|
||||
ns.soap_enc = strdup((c + 6));
|
||||
ns.soap_enc = CWMP_STRDUP((c + 6));
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
c = (char *)xml__get_attribute_name_by_value(b, xsd_url);
|
||||
if (c && *(c + 5) == ':') {
|
||||
ns.xsd = strdup((c + 6));
|
||||
ns.xsd = CWMP_STRDUP((c + 6));
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
c = (char *)xml__get_attribute_name_by_value(b, xsi_url);
|
||||
if (c && *(c + 5) == ':') {
|
||||
ns.xsi = strdup((c + 6));
|
||||
ns.xsi = CWMP_STRDUP((c + 6));
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -107,7 +107,7 @@ int xml_recreate_namespace(mxml_node_t *tree)
|
|||
cwmp_urn = cwmp_urls[i];
|
||||
c = (char *)xml__get_attribute_name_by_value(b, cwmp_urn);
|
||||
if (c && *(c + 5) == ':') {
|
||||
ns.cwmp = strdup((c + 6));
|
||||
ns.cwmp = CWMP_STRDUP((c + 6));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ int xml_send_message(struct cwmp *cwmp, struct session *session, struct rpc *rpc
|
|||
FREE(msg_out);
|
||||
msg_out = (char *)zmsg_out;
|
||||
} else {
|
||||
msg_out_len = strlen(msg_out);
|
||||
msg_out_len = CWMP_STRLEN(msg_out);
|
||||
}
|
||||
}
|
||||
while (1) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue