Commit Graph

27081 Commits

Author SHA1 Message Date
Joshua Colp 820b9dc138 Merge "res/res_pjsip: Purge contacts when an AoR is deleted" 2015-09-08 14:03:43 -05:00
Joshua Colp 3628e380b8 res_pjsip: Use hash for contact object identity instead of Contact URI.
In the wild it is possible for Contact URIs to be quite long as
parameters can exist on them. This can present a problem when storing
them in the AstDB as the URI is used as part of the object name and
there is a fixed length limit for the AstDB. This will cause
the contact to not get stored.

This change uses the MD5 hash of the Contact URI as part of the
object name instead. This has a fixed length which is guaranteed
to not exceed the AstDB length limit.

ASTERISK-25295 #close

Change-Id: Ie8252a75331ca00b41b9f308f42cc1fbdf701a02
2015-09-08 07:44:52 -05:00
Alexander Anikin d2106c0b21 chan_ooh323: call ast_rtp_instance_stop on ooh323_destroy
Call ast_rtp_instance_stop on ooh323_destroy to free resources
    allocated by rtp instance

    ASTERISK-25299 #close
    Report by: Alexandr Dranchuk

Change-Id: I455096bd7da016b871afe90af86067c2c7c9f33f
2015-09-07 13:48:08 -05:00
Matt Jordan ef3358d0c0 res/res_pjsip: Purge contacts when an AoR is deleted
When an AoR is deleted by an external mechanism, such as through ARI, we
currently do not remove dynamic contacts that were created for that AoR as a
result of a received REGISTER request. As a result, re-creating the AoR will
cause the dynamic contact to be interpreted as a persistent contact, leading
to some rather strange state being created for the contacts/endpoints.

This patch adds a sorcery observer for the 'aor' object. When a delete is
issued on the underlying sorcery object, the observer is called, and all
contacts created and persisted in sorcery for that AoR are also removed. Note
that we don't want to perform this action when an AO2 object that is an AoR is
destroyed, as the AoR can still exist in the backing storage (and we would
thus be removing valid contacts from an AoR that still "exists".)

ASTERISK-25381 #close

Change-Id: I6697e51ef6b2858b5d63401f35dc378bb0f90328
2015-09-07 11:37:54 -05:00
Matt Jordan a79527ca64 Merge "endpoint snapshot: avoid second cleanup on alloc failure" 2015-09-05 18:48:26 -05:00
Matt Jordan b16c7ef0ed Merge "channels/pjsip/dialplan_functions: Add an option for extracting the SIP call-id" 2015-09-05 18:43:50 -05:00
Joshua Colp e1c43223ab Merge "res_pjsip: Change default from user value." 2015-09-05 15:56:59 -05:00
Joshua Colp bf74956371 Merge "Fix when remote candidates exceed PJ_ICE_MAX_CAND" 2015-09-05 15:42:37 -05:00
Matt Jordan 86b02228f5 channels/pjsip/dialplan_functions: Add an option for extracting the SIP call-id
This patch adds a new option to the CHANNEL function that allows for the
extraction of the SIP call-id. It is used in conjunction with the 'pjsip'
option, and will return the Call-ID of the INVITE request that established
the PJSIP channel.

ASTERISK-25352

Change-Id: I278d1f8bcfe3a53c5aa1dadebc14e92b0abd476a
2015-09-05 15:25:44 -05:00
David M. Lee 27c89053b0 Fix when remote candidates exceed PJ_ICE_MAX_CAND
We were passing the wrong count into pj_ice_sess_create_check_list(),
causing the create to fail if we ever received more than PJ_ICE_MAX_CAND
candidates.

Change-Id: I0303d8e1ecb20a8de9fe629a3209d216c4028378
2015-09-04 16:13:52 -05:00
Mark Michelson 993ae9a669 res_pjsip: Change default from user value.
When Asterisk sends an outbound SIP request, if there is no direct
reason to place a specific value for the username in the From header,
Asterisk would generate a UUID. For example, this would happen when
sending outbound OPTIONS requests when qualifying or when sending
outbound INVITE requests when originating (if no explicit caller ID were
provided). The issue is that some SIP providers reject these sorts of
requests with a "Name too long" error response.

This patch aims to fix this by changing the default outbound username in
From headers to "asterisk". This value can be overridden by changing the
default_from_user option in the global options if desired.

ASTERISK-25377 #close
Reported by Mark Michelson

Change-Id: I6a4d34a56ff73ff4f661b0075aeba5461b7f3190
2015-09-04 14:48:20 -05:00
Jonathan Rose 7d981b787c ParkAndAnnounce: Add variable inheritance
In Asterisk 11, the announcer channel would receive channel variables
from the channel being parked by means of normal channel inheritance.
This functionality was lost during the big res_parking project in
Asterisk 12. This patch restores that functionality.

ASTERISK-25369 #close
Review: https://gerrit.asterisk.org/#/c/1180/

Change-Id: Ie47e618330114ad2ea91e2edcef1cb6f341eed6e
2015-09-04 11:22:26 -05:00
Scott Griepentrog 7691035312 endpoint snapshot: avoid second cleanup on alloc failure
In ast_endpoint_snapshot_create(), a failure to init the
string fields results in two attempts to ao2_cleanup the
same pointer.  Removed RAII_VAR to eliminate problem.

ASTERISK-25375 #close
Reported by: Scott Griepentrog

Change-Id: If4d9dfb1bbe3836b623642ec690b6d49b25e8979
2015-09-04 09:26:46 -05:00
Martin Tomec be31747db8 res/pjsip: Mark WSS transport as secure
Pjsip is refusing to use unsecure transport with "sips" in url.
WSS should be considered as secure transport.

ASTERISK-24602 #comment Partially fixed by setting WSS as secure

Change-Id: Iddac406c6deba6240c41a603b8859dfefe1a5353
2015-09-04 12:46:14 +02:00
Guido Falsi fbdb42c9fc Core/General: Add #ifdef needed on FreeBSD.
pthread_attr_init() defaults to PTHREAD_EXPLICIT_SCHED on FreeBSD
too.

ASTERISK-25310 #close
Reported by: Guido Falsi

Change-Id: Iae6befac9028b5b9795f86986a4a08a1ae6ab7c4
2015-09-03 21:29:37 -05:00
Mark Michelson c15d8cc0ed res_pjsip: Fix contact refleak on stateful responses.
When sending a stateful response, creation of the transaction can fail,
most commonly because we are trying to create a transaction from a
retransmitted request. When creation of the transaction fails, we end up
leaking a reference to a contact that was bumped when the response was
created.

This patch adds the missing deref and fixes the reference leak.

Change-Id: I2f97ad512aeb1b17e87ca29ae0abacb4d6395f07
2015-09-02 17:28:18 -05:00
Joshua Colp b51cf1e712 pbx: Fix crash when issuing "core show hints" with long pattern match.
When issuing the "core show hints" CLI command a combination of both
the hint extension and context is created. This uses a fixed size
buffer expecting that the extension will not exceed maximum extension
length. When the extension is actually a pattern match this constraint
does not hold true, and the extension may exceed the maximum extension
length. In this case extra characters are written past the end of the
fixed size buffer.

This change makes it so the construction of the combined hint extension
and context can not exceed the size of the buffer.

ASTERISK-25367 #close

Change-Id: Idfa1b95d0d4dc38e675be7c1de8900b3f981f499
2015-09-02 12:47:51 -05:00
Mark Michelson beb568e51c res_pjsip_pubsub: re-re-fix persistent subscription storage.
A recent change to res_pjsip_pubsub switched to using pjsip_msg_print as
a means of writing an appropriate packet to persistent storage. While
this partially solved the issue, it had its own problems.
pjsip_msg_print will always add a Content-Length header to the message
it prints. Frequent restarts of Asterisk can result in persistent
subscriptions being written with five or more Content-Length headers. In
addition, sometimes some apparent corruption of individual headers could
be seen.

This aims to fix the problem by not running a parsed message through an
interpreter but rather by taking the raw message and saving it. The
logic for what to save is going to be different depending on whether a
SUBSCRIBE was received from the wire or if it was pulled from
persistence. When receiving a packet from the wire, when using a
streaming transport, the rdata->pkt_info.packet may contain multiple SIP
messages or fragments. However, the rdata->msg_info.msg_buf will always
contain the current SIP message to be processed. When pulling from
persistence, though, the rdata->msg_info.msg_buf will be NULL since no
transport actually handled the packet. However, since we know that we
will always ever pull one SIP message from persistence, we are free to
save directly from rdata->pkt_info.packet instead.

ASTERISK-25365 #close
Reported by Mark Michelson

Change-Id: I33153b10d0b4dc8e3801aaaee2f48173b867855b
2015-09-01 09:41:10 -05:00
Matt Jordan e23a01acbb Merge "taskprocessor: Fix race condition between unreferencing and finding." 2015-08-29 12:31:59 -05:00
Matt Jordan fdc287ea3a Merge "res_pjsip_sdp_rtp: Fix multiple keepalive scheduled items." 2015-08-29 12:30:59 -05:00
Joshua Colp fc4d4f5379 taskprocessor: Fix race condition between unreferencing and finding.
When unreferencing a taskprocessor its reference count is checked
to determine if it should be unlinked from the taskprocessors
container and its listener shut down. In between the time when the
reference count is checked and unlinking it is possible for
another thread to jump in, find it, and get a reference to it. If
the thread then uses the taskprocessor it may find that it is not
in the state it expects.

This change locks the taskprocessors container during almost the
entire unreference operation to ensure that any other thread which
may attempt to find the taskprocessor has to wait.

ASTERISK-25295

Change-Id: Icb842db82fe1cf238da55df92e95938a4419377c
2015-08-29 10:44:27 -05:00
Joshua Colp bb38010c67 res_pjsip_sdp_rtp: Fix multiple keepalive scheduled items.
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-28 20:49:35 -05:00
Joshua Colp c036e50fbe sched: ast_sched_del may return prematurely due to spurious wakeup
When deleting a scheduled item if the item in question is currently
executing the ast_sched_del function waits until it has completed.
This is accomplished using ast_cond_wait. Unfortunately the
ast_cond_wait function can suffer from spurious wakeups so the
predicate needs to be checked after it returns to make sure it has
really woken up as a result of being signaled.

This change adds a loop around the ast_cond_wait to make sure that
it only exits when the executing task has really completed.

ASTERISK-25355 #close

Change-Id: I51198270eb0b637c956c61aa409f46283432be61
2015-08-28 20:04:53 -05:00
Joshua Colp 229b95d253 res_pjsip_session: Don't invoke session supplements twice for BYE requests.
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-28 06:44:21 -05:00
Joshua Colp 388e628120 Merge "res_pjsip: Add common ast_sip_get_host_ip API." 2015-08-27 15:41:54 -05:00
Mark Michelson 4a540721d1 Merge "Chaos: make hangup NULL tolerant" 2015-08-27 14:53:46 -05:00
Scott Griepentrog 6bfa14bdad Chaos: handle failed allocation in get_media_encryption_type
If the ast_strndup() call fails to allocate a copy of the
transport string for parsing, fail gracefully.

ASTERISK-25323
Reported by: Scott Griepentrog

Change-Id: Ia4b905ce6d03da53fea526224455c1044b1a5a28
2015-08-26 15:26:00 -05:00
Scott Griepentrog 490db8ba94 Chaos: make hangup NULL tolerant
In chan_pjsip_new, if allocation of the pvt
structure fails, ast_hangup is called.  But
it was written to assume pvt was valid, and
this change corrects that.

ASTERISK-25323
Reported by: Scott Griepentrog

Change-Id: I5f47860fe9cee4cd56abd3f79b108678ab72cc87
2015-08-26 14:34:18 -05:00
Joshua Colp d03d09aad3 chan_sip: Allow call pickup to set the hangup cause.
The call pickup implementation in chan_sip currently sets the channel
hangup cause to "normal clearing" if call pickup is successfully
performed. This action overwrites the "answered elsewhere" hangup cause
set by the call pickup code and can result in the SIP device in
question showing a missed call when it should not.

This change sets the hangup cause to "normal clearing" as a
default initially but allows the call pickup to change it as
needed.

ASTERISK-25346 #close

Change-Id: I00ac2c269cee9e29586ee2c65e83c70e52a02cff
2015-08-26 06:08:43 -05: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
Mark Michelson 6b8734fe68 Merge "res_pjsip_pubsub: On recreated notify fail deleted sub_tree is referenced" 2015-08-24 17:16:48 -05:00
Mark Michelson d36c8aa006 Merge "bridge: Kick channel from bridge if hung up during action." 2015-08-24 17:12:06 -05:00
Joshua Colp 3108820000 Merge "res_pjsip/pjsip_configuration: Disregard empty auth values" 2015-08-24 13:59:32 -05:00
Joshua Colp 98d089fb9a bridge: Kick channel from bridge if hung up during action.
When executing an action in a bridge it is possible for the
channel to be hung up without the bridge becoming aware of it.
This is most easily reproducible by hanging up when the bridge
is streaming DTMF due to a feature timeout. This change makes
it so after action execution the channel is checked to determine
if it has been hung up and if it has it is kicked from the bridge.

ASTERISK-25341 #close

Change-Id: I6dd8b0c3f5888da1c57afed9e8a802ae0a053062
2015-08-24 11:12:57 -05:00
Joshua Colp a408369bac res_pjsip_pubsub: On recreated notify fail deleted sub_tree is referenced
When recreating a subscription it is possible for a freed sub_tree
to be referenced when the initial NOTIFY fails to be created.

Change-Id: I681c215309aad01b21d611c2de47b3b0a6022788
2015-08-24 11:09:05 -05:00
Matt Jordan 3af34441eb res_pjsip/pjsip_configuration: Disregard empty auth values
When an endpoint is backed by a non-static conf file backend (such as
the AstDB or Realtime), the 'auth' object may be returned as being an
empty string. Currently, res_pjsip will interpret that as being a valid
auth object, and will attempt to authenticate inbound requests. This
isn't desired; is an auth value is empty (which the name of an auth
object cannot be), we should instead interpret that as being an invalid
auth object and skip it.

ASTERISK-25339 #close

Change-Id: Ic32b0c6eb5575107d5164a8c40099e687cd722c7
2015-08-23 18:43:55 -05:00
Rodrigo Ramírez Norambuena 89003ea320 README*: Remove trailing whitespace
Change-Id: I18b7d75187548a9ed55b4f258d21aaaf29d08874
2015-08-22 00:37:23 -04:00
Richard Mudgett 857923d9c7 chan_sip.c: Set preferred rx payload type mapping on incoming offers.
ASTERISK-25166
Reported by: Kevin Harwell

ASTERISK-17410
Reported by: Boris Fox

Change-Id: I7f04d5c8bee1126fee5fe6afbc39e45104469f4e
2015-08-20 11:56:14 -05:00
Richard Mudgett d643b206c6 res_pjsip_sdp_rtp.c: Set preferred rx payload type mapping on incoming offers.
ASTERISK-25166
Reported by: Kevin Harwell

ASTERISK-17410
Reported by: Boris Fox

Change-Id: I97ecebc1ab9b5654fb918bf1f4c98c956b852369
2015-08-20 11:56:14 -05:00
Richard Mudgett f7df3e1a01 rtp_engine.c: Get current or create a needed rx payload type mapping.
* Make ast_rtp_codecs_payload_code() get the current mapping or create a
rx payload type mapping.

ASTERISK-25166
Reported by: Kevin Harwell

ASTERISK-17410
Reported by: Boris Fox

Change-Id: Ia4b2d45877a8f004f6ce3840e3d8afe533384e56
2015-08-20 11:56:13 -05:00
Richard Mudgett 38854a9f7b rtp_engine.c: Extract rtp_codecs_payload_replace_rx().
ASTERISK-25166
Reported by: Kevin Harwell

