Commit Graph

1214 Commits

Author SHA1 Message Date
Naveen Albert accedd4c3e chan_iax2: Improve authentication debugging.
Improves and adds some logging to make it easier
for users to debug authentication issues.

Resolves: #286
(cherry picked from commit 833ee80789)
2024-01-12 18:29:18 +00:00
Sean Bright 22f31ecedd chan_iax2.c: Avoid crash with IAX2 switch support.
A change made in 82cebaa0 did not properly handle the case when a
channel was not provided, triggering a crash. ast_check_hangup(...)
does not protect against NULL pointers.

Fixes #180

(cherry picked from commit d26a00ef34)
2023-09-06 16:55:59 +00:00
Naveen Albert ede67a99be chan_iax2: Fix jitterbuffer regression prior to receiving audio.
ASTERISK_29392 (a security fix) introduced a regression by
not processing frames when we don't have an audio format.

Currently, chan_iax2 only calls jb_get to read frames from
the jitterbuffer when the voiceformat has been set on the pvt.
However, this only happens when we receive a voice frame, which
means that prior to receiving voice frames, other types of frames
get stalled completely in the jitterbuffer.

To fix this, we now fallback to using the format negotiated during
call setup until we've actually received a voice frame with a format.
This ensures we're always able to read from the jitterbuffer.

ASTERISK-30354 #close
ASTERISK-30162 #close

Change-Id: Ie4fd1e8e088a145ad89e0427c2100a530e964fe9
2023-02-28 07:55:13 -06:00
Philip Prindeville 3e054c9ebc res_crypto: Use EVP API's instead of legacy API's
ASTERISK-30046 #close

Change-Id: I5c738756de75fd27ebad54be144c0ac6193f21b2
2022-09-12 16:19:37 -05:00
Naveen Albert ff044c222b chan_iax2: Add missing options documentation.
Adds missing dial resource option documentation.

ASTERISK-30164 #close

Change-Id: I674e1fc9b1e5d67a20599bd4b418ce294d48fc83
2022-08-10 08:36:21 -05:00
Naveen Albert c654486547 general: Improve logging levels of some log messages.
Adjusts some logging levels to be more or less important,
that is more prominent when actual problems occur and less
prominent for less noteworthy things.

ASTERISK-30153 #close

Change-Id: Ifc8f7df427aa018627db462125ae744986d3261b
2022-08-01 11:03:46 -05:00
Naveen Albert 5f60caa402 chan_iax2: Allow compiling without OpenSSL.
ASTERISK_30007 accidentally made OpenSSL a
required depdendency. This adds an ifdef so
the relevant code is compiled only if OpenSSL
is available, since it only needs to be executed
if OpenSSL is available anyways.

ASTERISK-30083 #close

Change-Id: Iad05c1a9a8bd2a48e7edf8d234eaa9f80779e34d
2022-07-11 04:11:09 -05:00
Naveen Albert 169e553320 chan_iax2: Prevent deadlock due to duplicate autoservice.
If a switch is invoked using chan_iax2, deadlock can result
because the PBX core is autoservicing the channel while chan_iax2
also then attempts to service it while waiting for the result
of the switch. This removes servicing of the channel to prevent
any conflicts.

ASTERISK-30064 #close

Change-Id: Ie92f206d32f9a36924af734ddde652b21106af22
2022-06-06 17:43:59 -05:00
Naveen Albert fbe960ca42 chan_iax2: Prevent crash if dialing RSA-only call without outkey.
Currently, if attempting to place a call to a peer that only allows
RSA authentication, if we fail to provide an outkey when placing
the call, Asterisk will crash.

This exposes the broader issue that IAX2 is prone to causing a crash
if encryption or decryption is attempted but we never initialized
the encryption and decryption keys. In other words, if the logic
to use encryption in chan_iax2 is not perfectly aligned with the
decision to build keys in the first place, then a crash is not
only possible but probable. This was demonstrated by ASTERISK_29264,
for instance.

This permanently prevents such events from causing a crash by explicitly
checking that keys are initialized properly before setting the flags
to use encryption for the call. Instead of crashing, the call will
now abort.

ASTERISK-30007 #close

Change-Id: If925c3d86099ceac7f621804f2532baac5050c9a
2022-05-02 08:56:53 -05:00
Naveen Albert 0d11938e92 chan_iax2: Fix spacing in netstats command
The iax2 show netstats command previously didn't contain
enough spacing in the header to properly align the table
header with the table body. This caused column headers
to not align with the values on longer channel names.

Some spacing is added to account for the longest channel
names that display (before truncation occurs) so that
columns are always properly aligned.

ASTERISK-29895 #close
patches:
  61205_misaligned2.patch submitted by Birger Harzenetter (license 5870)

Change-Id: I450ce6bb81157b9d6d149007e53b749f237b6d9f
2022-03-28 15:12:04 -05:00
Naveen Albert 7bc8ef2681 chan_iax2: Fix perceived showing host address.
ASTERISK_22025 introduced a regression that shows
the host IP and port as the perceived IP and port
again, as opposed to showing the actual perceived
address. This fixes this by showing the correct
information.

ASTERISK-29048 #close

Change-Id: I0ad3e25bc6b449e83ce72ea5d1a1cdba72aa304a
2022-03-25 17:32:16 -05:00
Alexander Traud 726d6dd166 channels: Fix for Doxygen.
ASTERISK-29762

Change-Id: Ia8811ac12b93ff8c18164699c6fbc604cb0a23f7
2021-11-19 09:02:06 -06:00
Alexander Traud 4051434be4 chan_iax2: Fix for Doxygen.
ASTERISK-29737

Change-Id: I282003cc553989fd5c19ceeac9e478fa4ee06cec
2021-11-18 12:48:49 -06:00
Josh Soref d46ba42910 channels: Spelling fixes
Correct typos of the following word families:

appease
permanently
overriding
residue
silliness
extension
channels
globally
reference
japanese
group
coordinate
registry
information
inconvenience
attempts
cadence
payloads
presence
provisioning
mimics
behavior
width
natively
syslabel
not owning
unquelch
mostly
constants
interesting
active
unequipped
brodmann
commanding
backlogged
without
bitstream
firmware
maintain
exclusive
practically
structs
appearance
range
retransmission
indication
provisional
associating
always
whether
cyrillic
distinctive
components
reinitialized
initialized
capability
switches
occurring
happened
outbound

ASTERISK-29714

Change-Id: Ife52ee89cd2170b684fa651ca72b1cb911a57339
2021-11-16 05:35:29 -06:00
Naveen Albert df9aeea4c8 chan_iax2: Allow both secret and outkey at dial time
Historically, the dial syntax for IAX2 has held that
an outkey (used only for RSA authenticated calls)
and a secret (used only for plain text and MD5 authenticated
calls, historically) were mutually exclusive, and thus
the same position in the dial string was used for both
values.

Now that encryption is possible with RSA authentication,
this poses a limitation, since encryption requires a
secret and RSA authentication requires an outkey. Thus,
the dial syntax is extended so that both a secret and
an outkey can be specified.

The new extended syntax is backwards compatible with the
old syntax. However, a secret can now be specified after
the outkey, or the outkey can be specified after the secret.
This makes it possible to spawn an encrypted RSA authenticated
call without a corresponding peer being predefined in iax.conf.

ASTERISK-29707 #close

Change-Id: I1f8149313ed760169d604afbb07720a8b07dd00e
2021-11-08 11:26:21 -06:00
Naveen Albert 7ff6c43760 chan_iax2: Add encryption for RSA authentication
Adds support for encryption to RSA-authenticated
calls. Also prevents crashes if an RSA IAX2 call
is initiated to a switch requiring encryption
but no secret is provided.

ASTERISK-20219

Change-Id: I18f1f9d7c59b4f9cffa00f3b94a4c875846efd40
2021-10-07 18:23:48 -05:00
Naveen Albert 3072c540bb chan_iax2: Add ANI2/OLI information element
Adds an information element for ANI2 so that
Originating Line Information can be transmitted
over IAX2 channels.

ASTERISK-29605 #close

Change-Id: Iaeacdf6ccde18eaff7f776a0f49fee87dcb549d2
2021-09-02 14:17:11 -05:00
Kevin Harwell 1b62831f2c AST-2021-008 - chan_iax2: remote crash on unsupported media format
If chan_iax2 received a packet with an unsupported media format, for
example vp9, then it would set the frame's format to NULL. This could
then result in a crash later when an attempt was made to access the
format.

This patch makes it so chan_iax2 now ignores/drops frames received
with unsupported media format types.

ASTERISK-29392 #close

Change-Id: Ifa869a90dafe33eed8fd9463574fe6f1c0ad3eb1
2021-07-22 16:17:05 -05:00
Alexander Traud 8c461845c8 chan_iax2: System Header strings is included via asterisk.h/compat.h.
The system header strings was included mistakenly with commit 3de0204.
That header is included via asterisk.h and there via the compat.h.

Change-Id: I3dc49060e275295f785670c87cc65fd3c3abd24a
2021-03-10 04:21:40 -06:00
George Joseph 91b0778791 chan_iax2.c: Require secret and auth method if encryption is enabled
If there's no secret specified for an iax2 peer and there's no secret
specified in the dial string, Asterisk will crash if the auth method
requested by the peer is MD5 or plaintext.  You also couldn't specify
a default auth method in the [general] section of iax.conf so if you
don't have static peers defined and just use the dial string, Asterisk
will still crash even if you have a secret specified in the dial string.

* Added logic to iax2_call() and authenticate_reply() to print
  a warning and hanhup the call if encryption is requested and
  there's no secret or auth method.  This prevents the crash.

* Added the ability to specify a default "auth" in the [general]
  section of iax.conf.

ASTERISK-29624
Reported by: N A

Change-Id: I5928e16137581f7d383fcc7fa04ad96c919e6254
2021-02-09 09:16:07 -06:00
Alexander Traud 28faafd1c4 Compiler fixes for GCC when printf %s is NULL
ASTERISK-29146

Change-Id: Ib04bdad87d729f805f5fc620ef9952f58ea96d41
2020-11-03 15:47:33 -06:00
Sean Bright 32ce6e9a06 channels: Allow updating variable value
When modifying an already defined variable in some channel drivers they
add a new variable with the same name to the list, but that value is
never used, only the first one found.

Introduce ast_variable_list_replace() and use it where appropriate.

ASTERISK-23756 #close
Patches:
  setvar-multiplie.patch submitted by Michael Goryainov

Change-Id: Ie1897a96c82b8945e752733612ee963686f32839
2019-09-12 16:00:07 -05:00
Kevin Harwell 3656c42cb0 various modules: json integer overflow
There were still a few places in the code that could overflow when "packing"
a json object with a value outside the base type integer's range. For instance:

unsigned int value = INT_MAX + 1
ast_json_pack("{s: i}", value);

would result in a negative number being "packed". In those situations this patch
alters those values to a ast_json_int_t, which widens the value up to a long or
long long.

ASTERISK-28480

Change-Id: Ied530780d83e6f1772adba0e28d8938ef30c49a1
2019-08-01 15:31:48 -06:00
Kevin Harwell 9637e1dfdc MWI: Update modules that subscribe to MWI to use new API calls
The MWI core recently got some new API calls that make tracking MWI state
lifetime more reliable. This patch updates those modules that subscribe to
specific MWI topics to use the new API. Specifically, these modules now
subscribe to both MWI topics and MWI state.

ASTERISK-28442

Change-Id: I32bef880b647246823dbccdf44a98d384fcabfbd
2019-07-08 18:12:49 -05:00
George Joseph c5c953c1f1 Fixes for GCC 9
Various fixes for issues caught by gcc 9.  Mostly snprintf
trying to copy to a buffer potentially too small.

ASTERISK-28412

Change-Id: I9e85a60f3c81d46df16cfdd1c329ce63432cf32e
2019-05-10 10:22:55 -06:00
Kevin Harwell ff0d0ac23a mwi core: Move core MWI functionality into its own files
There is enough MWI functionality to warrant it having its own 'c' and header
files. This patch moves all current core MWI data structures, and functions
into the following files:

main/mwi.h
main/mwi.c

Note, code was simply moved, and not modified. However, this patch is also in
preparation for core MWI changes, and additions to come.

Change-Id: I9dde8bfae1e7ec254fa63166e090f77e4d3097e0
2019-04-23 17:40:15 -05:00
Corey Farrell 021ce938ca
astobj2: Remove legacy ao2_container_alloc routine.
Replace usage of ao2_container_alloc with ao2_container_alloc_hash or
ao2_container_alloc_list.  Remove ao2_container_alloc macro.

Change-Id: I0907d78bc66efc775672df37c8faad00f2f6c088
2018-11-21 09:56:16 -05: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
ktyerman e1908ea484 chan_iax2: better handling for timeout and EINTR
The iax2 module is not handling timeout and EINTR case properly. Mainly when
there is an interupt to the kernel thread. In case of ast_io_wait recieves a
signal, or timeout it can be an error or return 0 which eventually escapes the
thread loop, so that it cant recieve any data. This then causes the modules
receive queue to build up on the kernel and stop any communications via iax in
asterisk.

The proposed patch is for the iax module, so that timeout and EINTR does not
exit the thread.

ASTERISK-27705
Reported-by: Kirsty Tyerman

Change-Id: Ib4c32562f69335869adc1783608e940c3535fbfb
2018-06-13 16:47:02 -06:00
Alexander Traud 99aed78078 crypto.h: Repair ./configure --with-ssl=PATH.
ASTERISK-27908

Change-Id: Iac49d9f82faeb8a4611c6805906bd6d650b1b1d8
2018-06-08 13:01:53 +02:00
Corey Farrell b5914d90ac Fix GCC 8 build issues.
This fixes build warnings found by GCC 8.  In some cases format
truncation is intentional so the warning is just suppressed.

ASTERISK-27824 #close

Change-Id: I724f146cbddba8b86619d4c4a9931ee877995c84
2018-05-11 09:48:58 -04:00
Corey Farrell 572a508ef2 loader: Convert reload_classes to built-in modules.
* acl (named_acl.c)
* cdr
* cel
* ccss
* dnsmgr
* dsp
* enum
* extconfig (config.c)
* features
* http
* indications
* logger
* manager
* plc
* sounds
* udptl

These modules are now loaded at appropriate time by the module loader.
Unlike loadable modules these use AST_MODULE_LOAD_FAILURE on error so
the module loader will abort startup on failure of these modules.

Some of these modules are still initialized or shutdown from outside the
module loader.  logger.c is initialized very early and shutdown very
late, manager.c is initialized by the module loader but is shutdown by
the Asterisk core (too much uses it without holding references).

Change-Id: I371a9a45064f20026c492623ea8062d02a1ab97f
2018-03-14 05:20:12 -04:00
Corey Farrell 9cfdb81e91 loader: Add dependency fields to module structures.
* Declare 'requires' and 'enhances' text fields on module info structure.
* Rename 'nonoptreq' to 'optional_modules'.
* Update doxygen comments.

Still need to investigate dependencies among modules I cannot compile.

Change-Id: I3ad9547a0a6442409ff4e352a6d897bef2cc04bf
2018-01-15 13:25:51 -05:00
Sean Bright fd0ca1c3f9 Remove as much trailing whitespace as possible.
Change-Id: I873c1c6d00f447269bd841494459efccdd2c19c0
2017-12-22 09:23:22 -05:00
Corey Farrell 064c74e4af netsock: Remove from Asterisk core.
This moves netsock.c / netsock.h to the chan_iax2 module.  netsock.h has
been marked deprecated since 13.0.0, chan_iax2 is the only remaining
user.

Change-Id: I28c6578043bac18de5ea608e136acec4f83d5dd3
2017-12-18 15:00:35 -05:00
Corey Farrell 606ae3484a Add missing menuselect dependencies.
This adds menuselect dependencies for modules that use symbols of other
modules.

