Compare commits

...

1138 Commits

Author SHA1 Message Date
Oliver Smith fa393fa1e9 doc: example configs: fix deprecation warnings
Fix for:
  range must end at an odd port number, autocorrecting port (16000) to: 16001
  % Deprecated 'sdp audio-payload number <0-255>' config no longer has any effect
  % Deprecated 'sdp audio-payload name NAME' config no longer has any effect
  % Deprecated 'loop (0|1)' config no longer has any effect

Change-Id: I62a4fd119de48039c3c450d5323d8f9b7de8120f
2024-05-15 11:58:52 +00:00
Oliver Smith e0fc37a437 contrib/systemd: run as osmocom user
I have verified that with AmbientCapabilities=CAP_SYS_NICE, setting
scheduling policy as described in the manual still works as expected.

Related: OS#4107
Change-Id: Ibb83c231231b39dc6732c0f375aeb3b21f3938ef
2024-05-14 15:25:21 +02:00
Oliver Smith 4aa2b0e35b contrib: remove rpm spec file
Related: https://osmocom.org/news/255
Related: OS#6446
Change-Id: I703e115a426ac1012c80d2e1576ee6dcfbe191a5
2024-05-08 14:41:07 +02:00
Pau Espin e01f6e7f33 iuup: Increment RTP hdr seqnr even if Tx over UDP fails
This way holes can be detected. In practice it's not much important
since it would be really strange that UDP fails for a while and then it
starts working out of the blue...

Related: SYS#6907
Change-Id: I8095f3505c859650c0b83abce405067bef745975
2024-04-24 18:57:02 +02:00
Pau Espin 388b48d14e Fix IuUP RTP hdr seqnr field not incremented
Previous commit add osmo_io changed mgcp_udp_send() implementation from
"return sendto()", which is documented as:
"return the number of bytes sent. Otherwise, -1 shall be returned"

to "return mgcp_udp_send_msg()", which in turn calls
"return osmo_iofd_sendto_msgb()", and which is documented as:
"\returns 0 in case of success (takes msgb ownership), -1 on error
(doesn't take msgb ownership)."

So successful return code changed from >0 (bytes sent) to ==0,
but forgot to update mgcp_send_iuup() return code path check (and also
some related function documentation calling mgcp_udp_send()".

This commit fixes all the related aspects of that return code change.

Related: SYS#6907
Fixes: 352b967d1b
Change-Id: I154e1e41cd02fd4d9b88ad98fc7c4d657246c589
2024-04-24 18:56:57 +02:00
Harald Welte 352b967d1b Convert RTP/RTCP/OSMUX I/O from osmo_fd to osmo_io
Converting from osmo_fd to osmo_io allows us to switch to the new
io_uring backend and benefit from related performance benefits.

In a benchmark running 200 concurrent bi-directional voice calls with
GSM-EFR codec, I am observing:

* the code before this patch uses 40..42% of a single core on a
  Ryzen 5950X at 200 calls (=> 200 endpoints with each two connections)

* no increase in CPU utilization before/after this patch, i.e. the
  osmo_io overhead for the osmo_fd backend is insignificant compared
  to the direct osmo_fd mode before

* an almost exactly 50% reduction of CPU utilization when running the
  same osmo-mgw build with LIBOSMO_IO_BACKEND=IO_URING - top shows
  19..21% for the same workload instead of 40..42% with the OSMO_FD
  default backend.

* An increase of about 4 Megabytes in both RSS and VIRT size when
  enabling the OSMO_IO backend.  This is likely the memory-mapped rings.

No memory leakage is observed when using either of the backends.

Change-Id: I8471960d5d8088a70cf105f2f40dfa5d5458169a
2024-04-02 19:40:03 +02:00
Harald Welte ed4da25f2f cosmetic: make linter happy
Change-Id: Iec8404061588b848f9e597bf4112d6df9597de95
2024-03-20 14:25:49 +01:00
Harald Welte 5abda312ed Change msgb ownership in processing of received msgb
The old approach was: rtp_data_net() reads a msgb from the incomging
socket, calls through whatever function chain and in the end free's it.
So none of the intermediate functions was permitted to take msgb
ownership.

This was a good choice as all processing would happen synchronously,
up to the point where that msgb was written on the output RTP socket.

Let's change this from passing msgb ownership throug the whole call
chain, through rx_rtp() to the various *_dispatch_rtp() functions.

This is required for upcoming migration to osmo_io, as in that case the
write (sendto) calls are asynchronous and hence msgb ownership needs
to be transferred.

Change-Id: I6a331f3c6b2eb51ea312ac6ef8c357185ddb79cf
2024-03-20 14:25:49 +01:00
Harald Welte 75862d3131 remove osmo_fd from mgcp_create_bind()
preparation for osmo_io

Change-Id: I4a3b66a14fdfbc867daca0f0a05f694d5e0d7b66
2024-03-20 14:25:49 +01:00
Harald Welte 8733542b13 simplify unused transcoding/processing call-back
the processing call-back is working with a raw buffer + length,
while we actually work with struct msgb.  Let's simply pass the msgb
into the call-back, and the call-back can then do what they want with
the contents of that msgb.

Change-Id: I002624f9008726e3d754d48aa2282c38e3b42953
2024-03-20 14:25:43 +01:00
Harald Welte d7aac20cc1 remove strange loop for non-existant transcoding support
The existing support preparing the mgw for transcoding (which doesn't exist)
has some kind of method where the transcoding function might be called
multiple times in a row.  However, as it is not used, it is not entirely
clear how it was intended to work.  Let's remove this unused looping
feature which makes it hard to understand how upcoming osmo_io should
deal with it.

Change-Id: Ie1a629fd31c5ab806fc929d1e6b279c4be5b8246
2024-03-20 13:25:22 +00:00
Harald Welte 8b5361412c don't log useless "transcoding disabled" message
The entire mgw has no transcoding support.  So printing that message is
useless to begin with.  And printing it for *every RTP packet* is even
more useless.  Let's remove it.

Change-Id: If0ee2607404afc3a00665a5cf22a9e0eb62eb476
2024-03-20 12:34:38 +00:00
Harald Welte 3a971ba0d1 mgw: Add our usual SIGABRT, SIGUSR1 signal handlers
This is mostly related to talloc reports.

Change-Id: Idc35444d2b8a0bc52c267b468dfa3c1b59f9187a
2024-03-19 18:16:58 +01:00
Neels Hofmeyr c4b90354ca mgw: do not fail MGCP on codec mismatch
Before this patch, when an CRCX+MDCX wants to set a codec list that has
no match with the codecs for the other conn of that same endpoint,
osmo-mgw returns an MGCP "FAIL" response.

When a client wants to change the codec, it has to do that one RTP port
at a time. So osmo-mgw *must* allow to configure an MGCP conn with a
codec choice that mismatches the other conn.

This is crucial to allow codec negotiation in osmo-msc: if MO has
already assigned a specific codec, and later wants to re-assign to the
codec that MT has chosen, the codec needs to be changed at osmo-mgw.

This patch is the minimal fix required to get re-assignment to a
different codec to work (via osmo-msc). There is more work to be done
about this bit of code in osmo-mgw, but keep that to a separate patch.

In detail, before this patch, we fail both
- when a side has no codecs,
- or when there is no single match between codecs of the two sides of
  the endpoint.
Remove only the second condition; after this patch, still fail when a
side has no codecs -- this allows mgcp_test.c to still pass.

Related: OS#6293
Related: osmo-msc I8760feaa8598047369ef8c3ab2673013bac8ac8a
Change-Id: I3d1163fe622bdd7dc42a485f796072524ab39db9
2024-03-19 03:38:38 +00:00
Harald Welte 28fd236044 migrate mgcp_client from osmo_wqueue to osmo_io
The new osmo_io framework means that we can [optionally] make use
of the io_uring backend, which greatly reduces the syscall load
compared to the legacy osmo_wqueue + osmo_select_main + read/write.

We only use features already present in the intiial osmo_io support
of libosmocore 1.9.0, so no entry in TODO-RELEASE is needed.

Closes: OS#5754
Related: OS#5755
Change-Id: I766224da4691695c023d4d08d042a4bbeba05e47
2024-03-07 19:44:59 +01:00
Neels Hofmeyr 17b5701f19 mgcp_test: fix false negatives in test output
If one test fails, do not print failure for all following tests as well.

Change-Id: I196880b4b34a672ef45042c25f89bc1684363567
2024-02-06 03:17:50 +01:00
Neels Hofmeyr 9bea6eb78c tweak DEBUG log
Printing the debug log line a little later will include the MGCP verb
information.

Change-Id: Icb230cf4d623cdbc4ab52bd52d2a72525c0168c7
2024-02-06 03:17:50 +01:00
Neels Hofmeyr fd57bd5f6f mgcp_codec_decide: remove redundant lookup
We already did a lookup from conn_src[i] and found a matching
codec_conn_dst, no need to do another reverse lookup to end up at the
same conn_src[i] codec.

Change-Id: Iecc7f22c551fd17b23db434fdb177266407d2621
2024-02-06 03:14:56 +01:00
Neels Hofmeyr d0dbda4106 drop cfg 'sdp audio fmtp-extra'
There is considerable code complexity in place for this ancient hack.

It dates back to 5ea1bc77a3
"
mgcp: Allow to freely control the a=fmtp line for experiments

In case of AMR one can specify the available codecs out-of-band. Allow
to configure this line statically in the configuration file.
"

Looking in mgcp_test.c output, the fmtp-extra tests do not even make
sense: they result in fmtp for pt=126 being added, even though there is
no payload type 126 listed in the SDP...

Related: OS#6313
Change-Id: Icee0cd1f5a751fa760d5a9deca29089e78e7eb93
2024-02-06 03:04:10 +01:00
Neels Hofmeyr 35a738214c drop get_net_downlink_format_cb
It seems to be a remnant from early openbsc_mgcp. There is only the
default implementation for this callback and it simply returns two
pointers. Simplify that.

Change-Id: I18dfd44c931540caf4ac360c08ed10e5f65b2165
2024-02-06 03:00:50 +01:00
Neels Hofmeyr afbe872045 tests/mgcp: add update_exp target
Change-Id: I1ea7e881fe13429762bf31507d8d23fe58e241b3
2024-02-06 03:00:50 +01:00
Harald Welte 909be19285 Convert README to README.md and expand like in other projects
Let's align with structure and content of README.md in other osmo-*
projects.

Change-Id: Id9a78ccc0d10f0e3a9d832ac4c4988cfbb8ddb3c
2024-01-29 08:17:09 +01:00
Vadim Yanitskiy 8ee08c6b78 build: include README into the release tarball
Change-Id: I4e302914340467e8c047d60ab862267f4e94acad
2024-01-26 23:35:20 +07:00
Neels Hofmeyr c053e07336 Revert "drop (now) unused code"
This reverts commit 2b30cbdfa8.

Reason for revert: Older versions of osmo-msc were actually calling map_codec_to_pt().

Change-Id: Ifff31012b327d40ed0b1559d5cf4f320784a4061
Related: https://jenkins.osmocom.org/jenkins/job/Osmocom-build-tags-against-master/1792/console
2024-01-11 19:40:27 +00:00
Neels Hofmeyr 2b30cbdfa8 drop (now) unused code
Removing the duality of codecs[] and ptmap[] in structs mgcp_msg,
mgcp_response and mgcp_conn_peer has removed the need to "map" from
codec type enum to payload type number. They are stored together now.

Remove functions that are no longer used.
None of our osmocom users of libosmo-mgcp-client call these functions.

Change-Id: I84e5285831397c992af59deee12dea8458d16cc6
2024-01-05 02:44:58 +01:00
Neels Hofmeyr c9df010416 mgcp_client_test: add test_parse_response()
Change-Id: I842ce65a9a70f313570857b7df53727cc572b9e6
2024-01-05 02:44:58 +01:00
Neels Hofmeyr 3a3e1b57c6 client SDP: more verbose error logging
So far it was pure guess work to find out why a message fails.

Change-Id: Ibc6343db82281789004c140ba98d99e5f6f73d83
2024-01-05 02:44:58 +01:00
Neels Hofmeyr 186d4f1a0b client: allow MGCP_MAX_CODECS entries
So far we allow only MGCP_MAX_CODECS-1 entries, because the parsing exit
condition hits only after the array size check. Instead, check the array
size a bit later, just before actually adding a valid entry.

This is verified to work as expected in upcoming patch
I842ce65a9a70f313570857b7df53727cc572b9e6 that adds a new
mgcp_client_test.c section for this.

Change-Id: I9a28da85e437f118026ea71a5a708e5758fff623
2024-01-05 02:44:58 +01:00
Neels Hofmeyr cc2f7937ed client: collapse codecs[] and ptmap[]; allow codec variants
codecs[] is an array of enum osmo_mgcp_codecs.
ptmap[] is an array of { enum osmo_mgcp_codecs, unsigned int ptmap }.

MGCP lists first a bunch of payload type numbers and then specifies them
again for details, like the numbers 112, 96, 3 in this example:

 m=audio <port> RTP/AVP 112 96 3
 a=rtpmap:112 AMR/8000
 a=rtpmap:96 VND.3GPP.IUFP/16000
 a=rtpmap:3 GSM-FR/8000

So far we keep these lists in two separate arrays:
- codecs[], codecs_len stores the 'm=audio' list
- ptmap[], ptmap_len stores the 'a=rtpmap' list (and may omit some
  elements present in codecs[])
This applies to both struct mgcp_response and struct mgcp_msg.

These are semantically identical, and the separation leads to checks,
conversions and dear hopes of correct ordering.

So let's keep only one list with both codec and payload type number in
it. The 'm=audio' list establishes the order of the pt numbers, and the
'a=rtpmap' list adds codec information to the established entries.

In the internal API structs mgcp_msg and mgcp_response, just drop the
codecs[] entirely.

In public API struct mgcp_conn_peer, keep the codecs[] array, mark it
deprecated, and provide a backwards compat conversion: if any caller
invokes mgcp_conn_create() or mgcp_conn_modify() with codecs[] still
present in the verb_info arg, then move codecs[] entries over to the
ptmap[] array in a sensible way.
(BTW, even mgcp_conn_create() and mgcp_conn_modify() are never called
from outside of libosmo-mgcp-client in any of our osmo-cni programs;
users call osmo_mgcpc_ep_ci_add() and osmo_mgcpc_ep_ci_request(), which
in turn may pass user-provided codecs[] lists on to mgcp_conn_create() or
mgcp_conn_modify().)

Tests for parsing the MGCP response are mostly missing. They will be
added in upcoming patch I842ce65a9a70f313570857b7df53727cc572b9e6,
because they will be using only the new ptmap API.

Related: OS#6171
Change-Id: I798e02c6663376d3d52f4a74fc4b32411ce95bed
2024-01-05 02:44:58 +01:00
Neels Hofmeyr 960c031a67 client: deprecate legacy API
Change-Id: I7409907dafbb2fe905fee9bc22d6870056bf3022
2024-01-05 01:44:33 +00:00
Neels Hofmeyr 4993452561 build: move mgcp/*.h to noinst_HEADERS, drop RPM libosmo-mgcp-devel
We only install the mgcp_client/ headers.

Related: OS#6300
Change-Id: Ie0f79222bd1702097c12193dcf7a0462805cfc4a
2023-12-23 07:23:33 +01:00
Neels Hofmeyr 43eed63b09 client: safely handle dealloc on event dispatch
See also the long in-code comment.

Related: OS#6302
Change-Id: I6f1c0f6a26f9cd6993dc1910a44070ec0438e636
2023-12-19 11:46:42 +00:00
Vadim Yanitskiy 7a6d9c2f72 mgcp: correctly put NUL character in mgcp_msg_terminate_nul()
As was pointed out during code review of a previously merged patch,
whenever we write something to the tailroom, we must use msgb_put().

Change-Id: Ibe1605631a94088bfd1f603f7043322ed5585ffe
2023-12-17 18:54:25 +07:00
Vadim Yanitskiy f3715dc0d3 mgcp: reserve once byte for '\0' in mgcp_do_read()
We need to be able to terminate the received string in case it was
not nul-terminated by the sender (see mgcp_msg_terminate_nul()).

Change-Id: Icc878af7f671213bb516af62cb601914d86ff808
Fixes: CID#272990
2023-12-17 11:50:44 +00:00
Vadim Yanitskiy a68a863b9d mgcp: simplify getting msgb tail in mgcp_msg_terminate_nul()
The current statement:

  msg->l2h + msgb_l2len(msg)

looks as follows, if we expand the msgb_l2len():

  msg->l2h + msgb->tail - msg->l2h

so this is basically equal to msgb->tail alone.

Change-Id: I4f4b0f792bbeef94a5449c4a5843628a703a3d54
Related: CID#272990
2023-12-17 11:50:44 +00:00
Neels Hofmeyr 18717f5247 client: move some items to internal header
There is an upcoming modification of structs mgcp_msg and mgcp_response.
When it is public API, it needs to be kept backwards compatible.

But no libosmo-mgcp-client caller (in the osmocom-cni world) has used
these structs in years and years. Everyone should use the higher level
osmo_mgcpc_* API only.

Move this legacy API to a private header, so we no longer need to worry
about compatibility there.

Related: OS#6171
Related: I798e02c6663376d3d52f4a74fc4b32411ce95bed
Change-Id: I6d8bdda5c2ffa236e94a0b6111de4dbfac923187
2023-12-08 07:02:55 +01:00
Neels Hofmeyr 677b5396cb fix possible NULL deref on early media
end.codec may be NULL, depending on whether a single matching codec
could be found or not, i.e. based on external input. So let's not crash
if an RTP packet arrives while end.codec == NULL.

Change-Id: I9bfb55a343b3f2b1459e0aba4ee71a6133b992b3
2023-12-08 06:59:37 +01:00
Neels Hofmeyr 5d0e07112f mgcp_client_test: fix function name
Change-Id: I213f9b2713ff80a16603b8342c204cb546cc782d
2023-12-08 05:57:37 +00:00
Pau Espin a5acaa68db mgcp-client: Transmit remote IP addr in CRCX if known and port=0
A client may know the IP address during CRCX but not yet the port, or it
may simply want to hint an initial IP address so that the MGW can better
guess when allocating a local IP address.

Related: SYS#6657
Change-Id: I30165dbac5e484011d0acf46af36f105954a501d
2023-12-07 11:14:53 +00:00
Pau Espin 7787a3aeae IuUP: Allow Initialization with set rem IP address and unset rem port
Do not refuse IuUP Initialization messages coming in on an RTP port if
the remote port is not yet known.
If an IUFP conn is not yet configured (pre-Initialization), allow rx
from any address or port.

An osmo-mgw client (eg. osmo-hnbgw) may wish to initially set a remote
IP address as a hint during CRCX, hence the IP address may already be
set while the port may be unset.

Related: SYS#6657
Change-Id: Idd833997abce46886e9664505b2776fa5dadc8db
2023-12-05 13:50:42 +01:00
Neels Hofmeyr dd1ddf74fc check_rtp_origin: drop special case for legacy IuUP hack
We have proper IuUP support and everything about this legacy hack should
be purged.

The purpose of this function is to validate that RTP is coming from the
expected address and port. To allow that legacy IuUP hack, which is no
longer needed, we punched a hole into this validation, by adding this
special case for loopback mode (suddenly we don't care who or what sends
RTP and bounce it back to anyone). So let's get rid of this hole that
was only needed for very early 3G voice hacking.

Instead, we permit RTP for IuUP Initialization regardless of the RTP
loopback/send/recv mode since I6c365559a7bd197349f0ea99f7a13b56a4bb580b

Related: SYS#6657
Change-Id: I158dd046fdfcb10392cde3de8cc88dd095a05b40
2023-12-05 13:50:42 +01:00
Neels Hofmeyr 5e101c9fed IuUP: allow Initialization from any address if not yet set
Do not refuse IuUP Initialization messages coming in on an RTP port if
the remote IP address is not yet known.
If an IUFP conn is not yet configured (pre-Initialization), allow rx
from any remote address if the remote IP address is not yet known.

If we refuse the IuUP Initialization, a 3G RNC may fail to set up a RAB.
We will know the remote address only *after* assigning a RAB succeeded.
So the IuUP Initialization must be allowed before knowing all addresses.

At the time of writing, CRCX for IUFP are sent to osmo-mgw in either
LOOPBACK or in RECVONLY mode:
- current osmo-msc: recvonly
- osmo-msc <= v1.10.0: loopback
- osmo-hnbgw: loopback
IuUP Initialization should work regardless of that.
See also next patch I158dd046fdfcb10392cde3de8cc88dd095a05b40

IuUP is one layer below the loopback/send/recv decision for RTP; IuUP is
always terminated at the MGW, while the AMR payload carries through.

Related: alternative patch Idd833997abce46886e9664505b2776fa5dadc8db
Related: SYS#6657
Change-Id: I6c365559a7bd197349f0ea99f7a13b56a4bb580b
2023-12-05 13:49:10 +01:00
Pau Espin f6db465082 cosmetic: Fix line indentation
Change-Id: I85e47894aa0ed54dbf22a7a88d8cbeadaad4b248
2023-12-05 13:35:41 +01:00
Pau Espin a7e6fbc220 mgcp_network: Improve err logging when rtp pkt from unexpected origin comes in
Change-Id: Id9b60395df667ae9898c23cbc2afe56ac7e8b0e5
2023-12-04 11:21:53 +01:00
Neels Hofmeyr cd132126ef systemd,manual: set LimitNOFILE=65536
A typical OS imposed limit is 1024 open FD, which can bee too low when
there are hundreds of concurrent voice calls.

In systemd service file, set a super high limit of 65536.

In osmo-mgw's user manual, add section 'Configure limits' describing
this in detail.

Related: OS#6256
Related: osmo-bsc I26c4058484b11ff1d035a919bf88824c3af14e71
Change-Id: I46512517bc3b5bb90cac7643e7ac73afba398d36
2023-12-03 02:20:48 +00:00
Andreas Eversberg 249d21eb1e Use uniform log format for default config files
Related: OS#6272
Change-Id: I82ee4ce3c961976526a792862061c237a372e31b
2023-12-01 12:48:09 +01:00
Neels Hofmeyr 0127a0608d client: replace two assertions with graceful error handling
A user reports crashes of osmo-bsc upon EV_MDCX. It turns out that there
is a lot of error reporting and a distinct possibility to get a NULL
return value because of external input. Terminate the FSM instead.

FSM termination is the proper way to report a bad error, it signals the
parent_term_evt to the FSM parent, which will then be able to act on the
failed MGCP operation.

Related: SYS#6632
Change-Id: Ia5d8a9aff565399a85a5b116d7029fedcab234e0
2023-11-30 02:31:53 +00:00
Neels Hofmeyr 8b663e4d7c mgcp_parse_audio_port_pt(): fix buffer overflow
Change-Id: I18c78d15eb1593f404b4741248225b68878b463f
2023-11-15 22:09:55 +00:00
Keith Whyte 5e5c7bc176 vty and log: also show local port for RTP conns
Before:

    CONN: (1226/rtp, id:0xD94316AD, ip:127.0.0.2, rtp:2344 rtcp:2345)

After:

    CONN: (1226/rtp C:D94316AD r=127.0.0.2:2344<->l=127.0.0.1:4002)

While changing that string, also include these changes for consistency
and readability:

- use the same r:...<->l:... format as osmo_sock_get_name().
- Instead of 'id:0x' use the actual MGCP format 'C: 9B686BE3'.
- drop the commas
- drop RTCP port: it is always RTP+1 and always an odd number.

Rationale:
The CONN pairs associated with each endpoint show remote RTP
ports. When osmo-mgw is being used by both BSC and MSC, one
side of the pair is showing the internal loop connection inside
osmo-mgw, while my intuition suggested this connection pair
is showing me the RTP port tuple of a single RTP stream. Adding
the local port to the display makes it more clear, IMHO.
Seeing the local port can also help to correlate the MGW vty
dump with a capture of RTP.

Implementation:
I first tried directly using osmo_sock_get_name_buf() on
conn->u.rtp.end.rtp.fd, but that might hide already known information
when the fd is not actively used yet (before SDP): the local address and
port would then be shown from the fd, not from
conn->u.rtp.end.local_addr/_port == hidden before the fd is set up.

Patch-By: whytek, nhofmeyr
Change-Id: Ib89a6779e1d68c6600f00699d4303f6c0ee07132
2023-11-02 18:44:16 +00:00
Neels Hofmeyr c695e9f972 add mgcp_conn_rtp_type_names[]
First use in upcoming Ib89a6779e1d68c6600f00699d4303f6c0ee07132

Change-Id: If3d8bc68a3b26d3aa0ba7eedeab67b820889ed54
2023-11-01 21:30:29 +01:00
Oliver Smith 2bdad960ff Bump version: 1.12.0.3-58d5b → 1.12.1
Change-Id: Iefb000582a139ff53c4afbf94e1299e26ceeac44
2023-09-28 15:58:57 +02:00
Pau Espin 58d5b97831 mgw: Configure IuUP if codec set during MDCX
The mgcp client may first configure the connection to use RTP-AMR, but
after setting up another call leg may find out that both legs are IuUP
and hence want to forward the IuUP between the 2 connections instead.
In that case, an MDCX with codec VND.3GPP.IUFP would be set.

Until now, osmo-mgw didn't take that scenario into account, and it was
only upgrading the rtp conn to iuup internally during CRCX.
As a result, in the mentioned scenario osmo-mgw would continue to
output RTP instead of IuUP after the MDCX with VND.3GPP.IUFP, which is
wrong.

Related: SYS#6578
Change-Id: Ic94bf90f54d8ba3e65a2cd52734867847f3a60c2
2023-09-27 16:25:58 +02:00
Pau Espin 6225b5cecb mgcp-client: Introduce API osmo_mgcpc_ep_local_name()
Change-Id: I18d7bdf650c0ec87ae16ed4944aed9f495400137
2023-09-26 12:44:11 +02:00
Pau Espin c415ed5113 mgcp-client: Fix missing include in mgcp_client_pool.h
struct vty is used as a param but it is never defined.

Change-Id: Ia27bb20a79966cb90e04720462d24a236a168ada
2023-09-22 18:03:02 +02:00
Pau Espin 730a1f28d2 Bump version: 1.11.0.51-af67-dirty → 1.12.0
Change-Id: I9b1272cacaeaf1213f9a372eda52aac560cfbde5
2023-09-12 14:48:51 +02:00
Andreas Eversberg af67178581 ASCI: Support conference briding with 1..n connections
For each RTP packet that is received from a connection, the mode is
checked whether receiving is allowed or not. If not it is discarded.

In case of "confecho" mode, the RTP is also sent by the receiving
connection.

Then a loop is used to send RTP to all sending endpoints except the one
that received the packet.

Because we have a loop that allows to have 1..n connections, we have no
maximum number of allowed connections anymore.

Change-Id: Ic99a55ab5a3a6170e940403fadd52697e99f2f3a
Related: OS#4853
2023-07-10 12:14:05 +02:00
Andreas Eversberg dc7dfd0bbd ASCI: Add new mode for voice group/broadcast call
The new mode "confecho" is similar to "sendrecv", except that it also
echoes back RTP towards the sender. This is required for voice group or
broadcast calls. Talker and listeners use the same timeslot, so that
audio must be echoed from the talker to the listeners.

It is different from "loopback", because a loopback only echoes back RTP
towards the sender, but does not forward audio through the endpoint to
the other connections. Also it does not forward RTP from senders of
other connections.

The current implementation of MGW does not support transcoding and
mixing. This means that a sending connection must not send RTP that has
been received by multiple receiving connections. The application that
uses the MGW has to set the connection modes, so that only one
connection receives RTP in case of a conference.

Change-Id: I0639c663e119d85bef1010c7aa45e2f133a9daf0
Related: OS#4853
2023-07-10 11:54:16 +02:00
Neels Hofmeyr c364f4ab5a mgcp_client: tweak extract_codec_name() implementation
Instead of calling strlen() for every loop iteration, just use strchr()
to find the position of '/'.

Change-Id: Ifc7302b6c5f9288a622e33c3e8b5fe0e7037dbdc
2023-06-30 05:25:12 +02:00
Neels Hofmeyr e9989b9e76 mgcp: fix "L: a:" header parsing: heed ";" separator
In the "L: a:" header, read the first codec name only up to the ";"
separator, and ignore the rest.

According to RFC-2705, the "L: a:" header may include multiple codecs
like "GSM-EFR;GSM" in:

  L: p:20, a:GSM-EFR;GSM, nt:IN

osmo-mgw can handle only a single codec here. Since recently, osmo-msc
is our first client that may actually send more than one codec. This
uncovered a bug that leads to failing voice calls:

* osmo-mgw parses the entire list "GSM-EFR;GSM" as a single codec name,
* puts that into the ptmap without scrutiny,
* and even sends it back in the OK response, in the *SDP* part, as a
  single "GSM-EFR;GSM" codec entry.

We do not care very much about the "a:" codec list, because we always
establish codecs via SDP later. So all we need to fix this is: parse the
first codec done correctly, and ignore the rest.

Related: OS#6081
Change-Id: I0342e85b32ed89f3a1fdb6131c3c8ded8f47a455
2023-06-30 05:25:12 +02:00
Oliver Smith 9423817311 mgcp_client: check rc of map_str_to_codec
Abort with error log when map_str_to_codec is -1, instead of writing it
as unsigned integer into ptmap[i].codec.

Related: OS#6074
Change-Id: I08b91c849d810fe3cdb72c0f6f2a558b7377deab
2023-06-28 12:21:30 +00:00
Oliver Smith 292ba1bdb1 Cosmetic: fix a typo
Change-Id: I49f72acc3a42f6c7d50aeffdb1aef312c469d9f3
2023-06-28 11:49:45 +00:00
Pau Espin 10d9f8dcf4 mgcp-client: Mark client as UP when keepalive request-interval/timeout is disabled through VTY
This way if keepalive becomes disabled for an MGW, it can be selected
again (otherwise it would become non-selectable forever, and we already
have a "blocked" config for that).

Fixes: 563386e8bb
Related: SYS#6481
Change-Id: I263d23885a1a967f844033f9810b96691b8e3b30
2023-06-27 17:38:35 +02:00
Pau Espin 4c0658955e mgcp-client: Always mark client as UP if keepalive request-interval disabled
In the previous logic, if "keepalive request-interval" was disabled
(value 0, default), then if the client was configured to send a DLCX on
startup it would end up in state UP or DOWN depending on whether the MGW
answered to that request.
As a result, an MGW that wouldn't answer would be left forever in DOWN
state since it would have been selected no more and there would be a
keepalive configured to re-mark it as UP.

Fixes: 563386e8bb
Related: SYS#6481
Change-Id: I290f7436f48418ee25179951359c76208796e279
2023-06-27 17:38:27 +02:00
Pau Espin e9164c295d mgcp_client: pool: Only pick clients with an MGCP link considered to be UP
This way the user ends up picking a working MGW instance instead of one
which is not reachable around the time.

Related: SYS#6481
Change-Id: Ia3f451d3cd97851f65074408812b1ddc68f67056
2023-06-15 16:46:50 +02:00
Pau Espin 563386e8bb mgcp-client: Add keepalive feature
The `keepalive` feature in libosmo-mgcp-client allows scheduling periodical
queries on the MGCP layer in order to make sure it is reachable and hence
obtain information on the state of the MGCP link.
This patch only uses it to print the status on the VTY, but it will be used
too in a follow-up commit by the MGW Pool when picking an MGW from the pool:
MGWs whose link is considered to be DOWN are skipped.

The feature consists of:
- A `keepalive request-interval` which will trigger a transmission of an MGCP
  AuditEndpoint command targeting endpoint with name `keepalive request-endpoint`.
  This interval is updated every time any message is transmitted in the MGCP
  link, meaning the MGCP AuditEndpoint message is only triggered if no message
  has been transmitted since `keepalive request-interval` seconds ago.
- A `keepalive timeout` considering the MGW to be non-reachable (link DOWN) if
  no message is received over that amount of time.

The `keepalive` parameters are to be preferrably configured so that
"keepalive request-interval" * 2 < "keepalive timeout".

Example VTY configuration of `keepalive` feature in libosmo-mgcp-client:
----
 mgw 0
  ...
  keepalive request-interval 20 <1>
  keepalive request-endpoint null <2>
  keepalive timeout 50 <3>
----

<1> Transmit an MGCP AuditEndpoint message to the MGW if no message has been
    sent to it over last 10 seconds
<2> The MGCP AuditEndpoint targets the `null` endpoint. This is a special
    endpoint available at OsmoMGW for those purposes, but any available
    endpoint can be configured and used instead.
<3> Consider the MGCP link to be DOWN if no message is received from the
    MGW over the last 50 seconds

NOTE: The `keepalive` feature is disabled by default, and must be explicitly
      configured in order to enable it.

Related: SYS#6481
Change-Id: I3dc74c78548d017f272da863d5282dc5e0020ca3
2023-06-15 16:46:46 +02:00
Pau Espin af0f58fac7 mgw: Allow auditing speciall 'null' endpoint
This is a special endpoint which can always be audited. This is useful
for clients who wish to submit requests to osmo-mgw periodically to find
out whether the MGW is still reachable. This endpoint will be used by
libomso-mgcp-client as default target endpoint to implement such
feature.
This "null" Endpoint is osmo-mgw specific, not described in MGCP specs.

Related: SYS#6481
Change-Id: Ia409b16e9211e6261e2e0f21288544289d6f3733
2023-06-15 11:08:50 +02:00
Pau Espin 2e411f33a0 mgcp-client: Move some static functions further above
This is a preparation commit for follow-up one, where some of these
functions need to be used in other static functions.

Related: SYS#6481
Change-Id: I3a00d8c47ec773390d9626364c4c75ca579f1508
2023-06-14 13:04:15 +02:00
Pau Espin 8e8d59ff0e mgcp_client: Introduce mgcp_client_conf_alloc(), deprecate mgcp_client_conf_init()
So far, the users of the old non-pooled API were in charge of allocating
the struct mgcp_client_conf by themselves, then init them using
mgcp_client_conf_init(). This causes a major problem, since it makes it
difficult to extend the struct mgcp_client_conf structure to add new
features, which may happen frequently.

The MGW pool API doesn't have this problem, because the struct
mgcp_client_conf is allocated as parts/fields of private structs defined
in internal headers. Only pointers to it are used in public headers.
Since it still has to internally initialize the conf fields, we still
need the API to initialize it internally, and hence why is it marked as
DEPRECTED_OUTSIDE instead of DEPRECATED.

While some programs already moved to the new MGW pool infrastructure,
they still use the old APIs to accomodate for old config files in order
to be back-compatible, hence most users of libosmo-mgcp-client are
affected.

Introduce an API to allocate the conf struct internally, which, while
still breaking the ABI, allows for a more relaxed update path where it's
possible to extend the struct mgcp_client_conf at the end.

Eventually the non pooled API should be gone and the struct
mgcp_client_conf can then be moved to a private header, but for now
let's add this small feature to avoid major ABI breakage.

Change-Id: Iba0853ed099a32cf1dde78c17e1b34343db41cfc
2023-06-14 10:59:50 +02:00
Philipp Maier 14da3a33cb mgcp_client.h: also add spec ref to the other 3gpp defined payload types
Some payload type numbers are defined in 3GPP TS 48.103, let's put the
spec reference between all of those so that it is immediately clear
where those numbers come from.

Change-Id: Ie9d949ee72286ee4de7590c99acc740011208466
2023-06-11 19:28:10 +00:00
Pau Espin ea2035326d mgcp-client: Drop unused struct mgcp_client field
Change-Id: I0b2c4a83ca0e59e54bf5e2af289e4e1fe4f0cf27
2023-06-09 11:38:00 +02:00
Philipp Maier 2bfa708527 mgcp_codec: be sensitive about IuFP when checking codecs
When two codecs are checked for convertibility we insist that
subtype_name and rate are equal since normally when those are different,
we assume a completely different codec that will require a transcoder,
which we do not have yet.

However when IuFP is used, the call agent will always negotiate IuFP as
VND.3GPP.IUFP with a rate of 16000, even though the IuFP payloads
contain regular AMR at a rate of 8000.

This means that if we detect IuFP on one side of the call leg and AMR on
the other side of the call leg, we must not insist on equal subtype_name
and rate.

This fixes the following TTCN3 testcases:
MGCP_Test.TC_two_crcx_mdcx_and_iuup_rtp
MGCP_Test.TC_two_crcx_mdcx_and_iuup_rtp_rfci_unordered

Related: OS#5461
Change-Id: I6bc1e6022efe21cb893ef213f3da35017960357d
2023-05-31 09:34:14 +00:00
Oliver Smith 72f911513e systemd: depend on networking-online.target
Related: SYS#6400
Change-Id: Ib6c78c76c5f13b9482428ce653a61b03b2aca1d3
2023-05-26 14:10:46 +02:00
Philipp Maier 3d0676a791 mgcp_network: do not deliver RTP packets with unpatched PT
When a call leg is set up, then the call agent (e.g. BSC, MSC, etc.)
will also negotiate a codec along with a payload type number. When
sending RTP packets, each RTP packet must also contain the negotiated
payload type number. To prevent the emission of RTP packets with an
incorrect payload type number, ensure that no packet is sent when
mgcp_patch_pt() fails.

Change-Id: I013a24c1e0f853557257368cfab9192d4611aafa
Related: OS#5461
2023-05-22 11:18:45 +02:00
Philipp Maier 4c4d227624 mgcp_codec: fix codec decision
Unfortunately OsmoMGW was never really tested with multiple different
codecs on either side of the connection. While OsmoMSC and OsmoBSC only
assign exactly one codec on each side this has never been a problem,
however it might become a problem when a call agent assigns multiple
codecs on one side. This has been observed in a setup where OsmoMGW had
one leg towards an external call agent. Also due to recent upgrades to
the TTCN3 tests we are now able to simulate different codecs on both
sides to pinpoint issues.

Testing has shown that OsmoMGW has difficulties with multiple codecs.
The reason for this is that the function that makes the codec decision
was not fully finished. So let's finish the codec decision function and
let's also use that decision when patching the payload type of outgoing
RTP packets.

Related: OS#5461
Change-Id: I6c3291f825488e5d8ce136aeb18450156794aeb5
2023-05-22 11:18:45 +02:00
Philipp Maier 0e8310fa6c mgcp_codec: move mgcp_codec_decide down
In a follow up patch we intend to fix mgcp_codec_decide, since the
fixed version of mgcp_codec_decide will use some functions below its
current position let's move it down before fixing it to make reviewing
the changes easier.

Related: OS#5461
Change-Id: I2f2538ff912eae4d80d3b74b766e18c4da94d6b6
2023-05-22 10:24:57 +02:00
Vadim Yanitskiy e3624562dc copyright: fix typo: sysmocom s/s.m.f.c./s.f.m.c./ GmbH
Change-Id: I0de7650ad119d9a5d2585e2af981c5f1ff8e7058
2023-05-18 17:22:26 +07:00
Oliver Smith d5057ec7b8 debian: set compat level to 10
Related: OS#5958
Change-Id: If00d77a3b83fa7ba000a346f087a6baf1966fdff
2023-04-25 16:48:29 +02:00
Philipp Maier 72761b312b mgcp_vty: add warnings for deprecated config options
We normally warn in case someone uses a deprecated config option

Change-Id: I182f6579930a4e5ed79c8eb87501578ce7e89c15
2023-04-21 12:09:28 +02:00
Oliver Smith a312523be4 Cosmetic: mgcp_client: fix typo
Change-Id: I8e44b4bb853ebac881cb51b9546505874cf8fa45
2023-04-18 16:11:03 +02:00
Neels Hofmeyr 45fe47cea7 mgcp_client: simpler error handling
add_sdp(), add_lco():

- do not msgb_free() within these functions. Just return error, and move
  the msgb_free() to the caller.

- when failing to write to the msgb, directly return error.

Change-Id: I904d56f56053952c2ebbbe5dca744fafa32b333e
2023-04-15 00:56:06 +02:00
Neels Hofmeyr ce356eec1f mgcp_find_section_end(): skip spaces at start of SDP
Change-Id: I015e0347a268b61c0ca45d40754942f87b461c09
2023-04-15 00:10:19 +02:00
Philipp Maier cca1d180f5 mgcp_network: fix apidoc
Change-Id: I358e21e9a9ab33beb07a9adfd4a53145aadb997d
2023-04-13 14:38:31 +02:00
Oliver Smith 833ab4b083 mgcp_client_pool: add mgcp_client_pool_empty()
Check if the private struct mgcp_client_pool has an empty member_list.

Clients that support both the legacy config and the pool config can
use this to properly exit with error if pool members are configured,
but no connection to any of the pool members can be established.

Currently clients can't distinguish a config without pool members and a
config with pool members that is broken and will fall back to using the
defaults of the legacy config in both cases.

Related: OS#5993
Change-Id: I009483ac9dfd6627e414f14d43b89f40ea4644db
2023-04-04 14:27:04 +02:00
Vadim Yanitskiy d358ca14a9 tests: $(BUILT_SOURCES) is not defined, depend on osmo-mgw
Change-Id: I951ce2410614993a855336e6bb408cae1823ef9a
2023-03-31 11:56:02 +00:00
Philipp Maier 3699ef06a4 mgcp_codec: cosmetic: remove line break in api-doc
We usually do not make a final line break on our api-doc strings.

Change-Id: I025bbf36287ef014e294cc18a6435d7e2f9c1bff
2023-03-27 17:50:18 +02:00
Philipp Maier 9dd80ca1f8 mgcp_codec: refactor payload type converstion
in mgcp_codec.c we have a function mgcp_codec_pt_translate that is used
to find the equivalent payload type number on an opposite connection.
This is quite specific and the resulting payload type number may still
belong to a codec that might require some form of conversion.

Lets refactor this so that the function just finds a convertible codec
for a given connection. This also opens up other usecases. The payload
type conversion like we did it before can then be done with a few lines
in mgcp_network.c

Related: OS#5461
Change-Id: I085260a2ca8cfecdb58656b7a046c536189e238d
2023-03-27 17:50:18 +02:00
Philipp Maier 621e8666ff mgcp_codec: fix oa/bwe comparison in mgcp_codec_pt_translate()
The function mgcp_codec_pt_translate is very strict when comparing the
codecs to each other to find a matching payload type number to be used
on the egress side.

This poses a problem when one side uses AMR in bandwith-efficient, while
the other side uses AMR in octet-aligned payload type format. To the pt
translate function the difference in the payload format will appear as
if the codec were different and eventually the payload type number
cannot be translated.

since osmo-mgw offers conversion between the payload type format it
would be no problem to ignore the payload type format when making the
translation decision. The only exception here would be if one side would
announce AMR two times, the first time with octet-aligned and the second
time with bandwith-efficient format. Then we would have to use the
payload type number from the exact match. (and skip any formatconversion)

To archive such an optimized decision we will first go through the codec
lists and perform an exact match. If we don't get a match we go through
the codec lists a second time, but this time we ignore the payload
format.

Change-Id: Ifbd201a2749009a4644a29bd77e1d0fc0c124a9d
Related: OS#5461
2023-03-27 13:12:50 +02:00
Philipp Maier ec967d74f7 Revert "mgcp_codec: do not differentiate between oa and bwe when comparing codec"
This reverts commit e0058b7207. The reason
for this revert is that the solution in the reverted patch does not
cover a situation where the other side announces both payload formats at
the same time.

It could be that the end facing to a transit network announces both
formats under two different payload types. In this case no conversion
would be necessary. Depending on the input format the output would be
send to the transit network under the payload type that matches and no
conversion would happen at all.

This revert re-intruduces the problem that was fixed in the patch
before. Therefore it must be merged together with the follow up patch
(Ifbd201a2749009a4644a29bd77e1d0fc0c124a9d) that contains the proper fix.

Change-Id: I0b2854ef2397f38606fab3425be586a3d0ca27d1
Related: OS#5461
2023-03-22 17:12:44 +01:00
Philipp Maier 3ccf02a300 mgcp_e1: cosmetic: rewrite comment
Change-Id: I405cf464c052a2ab1461c3a8ba96665a3bc30341
2023-03-22 09:58:34 +00:00
Philipp Maier b6795ddfd2 mgcp_e1: rename e1_send to e1_send_ts_frame
The function name e1_send is very generic, lets make clear that one E1
timeslot frame is sent.

Change-Id: I5fba7993860a63149a13d943edbfabc4008680ef
2023-03-22 09:58:34 +00:00
Pau Espin 747fbce4ce mgcp-client: Call osmo_fd_unregister() before closing and changing bfd->fd
Change-Id: I95fbcc21a18cadd2c06608cc39b9fe8e12c8bccf
2023-03-14 11:48:27 +01:00
Vadim Yanitskiy e1da8c9d2c tests: use -no-install libtool flag to avoid ./lt-* scripts
This option should be used for any executables which are used only
for testing, or for generating other files and are consequently never
installed.  By specifying this option, we are telling Libtool that
the executable it links will only ever be executed from where it is
built in the build tree.  Libtool is usually able to considerably
speed up the link process for such executables.

Change-Id: I4bc03bdc1f2de2574558e2ad753e116486993a7f
2023-03-11 04:47:20 +07:00
Vadim Yanitskiy e78221d273 */Makefile.am: libraries shall not be in AM_LDFLAGS
Change-Id: Ie9df855ee09b0761bd617fab58ca26450ac0c754
2023-03-11 04:46:12 +07:00
Pau Espin 6c303664f5 mgcp_network: Unregister osmo_fd before closing fd
Change-Id: Ib937e56be62327f52d9cf03a07d7620080356ee8
2023-03-09 18:34:12 +01:00
Philipp Maier 544016d8e6 mgcp_e1: rewrite comment
Change-Id: I5e6db4e29ae4af1ec790a4e8b201930206cc5828
2023-02-28 18:45:31 +00:00
Philipp Maier 263a1a3e8f mgcp_e1: fix typo
Change-Id: Ida399e58b996ebab74e719ec907984e5aa9ddce4
2023-02-28 18:45:31 +00:00
Philipp Maier 30bdf94102 mgcp_client: fix sourcecode formatting
Change-Id: I55f98379ea48ffddc25186c15e4dd40762e818b6
2023-02-28 14:32:02 +01:00
Oliver Smith 0dbaaadc06 mgcp_client: mgcp_msg_gen: add more error logs
While adding CSD, this failed for me in add_lco without a descriptive
log message, so add more error messages.

Related: OS#4393
Change-Id: I4873a2db95525aab3e13046b645dd8f90e951466
2023-02-27 08:30:08 +00:00
arehbein 671c37b72b Transition to use of 'telnet_init_default'
Related: OS#5809
Change-Id: Icc57c68337d55c6594c1c36e9bf41624d11dab0a
2023-02-25 17:48:58 +01:00
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 f8abd0ec0c mgcp_e1: fix log output
Its not the E1 timeslot that is updated, its the E1 line instead
(which includes the timeslot)

Change-Id: Ic72cf90ebdba1b5e395089417c6df5b962f8ffc8
2023-02-13 11:57:52 +01:00
Harald Welte 1a7048d69a cosmetic: Fix grammar suggesting reading _the_ user manual
without the *the*, the sentence sounds Russian - and it wasn't even
added by Vadim or Max :P

Change-Id: I95b66c6cc88f545eb738945233bd2e560abf4711
2023-02-10 11:47:56 +00: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
Philipp Maier b9e7569217 mgcp_sdp: cosmetic: remove newline
Change-Id: Ib9a03a75d9bcc4bdbc9d740edbd12c280ec1d933
2023-02-08 10:21:42 +01:00
Philipp Maier 057decfe3a mgcp_sdp: add spec reference
Change-Id: I16cd453aa986cf9efa0716257230aed8739593da
2023-02-08 09:21:12 +00:00
Pau Espin 342a9a9418 Bump version: 1.10.0.117-22f9c-dirty → 1.11.0
Change-Id: I9f1dcbbf2fdc242e8d304ec6b2a8e1e60d010c32
2023-02-07 16:58:42 +01:00
Harald Welte 22f9cf2687 update outdated vty copyright statement
Change-Id: I7af4bdecddda0b43f98855571942219e8ba00b64
2023-02-06 16:07:07 +00:00
Oliver Smith 26d6b2b5ce mgcp_client: add new clearmode codec
Set 120 as payload type, as specified in 3GPP TS 48.103 table 5.4.2.2.1.

Related: OS#4395
Related: https://www.rfc-editor.org/rfc/rfc4040#section-5
Change-Id: I55f9fe241a405935dbedc3947b0a4f4986acd5cb
2023-01-24 18:18:11 +01:00
Oliver Smith 169d50ed4a Fix various typos
Change-Id: Iba7851a5bdb0ce2ce6852a8fa035b72515d7b0a1
2023-01-24 13:23:21 +01:00
Philipp Maier 82dfb505db mgcp_network: improve coment
the comment that explains the AMR frame format check is a bit difficult
to understand, lets rephrase it.

Change-Id: I07f12c03449e1e8eda8bdd3edad6d1007f5ba48d
2023-01-19 14:28:30 +01:00
Max 9c0d105d09 ctrl: take both address and port from vty config
Change-Id: Id053bc02e0a6359e52a0f5e110128d3bb87ed151
2022-12-20 19:00:45 +03:00
Pau Espin ded02cfc29 iuup: Use osmo_amr_ft_valid() API
This is the only user outside libosmo-abis using this define, which
meaning is not clear at all. Let's simply use the related API to clearly
check the FT.

Related: SYS#6161
Change-Id: I40c7ed2e7f6a99a33b467734e33acf3d5befac0d
2022-12-19 13:24:23 +01:00
Pau Espin 0cbed362cd osmux: Use new osmux_xfrm_input API to set name on each link
Depends: libosmo-netif.git Change-Id 8bb688e4827f345416c2a4526ced956a07fcc60b
Change-Id: Id5b7d497be4b3405403d30e40e1a52f13101cf5f
2022-11-21 10:52:17 +01:00
Pau Espin 310e41cdf3 osmux: Rotate over available Osmux CID when allocating a new one
Before this patch, the free CID with the smallest number was always
selected to be used. This caused more or less the same subset of CIDs to
be used all the time, while the CIDs with bigger numbers were mostly
unused.
Let's distribute the use so that all CIDs are used roughly the same.
This has the advantage, among others, that the same CID will not be
re-used immediatelly after being freed if a new call is established.
It is useful to leave the CIDs unused for some time since the other end
peer may know of the call being tear down with some delay.
Hence if a new call is established immediately after the CID was
released, the same CID would be allocated and passed at the peer, which
would then detect that the old call (in its view still active) would
already make use of that remote CID.

Change-Id: I9dfbcc5e4b4c61ce217020e533d68fbcfa6b9f56
Related: SYS#6161
2022-11-15 18:10:28 +01:00
Max a55bfdc436 Add realtime scheduling and set priority in service file
This sets lowest realtime priority which still takes precedence over any non-realtime service.

Related: OS#5687
Change-Id: Ib1705a164b04b876f129a17c4e8353b9ddcc538e
2022-11-14 10:52:06 +00:00
Harald Welte 6ea8d7dac6 Add -Werror=implicit-int -Werror=int-conversion -Werror=old-style-definition
... if --enable-werror is used

Change-Id: Ib397f3ad748e17f20b6177ef706af65088571f70
2022-11-03 12:53:20 +01:00
Harald Welte 9befdeb673 Support building with -Werror=strict-prototypes / -Werror=old-style-definition
Unfortunately "-std=c99" is not sufficient to make gcc ignore code that
uses constructs of earlier C standards, which were abandoned in C99.

See https://lwn.net/ml/fedora-devel/Y1kvF35WozzGBpc8@redhat.com/ for
some related discussion.

Change-Id: I98a3c0d5cfda2c4b020652efb4f445f8288342b6
2022-11-03 12:53:20 +01:00
Neels Hofmeyr 5fb814b6b9 AMR->IuUP: log conversion, like for the flipside
For IuUP -> AMR, we log a message like
  Convert IuUP -> AMR OA:...
Do the same for the direction AMR -> IuUP.

Related: SYS#5092
Change-Id: I525685a7dedb6d5d1deecbd026844cbe23193fac
2022-10-28 19:04:00 +00:00
Pau Espin 9ac9cb963d Improve logging on AMR OA<->BWE conversion failure
Change-Id: I7c7dd10650c1d249c723d6781585b343004bd64d
2022-10-26 12:36:48 +02:00
Pau Espin 377d39122d osmux: Make sure RTP AMR feed to osmux is in octet-aligned mode
The Osmux implementation in libosmo-netif expects to work with RTP AMR
in octet-aligned mode. Therefore, if the peer connection received RTP
AMR in bandwidth-efficient mode, we need to convert it to octet-aligned
before feeding the packets to the osmux layer.

Related: SYS#6161
Change-Id: Ifeec44241079f7a31da12745c92bfdc4fb222f3a
2022-10-26 11:56:05 +02:00
Pau Espin d1e94c7ac3 osmux: Rename function and pass msgb directly to it
The new prefix now matches other related functions acting on an osmux
connection.
Pass the msgb to it so simplify new msgb copy.

Change-Id: I8c0121485d0c96f70fe8bcbdb150793d428183ff
2022-10-26 11:56:05 +02:00
Pau Espin 6db3f7f1cb mgw: Rename s/mgcp_send_rtp/mgcp_conn_rtp_dispatch_rtp/
The previous name is misleading since the function is not really sending
stuff over a socket, but rather handling/dispatching the incoming
message internally (and finally later it may be sent over a socket under
some conditions).

Change-Id: Idaf791997b8438a4aede50f614afa0d55ad41faa
2022-10-26 11:55:26 +02:00
Pau Espin 58c0b0a6f7 mgw: rx_rtp(): reorder checks and handlings
First validate the origin of the message, then later the content
of the message and finally execute whatever triggers are necessary.
This way contents from unknown senders are not even parsed or acted
upon, avoiding useless potential harm.

Change-Id: I011a6d7d705768c32a35cec5cd7169725a21a670
2022-10-25 18:23:09 +02:00
Pau Espin cca55247ed Rename and move func checking if amr mode is explicitly configured
The previous naming was quite confusing, since the function is not
really checking whether a conversion is needed, but rather whether the
codec has the AMR RTP mode defined explicitly and hence forced.

The previous naming didn't harm because the amr_oa_bwe_convert also
supports the conversion path OA<->OA and BE<->BE.
Hence nowadays the amr_oa_bwe_convert() function is called always if the
dst conn has its codec with AMR RTP mode explicitly set, no matter if
the src and dst conn have the same mode.

Related: SYS#6161
Change-Id: I8dce3038ebccf5e1e37e2908070a67d66693a96f
2022-10-25 18:23:08 +02:00
Pau Espin d266c374ee mgw: Log unexpected RTP AMR OA-vs-BE payload
Change-Id: Ib5ae82c01153398491b21191a8cec9969337bbbc
2022-10-25 18:23:04 +02:00
Pau Espin d358d71206 cosmetic: Clarify and fix typos in comment
Change-Id: Ibcbe7d85cf7e1912de73d59540f2dea1dfa5d98d
2022-10-25 13:09:36 +02:00
Neels Hofmeyr 5e6661eece IuUP->AMR: log whether converting to AMR OA or BE
Enhance the existing log message
  Convert IuUP -> AMR:...
to
  Convert IuUP -> AMR OA:...
(or BE) to show wether emitting Octet-Aligned or Bandwidth-Efficient.

Related: SYS#5092
Change-Id: I3672d01d2879ae8820176a46454f26a4f5f584de
2022-10-24 21:23:15 +02:00
Neels Hofmeyr c1468ef7a5 IuUP->AMR: do not patch payload type a second time
When converting IuUP to AMR/RTP, bridge_iuup_to_rtp_peer() sets the AMR
side's payload type number and then calls mgcp_send(). In mgcp_send(),
do not attempt to patch the payload type number a second time.

In mgcp_send(), skip patching payload type numbers if the source side is
IuUP. This matches exactly the case of converting IuUP to AMR/RTP.

There already is a check for IuUP, but for the wrong side. Drop that one
and explain in a comment why.

Move the comment about transcoding into the failure branch, where it is
relevant and doesn't clutter the new explanation of payload type
patching conditions.

Related: OS#5720
Related: SYS#5092
Change-Id: I7c722cd959f76bd104ae4941d182c77e5c025867
2022-10-24 21:23:15 +02:00
Neels Hofmeyr 24763eaa73 AMR->IuUP: properly translate Q -> FQC
Fix the reversed logic when composing IuUP.FQC:
AMR.Q == 1 means the frame is good.

Without this fix, all frames on IuUP are marked as bad, and no voice is
heard on the IuUP side.

Related: SYS#5092
Change-Id: I29878dd27af9ba0c9e600324c528b22940cdcc30
2022-10-24 21:23:15 +02:00
Neels Hofmeyr d8c2f31a87 AMR->IuUP: do not crash on AMR data before IuUP Init
When translating AMR to IuUP, when AMR data arrives before the IuUP side
has negotiated an IuUP Initialization, do not crash osmo-mgw, but return
failure and drop the AMR packet.

As soon as IuUP Initialization occured and RFCIs are defined, the AMR
starts to pass through to the IuUP side.

Related: SYS#5092
Change-Id: Id9efb7e523d8d9af988e4bf4f5e925839204f934
2022-10-24 21:23:02 +02:00
Pau Espin 01b812ea76 mgcp_send: Use mgcp_conn_rtp_is_iuup() helper
Change-Id: I6988337f395168b88959876fe3827d8e67b8fc00
2022-10-19 19:18:50 +02:00
Pau Espin 0807771b9e Fix misleading error log
The check is not for an AMR RTP packet. It actually only checks for RTP
header.

Change-Id: I60d7dbfeb2977bcb7102eed19e1c73c9433151a7
2022-10-19 19:06:47 +02:00
Pau Espin 103e50a561 mgcp-client: Fix no 'mgw ' prefix written in old VTY node
Recent commit dropped the 'mgw ' prefix in commands under the "mgw" VTY
node because it was redundant.
However, for old apps still not supporting the 'mgw' node, the commands
are still printed in another node and hence the 'mgw ' prefix must still
be appeneded to them, to avoid breaking backward compatibility.

Related: SYS#5987
Fixes: 8c138fe89c
Change-Id: Ifbfb71f8864b425c1b842cdee241ce279d17a8ba
2022-10-19 17:22:48 +02:00
Pau Espin 3a914e33e9 mgcp-client: Refactor system keeping old users not calling mgcp_client_pool_config_write() working
Move the regular writing logic to a subfunction, and raise the flag only
on one of them.
This simplifies the code paths but not marking stuff true and false over
the same code path.

Change-Id: I070798863f2bdc253df004a63262d4bcd529348f
2022-10-19 17:14:51 +02:00
Pau Espin 2172f402a5 mgcp-client: Fix 'mgw endpoint-range' command dropped from old VTY node
That command was already deprecated when the new commands without the
"mgw" prefix were dropped, so there was no need to create a new command
for it (since it shouldn't be used and it's currently implemented as a
NOOP).

However, the recent patch moved the install line out of the common
function, which meant the command was not available anymore on the old
node, and as a result old config files using it would fail to be parsed.

This commit moves the command back to the common function so that it is
still available for config files using the old node.

Related: SYS#5987
Fixes: 8c138fe89c
Change-Id: I800abcc9869ed097a9d28715269c42552f5aaf29
2022-10-19 16:13:23 +02:00
Pau Espin 8c138fe89c mgcp-client: Add new VTY commands under mgw node without mgw prefix
Previous existing ones are left marked as deprecated, to avoid breakage
with older configs.

Related: SYS#5987
Change-Id: Id55af13d2ecde49d968b9dca6a2f8108a17ec484
2022-10-19 12:47:33 +02:00
Pau Espin 7881f7da0b mgcp-client: Introduce API mgcp_client_pool_config_write
It is not a good idea to use a personal write_config function for the
MGW node, since it's not meant to be a 1st level (top) node.
During write-config the node function will be called at an
implementation specific time (based on the order defined by the app in
the node type enum), so there's no real way to control that the output
of the MGW node will end up under the parent configured in
mgcp_client_pool_vty_init(). As mentioned the order can be tweaked based
on how the node enums are configured, installed, etc. but that's really
a nightmare, so let's better not rely on that.

Therefore, this patch introduces a new API which the users (apps such as
OsmoBSc and OsmoMSC) can use to write the config at the required time
(when writing its own parent node).
A hack is introduced internally to detect older versions of the users
which didn't call this function to still print stuff (up to to the app
if the order is correct).

Related: SYS#5987
Change-Id: I7a620cf47886d8ecab30ce369cf123d98ab842c5
2022-10-18 17:38:44 +02:00
Pau Espin d17a9de79e mgcp-client: Convert users supporting new MGW Pool VTY node during write-config
If the user (app) already supports the MGW Pool VTY command set
(mgcp_client_pool_vty_init() was called), then if single MGW mode is in
use it's because the config file was not updated to use the new MGW Pool
node. Let's convert it to the new format to help in transitioning to the
new VTY command set.

Related: SYS#5987
Change-Id: I2f6658cc66f8bcbd4a60ee2b932bb5dd65888233
2022-10-18 12:44:52 +02:00
Pau Espin 8e74c63e15 mgcp-client: Use random free local port by default
Deprecate mgcp_client_connect2() and all the related messy system where
configured port is incremented until a free port is found.
Let's simply use local_port=0 by default and let the kernel take care of
doing all that.
The mgcp_client_connect2() is actually not being used anywhere outside
of libosmo-mgcp-client, so it's not a real problem deprecating it. We
could poitentially remove it too.

This helps in fixing a regression in recent refactoring commit
f48cd95bbc, which unified calls to
mgcp_client_connect() and in the process dropped the code path which was
setting the retry_n_ports=99.
As a result, since all libosmo-mgcp-client instances set local_port=2727
and addr=NULL by default, using MGW pooling or having several osmo-bsc
or osmo-msc processes would make creating the socket fail.

Change-Id: I5683bcf3b2c4e8058338433f2cd1b143753f6512
2022-10-17 19:22:41 +02:00
Pau Espin 80dd576ad2 mgcp-client: vty: Write deprecation warning using non-mgw nodes
Let's advise all our users to migrate to the new pooled mode, the old
VTY interface should be dropped at some point to avoid making it
overcomplex to configure MGW. There's no need to maintain the same set
of commands under 2 different places.

Change-Id: I95f717a0fcd3c4ca622e3989baa28fac1f7ec1ca
2022-10-17 17:32:31 +02:00
Oliver Smith cb922b646f mgcp_client_pool.h: add missing stdbool include
Fix for:
[   34s] In file included from vty.c:22:
[   34s] /usr/include/osmocom/mgcp_client/mgcp_client_pool.h:18:1: error: unknown type name 'bool'; did you mean '_Bool'?
[   34s]  bool mgcp_client_pool_member_is_blocked(const struct mgcp_client_pool_member *pool_member);

Related: https://obs.osmocom.org/package/live_build_log/osmocom:master/osmo-bsc-nat/CentOS_8/x86_64
Change-Id: Ic3773f49160cbb8c6f53c4f0e17b897017dec98a
2022-10-14 16:42:03 +02:00
Pau Espin 5d8b5b0935 mgcp-client: Introduce APIs to manually select mgcp_client from pool
This will be used by osmo-bsc to implement MGW-pinning for specific BTS.
This is useful for instance to keep all BTS connections targeting the
same MGW in order to make use of Osmux trunking optimizations (AMR
payload of different calls filling same underlaying UDP packet).

Related: SYS#5987
Change-Id: I75ce3e04cd3f6d9cc20d7b4fc0f51083780786c8
2022-10-13 18:47:07 +02:00
Pau Espin 35bd2523e2 mgcp-client: Rearrange internal backpointers
Let's properly store backpointers so that it is easy to access all
relation chain (pool<->pool_member<->mgcp_client).

Related: SYS#5987
Change-Id: I5ec2465075da2e3c8eabca9df60681620a7db499
2022-10-13 18:42:34 +02:00
Pau Espin f45a9b9760 mgcp-client: Rearrange order of structs and APIs in header
Move mgcp_client_pool up in the file as a preparation for next commit,
where pool_member will have a pointer to the pool added.
The related APIs on the object are also moved up in the file.

Change-Id: I9ff9c6e1e722690835c5d59b1fa87fb7d9e3120c
2022-10-13 18:42:34 +02:00
Pau Espin f48cd95bbc mgcp-client: Refactor reinit of mgcp clients
The second parameter of mgcp_client_pool_member_reinit_client() will be
removed in a follow-up patch after further refactoring.

Related: SYS#5987
Change-Id: I0ab59278629c0e7e7c62a68b54b4235df58a5d77
2022-10-13 18:42:34 +02:00
Pau Espin 7558c20973 mgcp-client: Move internal API acting on mgcp_client_pool to the correct file section
Change-Id: Ia0cccb783918eea72c4a77861dac4b60ad369b95
2022-10-13 18:42:31 +02:00
Pau Espin 6ddc79b6ed mgcp-client: Create alloc() and free() internal APIs for mgcp_client_pool_member
Related: SYS#5987
Change-Id: Ibd2bf976885c777fe944652af6fe6eb0f1820468
2022-10-13 18:39:10 +02:00
Pau Espin ff5921573a mgcp-client: Move & rename helper function outside of vty code
This way acessing of the list is kept inside the same file.

Related: SYS#5987
Change-Id: I6b26c2de4064d9c28f92452178fff170fb295576
2022-10-13 18:38:57 +02:00
Pau Espin d4ad77d326 mgcp-client: Rename internal field in mgcp_client_pool
Having a list named pool inside an object already named pool is quite
confusing. Let's rename the field so that it makes sense immediatelly
when looking at it.

Change-Id: I4062af6b619317c48223ad4577eaaad05d4eec9d
2022-10-13 18:38:43 +02:00
Pau Espin a6917fecb1 mgcp-client: Fix typo in internal function name
Change-Id: I073038f1d6c68bc8546763a2c8c791fb5a021630
2022-10-13 18:38:43 +02:00
Pau Espin 58877f04e3 mgcp-client: Avoid double iteration picking client from pool
Change-Id: I99e8be878452c5d8e2183239fbdd499dcf507e90
2022-10-13 18:38:43 +02:00
Pau Espin d4707e2185 mgcp-client: pool: Improve documentation of some internal fields
Change-Id: Ic9823ab0a3f101549452a7c7a0b1b5b21aaa837c
2022-10-13 18:38:28 +02:00
Pau Espin f633302c73 cosmetic: Fix typo in comment
Change-Id: I6b0fcd7ee13e0e712d47741258f83a6f98503e27
2022-10-13 13:20:10 +02:00
Pau Espin 36413c011f osmux: Clean up mgcp_config osmux fields
* Move all of them to an anonymous "osmux" substruct to have them all
  together.
* Rename some fields to clarify its meanings, similar to what
  was already done in osmo-bts.
* Move the port VTY config next to the ip address ones.

Change-Id: Icc1c1ce3ab3a8beb941cda7c112485a0db882a90
2022-10-13 12:36:44 +02:00
Pau Espin 833281dcb9 osmux: Introduce osmux peer-behind-nat (on|off) and rework conn activation
Change-Id: I7654ddf51d197a4107e55f4e406053b2e4a02f83
2022-10-12 17:13:04 +02:00
Pau Espin 07bbd766c5 mgcp_conn_dump(): Separate dump for osmux and iuup connections
Change-Id: Iec1f2d61e4eb14a8a3c634e2642063bea6000c04
2022-10-06 18:49:31 +02:00
Pau Espin c7c8e649f1 osmux: Erase references to bsc-nat
Change-Id: I21ab7134de577278175132fc78431a249de76731
2022-10-06 18:24:24 +02:00
Pau Espin c0e1b1aec5 osmux: Move setting OSMUX_STATE_DISABLED to initializer function
Change-Id: I7c184b17075fc3e71f1f66775e16b56a5ae91b62
2022-10-06 16:21:37 +02:00
Pau Espin 9735d21b9d osmux: Define osmux_dummy cfg as boolean
Change-Id: Ifc3384f9871ddfdbd6282c6e03bf6a2dd8a09a9e
2022-10-06 16:19:37 +02:00
Pau Espin 705565d745 osmux: Make conn_osmux_{allocate,release}_local_cid() APIs static
They are used internally in the mgcp_osmux.c file.

Change-Id: If7c83f98a94818090173a8be9d3bff9818b2ead1
2022-10-06 14:37:33 +02:00
Pau Espin 63088e0e61 osmux: Set conn->type during osmux_init_conn()
It's basically the same code path (one function calls the other), but it
makes a lot more sense to have it in the init function itself.

Change-Id: I63d7dfff451870f708f7cb710d66f4ec786c27d7
2022-10-06 14:33:00 +02:00
Pau Espin 887c93e198 osmux: Simplify and constify param passing
Parameters passed to several functions are rearrange to make code
simplier to follow, as well as dependencies between the different
functions. As a result, some parameters can be marked as const while
doing the change.

Change-Id: Idebd4a66630c16548f557632a54d6b7e1b3906fd
2022-10-06 14:20:52 +02:00
Pau Espin 2ca48823b1 Check once if remote addr is available when sending dummy packet
It's checked in all code paths being called, which makes sense since
it's impossible to send anything if the remote address is not set. Let's
check it once in a unique to simplify the code.

Change-Id: I224dbfeda17c364b85166268e2ac1e019a87edb6
2022-10-06 13:10:51 +02:00
Pau Espin e7de137b29 osmux: cosmetic: Fix indentation
Change-Id: Ic7087e7907c1078d134d7d9b11ed6a6bf1941308
2022-10-06 13:10:51 +02:00
Pau Espin c1ad7fd92b osmux: Drop unused role parameter
Change-Id: I39c2852bb60aaba4f85188c55f157e4abec47a0e
2022-10-06 13:10:51 +02:00
Pau Espin 3779919551 osmux: Add square brackets around IPv6 address to distinguish port in log line
Change-Id: I811ac5b4386f06c224f29f44f10dce4008fa7a4f
2022-10-06 13:10:41 +02:00
Pau Espin 8e0d101997 osmux: Change couple log lines to OSMUX category
Change-Id: Ia04d08099f0b1e81707699d872779108f22522bf
2022-10-06 10:31:19 +02:00
Pau Espin 654b68d602 Clean up local var pointers in mgcp_get_local_addr()
Change-Id: I12f1d38b70f97426318e948cd80f9efc2592d54b
2022-10-05 10:37:49 +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 e56ec4a146 osmux: Use available API to check if remote end is known
Since recently the port is guaranteed to be placed at
CRCX/MDCX in the sockaddr, hence we can check it using the API instead
of checking manually only for the address part.

In osmux_send_dummy() we actually fix a bug where an in_addr was being
compared against a struct sockaddr.

Change-Id: I736e7f4c51e577d8eb0b96bc776f984f928b6d27
2022-10-04 14:44:48 +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 051eb4d563 Use new libosmocore API osmo_sockaddr_is_any()
Depends: libosmocore.git Change-Id I2810a889fc14052d0e0be6a2b500ad4e5088ffa9
Change-Id: Ib2ba708bdc834359de8a7cce302e2dc1f8c64954
2022-10-04 12:51:15 +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 abb9d47c90 send_dummy: Use proper condition to test if conn is osmux
Change-Id: I493e7afaf8e6edb5bf975b3097fab49986d064cf
2022-10-04 12:10:10 +02:00
Pau Espin 2dd2b33030 osmux: Log remote address upon rx of osmux pkt
Change-Id: Ie2a375711c7c0989161ae651ea6f0695799e2670
2022-10-03 18:10:55 +02:00
Pau Espin 69f15e4e95 osmux: Fill in from_addr in struct osmo_rtp_msg_ctx
Change-Id: I9783978e295b964ca914f8d90d73effa8785f10d
2022-10-03 18:04:07 +02:00
Pau Espin b0ea7976bf osmux: Match remote address in osmux_conn_lookup()
Depends: libosmo-netif.git I95433b18802f73fa70e758f4aa02128eee940d88
Change-Id: Ia717efa5f68e9412b86ef44a4c42a0715ff0e469
2022-10-03 18:04:03 +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 cb25a0aa48 osmux: Drop logging of osmux internal counters
This way we have no more access to internal osmux structures.
Moreover, we already have similar information in our rate_ctrs, so
there's no need to print those there.

Change-Id: I853e118f843070ea29b19e1b0fe56b52f267437a
2022-10-03 15:57:09 +02:00
Pau Espin 72eff2cf6a Allocate struct osmux_in_handle through new libosmo-netif APIs
Change-Id: I013c99d1f915279684ce278648e9c69e39b94266
Depends: libosmo-netif.git I752ab031f935f04731bb1a354333f1682a1aa5bd
2022-10-03 15:57:09 +02:00
Pau Espin 1c5fcb0791 osmux: Keep decoding osmux pkt if a batch contains an unknown CID
Receiving an unknown CID (for which we don't have an active conn) is
totally expected at the end of the call, were some messages from the
peer may be send for a while, specially if latency is high.
If this occurs, we simply drop that batch and keep decoding the osmux
message in order to keep delivering content to other circuits.

Related: SYS#5987
Change-Id: I315949853bdcc07bef15d2e8579029cc72c427cf
2022-09-29 16:02:10 +02:00
Pau Espin 48fb176fbc osmux: Lower log level when osmux batch received for unknown CID
This is actually quite common, since our peer may be sending some osmux
packets to us a while after we have closed the conn on our side,
specially if latency is high in the network (eg satellite links).

Related: SYS#5987
Change-Id: Idffd91b68d1f98ac906d78e7fbc0e6eaa1962f9e
2022-09-29 16:02:03 +02:00
Pau Espin 4d090d85f4 osmux: Drop unneeded comment block
Change-Id: Iae04a7c4b496492ce5b363a56fdd871b210012ed
2022-09-29 16:02:03 +02:00
Pau Espin 81c5847434 cosmetic: osmux: Drop extra empty line
Change-Id: I679a62c49290dfeb9e2c63890daa67002bfe3339
2022-09-27 13:45:07 +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 b4a59475d2 osmux: Fix incorrect rate_ctr_group used in mgcp_osmux.c
During development of the counters, they were first added to the same
RTP counter group and later on split, but some places still used the
RTP related functions to increment the counters.
Let's add a seaprate set of helpers to update the correct osmux counter
group.

Fixes: 582c2bf7b0

Change-Id: Ia2e5601c7d476b79afd95032dbc019517f8209af
2022-09-25 00:05:49 +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 b9022497d8 cosmetic: osmux: Fix formatting of if-else brackets
Change-Id: I748d41cd110841ef121f70560e70c07de56aa9da
2022-09-22 21:47:23 +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 663ba5c41f Use 'static const' instead of 'const static' everywhere
As requested by the linter on a new patch being submitted.

Change-Id: I692624da6a1c7f59ac2989509f074cb52d089907
2022-09-22 21:43:45 +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 941e317c97 osmux: Get rid of static NULL talloc context
struct osmux_handle, which is shared by several rtp_conn, is
attached to the trunk object, since the socket also attaches to it.

Related: SYS#5987
Change-Id: If4980424cdb8e3dc26a23e9ee419c0a38912f38f
2022-09-22 21:21:11 +02:00
Pau Espin 3fbf035923 osmux: Clean up helper macro osmux_chunk_length()
Change-Id: I482d8c5be08610788c2ed98e3b87ae4184075e8d
2022-09-22 19:01:33 +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 4d1a52d463 osmux: Log sendto() error
Change-Id: Icd91b725ac6b5ef2b9307cc99d67d60efdfa32cb
2022-09-22 17:11:57 +02:00
Pau Espin 83df47cd7a cosmetic: vty: Fix indentation whitespace
Change-Id: I2f42707f815ca58690d86a956118b6661c59fda3
2022-09-21 20:07:59 +02:00
Pau Espin c5bbb78ffe osmux: set log level of expected code path to INFO
Change-Id: I5caf850b7bb19c66716139512f16568d4f8459eb
2022-09-19 16:46:02 +02:00
Harald Welte e0e5a772f4 Make osmo_mgcpc_ep_fsm_pre_term() static
This is a call-back for FSM pre-termination and it should not
be publicly exported.

Change-Id: Iaa44906baa201571f6bc3192bd3caacb272fec0b
2022-09-16 10:37:22 +00:00
Pau Espin e39ae87ea3 osmux: don't store conn ptr inside shared osmux_handle
The struct osmux_handle is a shared structure which goes together 1-1
with libosmo-netif's struct osmux_in_handle, which is common to all CIDs
to be muxed together. Hence, it makes no sense to store a specific conn
object to it, since it actually manages several of them. Hence, all the
conn specific stuff must be handled beforehand, not at osmux deliver
time.

Related: SYS#5987
Change-Id: Ie739b556e9eb7d3133e798831a09728c7cc87135
2022-09-09 18:13:45 +02:00
Pau Espin 8b0a614e43 osmux: Fix memleak on error code path
Change-Id: Ib84f78a53293799b925b645156513e129c32c705
2022-09-09 18:13:45 +02:00
Pau Espin c61664c2b2 osmux: Log refcounting of osmux_handle_list
Change-Id: Ia873e3021078976748762baaf406865149b2a090
2022-09-09 18:13:45 +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 ab8371c6d7 osmux: Use better name for function which may allocate a new struct
Change-Id: I867e3f74775d97749a78c2f198452b1f2916492f
2022-09-09 16:40:57 +02:00
Pau Espin 8c777990a5 cosmetic: main: Properly format log_info_cat
Change-Id: If130d1debc1977b7f8d82f515861df2c513d55bb
2022-09-09 16:21:22 +02:00
Pau Espin ec5e85b84e Add Osmux log category
Change-Id: Ia75de7965c39f3f84164a25584d901dbdd43f10f
2022-09-09 16:04:19 +02:00
Pau Espin ab4e8663e1 mgw: Use X-Osmux string define
Change-Id: Ib437c0a6b414f1d8f08fdb90e88a61e9aed2780d
2022-09-08 15:15:37 +02:00
Pau Espin a4f783b51b cosmetic: osmux: Fix wrong indentation
Change-Id: I7675d17bb3fc827e05c197104be29eadd8ddf3f2
2022-09-07 20:04:20 +02:00
Pau Espin 479cf76e55 mgw: Fix osmux conn local IP selection
The local Osmux IP address (cfg->osmux_addr) was never applied in
generated MGCP messages. Instead, the RTP one was written into the
MGCP message.

Related: SYS#5987
Change-Id: I305f2501221e86d1eb0140446c03f36698f3194a
2022-09-07 19:42:59 +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
Max 709aad28ed Set working directory in systemd service file
By default systemd will execute service with root directory (or home directory for user instance) which might result in
attempts to create files in unexpected place. Let's set it to 'osmocom' subdir of state directory (/var/lib for system instance) instead.

Related: OS#4821
Change-Id: I7696cd92953787591e7b4777ee79c2671326b972
2022-08-30 19:45:32 +07: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 f1f73b8e1d mgcp_osmux: Drop duplicated conn_osmux_release_cid() in code path
Change-Id: I65d9978ee93ef9b1a2e48a92617ae8de3e131a93
2022-08-12 14:06:50 +02:00
Philipp Maier 0fdc08c551 mgcp_e1: fix apidoc
Change-Id: Iaccb9b67e72d113483160e61f660ea9c4c2f53a5
2022-08-10 14:13:41 +02:00
Vadim Yanitskiy 5be57da075 libosmo-mgcp-client: add -no-undefined to *_la_LDFLAGS
Make sure that there is no undefined references in shared libraries.

Change-Id: If6aa8016026beb8bad735987f3ab6e0d114b86a5
2022-08-04 05:35:43 +07:00
Pau Espin 147184eb06 mgcp-client: Remove impossible code path
read(4096 - 128) cannot return > 4096 - 128.

Change-Id: I352c3b28c8de6482277cb84cd0f51893494dc929
2022-06-29 18:45:02 +02:00
Pau Espin cfef36837e Bump version: 1.9.0.26-c9466-dirty → 1.10.0
Change-Id: If6d23bd0628cebf6cfa8fca0ae8a91278264e2a3
2022-06-28 18:50:25 +02:00
Harald Welte c946605208 update git URLs (git -> https; gitea)
Change-Id: I122aa939df79663a4f226565b32524b2bfdf7c68
2022-06-18 12:18:10 +02:00
Pau Espin a02faff1ac iuup: Check for IuUP Initialization retrans
Since libosmocore.git Change-Id
I5cb740702805693cc7f0a550e2e093f9bfdd507c, the IuUP stack can send INIT
event more than once, it sends one each time an IuUP Initialization
message is received.
This is done since potentially a peer could send an Initialization
message at any time with a different subflow size configuration. So
ideally we should update all osmo-mgw state regarding codecs, and
forward the Init starting the procedure on the other conn of the
endpoint.
However, this scenario is most probably not going to happen right now
and it would be a lot of work to implement and test,
and subsequent INITs we received will almost surely come from
retransmissions of the initial Initialization message, which means
content will not really change.
Hence, it makes sense to simply drop the receive message (the IuUP stack
already takes care of re-ACKing it) and let the endpoint state continue
with its ongoing procedures.

Related: SYS#4705
Change-Id: Ib97bc6f57d265622e24a776b96f0a82c25d33d39
2022-06-13 15:57:39 +02:00
Pau Espin ce055d5ac4 iuup: Fix caps in logging message
Change-Id: Icf836f770f22a9460378f91ef037997a73464faa
2022-05-25 18:34:06 +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
Vadim Yanitskiy 0b6faa4521 libosmo-mgcp: e1: fix memleaks in e1_recv_cb()
Change-Id: I4be9e6d09b34e792f24c9f09d19dce15b9dfbe3f
Fixes: OS#5533
2022-04-18 02:29:42 +03:00
Vadim Yanitskiy 1c69fb0f14 tests: use 'check_PROGRAMS' instead of 'noinst_PROGRAMS'
When using 'check_PROGRAMS', autoconf/automake generates smarter
Makefiles, so that the test programs are not being compiled during
the normal 'make all', but only during 'make check'.

Change-Id: I938669a78b4afa808ca4f741aee9919944aeb7f6
2022-04-13 19:55:34 +03:00
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
Pau Espin fed5feafd3 Drop unneeded ax_check_compile_flag.m4
The macro is no longer used since
172f5acfce.

Change-Id: I2daa73b960a9f3ae7babb8b44dc343aaaf3b57aa
2022-01-11 17:46:41 +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
Alexander Couzens b4a067c9fb doc/overview: fix wrong project page link
Change-Id: Ie221099bf1ac278729817ae88773cfc3a709ffba
2021-12-25 20:17:09 +01: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
Philipp Maier fae09f4562 configuration: point out difference between trunk-nr and e1 line nr
When configuring osmo-mgw the user may choose an arbitrary trunk number
for the E1 trunk and sets a line number that must match the number of
the physical line that is used with the particular trunk. This is easy
to confuse, so lets add a note to the maual that mekes this clear.

Change-Id: I4b647a60d21cae99663a8258d6636ec8a7609d97
Related OS#5308

Change-Id: Ide27fda6d9ee2627bb544d21aa65161eace35a34
2021-11-25 15:44:57 +01: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 98aef217c6 clang-format: remove foreach macros
We don't really care about the kernel style after all and the linter
complains about proper formatting, so remove all for-like macros so
we don't accidentally apply kernel style formatting.

Change-Id: Ia1b5848b31470b694a2031ad83e84f3132212f94
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
Oliver Smith 172f5acfce Revert "Turn some compiler warnings into errors"
Do not turn some compiler warnings into errors by default. This patch
was added before --enable-werror was available.

We build with --enable-werror during development and in CI. If the code
is built with a different compiler that throws additional warnings, it
should not stop the build.

This reverts commit 34f012639d.

Related: OS#5289
Change-Id: I6042f917a5a891dd13cb96d9477a45a45a7b35fe
2021-11-04 10:52:40 +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
Eric Wild 995529548b add modified .clang-format
Adjusted ColumnLimit: 80 -> 120
Added ForEachMacros:
  - 'for_each_line'
  - 'for_each_non_empty_line'

Change-Id: I080cf2d2437d0b8e6190fbd7c01af8cdc9420878
2021-11-03 15:18:45 +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
Eric Wild 1e8d5fa44b fix missing includes and forward declarations
Change-Id: I669e475f7ab74abef85f0f6194cc37db04af62e3
2021-09-10 17:24:45 +02:00
Eric Wild 374ad788d8 configure.ac: fix maybe-uninitialized for clang
Clang and gcc have different names for this, but the check fails without
-Werror since clang only warns about unknown args.

The previous check led to a lot of "unknown arg" spam while compiling
with clang.

Change-Id: Iad6c16beed26d5fe8952d7d5a79a93845c391b48
2021-09-10 17:24:45 +02:00
Eric Wild da07b90f0f add vscode stuff to gitignore
Change-Id: If3cfb71700929aa63df7f4f7f89f5392ba94c77e
2021-09-09 16:04:17 +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
Daniel Willmann 41ab87f67c contrib/jenkins: Use ASAN for osmo-mgw
Change-Id: I55cfea8a94730ebfaed1ef3227c50777edfb94fb
Related: OS#5201
2021-07-23 15:20:59 +02: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 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 97cae477fb mgcp_ratectr: fix sourcecode formatting
Change-Id: I7460fd4cdf1a552bca1af681faaa9bd8f88f1404
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
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 4f6a7ad5f8 manual: Include QoS chapter and add osmo-mgw specific example
Change-Id: I46f632f52a86a50242689a0132a7a7cb2a8feb12
Depends: osmo-gsm-manuals.git Id344c29eda2a9b3e36376302b425e9db1f6c0f28
2021-04-29 21:26:15 +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 3ff5151661 manual: don't define fig-bsc twice
Change-Id: Ibaed44a8de5425b420820a13f14c92c38b9c5fd9
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
Harald Welte 9ffaba7c1b Bump version: 1.8.0.1-535e → 1.8.1
Change-Id: Ib92e6ca89e1406d3707a94063975fe338cf67a9e
2021-02-24 10:56:17 +01:00
Harald Welte 535ede2598 attempt to fix RPM spec file after recent soversion bump
In I64ff22193ab2a95a9a7d66e9957a875d096e23de the soversion was
chhanged, but the spec.in file was not adjusted accordingly.

Change-Id: I45d7321adb2db8e7b9ea41b6bcf0c6cc59984a0e
2021-02-24 10:54:32 +01: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
Pau Espin ace0b946ff tests: Replace deprecated API log_set_print_filename
Change-Id: I761d2bf99aa5a009ff489584d804634e58588125
2021-02-19 13:33:52 +01:00
Pau Espin a34036c296 .gitignore: Ignore new autofoo tmp files
Change-Id: I792f5cd80bee6572ee60269ac44a12d10b5e3a5f
2021-02-04 12:50:27 +01:00
Oliver Smith 9fec391d6e configure.ac: set -std=gnu11
Change-Id: Ic2a1f20be65810a86cdc36aaa459819146a0bfcc
2021-01-28 09:28:08 +00:00
Oliver Smith a835fa85d7 contrib/jenkins: don't build osmo-gsm-manuals
Related: OS#4912
Change-Id: Idb179c5618797bb245fad857fa79242c43d539a2
2021-01-13 13:14:39 +01:00
Vadim Yanitskiy 2c66c15227 fixup mgcp_trunk: increase default number of virtual endpoints
In change I55605ea083565b6950d0820e3f72c50c9dc19ffa, the default
number of endpoints was increased to 512, however the
configuration examples were not updated.

Change-Id: I449a612065a5208c9f70ae74f594e8d45eb344cf
Related: OS#4711, SYS#5262
2021-01-02 11:29:29 +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 6e2795bfbf usermanual: add chapter about mgcp endpoints
The manual does not say much about the endpoint naming, even though
osmo-mgw is oriented at RFC 3435 the endpoint names are specific to
osmo-mgw. In particular the E1/T1 endpoints and their overlapping need
some explaination

Change-Id: I16265eb667221959a69f33701d024bd8d9b22040
2020-12-01 12:04:38 +00:00
Philipp Maier 276b595361 configuration: add section about E1 trunks
The cunfiguration chapter does not say anything about E1 trunk
configurations, lets add a subsection that explains how an E1
trunk is added.

Change-Id: I4059771df0f115242398d1af499c837005a7dabc
2020-12-01 12:04:38 +00: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 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
Philipp Maier 870f94b493 configuration: add note that changes to trunks need a restart
Change-Id: I06e3f8fed9a6784be773fbdd6a1e3d6b41f7b0bb
2020-11-25 18:13:25 +01:00
Philipp Maier 242e9ada91 configuration: drop note about lackin E1 support
We have now support for E1 trunks

Change-Id: If62f2b646c3b649fa3cbb5ea7007e17b80086bce
2020-11-25 16:22:40 +01:00
Philipp Maier 9b444fd417 configuration: remove hint towards trunk 0 limit
The trunk 0 was reserved for rtpbridge in earlier versions of osmo-mgw,
this was due to internal technical limitations which no longer exist.

Change-Id: Ic322f7dcf28db827187a4537e2634a887bd7b13b
2020-11-25 16:09:16 +01:00
Philipp Maier e9473f610e overview: add graph to show E1 integration
Add a graph similar to "OsmoMGW used with OsmoMSC" that shows the
integration of a legacy E1 BTS into a AoIP network

Change-Id: I71dc2f4a188fbc25e81050be3dd4c83e1797e63d
2020-11-25 15:56:55 +01:00
Philipp Maier 53002b3a00 overview: fix graph "OsmoMGW used with OsmoMSC"
The graph "OsmoMGW used with OsmoMSC" shows a BSC entity that accepts
AoIP and RTP, however osmo-bsc has no RTP proxy functionality. It makes
probably more sense to remove the BTS from the graph and call "BSC" "2G
BSS"

Change-Id: I6c7d26b6e45d0f953b82bca3ae7b2f26600982b2
2020-11-25 15:47:35 +01:00
Philipp Maier a098b65252 overview: fix graph "OsmoMGW used with OsmoBSC"
The graph "OsmoMGW used with OsmoBSC" shows an RTP and 3GPP AoIP going
to OsmoMSC, this is technically wrong since osmoMSC has no RTP proxy
functionality whatsoever. Since the graph is not so much about OsmoMSC
it makes more sense to label OsmoMSC with "core-network", then it makes
sense and correctly highlights the role of osmo-mgw on the BSS side.

Change-Id: If3550a101e1e3cc2a25e21dcfe5474134015a6a7
2020-11-25 15:38:49 +01:00
Philipp Maier 78b0055e5e overview: update section limitations.
The limitations section is outdated. We now have support for osmux and
E1 timeslots with trau frames. However, we did not mention that we still
have no transcoding as well.

Change-Id: Ia0fe8be96bbf880cfcd9d18256f4ac23a6efae79
2020-11-25 15:11:30 +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
Pau Espin 38404969df contrib/jenkins: Enable parallel make in make distcheck
Change-Id: I8b73a9cdd0e481075a234abd9e94bd5c4396f168
Related: OS#4421
2020-10-12 19:34:58 +02: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 0ab152b2c6 mgw: Fix mgcp_rtp_end field description comment
Change-Id: Ieb044daaaa47572cd9a2524ea69e903200527d17
2020-09-07 15:55:30 +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 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 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 1add5a53cb mgcp-client: Fix trailing whitespace in mgcp_client_fsm.h
Change-Id: Iad9ee764c1b6d7960a810a3eef95b207596e4796
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
Harald Welte 9e494e67c7 Add example osmo-mgw configuration file for Abis/E1
In this example, we are using the first span (0) of the first DAHDI card
and use it as 'trunk 1' in the MGW.

Change-Id: I0a97da5163a94379b327403b1258696855836bad
2020-08-28 15:00:32 +02:00
Alexander Couzens 5322473d04 configure.ac: require libosmoabis + libosmotrau >= 1.0.0
Since osmo-mgw supports trau frames it requries a newer version.
The spec file already requires those newer version.

Change-Id: If6c7ecdde09c6e09ded7e0959b7765a01a31d702
2020-08-21 18:37:42 +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
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
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 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 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 62612e8575 mgcp: find better locations for LOGPCONN and LOGPENDP
The logging defines LOGPCONN and LOGPENDP are currently located in
mgcp_internal.h. However, there are specific header files for conn
(mgcp_conn.h) and endpoint (mgcp_endp.h) related stuff. Lets put LOGPCON
into mgcp_conn.h and LOGPENDP in mgcp_endp.h

Change-Id: I25ff37ee8108c27d169d294fd16ddcdde9b00195
2020-05-28 09:23:25 +00:00
Harald Welte af932ce3bc remove accidential TODO-RELEASE entry
I wanted to use gerrit to merge v1 of
 I8d58281e1ff898638293c9e8cb000329462c7a70, but gerrit merged v2
nevertheless :(

Change-Id: I7b16912e66e91f0c30716e4ea1181b39906bacc1
2020-05-28 11:22:29 +02:00
Philipp Maier 265b0a8045 mgcp: remove unused callback pointer
struct mgcp_config contains a function pointer realloc_cb, which is
never popoulated nor used anywhere in the code. Lets remove it

Change-Id: I8d58281e1ff898638293c9e8cb000329462c7a70
2020-05-27 13:45:26 +02:00
Philipp Maier 74390c521e cosmetic: remove excess newlines
Change-Id: Idefe3e86d5b659666bf0356991906c9a2f858aae
2020-05-26 22:26:04 +02:00
Oliver Smith abfb858f0c Makefile.am: EXTRA_DIST: debian, contrib/*.spec.in
Change-Id: I1ab1e30cc0c8a7ece997ae776ab0945a989eb82a
2020-05-22 13:41:39 +02:00
Oliver Smith 6500d72aaf contrib: integrate RPM spec
Remove OpenSUSE bug report link, set version to @VERSION@, make it build
with CentOS 8 etc.

Related: OS#4550
Change-Id: I1d03ac87a7d0c3c600d187f3e485cb2dab8838bb
2020-05-19 15:33:19 +02:00
Oliver Smith d6877eb8f9 contrib: import RPM spec
Copy the RPM spec file from:
https://build.opensuse.org/project/show/home:mnhauke:osmocom:nightly

Related: OS#4550
Change-Id: I6d6119ca5debf4adfec6c155f81027c8a3583537
2020-05-14 11:47:38 +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
Eric Wild eebbf2b1fc configure.ac: fix libtool issue with clang and sanitizer
As pointed out at https://github.com/libexpat/libexpat/issues/312
libtool does not play nice with clang sanitizer builds at all.
For those builds LD shoud be set to clang too (and LDFLAGS needs the
sanitizer flags as well), because the clang compiler driver knows how
linking to the sanitizer libs works, but then at a later stage libtool
fails to actually produce the shared libraries and the build fails. This
is fixed by this patch.

Addtionally LD_LIBRARY_PATH has no effect on conftest runs during
configure time, so the rpath needs to be set to the asan library path to
ensure the configure run does not fail due to a missing asan library,
i.e.:

SANS='-fsanitize=memory -fsanitize-recover=all -shared-libsan'
export CC=clang-10
ASANPATH=$(dirname `$CC -print-file-name=libclang_rt.asan-x86_64.so`)
export LDFLAGS="-Wl,-rpath,$ASANPATH $SANS $LDFLAGS"

Change-Id: I2314ef45e6f588e88d5aab8213cc7b5cdef11325
2020-04-11 18:33:04 +00:00
Eric Wild e885bc5c24 tests: dlopen does not imply availability of dlsym..
Check for both.

Change-Id: I1a1e82882ad28dd53e634f10f9cebb4bc74cac1e
2020-04-11 00:57:13 +02:00
Philipp Maier 173dc129fc doc: do not bind osmo-mgw to random ip-address
The example config bind the MGW to a random ip-address, lets use the
loopback address here, this will suit cases where osmo-bts runs on the
same machine as the MGW (nitb). For all other cases were an external BTS
is used the ip-address still needs to be changed.

Change-Id: Iae52c671c48953ea6b52b18c5d77347343cde0df
2020-03-24 20:37:44 +01: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
Oliver Smith 832bcdf631 osmoappdesc.py: switch to python 3
Make build and external tests work with python3, so we can drop
the python2 dependency.

This should be merged shortly after osmo-python-tests was migrated to
python3, and the jenkins build slaves were (automatically) updated to
have the new osmo-python-tests installed.

Related: OS#2819
Depends: osmo-python-tests I3ffc3519bf6c22536a49dad7a966188ddad351a7
Change-Id: I48f4c2c520e8285aff5d6d65f95bd041c13466e8
2019-12-11 09:35:24 +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
Harald Welte a8f27abe12 manual: Fix copy+paste error
Change-Id: I5cd93994563520c94ed9aefbedaf9d18ea2134a6
2019-12-01 14:33:33 +00: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
Pau Espin d071a30238 mgcp_test: Correctly release all endpoints allocated
Currently in handle_create_con(), mgcp_conn_alloc() is called with NULl
ctx. As soon as this ctx is changed to be part of the trunk's endpoint
array (tcfg->endpoints), test will segfault because some fds from
previous tcfg are still registered after the whole tcfg object was freed
with talloc_free() by previous test. That's because
mgcp_endpoint_release() must be called on all endpoints to make sure all
registered components are correctly unplugged.

Related: OS#3950
Change-Id: I813d52b518ed0bb8db4e42dff83e040b0891fee2
2019-09-19 17:43:21 +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 2698540c1e test_mgcp_codec_pt_translate(): more tests
Change-Id: I334a075ac2800ae4a7c4e2d6eaeb17dd8c6b09a1
2019-08-28 00:17:40 +02:00
Neels Hofmeyr d2f5e69d3e mgcp_test: extend / rewrite test_mgcp_codec_pt_translate()
Instead of manually entering codec values, use mgcp_codec_add() to populate
test conns with codecs. The idea is to better test what actually happens when
parsing SDP codec strings.

Rewrite current test_mgcp_codec_pt_translate() from procedural to a data model
with human readable stdout logging.

This prepares to enable interpreting codec strings like "FOO/8000/1" as
equivalent with "FOO/8000": the SDP standard defines the final "/1", indicating
the nr of channels, as optional for a single channel, but osmo-mgw currently is
unable to match these two formats as identical. So prepare the
test_mgcp_codec_pt_translate() so that upcoming patches can incorporate strings
with and without the final "/1" by extending the struct arrays.

Change-Id: I888000d77512cfecb0f199b86ef6003e7fc0e6cb
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 a2d10216ea configure.ac: Require libosmo-netif 0.6.0
Current code uses APIs like osmux_xfrm_output_init2() and osmo_amr_*(),
that are only available in libosmo-netif 0.6.0 onwards. Let's update
configure.ac accordingly.

Change-Id: I3bc0196bb6b5c5e5cf96935422fd56c4582ed7f5
2019-08-07 16:42:28 +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
Pau Espin f7de9aea7b doc: Add Osmux documentation to OsmoMGW User Manual
Depends: osmo-gsm-manuals.git I182d94c63f7d74ef882b77be59a95b1b7d8a4e5e
Change-Id: Ie53f98777070fc00ed085646f698d20f8cf49553
2019-07-24 19:32:56 +00:00
Hoernchen 199c5e965e turn -Werror=null-dereference into a warning
There is unfortunately no way to suppres this witha pragma,
and gcc 9 uncovers quite a few new instaces with enabled LTO that can't/won't be fixed

Related: OS#4123
Change-Id: Ib157bd2e110b271dbe5ac928c98251e016477f56
2019-07-22 19:56:59 +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
Oliver Smith 6349bd422a contrib/jenkins.sh: run "make maintainer-clean"
Related: OS#3047
Change-Id: I60c713a64ef629f0cb88121632ea6adc017fd0ae
2019-07-10 13:29:36 +02:00
Pau Espin 796a4a1325 doc: X-Osmo-IGN: small formatting and typo fixes
Change-Id: I658901a63504f3733793c34947d59b034daa93f6
2019-07-07 14:34:17 +00:00
Oliver Smith 2cf6652ba2 "make dist" fix for: no rule to make mgcp_common.h
Mark osmocom/mgcp_client/mgcp_common.h as nodist, so "make dist" will
not try to include it in the source tarball. This caused "make dist" to
fail in a clean osmo-mgw source tree with:
make[2]: *** No rule to make target 'osmocom/mgcp_client/mgcp_common.h', needed by 'distdir'.  Stop.

The file gets copied during make from osmocom/mgcp/mgcp_common.h (see
include/osmocom/mgcp_client/Makefile.am). Therefore it is not included
in the source tree and we don't need to distribute it.

Related: OS#4084
Change-Id: Ia1d7b051c0924a785b0f7ec0195192e3a852ed70
2019-07-07 08:15:28 +00: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 1e4a34d45e manuals: update VTY documentation
Change-Id: Id34c363080ced158d1f1eddd15b954e731797cf8
2019-06-27 09:41:35 +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
Daniel Willmann ef9420adf5 manuals: Update vty/counter documentation
Change-Id: Icc86ef7ddd8a30984f91b025157e11fc0df9631e
Depends: OS#1700
2019-06-19 14:08:22 +02:00
Daniel Willmann cb96e05a91 manuals: Add script to regenerate vty/counter documentation
Change-Id: Ib5e0bd9ec430a6ef3dce6845d7def39720c54637
Depends: Ic5828957a29d4f317e1ebf4f03b5f5359f6250e8 (docker-playground.git)
Related: OS#1700
2019-06-19 14:08:21 +02:00
Oliver Smith f6387dc766 debian: create -doc subpackage with pdf manuals
I have verified, that the resulting debian packages build in my own OBS
namespace (see the -doc packages):
https://download.opensuse.org/repositories/home:/osmith42/Debian_9.0/all/
https://build.opensuse.org/project/show/home:osmith42

Depends: Ib7251cca9116151e473798879375cd5eb48ff3ad (osmo-ci)
Related: OS#3899
Change-Id: I8466713a8d414ea56ca24f6f7119338ad2b98ce5
2019-05-31 14:25:27 +00: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
Pau Espin fa810e8ccd osmux: Mark conn_rtp->type as osmux during CRCX
We also update code to allow setting up RTP related fields to succeed
during CRCX. We also update code to allow setting up RTP related fields to
succeed during CRCX.

Change-Id: Ia6e723d9a28ba38fc3382a4fb35ea6e5bab30c09
2019-05-13 18:56:56 +02:00
Pau Espin 497611ae84 osmux: Introduce mgcp_conn_rtp_is_osmux() helper
This is going to be useful to know if a conn is to use Osmux without
looking at implementation details. Currently we have some duplicated
information (type, osmux.state, etc.) which we may want to refactor
later. This will allow changing implementation details without caring
much about rest of code.

Change-Id: Ib5a239fdbc319bcb16317f5e959d9a724b7a444a
2019-05-13 18:56:56 +02:00
Pau Espin 2b89617aad osmux: Allocate CID during CRCX
Change-Id: Ie0e1835ff7e99421de9a5741a5eb57a11c004f7e
2019-05-13 18:56:56 +02:00
Pau Espin b542b0457b vty: Allow enabling Osmux
Change-Id: Ica2f82473bf1934502444be2325ee2049d938781
2019-05-13 18:56:56 +02:00
Pau Espin 120568651a cosmetic: osmux: Document network byte order in port variable
Change-Id: Ia367ef08625265bc9cbdfcc693720a9b88852f4a
2019-05-13 18:56:56 +02:00
Pau Espin f1d301a9a6 cosmetic: mgcp_udp_send: Document port param is in network byte order
Change-Id: I7c4a388eba850ac066e60db089d46da0247773ec
2019-05-13 18:56:56 +02:00
Pau Espin c9a6280c94 osmux: Use LOGPCONN in several log calls
Change-Id: Ieb2c4b53db2df44e0dfbedb7de76d8cf6c83da91
2019-05-13 13:20:13 +02:00
Pau Espin b5583cde41 osmux: Fix reception of legacy dummy payloads
Size check had a bug. Take the opportunity to print wrong frames on
error.

Change-Id: I9f0d4e28a2019c7ad94344f2c34d17c365bebea9
2019-05-13 12:59:51 +02:00
Vadim Yanitskiy 6c1cd63a57 configure.ac: drop useless check for -fvisibility=hidden
We don't use this attribute in OsmoMGW anyway.

Change-Id: I61d08adbaaf938310f9474a1ea449e016a611ca3
2019-05-10 23:34:21 +07:00
Harald Welte 0d7ba56f5c update .gitignore
* remove tons of old cruft from openbsc.git that doesn't exist here
* actually add the osmo-mgw binary and .la file that we're building

Change-Id: Ic0e27c05e3ab368c195f9f9961fa70feb077a5e0
2019-05-08 22:15:27 +00:00
Harald Welte 3ac604e3ad handle NULL return of rate_ctr_group_alloc()
Change-Id: Ieadded9c088ef8f86164400a60ce542e3c868e9d
Related: OS#3701
2019-05-08 22:15:27 +00:00
Pau Espin 9fb8ddf00e osmux: Document func and return different rc upon osmux init failure
Change-Id: Id8593bc374b598e63a70c60ac256273b9d99ba6e
2019-05-08 16:39:13 +00:00
Pau Espin 182ca3bad4 mgcp-cli: Change osmo_mgcpc_ep_fsm name to avoid collision with old osmo-bsc
Recent commit moved mgw_endpoint_fsm from osmo-bsc.git here as
osmo_mgcpc_ep_fsm. Some API name changes were applied to avoid
collisions, but FSM was kept and it is registered during startup with
__attribute__((constructor)). As a result, with old osmo-bsc (+tests)
try to allocate its copy of mgw_endpoint_fsm, it fails because that name
is already registered.

Fixes: 538d2c53d9
Change-Id: I694ce58baa43f536b7e594b003edc891f029aa4a
2019-05-08 14:03:13 +02:00
Pau Espin f027f17dcb osmux: Log osmux socket during osmux_init
Change-Id: I43a658b19765b1c3b3cc42f78602b793ee36c67d
2019-05-06 17:41:37 +00:00
Pau Espin ac772d8b0c mgcp_osmux.c: osmux_enable_endpoint: Fix incorrect return check
osmux_xfrm_input_open_circuit returns 0 on success and -1 on error.
Confusion comes from that function being implemented by calling
osmux_batch_add_circuit which returns NULL on error.

cherry-picked from: openbsc.git ac1b03c8e59408336d07527e2597171cb99ed654.

Change-Id: Iba018aa57901642ea4c486526a973fe6023e10cf
2019-05-06 18:02:02 +02:00
Alexander Couzens 9d9f44ac71 mgcp_internal: LOGPENDP: ensure *endp is not NULL
In certain cases the endp can be NULL. LOGPENDP will dereference the
pointer to retreive the endpoint number.

Fixes: 8a893442a1e9 ("mgcp_internal: LOGPENDP: ensure *endp is not NULL")
Change-Id: Ie9b5ecf08f69533ccb2fbd7fbbb529105e0c922f
2019-05-02 17:59:51 +02:00
Neels Hofmeyr 84274e4e9b constify map_codec_to_pt() ptmap arg
Change-Id: I030843d2d692b7a73cca8f427df070d2806ab695
2019-04-30 02:25:05 +02:00
Neels Hofmeyr c5479fe086 fix: multiple initial CRCX
The first CRCX responds with the actual MGW endpoint name that is assigned (at
least for rtpbridge/*@mgw requests).

If multiple CRCX are scheduled at the same time on a fresh MGW endpoint, both
get fired with a '*' and each creates a separate MGW endpoint.

Make mgcp_client_endpoint_fsm avoid this, and schedule only one CRCX at first,
and the rest once the MGW endpoint name is fixated. It is thus possible to
safely issue two osmo_mgcpc_ep_ci_request() at the same time.

Change-Id: I92a9944acc96398acd6649f9c3c5badec5dd6dcc
2019-04-30 02:25:05 +02:00
Neels Hofmeyr 538d2c53d9 move MGW endpoint FSM from osmo-bsc to here
Move mgw_endpoint_fsm from osmo-bsc here as osmo_mgcpc_ep_fsm. Apply various
renames for consistency. Use osmo_tdef from libosmocore instead of osmo-bsc's
(so far) local T_defs API.

Change T23042 to T2427001, which is a slightly less arbitrary number and
slightly more extendable in the future (2427 corresponds to the default MGCP
port at osmo-mgw, 001 is the first MGCP timer and so far the only one).

Change-Id: I9a3effd38e72841529df6c135c077116981dea36
2019-04-30 02:25:05 +02:00
Pau Espin 8de58e79b8 osmux: Cleanup of CID alloc pool APIs
* Cleanup naming to make it far more clear
* Drop 2 variables holding CID values (allocated_cid, cid), in favour of
1 value holdinf the value and one bool stating whether the value is
used.
* Change conn_osmux_allocate_cid to allow allocating either next
available CID or a specific one, in preparation for forthcoming patches.

This commit can be merged straight away because anyway osmux cannot be
enabled in current status (blocked by vty config) and
(conn_)osmux_allocate_cid was/is not called anywhere. However, it helps
improving code base for future re-introduction of Osmux as it is
envisioned.

Change-Id: I737a248ac6c74add8e917fe2e2f36779d0f1d685
2019-04-25 21:38:38 +00:00
Pau Espin 5e8d7995d1 create_response_with_sdp: Fix inclusion of X-Osmux
In previous code, 2 blocks were handling osmux inclusion one after the
other under same osmux.state. However, first block changes osmux.state
so second block can never be true and X-Osmux is never added.

Change-Id: Iceee8b64978651f1fe6bb883923561b081f73d9b
2019-04-25 21:38:31 +00: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
Pau Espin 209eb9f103 cosmetic: handle_modify_con: Fix indentation level
Change-Id: Ieb1e07d667a9fc1ff1e2fd367cbdb3c0dbfd4607
2019-04-24 12:03:24 +02:00
Pau Espin ef6304e4a1 mgcp_msg: Log faulty line on Osmux parsing error
Change-Id: I436e53963f8e7d00f3111ff81f7b08475c4b8ae9
2019-04-23 13:24:58 +02:00
Pau Espin 21cdbfc196 cosmetic: tests: mgcp_client_test: clean trailing whitespace
Change-Id: Ie27c0a9bf7a16983f31a07c314b0a602e9fb8999
2019-04-23 12:36:51 +02:00
Pau Espin fc8067348b cosmetic: Fix typos in comment
Change-Id: I3c638033f1008325d2d653f00717e8c4a1bf9789
2019-04-23 00:20:32 +02:00
Pau Espin 9f11dc5616 libosmo-mgcp: Use trunk type during endpoint allocation
This way we prepare it to add more endpoint types in the future (osmux)
and also make it clear that E1 endpoint specifics allocation is still
missing.

Change-Id: I7633b5287a436c11f0bbbdbaef1cf59a051a2471
2019-04-22 20:50:03 +02:00
Pau Espin ca0818c760 mgcp-client: Sanitize implementation of mgcp_client_rtpbridge_wildcard
* Get rid of string define containing printf statements
* Split name from rest of checks to easily add new names later

Change-Id: I46e05a7a3432733976760bbf1c5deb4f7610db11
2019-04-16 19:45:29 +02:00
Pau Espin c12bfb7ffc mgcp-client: whitespace cleanup in mgcp_client.c
Change-Id: Ic3495d70cb9c4e12552c6d97481cc0cf04b79f94
2019-04-16 17:23:09 +02:00
Philipp Maier 228e591589 AMR: Add function to convert between bw-effient and octet aligned mode
RFC3267 specifies two framing modes for AMR packets. An octet aligned
mode is specified where all fields of the AMR packets are aligned to
octet boundaries. The second framing mode is the bandwith efficient mode
where the fields are directly packed one after another.

- add paring/generation functions for related SDP fmtp parameters
- add conversion function to convert AMR payload

Depends: libosmo-netif I5b5a0fa644d8dbb1f04f9d7e35312683c7b3d196
Change-Id: I622c01874b25f5049d4f59eb8157e0ea3cbe16ba
Related: OS#3807
2019-03-12 09:56:28 +01:00
Philipp Maier 58128258b0 mgcp_network: use mgcp_rtp_codec in downlink format callback
The callback function mgcp_get_format() is used to request the codec
parameters for a specific connection. This function returns the
parameters as idividual pointers. Since there is a struct that holds all
important codec information among the ones which are currently returned
by mgcp_get_format, lets just use this codec struct as single return
value.

Change-Id: I348f9141eb59ed1a986447b96ab4a24ddf326936
Related: OS#3807
2019-03-11 09:55:04 +01:00
Philipp Maier e7ae69a7be mgcp_sdp: untangle parsing of a= parameters
The if construct that takes care for parsing the a= parameters is
unnecessary complex. Lets handle each of the possible parameters
seperately on the same level.

Change-Id: Ifc801a757e9beb6b3974863d5ee99fc7c194559e
Related: OS#3807
2019-03-11 09:24:52 +01:00
Philipp Maier 7e37ce6008 mgcp_sdp: mgcp_sdp.c does not include own header file
The header file mgcp_sdp.h is not included by mgcp_sdp.c. Lets include
it here as well in order to be complete.

Change-Id: I3d9f28d6e7ca027b1be25d775a6a75d0fc491a50
2019-03-07 13:50:32 +01:00
Philipp Maier dbe09dd515 mgco_client: cosmetic: remove excess whitespace
Change-Id: I54d70d8dfd7b4e1d3db892ec553eb78c6792d520
2019-03-07 13:50:32 +01:00
Philipp Maier 217d31d62f mgcp_sdp: cosmetic: correct typo in comment
Change-Id: I42aa9b5ce36df347cfb72be97e0f7a1898e6e8d0
2019-03-06 09:54:29 +01:00
Neels Hofmeyr 47642f245d make codec_table public as osmo_mgcpc_codec_names
These value_string[]s are also useful for printing chosen codecs in osmo-msc.

Change-Id: Ida0e59f9a1f2dd18efea0a51680a67b69f141efa
2019-03-04 22:25:06 +01:00
Neels Hofmeyr cb760bdebe mgcp client: allow setting conn mode for CRCX and MDCX
Add conn_mode to struct mgcp_conn_peer, to allow setting an explicit connection
mode instead of implicit MGCP_CONN_RECV_ONLY / MGCP_CONN_RECV_SEND depending on
remote RTP port presence. Default to old behavior if this is left unset.

Rationale:

For IuUP Initialization, osmo-msc currently still uses a hack at osmo-mgw to
echo the IuUP Initialization back to the sender as an ACK. For sanity checking
reasons, this is done iff the CRCX created the CI in loopback mode. So, in
order to be able to switch to the mgcp_client_fsm in osmo-msc instead of
"manual" MGCP message composition and yet still be able to support IuUP and
IuCS, we need to be able to set the conn mode upon CRCX to loopback.

If we merged the IuUP patch (which is already on a branch somewhere) to
osmo-mgw, we wouldn't bother with this patch, but adding this conn mode choice
has these benefits:

- post-IuUP-fix osmo-msc versions can interop with older osmo-mgw IuUP for
  IuCS.

- It is conceivable that some MGCP clients prefer explicit conn modes instead
  of the implicit MGCP_CONN_RECV_ONLY / MGCP_CONN_RECV_SEND choice. This opens
  the possibility to switch between conn modes with MDCX messages.

Change-Id: I26be5c4b06a680f25f19797407ab56a5a4880ddc
2019-03-04 22:25:06 +01:00
Neels Hofmeyr e3f8bca424 log: don't spam with "can not patch PT" messages
currently, when looking at an osmo-mgw log output with a phone call working
completely fine, you see these messages on LOGL_ERROR for each RTP packet:

20190304221420619 DRTP ERROR endpoint:0x0 can not patch PT because no suitable egress codec was found. (mgcp_network.c:761)
20190304221420639 DRTP ERROR endpoint:0x1 can not patch PT because no suitable egress codec was found. (mgcp_network.c:761)
20190304221420639 DRTP ERROR endpoint:0x0 can not patch PT because no suitable egress codec was found. (mgcp_network.c:761)
20190304221420659 DRTP ERROR endpoint:0x1 can not patch PT because no suitable egress codec was found. (mgcp_network.c:761)
20190304221420659 DRTP ERROR endpoint:0x0 can not patch PT because no suitable egress codec was found. (mgcp_network.c:761)

Put these messages on DEBUG level instead. They currently do not convey useful
information.

Possibly our MGCP clients could use some changes in behavior regarding payload
types, but since that topic is quite unresolved, let's not spam the ERROR log
level with this.

Change-Id: I4afc41fd472ec8ba887b9263fbac62de50d7cef9
2019-03-04 22:25:06 +01:00
Philipp Maier 9fc8a02196 Add option to GSM HR frames to RFC5593 representation
There are different specifications around on how a GSM-HR frame should
be encapsulated into an RTP packet. RFC5593 specifies a ToC (Table of
Contents) byte to be prepended in front of the payload data.

The two formats can be distinguished easily by their length. Then the
data can be formatted into the corresponding opposite format and vice
versa.

- Add new VTY rtp-patch options
- Add conversion function

Change-Id: Iceef19e5619f8c92dfa7c8cdecb2e9b15f0a11a1
Related: OS#3807
2019-02-25 15:06:05 +01:00
Oliver Smith e36b775eae Inactive connection cleanup (disabled by default)
Add a watchdog timer to connections, and close these connections when
the watchdog timer expires. Kick the watchdog whenever RTP messages or
the relevant MGCP messages arrive. Add the currently remaining timeout
to "show mgcp stats" in the VTY.

This feature is disabled by default, as it is incompatible with LCLS
(connections in LCLS state appear to be inactive). Enable it with the
new "conn-timeout" VTY setting. In general, this feature can be used to
work around interoperability problems causing connections to stay open
forever, and slowly exhausting all available ports. This happened for
various reasons already.

MDCX is the only relevant MGCP message:
- CRCX creates the conn and timer
- DLCX deletes the conn and timer
- MDCX is the only remaining supported MGCP message that indicates a CI
- Can't easily generically parse a CI for all MGCP messages, parsing is
  done in handle_modify_con().

Related: OS#3429
Change-Id: I18886052e090466f73829133c24f011806cc1fe0
2019-02-06 12:01:06 +01:00
Oliver Smith 622dd61764 Cosmetic: fix spaces/tabs in mgcp_requests[]
Change-Id: I2e8ef83b231b7d7b71e533d0699afea433d635aa
2019-01-30 15:27:21 +01:00
Harald Welte e81c1176aa Bump version: 1.4.0.90-ed0c-dirty → 1.5.0
Change-Id: I8f7c7b75f38ebd1ee48605596424af48cc1ad53d
2019-01-20 15:02:19 +01:00
Neels Hofmeyr ed0c1aa9d5 mgcp_client: tweak some log levels INFO -> {DEBUG,ERROR}
Change-Id: Ie4ecb4b82a7a1e476c58d0a6056525733254adbb
2019-01-03 02:12:55 +01:00
Neels Hofmeyr ac69ea9cdf mgcp_client: make domain part of endpoint configurable
So far, both osmo-msc and osmo-bsc always pass endpoint names of the form
'...@mgw' to osmo-mgw. Allow configuring the 'mgw' part.

Note that the actual way to pass a differing name is to pass a composed
'rtpbridge/*@foo' to mgcp_msg_gen() in the struct mgcp_msg. So this merely adds
a common VTY config for the domain name part, changes to clients are necessary.

- add mgcp_client_rtpbridge_wildcard() (useful for AoIP endpoints)
- add mgcp_client_endpoint_domain() (useful for SCCPlite endpoints)
- add mgcp client vty cfg 'mgw endpoint-domain NAME'

Rationale: reading pcaps becomes so much easier when each of osmo-bsc and
osmo-msc address their MGW with differing domain names. Otherwise, both will
have a '0@mgw' endpoint and it gets really confusing.

Also: our MGCP clients osmo-bsc and osmo-msc use code dup to compose the
initial 'rtpbridge/*@mgw' rtpbridge wildcard. It should be defined by this API
instead.

This will be used by:
* osmo-msc I87ac11847d1a6d165ee9a2b5d8a4978e7ac73433
* osmo-bsc I492023e9dca0233ec0a077032455d9f2e3880f78

After these, with according configuration, there can be a '0@bsc' and a '0@msc'
endpoint on two separate osmo-mgw instances:

osmo-mgw-for-bsc.cfg:
 mgcp
  domain bsc

osmo-bsc.cfg:
 msc 0
  mgw endpoint-domain bsc

osmo-mgw-for-msc.cfg:
 mgcp
  domain msc

osmo-msc.cfg:
 msc
  mgw endpoint-domain msc

There can also be '0@bsc' and '1@msc' endpoints on one single osmo-mgw instance with:

osmo-mgw.cfg:
 mgcp
  domain *

and same osmo-{bsc,msc}.cfg as above.

(By default, everything will still use '@mgw')

Change-Id: Ia662016f29dd8727d9c4626d726729641e21e1f8
2019-01-03 02:11:23 +01:00
Neels Hofmeyr 0a40379214 mgcp_client: logging tweaks
Fix typos, use osmo_sock_get_name2() to show the tx source and target IP:port,
shorten some wording.

Depends: I8ad89ac447c9c582742e70d082072bdd40a5a398 (libosmocore)
Change-Id: Iae728192f499330d16836d9435648f6b8ed213b6
2018-12-19 22:47:53 +00:00
Neels Hofmeyr 72bc8da537 mgcp_client: drop a bunch of dead code
Remove public API that makes no sense anymore and is dead code.

I see the dropped API as a dead-end initial misconception of the early mgcp
client, and it doesn't really make sense to drag this stuff along. It has not
been used by osmo-msc,-bsc for a long time now, and just confuses the reader.

It is public API, yes, and older versions of osmo-msc / osmo-bsc will not be
able to compile against this, but even if it did, the resulting MGCP client
would not work with the current osmo-mgw: this API is still based on the
premise that the MGCP client dictates the MGW endpoint numbers, a concept that
cannot be used with the current osmo-mgw. Instead, osmo-mgw expects a
wildcarded endpoint upon CRCX and assigns its own endpoint names.

Also, the bts-base configuration is unused and a legacy of when osmo-bsc_mgcp
had explicit BTS and CN sides.

Change-Id: I98a9f1f17a1c4ab20cea3b08c7d21663592134d6
2018-12-19 22:22:34 +00:00
Neels Hofmeyr c3132fd508 mgcp_client_vty: fix missing talloc_free
If the vty client enters multiple local / remote addresses, that leaks talloc
memory of the previously set addresses. Free those first, if any, using
osmo_talloc_replace_string().

Change-Id: I331b3d53b5eb330b87d798f952077a043674d409
2018-12-19 22:19:17 +00:00
Neels Hofmeyr 96c3107daf osmo-mgw: err-log: include expected domain name
Add the expected domain name, and move the error log to where the expected
domain name is compared.

Change-Id: I59f40dc9263f686852f103ca904fc0a6702d7c8e
2018-12-19 17:58:42 +01:00
Neels Hofmeyr ad21a0e166 check_rtp: on IP:port errors, log the IP and port
Half of those are obviously zero, but I'd rather print the raw data instead of
adding string constants, even if the condition must always lead to 0.0.0.0:0.

Rationale: I had osmo-mgw listen on 0.0.0.0 and got the error message
  DRTP ERROR endpoint:0x1 destination IP-address is invalid
which didn't convey that 0.0.0.0 is regarded as invalid.

Change-Id: I9e98d464a27038904797c5c10735a98ef5b7b9c3
2018-12-17 13:38:12 +00:00
Neels Hofmeyr 32d15cc8ba drop/replace very weird logging in mgcp_client.c
mgcp_do_write() is the final stage of writing data towards the MGCP server
(MGW). In that function, drop an unconditional iteration and copy of the MGCP
message to a static string buffer for no apparent reason besides debug logging.

Instead, use osmo_escape_str() with a limited length, which can just be an
inline format argument in the LOGP() statement. This way, the string mangling
is simpler and only gets run when DMGCP is actually on debug log level.

Change-Id: Id6877ed7fd7dbe009b2ece8792d5160d040c1aaa
2018-12-17 13:37:18 +00:00
Oliver Smith 1fd50e5306 contrib: fix makedistcheck with disabled systemd
EXTRA_DIST files need to be distributed, no matter if the systemd option
is configured or not.

Change-Id: I5014d98e06e033d04be45585b34458c90b1ced00
2018-12-06 13:54:53 +01:00
Oliver Smith 6802374574 contrib/jenkins.sh: build and publish manuals
Add new environment variables WITH_MANUALS and PUBLISH to control if
the manuals should be built and uploaded. Describe all environment vars
on top of the file.

When WITH_MANUALS is set, install osmo-gsm-manuals like any other
dependency and add --enable-manuals to the configure flags (for "make"
and "make distcheck"). Add the bin subdir of the installed files to
PATH, so osmo-gsm-manuals-check-depends can be used by ./configure.

Related: OS#3385
Change-Id: I24179b21ce4ff182649243e286c87c824b889454
2018-12-05 13:09:33 +01:00
Oliver Smith 82c1d1eb20 Fix DISTCHECK_CONFIGURE_FLAGS override
Set AM_DISTCHECK_CONFIGURE_FLAGS in Makefile.am instead of
DISTCHECK_CONFIGURE_FLAGS. This is the recommended way from the
automake manual, as otherwise the flag can't be changed by the user
anymore.

Related: OS#3718
Change-Id: Ie9db1519e89d2a8ca1e403e480f57d72fc25ab75
2018-12-04 15:36:37 +01:00
Oliver Smith 5a5169e15c jenkins.sh: remove leftover MGCP env variable
Jenkins currently runs the build twice, once with
MGCP="--enable-mgcp-transcoding" and once with
MGCP="--disable-mgcp-transcoding". The configure.ac does not have this
parameter, so let's remove the confusing variable.

This is in preparation for describing all environment variables used in
jenkins.sh (follow up commit).

Change-Id: I6223afef0f34d90170a691d7d5b1d9542c34c6b0
2018-12-03 16:52:11 +01:00
Oliver Smith 7c0b70a94e build manuals moved here from osmo-gsm-manuals.git
Moved to doc/manuals/, with full commit history, in preceding merge commit.
Now incorporate in the build system.

Build with:

$ autoreconf -fi
$ ./configure --enable-manuals
$ make

Shared files from osmo-gsm-manuals.git are found automatically if
- the repository is checked out in ../osmo-gsm-manuals; or
- if it osmo-gsm-manuals was installed with "make install"; or
- OSMO_GSM_MANUALS_DIR is set.

Related: OS#3385
Change-Id: I504f05a49721f2dfe105b6c5fd1995c4e7a0be9c
2018-11-27 18:07:37 +01:00
Neels Hofmeyr ca6a8495e1 Merge history from osmo-gsm-manuals.git
Change-Id: Ibbc4f41f7672159d8596ceb84b60e5c849b98074
2018-11-27 18:07:16 +01:00
Neels Hofmeyr c0a2196f91 mgw: update vty reference
Change-Id: Ib30ea8b02f8a950648b85e7ebc96a40ba5a36b34
2018-11-27 18:07:00 +01:00
Neels Hofmeyr da026abc27 OsmoMGW: document the 'X-Osmo-IGN' MGCP extension
See also Ia6fe5ead4b601931c1bf41b29fc1b237aac37d2c in osmo-mgw.git, which
changes the initial single-character implementation to match this specification
of string tokens separated by spaces.

Change-Id: If15a88c3b5b40fd1d24ad0f94f3231f678669ab1
2018-11-27 18:07:00 +01:00
Daniel Willmann 27780313ac Add initial OsmoMGW manual
Change-Id: I1b4ff96309d280c6a63105a6e06a82ec2e7b6908
2018-11-27 18:07:00 +01:00
Daniel Willmann e5ed946bdb mgw: Add new VTY reference
Change-Id: Ic8ca983f3358aae9362fb21ff3a111f9c4f3935b
2018-11-27 18:07:00 +01:00
Harald Welte c319b79baa vty-ref: Update URI of docbook 5.0 schema
... to match the /etc/xml/catalog file on debian (no "www" in hostname)

Change-Id: Id9f3579c7f2bc3af13fe30b5268f249b6f59ed0d
2018-11-27 18:07:00 +01:00
Neels Hofmeyr 2818db8b33 OsmoMGW: update VTY reference
This is the first update since the libosmocore changes to the 'show
online-help' generated output. Hence the produced document now benefits from
the structural improvements:
- not repeating common commands for every node;
- using section names that match the VTY prompt.

Change-Id: I79804ec0e61cc19a679f079a083a5ea2ea3ee2de
2018-11-27 18:07:00 +01:00
Philipp Maier 0415de74b8 osmo-mgw: Add vty reference manual
add missing vty reference manual for osmo-mgw

Change-Id: If9d8cdcbbbf14b23e48af5b9ae1c56c2a38219a2
2018-11-27 18:07:00 +01:00
Neels Hofmeyr 4075b8805d Importing history from osmo-gsm-manuals.git
Change-Id: Ie9bf61a61d00a74cb327853f26dd1a7e1481fdfa
2018-11-27 18:05:58 +01:00
Stefan Sperling 8ab3fbbaf2 add DLCX command statistics to osmo-mgw
Add a counter group for DLCX commands. The group contains counters for
successful connection processing as well as various error conditions.
This provides a quick overview of DLCX failures on each trunk throughout
the lifetime of the osmo-mgw process.

The counters are displayed by 'show mgcp stats' and 'show rate-counters'

While here, rename MGCP_MDCX_FAIL_DEFERRED_BY_POLICY to
MGCP_MDCX_DEFERRED_BY_POLICY; we have decided that deferred connections
aren't failures, and this keeps names used by DLCX and MDCX in sync.

Also remove some allocation failure checks with OSMO_ASSERT(); such
checks aren't en vogue anymore.

Change-Id: Ie0dde2faf02fd68a69f986973d39b1bea367039b
Depends: I80d36181600901ae2e0f321dc02b5d54ddc94139I
Related: OS#2660
2018-11-27 14:58:21 +00:00
Neels Hofmeyr cc39218dce fix osmo-mgw -s; fixes osmo-mgw.service using -s
Even though osmo-mgw advertises the -s option, the getopt configuration lacks
-s and that option does not work. Thus the osmo-mgw.service file that uses -s
was unable to start.

Add 's' to the getopt configuration, fix -s and hence also fix the .service
file.

Change-Id: I6f298aef73eb3486d04706910e9fdbaaebaf2481
2018-11-25 22:43:16 +01:00
Philipp Maier 8dbc9ed408 mgcp_protocol: increase buffer space for codec name in LCO
The function that parses the LCO uses an internal buffer to store the
codec name that has been issued via LCO. This buffer is only 9 byte
long, this means an 8 character string can be stored. If a codec name
exceeds this limit it gets chopped. For example "GSM-HR-08" becomes
"GSM-HR-0", which may mess up the codec negotiation.

- Increase the buffer from 9 to 17 byte.

Change-Id: I17ce7acde1f23ab1394227d74214fe2a55cd2264
Related: OS#3673
2018-11-07 11:34:59 +00:00
Stefan Sperling ba25eab0fa add aggregated rtp connection stats to osmo-mgw
Add a counter group for aggregated RTP connection statistics.
This group contains RTP counters which aggregate values of the
ephemeral RTP counters maintained per connection (mgcp_conn).

This provides a global overview of RTP processing for each
trunk throughout the lifetime of the osmo-mgw process.

The counters are displayed by 'show mgcp stats' and 'show rate-counters'.

While here, fix a typo in an item of the mgcp_conn_rate_ctr_desc array:
"rtp:octets_rx" was displayed for outbound packes; now says "_tx".

Change-Id: I80d36181600901ae2e0f321dc02b5d54ddc94139
Related: OS#2660
2018-11-06 11:46:47 +01:00
Stefan Sperling aa823bf24b add MDCX command statistics to osmo-mgw
Add a counter group for MDCX commands. The group contains counters for
successful connection processing as well as various error conditions.
This provides a quick overview of MDCX failures on each trunk throughout
the lifetime of the osmo-mgw process.

The counters are displayed by 'show mgcp stats' and 'show rate-counters'.

Change-Id: I79c27425ba40c3a85edc6cd846cba325d847298c
Depends: Ia2004f8063f3a50b5d7a838ebe8a784a47fcc50d
Related: OS#2660
2018-10-29 23:18:16 +00:00
Stefan Sperling a714abfc91 add more mgcp crxc error counters
Add counters for error conditions which I overlooked in
commit 1e174875bf

Change-Id: Ia2004f8063f3a50b5d7a838ebe8a784a47fcc50d
Depends: If4f097c5e441914eaa24c7657813ebb3f9a49916
Related: OS#2660
2018-10-29 23:18:16 +00:00
Stefan Sperling 9270e91c09 use local variable for rate counters in handle_create_con()
Use a local variable to shorten the length of rate counter names.
Cosmetic only; no functional change.

Change-Id: If4f097c5e441914eaa24c7657813ebb3f9a49916
Related: OS#2660
2018-10-29 23:18:16 +00:00
Stefan Sperling b7974e2fa4 show RTP TX/RX stats in 'mgcp show stats' output
Make the 'mgcp show stats' VTY command display TX/RX counters
for an RTP stream. This command was already showing the counter
for dropped packets from the same counter group, so it seems
natural to display other relevant counters in the group as well.

Change-Id: I1313e64d7d8b49964f21fc8d213cba6c9fb6c7cf
Related: OS#2660
2018-10-29 13:22:00 +01:00
Stefan Sperling 1e174875bf add MGCP CRCX command statistics to osmo-mgw
Add a counter group for CRCX commands. The group contains counters for
successful connection processing as well as various error conditions.
This provides a quick overview of CRCX failures on each trunk throughout
the lifetime of the osmo-mgw process.

For example, after running the TTCN3 mgw test suite, the counters show
the following values:

OsmoMGW> show rate-counters
crxc statistics:
             crcx:success:         88 (0/s 88/m 0/h 0/d) CRCX command processed successfully.
          crcx:bad_action:          0 (0/s 0/m 0/h 0/d) bad action in CRCX command.
     crcx:unhandled_param:          1 (0/s 1/m 0/h 0/d) unhandled parameter in CRCX command.
      crcx:missing_callid:          1 (0/s 1/m 0/h 0/d) missing CallId in CRCX command.
        crcx:invalid_mode:          1 (0/s 1/m 0/h 0/d) connection invalid mode in CRCX command.
      crcx:limit_exceeded:          0 (0/s 0/m 0/h 0/d) limit of concurrent connections was reached.
       crcx:unkown_callid:          0 (0/s 0/m 0/h 0/d) unknown CallId in CRCX command.
     crcx:alloc_conn_fail:          0 (0/s 0/m 0/h 0/d) connection allocation failure.
 crcx:no_remote_conn_desc:          1 (0/s 1/m 0/h 0/d) no opposite end specified for connection.
   crcx:start_rtp_failure:          0 (0/s 0/m 0/h 0/d) failure to start RTP processing.
       crcx:conn_rejected:          0 (0/s 0/m 0/h 0/d) connection rejected by policy.
OsmoMGW>

These same counters are now also shown by 'show mgcp stats'
in the context of the trunk which they belong to.

With input from Philipp Maier.

Change-Id: Ida82fc340d5c66180e5fe9a0d195e9be6dc64c61
Related: OS#2660
2018-10-29 10:17:20 +00:00
Harald Welte c26b665c0c check_rtp_origin(): Avoid using memcmp for comparing integer types
in_addr consists only of s_addr, which is an integer type that
can be compared directly.  By avoiding memcmp() here we would have
been able to catch Coverity CID#188874 even without Coverity, and
make the code more compact...

Change-Id: Ic6105d39ae2fb4b301f87448b16763fe9f695621
2018-10-21 12:01:04 +02:00
Harald Welte 0479b2a15f check_rtp_origin(): Don't memcmp sockadd_in and in_addr
We were comparing 16 bytes (sockaddr_in) in memcmp() rather than using
four bytes (struct in_addr in mgcp conn end).

This is a good example why we should actually simply use the == (equals)
operator rather than using memcmp which treats everything as void.

Change-Id: Ic64256619ef893d625400e8b1b573ea2c629ed9c
Fixes: Coverity CID#188874
2018-10-21 11:56:05 +02:00
Pau Espin ff6606cacb osmux: Avoid processing further frames if conn not found
Other frames can come from known connections, so let's keep processing
each of them.

Change-Id: I09190140ba917dfada4b0952230b68e0f5f6d43d
2018-10-16 16:45:43 +02:00
Pau Espin 407b1f186d osmux.h: Document enum osmux_state
Port for openbsc 9ae32d0d0607f270f20239b8104e09ec20352301.
Change-Id: I28978fa505d259f144457f29af4ba615aeaac74c
2018-10-16 16:44:51 +02:00
Pau Espin de2a4d7c22 osmux: Improve checks around activating and using enabled osmux
* Refactor code to have unified checks on all paths activating Osmux.
* Improve checkings at activation time and add logging.
* Code now enforces endp osmux status to be enabled before processing
the frame through endp->osmux.out. Before, a delayed or bad pkt could
arrive and be processed by an endp with osmux not enabled, using
endp->osmux.out that was not initialized and ended up crashing:
libosmo-netif/src/osmux.c:281:3: runtime error: member access within null pointer of type 'struct msgb'

This could also happen if a BSC started sending or we received (non legacy dummy) osmux
frames before we received the BSC CRCX ACK agreeing on osmux negotiation
and switching to ACTIVATING state.

Related: SYS#4350

Port from openbsc 4a2cc9eb0a0f9424c16b26fcb757483a39d67482.
Includes fixup from openbsc I438349bffaa46a10ad8983090a4b17aed7e00d82.
Change-Id: Iac11e447ec0d76e4e74ec982a6e3f63b35548978
2018-10-16 16:44:49 +02:00
Pau Espin 48aff62341 osmux: allow enabling osmux only on correct activating state
State ACTIVATING is set once negotiation between the 2 parts went
successfuly.

Port from openbsc 96bd7b075a59eb051079152241b127ca944b0781.
Change-Id: Ic56eda1251be41369d869e687a1cf955df2c6d61
2018-10-16 16:43:42 +02:00
Pau Espin 852ba86949 osmux: Make func handling dummy frames independent of endp type
Port from openbsc 8f321179747f64819d940d72d0212192f69284ca.
Change-Id: I3e16217737fd5ffb95c166c5f7344492cb6a6263
2018-10-16 16:43:34 +02:00
Pau Espin 662fa421c6 osmux: Move parse_cid of legacy dummy frames to own function
Backport from openbsc b010f869c915016b7fa97a26621582cd89de96b0.
Change-Id: I5766165985fbfcecc63d45b9e229322bc8cedf52
2018-10-16 15:54:40 +02:00
Pau Espin d14163e74f osmux: Don't process regular osmux frames if disabled by cfg
Prior to this commit, the check was only done on legacy dummy frames.

Port from openbsc a42d4584fd01c9cd1021fab609bdaaafe859c13a.
Change-Id: I5b6606d72a9f5ae593a8e3ab5fbbe7e1e5a0ae11
2018-10-16 15:49:02 +02:00
Pau Espin 11b4810142 osmux_send_dummy: Avoid logging incorrectly and sending if osmux not enabled
Port from openbsc 37a0307b6193c9b108cfd1aa2a88517a8b5cb907.
Change-Id: Iabc84cb482a425d4a6c2bb08c20b2e02a5a86b36
2018-10-16 15:45:59 +02:00
Pau Espin 9ecceb651b mgcp: Log endpoint nr consistently as hex
Port from openbsc 078905a0603c91b227854abfa01c9e24143e39a1.
Change-Id: Idcb40e6fd561b24e111afe7463f44c43c530fac5
2018-10-16 15:36:08 +02:00
Pau Espin 426a9d9103 osmux: Avoid initing output without enabling osmux
Otherwise we end up in a weird state where we have timers set up but
osmux is still flagged as not enabled.

Cherry-picked from openbsc cad739d2386640a68c24e3d470ddacdcaf377561.
Change-Id: I0a334842463d311bc80a980e60fb702a0a9ad610
2018-10-16 15:31:49 +02:00
Pau Espin 17bf603222 mgcp_osmux: Use define to calculate rtp_ssrc_winlen
Since that define is already used to allocate size of osmux_cid_bitmap,
let's use it here too instead of hardcoding its value.

Change-Id: Ib2e4febee8bc6bcc035ad0a65c5c1eb94ef5e6fb
2018-09-17 13:38:46 +02:00
Pau Espin bcd52e5724 mgcp: Fix osmux_cid_bitmap static array size calculation
Right now it's not a big issue since OSMUX_CID_MAX is 255, so 255+1 is
256 which fits array boundaries correctly (multiple of 8). However, if
for example OSMUX_CID_MAX was modified to be 12, 12+1/8 = 1, so we'd
have an undesired memory access when accessing last 4 CIDs.

A +1 should be kept on top, because OSMUX_CID_MAX specified the maximum
number used by a CID, that is (0,OSMUX_CID_MAX), and as a result we
require OSMUX_CID_MAX+1 slots.

Change-Id: Iaf9b93712dbd2a862b01e70dd8e11893bfa6b24c
2018-09-17 13:36:36 +02:00
Pau Espin 956242dcec Install sample cfg file to /etc/osmocom
Change-Id: I6926e989a130086f4b6c8277407377a4063f452f
2018-09-12 20:27:00 +02:00
Pau Espin e686675f7d Install systemd services with autotools
Change-Id: I7e4dae6b8c1685e8a673c58a843c41fa0af1b35c
2018-09-12 14:14:55 +02:00
Pau Espin 4ca0b0d1fa debian: Remove dangling symlink to osmo-bsc-mgcp.service
osmo-bsc-mgcp was removed recently from osmo-mgw.git as it belongs to
openbsc.git.
This symlink was a leftover from that time.

Change-Id: Ifdcb266efd821eac9d90aff186400f85751e8f42
2018-09-11 03:20:34 +00:00
Neels Hofmeyr efd645e5a8 log: avoid logging early media as error
When the peer address is still 0.0.0.0, the endpoint is not yet configured.
This commonly happens before bridging a call is complete, so instead of ERROR
logging about an invalid packet, rather INFO-log this as "early media".

Related: OS#3539
Change-Id: I335f6453bd599be76eef08fcf9e5daed071e5b6d
2018-09-10 13:37:26 +02:00
Neels Hofmeyr f0504e86b3 comment: indicate struct type for mgcp_endpoint.conns
Change-Id: Ia65359c22da3e7b28e3f23b36446ca434ca0be8c
2018-09-07 04:14:51 +02:00
Neels Hofmeyr e28b673fba cosmetic: mgcp_test: fix get_conn_id_from_response()
This function is implemented in such a weird way that I couldn't stop myself
from rewriting it.

Change-Id: Ib9b13d7b0e64f8ae25a7b69cbb385e7fad33d02b
2018-09-07 04:14:51 +02:00
Neels Hofmeyr a77eade744 mgcp_conn_get(): match conn Id ('I:') despite leading zeros
The Connection Identifier is defined as a hex string, so clients may send the
ID back with or without leading zeros. Ignore all leading zeros when comparing.

A specific SCCPlite MSC is observed to DLCX with Connection Identifier with
leading zeros removed, which would mismatch pefore this patch.

Extend test_conn_id_matching() in mgcp_test.c to include leading zero tests.

Now, mgcp_conn_get() would match a valid id with *any* amount of leading zeros,
even if that far surpasses the permitted conn id length. Valid lengths of
incoming conn ids should be and is checked elsewhere.

Related: OS#3509
Change-Id: If55a64a2da47b6eff035711c08e4114d70dbec91
2018-09-07 04:14:51 +02:00
Neels Hofmeyr 6531726a02 mgcp_conn_get(): compare conn Id ('I:') case insensitively
The Connection Identifier is defined as a hex string, so clients may send the
ID back in lower case. Convert to upper case before comparing.

A specific SCCPlite MSC is observed to DLCX with Connection Identifier in lower
case, which would mismatch pefore this patch.

Add test_conn_id_matching() in mgcp_test.c to verify case insensitivity.

Cosmetic: use strcmp(), not strncmp(). In the presence of a terminating nul as
we can assume here, this makes no functional difference, but it clarifies the
code.

Related: OS#3508
Depends: Ib0ee1206b9f31d7ba25c31f8008119ac55440797 (libosmocore)
Change-Id: I8e52278c3abe9e9c8c848c2b1538bce443f68a43
2018-09-07 04:14:40 +02:00
Pau Espin 31b4729f27 Remove libosmo-legacy-mgcp and osmo-bsc-mgcp
They are only used by openbsc.git programs and belong there.

Change-Id: Id31bef052d3f9b8aada1824d6f7f995ebd39bbfd
2018-09-06 20:39:53 +00:00
Neels Hofmeyr a729db62a9 generate shorter 'I:' conn IDs
Reduce the number of hex chars generated as Connection Identifier from 32 to 8.

According to RFC3435 2.1.3.2 "Names of Connections", the maximum length is
indeed 32 characters, but there isn't really a benefit of using IDs of that
size. That, and:

A specific SCCPlite MSC is seen to be able to store conn IDs of up to 8 hex
characters of length. If given more than that, it will later send 'ffffffff' as
ID, e.g. in the DLCX message, causing mismatches and rejected DLCX.

Conn IDs need to be unique only within the context of one endpoint, so
producing 32 characters of ID is far beyond overkill, especially if we
currently expect exactly two IDs per endpoint.

Notice that the maximum length of conn ID that can be handled by the message
parsing and composition doesn't change, only the length that an osmo-mgw will
generate upon CRCX does.

Related: OS#3507
Change-Id: Ia290c22a91fca0e5aa44515fca6df00064aff100
2018-09-03 23:12:23 +02:00
Neels Hofmeyr 5336f57f05 fix mgcp_verify_ci(): off-by-one in max len check
MGCP_CONN_ID_MAXLEN actually includes a terminating nul, so we need to compare
strlen() against MGCP_CONN_ID_MAXLEN-1.

Log the length if it is too long.

Add MDCX_TOO_LONG_CI test to mgcp_test.c, testing a conn id of 33 characters.
Before this patch, the test returns error code 515 meaning "not found", while
now it returns 510 meaning "invalid", showing the off-by-one. Same is
illustrated by the error log ("not found" before, "too long" now), but the
error log is not verified by mgcp_test.c.

Change-Id: I8d6cc96be252bb486e94f343a8c7cae641ff9429
2018-09-03 23:08:08 +02:00
Neels Hofmeyr eb72ff058f mgcp_verify_ci(): return meaningful error codes
Instead of just -1, return RFC3435 error codes that can be used to compose a
FAIL message response. Note that the return value stays compatible in that it
returns 0 on a valid Connection Identifier, nonzero otherwise.

The idea is to be able to distinguish between "Conn ID not found" and "Conn ID
invalid" in mgcp_test.c's expected output, in upcoming change
I8d6cc96be252bb486e94f343a8c7cae641ff9429.

Change-Id: Ifc17f2893cc4b9a865f3ffcb9888bbf1039337a6
2018-09-03 23:06:29 +02:00
Neels Hofmeyr 8a91d2c04e doc: fix mgcp_verify_ci() return val doc
Match the '\returns' doc to the actual implementation.

Change-Id: I6f89abd56ffcda8ba0276db1bc3381fa372e35a4
2018-09-03 23:05:26 +02:00
Neels Hofmeyr 55e0dcf254 mgcp_common: rename to MGCP_CONN_ID_MAXLEN
So far, MGCP_CONN_ID_LENGTH was often used as exactly the length of the
Connection Identifier. To indicate this length as a maximum, introduce the
MGCP_CONN_ID_MAXLEN and use it everywhere. Keep the old name as an alias.

Change-Id: I1117003c7614e98535d5c201d002e459c01bdc3f
2018-09-03 22:26:14 +02:00
Neels Hofmeyr 23e7bf1c00 mgcp_client: error on too long conn id
Instead of just silently truncating the conn ID if it is too long, rather
verify its length and return an error where applicable.

Adjust expected test output.

Change-Id: If2a1aab1f13e771a6705c430e3c75bd42477a23b
2018-09-03 21:32:37 +02:00
Neels Hofmeyr 10d487e13f mgcp_client_test: test long conn_id
Add a full length (32 characters according to spec) conn ID in a CRCX response,
as well as a too long one.

The too long one is currently silently truncated, a subsequent patch will
improve on that (If2a1aab1f13e771a6705c430e3c75bd42477a23b).

Change-Id: I5f2d52f086ea2d330fcce88a176488ace972bf79
2018-09-03 21:31:34 +02:00
Neels Hofmeyr 40f5033cf9 mgcp_client_test: also verify received conn_id
Include the parsed conn_id in the response cb printout to verify them in
mgcp_client_test.ok.

Change-Id: I6b9b18d4d0867febd75a4d29f8a2fcdf0553ae4c
2018-09-03 21:14:49 +02:00
Neels Hofmeyr b1bb1fa187 mgcp_client_test: use "\r\n\r\n" instead of "\n\n"
The separator between MGCP and SDP section is typically "\r\n\r\n". For some
reason the test so far used "\n\n" instead, rather use the standard separator.

Change-Id: I41c73722e5fae00663bcf96de0b57b7155809a06
2018-09-03 21:13:19 +02:00
Neels Hofmeyr 1d121483f6 mgcp_client_test: cosmetically re-arrange reply_to() args
I want to test arbitrary length Conn IDs ('I:'), and hence don't want to pass
the conn_id as int, but rather just include it in the message string. Prepare
for that by eliminating the extra conn_id arg and just pass a params string.

Change-Id: Ib2e718dda3aa1f6e9979dee823d973dd002e2318
2018-09-03 21:13:19 +02:00
Harald Welte 124441af1f debian/rules: Don't overwrite .tarball-version
The .tarball-version file should contain the *source version* uniquely
identifying the git commit, and not the Debian package name.

With https://gerrit.osmocom.org/#/c/osmo-ci/+/10343/ there is a correct
.tarball-version file in the .tar.xz of the nightly source packages.

Change-Id: I4bf7b6124c747a0cff5562187a099c33525e109e
Related: OS#3449
2018-09-03 14:57:14 +02:00
Neels Hofmeyr b861db97ea mgcp_test: fix get_conn_id_from_response() CI length
This function is set on conn ID length of 32 characters. Make it detect a
shorter length also when parsing 'o=-' headers. Before, this failed to
recognize a space as the end of the conn ID, now sees any non-hex char as end.

Related: OS#3507
Change-Id: I762c273bac172acb6d0aae6ea6267603ab654cbf
2018-08-30 14:23:12 +00:00
Neels Hofmeyr 08e07046f9 mgcp_test: fix log of conn_id presence
Flip logic to accurately log whether an 'I:' is included, instead of logging
the opposite.

Note that it isn't possible to log the actual conn ID, because they are random
and differ in every test run, which would collide with the fixed expected
output file mgcp_test.ok.

Change-Id: Idcd731b9daf618b97d8f7e6a776266071cd29e08
2018-08-30 14:23:12 +00:00
Philipp Maier a5e0cf09a6 mgcp_client_fsm: switch to MGCP_CONN_RECV_SEND in add_audio()
The change Ie51cc86e90ffeca5b66bcb8f6db0d389241abe57 has replaced the
functions make_crcx_msg_bind() and make_crcx_msg_bind_connect() with
make_crcx_msg() and add_audio(). When a bidirectional connection is
needed, the user calls add_audio() to add the remaining connection
details. Unfortunately add_audio() leaves the conn_mode struct member
unchanged. Which means the connection is still at MGCP_CONN_RECV_ONLY,
which will instruct the MGW not to forward any of the received packets.

- Make sure that conn_mode is set to MGCP_CONN_RECV_SEND when
  add_audio() is called.

Change-Id: Id12de37797de5af5cc447642d2fbb1af7de680df
Closes: OS#3511
2018-08-29 14:44:52 +02:00
Neels Hofmeyr f2388eab71 X-Osmo-IGN: rather parse items by token, not char
Adjust the X-Osmo-IGN parsing to use string tokens instead of parsing single
characters.

Reconsidering the first implementation as a poor choice, rather specify the
format of X-Osmo-IGN as any-length string tokens separated by spaces, which is
more flexible and more future proof.

See also osmo-gsm-manuals If15a88c3b5b40fd1d24ad0f94f3231f678669ab1 which
defines the X-Osmo-IGN format as string tokens, matching this patch.

In mgcp_test, add an unknown X-Osmo-IGN item. Though the output is not checked
by the testsuite.at, running manually shows the error log about the unkown
X-Osmo-IGN item.

Change-Id: Ia6fe5ead4b601931c1bf41b29fc1b237aac37d2c
2018-08-28 19:38:22 +00:00
Stefan Sperling 120865833c add VTY commands which show specific mgcp endpoints
Add VTY commands "show mgcp endpoint NAME" and
"show mgcp trunk <0-64> endpoint NAME" which
show information about specific endpoints.

Change-Id: I5330e697ec34bf215de91d44209048a8dc226d51
Related: OS#2660
2018-08-28 15:33:03 +02:00
Neels Hofmeyr e6d8e91b3a add X-Osmo-IGN MGCP header to ignore CallID
The format is

  CRCX ...
  C: ...
  M: ...
  X-Osmo-IGN: C

So far the only ignorable element is C, i.e. the CallID. Any other items may be
added in the future.

(I initially intended to also add '@' to ignore the endpoint name's domain
part, but in the osmo-mgw code base the domain part is verified long before any
additional headers are even parsed, so sparing that refactoring for now.)

The intention is that osmo-bsc will issue "X-Osmo-IGN: C" for all SCCPlite
calls, because we are unable to retrieve the CallID that the MSC sends to
osmo-mgw for the network side of the endpoint.

Testing with a specific SCCPlite MSC, I actually observe that all CallIDs are
1, even for concurrent calls. So, an alternative hacky solution would have been
to always pass CallID == 1 for SCCPlite connections from osmo-bsc.

Related: I257ad574d8060fef19afce9798bd8a5a7f8c99fe (osmo-bsc)
Change-Id: Id7ae275ffde8ea9389270cfe3db087ee8db00b51
2018-08-25 16:47:44 +02:00
Neels Hofmeyr 475f868b7f cosmetic: drop code dup in mgcp_client_fsm.c CRCX
Both make_crcx_msg_bind() and make_crcx_msg_bind_connect() were mostly
identical. Rather, compose the CRCX bits in one common function and just add
the audio bits in another.

Prepares cosmetically for adding X-Osmo-IGN header.

Change-Id: Ie51cc86e90ffeca5b66bcb8f6db0d389241abe57
2018-08-25 14:23:10 +00:00
Neels Hofmeyr 0063ca2fb0 fix 3G hack: allow any IP for loopback and 0.0.0.0
HACK: for IuUP, we want to reply with an IuUP Initialization ACK upon the first RTP
message received. We currently hackishly accomplish that by putting the endpoint in
loopback mode and patching over the looped back RTP message to make it look like an
ack. We don't know the femto cell's IP address and port until the RAB Assignment
Response is received, but the nano3G expects an IuUP Initialization Ack before it even
sends the RAB Assignment Response. Hence, if the remote address is 0.0.0.0 and the
MGCP port is in loopback mode, allow looping back the packet to any source.

None of these are anything near nice, during call setup using a 3G femto cell,
we still lack a proper IuUP handling. See OS#2459, OS#1937. This is merely a
temporary hack to maintain 3G voice usability in a quick and dirty way.

Related: OS#3411
Change-Id: Ib25e6261855eae8ddb8d1c0b8838cc3e30332cf1
2018-08-24 10:37:03 +00:00
Neels Hofmeyr 610fda6108 cosmetic: log: fix "CallIDs does not match"
Change-Id: I16f3bf1312f913b7a7f0d9ff5c42efa645c6a5b3
2018-08-21 00:03:48 +02:00
Neels Hofmeyr 352eed09ae interpret domain '*' as 'allow any domain'
Make the 'domain NAME' vty doc more descriptive, and add the hint that '*'
means any domain.

In check_domain_name(), exit early in success if the configured domain name is
'*'.

(Do not implement other wildcard functionality for partial matches or the
like, just the single '*'.)

Related: OS#3490
Change-Id: Ie0220c88d2f5cee15f2a90390b3c4590ac61d5eb
2018-08-20 23:59:32 +02:00
Neels Hofmeyr 0a89e92a5e fix handling of "Wrong domain name" error
If no endpoint was found, assert that the cause code indicates error, so that
the remaining code path doesn't assume finding an endpoint was successful.

Also fix find_endpoint() to return an error cause (not 0) in case it finds the
domain name to be wrong.

After this, the error described in OS#3488 simply results in a CRCX failure,
not in a program crash.

Related: OS#3488
Change-Id: I87e2d76c22603d6fef89907c3cf8f7965abf35a0
2018-08-20 22:39:53 +02:00
Pau Espin dde80f3f61 vty: Fix typo writing bts-jitter-buffer-delay-{min,max}
Change-Id: I15ec1bd9e8d2241d29ef64cefe7ad4879ccdf898
2018-08-16 15:10:42 +02:00
Philipp Maier 9a7ccc3746 mgcp_client: check local port only once
When the user has set a local port for the mgcp client we want the
client to exit if this port is already occupied. If no port is set the
IETF default port is configured automatically. When we find this port
occupied we try up to 100 times the next port to find a useable port.

Since the for loop that controls the attempts always sets the port
config it uses for its checks it will mistakenly assume that the user
has set a port on the second cycle.

- Make sure we only check for the default port in the first cycle

Change-Id: Ic1fd1018d68fcac94961321615bfdd726465532d
2018-08-09 11:48:13 +02:00
Philipp Maier 910189d0a1 mgcp_sdp: restructure mgcp_write_response_sdp() (audio)
The function mgcp_write_response_sdp() is responsible to write the
audio port and the list with the supported payload type numbers to
the sdp response. At the moment it can only write exactly one payload
type number to the response, but in the future we may want to write
several payload type numbers to the response. Lets add a function
for that so that now.

- add add_audio() helper function to add multiple payload type
  numbers, but keep the functionality as it is for now

Change-Id: I662c725f697b2ffb1e3ad4671a445f943cd79b63
Related: OS#3442
2018-08-05 07:17:17 +00:00
Philipp Maier 8482e8374c mgcp_sdp: restructure mgcp_write_response_sdp() (rtpmap)
The function mgcp_write_response_sdp() generates the rtpmap lines in the
sdp response. Since we will likely support multiple codecs we will need
to generate several rtpmap lines. Therefore it makes sense to split up
that part in a separate function without altering the overall
functionality (yet)

- add static function add_rtpmap() to generate the rtpmap.

Change-Id: I520e2d40fe6294c88bae63dfcbc5238ef98101e2
Related: OS#3442
2018-08-05 07:17:17 +00:00
Philipp Maier fee4fa9492 Cosmetic: remove misplaced line break
Change-Id: I7eea5454cb0567a4a162fb9796f889b2daa21af7
2018-08-03 12:24:20 +02:00
Philipp Maier 4dba769577 network: check packets before further processing
When we receive a packet, we do not really check the contents. However,
we should at least do some basic checks.

- Check for short RTP packets
- Check if the length field of RTCP packets seems plausible
- Check if the packet type of RTCP packets makes sense (IANA)

Change-Id: Id47b9eee2164c542e6b673db24974859dd0a7618
Related: OS#3444
2018-08-03 12:20:52 +02:00
Philipp Maier da895b1151 network: do not patch PT of RTCP packets
At the moment all packets that are sent with mgcp_send are fed into
mgcp_patch_pt(). This functions corrects the payload type so that it
matches the codec configuration on the egress side. However, this
functions is only to be used with RTP packets and must not be used on
RTCP packets, which we currently do because we do not check if the
packet is RTCP or RTP.

- Check if the packet is RTP before running mgcp_patch_pt()

Change-Id: I55b8aa830e4e23f991373470bd04d4db12241c56
Related: OS#3444
2018-08-03 12:20:01 +02:00
Philipp Maier a74c0ea2db mgcp_test: release endpoints after use
The test function test_multilple_codec() in mgcp_test.c creates a
lot of connections, but it never releases them. Just freeing the
cfg object is not enough since the UDP ports stay open and this
may interfere with other tests that also create connections
(port numbers).

- Make sure all endpoints are released when test_multilple_codec()
  is done.

Change-Id: Ic13b4368162149ec36c93f4188fa4c71166e08d5
2018-08-02 12:01:31 +00:00
Philipp Maier 6a26c16eb0 mgcp_client: increment local port number when port is in use
The IETF has designated port 2727 for call agents (clients). This
works as long as only one call agent is running. As soon as two
call agents (e.g. osmo-bsc and osmo-msc) run on the same machine.
The port numbers will collide.

To avoid such a situation we will first try the IETF port and if
we fail to use it we increment the port number until we found a
usable port. However, we should only do this if the user has not
configured a non standard port. (The rationale behind this is that
if there is a non standard port configured the choice must have
been made conciously by the user and therefor we should fail hard
so that the user gets aware of the problem.)

Change-Id: Iaa5f41fdb43ec6bf4feaefa174fd82622e37d4d0
Related: OS#2874
2018-08-02 12:38:06 +02:00
Philipp Maier af8e00ffe8 mgcp_client: use IETF source port as for MGCP
At the moment the mgcp client uses an arbitrary port as sourceport to
exchange MGCP messages with the MGW. However, IETF has designated a
specific port as sourceport for MGCP clients (Call agents), which is
2727. See also RFC3435, capter 3.5 Transmission over UDP.

- Change MGCP_CLIENT_LOCAL_PORT_DEFAULT from 0 to 2727

Change-Id: I96de84df3a3bf623d98b057ec3f3f621a3330a8a
Closes:	OS#2874
2018-08-01 16:37:12 +02:00
Philipp Maier 6931f9a7a4 mgcp_network: translate payload type numbers in RTP packets
Since no transcoding is in place osmo-mgw forwards the incoming rtp
packets as they are (there may be minor modifications of the header) from
an ingress connection to an egress connection.

This works without problems as long as both connections use the same
payload type. For IANA defined fixed payload type numbers this is
usually the case, but for dynemic payload type numbers both ends may set
up the same codecs but with different payload type numbers.

When different payload type numbers are set up, and the packet is passed
through without modification, it will have the wrong payload type when
it is sent. The receiving end may then toss the packet since it expects
packets with the payload type it has configured.

The machanism, which is introduced with this patch looks up actual codec
inside the struct data of the ingress connection and then looks for the
matching codec in the struct data of the egress connection. When it
finds the codec there it looks up the payload type of this codec. The
header of the RTP packet is then patched with the correct payoad type.

- Add function mgcp_codec_pt_translate() to look up the payload type
- Add unit-test for function mgcp_codec_pt_translate()
- Add payload type translation to mgcp_network.c

Change-Id: I3a874e59fa07bcc2a67c376cafa197360036f539
Related: OS#2728
Related: OS#3384
2018-07-31 17:18:14 +00:00
Philipp Maier 544448abea mgcp_client_fsm: allow ptmap in mgcp_client_fsm as well
The regular version of the mgcp_client supports the configuration of of
custom payload types. In case some corner cases require a specific
dynamic paylod type number that is not according to 3GPP standards has
to be used the user can override the standard settings. However the fsm
based variant of the mgcp_client does not have that feature but it
should have it as well.

- add struct members for ptmap config.
- pass configuration values down to the underlying magcp client.

Change-Id: If176a3719dd9e888da16196d5fc0bdb53cc2a5f2
Related: OS#2728
Related: OS#3384
2018-07-31 17:18:14 +00:00
Pau Espin e547bdd1ce configure: Find correct libgsm's gsm.h header
Some distributions (archlinux) or versions of libgsm install gsm.h in
/usr/include/gsm/gsm.h

Since libgsm doesn't come with a pkfconfig, let's first check if gsm.h
and take the correct path in the build setup.

Change-Id: I07d3c03903e0d4bb80e843c7ed917a27b791ea53
2018-07-28 02:48:04 +02:00
Pau Espin d1562a7766 gitignore: Filter *.pc
Change-Id: I1e4e9b7342b23b4ef460801d61b4dd9c2fdc6dab
2018-07-27 19:23:34 +02:00
Pau Espin 304b3eb328 Bump version: 1.3.0.34-9cd52-dirty → 1.4.0
Change-Id: Ice736ca8016be5ed000c30014b955f4e0f77cb4e
2018-07-27 19:05:23 +02:00
Daniel Willmann 9cd5233609 git-version-gen: Don't check for .git directory
This check is not in all our repos that use git-version-gen. Indeed it
seems to be a leftover of openbsc where I think it wanted to ensure
being called in the openbsc subfolder or something? libosmocore e.g.
doesn't have it.

In any case .git being a directory is not always true (if using git
worktree) so remove this check.

Change-Id: I83b84099c34d593a8a384f001a8131c2a8085606
2018-07-24 18:06:54 +02:00
Neels Hofmeyr 35a382968c IuUP hack: make RTP patching less general
We currently still patch over an RTP message to make it look like an IuUP
Initialization Ack specifically for the ip.access nano3G femto cell.

Be more specific about it:

- only patch over RTP in 'loopback' mode. osmo-msc specifically leaves the
  endpoint in loopback mode for this hack, so if we're not in 'loopback', then
  this hack is out of place.

- only patch over RTP if the header indicates an IuUP Initialization (check for
  0xe4 byte).

Change-Id: Ia9ec4debc138b34f6ca6a871a8778eafa6c0ba21
2018-07-23 18:32:23 +02:00
Neels Hofmeyr 7066af825a cosmetic: mgcp_network.c: merge one LOGPC to its preceding LOGP
Change-Id: I4dde8a060ec77e1234a373d7501c7082ae4c5028
2018-07-23 18:32:23 +02:00
Philipp Maier acc10353fe protocol: prevent unnecessary null pointer deref
The function setup_rtp_processing() in mgcp_protocol.c executes a
function pointer setup_rtp_processing_cb(). The function pointer
gets two struct mgcp_rtp_end pointers as parameter. To get those
parameters it has to dereference them from struct mgcp_conn_rtp
pointers. The variable conn_src is such a struct pointer and there
are conditions where this pointer may be NULL. The function at the
function pointer should get the conn pointers directly instead of
the dereferenced end (rtp) pointers. This also gives additional
flexibility to the implementation behind the function pointer,
which is not yet defined (the function pointer points always to
a stub function since we donot support transcoding yet.

- give conn pointers directly to setup_rtp_processing_cb() insed
  of dereferencing conn_src->end

Change-Id: Id46e9bfba88613387026639eb4957221cce6820a
Closes OS#3406
2018-07-19 18:15:23 +02:00
Philipp Maier bca0ef6cd9 stat+vty: fix printing of rate counter values
When creating the mgcp statistics (DLCX) and also when printing
values in the VTY. The printf placeholder %lu is used. However,
this is not portable when the same code is compiled on a machine
with different integer size (e.g. armv7).

- Use PRIu64 when printing ->current value of the rate counters

Change-Id: Ifb8944cec83868845f74ad84551eb090f812daf8
2018-07-09 17:24:55 +02:00
Philipp Maier cede2a4b7c stats: replace packet statistic counters with libosmocore rate counters
In struct mgcp_rtp_end one finds unsigned int counters. Those should
be replaced with libosmocore rate counters

- replace packets_rx, octets_rx, packets_tx, octets_tx and
  dropped_packets with libosmocore rate counters.

Change-Id: I47c5c9006df5044e59ddebb895e62adb849d72d5
Related: OS#2517
2018-07-05 15:55:19 +02:00
Philipp Maier 337209a6ea mgcp_internal: remove unused struct member
The struct member rtp_process_data in struct mgcp_rtp_end is
unused and should be removed

- remove rtp_process_data

Change-Id: I3a66d159ce32359621ff2e772ee3421340b78cd5
2018-07-03 09:41:04 +02:00
Pau Espin 56e0443e1c gitignore: Add m4 scripts from m4 subdir
Change-Id: I8da2a55e84bcc24cc5af00dc089630a18105c625
2018-07-02 17:05:39 +02:00
Pau Espin b1a1b4000e debian: Package installed example doc files
Change-Id: I71afa4799e0b484879b96567acd004755a84027f
2018-07-02 17:05:20 +02:00
Neels Hofmeyr 8838c62fe9 cosmetic: fix doxygen comment markers
There has obviously been a misunderstanding on how the doxygen comments work.
A comment marked '<' is for placing a comment *after* a member, to point back
to the item before it, typically

  enum foo {
  	thing, /*!< this is a thing */
	a_bobby,
  }

It does not make sense to place these above the item they are describing.

We actually don't use doxygen in the osmo-mgw build, but if we have doxygen
syntax, we might as well have the correct one.

Change-Id: I9e8ea0e3bd5ae5fcc0a6fae8e26e11baa8f35e27
2018-06-26 00:05:54 +02:00
Philipp Maier 704c4f0adf client: add features to generate and parse codec information
The current implementation does not support any way to influence the
codec that is negotiated via SDP or LCO. The client statically
negotitates AMR on an invalid payload type number. Also we ignore
any codec information in the responses.

- Add struct members to allow setting of user defined codec information.
- Add struct members to retrieve parsed codec info from responses.
- Add code to generate codec information in SDP
- Add code to parse SDP codec info in MGCP responses

Change-Id: I78e72d41b73acfcb40599a0ff4823f17c3642059
Related: OS#2728
Related: OS#3334
2018-06-23 11:39:48 +00:00
Philipp Maier bc0346e080 mgw: clean up codec negotiation (sdp)
The codec negotiation via SDP is currently in a neglected state. Also
osmo-mgw does some kind of codec decision wile the SDP is parsed, the
result is information for one codec, even when there are multiple codecs
negotiated. This is problematic because we loose all information about
alternate codecs while we parse. This should be untangled and the
information should be presevered. Also we are not really capable
picking a default. Wehen we do not supply any codec information (not
even LCO), then we should pick a sane default codec.

- separate the codec decision from the sdp parser and concentrate
  codec related code in a separate c file
- add support for multiple codecs in one SDP negotiation
- do not initalize "magic" codec defaults during conn allocation
- do not allow invalid payload types, especially not 255. When
  someone tries to select an invalid payload type, do not fail
  hard, just pick a sane default.
- handle the codec decision in protocol.c, pick a sane default
  codec when no (valid) codec has been negotiated (no LCO, no SDP)

Change-Id: If730d022ba6bdb217ad4e20b3fbbd1114dbb4b8f
Closes: OS#2658
Related: OS#3114
Related: OS#2728
2018-06-23 11:39:44 +00:00
Neels Hofmeyr 5928dc9345 mgcp_client_fsm: improve error logging
Change-Id: I2feefaeefc2d71b64714585ef8137afbb4055b7e
2018-06-15 04:33:37 +02:00
Neels Hofmeyr 04da5e5e98 mgcp-client: add mgcp_conn_get_ci()
Return the CI string allocated by the MGW and sent back during CRCX ACK.

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

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

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

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

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

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

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

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

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

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

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

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

- use MGCP_CONN_RECV_ONLY instead of MGCP_CONN_RECV_LOOPBACK

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

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

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

- remove unnecessary circular inclusion

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

- remove unused alt_codec field

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

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

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

- correct API documentation

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

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

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

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

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

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

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

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

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

- Initalize out_stream and in_stream independently from each other

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

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

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

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

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

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

- rename mgcp_rtp_conn_reset() to mgcp_rtp_conn_init()

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

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

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

- rename mgcp_rtp_conn_reset() to mgcp_rtp_conn_init()

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

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

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

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

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

- coose a more conceise prefix

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

- Add proper FSM Event names

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

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

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

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

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

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

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

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

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

Forward-ported from openbsc e39e18992a3b966581f06fa632d6342643996aaa.

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

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

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

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

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

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

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

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

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

See also TTCN3 testcases:
MGCP_Test.TC_mdcx_wildcarded
MGCP_Test.TC_dlcx_wildcarded

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

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

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

- rename wildcarded_crcx to wildcarded_req

- ensure the flag is refreshed with every new request

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

- reject sendrecv or sendonly on half open connections

See also TTCN3 Test:
MGCP_Test.TC_crcx_early_bidir_mode

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

- Add missing \n

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

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

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

Change-Id: Iaef4ea6c6a2f24ac8b276966bda72d0b30f25cd5
Related: OS#2654
2018-02-05 10:32:42 +01:00
Philipp Maier dd0c522cd4 protocol: reject DLCX/CRCX/MDCX on unsupported parameters
When an unsupported MGCP parameter (e.g. N) is used, then this
parameter is ignored and the command execution continues. However,
an MGCP command that contains an unsupported parameter should
be rejected.

- Make sure that MGCP commands DLCX, CRCX and MDCX are rejected,
  when they contain unsupported parameters.

Change-Id: I8cd5987fc6befcd53a7c4916f77b1a24c904ba48
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
Philipp Maier 1355d7e4f7 cosmetic: rename mgcp_release_endp to mgcp_endp_release
In order to allow clean prefixes for future endpoint related
functions the "rlease" should be moved to the end of the
function name.

- rename mgcp_release_endp to mgcp_endp_release

Change-Id: I22e938e702f57ad76d38c9f4a1370b110ac1ba11
2018-02-05 10:32:42 +01:00
Philipp Maier fdd603c4c8 ep: move endpoint struct and define to mgcp_ep.h
The endpoint and the define that computes the endpoint number is
defined in mgcp_internal.h. Since we have a dedicated module for
endpoint related code it makes sense to move the endpoint related
parts there.

- move struct mgcp_endpoint to mgcp_ep.h

- move #define ENDPOINT_NUMBER(endp) to mgcp_ep.h

Change-Id: Ibae55e1859bd41e2d1918eda433418b4bf8365fe
2018-02-05 10:32:42 +01:00
Philipp Maier 1fc6999a77 client: use heap to store mgcp_response
The struct that holds the parsing results of the MGCP response is
allocated on the stack. However, it would make sense to allocate
the struct dynamically on the heap. This also would provide a
talloc context that is in reach on most places of the code.

- Allocate struct mgcp_response dynamically in mgcp_client_rx()

- Use struct mgcp_response as talloc context for temporary
  allocated memory while parsing the response.

Change-Id: I5099abe68b580c75b47bc797bf93f01084f0c4db
2018-02-05 10:32:42 +01:00
Harald Welte 220f487238 libosmo-mgcp-client is GPLv2+, not AGPLv3+
The client library should be usable to all GPLv2/v3/AGPLv2/v3 programs,
so like our general project practises, let's put it under
GPLv2-or-later.  I believe this was unintentional from the beginning.

Our general policy has been:
* libraries under GPLv2-or-later
* applications under AGPLv3-or-later

Change-Id: I29ed7edc510dba67d28b9247aecb4d6d5d25cc0c
2018-02-04 16:06:38 +00:00
Philipp Maier edc00f4ea7 cosmetic: move mgcp_release_endp() to mgcp_ep.c
- move mgcp_release_endp() to mgcp_ep.c since it is clearly
  an endpoint sicific function.

Change-Id: I0a65b6e906c52a9e7cd75c88c4cbe1bf473b866b
2018-02-02 15:59:16 +01:00
Philipp Maier a49e32a1ab msg: fix response code on exhausted endp resources
When all endpoints are seized and a call agent tries to allocate
another one, then 500 is returned as response code, which means
that the endpoint was not found. This does not match.

- Return 403 which is defined as "Insufficient resources available
  at this time"

Change-Id: Idf241b47e711e35e9f9b5a43f3cea5c0298ea30b
2018-02-01 18:50:48 +01:00
Philipp Maier dd4ede34ad protocol: on wildcarded CRCX return endpoint number as hex
When a wildcarded CRCX is done, then the endpoint number is
returned as unsigned integer (%u). This results into problems
with endpoint numbers higher than 9.

- Return endpoint identifier with the endpoint number in
  hexadecimal representation

Change-Id: I504f4658c193009347753b15256dbb46b32ad5a4
2018-02-01 17:55:50 +01:00
Philipp Maier 3aa815755d client: prohibit endpoint ids without @ character
The function mgcp_msg_gen() does only check if the user supplied
an endpoint name or not. The user may still supply an endpoint
name that does not contain the separator (@) character.

- Refuse to generate the message if the endpoint name does not
  contain any @ character.

Change-Id: I92dd1556e4a26b4bef8e1c8c57141552abf988ca
2018-01-31 17:39:06 +01:00
Philipp Maier 3261dc7540 client: do not accept endpoint ids without @ character in responses
At the moment the client does not check if the endpoint identifier
that is returned from the MGW actually contains an @ character.

- Check if the endpoint id in the response contains an @ character.

Change-Id: I6073419a4b6cdcd31880672564f0861cb4bd02f5
2018-01-31 17:39:06 +01:00
Philipp Maier 771b26a043 client: Do not accept endpoint ids with wildcards in responses
When the client gets a specific endpoint identifier (Z) in a
MGCP response it just accepts the identifier even when it is
not specific (contsins wildcard characters). In those cases,
the client should refuse to parse the response.

- Check for wildcards in endpoint identifiers and stop
  parsing when check is positive.

Change-Id: Ic94bd8c025b7b3eb006b639fecfd7282194e504a
2018-01-31 17:39:06 +01:00
Philipp Maier 36a81129ec cosmetic: remove spaces from pointer symbol
Change-Id: Id778181a40638bce15c6f085841c35c1895d2602
2018-01-31 17:39:06 +01:00
Philipp Maier a390d0ba52 protocol: check the packetization in local cx options
When the local connection options in an MDCX or CRCX request
are parsed, then the packetization interval is not checked.

- Check if the packetization is a multiple of 20ms

see also TTCN3 test: MGCP_Test.TC_crcx_unsupp_packet_intv

Change-Id: I02aaa3042f2a0e32eb4ec6b8753deab7082947a0
Related: OS#2654
2018-01-31 17:39:06 +01:00
Philipp Maier b759473d10 client: fix sdp parameter ordering
The parameter ordering of the client responses does not match the
ordering as proposed by by RFC2327, Chapter 6. SDP Specification

- reorder generated SDP parameters so that they match RFC2327

Change-Id: I63cac2ebc982ffead92703c22bf68c7aafa7936c
2018-01-31 16:58:37 +01:00
Philipp Maier c3cfae2cf8 protocol: fix missing carriage return
Some of the line breaks lack the \r character, which leads to an
inconsistancy. While our software and even wireshark does ignore
the problem, other third party implementations might reject those
messages.

- Add the missing \r characters to make the message format
  consistant.

Change-Id: I0cd80afae65accd3b4ddc5d82e5d30385879141c
2018-01-26 00:32:22 +00:00
Philipp Maier 3cbfb8a53c protocol: fix problem with line break and OSMUX
The SDP parameter block must be detached from the regular parameters
using an additional line break (empty line). At the moment this works
because the empty OSMOX variable is added and by this also adds a
line break. It breaks as soon as OSMUX is used again.

- Make clear that no OSMUX variable is added when OSMUX is not in
  use.

- Add the extra line break independently

Change-Id: I6261971040db527b96fe79676520ccd7794bd327
2018-01-26 00:32:18 +00:00
Philipp Maier 275ac97036 cosmetic: client: add doxygen comments
The client lacks doxygen apidoc comments

- Add missing doxygen apidoc comments

Change-Id: I0b8a0652e60f2b3d72ee1cedfa6e2d5547d88455
2018-01-26 00:32:14 +00:00
Philipp Maier abe8c897fd client: eliminate destructive head parsing
While parsing the head of an MGCP response the r->body buffer is
manipulated in order to NUL terminate the extracted comment filed.

- Use a static buffer to store and manipulate the comment field.

Change-Id: Ib273c13d6fe7ee042fb4e3b8ed46ac02602226f6
2018-01-26 00:32:09 +00:00
Philipp Maier e9d645b3b3 client: eliminate destructive parameter parsing
The function mgcp_response_parse_params() that is used to parse the
SDP parameters edits the content of the r->body.

- Create a local copy of r->body and work on this copy to keep
  the original r-body in its original state.

Change-Id: Ia475036f7f3802b1638e0511a5e9162fea1592eb
2018-01-26 00:32:04 +00:00
Philipp Maier 7f0966c13d mgcp: add prefix to virtual trunk
the virtual trunk is addressed without a prefix (just *@domain).

- reorganize find_endpoint() so that it accepts a prefix when
  addressing the virtual trunk.

- do no longer accept wildcarded CRCX requests without prefix
  (will not break anything, the feature of wildcarded CRCX is
  not in use yet)

- keep the old prefix-less method but print a warning that it is
  depreacted.

Change-Id: I2aac3ba0f1f3122dfbb3bf36f74198ecb2b21de5
2018-01-26 00:31:51 +00:00
Philipp Maier 55295f7b07 mgcp: permit wildcarded endpoint assignment (CRCX)
The mgcp protocol in general allows wildcarded endpoints on CRCX.
osmo-mgw does not support this feature yet.

- when the endpoint name contains a wildcard character, search
  a free endpoint automatically

- return the resulting endpoint name in the parameter section of
  the mgcp response

- add parsing support for the returned endpoint names

- Be more concious about the parameters that are returned with
  each response. Do not unnecessarily attach known parameters.
  Return the connection ID only on CRCX commands. Only return
  the endpoint ID on CRCX commands that are wildcarded.

Change-Id: Iebc95043569191b6f5fbc8fe266b13fcfcab2e48
related: OS#2631
2018-01-26 00:31:22 +00:00
Philipp Maier 9d25d7a2e6 client: add missing mandatory SDP fields
The mcgp message generator function mgcp_msg_gen() lacks support
for the mandatory SDP fields (v)ersion, (o)rigin, (s)ession and
(t)ime.

- Automatically generate the missing fields when SDP is
  generated.

Change-Id: I5fbc31a17e8ac10c7cc5dbc31357b61e8920aaa5
Related: OS#2837
2018-01-26 00:27:34 +00:00
Philipp Maier 490cbaa89e client: make callid in MDCX mandatory
An MDCX without call-id does not make much sense. The call-id is
an integral element of the MDCX message to ensure that the correct
call is modified.

- update the presence check bitmasks to mark the call-id field
  mandatory for MDCX requests

Change-Id: Id2bcc3a68139e0d935790bcea2ef91eaf6291aa3
2018-01-22 17:35:50 +01:00
Philipp Maier eb0bde09bb main: display mgcp ip/port
osmo-mgw does not display the IP/Port on which it is listening for
MGCP commands. However, this information can be very helpful when
working with multiple MGCP instances on one machine.

- print IP/Port on which we listen for MGCP commands on startup

Change-Id: Idf5e8b6a7344c4ebaf9b89940456a496b2c23334
2018-01-19 18:03:58 +00:00
Philipp Maier 3b12e1b011 client: do not insist on \n\n when parsing MGCP messages
The current implementation of mgcp_client.c requires MGCP
paragraphs to be separated wit a \n\n sequence. However,
when the client is used with servers other than osmo-mgcp,
the parapgraph may be formatted differently.

Also allow \n\r\n\r and \r\n\r\n as separator

Change-Id: Ie209fb71499e011e52f58575c6af118de2fdee88
2018-01-19 18:03:38 +00:00
Philipp Maier 2138779559 cosmetic: protocol: remove unnecessary nul termination
Adding a NUL manually is a common idiom after calling strncpy() because
strncpy() does not always NUL-terminate the string. But snprintf() is
fine.

- remove NUL termination after snprintf in mgcp_send_reset_ep()

Change-Id: I5a1187b13b21b11674f13d3449c730616b0a4ddf
2018-01-19 10:35:12 +01:00
Philipp Maier 12943ea0c1 mgcp: make domain name configurable
At the moment the MGW has a fixed domain name string that is not even
checked properly.

- Make domain name configurable, use the current "mgw" string as
  defualt to maintain compatibility

- Check the domain name with each request. If the endpoint contains
  an unexpected domain name, the request must be rejected.

Change-Id: Ia91ac428ba83ac1f9b52a0ec8dbf00ef7876da9e
2018-01-19 10:15:47 +01:00
Philipp Maier 6efb43a210 client/common: move constant MGCP_ENDPOINT_MAXLEN
MGCP_ENDPOINT_MAXLEN is currently only defined for the mgcp client,
since this is in general a common parameter it should be moved to
mgcp_common.h so that both sides can use it.

Change-Id: I9e1c52aa5ebd83b2d9e5178ea24cb27d96cb7ddd
2018-01-18 18:26:52 +01:00
Philipp Maier 03cc48474c mgcp: allow endpoints beginning from zero
there is a now obsolete constraint that endpoint numbers must
start at 1.

- remove the check to allow also endpoints starting at 0

Change-Id: Iec2f4e36e1ab01ff23875d99e4b0e04af7c1ad98
2018-01-18 18:26:31 +01:00
Neels Hofmeyr 5672563f7e cosmetic: mgcp_network: typo in log
Change-Id: Ia7675e52fe1082d21bd68dcf54fe34c0f0326f11
2018-01-17 10:51:09 +00:00
Harald Welte 106743c66b osmo-bsc_mgcp: Add LIBOSMONETIF_{CFLAGS,LIBS}
The osmo-mgw gerrit build is currently failing with the following error:

make[3]: Entering directory '/build/src/osmo-bsc_mgcp'
  CC       mgcp_main.o
In file included from ../../include/osmocom/legacy_mgcp/mgcp_internal.h:146:0,
                 from mgcp_main.c:36:
../../include/osmocom/legacy_mgcp/osmux.h:4:33: fatal error: osmocom/netif/osmux.h: No such file or directory
 #include <osmocom/netif/osmux.h>
                                 ^
compilation terminated.

Let's make sure we're adding the required flags/libs for libosmonetif dependency

Related: OS#2829
Change-Id: I402314532590498a6340dc14101a32b605cd5e09
2018-01-15 18:59:29 +01:00
Harald Welte 8890dfa634 osmo-mgw: Use libosmocore socket abstraction
There's no need for us to use the sockets API directly:  We have
pretty nice socket helper functions in libosmocore, let's make
use of them.

Change-Id: I39d47b8a27f683060a2facf2dbecff8d00c19ce9
2018-01-08 12:52:18 +00:00
Philipp Maier 10f32dbfbf client: mgcp_response_parse_params: check rtp port
Also check the port number for plausibility like we do it
already for the IP-Address

Change-Id: I594a06fc9dd1bf0522f6e72a8943df52448d2ce4
2018-01-04 10:57:04 +00:00
Harald Welte e35eeae8e0 Return proper MGCP Error codes, as per spec
Change-Id: I55db8351422ff951516fefa6a29e87086b7ab74b
Closes: OS#2657, OS#2656
2017-12-28 14:00:42 +01:00
Harald Welte abbb6b9088 centralize handling of common errors like "endpoint not found"
Previously we
* did not distinguish between the cause of errors in mgcp_header_parse
* common errors were not handled in mgcp_handle_message() but in
  individual per-verb functions

Let's centralize the handling of generating error responses and remove
that burden from the individual per-verb handler functions.

Change-Id: I463b27306e10ae3b021583ed102977e7299e5e66
2017-12-28 14:00:37 +01:00
Harald Welte 3f35a3708a mgcp_internal.h: document more struct members with comments
Change-Id: Idfba05de37d354f9485030f37dfc9c780eff7b35
2017-12-28 03:17:10 +01:00
Harald Welte 33eafe050b mgcp_msg: We must parse endpoint numbers as hex, not decimal!
The MGCP client uses hex numbers, while the server side parses it
as decimal. This results in the first 10 calls succeeding, but from
0x0a onwards it of course fails :/

Change-Id: I006f5f5325f0a5069d02fec8912a38d943cfc552
Closes: OS#2784
2017-12-28 03:17:10 +01:00
Harald Welte 1d1b98f4a4 libosmo-mgcp: Cosmetic spelling fixes in comments
Change-Id: Ic0469c2a4d69b55a6a90653ad7ea1ad89a34e4bc
2017-12-25 10:10:29 +01:00
Harald Welte a0ac30faa5 mgcp_rtp_end: Group statistics members into 'stats' sub-struct
Change-Id: I4e0ecdcd9a75fe08abc55b730780c01617f3d4af
2017-12-25 10:10:29 +01:00
Harald Welte 49e3d5a9c9 mgcp_rtp_state: grup 'stats' members into sub-structure
Change-Id: I92a1bead01c6b85bf237b6edf64a1b76b9e97c78
2017-12-25 10:10:29 +01:00
Harald Welte 3338135ead strct mgcp_rtp_state: Group + document struct members related to patching
Change-Id: I403ddcafe0a11290103bb017568cfacaf5c04412
2017-12-25 10:10:29 +01:00
Philipp Maier 5dbfc78aff network: use originating RTP packet address for loopback
When a connection is created in loopback mode all incoming
packets should be reflected back to their origin. If the
user did not supply a destination address with the CRCX
command all incoming packets will be tossed because no
destination address is officially known yet.

If there is no destination address set and the connection
is in loopback mode. Then use the originating address of
the incoming packet as destination address.

Change-Id: I3d1abe56d016e28c97f60635eb574679d36e2c52
2017-12-12 16:27:14 +01:00
Philipp Maier 7bc5552512 mcgp_client: mgcp_msg_gen(): add checks to verify params
mgcp_msg_gen() does not check the contents of the prameters that
are handed over with the struct. This may lead to invalid mgcp
messages sent to the MGW, which can be difficult to debug.

Add some additional checks to make a possible problem
noticeable in an early stage.

- verify that the endpoint is not a nullstring
- verify that the connection id is not a nullstring
- verify that the ip-address is not a nullstring
- verify that the port number is a value greater 0

Change-Id: I15c464c4bcdf6e524f68acc62f44186dd7ad19a7
2017-12-10 23:22:14 +01:00
Philipp Maier a330b864e5 mgcp_test: fix possible double free
Change-Id: I2d044382c0bb66e190400e3397449c3f2387359a
2017-12-04 17:34:11 +01:00
Philipp Maier 7df419b434 mgcp_test: add returncode check
The returncode of get_conn_id_from_response() is unchecked, which
is intentional since some of the test messages will intentionally cause
this function to fail (the response does not inclde a connection
identifier). This means it makes no sense to assert this function
to a fixed value.

In order to spot regressions better print a log message depending
on the return code.

Change-Id: I9bce9ca39b7751b557374b7ab57c6c9005bcdb7d
Fixes: Coverity CID#180534
2017-12-04 17:34:11 +01:00
Philipp Maier 7cedfd753b mgcp_test: fix nullpointer dereference
Change-Id: Ic2ee79eaaca2fada673baf6ff4c226aa16c26269
Fixes: Coverity CID#180536
2017-12-04 17:33:59 +01:00
Philipp Maier 23b8e29835 mgcp_test: fix wrong strcmp() parameters
The CRCX string parameter lacks the quotes and the result of
the function call is not checked against zero. Also the
return code of get_conn_id_from_response() is not asserted.

Fixes: Coverity CID#180534

Change-Id: If4f3ed2c3572da196160569a9705b7a302b700a9
2017-12-04 16:51:40 +01:00
Philipp Maier 1c3287f1db conn: remove assertions
the assertions in the code that handles the connection
lists introduce a lot of unnecessary bloat.

Change-Id: I7badc729e97b76701abbce6a73a1ad1e46d3fee0
2017-12-04 16:04:10 +01:00
Philipp Maier 922ae9a5bf client: use string as connection identifier
The test that tests the cancelation of a pending mgcp message
uses an integer as connection identifier, which leads to a
segfault since connection identifiers are represented as strings.

Use a string as connection identifier.

Change-Id: I395a23c1828cf216031d69d481ad35dd458ee7d4
2017-12-04 16:04:10 +01:00
Neels Hofmeyr 189d6bf4d4 mgcp_client_test makefile: add update_exp target
Change-Id: I8cda082c46ab5734873cbb39b313037d86777589
2017-12-03 22:47:38 +00:00
Neels Hofmeyr c8f37cb4d6 mgcp_client: add transaction cleanup
So far, if an MGCP message is sent, the transaction gets enqueued, but there is
no way to end the transaction other than receiving a valid reply. So, if the
caller decides that the transaction timed out and tears down the priv pointer
passed to mgcp_client_tx, and if then a late reply arrives, the callback will
dereference the invalid priv pointer and cause a segfault. Hence it is possible
to crash an mgcp_client program by sending a late response.

Furthermore, if no reply ever arrives, we would keep the pending response in
the list forever, amounting to a "memory leak".

Add mgcp_client_cancel() to discard a pending transaction. The caller can now
decide to discard a pending response when it sees fit (e.g. the caller's
timeout expired). This needs to be added to OsmoMSC and OsmoBSC.

Add mgcp_msg_trans_id() to provide an obvious way to obtain the transaction id
from a generated MGCP message.

No public API is broken; but refine the negative return code from
mgcp_client_rx(): return -ENOENT if no such transaction ID is found, and still
-1 if decoding failed. This is mainly for mgcp_client_test.

Implement a test for mgcp_client_cancel() in mgcp_client_test.c.

Tweak internal mgcp_client_response_pending_get() to take only the transaction
id as argument instead of the entire mgcp message struct.

Found-by: dexter
Related: OS#2695 OS#2696
Change-Id: I16811e168a46a82a05943252a737b3434143f4bd
2017-12-03 22:47:01 +00:00
Neels Hofmeyr c0dcc3c60c Revert "mgcp_client: don't configure "bts base"" until osmo-msc is ready
OsmoMSC is in the odd situation that it is already using the new 
libosmo-mgcp-client, which is targeted at osmo-mgw, to configure talking to the
old osmo-bsc_mgcp. By removing the bts_base, we break current OsmoMSC.

Removing bts_base makes sense, but let's revert this until OsmoMSC is ready
after merging Ieea9630358b3963261fa1993cf1f3b563ff23538 (which moves the 
osmo-msc over to osmo-mgw).

This reverts commit 0be3ce66c0.

Change-Id: Ibce214c2bfc35623097abbb647619426ef3dcc94
2017-12-02 18:37:18 +00:00
Philipp Maier 230e4fc270 cosmetic: clearly mark endpoint numbers as hex
The log prints the endpoint numbers as hexadecimal numbers, but
it does not prefix them with "0x".

Add "0x" prefixes to all endpoint number outputs in the log

Change-Id: I284627de02cd140a894445375e9152ff007a71e6
2017-12-01 11:58:24 +00:00
Philipp Maier ead2f60f73 cosmetic: fix sourcecode formatting
Change-Id: I1a4eda30986e07237bb7b496704f36f03d25a149
2017-12-01 11:58:24 +00:00
Philipp Maier f8bfbe8b14 client: use osmo_strlcpy instead of strncpy
simplify \nul termination of the ip_addr string

Change-Id: I94e3815f45d08e0d40faf41e580547de937c4ce8
2017-12-01 11:58:24 +00:00
Philipp Maier ffd75e420c libosmo-mgcp: Connection Identifiers are allocated by MGW, not CA
The MGCP connection identifier is allocated by the MGW while processing
the CRCX, see RFC3435 2.1.3.2:. Including/Accepting a connection
identifier in CRCX is "forbidden" as per RFC3435 Section 3.2.2.

So the MGW side must *reject* a CRCX message with 'I' parameter, and
allocate a connection identifier which is subsequently returned in the
response.

Closes: OS#2648
Change-Id: Iab6a6038e7610c62f34e642cd49c93d11151252c
2017-12-01 11:58:24 +00:00
Philipp Maier 01d24a3281 MGCP: Connection Identifiers are hex strings
The MGCP spec in RFC3435 is quite clear: Connection Identifiers are
hexadecimal strings of up to 32 characters. We should not print and
parse them as integers on either client or server.

Change the internal uint32_t representation of connection identifiers
to a string representation in the client and also in the server.

Closes: OS#2649
Change-Id: I0531a1b670d00cec50078423a2868207135b2436
2017-12-01 11:58:23 +00:00
Neels Hofmeyr 0be3ce66c0 mgcp_client: don't configure "bts base"
There should not be any BTS base port to be configured at an MGCP client.

Possibly this is related to the legacy behavior of libosmo-legacy-mgcp, and
certainly has no place in libosmo-mgcp-client.

Further changes may be needed to follow up on removal of the BTS base port
concept, at least drop it from the VTY for now.

Change-Id: I36e46208d7b75611e5ade3c74d8e1c25870de511
2017-11-30 12:18:57 +01:00
Philipp Maier fcd0655176 vty: do not change number_endpoints at runtime
The variable number_endpoints is used as a length indicator
for the array that contains the trunk endpoints at all times.
When osmo-mgw is startet up, the variable is set and osmo-mgw
will allocate the memory for the endpoints. However, it is
still possible to manipulate the variable via the telnet
interface. When the value is increased osmo-mgw might start
using unallocated memory at some point.

Store subsequent changes of number_enspoints in a separate
variable in order to write them to the config file. The
changes will then take effect after a restart.

Closes: OS#2632
Change-Id: I3994af016fb96427263edbba05f560743f85fdd4
2017-11-27 14:38:29 +00:00
Philipp Maier 48454983c4 vty: simplify endpoint allocation
mgcp_parse_config() uses a helper function allocate_trunk() to
perform the trunk allocation. This helper function only calls
mgcp_endpoints_allocate() and checks the return code.

Call mgcp_endpoints_allocate() directly from mgcp_parse_config()

Change-Id: Iefdc5b905d76d2cd97f26584261fe5cbefb699cf
2017-11-27 11:01:43 +01:00
Philipp Maier 9a3543a8d4 cosmetic: use correct VTY port number constant
osmo-mgw currently uses VTY port number constant of osmo-bsc_mgwp,
however, libosmore now offers a constant specifically for osmo_mgw,
which has the same value, but is intended to be used by osmo-mgw

use the new port number constant for osmo-mgw

Closes: OS#2628
Change-Id: I63c3b300cc9287d1755a3f2c5b5ade7fc6398f6e
Depends: libosmocore I1770787e697906322ce5815fcaadba06c01ddee9
2017-11-24 12:40:51 +01:00
Neels Hofmeyr 465446b4b4 mgcp_test: sanitize: free msgb_ctx
Ensure that all msgb were cleaned up, then free the overall msgb_ctx, in order
to not leave any memory leaks the sanitizer build complains about.

Change-Id: I53373023a6c3f490d6d6cb1c283db5dfb915882c
2017-11-22 02:59:03 +01:00
Neels Hofmeyr b597b4fc9d mgcp_test: test_no_cycle: sanitize: free endp
Release endpoint to avoid sanitizer errors.

Change-Id: I78d16ffc435c0f967fe99c6e38dde829b6fa0dc9
2017-11-22 02:58:27 +01:00
Neels Hofmeyr d20910c655 mgcp_test: test_packet_error_detection: sanitize: free all conns
Don't leave any memory leaks a sanitizer build will complain about.

Change-Id: I6823653d5efcebaed40471123d21a9321cf633fd
2017-11-18 21:27:55 +01:00
Neels Hofmeyr 677f4ad968 legacy_mgcp: mgcp_test: sanitize: free msgb_ctx
Ensure that all msgb were cleaned up, then free the overall msgb_ctx, in order
to not leave any memory leaks the sanitizer build complains about.

Change-Id: I84e0ac7f0928f04ffddd7da18200466841589c25
2017-11-18 21:26:27 +01:00
Neels Hofmeyr 7c20c9de5a add --enable-sanitize config option
Change-Id: I2693238c5c8d914cf3ff7721511e7b4b56e413d2
2017-11-18 10:17:39 +00:00
Harald Welte 839fc954d0 osmo-mgw: Fix copyright notice
The copyright statement and contribution notices were copied 1:1
from OpenBSC, which is of course not correct for OsmoMGW.

Change-Id: I6143becdd0da589451efcbda530a78f655b7ce0b
2017-11-17 20:58:22 +01:00
Harald Welte d164b05655 osmo-mgw: Config file is osmo-mgw.cfg, and not mgcp.cfg
Change-Id: I16016684ee5bd6d82a8867d4b2be108b6d718291
2017-11-17 15:41:24 +01:00
Harald Welte a896f9cdeb osmo-mgw: Update copyright statement
sysmocom (specifically Philipp) was doing all the new osmo-mgw
development, but that is not yet reflected in the Copyright statement
for some reason.  Let's fix it.

Change-Id: I4cad29daaabec1caec1bd09088414e59fa15a17e
2017-11-17 15:08:41 +01:00
Harald Welte 1b0cf6fa1c Fix possible buffer overflow in mgcp_conn_dump()
mgcp_conn.c: In function ‘mgcp_conn_dump’:
mgcp_conn.c:248:30: warning: ‘/rtp, id:’ directive output may be truncated writing 9 bytes into a region of size between 0 and 255 [-Wformat-truncation=]
   snprintf(str, sizeof(str), "(%s/rtp, id:%u, ip:%s, "
                              ^~~~~~~~~~~~~~~~~~~~~~~~~
mgcp_conn.c:248:30: note: directive argument in the range [0, 65535]
mgcp_conn.c:248:30: note: directive argument in the range [0, 65535]
mgcp_conn.c:248:3: note: ‘snprintf’ output 32 or more bytes (assuming 295) into a destination of size 256
   snprintf(str, sizeof(str), "(%s/rtp, id:%u, ip:%s, "

as mgcp_conn->name can already be up to 256 bytes, a total buffer size
of 256 is insufficient!

Change-Id: I5d48132b1358d19fe72e3901117737b09a42c69c
2017-11-17 14:28:46 +01:00
Harald Welte 9bf7c53779 cosmetic: fix whitespaces; we use tabs for indentation
Change-Id: I547f650bcda369ea399c5171a3541a96862d978b
2017-11-17 14:18:24 +01:00
Alexander Couzens 6be0fdb5e4 debian: include systemd service osmo-mgw.service
Change-Id: Ic298b836620b3497734aed89b92c4f22a9071f0d
2017-11-16 15:54:55 +00:00
Alexander Couzens 641c4d47b9 debian/control: correct library dependency of osmo-mgw against libosmo-mgcp1
When the library version was bump, the dependency of osmo-mgw
was forgotten.

Change-Id: I3eeafa3c294d9ec71a72fb2833fe3b2bdef05a50
Fixes: e7d27aeae1 ("Tag/Release Version 1.2.0")
2017-11-16 15:54:54 +00:00
Neels Hofmeyr c1b9fa158e MGCP endpoints: parse as decimal, not hex
Parse the endpoint index from the MGCP messages as base-10, not 16.

If osmo-mgw parses the endpoint IDs as base-16 numbers while OsmoMSC and
OsmoBSC pass in decimal endpoint numbers, the consequence is, for example:

- I configure 32 endpoints in osmo-mgw,
- I tell OsmoBSC to use endpoint range 1-32,
- At some point OsmoBSC may pass in, say, "30@mgw",
- "30" is parsed base-16 and ends up being endpoint index 48, instead of 32,
- OsmoMGW sees that 48 > number_endpoints and barfs.

Related: OS#2633
Change-Id: Ic18608ff23303c1564548a86d5f6bfa539fe555e
2017-11-15 23:02:05 +00:00
Philipp Maier 6a421f1b6f doc: update sample config file
The current example configuration is out of date.

Add a recent configuration file

Change-Id: Iad2034ce4c68bb8b70cb72d3978d2a0f685bbe19
2017-11-12 14:22:23 +00:00
Philipp Maier f1889d8640 cosmetic: remove prefix "net" from rtp related vty commands
There the prefix "net" is a leftover from the time when
there was a bts and a net side. Now we do not distinguish
anymore between the two.

remove prefix "net"

Change-Id: Id627e2ef6f725979ed52a585ca09686e1a049adf
2017-11-12 14:22:22 +00:00
Philipp Maier 2982e42d93 cosmetic: guard dead osmux vty code with ifdef
Since currently osmux is not available we decided to lock down the
respective VTY command with an early return CMD_WARNING, making
the code after this line unreachable.

Guard the dead code with an ifdef

Fixes: Coverity CID#178648
Change-Id: I2ad9579453f52fe129cf120801a2efa19a26304e
2017-11-10 21:32:35 +00:00
Philipp Maier ddf1f9d7d5 osmux: fix nullpointer dereference
in point_lookup() the connection pointer is determined using
mgcp_conn_get_rtp() this function may return 0. At the moment
there are no nullpointer checks implemented

Add checks to test for nullpointer.

Fixes: Coverity CID#178662
Change-Id: If9a3c1ac002bc8adc90ca1c1c3dd1db4feea07ac
2017-11-10 21:30:19 +00:00
Neels Hofmeyr 653c4ff354 fix segfault: DLCX for unknown endpoint: dont try to log NULL endpoint
Change-Id: Ib127fd81a2d68f51c470ff77ef0822bdb4829de4
2017-11-10 16:23:36 +01:00
Pau Espin 4efce88a62 contrib: Add osmo-mgw systemd service
Change-Id: Ic89815dc4ef8dff8a9d8541b61212ab8d4837712
2017-11-10 10:31:39 +00:00
Harald Welte e7d27aeae1 Tag/Release Version 1.2.0
Change-Id: Ieff5a16285d2d2d46ad8977713fec622ad0596a7
2017-11-10 11:21:40 +09:00
Philipp Maier e6f172dd57 network: remove unused return code
The function that forwards the tapped (voice ebug) traffic returns
its status (sendto) to the caller. However, none of the callers
seem need this info.

Remove the return code and print an error message on failure

Fixes: Coverity CID#178666
Change-Id: I16c12c4565bccbc0d75c412b43469bf70b6b7ea5
2017-11-08 19:14:06 +00:00
Philipp Maier b969455941 network: fix rtp packet length
When sending rtp packets sizeof(buf) is used as length. This causes
all RTP packets to be the size of the buffer (4096) containing the
rtp payload and random excess data from previoes memory usage

Use the actual length of the received RTP data, rather then the
full buffer size.

Change-Id: I47a15701f9a7e7a492df183b67ec971f5be61069
2017-11-08 16:57:31 +01:00
Neels Hofmeyr 54dd4b3f72 mgcp client: vty: tweak doc strings
Fix errors like "remote bind address", mention 'MGW' instead of 'MGCP gateway',
minor typos and wording tweaks.

Change-Id: Ie1a408f9e651c5fb3424a84ceaaa603e20ad595c
2017-11-06 16:35:46 +00:00
Pau Espin dbd88e5167 mgcp_client_vty.c: Fix VTY compatibility with 'mgcpgw bts-base'
Commit 87203f2a37 renamed some cmds to use
mgw instead of mgcpgw, and added deprecated alias for the old commands,
but forgot to add one for 'mgcpgw bts-base'. This commit fixes
backawards compatibility with old config files that mentioned commit
introduced.

Change-Id: Ib1c58945f4203b05d79f367afb3082b9a6a2c4e3
2017-11-06 14:02:34 +01:00
Neels Hofmeyr 87203f2a37 mgcp-client vty: use name 'mgw' instead of 'mgcpgw'
'mgcpgw' was a working title for the osmo-mgw. Before this takes hold out
there, let's rename the VTY commands to 'mgw'. I'd rather have some local
fallout in our testing environments now than drag the stupid name along.

Keep deprecated 'mgcpgw' commands for backwards compat.

Change-Id: I1d43d42929dc9162e57640499526fb7cadbcfbe6
2017-11-05 19:32:48 +00:00
Philipp Maier 1cb1e38dbc network: autdetect rtp bind ip-address
Currently there are two ways to set the rtp bind ip-address (local
ip address where the rtp streams are bound to). It is possible to
set no set an rtp bind ip, if none no address is configured, then
the ip address where the mgcp service is bound to is used.

On a system with multiple network interfaces it is likely that
there are the remote end is not reachable through the interface
that has been configured. In this case rtp ip-probing can be
enabled via vty option in order to automatically detect the
ip address of the interface that points towards the remote end.

The autodetection can only work if the ip-address is known when
a CRCX is performed. For this the remote entity must include the
remote ip address in the sdp trailer.

Implement probing to determine te right local ip address
Add debug log to display which ip address is actually used
Add a VTY option for the probing functionality.

Change-Id: Ia57cf7dab8421fd3ab6e1515727db0080373485e
2017-11-02 17:16:04 +01:00
Philipp Maier e726d4fad2 cosmetic: make dummy packet handling more explicit
The way how osmo-mgw decides when to send a dummy packet and
when not is not very obvious.

use more explicit if statements, and define constants. Also add
comments that explain how it works.

Change-Id: Ie7ee9409baec50a09fb357d655b5253434fae924
2017-11-02 11:47:44 +01:00
Philipp Maier c341388b30 network: add separate log category
the network (mgcp_network.c) part and the protocol part
(mgcp_protoocl.c) share a single loglevel DLMGCP. This
makes debuging hard because when debugging the protocol
we also get the log output from the RTP packets.

assign the network part a private loglevel and keep DLMGCP
for the directly MGCP related code

Change-Id: I55a2711798d1d1c2c9ef2f3b7ebb8fdd78bd6ea2
2017-11-02 11:47:44 +01:00
Philipp Maier 7bf4ce3aed mgcp: remove port/timeslot calculator functions from mgcp.h
the functions rtp_calculate_port(), mgcp_timeslot_to_endpoint(),
mgcp_endpoint_to_timeslot() were a hack to map CIC addresses
to endpoints and ports. This is no longer needed.

Remove the affected functions.

Change-Id: I9ef14396dc9f97e570d9bcfb4d9b4a94e650ad46
2017-11-02 11:47:44 +01:00
Philipp Maier f4c0e37352 protocol: allow wildcarded DLCX
In many cases it is simpler to instruct the mgcp-gw to drop all
connections at once instead of removing each connection
individually.

drop all connections and release the endpoint in when no connection
id is supplied with the DLCX command.

Change-Id: Ib5fcc72775bf72b489ff79ade36fb345d8d20736
2017-11-02 11:47:44 +01:00
Philipp Maier 06da85ed3a client: add ip address parsing to the client
Some MGCP messages (CRCX, MDCX) return IP-Addresses. Make use of
this information.

Change-Id: I44b338b09de45e1675cedf9737fa72dde72e979a
2017-11-02 11:47:44 +01:00
Philipp Maier 1dc6be6a82 client: add unified function to generate MGCP messages
currently the only way to generate MGCP messages is to use
mgcp_msg_crcx(), mgcp_msg_mdcx() and mgcp_msg_dlcx(). All
three function take a fixed set of parameters via their
parameter list. There is no way to add or leave away optional
parameters.

add function mgcp_msg_gen(), this function takes a unified
message struct. The struct features a presence bitmask which
allows to enable and disable parameters as needed. It is also
possible to add new parameters in the future without breaking
the API.

Depends: libosmocore I15e1af68616309555d0ed9ac5da027c9833d42e3

Change-Id: I29c5e2fb972896faeb771ba040f015592487fcbe
2017-11-02 11:47:44 +01:00
Philipp Maier 8348abb372 client: fix stderror logging in unit-test
When testing the file name and the line numbers are output to
stderr, this causes the test to fail when change moves the
lines.

Disable line numbers in the stderror log when testing, also
disable timestamps and colors. Make sure the log category
is print.

Change-Id: I7f1bd9454188f0ca869dada1fcc2877b789cc0ac
2017-11-02 11:47:44 +01:00
Philipp Maier d8d7b4b188 cosmetic: correct whitespaces
Change-Id: I22302ae8a48a2c776025a60267f5ef5af706e576
2017-11-02 11:47:44 +01:00
Philipp Maier 31c4305225 cosmetic: fix commenting style
Change-Id: Ib717d9dd3b17250ef4d6c67be0463a407cb83fbe
2017-11-02 11:47:44 +01:00
Philipp Maier c7a228aceb cosmetic: fix coding style for mgcp_parse_sdp_data()
move variable declaration to the top

remove brackets in case statement

correct whitespaces

Change-Id: I6dcf53ef8d3af5885b8b1f258d963949fa3ee93a
2017-11-02 11:47:44 +01:00
Philipp Maier e472b4e39a cosmetic: rename bts_codec to codec_str
make variable name more meaningful

e enter the commit message for your changes. Lines starting

Change-Id: I4d4d5af8925d032155ca1ef8c7d7d2e496a60fb6
2017-11-02 11:47:44 +01:00
Philipp Maier 8970c497bc sdp: refactoring sdp parser/generator
move SDP generator function write_response_sdp() from mgcp_protocol.c
to mgcp_sdp.c and use msgb_printf() instead of snprintf()

move prototypes for mgcp_parse_sdp_data() and mgcp_set_audio_info()
to mgcp_sdp.h

change parameter list of mgcp_parse_sdp_data() so that it takes the
rtp conn directly, rather than struct mgcp_rtp_end.

add doxygen comments to all public functions

Change-Id: I9f88c93872ff913bc211f560b26901267f577324
2017-11-02 11:47:44 +01:00
Neels Hofmeyr 1e0b9f872c vty: skip installing cmds now always installed by default
vty_install_default() and install_default() will soon be deprecated.

Depends: I5021c64a787b63314e0f2f1cba0b8fc7bff4f09b
Change-Id: I246853156c4bd2a47690e580e647105eb838ca92
2017-11-01 00:50:52 +01:00
Neels Hofmeyr 8863f7ae64 jenkins: use osmo-clean-workspace.sh before and after build
See osmo-ci change I2409b2928b4d7ebbd6c005097d4ad7337307dd93 for rationale.

Depends: I2409b2928b4d7ebbd6c005097d4ad7337307dd93
Change-Id: I5a64b305dff5387cbe2462b564051f807061086d
2017-10-28 15:08:04 +00:00
Harald Welte 1ae2d5ebf4 Tag/Release 1.1.0
This marks the first release that includes the new libosmo-mgcp
as well as some updates to libosmo-mgcp-client.  Hence, all programs
using those libraries can now depend on a proper minimum version

Change-Id: I1748ed230041930b4e9f49deb03341772ab02144
2017-10-28 12:54:53 +02:00
Harald Welte 5852a78d2e libosmo-mgcp-client: Bump LIBVERSION as interfaces have been added
Change-Id: I3e00af70267563a5fbf7e2a3c1326c22481d2666
2017-10-28 12:54:35 +02:00
Harald Welte 59e2d518fd libosmo-legacy-mgcp: Link against libosmovty, don't link libosmogsm
This fixes the following dpkg-shlibdeps warnings:

Change-Id: I648bbda50520808afcf2a6ce64fe710df918936c
dpkg-shlibdeps: warning: symbol install_element_ve used by debian/libosmo-legacy-mgcp0/usr/lib/x86_64-linux-gnu/libosmo-legacy-mgcp.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol argv_concat used by debian/libosmo-legacy-mgcp0/usr/lib/x86_64-linux-gnu/libosmo-legacy-mgcp.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vty_out used by debian/libosmo-legacy-mgcp0/usr/lib/x86_64-linux-gnu/libosmo-legacy-mgcp.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vty_install_default used by debian/libosmo-legacy-mgcp0/usr/lib/x86_64-linux-gnu/libosmo-legacy-mgcp.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vty_read_config_file used by debian/libosmo-legacy-mgcp0/usr/lib/x86_64-linux-gnu/libosmo-legacy-mgcp.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol install_element used by debian/libosmo-legacy-mgcp0/usr/lib/x86_64-linux-gnu/libosmo-legacy-mgcp.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol install_node used by debian/libosmo-legacy-mgcp0/usr/lib/x86_64-linux-gnu/libosmo-legacy-mgcp.so.0.0.0 found in none of the libraries
2017-10-28 12:11:29 +02:00
Harald Welte 062b0f0eee osmo-bsc_mgcp: Don't link against libosmo-netif
This fixes the following dpkg-shlibdeps warning:

Change-Id: I1eb079aa74a56b75e881b7abae0e5d9b4d7ae9c4
dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/osmo-bsc-mgcp/usr/bin/osmo-bsc_mgcp was not linked against libosmonetif.so.4 (it uses none of the library's symbols)
2017-10-28 12:08:19 +02:00
Harald Welte 71c619ee05 libosmo-mgcp-client: don't link against libosmonetif
This fixes the following dpkg-shlibdeps warning:

Change-Id: If60583b2bec344fc674af6f129787206540bc9fc
dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/libosmo-mgcp-client0/usr/lib/x86_64-linux-gnu/libosmo-mgcp-client.so.0.0.0 was not linked against libosmonetif.so.4 (it uses none of the library's symbols)
2017-10-28 12:06:38 +02:00
Harald Welte e3b5de2285 libosmo-mgcp-client: Don't link libosmogsm, but link libosmovty
This addresses the following dpkg-shlibdeps warnings:

Change-Id: I737c36402b7b88634b56725f2caab4f5f971ac51
dpkg-shlibdeps: warning: symbol install_element used by debian/libosmo-mgcp-client0/usr/lib/x86_64-linux-gnu/libosmo-mgcp-client.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vty_out used by debian/libosmo-mgcp-client0/usr/lib/x86_64-linux-gnu/libosmo-mgcp-client.so.0.0.0 found in none of the libraries
2017-10-28 12:05:22 +02:00
Harald Welte f96e46fcce libosmo-mgcp: Don't link against libosmogsm; link against libosmovty
This addresses the following dpkg-shlibdeps warnings:

Change-Id: I518eb5e19cef5f261711b034d28337265c69f443
dpkg-shlibdeps: warning: symbol install_element_ve used by debian/libosmo-mgcp0/usr/lib/x86_64-linux-gnu/libosmo-mgcp.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vty_read_config_file used by debian/libosmo-mgcp0/usr/lib/x86_64-linux-gnu/libosmo-mgcp.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vty_install_default used by debian/libosmo-mgcp0/usr/lib/x86_64-linux-gnu/libosmo-mgcp.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol install_element used by debian/libosmo-mgcp0/usr/lib/x86_64-linux-gnu/libosmo-mgcp.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol install_node used by debian/libosmo-mgcp0/usr/lib/x86_64-linux-gnu/libosmo-mgcp.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vty_out used by debian/libosmo-mgcp0/usr/lib/x86_64-linux-gnu/libosmo-mgcp.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol argv_concat used by debian/libosmo-mgcp0/usr/lib/x86_64-linux-gnu/libosmo-mgcp.so.0.0.0 found in none of the libraries
2017-10-28 12:03:01 +02:00
Harald Welte 88d4dae645 osmo-mgw: Don't link against libosmo-netif
Change-Id: Ic62efeb3c139016aa8a1e68651442edf2044eeef
dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/osmo-mgw/usr/bin/osmo-mgw was not linked against libosmonetif.so.4 (it uses none of the library's symbols)
2017-10-28 12:00:11 +02:00
Harald Welte 8042539444 Debian: Include the osmo-bsc-mgcp systemd service in Debian package
Change-Id: Ife3f034ddaaba993bf27c1f9a34a1d57d1bf3e05
2017-10-28 11:57:50 +02:00
Harald Welte 6ba4406c47 Debian: make sure osmo-bsc_mgcp ends up in its own package
... rather than being in the osmo-mgw package, which is clearly wrong.

Change-Id: Ib5d19f56b611722101040639db615184fa223f82
2017-10-28 11:56:38 +02:00
Harald Welte 1e940d615a configure.ac: Depend on latest tagged/released libosmo-* versions
This is the safe choice, as in absence of automatic testing we don't
know if we actually still build against the [sometimes] ancient
dependencies.

Change-Id: I8118defcd270bb487d9fd674fe30a74d379fda18
2017-10-28 11:51:07 +02:00
Philipp Maier fde78ad412 mgcp: move misplaced include
mgcp.h includes mgcp_ep.h but does not use anything from it. This
does not hurt the mgcp code internally, but when mgcp.h is included
by an application compilation fails because mgcp_ep.h is not
installed.

remove mgcp_ep.h from include list in mgcp.h

add mgcp_ep.h to include list in mgcp_conn.c where it is needed.

Change-Id: Ib58a8ed64f729055282c2b9673f7684cdfdb5936
2017-10-16 14:47:21 +02:00
Philipp Maier 3d9b656a1c mgcp_test: do not send rtp packets
The sendto() override in mgcp_test sends rtp packets out. This
might be a problem for some test hosts. e.g. on OBS, sending packets
fails with an error message, which exits sendto() early and hence fails
to send the expected amount of "Dummy Packets". Interestingly enough
calling the real sendto is not necessary to run the test at all.

Remove the execution of the real_sendto and just return len.

Related: OS#2561
Change-Id: Ia8fa0770f9bc75725cc6b0cd445e753f7e029ca5
2017-10-13 18:41:52 +00:00
Neels Hofmeyr 2152f8523e build: make sure copied mgcp_common.h is removed on 'make clean'
I thought the BUILT_SOURCES also enters the files to CLEANFILES, but 'make
clean' leaves the copied header behind for me. Add to CLEANFILES to get it
removed.

Change-Id: I5a56f83289e32a09643047f0e779c9de3e4b39a6
2017-10-11 08:15:38 +00:00
Alexander Couzens c5ecebb711 debian/rules: show testsuite.log files when tests are failing
Change-Id: I11aca905350b2e3464fb526ec4d3ae6ffcf55114
2017-10-11 06:05:33 +02:00
Neels Hofmeyr 020e89bce9 mgcp_test: tweak test failure output
Change-Id: Ibfc80f06b2811cc32fe38518b11efd6764b347ee
2017-10-11 02:02:22 +02:00
Neels Hofmeyr 6779354245 drop code dup between libosmo-mgcp-client and libosmo-mgcp
Remove mgcp_common.c and replace with mgcp_common.h.

Move mgcp_common.h from mgcp_client/ to mgcp/;
Place a compile-time copy of it back in mgcp_client/.

Add builddir/include to compiler -I paths to find generated header.

Rationale:
- Keep separate copies of the file for each of the library to not require
  debian dependencies between the two libraries.
- Avoid code dup by copying during 'make' (think: a generated header, BUILT_SOURCE).
- The copy does not have implications for linking (like mgcp_common.c did) nor
  is it a source for build confusion or fallout in other projects, because it
  does not reach across several git source trees (like gsm_data_shared.h did).

mgcp_connection_mode_strs are not actually used in libosmo-mgcp, so drop them.
(It would make semantic sense to have then in mgcp, but we can add it when it
is needed. A similar value string array remains in libosmo-mgcp-client.)

Change-Id: I7a5d3b9a2eb90be7e34b95efa529429f2e6c3ed8
2017-10-05 19:32:58 +02:00
Philipp Maier 87bd9be0b0 Initially implement the new osmo-mgw and libosmo-mgcp
Leave the old osmo-bsc_mgcp and libosmo-legacy-mgcp as it is; on a copy thereof
(added by a previous commit), apply changes to initially implement the new
osmo-mgw.

Adjust build system and debian packaging to accomodate the new libosmo-mgcp and
osmo-mgw.

The main differences:

*) use a list to manage rtp connections.

Aggregate all rtp related information inside a single struct.

Use a linked list to manage the both connections (net and bts).
The idea behind using a list is that we might support conference
calls at some later point.

Store the linked list in struct mgcp_endpoint, have a private linked
list for each endpoint. The list contains connection items which are
implemented in struct mgcp_conn. A connection is allocated and freed
using the functions in mgcp_conn.c. A connection is allocated on the
reception of a CRCX command and freed with the reception of a DLCX
command.

*) remove external transcoder feature

Fortunatelly the external transcoder feature is not needed
anymore. This patch removes the related code.

*) vty: get rid of CONN_BTS and CONN_NET

Since the new connection model does not make a difference
between BTS and NET connections the VTY should not use
the fixed CONN_BTS and CONN_NET constants.

- Handle the conns list inside the endpoint directly
- introduce function to dump basic rtp connection info
- introduce human readable names for connections

Parts of the code adjusted to use generalized connections instead of explicit
BTS/NET ones:

- teach mgcp_send_dummy() to send dummy packets to any RTP connection
- network: generalize mgcp_bind_net/bts_rtp_port()
- network: generalize mgcp_send()
- tap: generalize call tapping feature
- stat: generalize statistics
- Replace rtp_data_net() and rtp_data_bts() with generalized rtp_data_rx()

*) mgcp_protocol.c fixes:

- check ci string before it is converted:
  In case of missing ci, a nullpointer is delivered to strtoul().
  Add a function that takes ci, checks it and converts it to an
  uint32_t. Use the return code to react on missing ci.
- output error message on missing CI.
- when parsing the mode, print log message when mode is missing.
- use mode_orig when mode is missing.
- fix ptime formatstring to use %u rather than %d.
- cosmetic: log when connection is deleted on DLCX.
- change loglevels of CRCX, MDCX, DLCX events from DEBUG to NOTICE.

*) mgcp_test

- apply rename of strline_r() to mgcp_strline().
- MGCP command macros:
  - Add 'I: 1' parameters.
  - Use proper port numbers:
    from m=audio 0 RTP/AVP 126
    to   m=audio 16002 RTP/AVP 128
  - Change ptime to 'a=ptime:40' because this is what the MGW currently
    returns.  CRCX generally feed a ptime:40 and this is expected to be
    returned.
- struct mgcp_test: Use only one ptype, there are no explicit BTS and NET
  endpoints anymore.
  Hence remove one column from tests[].
- test_messages():
  - Enable: remove '#if 0'
  - Remove concept of BTS and NET endpoints: test only one conn, as they are
    now interchangeable anyway.
  - remove endpoint init, now done internally.
  - add false asserts in error cases.
- test_retransmission():
  - remove endpoint init, now done internally.
  - add false asserts in error cases.
- test_packet_error_detection():
  - Remove concept of BTS and NET endpoints: test only one conn, as they are
    now interchangeable anyway. Use arbitrary conn ids (e.g. 4711).
  - remove endpoint init, now done internally.
  - add false assert in error case.
  - Assert that a conn really vanishes on DLCX, previously the conn would
    remain and just be unused, now it is actually discarded.
- test_no_cycle()
  - Remove concept of BTS and NET endpoints: test only one conn, as they are
    now interchangeable anyway. Use arbitrary conn ids (e.g. 4711).
- test_no_name()
  - Enable: remove '#if 0'.
  - remove endpoint init, now done internally.
  - add false assert in error case.
- mgcp_test.ok: adjust expected results to status quo:
  - We now see two dummy packets instead of one, now sent to both sides because
    we don't know of BTS or NET side. (maybe drop dummy packets later...)
  - packet duration, conn mode: now sane defaults show instead of unset.
- various whitespace and formatting changes from lindent.

Change-Id: Ie008599136c7ed8a0dfbb0cf803188975a499fc5
2017-10-05 01:40:43 +00:00
Neels Hofmeyr f83ec56212 create libosmo-mgcp and osmo-mgw by copying legacy code
This a cosmetic commit, copying libosmo-legacy-mgcp to libosmo-mgcp and
osmo-bsc_mgcp to osmo-mgw 1:1 at first, to provide a basis for next patches
that highlight the changes from legacy to new code.

Until osmo-msc and osmo-bsc are adjusted to operate with the new code, we will
keep the legacy code alongside the new code. The legacy code might be dropped
later.

Change-Id: Idf54481754a1765bdb2d0d7033bc0d7dc2018024
2017-10-05 01:40:43 +00:00
Pau Espin 1c8d67d7f5 libosmo-legacy-mgcp: fix link against libgsm
libosmo-legacy-mgcp was not linked against libgsm
when built with --enable-mgcp-transcoding.
When afterwards a binary such as osmo-bsc is built and
tries to link against it, it will fail with an error
like the one below:
/home/pespin/dev/sysmocom/bin/../build/new/out/lib/libosmo-legacy-mgcp.so: undefined reference to `gsm_create'

Tested that building with this patch fixes the issue.
Also tested that it still builds fine without --enable-mgcp-transcoding.

Change-Id: I5ed356ac0c8f476e263fc6dcc5613d594890dfcd
2017-09-26 13:50:32 +02:00
Neels Hofmeyr 9d4f1d57f3 debian: tweak .install: less wildcards
With the upcoming addition of libosmo-mgcp, when we try the same scheme
of wildcards there, it would also include all of the other libraries:

  *mgcp*.so.*

There we will have to clarify that we mean exactly:

  libosmo-mgcp.so.*

This is a cosmetic change to also be less ambiguous for the current libs:
I prefer to state exactly which parts of the file names may vary, so that
we have a firmer understanding of what is being installed.

Change-Id: I6a3f3b9efa08eb9c5cdca3e02f8fab4a96c28ad5
2017-09-24 23:06:06 +02:00
Neels Hofmeyr d95ab1e9ad libosmo-mgcp-client: fix debian, make self-contained
Add mgcp_common.h to libosmo-mgcp-client, to not need to share a header file
with libosmo-legacy-mgcp (nor the upcoming libosmo-mgcp). Both libraries use
the enum mgcp_connection_mode (and a for-loop macro and a string mangling
function), so far declared in mgcp.h, and both mgcp-dev and mgcp-client-dev
debian packages would require this header file to be installed. So far the
mgcp-client-dev lacks this header file, which causes the osmo-msc debian
package to fail building. Ways to solve:
- If both -dev debian packages installed the same header file in the same
  place, they would conflict if ever installed at the same time.
- mgcp-client-dev can depend on mgcp-dev, but it seems bad to keep such a large
  dependency for just one enum and two helpers.
- Instead, this patch solves this by copying the few definitions to
  libosmo-mgcp-client.

Once libosmo-mgcp-client has its own copy of those definitions, it is
fully self-contained and depending builds (osmo-msc deb) will succeed.

Copy the few actually common definitions to new header
<osmocom/mgcp_client/mgcp_common.h>. The nature of this .h is that it may be
shared with future libosmo-mgcp without causing linking problems.

Remove libosmo-legacy-mgcp/mgcp_common.c file from the build of
libosmo-mgcp-client, no longer needed.

Add to new mgcp_common.h:
- enum mgcp_connection_mode;
- for_each_non_empty_line() macro.
- mgcp_msg_terminate_nul() as static function.  Its complexity is just above
  your average static inline, but being inline is a way to use it in both mgcp
  and mgcp_client without linking problems.

Replace for_each_line() use in mgcp_client with for_each_non_empty_line()
(for_each_non_empty_line() replaces for_each_line() and uses strtok_r() instead
of a local reinvention).

mgcp_connection_mode_strs are actually only used in libosmo-mgcp-client, so
rename to mgcp_client_ prefix and move to mgcp_client.c.

BTW, the future plan for upcoming libosmo-mgcp is to use the identical header
file, and keep only one copy in the git source tree. The second copy may be
generated during 'make', to avoid code dup while having two distinct headers.

Related: I8e3359bedf973077c0a038aa04f5371a00c48fa0 (fix osmo-msc after this),
         I7a5d3b9a2eb90be7e34b95efa529429f2e6c3ed8 (mgcp_common.h)
Change-Id: Ifb8f3fc2b399662a9dbba174e942352a1a21df3f
2017-09-24 19:48:37 +02:00
Neels Hofmeyr a1fa2f4bc3 tweak API version comments
Clarify LIBVERSION comments in TODO-RELEASE and reference Makefile.am comments
to look there.

Change-Id: I4edf786fde085f612f8a04972c55175a080ac65f
2017-09-21 22:01:55 +00:00
Neels Hofmeyr c221b7ad01 set API versions back to 0
Roll back the LIBVERSIONs to 0:0:0 -- the bumps so far have been confused and
wrong. Let's start over from scratch with API-current of 0 while we still can.

Rename the mgcp_client debian .install files back to 0 to match the API
version.

Change-Id: I3d81853f811f412b186621c3657bab6af397a980
2017-09-21 00:00:40 +02:00
Max f19acc9a35 Bump version: 1.0.1 → 1.0.2
Catch-up with release tagging and .deb changelog: the requirements in
OsmoMSC were updated.

Change-Id: I2c37b56e81df13007738f340c3fb48f0996a95f3
2017-09-14 18:50:51 +02:00
Max 53f2bd0443 Add TODO-RELEASE file
Let's track the API/ABI changes in libosmo*mgcp the same way we do it in
other libosmo* libraries.

Change-Id: Id0b8d55ea58bdb3d72b4c131ac983d8895b55ef8
2017-09-14 18:21:16 +02:00
Alexander Couzens 0c5a16c253 debian: use new dbgsym package instead of old dbg packages.
The new dbgsym packages gets created automatic without
taken care of them.

Change-Id: I4113c10d7698232217071becddd997fad918ca36
2017-09-14 05:06:13 +02:00
Alexander Couzens 32330aa9be debian/rules: compile with debug symbols
The debug symbol will be stripped out of the "normal" package.

Change-Id: I2428b922298c312c6071f51f23d7fd5939e5af91
2017-09-14 05:06:07 +02:00
Alexander Couzens beabe15526 debian: .install: split mgcp-client out of legacy-mgcp
Change-Id: I681e9a1299607ff3a30de34c043da499c471bc31
2017-09-14 05:06:04 +02:00
Alexander Couzens 8ec0365ae9 debian: rename libosmo-mgcp-client0 -> libosmo-mgcp-client1
The numeral is describing the library major version. libosmo-mgcp-client has
version 1.0.0

Change-Id: I66394109f909cfe0385d4519c14236bc53a10b14
2017-09-14 05:06:00 +02:00
Neels Hofmeyr 725f924316 doc/examples: fix mgcp.cfg indenting, tweak
Use one space to indent mgcp.cfg, like all the other osmo*.cfg examples.

Tweak the header comment.

Remove the password and line vty commands.

Change-Id: I52e481dbf4778dd187ce6b67d879a04ef61e8b47
2017-09-08 23:38:06 +00:00
Neels Hofmeyr 3a8e723a0d rename mgcpgw_client_* to mgcp_client_*
The name "mgcpgw_client" referred to an MGCP gateway, which is rather an MGW
(Media Gateway). But this client code is more generally a client for the MGCP
protocol, independently from what the server program is called.

Rename the files as well as the function prefixes to drop the "gw". It is
purely cosmetic and not strictly necessary, but a good point in time for fixes
like this.

osmo-msc build will be adjusted by I093ad02ca0e532f659447c785e09678b3e6f220d.
osmo-bsc build will be adjusted by I6402c7cbe58dacae7630f7f03819f8102e54c699.
These should be applied right after this here is merged to avoid fallout.

Change-Id: I99f7faab637cfcc22ece64a1dbcbe590f2042187
2017-09-08 23:37:46 +00:00
Neels Hofmeyr 97df691307 separate libosmo-mgcp-client from mgcp server code
When osmo-mgw is built --with-mgcp-transcoding, linking the mgcp library
also requires linking libgsm, even though e.g. osmo-msc never use it.
Separate the MGCP client code from the MGCP server code to avoid this dep.

The mgcp client code does use some definitions from mgcp.h and mgcp_common.c.
For simplicity, link mgcp_common.c in both libosmo-legacy-mgcp as well as
libosmo-mgcp-client. That means it is not possible to link both
libosmo-legacy-mgcp and libosmo-mgcp-client in the same binary because of
duplicate symbols, but currently that is sufficient. (An alternative would be
code dup or yet another libosmo-mgcp-common library.)

Add libosmo-mgcp-client to debian packaging.

Related: OS#2488
Change-Id: I8e0b2d2a399b77086a36606f5e427271c6242df1
2017-09-05 20:56:27 +00:00
Neels Hofmeyr d049a66b79 rewrite README
Change-Id: I84cba73b4366c6b403f7da587f46cf621e58c33f
2017-09-04 02:36:56 +02:00
Neels Hofmeyr 48dd6c3e73 debian: fix VCS links, tweak descriptions and copyright
Change-Id: I4a444cf40839c20a0d3d5237f9d4d01d71e01d60
2017-09-04 02:36:55 +02:00
Neels Hofmeyr 7eaeb5a416 drop files unrelated to osmo-mgw
These either remain from openbsc.git or slipped in while applying recent
patches from openbsc.git and do not belong in osmo-mgw.

The ctrl_test_runner.py from openbsc.git still sticks around, but osmo-bsc_mgcp
has no CTRL interface (yet). If it gets one, we can re-add the
ctrl_test_runner.

Change-Id: I623ba8c053bef91a327e58de214e05f0d6768605
2017-09-04 02:05:37 +02:00
Philipp Maier 2fb853fb35 log: output message content also on retransmissions
When a duplicate command is sent, the MGCP-GW will interpret this
as a retramsmission and will send the response of the already
executed command again. This response is not printed in the log.

Make sure that also responses, which are retrsnamitted are
displayed in the log

Change-Id: Ic41c2defb521e2f81762d932f8e29f7c8fed06a9
2017-08-30 15:05:06 +02:00
Alexander Couzens bf0ab74b23 rework debian packages support
Remove old leftover from split of osmo-mgw out of openbsc.

Change-Id: I96a6a56c401833d053d48908872fb0474f5aec53
2017-08-30 15:05:06 +02:00
Neels Hofmeyr e9920f24b1 split off osmo-mgw: remove files, apply build, rename
Add vty and logging previously used from libcommon

Rename libmgcp to libosmo-legacy-mgcp and install.

Use DLMGCP, not DMGCP.

Slim down the public mgcpgw_client API, move all elements not actually used by
current callers to private headers / static c.

Depends: libosmocore I09c587e2d59472cbde852d467d457254746d9e67
Change-Id: I71a0a16ebaaef881c34235849601fc40aa12cfd7
2017-08-30 15:04:52 +02:00
Neels Hofmeyr b6f6c23fa1 .gitignore: cosmetic: use globs to ignore test binaries
Change-Id: I840e4333a4cad646d751ebafe7e0ef23e7a9c708
2017-08-30 14:20:17 +02:00
Neels Hofmeyr 73a93bd4ef cosmetic: msc_vlr_tests: drop unused var
Change-Id: I584c0dfffe005597563dbd72fad8a087c554ba3d
2017-08-30 14:20:17 +02:00
Neels Hofmeyr 28295b939c move libiu to osmo-iuh/libosmo-ranap
Remove libiu here, use the functions from libosmo-ranap instead, by applying
the ranap_ / RANAP_ prefix.

Corresponding change-id in osmo-iuh.git is I6a3f7ad15be03fb94689b4af6ccfa828c25f45c0

To be able to run the msc_vlr tests for RAN_UTRAN_IU without Iu client headers
available, add iu_dummy.h, containing mere function signatures that match
iu_dummy.c and a mostly empty struct ranap_ue_conn_ctx.

Make sure we can build with and without --enable-iu: include osmo-iuh headers
only with --enable-iu.

Change-Id: Ib8c4fcdb4766c5e575618b95ce16dce51063206b
2017-08-30 14:20:17 +02:00
Neels Hofmeyr 6542f52dc1 MSC,SGSN: use OSMO_GSUP_PORT == 4222 instead of 2222
In SGSN, actually place the port in the SGSN config by default, so that the
gsup port may now be omitted in the VTY config (the IP address suffices).

Adjust the osmo-sgsn.cfg example.

Depends: I4222e21686c823985be8ff1f16b1182be8ad6175 (libosmocore)
Change-Id: I50f2040e2eb0baacb43849e93cfed10cbc2fc156
2017-08-30 14:20:17 +02:00
Philipp Maier dd9f6cd377 mgcp: add VTY Option to force-realloc endpoints
Currently the force_realloc feature is turnd on and of in a
hardcoded way. This patch makes the option available via VTY.

Change-Id: Ic8740512c5ea0766ff6ceb1c28b9c2b3fe46e75f
2017-08-30 14:20:17 +02:00
Philipp Maier 4b60d0782c Implement AoIP, port to M3UA SIGTRAN (large addition and refactoring)
This was originally a long series of commits converging to the final result
seen in this patch. It does not make much sense to review the smaller steps'
trial and error, we need to review this entire change as a whole.

Implement AoIP in osmo-msc and osmo-bsc.

Change over to the new libosmo-sigtran API with support for proper
SCCP/M3UA/SCTP stacking, as mandated by 3GPP specifications for the IuCS and
IuPS interfaces.

From here on, a separate osmo-stp process is required for SCCP routing between
OsmoBSC / OsmoHNBGW <-> OsmoMSC / OsmoSGSN

jenkins.sh: build from libosmo-sccp and osmo-iuh master branches now for new
M3UA SIGTRAN.

Patch-by: pmaier, nhofmeyr, laforge
Change-Id: I5ae4e05ee7c57cad341ea5e86af37c1f6b0ffa77
2017-08-30 14:20:17 +02:00
Max 58cfd25c2f Use release helper from libosmocore
See
https://osmocom.org/projects/cellular-infrastructure/wiki/Make_a_new_release
for details.

Change-Id: I869395d5c9ab5ec1a487aff15418d1517f47e831
Related: OS#1861
2017-08-30 14:20:17 +02:00
Harald Welte 3d24d2947e Treat SIGTERM just like SIGINT in our programs
When somebody kills the process, it's best to handle the signal
and to use the opportunity for some cleanup.  We always did this
in the NITB on SIGINT, but never on SIGTERM. Let's change it.

Change-Id: Iea6804325a6575ceab5edfd28dd20249462f143b
2017-08-27 17:44:59 +02:00
Harald Welte 4d254dd490 NITB: remove 'help' output about '-a' option that is removed for ages
This option was present in very early versions of the NITB, but
at least since 2011 it is no longer supported.  It's still listed
in --help output, which is wrong.

Change-Id: I1d2cceb588ec5fb34ec5e2c05a7d8c93310bee88
2017-08-27 17:44:59 +02:00
Keith Whyte c7a58cb239 libmsc: Use actual delivery time in delivery reports.
Set the time on the status report to the time the message was delivered, as
this may not be the same as the time when we are delivering the report to the
originating MS.

Change-Id: I9056429d40bf02731f004b7833f1de45a0d1add8
2017-08-27 17:44:59 +02:00
Max 8f282f23c2 gbproxy: log signal value as text
Change-Id: I6ed923f5c60a8d64305f4b8e90d1362d6510e1c5
2017-08-27 17:44:59 +02:00
Max 52c43258e5 gbproxy: log unhandled BSSGP PDU as text
Change-Id: Ibe3c8bd353b3a178e26b0936f25b2e1959f9990c
2017-08-27 17:44:59 +02:00
Pau Espin 0c99bb469f libmsc: Fix wrong handling of user_message_reference parameter
libsmpp34 already converts received TLV integer values to native
endianess in libsmpp34_(un)pack.

Converting them again at receive time swaps the 2 bytes of
user_message_reference, then using a wrong value. As GSM03.40 spec
uses only 1 byte for the id, then only the high byte of the initial
value is used and eventually sent back to the ESME. Again, at that time,
htons() is not needed because libsmpp34 already handles that part.

See OS-#2429 for more details.

Change-Id: If748548a4a223e529a1110c89e483b599b406e8b
2017-08-27 17:44:59 +02:00
Pau Espin ad0161db6c smpp: Fix compilation warning
I already stumbled into 2 compilation environments which had Werror
enabled for -Wmaybe-uninitialized and the build failed, so let's
workaround this warning.

| smpp_openbsc.c: In function 'handle_smpp_submit':
| smpp_openbsc.c:216:9: error: 'sms_msg_len' may be used uninitialized in this function [-Werror=maybe-uninitialized]
|    memcpy(sms->user_data, sms_msg, sms_msg_len);
|          ^
| smpp_openbsc.c💯15: note: 'sms_msg_len' was declared here
|   unsigned int sms_msg_len;
|                ^
| cc1: some warnings being treated as errors

Change-Id: I0901ddadb5f72e1585cb1797ac22c8ab95e83146
2017-08-27 17:44:59 +02:00
Pau Espin 3671968824 sgsn_test: Fix wrong definition of wrap func
Commit 058cd573d8 added 2 new pointer parameters to
gprs_subscr_request_auth_info, but forgot to update wraps of the
function in sgsn_test.

I catched this today because openbsc build test sgsn_test was failing.
Closed look up to the logs showed:
Assert failed (auts != NULL) == (auts_rand != NULL) openbsc/openbsc/src/gprs/gprs_subscriber.c:791

Change-Id: Ie9e4af6da0339536fb20ca0b7bbcf6f485bd522c
2017-08-27 17:44:58 +02:00
Keith Whyte 4a1e442daa LIBMSC: Use sms->text, not sms->user_data to construct report body
gsm_04_11.c sms_report_alloc()

Use the sms->text, not the sms->user_data to construct the report body.
This also prevents the potential output of non printable characters to
the log and or vty.

Change-Id: Id51bc9483ad6f52d6da74135605cfd12434c7c96
2017-08-27 17:44:58 +02:00
Keith Whyte 9c10f4a9dc LIBMSC: Place correct dst address in status report
gsm_04_11.c: gsm340_gen_sms_status_report_tpdu()

When we construct the status report PDU, use sms->src
instead of sms->dst as the destination address
This way we tell the MS that the message was delivered
to the destination and not to itself.
This is relevant for phones that display a textual
representation of the delivery report.

Change-Id: I2d4f87ac777465de9bfb5a775a789a2691755ee9
2017-08-27 17:44:58 +02:00
Pablo Neira Ayuso 3d80064c59 libmsc: use SMPP34_DELIVERY_RECEIPT_* in libsmpp34
Use new definitions in libsmpp34 to set the registered_delivery field
accordingly, as provided by I5b3afff1b3b77cccd949e0606914c7ac3ba6114c.

Moreover, do not set this header field to zero if status reports are
off, the deliver_t structure has been already zeroed so this not
required.

Change-Id: Ie78e17323796120f576b9c0e1bc5ccc32da8ee12
2017-08-27 17:44:58 +02:00
Harald Welte 52bdd62eb3 increase libsmpp34 version requirement to 1.12
Only 1.12 contains some of the #defines that we're using with recent
commits.

Change-Id: I3743b10a1a5d2f1d42a61204273c1d00dc22b600
2017-08-27 17:44:58 +02:00
Harald Welte d0d62499c3 Migrate from gprs_apn_to_str() to libosmocore osmo_apn_to_str()
In 2015, Jacob moved/copied related functions to libosmocore, but
for some reason didn't remove the copies here.  Let's follow-up on
that and remove duplicated code.

The libosmocore commit introducing osmo_apn_to_str() was
8114294bf29ac6e44822c0ae43d4b0819f11b022

Change-Id: I7315ffcbed8a54cca2056f313bb7783ad82d0ee9
2017-08-27 17:44:58 +02:00
Harald Welte 4a6c56bbfb sgsn_vty: Don't assume pdp->lib is always valid
We can only print libgtp pdp information if a library context is
attached to this pdp context.  This is not always the case,
particuarly during some teardown scenarios.

Change-Id: Ia3184877f9709db65f5f93a98403f2ef5b04a8ca
2017-08-27 17:44:58 +02:00
Harald Welte dea26c68e4 Fix gsm_pchan2chan_nr() to use RSL_CHAN_OSMO_PDCH
When converting from GSM_PCHAN_PDCH, we should generate
a RSL channel number IE with the osmocom extension
RSL_CHAN_OSMO_PDCH rather than claiming it is a regular
TCH/F channel.

This is important as this function is used by
osmo-bts, too - and it decides which channel number IE is
put in the GSMTAP header for both GSMTAP tracing as well
as the GSMTAP based osmo-bts-virtual.

In order to avoid any unintended effect on libbsc,
we make sure to modify rsl_ipacc_pdch_activate() to
always use GSM_PCHAN_TCH_F in related RSL message.

Change-Id: Ie34219e64a6d89da4a79f2db8ec73d1909fb8280
2017-08-27 17:44:58 +02:00
Harald Welte 4a6d8d95a4 SGSN: Fix RAN information exposed on GTP during PDP CTX CREATE
In the PDP Context Create from SGSN to GGSN, we include information
about the RAN type (GERAN/UTRAN) and the Cell of the MS. This was
all hard-coded to GERAN, and wasn't updated when we added UTRAN
support to the SGSN.

Change-Id: I6c79e42c5e08b28fe8182555302a5505fbbaa313
2017-08-27 17:44:58 +02:00
Pau Espin c5f60fb64e mgcp: Fix uplink activation of Osmux stream
Commit 5754206379 introduced
OSMUX_STATE_NEGOTIATING to fix a race condition present in osmo-bsc_nat.
However, after this change osmo-bsc_mgcp cannot switch to
OSMUX_STATE_ACTIVATING anymore, which means during osmux_send_dummy time
it won't call osmux_enable_endpoint(), which in turn won't set endp type
to MGCP_OSMUX_BSC.

If MGCP_OSMUX_BSC is not set, uplink streams are sent using regular RTP
instead of Osmux not matter it is enabled in config or not.

Change-Id: Ibcb59aa1ca25408f82cc88c2d5b81177b5f276dc
2017-08-27 17:44:58 +02:00
Ivan Kluchnikov 02da674ed4 handover_logic: set correct link to bts for subscriber_connection in case of moving this connection to another bts
In case of successful completion of handover gsm_subscriber_connection could be moved from one bts to another,
so connection link to bts should be replaced by link to bts, which owns new_lchan.
This bug was detected, because conn->bts->nr is used in call control log messages
and wrong number of bts was observed in these messages after handover.

Change-Id: Idc7dd412b7580c451e716b73ef7549826c60b0d9
2017-08-27 17:44:58 +02:00
Pau Espin 569dc7b6d8 mgcp_osmux: Remove unused parameter
Change-Id: Icb1e7cb15fe04642578f5292124ebc1eac9c9aa3
2017-08-27 17:44:58 +02:00
Alexander Chemeris ff4cb11e17 libcommon: Fix log output for bts>0.
Fixes regression probably introduced in c696cc28.

For bts>0 logging doesn't show bts number correctly when printing lchan
identification string - it will always show it as "bts=0". The reason for
this is that the identification string is cached before bts->nr value is
set to a proper value.

This patch sets bts->nr as part of the first step of the bts structure
initialization, before caching happens thus making sure the cached
identification string is cached with the correct values.

Change-Id: I61c18a7f021fcb1ec00d34a745f4e3ab03416c2d
2017-08-27 17:44:58 +02:00
Pablo Neira Ayuso 03a3cc7ba5 libmsc: use new smpp34 esm_class definitions
Replace magic numbers by esm_class definitions, which
have been added to latest libsmpp34 in Change-Id
I91afd8b462b8fd3b2c4c5b54f4eeb7ec5b730b65

Change-Id: I6c458690da60c8f3637680efbd718f6e8c6feb4c
2017-08-27 17:44:58 +02:00
Pablo Neira Ayuso e802f1a54f libmsc: use smpp34_tlv_for_each() to avoid suboptimal TLV handling
submit_to_sms() now handles two TLVs, so find_tlv() is suboptiomal and
it can be removed, since it would result in two passes on the TLV list.
Use new smpp34_tlv_for_each() helper to iterate over the list of TLVs
that is available since I446929feed049d0411e1629ca263e2bc41f714cc.

Change-Id: I53a65164a6cc4abc6bf57d9a8dc275cf21c90222
2017-08-27 17:44:58 +02:00
Pau Espin 1f9a576cdc libmsc: Remove comment not applying anymore
The change-id I7276d356d805a83ebeec72b02c8563b7135ea0b6 added msg_ref to
the databse but forgot to remove the comment stating it's not being
stored.

Change-Id: I204f098c8f2a480405446113e2181b2c53700cf3
2017-08-27 17:44:58 +02:00
Pablo Neira Ayuso bc822624e4 libmsc: gsm340_gen_oa_sub() may return negative value
gsm340_gen_oa() returns a negative value if the output buffer that the
caller passes is too small, so we have to check the return value of this
function.

Fixes: CID 174178
Fixes: CID 174179
Change-Id: I47215d7d89771730a7f84efa8aeeb187a0911fdb
2017-08-27 17:44:58 +02:00
Pablo Neira Ayuso b31d2c62a6 libmsc: support GSM 03.40 status report for nitb
This patch adds support for GSM 03.40 in nitb mode.

          MS         GSM 03.40          SMSC
           |                            |
           |         SMS-SUBMIT         |
           |--------------------------->|
           |     GSM 04.11 RP-ACK       |
           |<---------------------------|
           |         SMS-DELIVER        |
           |<---------------------------|
           |     GSM 04.11 RP-ACK       |
           |--------------------------->|
           |     SMS-STATUS-REPORT      |
           |<---------------------------|
           |     GSM 04.11 RP-ACK       |
           |--------------------------->|
           |                            |

Change-Id: I5cc7bb4ebadde0940f44d10c3df34707b0615160
2017-08-27 17:44:58 +02:00
Pablo Neira Ayuso 3c8d627a08 libmsc: handle delivery ack via SMPP SUBMIT SM / send GSM 03.40 status report
This patch adds gsm340_sms_send_status_report_tpdu() to build a
status-report. Moreover, set sms->report field if we see a SMPP
SUBMIT_SM with Delivery Acknowledgment esm_class, so this identifies
that this is a delivery report.

    MS        GSM 03.40           SMSC       SMPP 3.4               ESME
     |                             |                                |
     |                             |           SUBMIT-SM            |
     |                             |    esm_class = Delivery Ack    |
     |                             |<-------------------------------|
     |                             |         SUBMIT-SM-RESP         |
     |                             |------------------------------->|
     |                             |                                |
     |     SMS-STATUS-REPORT       |                                |
     |<----------------------------|                                |
     |     GSM 04.11 RP-ACK        |                                |
     |---------------------------->|                                |
     |                             |                                |

There is a FIXME message in this patch, that I just copied from
gsm340_gen_sms_deliver_tpdu() since TP-MMS is not supported by OpenBSC.

Change-Id: Ib70e534840308ed315f7add440351e649de3f907
2017-08-27 17:44:58 +02:00
Pablo Neira Ayuso 868e442bd0 utils: smpp_mirror: bounce Delivery Receipts as Delivery Acknowledgments
Simple patch to test the new status-report support code, remove previous
code before Delivery Acknowledgement support was in place. Use
LOGL_DEBUG for logging messages here as suggested by Neels and Harald.

Change-Id: I877e228d8e174430f700631edbf9955972da7892
2017-08-27 17:44:58 +02:00
Pablo Neira Ayuso b343807cf8 libmsc: update database to accomodate SMS status-report fields
SMPP DELIVER_SM messages with esm_class = Delivery Receipt need to send
this message reference (that the mobile phone allocates) to the ESME.
Thus, the ESME propagates it via SUBMIT_SM with esm_class = Delivery
Acknoledgment so that the SMSC sends the GSM 03.40 status-report to the
origin including this. Given this field is useful for status-reports, we
need to store it in the HLR database.

Moreover, we need a new field that specifies if the entry represents a
SMS status-report, to do the right handling from the gsm411_send_sms() -
such new handling comes in a follow up patch entitled "libmsc: handle
delivery ack via SMPP SUBMIT SM / send GSM 03.40 status report".

This patch includes the migration routines to the new database schema
revision 5, it's quite a bit of dbi boilerplate code - copied-pasted and
adapted.

Change-Id: I7276d356d805a83ebeec72b02c8563b7135ea0b6
2017-08-27 17:44:58 +02:00
Pablo Neira Ayuso be89bc7278 libmsc: add support for SMPP delivery receipts
If the mobile phone requests a status report via SMS, send a DELIVER_SM
with esm_class = Delivery Receipt to ESME to indicate that the SMS has
been already delivered to its destination.

    MS        GSM 03.40           SMSC       SMPP 3.4               ESME
     |                             |                                |
     |       SMS-DELIVER           |                                |
     |<----------------------------|                                |
     |     GSM 04.11 RP-ACK        |                                |
     |---------------------------->|                                |
     |                             |           DELIVER-SM           |
     |                             |  esm_class = Delivery Receipt  |
     |                             |------------------------------->|
     |                             |         DELIVER-SM-RESP        |
     |                             |<-------------------------------|
     |                             |                                |

This patch implements "Appendix B. Delivery Receipt Format" as specified
in the SMPP 3.4 specs. This string is conveyed in the SMS message as
data, and it is only meaningful to the ESME, for logging purposes. The
"submit date" and "done date" are not yet set, and other fields are just
sent with dummy values, so they are left to be finished as future work.

The new SMPP TLV tag TLVID_user_message_reference is added to the SMPP
messages inconditionally now since this information is required by
delivery-reports to associate the status-report with the original SMS.

Change-Id: Ic1a9023074bfa938099377980b6aff9b262fab2a
2017-08-27 17:44:58 +02:00
Pablo Neira Ayuso 14af83239a utils: smpp_mirror: reflect message reference TLV
Useful to test the delivery receipt support. This TLV contains the
GSM03.40 message reference.

Change-Id: I1b0abaa7e06ffe1bd2242c70813d8b70e9fa954f
2017-08-27 17:44:58 +02:00
Pablo Neira Ayuso ff6900943a utils: smpp_mirror: temporarily munch SMPP delivery receipts
Just munch and log SMPP delivery receipts by now, don't mirror this, it
is going to break things in openbsc.

Follow up patch removes this and mirrors this SMPP message as a
SUBMIT_SM with esm_class = Delivery Acknowledgement.

Change-Id: I78e93bc4034679e238c8642ccf6a0e844b1d6d8b
2017-08-27 17:44:58 +02:00
Pablo Neira Ayuso f49519ef46 utils: smpp_mirror: set registered_delivery field in SMPP SUBMIT_SM
To test delivery reports using this utility.

Change-Id: I0e477407531fdd4d906e53c9b5a48a79a239966f
2017-08-27 17:44:58 +02:00
Pablo Neira Ayuso 4d62a999f9 libmsc: missing bit shift in status report flag when stored in sms object
So we just store 0 or 1 depending on what the mobile phone requests.

Change-Id: Idb7d5594219c0e458ccb561383a59604bc1a4201
2017-08-27 17:44:58 +02:00
Pablo Neira Ayuso 92d6dcbbaf libmsc: report status report request flag from SMPP SUBMIT_SM
Restore the sms status report request flag from SUBMIT_SM.

Change-Id: Iac05252253f8933a3875b4904599b7a225191a4b
2017-08-27 17:44:58 +02:00
Pablo Neira Ayuso d11e8f358f libmsc: set registered_delivery field in SMPP 3.4 DELIVER_SM messages
Propagate the status report request field to the SMPP message through
the registered_delivery field, so the ESME knows that the mobile phone
is asking for explicit delivery acknowledgment is required. See SMPP 3.4
specs section 5.2.17.

Change-Id: I59af60fa89cd10ae973c5e122789e3e03e3728ee
2017-08-27 17:44:58 +02:00
Neels Hofmeyr f694033bc6 timer vty: also print the default value in cmd doc
Rationale: allows seeing all timer defaults at once by doing

  OsmoBSC(config-net)# timer ?

Before, defaults are visible only by doing on each timer:

  OsmoBSC(config-net)# timer t1234 <tab>

Change-Id: I8259234e5c62e058dde56d531071440bbab11462
2017-08-27 17:44:58 +02:00
Neels Hofmeyr 06e14c6b72 vty: add 'default' keyword to timer config
Change-Id: I4e837e8bedfad7ac4fd50048ecb016ddb37c2397
2017-08-27 17:44:58 +02:00
Neels Hofmeyr d7d926620c cosmetic: vty for timers: remove obsolete range check
The VTY parsing already ensures the parameter range being 1..65535, no need to
check the range again.

Change-Id: I1cffa5b01cd5c589f1e42998e32135f1da8c960b
2017-08-27 17:44:58 +02:00
Pablo Neira Ayuso ac64f87708 libmsc: move gsm340_rx_sms_submit() to sms_route_mt_sms()
Move the sms message-type-identifier (mti) handling away from the
routing logic. This patch allows us to reuse the sms_route_mt_sms()
function in a follow up patch for sms reports send through SMPP
DELIVER_SM with esm_class = Delivery Receipt whose Change-Id is
Ic1a9023074bfa938099377980b6aff9b262fab2a.

Change-Id: I3f3d30e0762b91e2099243b0be1a4b67cbb5e9c0
2017-08-27 17:44:58 +02:00
Pablo Neira Ayuso a5d7e61308 libmsc: remove 'deferred' parameter in sms_route_mt_sms()
No need to cache the sms object, just cache what we need into the
smpp_cmd structure. This simplifies what that I introduced in
93ffbd0029 ("libmsc: send RP-ACK to MS after ESME sends SMPP
DELIVER-SM-RESP").

Change-Id: Iba5f864f9bb963baff95969e306b1b7cff00c1e3
2017-08-27 17:44:57 +02:00
Pablo Neira Ayuso 4bb662b473 libmsc: remove duplicate lines in deliver_to_esme()
This code is accidentally doing the same thing twice, remove it.

Change-Id: I68087a850399e22951d2407e4d8a09c671a775c9
2017-08-27 17:44:57 +02:00
Pablo Neira Ayuso d0e4764ecd libmsc: remove dead code in sms_route_mt_sms()
The following branch:

	if (!rc && !gsms->receiver)
		rc = GSM411_RP_CAUSE_MO_NUM_UNASSIGNED;

at the end of sms_route_mt_sms() always evaluates false.

Just a bit before, in such function, we have this:

        if (!gsms->receiver) {
                ...
 #ifdef BUILD_SMPP
                ...
 #else
                ...
 #endif
                return rc;
        }

So, if there is no receiver, we just stop running code and return the RP
cause via the rc variable. Same applies to the smpp_first check under
the BUILD_SMPP ifdef (that I have removed in this snippet to keep this
commit message small).

Change-Id: Ic3502b5b169bc7a73a67fd6ff53d8b6c0dc045c8
2017-08-27 17:44:57 +02:00
Pablo Neira Ayuso 20515896b3 libmsc: do not leak pending SMPP command object on error path
Make sure the SMPP command object is released on errors.

Change-Id: I474584425d23fb379a9d71b33e29ac0e24f01e61
2017-08-27 17:44:57 +02:00
Pablo Neira Ayuso f226bd5236 gsm_04_11: get rid of unused parameter in sms_route_mt_sms()
This parameter is unused, remove it.

Change-Id: I797abce3f91447e8f397c7cf726db7425479fe0e
2017-08-27 17:44:57 +02:00
Holger Hans Peter Freyther b65195fa16 sgsn: Convert cch_pdp to host order for libgtp
libgtp is calling gtpie_tv2 which will convert this uint16_t from host
to network order. So far libosmogsm and the sgsn treated the charging
characteristics as opaque data. So when moving from byte array to the
uint16_t do the swapping.

Change-Id: I977aec2e2f8d57802e45f591754e5733562d5c2a
2017-08-27 17:44:57 +02:00
Harald Welte 0854d6b156 remove code disabling T3109 if configured to 0
We no longer permit timers with a 0 value, so this case can never
happen.  Also, if it should happen, I'd rather have a timter expiring
immediately (and breaking something) than not being started in the
first place.

Change-Id: Ibfcdd3ddc0155caee89c501498329bde247621a0
2017-08-27 17:44:57 +02:00
Harald Welte fad3309556 bsc_vty: Don't allow timers of zero (0)
It typically doesn't make sense to configure any of the GSM RR timer
to 0 (Seconds).  In fact, accidentially configuring any of the timers
to zero might have severe side effects, such as "stuck channels"
described in https://osmocom.org/issues/2380

Change-Id: I517828f2f0c80ec01cb63648db2626f17a67fe57
2017-08-27 17:44:57 +02:00
Harald Welte d5429bb79b GSM timers: User reasonable defaults; don't save if equal default
A number of the GSM timers (including T3109) had no reasonable
default values if not specified in the VTY / config file.  Together
with unconditional writing to the config file, this created
config files with a persistent setting for important timers as '0'.

To make things worse, many of our example cofig files suffered from the
same problem.

Let's avoid this from happening by
* having reasonable defaults if nothing specified in the config file
* conditionally savingg timers only if they differ from default
* reject any timer values that state zero during start-up (see previous
  commit)

Change-Id: Iaac0bfca423852b61d8b9eb1438157ef00d0d8c8
Closes: OS#2380
2017-08-27 17:44:57 +02:00
Harald Welte 3fb8a7ba87 bsc_vty: Add VTY command to test CTRL TRAP feature
Using this new command (introduced in OsmoBSC + OsmoNITB), you can
simulate the generation of TRAP events for testin purposes.

start the control interface monitor as an example client program:
	./openbsc/contrib/bsc_control.py -m -d localhost -p 4249

then start OsmoBSC or OsmoNITB, telnet to the VTY and enter 'enable'
mode and issue the following (example) command:
	ctrl-interface generate-trap my.foo.var 2342

As a result, on the bsc_control.py you will see:
	Got message: TRAP 0 my.foo.var 2342

Change-Id: Ib1d2ec38290dc94797c1b365d9b733e5215ab7d1
2017-08-27 17:44:57 +02:00
Harald Welte bbb17f0148 gtphob: check for missing result of rate_ctr_group_alloc()
In case the counter group allocation fails, we must handle this
gracefully and fail the allocation of the parent object, too.

The recent change (Id I7dad4a4d52fe05f6b990359841b4408df5990e21) seems
to have missed one instance, so let's follow-up.

Change-Id: I1ee9e3d26dcc18e7f979fd9a786162cbcc50942c
Related: OS#2361
2017-08-27 17:44:57 +02:00
Harald Welte ca52991d6e gsm_bts_trx_set_system_infos(): Disable non-existing SI
If we previously had a given SI present/active, we must send a
zero-length BCCH FILLING for that SI type to the BTS to stop it from
further transmitting this SI.

Change-Id: I33e356e2fa3a69efac9080813e3e9ef4e6438ed1
Closes: OS#2368
2017-08-27 17:44:57 +02:00
Harald Welte 8008ac0175 RSL: Allow disabling of BCCH/SACCH filling for given SI type
If we want to instruct the BTS to stop sending a given SI, we must be
able to send the respective BCCH INFO / SACCH FILLING with a header but
without any L3 data IE.  This patch enables the related functions to do
this whenever their data argument points to NULL.

Change-Id: I88b85614951a108574f05db3b706884afe7e87a9
2017-08-27 17:44:57 +02:00
Harald Welte 4755091a8a Fix regression causing loss of static system-information messages
In commit 8b1a2f8cd7 we started to
initialize bts->si_valid to 0.  This means we are skipping the manually
configured static system information.

Instead, we have to initialize bts->si_valid to bts->si_mode_static,
i.e. start with those that are static and not to be auto-generated.

Found while developing
http://git.osmocom.org/osmo-ttcn3-hacks/tree/sysinfo

Change-Id: Iab9cc93cf6d54560a72cc393cc3721a8d10e04bf
Closes: #2367
2017-08-27 17:44:57 +02:00
Harald Welte 9282db8be8 check for missing result of rate_ctr_group_alloc()
In case the counter group allocation fails, we must handle this
gracefully and fail the allocation of the parent object, too.

RelateD: OS#2361
Change-Id: I7dad4a4d52fe05f6b990359841b4408df5990e21
2017-08-27 17:44:57 +02:00
Harald Welte d36641a832 libbsc: Add VTY command to re-send the SYSTEM INFORMATION to BTS
This is useful if you are updating some configuration parameters which
affect the content of the SYSTEM INFORMATION messages.  Currently, we
only send them at the time the RSL connection is established (i.e. when
the BTS is initialized), so if you change something, you need to bring
down and re-start the BTS.

Using the newly-introduced "bts <0-255> resend-system-information"
command, you can re-generate + re-send SYSTEM INFORMATION without
bringing the BTS down, i.e. without any radio carrier downtime.

Change-Id: I326df47de98f6d36c9a4d2d5475225d1e62bafb5
2017-08-27 17:44:57 +02:00
Harald Welte 4331f25e42 bsc_api: Fix copy+paste error in printing name of RR STATUS PDU
Change-Id: I0ef78ef046e4850346569f750693e12938b50ab5
2017-08-27 17:44:57 +02:00
Benoit Bolsee b68ad96406 transaction: reject calls from unidentified subscribers
A valid subscriber is indespensible when allocating a new
transaction. Return NULL if no subscriber is supplied. This
will cause unidentified subscribers to be rejected.

Note: Under normal conditions, the problem does not occour,
but it is still possible that a misbehaving MS might trigger
the problem by sending a SETUP command before authenticating
the subscriber. (unencrypted networks)

Change-Id: Ia8739b6e329ab02c0064270d02ad1d6ee245520d
2017-08-27 17:44:57 +02:00
Max 6571561192 Fix BTS attribute requests
* fix BTS numbers: use 0 to indicate given BTS and 0xFF to indicate all
  BTS' as it's explained in 3GPP TS 52.021 §9.3.
* only request attributes from supported (OsmoBTS) types

Change-Id: I8f43055c38000248033a8ff9ddaf0910d68d794b
Related: OS#2317
2017-08-27 17:44:57 +02:00
Harald Welte 1016fb5c16 Add VTY commands for experimentation with TS 04.14 commands
TS 04.14 (TS 44.014) specifies a series of commands specific to
conformance testing.  Let's add some VTY commands to play (at least
initially) with closing and opening voice loops in the MS.

Change-Id: I38b1ee9dbf26f5689c38cb83b1b3c5e9eaad7678
2017-08-27 17:44:57 +02:00
Harald Welte 48c23b6416 Support for TS 04.14 conformance test commands
Change-Id: Ib27edbfc8ccdedf00589ec715ced7bed435fa94c
2017-08-27 17:44:57 +02:00
Alexander Chemeris 9a9d0560b2 libmsc: Fix VTY output for handover counters.
Handover countrs belong to BSC, but we mistakenly take values from MSC counters.

Change-Id: I9512330f2e91d2f526751c5228e6e8e0fe17d579
2017-08-27 17:44:57 +02:00
Holger Hans Peter Freyther c3bd466259 sgsn: Fill the cch_pdp with a value coming from the tlv structure
For some GGSNs we need to insert the PDP Charging Characteristics
that were returned. We receive these values from GSUP and will
fill them into the tlv structure when finding the ggsn context.

Change-Id: I1725bfd2403d29ce3550bfcd6fcc1498426ef906
2017-08-27 17:44:57 +02:00
Benoit Bolsee e44dbcf30a 04.08: find a portable way to obtain the timezone offset
Portable GMT offset calculation to display correct
time on GSM.

Change-Id: I673f17af2550c9708c4771e4ea4eafbbfafbb824
2017-08-27 17:44:57 +02:00
Harald Welte d4ee5923c9 jenkins.sh: Proper error message if local environment isn't set up
Change-Id: I79c2302365824d9c8783dadfa378c8eaa07e2ee7
2017-08-27 17:44:57 +02:00
Benoit Bolsee dc6a7cd406 smpp: fix return cause
Return cause 38 when default SMPP route is unavailable. This
is better than cause 1.

Change-Id: If3241d50a78fa611981e55fef6ae4c72b0a2a167
2017-08-27 17:44:56 +02:00
Pau Espin 8fd871143f smpp_smsc.c: Log on sending deliver_sm message
Change-Id: Ie16294df6d5bc0065f8d2b49320ead61f535f271
2017-08-27 17:44:56 +02:00
Neels Hofmeyr 1a232bd900 Use value string check from osmo-ci
Necessary since libosmocore I513835be2d931d0a931cdfc996f361a451bc1a15
removes the script from libosmocore/contrib.

Change-Id: I02d7e1c0151c687fd9341d21a09ca15cbf5a1938
2017-08-27 17:44:56 +02:00
Daniel Willmann 2e7e4b93a0 examples/sgsn: Use osmo-hlr with auth-policy remote by default
For the vty tests, add osmo-sgsn-accept-all.cfg (that does not need an HLR) and
use in vty_test_runner.py, otherwise the 'show sgsn' command will reply that it
could not connect to the HLR, failing the vty test which expects empty.

Change-Id: Ie3b2013198d3e2b780a4e31c36b89b58129dcacd
2017-08-27 17:44:56 +02:00
Daniel Willmann 30f532b9bd contrib: Change systemd requirements so the services connect properly
Change-Id: Ib1b3c640ddd81927a60ee307c4b0cb90fd83eebe
2017-08-27 17:44:56 +02:00
Daniel Willmann 6424b5633c examples: Change IP address of config files
This helps in providing 3G software packages for the sysmoNITB hardware, which
uses 10.23.24.1 for SGSN and 10.23.24.2 for GGSN.

However, in order to not break the python tests, the osmo-sgsn.cfg example
still uses 127.0.0.1 as local address.

Change the GGSN address to 127.0.0.2, because SGSN and GGSN cannot co-exist on
the same address (the GTP port number is fixed by spec: no IE to communicate a
differing port, so it has to be the standard GTP port for both).

Change-Id: Ie3a25f6771ed6e620cb2b315638c622a9a24e530
2017-08-27 17:44:56 +02:00
Daniel Willmann 075fc11fce contrib: Add osmo-msc service file
Change-Id: Ifdaf4107167c84af8a616f4ee792d5a34495564b
2017-08-27 17:44:56 +02:00
Neels Hofmeyr 717c7b9692 04.08: log protocol discriminators and message types by name
On incoming 04.08 messages, we log only the protocol discriminator in
decimal. Enhance: log pdisc and message type in hex, and also log the
protocol and message type as human readable string.

Also adjust the msc_vlr tests' log statements for wrapped rx/tx functions
of dtap from/to the MS.

Adjust the expected output of msc_vlr_tests.

Change-Id: Ida205d217e304337d816b14fd15e2ee435e7397d
Depends: libosmocore change-id I0fca8e95ed5c2148b1a7440eff3fc9c7583898df
2017-08-27 17:44:56 +02:00
Neels Hofmeyr 10d64d5d66 mgcp: hack RAB success from nano3G: patch first RTP payload
The ip.access nano3G needs the first RTP payload's first two bytes to read hex
'e400', or it will reject the RAB assignment. Add flag
patched_first_rtp_payload to mgcp_rtp_state to detect the first RTP payload on
a stream, and overwrite its first bytes with e400. This should probably be
configurable, but seems to not harm other femto cells (as long as we patch only
the first RTP payload in each stream). Only do this when sending to the BTS
side.

Related: OS#2459
Change-Id: I5eff04dcb0936e21690e427ae5e49228cd459bd4
2017-08-27 17:44:56 +02:00
Neels Hofmeyr 815124952b fix msc_vlr tests after libosmocore uses localtime for SMS
libosmocore change-id I4efdb1eaae43aced33961b64d4f14b0040321c10 changes the
gsm340_gen_scts() from gmtime to localtime, meaning that by feeding a mere zero
as timestamp, we get different results depending on the local machine's
timezone setting. Instead of calling gsm340_gen_scts() with zero, simply write
a bunch of bytes as time so that the tests get identical SMS bytes every time.

Change-Id: I8a50e8963dce80609749571b61fc6ffe1c54660c
2017-08-27 17:44:56 +02:00
Neels Hofmeyr a1756f320a Implement IuCS (large refactoring and addition)
osmo-nitb becomes osmo-msc
add DIUCS debug log constant
add iucs.[hc]
add msc vty, remove nitb vty
add libiudummy, to avoid linking Iu deps in tests
Use new msc_tx_dtap() instead of gsm0808_submit_dtap()
libmgcp: add mgcpgw client API
bridge calls via mgcpgw

Enable MSC specific CTRL commands, bsc_base_ctrl_cmds_install() still needs to
be split up.

Change-Id: I5b5b6a9678b458affa86800afb1ec726e66eed88
2017-08-27 17:44:56 +02:00
Neels Hofmeyr 069e53fbb5 sgsn init: pass sgsn_config pointer to sgsn_vty_init(), not sgsn_parse_config
In an upcoming commit, sgsn_vty_init() will require access to the global sgsn
config struct to initialize a generic VTY command with the proper config
destination address, see Change-Id I5b5b6a9678b458affa86800afb1ec726e66eed88.

Change-Id: Ie6b6e5422987586531a898e0c5b867623dbecb0f
2017-08-27 17:44:56 +02:00
Neels Hofmeyr 0e5a7c409c mscsplit: various preparations to separate MSC from BSC
Disable large parts of the code that depend on BSC presence. The code sections
disabled by #if BEFORE_MSCSPLIT shall be modified or dropped in the course of
adding the A-interface.

Don't set msg->lchan nor msg->dst.
Don't use lchan in libmsc.
Decouple lac from bts.

Prepare entry/exit point for MSC -> BSC and MSC -> RNC communication:
Add msc_ifaces.[hc], a_iface.c, with a general msc_tx_dtap() to redirect to
different interfaces depending on the actual subscriber connection.
While iu_tx() is going to be functional fairly soon, the a_tx() is going to be
just a dummy for some time (see comment).
Add Iu specific fields in gsm_subscriber_connection: the UE connection pointer
and an indicator for the Integrity Protection status on Iu (to be fully
implemented in later commits).
Add lac member to gsm_subscriber_connection, to allow decoupling from
bts->location_area_code. The conn->lac will actually be set in iu.c in an
upcoming commit ("add iucs.[hc]").

move to libcommon-cs: gsm48_extract_mi(), gsm48_paging_extract_mi().

libmsc: duplicate gsm0808 / gsm48 functions (towards BSC).
In osmo-nitb, libmsc would directly call the functions on the BSC level, not
always via the bsc_api. When separating libmsc from libbsc, some functions are
missing from the linkage.
Hence duplicate these functions to libmsc, add an msc_ prefix for clarity, also
add a _tx to gsm0808_cipher_mode():
* add msc_gsm0808_tx_cipher_mode() (dummy/stub)
* add msc_gsm48_tx_mm_serv_ack()
* add msc_gsm48_tx_mm_serv_rej()
Call these from libmsc instead of
* gsm0808_cipher_mode()
* gsm48_tx_mm_serv_ack()
* gsm48_tx_mm_serv_rej()
Also add a comment related to msc_gsm0808_tx_cipher_mode() in two places.

Remove internal RTP streaming code; OsmoNITB supported that, but for OsmoMSC,
this will be done with an external MGCP gateway.

Remove LCHAN_MODIFY from internal MNCC state machine.

Temporarily disable all paging to be able to link libmsc without libbsc.
Skip the paging part of channel_test because the paging is now disabled.
Employ fake paging shims in order for msc_vlr_tests to still work.

msc_compl_l3(): publish in .h, tweak return value.  Use new libmsc enum values
for return val, to avoid dependency on libbsc headers.  Make callable from
other scopes: publish in osmo_msc.h and remove 'static' in osmo_msc.c

add gsm_encr to subscr_conn
move subscr_request to gsm_subscriber.h
subscr_request_channel() -> subscr_request_conn()
move to libmsc: osmo_stats_vty_add_cmds()
gsm_04_08: remove apply_codec_restrictions()
gsm0408_test: use NULL for root ctx
move to libbsc: gsm_bts_neighbor()
move to libbsc: lchan_next_meas_rep()
move vty config for t3212 to network level (periodic lu)
remove unneccessary linking from some tests
remove handle_abisip_signal()
abis_rsl.c: don't use libvlr from libbsc

gsm_subscriber_connection: put the LAC here, so that it is available without
accessing conn->bts. In bsc_api.c, place this lac in conn for the sake of
transition: Iu and A will use this new field to pass the LAC around, but in a
completely separate OsmoBSC this is not actually needed. It can be removed
again from osmo-bsc.git when the time has come.

Siemens MRPCI: completely drop sending the MRPCI messages for now, they shall
be added in osmo-bsc once the A-Interface code has settled. See OS#2389.

Related: OS#1845 OS#2257 OS#2389
Change-Id: Id3705236350d5f69e447046b0a764bbabc3d493c
2017-08-27 17:44:56 +02:00
Neels Hofmeyr 2d503d03f4 vlr: LU FSM: enable Retrieve_IMEISV_If_Required
Change-Id: I121b95ad6d5ecb7603815eece2b43008de487a8a
2017-08-27 17:44:56 +02:00
Neels Hofmeyr 29dfc91b93 vlr: place comments on if (0) cases
Change-Id: I56c1e61dedeac01a4e24452feee6616782783d8f
2017-08-27 17:44:56 +02:00
Harald Welte 21b48e96c3 SGSN: Don't indicate GERAN in Iu mode PDP CTX ACT REQ to GGSN
Change-Id: Ifd9ff4342de342475609bad0257a23c50290e23b
2017-08-27 17:44:56 +02:00
Neels Hofmeyr 3728471963 IuPS: explicitly check RAN type; move comment
Change-Id: I054d72590dfb2012f6f8506d3a5f8fd2953194e1
2017-08-27 17:44:56 +02:00
Neels Hofmeyr e7542288bb IuPS: don't require an MM context for Iu Release
Change-Id: I8b4d08b3ee8add1f1d54efb13985eabe0c9d31f3
2017-08-27 17:44:56 +02:00
Neels Hofmeyr 48a0c6a940 SI3: indicate R99+ MSC to GSM MS to enable UMTS AKA
Change-Id: I796e1f4281628061f4522c43c549de9e751bc045
2017-08-27 17:44:55 +02:00
Neels Hofmeyr b6cd7934de cosmetic: make osmo-python-tests dependency more accurate
Change-Id: I4f84a13b7fa6ec4173bdc155e6114d4d7328b619
2017-08-27 17:44:55 +02:00
Neels Hofmeyr 9f52b06975 osmo-nitb: change default db name to sms.db
libvlr now delegates subscriber management to osmo-hlr, so the database no
longer represents a HLR. It basically only stores SMS, so reflect that fact in
the default database name.

Change-Id: I3289d68d3eb63aff940b48a25b584d5e83cd0197
2017-08-27 17:44:55 +02:00
Neels Hofmeyr f817814c68 Add msc_vlr test suite for MSC+VLR end-to-end tests
Change-Id: If0e7cf20b9d1eac12126955b2f5f02bd8f1192cd
2017-08-27 17:44:55 +02:00
Harald Welte 7b423edb56 Use libvlr in libmsc (large refactoring)
Original libvlr code is by Harald Welte <laforge@gnumonks.org>,
polished and tweaked by Neels Hofmeyr <nhofmeyr@sysmocom.de>.

This is a long series of trial-and-error development collapsed in one patch.
This may be split in smaller commits if reviewers prefer that. If we can keep
it as one, we have saved ourselves the additional separation work.

SMS:

The SQL based lookup of SMS for attached subscribers no longer works since the
SQL database no longer has the subscriber data. Replace with a round-robin on
the SMS recipient MSISDNs paired with a VLR subscriber RAM lookup whether the
subscriber is currently attached.

If there are many SMS for not-attached subscribers in the SMS database, this
will become inefficient: a DB hit returns a pending SMS, the RAM lookup will
reveal that the subscriber is not attached, after which the DB is hit for the
next SMS. It would become more efficient e.g. by having an MSISDN based hash
list for the VLR subscribers and by marking non-attached SMS recipients in the
SMS database so that they can be excluded with the SQL query already.

There is a sanity limit to do at most 100 db hits per attempt to find a pending
SMS. So if there are more than 100 stored SMS waiting for their recipients to
actually attach to the MSC, it may take more than one SMS queue trigger to
deliver SMS for subscribers that are actually attached.

This is not very beautiful, but is merely intended to carry us over to a time
when we have a proper separate SMSC entity.

Introduce gsm_subscriber_connection ref-counting in libmsc.

Remove/Disable VTY and CTRL commands to create subscribers, which is now a task
of the OsmoHLR. Adjust the python tests accordingly.

Remove VTY cmd subscriber-keep-in-ram.

Use OSMO_GSUP_PORT = 4222 instead of 2222. See
I4222e21686c823985be8ff1f16b1182be8ad6175.

So far use the LAC from conn->bts, will be replaced by conn->lac in
Id3705236350d5f69e447046b0a764bbabc3d493c.

Related: OS#1592 OS#1974
Change-Id: I639544a6cdda77a3aafc4e3446a55393f60e4050
2017-08-27 17:44:55 +02:00
Harald Welte a183a6ed20 Add libvlr implementation
Original libvlr code is by Harald Welte <laforge@gnumonks.org>,
polished and tweaked by Neels Hofmeyr <nhofmeyr@sysmocom.de>.

This is a long series of trial-and-error development collapsed in one patch.
This may be split in smaller commits if reviewers prefer that. If we can keep
it as one, we have saved ourselves the additional separation work.

Related: OS#1592
Change-Id: Ie303c98f8c18e40c87c1b68474b35de332033622
2017-08-27 17:44:55 +02:00
Neels Hofmeyr 0bc77b1283 jenkins: pass proper configure flags to make distcheck
Enable various components according to the build matrix during make distcheck.
Add python tests, osmo-bsc, nat, ...

Change-Id: Ic724cf61d44409337414dc58c8795896b4b97a8a
2017-08-27 17:44:55 +02:00
Neels Hofmeyr ffebe6e938 fix make distcheck with python tests
- bscs.config needed by the vty tests was not picked up as a dist file, because
  its suffix is not 'cfg'. Rename to *.cfg. Apply this rename in
  vty_test_runner.py and osmo-bsc_nat.cfg.
- Remove restart counters after external tests, otherwise distcheck complains
  about uncleaned files.
- Add contrib/ipa.py to EXTRA_DIST, hence add a Makefile.am to contrib/.
  Otherwise the python tests cannot find that dependency.

Change-Id: I42b55cb1125099afc3a8e3f87c0e398426b2e2a9
2017-08-27 17:44:55 +02:00
Neels Hofmeyr 39a7c75814 logging: auth request: use hexdump without spaces for RAND, AUTN
Change-Id: Ie16bb2c01e770914f411bfb34b523c56ea9fab81
2017-08-27 17:44:55 +02:00
Neels Hofmeyr 4c30529a84 gsup_client: allow passing a unit id to identify with HLR
Before, each GSUP client would contact the HLR with an identical unit id, i.e.
"SGSN-00-00-00-00-00-00", with the result that some messages were sucked off by
the wrong client.

Pass explicit unit name from each gsup client user, so that OsmoMSC is "MSC"
and OsmoSGSN is "SGSN". Hence the HLR can properly route the messages.

Todo: also set some values instead of the zeros.

Unrelated cosmetic change while editing the arguments: gsup_client_create()'s
definition's oap client config arg name mismatched the one used in the
declaration. Use oapc_config in both.

Change-Id: I0a60681ab4a4d73e26fe8f0637447db4b6fe6eb2
2017-08-27 17:44:55 +02:00
Neels Hofmeyr 3eb991ead2 GPRS/IuPS: remove all 3G authentication dev hacks
UMTS auth works now with the external OsmoHLR.

Change-Id: Ie42945bb687b077fd0ee430c2711d19782151610
2017-08-27 17:44:55 +02:00
Neels Hofmeyr 079d4e0fe9 git-version-gen: look for .git in ./, not ../
Change-Id: Ic71cfb8dde0a43325b50c75aae1e6ef3c3008501
2017-08-27 17:44:55 +02:00
Neels Hofmeyr 9e95604394 join openbsc/.gitignore with .gitignore
Change-Id: Ib2120592749e85a4d13f6668e198857e3bddcf1e
2017-08-27 17:44:55 +02:00
Neels Hofmeyr 0c0d70582c jenkins: apply rename to osmo-msc in log marker
Change-Id: I8ca9a1a8bdb5b9615df5f19f0c1017cb9383f6ee
2017-08-27 17:44:55 +02:00
Neels Hofmeyr 85929a7be7 move openbsc/* to repos root
This is the first step in creating this repository from the legacy openbsc.git.

Like all other Osmocom repositories, keep the autoconf and automake files in
the repository root. openbsc.git has been the sole exception, which ends now.

Change-Id: I9c6f2a448d9cb1cc088cf1cf6918b69d7e69b4e7
2017-08-27 17:44:55 +02:00
Neels Hofmeyr 68bd8e434a jenkins: fix build of --enable-iu: use osmo-iuh tag 'old_sua'
We are building with libosmo-sccp tag 'old_sua' until the new sigtran has
been applied. Since osmo-iuh commit
  0f88c110093935305143987638e46dc6db304a3e
  "migrate osmo-hnbgw to libosmo-sigtran's SCCP/M3UA"
osmo-iuh requires libosmo-sccp master. A similar 'old_sua' tag is in place in
osmo-iuh.git, to match libosmo-sccp 'old_sua'. Do that to fix the jenkins
build of --enable-iu.

Change-Id: I70f731db0b74ed48ae6dd713ed4c3247222ef0de
2017-08-27 17:44:54 +02:00
Alexander Couzens 220dc0c7f6 .gitreview: update repo url to new location
Change-Id: Ic08e308e3b6f9dda35c95da4628268ccd2b6cfaa
2017-08-08 17:15:31 +02:00
Max eab5f594b0 Enable optional static builds
* use LT_INIT instead of AC_PROG_RANLIB
* remove redundant libbsc entries

The default (for both manual and .deb builds) is to use shared build (as
before) - the static build is entirely optional.

Based on work by Sergey Kostanbaev <sergey.kostanbaev@gmail.com> and
Alexander Chemeris <Alexander.Chemeris@gmail.com>.

Change-Id: Ibcd1da98302413182c85e25c4cb7d69d9e38c35a
2017-06-22 10:51:46 +00:00
Max 5a44d25ad3 Fix BTS features length check
While fixing potentially incorrect memory access, the check for maximum
number of supported BTS features was incorrectly adjusted instead of
feature vectore length check next to it. Fix this by adjusting checks
properly and adding comments to avoid future confusion.

The error was introduced in a60bb3dd28.

Change-Id: I06d2498d730624d5da535f6add6fa98d004714ae
2017-06-22 10:50:30 +00:00
Harald Welte 2f8b9d25f8 Add vty command "radio-link-timeout infinite" for uplink rx testing
When we are performing Rx sensitivity testing on a BTS, we want to
deactivate the connection failure criterion / radio link timeout, i.e.
no matter how many SACCH frames in uplink are failed to decode, the BTS
should never close the channel.

OsmoBTS Change-Id I736f21f6528db5c16fa80cdb905af20673797be5 covers a way
how this behavior can be requested from the BTS via an OML attribute.
This patch adds support to the BSC to actually set that attribute.

Do not use this in production networks, as the BTS will keep open radio
channels indefinitely even if the phone is gone and no longer
transmitting anything.  This is a pure testing feature.

Change-Id: I6cb94e0f024934f7baeeb728ca9ed3042fbf16d2
2017-06-18 12:56:00 +03:00
Max 8b1a2f8cd7 bsc_init: Forget which SIs are valid for the trx
Previously the SI generation lead to setting the BCCH SIs for all TRX in
a multi-trx setup. This is because we create the SIs globally but
si_valid appears to be limited to the 'current' trx. Warn if we attempt
to set SIs for the BCCH on a trx that does not have a BCCH.

Change-Id: Ie0e288252a2e7709c4dae16b96a0b1512278847f
Tweaked-by: Max <msuraev@sysmocom.de>
2017-06-15 16:39:55 +02:00
Max 70fdd24d04 Update SI data structures and generation
To support segmented SI2quater as per 3GPP TS 44.018 we'll have to
support multiple SI messages (up to 16 for SI2q) for a given type in
contrast to existing 1:1 mapping:

* expand storage space to hold up to 16 SI messages (spec limit)
* add assertions for budget calculations
* generate multiple SI2q messages
* adjust SI2q-related tests
* use precise check for number of SIq messages instead of approximate
  estimation

Change-Id: Ic516ec9f0b821557d9461ae9f1c0afdd786f3b05
Related: OS#1660
2017-06-15 16:39:55 +02:00
Max 9b97b007df Move SI-related defines
* move SI2quater related defines to shared header
* add define from OsmoBTS which checks for presence of a given SI
  message in gsm_bts struct. Rename it to avoid conflicts with OsmoBTS
  code and to match naming conventions of similar macros.

Change-Id: I11432c93c772d1ead6d45a7bb0f1d13d492c82f1
Related: OS#1660
2017-06-15 11:43:10 +00:00
Max a60bb3dd28 OML: fix potential OOB memory access
Use sizeof target BTS feature storage to make sure we always fit into
pre-allocated memory. Also use it for log check.

Change-Id: Ib107daa6e8b9bc397a10756071849f8ff82455d5
Fixes: CID 170581
2017-06-12 13:45:03 +02:00
Max c51c1e7950 Request and parse BTS feature list via OML
Request features supported by BTS when getting attributes over OML.

Change-Id: Ic35b2865998bca3c2c0cb4b77e4e73d12e08bd7e
Related: OS#1614
2017-06-09 08:58:04 +00:00
Max 33e1357a90 Get TRX attributes
Request per-TRX attributes in addition to BTS attributes.

Change-Id: I2b61131b9930afd03357c0b66947ee856d58cc46
Related: OS#1614
2017-06-09 08:58:04 +00:00
Harald Welte 4a824ca8fc don't re-implement osmo_talloc_replace_string()
osmo_talloc_replace_string() was introducd into libosmocore in 2014, see
commit f3c7e85d05f7b2b7bf093162b776f71b2bc6420d

There's no reason for us to re-implement this as bsc_replace_string
here.

Change-Id: I6d2fcaabbc74730f6f491a2b2d5c784ccafc6602
2017-06-09 08:49:36 +00:00
Max aef68387ae Add remote BTS feature storage and helpers
In addition to compile-time defined BTS model features we also need
run-time BTS features reported by BTS via OML. This should be shared by
BSC and BTS. To accommodate for this, add following:

* features bitvec to gsm_bts struct
* features descriptions
* comments to avoid confusion between 2 feature sets
* helper functions to set/query particular feature
* upper boundary on number of supported features and assertion for it

Change-Id: I02bd317097ba66585c50ebd4e8fc348f6dc3dad9
Related: OS#1614
2017-05-31 12:15:54 +02:00
Max 71d082bec7 Adjust BTS model feature check
Rename gsm_bts_has_feature() -> gsm_btsmodel_has_feature() and adjust
type signature to match gsm_btsmodel_set_feature() function and avoid
confusion with upcoming functions to check/set BTS features reported
over OML.

Change-Id: I97abdedbef568e0c2fbd37c110f7d658cf20e100
Related: OS#1614
2017-05-31 12:14:17 +02:00
Harald Welte 8254cf75bf libbsc: Create pcu-socket only as specified in config file
Since commit b4999b60d4 we created PCU
sockets at hard-coded paths in the filesystem by default for all BTSs.
This is inflexible and prevents the use of multiple BSC instances on a
single filesystem, or the placement of the sockets in a more secure
location than /tmp.

The new approach with this patch is that
* no PCU sockets are created by default
* only for those BTSs where a 'pcu-socket' is configured via VTY,
  the socket will actually be created

Change-Id: Ie9079470584777dcc31f85f9bf0808f479156ccb
Closes: OS#2293
2017-05-29 13:45:04 +02:00
Harald Welte 3f86c523ee bsc_vty: Add command to manually issue IPAC MDCX
Using this command, one can modify the RTP stream associated with a
given logical channel and (re)direct it to a specified IP:Port.

Change-Id: I63e03b932038a4e2f6d51c5541b52e4a42df27bf
2017-05-28 22:51:47 +00:00
Harald Welte 2abd5e1663 bsc_vty.c: Add command for manual [de]actiovation of logical channels
Sometimes it is useful to manually activate (or decativate) a given
logical channel from the VTY.  Doing this on the BSC (rather than the
BTS) ensures that the BSC knows that this timeslot / channel is
allocated and there is no risk to have clashes between the BSC "owning"
the resources and the BTS allocating some by itself.

Change-Id: I44fc3904678eb48bd3ab1a3da8c0c265fa082e0d
2017-05-27 15:55:11 +02:00
Harald Welte 645eb62283 bsc_vty.c: Further simplify vty_get_ts()
We can also move the string-to-numeric conversion inside vty_get_ts() to
reduce the amount of work required in the caller.

Change-Id: I2a74ed06e90e39d39f53fff39bb96df172728c0e
2017-05-27 15:54:39 +02:00
Harald Welte 7fe00fb9be bsc_vty: Factor vty_get_ts() out of pdch_act_cmd()
Resolving a timeslot based on its numeric identities is a generally
useful function, so lets' factor that out.

Change-Id: Id2570232f82542487a1133be7efb1dc1eb3029a8
2017-05-27 14:09:50 +02:00
Harald Welte 0483f33820 bsc_api.c: Documentation for handle_mr_config()
Change-Id: I6edd442afc7c20f8f097198941bc592d429ba5da
2017-05-27 14:08:20 +02:00
Harald Welte 0de69a2501 costmetic: Document gsm48_multirate_config() + const-ify input
We generally use const pointers for input arguments.  Also, document
input/output arguments of function and add spec reference.

Change-Id: I2532cde69a18e3b021f7371e68f67a28a43d8b5f
2017-05-27 13:18:50 +02:00
Harald Welte 5f72f6fccc Use new e1inp_signal_names from libosmo-abis to print input signal names
Change-Id: I156027ecdd1456228c9f8776577edd48e70c19da
2017-05-25 19:16:40 +02:00
Alexander Couzens 271ceca862 abis_rsl: use msgb_pull to parse tlli from msg
Change-Id: I971bf6c8821689f9d8a1294a9b3bf1af9c4091f7
2017-05-25 14:04:08 +02:00
Alexander Couzens 2faeb1ac6c abis_rsl: fix off-by-one length check when parsing ericson tlli field
Change-Id: I658f6d82a67944345ddda5534fa996dca9e990ab
2017-05-25 14:04:08 +02:00
Philipp Maier 722bbb402f pcu_sock: Fix broken paging command
The pcu sends us an already made up MAC-Block that contains the
paging request. pcu_sock.c is parsing this paging request
wrongly and fails silently, which results into a dropping of the
request.

This commit fixes the parsing problems.

Change-Id: Iefef08123bdc351afd8287d3f27ebf0ae58a6e7d
2017-05-25 14:04:08 +02:00
Philipp Maier f8aeb2cccb pcu_sock: Forward imm.ass PCU originated messages
The PCU sends imm.ass messages in response to a rach request. Those
messages need to be forwarded to RSL in order to get them send. This
commit introduces the required functionality for that

Change-Id: Ice099c4ed7008200ed179e581aba1899c6c29455
2017-05-25 14:04:08 +02:00
Alexander Couzens f14cb3535c pcu_sock: implement direct tlli on AGCH
Ericsson allows to attach a reference to immediate assignments. A
confirmation of the transmission is then sent back, but only containing
the reference, not the whole RLC packet.

Change-Id: I945f49e62e2a74a7906e2d49940927773edd04a9
2017-05-25 14:04:08 +02:00
Alexander Couzens 872671e01b pcu_sock: pcu_tx_info_ind allow to use TRX not starting from 0
It would prevent using only e.g. TRX 1 when TRX 0 is disabled.

Change-Id: I68dc5e837bd2a3602f7875063c85da4082196274
2017-05-25 14:04:08 +02:00
Alexander Couzens a229756885 pcu_sock: set flag PCU_IF_FLAG_SYSMO by setting pcu_direct = 1
The use of PCU_IF_FLAG_SYSMO enable the PCU to use DIRECT_PHY code path.

Change-Id: I1f5407264fc4f209456ffcb73d7853ff315aab86
2017-05-25 14:04:08 +02:00
Harald Welte 54050a28ed pcu_sock: Send non-NULL hLayer1 to PCU
The BSC-located PCU case looks to the PCU like a BTS-located PCU with
"direct PHY" access, i.e. the data related primitives are communicated
from the PCU directly towards the TRAU Frames or whatever transport
method is used between CCU and PCU.

In order to make the PCU believe that, we need to pass in a 'layer 1
handle'.  As we don't use it, we can just pass any non-zero value and be
happy.

Change-Id: I8170bd4134904702b6b272e496100361ba473cbc
2017-05-25 14:04:08 +02:00
Harald Welte 854bcc2b7b pcu_sock: Forward paging request from PCU via RSL to BTS
Change-Id: I28bf0995699618f3f5fa15fc8e1733beddfc482f
2017-05-25 14:04:08 +02:00
Harald Welte e586f41692 pcu_sock: get rid of magic numbers and use ARRAY_SIZE() for array iteration
Change-Id: I602b581fab67b3a1c3c03c73a3a99e9afd564e29
2017-05-25 14:04:08 +02:00
Harald Welte 67798617b5 pcu_sock: Don't re-implement core functionality like gsm_bts_trx_num()
Change-Id: I5ea506c8240dac124ccf5522d02ba18e4f0cb90d
2017-05-25 14:04:08 +02:00
Philipp Maier b4999b60d4 pcu_sock: add basic pcu interface support
Adds a basic version of a pcu socket interface, similar
to the one that can be found in osmo-bts.

Change-Id: Ib13cb4099d12fa71e9e0b8727e19ab29e11909b2
2017-05-25 14:04:08 +02:00
Philipp Maier 94bbc73bce libbsc: add debug log message to S_L_INP_* callbacks
Improve debug log output of input callbacks by adding a line containing
the signal event name.

Change-Id: Ifca46dd8b356d0de31cccbd79e406079d3a0d7d2
2017-05-25 14:04:03 +02:00
Philipp Maier 6f483d3a05 gsm_data_shared: add value strings for gsm_chreq
Change-Id: I23d3be5610a5a46098d2b12feed4245828599aae
2017-05-25 14:01:50 +02:00
Neels Hofmeyr 1fe2647c5d ipaccess-config: properly create swload
Instead of 20, use the actual buffer sizes of struct sw_load, which are 255.
Previous code would truncate a longer string at 20 without(!) NUL termination.

In the _len members, store the actual length copied. In previous code, if the
source string were longer than 20, we would store only 20 (without NUL term)
but still reflect the longer length of the source string.

Fix both of these issues for sw_load.file_id / file_id_len and
sw_load.file_version / file_version_len.

Change-Id: I2e34a1348a290d3f58dd830d08da65b94b3270db
2017-05-22 13:28:31 +00:00
Alexander Huemer 5265bea76c Add missing _CFLAGS and _LIBS
These missing pieces go unnoticed if dependencies are not installed in
distinct directories.

Change-Id: If8d57b72f63d79cc0d8efba7466c6ec177207cbb
2017-05-20 11:42:37 +00:00
Keith Whyte 320960cf9d libmsc: Map SMPP command status to GSM 04.11 cause
Send SMS RP ERROR with a failure cause that relates to
the status returned by the ESME in the deliver_sm_resp.

Actual mapping array is limited as most phones I tested
don't seem to care about the failure cause anyway,
although some will display a different notification for
GSM411_RP_CAUSE_MO_NUM_UNASSIGNED

Change-Id: I61fb2d9ef4f2d2eabdc49b53d9966ad328d15e51
2017-05-20 08:18:50 +00:00
Neels Hofmeyr 9f77d7bd0e fix '/include/openbsc ' to have no trailing space
The newline and $NULL manage to append a trailing space to the 'openbsc' dir.

This was broken in commit 7b6673fa06
"Consistenly format variables in */Makefile.am files"
by Change-Id Ifa21513c007072314097b7bec188579972dc1694

Add a comment to prevent this in the future.

Reported-by: Andreas Mueller <andreas.mueller@criticallabs.org>
Change-Id: I218027459e3b2aaa817d91eb3f69d9c0b10dcd4e
2017-05-19 12:36:32 +00:00
Max 71124de33c Remove errorneous include
The gsm_data_shared.h header is installable and used by OsmoBTS so it
should not include any private (non-installable headers) to avoid
OsmoBTS' build failures.

Change-Id: Ic25031101fc01bd732fe691132c081ad05fa6a4b
2017-05-18 14:17:10 +02:00
Max defb6c95c1 Get basic BTS attributes
Request BTS attributes via OML on connection and parse the response:
request/parse incoming response as sw-config.

Note: only basic BTS-wide KV attributes wrapped in sw-config are
supported for now.

Change-Id: I589be51daca0cb9e1f3473b93e910e46b06e23ae
Related: OS#1614
2017-05-17 17:52:28 +00:00
Max 845a3a4c59 SI2quater: fix EARFCN inclusion check
Previously only the existance of bts->si_common.si2quater_neigh_list was
checked but not the actual number of EARFCNs in it. Fix it by using
si2q_earfcn_count() and adjust tests accordingly. While at it - reformat
tests to include extra information.

The correctness was checked manually by inspecting GSMTAP output.

Change-Id: Ic4fb2a9e870db66cac58b1e8d113587b30d64ce2
Related: RT#8792
2017-05-15 15:13:01 +02:00
Max f39d03ad21 Restructure SI2quater generation
In preparation for extended SI2q messages:

* add SI2q-specific accessor macro
* add *_offset variables to gsm_bts struct
* internalize memory check while generating rest octets - introduce
  budget concept (number of bits available in a given message)
* internalize *arfcn_size() functions as they are not needed outside of
  si2q_num() anymore
* change rest octets generation to work with gsm_bts struct directly
* do not generate rest octets if no SI2q is necessary
* adjust unit tests accordingly (cosmetic changes only to avoid
  regressions)

Requires: I92e12e91605bdab9916a3f665705287572434f74 in libosmocore

Change-Id: Ib554cf7ffc949a321571e1ae2ada1160e1b35fa6
Related: RT#8792
2017-05-15 13:11:48 +00:00
Max 1ebf23b7fe Prepare for BTS attribute reporting via OML
* use define for number of attributes instead of magic number
* add sub_model to gsm_bts struct
* expand number of BTS features
* mark attributes parameter to abis_nm_get_attr() as const

Change-Id: I7ecb0c4339530d3a8354a2f94b34063dda87e030
Related: OS#1614
2017-05-15 08:13:03 +00:00
Neels Hofmeyr 7590ff3fd6 fix subscriber random extension allocation range
The VTY config allows above 32bit range extensions, but
db_subscriber_alloc_exten() was unable to generate extensions outside of 32bit.

Add VTY regression test and fix the problem by using proper 64bit types.

Related: OS#2253
Change-Id: I9afe6a8833004ecd2f3f936b2d5aa4de8e7dbcb0
2017-05-12 15:43:49 +02:00
Neels Hofmeyr 34ce3d93c5 fix VTY parsing: subscriber-create-on-demand random
Fix parsing of the 'subscriber-create-on-demand random' VTY: atoi() is not
enough to include the specified range of 1-9999999999.

Use atoll() instead to ensure a large enough number space also on 32bit
systems.

(Note: for me, atoll() truncates at 32 bit when <stdlib.h> is not included.)

Add a VTY regression test for this.

Related: OS#2253
Change-Id: I353e04481ec567adca383d6b51ba8fb865eed73e
2017-05-12 15:43:18 +02:00
Pablo Neira Ayuso 5121576b0c src: use osmo_timer_setup()
Use new function available in libosmocore to set up timers. Compile
tested only.

Change-Id: Ibcfd915688e97d370a888888a83a7c95cbe16819
2017-05-10 11:21:24 +02:00
Max 7b62d54b52 Use define for limit on number of BTS features
Change-Id: Ief81db0b3653fec180e60776ff9bcb0ac1357217
Related: OS#1614
2017-05-10 07:49:43 +00:00
Max 2b6c5407b6 Add forgotten items to .gitignore
Change-Id: I04b2ec1115f6207bd238489db9317bfaee58f3bc
2017-05-09 11:37:36 +02:00
Max 7507aef92b Make BTS type and variant converters shareable
* move value_string definition and corresponding functions for BTS type
  to shared header to make it re-usable by OsmoBTS
* use consistent function naming
* add similar functions for BTS variant
* add enum to be used by OML Attribute Reporting to distinguish between
  type, variant and other info

Change-Id: Ida94725a6fce968443541e3526f48f13758031fd
Related: OS#1614
2017-05-09 09:09:55 +00:00
Pablo Neira Ayuso 93ffbd0029 libmsc: send RP-ACK to MS after ESME sends SMPP DELIVER-SM-RESP
Hold on with the GSM 04.11 RP-ACK/RP-ERROR that we send to the MS until
we get a confirmation from the ESME, via SMPP DELIVER-SM-RESP, that we
can route this sms somewhere we can reach indeed.

After this change, the conversation looks like this:

    MS    GSM 03.40      SMSC   SMPP 3.4   ESME
     |                    |                 |
     |   SMS-SUBMIT       |                 |
     |------------------->|                 |
     |                    |    DELIVER-SM   |
     |                    |---------------->|
     |                    |                 |
     |                    | DELIVER-SM-RESP |
     |                    |<----------------|
     |  GSM 04.11 RP-ACK  |                 |
     |<-------------------|                 |
     |                    |                 |

Before this patch, the RP-ACK was sent back straight forward to the MS,
no matter if the sms can be route by the ESME or not. Thus, the user
ends up getting a misleading "message delivered" in their phone screen,
when the message may just be unroutable by the ESME hence silently
dropped.

If we get no reply from the ESME, there is a hardcoded timer that will
expire to send back an RP-ERROR to the MS indicating that network is
out-of-order. Currently this timer is arbitrarily set to 5 seconds. I
found no specific good default value on the SMPP 3.4 specs, section 7.2,
where the response_timer is described. There must be a place that
describes a better default value for this. We could also expose this
timer through VTY for configurability reasons, to be done later.

Given all this needs to happen asyncronously, ie. block the SMSC, this
patch extends the gsm_sms structure with two new fields to annotate
useful information to send the RP-ACK/RP-ERROR back to the MS of origin.
These new fields are:

* the GSM 04.07 transaction id, to look up for the gsm_trans object.

* the GSM 04.11 message reference so the MS of origin can correlate this
  response to its original request.

Tested here using python-libsmpp script that replies with
DELIVER_SM_RESP and status code 0x0b (Invalid Destination). I can see
here on my motorola C155 that message cannot be delivered. I have tested
with the success status code in the SMPP DELIVER_SM_RESP too.

Change-Id: I0d5bd5693fed6d4f4bd2951711c7888712507bfd
2017-05-08 17:15:12 +02:00
Pablo Neira Ayuso 638ad068e8 libmsc: use GSM411_RP_CAUSE_MO_NUM_UNASSIGNED as return value
Instead of hardcoded value of 1 plus comment of the right hand side of
the statement.

Change-Id: I865bdbd6da17a0389044a8e749deeeebcb9cae06
2017-05-08 14:45:17 +00:00
Max fd2c1f90ba Use libosmocore for SW Description parsing
Requires libosmocore with Ib63b6b5e83b8914864fc7edd789f8958cdc993cd.

Change-Id: Ib94db414e94a2a1f234ac6f1cb346dca1c7a8be3
2017-05-08 11:49:40 +00:00
Max 310b730798 Use ipa.py for ctrl tests
Remove duplicated code and make sure that python code is actively used
as part of test harness

Change-Id: I676390abe2f179df6004cdd33d0eaaf60e18df03
2017-05-08 08:31:09 +00:00
Max 7b5dbc2805 Gb: use textual representation for parse log
Use textual representation for message type and protocol descriminator
in case of Gb parsing errors.

Change-Id: Ida925258be119619d8705361730c554a130b75bc
Related: SYS#3610
2017-05-05 11:31:07 +00:00
Max c6e8a01e70 deb: install python scripts from contrib/
Add .py scripts from contrib/ to osmo-nitb.deb package.

Change-Id: I852815f348ae330980b186e1ddbc78f18f4f42b5
Related: SYS#3028
2017-05-04 13:38:45 +00:00
Max 50eb66996d ctrl: remove boilerplate code
Define subscriber-list-active-v1 ctrl command as RO and remove
unnecessary functions.

Change-Id: I88fe905c22cf7563415d470b88cb43fca0d52a7f
2017-05-04 13:35:13 +00:00
Max 086067f0a1 Fix vty warnings for GEA0
Previously vty always used additional checks even for GEA0 (no
encryption) which resulted in misleading warnings. Fix this by
adding explicit check for GEA0.

Related: SYS#3610
Change-Id: I1ee468ab3298076d4cb5c7b1f6293c07e272417b
2017-05-02 13:43:13 +02:00
Max 7bb383a45c Make pcap dependency optional
Previously we required pcap.h unconditionally which causes embedded
build failure because it's not included in current version of out poky
toolchain. We can add it to toolchain but it's only necessary for
utils/osmo-meas-pcap2db which is not built for sysmobts anyway so it's
easier to just make this dependency optional and build osmo-meas-pcap2db
only if it's available - similar to the way we build osmo-meas-udp2db.

Related: SYS#3610
Change-Id: I77a5f7eafe0282abedacffad6a9bcb0a8f2b5caa
2017-05-02 13:43:06 +02:00
Max 6d8e5198ad Add gsm_bts_type_variant to gsm_bts struct
Previously it was only in gsm_bts_model which is not initialized on BTS
side. It's more convenient to have it in the struct which is available
to BTS as well.

Change-Id: I54fde8c4ccd5d994af08074f5864446e79a93a25
Related: OS#1614
2017-04-28 08:49:05 +00:00
Max 6f0e50c833 Prepare for extended SI2quater support
Supporting SI2quater as per 3GPP TS 44.018 will require chnages to the
way System Information is stored because it uses 1:n instead of 1:1
mapping between SI type and generated SI content. This should not affect
other SI types though. To facilitate this transition:

* convert the code to always use GSM_BTS_SI helper instead of accessing
  buffer directly
* make helper more robust by adding extra parenthesis
* add similar helper for gsm_lchan
* add function estimating number of SI2quater message to hold configured
  number of (U|E)ARFCNs
* add SI2q index/count fields and pass them to rest_octets generator
  explicitly
* internalize buffer access in generate_si* functions

Change-Id: I74e4e3cb86364cec869a1472a41b4a95af0d50dd
Related: RT#8792
2017-04-28 08:45:36 +00:00
Max a18001d506 Save PCU version reported by BTS
When BTS reports PCU disconnect - clear it.

Change-Id: Idb32c73036413ee912f633604150ee17b611cfa7
Related: OS#1615
2017-04-28 08:44:18 +00:00
Max 8b8fca757e deb: install openbsc.pc
Previously openbsc.pc was generated but not installed as part of
openbsc-dev.

Change-Id: I5472a8fe74a81b98598fbdb688db778cb7d09e62
2017-04-27 10:21:19 +00:00
Max 2b229ffaef gbproxy: add example .service
Change-Id: Ic8144777a77efce4bad44abf6c6abde12fc5149c
Related: SYS#3610
2017-04-26 16:21:43 +02:00
Max cb1e366094 Remove libs from openbsc.pc
OpenBSC does not produce any installable libraries, only header files so
this section is unnecessary.

Change-Id: I4c563d775a84f41f82404e0eaba1a25fdbaac1a5
2017-04-26 12:07:08 +02:00
Max 11e4e41ffc Fix MS TO measurement representation
* set proper flag when saving MS Timing Offset
* use gsm_subscriber's IMSI or lchan's name if bsc_subscriber is unknown
* add comments with spec reference
* store/display MS Timing Offset instead of raw Timing Offset field from
  RSL
* Compute MS Timing Offset [-63; 192] from Timing Offset field [0; 255],
  adjust structure gsm_meas_rep with proper type to store it

Change-Id: I7e003d23a6edb714c5f17688fd6a8edac131161d
Related: OS#1574
2017-04-26 08:25:22 +00:00
Pau Espin 7636c0833b nat: Fix initial buffer size parameter for getline
According to man, lineptr must be set to null AND n to 0.

Change-Id: I36683884106b97ef697264716de13813c00da9bc
2017-04-12 12:28:51 +00:00
Pau Espin dc9de23523 nat: Use equal func in bsc_sccp
It is defined in the file and used twice in there, so let's use it for
all of them which makes code smaller and more clear.

Change-Id: I9fac7cabedff74f8f6293ad8b54420229b80aa71
2017-04-12 12:24:49 +00:00
Neels Hofmeyr d75f11e6f2 build: iu: use libosmo-sccp tag 'old_sua'
libosmo-sccp master is moving ahead, openbsc --enable-iu needs an older
version.

Change-Id: Id74a802fd2ca65f4b6c2079550fbb6b0af3e8340
2017-04-10 20:57:09 +02:00
Max f9685c1461 gsm_bts: add version and variant details
* add version string to gsm_bts
* add PCU version string to gsm_bts
* rename GSM_BTS_TYPE_OSMO_SYSMO -> GSM_BTS_OSMOBTS to avoid confusion
  between BTS model and variant
* add variant enum to gsm_bts_model using enum with variants for each
  hw vendor of OsmoBTS
* show connected PCU version (if available) in vty via 'show bts'

This will come in handy when logging details regarding particular BTS
reported via OML, see:

Related: OS#1614

Change-Id: I6710d53115f34634a7b70969cc05fd5c72ff8ab2
2017-04-10 06:58:43 +00:00
Max 689e7e5562 abis: log known ACKs and unknown messages
Log expected ACK messages and unhandled messages to aid in
troubleshooting.

Change-Id: Id3afaaa76e24f63076ae0e6fd2322e4a7fa29b45
Related: OS#1614
2017-04-08 07:46:07 +00:00
Max 2d92162a6b python: fix Null logger
Change-Id: Ie120273eabbc670e9f19ba365508688a810a2773
Related: SYS#3028
2017-04-05 08:16:25 +00:00
Vadim Yanitskiy 7f3724e04d VTY: add the dyn_ts_allow_tch_f option
This option allows to enable or disable TCH/F allocation on the
TCH/F_TCH/H_PDCH timeslots. Until now, source code modification
was required to enable this feature.

Related: OS#1778

Change-Id: Id18cab25844dc854a66b4e2713e90c3f43afa712
2017-04-03 16:38:06 +00:00
Neels Hofmeyr 4aa75e74f4 jenkins.sh: Iu: use libosmo-sccp,-netif master
The iu specific branches of libosmo-sccp and libosmo-netif have recently
been merged to master.

Change-Id: I9465d7b956c3bd65d6e8a387e6710235672352e8
2017-03-31 20:03:43 +00:00
Neels Hofmeyr 36891a7d9d LU counters: count completion and failure, not messages sent
From a human admin viewpoint it doesn't make sense to count the messages sent:

When we use TMSIs, we first send a LU Accept with a new TMSI, and then expect
the MS to respond with a TMSI Realloc Complete message. When that fails to come
through, the LU actually ends in failure, even though a LU Accept was sent.

If a conn breaks/vanishes during LU, we cancel the LU without sending any reply
at all, so the failed LU would not be counted.

Instead, count Location Updating results, i.e. completion and failures.

(With the new VLR developments, LU counters need to be triggered in completely
different places, and this patch prepares for that by providing sensible
counters.)

Change-Id: I03f14c6a2f7ec5e1d3ba401e32082476fc7b0cc6
2017-03-31 12:05:29 +00:00
Max b1e6b37493 Handle PCU version received via OML alert
Explicitly check for and log PCU version received from BTS via OML alert
message.

Change-Id: I3c88663d4e2887a4038b4c3f1387128295b8934e
Related: OS#1614
2017-03-23 11:09:22 +00:00
Max 9311881bb1 Add simple CTRL2SOAP proxy
Add python client which converts TRAP messages into SOAP requests and
perform corresponding actions.

It can be used as follows

./soap.py -d -w http://example.com/soapservice/htdocs/wsdl/test.wsdl

See ./soap.py -h for additional options.

Change-Id: I82844ec7a302bac30d6daee9ebca2188fd48ca46
Related: SYS#3028
2017-03-23 09:41:00 +00:00
Alexander Couzens 16dcf2ae22 libbsc: add rsl_ericsson_imm_assign_cmd() which reply with a confirmation message
ericsson can handle a reference at the end of a imm assign command which is used in
the confirm response. The confirm response is only sent if the trailer is present.

Change-Id: I88560291b5a3a3d7a0bac4d3c089b45f1f6b297f
2017-03-23 02:10:21 +01:00
Harald Welte baaf3e242e RBS2000 RSL: Support for sending RSL PAGING CMD for GPRS
Change-Id: I66541f9b20e7fd67fbec329283fc3c821c970a56
2017-03-23 02:10:21 +01:00
Harald Welte f7e9a349ef RBS2000: Add the P-GSL Timer IE to RSL CHAN ACT for PDCH
This seems to be mandatory when an Ericsson RBS2000 uses a SuperChannel
as back-haul.

Change-Id: I793e7d62df1ca9f9c38d39e22d3868064d446c8d
2017-03-23 02:10:21 +01:00
Alexander Couzens 3521af7f3a abis_om2k: protect MO FSMs by NULL check
Also set MO FSMs to NULL after freeing them.

Change-Id: I30df0b9ab8bc47ba9756c8388e977deed0e40200
2017-03-23 02:10:21 +01:00
Harald Welte ce49258a12 OM2000: Send ALTCRQ for SuperChannel after receiving IS Enable Req Ack
When the BTS is configured to use a SuperChannel and it is using a
unix domain socket based transport towards the L2TP daemon, then
we must instruct the L2TP daemon to instruct the SIU to change the Abis
Lower Transport Mode using the ALTCRQ / ALTCRP L2TP signalling.

Change-Id: I672bfaa09c42fbeb0c8459f24b2222b952de954b
2017-03-23 02:10:21 +01:00
Max dd22a30d75 twisted_ipa.py: make debug logging more robust
Do not print anything to stdout directly - use proper logger object
instead: either the one supplied by IPAFactory user or default to NO-OP
NullHandler logger.

Change-Id: Ic3417095a6e8848f0acabb46a9e64c0197b736e2
Related: SYS#3028
2017-03-21 14:06:50 +01:00
Max ca2778cd22 twisted_ipa.py: bump version properly
Adjust version string to comply with PEP8 and PEP386.

Change-Id: I44c8521f12e6432038998bfb1ac1bb37a1137787
Related: SYS#3028
2017-03-21 12:55:54 +00:00
Neels Hofmeyr 476c4bb7d1 python tests: allow running from separate build dir
The VTY tests assume that $top_builddir == $top_srcdir. Use the script's
location from sys.path[0] to find the correct locations of example configs even
when building in another directory.

Change-Id: I2731f361e3b72d0980968e6cf83594ea450db7c2
2017-03-20 13:33:15 +00:00
Neels Hofmeyr ca06e040cc bsc_/gprs_subscriber: fix: use osmo_strlcpy() to safely copy IMSI
Fixes: coverity scan CID 163918
Change-Id: I4b2760b006a0707928530b4390c6997b79b02981
2017-03-20 00:21:01 +00:00
Neels Hofmeyr ac27a99021 jenkins: add value_string termination check
Depends: libosmocore change-id I2bc93ab4781487e7685cfb63091a489cd126b1a8
Change-Id: I4183415cd1ead9d46ae3a556e94243325ef5a844
2017-03-16 18:59:24 +00:00
Max 88d4fc70d5 Don't drop OML links for Get Attributes NACK
Previously any OML NACK message will result in BSC dropping OML link to
BTS which makes it impossible to use optional OML messages which might
be unsupported by BTS. Fix this for 3GPP TS 52.021 §8.11.1 Get
Attributes message. Also, log human-readable NACK name to see what
exactly causing OML link drop.

Change-Id: Ib8af2872c27abb793172ec59bdc145b8d54f83da
Related: OS#1614
2017-03-16 14:07:06 +01:00
Neels Hofmeyr 6dd0fc685b oap tests: fix after SQN scheme changes from libosmocore
In change-id Iadf43f21e0605e9e85f7e8026c40985f7ceff1a3, libosmocore changes
from incrementing SQN after tuple generation to incrementing SQN before tuple
generation. Thus we now need to pass desired_sqn - 1 to get the same tuples.

Change-Id: Ifeda71e713bb60dcd31ac651f461b714cfa39b5c
Related: OS#1968 OS#1969
2017-03-15 16:05:42 +01:00
Harald Welte c103c64e7d OM2000: Change the order of MO initialization
So far: CF-IS-CON-TF
Now: CF-TF-CON-IS

Change-Id: I8efd9bafdcf9504d2e5fc85c44c708fa53f4dff8
2017-03-15 13:36:31 +00:00
Philipp Maier 3d6cb338c6 gprs: fix T3186 encoding in Sysinfo 13
The timer T3186, which is described in 3GPP TS 44.060, is using 3
bits of the si13 mac block. This requires special encoding. In the
case of T3186, the value is encoded by the formula: bits = t/500-1.
Our implementation uses the formula bits=t/500, which is incorrect.

Change-Id: Ifd340c536cff2d1c4b1b3677a358ea95438801eb
2017-03-15 13:15:26 +00:00
Max e7379fe657 examples: remove logging level * everything
Option "logging level ... everything" is broken for quite some time and
might be deprecated in future. Replace it with "logging level ... debug"
in config examples.

Change-Id: I828ef7671b4fb38717526a18ff8e9a5428cd511e
Related: OS#71
2017-03-15 13:01:12 +00:00
Philipp Maier 99c9707d1c cosmetic: Add commandline option to display version
The -V option to display the Version and the copyright info
is missing.

Change-Id: I0c848fd42c13f473807caf3478d32c6ce5e43e31
2017-03-15 13:00:47 +00:00
Alexander Couzens 11368118c9 libbsc: add chreq type for CHREQ_T_PDCH_ONE_PHASE & CHREQ_T_PDCH_TWO_PHASE
When using a BSC located PCU the BSC must understand PDCH requests.

Change-Id: Ie7f4ed000cf1b40d269873cf0ddf5ff9f5bbc18a
2017-03-15 12:48:03 +00:00
Philipp Maier 2459f9fb5a cosmetic: add copyright header to bsc_control.py
bsc_control.py lacks a copyright header. This commit adds the
copyright header from ipa.py to bsc_control.py.

Change-Id: Ie70bf686ee9bb157198e02bf8d946abf56adc82a
2017-03-14 17:19:23 +00:00
Alexander Couzens 8a215c3d25 gprs_sgsn.c: initialize ptmsi with 0xdeadbeef
Fix uninitialized memory access warning.
"Conditional jump or move depends on uninitialised value"
Found by valgrind.

Change-Id: Ibc2d585c5db899e6af20104211e32faf3822633a
2017-03-14 12:00:03 +00:00
Neels Hofmeyr b3c7c79c04 python tests: vty and smpp: speed up >10 times
osmo-python-tests now includes code that retries connecting the VTY socket and
needs no external sleep()ing. This flies through most tests without any sleep()
at all.

See osmo-python-tests.git change-id Icc337f52a93d5fe31fc4ff235ccaf4e0fe75fa39

Change-Id: I42161d9716fe5bb0ef1c56e4bfb770bb99bbca7a
2017-03-14 03:18:26 +01:00
Alexander Couzens dfb138ff09 unixsocket: start sabm for UNIXSOCKET
openbsc only starts sabm messages for a subset of line drivers.
Add unixsocket to those subset.

Change-Id: If98c037119142cc33b46ab5c1bf02d4cda81c81e
2017-03-13 11:19:18 +00:00
Harald Welte 0722ffc743 OM2000: Add FIXME comments for missing resolving of RX/TX MO!
Change-Id: I45708df724c5fc3316eca6bd2ac2c0738b19a45b
2017-03-13 09:41:58 +01:00
Neels Hofmeyr 6d804b1a7e add struct bsc_subscr, separating libbsc from gsm_subscriber
In a future commit, gsm_subscriber will be replaced by vlr_subscr, and it will
not make sense to use vlr_subscr in libbsc. Thus we need a dedicated BSC
subscriber: struct bsc_subscr.

Add rf_policy arg to bsc_grace_paging_request() because the bsc_subscr will no
longer have a backpointer to gsm_network (used to be via subscr->group).

Create a separate logging filter for the new BSC subscriber. The implementation
of adjusting the filter context is added in libbsc to not introduce
bsc_subscr_get/_put() dependencies to libcommon.

During Paging Response, fetch a bsc_subscr from the mobile identity, like we do
for the gsm_subscriber. It looks like a duplication now, but will make sense
for the VLR as well as for future MSC split patches.

Naming: it was requested to not name the new struct bsc_sub, because 'sub' is
too ambiguous. At the same time it would be fine to have 'bsc_sub_' as function
prefix. Instead of struct bsc_subscriber and bsc_sub_ prefix, I decided to
match both up as struct bsc_subscr and bsc_subscr_ function prefix. It's fast
to type, relatively short, unambiguous, and the naming is consistent.

Add bsc_subscr unit test.

Related: OS#1592, OS#1594
Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e
2017-03-08 01:01:43 +01:00
Max abf53d87b6 Add MS time. offset to gsm_lchan
Add MS TIMING OFFSET (3GPP TS 48.058 § 8.4.8) and P offset (3GPP TS
45.010 § 1.2) which can be used to compute MS TO from known TA.

This will be used by osmo-bts (see
I4dfe5c48834a083e757d5de3236a02e15a238b28) to provide MS TO as part of
RSL MEASUREMENT RESULT.

Change-Id: I8bda57c8d6c15bbb803eca708931556dae118a00
Related: OS#1574
2017-03-07 15:11:14 +01:00
Neels Hofmeyr 0b61932e7f vty tests: close msc socket after nat_msc_test
Change-Id: Ib64cf8690627803e1b4a8497ea63f1e766960478
2017-03-05 12:24:46 +00:00
Philipp Maier 6ee49d8416 sgsn: fix problem with leading-zero-IMSIs
When the IMSI ACL is maintained via the VTY, users may enter IMSIs
without leading zeros. Especially in test environments, where
MCC=001 and MNC=01 is common, it is likely that someone enters the
corresponding IMSI (001010000000001) without the two zeros at the
beginning.

This patch fixes the problem by sanitizing the IMSI, eventually
missing zeros in the beginning will be automatically added.

Change-Id: I56ba0da61978bbdce71d0e320166c52b20b42517
2017-03-05 12:24:25 +00:00
Neels Hofmeyr 3f8a8f7736 vty tests: allow picking specific tests to run by name
Depends: osmo-python-tests change-id I92f90c334169f31920c63dd5c5ac8dac215065e6
Change-Id: I849455e0423e1a63d6890aef7f9c6075ad53a920
2017-03-02 14:30:41 +00:00
Max 0436e42472 Fix potential segfault in sgsn_libgtp.c
* print pdp->address instead of mm->imsi if mm is NULL
* print mm->imsi in debug log (move it below NULL check)

Change-Id: I4fbf5a54019a46612fbc528d61120182738f9205
2017-03-02 13:28:52 +01:00
Neels Hofmeyr d3270a9c05 subscriber conn: add indicator for originating RAN
Add via_ran to gsm_subscriber_connection to indicate whether a conn is coming
in via 2G/GERAN/A-Interface or 3G/UTRAN/Iu-Interface. Prepares for Iu, but
also for libvlr to decide between GSM or UMTS Auth.

Until actual Iu support is merged to master, this indicator will aid VLR unit
testing.

At some point we may also add RAN_GERAN_IU; it's not on the agenda yet, but to
clearly distinguish the names if we want to add it, explicitly name the ones we
have RAN_GERAN_A and RAN_UTRAN_IU.

Change-Id: I93b870522f725170e4265a5543f6b680383d7465
2017-03-02 03:13:02 +01:00
Neels Hofmeyr 5616cdde3a fix: gprs_gmm, gprs_llc_vty: two unterminated value_string arrays
Change-Id: Icc4163ac4f962fe88bbebeb3310a557ba0834e84
2017-03-02 01:48:31 +00:00
Keith Whyte f01bd13ca1 meas_json: fix NEIGH: missing array braces
Make NEIGH an array of Javascript objects, otherwise the JSON is not parseable
when neighbours exist

Change-Id: I42029f40bf357adbb2f3c71cdcbafbc21090e348
2017-03-01 11:48:09 +00:00
Alexander Couzens f480b35893 libmsc/update_db_revision_3(): free memleaking db result
Found by ASAN

Change-Id: I2680c60e26b9876b428d4b75323f884f9ecd95b3
2017-02-28 18:36:35 +00:00
Philipp Maier e0d5caa916 silent_call: remove unfinished fuzzer interface
Remove the fuzzer interface that was partially implemented in
gsm_04_08.c and silent_call.c is causing problems when an
SMS is sent during an active silent call. The reason for this
is that gsm0408_dispatch() in gsm_04_08.c would decide to
rout all uplink traffic to silent_call_rx() in silent_call.c.
silent_call_rx() is a stub function that discards the data.

This patch removes the fuzzer interface code by placing ifdefs
around it, so that it can be re-activated by experimentators.

Change-Id: Id500197d58663b3f4b1756136343670388b0a4bc
2017-02-28 18:28:03 +00:00
Neels Hofmeyr acc6e8323a ctrl_test_runner: speed up more than 10 fold by sleeping less
Similar to a recent patch in osmo-python-tests for VTY based tests, but this is
for the Ctrl tests.

The TestCtrlBase tests gave a constant sleep(2) grace period for the process to
startup. This causes tests to take minutes for no reason at all.

Add code to TestCtrlBase to try and connect right away, retrying up to three
seconds in .1 second intervals. This flies through most tests without any
sleep() at all.

Change-Id: I06569767153838bd9cd3edac001df5f6c567874c
2017-02-28 18:26:49 +00:00
Neels Hofmeyr 534034580c vty test: nat_msc_test: setsockopt REUSE to avoid TIME_WAIT problems
When running the testBSCreload test in close succession, I get a "Connection
refused" error because the socket is still in TIME_WAIT state. Passing the
SO_REUSEADDR flag allows reusing the addr despite a TIME_WAIT socket.

Change-Id: I941851b062999ab4b962430f7b27c19935993e0a
2017-02-28 18:22:06 +00:00
Philipp Maier d015cbd65d XID: resend xid with pdp-ctx-ack messages
If a pdp context is created a xid request is sent right after
the pdp-context-ack message. The sending of the pdp-context-ack
and the xid message is triggered from the GGSN via the GTP
interface.

When the pdp-context-ack message is not received by the MS, it will
send the pdp-context-request again. A lost pdp-context-ack is resent
by the SGSN directly so that the mechanism described  above does
not work for pdp-context-ack resents.

This commit adds code to trigger the sending of xid messages also
for resent pdp-context-ack messages.

Change-Id: Ice66790803154310a61a70a54be76cec539c97a7
2017-02-27 18:07:29 +01:00
Neels Hofmeyr 27355c9c65 SGSN VTY: make missing GSUP server address+port fatal
On 'auth-policy remote', the SGSN requires GSUP server address and port. If it
was missing, the SGSN would print a VTY warning and run anyway. Make this error
more fatal: print an error (flattened a bit) to stderr and abort the program.

Move validation of the GSUP server data presence out of the VTY command itself
and into the config reading function. This way the GSUP server config can be
given anywhere, including below the auth-policy config (was required above).

Don't care about setting the auth-policy to remote with a telnet VTY, because
in that case the GSUP client won't be started anyway.

Change-Id: I4d8db910c32abd8579d3c9b9f0b2cb3a9a6dfe4c
2017-02-27 14:29:41 +00:00
Neels Hofmeyr 058cd573d8 SGSN: Integrate support for UMTS AKA
The general infrastructure for UMTS AKA is already in place:
* GSUP with capability to send us auth_vectors that contain
  either triplets or quintuples
* mm_context that holds such auth_vectors

Add:
* capability to send UMTS AUTN in GMM AUTH REQ
* parse extended UMTS RES
* on auth response, validate expected AKA with vector and received res/sres
* add Auth Failure message to receive resync AUTS token and
  * send to HLR
  * clear out-of-sync auth tuple
  * enter new state for when we're waiting for HLR to resync and send new
    tuples so that the next Auth Request will be handled

Original first half of this patch by: Harald Welte <laforge@gnumonks.org>

Full UMTS AKA procedure including AUTS resync tested to work against OsmoHLR
with R99 USIM and Milenage algorithm.

The sgsn_test.c needs adjustment because we're checking the vector's auth_types
now.

Depends: libosmocore change-ids
         I277fb3d407396dffa5c07a9c5454d87a415d393f
         If943731a78089f0aac3d55245de80596d01314a4
Related: OS#1956
Change-Id: Ie6a0cefba5e4e7f02cc2eaf6ec006ac07d5c1816
2017-02-27 14:29:41 +00:00
Neels Hofmeyr 44468ad531 smpp_test_runner.py: fix socket leak
Each running test would open up another socket without ever closing unused
ones. Close the sockets after each test is done.

Change-Id: I0a42caab3bb8c9c9d04b033e4de9efe0ca8fd2af
2017-02-25 17:04:45 +00:00
Neels Hofmeyr 577a125652 python tests: remove process 'Launch' message, now at osmoutil
Change-Id: Id8eb70ddfdc1d0d9f90aa5343a4ea522042c34ee
2017-02-25 17:04:08 +00:00
Neels Hofmeyr 8b24e9f203 vty_rest_runner.py: remove debug monitoring for TCP sockets
Change-Id: I7361bb0ce5302d00ccb18dc04eeb75ee1f6844a8
2017-02-25 17:04:08 +00:00
Alexander Chemeris c634063ea3 utils: 'meas_json' utility to convert measurement feed into a JSON feed.
Change-Id: I56631969384da245eed8ffc14845c76a5d4de8d4
2017-02-25 05:23:22 +00:00
Neels Hofmeyr 0e5d807297 add struct gprs_subscr, separating gprs from gsm_subscriber
Prepare for replacing gsm_subscriber with vlr_subscriber. vlr_subscriber will
not make sense to be used in gprs, so have a dedicated GPRS subscriber struct.
(Could change if the gprs code were to use libvlr; is currently independent).

Related: OS#1592
Change-Id: Ia8b391ee009c8545763cba04505be3947835120e
2017-02-25 01:25:22 +00:00
Neels Hofmeyr a369e24cb9 cosmetic: rename struct osmo_msc_data to bsc_msc_data
With the OsmoMSC program coming up, the name osmo_msc_data becomes even
more confusing than it already is. Clearly indicate it as libbsc's data of
a remote MSC by prefixing with bsc_.

Also, the Osmocom community has in the meantime agreed to have the osmo_
prefix only in libosmocore, to avoid naming conflicts in case things are
moved there. So while renaming anyway, also drop the osmo_ prefix.

Change-Id: I0dfbcb7d1a579211180f71319982820d8700afab
2017-02-24 21:01:55 +01:00
Neels Hofmeyr a42855f09f cosmetic: rename osmo_msc_data.h to bsc_msc_data.h
With the OsmoMSC program coming up, the name osmo_msc_data becomes even
more confusing than it already is. Clearly indicate it as libbsc's data of
a remote MSC by prefixing with bsc_.

Also, the Osmocom community has in the meantime agreed to have the osmo_
prefix only in libosmocore, to avoid naming conflicts in case things are
moved there. So while renaming anyway, also drop the osmo_ prefix.

Change-Id: I13554563ce9289de126ba0d4cf329bafcda35607
2017-02-24 21:01:55 +01:00
Neels Hofmeyr 9762b4c579 cosmetic: clarify BSC's remote MSC data vs. OsmoMSC
Change-Id: I74dd2b3f935d39b8caa718e2c8a51cc81bddf1b9
2017-02-24 21:01:55 +01:00
Neels Hofmeyr fe291de36b cosmetic: gsm_data.h, README: rename CSCN to MSC
We're discarding the name OsmoCSCN for the benefit of OsmoMSC. But "CSCN" has
already crept into the master branch in two places; apply the rename.

See OS#1958

Change-Id: Ib4274eb3c172ada1fe7f05746740b456370bc93d
2017-02-24 21:01:55 +01:00
Neels Hofmeyr d2b3399c04 vty: fix subscr ref count leak in 'subscriber name' cmd
Change-Id: I3d19518c94a7f302bf108f2ad945983cdc8db0b1
2017-02-24 19:58:07 +00:00
Neels Hofmeyr 40a91b38ec vty_test_runner.py: fix socket leak
Each running test would open up another socket without ever closing unused
ones. Close the sockets after each test is done.

Change-Id: Ie433c8560de54f9a9d05fa07c44bae3126d19b30
2017-02-24 17:54:24 +01:00
Neels Hofmeyr 7a250cc9d9 cosmetic: remove unused scall_signal_data.subscr
Doesn't make sense to switch this to struct vlr_subscr when it isn't used at
all. So let's remove it.

Change-Id: Ifa5901f8bf1aed3981841d24d4ec8d659f3de7a9
2017-02-23 23:44:05 +00:00
Neels Hofmeyr 89a8e722ed logging fixup: shorter names for LOGGING_FILTER_* and LOGGING_CTX_*
In libosmocore, my patch was merged to master a bit too soon. To accomodate the
request for naming that matches the general "LOG" prefix instead of "LOGGING",
a fixup was committed to libosmocore. Adjust for that.

Original patch: change-id I5c343630020f4b108099696fd96c2111614c8067
The fixup: change-id I424fe3f12ea620338902b2bb8230544bde3f1a93

Change-Id: Ib2ec5e4884aa90f48051ee2f832af557aa525991
2017-02-23 18:11:57 +01:00
Neels Hofmeyr 94f49a4f08 debug.h/c: remove unused cruft / cosmetic tweaks
Change-Id: I9601d478763569933bcc46bf4eaaff70a9843be9
2017-02-22 17:28:49 +01:00
Neels Hofmeyr f13b3c968f logging: use central filter and ctx consts from libosmocore
The LCHAN and BTS filter contexts are actually never used, so drop them until
someone adds them properly.

For now use only LOGGING_{FILTER,CTX}_VLR_SUBSCR. Some of these will change to
_BSC_SUBSCR once struct bsc_subscriber is introduced, and later on, struct
gsm_subscriber will be replaced by vlr_subscriber so that the names will match.

Depends: libosmocore change-id I5c343630020f4b108099696fd96c2111614c8067
Change-Id: Ifa82f6a461ad4c0eeddb8a38fb3833460432d16b
2017-02-22 17:24:54 +01:00
Max a66d8cfcb5 Handle DSD from HLR
Handle Delete Subscriber Data GSUP message from HLR to disable Packet
Services for a given IMSI.

Change-Id: I6b9b494fa58bcb95bd550c49f8204f00f8fdf628
Related: OS#1645
2017-02-21 16:24:37 +00:00
Neels Hofmeyr a1613695d1 subscr_update_expire_lu(): fix (obscure) segfault
To be paranoid, catch a NULL subscriber and/or bts in
subscr_update_expire_lu(): print an error log and avoid segfault.
(I'm not sure this would really happen in a normal situation.)

During aggressive testing of Paging timeout, I came across this segfault in
msc_release_connection() when conn->expire_timer_stopped is set but
conn->subscr is NULL, at the subscr dereference after:

        if (conn->expire_timer_stopped)
                subscr_update_expire_lu(conn->subscr, conn->bts);

I brought this situation about by a fabricated Paging fault, i.e. in
gsm48_rx_rr_pag_resp() return 0 and don't call gsm48_handle_paging_resp() at
all. Thus conn->subscr is still NULL when expire_timer_stopped is 1.

When looking at CM Service Request handling, the conn->subscr is set before
setting expire_timer_stopped = 1, which is a saner thing to do. But without my
mad 'return 0', there is in fact no way to have a NULL subscriber there.

It looks like all other code paths already do the same, but it's not that
obvious (e.g. _gsm48_rx_mm_serv_req_sec_cb()). So rather catch this case of
NULL conn->subscr, and while at it catch NULL bts as well.

Change-Id: I430dd952b2b928bea7f8360f1e01bb3cccb0a395
2017-02-19 13:48:31 +00:00
Max 2c16beeb64 Add support for extended SI2q parameters
* add vty command to set E-UTRAN_PRIORITY, THRESH_E-UTRAN_low and
  E-UTRAN_QRXLEVMIN according to 3GPP TS 44.018 Table 10.5.2.33b.1
* remove old command which does not support those parameters

Change-Id: I36dcc79f7b7a02036e74720923d0df1a2a2db504
Fixes: RT#8792
2017-02-19 08:53:57 +00:00
Neels Hofmeyr 87bfed259d remove compiler warning: unused rc in vty_interface_layer3
Change-Id: I3dc94dc4bddc5a887ce196071327a6dddfe5b280
2017-02-18 23:11:04 +01:00
Max b726c2c72b Remove duplicating define
Use GSM_MACBLOCK_LEN consistently throughout abis_rsl.c

Change-Id: I96aec02748a0be0100dee2117f124ff32d5ee3f5
2017-02-09 19:23:38 +01:00
Max 8dc8f23c07 Expand chan allocation logging
Log more data related to channel allocation:
- channel type
- number of paging attempts
- timers fired

Change-Id: Ib417a9c942c17b902dd80ff555cd9da5f91bff48
2017-02-09 19:13:02 +01:00
Max db0e380558 vty: remove ignored logging parameters
Since ce9fec3e896571835ac5bfd2980d6836f2b29f0d libosmocore ignores
parameters to log_vty_command_* functions. Hence parameter of
logging_vty_add_cmds() is ignored too. As we depend on much later
libosmocore version anyway, we can simplify code somewhat by removing
parameters which will be ignored anyway.

Change-Id: I62f752fd88f1d8fefa563648f9864c7c31f87991
2017-02-08 09:37:38 +00:00
Neels Hofmeyr 50422016f0 vty tests: more attempts to resolve 'Broken Pipe' error (2)
Change-Id: I1c0a16d5b3094c25a908f0117d7656d57aac3fda
2017-02-08 08:33:10 +00:00
550 changed files with 26265 additions and 139420 deletions

118
.clang-format Normal file
View File

@ -0,0 +1,118 @@
# SPDX-License-Identifier: GPL-2.0
#
# clang-format configuration file. Intended for clang-format >= 4.
#
# For more information, see:
#
# Documentation/process/clang-format.rst
# https://clang.llvm.org/docs/ClangFormat.html
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
#
---
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
#AlignEscapedNewlines: Left # Unknown to clang-format-4.0
AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
#AfterExternBlock: false # Unknown to clang-format-5.0
BeforeCatch: false
BeforeElse: false
IndentBraces: false
#SplitEmptyFunction: true # Unknown to clang-format-4.0
#SplitEmptyRecord: true # Unknown to clang-format-4.0
#SplitEmptyNamespace: true # Unknown to clang-format-4.0
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
#BreakBeforeInheritanceComma: false # Unknown to clang-format-4.0
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
#BreakConstructorInitializers: BeforeComma # Unknown to clang-format-4.0
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
#CompactNamespaces: false # Unknown to clang-format-4.0
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 8
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
#FixNamespaceComments: false # Unknown to clang-format-4.0
#IncludeBlocks: Preserve # Unknown to clang-format-5.0
IncludeCategories:
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
#IndentPPDirectives: None # Unknown to clang-format-5.0
IndentWidth: 8
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
#ObjCBinPackProtocolList: Auto # Unknown to clang-format-5.0
ObjCBlockIndentWidth: 8
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
# Taken from git's rules
#PenaltyBreakAssignment: 10 # Unknown to clang-format-4.0
PenaltyBreakBeforeFirstCallParameter: 30
PenaltyBreakComment: 10
PenaltyBreakFirstLessLess: 0
PenaltyBreakString: 10
PenaltyExcessCharacter: 100
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: false
SortIncludes: false
#SortUsingDeclarations: false # Unknown to clang-format-4.0
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
#SpaceBeforeCtorInitializerColon: true # Unknown to clang-format-5.0
#SpaceBeforeInheritanceColon: true # Unknown to clang-format-5.0
SpaceBeforeParens: ControlStatements
#SpaceBeforeRangeBasedForLoopColon: true # Unknown to clang-format-5.0
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp03
TabWidth: 8
UseTab: Always
...

70
.gitignore vendored
View File

@ -1 +1,71 @@
debian/*.log
*.o
*.lo
*.a
*.la
.deps
Makefile
Makefile.in
bscconfig.h
bscconfig.h.in
src/osmo-mgw/osmo-mgw
*.*~
*.sw?
.libs
*.pyc
*.gcda
*.gcno
*.pc
*~
#configure
aclocal.m4
autom4te.cache/
config.log
config.status
config.guess
config.sub
configure
compile
depcomp
install-sh
missing
stamp-h1
libtool
ltmain.sh
m4/*.m4
# git-version-gen magic
.tarball-version
.version
#tests
tests/testsuite.dir
tests/*/*_test
tests/atconfig
tests/atlocal
tests/package.m4
tests/testsuite
tests/testsuite.log
writtenconfig/
# manuals
doc/manuals/*.html
doc/manuals/*.svg
doc/manuals/*.pdf
doc/manuals/*__*.png
doc/manuals/*.check
doc/manuals/generated/
doc/manuals/osmomsc-usermanual.xml
doc/manuals/common
doc/manuals/build
contrib/osmo-mgw.spec
#vs code
.cache
.vscode

View File

@ -1,3 +1,3 @@
[gerrit]
host=gerrit.osmocom.org
project=openbsc
project=osmo-mgw

View File

@ -9,17 +9,32 @@ AM_CPPFLAGS = \
$(NULL)
SUBDIRS = \
doc \
include \
src \
tests \
doc \
contrib \
$(NULL)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = openbsc.pc
pkgconfig_DATA = \
libosmo-mgcp-client.pc \
$(NULL)
BUILT_SOURCES = $(top_srcdir)/.version
EXTRA_DIST = git-version-gen osmoappdesc.py .version
EXTRA_DIST = \
.version \
README.md \
debian \
git-version-gen \
osmoappdesc.py \
$(NULL)
AM_DISTCHECK_CONFIGURE_FLAGS = \
--with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
@RELMAKE@
$(top_srcdir)/.version:
echo $(VERSION) > $@-t && mv $@-t $@
dist-hook:

102
README.md Normal file
View File

@ -0,0 +1,102 @@
osmo-mgw - Osmocom MGW (Media GateWay) Implementation
=====================================================
This repository contains a C-language implementation of an MGW (Media
GateWay) for use [not only] within the 2G (GSM) and/or 3G (UMTS)
Cellular Network built using Osmocom CNI (Cellular Network
Infrastructure) software.
The OsmoMGW program provides an MGCP interface towards an MGCP call agent
(client) like OsmoMSC and OsmoBSC, and receives and sends RTP streams as
configured via the MGCP control plane.
This Media Gateway implementation is capable of
* streaming RTP for 2G (3GPP AoIP and Abis-over-IP)
* streaming RTP for 3G (IuCS including the IuFP protocol)
* TDM (E1/T1) based Abis interface with TRAU frames on 16k sub-slots
* basic support for LCLS (Local Call, Local Switch) related features
* various built-in translation capabilities
* between Abis TRAU frames and RTP formats
* between 2G AMR/RTP and 3G AMR/IuFP/RTP
* between bandwidth-efficient and octet-aligned AMR
* between different standards for encapsulating GSM HR codec frames in RTP
osmo-mgw is typically co-located with
* osmo-bsc (GSM BSC)
* osmo-msc (GSM/UMTS MSC)
* osmo-hnbgw (UMTS HNBGW); osmo-mgw implements RTP relay between Iuh
and IuCS interfaces
The libosmo-mgcp-client library exposes utilities used by e.g. OsmoMSC
(found in osmo-msc.git) to instruct OsmoMGW via its MGCP service.
Homepage
--------
You can find the OsmoMGW issue tracker and wiki online at
<https://osmocom.org/projects/osmo-mgw> and <https://osmocom.org/projects/osmo-mgw/wiki>.
GIT Repository
--------------
You can clone from the official osmo-mgw.git repository using
git clone https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw
There is a web interface at <https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw>
Documentation
-------------
User Manuals and VTY reference manuals are [optionally] built in PDF form
as part of the build process.
Pre-rendered PDF version of the current "master" can be found at
[User Manual](https://ftp.osmocom.org/docs/latest/osmomgw-usermanual.pdf)
as well as the [VTY Reference Manual](https://ftp.osmocom.org/docs/latest/osmomgw-vty-reference.pdf)
Mailing List
------------
Discussions related to osmo-mgw are happening on the
openbsc@lists.osmocom.org mailing list, please see
<https://lists.osmocom.org/mailman/listinfo/openbsc> for subscription
options and the list archive.
Please observe the [Osmocom Mailing List
Rules](https://osmocom.org/projects/cellular-infrastructure/wiki/Mailing_List_Rules)
when posting.
Contributing
------------
Our coding standards are described at
<https://osmocom.org/projects/cellular-infrastructure/wiki/Coding_standards>
We use a gerrit based patch submission/review process for managing
contributions. Please see
<https://osmocom.org/projects/cellular-infrastructure/wiki/Gerrit> for
more details
The current patch queue for osmo-mgw can be seen at
<https://gerrit.osmocom.org/#/q/project:osmo-mgw+status:open>
History
-------
OsmoMGW originated from the OpenBSC project, which started as a minimalistic
all-in-one implementation of the GSM Network. In 2017, OpenBSC had reached
maturity and diversity (including M3UA SIGTRAN and 3G support in the form of
IuCS and IuPS interfaces) that naturally lead to a separation of the all-in-one
approach to fully independent separate programs as in typical GSM networks.
OsmoMGW was one of the parts split off from the old openbsc.git. It originated
as a solution to merely navigate RTP streams through a NAT, but has since
matured.

View File

@ -1,6 +1,6 @@
To run the configuration parsing and output (VTY) test suite, first install
git://git.osmocom.org/python/osmo-python-tests
https://gitea.osmocom.org/cellular-infrastructure/osmo-python-tests
and pass the following configure options here:

43
TODO-RELEASE Normal file
View File

@ -0,0 +1,43 @@
# When cleaning up this file upon a release:
#
# - Note that the release version number is entirely unrelated to the API
# versions. A release version 5.2.3 may happily have an API version of 42:7:5.
#
# - Bump API version in src/lib*/Makefile.am files according to chapter
# "Library interface versions" of the libtool documentation.
# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
#
# - Iff the 'current' API version has changed, rename debian/lib*.install
#
# API version bumping for the impatient:
# LIBVERSION=c:r:a (current:revision_of_current:backwards_compat_age)
# 5:2:4 means that
# - this implements version 5 of the API;
# - this is the 2nd (compatible) revision of API version 5;
# - this is backwards compatible to all APIs since 4 versions ago,
# i.e. callers that need API versions from 1 to 5 can use this.
#
# Bumping API versions recipe:
# If the library source code has changed at all since the last update, r++;
# If any interfaces have been added, removed, or changed since the last update, c++, r=0;
# If any interfaces have been added since the last public release, a++;
# If any interfaces have been removed or changed since the last public release, a=0.
#
#library what description / commit summary line
libosmo-mgcp-client remove public API These public API items have not been called by any of our osmo-programs
for many years. Any sane caller of libosmo-mgcp-client should use the
higher level osmo_mgcpc_* API instead. Move these to a private header:
struct mgcp_response_head
struct mgcp_response
struct mgcp_msg
mgcp_response_parse_params()
mgcp_client_tx()
mgcp_client_cancel()
mgcp_msg_gen()
mgcp_msg_trans_id()
libosmo-mgcp-client deprecate public API New code should no longer use codecs[], instead use ptmap[].codec. There
is backwards compat code that moves codecs[] entries, if any, over to
ptmap[], so callers may migrate at own leisure.
osmo-mgw remove cfg Remove VTY config item 'sdp audio fmtp-extra' (see OS#6313)
libosmocore bump_dep; workaround Bump libosmocore version dependency after I68328adb952ca8833ba047cb3b49ccc6f8a1f1b5
has been merged to libosmocore.git; then remove my_msgb_copy_c wrapper function.

207
configure.ac Normal file
View File

@ -0,0 +1,207 @@
dnl Process this file with autoconf to produce a configure script
AC_INIT([osmo-mgw],
m4_esyscmd([./git-version-gen .tarball-version]),
[openbsc@lists.osmocom.org])
dnl *This* is the root dir, even if an install-sh exists in ../ or ../../
AC_CONFIG_AUX_DIR([.])
AM_INIT_AUTOMAKE([dist-bzip2])
AC_CONFIG_TESTDIR(tests)
CFLAGS="$CFLAGS -std=gnu11"
dnl kernel style compile messages
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
dnl include release helper
RELMAKE='-include osmo-release.mk'
AC_SUBST([RELMAKE])
dnl checks for programs
AC_PROG_MAKE_SET
AC_PROG_CC
AC_PROG_INSTALL
LT_INIT
dnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang
AS_CASE(["$LD"],[*clang*],
[AS_CASE(["${host_os}"],
[*linux*],[archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'])])
dnl check for pkg-config (explained in detail in libosmocore/configure.ac)
AC_PATH_PROG(PKG_CONFIG_INSTALLED, pkg-config, no)
if test "x$PKG_CONFIG_INSTALLED" = "xno"; then
AC_MSG_WARN([You need to install pkg-config])
fi
PKG_PROG_PKG_CONFIG([0.20])
dnl checks for libraries
AC_SEARCH_LIBS([dlopen], [dl dld], [LIBRARY_DL="$LIBS";LIBS=""])
AC_SUBST(LIBRARY_DL)
AC_SEARCH_LIBS([dlsym], [dl dld], [LIBRARY_DLSYM="$LIBS";LIBS=""])
AC_SUBST(LIBRARY_DLSYM)
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.9.0)
PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.9.0)
PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 1.9.0)
PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.9.0)
PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 1.4.0)
PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 1.5.0)
PKG_CHECK_MODULES(LIBOSMOTRAU, libosmotrau >= 1.5.0)
CFLAGS="$CFLAGS -DBUILDING_LIBOSMOMGCPCLIENT -pthread"
CPPFLAGS="$CPPFLAGS -DBUILDING_LIBOSMOMGCPCLIENT -pthread"
LDFLAGS="$LDFLAGS -pthread"
AC_ARG_ENABLE(sanitize,
[AS_HELP_STRING(
[--enable-sanitize],
[Compile with address sanitizer enabled],
)],
[sanitize=$enableval], [sanitize="no"])
if test x"$sanitize" = x"yes"
then
CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
fi
AC_ARG_ENABLE(werror,
[AS_HELP_STRING(
[--enable-werror],
[Turn all compiler warnings into errors, with exceptions:
a) deprecation (allow upstream to mark deprecation without breaking builds);
b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds)
]
)],
[werror=$enableval], [werror="no"])
if test x"$werror" = x"yes"
then
WERROR_FLAGS="-Werror"
WERROR_FLAGS+=" -Werror=implicit-int -Werror=int-conversion -Werror=old-style-definition"
WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations"
WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
CFLAGS="$CFLAGS $WERROR_FLAGS"
CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
fi
# Coverage build taken from WebKit's configure.in
AC_MSG_CHECKING([whether to enable code coverage support])
AC_ARG_ENABLE(coverage,
AC_HELP_STRING([--enable-coverage],
[enable code coverage support [default=no]]),
[],[enable_coverage="no"])
AC_MSG_RESULT([$enable_coverage])
if test "$enable_coverage" = "yes"; then
COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs"
COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs"
AC_SUBST([COVERAGE_CFLAGS])
AC_SUBST([COVERAGE_LDFLAGS])
fi
AC_ARG_ENABLE([vty_tests],
AC_HELP_STRING([--enable-vty-tests],
[Include the VTY/CTRL tests in make check (deprecated)
[default=no]]),
[enable_ext_tests="$enableval"],[enable_ext_tests="no"])
AC_ARG_ENABLE([external_tests],
AC_HELP_STRING([--enable-external-tests],
[Include the VTY/CTRL tests in make check [default=no]]),
[enable_ext_tests="$enableval"],[enable_ext_tests="no"])
if test "x$enable_ext_tests" = "xyes" ; then
AM_PATH_PYTHON
AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
AC_MSG_ERROR([Please install https://gitea.osmocom.org/cellular-infrastructure/osmo-python-tests to run the VTY/CTRL tests.])
fi
fi
AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
AC_MSG_RESULT([$enable_ext_tests])
AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
# Generate manuals
AC_ARG_ENABLE(manuals,
[AS_HELP_STRING(
[--enable-manuals],
[Generate manual PDFs [default=no]],
)],
[osmo_ac_build_manuals=$enableval], [osmo_ac_build_manuals="no"])
AM_CONDITIONAL([BUILD_MANUALS], [test x"$osmo_ac_build_manuals" = x"yes"])
AC_ARG_VAR(OSMO_GSM_MANUALS_DIR, [path to common osmo-gsm-manuals files, overriding pkg-config and "../osmo-gsm-manuals"
fallback])
if test x"$osmo_ac_build_manuals" = x"yes"
then
# Find OSMO_GSM_MANUALS_DIR (env, pkg-conf, fallback)
if test -n "$OSMO_GSM_MANUALS_DIR"; then
echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from env)"
else
OSMO_GSM_MANUALS_DIR="$($PKG_CONFIG osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null)"
if test -n "$OSMO_GSM_MANUALS_DIR"; then
echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from pkg-conf)"
else
OSMO_GSM_MANUALS_DIR="../osmo-gsm-manuals"
echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (fallback)"
fi
fi
if ! test -d "$OSMO_GSM_MANUALS_DIR"; then
AC_MSG_ERROR("OSMO_GSM_MANUALS_DIR does not exist! Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR.")
fi
# Find and run check-depends
CHECK_DEPENDS="$OSMO_GSM_MANUALS_DIR/check-depends.sh"
if ! test -x "$CHECK_DEPENDS"; then
CHECK_DEPENDS="osmo-gsm-manuals-check-depends"
fi
if ! $CHECK_DEPENDS; then
AC_MSG_ERROR("missing dependencies for --enable-manuals")
fi
# Put in Makefile with absolute path
OSMO_GSM_MANUALS_DIR="$(realpath "$OSMO_GSM_MANUALS_DIR")"
AC_SUBST([OSMO_GSM_MANUALS_DIR])
fi
# https://www.freedesktop.org/software/systemd/man/daemon.html
AC_ARG_WITH([systemdsystemunitdir],
[AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
[with_systemdsystemunitdir=auto])
AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
AS_IF([test "x$def_systemdsystemunitdir" = "x"],
[AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
[AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
with_systemdsystemunitdir=no],
[with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
[AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
AC_MSG_RESULT([CFLAGS="$CFLAGS"])
AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
dnl Generate the output
AM_CONFIG_HEADER(bscconfig.h)
AC_OUTPUT(
libosmo-mgcp-client.pc
include/Makefile
include/osmocom/Makefile
include/osmocom/mgcp_client/Makefile
include/osmocom/mgcp/Makefile
src/Makefile
src/libosmo-mgcp-client/Makefile
src/libosmo-mgcp/Makefile
src/osmo-mgw/Makefile
tests/Makefile
tests/atlocal
tests/mgcp_client/Makefile
tests/mgcp/Makefile
doc/Makefile
doc/examples/Makefile
doc/manuals/Makefile
contrib/Makefile
contrib/systemd/Makefile
Makefile)

3
contrib/Makefile.am Normal file
View File

@ -0,0 +1,3 @@
SUBDIRS = systemd
EXTRA_DIST = ipa.py

View File

@ -15,10 +15,6 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
"""

View File

@ -1,4 +1,16 @@
#!/usr/bin/env bash
# jenkins build helper script for openbsc. This is how we build on jenkins.osmocom.org
#
# environment variables:
# * WITH_MANUALS: build manual PDFs if set to "1"
# * PUBLISH: upload manuals after building if set to "1" (ignored without WITH_MANUALS = "1")
#
if ! [ -x "$(command -v osmo-build-dep.sh)" ]; then
echo "Error: We need to have scripts/osmo-deps.sh from http://git.osmocom.org/osmo-ci/ in PATH !"
exit 2
fi
set -ex
@ -7,45 +19,48 @@ deps="$base/deps"
inst="$deps/install"
export deps inst
mkdir "$deps" || true
rm -rf "$inst"
osmo-clean-workspace.sh
mkdir "$deps" || true
osmo-build-dep.sh libosmocore "" ac_cv_path_DOXYGEN=false
verify_value_string_arrays_are_terminated.py $(find . -name "*.[hc]")
export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH"
export LD_LIBRARY_PATH="$inst/lib"
if [ "x$IU" = "x--enable-iu" ]; then
netif_branch="sysmocom/sctp"
sccp_branch="sysmocom/iu"
fi
export PATH="$inst/bin:$PATH"
osmo-build-dep.sh libosmo-abis
osmo-build-dep.sh libosmo-netif $netif_branch
osmo-build-dep.sh libosmo-sccp $sccp_branch
PARALLEL_MAKE="" osmo-build-dep.sh libsmpp34
osmo-build-dep.sh openggsn
osmo-build-dep.sh libosmo-netif
if [ "x$IU" = "x--enable-iu" ]; then
osmo-build-dep.sh libasn1c
#osmo-build-dep.sh asn1c aper-prefix # only needed for make regen in osmo-iuh
osmo-build-dep.sh osmo-iuh
# Additional configure options and depends
CONFIG=""
if [ "$WITH_MANUALS" = "1" ]; then
CONFIG="--enable-manuals"
fi
set +x
echo
echo
echo
echo " =============================== openbsc ==============================="
echo " =============================== osmo-mgw ==============================="
echo
set -x
cd "$base"
cd openbsc
autoreconf --install --force
./configure --enable-osmo-bsc --enable-nat $SMPP $MGCP $IU --enable-vty-tests --enable-external-tests
./configure --enable-sanitize --enable-vty-tests --enable-external-tests --enable-werror $CONFIG
$MAKE $PARALLEL_MAKE
LD_LIBRARY_PATH="$inst/lib" $MAKE check \
|| cat-testlogs.sh
LD_LIBRARY_PATH="$inst/lib" $MAKE distcheck \
LD_LIBRARY_PATH="$inst/lib" \
DISTCHECK_CONFIGURE_FLAGS="--enable-vty-tests --enable-external-tests $CONFIG" \
$MAKE $PARALLEL_MAKE distcheck \
|| cat-testlogs.sh
if [ "$WITH_MANUALS" = "1" ] && [ "$PUBLISH" = "1" ]; then
make -C "$base/doc/manuals" publish
fi
$MAKE $PARALLEL_MAKE maintainer-clean
osmo-clean-workspace.sh

View File

@ -0,0 +1,6 @@
EXTRA_DIST = osmo-mgw.service
if HAVE_SYSTEMD
systemdsystemunit_DATA = \
osmo-mgw.service
endif

View File

@ -0,0 +1,24 @@
[Unit]
Description=Osmocom Media Gateway (MGW)
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
LimitNOFILE=65536
StateDirectory=osmocom
WorkingDirectory=%S/osmocom
Restart=always
User=osmocom
Group=osmocom
ExecStart=/usr/bin/osmo-mgw -s -c /etc/osmocom/osmo-mgw.cfg
RestartSec=2
AmbientCapabilities=CAP_SYS_NICE
# CPU scheduling policy:
CPUSchedulingPolicy=rr
# For real-time scheduling policies an integer between 1 (lowest priority) and 99 (highest priority):
CPUSchedulingPriority=1
# See sched(7) for further details on real-time policies and priorities
[Install]
WantedBy=multi-user.target

1
debian/autoreconf vendored
View File

@ -1 +0,0 @@
openbsc

1018
debian/changelog vendored

File diff suppressed because it is too large Load Diff

2
debian/compat vendored
View File

@ -1 +1 @@
9
10

203
debian/control vendored
View File

@ -1,181 +1,46 @@
Source: openbsc
Maintainer: Harald Welte <laforge@gnumonks.org>
Source: osmo-mgw
Section: net
Priority: optional
Build-Depends: debhelper (>= 9),
autotools-dev,
autoconf-archive,
pkg-config,
libgtp-dev,
libosmocore-dev,
libosmo-sccp-dev,
libdbi0-dev,
Priority: extra
Maintainer: Osmocom team <openbsc@lists.osmocom.org>
Build-Depends: debhelper (>= 10),
dh-autoreconf,
libosmo-abis-dev,
libosmo-netif-dev,
libdbd-sqlite3,
libpcap-dev,
libssl-dev,
libc-ares-dev,
libsmpp34-dev
pkg-config,
autotools-dev,
libosmocore-dev (>= 1.9.0),
libosmo-netif-dev (>= 1.4.0),
libosmo-abis-dev (>= 1.5.0),
osmo-gsm-manuals-dev (>= 1.5.0)
Standards-Version: 3.9.8
Vcs-Git: git://bs11-abis.gnumonks.org/openbsc.git
Vcs-Browser: http://openbsc.osmocom.org/trac/browser
Homepage: https://projects.osmocom.org/projects/openbsc
Vcs-Git: https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw
Vcs-Browser: https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw
Homepage: https://osmocom.org/projects/osmo-mgw
Package: osmocom-bsc
Package: osmo-mgw
Architecture: any
Depends: ${shlibs:Depends},
${misc:Depends}
Description: GSM Base Station Controller
This is the BSC-only version of OpenBSC. It requires a Mobile Switching Center
(MSC) to operate.
.
You might rather prefer to use osmocom-nitb which is considered a
"GSM Network-in-a-Box" and does not depend on a MSC.
Multi-Arch: foreign
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: OsmoMGW: Osmocom's Media Gateway for 2G and 3G circuit-switched mobile networks
Package: osmocom-nitb
Package: libosmo-mgcp-client12
Section: libs
Architecture: any
Depends: ${shlibs:Depends},
${misc:Depends},
libdbd-sqlite3
Description: GSM Network-in-a-Box, implements BSC, MSC, SMSC, HLR, VLR
This is the Network-in-a-Box version of OpenBSC. It has all the GSM network
components bundled together. When using osmocom-nitb, there is no need for a
Mobile Switching Center (MSC) which is needed when using osmocom-bsc.
Multi-Arch: same
Pre-Depends: ${misc:Pre-Depends}
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: libosmo-mgcp-client: Osmocom's Media Gateway Control Protocol client utilities
Package: osmocom-ipaccess-utils
Package: libosmo-mgcp-client-dev
Section: libdevel
Architecture: any
Depends: ${shlibs:Depends},
${misc:Depends}
Description: Command line utilities for ip.access nanoBTS
This package contains utilities that are specific for nanoBTS when being used
together with OpenBSC. It contains mainly three tools: ipaccess-find,
ipaccess-config and ipaccess-proxy.
Multi-Arch: same
Depends: libosmo-mgcp-client12 (= ${binary:Version}), ${misc:Depends}
Description: libosmo-mgcp-client: Osmocom's Media Gateway Control Protocol client utilities
Package: osmocom-bs11-utils
Architecture: any
Depends: ${shlibs:Depends},
${misc:Depends}
Description: Command line utilities for Siemens BS-11 BTS
There is a tool in this package for configuring the Siemens BS-11 BTS.
Additionally, it contains one tool for making use of an ISDN-card and the
public telephone network as frequency standard for the E1 line.
Package: osmocom-sgsn
Architecture: any
Depends: ${shlibs:Depends},
${misc:Depends}
Suggests: osmocom-bsc
Description: Osmocom Serving GPRS Support Node
This is an implementation of the GPRS Serving GPRS Support Node (SGSN). As
such it implements the GPRS Mobility Management (GMM) and SM (Session
Management).
.
The SGSN connects via the Gb-interface to the BSS (like the osmo-pcu or an
ip.access nanoBTS), and it connects via the GTP protocol to a Gateway GPRS
Support Node (GGSN) like openggsn.
Package: osmocom-gbproxy
Architecture: any
Depends: ${shlibs:Depends},
${misc:Depends}
Recommends: osmocom-sgsn
Description: Osmocom GPRS Gb Interface Proxy
The purpose of the Gb proxy is to aggregate the Gb links of multiple
BSS's and present them in one Gb link to the SGSN.
.
This package is part of OpenBSC and closely related to osmocom-sgsn.
Package: osmocom-bsc-nat
Architecture: any
Depends: ${shlibs:Depends},
${misc:Depends}
Recommends: osmocom-bsc
Description: Osmocom Base Station Controller Network Address Translation
This NAT is useful for masquerading multiple BSCs behind one. It listens
for incoming BSCs on port 5000 and connects to a specified Mobile Switching
Center (MSC).
.
This package is part of OpenBSC and closely related to osmocom-bsc.
Package: openbsc-dev
Package: osmo-mgw-doc
Architecture: all
Section: doc
Priority: optional
Depends: ${misc:Depends}
Description: Header file needed by tools tightly integrated
Some other programs depend on gsm_data_shared.h and gsm_data_shared.c
from OpenBSC. This package installs these files to your file system so
that the other packages can build-depend on this package.
.
The directory structure is copied after the structure in the repository
and the header and .c file are installed into /usr/src/osmocom/openbsc/.
Package: osmo-gtphub
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Osmocom GTP Hub
Proxy for comms between multiple SGSNs and GGSNs.
Package: osmocom-bsc-dbg
Architecture: any
Section: debug
Priority: extra
Depends: osmocom-bsc (= ${binary:Version}), ${misc:Depends}
Description: Debug symbols for the OpenBSC BSC
Make debugging possible
Package: osmocom-nitb-dbg
Architecture: any
Section: debug
Priority: extra
Depends: osmocom-nitb (= ${binary:Version}), ${misc:Depends}
Description: Debug symbols for the OpenBSC NITB
Make debugging possible
Package: osmocom-ipaccess-utils-dbg
Architecture: any
Section: debug
Priority: extra
Depends: osmocom-ipaccess-utils (= ${binary:Version}), ${misc:Depends}
Description: Debug symbols for the OpenBSC ip.access utils
Make debugging possible
Package: osmocom-bs11-utils-dbg
Architecture: any
Section: debug
Priority: extra
Depends: osmocom-bs11-utils (= ${binary:Version}), ${misc:Depends}
Description: Debug symbols for the OpenBSC BS11 utils
Make debugging possible
Package: osmocom-sgsn-dbg
Architecture: any
Section: debug
Priority: extra
Depends: osmocom-sgsn (= ${binary:Version}), ${misc:Depends}
Description: Debug symbols for the OpenBSC Serving GPRS Support Node
Make debugging possible
Package: osmocom-gbproxy-dbg
Architecture: any
Section: debug
Priority: extra
Depends: osmocom-gbproxy (= ${binary:Version}), ${misc:Depends}
Description: Debug symbols for the OpenBSC GPRS GBProxy
Make debugging possible
Package: osmocom-bsc-nat-dbg
Architecture: any
Section: debug
Priority: extra
Depends: osmocom-bsc-nat (= ${binary:Version}), ${misc:Depends}
Description: Debug symbols for the OpenBSC Network Address Translation
Make debugging possible
Package: osmo-gtphub-dbg
Architecture: any
Section: debug
Priority: extra
Depends: osmo-gtphub (= ${binary:Version}), ${misc:Depends}
Description: Debug symbols for Osmocom GTP Hub
Make debugging possible
Description: ${misc:Package} PDF documentation
Various manuals: user manual, VTY reference manual and/or
protocol/interface manuals.

168
debian/copyright vendored
View File

@ -1,74 +1,14 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: OpenBSC
Source: http://openbsc.osmocom.org/
Upstream-Name: osmo-mgw
Source: https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw
Files: *
Copyright: 2008-2015 Harald Welte <laforge@gnumonks.org>
2008-2015 Holger Hans Peter Freyther <zecke@selfish.org>
2009-2015 On-Waves
2008 Jan Luebbe <jluebbe@debian.org>
2008,2010-2011 Daniel Willmann <daniel@totalueberwachung.de>
2009,2011,2013 Andreas Eversberg <Andreas.Eversberg@versatel.de>
2009,2011 Dieter Spaar <spaar@mirider.augusta.de>
2009 Mike Haben <michael.haben@btinternet.com>
2010 Sylvain Munaut <246tnt@gmail.com>
2012-2013 Pablo Neira Ayuso <pablo@gnumonks.org>
2013-2015 Sysmocom s.f.m.c. GmbH (Jacob Erlbeck)
2014 Alexander Chemeris <Alexander.Chemeris@fairwaves.co>
License: AGPL-3+
Comment: Contributions by Stefan Schmidt <stefan@datenfreihafen.org> as well
Files: wireshark/0001-abis_oml.patch
wireshark/0002-ericsson_rbs2409.patch
wireshark/0003-lucent-hnb.patch
wireshark/0005-rsl-hsl.patch
Copyright: 1998 Gerald Combs <gerald@wireshark.org>
2007,2011 Anders Broman <anders.broman@ericsson.com>
2009 Holger Hans Peter Freyther <zecke@selfish.org>
2009-2011 Harald Welte <laforge@gnumonks.org>
License: GPL-2+
Files: openbsc/include/mISDNif.h
Copyright: 2008 Karsten Keil <kkeil@novell.com>
License: LGPL-2.1
Files: openbsc/src/libmgcp/g711common.h
Copyright: 2009 Abramo Bagnara <abramo@alsa-project.org>
License: GPL-2+
Files: openbsc/git-version-gen
Copyright: 2007-2010 Free Software Foundation
License: GPL-3+
Files: openbsc/osmoappdesc.py
openbsc/tests/smpp_test_runner.py
openbsc/tests/ctrl_test_runner.py
openbsc/tests/vty_test_runner.py
Copyright: 2013 Katerina Barone-Adesi <kat.obsc@gmail.com>
2013 Jacob Erlbeck <jerlbeck@sysmocom.de>
2013-2014 Holger Hans Peter Freyther <zecke@selfish.org>
License: GPL-3+
Files: openbsc/src/libbsc/bsc_ctrl_lookup.c
Copyright: 2010-2011 Daniel Willmann <daniel@totalueberwachung.de>
2010-2011 On-Waves
License: GPL-2+
Files: openbsc/src/libmsc/mncc_sock.c
openbsc/src/libmsc/mncc_builtin.c
Copyright: 2008-2010 Harald Welte <laforge@gnumonks.org>
2009 Andreas Eversberg <Andreas.Eversberg@versatel.de>
2012 Holger Hans Peter Freyther <zecke@selfish.org>
License: GPL-2+
Files: debian/*
Copyright: 2012-2015 Holger Hans Peter Freyther <zecke@selfish.org>
2016 Ruben Undheim <ruben.undheim@gmail.com>
License: GPL-2+
License: AGPL-3+
This package is free software; you can redistribute it and/or modify
Files: *
Copyright: 2009-2014 On-Waves
2009-2015 Holger Hans Peter Freyther <zecke@selfish.org>
2013 Jacob Erlbeck <jerlbeck@sysmocom.de>
2016-2017 sysmocom s.f.m.c. GmbH <info@sysmocom.de>
License: AGPL-3.0+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
@ -76,62 +16,50 @@ License: AGPL-3+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GNU Affero General Public License for more details.
.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
License: GPL-2+
This package is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or (at
your option) any later version.
Files: src/libosmo-mgcp-client/* include/osmocom/mgcp_client/*
Copyright: 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
Based on OpenBSC interface to quagga VTY (libmsc/vty_interface_layer3.c)
2009 by Harald Welte <laforge@gnumonks.org>
2009-2011 by Holger Hans Peter Freyther
License: GPL-2.0+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
.
On Debian systems, the complete text of the GNU General Public
License version 2 can be found in "/usr/share/common-licenses/GPL-2".
License: GPL-3+
This package is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
.
On Debian systems, the complete text of the GNU General Public
License version 3 can be found in "/usr/share/common-licenses/GPL-3".
License: LGPL-2.1
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; version
2.1 of the License.
.
This library is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Files: tests/vty_test_runner.py
Copyright: 2013 Holger Hans Peter Freyther
2013 Katerina Barone-Adesi <kat.obsc@gmail.com>
License: GPL-3.0+
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
.
On Debian systems, the complete text of the GNU Lesser General
Public License version 2.1 can be found in
"/usr/share/common-licenses/LGPL-2.1".
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
.
On Debian systems, the complete text of the GNU General Public License
Version 3 can be found in `/usr/share/common-licenses/GPL-3'.
Files: osmoappdesc.py
Copyright: 2013 Katerina Barone-Adesi <kat.obsc@gmail.com>
License: GPL-3.0+

1
debian/docs vendored
View File

@ -1 +0,0 @@
openbsc/README

View File

@ -0,0 +1,4 @@
usr/include/osmocom/mgcp_client
usr/lib/*/libosmo-mgcp-client.so
usr/lib/*/libosmo-mgcp-client.a
usr/lib/*/pkgconfig/libosmo-mgcp-client.pc

1
debian/libosmo-mgcp-client12.install vendored Normal file
View File

@ -0,0 +1 @@
usr/lib/*/libosmo-mgcp-client.so.*

View File

@ -1,3 +0,0 @@
openbsc/include/openbsc/gsm_data_shared.h usr/src/osmocom/openbsc/openbsc/include/openbsc/
openbsc/include/openbsc/common_cs.h usr/src/osmocom/openbsc/openbsc/include/openbsc/
openbsc/src/libcommon/gsm_data_shared.c usr/src/osmocom/openbsc/openbsc/src/libcommon/

View File

@ -1,2 +0,0 @@
CONFIG_FILE="/etc/osmocom/osmo-gtphub.cfg"

View File

@ -1 +0,0 @@
openbsc/doc/examples/osmo-gtphub

View File

@ -1,150 +0,0 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: osmo-gtphub
# Required-Start: $network $local_fs
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Osmocom GTP hub
# Description: Osmocom GTP hub
### END INIT INFO
# Author: Neels Hofmeyr <nhofmeyr@sysmocom.de>
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
NAME=osmo-gtphub # Introduce the short server's name here
DESC="Osmocom GTP hub" # Introduce a short description here
DAEMON=/usr/bin/osmo-gtphub # Introduce the server's location here
SCRIPTNAME=/etc/init.d/osmo-gtphub
# Exit if the package is not installed
[ -x $DAEMON ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/osmo-gtphub ] && . /etc/default/osmo-gtphub
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
DAEMON_ARGS="$DAEMON_ARGS -D -c $CONFIG_FILE"
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
return "$RETVAL"
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
#
# If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
#
start-stop-daemon --stop --signal 1 --quiet $PIDFILE --name $NAME
return 0
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
#reload|force-reload)
#
# If do_reload() is not implemented then leave this commented out
# and leave 'force-reload' as an alias for 'restart'.
#
#log_daemon_msg "Reloading $DESC" "$NAME"
#do_reload
#log_end_msg $?
#;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:

View File

@ -1 +0,0 @@
/usr/bin/osmo-gtphub

1
debian/osmo-mgw-doc.install vendored Normal file
View File

@ -0,0 +1 @@
usr/share/doc/osmo-mgw-doc/*.pdf

5
debian/osmo-mgw.install vendored Normal file
View File

@ -0,0 +1,5 @@
etc/osmocom/osmo-mgw.cfg
lib/systemd/system/osmo-mgw.service
usr/bin/osmo-mgw
usr/share/doc/osmo-mgw/examples/osmo-mgw/osmo-mgw.cfg
usr/share/doc/osmo-mgw/examples/osmo-mgw/osmo-mgw-abis_e1.cfg

View File

@ -1,2 +0,0 @@
/usr/bin/bs11_config
/usr/bin/isdnsync

View File

@ -1,153 +0,0 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: osmocom-bsc-nat
# Required-Start: $network $local_fs
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Osmocom GSM network-in-a-box
# Description: A minimal implementation of the GSM Base Station Controller,
# Mobile Switching Center, Home Location regster and all other
# components to run a self-contained GSM network.
### END INIT INFO
# Author: Harald Welte <laforge@gnumonks.org>
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
NAME=osmo-bsc_nat # Introduce the short server's name here
DESC="Osmocom GSM BSC Multiplexer (NAT)" # Introduce a short description here
DAEMON=/usr/bin/osmo-bsc_nat # Introduce the server's location here
SCRIPTNAME=/etc/init.d/osmocom-bsc-nat
CONFIG_FILE=/etc/osmocom/osmocom-bsc-nat.cfg
# Exit if the package is not installed
[ -x $DAEMON ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/osmocom-bsc-nat ] && . /etc/default/osmocom-bsc-nat
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
DAEMON_ARGS="-D -c $CONFIG_FILE"
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
return "$RETVAL"
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
#
# If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
#
start-stop-daemon --stop --signal 1 --quiet $PIDFILE --name $NAME
return 0
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
#reload|force-reload)
#
# If do_reload() is not implemented then leave this commented out
# and leave 'force-reload' as an alias for 'restart'.
#
#log_daemon_msg "Reloading $DESC" "$NAME"
#do_reload
#log_end_msg $?
#;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:

View File

@ -1 +0,0 @@
/usr/bin/osmo-bsc_nat

View File

@ -1 +0,0 @@
openbsc/doc/examples/osmo-bsc_mgcp

View File

@ -1,2 +0,0 @@
/usr/bin/osmo-bsc_mgcp
/usr/bin/osmo-bsc

View File

@ -1,151 +0,0 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: osmo-gbproxy
# Required-Start: $network $local_fs
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Osmocom GBproxy
# Description: A tool to proxy the GPRS Gb interface.
### END INIT INFO
# Author: Harald Welte <laforge@gnumonks.org>
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
NAME=osmo-gbproxy # Introduce the short server's name here
DESC="Osmocom GBProxy" # Introduce a short description here
DAEMON=/usr/bin/osmo-gbproxy # Introduce the server's location here
SCRIPTNAME=/etc/init.d/osmocom-gbproxy
CONFIG_FILE=/etc/osmocom/osmocom-gbproxy.cfg
# Exit if the package is not installed
[ -x $DAEMON ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/osmocom-gbproxy ] && . /etc/default/osmocom-gbproxy
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
DAEMON_ARGS="-D -c $CONFIG_FILE"
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
return "$RETVAL"
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
#
# If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
#
start-stop-daemon --stop --signal 1 --quiet $PIDFILE --name $NAME
return 0
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
#reload|force-reload)
#
# If do_reload() is not implemented then leave this commented out
# and leave 'force-reload' as an alias for 'restart'.
#
#log_daemon_msg "Reloading $DESC" "$NAME"
#do_reload
#log_end_msg $?
#;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:

View File

@ -1 +0,0 @@
/usr/bin/osmo-gbproxy

View File

@ -1,3 +0,0 @@
/usr/bin/ipaccess-config
/usr/bin/abisip-find
/usr/bin/ipaccess-proxy

View File

@ -1,8 +0,0 @@
CONFIG_FILE="/etc/osmocom/osmo-nitb.cfg"
HLR_FILE="/var/lib/osmocom/hlr.sqlite3"
DAEMON_ARGS="-P"
# Uncomment if using LCR+Asterisk
# DAEMON_ARGS="-m -P"

View File

@ -1,3 +0,0 @@
/etc/osmocom
/var/log/osmocom
/var/lib/osmocom

View File

@ -1 +0,0 @@
openbsc/doc/examples/osmo-nitb

View File

@ -1,152 +0,0 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: osmo-nitb
# Required-Start: $network $local_fs
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Osmocom GSM network-in-a-box
# Description: A minimal implementation of the GSM Base Station Controller,
# Mobile Switching Center, Home Location regster and all other
# components to run a self-contained GSM network.
### END INIT INFO
# Author: Harald Welte <laforge@gnumonks.org>
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
NAME=osmo-nitb # Introduce the short server's name here
DESC="Osmocom GSM Network-in-a-Box" # Introduce a short description here
DAEMON=/usr/bin/osmo-nitb # Introduce the server's location here
SCRIPTNAME=/etc/init.d/osmocom-nitb
# Exit if the package is not installed
[ -x $DAEMON ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/osmocom-nitb ] && . /etc/default/osmocom-nitb
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
DAEMON_ARGS="$DAEMON_ARGS -D -c $CONFIG_FILE -l $HLR_FILE"
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
return "$RETVAL"
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
#
# If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
#
start-stop-daemon --stop --signal 1 --quiet $PIDFILE --name $NAME
return 0
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
#reload|force-reload)
#
# If do_reload() is not implemented then leave this commented out
# and leave 'force-reload' as an alias for 'restart'.
#
#log_daemon_msg "Reloading $DESC" "$NAME"
#do_reload
#log_end_msg $?
#;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:

View File

@ -1 +0,0 @@
/usr/bin/osmo-nitb

View File

@ -1,2 +0,0 @@
CONFIG_FILE="/etc/osmocom/osmo-sgsn.cfg"

View File

@ -1 +0,0 @@
openbsc/doc/examples/osmo-sgsn

View File

@ -1,150 +0,0 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: osmo-sgsn
# Required-Start: $network $local_fs
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Osmocom Serving GPRS Support Node
# Description: Osmocom Serving GPRS Support Node
### END INIT INFO
# Author: Harald Welte <laforge@gnumonks.org>
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
NAME=osmo-sgsn # Introduce the short server's name here
DESC="Osmocom Serving GPRS Support Node" # Introduce a short description here
DAEMON=/usr/bin/osmo-sgsn # Introduce the server's location here
SCRIPTNAME=/etc/init.d/osmocom-sgsn
# Exit if the package is not installed
[ -x $DAEMON ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/osmocom-sgsn ] && . /etc/default/osmocom-sgsn
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
DAEMON_ARGS="$DAEMON_ARGS -D -c $CONFIG_FILE"
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
return "$RETVAL"
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
#
# If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
#
start-stop-daemon --stop --signal 1 --quiet $PIDFILE --name $NAME
return 0
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
#reload|force-reload)
#
# If do_reload() is not implemented then leave this commented out
# and leave 'force-reload' as an alias for 'restart'.
#
#log_daemon_msg "Reloading $DESC" "$NAME"
#do_reload
#log_end_msg $?
#;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:

View File

@ -1 +0,0 @@
/usr/bin/osmo-sgsn

38
debian/postinst vendored Executable file
View File

@ -0,0 +1,38 @@
#!/bin/sh -e
case "$1" in
configure)
# Create the osmocom group and user (if it doesn't exist yet)
if ! getent group osmocom >/dev/null; then
groupadd --system osmocom
fi
if ! getent passwd osmocom >/dev/null; then
useradd \
--system \
--gid osmocom \
--home-dir /var/lib/osmocom \
--shell /sbin/nologin \
--comment "Open Source Mobile Communications" \
osmocom
fi
# Fix permissions of previous (root-owned) install (OS#4107)
if dpkg --compare-versions "$2" le "1.13.0"; then
if [ -e /etc/osmocom/osmo-mgw.cfg ]; then
chown -v osmocom:osmocom /etc/osmocom/osmo-mgw.cfg
chmod -v 0660 /etc/osmocom/osmo-mgw.cfg
fi
if [ -d /etc/osmocom ]; then
chown -v root:osmocom /etc/osmocom
chmod -v 2775 /etc/osmocom
fi
mkdir -p /var/lib/osmocom
chown -R -v osmocom:osmocom /var/lib/osmocom
fi
;;
esac
# dh_installdeb(1) will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#

47
debian/rules vendored
View File

@ -1,32 +1,39 @@
#!/usr/bin/make -f
# You must remove unused comment lines for the released package.
# See debhelper(7) (uncomment to enable)
# This is an autogenerated template for debian/rules.
#
# Output every command that modifies files on the build system.
#export DH_VERBOSE = 1
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
DEBIAN := $(shell dpkg-parsechangelog | grep ^Version: | cut -d' ' -f2)
DEBIAN := $(shell dpkg-parsechangelog | grep '^Version:' | cut -d' ' -f2)
DEBVERS := $(shell echo '$(DEBIAN)' | cut -d- -f1)
VERSION := $(shell echo '$(DEBVERS)' | sed -e 's/[+-].*//' -e 's/~//g')
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
CFLAGS += -g
# main packaging script based on dh7 syntax
%:
dh $@ --sourcedirectory=openbsc --with autoreconf
dh $@ --with autoreconf
# This is needed for debian stable (squeeze)
override_dh_autoreconf:
cd openbsc && autoreconf --install --force
# debmake generated override targets
# Set options for ./configure
#CONFIGURE_FLAGS = <options for ./configure>
#overrride_dh_configure:
# dh_configure -- $(CONFIGURE_FLAGS)
#
# Do not install libtool archive, python .pyc .pyo
#override_dh_install:
# dh_install --list-missing -X.la -X.pyc -X.pyo
override_dh_strip:
dh_strip -posmocom-bsc --dbg-package=osmocom-bsc-dbg
dh_strip -posmocom-nitb --dbg-package=osmocom-nitb-dbg
dh_strip -posmocom-ipaccess-utils --dbg-package=osmocom-ipaccess-utils-dbg
dh_strip -posmocom-bs11-utils --dbg-package=osmocom-bs11-utils-dbg
dh_strip -posmocom-sgsn --dbg-package=osmocom-sgsn-dbg
dh_strip -posmocom-gbproxy --dbg-package=osmocom-gbproxy-dbg
dh_strip -posmocom-bsc-nat --dbg-package=osmocom-bsc-nat-dbg
dh_strip -posmo-gtphub --dbg-package=osmo-gtphub-dbg
override_dh_auto_test:
dh_auto_test || (find . -name testsuite.log -exec cat {} \; ; false)
override_dh_auto_configure:
echo $(VERSION) > openbsc/.tarball-version
dh_auto_configure --sourcedirectory=openbsc -- --enable-nat --enable-osmo-bsc --enable-smpp
dh_auto_configure -- --with-systemdsystemunitdir=/lib/systemd/system --enable-manuals
# Don't create .pdf.gz files (barely saves space and they can't be opened directly by most pdf readers)
override_dh_compress:
dh_compress -X.pdf
# See https://www.debian.org/doc/manuals/developers-reference/best-pkging-practices.html#bpp-dbg

View File

@ -1,3 +1,4 @@
SUBDIRS = \
examples \
manuals \
$(NULL)

View File

@ -1,3 +1,11 @@
OSMOCONF_FILES = \
osmo-mgw/osmo-mgw.cfg
osmoconfdir = $(sysconfdir)/osmocom
osmoconf_DATA = $(OSMOCONF_FILES)
EXTRA_DIST = $(OSMOCONF_FILES)
CFG_FILES = find $(srcdir) -name '*.cfg*' | sed -e 's,^$(srcdir),,'
dist-hook:

View File

@ -0,0 +1,30 @@
!
! MGCP configuration example
!
log stderr
logging color 1
logging print category-hex 0
logging print category 1
logging timestamp 0
logging print file basename last
logging print level 1
e1_input
e1_line 0 driver dahdi
e1_line 0 port 0
mgcp
bind ip 127.0.0.1
rtp port-range 4002 16001
rtp bind-ip 127.0.0.1
rtp ip-probing
rtp ip-dscp 46
bind port 2427
number endpoints 512
force-realloc 1
rtcp-omit
rtp-patch ssrc
rtp-patch timestamp
trunk 1
rtp keep-alive once
no rtp keep-alive
line 0

View File

@ -0,0 +1,23 @@
!
! MGCP configuration example
!
log stderr
logging color 1
logging print category-hex 0
logging print category 1
logging timestamp 0
logging print file basename last
logging print level 1
mgcp
bind ip 127.0.0.1
rtp port-range 4002 16001
rtp bind-ip 127.0.0.1
rtp ip-probing
rtp ip-dscp 46
bind port 2427
number endpoints 512
force-realloc 1
rtcp-omit
rtp-patch ssrc
rtp-patch timestamp

23
doc/manuals/Makefile.am Normal file
View File

@ -0,0 +1,23 @@
EXTRA_DIST = osmomgw-usermanual.adoc \
osmomgw-usermanual-docinfo.xml \
osmomgw-vty-reference.xml \
regen_doc.sh \
chapters \
vty
if BUILD_MANUALS
ASCIIDOC = osmomgw-usermanual.adoc
ASCIIDOC_DEPS = $(srcdir)/chapters/*.adoc
include $(OSMO_GSM_MANUALS_DIR)/build/Makefile.asciidoc.inc
VTY_REFERENCE = osmomgw-vty-reference.xml
include $(OSMO_GSM_MANUALS_DIR)/build/Makefile.vty-reference.inc
BUILT_REFERENCE_XML = $(builddir)/vty/mgw_vty_reference.xml
$(builddir)/vty/mgw_vty_reference.xml: $(top_builddir)/src/osmo-mgw/osmo-mgw
mkdir -p $(builddir)/vty
$(top_builddir)/src/osmo-mgw/osmo-mgw --vty-ref-xml > $@
OSMO_REPOSITORY = osmo-mgw
include $(OSMO_GSM_MANUALS_DIR)/build/Makefile.common.inc
endif

View File

@ -0,0 +1,129 @@
== Configuring OsmoMGW
A basic configation of OsmoMGW mainly consists of specifying the IP address
and port on which to listen to MGCP commands, but changing the port range at
which the RTP streams terminate as well as limiting operation to a single call
agent can be done as well as changing the number of endpoints.
=== Configuring MGCP
By default OsmoMGW listens for MGCP on port 2427 on any IP address. If a call
agent address is configured then OsmoMGW will only answer MGCP commands from
that IP port 2727, otherwise all sources are handled. A domain can be
specified
.Example: MGCP configuration
----
OsmoMGW(config-mgcp)# bind ip 127.0.0.1
OsmoMGW(config-mgcp)# bind port 2427
OsmoMGW(config-mgcp)# call-agent ip 127.0.0.1
OsmoMGW(config-mgcp)# domain mgw-bsc
OsmoMGW(config-mgcp)# local ip 127.0.0.1
----
=== Configuring the trunk
The first trunk is considered a virtual trunk in OsmoMGW. All
endpoints of type "rtpbridge" are routed here. The virtual trunk is configured
in the config-mgcp context.
All other trunks are configured in the config-mgcp-trunk context, but the
commands used are identical. Right now trunks are considered only for "ds/e1"
type endpoints.
.Example: MGCP trunk configuration
----
OsmoMGW(config-mgcp)# number endpoints 63 <1>
OsmoMGW(config-mgcp)# rtp bind-ip 10.0.0.1 <2>
OsmoMGW(config-mgcp)# rtp port-range 12000-14000 <3>
----
<1> Maximum number of endpoints that can be allocated at once
<2> Use this IP when binding RTP endpoints
<3> Use ports in this range when binding RTP endpoints
There are some options to tweak how RTP forwarding behaves in OsmoMGW:
.Example: MGCP trunk rtp options
----
OsmoMGW(config-mgcp)# rtp keep-alive 30 <1>
OsmoMGW(config-mgcp)# rtp-patch ssrc <2>
OsmoMGW(config-mgcp)# rtp-patch timestamp <3>
----
<1> Send dummy UDP packets periodically to RTP destination
<2> Hide SSRC changes
<3> Ensure RTP timestamp is aligned with frame duration
NOTE: Changes to trunks that affect resource allocation, such as newly created
trunks or a change of the number of available endpoints, require a full restart
of osmo-mgw!
=== E1 trunk considerations
While the RTP bridge trunks are natively based on IP no special considerations
are required during setup. E1 trunks are mapped on a physical E1 line, which has
to be configured as shown below.
.Example: E1 line setup
----
OsmoMGW(config-e1_input)# e1_line 0 driver dahdi <1>
OsmoMGW(config-e1_input)# e1_line 0 port 2 <2>
----
<1> Name of the libosmo-abis driver implementation ("dahdi")
<2> Port number of the physical E1 port to use (2)
In osmo-mgw the e1_input node is used to configure the physical E1 line. The
line number will be used internally to identify the configured E1 line. The
port number is the physical E1 connector (sometimes called 'span') at the E1
hardware. Per trunk an individual E1 line will be needed. Beware that the E1
driver may also need configuration settings that are not discussed here.
.Example: E1 trunk setup
----
OsmoMGW(config-mgcp)# trunk 0 <1>
OsmoMGW(config-mgcp-trunk)# line 0 <2>
----
<1> Creation of a trunk (0)
<2> Reference to the E1 line to use (0)
The E1 trunk is created along with a number, typically starting at 0, but if
required any number from 0-64 is allowed. The E1 trunk configuration concerning
the IP related aspects is nearly identical to the configuration of the virtual
trunk. However, it is important that the user assigns one of the E1 line numbers
that were configured under the e1_input node.
NOTE: The endpoint name that is used on MGCP level will include the trunk number,
not the E1 line number. For simplicity (and compatibility with OsmoBSC) it is
recommended to use equal numbers for trunk and E1 line. However, if required any
E1 line can be mapped flexible on any trunk as long as the mapping is bijective.
.Example: A typical configuration with one E1 trunk
----
e1_input
e1_line 0 driver dahdi
e1_line 0 port 2
mgcp
bind ip 127.0.0.1
rtp net-range 6000 6011
rtp net-bind-ip 192.168.100.130
rtp ip-probing
rtp ip-dscp 46
no rtp keep-alive
bind port 2428
number endpoints 30
loop 0
force-realloc 1
osmux off
rtp-patch rfc5993hr
trunk 0
rtp keep-alive once
no rtp keep-alive
line 0
----
NOTE: One E1 trunk always covers a whole E1 line. All subslots (I.640) will be mapped
to individual MGCP endpoints. As long as the endpoints remain unused the
underlying E1 timeslot is not used.
NOTE: The E1 trunk implementation also works with T1 lines, however since T1 has
24 instead of 31 usable timeslots only the endpoints that fall into that 1-24 timeslot
range will be useable.

View File

@ -0,0 +1,4 @@
[[counters]]
== Counters
include::./counters_generated.adoc[]

View File

@ -0,0 +1,83 @@
// autogenerated by show asciidoc counters
These counters and their description based on OsmoMGW 1.5.0.64-189f (OsmoMGW).
=== Rate Counters
// generating tables for rate_ctr_group
// rate_ctr_group table aggregated statistics for all rtp connections
.all_rtp_conn - aggregated statistics for all rtp connections
[options="header"]
|===
| Name | Reference | Description
| all_rtp:err_tstmp_in | <<all_rtp_conn_all_rtp:err_tstmp_in>> | Total inbound rtp-stream timestamp errors.
| all_rtp:err_tstmp_out | <<all_rtp_conn_all_rtp:err_tstmp_out>> | Total outbound rtp-stream timestamp errors.
| all_rtp:packets_rx | <<all_rtp_conn_all_rtp:packets_rx>> | Total inbound rtp packets.
| all_rtp:octets_rx | <<all_rtp_conn_all_rtp:octets_rx>> | Total inbound rtp octets.
| all_rtp:packets_tx | <<all_rtp_conn_all_rtp:packets_tx>> | Total outbound rtp packets.
| all_rtp:octets_tx | <<all_rtp_conn_all_rtp:octets_tx>> | Total outbound rtp octets.
| all_rtp:dropped | <<all_rtp_conn_all_rtp:dropped>> | Total dropped rtp packets.
| all_rtp:num_closed_conns | <<all_rtp_conn_all_rtp:num_closed_conns>> | Total number of rtp connections closed.
|===
// rate_ctr_group table dlcx statistics
.dlcx - dlcx statistics
[options="header"]
|===
| Name | Reference | Description
| dlcx:success | <<dlcx_dlcx:success>> | DLCX command processed successfully.
| dlcx:wildcard | <<dlcx_dlcx:wildcard>> | wildcard names in DLCX commands are unsupported.
| dlcx:no_conn | <<dlcx_dlcx:no_conn>> | endpoint specified in DLCX command has no active connections.
| dlcx:callid | <<dlcx_dlcx:callid>> | CallId specified in DLCX command mismatches endpoint's CallId .
| dlcx:connid | <<dlcx_dlcx:connid>> | connection ID specified in DLCX command does not exist on endpoint.
| dlcx:unhandled_param | <<dlcx_dlcx:unhandled_param>> | unhandled parameter in DLCX command.
| dlcx:rejected | <<dlcx_dlcx:rejected>> | connection deletion rejected by policy.
| dlcx:deferred | <<dlcx_dlcx:deferred>> | connection deletion deferred by policy.
|===
// rate_ctr_group table mdcx statistics
.mdcx - mdcx statistics
[options="header"]
|===
| Name | Reference | Description
| mdcx:success | <<mdcx_mdcx:success>> | MDCX command processed successfully.
| mdcx:wildcard | <<mdcx_mdcx:wildcard>> | wildcard endpoint names in MDCX commands are unsupported.
| mdcx:no_conn | <<mdcx_mdcx:no_conn>> | endpoint specified in MDCX command has no active connections.
| mdcx:callid | <<mdcx_mdcx:callid>> | invalid CallId specified in MDCX command.
| mdcx:connid | <<mdcx_mdcx:connid>> | invalid connection ID specified in MDCX command.
| crcx:unhandled_param | <<mdcx_crcx:unhandled_param>> | unhandled parameter in MDCX command.
| mdcx:no_connid | <<mdcx_mdcx:no_connid>> | no connection ID specified in MDCX command.
| mdcx:conn_not_found | <<mdcx_mdcx:conn_not_found>> | connection specified in MDCX command does not exist.
| mdcx:invalid_mode | <<mdcx_mdcx:invalid_mode>> | invalid connection mode in MDCX command.
| mdcx:conn_opt | <<mdcx_mdcx:conn_opt>> | connection options invalid.
| mdcx:no_remote_conn_desc | <<mdcx_mdcx:no_remote_conn_desc>> | no opposite end specified for connection.
| mdcx:start_rtp_failure | <<mdcx_mdcx:start_rtp_failure>> | failure to start RTP processing.
| mdcx:conn_rejected | <<mdcx_mdcx:conn_rejected>> | connection rejected by policy.
| mdcx:conn_deferred | <<mdcx_mdcx:conn_deferred>> | connection deferred by policy.
|===
// rate_ctr_group table crxc statistics
.crcx - crxc statistics
[options="header"]
|===
| Name | Reference | Description
| crcx:success | <<crcx_crcx:success>> | CRCX command processed successfully.
| crcx:bad_action | <<crcx_crcx:bad_action>> | bad action in CRCX command.
| crcx:unhandled_param | <<crcx_crcx:unhandled_param>> | unhandled parameter in CRCX command.
| crcx:missing_callid | <<crcx_crcx:missing_callid>> | missing CallId in CRCX command.
| crcx:invalid_mode | <<crcx_crcx:invalid_mode>> | invalid connection mode in CRCX command.
| crcx:limit_exceeded | <<crcx_crcx:limit_exceeded>> | limit of concurrent connections was reached.
| crcx:unkown_callid | <<crcx_crcx:unkown_callid>> | unknown CallId in CRCX command.
| crcx:alloc_conn_fail | <<crcx_crcx:alloc_conn_fail>> | connection allocation failure.
| crcx:no_remote_conn_desc | <<crcx_crcx:no_remote_conn_desc>> | no opposite end specified for connection.
| crcx:start_rtp_failure | <<crcx_crcx:start_rtp_failure>> | failure to start RTP processing.
| crcx:conn_rejected | <<crcx_crcx:conn_rejected>> | connection rejected by policy.
| crcx:no_osmux | <<crcx_crcx:no_osmux>> | no osmux offered by peer.
| crcx:conn_opt | <<crcx_crcx:conn_opt>> | connection options invalid.
| crcx:codec_nego | <<crcx_crcx:codec_nego>> | codec negotiation failure.
| crcx:bind_port | <<crcx_crcx:bind_port>> | port bind failure.
|===
== Osmo Stat Items
// generating tables for osmo_stat_items
== Osmo Counters
// generating tables for osmo_counters
// there are no ungrouped osmo_counters

View File

@ -0,0 +1,100 @@
== MGCP Endpoints
MGCP organizes the switching resources in so called endpoints. Each endpoint is
referenced by its unique identifier. While RFC 3435 specifies a naming scheme, the
actual identifier naming is subject to the implementation and configuration.
=== RTP proxy / RTP bridge endpoints
OsmoMGW implements a freely configurable number of `rtpbridge` endpoints. Those
endpoints are able to host two connections at a time to model the functionality
of a tandem switch.
RTP bridge endpoint identifiers are referenced by the string `rtpbridge/`, a
hexadecimal number without leading zeros and a domain name (configurable).
----
rtpbridge/<number>@<domain>
----
.Example: List of virtual endpoints
----
rtpbridge/1@mgw
rtpbridge/2@mgw
rtpbridge/3@mgw
rtpbridge/4@mgw
rtpbridge/5@mgw
rtpbridge/6@mgw
rtpbridge/7@mgw
rtpbridge/8@mgw
rtpbridge/9@mgw
rtpbridge/a@mgw
rtpbridge/b@mgw
rtpbridge/c@mgw
rtpbridge/d@mgw
rtpbridge/e@mgw
rtpbridge/f@mgw
rtpbridge/10@mgw
----
=== E1/T1 endpoints
OsmoMGW supports E1 subslot multiplexing as specified by I.460. All possible
subslot combinations are mapped on individual endpoints. The endpoint names
are prefixed with `ds/e1-` followed by the trunk number and the E1 timeslot.
The subslot is defined by a bit rate and a bit offset.
----
ds/e1-<trunk>/s-<timeslot>/su<bitrate>-<bitoffset>@<domain>
----
.Example: List of endpoints on E1 trunk 0 at E1 timeslot 2
----
ds/e1-0/s-2/su64-0@mgw
ds/e1-0/s-2/su32-0@mgw
ds/e1-0/s-2/su32-4@mgw
ds/e1-0/s-2/su16-0@mgw
ds/e1-0/s-2/su16-2@mgw
ds/e1-0/s-2/su16-4@mgw
ds/e1-0/s-2/su16-6@mgw
ds/e1-0/s-2/su8-0@mgw
ds/e1-0/s-2/su8-1@mgw
ds/e1-0/s-2/su8-2@mgw
ds/e1-0/s-2/su8-3@mgw
ds/e1-0/s-2/su8-4@mgw
ds/e1-0/s-2/su8-5@mgw
ds/e1-0/s-2/su8-6@mgw
ds/e1-0/s-2/su8-7@mgw
----
When creating connections on endpoints that reside in one E1 timeslot the call
agent must make sure that no overlapping endpoints are used. It is for example
not possible to use `ds/e1-0/s-2/su16-2@mgw` and `ds/e1-0/s-2/su8-3@mgw` at the
same time because they overlap.
.Subslot overlapping
[options="header"]
|===
| Bit offset 4+| Subslots
| 0 | 8k .2+| 16k .4+| 32k .8+| 64k
| 1 | 8k
| 2 | 8k .2+| 16k
| 3 | 8k
| 4 | 8k .2+| 16k .4+| 32k
| 5 | 8k
| 6 | 8k .2+| 16k
| 7 | 8k
|===
NOTE: The current implementation (December 2020) only implements TRAU frame
encoding/decoding for 16K and 8K subslots. Endpoints with other bitrates are
not yet useable.
NOTE: the VTY command "show mgcp" can be used to get a list of all available
endpoints (including identifiers)
=== The `null` endpoint
OsmoMGW offers a special `null@<domain>` endpoint which can be audited at all times.
This is useful for MGCP clients who wish to submit requests to OsmoMGW
periodically to find out whether it is still reachable and in a working state.

View File

@ -0,0 +1,72 @@
== MGCP Extensions
The MGCP protocol is extendable. The following non-standard extensions are
understood by OsmoMGW.
=== `X-Osmo-IGN`
`X-Osmo-IGN` indicates to OsmoMGW that specific items of an endpoint should be
ignored, so that it is lenient on mismatching values that would normally
indicate collisions or configuration errors.
==== `X-Osmo-IGN` Format
The value part of `X-Osmo-IGN` must be one or more items separated by one or more
spaces. Each item consists of one or more non-whitespace characters.
.Example: `X-Osmo-IGN` format with three ficticious items "X", "abc" and "123".
----
X-Osmo-IGN: X abc 123
----
`X-Osmo-IGN` must be issued in the MGCP header section (typically as its last item),
before the SDP section starts.
==== Supported `X-Osmo-IGN` Items
Currently, the following `X-Osmo-IGN` items are supported:
* `C`: ignore CallID mismatches, i.e. differing "C" values between connections
on the same endpoint.
.Note:
`X-Osmo-IGN` does not support ignoring mismatches on the domain part of
an endpoint name, e.g. ignoring a mismatch on "example.com" in
`rtpbridge/123abc@example.com`. Instead, you may globally configure OsmoMGW
with `mgcp` / `domain *` to permit all domain parts.
===== `X-Osmo-IGN: C`
By default, OsmoMGW verifies that all CallIDs ("C" values) match for all
connections on any one given endpoint. To ignore CallID mismatches, pass a `C`
in the `X-Osmo-IGN` header, for the first or the second `CRCX` on an endpoint.
When the `X-Osmo-IGN: C` is sent for any one `CRCX` on an endpoint, CallID
mismatches will be ignored for that and all subsequent messages for that
endpoint. Hence this header only needs to be included once per endpoint, in any
`CRCX` message that precedes or coincides with a CallID mismatch.
This is particularly useful for a BSC that is connected to an A/SCCPlite MSC,
where the BSC and MSC each are expected to configure their respective own
connection on a shared endpoint. For A/SCCPlite, it is impossible for the BSC
to know the CallID that the MSC will use, so CallID mismatches are inevitable.
See also OsmoBSC, which will by default pass the `X-Osmo-IGN: C` header for
endpoints associated with an A/SCCPlite MSC.
.Example: `CRCX` message that instructs OsmoMGW to ignore CallID mismatches
----
CRCX 2 rtpbridge/123abc@mgw MGCP 1.0
M: recvonly
C: 2
L: p:20
X-Osmo-IGN: C
v=0
c=IN IP4 123.12.12.123
m=audio 5904 RTP/AVP 97
a=rtpmap:97 GSM-EFR/8000
a=ptime:40
----
=== `X-Osmux`
See <<mgcp-extension-osmux>>

View File

@ -0,0 +1,115 @@
[[overview]]
== Overview
This manual should help you getting started with OsmoMGW. It will cover
aspects of configuring and running the media gateway.
[[intro_overview]]
=== About OsmoMGW
OsmoMGW is the Osmocom implementation of a media gateway to handle user
plane (voice) traffic in cellular networks. It can connect and optionally
transcode RTP voice streams between different network elements such as BTSs
and external entities like SIP. It is typically co-located with both OsmoBSC
and OsmoMSC and controlled by them via MGCP, the Media Gateway Control
Protocol.
[[fig-bsc]]
.OsmoMGW used with OsmoBSC
[graphviz]
----
digraph G {
rankdir = LR;
OsmoBTS -> OsmoBSC [label="Abis/IP"];
OsmoBSC -> "core-network" [label="3GPP AoIP"];
OsmoBSC -> OsmoMGW [label="MGCP"];
OsmoBTS -> OsmoMGW [label="RTP",dir=both];
OsmoMGW -> "core-network" [label="RTP",dir=both];
{rank=same OsmoBSC OsmoMGW}
OsmoMGW [color=red];
}
----
[[fig-msc]]
.OsmoMGW used with OsmoMSC
[graphviz]
----
digraph G {
rankdir = LR;
"2G BSS" -> OsmoMSC [label="3GPP AoIP"];
OsmoMSC -> OsmoMGW [label="MGCP"];
"2G BSS" -> OsmoMGW [label="RTP",dir=both];
OsmoMSC -> OsmoSIP [label="MNCC"];
OsmoSIP -> PBX [label="SIP Trunk"];
OsmoMGW -> PBX [label="RTP",dir=both];
{rank=same OsmoMSC OsmoMGW}
OsmoSIP [label="osmo-sip-connector"];
OsmoMGW [color=red];
hNodeB -> OsmoHNBGW [label="Iuh"];
OsmoHNBGW -> OsmoMSC [label="IuCS"];
hNodeB -> OsmoMGW [label="RTP",dir=both];
}
----
[[fig-bsc-e1]]
.Integration of legacy E1 BTS in AoIP network
[graphviz]
----
digraph G {
rankdir = LR;
BTS -> OsmoBSC [label="Abis/E1"];
OsmoBSC -> "core-network" [label="3GPP AoIP"];
OsmoBSC -> OsmoMGW [label="MGCP"];
BTS -> OsmoMGW [label="TRAU/E1",dir=both];
OsmoMGW -> "core-network" [label="RTP",dir=both];
{rank=same OsmoBSC OsmoMGW}
OsmoMGW [color=red];
}
----
=== Software Components
OsmoMGW contains a variety of different software components, which well
quickly describe in this section.
==== MGCP Implementation
OsmoMGW brings its own MGCP implementation through which OsmoMGW is
controlled.
The commands implemented are CRCX, MDCX, DLCX and RSIP. The command AUEP is
implemented as a stub and will simply respond with OK.
==== RTP implementation
Support for IuUP which is used in 3G cells is quite lacking at the moment.
3G<->3G and 2G<->2G calls should work, but 3G<->2G does not.
==== Audio transcoder
Transcoding is currently not supported in OsmoMGW.
=== Limitations
At the moment (November 2020), OsmoMGW implements RTP proxy / RTP bridge
type endpoints and E1/T1 16k/8k sub-slots with TRAU frames for classic BTS
support. To the RTP proxy / RTP bridge endpoints two RTP connections can
be established, which then work as a tandem. E1/T1 endpoints support one
RTP connection at a time that is associated with a sub-slot on an E1 line.
We are planning to add further endpoint types for:
- classic E1/T1 timeslots (64kBps alaw/ulaw)
- announcement/playout end-points
- conference endpoints
=== Additional resources
You can find the OsmoMGW issue tracker and wiki online at
- https://osmocom.org/projects/osmo-mgw
- https://osmocom.org/projects/osmo-mgw/wiki
RFC 3435 for MGCP is located at
- https://tools.ietf.org/html/rfc3435

View File

@ -0,0 +1,42 @@
==== Full example of QoS for osmo-mgw
In the below example we will show the full set of configuration required
for both DSCP and PCP differentiation of RTP traffic by osmo-mgw.
What we want to achieve in this example is the following configuration:
.DSCP and PCP assignments for osmo-mgw Abis downlink traffic in this example
[options="header",width="30%",cols="2,1,1"]
|===
|Traffic |DSCP|PCP
|RTP | 46| 6
|===
. configure the osmo-mgw program to set the DSCP value
. configure an egrees QoS map to map from priority to PCP
.Example Step 1: add related VTY configuration to `osmo-mgw.cfg`
----
...
mgcp
rtp ip-dscp 46
rtp socket-priority 6
...
----
.Example Step 2: egress QoS map to map from socket priority to PCP values
----
$ sudo ip link set dev eth0.9<1> type vlan egress-qos-map 0:0 5:5 6:6 7:7 <2>
----
<1> make sure to specify your specific VLAN interface name here instead of `eth0.9`.
<2> create a egress QoS map that maps the priority value 1:1 to the PCP. We also include the
mapping 5:5 and 7:7 from the osmo-bsc example (see <<userman-osmobsc>>) here.
NOTE:: The settings of the `ip` command are volatile and only active until
the next reboot (or the network device or VLAN is removed). Please refer to
the documentation of your specific Linux distribution in order to find out how
to make such settings persistent by means of an `ifup` hook whenever the interface
comes up. For CentOS/RHEL 8 this can e.g. be achieved by means of an `/sbin/ifup-local
script` (when using `network-scripts` and not NetworkManager). For Debian or Ubuntu,
this typically involves adding `up` lines to `/etc/network/interfaces` or a `/etc/network/if-up.d`
script.

View File

@ -0,0 +1,42 @@
== Running OsmoMGW
The OsmoMGW executable (`osmo-mgw`) offers the following command-line
arguments:
=== SYNOPSIS
*osmo-mgw* [-h|-V] [-D] [-c 'CONFIGFILE'] [-s]
=== OPTIONS
*-h, --help*::
Print a short help message about the supported options
*-V, --version*::
Print the compile-time version number of the program
*-D, --daemonize*::
Fork the process as a daemon into background.
*-c, --config-file 'CONFIGFILE'*::
Specify the file and path name of the configuration file to be
used. If none is specified, use `osmo-mgw.cfg` in the current
working directory.
*-s, --disable-color*::
Disable colors for logging to stderr. This has mostly been
deprecated by VTY based logging configuration, see <<logging>>
for more information.
=== Configure limits
When servicing hundreds of media endpoints, it may be necessary to adjust the
operating system's limit on open file descriptors for the osmo-mgw process. A
typical default limit imposed by operating systems is 1024; this would be
exceeded by, for example, about 256 active voice calls with 4 RTP/RTPC ports
each, sockets for other interfaces not considered yet.
It should be ok to set an OS limit on open file descriptors as high as 65536
for osmo-mgw, which practically rules out failure from running out of file
descriptors anywhere (<16,000 active calls).
When using systemd, the file descriptor limit may be adjusted in the service
file by the `LimitNOFILE` setting ("Number of Open FILE descriptors"). OsmoMGW
ships a systemd service file with a high LimitNOFILE setting.

View File

@ -0,0 +1,47 @@
<revhistory>
<revision>
<revnumber>1</revnumber>
<date>July 24th, 2018</date>
<authorinitials>DW</authorinitials>
<revremark>
Initial version
</revremark>
</revision>
</revhistory>
<authorgroup>
<author>
<firstname>Daniel</firstname>
<surname>Willmann</surname>
<email>dwillmann@sysmocom.de</email>
<authorinitials>DW</authorinitials>
<affiliation>
<shortaffil>sysmocom</shortaffil>
<orgname>sysmocom - s.f.m.c. GmbH</orgname>
</affiliation>
</author>
</authorgroup>
<copyright>
<year>2018</year>
<holder>sysmocom - s.f.m.c. GmbH</holder>
</copyright>
<legalnotice>
<para>
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License,
Version 1.3 or any later version published by the Free Software
Foundation; with the Invariant Sections being just 'Foreword',
'Acknowledgements' and 'Preface', with no Front-Cover Texts,
and no Back-Cover Texts. A copy of the license is included in
the section entitled "GNU Free Documentation License".
</para>
<para>
The Asciidoc source code of this manual can be found at
<ulink url="http://git.osmocom.org/osmo-gsm-manuals/">
http://git.osmocom.org/osmo-gsm-manuals/
</ulink>
</para>
</legalnotice>

View File

@ -0,0 +1,39 @@
:gfdl-enabled:
:program-name: OsmoMGW
OsmoMGW User Manual
====================
Daniel Willmann <dwillmann@sysmocom.de>
include::./common/chapters/preface.adoc[]
include::{srcdir}/chapters/overview.adoc[]
include::{srcdir}/chapters/running.adoc[]
include::./common/chapters/vty.adoc[]
include::./common/chapters/logging.adoc[]
include::{srcdir}/chapters/configuration.adoc[]
include::{srcdir}/chapters/mgcp_endpoints.adoc[]
include::{srcdir}/chapters/mgcp_extensions.adoc[]
include::./common/chapters/osmux/osmux.adoc[]
include::./common/chapters/qos-dscp-pcp.adoc[]
//include::{srcdir}/chapters/counters.adoc[]
include::./common/chapters/vty_cpu_sched.adoc[]
include::./common/chapters/port_numbers.adoc[]
include::./common/chapters/bibliography.adoc[]
include::./common/chapters/glossary.adoc[]
include::./common/chapters/gfdl.adoc[]

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
ex:ts=2:sw=42sts=2:et
-*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
-->
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML 5.0//EN"
"http://docbook.org/xml/5.0/dtd/docbook.dtd" [
<!ENTITY chapter-vty SYSTEM "./common/chapters/vty.xml" >
<!ENTITY sections-vty SYSTEM "generated/docbook_vty.xml" >
]>
<book>
<info>
<revhistory>
<revision>
<revnumber>v1</revnumber>
<date>12th December 2017</date>
<authorinitials>pm</authorinitials>
<revremark>Initial</revremark>
</revision>
</revhistory>
<title>OsmoMGW VTY Reference</title>
<copyright>
<year>2017</year>
</copyright>
<legalnotice>
<para>This work is copyright by <orgname>sysmocom - s.f.m.c. GmbH</orgname>. All rights reserved.
</para>
</legalnotice>
</info>
<!-- Main chapters-->
&chapter-vty;
</book>

17
doc/manuals/regen_doc.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/sh -x
if [ -z "$DOCKER_PLAYGROUND" ]; then
echo "You need to set DOCKER_PLAYGROUND"
exit 1
fi
SCRIPT=$(realpath "$0")
MANUAL_DIR=$(dirname "$SCRIPT")
COMMIT=${COMMIT:-$(git log -1 --format=format:%H)}
cd "$DOCKER_PLAYGROUND/scripts" || exit 1
OSMO_MGW_BRANCH=$COMMIT ./regen_doc.sh osmo-mgw 4243 \
"$MANUAL_DIR/chapters/counters_generated.adoc" \
"$MANUAL_DIR/vty/mgw_vty_reference.xml"

View File

@ -0,0 +1,2 @@
<vtydoc xmlns='urn:osmocom:xml:libosmocore:vty:doc:1.0'>
</vtydoc>

View File

@ -92,8 +92,8 @@ fi
if test -n "$v"
then
: # use $v
elif test -d ./../.git \
&& v=`git describe --abbrev=4 --match='v*' HEAD 2>/dev/null \
elif
v=`git describe --abbrev=4 --match='v*' HEAD 2>/dev/null \
|| git describe --abbrev=4 HEAD 2>/dev/null` \
&& case $v in
[0-9]*) ;;

23
include/Makefile.am Normal file
View File

@ -0,0 +1,23 @@
SUBDIRS = \
osmocom \
$(NULL)
nobase_include_HEADERS = \
osmocom/mgcp_client/defs.h \
osmocom/mgcp_client/mgcp_client.h \
osmocom/mgcp_client/mgcp_client_endpoint_fsm.h \
osmocom/mgcp_client/mgcp_client_fsm.h \
osmocom/mgcp_client/mgcp_client_pool.h \
$(NULL)
noinst_HEADERS = \
osmocom/mgcp/mgcp.h \
osmocom/mgcp/mgcp_common.h \
osmocom/mgcp/osmux.h \
$(NULL)
# This gets copied during make from osmocom/mgcp/mgcp_common.h. Therefore it is not included in the source tree and we
# don't need to distribute it (OS#4084).
nobase_nodist_include_HEADERS = \
osmocom/mgcp_client/mgcp_common.h \
$(NULL)

View File

@ -0,0 +1,4 @@
SUBDIRS = \
mgcp_client \
mgcp \
$(NULL)

View File

@ -0,0 +1,16 @@
noinst_HEADERS = \
vty.h \
mgcp_msg.h \
mgcp_conn.h \
mgcp_stat.h \
mgcp_endp.h \
mgcp_sdp.h \
mgcp_codec.h \
mgcp_trunk.h \
debug.h \
mgcp_ratectr.h \
mgcp_e1.h \
mgcp_network.h \
mgcp_protocol.h \
mgcp_iuup.h \
$(NULL)

View File

@ -1,6 +1,8 @@
/* (C) 2008 by Harald Welte <laforge@gnumonks.org>
/* (C) 2017 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* Author: Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
@ -16,12 +18,20 @@
*
*/
#ifndef MISDN_H
#define MISDN_H
#pragma once
#include <osmocom/abis/e1_input.h>
#include <stdio.h>
#include <osmocom/core/linuxlist.h>
int mi_setup(int cardnr, struct e1inp_line *line, int release_l2);
int mi_e1_line_update(struct e1inp_line *line);
#define DEBUG
#include <osmocom/core/logging.h>
#endif
/* Debug Areas of the code */
enum {
DRTP,
DE1,
DOSMUX,
Debug_LastEntry,
};
extern const struct log_info log_info;

209
include/osmocom/mgcp/mgcp.h Normal file
View File

@ -0,0 +1,209 @@
/* A Media Gateway Control Protocol Media Gateway: RFC 3435 */
/*
* (C) 2009-2012 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2009-2012 by On-Waves
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <osmocom/core/msgb.h>
#include <osmocom/core/socket.h>
#include <osmocom/core/osmo_io.h>
#include <osmocom/core/write_queue.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/logging.h>
#include <osmocom/mgcp/mgcp_common.h>
#include <osmocom/mgcp/osmux.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <pthread.h>
#include "mgcp_ratectr.h"
#define RTP_PORT_DEFAULT_RANGE_START 16002
#define RTP_PORT_DEFAULT_RANGE_END RTP_PORT_DEFAULT_RANGE_START + 64
/*
* Handling of MGCP Endpoints and the MGCP Config
*/
struct mgcp_endpoint;
struct mgcp_config;
struct mgcp_trunk;
struct mgcp_rtp_end;
#define MGCP_ENDP_CRCX 1
#define MGCP_ENDP_DLCX 2
#define MGCP_ENDP_MDCX 3
/*
* what to do with the msg?
* - continue as usual?
* - reject and send a failure code?
* - defer? do not send anything
*/
#define MGCP_POLICY_CONT 4
#define MGCP_POLICY_REJECT 5
#define MGCP_POLICY_DEFER 6
typedef int (*mgcp_reset)(struct mgcp_trunk *cfg);
typedef int (*mgcp_rqnt)(struct mgcp_endpoint *endp, char tone);
/**
* Return:
* < 0 in case no audio was processed
* >= 0 in case audio was processed.
*/
typedef int (*mgcp_processing)(struct mgcp_endpoint *endp,
struct mgcp_rtp_end *dst_end, struct msgb *msg);
struct mgcp_conn_rtp;
typedef int (*mgcp_processing_setup)(struct mgcp_endpoint *endp,
struct mgcp_conn_rtp *conn_dst,
struct mgcp_conn_rtp *conn_src);
struct mgcp_rtp_codec;
typedef void (*mgcp_get_format)(struct mgcp_endpoint *endp,
const struct mgcp_rtp_codec **codec,
const char **fmtp_extra,
struct mgcp_conn_rtp *conn);
/**
* This holds information on how to allocate ports
*/
struct mgcp_port_range {
pthread_mutex_t lock;
/* addr or NULL to fall-back to default */
char bind_addr_v4[INET6_ADDRSTRLEN];
char bind_addr_v6[INET6_ADDRSTRLEN];
/* dynamically allocated */
int range_start;
int range_end;
int last_port;
/* set to true to enable automatic probing
* of the local bind IP-Address, bind_addr
* (or its fall back) is used when automatic
* probing fails */
bool bind_addr_probe;
};
/* There are up to three modes in which the keep-alive dummy packet can be
* sent. The behaviour is controlled via the keepalive_interval member of the
* trunk config. If that member is set to 0 (MGCP_KEEPALIVE_NEVER) no dummy-
* packet is sent at all and the timer that sends regular dummy packets
* is no longer scheduled. If the keepalive_interval is set to -1, only
* one dummy packet is sent when an CRCX or an MDCX is performed. No timer
* is scheduled. For all vales greater 0, the timer is scheduled and the
* value is used as interval. See also mgcp_keepalive_timer_cb(),
* handle_modify_con(), and handle_create_con() */
#define MGCP_KEEPALIVE_ONCE (-1)
#define MGCP_KEEPALIVE_NEVER 0
enum mgcp_role {
MGCP_BSC = 0,
MGCP_BSC_NAT,
};
struct mgcp_config {
int source_port;
char local_ip[INET6_ADDRSTRLEN];
char source_addr[INET6_ADDRSTRLEN];
char call_agent_addr[INET6_ADDRSTRLEN];
/* RTP processing */
mgcp_processing rtp_processing_cb;
mgcp_processing_setup setup_rtp_processing_cb;
struct osmo_wqueue gw_fd;
struct mgcp_port_range net_ports;
int endp_dscp;
int endp_priority;
int force_ptime;
mgcp_reset reset_cb;
mgcp_rqnt rqnt_cb;
void *data;
/* list holding the trunks */
struct llist_head trunks;
enum mgcp_role role;
struct {
/* Osmux usage policy: */
enum osmux_usage usage;
/* addr to bind the server to */
char *local_addr_v4;
char *local_addr_v6;
/* osmux port */
uint16_t local_port;
/* The osmux socket is allocated on demand (1st time used).
* This tells us if the osmux socket is already initialized. */
bool initialized;
/* osmux batch factor: from 1 to 4 maximum */
int batch_factor;
/* osmux batch size (in bytes) */
int batch_size;
/* Pad circuit with dummy AMR frames if no payload to transmit is available */
bool dummy_padding;
/* Whether peer is behind NAT (Retrieve remote addr from 1st received Osmux packet) */
bool peer_behind_nat;
} osmux;
/* domain name of the media gateway */
char domain[255+1];
/* time after which inactive connections (CIs) get closed */
int conn_timeout;
/* osmocom CTRL interface */
struct ctrl_handle *ctrl;
/* global rate counters to measure the MGWs overall performance and
* health */
struct mgcp_ratectr_global ratectr;
};
/* config management */
struct mgcp_config *mgcp_config_alloc(void);
int mgcp_parse_config(const char *config_file, struct mgcp_config *cfg,
enum mgcp_role role);
int mgcp_vty_init(void);
void mgcp_trunk_set_keepalive(struct mgcp_trunk *trunk, int interval);
/*
* format helper functions
*/
struct msgb *mgcp_handle_message(struct mgcp_config *cfg, struct msgb *msg);
int mgcp_send_reset_ep(struct mgcp_endpoint *endp);
int mgcp_send_reset_all(struct mgcp_config *cfg);
int mgcp_create_bind(const char *source_addr, int port, uint8_t dscp, uint8_t prio);
int mgcp_udp_send(struct osmo_io_fd *iofd, const struct osmo_sockaddr *addr, const char *buf, int len);

View File

@ -0,0 +1,21 @@
#pragma once
#define DEFAULT_RTP_AUDIO_FRAME_DUR_NUM 20
#define DEFAULT_RTP_AUDIO_FRAME_DUR_DEN 1000
#define DEFAULT_RTP_AUDIO_PACKET_DURATION_MS 20
#define DEFAULT_RTP_AUDIO_DEFAULT_RATE 8000
#define DEFAULT_RTP_AUDIO_DEFAULT_CHANNELS 1
#define PTYPE_UNDEFINED (-1)
struct mgcp_conn_rtp;
void mgcp_codec_summary(struct mgcp_conn_rtp *conn);
void mgcp_codec_reset_all(struct mgcp_conn_rtp *conn);
int mgcp_codec_add(struct mgcp_conn_rtp *conn, int payload_type, const char *audio_name, const struct mgcp_codec_param *param);
int mgcp_codec_decide(struct mgcp_conn_rtp *conn_src, struct mgcp_conn_rtp *conn_dst);
const struct mgcp_rtp_codec *mgcp_codec_pt_find_by_subtype_name(struct mgcp_conn_rtp *conn,
const char *subtype_name, unsigned int match_nr);
bool mgcp_codec_amr_align_mode_is_indicated(const struct mgcp_rtp_codec *codec);
bool mgcp_codec_amr_is_octet_aligned(const struct mgcp_rtp_codec *codec);
struct mgcp_rtp_codec *mgcp_codec_from_pt(struct mgcp_conn_rtp *conn, int payload_type);

View File

@ -0,0 +1,112 @@
/* MGCP common implementations.
* These are used in libosmo-mgcp as well as libosmo-mgcp-client.
* To avoid interdependency, these are implemented in .h file only. */
/*
* (C) 2017 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
* (C) 2009-2012 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2009-2012 by On-Waves
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* Two copies of this file are kept in osmocom/mgcp/ and osmocom/mgcp_client/.
* Since both are by definition identical, use the old header exclusion ifdefs
* instead of '#pragma once' to avoid including both of these files.
* Though at the time of writing there are no such users, this allows including
* both libosmo-mgcp and libosmo-mgcp-client headers in the same file. */
#ifndef OSMO_MGCP_COMMON_H
#define OSMO_MGCP_COMMON_H
#include <string.h>
#include <errno.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/logging.h>
#define for_each_non_empty_line(line, save) \
for (line = strtok_r(NULL, "\r\n", &save); line; \
line = strtok_r(NULL, "\r\n", &save))
enum mgcp_connection_mode {
MGCP_CONN_NONE = 0,
MGCP_CONN_RECV_ONLY = 1,
MGCP_CONN_SEND_ONLY = 2,
MGCP_CONN_RECV_SEND = MGCP_CONN_RECV_ONLY | MGCP_CONN_SEND_ONLY,
MGCP_CONN_LOOPBACK = 4 | MGCP_CONN_RECV_SEND,
MGCP_CONN_CONFECHO = 8 | MGCP_CONN_RECV_SEND,
};
#define MGCP_X_OSMO_IGN_HEADER "X-Osmo-IGN:"
#define MGCP_X_OSMO_OSMUX_HEADER "X-Osmux:"
/* Values should be bitwise-OR-able */
enum mgcp_x_osmo_ign {
MGCP_X_OSMO_IGN_NONE = 0,
MGCP_X_OSMO_IGN_CALLID = 1,
};
/* Codec parameters (communicated via SDP/fmtp) */
struct mgcp_codec_param {
bool amr_octet_aligned_present;
bool amr_octet_aligned;
};
/* Ensure that the msg->l2h is NUL terminated. */
static inline int mgcp_msg_terminate_nul(struct msgb *msg)
{
unsigned char *tail = msg->tail; /* char after l2 data */
if (tail[-1] == '\0')
/* nothing to do */;
else if (msgb_tailroom(msg) > 0)
msgb_put_u8(msg, (uint8_t)'\0');
else if (tail[-1] == '\r' || tail[-1] == '\n')
tail[-1] = '\0';
else {
LOGP(DLMGCP, LOGL_ERROR, "Cannot NUL terminate MGCP message: "
"Length: %d, Buffer size: %d\n",
msgb_l2len(msg), msg->data_len);
return -ENOTSUP;
}
return 0;
}
/* Maximum length of the comment field */
#define MGCP_COMMENT_MAXLEN 256
/* Maximum allowed String length of Connection Identifiers as per spec
* (see also RFC3435 2.1.3.2 Names of Connections), plus one for '\0'. */
#define MGCP_CONN_ID_MAXLEN 32+1
/* Deprecated: old name of MGCP_CONN_ID_MAXLEN. */
#define MGCP_CONN_ID_LENGTH MGCP_CONN_ID_MAXLEN
/* String length of Endpoint Identifiers.
/ (see also RFC3435 section 3.2.1.3) */
#define MGCP_ENDPOINT_MAXLEN (255*2+1+1)
/* A prefix to denote the virtual trunk (RTP on both ends) */
#define MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK "rtpbridge/"
/* A prefix to denote the e1 trunk
* (see also RFC3435 section E.2) */
#define MGCP_ENDPOINT_PREFIX_E1_TRUNK "ds/e1-"
/* Maximal number of payload types / codecs that can be negotiated via SDP at
* at once. */
#define MGCP_MAX_CODECS 10
#endif

View File

@ -0,0 +1,251 @@
/* Message connection list handling */
/*
* (C) 2017 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* Author: Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <osmocom/mgcp/mgcp.h>
#include <osmocom/mgcp/mgcp_network.h>
#include <osmocom/mgcp/osmux.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/gsm/iuup.h>
#include <inttypes.h>
#define LOGPCONN(conn, cat, level, fmt, args...) \
LOGPENDP((conn)->endp, cat, level, "CI:%s " fmt, \
(conn)->id, \
## args)
#define LOG_CONN(conn, level, fmt, args...) \
LOGP(DRTP, level, "(%s I:%s) " fmt, \
(conn)->endp ? (conn)->endp->name : "none", (conn)->id, ## args)
#define LOG_CONN_RTP(conn_rtp, level, fmt, args...) \
LOG_CONN((conn_rtp)->conn, level, fmt, ## args)
/* Specific rtp connection type (see struct mgcp_conn_rtp) */
enum mgcp_conn_rtp_type {
MGCP_RTP_DEFAULT = 0,
MGCP_RTP_OSMUX,
MGCP_RTP_IUUP,
};
extern const struct value_string mgcp_conn_rtp_type_names[];
static inline const char *mgcp_conn_rtp_type_name(enum mgcp_conn_rtp_type val)
{
return get_value_string(mgcp_conn_rtp_type_names, val);
}
/*! Connection type, specifies which member of the union "u" in mgcp_conn
* contains a useful connection description (currently only RTP) */
enum mgcp_conn_type {
MGCP_CONN_TYPE_RTP,
};
/* MGCP connection (RTP) */
struct mgcp_conn_rtp {
/* Backpointer to conn struct */
struct mgcp_conn *conn;
/* Specific connection type */
enum mgcp_conn_rtp_type type;
/* Port status */
struct mgcp_rtp_end end;
/* Sequence bits */
struct mgcp_rtp_state state;
/* taps for the rtp connection; one per direction */
struct mgcp_rtp_tap tap_in;
struct mgcp_rtp_tap tap_out;
/* Osmux states (optional) */
struct {
/* Osmux state: disabled, activating, active */
enum osmux_state state;
/* Is local_cid holding valid data? is it allocated from pool? */
bool local_cid_allocated;
/* Allocated local Osmux circuit ID for this conn */
uint8_t local_cid;
/* Is remote_cid holding valid data? was it already received from client? */
bool remote_cid_present;
/* Received remote Osmux circuit ID for this conn */
uint8_t remote_cid;
/* handle to batch messages, shared (refcounted) among several conns */
struct osmux_in_handle *in;
/* handle to unbatch messages, one allocated and owned per conn */
struct osmux_out_handle *out;
/* statistics: */
struct rate_ctr_group *ctrg;
} osmux;
struct {
struct osmo_iuup_instance *iui;
bool active_init; /* true: Send IuUP Init */
int rfci_id_no_data; /* RFCI Id for RFCI NO_DATA (-1 if not available) */
bool configured;
struct osmo_iuup_rnl_prim *init_ind;
} iuup;
struct rate_ctr_group *ctrg;
};
/*! MGCP connection (untyped) */
struct mgcp_conn {
/*! list head */
struct llist_head entry;
/*! Backpointer to the endpoint where the conn belongs to */
struct mgcp_endpoint *endp;
/*! type of the connection (union) */
enum mgcp_conn_type type;
/*! mode of the connection */
enum mgcp_connection_mode mode;
/*! copy of the mode to restore the original setting (VTY) */
enum mgcp_connection_mode mode_orig;
/*! connection id to identify the connection */
char id[MGCP_CONN_ID_MAXLEN];
/*! human readable name (vty, logging) */
char name[256];
/*! activity tracker (for cleaning up inactive connections) */
struct osmo_timer_list watchdog;
/*! union with connection description */
union {
struct mgcp_conn_rtp rtp;
} u;
/*! pointer to optional private data */
void *priv;
};
/* RTP connection related counters */
enum {
IN_STREAM_ERR_TSTMP_CTR,
OUT_STREAM_ERR_TSTMP_CTR,
RTP_PACKETS_RX_CTR,
RTP_OCTETS_RX_CTR,
RTP_PACKETS_TX_CTR,
RTP_OCTETS_TX_CTR,
RTP_DROPPED_PACKETS_CTR,
RTP_NUM_CONNECTIONS,
};
/* RTP per-connection statistics. Instances of the corresponding rate counter group
* exist for the lifetime of an RTP connection.
* Must be kept in sync with all_rtp_conn_rate_ctr_desc below */
static const struct rate_ctr_desc mgcp_conn_rate_ctr_desc[] = {
[IN_STREAM_ERR_TSTMP_CTR] = {"stream_err_tstmp:in", "Inbound rtp-stream timestamp errors."},
[OUT_STREAM_ERR_TSTMP_CTR] = {"stream_err_tstmp:out", "Outbound rtp-stream timestamp errors."},
[RTP_PACKETS_RX_CTR] = {"rtp:packets_rx", "Inbound rtp packets."},
[RTP_OCTETS_RX_CTR] = {"rtp:octets_rx", "Inbound rtp octets."},
[RTP_PACKETS_TX_CTR] = {"rtp:packets_tx", "Outbound rtp packets."},
[RTP_OCTETS_TX_CTR] = {"rtp:octets_tx", "Outbound rtp octets."},
[RTP_DROPPED_PACKETS_CTR] = {"rtp:dropped", "Dropped rtp packets."}
};
/* Aggregated RTP connection stats. These are updated when an RTP connection is freed.
* Must be kept in sync with mgcp_conn_rate_ctr_desc above */
static const struct rate_ctr_desc all_rtp_conn_rate_ctr_desc[] = {
[IN_STREAM_ERR_TSTMP_CTR] = {"all_rtp:err_tstmp_in", "Total inbound rtp-stream timestamp errors."},
[OUT_STREAM_ERR_TSTMP_CTR] = {"all_rtp:err_tstmp_out", "Total outbound rtp-stream timestamp errors."},
[RTP_PACKETS_RX_CTR] = {"all_rtp:packets_rx", "Total inbound rtp packets."},
[RTP_OCTETS_RX_CTR] = {"all_rtp:octets_rx", "Total inbound rtp octets."},
[RTP_PACKETS_TX_CTR] = {"all_rtp:packets_tx", "Total outbound rtp packets."},
[RTP_OCTETS_TX_CTR] = {"all_rtp:octets_tx", "Total outbound rtp octets."},
[RTP_DROPPED_PACKETS_CTR] = {"all_rtp:dropped", "Total dropped rtp packets."},
/* This last counter does not exist in per-connection stats, only here. */
[RTP_NUM_CONNECTIONS] = {"all_rtp:num_closed_conns", "Total number of rtp connections closed."}
};
/* Osmux connection related counters */
enum {
OSMUX_CHUNKS_RX_CTR,
OSMUX_OCTETS_RX_CTR,
OSMUX_RTP_PACKETS_TX_CTR,
OSMUX_RTP_PACKETS_TX_DROPPED_CTR,
OSMUX_AMR_OCTETS_TX_CTR,
/* Only available in global stats: */
OSMUX_NUM_CONNECTIONS,
OSMUX_PACKETS_RX_CTR,
OSMUX_PACKETS_TX_CTR,
OSMUX_DROPPED_PACKETS_CTR,
};
/* RTP per-connection statistics. Instances of the corresponding rate counter group
* exist for the lifetime of an RTP connection.
* Must be kept in sync with all_rtp_conn_rate_ctr_desc below */
static const struct rate_ctr_desc mgcp_conn_osmux_rate_ctr_desc[] = {
[OSMUX_CHUNKS_RX_CTR] = {"osmux:chunks_rx", "Inbound Osmux chunks."},
[OSMUX_OCTETS_RX_CTR] = {"osmux:octets_rx", "Inbound Osmux octets."},
[OSMUX_RTP_PACKETS_TX_CTR] = {"osmux:rtp_packets_tx", "Tx outbound RTP packets to encode as Osmux."},
[OSMUX_RTP_PACKETS_TX_DROPPED_CTR] = {"osmux:rtp_packets_tx_dropped", "Dropped Tx outbound RTP packets to encode as Osmux."},
[OSMUX_AMR_OCTETS_TX_CTR] = {"osmux:amr_octets_tx", "Tx outbound AMD payload octets."},
};
/* Aggregated Osmux connection stats. These are updated when an Osmux connection is freed.
* Must be kept in sync with mgcp_conn_osmux_rate_ctr_desc above */
static const struct rate_ctr_desc all_osmux_conn_rate_ctr_desc[] = {
[OSMUX_CHUNKS_RX_CTR] = {"all_osmux:chunks_rx", "Inbound Osmux chunks."},
[OSMUX_OCTETS_RX_CTR] = {"all_osmux:octets_rx", "Inbound Osmux octets."},
[OSMUX_RTP_PACKETS_TX_CTR] = {"all_osmux:rtp_packets_tx", "Tx outbound RTP packets to encode as Osmux."},
[OSMUX_RTP_PACKETS_TX_DROPPED_CTR] = {"all_osmux:rtp_packets_tx_dropped", "Dropped Tx outbound RTP packets to encode as Osmux."},
[OSMUX_AMR_OCTETS_TX_CTR] = {"all_osmux:amr_octets_tx", "Tx outbound AMD payload octets."},
/* These last counters below do not exist in per-connection stats, only here: */
[OSMUX_NUM_CONNECTIONS] = {"all_osmux:num_closed_conns", "Total number of osmux connections closed."},
[OSMUX_PACKETS_RX_CTR] = {"all_osmux:packets_rx", "Total inbound UDP/Osmux packets."},
[OSMUX_PACKETS_TX_CTR] = {"all_osmux:packets_tx", "Total outbound UDP/Osmux packets."},
[OSMUX_DROPPED_PACKETS_CTR] = {"all_osmux:dropped_packets", "Dropped outbound UDP/Osmux packets."}
};
/* Was conn configured to handle Osmux? */
static inline bool mgcp_conn_rtp_is_osmux(const struct mgcp_conn_rtp *conn) {
return conn->type == MGCP_RTP_OSMUX;
}
/* Was conn configured to handle Osmux? */
static inline bool mgcp_conn_rtp_is_iuup(const struct mgcp_conn_rtp *conn)
{
return conn->type == MGCP_RTP_IUUP;
}
struct mgcp_conn *mgcp_conn_alloc(void *ctx, struct mgcp_endpoint *endp,
enum mgcp_conn_type type, char *name);
struct mgcp_conn *mgcp_conn_get(struct mgcp_endpoint *endp, const char *id);
struct mgcp_conn_rtp *mgcp_conn_get_rtp(struct mgcp_endpoint *endp,
const char *id);
void mgcp_conn_free(struct mgcp_endpoint *endp, const char *id);
void mgcp_conn_free_oldest(struct mgcp_endpoint *endp);
void mgcp_conn_free_all(struct mgcp_endpoint *endp);
char *mgcp_conn_dump(struct mgcp_conn *conn);
struct mgcp_conn *mgcp_find_dst_conn(struct mgcp_conn *conn);
struct mgcp_conn *mgcp_conn_get_oldest(struct mgcp_endpoint *endp);
void mgcp_conn_watchdog_kick(struct mgcp_conn *conn);

View File

@ -0,0 +1,27 @@
#pragma once
/* A 64k timeslot on an E1 line can be subdevied into the following
* subslot combinations:
*
* subslot: offset:
* [ ][ ][ 16k ][8k_subslot] 0
* [ ][ 32k ][_subslot__][8k_subslot] 1
* [ ][ subslot ][ 16k ][8k_subslot] 2
* [ 64k ][__________][_subslot__][8k_subslot] 3
* [ timeslot ][ ][ 16k ][8k_subslot] 4
* [ ][ 32K ][_subslot__][8k_subslot] 5
* [ ][ subslot ][ 16k ][8k_subslot] 6
* [ ][ ][ subslot ][8k_subslot] 7
*
* Since overlapping assignment of subslots is not possible there is a limited
* set of subslot assignments possible. The e1_rates array lists the possible
* assignments as depicted above. Also each subslot assignment comes along with
* a bit offset in the E1 bitstream. The e1_offsets arrays lists the bit
* offsets. */
static const uint8_t e1_rates[] = { 64, 32, 32, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 };
static const uint8_t e1_offsets[] = { 0, 0, 4, 0, 2, 4, 6, 0, 1, 2, 3, 4, 5, 6, 7 };
int mgcp_e1_endp_equip(struct mgcp_endpoint *endp, uint8_t ts, uint8_t ss, uint8_t offs);
void mgcp_e1_endp_update(struct mgcp_endpoint *endp);
void mgcp_e1_endp_release(struct mgcp_endpoint *endp, uint8_t ts);
int mgcp_e1_send_rtp(struct mgcp_endpoint *endp, struct mgcp_rtp_codec *codec, struct msgb *msg);

View File

@ -0,0 +1,148 @@
/* Endpoint types */
/*
* (C) 2017 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* Author: Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <osmocom/core/msgb.h>
#include <osmocom/gsm/i460_mux.h>
#include <osmocom/mgcp/mgcp_protocol.h>
struct sockaddr;
struct mgcp_conn;
struct mgcp_conn_rtp;
struct mgcp_endpoint;
/* Number of E1 subslots (different variants, not all useable at the same time) */
#define MGCP_ENDP_E1_SUBSLOTS 15
#define LOGPENDP(endp, cat, level, fmt, args...) \
LOGP(cat, level, "endpoint:%s " fmt, \
endp ? endp->name : "none", \
## args)
enum rtp_proto {
MGCP_PROTO_RTP,
MGCP_PROTO_RTCP,
};
struct osmo_rtp_msg_ctx {
enum rtp_proto proto;
struct mgcp_conn_rtp *conn_src;
struct osmo_sockaddr *from_addr;
};
#define OSMO_RTP_MSG_CTX(MSGB) ((struct osmo_rtp_msg_ctx*)(MSGB)->cb)
osmo_static_assert(sizeof(((struct msgb*)0)->cb) >= sizeof(struct osmo_rtp_msg_ctx), osmo_rtp_msg_ctx_fits_in_msgb_cb);
/* Callback type for RTP dispatcher functions (e.g mgcp_dispatch_rtp_bridge_cb, see below).
* The OSMO_RTP_MSG_CTX() should be set appropriately on the msg. */
typedef int (*mgcp_dispatch_rtp_cb) (struct msgb *msg);
/* Callback type for endpoint specific cleanup actions. This function
* is automatically executed when a connection is freed (see mgcp_conn_free()
* in mgcp_conn.c). Depending on the type of the endpoint there may be endpoint
* specific things to take care of once a connection has been removed. */
typedef void (*mgcp_cleanup_cp) (struct mgcp_endpoint *endp,
struct mgcp_conn *conn);
/*! MGCP endpoint properties */
struct mgcp_endpoint_type {
/*! maximum number of connections */
int max_conns;
/*! callback that defines how to dispatch incoming RTP data */
mgcp_dispatch_rtp_cb dispatch_rtp_cb;
/*! callback that implements endpoint specific cleanup actions */
mgcp_cleanup_cp cleanup_cb;
};
/*! MGCP endpoint typeset */
struct mgcp_endpoint_typeset {
struct mgcp_endpoint_type rtp;
struct mgcp_endpoint_type e1;
};
/*! static MGCP endpoint typeset (pre-initalized, read-only) */
extern const struct mgcp_endpoint_typeset ep_typeset;
/*! MGCP endpoint model */
struct mgcp_endpoint {
/*! Unique endpoint name, used for addressing via MGCP */
char *name;
/*! Call identifier string (as supplied by the call agant) */
char *callid;
/*! Local connection options (see mgcp_internal.h) */
struct mgcp_lco local_options;
/*! List of struct mgcp_conn, of the connections active on this endpoint */
struct llist_head conns;
/*! Backpointer to the trunk this endpoint belongs to */
struct mgcp_trunk *trunk;
/*! Endpoint properties (see above) */
const struct mgcp_endpoint_type *type;
/*! Last MGCP transmission (in case re-transmission is required) */
char *last_trans;
/*! Last MGCP response (in case re-transmission is required) */
char *last_response;
/*! MGCP_X_OSMO_IGN_* flags from 'X-Osmo-IGN:' header */
uint32_t x_osmo_ign;
/* E1 specific */
struct {
struct osmo_i460_schan_desc scd;
struct osmo_i460_subchan *schan;
struct osmo_fsm_inst *trau_sync_fi;
struct osmo_trau2rtp_state *trau_rtp_st;
uint8_t last_amr_ft;
struct mgcp_rtp_codec *last_codec;
} e1;
};
struct mgcp_endpoint *mgcp_endp_alloc(struct mgcp_trunk *trunk, unsigned int index);
int mgcp_endp_claim(struct mgcp_endpoint *endp, const char *callid);
void mgcp_endp_update(struct mgcp_endpoint *endp);
bool mgcp_endp_is_wildcarded(const char *epname);
bool mgcp_endp_is_null(const char *epname);
struct mgcp_endpoint *mgcp_endp_by_name_trunk(int *cause, const char *epname,
const struct mgcp_trunk *trunk);
struct mgcp_endpoint *mgcp_endp_by_name(int *cause, const char *epname,
struct mgcp_config *cfg);
bool mgcp_endp_avail(struct mgcp_endpoint *endp);
void mgcp_endp_add_conn(struct mgcp_endpoint *endp, struct mgcp_conn *conn);
void mgcp_endp_remove_conn(struct mgcp_endpoint *endp, struct mgcp_conn *conn);
void mgcp_endp_strip_name(char *epname_stripped, const char *epname,
const struct mgcp_trunk *trunk);
struct mgcp_endpoint *mgcp_endp_find_specific(const char *epname,
const struct mgcp_trunk *trunk);
void mgcp_endp_release(struct mgcp_endpoint *endp);

View File

@ -1,9 +1,10 @@
/* OML attribute table generator for ipaccess nanobts */
/* IuUP connection functionalitites */
/* (C) 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
/*
* (C) 2021 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* Author: Philipp Maier
* Author: Pau Espin Pedrol
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -17,16 +18,16 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <stdint.h>
#include <osmocom/core/msgb.h>
struct msgb *nanobts_attr_bts_get(struct gsm_bts *bts);
struct msgb *nanobts_attr_nse_get(struct gsm_bts *bts);
struct msgb *nanobts_attr_cell_get(struct gsm_bts *bts);
struct msgb *nanobts_attr_nscv_get(struct gsm_bts *bts);
struct msgb *nanobts_attr_radio_get(struct gsm_bts *bts,
struct gsm_bts_trx *trx);
struct mgcp_conn_rtp;
int mgcp_conn_iuup_init(struct mgcp_conn_rtp *conn_rtp);
void mgcp_conn_iuup_cleanup(struct mgcp_conn_rtp *conn_rtp);
int mgcp_conn_iuup_dispatch_rtp(struct msgb *msg);
int mgcp_conn_iuup_send_rtp(struct mgcp_conn_rtp *conn_src_rtp, struct mgcp_conn_rtp *conn_dest_rtp, struct msgb *msg);
int mgcp_conn_iuup_send_dummy(struct mgcp_conn_rtp *conn_rtp);

View File

@ -0,0 +1,58 @@
/* A Media Gateway Control Protocol Media Gateway: RFC 3435 */
/* Message parser/generator utilities */
/*
* (C) 2009-2012 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2009-2012 by On-Waves
* (C) 2017 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <stdint.h>
#include <stdbool.h>
struct mgcp_conn;
struct mgcp_parse_data;
struct mgcp_endpoint;
struct mgcp_trunk;
void mgcp_disp_msg(unsigned char *message, unsigned int len, char *preamble);
int mgcp_parse_conn_mode(const char *msg, struct mgcp_endpoint *endp,
struct mgcp_conn *conn);
int mgcp_parse_header(struct mgcp_parse_data *pdata, char *data);
int mgcp_parse_osmux_cid(const char *line);
bool mgcp_check_param(const struct mgcp_endpoint *endp, struct mgcp_trunk *trunk, const char *line);
int mgcp_verify_call_id(struct mgcp_endpoint *endp, const char *callid);
int mgcp_verify_ci(struct mgcp_endpoint *endp, const char *conn_id);
char *mgcp_strline(char *str, char **saveptr);
#define for_each_line(line, save)\
for (line = mgcp_strline(NULL, &save); line;\
line = mgcp_strline(NULL, &save))
#define for_each_non_empty_line(line, save)\
for (line = strtok_r(NULL, "\r\n", &save); line;\
line = strtok_r(NULL, "\r\n", &save))

View File

@ -0,0 +1,186 @@
#pragma once
#include <inttypes.h>
#include <stdbool.h>
#include <osmocom/core/socket.h>
#include <osmocom/core/osmo_io.h>
#include <osmocom/mgcp/mgcp.h>
/* The following constant defines an RTP dummy payload that is used for
* "UDP Hole Punching" (NAT) */
#define MGCP_DUMMY_LOAD 0x23
static const char rtp_dummy_payload[] = { MGCP_DUMMY_LOAD };
/* Check if the data in a given message buffer matches the rtp dummy payload
* defined above */
#define mgcp_is_rtp_dummy_payload(msg) \
(msgb_length(msg) == sizeof(rtp_dummy_payload) && \
memcmp(msgb_data(msg), rtp_dummy_payload, sizeof(rtp_dummy_payload)) == 0)
#define RTP_BUF_SIZE 4096
struct mgcp_rtp_stream_state {
uint32_t ssrc;
uint16_t last_seq;
uint32_t last_timestamp;
struct rate_ctr *err_ts_ctr;
int32_t last_tsdelta;
uint32_t last_arrival_time;
};
struct mgcp_rtp_state {
/* has this state structure been initialized? */
int initialized;
struct {
/* are we patching the SSRC value? */
bool patch_ssrc;
/* original SSRC (to which we shall patch any different SSRC) */
uint32_t orig_ssrc;
/* offset to apply on the sequence number */
int seq_offset;
/* offset to apply on the timestamp number */
int32_t timestamp_offset;
} patch;
/* duration of a packet (FIXME: in which unit?) */
uint32_t packet_duration;
/* Note: These states are not continuously updated, they serve as an
* information source to patch certain values in the RTP header. Do
* not use this state if constantly updated data about the RTP stream
* is needed. (see also mgcp_patch_and_count() */
struct mgcp_rtp_stream_state in_stream;
struct mgcp_rtp_stream_state out_stream;
/* jitter and packet loss calculation */
struct {
int initialized;
uint16_t base_seq;
uint16_t max_seq;
uint32_t ssrc;
uint32_t jitter;
int32_t transit;
int cycles;
} stats;
/* Alternative values for RTP tx, in case no sufficient header
* information is available so the header needs to be generated
* locally (when just forwarding packets, the header of incoming
* data is just re-used) */
uint16_t alt_rtp_tx_sequence;
uint32_t alt_rtp_tx_ssrc;
};
struct mgcp_rtp_codec {
uint32_t rate;
int channels;
uint32_t frame_duration_num;
uint32_t frame_duration_den;
int payload_type;
char audio_name[64];
char subtype_name[64];
bool param_present;
struct mgcp_codec_param param;
};
/* 'mgcp_rtp_end': basically a wrapper around the RTP+RTCP ports */
struct mgcp_rtp_end {
/* remote IP address of the RTP socket */
struct osmo_sockaddr addr;
/* in network byte order */
int rtcp_port;
/* currently selected audio codec */
struct mgcp_rtp_codec *codec;
/* array with assigned audio codecs to choose from (SDP) */
struct mgcp_rtp_codec codecs[MGCP_MAX_CODECS];
/* number of assigned audio codecs (SDP) */
unsigned int codecs_assigned;
/* per endpoint data */
int frames_per_packet;
uint32_t packet_duration_ms;
int maximum_packet_time; /* -1: not set */
/* are we transmitting packets (true) or dropping (false) outbound packets */
bool output_enabled;
/* FIXME: This parameter can be set + printed, but is nowhere used! */
int force_output_ptime;
/* RTP patching */
int force_constant_ssrc; /* -1: always, 0: don't, 1: once */
/* should we perform align_rtp_timestamp_offset() (1) or not (0) */
int force_aligned_timing;
bool rfc5993_hr_convert;
/* Each end has a separate socket for RTP and RTCP */
struct osmo_io_fd *rtp;
struct osmo_io_fd *rtcp;
/* local UDP port number of the RTP socket; RTCP is +1 */
int local_port;
/* where the endpoint RTP connection binds to, set during CRCX and
* possibly updated during MDCX */
char local_addr[INET6_ADDRSTRLEN];
};
bool mgcp_rtp_end_remote_addr_available(const struct mgcp_rtp_end *rtp_end);
struct mgcp_rtp_tap {
/* is this tap active (1) or not (0) */
int enabled;
/* IP/port to which we're forwarding the tapped data */
struct osmo_sockaddr forward;
};
struct mgcp_conn;
int mgcp_send(struct mgcp_endpoint *endp, int is_rtp, struct osmo_sockaddr *addr,
struct msgb *msg, struct mgcp_conn_rtp *conn_src,
struct mgcp_conn_rtp *conn_dst);
int mgcp_send_dummy(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn);
int mgcp_dispatch_rtp_bridge_cb(struct msgb *msg);
void mgcp_cleanup_rtp_bridge_cb(struct mgcp_endpoint *endp, struct mgcp_conn *conn);
int mgcp_dispatch_e1_bridge_cb(struct msgb *msg);
void mgcp_cleanup_e1_bridge_cb(struct mgcp_endpoint *endp, struct mgcp_conn *conn);
int mgcp_bind_net_rtp_port(struct mgcp_endpoint *endp, int rtp_port,
struct mgcp_conn_rtp *conn);
void mgcp_free_rtp_port(struct mgcp_rtp_end *end);
void mgcp_patch_and_count(const struct mgcp_endpoint *endp,
struct mgcp_rtp_state *state,
struct mgcp_rtp_end *rtp_end,
struct osmo_sockaddr *addr, struct msgb *msg);
int mgcp_get_local_addr(char *addr, struct mgcp_conn_rtp *conn);
/* payload processing default functions */
int mgcp_rtp_processing_default(struct mgcp_endpoint *endp, struct mgcp_rtp_end *dst_end, struct msgb *msg);
int mgcp_setup_rtp_processing_default(struct mgcp_endpoint *endp,
struct mgcp_conn_rtp *conn_dst,
struct mgcp_conn_rtp *conn_src);
void mgcp_get_net_downlink_format_default(struct mgcp_endpoint *endp,
const struct mgcp_rtp_codec **codec,
const char **fmtp_extra,
struct mgcp_conn_rtp *conn);
/* internal RTP Annex A counting */
void mgcp_rtp_annex_count(const struct mgcp_endpoint *endp, struct mgcp_rtp_state *state,
const uint16_t seq, const int32_t transit,
const uint32_t ssrc, const bool marker_bit);
void rtpconn_rate_ctr_add(struct mgcp_conn_rtp *conn_rtp, struct mgcp_endpoint *endp,
int id, int inc);
void rtpconn_rate_ctr_inc(struct mgcp_conn_rtp *conn_rtp, struct mgcp_endpoint *endp,
int id);
void forward_data_tap(struct osmo_io_fd *iofd, struct mgcp_rtp_tap *tap, struct msgb *msg);
uint32_t mgcp_get_current_ts(unsigned codec_rate);
int amr_oa_bwe_convert(struct mgcp_endpoint *endp, struct msgb *msg, bool target_is_oa);

View File

@ -0,0 +1,30 @@
#pragma once
/* Internal structure while parsing a request */
struct mgcp_parse_data {
struct mgcp_config *cfg;
char *epname;
char *trans;
char *save;
};
/* Local connection options */
struct mgcp_lco {
char *string;
char *codec;
int pkt_period_min; /* time in ms */
int pkt_period_max; /* time in ms */
};
char *mgcp_debug_get_last_endpoint_name(void);
char *get_lco_identifier(const char *options);
int check_local_cx_options(void *ctx, const char *options);
struct mgcp_rtp_end;
struct mgcp_endpoint;
void mgcp_rtp_end_config(struct mgcp_endpoint *endp, int expect_ssrc_change,
struct mgcp_rtp_end *rtp);
uint32_t mgcp_rtp_packet_duration(const struct mgcp_endpoint *endp,
const struct mgcp_rtp_end *rtp);

View File

@ -0,0 +1,109 @@
#pragma once
/* Global MCGP general rate counters */
enum {
MGCP_GENERAL_RX_MSGS_TOTAL,
MGCP_GENERAL_RX_MSGS_RETRANSMITTED,
MGCP_GENERAL_RX_MSGS_HANDLED,
MGCP_GENERAL_RX_MSGS_UNHANDLED,
MGCP_GENERAL_RX_FAIL_MSG_PARSE,
MGCP_GENERAL_RX_FAIL_NO_ENDPOINT,
};
/* Trunk-global MCGP CRCX related rate counters */
enum {
MGCP_CRCX_SUCCESS,
MGCP_CRCX_FAIL_BAD_ACTION,
MGCP_CRCX_FAIL_UNHANDLED_PARAM,
MGCP_CRCX_FAIL_MISSING_CALLID,
MGCP_CRCX_FAIL_INVALID_MODE,
MGCP_CRCX_FAIL_LIMIT_EXCEEDED,
MGCP_CRCX_FAIL_UNKNOWN_CALLID,
MGCP_CRCX_FAIL_ALLOC_CONN,
MGCP_CRCX_FAIL_NO_REMOTE_CONN_DESC,
MGCP_CRCX_FAIL_START_RTP,
MGCP_CRCX_FAIL_NO_OSMUX,
MGCP_CRCX_FAIL_INVALID_CONN_OPTIONS,
MGCP_CRCX_FAIL_CODEC_NEGOTIATION,
MGCP_CRCX_FAIL_BIND_PORT,
MGCP_CRCX_FAIL_AVAIL,
MGCP_CRCX_FAIL_CLAIM,
};
/* Trunk-global MCGP MDCX related rate counters */
enum {
MGCP_MDCX_SUCCESS,
MGCP_MDCX_FAIL_WILDCARD,
MGCP_MDCX_FAIL_NO_CONN,
MGCP_MDCX_FAIL_INVALID_CALLID,
MGCP_MDCX_FAIL_INVALID_CONNID,
MGCP_MDCX_FAIL_UNHANDLED_PARAM,
MGCP_MDCX_FAIL_NO_CONNID,
MGCP_MDCX_FAIL_CONN_NOT_FOUND,
MGCP_MDCX_FAIL_INVALID_MODE,
MGCP_MDCX_FAIL_INVALID_CONN_OPTIONS,
MGCP_MDCX_FAIL_NO_REMOTE_CONN_DESC,
MGCP_MDCX_FAIL_START_RTP,
MGCP_MDCX_FAIL_AVAIL,
};
/* Trunk-global MCGP DLCX related rate counters */
enum {
MGCP_DLCX_SUCCESS,
MGCP_DLCX_FAIL_NO_CONN,
MGCP_DLCX_FAIL_INVALID_CALLID,
MGCP_DLCX_FAIL_INVALID_CONNID,
MGCP_DLCX_FAIL_UNHANDLED_PARAM,
MGCP_DLCX_FAIL_AVAIL,
};
/* Trunk-global E1 related counters */
enum {
E1_I460_TRAU_RX_FAIL_CTR,
E1_I460_TRAU_TX_FAIL_CTR,
E1_I460_TRAU_MUX_EMPTY_CTR,
};
/* NOTE: When adding counters, also the dump_ratectr_* routines in vty.c must be updated. */
struct mgcp_ratectr_global {
/* Rate counter group which contains stats for generic MGCP events. */
struct rate_ctr_group *mgcp_general_ctr_group;
};
struct mgcp_ratectr_trunk {
/* Rate counter group which contains stats for processed CRCX commands. */
struct rate_ctr_group *mgcp_crcx_ctr_group;
/* Rate counter group which contains stats for processed MDCX commands. */
struct rate_ctr_group *mgcp_mdcx_ctr_group;
/* Rate counter group which contains stats for processed DLCX commands. */
struct rate_ctr_group *mgcp_dlcx_ctr_group;
/* Rate counter group which aggregates stats of individual RTP connections. */
struct rate_ctr_group *all_rtp_conn_stats;
/* Rate counter group which aggregates stats of individual Osmux connections. */
struct rate_ctr_group *all_osmux_conn_stats;
/* Rate counter group which contains stats for E1 events (only valid for E1 trunks) */
struct rate_ctr_group *e1_stats;
};
struct mgcp_config;
struct mgcp_trunk;
int mgcp_ratectr_global_alloc(struct mgcp_config *cfg);
void mgcp_ratectr_global_free(struct mgcp_config *cfg);
int mgcp_ratectr_trunk_alloc(struct mgcp_trunk *trunk);
void mgcp_ratectr_trunk_free(struct mgcp_trunk *trunk);
/* Trunk-global common stat items */
enum {
TRUNK_STAT_ENDPOINTS_TOTAL,
TRUNK_STAT_ENDPOINTS_USED,
};
struct mgcp_stat_trunk {
/* Stat item group which contains general status values of the trunk. */
struct osmo_stat_item_group *common;
};
int mgcp_stat_trunk_alloc(struct mgcp_trunk *trunk);
void mgcp_stat_trunk_free(struct mgcp_trunk *trunk);

View File

@ -1,6 +1,8 @@
/*
* (C) 2010-2013 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2010-2013 by On-Waves
* SDP generation and parsing
*
* (C) 2009-2015 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2009-2014 by On-Waves
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
@ -18,14 +20,12 @@
*
*/
#ifndef OSMO_BSC_GRACE_H
#define OSMO_BSC_GRACE_H
#pragma once
#include <openbsc/gsm_data.h>
int mgcp_parse_sdp_data(const struct mgcp_endpoint *endp,
struct mgcp_conn_rtp *conn,
struct mgcp_parse_data *p);
struct osmo_msc_data;
int bsc_grace_allow_new_connection(struct gsm_network *net, struct gsm_bts *bts);
int bsc_grace_paging_request(struct gsm_subscriber *sub, int type, struct osmo_msc_data *msc);
#endif
int mgcp_write_response_sdp(const struct mgcp_endpoint *endp,
const struct mgcp_conn_rtp *conn, struct msgb *sdp,
const char *addr);

View File

@ -1,7 +1,10 @@
/* Generic BTS - VTY code tries to allocate this BTS before type is known */
/* A Media Gateway Control Protocol Media Gateway: RFC 3435 */
/* The statistics generator */
/* (C) 2010 by Daniel Willmann <daniel@totalueberwachung.de>
*
/*
* (C) 2009-2012 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2009-2012 by On-Waves
* (C) 2017 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
@ -19,22 +22,14 @@
*
*/
#pragma once
#include <openbsc/gsm_data.h>
#include <osmocom/gsm/tlv.h>
#include <openbsc/abis_nm.h>
#include <inttypes.h>
static struct gsm_bts_model model_unknown = {
.type = GSM_BTS_TYPE_UNKNOWN,
.name = "unknown",
.oml_rcvmsg = &abis_nm_rcvmsg,
.nm_att_tlvdef = {
.def = {
},
},
};
void mgcp_format_stats(char *str, size_t str_len, struct mgcp_conn *conn);
int bts_model_unknown_init(void)
{
return gsm_bts_model_register(&model_unknown);
}
/* Exposed for test purposes only, do not use actively */
void calc_loss(struct mgcp_conn_rtp *conn, uint32_t *expected, int *loss);
/* Exposed for test purposes only, do not use actively */
uint32_t calc_jitter(struct mgcp_rtp_state *);

View File

@ -0,0 +1,52 @@
/*
* (C) 2021 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* Author: Eric Wild
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <stdatomic.h>
#include <stdbool.h>
#include <stdlib.h>
struct spsc {
atomic_uint readptr;
atomic_uint writeptr;
int efd_r, efd_w; /* eventfds used to block/notify readers/writers */
int count;
int size_per_buf;
void *buf; /* buffer size count*size_per_buf */
uintptr_t data[0]; /* count sized array of pointers to size_per_buf chunks in buf array*/
};
struct qchan {
struct spsc *a;
struct spsc *b;
};
bool spsc_push(struct spsc *q, void *elem);
bool spsc_pop(struct spsc *q, void *elem);
ssize_t spsc_prep_pop(struct spsc *q);
int spsc_get_a_rdfd(struct qchan *q);
struct qchan spsc_chan_init(void *talloc_ctx, unsigned int count, unsigned int size_per_buf);
struct qchan spsc_chan_init_ex(void *talloc_ctx, unsigned int count, unsigned int size_per_buf, bool blockr_a,
bool blockw_a, bool blockr_b, bool blockw_b);
void spsc_chan_close(struct qchan *q);

View File

@ -0,0 +1,85 @@
#pragma once
#include <osmocom/gsm/i460_mux.h>
#include <osmocom/abis/e1_input.h>
#include <osmocom/mgcp/mgcp_ratectr.h>
#define LOGPTRUNK(trunk, cat, level, fmt, args...) \
LOGP(cat, level, "trunk:%u " fmt, \
trunk ? trunk->trunk_nr : 0, \
## args)
enum mgcp_trunk_type {
MGCP_TRUNK_VIRTUAL,
MGCP_TRUNK_E1,
};
extern const struct value_string mgcp_trunk_type_strs[];
static inline const char *mgcp_trunk_type_strs_str(enum mgcp_trunk_type val)
{ return get_value_string(mgcp_trunk_type_strs, val); }
struct mgcp_trunk {
struct llist_head entry;
struct mgcp_config *cfg;
unsigned int trunk_nr;
enum mgcp_trunk_type trunk_type;
int audio_send_ptime;
int audio_send_name;
int omit_rtcp;
int keepalive_interval;
/* RTP patching */
int force_constant_ssrc; /* 0: don't, 1: once */
int force_aligned_timing;
bool rfc5993_hr_convert;
/* spec handling */
int force_realloc;
/* timer */
struct osmo_timer_list keepalive_timer;
/* When set, incoming RTP packets are not filtered
* when ports and ip-address do not match (debug) */
int rtp_accept_all;
unsigned int number_endpoints;
struct mgcp_endpoint **endpoints;
/* rate counters and stat items to measure the trunks overall performance and health */
struct mgcp_ratectr_trunk ratectr;
struct mgcp_stat_trunk stats;
union {
/* Virtual trunk specific */
struct {
unsigned int vty_number_endpoints;
} v;
/* E1 specific */
struct {
unsigned int vty_line_nr;
uint8_t ts_usecount[NUM_E1_TS-1];
struct osmo_i460_timeslot i460_ts[NUM_E1_TS-1];
/* Note: on an E1 line TS 0 is devoted to framing and
* alignment and therefore only NUM_E1_TS-1 timeslots
* are available for traffic. */
} e1;
};
};
struct mgcp_trunk *mgcp_trunk_alloc(struct mgcp_config *cfg, enum mgcp_trunk_type ttype, unsigned int nr);
int mgcp_trunk_equip(struct mgcp_trunk *trunk);
struct mgcp_trunk *mgcp_trunk_by_num(const struct mgcp_config *cfg, enum mgcp_trunk_type ttype, unsigned int nr);
struct mgcp_trunk *mgcp_trunk_by_name(const struct mgcp_config *cfg, const char *epname);
int e1_trunk_nr_from_epname(unsigned int *trunk_nr, const char *epname);
struct mgcp_trunk *mgcp_trunk_by_line_num(const struct mgcp_config *cfg, unsigned int num);
/* The virtual trunk is always created on trunk id 0 for historical reasons,
* use this define constant as ID when allocating a virtual trunk. Other
* trunks may be assigned with arbritrary id numbers */
#define MGCP_VIRT_TRUNK_ID 0

View File

@ -0,0 +1,41 @@
#pragma once
#include <stdint.h>
#include <osmocom/core/socket.h>
#include <osmocom/netif/osmux.h>
struct mgcp_conn_rtp;
struct mgcp_trunk;
struct mgcp_endpoint;
struct mgcp_conn_rtp;
int osmux_init(struct mgcp_trunk *trunk);
int osmux_init_conn(struct mgcp_conn_rtp *conn);
int conn_osmux_enable(struct mgcp_conn_rtp *conn);
void conn_osmux_disable(struct mgcp_conn_rtp *conn);
int conn_osmux_event_rx_crcx_mdcx(struct mgcp_conn_rtp *conn);
int conn_osmux_send_rtp(struct mgcp_conn_rtp *conn, struct msgb *msg);
int osmux_send_dummy(struct mgcp_conn_rtp *conn);
void osmux_cid_pool_get(uint8_t osmux_cid);
int osmux_cid_pool_get_next(void);
void osmux_cid_pool_put(uint8_t osmux_cid);
bool osmux_cid_pool_allocated(uint8_t osmux_cid);
int osmux_cid_pool_count_used(void);
enum osmux_state {
OSMUX_STATE_DISABLED = 0, /* Osmux not being currently used by endp */
OSMUX_STATE_ACTIVATING, /* Osmux was accepted in MGCP CRCX ACK. It can now be enabled by \ref conn_osmux_enable. */
OSMUX_STATE_ENABLED, /* Osmux was initialized by \ref conn_osmux_enable and can process frames */
};
extern const struct value_string osmux_state_strs[];
static inline const char *osmux_state_str(enum osmux_state val)
{ return get_value_string(osmux_state_strs, val); }
enum osmux_usage {
OSMUX_USAGE_OFF = 0,
OSMUX_USAGE_ON = 1,
OSMUX_USAGE_ONLY = 2,
};

View File

@ -0,0 +1,12 @@
#pragma once
#include <osmocom/vty/command.h>
enum mgcp_vty_node {
MGCP_NODE = _LAST_OSMOVTY_NODE + 1,
TRUNK_NODE,
};
enum mgw_vty_cmd_attr {
MGW_CMD_ATTR_NEWCONN = 0,
};

View File

@ -0,0 +1,14 @@
BUILT_SOURCES = \
mgcp_common.h \
$(NULL)
noinst_HEADERS = \
mgcp_client_internal.h \
mgcp_client_pool_internal.h \
$(NULL)
mgcp_common.h: $(top_srcdir)/include/osmocom/mgcp/mgcp_common.h
echo -e "/*\n\n DO NOT EDIT THIS FILE!\n THIS IS OVERWRITTEN DURING BUILD\n This is an automatic copy of <osmocom/mgcp/mgcp_common.h>\n\n */" > mgcp_common.h
cat $(top_srcdir)/include/osmocom/mgcp/mgcp_common.h >> mgcp_common.h
CLEANFILES = mgcp_common.h

View File

@ -0,0 +1,7 @@
#include <osmocom/core/defs.h>
#if BUILDING_LIBOSMOMGCPCLIENT
# define OSMO_DEPRECATED_OUTSIDE_LIBOSMOMGCPCLIENT(text)
#else
# define OSMO_DEPRECATED_OUTSIDE_LIBOSMOMGCPCLIENT(text) OSMO_DEPRECATED(text)
#endif

View File

@ -0,0 +1,127 @@
#pragma once
#include <stdint.h>
#include <arpa/inet.h>
#include <osmocom/mgcp_client/defs.h>
#include <osmocom/mgcp_client/mgcp_common.h>
/* See also: RFC 3435, chapter 3.5 Transmission over UDP */
#define MGCP_CLIENT_LOCAL_ADDR_DEFAULT NULL /* INADDR(6)_ANY */
#define MGCP_CLIENT_LOCAL_PORT_DEFAULT 0
#define MGCP_CLIENT_REMOTE_ADDR_DEFAULT "127.0.0.1"
#define MGCP_CLIENT_REMOTE_PORT_DEFAULT 2427
#define MGCP_CLIENT_KEEPALIVE_DEFAULT_ENDP "null"
#define MGCP_CLIENT_MGW_STR "Configure MGCP connection to Media Gateway\n"
struct msgb;
struct vty;
struct mgcp_client;
struct mgcp_client_conf {
const char *local_addr;
int local_port;
const char *remote_addr;
int remote_port;
/* By default, we are always addressing the MGW with e.g. 'rtpbridge/123@mgw'.
* If this is nonempty, the contained name will be used instead of 'mgw'. */
char endpoint_domain_name[MGCP_ENDPOINT_MAXLEN];
/* The user may configure certain endpoint names that are reset via DLCX
* on startup. Usually this will be one wildcarded endpoint e.g.
* 'rtpbridge/(wildcard)' or a number of specific E1 like e.g.
* 'ds/e1-0/s-3/su16-4' */
struct llist_head reset_epnames;
/* human readable name / description */
char *description;
struct {
uint32_t timeout_sec;
uint32_t req_interval_sec;
char req_endpoint_name[MGCP_ENDPOINT_MAXLEN];
} keepalive;
};
typedef unsigned int mgcp_trans_id_t;
/*! Enumeration of the codec types that mgcp_client is able to handle. */
enum mgcp_codecs {
CODEC_PCMU_8000_1 = 0,
CODEC_GSM_8000_1 = 3,
CODEC_PCMA_8000_1 = 8,
CODEC_G729_8000_1 = 18,
CODEC_GSMEFR_8000_1 = 110, /* 3GPP TS 48.103 table 5.4.2.2.1 */
CODEC_GSMHR_8000_1 = 111, /* 3GPP TS 48.103 table 5.4.2.2.1 */
CODEC_AMR_8000_1 = 112, /* 3GPP TS 48.103 table 5.4.2.2.1 */
CODEC_AMRWB_16000_1 = 113, /* 3GPP TS 48.103 table 5.4.2.2.1 */
CODEC_IUFP = 96,
CODEC_CLEARMODE = 120, /* 3GPP TS 48.103 table 5.4.2.2.1 */
};
/* Note: when new codec types are added, the corresponding value strings
* in mgcp_client.c (codec_table) must be updated as well. Enumerations
* in enum mgcp_codecs must correspond to a valid payload type. However,
* this is an internal assumption that is made to avoid lookup tables.
* The API-User should not rely on this coincidence! */
extern const struct value_string osmo_mgcpc_codec_names[];
static inline const char *osmo_mgcpc_codec_name(enum mgcp_codecs val)
{ return get_value_string(osmo_mgcpc_codec_names, val); }
/*! Structure to build a payload type map to allow the defiition custom payload
* types. */
struct ptmap {
/*! codec for which a payload type number should be defined */
enum mgcp_codecs codec;
/*! payload type number (96-127) */
unsigned int pt;
};
int ptmap_cmp(const struct ptmap *a, const struct ptmap *b);
enum mgcp_verb {
MGCP_VERB_CRCX,
MGCP_VERB_MDCX,
MGCP_VERB_DLCX,
MGCP_VERB_AUEP,
MGCP_VERB_RSIP,
};
struct mgcp_client_conf *mgcp_client_conf_alloc(void *ctx);
void mgcp_client_conf_init(struct mgcp_client_conf *conf) OSMO_DEPRECATED_OUTSIDE_LIBOSMOMGCPCLIENT("use mgcp_client_conf_alloc() (or even better, switch to the mgcp_client_pool API!)");
void mgcp_client_vty_init(void *talloc_ctx, int node, struct mgcp_client_conf *conf);
int mgcp_client_config_write(struct vty *vty, const char *indent);
struct mgcp_client_conf *mgcp_client_conf_actual(struct mgcp_client *mgcp);
struct mgcp_client *mgcp_client_init(void *ctx,
struct mgcp_client_conf *conf);
int mgcp_client_connect(struct mgcp_client *mgcp);
int mgcp_client_connect2(struct mgcp_client *mgcp, unsigned int retry_n_ports) OSMO_DEPRECATED("Use mgcp_client_connect() instead");
void mgcp_client_disconnect(struct mgcp_client *mgcp);
const char *mgcp_client_remote_addr_str(struct mgcp_client *mgcp);
uint16_t mgcp_client_remote_port(struct mgcp_client *mgcp);
uint32_t mgcp_client_remote_addr_n(struct mgcp_client *mgcp) OSMO_DEPRECATED("deprecated, returns 0");
const char *mgcp_client_endpoint_domain(const struct mgcp_client *mgcp);
const char *mgcp_client_rtpbridge_wildcard(const struct mgcp_client *mgcp);
const char *mgcp_client_e1_epname(void *ctx, const struct mgcp_client *mgcp, uint8_t trunk_id, uint8_t ts,
uint8_t rate, uint8_t offset);
enum mgcp_connection_mode;
extern const struct value_string mgcp_client_connection_mode_strs[];
static inline const char *mgcp_client_cmode_name(enum mgcp_connection_mode mode)
{
return get_value_string(mgcp_client_connection_mode_strs, mode);
}
enum mgcp_codecs map_str_to_codec(const char *str);
unsigned int map_codec_to_pt(const struct ptmap *ptmap, unsigned int ptmap_len,
enum mgcp_codecs codec);
enum mgcp_codecs map_pt_to_codec(struct ptmap *ptmap, unsigned int ptmap_len,
unsigned int pt);
const char *mgcp_client_name(const struct mgcp_client *mgcp);

View File

@ -0,0 +1,55 @@
/* FSM to manage multiple connections of an MGW endpoint */
#pragma once
#include <osmocom/mgcp_client/mgcp_client_fsm.h>
#define LOG_MGCPC_EP(ep, level, fmt, args...) do { \
LOGPFSML(ep->fi, level, "%s " fmt, \
osmo_mgcpc_ep_name(ep), ## args); \
} while(0)
struct osmo_mgcpc_ep;
struct osmo_mgcpc_ep_ci;
struct osmo_tdef;
struct osmo_mgcpc_ep *osmo_mgcpc_ep_alloc(struct osmo_fsm_inst *parent, uint32_t parent_term_event,
struct mgcp_client *mgcp_client,
const struct osmo_tdef *T_defs,
const char *fsm_id,
const char *endpoint_str_fmt, ...);
struct osmo_mgcpc_ep_ci *osmo_mgcpc_ep_ci_add(struct osmo_mgcpc_ep *ep, const char *label_fmt, ...);
const struct mgcp_conn_peer *osmo_mgcpc_ep_ci_get_rtp_info(const struct osmo_mgcpc_ep_ci *ci);
bool osmo_mgcpc_ep_ci_get_crcx_info_to_sockaddr(const struct osmo_mgcpc_ep_ci *ci, struct sockaddr_storage *dest);
bool osmo_mgcpc_ep_ci_get_crcx_info_to_osmux_cid(const struct osmo_mgcpc_ep_ci *ci, uint8_t* cid);
const struct mgcp_conn_peer *osmo_mgcpc_ep_ci_get_remote_rtp_info(const struct osmo_mgcpc_ep_ci *ci);
void osmo_mgcpc_ep_ci_request(struct osmo_mgcpc_ep_ci *ci,
enum mgcp_verb verb, const struct mgcp_conn_peer *verb_info,
struct osmo_fsm_inst *notify,
uint32_t event_success, uint32_t event_failure,
void *notify_data);
void osmo_mgcpc_ep_cancel_notify(struct osmo_mgcpc_ep *ep, struct osmo_fsm_inst *notify);
struct osmo_mgcpc_ep *osmo_mgcpc_ep_ci_ep(struct osmo_mgcpc_ep_ci *ci);
/*! Dispatch a DLCX for the given connection.
* \param ci Connection identifier as obtained from osmo_mgcpc_ep_ci_add().
*/
static inline void osmo_mgcpc_ep_ci_dlcx(struct osmo_mgcpc_ep_ci *ci)
{
osmo_mgcpc_ep_ci_request(ci, MGCP_VERB_DLCX, NULL, NULL, 0, 0, NULL);
}
void osmo_mgcpc_ep_clear(struct osmo_mgcpc_ep *ep);
const char *osmo_mgcpc_ep_name(const struct osmo_mgcpc_ep *ep);
const char *osmo_mgcpc_ep_local_name(const struct osmo_mgcpc_ep *ep);
const char *osmo_mgcpc_ep_ci_name(const struct osmo_mgcpc_ep_ci *ci);
const char *osmo_mgcpc_ep_ci_id(const struct osmo_mgcpc_ep_ci *ci);
struct mgcp_client *osmo_mgcpc_ep_client(const struct osmo_mgcpc_ep *ep);
extern const struct value_string osmo_mgcp_verb_names[];
static inline const char *osmo_mgcp_verb_name(enum mgcp_verb val)
{ return get_value_string(osmo_mgcp_verb_names, val); }

View File

@ -0,0 +1,78 @@
#pragma once
#include <osmocom/mgcp_client/mgcp_common.h>
#include <osmocom/mgcp_client/mgcp_client.h>
#include <osmocom/gsm/protocol/gsm_04_08.h>
/*! This struct organizes the connection infromation one connection side
* (either remote or local). It is used to pass parameters (local) to the FSM
* and get responses (remote) from the FSM as pointer attached to the FSM
* event.
*
* When modifiying a connection, the endpoint and call_id members may be left
* unpopulated. The call_id field is ignored in this case. If an endpoint
* identifier is supplied it is checked against the internal state to make
* sure it is correct. */
struct mgcp_conn_peer {
/*! RTP connection IP-Address (optional, string e.g. "127.0.0.1") */
char addr[INET6_ADDRSTRLEN];
/*! RTP connection IP-Port (optional) */
uint16_t port;
/*! RTP endpoint */
char endpoint[MGCP_ENDPOINT_MAXLEN];
/*! CALL ID (unique per connection) */
unsigned int call_id;
/*! RTP packetization interval (optional) */
unsigned int ptime;
/*! Deprecated. Use only ptmap[].codec in new code. */
enum mgcp_codecs codecs[MGCP_MAX_CODECS]
OSMO_DEPRECATED_OUTSIDE_LIBOSMOMGCPCLIENT("use ptmap[i].codec instead");
unsigned int codecs_len
OSMO_DEPRECATED_OUTSIDE_LIBOSMOMGCPCLIENT("use ptmap[] and ptmap_len instead");
/*! RTP payload type map (optional, only needed when payload types are
* used that differ from what IANA/3GPP defines) */
struct ptmap ptmap[MGCP_MAX_CODECS];
/*! RTP payload type map length (optional, only needed when payload
* types are used that differ from what IANA/3GPP defines) */
unsigned int ptmap_len;
/*! If nonzero, send 'X-Osmo-IGN:' header. This is useful e.g. for SCCPlite MSCs where the MSC is
* known to issue incoherent or unknown CallIDs / to issue CRCX commands with a different domain
* name than the BSC. An OsmoMGW will then ignore these and not fail on mismatches. */
uint32_t x_osmo_ign;
/*! send 'X-Osmux: %d' header (or "*" as wildcard). */
bool x_osmo_osmux_use;
/*! -1 means send wildcard. */
int x_osmo_osmux_cid;
/*! If left MGCP_CONN_NONE, use MGCP_CONN_RECV_ONLY or MGCP_CONN_RECV_SEND, depending on whether an audio RTP
* address is set. If != MGCP_CONN_NONE, force this conn mode. */
enum mgcp_connection_mode conn_mode;
/*! If the codec requires additional format parameters (fmtp), those cann be set here, see also
* mgcp_common.h */
bool param_present;
struct mgcp_codec_param param;
};
struct osmo_fsm_inst *mgcp_conn_create(struct mgcp_client *mgcp, struct osmo_fsm_inst *parent_fi, uint32_t parent_term_evt,
uint32_t parent_evt, struct mgcp_conn_peer *conn_peer)
OSMO_DEPRECATED_OUTSIDE_LIBOSMOMGCPCLIENT("use osmo_mgcpc_ep_alloc() and osmo_mgcpc_ep_ci_add() instead");
int mgcp_conn_modify(struct osmo_fsm_inst *fi, uint32_t parent_evt, struct mgcp_conn_peer *conn_peer)
OSMO_DEPRECATED_OUTSIDE_LIBOSMOMGCPCLIENT("use osmo_mgcpc_ep_ci_request() instead");
void mgcp_conn_delete(struct osmo_fsm_inst *fi)
OSMO_DEPRECATED_OUTSIDE_LIBOSMOMGCPCLIENT("use osmo_mgcpc_ep_ci_dlcx() instead");
const char *mgcp_conn_get_ci(struct osmo_fsm_inst *fi)
OSMO_DEPRECATED_OUTSIDE_LIBOSMOMGCPCLIENT("use osmo_mgcpc_ep_ci.mgcp_ci_str instead");
struct mgcp_client *mgcp_conn_get_client(struct osmo_fsm_inst *fi);
const char *osmo_mgcpc_conn_peer_name(const struct mgcp_conn_peer *info);

View File

@ -0,0 +1,101 @@
#pragma once
#include <osmocom/core/osmo_io.h>
#include <osmocom/core/timer.h>
#define MSGB_CB_MGCP_TRANS_ID 0
/* Struct that holds one endpoint name */
struct reset_ep {
struct llist_head list;
char name[MGCP_ENDPOINT_MAXLEN];
};
struct mgcp_client {
struct mgcp_client_conf actual;
struct osmo_io_fd *iofd;
mgcp_trans_id_t next_trans_id;
struct llist_head responses_pending;
struct mgcp_client_pool_member *pool_member;
struct osmo_timer_list keepalive_tx_timer;
struct osmo_timer_list keepalive_rx_timer;
bool conn_up;
};
struct mgcp_response_head {
int response_code;
mgcp_trans_id_t trans_id;
char comment[MGCP_COMMENT_MAXLEN];
char conn_id[MGCP_CONN_ID_MAXLEN];
char endpoint[MGCP_ENDPOINT_MAXLEN];
bool x_osmo_osmux_use;
uint8_t x_osmo_osmux_cid;
};
struct mgcp_response {
char *body;
struct mgcp_response_head head;
uint16_t audio_port;
char audio_ip[INET6_ADDRSTRLEN];
unsigned int ptime;
struct ptmap ptmap[MGCP_MAX_CODECS];
unsigned int ptmap_len;
};
/* Invoked when an MGCP response is received or sending failed. When the
* response is passed as NULL, this indicates failure during transmission. */
typedef void (*mgcp_response_cb_t)(struct mgcp_response *response, void *priv);
struct mgcp_response_pending {
struct llist_head entry;
mgcp_trans_id_t trans_id;
mgcp_response_cb_t response_cb;
void *priv;
};
int mgcp_client_rx(struct mgcp_client *mgcp, struct msgb *msg);
struct mgcp_response_pending * mgcp_client_pending_add(
struct mgcp_client *mgcp,
mgcp_trans_id_t trans_id,
mgcp_response_cb_t response_cb,
void *priv);
#define MGCP_MSG_PRESENCE_ENDPOINT 0x0001
#define MGCP_MSG_PRESENCE_CALL_ID 0x0002
#define MGCP_MSG_PRESENCE_CONN_ID 0x0004
#define MGCP_MSG_PRESENCE_AUDIO_IP 0x0008
#define MGCP_MSG_PRESENCE_AUDIO_PORT 0x0010
#define MGCP_MSG_PRESENCE_CONN_MODE 0x0020
#define MGCP_MSG_PRESENCE_X_OSMO_OSMUX_CID 0x4000
#define MGCP_MSG_PRESENCE_X_OSMO_IGN 0x8000
struct mgcp_msg {
enum mgcp_verb verb;
/* See MGCP_MSG_PRESENCE_* constants */
uint32_t presence;
char endpoint[MGCP_ENDPOINT_MAXLEN];
unsigned int call_id;
char *conn_id;
uint16_t audio_port;
char *audio_ip;
enum mgcp_connection_mode conn_mode;
unsigned int ptime;
struct ptmap ptmap[MGCP_MAX_CODECS];
unsigned int ptmap_len;
uint32_t x_osmo_ign;
bool x_osmo_osmux_use;
int x_osmo_osmux_cid; /* -1 is wildcard */
bool param_present;
struct mgcp_codec_param param;
};
int mgcp_response_parse_params(struct mgcp_response *r);
int mgcp_client_tx(struct mgcp_client *mgcp, struct msgb *msg,
mgcp_response_cb_t response_cb, void *priv);
int mgcp_client_cancel(struct mgcp_client *mgcp, mgcp_trans_id_t trans_id);
struct msgb *mgcp_msg_gen(struct mgcp_client *mgcp, struct mgcp_msg *mgcp_msg);
mgcp_trans_id_t mgcp_msg_trans_id(struct msgb *msg);

View File

@ -0,0 +1,24 @@
#pragma once
#include <stdbool.h>
#include <osmocom/vty/vty.h>
struct mgcp_client;
struct mgcp_client_pool;
struct mgcp_client_pool_member;
struct mgcp_client_pool *mgcp_client_pool_alloc(void *talloc_ctx);
void mgcp_client_pool_vty_init(int parent_node, int mgw_node, const char *indent, struct mgcp_client_pool *pool);
int mgcp_client_pool_config_write(struct vty *vty, const char *indent);
unsigned int mgcp_client_pool_connect(struct mgcp_client_pool *pool);
void mgcp_client_pool_register_single(struct mgcp_client_pool *pool, struct mgcp_client *mgcp_client);
bool mgcp_client_pool_empty(const struct mgcp_client_pool *pool);
struct mgcp_client *mgcp_client_pool_get(struct mgcp_client_pool *pool);
void mgcp_client_pool_put(struct mgcp_client *mgcp_client);
struct mgcp_client_pool_member *mgcp_client_pool_find_member_by_nr(struct mgcp_client_pool *pool, unsigned int nr);
struct mgcp_client *mgcp_client_pool_member_get(struct mgcp_client_pool_member *pool_member);
bool mgcp_client_pool_member_is_blocked(const struct mgcp_client_pool_member *pool_member);

View File

@ -0,0 +1,52 @@
#pragma once
/* Struct to handle a pool of MGWs. (Use _pool functions) */
struct mgcp_client_pool {
/* A pointer to a 'single' mgcp client. This is a non-pooled MGCP client that is configured using
* mgcp_client_vty_init() and actively registered by the API user using mgcp_client_pool_register_single() */
struct mgcp_client *mgcp_client_single;
/* A list that manages the pool members (see mgcp_client_pool_member->list above) */
struct llist_head member_list;
/* String to use for indentation when writing the configuration file to the VTY. This field is populated by
* mgcp_client_pool_vty_init() */
char *vty_indent;
/* VTY node specification used with this pool. This field is populated by mgcp_client_pool_vty_init() */
struct cmd_node *vty_node;
};
/* Struct to handle a member of a pool of MGWs. */
struct mgcp_client_pool_member {
/* Entry in llist mgcp_client_pool->pool. */
struct llist_head list;
/* The pool managing this object: */
struct mgcp_client_pool *pool;
/* Reference number assinged by VTY. This number is used to manage the pool from the VTY and to identify it in
* the log. */
unsigned int nr;
/* MGCP client configuration, this is not the running configuration, when mgcp_client_init() is executed, a
* copy of this config is created. */
struct mgcp_client_conf conf;
/* MGCP client descriptor, will be automatically allocated when mgcp_client_pool_connect() is called. (the MGCP
* client is connected when this pointer is populated) */
struct mgcp_client *client;
/* A pool member may be set as 'blocked' from the VTY, this means that the pool member may still work and serve
* ongoing calls, but it won't be picked from the pool anymore. */
bool blocked;
/* Reference counter to count how often this pool member is currently picked. */
unsigned int refcount;
};
struct mgcp_client_pool_member *mgcp_client_pool_member_alloc(struct mgcp_client_pool *pool, unsigned int nr);
void mgcp_client_pool_member_free(struct mgcp_client_pool_member *pool_member);
int mgcp_client_pool_member_reinit_client(struct mgcp_client_pool_member *pool_member);
const char *mgcp_client_pool_member_name(const struct mgcp_client_pool_member *pool_member);

10
libosmo-mgcp-client.pc.in Normal file
View File

@ -0,0 +1,10 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: Osmocom Media Gateway Control Protocol Client library
Description: C Utility Library
Version: @VERSION@
Libs: -L${libdir} -losmo-mgcp-client
Cflags: -I${includedir}/

Some files were not shown because too many files have changed in this diff Show More