RSL/BSSAP: fix: properly convert between RSL Link ID and DLCI

Data Link Connection Identifier (DLCI) is defined in 3GPP TS 48.006,
section 9.3.2, and coded as follows:

  .... .SSS - SAPI value used on the radio link;
  CC.. .... - control channel identification:
    00.. .... - indicates that the control channel is not further specified,
    10.. .... - represents the FACCH or the SDCCH,
    11.. .... - represents the SACCH,
    other values are reserved.

RSL Link Identifier is defined in 3GPP TS 3GPP TS 48.058,
section 9.3.2, and coded as follows:

  .... .SSS - SAPI value used on the radio link;
  ...P P... - priority for SAPI0 messages;
  CC.. .... - control channel identification:
    00.. .... - main signalling channel (FACCH or SDCCH),
    01.. .... - SACCH,
    other values are reserved.

As can be seen, CC bits in both DLCI and RSL Link Identifier
are coded differently.  Therefore, we cannot just assign
one identifier to another, we need to do conversion.

I noticed that osmo-bsc indicates DLCI '01000011'B for SMS
messages sent over SACCH/F (SAPI3), and this is wrong because
'01'B is reserved.  Let's fix this.

P.S. Interesting coincidence: section 9.3.2 in both documents.

Change-Id: If4d479a54cad467f53b49065c1c435a4471ac7d2
Related: Ica69ae95b47a67ba99ba9cc36629b6bd210d11e4
Related: OS#3716
This commit is contained in:
Vadim Yanitskiy 2020-10-01 21:10:51 +07:00 committed by laforge
parent 1ae1826245
commit a88fa1f12f
2 changed files with 27 additions and 4 deletions

View File

@ -537,6 +537,16 @@ early_exit:
return rc;
}
/* Data Link Connection Identifier (DLCI) is defined in 3GPP TS 48.006, section 9.3.2.
* .... .SSS - SAPI value used on the radio link;
* CC.. .... - control channel identification:
* 00.. .... - indicates that the control channel is not further specified,
* 10.. .... - represents the FACCH or the SDCCH,
* 11.. .... - represents the SACCH,
* other values are reserved. */
#define RSL_LINK_ID2DLCI(link_id) \
(link_id & 0x40 ? 0xc0 : 0x80) | (link_id & 0x07)
/*! MS->BSC/MSC: Um L3 message. */
void bsc_dtap(struct gsm_subscriber_connection *conn, uint8_t link_id, struct msgb *msg)
{
@ -549,8 +559,9 @@ void bsc_dtap(struct gsm_subscriber_connection *conn, uint8_t link_id, struct ms
parse_powercap(conn, msg);
/* Store link_id in msg->cb */
OBSC_LINKID_CB(msg) = link_id;
/* convert RSL link ID to DLCI, store in msg->cb */
OBSC_LINKID_CB(msg) = RSL_LINK_ID2DLCI(link_id);
osmo_fsm_inst_dispatch(conn->fi, GSCON_EV_MO_DTAP, msg);
done:
log_set_context(LOG_CTX_BSC_SUBSCR, NULL);

View File

@ -1186,6 +1186,16 @@ static int bssmap_rcvmsg_dt1(struct gsm_subscriber_connection *conn,
return ret;
}
/* RSL Link Identifier is defined in 3GPP TS 3GPP TS 48.058, section 9.3.2.
* .... .SSS - SAPI value used on the radio link;
* ...P P... - priority for SAPI0 messages;
* CC.. .... - control channel identification:
* 00.. .... - main signalling channel (FACCH or SDCCH),
* 01.. .... - SACCH,
* other values are reserved. */
#define DLCI2RSL_LINK_ID(dlci) \
((dlci & 0xc0) == 0xc0 ? 0x40 : 0x00) | (dlci & 0x07)
static int dtap_rcvmsg(struct gsm_subscriber_connection *conn,
struct msgb *msg, unsigned int length)
{
@ -1235,8 +1245,10 @@ static int dtap_rcvmsg(struct gsm_subscriber_connection *conn,
/* pass it to the filter for extra actions */
bsc_scan_msc_msg(conn, gsm48);
/* Store link_id in msgb->cb */
OBSC_LINKID_CB(gsm48) = header->link_id;
/* convert DLCI to RSL link ID, store in msg->cb */
OBSC_LINKID_CB(gsm48) = DLCI2RSL_LINK_ID(header->link_id);
dtap_rc = osmo_fsm_inst_dispatch(conn->fi, GSCON_EV_MT_DTAP, gsm48);
return dtap_rc;
}