Commit Graph

4429 Commits

Author SHA1 Message Date
Jacob Erlbeck 84a45cbf83 mgcp/test: Add test cases for transcoding and repacking
This patch adds test cases for transcoding and repacking.

Sponsored-by: On-Waves ehf
2014-06-05 14:08:53 +02:00
Jacob Erlbeck 07886d9b0a mgcp: Extend the CLI transcoding tool by ptime conversion
This modification allows it to set the number of samples per packet
that is written to the output.

Sponsored-by: On-Waves ehf
2014-06-05 14:08:53 +02:00
Jacob Erlbeck 42a833e89f mgcp: Add packet size (ptime) conversion
The current transcoder implemenation always does a 1:1 recoding
concerning the duration of a packet. So RTP timestamps and sequence
numbers are not modified.

This is not sufficient in some cases, e.g. when the BTS does only
allow for a single fixed ptime.

This patch decouples encoding from decoding and moves the decoded
samples to the state structure so that samples can be combined or
drain according to the packaging of incoming and outgoing packets.

This patch incorporates parts of Holger's experimental fixes in
0e669e05^..9eba68f9.

Ticket: OW#1111
Sponsored-by: On-Waves ehf
2014-06-05 14:08:45 +02:00
Jacob Erlbeck 136a319e91 mgcp: Add CLI tool to test audio conversion
This tool uses mgcp_transcode.c to convert audio data from stdin to
stdout.

Sponsored-by: On-Waves ehf
2014-06-05 14:00:47 +02:00
Jacob Erlbeck 239a853f40 mgcp: Add RTP audio transcoding
This patch implements audio transcoding between the formats GSM,
PCMA, L16, and optionally G.729.

The feature needs to be enabled by using the autoconf option
'--enable-mgcp-transcoding'. In this case mgcp_transcode.c will
be compiled and linked to osmo-bsc_mgcp, and the transcoding
functions provided will be registered as processing callbacks.

If G.729 support is required, libcg729 needs to be installed and
'--with-g729' must be passed to ./configure.

Ticket: OW#1111
Sponsored-by: On-Waves ehf
2014-06-05 14:00:47 +02:00
Jacob Erlbeck 997e1e8e9d mgcp: Only include SDP lines with valid content
Don't show media related lines if the payload type has not been set.
Don't show a 'a=rtpmap' line if the audio_name has not been set.

This patch unifies the SDP generation of create_response_with_sdp()
and send_msg().

Sponsored-by: On-Waves ehf
2014-06-05 14:00:46 +02:00
Jacob Erlbeck 168ca00b02 mgcp: Add a function to get media info for MGCP responses
This patch adds the get_net_downlink_format_cb() callback to provide
payload_type, subtype_name, and fmtp_extra suitable for use in a MGCP
response sent to the network. Per default, the BTS side values are
returned since these must be honoured by the net peer when sending
audio to the media gateway (unless transcoding is done).

Sponsored-by: On-Waves ehf
2014-06-05 14:00:46 +02:00
Jacob Erlbeck 845d0054b4 mgcp: Add audio info fields to struct mgcp_rtp_end
This patch adds the fields channels, subtype_name, and audio_name to
the struct. The field audio_name contains the full string that has
been used for the last part of a SDP a=rtpmap line. The others contain
decoded parts of that string. If no a=rtpmap line has been given
(e.g. because dynamic payload types are not used), values are
assigned when the payload type matches one of the predefined ones
(GSM, G729, PCMA).

The patch also moves the audio_name parsing code to a dedicated
set_audio_info() function.

Sponsored-by: On-Waves ehf
2014-06-05 14:00:41 +02:00
Jacob Erlbeck a0d64ce063 mgcp: Add callbacks for payload processing
This patch adds the callbacks rtp_processing_cb and
setup_rtp_processing_cb to mgcp_config to support arbitrary RTP
payload processing.

Sponsored-by: On-Waves ehf
2014-06-05 12:19:46 +02:00
Jacob Erlbeck b492d39177 gprs: Separate LLC parsing from LLC state handling
Currently LLC parsing is part of gprs_llc.c which needs large parts
of the SGSN code parsing to fulfill its link dependencies.

