bsc_api: Switch gsm_04_08.c to use the clear request of the API.
diff --git a/openbsc/include/openbsc/gsm_04_08.h b/openbsc/include/openbsc/gsm_04_08.h
index 142e245..cea377b 100644
--- a/openbsc/include/openbsc/gsm_04_08.h
+++ b/openbsc/include/openbsc/gsm_04_08.h
@@ -11,6 +11,7 @@
 struct gsm_subscriber;
 struct gsm_network;
 struct gsm_trans;
+struct gsm_subscriber_connection;
 
 #define GSM48_ALLOC_SIZE	1024
 #define GSM48_ALLOC_HEADROOM	128
@@ -23,6 +24,7 @@
 
 /* config options controlling the behaviour of the lower leves */
 void gsm0408_allow_everyone(int allow);
+void gsm0408_clear_request(struct gsm_subscriber_connection *conn, uint32_t cause);
 
 int gsm0408_rcvmsg(struct msgb *msg, u_int8_t link_id);
 enum gsm_chan_t get_ctype_by_chreq(struct gsm_bts *bts, u_int8_t ra, int neci);
diff --git a/openbsc/src/gsm_04_08.c b/openbsc/src/gsm_04_08.c
index 2ce2d15..4cc8667 100644
--- a/openbsc/src/gsm_04_08.c
+++ b/openbsc/src/gsm_04_08.c
@@ -253,35 +253,24 @@
 	return 0;
 }
 
-static int gsm0408_handle_lchan_signal(unsigned int subsys, unsigned int signal,
-					void *handler_data, void *signal_data)
+void gsm0408_clear_request(struct gsm_subscriber_connection* conn, uint32_t cause)
 {
 	struct gsm_trans *trans, *temp;
-
-	if (subsys != SS_LCHAN || signal != S_LCHAN_UNEXPECTED_RELEASE)
-		return 0;
-
 	/*
 	 * Cancel any outstanding location updating request
-	 * operation taking place on the lchan.
+	 * operation taking place on the subscriber connection.
 	 */
-	struct gsm_lchan *lchan = (struct gsm_lchan *)signal_data;
-	if (!lchan)
-		return 0;
-
-	release_loc_updating_req(&lchan->conn);
-	release_security_operation(&lchan->conn);
+	release_loc_updating_req(conn);
+	release_security_operation(conn);
 
 	/* Free all transactions that are associated with the released lchan */
 	/* FIXME: this is not neccessarily the right thing to do, we should
 	 * only set trans->lchan to NULL and wait for another lchan to be
 	 * established to the same MM entity (phone/subscriber) */
-	llist_for_each_entry_safe(trans, temp, &lchan->ts->trx->bts->network->trans_list, entry) {
-		if (trans->conn && trans->conn->lchan == lchan)
+	llist_for_each_entry_safe(trans, temp, &conn->bts->network->trans_list, entry) {
+		if (trans->conn == conn)
 			trans_free(trans);
 	}
-
-	return 0;
 }
 
 /* Chapter 9.2.14 : Send LOCATION UPDATING REJECT */
@@ -3129,6 +3118,5 @@
  */
 static __attribute__((constructor)) void on_dso_load_0408(void)
 {
-	register_signal_handler(SS_LCHAN, gsm0408_handle_lchan_signal, NULL);
 	register_signal_handler(SS_ABISIP, handle_abisip_signal, NULL);
 }
diff --git a/openbsc/src/osmo_msc.c b/openbsc/src/osmo_msc.c
index b5bb371..b647a81 100644
--- a/openbsc/src/osmo_msc.c
+++ b/openbsc/src/osmo_msc.c
@@ -35,8 +35,14 @@
 		gsm411_sapi_n_reject(conn);
 }
 
+static void msc_clear_request(struct gsm_subscriber_connection* conn, uint32_t cause)
+{
+	gsm0408_clear_request(conn, cause);
+}
+
 static struct bsc_api msc_handler = {
 	.sapi_n_reject = msc_sapi_n_reject,
+	.clear_request = msc_clear_request,
 };
 
 struct bsc_api *msc_bsc_api() {