ASTERISK-17410
Reported by: Boris Fox

Change-Id: I34e23bf5b084c8570f9c3e6ccd19b95fe85af239
2015-08-19 17:09:58 -05:00
Richard Mudgett 1a549ed134 rtp_engine.c: Initial split of payload types into rx and tx mappings.
There are numerous problems with the current implementation of the RTP
payload type mapping in Asterisk.  It uses only one mapping structure to
associate payload types to codecs.  The single mapping is overkill if all
of the payload type values are well known values.  Dynamic payload type
mappings do not work as well with the single mapping because RFC3264
allows each side of the link to negotiate different dynamic mappings for
what they want to receive.  Not only could you have the same codec mapped
for sending and receiving on different payload types you could wind up
with the same payload type mapped to different codecs for each direction.

1) An independent payload type mapping is needed for sending and
receiving.

2) The receive mapping needs to keep track of previous mappings because of
the slack to when negotiation happens and current packets in flight using
the old mapping arrive.

3) The transmit mapping only needs to keep track of the current negotiated
values since we are sending the packets and know when the switchover takes
place.

* Needed to create ast_rtp_codecs_payload_code_tx() and make some callers
use the new function because ast_rtp_codecs_payload_code() was used for
mappings in both directions.

* Needed to create ast_rtp_codecs_payloads_xover() for cases where we need
to pass preferred codec mappings to the peer channel for early media
bridging or when we need to prefer the offered mapping that RFC3264 says
we SHOULD use.

* ast_rtp_codecs_payloads_xover() and ast_rtp_codecs_payload_code_tx() are
the only new public functions created.  All the others were only used for
the tx or rx mapping direction so the function doxygen now reflects which
direction the function operates.

* chan_mgcp.c: Removed call to ast_rtp_codecs_payloads_clear() as doing
that makes no sense when processing an incoming SDP.  We would be wiping
out any mappings that we set for the possible outgoing SDP we sent
earlier.

ASTERISK-25166
Reported by: Kevin Harwell

ASTERISK-17410
Reported by: Boris Fox

Change-Id: Iaf6c227bca68cb7c414cf2fd4108a8ac98bd45ac
2015-08-19 17:09:58 -05:00
Mark Michelson aacb46b56a Merge "res_ari_events: Fix shutdown ref leak." 2015-08-19 17:06:51 -05:00
Mark Michelson 26fca72837 Merge "app_queue.c: Extract some functions for simpler code." 2015-08-19 17:03:35 -05:00
Mark Michelson 192693c2c1 Merge "res_http_websocket.c: Add missing unref on an off nominal path." 2015-08-19 16:56:35 -05:00
Mark Michelson 5d6b93a006 Merge "ari/ari_websockets.c: Fix ast_debug parameter type mismatch." 2015-08-19 16:55:48 -05:00
Richard Mudgett 21d419e4fc ari/ari_websockets.c: Fix ast_debug parameter type mismatch.
This is a type mismatch fix of the debugging commit
c63316eec1 made to find out why
a testsuite test was failing only on one of the continuous
integration build agents.

Change-Id: Iba34f6e87cec331f6ac80e4daff6476ea6f00a75
2015-08-19 12:10:18 -05:00
Scott Griepentrog 53e2a6a829 contrib: script install_prereq should install sqlite3
Asterisk needs the sqlite 3 library, which is package
sqlite-devel in CentOS. By adding this package to the
script, a problem with configure failing is resolved.

ASTERISK-25331 #close
Reported by: Kevin Harwell

Change-Id: I90efaf6a01914fea03f21e5cdbd91c348f44b0ec
2015-08-19 10:30:12 -05:00
Matt Jordan a260cee5cb Merge "res_http_websocket.c: Fix some off nominal path cleanup." 2015-08-19 08:42:56 -05:00
Matt Jordan 2d20379f8e Merge "app_queue.c: Fix setting QUEUE_MEMBER 'paused' and 'ringinuse'." 2015-08-19 08:40:39 -05:00