Commit Graph

729 Commits

Author SHA1 Message Date
Jenkins2 6753c08feb Merge "install_prereq: Support package manager DNF and yum option strict=1." 2018-01-24 07:48:58 -06:00
Alexander Traud fd557ad041 install_prereq: For PJProject, point users to configure script.
The installation script and the new configure option --with-pjproject-bundled
aimed to accomplish the same. However, the installation script was out of
date. Users should go for the maintained configure option, or the Wiki.

ASTERISK-24598

Change-Id: Icbf4b562f81f7c05bd24a3805bd46c0beb4ebd44
2018-01-22 09:02:08 -06:00
Alexander Traud 93471373f6 install_prereq: Update Debian/Ubuntu libraries.
ASTERISK-27555

Change-Id: Ieb41b0cbf968af12882b39454b819ebb48b9ea46
2018-01-19 13:16:36 +01:00
Alexander Traud 4c511c1a4d install_prereq: Support package manager DNF and yum option strict=1.
This re-enables the script ./contrib/scripts/install_prereq on Fedora 22 and
newer, and on RHEL/CentOS when the option strict=1 was set for yum install.

ASTERISK-27598
Reported by: Hunter Stevens, Said Masoud

Change-Id: I40f9517122aaa6906e8fc0962b4b8008dfddb368
2018-01-19 11:46:21 +01:00
Richard Mudgett 8494e78010 res_pjsip: Split type=identify to IP address and SIP header matching priorities
The type=identify endpoint identification method can match by IP address
and by SIP header.  However, the SIP header matching has limited
usefulness because you cannot specify the SIP header matching priority
relative to the IP address matching.  All the matching happens at the same
priority and the order of evaluating the identify sections is
indeterminate.  e.g., If you had two type=identify sections where one
matches by IP address for endpoint alice and the other matches by SIP
header for endpoint bob then you couldn't predict which endpoint is
matched when a request comes in that matches both.

* Extract the SIP header matching criteria into its own "header" endpoint
identification method so the user can specify the relative priority of the
SIP header and the IP address matching criteria in the global
endpoint_identifier_order option.  The "ip" endpoint identification method
now only matches by IP address.

ASTERISK-27491

Change-Id: I9df142a575b7e1e3471b7cda5d3ea156cef08095
2018-01-16 12:50:34 -06:00
Alexander Traud b9e2b72de6 install_prereq: Update Debian/Ubuntu libraries.
ASTERISK-27555

Change-Id: I0818b6e42631be1b69237e2b41d3415275693e53
2018-01-12 08:05:48 +01:00
Sean Bright fd0ca1c3f9 Remove as much trailing whitespace as possible.
Change-Id: I873c1c6d00f447269bd841494459efccdd2c19c0
2017-12-22 09:23:22 -05:00
Sean Bright a1a179c09d Fix some invalid Unicode characters
configs/samples/minivm.conf.sample contains invalid UTF-8, but that
appears to be intentional.

Change-Id: I7b1e0d332f3380fd0425962a3c9c55f9b200c8cc
2017-12-21 10:26:53 -06:00
Rodrigo Ramírez Norambuena 5335ad117d app_queue: Add feature to set wrapuptime on the queue member
This patch adds the ability to set the wrapuptime on the queue member
config.

When the option is set the wrapuptime on the queue member is used instead
of the queue's wrapuptime.

ASTERISK-27483 #close

Change-Id: I11c85809537f974eb44dc5bbf82bcedd8a458902
2017-12-18 17:29:21 -06:00
George Joseph cf1cb3345e ast_coredumper: Add ability to use directory other than /tmp
The OUTPUTDIR environment variable can now be set either in the
environment itself or in ast_debug_tools.conf.  If set, it's used
for all work products instead of /tmp.

Also added the --tarball-config option that includes the contents
of /etc/asterisk when either --tarball-coredumps or --tarball-results
are used.

Change-Id: I66b2553319df61caea5b313d084f51978f730b4c
2017-11-15 10:43:44 -05:00
Joshua Colp 637b37fb98 Merge "dtls: Add support for ephemeral DTLS certificates." 2017-11-06 12:22:38 -06:00
Sean Bright 04d3785a79 dtls: Add support for ephemeral DTLS certificates.
This mimics the behavior of Chrome and Firefox and creates an ephemeral
X.509 certificate for each DTLS session.

Currently, the only supported key type is ECDSA because of its faster
generation time, but other key types can be added in the future as
necessary.

ASTERISK-27395

Change-Id: I5122e5f4b83c6320cc17407a187fcf491daf30b4
2017-11-06 08:11:48 -05:00
Alexander Traud 2ebea5aa03 install_prereq: Checkout of libSRTP 2.x.
Since Asterisk 13.17, libSRTP 2.x is supported. Therefore, its latest version
is installed again via the script install_prereq.

ASTERISK-27356

Change-Id: I13125839a79052356469e41edacbebff0a937d39
2017-11-04 12:05:36 +01:00
Joshua Colp d05391ed55 Merge "ast_coredumper: allow setting asterisk binary explicitly" 2017-10-31 06:48:16 -05:00
Joshua Colp be5b7b2076 Merge "alembic: Add bundle column in ps_endpoints table" 2017-10-30 11:56:56 -05:00
Joshua Colp 15466f225c Merge "ast_coredumper: Add gzipping of binaries and display of signal info" 2017-10-30 10:53:42 -05:00
Tzafrir Cohen 022de525be ast_coredumper: allow setting asterisk binary explicitly
Adds an extra option, --asterisk-bin=<path> to ast_coredumper. If
provided, the binary given to gdb will be the parameter, rather than
asterisk from the PATH.

ASTERISK-27380 #close

Change-Id: I25f5b91eb75059b0fb2f142e468c26b283b0a9f3
2017-10-30 16:20:18 +02:00
Florian Floimair 3052b56423 alembic: Add bundle column in ps_endpoints table
The ps_endpoints table was missing the bundle column
introduced with the bundle feature in
commit 065c3005ad.

ASTERISK-27374 #close

Change-Id: Ic900f4f2c20f64b99ea898d50f5c0a7117472d46
2017-10-30 08:36:59 -05:00
Joshua Colp 9e1fbab382 res_pjsip: Add 'ip' as a valid option to 'identify_by' on endpoint.
When the identify_by option on an endpoint is set to ip it will
only be identified using the res_pjsip_endpoint_identifier_ip module.
This ensures that it is not mistakenly matched using the username of
the From header. To ensure behavior has not changed the default has
been changed to "username,ip" for the identify_by option.

ASTERISK-27206

Change-Id: I2170b86a7f7e221b4f00bf14aa1ef1ac5b050bbd
2017-10-25 18:14:03 +00:00
George Joseph 4aec70690d ast_coredumper: Add gzipping of binaries and display of signal info
The --tarball-coredump option now creates a gzipped tarball of
coredumps processed, their results txt files and copies of
/etc/os-release, /usr/sbin/asterisk, /usr/lib(64)/libasterisk* and
/usr/lib(64)/asterisk as those files are needed to properly examine
the coredump.  The file will be named
/tmp/asterisk.<timestamp>.coredumps.tar.gz or
/tmp/asterisk-<uniqueid>.coredumps.tar.gz if --tarball-uniqueid was
specified.

Added dumps of *_siginfo to the top of the txt files so you can
tell what signal was invoked.

Change-Id: Ib9ee6d83592d4b1bc90cb3419a05376a88d1ded9
2017-10-25 12:28:21 -05:00
Torrey Searle da24d425eb contrib/script/sip_to_pjsip: implement 'all' for allow/disallow
when 'all' is specified in an allow or disallow section, it should erase
all values from the inverse section in the default config. E.G.
allow=all should erase any deny values from default config &
vice-versa

ASTERISK-27333 #close

Change-Id: I99219478fb98f08751d769daaee0b7795118a5a6
2017-10-16 06:26:16 -05:00
Torrey Searle b1d9fc87bc contrib/thirdparty/sip_to_pjsip: add additional flag mappings
add mappings for udptl redundancy, rtptimeout, and debug flags

Change-Id: Ie73cf5c83c05dee01eb9624ede76c1a30225d73a
2017-10-10 10:50:24 -05:00
George Joseph 446d48fd49 res_pjsip: Add handling for incoming unsolicited MWI NOTIFY
A new endpoint parameter "incoming_mwi_mailbox" allows Asterisk to
receive unsolicited MWI NOTIFY requests and make them available to
other modules via the stasis message bus.

res_pjsip_pubsub has a new handler "pubsub_on_rx_mwi_notify_request"
that parses a simple-message-summary body and, if
endpoint->incoming_mwi_account is set, calls ast_publish_mwi_state
with the voice-message counts from the message.

Change-Id: I08bae3d16e77af48fcccc2c936acce8fc0ef0f3c
2017-09-13 09:24:28 -05:00
Jenkins2 ec940f4fec Merge "alembic: Fix typo in add_auto_info_to_endpoint_dtmf_mode" 2017-09-12 14:30:41 -05:00
George Joseph f9bad3bd61 alembic: Fix typo in add_auto_info_to_endpoint_dtmf_mode
The downgrade function was missing "_v2" at the end of the
alter column type.

Change-Id: Iaa9bcef48d6f3590ce07a61342d8e66f00263d8e
2017-09-11 05:54:57 -05:00
Florian Floimair e9a81157ac alembic: Add support for MS-SQL
MS-SQL has no native Enum-type support and therefore
needs to work with constraints.
Since these constraints need unique names the suggested approach
referenced in the following alembic documentation has been applied:
http://bit.ly/2x9r8pb

ASTERISK-27255 #close

Change-Id: I8b579750dae0c549f1103ee50172644afb9b2f95
2017-09-08 11:51:20 -05:00
George Joseph 2857a3334a Merge "alembic: Fix enum creation for dtls_fingerprint" 2017-09-06 11:52:26 -05:00
George Joseph 0cbb17ce8f alembic: Fix enum creation for dtls_fingerprint
Change-Id: Ic061c5066a146616a68376881c7e4cf6d6e7e7db
2017-09-06 07:57:31 -05:00
Florian Floimair a133c5cc53 alembic: fix erroneous commit for add_prune_on_boot
Added include for postgresql ENUM type and
redefined values in the same way as in the
other migration scripts.

ASTERISK-27254 #close

Change-Id: Id667304cdf3891b1c2f7d35fab3e2a84026159fa
2017-09-06 06:00:55 -05:00
Florian Floimair 2ee644aacf alembic: Add dtls_fingerprint column in ps_endpoints table
The ps_endpoints table was missing the dtls_fingerprint column
introduced with commit adba2a8d7f.

ASTERISK-27168 #close

Change-Id: I9cb5006f7f50718b5239919562773adabb334cfd
2017-08-25 08:11:04 -05:00
Richard Mudgett 82f4ade959 res_pjsip: Remove ephemeral registered contacts on transport shutdown.
The fix for the issue is broken up into three parts.

This is part two which handles the server side of REGISTER requests when
rewrite_contact is enabled.  Any registered reliable transport contact
becomes invalid when the transport connection becomes disconnected.

* Monitor the rewrite_contact's reliable transport REGISTER contact for
shutdown.  If it is shutdown then the contact must be removed because it
is no longer valid.  Otherwise, when the client attempts to re-REGISTER it
may be blocked because the invalid contact is there.  Also if we try to
send a call to the endpoint using the invalid contact then the endpoint is
not likely to see the request.  The endpoint either won't be listening on
that port for new connections or a NAT/firewall will block it.

* Prune any rewrite_contact's registered reliable transport contacts on
boot.  The reliable transport no longer exists so the contact is invalid.

* Websockets always rewrite the REGISTER contact address and the transport
needs to be monitored for shutdown.

* Made the websocket transport set a unique name since that is what we use
as the ao2 container key.  Otherwise, we would not know which transport we
find when one of them shuts down.  The names are also used for PJPROJECT
debug logging.

* Made the websocket transport post the PJSIP_TP_STATE_CONNECTED state
event.  Now the global keep_alive_interval option, initially idle shutdown
timer, and the server REGISTER contact monitor can work on wetsocket
transports.

* Made the websocket transport set the PJSIP_TP_DIR_INCOMING direction.
Now initially idle websockets will automatically shutdown.

ASTERISK-27147

Change-Id: I397a5e7d18476830f7ffe1726adf9ee6c15964f4
2017-08-10 12:18:58 -05:00
Kevin Harwell 521b6fed12 alembic/res_pjsip: Add "webrtc" configuration option
When the "webrtc" option was added in res_pjsip it was not added to the alembic
scripts. This patch adds the option for alembic.

Also, changed the sorcery configuration type to an OPT_YESNO_T value instead of
an OPT_BOOL_T so if this field is ever written to a database it will write out
the correct value.

ASTERISK-27119 #close

Change-Id: I3e199f060aea25e193c439fc5cf96be4d3ed1c7b
2017-08-03 11:44:28 -05:00
Jenkins2 1bec535df2 Merge "Core: Add support for systemd socket activation." 2017-07-26 09:17:40 -05:00
George Joseph ba52a36ff2 Restore the incorrectly deleted spandspflow2pcap.log
Change-Id: Iafe78cf0fb1e7064223d4dea279eeb776c8fa8e5
2017-07-21 10:24:24 -06:00
George Joseph 25459ac083 Merge "corosync: Fix corosync library name in configure.ac" 2017-07-21 06:54:00 -05:00
George Joseph 3e8d628c0e Update AMI and ARI versions for master/15 and update UPDATE.txt
AMI goes from 3.2.0 to 4.0.0
ARI goes from 2.0.0 to 3.0.0

Copied UPGRADE.txt -> UPGRADE-15.txt
Created new UPGRADE.txt
Removed a log file that was accidentally checked in a while ago

Change-Id: I1c794f910038459b13e16f9c3a12c44e56f142f7
2017-07-20 10:05:48 -06:00
Sean Bright 25c9464325 corosync: Fix corosync library name in configure.ac
Also add new corosync packages to install_prereq.

Reported by Travis Ryan in #asterisk-dev

Change-Id: Ib861c95ba630fed62dc54e56784ad8446ed9d2db
2017-07-20 10:40:28 -05:00
George Joseph 7a4f577eb7 Fix alembic branches
Change-Id: I04f607f084bda9b1b7f626e8e9735c37dc751187
2017-07-06 05:00:49 -06:00
Torrey Searle fb7247c57c res_pjsip: Add DTMF INFO Failback mode
The existing auto dtmf mode reverts to inband if 4733 fails to be
negotiated.  This patch adds a new mode auto_info which will
switch to INFO instead of inband if 4733 is not available.

ASTERISK-27066 #close

Change-Id: Id185b11e84afd9191a2f269e8443019047765e91
2017-06-29 07:57:01 -06:00
Mark Michelson 45df25a579 chan_pjsip: Add support for multiple streams of the same type.
The stream topology (list of streams and order) is now stored with the
configured PJSIP endpoints and used during the negotiation process.

Media negotiation state information has been changed to be stored
in a separate object. Two of these objects exist at any one time
on a session. The active media state information is what was previously
negotiated and the pending media state information is what the
media state will become if negotiation succeeds. Streams and other
state information is stored in this object using the index (or
position) of each individual stream for easy lookup.

The ability for a media type handler to specify a callback for
writing has been added as well as the ability to add file
descriptors with a callback which is invoked when data is available
to be read on them. This allows media logic to live outside of
the chan_pjsip module.

Direct media has been changed so that only the first audio and
video stream are directly connected. In the future once the RTP
engine glue API has been updated to know about streams each individual
stream can be directly connected as appropriate.

Media negotiation itself will currently answer all the provided streams
on an offer within configured limits and on an offer will use the
topology created as a result of the disallow/allow codec lines.

If a stream has been removed or declined we will now mark it as such
within the resulting SDP.

Applications can now also request that the stream topology change.
If we are told to do so we will limit any provided formats to the ones
configured on the endpoint and send a re-invite with the new topology.

Two new configuration options have also been added to PJSIP endpoints:

max_audio_streams: determines the maximum number of audio streams to
offer/accept from an endpoint. Defaults to 1.

max_video_streams: determines the maximum number of video streams to
offer/accept from an endpoint. Defaults to 1.

ASTERISK-27076

Change-Id: I8afd8dd2eb538806a39b887af0abd046266e14c7
2017-06-28 18:36:29 +00:00
Corey Farrell 70d2ccb9da Core: Add support for systemd socket activation.
This change adds support for socket activation of certain SOCK_STREAM
listeners in Asterisk:
* AMI / AMI over TLS
* CLI
* HTTP / HTTPS

Example systemd units are provided.  This support extends to any socket
which is initialized using ast_tcptls_server_start, so any unknown
modules using this function will support socket activation.

Asterisk continues to function as normal if socket activation is not
enabled or if systemd development headers are not available during
build.

ASTERISK-27063 #close

Change-Id: Id814ee6a892f4b80d018365c8ad8d89063474f4d
2017-06-19 13:33:48 -04:00
Alexei Gradinari 7a46309d3d res_pjsip: New endpoint option "notify_early_inuse_ringing"
This option was added to control whether to notify dialog-info state
'early' or 'confirmed' on Ringing when already INUSE.
The value "yes" is useful for some SIP phones (Cisco SPA)
to be able to indicate and pick up ringing devices.

ASTERISK-26919 #close

Change-Id: Ie050bc30023543c7dfb4365c5be3ce58c738c711
2017-06-16 11:25:07 -05:00
Alexei Gradinari 808f299808 res_pjsip: New endpoint option "refer_blind_progress"
This option was added to turn off notifying the progress details
on Blind Transfer. If this option is not set then the chan_pjsip
will send NOTIFY "200 OK" immediately after "202 Accepted".

Some SIP phones like Mitel/Aastra or Snom keep the line busy until
receive "200 OK".

ASTERISK-26333 #close

Change-Id: Id606fbff2e02e967c02138457badc399144720f2
2017-05-11 10:50:35 -05:00
Joshua Colp 199d4776c0 alembic: Add table for 'resource_list' PJSIP RLS type.
This change adds an Alembic migration which adds a
ps_resource_list table that can contain resource_list
RLS configuration objects.

ASTERISK-26929

Change-Id: I7c888fafc67b3e87012de974f71ca7a5b8b1ec05
2017-04-25 14:37:58 -05:00
Joshua Colp 270b485f04 pjsip: Add Alembic for PUBLISH support.
This change adds database tables for the PUBLISH support so it
can be configured using realtime. A minor fix to the
res_pjsip_publish_asterisk module was done so that it read the
sorcery configuration from the correct section. Finally the
sample configuration files have been updated.

ASTERISK-26928

