Commit Graph

26736 Commits

Author SHA1 Message Date
Richard Mudgett 99b1aa6d26 res_pjsip_outbound_registration.c: Add a serializer shutdown group.
The client_state objects contain a serializer used to send the outbound
REGISTER messages.  Once all those message transactions are complete then
the module can shutdown.

ASTERISK-24907 #close
Reported by: Kevin Harwell

Change-Id: Ibb2fe558f98190f2a06da830e0fadfa25516f547
2015-06-26 13:45:15 -05:00
Matt Jordan c0194b55b5 Merge "threadpool, res_pjsip: Add serializer group shutdown API calls." 2015-06-26 13:36:17 -05:00
Matt Jordan 8c1161a268 Merge "res_pjsip_outbound_registration.c: Fix handle_client_state_destruction() refs" 2015-06-26 13:34:54 -05:00
Matt Jordan 4208fe6ba7 Merge "res_pjsip_outbound_registration.c: Use ast_sorcery_object_unregister() API" 2015-06-26 13:34:47 -05:00
Matt Jordan d568177d7d Merge "res_pjsip_refer: Prevent sending duplicate headers." 2015-06-26 11:26:43 -05:00
Matt Jordan 771b9bb442 Merge "sorcery: Add ast_sorcery_object_unregister() API call." 2015-06-26 11:25:58 -05:00
Matt Jordan 8a9628dce5 Merge "res_pjsip_outbound_registration.c: Reorder load_module() and unload_module()." 2015-06-26 11:25:49 -05:00
Matt Jordan 19fcb928b2 Merge "AMI: Add Linkedid to the standard channel snapshot AMI event headers." 2015-06-26 11:00:29 -05:00
Matt Jordan 05dbfedb43 Merge "res_pjsip_nat: Rewrite route set when required." 2015-06-26 10:59:35 -05:00
Mark Michelson f536e9b59c res_pjsip_refer: Prevent sending duplicate headers.
res_pjsip_refer will attempt to add Referred-By or Replaces headers to
outbound INVITEs at times. If the INVITE gets challenged for
authentication, then we will resend the INVITE. Prior to this patch, the
Referred-By or Replaces header would be re-added to the outbound INVITE,
resulting in duplicated headers.

ASTERISK-25204 #close
Reported by Mark Michelson

Change-Id: I59fb5c08b4d253c0dba9ee3d3950b5025358222d
2015-06-26 10:41:05 -05:00
Richard Mudgett c2d48a2a28 AMI: Add Linkedid to the standard channel snapshot AMI event headers.
ASTERISK-25189 #close
Reported by: John Hardin

Change-Id: I2b1778c3fdc1dca0ed55db4e3a639eddfb16c2ac
2015-06-26 10:34:31 -05:00
Mark Michelson 700606a659 res_pjsip_nat: Rewrite route set when required.
When performing some provider testing, the rewrite_contact option was
interfering with proper construction of a route set when sending an ACK
after receiving a 200 OK response to an INVITE.

The initial INVITE was sent to address sip:foo. The 200 OK had a Contact
header with URI sip:bar. In addition, the 200 OK had Record-Route
headers for sip:baz and sip:foo, in that order. Since the Record-Route
headers had the lr parameter, the result should have been:

* Set R-URI of the ACK to sip:bar.
* Add Route headers for sip:foo and sip:baz, in that order.

However, the rewrite_contact option resulted in our rewriting the
Contact header on the 200 OK to sip:foo. The result was:

* R-URI remained sip:foo.
* We added Route headers for sip:foo and sip:baz, in that order.

The result was that sip:bar was not indicated in the ACK at all, so the
far end never received our ACK. The call eventually dropped.

The intention of rewrite_contact is to rewrite the most immediate
destination of our SIP request to be the same address on which we
received a request or response. In the case of processing a SIP response
with Record-Route headers, this means that instead of rewriting the
Contact header, we should instead rewrite the bottom-most Record-Route
header. In the case of processing a SIP request with Record-Route
headers, this means we rewrite the top-most Record-route header.
Like when we rewrite the Contact header, we also ensure to update
the dialog's route set if it exists.

