Commit Graph

380 Commits

Author SHA1 Message Date
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
Pablo Neira Ayuso 96e8128061 input: ipaccess: add preliminary BTS-side for A-bis over IP
This patch adds the BTS-side for the ip.access driver for
A-bis over IP communications.

This patch adds one example under test/ so you can test the
existing BSC and BTS sides over ip.access.

Still incomplete, it requires to allow to register some
callback in the BTS side to perform some action once we
receive some message. This will come in next updates.
2011-06-14 18:47:09 +02:00
Pablo Neira Ayuso e19c70a9ed src: add support for logging infrastructure in libosmo-abis
This patch uses the new libosmocore logging infrastructure
that allows to invoke log_init(&my_log_info) multiple times
so we can register categories from libraries and applications.
2011-06-12 15:15:30 +02:00
Pablo Neira Ayuso 0b099b27df include: remove internal definition that are now in libosmocore
Still in one separate patch for libosmocore, but they may become
part of mainline soon.
2011-06-09 13:14:11 +02:00
Pablo Neira Ayuso e47a978942 hsl: use include/abis/ipaccess.h
instead of deprecated include/gsm/protocol/ipaccess.h
2011-06-07 18:03:48 +02:00
Pablo Neira Ayuso 5a4b7c54c6 e1input: rework generic (virtual and real) E1 line operations
struct e1inp_line_ops {
       int     (*sign_link_up)(struct msgb *msg, struct e1inp_line *line);
       int     (*sign_link)(struct msgb *msg, struct e1inp_sign_link *link);
       int     (*error)(struct msgb *msg, int error);
};

The description of the operations is the following:

* sign_link_up is invoked if the signalling link becomes up. In A-bis
over IP, we have to wait until the other peer identifies itself as
a BTS/BSC device, then this function is invoked. This function is not
used by ISDN drivers, the signalling link can be set up just after
the line is created.

* sign_link is called if we receive OML/RSL message. This function
is used both by ISDN and A-bis over IP drivers.

* error is called if we receive a malformed message. It is used both
by ISDN and A-bis over IP drivers.
2011-06-07 17:28:53 +02:00
Pablo Neira Ayuso f0cb2b4a1a e1input: log_set_context(...) should be called from the application
Remove this line, it should be called from the application.
2011-06-07 17:27:46 +02:00
Pablo Neira Ayuso 211d2ca7a1 e1input: fix TRAU frame handling
With this patch, we pass TRAU frames to the callback that
e1inp_ts_config_trau(...) takes as parameter. Instead of passing
it to the line->rx(...) callback. The function
e1inp_ts_config_trau(...) should only be used by ISDN drivers.
2011-06-07 17:15:10 +02:00
Pablo Neira Ayuso 54b4979de6 src: add libosmo_abis_init(void *ctx) to set the talloc context
This function is called during initialization, so we can set what's
the talloc context for the application and the library.
2011-06-07 12:36:42 +02:00
Pablo Neira Ayuso 177094b4c9 src: use include/osmocom/abis instead of include/osmocom/gsm/abis
Harald prefers short paths.

This patch also remove commented includes in several files.
2011-06-07 12:21:51 +02:00
Pablo Neira Ayuso f67471fb7f src: use new socket API in libosmocore
get rid of internal copy of openbsc/libcommon/socket.c, we now
use the new socket API available in libosmocore.
2011-06-07 11:25:49 +02:00
Pablo Neira Ayuso 7b2d18bc4f missing logging header in trau_frame.c 2011-06-05 18:38:43 +02:00
Pablo Neira Ayuso 0ba77d53a9 initial commit of libosmo-abis
still many things to get fixed
2011-06-05 18:32:44 +02:00