summaryrefslogtreecommitdiff
path: root/res/res_pjsip_t38.c
AgeCommit message (Collapse)Author
2016-08-25ast_framehook_attach() must be called with the channel locked.Richard Mudgett
The framehook container could become corrupted if the channel lock is not held before calling. Change-Id: I1a6b957a1f7b899eb29a186915f8cccab886a438
2016-07-07chan_sip/res_pjsip_t38: Handle a request to negotiate T.38 after it is enabled.Joshua Colp
Some T.38 implementations may send another re-invite after the initial one which adds additional negotiation details (such as the max bitrate). Currently this will fail when passthrough is being done in chan_sip as we do nothing if T.38 is already active. Other handlers of T.38 inside of Asterisk (such as res_fax) handle this scenario so this change adds support for it to chan_sip and res_pjsip_t38. If a request to negotiate is received while T.38 is already enabled a new re-INVITE is sent and negotiation is done again. ASTERISK-26179 #close Change-Id: I0298494d3da6df3219bbfa4be9aa04015043145c
2016-02-29res_pjsip_t38.c: Back out part of an earlier fix attempt.Richard Mudgett
This backs out item 4 of the 4875e5ac32f5ccad51add6a4216947bfb385245d commit. Item 4 added the t38_bye_supplement. Unfortunately, the frame that it puts into the bridge may or may not be processed by the time the bridged peer is kicked out of the bridge. If it is processed then all is well. However, if it is not processed then that channel is stuck in fax mode until it hangs up or maybe if it joins another bridge for T.38 faxing. ASTERISK-25582 Change-Id: Ib20a03ecadf1bf8a0dcadfadf6c2f2e60919a9f7
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
2015-11-22chan_pjsip: Handle T.38 faxes with direct media bridgesMatt Jordan
When a channel is in a direct media bridge, a re-INVITE may arrive that forces Asterisk to re-negotiate the media to a T.38 fax. When this occurs, the bridge must change its technology to a simple bridge, and re-INVITE the media back to Asterisk. Generally, this logic mostly already exists in Asterisk. However, prior to this patch, there were a few bugs: (1) The T.38 framehook currently prevents a channel capable of T.38 faxes from ever entering into a direct media bridge. This applies even when the only media being passed over the channel is audio. This patch fixes this bug by having the framehook specify that it defers caring about any frame type. This allows the channels to enter into a direct media bridge, which will be broken when a re-INVITE is received. (2) When a re-INVITE is received, nothing instructed the bridging layer to re-inspect the allowed bridging technology. This now occurs when either a re-INVITE is received from a peer, or when a response is received from the far end (that is, when the T.38 state changes to either T38_PEER_REINVITE or T38_LOCAL_REINVITE). (3) chan_pjsip needs to do a small amount of work to prevent a direct media bridge from being chosen when a T.38 session is in progress. When a T.38 session supplement has a t38 datastore - which is added when we detect we should start thinking about T.38 on a channel - we now refuse a native RTP bridge. (4) When a BYE request is received, we don't terminate the T.38 session. If the other side of a T.38 fax survives the hangup (due to the 'g' flag in Dial, for example), we don't currently re-INVITE the media on the other channel back to audio. This patch now has res_pjsip_t38 intercept BYE requests and inform the far side that the T.38 session is terminated. This naturally causes the correct re-INVITEs to be sent. ASTERISK-25582 Change-Id: Iabd6aa578e633d16e6b9f342091264e4324a79eb
2015-11-21res/res_pjsip_t38: Add debug statementsMatt Jordan
This patch adds some debug statements to res_pjsip_t38. These statements help to determine which SDP negotiation callbacks are being executed, and, when a particular callback exits, why a callback may not have applied its logic to the local or remote SDP. Change-Id: I61b3fb9183b7ebbb5da8e9f48b59a5d9d7042d77
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-07Merge "PJSIP FAX: Fix T.38 automatic reject timer NULL channel pointer ↵Joshua Colp
dereferences." into 13
2015-07-06res_pjsip_t38.c: Fix always false if test.Richard Mudgett
Calling t38_change_state() sets the t38 state so it makes little sense to then check the state right after the call for something else. * Made the code in t38_interpret_parameters() reject or exit T.38 mode as intended but not implemented. Change-Id: Ib281263a6ed44da9448132c4e6df1e183b8a3df2
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-04-23res_pjsip_t38: Don't crash on authenticated reinvite after originated T.38 FAX.Mark Michelson
When Asterisk originates a channel to an application, the channel is hung up once the application finishes executing. When the application in question is SendFax, the Asterisk PJSIP code will attempt to reinvite the T.38 session to audio after the FAX completes. The hangup of the channel happens in the midst of this reinvite transaction. In most circumstances, this works out okay because the BYE is delayed until the reinvite transaction can complete. However, if the reinvite that Asterisk sends receives a 401/407 response, then Asterisk's attempt to re-send the reinvite with authentication will fail. This is because the session supplement in res_pjsip_t38 makes the assumption that the channel on the session will always be non-NULL. Since the channel has been hung up, though, the channel is now NULL. Attempting to operate on the channel causes a crash. This patch fixes the issue by ensuring that the channel on the session is not NULL before attempting to mess with the T.38 framehook. This patch also contains some corrections for comments that were incorrect and really confused me when I first started looking at the code. ASTERISK-25004 #close Reported by Mark Michelson Change-Id: Ic5a1230668369dda4bb13524098aed9306ab45a0
2015-04-11res/res_pjsip_t38: Add missing initialization of t38faxmaxdatagramMatthew Jordan
Prior to this patch, the far_max_datagram value on the UDPTL structure would remain -1 if the remote endpoint fails to provide the SDP media attribute T38FaxMaxDatagram. This can result in the INVITE request being rejected. With this patch, we will now properly initialize the value with either the default value or with the value provided by pjsip.conf's t38_udptl_maxdatagram parameter. Review: https://reviewboard.asterisk.org/r/4589 ASTERISK-24928 #close Reported by: Juergen Spies Tested by: Juergen Spies patches: pjsipT38patch20150331.txt submitted by Juergen Spies (License 6698) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@434688 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-04-08res_pjsip_t38: Fix FAX failures when using PJSIP with authenticationJonathan Rose
Without this patch, if a PJSIP endpoint with udptl enabled and authentication set attempted to use sendFax, the FAX session would fail during setup. This was because the invite issued in response to being auth challenged would cause the PJSIP channel performing the FAX to receive a second T38 framehook and this would cause frames to be consumed in an inappropriate manner. ASTERISK-24933 #close Reported by: Jonathan Rose Review: https://reviewboard.asterisk.org/r/4577/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@434425 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-17Audit ast_sockaddr_resolve() usage for memory leaks.Richard Mudgett
Valgrind found some memory leaks associated with ast_sockaddr_resolve(). Most of the leaks had already been fixed by earlier memory leak hunt patches. This patch performs an audit of ast_sockaddr_resolve() and found one more. * Fix ast_sockaddr_resolve() memory leak in apps/app_externalivr.c:app_exec(). * Made main/netsock2.c:ast_sockaddr_resolve() always set the addrs parameter for safety so the pointer will never be uninitialized on return. The same goes for res/res_pjsip_acl.c:extract_contact_addr(). * Made functions that call ast_sockaddr_resolve() with RAII_VAR() controlling the addrs variable use ast_free instead of ast_free_ptr to provide better MALLOC_DEBUG information. Review: https://reviewboard.asterisk.org/r/4509/ ........ Merged revisions 433056 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@433057 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
2014-12-16res_pjsip_t38: Fix T.38 failure when peer reinvites immediately.Joshua Colp
If a remote endpoint reinvites to T.38 immediately the state machine will go into a peer reinvite state. If a T.38 capable application (such as ReceiveFax) queries it will receive this state. Normally the application will then indicate so that the channel driver will queue up the T.38 offer previously received. Once it receives this offer the application will act normally and negotiate. The res_pjsip_t38 module incorrectly partially squashed this indication. This would cause the application to think the request had failed when in reality it had actually worked. This change makes it so that no T.38 control frames (or indications) are squashed. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@429612 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-09-19PJSIP: Prevent T38 framehook being put on wrong channelKinsey Moore
This change gives framehooks a reverse-direction masquerade callback in addition to chan_fixup_cb similar to the callback added to datastores to handle the same situation. The new callback provides the same parameters as the fixup callback, but is called on the new channel's framehooks before moving framehooks from the old channel to the new channel. This gives the framehooks an oppurtunity to decide whether they should remain on the new channel or be removed. This new callback is used to prevent the PJSIP T.38 framehook from remaining on a masqueraded channel if the new channel is not also a PJSIP channel. This was causing a crash when a local channel was masqueraded into a PJSIP channel and the framehook was executed on the local channel since the channel's tech private data was not structured as expected. Review: https://reviewboard.asterisk.org/r/4001/ ........ Merged revisions 423503 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@423504 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-25Add module support level to ast_module_info structure. Print it in CLI ↵Mark Michelson
"module show" . ASTERISK-23919 #close Reported by Malcolm Davenport Review: https://reviewboard.asterisk.org/r/3802 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419592 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-05-28res_pjsip_session: Fix leaked video RTP ports.Richard Mudgett
Simply enabling PJSIP to negotiage a video codec (e.g., h264) would leak video RTP ports if the codec were not negotiated by an incoming call. * Made add_sdp_streams() associate the handler with the media stream if the handler handled the media stream. Otherwise, when the ast_sip_session_media object was destroyed it didn't know how to clean up the RTP resources. * Fixed sdp_requires_deferral() associating the handler with the media stream when deciding if the SDP processing needs to be deferred for T.38. Like the leaked video RTP ports, the T.38 handler needs to clean up allocated resources from deciding if SDP processing needs to be deffered. * Cleaned up some dead code in handle_incoming_sdp() and sdp_requires_deferral(). ASTERISK-23721 #close Reported by: cervajs Review: https://reviewboard.asterisk.org/r/3571/ ........ Merged revisions 414749 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@414750 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-05-09Allow Asterisk to compile under GCC 4.10Kinsey Moore
This resolves a large number of compiler warnings from GCC 4.10 which cause the build to fail under dev mode. The vast majority are signed/unsigned mismatches in printf-style format strings. ........ Merged revisions 413586 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 413587 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 413588 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@413589 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-15PJSIP: Add Path header supportKinsey Moore
This adds Path support to chan_pjsip in res_pjsip_path.c with minimal additions in res_pjsip_registrar.c to store the path and additions in res_pjsip_outbound_registration.c to enable advertisement of path support to registrars and intervening proxies. Path information is stored on contacts and is enabled via Address of Record (AoRs) and Registration configuration sections. While adding path support, it became necessary to be able to add SIP supplements that handled messages outside of sessions, so a framework for handling these types of hooks was added in parallel to the already-existing session supplements and several senders of out-of-dialog requests were refactored as a result. (closes issue ASTERISK-21084) Review: https://reviewboard.asterisk.org/r/3050/ ........ Merged revisions 405565 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@405566 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-11func_channel, chan_pjsip: Add CHANNEL read function support for chan_pjsipMatthew Jordan
This patch adds CHANNEL read support for chan_pjsip. This allows the dialplan to use the CHANNEL function on a chan_pjsip channel to obtain run-time information about the channel from the PJSIP channel driver and the PJSIP stack. This includes: * RTP information, including source/destination media addresses, whether or not the media is secure, held, and other properties. * RTCP information. This includes sets of parseable information, as well as individual statistic attriutes. * PJSIP information. This includes URIs, local/remote signalling addresses, whether or not the signalling is secure, and other properties. * The endpoint name. This can be used in conjunction with the PJSIP_ENDPOINT function to obtain more detailed endpoint information. Review: https://reviewboard.asterisk.org/r/3038/ ........ Merged revisions 403618 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403619 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-04res_pjsip_t38: Don't pass T.38 control frames through to other hooks.Joshua Colp
This crept up during gateway testing where the gateway would receive the request to negotiate and assume it came from the remote side, causing the gateway state machine to go a little, to a use a technical term, "wonky". ........ Merged revisions 403364 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403365 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-01res_pjsip_t38: Add the framehook to the channel only on first INVITE.Joshua Colp
The check for determining whether the T.38 framehook should be added to the channel or not has now been changed to guarantee adding only occurs on the first incoming or outgoing INVITE. ........ Merged revisions 403258 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403259 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-10-03Fix crashes in res_pjsip_sdp_rtp and res_pjsip_t38 when a stream is rejected ↵Joshua Colp
and external_media_address is set. The callback function for changing the media address in streams wrongly assumes that a connection line will always be present. This is false as no line is present if a stream has been rejected. (closes issue ASTERISK-22645) Reported by: Rusty Newton ........ Merged revisions 400360 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400361 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-10-02Fix a crash in res_pjsip_t38 caused by the wrong assumption that a session ↵Joshua Colp
will always have a channel. When starting up or shutting down this assumption is false. ........ Merged revisions 400284 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400285 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-09-17Change the "external_media_address" PJSIP endpoint option to "media_address".Mark Michelson
The endpoint option does not apply to communication with external entities. Rather, the option is applied to all communications with the endpoint. The external_media_address transport configuration option may override the endpoint option if it turns out that we are going to be communicating with an external entity. Two things of note: 1) I have not updated the XML documentation. This is being taken care of by Rusty as part of his work on issue ASTERISK-22405 2) This commit is likely to cause testsuite failures since there are tests that use the external_media_address endpoint option, and they will need to be changed over. Well, I'm planning to get that updated ASAP after this commit. (closes issue ASTERISK-22528) reported by Rusty Newton ........ Merged revisions 399283 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@399284 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-30The large GULP->PJSIP renaming effort.Mark Michelson
The general gist is to have a clear boundary between old SIP stuff and new SIP stuff by having the word "SIP" for old stuff and "PJSIP" for new stuff. Here's a brief rundown of the changes: * The word "Gulp" in dialstrings, functions, and CLI commands is now "PJSIP" * chan_gulp.c is now chan_pjsip.c * Function names in chan_gulp.c that were "gulp_*" are now "chan_pjsip_*" * All files that were "res_sip*" are now "res_pjsip*" * The "res_sip" directory is now "res_pjsip" * Files in the "res_pjsip" directory that began with "sip_*" are now "pjsip_*" * The configuration file is now "pjsip.conf" instead of "res_sip.conf" * The module info for all PJSIP-related files now uses "PJSIP" instead of "SIP" * CLI and AMI commands created by Asterisk's PJSIP modules now have "pjsip" as the starting word instead of "sip" git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395764 65c4cc65-6c06-0410-ace0-fbb531ad65f3