Commit Graph

1244 Commits

Author SHA1 Message Date
Philipp Maier 069dd16b67 mgcp_network: fix typo RTPC -> RTCP
Change-Id: I3274441a1bf6f4f015f01017ef03451b7f79310a
2022-03-30 17:05:56 +02:00
Philipp Maier e144275757 mgcp_network: do not try to convert RTCP packets
Make sure that RTCP packets do not enter the code path where AMR OA and BWE
is converted. The conversion will fail and the RTCP packet will be
dropped.

Change-Id: Ic850344d8b5f7710d12e4553a4033b733dced52b
Related: SYS#5902
2022-03-30 17:05:56 +02:00
Philipp Maier e0058b7207 mgcp_codec: do not differentiate between oa and bwe when comparing codec
AMR that has the payload format bandwith-efficient is the same codec as
AMR that has the payload format octet-aligned. Its the same codec, and a
comparison of the codec info with the function codecs_same() should
return true (=equal).

The affected function codecs_same() is used by mgcp_codec_pt_translate().
When the egress payload type number is looked up, the ingress and egress
codec information is compared. When one end is using AMR in
bandwith-efficient format and the other end is using it in
octet-alingned format. Then the codec still must be recognized as the
same codec. Othersiwse the payload type number translation would not
work, even though the codec is the same on both sides.

Change-Id: I64731570c287a75d39c79c10e1bc09a37bdd54d6
Related: SYS#5834
2022-02-16 17:17:45 +01:00
Pau Espin bb3ccdea1a Initial IuUP support using proper FSMs
Related: OS#1937
Depends: libosmocore Change-Id I63ee780b4aa162ea097410b234e73984000c0965
Change-Id: I6694a21480b25ab8f35d375295be6601ce38e31d
2022-02-07 17:50:31 +00:00
Pau Espin 2799ff9bb9 Make function amr_is_octet_aligned publicly available
it will be used by mgcp_iuup.c in follow-up patch.

Change-Id: Iffaf90c1f713feef0c609a7581a346f5f28141d9
2022-01-18 14:56:34 +00:00
Philipp Maier 1de5ed6f97 mgcp_client: add new codec IUFP as VND.3GPP.IUFP
3GPP TS 25.414 5.1.3.3.1.6 specifies that IuUP can use RTP as transport.
The payload type is specified from 96-127, which shall be ignored on the
receiving end anyway.

The payload type number we use shall be 96 by default.

Change-Id: Ifd1210a897743396899f34457c96e6fd2109c6b3
Related: SYS#5152
2022-01-04 15:50:39 +01:00
Pau Espin 80751d850b cosmetic: mgcp_codec.c: Fix typo in comment
Change-Id: Ic93c9bcf6d3a12cc42fdfee2be97662adf068409
2022-01-03 15:26:27 +01:00
Pau Espin 2c40164ff0 Define mgcp_rtp_end.output_enabled as bool
Change-Id: I55f7796ef774f86050041f2c5e3a2f8f7d1f56df
2022-01-03 12:29:39 +01:00
Pau Espin e308202285 mgcp_network.c: Fix byte alignment of CRC Header for ACK Initialization
The Header CRC field is 6 bits, not 8, and spans bits 7-2.

Fixes: ebb05c1f90
Change-Id: I9a8179813d451948bfa02443894fdd2313dfc4a0
2021-12-28 21:05:47 +00:00
Pau Espin 8029b12146 cosmetic: Rename variable payload=>payload_type
Using "payload" there is misleading, the proper naming is payload type,
a well known term for RTP.

Change-Id: Ifcad63b0ba5068acd555960c71c3ad1489a2b870
2021-12-23 16:22:32 +01:00
Pau Espin ebb05c1f90 mgcp_network.c: Set proper CRC Header for ACK Initialization
Discovered while debugging wireshark CRC calculation and implementing
new IuUP code in libosmocore.

Change-Id: Ic8350d1f9a9e5dcefeb787462d267bfac08d778f
2021-12-16 16:11:09 +01:00
Oliver Smith bc3f3b40fe treewide: remove FSF address
Remove the paragraph about writing to the Free Software Foundation's
mailing address. The FSF has changed addresses in the past, and may do
so again. In 2021 this is not useful, let's rather have a bit less
boilerplate at the start of source files.

Change-Id: I2a623f67e116d5e56091ae5860ca2a305c57e50a
2021-12-14 12:50:59 +00:00
Eric Wild 7c0fe31697 fix mgcp_conn_free_all ubsan complaints
ubsan still complains about a unaligned load that can't be explained, so
silence it:

/mgw-threads/install/include/osmocom/core/linuxlist.h:171:15: runtime
error: member access within misaligned address 0x612000000249 for type
'const struct llist_head', which requires 8 byte alignment
0x612000000249: note: pointer points here
00 00 00  48 02 00 00 20 61 00 00  48 02 00 00 20 61 00 00  60 02 00 00
a0 62 00 00  80 1f 49 00 00
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
/mgw-threads/install/include/osmocom/core/linuxlist.h:171:15 in
/mgw-threads/install/include/osmocom/core/linuxlist.h:171:15: runtime
error: load of misaligned address 0x612000000249 for type 'struct
llist_head *const', which requires 8 byte alignment
0x612000000249: note: pointer points here
00 00 00  48 02 00 00 20 61 00 00  48 02 00 00 20 61 00 00  60 02 00 00
a0 62 00 00  80 1f 49 00 00
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
/mgw-threads/install/include/osmocom/core/linuxlist.h:171:15 in
mgcp_conn.c:303:17: runtime error: member access within misaligned
address 0x612000000249 for type 'struct llist_head', which requires 8
byte alignment
0x612000000249: note: pointer points here
00 00 00  48 02 00 00 20 61 00 00  48 02 00 00 20 61 00 00  60 02 00 00
a0 62 00 00  80 1f 49 00 00
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
mgcp_conn.c:303:17 in
mgcp_conn.c:303:17: runtime error: load of misaligned address
0x612000000249 for type 'struct llist_head *', which requires 8 byte
alignment
0x612000000249: note: pointer points here
00 00 00  48 02 00 00 20 61 00 00  48 02 00 00 20 61 00 00  60 02 00 00
a0 62 00 00  80 1f 49 00 00
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
mgcp_conn.c:303:17 in
mgcp_conn.c:304:30: runtime error: member access within misaligned
address 0x4800006120000002 for type 'struct mgcp_conn', which requires 8
byte alignment
0x4800006120000002: note: pointer points here
<memory cannot be printed>
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
mgcp_conn.c:304:30 in
AddressSanitizer:DEADLYSIGNAL
=================================================================
==223426==ERROR: AddressSanitizer: SEGV on unknown address (pc
0x0000004553f7 bp 0x7ffda5855080 sp 0x7ffda5855040 T0)
==223426==The signal is caused by a READ memory access.
==223426==Hint: this fault was caused by a dereference of a high value
address (see register values below).  Disassemble the provided pc to
learn which register was used.
/mgw-threads/osmo-mgw/src/libosmo-mgcp/mgcp_conn.c:199:14
/mgw-threads/osmo-mgw/src/libosmo-mgcp/mgcp_conn.c:258:9
/mgw-threads/osmo-mgw/src/libosmo-mgcp/mgcp_conn.c:304:3
/mgw-threads/osmo-mgw/src/libosmo-mgcp/mgcp_endp.c:124:2
/mgw-threads/osmo-mgw/tests/mgcp/mgcp_test.c:670:3
/mgw-threads/osmo-mgw/tests/mgcp/mgcp_test.c:923:2
/mgw-threads/osmo-mgw/tests/mgcp/mgcp_test.c:2248:2
/build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
(/mgw-threads/osmo-mgw/tests/mgcp/mgcp_test+0x404c2d)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV
/mgw-threads/osmo-mgw/src/libosmo-mgcp/mgcp_conn.c:199:14 in
mgcp_conn_get
==223426==ABORTING

Change-Id: Ifd056eeb88966df164c07b9165b25faa4edbaadb
2021-11-17 21:20:08 +00:00
Eric Wild e03e34f8bb add a lock-free bounded spsc interthread queue
Not entirely wait-free: allows waiting on a fd, and in general fd
notifications for poll-loop integration between threads.

Change-Id: I4f17042baf76d086ce6b20eb99402dc64c22c657
2021-11-17 21:20:08 +00:00
Eric Wild ee6958c9a8 rework message handling
This was previously broken and a free endpoint was requirted to dlcx *,
additionaly globally handling this is difficult due to different
response
codes, so just do it in the functions, they know best.

Change-Id: I8cbbe5936067ea1caa7935e8d14908ac5c4010bd
2021-11-17 21:20:08 +00:00
Eric Wild fbcf4a6f6c adjust mgcp response context
This patch also prepares for threading.

Change-Id: Id17f51d8bc0d1ba26f7fca72b1679ffadc9d6dc8
2021-11-17 21:20:08 +00:00
Pau Espin 58dc88bc31 Bump version: 1.8.1.90-aac8-dirty → 1.9.0
Change-Id: Icfc615c0d7d826269962b0d94fbe53c2f8adfdaf
2021-11-16 16:59:21 +01:00
Eric Wild aac84edc9d fix up some docstrings that lost their dot
Change-Id: I88333c165f1dc11ae29f4c1726c15656386d1f0e
2021-11-09 18:45:09 +01:00
Eric Wild fdbefde869 fix mgcp_conn_free_all
It calls itself recursively which messes with the list an ep, so ubsan
complains.

Change-Id: If38ead0ba0c28396df2332990c98b2532cf17d1c
2021-11-03 15:19:13 +00:00
Eric Wild 25ecc91c3b rename strip_epname and find_specific_endpoint and make them available
Change-Id: I4f76676640a308ab84da3848e1c1ec22bd5d9566
2021-11-03 15:19:13 +00:00
Vadim Yanitskiy 0c04500ac5 libosmo-mgcp: use OSMO_STRLCPY_ARRAY in mgcp_codec_add()
Change-Id: Icc2486308577b587a6ebd1b44b2fa92693aa7fc7
Fixes: CID#240100
2021-10-21 00:07:02 +03:00
Pau Espin a0b69f1896 Fix attribute parsing on gcc 11.1.0
Fixes following compilation error:
"osmo-mgw/src/libosmo-mgcp/mgcp_stat.c:39:1: error: ‘integer’ attribute directive ignored"

Change-Id: Ia5167068abe8a22cd35a833396cbd7cb531c7e83
Fixes: f936e10f07
2021-09-20 10:00:50 +00:00
Eric Wild fbf78d13f1 endp: do not cache cfg pointer
There is no obvious reason why we would want to complicate the code by
caching pointers, since pointer traversal is probably not a performance
bottleneck, and if it is we should rather take a look at our dozens of
linked lists first..

Change-Id: I2456ba63598f76200d53e00223abf60bb36a49c0
2021-09-14 18:33:24 +02:00
Philipp Maier df9192efee mgcp_client: add MGW name as logging context
Usually only one MGCP client per application is present. Then the log
lines from mgcp_client.c will be distinguishable without additional
information. When the application is using a pool of MGWs, then the
various MGCP Client instances become hard to distinguish.

- Add a possibility to set a description (name) for each MGW pool
  member. When no description is set, use the domain name.

- Output the pool member name on each log line in mgcp_client.c
  and mgcp_client_pool.c

Change-Id: I53ff5445c8e5faffa4ef908ffb1fdb1f47ea2904
Related: SYS#5091
2021-09-14 07:01:04 +00:00
Eric Wild 70a658a2ba adjust talloc context
there is no obvious reason why the endpoints that belong to a trunk would
have the (global) config as parent context, you can't really have endpoints
without a trunk anyway.

Change-Id: Id3d5fefc12b7d442c09c507b3a8b0231e46e3068
2021-09-13 18:49:49 +02:00
Eric Wild 2764bdb1aa embed strings into structs
They are mostly not even as large as the talloc header used to
dynamically allocate them, and they are also not "shared" by anything.

Change-Id: I7b46d531c5d3b53984f2ce44538116973f6a074d
2021-09-13 18:49:49 +02:00
Eric Wild 55fdfc223e globally lock the portrange when trying to grab a port to prep for multithreading
Change-Id: I78ae737b829bb428372f34db7d5bc601b5088b78
2021-09-13 18:49:49 +02:00
Eric Wild 8f33303660 libosmo-mgcp: do not use the default msgb talloc context
Trunk is safe, since it will not disappear sooner than the endpoints or
connections.

osmux still missing!

Change-Id: I15b01085f31e9a10a1ad381713ca2275356ca20c
2021-09-13 18:49:49 +02:00
Eric Wild a94c56e4c6 libosmo-mgcp: atomic rate counter group indexes
Postfix++ on atomics is specified as rmw operation with
memory_order_seq_cst.

Change-Id: Ib82d15aab2b3ba25827f9cf8751dbf87ee92a444
2021-09-13 18:49:49 +02:00
Eric Wild 2ebcf5c34a libosmo-mgcp: cleanup audio codex alloc
No need to complicate audio codes with pointers, our "usual" string is
barely larger than a poointer, five times smaller than a talloc header,
and most importantly not really optional anyway...

