Commit Graph

27698 Commits

Author SHA1 Message Date
Alexei Gradinari
3cb8934de0 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 09:59:08 -03:00
zuul
69ced86c6c Merge "pjproject_bundled: Disable PJSIP_UNESCAPE_IN_PLACE" into 13 2016-04-29 15:08:33 -05:00
Joshua Colp
d65023b5a5 Merge "res_pjsip: Start body generator users after suppliers." into 13 2016-04-29 13:11:37 -05:00
zuul
3e5666eadc Merge "res_pjsip_pubsub.c: Fix body generator registration race." into 13 2016-04-29 13:06:27 -05:00
zuul
72ee8c1bf9 Merge "chan_sip: Make autocreated peers send PeerStatus events" into 13 2016-04-29 12:13:57 -05:00
Joshua Colp
1ce30f1fb5 Merge "res_pjsip_outbound_publish.c: Remove redundant flag check." into 13 2016-04-29 04:57:32 -05:00
zuul
cc8a50631e Merge "res_pjsip_pubsub.c: Add useful information to some messages." into 13 2016-04-28 23:01:59 -05:00
zuul
2ae097f144 Merge "res_pjsip_pubsub.h: Fix doxygen association." into 13 2016-04-28 22:43:32 -05:00
zuul
28e6978e82 Merge "res_pjsip: Add ability to identify by Authorization username" into 13 2016-04-28 17:49:56 -05:00
Richard Mudgett
7992923c70 res_pjsip: Start body generator users after suppliers.
Change-Id: I8f0b57841feaab56c8a4e821b5ccb4e05e5fbadb
2016-04-28 17:12:36 -05:00
Richard Mudgett
5dc0e082b2 res_pjsip_pubsub.c: Add useful information to some messages.
Change-Id: Ia0b2e15773894c599e5c5748bbc70e99f434192a
2016-04-28 17:06:01 -05:00
Richard Mudgett
f9e416f053 res_pjsip_pubsub.c: Fix body generator registration race.
Change-Id: Id8752073ef06472a2fd96080f4009fac42843e67
2016-04-28 17:03:07 -05:00
Richard Mudgett
b1b2019046 res_pjsip_pubsub.h: Fix doxygen association.
Change-Id: I110d3e3572598289fcd4215d966cf0c858f98632
2016-04-28 17:00:46 -05:00
Richard Mudgett
b7f07fdff5 res_pjsip_outbound_publish.c: Remove redundant flag check.
Change-Id: I0da80a3c3e0eae0c52ff27e7412ba027d6f52353
2016-04-28 16:58:54 -05:00
George Joseph
719ece5659 pjproject_bundled: Disable PJSIP_UNESCAPE_IN_PLACE
When pjsip_parse_uri is called with PJSIP_UNESCAPE_IN_PLACE enabled,
the input uri string will become corrupted if it contains escape sequences.
It's not possible to automatically strdup or strdupa the input string because
the output uri pj_str_t's will have pointers to chunks of the input string.
Getting around this would require more memory management code and wouldn't
be worth the savings of doing the unescape in place.

ASTERISK-25970 #close
Reported-by: Dmitriy Serov

Change-Id: I28dc0e599b5108f7959b9c46dc8278371b372f88
2016-04-28 15:54:07 -06:00
Joshua Colp
86fb803257 Merge "func_odbc: Check connection status before executing queries." into 13 2016-04-28 06:50:55 -05:00
George Joseph
38bed4515d 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 15:22:29 -06:00
Joshua Colp
a16aa467f5 Merge "config: Fix ast_config_text_file_save2 writability check for missing files" into 13 2016-04-27 16:20:31 -05:00
Joshua Colp
e0e03cd2c8 Merge "res_pjsip: disable multi domain to improve realtime performace" into 13 2016-04-27 14:03:53 -05:00
Mark Michelson
677d5b5151 func_odbc: Check connection status before executing queries.
A recent change to func_odbc made it so that a single connection was
maintained per DSN. The problem was that the code was optimistic about
the health of the connection after initially opening it and did nothing
to re-connect in case the connection had died.

This change adds a check before executing a query to ensure that the
connection to the database is still up and running.

ASTERISK-25963 #close
Reported by Ross Beer

Change-Id: Id33c86eb04ff48ca088bb2e3086c27b3b683491d
2016-04-27 13:23:37 -05:00
Alexei Gradinari
df3639700a 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:25 -05:00
Joshua Colp
e5c5fac8f1 Merge "res_pjsip: Add serialized scheduler (res_pjsip/pjsip_scheduler.c)" into 13 2016-04-27 10:12:31 -05:00
zuul
b4ddcc0e94 Merge "chan_sip: Give more time for TCP/TLS threads to stop." into 13 2016-04-27 08:50:35 -05:00
Joshua Colp
949bf6b282 chan_sip: Give more time for TCP/TLS threads to stop.
The unload process currently tells each TCP/TLS to terminate but
does not wait for them to do so. This introduces a race condition
where the container holding the threads may be destroyed before
the threads are able to remove themselves from it. When they
finally do the container is invalid and can't be used causing a
crash.

A previous change existed which waited a bit to wait for any
stranglers to finish. This change extends this and waits longer.

ASTERISK-25961 #close

Change-Id: Idc6262b670ca49ede32061159e323b7b63c6f3c6
2016-04-26 13:15:37 -03:00
Joshua Colp
6959f5484b app_queue: Fix crash when unloading module.
When unloading the app_queue module the members in each queue are
destroyed and as part of this they are removed from the pending
members container. Unfortunately a crash would occur as the container
was destroyed before the members were removed.

This change tweaks ordering so the container destruction occurs
after the members are destroyed.

ASTERISK-16115

Change-Id: I48c728668c55aee3d05b751a5d450fb57e87f44b
2016-04-26 05:52:43 -05:00
Joshua Colp
9d8f59aaf2 Merge changes from topic 'system_stress_patches' into 13
* changes:
  test_message.c: Wait longer in case dialplan also processes the test message.
  Manager: Short circuit AMI message processing.
  manager.c: Eliminate most RAII_VAR usage.
  manager_channels.c: Fix allocation failure crash.
2016-04-26 04:57:07 -05:00
Joshua Colp
4efc6b4315 Merge changes from topic 'system_stress_patches' into 13
* changes:
  Bridge system: Fix memory leaks and double frees on impart failure.
  bridge_softmix.c: Fix crash if channel fails to join mixing tech.
2016-04-26 04:56:36 -05:00
George Joseph
b38f1146e5 config: Fix ast_config_text_file_save2 writability check for missing files
A patch I did back in 2014 modified ast_config_text_file_save2 to check the
writability of the main file and include files before truncating and re-writing
them.  An unintended side-effect of this was that if a file doesn't exist,
the check fails and the write is aborted.

This patch causes ast_config_text_file_save2 to check the writability of the
parent directory of missing files instead of checking the file itself.  This
allows missing files to be created again.  A unit test was also added to
test_config to test saving of config files.

The regression was discovered when app_voicemail's passwordlocation=spooldir
feature stopped working.

ASTERISK-25917 #close
Reported-by: Jonathan Rose

Change-Id: Ic4dbe58c277a47b674679e49daed5fc6de349f80
2016-04-25 18:16:58 -05:00
Joshua Colp
83dadc4683 Merge "app_queue: queue members can receive multiple calls" into 13 2016-04-25 17:47:02 -05:00
kkm
29bab0d1a4 chan_sip: Make autocreated peers send PeerStatus events
Since Stasis has been introduced, an attempt to send AMI messages by an
autocreated peer caused a crash, and all events from autocreated peers were
semi-inadvertently disabled altogether in 0b83761. This change restores the
disabled functionality.

ASTERISK-25950

Change-Id: Iecc350f23db603fadb2f302064643ebe9664e974
2016-04-25 17:31:50 -05:00
zuul
6c28e8c827 Merge "Fix case sensitive actions in AMI QueueSummary and QueueStatus" into 13 2016-04-25 14:18:09 -05:00
Kevin Harwell
c345e530f4 app_queue: queue members can receive multiple calls
It was possible for a queue member that is a member of at least 2 or more
queues to receive mulitiple calls at the same time. This happened because
of a race between when a member was being rung and when the device state
notified the other queue(s) member object of the state change.