Change-Id: I81991ae5c75af98d247f7eacd1c0b0a763675952
2017-04-07 08:44:49 -05:00
Sean Bright 7c0b12dc41 alembic: Turn off execute bit on non-executable python scripts
Change-Id: I744c986da4a38aeff8c00837eb89de7841fbc86c
2017-03-28 08:31:35 -06:00
Richard Begg 6b7697ed48 res_pjsip_session: Enable RFC3578 overlap dialing support.
Support for RFC3578 overlap dialling (i.e. 484 Response to partially matched
destinations) as currently provided by chan_sip is missing from res_pjsip.
This patch adds a new endpoint attribute (allow_overlap) [defaults to yes]
which when set to yes enables 484 responses to partial destination
matches rather than the current 404.

ASTERISK-26864

Change-Id: Iea444da3ee7c7d4f1fde1d01d138a3d7b0fe40f6
2017-03-22 11:26:48 +00:00
George Joseph 5013d8f5d3 res_pjsip: Symmetric transports
A new transport parameter 'symmetric_transport' has been added.

When a request from a dynamic contact comes in on a transport with
this option set to 'yes', the transport name will be saved and used
for subsequent outgoing requests like OPTIONS, NOTIFY and INVITE.
It's saved as a contact uri parameter named 'x-ast-txp' and will
display with the contact uri in CLI, AMI, and ARI output.  On the
outgoing request, if a transport wasn't explicitly set on the
endpoint AND the request URI is not a hostname, the saved transport
will be used and the 'x-ast-txp' parameter stripped from the
outgoing packet.

* config_transport was modified to accept and store the new parameter.

* config_transport/transport_apply was updated to store the transport
  name in the pjsip_transport->info field using the pjsip_transport->pool
  on UDP transports.

* A 'multihomed_on_rx_message' function was added to
  pjsip_message_ip_updater that, for incoming requests, retrieves the
  transport name from pjsip_transport->info and retrieves the transport.
  If transport->symmetric_transport is set, an 'x-ast-txp' uri parameter
  containing the transport name is added to the incoming Contact header.

* An 'ast_sip_get_transport_name' function was added to res_pjsip.
  It takes an ast_sip_endpoint and a pjsip_sip_uri and returns a
  transport name if endpoint->transport is set or if there's an
  'x-ast-txp' parameter on the uri and the uri host is an ipv4 or
  ipv6 address.  Otherwise it returns NULL.

* An 'ast_sip_dlg_set_transport' function was added to res_pjsip
  which takes an ast_sip_endpoint, a pjsip_dialog, and an optional
  pjsip_tpselector.  It calls ast_sip_get_transport_name() and if
  a non-NULL is returned, sets the selector and sets the transport
  on the dialog.  If a selector was passed in, it's updated.

* res_pjsip/ast_sip_create_dialog_uac and ast_sip_create_dialog_uas
  were modified to call ast_sip_dlg_set_transport() instead of their
  original logic.

* res_pjsip/create_out_of_dialog_request was modified to call
  ast_sip_get_transport_name() and pjsip_tx_data_set_transport()
  instead of its original logic.

* Existing transport logic was removed from endpt_send_request
  since that can only be called after a create_out_of_dialog_request.

* res_pjsip/ast_sip_create_rdata was converted to a wrapper around
  a new 'ast_sip_create_rdata_with_contact' function which allows
  a contact_uri to be specified in addition to the existing
  parameters.  (See below)

* res_pjsip_pubsub/internal_pjsip_evsub_send_request was eliminated
  since all it did was transport selection and that is now done in
  ast_sip_create_dialog_uac and ast_sip_create_dialog_uas.

* 'contact_uri' was added to subscription_persistence.  This was
  necessary because although the parsed rdata contact header has the
  x-ast-txp parameter added (if appropriate),
  subscription_persistence_update stores the raw packet which
  doesn't have it.  subscription_persistence_recreate was then
  updated to call ast_sip_create_rdata_with_contact with the
  persisted contact_uri so the recreated subscription has the
  correct transport info to send the NOTIFYs.

* res_pjsip_session/internal_pjsip_inv_send_msg was eliminated since
  all it did was transport selection and that is now done in
  ast_sip_create_dialog_uac.

* pjsip_message_ip_updater/multihomed_on_tx_message was updated
  to remove all traces of the x-ast-txp parameter from the
  outgoing headers.

NOTE:  This change does NOT modify the behavior of permanent
contacts specified on an aor.  To do so would require that the
permanent contact's contact uri be updated with the x-ast-txp
parameter and the aor sorcery object updated.  If we need to
persue this, we need to think about cloning permanent contacts into
the same store as the dynamic ones on an aor load so they can be
updated without disturbing the originally configured value.

You CAN add the x-ast-txp parameter to a permanent contact's uri
but it would be much simpler to just set endpoint->transport.

Change-Id: I4ee1f51473da32ca54b877cd158523efcef9655f
2017-03-16 09:49:07 -06:00
Mark Michelson 10fa49e327 Add rtcp-mux support
This commit adds support for RFC 5761: Multiplexing RTP Data and Control
Packets on a Single Port. Specifically, it enables the feature when
using chan_pjsip.

A new option, "rtcp_mux" has been added to endpoint configuration in
pjsip.conf. If set, then Asterisk will attempt to use rtcp-mux with
whatever it communicates with. Asterisk follows the rules set forth in
RFC 5761 with regards to falling back to standard RTCP behavior if the
far end does not indicate support for rtcp-mux.

The lion's share of the changes in this commit are in
res_rtp_asterisk.c. This is because it was pretty much hard wired to
have an RTP and an RTCP transport. The strategy used here is that when
rtcp-mux is enabled, the current RTCP transport and its trappings (such
as DTLS SSL session) are freed, and the RTCP session instead just
mooches off the RTP session. This leads to a lot of specialized if
statements throughout.

ASTERISK-26732 #close
Reported by Dan Jenkins

Change-Id: If46a93ba1282418d2803e3fd7869374da8b77ab5
2017-03-15 16:34:13 -05:00
Matt Jordan 1475604eff res_pjsip_endpoint_identifier_ip: Add an option to match requests by header
This patch adds a new features to the endpoint identifier module,
'match_header'. When set, inbound requests are matched by a provided SIP
header: value pair. This option works in conjunction with the existing
'match' configuration option, such that if any 'match*' attribute
matches an inbound request, the request is associated with the specified
endpoint.

Since this module now identifies by more than just IP address,
appropriate renaming of the module and/or variables can be done in a
non-release branch.

ASTERISK-26863 #close

Change-Id: Icfc14835c962f92e35e67bbdb235cf0589de5453
(cherry picked from commit 30f52d79d7)
2017-03-15 07:51:35 -06:00
George Joseph e252aff9ad debug_utilities: Install ast_logescalator to /var/lib/asterisk/scripts
Forgot to install it with the original patch

Change-Id: I8bdb540a6694971ae5fe21f48d532332c6482e4c
2017-01-31 12:48:14 -06:00
George Joseph ef4deb8ecd debug_utilities: Add ast_logescalator
The escalator works by creating a set of startup commands in cli.conf
that set up logger channels and issue the debug commands for the
subsystems specified.  If asterisk is running when it is executed,
the same commands will be issued to the running instance.  The original
cli.conf is saved before any changes are made and can be restored by
executing '$prog --reset'.

The log output will be stored in...
$astlogdir/message.$uniqueid
$astlogdir/debug.$uniqueid
$astlogdir/dtmf.$uniqueid
$astlogdir/fax.$uniqueid
$astlogdir/security.$uniqueid
$astlogdir/pjsip_history.$uniqueid
$astlogdir/sip_history.$uniqueid

Some minor tweaks were made to chan_sip, and res_pjsip_history
so their history output could be send to a log channel as packets
are captured.

A minor tweak was also made to manager so events are output to verbose
when "manager set debug on" is issued.

Change-Id: I799f8e5013b86dc5282961b27383d134bf09e543
2017-01-27 15:10:02 -06:00
George Joseph d16b3a9917 debug_utilities: Create ast_loggrabber
ast_loggrabber gathers log files from customizable search patterns,
optionally converts POSIX timestamps to a readable format and
tarballs the results.

Also a few tweaks were made to ast_coredumper.

Change-Id: I8bfe1468ada24c1344ce4abab7b002a59a659495
(cherry picked from commit c709152878)
2017-01-20 11:20:22 -06:00
George Joseph 0d53c91fba debug_utilities: Create the ast_coredumper utility
This utility allows easy manipulation of asterisk coredumps.

* Configurable search paths and patterns for existing coredumps
* Can generate a consistent coredump from the running instance
* Can dump the lock_infos table from a coredump
* Dumps backtraces to separate files...
  - thread apply 1 bt full -> <coredump>.thread1.txt
  - thread apply all bt -> <coredump>.brief.txt
  - thread apply all bt full -> <coredump>.full.txt
  - lock_infos table -> <coredump>.locks.txt
* Can tarball corefiles and optionally delete them after processing
* Can tarball results files and optionally delete them after processing
* Converts ':' in coredump and results file names '-' to facilitate
  uploading.  Jira for instance, won't accept file names with colons
  in them.

Tested on Fedora24+, Ubuntu14+, Debian6+, CentOS6+ and FreeBSD9+[1].

[1] For *BSDs, the "devel/gdb" package might have to be installed to
get a recent gdb.  The utility will check all instances of gdb
it finds in $PATH and if one isn't found that can run python, it
prints a friendly error.

Change-Id: I935d37ab9db85ef923f32b05579897f0893d33cd
(cherry picked from commit cb47b45560)
2017-01-11 12:11:45 -06:00
Joshua Colp a7d856cd96 res_pjsip_endpoint_identifier_ip: Add support for SRV lookups.
This change implements SRV support for the IP based endpoint
identifier module. All possible addresses through SRV are looked
up and added as matches. If no SRV records are available a
fallback to normal host resolution is done. If an IP address
is provided then no SRV lookup occurs.

This is configured using the "srv_lookups" option on the
identify section and defaults to "yes".

ASTERISK-26693

Change-Id: I6b641e275bf96629320efa8b479737062aed82ac
2017-01-06 09:00:22 -06:00
Tzafrir Cohen bab253ac9f Fixes to various issues reported by pyflakes
Pyflake is a python (2) source checker. This patch fixes various
(mostly trivial) errors and warnings it reports.

Change-Id: Ia35c5ac61751b927814cf693994c632c412386ea
2016-12-21 11:02:20 +02:00
Richard Mudgett d27dee3cca autosupport: Add 'pjproject show buildopts'
Change-Id: I8aa55a7c3fb175235ddc7f85e9457d5102d06fa7
2016-12-15 13:27:56 -06:00
Joshua Colp aed6c219a3 pjsip: Fix a few media bugs with reinvites and asymmetric payloads.
When channel format changes occurred as a result of an RTP
re-negotiation the bridge was not informed this had happened.
As a result the bridge technology was not re-evaluated and the
channel may have been in a bridge technology that was incompatible
with its formats. The bridge is now unbridged and the technology
re-evaluated when this occurs.

The chan_pjsip module also allowed asymmetric codecs for sending
and receiving. This did not work with all devices and caused one
way audio problems. The default has been changed to NOT do this
but to match the sending codec to the receiving codec. For users
who want asymmetric codecs an option has been added, asymmetric_rtp_codec,
which will return chan_pjsip to the previous behavior.

The codecs returned by the chan_pjsip module when queried by
the bridge_native_rtp module were also not reflective of the
actual negotiated codecs. The nativeformats are now returned as
they reflect the actual negotiated codecs.

ASTERISK-26423 #close

Change-Id: I6ec88c6e3912f52c334f1a26983ccb8f267020dc
2016-10-26 12:48:57 +00:00
Joshua Colp 403c4f5833 pjsip: Support dual stack automatically.
This change adds support for dual stack automatically. No
configuration is required and the IP address and version
in the SIP messages and SDP will be automatically changed
based on the transport over which the message is being
sent. RTP usage has also been changed to listen on both
IPv4 and IPv6 simultaneously to allow media to flow, and
to allow ICE support on both simultaneously. This also
allows failover between IPv6 and IPv4 to work as expected.

ASTERISK-26309 #close

Change-Id: I235a421d8f9a326606d861b449fa6fe3a030572d
2016-10-23 13:53:55 +00:00
zuul 1ca148cae8 Merge "Add text of cdr directory into README.md for ast-db-manage" 2016-10-11 19:45:14 -05:00
George Joseph 442b597929 alembic: Allow cdr, config and voicemail to exist in the same schema
cdr, config and voicemail are all separate alembic trees.  Because
alembic's default is to use a table named 'alembic_version' to store
the current tree revision, the 3 trees can't exist in the same schema
without stepping on each other.

Now each tree uses 'alembic_version_<tree_name>' as the version table.
Each tree's env.py script now first checks for 'alembic_version'.  If
it finds it AND its revision is in the tree's history, the script
renames it to 'alembic_version_<tree_name>'.  Regardless, the script
then continues with the migration using 'alembic_version_<tree_name>'
and creates that table if it's not found.  The result is that if an
existing 'alembic_version' table was found but it didn't belong to this
tree, it's left alone and 'alembic_version_<tree_name>' is used or
created.

WARNING:  If multiple trees are using the same schema, they MUST NOT
CRU or D any objects with names that might exist in the other trees.
An example would be 'yesno_values' type.  If two trees perform
operations on it, one tree could pull it out from under the other.
Thankfully we currently don't share any names among cdr, config and
voicemail.

NOTE:  Since the env.py scripts in each tree were identical, a common
env.py has been placed in the ast-db-manage directory and a symlink
to it has been placed in each tree directory.

ASTERISK-24311 #close
Reported-by: Dafi Ni

Change-Id: I4d593f000350deb5d21a14fa1e9bc3896844d898
2016-10-07 07:49:42 -05:00
Rodrigo Ramírez Norambuena 79532bca75 Add text of cdr directory into README.md for ast-db-manage
Change-Id: I68321c4bea50730c39fdb486e5f23aeadd1ad636
2016-09-30 18:32:19 -03:00
zuul e2d3882b30 Merge "sip_to_pjsip.py: Map legacy_useroption_parsing." 2016-09-14 15:03:46 -05:00
zuul cbd6f7001e Merge "res_pjsip: Add ignore_uri_user_options option." 2016-09-14 12:27:28 -05:00
zuul 50c3bb2631 Merge "contrib: Let safe_asterisk script continue without /dev/tty9." 2016-09-12 08:42:18 -05:00
Richard Mudgett 82ec58aa91 sip_to_pjsip.py: Map legacy_useroption_parsing.
Map the sip.conf general section legacy_useroption_parsing to the
new pjsip.conf global ignore_uri_user_options.

ASTERISK-26316
Reported by: Kevin Harwell

Change-Id: I78108a31995db19d41f4e1a07b3324692c5363fc
2016-09-09 17:13:14 -05:00
Richard Mudgett ba362822f3 res_pjsip: Add ignore_uri_user_options option.
This implements the chan_sip legacy_useroption_parsing option but with a
better name.

* Made the caller-id number and redirecting number strings obtained from
incoming SIP URI user fields always truncated at the first semicolon.
People don't care about anything after the semicolon showing up on their
displays even though the RFC allows the semicolon.

ASTERISK-26316 #close
Reported by: Kevin Harwell

Change-Id: Ib42b0e940dd34d84c7b14bc2e90d1ba392624f62
2016-09-09 17:13:02 -05:00
zuul 9d54dd04bb Merge "res/res_pjsip: Add preferred_codec_only config to pjsip endpoint." 2016-09-09 13:56:16 -05:00
Walter Doekes 56caf5402c contrib: Let safe_asterisk script continue without /dev/tty9.
If you use the safe_asterisk script, it uses hardcoded defaults before
running configurable values from /etc/asterisk/startup.d. The hardcoded
default has TTY=9. Some containerized environments don't have such a
TTY, and safe_asterisk would stop.

