[asterisk-commits] rmudgett: branch 1.8 r331714 - /branches/1.8/channels/chan_dahdi.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Aug 12 12:48:01 CDT 2011
Author: rmudgett
Date: Fri Aug 12 12:47:57 2011
New Revision: 331714
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=331714
Log:
AMI actions DAHDIHangup and DAHDITransfer have no effect.
The AMI actions DAHDIHangup and DAHDITransfer have no effect on a DAHDI
channel. These two AMI actions are highly specialized to analog channels
and appear to make the channel behave like a jack port for headsets.
* Made the faked DAHDI event get processed before a normal media stream
read in dahdi_read() instead of trying to trigger an exception read by
setting the AST_FLAG_EXCEPTION flag. Apparently a change was made long
ago that changed how AST_FLAG_EXCEPTION is processed in the core.
Unfortunately, the faked DAHDI events no longer worked when that happened.
* Updated the DAHDI AMI action documentation for the following actions:
DAHDITransfer, DAHDIHangup, DAHDIDialOffhook, DAHDIDNDon, DAHDIDNDoff,
DAHDIShowChannels, and DAHDIRestart.
* Made use sscanf() instead of atoi() for better error checking of the
DAHDIChannel header string.
JIRA AST-620
JIRA SWP-3616
Modified:
branches/1.8/channels/chan_dahdi.c
Modified: branches/1.8/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_dahdi.c?view=diff&rev=331714&r1=331713&r2=331714
==============================================================================
--- branches/1.8/channels/chan_dahdi.c (original)
+++ branches/1.8/channels/chan_dahdi.c Fri Aug 12 12:47:57 2011
@@ -175,11 +175,12 @@
<syntax>
<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
<parameter name="DAHDIChannel" required="true">
- <para>DAHDI channel name to transfer.</para>
+ <para>DAHDI channel number to transfer.</para>
</parameter>
</syntax>
<description>
- <para>Transfer a DAHDI channel.</para>
+ <para>Simulate a flash hook event by the user connected to the channel.</para>
+ <note><para>Valid only for analog channels.</para></note>
</description>
</manager>
<manager name="DAHDIHangup" language="en_US">
@@ -189,11 +190,12 @@
<syntax>
<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
<parameter name="DAHDIChannel" required="true">
- <para>DAHDI channel name to hangup.</para>
+ <para>DAHDI channel number to hangup.</para>
</parameter>
</syntax>
<description>
- <para>Hangup a DAHDI channel.</para>
+ <para>Simulate an on-hook event by the user connected to the channel.</para>
+ <note><para>Valid only for analog channels.</para></note>
</description>
</manager>
<manager name="DAHDIDialOffhook" language="en_US">
@@ -202,10 +204,15 @@
</synopsis>
<syntax>
<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
- <parameter name="DAHDIChannel" required="true" />
- <parameter name="Number" required="true" />
+ <parameter name="DAHDIChannel" required="true">
+ <para>DAHDI channel number to dial digits.</para>
+ </parameter>
+ <parameter name="Number" required="true">
+ <para>Digits to dial.</para>
+ </parameter>
</syntax>
<description>
+ <para>Generate DTMF control frames to the bridged peer.</para>
</description>
</manager>
<manager name="DAHDIDNDon" language="en_US">
@@ -214,9 +221,13 @@
</synopsis>
<syntax>
<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
- <parameter name="DAHDIChannel" required="true" />
+ <parameter name="DAHDIChannel" required="true">
+ <para>DAHDI channel number to set DND on.</para>
+ </parameter>
</syntax>
<description>
+ <para>Equivalent to the CLI command "dahdi set dnd <variable>channel</variable> on".</para>
+ <note><para>Feature only supported by analog channels.</para></note>
</description>
</manager>
<manager name="DAHDIDNDoff" language="en_US">
@@ -225,22 +236,27 @@
</synopsis>
<syntax>
<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
- <parameter name="DAHDIChannel" required="true" />
+ <parameter name="DAHDIChannel" required="true">
+ <para>DAHDI channel number to set DND off.</para>
+ </parameter>
</syntax>
<description>
+ <para>Equivalent to the CLI command "dahdi set dnd <variable>channel</variable> off".</para>
+ <note><para>Feature only supported by analog channels.</para></note>
</description>
</manager>
<manager name="DAHDIShowChannels" language="en_US">
<synopsis>
- Show status DAHDI channels.
+ Show status of DAHDI channels.
</synopsis>
<syntax>
<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
<parameter name="DAHDIChannel">
- <para>Specify the specific channel to show. Show all channels if zero or not present.</para>
+ <para>Specify the specific channel number to show. Show all channels if zero or not present.</para>
</parameter>
</syntax>
<description>
+ <para>Similar to the CLI command "dahdi show channels".</para>
</description>
</manager>
<manager name="DAHDIRestart" language="en_US">
@@ -251,6 +267,7 @@
<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
</syntax>
<description>
+ <para>Equivalent to the CLI command "dahdi restart".</para>
</description>
</manager>
***/
@@ -8910,6 +8927,19 @@
return &p->subs[idx].f;
}
+ /* If we have a fake_event, fake an exception to handle it */
+ if (p->fake_event) {
+ if (analog_lib_handles(p->sig, p->radio, p->oprmode)) {
+ struct analog_pvt *analog_p = p->sig_pvt;
+
+ f = analog_exception(analog_p, ast);
+ } else {
+ f = __dahdi_exception(ast);
+ }
+ ast_mutex_unlock(&p->lock);
+ return f;
+ }
+
if (ast->rawreadformat == AST_FORMAT_SLINEAR) {
if (!p->subs[idx].linear) {
p->subs[idx].linear = 1;
@@ -9140,10 +9170,6 @@
break;
}
}
-
- /* If we have a fake_event, trigger exception to handle it */
- if (p->fake_event)
- ast_set_flag(ast, AST_FLAG_EXCEPTION);
ast_mutex_unlock(&p->lock);
return f;
@@ -15665,16 +15691,37 @@
return p;
}
+/*!
+ * \internal
+ * \brief Get private struct using given numeric channel string.
+ *
+ * \param channel Numeric channel number string get private struct.
+ *
+ * \retval pvt on success.
+ * \retval NULL on error.
+ */
+static struct dahdi_pvt *find_channel_from_str(const char *channel)
+{
+ int chan_num;
+
+ if (sscanf(channel, "%30d", &chan_num) != 1) {
+ /* Not numeric string. */
+ return NULL;
+ }
+
+ return find_channel(chan_num);
+}
+
static int action_dahdidndon(struct mansession *s, const struct message *m)
{
- struct dahdi_pvt *p = NULL;
+ struct dahdi_pvt *p;
const char *channel = astman_get_header(m, "DAHDIChannel");
if (ast_strlen_zero(channel)) {
astman_send_error(s, m, "No channel specified");
return 0;
}
- p = find_channel(atoi(channel));
+ p = find_channel_from_str(channel);
if (!p) {
astman_send_error(s, m, "No such channel");
return 0;
@@ -15686,14 +15733,14 @@
static int action_dahdidndoff(struct mansession *s, const struct message *m)
{
- struct dahdi_pvt *p = NULL;
+ struct dahdi_pvt *p;
const char *channel = astman_get_header(m, "DAHDIChannel");
if (ast_strlen_zero(channel)) {
astman_send_error(s, m, "No channel specified");
return 0;
}
- p = find_channel(atoi(channel));
+ p = find_channel_from_str(channel);
if (!p) {
astman_send_error(s, m, "No such channel");
return 0;
@@ -15705,18 +15752,22 @@
static int action_transfer(struct mansession *s, const struct message *m)
{
- struct dahdi_pvt *p = NULL;
+ struct dahdi_pvt *p;
const char *channel = astman_get_header(m, "DAHDIChannel");
if (ast_strlen_zero(channel)) {
astman_send_error(s, m, "No channel specified");
return 0;
}
- p = find_channel(atoi(channel));
+ p = find_channel_from_str(channel);
if (!p) {
astman_send_error(s, m, "No such channel");
return 0;
}
+ if (!analog_lib_handles(p->sig, 0, 0)) {
+ astman_send_error(s, m, "Channel signaling is not analog");
+ return 0;
+ }
dahdi_fake_event(p,TRANSFER);
astman_send_ack(s, m, "DAHDITransfer");
return 0;
@@ -15724,18 +15775,22 @@
static int action_transferhangup(struct mansession *s, const struct message *m)
{
- struct dahdi_pvt *p = NULL;
+ struct dahdi_pvt *p;
const char *channel = astman_get_header(m, "DAHDIChannel");
if (ast_strlen_zero(channel)) {
astman_send_error(s, m, "No channel specified");
return 0;
}
- p = find_channel(atoi(channel));
+ p = find_channel_from_str(channel);
if (!p) {
astman_send_error(s, m, "No such channel");
return 0;
}
+ if (!analog_lib_handles(p->sig, 0, 0)) {
+ astman_send_error(s, m, "Channel signaling is not analog");
+ return 0;
+ }
dahdi_fake_event(p,HANGUP);
astman_send_ack(s, m, "DAHDIHangup");
return 0;
@@ -15743,7 +15798,7 @@
static int action_dahdidialoffhook(struct mansession *s, const struct message *m)
{
- struct dahdi_pvt *p = NULL;
+ struct dahdi_pvt *p;
const char *channel = astman_get_header(m, "DAHDIChannel");
const char *number = astman_get_header(m, "Number");
int i;
@@ -15756,7 +15811,7 @@
astman_send_error(s, m, "No number specified");
return 0;
}
- p = find_channel(atoi(channel));
+ p = find_channel_from_str(channel);
if (!p) {
astman_send_error(s, m, "No such channel");
return 0;
@@ -15780,9 +15835,11 @@
const char *dahdichannel = astman_get_header(m, "DAHDIChannel");
char idText[256] = "";
int channels = 0;
- int dahdichanquery = -1;
- if (!ast_strlen_zero(dahdichannel)) {
- dahdichanquery = atoi(dahdichannel);
+ int dahdichanquery;
+
+ if (!dahdichannel || sscanf(dahdichannel, "%30d", &dahdichanquery) != 1) {
+ /* Not numeric string. */
+ dahdichanquery = -1;
}
astman_send_ack(s, m, "DAHDI channel status will follow");
More information about the asterisk-commits
mailing list