Commit Graph

65 Commits

Author SHA1 Message Date
Oliver Smith 0e444f09cf WIP: mncc.c: remove "gsm_mncc of wrong size" check
Change-Id: I5267bae965f069f2372fb14ce49b9b0d23e6fa8e
2019-11-28 12:51:08 +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
Holger Hans Peter Freyther c2474dc0be mncc: Add handling to connect a MNCC MT call
This will go through the stage of:

* MNCC_CALL_CONF_IND (to which we create a RTP socket)
* then we might receive a MNCC_ALERT_IND
* and finally the MNCC_SETUP_CNF

For the last two we inform the other leg about the progress.
2016-03-31 16:06:04 +02:00
Holger Hans Peter Freyther 275571ff20 mncc: Introduce direction and start to handle it separetely
For releasing a MT-Call we will need to send a release request
and then wait for the release confirmation. Add if/else to it.
If this turns out to be too ugly we will be able to create one
MO and one MT leg.
2016-03-31 14:17:58 +02:00
Holger Hans Peter Freyther 4bfaf60ed2 mncc: Convert ip address so BTS sends it to the right place 2016-03-31 14:17:33 +02:00
Holger Hans Peter Freyther b8e802851d mncc: Handle REJ_IND from the NITB
In case a call can not be connected we will receive a REJ.IND.
Inform the other leg and release the call.
2016-03-27 17:05:48 +02:00
Holger Hans Peter Freyther a4970327f2 mncc: Stop timer when starting the release process 2016-03-27 17:05:48 +02:00
Holger Hans Peter Freyther 00a43e20ab mncc: On timeout release the other leg as well
In case we don't receive the response we had expected let us
take down the other part of the call as well.
2016-03-27 17:05:48 +02:00
Holger Hans Peter Freyther 916348b7dc mncc: Begin to implement MT call handling for SIP->MNCC
Initiate the setup request that should result in the call getting
all the way to the connected state at some point in time. The device
I test with sadly rejects the call too soon.
2016-03-27 17:02:39 +02:00
Holger Hans Peter Freyther b927a0bbde call: It is call_create and not sip_create
It is not creating anything related to sip at all. Remove the
prefix in preparation to creating a call from a sip_call_leg.
2016-03-26 18:52:22 +01:00
Holger Hans Peter Freyther 71fbe870d8 mncc: In case of a disconnect.ind inform the other leg
In case the call got disconnected propagate it to the other leg
of the call.
2016-03-26 06:22:06 +01:00
Holger Hans Peter Freyther d3d8348c62 mncc: Send RTP_CONNECT and verify connect result
The current code can not deal with two outstanding commands. Let's
assume the user will hang up if the voice connection will fail and
we will add a general RTP_CONNECT check to tearn down a call.
2016-03-26 06:22:06 +01:00