blob: 9ea4f178116bcf295467bac48af82d023531ce8e [file] [log] [blame]
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +02001/* OpenBSC Abis interface to E1 */
2
3/* (C) 2008-2009 by Harald Welte <laforge@gnumonks.org>
4 *
5 * All Rights Reserved
6 *
Harald Welte323d39d2017-11-13 01:09:21 +09007 * SPDX-License-Identifier: AGPL-3.0+
8 *
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +02009 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
18 *
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 *
22 */
23
24#include "internal.h"
Harald Welte3bc78852011-08-24 08:32:38 +020025#include "../config.h"
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +020026
27#include <stdio.h>
28#include <unistd.h>
29#include <stdlib.h>
30#include <errno.h>
31#include <string.h>
32#include <time.h>
Holger Hans Peter Freyther25474582017-01-23 19:49:07 +010033#include <fcntl.h>
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +020034#include <sys/socket.h>
35#include <sys/ioctl.h>
36#include <arpa/inet.h>
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +020037
Harald Weltefd44a5f2011-08-21 00:48:54 +020038#include <osmocom/abis/lapd.h>
39
Harald Weltef2737fc2011-08-16 14:30:10 +020040#include <osmocom/core/linuxlist.h>
41#include <osmocom/core/talloc.h>
42#include <osmocom/core/rate_ctr.h>
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +020043#include <osmocom/core/logging.h>
44#include <osmocom/core/signal.h>
Neels Hofmeyra160e4b2018-11-16 00:16:57 +010045#include <osmocom/core/endian.h>
Pablo Neira Ayuso177094b2011-06-07 12:21:51 +020046#include <osmocom/abis/e1_input.h>
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +020047
48#define NUM_E1_TS 32
49
50static void *tall_e1inp_ctx;
51
52/* list of all E1 drivers */
53LLIST_HEAD(e1inp_driver_list);
54
55/* list of all E1 lines */
56LLIST_HEAD(e1inp_line_list);
57
58static void *tall_sigl_ctx;
59
Harald Weltef2737fc2011-08-16 14:30:10 +020060static const struct rate_ctr_desc e1inp_ctr_d[] = {
61 [E1I_CTR_HDLC_ABORT] = {
Pau Espin Pedrola2106842018-07-24 15:00:11 +020062 "hdlc:abort", "HDLC abort"
Harald Weltef2737fc2011-08-16 14:30:10 +020063 },
64 [E1I_CTR_HDLC_BADFCS] = {
Pau Espin Pedrola2106842018-07-24 15:00:11 +020065 "hdlc:bad_fcs", "HLDC Bad FCS"
Harald Weltef2737fc2011-08-16 14:30:10 +020066 },
67 [E1I_CTR_HDLC_OVERR] = {
Pau Espin Pedrola2106842018-07-24 15:00:11 +020068 "hdlc:overrun", "HDLC Overrun"
Harald Weltef2737fc2011-08-16 14:30:10 +020069 },
70 [E1I_CTR_ALARM] = {
Harald Weltedd0c2ef2011-08-11 12:54:07 +020071 "alarm", "Alarm"
Harald Weltef2737fc2011-08-16 14:30:10 +020072 },
73 [E1I_CTR_REMOVED] = {
Harald Weltedd0c2ef2011-08-11 12:54:07 +020074 "removed", "Line removed"
Harald Weltef2737fc2011-08-16 14:30:10 +020075 },
76};
77
78static const struct rate_ctr_group_desc e1inp_ctr_g_d = {
79 .group_name_prefix = "e1inp",
80 .group_description = "E1 Input subsystem",
81 .num_ctr = ARRAY_SIZE(e1inp_ctr_d),
82 .ctr_desc = e1inp_ctr_d,
83};
84
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +020085/*
86 * pcap writing of the misdn load
87 * pcap format is from http://wiki.wireshark.org/Development/LibpcapFileFormat
88 */
89#define DLT_LINUX_LAPD 177
90#define PCAP_INPUT 0
91#define PCAP_OUTPUT 1
92
93struct pcap_hdr {
94 uint32_t magic_number;
95 uint16_t version_major;
96 uint16_t version_minor;
97 int32_t thiszone;
98 uint32_t sigfigs;
99 uint32_t snaplen;
100 uint32_t network;
101} __attribute__((packed));
102
103struct pcaprec_hdr {
104 uint32_t ts_sec;
105 uint32_t ts_usec;
106 uint32_t incl_len;
107 uint32_t orig_len;
108} __attribute__((packed));
109
110struct fake_linux_lapd_header {
111 uint16_t pkttype;
112 uint16_t hatype;
113 uint16_t halen;
114 uint64_t addr;
115 int16_t protocol;
116} __attribute__((packed));
117
118struct lapd_header {
Neels Hofmeyra160e4b2018-11-16 00:16:57 +0100119#if OSMO_IS_LITTLE_ENDIAN
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200120 uint8_t ea1 : 1;
121 uint8_t cr : 1;
122 uint8_t sapi : 6;
123 uint8_t ea2 : 1;
124 uint8_t tei : 7;
125 uint8_t control_foo; /* fake UM's ... */
Neels Hofmeyra160e4b2018-11-16 00:16:57 +0100126#elif OSMO_IS_BIG_ENDIAN
127/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
128 uint8_t sapi:6, cr:1, ea1:1;
129 uint8_t tei:7, ea2:1;
130 uint8_t control_foo;
131#endif
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200132} __attribute__((packed));
133
134osmo_static_assert(offsetof(struct fake_linux_lapd_header, hatype) == 2, hatype_offset);
135osmo_static_assert(offsetof(struct fake_linux_lapd_header, halen) == 4, halen_offset);
136osmo_static_assert(offsetof(struct fake_linux_lapd_header, addr) == 6, addr_offset);
137osmo_static_assert(offsetof(struct fake_linux_lapd_header, protocol) == 14, proto_offset);
138osmo_static_assert(sizeof(struct fake_linux_lapd_header) == 16, lapd_header_size);
139
140
141static int pcap_fd = -1;
142
Pablo Neira Ayuso2e11f5c2013-07-05 15:08:18 +0200143int e1_set_pcap_fd(int fd)
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200144{
Sylvain Munaut4b45e9d2020-05-08 09:40:44 +0200145 const struct pcap_hdr header = {
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200146 .magic_number = 0xa1b2c3d4,
147 .version_major = 2,
148 .version_minor = 4,
149 .thiszone = 0,
150 .sigfigs = 0,
151 .snaplen = 65535,
152 .network = DLT_LINUX_LAPD,
153 };
Sylvain Munaut4b45e9d2020-05-08 09:40:44 +0200154 struct e1inp_line *line;
155 int i;
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200156
Sylvain Munaut4b45e9d2020-05-08 09:40:44 +0200157 /* write header */
158 if (fd >= 0) {
159 int rc = write(fd, &header, sizeof(header));
160 if (rc < 0)
161 return rc;
162 }
163
164 /* update fd in all lines in our global list of e1 lines */
165 llist_for_each_entry(line, &e1inp_line_list, list) {
166 /* Set the PCAP file descriptor for all timeslots that have
167 * software LAPD instances, to ensure the osmo_lapd_pcap code is
168 * used to write PCAP files (if requested) */
169 for (i = 0; i < ARRAY_SIZE(line->ts); i++) {
170 struct e1inp_ts *e1i_ts = &line->ts[i];
171 if (e1i_ts->lapd)
172 e1i_ts->lapd->pcap_fd = fd;
173 }
174 }
175
176 /* close previous and update global */
177 if (pcap_fd >= 0)
178 close(pcap_fd);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200179 pcap_fd = fd;
Sylvain Munaut4b45e9d2020-05-08 09:40:44 +0200180
181 return 0;
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200182}
183
184/* This currently only works for the D-Channel */
185static void write_pcap_packet(int direction, int sapi, int tei,
186 struct msgb *msg) {
187 if (pcap_fd < 0)
188 return;
189
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200190 time_t cur_time;
191 struct tm *tm;
192
193 struct fake_linux_lapd_header header = {
194 .pkttype = 4,
195 .hatype = 0,
196 .halen = 0,
197 .addr = direction == PCAP_OUTPUT ? 0x0 : 0x1,
198 .protocol = ntohs(48),
199 };
200
201 struct lapd_header lapd_header = {
202 .ea1 = 0,
203 .cr = direction == PCAP_OUTPUT ? 1 : 0,
204 .sapi = sapi & 0x3F,
205 .ea2 = 1,
206 .tei = tei & 0x7F,
207 .control_foo = 0x03 /* UI */,
208 };
209
210 struct pcaprec_hdr payload_header = {
211 .ts_sec = 0,
212 .ts_usec = 0,
213 .incl_len = msgb_l2len(msg) + sizeof(struct fake_linux_lapd_header)
214 + sizeof(struct lapd_header),
215 .orig_len = msgb_l2len(msg) + sizeof(struct fake_linux_lapd_header)
216 + sizeof(struct lapd_header),
217 };
218
219
220 cur_time = time(NULL);
221 tm = localtime(&cur_time);
222 payload_header.ts_sec = mktime(tm);
223
Harald Weltec9295ea2014-08-21 02:41:41 +0200224 write(pcap_fd, &payload_header, sizeof(payload_header));
225 write(pcap_fd, &header, sizeof(header));
226 write(pcap_fd, &lapd_header, sizeof(lapd_header));
227 write(pcap_fd, msg->l2h, msgb_l2len(msg));
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200228}
229
Harald Welte4ca5c532016-07-27 23:05:03 +0200230const struct value_string e1inp_sign_type_names[5] = {
231 { E1INP_SIGN_NONE, "None" },
232 { E1INP_SIGN_OML, "OML" },
233 { E1INP_SIGN_RSL, "RSL" },
234 { E1INP_SIGN_OSMO, "OSMO" },
235 { 0, NULL }
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200236};
Harald Welte4ca5c532016-07-27 23:05:03 +0200237
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200238const char *e1inp_signtype_name(enum e1inp_sign_type tp)
239{
Harald Welte4ca5c532016-07-27 23:05:03 +0200240 return get_value_string(e1inp_sign_type_names, tp);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200241}
242
Harald Welte7a228eb2016-07-28 11:09:31 +0200243const struct value_string e1inp_ts_type_names[6] = {
Harald Welte4ca5c532016-07-27 23:05:03 +0200244 { E1INP_TS_TYPE_NONE, "None" },
245 { E1INP_TS_TYPE_SIGN, "Signalling" },
246 { E1INP_TS_TYPE_TRAU, "TRAU" },
Harald Weltea0108e72016-07-27 21:44:50 +0200247 { E1INP_TS_TYPE_RAW, "RAW" },
Harald Welte7a228eb2016-07-28 11:09:31 +0200248 { E1INP_TS_TYPE_HDLC, "HDLC" },
Harald Welte4ca5c532016-07-27 23:05:03 +0200249 { 0, NULL }
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200250};
251
252const char *e1inp_tstype_name(enum e1inp_ts_type tp)
253{
Harald Welte4ca5c532016-07-27 23:05:03 +0200254 return get_value_string(e1inp_ts_type_names, tp);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200255}
256
Pablo Neira Ayuso96e72632011-06-26 19:08:05 +0200257int abis_sendmsg(struct msgb *msg)
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200258{
259 struct e1inp_sign_link *sign_link = msg->dst;
260 struct e1inp_driver *e1inp_driver;
261 struct e1inp_ts *e1i_ts;
Alexander Couzens35daa672016-11-08 16:17:20 +0100262
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200263 msg->l2h = msg->data;
264
265 /* don't know how to route this message. */
266 if (sign_link == NULL) {
Harald Welte40b0e8c2011-07-21 16:57:34 +0200267 LOGP(DLINP, LOGL_ERROR, "abis_sendmsg: msg->dst == NULL: %s\n",
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200268 osmo_hexdump(msg->data, msg->len));
269 talloc_free(msg);
270 return -EINVAL;
271 }
272 e1i_ts = sign_link->ts;
273 if (!osmo_timer_pending(&e1i_ts->sign.tx_timer)) {
274 /* notify the driver we have something to write */
275 e1inp_driver = sign_link->ts->line->driver;
276 e1inp_driver->want_write(e1i_ts);
277 }
278 msgb_enqueue(&sign_link->tx_list, msg);
279
Harald Welte7f9d8512016-07-04 09:59:46 +0200280 /* we only need to write a 'Fake LAPD' packet here, if the
281 * underlying driver hides LAPD from us. If we use the
282 * libosmocore LAPD implementation, it will take care of writing
283 * the _actual_ LAPD packet */
284 if (!e1i_ts->lapd) {
285 write_pcap_packet(PCAP_OUTPUT, sign_link->sapi,
286 sign_link->tei, msg);
287 }
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200288
289 return 0;
290}
291
Pablo Neira Ayuso96e72632011-06-26 19:08:05 +0200292int abis_rsl_sendmsg(struct msgb *msg)
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200293{
Pablo Neira Ayuso96e72632011-06-26 19:08:05 +0200294 return abis_sendmsg(msg);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200295}
296
297/* Timeslot */
298int e1inp_ts_config_trau(struct e1inp_ts *ts, struct e1inp_line *line,
Pablo Neira Ayuso211d2ca2011-06-07 17:15:10 +0200299 int (*trau_rcv_cb)(struct subch_demux *dmx, int ch,
Harald Welte5226e5b2020-05-07 23:09:16 +0200300 const ubit_t *data, int len, void *_priv))
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200301{
302 if (ts->type == E1INP_TS_TYPE_TRAU && ts->line && line)
303 return 0;
304
305 ts->type = E1INP_TS_TYPE_TRAU;
306 ts->line = line;
307
308 subchan_mux_init(&ts->trau.mux);
Pablo Neira Ayuso211d2ca2011-06-07 17:15:10 +0200309 ts->trau.demux.out_cb = trau_rcv_cb;
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200310 ts->trau.demux.data = ts;
311 subch_demux_init(&ts->trau.demux);
312 return 0;
313}
314
Harald Welteb9031882020-05-02 21:09:15 +0200315void e1inp_ts_name(char *out, size_t out_len, const struct e1inp_ts *ts)
316{
317 if (ts->line->name)
318 snprintf(out, out_len, "%s:%u", ts->line->name, ts->num);
319 else
320 snprintf(out, out_len, "%u:%u", ts->line->num, ts->num);
321}
322
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200323int e1inp_ts_config_sign(struct e1inp_ts *ts, struct e1inp_line *line)
324{
325 if (ts->type == E1INP_TS_TYPE_SIGN && ts->line && line)
326 return 0;
327
328 ts->type = E1INP_TS_TYPE_SIGN;
329 ts->line = line;
330
331 if (line && line->driver)
332 ts->sign.delay = line->driver->default_delay;
333 else
334 ts->sign.delay = 100000;
335 INIT_LLIST_HEAD(&ts->sign.sign_links);
336 return 0;
337}
338
Harald Weltea0108e72016-07-27 21:44:50 +0200339int e1inp_ts_config_raw(struct e1inp_ts *ts, struct e1inp_line *line,
340 void (*raw_recv_cb)(struct e1inp_ts *ts,
341 struct msgb *msg))
342{
343 if (ts->type == E1INP_TS_TYPE_RAW && ts->line && line)
344 return 0;
345
346 ts->type = E1INP_TS_TYPE_RAW;
347 ts->line = line;
348 ts->raw.recv_cb = raw_recv_cb;
349 INIT_LLIST_HEAD(&ts->raw.tx_queue);
350
351 return 0;
352}
353
Harald Welte7a228eb2016-07-28 11:09:31 +0200354int e1inp_ts_config_hdlc(struct e1inp_ts *ts, struct e1inp_line *line,
355 void (*hdlc_recv_cb)(struct e1inp_ts *ts,
356 struct msgb *msg))
357{
358 if (ts->type == E1INP_TS_TYPE_HDLC && ts->line && line)
359 return 0;
360
361 ts->type = E1INP_TS_TYPE_HDLC;
362 ts->line = line;
363 ts->hdlc.recv_cb = hdlc_recv_cb;
364 INIT_LLIST_HEAD(&ts->hdlc.tx_queue);
365
366 return 0;
367}
368
Pablo Neira Ayuso3832c4f2011-07-07 17:47:26 +0200369struct e1inp_line *e1inp_line_find(uint8_t e1_nr)
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200370{
371 struct e1inp_line *e1i_line;
372
373 /* iterate over global list of e1 lines */
374 llist_for_each_entry(e1i_line, &e1inp_line_list, list) {
375 if (e1i_line->num == e1_nr)
376 return e1i_line;
377 }
378 return NULL;
379}
380
381struct e1inp_line *
Pablo Neira Ayusof163d232011-06-25 18:42:55 +0200382e1inp_line_create(uint8_t e1_nr, const char *driver_name)
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200383{
384 struct e1inp_driver *driver;
385 struct e1inp_line *line;
386 int i;
387
Pablo Neira Ayuso3832c4f2011-07-07 17:47:26 +0200388 line = e1inp_line_find(e1_nr);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200389 if (line) {
Harald Welteb5af0992020-01-12 12:59:52 +0100390 LOGPIL(line, DLINP, LOGL_ERROR, "E1 Line %u already exists\n", e1_nr);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200391 return NULL;
392 }
393
394 driver = e1inp_driver_find(driver_name);
395 if (!driver) {
Harald Weltecc2241b2011-07-19 16:06:06 +0200396 LOGP(DLINP, LOGL_ERROR, "No such E1 driver '%s'\n",
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200397 driver_name);
398 return NULL;
399 }
400
401 line = talloc_zero(tall_e1inp_ctx, struct e1inp_line);
402 if (!line)
403 return NULL;
404
405 line->driver = driver;
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200406 line->num = e1_nr;
Harald Weltef2737fc2011-08-16 14:30:10 +0200407
408 line->rate_ctr = rate_ctr_group_alloc(line, &e1inp_ctr_g_d, line->num);
Harald Welteff8eed22017-07-12 00:38:25 +0200409 if (!line->rate_ctr) {
Harald Welteb5af0992020-01-12 12:59:52 +0100410 LOGPIL(line, DLINP, LOGL_ERROR, "Cannot allocate counter group\n");
Harald Welteff8eed22017-07-12 00:38:25 +0200411 talloc_free(line);
412 return NULL;
413 }
Harald Weltef2737fc2011-08-16 14:30:10 +0200414
Harald Weltec2889512011-09-13 23:49:04 +0100415 line->num_ts = NUM_E1_TS;
416 for (i = 0; i < line->num_ts; i++) {
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200417 line->ts[i].num = i+1;
418 line->ts[i].line = line;
419 }
Pablo Neira Ayuso3832c4f2011-07-07 17:47:26 +0200420 line->refcnt++;
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200421 llist_add_tail(&line->list, &e1inp_line_list);
422
423 return line;
424}
425
Pablo Neira Ayuso3832c4f2011-07-07 17:47:26 +0200426struct e1inp_line *
427e1inp_line_clone(void *ctx, struct e1inp_line *line)
428{
429 struct e1inp_line *clone;
430
431 /* clone virtual E1 line for this new OML link. */
432 clone = talloc_zero(ctx, struct e1inp_line);
433 if (clone == NULL)
434 return NULL;
435
436 memcpy(clone, line, sizeof(struct e1inp_line));
Stefan Sperlingb0162072018-05-22 18:19:00 +0200437
438 if (line->name) {
439 clone->name = talloc_strdup(clone, line->name);
440 OSMO_ASSERT(clone->name);
441 }
442 if (line->sock_path) {
443 clone->sock_path = talloc_strdup(clone, line->sock_path);
444 OSMO_ASSERT(clone->sock_path);
445 }
446
447 /*
448 * Rate counters and driver data are shared between clones. These are pointers
449 * to dynamic memory so we use reference counting to avoid a double-free (see OS#3137).
450 */
451 OSMO_ASSERT(line->rate_ctr);
452 clone->rate_ctr = talloc_reference(clone, line->rate_ctr);
453 if (line->driver_data)
454 clone->driver_data = talloc_reference(clone, line->driver_data);
455
Pablo Neira Ayuso3832c4f2011-07-07 17:47:26 +0200456 clone->refcnt = 1;
457 return clone;
458}
459
460void e1inp_line_get(struct e1inp_line *line)
461{
Vadim Yanitskiyb43ce422019-12-02 01:49:43 +0700462 int old_refcnt = line->refcnt++;
463
Harald Welteb5af0992020-01-12 12:59:52 +0100464 LOGPIL(line, DLINP, LOGL_DEBUG, "Line '%s' (%p) reference count get: %d -> %d\n",
Vadim Yanitskiyb43ce422019-12-02 01:49:43 +0700465 line->name, line, old_refcnt, line->refcnt);
Pablo Neira Ayuso3832c4f2011-07-07 17:47:26 +0200466}
467
468void e1inp_line_put(struct e1inp_line *line)
469{
Vadim Yanitskiyb43ce422019-12-02 01:49:43 +0700470 int old_refcnt = line->refcnt--;
471
Harald Welteb5af0992020-01-12 12:59:52 +0100472 LOGPIL(line, DLINP, LOGL_DEBUG, "Line '%s' (%p) reference count put: %d -> %d\n",
Vadim Yanitskiyb43ce422019-12-02 01:49:43 +0700473 line->name, line, old_refcnt, line->refcnt);
474
Stefan Sperlingb0162072018-05-22 18:19:00 +0200475 if (line->refcnt == 0) {
476 /* Remove our counter group from libosmocore's global counter
477 * list if we are freeing the last remaining talloc context.
478 * Otherwise we get a use-after-free when libosmocore's timer
479 * ticks again and attempts to update these counters (OS#3011).
480 *
481 * Note that talloc internally counts "secondary" references
482 * _in addition to_ the initial allocation context, so yes,
483 * we must check for *zero* remaining secondary contexts here. */
484 if (talloc_reference_count(line->rate_ctr) == 0) {
485 rate_ctr_group_free(line->rate_ctr);
486 } else {
487 /* We are not freeing the last talloc context.
488 * Instead of calling talloc_free(), unlink this 'line' pointer
489 * which serves as one of several talloc contexts for the rate
490 * counters and driver private state. */
491 talloc_unlink(line, line->rate_ctr);
492 if (line->driver_data)
493 talloc_unlink(line, line->driver_data);
494 }
Pablo Neira Ayuso3832c4f2011-07-07 17:47:26 +0200495 talloc_free(line);
Stefan Sperlingb0162072018-05-22 18:19:00 +0200496 }
Pablo Neira Ayuso3832c4f2011-07-07 17:47:26 +0200497}
498
Pablo Neira Ayusof163d232011-06-25 18:42:55 +0200499void
500e1inp_line_bind_ops(struct e1inp_line *line, const struct e1inp_line_ops *ops)
501{
502 line->ops = ops;
503}
504
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200505#if 0
Pablo Neira Ayuso3832c4f2011-07-07 17:47:26 +0200506struct e1inp_line *e1inp_line_find_create(uint8_t e1_nr)
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200507{
508 struct e1inp_line *line;
509 int i;
510
Pablo Neira Ayuso3832c4f2011-07-07 17:47:26 +0200511 line = e1inp_line_find(e1_nr);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200512 if (line)
513 return line;
514
515 line = talloc_zero(tall_e1inp_ctx, struct e1inp_line);
516 if (!line)
517 return NULL;
518
519 line->num = e1_nr;
520 for (i = 0; i < NUM_E1_TS; i++) {
521 line->ts[i].num = i+1;
522 line->ts[i].line = line;
523 }
524 llist_add_tail(&line->list, &e1inp_line_list);
525
526 return line;
527}
528#endif
529
530static struct e1inp_ts *e1inp_ts_get(uint8_t e1_nr, uint8_t ts_nr)
531{
532 struct e1inp_line *e1i_line;
533
Pablo Neira Ayuso3832c4f2011-07-07 17:47:26 +0200534 e1i_line = e1inp_line_find(e1_nr);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200535 if (!e1i_line)
536 return NULL;
537
538 return &e1i_line->ts[ts_nr-1];
539}
540
541struct subch_mux *e1inp_get_mux(uint8_t e1_nr, uint8_t ts_nr)
542{
543 struct e1inp_ts *e1i_ts = e1inp_ts_get(e1_nr, ts_nr);
544
545 if (!e1i_ts)
546 return NULL;
547
548 return &e1i_ts->trau.mux;
549}
550
551/* Signalling Link */
552
553struct e1inp_sign_link *e1inp_lookup_sign_link(struct e1inp_ts *e1i,
554 uint8_t tei, uint8_t sapi)
555{
556 struct e1inp_sign_link *link;
557
558 llist_for_each_entry(link, &e1i->sign.sign_links, list) {
559 if (link->sapi == sapi && link->tei == tei)
560 return link;
561 }
562
563 return NULL;
564}
565
566/* create a new signalling link in a E1 timeslot */
567
568struct e1inp_sign_link *
569e1inp_sign_link_create(struct e1inp_ts *ts, enum e1inp_sign_type type,
570 struct gsm_bts_trx *trx, uint8_t tei,
571 uint8_t sapi)
572{
573 struct e1inp_sign_link *link;
574
575 if (ts->type != E1INP_TS_TYPE_SIGN)
576 return NULL;
577
578 link = talloc_zero(tall_sigl_ctx, struct e1inp_sign_link);
579 if (!link)
580 return NULL;
581
582 link->ts = ts;
583 link->type = type;
584 INIT_LLIST_HEAD(&link->tx_list);
585 link->trx = trx;
586 link->tei = tei;
587 link->sapi = sapi;
588
Pau Espin Pedrol89c6b8a2020-06-08 20:26:44 +0200589 e1inp_line_get(link->ts->line);
590
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200591 llist_add_tail(&link->list, &ts->sign.sign_links);
592
593 return link;
594}
595
596void e1inp_sign_link_destroy(struct e1inp_sign_link *link)
597{
598 struct msgb *msg;
599
600 llist_del(&link->list);
601 while (!llist_empty(&link->tx_list)) {
602 msg = msgb_dequeue(&link->tx_list);
603 msgb_free(msg);
604 }
605
606 if (link->ts->type == E1INP_TS_TYPE_SIGN)
607 osmo_timer_del(&link->ts->sign.tx_timer);
608
Pablo Neira Ayusoc9c4fd32011-06-30 12:19:42 +0200609 if (link->ts->line->driver->close)
Pablo Neira Ayusoadd3ec82011-07-05 14:45:46 +0200610 link->ts->line->driver->close(link);
Pablo Neira Ayusoc9c4fd32011-06-30 12:19:42 +0200611
Pablo Neira Ayuso6cc3f922012-08-22 13:57:58 +0200612 e1inp_line_put(link->ts->line);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200613 talloc_free(link);
614}
615
616/* XXX */
617/* the E1 driver tells us he has received something on a TS */
618int e1inp_rx_ts(struct e1inp_ts *ts, struct msgb *msg,
619 uint8_t tei, uint8_t sapi)
620{
621 struct e1inp_sign_link *link;
622 int ret = 0;
623
624 switch (ts->type) {
625 case E1INP_TS_TYPE_SIGN:
Harald Welte7f9d8512016-07-04 09:59:46 +0200626 /* we only need to write a 'Fake LAPD' packet here, if
627 * the underlying driver hides LAPD from us. If we use
628 * the libosmocore LAPD implementation, it will take
629 * care of writing the _actual_ LAPD packet */
630 if (!ts->lapd)
631 write_pcap_packet(PCAP_INPUT, sapi, tei, msg);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200632 /* consult the list of signalling links */
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200633 link = e1inp_lookup_sign_link(ts, tei, sapi);
634 if (!link) {
Harald Welteb5af0992020-01-12 12:59:52 +0100635 LOGPITS(ts, DLMI, LOGL_ERROR, "didn't find signalling link for "
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200636 "tei %d, sapi %d\n", tei, sapi);
Andreas Eversberga7ff0012011-09-26 11:29:30 +0200637 msgb_free(msg);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200638 return -EINVAL;
639 }
Pablo Neira Ayusof163d232011-06-25 18:42:55 +0200640 if (!ts->line->ops->sign_link) {
Harald Welteb5af0992020-01-12 12:59:52 +0100641 LOGPITS(ts, DLINP, LOGL_ERROR, "Fix your application, "
Pablo Neira Ayuso5a4b7c52011-06-07 14:07:48 +0200642 "no action set for signalling messages.\n");
Andreas Eversberga7ff0012011-09-26 11:29:30 +0200643 msgb_free(msg);
Pablo Neira Ayuso5a4b7c52011-06-07 14:07:48 +0200644 return -ENOENT;
645 }
Pablo Neira Ayusodbd82fb2011-07-05 15:29:23 +0200646 msg->dst = link;
647 ts->line->ops->sign_link(msg);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200648 break;
649 case E1INP_TS_TYPE_TRAU:
Pablo Neira Ayuso211d2ca2011-06-07 17:15:10 +0200650 ret = subch_demux_in(&ts->trau.demux, msg->l2h, msgb_l2len(msg));
Andreas Eversberga7ff0012011-09-26 11:29:30 +0200651 msgb_free(msg);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200652 break;
Harald Weltea0108e72016-07-27 21:44:50 +0200653 case E1INP_TS_TYPE_RAW:
654 ts->raw.recv_cb(ts, msg);
655 break;
Harald Welte7a228eb2016-07-28 11:09:31 +0200656 case E1INP_TS_TYPE_HDLC:
657 ts->hdlc.recv_cb(ts, msg);
658 break;
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200659 default:
660 ret = -EINVAL;
Harald Welteb5af0992020-01-12 12:59:52 +0100661 LOGPITS(ts, DLMI, LOGL_ERROR, "unknown TS type %u\n", ts->type);
Andreas Eversberga7ff0012011-09-26 11:29:30 +0200662 msgb_free(msg);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200663 break;
664 }
665
666 return ret;
667}
668
Harald Weltefd44a5f2011-08-21 00:48:54 +0200669/*! \brief Receive some data from the L1/HDLC into LAPD of a timeslot
670 * \param[in] e1i_ts E1 Timeslot data structure
671 * \param[in] msg Message buffer containing full LAPD message
672 *
673 * This is a wrapper around e1inp_rx_ts(), but feeding the incoming
674 * message first into our LAPD code. This allows a driver to read raw
675 * (HDLC decoded) data from the timeslot, instead of a LAPD stack
676 * present in any underlying driver.
677 */
678int e1inp_rx_ts_lapd(struct e1inp_ts *e1i_ts, struct msgb *msg)
679{
Harald Weltefd44a5f2011-08-21 00:48:54 +0200680 unsigned int sapi, tei;
Andreas Eversberga7ff0012011-09-26 11:29:30 +0200681 int ret = 0, error = 0;
Harald Weltefd44a5f2011-08-21 00:48:54 +0200682
683 sapi = msg->data[0] >> 2;
Andreas Eversberga7ff0012011-09-26 11:29:30 +0200684 if ((msg->data[0] & 0x1))
685 tei = 0;
686 else
687 tei = msg->data[1] >> 1;
Harald Weltefd44a5f2011-08-21 00:48:54 +0200688
Harald Welteb5af0992020-01-12 12:59:52 +0100689 LOGPITS(e1i_ts, DLMI, LOGL_DEBUG, "<= len = %d, sapi(%d) tei(%d)\n", msg->len, sapi, tei);
Harald Weltefd44a5f2011-08-21 00:48:54 +0200690
Andreas Eversberga7ff0012011-09-26 11:29:30 +0200691 ret = lapd_receive(e1i_ts->lapd, msg, &error);
692 if (ret < 0) {
Harald Weltefd44a5f2011-08-21 00:48:54 +0200693 switch(error) {
694 case LAPD_ERR_UNKNOWN_TEI:
695 /* We don't know about this TEI, probably the BSC
696 * lost local states (it crashed or it was stopped),
697 * notify the driver to see if it can do anything to
698 * recover the existing signalling links with the BTS.
699 */
700 e1inp_event(e1i_ts, S_L_INP_TEI_UNKNOWN, tei, sapi);
701 return -EIO;
702 }
Harald Weltefd44a5f2011-08-21 00:48:54 +0200703 }
704
Andreas Eversberga7ff0012011-09-26 11:29:30 +0200705 return 0;
706}
Harald Weltefd44a5f2011-08-21 00:48:54 +0200707
Andreas Eversberga7ff0012011-09-26 11:29:30 +0200708void e1inp_dlsap_up(struct osmo_dlsap_prim *dp, uint8_t tei, uint8_t sapi,
709 void *rx_cbdata)
710{
711 struct e1inp_ts *e1i_ts = rx_cbdata;
712 struct msgb *msg = dp->oph.msg;
Harald Weltefd44a5f2011-08-21 00:48:54 +0200713
Andreas Eversberga7ff0012011-09-26 11:29:30 +0200714 switch (dp->oph.primitive) {
715 case PRIM_DL_EST:
Harald Welteb5af0992020-01-12 12:59:52 +0100716 LOGPITS(e1i_ts, DLMI, LOGL_DEBUG, "DL_EST: sapi(%d) tei(%d)\n", sapi, tei);
Andreas Eversberga7ff0012011-09-26 11:29:30 +0200717 e1inp_event(e1i_ts, S_L_INP_TEI_UP, tei, sapi);
Harald Weltefd44a5f2011-08-21 00:48:54 +0200718 break;
Andreas Eversberga7ff0012011-09-26 11:29:30 +0200719 case PRIM_DL_REL:
Harald Welteb5af0992020-01-12 12:59:52 +0100720 LOGPITS(e1i_ts, DLMI, LOGL_DEBUG, "DL_REL: sapi(%d) tei(%d)\n", sapi, tei);
Andreas Eversberga7ff0012011-09-26 11:29:30 +0200721 e1inp_event(e1i_ts, S_L_INP_TEI_DN, tei, sapi);
Harald Weltefd44a5f2011-08-21 00:48:54 +0200722 break;
Andreas Eversberga7ff0012011-09-26 11:29:30 +0200723 case PRIM_DL_DATA:
724 case PRIM_DL_UNIT_DATA:
725 if (dp->oph.operation == PRIM_OP_INDICATION) {
726 msg->l2h = msg->l3h;
Harald Welteb5af0992020-01-12 12:59:52 +0100727 LOGPITS(e1i_ts, DLMI, LOGL_DEBUG, "RX: %s sapi=%d tei=%d\n",
Andreas Eversberga7ff0012011-09-26 11:29:30 +0200728 osmo_hexdump(msgb_l2(msg), msgb_l2len(msg)),
729 sapi, tei);
730 e1inp_rx_ts(e1i_ts, msg, tei, sapi);
731 return;
732 }
Harald Weltefd44a5f2011-08-21 00:48:54 +0200733 break;
Andreas Eversberga7ff0012011-09-26 11:29:30 +0200734 case PRIM_MDL_ERROR:
Harald Welteb5af0992020-01-12 12:59:52 +0100735 LOGPITS(e1i_ts, DLMI, LOGL_DEBUG, "MDL_EERROR: cause(%d)\n", dp->u.error_ind.cause);
Harald Weltefd44a5f2011-08-21 00:48:54 +0200736 break;
737 default:
738 printf("ERROR: unknown prim\n");
739 break;
740 }
Andreas Eversberga7ff0012011-09-26 11:29:30 +0200741
742 msgb_free(msg);
743
744 return;
Harald Weltefd44a5f2011-08-21 00:48:54 +0200745}
746
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200747#define TSX_ALLOC_SIZE 4096
748
749/* called by driver if it wants to transmit on a given TS */
750struct msgb *e1inp_tx_ts(struct e1inp_ts *e1i_ts,
751 struct e1inp_sign_link **sign_link)
752{
753 struct e1inp_sign_link *link;
754 struct msgb *msg = NULL;
755 int len;
756
757 switch (e1i_ts->type) {
758 case E1INP_TS_TYPE_SIGN:
759 /* FIXME: implement this round robin */
760 llist_for_each_entry(link, &e1i_ts->sign.sign_links, list) {
761 msg = msgb_dequeue(&link->tx_list);
762 if (msg) {
763 if (sign_link)
764 *sign_link = link;
765 break;
766 }
767 }
768 break;
769 case E1INP_TS_TYPE_TRAU:
770 msg = msgb_alloc(TSX_ALLOC_SIZE, "TRAU_TX");
771 if (!msg)
772 return NULL;
773 len = subchan_mux_out(&e1i_ts->trau.mux, msg->data, 40);
Pablo Neira Ayuso33f71752013-07-05 15:44:12 +0200774 if (len != 40) {
Harald Welteb5af0992020-01-12 12:59:52 +0100775 LOGPITS(e1i_ts, DLMI, LOGL_ERROR, "cannot transmit, failed to mux\n");
Pablo Neira Ayuso33f71752013-07-05 15:44:12 +0200776 msgb_free(msg);
777 return NULL;
778 }
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200779 msgb_put(msg, 40);
780 break;
Harald Weltea0108e72016-07-27 21:44:50 +0200781 case E1INP_TS_TYPE_RAW:
782 /* Get msgb from tx_queue */
783 msg = msgb_dequeue(&e1i_ts->raw.tx_queue);
784 break;
Harald Welte7a228eb2016-07-28 11:09:31 +0200785 case E1INP_TS_TYPE_HDLC:
786 /* Get msgb from tx_queue */
787 msg = msgb_dequeue(&e1i_ts->hdlc.tx_queue);
788 break;
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200789 default:
Harald Welteb5af0992020-01-12 12:59:52 +0100790 LOGPITS(e1i_ts, DLMI, LOGL_ERROR, "unsupported E1 TS type %u\n", e1i_ts->type);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200791 return NULL;
792 }
793 return msg;
794}
795
Holger Hans Peter Freyther55467f02011-12-28 19:47:07 +0100796static int e1inp_int_snd_event(struct e1inp_ts *ts,
797 struct e1inp_sign_link *link, int evt)
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200798{
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200799 struct input_signal_data isd;
Pablo Neira Ayuso31fe5f22011-08-09 23:15:38 +0200800 isd.line = ts->line;
Harald Weltef35d8892016-10-16 15:33:52 +0200801 isd.ts_nr = ts->num;
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200802 isd.link_type = link->type;
803 isd.trx = link->trx;
Holger Hans Peter Freyther55467f02011-12-28 19:47:07 +0100804 isd.tei = link->tei;
805 isd.sapi = link->sapi;
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200806
807 /* report further upwards */
Harald Weltecc2241b2011-07-19 16:06:06 +0200808 osmo_signal_dispatch(SS_L_INPUT, evt, &isd);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200809 return 0;
810}
811
Holger Hans Peter Freyther55467f02011-12-28 19:47:07 +0100812
813/* called by driver in case some kind of link state event */
814int e1inp_event(struct e1inp_ts *ts, int evt, uint8_t tei, uint8_t sapi)
815{
816 struct e1inp_sign_link *link;
817
818 link = e1inp_lookup_sign_link(ts, tei, sapi);
819 if (!link)
820 return -EINVAL;
821 return e1inp_int_snd_event(ts, link, evt);
822}
823
824void e1inp_close_socket(struct e1inp_ts *ts,
825 struct e1inp_sign_link *sign_link,
826 struct osmo_fd *bfd)
827{
828 e1inp_int_snd_event(ts, sign_link, S_L_INP_TEI_DN);
829 /* the first e1inp_sign_link_destroy call closes the socket. */
830 if (bfd->fd != -1) {
831 osmo_fd_unregister(bfd);
832 close(bfd->fd);
833 bfd->fd = -1;
834 }
835}
836
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200837/* register a driver with the E1 core */
838int e1inp_driver_register(struct e1inp_driver *drv)
839{
840 llist_add_tail(&drv->list, &e1inp_driver_list);
841 return 0;
842}
843
844struct e1inp_driver *e1inp_driver_find(const char *name)
845{
846 struct e1inp_driver *drv;
847
848 llist_for_each_entry(drv, &e1inp_driver_list, list) {
849 if (!strcasecmp(name, drv->name))
850 return drv;
851 }
852 return NULL;
853}
854
Pablo Neira Ayusof163d232011-06-25 18:42:55 +0200855int e1inp_line_update(struct e1inp_line *line)
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200856{
857 struct input_signal_data isd;
Harald Welte7f9d8512016-07-04 09:59:46 +0200858 int i, rc;
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200859
Pablo Neira Ayusof163d232011-06-25 18:42:55 +0200860 if (line->driver && line->ops && line->driver->line_update) {
Pablo Neira Ayuso4e862cb2011-08-19 18:43:38 +0200861 rc = line->driver->line_update(line);
Pablo Neira Ayusof163d232011-06-25 18:42:55 +0200862 } else
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200863 rc = 0;
864
Harald Welte7f9d8512016-07-04 09:59:46 +0200865 /* Set the PCAP file descriptor for all timeslots that have
866 * software LAPD instances, to ensure the osmo_lapd_pcap code is
867 * used to write PCAP files (if requested) */
868 for (i = 0; i < ARRAY_SIZE(line->ts); i++) {
869 struct e1inp_ts *e1i_ts = &line->ts[i];
870 if (e1i_ts->lapd)
871 e1i_ts->lapd->pcap_fd = pcap_fd;
872 }
873
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200874 /* Send a signal to anyone who is interested in new lines being
875 * configured */
876 memset(&isd, 0, sizeof(isd));
877 isd.line = line;
Pablo Neira Ayusode668912011-08-16 17:26:23 +0200878 osmo_signal_dispatch(SS_L_INPUT, S_L_INP_LINE_INIT, &isd);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200879
880 return rc;
881}
882
Pablo Neira Ayusoa20762a2011-07-02 19:01:58 +0200883static int e1i_sig_cb(unsigned int subsys, unsigned int signal,
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200884 void *handler_data, void *signal_data)
885{
Harald Weltecc2241b2011-07-19 16:06:06 +0200886 if (subsys != SS_L_GLOBAL ||
887 signal != S_L_GLOBAL_SHUTDOWN)
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200888 return 0;
889
890 if (pcap_fd) {
891 close(pcap_fd);
892 pcap_fd = -1;
893 }
894
895 return 0;
896}
897
Harald Weltecac78fe2017-05-25 19:13:13 +0200898const struct value_string e1inp_signal_names[] = {
899 { S_L_INP_NONE, "NONE" },
900 { S_L_INP_TEI_UP, "TEI-UP" },
901 { S_L_INP_TEI_DN, "TEI-DOWN" },
902 { S_L_INP_TEI_UNKNOWN, "TEI-UNKNOWN" },
903 { S_L_INP_LINE_INIT, "LINE-INIT" },
904 { S_L_INP_LINE_ALARM, "LINE-ALARM" },
905 { S_L_INP_LINE_NOALARM, "LINE-NOALARM" },
906 { 0, NULL }
907};
908
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200909void e1inp_misdn_init(void);
910void e1inp_dahdi_init(void);
Harald Weltec6c70762019-05-12 21:54:59 +0200911void e1inp_e1d_init(void);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200912void e1inp_ipaccess_init(void);
Pablo Neira Ayuso7e0d0062011-08-19 11:36:15 +0200913void e1inp_rs232_init(void);
Alexander Couzensbeb10ef2016-11-01 22:05:13 +0100914void e1inp_unixsocket_init(void);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200915
916void e1inp_init(void)
917{
Pablo Neira Ayuso54b49792011-06-07 12:15:26 +0200918 tall_e1inp_ctx = talloc_named_const(libosmo_abis_ctx, 1, "e1inp");
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200919 tall_sigl_ctx = talloc_named_const(tall_e1inp_ctx, 1,
920 "e1inp_sign_link");
Harald Weltecc2241b2011-07-19 16:06:06 +0200921 osmo_signal_register_handler(SS_L_GLOBAL, e1i_sig_cb, NULL);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200922
923 e1inp_misdn_init();
Harald Welte3bc78852011-08-24 08:32:38 +0200924#ifdef HAVE_DAHDI_USER_H
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200925 e1inp_dahdi_init();
Harald Welte3bc78852011-08-24 08:32:38 +0200926#endif
Harald Welte52b0d452019-05-12 21:54:26 +0200927#ifdef HAVE_E1D
Sylvain Munautb559a532019-05-09 11:14:26 +0200928 e1inp_e1d_init();
929#endif
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200930 e1inp_ipaccess_init();
Pablo Neira Ayuso7e0d0062011-08-19 11:36:15 +0200931 e1inp_rs232_init();
Alexander Couzensbeb10ef2016-11-01 22:05:13 +0100932 e1inp_unixsocket_init();
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200933}