aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmsc/ussd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libmsc/ussd.c')
-rw-r--r--src/libmsc/ussd.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/libmsc/ussd.c b/src/libmsc/ussd.c
index f12c1f28..81a35669 100644
--- a/src/libmsc/ussd.c
+++ b/src/libmsc/ussd.c
@@ -33,6 +33,7 @@
#include <openbsc/gsm_subscriber.h>
#include <openbsc/debug.h>
#include <openbsc/osmo_msc.h>
+#include <openbsc/vlr.h>
/* Declarations of USSD strings to be recognised */
const char USSD_TEXT_OWN_NUMBER[] = "*#100#";
@@ -48,13 +49,19 @@ int handle_rcv_ussd(struct gsm_subscriber_connection *conn, struct msgb *msg)
struct ss_request req;
struct gsm48_hdr *gh;
+ /* TODO: Use subscriber_connection ref-counting if we ever want
+ * to keep the connection alive due ot ongoing USSD exchange.
+ * As we answer everytying synchronously so far, there's no need
+ * yet */
+
+ cm_service_request_concludes(conn, msg);
+
memset(&req, 0, sizeof(req));
gh = msgb_l3(msg);
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);
- msc_release_connection(conn);
return rc;
}
@@ -63,13 +70,13 @@ int handle_rcv_ussd(struct gsm_subscriber_connection *conn, struct msgb *msg)
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;
}
+ msc_subscr_conn_communicating(conn);
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);
@@ -78,17 +85,18 @@ int handle_rcv_ussd(struct gsm_subscriber_connection *conn, struct msgb *msg)
rc = gsm0480_send_ussd_reject(conn, msg, &req);
}
- /* check if we can release it */
- msc_release_connection(conn);
return rc;
}
/* A network-specific handler function */
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 *own_number = conn->vsub->msisdn;
char response_string[GSM_EXTENSION_LENGTH + 20];
+ DEBUGP(DMM, "%s: MSISDN = %s\n", vlr_subscr_name(conn->vsub),
+ own_number);
+
/* Need trailing CR as EOT character */
snprintf(response_string, sizeof(response_string), "Your extension is %s\r", own_number);
return gsm0480_send_ussd_response(conn, msg, response_string, req);