diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index b5888085322e00def9c501979ff505636f8aea99..1a334411a9f541b473f3ab6b84422a7041bcea62 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -1458,6 +1458,16 @@ int ast_channel_whisper_feed(struct ast_channel *chan, struct ast_frame *f); */ void ast_channel_whisper_stop(struct ast_channel *chan); + + +/*! + \brief return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument + \param reason The integer argument, usually taken from AST_CONTROL_ macros + \return char pointer explaining the code + */ +char *ast_channel_reason2str(int reason); + + #if defined(__cplusplus) || defined(c_plusplus) } #endif diff --git a/main/channel.c b/main/channel.c index 26f9da5f78987f131f666bb8ecf7f2525fe8726b..cd2202fd42c66aeb6e42f02e8553276eb71f88e7 100644 --- a/main/channel.c +++ b/main/channel.c @@ -2919,6 +2919,29 @@ int ast_set_write_format(struct ast_channel *chan, int fmt) &chan->writetrans, 1); } +char *ast_channel_reason2str(int reason) +{ + switch (reason) /* the following appear to be the only ones actually returned by request_and_dial */ + { + case 0: + return "Call Failure (not BUSY, and not NO_ANSWER, maybe Circuit busy or down?)"; + case AST_CONTROL_HANGUP: + return "Hangup"; + case AST_CONTROL_RING: + return "Local Ring"; + case AST_CONTROL_RINGING: + return "Remote end Ringing"; + case AST_CONTROL_ANSWER: + return "Remote end has Answered"; + case AST_CONTROL_BUSY: + return "Remote end is Busy"; + case AST_CONTROL_CONGESTION: + return "Congestion (circuits busy)"; + default: + return "Unknown Reason!!"; + } +} + struct ast_channel *__ast_request_and_dial(const char *type, int format, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh) { int dummy_outstate; diff --git a/pbx/pbx_spool.c b/pbx/pbx_spool.c index 6a037fdb86ba2fe919300c7a08df4ecdd21f3338..d90967b7c3022c5dc629c66126d224d6420111f6 100644 --- a/pbx/pbx_spool.c +++ b/pbx/pbx_spool.c @@ -336,7 +336,7 @@ static void *attempt_thread(void *data) res = ast_pbx_outgoing_exten(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->context, o->exten, o->priority, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL); } if (res) { - ast_log(LOG_NOTICE, "Call failed to go through, reason %d\n", reason); + ast_log(LOG_NOTICE, "Call failed to go through, reason (%d) %s\n", reason, ast_channel_reason2str(reason)); if (o->retries >= o->maxretries + 1) { /* Max retries exceeded */ ast_log(LOG_EVENT, "Queued call to %s/%s expired without completion after %d attempt%s\n", o->tech, o->dest, o->retries - 1, ((o->retries - 1) != 1) ? "s" : "");