enb.c 21.8 KB
Newer Older
1
2
3
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Cedric Roux's avatar
Cedric Roux committed
4
#include <unistd.h>
5
#include <pthread.h>
6
#include <signal.h>
7
8
9
10
11
12
#include "database.h"
#include "event.h"
#include "handler.h"
#include "logger/logger.h"
#include "view/view.h"
#include "gui/gui.h"
13
#include "filter/filter.h"
14
15
16
#include "utils.h"
#include "../T_defs.h"
#include "event_selector.h"
Cedric Roux's avatar
Cedric Roux committed
17
#include "openair_logo.h"
18
#include "config.h"
19

Cedric Roux's avatar
Cedric Roux committed
20
typedef struct {
21
  view *phyview;
Cedric Roux's avatar
Cedric Roux committed
22
23
24
  view *macview;
  view *rlcview;
  view *pdcpview;
Cedric Roux's avatar
Cedric Roux committed
25
  view *rrcview;
Cedric Roux's avatar
Cedric Roux committed
26
  view *legacy;
Cedric Roux's avatar
Cedric Roux committed
27
28
} enb_gui;

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
typedef struct {
  int socket;
  int *is_on;
  int nevents;
  pthread_mutex_t lock;
} enb_data;

void is_on_changed(void *_d)
{
  enb_data *d = _d;
  char t;

  if (pthread_mutex_lock(&d->lock)) abort();

  if (d->socket == -1) goto no_connection;

  t = 1;
46
47
48
  if (socket_send(d->socket, &t, 1) == -1 ||
      socket_send(d->socket, &d->nevents, sizeof(int)) == -1 ||
      socket_send(d->socket, d->is_on, d->nevents * sizeof(int)) == -1)
Cedric Roux's avatar
Cedric Roux committed
49
    goto connection_dies;
50
51
52

no_connection:
  if (pthread_mutex_unlock(&d->lock)) abort();
Cedric Roux's avatar
Cedric Roux committed
53
54
55
56
57
58
  return;

connection_dies:
  close(d->socket);
  d->socket = -1;
  if (pthread_mutex_unlock(&d->lock)) abort();
59
60
}

61
62
63
64
65
66
67
68
69
70
71
72
void usage(void)
{
  printf(
"options:\n"
"    -d <database file>        this option is mandatory\n"
"    -on <GROUP or ID>         turn log ON for given GROUP or ID\n"
"    -off <GROUP or ID>        turn log OFF for given GROUP or ID\n"
"    -ON                       turn all logs ON\n"
"    -OFF                      turn all logs OFF\n"
"                              note: you may pass several -on/-off/-ON/-OFF,\n"
"                                    they will be processed in order\n"
"                                    by default, all is off\n"
73
74
"    -ip <host>                connect to given IP address (default %s)\n"
"    -p <port>                 connect to given port (default %d)\n"
75
"    -debug-gui                activate GUI debug logs\n",
76
  DEFAULT_REMOTE_IP,
77
78
79
80
81
82
83
84
85
86
87
88
  DEFAULT_REMOTE_PORT
  );
  exit(1);
}

static void *gui_thread(void *_g)
{
  gui *g = _g;
  gui_loop(g);
  return NULL;
}

89
90
static filter *ticktime_filter(void *database, char *event, int i)
{
Cedric Roux's avatar
cleanup    
Cedric Roux committed
91
  /* filter is "harq_pid == i && UE_id == 0 && eNB_id == 0" */
92
93
94
95
96
97
98
99
  return
    filter_and(
      filter_eq(filter_evarg(database, event, "harq_pid"), filter_int(i)),
      filter_and(
        filter_eq(filter_evarg(database, event, "UE_id"), filter_int(0)),
        filter_eq(filter_evarg(database, event, "eNB_ID"), filter_int(0))));
}