Change-Id: Icc41643050a5e1ca3c66f307d60b6911ba1b8032
2021-09-13 18:49:49 +02:00
Eric Wild f936e10f07 stats: make sanitizers happy
The test expects wrapping here, but the undefined sanitizer is not happy
with that, so disable it.

Change-Id: I59ec65519ea028d4628ba4b56c939aef70794abf
2021-09-13 18:49:38 +02:00
Eric Wild e303fa9ff3 mgcp_sdp: fix potential leak
Change-Id: I31527b54f602634024a0b687eef26a9b29354282
2021-09-10 17:24:45 +02:00
Eric Wild 958f5e74cc rename do_retransmission
...because it does not "do"

Change-Id: I5513e0ad15db4a0629f4e0348fc3e84d9972259a
2021-09-10 17:24:45 +02:00
Philipp Maier fa495d669f mgcp_client: fix typo in doxygen comment
Change-Id: I4431502ebbaa980f2abfdb98acba0f55ca658292
2021-09-02 10:09:28 +02:00
Philipp Maier 439c86fc58 mgcp_ratectr: remove unusued rate counters
The change I19f67db1c56473f47338b56114f6bbae8981d067 removes the
policy_cb and change_cb callback funtions, but it does not remove
the related ratecounters.

Change-Id: I53aa3c890555055466e86b09a359375a10d3be7b
2021-08-23 15:32:49 +02:00
Philipp Maier 74e83d3d82 mgcp_client_vty: fixing docstring
The docstring in the VTY command that is used to remove MGCP client
instances lacks the NO_STR constant.

Change-Id: I53f3e763a77ed8be78c5a51b1472f4b70bade9d4
Related: SYS#5091
2021-08-20 09:58:46 +02:00
Philipp Maier d55be05af1 mgcp_client_vty: cosmetic: doc string should terminated with \n
Change-Id: I34c16490e08af0c9853f1a794113c191bb65d09a
2021-08-19 14:58:31 +02:00
Philipp Maier 8f91a7f450 mgcp_client_vty: fix docstrings for mgw-pool
The interactive VTY commands to reconnect, block and unblock MGCP
clients from the pool are not displayed properly because the doctring
lacks the reference number.

Change-Id: I0367c33f5cd02978e3f14b1343dfaafa1ea62370
Related: SYS#5091
2021-08-19 14:57:28 +02:00
Philipp Maier da3a5759e1 mgcp_client_vty: add OSMO_ASSERT on pool parameter
When the function mgcp_client_pool_vty_init is called with pool = NULL,
then it segfaults. Lets put an OSMO_ASSERT() on pool to make clear that
a pool must be present before initalizing the VTY on it.

Change-Id: I36893bf5341d4ad21161e92d2d25d284647f7d18
2021-08-19 14:26:02 +02:00
Oliver Smith 29e671f257 mgcp_client_vty: add missing NO_STR
Fixes: 3f2c15 ("mgcp_client: allow to reset endpoints on startup")
Change-Id: Ib2052dcfcfc26fa898e31ffee1e792856fab22ed
2021-08-18 08:44:47 +02:00
Philipp Maier d6a7e17911 mgcp_client_vty: add missing docstrings
The VTY for the classic non pooled MGCP Client does not have any API
doctumentation.

Change-Id: Ia7ca2e4a8efa714f7a56ffd18de152c992936221
2021-08-16 16:22:31 +02:00
Philipp Maier 3f4a4cb49c libosmo-mgcp-client: extend the mgcp_client for MGW pooling
At the moment the MGCP Client only supports one MGW per application.
Depending on the requirements of the application one MGW might not offer
the performance needed. Lets add support for an MGCP Client pool that is
backward compatible to existing applications.

Change-Id: Icaaba0e470e916eefddfee750b83f5f65291a6b0
Related: SYS#5091
2021-08-16 16:22:31 +02:00
Philipp Maier 3d2b76fd95 mgcp_client: refactor function init_socket
The function init_socket has an arbitrary retry count when opening the
socket. After each retry the local port is incremented by one. The
intention behind this is to find a useable local port in case the
configured port is used by another process.

The maximum number of retrys is hardcoded. The upcomming MGW pooling
patch requires to set the maximum retry count.

Change-Id: Ifd65511daa92fbe610f52da1c4c3b6a7c761d890
Related: SYS#5091
2021-08-16 16:22:31 +02:00
Philipp Maier 276a414aa3 mgcp_client: do not print (null) when address is ANY
When the address is set to ANY, the address string is NULL. The log then
prints "(null)" where the address normaly would be. This looks odd, lets
print "(any)" instead.

Change-Id: I2ea138827ee5b9f40d352bf594364ee930520609
2021-08-16 16:22:31 +02:00
Philipp Maier c534ad17dc mgcp_client_vty: remove unnecessary checks
The vty always checks if global_mgcp_client_conf exists. (there is also
an assert This check about global_mgcp_client_ctx).
global_mgcp_client_ctx and global_mgcp_client_conf are populated before
the VTY commands are installed. Unleass the caller uses the API wrong
and calls mgcp_client_vty_init with NULL pointers there cannot be a
problem with unpopulated pointers. Lets remove the checks as they are
not needed.

Change-Id: I892d14c588573f76640453cb9c194594289b59f1
Related: SYS#5091
2021-08-16 16:22:31 +02:00
Philipp Maier 3f2c15f275 mgcp_client: allow to reset endpoints on startup
Depending on the usecase of osmo_mpcg_client it may be helpful to send a
DLCX to certain endpoints. Usually this would be a wildcarded endpoint
that resets the entire trunk to drop lingering RTP flows which may still
present after a restart/crash, but it might be also a group of specific
endpoints. The user may specify an arbitrary amount of endpoints where
the mgcp client will send a DLCX to. It does not matter if the endpoints
are wildcarded or not.

Change-Id: I47e7ff858d5067b46d52329be5f362ff61c0dff8
Related: SYS#5535
2021-08-16 16:22:31 +02:00
Philipp Maier 38533ba9b3 mgcp_ratectr: do not set talloc destructor on library allocated item
The rate counter and stats item groups, which are allocated in
mgcp_ratectr.c are freed using a talloc destructor that is set in the
context of the item we just allocated using the stats / rate counter API
functions. When we do that, we risk overwriting an already existing
talloc destructor. Lets instead implement own free functions and set
those as talloc_destructor from above (trunk and MGCP config)

Change-Id: Ifc5091e9f95cc721e58d1eb2e55b97102c497706
Related: OS#5201
2021-08-09 14:12:51 +02:00
Philipp Maier 39889e4389 mgcp_protocol: get rid of policy_cb and change_cb
The two callback functions policy_cb and change_cb are essentially dead
code. They also make the code more difficult to read and understand.
Lets remove them.

Change-Id: I19f67db1c56473f47338b56114f6bbae8981d067
2021-08-05 10:00:59 +02:00
Philipp Maier c824fe4eb0 mgcp_client: fix typo Initalize -> Initialize
Change-Id: If57f8c0e54dbb5d37f40e36d968a6e6b75eec066
2021-08-04 08:04:10 +00:00
Philipp Maier 124a3e0b34 mgcp_ratectr: add stats items to monitor trunk usage
We are currently counting events in rate counters, but there is
currently no way to get a sample of the current situation of the trunk
usage. In particular how many endpoints are currently in use.

This is a corrected version of:
Ib7b654168dc3512f55e45cc4755dc1f6f423d023

Change-Id: I6d3a74f6087512130d85002348787bffc672de81
Related: SYS#5201
2021-08-03 15:05:46 +00:00
Philipp Maier 96c6e06681 mgcp_trunk: check MGW domain name earlier
The MGW domain name is usually checked while resolving the endpoint
after the trunk has been resolved. This was no problem before, but since
we allow wildcarded DLCX requests, which require only a trunk to work,
the check is not done correctly for wildcarded DLCX requests and invalid
domain names may slip through.

Checking the domain name earlier while the trunk is resolved makes sense
and it fixes the problem.

Change-Id: I9944a9103981fb5f4d0d8714ee2847ae020f76df
2021-07-29 15:31:57 +02:00
Philipp Maier ce18705875 mgcp_protocol: assert endp when it becomes mandatory
The logic when an endp pointer is guranteed and when we are able to
process the request without the endp pointer populated is qute complex.
This shows up as a bug to coverity.

Change-Id: I1d4221f2df13c43321d5466534485cf21f0d9010
Fixes: CID#237088
2021-07-27 08:44:33 +00:00
Philipp Maier a8739fc7be mgcp_lient: remove unsubstantial FIXME note
Change-Id: Ibc73a8a95d93c4a0f8a891bfba6fd1293ae6f1b5
2021-07-22 13:46:43 +00:00
Philipp Maier 21dfeff8aa remove struct member wildcarded_req from struct mgcp_endpoint
The struct member bool wildcarded_req is no longer needed

Change-Id: Iabd2df8f0f8fcce964af647e3a6d8e4c3006ab29
Related: SYS#5535
2021-07-22 13:34:42 +00:00
Philipp Maier f486e741a4 mgcp_protocol: add support for wildcarded DLCX
The request handler handle_delete_con currently rejects wildcarded DLCX
requests even though a wildcarded DLCX would be a valuable tool to
remove lingering connections from the trunk in case osmo-bsc has to be
restarted.

Change-Id: I5c2de6b2b61ee64ba9c0618fd20e8fc2fe6a5ed3
Related: SYS#5535
2021-07-22 13:33:58 +00:00
Neels Hofmeyr 268568593e Revert "mgcp_ratectr: add stats items to monitor trunk usage"
This reverts commit 6bad138c96.

Reason for revert: heap-use-after-free during 'make check'
in mgcp_test.c test_retransmission()

Change-Id: I96792a719c9c7273676ab9ffe0b9e2aae4c23166
Related: OS#5201
2021-07-21 17:07:14 +00:00
Philipp Maier 41d59205c0 mgcp_protocol: refactor function create_response_with_sdp
The function create_response_with_sdp calls add_params, which is rather short.
The code in there can also be put in create_response_with_sdp. The
decision whether the endpoint name (Z) should be added or not, should be
made by the caller.

Change-Id: I7e29c513f4386832646e96194ed6c2397405ed3b
Related: SYS#5535
2021-07-21 11:16:36 +02:00
Philipp Maier 036612b035 mgcp_msg: add trunk parameter to mgcp_check_param for logging
There is not always an endp pointer present when mgcp_check_param() is
called but we always have a trunk pointer. Lets add a trunk parameter so
that the function can pick LOGPTRUNK when endp is not available.

Change-Id: I7327c5a105e7f0e20cabf64623ff9f36fd83bbb8
Related: SYS#5535
2021-07-21 11:16:36 +02:00
Philipp Maier 6bad138c96 mgcp_ratectr: add stats items to monitor trunk usage
We are currently counting events in rate counters, but there is
currently no way to get a sample of the current situation of the trunk
usage. In particular how many endpoints are currently in use.

Change-Id: Ib7b654168dc3512f55e45cc4755dc1f6f423d023
Related: SYS#5535
2021-07-20 17:00:09 +02:00
Philipp Maier 8dc3597085 mgcp_protocol: refactor MGCP request handling
At the moment the MGCP request handling and message parsing is not
clearly separated. The function mgcp_parse_header() in mgcp_msg.c is
also responsible for resolving an endpoint. This leads to unclear layer
separation. We eventually end up in a situation where we can not execute
any request handler without beeing able to resolve an endpoint, however
this is necessary if we want to implement wildcarded DLCX resquests.

In the current situation a wildcarded DLCX is not possible to implement
as we always have to resolve a an to get to the trunk which we need to
iterate. However, we just can't resolve a free endpoint in a situation
where all endpoints on te trunk are in use.

We have to refactor the request handler so that the parsing in mgcp_msg
only extracts us the endpoint name. The resolving is then done in
mgcp_handle_message() in mgcp_protocol.c. Then we are able to decide
what to do if we are unable to resolve an endpoint but still be able to
resolve the trunk.

This patch does not change the behaviour of osmo-mgw yet, but it lays
the foundation for request handler implementations that can still
perform useful actions if no endpoint but a trunk has been resolved. A
wilcarded DLCX is such a case. It does not need an endpoint, just the
trunk.

Change-Id: I9f519d8a0ee8a513fa1e74acf3ee7dbc0991cdde
Related: SYS#5535
2021-07-20 17:00:09 +02:00
Philipp Maier d70eef6421 mgcp_trunk: use unsigned int instead of int as trunk_nr
the trunk_nr is in struct mgcp_trunk. The trunk number can not be
negative and there is no magic value that makes use of the fact that it
could be negative. Lets use unsigned int to make this less irretating.

Change-Id: I5d0e1d76adb8c92d84331a0aca2496908e41d621
Related: SYS#5535
2021-07-20 16:34:50 +02:00
Philipp Maier 33d97f721d mgcp_protocol: refactor request handler array
the various types of MGCP requests are implemented in request handlers
functions. The function pointers to those functions are held in an array
that is used to find the right handler and call it then. The struct used
to model the array is defined somewhat away from the array definition
and there is also a macro in between that does not help to make the code
more understandable. Lets refactor this a bit to have it more distinct.

