Commit Graph

27345 Commits

Author SHA1 Message Date
Richard Mudgett
2b992014dc chan_sip: Fix crash involving the bogus peer during sip reload.
A crash happens sometimes when performing a CLI "sip reload".  The bogus
peer gets refreshed while it is in use by a new call which can cause the
crash.

* Protected the global bogus peer object with an ao2 global object
container.

ASTERISK-25610 #close

Change-Id: I5b528c742195681abcf713c6e1011ea65354eeed
2015-12-07 10:55:54 -06:00
Joshua Colp
eb9a353490 Merge "res_pjsip/contacts/statsd: Make contact lifecycle events more consistent" into 13 2015-12-07 07:51:28 -06:00
Matt Jordan
529535f0c2 Revert "bridges/bridge_t38: Add a bridging module for managing T.38 state"
This reverts commit 6614babea2.

Unfortunately, using a bridge to manage T.38 state will cause severe deadlocks
in core_unreal/chan_local. Local channels attempt to reach across both their
peer and the peer's bridge to inspect T.38 state. Given the propensity of
Local channel chains, managing the locking situation in such a scenario is
practically infeasible.

Change-Id: Ic687397ffea08dfb899345a443bd990ec3d0416a
2015-12-06 16:32:32 -06:00
George Joseph
450579e908 res_pjsip/contacts/statsd: Make contact lifecycle events more consistent
It will never be perfect or even pretty, mostly because of the differences
between static and dynamic contacts.

Created:

Can't use the contact or contact_status alloc functions
because the objects come and go regardless of the actual state.

Can't use the contact_apply_handler, ast_sip_location_add_contact or
a sorcery created handler because they only get called for dynamic
contacts.  Similarly, permanent_uri_handler only gets called for
static contacts.

So, Matt had it right. :)  ast_res_pjsip_find_or_create_contact_status is
the only place it can go and not have duplicated code.  Both
permanent_uri_handler and contact_apply_handler call find_or_create.

Removed:

Can't use the destructors for the same reason as above.  The only
place to put this is in persistent_endpoint_contact_deleted_observer
which I believe is the "correct" place but even that will handle only
dynamic contacts.  This doesn't called on shutdown however.  There is
no hook to use for static contacts that may be removed because of a
config change while asterisk is in operation.

I moved the cleanup of contact_status from ast_sip_location_delete_contact
to the handler as well.

Status Change and RTT:

Although they worked fine where they were (in update_contact_status) I
moved them to persistent_endpoint_contact_status_observer to make it
more consistent with removed.  There was logic there already to detect
a state change.

Finally, fixed a nit in permanent_uri_handler rmudgett reported
eralier.

ASTERISK-25608 #close

Change-Id: I4b56e7dfc3be3baaaf6f1eac5b2068a0b79e357d
Reported-by: George Joseph
Tested-by: George Joseph
2015-12-04 16:50:17 -07:00
Matt Jordan
9c0aaf0609 Merge "res_format_attr_vp8: In SDP, forward max-fr and max-fs for video-codec VP8." into 13 2015-12-04 11:34:12 -06:00
Matt Jordan
ffb0643467 Merge "res_format_attr_opus: Update to latest RFC 7587." into 13 2015-12-04 11:34:07 -06:00
Matt Jordan
e8f78f87a8 Merge "bridges/bridge_t38: Add a bridging module for managing T.38 state" into 13 2015-12-04 08:58:01 -06:00
Alexander Traud
5a18193dc0 res_format_attr_vp8: In SDP, forward max-fr and max-fs for video-codec VP8.
ASTERISK-25584 #close

Change-Id: Iae00071b4ff1ae76f24995aeac4d00284fd14f91
2015-12-04 08:57:50 -06:00
Alexander Traud
3e2178c05e res_format_attr_opus: Update to latest RFC 7587.
Beside that, the format-attribute module sends only non-default values in the
line fmtp, now. This avoids unnecessary overhead in SDP messages. Furthermore,
previously the parameter stereo was not parsed when being the first parameter.

ASTERISK-25583 #close

Change-Id: Iae85ba3e5960bfd5d51cf65bcffad00dd4875a73
2015-12-04 07:21:06 -06:00
Jonathan Rose
072d94183c Fix crash in audiohook translate to slin
This patch fixes a crash which would occur when an audiohook was
applied to a channel using an audio codec that could not be translated
to signed linear (such as when using pass-through codecs like OPUS or
when the codec translator module for the format in use is not loaded).

