fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-hlr/+/33528 ) Change subject: USSD: fix handling of ussd-DataCodingScheme != 0x0f ...................................................................... USSD: fix handling of ussd-DataCodingScheme != 0x0f Change-Id: Ib7bac660b1a7942adcfbe7b14f162c95061a25db Related: OS#6075 --- M src/hlr_ussd.c 1 file changed, 43 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/28/33528/1 diff --git a/src/hlr_ussd.c b/src/hlr_ussd.c index 35b74b6..d244b59 100644 --- a/src/hlr_ussd.c +++ b/src/hlr_ussd.c @@ -122,9 +122,40 @@ talloc_free(rt); } -static struct hlr_ussd_route *ussd_route_lookup_7bit(struct hlr *hlr, const char *ussd_code) +static struct hlr_ussd_route *ussd_route_lookup_for_req(struct hlr *hlr, const struct ss_request *req) { + const uint8_t cgroup = req->ussd_data_dcs >> 4; + const uint8_t lang = req->ussd_data_dcs & 0x0f; + char ussd_code[GSM0480_USSD_7BIT_STRING_LEN]; struct hlr_ussd_route *rt; + + ussd_code[0] = '\0'; + + /* We support only the Coding Group 0 (GSM 7-bit default alphabeet). In fact, + * the USSD request is usually limited to [*#0-9], so we don't really need to + * support other coding groups and languages. */ + switch (cgroup) { + case 0: + /* The Language is usually set to '1111'B (unspecified), but some UEs + * are known to indicate '0000'B (German). */ + if (lang != 0x0f) { + LOGP(DSS, LOGL_NOTICE, "USSD DataCodingScheme (0x%02x): " + "the Language is usually set to 15 (unspecified), " + "but the request indicates %u - ignoring this\n", + req->ussd_data_dcs, lang); + /* do not abort, attempt to decode as if it was '1111'B */ + } + + gsm_7bit_decode_n_ussd(&ussd_code[0], sizeof(ussd_code), + req->ussd_data, (req->ussd_data_len * 8) / 7); + break; + default: + LOGP(DSS, LOGL_ERROR, "USSD DataCodingScheme (0x%02x): " + "Coding Group %u is not supported, expecting Coding Group 0\n", + req->ussd_data_dcs, cgroup); + return NULL; + } + llist_for_each_entry(rt, &hlr->ussd_routes, list) { if (!strncmp(ussd_code, rt->prefix, strlen(rt->prefix))) { LOGP(DSS, LOGL_DEBUG, "Found %s '%s' (prefix '%s') for USSD " @@ -603,7 +634,7 @@ } else { /* VLR->EUSE: MO USSD. VLR is known ('conn'), EUSE is to be resolved */ struct hlr_ussd_route *rt; - rt = ussd_route_lookup_7bit(hlr, (const char *) req.ussd_text); + rt = ussd_route_lookup_for_req(hlr, &req); if (rt) { if (rt->is_external) { ss->is_external = true; -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/33528 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: Ib7bac660b1a7942adcfbe7b14f162c95061a25db Gerrit-Change-Number: 33528 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de> Gerrit-MessageType: newchange