Commit Graph

4483 Commits

Author SHA1 Message Date
Holger Hans Peter Freyther cb6ad70994 mgcp: Change API to remove memory management from the name
Jacob pointed out that "free_endp" refers to the memory of
the endpoint being freed. What we want is actually a way to
release an endpoint (and the resource it allocated) or in
the case of the testcase/testapp initialize the data structure
correctly. Introduce two names for that.
2014-07-22 15:00:52 +02:00
Holger Hans Peter Freyther 34a1976d5d Merge commit 'zecke/fixes/mgcp-transcoding'
Include the last bits of fixes for the transcoding code. These fixes
and the appropriate mgcp config are known to work.
2014-07-22 14:48:25 +02:00
Holger Hans Peter Freyther b936278b2e mgcp: Fix/test the case of a time jump and the resync
In case the sender didn't send a couple of frames we will have
a time gap that is bigger than the accepted delta. Add a new
testcase for this and update the next_time.
2014-07-22 14:48:07 +02:00
Holger Hans Peter Freyther 4c18d79475 mgcp: Add a testcase for 160->80 ptime handling 2014-07-22 14:48:07 +02:00
Holger Hans Peter Freyther c8b29083d2 mgcp: Initialise next_time in case the initial timestamp is not 0. 2014-07-22 14:48:07 +02:00
Holger Hans Peter Freyther bd4109babc mgcp: Document transcoding semantic and follow it
Transcoding from GSM to PCMA can lead to the MGCP MGW sending
two PCMA packages with the same sequence number and timestamp.
Once with the encoded audio and once completely empty.

This is because "state->dst_packet_duration" is 0 in most cases
(unless a ptime is forced) and we attempt to encode audio even
if there are not enough samples. The encode_audio return will
return 0 in that case which is not trated as an error by the
mgcp network code.

Handle rc == 0 specially and document the semantic.
2014-07-22 14:42:53 +02:00
Holger Hans Peter Freyther 91eeeae312 mgcp: Fix/test reading/writing the sequence number
The sequence number was read from the wrong place and then
the wrong byte order conversion routine was used so we ended
up wirting 0x00, 0x00 into the patched sequence number. Add
a testcase for that.
2014-07-22 14:31:35 +02:00
Holger Hans Peter Freyther 1fc1ed23b2 mgcp: Patch and Count _after_ the transcoding
When going from a ptime of 10 to 20 a lot of alignment errors
are reported. In fact the alignment check should be done before
and after the transcoding. As this is not possible right now
only do it _after_ the patching.
2014-07-22 14:31:28 +02:00
Holger Hans Peter Freyther 77ceaaf7f5 mgcp: Add a comment about the return of the function 2014-07-22 13:51:39 +02:00
Holger Hans Peter Freyther 7bcbe2a9cc Merge branch 'zecke/fixes/mgcp-transociding-tests'
Various clean-ups and extensions to the tests. Share one test
set-up routine, capture more of the API inside the output files.
2014-07-22 13:13:12 +02:00
Holger Hans Peter Freyther dd1f81512d mgcp: Make the internal state of the transcoder accessible
For the unit tests we need to look at the internal state.
2014-07-22 13:12:19 +02:00
Holger Hans Peter Freyther 4fb7e64da2 mgcp: Capture the return value of the of the transcode function 2014-07-22 13:12:12 +02:00
Holger Hans Peter Freyther 6041c8db27 mgcp: Do not use errx as finding a test failure is too hard
It took me a long time to figure out that errx just exits and
the test output didn't indicate that the application was exited
early. Use a printf and good old abort in case of a failure.
2014-07-22 13:12:05 +02:00
Holger Hans Peter Freyther 83cbac2ac0 mgcp: Re-factor testcase to separate test and setup
Separate the test from the code necessary for the setup. This is
somehow inspired by the PhExample framework of Pharo.
2014-07-22 13:11:59 +02:00
Holger Hans Peter Freyther e52ca9aad1 mgcp: Warn when the buffer is being reset due a wrong seq number
When the sample buffer is being dropped write a warning so we can
see how often this event occurs.
2014-07-22 12:41:48 +02:00
Holger Hans Peter Freyther a7992e0389 mgcp: Mention the packet duration in the error message 2014-07-22 12:41:32 +02:00
Holger Hans Peter Freyther 3d93d35a93 mgcp: Provide more information about configured endpoints 2014-07-22 12:41:25 +02:00
Holger Hans Peter Freyther c5c239f361 mgcp: Fix memory leak in the transcoding code
The GSM handle was never released. This was found using valgrind
and the leak check.

