Commit Graph

462 Commits

Author SHA1 Message Date
Max f446367a63 IPA: log remote address
Wrap IPA logging to always print peer's address to simplify
troubleshooting.

Change-Id: I19ebaea45812aad6b3d3480cac0f1f833daf428d
2018-02-13 15:17:27 +01:00
Max 7139352e67 cosmetic: update ipaccess_bts_handle_ccm()
* mark internal function parameter as const
* log unit IDs

Change-Id: Ifcf8baf4bf5670efaa8689ca7386597fe2797bda
2018-01-08 15:42:00 +01:00
Harald Welte d1dd22c38e Add a new osmo_rtp_set_source_desc() function to set the RTCP SDES items
This allows the users of libosmotrau to set the content of the SDES
items to something more useful than their compile-time defaults.

Change-Id: Ice794f9e0c6caeea1c67520c12efbfa375d1fb82
Related: OS#2701
2017-12-03 11:03:50 +01:00
Alexander Couzens 2d4888dd08 unixsocket: fix a potential string overflow
Change-Id: I8e3ec741247d728232f8c07c94eb63f068597d80
Found-by: coverity
2017-11-21 11:57:01 +01:00
Harald Welte 323d39d784 Add SPDX-License-Identifier to all source files
Change-Id: I9f2bc8c5d8a2c0bb0dd6caa4de5e2cb11be210e7
2017-11-13 01:09:21 +09:00
Neels Hofmeyr e2d33bf02d vty: skip installing cmds now always installed by default
vty_install_default() and install_default() will soon be deprecated.

Depends: I5021c64a787b63314e0f2f1cba0b8fc7bff4f09b
Change-Id: I7771131a27d0b7ad0397715ceb3be035062bc010
2017-11-01 00:44:19 +01:00
Neels Hofmeyr 01543a1ea3 cosmetic: ipa.c: use msgb_dequeue(), drop local var
Make ipa_server_conn_write() a lot simpler and shorter by using msgb_dequeue()
and avoiding local pointer that was used only once.

Change-Id: Id968e60d081a6d69de482a908ca3fe5e1044aaa3
2017-09-14 04:59:32 +02:00
Max 7f17b8c45d Bump version: 0.3.2 → 0.4.0
Change-Id: Ibefe53a7f5b06fb8a9294574af41dacac68bdbe9
2017-08-25 16:12:37 +02: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
Pau Espin 9e992c2435 osmo_ortp.c: Duration of a RTP frame affects timestamp of the next one
Duration of an RTP frames dictates the timestamp used for the next
frame, not for the one being sent now. It was done like this before to
account for possible losses.
Implementation wise, the duration was understood as "duration
between last frame was sent and now when current one is sent". It makes
more sense to use it as the duration in number of sampling ticks
as described on the function documentation, specially now that we can
account for extra time by means of osmo_rtp_skipped_frame.

Change-Id: Ib8f5fa5509059fe908c09a4381844c613d478548
2017-06-29 18:04:32 +02:00
Pau Espin 524923a96a osmo_ortp: Add osmo_rtp_drop_frame API
This API will be used by osmo-bts to maintain the sampling clock of the
RTP socket whenever a frame should be sent but it is not available, for
instance due to low quality of signal.

Change-Id: Id6099372b6231c0a4b6ea0716f46f5daee7049e1
2017-06-29 17:27:25 +02:00
Pau Espin 05df2d65a7 osmo_ortp.c: Fix warning: check ortp API in rtp_session_signal_connect
Since ortp commit 5ab29c50adc7948b11449e3aeee66010379ff7dc preceeding
ortp 0.24, the API is fixed and requests a pointer instead of an
unsigned long.

As we now require at least ortp 0.22 since libosmo-abis
15d9b7929d, we need to support both old
and new version of the API to continue having support for 0.22 but still
supporting new versions of the library.

Change-Id: I2dbd0498d75160358eca4336850e1a0ad2efdbeb
2017-06-22 19:27:16 +02:00
Pau Espin b0c3a4a30f osmo_ortp.c: Fix warning: implicit use of function
Explicitly state that we are using an internal API from ortp, and
define the function we are using to avoid printing a warning.

Change-Id: I9cadcb31ce7ade3632d83753be97fdc9ea518b5b
2017-06-22 19:26:57 +02:00
Pablo Neira Ayuso b26f2fd825 src: use osmo_timer_setup()
Use new function available in libosmocore to set up timers. Compile
tested only.

Change-Id: I4ca4950e49a09c63b608b13ac7561ebbd351889a
2017-06-07 18:34:49 +02:00
Harald Welte e416e2e09d Revert "ipacces.c: Remove ipa_bts_id_resp() and use libosmocore"
This reverts commit d517db06ce, which for
some reason broke the IPA client functionality.  This needs to be
investigated and properly fixed.  But until that happens: revert.

Change-Id: Ic168f437c5bf1fcdb7441b0541c80a4805463004
2017-05-26 13:12:14 +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
Harald Welte d517db06ce ipacces.c: Remove ipa_bts_id_resp() and use libosmocore
In Chanage-Id Icbcd8827a75fd5f3393351c1ca372de85275ad35 we introduced a
very similar function to libosocore.  Let's use that rather than our own
version here.

Change-Id: I858920db1fb5f5d66e71b676d28c84d330d7904a
2017-04-15 19:12:01 +02:00
Jean-Francois Dionne 5e87fdfcab Fix RTP jitter buffer that never stop to increase.
Duration passed to osmo_rtp_send_frame_ext function is based
on the last frame and the current one. Duration must then be
added to the timestamp before being transmitted.

Change-Id: I0593d6530c097cca34125a0ae2dd1b019b4dd80d
2017-03-29 13:40:22 +00:00
Pau Espin Pedrol c42bf19cc5 configure: Fix compilation with new libortp
Commit 0c8d9ddaea8c1afdc0e9b8c37a31c9d158e57efd in ortp broke old API:
function ortp_set_log_level_mask requires one new parameter 'domain'.

This commit fixes compilation in my Archlinux box using ortp 1.0.1.

Change-Id: I46e565f1873c7baf3c3b0aafe73951d20ce083b4
2017-03-27 15:21:48 +02:00
Philipp Maier 027e119363 lapd: log pointer addresses
Add pointer address output to the sap alloc/free functions in
order to track the objects later in the debug output (we have three
of them)

Change-Id: I9b961d5e36967cfd953551b24696849541257a1c
2017-03-15 13:00:24 +00:00
Philipp Maier d75bac40d1 lapd: Reduce N200 (SABM retransmission count)
N200, which controls the maxium number of LAPD retransmissions,
is set to 300. This will cause a long waiting time until
LAPD detects a failed link. This commit reduces the retransmission
count to 50 in order to get a faster link re-establishment in
case of link failure. This patch will only affect the ericsson
LAPD profile, all other lapd profiles will not be touched.

Change-Id: I4f56f9d00520adc0c0a4497547762cd054030867
2017-03-14 18:32:33 +01: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
Neels Hofmeyr 30ffa7ade5 undup: subchan_demux.c: use libosmocore's llist_count()
Depends on libosmocore Change-Id Ic49adc7a346f5722bf624d7d3b4a735e4220ae15

Change-Id: I47f1831f1835dc07925dabbc115677087e48fa1b
2017-01-21 01:18:02 +01:00
Max c9fa25e831 handle_ts1_read(): log sign_link() error
Change-Id: I95779ee8590ab16b7af4ad2c79ede68da3a12e5a
2017-01-09 13:24:26 +01:00
Max 4c4a1c2035 ipaccess_line_update(): log connection IP addresses and ports
Remove dup: call function to obtain IPA address only once. Log
explicitly IP address and ports to which IPA is bound or connected.

Change-Id: I841c40abdcba0fdd695a43231391c5d7cee20fae
2016-12-31 18:41:39 +00:00
Max bf42e0a91f Enable adaptive jitter compensation
* check RTP socket parameter and enable necessary jitter buffering
* return the status of requested jitter buffering instead of always
  returning 0
* document function parameters and return value

Change-Id: I87d4d9fe990683adbb02b64cb39b78de533d8046
2016-12-16 13:26:28 +01:00
Max ac2ad3b437 Remove obsolete compile-time conditional
Change-Id: If8f87587227b09635361b758873f75d8b6aa3497
2016-12-16 13:04:19 +01:00
Max 7c840be476 Expand network error callback
ortp: use extra parameter for network_error callback in log message as
it's described in oRTP documentation (error string).

Change-Id: I581db499d453b80230198d95000f0f6fc20752d1
2016-12-12 11:08:02 +00:00
Max 78d0486ffd osmo_rtp_socket_poll(): Fix log message to match function name
Change-Id: I5c36bbc35e2ba794b5e446f52a0752bcf1367d11
2016-12-05 15:22:07 +00:00
Harald Welte b0a4235805 don't pass negative error to strerror()
Change-Id: I48c25c78148d1fe9ce4e4a88cdfe5cf74dc95b17
Fixes: Coverity CID 57858
2016-11-26 09:44:33 +01:00
Harald Welte 519217f0ea call strerror() not on negative value
Change-Id: I0ba1eab49f93d9b34d162682f2528d106b56d6d6
Fixes: Coverity CID 57857
2016-11-26 09:43:46 +01:00
Harald Welte 14dd30a13e fix signed/unsigned bug in ipa_client_conn_open()
If osmo_sock_init() would ever return a negative FD together with
errno == EINPROGRESS, we would have attempted to register that negative
FD with the select() main loop handling, whihc of course doesn't work.