ASTERISK-25196 #close
Reported by Mark Michelson

Change-Id: I9702157c3603a2d0bd8a8215ac27564d366b666f
2015-06-26 09:53:26 -05:00
Richard Mudgett af4ae3095e threadpool, res_pjsip: Add serializer group shutdown API calls.
A module trying to unload needs to wait for all serializers it creates and
uses to complete processing before unloading.

ASTERISK-24907
Reported by: Kevin Harwell

Change-Id: I8c80b90f2f82754e8dbb02ddf3c9121e5e966059
2015-06-25 14:33:44 -05:00
Richard Mudgett 4c133d81cd res_pjsip_outbound_registration.c: Fix handle_client_state_destruction() refs
* handle_client_state_destruction() must always be passed a ref to
client_state because it will always unref client_state.
handle_registration_response() was not passing a client_state ref.

* Made the final un-REGISTER message get sent normally using the pjproject
register control structure in handle_client_state_destruction().  The
previous code attempted to short circuit the response handling for the
module to unload.  That doesn't work for a couple reasons.  One,
pjsip_regc_send() may call the registered callback before it returns and
unbalance the client_state ref count.  Two, the registered callback
handles any authentication for the un-REGISTER message.

* Made the distinction between internal registration state and external
registration status with sip_outbound_registration_status_str().  This is
necessary to avoid altering documented AMI messages with internal
changes.

* Removed references to client_state->client outside of the serializer
thread.  When handle_client_state_destruction() destroys the pjproject
register control structure that memory is freed and cannot be referenced
anymore.  These accesses were to provide information for debug and
off-nominal warning messages.

* In sip_outbound_registration_timer_cb() you should not access entry->id
after unrefing client_state because the passed in entry is normally
pointing to the timer entry in the client_state object.

ASTERISK-24907
Reported by: Kevin Harwell

Change-Id: Ia7b446d8644b6b4550ef5bea49527671de65183f
2015-06-25 14:33:44 -05:00
Richard Mudgett dc63377c60 res_pjsip_outbound_registration.c: Use ast_sorcery_object_unregister() API
The sorcery pjsip 'registration' config object needs to be destroyed on
module unload.  Otherwise, a reload of res_pjsip could try to use
callbacks for a previously unloaded instance of the module provided by
ast_sorcery_object_register() or one of the variants.  Also, if
res_pjsip_outbound_registration were subsequently reloaded, the sorcery
config field objects would be registered in sorcery twice.

ASTERISK-24907
Reported by: Kevin Harwell

Change-Id: I304fad13dece2604af48353f6c6d9d5c7b064697
2015-06-25 14:32:19 -05:00
Richard Mudgett 9ec8a0f3cc sorcery: Add ast_sorcery_object_unregister() API call.
Find and unlink the specified sorcery object type to complement
ast_sorcery_object_register().  Without this function you cannot
completely unload individual modules that use sorcery for configuration.

ASTERISK-24907
Reported by: Kevin Harwell

Change-Id: I1c04634fe9a90921bf676725c7d6bb2aeaab1c88
2015-06-25 14:30:48 -05:00
Richard Mudgett 77ff7325a2 res_pjsip_outbound_registration.c: Reorder load_module() and unload_module().
It is best if the loading code creates and initializes the module's
infrastructure before letting the system know of its existence.  The
unloading code needs to reverse the actions of the loading code and in the
reverse order.

ASTERISK-24907
Reported by: Kevin Harwell

