mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
Align with code-analysis image
This commit is contained in:
parent
75b3e8ccb6
commit
14f3375ab8
39 changed files with 493 additions and 368 deletions
|
|
@ -1,22 +1,16 @@
|
|||
variables:
|
||||
DEBUG: 'TRUE'
|
||||
SOURCE_FOLDER: "./src"
|
||||
FLAWFINDER_OPTIONS: "-m 4 --error-level=5"
|
||||
CPPCHECK_OPTIONS: " --enable=all --error-exitcode=1 -D_GNU_SOURCE --suppress=unusedFunction -i ./test/ --inline-suppr"
|
||||
SOURCE_FOLDER: "."
|
||||
COMPILATION_FIXUP: "cmake ."
|
||||
|
||||
include:
|
||||
- project: 'iopsys/gitlab-ci-pipeline'
|
||||
file: '/static-code-analysis.yml'
|
||||
ref: '0.32'
|
||||
- project: 'docs/portal2/pipeline-template'
|
||||
file: 'MkDocs.gitlab-ci.yml'
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == "devel"
|
||||
ref: '1.2'
|
||||
|
||||
stages:
|
||||
- static_code_analysis
|
||||
- pipeline_test
|
||||
- deploy
|
||||
|
||||
run_unit_test:
|
||||
stage: pipeline_test
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ struct manageable_device_node
|
|||
struct manageable_device_args dev;
|
||||
};
|
||||
|
||||
static struct uci_section* get_autonomous_notify_section(char *sec_name)
|
||||
static struct uci_section* get_autonomous_notify_section(const char *sec_name)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
uci_foreach_sections("cwmp", "autonomous_notify", s) {
|
||||
|
|
@ -168,7 +168,7 @@ static bool is_active_host(const char *mac, json_object *res)
|
|||
static char *dm_ioctl_get_ipv4(char *interface_name)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
char *ip = "";
|
||||
char *ip = NULL;
|
||||
int fd;
|
||||
|
||||
if (!DM_STRLEN(interface_name))
|
||||
|
|
@ -201,7 +201,7 @@ static char *dm_ifaddrs_get_global_ipv6(char *interface_name)
|
|||
struct ifaddrs *ifaddr = NULL,*ifa = NULL;
|
||||
void *in_addr = NULL;
|
||||
int family, err = 0;
|
||||
char *ip = "";
|
||||
char *ip = NULL;
|
||||
|
||||
if (!DM_STRLEN(interface_name))
|
||||
return ip;
|
||||
|
|
@ -250,6 +250,7 @@ static int browseManageableDevice(struct dmctx *dmctx, DMNODE *parent_node, void
|
|||
{
|
||||
#define DHCP_CLIENT_OPTIONS_FILE "/var/dhcp.client.options"
|
||||
|
||||
// cppcheck-suppress cert-MSC24-C
|
||||
FILE *f = fopen(DHCP_CLIENT_OPTIONS_FILE, "r");
|
||||
if (f == NULL)
|
||||
return 0;
|
||||
|
|
@ -343,8 +344,6 @@ static int get_management_server_url(char *refparam, struct dmctx *ctx, void *da
|
|||
*value = dhcp_url;
|
||||
else if (DM_STRLEN(url) != 0)
|
||||
*value = url;
|
||||
else
|
||||
*value = "";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -639,7 +638,7 @@ static int set_upgrades_managed(char *refparam, struct dmctx *ctx, void *data, c
|
|||
|
||||
static int get_lwn_protocol_supported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = "UDP";
|
||||
*value = dmstrdup("UDP");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -716,7 +715,7 @@ static int set_lwn_port(char *refparam, struct dmctx *ctx, void *data, char *ins
|
|||
|
||||
static int get_management_server_http_compression_supportted(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = "GZIP,Deflate";
|
||||
*value = dmstrdup("GZIP,Deflate");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -842,21 +841,19 @@ static int set_instance_mode(char *refparam, struct dmctx *ctx, void *data, char
|
|||
|
||||
static int get_management_server_supported_conn_req_methods(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = "HTTP,XMPP,STUN";
|
||||
*value = dmstrdup("HTTP,XMPP,STUN");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_management_server_instance_wildcard_supported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = "true";
|
||||
*value = dmstrdup("true");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_management_server_enable_cwmp(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("cwmp", "cpe", "enable", value);
|
||||
if ((*value)[0] == '\0')
|
||||
*value = "1";
|
||||
*value = dmuci_get_option_value_fallback_def("cwmp", "cpe", "enable", "1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -890,7 +887,7 @@ static int get_nat_detected(char *refparam, struct dmctx *ctx, void *data, char
|
|||
en = dmuci_string_to_boolean(v);
|
||||
*value = (en == true) ? "1" : "0";
|
||||
} else {
|
||||
*value = "0";
|
||||
*value = dmstrdup("0");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1164,10 +1161,7 @@ static int get_manageable_device_host(char *refparam, struct dmctx *ctx, void *d
|
|||
|
||||
static int get_transfer_compl_policy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("cwmp", TRANSFER_COMPL_SEC_NAME, "enable", value);
|
||||
if (DM_STRLEN(*value) == 0)
|
||||
*value = "0";
|
||||
|
||||
*value = dmuci_get_option_value_fallback_def("cwmp", TRANSFER_COMPL_SEC_NAME, "enable", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1266,10 +1260,7 @@ static int set_transfer_compl_policy_file_type_filter(char *refparam, struct dmc
|
|||
|
||||
static int get_du_state_change_compl_policy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("cwmp", DU_STATE_CHANGE_SEC_NAME, "enable", value);
|
||||
if (DM_STRLEN(*value) == 0)
|
||||
*value = "0";
|
||||
|
||||
*value = dmuci_get_option_value_fallback_def("cwmp", DU_STATE_CHANGE_SEC_NAME, "enable", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ enum autonomous_notif_type {
|
|||
typedef void (*autonomous_event_callback)(struct blob_attr *msg);
|
||||
|
||||
struct autonomous_event {
|
||||
char name[2048];
|
||||
autonomous_event_callback cb;
|
||||
char name[2048];
|
||||
};
|
||||
|
||||
static void free_autonomous_du_state_change_complete_data(auto_du_state_change_compl *p);
|
||||
|
|
@ -283,8 +283,8 @@ static void send_transfer_complete_notif(struct blob_attr *msg)
|
|||
}
|
||||
|
||||
static struct autonomous_event event_info[] = {
|
||||
{ "Device.SoftwareModules.DUStateChange!", send_du_state_change_notif },
|
||||
{ "Device.LocalAgent.TransferComplete!", send_transfer_complete_notif }
|
||||
{ send_du_state_change_notif, "Device.SoftwareModules.DUStateChange!" },
|
||||
{ send_transfer_complete_notif, "Device.LocalAgent.TransferComplete!" }
|
||||
};
|
||||
|
||||
static void send_autonomous_notification(char *ev_name, struct blob_attr *msg)
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@
|
|||
static mxml_node_t *bkp_tree = NULL;
|
||||
|
||||
struct search_keywords {
|
||||
char *name;
|
||||
char *value;
|
||||
const char *name;
|
||||
const char *value;
|
||||
};
|
||||
|
||||
static int bkp_session_check_file();
|
||||
|
|
@ -53,6 +53,8 @@ void bkp_session_save()
|
|||
FILE *fp;
|
||||
if (!bkp_tree)
|
||||
return;
|
||||
|
||||
// cppcheck-suppress cert-MSC24-C
|
||||
fp = fopen(CWMP_BKP_FILE, "w");
|
||||
mxmlSaveFile(bkp_tree, fp, MXML_NO_CALLBACK);
|
||||
fclose(fp);
|
||||
|
|
@ -63,6 +65,7 @@ void bkp_session_create_file()
|
|||
{
|
||||
FILE *pFile;
|
||||
|
||||
// cppcheck-suppress cert-MSC24-C
|
||||
pFile = fopen(CWMP_BKP_FILE, "w");
|
||||
if (pFile == NULL) {
|
||||
CWMP_LOG(ERROR, "Unable to create %s file", CWMP_BKP_FILE);
|
||||
|
|
@ -84,6 +87,8 @@ int bkp_session_check_file()
|
|||
|
||||
if (bkp_tree == NULL) {
|
||||
FILE *pFile;
|
||||
|
||||
// cppcheck-suppress cert-MSC24-C
|
||||
pFile = fopen(CWMP_BKP_FILE, "r");
|
||||
bkp_tree = mxmlLoadFile(NULL, pFile, MXML_OPAQUE_CALLBACK);
|
||||
fclose(pFile);
|
||||
|
|
@ -106,7 +111,7 @@ int save_acs_bkp_config()
|
|||
return CWMP_OK;
|
||||
}
|
||||
|
||||
mxml_node_t *bkp_session_node_found(mxml_node_t *tree, char *name, struct search_keywords *keys, int size)
|
||||
static mxml_node_t *bkp_session_node_found(mxml_node_t *tree, const char *name, struct search_keywords *keys, int size)
|
||||
{
|
||||
mxml_node_t *b = tree, *c, *d;
|
||||
struct search_keywords;
|
||||
|
|
@ -136,7 +141,7 @@ mxml_node_t *bkp_session_node_found(mxml_node_t *tree, char *name, struct search
|
|||
return b;
|
||||
}
|
||||
|
||||
mxml_node_t *get_bkp_session_node_by_id(mxml_node_t *tree, char *name, int id)
|
||||
static mxml_node_t *get_bkp_session_node_by_id(mxml_node_t *tree, const char *name, int id)
|
||||
{
|
||||
struct search_keywords keys[1];
|
||||
char bkp_id[32];
|
||||
|
|
@ -148,7 +153,7 @@ mxml_node_t *get_bkp_session_node_by_id(mxml_node_t *tree, char *name, int id)
|
|||
return bkp_session_node_found(tree, name, keys, 1);
|
||||
}
|
||||
|
||||
mxml_node_t *get_bkp_session_node_by_key(mxml_node_t *tree, char *name, char *key_name, char *key_value)
|
||||
static mxml_node_t *get_bkp_session_node_by_key(mxml_node_t *tree, const char *name, const char *key_name, const char *key_value)
|
||||
{
|
||||
struct search_keywords keys[1];
|
||||
|
||||
|
|
@ -160,7 +165,7 @@ mxml_node_t *get_bkp_session_node_by_key(mxml_node_t *tree, char *name, char *ke
|
|||
/*
|
||||
* Insert Backup Session
|
||||
*/
|
||||
mxml_node_t *bkp_session_insert(mxml_node_t *tree, char *name, char *value)
|
||||
mxml_node_t *bkp_session_insert(mxml_node_t *tree, const char *name, const char *value)
|
||||
{
|
||||
mxml_node_t *b;
|
||||
if (tree == NULL || name == NULL) {
|
||||
|
|
@ -177,7 +182,7 @@ mxml_node_t *bkp_session_insert(mxml_node_t *tree, char *name, char *value)
|
|||
return b;
|
||||
}
|
||||
|
||||
void bkp_session_simple_insert(char *parent, char *child, char *value)
|
||||
void bkp_session_simple_insert(const char *parent, const char *child, const char *value)
|
||||
{
|
||||
mxml_node_t *b = bkp_tree;
|
||||
|
||||
|
|
@ -192,7 +197,7 @@ void bkp_session_simple_insert(char *parent, char *child, char *value)
|
|||
bkp_session_insert(b, child, value);
|
||||
}
|
||||
|
||||
void bkp_session_simple_insert_in_parent(char *parent, char *child, char *value)
|
||||
void bkp_session_simple_insert_in_parent(const char *parent, const char *child, const char *value)
|
||||
{
|
||||
mxml_node_t *n, *b = bkp_tree;
|
||||
|
||||
|
|
@ -403,7 +408,7 @@ void bkp_session_insert_transfer_complete(struct transfer_complete *ptransfer_co
|
|||
/*
|
||||
* Load backup session
|
||||
*/
|
||||
static char *load_child_value(mxml_node_t *tree, char *sub_name)
|
||||
static char *load_child_value(mxml_node_t *tree, const char *sub_name)
|
||||
{
|
||||
char *value = NULL;
|
||||
mxml_node_t *b = tree;
|
||||
|
|
@ -757,14 +762,14 @@ int cwmp_load_saved_session(char **ret, enum backup_loading load)
|
|||
/*
|
||||
* Delete Backup Session
|
||||
*/
|
||||
void bkp_session_delete_element(char *element_name, int id)
|
||||
void bkp_session_delete_element(const char *element_name, int id)
|
||||
{
|
||||
mxml_node_t *b = get_bkp_session_node_by_id(bkp_tree, element_name, id);
|
||||
if (b)
|
||||
mxmlDelete(b);
|
||||
}
|
||||
|
||||
void bkp_session_delete_element_by_key(char *element_name, char *key_name, char *key_value)
|
||||
void bkp_session_delete_element_by_key(const char *element_name, const char *key_name, const char *key_value)
|
||||
{
|
||||
mxml_node_t *b = get_bkp_session_node_by_key(bkp_tree, element_name, key_name, key_value);
|
||||
if (b)
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ int cwmp_init_backup_session(char **ret, enum backup_loading load);
|
|||
void bkp_session_save();
|
||||
int cwmp_load_saved_session(char **acsurl, enum backup_loading load);
|
||||
int save_acs_bkp_config();
|
||||
mxml_node_t *bkp_session_insert(mxml_node_t *tree, char *name, char *value);
|
||||
void bkp_session_simple_insert_in_parent(char *parent, char *child, char *value);
|
||||
void bkp_session_simple_insert(char *parent, char *child, char *value);
|
||||
mxml_node_t *bkp_session_insert(mxml_node_t *tree, const char *name, const char *value);
|
||||
void bkp_session_simple_insert_in_parent(const char *parent, const char *child, const char *value);
|
||||
void bkp_session_simple_insert(const char *parent, const char *child, const char *value);
|
||||
mxml_node_t *bkp_session_insert_event(int index, char *command_key, int id);
|
||||
void bkp_session_insert_schedule_inform(int id, time_t schedule_time, char *command_key);
|
||||
void bkp_session_insert_download(struct download *pdownload);
|
||||
|
|
@ -50,7 +50,7 @@ void bkp_session_insert_schedule_download(struct download *pschedule_download);
|
|||
void bkp_session_insert_du_state_change_complete(struct du_state_change_complete *pdu_state_change_complete);
|
||||
void bkp_session_insert_autonomous_du_state_change(auto_du_state_change_compl *data);
|
||||
void bkp_session_insert_autonomous_transfer_complete(auto_transfer_complete *data);
|
||||
void bkp_session_delete_element(char *element_name, int id);
|
||||
void bkp_session_delete_element_by_key(char *element_name, char *key_name, char *key_value);
|
||||
void bkp_session_delete_element(const char *element_name, int id);
|
||||
void bkp_session_delete_element_by_key(const char *element_name, const char *key_name, const char *key_value);
|
||||
void bkp_tree_clean(void);
|
||||
#endif /* _BACKUPSESSION_H__ */
|
||||
|
|
|
|||
122
src/common.c
122
src/common.c
|
|
@ -125,7 +125,7 @@ int global_env_init(int argc, char **argv, struct env *env)
|
|||
cwmp_main->conf.amd_version = DEFAULT_AMD_VERSION;
|
||||
get_uci_path_value(NULL, "cwmp.cpe.amd_version", value, BUF_SIZE_256);
|
||||
if (CWMP_STRLEN(value) != 0) {
|
||||
int a = atoi(value);
|
||||
int a = (int)strtol(value, NULL, 10);
|
||||
cwmp_main->conf.amd_version = (a >= 1 && a <= 6) ? a : DEFAULT_AMD_VERSION;
|
||||
}
|
||||
|
||||
|
|
@ -155,8 +155,8 @@ int global_env_init(int argc, char **argv, struct env *env)
|
|||
/*
|
||||
* List dm_paramter
|
||||
*/
|
||||
void add_dm_parameter_to_list(struct list_head *head, char *param_name, char *param_val, char *param_type,
|
||||
int notification, bool writable)
|
||||
void add_dm_parameter_to_list(struct list_head *head, const char *param_name, const char *param_val,
|
||||
const char *param_type, int notification, bool writable)
|
||||
{
|
||||
struct cwmp_dm_parameter *dm_parameter = NULL;
|
||||
|
||||
|
|
@ -339,28 +339,29 @@ void cwmp_free_all_list_param_fault(struct list_head *list_param_fault)
|
|||
}
|
||||
}
|
||||
|
||||
int cwmp_asprintf(char **s, const char *format, ...)
|
||||
int icwmp_asprintf(char **s, const char *format, ...)
|
||||
{
|
||||
int size;
|
||||
char *str = NULL;
|
||||
va_list arg, argcopy;
|
||||
|
||||
va_start(arg, format);
|
||||
va_copy(argcopy, arg);
|
||||
size = vsnprintf(NULL, 0, format, argcopy);
|
||||
size = vsnprintf(NULL, 0, format, argcopy); // Flawfinder: ignore
|
||||
va_end(argcopy);
|
||||
|
||||
if (size < 0) {
|
||||
va_end(argcopy);
|
||||
va_end(arg);
|
||||
return -1;
|
||||
}
|
||||
va_end(argcopy);
|
||||
str = (char *)calloc(sizeof(char), size + 1);
|
||||
vsnprintf(str, size + 1, format, arg);
|
||||
vsnprintf(str, size + 1, format, arg); // Flawfinder: ignore
|
||||
va_end(arg);
|
||||
*s = strdup(str);
|
||||
|
||||
*s = icwmp_strdup(str);
|
||||
FREE(str);
|
||||
if (*s == NULL) {
|
||||
if (*s == NULL)
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -377,7 +378,7 @@ size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream)
|
|||
return written;
|
||||
}
|
||||
|
||||
void set_rpc_parameter_key(char *param_key)
|
||||
void set_rpc_parameter_key(const char *param_key)
|
||||
{
|
||||
set_uci_path_value(NULL, "cwmp.cpe.ParameterKey", param_key ? param_key : "");
|
||||
}
|
||||
|
|
@ -385,7 +386,7 @@ void set_rpc_parameter_key(char *param_key)
|
|||
/*
|
||||
* Reboot
|
||||
*/
|
||||
void cwmp_reboot(char *command_key)
|
||||
void cwmp_reboot(const char *command_key)
|
||||
{
|
||||
set_rpc_parameter_key(command_key);
|
||||
|
||||
|
|
@ -420,8 +421,9 @@ void cwmp_factory_reset() //use the ubus rpc-sys factory
|
|||
CWMP_LOG(ERROR, "# Problem in system factory reset #");
|
||||
}
|
||||
|
||||
unsigned int get_file_size(char *file_name)
|
||||
unsigned int get_file_size(const char *file_name)
|
||||
{
|
||||
// cppcheck-suppress cert-MSC24-C
|
||||
FILE *fp = fopen(file_name, "r");
|
||||
|
||||
if (fp == NULL) {
|
||||
|
|
@ -437,34 +439,6 @@ unsigned int get_file_size(char *file_name)
|
|||
return res;
|
||||
}
|
||||
|
||||
int opkg_install_package(char *package_path)
|
||||
{
|
||||
FILE *fp;
|
||||
char path[1035];
|
||||
char cmd[512];
|
||||
|
||||
CWMP_LOG(INFO, "Apply downloaded config ...");
|
||||
|
||||
int ret = snprintf(cmd, sizeof(cmd), "opkg --force-depends --force-maintainer install %s", package_path);
|
||||
if (ret < 0 || ret > 512)
|
||||
return -1;
|
||||
fp = popen(cmd, "r");
|
||||
if (fp == NULL) {
|
||||
CWMP_LOG(INFO, "Failed to run command");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Read the output a line at a time - output it. */
|
||||
while (fgets(path, sizeof(path), fp) != NULL) {
|
||||
if (strstr(path, "Installing") != NULL)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* close */
|
||||
pclose(fp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int copy(const char *from, const char *to)
|
||||
{
|
||||
int fd_to, fd_from;
|
||||
|
|
@ -608,32 +582,6 @@ char *icwmp_strdup(const char *s)
|
|||
return (char *)CWMP_MEMCPY(new, s, len);
|
||||
}
|
||||
|
||||
int icwmp_asprintf(char **s, const char *format, ...)
|
||||
{
|
||||
int size;
|
||||
char *str = NULL;
|
||||
va_list arg, argcopy;
|
||||
|
||||
va_start(arg, format);
|
||||
va_copy(argcopy, arg);
|
||||
size = vsnprintf(NULL, 0, format, argcopy);
|
||||
va_end(argcopy);
|
||||
|
||||
if (size < 0) {
|
||||
va_end(arg);
|
||||
return -1;
|
||||
}
|
||||
str = (char *)calloc(sizeof(char), size + 1);
|
||||
vsnprintf(str, size + 1, format, arg);
|
||||
va_end(arg);
|
||||
|
||||
*s = icwmp_strdup(str);
|
||||
free(str);
|
||||
if (*s == NULL)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void icwmp_free(void *m)
|
||||
{
|
||||
if (m == NULL)
|
||||
|
|
@ -891,16 +839,17 @@ bool icwmp_validate_unsignedint(char *arg)
|
|||
if (strcmp(arg, "0") == 0)
|
||||
arg_int = 0;
|
||||
else {
|
||||
arg_int = atoi(arg);
|
||||
arg_int = (int)strtol(arg, NULL, 10);
|
||||
if (arg_int == 0)
|
||||
return false;
|
||||
}
|
||||
return arg_int >= 0;
|
||||
}
|
||||
|
||||
bool icwmp_validate_int_in_range(char *arg, int min, int max)
|
||||
bool icwmp_validate_int_in_range(const char *arg, int min, int max)
|
||||
{
|
||||
int arg_int;
|
||||
char *ptr = NULL;
|
||||
|
||||
if(arg == NULL)
|
||||
return false;
|
||||
|
|
@ -908,8 +857,8 @@ bool icwmp_validate_int_in_range(char *arg, int min, int max)
|
|||
if (strcmp(arg, "0") == 0)
|
||||
arg_int = 0;
|
||||
else {
|
||||
arg_int = atoi(arg);
|
||||
if (arg_int == 0)
|
||||
arg_int = (int)strtol(arg, &ptr, 10);
|
||||
if (*ptr != '\0')
|
||||
return false;
|
||||
}
|
||||
return arg_int >= min && arg_int <= max;
|
||||
|
|
@ -940,11 +889,15 @@ int copy_file(char *source_file, char *target_file)
|
|||
int ch;
|
||||
FILE *source, *target;
|
||||
size_t len = 0;
|
||||
|
||||
// cppcheck-suppress cert-MSC24-C
|
||||
source = fopen(source_file, "rb");
|
||||
if (source == NULL) {
|
||||
CWMP_LOG(ERROR, "Not able to open the source file: %s\n", source_file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// cppcheck-suppress cert-MSC24-C
|
||||
target = fopen(target_file, "wb");
|
||||
if (target == NULL) {
|
||||
fclose(source);
|
||||
|
|
@ -1072,24 +1025,27 @@ bool is_ipv6_status_changed(void)
|
|||
return ipv6_status_changed;
|
||||
}
|
||||
|
||||
char *get_time(time_t t_time)
|
||||
int get_time(time_t t_time, char *local_time, size_t len)
|
||||
{
|
||||
static char local_time[32] = {0};
|
||||
struct tm *t_tm;
|
||||
|
||||
if (local_time == NULL || len < 26)
|
||||
return -1;
|
||||
|
||||
t_tm = localtime(&t_time);
|
||||
if (t_tm == NULL)
|
||||
return NULL;
|
||||
return -1;
|
||||
|
||||
if (strftime(local_time, sizeof(local_time), "%FT%T%z", t_tm) == 0)
|
||||
return NULL;
|
||||
memset(local_time, 0, len);
|
||||
if (strftime(local_time, len, "%FT%T%z", t_tm) == 0)
|
||||
return -1;
|
||||
|
||||
local_time[25] = local_time[24];
|
||||
local_time[24] = local_time[23];
|
||||
local_time[23] = local_time[22];
|
||||
local_time[22] = ':';
|
||||
local_time[26] = '\0';
|
||||
local_time[25] = '\0';
|
||||
|
||||
return local_time;
|
||||
return 0;
|
||||
}
|
||||
|
||||
time_t convert_datetime_to_timestamp(char *value)
|
||||
|
|
@ -1217,7 +1173,7 @@ void free_path_list(struct list_head *list)
|
|||
}
|
||||
}
|
||||
|
||||
void add_bin_list(struct list_head *list, uint8_t *str, size_t len)
|
||||
void add_bin_list(struct list_head *list, const uint8_t *str, size_t len)
|
||||
{
|
||||
bin_list_t *node;
|
||||
|
||||
|
|
@ -1381,8 +1337,8 @@ int regex_replace(char **str, const char *pattern, const char *replace, int *mat
|
|||
|
||||
memset(new, 0, len);
|
||||
strncat(new, search_start, m[0].rm_so); // string before pattern
|
||||
strcat(new, replace); // add the replacement
|
||||
strcat(new, search_start + m[0].rm_eo); // add trailing text in string
|
||||
// add the replacement & trailing text in string
|
||||
snprintf(new + m[0].rm_so, len - m[0].rm_so, "%s%s", replace, search_start + m[0].rm_eo);
|
||||
|
||||
free(*str);
|
||||
*str = strdup(new);
|
||||
|
|
|
|||
79
src/common.h
79
src/common.h
|
|
@ -106,31 +106,13 @@ typedef struct env {
|
|||
} env;
|
||||
|
||||
struct connection {
|
||||
char interface[BUF_SIZE_16];
|
||||
long ip_resolve;
|
||||
bool ipv6_status;
|
||||
bool use_curl_ifname;
|
||||
char interface[BUF_SIZE_16];
|
||||
};
|
||||
|
||||
typedef struct config {
|
||||
char acs_url[BUF_SIZE_2048];
|
||||
char acs_userid[BUF_SIZE_256];
|
||||
char acs_passwd[BUF_SIZE_256];
|
||||
char acs_ssl_capath[BUF_SIZE_256];
|
||||
char acs_ssl_cabundle[BUF_SIZE_256];
|
||||
char cpe_userid[BUF_SIZE_256];
|
||||
char cpe_passwd[BUF_SIZE_256];
|
||||
char custom_notify_json[BUF_SIZE_256];
|
||||
char forced_inform_json[BUF_SIZE_256];
|
||||
char connection_request_path[BUF_SIZE_256];
|
||||
char auto_tc_transfer_type[BUF_SIZE_16];
|
||||
char auto_tc_result_type[BUF_SIZE_16];
|
||||
char auto_tc_file_type[BUF_SIZE_16];
|
||||
char auto_cdu_oprt_type[BUF_SIZE_16];
|
||||
char auto_cdu_result_type[BUF_SIZE_16];
|
||||
char auto_cdu_fault_code[BUF_SIZE_16];
|
||||
char default_wan_iface[BUF_SIZE_32];
|
||||
|
||||
int connection_request_port;
|
||||
int period;
|
||||
int periodic_notify_interval;
|
||||
|
|
@ -156,10 +138,6 @@ typedef struct config {
|
|||
int retry_min_wait_interval;
|
||||
int retry_interval_multiplier;
|
||||
|
||||
bool lwn_enable;
|
||||
char lwn_hostname[BUF_SIZE_256];
|
||||
int lwn_port;
|
||||
|
||||
int amd_version;
|
||||
int supported_amd_version;
|
||||
unsigned int instance_mode;
|
||||
|
|
@ -169,6 +147,29 @@ typedef struct config {
|
|||
int clock_sync_timeout;
|
||||
bool force_ipv4;
|
||||
bool fw_upgrade_keep_settings;
|
||||
|
||||
bool lwn_enable;
|
||||
int lwn_port;
|
||||
char lwn_hostname[BUF_SIZE_256];
|
||||
|
||||
char acs_url[BUF_SIZE_2048];
|
||||
char acs_userid[BUF_SIZE_256];
|
||||
char acs_passwd[BUF_SIZE_256];
|
||||
char acs_ssl_capath[BUF_SIZE_256];
|
||||
char acs_ssl_cabundle[BUF_SIZE_256];
|
||||
char cpe_userid[BUF_SIZE_256];
|
||||
char cpe_passwd[BUF_SIZE_256];
|
||||
char custom_notify_json[BUF_SIZE_256];
|
||||
char forced_inform_json[BUF_SIZE_256];
|
||||
char connection_request_path[BUF_SIZE_256];
|
||||
char auto_tc_transfer_type[BUF_SIZE_16];
|
||||
char auto_tc_result_type[BUF_SIZE_16];
|
||||
char auto_tc_file_type[BUF_SIZE_16];
|
||||
char auto_cdu_oprt_type[BUF_SIZE_16];
|
||||
char auto_cdu_result_type[BUF_SIZE_16];
|
||||
char auto_cdu_fault_code[BUF_SIZE_16];
|
||||
char default_wan_iface[BUF_SIZE_32];
|
||||
|
||||
} config;
|
||||
|
||||
struct deviceid {
|
||||
|
|
@ -227,6 +228,9 @@ typedef struct cwmp {
|
|||
bool throttle_session_triggered;
|
||||
enum firewall_cr_policy cr_policy;
|
||||
bool acs_changed;
|
||||
int curr_delay_reboot;
|
||||
time_t curr_schedule_reboot;
|
||||
char ip_acs[128];
|
||||
} cwmp;
|
||||
|
||||
enum action {
|
||||
|
|
@ -273,9 +277,9 @@ typedef struct rpc {
|
|||
|
||||
struct cwmp_param_fault {
|
||||
struct list_head list;
|
||||
int fault_code;
|
||||
char path_name[1024];
|
||||
char fault_msg[256];
|
||||
int fault_code;
|
||||
};
|
||||
|
||||
struct cwmp_dm_parameter {
|
||||
|
|
@ -484,13 +488,13 @@ typedef struct download {
|
|||
struct uloop_timeout handler_timer;
|
||||
time_t scheduled_time;
|
||||
unsigned int file_size;
|
||||
int id;
|
||||
char *command_key;
|
||||
char *file_type;
|
||||
char *url;
|
||||
char *username;
|
||||
char *password;
|
||||
struct timewindow timewindowstruct[2];
|
||||
int id;
|
||||
} download;
|
||||
|
||||
typedef struct timeinterval {
|
||||
|
|
@ -605,24 +609,24 @@ typedef struct opfault {
|
|||
} opfault;
|
||||
|
||||
typedef struct intf_reset_node {
|
||||
char path[1024];
|
||||
struct list_head list;
|
||||
char path[1024];
|
||||
} intf_reset_node;
|
||||
|
||||
typedef struct bin_list {
|
||||
uint8_t bin[1024];
|
||||
size_t len;
|
||||
struct list_head list;
|
||||
uint8_t bin[1024];
|
||||
} bin_list_t;
|
||||
|
||||
typedef struct force_inform_node {
|
||||
char path[1024];
|
||||
struct list_head list;
|
||||
char path[1024];
|
||||
} force_inform_node;
|
||||
|
||||
typedef struct {
|
||||
char path[1024];
|
||||
struct list_head list;
|
||||
char path[1024];
|
||||
} path_list_t;
|
||||
|
||||
extern struct cwmp *cwmp_main;
|
||||
|
|
@ -631,25 +635,24 @@ extern struct FAULT_CPE FAULT_CPE_ARRAY[];
|
|||
extern struct cwmp_namespaces ns;
|
||||
extern struct session_timer_event *global_session_event;
|
||||
|
||||
void add_dm_parameter_to_list(struct list_head *head, char *param_name, char *param_data, char *param_type, int notification, bool writable);
|
||||
void add_dm_parameter_to_list(struct list_head *head, const char *param_name, const char *param_data,
|
||||
const char *param_type, int notification, bool writable);
|
||||
void add_dm_alias_to_list(struct list_head *head, char *param_name, char *param_data, char **l_param, char **l_trans);
|
||||
void cwmp_free_all_dm_parameter_list(struct list_head *list);
|
||||
void cwmp_free_all_dm_alias_list(struct list_head *list);
|
||||
int global_env_init(int argc, char **argv, struct env *env);
|
||||
void cwmp_add_list_fault_param(char *param_name, char *fault_msg, int fault_code, struct list_head *list_set_value_fault);
|
||||
void cwmp_free_all_list_param_fault(struct list_head *list_param_fault);
|
||||
int cwmp_asprintf(char **s, const char *format, ...);
|
||||
bool folder_exists(const char *path);
|
||||
bool file_exists(const char *path);
|
||||
void cwmp_reboot(char *command_key);
|
||||
void cwmp_reboot(const char *command_key);
|
||||
void cwmp_factory_reset();
|
||||
void get_firewall_zone_name_by_wan_iface(char *if_wan, char **zone_name);
|
||||
int download_file(const char *file_path, const char *url, const char *username, const char *password, const char *interface);
|
||||
unsigned int get_file_size(char *file_name);
|
||||
unsigned int get_file_size(const char *file_name);
|
||||
int cwmp_check_image();
|
||||
int cwmp_apply_firmware();
|
||||
bool cwmp_apply_web_content(char *filepath);
|
||||
int opkg_install_package(char *package_path);
|
||||
int copy(const char *from, const char *to);
|
||||
int cwmp_get_fault_code(int fault_code);
|
||||
int cwmp_get_fault_code_by_string(char *fault_code);
|
||||
|
|
@ -664,13 +667,13 @@ void icwmp_restart_services(int type, bool is_commit, bool monitor);
|
|||
bool icwmp_validate_string_length(char *arg, int max_length);
|
||||
bool icwmp_validate_boolean_value(char *arg);
|
||||
bool icwmp_validate_unsignedint(char *arg);
|
||||
bool icwmp_validate_int_in_range(char *arg, int min, int max);
|
||||
bool icwmp_validate_int_in_range(const char *arg, int min, int max);
|
||||
char *string_to_hex(const unsigned char *str, size_t size);
|
||||
int copy_file(char *source_file, char *target_file);
|
||||
int icwmp_check_http_connection(void);
|
||||
bool is_ipv6_enabled(void);
|
||||
bool is_ipv6_status_changed(void);
|
||||
char *get_time(time_t t_time);
|
||||
int get_time(time_t t_time, char *local_time, size_t len);
|
||||
bool is_reload_parameter(const char *object_name);
|
||||
time_t convert_datetime_to_timestamp(char *value);
|
||||
void set_interface_reset_request(char *param_name, char *value);
|
||||
|
|
@ -679,9 +682,9 @@ bool match_reg_exp(char *reg_exp, char *param_name);
|
|||
void cwmp_invoke_intf_reset(char *path);
|
||||
void add_day_to_time(struct tm *time);
|
||||
int set_rpc_acs_to_supported(const char *rpc_name);
|
||||
void set_rpc_parameter_key(char *param_key);
|
||||
void set_rpc_parameter_key(const char *param_key);
|
||||
|
||||
void add_bin_list(struct list_head *list, uint8_t *str, size_t len);
|
||||
void add_bin_list(struct list_head *list, const uint8_t *str, size_t len);
|
||||
void add_str_binlist(struct list_head *list, char *str);
|
||||
void free_binlist(struct list_head *list);
|
||||
int cwmp_strcmp(const char *s1, const char *s2, const char *origin, int pos);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ int get_preinit_config()
|
|||
cwmp_main->conf.amd_version = DEFAULT_AMD_VERSION;
|
||||
get_uci_path_value(NULL, UCI_CPE_AMD_VERSION, value, BUF_SIZE_256);
|
||||
if (CWMP_STRLEN(value) != 0) {
|
||||
int a = atoi(value);
|
||||
int a = (int)strtol(value, NULL, 10);
|
||||
cwmp_main->conf.amd_version = (a >= 1 && a <= 6) ? a : DEFAULT_AMD_VERSION;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -177,6 +177,9 @@ static int cwmp_init(void)
|
|||
|
||||
CWMP_MEMSET(cwmp_main, 0, sizeof(struct cwmp));
|
||||
|
||||
cwmp_main->curr_delay_reboot = -1;
|
||||
cwmp_main->curr_schedule_reboot = 0;
|
||||
|
||||
get_preinit_config();
|
||||
|
||||
CWMP_LOG(INFO, "STARTING ICWMP with PID :%d", getpid());
|
||||
|
|
@ -184,12 +187,14 @@ static int cwmp_init(void)
|
|||
icwmp_init_critical_services();
|
||||
|
||||
/* Only One instance should run*/
|
||||
|
||||
// cppcheck-suppress cert-MSC24-C
|
||||
cwmp_main->pid_file = fopen("/var/run/icwmpd.pid", "w+");
|
||||
fcntl(fileno(cwmp_main->pid_file), F_SETFD, fcntl(fileno(cwmp_main->pid_file), F_GETFD) | FD_CLOEXEC);
|
||||
int rc = flock(fileno(cwmp_main->pid_file), LOCK_EX | LOCK_NB);
|
||||
if (rc) {
|
||||
if (EWOULDBLOCK != errno) {
|
||||
char *piderr = "PID file creation failed: Quit the daemon!";
|
||||
const char *piderr = "PID file creation failed: Quit the daemon!";
|
||||
fprintf(stderr, "%s\n", piderr);
|
||||
CWMP_LOG(ERROR, "%s", piderr);
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ char *cmd_set_notif_exec_func(struct cmd_input in, union cmd_result *res __attri
|
|||
if (!icwmp_validate_int_in_range(in.second_input, 0, 6))
|
||||
return "9003";
|
||||
|
||||
char *fault = cwmp_set_parameter_attributes(in.first_input, atoi(in.second_input));
|
||||
char *fault = cwmp_set_parameter_attributes(in.first_input, (int)strtol(in.second_input, NULL, 10));
|
||||
if (fault != NULL)
|
||||
return fault;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ union cmd_result {
|
|||
};
|
||||
|
||||
struct cmd_input {
|
||||
char *first_input;
|
||||
char *second_input;
|
||||
char *third_input;
|
||||
const char *first_input;
|
||||
const char *second_input;
|
||||
const char *third_input;
|
||||
};
|
||||
|
||||
char *cmd_get_exec_func(struct cmd_input in, union cmd_result *res);
|
||||
|
|
|
|||
|
|
@ -24,9 +24,12 @@
|
|||
|
||||
LIST_HEAD(list_change_du_state);
|
||||
|
||||
static int cwmp_du_install(char *url, char *uuid, char *user, char *pass, char *path, char *env_ref, char **fault_code);
|
||||
static int cwmp_du_update(char *url, char *user, char *pass, char *du_path, char **fault_code);
|
||||
static int cwmp_du_uninstall(char *du_path, char **fault_code);
|
||||
static int cwmp_du_install(const char *url, const char *uuid, const char *user,
|
||||
const char *pass, const char *path, char *env_ref,
|
||||
char **fault_code);
|
||||
static int cwmp_du_update(const char *url, const char *user, const char *pass,
|
||||
const char *du_path, char **fault_code);
|
||||
static int cwmp_du_uninstall(const char *du_path, char **fault_code);
|
||||
|
||||
static char *generate_uuid(void)
|
||||
{
|
||||
|
|
@ -68,7 +71,7 @@ void ubus_du_state_callback(struct ubus_request *req, int type __attribute__((un
|
|||
}
|
||||
}
|
||||
|
||||
static void prepare_blob_msg(struct blob_buf *b, char *url, char *uuid, char *user, char *pass, char *path, char *env_ref, int op)
|
||||
static void prepare_blob_msg(struct blob_buf *b, const char *url, const char *uuid, const char *user, const char *pass, const char *path, const char *env_ref, int op)
|
||||
{
|
||||
char command[256] = {0};
|
||||
void *tbl = NULL;
|
||||
|
|
@ -109,7 +112,8 @@ static void prepare_blob_msg(struct blob_buf *b, char *url, char *uuid, char *us
|
|||
}
|
||||
}
|
||||
|
||||
int cwmp_du_install(char *url, char *uuid, char *user, char *pass, char *path, char *env_ref, char **fault_code)
|
||||
int cwmp_du_install(const char *url, const char *uuid, const char *user, const char *pass,
|
||||
const char *path, char *env_ref, char **fault_code)
|
||||
{
|
||||
int e;
|
||||
struct blob_buf b = { 0 };
|
||||
|
|
@ -131,7 +135,7 @@ int cwmp_du_install(char *url, char *uuid, char *user, char *pass, char *path, c
|
|||
return FAULT_CPE_NO_FAULT;
|
||||
}
|
||||
|
||||
int cwmp_du_update(char *url, char *user, char *pass, char *du_path, char **fault_code)
|
||||
int cwmp_du_update(const char *url, const char *user, const char *pass, const char *du_path, char **fault_code)
|
||||
{
|
||||
struct blob_buf b = {0};
|
||||
|
||||
|
|
@ -150,7 +154,7 @@ int cwmp_du_update(char *url, char *user, char *pass, char *du_path, char **faul
|
|||
return FAULT_CPE_NO_FAULT;
|
||||
}
|
||||
|
||||
int cwmp_du_uninstall(char *du_path, char **fault_code)
|
||||
int cwmp_du_uninstall(const char *du_path, char **fault_code)
|
||||
{
|
||||
struct blob_buf b = {0};
|
||||
|
||||
|
|
@ -170,7 +174,7 @@ int cwmp_du_uninstall(char *du_path, char **fault_code)
|
|||
}
|
||||
|
||||
|
||||
static char *get_software_module_object_eq(char *param1, char *val1, char *param2, char *val2, struct list_head *sw_parameters)
|
||||
static char *get_software_module_object_eq(const char *param1, const char *val1, const char *param2, const char *val2, struct list_head *sw_parameters)
|
||||
{
|
||||
char *err = NULL;
|
||||
|
||||
|
|
@ -275,12 +279,16 @@ static bool environment_exists(char *environment_path)
|
|||
return true;
|
||||
}
|
||||
|
||||
static int cwmp_launch_du_install(char *url, char *uuid, char *user, char *pass, char *path, char *env_ref, struct opresult **pchange_du_state_complete)
|
||||
static int cwmp_launch_du_install(const char *url, const char *uuid, const char *user,
|
||||
const char *pass, const char *path, char *env_ref,
|
||||
struct opresult **pchange_du_state_complete)
|
||||
{
|
||||
int error = FAULT_CPE_NO_FAULT;
|
||||
char *fault_code = NULL;
|
||||
char start_time[26] = {0};
|
||||
|
||||
(*pchange_du_state_complete)->start_time = strdup(get_time(time(NULL)));
|
||||
get_time(time(NULL), start_time, sizeof(start_time));
|
||||
(*pchange_du_state_complete)->start_time = strdup(start_time);
|
||||
|
||||
if (uuid == NULL) {
|
||||
(*pchange_du_state_complete)->fault_msg = strdup("No UUID information present");
|
||||
|
|
@ -318,12 +326,15 @@ static int cwmp_launch_du_install(char *url, char *uuid, char *user, char *pass,
|
|||
return error;
|
||||
}
|
||||
|
||||
static int cwmp_launch_du_update(char *url, char *uuid, char *user, char *pass, char *du_path, struct opresult **pchange_du_state_complete)
|
||||
static int cwmp_launch_du_update(const char *url, const char *uuid, const char *user, const char *pass,
|
||||
const char *du_path, struct opresult **pchange_du_state_complete)
|
||||
{
|
||||
int error = FAULT_CPE_NO_FAULT;
|
||||
char *fault_code = NULL;
|
||||
char start_time[26] = {0};
|
||||
|
||||
(*pchange_du_state_complete)->start_time = strdup(get_time(time(NULL)));
|
||||
get_time(time(NULL), start_time, sizeof(start_time));
|
||||
(*pchange_du_state_complete)->start_time = strdup(start_time);
|
||||
|
||||
if (uuid == NULL) {
|
||||
(*pchange_du_state_complete)->fault_msg = strdup("No UUID information");
|
||||
|
|
@ -360,12 +371,16 @@ static int cwmp_launch_du_update(char *url, char *uuid, char *user, char *pass,
|
|||
return error;
|
||||
}
|
||||
|
||||
static int cwmp_launch_du_uninstall(char *du_path, char *uuid, struct opresult **pchange_du_state_complete)
|
||||
static int cwmp_launch_du_uninstall(const char *du_path, const char *uuid,
|
||||
struct opresult **pchange_du_state_complete)
|
||||
{
|
||||
int error = FAULT_CPE_NO_FAULT;
|
||||
char *fault_code = NULL;
|
||||
char start_time[26] = {0};
|
||||
|
||||
(*pchange_du_state_complete)->start_time = strdup(get_time(time(NULL)));
|
||||
get_time(time(NULL), start_time, sizeof(start_time));
|
||||
|
||||
(*pchange_du_state_complete)->start_time = strdup(start_time);
|
||||
|
||||
if (uuid == NULL) {
|
||||
(*pchange_du_state_complete)->fault_msg = strdup("No UUID value provided");
|
||||
|
|
@ -437,10 +452,13 @@ int change_du_state_fault(struct change_du_state *pchange_du_state, struct du_st
|
|||
res->uuid = strdup(p->uuid);
|
||||
}
|
||||
|
||||
char start_time[26] = {0};
|
||||
get_time(time(NULL), start_time, sizeof(start_time));
|
||||
|
||||
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->start_time = strdup(start_time);
|
||||
res->complete_time = strdup(start_time);
|
||||
res->fault = error;
|
||||
res->fault_msg = strdup("Timeout expired");
|
||||
}
|
||||
|
|
@ -519,7 +537,7 @@ void change_du_state_execute(struct uloop_timeout *utimeout)
|
|||
}
|
||||
}
|
||||
|
||||
char *path = "Device.SoftwareModules.";
|
||||
const char *path = "Device.SoftwareModules.";
|
||||
bool uuid_generated = false;
|
||||
|
||||
if (CWMP_STRLEN(p->uuid) == 0) {
|
||||
|
|
@ -539,10 +557,13 @@ void change_du_state_execute(struct uloop_timeout *utimeout)
|
|||
package_name = get_package_name_by_url(p->url);
|
||||
|
||||
if (error != FAULT_CPE_NO_FAULT) {
|
||||
char end_time[26] = {0};
|
||||
get_time(time(NULL), end_time, sizeof(end_time));
|
||||
|
||||
res->uuid = strdup(p->uuid);
|
||||
res->current_state = strdup("Failed");
|
||||
res->resolved = 0;
|
||||
res->complete_time = strdup(get_time(time(NULL)));
|
||||
res->complete_time = strdup(end_time);
|
||||
res->fault = error;
|
||||
|
||||
if (res->fault_msg == NULL)
|
||||
|
|
@ -579,6 +600,9 @@ void change_du_state_execute(struct uloop_timeout *utimeout)
|
|||
if (error != FAULT_CPE_NO_FAULT) {
|
||||
struct cwmp_dm_parameter dm_param = {0};
|
||||
char version_param_path[128] = {0};
|
||||
char end_time[26] = {0};
|
||||
|
||||
get_time(time(NULL), end_time, sizeof(end_time));
|
||||
|
||||
snprintf(version_param_path, sizeof(version_param_path), "%s.Version", du_ref);
|
||||
cwmp_get_parameter_value(version_param_path, &dm_param);
|
||||
|
|
@ -587,7 +611,7 @@ void change_du_state_execute(struct uloop_timeout *utimeout)
|
|||
res->resolved = 0;
|
||||
res->version = strdup(dm_param.value ? dm_param.value : "");
|
||||
res->du_ref = strdup(du_path);
|
||||
res->complete_time = strdup(get_time(time(NULL)));
|
||||
res->complete_time = strdup(end_time);
|
||||
res->fault = error;
|
||||
|
||||
if (res->fault_msg == NULL)
|
||||
|
|
@ -637,12 +661,15 @@ void change_du_state_execute(struct uloop_timeout *utimeout)
|
|||
|
||||
error = cwmp_launch_du_uninstall(du_path, p->uuid, &res);
|
||||
if (error != FAULT_CPE_NO_FAULT) {
|
||||
char end_time[26] = {0};
|
||||
get_time(time(NULL), end_time, sizeof(end_time));
|
||||
|
||||
res->current_state = strdup("Installed");
|
||||
res->resolved = 1;
|
||||
res->du_ref = strdup(du_path);
|
||||
res->uuid = strdup(p->uuid);
|
||||
res->version = strdup(package_version ? package_version : "");
|
||||
res->complete_time = strdup(get_time(time(NULL)));
|
||||
res->complete_time = strdup(end_time);
|
||||
res->fault = error;
|
||||
|
||||
if (res->fault_msg == NULL)
|
||||
|
|
@ -740,7 +767,7 @@ void apply_change_du_state()
|
|||
}
|
||||
}
|
||||
|
||||
void remove_node_from_uuid_list(char *uuid, char *operation)
|
||||
void remove_node_from_uuid_list(const char *uuid, const char *operation)
|
||||
{
|
||||
if (uuid == NULL || operation == NULL)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ int cwmp_rpc_acs_destroy_data_du_state_change_complete(struct rpc *rpc);
|
|||
int cwmp_free_change_du_state_request(struct change_du_state *change_du_state);
|
||||
void change_du_state_execute(struct uloop_timeout *utimeout);
|
||||
void apply_change_du_state();
|
||||
void remove_node_from_uuid_list(char *uuid, char *operation);
|
||||
void remove_node_from_uuid_list(const char *uuid, const char *operation);
|
||||
bool exists_in_uuid_list(char *uuid, char *operation);
|
||||
void clean_du_uuid_list(void);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
#include "backupSession.h"
|
||||
#include "log.h"
|
||||
|
||||
static struct event_container *__cwmp_add_event_container(int event_code, char *command_key)
|
||||
static struct event_container *__cwmp_add_event_container(int event_code, const char *command_key)
|
||||
{
|
||||
struct event_container *event_container = NULL;
|
||||
list_for_each_entry(event_container, &cwmp_main->session->events, list) {
|
||||
|
|
@ -42,7 +42,7 @@ static struct event_container *__cwmp_add_event_container(int event_code, char *
|
|||
return event_container;
|
||||
}
|
||||
|
||||
struct event_container *cwmp_add_event_container(int event_code, char *command_key)
|
||||
struct event_container *cwmp_add_event_container(int event_code, const char *command_key)
|
||||
{
|
||||
struct event_container *event = __cwmp_add_event_container(event_code, command_key);
|
||||
return event;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define CWMP_EVENT_H
|
||||
|
||||
#include "event.h"
|
||||
struct event_container *cwmp_add_event_container(int event_code, char *command_key);
|
||||
struct event_container *cwmp_add_event_container(int event_code, const char *command_key);
|
||||
void move_next_session_events_to_actual_session();
|
||||
int cwmp_remove_all_session_events();
|
||||
int remove_single_event(int event_code);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ struct list_params_result {
|
|||
struct list_head *parameters_list;
|
||||
struct list_head *alias_list;
|
||||
int error;
|
||||
char *error_msg;
|
||||
const char *error_msg;
|
||||
};
|
||||
|
||||
struct setm_values_res {
|
||||
|
|
@ -477,7 +477,7 @@ char *cwmp_get_parameter_values(const char *parameter_name, struct list_head *pa
|
|||
return NULL;
|
||||
}
|
||||
|
||||
char *cwmp_get_parameter_names(const char *parameter_name, bool next_level, struct list_head *parameters_list, char **err_msg)
|
||||
char *cwmp_get_parameter_names(const char *parameter_name, bool next_level, struct list_head *parameters_list, const char **err_msg)
|
||||
{
|
||||
char *inst_path = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@
|
|||
|
||||
struct object_result {
|
||||
char *instance;
|
||||
char fault_msg[256];
|
||||
int fault_code;
|
||||
char fault_msg[256];
|
||||
};
|
||||
|
||||
int instantiate_param_name(const char *param, char **inst_path);
|
||||
bool cwmp_get_parameter_value(const char *parameter_name, struct cwmp_dm_parameter *dm_parameter);
|
||||
|
||||
char *cwmp_get_parameter_values(const char *parameter_name, struct list_head *parameters_list);
|
||||
char *cwmp_get_parameter_names(const char *parameter_name, bool next_level, struct list_head *parameters_list, char **err_msg);
|
||||
char *cwmp_get_parameter_names(const char *parameter_name, bool next_level, struct list_head *parameters_list, const char **err_msg);
|
||||
char *cwmp_validate_parameter_name(const char *param_name, bool next_level, struct list_head *param_list);
|
||||
char *cwmp_validate_multi_instance_path(const char *object, struct list_head *parameters_list);
|
||||
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ bool set_diagnostic_parameter_structure_value(char *parameter_name, char *value)
|
|||
|
||||
}
|
||||
|
||||
static int cwmp_diagnostics_operate(char *command, char *command_key, struct diagnostic_input diagnostics[], int number_inputs)
|
||||
static int cwmp_diagnostics_operate(const char *command, const char *command_key, struct diagnostic_input diagnostics[], int number_inputs)
|
||||
{
|
||||
struct blob_buf b = {0};
|
||||
|
||||
|
|
|
|||
|
|
@ -282,9 +282,9 @@ static void get_digest_response(const char *ha1, const char *nonce, const char *
|
|||
a = b;
|
||||
}
|
||||
|
||||
add_bin_list(&buff_list, (uint8_t *)ha1, MD5_HASH_HEX_LEN);
|
||||
add_bin_list(&buff_list, (const uint8_t *)ha1, MD5_HASH_HEX_LEN);
|
||||
add_str_binlist(&buff_list, a);
|
||||
add_bin_list(&buff_list, (uint8_t *)ha2, MD5_HASH_HEX_LEN);
|
||||
add_bin_list(&buff_list, (const uint8_t *)ha2, MD5_HASH_HEX_LEN);
|
||||
FREE(a);
|
||||
|
||||
calulate_md5_hash(&buff_list, digest, sizeof(digest));
|
||||
|
|
@ -334,11 +334,11 @@ static void get_nonce(uint32_t time, const char* method, const char *rand,
|
|||
|
||||
unsigned char digest[MD5_DIGEST_SIZE];
|
||||
|
||||
add_bin_list(&buff_list, (uint8_t *)ts, 4);
|
||||
add_bin_list(&buff_list, (const uint8_t *)ts, 4);
|
||||
add_str_binlist(&buff_list, meth);
|
||||
|
||||
if (rand != NULL && rand_size > 0) {
|
||||
add_bin_list(&buff_list, (uint8_t *)rand, rand_size);
|
||||
add_bin_list(&buff_list, (const uint8_t *)rand, rand_size);
|
||||
}
|
||||
|
||||
add_str_binlist(&buff_list, uri_realm);
|
||||
|
|
@ -432,7 +432,7 @@ int validate_http_digest_auth(const char *http_meth, const char *uri, const char
|
|||
return 0;
|
||||
|
||||
char *tms = param[E_NONCE].value + len - 8;
|
||||
uint32_t tm = strtoul(tms, NULL, 16);
|
||||
uint32_t tm = (uint32_t)strtoul(tms, NULL, 16);
|
||||
uint32_t cur_tm = (uint32_t)time(NULL);
|
||||
|
||||
if (cur_tm > tm + timeout) {
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ int download_file(const char *file_path, const char *url, const char *username,
|
|||
|
||||
if (file_path == NULL)
|
||||
file_path = "/tmp/download_file";
|
||||
|
||||
// cppcheck-suppress cert-MSC24-C
|
||||
FILE *fp = fopen(file_path, "wb");
|
||||
if (fp) {
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
|
||||
|
|
@ -145,7 +147,7 @@ int download_file_in_subprocess(const char *file_path, const char *url, const ch
|
|||
if (download_task != NULL) {
|
||||
char *ret = execute_task_in_subprocess(download_task);
|
||||
FREE(download_task);
|
||||
return ret ? atoi(ret) : 500;
|
||||
return ret ? (int)strtol(ret, NULL, 10) : 500;
|
||||
}
|
||||
|
||||
return 500;
|
||||
|
|
@ -440,18 +442,18 @@ int cwmp_apply_multiple_firmware_in_subprocess()
|
|||
{
|
||||
subprocess_start(apply_multiple_firmware_task_function);
|
||||
char *ret = execute_task_in_subprocess("{}"); //empty json object
|
||||
return ret ? atoi(ret) : 500;
|
||||
return ret ? (int)strtol(ret, NULL, 10) : 500;
|
||||
}
|
||||
|
||||
int cwmp_launch_download(struct download *pdownload, char *download_file_name, enum load_type ltype, struct transfer_complete **ptransfer_complete)
|
||||
{
|
||||
int error = FAULT_CPE_NO_FAULT;
|
||||
char *download_startTime;
|
||||
char download_startTime[26] = {0};
|
||||
char download_endTime[26] = {0};
|
||||
struct transfer_complete *p;
|
||||
char err_msg[256] = {0};
|
||||
|
||||
download_startTime = get_time(time(NULL));
|
||||
|
||||
get_time(time(NULL), download_startTime, sizeof(download_startTime));
|
||||
bkp_session_delete_element((ltype == TYPE_DOWNLOAD) ? "download" : "schedule_download", pdownload->id);
|
||||
bkp_session_save();
|
||||
|
||||
|
|
@ -534,6 +536,8 @@ int cwmp_launch_download(struct download *pdownload, char *download_file_name, e
|
|||
}
|
||||
|
||||
end_download:
|
||||
get_time(time(NULL), download_endTime, sizeof(download_endTime));
|
||||
|
||||
p = calloc(1, sizeof(struct transfer_complete));
|
||||
if (p == NULL || ptransfer_complete == NULL) {
|
||||
CWMP_LOG(ERROR, "%s: Failed to allocate memory", __FUNCTION__);
|
||||
|
|
@ -543,7 +547,7 @@ end_download:
|
|||
|
||||
p->command_key = pdownload->command_key ? strdup(pdownload->command_key) : strdup("");
|
||||
p->start_time = CWMP_STRDUP(download_startTime);
|
||||
p->complete_time = CWMP_STRDUP(get_time(time(NULL)));
|
||||
p->complete_time = CWMP_STRDUP(download_endTime);
|
||||
p->type = ltype;
|
||||
p->file_type = CWMP_STRDUP(pdownload->file_type);
|
||||
if (error != FAULT_CPE_NO_FAULT) {
|
||||
|
|
@ -698,8 +702,11 @@ struct transfer_complete *set_download_error_transfer_complete(struct download *
|
|||
struct transfer_complete *ptransfer_complete;
|
||||
ptransfer_complete = calloc(1, sizeof(struct transfer_complete));
|
||||
if (ptransfer_complete != NULL) {
|
||||
char start_time[26] = {0};
|
||||
get_time(time(NULL), start_time, sizeof(start_time));
|
||||
|
||||
ptransfer_complete->command_key = strdup(pdownload && pdownload->command_key ? pdownload->command_key : "");
|
||||
ptransfer_complete->start_time = CWMP_STRDUP(get_time(time(NULL)));
|
||||
ptransfer_complete->start_time = CWMP_STRDUP(start_time);
|
||||
ptransfer_complete->complete_time = strdup(ptransfer_complete->start_time ? ptransfer_complete->start_time : "");
|
||||
ptransfer_complete->fault_code = ltype == TYPE_DOWNLOAD ? FAULT_CPE_DOWNLOAD_FAILURE : FAULT_CPE_DOWNLOAD_FAIL_WITHIN_TIME_WINDOW;
|
||||
ptransfer_complete->type = ltype;
|
||||
|
|
@ -948,9 +955,12 @@ void cwmp_start_schedule_download(struct uloop_timeout *timeout)
|
|||
return;
|
||||
}
|
||||
|
||||
char cur_time[26] = {0};
|
||||
get_time(now, cur_time, sizeof(cur_time));
|
||||
|
||||
ptransfer_complete->command_key = sched_download->command_key ? strdup(sched_download->command_key) : strdup("");
|
||||
ptransfer_complete->start_time = CWMP_STRDUP(get_time(now));
|
||||
ptransfer_complete->complete_time = CWMP_STRDUP(get_time(now));
|
||||
ptransfer_complete->start_time = CWMP_STRDUP(cur_time);
|
||||
ptransfer_complete->complete_time = CWMP_STRDUP(cur_time);
|
||||
ptransfer_complete->type = TYPE_DOWNLOAD;
|
||||
ptransfer_complete->fault_code = FAULT_CPE_INTERNAL_ERROR;
|
||||
if (ptransfer_complete->id <= 0) {
|
||||
|
|
|
|||
35
src/http.c
35
src/http.c
|
|
@ -90,7 +90,7 @@ static size_t http_get_response(void *buffer, size_t size, size_t rxed, void *us
|
|||
|
||||
if (buffer == NULL)
|
||||
return 0;
|
||||
if (cwmp_asprintf(&c, "%s%.*s", *msg_in, (int)(size * rxed), (char *)buffer) == -1) {
|
||||
if (asprintf(&c, "%s%.*s", *msg_in, (int)(size * rxed), (char *)buffer) == -1) {
|
||||
FREE(*msg_in);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -265,7 +265,6 @@ int icwmp_http_send_message(char *msg_out, int msg_out_len, char **msg_in)
|
|||
int tmp = 0;
|
||||
CURLcode res;
|
||||
long http_code = 0;
|
||||
static char ip_acs[128] = { 0 };
|
||||
char *ip = NULL;
|
||||
char errbuf[CURL_ERROR_SIZE];
|
||||
|
||||
|
|
@ -312,8 +311,8 @@ int icwmp_http_send_message(char *msg_out, int msg_out_len, char **msg_in)
|
|||
|
||||
curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ip);
|
||||
if (CWMP_STRLEN(ip)) {
|
||||
if (ip_acs[0] == '\0' || strcmp(ip_acs, ip) != 0) {
|
||||
CWMP_STRNCPY(ip_acs, ip, sizeof(ip_acs));
|
||||
if (cwmp_main->ip_acs[0] == '\0' || strcmp(cwmp_main->ip_acs, ip) != 0) {
|
||||
CWMP_STRNCPY(cwmp_main->ip_acs, ip, sizeof(cwmp_main->ip_acs));
|
||||
tmp = inet_pton(AF_INET, ip, buf);
|
||||
if (tmp == 1) {
|
||||
tmp = 0;
|
||||
|
|
@ -322,14 +321,18 @@ int icwmp_http_send_message(char *msg_out, int msg_out_len, char **msg_in)
|
|||
}
|
||||
|
||||
if (tmp) {
|
||||
set_uci_path_value(VARSTATE_CONFIG, "icwmp.acs.ip6", ip_acs);
|
||||
set_uci_path_value(VARSTATE_CONFIG, "icwmp.acs.ip6", cwmp_main->ip_acs);
|
||||
} else {
|
||||
set_uci_path_value(VARSTATE_CONFIG, "icwmp.acs.ip", ip_acs);
|
||||
set_uci_path_value(VARSTATE_CONFIG, "icwmp.acs.ip", cwmp_main->ip_acs);
|
||||
}
|
||||
|
||||
// Trigger firewall to reload firewall.cwmp
|
||||
if (cwmp_main->cr_policy != CR_POLICY_Port_Only) {
|
||||
system(FIREWALL_CWMP);
|
||||
// Flawfinder: ignore
|
||||
FILE *pp = popen(FIREWALL_CWMP, "r");
|
||||
if (pp) {
|
||||
pclose(pp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -370,7 +373,12 @@ static void http_success_cr(void)
|
|||
CWMP_LOG(INFO, "Connection Request triggering ...");
|
||||
int retry = 0, rc = -1;
|
||||
while (rc != 0 && retry < 5) {
|
||||
rc = system("ubus call tr069 inform");
|
||||
// Flawfinder: ignore
|
||||
FILE *pp = popen("ubus call tr069 inform", "r");
|
||||
if (pp) {
|
||||
int status = pclose(pp);
|
||||
rc = WEXITSTATUS(status);
|
||||
}
|
||||
retry = retry + 1;
|
||||
}
|
||||
|
||||
|
|
@ -486,7 +494,7 @@ static void http_cr_new_client(int client, bool service_available)
|
|||
size_t avail_space = (size_t)(sizeof(data) - strlen(data));
|
||||
if (buf_len < avail_space) {
|
||||
CWMP_LOG(DEBUG, "Continue buffer overrun %d=>%d", buf_len, avail_space);
|
||||
strcat(data, buffer);
|
||||
strncat(data, buffer, buf_len);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -495,7 +503,7 @@ static void http_cr_new_client(int client, bool service_available)
|
|||
*/
|
||||
size_t avail_space = (size_t)(sizeof(data) - strlen(data));
|
||||
if (buf_len < avail_space) {
|
||||
strcat(data, buffer);
|
||||
strncat(data, buffer, buf_len);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -679,7 +687,12 @@ void icwmp_http_server_init(void)
|
|||
snprintf(cr_port_str, 6, "%hu", cr_port);
|
||||
cr_port_str[5] = '\0';
|
||||
set_uci_path_value(NULL, "cwmp.cpe.port", cr_port_str);
|
||||
system(FIREWALL_CWMP);
|
||||
// Flawfinder: ignore
|
||||
FILE *pp = popen(FIREWALL_CWMP, "r");
|
||||
if (pp) {
|
||||
pclose(pp);
|
||||
}
|
||||
|
||||
connection_request_port_value_change(cr_port);
|
||||
}
|
||||
|
||||
|
|
|
|||
10
src/log.c
10
src/log.c
|
|
@ -57,7 +57,7 @@ int log_set_log_file_name(char *value)
|
|||
int log_set_file_max_size(char *value)
|
||||
{
|
||||
if (CWMP_STRLEN(value) != 0) {
|
||||
log_max_size = atol(value);
|
||||
log_max_size = strtol(value, NULL, 10);
|
||||
} else {
|
||||
log_max_size = 102400;
|
||||
}
|
||||
|
|
@ -123,13 +123,15 @@ void puts_log(int severity, const char *fmt, ...)
|
|||
if (size >= log_max_size) {
|
||||
snprintf(log_file_name_bak, sizeof(log_file_name_bak), "%s.1", log_file_name);
|
||||
rename(log_file_name, log_file_name_bak);
|
||||
// cppcheck-suppress cert-MSC24-C
|
||||
pLog = fopen(log_file_name, "w");
|
||||
} else {
|
||||
// cppcheck-suppress cert-MSC24-C
|
||||
pLog = fopen(log_file_name, "a+");
|
||||
}
|
||||
}
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buf + i, sizeof(buf)-i-2, (const char *)fmt, args);
|
||||
vsnprintf(buf + i, sizeof(buf)-i-2, (const char *)fmt, args); // Flawfinder: ignore
|
||||
if (enable_log_file) {
|
||||
CWMP_STRNCPY(buf_file, buf, sizeof(buf_file));
|
||||
buf_file[strlen(buf)] = '\n';
|
||||
|
|
@ -162,7 +164,7 @@ void puts_log_xmlmsg(int severity, char *msg, int msgtype)
|
|||
long int size = 0;
|
||||
char log_file_name_bak[258];
|
||||
char buf[1024];
|
||||
char *description, *separator;
|
||||
const char *description, *separator;
|
||||
|
||||
if (msg == NULL)
|
||||
return;
|
||||
|
|
@ -195,8 +197,10 @@ void puts_log_xmlmsg(int severity, char *msg, int msgtype)
|
|||
if (size >= log_max_size) {
|
||||
snprintf(log_file_name_bak, sizeof(log_file_name_bak), "%s.1", log_file_name);
|
||||
rename(log_file_name, log_file_name_bak);
|
||||
// cppcheck-suppress cert-MSC24-C
|
||||
pLog = fopen(log_file_name, "w");
|
||||
} else {
|
||||
// cppcheck-suppress cert-MSC24-C
|
||||
pLog = fopen(log_file_name, "a+");
|
||||
}
|
||||
fputs(buf, pLog);
|
||||
|
|
|
|||
|
|
@ -28,9 +28,11 @@ LIST_HEAD(list_value_change);
|
|||
LIST_HEAD(list_lw_value_change);
|
||||
LIST_HEAD(list_param_obj_notify);
|
||||
|
||||
static int cr_url_retry = 3;
|
||||
|
||||
static void create_list_param_leaf_notify(struct list_head *, void (*fp)(FILE *, char *, char *, char *, int), FILE*);
|
||||
static void send_active_value_change(void);
|
||||
static void add_list_value_change(char *param_name, char *param_data, char *param_type);
|
||||
static void add_list_value_change(const char *param_name, const char *param_data, const char *param_type);
|
||||
static void add_lw_list_value_change(char *param_name, char *param_data, char *param_type);
|
||||
static void cwmp_lwnotification(void);
|
||||
static void periodic_check_notifiy(struct uloop_timeout *timeout __attribute__((unused)));
|
||||
|
|
@ -56,7 +58,7 @@ char *forced_notifications_parameters[] = {
|
|||
/*
|
||||
* Common functions
|
||||
*/
|
||||
static bool parameter_is_subobject_of_parameter(char *parent, char *child)
|
||||
static bool parameter_is_subobject_of_parameter(const char *parent, const char *child)
|
||||
{
|
||||
if (child == NULL) {
|
||||
CWMP_LOG(WARNING, "notifications %s: child is null", __FUNCTION__);
|
||||
|
|
@ -89,7 +91,7 @@ int check_parameter_forced_notification(const char *parameter)
|
|||
return 0;
|
||||
}
|
||||
|
||||
char *check_valid_parameter_path(char *parameter_name)
|
||||
static char *check_valid_parameter_path(const char *parameter_name)
|
||||
{
|
||||
char *error = NULL;
|
||||
LIST_HEAD(parameters_list);
|
||||
|
|
@ -110,7 +112,7 @@ char *check_valid_parameter_path(char *parameter_name)
|
|||
*/
|
||||
|
||||
// Add parameter_name to the suitable notifications list
|
||||
int add_uci_option_notification(char *parameter_name, int type)
|
||||
static int add_uci_option_notification(const char *parameter_name, int type)
|
||||
{
|
||||
char notif_path[BUF_SIZE_256] = {0};
|
||||
int ret;
|
||||
|
|
@ -125,7 +127,7 @@ int add_uci_option_notification(char *parameter_name, int type)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool check_parent_with_different_notification(char *parameter_name, int notification)
|
||||
static bool check_parent_with_different_notification(const char *parameter_name, int notification)
|
||||
{
|
||||
int i;
|
||||
bool ret = false;
|
||||
|
|
@ -153,7 +155,7 @@ bool check_parent_with_different_notification(char *parameter_name, int notifica
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool update_notifications_list(char *parameter_name, int notification)
|
||||
static bool update_notifications_list(const char *parameter_name, int notification)
|
||||
{
|
||||
int i;
|
||||
bool update_ret = true;
|
||||
|
|
@ -187,7 +189,7 @@ bool update_notifications_list(char *parameter_name, int notification)
|
|||
return update_ret;
|
||||
}
|
||||
|
||||
char *cwmp_set_parameter_attributes(char *parameter_name, int notification)
|
||||
char *cwmp_set_parameter_attributes(const char *parameter_name, int notification)
|
||||
{
|
||||
char *error = NULL;
|
||||
|
||||
|
|
@ -233,7 +235,7 @@ int cwmp_set_parameter_attributes_list(struct list_head *parameters_list)
|
|||
/*
|
||||
* GetPrameterAttributes
|
||||
*/
|
||||
int get_parameter_family_notifications(char *parameter_name, struct list_head *childs_notifications) {
|
||||
static int get_parameter_family_notifications(const char *parameter_name, struct list_head *childs_notifications) {
|
||||
|
||||
int i, notif_ret = 0;
|
||||
|
||||
|
|
@ -292,7 +294,7 @@ int get_parameter_leaf_notification_from_childs_list(char *parameter_name, struc
|
|||
return ret_notif;
|
||||
}
|
||||
|
||||
char *cwmp_get_parameter_attributes(char *parameter_name, struct list_head *parameters_list)
|
||||
char *cwmp_get_parameter_attributes(const char *parameter_name, struct list_head *parameters_list)
|
||||
{
|
||||
char *error = NULL;
|
||||
|
||||
|
|
@ -337,7 +339,7 @@ char *cwmp_get_parameter_attributes(char *parameter_name, struct list_head *para
|
|||
/*
|
||||
* Update notify file
|
||||
*/
|
||||
bool parameter_is_other_notif_object_child(char *parent, char *parameter)
|
||||
static bool parameter_is_other_notif_object_child(const char *parent, const char *parameter)
|
||||
{
|
||||
struct list_head list_iter, *list_ptr;
|
||||
list_iter.next = list_param_obj_notify.next;
|
||||
|
|
@ -450,6 +452,8 @@ void cwmp_update_enabled_notify_file(void)
|
|||
|
||||
LIST_HEAD(list_notify_params);
|
||||
remove(DM_ENABLED_NOTIFY);
|
||||
|
||||
// cppcheck-suppress cert-MSC24-C
|
||||
fp = fopen(DM_ENABLED_NOTIFY, "a");
|
||||
if (fp == NULL)
|
||||
return;
|
||||
|
|
@ -520,7 +524,8 @@ void load_custom_notify_json(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
add_dm_parameter_to_list(¬ification_list_head, blobmsg_get_string(tb[0]), "", "", atoi(blobmsg_get_string(tb[1])), false);
|
||||
add_dm_parameter_to_list(¬ification_list_head, blobmsg_get_string(tb[0]), "", "",
|
||||
(int)strtol(blobmsg_get_string(tb[1]), NULL, 10), false);
|
||||
}
|
||||
blob_buf_free(&bbuf);
|
||||
cwmp_set_parameter_attributes_list(¬ification_list_head);
|
||||
|
|
@ -543,7 +548,7 @@ void set_default_forced_active_parameters_notifications()
|
|||
/*
|
||||
* Check value change
|
||||
*/
|
||||
void get_parameter_value_from_parameters_list(struct list_head *params_list, char *parameter_name, char **value, char **type)
|
||||
static void get_parameter_value_from_parameters_list(struct list_head *params_list, const char *parameter_name, char **value, char **type)
|
||||
{
|
||||
struct cwmp_dm_parameter *param_value = NULL;
|
||||
|
||||
|
|
@ -574,6 +579,8 @@ int check_value_change(void)
|
|||
|
||||
char *parameter = NULL, *value = NULL;
|
||||
int notification = 0;
|
||||
|
||||
// cppcheck-suppress cert-MSC24-C
|
||||
fp = fopen(DM_ENABLED_NOTIFY, "r");
|
||||
if (fp == NULL)
|
||||
return notif_ret;
|
||||
|
|
@ -683,7 +690,6 @@ void periodic_check_notifiy(struct uloop_timeout *timeout __attribute__((unused
|
|||
* renew of old address is NACKED by the server (In this case interface releases its
|
||||
* current IP and waits for a new IP from server) */
|
||||
// An empty connection url cause CDR test to break
|
||||
static int cr_url_retry = 3;
|
||||
|
||||
if (cr_url_retry) {
|
||||
struct cwmp_dm_parameter cwmp_dm_param = {0};
|
||||
|
|
@ -732,7 +738,7 @@ void trigger_periodic_notify_check()
|
|||
uloop_timeout_set(&check_notify_timer, 10);
|
||||
}
|
||||
|
||||
void add_list_value_change(char *param_name, char *param_data, char *param_type)
|
||||
void add_list_value_change(const char *param_name, const char *param_data, const char *param_type)
|
||||
{
|
||||
add_dm_parameter_to_list(&list_value_change, param_name, param_data, param_type, 0, false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ void cwmp_update_enabled_notify_file(void);
|
|||
int check_value_change(void);
|
||||
void sotfware_version_value_change(struct transfer_complete *p);
|
||||
void clean_list_value_change();
|
||||
char *cwmp_set_parameter_attributes(char *parameter_name, int notification);
|
||||
char *cwmp_get_parameter_attributes(char *parameter_name, struct list_head *parameters_list);
|
||||
char *cwmp_set_parameter_attributes(const char *parameter_name, int notification);
|
||||
char *cwmp_get_parameter_attributes(const char *parameter_name, struct list_head *parameters_list);
|
||||
void load_custom_notify_json(void);
|
||||
void set_default_forced_active_parameters_notifications();
|
||||
char *calculate_lwnotification_cnonce();
|
||||
|
|
|
|||
11
src/reboot.c
11
src/reboot.c
|
|
@ -42,18 +42,15 @@ void cwmp_delay_reboot(struct uloop_timeout *timeout __attribute__((unused)))
|
|||
|
||||
void launch_reboot_methods()
|
||||
{
|
||||
static int curr_delay_reboot = -1;
|
||||
static time_t curr_schedule_redoot = 0;
|
||||
|
||||
if (cwmp_main->conf.delay_reboot != curr_delay_reboot && cwmp_main->conf.delay_reboot > 0) {
|
||||
if (cwmp_main->conf.delay_reboot != cwmp_main->curr_delay_reboot && cwmp_main->conf.delay_reboot > 0) {
|
||||
CWMP_LOG(INFO, "The device will reboot after %ld seconds", cwmp_main->conf.delay_reboot);
|
||||
curr_delay_reboot = cwmp_main->conf.delay_reboot;
|
||||
cwmp_main->curr_delay_reboot = cwmp_main->conf.delay_reboot;
|
||||
uloop_timeout_cancel(&delay_reboot_timer);
|
||||
uloop_timeout_set(&delay_reboot_timer, cwmp_main->conf.delay_reboot * 1000);
|
||||
}
|
||||
|
||||
if (cwmp_main->conf.schedule_reboot != curr_schedule_redoot && (cwmp_main->conf.schedule_reboot - time(NULL)) > 0) {
|
||||
curr_schedule_redoot = cwmp_main->conf.schedule_reboot;
|
||||
if (cwmp_main->conf.schedule_reboot != cwmp_main->curr_schedule_reboot && (cwmp_main->conf.schedule_reboot - time(NULL)) > 0) {
|
||||
cwmp_main->curr_schedule_reboot = cwmp_main->conf.schedule_reboot;
|
||||
time_t remaining_time = cwmp_main->conf.schedule_reboot - time(NULL);
|
||||
CWMP_LOG(INFO, "The device will reboot after %ld seconds", remaining_time);
|
||||
uloop_timeout_cancel(&schedule_reboot_timer);
|
||||
|
|
|
|||
120
src/rpc.c
120
src/rpc.c
|
|
@ -46,7 +46,7 @@ static int cwmp_handle_rpc_cpe_schedule_inform(struct rpc *rpc);
|
|||
static int cwmp_handle_rpc_cpe_schedule_download(struct rpc *rpc);
|
||||
static int cwmp_handle_rpc_cpe_change_du_state(struct rpc *rpc);
|
||||
static int cwmp_handle_rpc_cpe_fault(struct rpc *rpc);
|
||||
static int cwmp_create_fault_message(struct rpc *rpc_cpe, int fault_code, char *fault_msg);
|
||||
static int cwmp_create_fault_message(struct rpc *rpc_cpe, int fault_code, const char *fault_msg);
|
||||
static int cwmp_rpc_acs_parse_response_inform(struct rpc *rpc);
|
||||
static int cwmp_rpc_acs_parse_response_get_rpc_methods(struct rpc *this);
|
||||
static int cwmp_rpc_acs_prepare_get_rpc_methods(struct rpc *rpc);
|
||||
|
|
@ -314,14 +314,16 @@ static void load_inform_xml_schema(mxml_node_t **tree)
|
|||
char *product_class = cwmp_main->deviceid.productclass;
|
||||
char *serial_number = cwmp_main->deviceid.serialnumber;
|
||||
int max_env = 1;
|
||||
char *current_time = get_time(time(NULL));
|
||||
char current_time[26] = {0};
|
||||
get_time(time(NULL), current_time, sizeof(current_time));
|
||||
char *str_time = current_time;
|
||||
|
||||
inform_xml_attrs.manufacturer = &manufacturer;
|
||||
inform_xml_attrs.oui = &oui;
|
||||
inform_xml_attrs.product_class = &product_class;
|
||||
inform_xml_attrs.serial_number = &serial_number;
|
||||
inform_xml_attrs.max_envelopes = &max_env;
|
||||
inform_xml_attrs.current_time = ¤t_time;
|
||||
inform_xml_attrs.current_time = &str_time;
|
||||
inform_xml_attrs.retry_count = &cwmp_main->retry_count_session;
|
||||
|
||||
LIST_HEAD(xml_events_list);
|
||||
|
|
@ -504,7 +506,7 @@ int cwmp_rpc_acs_parse_response_inform(struct rpc *this __attribute__((unused)))
|
|||
c = (char *) mxmlGetOpaque(b);
|
||||
if (c && *(c + 1) == '.') {
|
||||
c += 2;
|
||||
cwmp_main->conf.amd_version = atoi(c) + 1;
|
||||
cwmp_main->conf.amd_version = (int)strtol(c, NULL, 10) + 1;
|
||||
return 0;
|
||||
}
|
||||
goto error;
|
||||
|
|
@ -517,7 +519,7 @@ int cwmp_rpc_acs_parse_response_inform(struct rpc *this __attribute__((unused)))
|
|||
c = (char *) mxmlGetOpaque(b);
|
||||
if (c && *(c + 1) == '.') {
|
||||
c += 2;
|
||||
cwmp_main->conf.amd_version = atoi(c) + 1;
|
||||
cwmp_main->conf.amd_version = (int)strtol(c, NULL, 10) + 1;
|
||||
return 0;
|
||||
}
|
||||
goto error;
|
||||
|
|
@ -670,7 +672,7 @@ int cwmp_rpc_acs_prepare_transfer_complete(struct rpc *rpc)
|
|||
faultstring = strdup(p->fault_string);
|
||||
}
|
||||
|
||||
int faultcode = (p && p->fault_code && (p->fault_code < __FAULT_CPE_MAX)) ? atoi(FAULT_CPE_ARRAY[p->fault_code].CODE) : 0;
|
||||
int faultcode = (p && p->fault_code && (p->fault_code < __FAULT_CPE_MAX)) ? (int)strtol(FAULT_CPE_ARRAY[p->fault_code].CODE, NULL, 10) : 0;
|
||||
transfer_complete_xml_attrs.fault_code = &faultcode;
|
||||
|
||||
if (faultstring == NULL)
|
||||
|
|
@ -845,7 +847,7 @@ int cwmp_handle_rpc_cpe_get_parameter_values(struct rpc *rpc)
|
|||
mxml_node_t *b = NULL;
|
||||
int fault_code = FAULT_CPE_INTERNAL_ERROR;
|
||||
int counter = 0;
|
||||
char *err_msg = NULL;
|
||||
const char *err_msg = NULL;
|
||||
|
||||
if (cwmp_main->session->tree_out == NULL) {
|
||||
err_msg = "Output xml tree does not exist";
|
||||
|
|
@ -875,7 +877,12 @@ int cwmp_handle_rpc_cpe_get_parameter_values(struct rpc *rpc)
|
|||
gpv_xml_attrs.rpc_enum = SOAP_PARAM_STRUCT;
|
||||
gpv_xml_attrs.counter = &counter;
|
||||
gpv_xml_attrs.inc_counter = false;
|
||||
char *xsi_type = "soap_enc:Array";
|
||||
char *xsi_type = strdup("soap_enc:Array");
|
||||
if (!xsi_type) {
|
||||
err_msg = "Failed to allocate memory to build GPV response";
|
||||
goto fault;
|
||||
}
|
||||
|
||||
char *soap_array_type = NULL;
|
||||
gpv_xml_attrs.xsi_type = &xsi_type;
|
||||
gpv_xml_attrs.soap_enc_array_type = &soap_array_type;
|
||||
|
|
@ -884,6 +891,8 @@ int cwmp_handle_rpc_cpe_get_parameter_values(struct rpc *rpc)
|
|||
|
||||
cwmp_free_all_xml_data_list(&gpv_xml_data_list);
|
||||
|
||||
FREE(xsi_type);
|
||||
|
||||
if (fault_code)
|
||||
goto fault;
|
||||
|
||||
|
|
@ -904,7 +913,7 @@ int cwmp_handle_rpc_cpe_get_parameter_names(struct rpc *rpc)
|
|||
char *parameter_name = NULL;
|
||||
bool next_level = true;
|
||||
int counter = 0, fault_code;
|
||||
char *err_msg = NULL;
|
||||
const char *err_msg = NULL;
|
||||
LIST_HEAD(parameters_list);
|
||||
|
||||
struct xml_data_struct gpn_xml_attrs = {0};
|
||||
|
|
@ -996,7 +1005,13 @@ build_response:
|
|||
gpv_resp_xml_attrs.data_list = &prameters_xml_list;
|
||||
gpv_resp_xml_attrs.counter = &counter;
|
||||
gpv_resp_xml_attrs.inc_counter = true;
|
||||
char *xsi_type = "soap_enc:Array";
|
||||
char *xsi_type = strdup("soap_enc:Array");
|
||||
if (!xsi_type) {
|
||||
fault_code = FAULT_CPE_INTERNAL_ERROR;
|
||||
err_msg = "Failed to allocate memory to build GPN response";
|
||||
goto fault;
|
||||
}
|
||||
|
||||
char *soap_array_type = NULL;
|
||||
gpv_resp_xml_attrs.xsi_type = &xsi_type;
|
||||
gpv_resp_xml_attrs.soap_enc_array_type = &soap_array_type;
|
||||
|
|
@ -1006,6 +1021,8 @@ build_response:
|
|||
cwmp_free_all_dm_parameter_list(¶meters_list);
|
||||
cwmp_free_all_xml_data_list(&prameters_xml_list);
|
||||
|
||||
FREE(xsi_type);
|
||||
|
||||
if (fault_code != CWMP_OK) {
|
||||
err_msg = "Failed to build the xml data nodes for GPN response message";
|
||||
goto fault;
|
||||
|
|
@ -1027,7 +1044,7 @@ int cwmp_handle_rpc_cpe_get_parameter_attributes(struct rpc *rpc)
|
|||
{
|
||||
mxml_node_t *n, *b;
|
||||
int counter = 0, fault_code = FAULT_CPE_INTERNAL_ERROR;
|
||||
char *err_msg = NULL;
|
||||
const char *err_msg = NULL;
|
||||
|
||||
b = cwmp_main->session->body_in;
|
||||
|
||||
|
|
@ -1056,7 +1073,13 @@ int cwmp_handle_rpc_cpe_get_parameter_attributes(struct rpc *rpc)
|
|||
gpa_xml_attrs.counter = &counter;
|
||||
gpa_xml_attrs.inc_counter = false;
|
||||
char *soap_array_type = NULL;
|
||||
char *xsi_type = "soap_enc:Array";
|
||||
char *xsi_type = strdup("soap_enc:Array");
|
||||
if (!xsi_type) {
|
||||
fault_code = FAULT_CPE_INTERNAL_ERROR;
|
||||
err_msg = "Failed to allocate memory to build GetParameterAttributes response";
|
||||
goto fault;
|
||||
}
|
||||
|
||||
gpa_xml_attrs.xsi_type = &xsi_type;
|
||||
gpa_xml_attrs.soap_enc_array_type = &soap_array_type;
|
||||
mxml_node_t *resp = n;
|
||||
|
|
@ -1064,6 +1087,8 @@ int cwmp_handle_rpc_cpe_get_parameter_attributes(struct rpc *rpc)
|
|||
|
||||
cwmp_free_all_xml_data_list(&gpa_xml_data_list);
|
||||
|
||||
FREE(xsi_type);
|
||||
|
||||
if (fault_code)
|
||||
goto fault;
|
||||
|
||||
|
|
@ -1101,7 +1126,7 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct rpc *rpc)
|
|||
mxml_node_t *b = NULL;
|
||||
char *parameter_key = NULL;
|
||||
int fault_code, ret = 0;
|
||||
char *err_msg = NULL;
|
||||
const char *err_msg = NULL;
|
||||
|
||||
LIST_HEAD(xml_list_set_param_value);
|
||||
LIST_HEAD(list_set_param_value);
|
||||
|
|
@ -1196,7 +1221,7 @@ int cwmp_handle_rpc_cpe_set_parameter_attributes(struct rpc *rpc)
|
|||
mxml_node_t *n;
|
||||
int fault_code = FAULT_CPE_INTERNAL_ERROR, ret = 0;
|
||||
char c[256];
|
||||
char *err_msg = NULL;
|
||||
const char *err_msg = NULL;
|
||||
|
||||
if (snprintf(c, sizeof(c), "%s:%s", ns.cwmp, "SetParameterAttributes") == -1) {
|
||||
err_msg = "Failed to write in buffer, string operation failure";
|
||||
|
|
@ -1264,7 +1289,7 @@ int cwmp_handle_rpc_cpe_add_object(struct rpc *rpc)
|
|||
char *parameter_key = NULL;
|
||||
int ret = 0;
|
||||
struct object_result res = {0};
|
||||
char *err_msg = NULL;
|
||||
const char *err_msg = NULL;
|
||||
|
||||
struct xml_data_struct add_obj_xml_attrs = {0};
|
||||
add_obj_xml_attrs.object_name = &object_name;
|
||||
|
|
@ -1308,7 +1333,7 @@ int cwmp_handle_rpc_cpe_add_object(struct rpc *rpc)
|
|||
}
|
||||
|
||||
struct xml_data_struct add_resp_xml_attrs = {0};
|
||||
int instance_int = atoi(res.instance);
|
||||
int instance_int = (int)strtol(res.instance, NULL, 10);
|
||||
int status = 0;
|
||||
|
||||
add_resp_xml_attrs.instance = &instance_int;
|
||||
|
|
@ -1350,7 +1375,7 @@ int cwmp_handle_rpc_cpe_delete_object(struct rpc *rpc)
|
|||
char *parameter_key = NULL;
|
||||
int ret = 0;
|
||||
struct object_result res = {0};
|
||||
char *err_msg = NULL;
|
||||
const char *err_msg = NULL;
|
||||
|
||||
struct xml_data_struct del_obj_xml_attrs = {0};
|
||||
del_obj_xml_attrs.object_name = &object_name;
|
||||
|
|
@ -1422,7 +1447,7 @@ int cwmp_handle_rpc_cpe_get_rpc_methods(struct rpc *rpc)
|
|||
mxml_node_t *n;
|
||||
int i, counter = 0;
|
||||
int fault_code = FAULT_CPE_INTERNAL_ERROR;
|
||||
char *err_msg = NULL;
|
||||
const char *err_msg = NULL;
|
||||
|
||||
n = build_top_body_soap_response(cwmp_main->session->tree_out, "GetRPCMethods");
|
||||
|
||||
|
|
@ -1447,7 +1472,13 @@ int cwmp_handle_rpc_cpe_get_rpc_methods(struct rpc *rpc)
|
|||
getrpc_resp_xml_attrs.data_list = &rpcs_list;
|
||||
getrpc_resp_xml_attrs.counter = &counter;
|
||||
getrpc_resp_xml_attrs.inc_counter = false;
|
||||
char *xsi_type = "soap_enc:Array";
|
||||
char *xsi_type = strdup("soap_enc:Array");
|
||||
if (!xsi_type) {
|
||||
fault_code = FAULT_CPE_INTERNAL_ERROR;
|
||||
err_msg = "Failed to allocate memory to build GetRPC response";
|
||||
goto fault;
|
||||
}
|
||||
|
||||
char *soap_array_type = NULL;
|
||||
getrpc_resp_xml_attrs.xsi_type = &xsi_type;
|
||||
getrpc_resp_xml_attrs.soap_enc_array_type = &soap_array_type;
|
||||
|
|
@ -1456,6 +1487,8 @@ int cwmp_handle_rpc_cpe_get_rpc_methods(struct rpc *rpc)
|
|||
fault_code = build_xml_node_data(SOAP_RESP_GETRPC, n, &getrpc_resp_xml_attrs);
|
||||
cwmp_free_all_xml_data_list(&rpcs_list);
|
||||
|
||||
FREE(xsi_type);
|
||||
|
||||
if (fault_code != CWMP_OK) {
|
||||
err_msg = "Failed to build xml data nodes for GetRPCMethods response";
|
||||
goto fault;
|
||||
|
|
@ -1476,7 +1509,7 @@ fault:
|
|||
int cwmp_handle_rpc_cpe_factory_reset(struct rpc *rpc)
|
||||
{
|
||||
mxml_node_t *b;
|
||||
char *err_msg = NULL;
|
||||
const char *err_msg = NULL;
|
||||
|
||||
b = build_top_body_soap_response(cwmp_main->session->tree_out, "FactoryReset");
|
||||
|
||||
|
|
@ -1530,7 +1563,7 @@ int cwmp_handle_rpc_cpe_cancel_transfer(struct rpc *rpc)
|
|||
{
|
||||
mxml_node_t *b;
|
||||
char *command_key = NULL;
|
||||
char *err_msg = NULL;
|
||||
const char *err_msg = NULL;
|
||||
|
||||
struct xml_data_struct canceltrancer_obj_xml_attrs = {0};
|
||||
canceltrancer_obj_xml_attrs.command_key = &command_key;
|
||||
|
|
@ -1610,7 +1643,7 @@ int cwmp_handle_rpc_cpe_reboot(struct rpc *rpc)
|
|||
mxml_node_t *b;
|
||||
struct event_container *event_container;
|
||||
char *command_key = NULL;
|
||||
char *err_msg = NULL;
|
||||
const char *err_msg = NULL;
|
||||
|
||||
struct xml_data_struct reboot_obj_xml_attrs = {0};
|
||||
reboot_obj_xml_attrs.command_key = &command_key;
|
||||
|
|
@ -1834,6 +1867,8 @@ int cwmp_handle_rpc_cpe_download(struct rpc *rpc)
|
|||
time_t scheduled_time = 0;
|
||||
time_t download_delay = 0;
|
||||
char err_msg[256] = {0};
|
||||
char *start_time = NULL;
|
||||
char *complete_time = NULL;
|
||||
|
||||
if (snprintf(c, sizeof(c), "%s:%s", ns.cwmp, "Download") == -1) {
|
||||
error = FAULT_CPE_INTERNAL_ERROR;
|
||||
|
|
@ -1902,8 +1937,14 @@ int cwmp_handle_rpc_cpe_download(struct rpc *rpc)
|
|||
goto fault;
|
||||
}
|
||||
|
||||
char *start_time = "0001-01-01T00:00:00+00:00";
|
||||
char *complete_time = "0001-01-01T00:00:00+00:00";
|
||||
start_time = strdup("0001-01-01T00:00:00+00:00");
|
||||
complete_time = strdup("0001-01-01T00:00:00+00:00");
|
||||
if (!start_time || !complete_time) {
|
||||
error = FAULT_CPE_INTERNAL_ERROR;
|
||||
snprintf(err_msg , sizeof(err_msg), "Failed to allocate memory to build download response");
|
||||
goto fault;
|
||||
}
|
||||
|
||||
int status = 1;
|
||||
|
||||
struct xml_data_struct download_resp_xml_attrs = {0};
|
||||
|
|
@ -1947,9 +1988,13 @@ int cwmp_handle_rpc_cpe_download(struct rpc *rpc)
|
|||
cwmp_set_end_session(END_SESSION_DOWNLOAD);
|
||||
}
|
||||
|
||||
FREE(start_time);
|
||||
FREE(complete_time);
|
||||
return 0;
|
||||
|
||||
fault:
|
||||
FREE(start_time);
|
||||
FREE(complete_time);
|
||||
cwmp_free_download_request(download);
|
||||
if (cwmp_create_fault_message(rpc, error, err_msg))
|
||||
return -1;
|
||||
|
|
@ -2129,6 +2174,8 @@ int cwmp_handle_rpc_cpe_upload(struct rpc *rpc)
|
|||
time_t upload_delay = 0;
|
||||
char c[256];
|
||||
char err_msg[256] = {0};
|
||||
char *start_time = NULL;
|
||||
char *complete_time = NULL;
|
||||
|
||||
if (snprintf(c, sizeof(c), "%s:%s", ns.cwmp, "Upload") == -1) {
|
||||
error = FAULT_CPE_INTERNAL_ERROR;
|
||||
|
|
@ -2197,8 +2244,14 @@ int cwmp_handle_rpc_cpe_upload(struct rpc *rpc)
|
|||
goto fault;
|
||||
}
|
||||
|
||||
char *start_time = "0001-01-01T00:00:00+00:00";
|
||||
char *complete_time = "0001-01-01T00:00:00+00:00";
|
||||
start_time = strdup("0001-01-01T00:00:00+00:00");
|
||||
complete_time = strdup("0001-01-01T00:00:00+00:00");
|
||||
if (!start_time || !complete_time) {
|
||||
error = FAULT_CPE_INTERNAL_ERROR;
|
||||
snprintf(err_msg , sizeof(err_msg), "Failed to allocate memory to build upload response");
|
||||
goto fault;
|
||||
}
|
||||
|
||||
int status = 1;
|
||||
|
||||
struct xml_data_struct upload_resp_xml_attrs = {0};
|
||||
|
|
@ -2241,9 +2294,14 @@ int cwmp_handle_rpc_cpe_upload(struct rpc *rpc)
|
|||
}
|
||||
cwmp_set_end_session(END_SESSION_UPLOAD);
|
||||
}
|
||||
|
||||
FREE(start_time);
|
||||
FREE(complete_time);
|
||||
return 0;
|
||||
|
||||
fault:
|
||||
FREE(start_time);
|
||||
FREE(complete_time);
|
||||
cwmp_free_upload_request(upload);
|
||||
if (cwmp_create_fault_message(rpc, error, err_msg))
|
||||
return -1;
|
||||
|
|
@ -2262,9 +2320,12 @@ int cwmp_handle_rpc_cpe_fault(struct rpc *rpc)
|
|||
struct xml_data_struct fault_xml_attrs = {0};
|
||||
|
||||
char *faultcode = (FAULT_CPE_ARRAY[cwmp_main->session->fault_code].TYPE == FAULT_CPE_TYPE_CLIENT) ? "Client" : "Server";
|
||||
char *faultstring = "CWMP fault";
|
||||
char *faultstring = strdup("CWMP fault");
|
||||
if (!faultstring) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fault_code = atoi(cwmp_main->session->fault_code ? FAULT_CPE_ARRAY[cwmp_main->session->fault_code].CODE : "0");
|
||||
int fault_code = (int)strtol(cwmp_main->session->fault_code ? FAULT_CPE_ARRAY[cwmp_main->session->fault_code].CODE : "0", NULL, 10);
|
||||
char *fault_string = CWMP_STRLEN(cwmp_main->session->fault_msg) ? strdup(cwmp_main->session->fault_msg) : strdup(FAULT_CPE_ARRAY[cwmp_main->session->fault_code].DESCRIPTION);
|
||||
|
||||
fault_xml_attrs.fault_code = &fault_code;
|
||||
|
|
@ -2274,6 +2335,7 @@ int cwmp_handle_rpc_cpe_fault(struct rpc *rpc)
|
|||
|
||||
int fault = build_xml_node_data(SOAP_ROOT_FAULT, body, &fault_xml_attrs);
|
||||
FREE(fault_string);
|
||||
FREE(faultstring);
|
||||
if (fault)
|
||||
return -1;
|
||||
|
||||
|
|
@ -2299,7 +2361,7 @@ int cwmp_handle_rpc_cpe_fault(struct rpc *rpc)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cwmp_create_fault_message(struct rpc *rpc_cpe, int fault_code, char *fault_msg)
|
||||
int cwmp_create_fault_message(struct rpc *rpc_cpe, int fault_code, const char *fault_msg)
|
||||
{
|
||||
CWMP_LOG(INFO, "Fault detected");
|
||||
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ static int cwmp_get_retry_interval(void)
|
|||
|
||||
static void set_cwmp_session_status_state(int status)
|
||||
{
|
||||
char *state = NULL;
|
||||
const char *state = NULL;
|
||||
|
||||
// Create sess_status config section
|
||||
set_uci_path_value(VARSTATE_CONFIG, "icwmp.sess_status", "sess_status");
|
||||
|
|
|
|||
|
|
@ -35,10 +35,10 @@ typedef struct session {
|
|||
mxml_node_t *tree_in;
|
||||
mxml_node_t *tree_out;
|
||||
mxml_node_t *body_in;
|
||||
char fault_msg[256];
|
||||
bool hold_request;
|
||||
int fault_code;
|
||||
int error;
|
||||
char fault_msg[256];
|
||||
} session;
|
||||
|
||||
struct session_timer_event {
|
||||
|
|
|
|||
|
|
@ -52,11 +52,9 @@ end:
|
|||
void message_compute_signature(char *msg_out, char *signature, size_t len)
|
||||
{
|
||||
int result_len = 20;
|
||||
struct config *conf;
|
||||
unsigned char result[EVP_MAX_MD_SIZE] = {0};
|
||||
|
||||
conf = &(cwmp_main->conf);
|
||||
HMAC(EVP_sha1(), conf->acs_passwd, CWMP_STRLEN(conf->acs_passwd), (unsigned char *)msg_out, CWMP_STRLEN(msg_out), result, NULL);
|
||||
HMAC(EVP_sha1(), cwmp_main->conf.acs_passwd, CWMP_STRLEN(cwmp_main->conf.acs_passwd), (unsigned char *)msg_out, CWMP_STRLEN(msg_out), result, NULL);
|
||||
|
||||
for (int i = 0; i < result_len; i++) {
|
||||
if (len - CWMP_STRLEN(signature) < 3) // each time 2 hex chars + '\0' at end so needed space is 3 bytes
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ typedef char* (*task_function)(char *task_arg);
|
|||
|
||||
static int pipefd1[2], pipefd2[2];
|
||||
|
||||
bool check_task_name(char *task, char *name)
|
||||
static bool check_task_name(char *task, const char *name)
|
||||
{
|
||||
struct blob_buf bbuf;
|
||||
|
||||
|
|
@ -119,7 +119,7 @@ int subprocess_start(task_function task_fun)
|
|||
return CWMP_OK;
|
||||
}
|
||||
|
||||
char *execute_task_in_subprocess(char *task)
|
||||
char *execute_task_in_subprocess(const char *task)
|
||||
{
|
||||
char *ret = NULL;
|
||||
int len = 0;
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@
|
|||
#include <libubox/blobmsg_json.h>
|
||||
typedef char* (*task_function)(char *task_arg);
|
||||
int subprocess_start(task_function task_fun);
|
||||
char *execute_task_in_subprocess(char *task);
|
||||
char *execute_task_in_subprocess(const char *task);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ static time_t get_nonzero_min_time(time_t time1, time_t time2, time_t time3)
|
|||
int i;
|
||||
int size = sizeof(arr)/sizeof(time_t);
|
||||
|
||||
for (i = 0; i < size && arr[i] == 0; i++); // find the first non zero element
|
||||
for (i = 0; i < size && arr[i] == 0; i++) {} // find the first non zero element
|
||||
|
||||
if (i == size) {
|
||||
return min; // array has no non-zero values
|
||||
|
|
@ -223,32 +223,58 @@ static void bb_add_icwmp_status(struct blob_buf *bb)
|
|||
CWMP_LOG(ERROR, "icwmp status blob is null");
|
||||
return;
|
||||
}
|
||||
|
||||
char start_time[26] = {0};
|
||||
get_time(cwmp_main->start_time, start_time, sizeof(start_time));
|
||||
|
||||
void *tbl = blobmsg_open_table(bb, "cwmp");
|
||||
bb_add_string(bb, "status", "up");
|
||||
bb_add_string(bb, "start_time", get_time(cwmp_main->start_time));
|
||||
bb_add_string(bb, "start_time", start_time);
|
||||
bb_add_string(bb, "acs_url", cwmp_main->conf.acs_url);
|
||||
blobmsg_close_table(bb, tbl);
|
||||
}
|
||||
|
||||
static void bb_add_icwmp_last_session(struct blob_buf *bb)
|
||||
{
|
||||
|
||||
char start_time[26] = {0};
|
||||
char end_time[26] = {0};
|
||||
|
||||
void *tbl = blobmsg_open_table(bb, "last_session");
|
||||
const char *status = cwmp_main->session->session_status.last_start_time ? arr_session_status[cwmp_main->session->session_status.last_status] : "N/A";
|
||||
|
||||
if (cwmp_main->session->session_status.last_start_time) {
|
||||
get_time(cwmp_main->session->session_status.last_start_time, start_time, sizeof(start_time));
|
||||
} else {
|
||||
snprintf(start_time, sizeof(start_time), "N/A");
|
||||
}
|
||||
|
||||
if (cwmp_main->session->session_status.last_end_time) {
|
||||
get_time(cwmp_main->session->session_status.last_end_time, end_time, sizeof(end_time));
|
||||
} else {
|
||||
snprintf(end_time, sizeof(end_time), "N/A");
|
||||
}
|
||||
|
||||
bb_add_string(bb, "status", status);
|
||||
char *start_time = cwmp_main->session->session_status.last_start_time ? get_time(cwmp_main->session->session_status.last_start_time) : "N/A";
|
||||
bb_add_string(bb, "start_time", start_time);
|
||||
char *end_time = cwmp_main->session->session_status.last_end_time ? get_time(cwmp_main->session->session_status.last_end_time) : "N/A";
|
||||
bb_add_string(bb, "end_time", end_time);
|
||||
blobmsg_close_table(bb, tbl);
|
||||
}
|
||||
|
||||
static void bb_add_icwmp_next_session(struct blob_buf *bb)
|
||||
{
|
||||
char next_time[26] = {0};
|
||||
time_t ntime = get_next_session_time();
|
||||
|
||||
if (ntime) {
|
||||
get_time(ntime, next_time, sizeof(next_time));
|
||||
} else {
|
||||
snprintf(next_time, sizeof(next_time), "N/A");
|
||||
}
|
||||
|
||||
void *tbl = blobmsg_open_table(bb, "next_session");
|
||||
bb_add_string(bb, "status", arr_session_status[SESSION_WAITING]);
|
||||
time_t ntime = get_next_session_time();
|
||||
char *start_time = ntime ? get_time(ntime) : "N/A";
|
||||
bb_add_string(bb, "start_time", start_time);
|
||||
bb_add_string(bb, "start_time", next_time);
|
||||
bb_add_string(bb, "end_time", "N/A");
|
||||
blobmsg_close_table(bb, tbl);
|
||||
}
|
||||
|
|
@ -304,7 +330,7 @@ static int icwmp_inform_get_rpc_method(struct blob_buf *bb)
|
|||
return EVENT_IDX_2PERIODIC;
|
||||
}
|
||||
|
||||
static int icwmp_inform_event(struct blob_buf *bb, char *event)
|
||||
static int icwmp_inform_event(struct blob_buf *bb, const char *event)
|
||||
{
|
||||
int event_code = cwmp_get_int_event_code(event);
|
||||
if (event_code != -1) {
|
||||
|
|
@ -327,7 +353,7 @@ static int icwmp_inform_handler(struct ubus_context *ctx, struct ubus_object *ob
|
|||
|
||||
struct blob_attr *tb[__INFORM_MAX] = {0};
|
||||
bool is_get_rpc = false;
|
||||
char *event = "";
|
||||
const char *event = "";
|
||||
int event_code;
|
||||
|
||||
int ret = blobmsg_parse(icwmp_inform_policy, ARRAY_SIZE(icwmp_inform_policy), tb, blob_data(msg), blob_len(msg));
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
pthread_mutex_t mutex_config_load = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
// STATIC functions
|
||||
static int _uci_get_value_by_section_string(struct uci_section *s, char *option, char *value, int len)
|
||||
static int _uci_get_value_by_section_string(struct uci_section *s, const char *option, char *value, int len)
|
||||
{
|
||||
struct uci_element *e;
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ static void config_get_acs_elements(struct uci_section *s)
|
|||
char *op_interval = cwmp_main->conf.dhcp_discovery ? acs_dhcp_retry_min_wait_interval : acs_retry_min_wait_interval;
|
||||
if (strlen(op_interval) != 0) {
|
||||
if (cwmp_main->conf.amd_version >= AMD_3) {
|
||||
int a = atoi(op_interval);
|
||||
int a = (int)strtol(op_interval, NULL, 10);
|
||||
cwmp_main->conf.retry_min_wait_interval = (a <= 65535 && a >= 1) ? a : DEFAULT_RETRY_MINIMUM_WAIT_INTERVAL;
|
||||
}
|
||||
}
|
||||
|
|
@ -164,7 +164,7 @@ static void config_get_acs_elements(struct uci_section *s)
|
|||
char *op_multi = cwmp_main->conf.dhcp_discovery ? acs_dhcp_retry_interval_multiplier : acs_retry_interval_multiplier;
|
||||
if (strlen(op_multi) != 0) {
|
||||
if (cwmp_main->conf.amd_version >= AMD_3) {
|
||||
int a = atoi(op_multi);
|
||||
int a = (int)strtol(op_multi, NULL, 10);
|
||||
cwmp_main->conf.retry_interval_multiplier = (a <= 65535 && a >= 1000) ? a : DEFAULT_RETRY_INTERVAL_MULTIPLIER;
|
||||
}
|
||||
}
|
||||
|
|
@ -191,7 +191,7 @@ static void config_get_acs_elements(struct uci_section *s)
|
|||
cwmp_main->conf.period = PERIOD_INFORM_DEFAULT;
|
||||
char *inform_interval = get_value_from_uci_option(acs_tb[UCI_ACS_PERIODIC_INFORM_INTERVAL]);
|
||||
if (strlen(inform_interval) != 0) {
|
||||
int a = atoi(inform_interval);
|
||||
int a = (int)strtol(inform_interval, NULL, 10);
|
||||
cwmp_main->conf.period = (a >= PERIOD_INFORM_MIN) ? a : PERIOD_INFORM_DEFAULT;
|
||||
}
|
||||
CWMP_LOG(DEBUG, "CWMP CONFIG - acs periodic inform: %d", cwmp_main->conf.period);
|
||||
|
|
@ -205,7 +205,7 @@ static void config_get_acs_elements(struct uci_section *s)
|
|||
cwmp_main->conf.heartbeat_interval = 30;
|
||||
char *heartbeat_interval = get_value_from_uci_option(acs_tb[UCI_ACS_HEARTBEAT_INTERVAL]);
|
||||
if (strlen(heartbeat_interval) != 0) {
|
||||
int a = atoi(heartbeat_interval);
|
||||
int a = (int)strtol(heartbeat_interval, NULL, 10);
|
||||
cwmp_main->conf.heartbeat_interval = a;
|
||||
}
|
||||
CWMP_LOG(DEBUG, "CWMP CONFIG - acs heartbeat interval: %d", cwmp_main->conf.heartbeat_interval);
|
||||
|
|
@ -294,7 +294,7 @@ static void config_get_cpe_elements(struct uci_section *s)
|
|||
cwmp_main->conf.connection_request_port = DEFAULT_CONNECTION_REQUEST_PORT;
|
||||
char *port = get_value_from_uci_option(cpe_tb[UCI_CPE_PORT]);
|
||||
if (strlen(port) != 0) {
|
||||
int a = atoi(port);
|
||||
int a = (int)strtol(port, NULL, 10);
|
||||
cwmp_main->conf.connection_request_port = (a != 0) ? a : DEFAULT_CONNECTION_REQUEST_PORT;
|
||||
}
|
||||
CWMP_LOG(DEBUG, "CWMP CONFIG - cpe connection request port: %d", cwmp_main->conf.connection_request_port);
|
||||
|
|
@ -316,7 +316,7 @@ static void config_get_cpe_elements(struct uci_section *s)
|
|||
cwmp_main->conf.periodic_notify_interval = DEFAULT_NOTIFY_PERIOD;
|
||||
char *notify_period = get_value_from_uci_option(cpe_tb[UCI_CPE_NOTIFY_PERIOD]);
|
||||
if (strlen(notify_period) != 0) {
|
||||
int a = atoi(notify_period);
|
||||
int a = (int)strtol(notify_period, NULL, 10);
|
||||
cwmp_main->conf.periodic_notify_interval = (a != 0) ? a : DEFAULT_NOTIFY_PERIOD;
|
||||
}
|
||||
CWMP_LOG(DEBUG, "CWMP CONFIG - cpe periodic notify interval: %d", cwmp_main->conf.periodic_notify_interval);
|
||||
|
|
@ -330,28 +330,28 @@ static void config_get_cpe_elements(struct uci_section *s)
|
|||
cwmp_main->conf.delay_reboot = -1;
|
||||
char *delay_reboot = get_value_from_uci_option(cpe_tb[UCI_CPE_DELAY_REBOOT]);
|
||||
if (strlen(delay_reboot) != 0) {
|
||||
int a = atoi(delay_reboot);
|
||||
int a = (int)strtol(delay_reboot, NULL, 10);
|
||||
cwmp_main->conf.delay_reboot = (a > 0) ? a : -1;
|
||||
}
|
||||
|
||||
cwmp_main->conf.active_notif_throttle = 0;
|
||||
char *notify_thottle = get_value_from_uci_option(cpe_tb[UCI_CPE_ACTIVE_NOTIF_THROTTLE]);
|
||||
if (strlen(notify_thottle) != 0) {
|
||||
int a = atoi(notify_thottle);
|
||||
int a = (int)strtol(notify_thottle, NULL, 10);
|
||||
cwmp_main->conf.active_notif_throttle = (a > 0) ? a : 0;
|
||||
}
|
||||
|
||||
cwmp_main->conf.md_notif_limit = 0;
|
||||
char *notify_limit = get_value_from_uci_option(cpe_tb[UCI_CPE_MANAGEABLE_DEVICES_NOTIF_LIMIT]);
|
||||
if (strlen(notify_limit) != 0) {
|
||||
int a = atoi(notify_limit);
|
||||
int a = (int)strtol(notify_limit, NULL, 10);
|
||||
cwmp_main->conf.md_notif_limit = (a > 0) ? a : 0;
|
||||
}
|
||||
|
||||
cwmp_main->conf.session_timeout = DEFAULT_SESSION_TIMEOUT;
|
||||
char *session_timeout = get_value_from_uci_option(cpe_tb[UCI_CPE_SESSION_TIMEOUT]);
|
||||
if (strlen(session_timeout) != 0) {
|
||||
int a = atoi(session_timeout);
|
||||
int a = (int)strtol(session_timeout, NULL, 10);
|
||||
cwmp_main->conf.session_timeout = (a >= 1) ? a : DEFAULT_SESSION_TIMEOUT;
|
||||
}
|
||||
|
||||
|
|
@ -397,7 +397,7 @@ static void config_get_cpe_elements(struct uci_section *s)
|
|||
cwmp_main->conf.clock_sync_timeout = DEFAULT_SYNC_TIMEOUT;
|
||||
char *sync_time = get_value_from_uci_option(cpe_tb[UCI_CPE_CLOCK_SYNC_TIMEOUT]);
|
||||
if (CWMP_STRLEN(sync_time) != 0) {
|
||||
int val = atoi(sync_time);
|
||||
int val = (int)strtol(sync_time, NULL, 10);
|
||||
if (val >= 0 && val <= 180) {
|
||||
cwmp_main->conf.clock_sync_timeout = val;
|
||||
}
|
||||
|
|
@ -443,7 +443,7 @@ static void config_get_lwn_elements(struct uci_section *s)
|
|||
cwmp_main->conf.lwn_port = DEFAULT_LWN_PORT;
|
||||
char *port = get_value_from_uci_option(lwn_tb[UCI_LWN_PORT]);
|
||||
if (strlen(port) != 0) {
|
||||
int a = atoi(port);
|
||||
int a = (int)strtol(port, NULL, 10);
|
||||
cwmp_main->conf.lwn_port = a;
|
||||
}
|
||||
CWMP_LOG(DEBUG, "CWMP CONFIG - lwn port: %d", cwmp_main->conf.lwn_port);
|
||||
|
|
@ -527,6 +527,7 @@ static int _export_uci_package(struct uci_context *uci_ctx, char *package, const
|
|||
if (output_path == NULL)
|
||||
return -1;
|
||||
|
||||
// cppcheck-suppress cert-MSC24-C
|
||||
FILE *out = fopen(output_path, "a");
|
||||
if (!out)
|
||||
return -1;
|
||||
|
|
@ -604,7 +605,7 @@ end:
|
|||
return 0;
|
||||
}
|
||||
|
||||
int import_uci_package(char *package_name, const char *input_path)
|
||||
int import_uci_package(const char *package_name, const char *input_path)
|
||||
{
|
||||
struct uci_context *uci_ctx = NULL;
|
||||
struct uci_package *package = NULL;
|
||||
|
|
@ -616,6 +617,7 @@ int import_uci_package(char *package_name, const char *input_path)
|
|||
return -1;
|
||||
}
|
||||
|
||||
// cppcheck-suppress cert-MSC24-C
|
||||
input = fopen(input_path, "r");
|
||||
if (!input)
|
||||
return -1;
|
||||
|
|
@ -648,7 +650,7 @@ end:
|
|||
return ret;
|
||||
}
|
||||
|
||||
int get_uci_path_value(const char *conf_dir, char *path, char *value, size_t max_value_len)
|
||||
int get_uci_path_value(const char *conf_dir, const char *path, char *value, size_t max_value_len)
|
||||
{
|
||||
struct uci_context *uci_ctx = NULL;
|
||||
struct uci_ptr ptr;
|
||||
|
|
@ -759,7 +761,7 @@ exit:
|
|||
return ret;
|
||||
}
|
||||
|
||||
int set_uci_path_value(const char *conf_dir, char *path, char *value)
|
||||
int set_uci_path_value(const char *conf_dir, const char *path, const char *value)
|
||||
{
|
||||
struct uci_context *uci_ctx = NULL;
|
||||
struct uci_ptr ptr;
|
||||
|
|
@ -842,7 +844,7 @@ exit:
|
|||
return ret;
|
||||
}
|
||||
|
||||
int set_uci_list_value(const char *conf_dir, char *path, char *value)
|
||||
int set_uci_list_value(const char *conf_dir, const char *path, const char *value)
|
||||
{
|
||||
struct uci_context *uci_ctx = NULL;
|
||||
struct uci_ptr ptr;
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ struct strNode {
|
|||
|
||||
int export_uci_package(char *package, const char *output_path);
|
||||
int export_std_uci(const char *output_path);
|
||||
int import_uci_package(char *package_name, const char *input_path);
|
||||
int get_uci_path_value(const char *conf_dir, char *path, char *value, size_t max_value_len);
|
||||
int import_uci_package(const char *package_name, const char *input_path);
|
||||
int get_uci_path_value(const char *conf_dir, const char *path, char *value, size_t max_value_len);
|
||||
int get_uci_dm_list(const char *conf_dir, char *path, struct list_head *head, int notif_type);
|
||||
int set_uci_path_value(const char *conf_dir, char *path, char *value);
|
||||
int set_uci_list_value(const char *conf_dir, char *path, char *value);
|
||||
int set_uci_path_value(const char *conf_dir, const char *path, const char *value);
|
||||
int set_uci_list_value(const char *conf_dir, const char *path, const char *value);
|
||||
int del_uci_list_value(const char *conf_dir, char *path, char *value);
|
||||
int get_inform_parameters_uci(struct list_head *inform_head);
|
||||
int commit_uci_package(char *package, const char *conf_dir, const char *save_dir);
|
||||
|
|
|
|||
13
src/upload.c
13
src/upload.c
|
|
@ -92,6 +92,7 @@ static long upload_file(const char *file_path, const char *url, const char *user
|
|||
return FAULT_CPE_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
// cppcheck-suppress cert-MSC24-C
|
||||
fd_upload = fopen(file_path, "rb");
|
||||
if (fd_upload == NULL) {
|
||||
CWMP_LOG(ERROR, "Failed to open file[%s] for upload", file_path);
|
||||
|
|
@ -208,7 +209,7 @@ int upload_file_in_subprocess(const char *file_path, const char *url, const char
|
|||
if (upload_task != NULL) {
|
||||
char *ret = execute_task_in_subprocess(upload_task);
|
||||
FREE(upload_task);
|
||||
return ret ? atoi(ret) : 500;
|
||||
return ret ? (int)strtol(ret, NULL, 10) : 500;
|
||||
}
|
||||
return 500;
|
||||
}
|
||||
|
|
@ -216,15 +217,16 @@ int upload_file_in_subprocess(const char *file_path, const char *url, const char
|
|||
int cwmp_launch_upload(struct upload *pupload, struct transfer_complete **ptransfer_complete)
|
||||
{
|
||||
int error = FAULT_CPE_NO_FAULT;
|
||||
char *upload_startTime;
|
||||
char upload_startTime[26] = {0};
|
||||
struct transfer_complete *p;
|
||||
char *name = NULL;
|
||||
upload_startTime = get_time(time(NULL));
|
||||
char file_path[128] = {'\0'};
|
||||
bkp_session_delete_element("upload", pupload->id);
|
||||
bkp_session_save();
|
||||
char err_msg[256] = {0};
|
||||
|
||||
get_time(time(NULL), upload_startTime, sizeof(upload_startTime));
|
||||
|
||||
if (!folder_exists(ICWMP_TMP_PATH)) {
|
||||
int status = mkdir(ICWMP_TMP_PATH, S_IRWXU);
|
||||
if (status != 0) {
|
||||
|
|
@ -299,9 +301,12 @@ end_upload:
|
|||
return error;
|
||||
}
|
||||
|
||||
char upload_endTime[26] = {0};
|
||||
get_time(time(NULL), upload_endTime, sizeof(upload_endTime));
|
||||
|
||||
p->command_key = pupload->command_key ? strdup(pupload->command_key) : strdup("");
|
||||
p->start_time = CWMP_STRDUP(upload_startTime);
|
||||
p->complete_time = CWMP_STRDUP(get_time(time(NULL)));
|
||||
p->complete_time = CWMP_STRDUP(upload_endTime);
|
||||
p->type = TYPE_UPLOAD;
|
||||
if (error != FAULT_CPE_NO_FAULT) {
|
||||
p->fault_code = error;
|
||||
|
|
|
|||
78
src/xml.c
78
src/xml.c
|
|
@ -46,7 +46,7 @@ static int build_parameter_structure(mxml_node_t *param_list, struct xml_data_st
|
|||
static int build_backup_cdu_option(mxml_node_t *cdu, struct xml_data_struct *xml_attrs);
|
||||
static int get_soap_enc_array_type(mxml_node_t *node, struct xml_data_struct *xml_attrs);
|
||||
static char *get_xml_node_name_switch(char *node_name);
|
||||
static char *get_xml_node_name_by_switch_name(char *switch_node_name);
|
||||
static char *get_xml_node_name_by_switch_name(const char *switch_node_name);
|
||||
static const char *whitespace_cb(mxml_node_t *node, int where);
|
||||
static const char *get_node_tab_space(mxml_node_t *node);
|
||||
|
||||
|
|
@ -329,7 +329,7 @@ int load_backup_event_command_key(mxml_node_t *b __attribute__((unused)), struct
|
|||
const char *command_key = mxmlGetOpaque(c);
|
||||
if (xml_attrs->index && *(xml_attrs->index) > -1) {
|
||||
if (EVENT_CONST[*(xml_attrs->index)].RETRY & EVENT_RETRY_AFTER_REBOOT) {
|
||||
xml_attrs->event_save = cwmp_add_event_container(*(xml_attrs->index), ((command_key != NULL) ? (char *)command_key : ""));
|
||||
xml_attrs->event_save = cwmp_add_event_container(*(xml_attrs->index), ((command_key != NULL) ? command_key : ""));
|
||||
if (xml_attrs->event_save != NULL)
|
||||
xml_attrs->event_save->id = *(xml_attrs->id);
|
||||
}
|
||||
|
|
@ -344,7 +344,7 @@ int load_backup_event_parameter(mxml_node_t *b, struct xml_data_struct *xml_attr
|
|||
const char *op = mxmlGetOpaque(c);
|
||||
if (op != NULL) {
|
||||
if (xml_attrs->event_save != NULL)
|
||||
add_dm_parameter_to_list(&xml_attrs->event_save->head_dm_parameter, (char *)op, NULL, NULL, 0, false);
|
||||
add_dm_parameter_to_list(&xml_attrs->event_save->head_dm_parameter, op, NULL, NULL, 0, false);
|
||||
}
|
||||
}
|
||||
return FAULT_CPE_NO_FAULT;
|
||||
|
|
@ -410,7 +410,7 @@ int load_download_filetype(mxml_node_t *b, struct xml_data_struct *xml_attrs)
|
|||
char tmp[128];
|
||||
snprintf(tmp, sizeof(tmp), "%s", *(xml_attrs->file_type));
|
||||
FREE(*(xml_attrs->file_type));
|
||||
if (cwmp_asprintf(xml_attrs->file_type, "%s %s", tmp, node_opaque) == -1)
|
||||
if (asprintf(xml_attrs->file_type, "%s %s", tmp, node_opaque) == -1)
|
||||
return FAULT_CPE_INTERNAL_ERROR;
|
||||
}
|
||||
return FAULT_CPE_NO_FAULT;
|
||||
|
|
@ -425,9 +425,10 @@ int load_sched_download_window_mode(mxml_node_t *b, struct xml_data_struct *xml_
|
|||
if (*(xml_attrs->window_mode) == NULL)
|
||||
*(xml_attrs->window_mode) = strdup(node_opaque ? node_opaque : "");
|
||||
else {
|
||||
static char *tmp = NULL;
|
||||
tmp = *(xml_attrs->window_mode);
|
||||
if (cwmp_asprintf(xml_attrs->window_mode, "%s %s", tmp, node_opaque ? node_opaque : "") == -1)
|
||||
char tmp[256];
|
||||
snprintf(tmp, sizeof(tmp), "%s", *(xml_attrs->window_mode));
|
||||
FREE(*(xml_attrs->window_mode));
|
||||
if (asprintf(xml_attrs->window_mode, "%s %s", tmp, node_opaque ? node_opaque : "") == -1)
|
||||
return FAULT_CPE_INTERNAL_ERROR;
|
||||
}
|
||||
return FAULT_CPE_NO_FAULT;
|
||||
|
|
@ -564,8 +565,11 @@ int build_inform_env_header(mxml_node_t *b, struct xml_data_struct *xml_attrs)
|
|||
if (!node)
|
||||
return FAULT_CPE_INTERNAL_ERROR;
|
||||
|
||||
char amd_versions[60] = {0};
|
||||
xml_get_cwmp_version(amd_version, amd_versions, sizeof(amd_versions));
|
||||
|
||||
mxmlElementSetAttr(node, "soap_env:mustUnderstand", "0");
|
||||
node = mxmlNewOpaque(node, xml_get_cwmp_version(amd_version));
|
||||
node = mxmlNewOpaque(node, amd_versions);
|
||||
if (!node)
|
||||
return FAULT_CPE_INTERNAL_ERROR;
|
||||
}
|
||||
|
|
@ -741,7 +745,7 @@ char *get_xml_node_name_switch(char *node_name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
char *get_xml_node_name_by_switch_name(char *switch_node_name)
|
||||
char *get_xml_node_name_by_switch_name(const char *switch_node_name)
|
||||
{
|
||||
unsigned int i;
|
||||
if (switch_node_name == NULL)
|
||||
|
|
@ -880,7 +884,7 @@ bool validate_xml_node_opaque_value(char *node_name, char *opaque, struct xml_ta
|
|||
return true;
|
||||
}
|
||||
|
||||
bool check_node_is_switch_by_node_name(int node_ref, char *node_name)
|
||||
static bool check_node_is_switch_by_node_name(int node_ref, const char *node_name)
|
||||
{
|
||||
unsigned int i;
|
||||
if (node_name == NULL)
|
||||
|
|
@ -909,12 +913,12 @@ int load_single_xml_node_data(int node_ref, mxml_node_t *node, struct xml_data_s
|
|||
mxml_node_t *firstchild = mxmlGetFirstChild(b);
|
||||
char *xsi_type = NULL;
|
||||
|
||||
char *node_name = get_xml_node_name_by_switch_name((char *)xml_node_name);
|
||||
const char *node_name = get_xml_node_name_by_switch_name(xml_node_name);
|
||||
if (!check_node_is_switch_by_node_name(node_ref, node_name))
|
||||
node_name = (char *)xml_node_name;
|
||||
node_name = xml_node_name;
|
||||
|
||||
if (node_type == MXML_ELEMENT) {
|
||||
soap_idx = get_xml_soap_tag_index(node_ref, (char *)node_name);
|
||||
soap_idx = get_xml_soap_tag_index(node_ref, node_name);
|
||||
if (soap_idx == -1) {
|
||||
b = mxmlWalkNext(b, node, MXML_DESCEND);
|
||||
continue;
|
||||
|
|
@ -935,11 +939,11 @@ int load_single_xml_node_data(int node_ref, mxml_node_t *node, struct xml_data_s
|
|||
continue;
|
||||
}
|
||||
|
||||
if (node_ref == SOAP_REQ_SPV_LIST_REF && CWMP_STRCMP((char *)node_name, "Value") == 0) {
|
||||
if (node_ref == SOAP_REQ_SPV_LIST_REF && CWMP_STRCMP(node_name, "Value") == 0) {
|
||||
xsi_type = (char *)mxmlElementGetAttr(b, "xsi:type");
|
||||
}
|
||||
|
||||
idx = get_xml_tag_index((char *)node_name);
|
||||
idx = get_xml_tag_index(node_name);
|
||||
|
||||
// cppcheck-suppress knownConditionTrueFalse
|
||||
/*
|
||||
|
|
@ -972,7 +976,7 @@ int load_single_xml_node_data(int node_ref, mxml_node_t *node, struct xml_data_s
|
|||
*str = strdup(opaque ? opaque : "");
|
||||
|
||||
// If SPV then need to forward datatype received in xml
|
||||
if (node_ref == SOAP_REQ_SPV_LIST_REF && CWMP_STRCMP((char *)node_name, "Value") == 0) {
|
||||
if (node_ref == SOAP_REQ_SPV_LIST_REF && CWMP_STRCMP(node_name, "Value") == 0) {
|
||||
int ids = get_xml_tag_index("xsi:type");
|
||||
void **p = (void **)((char *)xml_attrs + ids * sizeof(char *));
|
||||
str = (char **)(*p);
|
||||
|
|
@ -987,7 +991,7 @@ int load_single_xml_node_data(int node_ref, mxml_node_t *node, struct xml_data_s
|
|||
break;
|
||||
case XML_INTEGER:
|
||||
intgr = (int *)(*ptr);
|
||||
*intgr = opaque ? atoi(opaque) : 0;
|
||||
*intgr = opaque ? (int)strtol(opaque, NULL, 10) : 0;
|
||||
break;
|
||||
case XML_BOOL:
|
||||
bol = (bool *)(*ptr);
|
||||
|
|
@ -995,11 +999,11 @@ int load_single_xml_node_data(int node_ref, mxml_node_t *node, struct xml_data_s
|
|||
break;
|
||||
case XML_LINTEGER:
|
||||
lint = (long int *)(*ptr);
|
||||
*lint = opaque ? atol(opaque) : 0;
|
||||
*lint = opaque ? strtol(opaque, NULL, 10) : 0;
|
||||
break;
|
||||
case XML_TIME:
|
||||
time = (time_t *)(*ptr);
|
||||
*time = opaque ? atol(opaque) : 0;
|
||||
*time = opaque ? strtol(opaque, NULL, 10) : 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -1035,7 +1039,7 @@ void cwmp_param_fault_list_to_xml_data_list(struct list_head *param_fault_list,
|
|||
int idx = cwmp_get_fault_code(param_fault->fault_code);
|
||||
|
||||
xml_data->param_name = CWMP_STRDUP(param_fault->path_name);
|
||||
xml_data->fault_code = atoi(FAULT_CPE_ARRAY[idx].CODE);
|
||||
xml_data->fault_code = (int)strtol(FAULT_CPE_ARRAY[idx].CODE, NULL, 10);
|
||||
xml_data->fault_string = CWMP_STRLEN(param_fault->fault_msg) ? strdup(param_fault->fault_msg) : strdup(FAULT_CPE_ARRAY[idx].DESCRIPTION);
|
||||
}
|
||||
}
|
||||
|
|
@ -1103,7 +1107,7 @@ void cdu_operations_result_list_to_xml_data_list(struct list_head *du_op_res_lis
|
|||
xml_data->current_state = strdup(du_op_res_data->current_state ? du_op_res_data->current_state : "");
|
||||
xml_data->start_time = strdup(du_op_res_data->start_time ? du_op_res_data->start_time : "");
|
||||
xml_data->complete_time = strdup(du_op_res_data->complete_time ? du_op_res_data->complete_time : "");
|
||||
xml_data->fault_code = du_op_res_data->fault ? atoi(FAULT_CPE_ARRAY[du_op_res_data->fault].CODE) : 0;
|
||||
xml_data->fault_code = du_op_res_data->fault ? (int)strtol(FAULT_CPE_ARRAY[du_op_res_data->fault].CODE, NULL, 10) : 0;
|
||||
xml_data->fault_string = du_op_res_data->fault_msg ? strdup(du_op_res_data->fault_msg) : strdup("");
|
||||
}
|
||||
}
|
||||
|
|
@ -1135,6 +1139,9 @@ void event_container_list_to_xml_data_list(struct list_head *event_container_lis
|
|||
if ((!cwmp_main->session->session_status.is_heartbeat) && (event_container->code == EVENT_IDX_14HEARTBEAT))
|
||||
continue;
|
||||
struct xml_list_data *xml_data = calloc(1, sizeof(struct xml_list_data));
|
||||
if (xml_data == NULL)
|
||||
break;
|
||||
|
||||
list_add_tail(&xml_data->list, xml_data_list);
|
||||
xml_data->event_code = event_container->code;
|
||||
xml_data->command_key = strdup(event_container->command_key ? event_container->command_key : "");
|
||||
|
|
@ -1327,7 +1334,7 @@ int build_xml_node_data(int node_ref, mxml_node_t *node, struct xml_data_struct
|
|||
return CWMP_OK;
|
||||
}
|
||||
|
||||
mxml_node_t * build_top_body_soap_response(mxml_node_t *node, char *method)
|
||||
mxml_node_t * build_top_body_soap_response(mxml_node_t *node, const char *method)
|
||||
{
|
||||
mxml_node_t *n = mxmlFindElement(node, node, "soap_env:Body", NULL, NULL, MXML_DESCEND);
|
||||
|
||||
|
|
@ -1344,7 +1351,7 @@ mxml_node_t * build_top_body_soap_response(mxml_node_t *node, char *method)
|
|||
return n;
|
||||
}
|
||||
|
||||
mxml_node_t * build_top_body_soap_request(mxml_node_t *node, char *method)
|
||||
mxml_node_t * build_top_body_soap_request(mxml_node_t *node, const char *method)
|
||||
{
|
||||
mxml_node_t *n = mxmlFindElement(node, node, "soap_env:Body", NULL, NULL, MXML_DESCEND);
|
||||
|
||||
|
|
@ -1536,6 +1543,7 @@ int xml_send_message(struct rpc *rpc)
|
|||
CWMP_LOG(ERROR, "Failed to get ns parameters");
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* get NoMoreRequests or HolRequest*/
|
||||
cwmp_main->session->hold_request = false;
|
||||
|
||||
|
|
@ -1546,7 +1554,7 @@ int xml_send_message(struct rpc *rpc)
|
|||
b = mxmlWalkNext(b, cwmp_main->session->tree_in, MXML_DESCEND_FIRST);
|
||||
const char *bname = b ? mxmlGetOpaque(b) : NULL;
|
||||
if (b && mxmlGetType(b) == MXML_OPAQUE && bname)
|
||||
cwmp_main->session->hold_request = atoi(bname);
|
||||
cwmp_main->session->hold_request = (int)strtol(bname, NULL, 10);
|
||||
} else {
|
||||
if (snprintf(c, sizeof(c), "%s:%s", ns.cwmp, "HoldRequests") == -1)
|
||||
goto error;
|
||||
|
|
@ -1556,7 +1564,7 @@ int xml_send_message(struct rpc *rpc)
|
|||
if (b) {
|
||||
b = mxmlWalkNext(b, cwmp_main->session->tree_in, MXML_DESCEND_FIRST);
|
||||
if (b && mxmlGetType(b) == MXML_OPAQUE && bname)
|
||||
cwmp_main->session->hold_request = atoi(bname);
|
||||
cwmp_main->session->hold_request = (int)strtol(bname, NULL, 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1646,21 +1654,29 @@ int xml_set_cwmp_id_rpc_cpe()
|
|||
return 0;
|
||||
}
|
||||
|
||||
char *xml_get_cwmp_version(int version)
|
||||
void xml_get_cwmp_version(int version, char *versions, size_t len)
|
||||
{
|
||||
static char versions[60];
|
||||
unsigned pos = 0;
|
||||
int k;
|
||||
|
||||
versions[0] = '\0';
|
||||
if (versions == NULL || len < 60)
|
||||
return;
|
||||
|
||||
memset(versions, 0, len);
|
||||
|
||||
for (k = 0; k < version; k++) {
|
||||
pos += snprintf(&versions[pos], sizeof(versions) - pos, "1.%d, ", k);
|
||||
char tmp[16] = {0};
|
||||
snprintf(tmp, sizeof(tmp), "1.%d, ", k);
|
||||
|
||||
if ((len - pos) > strlen(tmp)) {
|
||||
pos += snprintf(&versions[pos], len - pos, "%s", tmp);
|
||||
}
|
||||
}
|
||||
|
||||
if (pos)
|
||||
versions[pos - 2] = 0;
|
||||
|
||||
return versions;
|
||||
return;
|
||||
}
|
||||
|
||||
static int xml_prepare_lwnotifications(mxml_node_t *parameter_list)
|
||||
|
|
@ -1745,7 +1761,7 @@ void load_notification_xml_schema(mxml_node_t **tree)
|
|||
return;
|
||||
}
|
||||
|
||||
if (cwmp_asprintf(&c, "%ld", time(NULL)) == -1) {
|
||||
if (asprintf(&c, "%ld", time(NULL)) == -1) {
|
||||
MXML_DELETE(xml);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -312,15 +312,15 @@ int xml_recreate_namespace(mxml_node_t *tree);
|
|||
int xml_set_cwmp_id();
|
||||
int xml_send_message(struct rpc *rpc);
|
||||
mxml_node_t *mxmlFindElementOpaque(mxml_node_t *node, mxml_node_t *top, const char *text, int descend);
|
||||
char *xml__get_attribute_name_by_value(mxml_node_t *node, const char *value);
|
||||
char *xml_get_cwmp_version(int version);
|
||||
char *xml__get_attribute_name_by_value(mxml_node_t *node, const char *value);
|
||||
void xml_get_cwmp_version(int version, char *versions, size_t len);
|
||||
void xml_exit(void);
|
||||
void load_response_xml_schema(mxml_node_t **schema);
|
||||
int load_xml_node_data(int node_ref, mxml_node_t *node, struct xml_data_struct *xml_attrs);
|
||||
int build_xml_node_data(int node_ref, mxml_node_t *node, struct xml_data_struct *xml_attrs);
|
||||
void add_xml_data_list(struct list_head *data_list, struct xml_list_data *xml_data);
|
||||
mxml_node_t * build_top_body_soap_response(mxml_node_t *node, char *method);
|
||||
mxml_node_t * build_top_body_soap_request(mxml_node_t *node, char *method);
|
||||
mxml_node_t * build_top_body_soap_response(mxml_node_t *node, const char *method);
|
||||
mxml_node_t * build_top_body_soap_request(mxml_node_t *node, const char *method);
|
||||
void dm_parameter_list_to_xml_data_list(struct list_head *dm_parameter_list, struct list_head *xml_data_list);
|
||||
void xml_data_list_to_dm_parameter_list(struct list_head *xml_data_list, struct list_head *dm_parameter_list);
|
||||
void xml_data_list_to_cdu_operations_list(struct list_head *xml_data_list, struct list_head *du_op_list);
|
||||
|
|
|
|||
|
|
@ -182,11 +182,16 @@ static void cwmp_backup_session_unit_test(void **state)
|
|||
/*
|
||||
* Insert TransferComplete bkp_session_insert_transfer_complete
|
||||
*/
|
||||
char start_time[26] = {0};
|
||||
char end_time[26] = {0};
|
||||
|
||||
struct transfer_complete *p;
|
||||
p = icwmp_calloc(1, sizeof(struct transfer_complete));
|
||||
p->command_key = icwmp_strdup("transfer_complete_key");
|
||||
p->start_time = icwmp_strdup(get_time(time(NULL)));
|
||||
p->complete_time = icwmp_strdup(get_time(time(NULL)));
|
||||
get_time(time(NULL), start_time, sizeof(start_time));
|
||||
p->start_time = icwmp_strdup(start_time);
|
||||
get_time(time(NULL), end_time, sizeof(end_time));
|
||||
p->complete_time = icwmp_strdup(end_time);
|
||||
p->old_software_version = icwmp_strdup("iopsys_img_old");
|
||||
p->type = TYPE_DOWNLOAD;
|
||||
p->fault_code = FAULT_CPE_NO_FAULT;
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ static void cwmp_download_file_unit_test(void **state)
|
|||
*/
|
||||
int http_code = download_file(ICWMP_DOWNLOAD_FILE, "http://127.0.0.1/firmware_v1.0.bin", NULL, NULL, NULL);
|
||||
assert_int_equal(http_code, 200);
|
||||
assert_int_equal(access( ICWMP_DOWNLOAD_FILE, F_OK ), 0);
|
||||
assert_true(file_exists(ICWMP_DOWNLOAD_FILE));
|
||||
remove(ICWMP_DOWNLOAD_FILE);
|
||||
|
||||
/*
|
||||
|
|
@ -79,7 +79,7 @@ static void cwmp_download_file_unit_test(void **state)
|
|||
*/
|
||||
http_code = download_file(ICWMP_DOWNLOAD_FILE, "http://127.0.0.1/firmware.bin", NULL, NULL, NULL);
|
||||
assert_int_equal(http_code, 404);
|
||||
assert_int_equal(access( ICWMP_DOWNLOAD_FILE, F_OK ), 0);
|
||||
assert_true(file_exists(ICWMP_DOWNLOAD_FILE));
|
||||
remove(ICWMP_DOWNLOAD_FILE);
|
||||
}
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ static void cwmp_launch_download_unit_test(void **state)
|
|||
transfer_complete_test = ptransfer_complete;
|
||||
|
||||
assert_int_equal(error, FAULT_CPE_NO_FAULT);
|
||||
assert_int_equal(access( FIRMWARE_UPGRADE_IMAGE, F_OK ), 0);
|
||||
assert_true(file_exists(FIRMWARE_UPGRADE_IMAGE));
|
||||
assert_int_equal(ptransfer_complete->fault_code, FAULT_CPE_NO_FAULT);
|
||||
assert_string_equal(ptransfer_complete->command_key, "download_key");
|
||||
assert_non_null(ptransfer_complete->start_time);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue