blob: b478bc7f53cbf2e76cf950133056142823100e27 [file] [log] [blame]
Harald Welte52b1f982008-12-23 20:25:15 +00001/* GSM Mobile Radio Interface Layer 3 messages on the A-bis interface
2 * 3GPP TS 04.08 version 7.21.0 Release 1998 / ETSI TS 100 940 V7.21.0 */
3
4/* (C) 2008 by Harald Welte <laforge@gnumonks.org>
Harald Welte8470bf22008-12-25 23:28:35 +00005 *
Harald Welte52b1f982008-12-23 20:25:15 +00006 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 */
23
24
25#include <stdio.h>
26#include <stdlib.h>
27#include <string.h>
28#include <errno.h>
Harald Welte4b634542008-12-27 01:55:51 +000029#include <netinet/in.h>
Harald Welte52b1f982008-12-23 20:25:15 +000030
Harald Welte8470bf22008-12-25 23:28:35 +000031#include <openbsc/msgb.h>
32#include <openbsc/debug.h>
33#include <openbsc/gsm_data.h>
34#include <openbsc/gsm_subscriber.h>
35#include <openbsc/gsm_04_08.h>
36#include <openbsc/abis_rsl.h>
Harald Welte52b1f982008-12-23 20:25:15 +000037
Harald Welte8470bf22008-12-25 23:28:35 +000038#define GSM48_ALLOC_SIZE 1024
39#define GSM48_ALLOC_HEADROOM 128
Harald Welte52b1f982008-12-23 20:25:15 +000040
41struct gsm_lai {
42 u_int16_t mcc;
43 u_int16_t mnc;
44 u_int16_t lac;
45};
46
47static void parse_lai(struct gsm_lai *lai, const struct gsm48_loc_area_id *lai48)
48{
49 u_int8_t dig[4];
50
51 /* MCC */
52 dig[1] = lai48->digits[0] & 0x0f;
53 dig[2] = lai48->digits[0] >> 4;
54 dig[3] = lai48->digits[1] & 0x0f;
55 lai->mcc = dig[3] * 100 + dig[2];
56
57 /* MNC */
58 dig[1] = lai48->digits[1] >> 4;
59 dig[2] = lai48->digits[2] & 0x0f;
60 dig[3] = lai48->digits[2] >> 4;
61 lai->mnc = dig[3] * 100 + dig[2];
62
63 lai->lac = lai48->lac;
64}
65
66static void to_bcd(u_int8_t *bcd, u_int16_t val)
67{
Harald Welte4b634542008-12-27 01:55:51 +000068 bcd[2] = val % 10;
Harald Welte52b1f982008-12-23 20:25:15 +000069 val = val / 10;
70 bcd[1] = val % 10;
71 val = val / 10;
Harald Welte4b634542008-12-27 01:55:51 +000072 bcd[0] = val % 10;
Harald Welte52b1f982008-12-23 20:25:15 +000073 val = val / 10;
74}
75
76static void generate_lai(struct gsm48_loc_area_id *lai48, u_int16_t mcc,
77 u_int16_t mnc, u_int16_t lac)
78{
79 u_int8_t bcd[3];
80
81 to_bcd(bcd, mcc);
82 lai48->digits[0] = bcd[0] | (bcd[1] << 4);
83 lai48->digits[1] = bcd[2];
84
85 to_bcd(bcd, mnc);
Harald Welte4b634542008-12-27 01:55:51 +000086 /* FIXME: do we need three-digit MNC? See Table 10.5.3 */
87#if 0
Harald Welte8470bf22008-12-25 23:28:35 +000088 lai48->digits[1] |= bcd[2] << 4;
89 lai48->digits[2] = bcd[0] | (bcd[1] << 4);
Harald Welte4b634542008-12-27 01:55:51 +000090#else
91 lai48->digits[1] |= 0xf << 4;
92 lai48->digits[2] = bcd[1] | (bcd[2] << 4);
93#endif
Harald Welte52b1f982008-12-23 20:25:15 +000094
Harald Welte4b634542008-12-27 01:55:51 +000095 lai48->lac = htons(lac);
Harald Welte52b1f982008-12-23 20:25:15 +000096}
97
98#define TMSI_LEN 4
99#define MID_TMSI_LEN (TMSI_LEN + 2)
100
101static void generate_mid_from_tmsi(u_int8_t *buf, u_int8_t *tmsi_bcd)
102{
Harald Welte4b634542008-12-27 01:55:51 +0000103 buf[0] = GSM48_IE_MOBILE_ID;
104 buf[1] = MID_TMSI_LEN;
105 buf[2] = 0xf0 | GSM_MI_TYPE_TMSI;
106 buf[3] = tmsi_bcd[0];
107 buf[4] = tmsi_bcd[1];
108 buf[5] = tmsi_bcd[2];
109 buf[6] = tmsi_bcd[3];
Harald Welte52b1f982008-12-23 20:25:15 +0000110}
111
Harald Welte8470bf22008-12-25 23:28:35 +0000112static struct msgb *gsm48_msgb_alloc(void)
113{
114 return msgb_alloc_headroom(GSM48_ALLOC_SIZE, GSM48_ALLOC_HEADROOM);
115}
116
Harald Welte52b1f982008-12-23 20:25:15 +0000117static int gsm0408_sendmsg(struct msgb *msg)
118{
Harald Welte8470bf22008-12-25 23:28:35 +0000119 if (msg->lchan)
120 msg->trx = msg->lchan->ts->trx;
Harald Welte52b1f982008-12-23 20:25:15 +0000121
Harald Welte4b634542008-12-27 01:55:51 +0000122 msg->l3h = msg->data;
123
Harald Welte8470bf22008-12-25 23:28:35 +0000124 return rsl_data_request(msg, 0);
Harald Welte52b1f982008-12-23 20:25:15 +0000125}
126
Harald Welte4b634542008-12-27 01:55:51 +0000127static int gsm48_cc_tx_status(struct gsm_lchan *lchan)
128{
129 struct msgb *msg = gsm48_msgb_alloc();
130 struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh));
131 u_int8_t *cause, *call_state;
132
133 msg->lchan = lchan;
134
135 gh->proto_discr = GSM48_PDISC_CC;
136 gh->msg_type = GSM48_MT_CC_STATUS;
137
138 cause = msgb_put(msg, 3);
139 cause[0] = 2;
140 cause[1] = GSM48_CAUSE_CS_GSM | GSM48_CAUSE_LOC_USER;
141 cause[2] = 0x80 | 30; /* response to status inquiry */
142
143 call_state = msgb_put(msg, 1);
144 call_state[0] = 0xc0 | 0x00;
145
146 return gsm0408_sendmsg(msg);
147}
148
149static int gsm48_cc_rx_status_enq(struct msgb *msg)
150{
151 return gsm48_cc_tx_status(msg->lchan);
152}
153
Harald Welte52b1f982008-12-23 20:25:15 +0000154static int gsm0408_rcv_cc(struct msgb *msg)
155{
156 struct gsm48_hdr *gh = msgb_l3(msg);
Harald Welte4b634542008-12-27 01:55:51 +0000157 u_int8_t msg_type = gh->msg_type & 0xbf;
158 int rc = 0;
Harald Welte52b1f982008-12-23 20:25:15 +0000159
Harald Welte4b634542008-12-27 01:55:51 +0000160 switch (msg_type) {
Harald Welte52b1f982008-12-23 20:25:15 +0000161 case GSM48_MT_CC_CALL_CONF:
162 /* Response to SETUP */
163 DEBUGP(DCC, "CALL CONFIRM\n");
164 break;
165 case GSM48_MT_CC_RELEASE_COMPL:
166 DEBUGP(DCC, "RELEASE COMPLETE\n");
167 break;
168 case GSM48_MT_CC_ALERTING:
169 DEBUGP(DCC, "ALERTING\n");
170 break;
171 case GSM48_MT_CC_CONNECT:
172 DEBUGP(DCC, "CONNECT\n");
173 /* need to respond with CONNECT_ACK */
174 break;
175 case GSM48_MT_CC_RELEASE:
176 DEBUGP(DCC, "RELEASE\n");
177 /* need to respond with RELEASE_COMPLETE */
178 break;
Harald Welte4b634542008-12-27 01:55:51 +0000179 case GSM48_MT_CC_STATUS_ENQ:
180 rc = gsm48_cc_rx_status_enq(msg);
181 break;
182 case GSM48_MT_CC_DISCONNECT:
183 DEBUGP(DCC, "DISCONNECT\n");
184 break;
Harald Welte52b1f982008-12-23 20:25:15 +0000185 case GSM48_MT_CC_SETUP:
Harald Welte4b634542008-12-27 01:55:51 +0000186 DEBUGP(DCC, "SETUP\n");
Harald Welte52b1f982008-12-23 20:25:15 +0000187 /* FIXME: continue with CALL_PROCEEDING, ALERTING, CONNECT, RELEASE_COMPLETE */
Harald Welte4b634542008-12-27 01:55:51 +0000188 break;
189 case GSM48_MT_CC_EMERG_SETUP:
190 DEBUGP(DCC, "EMERGENCY SETUP\n");
191 /* FIXME: continue with CALL_PROCEEDING, ALERTING, CONNECT, RELEASE_COMPLETE */
192 break;
Harald Welte52b1f982008-12-23 20:25:15 +0000193 default:
194 fprintf(stderr, "Unimplemented GSM 04.08 msg type 0x%02x\n",
Harald Welte4b634542008-12-27 01:55:51 +0000195 msg_type);
Harald Welte52b1f982008-12-23 20:25:15 +0000196 break;
197 }
Harald Welte8470bf22008-12-25 23:28:35 +0000198
Harald Welte4b634542008-12-27 01:55:51 +0000199 return rc;
Harald Welte52b1f982008-12-23 20:25:15 +0000200}
201
202/* Chapter 9.2.14 : Send LOCATION UPDATE REJECT */
Harald Welte8470bf22008-12-25 23:28:35 +0000203int gsm0408_loc_upd_rej(struct gsm_lchan *lchan, u_int8_t cause)
Harald Welte52b1f982008-12-23 20:25:15 +0000204{
Harald Welte8470bf22008-12-25 23:28:35 +0000205 struct msgb *msg = gsm48_msgb_alloc();
Harald Welte52b1f982008-12-23 20:25:15 +0000206 struct gsm48_hdr *gh;
207
Harald Welte8470bf22008-12-25 23:28:35 +0000208 msg->lchan = lchan;
Harald Welte52b1f982008-12-23 20:25:15 +0000209
210 gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1);
211 gh->proto_discr = GSM48_PDISC_MM;
212 gh->msg_type = GSM48_MT_MM_LOC_UPD_ACCEPT;
213 gh->data[0] = cause;
214
215 DEBUGP(DMM, "-> LOCATION UPDATE REJECT\n");
216
217 return gsm0408_sendmsg(msg);
218}
219
220/* Chapter 9.2.13 : Send LOCATION UPDATE ACCEPT */
Harald Welte8470bf22008-12-25 23:28:35 +0000221int gsm0408_loc_upd_acc(struct gsm_lchan *lchan, u_int8_t *tmsi)
Harald Welte52b1f982008-12-23 20:25:15 +0000222{
Harald Welte8470bf22008-12-25 23:28:35 +0000223 struct gsm_bts *bts = lchan->ts->trx->bts;
224 struct msgb *msg = gsm48_msgb_alloc();
Harald Welte52b1f982008-12-23 20:25:15 +0000225 struct gsm48_hdr *gh;
226 struct gsm48_loc_area_id *lai;
227 u_int8_t *mid;
228
Harald Welte8470bf22008-12-25 23:28:35 +0000229 msg->lchan = lchan;
Harald Welte52b1f982008-12-23 20:25:15 +0000230
231 gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh));
232 gh->proto_discr = GSM48_PDISC_MM;
233 gh->msg_type = GSM48_MT_MM_LOC_UPD_ACCEPT;
234
235 lai = (struct gsm48_loc_area_id *) msgb_put(msg, sizeof(*lai));
236 generate_lai(lai, bts->network->country_code,
237 bts->network->network_code, bts->location_area_code);
238
239 mid = msgb_put(msg, MID_TMSI_LEN);
240 generate_mid_from_tmsi(mid, tmsi);
241
242 DEBUGP(DMM, "-> LOCATION UPDATE ACCEPT\n");
243
244 return gsm0408_sendmsg(msg);
245}
246
Harald Welte52b1f982008-12-23 20:25:15 +0000247/* Chapter 9.2.15 */
248static int mm_loc_upd_req(struct msgb *msg)
249{
Harald Welte8470bf22008-12-25 23:28:35 +0000250 struct gsm48_hdr *gh = msgb_l3(msg);
Harald Welte702d8702008-12-26 20:25:35 +0000251 struct gsm_bts *bts = msg->trx->bts;
Harald Welte52b1f982008-12-23 20:25:15 +0000252 struct gsm48_loc_upd_req *lu;
253 struct gsm_subscriber *subscr;
Harald Welte8470bf22008-12-25 23:28:35 +0000254 u_int8_t mi_type;
Harald Welte52b1f982008-12-23 20:25:15 +0000255
Harald Welte8470bf22008-12-25 23:28:35 +0000256 lu = (struct gsm48_loc_upd_req *) gh->data;
257
258 mi_type = lu->mi[0] & GSM_MI_TYPE_MASK;
Harald Welte52b1f982008-12-23 20:25:15 +0000259
Harald Welte4b634542008-12-27 01:55:51 +0000260 DEBUGP(DMM, "LUPDREQ: mi_type = 0x%02x\n", mi_type);
Harald Welte52b1f982008-12-23 20:25:15 +0000261 switch (mi_type) {
262 case GSM_MI_TYPE_IMSI:
263 /* look up subscriber based on IMSI */
264 subscr = subscr_get_by_imsi(&lu->mi[1]);
Harald Welte4b634542008-12-27 01:55:51 +0000265 break;
Harald Welte52b1f982008-12-23 20:25:15 +0000266 case GSM_MI_TYPE_TMSI:
267 /* look up the subscriber based on TMSI, request IMSI if it fails */
268 subscr = subscr_get_by_tmsi(&lu->mi[1]);
269 if (!subscr) {
270 /* FIXME: send IDENTITY REQUEST message to get IMSI */
271 //gsm0408_identity_request(...GSM_MI_TYPE_IMSI);
272 }
273 break;
274 case GSM_MI_TYPE_IMEI:
275 case GSM_MI_TYPE_IMEISV:
276 /* no sim card... FIXME: what to do ? */
277 fprintf(stderr, "Unimplemented mobile identity type\n");
278 break;
279 default:
280 fprintf(stderr, "Unknown mobile identity type\n");
281 break;
282 }
283
284 if (!subscr) {
285 /* 0x16 is congestion */
Harald Welte8470bf22008-12-25 23:28:35 +0000286 gsm0408_loc_upd_rej(msg->lchan, 0x16);
Harald Welte52b1f982008-12-23 20:25:15 +0000287 return -EINVAL;
288 }
289
Harald Welte8470bf22008-12-25 23:28:35 +0000290 msg->lchan->subscr = subscr;
Harald Welte52b1f982008-12-23 20:25:15 +0000291 subscr_update(subscr, bts);
Harald Welte8470bf22008-12-25 23:28:35 +0000292
293 return gsm0408_loc_upd_acc(msg->lchan, subscr->tmsi);
Harald Welte52b1f982008-12-23 20:25:15 +0000294}
295
Harald Welte4b634542008-12-27 01:55:51 +0000296static int gsm48_tx_mm_serv_ack(struct gsm_lchan *lchan)
297{
298 struct msgb *msg = gsm48_msgb_alloc();
299 struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh));
300
301 msg->lchan = lchan;
302
303 gh->proto_discr = GSM48_PDISC_MM;
304 gh->msg_type = GSM48_MT_MM_CM_SERV_ACC;
305
306 DEBUGP(DMM, "-> CM SERVICE ACK\n");
307
308 return gsm0408_sendmsg(msg);
309}
310
311static int gsm48_rx_mm_serv_req(struct msgb *msg)
312{
313 struct gsm48_hdr *gh = msgb_l3(msg);
314
315 DEBUGP(DMM, "CM SERVICE REQUEST\n");
316 return gsm48_tx_mm_serv_ack(msg->lchan);
317}
318
Harald Welte52b1f982008-12-23 20:25:15 +0000319static int gsm0408_rcv_mm(struct msgb *msg)
320{
321 struct gsm48_hdr *gh = msgb_l3(msg);
322 int rc;
323
324 switch (gh->msg_type & 0xbf) {
325 case GSM48_MT_MM_LOC_UPD_REQUEST:
326 DEBUGP(DMM, "LOCATION UPDATE REQUEST\n");
327 rc = mm_loc_upd_req(msg);
328 break;
329 case GSM48_MT_MM_ID_RESP:
330 case GSM48_MT_MM_TMSI_REALL_COMPL:
331 case GSM48_MT_MM_AUTH_RESP:
332 case GSM48_MT_MM_IMSI_DETACH_IND:
333 case GSM48_MT_MM_CM_SERV_REQ:
Harald Welte4b634542008-12-27 01:55:51 +0000334 rc = gsm48_rx_mm_serv_req(msg);
335 break;
Harald Welte52b1f982008-12-23 20:25:15 +0000336 case GSM48_MT_MM_CM_REEST_REQ:
337 fprintf(stderr, "Unimplemented GSM 04.08 MM msg type 0x%02x\n",
338 gh->msg_type);
339 break;
340 default:
341 fprintf(stderr, "Unknown GSM 04.08 MM msg type 0x%02x\n",
342 gh->msg_type);
343 break;
344 }
345
346 return rc;
347}
348static int gsm0408_rcv_rr(struct msgb *msg)
349{
350 struct gsm48_hdr *gh = msgb_l3(msg);
351
352 switch (gh->msg_type) {
353 case GSM48_MT_RR_CLSM_CHG:
354 DEBUGP(DRR, "CLASSMARK CHANGE\n");
355 /* FIXME: what to do ?!? */
356 break;
357 case GSM48_MT_RR_PAG_RESP:
358 default:
359 fprintf(stderr, "Unimplemented GSM 04.08 msg type 0x%02x\n",
360 gh->msg_type);
361 break;
362 }
363
364 return 0;
365}
366
367/* here we pass in a msgb from the RSL->RLL. We expect the l3 pointer to be set */
368int gsm0408_rcvmsg(struct msgb *msg)
369{
370 struct gsm48_hdr *gh = msgb_l3(msg);
371 u_int8_t pdisc = gh->proto_discr & 0x0f;
Harald Welte8470bf22008-12-25 23:28:35 +0000372 int rc = 0;
Harald Welte52b1f982008-12-23 20:25:15 +0000373
374 switch (pdisc) {
375 case GSM48_PDISC_CC:
376 rc = gsm0408_rcv_cc(msg);
377 break;
378 case GSM48_PDISC_MM:
379 rc = gsm0408_rcv_mm(msg);
380 break;
381 case GSM48_PDISC_RR:
382 rc = gsm0408_rcv_rr(msg);
383 break;
384 case GSM48_PDISC_MM_GPRS:
385 case GSM48_PDISC_SM:
386 fprintf(stderr, "Unimplemented GSM 04.08 discriminator 0x%02d\n",
387 pdisc);
388 break;
389 default:
390 fprintf(stderr, "Unknown GSM 04.08 discriminator 0x%02d\n",
391 pdisc);
392 break;
393 }
394
395 return rc;
396}
Harald Welte8470bf22008-12-25 23:28:35 +0000397
398enum chreq_type {
399 CHREQ_T_EMERG_CALL,
400 CHREQ_T_CALL_REEST_TCH_F,
401 CHREQ_T_CALL_REEST_TCH_H,
402 CHREQ_T_CALL_REEST_TCH_H_DBL,
403 CHREQ_T_SDCCH,
404 CHREQ_T_TCH_F,
405 CHREQ_T_VOICE_CALL_TCH_H,
406 CHREQ_T_DATA_CALL_TCH_H,
407 CHREQ_T_LOCATION_UPD,
408 CHREQ_T_PAG_R_ANY,
409 CHREQ_T_PAG_R_TCH_F,
410 CHREQ_T_PAG_R_TCH_FH,
411};
412
413/* Section 9.1.8 / Table 9.9 */
414struct chreq {
415 u_int8_t val;
416 u_int8_t mask;
417 enum chreq_type type;
418};
419
420/* If SYSTEM INFORMATION TYPE 4 NECI bit == 1 */
421static const struct chreq chreq_type_neci1[] = {
422 { 0xa0, 0xe0, CHREQ_T_EMERG_CALL },
423 { 0xc0, 0xe0, CHREQ_T_CALL_REEST_TCH_F },
424 { 0x68, 0xfc, CHREQ_T_CALL_REEST_TCH_H },
425 { 0x6c, 0xfc, CHREQ_T_CALL_REEST_TCH_H_DBL },
426 { 0xe0, 0xe0, CHREQ_T_SDCCH },
427 { 0x40, 0xf0, CHREQ_T_VOICE_CALL_TCH_H },
428 { 0x50, 0xf0, CHREQ_T_DATA_CALL_TCH_H },
429 { 0x00, 0xf0, CHREQ_T_LOCATION_UPD },
430 { 0x10, 0xf0, CHREQ_T_SDCCH },
431 { 0x80, 0xe0, CHREQ_T_PAG_R_ANY },
432 { 0x20, 0xf0, CHREQ_T_PAG_R_TCH_F },
433 { 0x30, 0xf0, CHREQ_T_PAG_R_TCH_FH },
434};
435
436/* If SYSTEM INFORMATION TYPE 4 NECI bit == 0 */
437static const struct chreq chreq_type_neci0[] = {
438 { 0xa0, 0xe0, CHREQ_T_EMERG_CALL },
439 { 0xc0, 0xe0, CHREQ_T_CALL_REEST_TCH_H },
440 { 0xe0, 0xe0, CHREQ_T_TCH_F },
441 { 0x50, 0xf0, CHREQ_T_DATA_CALL_TCH_H },
442 { 0x00, 0xe0, CHREQ_T_LOCATION_UPD },
443 { 0x80, 0xe0, CHREQ_T_PAG_R_ANY },
444 { 0x20, 0xf0, CHREQ_T_PAG_R_TCH_F },
445 { 0x30, 0xf0, CHREQ_T_PAG_R_TCH_FH },
446};
447
448static const enum gsm_chan_t ctype_by_chreq[] = {
449 [CHREQ_T_EMERG_CALL] = GSM_LCHAN_TCH_F,
450 [CHREQ_T_CALL_REEST_TCH_F] = GSM_LCHAN_TCH_F,
451 [CHREQ_T_CALL_REEST_TCH_H] = GSM_LCHAN_TCH_H,
452 [CHREQ_T_CALL_REEST_TCH_H_DBL] = GSM_LCHAN_TCH_H,
453 [CHREQ_T_SDCCH] = GSM_LCHAN_SDCCH,
454 [CHREQ_T_TCH_F] = GSM_LCHAN_TCH_F,
455 [CHREQ_T_VOICE_CALL_TCH_H] = GSM_LCHAN_TCH_H,
456 [CHREQ_T_DATA_CALL_TCH_H] = GSM_LCHAN_TCH_H,
457 [CHREQ_T_LOCATION_UPD] = GSM_LCHAN_SDCCH,
458 [CHREQ_T_PAG_R_ANY] = GSM_LCHAN_SDCCH,
459 [CHREQ_T_PAG_R_TCH_F] = GSM_LCHAN_TCH_F,
460 [CHREQ_T_PAG_R_TCH_FH] = GSM_LCHAN_TCH_F,
461};
462
463enum gsm_chan_t get_ctype_by_chreq(struct gsm_bts *bts, u_int8_t ra)
464{
465 int i;
466 /* FIXME: determine if we set NECI = 0 in the BTS SI4 */
467
468 for (i = 0; i < ARRAY_SIZE(chreq_type_neci0); i++) {
469 const struct chreq *chr = &chreq_type_neci0[i];
470 if ((ra & chr->mask) == chr->val)
471 return ctype_by_chreq[chr->type];
472 }
473 fprintf(stderr, "Unknown CHANNEL REQUEST RQD 0x%02x\n", ra);
474 return GSM_LCHAN_SDCCH;
475}