Commit Graph

6321 Commits

Author SHA1 Message Date
Neels Hofmeyr 04da5e5e98 mgcp-client: add mgcp_conn_get_ci()
Return the CI string allocated by the MGW and sent back during CRCX ACK.

So far the CI that identifies one connection of an MGW endpoint is "hidden"
behind mgcp_conn_* API. This CI string is however very interesting, for
logging, to be able to correlate with MGCP messages in network traces.

For osmo-bsc, there is an upcoming mgw_endpoint_fsm that will log the CI string
using this function.

Change-Id: I0c802c0cc3fa0aae9558bd7f15aad1cb9a8b12b2
2018-06-12 21:56:12 +02:00
Philipp Maier 54b4f82f91 cosmetic: fix typo
Change-Id: I1df5ff642b3744771836dea82f9d0b4ad6749bc5
2018-06-07 07:01:06 +00:00
Philipp Maier 3d7b58d77a protocol: reject illegal lco options
At the moment osmo-mgw will accept multiple lco options. (e.g.
p:10, a:PCMU, p:10) If LCO appear multiple times, than the first
appearance of will be parsed and used, all following appearances
will be ignored. However, having multiple appearances of LCO is
illegal and affected requests should be rejected. Also osmo-mgw
should reject illegal formatted LCO strings

- make sure that multiple appearances of LCOs will be rejected
- make sure that illegal formated LCOs are rejected
- add testcases with garbeled LCO and valid LCO examples

Change-Id: Iae2fddfa5f2bcfc952f8ab217b3056694e5f7812
Closes: OS#3119
2018-06-06 16:41:04 +02:00
Philipp Maier 604410cd13 protocol: do not change LCO, when no LCO are present
In the current implementation the LCO parameters are reset. This means
that an MDCX without LCO will reset the LCO that have previously set
via CRCX. But according to RFC 3435 6.8 LocalConnectionOptions, the
LCO parameters should be preserved or left at their defaults if missing.

- Make sure LCO are retained if no LCO string is present.
- Also preserve the values of individual parameters if missing.

Change-Id: Ia0d73f61516618317dcd1d49384818fd8de27aa6
2018-06-06 10:36:48 +02:00
Philipp Maier b340f90c9e conn: call talloc_free before setting the pointer to NULL
in mgcp_rtp_codec_init() tallo_free is called after codec->subtype_name
and codec->audio_name are set to NULL. So talloc_free() always sees
NULL-pointers and never frees anything. This may cause a memory leak.

- call talloc_free() first, then set pointers to NULL

Change-Id: I7373819c3689d34811846f6f48f27568297b26e4
2018-06-05 07:23:26 +00:00
Philipp Maier 3c8ccb6724 cosmetic: fix log output
"unable to create connection resource error" sounds a bit strange.
Lets just output "unable to create connection".

Change-Id: Ibef16b455f2e122c8e5ff95240c4d7a654c56a39
2018-06-04 10:01:16 +02:00
Harald Welte d4e6aa42ca cosmetic: fix typo in log message: 'abrupt' instead of 'aprupt'
Change-Id: Ib4d8864baf538ec5871f42fa717eba3b7da9f48e
2018-06-02 18:07:40 +02:00
Philipp Maier e6df0e47e7 mgcp_network: do not log destination invalid ip/port as error
It is legal to create connection without setting the destination
ip and port (this usually done later through MDCX). However, if
some other connection tries to deliver an RTP packet through a
a half open connection, then the fact that no destination ip is
set is logged as error even if it is a pretty normal situation.

- Check if destination ip and port are set to zero. If yes, we
  assume that the destination connection details are intentionally
  not set yet. Only when one value is set and the other one not,
  we log an error. Otherweise we log a message to debug.

