tempest has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-msc/+/43918?usp=email )
Change subject: mm-info: properly encode length 8n-1 network names ......................................................................
mm-info: properly encode length 8n-1 network names
Because of the way CBS-format GSM messages are encoded (see 3GPP TS 23.038 6.1.2.3.1), messages of length 8n-1 require an special padding character to avoid being interpreted as a message of length 8n with some extra character postpended (commonly an @ character in the case of all zeroes, this case is explicitly mentioned in the aformentioned spec).
Using the already existing gsm_7bit_encode_n_ussd instead of the SMS format gsm_7bit_encode_n resolves this issue of network names of length 8n-1 (commonly 7) showing with an erroneous @ character postpended on the end of the network name.
Note: because gsm_7bit_encode_n_ussd relies on the returned octets pointer from gsm_7bit_encode_n, osmo-msc will segfault if NULL is passed to the USSD encode function. Unless a patch is wanted in libosmocore, a temporary octets variable works fine.
Change-Id: Ib8328cd2c9984b490951d39f21e86a4ef63e35d5 Related: OS#6847 --- M src/libmsc/gsm_04_08.c 1 file changed, 3 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/18/43918/1
diff --git a/src/libmsc/gsm_04_08.c b/src/libmsc/gsm_04_08.c index 0347f63..8a303d4 100644 --- a/src/libmsc/gsm_04_08.c +++ b/src/libmsc/gsm_04_08.c @@ -469,7 +469,7 @@ struct msgb *msg = gsm48_msgb_alloc_name("GSM 04.08 MM INF"); struct gsm48_hdr *gh; uint8_t *ptr8; - int name_len, name_pad; + int name_len, name_pad, octets;
time_t cur_t; struct tm* gmt_time; @@ -508,7 +508,7 @@ ptr8[2] = 0x80 | name_pad; /* Cell Broadcast DCS, no CI */
ptr8 = msgb_put(msg, name_len); - gsm_7bit_encode_n(ptr8, name_len, net->name_long, NULL); + gsm_7bit_encode_n_ussd(ptr8, name_len, net->name_long, &octets);
}
@@ -536,7 +536,7 @@ ptr8[2] = 0x80 | name_pad; /* Cell Broadcast DCS, no CI */
ptr8 = msgb_put(msg, name_len); - gsm_7bit_encode_n(ptr8, name_len, net->name_short, NULL); + gsm_7bit_encode_n_ussd(ptr8, name_len, net->name_short, &octets);
}