EINPROGRESS for a non-blocking connecting socket is handled inside
osmo_sock_init() and would result in it returning a positive FD, so the
above case is of theoretical significance only.

Change-Id: Id01eb0d48eea6cab1fbc720c52361101b8ea4e35
Fixes: Coverity CID 57856
2016-11-26 09:37:09 +01:00
Harald Welte 34260c8923 osmo_rtp_socket_fdreg(): Check return value of osmo_fd_register()
Change-Id: I4969e0a9e7109d426066e6c2b80ed44c396b65b5
Fixes: Coverity CID 57631
2016-11-26 09:27:46 +01:00
Harald Welte ae3a993bd6 input/ipaccess.c: Check return value of osmo_fd_register()
Change-Id: I81659e0533ceb5d43292d97a63300b500044add7
Fixes: Coverity CID 57630
2016-11-26 09:25:23 +01:00
Alexander Couzens 35daa67763 e1_input: remove superflous semi colon
Change-Id: I7e9079cbac1d9920da2aace35810682b49ec532f
2016-11-16 10:08:02 +00:00
Philipp Maier 0c7d5f4a61 lapd: adding support for ericsson's lapd dialect
Ericsson's RBS2111-BTS (and similar) implements a lapdm dialect which uses
a link establishment method that differs from the standard. While the BSC
is transmitting sabm frames on one specific timeslot, the BTS will
periodically scan through all timeslots to check for incoming sabm frames.
When the BTS detcts the sabm fames on one of the timeslots it will stay
there and continue to commence the link establishment.

The described procedure requires a slightly modified lapd profile, the t200
retransmission timeout has to be configured to exactly 300 msek. Otherwise
the link establishment will fail. Since the BTS will switch from timeslot
to timeslot most of the sabm frames will not be seen by the BTS, so the
maximum retransmission has to be increased. This patch suggests a maximum
retry count of 300, which is an educated guess and has worked fine during
our tests.

Change-Id: I892af57013d7ab4216e9e2d0873a69129aaeb8e5
2016-11-02 09:23:01 +00:00
Harald Welte 7895e0456a Fix metadata corruption
Use separate pointer for payload to make sure mblk->b_rptr is not
advanced (which breaks the use of rtp_get_* macros that assume
mblk->b_rptr is pointing to the RTP header, not the payload).

Committed by: Max <msuraev@sysmocom.de>

Change-Id: I205630e1da98693ba0ac25e86e21780284185077
Related: OS#1802
2016-10-28 09:03:22 +00:00
Max f69060066c Unify RTP receiving
* Remove code duplication
* Use return value of rtp_get_payload() instead of pointer arithmetic

Change-Id: Id42e85b55eab33c5eb81ac7a2cdea7962b2e30ef
2016-10-27 18:06:20 +02:00
Max 02ceea8342 Extend RTP RX callback parameters
While debugging low-level RTP issues it is handy to be able to match
exact RTP packet with the payload available to higher-level
functions. Having Sequence number and Timestamp RTP fields as parameter
to receiving callback is the easiest way to do so.

Change-Id: I0c9b08d247d7342d6139badca77ce64fda0cf274
2016-10-21 19:45:00 +02: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
Yves Godin 2c32f0a269 Resync RTP session in case of timestamp jump
This will prevent the timestamp jump to occur between each call for DTX
if something goes wrong. It's handy as oRTP does not manage well
timestamp jump if it is not resynced.

Fixes: OS#1803
Change-Id: Iae5da832218dbd1ede7a9451102074f2a5eb66df
2016-10-12 09:26:00 +00:00
Neels Hofmeyr a0ff942e92 Really fix order of set_connected_mode and set_remote_addr
This reverts commit c77c2a6aa1,
and explicitly sets connected mode to zero for set_remote_addr to work around
internal libortp problems. See https://osmocom.org/issues/1661#note-15.

Related: OS#1661
Change-Id: I9d146c3bd76e02685b09278167b56029152221a0
2016-10-06 15:50:18 +02:00
Max 15d9b7929d Bump minimum oRTP version
Require version 0.22.0 which matches Debian stable ATM to simplify
testing and maintenance across all supported BTS models and
corresponding toolchains.

Change-Id: I005d60bb50889edad3e6fc0cd9f7f180aeaf1dab
Fixes: SYS#2569
2016-09-24 16:30:22 +02:00
Max fc47015d91 Use callback for polling data
Previously rs->rtp_bfd.when and rs->rtcp_bfd.when value of BSC_FD_READ
was overridden by 0. Fix it.

Reported by coverity: CID 1357763.

Change-Id: I11940cbf50361c4ea262d7001a16f9a982392f27
2016-09-20 19:17:02 +02:00
Max 6dab90f39f Change API to convey marker bit
Previously RTP receive callback ignored Marker bit from RTP
headers. Extend API to include it explicitly.

Change-Id: I3c2b6365d8a51bf98805614e07344d2639875fde
Related: OS#1750
2016-09-09 06:34:54 +00:00
Neels Hofmeyr c77c2a6aa1 osmo_ortp.c: fix order of set_connected_mode and set_remote_addr
In libortp, rtp_session_set_connected_mode() sets a flag that is used in
rtp_session_set_remote_addr().

The name rtp_session_set_remote_addr() is misleading: this function actually
does take a lot of action, including an attempt to connect to the remote
server. Thus the "connected mode" flag needs to be set before this.

Suggested-by: NuRan Wireless <nuranwireless.com>
Change-Id: I92308ddffc376af8d4d65e6b9cbeee222b7bff5e
2016-09-05 14:18:08 +02: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 b4698ef0d9 lapd_pcap: Correctly set the pseudo-header packet type
We want the direction of the packet to be properly reflected in the
pseudo-header, so wireshark can display if the packet is sent in
network->user (BSC->BTS) direction, or in th reverse direction.

Related: OS#1764
Change-Id: I19afca0ce7e8b068bc64fa14bce6feb35aa9f1fc
2016-07-04 10:29:48 +02:00
Harald Welte 47bee5bed5 Add osmo_pcap_lapd_set_fd() function
This way the caller can hand in an already-open file descriptor, rather
than calling osmo_pcap_lapd_open() with a file path name.