Change-Id: If96e5a60b8ab92259d3bddaa143121893bb6c525
Related OS#3104
2018-05-29 14:09:13 +02:00
Philipp Maier 54eb0e1204 client: do not start connections in loopback mode
Starting connections in loopback bode may cause confusion at the
receiving end when the connection is switched from looback into
an actual send-receive connection. The reason for this is by this
the SSRC of the RTP stream will suddenly change. For the majority
of usecases it is not necessary to loopback the incomming packets
back to the receiver in the beginning. So lets use receive-only
as a safe default.

- use MGCP_CONN_RECV_ONLY instead of MGCP_CONN_RECV_LOOPBACK

Change-Id: I44178434ee497bc1d5e9d5f6d92c13c1a09ae241
Related: OS#3104
2018-05-29 09:55:42 +02:00
Philipp Maier b38fb8911f protocol: Try whole port range on port allocation
The function allocate_port tryes at least 200 different ports when
a new port is allocated. Since after every allocation the port
number is incremented the allocation should be able to allocate
a port with the first attempt. However, the number 200 is an
arbitrary number and it will not cover the whole port range in
most cases.

- Make sure that in the worst case at each port in the range
  is tryed once, not only the next 200

Change-Id: Ic47f09869eaddd4aea817bb2517362883d65d029
Related: OS#2825
2018-05-25 10:04:59 +00:00
Philipp Maier 1b3a385b9d sdp: remove circular inclusion
The header file mgcp_sdp.h includes itsself.

- remove unnecessary circular inclusion

Change-Id: I816c6b922641c0b58053714244ada22a75781956
2018-05-25 11:45:06 +02:00
Philipp Maier dbd70c7b68 sdp: remove unused alt_codec field from struct mgcp_rtp_end
The alt_codec field is not used anywhere in the code

- remove unused alt_codec field

Change-Id: I5ff2899e3e61f33eb86f284b50ad8a94a949ed16
Related: OS#3114
2018-05-25 11:07:31 +02:00
Philipp Maier a19547b7a1 vty: clean up rtp port-range command
The VTY command that sets the RTP port range does not check if the data
entered by the user actually makes sens. Also it allwos to configur a
range that starts at 0.

- Make sure 0 can not be used as start or end of the range
- make sure the end port number is always greater then the begin
  port number
- Autocorrect uneaven port range beginnings to one port number before to
  ensure the range starts at an even port number
- Autocorrect even port range ends to the next odd port number to
  ensure the range ends at an odd port number.

Change-Id: Ib1312acba4f03f378594dbbeb4f31afd891d68d7
Related: OS#2825
2018-05-24 10:21:31 +02:00
Philipp Maier 06823731d8 mgcp_sdp: correct apidoc of mgcp_parse_sdp_data
The API documentation of mgcp_parse_sdp_data is incorrect.

- correct API documentation

Change-Id: I9906f1dd6811c7092b93d60c9348221fef68cc3e
2018-05-22 10:04:22 +00:00
Neels Hofmeyr ed1cff5ab9 api doc: fix parameter name for mgcp_conn_create()
Change-Id: Ib6ea230c2e1918bd4e431208610b53e468e534c7
2018-05-19 23:08:35 +02:00
Pau Espin f2321b7a72 mgcp: switch to new osmux output APIs
Older ones are being deprecated as they may generate interleaved
packets.

Change-Id: I0705aa4dc4b02eaff4d6030795243e6720f7fddf
2018-05-19 12:06:12 +00:00
Pau Espin 4219904cb2 mgcp: mgcp_osmux: use conn_bts when forwarding pkts from bsc_nat
This commit actually doesn't fix the entire code, since anyway osmux
conns are not supported and mgcp_conn_get_rtp() will return NULL.
However, it makes the code more logical and easier to understand once
somebody refactors the code to make it work again.

Change-Id: Ib57e12e5a36b5842c40673c236907bbcbfc390f3
2018-05-19 12:06:12 +00:00
Pau Espin b2753f2044 legacy-mgcp: switch to new osmux output APIs
Older ones are being deprecated as they may generate interleaved
packets.

