
GSM 04.08 7.1.7 / 9.1.7		RR CHANNEL RELESE

RSL 08.58 3.4 / ?		RLL Link Release Request

RSL 08.58 4.6 / 8.4.5		DEACTivate SACCH
	* Deactivate SACCH according to Channel Release Proc 04.08
	* to be sent after RR CHANNEL RELEASE is sent to MS

RSL 08.58 4.7 / 8.4.14		RF CHANnel RELease
	* tells the BTS to release a radio channel
	* "when an activated radio channel is no longer needed"
	* BTS responds with RF CHANnel RELease ACKnowledge


GSM 04.08 3.4.13: RR connection release procedure

* network sends RR CHANNEL RELEASE to MS on the DCCH
  * start T3109
  * deactivate SACCH
* MS disconnects main signalling link (by sending DISC)
  * all other data links are disconnected by local end link release
* network receives DISC (BTS sends RLL REL IND to BSC)
  * stop T3109
  * start T3111 
* when T3111 times out, the network can reuse the channls
* if T3109 times out, the network deactivates the channels 
  and can reuse them
  * this probably means simply RF CHANnel RELease


== Implementation in OpenBSC ==

There are two possible reasons a gsm_subscriber_connection
will be released. One is a network failure, the other is
the completion of an operation/transaction.

=== Failure ===
The BSC API will call the gsm_04_08.c:gsm0408_clear_request callback
and the MSC part will release all transactions, operations and such
and the channels will be released as error case.

=== Success ===
Every time an 'operation' or 'transaction' is finished msc_release_connection
will be called and it will determine if the gsm_subscriber_connection can
be released.

In case it can be released bsc_api.c:gsm0808_clear will be called
which will release all lchan's associated with the connection. For the
primary channel a SACH Deactivate will be send with the release
reason NORMAL RELEASE.


bsc_api.c:gsm0808_clear
	* Release a channel used for handover
	* Release the primary lchan with normal release, SACH deactivate

chan_alloc.c:lchan_release(chan, sacch_deactivate, reason)
	* Start the release procedure. It is working in steps with callbacks
	  coming from the abis_rsl.c code.
	* Release all SAPI's > 0 as local end (The BTS should send a
	  REL_CONF a message)
	* Send SACH Deactivate on SAPI=0 if required.
	* Start T3109 (stop it when the main signalling link is disconnected)
	  or when the channel released. On timeout start the error handling.
	* abis_rsl.c schedules the RSL_MT_RF_CHAN_REL once all SAPI's are
	  released and after T3111 has timed out or there is an error.

RX of RELease INDication:
        * Calls internal rsl_handle_release which might release the RF.

RX of RELease CONFirmation:
        * Calls internal rsl_handle_release which might release the RF.

* RX of RF_CHAN_REL_ACK
	* call lchan_free()


=== Integration with SMS ===

* RX of CP_ERROR or unimplemented MT
	* trigger trans_free() which will msc_release_connection()

* CP TC1* expired while waiting for CP-ACK
	* trigger trans_free() which will msc_release_connection()

* RX of RP_ERROR
	* trigger trans_free() which will msc_release_connection()
	
* TX of CP-ACK in MT DELIVER
	* trigger trans_free() which will msc_release_connection()

* RX of CP-ACK in MO SUBMIT
	* trigger trans_free() which will msc_release_connection()
	
