zuul [Wed, 16 Mar 2016 19:15:44 +0000 (14:15 -0500)]
Merge "app_stasis: Don't hang up if app is not registered"
zuul [Wed, 16 Mar 2016 17:14:17 +0000 (12:14 -0500)]
Merge "chan_sip.c: Simplify sip_pvt destructor call levels."
Andrew Nagy [Tue, 15 Mar 2016 18:31:19 +0000 (11:31 -0700)]
app_stasis: Don't hang up if app is not registered
This prevents pbx_core from hanging up the channel if the app isn't
registered.
ASTERISK-25846 #close
Change-Id: I63216a61f30706d5362bc0906b50b6f0544aebce
zuul [Tue, 15 Mar 2016 22:40:02 +0000 (17:40 -0500)]
Merge "pjproject: Pass (dont_)optimize flags to pjproject and fix pjsua"
Joshua Colp [Tue, 15 Mar 2016 20:55:27 +0000 (15:55 -0500)]
Merge "build_system: Split COMPILE_DOUBLE from DONT_OPTIMIZE"
zuul [Tue, 15 Mar 2016 15:27:09 +0000 (10:27 -0500)]
Merge "build: Add configure check for proto field of PJSIP TLS transport setting."
Joshua Colp [Tue, 15 Mar 2016 13:47:43 +0000 (08:47 -0500)]
Merge "res_pjsip_refer.c: Delay sending the initial SIP Notify with frag 100"
Richard Mudgett [Tue, 8 Mar 2016 00:56:05 +0000 (18:56 -0600)]
chan_sip.c: Simplify sip_pvt destructor call levels.
Remove destructor calling destroy_it calling really_destroy_it
for no benefit. Just make the destructor the really_destroy_it
function.
Change-Id: Idea0d47b27dd74f2488db75bcc7f353d8fdc614a
Joshua Colp [Mon, 14 Mar 2016 13:59:10 +0000 (10:59 -0300)]
build: Add configure check for proto field of PJSIP TLS transport setting.
Older versions of PJSIP do not have the proto field on the TLS transport
setting structure. This change adds a configure check so even if it is
not present we will still be able to build.
Change-Id: Ibf3f47befb91ed1b8194bf63888baa6fee05aba9
George Joseph [Sat, 12 Mar 2016 22:02:20 +0000 (15:02 -0700)]
build_system: Split COMPILE_DOUBLE from DONT_OPTIMIZE
I can't ever recall actually needing the intermediate files or the checking
that a double compile produces. What I CAN remember is every DONT_OPTIMIZE
build needing 3 invocations of gcc instead of 1 just to do the checks and
produce those intermediate files.
Having said that, Richard pointed out that the reason for the double compile
was that there were cases in the past where a submitted patch failed to compile
because the submitter never tried it with the optimizations turned on.
To get the best of both worlds, COMPILE_DOUBLE has been split into its own
option. If DONT_OPTIMIZE is turned on, COMPILE_DOUBLE will also be selected
BUT you can then turn it off if all you need are the debugging symbols. This
way you have to make an informed decision about disabling COMPILE_DOUBLE.
To allow COMPILE_DOUBLE to be both auto-selected and turned off, a new feature
was added to menuselect. The <use> element can now contain an "autoselect"
attribute which will turn the used member on but not create a hard dependency.
The cflags.xml implementation for COMPILE_DOUBLE looks like this...
<member name="DONT_OPTIMIZE" displayname="Disable Optimizations ...">
<use autoselect="yes">COMPILE_DOUBLE</use>
<support_level>core</support_level>
</member>
<member name="COMPILE_DOUBLE" displayname="Pre-compile with ...>
<depend>DONT_OPTIMIZE</depend>
<support_level>core</support_level>
</member>
When DONT_OPTIMIZE is turned on, COMPILE_DOUBLE is turned on because
of the use.
When DONT_OPTIMIZE is turned off, COMPILE_DOUBLE is turned off because
of the depend.
When COMPILE_DOUBLE is turned on, DONT_OPTIMIZE is turned on because
of the depend.
When COMPILE_DOUBLE is turned off, DONT_OPTIMIZE is left as is because
it only uses COMPILE_DOUBLE, it doesn't depend on it.
I also made a few tweaks to the ncurses implementation to move things
left a bit to allow longer descriptions.
Change-Id: Id49ca930ac4b5ec4fc2d8141979ad888da7b1611
George Joseph [Thu, 10 Mar 2016 19:09:13 +0000 (12:09 -0700)]
pjproject: Pass (dont_)optimize flags to pjproject and fix pjsua
The pjproject Makefile now uses the Asterisk optimization flags which
are determined by the setting of the DONT_OPTMIZE menuselect flag.
The Makefile was also restructured so a change to the top level
menuselect.makeopts will result in a rebuild of pjproject.
Also, "--disable-resample" was removed from the pjproject configure
options. Without resample, pjsua (which is used by the testsuite)
can't make audio calls. When it can't, it segfaults.
Change-Id: I24b0a4d0872acef00ed89b3c527a713ee4c2ccd4
Walter Doekes [Fri, 11 Mar 2016 22:03:08 +0000 (23:03 +0100)]
app_chanspy: Fix occasional deadlock with ChanSpy and Local channels.
Channel masquerading had a conflict with autochannel locking.
When locking autochannel->channel, the channel is fetched from the
autochannel and then locked. During the fetch, the autochannel -- which
has no locks itself -- can be modified by someone who owns the channel
lock. That means that the value of autochan->channel cannot be trusted
until you hold the lock.
In practice, this caused problems with Local channels getting
masqueraded away while the ChanSpy attempted to get info from that
channel. The old channel which was about to get removed got locked, but
the new (replaced) channel got unlocked (no-op). Because the replaced
channel was now locked (and would never get unlocked), it couldn't get
removed from the channel list in a timely manner, and would now cause
deadlocks when iterating over the channel list.
This change checks the autochannel after locking the channel for changes
to the autochannel. If the channel had been changed, the lock is
reobtained on the new channel.
In theory it seems possible that after this fix, the lock attempt on the
old (wrong) channel can be on an already destroyed lock, maybe causing
a crash. But that hasn't been observed in the wild and is harder induce
than the current deadlock.
Thanks go to Filip Frank for suggesting a fix similar to this and
especially to IRC user hexanol for pointing out why this deadlock was
possible and testing this fix. And to Richard for catching my rookie
while loop mistake ;)
ASTERISK-25321 #close
Change-Id: I293ae0014e531cd0e675c3f02d1d118a98683def
zuul [Thu, 10 Mar 2016 12:44:25 +0000 (06:44 -0600)]
Merge "install_prereq: Add packages for bundled pjproject"
zuul [Wed, 9 Mar 2016 02:36:47 +0000 (20:36 -0600)]
Merge "res_pjsip_caller_id: Anonymize 'From' when caller id presentation is prohibited"
zuul [Tue, 8 Mar 2016 23:04:55 +0000 (17:04 -0600)]
Merge "pjproject_bundled: Remove --with-external-pa from configure options."
zuul [Tue, 8 Mar 2016 18:27:15 +0000 (12:27 -0600)]
Merge "res_pjsip: Strip spaces from items parsed from comma-separated lists"
Joshua Colp [Tue, 8 Mar 2016 17:29:45 +0000 (11:29 -0600)]
Merge "main/cli.c: Refactor function to print seconds formatted"
zuul [Tue, 8 Mar 2016 17:12:37 +0000 (11:12 -0600)]
Merge "res_odbc_transaction: fix some format tab"
George Joseph [Tue, 8 Mar 2016 03:34:12 +0000 (20:34 -0700)]
pjproject_bundled: Remove --with-external-pa from configure options.
Not sure why it was there in the first place as we already specify
--disable-sound.
Change-Id: Ia80a40e8b1e1acc287955ab11ba1fbd0c7d4cff9
George Joseph [Sun, 6 Mar 2016 20:38:41 +0000 (13:38 -0700)]
res_pjsip: Strip spaces from items parsed from comma-separated lists
Configurations like "aors = a, b, c" were either ignoring everything after "a"
or trying to look up " b". Same for mailboxes, ciphers, contacts and a few
others.
To fix, all the strsep(©, ",") calls have been wrapped in ast_strip. To
facilitate this, ast_strip, ast_skip_blanks and ast_skip_nonblanks were
updated to handle null pointers.
In some cases, an ast_strlen_zero() test was added to skip consecutive commas.
There was also an attempt to ast_free an ast_strdupa'd string in
ast_sip_for_each_aor which was causing a SEGV. I removed it.
Although this issue was reported for realtime, the issue was in the res_pjsip
modules so all config mechanisms were affected.
ASTERISK-25829 #close
Reported-by: Mateusz Kowalski
Change-Id: I0b22a2cf22a7c1c50d4ecacbfa540155bec0e7a2
Rodrigo Ramírez Norambuena [Mon, 7 Mar 2016 08:02:45 +0000 (05:02 -0300)]
res_odbc_transaction: fix some format tab
Change-Id: I265e4ac47c629c9a63dd86b59df82a7ab3c64384
Rodrigo Ramírez Norambuena [Thu, 18 Feb 2016 04:58:01 +0000 (01:58 -0300)]
main/cli.c: Refactor function to print seconds formatted
Refactor and created function ast_cli_print_timestr_fromseconds to print
seconds formatted: year(s) week(s) day(s) hour(s) second(s)
This function now is used in addons/cdr_mysql.c,cdr_pgsql.c, main/cli.c,
res_config_ldap.c, res_config_pgsql.c.
Change-Id: Ibeb8634102cd11d3f8623398b279cb731bcde36c
George Joseph [Sat, 5 Mar 2016 02:37:44 +0000 (19:37 -0700)]
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
zuul [Fri, 4 Mar 2016 13:04:15 +0000 (07:04 -0600)]
Merge "third_party/Makefile.rules: Replace unsupported != operator with $(shell ...)"
zuul [Fri, 4 Mar 2016 03:45:39 +0000 (21:45 -0600)]
Merge "config_transport: Fix objects returned by ast_sip_get_transport_states"
George Joseph [Wed, 24 Feb 2016 23:25:09 +0000 (16:25 -0700)]
res_pjsip_caller_id: Anonymize 'From' when caller id presentation is prohibited
Per RFC3325, the 'From' header is now anonymized on outgoing calls when
caller id presentation is prohibited.
TID = trust_id_outbound
PRO = Set(CALLERID(pres)=prohib)
USR = endpoint/from_user
DOM = endpoint/from_domain
PAI = YES(privacy=off), NO(not sent), PRI(privacy=full) (assumes send_pai=yes)
Conditions |Result
--------------------|----------------------------------------------------
TID PRO USR DOM |PAI FROM
--------------------|----------------------------------------------------
Y Y abc def.ghi |PRI "Anonymous" <sip:abc@def.ghi>
Y Y abc |PRI "Anonymous" <sip:abc@anonymous.invalid>
Y Y def.ghi |PRI "Anonymous" <sip:anonymous@def.ghi>
Y Y |PRI "Anonymous" <sip:anonymous@anonymous.invalid>
Y N abc def.ghi |YES <sip:abc@def.ghi>
Y N abc |YES <sip:abc@<ip_address>>
Y N def.ghi |YES "Caller Name" <sip:<caller_exten>@def.ghi>
Y N |YES "Caller Name" <sip:<caller_exten>@<ip_address>>
N Y abc def.ghi |NO "Anonymous" <sip:abc@def.ghi>
N Y abc |NO "Anonymous" <sip:abc@anonymous.invalid>
N Y def.ghi |NO "Anonymous" <sip:anonymous@def.ghi>
N Y |NO "Anonymous" <sip:anonymous@anonymous.invalid>
N N abc def.ghi |YES <sip:abc@def.ghi>
N N abc |YES <sip:abc@<ip_address>>
N N def.ghi |YES "Caller Name" <sip:<caller_exten>@def.ghi>
N N |YES "Caller Name" <sip:<caller_exten>@<ip_address>>
ASTERISK-25791 #close
Reported-by: Anthony Messina
Change-Id: I2c82a5ca1413c2c00fb62ea95b0ae8e97af54dc9
zuul [Fri, 4 Mar 2016 02:01:15 +0000 (20:01 -0600)]
Merge "alembic: Fix downgrade and tweak for sqlite"
zuul [Fri, 4 Mar 2016 01:57:43 +0000 (19:57 -0600)]
Merge "loader: Retry dlopen when loading fails"
George Joseph [Thu, 3 Mar 2016 23:34:51 +0000 (16:34 -0700)]
third_party/Makefile.rules: Replace unsupported != operator with $(shell ...)
Apparently the != operator is fairly new so I've replaced it with
the old $(shell ...) syntax.
Change-Id: I16b2e1878a4f91e7e9740abd427f9639f933c479
Reported-by: Richard Mudgett
zuul [Thu, 3 Mar 2016 23:37:45 +0000 (17:37 -0600)]
Merge "bridge.c: Crash during attended transfer when missing a local channel half"
George Joseph [Sat, 23 Jan 2016 21:50:57 +0000 (14:50 -0700)]
loader: Retry dlopen when loading fails
Although we use the RTLD_LAZY flag when calling dlopen
the first time on a module, this only defers resolution
for function calls. Pointer references to functions are
determined at link time so dlopen expects them to be there.
Since we don't cross-module link, pointers to functions
in other modules won't be available and dlopen will fail.
Doing a "hardened" build also causes problems because it
typically sets "-z now" on the ld command line which
overrides RTLD_LAZY at run time.
If the failing module isn't a GLOBAL_SYMBOLS module, then
dlopen will be called again after all the GLOBAL_SYMBOLS
modules have been loaded and they'll eventually resolve.
If the calling module IS a GLOBAL_SYMBOLS module itself
and a third module depends on it, then there's an issue
because the second time through the dlopen loop,
GLOBAL_SYMBOLS modules aren't given any special treatment
and since the order in which dlopen is called isn't
deterministic, the dependent may again be tried before the
module it needs is loaded.
Simple solution: Save modules that fail load_resource
because of a dlopen error in a list and retry them
immediately after the first pass. Keep retrying until
the failed list is empty or we reach a #defined max
retries. Error messages are suppressed until the final
pass which also gets rid of those confusing error messages
about module failures that are later corrected.
Change-Id: Iddae1d97cd2f00b94e61662447432765755f64bb
zuul [Thu, 3 Mar 2016 20:51:10 +0000 (14:51 -0600)]
Merge "res_pjsip_dtmf_info: NULL terminate the message body."
Kevin Harwell [Tue, 1 Mar 2016 22:18:21 +0000 (16:18 -0600)]
bridge.c: Crash during attended transfer when missing a local channel half
It's possible for the transferer channel to get hung up early during the
attended transfer process. For instance, a phone may send a "bye" immediately
upon receiving a sip notify that contains a sip frag 100 (I'm looking at you
Jitsi). When this occurs a race begins between the transferer being hung up
and completion of the transfer code.
If the channel hangs up too early during a transfer involving stasis bridging
for instance, then when the created local channel goes to look up its swap
channel (and associated datastore) it can't find it (since it is no longer in
the bridge) thus it fails to enter the stasis application. Consequently, the
created local channel(s) hang up as well. If the timing is just right then the
bridging code attempts to add the message link with missing local channel(s).
Hence the crash.
Unfortunately, there is no great way to solve the problem of the unexpected
"bye". While we can't guarantee we won't receive an early hangup, and in this
case still fail to enter the stasis application, we can make it so asterisk
does not crash.
This patch does just that by locking the local channel structure, checking
that the local channel's peer has not been lost, and then continuing. This
keeps the local channel's peer from being ripped out from underneath it by
the local/unreal hangup code while attempting to set the stasis message link.
ASTERISK-25771
Change-Id: Ie6d6061e34c7c95f07116fffac9a09e5d225c880
Kevin Harwell [Wed, 2 Mar 2016 00:08:52 +0000 (18:08 -0600)]
res_pjsip_refer.c: Delay sending the initial SIP Notify with frag 100
During the transfer process, some phones (okay it was the Jitsi softphone,
but maybe others are out there) send a "bye" immediately after receiving a
SIP Notify. When a "bye" is received early for some types of transfers the
transferer channel may no longer be available during late stage transfer
processing.
For instance, during an attended transfer involving stasis bridging at one
point the created local channel looks for an associated swap channel in
order to retrieve the stasis application name. If the transferer has hung
up then the local channel will fail to find it. The local channel then has
no way to know which stasis app to enter, so it fails and hangs up as well.
Thus the transfer does not complete as expected.
This patch delays the sending of the initial notify in order to give the
transfer process enough time to gather the necessary data for a successful
transfer.
ASTERISK-25771
Change-Id: I09cfc9a5d6ed4c007bc70625e0972b470393bf16
zuul [Thu, 3 Mar 2016 17:30:41 +0000 (11:30 -0600)]
Merge "build-system: Allow building with static pjproject"
Joshua Colp [Thu, 3 Mar 2016 14:26:10 +0000 (10:26 -0400)]
res_pjsip_dtmf_info: NULL terminate the message body.
PJSIP does not ensure that when printing the message body the
buffer will be NULL terminated. This is problematic when searching
for the signal and duration values of the DTMF.
This change ensures the buffer is always NULL terminated.
Change-Id: I52653a1a60c93092d06af31a27408d569cc98968
Joshua Colp [Thu, 3 Mar 2016 13:40:53 +0000 (07:40 -0600)]
Merge "func_callerid.c: Update REDIRECTING reason documentation."
Joshua Colp [Thu, 3 Mar 2016 13:40:40 +0000 (07:40 -0600)]
Merge "SIP diversion: Fix REDIRECTING(reason) value inconsistencies."
Joshua Colp [Thu, 3 Mar 2016 11:32:59 +0000 (05:32 -0600)]
Merge "res_pjsip_send_to_voicemail.c: Allow either quoted or not send_to_vm reason."
zuul [Thu, 3 Mar 2016 03:24:14 +0000 (21:24 -0600)]
Merge "res_pjsip_send_to_voicemail.c: Fix off-nominal double channel unref."
zuul [Thu, 3 Mar 2016 00:02:38 +0000 (18:02 -0600)]
Merge "CHAOS: cleanup possible null vars on msg alloc failure"
George Joseph [Wed, 2 Mar 2016 02:03:04 +0000 (19:03 -0700)]
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
George Joseph [Wed, 2 Mar 2016 21:55:48 +0000 (14:55 -0700)]
config_transport: Fix objects returned by ast_sip_get_transport_states
ast_sip_get_transport_states was returning a container of internal_state
objects instead of ast_sip_transport_state objects. This was causing
transport lookups to fail, most noticably in res_pjsip_nat, which
couldn't find the correct external addresses. This was causing contacts
to go out with internal ip addresses.
ASTERISK-25830 #close
Reported-by: Sean Bright
Change-Id: I1aee6a2fd46c42e8dd0af72498d17de459ac750e
Scott Griepentrog [Wed, 2 Mar 2016 17:17:54 +0000 (11:17 -0600)]
CHAOS: cleanup possible null vars on msg alloc failure
In message.c, if msg_alloc fails to init the string field,
vars may be null, so use a null tolerant cleanup.
In res_pjsip_messaging.c, if msg_data_create fails, mdata
will be null, so use a null tolerant cleanup.
ASTERISK-25323
Change-Id: Ic2d55c2c3750d5616e2a05ea92a19c717507ff56
Scott Griepentrog [Wed, 2 Mar 2016 15:34:10 +0000 (09:34 -0600)]
CHAOS: prevent crash on failed strdup
This patch avoids crashing on a null pointer
if the strdup() allocation fails.
ASTERISK-25323
Change-Id: I3f67434820ba53b53663efd6cbb42749f4f6c0f5
Richard Mudgett [Tue, 1 Mar 2016 00:11:33 +0000 (18:11 -0600)]
func_callerid.c: Update REDIRECTING reason documentation.
Change-Id: I6e8d39b0711110a4bceafa652e58b30465e28386
Richard Mudgett [Sat, 27 Feb 2016 00:57:17 +0000 (18:57 -0600)]
SIP diversion: Fix REDIRECTING(reason) value inconsistencies.
Previous chan_sip behavior:
Before this patch chan_sip would always strip any quotes from an incoming
reason and pass that value up as the REDIRECTING(reason). For an outgoing
reason value, chan_sip would check the value against known values and
quote any it didn't recognize. Incoming 480 response message reason text
was just assigned to the REDIRECTING(reason).
Previous chan_pjsip behavior:
Before this patch chan_pjsip would always pass the incoming reason value
up as the REDIRECTING(reason). For an outgoing reason value, chan_pjsip
would send the reason value as passed down.
With this patch:
Both channel drivers match incoming reason values with values documented
by REDIRECTING(reason) and values documented by RFC5806 regardless of
whether they are quoted or not. RFC5806 values are mapped to the
equivalent REDIRECTING(reason) documented value and is set in
REDIRECTING(reason). e.g., an incoming RFC5806 'unconditional' value or a
quoted string version ('"unconditional"') is converted to
REDIRECTING(reason)'s 'cfu' value. The user's dialplan only needs to deal
with 'cfu' instead of any of the aliases.
The incoming 480 response reason text supported by chan_sip checks for
known reason values and if not matched then puts quotes around the reason
string and assigns that to REDIRECTING(reason).
Both channel drivers send outgoing known REDIRECTING(reason) values as the
unquoted RFC5806 equivalent. User custom values are either sent as is or
with added quotes if SIP doesn't allow a character within the value as
part of a RFC3261 Section 25.1 token. Note that there are still
limitations on what characters can be put in a custom user value. e.g.,
embedding quotes in the middle of the reason string is silly and just
going to cause you grief.
* Setting a REDIRECTING(reason) value now recognizes RFC5806 aliases.
e.g., Setting REDIRECTING(reason) to 'unconditional' is converted to the
'cfu' value.
* Added missing malloc() NULL return check in res_pjsip_diversion.c
set_redirecting_reason().
* Fixed potential read from a stale pointer in res_pjsip_diversion.c
add_diversion_header(). The reason string needed to be copied into the
tdata memory pool to ensure that the string would always be available.
Otherwise, if the reason string returned by reason_code_to_str() was a
user's reason string then the string could be freed later by another
thread.
Change-Id: Ifba83d23a195a9f64d55b9c681d2e62476b68a87
Richard Mudgett [Sat, 27 Feb 2016 00:54:53 +0000 (18:54 -0600)]
res_pjsip_send_to_voicemail.c: Allow either quoted or not send_to_vm reason.
Change-Id: Id6350b3c7d4ec8df7ec89863566645e2b0f441fd
Richard Mudgett [Tue, 1 Mar 2016 02:41:55 +0000 (20:41 -0600)]
res_pjsip_send_to_voicemail.c: Fix off-nominal double channel unref.
* Fix double unref of other_party channel in off nominal path.
* This is unlikely to be a real problem. However, for safety,
in handle_incoming_request() keep the datastore ref with the
other_party channel ref until we are finished with the other_party
channel.
Change-Id: I78f22547bf0bb99fb20814ceab75952bd857f821
George Joseph [Tue, 19 Jan 2016 03:54:28 +0000 (20:54 -0700)]
build-system: Allow building with static pjproject
Background here:
http://lists.digium.com/pipermail/asterisk-dev/2016-January/075266.html
From CHANGES:
* To help insure that Asterisk is compiled and run with the same known
version of pjproject, a new option (--with-pjproject-bundled) has been
added to ./configure. When specified, the version of pjproject specified
in third-party/versions.mak will be downloaded and configured. When you
make Asterisk, the build process will also automatically build pjproject
and Asterisk will be statically linked to it. Once a particular version
of pjproject is configured and built, it won't be configured or built
again unless you run a 'make distclean'.
To facilitate testing, when 'make install' is run, the pjsua and pjsystest
utilities and the pjproject python bindings will be installed in
ASTDATADIR/third-party/pjproject.
The default behavior remains building with the shared pjproject
installation, if any.
Building:
All you have to do is include the --with-pjproject-bundled option on
the ./configure command line (and remove any existing --with-pjproject
option if specified). Everything else is automatic.
Behind the scenes:
The top-level Makefile was modified to include 'third-party' in the
list of MOD_SUBDIRS.
The third-party directory was created to contain any third party
packages that may be needed in the future. Its Makefile automatically
iterates over any subdirectories passing on targets.
The third-party/pjproject directory was created to house the pjproject
source distribution. Its Makefile contains targets to download, patch
configure, generate dependencies, compile libs, apps and python bindings,
sanitized build.mak and generate a symbols list.
When bootstrap.sh is run, it automatically includes the configure.m4
file in third-party/pjproject. This file has a macro to download and
conifgure pjproject and get and set PJPROJECT_INCLUDE, PJPROJECT_DIR
and PJPROJECT_BUNDLED. It also tests for the capabilities like
PJ_TRANSACTION_GRP_LOCK by parsing preprocessor output as opposed to
trying to compile. Of course, bootstrap.sh is only run once and the
configure file is incldued in the patch.
When configure is run with the new options, the macro in configure.m4
triggers the download, patch, conifgure and tests. No compilation is
performed at this time. The downloaded tarball is cached in /tmp so
it doesn't get downloaded again on a distclean.
When make is run in the top-level Asterisk source directory, it will
automatically descend all the subdirectories in third_party just as it
does for addons, apps, etc. The top-level Makefile makes sure that
the 'third-party' is built before 'main' so that dependencies from the
other directories are built first.
When main does build, a new shared library (libasteriskpj) is created that
links statically to the pjproject .a files and exports all their symbols.
The asterisk binary links to that, just as it does with libasteriskssl.
When Asterisk is installed, the pjsua and pjsystest apps, and the pjproject
python bindings are installed in ASTDATADIR/third-party/pjproject. This
will facilitate testing, including running the testsuite which will be
updated to check that directory for the pjsua module ahead of the system
python library.
Modules should continue to depend on pjproject if they use pjproject APIs
directly. They should not care about the implementation. No changes to any
res_pjsip modules were made.
Change-Id: Ia7a60c28c2e9ba9537c5570f933c1ebcb20a3103
Joshua Colp [Tue, 1 Mar 2016 12:00:43 +0000 (06:00 -0600)]
Merge "chan_sip.c: Fix T.38 issues caused by leaving a bridge."
Joshua Colp [Tue, 1 Mar 2016 12:00:35 +0000 (06:00 -0600)]
Merge "res_pjsip_t38.c: Back out part of an earlier fix attempt."
Joshua Colp [Tue, 1 Mar 2016 12:00:27 +0000 (06:00 -0600)]
Merge "bridge core: Add owed T.38 terminate when channel leaves a bridge."
Joshua Colp [Tue, 1 Mar 2016 12:00:17 +0000 (06:00 -0600)]
Merge "channel api: Create is_t38_active accessor functions."
Joshua Colp [Tue, 1 Mar 2016 12:00:03 +0000 (06:00 -0600)]
Merge "bridge_channel: Don't settle owed events on an optimization."
Joshua Colp [Tue, 1 Mar 2016 11:59:54 +0000 (05:59 -0600)]
Merge "channel.c: Route all control frames to a channel through the same code."
zuul [Mon, 29 Feb 2016 22:55:33 +0000 (16:55 -0600)]
Merge "res_pjsip_mwi: Turn some NOTICEs and WARNINGs into debug 1s."
Richard Mudgett [Mon, 22 Feb 2016 22:59:40 +0000 (16:59 -0600)]
chan_sip.c: Fix T.38 issues caused by leaving a bridge.
chan_sip could not handle AST_T38_TERMINATED frames being sent to it when
the channel left the bridge. The action resulted in overlapping outgoing
reINVITEs. The testsuite tests/fax/sip/directmedia_reinvite_t38 was not
happy.
* Force T.38 to be remembered as locally bridged. Now when the channel
leaves the native RTP bridge after T.38, the channel remembers that it has
already reINVITEed the media back to Asterisk. It just needs to terminate
T.38 when the AST_T38_TERMINATED arrives.
* Prevent redundant AST_T38_TERMINATED from causing problems. Redundant
AST_T38_TERMINATED frames could cause overlapping outgoing reINVITEs if
they happen before the T.38 state changes to disabled. Now the T.38 state
is set to disabled before the reINVITE is sent.
ASTERISK-25582 #close
Change-Id: I53f5c6ce7d90b3f322a942af1a9bcab6d967b7ce
Richard Mudgett [Fri, 19 Feb 2016 00:27:02 +0000 (18:27 -0600)]
res_pjsip_t38.c: Back out part of an earlier fix attempt.
This backs out item 4 of the
4875e5ac32f5ccad51add6a4216947bfb385245d
commit. Item 4 added the t38_bye_supplement. Unfortunately, the frame
that it puts into the bridge may or may not be processed by the time the
bridged peer is kicked out of the bridge. If it is processed then all is
well. However, if it is not processed then that channel is stuck in fax
mode until it hangs up or maybe if it joins another bridge for T.38
faxing.
ASTERISK-25582
Change-Id: Ib20a03ecadf1bf8a0dcadfadf6c2f2e60919a9f7
Richard Mudgett [Mon, 22 Feb 2016 19:54:47 +0000 (13:54 -0600)]
bridge core: Add owed T.38 terminate when channel leaves a bridge.
The channel is now going to get T.38 terminated when it leaves the
bridging system and the bridged peers are going to get T.38 terminated as
well.
ASTERISK-25582
Change-Id: I77a9205979910210e3068e1ddff400dbf35c4ca7
Richard Mudgett [Fri, 19 Feb 2016 22:01:17 +0000 (16:01 -0600)]
channel api: Create is_t38_active accessor functions.
ASTERISK-25582
Change-Id: I69451920b122de7ee18d15bb231c80ea7067a22b
Richard Mudgett [Sat, 20 Feb 2016 01:06:14 +0000 (19:06 -0600)]
bridge_channel: Don't settle owed events on an optimization.
Local channel optimization could cause DTMF digits to be duplicated.
Pending DTMF end events would be posted to a bridge when the local channel
optimizes out and is replaced by the channel further down the chain. When
the real digit ends, the channel would get another DTMF end posted to the
bridge.
A -- LocalA;1/n -- LocalA;2/n -- LocalB;1 -- LocalB;2 -- B
1) LocalA has the /n flag to prevent optimization.
2) B is sending DTMF to A through the local channel chain.
3) When LocalB optimizes out it can move B to the position of LocalB;1
4) Without this patch, when B swaps with LocalB;1 then LocalB;1 would
settle an owed DTMF end to the bridge toward LocalA;2.
5) When B finally ends its DTMF it sends the DTMF end down the chain.
6) Without this patch, A would hear the DTMF digit end when LocalB
optimizes out and when B ends the original digit.
ASTERISK-25582
Change-Id: I1bbd28b8b399c0fb54985a5747f330a4cd2aa251
Richard Mudgett [Mon, 22 Feb 2016 18:15:34 +0000 (12:15 -0600)]
channel.c: Route all control frames to a channel through the same code.
Frame hooks can conceivably return a control frame in exchange for an
audio frame inside ast_write(). Those returned control frames were not
handled quite the same as if they were sent to ast_indicate(). Now it
doesn't matter if you use ast_write() to send an AST_FRAME_CONTROL to a
channel or ast_indicate().
ASTERISK-25582
Change-Id: I5775f41421aca2b510128198e9b827bf9169629b
George Joseph [Thu, 25 Feb 2016 21:13:19 +0000 (14:13 -0700)]
sorcery: Refactor create, update and delete to better deal with caches
The ast_sorcery_create, update and delete function have been refactored
to better deal with caches and errors.
The action is now called on all non-caching wizards first. If ANY succeed,
the action is called on all caching wizards and the observers are notified.
This way we don't put something in the cache (or update or delete) before
knowing the action was performed in at least 1 backend and we only call the
observers once even if there were multiple writable backends.
ast_sorcery_create was never adding to caches in the first place which
was preventing contacts from getting added to a memory_cache when they
were created. In turn this was causing memory_cache to emit errors if
the contact was deleted before being retrieved (which would have
populated the cache).
ASTERISK-25811 #close
Reported-by: Ross Beer
Change-Id: Id5596ce691685a79886e57b0865888458d6e7b46
George Joseph [Thu, 25 Feb 2016 21:39:54 +0000 (14:39 -0700)]
res_pjsip_mwi: Turn some NOTICEs and WARNINGs into debug 1s.
There are a few cases where we're emitting notices or warnings
for things that really need neither, like a client retrying to subscribe
to mwi when they're not conifgured for it. They get a 404 so there's no
need for non-debug messages.
Change-Id: I05e38a7ff6c2f2521146f4be6a79731b9864e61f
Joshua Colp [Sat, 27 Feb 2016 16:18:26 +0000 (10:18 -0600)]
Merge "res_pjsip/config_transport: Allow reloading transports."
Joshua Colp [Sat, 27 Feb 2016 14:50:20 +0000 (08:50 -0600)]
Merge "res_sorcery_memory_cache: Fix SEGV in some CLI commands"
zuul [Thu, 25 Feb 2016 23:56:42 +0000 (17:56 -0600)]
Merge "chan_sip: Optionally supply fromuser/fromdomain in SIP dial string."
George Joseph [Thu, 25 Feb 2016 20:17:04 +0000 (13:17 -0700)]
res_sorcery_memory_cache: Fix SEGV in some CLI commands
A few of the CLI commands weren't checking for enough arguments
and were SEGVing.
Change-Id: Ie6494132ad2fe54b4f014bcdc112a37c36a9b413
zuul [Thu, 25 Feb 2016 00:40:15 +0000 (18:40 -0600)]
Merge "chan_sip.c: Suppress T.38 SDP c= line if addr is the same."
zuul [Thu, 25 Feb 2016 00:26:06 +0000 (18:26 -0600)]
Merge "res_config_sqlite3: Fix crashes when reading peers from sqlite3 tables"
zuul [Wed, 24 Feb 2016 16:18:01 +0000 (10:18 -0600)]
Merge "rtp_engine.h: Remove extraneous semicolons."
zuul [Tue, 23 Feb 2016 23:41:35 +0000 (17:41 -0600)]
Merge "res_pjsip_config_wizard: Add command to export primitive objects"
Richard Mudgett [Tue, 23 Feb 2016 01:31:24 +0000 (19:31 -0600)]
rtp_engine.h: Remove extraneous semicolons.
Change-Id: Ib462633d396fa941379dfef648dcd2245e350084
Richard Mudgett [Tue, 23 Feb 2016 20:57:42 +0000 (14:57 -0600)]
chan_sip.c: Suppress T.38 SDP c= line if addr is the same.
Use the correct comparison function since we only care if the address
without the port is the same.
Change-Id: Ibf6c485f843a1be6dee58a47b33d81a7a8cbe3b0
Joshua Colp [Mon, 22 Feb 2016 16:55:03 +0000 (10:55 -0600)]
Merge "res_pjproject: Add ability to map pjproject log levels to Asterisk log levels"
Christof Lauber [Tue, 16 Feb 2016 14:14:15 +0000 (15:14 +0100)]
res_config_sqlite3: Fix crashes when reading peers from sqlite3 tables
Introduced realloaction of ast_str buf in sqlite3_escape functions in case
the returned buffer from threadstorage was actually too small.
Change-Id: I3c5eb43aaade93ee457943daddc651781954c445
George Joseph [Thu, 11 Feb 2016 17:01:05 +0000 (10:01 -0700)]
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
Walter Doekes [Fri, 19 Feb 2016 10:30:15 +0000 (11:30 +0100)]
chan_sip: Optionally supply fromuser/fromdomain in SIP dial string.
Previously you could add [!dnid] to the SIP dial string to alter the To:
header. This change allows you to alter the From header as well.
SIP dial string extra options now look like this:
[![touser[@todomain]][![fromuser][@fromdomain]]]
INCOMPATIBLE CHANGE: If you were using an exclamation mark in your To:
header, that is no longer possible.
ASTERISK-25803 #close
Change-Id: I2457e9ba7a89eb1da22084bab5a4d4328e189db7
zuul [Fri, 19 Feb 2016 00:28:50 +0000 (18:28 -0600)]
Merge "Fix failing threadpool_auto_increment test."
zuul [Thu, 18 Feb 2016 23:59:36 +0000 (17:59 -0600)]
Merge "res_pjsip_outbound_publish: Fix processing 412 response"
George Joseph [Sun, 7 Feb 2016 23:34:20 +0000 (16:34 -0700)]
res_pjproject: Add ability to map pjproject log levels to Asterisk log levels
Warnings and errors in the pjproject libraries are generally handled by
Asterisk. In many cases, Asterisk wouldn't even consider them to be warnings
or errors so the messages emitted by pjproject directly are either superfluous
or misleading. A good exampe of this are the level-0 errors pjproject emits
when it can't open a TCP/TLS socket to a client to send an OPTIONS. We don't
consider a failure to qualify a UDP client an "ERROR", why should a TCP/TLS
client be treated any differently?
A config file for res_pjproject has bene added (pjproject.conf) and a new
log_mappings object allows mapping pjproject levels to Asterisk levels
(or nothing). The defaults if no pjproject.conf file is found are the same
as those that were hard-coded into res_pjproject initially: 0,1 = LOG_ERROR,
2 = LOG_WARNING, 3,4,5 = LOG_DEBUG<level>
Change-Id: Iba7bb349c70397586889b8f45b8c3d6c6c8c3898
Joshua Colp [Thu, 18 Feb 2016 19:12:03 +0000 (13:12 -0600)]
Merge "app_queue: fix Calculate talktime when is first call answered"
Alexei Gradinari [Thu, 18 Feb 2016 16:55:39 +0000 (11:55 -0500)]
res_pjsip_outbound_publish: Fix processing 412 response
When Asterisk receives a 412 (Conditional Request Failed) response
it has to recreate publish session.
There is bug in res_pjsip_outbound_publish.c
The function sip_outbound_publish_client_alloc is called with wrong object
while processing 412 (Conditional Request Failed) response.
This patch fixes it.
ASTERISK-25229 #close
Change-Id: I3b62f2debf6bb1e5817cde7b13ea39ef2bf14359
Mark Michelson [Thu, 18 Feb 2016 17:15:22 +0000 (11:15 -0600)]
Fix failing threadpool_auto_increment test.
The threadpool_auto_increment test fails infrequently for a couple of
reasons
* The threadpool listener was notified of fewer tasks being pushed than
were actually pushed
* The "was_empty" flag was set to an unexpected value.
The problem is that the test pushes three tasks into the threadpool.
Test expects the threadpool to essentially gather those three tasks, and
then distribute those to the threadpool threads. It also expects that as
the tasks are pushed in, the threadpool listener is alerted immediately
that the tasks have been pushed. In reality, a task can be distributed
to the threadpool threads quicker than expected, meaning that the
threadpool has already emptied by the time each subsequent task is
pushed. In addition, the internal threadpool queue can be delayed so
that the threadpool listener is not alerted that a task has been pushed
even after the task has been executed.
From the test's point of view, there's no way to be able to predict
exactly the order that task execution/listener notifications will occur,
and there is no way to know which listener notifications will indicate
that the threadpool was previously empty.
For this reason, the test has been updated to only check the things it
can check. It ensures that all tasks get executed, that the threads go
idle after the tasks are executed, and that the listener is told the
proper number of tasks that were pushed.
Change-Id: I7673120d74adad64ae6894594a606e102d9a1f2c
Richard Mudgett [Wed, 17 Feb 2016 19:30:06 +0000 (13:30 -0600)]
cel.c: Fix mismatch in ast_cel_track_event() return type.
The return type of ast_cel_track_event() is not large enough to return all
64 potential bits of the event enable mask. Fortunately, the defined CEL
events do not really need all 64 bits and the return value is only used to
determine if the requested CEL event is enabled.
* Made the ast_cel_track_event() return 0 or 1 only so the return value
can fit inside an int type instead of zero or a truncated 64 bit non-zero
value.
Change-Id: I783d932320db11a95c7bf7636a72b6fe2566904c
Rodrigo Ramírez Norambuena [Wed, 17 Feb 2016 05:37:43 +0000 (02:37 -0300)]
app_queue: fix Calculate talktime when is first call answered
Fix calculate of average time for talktime is wrong when is completed the
first call beacuse the time for talked would be that call.
ASTERISK-25800 #close
Change-Id: I94f79028935913cd9174b090b52bb300b91b9492
George Joseph [Tue, 16 Feb 2016 22:37:48 +0000 (15:37 -0700)]
res_odbc: Fix exports.in for missing symbols
res_odbc.exports.in was missing a few symbols.
Changed to wildcards.
Change-Id: Ieadd76df24e43ea92577f651d478a0f7b742c30c
George Joseph [Tue, 16 Feb 2016 18:20:57 +0000 (11:20 -0700)]
res_statsd: Fix exports.in for missing symbols
res_statsd.export.in was missing the _va variations of the log
functions causing Asterisk to crash in res_pjsip if OPTIONAL_API
wasn't enabled.
ASTERISK-25727 #close
Reported-by: Gergely Dömsödi
Change-Id: I395729f9f51bdd33c5ca757f5f96ebedad74077b
George Joseph [Tue, 16 Feb 2016 03:31:38 +0000 (20:31 -0700)]
res_pjsip_config_wizard: Add command to export primitive objects
A new command (pjsip export config_wizard primitives) has been added that
will export all the pjsip objects it created to the console or a file
suitable for reuse in a pjsip.conf file.
ASTERISK-24919 #close
Reported-by: Ray Crumrine
Change-Id: Ica2a5f494244b4f8345b0437b16d06aa0484452b
George Joseph [Mon, 15 Feb 2016 21:37:30 +0000 (14:37 -0700)]
res_pjsip_caller_id: Fix segfault when replacing rpid or pai header
If the PJSIP_HEADER dialplan function adds a PAI or RPID header and send_rpid
or send_pai is set, res_pjsip_caller_id attemps to retrieve, parse and modify
the header added by the dialplan function. Since the header added by the
dialplan function is generic string, there are no virtual functions to parse
the uri and we get a segfault when we try. Since the modify, was really only
an overwrite, we now just delete the old header if it was type PJSIP_H_OTHER
and recreate it.
This raises a question for another time though: What should happen with
duplicate headers? Right now res_pjsip_header_funcs doesn't check for dups
so if it's session supplement is loaded after res_pjsip_caller_id's (or any
other module that adds headers), there'll be dups in the message.
ASTERISK-25337 #close
Change-Id: I5e296b52d30f106b822c0eb27c4c2b0e0f71c7fa
zuul [Mon, 15 Feb 2016 21:39:47 +0000 (15:39 -0600)]
Merge "Fix creation race of contact_status structures."
Mark Michelson [Mon, 15 Feb 2016 19:08:22 +0000 (13:08 -0600)]
Fix creation race of contact_status structures.
It is possible when processing a SIP REGISTER request to have two
threads end up creating contact_status structures in sorcery.
contact_status is created using a "find or create" function. If two
threads call into this at the same time, each thread will fail to find
an existing contact_status, and so both will end up creating a new
contact status.
During testing, we would see sporadic failures because the
PJSIP_CONTACT() dialplan function would operate on a different
contact_status than what had been updated by res_pjsip/pjsip_options.
The fix here is two-fold:
1) The "find or create" function for contact_status now has a lock
around the entire operation. This way, if two threads attempt the
operation simultaneously, the first to get there will create the object,
and the second will find the object created by the first thread.
2) res_sorcery_memory has had its create callback updated so that it
will not allow for objects with duplicate IDs to be created.
Change-Id: I55b1460ff1eb0af0a3697b82d7c2bac9f6af5b97
Joshua Colp [Mon, 15 Feb 2016 18:52:22 +0000 (14:52 -0400)]
res_pjsip_pubsub: Move where the subscription is stored to after initialized.
A problem arose when testing the AMI subscription listing actions where it
was possible for a subscription that had not been fully initialized to be
listed. This was problematic as the underlying listing code would crash.
This change makes it so the subscription tree is fully set up before it is
added to the list of subscriptions. This ensures that when the listing actions
get the subscription it is valid.
ASTERISK-25738 #close
Change-Id: Iace2b13641c31bbcc0d43a39f99aba1f340c0f48
zuul [Fri, 12 Feb 2016 22:50:18 +0000 (16:50 -0600)]
Merge "res_pjsip: Refactor load_module/unload_module"
zuul [Fri, 12 Feb 2016 22:50:13 +0000 (16:50 -0600)]
Merge "res_pjsip: Handle pjsip_dlg_create_uas deprecation"
George Joseph [Tue, 9 Feb 2016 23:34:05 +0000 (16:34 -0700)]
res_pjsip: Refactor load_module/unload_module
load_module was just too hairy with every step having to clean up all
previous steps on failure.
Some of the pjproject init calls have now been moved to a separate
load_pjsip function and the unload_pjsip function was enhanced to clean
up everything if an error happened at any stage of the load process.
In the process, a bunch of missing pj_shutdowns, serializer_pool_shutdowns
and ast_threadpool_shutdowns were also corrected.
Change-Id: I5eec711b437c35b56605ed99537ebbb30463b302
zuul [Thu, 11 Feb 2016 23:04:50 +0000 (17:04 -0600)]
Merge "Resources/res_phoneprov: fix memory leak and heap-use-after-free"
Badalyan Vyacheslav [Wed, 10 Feb 2016 04:42:11 +0000 (04:42 +0000)]
Resources/res_phoneprov: fix memory leak and heap-use-after-free
* heap-use-after-free happens when we free "cfg"
but then use "value" which refers to it
* A memory leak occurs because in some cases
it is not released "defaults"
ASTERISK-25721 #close
Reported by: Badalyan Vyacheslav
Tested by: Badalyan Vyacheslav
Change-Id: I3807d3f4726df6864430ec144cf6265d3f538469
Sean Bright [Thu, 11 Feb 2016 17:21:42 +0000 (12:21 -0500)]
func_iconv: Ensure output strings are properly terminated.
ASTERISK-25272 #close
Reported by: Etienne Lessard
patches:
AST-25272.patch submitted by Etienne Lessard (license #6394)
Change-Id: Id75ad202300960a1e91afe15e319d992936ecc17