From ccc463355d752034db9d380d590d3acc220cf79e Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Wed, 12 Jun 2013 09:25:27 +0200 Subject: 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 --- src/gsm/lapd_core.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src') 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 -- cgit v1.2.3