Commit Graph

75 Commits

Author SHA1 Message Date
Vadim Yanitskiy bd66804082 mncc: rework passing GCR over the MNCC interface
Using *unpacked* 'struct osmo_gcr_parsed' in the MNCC PDUs makes
the protocol even more complicated than it currently is, and
moreover complicates implementing MNCCv8 in the ttcn3-sip-test.

Replace 'struct osmo_gcr_parsed' in 'struct gsm_mncc' with a
fixed-length buffer, which is supposed to hold the Global Call
Reference encoded as per 3GPP TS 29.205.

Check / indicate presence of GCR using the MNCC_F_GCR flag.

Change-Id: Iaff46732948f8f5d03e42f17c35cbac8a80af49b
Fixes: Id40d7e0fed9356f801b3627c118150055e7232b1
Related: OS#5164, OS#5282
2021-10-27 17:03:42 +03:00
Vadim Yanitskiy f3eb44f54b sip: use osmo_{enc,dec}_gcr() from libosmocore
Change-Id: I46fa46fc79494d337f2f4657215b91c39207eea4
Depends: I06babb959fdc82f4e82d92260131d60c98b0abd2
Fixes: Id40d7e0fed9356f801b3627c118150055e7232b1
Related: OS#5164
2021-10-27 16:46:00 +03:00
Keith Whyte 364f237b42 MNCC v8: Implement Basic Support for Global Call Reference.
* Add GCR to mncc struct and therefore bump mncc version.
* Pass the GCR as a SIP Header to SIP UA and retrieve any such header
  from incoming SIP calls, passing the GCR on to MNCC

Related: #OS5164
Depends: osmo-msc I705c860e51637b4537cad65a330ecbaaca96dd5b
Change-Id: Id40d7e0fed9356f801b3627c118150055e7232b1
2021-10-05 20:30:16 +00:00
Pau Espin Pedrol 9484ad9a87 mncc: Fix write len
Fixes bug introduced recently.

Closes: OS#4957
Fixes: 0f27b1bd39
Change-Id: Ibbff004e2b76fbfe8962d14628c916afb19f30e6
2021-02-02 16:32:55 +00:00
Pau Espin Pedrol 462ec86ff3 mncc: Log write error code
Change-Id: If7b49bee6fec3a188c978c0606c524776a577927
2021-02-02 16:41:44 +01:00
Alexander Couzens 1bd26902d2 mncc: mncc_create_remote_leg: use mncc_write instead of write direct to the fd
Change-Id: I870c16d7ee5e5424304f3c1c9fb78af418ae2577
2021-01-14 21:27:55 +01:00
Alexander Couzens 0f27b1bd39 mncc: Introduce mncc_rtp_write similiar to mncc_write
Concentrate the write() to the socket in 2 places.
One for struct gsm_mncc and one for struct gsm_mncc_rtp.
Improve debugging as now all function debug print the
MNCC primitiv.

Change-Id: Ia84602955b913a3bb13de7a6a92048799f2e1955
2021-01-14 21:27:50 +01:00
Alexander Couzens ef646b07e2 mncc: add return code for write/send function
Allow to get errors back for the caller to clean up state.

Change-Id: Ic926d192c238ef84fb3ad2be27e507e010b0e93f
2021-01-14 03:41:34 +01:00
Alexander Couzens 3b95463d09 mncc: remove callref argument from mncc_write()
The callref is always included in the struct mncc argument.

Change-Id: Ia156010194c1f4334a4966d01aadfd02fa7097a8
2021-01-14 03:41:34 +01:00
Pau Espin b6cb607d12 mncc: Support IPv6 addresses (new version mncc 7)
Change-Id: I3b1bebbcc9e36be43d8d055c8d28cbb38ff21b37
2020-09-10 17:08:19 +02:00
Oliver Smith b544ea396a mncc.c: fix gsm_mncc_rtp size checks
Verify is the parsed data is at least the size of the struct, not
exactly the size. Make it accept messages with additional data, like
the SDP information the TTCN-3 testsuite is sending since
Ic9568c8927507e161aadfad1a4d20aa896d8ae30.

