From b37e5f8a603d513056da697e08a9976206fd843b Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 20 Jun 2010 10:41:47 +0200 Subject: [PATCH] [BSC] mISDN: Avoid sending RSL messages to wrong channel number In some cases, we get a DL_INFORMATION_IND with a wrong channel number, and only in the DL_ESTABLISH_IND we will see the real channel number that is to be used for this (TEI, SAPI) tuple. --- openbsc/src/input/misdn.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/openbsc/src/input/misdn.c b/openbsc/src/input/misdn.c index 83b01f2ca..fa8aca02c 100644 --- a/openbsc/src/input/misdn.c +++ b/openbsc/src/input/misdn.c @@ -141,7 +141,18 @@ static int handle_ts1_read(struct bsc_fd *bfd) break; case DL_ESTABLISH_IND: DEBUGP(DMI, "DL_ESTABLISH_IND: channel(%d) sapi(%d) tei(%d)\n", - l2addr.channel, l2addr.sapi, l2addr.tei); + l2addr.channel, l2addr.sapi, l2addr.tei); + /* For some strange reason, sometimes the DL_INFORMATION_IND tells + * us the wrong channel, and we only get the real channel number + * during the DL_ESTABLISH_IND */ + link = e1inp_lookup_sign_link(e1i_ts, l2addr.tei, l2addr.sapi); + if (!link) { + DEBUGPC(DMI, "mISDN message for unknown sign_link\n"); + msgb_free(msg); + return -EINVAL; + } + /* save the channel number in the driver private struct */ + link->driver.misdn.channel = l2addr.channel; ret = e1inp_event(e1i_ts, EVT_E1_TEI_UP, l2addr.tei, l2addr.sapi); break; case DL_RELEASE_IND: @@ -217,7 +228,8 @@ static int handle_ts1_write(struct bsc_fd *bfd) hh = (struct mISDNhead *) msgb_push(msg, sizeof(*hh)); hh->prim = DL_DATA_REQ; - DEBUGP(DMI, "TX TEI(%d) SAPI(%d): %s\n", sign_link->tei, + DEBUGP(DMI, "TX channel(%d) TEI(%d) SAPI(%d): %s\n", + sign_link->driver.misdn.channel, sign_link->tei, sign_link->sapi, hexdump(l2_data, msg->len - MISDN_HEADER_LEN)); /* construct the sockaddr */