Compare commits

..

1 Commits

Author SHA1 Message Date
Joshua Colp
a9315f8d1a Update for certified/13.21-cert1-rc1 2018-05-02 10:52:56 -05:00
22 changed files with 4155 additions and 1172 deletions

View File

@@ -1 +1 @@
certified/13.21-cert2
certified/13.21-cert1-rc1

29
CHANGES
View File

@@ -8,39 +8,10 @@
===
==============================================================================
------------------------------------------------------------------------------
--- Functionality changes from Asterisk 13.21.0 to Asterisk 13.22.0 ----------
------------------------------------------------------------------------------
Core
------------------
* Core bridging and, more specifically, bridge_softmix have been enhanced to
relay received frames of type TEXT or TEXT_DATA to all participants in a
softmix bridge. res_pjsip_messaging and chan_pjsip have been enhanced to
take advantage of this so when res_pjsip_messaging receives an in-dialog
MESSAGE message from a user in a conference call, it's relayed to all
other participants in the call.
------------------------------------------------------------------------------
--- Functionality changes from Asterisk 13.20.0 to Asterisk 13.21.0 ----------
------------------------------------------------------------------------------
Core
------------------
* Core bridging and, more specifically, bridge_softmix have been enhanced to
relay received frames of type TEXT or TEXT_DATA to all participants in a
softmix bridge. res_pjsip_messaging and chan_pjsip have been enhanced to
take advantage of this so when res_pjsip_messaging receives an in-dialog
MESSAGE message from a user in a conference call, it's relayed to all
other participants in the call.
app_sendtext
------------------
Support Enhanced Messaging. SendText now accepts new channel variables
that can be used to override the To and From display names and set the
Content-Type of a message. Since you can now set Content-Type, other
text/* content types are now valid.
Build System
------------------
* RADIUS backends for CEL and CDR can now also be built using the radcli

198
ChangeLog
View File

@@ -1,200 +1,6 @@
2018-06-11 21:09 +0000 Asterisk Development Team <asteriskteam@digium.com>
2018-05-02 15:52 +0000 Asterisk Development Team <asteriskteam@digium.com>
* asterisk certified/13.21-cert2 Released.
2018-04-30 17:38 +0000 [3cccb60321] Richard Mudgett <rmudgett@digium.com>
* AST-2018-008: Fix enumeration of endpoints from ACL rejected addresses.
When endpoint specific ACL rules block a SIP request they respond with a
403 forbidden. However, if an endpoint is not identified then a 401
unauthorized response is sent. This vulnerability just discloses which
requests hit a defined endpoint. The ACL rules cannot be bypassed to gain
access to the disclosed endpoints.
* Made endpoint specific ACL rules now respond with a 401 unauthorized
which is the same as if an endpoint were not identified. The fix is
accomplished by replacing the found endpoint with the artificial endpoint
which always fails authentication.
ASTERISK-27818
Change-Id: Icb275a54ff8e2df6c671a6d9bda37b5d732b3b32
2018-06-05 12:47 +0000 Asterisk Development Team <asteriskteam@digium.com>
* asterisk certified/13.21-cert1 Released.
2018-06-04 09:50 +0000 [f5bc8aeb9a] George Joseph <gjoseph@digium.com>
* app_sendtext: Allow content types other than text/plain
There was no real reason to limit the conteny type to text/plain other
than that's what it was limited to before. Now any text/* content
type will be allowed for channel drivers that don't support enhanced
messaging and any type will be allowed for channel drivers that do
support enhanced messaging.
Change-Id: I94a90cfee98b4bc8e22aa5c0b6afb7b862f979d9
2018-04-10 16:09 +0000 [8f5fc3870d] George Joseph <gjoseph@digium.com>
* app_sendtext: Enhance SendText to support Enhanced Messaging
SendText now accepts new channel variables that can be used
to override the To and From display names and set the Content-Type
of a message. Since you can now set Content-Type, other text/*
content types are now valid.
Change-Id: I648b4574478119f95de09d9f08e9595831b02830
2017-09-27 11:44 +0000 [c1deeb28c2] George Joseph <gjoseph@digium.com>
* bridge_softmix: Forward TEXT frames
Core bridging and, more specifically, bridge_softmix have been
enhanced to relay received frames of type TEXT or TEXT_DATA to all
participants in a softmix bridge. res_pjsip_messaging and
chan_pjsip have been enhanced to take advantage of this so when
res_pjsip_messaging receives an in-dialog MESSAGE message from a
user in a conference call, it's relayed to all other participants
in the call.
res_pjsip_messaging already queues TEXT frames to the channel when
it receives an in-dialog MESSAGE from an endpoint and chan_pjsip
will send an MESSAGE when it gets a TEXT frame. On a normal
point-to-point call, the frames are forwarded between the two
correctly. bridge_softmix was not though so messages weren't
getting forwarded to conference bridge participants. Even if they
were, the bridging code had no way to tell the participants who
sent the message so it would look like it came from the bridge
itself.
* The TEXT frame type doesn't allow storage of any meta data, such
as sender, on the frame so a new TEXT_DATA frame type was added that
uses the new ast_msg_data structure as its payload. A channel
driver can queue a frame of that type when it receives a message
from outside. A channel driver can use it for sending messages
by implementing the new send_text_data channel tech callback and
setting the new AST_CHAN_TP_SEND_TEXT_DATA flag in its tech
properties. If set, the bridging/channel core will use it instead
of the original send_text callback and it will get the ast_msg_data
structure. Channel drivers aren't required to implement this. Even
if a TEXT_DATA enabled driver uses it for incoming messages, an
outgoing channel driver that doesn't will still have it's send_text
callback called with only the message text just as before.
* res_pjsip_messaging now creates a TEXT_DATA frame for incoming
in-dialog messages and sets the "from" to the display name in the
"From" header, or if that's empty, the caller id name from the
channel. This allows the chat client user to set a friendly name
for the chat.
* bridge_softmix now forwards TEXT and TEXT_DATA frames to all
participants (except the sender).
* A new function "ast_sendtext_data" was added to channel which
takes an ast_msg_data structure and calls a channel's
send_text_data callback, or if that's not defined, the original
send_text callback.
* bridge_channel now calls ast_sendtext_data for TEXT_DATA frame
types and ast_sendtext for TEXT frame types.
* chan_pjsip now uses the "from" name in the ast_msg_data structure
(if it exists) to set the "From" header display name on outgoing text
messages.
Change-Id: Idacf5900bfd5f22ab8cd235aa56dfad090d18489
(cherry picked from commit be7d4faed5fb3684e9d68454ae2a97167e1ebb51)
2017-09-27 11:44 +0000 [72fb285d9b] George Joseph <gjoseph@digium.com>
* bridge_softmix: Forward TEXT frames
Core bridging and, more specifically, bridge_softmix have been
enhanced to relay received frames of type TEXT or TEXT_DATA to all
participants in a softmix bridge. res_pjsip_messaging and
chan_pjsip have been enhanced to take advantage of this so when
res_pjsip_messaging receives an in-dialog MESSAGE message from a
user in a conference call, it's relayed to all other participants
in the call.
res_pjsip_messaging already queues TEXT frames to the channel when
it receives an in-dialog MESSAGE from an endpoint and chan_pjsip
will send an MESSAGE when it gets a TEXT frame. On a normal
point-to-point call, the frames are forwarded between the two
correctly. bridge_softmix was not though so messages weren't
getting forwarded to conference bridge participants. Even if they
were, the bridging code had no way to tell the participants who
sent the message so it would look like it came from the bridge
itself.
* The TEXT frame type doesn't allow storage of any meta data, such
as sender, on the frame so a new TEXT_DATA frame type was added that
uses the new ast_msg_data structure as its payload. A channel
driver can queue a frame of that type when it receives a message
from outside. A channel driver can use it for sending messages
by implementing the new send_text_data channel tech callback and
setting the new AST_CHAN_TP_SEND_TEXT_DATA flag in its tech
properties. If set, the bridging/channel core will use it instead
of the original send_text callback and it will get the ast_msg_data
structure. Channel drivers aren't required to implement this. Even
if a TEXT_DATA enabled driver uses it for incoming messages, an
outgoing channel driver that doesn't will still have it's send_text
callback called with only the message text just as before.
* res_pjsip_messaging now creates a TEXT_DATA frame for incoming
in-dialog messages and sets the "from" to the display name in the
"From" header, or if that's empty, the caller id name from the
channel. This allows the chat client user to set a friendly name
for the chat.
* bridge_softmix now forwards TEXT and TEXT_DATA frames to all
participants (except the sender).
* A new function "ast_sendtext_data" was added to channel which
takes an ast_msg_data structure and calls a channel's
send_text_data callback, or if that's not defined, the original
send_text callback.
* bridge_channel now calls ast_sendtext_data for TEXT_DATA frame
types and ast_sendtext for TEXT frame types.
* chan_pjsip now uses the "from" name in the ast_msg_data structure
(if it exists) to set the "From" header display name on outgoing text
messages.
Change-Id: Idacf5900bfd5f22ab8cd235aa56dfad090d18489
(cherry picked from commit be7d4faed5fb3684e9d68454ae2a97167e1ebb51)
2018-05-17 01:58 +0000 [5de8b00f2c] Alexander Traud <pabstraud@compuserve.com>
* res_pjsip_endpoint_identifier_ip: Unregister the module for headers.
Asterisk uses Reference Counting to track whether a module can be unloaded.
Every consumer who requires a module, increases the reference count. When the
consumer goes, is unloaded itself, it has to decrease the reference count on
all its used/required modules. That way
core stop gracefully
works on the command-line interface (CLI): One module after the other is
unloaded. A recent change broke this for the module res_pjsip.
ASTERISK-27861
Change-Id: I261abcb411d026bbb0691cc78f28300bfd3103a3
2018-05-17 00:34 +0000 [5aaf6d1605] Alexander Traud <pabstraud@compuserve.com>
* res_pjsip: Register pjsip_transport_management not externally but internally.
The module (res_)pjsip_transport_management got moved into res_pjsip. It is no
longer an independent/external module with (un)load_module and therefore has to
register just internally with res_pjsip.
ASTERISK-27860
Change-Id: Icd0413be7d2e98b92f51e6d6c353f2570bb4be95
* asterisk certified/13.21-cert1-rc1 Released.
2017-10-30 15:24 +0000 [13a85290fe] Kevin Harwell <kharwell@digium.com>

View File

@@ -40,64 +40,19 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/app.h"
#include "asterisk/message.h"
/*** DOCUMENTATION
<application name="SendText" language="en_US">
<synopsis>
Send a Text Message on a channel.
Send a Text Message.
</synopsis>
<syntax>
<parameter name="text" required="false" />
<parameter name="text" required="true" />
</syntax>
<description>
<para>Sends <replaceable>text</replaceable> to the current channel.</para>
<note><para><literal>current channel</literal> could be the caller or callee depending
on the context in which this application is called.</para></note>
<para>
</para>
<para>The following variables can be set:</para>
<para>Sends <replaceable>text</replaceable> to current channel (callee).</para>
<para>Result of transmission will be stored in the <variable>SENDTEXTSTATUS</variable></para>
<variablelist>
<variable name="SENDTEXT_FROM_DISPLAYNAME">
<para>If set and this channel supports enhanced messaging, this value will be
used as the <literal>From</literal> display name.</para>
</variable>
<variable name="SENDTEXT_TO_DISPLAYNAME">
<para>If set and this channel supports enhanced messaging, this value will be
used as the <literal>To</literal> display name.</para>
</variable>
<variable name="SENDTEXT_CONTENT_TYPE">
<para>If set and this channel supports enhanced messaging, this value will be
used as the message <literal>Content-Type</literal>. If not specified, the
default of <literal>text/plain</literal> will be used.</para>
<para><emphasis>Warning:</emphasis> Messages of types other than
<literal>text/&#42;</literal> cannot be sent via channel drivers that do not
support Enhanced Messaging. An attempt to do so will be ignored and will result
in the <literal>SENDTEXTSTATUS</literal> variable being set to
<literal>UNSUPPORTED</literal>.</para>
</variable>
<variable name="SENDTEXT_BODY">
<para>If set this value will be used as the message body and any text supplied
as a function parameter will be ignored.
</para>
</variable>
</variablelist>
<para>
</para>
<para>Result of transmission will be stored in the following variables:</para>
<variablelist>
<variable name="SENDTEXTTYPE">
<value name="NONE">
No message sent.
</value>
<value name="BASIC">
Message body sent without attributes because the channel driver
doesn't support enhanced messaging.
</value>
<value name="ENHANCED">
The message was sent using enhanced messaging.
</value>
</variable>
<variable name="SENDTEXTSTATUS">
<value name="SUCCESS">
Transmission succeeded.
@@ -110,34 +65,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
</value>
</variable>
</variablelist>
<para>
</para>
<note><para>The text encoding and transmission method is completely at the
discretion of the channel driver. chan_pjsip will use in-dialog SIP MESSAGE
messages always. chan_sip will use T.140 via RTP if a text media type was
negotiated and in-dialog SIP MESSAGE messages otherwise.</para></note>
<para>
</para>
<para>Examples:
</para>
<example title="Send a simple message">
same => n,SendText(Your Text Here)
</example>
<para>If the channel driver supports enhanced messaging (currently only chan_pjsip),
you can set additional variables:</para>
<example title="Alter the From display name">
same => n,Set(SENDTEXT_FROM_DISPLAYNAME=Really From Bob)
same => n,SendText(Your Text Here)
</example>
<example title="Send a JSON String">
same => n,Set(SENDTEXT_CONTENT_TYPE=text/json)
same => n,SendText({"foo":a, "bar":23})
</example>
<example title="Send a JSON String (alternate)">
same => n,Set(SENDTEXT_CONTENT_TYPE=text/json)
same => n,Set(SENDTEXT_BODY={"foo":a, "bar":23})
same => n,SendText()
</example>
<note><para>At this moment, text is supposed to be 7 bit ASCII in most channels.</para></note>
</description>
<see-also>
<ref type="application">SendImage</ref>
@@ -150,93 +78,36 @@ static const char * const app = "SendText";
static int sendtext_exec(struct ast_channel *chan, const char *data)
{
char *status;
char *msg_type;
char *status = "UNSUPPORTED";
struct ast_str *str;
const char *from;
const char *to;
const char *content_type;
const char *body;
int rc = 0;
/* NOT ast_strlen_zero, because some protocols (e.g. SIP) MUST be able to
* send a zero-length message. */
if (!data) {
ast_log(LOG_WARNING, "SendText requires an argument (text)\n");
return -1;
}
if (!(str = ast_str_alloca(strlen(data) + 1))) {
return -1;
}
ast_str_get_encoded_str(&str, -1, data);
ast_channel_lock(chan);
from = pbx_builtin_getvar_helper(chan, "SENDTEXT_FROM_DISPLAYNAME");
to = pbx_builtin_getvar_helper(chan, "SENDTEXT_TO_DISPLAYNAME");
content_type = pbx_builtin_getvar_helper(chan, "SENDTEXT_CONTENT_TYPE");
body = S_OR(pbx_builtin_getvar_helper(chan, "SENDTEXT_BODY"), data);
body = S_OR(body, "");
if (!(str = ast_str_alloca(strlen(body) + 1))) {
rc = -1;
goto cleanup;
if (!ast_channel_tech(chan)->send_text) {
ast_channel_unlock(chan);
/* Does not support transport */
pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
return 0;
}
ast_str_get_encoded_str(&str, -1, body);
body = ast_str_buffer(str);
msg_type = "NONE";
status = "UNSUPPORTED";
if (ast_channel_tech(chan)->send_text_data) {
struct ast_msg_data *msg;
struct ast_msg_data_attribute attrs[] =
{
{
.type = AST_MSG_DATA_ATTR_FROM,
.value = (char *)S_OR(from, ""),
},
{
.type = AST_MSG_DATA_ATTR_TO,
.value = (char *)S_OR(to, ""),
},
{
.type = AST_MSG_DATA_ATTR_CONTENT_TYPE,
.value = (char *)S_OR(content_type, ""),
},
{
.type = AST_MSG_DATA_ATTR_BODY,
.value = (char *)S_OR(body, ""),
},
};
msg_type = "ENHANCED";
msg = ast_msg_data_alloc(AST_MSG_DATA_SOURCE_TYPE_IN_DIALOG, attrs, ARRAY_LEN(attrs));
if (msg) {
if (ast_sendtext_data(chan, msg) == 0) {
status = "SUCCESS";
} else {
status = "FAILURE";
}
ast_free(msg);
} else {
rc = -1;
goto cleanup;
}
} else if (ast_channel_tech(chan)->send_text) {
if (!ast_strlen_zero(content_type) && !ast_begins_with(content_type, "text/")) {
rc = -1;
goto cleanup;
}
msg_type = "BASIC";
if (ast_sendtext(chan, body) == 0) {
status = "SUCCESS";
} else {
status = "FAILURE";
}
status = "FAILURE";
if (!ast_sendtext(chan, ast_str_buffer(str))) {
status = "SUCCESS";
}
pbx_builtin_setvar_helper(chan, "SENDTEXTTYPE", msg_type);
pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
cleanup:
pbx_builtin_setvar_helper(chan, "SENDTEXT_FROM_DISPLAYNAME", NULL);
pbx_builtin_setvar_helper(chan, "SENDTEXT_TO_DISPLAYNAME", NULL);
pbx_builtin_setvar_helper(chan, "SENDTEXT_CONTENT_TYPE", NULL);
pbx_builtin_setvar_helper(chan, "SENDTEXT_BODY", NULL);
ast_channel_unlock(chan);
return rc;
pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
return 0;
}
static int unload_module(void)

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -1,19 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><title>Release Summary - asterisk-certified/13.21-cert2</title><h1 align="center"><a name="top">Release Summary</a></h1><h3 align="center">asterisk-certified/13.21-cert2</h3><h3 align="center">Date: 2018-06-11</h3><h3 align="center">&lt;asteriskteam@digium.com&gt;</h3><hr><h2 align="center">Table of Contents</h2><ol>
<li><a href="#summary">Summary</a></li>
<li><a href="#contributors">Contributors</a></li>
<li><a href="#closed_issues">Closed Issues</a></li>
<li><a href="#diffstat">Diffstat</a></li>
</ol><hr><a name="summary"><h2 align="center">Summary</h2></a><center><a href="#top">[Back to Top]</a></center><p>This release has been made to address one or more security vulnerabilities that have been identified. A security advisory document has been published for each vulnerability that includes additional information. Users of versions of Asterisk that are affected are strongly encouraged to review the advisories and determine what action they should take to protect their systems from these issues.</p><p>Security Advisories:</p><ul>
<li><a href="http://downloads.asterisk.org/pub/security/AST-2018-008.html">AST-2018-008</a></li>
</ul><p>The data in this summary reflects changes that have been made since the previous release, asterisk-certified/13.21-cert1.</p><hr><a name="contributors"><h2 align="center">Contributors</h2></a><center><a href="#top">[Back to Top]</a></center><p>This table lists the people who have submitted code, those that have tested patches, as well as those that reported issues on the issue tracker that were resolved in this release. For coders, the number is how many of their patches (of any size) were committed into this release. For testers, the number is the number of times their name was listed as assisting with testing a patch. Finally, for reporters, the number is the number of issues that they reported that were affected by commits that went into this release.</p><table width="100%" border="0">
<tr><th width="33%">Coders</th><th width="33%">Testers</th><th width="33%">Reporters</th></tr>
<tr valign="top"><td width="33%">1 Richard Mudgett <rmudgett@digium.com><br/></td><td width="33%"><td width="33%">1 John <john@antme.com><br/></td></tr>
</table><hr><a name="closed_issues"><h2 align="center">Closed Issues</h2></a><center><a href="#top">[Back to Top]</a></center><p>This is a list of all issues from the issue tracker that were closed by changes that went into this release.</p><h3>Security</h3><h4>Category: Resources/res_pjsip</h4><a href="https://issues.asterisk.org/jira/browse/ASTERISK-27818">ASTERISK-27818</a>: Username bruteforce is possible when using ACL with PJSIP<br/>Reported by: John<ul>
<li><a href="https://code.asterisk.org/code/changelog/asterisk?cs=3cccb6032139a4257d98b8acf8bdbb88c0594950">[3cccb60321]</a> Richard Mudgett -- AST-2018-008: Fix enumeration of endpoints from ACL rejected addresses.</li>
</ul><br><hr><a name="diffstat"><h2 align="center">Diffstat Results</h2></a><center><a href="#top">[Back to Top]</a></center><p>This is a summary of the changes to the source code that went into this release that was generated using the diffstat utility.</p><pre>asterisk-certified-13.21-cert1-summary.html | 1201
asterisk-certified-13.21-cert1-summary.txt | 2895 -
b/.version | 2
b/ChangeLog |55767 +++++++++++-----------------
b/asterisk-13.21.0-rc1-summary.html | 348
b/asterisk-13.21.0-rc1-summary.txt | 825
6 files changed, 23793 insertions(+), 37245 deletions(-)</pre><br></html>

View File

@@ -1,89 +0,0 @@
Release Summary
asterisk-certified/13.21-cert2
Date: 2018-06-11
<asteriskteam@digium.com>
----------------------------------------------------------------------
Table of Contents
1. Summary
2. Contributors
3. Closed Issues
4. Diffstat
----------------------------------------------------------------------
Summary
[Back to Top]
This release has been made to address one or more security vulnerabilities
that have been identified. A security advisory document has been published
for each vulnerability that includes additional information. Users of
versions of Asterisk that are affected are strongly encouraged to review
the advisories and determine what action they should take to protect their
systems from these issues.
Security Advisories:
* AST-2018-008
The data in this summary reflects changes that have been made since the
previous release, asterisk-certified/13.21-cert1.
----------------------------------------------------------------------
Contributors
[Back to Top]
This table lists the people who have submitted code, those that have
tested patches, as well as those that reported issues on the issue tracker
that were resolved in this release. For coders, the number is how many of
their patches (of any size) were committed into this release. For testers,
the number is the number of times their name was listed as assisting with
testing a patch. Finally, for reporters, the number is the number of
issues that they reported that were affected by commits that went into
this release.
Coders Testers Reporters
1 Richard Mudgett 1 John
----------------------------------------------------------------------
Closed Issues
[Back to Top]
This is a list of all issues from the issue tracker that were closed by
changes that went into this release.
Security
Category: Resources/res_pjsip
ASTERISK-27818: Username bruteforce is possible when using ACL with PJSIP
Reported by: John
* [3cccb60321] Richard Mudgett -- AST-2018-008: Fix enumeration of
endpoints from ACL rejected addresses.
----------------------------------------------------------------------
Diffstat Results
[Back to Top]
This is a summary of the changes to the source code that went into this
release that was generated using the diffstat utility.
asterisk-certified-13.21-cert1-summary.html | 1201
asterisk-certified-13.21-cert1-summary.txt | 2895 -
b/.version | 2
b/ChangeLog |55767 +++++++++++-----------------
b/asterisk-13.21.0-rc1-summary.html | 348
b/asterisk-13.21.0-rc1-summary.txt | 825
6 files changed, 23793 insertions(+), 37245 deletions(-)

View File

@@ -54,7 +54,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/astobj2.h"
#include "asterisk/timing.h"
#include "asterisk/translate.h"
#include "asterisk/message.h"
#define MAX_DATALEN 8096
@@ -720,42 +719,6 @@ static void softmix_bridge_check_voice(struct ast_bridge *bridge, struct ast_bri
}
}
/*!
* \internal
* \brief Determine what to do with a text frame.
* \since 13.22.0
* \since 15.5.0
*
* \param bridge Which bridge is getting the frame
* \param bridge_channel Which channel is writing the frame.
* \param frame What is being written.
*
* \return Nothing
*/
static void softmix_bridge_write_text(struct ast_bridge *bridge,
struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
{
if (DEBUG_ATLEAST(1)) {
struct ast_msg_data *msg = frame->data.ptr;
char frame_type[64];
ast_frame_type2str(frame->frametype, frame_type, sizeof(frame_type));
if (frame->frametype == AST_FRAME_TEXT_DATA) {
ast_log(LOG_DEBUG, "Received %s frame from '%s:%s': %s\n", frame_type,
ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_FROM),
ast_channel_name(bridge_channel->chan),
ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_BODY));
} else {
ast_log(LOG_DEBUG, "Received %s frame from '%s': %.*s\n", frame_type,
ast_channel_name(bridge_channel->chan), frame->datalen,
(char *)frame->data.ptr);
}
}
ast_bridge_queue_everyone_else(bridge, bridge_channel, frame);
}
/*!
* \internal
* \brief Determine what to do with a control frame.
@@ -840,10 +803,6 @@ static int softmix_bridge_write(struct ast_bridge *bridge, struct ast_bridge_cha
case AST_FRAME_VIDEO:
softmix_bridge_write_video(bridge, bridge_channel, frame);
break;
case AST_FRAME_TEXT:
case AST_FRAME_TEXT_DATA:
softmix_bridge_write_text(bridge, bridge_channel, frame);
break;
case AST_FRAME_CONTROL:
res = softmix_bridge_write_control(bridge, bridge_channel, frame);
break;

View File

@@ -63,7 +63,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/features_config.h"
#include "asterisk/pickup.h"
#include "asterisk/test.h"
#include "asterisk/message.h"
#include "asterisk/res_pjsip.h"
#include "asterisk/res_pjsip_session.h"
@@ -92,7 +91,6 @@ static void chan_pjsip_pvt_dtor(void *obj)
/* \brief Asterisk core interaction functions */
static struct ast_channel *chan_pjsip_request(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause);
static int chan_pjsip_sendtext_data(struct ast_channel *ast, struct ast_msg_data *msg);
static int chan_pjsip_sendtext(struct ast_channel *ast, const char *text);
static int chan_pjsip_digit_begin(struct ast_channel *ast, char digit);
static int chan_pjsip_digit_end(struct ast_channel *ast, char digit, unsigned int duration);
@@ -114,7 +112,6 @@ struct ast_channel_tech chan_pjsip_tech = {
.description = "PJSIP Channel Driver",
.requester = chan_pjsip_request,
.send_text = chan_pjsip_sendtext,
.send_text_data = chan_pjsip_sendtext_data,
.send_digit_begin = chan_pjsip_digit_begin,
.send_digit_end = chan_pjsip_digit_end,
.call = chan_pjsip_call,
@@ -131,7 +128,7 @@ struct ast_channel_tech chan_pjsip_tech = {
.queryoption = chan_pjsip_queryoption,
.func_channel_read = pjsip_acf_channel_read,
.get_pvt_uniqueid = chan_pjsip_get_uniqueid,
.properties = AST_CHAN_TP_WANTSJITTER | AST_CHAN_TP_CREATESJITTER | AST_CHAN_TP_SEND_TEXT_DATA
.properties = AST_CHAN_TP_WANTSJITTER | AST_CHAN_TP_CREATESJITTER
};
/*! \brief SIP session interaction functions */
@@ -2264,99 +2261,50 @@ static struct ast_channel *chan_pjsip_request(const char *type, struct ast_forma
struct sendtext_data {
struct ast_sip_session *session;
struct ast_msg_data *msg;
char text[0];
};
static void sendtext_data_destroy(void *obj)
{
struct sendtext_data *data = obj;
ao2_cleanup(data->session);
ast_free(data->msg);
ao2_ref(data->session, -1);
}
static struct sendtext_data* sendtext_data_create(struct ast_channel *chan,
struct ast_msg_data *msg)
static struct sendtext_data* sendtext_data_create(struct ast_sip_session *session, const char *text)
{
struct ast_sip_channel_pvt *channel = ast_channel_tech_pvt(chan);
struct sendtext_data *data = ao2_alloc(sizeof(*data), sendtext_data_destroy);
int size = strlen(text) + 1;
struct sendtext_data *data = ao2_alloc(sizeof(*data)+size, sendtext_data_destroy);
if (!data) {
return NULL;
}
data->msg = ast_msg_data_dup(msg);
if (!data->msg) {
ao2_cleanup(data);
return NULL;
}
data->session = channel->session;
data->session = session;
ao2_ref(data->session, +1);
ast_copy_string(data->text, text, size);
return data;
}
static int sendtext(void *obj)
{
struct sendtext_data *data = obj;
RAII_VAR(struct sendtext_data *, data, obj, ao2_cleanup);
pjsip_tx_data *tdata;
const char *body_text = ast_msg_data_get_attribute(data->msg, AST_MSG_DATA_ATTR_BODY);
const char *content_type = ast_msg_data_get_attribute(data->msg, AST_MSG_DATA_ATTR_CONTENT_TYPE);
char *sep;
struct ast_sip_body body = {
const struct ast_sip_body body = {
.type = "text",
.subtype = "plain",
.body_text = body_text,
.body_text = data->text
};
if (!ast_strlen_zero(content_type)) {
sep = strchr(content_type, '/');
if (sep) {
*sep = '\0';
body.type = content_type;
body.subtype = ++sep;
}
}
if (data->session->inv_session->state == PJSIP_INV_STATE_DISCONNECTED) {
ast_log(LOG_ERROR, "Session already DISCONNECTED [reason=%d (%s)]\n",
data->session->inv_session->cause,
pjsip_get_status_text(data->session->inv_session->cause)->ptr);
} else {
pjsip_from_hdr *hdr;
pjsip_name_addr *name_addr;
const char *from = ast_msg_data_get_attribute(data->msg, AST_MSG_DATA_ATTR_FROM);
const char *to = ast_msg_data_get_attribute(data->msg, AST_MSG_DATA_ATTR_TO);
int invalidate_tdata = 0;
ast_debug(3, "Sending in dialog SIP message\n");
ast_sip_create_request("MESSAGE", data->session->inv_session->dlg, data->session->endpoint, NULL, NULL, &tdata);
ast_sip_add_body(tdata, &body);
/*
* If we have a 'from' in the msg, set the display name in the From
* header to it.
*/
if (!ast_strlen_zero(from)) {
hdr = PJSIP_MSG_FROM_HDR(tdata->msg);
name_addr = (pjsip_name_addr *) hdr->uri;
pj_strdup2(tdata->pool, &name_addr->display, from);
invalidate_tdata = 1;
}
/*
* If we have a 'to' in the msg, set the display name in the To
* header to it.
*/
if (!ast_strlen_zero(to)) {
hdr = PJSIP_MSG_TO_HDR(tdata->msg);
name_addr = (pjsip_name_addr *) hdr->uri;
pj_strdup2(tdata->pool, &name_addr->display, to);
invalidate_tdata = 1;
}
if (invalidate_tdata) {
pjsip_tx_data_invalidate_msg(tdata);
}
ast_sip_send_request(tdata, data->session->inv_session->dlg, data->session->endpoint, NULL, NULL);
}
@@ -2364,22 +2312,14 @@ static int sendtext(void *obj)
pjsip_inv_dec_ref(data->session->inv_session);
#endif
ao2_cleanup(data);
return 0;
}
/*! \brief Function called by core to send text on PJSIP session */
static int chan_pjsip_sendtext_data(struct ast_channel *ast, struct ast_msg_data *msg)
static int chan_pjsip_sendtext(struct ast_channel *ast, const char *text)
{
struct ast_sip_channel_pvt *channel = ast_channel_tech_pvt(ast);
struct sendtext_data *data = sendtext_data_create(ast, msg);
ast_debug(1, "Sending MESSAGE from '%s' to '%s:%s': %s\n",
ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_FROM),
ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_TO),
ast_channel_name(ast),
ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_BODY));
struct sendtext_data *data = sendtext_data_create(channel->session, text);
if (!data) {
return -1;
@@ -2403,28 +2343,6 @@ static int chan_pjsip_sendtext_data(struct ast_channel *ast, struct ast_msg_data
return 0;
}
static int chan_pjsip_sendtext(struct ast_channel *ast, const char *text)
{
struct ast_msg_data *msg;
int rc;
struct ast_msg_data_attribute attrs[] =
{
{
.type = AST_MSG_DATA_ATTR_BODY,
.value = (char *)text,
}
};
msg = ast_msg_data_alloc(AST_MSG_DATA_SOURCE_TYPE_UNKNOWN, attrs, ARRAY_LEN(attrs));
if (!msg) {
return -1;
}
rc = chan_pjsip_sendtext_data(ast, msg);
ast_free(msg);
return rc;
}
/*! \brief Convert SIP hangup causes to Asterisk hangup causes */
static int hangup_sip2cause(int cause)
{

View File

@@ -62,7 +62,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
<enum name = "NULL" />
<enum name = "IAX" />
<enum name = "TEXT" />
<enum name = "TEXT_DATA" />
<enum name = "IMAGE" />
<enum name = "HTML" />
<enum name = "CNG" />
@@ -92,7 +91,6 @@ static struct {
{ AST_FRAME_NULL, "NULL" },
{ AST_FRAME_IAX, "IAX" },
{ AST_FRAME_TEXT, "TEXT" },
{ AST_FRAME_TEXT_DATA, "TEXT_DATA" },
{ AST_FRAME_IMAGE, "IMAGE" },
{ AST_FRAME_HTML, "HTML" },
{ AST_FRAME_CNG, "CNG" },
@@ -375,9 +373,6 @@ static void print_frame(struct ast_frame *frame)
}
ast_verbose("Bytes: %d\n", frame->datalen);
break;
case AST_FRAME_RTCP:
ast_verbose("FrameType: RTCP\n");
break;
case AST_FRAME_NULL:
ast_verbose("FrameType: NULL\n");
break;
@@ -387,9 +382,6 @@ static void print_frame(struct ast_frame *frame)
case AST_FRAME_TEXT:
ast_verbose("FrameType: TXT\n");
break;
case AST_FRAME_TEXT_DATA:
ast_verbose("FrameType: TXT_DATA\n");
break;
case AST_FRAME_IMAGE:
ast_verbose("FrameType: IMAGE\n");
break;

View File

@@ -589,11 +589,6 @@ struct ast_assigned_ids {
const char *uniqueid2;
};
/*!
* \brief Forward declaration
*/
struct ast_msg_data;
/*!
* \brief
* Structure to describe a channel "technology", ie a channel driver
@@ -761,9 +756,6 @@ struct ast_channel_tech {
* \retval -1 on error.
*/
int (*pre_call)(struct ast_channel *chan, const char *sub_args);
/*! \brief Display or transmit text with data*/
int (* const send_text_data)(struct ast_channel *chan, struct ast_msg_data *data);
};
/*! Kill the channel channel driver technology descriptor. */
@@ -891,10 +883,6 @@ enum {
* world
*/
AST_CHAN_TP_INTERNAL = (1 << 2),
/*!
* \brief Channels have this property if they implement send_text_data
*/
AST_CHAN_TP_SEND_TEXT_DATA = (1 << 3),
};
/*! \brief ast_channel flags */
@@ -2079,26 +2067,6 @@ int ast_set_write_format(struct ast_channel *chan, struct ast_format *format);
*/
int ast_sendtext(struct ast_channel *chan, const char *text);
/*!
* \brief Sends text to a channel in an ast_msg_data structure wrapper with ast_sendtext as fallback
* \since 13.22.0
* \since 15.5.0
*
* \param chan channel to act upon
* \param msg ast_msg_data structure
*
* \details
* Write text to a display on a channel. If the channel driver doesn't support the
* send_text_data callback. then the original send_text callback will be used if
* available.
*
* \note The channel does not need to be locked before calling this function.
*
* \retval 0 on success
* \retval -1 on failure
*/
int ast_sendtext_data(struct ast_channel *chan, struct ast_msg_data *msg);
/*!
* \brief Receives a text character from a channel
* \param chan channel to act upon

View File

@@ -48,7 +48,6 @@ extern "C" {
* \arg \b DTMF: A DTMF digit, subclass is the digit
* \arg \b IMAGE: Image transport, mostly used in IAX
* \arg \b TEXT: Text messages and character by character (real time text)
* \arg \b TEXT_DATA: Text messages in an ast_msg_data structure
* \arg \b HTML: URL's and web pages
* \arg \b MODEM: Modulated data encodings, such as T.38 and V.150
* \arg \b IAX: Private frame type for the IAX protocol
@@ -128,10 +127,6 @@ enum ast_frame_type {
* directly into bridges.
*/
AST_FRAME_BRIDGE_ACTION_SYNC,
/*! RTCP feedback (the subclass will contain the payload type) */
AST_FRAME_RTCP,
/*! Text message in an ast_msg_data structure */
AST_FRAME_TEXT_DATA,
};
#define AST_FRAME_DTMF AST_FRAME_DTMF_END

View File

@@ -407,129 +407,6 @@ void ast_msg_var_iterator_destroy(struct ast_msg_var_iterator *iter);
*/
void ast_msg_var_unref_current(struct ast_msg_var_iterator *iter);
/*! \defgroup ast_msg_data Enhanced Messaging
* @{
* \page Messaging Enhanced Messaging
*
* The basic messaging framework has a basic drawback... It can only pass
* a text string through the core. This causes several issues:
* \li Only a content type of text/plain can be passed.
* \li If a softmix bridge is used, the original sender identity is lost.
*
* The Enhanced Messaging framework allows attributes, such as "From", "To"
* and "Content-Type" to be attached to the message by the incoming channel
* tech which can then be used by the outgoing channel tech to construct
* the appropriate technology-specific outgoing message.
*/
/*!
* \brief Structure used to transport an enhanced message through the frame core
* \since 13.22.0
* \since 15.5.0
*/
struct ast_msg_data;
enum ast_msg_data_source_type {
AST_MSG_DATA_SOURCE_TYPE_UNKNOWN = 0,
AST_MSG_DATA_SOURCE_TYPE_T140,
AST_MSG_DATA_SOURCE_TYPE_IN_DIALOG,
AST_MSG_DATA_SOURCE_TYPE_OUT_OF_DIALOG,
__AST_MSG_DATA_SOURCE_TYPE_LAST,
};
enum ast_msg_data_attribute_type {
AST_MSG_DATA_ATTR_TO = 0,
AST_MSG_DATA_ATTR_FROM,
AST_MSG_DATA_ATTR_CONTENT_TYPE,
AST_MSG_DATA_ATTR_BODY,
__AST_MSG_DATA_ATTR_LAST,
};
struct ast_msg_data_attribute {
enum ast_msg_data_attribute_type type;
char *value;
};
/*!
* \brief Allocates an ast_msg_data structure.
* \since 13.22.0
* \since 15.5.0
*
* \param source The source type of the message
* \param attributes A pointer to an array of ast_msg_data_attribute structures
* \param count The number of elements in the array
*
* \return Pointer to msg structure or NULL on allocation failure.
* Caller must call ast_free when done.
*/
struct ast_msg_data *ast_msg_data_alloc(enum ast_msg_data_source_type source,
struct ast_msg_data_attribute attributes[], size_t count);
/*!
* \brief Clone an ast_msg_data structure
* \since 13.22.0
* \since 15.5.0
*
* \param msg The message to clone
*
* \return New message structure or NULL if there was an allocation failure.
* Caller must call ast_free when done.
*/
struct ast_msg_data *ast_msg_data_dup(struct ast_msg_data *msg);
/*!
* \brief Get length of the structure
* \since 13.22.0
* \since 15.5.0
*
* \param msg Pointer to ast_msg_data structure
*
* \return The length of the structure itself plus the dynamically allocated attribute buffer.
*/
size_t ast_msg_data_get_length(struct ast_msg_data *msg);
/*!
* \brief Get "source type" from ast_msg_data
* \since 13.22.0
* \since 15.5.0
*
* \param msg Pointer to ast_msg_data structure
*
* \return The source type field.
*/
enum ast_msg_data_source_type ast_msg_data_get_source_type(struct ast_msg_data *msg);
/*!
* \brief Get attribute from ast_msg_data
* \since 13.22.0
* \since 15.5.0
*
* \param msg Pointer to ast_msg_data structure
* \param attribute_type One of ast_msg_data_attribute_type
*
* \return The attribute or an empty string ("") if the attribute wasn't set.
*/
const char *ast_msg_data_get_attribute(struct ast_msg_data *msg,
enum ast_msg_data_attribute_type attribute_type);
/*!
* \brief Queue an AST_FRAME_TEXT_DATA frame containing an ast_msg_data structure
* \since 13.22.0
* \since 15.5.0
*
* \param channel The channel on which to queue the frame
* \param msg Pointer to ast_msg_data structure
*
* \retval -1 Error
* \retval 0 Success
*/
int ast_msg_data_queue_frame(struct ast_channel *channel, struct ast_msg_data *msg);
/*!
* @}
*/
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif

View File

@@ -57,7 +57,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/causes.h"
#include "asterisk/test.h"
#include "asterisk/sem.h"
#include "asterisk/message.h"
/*!
* \brief Used to queue an action frame onto a bridge channel and write an action frame into a bridge.
@@ -1000,20 +999,6 @@ int ast_bridge_channel_queue_frame(struct ast_bridge_channel *bridge_channel, st
return 0;
}
if (DEBUG_ATLEAST(1)) {
if (fr->frametype == AST_FRAME_TEXT) {
ast_log(LOG_DEBUG, "Queuing TEXT frame to '%s': %*.s\n", ast_channel_name(bridge_channel->chan),
fr->datalen, (char *)fr->data.ptr);
} else if (fr->frametype == AST_FRAME_TEXT_DATA) {
struct ast_msg_data *msg = fr->data.ptr;
ast_log(LOG_DEBUG, "Queueing TEXT_DATA frame from '%s' to '%s:%s': %s\n",
ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_FROM),
ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_TO),
ast_channel_name(bridge_channel->chan),
ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_BODY));
}
}
AST_LIST_INSERT_TAIL(&bridge_channel->wr_queue, dup, frame_list);
if (ast_alertpipe_write(bridge_channel->alert_pipe)) {
ast_log(LOG_ERROR, "We couldn't write alert pipe for %p(%s)... something is VERY wrong\n",
@@ -2304,7 +2289,6 @@ static void bridge_channel_handle_write(struct ast_bridge_channel *bridge_channe
{
struct ast_frame *fr;
struct sync_payload *sync_payload;
struct ast_msg_data *msg;
ast_bridge_channel_lock(bridge_channel);
@@ -2337,7 +2321,6 @@ static void bridge_channel_handle_write(struct ast_bridge_channel *bridge_channe
AST_LIST_TRAVERSE_SAFE_END;
ast_bridge_channel_unlock(bridge_channel);
if (!fr) {
/*
* Wait some to reduce CPU usage from a tight loop
@@ -2361,20 +2344,6 @@ static void bridge_channel_handle_write(struct ast_bridge_channel *bridge_channe
break;
case AST_FRAME_NULL:
break;
case AST_FRAME_TEXT:
ast_debug(1, "Sending TEXT frame to '%s': %*.s\n",
ast_channel_name(bridge_channel->chan), fr->datalen, (char *)fr->data.ptr);
ast_sendtext(bridge_channel->chan, fr->data.ptr);
break;
case AST_FRAME_TEXT_DATA:
msg = (struct ast_msg_data *)fr->data.ptr;
ast_debug(1, "Sending TEXT_DATA frame from '%s' to '%s:%s': %s\n",
ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_FROM),
ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_TO),
ast_channel_name(bridge_channel->chan),
ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_BODY));
ast_sendtext_data(bridge_channel->chan, msg);
break;
default:
/* Write the frame to the channel. */
bridge_channel->activity = BRIDGE_CHANNEL_THREAD_SIMPLE;

View File

@@ -75,7 +75,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/test.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/max_forwards.h"
#include "asterisk/message.h"
/*** DOCUMENTATION
***/
@@ -1514,7 +1513,6 @@ int ast_is_deferrable_frame(const struct ast_frame *frame)
case AST_FRAME_BRIDGE_ACTION_SYNC:
case AST_FRAME_CONTROL:
case AST_FRAME_TEXT:
case AST_FRAME_TEXT_DATA:
case AST_FRAME_IMAGE:
case AST_FRAME_HTML:
return 1;
@@ -1527,7 +1525,6 @@ int ast_is_deferrable_frame(const struct ast_frame *frame)
case AST_FRAME_IAX:
case AST_FRAME_CNG:
case AST_FRAME_MODEM:
case AST_FRAME_RTCP:
return 0;
}
return 0;
@@ -2886,13 +2883,11 @@ int __ast_answer(struct ast_channel *chan, unsigned int delay)
case AST_FRAME_VOICE:
case AST_FRAME_VIDEO:
case AST_FRAME_TEXT:
case AST_FRAME_TEXT_DATA:
case AST_FRAME_DTMF_BEGIN:
case AST_FRAME_DTMF_END:
case AST_FRAME_IMAGE:
case AST_FRAME_HTML:
case AST_FRAME_MODEM:
case AST_FRAME_RTCP:
done = 1;
break;
case AST_FRAME_CONTROL:
@@ -4874,11 +4869,9 @@ char *ast_recvtext(struct ast_channel *chan, int timeout)
return buf;
}
int ast_sendtext_data(struct ast_channel *chan, struct ast_msg_data *msg)
int ast_sendtext(struct ast_channel *chan, const char *text)
{
int res = 0;
const char *body = ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_BODY);
const char *content_type = ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_CONTENT_TYPE);
ast_channel_lock(chan);
/* Stop if we're a zombie or need a soft hangup */
@@ -4887,76 +4880,35 @@ int ast_sendtext_data(struct ast_channel *chan, struct ast_msg_data *msg)
return -1;
}
CHECK_BLOCKING(chan);
if (ast_channel_tech(chan)->write_text
&& (ast_strlen_zero(content_type) || ast_begins_with(content_type, "text/"))
&& (ast_format_cap_has_type(ast_channel_nativeformats(chan), AST_MEDIA_TYPE_TEXT))) {
struct ast_frame f;
size_t body_len = strlen(body) + 1;
if (ast_strlen_zero(text)) {
ast_channel_unlock(chan);
return 0;
}
CHECK_BLOCKING(chan);
if (ast_channel_tech(chan)->write_text && (ast_format_cap_has_type(ast_channel_nativeformats(chan), AST_MEDIA_TYPE_TEXT))) {
struct ast_frame f;
/* Process as T.140 text (moved here from ast_sendtext() */
memset(&f, 0, sizeof(f));
f.src = "DIALPLAN";
f.subclass.format = ast_format_t140;
f.frametype = AST_FRAME_TEXT;
f.datalen = body_len;
f.src = "DIALPLAN";
f.mallocd = AST_MALLOCD_DATA;
f.data.ptr = ast_strdup(body);
f.datalen = strlen(text);
f.data.ptr = ast_strdup(text);
f.subclass.format = ast_format_t140;
if (f.data.ptr) {
res = ast_channel_tech(chan)->write_text(chan, &f);
} else {
res = -1;
ast_frfree(&f);
}
ast_frfree(&f);
} else if ((ast_channel_tech(chan)->properties & AST_CHAN_TP_SEND_TEXT_DATA)
&& ast_channel_tech(chan)->send_text_data) {
/* Send enhanced message to a channel driver that supports it */
ast_debug(1, "Sending TEXT_DATA from '%s' to %s:%s %s\n",
ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_FROM),
ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_TO),
ast_channel_name(chan), body);
res = ast_channel_tech(chan)->send_text_data(chan, msg);
} else if (ast_channel_tech(chan)->send_text
&& (ast_strlen_zero(content_type) || ast_begins_with(content_type, "text/"))) {
/* Send the body of an enhanced message to a channel driver that supports only a char str */
ast_debug(1, "Sending TEXT to %s: %s\n", ast_channel_name(chan), body);
res = ast_channel_tech(chan)->send_text(chan, body);
} else {
ast_debug(1, "Channel technology does not support sending text on channel '%s'\n",
ast_channel_name(chan));
res = -1;
} else if (ast_channel_tech(chan)->send_text) {
res = ast_channel_tech(chan)->send_text(chan, text);
}
ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING);
ast_channel_unlock(chan);
return res;
}
int ast_sendtext(struct ast_channel *chan, const char *text)
{
struct ast_msg_data *msg;
int rc;
struct ast_msg_data_attribute attrs[] =
{
{
.type = AST_MSG_DATA_ATTR_BODY,
.value = (char *)text,
}
};
if (ast_strlen_zero(text)) {
return 0;
}
msg = ast_msg_data_alloc(AST_MSG_DATA_SOURCE_TYPE_UNKNOWN, attrs, ARRAY_LEN(attrs));
if (!msg) {
return -1;
}
rc = ast_sendtext_data(chan, msg);
ast_free(msg);
return rc;
}
int ast_senddigit_begin(struct ast_channel *chan, char digit)
{
/* Device does not support DTMF tones, lets fake

View File

@@ -591,9 +591,6 @@ void ast_frame_type2str(enum ast_frame_type frame_type, char *ftype, size_t len)
case AST_FRAME_TEXT:
ast_copy_string(ftype, "Text", len);
break;
case AST_FRAME_TEXT_DATA:
ast_copy_string(ftype, "Text Data", len);
break;
case AST_FRAME_IMAGE:
ast_copy_string(ftype, "Image", len);
break;

View File

@@ -1350,148 +1350,6 @@ int ast_msg_send(struct ast_msg *msg, const char *to, const char *from)
return res;
}
/*!
* \brief Structure used to transport a message through the frame core
* \since 13.22.0
* \since 15.5.0
*/
struct ast_msg_data {
/*! The length of this structure plus the actual length of the allocated buffer */
size_t length;
enum ast_msg_data_source_type source;
/*! These are indices into the buffer where teh attribute starts */
int attribute_value_offsets[__AST_MSG_DATA_ATTR_LAST];
/*! The buffer containing the NULL separated attributes */
char buf[0];
};
#define ATTRIBUTE_UNSET -1
struct ast_msg_data *ast_msg_data_alloc(enum ast_msg_data_source_type source,
struct ast_msg_data_attribute attributes[], size_t count)
{
struct ast_msg_data *msg;
size_t len = sizeof(*msg);
size_t i;
size_t current_offset = 0;
enum ast_msg_data_attribute_type attr_type;
if (!attributes) {
ast_assert(attributes != NULL);
return NULL;
}
if (!count) {
ast_assert(count > 0);
return NULL;
}
/* Calculate the length required for the buffer */
for (i=0; i < count; i++) {
if (!attributes[i].value) {
ast_assert(attributes[i].value != NULL);
return NULL;
}
len += (strlen(attributes[i].value) + 1);
}
msg = ast_calloc(1, len);
if (!msg) {
return NULL;
}
msg->source = source;
msg->length = len;
/* Mark all of the attributes as unset */
for (attr_type = 0; attr_type < __AST_MSG_DATA_ATTR_LAST; attr_type++) {
msg->attribute_value_offsets[attr_type] = ATTRIBUTE_UNSET;
}
/* Set the ones we have and increment the offset */
for (i=0; i < count; i++) {
len = (strlen(attributes[i].value) + 1);
strcpy(msg->buf + current_offset, attributes[i].value); /* Safe */
msg->attribute_value_offsets[attributes[i].type] = current_offset;
current_offset += len;
}
return msg;
}
struct ast_msg_data *ast_msg_data_dup(struct ast_msg_data *msg)
{
struct ast_msg_data *dest;
if (!msg) {
ast_assert(msg != NULL);
return NULL;
}
dest = ast_malloc(msg->length);
if (!dest) {
return NULL;
}
memcpy(dest, msg, msg->length);
return dest;
}
size_t ast_msg_data_get_length(struct ast_msg_data *msg)
{
if (!msg) {
ast_assert(msg != NULL);
return 0;
}
return msg->length;
}
enum ast_msg_data_source_type ast_msg_data_get_source_type(struct ast_msg_data *msg)
{
if (!msg) {
ast_assert(msg != NULL);
return AST_MSG_DATA_SOURCE_TYPE_UNKNOWN;
}
return msg->source;
}
const char *ast_msg_data_get_attribute(struct ast_msg_data *msg,
enum ast_msg_data_attribute_type attribute_type)
{
if (!msg) {
ast_assert(msg != NULL);
return "";
}
if (msg->attribute_value_offsets[attribute_type] > ATTRIBUTE_UNSET) {
return msg->buf + msg->attribute_value_offsets[attribute_type];
}
return "";
}
int ast_msg_data_queue_frame(struct ast_channel *channel, struct ast_msg_data *msg)
{
struct ast_frame f;
if (!channel) {
ast_assert(channel != NULL);
return -1;
}
if (!msg) {
ast_assert(msg != NULL);
return -1;
}
memset(&f, 0, sizeof(f));
f.frametype = AST_FRAME_TEXT_DATA;
f.data.ptr = msg;
f.datalen = msg->length;
return ast_queue_frame(channel, &f);
}
int ast_msg_tech_register(const struct ast_msg_tech *tech)
{
const struct ast_msg_tech *match;

View File

@@ -666,26 +666,6 @@ static void check_endpoint(pjsip_rx_data *rdata, struct unidentified_request *un
ao2_unlock(unid);
}
static int apply_endpoint_acl(pjsip_rx_data *rdata, struct ast_sip_endpoint *endpoint);
static int apply_endpoint_contact_acl(pjsip_rx_data *rdata, struct ast_sip_endpoint *endpoint);
static void apply_acls(pjsip_rx_data *rdata)
{
struct ast_sip_endpoint *endpoint;
/* Is the endpoint allowed with the source or contact address? */
endpoint = rdata->endpt_info.mod_data[endpoint_mod.id];
if (endpoint != artificial_endpoint
&& (apply_endpoint_acl(rdata, endpoint)
|| apply_endpoint_contact_acl(rdata, endpoint))) {
ast_debug(1, "Endpoint '%s' not allowed by ACL\n",
ast_sorcery_object_get_id(endpoint));
/* Replace the rdata endpoint with the artificial endpoint. */
ao2_replace(rdata->endpt_info.mod_data[endpoint_mod.id], artificial_endpoint);
}
}
static pj_bool_t endpoint_lookup(pjsip_rx_data *rdata)
{
struct ast_sip_endpoint *endpoint;
@@ -704,7 +684,6 @@ static pj_bool_t endpoint_lookup(pjsip_rx_data *rdata)
ao2_unlink(unidentified_requests, unid);
ao2_ref(unid, -1);
}
apply_acls(rdata);
return PJ_FALSE;
}
@@ -764,8 +743,6 @@ static pj_bool_t endpoint_lookup(pjsip_rx_data *rdata)
ast_sip_report_invalid_endpoint(name, rdata);
}
}
apply_acls(rdata);
return PJ_FALSE;
}
@@ -849,11 +826,16 @@ static pj_bool_t authenticate(pjsip_rx_data *rdata)
ast_assert(endpoint != NULL);
if (is_ack) {
return PJ_FALSE;
if (endpoint!=artificial_endpoint) {
if (apply_endpoint_acl(rdata, endpoint) || apply_endpoint_contact_acl(rdata, endpoint)) {
if (!is_ack) {
pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 403, NULL, NULL, NULL);
}
return PJ_TRUE;
}
}
if (ast_sip_requires_authentication(endpoint, rdata)) {
if (!is_ack && ast_sip_requires_authentication(endpoint, rdata)) {
pjsip_tx_data *tdata;
struct unidentified_request *unid;
@@ -889,10 +871,6 @@ static pj_bool_t authenticate(pjsip_rx_data *rdata)
return PJ_TRUE;
}
pjsip_tx_data_dec_ref(tdata);
} else if (endpoint == artificial_endpoint) {
/* Uh. Oh. The artificial endpoint couldn't challenge so block the request. */
pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 500, NULL, NULL, NULL);
return PJ_TRUE;
}
return PJ_FALSE;