This change makes the size checks consistent with the two other size
checks in the file:
	if (rc < sizeof(*rtp)) {
	if (rc < sizeof(**mncc)) {

Related: OS#4282
Change-Id: I522ce7f206932a816a64f03d916799c3215bb8c7
2019-11-28 15:11:33 +01:00
Philipp Maier e49a3d714c mncc: check fd before closing a connection
The function close_connection() closes the fd without marking it as
closed. Lets set the fd to -1 and check at the beginning if it is
greater than zero. This prevents us from closing an already closed fd
again.

Related: OS#4159
Change-Id: I9742f31a37296fed15d54cf44c1f65b93abb8c8e
2019-09-02 14:23:36 +02:00
Keith Whyte 5319d4d979 coverity: Address issue found by coverity
Add NULL checks on the return value of call_leg_other() in
update_rtp()

If the remote side has requested media change and we cannot
find the other leg, then release call. This should not
happen.

Also, Add an assert to show that we cannot be here
without call type of SIP or MNCC (not related to coverity)

Fixes: CID#202863
Change-Id: I6f1f26533a25c93f243090bc02f1bc83b9108d42
2019-08-09 14:12:32 +02:00
Keith Whyte eb0a93e037 In hold/retrieve/reinvite, add check that other_leg exists
We should always check that the other leg did not somehow
dissapear before accessing it.

Change-Id: I947aab6c0cc5019929bde1c7012e1a8c3d3472a5
2019-08-07 13:10:51 +02:00
Keith Whyte b43c296f19 Logging: Make use of Levels, clarify some messages
Up to now most logging is on LDEBUG, lets make more use of Log Levels.
reserve NOTICE for unusual events
INFO: normal call setup/teardown
DEBUG, well.. it's DEBUG

* BYE is not an Error.
* 4XX or 5XX response to INVITE is not an Error don't log as such.
* 183 does not necessarily mean "ringing".
Change those log messages for clarity.

Change-Id: Ie0014043d93303a87cbb8bb351e439ff78651cbe
2019-08-07 13:09:44 +02:00
Keith Whyte f9a0f3af42 Handle case where SIP side hangsup while MNCC is on hold
Change-Id: Ie32690e036180e6b80a1b59177c1a72a6fd78d15
2019-08-07 02:16:07 +02:00
Keith Whyte 5311868c26 Cosmetic: Logging and Comments, spelling and clarity changes
Also removes a comment in sdp_create_file() about the
IP address in o= and c= having to be the same.
It is completely legal in SDP and often normal for the
originator and the connection information IP to be different.

Change-Id: I057573467c335fc27ead391c0bb4c775f2f6ba0a
2019-08-07 02:16:07 +02:00
Keith Whyte a5b65505f9 inet_ntoa() is deprecated, use inet_ntop() instead
Change-Id: If6a96ede7d5e73884c32fbfdb03052e2bda50a77
2019-08-06 16:53:29 +02:00
Keith Whyte 1f1f3f6fb9 IPs stored in the call struct are NETWORK byte order
As far as I can make out, the intention is to always store ip address in the call struct
in network byte order, whereas the ip address sent on MNCC are in host byte order.

Change-Id: I89ef26aa32a672f394699251cf560b53ae01a814
2019-08-06 14:38:32 +02:00
Keith Whyte ba7450cf26 Add support for MNCC HOLD/RETRIEVE
Handle MO hold and retrieve and pass this to the SIP side.

Handle the 200 from the SIP side in response to our HOLD-ing re-INVITE.

With this commit we now handle MO hold and therefore also handle
call-waiting and swapping.

Change-Id: Ife7bdab20cde92b7ce550215bab28b36a0f302e9
2019-08-05 19:08:34 +02:00
Keith Whyte 5f73c2033b Handle SIP re-INVITEs
SIP end points can send periodic re-INVITES. Previous to this commit,
the osmo-sip-connector would send a new call SETUP to the MSC for each
re-INVITE.

Add a function to find if we already handle this call based on the nua handle.
Use this function to detect and respond with an ACK to re-INVITES.

Add a function to extract the media mode from the SDP.
In the case the re-INVITE has a=sendonly (HOLD) respond with a=recvonly

In the case that the re-INVITE changes the media connection ip/port,
forward this to the MNCC side with an MNCC_RTP_CONNECT

Change-Id: I4083ed50d0cf1b302b80354fe0c2b73fc6e14fed
2019-08-05 19:05:40 +02:00
Harald Welte 73f99bc442 MNCC: Do not continue with B leg if A leg is cancelled.
In case we receive MNCC_RTP_CREATE after MNCC_DISC_IND,
check if the call is already marked in_release
and if so, send MNCC_REJ_REQ and do not proceed with
the B leg.

Related: OS#3518
Change-Id: I0eca9a741f7924c2fc32c503dd1a0fc083f94f37
2019-04-21 08:03:38 +00:00
Keith Whyte c90829c395 Support Emergency Calling
LCR supports emergency calling by sending the string 'emergency' as callee to
the SIP side.

This does the same

Change-Id: I5d0adb61dfa82e7ded5f41d9bc773d546112c9f1
2019-03-19 16:25:35 +00:00
Harald Welte e9113f21f6 cosmetic: use OSMO_STRLCPY_ARRAY() instead of osmo_strlcpy()
This saves us the extra sizeof().

Change-Id: If329f122017c0c5b5222e46d55f39731c5bdf662
2019-02-14 22:52:21 +01:00
Keith Whyte db2336a9f5 Support International Caller ID
When the SIP call source contains + as first character,
set the TON to International so that the MS displays
caller ID correctly

Change-Id: Idcfa31aff90e04dd0aa3583957f288889b1bbefe
2019-02-14 22:51:58 +01:00
Keith Whyte 8c0f6d2f75 Allow GSM340_PLAN_UNKNOWN on MNCC originated leg.
Allows dialing of numbers with GSM340_PLAN_UNKNOWN,
for example a number beginning with '*'

Change-Id: I8d71cac5b169e3b19675b9b9626e6993f3acd979
2018-11-12 17:07:06 +01:00
Keith Whyte d195c09228 Logging: Further use of osmo_mncc_name() in logging
Use osmo_mncc_name() in timer functions and in logging
the type of MNCC message sent to the socket.

Change-Id: Ic77e0d86c91c29ff7304e620fdecb69b22127d33
2018-10-02 13:24:53 +01:00
Keith Whyte cddf0d175e Log using GSM48 Cause Value strings
Use gsm48_cc_cause_name() in logging messages

Depends-On: I296f208581ce2550805f9d96e20f7319e1199023
Change-Id: I6e3541b66cb3407f0cb23fb6e00a04685fe90757
2018-09-04 12:02:18 +02:00
Keith Whyte 741c51bb61 Logging: Add debug logging for status/causes
Adds some DEBUG level logging for SIP status and MNCC causes.

Change-Id: Ib56e34ba079c7927e932c1b29d3e8341b8099ae0
2018-09-04 12:01:22 +02:00
Pau Espin 87b19a06d7 mncc: Fix missing conditional clause
Fixes following compilation warning:
osmo-sip-connector/src/mncc.c: In function ‘check_disc_ind’:
osmo-sip-connector/src/mncc.c:517:2: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
  if (other_leg)
  ^~

Fixes: 008915ee41 ("Implement Cause Mapping")

Change-Id: I5bdbc29a3f82bdc92b156c1f7df68c9503f85f8f
2018-09-03 11:30:42 +02:00
Keith Whyte 008915ee41 Implement Cause Mapping
Adds cause field to the call_leg and sip_call_leg structs.

Translates the SIP status to MNCC cause and vice versa and
uses this information in the SIP/MNCC messages at call leg
release time.

Change-Id: Ic1b80dff7e583cd6fff2b662bc6cc4bad3f81cd4
2018-08-31 19:11:45 +02:00
Keith Whyte 0cfe4763a4 Logging: Log RTP IP in dotted quad format.
in check_rtp_create() log the IP address in
human readable dotted quad format.

Change-Id: I298b13836cc6b9c5888f931deca61132d31da035
2018-08-28 07:18:26 -04:00
Keith Whyte 6d398fea1d Add Cause to DISCONNECT and RELEASE Requests
GSM 04.08 10.5.4.11 (Table 10.85) states:

Coding standards other than the standard defined for the
GSM PLMNS shall not be used if the cause can be represented
with the GSM standardized coding.

This patch adds cause coding GSM PLMS (3) and sets cause
location to  "public network serving the local user" (2)
This prevents UE that pay attention to this from treating
all call termination as an error and paves the way to
adding correct cause mapping from Table 10.86

Also replaces use of magic numbers with enum constants.

Change-Id: I5d3fe3f0c9e8de26dd0c73b10b7e4fc63dff3952
2018-05-28 15:20:26 +00:00
Keith Whyte 911d4d5e15 Logging: Log mncc_names in mncc_data()
Links libosmocore (libosmogsm) for access to osmo_mncc_name()

Remove reference to get_mncc_name() in src/mncc_protocol.h
Uses osmo_mncc_name() to output to debug log
which MNCC_* message was received.

Change-Id: I161d1b841ac5fe1b7e092b329ae0674cb340f5ac
2018-05-24 16:56:41 +02:00
Harald Welte fd203f6a97 mncc: use 'const' to denote read-only input buffer/message
We normally use the 'const' modifier whenever using read-only input
data, let's do so in the mncc parser/handler, too.

Change-Id: Ide24feb536c04fe7ef08c62b4498fdd95605b58c
2018-03-19 10:03:26 +01:00
Harald Welte 05cd0f2628 comments
Change-Id: Icf0e9211a4e93eb1b05b5a5d68f9ba766982da8d
2018-03-19 10:00:01 +01:00
Harald Welte 4954fee4c6 mncc.c: Ensure proper string buffer NUL termination
Change-Id: I2f58a495f60ed744c1f625dc8df56aa4dc0aa4cb
Fixes: Coverity CID#92223
2017-11-07 20:55:12 +00:00
Holger Hans Peter Freyther 417f254216 mncc/sip: Attempt to parse the media from session in progress
Parse the media from session in progress and if present in alerting
connect the call early. Sadly this sets RTP to the sendrecv mode even
if we would like to keep it as recvonly.

Change-Id: I98d173abc46c67b87666ed2f193a581d6e72344b
Related: OS#1784
2017-03-23 09:01:45 +00:00
Holger Hans Peter Freyther 9d796ff156 mncc: Enable in-band signalling for early media
Besides sending the alerting request we should inform the
MS that there is in-band information now. We do not seem
to export these flags in protocol/gsm_04_08.h so hardcode
them for now (until I come up with good names for them).

Related: OS#1784

Change-Id: I80b1e1f4ca045bd63536476702a5812f27d9b36d
2017-03-23 09:01:14 +00:00
Holger Hans Peter Freyther 4649746798 dtmf: Forward DTMF from MNCC to SIP
We are not using the RTP telephony-event here but the older dtmf
relay. We also only have a fixed DTMF duration for now.

Change-Id: Icf770fae89f7aedf6eba9a119db9b8acc7f938df
2017-03-23 09:00:24 +00:00
Holger Hans Peter Freyther 62f50f5297 dtmf: Start handling the DTMF MNCC messages and respond
Simply respond to the dtmf start/stop with a response
and move on.

Change-Id: Iffc92ea2112c9943ce89c244a9b323125c352ae5
2017-03-23 07:30:17 +00:00
Holger Hans Peter Freyther d1c11b1e97 vty: Add VTY command about the state of the mncc connection
Add VTY command with the state of the MNCC connection. It gives
a simple state and is connected in case of the READY state.
2016-04-04 20:17:29 +02:00
Holger Hans Peter Freyther 02b19354e4 mncc: Use strcpy for these routines and not memcpy
We need to stop on the first occurence of a \0 in the address
provided by SIP. Do not copy the full amount of bytes.
2016-04-04 20:16:27 +02:00
Holger Hans Peter Freyther 211ad859de sip/call/mncc: Move source/dest into the call structure
In preparation of a better show calls VTY command it is of interest
to know which number has been dialed by whom. For that store the
source/dest in there.

MNCC: Change the talloc root context to the call and don't try to
free the strings after calling the routing code

SIP: Use talloc_strdup to duplicate them.

Call: Add null check because the talloc_strdup of the SIP layer
could have failed.
2016-04-04 19:52:41 +02:00
Holger Hans Peter Freyther b2b13f69ae mncc: Use snprintf correctly create format specifier
I was focusing so much on the length that I didn't notice the
wrong usage of snprintf. Correct it.

Warning on Ubuntu:
mncc.c:679:3: warning: format not a string literal and no format arguments [-Wformat-security]
   snprintf(mncc.imsi, 15, called);
2016-04-04 16:26:50 +02:00
Holger Hans Peter Freyther 270c73c11f mncc: Reject hold requests for now
MNCC hold to sip has not been implemented, so let me reject the
request right now. A ticket (OS#1686) has been filed to track
implementing call holding.
2016-04-04 12:38:10 +02:00
Holger Hans Peter Freyther 6d7d7f2cd3 mncc: Have all release go through a local method
Have all release go through a local method first. This way we can
make sure to stop the timer. I have seen something odd (a busy loop
in the RB tree of the timer code) and we can easily avoid having a
timer run on a page of memory that has been "freed".
2016-04-04 12:38:01 +02:00
Holger Hans Peter Freyther c313ab0f6b mncc: Only copy 15 chars to leave the last one as NULL
Right now we are lucky the next byte after imsi is already set
to NUL here but we should not rely on that.
2016-04-01 15:42:41 +02:00
Holger Hans Peter Freyther 3d2787646b app/mncc: Add "use-imsi" to allow calling by IMSI
In case one is using a PBX it might be the easiest just to
call based on IMSI. Add a VTY option to enable/disable this
feature. It can be used to keep the number assignment outside
of the HLR database.
2016-04-01 15:35:29 +02:00
Holger Hans Peter Freyther bec32eb207 coverity: Address two issues found by coverity
Add NULL check in the case of MNCC disconnect that was missing and
add an assert to show that at this point the other leg must exist.

Fixes: CID#80799, CID#80800, 80801
2016-03-31 19:36:27 +02:00