This commit is a forward-port of openbsc.git Change-Id
I189564fc63139c15314db8975afd423c7153ea32.

Change-Id: I9b8a19e5b8d62deaa9bbb92d49d99e8c33b7e345
2018-05-19 12:06:12 +00:00
Pau Espin ba61f68137 legacy-mgcp: Add jitter buffer on the uplink receiver
Default usage values are defined in mgcp node, and can be per-BSC
overriden on each bsc node

This commit is a forward-port of openbsc.git Change-Id
Ibf3932adc07442fb5e9c7a06404853f9d0a20959.

Change-Id: Ie19a64ac09f9d51f2434ad0d7925610fc919a90e
2018-05-19 12:06:12 +00:00
Philipp Maier 9e1d164469 stats: use libosmocore rate counter for in/out_stream.err_ts_counter
The two counters: in_stream.err_ts_counter and out_stream.err_ts_counter
are still handcoded. To make them better accessible they should
 be replaced with libosmocore rate counters.

- replace state.in_stream.err_ts_counter with libosmocore rate counter
- replace state.out_stream.err_ts_counter with libosmocore rate counter

Change-Id: I9fbd65bf2f4d1e015a05996db4c1f7ff20be2c95
Related: OS#2517
2018-05-16 11:32:36 +02:00
Philipp Maier 0ec1d4e17c network: independently initalize state->out_stream
The struct state->out_stream.ssrc is initalized by first initalizing
state->in_stream and then copying state->in_stream over to
state->out_stream. This works as long as no pointers to other objects
are added to struct mgcp_rtp_stream_state but we may add pointers to
struct mgcp_rtp_stream_state in the future.

- Initalize out_stream and in_stream independently from each other

Change-Id: I5deb27e609448ee0b9f7034e644ae96f1e57887a
Related: OS#2517
2018-05-16 11:32:12 +02:00
Pau Espin d761d355f9 Bump version: 1.2.0.109-8d064-dirty → 1.3.0
Change-Id: I524222f5a056111325087cfb44d83d02571b475f
2018-05-03 17:40:35 +02:00
Alexander Couzens 8d064dfd24 Revert "stats: use libosmocore rate counter for in/out_stream.err_ts_counter"
This reverts commit 7181cc1f02.
The tests are broken on i686, arm (non 64bit systems).

Change-Id: I15f3c78f8410d709733ed5692ba94ba17559d7e1
2018-04-21 20:26:17 +02:00
Philipp Maier 7181cc1f02 stats: use libosmocore rate counter for in/out_stream.err_ts_counter
The two counters: in_stream.err_ts_counter and out_stream.err_ts_counter
are still handcoded. To make them better accessible they should
be replaced with libosmocore rate counters.

- replace state.in_stream.err_ts_counter with libosmocore rate counter
- replace state.out_stream.err_ts_counter with libosmocore rate counter

Change-Id: I67aa7a8602f60366ef3ba2c5b1319b1b85719f64
Related: OS#2517
2018-04-17 16:43:59 +02:00
Neels Hofmeyr 60f8e31a2f use osmo_init_logging2() with proper talloc ctx
Change-Id: I3e2a9aef5242efdf11a64536f79099a6e9cec53f
2018-04-01 16:05:05 +02:00
Neels Hofmeyr 086c3f3c67 cosmetic: mgcp, legacy_mgcp: drop unused vty.h definitions
Change-Id: I38e279ed175259e6d36c0e69d6a352506face014
2018-03-22 14:56:20 +01:00
Philipp Maier d0b470d1a9 mgcp_conn: add function mgcp_rtp_conn_cleanup()
The function mgcp_conn_free() holds a few lines to de-initalize
members which are struct mgcp_conn_rtp specific. Since we already
have an mgcp_rtp_conn_init() that does the intialization, we should
have an mgcp_rtp_conn_cleanup() too.

 - add function mgcp_rtp_conn_cleanup() and move rtp specific
   code to that function.