This patch moves the functions that just do plain parsing, dumping,
and FCS computation to a different file to avoid these dependencies
if LLC stateful processing is not needed. It also exposes
struct gprs_llc_hdr_parsed and enum gprs_llc_cmd publically.

Sponsored-by: On-Waves ehf
2014-06-04 16:29:30 +02:00
Jacob Erlbeck def0391ec5 gprs/test: Use valid MCC/MNC for BVC RESET
The code currently uses an encoded sequence of (hex) 10 20 30 40 50
60 as RAI, for which no bijective mapping to the set of
representations MCC-MNC-LAC-RAC exists.

This patch changes the hard-coded RAI to 11 22 33 40 50 60 which maps
to 112-332-16464-96 (and vice-versa).

Sponsored-by: On-Waves ehf
2014-06-04 16:20:46 +02:00
Holger Hans Peter Freyther cc84c9535c osmux: Fix the VTY online help in the osmux command
This should fix most of:

Documentation error (missing docs):
<command id='osmux (on|off)'>
        <param name='off' doc='(null)' />

Documentation error (missing docs):
<command id='osmux batch-factor &lt;1-4&gt;'>
        <param name='&lt;1-4&gt;' doc='(null)' />

Documentation error (missing docs):
<command id='osmux (on|off)'>
        <param name='off' doc='(null)' />

Documentation error (missing docs):
<command id='osmux (on|off)'>
        <param name='off' doc='(null)' />

Documentation error (missing docs):
<command id='osmux batch-factor &lt;1-4&gt;'>
        <param name='&lt;1-4&gt;' doc='(null)' />
2014-06-03 13:36:42 +02:00
Holger Hans Peter Freyther 889710c890 Merge branch 'hfreyther/fixes/channel-release-handling'
The patches were posted to the ML but didn't receive review
there. At the time I merge the change I did a Location Updating
Request and the channel was released in a successful way.
2014-06-03 13:25:02 +02:00
Holger Hans Peter Freyther 0e4e73a891 rsl: Check if the channel is active and then start the channel release
In case we receive ERROR INDICATION and CONNECTION FAILURE we only
want to RF Channel Release the lchan once. This code is more simple
and should work as reliable as the previous commit.
2014-06-03 12:51:16 +02:00
Holger Hans Peter Freyther 1e93b79cce rsl: Avoid double channel release procedure in error conditions
When we receive an ERROR INDICATION and CONNECTION FAILURE we
might call rsl_rf_chan_release multiple times. The channel release
handling is still a bit messy and there too many paths that lead
to the call.

1.) In case we receive an ERROR INDICATION for SAPI=3. A RLL
error signal will be emitted that leads to the release of the
channel through the SMS code in case of the NITB.  The call to
rsl_rf_chan_release might be a double release.

2.) In case a CONNECTION FAILURE is received when the release
process has already been started we would unconditionally
call rsl_rf_chan_release as well.

Because the lchan state is changed by the callers of the
rsl_rf_chan_release we can not move the state checking into this
code but need to do it in the caller. The issue was seen in a trace
from Rhizomatica and I created the DoubleRelease.st to re-produce
the issue and verified that we have no duplicate RF Channel Releses.

The other option would be to introduce a new state to track
the release process and see if we have already released SAPIs
deactivated the SACCH or such. We can not simply look at these
as for a channel that fails to activate they will be null already.
2014-06-03 12:51:16 +02:00
Holger Hans Peter Freyther f0405068d8 lchan: Speculative "fix" for error and late reply
Looking at the code it seemed possible that a channel would
transition from BROKEN to NONE. Or worse from NONE to BROKEN.
Start the timer _after_ the channel has been released.
2014-06-03 12:51:16 +02:00
Holger Hans Peter Freyther 5308fffc53 bsc: Introduce a local notification scheme for the CTRL interface
Make it possible to inform local CTRL connections about some state.
The TRAP will be only sent to local connections. The notification
text may not contain spaces.
2014-05-31 08:42:29 +02:00
Holger Hans Peter Freyther 4f0381b1c3 mgcp: Address scanf issue already found by cppcheck and now ASAN
Use the right size for scanf.

