mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
Remove ubus call tr069 notify
This commit is contained in:
parent
31e806bc82
commit
ad798f2b9d
5 changed files with 7 additions and 143 deletions
1
config.c
1
config.c
|
|
@ -1245,7 +1245,6 @@ int cwmp_init(int argc, char** argv,struct cwmp *cwmp)
|
|||
pthread_mutex_init(&cwmp->mutex_periodic, NULL);
|
||||
pthread_mutex_init(&cwmp->mutex_session_queue, NULL);
|
||||
pthread_mutex_init(&cwmp->mutex_session_send, NULL);
|
||||
pthread_mutex_init(&cwmp->mutex_handle_notify, NULL);
|
||||
memcpy(&(cwmp->env),&env,sizeof(struct env));
|
||||
INIT_LIST_HEAD(&(cwmp->head_session_queue));
|
||||
|
||||
|
|
|
|||
16
cwmp.c
16
cwmp.c
|
|
@ -25,6 +25,8 @@
|
|||
#include "ubus.h"
|
||||
#include "diagnostic.h"
|
||||
#include "config.h"
|
||||
#include "jshn.h"
|
||||
#include <libubus.h>
|
||||
|
||||
struct cwmp cwmp_main = {0};
|
||||
char *commandKey = NULL;
|
||||
|
|
@ -37,6 +39,7 @@ void cwmp_set_end_session(unsigned int flag)
|
|||
end_session_flag |= flag;
|
||||
}
|
||||
#endif
|
||||
|
||||
int cwmp_dm_ctx_init(struct cwmp *cwmp, struct dmctx *ctx)
|
||||
{
|
||||
if(cwmp->conf.supported_amd_version == 0)
|
||||
|
|
@ -189,8 +192,8 @@ void cwmp_schedule_session (struct cwmp *cwmp)
|
|||
if(!event_exist_in_list(cwmp, EVENT_IDX_4VALUE_CHANGE))
|
||||
is_notify = check_value_change();
|
||||
}
|
||||
|
||||
dmbbf_update_enabled_notify_file(DM_CWMP, cwmp->conf.amd_version, cwmp->conf.instance_mode);
|
||||
if(is_notify>0 || access(DM_ENABLED_NOTIFY, F_OK ) < 0)
|
||||
dmbbf_update_enabled_notify_file(DM_CWMP, cwmp->conf.amd_version, cwmp->conf.instance_mode);
|
||||
cwmp_prepare_value_change(cwmp);
|
||||
free_dm_parameter_all_fromlist(&list_value_change);
|
||||
if ((error = cwmp_move_session_to_session_send (cwmp, session))) {
|
||||
|
|
@ -688,7 +691,6 @@ int main(int argc, char **argv)
|
|||
struct cwmp *cwmp = &cwmp_main;
|
||||
int error;
|
||||
pthread_t periodic_event_thread;
|
||||
pthread_t handle_notify_thread;
|
||||
pthread_t scheduleInform_thread;
|
||||
pthread_t change_du_state_thread;
|
||||
pthread_t download_thread;
|
||||
|
|
@ -698,8 +700,8 @@ int main(int argc, char **argv)
|
|||
pthread_t ubus_thread;
|
||||
pthread_t http_cr_server_thread;
|
||||
pthread_t periodic_check_notify;
|
||||
|
||||
struct sigaction act = {0};
|
||||
|
||||
#ifndef TR098
|
||||
set_bbfdatamodel_type(BBFDM_CWMP); // To show only CWMP parameters
|
||||
#endif
|
||||
|
|
@ -721,7 +723,6 @@ int main(int argc, char **argv)
|
|||
act.sa_handler = signal_handler;
|
||||
sigaction(SIGINT, &act, 0);
|
||||
sigaction(SIGTERM, &act, 0);
|
||||
|
||||
error = pthread_create(&http_cr_server_thread, NULL, &thread_http_cr_server_listen, NULL);
|
||||
if (error < 0)
|
||||
CWMP_LOG(ERROR,"Error when creating the http connection request server thread!");
|
||||
|
|
@ -734,10 +735,6 @@ int main(int argc, char **argv)
|
|||
if (error < 0)
|
||||
CWMP_LOG(ERROR,"Error when creating the periodic event thread!");
|
||||
|
||||
error = pthread_create(&handle_notify_thread, NULL, &thread_handle_notify, (void *)cwmp);
|
||||
if (error < 0)
|
||||
CWMP_LOG(ERROR,"Error when creating the handle notify thread!");
|
||||
|
||||
error = pthread_create(&periodic_check_notify, NULL, &thread_periodic_check_notify, (void *)cwmp);
|
||||
if (error < 0)
|
||||
CWMP_LOG(ERROR,"Error when creating the download thread!");
|
||||
|
|
@ -769,7 +766,6 @@ int main(int argc, char **argv)
|
|||
|
||||
pthread_join(ubus_thread, NULL);
|
||||
pthread_join(periodic_event_thread, NULL);
|
||||
pthread_join(handle_notify_thread, NULL);
|
||||
pthread_join(scheduleInform_thread, NULL);
|
||||
pthread_join(download_thread, NULL);
|
||||
pthread_join(upload_thread, NULL);
|
||||
|
|
|
|||
105
event.c
105
event.c
|
|
@ -289,7 +289,7 @@ int check_value_change(void)
|
|||
if (fp == NULL)
|
||||
return false;
|
||||
|
||||
dm_ctx_init(&dmctx, DM_CWMP, cwmp->conf.amd_version, cwmp->conf.instance_mode);
|
||||
dm_ctx_init(&dmctx, DM_CWMP, cwmp->conf.amd_version, cwmp->conf.instance_mode);
|
||||
while (fgets(buf, 512, fp) != NULL) {
|
||||
if (!first_iteration)
|
||||
dm_ctx_init_list_parameter(&dmctx);
|
||||
|
|
@ -330,93 +330,6 @@ int check_value_change(void)
|
|||
return is_notify;
|
||||
}
|
||||
|
||||
void cwmp_add_notification(void)
|
||||
{
|
||||
int fault, iscopy;
|
||||
int i = 0;
|
||||
FILE *fp;
|
||||
char buf[512];
|
||||
char *parameter, *notification = NULL, *value = NULL, *jval;
|
||||
struct cwmp *cwmp = &cwmp_main;
|
||||
struct dm_enabled_notify *p;
|
||||
struct dm_parameter *dm_parameter;
|
||||
struct dmctx dmctx = {0};
|
||||
struct config *conf = &(cwmp->conf);
|
||||
bool isactive = false;
|
||||
bool initiate = false;
|
||||
bool lw_isactive = false;
|
||||
|
||||
pthread_mutex_lock(&(cwmp->mutex_session_send));
|
||||
pthread_mutex_lock(&(cwmp->mutex_handle_notify));
|
||||
cwmp->count_handle_notify = 0;
|
||||
pthread_mutex_unlock(&(cwmp->mutex_handle_notify));
|
||||
cwmp_dm_ctx_init(&cwmp_main, &dmctx);
|
||||
|
||||
fp = fopen(DM_ENABLED_NOTIFY, "r");
|
||||
if (fp == NULL)
|
||||
return;
|
||||
|
||||
while (fgets(buf, 512, fp) != NULL) {
|
||||
dm_ctx_init_sub(&dmctx, DM_CWMP, cwmp_main.conf.amd_version, cwmp_main.conf.instance_mode);
|
||||
initiate = true;
|
||||
int len = strlen(buf);
|
||||
if (len)
|
||||
buf[len-1] = '\0';
|
||||
dmjson_parse_init(buf);
|
||||
dmjson_get_string("parameter", &jval);
|
||||
parameter = strdup(jval);
|
||||
dmjson_get_string("value", &jval);
|
||||
value = strdup(jval);
|
||||
dmjson_get_string("notification", &jval);
|
||||
notification = strdup(jval);
|
||||
dmjson_parse_fini();
|
||||
|
||||
fault = dm_entry_param_method(&dmctx, CMD_GET_VALUE, parameter, NULL, NULL);
|
||||
if (!fault && dmctx.list_parameter.next != &dmctx.list_parameter) {
|
||||
dm_parameter = list_entry(dmctx.list_parameter.next, struct dm_parameter, list);
|
||||
if (strcmp(dm_parameter->data, value) != 0) {
|
||||
dm_update_file_enabled_notify(parameter, dm_parameter->data);
|
||||
iscopy = copy_temporary_file_to_original_file(DM_ENABLED_NOTIFY, DM_ENABLED_NOTIFY_TEMPORARY);
|
||||
if(iscopy)
|
||||
remove(DM_ENABLED_NOTIFY_TEMPORARY);
|
||||
if (notification[0] == '1' || notification[0] == '2' || notification[0] == '4' || notification[0] == '6' )
|
||||
add_list_value_change(parameter, dm_parameter->data, dm_parameter->type);
|
||||
if (notification[0] == '2')
|
||||
isactive = true;
|
||||
}
|
||||
}
|
||||
FREE(value);
|
||||
FREE(notification);
|
||||
FREE(parameter);
|
||||
}
|
||||
fclose(fp);
|
||||
cwmp_dm_ctx_clean(&dmctx);
|
||||
/*list_for_each_entry(p, &list_enabled_lw_notify, list) {
|
||||
if (!initiate || i != 0)
|
||||
dm_ctx_init_sub(&dmctx, DM_CWMP, cwmp_main.conf.amd_version, cwmp_main.conf.instance_mode);
|
||||
i++;
|
||||
if (!conf->lw_notification_enable)
|
||||
break;
|
||||
fault = dm_entry_param_method(&dmctx, CMD_GET_VALUE, p->name, NULL, NULL);
|
||||
if (!fault && dmctx.list_parameter.next != &dmctx.list_parameter) {
|
||||
dm_parameter = list_entry(dmctx.list_parameter.next, struct dm_parameter, list);
|
||||
if (strcmp(dm_parameter->data, p->value) != 0) {
|
||||
dm_update_enabled_notify(p, dm_parameter->data);
|
||||
if (p->notification[0] >= '3' ) add_lw_list_value_change(p->name, dm_parameter->data, dm_parameter->type);
|
||||
if (p->notification[0] == '5' || p->notification[0] == '6') lw_isactive = true;
|
||||
}
|
||||
}
|
||||
dm_ctx_clean_sub(&dmctx);
|
||||
}
|
||||
cwmp_dm_ctx_clean(&dmctx);
|
||||
if (lw_isactive) {
|
||||
cwmp_lwnotification();
|
||||
}*/
|
||||
pthread_mutex_unlock(&(cwmp->mutex_session_send));
|
||||
if (isactive)
|
||||
send_active_value_change();
|
||||
}
|
||||
|
||||
void cwmp_root_cause_event_ipdiagnostic(void)
|
||||
{
|
||||
struct cwmp *cwmp = &cwmp_main;
|
||||
|
|
@ -659,22 +572,6 @@ int cwmp_root_cause_getRPCMethod (struct cwmp *cwmp)
|
|||
return CWMP_OK;
|
||||
}
|
||||
|
||||
void *thread_handle_notify(void *v)
|
||||
{
|
||||
struct cwmp *cwmp = (struct cwmp *) v;
|
||||
|
||||
for(;;) {
|
||||
pthread_mutex_lock(&(cwmp->mutex_handle_notify));
|
||||
pthread_cond_wait(&(cwmp->threshold_handle_notify), &(cwmp->mutex_handle_notify));
|
||||
pthread_mutex_unlock(&(cwmp->mutex_handle_notify));
|
||||
while(cwmp->count_handle_notify) {
|
||||
cwmp_add_notification();
|
||||
}
|
||||
|
||||
}
|
||||
return CWMP_OK;
|
||||
}
|
||||
|
||||
void *thread_event_periodic (void *v)
|
||||
{
|
||||
struct cwmp *cwmp = (struct cwmp *) v;
|
||||
|
|
|
|||
|
|
@ -265,7 +265,6 @@ typedef struct cwmp {
|
|||
pthread_mutex_t mutex_notify_periodic;
|
||||
pthread_cond_t threshold_periodic;
|
||||
pthread_cond_t threshold_notify_periodic;
|
||||
pthread_mutex_t mutex_handle_notify;
|
||||
pthread_cond_t threshold_handle_notify;
|
||||
int count_handle_notify;
|
||||
int retry_count_session;
|
||||
|
|
@ -329,7 +328,6 @@ void *thread_exit_program (void *v);
|
|||
void connection_request_ip_value_change(struct cwmp *cwmp, int version);
|
||||
void connection_request_port_value_change(struct cwmp *cwmp, int port);
|
||||
void add_dm_parameter_tolist(struct list_head *head, char *param_name, char *param_data, char *param_type);
|
||||
void *thread_handle_notify(void *v);
|
||||
int zlib_compress (char *message, unsigned char **zmsg, int *zlen, int type);
|
||||
int cwmp_get_int_event_code(char *code);
|
||||
int cwmp_dm_ctx_init(struct cwmp *cwmp, struct dmctx *ctx);
|
||||
|
|
|
|||
26
ubus.c
26
ubus.c
|
|
@ -39,31 +39,6 @@ static const char *arr_session_status[] = {
|
|||
[SESSION_SUCCESS] = "success",
|
||||
};
|
||||
|
||||
static int
|
||||
cwmp_handle_notify(struct ubus_context *ctx, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method,
|
||||
struct blob_attr *msg)
|
||||
{
|
||||
bool send_signal = false;
|
||||
CWMP_LOG(INFO, "triggered ubus notification");
|
||||
|
||||
blob_buf_init(&b, 0);
|
||||
|
||||
pthread_mutex_lock(&(cwmp_main.mutex_handle_notify));
|
||||
if (!cwmp_main.count_handle_notify)
|
||||
send_signal = true;
|
||||
cwmp_main.count_handle_notify++;
|
||||
pthread_mutex_unlock(&(cwmp_main.mutex_handle_notify));
|
||||
if (send_signal)
|
||||
pthread_cond_signal(&(cwmp_main.threshold_handle_notify));
|
||||
|
||||
blobmsg_add_u32(&b, "status", 1);
|
||||
ubus_send_reply(ctx, req, b.head);
|
||||
blob_buf_free(&b);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
enum command {
|
||||
COMMAND_NAME,
|
||||
|
|
@ -305,7 +280,6 @@ cwmp_handle_inform(struct ubus_context *ctx, struct ubus_object *obj,
|
|||
}
|
||||
|
||||
static const struct ubus_method freecwmp_methods[] = {
|
||||
UBUS_METHOD_NOARG("notify", cwmp_handle_notify),
|
||||
UBUS_METHOD("command", cwmp_handle_command, command_policy),
|
||||
UBUS_METHOD_NOARG("status", cwmp_handle_status),
|
||||
UBUS_METHOD("inform", cwmp_handle_inform, inform_policy),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue