Commit Graph

75 Commits

Author SHA1 Message Date
Andreas Eversberg 9a151091cc Add function to set Sa bits to common part
Change-Id: I4f5f975f0e5f708ae573a1e1ce41c6a08c207fad
2023-02-18 10:39:31 +01:00
Philipp Maier cc42444539 e1_input: add timeslot type NONE
Allow to configure a timeslot as type E1INP_TS_TYPE_NONE. The timeslot
is then put back in its unconfigured state

Change-Id: I073cfaba0d5073447842f22665e213135ea3f635
Related: OS#5198
2023-02-14 09:32:02 +01:00
Andreas Eversberg eb4030f152 Add more L1 signals to common part
Change-Id: I295dc340d3d3a7cbb5aba5afe807746acbcde33f
2023-02-13 22:15:17 +00:00
Andreas Eversberg 917454dd9c Add missing functions to send HDLC/RAW data
Change-Id: Iebcb99f491b945d364b1044a59638524637dd8b2
2023-01-15 19:01:00 +01:00
Daniel Willmann c20af05bfc ipaccess: Add connect timeout in e1inp_line
* VTY command e1_line N connect-timeout T to set the connect() timeout
* use ipa_client_conn_open2 to connect with timeout

Related: SYS#6237
Change-Id: I7379102d19c172bed2aa00377d92bc885f54b640
2022-12-15 16:10:36 +01:00
Oliver Smith ef0f7c25f0 e1_input: enable tcp keepalive by default
Set the keepalive parameters to E1INP_USE_DEFAULT initially instead
of 0. Do this independent of the driver (the only driver making use of
this is ipaccess).

Closes: OS#5785
Change-Id: Ia7659c209aea0d26eb37d31e771adc91b17ae668
2022-11-23 12:34:00 +01:00
Pau Espin 57ff57ac5c e1inp_input: Fix e1inp_line_clone removing original line from global list when freed
Since a recent commit (see hash below), e1_input.c code was fixed to
release the line from the global line list (e1inp_line_list) before
freeing the object. However, the change didn't have into account that
there were cloned lines from the original one which had a duplicate of
the original line->list. Hence, whenver a clone was freed, it actually
removed the original line from the global list.

Since the original line is the one actually holding the permanent
reference due to being configured over VTY, let's fix e1inp_line_clone
to reset the clone->list so that whenever it is freed it doesn't affect
the original line.

Fixes: 49924f0a79
Related: SYS#5642
Change-Id: I0627da0d28057649b494e2bd83b283b09fb9a2d7
2021-10-13 16:38:02 +02:00
Pau Espin dd48e257ab e1_input: Document e1inp_line_create()
Specially important regarding the pre-allocated reference count.
This was done when moving the API to use osmo_use_count internally,
because previous code already came with refcount=1.

Change-Id: I819a13732c5d0ff150bc11d1cfd64e96ee81bad2
2021-09-22 19:37:56 +02:00
Pau Espin 49924f0a79 e1_input: Fix line not removed from e1inp_line_list when freed
This was not an observable issue so far because both osmo-bts and
osmo-bsc used to keep the same line created once, keeping at least 1
reference count to it.

Change-Id: I1314d6b917ecb622994507475eb894e649a1a2ad
2021-09-22 19:32:15 +02:00
Keith Whyte 2672a2a2a7 Configure E1 pcap file per line
In order to allow configuration of pcap files per e1_line
the vty command is now (for example line 0):

  e1_line 0 pcap /tmp/e1cap.pcap

in place of:

  pcap /tmp/e1cap.pcap

Also ensures that a configured pcap appears in 'show running-config'
and is written to the config file on issuing 'write'

This commit deprecates e1_set_pcap_fd()

Change-Id: I316c3d6a839e84c2f52a148c6b8dd6f5933cf4bf
2021-04-13 23:28:02 +02:00
Harald Welte b3952c60f1 e1_input: Support I.460 timeslot type
Unlike the legacy TRAU mode, this only adds I460 mux/demux,
without any TRAU frame synchronization.  The user must still be
adding the actual sub-channels using osmo_i460_subchan_add()
depending on his requirements.

Change-Id: I44da6dfec77ef475adb35001a0e4fa11d549aa02
2021-02-03 08:49:07 +00:00
Pau Espin 8737ad4f75 ipacces: Fix e1inp_line reference put in ipaccess_close
Drop the function e1inp_close_socket since it's only used by the caller
at hand, and it's only exported through "internal.h", so no app is using
it. Remove it because there's only a caller, and furthermore because
keeping it (and putting bfd->data==line) would introduce a layer
violation because the bfd->data==line is only used for ipaccess so far.

Triggering path:
handle_ts1_read ret=0 "Sign link vanished"
  ipaccess_drop
line->ops->sign_link_down
  (osmo-bsc) ipaccess_drop_oml
e1inp_sign_link_destroy
  link->ts->line->driver->close
ipaccess_close

Related: OS#4624
Change-Id: If23cc722106a9f70c998e591369a4acafa52c519
2020-07-15 15:39:33 +02:00
Pau Espin 5196cd5641 e1_input: Use osmo_use_count in e1inp_line
osmo_use_count is available since libosmocore 1.1.0 release, so bump
required libosmocore version in autotools and packages.

struct e1inp_line field refcnt is kept in order to keep ABI
compatibility accessing struct fields. The new use_count is added at the
end. Size of struct changing is fine since it is allocated through
an API and a pointer should be used by clients.

e1inp_line_clone API is changed but it's not used by anyone outside
libosmo-abis, so it's fine.

Related: OS#4624
Change-Id: I0658b2e9c452598025cc0f1d0b060076171767cc
2020-07-15 15:39:33 +02:00
Pau Espin 89c6b8a42e e1_input: refcount inc line during e1_sign_link_create, not during line update
Increase reference count when a new sign_link using the line is created.
Otherwise the line is freed too quickly during e1inp_sign_link_destroy()
with several TRX being used, since each RSL link is missing a reference.

That extra refcoutny in update() is not really needed given that we already
have a link assigned on the line when we call update.

Fixes: OS#3612
Fixes: OS#4094

Change-Id: I74405b0e87a89c17d58e87024f4aedbd30832013
2020-06-09 07:36:21 +00:00
Harald Welte b90318808b lapd: Always print context information when logging
Historically, OpenBSC has primarily been used with setups that have
a single E1 based BTS connected. This meant that an error message on
the E1 LAPD implicitly has to be related to that single BTS.

However, in more comprehensive setups, there may be many BTSs on many
E1 lines with many signaling slots.  At this point, it's important to
know which line/timeslot/tei/sapi a given log message relates to.

This patch introduces related log context.

Change-Id: Ib81a749ae24013b17caaf5fd64ccd9acbbc3ce08
Requires: libosmocore.git Change-Id Ie6742843fff809edffcac24c4dce4edf66bc71be
Related: OS#1938
2020-06-09 07:11:42 +00:00
Harald Welte 5226e5b926 subchan_demux: Use 'ubit_t' for unpacked bit buffer; use const
Change-Id: Ia082b9fddf03d02afd007825a1588a3ef0dbedae
2020-05-10 19:11:44 +02:00
Sylvain Munaut 4b45e9d1a6 e1_input: Allow to change the pcap fd and/or unset it
This will update the pcap fd in all open lines and close
the previous one (if applicable).

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I5c7dd740ba0a90b40c69a53b3dcc9d6d6a98f660
2020-05-08 18:10:15 +02:00
Harald Welte c6c70766b3 e1d: add missing forward-declaration of e1inp_e1d_init()
Change-Id: I0060e2c9772eb5c0293712cb0da7cc0477eb8abd
2020-01-12 14:24:20 +01:00
Harald Welte 52b0d45b8a e1d: Use HAVE_E1D in C source, not ENABLE_E1D
The config.h files contains HAVE_E1D.

Change-Id: Ib7d2db6703300b7d537c78ad9285948673d8b1d3
2020-01-12 14:24:15 +01:00
Sylvain Munaut b559a53263 e1d: Initial osmo-e1d support
osmo-e1d is part of the Osmocom 'software defined E1 interface,
which consists of a USB device for the actual E1 hardware interfacing,
and a daemon (osmo-e1d) implementing a libusb-based driver.

This commit adds initial support for talking to osmo-e1d using
the related libosmoe1d library.  You need to use '--enable-e1d'
at configure time to enable it.

Change-Id: Ia0431c124e3b5b4108aee7b109d8c4bb0d8b45d4
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2020-01-12 14:22:18 +01:00
Harald Welte b5af0991b3 introduce and use logging macros with context on E1 line / timeslot
Change-Id: I447a2360757fed97ed50f9db1e2efbf2f90e46a0
2020-01-12 13:31:35 +01:00
Neels Hofmeyr a160e4bfdb add/clean big-endian packed structs (struct_endianess.py)
Change-Id: I09c56f59631828ad219a5edd7d95cac8df462c84
2020-01-07 17:49:51 +01:00
Vadim Yanitskiy b43ce42411 e1_input.c: make reference counting get() / put() more verbose
Change-Id: I1c730d6d146b365712b28e3d37e038344ea850bc
2019-12-02 02:45:00 +07:00
Pau Espin a210684433 e1_input.c: Replace '.' in counter names with ':'
The '.' is illegal character in counter names, as they are exported
via CTRL interface, where '.' has a special meaning that cannot be
used by strings comprising the variable name.

Change-Id: I730d1acdd5562cd2c1758ceee31193010b14337d
2018-07-24 15:00:15 +02:00
Stefan Sperling b0162077da fix double-free/use-after-free of pointers in struct e1inp_line
Ensure that pointers in cloned e1inp_lines point to valid memory.
Some members of struct e1inp_line can simply be deep-copied.
Use talloc reference counting for pointers to objects which may
be shared between clones (driver-private state and counters).
Prevents double-free bugs, e.g. when multiple links referring
to the same line are closed.

Also, do not forget to unlink struct e1inp_line's counter group from
the counter list. Fixes use-after-free in rate_ctr_timer_cb() during
osmo-bts shutdown.

Change-Id: I9f4724b4a5a064801591e9acf4f2fd1db006d082
Related: OS#3011
Related: OS#3137
2018-05-24 14:57:36 +02:00
Harald Welte 323d39d784 Add SPDX-License-Identifier to all source files
Change-Id: I9f2bc8c5d8a2c0bb0dd6caa4de5e2cb11be210e7
2017-11-13 01:09:21 +09:00
Harald Welte ff8eed24e7 check for missing result of rate_ctr_group_alloc()
In case the counter group allocation fails, we must handle this
gracefully and fail the allocation of the parent object, too.

Change-Id: Iff8506832d3472ab193b19b43cfbe7a9511075d1
Related: OS#2361
2017-07-12 00:38:25 +02:00
Harald Welte cac78fe9e9 Add value_string for input signal names (e1inp_signal_names)
Change-Id: I1662d4a969d2d12677646f3120b25be9a20c6d22
2017-05-25 19:13:13 +02:00
Alexander Couzens beb10ef02a add basic unixsocket support
Allow to connect to a unix socket for communicating with LAPD.

Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a
2017-03-08 10:14:05 +00:00
Holger Hans Peter Freyther 254745880b misc: Fix build failure/warning when building on alpine linux
alpine linux is using the musl libc and this triggered some minor
compilation issues. Remove unused mISDN include and defines from
the general E1 input handling and address the other warnings and
errors.

/usr/include/sys/fcntl.h:1:2: warning: #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h> [-Wcpp]
 #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h>
  ^~~~~~~

In file included from input/misdn.c:48:0:
../include/mISDNif.h:286:2: error: unknown type name 'u_int'
  u_int   id;
  ^~~~~

Change-Id: I997e45a456faedb5f370fd02ded300c1e36b791b
2017-01-23 19:49:07 +01:00
Alexander Couzens 35daa67763 e1_input: remove superflous semi colon
Change-Id: I7e9079cbac1d9920da2aace35810682b49ec532f
2016-11-16 10:08:02 +00:00
Harald Welte 7a228ebc60 Add HDLC timeslot mode
This is useful for protocols that use HDLC framing for signalling on E1
timeslots, but which don't use LAPD inside (our E1INP_TS_TYPE_SIGN).

Examples are particularly a MTP2/MTP3 SS7 stack, like it is used on the
A interfaces or on the core network interfaces of classic
circuit-switched networks.

Change-Id: I2d75801df4d7cbb8dad325f4d6689841f0196fa6
2016-10-17 22:15:55 +02:00
Harald Welte a0108e78a9 Implement new 'raw' input type for E1 timeslots
In the past, the A-bis E1 input system only unederstood LAPD signalling
time-slots and trau-slots with 16kBps sub-slots.  This adds the notion
of a 'raw' transparent 64kBps slot, without any furthe de-multiplexing
nor any HLDC inside.

Change-Id: I0c25c2688eddd0c55c15b280a8c6e8a49629516b
2016-10-17 22:14:19 +02:00
Harald Welte 4ca5c53f7f Convert e1inp_{sign,ts}type_name() to use struct value_string
Change-Id: I0546c3f5aefe5e1cc33d8d82f1783fa467e37ff0
2016-10-16 22:14:08 +00:00
Harald Welte f35d8898ab e1_input: Add E1 timeslot number to input_signal_data
It is quite useful for the signal receiver to know on which of the many
E1/T1 timeslots a given event (like a 'link down' event) has happened.
The line number, TEI and SAPI are isnuficcient in case there are
multiple signalling TS in the line.

Change-Id: I07f0f79e0cda09766f357032ffb4e7ad643d448a
2016-10-16 22:13:46 +00:00
Harald Welte 7f9d851d9f e1_input: Use osmo_pcap_lapd if using software LAPD
The e1_input code for PCAP writing uses the Layer3 RSL/OML message and
prepends a fake LAPD header.  This means that all frames look like UI
frames in wireshark.  In case we use in-kernel LAPD of mISDN, this is
the best we can do.  However, in case of software (libosmocore) LAPD,
we can do better, by dumping the real LAPD frames at the interface
between LAPD code and the physical layer.

Related: OS#1763
Change-Id: Id0815690b5bc0a9b7f29f5cfde9d2f24c4f88ee5
2016-07-04 10:30:01 +02:00
Harald Welte c9295ea2dd fix compiler warning in write_pcap_packet()
if we don't evaluate the result of write(), there's no point in
storing the result in a variable.
2014-08-21 02:41:41 +02:00
Harald Welte 46fc7e2df7 ipa: Add E1INP_SIGN_OSMO to use IPAC_PROTO_OSMO via e1_input
In order to make use of the IPAC_PROTO_OSMO stream_id of the IPA
multiplex via the e1_input abstraction layer, we need to define
E1INP_SIGN_OSMO and treat it like other signalling (OML/RSL).

This is required for the upcoming code that uses IPAC_PROTO_OSMO
to remotely insert routing table entries into the OML router (e.g. from
osmo-bts).
2014-08-18 20:51:03 +02:00
Pablo Neira Ayuso 33f7175764 e1_input: fix compilation warning in e1inp_tx_ts
e1_input.c: In function 'e1inp_tx_ts':
e1_input.c:620:6: warning: variable 'len' set but not used [-Wunused-but-set-variable]

Fix it by performing a stricter checking on the muxed bits
before transmission. Let's see if this spots some hidden bug
in this code.
2013-07-08 01:22:57 +02:00
Pablo Neira Ayuso 2e11f5c7dc e1_input: fix compilation warning in e1_set_pcap_fd
CC     e1_input.lo
e1_input.c: In function 'e1_set_pcap_fd':
e1_input.c:143:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]

e1_set_pcap_fd returns now the result of write. OpenBSC is still
assuming that this function returns nothing, so it simply ignores
this return value by now.
2013-07-05 15:18:52 +02:00
Holger Hans Peter Freyther 9d4fe51424 hsl: Remove the input handling for the HSL BTS
I have removed HSL support from OpenBSC, the E1/Abis code is now
unused and can be removed.