Change-Id: I2ef167b2ac179d2b0683a27a095f9662fda460bf
Related: SYS#5535
2021-07-19 09:03:05 +00:00
Neels Hofmeyr d57310731f mgcp_client: add logging on received MGCP messages
There is verbose debug logging on MGCP messages sent out to the MGW, but
none on received MGCP messages. Add Rx logging.

Related: SYS#5529
Change-Id: Id76230896aa87c1a12bd5ad87a62430c048a2873
2021-07-15 11:36:15 +02:00
Neels Hofmeyr a8c684b51f mgcp_client_fsm: add missing log_subsys
To see state transitions and events on LMGCP DEBUG logging, actually set
the log_subsys of the mgcp_client_fsm.

Related: SYS#5529
Change-Id: I6e84d5f7b85752a7a54f17be1d074b01d1467f26
2021-07-15 02:28:03 +02:00
Neels Hofmeyr 03fcc91aad mgcp_client_endpoint_fsm: on term, still let conns wait for DLCX OK
When the mgcp_client_endpoint_fsm terminates, do not directly pull each
conn FSM instance (mgcp_client_fsm) into oblivion as well. Those should
emit a DLCX and wait for the "OK" response before deallocating.

In programs using the mgcp client endpoint FSM (osmo-bsc, osmo-msc),
this gets rid of false LMGCP ERROR logging related to DLCX like this:

  Cannot find matching MGCP transaction for trans_id 71998

Related: SYS#5529
Change-Id: I8fbfec5533e9be9cc7ea550df1e6639a0a215973
2021-07-15 02:28:03 +02:00
Neels Hofmeyr 9de30e7cc4 mgcp_client_fsm delete: set mgcp_client as ctx, not NULL
Upon mgcp_conn_delete(), we unparent the FSM instance. Instead of
setting the talloc ctx to NULL, place the deleting conn under the
struct mgcp_client talloc ctx.

Related: SYS#5529
Change-Id: Ia12749e0d7d520f24a967c2df9a4651267e1019e
2021-07-15 02:26:56 +02:00
Philipp Maier d64c041cdb mgcp_endp: make wildcarded detection separate
osmo-mgw currently does only a very simple detection method for
wildcarded requests, but it makes sense to split this detection
off into a separate function so that it can be used from different code
locations and we still have it at one place only.

Change-Id: I27018c01afb8acabfcf5d435c996cc9806e52d6b
Related: SYS#5535
2021-07-14 15:15:15 +02:00
Philipp Maier a065e632c0 mgcp_ratectr: refactor rate counter and set group name
The rate counter group is currently only referenced by an index. In a
system with multiple trunks this makes it difficult to say which rate
counter group belongs to which trunk sinde the index that is used does
not necessarly corespond to a specific trunk.

Since rate counter groups can now get a human readable name assigned, we
should do that.

Also E1 specific rate counters only make sense for E1-trunks, so they
should not be present on the virtual trunk.

