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