Commit Graph

491 Commits

Author SHA1 Message Date
Pau Espin c1ad7fd92b osmux: Drop unused role parameter
Change-Id: I39c2852bb60aaba4f85188c55f157e4abec47a0e
2022-10-06 13:10:51 +02:00
Pau Espin 70c03f5e44 Add Osmux IPv6 support
A new osmux bind-ip-v6 VTY command is added, similar to what's already
available for RTP. This way the user can decide whether to support IPv4,
IPv6 or both types of IP versions.

Both IP sockets are by default disabled, and must be explicitly enabled
by setting the bind-ip in the VTY configuration.

Change-Id: I446cd7da217e9f4a74995d7784ae55dcc60a29b7
2022-10-05 10:32:42 +02:00
Pau Espin 5ffd127384 Get rid of separate rtp_port field
Let's use the port part of the struct mgcp_rtp_end->addr field instead
of keeping it separate. This makes it easier passing around and
using/checking the RTP remote address + port, and avoids confusion
having to check stuff outside of the address, with its port part
potentially unset.

Change-Id: I294eb5d85fae79bf62d36eb9e818426e187d442c
2022-10-04 14:44:44 +02:00
Pau Espin e740665cab Fix regression in detection of legacy dummy packets
A commit refactored this code around one year ago, which broke osmux
detection of dummy messages. This commit partially reverts the earlier
commit and rearranges the existing code to make it more robust.

Fixes: b3d14eb552
Change-Id: Iedf085932c45af5d13e04e56a4cd1082de81d869
2022-10-04 12:16:15 +02:00
Pau Espin 9d939b6d5d osmux: Unify rtp_conn osmux type into a single type
There's no need to separate between BSS and CN side nowadays, the
different types are used nowehere. This separation dates from
osmo-bsc-nat code days.

Change-Id: I65effeddf033eb1955553e8d659c593b4e67f7bc
2022-10-03 17:16:16 +02:00
Pau Espin de805b6772 osmux: cleanup misleading code calling rtp_bridge_cb
Documentation of rtp_bridge_cb was outdated, and caused confusion when
adding initial osmux support. Let's clear all the mess.

Change-Id: I42d1f2e2919eae3b1555ca4929e571855960792e
2022-10-03 17:16:16 +02:00
Pau Espin d48a811f6c osmux: Allocate rate counters during initialization of osmux conn
Let's not delay allocation of rate counters until the osmux conn is
fully enabled, since we may want to count stuff before that point in
time.

Fixes crash accessing null conn->osmux.ctrg in
MGCP_Test.TC_two_crcx_and_rtp_osmux_bidir.

Change-Id: Ic31d3567f4d24e628f8983d8362e5c7c2f66ec02
2022-09-27 13:45:04 +02:00
Pau Espin b7f52b414e osmux: Rename field s/init/initialized
Change-Id: Ic48de396b1d8a0774611b4a1c2248ba79bdaf044
2022-09-25 00:14:03 +02:00
Pau Espin ea7aaf2eca vty: show per-connection Osmux VTY stats
Related: SYS#5987
Change-Id: Ieab6dcbd195c8e01a73a2a832bce78ee015ae1c3
2022-09-25 00:06:00 +02:00
Pau Espin 432ee9d150 osmux: Improve per-conn tx rate counters
Change-Id: If030f5d921bdfcfcd00b015b4a9e48bb3b04e721
2022-09-25 00:06:00 +02:00
Pau Espin 2177919edb osmux: Support local CID != remote CID
So far the implementation only allowed the remote CID being the same as
the one dynamically implemented internally.

Related: SYS#6138
Change-Id: I6b03eabc0305580c9788c529bec7dda9044a008f
2022-09-23 16:55:46 +02:00
Pau Espin 87f114a1d0 Use bool type instead of int in config field
Change-Id: Ie2624a6a6848c3c88deb39760317860d8074acb9
2022-09-23 15:48:43 +02:00
Pau Espin 928a20b540 osmux: Rename field osmux usage policy and define it with proper type
Change-Id: I7f41a443f488b75df792597ec3cec8f7e97a7411
2022-09-23 15:48:20 +02:00
Pau Espin 582c2bf7b0 osmux: Add connection and global rate counters
Change-Id: I200a4aa3908cac0ec729d980a66f3df7f55e4da7
2022-09-22 21:44:46 +02:00
Pau Espin daf5bcea99 mgcp_conn: rename field s/rate_ctr_group/ctrg/g
This makes all lines operating on rate groups way shorter. The "ctrg"
naming is already used in tons of places in osmocom code.

Change-Id: I745eddbf66e7d811bb73c8ae9bb54ea93073c71b
2022-09-22 21:21:12 +02:00
Pau Espin a29f155301 Fix typo in ratectr description
Change-Id: I2ac8581f13814f320767ba188ef7cf3286fa443d
2022-09-22 21:21:12 +02:00
Pau Espin 21bcf6abd8 osmux: Attach osmux to virtual trunk
It makes sense to handle one osmux socket per trunk. Since we only so
far operate one RTP/osmux trunk, let's stick to that only one for
simplicity.

Change-Id: I173266c4058d5db9479d773d7dec1304bc8f1f99
2022-09-22 18:23:05 +02:00
Pau Espin 26e810d8a9 cosmetic: mgcp_conn.h: fix indentation whitespace
Change-Id: I6b12b589d1b0a8f95a8283aac8ba0ad22026b43f
2022-09-22 17:16:20 +02:00
Pau Espin 15e7e4f37d osmux: Use osmo_sockaddr wherever possible
This cleans up all the code, and makes it a lot easier to add IPv6 support
later on (mostly only a matter of adding an IPv6 bind address in VTY).
Similar changes were done to the Osmux code being added to osmo-bts.

Related: SYS#5987
Change-Id: I5a100fc654f88d29b2bcd85889a5a92aef3d576d
2022-09-09 18:13:40 +02:00
Pau Espin ec5e85b84e Add Osmux log category
Change-Id: Ia75de7965c39f3f84164a25584d901dbdd43f10f
2022-09-09 16:04:19 +02:00
Pau Espin 33639166a2 osmux: Use new osmux APIs to let libosmo-netif alloc struct osmux_out_handle
This way we don't need to worry about implementation details (struct
size) in the future in case they change (they will).

Related: OS#5987
Requires: libosmo-netif.git Change-Id Ie8df581f375c9a183a7af60b431561bda82f6e34
Change-Id: I2d0d8c152b8f1234ddfcd74d6cb04b1818b41510
2022-09-07 08:29:35 +00:00
Pau Espin 5892b2e4db Use Osmux default port define from libosmo-netif
Change-Id: Ibf5fbec591307232be98cad914c0df4b2993db15
Requires: libosmo-netif.git Ibfd058bceeeaa1384a00d8fcd6d6268b445e19bd
2022-08-12 14:08:34 +02:00
Pau Espin 452f2ba5bd IuUP: Support RFCI ID != RFCI Index
The initially merged IuUP API and implementation in libosmocore assumed
that RFCI with ID was always in the position of its ID inside the list
of RFCIs. This was the case for messages sent by ip.access nano3g as well
as our own osmocom implementation. However it was noticed that other nodes
from other vendors actually use other order, as allowed by the IuUP message
format.
Hence, we need to break the assumption and provide explicit ID
information in the list.

NOTICE: This commit implies an API change when using libosmogsm.
However, the previous API was never available in any libosmogsm release,
and only available in both libosmogsm and osmo-mgw master, so we are
only breaking compatibility between different master versions, which is
acceptable.

Related: SYS#5969
Depends: libosmocore.git Change-Id Ib21cee2e30bf83dff4e167f79541796007af9845
Change-Id: I40ebf36ad37f5196751caf2297a340e538ad28bc
2022-05-25 13:37:28 +02: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 2c40164ff0 Define mgcp_rtp_end.output_enabled as bool
Change-Id: I55f7796ef774f86050041f2c5e3a2f8f7d1f56df
2022-01-03 12:29:39 +01: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 25ecc91c3b rename strip_epname and find_specific_endpoint and make them available
Change-Id: I4f76676640a308ab84da3848e1c1ec22bd5d9566
2021-11-03 15:19:13 +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 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 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 1e8d5fa44b fix missing includes and forward declarations
Change-Id: I669e475f7ab74abef85f0f6194cc37db04af62e3
2021-09-10 17:24:45 +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 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 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 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 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 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 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 d02716d6c2 mgcp_protocol: forward declare mgcp_endpoint
The function mgcp_rtp_end_config() takes an mgcp_endpoint as
parameter. The header file does not declare the mgcp_endp struct
and it also does not include mgcp_endp.h because that also would
cause problems. Since the endp parameter in mgcp_rtp_end_config()
is only a pointer we can simply forward declare it.

This patch will currently not change anythig, but it will prevent
compiler warnings when we remove the endp pointer from
struct mgcp_parse_data in a follow up patch

