aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2013-06-12 09:25:27 +0200
committerHarald Welte <laforge@gnumonks.org>2013-07-06 23:36:15 +0200
commitccc463355d752034db9d380d590d3acc220cf79e (patch)
treeec6efd8beef466ee547e8fabe07b60e7a0355bcb
parent610517c8bd5f9e87729acdb4529c0870b0b5dced (diff)
LAPDm: Fix re-establishment of datalink
If the datalink fails or if handover or assignment to a new channel fails, it is re-establised by sending SABM again. The length of establish message is 0 in this case. The length is used to differentiate between re-establishment and contention resolution, which has to be handled differently. See TS 04.06 Chapter 5.4.2.1
-rw-r--r--src/gsm/lapd_core.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/gsm/lapd_core.c b/src/gsm/lapd_core.c
index 116e3116..68b5e784 100644
--- a/src/gsm/lapd_core.c
+++ b/src/gsm/lapd_core.c
@@ -826,14 +826,23 @@ static int lapd_rx_u(struct msgb *msg, struct lapd_msg_ctx *lctx)
* yet received UA or another mobile (collision) tries
* to establish connection. The mobile must receive
* UA again. */
- if (!dl->cont_res && dl->v_send != dl->v_recv) {
- LOGP(DLLAPD, LOGL_INFO, "Remote reestablish\n");
- mdl_error(MDL_CAUSE_SABM_MF, lctx);
+ /* 5.4.2.1 */
+ if (!length) {
+ /* If no content resolution, this is a
+ * re-establishment. */
+ LOGP(DLLAPD, LOGL_INFO,
+ "Remote reestablish\n");
break;
}
+ if (!dl->cont_res) {
+ LOGP(DLLAPD, LOGL_INFO, "SABM command not "
+ "allowed in this state\n");
+ mdl_error(MDL_CAUSE_SABM_MF, lctx);
+ msgb_free(msg);
+ return 0;
+ }
/* Ignore SABM if content differs from first SABM. */
- if (dl->mode == LAPD_MODE_NETWORK && length
- && dl->cont_res) {
+ if (dl->mode == LAPD_MODE_NETWORK && length) {
#ifdef TEST_CONTENT_RESOLUTION_NETWORK
dl->cont_res->data[0] ^= 0x01;
#endif