=================================================================
==6106== ERROR: AddressSanitizer: unknown-crash on address 0xbffff4b0 at pc 0xb69d87fd bp 0xbffff248 sp 0xbffff21c
WRITE of size 65 at 0xbffff4b0 thread T0
    #0 0xb69d87fc (/usr/lib/i386-linux-gnu/libasan.so.0.0.0+0xa7fc)
    #1 0xb69d9239 (/usr/lib/i386-linux-gnu/libasan.so.0.0.0+0xb239)
    #2 0xb69d92d6 (/usr/lib/i386-linux-gnu/libasan.so.0.0.0+0xb2d6)
    #3 0x804f151 (/home/ich/source/gsm/openbsc/openbsc/tests/mgcp/mgcp_test+0x804f151)
    #4 0x80531e8 (/home/ich/source/gsm/openbsc/openbsc/tests/mgcp/mgcp_test+0x80531e8)
    #5 0x8051e6f (/home/ich/source/gsm/openbsc/openbsc/tests/mgcp/mgcp_test+0x8051e6f)
    #6 0x8049b0a (/home/ich/source/gsm/openbsc/openbsc/tests/mgcp/mgcp_test+0x8049b0a)
    #7 0x804bd9e (/home/ich/source/gsm/openbsc/openbsc/tests/mgcp/mgcp_test+0x804bd9e)
    #8 0xb6778a62 (/lib/i386-linux-gnu/i686/cmov/libc-2.18.so+0x19a62)
    #9 0x8049330 (/home/ich/source/gsm/openbsc/openbsc/tests/mgcp/mgcp_test+0x8049330)
Address 0xbffff4b0 is located at offset 416 in frame <parse_sdp_data> of T0's stack:
  This frame has 8 object(s):
    [32, 36) 'audio_payload'
    [96, 100) 'payload'
    [160, 164) 'channels'
    [224, 228) 'ptime'
    [288, 292) 'port'
    [352, 368) 'ipv4'
    [416, 480) 'audio_name'
    [512, 576) 'audio_codec'
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
      (longjmp and C++ exceptions *are*
2014-05-28 17:00:56 +02:00
Holger Hans Peter Freyther b691bf1d54 channel_test: Return a positive number to claim it was paged
This addresses an ASAN issue where the request was already deleted
by our callback function.

(gdb) where
 #0  0xb69e7810 in __asan_report_error () from /usr/lib/i386-linux-gnu/libasan.so.0
 #1  0xb69e0aff in __asan_report_store4 () from /usr/lib/i386-linux-gnu/libasan.so.0
 #2  0x0804ea64 in subscr_send_paging_request (subscr=subscr@entry=0xb5103cb0)
     at gsm_subscriber.c:212
 #3  0x0804edac in subscr_get_channel (subscr=subscr@entry=0xb5103cb0, type=type@entry=2,
     cbfn=cbfn@entry=0x804969d <subscr_cb>, param=param@entry=0x2342) at gsm_subscriber.c:246
 #4  0x080498f7 in main (argc=1, argv=0xbffff804) at channel_test.c:77

Breakpoint 3, subscr_paging_dispatch (hooknum=hooknum@entry=101, event=event@entry=200,
    msg=msg@entry=0x1323, data=<optimized out>, data@entry=0x8063900 <s_conn>,
    param=<optimized out>, param@entry=0xb5103cb0) at gsm_subscriber.c:126
126		llist_del(&request->entry);

 (gdb) b llist_del
 (gdb) bt
 #0  subscr_paging_dispatch (hooknum=hooknum@entry=101, event=event@entry=200,
     msg=msg@entry=0x1323, data=<optimized out>, data@entry=0x8063900 <s_conn>,
     param=<optimized out>, param@entry=0xb5103cb0) at gsm_subscriber.c:126
 #1  0x0804e8a9 in subscr_paging_cb (hooknum=101, event=200, msg=0x1323,
     data=0x8063900 <s_conn>, param=0xb5103cb0) at gsm_subscriber.c:187
 #2  0x080497e9 in paging_request (bts=0xb5b03e70, subscriber=subscriber@entry=0xb5103cb0,
     type=2, cbfn=cbfn@entry=0x804e881 <subscr_paging_cb>, data=data@entry=0xb5103cb0)
     at channel_test.c:51
 #3  0x0804ea39 in subscr_send_paging_request (subscr=subscr@entry=0xb5103cb0)
     at gsm_subscriber.c:207
 #4  0x0804edac in subscr_get_channel (subscr=subscr@entry=0xb5103cb0, type=type@entry=2,
     cbfn=cbfn@entry=0x804969d <subscr_cb>, param=param@entry=0x2342) at gsm_subscriber.c:246
 #5  0x080498f7 in main (argc=1, argv=0xbffff804) at channel_test.c:77
(gdb) q
2014-05-28 17:00:48 +02:00
Holger Hans Peter Freyther f6b61e6154 mgcp: Use #pragma once instead of a possible clashing #ifdef
The filename is mgcp_internal.h but the define refers to MGCP_DATA.
Avoid having a potential clash by using the #pragma once option.
2014-05-26 08:17:45 +02:00
Holger Hans Peter Freyther ee41ecff98 rsl: Remove obsolete FIXME comment.
The lchan state is set to none either on RF Channel Release ACK
or in case of an error after the error timer has expired.
2014-05-26 08:17:35 +02:00
Holger Hans Peter Freyther 4f200491ff osmux: Fix potential memory leak in the msgb handling 2014-05-22 16:46:11 +02:00
Holger Hans Peter Freyther 1cc5ff8e19 mgcp: Add proper length checking for line handling
In ae1997248c the handwritten tokenizer
was replaced with strtok_r. As part of this change the structural
checking of MGCP parameters was stopped. This means that a code like
"line + 3" might access beyond the first NUL and be possibly behind
the msgb. Manually add size checking again. Manually jumping to the
error label is not possible anymore as it has been removed. The result
is that invalid lines will be skipped. This is matching the general
approach by the IETF RFCs to be permissive in data being received.
2014-05-22 16:46:11 +02:00
Holger Hans Peter Freyther f259bd8359 mgcp: Remove excessive logging for each frame 2014-05-22 14:42:09 +02:00
Pablo Neira Ayuso cab6e7528c mgcp: add voice muxer support
This patch adds the voice muxer. You can use this to batch RTP
traffic to reduce bandwidth comsuption. Basically, osmux transforms
RTP flows to a compact batch format, that is later on decompacted
to its original form. Port UDP/1984 is used for the muxer traffic
between osmo-bsc_nat and osmo-bsc_mgcp (in the BSC side). This
feature depends on libosmo-netif, which contains the osmux core
support.

Osmux is requested on-demand via the MGCP CRCX/MDCX messages (using
the vendor-specific extension X-Osmux: on) coming from the BSC-NAT,
so you can selectively enable osmux per BSC from one the bsc-nat.cfg
file, so we have a centralized point to enable/disable osmux.

First thing you need to do is to accept requests to use Osmux,
this can be done from VTY interface of osmo-bsc_nat and
osmo-bsc_mgcp by adding the following line:

mgcp
  ...
  osmux on
  osmux batch-factor 4

This just initializes the osmux engine. You still have to specify
what BSC uses osmux from osmo-bsc_nat configuration file:

...
 bsc 1
  osmux on
 bsc 2
  ...
 bsc 3
  osmux on

In this case, bsc 1 and 3 should use osmux if possible, bsc 2 does
not have osmux enabled.

Thus, you can selectively enable osmux depending on the BSC, and
we have a centralized point for configuration from the bsc-nat to
enable osmux on demand, as suggested by Holger.

At this moment, this patch contains heavy debug logging for each
RTP packet that can be removed later to save cycles.

The RTP ssrc/seqnum/timestamp is randomly allocated for each MDCX that
is received to configure an endpoint.
2014-05-22 14:39:16 +02:00
Daniel Willmann 038f97a69f bsc_hack: Don't strdup the string arguments
Fixes CIDs #1206577, #1206578
2014-05-22 14:34:24 +02:00
Daniel Willmann 45fcb85236 rtp_proxy: Prevent out-of-bounds read in rtcp_sdes_cname_mangle
In rtcp_sdes_cname_mangle when skipping over additional zeroes at the
end of a chunk we should not read past the actual message (rtcp_end).

Fixes CID #1206579
2014-05-22 14:31:09 +02:00
Harald Welte a4c63b0cdb chan_alloc: Fall-back to TCH/H, if we cannot find a TCH/F
I'm not entirely sure if this is the best approach.  However,
there are phones that send a RACH request for TCH/F on MO calls, even
though they actually do support TCH/H channels.
2014-05-19 08:31:39 +02:00
Harald Welte ec75798644 rtp_proxy.c: Correctly set msg_type to GSM_TCH_FRAME_AMR on AMR
When forwarding AMR from RTP towards the MNCC interface, we need to set
the apropriate msg_type.  Before this patch it was unitialized,
resulting in improper/unknown msg_types of messages on the MNCC
interface.
2014-05-18 22:23:15 +02:00
Harald Welte a87f8f9891 rtp_proxy: Simplify AMR handling
AMR frames on the MNCC interface are slightly different as they
include a single-byte payload_length indicator prior to the actual
payload.  Commit 3f201ac89952b68d05c0bb6cb41932b9cd898b19 introduced
more special-case handling than required, so I'm trying to simplify
things again.

We now also use msgb_put() more consistently, i.e. always put
before actually using the data, and use the return value of msgb_put()
rather than first making assumptions about the pointer, writing to it
and then calling msgb_put().
2014-05-18 22:23:15 +02:00
Andreas Eversberg d8967f76a5 Add support for AMR frames to MNCC/RTP interface
AMR rate is currently fixed to 5.9k.
2014-05-18 22:23:15 +02:00
Andreas Eversberg 72c0dbd753 bsc_api/NITB: If TCH/H channel is used, indicate it to bsc_api
If we don't do this, OsmoNITB will send an assignment command from
a TCH/H to another TCH/H without any need.
2014-05-18 22:23:15 +02:00
Andreas Eversberg a4d0e3cc6b Add check to tch_map(), if RTP sockets exist 2014-05-18 22:23:15 +02:00
Holger Hans Peter Freyther 20f6e946e1 ctrl: Use CTRL_CMD_DEFINE_STRUCT in CTRL_CMD_DEFINE_RANGE
Jacob pointed out that I didn't convert CTRL_CMD_DEFINE_RANGE.
This patch is doing it now.
2014-05-15 17:28:03 +02:00
Holger Hans Peter Freyther b66f158b05 ctrl: Reduce code duplication and add a define to create the struct
This has been pointed out by Jacob and removes two more duplicates
of the struct. For the unused CTRL_CMD_DEFINE_STRING macro there
will be no verify command.
2014-05-15 15:50:55 +02:00
Holger Hans Peter Freyther 6e36255221 ctrl: Remove the param parameter as it was never used/implemented 2014-05-15 15:50:55 +02:00
Holger Hans Peter Freyther 1159005ae0 ctrl: Introduce a macro for read-only attributes and use it
Certain attributes are read-only. Add a macro to make it more
easy to define those.
2014-05-15 15:30:52 +02:00
Jacob Erlbeck 268b2e6544 ctrl: Fix handling of missing replies
Currently, if a CTRL method does not set the reply, an error is
logged ("cmd->reply has not been set"). It even complains when the
function implementing the command returns CTRL_CMD_HANDLED, where
a reply text is not needed.

This patch changes the logging level from ERROR to NOTICE. The logging
is now only done, when the retry has not been set and the
implementation returns either CTRL_CMD_ERROR or CTRL_CMD_REPLY. So
in these cases the reply field must be set.

This fixes the generation of log messages when doing NAT ctrl command
forwarding.