Change-Id: I5d151383e9787b5b60aa5e1627b10f040acdded4
2015-06-25 14:30:48 -05:00
Mark Michelson 3f1fe83633 Merge "res_pjsip_mwi: Set up unsolicited MWI upon registration." 2015-06-25 09:51:48 -05:00
Joshua Colp 6fffef78c3 Merge "test.c: Add unit test registration checks for summary and description." 2015-06-25 04:52:02 -05:00
Joshua Colp 52aa9536a1 Merge "Unit tests: Fix more unit test description strings." 2015-06-25 04:50:54 -05:00
Joshua Colp 7f30be6f5e Merge "Unit tests: Fix unit test description strings." 2015-06-25 04:48:46 -05:00
Joshua Colp 2315a08297 Merge "DNS unit tests: Fix extraneous description string commas." 2015-06-25 04:48:23 -05:00
Richard Mudgett daaa551c92 test.c: Add unit test registration checks for summary and description.
Added checks when a unit test is registered to see that the summary and
description strings do not end with a new-line '\n' for consistency.

The check generates a warning message and will cause the
/main/test/registrations unit test to fail.

* Updated struct ast_test_info member doxygen comments.

Change-Id: I295909b6bc013ed9b6882e85c05287082497534d
2015-06-24 17:13:31 -05:00
Richard Mudgett 71a4d1a033 Unit tests: Fix more unit test description strings.
Analyzing the code shows that the unit test summary and description
strings should not end with a new-line character.  Where these strings are
used in the code a new-line is provided for output.

Change-Id: I2f4f37988ec363c8d1c5077a2fc8ca841c5cd30c
2015-06-24 17:13:31 -05:00
Richard Mudgett 9c6d72e30d Unit tests: Fix unit test description strings.
Analyzing the code shows that the unit test summary and description
strings should not end with a new-line character.  Where these strings are
used in the code a new-line is provided for output.

Change-Id: I129284f5e7ca93d82532334076da4c462d3d9fba
2015-06-24 17:13:31 -05:00
Richard Mudgett a0c2d2089d DNS unit tests: Fix extraneous description string commas.
Change-Id: Icf5f13c8e1c2c92a4473bb573ed2dd856ce1b64e
2015-06-24 17:13:17 -05:00
Joshua Colp 3b2b004d69 app_dial: Hold reference to calling channel formats when dialing outbound.
Currently when requesting a channel the native formats of the
calling channel are provided to the core for usage when dialing
the outbound channel. This occurs without holding the channel lock
or keeping a reference to the formats. This is problematic as
the channel driver may end up changing the formats during this time.
In the case of chan_sip this happens when an SDP negotiation
completes.

This change makes it so app_dial keeps a reference to the native
formats of the calling channel which guarantees that they will
remain valid for the period of time needed.

ASTERISK-25172 #close

Change-Id: I2f0a67bd0d5d14c3bdbaae552b4b1613a283f0db
2015-06-24 13:51:02 -05:00
Richard Mudgett af66b0f3f7 res_pjsip_outbound_registration.c: Add missing line endings to CLI commands
Change-Id: I39ae612746d892d2dbe86f3ff2d7027fa1da57f7
2015-06-23 13:16:47 -05:00
Richard Mudgett 3f0708e5fe res_pjsip_outbound_registration.c: Eliminate simple RAII_VAR() usage.
Change-Id: I399cb9d61bbba706b48c98e0bf75e98984cd9a9e
2015-06-23 13:16:24 -05:00
Richard Mudgett 9ceb848242 res_pjsip_outbound_registration.c: Misc code cleanups.
* Break some long lines.

* Fix doxygen comment.

Change-Id: I8f12ba6822f84d5e7bb575280270cd7e2fefb305
2015-06-23 13:16:08 -05:00
Joshua Colp 39c79cd6fb Merge "res_pjsip_outbound_registration.c: Fix whitespace conflict potential." 2015-06-23 12:54:03 -05:00
Kevin Harwell 44c3c392e3 bridge.c: Hangup attended transfer target if bridged
After completing an attended transfer the transfer target channel was not being
hung up after leaving the bridge. Added an explicit softhangup to hangup said
channel, but only if it was previously bridged.

ASTERISK-24782 #close
Reported by: John Bigelow

