summaryrefslogtreecommitdiff
path: root/channel.c
diff options
context:
space:
mode:
authorMartin Pycko <martinp@digium.com>2003-09-12 16:51:35 +0000
committerMartin Pycko <martinp@digium.com>2003-09-12 16:51:35 +0000
commit4828759ab85a1b9198a4d8dc7eff3da99d0a86c5 (patch)
tree0cfa74e63cdce0bf09e2e845357eac5addf73e15 /channel.c
parent3672619e13400601b6d92447a0a89e5643217859 (diff)
Add distinguishing between BUSY and FAILURE for outgoing spool calls. Always save CDR record (even if the call fails). If the call fails try to see if there is
"failed" extension in the specified context (only if you use context,extension,priority syntax) and execute it. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1499 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channel.c')
-rwxr-xr-xchannel.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/channel.c b/channel.c
index 2ecde4fee..6d704d742 100755
--- a/channel.c
+++ b/channel.c
@@ -34,6 +34,7 @@
#include <asterisk/linkedlists.h>
#include <asterisk/indications.h>
#include <asterisk/monitor.h>
+#include <asterisk/causes.h>
#ifdef ZAPTEL_OPTIMIZATIONS
#include <sys/ioctl.h>
#include <linux/zaptel.h>
@@ -1493,8 +1494,7 @@ struct ast_channel *ast_request_and_dial(char *type, int format, void *data, int
int state = 0;
struct ast_channel *chan;
struct ast_frame *f;
- int res;
-
+ int res = 0;
chan = ast_request(type, format, data);
if (chan) {
if (callerid)
@@ -1504,8 +1504,6 @@ struct ast_channel *ast_request_and_dial(char *type, int format, void *data, int
res = ast_waitfor(chan, timeout);
if (res < 0) {
/* Something not cool, or timed out */
- ast_hangup(chan);
- chan = NULL;
break;
}
/* If done, break out */
@@ -1516,8 +1514,7 @@ struct ast_channel *ast_request_and_dial(char *type, int format, void *data, int
f = ast_read(chan);
if (!f) {
state = AST_CONTROL_HANGUP;
- ast_hangup(chan);
- chan = NULL;
+ res = 0;
break;
}
if (f->frametype == AST_FRAME_CONTROL) {
@@ -1537,17 +1534,36 @@ struct ast_channel *ast_request_and_dial(char *type, int format, void *data, int
}
ast_frfree(f);
}
- } else {
- ast_hangup(chan);
- chan = NULL;
+ } else
ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, (char *)data);
- }
} else
ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, (char *)data);
if (chan && (chan->_state == AST_STATE_UP))
state = AST_CONTROL_ANSWER;
if (outstate)
*outstate = state;
+ if (chan && res <= 0) {
+ if (!chan->cdr) {
+ chan->cdr = ast_cdr_alloc();
+ if (chan->cdr)
+ ast_cdr_init(chan->cdr, chan);
+ }
+ if (chan->cdr) {
+ char tmp[256];
+ sprintf(tmp, "%s/%s",type,(char *)data);
+ ast_cdr_setapp(chan->cdr,"Dial",tmp);
+ ast_cdr_update(chan);
+ ast_cdr_start(chan->cdr);
+ ast_cdr_end(chan->cdr);
+ /* If the cause wasn't handled properly */
+ if (ast_cdr_disposition(chan->cdr,chan->hangupcause))
+ ast_cdr_failed(chan->cdr);
+ ast_cdr_reset(chan->cdr,1);
+ } else
+ ast_log(LOG_WARNING, "Unable to create Call Detail Record\n");
+ ast_hangup(chan);
+ chan = NULL;
+ }
return chan;
}
@@ -2431,4 +2447,3 @@ int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, i
return 0;
}
-