ASTERISK-25498 #close
Reported by: Ben Langfeld

Change-Id: Ib6ea7373fcc22e537cad373996136636201f4384
2015-12-03 16:04:39 -06:00
Joshua Colp
cfb146e055 Merge "res_pjsip: Use a MD5 hash for static Contact IDs" into 13 2015-12-03 15:51:45 -06:00
Joshua Colp
59134eb7cb Merge "res_pjsip: Update logging to show contact->uri in messages" into 13 2015-12-03 12:39:08 -06:00
Joshua Colp
1d5ddb4b99 Merge "codec_resample: Increase buffer for Opus Codec." into 13 2015-12-03 12:38:08 -06:00
George Joseph
9184fbeb34 res_pjsip: Use a MD5 hash for static Contact IDs
When 90d9a70789 was merged, it mostly tested dynamic contacts created as
a result of registering a PJSIP endpoint. Contacts generated in this
fashion typically have a long alphanumeric string as their object identifier,
which maps reasonably well for StatsD. Unfortunately, this doesn't work in the
general case. StatsD treats both '.' and ':' characters as special characters.
In particular, having a ':' appear in the middle of a StatsD metric will
result in the metric being rejected.

This causes some obvious issues with SIP URIs.

The StatsD API should not be responsible for escaping the metric name passed
to it. The metric is treated as a single long string, and it would be
challenging to know what to escape in the string passed to the function.
Likewise, we don't want to escape the metric in PJSIP, as that involves
overhead that is wasted when either res_statsd isn't loaded or enabled.

This patch takes an alternative approach. The Contact ID has been changed
to be "aor@@uri_hash" instead of "aor@@uri". This (a) won't contain any of the
aforementioned special characters, (b) can be done on Contact creation,
which has minimal impact on run-time performance, and (c) also conforms to an
earlier commit that changed the ID for dynamic contacts.

The downside of this is that StatsD users will have to map SHA1 hashes back to
the Contacts that are emitting the statistics. To that end, the CLI commands
have been updated to include the first 10 characters of the MD5 hash, which
should be enough to match what is shown in Graphite (or some other StatsD
backend).

ASTERISK-25595 #close

Change-Id: Ic674a3307280365b4a45864a3571c295b48a01e2
Reported-by: Matt Jordan
Tested-by: George Joseph
2015-12-03 11:07:49 -07:00
Joshua Colp
8ab0c2107a Merge "res_sorcery_memory_cache.c: Fix off nominal ref leak." into 13 2015-12-03 05:51:17 -06:00
Joshua Colp
3b1452b542 Merge "sched.c: Make not return a sched id of 0." into 13 2015-12-03 05:50:43 -06:00
Joshua Colp
53d4f77064 Merge topic 'ASTERISK-25476' into 13
* changes:
  Audit improper usage of scheduler exposed by 5c713fdf18. (v13 additions)
  Audit improper usage of scheduler exposed by 5c713fdf18.
2015-12-03 05:50:04 -06:00
George Joseph
ed9134282e res_pjsip: Update logging to show contact->uri in messages
An earlier commit changed the id of dynamic contacts to contain
a hash instead of the uri.  This patch updates status change
logging to show the aor/uri instead of the id.  This required
adding the aor id to contact and contact_status and adding
uri to contact_status.  The aor id gets added to contact and
contact_status in their allocators and the uri gets added to
contact_status in pjsip_options when the contact_status is
created or updated.

ASTERISK-25598 #close

Reported-by: George Joseph
Tested-by: George Joseph

Change-Id: I56cbec1d2ddbe8461367dd8b6da8a6f47f6fe511
2015-12-02 19:32:26 -07:00
Jonathan Rose
eadad24b59 Unset BRIDGEPEER when leaving a bridge
Currently if a channel is transferred out of a bridge, the BRIDGEPEER
variable (also BRIDGEPVTCALLID) remain set even once the channel is
out of the bridge. This patch removes these variables when leaving
the bridge.

ASTERISK-25600 #close
Reported by: Mark Michelson

Change-Id: I753ead2fffbfc65427ed4e9244c7066610e546da
2015-12-02 12:57:04 -06:00
Richard Mudgett
bb0b60619d res_sorcery_memory_cache.c: Fix off nominal ref leak.
Change-Id: If83d63cf11cbc6df9b15251848b01feb570ade49
2015-12-01 13:53:18 -06:00
Richard Mudgett
e7c88e11aa sched.c: Make not return a sched id of 0.
According to the API doxygen a sched ID of 0 is valid.  Unfortunately, 0
was never returned historically and several users incorrectly coded usage
of the returned sched ID assuming that 0 was invalid.

ASTERISK-25476

Change-Id: Ib19c7ebb44ec9fd393ef6646dea806d4f34e3a20
2015-12-01 13:53:18 -06:00
Richard Mudgett
4aed349a7b Audit improper usage of scheduler exposed by 5c713fdf18. (v13 additions)
chan_sip.c:
* Initialize mwi subscription scheduler ids earlier because of ASTOBJ to
ao2 conversion.

* Initialize register scheduler ids earlier because of ASTOBJ to ao2
conversion.

chan_skinny.c:
* Fix more scheduler usage for the valid 0 id value.

ASTERISK-25476

Change-Id: If9f0e5d99638b2f9d102d1ebc9c5a14b2d706e95
2015-12-01 13:53:18 -06:00
Richard Mudgett
6d9156d10f Audit improper usage of scheduler exposed by 5c713fdf18.
channels/chan_iax2.c:
* Initialize struct chan_iax2_pvt scheduler ids earlier because of
iax2_destroy_helper().

channels/chan_sip.c:
channels/sip/config_parser.c:
* Fix initialization of scheduler id struct members.  Some off nominal
paths had 0 as a scheduler id to be destroyed when it was never started.

chan_skinny.c:
* Fix some scheduler id comparisons that excluded the valid 0 id.

channel.c:
* Fix channel initialization of the video stream scheduler id.

pbx_dundi.c:
* Fix channel initialization of the packet retransmission scheduler id.

ASTERISK-25476

Change-Id: I07a3449f728f671d326a22fcbd071f150ba2e8c8
2015-12-01 13:53:18 -06:00
Alexander Traud
b76c196e13 codec_resample: Increase buffer for Opus Codec.
ASTERISK-25599 #close

Change-Id: I1f88a88c59fb4e1e62bbdbb100c7152d48e73f10
2015-12-01 07:59:19 -06:00
Matt Jordan
6614babea2 bridges/bridge_t38: Add a bridging module for managing T.38 state
When 4875e5ac32 was merged, it fixed several issues with a direct media bridge
transitioning to handling a T.38 fax. However, it uncovered a race condition
caused by the bridging core. When a channel involved in a T.38 fax leaves a
bridge, the frame queued by the channel driver that should inform the far side
that it is no longer in a T.38 fax may not make it across the bridge. The
bridging framework is *extremely* aggressive in tearing down the bridge, and
control frames that are currently in flight *may* get dropped.

This patch adds a new module to the bridging framework, bridge_t38. This module
maintains some notion of the T.38 state for the two channels in a bridge. When
the bridge detects that it is being torn down or when one of the two channels
leaves, it informs the respective channel(s) that they should stop faxing. This
ensures that channels switch back to audio if they survive and are ejected out
of a bridge while faxing.

ASTERISK-25582

Change-Id: If5b0bb478eb01c4607c9f4a7fc17c7957d260ea0
2015-11-30 20:11:43 -06:00
Niklas Larsson
3fcf160fae CHANGES: Fix a typo
Change-Id: Iceb3d9bb78140c376174a7bee197dfcf8ef9cda7
2015-11-27 10:24:57 -06:00
Matt Jordan
762dc9c89d Merge "fastagi: record file closed after sending result" into 13 2015-11-25 22:19:16 -06:00
Matt Jordan
5d80a6e714 Merge "main: Slight refactor of main. Improve color situation." into 13 2015-11-25 22:17:43 -06:00
Kevin Harwell
45efbf8503 fastagi: record file closed after sending result
The fastagi record-file testsuite test sometimes fails reporting an empty
recorded file. This was happening because Asterisk was sending the agi result
notification prior to actually closing the file and the data, being buffered,
had not been written to the file yet when the test attempts to check the file
size.

This patch makes it so the record file stream is closed prior to sending the
agi result notification.

ASTERISK-25593 #close

Change-Id: I6b2b3be3ae37f7c7b18e672c419a89b3b8513cde
2015-11-25 15:33:29 -06:00
Walter Doekes
b2787876d6 main: Slight refactor of main. Improve color situation.
Several issues are addressed here:
- main() is large, and half of it is only used if we're not rasterisk;
  fixed by spliting up the daemon part into a separate function.
- Call ast_term_init from rasterisk as well.
- Remove duplicate code reading/writing asterisk history file.
- Attempt to tackle background color issues and color changes that
  occur. Tested by starting asterisk -c until the colors stopped
  changing at odd locations.

