Commit Graph

6972 Commits

Author SHA1 Message Date
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
Harald Welte 55863e42c1 osmo-mgw.spec.in: Add missing dependency to libosmotrau
Change-Id: I2d5f8b1d852079b8f82adb681d7e6b72a8358cf1
2020-08-14 09:48:35 +02:00
Vadim Yanitskiy 6177cae2a2 debian/control: change maintainer to the Osmocom team / mailing list
Change-Id: I1bb002b257d4bef83d181d615411e443c1831f00
2020-08-13 16:09:02 +07:00
Harald Welte 6af3ccf65d osmo-mgw.spec.in: Fix dependency to libosmoabis
Confusingly, in Debian the package is called libosmo-abis, but in
the CentOS/RPM it's called libosmoabis.  Fixes a bug introduced
in I45717bda3ef7eba1ef59b993cc8a69bf2f92a29f

Change-Id: I97dfec72a99295148e84e60c1e5037381f736c03
2020-08-13 09:35:12 +02:00
Harald Welte 03cb5f3397 debian/control + SPEC: Add missing build dependency to libosmo-abis
In I6b93809b5ac7d01af55888347dd787b0bc997ae1 we introduced E1 support
to osmo-mgw, but failed to add it to the build dependencies of the
Debian packages, making network:osmocmo:nightly builds fail.

Change-Id: I45717bda3ef7eba1ef59b993cc8a69bf2f92a29f
2020-08-13 07:28:55 +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
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 06ea49159e mgcp_test: remove trunk2 from unit-test
Some of the unit-tests initalize a second trunk (trunk2) but the test
never do anything with this trunk. Lets remove it.

Change-Id: I228aa45160152091baac9d9c2e6486b774278b6a
Related: OS#2659
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 37a808c5a5 mgcp_test: do not access endpoint array elements directly
The test assumes that the endpoint "rtpbridge/X@mgw" is at array
position X in many places. This does not necessarly have to match.
Accessing the array elements directly was the prefered way when the MGW
did use integer numbers and not strings to identify endpoints. Since the
endpoint name strings are used to access the endpoints the unit-test
should also reflect this.

Lets replace the integer variable last_endpoint with a string variable
and do related verifications based on strings.

Change-Id: Ic950c427f23be4a792af94972554637c2b0fbdf2
Related: OS#2659
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 6521fc0695 manuals: generate vty reference xml at build time
Move 'doc' subdir further down to "make sure" the osmo-mgw binary is built
before the docs.

Remove mgw_vty_reference.xml from the source tree.

In manuals/Makefile.am use the new BUILT_REFERENCE_XML feature recently added
to osmo-gsm-manuals, and add a build target to generate the XML using the new
osmo-mgw --vty-ref-xml cmdline switch.

Depends: I613d692328050a036d05b49a436ab495fc2087ba (osmo-gsm-manuals)
Change-Id: I526af21134087e2b43b9ada59c93f636ae242e24
2020-07-11 02:02:50 +00: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 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 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
Harald Welte 41f77d8018 osmo-mgw.spec.in: Use %config(noreplace) to retain current config file
Change-Id: I37c130d9715a6826cc338f77edcd3cbec762fffd
2020-06-22 14:20:53 +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