Ticket: OW#1177
Sponsored-by: On-Waves ehf
2014-05-15 14:22:56 +02:00
Holger Hans Peter Freyther 47d8f02c06 misc: Use the right mailinglist address for OpenBSC 2014-05-15 12:26:54 +02:00
Jacob Erlbeck 543e11496e contrib/rtp: Use payload data files directly by gen_rtp_header
This adds a --frame-size option to read payload binary files with a
fixed frame size directly. The file must not contain RTP headers.
In addition '--rate' and '--duration' can be used to configure the
timing.

Sponsored-by: On-Waves ehf
2014-05-09 16:38:28 +02:00
Nikola Kolev 10bad1031e ipa: Fix the compilation of ipaccess-find on FreeBSD
FreeBSD does not offer the SO_BINDTODEVICE option. The closest
thing is the IP_RECVIF option and this is used here now.
2014-05-09 04:40:23 +02:00
Nikola Kolev b9f45987b3 bsc: Fix compilation on FreeBSD
FreeBSD uses POSIX netinet/in.h for representing socket addresses
data types.

[Holger removed the #ifdef and changed the order of includes to
have specific ones first and system includes later]
2014-05-09 04:38:58 +02:00
Holger Hans Peter Freyther abddd6aa44 nat/bsc: Check proto before calling ipaccess_rcvmsg_base
The code in the BSC/NAT called ipaccess_rcvmsg_base without
checking if the protocol is IPA. This lead the BSC to respond
to SCCP messages with an "ID ACK". From a quick look neither
the code of ipaccess_rcvmsg_base in OpenBSC nor the copy of
libosmo-abis ever checked the protocol header. So this code
has been wrong since initially being created in 2010.
2014-05-06 06:50:39 +02:00
Holger Hans Peter Freyther 3c9068f185 db: Fix next fall-out with make distcheck 2014-05-01 07:53:42 +02:00
Holger Hans Peter Freyther f242e7afef db: Fix fall-out with the subscriber removal in the subscriber deletion code
The sender_id is gone so the code that attempted to delete SMS
didn't work anymore. Delete the SMS based on src_addr or the
dest_addr.

Fixes:
======================================================================
ERROR: testSubscriberAddRemove (__main__.TestCtrlNITB)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/ctrl_test_runner.py", line 379, in testSubscriberAddRemove
    r = self.do_set('subscriber-delete-v1', '2620345')
  File "tests/ctrl_test_runner.py", line 114, in do_set
    return self.recv_msgs()[id]
KeyError: 1002
2014-04-30 20:51:28 +02:00
Holger Hans Peter Freyther edfdc9829c Merge branch 'zecke/features/sms-db-changes'
This branch allows a SMPP user to fully specify the sender id. It
requires a change in schema, database migration code and exposed
some issues in the libdbi and the sqlite3 driver.
2014-04-30 15:32:41 +02:00
Holger Hans Peter Freyther 6114401b9b db: Add testcase for the db migration. 2014-04-30 15:31:57 +02:00
Holger Hans Peter Freyther e7cc9aa447 sms: Add code to migrate the database to the new schema
This is mostly based on Alexander's migration code. The code
adds transaction handling and some sanity checks and cleanups
to the code. We made the decision to fork the sms_from_result
method and freeze it to that version. This way sms_from_result
can move forward without having to deal with legacy.
2014-04-30 15:31:57 +02:00
Alexander Chemeris ca7ed2d2df sms: Do not store received id in the SMS database.
That was a bad idea from the very beginning. A visible result of this is a wrong
SMS routing when you change subscriber extensions, while having queued SMS. It's
also a very wrong thing from the code layering perspective.

I think the next logical step should be to remove "receiver" pointer from
the gsm_sms structure into a structure, special for the internal SMS queue.
2014-04-30 15:31:57 +02:00
Holger Hans Peter Freyther 73bc51deea db: Add testcase for storing/loading/comparing a sms
Use the already created subscriber, create a sms and read it
back from the subscriber.
2014-04-30 15:31:57 +02:00