summaryrefslogtreecommitdiff
path: root/res/res_pjsip_session.c
AgeCommit message (Collapse)Author
2017-05-15res_pjsip_session.c: Process initial INVITE sooner. (key exists)Richard Mudgett
Retransmissions of an initial INVITE could be queued in the serializer before we have processed the first INVITE message. If the first INVITE message doesn't get completely processed before the retransmissions are seen then we could try to setup the same call from the retransmissions. A symptom of this is seeing a (key exists) message associated with an INVITE. An earlier change attempted to address this kind of problem by calculating a distributor serializer to use for unassociated messages. Part of that change also made incoming calls keep using that distributor serializer. (ASTERISK-26088) However, some leftover code was still deferring the INVITE processing to the session's serializer even though we were already in that serializer. This not only is unnecessary but would cause the same call resetup problem. * Removed the code to defer processing the initial INVITE to the session's serializer because we are already running in that serializer. ASTERISK-26998 #close Change-Id: I1e822d82dcc650e508bc2d40d545d5de4f3421f6
2017-04-27res_pjsip_session: Add cleanup to ast_sip_session_terminateGeorge Joseph
If you use ast_request to create a PJSIP channel but then hang it up without causing a transaction to be sent, the session will never be destroyed. This is due ot the fact that it's pjproject that triggers the session cleanup when the transaction ends. app_chanisavail was doing this to get more granular channel state and it's also possible for this to happen via ARI. * ast_sip_session_terminate was modified to explicitly call the cleanup tasks and unreference session if the invite state is NULL AND invite_tsx is NULL (meaning we never sent a transaction). * chan_pjsip/hangup was modified to bump session before it calls ast_sip_session_terminate to insure that session stays valid while it does its own cleanup. * Added test events to session_destructor for a future testsuite test. ASTERISK-26908 #close Reported-by: Richard Mudgett Change-Id: I52daf6f757184e5544c261f64f6fe9602c4680a9
2017-04-26res_pjsip_session : fixed wrong From Header number On Re-inviteYasin CANER
ASTERISK-26964 #close Change-Id: I55a9caa7dc90e6c4c219cb09b5c2ec08af84a302
2017-04-21res_pjsip_session.c: Send 100 Trying out earlier to prevent retransmissions.Richard Mudgett
If ICE is enabled and a STUN server does not respond then we will block until we give up on the STUN response. This will take nine seconds. In the mean time the peer that sent the INVITE will send retransmissions. * Restructure res_pjsip_session.c:new_invite() to send a 100 Trying out earlier to prevent these retransmissions. ASTERISK-26890 Change-Id: Ie3fc611e53a0eff6586ad55e4aacad81cf6319a8
2017-04-21res_pjsip_session.c: Restructure ast_sip_session_alloc()Richard Mudgett
* Restructure ast_sip_session_alloc() to need less cleanup on off nominal error paths. * Made ast_sip_session_alloc() and ast_sip_session_create_outgoing() avoid unnecessary ref manipulation to return a session. This is faster than calling a function. That function may do logging of the ref changes with REF_DEBUG enabled. Change-Id: I2a0affc4be51013d3f0485782c96b8fee3ddb00a
2017-04-01res_pjsip_session: Allow BYE to be sent on disconnected session.Joshua Colp
It is perfectly acceptable for a BYE to be sent on a disconnected session. This occurs when we respond to a challenge to the BYE for authentication credentials. ASTERISK-26363 Change-Id: I6ef0ddece812fea6665a1dd2549ef44fb9d90045
2017-03-22res_pjsip_session: Enable RFC3578 overlap dialing support.Richard Begg
Support for RFC3578 overlap dialling (i.e. 484 Response to partially matched destinations) as currently provided by chan_sip is missing from res_pjsip. This patch adds a new endpoint attribute (allow_overlap) [defaults to yes] which when set to yes enables 484 responses to partial destination matches rather than the current 404. ASTERISK-26864 Change-Id: Iea444da3ee7c7d4f1fde1d01d138a3d7b0fe40f6
2017-03-20Merge "res/res_pjsip_session: Only check localnet if it is defined"Joshua Colp
2017-03-16res/res_pjsip_session: Only check localnet if it is definedMatt Jordan
If local_net is not defined on a transport, transport_state->localnet will be NULL. ast_apply_ha will, be default, return AST_SENSE_ALLOW in this case, causing the external_media_address, if set, to be skipped. This patch causes us to only check if we are sending within a network if local_net is defined. ASTERISK-26879 #close Change-Id: Ib661c31a954cabc9c99f1f25c9c9a5c5b82cbbfb
2017-03-16res_pjsip: Symmetric transportsGeorge Joseph
A new transport parameter 'symmetric_transport' has been added. When a request from a dynamic contact comes in on a transport with this option set to 'yes', the transport name will be saved and used for subsequent outgoing requests like OPTIONS, NOTIFY and INVITE. It's saved as a contact uri parameter named 'x-ast-txp' and will display with the contact uri in CLI, AMI, and ARI output. On the outgoing request, if a transport wasn't explicitly set on the endpoint AND the request URI is not a hostname, the saved transport will be used and the 'x-ast-txp' parameter stripped from the outgoing packet. * config_transport was modified to accept and store the new parameter. * config_transport/transport_apply was updated to store the transport name in the pjsip_transport->info field using the pjsip_transport->pool on UDP transports. * A 'multihomed_on_rx_message' function was added to pjsip_message_ip_updater that, for incoming requests, retrieves the transport name from pjsip_transport->info and retrieves the transport. If transport->symmetric_transport is set, an 'x-ast-txp' uri parameter containing the transport name is added to the incoming Contact header. * An 'ast_sip_get_transport_name' function was added to res_pjsip. It takes an ast_sip_endpoint and a pjsip_sip_uri and returns a transport name if endpoint->transport is set or if there's an 'x-ast-txp' parameter on the uri and the uri host is an ipv4 or ipv6 address. Otherwise it returns NULL. * An 'ast_sip_dlg_set_transport' function was added to res_pjsip which takes an ast_sip_endpoint, a pjsip_dialog, and an optional pjsip_tpselector. It calls ast_sip_get_transport_name() and if a non-NULL is returned, sets the selector and sets the transport on the dialog. If a selector was passed in, it's updated. * res_pjsip/ast_sip_create_dialog_uac and ast_sip_create_dialog_uas were modified to call ast_sip_dlg_set_transport() instead of their original logic. * res_pjsip/create_out_of_dialog_request was modified to call ast_sip_get_transport_name() and pjsip_tx_data_set_transport() instead of its original logic. * Existing transport logic was removed from endpt_send_request since that can only be called after a create_out_of_dialog_request. * res_pjsip/ast_sip_create_rdata was converted to a wrapper around a new 'ast_sip_create_rdata_with_contact' function which allows a contact_uri to be specified in addition to the existing parameters. (See below) * res_pjsip_pubsub/internal_pjsip_evsub_send_request was eliminated since all it did was transport selection and that is now done in ast_sip_create_dialog_uac and ast_sip_create_dialog_uas. * 'contact_uri' was added to subscription_persistence. This was necessary because although the parsed rdata contact header has the x-ast-txp parameter added (if appropriate), subscription_persistence_update stores the raw packet which doesn't have it. subscription_persistence_recreate was then updated to call ast_sip_create_rdata_with_contact with the persisted contact_uri so the recreated subscription has the correct transport info to send the NOTIFYs. * res_pjsip_session/internal_pjsip_inv_send_msg was eliminated since all it did was transport selection and that is now done in ast_sip_create_dialog_uac. * pjsip_message_ip_updater/multihomed_on_tx_message was updated to remove all traces of the x-ast-txp parameter from the outgoing headers. NOTE: This change does NOT modify the behavior of permanent contacts specified on an aor. To do so would require that the permanent contact's contact uri be updated with the x-ast-txp parameter and the aor sorcery object updated. If we need to persue this, we need to think about cloning permanent contacts into the same store as the dynamic ones on an aor load so they can be updated without disturbing the originally configured value. You CAN add the x-ast-txp parameter to a permanent contact's uri but it would be much simpler to just set endpoint->transport. Change-Id: I4ee1f51473da32ca54b877cd158523efcef9655f
2017-01-04res_pjsip_session: Access SIPDOMAIN via Dialplan.Alexander Traud
This feature was available in the SIP channel driver chan_sip. For example, Asterisk is the outbound proxy and has to handle all SIP-URIs, even domains not local to Asterisk. In that case, SIPDOMAIN is used in the Dialplan, to detect and dial remote SIP-URIs. This change here sets the SIP destination domain of an inbound call (SIPDOMAIN) in the SIP channel driver res_pjsip as well. ASTERISK-26670 #close Change-Id: I27c880dc404a3c1c6792e1ba3545475339577243
2016-12-14res_pjsip: Add/update ERROR msg if invalid URI.Richard Mudgett
ASTERISK-24499 Change-Id: Ie305153e47e922233b2ff24715e0e326e5fa3a6c
2016-11-09res_pjsip_session: Do not call session supplements when it's too late.Mark Michelson
res_pjsip_sesssion was hooking into transaction and invite state changes. One of the reasons for doing so was due to the PJSIP_EVENT_TX_MSG event. The idea was that we were hooking into the message sending process, and so we should call session supplements to alter the outgoing message. In reality, this event was meant to indicate that the message either a) had already been sent, or b) required a DNS lookup and would be sent when the DNS query completed. In case (a), this meant we were altering an already-sent request/response for no reason. In case (b), this potentially meant we could be trying to alter a request/response at the same time that the DNS resolution completed. In this case, it meant we might be stomping on memory being used by the thread actually sending the message. This caused potential crashes and memory corruption. This patch removes the calls to session supplements from the case where the PJSIP_EVENT_TX_MSG event occurs. In all of these cases, trying to alter the message at this point is too late, and it can cause nothing but harm to try to do it. Because there were no longer any calls to the handle_outgoing() function, it has been removed. Change-Id: Ibcc223fb1c3a237927f38754e0429e80ee301e92
2016-09-09res_pjsip: Add ignore_uri_user_options option.Richard Mudgett
This implements the chan_sip legacy_useroption_parsing option but with a better name. * Made the caller-id number and redirecting number strings obtained from incoming SIP URI user fields always truncated at the first semicolon. People don't care about anything after the semicolon showing up on their displays even though the RFC allows the semicolon. ASTERISK-26316 #close Reported by: Kevin Harwell Change-Id: Ib42b0e940dd34d84c7b14bc2e90d1ba392624f62
2016-09-09Merge "res/res_pjsip: Add preferred_codec_only config to pjsip endpoint."zuul
2016-09-09res/res_pjsip: Add preferred_codec_only config to pjsip endpoint.Aaron An
This patch add config to pjsip by endpoint. ;preferred_codec_only=yes ; Respond to a SIP invite with the single most preferred codec ; rather than advertising all joint codec capabilities. This ; limits the other side's codec choice to exactly what we prefer. ASTERISK-26317 #close Reported by: AaronAn Tested by: AaronAn Change-Id: Iad04dc55055403bbf5ec050997aee2dadc4f0762
2016-09-06res_pjsip_session: segfault on already disconnected sessionAlexei Gradinari
On heavy loaded system the TCP/TLS incoming calls could be disconnected by pjproject while these calls are being processed by asterisk which could use the session's memory pools. If the session in the disconnected state then the session memory pools were already freed, so we get segfault. This patch adds a lifetime control on an INVITE session to pjproject. The lifetime of the session is manipulated by calling pjsip_inv_add_ref/pjsip_inv_dec_ref. This patch uses these functions to inform pjproject that the session is in use. This patch adds check if the session state is not disconnected and also checks if the memory pool is not NULL. This patch also places tasks 'session_end' and 'session_end_completion' into session's serializer to avoid race condition. ASTERISK-26291 #close Change-Id: I4d28b1fb3b91f0492a911d110049d670fdc3c8d7
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-13res/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-09res_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-28res_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-20Merge "res_pjsip: Add rtp_keepalive endpoint option."Joshua Colp
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: I3b9903d99e35fe5d0b53ecc46df82c750776bc8d
2015-07-16res_pjsip_session.c: Extract sip_session_defer_termination_stop_timer().Richard Mudgett
Change-Id: I9e115dee74bd72e06081d0ee73ecdeb886caa5fb
2015-07-16res_pjsip_session.c: Add some helpful comments and minor tweaks.Richard Mudgett
Change-Id: I742aeeaf5f760593f323a00fb691affe22e35743
2015-07-16res_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-07-06res_pjsip: Failover when server is not availableKevin Harwell
Previously Asterisk did not properly failover to the next resolved DNS address when a endpoint could not be reached. With this patch, and while using res_pjsip, SIP requests (both in/out of dialog) now attempt to use the next address in the list of resolved addresses until a proper response is received or no more addresses are left. ASTERISK-25076 #close Reported by: Joshua Colp Change-Id: Ief14f4ebd82474881f72f4538f4577f30af2a764
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-06-02res_pjsip_session: Fix cherry pick to master compile error.Richard Mudgett
ASTERISK-25131 Reported by: Richard Mudgett Change-Id: I87c9c96ae4a8fe2bc8a0ddea6958a2ad9cefd8e3
2015-06-01res_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-05-13AST_MODULE_INFO: Format corrections to the usages of AST_MODULE_INFO macro.Rodrigo Ramírez Norambuena
Change-Id: Icf88f9f861c6b2a16e5f626ff25795218a6f2723