From c9ce523168b3a6a6f6ab6abe58b152a974a6e41d Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Mon, 28 Jan 2008 22:17:34 +0000 Subject: [PATCH] more gracefully handle messagees with unexpected chan id that we don't have allocated. git-svn-id: http://svn.openzap.org/svn/openzap/trunk@376 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/openzap/src/zap_isdn.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/libs/openzap/src/zap_isdn.c b/libs/openzap/src/zap_isdn.c index 5f92cfa4b6..4d10f8c555 100644 --- a/libs/openzap/src/zap_isdn.c +++ b/libs/openzap/src/zap_isdn.c @@ -144,7 +144,11 @@ static L3INT zap_isdn_931_34(void *pvt, L2UCHAR *msg, L2INT mlen) case Q931mes_RELEASE: case Q931mes_RELEASE_COMPLETE: { - zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN); + if (zchan) { + zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN); + } else { + zap_log(ZAP_LOG_CRIT, "Received Release Complete with no matching channel %d\n", chan_id); + } } break; case Q931mes_DISCONNECT: @@ -157,17 +161,29 @@ static L3INT zap_isdn_931_34(void *pvt, L2UCHAR *msg, L2INT mlen) break; case Q931mes_ALERTING: { - zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_PROGRESS_MEDIA); + if (zchan) { + zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_PROGRESS_MEDIA); + } else { + zap_log(ZAP_LOG_CRIT, "Received Alerting with no matching channel %d\n", chan_id); + } } break; case Q931mes_PROGRESS: { - zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_PROGRESS); + if (zchan) { + zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_PROGRESS); + } else { + zap_log(ZAP_LOG_CRIT, "Received Progress with no matching channel %d\n", chan_id); + } } break; case Q931mes_CONNECT: { - zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_UP); + if (zchan) { + zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_UP); + } else { + zap_log(ZAP_LOG_CRIT, "Received Connect with no matching channel %d\n", chan_id); + } } break; case Q931mes_SETUP: