Commit Graph

30 Commits

Author SHA1 Message Date
Philipp Maier 2a9ba66922 mgcp_e1: be more frugal withe E1 line resources
At the moment we open an E1 timeslot when needed, but we never
close it even when it is not needed anymore. This may block other
entities from using it. Lets add some logic to detect whether the E1
timeslot is still needed and make sure that it is closed when it is no
longer needed.

Depends: libosmo-abis.git I073cfaba0d5073447842f22665e213135ea3f635
Change-Id: Ie6a32abbc5cd984f6d72a384e3b47c1b82ce7058
Related: OS#5198
2023-02-22 13:03:54 +01:00
Philipp Maier c70c08cd49 mgcp_endp: cosmetic: remove unnecessary new line
Change-Id: I5892bc2e07ab16356acb4e75c6f9c31f6604d41e
2023-02-09 13:37:34 +01:00
Philipp Maier a8f13286ff mgcp_endp: cosmetic move mgcp_endp_release to the end
It is more logical to move the function mgcp_endp_release to the end
since it is used to release the endpoint when it is no longer needed for
any transmission. (Also the follow up patch requires the function to be
moved)

Change-Id: Id3166a6a817ddb9ce36ff1b375ff8ed3598a00c2
2023-02-09 13:37:03 +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 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 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 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
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 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 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
Pau Espin 30e01355f6 cosmetic: Fix typo in comment
Change-Id: Ie982e6721f9840ac9c0bca62646f5c97cc0b1139
2020-09-21 15:45: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
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
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 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 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
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 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 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
Pau Espin 3239f6212e Introduce log fmt helpers LOGPENDP and LOGPCONN
Let's define macro once and use it everywhere instead of passing endp
information in different ways everywhere. Furthermore, use conn whenever
appropiate to have more information.

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

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

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

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

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

- rename wildcarded_crcx to wildcarded_req

- ensure the flag is refreshed with every new request

Change-Id: Ia5063ec65f5bc3a8a0943d1fd823aaeee20b8637
2018-02-05 10:32:42 +01:00
Philipp Maier 37d11c80da cosmetic: rename mgcp_ep.c/h to mgcp_endp.c/h
The short term of endpoint has always been "endp" througout the whole
project and not "ep".

- rename mcgp_ep.c to mgcp_endp.c

- rename mgcp_ep.h to mgcp_endp.h

Change-Id: Id52047bb2d0407655ac272c858ed3412b8ae9e6d
2018-02-05 10:32:42 +01:00