blob: 5c532051eff988dc22cc2aae9682add2ec400855 [file] [log] [blame]
Harald Welte39cfbf42016-07-28 09:04:11 +02001#include <osmocom/core/signal.h>
2#include <osmocom/core/logging.h>
3#include <osmocom/core/application.h>
4#include <osmocom/vty/vty.h>
5#include <osmocom/vty/telnet_interface.h>
6
7#include <osmocom/abis/abis.h>
8#include <osmocom/abis/e1_input.h>
9
10#include "storage.h"
11#include "recorder.h"
12
13static enum osmo_e1cap_capture_mode ts2cap_mode(struct e1inp_ts *ts)
14{
15 switch (ts->type) {
16 case E1INP_TS_TYPE_RAW:
17 return OSMO_E1CAP_MODE_RAW;
18 case E1INP_TS_TYPE_SIGN:
19 return OSMO_E1CAP_MODE_HDLC;
20 case E1INP_TS_TYPE_TRAU:
21 return OSMO_E1CAP_MODE_TRAU;
22 default:
23 OSMO_ASSERT(0);
24 }
25}
26
27/* receive a raw message frome the E1 timeslot */
28void e1ts_raw_recv(struct e1inp_ts *ts, struct msgb *msg)
29{
Harald Welte0e91aa12016-07-28 21:03:40 +020030 struct e1_recorder_line *rline = &g_recorder.line[ts->line->num];
Harald Welte39cfbf42016-07-28 09:04:11 +020031 enum osmo_e1cap_capture_mode cap_mode = ts2cap_mode(ts);
32
33 /* FIXME: special processing of TFP and PGSL */
34
35 e1frame_store(ts, msg, cap_mode);
36
Harald Welte0e91aa12016-07-28 21:03:40 +020037 if (rline->mirror.enabled) {
Harald Welte39cfbf42016-07-28 09:04:11 +020038 /* forward data to destination line */
39 }
40}
41
42static int inp_sig_cb(unsigned int subsys, unsigned int signal,
43 void *handler_data, void *signal_data)
44{
45 OSMO_ASSERT(subsys == SS_L_INPUT);
46
47 /* FIXME */
48
49 return 0;
50}
51
52// e1inp_ts_config_raw(ts, line, &e1ts_raw_recv);
53
54static const struct log_info_cat recorder_categories[] = {
55 [DMAIN] = {
56 .name = "MAIN",
57 .enabled = 1, .loglevel = LOGL_DEBUG,
58 },
59};
60static struct log_info info = {
61 .cat = recorder_categories,
62 .num_cat = ARRAY_SIZE(recorder_categories),
63};
64
65struct vty_app_info vty_info = {
66 .name = "osmo-e1-recorder",
67 .version = "0",
68 .copyright = "(C) 2016 by Harald Welte <laforge@gnumonks.org>\n",
69};
70
71static void *rec_tall_ctx;
72struct e1_recorder g_recorder;
73
74int main(int argc, char **argv)
75{
76 int rc;
77
78 rec_tall_ctx = talloc_named_const(NULL, 0, "recorder");
79
80 osmo_init_logging(&info);
81 vty_init(&vty_info);
82 osmo_signal_register_handler(SS_L_INPUT, inp_sig_cb, NULL);
83 libosmo_abis_init(rec_tall_ctx);
84 e1inp_vty_init();
85 recorder_vty_init();
86
87 rc = vty_read_config_file("osmo-e1-recorder.cfg", NULL);
88 if (rc < 0)
89 exit(1);
90
91 /* start telne tafte reading config for vty_get_bind_adr() */
92 telnet_init_dynif(rec_tall_ctx, NULL, vty_get_bind_addr(), 4444);
93
94 while (1) {
95 osmo_select_main(0);
96 };
97}