Change-Id: Ib9bf6d2a3af4f1df1a4ab5ec789b39a2cee2532f
2018-03-19 18:05:51 +01:00
Philipp Maier 77f76d0be5 cosmetic: rename .._codec_reset() to .._codec_init()
The function mgcp_rtp_codec_reset() is soley called from
mgcp_rtp_conn_init(), lets change the prefix here to _init too.

- rename mgcp_rtp_conn_reset() to mgcp_rtp_conn_init()

Change-Id: I246aabc896089c1f2b3d0409ec3422a85e43575c
2018-03-19 18:05:51 +01:00
Philipp Maier 892dec0be9 mgcp_conn: do not touch u.rtp in mgcp_conn_alloc()
The function mgcp_conn_alloc() calls mgcp_rtp_conn_init() to initalize
the RTP specific members (union u.rtp) but also touches u.rtp directly.
This should not be the case, only mgcp_rtp_conn_init() may touch the
union depending on which type of RTP connection is initialized
(currently there is only MGCP_CONN_TYPE_RTP).

- let mgcp_rtp_conn_init() set the backpointer to the generic
  conn part.

Change-Id: I6f806f9bfa71b446c15bdc34ae59d2bc1cd10d7e
Note: This is merely a cosmetic change.
2018-03-19 18:05:51 +01:00
Philipp Maier c430d19112 cosmetic: rename function .._conn_reset() to .._conn_init()
We do allocate connections dynamically and we initialize them
once by calling mgcp_rtp_conn_reset(). Calling this a reset
function implies that the reset happens multiple times while
the struct lives. This is not tha case, so lets change the
suffix to _init()

- rename mgcp_rtp_conn_reset() to mgcp_rtp_conn_init()

Change-Id: Ie48b575ff81c8f48afcc25f485967e011e90027b
2018-03-19 18:05:46 +01:00
Neels Hofmeyr 7b8e419d92 jenkins.sh: add --enable-werror to configure flags
Change-Id: If3af8d0fe9247c22d57dbe70fc80a58ee7297f75
2018-03-13 15:39:32 +01:00
Neels Hofmeyr 4f7613eeb1 configure: add --enable-werror
Provide a sane means of adding the -Werror compiler flag.

Currently, some of our jenkins.sh add -Werror by passing 'CFLAGS="-Werror"',
but that actually *overwrites* all the other CFLAGS we might want to have set.

Maintain these exceptions from -Werror:
a) deprecation (allow upstream to mark deprecation without breaking builds);
b) "#warning" pragmas (allow to remind ourselves of errors without breaking
   builds)

As a last configure step before generating the output files, print the complete
CFLAGS and CPPFLAGS by means of AC_MSG_RESULT.

Change-Id: Ia66aa48e957f4dcbdf8a7df3010b84f472c33f76
2018-03-05 20:43:27 +01:00
Philipp Maier 01f039538e cosmetic: mgcp_client_fsm: rename enums
The enum defining the event and state identifiers is prefixed with
"bsc_".

- coose a more conceise prefix

Change-Id: I662d8e4328911610e7d1943f1b623e96c3a8b3c1
2018-02-26 16:09:57 +01:00
Philipp Maier d2e3a52230 mgcp_client_fsm: Add FSM event names
The FSM lacks a proper definition of the FSM event names. This causes
problems when inspecting the FSM using the VTY.

- Add proper FSM Event names

Change-Id: Ic0990abea2e9fd92546e7b337b5ff3d6f0866321
Related: OS#2924
2018-02-26 16:09:57 +01:00
Stefan Sperling 2924825bc6 enable osmo_fsm vty commands in libosmo-mgcp-client vty
Call osmo_fsm_vty_add_cmds() to make osmo_fsm VTY commands available
in libosmo-mgcp-client's VTY interface.

Change-Id: If772edc304a9f342a57fb548f26908256cc9e6e5
Related: OS#2967
2018-02-22 18:10:45 +01:00
Neels Hofmeyr bd86f94a09 compiler warning: ignore deprecated in mgcp_client_test.c
mgcp_msg_crcx() causes deprecation warning, but it's fine for a unit test
to use deprecated API.

Change-Id: Iba6d0c9c729367e00a9ab7fff7c89007d336e59d
2018-02-22 07:59:04 +00:00
Neels Hofmeyr 1083533db4 mgcp_client: detect SDP section-start parsing errors
After call to mgcp_find_section_end(), actually check the proper variable to
evaluate its return value.

Show in mgcp_client_test output that the parsing errors are fixed, and enable
the assertion that no tests should fail.

Change-Id: I62a2453cd9e2e7d5408423161fa65ec9c9989f98
2018-02-21 16:58:53 +01:00
Neels Hofmeyr 0793d2f5d5 mgcp_client: cosmetic: clean up SDP params parsing
The mgcp_response_parse_params() is in a jumble. Straighten out these cosmetic
issues:

- Move assertion of r->body close to its first use.
- Instead of a talloc_zero and osmo_strlcpy dance, simply use talloc_strdup().
- Drop the first unused invocation of mgcp_find_section_end().
- Drop unused assignment of data_ptr = data.
- In the log, mention "SDP" to clarify.
- Add a comment clarifying how we skip the section marker.

Change-Id: Icf1df761270777a142bc8ace75f2a10918314f73
2018-02-21 16:58:53 +01:00
Neels Hofmeyr a8c6a9c37a mgcp_client: show failure by MGCP SDP section parsing test
To show how the current code fails, add test_sdp_section_start() to
mgcp_client_test.c, and temporarily accept failing output. This will be fixed
in change I62a2453cd9e2e7d5408423161fa65ec9c9989f98.

Change-Id: I5c6d3566b8f6dbf04c0cd8b127423f5295c19f8d
2018-02-21 16:58:30 +01:00
Pau Espin 2da99a2946 mgcp_stat: Don't print osmux stats if it is off
Otherwise we get Osmux stats during a session using RTP, which is
confusing.

Change-Id: I6fcd680a073fbf8769488ffa2b2b32098c87edf4
2018-02-20 13:12:02 +01:00
Pau Espin c3eed40f00 legacy: mgcp_protocol: Don't print osmux stats if it is off
Otherwise we get Osmux stats during a session using RTP, which is
confusing.

Forward-ported from openbsc e39e18992a3b966581f06fa632d6342643996aaa.

Change-Id: I9031350242dd37ce255631c20eed33976887faa6
2018-02-20 13:11:43 +01:00
Neels Hofmeyr 515e341ff6 osmo-mgw: Add talloc context introspection via VTY
This requires libosmocore with Change-Id
I43fc42880b22294d83c565ae600ac65e4f38b30d or later.

Change-Id: I59feac155ba2342fcc2b27b029e803b8a10da2d3
2018-02-17 14:11:33 +01:00
Philipp Maier 8bda7a7766 client: add an optional FSM interface
the client API is not very intuitive and requires a lot of extra
care when it is used from an osmo-fsm.

- Add an FSM that permits comfortable handling of an MGCP
  connection.

Change-Id: I887ce0c15a831dffeb6251a975337b83942af566
2018-02-08 16:22:45 +01:00
Philipp Maier df5d219f39 mgcp: fix use-after-free and add callback for endpoint cleanup
Since we will support multiple different types of endpoints in the
future, all these endpoints will handle connections slightly different
and there will be possibly state that needs to be kept consistant
when a connection is deleted.

In mgcp_network.c where we implement the callback that is used to
create an rtp-bride-endpoint. In that callback we cache the pointer
of the connection we where we want to bride to (opposite connection).
When one of the connections is deleted using a DLCX operation, the
pointer is still there and the next incoming packet causes a use-
after-free segfault.