Cedric Roux's avatar
Cedric Roux committed
100
static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database)
101
102
103
{
  widget *main_window;
  widget *top_container;
Cedric Roux's avatar
Cedric Roux committed
104
  widget *line, *col;
Cedric Roux's avatar
Cedric Roux committed
105
  widget *logo;
106
107
108
  widget *input_signal_plot;
  logger *input_signal_log;
  view *input_signal_view;
Cedric Roux's avatar
Cedric Roux committed
109
  widget *timeline_plot;
110
111
112
  logger *timelog;
  view *timeview;
  view *subview;
Cedric Roux's avatar
Cedric Roux committed
113
114
  widget *text;
  view *textview;
Cedric Roux's avatar
Cedric Roux committed
115
  int i;
116
117
118
  widget *w;
  view *v;
  logger *l;
119

120
  main_window = new_toplevel_window(g, 1200, 900, "eNB tracer");
121
122
123
124
125
  top_container = new_container(g, VERTICAL);
  widget_add_child(g, main_window, top_container, -1);

  line = new_container(g, HORIZONTAL);
  widget_add_child(g, top_container, line, -1);
Cedric Roux's avatar
Cedric Roux committed
126
127
  logo = new_image(g, openair_logo_png, openair_logo_png_len);
  widget_add_child(g, line, logo, -1);
128
129
130
131
  input_signal_plot = new_xy_plot(g, 256, 55, "input signal", 20);
  widget_add_child(g, line, input_signal_plot, -1);
  xy_plot_set_range(g, input_signal_plot, 0, 7680*10, 20, 70);
  input_signal_log = new_framelog(h, database,
132
      "ENB_PHY_INPUT_SIGNAL", "subframe", "rxdata");
133
134
135
136
137
  /* a skip value of 10 means to process 1 frame over 10, that is
   * more or less 10 frames per second
   */
  framelog_set_skip(input_signal_log, 10);
  input_signal_view = new_view_xy(7680*10, 10,
Cedric Roux's avatar
Cedric Roux committed
138
      g, input_signal_plot, new_color(g, "#0c0c72"), XY_LOOP_MODE);
139
  logger_add_view(input_signal_log, input_signal_view);
Cedric Roux's avatar
Cedric Roux committed
140

141
  /* UE 0 PUSCH IQ data */
Cedric Roux's avatar
Cedric Roux committed
142
  w = new_xy_plot(g, 55, 55, "PUSCH IQ [UE 0]", 50);
143
144
145
146
147
148
149
150
151
  widget_add_child(g, line, w, -1);
  xy_plot_set_range(g, w, -1000, 1000, -1000, 1000);
  l = new_iqlog(h, database, "ENB_PHY_PUSCH_IQ", "nb_rb",
      "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);
  logger_add_view(l, v);
  logger_set_filter(l,
      filter_eq(
        filter_evarg(database, "ENB_PHY_PUSCH_IQ", "UE_ID"),
Cedric Roux's avatar
Cedric Roux committed
152
        filter_int(0)));
153
154

  /* UE 0 estimated UL channel */
Cedric Roux's avatar
Cedric Roux committed
155
  w = new_xy_plot(g, 280, 55, "UL estimated channel [UE 0]", 50);
156
157
158
159
160
161
162
163
164
165
166
  widget_add_child(g, line, w, -1);
  xy_plot_set_range(g, w, 0, 512*10, -10, 80);
  l = new_framelog(h, database,
      "ENB_PHY_UL_CHANNEL_ESTIMATE", "subframe", "chest_t");
  //framelog_set_skip(input_signal_log, 10);
  framelog_set_update_only_at_sf9(l, 0);
  v = new_view_xy(512*10, 10, g, w, new_color(g, "#0c0c72"), XY_LOOP_MODE);
  logger_add_view(l, v);
  logger_set_filter(l,
      filter_eq(
        filter_evarg(database, "ENB_PHY_UL_CHANNEL_ESTIMATE", "UE_ID"),
Cedric Roux's avatar
Cedric Roux committed
167
        filter_int(0)));
168

169
  /* downlink/uplink UE DCIs */
Cedric Roux's avatar
Cedric Roux committed
170
  widget_add_child(g, top_container,
Cedric Roux's avatar
Cedric Roux committed
171
      new_label(g,"DL/UL TICK/DCI/ACK/NACK [all UEs]"), -1);
Cedric Roux's avatar
Cedric Roux committed
172
173
  line = new_container(g, HORIZONTAL);
  widget_add_child(g, top_container, line, -1);
Cedric Roux's avatar
Cedric Roux committed
174
  timeline_plot = new_timeline(g, 512, 8, 5);
Cedric Roux's avatar
Cedric Roux committed
175
176
  widget_add_child(g, line, timeline_plot, -1);
  container_set_child_growable(g, line, timeline_plot, 1);
Cedric Roux's avatar
Cedric Roux committed
177
  for (i = 0; i < 8; i++)
Cedric Roux's avatar
Cedric Roux committed
178
    timeline_set_subline_background_color(g, timeline_plot, i,
Cedric Roux's avatar
Cedric Roux committed
179
        new_color(g, i==0 || i==4 ? "#aaf" : "#eee"));
180
  timeview = new_view_time(3600, 10, g, timeline_plot);
181
  /* DL tick logging */
182
  timelog = new_timelog(h, database, "ENB_PHY_DL_TICK");
Cedric Roux's avatar
Cedric Roux committed
183
  subview = new_subview_time(timeview, 0, new_color(g, "#77c"), 3600*1000);
184
  logger_add_view(timelog, subview);
185
  /* DL DCI logging */
186
  timelog = new_timelog(h, database, "ENB_PHY_DLSCH_UE_DCI");
187
  subview = new_subview_time(timeview, 1, new_color(g, "#228"), 3600*1000);
Cedric Roux's avatar
Cedric Roux committed
188
  logger_add_view(timelog, subview);
189
  /* DL ACK */
190
  timelog = new_timelog(h, database, "ENB_PHY_DLSCH_UE_ACK");
191
  subview = new_subview_time(timeview, 2, new_color(g, "#282"), 3600*1000);
192
  logger_add_view(timelog, subview);
193
  /* DL NACK */
194
  timelog = new_timelog(h, database, "ENB_PHY_DLSCH_UE_NACK");
195
  subview = new_subview_time(timeview, 3, new_color(g, "#f22"), 3600*1000);
196
  logger_add_view(timelog, subview);
197

198
  /* UL tick logging */
199
  timelog = new_timelog(h, database, "ENB_PHY_UL_TICK");
Cedric Roux's avatar
Cedric Roux committed
200
  subview = new_subview_time(timeview, 4, new_color(g, "#77c"), 3600*1000);
201
  logger_add_view(timelog, subview);
202
  /* UL DCI logging */
203
  timelog = new_timelog(h, database, "ENB_PHY_ULSCH_UE_DCI");
204
205
206
  subview = new_subview_time(timeview, 5, new_color(g, "#228"), 3600*1000);
  logger_add_view(timelog, subview);
  /* UL retransmission without DCI logging */
207
  timelog = new_timelog(h,database,"ENB_PHY_ULSCH_UE_NO_DCI_RETRANSMISSION");
208
209
210
  subview = new_subview_time(timeview, 5, new_color(g, "#f22"), 3600*1000);
  logger_add_view(timelog, subview);
  /* UL ACK */
211
  timelog = new_timelog(h, database, "ENB_PHY_ULSCH_UE_ACK");
212
213
214
  subview = new_subview_time(timeview, 6, new_color(g, "#282"), 3600*1000);
  logger_add_view(timelog, subview);
  /* UL NACK */
215
  timelog = new_timelog(h, database, "ENB_PHY_ULSCH_UE_NACK");
216
217
  subview = new_subview_time(timeview, 7, new_color(g, "#f22"), 3600*1000);
  logger_add_view(timelog, subview);
Cedric Roux's avatar
Cedric Roux committed
218

219
220
  /* harq processes' ticktime view */
  widget_add_child(g, top_container,
Cedric Roux's avatar
Cedric Roux committed
221
      new_label(g,"DL/UL HARQ (x8) [UE 0]"), -1);
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
  line = new_container(g, HORIZONTAL);
  widget_add_child(g, top_container, line, -1);
  timeline_plot = new_timeline(g, 512, 2*8+2, 3);
  widget_add_child(g, line, timeline_plot, -1);
  container_set_child_growable(g, line, timeline_plot, 1);
  for (i = 0; i < 2*8+2; i++)
    timeline_set_subline_background_color(g, timeline_plot, i,
        new_color(g, i==0 || i==9 ? "#ddd" : (i%9)&1 ? "#e6e6e6" : "#eee"));
  timeview = new_view_ticktime(10, g, timeline_plot);
  ticktime_set_tick(timeview,
      new_ticklog(h, database, "ENB_MASTER_TICK", "frame", "subframe"));
  /* tick */
  timelog = new_ticklog(h, database, "ENB_MASTER_TICK", "frame", "subframe");
  /* tick on DL view */
  subview = new_subview_ticktime(timeview, 0, new_color(g,"#bbb"), 3600*1000);
  logger_add_view(timelog, subview);
  /* tick on UL view */
  subview = new_subview_ticktime(timeview, 9, new_color(g,"#bbb"), 3600*1000);
  logger_add_view(timelog, subview);
  /* DL harq pids */
  for (i = 0; i < 8; i++) {
243
    timelog = new_ticklog(h, database, "ENB_PHY_DLSCH_UE_DCI",
244
245
246
247
248
        "frame", "subframe");
    subview = new_subview_ticktime(timeview, i+1,
        new_color(g,"#55f"), 3600*1000);
    logger_add_view(timelog, subview);
    logger_set_filter(timelog,
249
        ticktime_filter(database, "ENB_PHY_DLSCH_UE_DCI", i));
250
251
252
  }
  /* DL ACK */
  for (i = 0; i < 8; i++) {
253
    timelog = new_ticklog(h, database, "ENB_PHY_DLSCH_UE_ACK",
254
255
256
257
258
        "frame", "subframe");
    subview = new_subview_ticktime(timeview, i+1,
        new_color(g,"#282"), 3600*1000);
    logger_add_view(timelog, subview);
    logger_set_filter(timelog,
259
        ticktime_filter(database, "ENB_PHY_DLSCH_UE_ACK", i));
260
261
262
  }
  /* DL NACK */
  for (i = 0; i < 8; i++) {
263
    timelog = new_ticklog(h, database, "ENB_PHY_DLSCH_UE_NACK",
264
265
266
267
268
        "frame", "subframe");
    subview = new_subview_ticktime(timeview, i+1,
        new_color(g,"#f22"), 3600*1000);
    logger_add_view(timelog, subview);
    logger_set_filter(timelog,
269
        ticktime_filter(database, "ENB_PHY_DLSCH_UE_NACK", i));
270
271
272
273
  }
  /* UL harq pids */
  for (i = 0; i < 8; i++) {
    /* first transmission */
274
    timelog = new_ticklog(h, database, "ENB_PHY_ULSCH_UE_DCI",
275
276
277
278
279
        "frame", "subframe");
    subview = new_subview_ticktime(timeview, i+9+1,
        new_color(g,"#55f"), 3600*1000);
    logger_add_view(timelog, subview);
    logger_set_filter(timelog,
280
        ticktime_filter(database, "ENB_PHY_ULSCH_UE_DCI", i));
281
    /* retransmission */
282
283
    timelog = new_ticklog(h, database,
        "ENB_PHY_ULSCH_UE_NO_DCI_RETRANSMISSION", "frame", "subframe");
284
285
286
287
    subview = new_subview_ticktime(timeview, i+9+1,
        new_color(g,"#99f"), 3600*1000);
    logger_add_view(timelog, subview);
    logger_set_filter(timelog,
288
289
        ticktime_filter(database,
            "ENB_PHY_ULSCH_UE_NO_DCI_RETRANSMISSION", i));
290
291
292
  }
  /* UL ACK */
  for (i = 0; i < 8; i++) {
293
    timelog = new_ticklog(h, database, "ENB_PHY_ULSCH_UE_ACK",
294
295
296
297
298
        "frame", "subframe");
    subview = new_subview_ticktime(timeview, i+9+1,
        new_color(g,"#282"), 3600*1000);
    logger_add_view(timelog, subview);
    logger_set_filter(timelog,
299
        ticktime_filter(database, "ENB_PHY_ULSCH_UE_ACK", i));
300
301
302
  }
  /* UL NACK */
  for (i = 0; i < 8; i++) {
303
    timelog = new_ticklog(h, database, "ENB_PHY_ULSCH_UE_NACK",
304
305
306
307
308
        "frame", "subframe");
    subview = new_subview_ticktime(timeview, i+9+1,
        new_color(g,"#f22"), 3600*1000);
    logger_add_view(timelog, subview);
    logger_set_filter(timelog,
309
        ticktime_filter(database, "ENB_PHY_ULSCH_UE_NACK", i));
310
311
  }

Cedric Roux's avatar
Cedric Roux committed
312
313
314
315
316
317
318
319
320
321
322
323
324
325
  /* phy/mac/rlc/pdcp/rrc textlog */
  line = new_container(g, HORIZONTAL);
  widget_add_child(g, top_container, line, -1);
  container_set_child_growable(g, top_container, line, 1);

  /* phy */
  col = new_container(g, VERTICAL);
  widget_add_child(g, line, col, -1);
  container_set_child_growable(g, line, col, 1);
  widget_add_child(g, col, new_label(g, "PHY"), -1);
  text = new_textlist(g, 100, 10, new_color(g, "#afa"));
  widget_add_child(g, col, text, -1);
  container_set_child_growable(g, col, text, 1);
  textview = new_view_textlist(10000, 10, g, text);
326
  e->phyview = textview;
Cedric Roux's avatar
Cedric Roux committed
327
328
329
330
331
332
333
334
335
336

  /* mac */
  col = new_container(g, VERTICAL);
  widget_add_child(g, line, col, -1);
  container_set_child_growable(g, line, col, 1);
  widget_add_child(g, col, new_label(g, "MAC"), -1);
  text = new_textlist(g, 100, 10, new_color(g, "#adf"));
  widget_add_child(g, col, text, -1);
  container_set_child_growable(g, col, text, 1);
  textview = new_view_textlist(10000, 10, g, text);
Cedric Roux's avatar
Cedric Roux committed
337
  e->macview = textview;
Cedric Roux's avatar
Cedric Roux committed
338

339
340
341
342
  line = new_container(g, HORIZONTAL);
  widget_add_child(g, top_container, line, -1);
  container_set_child_growable(g, top_container, line, 1);

Cedric Roux's avatar
Cedric Roux committed
343
344
345
346
347
348
349
350
351
  /* rlc */
  col = new_container(g, VERTICAL);
  widget_add_child(g, line, col, -1);
  container_set_child_growable(g, line, col, 1);
  widget_add_child(g, col, new_label(g, "RLC"), -1);
  text = new_textlist(g, 100, 10, new_color(g, "#aff"));
  widget_add_child(g, col, text, -1);
  container_set_child_growable(g, col, text, 1);
  textview = new_view_textlist(10000, 10, g, text);
Cedric Roux's avatar
Cedric Roux committed
352
  e->rlcview = textview;
Cedric Roux's avatar
Cedric Roux committed
353
354
355
356
357
358
359
360
361
362

  /* pdcp */
  col = new_container(g, VERTICAL);
  widget_add_child(g, line, col, -1);
  container_set_child_growable(g, line, col, 1);
  widget_add_child(g, col, new_label(g, "PDCP"), -1);
  text = new_textlist(g, 100, 10, new_color(g, "#ed9"));
  widget_add_child(g, col, text, -1);
  container_set_child_growable(g, col, text, 1);
  textview = new_view_textlist(10000, 10, g, text);
Cedric Roux's avatar
Cedric Roux committed
363
  e->pdcpview = textview;
Cedric Roux's avatar
Cedric Roux committed
364

365
366
367
368
  line = new_container(g, HORIZONTAL);
  widget_add_child(g, top_container, line, -1);
  container_set_child_growable(g, top_container, line, 1);

Cedric Roux's avatar
Cedric Roux committed
369
370
371
372
373
374
375
376
377
378
  /* rrc */
  col = new_container(g, VERTICAL);
  widget_add_child(g, line, col, -1);
  container_set_child_growable(g, line, col, 1);
  widget_add_child(g, col, new_label(g, "RRC"), -1);
  text = new_textlist(g, 100, 10, new_color(g, "#fdb"));
  widget_add_child(g, col, text, -1);
  container_set_child_growable(g, col, text, 1);
  textview = new_view_textlist(10000, 10, g, text);
  e->rrcview = textview;
Cedric Roux's avatar
Cedric Roux committed
379
380
381
382
383
384
385

  /* legacy logs (LOG_I, LOG_D, ...) */
  widget_add_child(g, top_container, new_label(g, "LEGACY"), -1);
  text = new_textlist(g, 100, 10, new_color(g, "#eeb"));
  widget_add_child(g, top_container, text, -1);
  container_set_child_growable(g, top_container, text, 1);
  e->legacy = new_view_textlist(10000, 10, g, text);
Cedric Roux's avatar
Cedric Roux committed
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
}

void view_add_log(view *v, char *log, event_handler *h, void *database,
    int *is_on)
{
  logger *textlog;
  char *name, *desc;

  database_get_generic_description(database,
      event_id_from_name(database, log), &name, &desc);
  textlog = new_textlog(h, database, name, desc);
  logger_add_view(textlog, v);
  free(name);
  free(desc);

  on_off(database, log, is_on, 1);
402
403
404
405
406
407
408
}

int main(int n, char **v)
{
  extern int volatile gui_logd;
  char *database_filename = NULL;
  void *database;
409
  char *ip = DEFAULT_REMOTE_IP;
410
411
412
413
414
415
416
417
418
  int port = DEFAULT_REMOTE_PORT;
  char **on_off_name;
  int *on_off_action;
  int on_off_n = 0;
  int *is_on;
  int number_of_events;
  int i;
  event_handler *h;
  gui *g;
Cedric Roux's avatar
Cedric Roux committed
419
  enb_gui eg;
420
  enb_data enb_data;
421

422
423
424
  /* write on a socket fails if the other end is closed and we get SIGPIPE */
  if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) abort();

425
426
427
428
429
430
431
  on_off_name = malloc(n * sizeof(char *)); if (on_off_name == NULL) abort();
  on_off_action = malloc(n * sizeof(int)); if (on_off_action == NULL) abort();

  for (i = 1; i < n; i++) {
    if (!strcmp(v[i], "-h") || !strcmp(v[i], "--help")) usage();
    if (!strcmp(v[i], "-d"))
      { if (i > n-2) usage(); database_filename = v[++i]; continue; }
432
    if (!strcmp(v[i], "-ip")) { if (i > n-2) usage(); ip = v[++i]; continue; }
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
    if (!strcmp(v[i], "-p"))
      { if (i > n-2) usage(); port = atoi(v[++i]); continue; }
    if (!strcmp(v[i], "-on")) { if (i > n-2) usage();
      on_off_name[on_off_n]=v[++i]; on_off_action[on_off_n++]=1; continue; }
    if (!strcmp(v[i], "-off")) { if (i > n-2) usage();
      on_off_name[on_off_n]=v[++i]; on_off_action[on_off_n++]=0; continue; }
    if (!strcmp(v[i], "-ON"))
      { on_off_name[on_off_n]=NULL; on_off_action[on_off_n++]=1; continue; }
    if (!strcmp(v[i], "-OFF"))
      { on_off_name[on_off_n]=NULL; on_off_action[on_off_n++]=0; continue; }
    if (!strcmp(v[i], "-debug-gui")) { gui_logd = 1; continue; }
    usage();
  }

  if (database_filename == NULL) {
    printf("ERROR: provide a database file (-d)\n");
    exit(1);
  }

  database = parse_database(database_filename);

454
  load_config_file(database_filename);
455

456
457
458
459
460
461
462
463
464
  number_of_events = number_of_ids(database);
  is_on = calloc(number_of_events, sizeof(int));
  if (is_on == NULL) abort();

  h = new_handler(database);

  g = gui_init();
  new_thread(gui_thread, g);

Cedric Roux's avatar
Cedric Roux committed
465
  enb_main_gui(&eg, g, h, database);
466

Cedric Roux's avatar
Cedric Roux committed
467
468
469
470
  for (i = 0; i < number_of_events; i++) {
    logger *textlog;
    char *name, *desc;
    database_get_generic_description(database, i, &name, &desc);
Cedric Roux's avatar
Cedric Roux committed
471
472
473
474
    if (!strncmp(name, "LEGACY_", 7)) {
      textlog = new_textlog(h, database, name, desc);
      logger_add_view(textlog, eg.legacy);
    }
Cedric Roux's avatar
Cedric Roux committed
475
476
477
478
    free(name);
    free(desc);
  }

479
  on_off(database, "ENB_PHY_INPUT_SIGNAL", is_on, 1);
480
  on_off(database, "ENB_PHY_UL_CHANNEL_ESTIMATE", is_on, 1);
481
482
483
484
485
486
487
488
489
  on_off(database, "ENB_PHY_DL_TICK", is_on, 1);
  on_off(database, "ENB_PHY_DLSCH_UE_DCI", is_on, 1);
  on_off(database, "ENB_PHY_DLSCH_UE_ACK", is_on, 1);
  on_off(database, "ENB_PHY_DLSCH_UE_NACK", is_on, 1);
  on_off(database, "ENB_PHY_UL_TICK", is_on, 1);
  on_off(database, "ENB_PHY_ULSCH_UE_DCI", is_on, 1);
  on_off(database, "ENB_PHY_ULSCH_UE_NO_DCI_RETRANSMISSION", is_on, 1);
  on_off(database, "ENB_PHY_ULSCH_UE_ACK", is_on, 1);
  on_off(database, "ENB_PHY_ULSCH_UE_NACK", is_on, 1);
490
  on_off(database, "ENB_MASTER_TICK", is_on, 1);
491
  on_off(database, "ENB_PHY_PUSCH_IQ", is_on, 1);
492

493
494
495
496
  on_off(database, "LEGACY_RRC_INFO", is_on, 1);
  on_off(database, "LEGACY_RRC_ERROR", is_on, 1);
  on_off(database, "LEGACY_RRC_WARNING", is_on, 1);

497
498
499
500
501
  view_add_log(eg.phyview, "ENB_PHY_DLSCH_UE_DCI", h, database, is_on);
  view_add_log(eg.phyview, "ENB_PHY_DLSCH_UE_ACK", h, database, is_on);
  view_add_log(eg.phyview, "ENB_PHY_DLSCH_UE_NACK", h, database, is_on);
  view_add_log(eg.phyview, "ENB_PHY_ULSCH_UE_DCI", h, database, is_on);
  view_add_log(eg.phyview, "ENB_PHY_ULSCH_UE_NO_DCI_RETRANSMISSION",
502
      h, database, is_on);
503
504
  view_add_log(eg.phyview, "ENB_PHY_ULSCH_UE_ACK", h, database, is_on);
  view_add_log(eg.phyview, "ENB_PHY_ULSCH_UE_NACK", h, database, is_on);
505

Cedric Roux's avatar
Cedric Roux committed
506
507
508
509
510
  view_add_log(eg.macview, "ENB_MAC_UE_DL_SDU", h, database, is_on);
  view_add_log(eg.macview, "ENB_MAC_UE_UL_SCHEDULE", h, database, is_on);
  view_add_log(eg.macview, "ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION",
      h, database, is_on);
  view_add_log(eg.macview, "ENB_MAC_UE_UL_PDU", h, database, is_on);
511
  view_add_log(eg.macview, "ENB_MAC_UE_UL_PDU_WITH_DATA", h, database, is_on);
Cedric Roux's avatar
Cedric Roux committed
512
  view_add_log(eg.macview, "ENB_MAC_UE_UL_SDU", h, database, is_on);
513
  view_add_log(eg.macview, "ENB_MAC_UE_UL_SDU_WITH_DATA", h, database, is_on);
Cedric Roux's avatar
Cedric Roux committed
514
515
516
517
518
519
520
521
522
523
  view_add_log(eg.macview, "ENB_MAC_UE_UL_CE", h, database, is_on);

  view_add_log(eg.rlcview, "ENB_RLC_DL", h, database, is_on);
  view_add_log(eg.rlcview, "ENB_RLC_UL", h, database, is_on);
  view_add_log(eg.rlcview, "ENB_RLC_MAC_DL", h, database, is_on);
  view_add_log(eg.rlcview, "ENB_RLC_MAC_UL", h, database, is_on);

  view_add_log(eg.pdcpview, "ENB_PDCP_UL", h, database, is_on);
  view_add_log(eg.pdcpview, "ENB_PDCP_DL", h, database, is_on);

Cedric Roux's avatar
Cedric Roux committed
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
  view_add_log(eg.rrcview, "ENB_RRC_CONNECTION_SETUP_COMPLETE",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_SECURITY_MODE_COMMAND",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_UE_CAPABILITY_ENQUIRY",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_CONNECTION_REJECT",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_CONNECTION_REESTABLISHMENT_REJECT",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_CONNECTION_RELEASE",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_CONNECTION_RECONFIGURATION",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_MEASUREMENT_REPORT",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_HANDOVER_PREPARATION_INFORMATION",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_CONNECTION_RECONFIGURATION_COMPLETE",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_CONNECTION_SETUP",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_UL_CCCH_DATA_IN",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_UL_DCCH_DATA_IN",
      h, database, is_on);
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
  view_add_log(eg.rrcview, "ENB_RRC_SECURITY_MODE_COMPLETE",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_SECURITY_MODE_FAILURE",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_UE_CAPABILITY_INFORMATION",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_CONNECTION_REQUEST",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_CONNECTION_REESTABLISHMENT_REQUEST",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_CONNECTION_REESTABLISHMENT_COMPLETE",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_UL_HANDOVER_PREPARATION_TRANSFER",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_UL_INFORMATION_TRANSFER",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_COUNTER_CHECK_RESPONSE",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_UE_INFORMATION_RESPONSE_R9",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_PROXIMITY_INDICATION_R9",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_RECONFIGURATION_COMPLETE_R10",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_MBMS_COUNTING_RESPONSE_R10",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_INTER_FREQ_RSTD_MEASUREMENT_INDICATION",
      h, database, is_on);
  view_add_log(eg.rrcview, "ENB_RRC_UNKNOW_MESSAGE",
      h, database, is_on);
Cedric Roux's avatar
Cedric Roux committed
580

581
582
583
584
  /* deactivate those two by default, they are a bit heavy */
  on_off(database, "ENB_MAC_UE_UL_SDU_WITH_DATA", is_on, 0);
  on_off(database, "ENB_MAC_UE_UL_PDU_WITH_DATA", is_on, 0);

585
586
587
  for (i = 0; i < on_off_n; i++)
    on_off(database, on_off_name[i], is_on, on_off_action[i]);

588
589
590
591
592
  enb_data.socket = -1;
  enb_data.is_on = is_on;
  enb_data.nevents = number_of_events;
  if (pthread_mutex_init(&enb_data.lock, NULL)) abort();
  setup_event_selector(g, database, is_on, is_on_changed, &enb_data);
593

Cedric Roux's avatar
Cedric Roux committed
594
595
restart:
  clear_remote_config();
596
  enb_data.socket = connect_to(ip, port);
597

598
599
  /* send the first message - activate selected traces */
  is_on_changed(&enb_data);
600
601
602
603
604

  /* read messages */
  while (1) {
    char v[T_BUFFER_MAX];
    event e;
605
    e = get_event(enb_data.socket, v, database);
Cedric Roux's avatar
Cedric Roux committed
606
    if (e.type == -1) goto restart;
607
608
609
610
611
    handle_event(h, e);
  }

  return 0;
}