Related: SYS#5535
Change-Id: I07a4d6f9d5334b1f4cf4b262482b8a67b1384398
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 02c880a7dd mgcp_ratectr: drop ws line
Change-Id: Ib0bb231ebf1d941dee85bdea596f07fe26510ce5
2021-07-09 13:57:32 +02:00
Philipp Maier ba09687768 mgcp_trunk: drop ws line
Change-Id: Iac2dfe5643d87066490a77211f01ee9ee3d9fcc7
2021-07-09 13:57:32 +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 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 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
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
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
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
Philipp Maier 3c293b418b mgcp_trunk: get rid of magic numbers for E1 slots
use NUM_E1_TS-1 instead of 31 in relation of E1 timeslot count

Change-Id: I1cf5fa17f7455448a08ec3c32febca450eadb21e
2020-11-27 15:12:33 +01: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
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 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 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 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 0ab152b2c6 mgw: Fix mgcp_rtp_end field description comment
Change-Id: Ieb044daaaa47572cd9a2524ea69e903200527d17
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 ee2f33bf9a mgcp_client: Make MGCP_CLIENT_LOCAL_ADDR_DEFAULT IPv6 compatible
If "0.0.0.0", the default, is passed together with an IPv6 configured
address (ex: "mgw remote-ip ::1") in VTY, socket creation will fail due
to address version mismatch (because getaddrinfo() returns only an IPv4
address in the local result set).
If instead NULL is passed, then 2 entries are returned, one in IPv4 and
one in IPv6, and osmo_sock_init2 is smart enough to take one or another
when passed AF_UNSPEC.

Change-Id: I1be6f3b71486ce1782ba6b8c62f25145b42ec894
2020-09-07 15:55:30 +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 1add5a53cb mgcp-client: Fix trailing whitespace in mgcp_client_fsm.h
Change-Id: Iad9ee764c1b6d7960a810a3eef95b207596e4796
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 113141d4f9 mgcp_ratectr: fix comments in header file
Change-Id: Idd9d7b108e81b44501b78264284dfa46e679d994
2020-08-10 22:56:59 +02: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
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 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
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 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 58a1ba85c7 mgcp_internal: remove forward declaration struct mgcp_endpoint_type
In is no longer needed to define struct mgcp_endpoint_type in
mgcp_internal.h

Change-Id: Iecea75e5620e8a2f1fd2066949c116bf72320aca
Related: OS#2659
2020-07-06 19:18:52 +02:00
Philipp Maier b0c05aa3a9 mgcp_conn: move struct mgcp_conn mgcp_conn.h
The struct mgcp_conn is currently defined in mgcp_internal.h, however it
makes more sense to put the struct in mgcp_conn.h

Change-Id: Ibe9a356300ddb9567432fe48e37c956b7125c79c
Related: OS#2659
2020-07-06 19:17:17 +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 04bbb9de3e mgcp_trunk: use enum type for trunk type variable
The trunk_type variable in struct mgcp_trunk is specified as an int,
however there is an enum mgcp_trunk_type specified. Lets use the enum as
type for trunk_type instead of int.

Related: OS#2659
Change-Id: I8e8b0cf448cfe67ad3b7caab24f301708d2a515f
2020-07-02 21:25:19 +02:00
Philipp Maier bea56788cb mgcp_trunk: move enum mgcp_trunk_type to mgcp_trunk.h
The enum mgcp_trunk_type, which is currently located in mgcp_internal.h
makes more sense in mgcp_trunk.h, so lets move it.

Related: OS#2659
Change-Id: I077121503c44fc112a33f1c946f368414e28f841
2020-07-01 23:21:51 +02:00
Philipp Maier 48bcc2ee12 mgcp_osmux: remove unused define constants
The define constants CONN_ID_BTS and CONN_ID_NET were used in mgcp_osmux
long time ago when osmux support was temporarly broken. Now those
defines are no longer used anywhere, so lets remove them.

Change-Id: I3d0b9d482ef0e2187bccace5779a7f8b9507c4e2
2020-07-01 23:13:25 +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 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 3d5a2dd19f ratectr: move rate counter definitions into mgcp_ratectr.h
The rate counter definition (enums) are still in mgcp.h.
Lets move them to mgcp_ratectr.h since it makes more sense
to keep them there.

Change-Id: Id37f66673bc20f9c2cc47a6b44cdfe75f728b936
Related: OS#2659
2020-06-18 11:31:24 +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 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
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