View File

@@ -342,7 +342,7 @@ int ast_sip_initialize_transport_management(void)
return AST_MODULE_LOAD_DECLINE;
}
internal_sip_register_service(&idle_monitor_module);
ast_sip_register_service(&idle_monitor_module);
ast_sip_transport_state_register(&monitored_transport_reg);
@@ -367,7 +367,7 @@ void ast_sip_destroy_transport_management(void)
ast_sip_transport_state_unregister(&monitored_transport_reg);
internal_sip_unregister_service(&idle_monitor_module);
ast_sip_unregister_service(&idle_monitor_module);
ast_sched_context_destroy(sched);
sched = NULL;

View File

@@ -768,7 +768,6 @@ static int unload_module(void)
ast_cli_unregister_multiple(cli_identify, ARRAY_LEN(cli_identify));
ast_sip_unregister_cli_formatter(cli_formatter);
ast_sip_unregister_endpoint_formatter(&endpoint_identify_formatter);
ast_sip_unregister_endpoint_identifier(&header_identifier);
ast_sip_unregister_endpoint_identifier(&ip_identifier);
return 0;

View File

@@ -76,32 +76,6 @@ static enum pjsip_status_code check_content_type(const pjsip_rx_data *rdata)
return res ? PJSIP_SC_OK : PJSIP_SC_UNSUPPORTED_MEDIA_TYPE;
}
/*!
* \internal
* \brief Checks to make sure the request has the correct content type.
*
* \details This module supports the following media types: "text/\*".
* Return unsupported otherwise.
*
* \param rdata The SIP request
*/
static enum pjsip_status_code check_content_type_any_text(const pjsip_rx_data *rdata)
{
int res = PJSIP_SC_UNSUPPORTED_MEDIA_TYPE;
pj_str_t text = { "text", 4};
/* We'll accept any text/ content type */
if (rdata->msg_info.msg->body && rdata->msg_info.msg->body->len
&& pj_stricmp(&rdata->msg_info.msg->body->content_type.type, &text) == 0) {
res = PJSIP_SC_OK;
} else if (rdata->msg_info.ctype
&& pj_stricmp(&rdata->msg_info.ctype->media.type, &text) == 0) {
res = PJSIP_SC_OK;
}
return res;
}
/*!
* \internal
* \brief Puts pointer past 'sip[s]:' string that should be at the
@@ -782,98 +756,39 @@ static pj_bool_t module_on_rx_request(pjsip_rx_data *rdata)
static int incoming_in_dialog_request(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
{
char buf[MAX_BODY_SIZE];
enum pjsip_status_code code;
int rc;
struct ast_frame f;
pjsip_dialog *dlg = session->inv_session->dlg;
pjsip_transaction *tsx = pjsip_rdata_get_tsx(rdata);
struct ast_msg_data *msg;
struct ast_party_caller *caller;
pjsip_name_addr *name_addr;
size_t from_len;
size_t to_len;
struct ast_msg_data_attribute attrs[4];
int pos = 0;
int body_pos;
if (!session->channel) {
send_response(rdata, PJSIP_SC_NOT_FOUND, dlg, tsx);
return 0;
}
code = check_content_type_any_text(rdata);
if (code != PJSIP_SC_OK) {
if ((code = check_content_type(rdata)) != PJSIP_SC_OK) {
send_response(rdata, code, dlg, tsx);
return 0;
}
caller = ast_channel_caller(session->channel);
name_addr = (pjsip_name_addr *) rdata->msg_info.from->uri;
from_len = pj_strlen(&name_addr->display);
if (from_len) {
attrs[pos].type = AST_MSG_DATA_ATTR_FROM;
from_len++;
attrs[pos].value = ast_alloca(from_len);
ast_copy_pj_str(attrs[pos].value, &name_addr->display, from_len);
pos++;
} else if (caller->id.name.valid && !ast_strlen_zero(caller->id.name.str)) {
attrs[pos].type = AST_MSG_DATA_ATTR_FROM;
attrs[pos].value = caller->id.name.str;
pos++;
}
name_addr = (pjsip_name_addr *) rdata->msg_info.to->uri;
to_len = pj_strlen(&name_addr->display);
if (to_len) {
attrs[pos].type = AST_MSG_DATA_ATTR_TO;
to_len++;
attrs[pos].value = ast_alloca(to_len);
ast_copy_pj_str(attrs[pos].value, &name_addr->display, to_len);
pos++;
}
attrs[pos].type = AST_MSG_DATA_ATTR_CONTENT_TYPE;
attrs[pos].value = ast_alloca(rdata->msg_info.msg->body->content_type.type.slen
+ rdata->msg_info.msg->body->content_type.subtype.slen + 2);
sprintf(attrs[pos].value, "%.*s/%.*s",
(int)rdata->msg_info.msg->body->content_type.type.slen,
rdata->msg_info.msg->body->content_type.type.ptr,
(int)rdata->msg_info.msg->body->content_type.subtype.slen,
rdata->msg_info.msg->body->content_type.subtype.ptr);
pos++;
body_pos = pos;
attrs[pos].type = AST_MSG_DATA_ATTR_BODY;
attrs[pos].value = ast_malloc(rdata->msg_info.msg->body->len + 1);
if (!attrs[pos].value) {
send_response(rdata, PJSIP_SC_INTERNAL_SERVER_ERROR, dlg, tsx);
return 0;
}
ast_copy_string(attrs[pos].value, rdata->msg_info.msg->body->data, rdata->msg_info.msg->body->len);
pos++;
msg = ast_msg_data_alloc(AST_MSG_DATA_SOURCE_TYPE_IN_DIALOG, attrs, pos);
if (!msg) {
ast_free(attrs[body_pos].value);
send_response(rdata, PJSIP_SC_INTERNAL_SERVER_ERROR, dlg, tsx);
if (print_body(rdata, buf, sizeof(buf)-1) < 1) {
/* invalid body size */
send_response(rdata, PJSIP_SC_REQUEST_ENTITY_TOO_LARGE, dlg, tsx);
return 0;
}
ast_debug(1, "Received in-dialog MESSAGE from '%s:%s': %s %s\n",
ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_FROM),
ast_channel_name(session->channel),
ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_TO),
ast_msg_data_get_attribute(msg, AST_MSG_DATA_ATTR_BODY));
ast_debug(3, "Received in dialog SIP message\n");
rc = ast_msg_data_queue_frame(session->channel, msg);
ast_free(attrs[body_pos].value);
ast_free(msg);
if (rc != 0) {
send_response(rdata, PJSIP_SC_INTERNAL_SERVER_ERROR, dlg, tsx);
} else {
send_response(rdata, PJSIP_SC_ACCEPTED, dlg, tsx);
}
memset(&f, 0, sizeof(f));
f.frametype = AST_FRAME_TEXT;
f.subclass.integer = 0;
f.offset = 0;
f.data.ptr = buf;
f.datalen = strlen(buf) + 1;
ast_queue_frame(session->channel, &f);
send_response(rdata, PJSIP_SC_ACCEPTED, dlg, tsx);
return 0;
}