Change-Id: Ic7193907a96b0e2284cb6a8a942d2bf0fb95d7e4
2016-07-04 10:25:02 +02:00
Max 73b9bc72ac Extend RTP frame sending API
Add osmo_rtp_send_frame_ext() which accept boolean parameter in addition
to arguments of osmo_rtp_send_frame() to explicitly set marker bit in
RTP header. Previously it was always unset which resulted in degradation
of speech quality for codecs with explicit talkspurt events (was tested
with AMR's ONSET).

Related: OS#1562
Change-Id: I23e6dccfad5643e662391a0a2abebbb45597ffd9
Reviewed-on: https://gerrit.osmocom.org/82
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-06-06 10:03:08 +00:00
Harald Welte 9ed7ca5b86 ipa_bts_id_resp(): handle non-existing members of ipacces_unit
Just because the IPA server is requesting certain identities via the CCM
protocol, doesn't mean that the client actually has those fields
available and initialized in struct ipaccess_unit.

Instad of segfaulting the client, let's check if the respective
identities are known.  If yes, send them.  If not, send the empty string
for that particular identity.
2016-04-29 12:59:27 +02:00
Harald Welte 12814b9636 ipa_server_conn: Add server-side CCM handling
An ipa_server implementation may call ipa_server_conn_ccm for
the CCM processing on the server side of the connection.  This
function in turn will call a conn->ccm_cb() function for messages to be
handled by the server implementation, such as the ID_RESP message,
which contains the Unit ID of the client that has just connected.
2016-04-29 12:59:27 +02:00
Harald Welte b2d727a102 ipa_server_conn: Add remote (peer) address to struct
This is better than every implementation calling getpeername()
on its own.
2016-04-29 12:59:27 +02:00
Max 8c119f7a05 Set connected mode after setting remote address
ortp: according to oRTP documentation rtp_session_set_connected_mode()
uses the address set by rtp_session_set_remote_addr() - move the
function call accordingly.

Fixes: OS#1661
2016-04-29 12:54:38 +02:00
Max 80f7c0465f Fix RTCP port allocation
Force use of RTCP port adjacend to random RTP port, if random RTP port
is used.

Before this patch, port 0 could be selected for RTCP.
2016-04-29 12:54:00 +02:00
Max e54d7bcef5 Do not send RTP to port 0
Previously it was possible to send RTP data to port 0. This produce
multiple errors during the beginning of RTP transmission.

To address this OSMO_RTP_F_DISABLED flag was introduced. It's set by
default for all new RTP sessions. It can be manually unset after the
call to osmo_rtp_socket_create(). When the flag is set it prevents
transmission and reception of RTP frames for the session. The flag is
unset automatically in osmo_rtp_socket_connect() when session is bound
to non-zero remote port.

Fixes: OS#1662
2016-04-29 12:53:21 +02:00
Neels Hofmeyr 0db1d43c0d ipa driver: make bind address vty configurable
Add VTY function to set the ipa bind address:
    e1_input
     ipa bind A.B.C.D

Add a priv pointer to struct e1inp_driver in order to communicate the bind
address parameter to ipaccess_line_update(). Add two "internal.h" functions to
get/set it in the ipa driver struct.

Add static ip_bind_addr() to use the IP address set from the VTY or, if NULL,
use "0.0.0.0". Apply in ipaccess_line_update().
2016-02-25 12:12:28 +01:00
Holger Hans Peter Freyther 3cef39b03c debian: Bump so version to link against new libosmovty2
Debian doesn't have reverse dependencies so we need to bump the
SO version to have libosmoabis and libosmotrau link against our
new version.
2015-11-03 09:42:24 +01:00
Holger Hans Peter Freyther 71bc9e2ac8 ortp: Guard the jitter stats with a version check
ortp 0.18 has introduced the jitter_stats but we only check for
0.21 an later. It is okay that at some point the jitter stats
will be reported. For previous versions it is 0.
2015-09-21 12:18:37 +02:00
Holger Hans Peter Freyther fe01908428 ortp: Export statistics for the bts or similar
We might want to know how many things arrived at the BTS and
ortp is already counting for us. We don't intend to use RTCP
so I am not sure what the last "sender report" is and how
accurate the jitter is.
2015-09-21 10:55:12 +02:00
Holger Hans Peter Freyther 3a580f263a subchan: Remove unused const variable
nullbytes has never been used, I assume the code ended up
using memset instead of copying from nullbytes.

Fixes:
subchan_demux.c:47:22: warning: unused variable 'nullbytes' [-Wunused-const-variable]
static const uint8_t nullbytes[SYNC_HDR_BITS];
2015-03-22 09:25:19 +01:00
Holger Hans Peter Freyther 9087859057 ipa: Add API to clear the tx queue
Jacob noticed that after a re-connect old messages would be
sent. This can be the wanted behavior but add a method that
allows a caller to clear the tx queue. The implementation has
not been verified and there is no existing unit test where
I could easily add this code to.
2015-01-18 17:52:08 +01:00
Holger Hans Peter Freyther adfa01f041 misdn: Close the file descriptor if the ioctl is failing
Fixes: Coverity CID#1040691
2014-12-26 18:13:55 +01:00
Holger Hans Peter Freyther 687046ba2f ipa: Set the BSC_FD_WRITE in ipa_client_conn_open
When the link is being created BSC_FD_WRITE and BSC_FD_READ are
being ored into the flag. When the socket connects the first time
the ipa_client_fd_cb function is called and the link->state is
moved from connecting to connect.

In case the connection drops and ipa_client_conn_open is called
again the BSC_FD_WRITE flag might not be set. This means that after
the socket is connected, ipa_client_fd_cb will not be called. This
means that the updown_cb will not be called until after the first
write or read on the socket. It might even lead to missing some
data.

When re-connecting set the write flag again.
2014-12-12 17:39:58 +01:00
Holger Hans Peter Freyther 37fcd93a50 ipa: Partially revert the e1inp_ipa_bts_rsl_connect_n commit
The check was always hit by osmo-bts master leading to the RSL
connection never being made. This is because the type of the line
will be set _after_ the RSL connection has been made. E.g. inside
osmo-bts/src/common/abis.c:

static struct e1inp_sign_link *sign_link_up(void *unit, struct e1inp_line *line,
                                            enum e1inp_sign_type type)
{
        struct e1inp_sign_link *sign_link = NULL;

        switch (type) {
	...
        case E1INP_SIGN_RSL:
                LOGP(DABIS, LOGL_INFO, "RSL Signalling link up\n");
                e1inp_ts_config_sign(&line->ts[E1INP_SIGN_RSL-1], line);
	...

Only the call to e1inp_ts_config_sign will set the type to be
E1INP_TS_TYPE_SIGN. Before the call the type is still _NONE and
the connect was rejected.
2014-10-26 08:29:20 +01:00
Holger Hans Peter Freyther d9d1b5c19f misc: Work with src != builddir
libosmo-abis/0.3.0+gitrAUTOINC+b6d2834eef-r2.14.0/git/src/input/dahdi.c:25:26: fatal error: ../../config.h: No such file or directory
 #include "../../config.h"
2014-09-25 18:47:12 +02:00
Holger Hans Peter Freyther b6d2834eef Prepare a new release of libosmo-abis 2014-09-08 07:57:09 +02:00
Andreas Eversberg f422a753a7 Support for multiple RSL connections with ABIS/ipaccess (BTS side)
In order to support multiple TRX, multiple RSL connections can be
establised. e1inp_ipa_bts_rsl_connect() requires an additional parameter
to set the TRX number.

The ts[] array (member of struct e1inp_line) refers to OML and RSL.
ts[0] refers to OML link, ts[1] to RSL link of first TRX, ts[2] to
RSL link of second TRX (if exists) and so on.

The code was successfully tested with osmobts-trx and UmTRX with two
transceivers.

The user of e1inp_ipa_bts_rsl_connect() (which is osmo-bts) can use
the new function like this (backwards compatibility function provided):

src/common/oml.c
-	rc = e1inp_ipa_bts_rsl_connect(oml_link->ts->line, inet_ntoa(in), port);
+	rc = e1inp_ipa_bts_rsl_connect_n(oml_link->ts->line, inet_ntoa(in), port,
+		trx->nr);
2014-08-28 12:50:29 +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 b65f58f6f9 move various generic IPA related functions to libosmocore
libosmo-abis is about forming A-bis interfaces/lines by means
of E1 or the IPA multiplex (or possibly other link layers).

The IPA multiplex is used in other contexts, such as the Control
interface, or the A interface.  In that context, it makes sense to have
generic IPA related functions in libosmocore.
2014-08-20 23:41:07 +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
Harald Welte f5efba40e7 ipa: add ipaccess_tlv_to_unitdata()
this function takes the parsed TLVs of an IPA ID RESP message and
fills a 'struct ipaccess_unit'.
2014-08-18 20:51:03 +02:00
Harald Welte 783715b204 Split generic CCM handling out of ipaccess_bts_read_cb()
The generic functionality of responding to IPA CCM messages doesn't need
to be intertwined with our e1input abstraction.  We split this out
as new exported function ipaccess_bts_handle_ccm() and modify
ipaccess_bts_read_cb() to make use of that function.
2014-08-18 20:51:03 +02:00
Holger Hans Peter Freyther 46c40b8e58 ipa: Move the second null check into the first one
Move the second null check before we actually dereference the
msg.

Fixes: Coverity CID 1231854
2014-08-18 20:25:07 +02:00
Harald Welte e7e1b75564 ipa: ensure updown_cb() gets called on reconnect
If the ipa_client_conn is lost and ther user issues a new
ipa_client_conn_open(), then we need to re-set our internal state
to IPA_CLIENT_LINK_STATE_CONNECTING, as otherwise we wouldn't call the
updown_cb() once the link is up again.
2014-08-18 14:54:47 +02:00
Harald Welte f0d4a2213a ipa: Set msgb->l1h to the beginning of the IPA header
l2h points to the OML/RSL header, so it is only logical that l1h points
to the IPA header. Also, this is what osmo-bts/msg_utils.c expects.
2014-08-18 14:54:47 +02:00
Holger Hans Peter Freyther fb6e1e993e rtp: Randomize the initial timestamp for RFC compliance
Pick a random timestamp when creating the session.

RFC 3550:
The initial value of the timestamp SHOULD be random, as for the
sequence number.

Fixes: SYS#403
2014-06-24 11:02:01 +02:00
Holger Hans Peter Freyther bf6f1f4a37 rtp: Randomize the initial sequence number for RFC compliance
The usage of random() is not that unpredictable but the closest
we can get right now.

RFC 3550:
The initial value of the sequence number SHOULD be random
(unpredictable) to make known-plaintext attacks on encryption
more difficult, even if the source itself does not encrypt
according to the method in Section 9.1, because the packets
may flow through a translator that does.  Techniques for
choosing unpredictable numbers are discussed in [17].

Fixes: SYS#403
2014-06-24 10:59:43 +02:00
Pablo Neira Ayuso 754d5d4b6c ipa_proxy: make sure ipa instance name is nul-terminated
Reported by coverity. CID 1206565.
2014-04-26 12:44:18 +02:00
Holger Hans Peter Freyther ecd0a36ce8 release: Prepare the 0.2.0 release of libosmo-abis 2014-03-31 15:49:13 +02:00
Jacob Erlbeck 98af3c3a6d ipa: Change ipa_msg_recv() to support partial receive
Currently ipa_msg_recv() fails, when messages are received partially.

This patch provides a new function ipa_msg_recv_buffered() that uses
an additional ** to a message buffer to store partial data.  When
this happens, -EAGAIN is returned. If NULL is used, the function
behaves similar to ipa_msg_recv() and fails on partial read.
In addition in case of errors the return value is now always -EXXX
and the contents of errno is undefined.

Note that this feature needs support by the calling code insofar that
*tmp_msg must be set to NULL initially and it must be freed and
set to NULL manually when the socket is closed.

Note also that ipa_msg_recv() is then a wrapper around
ipa_msg_recv_buffered() which mimics the old error behaviour by
setting errno explicitely to -rc and returning -1 when an error has
happened.

Ticket: OW#728
Sponsored-by: On-Waves ehf
2014-03-31 14:33:18 +02:00
Holger Hans Peter Freyther f465a4c16f ipaccess: Move the #endif before the curly brace
Fix the compilation on FreeBSD that does not use these names
but they are prefixed with TCPTV_KEEP... instead.
2014-02-03 09:34:02 +01:00
Holger Hans Peter Freyther ba9aa8941b Prepare the v0.1.6 release of libosmo-abis 2014-01-20 10:22:45 +01:00
Holger Hans Peter Freyther 901ef1cbbb ipaccess: Change the visibility of the ipa messages 2014-01-20 08:11:51 +01:00
Jacob Erlbeck 8fe1571ea9 ipaccess: Make TCP keep-alive configurable
This patch changes the implementation to use the keep-alive
configuration fields instead of constants.

Ticket: OW#1060
Sponsored-by: On-Waves ehf
2014-01-20 08:10:43 +01:00
Jacob Erlbeck 86dae84bed input: Make keep alive configurable (generic)
This patch adds a generic keep alive configuration layer that mainly
consists of additional fields in e1_input structs and VTY commands
and extensions.

Ticket: OW#1060
Sponsored-by: On-Waves ehf
2014-01-20 08:10:43 +01:00
Jacob Erlbeck a4ec51e108 ipaccess: Use keep alive for all connections
Keep alive has only been used for OML so far.

This patch refactors the socket configuration into an own function
and uses it for RSL, too.

Ticket: OW#1060
Sponsored-by: On-Waves ehf
2014-01-20 08:10:43 +01:00
Daniel Willmann 859807261e ipaccess: Enable TCP keepalive by default on all BTS connections
This way we can find out fast if the connection is broken.

Ticket: OW#1060
2014-01-20 08:10:43 +01:00
Holger Hans Peter Freyther 63ddf4645c ipaccess: Fix crash when no IPA message is sent first on the RSL port
The issue was that the link has not been configured yet and the
list has not been initialized yet (it is NULL for next/prev).
Check if the ts is not configured before searching a link.

Reproduce with:
 (Sockets.StreamSocket remote: 'localhost' port: 3003)
	nextPutAll: #[0 1 0 0];
	flush.

Backtrace:
 #0  e1inp_lookup_sign_link (e1i=0x27af8c0, tei=0 '\000', sapi=0 '\000') at e1_input.c:437
 437			if (link->sapi == sapi && link->tei == tei)
(gdb) bt
 #0  e1inp_lookup_sign_link (e1i=0x27af8c0, tei=0 '\000', sapi=0 '\000') at e1_input.c:437

 #1  0x00007f338ee87d49 in handle_ts1_read (bfd=0x27afe60) at input/ipaccess.c:436
 #2  ipaccess_fd_cb (bfd=0x27afe60, what=1) at input/ipaccess.c:586
 #3  0x00007f338f0976ce in osmo_select_main (polling=0) at select.c:158
 #4  0x0000000000407394 in main (argc=<optimized out>, argv=0x7fff1aa4fed8) at bsc_hack.c:346
(gdb) p *e1i
 $1 = {type = E1INP_TS_TYPE_NONE, num = 2, line = 0x222e860, lapd = 0x0, {sign = {
      sign_links = {next = 0x0, prev = 0x0}, delay = 0, tx_timer = {node = {
          rb_parent_color = 0, rb_right = 0x0, rb_left = 0x0}, list = {next = 0x0,
          prev = 0x0}, timeout = {tv_sec = 0, tv_usec = 0}, active = 0, cb = 0, data = 0x0}},
    trau = {demux = {chan_activ = 0 '\000', subch = {{
            out_bitbuf = '\000' <repeats 319 times>, out_idx = 0, consecutive_zeros = 0,
            in_sync = 0}, {out_bitbuf = '\000' <repeats 319 times>, out_idx = 0,
            consecutive_zeros = 0, in_sync = 0}, {out_bitbuf = '\000' <repeats 319 times>,
            out_idx = 0, consecutive_zeros = 0, in_sync = 0}, {
            out_bitbuf = '\000' <repeats 319 times>, out_idx = 0, consecutive_zeros = 0,
            in_sync = 0}}, out_cb = 0, data = 0x0}, mux = {subch = {{tx_queue = {next = 0x0,
              prev = 0x0}}, {tx_queue = {next = 0x0, prev = 0x0}}, {tx_queue = {next = 0x0,
              prev = 0x0}}, {tx_queue = {next = 0x0, prev = 0x0}}}}}}, driver = {misdn = {
      fd = {list = {next = 0x7f338f2a7950, prev = 0x250f890}, fd = 19, when = 1,
        cb = 0x7f338ee87c40 <ipaccess_fd_cb>, data = 0x27af2c0, priv_nr = 2}}, ipaccess = {
      fd = {list = {next = 0x7f338f2a7950, prev = 0x250f890}, fd = 19, when = 1,
        cb = 0x7f338ee87c40 <ipaccess_fd_cb>, data = 0x27af2c0, priv_nr = 2}}, dahdi = {fd = {
        list = {next = 0x7f338f2a7950, prev = 0x250f890}, fd = 19, when = 1,
        cb = 0x7f338ee87c40 <ipaccess_fd_cb>, data = 0x27af2c0, priv_nr = 2}}, rs232 = {fd = {
        list = {next = 0x7f338f2a7950, prev = 0x250f890}, fd = 19, when = 1,
        cb = 0x7f338ee87c40 <ipaccess_fd_cb>, data = 0x27af2c0, priv_nr = 2}}}}
2013-12-28 21:21:30 +01:00
Jacob Erlbeck 3ea52e4f4c ipa-proxy/vty: Removed enable/ipa node
This was basically a link to configure/ipa which is not cleanly
supported by the current VTY framework.

The test program uses the default implementation for
go_parent_cb/vty_go_parent() and is_config_node, since config-ipa is
a top level config node which is assumed by default.
2013-11-11 14:54:53 +01:00
Jacob Erlbeck 1c9dcc1236 vty: Use same prompt string format like in libosmocore
Ensures a single blank after the '#'. Use (config-foo) instead (foo)
for config nodes.
2013-11-11 14:54:53 +01:00
Jacob Erlbeck 37f0695626 vty: Use new vty_install_default() function
This patch removes the local 'end' and 'exit' implementations and
uses the generic ones provided by libosmocore instead, which are
enabled automatically when vty_install_default() is used.
2013-11-11 14:54:53 +01:00
Holger Hans Peter Freyther e58d33153d ortp: Fix the version check for ORTP by not using the cached result
The second check used the cached result for ORTP. Store the result
in ORTP_VERSION and my system properly detects that it is running
on < 0.21.

The HAVE_ORTP_021 will always be defined so just use #if and not
the #ifdef to fix the build.
2013-10-06 13:37:08 +02:00
Harald Welte 2bfc01dfd8 enable support of libortp >= 0.21, which has an API breakage
in libortp >= 0.21, rtp_session_set_local_addr() has one extra
argument for the RTCP port.
2013-10-06 12:23:35 +02:00
Harald Welte a98a6254bf it's called 'truncated' message, not 'trunked' 2013-10-06 11:55:19 +02:00
Harald Welte 6eddd478e2 ipaccess.c: call sign_link_up() only _after_ tx ID_ACK/ID_RESP
in order to keep the message ordering right, we first send the
ID_ACK/ID_RESP messages, before handing sign_link_up() into the
application.  This ensures that no OML messages get transmitted before
the ID_ACK/ID_RESP has been completed
2013-10-06 11:55:19 +02:00
Harald Welte 51de9ca3a6 IPA: remove automatic reconnect logic
When an IPA link is in client (BTS) mode, we should not automatically
re-connect in the lowest (ipa) layer.  Instead, we properly close the
socket if the link is dead, and we call link->updown_cb() to notify
the user that the link is down.

The e1inp/ipaccess layer translates this into a line->sign_link_down()
callback that propagates up to the user.
2013-10-06 11:55:18 +02:00
Harald Welte a3e9dd5757 ipaccess: rename ipaccess_bts_cb() to ipaccess_bts_read_cb()
this is consistent with ipaccess_bts_write_cb().
2013-10-06 11:54:39 +02:00
Harald Welte e68055bf11 ipa: protect against multiple subsequent calls to ipa_client_conn_close()
This would create linked list coruption in osmo_fd_unregister().

The fact that multiple calls of osmo_fd_unrgeister() on the same fd
happen is due to the fact that ipaccess_drop() and others already close
the file descriptor.
2013-10-06 11:54:38 +02:00
Harald Welte 10b41306db ipaccess: Properly resolve 'line' in error case
If a write on an IPA file descriptor fails, then we call
ipaccess_drop().  However, only in the BSC side the assumption that
bfd->data == e1inp_line holds true. On the BTS side, ofd->data
references to the ipa_client_conn structure.  In order to avoid the
problem, call ipaccess_drop() with an explicit reference to the line in
which the link was dropped.
2013-10-06 11:54:38 +02:00
Harald Welte 84f67b2832 Don't establish RSL at same time as OML link on IPA type lines
If we have a BTS-side e1inp_line, we can only establish OML at the
time of line_update.  We have to wait with RSL until the BTS explicitly
tells us the RSL destination IP and port (received via OML from BSC).

This is now handled in a new function called
e1inp_ipa_bts_rsl_connect().
2013-10-06 11:54:38 +02:00
Pablo Neira Ayuso ef13269e07 input: fix compilation warning due to missing include osmocom/core/backtrace.h
input/ipa.c: In function 'ipa_server_link_create':
input/ipa.c:344:2: warning: implicit declaration of function 'osmo_generate_backtrace' [-Wimplicit-function-declaration]

input/ipaccess.c: In function 'ipaccess_bts_cb':
input/ipaccess.c:873:2: warning: implicit declaration of function 'osmo_generate_backtrace' [-Wimplicit-function-declaration]
2013-07-08 01:22:58 +02:00
Pablo Neira Ayuso cdda0a87e4 ipa: stricter accept callback handling in ipa_server_link_create
Add assertion as suggested by Holger. This function does not make
much sense with the accept callback set. While at it, check return
value of the accept callback and release the peer socket in case
such callback returns an error.

Reported by Holger.

Reference: CID 1040692
2013-07-08 01:22:57 +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
Holger Hans Peter Freyther f69b8123f9 dahdi: Fix potential but unlikely out of bounds access
The line->port_nr is compared to the array size of the span config
and then the array can be potentially accessed one element outside
of the array.

Fixes: Coverity 1042368
2013-07-06 18:54:58 +02:00
Holger Hans Peter Freyther 219a6a4add misdn: Fix a file descriptor leak in _mi_e1_line_update
The socket is created to get information about the ISDN system
and can be released once we have found the information.

Fixes: Coverity CID 1040691
2013-07-06 18:49:59 +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
Pablo Neira Ayuso 4bab3bf415 input: ipaccess: stricter string handling in ipa_bts_id_resp
These strings are locally set via the BTS configuration, not the
network, but make sure we don't overrun the buffer.

Reference: CID 1040690
2013-07-05 15:05:30 +02:00
Pablo Neira Ayuso a8c4871a2a input: ipa: close descriptor if no accept callback is set
Reported by Holger.

Reference: CID 1040692
2013-07-05 14:48:24 +02:00
Pablo Neira Ayuso b948701f8c input: ipaccess: fix possible NULL dereference
Unlikely to happen, but add assertion for correctness.

Reported by Holger.

Reference: CID 1042352
2013-07-05 14:41:42 +02:00
Holger Hans Peter Freyther 3a5b4364e8 ipa_proxy: The ret variable was not initialized/assigned
Remove the unused variable and return -ENOMEM in case of an error
and return 0 at the normal exit.

Fixes: Coverity CID 1040689
2013-07-04 20:05:50 +02:00
Holger Hans Peter Freyther 8cbd9f4d09 e1_input_vty: Help coverity in understanding this code
In theory argc could be negative and this code would crash with
a null pointer dereference on the line pointer. Check for <= to
avoid this warning.

Fixes: Coverity CID 1040699
2013-07-04 20:00:33 +02:00
Holger Hans Peter Freyther a677cbc0cb ipa: Fix the size of the streamid array used in the proxy code
We want to store stream ids 0 to 0xff. This means we need to have
256 entries in this array.

Fixes: Coverity CID 1040697, CID 1040696, CID 1040695, CID 1040694
2013-07-04 19:52:41 +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
Alexander Huemer 3eed8a115a Makefile.am: Use AM_CPPFLAGS
Since automake 1.13 INCLUDES is depricates and causes a warning
2013-06-12 07:51:41 +02:00
Holger Hans Peter Freyther 5731dd74f7 misdn: Set ret to 0 when using the LAPD from userspace
Warning:
input/misdn.c:252:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is
      true [-Wsometimes-uninitialized]
        if (mline->use_userspace_lapd) {
            ^~~~~~~~~~~~~~~~~~~~~~~~~
input/misdn.c:289:9: note: uninitialized use occurs here
        return ret;
               ^~~
input/misdn.c:252:2: note: remove the 'if' if its condition is always false
        if (mline->use_userspace_lapd) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input/misdn.c:241:9: note: initialize the variable 'ret' to silence this warning
        int ret;
               ^
                = 0
1 warning generated.
2013-03-09 17:37:42 +01:00
Holger Hans Peter Freyther 4b6860db44 lapd: Do not override t203_sec initialization.
This was spotted by clang3.3 and got broken in git revision
f42280b6a2 when moving to the
C99 initializer.

Warning:
input/lapd.c:106:30: warning: initializer overrides prior initialization of this subobject
      [-Winitializer-overrides]
        .t203_sec       = 20,   .t203_sec       = 0,
                                                  ^
input/lapd.c:106:14: note: previous initialization is here
        .t203_sec       = 20,   .t203_sec       = 0,
                          ^~
1 warning generated.
2013-03-09 17:37:42 +01:00
Harald Welte e7a3f43d86 ortp: Don't write error callbacks to stderr, but use osmocom logging 2013-02-19 13:35:22 +01:00
Andreas Eversberg 41bc615c3f RTP: Allow disabling jitter buffer by setting a buffer size of 0 2013-02-14 17:21:26 +01:00
Harald Welte d426d458ca Permit libortp to use the connect() syscall, enabling later getsockname()
If we bind a local socket to INADDR_ANY, then getsockname() will always
return 0.0.0.0 for the local IP address _unless_ the socket was
previously connected to a specific remote IP/port using connect().

This will have the side effect that we only accept RTP packets from the
one IP/port that we have connect()ed to, but that is actually
intentional and useful in our applications.
2013-02-09 11:01:19 +01:00
Pablo Neira Ayuso a49c24d965 ipaccess: relax default behaviour on errors coming from signalling layer
This patch relaxes the behaviour on error coming from the signalling
layer. This is probably too strict for recoverable errors.

Don't release msgb in this case, as this is controled by the signaling link
layer.

Thanks to Lennart Müller <mueller.lennart@googlemail.com> for the report.
2012-10-16 18:18:33 +02:00
Tobias Engel f684976724 Adds support for GSM 08.60 data frame en-/decoding
There is no interworking function (IWF) here. The contents of an uplink
frame simply gets copied into a downlink frame. For this to work both
sides of the call need to connect with the same speed and parameters.
2012-10-12 16:23:02 +02:00
Dieter Spaar 08c103251c Make sure sync header was fully received
The sync header consists of 16 zero-bits followed by 1 one-bit. Before,
subchan_demux only tested for the 16 zero-bits. But if the previous
frame ended in one or more zero-bits these were then already counted as
belonging to the sync header, leading to a frame that was shifted by one
or more bits.
2012-10-12 16:22:36 +02:00
Pablo Neira Ayuso 84e5cb9b34 ipaccess: fix leak of IPA control messages in the BTS side 2012-08-30 21:50:32 +02:00
Pablo Neira Ayuso 953060001d input: add generic PCAP interface for LAPD
This patch allows you to create PCAP traces between the BSC and BTS including
the LAPD frames. Useful for debugging communication issues.

So far, it was only possible to create layer 3 traces containing
OML/RSL. LAPD traces can be also interesting to debug communication
issues between the BSC and the BTS.

To enable PCAP of LAPD, you only have to invoke:

li->pcap_fd = osmo_pcap_lapd_open("/tmp/file.pcap", 0600);

By default, li->pcap_fd is set to -1 which means disabled.

openBSC needs a patch to replace all usage of e1_set_pcap_fd by
osmo_pcap_lapd_open.
2012-08-30 21:50:31 +02:00
Pablo Neira Ayuso 7ed92581ee input: dahdi: replace exit by return
This is a library, we leave up to the client code to decide when to
finish the code execution.
2012-08-30 21:50:31 +02:00
Pablo Neira Ayuso 5c67fb5610 input: dahdi: use logging facilities instead of fprintf and stderr 2012-08-30 21:50:31 +02:00
Pablo Neira Ayuso f42280b6a2 lapd: use C99 structure initialization for profile templates 2012-08-30 21:50:31 +02:00
Pablo Neira Ayuso 1e4019483f ipaccess: improve error handling
If we hit any error, spot an error message containing the reason
and close the links to start over.

This patch has been tested by injecting errors in:

* ipaccess_send, by randomly returning -1.
* returning error from the ->sign_link_up callback, both from the
  OML and RSL links.
* returning error from the ->sign_link callback, both for the
  OML and RSL links.

With this patch, Valgrind shows no "definitely lost" memory blocks
anymore (including the error path that has been tested) and the
ipaccess driver behaves more robustly in case of errors.

Acked-by: Holger Freyther <holger@freyther.de>
2012-08-30 21:50:30 +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
Pablo Neira Ayuso 81ed759993 ipa: fix missing set of write_cb for IPA client connection
Now the BTS and BSC tests work again.
2012-08-30 21:50:29 +02:00
Holger Hans Peter Freyther 9e8f1c0362 doc: Describe the optional 'stats' parameter 2012-07-21 00:09:52 +02:00
Holger Hans Peter Freyther 36bac9a8b1 doc: Add a newline to fix the documentation of the HSL option 2012-07-20 23:49:52 +02:00
Diego Elio Pettenò 56855350e9 build: build libosmotrau.la in the src directory.
This spares us another recursion, and allows a much higher
parallelisation, since trau is only one source unit and one standalone
library.

Incidentally, also make sure that the version specification for
libosmoabis is applied.

Signed-off-by: Diego Elio Pettenò <flameeyes@flameeyes.eu>
2012-07-01 07:40:36 +02:00
Diego Elio Pettenò 05819cebc4 build: avoid using a convenience library for the input subdirectory.
automake is well capable of building sources present in sub-directory
without requiring a recursion, so there is no reason to use a
non-installed library just for the extra files.

Signed-off-by: Diego Elio Pettenò <flameeyes@flameeyes.eu>
2012-07-01 07:40:36 +02:00
Diego Elio Pettenò 62f0e0612a build: use LT_INIT([pic-only]) instead of forcing -fPIC in AM_CFLAGS.
Also contextually remove the AC_PROG_LIBTOOL call (which is an
obsolete name for what is now LT_INIT).

Signed-off-by: Diego Elio Pettenò <flameeyes@flameeyes.eu>
2012-07-01 07:40:35 +02:00
Harald Welte 36a85a41b0 ipaccess: hex-dump message in case ops->sign_link() returns an error 2012-03-18 18:46:23 +01:00
Holger Hans Peter Freyther df78e92596 osmo-ortp: Prefix oRTP messages with osmo-ortp
When many applications write to the stdout it is not clear that
'network_error' comes from osmo-bts due the usage of oRTP. At least
provide a hint that oRTP is involved.
2012-02-04 19:01:36 +01:00
Andreas Eversberg a659f4827e Fixed TRAU frame handling of packet lengths that are not a multiple of 4 2012-01-18 19:07:30 +01:00
Andreas Eversberg 4308667a25 Fixed wrong reference while opening mISDN socket 2012-01-18 19:06:12 +01: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 d73c84670b mISDN input: avoid some strange distortion caused by buffer mgmt
We used to write as many messages as we received from mISDN for
b-channels.  Now we write as many _bytes_ as we have received, which
seems to be the more logical thing to do.
2011-12-20 18:56:42 +01:00
Holger Hans Peter Freyther e194cd92a8 ipa: The message claims to close the socket but it remains open.
Correct the 'closing socket' statement. It would be nice to know
why this message has been discarded but I can't answer that right now.
2011-11-07 13:37:56 +01:00
Harald Welte 0b5ffc1788 osmo_ortp: include ortp/port.h for the memory management functions 2011-10-22 15:58:02 +02:00
Harald Welte 43f4e08841 depend on new libosmocore 0.3.10 (lapd) and increment LIBVERSION 2011-10-10 08:49:01 +02:00
Andreas Eversberg 8aaed05e21 Length check of LAPD messages to prevent overflows on corrupt frames 2011-10-01 04:10:57 +02:00
Andreas Eversberg d88c5bf637 Fixed missing T203 in profiles 2011-09-30 03:41:44 +02:00
Andreas Eversberg 3c46044cf1 Addition to last commit 2f5a3714075882ac946536709ac581453b6ad52a 2011-09-29 01:31:20 +02:00
Andreas Eversberg 3744b873e5 LAPD profiles are globally defined structures
The pre-defined structures can be used as a profile, as well as own
defined or modified versions of them.
2011-09-29 01:31:20 +02: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 fe05cf5b39 DAHDI: add information on span number, timeslot count to VTY 2011-09-26 23:18:41 +02:00
Harald Welte 494f290f6b DAHDI: remove unused variable 2011-09-26 23:06:49 +02:00
Harald Welte 0cf5514616 DAHDI: Print error message in case config uses non-existing span 2011-09-26 23:06:18 +02:00
Harald Welte e2bd68575f DAHDI: make sure the first e1_line N port start with number 0 2011-09-26 23:03:12 +02:00
Harald Welte 356918fed4 fix parsing error during "e1_line N port M"
A misplaced comma in the DEFUN macro argument list resulted in
part of the help message becoming part of the command syntax ;)
2011-09-26 22:58:07 +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
Daniel Willmann a0d9331cb1 ipa: Add a callback to detect if the server_conn was closed 2011-09-19 03:00:43 +02:00
Daniel Willmann dc4479f27d ipa: Fix resource leak if we encounter an error in ipa_server_conn_read
In case of a connection reset or protocol error we should destroy the
connection as well.
2011-09-19 03:00:26 +02:00
Pablo Neira Ayuso 218bb8f31e ipa: use DEBUG level instead of NOTICE for debugging log messages
Use DEBUG instead of NOTICE for several messages that are actually
used for debugging purposes.
2011-09-09 02:35:45 +02:00
Pablo Neira Ayuso 32c883a96f ipa: better log error messages for ipa_msg_recv()
More descriptive errors help to debug problems.
2011-09-09 02:35:45 +02:00
Pablo Neira Ayuso 2220a0542c ipa: fix segfault in ipa_client_conn_create if no E1 timeslot is specified
Fix segfault if IPA client is not used as signalling link (in that
case E1 timeslot is NULL).
2011-09-09 02:35:45 +02:00
Pablo Neira Ayuso 8ad30c96d4 ipa: use default write callback in ipa_client_conn_create if not specified
If no write callback is specified, use the default write callback.
Thus, we don't need to export ipa_client_write_default_cb.

No clients of this function outside libosmo-abis, so no breakages should
be expected.
2011-09-09 02:35:45 +02:00
Pablo Neira Ayuso f099567ae3 ipa: rename all reference to ipa_*_peer to ipa_*_conn
This patch is a cleanup. It renames several function from _peer
to _conn which seems to me like a more logical name.

There are no clients of this code out of the libosmo-abis tree
so far, so this shouldn't break anything.
2011-09-09 02:35:35 +02:00
Pablo Neira Ayuso 00af772339 ipa: remove bogus driver_name parameter from ipa_client_create
This parameter is not required since the line that we pass as
parameter already has one driver attached.
2011-09-09 02:35:32 +02:00
Harald Welte 65a50893d5 add osmo_rtp_socket_set_param() and osmo_rtp_socket_log_stats() 2011-09-08 14:42:58 +02:00
Harald Welte fcb1fe8c62 libosmo-trau: doxygen documentation 2011-09-07 11:51:52 +02:00
Harald Welte 9b737df611 osmo_ortp: introduce POLL mode for rtp sockets
This bypasses the osmo_fd integration and will allow a RTP socket to be
in pure polling mode, triggered by the consumer of the payload data.
2011-09-07 00:59:11 +02:00
Harald Welte 41d0d84fd6 add 'libosmotrau' for TRAU/RTP related code
This new library is intended to include everything related to
interfacing actual voice channels either via E1 or via RTP.

The first module in the library is osmo_rtp, based on the ortp library.
2011-09-03 15:33:24 +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 f350e25394 lapd: stop timers in lapd_instance_free() 2011-08-26 07:55:26 +02:00
Harald Welte cfc9f1f7cc DAHDI: Make sure dahdi_e1_setup() can be called multiple times
In case we have multiple BTS attached to the same E1 line, the
e1inp_driver::line_update() function will be called multiple times,
and we need to make sure this is handled gracefully.
2011-08-24 09:48:00 +02:00
Harald Welte 14078eaffe LAPD: Add function to release/free a LAPD instance 2011-08-24 09:45:11 +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 ce307b4420 mISDN: optionally bypass kernel LAPD code and use userspace LAPD
The problem with kernel LAPD mainly is that you can only have one
signalling timeslot in each E1 line/interface.  However, with many BTS
attached to the same line, we need multiple signalling slots per line.

This allows the user to have a per-line selection between kernel-LAPD
(misdn) and userspace-LAPD (misdn_lapd) drivers in the config file.
2011-08-21 13:03:24 +02:00
Harald Welte 6341aa0595 mISDN: use 'struct value_string' instead of local copy
Apparently value_string was not part of libosmocore when the code was
written originally...
2011-08-21 12:15:08 +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
Harald Welte 2f69b890bc trau_frame: Add doxygen documentation 2011-08-21 11:13:50 +02:00
Harald Welte e4ec40a365 subchan_demux: add doxygen documentation 2011-08-21 11:07:20 +02:00
Dieter Spaar aa4942440a TRAU: Properly initialize idle frames
This is particularly important in case of the Nokia BTS, as they seem
to drop the RF/signalling channel if they don't get proper TRAU
frames.
2011-08-21 10:49:31 +02:00
Harald Welte bc25bcaea1 ipa: export ipaccess_rcvmsg_base() and return int 2011-08-19 22:32:38 +02:00
Harald Welte 7b6fc2e480 ipaccess: make some functions static that shouldn't be exported 2011-08-19 22:00:38 +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
Harald Welte 94aebf983f ipa: remove unused 'proto' variable 2011-08-19 13:34:12 +02:00
Harald Welte 4301c370c0 ipa: fix compiler warning about ssize_t / socklen_t 2011-08-19 13:33:16 +02:00
Harald Welte 3e1d84b3e0 hsl: use PRIx64 / inttypes.h for uint64_t format string 2011-08-19 13:32:18 +02:00
Harald Welte b3f06dac2b hsl: remove unsued 'proto' variable 2011-08-19 13:28:59 +02:00
Harald Welte d4f8f68e16 add string.h include to fix compiler warning 2011-08-19 13:28:48 +02:00
Pablo Neira Ayuso 6f35d108e5 ipaccess: don't close the signalling link if we receive bad OML/RSL message
Instead, propagate the error to upper layers. This fixes a segfault
in the BSC if bad OML/RSL message is received.
2011-08-17 23:36:11 +02:00
Pablo Neira Ayuso a54269c81e ipaccess: fix segfault if bsc port already in used
This patch fixes a segfault if we try to bind to an already
busy port, it can be easily reproduced with:

$ test/./e1inp_ipa_bsc_test &
<0003> ipaccess.c:830 enabling ipaccess BSC mode
<0000> e1inp_ipa_bsc_test.c:241 entering main loop
$ test/./e1inp_ipa_bsc_test
segfault
2011-08-17 23:23:21 +02:00
Pablo Neira Ayuso 2bbaddfe81 e1_input: fix missing registration of dahdi driver
This patch fixes the registration of the dahdi driver. We were
using conditional compilation (HAVE_DAHDI_USER_H) which we don't
use anymore.
2011-08-17 10:23:09 +02:00
Pablo Neira Ayuso de668910d6 src: replace S_INP_* signals by S_L_INP_* according to naming policy 2011-08-16 17:26:23 +02:00
Harald Welte 95e5decb79 DAHDI: Actually increment e1_input related rate counters 2011-08-16 14:41:32 +02:00
Harald Welte dd0c2ef7f3 E1 Input: better names for rate counters 2011-08-16 14:37:54 +02:00
Harald Welte f2737fcd64 E1 Input: Add rate counters for events related to E1 lines 2011-08-16 14:35:34 +02:00
Harald Welte 6e37c591f9 E1 Input: Move 'show e1_*' command to e1_input_vty.c 2011-08-16 14:20:37 +02:00
Harald Welte 601a9c7d32 E1 Input: Add VTY command to specify the name of a Line
So far, there was no way to set the line->name field at all.
2011-08-16 14:18:53 +02:00
Pablo Neira Ayuso 31fe5f2ef8 LAPD: Propagate lapd_receive() errors to the E1 driver
Scenario: BTS are configured and working, then the BSC stops working
for some reason (crash or administrative stop).

If the BSC comes back to life, LAPD among other things does not know
about the previous existing TEIs. Instead of ignoring these frames,
we notify the driver that we are seeing frames with unknown TEIs, so
it can try to recover, e.g. by resending the SABM message.
2011-08-16 14:12:33 +02:00
Harald Welte 4ca16c779e LAPD: Use proper log levels and prefix all messages with LAPD 2011-08-16 14:04:11 +02:00
Harald Welte 1ef2457fba LAPD: Remove all calls to 'assert' from the code
For a system-level daemon, no protocol parser error should ever call
assert, which would take down the entire process.
2011-08-16 13:51:07 +02:00
Harald Welte f3ca61c5cd DAHDI: Fix case where we have multiple E1 ports/cards (spans)
DAHDI creates one device node for every E1 timeslot, starting from '1',
and keeps incrementing that number even for additional ports/cards.

Thus, we have to use the e1inp_line number multiplied by 31 as a base.
2011-08-16 13:46:06 +02:00
Harald Welte 40b0e8cd0e don't use DLRSL, as it will be removed 2011-07-21 16:57:34 +02:00
Harald Welte cc2241bf1c update to comply with libosmocore namespace fixes
This updates the code and brings it in sync to
libosmocore git commit 892e621fec571c7cba3573caa0d328ed1b25d8ee
2011-07-19 16:06:06 +02:00
Harald Welte 71d87b2597 talloc: revert to use talloc inside libosmocore
It's not a good idea to confuse the two changes with each other.  Moving the
Abis part into a separate library is independent from the question whether we
have talloc inside libosmocore or use a stand-alone talloc library.
2011-07-18 14:51:16 +02:00
Pablo Neira Ayuso 495ddb66d8 ipaccess: hack to get openBSC's ipaccess-config tool working
Export one function that we shouldn't, it's a quick way to fix
the ipaccess-config in openBSC.
2011-07-08 21:04:11 +02:00
Pablo Neira Ayuso 34073fbc97 hsl: close socket if we destroy the signalling link
As we do in ipaccess driver, the socket is not useful anymore
if the BSC/BTS decides to close the signalling link.
2011-07-08 20:36:05 +02:00
Pablo Neira Ayuso 88136fc6dd hsl: BTS support
This patch adds the BTS support for the hsl driver.

It includes two examples under the tests/ directory.
2011-07-08 16:21:55 +02:00
Pablo Neira Ayuso db1c8a718b ipaccess: add bugtrag for the RSL link becomes up case
The RSL signal link becomes up for the ipaccess driver is tricky.
If the BSC forgets to use the E1 line used by OML for the RSL
link, we run into trouble.

This patch adds a bugtrap so people don't forget to appropriately
handle this case.
2011-07-08 15:12:03 +02:00
Pablo Neira Ayuso cdd7c78363 hsl: remove unused hsl_setup function
This function lives in openBSC not here.
2011-07-07 20:21:27 +02:00
Pablo Neira Ayuso 3832c4f908 e1_input: add new refcounting scheme to avoid leaking E1 lines
This patch 's/e1inp_line_get/e1inp_line_find/g' since we need this
function name for the new refcounting scheme.

Basically, I have added a new function to clone lines that is used
by the ipaccess driver:

struct e1inp_line *e1inp_line_clone(void *ctx, struct e1inp_line *line);

And two functions to bump and decrement the refcount:

void e1inp_line_get(struct e1inp_line *line);
void e1inp_line_put(struct e1inp_line *line);

This is useful to avoid leaking virtual E1 lines in the ipaccess
case, since we have two sockets for OML and RSL respectively, we
have to release the line *once* both sockets have been closed.

Without this patch, there are cases in which we don't know if it's
time to release the virtual E1 line.

This patch also includes a fix to avoid crashing if we open a
connection with OML/RSL port without sending any ID_RESP message
(in that case, we have no chance to set the signal link). I tested
these situations with netcat.
2011-07-07 19:33:24 +02:00
Pablo Neira Ayuso 466c5467e2 ipaccess: close connection if we receive bad messages from BTS
If we receive bad messages from the BTS, we close the connection.
I think this is a more robust behaviour.
2011-07-07 19:19:54 +02:00
Pablo Neira Ayuso eb43413013 ipaccess: skip further processing for ping, pong and id_req messages 2011-07-07 19:19:46 +02:00
Pablo Neira Ayuso d2fba90c13 ipaccess: release virtual E1 line for closed connection
We fix a leak in the ipaccess_drop(...) path where we were missing
the release of the cloned E1 line for this OML/RSL links
2011-07-07 17:42:07 +02:00
Pablo Neira Ayuso 9621b41cf6 ipaccess: don't forget to release temporary RSL socket
We have to release the temporary RSL in case that the socket is
closed and we have no chance to attach it to the OML link.
2011-07-07 16:19:21 +02:00
Pablo Neira Ayuso 262aee80ac src: add e1_input_vty.c to libosmo-abis
This file provides the VTY interface for E1 lines, I have moved
it to libosmo-abis since it belongs here.
2011-07-05 19:17:08 +02:00
Pablo Neira Ayuso b9ed7e3145 ipaccess: fix write path for OML/RSL message from BSC -> BTS
This patch fixes the write path for OML/RSL messages. I broke
this while trying to support the delivery of IPA CCM messages
using this path, which is not useful since they are directly
delivered by means of the file descriptor.

This patch fixes the corruption of messages leaving the BSC.
2011-07-05 18:31:59 +02:00
Pablo Neira Ayuso a20762ab72 src: use signal infrastructure that will be available in libosmocore
This is still not in mainline yet, it's in a separate patch that
I expect to send to Harald soon.
2011-07-05 18:27:33 +02:00
Pablo Neira Ayuso fe8ab0af7a logging: use new harald's logging infrastructure in libosmocore
I can send patches to improve it later, better not to waste
much time at it by now so port libosmo-abis upon it.
2011-07-05 16:38:16 +02:00
Pablo Neira Ayuso 62d345a6ef ipaccess: fix ID_RESP parsing in BSC mode 2011-07-05 16:37:37 +02:00
Pablo Neira Ayuso 3e86c6be0e ipaccess: remove any reference to deprecated msg->trx
We plan to use msg->dst instead.
2011-07-05 16:03:37 +02:00
Pablo Neira Ayuso dbd82fb5b1 e1_input: change prototype of ->sign_link(...)
This patch removes the struct e1inp_sign_link parameter since this
is already available in the msgb->dst field of the message.
2011-07-05 15:29:23 +02:00
Pablo Neira Ayuso add3ec8477 e1_input: change prototype of close hook in e1inp_driver
This patch changes `close' so we can make the e1inp_event
inside this hook.
2011-07-05 14:59:16 +02:00
Pablo Neira Ayuso 355ce69661 include: export lapd.h since openBSC needs it
More specifically, the unfinished ericsson rbs2000 BTS.
2011-07-05 14:53:37 +02:00
Pablo Neira Ayuso 0b9ed9a389 dahdi: fix driver compilation
Now dahdi driver compiles file. We force the compilation of this
driver, I prefer to avoid condition compilation options that tend
add problems IMO.
2011-07-02 17:25:19 +02:00
Pablo Neira Ayuso cd8d2e5f30 input: close socket if no signal link was created
If the ->sign_link_up callback does not returns (or if it's
NULL) a valid new signal link, we inmediately close the
socket.

If no signal link is set, there is nothing we can do with
this socket, so keeping it open is useless otherwise.
2011-07-02 17:05:21 +02:00
Pablo Neira Ayuso dfafe68a05 ipaccess: put the ID_GET logic for the BTS mode into the driver
This patch moves the ID_GET logic from the example file to the
ipaccess driver in BTS mode.
2011-07-02 14:32:32 +02:00
Pablo Neira Ayuso c9c4fd3905 major updates in e1_input callback ops and IPA infrastructures
This patch is a major update of the callback infrastructure, now
the e1input_ops looks like the following:

struct e1inp_sign_link *        (*sign_link_up)(void *unit_info, struct e1inp_line *line, enum e1inp_sign_type type);

void    (*sign_link_down)(struct e1inp_line *line);

int     (*sign_link)(struct msgb *msg, struct e1inp_sign_link *link);

The sign_link_up and sign_link_down will be used by the A-bis over IP
input drivers.

The sign_link_up callback is used if we receive a ID_RESP message, in
that case, we have to set up the sign link for the corresponding new
OML/RSL signal link. The pointer to unit_info provides a data structure
that contains the BTS device details if we run as BSC, and the requested
device information from the BSC if we run as BTS. The sign_link_up
callback must return the new sign_link created.

The sign_link_down callback is invoked if the line does down, which
means that the counterpart has closed the socket.

The sign_link callback is used to handle all RSL/OML messages.

I have also added the following callback to the e1inp_driver:

+       void (*close)(struct e1inp_ts *ts);

Which is invoked if you call e1inp_sign_link_destroy(). This callback
is used to close the socket that is linked to that timeslot. This is
useful for A-bis over IP drivers since sockets are closed if the
OML/RSL signalling link is destroyed.

As you can notice, I have also added all the ID_RESP parsing into
libosmo-abis for both ipaccess and hsl drivers.

This patch also contains a rework of the ipa_client_link whose
integration with the e1_input infrastructure was broken (the
transmission path was broken).

This patch also contains more develop examples that act as BSC
and BTS for the ipaccess driver.

Sorry, I know it would be better to split all these changes into
logical pieces but many of them are tightly related.

This is under heavy development stage, it's anyway hard to track
changes until this becomes more stable.
2011-06-30 12:19:42 +02:00
Pablo Neira Ayuso 59301856f6 ipaccess: use E1INP_SIGN_OML instead of hardcoded 1
This patch is a minor cleanup.
2011-06-27 15:44:23 +02:00
Pablo Neira Ayuso 8e479aece2 ipaccess: fix RSL link establishment
This patch fixes the RSL link establishment which made openBSC port
over libosmo-abis crash.
2011-06-27 15:19:11 +02:00
Pablo Neira Ayuso 93c620107e ipaccess: fix write path for OML socket
We have to use e1i_ts->driver.ipaccess.fd file descriptor to
fix the write path. Otherwise, openBSC never delivers replies
to OML messages.
2011-06-26 19:23:24 +02:00
Pablo Neira Ayuso ff66363716 ipaccess: add msg->trx to reduce the size of the openbsc-port patch
This is a temporary change to keep the openbsc port over libosmo-abis
smaller. We'll remove it at some point once we fully transition to
the new msg->dst routing attribute.
2011-06-26 19:10:56 +02:00
Pablo Neira Ayuso 96e7263c85 e1_input: add abis_sendmsg(...)
This patch adds generic abis_sendmsg to send NM messages (both OML and RSL).

abis_rsl_sendmsg(...) is basically the same, we'll remove it from
libosmo-abis once we can propagate changes to openbsc.
2011-06-26 19:08:05 +02:00
Pablo Neira Ayuso 70ef10c724 e1_input: remove unused function ipaccess_connect()
This function should live in openbsc instead.
2011-06-25 18:50:54 +02:00
Pablo Neira Ayuso f163d23bf6 e1_input: minor API changes to adapt it to openbsc
While working on the openbsc over libosmo-abis port, I noticed
several API changes that we need to perform for better adaptation.
2011-06-25 18:42:55 +02:00
Pablo Neira Ayuso 130c4fbe2e ipa-proxy: add A-bis over IP generic proxy commands for VTY
This patch adds VTY commands to route IPA flows. The following
example allows to add a new route:

$ tests/./ipa_proxy_test &
<0000> ipa_proxy_test.c:74 entering main loop
$ telnet localhost 4260
ipa-proxy-test> enable
ipa-proxy-test# ipa instance input-oml bind 127.0.0.1 tcp port 8888
ipa-proxy-test# ipa instance output-oml connect 127.0.0.1 tcp port 3002
ipa-proxy-test# ipa route instance input-oml streamid 0xfe instance output-oml streamid 0xfe
ipa-proxy-test# ipa instance input-rsl bind 127.0.0.1 tcp port 8889
ipa-proxy-test# ipa instance output-rsl connect 127.0.0.1 tcp port 3003
ipa-proxy-test# ipa route instance input-rsl streamid 0xfe instance output-rsl streamid 0xfe

I'm using this to initially test this code [*].

[*] note that this requires a minor hackish patch for the
src/input/ipaccess.c driver which changes the default OML and RSL
ports to listen in 8888 and 8889 instead of the default ports,
thus, I can initially test everything from the localhost.
2011-06-23 22:15:45 +02:00
Pablo Neira Ayuso af3fed9213 ipa: add ipa_*_send() to transmit messages
This patch adds ipa_*_send() functions to transmit messages
using the new A-bis over IP infrastructure.

This patch completes the transmission path support for the A-bis
over IP infrastructure.
2011-06-23 22:15:22 +02:00
Pablo Neira Ayuso 6af9b61a48 ipa: add ipa_server_peer infrastructure
This patch adds the ipa_server_peer abstraction which provide
helpers for the accept path of ipa_server_link.
2011-06-23 14:07:47 +02:00
Pablo Neira Ayuso e009f4a009 ipa: extend ipa_*link_create() to take one generic data pointer
With this patch we can attach generic data to some IPA link. This
will be useful for the IPA proxy support.
2011-06-23 13:36:34 +02:00
Pablo Neira Ayuso af8ed983ff ipaccess: remove dead code from ipaccess adriver
This patch removes some dead code in the ipaccess driver
2011-06-21 20:35:27 +02:00
Pablo Neira Ayuso 986191fadf ipa: add ipa_server_link abstraction
This patch adds the ipa_server_link which allows to create
IPA servers.

I have also changed the ipaccess driver to use it. Still
missing the port of HSL driver.
2011-06-21 19:56:26 +02:00
Pablo Neira Ayuso c07a8e7cf7 ipa: rename `struct ipa_link' by `struct ipa_client_link'
And IPA_LINK_STATE_* by IPA_CLIENT_LINK_STATE_* to prepare
the addition of the ipa_server_link abstraction.
2011-06-21 19:50:04 +02:00
Pablo Neira Ayuso 591ddadbe8 ipaccess: initial works to get BTS mode working
This patch adds the initial support to get BTS mode working with
the ipaccess driver.

Now, the driver handles IPA ping, pong and id_ack messages
internally in BTS modes, and it passes the signalling messages
to the client application by invoking the callback line operations.

Moreover, with this patch, each IPA link object always has one
E1 line object associated.

Still HSL BTS-mode remains unimplemented.
2011-06-21 18:16:42 +02:00
Pablo Neira Ayuso 29465d35fc ipaccess: create RSL socket in BTS mode
With this patch, we create the RSL socket in BTS mode.

This patch also fixes a crash if the RSL socket goes down
before we have set the RSL line via OML with the existing
code.
2011-06-21 14:21:33 +02:00
Pablo Neira Ayuso 7a24940805 input: use generic ipa_msg_recv() instead of ipaccess_read_msg()
We use the new generic function to receive messages, instead of
ipaccess_read_msg.

It's a mere renaming, but it's the first step before the rework
that will happen soon to avoid calling read() twice.
2011-06-21 14:15:46 +02:00
Pablo Neira Ayuso 9b3a33cba9 hsl: add support for BTS-mode
This patch adds support for BTS-mode for the hsl input driver.
2011-06-21 13:52:41 +02:00
Pablo Neira Ayuso c00ee7399d e1input: add address as parameter to e1inp_line_update(...)
This patch adds a new parameter to e1inp_line_update that allows to
specific the address for A-bis over IP BSC/BTS.
2011-06-21 12:22:49 +02:00