==14933== 752 bytes in 1 blocks are definitely lost in loss record 15 of 19
==14933==    at 0x4028B4C: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==14933==    by 0x4130201: gsm_create (in /usr/lib/i386-linux-gnu/libgsm.so.1.0.12)
==14933==    by 0x80517AE: mgcp_transcoding_setup (mgcp_transcode.c:199)
==14933==    by 0x8049691: given_configured_endpoint.isra.1 (mgcp_transcoding_test.c:198)
==14933==    by 0x8049C11: test_transcode_result (mgcp_transcoding_test.c:328)
==14933==    by 0x8049418: main (mgcp_transcoding_test.c:582)
2014-07-22 12:40:59 +02:00
Holger Hans Peter Freyther 24fc435dad trau_mux.c: Prevent out-of-bounds read in trau_decode_fr()
Haralds patch in 9f109dfb99 only fixed
the trau_encode_fr part but the issue seems to exist in the decode
function as well. Apply the same fix.
2014-07-22 12:23:03 +02:00
Holger Hans Peter Freyther 94f83e1787 smpp: Fix small typo in the comment 2014-07-19 19:02:46 +02:00
Holger Hans Peter Freyther 0d7efef394 gbproxy: Fix the NAME in the start script...
NAME is used by start-stop-daemon to stop the process.
2014-07-17 07:31:42 +02:00
Holger Hans Peter Freyther d29b8a4745 bsc: Implement a way to relay a message to the remote MSC
This is analogue to the notification that is relayed locally and
now we have a way to relay a message back to the network.
2014-07-09 15:22:21 +02:00
Holger Hans Peter Freyther c6e9049f9c osmux: Now that we have IPv4/port we might want to consider to expire handles 2014-07-09 13:51:29 +02:00
Holger Hans Peter Freyther 9d43cee88c osmux: Mention where the data was coming from 2014-07-09 13:51:04 +02:00
Holger Hans Peter Freyther 7239f574aa osmux: Be accurate. The label has been already created 2014-07-09 13:50:56 +02:00
Holger Hans Peter Freyther 6b0ba01bf3 osmux: Make sure to always use the right dummy sending method
Make sure to re-use the right method for nat traversal. Found
by Roch while looking at traces.
2014-07-08 13:08:00 +02:00
Holger Hans Peter Freyther 768580b3ec bsc: Use the word core network and not backbone. 2014-07-08 12:48:49 +02:00
Holger Hans Peter Freyther 891b0a857d osmux: Remove extra newline from the osmux log message
<000b> osmux.c:177 Cannot find endpoint with cid=7
!
<000b> osmux.c:253 Cannot find an endpoint for circuit_id=7

The extra newline and '!' do not provide any extra value and
make reading the output more difficult. Just remove it.
2014-07-08 09:08:34 +02:00
Jacob Erlbeck 627e7d9bfe gprs/test: Increase stderr log level
Enable the generation of more log messages.

Sponsored-by: On-Waves ehf
2014-07-07 20:07:34 +02:00
Holger Hans Peter Freyther 2840b3f6c3 gbproxy_test: Provide enough disabled categories to please valgrind
An empty log_info is not enough. We need to make sure that at least
DLGLOBAL is present. Instead of doing that make sure that we have
enough entries.

==26163== Conditional jump or move depends on uninitialised value(s)
==26163==    at 0x403B289: osmo_vlogp (logging.c:290)
==26163==    by 0x403B3DA: logp2 (logging.c:339)
==26163==    by 0x804D027: gbprox_relay2bvci (gb_proxy.c:347)
==26163==    by 0x804D3CF: gbprox_rx_sig_from_sgsn (gb_proxy.c:589)
==26163==    by 0x804DBFC: gbprox_rcvmsg (gb_proxy.c:685)
==26163==    by 0x4052CB0: gprs_ns_process_msg (gprs_ns.c:669)
==26163==    by 0x4052F70: gprs_ns_rcvmsg (gprs_ns.c:1053)
==26163==    by 0x804BB49: gprs_process_message (gbproxy_test.c:488)
==26163==    by 0x804BC4C: send_ns_unitdata (gbproxy_test.c:210)
==26163==    by 0x804BDE8: send_bssgp_reset_ack (gbproxy_test.c:243)
==26163==    by 0x804B54F: main (gbproxy_test.c:863)
==26163==
2014-07-07 19:48:14 +02:00
Holger Hans Peter Freyther 461966b8ef mgcp: Ignore the transcoding test 2014-07-07 19:24:43 +02:00
Holger Hans Peter Freyther 8d998a713e mgcp: Verify that the force-ptime is written back to the file
When the command was added it was not verified that. Add a very
basic MGCP VTY test and test that the string appears in the config.
2014-07-07 19:24:34 +02:00
Holger Hans Peter Freyther 2947411383 mgcp: Fix documentation issue in the force-ptime command
<command id='rtp force-ptime (10|20|40)'>
        <param name='10' doc='(null)' />
        <param name='20' doc='(null)' />
        <param name='40' doc='(null)' />
2014-07-07 19:24:28 +02:00
Holger Hans Peter Freyther 983c99113d rtp: Share the rtp header between the proxy and the mgcp code 2014-07-07 19:24:21 +02:00
Holger Hans Peter Freyther 6019b5a508 nat: Fix the documentation issue with the osmux command
Documentation error (missing docs):
<command id='osmux (on|off)'>
        <param name='off' doc='(null)' />
2014-07-07 19:24:14 +02:00
Holger Hans Peter Freyther 84db98fdbe gbproxy_test: Reset the gbproxy before we reset GPRS NS
The peers are (talloc) children of the GPRS NS. This means the
peers (and the rate counters) are currently being deleted twice.

==23446== Invalid write of size 4
==23446==    at 0x403C243: rate_ctr_group_alloc (linuxlist.h:66)
==23446==    by 0x4050974: gprs_nsvc_create (gprs_ns.c:209)
==23446==    by 0x405320D: gprs_ns_instantiate (gprs_ns.c:1330)
==23446==    by 0x804ABEB: main (gbproxy_test.c:666)
==23446==  Address 0x4300694 is 52 bytes inside a block of size 784 free'd
==23446==    at 0x4029DA8: free (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==23446==    by 0x4041B9D: _talloc_free (talloc.c:609)
==23446==    by 0x4043292: talloc_free (talloc.c:578)
==23446==    by 0x40532D3: gprs_ns_destroy (gprs_ns.c:1363)
==23446==    by 0x804ABD7: main (gbproxy_test.c:660)
2014-07-07 19:22:02 +02:00
Daniel Willmann 46d13268b8 gprs_llc: Prevent llme_alloc/lle_init from reading invalid memory
Make the llc_default_params structure from which data is initialized
large enough. Otherwise address sanitizer complains with out-of-bounds
reads.

Only SAPIs 1, 2, 3, 5, 7, 8, 9, 11 are defined for GPRS but the
struct gprs_llc_llme includes NUM_SAPIS lle's and they are populated
from the llc_default_params structure.
2014-07-07 19:17:54 +02:00
Daniel Willmann 8a485f0bec libbsc, osmo-bsc{, _nat}: Prevent unaligned access when casting TLVP_VAL
foo = *((uintXX_t *) TLVP_VAL(...) can lead to unaligned access. To
prevent that use tlvp_valXX_unal() to get the values.
2014-07-07 19:04:32 +02:00
Holger Hans Peter Freyther 99a20d6be1 gbproxy_test: Simplify the test setup by sharing code 2014-07-07 15:06:21 +02:00
Jacob Erlbeck 7fb42dbd27 gprs/test: Add additional gbproxy tests
This adds a test case with several messages to test BSSGP patching.
New messages:

- BSSGP/DTAP Attach Request
- BSSGP/DTAP Attach Accept
- BSSGP/DTAP Routing Area Update Request
- BSSGP/DTAP Routing Area Update Accept
- BSSGP/DTAP Activate PDP Context Request
- BSSGP SUSPEND
- BSSGP SUSPEND ACK

Sponsored-by: On-Waves ehf
2014-07-07 15:06:12 +02:00
Jacob Erlbeck 2e038f7336 gprs/test: Add connect_sgsn() function
This function abstracts identical code sequences that are used at
multiple places.

Sponsored-by: On-Waves ehf
2014-07-07 15:06:06 +02:00
Jacob Erlbeck b32d3c041b gprs/test: Remove verbose parameter of gbprox_dump_* functions
This parameter is not used (the methods are always called with an
argument of 1 in the third position). Thus the parameter is removed
completely.

Sponsored-by: On-Waves ehf
2014-07-07 15:05:59 +02:00
Holger Hans Peter Freyther b115cb6655 db: Use ulonglong to access the database for sqlite3
The type in the schema is integer but we need to use ulonglong to
read it as otherwise the read will fail.

DBI: -7: The requested variable type does not match what libdbi thinks it should be
2014-07-03 14:12:24 +02:00
Harald Welte 9f109dfb99 trau_mux.c: Prevent out-of-bounds read in trau_encode_fr()
found by -fsanitize=address the last iteration of the loop, where i ==
259 and o == 260.  It is read out-of-bounds but the content is never
used.
2014-06-23 09:49:29 +02:00
Holger Hans Peter Freyther db0caf239e nitb: Only print channel activations once in show statistics
openbsc_vty_print_statistics will already print these counters
for us. No need to print them again.
2014-06-18 08:34:54 +02:00
Holger Hans Peter Freyther 421365eeaa mgcp: Allow to batch more than four messages 2014-06-16 14:12:02 +02:00
Jacob Erlbeck 8f50359ebf gprs: Use area terms LAI/RAI as defined in GSM 03.03
Currently the terms 'Routing area code' (RAC) and 'Location area
code' (LAC) are used in several places where 'Routing area
identification' (RAI) or 'Location area identification' (LAI) are
meant in fact.

This patch replaces RAC/LAC by RAI/LAI and 'code' by 'identification'
at these places.

Note that RAI := MCC MNC LAC RAC, and LAI := MCC MNC LAC (see GSM
03.03, sections 4.1 and 4.2).

Sponsored-by: On-Waves ehf
2014-06-15 19:23:38 +02:00
Jacob Erlbeck cb04ca2fc3 mgcp: Fix SDP formatting of fmtp_extra (Coverity)
Currently when ftmp_extra is set, a doubled a=rtpmap line is emitted
instead of the fmtp_extra info.

This patch fixes replaces the formerly copied and pasted but not
modified snprintf parameters by the correct ones.

Fixes: Coverity CID 1220873
Sponsored-by: On-Waves ehf
2014-06-15 19:15:32 +02:00
Jacob Erlbeck bebf92d7f0 mgcp/test: Add test case using the fmtp_extra info
Add tests setting the fmtp_extra field to check the response
generation. This triggers a bug found by Coverity.

Addresses: Coverity CID 1220873
Sponsored-by: On-Waves ehf
2014-06-15 19:15:09 +02:00
Holger Hans Peter Freyther 4e5f93ccdc proxy: Annotate the switch/case/fall through
Use the same comment as some lines earlier in that file.

Fixes: Coverity CID 1040737
2014-06-12 11:32:25 +02:00