Use `unsigned long long` for SDP session id and version
instead of unsigned int.
Refactor all usage of them accordingly.
Additionally intrdouce new utils functions for conversion:
- `ulonglong2str()` - converts `unsigned long long` to `string`
- `str2ull()` - converts `string` to `unsigned long long`
Change-Id: I4210349a5442d4173b14227497f4a01d68cad7a4
Save SDP origin after a call leg is held.
Successive reinvites in the session version must be incremented
based on hold/resume reinvite and not based on the original SDP origin.
Change-Id: I771778dbc26f329561fd928ec70e17ab644b19be
Increment the sessV each time,
when creating new hold request.
Instead of blindly using `established_body` AmMimeBody,
properly treat the sessV, and keep it updated.
`updateLocalSdp()` stores updated body then as `CallLeg::non_hold_sdp`
Which will be later on used to resume held.
During resume keep sessV incremented, because each time new
SDP offer is sent out, sessV has to be updated.
Change-Id: Ifaa6ead0a36f9fe77e032e64547a490d856c44d6
- remove `hm` type, which used to be a crutch
- only use the `holdMethod` type for hold method detection
(so instead of `hm` used)
- move `holdMethod` from .cpp to .h
- make `CallLeg::hold` to a `enum holdAction` data type
(so this enum can be reused)
- make `CallLeg::hold_method_requested` to a `enum holdType` data type
(so this enum can be reused)
- move the `isHoldRequest()` helper to class methods instead of being static
- rename `hold_method_requested` to `hold_type_requested` to have less
confusion in naming (with `enum holdMethod` for example)
Change-Id: Ib40a9e1c40419d6ffd444b59f92958c893c7f268
This commit affects cases when the on-hold is requested,
and the MoH emulation on the SEMS is additionally used.
Currently regardless the method used by the one who sets the call
on-hold, the answer will be always 'a=sendrecv', which leads to
a premature termination of the call at the RTPEngine
(because RTPEngine takes the 'a=sendrecv' into account and
terminates the call due to no seeing the audio)
We need to make sure, that an originator of the on-hold, is being
answered:
- with the 'a=recvonly', if an originator requests the 'a=sendonly'
method of the on-hold to be used.
- with the 'a=inactive', if an originator requests the 'a=inactive'
method of the on-hold to be used.
And after the on-hold is restored (by 'a=sendrecv'),
make sure to send the SDP answer with the 'a=sendrecv' as well.
Change-Id: I50df81be16a75d9e813484012938e2a94ec422e1
Add a function to the AmSipDialog class interface,
to be able to check whether the OA currently expects an offer.
Use it then in the `CallLeg::updateLocalSdp(AmSdp &sdp)`
Change-Id: I1c4f4364ce13c7b03e22e0f037d19b99245a0be8
Make the `isHoldRequest()` safer in terms of operating
on a given `AmSdp &sdp`, we still don't change anything in
the body, but just checking if the request is a hold one.
Change-Id: I82fa3da1a11c686050dc482106735139b800ff2d
Do not take into account `send_491_on_pending_session_leg`
when processing pending updates for call-pick call scenario.
This is required to let the A side (so caller) be updated,
which in a cascading manner later triggers 200OK sending
towards the call pick-up'er, and further media updates
via re-invite.
`send_491_on_pending_session_leg` is used to prevent
overlapping updates towards the same other leg.
In this situation however, two updates towards the caller
is a proper way to finish the call-pickup, so the media update.
A new header for interaction between SBC<->B2B introduced:
`P-Force-491`, which takes either of values '1' or '0'.
If set to '0' the `send_491_on_pending_session_leg` will always
be ignored by SBC, and hence re-invite will reach the target,
regardless if there has been anyone shortly before.
Change-Id: Iee7d2c6ef38e568e7c57a89358b22be0b1cb0438
We need to take care of cases, when one leg has pending
transaction(s), and an opposite leg triggers media re-negotiations,
which assumes we have to update the first leg as well (the one which
has a pending transaction).
Perviously we used to only support sending a fake 200OK to the one,
who triggered a media attributes re-negotiation, and scheduling
an update for the opposite leg for a later time (as soon as its done
with its own transaction(s) ).
For now we can optionally decide whether:
- to send 200OK to the one who triggers re-INVITE
- to send 491 Pending to the one who triggers re-INVITE
Using the approach with 491, gives a solution to the problem,
when a fake 200OK is sent to the remote side, and ACK after a while
is not matched to any of the existing local transactions.
This can happen in case, we have sent a fake 200OK, but SBC triggers
one more transaction towards the same side (over already existing one).
This behavior leads to a failure when trying to match coming ACK to the fake 200OK.
By default, enabled behavior - generate fake 200OK.
Optionally it's now possible to enable 491 Pending response,
by setting sems.conf option:
- send_491_on_pending_session_leg = 'yes'
Change-Id: I17f41833651eb006666315c1f9a7cfd4c0441f8a
Core in CE is missing currently functions to accept
pending invitations, introduce them from PRO version:
- `acceptPendingInviteB2B()`
- `acceptPendingInvite()`
Additionally:
- add a helper to create fake replies `createFakeReply()`
Change-Id: Icc5be22051f68f269d4b93637f2b3b59498dbd25
Sync the `CallLeg::onB2BReconnect()` with PRO code version,
and add second part of SDP origin manipulation fix.
Change-Id: I7d7558bc88ab91d00bac72a22e1f713afd218233
If there are no timers then it makes no senes to process ticks in real
time. Sleep up to 0.5 seconds in that case. When timers are added we
are immediately woken up through the conditional variable. Only setting
the shutdown flag would not wake up the thread, but a sleep time of half
a second should be an acceptable delay for shutdowns.
Analogous to 695d902841
Change-Id: I37adf078825470af99e6a7755df3d8786d3eeaa6
Signal the sleeping thread through a condition variable whenever a new
event has been added to the queue. We can then process these events
immediately instead of having to wait for the timer to expire.
(The decision to use a separate private mutex and an extra bool value
for the AmCondition class of course is highly questionable, but that's
what we have in the code base for now.)
Change-Id: I78b74f1152e36aa106906e962bc133f15093ea02
Use one method for wheel turning and another separate method for events
processing. This logically separates two indepenent processes.
In the event of the actual sleep time being different from the requested
sleep time, we do the wheel turning based on the number of required
ticks, but run the events processing only once, after the wall clock has
been brought up to date.
Change-Id: Ibbc6571a5a569050647efd1ba595c1fd08918409
We may end up sleeping shorter or longer than the desired sleep time. If
we ended up sleeping shorter, don't advance a tick, and if we ended up
sleeping significantly longer (more than one tick), advance multiple
ticks.
Change-Id: I0be20104e6243c89006367430a3663cc304486b9
Go to sleep even if the sleep time is less than 2 ms. This makes the
math a lot easier and shouldn't have a noticeable impact as this is
a somewhat unnecessary attempt at optimization.
Analogous to 292eb8cf1c
Change-Id: I6d936a4450967dcd76b4647f189aa3f71e5ed7ae
By making the wall_clock private to the timer thread, we force all
externally used timers to use relative timeout values. Amend the timer
class to keep both timeout values for clarity.
The previously existing member `expires` is the absolute timeout, but is
now initially left unset (zero). Instead the given timeout value is put
into the new member `expires_rel` and the absolute timeout is calculated
only once the timer is inserted into the wheel by adding the current
wall clock.
We add an extra getter function for the current wall clock only for
debugging and logging purposes.
This also turns the two expiry timestamps kept in the timer class
protected and private, delegating maintenance to getter and setter
methods.
Change-Id: Ia6baf552a1de94ba64f314e9123df172b45eed85
Remove dependency on AmAppTimer's wall_clock ticks by switching to
direct call of gettimeofday() and converting the internally used time
units to milliseconds instead of the tick-based wall clock time.
Remove ::getLastUpdate() as it's unused.
Change-Id: Ia3a026103b594351c0a6943de67dd94883e30578
Change it into a wrapper that directly calls time() to eliminate the
need of the timer thread to continuously set unix_clock to the current
time. With vDSO the call to time() is sufficiently cheap.
Move constructor to header and remove default empty destructor.
Change-Id: Ib812a993da9340b9ded4fd97c81d762d9452c3ea
If there are no sessions then it makes no senes to process ticks in real
time. Sleep up to 0.5 seconds in that case. When sessions are added we
are immediately woken up through the conditional variable. Only setting
the shutdown flag would not wake up the thread, but a sleep time of half
a second should be an acceptable delay for shutdowns.
Change-Id: I5aa43382248754ff8dec811038998cf636579734
Calculate how many ticks have passed since we were last awake, and
advance next_tick based on the actual time, but in multiples of tick.
Change-Id: I50f9804b1002780fc55358f00ff41d3a73ab854e
Go to sleep even if the sleep time is less than 2 ms. This makes the
math a lot easier and shouldn't have a noticeable impact as this is
a somewhat unnecessary attempt at optimization.
Change-Id: Ibd97c216e529b4e0b2110f81200b649db6ff2764
Extend logging in the `AmSipSubscription::makeSubscription()`
and also refactor code for better readability.
Change-Id: Ibbeb9f8cb7b808bf24685af46ed31c00040913a0
If the leg during the `B2BEvent::B2BTerminateLeg` event
handling turns out to be in the 183/200 faked state,
then handle the leg termination with CANCEL, instead of BYE.
This is because this leg has never seen the real 200OK
response, and hence remains indeed in the early stage.
Change-Id: I4a9d4197a6ea42f1cfbbcdc5fb306c48684e64bf
When outbound PRACK is challanged, SEMS is regenerating
the PRACK to proxy duplicating the proxy socket in the
Route header, with the result of:
Route: <sip:127.0.0.1:5062;lr>,
<sip:127.0.0.1:5062;lr=on;ftag=xyz;leg_b=1;did=f85.d281>,
<sip:127.0.0.1;r2=on;lr=on;ftag=xyz;ngcplb=yes>,
<sip:192.168.178.104;r2=on;lr=on;ftag=xyz;ngcplb=yes>
the duplicate "127.0.0.1:5062" is causing routing
issue on proxy, cause loose_route() function removes
only the first element. Then proxy sends PRACK to
itself.
To avoid that, we make sure is SEMS to do not add
the 'outbound_socket' value in the Route header
if that value already exist in the first position.
Change-Id: Id310144d8e77a99111e199358462496c9dd0495c
For the PRACK transcations (e.g. PRACK/401) update the
remote tag as well as route set.
Scope: `AmSipDialog::onRxReplyStatus()`
Additionally: do not reset remote tag during the authentication
process for PRACK methods, in: `UACAuth::onSipReply()`.
Change-Id: Ibd4e4ee737287bab3883b74a32ded6a966ec62ab
During refreshing of the media for the call leg in the
`CallLeg::adjustOffer()`, when the resume is required,
but the `on_hold` wasn't set before (so is false),
then additionally check, whether the SDP body
(media sessions of `MT_AUDIO` type) has state like:
- sendonly
- recvonly
- inactive
This will properly fix the attributes (like: `a=sendonly`)
in the re-INVITE, which is supposed to resume the session.
Change-Id: I1c45b7db55d2a5174f3fd96f3fcd0201b48345f2
The hiredis library does not provide a direct way
to retrieve the allocated port number.
We hav to retrieve the socket file descriptor (redis_context->fd)
from the `redisContext` structure and using the `getsockname()`
get the local address associated with that socket.
Then the `sin_port` field of the resulting `sockaddr_in` structure
will contain the allocated ephemeral port.
By using `ntohs()`, just convert the port number from network
byte order to host byte order for printing. However make an additional
on-the-go type casting into the `unsigned int` also, to be able to print.
(unsigned int is guaranteed to be at least 16 bits,
so this is not a lossy conversion).
Change-Id: Id2a8e9ee4fad6f28db099323fb68fd2db0bfafc2
This is a partial rework of b67428d.
The patch was always saving the Allow header
from the initial INVITE and replacing the Allow
header in the 200 OK with that.
This fixed an issue with AA, where Allow
header in the 200 OK, generated by the AA, was
empty. But it causes an issue in case of normal
calls between A and B.
In general we want to keep the Allow header in
the 200 OK, if exist.
Instead, we want to add the Allow header in the 200 OK
response in case the 200 OK does not contain
the Allow header. In this case we won't set the
original Allow from the INVITE but instead we will
set a default Allow header (SIP_REPLY_DEFAULT_ALLOW)
containing all the major SIP method.
Change-Id: I6bf5a2cc7e0228f7b99d28963d16c14c463be695
Backport from the upstream to add `lock(mutex)` calls
in order to avoid crash.
Upstream commit: 0af0c924a8fc9638c5b18a4d5799a085ea8132bc
Change-Id: I022b09d2827b41f0785a9c0568c334b8a2af108f
Backport from the upstream to fix NOTIFY to URI.
Upstream commit: c2908dcb50342e3c8400695b43280181a850fc34
Change-Id: Iff9c0d82ab798f4646284de61365422e48c50a59
Backport from the upstream to fix parsing of sip uri,
when display name contains uri scheme characters:
's', 'i', 'p', and ':'
Upstream commit: fe760b5afdb455707ad2ed3ada7f7fbda6b2fd0e
Change-Id: Idf0236ae9ef2be958693d589894d52ea1ed70848