From 9037525b7bf256d09161fd4424b627fdad451700 Mon Sep 17 00:00:00 2001 From: Matthew Fredrickson Date: Fri, 21 Jul 2006 15:43:31 +0000 Subject: [PATCH] Improve call state handling code. (#7269) git-svn-id: https://origsvn.digium.com/svn/libpri/trunk@365 2fbb986a-6c06-0410-b554-c9c1f0a7f128 --- q931.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/q931.c b/q931.c index cead4c5..3971c88 100644 --- a/q931.c +++ b/q931.c @@ -2693,18 +2693,17 @@ int q931_connect(struct pri *pri, q931_call *c, int channel, int nonisdn) c->progressmask = PRI_PROG_CALLED_NOT_ISDN; } else c->progressmask = 0; - if (pri->localtype == PRI_CPE) { - UPDATE_OURCALLSTATE(pri, c, Q931_CALL_STATE_CONNECT_REQUEST); - } else { + if(pri->localtype == PRI_NETWORK || pri->switchtype == PRI_SWITCH_QSIG) UPDATE_OURCALLSTATE(pri, c, Q931_CALL_STATE_ACTIVE); - } + else + UPDATE_OURCALLSTATE(pri, c, Q931_CALL_STATE_CONNECT_REQUEST); c->peercallstate = Q931_CALL_STATE_ACTIVE; c->alive = 1; - /* Setup timer */ + /* Connect request timer */ if (c->retranstimer) pri_schedule_del(pri, c->retranstimer); c->retranstimer = 0; - if ((pri->localtype == PRI_CPE) && (!pri->subchannel)) + if ((c->ourcallstate == Q931_CALL_STATE_CONNECT_REQUEST) && (!pri->subchannel)) c->retranstimer = pri_schedule_event(pri, pri->timers[PRI_TIMER_T313], pri_connect_timeout, c); return send_message(pri, c, Q931_CONNECT, connect_ies); } @@ -3422,7 +3421,9 @@ int q931_receive(struct pri *pri, q931_h *h, int len) q931_release_complete(pri,c,PRI_CAUSE_INVALID_CALL_REFERENCE); break; } - if (c->ourcallstate != Q931_CALL_STATE_CONNECT_REQUEST) { + if (!(c->ourcallstate == Q931_CALL_STATE_CONNECT_REQUEST) && + !(c->ourcallstate == Q931_CALL_STATE_ACTIVE && + (pri->localtype == PRI_NETWORK || pri->switchtype == PRI_SWITCH_QSIG))) { q931_status(pri,c,PRI_CAUSE_WRONG_MESSAGE); break; }