blob: 462d9789e78c8ea816e74b1a1f058d160f068174 [file] [log] [blame]
Harald Welte8c8f7912009-10-26 20:42:55 +01001/* GSM Mobile Radio Interface Layer 3 messages on the A-bis interface
Harald Welte6eafe912009-10-16 08:32:58 +02002 * 3GPP TS 04.08 version 7.21.0 Release 1998 / ETSI TS 100 940 V7.21.0 */
3
4/* (C) 2008-2009 by Harald Welte <laforge@gnumonks.org>
Holger Hans Peter Freyther680833e2010-07-25 18:08:53 +08005 * (C) 2008, 2009, 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
Harald Welte6eafe912009-10-16 08:32:58 +02006 * (C) 2009 by Mike Haben <michael.haben@btinternet.com>
7 *
8 * All Rights Reserved
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 *
24 */
25
26
27#include <stdio.h>
28#include <stdlib.h>
29#include <string.h>
30#include <errno.h>
31
Harald Weltedfe6c7d2010-02-20 16:24:02 +010032#include <osmocore/msgb.h>
33#include <osmocore/tlv.h>
Harald Welte6eafe912009-10-16 08:32:58 +020034#include <openbsc/debug.h>
35#include <openbsc/gsm_data.h>
Harald Weltedfe6c7d2010-02-20 16:24:02 +010036#include <osmocore/gsm_utils.h>
Harald Welte6eafe912009-10-16 08:32:58 +020037#include <openbsc/gsm_04_08.h>
38#include <openbsc/gsm_04_80.h>
Holger Hans Peter Freyther9c137a72010-06-15 13:57:40 +080039#include <openbsc/bsc_api.h>
Harald Welte6eafe912009-10-16 08:32:58 +020040
Harald Welte6eafe912009-10-16 08:32:58 +020041/* Forward declarations */
Mike Habendc329a62009-10-22 09:56:44 +020042static int parse_ussd(u_int8_t *ussd, struct ussd_request *req);
Harald Welte17e5f972009-10-26 20:42:07 +010043static int parse_ussd_info_elements(u_int8_t *ussd_ie,
Mike Habendc329a62009-10-22 09:56:44 +020044 struct ussd_request *req);
Harald Welte17e5f972009-10-26 20:42:07 +010045static int parse_facility_ie(u_int8_t *facility_ie, u_int8_t length,
Mike Habendc329a62009-10-22 09:56:44 +020046 struct ussd_request *req);
Harald Welte17e5f972009-10-26 20:42:07 +010047static int parse_ss_invoke(u_int8_t *invoke_data, u_int8_t length,
Mike Habendc329a62009-10-22 09:56:44 +020048 struct ussd_request *req);
Harald Welte17e5f972009-10-26 20:42:07 +010049static int parse_process_uss_req(u_int8_t *uss_req_data, u_int8_t length,
Mike Habendc329a62009-10-22 09:56:44 +020050 struct ussd_request *req);
Harald Welte6eafe912009-10-16 08:32:58 +020051
52static inline unsigned char *msgb_wrap_with_TL(struct msgb *msgb, u_int8_t tag)
53{
Holger Hans Peter Freytherac30cc82010-07-26 19:08:59 +080054 uint8_t *data = msgb_push(msgb, 2);
55
56 data[0] = tag;
57 data[1] = msgb->len;
58 return data;
Harald Welte6eafe912009-10-16 08:32:58 +020059}
60
Harald Welte6307b852009-10-16 08:41:51 +020061static inline unsigned char *msgb_push_TLV1(struct msgb *msgb, u_int8_t tag,
62 u_int8_t value)
Harald Welte6eafe912009-10-16 08:32:58 +020063{
Holger Hans Peter Freytherac30cc82010-07-26 19:08:59 +080064 uint8_t *data = msgb_push(msgb, 3);
65
66 data[0] = tag;
67 data[1] = 1;
68 data[2] = value;
69 return data;
Harald Welte6eafe912009-10-16 08:32:58 +020070}
71
72
Mike Habendc329a62009-10-22 09:56:44 +020073/* Decode a mobile-originated USSD-request message */
Mike Haben2449b372009-10-26 20:36:34 +010074int gsm0480_decode_ussd_request(const struct msgb *msg, struct ussd_request *req)
Harald Welte6eafe912009-10-16 08:32:58 +020075{
76 int rc = 0;
Harald Welte6307b852009-10-16 08:41:51 +020077 u_int8_t *parse_ptr = msgb_l3(msg);
Harald Welte6eafe912009-10-16 08:32:58 +020078
Harald Welte6eafe912009-10-16 08:32:58 +020079 if ((*parse_ptr & 0x0F) == GSM48_PDISC_NC_SS) {
Mike Habendc329a62009-10-22 09:56:44 +020080 req->transaction_id = *parse_ptr & 0x70;
81 rc = parse_ussd(parse_ptr+1, req);
Harald Welte6eafe912009-10-16 08:32:58 +020082 }
83
84 if (!rc)
Harald Welte17e5f972009-10-26 20:42:07 +010085 DEBUGP(DMM, "Error occurred while parsing received USSD!\n");
Harald Welte6eafe912009-10-16 08:32:58 +020086
Mike Habendc329a62009-10-22 09:56:44 +020087 return rc;
Harald Welte6eafe912009-10-16 08:32:58 +020088}
89
Mike Habendc329a62009-10-22 09:56:44 +020090static int parse_ussd(u_int8_t *ussd, struct ussd_request *req)
Harald Welte6eafe912009-10-16 08:32:58 +020091{
92 int rc = 1;
93 u_int8_t msg_type = ussd[0] & 0xBF; /* message-type - section 3.4 */
94
Harald Welte6307b852009-10-16 08:41:51 +020095 switch (msg_type) {
Harald Welte6eafe912009-10-16 08:32:58 +020096 case GSM0480_MTYPE_RELEASE_COMPLETE:
Harald Welte6307b852009-10-16 08:41:51 +020097 DEBUGP(DMM, "USS Release Complete\n");
98 /* could also parse out the optional Cause/Facility data */
Mike Habendc329a62009-10-22 09:56:44 +020099 req->text[0] = 0xFF;
Harald Welte6eafe912009-10-16 08:32:58 +0200100 break;
101 case GSM0480_MTYPE_REGISTER:
102 case GSM0480_MTYPE_FACILITY:
Mike Habendc329a62009-10-22 09:56:44 +0200103 rc &= parse_ussd_info_elements(ussd+1, req);
Harald Welte6eafe912009-10-16 08:32:58 +0200104 break;
105 default:
106 fprintf(stderr, "Unknown GSM 04.80 message-type field 0x%02x\n",
107 ussd[0]);
108 rc = 0;
109 break;
110 }
111
112 return rc;
113}
114
Mike Habendc329a62009-10-22 09:56:44 +0200115static int parse_ussd_info_elements(u_int8_t *ussd_ie, struct ussd_request *req)
Harald Welte6eafe912009-10-16 08:32:58 +0200116{
Holger Hans Peter Freyther4f140642010-07-23 19:35:54 +0800117 int rc = -1;
Harald Welte6307b852009-10-16 08:41:51 +0200118 /* Information Element Identifier - table 3.2 & GSM 04.08 section 10.5 */
119 u_int8_t iei = ussd_ie[0];
Harald Welte17e5f972009-10-26 20:42:07 +0100120 u_int8_t iei_length = ussd_ie[1];
Harald Welte6307b852009-10-16 08:41:51 +0200121
122 switch (iei) {
Harald Welte6eafe912009-10-16 08:32:58 +0200123 case GSM48_IE_CAUSE:
124 break;
125 case GSM0480_IE_FACILITY:
Mike Habendc329a62009-10-22 09:56:44 +0200126 rc = parse_facility_ie(ussd_ie+2, iei_length, req);
Harald Welte6eafe912009-10-16 08:32:58 +0200127 break;
128 case GSM0480_IE_SS_VERSION:
129 break;
130 default:
Harald Welte6307b852009-10-16 08:41:51 +0200131 fprintf(stderr, "Unhandled GSM 04.08 or 04.80 IEI 0x%02x\n",
Harald Welte6eafe912009-10-16 08:32:58 +0200132 iei);
133 rc = 0;
134 break;
135 }
136
137 return rc;
138}
139
Harald Welte17e5f972009-10-26 20:42:07 +0100140static int parse_facility_ie(u_int8_t *facility_ie, u_int8_t length,
Mike Habendc329a62009-10-22 09:56:44 +0200141 struct ussd_request *req)
Harald Welte6eafe912009-10-16 08:32:58 +0200142{
143 int rc = 1;
144 u_int8_t offset = 0;
145
146 do {
Harald Welte6307b852009-10-16 08:41:51 +0200147 /* Component Type tag - table 3.7 */
148 u_int8_t component_type = facility_ie[offset];
Harald Welte6eafe912009-10-16 08:32:58 +0200149 u_int8_t component_length = facility_ie[offset+1];
Harald Welte6307b852009-10-16 08:41:51 +0200150
151 switch (component_type) {
Harald Welte6eafe912009-10-16 08:32:58 +0200152 case GSM0480_CTYPE_INVOKE:
Harald Welte17e5f972009-10-26 20:42:07 +0100153 rc &= parse_ss_invoke(facility_ie+2,
154 component_length,
Mike Habendc329a62009-10-22 09:56:44 +0200155 req);
Harald Welte6eafe912009-10-16 08:32:58 +0200156 break;
157 case GSM0480_CTYPE_RETURN_RESULT:
158 break;
159 case GSM0480_CTYPE_RETURN_ERROR:
160 break;
161 case GSM0480_CTYPE_REJECT:
162 break;
163 default:
Harald Welte6307b852009-10-16 08:41:51 +0200164 fprintf(stderr, "Unknown GSM 04.80 Facility "
165 "Component Type 0x%02x\n", component_type);
Harald Welte6eafe912009-10-16 08:32:58 +0200166 rc = 0;
167 break;
168 }
169 offset += (component_length+2);
Harald Welte6307b852009-10-16 08:41:51 +0200170 } while (offset < length);
Harald Welte6eafe912009-10-16 08:32:58 +0200171
172 return rc;
173}
174
175/* Parse an Invoke component - see table 3.3 */
Harald Welte17e5f972009-10-26 20:42:07 +0100176static int parse_ss_invoke(u_int8_t *invoke_data, u_int8_t length,
Mike Habendc329a62009-10-22 09:56:44 +0200177 struct ussd_request *req)
Harald Welte6eafe912009-10-16 08:32:58 +0200178{
179 int rc = 1;
Harald Welte6307b852009-10-16 08:41:51 +0200180 u_int8_t offset;
181
182 /* mandatory part */
183 if (invoke_data[0] != GSM0480_COMPIDTAG_INVOKE_ID) {
184 fprintf(stderr, "Unexpected GSM 04.80 Component-ID tag "
185 "0x%02x (expecting Invoke ID tag)\n", invoke_data[0]);
Harald Welte6eafe912009-10-16 08:32:58 +0200186 }
Harald Welte6307b852009-10-16 08:41:51 +0200187
188 offset = invoke_data[1] + 2;
Mike Habendc329a62009-10-22 09:56:44 +0200189 req->invoke_id = invoke_data[2];
Harald Welte6eafe912009-10-16 08:32:58 +0200190
Harald Welte6307b852009-10-16 08:41:51 +0200191 /* optional part */
192 if (invoke_data[offset] == GSM0480_COMPIDTAG_LINKED_ID)
Harald Welte6eafe912009-10-16 08:32:58 +0200193 offset += invoke_data[offset+1] + 2; /* skip over it */
Harald Welte6307b852009-10-16 08:41:51 +0200194
195 /* mandatory part */
196 if (invoke_data[offset] == GSM0480_OPERATION_CODE) {
Harald Welte6eafe912009-10-16 08:32:58 +0200197 u_int8_t operation_code = invoke_data[offset+2];
Harald Welte6307b852009-10-16 08:41:51 +0200198 switch (operation_code) {
Harald Welte6eafe912009-10-16 08:32:58 +0200199 case GSM0480_OP_CODE_PROCESS_USS_REQ:
Harald Welte6307b852009-10-16 08:41:51 +0200200 rc = parse_process_uss_req(invoke_data + offset + 3,
Mike Habendc329a62009-10-22 09:56:44 +0200201 length - offset - 3,
202 req);
Harald Welte6eafe912009-10-16 08:32:58 +0200203 break;
204 default:
Harald Welte6307b852009-10-16 08:41:51 +0200205 fprintf(stderr, "GSM 04.80 operation code 0x%02x "
206 "is not yet handled\n", operation_code);
Harald Welte6eafe912009-10-16 08:32:58 +0200207 rc = 0;
208 break;
209 }
210 } else {
Harald Welte6307b852009-10-16 08:41:51 +0200211 fprintf(stderr, "Unexpected GSM 04.80 Component-ID tag 0x%02x "
212 "(expecting Operation Code tag)\n",
Harald Welte6eafe912009-10-16 08:32:58 +0200213 invoke_data[0]);
214 rc = 0;
215 }
216
217 return rc;
218}
219
220/* Parse the parameters of a Process UnstructuredSS Request */
Harald Welte17e5f972009-10-26 20:42:07 +0100221static int parse_process_uss_req(u_int8_t *uss_req_data, u_int8_t length,
Mike Habendc329a62009-10-22 09:56:44 +0200222 struct ussd_request *req)
Harald Welte6eafe912009-10-16 08:32:58 +0200223{
Mike Habendc329a62009-10-22 09:56:44 +0200224 int rc = 0;
Harald Welte6eafe912009-10-16 08:32:58 +0200225 int num_chars;
226 u_int8_t dcs;
227
Harald Welte6eafe912009-10-16 08:32:58 +0200228 if (uss_req_data[0] == GSM_0480_SEQUENCE_TAG) {
229 if (uss_req_data[2] == ASN1_OCTET_STRING_TAG) {
230 dcs = uss_req_data[4];
Harald Welte6307b852009-10-16 08:41:51 +0200231 if ((dcs == 0x0F) &&
232 (uss_req_data[5] == ASN1_OCTET_STRING_TAG)) {
Harald Welte6eafe912009-10-16 08:32:58 +0200233 num_chars = (uss_req_data[6] * 8) / 7;
Mike Haben2449b372009-10-26 20:36:34 +0100234 /* Prevent a mobile-originated buffer-overrun! */
235 if (num_chars > MAX_LEN_USSD_STRING)
236 num_chars = MAX_LEN_USSD_STRING;
Mike Habendc329a62009-10-22 09:56:44 +0200237 gsm_7bit_decode(req->text,
Harald Welte6307b852009-10-16 08:41:51 +0200238 &(uss_req_data[7]), num_chars);
Mike Habendc329a62009-10-22 09:56:44 +0200239 /* append null-terminator */
Holger Hans Peter Freytheracf8a0c2010-03-29 08:47:44 +0200240 req->text[num_chars+1] = 0;
Mike Habendc329a62009-10-22 09:56:44 +0200241 rc = 1;
Harald Welte6eafe912009-10-16 08:32:58 +0200242 }
243 }
Mike Habendc329a62009-10-22 09:56:44 +0200244 }
Harald Welte6eafe912009-10-16 08:32:58 +0200245 return rc;
246}
247
Holger Hans Peter Freyther680833e2010-07-25 18:08:53 +0800248struct msgb *gsm0480_create_notifySS(const char *text)
249{
250 struct msgb *msg;
251 uint8_t *data, *tmp_len;
252 uint8_t *seq_len_ptr, *cal_len_ptr, *opt_len_ptr, *nam_len_ptr;
253 int len;
254
255 len = strlen(text);
256 if (len < 1 || len > 160)
257 return NULL;
258
259 msg = gsm48_msgb_alloc();
260 if (!msg)
261 return NULL;
262
263 msgb_put_u8(msg, GSM_0480_SEQUENCE_TAG);
264 seq_len_ptr = msgb_put(msg, 1);
265
266
267 /* nameIndicator { */
268 msgb_put_u8(msg, 0xB4);
269 nam_len_ptr = msgb_put(msg, 1);
270
271 /* callingName { */
272 msgb_put_u8(msg, 0xA0);
273 opt_len_ptr = msgb_put(msg, 1);
274 msgb_put_u8(msg, 0xA0);
275 cal_len_ptr = msgb_put(msg, 1);
276
277 /* namePresentationAllowed { */
278 /* add the DCS value */
279 msgb_put_u8(msg, 0x80);
280 msgb_put_u8(msg, 1);
281 msgb_put_u8(msg, 0x0F);
282
283 /* add the lengthInCharacters */
284 msgb_put_u8(msg, 0x81);
285 msgb_put_u8(msg, 1);
286 msgb_put_u8(msg, strlen(text));
287
288 /* add the actual string */
289 msgb_put_u8(msg, 0x82);
290 tmp_len = msgb_put(msg, 1);
291 data = msgb_put(msg, 0);
292 len = gsm_7bit_encode(data, text);
293 tmp_len[0] = len;
294 msgb_put(msg, len);
295
296 /* }; namePresentationAllowed */
297
298 cal_len_ptr[0] = 3 + 3 + 2 + len;
299 opt_len_ptr[0] = cal_len_ptr[0] + 2;
300 /* }; callingName */
301
302 nam_len_ptr[0] = opt_len_ptr[0] + 2;
303 /* ); nameIndicator */
304
305 /* write the lengths... */
306 seq_len_ptr[0] = nam_len_ptr[0] + 2;
307
308 return msg;
309}
310
Holger Hans Peter Freyther15ef17e2010-07-26 18:34:27 +0800311struct msgb *gsm0480_create_unstructuredSS_Notify(const char *text)
312{
313 struct msgb *msg;
314 uint8_t *seq_len_ptr, *ussd_len_ptr, *data;
315 int len;
316
317 msg = gsm48_msgb_alloc();
318 if (!msg)
319 return NULL;
320
321 /* SEQUENCE { */
322 msgb_put_u8(msg, GSM_0480_SEQUENCE_TAG);
323 seq_len_ptr = msgb_put(msg, 1);
324
325 /* DCS { */
326 msgb_put_u8(msg, ASN1_OCTET_STRING_TAG);
327 msgb_put_u8(msg, 1);
328 msgb_put_u8(msg, 0x0F);
329 /* } DCS */
330
331 /* USSD-String { */
332 msgb_put_u8(msg, ASN1_OCTET_STRING_TAG);
333 ussd_len_ptr = msgb_put(msg, 1);
334 data = msgb_put(msg, 0);
335 len = gsm_7bit_encode(data, text);
336 msgb_put(msg, len);
337 ussd_len_ptr[0] = len;
338 /* USSD-String } */
339
340 seq_len_ptr[0] = 3 + 2 + ussd_len_ptr[0];
341 /* } SEQUENCE */
342
343 return msg;
344}
345
Harald Welte6eafe912009-10-16 08:32:58 +0200346/* Send response to a mobile-originated ProcessUnstructuredSS-Request */
Holger Hans Peter Freytherd42c3f22010-06-17 17:35:57 +0800347int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn,
348 const struct msgb *in_msg, const char *response_text,
349 const struct ussd_request *req)
Harald Welte6eafe912009-10-16 08:32:58 +0200350{
351 struct msgb *msg = gsm48_msgb_alloc();
352 struct gsm48_hdr *gh;
353 u_int8_t *ptr8;
354 int response_len;
355
Harald Welte6eafe912009-10-16 08:32:58 +0200356 /* First put the payload text into the message */
Holger Hans Peter Freytherba81ab32010-07-26 17:56:55 +0800357 ptr8 = msgb_put(msg, 0);
358 response_len = gsm_7bit_encode(ptr8, response_text);
359 msgb_put(msg, response_len);
Harald Welte6eafe912009-10-16 08:32:58 +0200360
361 /* Then wrap it as an Octet String */
362 msgb_wrap_with_TL(msg, ASN1_OCTET_STRING_TAG);
363
364 /* Pre-pend the DCS octet string */
365 msgb_push_TLV1(msg, ASN1_OCTET_STRING_TAG, 0x0F);
366
367 /* Then wrap these as a Sequence */
368 msgb_wrap_with_TL(msg, GSM_0480_SEQUENCE_TAG);
369
370 /* Pre-pend the operation code */
Harald Welte6307b852009-10-16 08:41:51 +0200371 msgb_push_TLV1(msg, GSM0480_OPERATION_CODE,
372 GSM0480_OP_CODE_PROCESS_USS_REQ);
Harald Welte6eafe912009-10-16 08:32:58 +0200373
374 /* Wrap the operation code and IA5 string as a sequence */
375 msgb_wrap_with_TL(msg, GSM_0480_SEQUENCE_TAG);
376
377 /* Pre-pend the invoke ID */
Mike Habendc329a62009-10-22 09:56:44 +0200378 msgb_push_TLV1(msg, GSM0480_COMPIDTAG_INVOKE_ID, req->invoke_id);
Harald Welte6eafe912009-10-16 08:32:58 +0200379
380 /* Wrap this up as a Return Result component */
381 msgb_wrap_with_TL(msg, GSM0480_CTYPE_RETURN_RESULT);
382
383 /* Wrap the component in a Facility message */
384 msgb_wrap_with_TL(msg, GSM0480_IE_FACILITY);
385
386 /* And finally pre-pend the L3 header */
387 gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));
Harald Welte8c8f7912009-10-26 20:42:55 +0100388 gh->proto_discr = GSM48_PDISC_NC_SS | req->transaction_id
Mike Habendc329a62009-10-22 09:56:44 +0200389 | (1<<7); /* TI direction = 1 */
Harald Welte6eafe912009-10-16 08:32:58 +0200390 gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE;
391
Holger Hans Peter Freytherd42c3f22010-06-17 17:35:57 +0800392 return gsm0808_submit_dtap(conn, msg, 0);
Harald Welte6eafe912009-10-16 08:32:58 +0200393}
394
Holger Hans Peter Freyther6a4b3622010-07-26 03:41:11 +0800395/* wrap an invoke around it... the other way around
396 *
397 * 1.) Invoke Component tag
398 * 2.) Invoke ID Tag
399 * 3.) Operation
400 * 4.) Data
401 */
402int gsm0480_wrap_invoke(struct msgb *msg, int op, int link_id)
403{
404 /* 3. operation */
405 msgb_push_TLV1(msg, GSM0480_OPERATION_CODE, op);
406
407 /* 2. invoke id tag */
408 msgb_push_TLV1(msg, GSM0480_COMPIDTAG_INVOKE_ID, link_id);
409
410 /* 1. component tag */
411 msgb_wrap_with_TL(msg, GSM0480_CTYPE_INVOKE);
412
413 return 0;
414}
415
Holger Hans Peter Freytherb02c89e2010-07-26 19:05:56 +0800416/* wrap the GSM 04.08 Facility IE around it */
417int gsm0480_wrap_facility(struct msgb *msg)
418{
419 msgb_wrap_with_TL(msg, GSM0480_IE_FACILITY);
420
421 return 0;
422}
423
Holger Hans Peter Freytherd42c3f22010-06-17 17:35:57 +0800424int gsm0480_send_ussd_reject(struct gsm_subscriber_connection *conn,
425 const struct msgb *in_msg,
426 const struct ussd_request *req)
Harald Welte6eafe912009-10-16 08:32:58 +0200427{
428 struct msgb *msg = gsm48_msgb_alloc();
429 struct gsm48_hdr *gh;
430
Harald Welte6eafe912009-10-16 08:32:58 +0200431 /* First insert the problem code */
Harald Welte6307b852009-10-16 08:41:51 +0200432 msgb_push_TLV1(msg, GSM_0480_PROBLEM_CODE_TAG_GENERAL,
433 GSM_0480_GEN_PROB_CODE_UNRECOGNISED);
Harald Welte6eafe912009-10-16 08:32:58 +0200434
435 /* Before it insert the invoke ID */
Mike Habendc329a62009-10-22 09:56:44 +0200436 msgb_push_TLV1(msg, GSM0480_COMPIDTAG_INVOKE_ID, req->invoke_id);
Harald Welte6eafe912009-10-16 08:32:58 +0200437
438 /* Wrap this up as a Reject component */
439 msgb_wrap_with_TL(msg, GSM0480_CTYPE_REJECT);
440
441 /* Wrap the component in a Facility message */
442 msgb_wrap_with_TL(msg, GSM0480_IE_FACILITY);
443
444 /* And finally pre-pend the L3 header */
445 gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));
Harald Welte6307b852009-10-16 08:41:51 +0200446 gh->proto_discr = GSM48_PDISC_NC_SS;
Mike Habendc329a62009-10-22 09:56:44 +0200447 gh->proto_discr |= req->transaction_id | (1<<7); /* TI direction = 1 */
Harald Welte6eafe912009-10-16 08:32:58 +0200448 gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE;
449
Holger Hans Peter Freytherd42c3f22010-06-17 17:35:57 +0800450 return gsm0808_submit_dtap(conn, msg, 0);
Harald Welte6eafe912009-10-16 08:32:58 +0200451}