- introduce an endpoint specific callback function that is executed
  before removing the connection.

- implement the endpoint specific callback for rtp bridge endpoints,
  so that the use-after-free is prevented.

Change-Id: I921d9bbe58be1c3298e164a37f3c974880b3759f
2018-02-06 08:21:24 +00:00
Philipp Maier 5656fbf49d protocol: prohibit wildcarded requests for MDCX and DLCX
When a wildcarded request is made with a DLCX or MDCX command
the MGW will search for a free endpoint and continues the command
execution with that endpoint.

- Catch the wildcarded request early on DLCX and MDCX and return
  with an error code.

See also TTCN3 testcases:
MGCP_Test.TC_mdcx_wildcarded
MGCP_Test.TC_dlcx_wildcarded

Change-Id: Ia77d44a6a86083e62338e5845b553e5cf13ebd10
2018-02-06 08:21:24 +00:00
Harald Welte 19d640e806 Turn libosmo-mgcp into local, non-installed library
This is an internal library simmilar to 'libmsc' in osmo-msc, which
we don't expect to be used by other programs except osmo-mgw.  Hence,
there's no need to install it as a shared library, which introduces
requirements about ABI/API stability and the like.

osmo-bsc_nat uses libosmo-legacy-mgcp, and once we should rewrite
osmo-bsc_nat, we might need some of the libosmo-mgcp related functions,
but at this point it's unclear what exactly would be needed and if
current libosmo-mgcp can provide that.  As needed, we can introduce
a related shared library at that point.

Change-Id: Iba0a2c9c694e360356ac2ca584e97795281c6198
2018-02-05 22:41:32 +00:00
Philipp Maier 207ab51270 protocol: fix tagging of wildcarded requests
When a wildcarded CRCX is done flag "wildcarded_crcx" is set in the
endpoint struct. The flag tells other part of the code whether the
request was wildcarded or not since in some cases the behaviour
might be different for wildcarded requests. The implementation of
this mechanism is not entirely correct. The flag is set on wildcarded
requests but on non wildcarded requests it is not reset. Also the
name is misleading.

- rename wildcarded_crcx to wildcarded_req

- ensure the flag is refreshed with every new request

Change-Id: Ia5063ec65f5bc3a8a0943d1fd823aaeee20b8637
2018-02-05 10:32:42 +01:00
Philipp Maier c3cc654add protocol: check requested connection mode
The connection mode setting (e.g. recvonly) is not checked on CRCX
and MDCX. This allows requests that set the connection mode to
sendrecv or sendonly without ever configuring the remote end of
the connection (half-open connection).

- reject sendrecv or sendonly on half open connections

See also TTCN3 Test:
MGCP_Test.TC_crcx_early_bidir_mode

Change-Id: I6ab01855d3b1faa36aebac357e7b97c563990678
Related: OS#2652
2018-02-05 10:32:42 +01:00
Philipp Maier b911b879d8 cosmetic: Add missing \n on log line
The final log lone in find_endpoint() lacks the \n causing a messed
up log output.

- Add missing \n

Change-Id: I97fca654b199dfb7aae2359322a56c6d0bae9599
2018-02-05 10:32:42 +01:00
Philipp Maier af07f66ca3 protocol: exit cleanly when local cx options check fails
When set_local_cx_options() returns an error code the MGCP command
execution is aborted and and the error code is returned, but on
CRCX the already seized eindpoint is not released.

- Do not generate the error response on the spot, jump to the
  respective label and let the already existing error handling
  do its work.

This patch is a follow-up page to:
Change-Id I02aaa3042f2a0e32eb4ec6b8753deab7082947a0

Change-Id: Iaef4ea6c6a2f24ac8b276966bda72d0b30f25cd5
Related: OS#2654
2018-02-05 10:32:42 +01:00