The custom configuration from /etc/asterisk/startup.d/* isn't read until
after it stopped, so changing TTY in a custom config did not help.

This changeset changes safe_asterisk to continue if the TTY setting was
untouched and /dev/tty9 and /dev/vc/9 aren't found.

Change-Id: I2c7cdba549b77f418a0af4cb1227e8e6fe4148fc
2016-09-09 13:26:01 +02:00
Aaron An 2a50c29101 res/res_pjsip: Add preferred_codec_only config to pjsip endpoint.
This patch add config to pjsip by endpoint.
;preferred_codec_only=yes
; Respond to a SIP invite with the single most preferred codec
; rather than advertising all joint codec capabilities. This
; limits the other side's codec choice to exactly what we prefer.

ASTERISK-26317 #close
Reported by: AaronAn
Tested by: AaronAn

Change-Id: Iad04dc55055403bbf5ec050997aee2dadc4f0762
2016-09-09 05:36:19 -05:00
zuul 05240e2b57 Merge "sip_to_pjsip.py: Map canreinvite as directmedia alias." 2016-09-06 16:30:33 -05:00
zuul eae37c3524 Merge "sip_to_pjsip.py: Fix typo converting outboundproxy registration." 2016-09-06 15:26:23 -05:00
Richard Mudgett edcf09e47c sip_to_pjsip.py: Map canreinvite as directmedia alias.
Change-Id: I48b8e150f96a3d2a24d8fc25fbe4f5aff9f4a6b2
2016-09-02 13:07:08 -05:00
Richard Mudgett 47336a0bdd sip_to_pjsip.py: Fix typo converting outboundproxy registration.
Change-Id: I6f30e5f9fcf8469ba0079fbf884047d54c2c0b15
2016-09-02 13:05:16 -05:00
Richard Mudgett dba02575fc sip_to_pjsip.py: Fix comment typo and tabs.
Change-Id: If35174614545727817d329c60ba4456c028941b5
2016-09-02 13:03:09 -05:00
Alexander Traud f35501b8c9 sip_to_pjsip: Migrate IPv4/IPv6 (Dual Stack) configurations.
When using the migration script sip_to_pjsip.py, and your sip.conf is
configured with bindaddr=::, two transports are written to pjsip.conf, one for
0.0.0.0 (IPv4) and one for [::] (IPv6). That way, PJProject listens on the IPv4
and IPv6 wildcards; a IPv4/IPv6 Dual Stack configuration on a single interface
like in chan_sip.

Furthermore, the script internal functions "build_host" and "split_hostport"
did not parse Literal IPv6 addresses as expected (like [::1]:5060). This change
makes sure, even such addresses are parsed correctly.

ASTERISK-26309

Change-Id: Ia4799a0f80fc30c0550fc373efc207c3330aeb48
2016-08-26 12:49:50 +02:00
zuul c6ed91a9c8 Merge "sip_to_pjsip: Map externhost/ip to Transports." 2016-08-19 17:54:48 -05:00
zuul be26a93687 Merge "sip_to_pjsip: Add cert_file." 2016-08-19 12:39:07 -05:00
zuul d86ee51ca0 Merge "res_pjsip: Add contact_user to endpoint" 2016-08-19 10:08:11 -05:00
Alexander Traud 02a82f758e sip_to_pjsip: Add cert_file.
When using the migration script sip_to_pjsip.py, cert_file was not migrated to
pjsip.conf. A previous change regarding this contained a copy/paste error.

ASTERISK-22374

Change-Id: I0fa72e9412117d53b4284fc6b83fa5b2b95ba03b
2016-08-19 10:59:40 +02:00
Joshua Colp b544bfbbd5 Merge "sip_to_pjsip: Write cos and tos." 2016-08-18 18:55:35 -05:00
Kevin Harwell 966527249e sip_to_pjsip: Set correct tls transport method
A recent update had a copy/paste error where the unused variable 'val' was
being passed to the set_value function instead of the 'method' value itself.

This patch passes in the right variable.

ASTERISK-22374

Change-Id: I895b7b3779ce4442bc58b8ec40d59dd29bb43f06
2016-08-18 12:04:56 -05:00
Joshua Colp 2dba6d0371 Merge "sip_to_pjsip: Parse register even with transport." 2016-08-18 11:50:16 -05:00
Joshua Colp 71b3751093 Merge "sip_to_pjsip: Write local_net, contact_acl, contact_deny, and contact_permit." 2016-08-18 11:49:53 -05:00
Joshua Colp 54c5bb0287 Merge "sip_to_pjsip: Map (session-)timers correctly." 2016-08-18 11:49:15 -05:00
Joshua Colp 5899b4c593 Merge "sip_to_pjsip: Add cert_file and ca_list_path." 2016-08-18 11:48:32 -05:00
Joshua Colp 560c2abdec Merge "sip_to_pjsip: Write username even without authname." 2016-08-18 11:48:23 -05:00
Joshua Colp 14284aee45 Merge "sip_to_pjsip: Map the TLS method correctly." 2016-08-18 11:47:29 -05:00
Joshua Colp 0a09ab5b1c Merge "sip_to_pjsip: Add compactheaders, timerb, timert1, and useragent." 2016-08-18 11:46:39 -05:00
Joshua Colp 91624f439c Merge "sip_to_pjsip: Write media_encryption." 2016-08-18 11:45:56 -05:00
Alexander Traud e55d1e47aa sip_to_pjsip: Map the TLS method correctly.
When using the migration script sip_to_pjsip.py and tlsclientmethod is not set
in sip.conf, the default value of chan_sip (sslv23) is copied to pjsip.conf, to
overwrite the default of the PJProject (tlsv1). This makes sure, res_pjsip is
offering/using not just TLSv1.0 but TLSv1.2 as well.

ASTERISK-22374

Change-Id: Ie530a3dae9926ae14f3920a21be1e2edb15bda4f
2016-08-18 15:19:15 +02:00
Alexander Traud da14c439a3 sip_to_pjsip: Add compactheaders, timerb, timert1, and useragent.
When using the migration script sip_to_pjsip.py, no section of type=system or
type=general were created. Therefore the keys compactheaders, timerb, timert1,
and useragent were not migrated to pjsip.conf.

ASTERISK-22374

Change-Id: I318a453843227ea36bf130d392d4abd7bd26b5a1
2016-08-18 15:17:47 +02:00
Alexander Traud 675721a7ab sip_to_pjsip: Map (session-)timers correctly.
When using the migration script sip_to_pjsip.py, session-timers=accept and
session-timers=refuse were mapped to wrong values.

ASTERISK-22374

Change-Id: Ie4e90d5f6a29aff07837b7fe5bc8aea5fb6fc092
2016-08-18 15:16:45 +02:00
Alexander Traud acc5237e91 sip_to_pjsip: Write username even without authname.
When using the migration script sip_to_pjsip.py, now the (mandatory) username is
written to pjsip.conf, even if there was no (optional) authname in the register
string in sip.conf.

ASTERISK-22374

Change-Id: Ie53e1997104cd2674821688b8a8247249f5e156f
2016-08-18 15:15:38 +02:00
Alexander Traud 3eb02235f5 sip_to_pjsip: Parse register even with transport.
When using the migration script sip_to_pjsip.py and the register string
started with a transport in sip.conf - like tls://... - register was not parsed
correctly and therefore not migrated correctly to pjsip.conf.

ASTERISK-22374

Change-Id: I44c12104eea2bd8558ada6d25d77edfecd92edd2
2016-08-18 15:14:36 +02:00
Alexander Traud 9907e2b1c1 sip_to_pjsip: Write local_net, contact_acl, contact_deny, and contact_permit.
When using the migration script sip_to_pjsip.py, those keys got missing. These
keys might appear several times and the function "merge_value" tried to collect
those. However, because these keys have different names in sip.conf and
pjsip.conf, "merge_value" was not able to find the new key name in sip.conf.
This change lets "merge_value" search with the old key name in sip.conf and
write with the new key name in pjsip.conf.

ASTERISK-22374

Change-Id: Ie53c5278ae6f1cb8fa7e96c5289877d46981d9d2
2016-08-18 15:13:03 +02:00
Alexander Traud c0e0075718 sip_to_pjsip: Map externhost/ip to Transports.
When using the migration script sip_to_pjsip.py, the externhost or externip of
sip.conf were erroneously written to Endpoints instead to Transports.

ASTERISK-22374

Change-Id: I2c5873386cfc388899fa9cf2368639dd12f1b8e4
2016-08-18 15:11:02 +02:00
Alexander Traud a937c2ccb1 sip_to_pjsip: Add defaultexpiry, maxexpiry, and minexpiry.
When using the migration script sip_to_pjsip.py, defaultexpiry, maxexpiry, and
minexpiry were not migrated to pjsip.conf.

ASTERISK-22374

Change-Id: I007fbf543dcadc96fc3ed71c54da502bcb209b7b
2016-08-18 15:04:53 +02:00
Alexander Traud 163cc2d68f sip_to_pjsip: Write media_encryption.
When using the migration script sip_to_pjsip.py, encryption=yes got missing and
media_encryption=sdes was not written to pjsip.conf, because of a typo.

ASTERISK-22374

Change-Id: I0fc3e55dc512a57603ae0fef41baacccf2a35c05
2016-08-18 15:03:24 +02:00
Alexander Traud d8b5970749 sip_to_pjsip: Write cos and tos.
When using the migration script sip_to_pjsip.py, both tos_sip and cos_sip got
missed, because of a typo. Therefore, cos and tos were not written to
pjsip.conf. Furthermore, that revealed a misuse of an internal function, caused
by a copy-and-paste error.

ASTERISK-22374

Change-Id: Id245ebadf70ab9776eb280c026288540af3af5c2
2016-08-18 15:02:07 +02:00
Alexander Traud 38491401b5 sip_to_pjsip: Add cert_file and ca_list_path.
When using the migration script sip_to_pjsip.py, cert_file and ca_list_path were
not migrated to pjsip.conf.

ASTERISK-22374

Change-Id: I4612877d190b7f86a48698cefbf5c4db6c265825
2016-08-18 14:55:58 +02:00
George Joseph 534063fd67 res_pjsip: Add contact_user to endpoint
contact_user, when specified on an endpoint, will override the user
portion of the Contact header on outgoing requests.

Change-Id: Icd4ebfda2f2e44d3ac749d0b4066630e988407d4
2016-08-17 16:21:19 -05:00
Kevin Harwell b3c2f1164b alembic: add auth_username to endpoint's identify_by enum
A new identify_by option was added recently, auth_username. However, this
setting was not added as an allowable choice in the database enumeration
value.

This patch updates the current enumeration, adding in the new setting.

ASTERISK-26268 #close

Change-Id: Ib4788e8485e4cd40172ec0abbf5810a147ab8bf8
2016-08-11 10:50:09 -05:00
zuul 3eeeb13481 Merge "alembic/sqlalchemy: auto increment only allowed on a single column" 2016-08-10 21:00:42 -05:00
Kevin Harwell d4170df40a alembic/sqlalchemy: auto increment only allowed on a single column
The extensions table defined two columns (id and priority) as primary key
autoincrement columns. However only one is allowed when defining the primary
key.

This patch removes the autoincrement attribute from the priority column since
it does not need to be as such and really should not have been on there in the
first place.

This patch also removes 'context', 'exten', and 'priority' from the primary key
index and creates a new combined unique contraint index on them.

ASTERISK-26183 #close

Change-Id: Ib9c712c612a4d7ec1edb0dcb77f1bae0905a470b
2016-08-10 13:49:48 -05:00
Alexei Gradinari 403b63571c res_pjsip_mwi: fix unsolicited mwi blocks PJSIP stack
The PJSIP taskprocessors could be overflowed on startup
if there are many (thousands) realtime endpoints
configured with unsolicited mwi.
The PJSIP stack could be totally unresponsive for a few minutes
after boot completed.

This patch creates a separate PJSIP serializers pool for mwi
and makes unsolicited mwi use serializers from this pool.
This patch also adds 2 new global options to tune taskprocessor
alert levels: 'mwi_tps_queue_high' and 'mwi_tps_queue_low'.

This patch also adds new global option 'mwi_disable_initial_unsolicited'
to disable sending unsolicited mwi to all endpoints on startup.
If disabled then unsolicited mwi will start processing
on next endpoint's contact update.

ASTERISK-26230 #close

Change-Id: I4c8ecb82c249eb887930980a800c9f87f28f861a
2016-08-08 13:57:58 -05:00
Joshua Colp 90b30b21ac astconfigparser: Really handle case where line is simply a comment.
The regular expression would match causing the code that handled
the line if it was merely a comment to never get executed.

Change-Id: I3e4022481037ebcba9905587fe8c764b4ce21819
2016-08-03 09:49:45 -05:00
Joshua Colp a7ae48441f astconfigparser: Handle case where line is simply a comment.
Change-Id: I2dea5815363f4d787d709228a04f33baee383ef5
2016-07-29 04:49:06 -05:00
Joshua Colp 1e7168aee0 astconfigparser.py: Update with realtime fixes.
When configuring SIP URIs in the pjsip.conf file it is
necessary to escape the semicolon so the parser does not
treat it as a comment. This change allows this to work in
the astconfigparser implementation.

A secondary bug where some data was lost if a configuration
option included a "=" in its value was also fixed.

A bug where sections would be considered equal despite
being different has also been fixed.

Change-Id: If229f656ef22050b50e7b34e90c4bffe796431f8
2016-07-26 17:31:06 -05:00
Mark Michelson 76781a0964 Fix sqlalchemy error regarding identifier length.
sqlalchemy was complaining:

sqlalchemy.exc.IdentifierError: Identifier
'ps_contacts_qualifyfreq_exptime' exceeds maximum length of 30
characters

This fixes the problem by changing the index name to be
"ps_contacts_qualifyfreq_exp" instead.

ASTERISK-26227 #close
Reported by Mark Michelson

Change-Id: I0ed784f87504be2a59ee8d3242ef6f625d5ed1a9
2016-07-22 14:47:00 -05:00
Richard Mudgett e739888d99 res_pjsip: Add fax_detect_timeout endpoint option.
The new endpoint option allows the PJSIP channel driver's fax_detect
endpoint option to timeout on a call after the specified number of
seconds into a call.  The new feature is disabled if the timeout is set
to zero.  The option is disabled by default.

ASTERISK-26214
Reported by: Richard Mudgett

Change-Id: Id5a87375fb2c4f9dc1d4b44c78ec8735ba65453d
2016-07-19 10:33:45 -05:00
Joshua Colp c2a72e6aa6 Merge "install_prereq: Checkout of libSRTP 1.5.x." 2016-07-12 19:30:38 -05:00
Alexander Traud 8476a9332f install_prereq: Checkout of libSRTP 1.5.x.
Since 5th November 2014, the master branch of libSRTP changed the prefix of
several member names and is not compatible with the source code in Asterisk
anymore. Therefore instead, this change checks out the latest version of the
libSRTP 1.5.x branch. Furthermore now, libSRTP is compiled with OpenSSL as
backend. This makes AES-GCM and AES-IN possible.

ASTERISK-22131 #close

Change-Id: I2e396cdc01da0ff610686e398ed210ca7408f7d6
2016-07-11 17:18:56 +02:00
Alexei Gradinari 1c949eea6c res_pjsip: Added "subscribe_context" to endpoint
If specified, incoming SUBSCRIBE requests will be searched for the matching
extension in the indicated context. If no "subscribe_context" is specified,
then the "context" setting is used.

ASTERISK-25471 #close

Change-Id: I3fb7a15f5bc154079bd348c08b7ad1cdd2d5e514
2016-07-06 10:30:27 -04:00
Joshua Colp 040a11cecd Merge "res_pjsip: improve realtime performance #2" 2016-06-30 15:53:24 -05:00
Alexei Gradinari 6fa3ed0679 res_pjsip: improve realtime performance #2
The patch removes updating all Endpoints' status on startup.
Instead, only non-qualified aors with static contact
and non-qualified non-expired contacts are retrieved from the realtime to
update the endpoint status to ONLINE.
The endpoint name was added to the contact object to simply find the endpoint
that created this contact.

The status of endpoints with qualified aors will be updated by 'qualify'
functions.

ASTERISK-26061 #close

Change-Id: Id324c1776fa55d3741e0c5457ecac0304cb1a0df
2016-06-22 15:29:50 -04:00
Mark Michelson b6bd97eea2 Fix Alembic upgrades.
A non-existent constraint was being referenced in the upgrade script.
This patch corrects the problem by removing the reference.

In addition, the head of the alembic branch referred to a non-existent
revision. This has been fixed by referring to the proper revision.

This patch fixes another realtime problem as well. Our Alembic scripts
store booleans as yes or no values. However, Sorcery tries to insert
"true" or "false" instead. This patch introduces a new boolean type that
translates to "yes" or "no" instead.

ASTERISK-26128 #close

Change-Id: I51574736a881189de695a824883a18d66a52dcef
2016-06-22 12:23:44 -05:00
Joshua Colp 4505a59dc9 alembic: Fix migration.
The 81b01a191a46_pjsip_add_contact_reg_server.py script was attempting
to use UniqueConstraint and failing. It was not imported and after
importing it also continued to fail.

I've changed the script to use the explicit name of the constraint
instead.

Change-Id: I2438b0be90b7ce583b47dd27983c0c1a02cea5b9
2016-06-02 05:00:51 -05:00
Alexei Gradinari 31f17abe44 res_pjsip: add "via_addr", "via_port", "call_id" to contact
As res_pjsip_nat rewrites contact's address, only the last Via header
can contain the source address of registered endpoint.
Also Call-Id header may contain the source address of registered
endpoint.

Added "via_addr", "via_port", "call_id" to contact.
Added new fields ViaAddress, CallID to AMI event ContactStatus.

ASTERISK-26011

Change-Id: I36bcc0bf422b3e0623680152d80486aeafe4c576
2016-05-26 16:18:11 -05:00
Alexei Gradinari 69a85a519f res_pjsip: Endpoint IP Access Controls
With the old SIP module we can use IP access controls per peer.
PJSIP module missing this feature.

This patch added next configuration Endpoint options:
    "acl" - list of IP ACL section names in acl.conf
    "deny" - List of IP addresses to deny access from
    "permit" - List of IP addresses to permit access from
    "contact_acl" - List of Contact ACL section names in acl.conf
    "contact_deny" - List of Contact header addresses to deny
    "contact_permit" - List of Contact header addresses to permit

This patch also better logging failed request:
    add custom message instead of "No matching endpoint found"
    add SIP method to logging

ASTERISK-25900

Change-Id: I456dea3909d929d413864fb347d28578415ebf02
2016-05-13 12:46:52 -04:00
Joshua Colp 87787bb889 Merge "res_pjsip: improve realtime performance" 2016-05-11 10:58:54 -05:00
Alexei Gradinari cc4c5f5693 res_pjsip: improve realtime performance
This patch modified pjsip_options to retrieve only
permament contacts for aor if the qualify_frequency is > 0
and persisted contacts if the qualify_frequency is > 0.

This patch also fixed a bug in res_sorcery_astdb.
res_sorcery_astdb doesn't save object data retrived from astdb.

ASTERISK-25826

Change-Id: I1831fa46c4578eae5a3e574ee3362fddf08a1f05
2016-05-05 10:45:49 -05:00
Alexei Gradinari 4df48581f1 pjsip: Added "reg_server" to contacts (fixed alembic)
ASTERISK-25931

Change-Id: Icc4321a88f5c93ff809da3f372eebbf69c6a8549
2016-05-05 10:21:53 -05:00
zuul d9ed4e3153 Merge "pjproject_bundled: Various fixes discovered during testing of OSes" 2016-05-03 19:11:18 -05:00
George Joseph e61716b774 pjproject_bundled: Various fixes discovered during testing of OSes
For all OSes:
* Disabled third-party codecs in pjproject and added
  '--disable-speex-codec --disable-speex-aec --disable-gsm-codec' to the
  configure options since we don't use the pjsip codec capability.

FreeBSD:
* Added FreeBSD support to install_prereq.
* Changed pjproject/configure.m4 to use $GNU_MAKE instead of hardcoding "make".
* Added __progname and environ to asterisk.exports.in.
* Reverted the use of ldconfig to create shared library symlinks to ln.
* Only enable epoll in pjproject if `uname -s` is Linux.
* Added a patch to pjproject to take the name of the 'make' command from
  an environment variable if supplied.  This is needed for the python bindings.
  (merged by Teluu into pjproject trunk 5/3/2016)
FreeBSD support isn't complete.  Still some general issues regarding
make/gmake having nothing to do with pjproject.  With some handholding it DOES
build successfully.

CentOS:
Added 'patch' and 'bzip2' to install_prereq PACKAGES_RH.
CentOS 6/7 32/64 build and run the pjsip testsuite successfully.

Ubuntu:
No changes required.
Ubuntu 15/16 32/64 build and run the pjsip testsuite successfully.

Debian:
No changes required.
Debian 6/7/8 32/64 build and run the pjsip testsuite successfully.

There will utimately be a follow-up patch to create an install_prereq for
the testsuite as I've discovered a few missing requirements.

ASTERISK-25968 #close

Change-Id: I5756a07facfc63798115a5e73a8709382fe9259c
2016-05-03 07:56:18 -05:00
Alexei Gradinari 2b1edee772 pjsip: Added "reg_server" to contacts.
If the Asterisk system name is set in asterisk.conf, it will be stored
into the "reg_server" field in the ps_contacts table to facilitate
multi-server setups.

ASTERISK-25931

Change-Id: Ia8f6bd2267809c78753b52bcf21835b9b59f4cb8
2016-05-02 10:01:40 -03:00
George Joseph 4ebf9a938d res_pjsip: Add ability to identify by Authorization username
A feature of chan_sip that service providers relied upon was the ability to
identify by the Authorization username.  This is most often used when customers
have a PBX that needs to register rather than identify by IP address.  From my
own experiance, this is pretty common with small businesses who otherwise
don't need a static IP.

In this scenario, a register from the customer's PBX may succeed because From
will usually contain the PBXs account id but an INVITE will contain the caller
id.  With nothing recognizable in From, the service provider's Asterisk can
never match to an endpoint and the INVITE just stays unauthorized.

The fixes:

A new value "auth_username" has been added to endpoint/identify_by that
will use the username and digest fields in the Authorization header
instead of username and domain in the the From header to match an endpoint,
or the To header to match an aor.  This code as added to
res_pjsip_endpoint_identifier_user rather than creating a new module.

Although identify_by was always a comma-separated list, there was only
1 choice so order wasn't preserved.  So to keep the order, a vector was added
to the end of ast_sip_endpoint.  This is only used by res_pjsip_registrar
to find the aor.  The res_pjsip_endpoint_identifier_* modules are called in
globals/endpoint_identifier_order.

Along the way, the logic in res_pjsip_registrar was corrected to match
most-specific to least-specific as res_pjsip_endpoint_identifier_user does.

The order is:

username@domain
username@domain_alias
username

Auth by username does present 1 problem however, the first INVITE won't have
an Authorization header so the distributor, not finding a match on anything,
sends a securty_alert.  It still sends a 401 with a challenge so the next
INVITE will have the Authorization header and presumably succeed.  As a result
though, that first security alert is actually a false alarm.

To address this, a new feature has been added to pjsip_distributor that keeps
track of unidentified requests and only sends the security alert if a
configurable number of unidentified requests come from the same IP in a
configurable amout of time.  Those configuration options have been added to
the global config object.  This feature is only used when auth_username
is enabled.

Finally, default_realm was added to the globals object to replace the hard
coded "asterisk" used when an endpoint is not yet identified.

The testsuite tests all pass but new tests are forthcoming for this new
feature.

ASTERISK-25835 #close
Reported-by: Ross Beer

Change-Id: I30ba62d208e6f63439600916fcd1c08a365ed69d
2016-04-27 16:33:51 -05:00
Alexei Gradinari 860b135c88 res_pjsip: disable multi domain to improve realtime performace
This patch added new global pjsip option 'disable_multi_domain'.
Disabling Multi Domain can improve Realtime performance by reducing
number of database requests.

ASTERISK-25930 #close

Change-Id: I2e7160f3aae68475d52742107949a799aa2c7dc7
2016-04-27 10:58:43 -05:00
George Joseph 751d7a5a49 alembic: Remove batch operations (and sqlite support)
Because SQLite doesn't support full ALTER capabilities, alembic scripts
require batch operations.  However, that capability wasn't available until
0.7.0 which some distributions haven't reached yet.  Therefore, the batch
operations introduced in commit 86d6e44cc (review 2319) have been reverted
and SQLite is unsupported again, for now anyway.

Tested the full upgrade and downgrade on MySQL/Mariadb and Postgresql.

ASTERISK-25890 #close
Reported-by: Harley Peters

Change-Id: I82eba5456736320256f6775f5b0b40133f4d1c80
2016-04-07 13:35:35 -05:00
Joshua Colp 86ccd1bd2b Merge "install_prereq: Fix check_installed_debs remove subversion" 2016-04-04 17:39:45 -05:00
George Joseph 060b7b83bc install_prereq: Fix check_installed_debs remove subversion
check_installed_debs wasn't handling virtual packages like libsrtp-dev and
libresample-dev and on multiarch systems it was accidentally filtering out all
packages if any :i386 packages were found instead of just filtering out the
:i386 packages themselves.

Change-Id: Ifd68da0d1ee30cc84df14de3f9b9079d7c3cecda
2016-04-04 13:47:21 -05:00
George Joseph e2524fcee3 res_pjsip_mwi: Add voicemail extension and mwi_subscribe_replaces_unsolicited
res_pjsip_mwi was missing the chan_sip "vmexten" functionality which adds
the Message-Account header to the MWI NOTIFY.  Also, specifying mailboxes
on endpoints for unsolicited mwi and on aors for subscriptions required
that the admin know in advance which the client wanted.  If you specified
mailboxes on the endpoint, subscriptions were rejected even if you also
specified mailboxes on the aor.

Voicemail extension:
* Added a global default_voicemail_extension which defaults to "".
* Added voicemail_extension to both endpoint and aor.
* Added ast_sip_subscription_get_dialog for support.
* Added ast_sip_subscription_get_sip_uri for support.

When an unsolicited NOTIFY is constructed, the From header is parsed, the
voicemail extension from the endpoint is substituted for the user, and the
result placed in the Message-Account field in the body.

When a subscribed NOTIFY is constructed, the subscription dialog local uri
is parsed, the voicemail_extension from the aor (looked up from the
subscription resource name) is substituted for the user, and the result
placed in the Message-Account field in the body.

If no voicemail extension was defined, the Message-Account field is not added
to the NOTIFY body.

mwi_subscribe_replaces_unsolicited:
* Added mwi_subscribe_replaces_unsolicited to endpoint.

The previous behavior was to reject a subscribe if a previous internal
subscription for unsolicited MWI was found for the mailbox.  That remains the
default.  However, if there are mailboxes also set on the aor and the client
subscribes and mwi_subscribe_replaces_unsolicited is set, the existing internal
subscription is removed and replaced with the external subscription.  This
allows an admin to configure mailboxes on both the endpoint and aor and allows
the client to select which to use.

ASTERISK-25865 #close
Reported-by: Ross Beer

Change-Id: Ic15a9415091760539c7134a5ba3dc4a6a1217cea
2016-03-30 13:23:54 -05:00
George Joseph c948ce9651 sorcery/res_pjsip: Refactor for realtime performance
There were a number of places in the res_pjsip stack that were getting
all endpoints or all aors, and then filtering them locally.

A good example is pjsip_options which, on startup, retrieves all
endpoints, then the aors for those endpoints, then tests the aors to see
if the qualify_frequency is > 0.  One issue was that it never did
anything with the endpoints other than retrieve the aors so we probably
could have skipped a step and just retrieved all aors. But nevermind.

This worked reasonably well with local config files but with a realtime
backend and thousands of objects, this was a nightmare.  The issue
really boiled down to the fact that while realtime supports predicates
that are passed to the database engine, the non-realtime sorcery
backends didn't.

They do now.

The realtime engines have a scheme for doing simple comparisons. They
take in an ast_variable (or list) for matching, and the name of each
variable can contain an operator.  For instance, a name of
"qualify_frequency >" and a value of "0" would create a SQL predicate
that looks like "where qualify_frequency > '0'".  If there's no operator
after the name, the engines add an '=' so a simple name of
"qualify_frequency" and a value of "10" would return exact matches.

The non-realtime backends decide whether to include an object in a
result set by calling ast_sorcery_changeset_create on every object in
the internal container.  However, ast_sorcery_changeset_create only does
exact string matches though so a name of "qualify_frequency >" and a
value of "0" returns nothing because the literal "qualify_frequency >"
doesn't match any name in the objset set.

So, the real task was to create a generic string matcher that can take a
left value, operator and a right value and perform the match. To that
end, strings.c has a new ast_strings_match(left, operator, right)
function.  Left and right are the strings to operate on and the operator
can be a string containing any of the following: = (or NULL or ""), !=,
>, >=, <, <=, like or regex.  If the operator is like or regex, the
right string should be a %-pattern or a regex expression.  If both left
and right can be converted to float, then a numeric comparison is
performed, otherwise a string comparison is performed.

To use this new function on ast_variables, 2 new functions were added to
config.c.  One that compares 2 ast_variables, and one that compares 2
ast_variable lists.  The former is useful when you want to compare 2
ast_variables that happen to be in a list but don't want to traverse the
list.  The latter will traverse the right list and return true if all
the variables in it match the left list.

Now, the backends' fields_cmp functions call ast_variable_lists_match
instead of ast_sorcery_changeset_create and they can now process the
same syntax as the realtime engines.  The realtime backend just passes
the variable list unaltered to the engine.  The only gotcha is that
there's no common realtime engine support for regex so that's been noted
in the api docs for ast_sorcery_retrieve_by_fields.

Only one more change to sorcery was done...  A new config flag
"allow_unqualified_fetch" was added to reg_sorcery_realtime.
"no": ignore fetches if no predicate fields were supplied.
"error": same as no but emit an error. (good for testing)
"yes": allow (the default);
"warn": allow but emit a warning. (good for testing)

Now on to res_pjsip...

pjsip_options was modified to retrieve aors with qualify_frequency > 0
rather than all endpoints then all aors.  Not only was this a big
improvement in realtime retrieval but even for config files there's an
improvement because we're not going through endpoints anymore.

res_pjsip_mwi was modified to retieve only endpoints with something in
the mailboxes field instead of all endpoints then testing mailboxes.

res_pjsip_registrar_expire was completely refactored.  It was retrieving
all contacts then setting up scheduler entries to check for expiration.
Now, it's a single thread (like keepalive) that periodically retrieves
only contacts whose expiration time is < now and deletes them.  A new
contact_expiration_check_interval was added to global with a default of
30 seconds.

Ross Beer reports that with this patch, his Asterisk startup time dropped
from around an hour to under 30 seconds.

There are still objects that can't be filtered at the database like
identifies, transports, and registrations.  These are not going to be
anywhere near as numerous as endpoints, aors, auths, contacts however.

Back to allow_unqualified_fetch.  If this is set to yes and you have a
very large number of objects in the database, the pjsip CLI commands
will attempt to retrive ALL of them if not qualified with a LIKE.
Worse, if you type "pjsip show endpoint <tab>" guess what's going to
happen? :)  Having a cache helps but all the objects will have to be
retrieved at least once to fill the cache.  Setting
allow_unqualified_fetch=no prevents the mass retrieve and should be used
on endpoints, auths, aors, and contacts.  It should NOT be used for
identifies, registrations and transports since these MUST be
retrieved in bulk.

Example sorcery.conf:

[res_pjsip]
endpoint=config,pjsip.conf,criteria=type=endpoint
endpoint=realtime,ps_endpoints,allow_unqualified_fetch=error

ASTERISK-25826 #close
Reported-by: Ross Beer
Tested-by: Ross Beer

Change-Id: Id2691e447db90892890036e663aaf907b2dc1c67
2016-03-27 22:43:27 -05:00
Leif Madsen 0da36fca6b Add initial support to build Docker images
This work-in-progress is the first step to being able to reliably
build Asterisk containers from the Asterisk source. I'm submitting
this based on feedback gained at AstriDevCon 2015.

Information about how to use this is provided in contrib/docker/README.md
and will result in a local Asterisk container being built right from
your source. I believe this can eventually be automated via
hub.docker.com.

Change-Id: Ifa070706d40e56755797097b6ed72c1e243bd0d1
2016-03-17 09:53:57 -05:00
George Joseph 471ff375fd install_prereq: Add packages for bundled pjproject
RedHat/CentOS needs python-devel
Debian/Ubuntu needs automake, libsrtp-dev and python-dev

Ubuntu also needed libncurses5-dev for cmenuselect so while not
needed for pjproject, I adedd it anyway.

Change-Id: Idf5fa16e2d87c687439621507e122cb9461d7089
2016-03-05 17:46:15 -06:00
George Joseph b8b7c2e428 alembic: Fix downgrade and tweak for sqlite
Downgrade had a few issues.  First there was an errant 'update' statement in
add_auto_dtmf_mode that looks like it was a copy/paste error.  Second, we
weren't cleaning up the ENUMs so subsequent upgrades on postgres failed
because the types already existed.

For sqlite...  sqlite doesn't support ALTER or DROP COLUMN directly.
Fortunately alembic batch_operations takes care of this for us if we
use it so the alter and drops were converted to use batch operations.

Here's an example downgrade:

    with op.batch_alter_table('ps_endpoints') as batch_op:
        batch_op.drop_column('tos_audio')
        batch_op.drop_column('tos_video')
        batch_op.add_column(sa.Column('tos_audio', yesno_values))
        batch_op.add_column(sa.Column('tos_video', yesno_values))
        batch_op.drop_column('cos_audio')
        batch_op.drop_column('cos_video')
        batch_op.add_column(sa.Column('cos_audio', yesno_values))
        batch_op.add_column(sa.Column('cos_video', yesno_values))

    with op.batch_alter_table('ps_transports') as batch_op:
        batch_op.drop_column('tos')
        batch_op.add_column(sa.Column('tos', yesno_values))
    # Can't cast integers to YESNO_VALUES, so dropping and adding is required
        batch_op.drop_column('cos')
        batch_op.add_column(sa.Column('cos', yesno_values))

Upgrades from base to head and downgrades from head to base were tested
repeatedly for postgresql, mysql/mariadb, and sqlite3.

Change-Id: I862b0739eb3fd45ec3412dcc13c2340e1b7baef8
2016-03-02 15:42:01 -07:00
George Joseph ba8adb4ce3 res_pjsip/config_transport: Allow reloading transports.
The 'reload' mechanism actually involves closing the underlying
socket and calling the appropriate udp, tcp or tls start functions
again.  Only outbound_registration, pubsub and session needed work
to reset the transport before sending requests to insure that the
pjsip transport didn't get pulled out from under them.

In my testing, no calls were dropped when a transport was changed
for any of the 3 transport types even if ip addresses or ports were
changed. To be on the safe side however, a new transport option was
added (allow_reload) which defaults to 'no'.  Unless it's explicitly
set to 'yes' for a transport, changes to that transport will be ignored
on a reload of res_pjsip.  This should preserve the current behavior.

Change-Id: I5e759850e25958117d4c02f62ceb7244d7ec9edf
2016-02-19 18:57:55 -06:00
George Joseph 9b13ab6a63 pjsip/alembic: Add missing columns to system and registration
ps_systems needed disable_tcp_switch
ps_registrations needed line and endpoint

ASTERISK-25737 #close

Change-Id: Iaf9c2d69e62243d9fa53104c28c5339c47d4ac19
2016-02-04 14:23:45 -06:00
George Joseph 52b29f9b4c pjsip/alembic: Fix definition of qualify_timeout
A recent commit set qualify_timeout to Decimal which isn't supported.
This path corrects it to Float.

Change-Id: I038f5274ba8cb60f8518a5845ce448d49306aadf
2016-01-31 20:20:47 -06:00
Richard Mudgett a4dcbdf50f Fix alembic branches on master.
Change-Id: I64ed21fec50eb833641ca49d92184f6aaabd86e8
2016-01-19 14:16:17 -06:00
Joshua Colp 2cdbd4d711 Merge "pjsip/alembic: Fix qualify_timeout column definition" 2016-01-18 05:49:45 -06:00
Daniel Journo c60d6c0162 pjsip/alembic: Fix qualify_timeout column definition
Corrects the qualify_timeout column type from Integer to Decimal

ASTERISK-25686 #close
Reported-by: Marcelo Terres

Change-Id: I757d0e3c011ee9be6cd5abd48bc92441a405d3c8
2016-01-16 19:58:17 +00:00
Daniel Journo 8182146e85 pjsip: Add option global/regcontext
Added new global option (regcontext) to pjsip. When set, Asterisk will
dynamically create and destroy a NoOp priority 1 extension
for a given endpoint who registers or unregisters with us.

ASTERISK-25670 #close
Reported-by: Daniel Journo

Change-Id: Ib1530c5b45340625805c057f8ff1fb240a43ea62
2016-01-13 11:42:20 -06:00
Richard Mudgett 1fffe71f77 res_pjsip_log_forwarder.c: Add CLI "pjsip show buildopts".
PJPROJECT has a function available to dump the compile time
options used when building the library.

* Add CLI "pjsip show buildopts" command.

* Update contrib/scripts/autosupport to get pjproject information.

Change-Id: Id93a6a916d765b2a2e5a1aeb54caaf83206be748
2016-01-12 20:27:47 -06:00
George Joseph a41aab477a pjsip_sdp_rtp: Add option endpoint/bind_rtp_to_media_address
On a system with multiple ip addresses in the same subnet, if a
transport is bound to a specific ip address and endpoint/media_address
 is set, the SIP/SDP will have the correct address in all fields but
the rtp stream MAY still originate from one of the other ip addresses,
most probably the "primary" ip address.  This happens because
 res_pjsip_sdp_rtp/create_rtp always calls ast_instance_new with
the "all" ip address (0.0.0.0 or ::).

The new option causes res_pjsip_sdp_rtp/create_rtp to call
ast_rtp_instance_new with the endpoint's media_address (if specified)
instead of the "all" address.  This causes the packets to originate from
the specified address.

ASTERISK-25632
ASTERISK-25637
Reported-by: Olivier Krief
Reported-by: Dan Journo

Change-Id: I3dfaa079e54ba7fb7c4fd1f5f7bd9509bbf8bd88
2016-01-11 18:41:31 -06:00
Joshua Colp e106292a92 Merge "Alembic: Increase column size of PJSIP AOR "contact"." 2016-01-11 16:59:11 -06:00
Joshua Colp 8bd9e2dcc0 Merge "Alembic: Add PJSIP global keep_alive_interval." 2016-01-11 16:59:05 -06:00
Mark Michelson c5e16fe33a Alembic: Add PJSIP global keep_alive_interval.
The keep_alive_interval option was added about a year ago, but no
alembic revision was created to add the appropriate column to the
database.

This commit fixes the problem and adds the column. This was discovered
by running the testsuite with automatic conversion to realtime enabled.

Change-Id: If3ef92a7c4f4844d08f8aae170d2178aec5c4c1a
2016-01-08 14:29:17 -06:00
Walter Doekes 64b2046f3d Add sipp-sendfax.xml and spandspflow2pcap.py to contrib/scripts.
The spandspflow2pcap.py creates pcap files from fax.log files, generated
through 'fax set debug on' when receiving a fax. An example fax.log is
included as spandspflow2pcap.log.

The sipp-sendfax.xml SIPp scenario can be used to replay that fax with a
recent version of SIPp.

ASTERISK-25660 #close

Change-Id: I4de8f28b084055b482ab8a5b28d28b605b0ed526
2016-01-06 14:12:40 +01:00
Mark Michelson cfb34adb83 Alembic: Increase column size of PJSIP AOR "contact".
When running the PJSIP AMI "show_endpoint" test with automatic
conversion to realtime, the test would fail. This was because the AOR
"contact" column was sized at 40, and the configured contact was larger
than that.

This commit increases the size of the contact column to 255 characters.

Change-Id: Ia65bc7fd37699b7c0eaef9629a1a31eab9a24ba1
2015-12-16 11:34:22 -06:00