aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/ussd.c
diff options
context:
space:
mode:
authorMike Haben <michael.haben@btinternet.com>2009-10-22 09:56:44 +0200
committerHarald Welte <laforge@gnumonks.org>2009-10-26 20:39:26 +0100
commitdc329a6cdb204d89c15599ca606e239dde368e7f (patch)
tree39ea0ad4d2749011f87ca2a06b2c4afe8b052c94 /openbsc/src/ussd.c
parent6307b8570061597d165d1e2cfdfbf77ca6f90073 (diff)
[USSD] eliminate static global variables
This patch removes the need of static global variables and introduces a new, caller-allocated 'struct ussd_request' that needs to be passed to the various functions.
Diffstat (limited to 'openbsc/src/ussd.c')
-rw-r--r--openbsc/src/ussd.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/openbsc/src/ussd.c b/openbsc/src/ussd.c
index 9dc2205f1..e414b1cea 100644
--- a/openbsc/src/ussd.c
+++ b/openbsc/src/ussd.c
@@ -38,33 +38,34 @@
const char USSD_TEXT_OWN_NUMBER[] = "*#100#";
/* Forward declarations of network-specific handler functions */
-static int send_own_number(struct msgb *msg);
+static int send_own_number(const struct msgb *msg, const struct ussd_request *req);
/* Entrypoint - handler function common to all mobile-originated USSDs */
int handle_rcv_ussd(struct msgb *msg)
{
- char *ussd_text_rcvd = gsm0480_rcv_ussd(msg);
+ struct ussd_request req;
- if (ussd_text_rcvd[0] == 0xFF) /* Release-Complete */
+ gsm0480_decode_ussd_request(msg, &req);
+ if (req.text[0] == 0xFF) /* Release-Complete */
return 0;
- if (strstr(USSD_TEXT_OWN_NUMBER, ussd_text_rcvd) != NULL) {
+ if (strstr(USSD_TEXT_OWN_NUMBER, req.text) != NULL) {
DEBUGP(DMM, "USSD: Own number requested\n");
- return send_own_number(msg);
+ return send_own_number(msg, &req);
} else {
- DEBUGP(DMM, "Unhandled USSD %s\n", ussd_text_rcvd);
- return gsm0480_send_ussd_reject(msg);
+ DEBUGP(DMM, "Unhandled USSD %s\n", req.text);
+ return gsm0480_send_ussd_reject(msg, &req);
}
}
/* A network-specific handler function */
-static int send_own_number(struct msgb *msg)
+static int send_own_number(const struct msgb *msg, const struct ussd_request *req)
{
char *own_number = msg->lchan->subscr->extension;
/* Need trailing CR as EOT character */
char response_string[] = "Your extension is xxxxx\r";
memcpy(response_string + 18, own_number, 5);
- return gsm0480_send_ussd_response(msg, response_string);
+ return gsm0480_send_ussd_response(msg, response_string, req);
}