ASTERISK-27390

Change-Id: Ia2d2849f5b87a72af7324a82edc3f283eafb5385
2017-11-02 02:57:52 -04:00
Joshua Colp f2985e3106 bridge: Change participant SFU streams when source streams change.
Some endpoints do not like a stream being reused for a new
media stream. The frame/jitterbuffer can rely on underlying
attributes of the media stream in order to order the packets.
When a new stream takes its place without any notice the
buffer can get confused and the media ends up getting dropped.

This change uses the SSRC change to determine that a new source
is reusing an existing stream and then bridge_softmix renegotiates
each participant such that they see a new media stream. This
causes the frame/jitterbuffer to start fresh and work as expected.

ASTERISK-27277

Change-Id: I30ccbdba16ca073d7f31e0e59ab778c153afae07
2017-09-21 12:20:02 -05:00
Corey Farrell 58d032112b Fix compiler warnings on Fedora 26 / GCC 7.
GCC 7 has added capability to produce warnings, this fixes most of those
warnings.  The specific warnings are disabled in a few places:

* app_voicemail.c: truncation of paths more than 4096 chars in many places.
* chan_mgcp.c: callid truncated to 80 chars.
* cdr.c: two userfields are combined to cdr copy, fix would break ABI.
* tcptls.c: ignore use of deprecated method SSLv3_client_method().

ASTERISK-27156 #close

Change-Id: I65f280e7d3cfad279d16f41823a4d6fddcbc4c88
2017-08-01 15:42:38 -06:00
Sergej Kasumovic d3f5b265c7 chan_iax2: On reload make sure to check for existing MWI subscription
On every reload of chan_iax2 module, MWI subscription was added, which
results in additional taskprocessors being accumulated over time.

This commit fixes it by making sure we check for existing subscription
first.

This was verified with 'core show taskprocessors' CLI command.

ASTERISK-27122 #close

Change-Id: Ie2ef528fd5ca01b933eeb88188cc10967899cfb9
2017-07-14 01:22:31 -05:00
Sean Bright 325eeced6a core: Remove 'Data Retrieval API'
This API was not actively maintained, was not added to new modules
(such as res_pjsip), and there exist better alternatives to acquire the
same information, such as the ARI.

Change-Id: I4b2185a83aeb74798b4ad43ff8f89f971096aa83
2017-07-05 11:25:58 -05:00
George Joseph 747beb1ed1 modules: change module LOAD_FAILUREs to LOAD_DECLINES
In all non-pbx modules, AST_MODULE_LOAD_FAILURE has been changed
to AST_MODULE_LOAD_DECLINE.  This prevents asterisk from exiting
if a module can't be loaded.  If the user wishes to retain the
FAILURE behavior for a specific module, they can use the "require"
or "preload-require" keyword in modules.conf.

A new API was added to logger: ast_is_logger_initialized().  This
allows asterisk.c/check_init() to print to the error log once the
logger subsystem is ready instead of just to stdout.  If something
does fail before the logger is initialized, we now print to stderr
instead of stdout.

Change-Id: I5f4b50623d9b5a6cb7c5624a8c5c1274c13b2b25
2017-04-12 15:57:21 -06:00
Joshua Colp aec2a087ed Merge "chan_iax2: Reload of iax peer results in loss of host address/port" 2017-03-16 05:23:37 -05:00
Richard Begg 0dc007e94d chan_iax2: Reload of iax peer results in loss of host address/port
When using a non-dynamic peer address, build_peer() invalidates the
peer address structure by setting the address family to unspecified.
However, if dnsmgr is enabled, the subsequent call to ast_dnsmgr_lookup()
will not amend the peer address if the cache is still valid, resulting
in peer connectivity failures.
To fix this, we call ast_dnsmgr_refresh() instead.

ASTERISK-26865

Change-Id: Id8a89a2f771ebbaf32255a35fe596a6dcb97a082
2017-03-14 16:01:04 -06:00
Joshua Colp 3ed05badb9 core: Add stream topology changing primitives with tests.
This change adds a few things to facilitate stream topology changing:

1. Control frame types have been added for use by the channel driver
to notify the application that the channel wants to change the stream
topology or that a stream topology change has been accepted. They are
also used by the indicate interface to the channel that the application
uses to indicate it wants to do the same.

2. Legacy behavior has been adopted in ast_read() such that if a
channel requests a stream topology change it is denied automatically
and the current stream topology is preserved if the application is
not capable of handling streams.

Tests have also been written which confirm the multistream and
non-multistream behavior.

ASTERISK-26839

Change-Id: Ia68ef22bca8e8457265ca4f0f9de600cbcc10bc9
2017-03-07 12:08:51 +00:00
Corey Farrell a6e5bae3ef Remove ASTERISK_REGISTER_FILE.
ASTERISK_REGISTER_FILE no longer has any purpose so this commit removes
all traces of it.

Previously exported symbols removed:
* __ast_register_file
* __ast_unregister_file
* ast_complete_source_filename

This also removes the mtx_prof static variable that was declared when
MTX_PROFILE was enabled.  This variable was only used in lock.c so it
is now initialized in that file only.

ASTERISK-26480 #close

Change-Id: I1074af07d71f9e159c48ef36631aa432c86f9966
2016-10-27 09:53:55 -04:00
varnav d2e03c252d chan_iax2: Set plaintext auth to deprecated as per ASTERISK-22820
Starting from draft 2 of RFC 5456 (October 23, 2006) plaintext auth
is not supported in IAX2 protocol. Please refer to section 8.6.13 of
RFC 5456.

But plaintext auth is still supported by Asterisk implementation of IAX2.
This support should be dropped.

Patch, based on asterisk-dev discussion, adds deprecation warning on
startup if 'auth' is set to 'plaintext', changes default values of
'auth' from 'md5, plaintext' to 'md5'.

Patch is safe in terms of backwards compatibility, will work even if
remote peers have auth=plaintext and we have defaults.

auth=plaintext setting will remain deprecated in Asterisk 14 and 15,
and IAX2 plaintext support will be removed in Asterisk 16.

ASTERISK-22820 #close

Change-Id: I5d2f3830cb57645604818f87518916e8a5c317bf
2016-08-25 11:25:55 +03:00
Corey Farrell 824a4e84d1 Refactor usage pattern of xmldoc info tag.
This updates func_channel.c and main/message.c to use a generic xpointer
include instead of including info from each channel driver.  Now the
name attribute of info is CHANNEL or CHANNEL_EXAMPLES to be included in
documentation for func_channel.  Setting the name attribute of info to
MessageToInfo or MessageFromInfo causes it to be included in the
MessageSend application and AMI action.

Change-Id: I89fd8276a3250824241a618009714267d3a8d1ea
2016-08-16 10:42:46 -05:00
Matt Jordan ddab42e296 func_channel: Reorganize documentation
* Following the example of the PJSIP channel driver, the channel
  technology specific documentation has been moved to the respective
  channel drivers that provide that functionality. This has the benefit
  of locating the documentation of items with those modules that provide
  it.

* Examples of using the CHANNEL function for both standard items as well
  as for PJSIP have been added.

* The 'max_forwards' standard item has been documented.

Change-Id: Ifaa79a232c8ac99cf8da6ef6cc7815d398b1b79b
2016-08-15 07:39:19 -05:00
Timo Teräs 39b69ab537 Fixes to include signal.h
POSIX defines signal.h. sys/signal.h should not be used as it is
c-library internal header which may or may not exist. Notably with
musl it generates warning of being incorrect.

Change-Id: Ia56b0aa1d84b5c590114867b1b384a624f39a6fc
2016-06-08 20:37:08 +03:00
Richard Mudgett fa20729032 Audit improper usage of scheduler exposed by 5c713fdf18.
channels/chan_iax2.c:
* Initialize struct chan_iax2_pvt scheduler ids earlier because of
iax2_destroy_helper().

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

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

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

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

ASTERISK-25476

Change-Id: I07a3449f728f671d326a22fcbd071f150ba2e8c8
2015-12-01 13:54:04 -06:00