From 0094f84f305bcdbe29478170109639de9737f088 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 28 Jan 2010 05:10:57 +0100 Subject: [bssap] Use switch/case for the signal handler Use switch/case, switch/case for the subsys and signal to prepare to handle more signals in the future. --- openbsc/src/bssap.c | 56 ++++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) (limited to 'openbsc') diff --git a/openbsc/src/bssap.c b/openbsc/src/bssap.c index c5ad80fb1..a6a111e01 100644 --- a/openbsc/src/bssap.c +++ b/openbsc/src/bssap.c @@ -940,41 +940,45 @@ static int bssap_handle_lchan_signal(unsigned int subsys, unsigned int signal, struct gsm_lchan *lchan; struct sccp_connection *conn; - if (subsys != SS_LCHAN || signal != S_LCHAN_UNEXPECTED_RELEASE) - return 0; - /* * If we have a SCCP Connection we need to inform the MSC about * the resource error and then drop the lchan<->sccp association. */ - lchan = (struct gsm_lchan *)signal_data; + switch (subsys) { + case SS_LCHAN: + lchan = (struct gsm_lchan *)signal_data; + + if (!lchan || !lchan->msc_data) + return 0; + switch (signal) { + case S_LCHAN_UNEXPECTED_RELEASE: + bsc_del_timer(&lchan->msc_data->T10); + conn = lchan->msc_data->sccp; + lchan->msc_data->lchan = NULL; + lchan->msc_data = NULL; + + msg = msgb_alloc(30, "sccp: clear request"); + if (!msg) { + DEBUGP(DMSC, "Failed to allocate clear request.\n"); + return 0; + } - if (!lchan || !lchan->msc_data) - return 0; + msg->l3h = msgb_put(msg, 2 + 4); + msg->l3h[0] = BSSAP_MSG_BSS_MANAGEMENT; + msg->l3h[1] = 4; - bsc_del_timer(&lchan->msc_data->T10); - conn = lchan->msc_data->sccp; - lchan->msc_data->lchan = NULL; - lchan->msc_data = NULL; + msg->l3h[2] = BSS_MAP_MSG_CLEAR_RQST; + msg->l3h[3] = GSM0808_IE_CAUSE; + msg->l3h[4] = 1; + msg->l3h[5] = GSM0808_CAUSE_RADIO_INTERFACE_FAILURE; - msg = msgb_alloc(30, "sccp: clear request"); - if (!msg) { - DEBUGP(DMSC, "Failed to allocate clear request.\n"); - return 0; + DEBUGP(DMSC, "Sending clear request on unexpected channel release.\n"); + bsc_queue_connection_write(conn, msg); + break; + } + break; } - msg->l3h = msgb_put(msg, 2 + 4); - msg->l3h[0] = BSSAP_MSG_BSS_MANAGEMENT; - msg->l3h[1] = 4; - - msg->l3h[2] = BSS_MAP_MSG_CLEAR_RQST; - msg->l3h[3] = GSM0808_IE_CAUSE; - msg->l3h[4] = 1; - msg->l3h[5] = GSM0808_CAUSE_RADIO_INTERFACE_FAILURE; - - DEBUGP(DMSC, "Sending clear request on unexpected channel release.\n"); - bsc_queue_connection_write(conn, msg); - return 0; } -- cgit v1.2.3