Change-Id: Idde9543d56842369384a5e8c00d72a22bbc39ada
2015-06-23 09:57:28 -05:00
Joshua Colp 7846f73432 res_pjsip_mwi: Set up unsolicited MWI upon registration.
The res_pjsip_mwi previously required a reload to set up the proper
subscriptions to allow unsolicited MWI to work. This change
makes it so the act of registering will also cause this to occur.
This is particularly useful if realtime is involved as no reload
needs to occur within Asterisk to cause the MWI information
to get sent.

ASTERISK-25180 #close

Change-Id: Id847b47de4b8b3ab8858455ccc2f07b0f915f252
2015-06-23 08:15:05 -05:00
Richard Mudgett 096b27d9d2 res_pjsip_outbound_registration.c: Fix whitespace conflict potential.
Change-Id: I82e6e388e3688aebe0783f16c9e0800a747584b5
2015-06-22 13:57:21 -05:00
Alexander Traud 1ad9a6b6b6 chan_sip: Reload peer without its old capabilities.
On reload, previously allowed codecs were not removed. Therefore, it was not
possible to remove codecs while Asterisk was running. Furthermore, newly added
codecs got appended behind the previous codecs. Therefore, it was not possible
to add a codec with a priority of #1. This change removes the old capabilities
before the current ones are added.

ASTERISK-25182 #close
Reported by: Alexander Traud
patches:
 asterisk_13_allow_codec_reload.patch uploaded by Alexander Traud (License 6520)

Change-Id: I62a06bcf15e08e8c54a35612195f97179ebe5802
2015-06-22 16:47:07 +02:00
Joshua Colp 5caefc98a1 chan_sip: Destroy peers without holding peers container lock.
Due to the use of stasis_unsubscribe_and_join in the peer destructor
it is possible for a deadlock to occur when an event callback is
occurring at the same time.

This happens because the peer may be destroyed while holding the
peers container lock. If this occurs the event callback will never
be able to acquire the container lock and the unsubscribe will
never complete.

This change makes it so the peers that have been removed from the
peers container are not destroyed with the container lock held.

ASTERISK-25163 #close

Change-Id: Ic6bf1d9da4310142a4d196c45ddefb99317d9a33
2015-06-20 19:48:34 -05:00
Matt Jordan bd77ace25a Merge "Resolve race conditions involving Stasis bridges." 2015-06-19 10:11:36 -05:00
Mark Michelson d7a1e84a1e Resolve race conditions involving Stasis bridges.
This resolves two observed race conditions.

First, a bit of background on what the Stasis application does:

1a Creates a stasis_app_control structure. This structure is linked into
   a global container and can be looked up using a channel's unique ID.
2a Puts the channel in an event loop. The event loop can exit either
   because the stasis_app_control structure has been marked done, or
   because of some other factor, such as a hangup. In the event loop, the
   stasis_app_control determines if any specific ARI commands need to be
   run on the channel and will run them from this thread.
3a Checks if the channel is bridged. If the channel is bridged, then
   ast_bridge_depart() is called since channels that are added to Stasis
   bridges are always imparted as departable.
4a Unlink the stasis_app_control from the container.

When an ARI command is received by Asterisk, the following occurs
1b A thread is spawned to handle the HTTP request
2b The stasis_app_control(s) that corresponds to the channel(s) in the
   request is/are retrieved. If the stasis_app_control cannot be
   retrieved, then it is assumed that the channel in question has exited
   the Stasis app or perhaps was never in Stasis in the first place.
3b A command is queued onto the stasis_app_control, and the channel's
   event loop thread is signaled to run the command.
4b While most ARI commands do nothing further, some, such as adding or
   removing channels from a bridge, will block until the command they
   issued has been completed by the channel's event loop.

The first race condition that is solved by this patch involves a crash
that can occur due to faulty detection of the channel's bridged status
in step 3a. What can happen is that in step 2a, the event loop may run
the ast_bridge_impart() function to asynchronously place the channel
into a bridge, then immediately exit the event loop because the channel
has hung up. In step 3a, we would detect that the channel was not
bridged and would not call ast_bridge_depart(). The reason that the
channel did not appear to be bridged was that the depart_thread that is
spawned by ast_bridge_impart() had not yet started. That is the thread
where the channel is marked as being bridged. Since we did not call
ast_bridge_depart(), the Stasis application would exit, and then the
channel would be destroyed Then the depart_thread would start up and
try to manipulate the destroyed channel, causing a crash.

The fix for this is to switch from using ast_channel_is_bridged() to
checking the NULLity of ast_channel_internal_bridge_channel() to
determine if ast_bridge_depart() needs to be called. The channel's
internal bridge_channel is set when ast_bridge_impart() is called and
is NULLed by the call to ast_bridge_depart(). If the channel's internal
bridge_channel is non-NULL, then the channel must have been imparted
into the bridge and needs to be departed, even if the actual bridging
operation has not yet started. By departing the channel when necessary,
the thread that is running the Stasis application will block until the
bridge gives the okay that the depart_thread has exited.

The second race condition that is solved by this patch involves a leak
of HTTP handler threads. The problem was that step 2b would successfully
retrieve a stasis_app_control structure. Then step 2a would exit the
channel from the event loop due to a hangup. Steps 3a and 4a would
execute, and then finally steps 3b and 4b would. The problem is that at
step 4b, when attempting to add a channel to a bridge, the thread would
block forever since the channel would never execute the queued command
since it was finished with the event loop. This meant that the HTTP
handling thread would be leaked, along with any references that thread
may have owned (in my case, I was seeing bridges leaked).

The fix for this is to hone in better on when the channel has exited the
event loop. The stasis_app_control structure has an is_done field that
is now set at each point where the channel may exit the event loop. If
step 2b retrieves a valid stasis_app_control structure but the control
is marked as done, then the attempted operation exits immediately since
there will be nothing to service the attempted command.

ASTERISK-25091 #close
Reported by Ilya Trikoz

Change-Id: If66265b73b4c9f8f58599124d777fedc54576628
2015-06-18 16:19:20 -05:00
Joshua Colp 9668a1acb5 res_sorcery_memory_cache: Remove 'prefetch' option.
To prevent confusion I am removing the prefetch option until such
time as it is implemented. All other functionality, however, has
been implemented.

ASTERISK-25067

Change-Id: I9ce6aa3e5c6c5bc3c5baa8ff90fa036d73939895
2015-06-17 09:00:21 -03:00
Matt Jordan 8c0b917032 Merge "Parking: Add documentation for AMI ParkedCallSwap event." 2015-06-16 11:40:34 -05:00
Mark Michelson 59552c2d08 Parking: Add documentation for AMI ParkedCallSwap event.
This event was added some time ago in order to clarify when a channel
took the place of another channel in a parking lot. However, there was
no XML documentation added for the event. This patch adds the XML
documentation.

ASTERISK-24900 #close
Reported by Rusty Newton

Change-Id: I4cfe7777c4b94bbff91c9221c6096a7a02a92eac
2015-06-16 11:22:11 -05:00
Joshua Colp 7cdb858651 Merge "res_pjsip: Add option to force G.726 to be treated as AAL2 packed." 2015-06-16 07:51:30 -05:00
Corey Farrell ea9d5f155e func_pjsip_aor: Fix leaked contact from iterator.
ASTERISK-25162 #close

Change-Id: Id79aa3c6fe490016ee98efc97ac4c1d3f461f97e
2015-06-15 17:14:56 -05:00
Kevin Harwell 93ac45d3bd res_pjsip: Add option to force G.726 to be treated as AAL2 packed.
Some phones send g.726 audio packed for AAL2, which differs from what is
recommended by RFC 3351. If Asterisk receives audio formatted as such when
negotiating g.726 then it sounds a bit distorted. Added an option to
res_pjsip_endpoint that allows g.726 negotiated audio to be treated as g.726
AAL2 packed.

ASTERISK-25158 #close
Reported by: Steve Pitts

Change-Id: Ie7e21f75493d7fe53e75e12c971e72f5afa33615
2015-06-15 12:40:03 -05:00
mjordan 15c2208701 main/cdr: Carry over the disable flag when 'disable all' is specified
The CDR_PROP function (as well as the NoCDR application) set the
'disable all' flag (AST_CDR_FLAG_DISABLE_ALL) on the current CDR. This
flag is supposed to be applied to all CDRs that are currently in the
chain, as well as all CDRs that may be created in the future. Currently,
however, the flag is only applied to the existing CDRs in the chain; new
CDRs do not receive the 'disable all' flag. In particular, this affects
parallel dials, which generate new CDRs for each pair of channels in
the dial attempt.

This patch carries over the 'disable all' flag when it is specified on a
CDR and a new CDR is generated for the chain.

ASTERISK-24344 #close

Change-Id: I91a0f0031e4d147bdf8a68ecd08304d506fb6a0e
2015-06-15 10:35:01 -05:00
Matt Jordan b8bc15286f main/cdr: Copy context/exten on chained CDRs for parallel dials in subroutines
When a parallel dial occurs, a new CDR will be created for each dial
attempt that is made. In most circumstances, the act of creating each
CDR in the chain will include a step that updates the Party A snapshot,
which causes the context/extension of the Party A to be copied onto the
CDR object.

However, when the Party A is in a subroutine, we explicitly do *not*
copy the context/extension onto the CDR. This prevents the Macro or
GoSub routine name from blowing away the context/extension that the
channel was originally executing in. For the original CDR, this is not a
problem: the original CDR already recorded the last known 'good' state
of the channel just prior to it going into the subroutine. However, for
newly generated CDRs in a chain, there is no context/extension set on
them. Since we are in a subroutine, we will never set the Party A's
context/extension on the CDR, and we end up with a CDR with no
destination recorded on it.

This patch updates the creation of a chained CDR such that it copies
over the original CDR's context/extension. This is the last known "good"
state of the CDR, and is a reasonable starting point for the newly
generated CDR. In the case where we are not in a subroutine, subsequent
code will update the location of the CDR from the Party A information;
in the case where we are in a subroutine, the context/extension on the
original CDR is the correct information.

ASTERISK-24443 #close

Change-Id: I6a3ef0d6e458d3b9b30572feaec70f2964f3bc2a
2015-06-13 08:47:53 -05:00
Matt Jordan 56d6b52a3f Merge "bridge: When performing a blonde transfer update connected line information." 2015-06-13 08:36:58 -05:00
Mark Michelson 0b1a25054f Merge "chan_sip.c: Update dialog fromtag after request with auth" 2015-06-12 16:02:16 -05:00
Mark Michelson b9587fa9a8 Merge "app_directory: Fix crash when using the alias option 'a'." 2015-06-12 16:01:44 -05:00
Damian Ivereigh 19f60d9412 chan_sip.c: Update dialog fromtag after request with auth
If a client sends and INVITE which is 401 rejected, then subsequently
sends a new INVITE with the auth info and uses a different fromtag
from the first INVITE, Asterisk will accept the new INVITE as part of
the original dialog - match_req_to_dialog() specifically ignores the
fromtag. However it does not update the stored dialog with the new
fromtag.

This results in Asterisk being unable to match future packets that are
part of this dialog (such as the ACK to the OK or the OK to the BYE),
and the call is dropped.

This problem was originally found when using an NEC-i SV8100-GE (NEC SIP
Card).

* After a successful match of a packet to the dialog, if the packet is
  not a SIP_RESPONSE, authentication is present and the fromtags are
  different, the stored fromtag is updated with the one from the recent
  INVITE.

ASTERISK-25154 #close
Reported by: Damian Ivereigh
Tested by: Damian Ivereigh

Change-Id: I5c16cf3b409e5ef9f2b2fe974b6bd2a45a6aa17e
2015-06-12 09:02:34 -05:00