This commit is contained in:
Suvendhu Hansa 2023-12-26 11:34:32 +00:00 committed by Vivek Kumar Dutta
parent cf89728b92
commit ffa47ddf73
3 changed files with 10 additions and 41 deletions

View file

@ -181,7 +181,6 @@ typedef struct cwmp {
struct connection net; struct connection net;
struct session *session; struct session *session;
bool cwmp_cr_event; bool cwmp_cr_event;
bool init_complete;
bool prev_periodic_enable; bool prev_periodic_enable;
bool prev_heartbeat_enable; bool prev_heartbeat_enable;
bool heart_session; bool heart_session;

View file

@ -85,49 +85,32 @@ int get_preinit_config()
static int global_conf_init() static int global_conf_init()
{ {
int error = CWMP_OK; get_global_config();
if ((error = get_global_config())) {
cwmp_main->init_complete = false;
goto end;
}
cwmp_main->init_complete = true;
/* Launch reboot methods if needed */ /* Launch reboot methods if needed */
launch_reboot_methods(); launch_reboot_methods();
end: return 0;
return error;
} }
void cwmp_config_load() void cwmp_config_load()
{ {
int ret = CWMP_GEN_ERR;
int error = CWMP_GEN_ERR; int error = CWMP_GEN_ERR;
ret = global_conf_init(); global_conf_init();
if (cwmp_stop == true) if (cwmp_stop == true)
return; return;
if (ret == CWMP_OK) { cwmp_main->net.ipv6_status = is_ipv6_enabled();
cwmp_main->net.ipv6_status = is_ipv6_enabled(); error = icwmp_check_http_connection();
error = icwmp_check_http_connection();
}
while (error != CWMP_OK && cwmp_stop != true) { while (error != CWMP_OK && cwmp_stop != true) {
if (ret != CWMP_OK) { CWMP_LOG(DEBUG, "Init: failed to check http connection");
CWMP_LOG(DEBUG, "Error reading uci ret = %d", ret);
} else {
CWMP_LOG(DEBUG, "Init: failed to check http connection");
}
sleep(UCI_OPTION_READ_INTERVAL); sleep(UCI_OPTION_READ_INTERVAL);
ret = global_conf_init(); global_conf_init();
if (ret == CWMP_OK) { cwmp_main->net.ipv6_status = is_ipv6_enabled();
cwmp_main->net.ipv6_status = is_ipv6_enabled(); error = icwmp_check_http_connection();
error = icwmp_check_http_connection();
}
} }
} }

View file

@ -139,11 +139,6 @@ static const struct blobmsg_policy icwmp_cmd_policy[] = {
static int icwmp_command_handler(struct ubus_context *ctx, struct ubus_object *obj __attribute__((unused)), struct ubus_request_data *req, const char *method __attribute__((unused)), struct blob_attr *msg) static int icwmp_command_handler(struct ubus_context *ctx, struct ubus_object *obj __attribute__((unused)), struct ubus_request_data *req, const char *method __attribute__((unused)), struct blob_attr *msg)
{ {
if (cwmp_main->init_complete == false) {
CWMP_LOG(INFO, "Request can't be handled since icwmpd is still in init state");
return 0;
}
if (ctx == NULL) if (ctx == NULL)
return -1; return -1;
struct blob_attr *tb[__COMMAND_MAX] = {0}; struct blob_attr *tb[__COMMAND_MAX] = {0};
@ -219,7 +214,7 @@ static void bb_add_icwmp_status(struct blob_buf *bb)
return; return;
} }
void *tbl = blobmsg_open_table(bb, "cwmp"); void *tbl = blobmsg_open_table(bb, "cwmp");
bb_add_string(bb, "status", cwmp_main->init_complete ? "up" : "init"); bb_add_string(bb, "status", "up");
bb_add_string(bb, "start_time", get_time(cwmp_main->start_time)); bb_add_string(bb, "start_time", get_time(cwmp_main->start_time));
bb_add_string(bb, "acs_url", cwmp_main->conf.acs_url); bb_add_string(bb, "acs_url", cwmp_main->conf.acs_url);
blobmsg_close_table(bb, tbl); blobmsg_close_table(bb, tbl);
@ -320,14 +315,6 @@ static int icwmp_inform_handler(struct ubus_context *ctx, struct ubus_object *ob
CWMP_MEMSET(&bb, 0, sizeof(struct blob_buf)); CWMP_MEMSET(&bb, 0, sizeof(struct blob_buf));
blob_buf_init(&bb, 0); blob_buf_init(&bb, 0);
if (cwmp_main->init_complete == false) {
CWMP_LOG(WARNING, "Inform can't be sent since icwmpd is still in init state");
blobmsg_add_u32(&bb, "status", -1);
blobmsg_add_string(&bb, "info", "icwmpd is still in init state");
goto end;
}
struct blob_attr *tb[__INFORM_MAX] = {0}; struct blob_attr *tb[__INFORM_MAX] = {0};
bool is_get_rpc = false; bool is_get_rpc = false;
char *event = ""; char *event = "";