From 5fda3d8c68512cf2bdebce3e7cb573eb929eadbd Mon Sep 17 00:00:00 2001 From: Richard Mudgett Date: Mon, 17 Nov 2014 20:07:53 +0000 Subject: [PATCH] q931.c: Send STATUS messages when receiving messages in the wrong call state. * Add checks to send STATUS messages when receiving SETUP ACKNOWLEDGE, ALERTING, and CONNECT ACKNOWLEDGE messages when in the wrong call state. LIBPRI-76 #close Reported by: Richard Mudgett git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2331 2fbb986a-6c06-0410-b554-c9c1f0a7f128 --- q931.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/q931.c b/q931.c index 2cafb38..2c136ed 100644 --- a/q931.c +++ b/q931.c @@ -8696,6 +8696,15 @@ static int post_handle_q931_message(struct pri *ctrl, struct q931_mh *mh, struct q931_release_complete(ctrl, c, newcall_rel_comp_cause(c)); break; } + switch (c->ourcallstate) { + default: + q931_status(ctrl, c, PRI_CAUSE_WRONG_CALL_STATE); + return 0; + case Q931_CALL_STATE_CALL_INITIATED: + case Q931_CALL_STATE_OVERLAP_SENDING: + case Q931_CALL_STATE_OUTGOING_CALL_PROCEEDING: + break; + } UPDATE_OURCALLSTATE(ctrl, c, Q931_CALL_STATE_CALL_DELIVERED); c->peercallstate = Q931_CALL_STATE_CALL_RECEIVED; ctrl->ev.e = PRI_EVENT_RINGING; @@ -8866,11 +8875,8 @@ static int post_handle_q931_message(struct pri *ctrl, struct q931_mh *mh, struct } switch (c->ourcallstate) { default: - if (ctrl->localtype == PRI_NETWORK || ctrl->switchtype == PRI_SWITCH_QSIG) { - q931_status(ctrl, c, PRI_CAUSE_WRONG_MESSAGE); - break; - } - /* Fall through */ + q931_status(ctrl, c, PRI_CAUSE_WRONG_CALL_STATE); + return 0; case Q931_CALL_STATE_CONNECT_REQUEST: case Q931_CALL_STATE_ACTIVE: UPDATE_OURCALLSTATE(ctrl, c, Q931_CALL_STATE_ACTIVE); @@ -9208,6 +9214,13 @@ static int post_handle_q931_message(struct pri *ctrl, struct q931_mh *mh, struct q931_release_complete(ctrl, c, newcall_rel_comp_cause(c)); break; } + switch (c->ourcallstate) { + default: + q931_status(ctrl, c, PRI_CAUSE_WRONG_CALL_STATE); + return 0; + case Q931_CALL_STATE_CALL_INITIATED: + break; + } UPDATE_OURCALLSTATE(ctrl, c, Q931_CALL_STATE_OVERLAP_SENDING); c->peercallstate = Q931_CALL_STATE_OVERLAP_RECEIVING; ctrl->ev.e = PRI_EVENT_SETUP_ACK;