Change-Id: I5e7f0e9081a06af48e284afa5c36a095b2847704
2021-07-13 14:58:07 +02:00
Philipp Maier bd060c3c99 mgcp_trunk: add value string for trunk type.
Change-Id: I634fb2a03744117e976430468ab5c57d50ab0089
2021-07-09 13:57:32 +02:00
Philipp Maier 97cae477fb mgcp_ratectr: fix sourcecode formatting
Change-Id: I7460fd4cdf1a552bca1af681faaa9bd8f88f1404
2021-07-09 13:57:32 +02:00
Neels Hofmeyr a4b677c45a check_rtp_destin(): clarify log msg
The braces as put before this patch would read as {"is known", "is not
yet known"}, which is confusing the actual situation.

Change-Id: Icd1f22a9f4147a2758c2f068ecba46cf7f732604
2021-07-09 11:52:04 +00:00
Philipp Maier 6b7afe8f57 mgw_main: fix loop that resets all endpoints
The loop that resets all endpoints in read_call_agent() starts counting
at endpoint index 1, but it should begin counting at index 0

Change-Id: I82a385e547e54d82eff95213652317ed2fdaadd8
2021-07-09 11:51:00 +00:00
Philipp Maier 4131a65c4d mgcp_protocol: fix loop that sends dummy RTP packets
The logic in mgcp_keepalive_timer_cb() only sends dummy packets for
endpoints 1-N, leaving out endpoint 0, this is not correct it should
include all endpoints (0-N).

Change-Id: I99a9b572eac26780bc1286a8dd63c4c5652fda4f
2021-07-09 11:51:00 +00:00
Pau Espin 6a5e5ac2d4 Use DLMGCP instead of DLGLOBAL in log lines
Change-Id: I95e11e8b1803153315750840ecec01402becf819
2021-07-08 18:13:46 +02:00
Pau Espin b066bd0c86 Take into account Marker bit when patching RTP stream
On a deployed osmo-mgw with RTP traffic coming from a thirdparty
RTP source, it was usual to see log messages like following one from
time to time:
"The input timestamp has an alignment error of 159 on SSRC"

Doing a quick traffic analysis showed that the above mentioned RTP
source was generating traffic from time to time containing RTP packets
with the Marker (M) bit.

Those messages were logged because the verification & patching funcions
in osmo-mgw were not Marker-bit aware. Hence, this patch implements
support for Marker bit when handling RTP packets.

The Marker bit is usually used as a start of a talkspurt, and has to be
considered a syncrhonization point, where timestamp and relation to real
time don't need to match with last received RTP packet in the stream.

Related: SYS#5498
Change-Id: I1fb449eda49e82607649122b9b9d983a9e5983fa
2021-07-08 10:18:15 +00:00
Pau Espin d6769ea207 Fail rx MDCX sendrecv with invalid remote addr
use the recently new available API to check both remote address and
port, instead of only the port.
It doesn't make sense to configure a conn as sendrecv if we have no IP
address to send stuff to, similar to what was already being checked with
the port.

Change-Id: I6ce8cf52930d423d3db8c27251be8350a26a4ede
2021-07-07 14:12:35 +00:00
Pau Espin ca280a1a84 mgw: rx CRCX: Avoid sending dummy rtp if remote address not provided
The following sequence of events was seen frequently in a osmo-mgw
instance running on the field with heavy traffic:
"""
endpoint:rtpbridge/1@mgw CRCX: creating new connection ...
mgcp_network.c:236 endpoint:rtpbridge/1@mgw CI:1C8CCFA9 Failed to send dummy RTP packet.
"""

Allegedly, that happens because at CRCX time the remote address may
still not be known, hence we end up trying to send a dummy rtp packet
to, for instance, host 0.0.0.0 port 0, which will of course fail.
Let's avoid sending it if the address is not yet known.

Similary, same issue could be seen during MDCX, since at MDCX we don't
necessarily need to have a valid addr+port (there could be several MDCX
and only last one set it).

Finally, the keepalive timer also needs the check, since it iterates
over all connections, and it could be that some is still not fully
configured.

Related: SYS#5498
Change-Id: I8ceafda691146823b12232b4a804b4ce74acbdc8
2021-07-07 14:12:35 +00:00
Pau Espin a24dcc61d7 mgcp_send_dummy: Check RTP destination is available before attempt tx
Several log messages showing "Failed to send dummy RTP packet." were
seen in a osmo-mgw on the field. Let's re-use the function to check and
provide more information on what's wrong to ease debugging.

Related: SYS#5498
Change-Id: Iee6ac1f4d24c131e3bf40c37e6fdc252e5208ec8
2021-07-07 14:12:35 +00:00
Pau Espin 62d9df684f mgcp_network.c: Reorder some functions in file
This is a preparation for next commit, where one of the function will
require an static function available before it in the file.

Moving the functions also make sense, in order to have the 3 mgcp send
functions together for more easy understanding.

This commit does small style changes to fix followint linter errors:
"""
src/libosmo-mgcp/mgcp_network.c:1036: ERROR:SPACING: space required after that ',' (ctx:VxV)
src/libosmo-mgcp/mgcp_network.c:1091: WARNING:BRACES: braces {} are not necessary for any arm of this statement
src/libosmo-mgcp/mgcp_network.c:1145: ERROR:POINTER_LOCATION: "(foo*)" should be "(foo *)"
src/libosmo-mgcp/mgcp_network.c:1163: ERROR:ELSE_AFTER_BRACE: else should follow close brace '}'
src/libosmo-mgcp/mgcp_network.c:1204: ERROR:POINTER_LOCATION: "(foo*)" should be "(foo *)"
src/libosmo-mgcp/mgcp_network.c:1226: ERROR:POINTER_LOCATION: "(foo*)" should be "(foo *)"
"""

Change-Id: Iff8dab942182a0d909519acddb86be75d9cda7ae
2021-07-07 14:12:35 +00:00
Pau Espin 8358c4ba07 constify some function arg pointers
Change-Id: I7a7560fad96719da01f1ee30eea0be0e52c60e99
2021-07-07 13:44:39 +02:00
Pau Espin 4c77e9b748 Define patch_ssrc as bool type
This variable clearly holds a boolean value, so let's use stdef to make
it clear.

Change-Id: I05233a413b0d8511d056e8f93467a111c4bdf119
2021-07-07 12:18:43 +02:00
Pau Espin 33347a4f5d constify arg in addr_is_any()
Change-Id: Ie8cb750d2e265bae48bbfa8ea1d88f3e316879ed
2021-07-06 20:04:23 +02:00
Philipp Maier 7d86d4c523 mgcp_client: fix error handling in mgcp message generation
The functions add_lco and add_sdp assert when the codec string can not
be generated. This is the case when an unexpected codec is addressed in
the input parameter mgcp_msg for mgcp_msg_gen(). Even though the API
user is expected only to use the codec identifiers in mgcp_client.h the
check should not be done with an assert. Instead mgcp_msg_gen() should
just return NULL imediately.

Also all generation functions should not use magic numbers as return
codes. Instead constants from errno.h should be used. It is also
problematic that the return codes from msgb_printf are added up.
Depending. It makes more sense to use an OR operator since msgb_printf
only returns 0 or -EINVAL, so the end result will be -EINVAL if one or
more msgb_printf fail and not just a random negative value.

Change-Id: Ibb788343e0bec9c0eaf33e6e4727d4d36c100017
Related: OS#5119
2021-06-11 15:16:13 +02:00
Philipp Maier eb984bd630 mgcp_client: drop nunnecessary else statement
There is an elarly return statement, so there is no need for an else
branch.

Change-Id: I96d0d468ccab302f9add206164f4d5b1b768bb48
2021-06-11 12:22:51 +02:00
Philipp Maier b3d14eb552 mgcp_network: refactor MGCP_DUMMY_LOAD
The constant MGCP_DUMMY_LOAD is used ambigously. Sometimes it is used as
initalizer for an array, sometimes it is used as a single byte. Also the
name is not very expressive. Lets refactor this.

Change-Id: I21d96cefeeb647958bfa1e22a0ea030884746fad
Related: OS#4005
2021-06-07 20:14:35 +00:00
Pau Espin 907744e2fc Use new stat item/ctr getter APIs
Generated with spatch with this and similat snippets:
"""
@@
expression E1, E2;
@@
- &E2->ctr[E1]
+ rate_c

Change-Id: I53b75ea8a88bc1ae4ceb479ed272865054de9665
2021-06-04 17:57:34 +02:00
Philipp Maier 776846a0b9 mgcp_common, mgcp_udp_send: make parameter buf const
When mgcp_udp_send() is called, the memory where *buf is pointing to is
never modified. It should be marked as const.

Change-Id: Iac90de5beb19bf52586ac6ffeab9eb5152edf339
2021-05-20 14:22:08 +02:00
Neels Hofmeyr 59e7cf4437 add osmo_mgcpc_ep_ci_get_remote_rtp_info()
So far an mgcp_client user can get the RTP address+port information that
the MGW has returned upon a CRCX. Add this function to return the other
RTP end, i.e. address+port that the MGW was told to send RTP to.

This will be used to fix the MGCP in osmo-bsc, which so far mixes up the
two RTP ends and compares the MSC's RTP address+port with the MGW's one
and hence fails to skip unnecessary MDCX.

Change-Id: Ibb488925827d9dc0ccb1f8d6d84728745d086793
2021-05-19 19:05:44 +02:00
Keith Whyte b2064423fe Log some useful messages at ERROR/INFO instead of DEBUG
Change-Id: I22cbecab8d9f7a1980387f16c9a8da444aaa0311
2021-05-10 17:45:49 -05:00
Philipp Maier 97a9312be8 mgcp_network: fix implicit address loopback
A call agent may send a CRCX to create a connection in LOOPBACK mode but
without specifiying the destination address. In those cases the MGW
should deduct the destination address from the first incoming RTP
packet.

Unfortunately this is currently blocked by an OSMO_ASSERT that checks the
current sa_familiy against the sa_family from the incoming packet. This
makes no sense since the current sa_family is still uninitalized, which
is expected and not an error since the code that follows will initalize
it.

It also makes sense not to access the osmo_sockaddr struct members
individually but rather copy the address as a wohle.

Since the event only happens once and since it is also somewhat special
it makes sense to log the event as well.

Change-Id: I2dbd6f62170a7f62e5287d04a4ee6716b8786c26
Related: OS#5123
2021-05-10 12:50:34 +00:00
Neels Hofmeyr 427cede4ba tweak termination DLCX log msg
Sending a DLCX upon FSM cleanup is not unusual. Move the log about that
DLCX to INFO, and also print the endpoint and conn identifier.

Change-Id: Id723d949f101b66fb75296d01489d9dac350c7c8
2021-05-08 09:05:01 +00:00
Neels Hofmeyr 7371663aeb send DLCX only once
If the mgcp_client_fsm gets terminated in ST_DLCX_RESP, it has already
sent a DLCX to the MGW. So do not send a second one.

I noticed the duplicate DLCX for the same endpoint conn identifier while
running TTCN3 tests and watching the network trace of test teardown.

Change-Id: I35e415f67946b73c74408afe265618cfe4f72b0b
2021-05-08 09:05:01 +00:00
Keith Whyte fe53edd776 Add vty command 'show mgcp active'
With just one E1 line, the 'show mgcp' command outputs
several hundred lines to the vty. Add a 'active' parameter to
only show endpoints that are active.

Change-Id: I23a26b4fdc03d8b2469d293dd6c06ed83ce739e9
2021-05-07 19:00:17 +00:00
Harald Welte 55a9229922 mgw: Add support for setting socket priority from VTY
This is useful for affecting the 802.1Q PCP value without any separate
external packet filter rules for classification.

Change-Id: I69136c6dd114c24b1dace034e75dba5157bac37e
Depends: libosmocore.git I89abffcd125e6d073338a5c6437b9433220e1823
2021-04-29 21:25:33 +02:00
Harald Welte 7802ccc8d6 switch from osmo_sock_set_dscp() to OSMO_SOCK_F_DSCP()
libosmocore If22988735fe05e51226c6b091a5348dcf1208cdf introduces
an even more convenient mechanism for specifying the DSCP of
an IP socket via OSMO_SOCK_F_DSCP()

Change-Id: If0b11dea08716ed3952a25b546b2a9bd013857bf
2021-04-28 20:27:37 +02:00
Harald Welte 5936a9c23e TOS bits != DSCP
We have VTY options that allow to set the DSCP value.  However, we
then call a function to set the TOS bits in the kernel.  This is
very wrong.  The DSCP is only the upper 6 bits of the 8-bit TOS
value, and hence we are mussing that translation.

As libosmocore now has a helper function osmo_sock_set_dscp(),
let's make use of it and don't care about the low-level details.

However, this means we need to finally remove the deprecated
alias for "rtp ip-tos <0-255>".

Closes: OS#5137
Change-Id: I9c18c90273be97aedd2ad212b82f650e35c32851
Depends: libosmocore.git Ia4ba389a5b7e3e9d5f17a742a900d6fd68c08e40
2021-04-28 20:27:11 +02:00
Pau Espin 6ccdaa243f Bump version: 1.7.0.138-ace0b-dirty → 1.8.0
Change-Id: I64ff22193ab2a95a9a7d66e9957a875d096e23de
2021-02-23 18:28:45 +01:00
Philipp Maier 92a73cd637 mgcp_client: get rid of magic numbers for E1 slots
use NUM_E1_TS-1 instead of 31 in relation of E1 timeslot count

Change-Id: Iee134d70f05883fcd2e58e0b9c78ed70aea16695
2020-12-10 15:23:17 +00:00
Philipp Maier 41425e9b85 mgcp_vty: add missing VTY commands for E1 trunks
The E1 trunk lacks the VTY commands force-realloc and rtp-accept-all.
However, the function that write the E1 trunk config includes those
commands. Also they would be applicable, so lets add those two commands
also for E1 trunks.

Change-Id: Ief2bc7502bb8d1e0f9c784d42edbe1aed5ffb728
2020-11-26 21:52:00 +01:00
Philipp Maier 31682a3274 mgcp_vty: fix config write for trunk 0
When a trunk 0 is created (which is legal) than it is impossible to
write this trunk back to the config. The reason for this that there is
still a filtering in place from the time where trunk 0 was not allowed.
This filter needs to be extended to filter only virtual trunk 0 but not
E1 trunk 0 out.

Change-Id: Iad6b577b5a711c35f98c477351fde567d8c87298
2020-11-26 00:41:36 +01:00
Vadim Yanitskiy 648bec3982 main: add --vty-ref-mode, use vty_dump_xml_ref_mode()
Change-Id: Icb19a635fb7526058d3c47e24ed7d72584dffb0f
Depends: Ie2022a7f9e167e5ceacf15350c037dd43768ff40
Related: SYS#4910
2020-10-24 05:21:06 +07:00
Harald Welte c2a8f59560 use osmo_fd_setup() whenever applicable
Change-Id: I1586e855d37670af2602fc26b5d1fc72a32d1929
2020-10-21 11:56:17 +00:00
Philipp Maier 19c430feba mgcp_vty: add user attributes to configuration commands
To make clear which configuration changes (configure terminal)
apply when, add appropriate user attributes to VTY commands.

Change-Id: I2d9487801b3b78f94577264b56d217c926ef76a9
Related: SYS#4937, OS#1601
2020-10-08 19:26:51 +02:00
Vadim Yanitskiy 3ba409558e vty: use install_lib_element() and install_lib_element_ve()
See https://lists.osmocom.org/pipermail/openbsc/2020-October/013278.html.

Change-Id: I0eff9e0daa1c4327fec8034755986d768f9ba511
Depends: I8baf31ace93c536421893c2aa4e3d9d298dcbcc6
Related: SYS#4937
2020-10-04 16:48:55 +07:00
Philipp Maier 60be627557 mgcp_e1: do not expose function mgcp_e1_init()
The initialization of the E1 line in mgcp_e1.c is controlled internally,
there is no need to expose the function mgcp_e1_init(), lets make it
static and remove the prefix mgcp_

Change-Id: I6aba1c55c9b1d729709ee1fba2994c77bd848a9b
2020-09-23 10:25:52 +02:00
Philipp Maier 8cfe7df3f1 mgcp_vty: deprecate bind early command
The VTY command "bind early" is deprecated but it prints an error
message and the DEFUN is not set to DEFUN_DEPRECATED.

Change-Id: I594a87d2f63826a9d7b4f6a380586b08b3b79518
2020-09-23 10:25:52 +02:00
Philipp Maier ba94b6d7be mgcp_vty: remove remains of loopback functionality
There exist trunk_loop commands, which sets an trunk->audio_loop
variable, however all it does is to turn on a log message. There is no
actual implementation present. Lets set the VTY commands to
DEFUN_DEPRECATED and remove the variable.

Change-Id: I72b0f8b908e32643e6e3db6ac024371b13c074a1
2020-09-22 16:17:38 +02:00
Pau Espin 30e01355f6 cosmetic: Fix typo in comment
Change-Id: Ie982e6721f9840ac9c0bca62646f5c97cc0b1139
2020-09-21 15:45:38 +02:00
Pau Espin 06624e13d4 mgw: Fix return value documentation for API mgcp_verify_call_id
Change-Id: Ib5d32baf3a10dad73de29b4388eab14b93ab6f09
2020-09-21 15:45:38 +02:00
Pau Espin 19539866e5 mgw: Avoid logging notice message each time we receive nt param in LCO
We don't really use it so far and it doesn't deserve a NOTICE message.

Change-Id: I058dc37fe6229e879284a8f5e7677d6016129c47
2020-09-21 15:45:21 +02:00
Pau Espin 1dc2dcebbf cosmetic: Fix typo in comment
Change-Id: I87894dc710823226c1891c919a11ea32c326d3b9
2020-09-21 11:25:18 +02:00
Pau Espin 6049a63d1d mgw: Don't be case-sensitive when parsing X-Osmo-IGN param
Some implementations like our TTCN3 encoder set all param characters in
caps.

Related: SYS#5063
Change-Id: Ie4bc5e86551c55021ca6ca2fbc6fc56a26f5fb16
2020-09-21 11:03:25 +02:00
Philipp Maier 3ef8e76534 cosmetic: mgcp_client_fsm: change error message.
The error message: "abrupt FSM termination with connections still
present, sending unconditional DLCX..." implies a more serious problem
than in actually is. Even when connections are present on the
mgcp_client_fsm while it terminates, normal operation is still possible.
Lets change the loglevel to NOTICE and remove the "aprupt" from the
phrase.

Change-Id: I9749c024e208835bd4188bace13f723008de54c8
Related: SYS#5082
2020-09-18 08:46:21 +00:00
Neels Hofmeyr fbf07f3f69 change timer T2427001 to X2427
libosmo-mgcp-client looks up this timer in a caller provided osmo_tdef
definition. So far, all of our libosmo-mgcp-client callers do not configure
such a timer, so that we always use the default timer value.

We have introduced X timers (negative numbers) to indicate Osmocom specific
timers, and reserve T timers for 3GPP specified ones. So now is still a good
chance to move this timer to the Osmocom X realm.

Remove a comment about this timer at an unrelated place. It is still described
at osmo_mgcpc_ep_alloc().

Change-Id: If097f52701fd81f29bcca1d252f4fb4fca8a04f7
2020-09-16 00:02:31 +02:00
Pau Espin de133113a0 mgw: osmux: Fix conn watchdog timeout not updated
It is currently done upon receival of RTP packets in rx_rtp for pure RTP
conns, but nothing similar is done for Osmux conns, which eventually
trigger a connection time out.

Change-Id: Id592d7db7b9399a497176e0d28cc826b3bce48c0
2020-09-08 17:51:45 +02:00
Pau Espin 6d0a59a1bf mgw: Release endpoint after last conn times out
Otherwise some state is kept, like the previous CallId, which may then
provoke issues next time the endpoint is to be used.

Change-Id: I3ac4f4542c1c8c877127c64acce6c82b458f697f
2020-09-08 16:50:24 +02:00
Pau Espin 2491401932 mgw: osmux: Avoid sending packets on recvonly connection
Change-Id: I87b1fb7d73cbbb2a5d4d8a40a9527a3e05d9947b
2020-09-08 12:57:35 +02:00
Pau Espin fbbe8f2f98 mgw: Announce and rebind new local address if change required during MDCX
MDCX may provide a new remote address, which means we may need to update
our announced IP addr and re-bind our local end. This can happen for
instance if MGW initially provided an IPv4 during CRCX ACK, and now MDCX
tells us the remote has an IPv6 address.

Change-Id: Iaed424e2c209e1753e1f579752fc684aaad7a512
2020-09-07 18:12:59 +02:00
Pau Espin 71d42e778a mgw: Find and store RTP conn local_addr once during CRCX handling
It doesn't make sense to call the function several times since anyway we
are only binding during
allocate_port()->mgcp_bind_net_rtp_port()->bind_rtp()->mgcp_create_bind()->osmo_sock_init2().

Let's better calculate the local IP addr once and use that stored value.
THis is a previous step towards next commit updating the local IP addr
and re-bindng if encessary.

Change-Id: I803b99c5e5fe0f92a5bf6796d8c25df88d1608e6
2020-09-07 18:12:59 +02:00
Pau Espin 8a2a1b22fe mgw: Introduce VTY cmd 'rtp bind-ip-v6' command
This commit allows for fully IPv6 systems to work fine. However, if a
remote endpoint still wants to use IPv4, it will fail since at this
point osmo-mgw still doesn't re-bind the local end of the connection to
an IPv4 after having initially bound it to an IPv6 one. This kind of
scenarios get fixed in next commits.

TODO: really bind the socket if a different IP address is requested.

Change-Id: I8ed94bd3f674f498e6ba315f44a351fff9c1be15
2020-09-07 18:12:59 +02:00
Pau Espin a790f0c082 mgw: Initial IPv6 support
This commit contains the bulky work of moving all address parsing to
support IPv6 together with IPv4.
Some specific patches required for full IPv6+IPv4 support requiring
behavioral changes come after this one.

Full Osmux IPv6 support is left out of the scope of this patch.

Depends: libosmocore.git Ie07a38b05b7888885dba4ae795e9f3d9a561543d (> 1.4.0)
Depends: libosmocore.git I59bf4b4b3ed14766a5a5285923d1ffa9fc8b2294 (> 1.4.0)
Change-Id: I504ca776d88fd852bbaef07060c125980db3fdd7
2020-09-07 18:12:59 +02:00
Pau Espin 2741d6bb0e mgcp_client: copy back Connection Information from MDCX ACK
This is needed in case MGW changes the local IP address (for instance
because it initlaly offered an IPv4 address, and a client submitted a
remote IPv6 address, so MGW needs then to offer a local IPv6 address for
the RTP connection to be possible).

Change-Id: Ie964412b81fe6e10914790baaea724ca5f772adc
2020-09-07 15:55:30 +02:00
Pau Espin 74d0e5c318 mgcp_client: Deprecate unused IPv4-only API
The API and related implementation fields are not used internally nor
externally, and only support IPv4. Let's simply deprecate the API and
drop all the uneeded implementation.

Change-Id: I905d4c4efabb6b4a4bc5c02e956808777243cadc
2020-09-07 15:55:30 +02:00
Pau Espin c4ef4a21c6 mgcp_client: Support validating IPv6 addresses in CRCX and MDCX commands
Change-Id: Ie97675f173dc3a223f6c2ced913906d760ffb732
2020-09-07 15:55:30 +02:00
Pau Espin 531470a0ca mgcp_client: Allow setting IPv6 addresses
Change-Id: I257218b2ad7cbdd0ac4ae7fa75802bed74ce983f
2020-09-07 15:55:30 +02:00
Pau Espin 9dc73593a3 mgcp_client: Allow submitting and parsing IPv6 addr in SDP
Existing mgcp_client_test code required the '.' to trigger the same code
path, since with this commit we do extra checks and without a dot the
address is not accepted as IPv4 by osmo_ip_str_type().

Change-Id: I936bf57d37f5f0607dfe7fc66c37e424c3793f9b
2020-09-07 15:55:30 +02:00
Philipp Maier ae6858bddf mgcp_trunk: increase default number of virtual endpoints
The VTY default for the number of endpoints is 32. This is sufficient
for small setups and lab testing, but for medium sized setupts the limit
might be reached soon. Lets increase the default to 512 virtual endpoints.

Change-Id: I55605ea083565b6950d0820e3f72c50c9dc19ffa
Related: OS#4711
2020-09-07 12:11:25 +02:00
Philipp Maier 99d4d368e8 mgcp_endp: use NUM_E1_TS from e1_input.h
do not introduce another define constant, use NUM_E1_TS as number of E1
timeslots.

Change-Id: I3bbfb6822d5595f9d243849141883490fa8037cb
2020-09-07 12:00:51 +02:00
Pau Espin 8667d5169d mgcp_client: Use INET6_ADDRSTRLEN to store addresses in str format
Warning: This breaks libosmo-mgcp-cli ABI!

Related: SYS#4915
Change-Id: Ib778e9a72764103b52a462ea3c7fb56b23c1bcd6
2020-08-31 17:10:08 +02:00
Pau Espin 729bf3e45a mgcp-client: Support IPv6 in osmo_mgcpc_ep_ci_get_crcx_info_to_sockaddr() implementation
Change-Id: Ibbfc1c2485636502dc0f3aef3922432cc7fd6170
2020-08-31 17:10:08 +02:00
Philipp Maier 2f34b53b5b mgcp_e1: remove unused struct member trunk->e1.line
The struct member trunk->e1.line is never set. Also it is always
possible to use e1inp_line_find() to get a pointer to the e1.line.
Lets remove it.

Change-Id: Id4ff52285917ce3885b8dad3a16270999c9da0aa
2020-08-31 16:21:03 +02:00
Philipp Maier ad79f9eb99 mgcp_e1: make E1 ts initalization more debugable
The E1 timeslot initalization may fail silently in the last steps. There
is an error code returned, but no log lines are printed. This can make
debugging difficult.

Change-Id: I9aab17fc1ba6666c81b14035a8f1f17e5a55adaf
2020-08-31 16:21:03 +02:00
Pau Espin c57ad7ff9a cosmetic: Rename main talloc ctx
It contained name from a different program, probably due to main.c being
copied over during project start.

Change-Id: I4bfa40eec0277705f5d3335d779bff35518470a8
2020-08-20 08:43:52 +00:00
Pau Espin c59b5c533d Support setting rt-prio and cpu-affinity mask through VTY
Change-Id: Icfafea073a0cdac289a651d61632b4c6af39c6a9
Depends: libosmocore.git Change-Id If76a4bd2cc7b3c7adf5d84790a944d78be70e10a
Depends: osmo-gsm-masnuals.git Change-Id Icd75769ef630c3fa985fc5e2154d5521689cdd3c
Related: SYS#4986
2020-08-20 08:43:52 +00:00
Philipp Maier 0653cc8a7c mgcp_trunk: drop "trunk 0" limitation
Due to the internal handling of the trunks it was not possible to allow
an E1 trunk that has the ID 0. However this limitation is no longer
present, so we now can allow an E1 trunk with ID 0.

Change-Id: I302c2007628f607033686e277c407232351e66ad
Related: OS#2659
2020-08-20 06:21:41 +00:00
Philipp Maier 246233d0d4 cosmetic: add missing new-line
Change-Id: I4a4a7515e8d92ab39576c33765dd3dc581453ceb
2020-08-18 20:11:38 +02:00
Philipp Maier a910a81b7c mgcp_protocol: log when endpoint is unavailable
When endpoints become unavailable when MDCX/CRCX/DLCX are executed on
them a major problem may be the cause, lets make sure that those events
are logged.

Change-Id: I059b7e29f960e75a53bfb5dfb2b83ab3d79e84f3
2020-08-18 20:11:11 +02:00
Philipp Maier c8acee2234 mgcp_e1: use return value of e1inp_line_update()
The function e1inp_line_update() is called without assigning its return
code to the rc variable.

Change-Id: Ia72ea2dca210b038766151d547f66b7b7139a2c4
Fixes: CID#212160
2020-08-15 07:43:38 +00:00
Philipp Maier 993ea6be7a get rid of mgcp_internal.h
The file mgcp_internal.h still contains mostly definitions and types
that are relevant for mgcp_network.c and mgcp_protocol.c. Lets give
the network and protocol module its own header files, also move stuff
that does not relate to protocol and network to the appropiate places.

Change-Id: I837eaad771ed7252304db4a81c37953b70766fff
2020-08-10 22:56:59 +02:00
Philipp Maier 889fe7f203 mgcp_e1: finish E1 support, add E1 support from libosmoabis
Currently only the endpoint handling for E1 exists, but there is no
actual code behind it that handles the E1 traffic.

Change-Id: I6b93809b5ac7d01af55888347dd787b0bc997ae1
Related: OS#2659
2020-08-10 22:56:59 +02:00
Philipp Maier efd09d0b77 mgcp_protocol: remove unused variable
The function allocate_port() has pointer a variable end, it even does an
OSMO_ASSERT on it, but it never uses it. Lets remove it.

Change-Id: I369361389c6276e5511c683ebd630093713bdd37
2020-08-02 19:30:48 +02:00
Vadim Yanitskiy ffbc618a13 libosmo-mgcp-client: mgcp_client_tx(): return rc on error
Change-Id: Ic2080241ceb9e00109a5222b78c35b7971320c21
2020-07-31 10:21:49 +00:00
Harald Welte 563ffc51b5 libosmo-mgcp-client: fix memleak in case if no response is received
This problem was noticed while running several LCLS test cases from
ttcn3-bsc-test.  Every test case makes osmo-bsc leak at least two
chunks named 'struct mgcp_response_pending'.

Here is the related osmo-bsc output with additional debug messages:

  DRLL ERROR mgcp_client_fsm.c:525 MGCP_CONN(to-MSC)[0x612000016120]{ST_READY}:
             MGW/DLCX: abrupt FSM termination with connections still present,
             sending unconditional DLCX...
  DLMGCP DEBUG mgcp_client.c:1010 mgcp_client_next_trans_id(id=35): new trans ID
  DLMGCP DEBUG mgcp_client.c:918 mgcp_client_pending_add(id=35): allocated and queued
  DLMGCP DEBUG mgcp_client.c:962 Queued 53 bytes for MGCP GW
  DLMGCP DEBUG mgcp_client.c:725 Tx MGCP: r=127.0.0.1:2427<->l=127.0.0.1:2727:
               len=53 'DLCX 35 rtpbridge/1@mgw MGCP 1.0\r\nC: 5\r\nI:'...
  DLMGCP ERROR mgcp_client.c:704 Failed to read: r=127.0.0.1:2427<->l=127.0.0.1:2727:
               111='Connection refused'

The MGCP client FSM enqueues a DLCX from its fsm_cleanup_cb(), and
terminates.  Thus if the remote MGCP peer becomes unavailable (e.g.
due to a network failure), we would never get a response, and since
the FSM is already terminated, nobody would pop and free() the
response handler from the queue (mgcp->responses_pending).

As a simple workaround, let's avoid allocating dummy entries of
'struct mgcp_response_pending' without a response handler.  The
only case where an MGCP message is sent without a handler is
exactly during the FSM termination.

Change-Id: I83938ff47fa8570b8d9dc810a184864a0c0b58aa
Related: OS#4619
2020-07-31 10:21:49 +00:00
Neels Hofmeyr 51b42ff2e1 refactor: use msgb to receive, pass and send RTP packets
Instead of numerous arguments (buf, len and context data), use a msgb, like
most other osmo programs do, with a msb->cb pointing at a context data struct.

This opens the future for adding/stripping IuUP header data from the msgb
easily.

(Checked to pass current ttcn3-mgw-tests.)

Change-Id: I3af40b63bc49f8636d4e7ea2f8f83bb67f6619ee
2020-07-21 16:13:23 +00:00
Philipp Maier 7a755be4c2 mgcp_trunk: use talloc_zero_array instead of _talloc_zero_array
_talloc_zero_array is not supposed to be called by the API user. Lets
use talloc_zero_array instead.

Related: OS#2659
Change-Id: I27549585016a7998e9233c52f6d86429fc75f509
2020-07-16 11:57:45 +00:00
Philipp Maier 869b21c869 mgcp_vty: fix endpoint number configuration
At the moment the number of possible E1 endpoints (depends on the number
of E1 timeslots that should be used) is hardcoded and the configuration
of the number of virtual endpoints has an off-by-one problem.

For the E1 timeslots one might choose not to occupy all E1 timeslots of
once. A one TRX E1 BTS usually requires 3 E1 timeslots. One as D-Channel
timeslot and two to cover the voice channels. The voice channels
timeslots need to be set up in osmo-mgw, while the D-Channel timeslot
must not be touched. The VTY config needs to be able to reflect that.

Change-Id: I73b31e3c236a61ea0a6f76ef5ff98ce589f52c77
Related: OS#2547
2020-07-16 11:57:45 +00:00
Philipp Maier 24b8c0ce92 mgcp_trunk: remove double check
At the moment, the trunk prefix is checked twice. Lets re-arange the
code a bit so that the check only happens once.

Change-Id: I91fb8cf6e3b077ba8f18fdbcd071275c6fd7cacd
Related: OS#2547
2020-07-16 11:57:45 +00:00
Philipp Maier fe67e094ad mgcp_endp.c: cosmetic: fix sourcecode formatting
Change-Id: Ib83442d9a033b96c304bfd5e81206405d98d2ed5
2020-07-16 11:56:39 +00:00
Philipp Maier fbcf39976e mgcp_endp: use define constant to define max number of E1 subslots
There are 15 possible subslots (not all at the same time) in one E1
timeslot. Lets use a define constant for that.

Change-Id: If7cb74e486946aff09e22abf8a8885bf0693f34e
Related: OS#2547
2020-07-16 11:56:39 +00:00
Philipp Maier 4863591c23 mgcp_client: add function to generate e1-endpoint names
mgcp_client.h offers functions to generate endpoint names for wildcarded
request. This is used in osmo-bsc, lets now also add a function that can
generate e1-endpoint names.

Change-Id: Iec35b5bae8a7b07ddb3559f7114a24dcd10e8f14
Related: OS#2547
2020-07-16 11:56:39 +00:00
Harald Welte 827da2c867 mgcp_client_pending_add(): Consider "talloc returns NULL" case
Change-Id: I43a4715fa41fba5a5506fc08e3c21ef6f9ca2521
2020-07-15 10:57:08 +02:00
Harald Welte efe1571b7b mgcp_client_init(): consider "talloc returns NULL" case
Change-Id: I131019b3c04a7860a118991c8f3bb31185fb11e4
2020-07-15 10:56:45 +02:00
Neels Hofmeyr f5531845bc add osmo-mgw --vty-ref-xml: dump VTY ref XML to stdout
Add only a long option to not clutter the cmdline namespace.

To add a long option without a short letter is slightly complex: use the 'flag'
and 'val' mechanism as in 'man 3 getopt' to write an option index to
long_option.

Depends: Ic74bbdb6dc5ea05f03c791cc70184861e39cd492 (libosmocore)
Change-Id: Ia988ea1c3f5169bdb4d21f2f05933665711cfcbf
2020-07-11 01:53:32 +00:00
Vadim Yanitskiy 13fae78b32 libosmo-mgcp: always check result of msgb_printf() in add_fmtp()
Change-Id: I218ac21612116366eabd0c75ce3648bad4e27abf
2020-07-08 07:54:16 +00:00
Vadim Yanitskiy b7d395d83a libosmo-mgcp: fix unused extra argument to printf() in add_fmtp()
Change-Id: Ie48da20aea7bc1eedc3f8b5b4a708458f0860a25
Closes: CID#208171
2020-07-08 07:54:16 +00:00
Philipp Maier 6fbbeec064 mgcp_trunk: pick trunk by number and type
The function mgcp_trunk_by_num() is used to directly pick a specific
trunk that is known by its id number (sometimes called "index").
Traditionally the virtual trunk will reside under id number 0 and all
consecutively created E1 trunks will be created under number 1 to 64.
This works fine, but puts a limitation on us should we ever introduce an
aditional trunk type (e.g. T1). Since the numbers must be unique
regardless of the trunk type one could not have an E1 trunk number 1 and
e.g. a T1 trunk number 1 at the same time. So we should pick the trunk
not only by its number, but also by its type to allow different trunk
types to carry the same number. The trunks will still be distinguishable
by its type along with the respective endpoint prefix.

Change-Id: I7af1e9ce601babd4a51e88201a98319e03945f83
Related: OS#2659
2020-07-07 12:45:14 +02:00
Philipp Maier 0ffa3bdc45 endp: require domain name also for E1 endpoints
RFC3435 requires an MGW domain name appeneded to every endpoints. When
defining endpoint names in Appendix E, the domain name is is not
mentioned for digital trunks, however, this does not mean that digital
trunks do not have a domain appended. Osmo-mgw currently violates the
spec because it explicitly checks if the domain name is _NOT_ present
for E1 endpoints.

Change-Id: Ibb800b689e090b97b58d0206959b660890acd967
Related: OS#2547
2020-07-07 10:25:35 +00:00
Vadim Yanitskiy ca8639dc05 libosmo-mgcp: fix unsigned compared against 0 in mgcp_trunk_by_name()
e1_trunk_nr_from_epname() returns a signed integer:

  int e1_trunk_nr_from_epname(const char *epname);

mgcp_trunk_by_num() accepts a signed integer:

  struct mgcp_trunk *mgcp_trunk_by_num(const struct mgcp_config *cfg, int index);

Change-Id: Id333a6ddcefd37d82d19f9378ab87d1c02ffd7e3
Closes: CID#211333
2020-07-07 14:03:15 +07:00
Philipp Maier 8d6a193c1a endp: add E1 endpoint interlocking
E1 endpoint names also represent different rates, this may mean that
some rate / subslot combinations are not possible because they overlap
within nthe timeslot. When the equipment (BSC) is properly configured,
this will be no problem, however invalid configuration may cause the
selection of overlapping endpoints and this needs to be prevented, and
logged. Also rate counters need to be in place.

Change-Id: I18e90b10648a7e504371179ad144645fc82e1c27
Related: OS#2547
2020-07-06 19:19:27 +02:00
Philipp Maier 0996a1e4ae endp: add typeset for e1-endpoints
Add an endpoint typeset for E1 support, also lets add dummy callbacks
for the cleanup and rtp dispatch functionality.

Related: OS#2547
Change-Id: I68b719a906e8f7251f0ca8c74ceec73bc40376f7
2020-07-04 10:02:56 +02:00
Philipp Maier 7e9ddc9904 trunk: parse E1 trunk number
The E1 trunk number is currently not parsed, whenever a trunk prefix is
detected that indicates an E1 trunk, then the entire request is
rejected.

Parse the trunk number and select the trunk accordingly

Related: OS#2547
Change-Id: Ifdaab953544151e73b58cc3e95d21afdb40765f4
2020-07-04 10:02:56 +02:00
Philipp Maier 080935a8c7 mgcp_trunk: fix docstring for mgcp_trunk_alloc()
Change-Id: I845397d829476e15f7e3221c63ea35a00a965647
2020-07-01 23:09:48 +02:00
Philipp Maier a466f57007 mgcp_client: add docstring for mgcp_client_rtpbridge_wildcard()
Change-Id: I2d811b6ddda5b330054145abff37c996c54c3e3a
2020-06-26 10:50:06 +02:00
Vadim Yanitskiy e674345e29 libosmo-mgcp-client: fix use-after-free in mgcp_msg_gen()
Change-Id: Ib8b6c25489a6a704912aa1763d7430c8055d54e3
2020-06-18 11:40:37 +00:00
Vadim Yanitskiy 3f8139c55f libosmo-mgcp-client: fix use-after-free in mgcp_client_tx()
This function calls mgcp_client_pending_add(), that in its turn
allocates a 'mgcp_response_pending' and appends it to the queue.

In case of an error, it calls mgcp_client_handle_response() that
would free the 'mgcp_response_pending', but this structure would
still remain in the linked list (the queue).

Change-Id: Id94bb93a6b0ea7b7241cf7868112e9bec3e60f0b
2020-06-18 11:40:37 +00:00
Philipp Maier 98c09b3f30 endp: add name generator function for E1 endpoints
Currently the endpoint name that is generated for an E1 endpoint is not
correct. Let's add an endpoint name generator function that derives a
full endpoint name for a given E1 index

Change-Id: I70e0c3f96aa3947165f9926666815ee5614c8f57
Related: OS#2547
2020-06-18 12:31:16 +02:00
Philipp Maier 7462b95829 endp: move endpoint name generation into mgcp_endp.c
When the trunk allocates its endpoints by using mgcp_endp_alloc()
ist passes the name for each endpoint as a parameter. In order to
generate the name endpoint specific knowlege is required.

This process can be simplified, since all what
mgcp_trunk_alloc_endpts() does is calling mgcp_endp_alloc() in a loop in
order to generate a consecuitve series of endpoints. The endpoint names
are generated from the index of the for loop.

When we just pass the index instead of the endpoint name to
mgcp_endp_alloc(), then we can greatly simplify the code since all the
knowledge about the name generation can go into mgcp_endp.c. The
endpoint will name itsself by the trunk properties and the index number
we pass with the allocator function.

Change-Id: I8dee07f1c63037d1f73113f69c612d1f2703cee5
Related: OS#2659
2020-06-18 12:03:19 +02:00
Philipp Maier 7a64182f9a cosmetic: remove excess space
Change-Id: I3620efea2f809fb822c5b8f0a68036066dc6aa95
2020-06-18 12:03:19 +02:00
Philipp Maier d19de2ee80 trunk: get rid of virt_trunk pointer
The virtual trunk is a pre-configured trunk that always exists. It is
kept separate from the trunk list using a separate pointer. This makes
thinks unecessarly complicated. Lets organize the trunk in the trunk
list like any other trunk, except that we automatically create it on
startup and assign it always the trunk id number 0.

Change-Id: I81934fbd211b225ab7920e78510729c8e22607b3
Related: OS#2659
2020-06-18 12:03:19 +02:00
Philipp Maier 08eb9352ab cosmetic: fix doxygen for mgcp_cleanup_rtp_bridge_cb()
Change-Id: I231b9026402a0f0d3aa23c8de748fc7e88b8bb36
2020-06-18 12:03:19 +02:00
Philipp Maier 0b79d21c7f cosmetic: fix doxygen
Change-Id: I31f7ccf748d09062dbb82f3e921a90e77db02a3d
2020-06-18 12:03:19 +02:00
Philipp Maier bce5f29265 cosmetic: fix doxygen
Change-Id: Icd757befce68fd12aa0832b7790ca118103a102c
2020-06-18 11:59:26 +02:00
Philipp Maier 7f90ddb519 mgcp_trunk: remove audio_name and audio_payload
get rid of deprecated trunk parameters which seem to be leftovers
from the old osmo-bsc_mgcp implementation. This is in particular
audio_name and audio_payload in struct mgcp_trunk_config which
allowed the user to "hardcode" an andio name and payload type
via VTY configuration

The removal of the struct members above also require a change to
mgcp_codec.c. The code that is is never actively used and even
causes wrong behavior when activated (set the no-transcoding
flag in VTY). Since the code is removed also the unit tests
also require to be changed to match the new behavior.

Change-Id: Ia050ec3cd34b410dfe089c41b977ae3d5aed7354
Related: OS#2659
2020-06-12 17:08:41 +02:00
Philipp Maier c66ab2c4c3 osmo-mgw: refactor endpoint and trunk handling
The trunk and endpoint handling in osmo-mgw is still very complex and
implemented in various places (mostly mgcp_protocol.c). Also we use
still integers for endpoint identification, which is not flexible enough
to address timeslots/subslots on an E1 trunk. Some refactoring is needed.

  - get rid of integers as endpoint identifiers, use strings instead and
    find the endpoint based on its string name on the trunk.

  - identify the trunk based on the trunk prefix given in the endpoint
    name.

  - refactor trunk and endpoint allocation. Aggregate functionality in
    in mgcp_endp.c and mgcp_trunk.c. Also remove non-reusable code that
    relates to the still exisiting, but unfinished E1 trunk support.

  - refactor rate counters, put them into a separate module and do no
    longer allocate them per trunk. Allocate them globally instead.

Change-Id: Ia8cf4d6caf05a4e13f1f507dc68cbabb7e6239aa
Related: OS#2659
2020-06-12 17:08:41 +02:00
Philipp Maier f53796c1fe mgcp_vty: fix indentation in VTY config write
The config under the node mgcp is written with an indentation that has
one space too much.

Change-Id: I2aefeaf3d7ad4a98b7bfcdc7cbc1ce6ebcbe0537
Related: OS#2659
2020-06-03 13:57:38 +02:00
Philipp Maier 14b27a8893 osmo-mgw: rename struct mgcp_trunk_config and symbol tcfg
rename struct mgcp_trunk_config to struct mgcp_trunk and the related
symbol name "tcfg" to "trunk" in order to better match the reality.

Change-Id: I02889dbf8149e139b1bd0326e13ce4c1aec867d1
Related: OS#2659
2020-06-02 20:30:58 +02:00
Philipp Maier 21be42abed mgcp_vty: fix indentation
Some DEFUN macros are not correctly indented

Change-Id: I613f2ebcb06a01744d957e87e8b1215a141b43c4
2020-05-29 21:41:46 +02:00
Philipp Maier 2d681fd84c vty: fix unreachable code (error msg on trunk alloc fail)
When a trunk is selected that does not exist, a new one is created. In
this case the VTY would print an error message but the function exits
early. The code that would print the error is unreachable.

Change-Id: Ie8c3b083174eb8209df2c06f65db6d7bbfaa87f7
fixes: CID#210637
2020-05-29 16:49:06 +02:00
Harald Welte c39b1bffec mgcp_protocol: Avoid code duplication between virtual + other trunks
There were two code paths that were supposed to do exactly the same,
but then in Change-Id I3994af016fb96427263edbba05f560743f85fdd4 only
one of the two was modified, resulting in OS#4034

Let's
* dynamically allocate the virtual trunk
* rename mgcp_config.trunk to mgcp_config.virt_trunk to clarify
* as a result, abolish copy+pasted code for trunk initialization

Change-Id: I54762af6d417b849a24b6e71b6c5c996a5cb3fa6
Related: OS#4034
2020-05-28 09:23:25 +00:00
Philipp Maier 74390c521e cosmetic: remove excess newlines
Change-Id: Idefe3e86d5b659666bf0356991906c9a2f858aae
2020-05-26 22:26:04 +02:00
Alexander Chemeris ebb9bf3f12 rtp_bridge: Demote a chatty ERROR log message to DEBUG level.
Not having a second leg of an MGCP endpoint is a normal situtation
and can't be treated as an ERROR message, especially not as an ERROR
message logged on every RTP packet. This happens routinely at
the beginning of call setup and we get tens of ERROR messages in
the logs for every call.

Change-Id: If741a742208772bda4e59236345d7ae650368d5a
2020-05-11 18:14:31 +03:00
Alexander Chemeris 61cf9bb5f1 mgcp_network: Fix a typo in the comment bahviour -> behaviour
Change-Id: I59a06b95e9bbf90c038c5c9234f5c857315d5f07
2020-05-11 18:13:53 +03:00
Pau Espin a7152e055a Use OSMO_FD_* instead of deprecated BSC_FD_*
New define is available since libosmocore 1.1.0, and we already require
1.1.0, so no need to update dependenices.
Let's change it to avoid people re-using old BSC_FD_* symbols when
copy-pasting somewhere else.

Change-Id: I9b6463af713f76c06a144bdbf202c0d91eef4d21
2020-05-09 19:15:50 +02:00
Alexander Chemeris 63866009e2 counters: Implement more useful counters.
Right now a lot of errors with MGCP processing are invisible in rate
counters which makes them difficult to trace or even notice in
a production environment. E.g. reaching a limit of MGCP endpoints
is completely invisible even though it's a critical opertion alarm.

Change-Id: I6db68f044255c927dfd534fed880e405ec3ed4d6
2020-05-05 22:17:41 +03:00
Alexander Chemeris dab89af070 vty: Prepend VTY output of counters for better visual separation.
Before this patch rate counters started right after trunk information
with no visual separation which was quite confusing. We're adding
a new line and a header to warn a user of the section change.

Change-Id: I3943def03ab821b05ac597f40bdfa4a3a71ddca3
2020-05-05 20:38:16 +03:00
Neels Hofmeyr 3abced8d64 allow larger MGCP client wqueue: 10 -> 1024
Enlarge the MGCP client workqueue maximum limit by factor 100.

During Abis load testing, a BSC trying to DLCX 200 conns at the same time hit
the limit of 10 very very quickly, and everything broke down.

Change-Id: I8980cce37bae0757828b28455b25c77bcb6316d0
2020-03-10 03:55:35 +01:00
Harald Welte a48ff4a738 Update per-trunk global packet/byte counters in real-time
We used to update only the per-connection rx/tx packet/byte counters
on-the-fly, but not the per-trunk global counters.  The latter would
only be updated at the end of a connection.  As MGCP connections
can last quite long (think of a long phone call) this is maybe
not the best of ideas.

Note: The all_rtp:err_tstmp_in and all_rt:err_tstmp_out are still
only updated at the end of a connection.

Change-Id: Ib3866cb8149d3257fcf39733846c97c33881c4ee
Related: OS#4437
2020-03-08 14:50:20 +01:00
Neels Hofmeyr 6c92f9d83e fix vty dump_trunk: start from zero, do not omit first CONN
Change-Id: Ibb97fbf5c0b46ab841c3f6126b3622e4a8054feb
2020-03-08 14:12:54 +01:00
Harald Welte 9852e22101 Add CTRL interface to osmo-mgw
OsmoMGW has a lot of nice built-in statistics (rate_ctr,...) but it
seems the only way to look at them is via the VTY. While libosmocore
contains automatic exposure of all rate counters via CTRL, the CTRL
interface simply is not used by osmo-mgw so far.

Closes: OS#4441
Change-Id: I7ed6bdb9f4749c24ca11a5905a620546cfe42952
2020-03-08 13:23:46 +01:00
Harald Welte b141cccbfb Fix number of endpoints of default trunk
If a config file doesn't have a 'number endpoints' config line,
we would use -1 as unsigned integer and end up with
 number endpoints 4294967295
if the config file is re-written

Change-Id: I05a3814117b1d6e0cdc30740da31709ce333df4b
Closes: OS#4034
2020-03-08 10:51:41 +01:00
Pau Espin ec45068972 Bump version: 1.6.0.30-832bc-dirty → 1.7.0
libosmocore required version increased due to include used from
libosmo-netif including an include from libosmocore which in previous
versions misses including an include from a symbol used.

Change-Id: I1d5f14b1ad36b2ed94343fca71fdc622424403d3
2020-01-03 13:35:10 +01:00
Harald Welte 73f9c02f49 exit(2) on unsupported positional arguments on command line
Change-Id: I5398edac755280d2982285802516681aa5255470
2019-12-03 21:51:05 +01:00
Harald Welte 6a25a61142 Move fsm_mgcp_client regstration to __attribute__((contructor))
This way we can avoid the runtime overhead of checking whether or not
it is initialized over and over again.  It also brings this code more
in line with other users of osmo_fsm_register().

Change-Id: Ia73ba8e46c13d925e88203e08a8966839e573183
2019-12-01 15:39:12 +01:00
Harald Welte 1dbbed169a mgcp_client: Check for osmo_fsm_register() error return value
Change-Id: Ie5e7fa419117349d098b0158ed840341094f3c16
2019-12-01 15:39:12 +01:00
Neels Hofmeyr ca2aec0235 fix use-after-free: require new fsm deferred dealloc, check for term
API doc: require osmo_fsm_set_dealloc_ctx().

mgcp_client during delete: do not reparent the FSM when it is already
terminating.

I have recently discovered a vulnerability: if an endpoint FSM deallocates
during event handling of a successful MGCP response, this causes a
use-after-free; and once that is fixed, a state change on the already
terminated FSM causes a pointer corruption by using already cleaned data
structures. osmo_fsm_set_dealloc_ctx() fixes the use-after-free, and
osmo_fsm_set_term_stops_actions() fixes the pointer corruption.

Related: Ib7fce7b7d54dfb87af97544796680919e5929a50 (osmo-bsc),
         I08c03946605aa12e0a5ce8b3c773704ef5327a7a (osmo-msc)
Depends: Ief4dba9ea587c9b4aea69993e965fbb20fb80e78 (libosmocore),
         I0adc13a1a998e953b6c850efa2761350dd07e03a (libosmocore)
Change-Id: I7df2e9202b04e7ca7366bb0a8ec53cf3bb14faf3
2019-11-01 17:37:59 +01:00
Neels Hofmeyr e827831514 accept MGCP without SDP
SDP is an optional part of MGCP messages. Do not fail when there is no SDP part.

Practically this is useful to compose simpler MGCP responses from TTCN3 tests.
osmo-mgw itself always includes SDP, so there is no real impact on operating
libosmo-mgcp-client with osmo-mgw from osmo-bsc or osmo-msc.

Change-Id: I608001626459ea72415fb142f857550bbb90c683
2019-11-01 17:37:40 +01:00
Neels Hofmeyr 923d60bb12 client: endp fsm: add osmo_mgcpc_ep_ci_ep()
If an API user only has access to the ci FSM (which is managed via an opaque
struct), provide this function to obtain the backpointer to the parent endpoint
FSM, mostly to be able to call osmo_mgcpc_ep_cancel_notify() on it.

osmo-msc's rtp_stream FSM will use this in
I351bb8e8fbc46eb629bcd599f6453e2c84c15015.

Change-Id: I14f7a46031327fb2b2047b998eae6ad0bb7324ad
2019-10-29 23:04:11 +01:00
Neels Hofmeyr f2bf8dc8c8 client: endp fsm: allow cancelling a notify event
There is a use-after-free problem if a 'notify' FSM as passed to
osmo_mgcpc_ep_ci_request() deallocates before the notify event has been
dispatched. To avoid that, add API to allow cancelling a notify.

Change-Id: I41687d7f3a808587ab7f7520f46dcc3c29cff92d
2019-10-29 23:04:01 +01:00
Neels Hofmeyr 055ded74de client: endp fsm: clear ci[] before dispatching DLCX success
In case the ep gets deallocated during event dispatch, move all ci[] cleanup to
*before* dispatching a DLCX OK event. Afterwards, it might become a
use-after-free.

Change-Id: Ib2032e5566e465c02a9a525ccd38f9dcc84fb669
2019-10-29 23:03:50 +01:00
Neels Hofmeyr 3ff71284fa client: endp fsm: add notify struct, prep for cancel-notify
Upcoming patches introduce copying notify information. Prepare by combining
notify info into a separate sub-struct.

Change-Id: I47c0dd112011b8cb4dc88e8efd010466d4ba6308
2019-10-29 23:03:36 +01:00
Neels Hofmeyr cc0b97e197 clear pending requests on MGCP failure
If an MGCP operation on one conn of an endpoint fails, no longer carry out
other pending requests for that endpoint. Only allow pending DLCX to be sent.

If the caller schedules two CRCX at the same time, the first CRCX is sent with
a wildcarded endpoint name like "rtpbridge/*@mgw". Only when the OK for that
returns an allocated endpoint, will the second CRCX be sent, using that actual
allocated endpoint name. But, if the first CRCX fails, then we should not send
another wildcard CRCX, but rather assume both as failed.

Since a failed MGCP message means that the endpoint becomes unusable /
undefined and typically deallocates directly, we can actually discard all other
pending requests except for DLCX.

Change-Id: Icb1d485224bb486b84eff6329f0bd95932e63246
2019-10-02 22:03:25 +02:00
Neels Hofmeyr 8c69e29820 mgcp_client_fsm cleanup: Do not assert on DLCX failure
During FSM instance cleanup, a DLCX message composition may fail if a preceding
received MGCP message was missing parameters. If that occurs, don't crash, just
log an error and deallocate.

Change-Id: Ic1c3c4deeb4703b60e870af9d5d7be216a87fff8
2019-10-02 21:11:56 +02:00
Pau Espin 843d9038ce mgw: Allocate mgcp_conn instance under tcfg->endpoints
The connection becomes to the endpoint, so let's not use the NULL
context there.

Related: OS#3950
Change-Id: I6f6441c3ef21aac577af08eb018bacbca4c45fb7
2019-09-19 17:44:16 +02:00
Neels Hofmeyr 3ab8ca4d84 SDP: store all ptmap entries
If a ptmap appears in the SDP, always store it in the ptmap array. No longer
attempt to drop entries if they match the conventional payload type number.

- One reason is that the past code only matched full explicit "FOO/8000/1"
  strings, while the channel number "/1" can be omitted to imply 1; by simply
  storing everything received in the SDP, there is no need to add complexity
  to match both "FOO/8000" and "FOO/8000/1".

- The other reason is to rather parse exactly what was received, instead of
  filtering entries, to take away a degree of implied magic.

Change-Id: I2a69c21e68c602daf804744212d335ab1eafd81b
2019-08-28 04:57:19 +02:00
Neels Hofmeyr 23f4048b57 tweak mgcp_parse_audio_ptime_rtpmap()
- move the error logging up to the actual errors. Each appear only once, no
  goto labels needed.

- instead of strstr("rtpmap"), use osmo_str_startswith("a=rtpmap:") to more
  concisely trigger on the actual syntax of the audio parameters. Same for
  "a=ptime:".

Change-Id: I730111e245da8485c1b5e8811f75d140e379cec6
2019-08-28 04:57:19 +02:00
Neels Hofmeyr 401b740ccd explicitly free codecs in mgcp_rtp_conn_cleanup()
There are allocated bits in conn->end.codecs[], free them.

This is not fixing a memleak, since mgcp_rtp_conn_cleanup() is currently only
called from mgcp_conn_free(), which soon after frees the conn; the conn serves
as talloc parent for the codec strings freed in this patch.

The rationale: it is better style to explicitly free them, to also guard
against future callers of mgcp_rtp_conn_cleanup() which might expect complete
cleanup.

Change-Id: Ic471107ce6e94d9ce582d887429c744ff93e3053
2019-08-28 04:57:19 +02:00
Neels Hofmeyr a468b0f57f mgcp_codec_add: fix audio_name size check
Needs to account for terminating '\0'.

Change-Id: I27896beef6ffcc1cb6207daaba6c8b2b03eb513d
2019-08-28 04:56:52 +02:00
Neels Hofmeyr b0cfa7272e mgcp_codec: codec_set(): log about all possible errors
In codec_set(), for each 'goto error', log the specific error cause.

Also add a TODO and a FIXME comment about inventing dynamic payload type
numbers.

Change-Id: I0b44b574c814882b6f8ae7cd738a6f481cd721fd
2019-08-28 00:17:40 +02:00
Neels Hofmeyr 683e05f60b ptmap: implicitly match '/8000' and '/8000/1'
In codecs_same(), do not compare the complete audio_name. The parts of it are
already checked individually:
- subtype_name ("AMR"),
- rate ("8000"; defaults to 8000 if omitted) and
- channels ("1"; defaults to 1 if omitted)
So by also checking the complete audio_name, we brushed over the match of
implicit "/8000" and "/8000/1", which otherwise works out fine.

As a result, translating payload type numbers in RTP headers now also works if
one conn of an endpoint set an rtpmap with "AMR/8000" and the other conn set
"AMR/8000/1".

It seems to me that most PBX out there generate ptmaps omitting the "/1", so
fixing this should make us more interoperable with third party SDP.

See IETF RFC4566 section 6. SDP Attributes:
  For audio streams, <encoding parameters> indicates the number
  of audio channels.  This parameter is OPTIONAL and may be
  omitted if the number of channels is one, provided that no
  additional parameters are needed.

Also allowing to omit the "/8000" is a mere side effect of this patch.
Omitting the rate does not seem to be specified in an RFC, but is logical for
audio codecs defined to require exactly 8000 set as rate (most GSM codecs).

Add tests in mgcp_test.c.

Change-Id: Iab00bf9a55b1847f85999077114b37e70fb677c2
2019-08-28 00:17:40 +02:00
Neels Hofmeyr 16b637bf1b differentiate AMR octet-aligned=0 vs =1
Add corresponding tests in mgcp_test.c

Change-Id: Ib8be73a7ca1b95ce794d130e8eb206dcee700124
2019-08-28 00:17:40 +02:00
Neels Hofmeyr ce64f18587 fix memleak: actually free strings in mgcp_codec_reset_all()
The audio_name and subtype_name are allocated from talloc, so they need to be
freed before resetting the codec array. Use mgcp_codec_free() to ensure this.

Change-Id: I07f207dcb7ce66bbf3445a30af41e696677b384f
2019-08-27 21:53:17 +00:00
Neels Hofmeyr 667fa59b0c mgcp_codec: split codec_free() off of codec_init()
Both are used only in the same .c file, so make them static.

Move codec_set() guts into codec_add(): codec_set is only called by codec_add.
If codec_set were left separate, it'd look like the codec_init() is a bug and
lacks a codec_free() first. When looking at the entire context in codec_add(),
it becomes obvious that codec_init() should be called, not codec_free(),
because it is populating a previously unused entry.

Preparation to fix a memleak in a conn's codec list.

Change-Id: I120cab0a352a1e7b31c8f9c720c47b2c291311d7
2019-08-27 21:53:17 +00:00
Neels Hofmeyr 5a6220f43b mgcp_send(): stop looping on conversion error
If mgcp_send() runs a transcoder loop, break the loop if rfc5993_hr_convert()
or amr_oa_bwe_convert() return with error. Possibly fixes an infinite loop
situation for erratic packets? (Didn't check for that in detail.)

Change-Id: Iba115a0b1d74e7cefba5dcdd777e98ddea9eba8c
2019-08-21 23:06:02 +02:00
Neels Hofmeyr 7c6dd3c2c3 fix crashes: don't assert on incoming RTP packet size
Remove various OSMO_ASSERT() on size of incoming packets. Doing an assert on
incoming data is a DoS attack vector, absolute no-go. Instead, return -EINVAL
and keep running.

Change some return values to be able to distinguish successful operation from
invalid RTP sizes. In rtp_data_net(), make sure to return negative if the RTP
packet was invalid.

Some of the error return codes implemented here will only be used in upcoming
patch Iba115a0b1d74e7cefba5dcdd777e98ddea9eba8c.

Change-Id: I6bc6ee950ce07bcc2c585c30fad02b81153bdde2
2019-08-21 23:05:35 +02:00
Neels Hofmeyr 740af6ed44 mgcp_codec: constify 'param' arg
Change-Id: I3ec6b57298f78604d5cd453f1db6d90ddfd6a2ba
2019-08-09 02:28:37 +02:00
Neels Hofmeyr 782d607962 rename codecs_cmp() to codecs_same()
The name 'cmp' implies a return value of -1, 0, 1 to indicate smaller, match or
larger. Since this function returns bool, it should not be named with 'cmp'.

Change-Id: I2d41b1a32300e295551e85d3f9ab82dd2b0e86b8
2019-08-09 02:28:37 +02:00
Pau Espin 50e52e45f9 Bump version: 1.5.0.84-a2d10-dirty → 1.6.0
Change-Id: I57277c34bbab1fc9ea2be6a754d5a79786ce627d
2019-08-07 16:52:59 +02:00
Pau Espin f54eb96338 Remove undefined param passed to {logging,osmo_stats}_vty_add_cmds
Since March 15th 2017, libosmocore API logging_vty_add_cmds() had its
parameter removed (c65c5b4ea075ef6cef11fff9442ae0b15c1d6af7). However,
definition in C file doesn't contain "(void)", which means number of
parameters is undefined and thus compiler doesn't complain. Let's remove
parameters from all callers before enforcing "(void)" on it.
API osmo_stats_vty_add_cmds never had a param list but has seem problem
(no "void"), so some users decided to pass a parameter to it.

Change-Id: Icf4d18969488c9eacca7a597d4071828e649e772
Related: OS#4138
2019-08-05 16:05:14 +02:00
Pau Espin a2b1c5e6f6 Fix return variable of strtoul()
Return variable specified by strtoul() is "unsigned long int". If
"unsigned int" is used, according to Coverity the return value can never
be ULONG_MAX:

CID 202173:  Integer handling issues  (CONSTANT_EXPRESSION_RESULT)
"pt == 18446744073709551615UL /* 9223372036854775807L * 2UL + 1UL */" is always false regardless of the values of its operands. This occurs as the logical second operand of "&&".

Furthermore, PT is 7 bit in RTP header [1], so let's avoid accepting
incorrect values.

[1] https://tools.ietf.org/html/rfc3550#section-5

Fixes: c5c1430a1c ("Catch unsigned integer MGCP parsing errors with strtoul")
Fixes: Coverity CID#202172
FIxes: Coverity CID#202173
Change-Id: Ice9eee6a252fab73dbab5ebf3cfc83c1b354fd08
2019-07-29 18:33:38 +02:00
Pau Espin c5c1430a1c Catch unsigned integer MGCP parsing errors with strtoul
Checks to find if strotul failed are taken both from:
man strtoul
man strtol

Change-Id: Ifba1c1e3151d6f92f9da3d4ca2569a5908455ca8
2019-07-25 12:14:48 +00:00
Harald Welte 06a49fc04b mgcp_sdp: Don't check if an unsigned int is below 0
Change-Id: I129f5c6175a8e961bc08b9768bdf22a2232e2fcb
Closes: CID#188849
2019-07-21 09:28:28 +02:00
Pau Espin 9b508f6b53 mgw: Allow receiving uppercase noanswer keyword
MGCP RFC3435 (https://tools.ietf.org/html/rfc3435) states almost all
text has to be handled in a case-insensitive way, except SDP parts.

Related: OS#4001
Change-Id: I637cb20f0af4de33ebf6589b1aff260d57d03e7b
2019-07-03 12:29:43 +02:00
Pau Espin 6e26c70f46 mgw: Allow receiving lowercase X-Osmo-Ign Callid field
MGCP RFC3435 (https://tools.ietf.org/html/rfc3435) states almost all
text has to be handled in a case-insensitive way, except SDP parts.

Related: OS#4001

Change-Id: Ifc1b3bfe6ff6922df478cea89bbbb291b5fa5706
2019-07-03 12:29:43 +02:00
Pau Espin 9a34592c09 mgw: Allow receiving lowercase MGCP header keyword
MGCP RFC3435 (https://tools.ietf.org/html/rfc3435) states almost all
text has to be handled in a case-insensitive way, except SDP parts.

Related: OS#4001
Change-Id: I7d1e55faddafa3c3093d38513d4a434ecf5ea5bd
2019-07-03 12:29:43 +02:00
Pau Espin 7eb6f2cb56 mgw: Make check of duplicated LCO fields case insensitive
Otherwise it would not catch a duplicate if first the param is
introduced in upper case and later in lower case, or the other way
around.

MGCP RFC3435 (https://tools.ietf.org/html/rfc3435) states almost all
text has to be handled in a case-insensitive way, except SDP parts.

Related: OS#4001
Change-Id: I254bfa3a2d2562441ca3a576cc8e1e7967d9c495
2019-07-03 12:29:42 +02:00
Pau Espin 83fd8a5692 mgw: Support receiving lowercase LCO codec
MGCP RFC3435 (https://tools.ietf.org/html/rfc3435) states almost all
text has to be handled in a case-insensitive way, except SDP parts.

Related: OS#4001
Change-Id: I51dc1cdcbe2a5587769335fbecb5039ef22cae5d
2019-07-03 12:29:42 +02:00
Pau Espin 17058484d1 mgw: Support receiving uppercase connection mode
MGCP RFC3435 (https://tools.ietf.org/html/rfc3435) states almost all
text has to be handled in a case-insensitive way, except SDP parts.

Related: OS#4001
Change-Id: I4da93dfc69b5585a197a7e201a1afb72c2f97030
2019-07-03 12:29:42 +02:00
Pau Espin 166077ea48 mgcp-cli: Support lowercase header parameters
MGCP RFC3435 (https://tools.ietf.org/html/rfc3435) states almost all
text has to be handled in a case-insensitive way, except SDP parts.

Related: OS#4001
Change-Id: I4f7b07b77c2946e9cd6f0eeca00011bd905126dd
2019-07-03 12:29:37 +02:00
Pau Espin 0c6c3c1da6 mgw: Support lowercase header parameters
MGCP RFC3435 (https://tools.ietf.org/html/rfc3435) states almost all
text has to be handled in a case-insensitive way, except SDP parts.

Related: OS#4001
Change-Id: I48252415f9d0cd985ad097f334aa4c1665f52511
2019-07-03 12:28:45 +02:00
Pau Espin fe9a1fe03b mgw: Support uppercase LCO options
MGCP RFC3435 (https://tools.ietf.org/html/rfc3435) states almost all
text has to be handled in a case-insensitive way, except SDP parts.

Related: OS#4001
Change-Id: Ic28a5eacc4c441d68e8a20d2743956ab2e01125d
2019-07-03 12:27:53 +02:00
Oliver Smith 189f29e939 vty: update desc of conn-timeout
It can be used together with LCLS, just make sure to also enable
keep-alive packets.

In OS#3429 it was pointed out, that during LCLS the media path remains
active but is not used. Without any traffic flowing, this looks like a
timed out connection and so it will be killed if conn-timeout is set.

However, OsmoBSC and OsmoMSC have an option to enable RTP keep-alive
packets (through libosmo-mgcp, originally intended to keep connections
behind NAT open). If that option is enabled, the keep-alive packets
should also prevent the conn-timeout.

Related: OS#3783
Change-Id: Ib4d19104d558a26a444a80fb36f4b7b33bc5cc59
2019-06-26 16:28:14 +02:00
Oliver Smith d2ce444008 vty: allow 0 as conn-timeout to disable it
VTY command to disable conn-timeout again, after it has been enabled.
conn-timeout was introduced in [1].

[1] Change-Id I18886052e090466f73829133c24f011806cc1fe0.
Change-Id: I7dee7dafaaf4bb93fd692ea06b52b9e012beac6d
2019-06-26 16:27:54 +02:00
Pau Espin 1b1d7ed98f mgcp-cli: Validate osmux cid value during mgcp_msg_gen
Change-Id: I5c4d39b346b94de933f86200902c6c0ea2e1d5df
2019-05-23 16:48:24 +02:00
Pau Espin df7d97e4b4 osmux: Fix hardcoded rtp payload_type 98 in osmux conn
Depends on: libosmo-netif.git I5cbeb494a8932953d9fd2dc24dacf8cd97fd84e4
Change-Id: I24698a9613bc0de9460c6ad2d1067c152ebcf0b2
2019-05-19 19:28:49 +02:00
Pau Espin 85978dadab osmux: Fix CID release for non-enabled connections
Change-Id: If65c70b421476776e20233733722d72aa26d69a8
2019-05-19 07:31:51 +00:00
Pau Espin 9aaaab6b3b osmux: Fix loopback for Osmux connections
Move code in RTP specific path to generic dispatch_rtp_cb. This way
loopback logic is applied both for Osmux and RTP connections.

Change-Id: Ia30f5a14f150e4d151eac4d1046ea834f1685a5f
2019-05-15 23:32:09 +02:00
Pau Espin c1ad553d86 osmux: Use DUMMY ft msg as per Osmux spec
That MGCP_DUMMY_LOAD is an old hack prior to Osmux spec update, and it's
not nice since it cannot be 100% distinguished from a usual AMR ft
frame.

Let's use the correct DUMMY ft type and build it according spec. Allow
handling differently the old format for a while until we are sure no old
implementations (like bsc-nat) exist sending that kind of message.

Change-Id: Ib17d20b87b28aade49ba60519b56a96e694819af
2019-05-15 23:00:55 +02:00
Pau Espin c1bf4694e7 mgw, mgcp-li: Handle X-Osmux param name as case insensitive
RFC3435 states most text (except SDP) must be handled as case
insensitive.

Related: OS#4001
Change-Id: Iac073f1db46569b46eddeaecc9934a2986bd50f1
2019-05-14 20:35:13 +02:00
Pau Espin 1442c5a99e osmux: Redo read/write osmux glue code to have data routed correctly
Remove old BTS/NET no longer in use and meaningless. Use new osmo-mgw
APIs to inject payload RTP<->Osmux on the correct socket and conn.

Change-Id: I60b6ba3ffdc74efff945ba13a0b736798bdf5d8c
2019-05-14 11:36:33 +02:00
Pau Espin dac2ca7e21 osmux: Delay osmux enable of conn until remote addr is configured by MDCX
Change-Id: I243e53681ebeb3d9cd8ed38bb132172b41745795
2019-05-14 11:36:33 +02:00
Pau Espin 375252279c osmux: Improve logging around osmux enabling events
Change-Id: Iab687b97010fd484cb353b240b120c9c382066fa
2019-05-14 11:36:33 +02:00
Pau Espin 295570c631 osmux: Use remote port to send osmux frames
Previously the local one was used but nobody cared because probably
everybody was using default 1984 on different IP addresses.

Change-Id: I01e590465fa247185d74103578681e9041249099
2019-05-14 11:36:33 +02:00
Pau Espin a93c6e9263 osmux: Provide correct local port during mgcp resp
Also document some possible future improvements for local addr.

Change-Id: I12c8fcdc8b772b9f92a70774406d4662f44bd9a9
2019-05-14 11:36:33 +02:00
Pau Espin 30907dc9d8 mgcp-cli: endpoint_fsm: Add API to retrieve Osmux CID from MGW
Change-Id: Ic80d47f8eedda1c6ac8c33f1cafeb55c65e74692
2019-05-14 11:36:33 +02:00
Pau Espin 14f8a08f44 osmux: Drop unneeded OSMUX_STATE_NEGOTIATING
Change-Id: I94e7df3287d037975adc16c5ada05adf94269ead
2019-05-14 11:36:33 +02:00
Pau Espin c63f15a9a7 mgcp-cli: Parse X-Osmux on MDCX response
During MDCX state is already changed to ACTIVATING but we still want to
send the local CID back to announce that we still use same local CID.

Change-Id: If182a48743ebe03f97caf9034e49b9947014bdf9
2019-05-14 11:36:29 +02:00
Pau Espin ca538fc5eb mgcp-cli: Allow submitting X-Osmux on MDCX request
Change-Id: I41243f3ed212ace6087d5b0341e3a52f4069e37d
2019-05-14 11:32:33 +02:00
Pau Espin 6be2c49538 osmux: Handle Osmux MGCP extension in MDCX messages
Change-Id: I65e53bd5dd08b58c253e03d2f358f3be523a2688
2019-05-14 11:32:33 +02:00
Pau Espin 91088c305f mgcp-cli: Parse X-Osmux on CRCX response
Change-Id: I6174d092b7425b8d3d6d02a55bf294be3e710e6a
2019-05-14 11:32:29 +02:00
Pau Espin 900cd6518a mgcp-cli: Allow submitting X-Osmux on CRCX request
Change-Id: I73b4c62baf39050da81d65553cbea07bc51163de
2019-05-14 11:29:44 +02:00