2 * (C) 2010 by Holger Hans Peter Freyther
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <osmocore/gsm0480.h>
27 static const uint8_t ussd_request[] = {
28 0x0b, 0x7b, 0x1c, 0x15, 0xa1, 0x13, 0x02, 0x01,
29 0x03, 0x02, 0x01, 0x3b, 0x30, 0x0b, 0x04, 0x01,
30 0x0f, 0x04, 0x06, 0x2a, 0xd5, 0x4c, 0x16, 0x1b,
31 0x01, 0x7f, 0x01, 0x00
34 static int parse_ussd(const uint8_t *_data, int len)
38 struct ussd_request req;
39 struct gsm48_hdr *hdr;
42 memcpy(data, _data, len);
43 hdr = (struct gsm48_hdr *) &data[0];
44 rc = gsm0480_decode_ussd_request(hdr, len, &req);
50 int main(int argc, char **argv)
52 const int size = sizeof(ussd_request);
55 printf("Testing parsing a USSD request and truncated versions\n");
57 for (i = size; i > sizeof(struct gsm48_hdr); --i) {
58 int rc = parse_ussd(&ussd_request[0], i);
59 printf("Result for %d is %d\n", rc, i);