FreeCalypso > hg > freecalypso-citrine
comparison g23m-gsm/rr/rr_datp.c @ 0:75a11d740a02
initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 09 Jun 2016 00:02:41 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:75a11d740a02 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : | |
4 | Modul : | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : This Modul defines the functions for the data transfer | |
18 | capability of the module Radio Resource. | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 #ifndef RR_DATP_C | |
23 #define RR_DATP_C | |
24 | |
25 #include "config.h" | |
26 #include "fixedconf.h" | |
27 #include "condat-features.h" | |
28 | |
29 #define ENTITY_RR | |
30 | |
31 /*==== INCLUDES ===================================================*/ | |
32 | |
33 #include <string.h> | |
34 #include <stdlib.h> | |
35 #include <stddef.h> /* offsetof */ | |
36 #include <stdio.h> /* sprintf */ | |
37 #include "typedefs.h" | |
38 #include "pcm.h" | |
39 #include "pconst.cdg" | |
40 #include "mconst.cdg" | |
41 #include "message.h" | |
42 #include "ccdapi.h" | |
43 #include "vsi.h" | |
44 #include "custom.h" | |
45 #include "gsm.h" | |
46 #include "prim.h" | |
47 #include "cnf_rr.h" | |
48 #include "tok.h" | |
49 #include "rr.h" | |
50 #include "rr_em.h" | |
51 | |
52 /*==== EXPORT =====================================================*/ | |
53 #if defined (REL99) && defined (TI_PS_FF_EMR) | |
54 #define MAX_MSTRUCT_CCD_RR MAXIMUM(MAX_MSTRUCT_LEN_RR_SHORT, MAX_MSTRUCT_LEN_RR) | |
55 GLOBAL UBYTE _decodedMsg [MAX_MSTRUCT_CCD_RR]; | |
56 #else | |
57 GLOBAL UBYTE _decodedMsg [MAX_MSTRUCT_LEN_RR]; | |
58 #endif | |
59 | |
60 | |
61 /*==== PRIVAT =====================================================*/ | |
62 | |
63 /*==== VARIABLES ==================================================*/ | |
64 | |
65 /*==== FUNCTIONS ==================================================*/ | |
66 | |
67 /* | |
68 * ------------------------------------------------------------------- | |
69 * PRIMITIVE Processing functions | |
70 * ------------------------------------------------------------------- | |
71 */ | |
72 | |
73 /* | |
74 +--------------------------------------------------------------------+ | |
75 | PROJECT : GSM-PS (6147) MODULE : RR_DAT | | |
76 | STATE : code ROUTINE : dat_init_rr_data | | |
77 +--------------------------------------------------------------------+ | |
78 | |
79 PURPOSE : Initialize the RR data for the module data transfer. | |
80 | |
81 */ | |
82 | |
83 GLOBAL void dat_init_rr_data (void) | |
84 { | |
85 GET_INSTANCE_DATA; | |
86 TRACE_FUNCTION ("dat_init_rr_data()"); | |
87 | |
88 SET_STATE (STATE_DAT, DAT_NULL); | |
89 } | |
90 | |
91 | |
92 /* | |
93 +--------------------------------------------------------------------+ | |
94 | PROJECT : GSM-PS (6147) MODULE : RR_DAT | | |
95 | STATE : code ROUTINE : dat_dl_establish_cnf | | |
96 +--------------------------------------------------------------------+ | |
97 | |
98 PURPOSE : Process the primitive DL_ESTABLISH_CNF received from DL. | |
99 | |
100 */ | |
101 GLOBAL void dat_dl_establish_cnf (T_DL_ESTABLISH_CNF *dl_establish_cnf_orig) | |
102 { | |
103 GET_INSTANCE_DATA; | |
104 /* | |
105 * sys infos during l2 establishment are | |
106 * lost, inform layer 1 to send them again | |
107 */ | |
108 PPASS(dl_establish_cnf_orig, dl_establish_cnf, DL_ESTABLISH_CNF); | |
109 | |
110 TRACE_FUNCTION ("dat_dl_establish_cnf()"); | |
111 rr_data->net_lost = FALSE; | |
112 TRACE_EVENT_P1("rr_data->net_lost = %u", rr_data->net_lost); | |
113 | |
114 switch (GET_STATE (STATE_DAT)) | |
115 { | |
116 case DAT_CHAN_ASS_1: | |
117 case DAT_CHAN_ASS_2: | |
118 case DAT_IMM_ASS_1: | |
119 break; | |
120 | |
121 default : | |
122 if (dl_establish_cnf->sapi EQ SAPI_0) | |
123 { | |
124 PALLOC (mph_sync_req, MPH_SYNC_REQ); | |
125 mph_sync_req->cs = CS_CLEAN_SYS_INFO; | |
126 PSENDX (PL, mph_sync_req); | |
127 } | |
128 break; | |
129 } | |
130 | |
131 switch (GET_STATE (STATE_DAT)) | |
132 { | |
133 case DAT_CHAN_ASS_1: | |
134 /* | |
135 * successfull establishment of new layer 2 connection | |
136 * after channel assignment | |
137 */ | |
138 | |
139 EM_DL_ESTABLISH_CNF; | |
140 | |
141 PFREE (dl_establish_cnf); | |
142 | |
143 if (rr_data->sc_data.ch_mode NEQ | |
144 rr_data->cr_data.ch_mode) | |
145 { | |
146 /* | |
147 * a changed channel mode has been detected. | |
148 * update channel description and channel mode | |
149 * for the serving cell and inform MM about the | |
150 * new channel mode. | |
151 */ | |
152 memcpy (&rr_data->sc_data.chan_desc, | |
153 &rr_data->cr_data.chan_desc, | |
154 sizeof (T_chan_desc)); | |
155 rr_data->sc_data.ch_mode = rr_data->cr_data.ch_mode; | |
156 dat_code_channel_mode_to_mm (); | |
157 } | |
158 | |
159 if (rr_data->cr_data.ciph_on NEQ | |
160 rr_data->sc_data.ciph_on) | |
161 { | |
162 /* | |
163 * the ciphering has changed. Inform MM about the new | |
164 * ciphering. | |
165 */ | |
166 dat_code_ciphering_to_mm (rr_data->cr_data.ciph_on); | |
167 } | |
168 | |
169 /* | |
170 * copy cr data to sc data and go back to normal dedicated mode. | |
171 */ | |
172 rr_data->sc_data.ciph_on = rr_data->cr_data.ciph_on; | |
173 rr_data->sc_data.algo = rr_data->cr_data.algo; | |
174 rr_data->sc_data.ch_mode = rr_data->cr_data.ch_mode; | |
175 rr_data->sc_data.cd.v_cell_chan_desc = | |
176 rr_data->cr_data.cd.v_cell_chan_desc; | |
177 memcpy (&rr_data->sc_data.cd.cell_chan_desc, | |
178 &rr_data->cr_data.cd.cell_chan_desc, | |
179 sizeof (T_LIST)); | |
180 memcpy (&rr_data->sc_data.chan_desc, | |
181 &rr_data->cr_data.chan_desc, | |
182 sizeof (T_chan_desc)); | |
183 memcpy (&rr_data->sc_data.amr_conf, | |
184 &rr_data->cr_data.amr_conf, | |
185 sizeof (T_multirate_conf)); | |
186 | |
187 rr_data->nc_data[CR_INDEX].arfcn = NOT_PRESENT_16BIT; | |
188 att_remove_multiple_channels (); | |
189 SET_STATE (STATE_SAPI_3, SMS_IDLE); | |
190 srv_use_stored_prim (); | |
191 dat_set_last_used_channel (&rr_data->sc_data.chan_desc); | |
192 att_dat_dedicated (); | |
193 dat_emo_stop ( TRUE ); | |
194 SET_STATE (STATE_DAT, DAT_DEDICATED); | |
195 rr_data->mode_after_dedi = MODE_CELL_RESELECTION; | |
196 break; | |
197 | |
198 case DAT_CHAN_ASS_2: | |
199 /* | |
200 * successfull reconnection on old channel after failed | |
201 * channel assignment | |
202 * | |
203 * update some parameters to go back to normal dedicated mode. | |
204 */ | |
205 PFREE (dl_establish_cnf); | |
206 srv_use_stored_prim (); | |
207 SET_STATE (STATE_SAPI_3, SMS_IDLE); | |
208 att_dat_dedicated (); | |
209 rr_data->nc_data[CR_INDEX].arfcn = NOT_PRESENT_16BIT; | |
210 SET_STATE (STATE_DAT, DAT_DEDICATED); | |
211 | |
212 rr_data->mode_after_dedi = MODE_CELL_RESELECTION; | |
213 | |
214 EM_ASS_FAILURE_RECONNECT_SUCCESS; | |
215 | |
216 break; | |
217 | |
218 case DAT_DEDICATED: | |
219 /* | |
220 * An establish confirm in normal dedicated mode is only | |
221 * expected for short messages (SAPI 3) | |
222 */ | |
223 if (dl_establish_cnf->sapi EQ SAPI_3) | |
224 { | |
225 SET_STATE (STATE_SAPI_3, SMS_ESTABLISHED); | |
226 srv_use_stored_prim (); | |
227 } | |
228 PFREE (dl_establish_cnf); | |
229 break; | |
230 | |
231 case DAT_HANDOVER_4: | |
232 TRACE_EVENT ("DL_ESTABLISH_CNF"); | |
233 | |
234 EM_L2_CONNECTION_ESTABLISHED; | |
235 | |
236 PFREE (dl_establish_cnf); | |
237 | |
238 /* | |
239 * successfull establishment of new layer 2 connection | |
240 * after handover | |
241 */ | |
242 if (rr_data->sc_data.ch_mode NEQ | |
243 rr_data->cr_data.ch_mode) | |
244 { | |
245 /* | |
246 * a changed channel mode has been detected. | |
247 * update channel description and channel mode | |
248 * for the serving cell and inform MM about the | |
249 * new channel mode. | |
250 */ | |
251 memcpy (&rr_data->sc_data.chan_desc, | |
252 &rr_data->cr_data.chan_desc, | |
253 sizeof (T_chan_desc)); | |
254 rr_data->sc_data.ch_mode = rr_data->cr_data.ch_mode; | |
255 dat_code_channel_mode_to_mm (); | |
256 } | |
257 | |
258 if (rr_data->cr_data.ciph_on NEQ rr_data->sc_data.ciph_on) | |
259 { | |
260 /* | |
261 * the ciphering has changed. Inform MM about the new | |
262 * ciphering. | |
263 */ | |
264 dat_code_ciphering_to_mm (rr_data->cr_data.ciph_on); | |
265 } | |
266 | |
267 /* | |
268 * copy cr data to sc data and go back to normal dedicated mode. | |
269 */ | |
270 rr_data->sc_data.ciph_on = rr_data->cr_data.ciph_on; | |
271 rr_data->sc_data.algo = rr_data->cr_data.algo; | |
272 rr_data->sc_data.ch_mode = rr_data->cr_data.ch_mode; | |
273 rr_data->sc_data.cd.v_cell_chan_desc = | |
274 rr_data->cr_data.cd.v_cell_chan_desc; | |
275 memcpy (&rr_data->sc_data.cd.cell_chan_desc, | |
276 &rr_data->cr_data.cd.cell_chan_desc, | |
277 sizeof (T_LIST)); | |
278 memcpy (&rr_data->sc_data.chan_desc, | |
279 &rr_data->cr_data.chan_desc, | |
280 sizeof (T_chan_desc)); | |
281 memcpy (&rr_data->sc_data.amr_conf, | |
282 &rr_data->cr_data.amr_conf, | |
283 sizeof (T_multirate_conf)); | |
284 | |
285 rr_data->nc_data[SC_INDEX].bsic = rr_data->nc_data[CR_INDEX].bsic; | |
286 rr_data->nc_data[SC_INDEX].arfcn = rr_data->nc_data[CR_INDEX].arfcn; | |
287 rr_data->nc_data[CR_INDEX].arfcn = NOT_PRESENT_16BIT; | |
288 /* | |
289 * after a handover we cannot come back directly to the | |
290 * cell instead we have to do a normal cell reselection | |
291 */ | |
292 rr_data->mode_after_dedi = MODE_CELL_RESELECTION; | |
293 att_remove_multiple_channels (); | |
294 SET_STATE (STATE_SAPI_3, SMS_IDLE); | |
295 srv_use_stored_prim (); | |
296 dat_set_last_used_channel (&rr_data->sc_data.chan_desc); | |
297 att_dat_dedicated (); | |
298 dat_emo_stop ( TRUE ); | |
299 SET_STATE (STATE_DAT, DAT_DEDICATED); | |
300 break; | |
301 | |
302 case DAT_HANDOVER_5: | |
303 TRACE_EVENT ("DL_ESTABLISH_CNF"); | |
304 /* | |
305 * successfull reconnection on old channel after failed | |
306 * handover | |
307 * | |
308 * update some parameters to go back to normal dedicated mode. | |
309 */ | |
310 PFREE (dl_establish_cnf); | |
311 srv_use_stored_prim (); | |
312 SET_STATE (STATE_SAPI_3, SMS_IDLE); | |
313 att_dat_dedicated (); | |
314 rr_data->nc_data[CR_INDEX].arfcn = NOT_PRESENT_16BIT; | |
315 SET_STATE (STATE_DAT, DAT_DEDICATED); | |
316 | |
317 rr_data->mode_after_dedi = MODE_CELL_RESELECTION; | |
318 | |
319 EM_HO_FAILURE_RECONNECT_SUCCESS; | |
320 break; | |
321 | |
322 case DAT_IMM_ASS_1: | |
323 /* | |
324 * successfull establishment of a dedicated connection. | |
325 * Depending on the originator of the connection MM | |
326 * is informed. | |
327 */ | |
328 EM_L2_CONNECTION_ESTABLISHED; | |
329 | |
330 #ifdef GPRS | |
331 if(! dat_check_packet_access()) | |
332 { | |
333 #endif | |
334 if (rr_data->ms_data.establish_cause EQ ESTCS_PAGING) | |
335 { | |
336 PREUSE (dl_establish_cnf, rr_establish_ind, RR_ESTABLISH_IND); | |
337 PSENDX (MM, rr_establish_ind); | |
338 } | |
339 else | |
340 { | |
341 PREUSE (dl_establish_cnf, rr_establish_cnf, RR_ESTABLISH_CNF); | |
342 PSENDX (MM, rr_establish_cnf); | |
343 } | |
344 #ifdef GPRS | |
345 } | |
346 else | |
347 { /* packet access */ | |
348 PFREE (dl_establish_cnf); | |
349 } | |
350 #endif | |
351 | |
352 /* | |
353 * initialize some variables for the dedicated mode. | |
354 */ | |
355 rr_data->dyn_config.fho = 0; | |
356 rr_data->dyn_config.fca = 0; | |
357 rr_data->tch_loop_subch = NOT_PRESENT_8BIT; | |
358 rr_data->sc_data.ciph_received = FALSE; | |
359 rr_data->rel_cause = RRCS_INT_NOT_PRESENT; | |
360 rr_data->sc_data.ciph_on = CIPH_OFF; | |
361 att_copy_old_lai_rac(SC_INDEX); | |
362 #if 0 | |
363 memcpy (&rr_data->old_lai, | |
364 &rr_data->nc_data[SC_INDEX].lai, | |
365 sizeof (rr_data->old_lai)); | |
366 rr_data->old_cell_id = rr_data->nc_data[SC_INDEX].cell_id; | |
367 #endif | |
368 SET_STATE (STATE_SAPI_3, SMS_IDLE); | |
369 att_dat_dedicated (); | |
370 SET_STATE (STATE_DAT, DAT_DEDICATED); | |
371 | |
372 /* | |
373 * Early classmark Sending is performed if the mobile supports it | |
374 * and the network requests it. | |
375 */ | |
376 | |
377 if (rr_data->ms_data.classmark2.es_ind AND | |
378 rr_data->nc_data[SC_INDEX].c2_par.ecsc) | |
379 { | |
380 /* | |
381 * building of the Early Classmark Sending message | |
382 */ | |
383 /* Implements RR Clone findings #15 */ | |
384 dat_class_chng_data_req(); | |
385 } | |
386 | |
387 #ifdef GPRS | |
388 dat_gprs_suspend_req (); | |
389 #endif | |
390 | |
391 EM_EARLY_CLASSMARK_SENDING; | |
392 break; | |
393 | |
394 #ifdef GPRS | |
395 case DAT_PDCH_ASS_4: | |
396 dat_rrgrr_reconnect_dcch_cnf (RECONN_OK); | |
397 SET_STATE (STATE_DAT, DAT_DEDICATED); | |
398 PFREE (dl_establish_cnf); | |
399 break; | |
400 | |
401 case DAT_CCO_4: | |
402 if ( rr_data->gprs_data.cco_need_reconnect_cnf ) | |
403 { | |
404 dat_rrgrr_reconnect_dcch_cnf (RECONN_OK); | |
405 } | |
406 else | |
407 { | |
408 /* | |
409 * GRR has received d_change_order message, | |
410 * but the BCCH reading in the new cell failed. | |
411 * The connection is resumed on the old channel | |
412 * in dedicated mode. | |
413 */ | |
414 | |
415 PALLOC (rrgrr_sync_ind, RRGRR_SYNC_IND); | |
416 rrgrr_sync_ind->sync_res = SYNC_FAILED; | |
417 PSENDX (GRR, rrgrr_sync_ind); | |
418 } | |
419 SET_STATE (STATE_DAT, DAT_DEDICATED); | |
420 PFREE (dl_establish_cnf); | |
421 break; | |
422 #endif | |
423 | |
424 default: | |
425 PFREE (dl_establish_cnf); | |
426 break; | |
427 } | |
428 } | |
429 | |
430 /* | |
431 +--------------------------------------------------------------------+ | |
432 | PROJECT : GSM-PS (6147) MODULE : RR_DAT | | |
433 | STATE : code ROUTINE : dat_dl_establish_ind | | |
434 +--------------------------------------------------------------------+ | |
435 | |
436 PURPOSE : Process the primitive DL_ESTABLISH_IND received from DL. | |
437 This is only expected for short messages on SAPI 3 during | |
438 a connection. | |
439 | |
440 */ | |
441 | |
442 GLOBAL void dat_dl_establish_ind (T_DL_ESTABLISH_IND *dl_establish_ind) | |
443 { | |
444 GET_INSTANCE_DATA; | |
445 | |
446 TRACE_FUNCTION ("dat_dl_establish_ind()"); | |
447 | |
448 switch (GET_STATE (STATE_DAT)) | |
449 { | |
450 case DAT_DEDICATED: | |
451 /* | |
452 * if it indicates a mobile terminated connection establishment | |
453 * for SAPI 3 in the layer 2, change the state in RR for SMS. | |
454 * Answers from upper layer for SMS can be forwarded then | |
455 * immediately. | |
456 */ | |
457 if (dl_establish_ind->sapi EQ SAPI_3) | |
458 { | |
459 /* | |
460 * set state for SMS if it is on SAPI 3 | |
461 */ | |
462 SET_STATE (STATE_SAPI_3, SMS_ESTABLISHED); | |
463 srv_use_stored_prim (); | |
464 } | |
465 break; | |
466 | |
467 default: | |
468 break; | |
469 } | |
470 PFREE (dl_establish_ind); | |
471 } | |
472 | |
473 /* | |
474 +--------------------------------------------------------------------+ | |
475 | PROJECT : GSM-PS (6147) MODULE : RR_DAT | | |
476 | STATE : code ROUTINE : dat_mph_random_access_cnf | | |
477 +--------------------------------------------------------------------+ | |
478 | |
479 PURPOSE : Layer 1 confirms with the primitive MPH_RANDOM_ACCESS_CNF | |
480 the sending of a random burst during connection establishment. | |
481 | |
482 */ | |
483 | |
484 GLOBAL void dat_mph_random_access_cnf (T_MPH_RANDOM_ACCESS_CNF *mph_random_access_cnf) | |
485 { | |
486 GET_INSTANCE_DATA; | |
487 TRACE_FUNCTION ("dat_mph_random_access_cnf()"); | |
488 | |
489 EM_CHANNEL_REQUEST_SENT; | |
490 | |
491 switch (GET_STATE (STATE_DAT)) | |
492 { | |
493 case DAT_IMM_ASS: | |
494 if (rr_data->ms_data.access_counter < rr_data->ms_data.max_attempt) | |
495 { | |
496 /* | |
497 * if it the last or less then last random burst | |
498 * copy the frame number of the random burst for later | |
499 * comparision with the request reference of an immediate | |
500 * assignment message. | |
501 */ | |
502 memcpy (&rr_data->used_frame_no[rr_data->ms_data.access_counter], | |
503 &mph_random_access_cnf->frame_no, | |
504 sizeof (T_frame_no)); | |
505 | |
506 /* | |
507 TRACE_EVENT_P5 ("RA %u CNF: %d %d %d 0x%02x", | |
508 rr_data->ms_data.access_counter, | |
509 mph_random_access_cnf->frame_no.t1, | |
510 mph_random_access_cnf->frame_no.t2, | |
511 mph_random_access_cnf->frame_no.t3, | |
512 rr_data->used_channel_ref[rr_data->ms_data.access_counter]); | |
513 */ | |
514 | |
515 /* | |
516 * increment the number of already sent messages | |
517 */ | |
518 rr_data->ms_data.access_counter++; | |
519 | |
520 if (rr_data->ms_data.access_counter EQ rr_data->ms_data.max_attempt) | |
521 { | |
522 /* | |
523 * T3126 and T3146 (GPRS Packet Access on CCCH) are | |
524 * the same so use them for both purposes | |
525 * | |
526 * if it is the last random burst, start T3126 if the timer is not | |
527 * running yet (can be started after reception of an immediate | |
528 * assignment reject message). | |
529 * The timer controls reception of an immediate assignment message | |
530 * as response to the random bursts. | |
531 */ | |
532 /* Implements Measure#32: Row 196,197 */ | |
533 (IS_TIMER_ACTIVE(T3126)) ? | |
534 TRACE_TIMER ( "T3126 re-start") : TRACE_TIMER ( "T3126 start"); | |
535 | |
536 if (! IS_TIMER_ACTIVE(T3126)) | |
537 { | |
538 TIMERSTART (T3126, T3126_VALUE); | |
539 } | |
540 | |
541 /* | |
542 * set a flag that all random bursts are send and confirmed. | |
543 */ | |
544 rr_data->ms_data.all_conf_received = TRUE; | |
545 } | |
546 } | |
547 break; | |
548 | |
549 default: | |
550 break; | |
551 } | |
552 PFREE (mph_random_access_cnf); | |
553 } | |
554 | |
555 /* | |
556 +--------------------------------------------------------------------+ | |
557 | PROJECT : GSM-PS (6147) MODULE : RR_DAT | | |
558 | STATE : code ROUTINE : dat_dl_release_cnf | | |
559 +--------------------------------------------------------------------+ | |
560 | |
561 PURPOSE : Layer 2 confirms with DL_RELEASE_CNF a disconnection on | |
562 layer 2 which has been initiated by RR. | |
563 | |
564 */ | |
565 | |
566 GLOBAL void dat_dl_release_cnf (T_DL_RELEASE_CNF *dl_release_cnf) | |
567 { | |
568 GET_INSTANCE_DATA; | |
569 TRACE_FUNCTION ("dat_dl_release_cnf()"); | |
570 | |
571 switch (GET_STATE (STATE_DAT)) | |
572 { | |
573 case DAT_CHAN_REL: | |
574 /* | |
575 * after reception of a channel release message RR has | |
576 * started disconnection to come from dedicated to idle | |
577 * mode. Stop T3110, which controls the disconnection in | |
578 * layer 2. | |
579 */ | |
580 TIMERSTOP (T3110); | |
581 /* | |
582 * Send STOP_DEDICATED_REQUEST to L1 and wait for confirmation | |
583 */ | |
584 att_stop_dedicated(); | |
585 break; | |
586 | |
587 #ifdef GPRS | |
588 case DAT_PDCH_ASS_2: | |
589 dat_rrgrr_resumed_tbf_cnf(); | |
590 rr_data->gprs_data.tbf_est = TBF_EST_NONE; /* the initial state */ | |
591 break; | |
592 #endif | |
593 | |
594 case DAT_HANDOVER_4: | |
595 TRACE_EVENT ("Event: DAT_HANDOVER_4"); | |
596 /* | |
597 * the layer 2 resumption on the new channel during handover | |
598 * has failed and RR switches back to the old channel. | |
599 */ | |
600 dat_code_mph_old_chan_req (); | |
601 SET_STATE (STATE_DAT, DAT_HANDOVER_5); | |
602 break; | |
603 | |
604 case DAT_CHAN_ASS_1: | |
605 /* | |
606 * resumption of layer 2 has failed after channel assignment | |
607 * go back to the old channel. | |
608 */ | |
609 dat_code_mph_old_chan_req (); | |
610 SET_STATE (STATE_DAT, DAT_CHAN_ASS_2); | |
611 break; | |
612 | |
613 case DAT_DEDICATED: | |
614 case DAT_CHAN_ASS: | |
615 case DAT_CHAN_ASS_2: | |
616 case DAT_HANDOVER_5: | |
617 TRACE_EVENT ("Event: DAT_DEDICATED, DAT_CHAN_ASS, DAT_CHAN_ASS_2 or DAT_HANDOVER_5"); | |
618 | |
619 if (dl_release_cnf->sapi EQ SAPI_3) | |
620 { | |
621 /* | |
622 * the connection for SAPI 3 is disconnected by the | |
623 * network. | |
624 */ | |
625 SET_STATE (STATE_SAPI_3, SMS_IDLE); | |
626 dat_rr_release_ind(RRCS_DATA_LINK_FAIL, SAPI_3); | |
627 | |
628 /* | |
629 * clear any stored SAPI 3 message | |
630 */ | |
631 srv_clear_stored_prim (RR_DATA_REQ); | |
632 } | |
633 else | |
634 { | |
635 /* | |
636 * the reconnection to the old channel has failed | |
637 * or a lower layer failure had happen. | |
638 * Indicate the abort to MM and start cell reselection. | |
639 */ | |
640 switch (GET_STATE (STATE_DAT)) | |
641 { | |
642 case DAT_CHAN_ASS: | |
643 case DAT_CHAN_ASS_2: | |
644 TRACE_EVENT("Assignment failed: reconnect failed"); | |
645 EM_ASS_FAILURE_RECONNECT_FAILED; | |
646 break; | |
647 case DAT_HANDOVER_5: | |
648 TRACE_EVENT("Handover failed: reconnect failed"); | |
649 EM_HO_FAILURE_RECONNECT_FAILED; | |
650 break; | |
651 default: | |
652 break; | |
653 } | |
654 | |
655 att_code_rr_abort_ind (RRCS_DATA_LINK_FAIL); | |
656 | |
657 rr_data->net_lost = TRUE; | |
658 att_stop_dedicated(); | |
659 } | |
660 break; | |
661 | |
662 case DAT_IMM_ASS_1: | |
663 /* | |
664 * Layer 2 establishment has failed for immediate assignment | |
665 * Stop dedicated and go back to idle mode. MM will be informed about | |
666 * release after receiving MPH_STOP_DEDICATED_CNF from L1. | |
667 */ | |
668 if (rr_data->ms_data.establish_cause NEQ ESTCS_PAGING) | |
669 { | |
670 rr_data->rel_cause = RRCS_DL_EST_FAIL; | |
671 } | |
672 att_stop_dedicated(); | |
673 break; | |
674 | |
675 default: | |
676 break; | |
677 } | |
678 PFREE (dl_release_cnf); | |
679 } | |
680 | |
681 /* | |
682 +--------------------------------------------------------------------+ | |
683 | PROJECT : GSM-PS (6147) MODULE : RR_DAT | | |
684 | STATE : code ROUTINE : dat_dl_release_ind | | |
685 +--------------------------------------------------------------------+ | |
686 | |
687 PURPOSE : Layer 2 indicates disconnection due to layer 2 problems. | |
688 | |
689 */ | |
690 | |
691 GLOBAL void dat_dl_release_ind (T_DL_RELEASE_IND *dl_release_ind) | |
692 { | |
693 GET_INSTANCE_DATA; | |
694 TRACE_FUNCTION ("dat_dl_release_ind()"); | |
695 | |
696 switch (GET_STATE (STATE_DAT)) | |
697 { | |
698 case DAT_CHAN_ASS: | |
699 case DAT_CHAN_ASS_2: | |
700 case DAT_DEDICATED: | |
701 case DAT_HANDOVER: | |
702 case DAT_HANDOVER_5: | |
703 TRACE_EVENT ("DL_RELEASE_IND"); | |
704 if (dl_release_ind->sapi EQ SAPI_3) | |
705 { | |
706 /* | |
707 * indicate release for SAPI 3 (SMS) | |
708 * to MM and reset RR state back to SMS_IDLE. | |
709 */ | |
710 dat_rr_release_ind(RRCS_DATA_LINK_FAIL, SAPI_3); | |
711 SET_STATE (STATE_SAPI_3, SMS_IDLE); | |
712 /* | |
713 * clear any stored SAPI 3 message | |
714 */ | |
715 srv_clear_stored_prim (RR_DATA_REQ); | |
716 } | |
717 else | |
718 { | |
719 /* | |
720 * Delay 4 frames to allow sending UA response | |
721 * in RF for FTA testcase 25.2.3 | |
722 * else the idle mode is configured too early. | |
723 * vsi_t_sleep (VSI_CALLER FOUR_FRAMES); | |
724 * | |
725 * msb: DL delays the release indication itself for completion of the | |
726 * UA response transmission. | |
727 */ | |
728 EM_DL_RELEASE_IND; | |
729 | |
730 /* | |
731 * Inform MM about the release and start cell reselection. | |
732 */ | |
733 att_code_rr_abort_ind (RRCS_DATA_LINK_FAIL); | |
734 | |
735 rr_data->net_lost = TRUE; | |
736 att_stop_dedicated(); | |
737 } | |
738 break; | |
739 | |
740 case DAT_CHAN_ASS_1: | |
741 /* | |
742 * resumption of layer 2 has failed after channel assignment | |
743 * go back to the old channel. | |
744 */ | |
745 dat_code_mph_old_chan_req (); | |
746 SET_STATE (STATE_DAT, DAT_CHAN_ASS_2); | |
747 | |
748 EM_ASS_FAILURE_RECONNECT_FAILED2 | |
749 break; | |
750 | |
751 case DAT_CHAN_REL: | |
752 /* | |
753 * after reception of a channel release message RR has | |
754 * started disconnection to come from dedicated to idle | |
755 * mode. Stop T3110, which controls the disconnection in | |
756 * layer 2. | |
757 */ | |
758 TIMERSTOP (T3110); | |
759 | |
760 /* | |
761 * Send STOP_DEDICATED_REQUEST to L1 and wait for confirmation | |
762 */ | |
763 att_stop_dedicated(); | |
764 | |
765 EM_L2_CONNECTION_LOST; | |
766 break; | |
767 | |
768 case DAT_HANDOVER_4: | |
769 TRACE_EVENT ("DL_RELEASE_IND"); | |
770 /* | |
771 * resumption of layer 2 has failed handover | |
772 * go back to the old channel. | |
773 */ | |
774 dat_code_mph_old_chan_req (); | |
775 SET_STATE (STATE_DAT, DAT_HANDOVER_5); | |
776 | |
777 EM_HO_FAILURE_RECONNECT_FAILED2; | |
778 | |
779 break; | |
780 | |
781 case DAT_IMM_ASS_1: | |
782 | |
783 /* | |
784 * layer 2 establishment has failed during immediate assignment | |
785 */ | |
786 if (dl_release_ind->cs EQ DL_INFO_FIELD_MISMATCH AND | |
787 rr_data->sc_data.first_attempt) | |
788 { | |
789 /* | |
790 * if the reason is a mismatch in the layer 3 messages in SABM | |
791 * and the response UA, a second attempt of establishment is started. | |
792 */ | |
793 rr_data->sc_data.first_attempt = FALSE; | |
794 rr_data->repeat_est = TRUE; | |
795 #ifdef GPRS | |
796 if (rr_data->ms_data.establish_cause EQ ESTCS_GPRS_PAGING) | |
797 rr_data->dcch_stop_cause = CONTENTION_RESOLUTION_FAIL; | |
798 #endif | |
799 } | |
800 else | |
801 { | |
802 switch (rr_data->ms_data.establish_cause) | |
803 { | |
804 #ifdef GPRS | |
805 case ESTCS_GPRS_PAGING: | |
806 rr_data->dcch_stop_cause = DL_ESTABLISHMENT_FAIL; | |
807 break; | |
808 case ESTCS_PAGING: | |
809 rr_data->rel_cause = RRCS_INT_NOT_PRESENT; | |
810 #else | |
811 case ESTCS_PAGING: | |
812 #endif | |
813 break; | |
814 default: | |
815 rr_data->rel_cause = RRCS_DL_EST_FAIL; | |
816 break; | |
817 } | |
818 } | |
819 | |
820 /* | |
821 * Stop dedicated and go back to idle mode. | |
822 */ | |
823 att_stop_dedicated(); | |
824 break; | |
825 | |
826 #ifdef GPRS | |
827 case DAT_PDCH_ASS_4: | |
828 case DAT_CCO_4: | |
829 if ( GET_STATE (STATE_DAT) EQ DAT_PDCH_ASS_4 OR | |
830 rr_data->gprs_data.cco_need_reconnect_cnf ) | |
831 { | |
832 dat_rrgrr_reconnect_dcch_cnf (RECONN_LOW_FAIL); | |
833 } | |
834 att_build_idle_req (SC_INDEX, MODE_CELL_RESELECTION); | |
835 SET_STATE (STATE_DAT, DAT_IDLE); | |
836 break; | |
837 #endif | |
838 | |
839 default: | |
840 break; | |
841 } | |
842 PFREE (dl_release_ind); | |
843 } | |
844 | |
845 /* | |
846 +--------------------------------------------------------------------+ | |
847 | PROJECT : GSM-PS (6147) MODULE : RR_DAT | | |
848 | STATE : code ROUTINE : dat_mph_dedicated_cnf | | |
849 +--------------------------------------------------------------------+ | |
850 | |
851 PURPOSE : Layer 1 confirms the configuration of a dedicated channel. | |
852 | |
853 */ | |
854 | |
855 GLOBAL void dat_mph_dedicated_cnf (T_MPH_DEDICATED_CNF *mph_dedicated_cnf) | |
856 { | |
857 GET_INSTANCE_DATA; | |
858 TRACE_FUNCTION ("dat_mph_dedicated_cnf()"); | |
859 | |
860 switch (GET_STATE (STATE_DAT)) | |
861 { | |
862 case DAT_IMM_ASS_1: | |
863 /* | |
864 * A dedicated channel has been configured after | |
865 * reception of the immediate assignment message. | |
866 * | |
867 * clear neighbourcell list and start layer 2 establishment | |
868 */ | |
869 srv_clear_list (&rr_data->sc_data.cd.ncell_list); | |
870 srv_clear_list (&rr_data->sc_data.five_ter_list); | |
871 att_clean_buf (IND_ALL_DEDI_SI); | |
872 rr_data->sc_data.cd.sys_info_read &= ~ALL_DEDI_SYS_INFOS; | |
873 /* | |
874 * from now on we have a channel assigned | |
875 * even if the contention resolution is not | |
876 * done yet. If the contention resolution fails | |
877 * we use the same procedure for selecting a cell | |
878 * as in dedicated mode | |
879 */ | |
880 | |
881 rr_data->mode_after_dedi = MODE_CELL_SELECTION; /* default mode */ | |
882 TIMERSTART (T_DEDICATED_MODE, THIRTY_SEC); | |
883 #ifdef GPRS | |
884 if(! dat_gprs_start_sabm()) | |
885 #endif | |
886 dat_start_sabm (); | |
887 break; | |
888 | |
889 case DAT_CHAN_ASS: | |
890 | |
891 if (rr_data->dyn_config.fca) | |
892 { | |
893 /* | |
894 * special testfeature to force a failed layer 2 establishment | |
895 * during channel assignment. Reset flag and switch back to old | |
896 * channel. | |
897 */ | |
898 rr_data->dyn_config.fca = 0; | |
899 dat_code_mph_old_chan_req (); | |
900 SET_STATE (STATE_DAT, DAT_CHAN_ASS_2); | |
901 } | |
902 else | |
903 { | |
904 /* | |
905 * Resume layer 2 connection on the new channel with | |
906 * an assignment complete message. | |
907 */ | |
908 MCAST (assign_com, U_ASSIGN_COMP); | |
909 PALLOC_MSG ( dl_resume_req, DL_RESUME_REQ, U_ASSIGN_COMP); | |
910 | |
911 SET_STATE (STATE_DAT, DAT_CHAN_ASS_1); | |
912 assign_com->msg_type = U_ASSIGN_COMP; | |
913 assign_com->rr_cause = RRC_NORMAL_EVENT; | |
914 | |
915 /* | |
916 * set channel and sapi for the new channel description | |
917 */ | |
918 dat_code_prr_channel (&dl_resume_req->ch_type, | |
919 &dl_resume_req->sapi, | |
920 rr_data->cr_data.chan_desc.chan_type); | |
921 | |
922 /* | |
923 * start layer 2 resumption. | |
924 */ | |
925 for_dat_resume_req (dl_resume_req); | |
926 EM_ASSIGNMENT_COMPLETE; | |
927 } | |
928 break; | |
929 | |
930 #ifdef GPRS | |
931 case DAT_PDCH_ASS: | |
932 /* | |
933 * The current channel has been stopped at the Physical Layer. | |
934 */ | |
935 dat_rrgrr_suspend_dcch_cnf(); | |
936 SET_STATE (STATE_DAT, DAT_PDCH_ASS_1); | |
937 SET_STATE (STATE_GPRS, GPRS_PIM_BCCH); /* force MPH_IDLE_REQ with RRGRR_STOP_MON_CCCH_REQ */ | |
938 rr_data->gprs_data.tbf_est = TBF_EST_PDCH; | |
939 break; | |
940 #endif | |
941 | |
942 case DAT_HANDOVER: | |
943 { | |
944 /* | |
945 * clearing of neighbourcells is already done | |
946 * after reception of the handover command. | |
947 * | |
948 * following behaviour depends on the result of | |
949 * handover execution in layer 1. | |
950 */ | |
951 switch (mph_dedicated_cnf->dedi_res) | |
952 { | |
953 case DEDI_RES_OK: | |
954 /* | |
955 * handover is successfull. | |
956 */ | |
957 if (rr_data->dyn_config.fca) | |
958 { | |
959 /* | |
960 * special testfeature to simulate | |
961 * failed handover, reset flag | |
962 * and start reconnection. | |
963 */ | |
964 rr_data->dyn_config.fca = 0; | |
965 dat_code_mph_old_chan_req (); | |
966 SET_STATE (STATE_DAT, DAT_HANDOVER_5); | |
967 } | |
968 else | |
969 { | |
970 /* | |
971 * build a handover complete message. | |
972 */ | |
973 MCAST (handov_comp, U_HANDOV_COMP); | |
974 PALLOC_MSG (dl_resume, DL_RESUME_REQ, U_HANDOV_COMP); | |
975 | |
976 if (rr_data->ms_data.ho_type.rot EQ TIME_DIFF_YES) | |
977 { | |
978 /* | |
979 * handover command has requested the observed time difference. | |
980 */ | |
981 handov_comp->v_mob_time_diff = TRUE; | |
982 handov_comp->mob_time_diff.diff = rr_data->sc_data.observed_ta; | |
983 } | |
984 else | |
985 { | |
986 handov_comp->v_mob_time_diff = FALSE; | |
987 } | |
988 | |
989 handov_comp->msg_type = U_HANDOV_COMP; | |
990 handov_comp->rr_cause = RRC_NORMAL_EVENT; | |
991 | |
992 /* | |
993 * set channel type and sapi for the new channel | |
994 */ | |
995 dat_code_prr_channel (&dl_resume->ch_type, | |
996 &dl_resume->sapi, | |
997 rr_data->cr_data.chan_desc.chan_type); | |
998 | |
999 EM_HANDOVER_COMPLETE; | |
1000 | |
1001 /* | |
1002 * start layer 2 resumption. | |
1003 */ | |
1004 for_dat_resume_req (dl_resume); | |
1005 SET_STATE (STATE_DAT, DAT_HANDOVER_4); | |
1006 } | |
1007 break; | |
1008 | |
1009 case DEDI_RES_TIMEOUT: | |
1010 /* | |
1011 * the timer T3124 during an asynchronous handover | |
1012 * has timed out, start reconnection. | |
1013 */ | |
1014 dat_code_mph_old_chan_req (); | |
1015 SET_STATE (STATE_DAT, DAT_HANDOVER_5); | |
1016 break; | |
1017 | |
1018 case DEDI_RES_CELL_NOT_SYNC : | |
1019 /* | |
1020 * Timing Info for this cell is not present in ALR. | |
1021 * This could be due to : | |
1022 * a) Cell not present in BA list, | |
1023 * b) Synchronization to this cell failed or not attempted. | |
1024 */ | |
1025 case DEDI_RES_TA_OUT_OF_RANGE: | |
1026 { | |
1027 /* | |
1028 * Layer 1 has detected that the timing advance is out of range. | |
1029 * In fact the new channel has not been configured and RR | |
1030 * can start reconnection to the old layer 2 connection immediately. | |
1031 * It sends a handover failure message with the expected cause. | |
1032 */ | |
1033 MCAST (handov_fail, U_HANDOV_FAIL); | |
1034 PALLOC_MSG (dl_reconnect_req, DL_RECONNECT_REQ, U_HANDOV_FAIL); | |
1035 | |
1036 /* | |
1037 * set channel type and sapi for the old channel | |
1038 */ | |
1039 dat_code_prr_channel (&dl_reconnect_req->ch_type, | |
1040 &dl_reconnect_req->sapi, | |
1041 rr_data->sc_data.chan_desc.chan_type); | |
1042 handov_fail->msg_type = U_HANDOV_FAIL; | |
1043 | |
1044 if( mph_dedicated_cnf->dedi_res EQ DEDI_RES_TA_OUT_OF_RANGE) | |
1045 handov_fail->rr_cause = RRC_TIME_ADVANCE; | |
1046 else if ( mph_dedicated_cnf->dedi_res EQ DEDI_RES_CELL_NOT_SYNC) | |
1047 #if defined (REL99) && defined (FF_BHO) | |
1048 handov_fail->rr_cause = RRC_LOWER_LAYER_FAIL; | |
1049 #else | |
1050 handov_fail->rr_cause = RRC_CHAN_UNACCEPT; | |
1051 #endif | |
1052 RR_EM_SET_HANDOVER_FAIL_CAUSE(handov_fail->rr_cause); | |
1053 | |
1054 /* | |
1055 * start reconnection of the layer 2 link on the old channel. | |
1056 */ | |
1057 for_dat_reconnect_req (dl_reconnect_req); | |
1058 SET_STATE (STATE_DAT, DAT_HANDOVER_5); | |
1059 | |
1060 break; | |
1061 } | |
1062 } | |
1063 break; | |
1064 } | |
1065 | |
1066 default: | |
1067 break; | |
1068 } | |
1069 PFREE (mph_dedicated_cnf); | |
1070 } | |
1071 | |
1072 /* | |
1073 +--------------------------------------------------------------------+ | |
1074 | PROJECT : GSM-PS (6147) MODULE : RR_DAT | | |
1075 | STATE : code ROUTINE : dat_mph_dedicated_fail_cnf | | |
1076 +--------------------------------------------------------------------+ | |
1077 | |
1078 PURPOSE : Layer 1 confirms the re-configuration of the old channel | |
1079 after a failed handover or channel assignment with the | |
1080 primitive MPH_DEDICATED_FAIL_CNF. | |
1081 | |
1082 */ | |
1083 | |
1084 GLOBAL void dat_mph_dedicated_fail_cnf (T_MPH_DEDICATED_FAIL_CNF *mph_dedicated_fail_cnf) | |
1085 { | |
1086 GET_INSTANCE_DATA; | |
1087 TRACE_FUNCTION ("dat_mph_dedicated_fail_cnf()"); | |
1088 | |
1089 switch (GET_STATE (STATE_DAT)) | |
1090 { | |
1091 case DAT_CHAN_ASS_2: | |
1092 { | |
1093 /* | |
1094 * reconnection is done in layer 2. An assignment failure | |
1095 * message is send to the network. | |
1096 */ | |
1097 | |
1098 MCAST (assign_fail, U_ASSIGN_FAIL); | |
1099 PALLOC_MSG (dl_reconnect_req, DL_RECONNECT_REQ, U_ASSIGN_FAIL); | |
1100 | |
1101 assign_fail->msg_type = U_ASSIGN_FAIL; | |
1102 assign_fail->rr_cause = RRC_PROT_UNSPECIFIED; | |
1103 | |
1104 RR_EM_SET_ASSIGN_FAIL_CAUSE(assign_fail->rr_cause); | |
1105 | |
1106 /* | |
1107 * set channel type and SAPI for layer 2 | |
1108 */ | |
1109 dat_code_prr_channel (&dl_reconnect_req->ch_type, | |
1110 &dl_reconnect_req->sapi, | |
1111 rr_data->sc_data.chan_desc.chan_type); | |
1112 | |
1113 /* | |
1114 * start layer 2 reconnection | |
1115 */ | |
1116 for_dat_reconnect_req (dl_reconnect_req); | |
1117 | |
1118 break; | |
1119 } | |
1120 | |
1121 case DAT_HANDOVER_5: | |
1122 { | |
1123 /* | |
1124 * reconnection is done in layer 2. A handover failure | |
1125 * message is send to the network. | |
1126 */ | |
1127 MCAST (handov_fail, U_HANDOV_FAIL); | |
1128 PALLOC_MSG (dl_reconnect_req, DL_RECONNECT_REQ, U_HANDOV_FAIL); | |
1129 | |
1130 /* | |
1131 * clear neighbourcell list | |
1132 */ | |
1133 srv_clear_list (&rr_data->sc_data.cd.ncell_list); | |
1134 srv_clear_list (&rr_data->sc_data.five_ter_list); | |
1135 att_clean_buf (IND_ALL_DEDI_SI); | |
1136 rr_data->sc_data.cd.sys_info_read &= ~ALL_DEDI_SYS_INFOS; | |
1137 handov_fail->msg_type = U_HANDOV_FAIL; | |
1138 handov_fail->rr_cause = RRC_UNSPECIFIED; | |
1139 | |
1140 RR_EM_SET_HANDOVER_FAIL_CAUSE(handov_fail->rr_cause); | |
1141 | |
1142 /* | |
1143 * set channel type and SAPI for layer 2 | |
1144 */ | |
1145 dat_code_prr_channel (&dl_reconnect_req->ch_type, | |
1146 &dl_reconnect_req->sapi, | |
1147 rr_data->sc_data.chan_desc.chan_type); | |
1148 | |
1149 /* | |
1150 * start layer 2 reconnection | |
1151 */ | |
1152 for_dat_reconnect_req (dl_reconnect_req); | |
1153 break; | |
1154 } | |
1155 | |
1156 #ifdef GPRS | |
1157 case DAT_PDCH_ASS_3: | |
1158 { | |
1159 MCAST (u_assign_fail, U_ASSIGN_FAIL); | |
1160 PALLOC_MSG (dl_reconnect_req, DL_RECONNECT_REQ, U_ASSIGN_FAIL); | |
1161 | |
1162 /* | |
1163 * set channel type and SAPI | |
1164 */ | |
1165 dat_code_prr_channel (&dl_reconnect_req->ch_type, | |
1166 &dl_reconnect_req->sapi, | |
1167 rr_data->sc_data.chan_desc.chan_type); | |
1168 | |
1169 u_assign_fail->msg_type = U_ASSIGN_FAIL; | |
1170 u_assign_fail->rr_cause = rr_data->gprs_data.reconn_cause; | |
1171 | |
1172 for_dat_reconnect_req (dl_reconnect_req); | |
1173 | |
1174 SET_STATE (STATE_DAT, DAT_PDCH_ASS_4); | |
1175 break; | |
1176 } | |
1177 | |
1178 case DAT_CCO_3: | |
1179 { | |
1180 MCAST (u_handov_fail, U_HANDOV_FAIL); | |
1181 PALLOC_MSG (dl_reconnect_req, DL_RECONNECT_REQ, U_HANDOV_FAIL); | |
1182 | |
1183 /* | |
1184 * set channel type and SAPI | |
1185 */ | |
1186 dat_code_prr_channel (&dl_reconnect_req->ch_type, | |
1187 &dl_reconnect_req->sapi, | |
1188 rr_data->sc_data.chan_desc.chan_type); | |
1189 | |
1190 u_handov_fail->msg_type = U_HANDOV_FAIL; | |
1191 u_handov_fail->rr_cause = rr_data->gprs_data.reconn_cause; | |
1192 | |
1193 for_dat_reconnect_req (dl_reconnect_req); | |
1194 SET_STATE (STATE_DAT, DAT_CCO_4); | |
1195 break; | |
1196 } | |
1197 #endif | |
1198 | |
1199 default: | |
1200 break; | |
1201 } | |
1202 PFREE (mph_dedicated_fail_cnf); | |
1203 } | |
1204 | |
1205 /* | |
1206 +--------------------------------------------------------------------+ | |
1207 | PROJECT : GSM-PS (6147) MODULE : RR_DAT | | |
1208 | STATE : code ROUTINE : dat_rr_abort_req | | |
1209 +--------------------------------------------------------------------+ | |
1210 | |
1211 PURPOSE : MM aborts a connection due to several reasons (SIM remove, | |
1212 timeout, power off etc.). | |
1213 | |
1214 */ | |
1215 | |
1216 GLOBAL void dat_rr_abort_req (T_RR_ABORT_REQ *rr_abort_req) | |
1217 { | |
1218 GET_INSTANCE_DATA; | |
1219 TRACE_FUNCTION ("dat_rr_abort_req()"); | |
1220 | |
1221 switch (GET_STATE (STATE_DAT)) | |
1222 { | |
1223 case DAT_CHAN_ASS: | |
1224 case DAT_CHAN_ASS_1: | |
1225 case DAT_CHAN_ASS_2: | |
1226 case DAT_DEDICATED: | |
1227 case DAT_HANDOVER: | |
1228 case DAT_HANDOVER_4: | |
1229 case DAT_HANDOVER_5: | |
1230 if (rr_abort_req->abcs EQ ABCS_SIM_REM) | |
1231 { | |
1232 /* | |
1233 * in case of SIM remove the registration data | |
1234 * especially the mobile identities are cleared | |
1235 */ | |
1236 att_clear_registration_data (); | |
1237 } | |
1238 | |
1239 /* | |
1240 * the disconnection of the layer 2 link is started. | |
1241 */ | |
1242 dat_disconnect_link (RRCS_MM_ABORTED); | |
1243 break; | |
1244 | |
1245 case DAT_CHAN_REL: | |
1246 /* | |
1247 * RR has already started the layer 2 link disconnection. | |
1248 * Wait for T3110 timeout or DL disconnection and process | |
1249 * normal cell reselection. | |
1250 */ | |
1251 if (rr_abort_req->abcs EQ ABCS_SIM_REM) | |
1252 { | |
1253 /* | |
1254 * in case of SIM remove the registration data | |
1255 * especially the mobile identities are cleared | |
1256 */ | |
1257 att_clear_registration_data (); | |
1258 } | |
1259 break; | |
1260 | |
1261 case DAT_IDLE: | |
1262 if (rr_abort_req->abcs EQ ABCS_SIM_REM) | |
1263 { | |
1264 /* | |
1265 * in case of SIM remove the registration data | |
1266 * especially the mobile identities are cleared | |
1267 * The idle mode is configured again to set a | |
1268 * faked BS_PA_MFRMS of 9 to slow down layer 1 | |
1269 * and save power. A correct paging group is not | |
1270 * longer needed, because paging is not possible | |
1271 * in limited service. | |
1272 */ | |
1273 att_clear_registration_data (); | |
1274 att_build_idle_req (SC_INDEX, | |
1275 MODE_SYS_INFO_CHANGE); | |
1276 #ifdef REL99 | |
1277 att_config_cbch (); | |
1278 #else | |
1279 att_build_cbch (); | |
1280 #endif | |
1281 } | |
1282 break; | |
1283 | |
1284 case DAT_IMM_ASS: | |
1285 case DAT_IMM_ASS_1: | |
1286 if (rr_abort_req->abcs EQ ABCS_SIM_REM) | |
1287 { | |
1288 /* | |
1289 * in case of SIM remove the registration data | |
1290 * especially the mobile identities are cleared | |
1291 */ | |
1292 att_clear_registration_data (); | |
1293 } | |
1294 | |
1295 /* | |
1296 * stop any timer related to connection establishment | |
1297 */ | |
1298 TIMERSTOP (T3122); | |
1299 TIMERSTOP (T3126); | |
1300 | |
1301 /* | |
1302 * set the release establishment cause. This will be used in | |
1303 * dat_release_connection() function | |
1304 */ | |
1305 rr_data->rel_cause = RRCS_MM_ABORTED; | |
1306 | |
1307 if(GET_STATE (STATE_DAT) EQ DAT_IMM_ASS) | |
1308 { | |
1309 dat_rr_release_ind(rr_data->rel_cause, SAPI_0); | |
1310 att_leave_dat_imm_ass(); | |
1311 } | |
1312 else | |
1313 { | |
1314 /* | |
1315 * go back to idle mode. | |
1316 * inform GRR, and don't wait for CR_RSP | |
1317 */ | |
1318 att_stop_dedicated(); | |
1319 } | |
1320 break; | |
1321 | |
1322 default: | |
1323 if (rr_abort_req->abcs EQ ABCS_SIM_REM) | |
1324 { | |
1325 /* | |
1326 * in case of SIM remove the registration data | |
1327 * especially the mobile identities are cleared | |
1328 */ | |
1329 att_clear_registration_data (); | |
1330 } | |
1331 /* | |
1332 * clear any store establish requests if available | |
1333 * due to a timeout abort of the upper layer. | |
1334 */ | |
1335 if (srv_check_stored_prim (RR_ESTABLISH_REQ)) | |
1336 { | |
1337 /* | |
1338 * release previous establish request | |
1339 */ | |
1340 dat_rr_release_ind(RRCS_MM_ABORTED, SAPI_0); | |
1341 srv_clear_stored_prim (RR_ESTABLISH_REQ); | |
1342 } | |
1343 break; | |
1344 } | |
1345 | |
1346 PFREE (rr_abort_req); | |
1347 } | |
1348 | |
1349 /* | |
1350 +--------------------------------------------------------------------+ | |
1351 | PROJECT : GSM-PS (6147) MODULE : RR_DAT | | |
1352 | STATE : code ROUTINE : dat_rr_data_req | | |
1353 +--------------------------------------------------------------------+ | |
1354 | |
1355 PURPOSE : A layer 3 message of an upper layer shall be send. | |
1356 | |
1357 */ | |
1358 | |
1359 GLOBAL void dat_rr_data_req (T_RR_DATA_REQ *rr_data_req) | |
1360 { | |
1361 GET_INSTANCE_DATA; | |
1362 UBYTE pd; | |
1363 | |
1364 TRACE_FUNCTION ("dat_rr_data_req()"); | |
1365 | |
1366 /* | |
1367 * get the protocol discriminator of the message. | |
1368 */ | |
1369 GET_PD (rr_data_req->sdu, pd); | |
1370 | |
1371 if (pd EQ PD_SMS) | |
1372 { | |
1373 TRACE_EVENT ("SMS Message"); | |
1374 | |
1375 /* | |
1376 * A SMS must be send with SAPI 3. Therefore the | |
1377 * SAPI 3 connection must be established on layer 2. | |
1378 * The STATE_SAPI_3 variable in RR indicates whether | |
1379 * the connection is established or not. If not the | |
1380 * message is stored and the connection will be established. | |
1381 * A SAPI 3 connection is automatically released after | |
1382 * channel assignment, handover or SAPI 0 release. | |
1383 */ | |
1384 switch (GET_STATE (STATE_SAPI_3)) | |
1385 { | |
1386 case SMS_ESTABLISHED: | |
1387 { | |
1388 /* | |
1389 * SAPI 3 connection is available, then send the message | |
1390 * directly. | |
1391 */ | |
1392 PPASS (rr_data_req, dl_data_req, DL_DATA_REQ); | |
1393 | |
1394 /* | |
1395 * set channel type and SAPI for SMS message. | |
1396 */ | |
1397 dat_code_prr_channel_sms (dl_data_req, | |
1398 rr_data->sc_data.chan_desc.chan_type); | |
1399 for_dat_l3_data_req (dl_data_req); | |
1400 break; | |
1401 } | |
1402 | |
1403 case SMS_PENDING: | |
1404 /* | |
1405 * the establishment of SAPI 3 connection is still ongoing. | |
1406 * store the message until connection is ready. | |
1407 */ | |
1408 if (!srv_store_prim ((T_PRIM *)D2P(rr_data_req))) | |
1409 { | |
1410 PFREE (rr_data_req); | |
1411 } | |
1412 break; | |
1413 | |
1414 case SMS_IDLE: | |
1415 /* | |
1416 * the establishment of SAPI 3 connection is not available | |
1417 * store the message until connection is ready. | |
1418 */ | |
1419 if (!srv_store_prim ((T_PRIM *)D2P(rr_data_req))) | |
1420 { | |
1421 PFREE (rr_data_req); | |
1422 } | |
1423 else | |
1424 { | |
1425 /* | |
1426 * Maximum size of the initial message is one frame (= 23 Bytes). | |
1427 */ | |
1428 PALLOC_SDU (dl_establish_req, DL_ESTABLISH_REQ, MAX_L2_FRAME_SIZE * BITS_PER_BYTE); | |
1429 dat_code_prr_channel_sms ((T_DL_DATA_REQ *)dl_establish_req, | |
1430 rr_data->sc_data.chan_desc.chan_type); | |
1431 | |
1432 SET_STATE (STATE_SAPI_3, SMS_PENDING); | |
1433 for_dat_est_req (dl_establish_req); | |
1434 } | |
1435 break; | |
1436 } | |
1437 } | |
1438 else | |
1439 { | |
1440 /* | |
1441 * it is a SAPI 0 message | |
1442 */ | |
1443 PPASS (rr_data_req, dl_data_req, DL_DATA_REQ); | |
1444 | |
1445 /* | |
1446 * set channel type and SAPI according the channel type. | |
1447 */ | |
1448 dat_code_prr_channel (&dl_data_req->ch_type, | |
1449 &dl_data_req->sapi, | |
1450 rr_data->sc_data.chan_desc.chan_type); | |
1451 | |
1452 /* | |
1453 * set N(S) for upper layer message and forward it to Layer 2. | |
1454 */ | |
1455 dat_vsd_bit_set ((T_L3_SDU *)&dl_data_req->sdu, SET_ONLY); | |
1456 for_dat_l3_data_req (dl_data_req); | |
1457 } | |
1458 } | |
1459 | |
1460 /* | |
1461 +--------------------------------------------------------------------+ | |
1462 | PROJECT : GSM-PS (6147) MODULE : RR_DAT | | |
1463 | STATE : code ROUTINE : dat_rr_establish_req | | |
1464 +--------------------------------------------------------------------+ | |
1465 | |
1466 PURPOSE : A mobile originated connection is started. | |
1467 | |
1468 */ | |
1469 | |
1470 GLOBAL void dat_rr_establish_req (T_RR_ESTABLISH_REQ *rr_establish_req) | |
1471 { | |
1472 GET_INSTANCE_DATA; | |
1473 TRACE_FUNCTION ("dat_rr_establish_req()"); | |
1474 | |
1475 switch (GET_STATE (STATE_DAT)) | |
1476 { | |
1477 case DAT_NULL: | |
1478 /* | |
1479 * Data transfer process is in null state, that means | |
1480 * the MS has no service | |
1481 */ | |
1482 if (!srv_store_prim ((T_PRIM *)D2P(rr_establish_req))) | |
1483 { | |
1484 /* | |
1485 * storing is not possible due to an overflow of the storage area | |
1486 * then reject the connection attempt. | |
1487 */ | |
1488 dat_rr_release_ind(RRCS_QUEUE_FULL, SAPI_0); | |
1489 PFREE (rr_establish_req); | |
1490 } | |
1491 break; | |
1492 | |
1493 case DAT_IDLE: | |
1494 if (IS_TIMER_ACTIVE(T3122) AND (rr_establish_req->estcs NEQ ESTCS_EMRG_CAL)) | |
1495 { | |
1496 /* | |
1497 * all non-emergency calls are rejected if T3122 is running. | |
1498 * The timer has been started after reception of an immediate | |
1499 * assignment reject message. | |
1500 */ | |
1501 dat_rr_release_ind(RRCS_T3122_RUNNING, SAPI_0); | |
1502 PFREE (rr_establish_req); | |
1503 | |
1504 TRACE_EVENT ("imm ass delayed"); | |
1505 } | |
1506 else | |
1507 { | |
1508 /* | |
1509 * If T3122 is not running the access to the network is checked. | |
1510 */ | |
1511 if (dat_access_allowed (rr_establish_req->estcs)) | |
1512 { | |
1513 if (rr_establish_req->estcs EQ ESTCS_SERV_REQ_BY_MM) | |
1514 { | |
1515 /* | |
1516 * if location updating is started, store fieldstrength | |
1517 * for an optimisation. RR indicates to MM fieldstrength jumps | |
1518 * over 6 dBm in the field, that means better chance to | |
1519 * perform a successfull location updating. | |
1520 */ | |
1521 rr_data->lup_rxlev = rr_data->nc_data[SC_INDEX].rxlev; | |
1522 } | |
1523 | |
1524 /* | |
1525 * store the piggy-backed layer 3 message for later use. | |
1526 */ | |
1527 memcpy (&rr_data->ms_data.l3msg, &rr_establish_req->sdu, | |
1528 sizeof (T_L3_SDU));/*lint !e420 Apparent access beyond array for function*/ | |
1529 | |
1530 /* | |
1531 * Initialize the N(S) for upper layer messages. | |
1532 */ | |
1533 dat_vsd_bit_set (&rr_data->ms_data.l3msg, SET_AND_RESET); | |
1534 | |
1535 /* | |
1536 * Initialize some parameters and start immediate assignment. | |
1537 */ | |
1538 rr_data->sc_data.first_attempt = TRUE; | |
1539 rr_data->repeat_est = FALSE; | |
1540 #ifdef GPRS | |
1541 dat_gprs_set_suspended(); | |
1542 #endif | |
1543 dat_start_immediate_assign (rr_establish_req->estcs); | |
1544 PFREE (rr_establish_req); | |
1545 } | |
1546 else | |
1547 { | |
1548 /* | |
1549 * Access is not allowed and the rejection is signalled to MM. | |
1550 */ | |
1551 dat_rr_release_ind(RRCS_ACCESS_BARRED, SAPI_0); | |
1552 PFREE (rr_establish_req); | |
1553 | |
1554 TRACE_EVENT ("access barred"); | |
1555 } | |
1556 } | |
1557 break; | |
1558 | |
1559 case DAT_IMM_ASS: | |
1560 case DAT_IMM_ASS_1: | |
1561 case DAT_DEDICATED: | |
1562 { | |
1563 /* | |
1564 * collision of MO and MT calls. MT has higher priority than | |
1565 * MO calls. | |
1566 */ | |
1567 dat_rr_release_ind(RRCS_MO_MT_COLL, SAPI_0); | |
1568 PFREE (rr_establish_req); | |
1569 break; | |
1570 } | |
1571 | |
1572 default: | |
1573 PFREE (rr_establish_req); | |
1574 break; | |
1575 } | |
1576 } | |
1577 | |
1578 /* | |
1579 +--------------------------------------------------------------------+ | |
1580 | PROJECT : GSM-PS (6147) MODULE : RR_DAT | | |
1581 | STATE : code ROUTINE : dat_mph_paging_ind | | |
1582 +--------------------------------------------------------------------+ | |
1583 | |
1584 PURPOSE : Layer 1 has detected a paging for the mobile. | |
1585 RR starts the immediate assignment procedure. | |
1586 | |
1587 */ | |
1588 | |
1589 GLOBAL void dat_mph_paging_ind (T_MPH_PAGING_IND *mph_paging_ind) | |
1590 { | |
1591 GET_INSTANCE_DATA; | |
1592 #ifdef GPRS | |
1593 UBYTE ret; | |
1594 #endif | |
1595 TRACE_FUNCTION ("dat_mph_paging_ind()"); | |
1596 | |
1597 EM_PAGING_IND; | |
1598 | |
1599 /* check access control class before processing for paging */ | |
1600 if (dat_access_allowed(ESTCS_PAGING) EQ FALSE) | |
1601 { | |
1602 PFREE (mph_paging_ind); | |
1603 TRACE_EVENT("Access ctrl class not allowed for responding to the page msg"); | |
1604 return; | |
1605 } | |
1606 | |
1607 switch (GET_STATE (STATE_DAT)) | |
1608 { | |
1609 case DAT_NULL: | |
1610 /* | |
1611 * MS is not in idle mode, searching for cell | |
1612 */ | |
1613 if (! IS_TIMER_ACTIVE(T3122) AND GET_STATE (STATE_ATT) NEQ ATT_NULL) | |
1614 { | |
1615 /* | |
1616 * paging is only excepted if T3122 is not running and there isn't | |
1617 * performed a RR_DEACTIVATE_REQ just before | |
1618 */ | |
1619 if (rr_data->pag_rec EQ FALSE) | |
1620 { | |
1621 /* | |
1622 * store paging if no paging is stored until now. | |
1623 */ | |
1624 if (!srv_store_prim ((T_PRIM *)D2P(mph_paging_ind))) | |
1625 { | |
1626 /* | |
1627 * storage is full | |
1628 */ | |
1629 PFREE (mph_paging_ind); | |
1630 } | |
1631 else | |
1632 { | |
1633 /* | |
1634 * marker that paging has been received. | |
1635 */ | |
1636 rr_data->pag_rec = TRUE; | |
1637 } | |
1638 return; | |
1639 } | |
1640 } | |
1641 break; | |
1642 | |
1643 case DAT_IDLE: | |
1644 if (! IS_TIMER_ACTIVE(T3122)) | |
1645 { | |
1646 if (rr_data->first_meas_received EQ FALSE) | |
1647 { | |
1648 /* | |
1649 * we are actually still in cell reselection | |
1650 * because we have not yet received a measurement | |
1651 * report. But we have to be in idle mode to make | |
1652 * measurements in the first place. | |
1653 */ | |
1654 | |
1655 if (srv_check_stored_prim (MPH_PAGING_IND)) | |
1656 { | |
1657 /* | |
1658 * if already a paging is stored, ignore subsequent pagings | |
1659 */ | |
1660 PFREE (mph_paging_ind); | |
1661 } | |
1662 else | |
1663 { | |
1664 /* | |
1665 * store paging until measurement receives | |
1666 */ | |
1667 rr_data->pag_rec = TRUE; | |
1668 if (!srv_store_prim ((T_PRIM *)D2P(mph_paging_ind))) | |
1669 { | |
1670 /* | |
1671 * storage buffer is full | |
1672 */ | |
1673 rr_data->pag_rec = FALSE; | |
1674 PFREE (mph_paging_ind); | |
1675 } | |
1676 } | |
1677 return; | |
1678 } | |
1679 | |
1680 #ifdef GPRS | |
1681 ret = dat_check_packet_paging_ind(mph_paging_ind); | |
1682 if(ret EQ FALSE) | |
1683 { | |
1684 /* | |
1685 * we are suspended and it is not a packet paging | |
1686 */ | |
1687 dat_begin_start_immediate_assign (mph_paging_ind->identity_type, | |
1688 mph_paging_ind->channel_needed); | |
1689 } | |
1690 else if(ret EQ TRUE) | |
1691 { | |
1692 /* | |
1693 * we are not suspended and it is not a packet paging | |
1694 * and GPRS is activate | |
1695 */ | |
1696 dat_ask_paging_ind(mph_paging_ind); | |
1697 } | |
1698 /* ret EQ 2-> packet paging for GPRS, do nothing */ | |
1699 #else /* GPRS */ | |
1700 dat_begin_start_immediate_assign (mph_paging_ind->identity_type, | |
1701 mph_paging_ind->channel_needed); | |
1702 #endif /* GPRS */ | |
1703 } | |
1704 | |
1705 break; | |
1706 #ifdef GPRS | |
1707 case DAT_IMM_ASS: | |
1708 /* only PS pagings are received in this state */ | |
1709 dat_ask_paging_ind_pa_only(mph_paging_ind); | |
1710 break; | |
1711 #endif | |
1712 default: | |
1713 break; | |
1714 } | |
1715 PFREE (mph_paging_ind); | |
1716 } | |
1717 | |
1718 #if defined FF_EOTD | |
1719 /* | |
1720 +--------------------------------------------------------------------+ | |
1721 | PROJECT : GSM-PS (6147) MODULE : RR_DAT | | |
1722 | STATE : code ROUTINE : dat_rrlc_meas_req | | |
1723 +--------------------------------------------------------------------+ | |
1724 | |
1725 PURPOSE : Process the primitive RRLC_MEAS_REQ received from LC. | |
1726 Start the LCS/EOTD postion measurement procedure. | |
1727 | |
1728 */ | |
1729 | |
1730 GLOBAL void dat_rrlc_meas_req (T_RRLC_MEAS_REQ *rrlc_meas_req) | |
1731 { | |
1732 GET_INSTANCE_DATA; | |
1733 T_NC_DATA *sc; | |
1734 int i,n; | |
1735 | |
1736 TRACE_FUNCTION ("dat_rrlc_meas_req()"); | |
1737 | |
1738 switch ( GET_STATE (STATE_DAT) ) | |
1739 { | |
1740 case DAT_HANDOVER : | |
1741 case DAT_HANDOVER_4: | |
1742 case DAT_HANDOVER_5: | |
1743 { | |
1744 PALLOC (rrlc_error_ind, RRLC_ERROR_IND); | |
1745 rrlc_error_ind->cause = LCS_HANDOVER; | |
1746 | |
1747 rr_data->eotd_req_id = NOT_PRESENT_16BIT; | |
1748 | |
1749 PSENDX (LC, rrlc_error_ind); | |
1750 | |
1751 PFREE(rrlc_meas_req); | |
1752 return; | |
1753 } | |
1754 default: | |
1755 break; | |
1756 } | |
1757 | |
1758 /* | |
1759 * Check if the requested cell matches the serving cell. | |
1760 */ | |
1761 | |
1762 sc = &rr_data->nc_data[SC_INDEX]; | |
1763 | |
1764 if ( rrlc_meas_req->v_arfcn AND | |
1765 rrlc_meas_req-> arfcn NEQ sc->arfcn AND | |
1766 rrlc_meas_req->v_bsic AND | |
1767 rrlc_meas_req-> bsic NEQ sc->bsic ) | |
1768 { | |
1769 PALLOC (rrlc_error_ind, RRLC_ERROR_IND); | |
1770 rrlc_error_ind->cause = LCS_WRONG_BTS; | |
1771 PSENDX (LC, rrlc_error_ind); | |
1772 | |
1773 PFREE(rrlc_meas_req); | |
1774 return; | |
1775 } | |
1776 | |
1777 /* | |
1778 * The requested cell matches the serving cell or | |
1779 * the requested cell was not specified. | |
1780 */ | |
1781 | |
1782 { | |
1783 PALLOC ( mph_ncell_pos_req, MPH_NCELL_POS_REQ ); | |
1784 | |
1785 rr_data->eotd_req_id = rrlc_meas_req->req_id; | |
1786 | |
1787 n = rrlc_meas_req->v_assist_data ? rrlc_meas_req->c_assist_data : 0; | |
1788 mph_ncell_pos_req->c_ncell_eotd = n; | |
1789 mph_ncell_pos_req->req_id = rrlc_meas_req->req_id; | |
1790 for ( i = 0; i < n; ++i ) | |
1791 mph_ncell_pos_req->ncell_eotd[i] = *(T_ncell_eotd*)&rrlc_meas_req->assist_data[i]; | |
1792 | |
1793 PSENDX ( PL, mph_ncell_pos_req ); | |
1794 } | |
1795 PFREE(rrlc_meas_req); | |
1796 } | |
1797 | |
1798 /* | |
1799 +--------------------------------------------------------------------+ | |
1800 | PROJECT : GSM-PS (6147) MODULE : RR_DAT | | |
1801 | STATE : code ROUTINE : dat_rrrrlp_data_req | | |
1802 +--------------------------------------------------------------------+ | |
1803 | |
1804 PURPOSE : Process the primitive RRRRLP_DATA_REQ received from LC. | |
1805 Transmit a APDU according 3GPP TS 04.18, section 3.4.21. | |
1806 | |
1807 */ | |
1808 | |
1809 GLOBAL void dat_rrrrlp_data_req (T_RRRRLP_DATA_REQ *rrrrlp_data_req_orig) | |
1810 { | |
1811 GET_INSTANCE_DATA; | |
1812 | |
1813 UBYTE cr = rrrrlp_data_req_orig->cr; | |
1814 T_sdu *sdu = &rrrrlp_data_req_orig->sdu; | |
1815 UBYTE *buf = &sdu->buf[sdu->o_buf/BITS_PER_BYTE]; | |
1816 USHORT len = BYTELEN(sdu->l_buf); | |
1817 USHORT num_seg = len / APDU_FULL_L2_FRAME; /* number of full segments */ | |
1818 USHORT rem_seg = len % APDU_FULL_L2_FRAME; /* size of last segment */ | |
1819 USHORT n_seg; /* total number of segments*/ | |
1820 USHORT i; | |
1821 UBYTE flag; | |
1822 | |
1823 PPASS(rrrrlp_data_req_orig, rrrrlp_data_req, RRRRLP_DATA_REQ); | |
1824 | |
1825 TRACE_FUNCTION ("dat_rrrrlp_data_req()"); | |
1826 | |
1827 /* sdu->o_buf must be a multiple of BITS_PER_BYTE */ | |
1828 TRACE_ASSERT ( sdu->o_buf % BITS_PER_BYTE EQ 0 ); | |
1829 | |
1830 /* compute the total number of segments (n_seg) */ | |
1831 | |
1832 if ( len EQ 0 ) | |
1833 { | |
1834 PFREE(rrrrlp_data_req); | |
1835 return; | |
1836 } | |
1837 | |
1838 n_seg = num_seg + ((rem_seg EQ 0) ? 0 : 1); | |
1839 | |
1840 /* in a loop with DL_DATA_REQ send all APDU segments */ | |
1841 | |
1842 for ( i = 0; i < num_seg; ++i ) | |
1843 { | |
1844 PALLOC_MSG ( dl_data_req, DL_DATA_REQ, B_APPLIC_INFO ); | |
1845 | |
1846 dat_code_prr_channel (&dl_data_req->ch_type, | |
1847 &dl_data_req->sapi, | |
1848 rr_data->sc_data.chan_desc.chan_type ); | |
1849 | |
1850 /* compute the APDU control flags */ | |
1851 | |
1852 if ( n_seg EQ 1 ) | |
1853 { | |
1854 flag = (UBYTE)(FIRST_SEG | LAST_SEG | (cr << 2)); | |
1855 } | |
1856 else | |
1857 { | |
1858 if ( i EQ 0 ) | |
1859 { | |
1860 flag = FIRST_SEG | NOT_LAST_SEG; | |
1861 } | |
1862 else | |
1863 { | |
1864 if ( i EQ num_seg-1 AND rem_seg EQ 0 ) | |
1865 flag = NOT_FIRST_SEG | LAST_SEG | (cr << 2); | |
1866 else | |
1867 flag = NOT_FIRST_SEG | NOT_LAST_SEG; | |
1868 } | |
1869 } | |
1870 | |
1871 /* compile the APDU message and send it to DL */ | |
1872 | |
1873 dl_data_req->sdu.buf[0] = PD_RR_TI_0; | |
1874 dl_data_req->sdu.buf[1] = B_APPLIC_INFO; | |
1875 dl_data_req->sdu.buf[2] = (flag << 4 ) | RRLP_LCS; | |
1876 dl_data_req->sdu.buf[3] = APDU_FULL_L2_FRAME; | |
1877 memcpy ( &dl_data_req->sdu.buf[4], buf, APDU_FULL_L2_FRAME ); | |
1878 | |
1879 buf += APDU_FULL_L2_FRAME; | |
1880 dl_data_req->sdu.l_buf = (4 + APDU_FULL_L2_FRAME) * BITS_PER_BYTE; | |
1881 dl_data_req->sdu.o_buf = 0; | |
1882 | |
1883 PSENDX ( DL, dl_data_req ); | |
1884 } | |
1885 | |
1886 /* send remaining APDU segment if its length > 0 */ | |
1887 | |
1888 if ( rem_seg > 0 ) | |
1889 { | |
1890 PALLOC_MSG ( dl_data_req, DL_DATA_REQ, B_APPLIC_INFO ); | |
1891 | |
1892 dat_code_prr_channel (&dl_data_req->ch_type, | |
1893 &dl_data_req->sapi, | |
1894 rr_data->sc_data.chan_desc.chan_type ); | |
1895 | |
1896 /* compute the APDU control flags */ | |
1897 | |
1898 if ( n_seg EQ 1 ) | |
1899 flag = FIRST_SEG | LAST_SEG | (cr << 2); | |
1900 else | |
1901 flag = NOT_FIRST_SEG | LAST_SEG | (cr << 2); | |
1902 | |
1903 /* compile the APDU message and send it to DL */ | |
1904 | |
1905 dl_data_req->sdu.buf[0] = PD_RR_TI_0; | |
1906 dl_data_req->sdu.buf[1] = B_APPLIC_INFO; | |
1907 dl_data_req->sdu.buf[2] = (flag << 4 ) | RRLP_LCS; | |
1908 dl_data_req->sdu.buf[3] = (UBYTE)rem_seg; | |
1909 memcpy ( &dl_data_req->sdu.buf[4], buf, rem_seg ); | |
1910 | |
1911 dl_data_req->sdu.l_buf = (4 + rem_seg) * BITS_PER_BYTE; | |
1912 dl_data_req->sdu.o_buf = 0; | |
1913 | |
1914 PSENDX ( DL, dl_data_req ); | |
1915 } | |
1916 | |
1917 /* release RRRRLP_DATA_REQ */ | |
1918 PFREE(rrrrlp_data_req); | |
1919 #ifdef REL99 | |
1920 /* Send RRLP procedure stop indication to MM*/ | |
1921 { | |
1922 PALLOC (rr_rrlp_stop_ind, RR_RRLP_STOP_IND); | |
1923 PSENDX (MM, rr_rrlp_stop_ind); | |
1924 } | |
1925 #endif | |
1926 } | |
1927 #endif /* FF_EOTD */ | |
1928 | |
1929 /* | |
1930 +--------------------------------------------------------------------+ | |
1931 | PROJECT : GSM-PS (6147) MODULE : RR_DAT | | |
1932 | STATE : code ROUTINE : att_mph_stop_dedicated_cnf | | |
1933 +--------------------------------------------------------------------+ | |
1934 | |
1935 PURPOSE : Process the primitive MPH_STOP_DEDICATED_CNF received from L1 | |
1936 */ | |
1937 GLOBAL void att_mph_stop_dedicated_cnf (T_MPH_STOP_DEDICATED_CNF * stop_cnf) | |
1938 { | |
1939 GET_INSTANCE_DATA; | |
1940 PFREE(stop_cnf); | |
1941 TRACE_FUNCTION ("att_mph_stop_dedicated_cnf()"); | |
1942 /* | |
1943 * Dedicated mode activity can be stopped in 3 cases | |
1944 * | |
1945 * - normal case :- Dedicated mode actvity has been stopped cleanly, without any errors. | |
1946 * Either a cell selection or a cell reselection (to the same cell) will take | |
1947 * place, depending on the timer T_DEDICATED_MODE. | |
1948 * | |
1949 * - failure :- Dedicated mode actvity has been stopped because of a radio link failure or a | |
1950 * data link failure. In this case cell re-selection must be started immediately. | |
1951 * | |
1952 * - CCO :- This is Applicable after RR has received a network cell change order | |
1953 */ | |
1954 switch(GET_STATE (STATE_ATT)) | |
1955 { | |
1956 case ATT_NULL: | |
1957 case ATT_CS1: | |
1958 case ATT_CS2: | |
1959 break; | |
1960 | |
1961 default: | |
1962 #ifdef GPRS | |
1963 if( rr_data->mode_after_dedi EQ MODE_CELL_CHANGE_ORDER) | |
1964 { | |
1965 PALLOC (mph_bsic_req, MPH_BSIC_REQ); | |
1966 mph_bsic_req->arfcn = rr_data->gprs_data.arfcn; | |
1967 SET_STATE (STATE_ATT, ATT_IDLE); | |
1968 SET_STATE (STATE_CELL_SEL, CS_CCO); | |
1969 rr_data->mode_after_dedi = NOT_PRESENT_8BIT; | |
1970 PSENDX( PL, mph_bsic_req); | |
1971 return; | |
1972 } | |
1973 #endif | |
1974 if(! rr_data->net_lost ) | |
1975 { | |
1976 /* Send Release indication to MM and go back to IDLE state */ | |
1977 dat_release_connection(); | |
1978 } | |
1979 else | |
1980 { | |
1981 #ifdef GPRS | |
1982 att_start_cell_reselection_gprs (BACK_FROM_DEDICATED_RLF); | |
1983 #else | |
1984 att_start_cell_reselection (BACK_FROM_DEDICATED_RLF); | |
1985 #endif | |
1986 } | |
1987 break; | |
1988 } | |
1989 } | |
1990 #endif |