Commit Graph

44 Commits

Author SHA1 Message Date
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
Vadim Yanitskiy 5e178d2c55 sip: fix memory leak (x_gcr) in send_invite()
Change-Id: I6a2e5e15061010f6e62d0f3b0acd2c040dbe3249
Fixes: Id40d7e0fed9356f801b3627c118150055e7232b1
Related: OS#5164
2021-10-27 16:26:57 +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
Neels Hofmeyr e7d05f40ba SIP re-INVITE: log media connection
Change-Id: I2d11be9fe65aa76e044a91f88ba0e9a1d8e756ec
2021-06-01 04:17:49 +02:00
Neels Hofmeyr 0294e38243 SIP re-INVITE: fix media connection change detection
Use the correct variable in address comparison.
The type cast hid the incompatible type from the compiler.

Change-Id: I701150f22f0eb49fae821996358568d60a385035
2021-06-01 04:16:19 +02:00
Pau Espin b6cb607d12 mncc: Support IPv6 addresses (new version mncc 7)
Change-Id: I3b1bebbcc9e36be43d8d055c8d28cbb38ff21b37
2020-09-10 17:08:19 +02:00
Alexander Couzens f678caa819 Revert "sip: Specify invite contact tag"
This reverts commit 52b2afce2c.
The contact header is generated by the original sofia-sip library.
By adding the contact header explicit as user header it violates the
SIP RFC because sofia will add the Contact header to the BYE message as
well.

Let's fix the bugs in the freeswitch sofia-sip and make it compatible
(not bug compatible) with the original sofia-sip.

Change-Id: I712f17fecbc372d1e486e80673a548e281b37800
2020-09-05 23:13:55 +02:00
Matt Johnson 52b2afce2c sip: Specify invite contact tag
Version 1.12.12 of libsofia-sip-ua no longer automatically generates a
contact header element from the local ip address and port. Specifying
the contact tag does not break operation with the existing
library (1.12.11), but allows for operation on a system with
freeswitch 1.10.4 or later installed, which is built against this new
version of libsofia-sip-ua.

Change-Id: I5c35c5a4bad2fbe76c22ac6d7ee37c832e0ba246
2020-08-13 19:31:58 +00:00
Neels Hofmeyr 037c6c1ba8 logging from sofia: add missing newline
Sometimes, logging from sofia lacks the final newline character, messing up log
output. First snprintf() to a buffer, add '\n' if necessary and then log.

Change-Id: Ia26c0b57a0166cf7de87c49471ce6f528a366dd5
2019-12-17 13:52:21 +00: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 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 a2b7c8e29f Define hold/retrieve functions for MO calls
My original patch that introduced this functionality,
bd2d14bd4a
only did so for MT calls.

Change-Id: Ifd42ed94053f6a38abfe6d6b18e2fe3582d037bb
2019-08-06 17:48:37 +00:00
Keith Whyte 5f79d5a319 Fix bug with MO calls not connecting.
Fixes a bug I introduced in 5f73c2033b
where we would not call mncc_call_leg_connect() on receiving 200 from
SIP side, and therefore never send MNCC_SETUP_RSP to the MS

Fixes: 5f73c2033b

Change-Id: Ic7cc56c0d68a27eb1229c0c4aa1fa54d00b660b6
2019-08-06 17:40:17 +00: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 ab5b4311b0 Only send update to MNCC if media info changed.
Do not send an MNCC_RTP_CONNECT as a result of a SIP re-INVITE,
unless the media connection information has changed.

Change-Id: I7c48300092a309e50a8fe091b30e395e7c72de9d
2019-08-05 19:08:42 +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 bd2d14bd4a Prepare to support MO Call HOLD
Add function pointers to the call_leg struct for call hold and retrieve.

Add function to send re-INVITE to SIP side when MNCC side puts call on HOLD/RETRIEVES.

Add MNCC/SIP CC_HOLD to call states.

Change-Id: I2595626dfa50eb2f8e29a02540b708c9c1dce88c
2019-08-05 19:05:43 +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
Keith Whyte f9a2a414ef Add media mode parameter to sdp_create_file()
This enables call hold implemented by subsequent commits

Prior to this commit, osmo-sip-connector would not send
any media mode attribute in the sdp. After this commit
we will by default always include a=sendrecv.

Given that a media mode attribute of "sendrecv" is default
and implicit it its absense, this does not represent any
functional change.

Change-Id: Ib4212d0174955042e7d80d3744ce632a4942ccb2
2019-08-01 09:38:55 +02: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 5b1621bf53 Cosmetic: correct spelling error in logging
Change-Id: I1f323a738f2c8ff21984b574a0ff47fe175e9161
2018-09-04 12:01:22 +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
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 503d8fdb64 Add SIP <-> MNCC Cause Map
Implements a cause_map, mapping the SIP status codes
to GSM48_CC_CAUSE_* that are defined in libosmocore.
The map at the same time implements the Q.850 cause texts
that are subsequently used in the SIP Reason: header.