Fixes: Coverity CID 1040693
2013-07-04 19:50:09 +02:00
Pablo Neira Ayuso 6cc3f92ea4 ipaccess: fix leak of e1inp_line
Holger reported a leak in the ipaccess_drop path and a patch to
fix this. This is a new version of the patch posted that also
handle the case in which only one of the link (OML / RSL) is
established and no ID_RESP was received.

Based on patch of Holger Freyther.
2012-08-30 21:50:30 +02:00
Holger Hans Peter Freyther 55467f0478 abis/close: Deliver S_L_INP_TEI_DN when closing the socket
* HSL/IPA had different socket closing code for the same thing,
  create one method for it.
* Both methods tried to send an event but as we are on the close
  path the sign_link was already removed from the list and the
  input event sending method couldn't find the sign_link using the
  sapi/tei provided.
2011-12-28 19:47:07 +01:00
Andreas Eversberg a7ff0019b3 Replaced LAPD implementation with new LAPD core of libosmogsm
The core functionality of input/lapd.c is removed. Now it uses lapd_core.c
of libosmogsm. The stucture of lapd_instance and SAP (SAPI/TEI handling)
is kept, as well as interfaceing and header transcoding. The former
implementation of datalink is completely replaced, except for the minimal
TEI manager..

Currently it supports 3 modes:
- ABIS (BS11/Ericsson/Nokia)
- ISDN (Not used yet)
- ASAT (A interface for satellite)
all these modes can run as NETWORK or USER.
2011-09-29 01:31:20 +02:00
Harald Welte c2889512c4 e1_input: add 'port_nr' field and support DAHDI T1 cards
the "e1_line <0-255> port <0-255>" vty command allows the user to
set which physical port/card number should be represented by the
given virtual e1_line.

Furthermore, we now actually query the DAHDI hardware to determine the
number of ports of a given span (e.g. only 24 in case of T1) instead of
blindly assuming there are 31 timeslots on each port.

This specifically will fix T1 timeslot (/dev/dahdi/%u) calculation in
setups with multiple DAHDI spans/ports and a T1 span != span 1.
2011-09-25 23:37:47 +02:00
Pablo Neira Ayuso d6216405b7 input: fix multiple BTS attached to single line scenario
With multiple BTS attached to a single line, we have to call
->line_update() multiple times. I broke this myself while avoiding
that A-bis over IP drivers bind to the socket several times.

To fix this situation, Harald prefers that this case is internally
handled by the ipaccess and hsl drivers by means of the driver_data
field in the e1inp_line structure.

Reported-by: Gus Bourg <gus@bourg.net>
2011-08-31 17:55:33 +02:00
Harald Welte 3bc7885539 re-introduce optional build of DAHDI input plugin
We should only build it when the dahdi/user.h file is actually present.
2011-08-24 08:32:38 +02:00
Harald Welte fd44a5f2fe e1_input: move the lapd_instance pointer out of dahdi specifics
... and create a new e1inp_rx_ts_lapd() from dahdi as well
2011-08-21 12:15:08 +02:00
Pablo Neira Ayuso 4e862cbf4b e1_input: rework configuration of virtual E1 line operations
struct e1inp_line_ops {
-       enum e1inp_line_role    role;
-       char                    *addr;
-       void                    *data;
+       union {
+               struct {
+                       enum e1inp_line_role role;      /* BSC or BTS mode. */
+                       const char *addr;               /* IP address .*/
+                       void *dev;                      /* device parameters. */
+               } ipa;
+               struct {
+                       const char *port;       /* e.g. /dev/ttyUSB0 */
+                       unsigned int delay;
+               } rs232;
+       } cfg;

Now this structure contains the configuration details for the
virtual E1 line, instead of using a pointer.

This also get the line_update callback to its original layout:

+       int (*line_update)(struct e1inp_line *line);
2011-08-19 18:43:38 +02:00
Pablo Neira Ayuso 7e0d006e3c input: add rs232 driver for virtual E1 lines
This patch adds the rs232 driver which is used by then bs11_config
utility available in openBSC.
2011-08-19 17:30:56 +02:00