ASTERISK-25585 #close

Change-Id: Ib641a0964c59ef9fe6f59efa8ccb481a9580c52f
2015-11-25 20:29:42 +01:00
Matt Jordan
e96604c902 Merge "Fixed some typos" into 13 2015-11-24 20:23:06 -06:00
David M. Lee
59881fbb99 Fixed some typos
Fixes some minor typos in the CHANGES file, plus an embarrasing typo in
the StatsD API.

Change-Id: I9ca4858c64a4a07d2643b81baa64baebb27a4eb7
2015-11-24 13:54:54 -06:00
Corey Farrell
b75f587d15 res_pjsip_notify: Fix CLI usage info
The usage info for 'pjsip send notify' previously referenced the
chan_sip configuration sip_notify.conf.  Fix this to reference
the correct configuration pjsip_notify.conf.

ASTERISK-25590 #close

Change-Id: I3898271a8e8a8b1db201741e790ebe2c6bf5cdea
2015-11-24 14:07:12 -05:00
Joshua Colp
3f85a1be5a Merge "translate: Provide translation modules the result of SDP negotiation." into 13 2015-11-24 08:20:52 -06:00
Mark Michelson
ba7665b070 Merge "res_sorcery_realtime.c: Fix crash from NULL sorcery object type." into 13 2015-11-23 18:04:53 -06:00
Richard Mudgett
fc45f4040d res_sorcery_realtime.c: Fix crash from NULL sorcery object type.
If the sorcery object type is not found a NULL is returned.
Unfortunately, sorcery_realtime_filter_objectset() will crash after
complaining about not finding the object type and saying to expect errors.

* Use ao2_cleanup() instead of ao2_ref() to prevent the crash.

ASTERISK-25165
Reported by Corey Farrell

Change-Id: Ic3b64453ea3058cb68d5c26d97d4fe7b8eea2e97
2015-11-23 14:42:31 -06:00
Matt Jordan
7e4d948397 Merge "chan_pjsip: Handle T.38 faxes with direct media bridges" into 13 2015-11-23 13:33:06 -06:00
Matt Jordan
25332911fe Merge "res/res_endpoint_stats: Add module to emit endpoint StatsD statistics" into 13 2015-11-23 09:26:49 -06:00
Matt Jordan
6a7cb60a47 Merge "res_pjsip/pjsip_options: Add StatsD statistics for PJSIP contacts" into 13 2015-11-23 09:26:35 -06:00
Matt Jordan
16437667eb Merge "res/res_pjsip_outbound_registration: Add registration statistics for StatsD" into 13 2015-11-23 09:26:15 -06:00
Matt Jordan
001b7f482b Merge "res_statsd: Add functions that support variable arguments" into 13 2015-11-23 08:43:29 -06:00
Matt Jordan
0f88f909ec Merge "StatsD: Add res_statsd compatibility" into 13 2015-11-22 22:38:21 -06:00
Matt Jordan
4875e5ac32 chan_pjsip: Handle T.38 faxes with direct media bridges
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-22 22:35:08 -06:00
Joshua Colp
fa969196b3 Merge "main/cli: Use proper string methods to check existence of context/exten/app" into 13 2015-11-21 11:36:48 -06:00
Joshua Colp
6dd8b67216 Merge "res/res_pjsip_t38: Add debug statements" into 13 2015-11-21 11:14:14 -06:00
Matt Jordan
aa8f1b04b6 Merge "res_pjsip_outbound_registration.c: Be tolerant of short registration timeouts." into 13 2015-11-21 10:57:12 -06:00
Matt Jordan
2b94d9a10d res/res_pjsip_t38: Add debug statements
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-11-21 08:50:53 -06:00
Matt Jordan
af288b2d96 main/cli: Use proper string methods to check existence of context/exten/app
Because the context, extension, and application are stored in stringfields,
checking for them being NULL doesn't work so well. This patch uses the
appropriate string library call, ast_strlen_zero, to see if there is a value
in the context/exten/app values.

Change-Id: Ie09623bfdf35f5a8d3b23dd596647fe3c97b9a23
2015-11-20 22:02:45 -06:00
Mark Michelson
6fcd361540 Merge "res_pjsip_outbound_registration.c: Fix 423 response handling." into 13 2015-11-20 13:03:18 -06:00
Joshua Colp
bdc7845a43 Merge "res_format_attr_h264: Do not reset string buffer." into 13 2015-11-20 09:20:51 -06:00