Commit Graph

12 Commits

Author SHA1 Message Date
George Joseph bbf3ace682 res_pjsip: Fix infinite recursion when loading transports from realtime
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-02-08 19:11:18 -06:00
Joshua Colp d013ecf748 res_pjsip: Add common ast_sip_get_host_ip API.
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-08-25 13:55:33 -03:00
Rodrigo Ramírez Norambuena eec010829a AST_MODULE_INFO: Format corrections to the usages of AST_MODULE_INFO macro.
Change-Id: Icf88f9f861c6b2a16e5f626ff25795218a6f2723
2015-05-13 16:34:23 -05:00
Matthew Jordan 29f66b0429 ARI/PJSIP: Add the ability to redirect (transfer) a channel in a Stasis app
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
........

Merged revisions 431717 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431718 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-12 20:34:37 +00:00
Joshua Colp e43912f3f3 res_pjsip / res_pjsip_multihomed: Use the correct transport and addressing 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/
........

Merged revisions 430755 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@430756 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-19 13:19:11 +00:00
Joshua Colp b06078880b res_pjsip_multihomed: Add logging during startup to aid debugging if local 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
........

Merged revisions 427303 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@427306 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-11-05 12:19:09 +00:00
Kinsey Moore 86a4ce4957 PJSIP: Enforce module load dependencies
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
........

Merged revisions 425691 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@425700 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-10-16 16:32:25 +00:00
Mark Michelson dcf1ad14da Add module support level to ast_module_info structure. Print it in CLI "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-07-25 16:47:17 +00:00
Joshua Colp 932fb5a6e2 res_pjsip_multihomed: Make address replacement less aggressive.
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-17 22:46:56 +00:00
Joshua Colp 1b5c098976 Multiple revisions 410509-410510
........
  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-13 13:25:09 +00:00
Joshua Colp d00c1ac23e res_pjsip_multihomed: Fix a bug where outgoing messages for TCP would go out 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-12 12:51:34 +00:00
Joshua Colp 2fa1ff6e75 res_pjsip_multihomed: Add module which places the correct address within 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
2014-03-11 16:07:42 +00:00