ussd: Add band-aid for interrogationSS

This is a speculative change for interrogateSS and by not answering
the request the radio connection would remain open long.

The SS/USSD code is from a time where none of knew much about GSM. We
do not support SS but should reject it. We have checked for an empty
string in the text field to guess if it is a result/release to not send
more information. The right way forward is to decode the ASN1 into the
fields REQUEST/RESULT(last).

Fix an issue and make the code worse. Assume ss_code > 0 to see if this
is a interrogate invoke. The issue is that code 0 is a well defined
value but unlikely to be used.

MAP ASN1 definition:

SS-Code ::= OCTET STRING (SIZE (1))
        -- This type is used to represent the code identifying a single
        -- supplementary service, a group of supplementary services, or
        -- all supplementary services. The services and abbreviations
        -- used are defined in TS 3GPP TS 22.004 [5]. The internal structure is
        -- defined as follows:
        --
        -- bits 87654321: group (bits 8765), and specific service
        -- (bits 4321)

allSS                   SS-Code ::= '00000000'B

Change-Id: Ib0dc4485388f030eb172fe21f5327b7ab94751f5
This commit is contained in:
Holger Hans Peter Freyther 2016-07-12 17:53:26 +02:00 committed by Holger Freyther
parent 26f6ced05c
commit 5085e0bf4c
3 changed files with 20 additions and 12 deletions

View File

@ -9,10 +9,10 @@ struct gsm_subscriber_connection;
int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn,
const struct msgb *in_msg, const char* response_text,
const struct ussd_request *req);
const struct ss_request *req);
int gsm0480_send_ussd_reject(struct gsm_subscriber_connection *conn,
const struct msgb *msg,
const struct ussd_request *request);
const struct ss_request *request);
int gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn, int level, const char *text);
int gsm0480_send_releaseComplete(struct gsm_subscriber_connection *conn);

View File

@ -63,7 +63,7 @@ static inline unsigned char *msgb_push_TLV1(struct msgb *msgb, uint8_t tag,
/* Send response to a mobile-originated ProcessUnstructuredSS-Request */
int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn,
const struct msgb *in_msg, const char *response_text,
const struct ussd_request *req)
const struct ss_request *req)
{
struct msgb *msg = gsm48_msgb_alloc_name("GSM 04.08 USSD RSP");
struct gsm48_hdr *gh;
@ -111,7 +111,7 @@ int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn,
int gsm0480_send_ussd_reject(struct gsm_subscriber_connection *conn,
const struct msgb *in_msg,
const struct ussd_request *req)
const struct ss_request *req)
{
struct msgb *msg = gsm48_msgb_alloc_name("GSM 04.08 USSD REJ");
struct gsm48_hdr *gh;

View File

@ -38,19 +38,19 @@
const char USSD_TEXT_OWN_NUMBER[] = "*#100#";
/* Forward declarations of network-specific handler functions */
static int send_own_number(struct gsm_subscriber_connection *conn, const struct msgb *msg, const struct ussd_request *req);
static int send_own_number(struct gsm_subscriber_connection *conn, const struct msgb *msg, const struct ss_request *req);
/* Entrypoint - handler function common to all mobile-originated USSDs */
int handle_rcv_ussd(struct gsm_subscriber_connection *conn, struct msgb *msg)
{
int rc;
struct ussd_request req;
struct ss_request req;
struct gsm48_hdr *gh;
memset(&req, 0, sizeof(req));
gh = msgb_l3(msg);
rc = gsm0480_decode_ussd_request(gh, msgb_l3len(msg), &req);
rc = gsm0480_decode_ss_request(gh, msgb_l3len(msg), &req);
if (!rc) {
DEBUGP(DMM, "Unhandled SS\n");
rc = gsm0480_send_ussd_reject(conn, msg, &req);
@ -58,15 +58,23 @@ int handle_rcv_ussd(struct gsm_subscriber_connection *conn, struct msgb *msg)
return rc;
}
/* Release-Complete */
if (req.text[0] == '\0')
/* Interrogation or releaseComplete? */
if (req.ussd_text[0] == '\0' || req.ussd_text[0] == 0xFF) {
if (req.ss_code > 0) {
/* Assume interrogateSS or modification of it and reject */
rc = gsm0480_send_ussd_reject(conn, msg, &req);
msc_release_connection(conn);
return rc;
}
/* Still assuming a Release-Complete and returning */
return 0;
}
if (!strcmp(USSD_TEXT_OWN_NUMBER, (const char *)req.text)) {
if (!strcmp(USSD_TEXT_OWN_NUMBER, (const char *)req.ussd_text)) {
DEBUGP(DMM, "USSD: Own number requested\n");
rc = send_own_number(conn, msg, &req);
} else {
DEBUGP(DMM, "Unhandled USSD %s\n", req.text);
DEBUGP(DMM, "Unhandled USSD %s\n", req.ussd_text);
rc = gsm0480_send_ussd_reject(conn, msg, &req);
}
@ -76,7 +84,7 @@ int handle_rcv_ussd(struct gsm_subscriber_connection *conn, struct msgb *msg)
}
/* A network-specific handler function */
static int send_own_number(struct gsm_subscriber_connection *conn, const struct msgb *msg, const struct ussd_request *req)
static int send_own_number(struct gsm_subscriber_connection *conn, const struct msgb *msg, const struct ss_request *req)
{
char *own_number = conn->subscr->extension;
char response_string[GSM_EXTENSION_LENGTH + 20];