From 6eafe9137ca345078531fc607a461f397faa505b Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 16 Oct 2009 08:32:58 +0200 Subject: Add USDD code from Mike Haben This is the initial checkin of the USSD code from Mike Haben. I didn't put it in the main branch as I think it still needs some cleanup. --- openbsc/src/ussd.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 openbsc/src/ussd.c (limited to 'openbsc/src/ussd.c') diff --git a/openbsc/src/ussd.c b/openbsc/src/ussd.c new file mode 100644 index 000000000..5f9a45725 --- /dev/null +++ b/openbsc/src/ussd.c @@ -0,0 +1,68 @@ +/* Network-specific handling of mobile-originated USSDs. */ + +/* (C) 2008-2009 by Harald Welte + * (C) 2008, 2009 by Holger Hans Peter Freyther + * (C) 2009 by Mike Haben + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +/* This module defines the network-specific handling of mobile-originated USSD messages. */ + +#include +#include +#include +#include + +#include +#include +#include + +/* Declarations of USSD strings to be recognised */ +const char USSD_TEXT_OWN_NUMBER[] = "*#100#"; + +/* Forward declarations of network-specific handler functions */ +static int send_own_number(struct msgb *msg); + + +/* Entrypoint - handler function common to all mobile-originated USSDs */ +int handle_rcv_ussd(struct msgb *msg) +{ + char* ussd_text_rcvd = gsm0480_rcv_ussd(msg); + + if(ussd_text_rcvd[0] == 0xFF) /* Release-Complete */ + return 0; + + if(strstr(USSD_TEXT_OWN_NUMBER, ussd_text_rcvd) != NULL) { + DEBUGP(DMM, "USSD: Own number requested\n"); + return send_own_number(msg); + } else { + DEBUGP(DMM, "Unhandled USSD %s\n", ussd_text_rcvd); + return gsm0480_send_ussd_reject(msg); + } +} + +/* A network-specific handler function */ +static int send_own_number(struct msgb *msg) +{ + char response_string[] = "Your extension is xxxxx\r"; /* Need trailing CR as EOT character */ + + char* own_number = msg->lchan->subscr->extension; + memcpy(response_string + 18, own_number, 5); + return gsm0480_send_ussd_response(msg, response_string); +} -- cgit v1.2.3