Commit e1c4e78b authored by Florian Kaltenberger's avatar Florian Kaltenberger
Browse files

Merge branch 'develop' of https://gitlab.eurecom.fr/oai/openairinterface5g into develop

parents 31541601 86039424
...@@ -24,6 +24,26 @@ typedef struct { ...@@ -24,6 +24,26 @@ typedef struct {
view *pdcpview; view *pdcpview;
view *rrcview; view *rrcview;
view *legacy; view *legacy;
widget *current_ue_label;
widget *prev_ue_button;
widget *next_ue_button;
widget *pusch_iq_ue_xy_plot;
widget *ul_estimate_ue_xy_plot;
widget *pucch1_energy_ue_xy_plot;
widget *pucch_iq_ue_xy_plot;
widget *dl_ul_harq_ue_label;
logger *pusch_iq_ue_logger;
logger *ul_estimate_ue_logger;
logger *pucch1_energy_ue_threshold_logger;
logger *pucch1_energy_ue_energy_logger;
logger *pucch_iq_ue_logger;
logger *dl_dci_logger[8];
logger *dl_ack_logger[8];
logger *dl_nack_logger[8];
logger *ul_dci_logger[8];
logger *ul_dci_retransmission_logger[8];
logger *ul_ack_logger[8];
logger *ul_nack_logger[8];
} enb_gui; } enb_gui;
typedef struct { typedef struct {
...@@ -31,6 +51,9 @@ typedef struct { ...@@ -31,6 +51,9 @@ typedef struct {
int *is_on; int *is_on;
int nevents; int nevents;
pthread_mutex_t lock; pthread_mutex_t lock;
enb_gui *e;
int ue; /* what UE is displayed in the UE specific views */
void *database;
} enb_data; } enb_data;
void is_on_changed(void *_d) void is_on_changed(void *_d)
...@@ -86,18 +109,97 @@ static void *gui_thread(void *_g) ...@@ -86,18 +109,97 @@ static void *gui_thread(void *_g)
return NULL; return NULL;
} }
static filter *ticktime_filter(void *database, char *event, int i) static filter *ticktime_filter(void *database, char *event, int i, int ue)
{ {
/* filter is "harq_pid == i && UE_id == 0 && eNB_id == 0" */ /* filter is "harq_pid == i && UE_id == 0 && eNB_id == 0" */
return return
filter_and( filter_and(
filter_eq(filter_evarg(database, event, "harq_pid"), filter_int(i)), filter_eq(filter_evarg(database, event, "harq_pid"), filter_int(i)),
filter_and( filter_and(
filter_eq(filter_evarg(database, event, "UE_id"), filter_int(0)), filter_eq(filter_evarg(database, event, "UE_id"), filter_int(ue)),
filter_eq(filter_evarg(database, event, "eNB_ID"), filter_int(0)))); filter_eq(filter_evarg(database, event, "eNB_ID"), filter_int(0))));
} }
static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database) static void set_current_ue(gui *g, enb_data *e, int ue)
{
int i;
char s[256];
sprintf(s, "[UE %d] ", ue);
label_set_text(g, e->e->current_ue_label, s);
sprintf(s, "PUSCH IQ [UE %d]", ue);
xy_plot_set_title(g, e->e->pusch_iq_ue_xy_plot, s);
sprintf(s, "UL estimated channel [UE %d]", ue);
xy_plot_set_title(g, e->e->ul_estimate_ue_xy_plot, s);
sprintf(s, "PUCCH1 energy (SR) [UE %d]", ue);
xy_plot_set_title(g, e->e->pucch1_energy_ue_xy_plot, s);
sprintf(s, "PUCCH IQ [UE %d]", ue);
xy_plot_set_title(g, e->e->pucch_iq_ue_xy_plot, s);
sprintf(s, "DL/UL HARQ (x8) [UE %d]", ue);
label_set_text(g, e->e->dl_ul_harq_ue_label, s);
logger_set_filter(e->e->pusch_iq_ue_logger,
filter_eq(
filter_evarg(e->database, "ENB_PHY_PUSCH_IQ", "UE_ID"),
filter_int(ue)));
logger_set_filter(e->e->ul_estimate_ue_logger,
filter_eq(
filter_evarg(e->database, "ENB_PHY_UL_CHANNEL_ESTIMATE", "UE_ID"),
filter_int(ue)));
logger_set_filter(e->e->pucch1_energy_ue_threshold_logger,
filter_eq(
filter_evarg(e->database, "ENB_PHY_PUCCH_1_ENERGY", "UE_ID"),
filter_int(ue)));
logger_set_filter(e->e->pucch1_energy_ue_energy_logger,
filter_eq(
filter_evarg(e->database, "ENB_PHY_PUCCH_1_ENERGY", "UE_ID"),
filter_int(ue)));
logger_set_filter(e->e->pucch_iq_ue_logger,
filter_eq(
filter_evarg(e->database, "ENB_PHY_PUCCH_1AB_IQ", "UE_ID"),
filter_int(ue)));
for (i = 0; i < 8; i++) {
logger_set_filter(e->e->dl_dci_logger[i],
ticktime_filter(e->database, "ENB_PHY_DLSCH_UE_DCI", i, ue));
logger_set_filter(e->e->dl_ack_logger[i],
ticktime_filter(e->database, "ENB_PHY_DLSCH_UE_ACK", i, ue));
logger_set_filter(e->e->dl_nack_logger[i],
ticktime_filter(e->database, "ENB_PHY_DLSCH_UE_NACK", i, ue));
logger_set_filter(e->e->ul_dci_logger[i],
ticktime_filter(e->database, "ENB_PHY_ULSCH_UE_DCI", i, ue));
logger_set_filter(e->e->ul_dci_retransmission_logger[i],
ticktime_filter(e->database,
"ENB_PHY_ULSCH_UE_NO_DCI_RETRANSMISSION", i, ue));
logger_set_filter(e->e->ul_ack_logger[i],
ticktime_filter(e->database, "ENB_PHY_ULSCH_UE_ACK", i, ue));
logger_set_filter(e->e->ul_nack_logger[i],
ticktime_filter(e->database, "ENB_PHY_ULSCH_UE_NACK", i, ue));
}
}
static void click(void *private, gui *g,
char *notification, widget *w, void *notification_data)
{
int *d = notification_data;
int button = d[0];
enb_data *ed = private;
enb_gui *e = ed->e;
int ue = ed->ue;
if (button != 1) return;
if (w == e->prev_ue_button) { ue--; if (ue < 0) ue = 0; }
if (w == e->next_ue_button) ue++;
if (pthread_mutex_lock(&ed->lock)) abort();
if (ue != ed->ue) {
set_current_ue(g, ed, ue);
ed->ue = ue;
}
if (pthread_mutex_unlock(&ed->lock)) abort();
}
static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database,
enb_data *ed)
{ {
widget *main_window; widget *main_window;
widget *top_container; widget *top_container;
...@@ -113,7 +215,7 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database) ...@@ -113,7 +215,7 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database)
widget *text; widget *text;
view *textview; view *textview;
int i; int i;
widget *w; widget *w, *w2;
view *v; view *v;
logger *l; logger *l;
...@@ -124,7 +226,26 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database) ...@@ -124,7 +226,26 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database)
line = new_container(g, HORIZONTAL); line = new_container(g, HORIZONTAL);
widget_add_child(g, top_container, line, -1); widget_add_child(g, top_container, line, -1);
logo = new_image(g, openair_logo_png, openair_logo_png_len); logo = new_image(g, openair_logo_png, openair_logo_png_len);
widget_add_child(g, line, logo, -1);
/* logo + prev/next UE buttons */
col = new_container(g, VERTICAL);
widget_add_child(g, col, logo, -1);
w = new_container(g, HORIZONTAL);
widget_add_child(g, col, w, -1);
w2 = new_label(g, "");
widget_add_child(g, w, w2, -1);
e->current_ue_label = w2;
/* TODO: use button widget, not label widget */
w2 = new_label(g, " [prev UE] ");
widget_add_child(g, w, w2, -1);
label_set_clickable(g, w2, 1);
e->prev_ue_button = w2;
w2 = new_label(g, " [next UE] ");
widget_add_child(g, w, w2, -1);
label_set_clickable(g, w2, 1);
e->next_ue_button = w2;
widget_add_child(g, line, col, -1);
input_signal_plot = new_xy_plot(g, 256, 55, "input signal", 20); input_signal_plot = new_xy_plot(g, 256, 55, "input signal", 20);
widget_add_child(g, line, input_signal_plot, -1); widget_add_child(g, line, input_signal_plot, -1);
xy_plot_set_range(g, input_signal_plot, 0, 7680*10, 20, 70); xy_plot_set_range(g, input_signal_plot, 0, 7680*10, 20, 70);
...@@ -138,21 +259,20 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database) ...@@ -138,21 +259,20 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database)
g, input_signal_plot, new_color(g, "#0c0c72"), XY_LOOP_MODE); g, input_signal_plot, new_color(g, "#0c0c72"), XY_LOOP_MODE);
logger_add_view(input_signal_log, input_signal_view); logger_add_view(input_signal_log, input_signal_view);
/* UE 0 PUSCH IQ data */ /* UE x PUSCH IQ data */
w = new_xy_plot(g, 55, 55, "PUSCH IQ [UE 0]", 50); w = new_xy_plot(g, 55, 55, "", 50);
e->pusch_iq_ue_xy_plot = w;
widget_add_child(g, line, w, -1); widget_add_child(g, line, w, -1);
xy_plot_set_range(g, w, -1000, 1000, -1000, 1000); xy_plot_set_range(g, w, -1000, 1000, -1000, 1000);
l = new_iqlog(h, database, "ENB_PHY_PUSCH_IQ", "nb_rb", l = new_iqlog(h, database, "ENB_PHY_PUSCH_IQ", "nb_rb",
"N_RB_UL", "symbols_per_tti", "pusch_comp"); "N_RB_UL", "symbols_per_tti", "pusch_comp");
v = new_view_xy(100*12*14,10,g,w,new_color(g,"#000"),XY_FORCED_MODE); v = new_view_xy(100*12*14,10,g,w,new_color(g,"#000"),XY_FORCED_MODE);
logger_add_view(l, v); logger_add_view(l, v);
logger_set_filter(l, e->pusch_iq_ue_logger = l;
filter_eq(
filter_evarg(database, "ENB_PHY_PUSCH_IQ", "UE_ID"),
filter_int(0)));
/* UE 0 estimated UL channel */ /* UE x estimated UL channel */
w = new_xy_plot(g, 280, 55, "UL estimated channel [UE 0]", 50); w = new_xy_plot(g, 280, 55, "", 50);
e->ul_estimate_ue_xy_plot = w;
widget_add_child(g, line, w, -1); widget_add_child(g, line, w, -1);
xy_plot_set_range(g, w, 0, 512*10, -10, 80); xy_plot_set_range(g, w, 0, 512*10, -10, 80);
l = new_framelog(h, database, l = new_framelog(h, database,
...@@ -161,43 +281,33 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database) ...@@ -161,43 +281,33 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database)
framelog_set_update_only_at_sf9(l, 0); framelog_set_update_only_at_sf9(l, 0);
v = new_view_xy(512*10, 10, g, w, new_color(g, "#0c0c72"), XY_LOOP_MODE); v = new_view_xy(512*10, 10, g, w, new_color(g, "#0c0c72"), XY_LOOP_MODE);
logger_add_view(l, v); logger_add_view(l, v);
logger_set_filter(l, e->ul_estimate_ue_logger = l;
filter_eq(
filter_evarg(database, "ENB_PHY_UL_CHANNEL_ESTIMATE", "UE_ID"),
filter_int(0)));
/* UE 0 PUCCH energy */ /* UE x PUCCH energy */
w = new_xy_plot(g, 128, 55, "PUCCH1 energy (SR) [UE 0]", 50); w = new_xy_plot(g, 128, 55, "", 50);
e->pucch1_energy_ue_xy_plot = w;
widget_add_child(g, line, w, -1); widget_add_child(g, line, w, -1);
xy_plot_set_range(g, w, 0, 1024*10, -10, 80); xy_plot_set_range(g, w, 0, 1024*10, -10, 80);
l = new_ttilog(h, database, l = new_ttilog(h, database,
"ENB_PHY_PUCCH_1_ENERGY", "frame", "subframe", "threshold", 0); "ENB_PHY_PUCCH_1_ENERGY", "frame", "subframe", "threshold", 0);
v = new_view_tti(10, g, w, new_color(g, "#ff0000")); v = new_view_tti(10, g, w, new_color(g, "#ff0000"));
logger_add_view(l, v); logger_add_view(l, v);
logger_set_filter(l, e->pucch1_energy_ue_threshold_logger = l;
filter_eq(
filter_evarg(database, "ENB_PHY_PUCCH_1_ENERGY", "UE_ID"),
filter_int(0)));
l = new_ttilog(h, database, l = new_ttilog(h, database,
"ENB_PHY_PUCCH_1_ENERGY", "frame", "subframe", "energy", 1); "ENB_PHY_PUCCH_1_ENERGY", "frame", "subframe", "energy", 1);
v = new_view_tti(10, g, w, new_color(g, "#0c0c72")); v = new_view_tti(10, g, w, new_color(g, "#0c0c72"));
logger_add_view(l, v); logger_add_view(l, v);
logger_set_filter(l, e->pucch1_energy_ue_energy_logger = l;
filter_eq(
filter_evarg(database, "ENB_PHY_PUCCH_1_ENERGY", "UE_ID"),
filter_int(0)));
/* UE 0 PUCCH IQ data */ /* UE x PUCCH IQ data */
w = new_xy_plot(g, 55, 55, "PUCCH IQ [UE 0]", 50); w = new_xy_plot(g, 55, 55, "", 50);
e->pucch_iq_ue_xy_plot = w;
widget_add_child(g, line, w, -1); widget_add_child(g, line, w, -1);
xy_plot_set_range(g, w, -100, 100, -100, 100); xy_plot_set_range(g, w, -2000, 2000, -2000, 2000);
l = new_iqdotlog(h, database, "ENB_PHY_PUCCH_1AB_IQ", "I", "Q"); l = new_iqdotlog(h, database, "ENB_PHY_PUCCH_1AB_IQ", "I", "Q");
v = new_view_xy(500, 10, g, w, new_color(g,"#000"), XY_LOOP_MODE); v = new_view_xy(500, 10, g, w, new_color(g,"#000"), XY_LOOP_MODE);
logger_add_view(l, v); logger_add_view(l, v);
logger_set_filter(l, e->pucch_iq_ue_logger = l;
filter_eq(
filter_evarg(database, "ENB_PHY_PUCCH_1AB_IQ", "UE_ID"),
filter_int(0)));
/* downlink/uplink UE DCIs */ /* downlink/uplink UE DCIs */
widget_add_child(g, top_container, widget_add_child(g, top_container,
...@@ -250,8 +360,8 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database) ...@@ -250,8 +360,8 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database)
logger_add_view(timelog, subview); logger_add_view(timelog, subview);
/* harq processes' ticktime view */ /* harq processes' ticktime view */
widget_add_child(g, top_container, e->dl_ul_harq_ue_label = new_label(g, "");
new_label(g,"DL/UL HARQ (x8) [UE 0]"), -1); widget_add_child(g, top_container, e->dl_ul_harq_ue_label, -1);
line = new_container(g, HORIZONTAL); line = new_container(g, HORIZONTAL);
widget_add_child(g, top_container, line, -1); widget_add_child(g, top_container, line, -1);
timeline_plot = new_timeline(g, 512, 2*8+2, 3); timeline_plot = new_timeline(g, 512, 2*8+2, 3);
...@@ -271,15 +381,14 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database) ...@@ -271,15 +381,14 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database)
/* tick on UL view */ /* tick on UL view */
subview = new_subview_ticktime(timeview, 9, new_color(g,"#bbb"), 3600*1000); subview = new_subview_ticktime(timeview, 9, new_color(g,"#bbb"), 3600*1000);
logger_add_view(timelog, subview); logger_add_view(timelog, subview);
/* DL harq pids */ /* DL DCI */
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
timelog = new_ticklog(h, database, "ENB_PHY_DLSCH_UE_DCI", timelog = new_ticklog(h, database, "ENB_PHY_DLSCH_UE_DCI",
"frame", "subframe"); "frame", "subframe");
subview = new_subview_ticktime(timeview, i+1, subview = new_subview_ticktime(timeview, i+1,
new_color(g,"#55f"), 3600*1000); new_color(g,"#55f"), 3600*1000);
logger_add_view(timelog, subview); logger_add_view(timelog, subview);
logger_set_filter(timelog, e->dl_dci_logger[i] = timelog;
ticktime_filter(database, "ENB_PHY_DLSCH_UE_DCI", i));
} }
/* DL ACK */ /* DL ACK */
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
...@@ -288,8 +397,7 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database) ...@@ -288,8 +397,7 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database)
subview = new_subview_ticktime(timeview, i+1, subview = new_subview_ticktime(timeview, i+1,
new_color(g,"#282"), 3600*1000); new_color(g,"#282"), 3600*1000);
logger_add_view(timelog, subview); logger_add_view(timelog, subview);
logger_set_filter(timelog, e->dl_ack_logger[i] = timelog;
ticktime_filter(database, "ENB_PHY_DLSCH_UE_ACK", i));
} }
/* DL NACK */ /* DL NACK */
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
...@@ -298,10 +406,9 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database) ...@@ -298,10 +406,9 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database)
subview = new_subview_ticktime(timeview, i+1, subview = new_subview_ticktime(timeview, i+1,
new_color(g,"#f22"), 3600*1000); new_color(g,"#f22"), 3600*1000);
logger_add_view(timelog, subview); logger_add_view(timelog, subview);
logger_set_filter(timelog, e->dl_nack_logger[i] = timelog;
ticktime_filter(database, "ENB_PHY_DLSCH_UE_NACK", i));
} }
/* UL harq pids */ /* UL DCI/retransmission without DCI */
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
/* first transmission */ /* first transmission */
timelog = new_ticklog(h, database, "ENB_PHY_ULSCH_UE_DCI", timelog = new_ticklog(h, database, "ENB_PHY_ULSCH_UE_DCI",
...@@ -309,17 +416,14 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database) ...@@ -309,17 +416,14 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database)
subview = new_subview_ticktime(timeview, i+9+1, subview = new_subview_ticktime(timeview, i+9+1,
new_color(g,"#55f"), 3600*1000); new_color(g,"#55f"), 3600*1000);
logger_add_view(timelog, subview); logger_add_view(timelog, subview);
logger_set_filter(timelog, e->ul_dci_logger[i] = timelog;
ticktime_filter(database, "ENB_PHY_ULSCH_UE_DCI", i));
/* retransmission */ /* retransmission */
timelog = new_ticklog(h, database, timelog = new_ticklog(h, database,
"ENB_PHY_ULSCH_UE_NO_DCI_RETRANSMISSION", "frame", "subframe"); "ENB_PHY_ULSCH_UE_NO_DCI_RETRANSMISSION", "frame", "subframe");
subview = new_subview_ticktime(timeview, i+9+1, subview = new_subview_ticktime(timeview, i+9+1,
new_color(g,"#99f"), 3600*1000); new_color(g,"#99f"), 3600*1000);
logger_add_view(timelog, subview); logger_add_view(timelog, subview);
logger_set_filter(timelog, e->ul_dci_retransmission_logger[i] = timelog;
ticktime_filter(database,
"ENB_PHY_ULSCH_UE_NO_DCI_RETRANSMISSION", i));
} }
/* UL ACK */ /* UL ACK */
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
...@@ -328,8 +432,7 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database) ...@@ -328,8 +432,7 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database)
subview = new_subview_ticktime(timeview, i+9+1, subview = new_subview_ticktime(timeview, i+9+1,
new_color(g,"#282"), 3600*1000); new_color(g,"#282"), 3600*1000);
logger_add_view(timelog, subview); logger_add_view(timelog, subview);
logger_set_filter(timelog, e->ul_ack_logger[i] = timelog;
ticktime_filter(database, "ENB_PHY_ULSCH_UE_ACK", i));
} }
/* UL NACK */ /* UL NACK */
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
...@@ -338,8 +441,7 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database) ...@@ -338,8 +441,7 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database)
subview = new_subview_ticktime(timeview, i+9+1, subview = new_subview_ticktime(timeview, i+9+1,
new_color(g,"#f22"), 3600*1000); new_color(g,"#f22"), 3600*1000);
logger_add_view(timelog, subview); logger_add_view(timelog, subview);
logger_set_filter(timelog, e->ul_nack_logger[i] = timelog;
ticktime_filter(database, "ENB_PHY_ULSCH_UE_NACK", i));
} }
/* phy/mac/rlc/pdcp/rrc textlog */ /* phy/mac/rlc/pdcp/rrc textlog */
...@@ -416,6 +518,10 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database) ...@@ -416,6 +518,10 @@ static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database)
widget_add_child(g, top_container, text, -1); widget_add_child(g, top_container, text, -1);
container_set_child_growable(g, top_container, text, 1); container_set_child_growable(g, top_container, text, 1);
e->legacy = new_view_textlist(10000, 10, g, text); e->legacy = new_view_textlist(10000, 10, g, text);
set_current_ue(g, ed, 0);
register_notifier(g, "click", e->prev_ue_button, click, ed);
register_notifier(g, "click", e->next_ue_button, click, ed);
} }
void view_add_log(view *v, char *log, event_handler *h, void *database, void view_add_log(view *v, char *log, event_handler *h, void *database,
...@@ -495,7 +601,11 @@ int main(int n, char **v) ...@@ -495,7 +601,11 @@ int main(int n, char **v)
g = gui_init(); g = gui_init();
new_thread(gui_thread, g); new_thread(gui_thread, g);
enb_main_gui(&eg, g, h, database); enb_data.ue = 0;
enb_data.e = &eg;
enb_data.database = database;
enb_main_gui(&eg, g, h, database, &enb_data);
for (i = 0; i < number_of_events; i++) { for (i = 0; i < number_of_events; i++) {
logger *textlog; logger *textlog;
...@@ -639,7 +749,9 @@ restart: ...@@ -639,7 +749,9 @@ restart:
event e; event e;
e = get_event(enb_data.socket, v, database); e = get_event(enb_data.socket, v, database);
if (e.type == -1) goto restart; if (e.type == -1) goto restart;
if (pthread_mutex_lock(&enb_data.lock)) abort();
handle_event(h, e); handle_event(h, e);
if (pthread_mutex_unlock(&enb_data.lock)) abort();
} }
return 0; return 0;
......
...@@ -13,6 +13,7 @@ struct filter { ...@@ -13,6 +13,7 @@ struct filter {
} v; } v;
int (*eval)(struct filter *this, event e); int (*eval)(struct filter *this, event e);
void (*free)(struct filter *this);
}; };
/****************************************************************************/ /****************************************************************************/
...@@ -52,7 +53,23 @@ int eval_evarg(struct filter *f, event e) ...@@ -52,7 +53,23 @@ int eval_evarg(struct filter *f, event e)
} }
/****************************************************************************/ /****************************************************************************/
/* filter construction functions */ /* free memory functions */
/****************************************************************************/
void free_op2(struct filter *f)
{
free_filter(f->v.op2.a);
free_filter(f->v.op2.b);
free(f);
}
void free_noop(struct filter *f)
{
free(f);
}
/****************************************************************************/
/* filter construction/destruction functions */
/****************************************************************************/ /****************************************************************************/
filter *filter_and(filter *a, filter *b) filter *filter_and(filter *a, filter *b)
...@@ -60,6 +77,7 @@ filter *filter_and(filter *a, filter *b) ...@@ -60,6 +77,7 @@ filter *filter_and(filter *a, filter *b)
struct filter *ret = calloc(1, sizeof(struct filter)); struct filter *ret = calloc(1, sizeof(struct filter));
if (ret == NULL) abort(); if (ret == NULL) abort();
ret->eval = eval_and; ret->eval = eval_and;
ret->free = free_op2;
ret->v.op2.a = a; ret->v.op2.a = a;
ret->v.op2.b = b; ret->v.op2.b = b;
return ret; return ret;
...@@ -70,6 +88,7 @@ filter *filter_eq(filter *a, filter *b) ...@@ -70,6 +88,7 @@ filter *filter_eq(filter *a, filter *b)
struct filter *ret = calloc(1, sizeof(struct filter)); struct filter *ret = calloc(1, sizeof(struct filter));
if (ret == NULL) abort(); if (ret == NULL) abort();
ret->eval = eval_eq; ret->eval = eval_eq;
ret->free = free_op2;
ret->v.op2.a = a; ret->v.op2.a = a;
ret->v.op2.b = b; ret->v.op2.b = b;
return ret; return ret;
...@@ -80,6 +99,7 @@ filter *filter_int(int v) ...@@ -80,6 +99,7 @@ filter *filter_int(int v)
struct filter *ret = calloc(1, sizeof(struct filter)); struct filter *ret = calloc(1, sizeof(struct filter));
if (ret == NULL) abort(); if (ret == NULL) abort();
ret->eval = eval_int; ret->eval = eval_int;
ret->free = free_noop;
ret->v.v = v; ret->v.v = v;
return ret; return ret;
} }
...@@ -97,6 +117,7 @@ filter *filter_evarg(void *database, char *event_name, char *varname) ...@@ -97,6 +117,7 @@ filter *filter_evarg(void *database, char *event_name, char *varname)
f = get_format(database, event_id); f = get_format(database, event_id);
ret->eval = eval_evarg; ret->eval = eval_evarg;
ret->free = free_noop;
ret->v.evarg.event_type = event_id; ret->v.evarg.event_type = event_id;
ret->v.evarg.arg_index = -1; ret->v.evarg.arg_index = -1;
...@@ -114,6 +135,14 @@ filter *filter_evarg(void *database, char *event_name, char *varname) ...@@ -114,6 +135,14 @@ filter *filter_evarg(void *database, char *event_name, char *varname)
return ret; return ret;
} }
void free_filter(filter *_f)
{
struct filter *f;
if (_f == NULL) return;
f = _f;
f->free(f);
}
/****************************************************************************/ /****************************************************************************/
/* eval function */