T.140 data in RTP is not zero terminated, so when we are queuing a text
frame on a bridge we need to ensure that we are passing a zero
terminated string.
ASTERISK-28974 #close
Change-Id: Ic10057387ce30b2094613ea67e3ae8c5c431dda3
The SCOPE_ENTER and SCOPE_EXIT* macros now print debug messages
at the same level as the scope level. This allows the same
messages to be printed to the debug log when AST_DEVMODE
isn't enabled.
Also added a few variants of the SCOPE_EXIT macros that will
also call ast_log instead of ast_debug to make it easier to
use scope tracing and still print error messages.
Change-Id: I7fe55f7ec28069919a0fc0b11a82235ce904cc21
* Added ast_stream_to_stra and ast_stream_topology_to_stra() macros
which are shortcuts for
ast_str_tmp(256, ast_stream_to_str(stream, &STR_TMP))
* Added the stream position to the string representation of the
stream.
* Fixed some formatting in ast_stream_to_str().
Change-Id: Idaf4cb0affa46d4dce58a73a111f35435331cc4b
Allow passing a topology from the called channel back to the
calling channel.
* Added a new function ast_queue_answer() that accepts a stream
topology and queues an ANSWER CONTROL frame with it as the
data. This allows the called channel to indicate its resolved
topology.
* Added a new virtual function to the channel tech structure
answer_with_stream_topology() that allows the calling channel
to receive the called channel's topology. Added
ast_raw_answer_with_stream_topology() that invokes that virtual
function.
* Modified app_dial.c and features.c to grab the topology from the
ANSWER frame queued by the answering channel and send it to
the calling channel with ast_raw_answer_with_stream_topology().
* Modified frame.c to automatically cleanup the reference
to the topology on ANSWER frames.
Added a few debugging messages to stream.c.
Change-Id: I0115d2ed68d6bae0f87e85abcf16c771bdaf992c
The assumed behavior of realloc() - that it was effectively a free() if
its second argument was 0 - is Linux specific behavior and is not
guaranteed by either POSIX or the C specification.
Instead, if we want to resize a vector to 0, do it explicitly.
Change-Id: Ife31d4b510ebab41cb5477fdc7ea4e3138ca8b4f
With the addition of STIR/SHAKEN, the function ast_base64decode_string
was added for convenience since there is a lot of converting done during
the STIR/SHAKEN process. This function returned the decoded string for
you, but did not NULL terminate it, causing some issues (specifically
with MALLOC_DEBUG). Now, the returned string is NULL terminated, and the
documentation has been updated to reflect this.
Change-Id: Icdd7d05b323b0c47ff6ed43492937a03641bdcf5
This change renames the codec preference endpoint options.
incoming_offer_codec_prefs becomes codec_prefs_incoming_offer
to keep the options together when showing an endpoint.
Change-Id: I6202965b4723777f22a83afcbbafcdafb1d11c8d
There are various places in Asterisk - specifically in regards to
database integration - where having some kind of UTF-8 validation would
be beneficial. This patch adds:
* Functions to validate that a given string contains only valid UTF-8
sequences.
* A function to copy a string (similar to ast_copy_string) stopping when
an invalid UTF-8 sequence is encountered.
* A UTF-8 validator that allows for progressive validation.
All of this is based on the excellent UTF-8 decoder by Björn Höhrmann.
More information is available here:
https://bjoern.hoehrmann.de/utf-8/decoder/dfa/
The API was written in such a way that should allow us to replace the
implementation later should we determine that we need something more
comprehensive.
Change-Id: I3555d787a79e7c780a7800cd26e0b5056368abf9
* Updated AMI version to 8.0.0
* Updated ARI version to 7.0.0
* Update make_ari_stubs.py to "Asterisk 19"
Change-Id: I51fb38c2e29f2db785f64a8bbd5565d56bea5af5
Added a new configuration option for PJSIP endpoints - stir_shaken. If
set to yes, then STIR/SHAKEN support will be added to inbound and
outbound INVITEs. The default is no. Alembic has been updated to include
this option.
Previously the dialplan function was not trimming the whitespace from
the parameters it recieved. Now it does.
Also added a conditional that, when TEST_FRAMEWORK is enabled, the
timestamp in the identity header will be overlooked. This is just for
testing, since the testsuite will rely on a SIPp scenario with a preset
identity header to trigger the MISMATCH result.
Change-Id: I43d67f1489b8c1c5729ed3ca8d71e35ddf438df1
Prior to making any modifications to the pjsip infrastructure
for ACN, I've added the tracing functions to the existing code.
This should make the final commit easier to review, but we can also
now run a "before and after" trace.
No functional changes were made with this commit.
Change-Id: Ia83a1a2687ccb96f2bc8a2a3928a5214c4be775c
This commit adds the endpoint options required to control
Advanced Codec Negotiation.
incoming_offer_codec_prefs
outgoing_offer_codec_prefs
incoming_answer_codec_prefs
outgoing_answer_codec_prefs
The documentation may need tweaking and some additional edits
added, especially for the "answer" prefs. That'll be handled
when things finalize.
This commit is safe to merge as it doens't alter any existing
functionality nor does it alter the previous codec negotiation
work which may now be obsolete.
Change-Id: I920ba925d7dd36430dfd2ebd9d82d23f123d0e11
* ast_frame_subclass2str() and ast_frame_type2str() now return
a pointer to the buffer that was passed in instead of void.
This makes it easier to use these functions inline in
printf-style debugging statements.
* Added many missing control frame entries in
ast_frame_subclass2str.
Change-Id: Ifd0d6578e758cd644c96d17a5383ff2128c572fc
Tracing through synchronous tasks was a little troublesome because
the new thread's stack counter reset to 0. This change allows
a synchronous task to set its trace level to be the same as the
thread that pushed the task. For now, the task's level has to be
passed in the task's data structure but a future enhancement to the
taskprocessor subsystem could automatically set the trace level
of the servant to be that of the caller.
This doesn't really make sense for async tasks because you never
know when they're going to run anyway.
Change-Id: Ib8049c0b815063a45d8c7b0cb4e30b7b87b1d825
This patch allows a user of AMI to now specify the type of message
content contained within by setting the 'Content-Type' parameter.
Note, the AMI version has been bumped for this change.
ASTERISK-28945 #close
Change-Id: Ibb5315702532c6b954e1498beddc8855fabdf4bb
The Streams API becomes the home for the core ACN capabilities.
These include...
* Parsing and formatting of codec negotation preferences.
* Resolving pending streams and topologies with those configured
using configured preferences.
* Utility functions for creating string representations of
streams, topologies, and negotiation preferences.
For codec negotiation preferences:
* Added ast_stream_codec_prefs_parse() which takes a string
representation of codec negotiation preferences, which
may come from a pjsip endpoint for example, and populates
a ast_stream_codec_negotiation_prefs structure.
* Added ast_stream_codec_prefs_to_str() which does the reverse.
* Added many functions to parse individual parameter name
and value strings to their respectrive enum values, and the
reverse.
For streams:
* Added ast_stream_create_resolved() which takes a "live" stream
and resolves it with a configured stream and the negotiation
preferences to create a new stream.
* Added ast_stream_to_str() which create a string representation
of a stream suitable for debug or display purposes.
For topology:
* Added ast_stream_topology_create_resolved() which takes a "live"
topology and resolves it, stream by stream, with a configured
topology stream and the negotiation preferences to create a new
topology.
* Added ast_stream_topology_to_str() which create a string
representation of a topology suitable for debug or display
purposes.
* Renamed ast_format_caps_from_topology() to
ast_stream_topology_get_formats() to be more consistent with
the existing ast_stream_get_formats().
Additional changes:
* A new function ast_format_cap_append_names() appends the results
to the ast_str buffer instead of replacing buffer contents.
Change-Id: I2df77dedd0c72c52deb6e329effe057a8e06cd56
Created new SCOPE_ functions that don't depend on RAII_VAR. Besides
generating less code, the use of the explicit SCOPE_EXIT macros
capture the line number where the scope exited. The RAII_VAR
versions can't do that.
* SCOPE_ENTER(level, ...): Like SCOPE_TRACE but doesn't use
RAII_VAR and therefore needs needs one of...
* SCOPE_EXIT(...): Decrements the trace stack counter and optionally
prints a message.
* SCOPE_EXIT_EXPR(__expr, ...): Decrements the trace stack counter,
optionally prints a message, then executes the expression.
SCOPE_EXIT_EXPR(break, "My while got broken\n");
* SCOPE_EXIT_RTN(, ...): Decrements the trace stack counter,
optionally prints a message, then returns without a value.
SCOPE_EXIT_RTN("Bye\n");
* SCOPE_EXIT_RTN_VALUE(__return_value, ...): Decrements the trace
stack counter, optionally prints a message, then returns the value
specified.
SCOPE_EXIT_RTN_VALUE(rc, "Returning with RC: %d\n", rc);
Create an ast_str helper ast_str_tmp() that allocates a temporary
ast_str that can be passed to a function that needs it, then frees
it. This makes using the above macros easier. Example:
SCOPE_ENTER(1, Format Caps 1: %s Format Caps 2: %s\n",
ast_str_tmp(32, ast_format_cap_get_names(cap1, &STR_TMP),
ast_str_tmp(32, ast_format_cap_get_names(cap2, &STR_TMP));
The calls to ast_str_tmp create an ast_str of the specified initial
length which can be referenced as STR_TMP. It then calls the
expression, which must return a char *, ast_strdupa's it, frees
STR_TMP, then returns the ast_strdupa'd string. That string is
freed when the function returns.
Change-Id: I44059b20d55a889aa91440d2f8a590865998be51
Integrated STIR/SHAKEN support with outgoing INVITEs. When an INVITE is
sent, the caller ID will be checked to see if there is a certificate
that corresponds to it. If so, that information will be retrieved and an
Identity header will be added to the SIP message. The format is:
header.payload.signature;info=<public_key_url>alg=ES256;ppt=shaken
Header, payload, and signature are all BASE64 encoded. The public key
URL is retrieved from the certificate. Currently the algorithm and ppt
are ES256 and shaken, respectively. This message is signed and can be
used for verification on the receiving end.
Two new configuration options have been added to the certificate object:
attestation and origid. The attestation is required and must be A, B, or
C. origid is the origination identifier.
A new utility function has been added as well that takes a string,
allocates space, BASE64 encodes it, then returns it, eliminating the
need to calculate the size yourself.
Change-Id: I1f84d6a5839cb2ed152ef4255b380cfc2de662b4
This patch makes the usual necessary changes when upgrading to a new
version pjproject. For instance, version number bump, patches removed
from third-party, new *.md5 file added, etc..
This patch also includes a change to the Asterisk pjproject Makefile to
explicitly create the 'source/pjsip-apps/lib' directory. This directory
is no longer there by default so needs to be added so the Asterisk
malloc debug can be built.
This patch also includes some minor changes to Asterisk that were a result
of the upgrade. Specifically, there was a backward incompatibility change
made in 2.10 that modified the "expires header" variable field from a
signed to an unsigned value. This potentially effects comparison. Namely,
those check for a value less than zero. This patch modified a few locations
in the Asterisk code that may have been affected.
Lastly, this patch adds a new macro PJSIP_MINVERSION that can be used to
check a minimum version of pjproject at compile time.
ASTERISK-28899 #close
Change-Id: Iec8821c6cbbc08c369d0e3cd2f14e691b41d0c81
When requesting a Local channel the requested stream topology
or a converted stream topology will now be placed onto the
resulting channels.
Frames written in on streams will now also preserve the stream
identifier as they are queued on the opposite channel.
Finally when a stream topology change is requested it is
immediately accepted and reflected on both channels. Each
channel also receives a queued frame to indicate that the
topology has changed.
ASTERISK-28938
Change-Id: I4e9d94da5230d4bd046dc755651493fce1d87186
This patch fixes a few compile warnings/errors that now occur when using gcc
10+.
Also, the Makefile.rules check to turn off partial inlining in gcc versions
greater or equal to 8.2.1 had a bug where it only it only checked against
versions with at least 3 numbers (ex: 8.2.1 vs 10). This patch now ensures
any version above the specified version is correctly compared.
Change-Id: I54718496eb0c3ce5bd6d427cd279a29e8d2825f9
Integrated STIR/SHAKEN support with incoming INVITES. Upon receiving an
INVITE, the Identity header is retrieved, parsing the message to verify
the signature. If any of the parsing fails,
AST_STIR_SHAKEN_VERIFY_NOT_PRESENT will be added to the channel for this
caller ID. If verification itself fails,
AST_STIR_SHAKEN_VERIFY_SIGNATURE_FAILED will be added. If anything in
the payload does not line up with the SIP signaling,
AST_STIR_SHAKEN_VERIFY_MISMATCH will be added. If all of the above steps
pass, then AST_STIR_SHAKEN_VERIFY_PASSED will be added, completing the
verification process.
A new config option has been added to the general section for
stir_shaken.conf. "signature_timeout" is the amount of time a signature
will be considered valid. If an INVITE is received and the amount of
time between when it was received and when it was signed is greater than
signature_timeout, verification will fail.
Some changes were also made to signing and verification. There was an
error where the whole JSON string was being signed rather than the
header combined with the payload. This has been changed to sign the
correct thing. Verification has been changed to do this as well, and the
unit tests have been updated to reflect these changes.
A couple of utility functions have also been added. One decodes a BASE64
string and returns the decoded string, doing all the length calculations
for you. The other retrieves a string value from a header in a rdata
object.
Change-Id: I855f857be3d1c63b64812ac35d9ce0534085b913
What's wrong with ast_debug?
ast_debug is fine for general purpose debug output but it's not
really geared for scope tracing since it doesn't present its
output in a way that makes capturing and analyzing flow through
Asterisk easy.
How is scope tracing better?
Scope tracing uses the same "cleanup" attribute that RAII_VAR
uses to print messages to a separate "trace" log level. Even
better, the messages are indented and unindented based on a
thread-local call depth counter. When output to a separate log
file, the output is uncluttered and easy to follow.
Here's an example of the output. The leading timestamps and
thread ids are removed and the output cut off at 68 columns for
commit message restrictions but you get the idea.
--> res_pjsip_session.c:3680 handle_incoming PJSIP/1173-00000001
--> res_pjsip_session.c:3661 handle_incoming_response PJSIP/1173
--> res_pjsip_session.c:3669 handle_incoming_response PJSIP/
--> chan_pjsip.c:3265 chan_pjsip_incoming_response_after
--> chan_pjsip.c:3194 chan_pjsip_incoming_response P
chan_pjsip.c:3245 chan_pjsip_incoming_respon
<-- chan_pjsip.c:3194 chan_pjsip_incoming_response P
<-- chan_pjsip.c:3265 chan_pjsip_incoming_response_after
<-- res_pjsip_session.c:3669 handle_incoming_response PJSIP/
<-- res_pjsip_session.c:3661 handle_incoming_response PJSIP/1173
<-- res_pjsip_session.c:3680 handle_incoming PJSIP/1173-00000001
The messages with the "-->" or "<--" were produced by including
the following at the top of each function:
SCOPE_TRACE(1, "%s\n", ast_sip_session_get_name(session));
Scope isn't limited to functions any more than RAII_VAR is. You
can also see entry and exit from "if", "for", "while", etc blocks.
There is also an ast_trace() macro that doesn't track entry or
exit but simply outputs a message to the trace log using the
current indent level. The deepest message in the sample
(chan_pjsip.c:3245) was used to indicate which "case" in a
"select" was executed.
How do you use it?
More documentation is available in logger.h but here's an overview:
* Configure with --enable-dev-mode. Like debug, scope tracing
is #ifdef'd out if devmode isn't enabled.
* Add a SCOPE_TRACE() call to the top of your function.
* Set a logger channel in logger.conf to output the "trace" level.
* Use the CLI (or cli.conf) to set a trace level similar to setting
debug level... CLI> core set trace 2 res_pjsip.so
Summary Of Changes:
* Added LOG_TRACE logger level. Actually it occupies the slot
formerly occupied by the now defunct "event" level.
* Added core asterisk option "trace" similar to debug. Includes
ability to specify global trace level in asterisk.conf and CLI
commands to turn on/off and set levels. Levels can be set
globally (probably not a good idea), or by module/source file.
* Updated sample asterisk.conf and logger.conf. Tracing is
disabled by default in both.
* Added __ast_trace() to logger.c which keeps track of the indent
level using TLS. It's #ifdef'd out if devmode isn't enabled.
* Added ast_trace() and SCOPE_TRACE() macros to logger.h.
These are all #ifdef'd out if devmode isn't enabled.
Why not use gcc's -finstrument-functions capability?
gcc's facility doesn't allow access to local data and doesn't
operate on non-function scopes.
Known Issues:
The only know issue is that we currently don't know the line
number where the scope exited. It's reported as the same place
the scope was entered. There's probably a way to get around it
but it might involve looking at the stack and doing an 'addr2line'
to get the line number. Kind of like ast_backtrace() does.
Not sure if it's worth it.
Change-Id: Ic5ebb859883f9c10a08c5630802de33500cad027
Adds the "STIR_SHAKEN" dialplan function and an API call to add a
STIR_SHAKEN verification result to a channel. This information will be
held in a datastore on the channel that can later be queried through the
"STIR_SHAKEN" dialplan funtion to get information on STIR_SHAKEN results
including identity, attestation, and verify_result. Here are some
examples:
STIR_SHAKEN(count)
STIR_SHAKEN(0, identity)
STIR_SHAKEN(1, attestation)
STIR_SHAKEN(2, verify_result)
Getting the count can be used to iterate through the results and pull
information by specifying the index and the field you want to retrieve.
Change-Id: Ice6d52a3a7d6e4607c9c35b28a1f7c25f5284a82
Add a new "masquarade" channel event, and use it in app_queue to track unique id's.
Testcase is submitted as https://gerrit.asterisk.org/c/testsuite/+/14210
ASTERISK-28829 #close
ASTERISK-25844 #close
Change-Id: Ifc5f9f9fd70903f3c6e49738d3bc632b085d2df6
There are a lot of moving parts in this patch, but the focus of it is on
the verification of the signature using a public key located at the
public key URL provided in the JSON payload. First, we check the
database to see if we have already downloaded the key. If so, check to
see if it has expired. If it has, redownload from the URL. If we don't
have an entry in the database, just go ahead and download the public
key. The expiration is tested each time we download the file. After
that, read the public key from the file and use it to verify the
signature. All sanity checking is done when the payload is first
received, so the verification is complete once this point is reached.
The XML has also been added since a new config option was added to
general (curl_timeout). The maximum amount of time to wait for a
download can be configured through this option, with a low value by
default.
Change-Id: I3ba4c63880493bf8c7d17a9cfca1af0e934d1a1c
Some places in Asterisk did not treat the formats on a stream
as immutable when they are.
The ast_stream_get_formats function is now const to enforce this
and parts of Asterisk have been updated to take this into account.
Some violations of this were also fixed along the way.
An additional minor tweak is that streams are now allocated with
an empty format capabilities structure removing the need in various
places to check that one is present on the stream.
ASTERISK-28846
Change-Id: I32f29715330db4ff48edd6f1f359090458a9bfbe
When in a conference bridge it may be necessary to have
text messages disabled for specific participants or for
all. This change adds a configuration option, "text_messaging",
which can be used to enable or disable this on the
user profile. By default existing behavior is preserved
as it defaults to "yes".
ASTERISK-28841
Change-Id: I30b5d9ae6f4803881d1ed9300590d405e392bc13
This unit test runs through combinations of...
* Local codecs
* Remote Codecs
* Codec Preference
* Incoming/Outgoing
A few new APIs were created to make it easier to test
the functionality but didn't result in any actual
functional change.
ASTERISK_28777
Change-Id: Ic8957c43e7ceeab0e9272af60ea53f056164f164
Based on this new endpoint setting, a joint list of preferred codecs
between those received from the Asterisk core (remote), and those
specified in the endpoint's "allow" parameter (local) is created and
is used to create the outgoing SDP offer.
* Add outgoing_call_offer_pref to pjsip_configuration (endpoint)
* Add "call_direction" to res_pjsip_session.
* Update pjsip_session_caps.c to make the functions more generic
so they could be used for both incoming and outgoing.
* Update ast_sip_session_create_outgoing to create the
pending_media_state->topology with the results of
ast_sip_session_create_joint_call_stream().
* The endpoint "preferred_codec_only" option now automatically sets
AST_SIP_CALL_CODEC_PREF_FIRST in incoming_call_offer_pref.
* A helper function ast_stream_get_format_count() was added to
streams to return the current count of formats.
ASTERISK-28777
Change-Id: Id4ec0b4a906c2ae5885bf947f101c59059935437
This change provides functions that take in a JSON payload, verify that
the contents contain all the mandatory fields and required values (if
any), and signs the payload with the private key. Four fields are added
to the payload: x5u, attest, iat, and origid. As of now, these are just
placeholder values that will be set to actual values once the logic is
implemented for what to do when an actual payload is received, but the
functions to add these values have all been implemented and are ready to
use. Upon successful signing and the addition of those four values, a
ast_stir_shaken_payload is returned, containing other useful information
such as the algorithm and signature.
Change-Id: I74fa41c0640ab2a64a1a80110155bd7062f13393
named_acl.c (which is really a named_ha) now uses ast_ha_output.
I've also updated main/manager.c to output the actual ACL on "manager
show user <username>" if one is set. If this works then we can add
similar to other modules as required.
Change-Id: I0ec9876a90dddd379c80ec078d48e3ee6991eb0f
This fixes ast_addressfamily_to_sockaddrsize to reference the
provided argument, and ast_sockaddr_from_sockaddr to not use the name of
a structure as argument.
Change-Id: Ibf5db469c47c3b4214edf8456326086174e8edd7
This commit sets up some of the initial framework for the module and
adds a way to read the private key from the specified file, which will
then be appended to the certificate object. This works fine for now, but
eventually some other structure will likely need to be used to store all
this information. Similarly, the caller_id_number is specified on the
certificate config object, but in the end we will want that information
to be tied to the certificate itself and read it from there.
A method has been added that will retrieve the private key associated
with the caller_id_number passed in. Tab completion for certificates and
stores has also been added.
Change-Id: Ic4bc1416fab5d6afe15a8e2d32f7ddd4e023295f
Add a new option, incoming_call_offer_pref, to res_pjsip endpoints that
specifies the preferred order of codecs after receiving an offer.
This patch does the following:
Adds a new enumeration, ast_sip_call_codec_pref, used by the the new
configuration option that's added to the endpoint media structure.
Adds a new ast_sip_session_caps structure that's set for each session media
object.
Creates a new file, res_pjsip_session_caps that "implements" the new
structure and option, and is compiled into the res_pjsip_session library.
ASTERISK-28756 #close
Change-Id: I35e7a2a0c236cfb6bd9cdf89539f57a1ffefc76f
When a text message was received any associated variable was not written to
the ARI TextMessageReceived event. This occurred because Asterisk only wrote
out "send" variables. However, even those "send" variables would fail ARI
validation due to a TextMessageVariable formatting bug.
Since it seems the TextMessageReceived event has never been able to include
actual variables it was decided to remove the TextMessageVariable object type
from ARI, and simply return a JSON object of key/value pairs for variables.
This aligns more with how the ARI sendMessage handles variables, and other
places in ARI.
ASTERISK-28755 #close
Change-Id: Ia6051c01a53b30cf7edef84c27df4ed4479b8b6f
Update the state of remote_hold immediately on receipt of remote
SDP so that the information is available when building the SDP
answer
ASTERISK-28754 #close
Change-Id: I7026032a807e9c95081cb8f060400b05deb4836f
There were a couple places where the format cap function parameter was not
'const' when it should have been. This patch makes them 'const'.
Change-Id: Ife753fb16a962d842a6b44f45363a61a66bfdb2e
There are exceptions for plural objects, but they are detected using the
supplied NUMBER, not using an extra option.
Change-Id: I95d1d1b2796b1aba92048a2dbae8a3856ed8a113
This change extends the Sorcery API to allow a wizard to be
told to explicitly reload objects or a specific object type
even if the wizard believes that nothing has changed.
This has been leveraged by res_pjsip and res_pjsip_acl to
reload endpoints and PJSIP ACLs when a named ACL changes.
ASTERISK-28697
Change-Id: Ib8fee9bd9dd490db635132c479127a4114c1ca0b