Implements two functions cause2status() and status2cause()
to read the map and return the the mapped status.

The mapping mostly follows the implemention in the LCR program,
so that any implementation relying on that mapping should
continue to work as expected with osmo-sip-connector.

Change-Id: Id82be8603a30a6aec28fc0258236c1746973db58
2018-08-31 16:22:17 +02:00
Harald Welte 6369f30c4d sip: Register log callback function with sofia-sip
sofia-sip allows applications to register a log backend function
which will be called every time the library wants to log something.

We register such a call-back and make it log using the libosmocore logging
framework.

The problem is that sofia-sip has its own log level management, and by
the time the message hits libosmocore, we don't know which log level we
shall use :(

Change-Id: Ib269b6b50f9d79bbd13acc43a626834921f05edb
Related: OS#3105
2018-04-15 22:12:42 +02: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 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 3d9ae085bf sip: Actually honor the remote port of the pbx
So far the remote_port has never been used. sofia-sip did the right
thing and put the port into the "Contact" and the rport option for
the via. But we would have never been able to connect a PBX on a
different port (as sofia-sip seems to parse the destination from the
to address).

Change-Id: Ifbd49b4aa6b01b118fe67e39dddef50b2946159c
2017-03-23 07:32:04 +00:00
Holger Hans Peter Freyther 14488c1c46 sip: Treat SIP 183 as progress too
It doesn't fix early media yet but brings us one step
closer to it:

   The 183 (Session Progress) response is used to convey information
   about the progress of the call that is not otherwise classified.  The
   Reason-Phrase, header fields, or message body MAY be used to convey
   more details about the call progress.

Change-Id: Ibf264f251e41c06a7b4839acc0d0853e6400291c
2017-02-11 04:53:16 +01: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 2a7cfb5c93 sip/sdp: Hack to get a GSM codec call connected
Extract IP and port once we have received the INVITE. In the near
future we need to improve this!
2016-03-31 16:28:21 +02:00
Holger Hans Peter Freyther 8763cf8850 sip: Pass to not enable media on our 200 response
In case we send a 200 but don't have this tag, a 500 response will
be sent and the call will be dropped.
2016-03-31 16:04:47 +02:00
Holger Hans Peter Freyther 80880d45b7 sip: Refactor sdp file creation and implement alert+connect
The codec negotiation is still a huge todo and the initial version
will be far from perfect. We will use whatever MNCC has decided on
and then see if it is compatible in the end.
2016-03-26 22:11:06 +01:00
Holger Hans Peter Freyther dac13bed50 sip/app: Route call from SIP to MNCC and deal with the release
Fix releasing of the leg in case it is not routable and make the
differentation if we initiated the invite (send CANCEL) or send
a final error. The error code was randomly picked and once we have
an enum of causes we can decide where to map it to.
2016-03-26 21:09:07 +01:00
Holger Hans Peter Freyther 7a30c94030 sip: Continue SIP->MNCC (MO or SIP Originated) implementation
Copy out to/from numbers, copy the sdp file, set the magic for the
nh handle. With the incoming cancel the leg and the entire call will
be terminated.
2016-03-26 20:55:02 +01:00
Holger Hans Peter Freyther 5f29be5acf sip: Actually return after having rejected the new call 2016-03-26 20:30:14 +01:00
Holger Hans Peter Freyther 392313ff73 sdp: Extract SDP traversing into a separate module
The code will still know about SIP and the sip_call_leg but is
now separate of the call handling logic.
2016-03-26 20:02:06 +01:00
Holger Hans Peter Freyther 586abf9f0f sip: Handle incoming message and screen the SDP file
Check if the SDP file has any codec potentially supported by GSM.
The topic of codec selection is a complicated one and we will not
support it correctly in the beginning.
2016-03-26 19:44:03 +01:00
Holger Hans Peter Freyther 6f039c158d sip: Mark call as MT call in preparation for incoming calls 2016-03-26 19:03:04 +01:00
Holger Hans Peter Freyther 989bef0875 app: Translate payload name to IETF codec name
Convert the MNCC codec type to the IETF codec name.
2016-03-26 16:33:15 +01:00
Holger Hans Peter Freyther 2211c3ba56 sip: Implement MT call out to SIP
* Create a new handle
* Send the invite
* Have some state transitions
* Allow to release a call in initial unconfirmed state, confirmed
one with cancel and connected with bye
* Add simple SDP parsing to find the rtpmap/codec that is used by
gsm
2016-03-26 06:22:06 +01:00
Holger Hans Peter Freyther 2e36090fea sip: Tell sofia-sip that we will ack certain things ourselves
This has not tested re-transmission and if a call is connected
multiple times or not.
2016-03-26 06:22:06 +01:00
Holger Hans Peter Freyther 90881b6a5a sip: Introduce source file to setup sofia sip
This code is capable of creating an agent that will bind on the
configured local address. The next steps are to configure the
library in terms of allowed features and prepare call handling.
2016-03-22 16:32:48 +01:00