summaryrefslogtreecommitdiff
path: root/res/res_pjsip_session.c
AgeCommit message (Collapse)Author
2016-08-17res_pjsip_session.c: Fix unbound srv failover tests.Richard Mudgett
Commit 1b666549f33d69dc080b212bf92126f3bc3a18b2 broke the srv failover functionality if a TCP connection gets disconnected. Under these conditions, session_inv_on_state_changed() gets a PJSIP_EVENT_TRANSPORT_ERROR and restarts the INVITE transaction on a new transport. Unfortunately, session_inv_on_tsx_state_changed() also gets the same PJSIP_EVENT_TRANSPORT_ERROR event and unconditionally terminates the session. * Made session_inv_on_tsx_state_changed() complete terminating the session on PJSIP_EVENT_TRANSPORT_ERROR only if the session state is still PJSIP_INV_STATE_DISCONNECTED. ASTERISK-26305 #close Reported by: Richard Mudgett Change-Id: If736e766b5c55b970fa38ca6c8a885caf27b897d
2016-08-10pjsip: Fix deadlock with suspend taskprocessor on masqueradeAlexei Gradinari
If both channels which should be masqueraded are in the same serializer: 1st channel will be locked waiting condition 'complete' 2nd channel will be locked waiting condition 'suspended' On heavy load system a chance that both channels will be in the same serializer 'pjsip/distibutor' is very high. To reproduce compile res_pjsip/pjsip_distributor.c with DISTRIBUTOR_POOL_SIZE=1 Steps to reproduce: 1. Party A calls Party B (bridged call 'AB') 2. Party B places Party A on hold 3. Party B calls Voicemail app (non-bridged call 'BV') 4. Party B attended transfers Party A to voicemail using REFER. 5. When asterisk masquerades calls 'AB' and 'BV', a deadlock is happened. This patch adds a suspension indicator to the taskprocessor. When a session suspends/unsuspends the serializer it sets the indicator to the appropriate state. The session checks the suspension indicator before suspend the serializer. ASTERISK-26145 #close Change-Id: Iaaebee60013a58c942ba47b1b4930a63e686663b
2016-07-06res/res_pjsip_session: Check for presence of an active negotiatorMatt Jordan
It is possible in a hypothetical situation for a session refresh to be invoked on a PJSIP when the negotiatior on the INVITE session has not yet been established. While this shouldn't occur with existing uses of ast_sip_session_refresh, the crashes that occur due to improperly calling PJSIP functions that expect a non-NULL negotiatior are avoidable. PJSIP will create the negotiator in pjsip_inv_reinvite; this means that simply checking for the presence of the negotiator before passing it to other PJSIP functions that use it is allowable. As such, this patch adds checks for the presence of the negotiator before calling PJSIP functions that assume it is non-NULL. Change-Id: I1028323e7e01b0a531865e5412a71b6f6ec4276d
2016-06-30res_pjsip_session.c: Don't send extra BYE if SDP invalid.Richard Mudgett
When an answer SDP is invalid we were disconnecting the outgoing call and sending two BYE requests. The first BYE was sent by PJPROJECT because of the invalid SDP answer. The second BYE was sent by Asterisk because it thought the canceled call was the result of the RFC5407 section 3.1.2 race condition. * Made not send the BYE on a canceled session if the SDP negotiation is incomplete because PJPROJECT has already sent a BYE for the failed negotiation. ASTERISK-25772 #close Reported by: Dmitriy Serov Change-Id: I44ad0bd0605e8eeb7035c890d6f97a1331f1a836
2016-06-30res_pjsip_session.c: End call on initial invalid SDP negotiation.Richard Mudgett
When an incoming call defers SDP negotiation and then sends us an invalid SDP in the ACK, we need to send a BYE to disconnect the call. In this case SDP negotiation has failed and we don't have valid media streams negotiated. ASTERISK-25772 Change-Id: Ia358516b0fc1e6c4c139b78246f10b9da7a2dfb8
2016-06-30res_pjsip_session.c: Remove unused parameter from handle_incoming().Richard Mudgett
Change-Id: Iedd182d189ec947c42edc2c66c4bda3c22060daa
2016-06-30res_pjsip: Add missing NULL checks when using pjsip_inv_end_session().Richard Mudgett
pjsip_inv_end_session() is documented as being able to return the passed in tdata parameter set to NULL on success. Change-Id: I09d53725c49b7183c41bfa1be3ff225f3a8d3047
2016-06-20res_pjsip_session: Handle race condition at shutdown with timer.Joshua Colp
When shutting down res_pjsip_session will get unloaded before res_pjsip. The act of unloading unregisters all the PJSIP services and sets their module IDs to -1. In some cases it is possible for a timer to occur after this happens which calls into res_pjsip_session. The res_pjsip_session module can then try to get the session from the INVITE session using the module ID. Since the module ID is now -1 this fails. This change stores a copy of the module ID and uses it for the timer callback scenario. If the module ID is -1 the callback immediately returns but if the module ID is valid then it continues as normal. This works as the original ID of the module is guaranteed to still be valid when used with the INVITE session. ASTERISK-26127 #close Change-Id: I88df72525c4e9ef9f19c13aedddd3ac4a335c573
2016-06-10res_pjsip_session.c: Reorganize ast_sip_session_terminate().Richard Mudgett
Change-Id: I68a2128bcba4830985d2d441e70dfd1ac5bd712b
2016-06-07res_pjsip_session: Use distributor serializer for incoming calls.Richard Mudgett
We must continue using the serializer that the original INVITE came in on for the dialog. There may be retransmissions already enqueued in the original serializer that can result in reentrancy and message sequencing problems. Outgoing call legs create the pjsip/outsess/<endpoint> serializers for their dialogs. ASTERISK-26088 Reported by: Richard Mudgett Change-Id: I24d7948749c582b8045d5389ba3f6588508adbbc
2016-04-05res_pjsip: Handle deferred SDP hold/unhold properly.Mark Michelson
Some SIP devices indicate hold/unhold using deferred SDP reinvites. In other words, they provide no SDP in the reinvite. A typical transaction that starts hold might look something like this: * Device sends reinvite with no SDP * Asterisk sends 200 OK with SDP indicating sendrecv on streams. * Device sends ACK with SDP indicating sendonly on streams. At this point, PJMedia's SDP negotiator saves Asterisk's local state as being recvonly. Now, when the device attempts to unhold, it again uses a deferred SDP reinvite, so we end up doing the following: * Device sends reinvite with no SDP * Asterisk sends 200 OK with SDP indicating recvonly on streams * Device sends ACK with SDP indicating sendonly on streams The problem here is that Asterisk offered recvonly, and by RFC 3264's rules, if an offer is recvonly, the answer has to be sendonly. The result is that the device is not taken off hold. What is supposed to happen is that Asterisk should indicate sendrecv in the 200 OK that it sends. This way, the device has the freedom to indicate sendrecv if it wants the stream taken off hold, or it can continue to respond with sendonly if the purpose of the reinvite was something else (like a session timer refresher). The fix here is to alter the SDP negotiator's state when we receive a reinvite with no SDP. If the negotiator's state is currently in the recvonly or inactive state, then we alter our local state to be sendrecv. This way, we allow the device to indicate the stream state as desired. ASTERISK-25854 #close Reported by Robert McGilvray Change-Id: I7615737276165eef3a593038413d936247dcc6ed
2016-03-03res_pjsip_caller_id: Anonymize 'From' when caller id presentation is prohibitedGeorge Joseph
Per RFC3325, the 'From' header is now anonymized on outgoing calls when caller id presentation is prohibited. TID = trust_id_outbound PRO = Set(CALLERID(pres)=prohib) USR = endpoint/from_user DOM = endpoint/from_domain PAI = YES(privacy=off), NO(not sent), PRI(privacy=full) (assumes send_pai=yes) Conditions |Result --------------------|---------------------------------------------------- TID PRO USR DOM |PAI FROM --------------------|---------------------------------------------------- Y Y abc def.ghi |PRI "Anonymous" <sip:abc@def.ghi> Y Y abc |PRI "Anonymous" <sip:abc@anonymous.invalid> Y Y def.ghi |PRI "Anonymous" <sip:anonymous@def.ghi> Y Y |PRI "Anonymous" <sip:anonymous@anonymous.invalid> Y N abc def.ghi |YES <sip:abc@def.ghi> Y N abc |YES <sip:abc@<ip_address>> Y N def.ghi |YES "Caller Name" <sip:<caller_exten>@def.ghi> Y N |YES "Caller Name" <sip:<caller_exten>@<ip_address>> N Y abc def.ghi |NO "Anonymous" <sip:abc@def.ghi> N Y abc |NO "Anonymous" <sip:abc@anonymous.invalid> N Y def.ghi |NO "Anonymous" <sip:anonymous@def.ghi> N Y |NO "Anonymous" <sip:anonymous@anonymous.invalid> N N abc def.ghi |YES <sip:abc@def.ghi> N N abc |YES <sip:abc@<ip_address>> N N def.ghi |YES "Caller Name" <sip:<caller_exten>@def.ghi> N N |YES "Caller Name" <sip:<caller_exten>@<ip_address>> ASTERISK-25791 #close Reported-by: Anthony Messina Change-Id: I2c82a5ca1413c2c00fb62ea95b0ae8e97af54dc9
2016-02-19res_pjsip/config_transport: Allow reloading transports.George Joseph
The 'reload' mechanism actually involves closing the underlying socket and calling the appropriate udp, tcp or tls start functions again. Only outbound_registration, pubsub and session needed work to reset the transport before sending requests to insure that the pjsip transport didn't get pulled out from under them. In my testing, no calls were dropped when a transport was changed for any of the 3 transport types even if ip addresses or ports were changed. To be on the safe side however, a new transport option was added (allow_reload) which defaults to 'no'. Unless it's explicitly set to 'yes' for a transport, changes to that transport will be ignored on a reload of res_pjsip. This should preserve the current behavior. Change-Id: I5e759850e25958117d4c02f62ceb7244d7ec9edf
2016-02-08res_pjsip: Fix infinite recursion when loading transports from realtimeGeorge Joseph
Attempting to load a transport from realtime was forcing asterisk into an infinite recursion loop. The first thing transport_apply did was to do a sorcery retrieve by id for an existing transport of the same name. For files, this just returns the previous object from res_sorcery_config's internal container, if any. For realtime, the res_sourcery_realtime driver looks in the database and finds the existing row but now it has to rehydrate it into a sorcery object which means calling... transport_apply. And so it goes. The main issue with loading from realtime (apart from the loop) was that transport stores structures and pointers directly in the ast_sip_transport structure instead of the separate ast_transport_state structure. This patch separates those items into the ast_sip_transport_state structure. The pattern is roughly the same as res_pjsip_outbound_registration. Although all current usages of ast_sip_transport and ast_sip_transport_state were modified to use the new ast_sip_get_transport_state API, the original items are left in ast_sip_transport and kept updated to maintain ABI compatability for third-party modules. They are marked as deprecated and noted that they're now in ast_sip_transport_state. ASTERISK-25606 #close Reported-by: Martin Moučka Change-Id: Ic7a836ea8e786e8def51fe3f8cce855ea54f5f19
2016-01-08res_pjsip: Create human friendly serializer names.Richard Mudgett
PJSIP name formats: pjsip/aor/<aor>-<seq> -- registrar thread pool serializer pjsip/default-<seq> -- default thread pool serializer pjsip/messaging -- messaging thread pool serializer pjsip/outreg/<registration>-<seq> -- outbound registration thread pool serializer pjsip/pubsub/<endpoint>-<seq> -- pubsub thread pool serializer pjsip/refer/<endpoint>-<seq> -- REFER thread pool serializer pjsip/session/<endpoint>-<seq> -- session thread pool serializer pjsip/websocket-<seq> -- websocket thread pool serializer Change-Id: Iff9df8da3ddae1132cb2ef65f64df0c465c5e084
2015-09-09pjsip: avoid possible crash req_caps allocation failureScott Griepentrog
Make certain that the pjsip session has not failed to allocate the format capabilities structure, which can otherwise cause a crash when referenced. ASTERISK-25323 Change-Id: I602790ba12714741165e441cc64a3ecde4cb5750
2015-08-28res_pjsip_sdp_rtp: Fix multiple keepalive scheduled items.Joshua Colp
The keepalive support in res_pjsip_sdp_rtp currently assumes that a stream will only be negotiated once. This is false. If the stream is replaced and later added back it can be negotiated again causing multiple keepalive scheduled items to exist. This change explicitly deletes the existing keepalive scheduled item before adding the new one. The res_pjsip_sdp_rtp module also does not stop RTP keepalives or timeout timer if the stream has been replaced. This change adds a callback to the session media interface to allow a media stream to be stopped without the resources being destroyed. This allows the scheduled items and RTP to be stopped when the stream no longer exists. ASTERISK-25356 #close Change-Id: Ibe6a7cc0927c87326fd5f1c0d4ad889dbfbea1de
2015-08-28Merge "res_pjsip_session: Don't invoke session supplements twice for BYE ↵Mark Michelson
requests." into 13
2015-08-27res_pjsip_session: Don't invoke session supplements twice for BYE requests.Joshua Colp
When a BYE request is received the PJSIP invite session implementation creates and sends a 200 OK response before we are aware of it. This causes the INVITE session state callback to be called into and ultimately the session supplements run on the BYE request. Once this response has been sent the normal transaction state callback is invoked which invokes the session supplements on the BYE request again. This can be problematic in particular with res_pjsip_rfc3326 as it may attempt to update the hangup cause code on the channel while it is in the process of being hung up. This change makes it so the session supplements are only invoked once by the INVITE session state callback. ASTERISK-25318 #close Change-Id: I69c17df55ccbb61ef779ac38cc8c6b411376c19a
2015-08-25res_pjsip: Add common ast_sip_get_host_ip API.Joshua Colp
Modules commonly used the pj_gethostip function for retrieving the IP address of the host. This function does not cache the result and may result in a DNS lookup occurring, or additional work. If the DNS server is unreachable or network issues arise this can cause the pj_gethostip function to block for a period of time. This change adds an ast_sip_get_host_ip and ast_sip_get_host_ip_string function which does the same thing but caches the host IP address at module load time. This results in no additional work being done each time the local host IP address is needed. ASTERISK-25342 #close Change-Id: I3205deb679b01fa5ac05a94b623bfd620a2abe1e
2015-07-30res_pjsip_session.c: Fix crashes seen when call cancelled.Richard Mudgett
Two testsuite tests crashed in the same place as a result of an INVITE being CANCELed. tests/channels/pjsip/resolver/srv/failover/in_dialog/transport_unspecified tests/channels/pjsip/resolver/srv/failover/in_dialog/transport_tcp The session pointer is no longer in the inv->mod_data[session_module.id] location because the INVITE transaction has reached the terminated state. ASTERISK-25297 #close Reported by: Richard Mudgett Change-Id: Idb75fdca0321f5447d5dac737a632a5f03614427
2015-07-24pjsip: Add rtp_timeout and rtp_timeout_hold endpoint options.Joshua Colp
This change adds support for the 'rtp_timeout' and 'rtp_timeout_hold' endpoint options. These allow the channel to be hung up if RTP is not received from the remote endpoint for a specified number of seconds. ASTERISK-25259 #close Change-Id: I3f39daaa7da2596b5022737b77799d16204175b9
2015-07-20res_pjsip: Add rtp_keepalive endpoint option.Mark Michelson
This adds an "rtp_keepalive" option for PJSIP endpoints. Similar to the chan_sip option, this specifies an interval, in seconds, at which we will send RTP comfort noise frames. This can be useful for keeping RTP sessions alive as well as keeping NAT associations alive during lulls. ASTERISK-25242 #close Reported by Mark Michelson Change-Id: I06660ba672c0a343814af4cec838e6025cafd54b
2015-07-15res_pjsip_session.c: Extract sip_session_defer_termination_stop_timer().Richard Mudgett
Change-Id: I9e115dee74bd72e06081d0ee73ecdeb886caa5fb
2015-07-15res_pjsip_session.c: Add some helpful comments and minor tweaks.Richard Mudgett
Change-Id: I742aeeaf5f760593f323a00fb691affe22e35743
2015-07-15res_pjsip_session.c: Fix off nominal crash potential in debug message.Richard Mudgett
Change-Id: I09928297927ee85f7655289acee3a586816466bc
2015-07-14res_pjsip_session.c: Fix crash on call disconnect.Richard Mudgett
The crash fix for ASTERISK-25183 backported some code from master to try to make sure that a BYE response is processed by the same serializer used by the BYE request. The identified race condition causing that backport was the BYE request code had not finished processing after sending the BYE before the BYE response came in for processing under a different thread. Unfortunately, there is still a race condition. Now the race condition is between destroying the call session's serializer in ast_taskprocessor_unreference() and using ast_taskprocessor_get() to get a reference to the serializer for a BYE response. Even worse, the new race condition is a design limitation of the taskprocessor implementation that didn't matter in versions before v12. Back then, taskprocessors were only destroyed when a module unloaded. Now res_pjsip can destroy them when a call ends. However, as noted on the ASTERISK-25183 commit, session_inv_on_state_changed() is disassociating the dialog from the session when the invite dialog state becomes PJSIP_INV_STATE_DISCONNECTED. This is a tad too soon because our BYE request transaction has not completed yet. * Split session_end() that is called by session_inv_on_state_changed() to hold off session destruction until the BYE transaction timeout occurs or a failed initial INVITE transaction timeout occurs in session_inv_on_tsx_state_changed(). ASTERISK-25201 #close Reported by: Matt Jordan Change-Id: Iaf8dc8485fd8392a2a3ee4ad3b7f7f04a0dcc961
2015-07-06PJSIP FAX: Fix T.38 automatic reject timer NULL channel pointer dereferences.Richard Mudgett
When a caller calls a FAX number and then hangs up right after the call is answered then the T.38 re-INVITE automatic reject timer may still be running after the channel goes away. * Added session NULL channel checks on the code paths that get executed by t38_automatic_reject() to prevent a crash when the T.38 re-INVITE automatic reject timer expires. ASTERISK-25168 Reported by: Carl Fortin Change-Id: I07b6cd23815aedce5044f8f32543779e2f7a2403
2015-06-03res_pjsip: Prevent access of NULL channels.Mark Michelson
It is possible to receive incoming requests or responses after the channel on an ast_sip_session has been destroyed and NULLed out. Handlers of these sorts of requests or responses need to be prepared for the possibility that the channel is NULL or else they could cause a crash. While several places have been amended to deal with NULL channels, there were still a couple of places that needed updating. res_pjsip_dtmf_info.c: When handling incoming INFO requests, we need to return early if there is no channel on the session. res_pjsip_session.c: When handling a 302 response, we need to stop the redirecting attempt if there is no channel on the session. ASTERISK-25148 #close reported by Mark Michelson Change-Id: Id1a75ffc3d0eaa168b0b28188fb54d6cf9fc47a9
2015-05-27res_pjsip_session: Fix in-dialog authentication.Richard Mudgett
When the remote peer requires authentication for in-dialog requests then re-INVITEs to the peer cause the call to be disconnected and other in-dialog requests to the peer like MESSAGE just don't go through. * Made session_inv_on_tsx_state_changed() handle in-dialog authentication for re-INVITEs and other methods. Initial INVITEs cannot be handled here because the INVITE transaction must be restarted earlier. * Pulled needed code from res/res_pjsip/pjsip_outbound_auth.c in preparation for removing the file. The generic outbound authentication code did not work as well as anticipated. * Created outbound_invite_auth() to only handle initial outbound INVITEs. Re-INVITEs cannot be handled here. The re-INVITE transaction is still in progress and the PJSIP library cannot handle the overlapping INVITE transactions. Other method types should not be handled here as this code only works on outgoing calls and we need to handle incoming and outgoing calls. ASTERISK-25131 #close Reported by: Richard Mudgett Change-Id: I12bdd7ddccc819b4ce4b091e826d1e26334601b0
2015-04-10res_pjsip: Add an 'auto' option for DTMF ModeMatthew Jordan
This patch adds support for automatically detecting the type of DTMF that a PJSIP endpoint supports. When the 'dtmf_mode' endpoint option is set to 'auto', the channel created for an endpoint will attempt to determine if RFC 4733 DTMF is supported. If so, it will use that DTMF type. If not, the DTMF type for the channel will be set to inband. Review: https://reviewboard.asterisk.org/r/4438 ASTERISK-24706 #close Reported by: yaron nahum patches: yaron_patch_3_Feb.diff submitted by yaron nahum (License 6676) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@434637 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-26res_pjsip: Enable unload of all modules at shutdown.Corey Farrell
* Move most of res_pjsip:module_unload to unload_pjsip to resolve crashes caused by running PJSIP functions from non-PJSIP threads. * Remove call to pjsip_endpt_destroy(ast_pjsip_endpoint), it was causing crashes in some cases. In theory pj_shutdown() should take care of this. * Mark res_pjsip_keepalive and res_pjsip_session as allowed to unload at shutdown. * Resolve leaked config global in res_pjsip_notify. * Unregister pubsub pjsip service module. * Implement cleanup for res_pjsip_session. ASTERISK-24731 #close Reported by: Corey Farrell Review: https://reviewboard.asterisk.org/r/4498/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@433469 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-18res_pjsip_session: Fix off-nominal extra unref of session.Richard Mudgett
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@433088 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-10res_pjsip_refer: Fix occasional unexpected BYE sent after receiving a REFER.Richard Mudgett
A race condition happened between initiating a transfer and requesting that a dialog termination be delayed. Occasionally, the transferrer channels would exit the bridge and hangup before the dialog termination delay was requested. * Made request dialog termination delay before initiating the transfer action. If the transfer fails then cancel the delayed dialog termination request. ASTERISK-24755 #close Reported by: John Bigelow Review: https://reviewboard.asterisk.org/r/4460/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@432668 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-13res_pjsip_session: Fix double re-INVITE collision crash.Richard Mudgett
A multi-asterisk box setup with direct media enabled would occasionally crash when two re-INVITE collisions on a call leg happen in a row. The re-INVITE logic only had one timer struct to defer the re-INVITE. When the second collision happens the timer struct is overwritten and put into the timer heap again. Resources for the first timer are leaked and the heap has two positions occupied by the same timer struct. Now the heap ordering is potentially corrupted, the timer will fire twice, and any resources allocated for the second timer will be released twice. * The solution is to put the collided re-INVITE into the delayed requests queue with all the other delayed requests and cherry pick the next request that can come off the queue when an event happens. * Changed to put delayed BYE requests at the head of the delayed queue. There is no sense in processing delayed UPDATEs and re-INVITEs when a BYE has been requested. * Made the start of a BYE request flush the delayed requests queue to prevent a delayed request from overlapping the BYE transaction. I saw a few cases where a delayed re-INVITE got started after the BYE transaction started. * Changed the delayed_request struct to use an enum instead of a string for the request method. Cherry picking the queue is easier with an enum than string comparisons and the compiler can warn if a switch statement does not cover all defined enum values. * Improved the debug output to give more information. It helps to know which channel is involved with an endpoint. Trunks can have many channels associated with the endpoint at the same time. ASTERISK-24727 #close Reported by: Mark Michelson Review: https://reviewboard.asterisk.org/r/4414/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@431734 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-28Fix file descriptor leak in RTP code.Mark Michelson
SIP requests that offered codecs incompatible with configured values could result in the allocation of RTP and RTCP ports that would not get reclaimed later. ASTERISK-24666 #close Reported by Y Ateya Review: https://reviewboard.asterisk.org/r/4323 AST-2015-001 ........ Merged revisions 431300 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@431303 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-16Fix problem where a hung channel could occur on a failed blind transfer.Mark Michelson
Different clients react differently to being told that a blind transfer has failed. Some will simply send a BYE and be done with it. Others will attempt to reinvite themselves back onto the call. In the latter case, we were creating a new channel and then leaving it to sit forever doing nothing. With this code change, that new channel will not be created and the dialog with the transferring channel will be cleaned up properly. ASTERISK-24624 #close Reported by Zane Conkle Review: https://reviewboard.asterisk.org/r/4339 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@430714 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-05pjsip: Add 'PJSIP_AOR' and 'PJSIP_CONTACT' dialplan functions.Joshua Colp
The PJSIP_AOR dialplan function allows inspection of configured AORs including what contacts are currently bound to them. The PJSIP_CONTACT dialplan function allows inspection of contacts in existence. These can include both externally added (by way of registration) or permanent ones. ASTERISK-24341 Reported by: xrobau Review: https://reviewboard.asterisk.org/r/4308/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@430179 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-12-12res_pjsip_session: Delay sending BYE if a re-INVITE transaction is in progress.Joshua Colp
Given the scenario where a PJSIP channel is in a native RTP bridge with direct media and the channel is then hung up the code will currently re-INVITE the channel back to Asterisk and send a BYE at the same time. Many SIP implementations dislike this greatly. This change makes it so that if a re-INVITE transaction is in progress the BYE is queued to occur after the completion of the transaction (be it through normal means or a timeout). Review: https://reviewboard.asterisk.org/r/4248/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@429409 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-12-12res_pjsip_session: Fix issue where a declined media stream in a re-INVITE ↵Joshua Colp
would fail SDP negotiation. In the past the SDP negotiation within res_pjsip_session was made more tolerant of certain situations. The only case where SDP negotiation will fail is when a major error occurs during negotiation. Receiving an already declined media stream is not considered a major error. When producing the local SDP the logic took this into account so on the initial INVITE the declined media stream did not cause an SDP negotiation failure. Unfortunately the logic for handling media streams with a handler did not mirror this logic and considered an already declined media stream an error and thus failed the SDP negotiation. This change makes the logic between both situations match so only under major errors will the SDP negotiation fail. ASTERISK-24607 #close Reported by: Matt Jordan Review: https://reviewboard.asterisk.org/r/4254/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@429407 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-12-08Fix a crash that would occur when receiving a 491 response to a reinvite.Mark Michelson
The reviewboard description does a fine job of summarizing this, so here it is: A reporter discovered that Asterisk would crash when attempting to retransmit a reinvite that had previously received a 491 response. The crash occurred because a pjsip_tx_data structure was being saved for reuse, but its reference count was not being increased. The result was that the pjsip_tx_data was being freed before we were actually done with it. When we attempted to re-use the structure when re-sending the reinvite, Asterisk would crash. The fix implemented here is not to try holding onto the pjsip_tx_data at all. Instead, when we reschedule sending the reinvite, we create a brand new pjsip_tx_data and send that instead. Because of this change, there is no need for an ast_sip_session_delayed_request structure to have a pjsip_tx_data on it any more. So any code referencing its use has been removed. When this initial fix was introduced, I encountered a second crash when processing a subsequent 200 OK on a rescheduled reinvite. The reason was that when rescheduling the reinvite, we gave the wrong location for a response callback. This has been fixed in this patch as well. ASTERISK-24556 #close Reported by Abhay Gupta Review: https://reviewboard.asterisk.org/r/4233 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@429089 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-11-19res_pjsip_sdp_rtp: Add support for optimistic SRTP.Joshua Colp
Optimistic SRTP is the ability to enable SRTP but not have it be a fatal requirement. If SRTP can be used it will be, if not it won't be. This gives you a better chance of using it without having your sessions fail when it can't be. Encrypt all the things! Review: https://reviewboard.asterisk.org/r/3992/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@428222 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-11-14Fix race condition where duplicated requests may be handled by multiple threads.Mark Michelson
This is the Asterisk 13 version of the patch. The main difference is in the pubsub code since it was completely refactored between Asterisk 12 and 13. Review: https://reviewboard.asterisk.org/r/4175 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@427841 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-10-17res_pjsip_session/res_pjsip_sdp_rtp: Be more tolerant of offersMatthew Jordan
When an inbound SDP offer is received, Asterisk currently makes a few incorrection assumptions: (1) If the offer contains more than a single audio/video stream, Asterisk will reject the entire stream with a 488. This is an overly strict response; generally, Asterisk should accept the media streams that it can accept and decline the others. (2) If the offer contains a declined media stream, Asterisk will attempt to process it anyway. This can result in attempting to match format capabilities on a declined media stream, leading to a 488. Asterisk should simply ignore declined media streams. (3) Asterisk will currently attempt to handle offers with AVPF with use_avpf=No/AVP with use_avpf=Yes. This mismatch results in invalid SDP answers being sent in response. If there is a mismatch between the media type being offered and the configuration, Asterisk must reject the offer with a 488. This patch does the following: * Asterisk will accept SDP offers with at least one media stream that it can use. Some WARNING messages have been dropped to NOTICEs as a result. * Asterisk will not accept an offer with a media type that doesn't match its configuration. * Asterisk will ignore declined media streams properly. #SIPit31 Review: https://reviewboard.asterisk.org/r/4063/ ASTERISK-24122 #close Reported by: James Van Vleet ASTERISK-24381 #close Reported by: Matt Jordan ........ Merged revisions 425868 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@425879 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-10-16PJSIP: Enforce module load dependenciesKinsey Moore
This enforces that res_pjsip, res_pjsip_session, and res_pjsip_pubsub have loaded properly before attempting to load any modules that depend on them since the module loader system is not currently capable of resolving module dependencies on its own. ASTERISK-24312 #close Reported by: Dafi Ni Review: https://reviewboard.asterisk.org/r/4062/ ........ Merged revisions 425690 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@425691 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-10-03chan_pjsip: Fix deadlock when masquerading PJSIP channels.Richard Mudgett
Performing a directed call pickup resulted in a deadlock when PJSIP channels were involved. A masquerade needs to hold onto the channel locks while it swaps channel information between the two channels involved in the masquerade. With PJSIP channels, the fixup routine needed to push a fixup task onto the PJSIP channel's serializer. Unfortunately, if the serializer was also processing a task that needed to lock the channel, you get deadlock. * Added a new control frame that is used to notify the channels that a masquerade is about to start and when it has completed. * Added the ability to query taskprocessors if the current thread is the taskprocessor thread. * Added the ability to suspend/unsuspend the PJSIP serializer thread so a masquerade could fixup the PJSIP channel without using the serializer. ASTERISK-24356 #close Reported by: rmudgett Review: https://reviewboard.asterisk.org/r/4034/ ........ Merged revisions 424471 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@424472 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-10-03res_pjsip_session: Reduce SDP size by removing duplicate connection lines.Joshua Colp
Due to the architecture of how media streams are handled each individual handler adds connection details (IP address) for it. The first media stream is then used as the top level SDP connection line. In practice each line ends up being the same so to reduce the SDP size stream-level connection information is also added to the SDP if it differs from the top level SDP connection line. ........ Merged revisions 424414 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@424415 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-09-29Simplify UUID generation in several places.Richard Mudgett
Replace code using ast_uuid_generate() with simpler and faster code using ast_uuid_generate_str(). The new code avoids a malloc(), free(), and copy. ........ Merged revisions 424103 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@424105 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-09-27res_pjsip_session: Add additional checks for delaying session refreshes.Joshua Colp
There are certain situations which no checks existed for which need to prevent session refreshes. This includes sending a session refresh with SDP before SDP negotiation has completed and sending a session refresh before the dialog itself has been established. Checks for these have been added. Additionally COLP related UPDATEs were including SDP when it is not needed. Review: https://reviewboard.asterisk.org/r/4008/ ........ Merged revisions 424056 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@424057 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-09-16res_pjsip_session: Fix usage of wrong memory pool when creating local SDP.Joshua Colp
........ Merged revisions 423172 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@423173 65c4cc65-6c06-0410-ace0-fbb531ad65f3