This patch makes it so when a queue member is being rung it gets added to
a global pool of queue members. If that same member is tried again, e.g.
from another queue, and it is found to already exist in the pending member
container then it will not ring that member.

ASTERISK-16115 #close

Change-Id: I546dd474776d158c2b6be44205353dee5bac7e48
2016-04-25 12:39:47 -05:00
zuul
a8f8e3c340 Merge "res_agi: Prevent run_agi from eating frames it shouldn't" into 13 2016-04-25 11:49:18 -05:00
DarkS
c0688a6398 Fix case sensitive actions in AMI QueueSummary and QueueStatus
ASTERISK-25954 #close
Reported by: Javier Acosta

Change-Id: I00be83d45cc7e8385de2523012bd196aafeeb256
2016-04-25 11:24:56 -05:00
George Joseph
eb7c581806 res_agi: Prevent run_agi from eating frames it shouldn't
The run_agi function is eating control frames when it shouldn't be. This is
causing issues when an AGI is run from CONNECTED_LINE_SEND_SUB in a blond
transfer.

Alice calls Bob. Bob attended transfers to Charlie but hangs up before Charlie
answers.

Alice gets the COLP UPDATE indicating Charlie but Charlie never gets an UPDATE
and is left thinking he's connected to Bob.

In this case, when CONNECTED_LINE_SEND_SUB runs on Alice's channel and it calls
an AGI, the extra eaten frames prevent CONNECTED_LINE_SEND_SUB from running on
Charlie's channel.

The fix was to accumulate deferrable frames in the "forever" loop instead of
dropping them, and re-queue them just before running the actual agi command
or exiting.

ASTERISK-25951 #close

Change-Id: I0f4bbfd72fc1126c2aaba41da3233a33d0433645
2016-04-25 08:55:11 -06:00
zuul
13ee3402ed Merge "func_odbc: Use one connection per DSN." into 13 2016-04-24 20:14:32 -05:00
zuul
84d2e4fb42 Merge "Remove reference to non-existent sip.conf option" into 13 2016-04-22 18:55:42 -05:00
zuul
77ae5cd7fd Merge "res_stasis: Handle re-enter stasis bridge with swap channel." into 13 2016-04-22 18:55:41 -05:00
zuul
09f8f8daa1 Merge "bridge: Hold off more than one imparting channel at a time." into 13 2016-04-22 18:29:19 -05:00
Richard Mudgett
ebf0724a83 test_message.c: Wait longer in case dialplan also processes the test message.
Bumped the wait from 1 second to 5 seconds.  The test message was hitting my
default call handler and failing the test because it took longer.

Change-Id: I3a03737f25e92983de00548fcc7bbc50dd7544ba
2016-04-22 16:44:05 -05:00
Richard Mudgett
ba63aa7c9e Manager: Short circuit AMI message processing.
Improve AMI message processing performance if there are no consumers
listening for the messages.  We now skip creating the AMI event message
text strings.

Change-Id: I7b22fc5ec4e500d00635c1a467aa8ea68a1bb2b3
2016-04-22 16:44:05 -05:00
Richard Mudgett
d5ee6acf28 manager.c: Eliminate most RAII_VAR usage.
* Made ast_manager_event_blob_create() not allocate the ao2 event object
with a lock as it is not needed.

Change-Id: I8e11bfedd22c21316012e0b9dd79f5918f644b7c
2016-04-22 16:44:05 -05:00
Richard Mudgett
7303e3dc96 manager_channels.c: Fix allocation failure crash.
An earlier allocation failure failed to create a channel snapshot for the
AMI HangupRequest/SoftHangupRequest event which resulted in a crash in
channel_hangup_request_cb().  Where the stasis message gets generated
cannot tell if the NULL snapshot returned was because of an allocation
failure or the channel was a dummy channel.

* Made channel_hangup_request_cb() check if the channel blob has a
snapshot and exit if it doesn't.

* Eliminated the RAII_VAR usage in channel_hangup_request_cb().

Change-Id: I0b6a1c4e95cbb7d80b2a7054c6eadecc169dfd24
2016-04-22 16:44:05 -05:00
Richard Mudgett
1e93f3d723 Bridge system: Fix memory leaks and double frees on impart failure.
You cannot reference the passed in features struct after calling
ast_bridge_impart().  Even if the call fails.

Change-Id: I902b88ba0d5d39520e670fb635078a367268ea21
2016-04-22 16:44:04 -05:00
Richard Mudgett
5e388d4188 bridge_softmix.c: Fix crash if channel fails to join mixing tech.
softmix_bridge_join() failed because of an allocation failure.  To address
this, the softmix bridge technology now checks if the channel failed to
join softmix successfully.  In addition, the bridge now begins the process
of kicking the channel out of the bridge so we don't have channels
partially in the bridge for very long.

* Fix the test_channel_feature_hooks.c unit tests.  The test channel must
have a valid codec to join the simple_bridge technology.  This patch makes
joining a bridge more strict by not allowing partially joined channels to
remain in the bridge.

Change-Id: I97e2ade6a2bcd1214f24fb839fda948825b61a2b
2016-04-22 16:44:04 -05:00
Mark Michelson
068ae54c76 func_odbc: Use one connection per DSN.
res_odbc was changed in Asterisk 13.8.0 to remove connection management,
opting instead to let unixodbc maintain open connections and return
those to Asterisk as requested.

This was a boon for realtime, since it meant that multiple threads could
potentially run parallel queries since they could each be using their
own database connections.

However, on the user-facing side, func_odbc, there were some inherent
behaviors being relied on that no longer hold true after the change.
One such reported behavior was that MySQL's LAST_INSERTED_ID() works
per-connection. This means that if Asterisk uses separate connections
for every database operation, whereas before it used one connection for
everything, we have broken expectations and functionality.

The fix provided in this patch is to make func_odbc use a single
database connection per DSN. This way, user-facing database usage will
have the same behavior as it did pre-13.8.0. However, realtime, which is
the real workhorse of database interaction, will continue to let
unixodbc manage connections.

ASTERISK-25938 #close
Reported by Edwin Vandamme

Change-Id: Iac961fe79154c6211569afcdfec843c0c24c46dc
2016-04-22 14:30:18 -05:00
Leif Madsen
6aeefa89bc Remove reference to non-existent sip.conf option
Option was removed in commit 7f883ef495

ASTERISK-25927 #close

Change-Id: I92f9b0196d9fc41d1d58354c07340c465ef1fcf8
2016-04-22 13:14:19 -05:00
Joshua Colp
6112a94d03 Merge "res_pjsip_callerid: Clear out display name if id->name is not valid" into 13 2016-04-21 16:25:00 -05:00
Diederik de Groot
e750ea9b5b lock.c: Check *lt before dereferencing it
*lt is NULL if t->tracking == 0

ASTERISK-25948 #close

Change-Id: I4a81af28f9c82a74aa82413d772a7dc8fa6f45ba
2016-04-21 11:35:37 -05:00
Richard Mudgett
a036c35903 res_stasis: Handle re-enter stasis bridge with swap channel.
We lose the fact that there is a swap channel if there is one.  We
currently wind up rejoining the stasis bridge as a normal join after the
swap channel has already been kicked from the bridge.

This patch preserves the swap channel so the AMI/ARI events can note that
the channel joining the bridge is swapping with another channel.  Another
benefit to swaqpping in one operation is if there are any channels that
get lonely (MOH, bridge playback, and bridge record channels).  The lonely
channels won't leave before the joining channel has a chance to come back
in under stasis if the swap channel is the only reason the lonely channels
are staying in the bridge.

ASTERISK-25947 #close
Reported by: Richard Mudgett

ASTERISK-24649
Reported by: John Bigelow

ASTERISK-24782
Reported by: John Bigelow

Change-Id: If37ea508831d1fed6dbfac2f191c638fc0a850ee
2016-04-20 15:45:46 -05:00