bsc: Unregister old RSL channel number after assignment

Change-Id: I27d113391094f938ff92c4d6514172ee634f695c
diff --git a/library/RSL_Emulation.ttcn b/library/RSL_Emulation.ttcn
index cbcff2c..d20718f 100644
--- a/library/RSL_Emulation.ttcn
+++ b/library/RSL_Emulation.ttcn
@@ -50,9 +50,10 @@
 } with { extension "internal" };
 
 signature RSLEM_register(uint8_t trx_nr, RslChannelNr chan_nr, RSL_DchanHdlr hdlr);
+signature RSLEM_unregister(uint8_t trx_nr, RslChannelNr chan_nr, RSL_DchanHdlr hdlr);
 
 type port RSLEM_PROC_PT procedure {
-	inout RSLEM_register;
+	inout RSLEM_register, RSLEM_unregister;
 } with { extension "internal" };
 
 /***********************************************************************
@@ -379,6 +380,13 @@
 			RSL_PROC.reply(RSLEM_register:{trx_nr, chan_nr, vc_conn});
 			}
 
+		[] RSL_PROC.getcall(RSLEM_unregister:{?,?,?}) -> param(trx_nr, chan_nr, vc_conn) {
+			cid := f_cid_by_chan_nr(trx_nr, chan_nr);
+			f_cid_clear(cid);
+			RSL_PROC.reply(RSLEM_unregister:{trx_nr, chan_nr, vc_conn});
+			}
+
+
 		}
 	}
 }
@@ -400,4 +408,12 @@
 	}
 }
 
+/* client/conn_hdlr side function to use procedure port to unregister stream_id/chan_nr */
+function f_rslem_unregister(uint8_t trx_nr, RslChannelNr chan_nr) runs on RSL_DchanHdlr {
+	RSL_PROC.call(RSLEM_unregister:{trx_nr, chan_nr, self}) {
+		[] RSL_PROC.getreply(RSLEM_unregister:{?,?,?}) {};
+	}
+}
+
+
 }