From: Matthew Jordan Date: Fri, 9 Sep 2011 16:09:09 +0000 (+0000) Subject: Updated SIP 484 handling; added Incomplete control frame X-Git-Tag: 1.8.8.0-rc1~83 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7dc49195d81a17096d8dc469a04142a2eb9a56bd;p=thirdparty%2Fasterisk.git Updated SIP 484 handling; added Incomplete control frame When a SIP phone uses the dial application and receives a 484 Address Incomplete response, if overlapped dialing is enabled for SIP, then the 484 Address Incomplete is forwarded back to the SIP phone and the HANGUPCAUSE channel variable is set to 28. Previously, the Incomplete application dialplan logic was automatically triggered; now, explicit dialplan usage of the application is required. Additionally, this patch adds a new AST_CONTOL_FRAME type called AST_CONTROL_INCOMPLETE. If a channel driver receives this control frame, it is an indication that the dialplan expects more digits back from the device. If the device supports overlap dialing it should attempt to notify the device that the dialplan is waiting for more digits; otherwise, it can handle the frame in a manner appropriate to the channel driver. (closes issue ASTERISK-17288) Reported by: Mikael Carlsson Tested by: Matthew Jordan Review: https://reviewboard.asterisk.org/r/1416/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@335064 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/addons/chan_ooh323.c b/addons/chan_ooh323.c index c346776984..830a623202 100644 --- a/addons/chan_ooh323.c +++ b/addons/chan_ooh323.c @@ -1226,21 +1226,24 @@ static int ooh323_indicate(struct ast_channel *ast, int condition, const void *d ast_mutex_lock(&p->lock); switch (condition) { + case AST_CONTROL_INCOMPLETE: + /* While h323 does support overlapped dialing, this channel driver does not + * at this time. Treat a response of Incomplete as if it were congestion. + */ case AST_CONTROL_CONGESTION: if (!ast_test_flag(p, H323_ALREADYGONE)) { - ooHangCall(callToken, OO_REASON_LOCAL_CONGESTED, - AST_CAUSE_SWITCH_CONGESTION); + ooHangCall(callToken, OO_REASON_LOCAL_CONGESTED, AST_CAUSE_SWITCH_CONGESTION); ast_set_flag(p, H323_ALREADYGONE); } break; case AST_CONTROL_BUSY: if (!ast_test_flag(p, H323_ALREADYGONE)) { - ooHangCall(callToken, OO_REASON_LOCAL_BUSY, AST_CAUSE_USER_BUSY); + ooHangCall(callToken, OO_REASON_LOCAL_BUSY, AST_CAUSE_USER_BUSY); ast_set_flag(p, H323_ALREADYGONE); } break; case AST_CONTROL_HOLD: - ast_moh_start(ast, data, NULL); + ast_moh_start(ast, data, NULL); break; case AST_CONTROL_UNHOLD: ast_moh_stop(ast); diff --git a/apps/app_dial.c b/apps/app_dial.c index 515fa1b3f6..c92dec2639 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -2423,14 +2423,6 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast } else { /* Nobody answered, next please? */ res = 0; } - - /* SIP, in particular, sends back this error code to indicate an - * overlap dialled number needs more digits. */ - if (chan->hangupcause == AST_CAUSE_INVALID_NUMBER_FORMAT) { - res = AST_PBX_INCOMPLETE; - } - - /* almost done, although the 'else' block is 400 lines */ } else { const char *number; diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c index 36745326da..5014da5ab7 100644 --- a/channels/chan_alsa.c +++ b/channels/chan_alsa.c @@ -537,6 +537,7 @@ static int alsa_indicate(struct ast_channel *chan, int cond, const void *data, s case AST_CONTROL_BUSY: case AST_CONTROL_CONGESTION: case AST_CONTROL_RINGING: + case AST_CONTROL_INCOMPLETE: case -1: res = -1; /* Ask for inband indications */ break; diff --git a/channels/chan_console.c b/channels/chan_console.c index 269ccaff18..1217392eab 100644 --- a/channels/chan_console.c +++ b/channels/chan_console.c @@ -610,6 +610,7 @@ static int console_indicate(struct ast_channel *chan, int cond, const void *data case AST_CONTROL_BUSY: case AST_CONTROL_CONGESTION: case AST_CONTROL_RINGING: + case AST_CONTROL_INCOMPLETE: case -1: res = -1; /* Ask for inband indications */ break; diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index 909ff92b21..3bacfb14a3 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -9315,13 +9315,18 @@ static int dahdi_indicate(struct ast_channel *chan, int condition, const void *d ast_setstate(chan, AST_STATE_RINGING); } break; + case AST_CONTROL_INCOMPLETE: + ast_debug(1, "Received AST_CONTROL_INCOMPLETE on %s\n", chan->name); + /* act as a progress or proceeding, allowing the caller to enter additional numbers */ + res = 0; + break; case AST_CONTROL_PROCEEDING: - ast_debug(1,"Received AST_CONTROL_PROCEEDING on %s\n",chan->name); + ast_debug(1, "Received AST_CONTROL_PROCEEDING on %s\n", chan->name); /* don't continue in ast_indicate */ res = 0; break; case AST_CONTROL_PROGRESS: - ast_debug(1,"Received AST_CONTROL_PROGRESS on %s\n",chan->name); + ast_debug(1, "Received AST_CONTROL_PROGRESS on %s\n", chan->name); /* don't continue in ast_indicate */ res = 0; break; diff --git a/channels/chan_h323.c b/channels/chan_h323.c index 0d2a9ee86b..fbca7e8209 100644 --- a/channels/chan_h323.c +++ b/channels/chan_h323.c @@ -900,6 +900,10 @@ static int oh323_indicate(struct ast_channel *c, int condition, const void *data res = 0; } break; + case AST_CONTROL_INCOMPLETE: + /* While h323 does support overlapped dialing, this channel driver does not + * at this time. Treat a response of Incomplete as if it were congestion. + */ case AST_CONTROL_CONGESTION: if (c->_state != AST_STATE_UP) { h323_answering_call(token, 1); diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index aa98d9c10a..49f1867460 100644 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -1457,6 +1457,10 @@ static int mgcp_indicate(struct ast_channel *ast, int ind, const void *data, siz case AST_CONTROL_BUSY: transmit_notify_request(sub, "L/bz"); break; + case AST_CONTROL_INCOMPLETE: + /* We do not currently support resetting of the Interdigit Timer, so treat + * Incomplete control frames as a congestion response + */ case AST_CONTROL_CONGESTION: transmit_notify_request(sub, sub->parent->ncs ? "L/cg" : "G/cg"); break; diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c index 76b250d814..37c4d08f33 100644 --- a/channels/chan_misdn.c +++ b/channels/chan_misdn.c @@ -6983,6 +6983,19 @@ static int misdn_indication(struct ast_channel *ast, int cond, const void *data, chan_misdn_log(1, p->bc->port, " --> * IND :\tproceeding pid:%d\n", p->bc->pid); misdn_lib_send_event(p->bc, EVENT_PROCEEDING); break; + case AST_CONTROL_INCOMPLETE: + chan_misdn_log(1, p->bc->port, " --> *\tincomplete pid:%d\n", p->bc->pid); + if (!p->overlap_dial) { + /* Overlapped dialing not enabled - send hangup */ + p->bc->out_cause = AST_CAUSE_INVALID_NUMBER_FORMAT; + start_bc_tones(p); + misdn_lib_send_event(p->bc, EVENT_DISCONNECT); + + if (p->bc->nt) { + hanguptone_indicate(p); + } + } + break; case AST_CONTROL_CONGESTION: chan_misdn_log(1, p->bc->port, " --> * IND :\tcongestion pid:%d\n", p->bc->pid); diff --git a/channels/chan_oss.c b/channels/chan_oss.c index 01f579d20c..df25ceed8d 100644 --- a/channels/chan_oss.c +++ b/channels/chan_oss.c @@ -755,6 +755,7 @@ static int oss_indicate(struct ast_channel *c, int cond, const void *data, size_ int res = 0; switch (cond) { + case AST_CONTROL_INCOMPLETE: case AST_CONTROL_BUSY: case AST_CONTROL_CONGESTION: case AST_CONTROL_RINGING: diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 3f0c46f8f4..433f3f4291 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -6677,6 +6677,20 @@ static int sip_indicate(struct ast_channel *ast, int condition, const void *data } res = -1; break; + case AST_CONTROL_INCOMPLETE: + if (ast->_state != AST_STATE_UP) { + if (ast_test_flag(&p->flags[1], SIP_PAGE2_ALLOWOVERLAP)) { + transmit_response_reliable(p, "484 Address Incomplete", &p->initreq); + } else { + transmit_response_reliable(p, "404 Not Found", &p->initreq); + } + p->invitestate = INV_COMPLETED; + sip_alreadygone(p); + ast_softhangup_nolock(ast, AST_SOFTHANGUP_DEV); + break; + } + res = 0; + break; case AST_CONTROL_PROCEEDING: if ((ast->_state != AST_STATE_UP) && !ast_test_flag(&p->flags[0], SIP_PROGRESS_SENT) && @@ -20619,6 +20633,15 @@ static void handle_response(struct sip_pvt *p, int resp, const char *rest, struc if (owner) ast_queue_control(p->owner, AST_CONTROL_CONGESTION); break; + case 484: /* Address Incomplete */ + if (owner && sipmethod != SIP_BYE) { + if (ast_test_flag(&p->flags[1], SIP_PAGE2_ALLOWOVERLAP)) { + ast_queue_hangup_with_cause(p->owner, hangup_sip2cause(resp)); + } else { + ast_queue_hangup_with_cause(p->owner, hangup_sip2cause(404)); + } + } + break; default: /* Send hangup */ if (owner && sipmethod != SIP_BYE) diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 799b578cba..77435065f3 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -4290,6 +4290,8 @@ static char *control2str(int ind) { return "Connected Line"; case AST_CONTROL_REDIRECTING: return "Redirecting"; + case AST_CONTROL_INCOMPLETE: + return "Incomplete"; case -1: return "Stop tone"; default: @@ -4423,6 +4425,8 @@ static int skinny_indicate(struct ast_channel *ast, int ind, const void *data, s } } return -1; /* Tell asterisk to provide inband signalling */ + case AST_CONTROL_INCOMPLETE: + /* Support for incomplete not supported for chan_skinny; treat as congestion */ case AST_CONTROL_CONGESTION: if (ast->_state != AST_STATE_UP) { if (!d->earlyrtp) { diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c index eac458f017..0d48ee43eb 100644 --- a/channels/chan_unistim.c +++ b/channels/chan_unistim.c @@ -4182,6 +4182,10 @@ static int unistim_indicate(struct ast_channel *ast, int ind, const void *data, break; } return -1; + case AST_CONTROL_INCOMPLETE: + /* Overlapped dialing is not currently supported for UNIStim. Treat an indication + * of incomplete as congestion + */ case AST_CONTROL_CONGESTION: if (ast->_state != AST_STATE_UP) { sub->alreadygone = 1; diff --git a/channels/chan_usbradio.c b/channels/chan_usbradio.c index 4c97937441..e7a009d5c2 100644 --- a/channels/chan_usbradio.c +++ b/channels/chan_usbradio.c @@ -2119,7 +2119,9 @@ static int usbradio_indicate(struct ast_channel *c, int cond, const void *data, case AST_CONTROL_RINGING: res = cond; break; - + case AST_CONTROL_INCOMPLETE: + res = AST_CONTROL_CONGESTION; + break; case -1: #ifndef NEW_ASTERISK o->cursound = -1; diff --git a/channels/sig_pri.c b/channels/sig_pri.c index dfdb16b5d0..46aea538c4 100644 --- a/channels/sig_pri.c +++ b/channels/sig_pri.c @@ -6922,6 +6922,15 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi /* don't continue in ast_indicate */ res = 0; break; + case AST_CONTROL_INCOMPLETE: + /* If we are connected or if we support overlap dialing, wait for additional digits */ + if (p->call_level == SIG_PRI_CALL_LEVEL_CONNECT || (p->pri->overlapdial & DAHDI_OVERLAPDIAL_INCOMING)) { + res = 0; + break; + } + /* Otherwise, treat as congestion */ + chan->hangupcause = AST_CAUSE_INVALID_NUMBER_FORMAT; + /* Falls through */ case AST_CONTROL_CONGESTION: if (p->priindication_oob || p->no_b_channel) { /* There are many cause codes that generate an AST_CONTROL_CONGESTION. */ diff --git a/channels/sig_ss7.c b/channels/sig_ss7.c index 3677213665..e484d5603b 100644 --- a/channels/sig_ss7.c +++ b/channels/sig_ss7.c @@ -1559,6 +1559,14 @@ int sig_ss7_indicate(struct sig_ss7_chan *p, struct ast_channel *chan, int condi /* don't continue in ast_indicate */ res = 0; break; + case AST_CONTROL_INCOMPLETE: + /* If the channel is connected, wait for additional input */ + if (p->call_level == SIG_SS7_CALL_LEVEL_CONNECT) { + res = 0; + break; + } + chan->hangupcause = AST_CAUSE_INVALID_NUMBER_FORMAT; + break; case AST_CONTROL_CONGESTION: chan->hangupcause = AST_CAUSE_CONGESTION; break; diff --git a/funcs/func_frame_trace.c b/funcs/func_frame_trace.c index e0441011a2..1b56bab995 100644 --- a/funcs/func_frame_trace.c +++ b/funcs/func_frame_trace.c @@ -312,6 +312,9 @@ static void print_frame(struct ast_frame *frame) case AST_CONTROL_AOC: ast_verbose("SubClass: AOC\n"); break; + case AST_CONTROL_INCOMPLETE: + ast_verbose("SubClass: INCOMPLETE\n"); + break; } if (frame->subclass.integer == -1) { ast_verbose("SubClass: %d\n", frame->subclass.integer); diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h index 15ffdb8561..dbd217652f 100644 --- a/include/asterisk/frame.h +++ b/include/asterisk/frame.h @@ -334,6 +334,7 @@ enum ast_control_frame_type { AST_CONTROL_READ_ACTION = 27, /*!< Tell ast_read to take a specific action */ AST_CONTROL_AOC = 28, /*!< Advice of Charge with encoded generic AOC payload */ AST_CONTROL_END_OF_Q = 29, /*!< Indicate that this position was the end of the channel queue for a softhangup. */ + AST_CONTROL_INCOMPLETE = 30, /*!< Indication that the extension dialed is incomplete */ }; enum ast_frame_read_action { diff --git a/main/channel.c b/main/channel.c index afc16257e0..439887949c 100644 --- a/main/channel.c +++ b/main/channel.c @@ -4293,6 +4293,7 @@ static int attribute_const is_visible_indication(enum ast_control_frame_type con case AST_CONTROL_END_OF_Q: break; + case AST_CONTROL_INCOMPLETE: case AST_CONTROL_CONGESTION: case AST_CONTROL_BUSY: case AST_CONTROL_RINGING: @@ -4449,6 +4450,7 @@ int ast_indicate_data(struct ast_channel *chan, int _condition, case AST_CONTROL_BUSY: ts = ast_get_indication_tone(chan->zone, "busy"); break; + case AST_CONTROL_INCOMPLETE: case AST_CONTROL_CONGESTION: ts = ast_get_indication_tone(chan->zone, "congestion"); break; @@ -5346,6 +5348,12 @@ struct ast_channel *__ast_request_and_dial(const char *type, format_t format, co timeout = 0; break; + case AST_CONTROL_INCOMPLETE: + ast_cdr_failed(chan->cdr); + *outstate = AST_CONTROL_CONGESTION; + timeout = 0; + break; + case AST_CONTROL_CONGESTION: ast_cdr_failed(chan->cdr); *outstate = f->subclass.integer; diff --git a/main/dial.c b/main/dial.c index ba1a2bb53c..ab1ebf748e 100644 --- a/main/dial.c +++ b/main/dial.c @@ -398,6 +398,10 @@ static void handle_frame(struct ast_dial *dial, struct ast_dial_channel *channel ast_hangup(channel->owner); channel->owner = NULL; break; + case AST_CONTROL_INCOMPLETE: + ast_verb(3, "%s dialed Incomplete extension %s\n", channel->owner->name, channel->owner->exten); + ast_indicate(chan, AST_CONTROL_INCOMPLETE); + break; case AST_CONTROL_RINGING: ast_verb(3, "%s is ringing\n", channel->owner->name); if (!dial->options[AST_DIAL_OPTION_MUSIC]) diff --git a/main/features.c b/main/features.c index a8f4a4142b..4f2399995e 100644 --- a/main/features.c +++ b/main/features.c @@ -3411,6 +3411,8 @@ static struct ast_channel *feature_request_and_dial(struct ast_channel *caller, ast_indicate(caller, AST_CONTROL_BUSY); ast_frfree(f); break; + } else if (f->subclass.integer == AST_CONTROL_INCOMPLETE) { + ast_verb(3, "%s dialed incomplete extension %s; ignoring\n", chan->name, chan->exten); } else if (f->subclass.integer == AST_CONTROL_CONGESTION) { state = f->subclass.integer; ast_verb(3, "%s is congested\n", chan->name); diff --git a/main/pbx.c b/main/pbx.c index 031db87607..4e52840426 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -9226,6 +9226,8 @@ static int pbx_builtin_incomplete(struct ast_channel *chan, const char *data) __ast_answer(chan, 0, 1); } + ast_indicate(chan, AST_CONTROL_INCOMPLETE); + return AST_PBX_INCOMPLETE; }