summaryrefslogtreecommitdiff
path: root/res/res_pjsip_multihomed.c
AgeCommit message (Collapse)Author
2016-09-15res_pjsip_multihomed: Change Contact port to listening port.Joshua Colp
The res_pjsip_multihomed module determines what interface and transport a request is going out on and updates the SIP message accordingly with the address information. This currently incorrectly updates the Contact header for connectionful protocols to the ephemeral connection port, instead of the bound address for the listening socket which can actually accept the connection back. If the remote side attempts to connect back on the epehemeral port it will fail. This change makes it so the port is updated to the bound port on connectionful protocols and is maintained on UDP (as there can be multiple of those). ASTERISK-26374 #close Change-Id: I50f8dab65b9f75117d73ba5f6bbcf6c9871854ab
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-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-02-12ARI/PJSIP: Add the ability to redirect (transfer) a channel in a Stasis appMatthew Jordan
This patch adds a new feature to ARI to redirect a channel to another server, and fixes a few bugs in PJSIP's handling of the Transfer dialplan application/ARI redirect capability. *New Feature* A new operation has been added to the ARI channels resource, redirect. With this, a channel in a Stasis application can be redirected to another endpoint of the same underlying channel technology. *Bug fixes* In the process of writing this new feature, two bugs were fixed in the PJSIP stack: (1) The existing .transfer channel callback had the limitation that it could only transfer channels to a SIP URI, i.e., you had to pass 'PJSIP/sip:foo@my_provider.com' to the dialplan application. While this is still supported, it is somewhat unintuitive - particularly in a world full of endpoints. As such, we now also support specifying the PJSIP endpoint to transfer to. (2) res_pjsip_multihomed was, unfortunately, trying to 'help' a 302 redirect by updating its Contact header. Alas, that resulted in the forwarding destination set by the dialplan application/ARI resource/whatever being rewritten with very incorrect information. Hence, we now don't bother updating an outgoing response if it is a 302. Since this took a looong time to find, some additional debug statements have been added to those modules that update the Contact headers. Review: https://reviewboard.asterisk.org/r/4316/ ASTERISK-24015 #close Reported by: Private Name ASTERISK-24703 #close Reported by: Matt Jordan git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@431717 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-19res_pjsip / res_pjsip_multihomed: Use the correct transport and addressing ↵Joshua Colp
information on UAS sessions. The first thing this patch fixes is UAS dialogs. Previously if a transport was configured on an endpoint and an inbound session was created there was no guarantee that requests sent on the dialog would use the correct transport and address information. This has now been fixed so an explicitly configured transport is taken into account. The second thing this patch fixes is res_pjsip_multihomed. The res_pjsip_multihomed module attempts to determine what transport a message should go out on and what addressing information should go into the message itself. In a scenario where multiple transports exist bound to the same IP address but a different port the code would incorrectly alter the transport and change the message to the wrong transport. This change makes the res_pjsip_multihomed module smarter so it will only change the transport and address information in the message when it is possible and makes sense. ASTERISK-24615 #close Reported by: David Justl Review: https://reviewboard.asterisk.org/r/4331/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@430755 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-11-05res_pjsip_multihomed: Add logging during startup to aid debugging if local ↵Joshua Colp
DNS is misbehaving. This change adds a bit of logging so if the local DNS is misbehaving it is easier to track down what is going on and where Asterisk may be hanging. ASTERISK-24438 #close Reported by: Melissa Shepherd Review: https://reviewboard.asterisk.org/r/4148/ ........ Merged revisions 427300 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@427303 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-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-03-17res_pjsip_multihomed: Make address replacement less aggressive.Joshua Colp
This change makes the res_pjsip_multihomed module less aggressive when changing the address in messages. It will now only occur if the transport in use is bound to the any address OR if the system determined source address matches the bound address of the transport in use. Review: https://reviewboard.asterisk.org/r/3369/ ........ Merged revisions 410793 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410794 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-13Multiple revisions 410509-410510Joshua Colp
........ r410509 | file | 2014-03-13 06:23:14 -0700 (Thu, 13 Mar 2014) | 2 lines res_pjsip_multihomed: Fix a bug where the 200 OK for a REGISTER would contain the wrong contact. ........ r410510 | file | 2014-03-13 06:24:17 -0700 (Thu, 13 Mar 2014) | 2 lines res_pjsip_multihomed: Remove change for testing fix. ........ Merged revisions 410509-410510 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410511 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-12res_pjsip_multihomed: Fix a bug where outgoing messages for TCP would go out ↵Joshua Colp
using UDP. This change fixes a bug where the code which changes the transport did not check whether the message is going out over UDP or not before changing it. For TCP and TLS transports we don't need to change the transport as the correct one is already chosen. ........ Merged revisions 410471 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410472 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-11res_pjsip_multihomed: Add module which places the correct address within ↵Joshua Colp
messages. Due to how messages are handled within PJSIP it is not until a message is actually sent that the destination is reliably known. This means that the addresses placed within the message may not be of the interface the message is being sent out on. This module determines what interface a message is being sent on and updates the message to contain the correct address if applicable. This module was tested by myself in a virtualized environment with multiple interfaces and also by Kinsey Moore in the following configuration: Networks: * 10.24.16.0/21 ** hard phone ** default gateway * 10.24.64.0/21 ** softphone with pjsip-based stack Transport details: bind address: 0.0.0.0 protocol: UDP All endpoints were tested with explicitly configured transports and unconfigured transports. This was tested with inbound and outbound calls, both of which were experiencing detrimental effects from incorrect IP addresses in SIP messages. These effects were only experienced by the soft phone on the 10.24.64.0 network since the messages to the hard phone on the 10.24.16.0 network had the correct IP address. (closes issue ASTERISK-23020) Reported by: xrobau Review: https://reviewboard.asterisk.org/r/3102/ ........ Merged revisions 410451 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410452 65c4cc65-6c06-0410-ace0-fbb531ad65f3