Commit Graph

31764 Commits

Author SHA1 Message Date
Joshua C. Colp 56eb18f395 stasis: Remove stringfields and lock from change message.
When a subscribe or unsubscribe occurs a message is published
containing this information. This change makes it so that the
message no longer uses stringfields or a lock, as both are not
really needed for the message.

Change-Id: I3f4831931d79f94fd979baf48048738df5dc1632
2018-11-18 19:53:14 -04:00
Alexei Gradinari fa048183aa pjsip: New function PJSIP_PARSE_URI to parse URI and return part of URI
New dialplan function PJSIP_PARSE_URI added to parse an URI and return
a specified part of the URI.

This is useful when need to get part of the URI instead of cutting it
using a CUT function.

For example to get 'user' part of Remote URI
${PJSIP_PARSE_URI(${CHANNEL(pjsip,remote_uri)},user)}

ASTERISK-28144 #close

Change-Id: I5d828fb87f6803b6c1152bb7b44835f027bb9d5a
2018-11-18 15:27:48 -05:00
George Joseph d81a43893d Merge "pjproject-bundled: Use AST_DEVMODE for conditional compilation." 2018-11-18 14:11:58 -06:00
Joshua Colp 3077ad0c24 stasis: Add internal filtering of messages.
This change adds the ability for subscriptions to indicate
which message types they are interested in accepting. By
doing so the filtering is done before being dispatched
to the subscriber, reducing the amount of work that has
to be done.

This is optional and if a subscriber does not add
message types they wish to accept and set the subscription
to selective filtering the previous behavior is preserved
and they receive all messages.

There is also the ability to explicitly force the reception
of all messages for cases such as AMI or ARI where a large
number of messages are expected that are then generically
converted into a different format.

ASTERISK-28103

Change-Id: I99bee23895baa0a117985d51683f7963b77aa190
2018-11-18 15:08:16 -05:00
George Joseph 915b80709d CI: Add tmpfs to all jenkinsfiles
Change-Id: Ida29d70d48d5f39aabf0b25c66b51f79324a8cba
2018-11-18 11:39:21 -05:00
George Joseph ccc981e91a Merge "res/res_pjsip_nat: Fix logic for REINVITES" 2018-11-18 08:47:10 -06:00
George Joseph fe64ca0be8 Merge "taskprocessor: Prevent race creating new taskprocessor." 2018-11-17 17:28:41 -06:00
George Joseph f5e3832dff CI: Mount a tmpfs on /tmp for testsuite docker containers
Change-Id: I0566d81b0852f22066cd76d58eae5f1fda5602aa
(cherry picked from commit 73efe86436)
2018-11-17 17:07:31 -05:00
George Joseph be87185f6d CI: Pass work directory to runTestsuite
The testsuite can now use a user-specified work directory for
all it's temp files.  This allows the docker containers to use
a tmpfs backed directory for the temp files instead of it's
own write-layer image.

* runTestsuite.sh now accepts a --work-dir command line argument
  that gets exported as AST_WORK_DIR before running the testsuite.

* gates.jenkinsfile now specifies --work-dir to be
  <testsuite_dir>/astroot.

Since the Asterisk CI docker hosts now mount /srv/jenkins/workspace
on a tmpfs, asterisk should be compiled and the testsuite run all in
memory.

Change-Id: If5ee905a15821296c355bb84cda38950ad8edc45
(cherry picked from commit a335f4c9ad)
2018-11-17 17:05:39 -05:00
George Joseph 8399c8dae6 Merge "CI: Allow runUnittests to use 'expect' to run the tests" 2018-11-17 11:30:30 -06:00
Sungtae Kim 1dea497454 res/res_ari: Fix null endpoint handle
The res_ari(POST /channels/create handler) deos not check the endpoint
parameter length. And it causes core
dump.
Fixed it to check the parameter length. Also fixed memory leak.

ASTERISK-28169

Change-Id: Ibf10a9eb8a2e3a9ee1e13fbe748b2ecf955c3993
2018-11-17 04:05:39 +01:00
George Joseph d2f784cc3a Merge "core: Fix handling of restart from remote console." 2018-11-16 09:22:26 -06:00
George Joseph 8ff3435c8a CI: Allow runUnittests to use 'expect' to run the tests
There seems to be a race condition between starting the asterisk
daemon and attempting to use 'asterisk -r' that can cause the
control socket file to not be created.  Since all of the Jenkins
slaves have 'expect' installed, the runUnittests script can use
it to start asterisk in the forground and issue the commands
interactively.  This is much more reliable and it can also make
startup errors more visible since they'll be in the Jenkins console
output.

If 'expect' isn't installed, the original daemon/asterisk -r
process is used.

Also added a "core show settings" before running the tests
and added "notice,warning,error" to the console log.

Change-Id: Idd656085f854afede813ac241b9e312b31358160
2018-11-16 10:03:51 -05:00
Corey Farrell 9abd5e1004
taskprocessor: Prevent race creating new taskprocessor.
Task processors are retrieved using a 'get or create' pattern.  The
singleton container was unlocked between the get and create steps so
it's possible that two threads could create task processors with the
same name at the same time.

Change-Id: Id64fae94a6a1e940ddf38fde622dcd4391635382
2018-11-16 08:55:31 -05:00
Corey Farrell 752fd06d12
pjproject-bundled: Use AST_DEVMODE for conditional compilation.
We previously allowed resample and g711 codecs to be built when
TEST_FRAMEWORK was enabled.  This could cause errors if the testsuite
was run without this option enabled.  Switch the build system to allow
those codecs to be built when --enable-dev-mode is used.  This removes a
chance for strange testsuite errors from use of an inadequate pjsua
binary.

Change-Id: Iee8a3613cdb711fa7e7d217c5a775a575907ae22
2018-11-16 08:26:32 -05:00
Corey Farrell 02c7a061ea res_pjsip_caller_id: Use static pj_str_t for fromto header names.
PJSIP assumes that these header names are not allocated, does not clone
the name strings when reusing headers.

Block unload of res_pjsip_caller_id until shutdown to ensure static
memory stays valid.  It was previously unsafe to unload while any
sessions are active.

Change-Id: I190854dea943d6e441cf03733f8a0da661aea27f
2018-11-15 15:49:12 -05:00
George Joseph fc82312aab Merge "pbx_config: Only the first [globals] section is seen." 2018-11-15 07:48:20 -06:00
Torrey Searle d0554783e2 res/res_pjsip_nat: Fix logic for REINVITES
The presence of Record-Route in re-invites is optional, thus it is
important to make sure the dialog doesn't have a routset before
rewriting the contact header.

ASTERISK-28129 #close

Change-Id: Ic8ceb54ccfc93f7e315e476c514a2c777f2da7dc
2018-11-15 06:35:24 -05:00
Corey Farrell c3d7b19cdd core: Fix handling of restart from remote console.
We cannot use need_el_end and SIGURG when restarting.  Instead we need
to run el_end within the SIGHUP restartnow handler.

ASTERISK-28158

Change-Id: Ia852276363c81bdcf1aa29eb4558c5c2fa1218a0
2018-11-15 06:34:19 -05:00
George Joseph eb5b83b8ea AST-2018-010: Fix length of buffer needed for SRV and NAPTR results
When dn_expand was being called on SRV and NAPTR results, the
return value was being used to calculate the size of the buffer
needed to store the host names.  Since dn_expand returns the
length of the COMPRESSED name the buffer could be too short
to hold the EXPANDED name.  The expanded name is NULL terminated
so using strlen() is the correct way to determine the length
actually needed for the buffer.

ASTERISK-28127
Reported by: Jan Hoffmann

patches:
  patch.diff submitted by janhoffmann (license 6986)

Change-Id: I4d35d6c431c6c6836cb61d37b1378cc47f0b414d
2018-11-14 09:25:32 -05:00
Joshua Colp 9e151413db Merge "core: Ensure that el_end is always run when needed." 2018-11-14 07:06:38 -06:00
Joshua Colp dbfc5ae020 Merge "taskprocessor: Do not use separate allocation for stats or name." 2018-11-14 07:05:10 -06:00
George Joseph 39cfc56dd8 Merge "jansson-bundled: Patch for off-nominal crash." 2018-11-13 14:39:37 -06:00
Corey Farrell 4b24731640 test_res_pjsip_scheduler: Fix possible write after free in scheduler_policy.
It's possible for a 4th task to be spawned before we cancel.  This
results in a write to the already freed test_data1.  Wait long enough to
verify success of the cancelation before freeing test_data1.

Change-Id: I057e2fcbe97f8a175e50890be89c28c20490a20f
2018-11-13 13:26:06 -05:00
Robert Cripps da562eb82d bridge_native_rtp.c: Fail native bridge if no framing match.
ASTERISK-28110 #close

Change-Id: Ic64b8fc6a140a93fbdb2f97550a40d0ff334e607
2018-11-13 04:09:27 -05:00
Corey Farrell 944d90a7ea taskprocessor: Do not use separate allocation for stats or name.
Merge storage for the stats object and name string into the main
allocation for struct ast_taskprocessor.

Change-Id: I74fe9a7f357f0e6d63152f163cf5eef6428218e1
2018-11-12 09:56:14 -05:00
Joshua Colp 6f3275e54c Merge "res_pjsip.c: Make taskprocessor scheduling algorithm pick the shortest queue" 2018-11-12 05:38:44 -06:00
Corey Farrell 194e40122a core: Ensure that el_end is always run when needed.
* Ignore console=yes configuration option in remote console processes.
* Use new flag to tell consolethread to run el_end and exit when needed.

ASTERISK-28158

Change-Id: I9e23b31d4211417ddc88c6bbfd83ea4c9f3e5438
2018-11-11 09:23:15 -05:00
Corey Farrell d9add7e086
jansson-bundled: Patch for off-nominal crash.
pack_string crashed on non-NULL strings returned when s->has_error was
true if the string was the result of 's' format without '#', '%' or '+'.

Change-Id: Ic125df691d81ba2cbc413e37bdae657b304d20d0
2018-11-08 16:37:34 -05:00
Corey Farrell 8e34cb302e
pbx_config: Only the first [globals] section is seen.
If multiple [globals] sections are used (for example via separate
included files), only the first one is processed.  This can result in
lost global variables when using a modular extensions.conf.

ASTERISK-28146 #close

Change-Id: Iaac810c0a7c4d9b1bf8989fcc041cdb910ef08a0
2018-11-08 06:43:10 -05:00
Chris-Savinovich a3fc97aa13 res_pjsip: Send a 503 response when overload state if reliable transport.
When Asterisk's taskprocessors get overloaded we need to reduce the work
load. res_pjsip currently ignores new SIP requests and relies on SIP
retransmissions in the hope that the overload condition will clear soon
enough to handle the retransmitted SIP request.
This change adds the following code after ast_taskprocessor_alert_get()
has returned TRUE:
1- identifies transport type. If non-udp then send a 503 response
2- if transport type is udp/udp6 then ignore, as before.

Change-Id: I1c230b40d43a254ea0f226b7acf9ee480a5d3836
2018-11-07 07:59:03 -05:00
Joshua Colp d3bc9e6784 Merge "stasis: Clarify lifetime of topics." 2018-11-07 06:33:54 -06:00
Kevin Harwell fdca9cb64f res_pjsip: formatting error in documentation
The use of a '|' in the "global/debug" synopsis documentation caused the
generated html table on the wiki to add an extra column that included the
text after the pipe.

This patch replaces the pipe with a comma.

ASTERISK-28150

Change-Id: I3d79a6ca6d733d9cb290e779438114884b98a719
2018-11-06 18:05:09 -05:00
Alexei Gradinari 5f3f707793 res_pjsip.c: Make taskprocessor scheduling algorithm pick the shortest queue
The current round-robin method does not take the current taskprocessor
load into consideration when distributing requests.  Using the least-size
method the request goes to the taskprocessor that is servicing the least
number of active tasks at the current time.

Longer running tasks with the round-robin method can delay processing
tasks.

* Change the algorithm from round-robin to least-size for picking the
PJSIP taskprocessor from the default serializer pool.

Change-Id: I7b8d8cc2c2490494f579374b6af0a4868e3a37cd
2018-11-06 10:26:11 -05:00
George Joseph 65cbf60efc Merge "chan_sip: Attempt ast_do_pickup in handle_invite_replaces" 2018-11-05 09:32:55 -06:00
Joshua Colp bf579222c4 stasis: Clarify lifetime of topics.
As mentioned in the comment I've added in the code there is no
ability to unsubscribe all subscribers from a topic and explicitly
destroy it. This is not currently a problem as we have two types of
topics:

Long lived topics which exist for the lifetime of the system.
Ephemeral topics which feed a long lived topic.

In the case of the ephemeral topics there is no subscriber which does
not have its lifetime managed by the same entity that has created
the topic. This ensures that when the topic is being unreferenced the
subscribers are also unsubscribed and destroyed, allowing the topic
to ultimately be destroyed as well.

Change-Id: Ic5e244da7b16b1895ba1fc5ece481ebba5809c9a
2018-11-05 09:46:54 -05:00
Jasper Hafkenscheid 2cf5079205 chan_sip: Attempt ast_do_pickup in handle_invite_replaces
When a call pickup is performed using and invite with replaces header
the ast_do_pickup method is attempted and a PICKUP stasis message is sent.

ASTERISK-28081 #close
Reported-by: Luit van Drongelen

Change-Id: Ieb1442027a3ce6ae55faca47bc095e53972f947a
2018-11-02 10:21:52 -05:00
Pascal Cadotte Michaud ebff81e3a0
contrib/sip_to_pjsip: add a --quiet option to avoid prints
Using the --quiet or -q option in conjonction with /dev/stdout as the output
file allow the output to be used as a valid configuration.

Given a script that generates a valid sip.conf I can pipe the output of that
script into `sip_to_pjsip.py -q /dev/stdin /dev/stdout`. This allow me to use
that piped command in my pjsip.conf using the `exec` command.

ASTERISK-28136

Change-Id: I7b0e2e90e2549f3f8e01dc96701f111b5874c88d
2018-11-01 08:50:19 -04:00
George Joseph 7ece4af59b Merge "res_pjsip: Add XML documentation for "use_callerid_contact"" 2018-10-31 13:58:52 -05:00
George Joseph 5ea16f0cb5 Merge "alembic: Fix use_callerid_contact option add script." 2018-10-31 13:58:31 -05:00
George Joseph 26810197c7 Merge "pjsip: new endpoint's options to control Connected Line updates" 2018-10-31 13:57:15 -05:00
George Joseph bcd07a86ba Merge "contrib/sip_to_pjsip: handle setvar in conversion" 2018-10-31 13:55:48 -05:00
George Joseph f1f4450bdf Merge "chan_sip deprecation." 2018-10-31 13:53:07 -05:00
Joshua Colp 0c9e217c81 res_pjsip: Add XML documentation for "use_callerid_contact"
ASTERISK-28087

Change-Id: I69d48813ec514f5ef06c6de994cba52630e0a3b4
2018-10-31 13:22:04 +00:00
Richard Mudgett c7528f16e6 alembic: Fix use_callerid_contact option add script.
ASTERISK-28087

Change-Id: I046d018015427d0916fab571b5a4f5367476f729
2018-10-30 10:58:20 -05:00
Alexei Gradinari eee935983b pjsip: new endpoint's options to control Connected Line updates
This patch adds new options 'trust_connected_line' and 'send_connected_line'
to the endpoint.

The option 'trust_connected_line' is to control if connected line updates
are accepted from this endpoint.

The option 'send_connected_line' is to control if connected line updates
can be sent to this endpoint.

The default value is 'yes' for both options.

Change-Id: I16af967815efd904597ec2f033337e4333d097cd
2018-10-30 10:39:28 -05:00
Pascal Cadotte Michaud b0155f7e58 contrib/sip_to_pjsip: handle setvar in conversion
Given a sip.conf with the following content:

setvar FOO=1
setvar BAR=42

I want my generated pjsip.conf to containt the following set_vars

set_var FOO=1
set_var BAR=42

in the matching endpoint section.

Change-Id: I6c822401fda4133c3b44bf31e655b4eb939d4d26
2018-10-30 10:26:07 -05:00
George Joseph 584e08b81b Merge "res_pjsip_notify: improve realtime performance on CLI completion on the endpoint" 2018-10-29 13:23:05 -05:00
Alexei Gradinari e407b8af21 res_pjsip_notify: improve realtime performance on CLI completion on the endpoint
The module 'res_pjsip_notify' inefficiently makes a lot of DB requests
on CLI completion on the endpoint.

For example if there are 10k endpoints the module makes 10k requests
of these 10k records.

Even if a part of the endpoint entered
the module makes the same 10k requests and then filtered them by itself.

This patch gathers endpoints container by prefix
and adds all gathered endpoints to completion at once.

ASTERISK-28137 #close

Change-Id: Ic20024912cc77bf4d3e476c4cd853293c52b254b
2018-10-27 17:51:02 -05:00
Torrey Searle cac4ccef25 res_pjsip_session: add new flag use_callerid_contact
Add a new global flag to res_pjsip to allow the callerid to be used
as the username in the contact header.  This allows chan_pjsip to have
the same behavour as chan_sip

ASTERISK-28087 #close

Change-Id: I9a720e058323f6862a91c62f8a8c1a4b5c087b95
2018-10-26 10:39:03 +02:00