comparison g23m/condat/ms/src/aci/cmh_gmmr.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
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 module defines the functions which are responsible
18 | for the responses of the protocol stack adapter for
19 | GPRS mobility management ( GMM ).
20 +-----------------------------------------------------------------------------
21 */
22
23 #if defined (GPRS) && defined (DTI)
24
25 #ifndef CMH_GMMR_C
26 #define CMH_GMMR_C
27 #endif
28
29 #include "aci_all.h"
30 /*==== INCLUDES ===================================================*/
31 #include "dti.h" /* functionality of the dti library */
32 #include "aci_cmh.h"
33 #include "ati_cmd.h"
34 #include "aci_cmd.h"
35
36 #include "dti_conn_mng.h"
37
38 #include "aci.h"
39 #include "gaci.h"
40 #include "gaci_cmh.h"
41 #include "psa.h"
42 #include "psa_mm.h"
43 #include "psa_gmm.h"
44 #include "psa_sim.h"
45
46 #include "cmh.h"
47 #include "cmh_mm.h"
48 #include "cmh_gmm.h"
49 #include "cmh_sim.h"
50
51 #if defined (FF_WAP) || defined (FF_SAT_E)
52 #include "wap_aci.h"
53 #include "psa_sm.h"
54 #include "cmh_sm.h"
55 #endif /* WAP */
56
57 #if defined (SIM_TOOLKIT) AND defined (FF_SAT_E)
58 #include "psa_cc.h"
59 #include "psa_sat.h"
60 #include "cmh_sat.h"
61 #endif /* SIM_TOOLKIT AND FF_SAT_E */
62
63 #ifdef FF_GPF_TCPIP
64 #include "dcm_utils.h"
65 #include "dcm_state.h"
66 #include "dcm_env.h"
67 #endif
68
69 #include "dcm_f.h"
70 /*==== CONSTANTS ==================================================*/
71
72
73 /*==== TYPES ======================================================*/
74
75
76 /*==== EXPORT =====================================================*/
77
78 /*==== VARIABLES ==================================================*/
79
80
81 /*==== FUNCTIONS ==================================================*/
82
83 /*
84 +-------------------------------------------------------------------+
85 | PROJECT : GPRS (8441) MODULE : CMH_GMMR |
86 | ROUTINE : cmhGMM_Attached |
87 +-------------------------------------------------------------------+
88
89 PURPOSE : ME is attached
90
91 */
92 GLOBAL void cmhGMM_Attached ( UBYTE attach_type, T_plmn *plmn, UBYTE search_running )
93 {
94 T_CGEREP_EVENT_REP_PARAM event;
95 SHORT i;
96
97 TRACE_FUNCTION ("cmhGMM_Attached()");
98
99 /*
100 * set GPRS attach state
101 */
102 gmmShrdPrm.current_attach_type = attach_type;
103
104 switch ( attach_type )
105 {
106 case GMMREG_AT_GPRS:
107 case GMMREG_AT_COMB:
108 cmhGMM_Set_state(AS_ATTACHED);
109 break;
110 case GMMREG_AT_IMSI:
111 cmhGMM_Set_state(AS_DETACHED);
112 break;
113 }
114
115 if (search_running EQ GMMREG_SEARCH_NOT_RUNNING)
116 {
117 gmmShrdPrm.mobile_class = gmmShrdPrm.requested_mobile_class;
118
119 switch(gmmShrdPrm.requested_mobile_class)
120 {
121 case GMMREG_CLASS_A :
122 gaciMobileClass.current = PERCENT_CGCLASS_A;
123 break;
124 case GMMREG_CLASS_B :
125 gaciMobileClass.current = PERCENT_CGCLASS_B;
126 break;
127 case GMMREG_CLASS_BC :
128 gaciMobileClass.current = PERCENT_CGCLASS_BC;
129 break;
130 case GMMREG_CLASS_BG :
131 gaciMobileClass.current = PERCENT_CGCLASS_BG;
132 break;
133 case GMMREG_CLASS_CC :
134 gaciMobileClass.current = PERCENT_CGCLASS_CC;
135 break;
136 case GMMREG_CLASS_CG :
137 gaciMobileClass.current = PERCENT_CGCLASS_CG;
138 break;
139 default:
140 gaciMobileClass.current = PERCENT_CGCLASS_MAX;
141 break;
142 }
143
144 if(AT_CMD_CGCLASS EQ gmmEntStat.curCmd)
145 {
146 /*
147 * brz: 22.10.02
148 * special behaviour for NMO III
149 *
150 * In the case of NMO III a COMB reject can not be succesful.
151 *
152 * case BG requested: attach type GPRS is also OK
153 * case BC requested: attach type IMSI is also OK
154 */
155 if( GMMREG_CLASS_BG EQ gmmShrdPrm.mobile_class && GMMREG_AT_GPRS EQ attach_type OR
156 GMMREG_CLASS_BC EQ gmmShrdPrm.mobile_class && GMMREG_AT_IMSI EQ attach_type )
157 {
158 /*
159 * GPRS event reporting>
160 */
161 event.mobile_class = gmmShrdPrm.mobile_class;
162 for( i = 0 ; i < CMD_SRC_MAX; i++ )
163 {
164 R_AT( RAT_CGEREP, i ) ( CGEREP_EVENT_ME_CLASS, &event );
165 R_AT( RAT_P_CGEV, i ) ( CGEREP_EVENT_ME_CLASS, &event );
166 }
167 R_AT( RAT_OK, gmmEntStat.entOwn ) ( gmmEntStat.curCmd );
168
169 /* log result */
170 cmh_logRslt ( gmmEntStat.entOwn, RAT_OK, gmmEntStat.curCmd, -1, -1, -1 );
171
172 gmmEntStat.curCmd = AT_CMD_NONE;
173 return;
174 }
175 }
176 }
177
178 if ( attach_type EQ GMMREG_AT_IMSI &&
179 gmmShrdPrm.requested_mobile_class NEQ GMMREG_CLASS_CC)
180 {
181 /*
182 * brz: 03.05.02
183 * patch for wrong behaviour of GMM: sending attach_cnf->IMSI instead of attach_rej->GPRS
184 */
185 if (search_running EQ GMMREG_SEARCH_NOT_RUNNING)
186 {
187 cmhGMM_NoAttach(GMMREG_DT_GPRS ,GMMCS_NO_SERVICE , GMMREG_SEARCH_NOT_RUNNING);
188 }
189
190 return;
191 }
192 else /* end of +CGATT or +CGCLASS */
193 {
194 /*
195 * due to implicit attach request over CGAUTO, S0, CGDATA, ATD
196 */
197
198 cmhGMM_inform_other_psa( 1 );
199
200 switch ( gmmEntStat.curCmd )
201 {
202 case AT_CMD_CGCLASS:
203 /*
204 * GPRS event reporting
205 */
206 event.mobile_class = gmmShrdPrm.requested_mobile_class;
207 for( i = 0 ; i < CMD_SRC_MAX; i++ )
208 {
209 R_AT( RAT_CGEREP, i ) ( CGEREP_EVENT_ME_CLASS, &event );
210 R_AT( RAT_P_CGEV, i ) ( CGEREP_EVENT_ME_CLASS, &event );
211 }
212 case AT_CMD_CGATT:
213 R_AT( RAT_OK, gmmEntStat.entOwn ) ( gmmEntStat.curCmd );
214
215 /* log result */
216 cmh_logRslt ( gmmEntStat.entOwn, RAT_OK, gmmEntStat.curCmd, -1, -1, -1 );
217
218 #ifdef FF_GPF_TCPIP
219 if(is_gpf_tcpip_call())
220 {
221 T_DCM_STATUS_IND_MSG msg;
222 msg.hdr.msg_id = DCM_NEXT_CMD_READY_MSG;
223 dcm_send_message(msg, DCM_SUB_WAIT_CGATT_CNF);
224 }
225 #endif /* FF_GPF_TCPIP */
226 break;
227 }
228
229 gmmEntStat.curCmd = AT_CMD_NONE;
230 }
231 }
232
233
234 /*
235 +-------------------------------------------------------------------+
236 | PROJECT : GPRS (8441) MODULE : CMH_GMMR |
237 | ROUTINE : cmhGMM_NoAttach |
238 +-------------------------------------------------------------------+
239
240 PURPOSE : the attach fail
241
242 */
243 GLOBAL void cmhGMM_NoAttach ( UBYTE detach_type, USHORT cause, UBYTE search_running )
244 {
245 UBYTE cme_err; /* error number */
246
247 TRACE_FUNCTION ("cmhGMM_NoAttach()");
248
249 /*
250 * map error cause
251 */
252 switch(cause)
253 {
254 case GMMCS_ILLEGAL_MS:
255 case MMCS_ILLEGAL_MS:
256 cme_err = CME_ERR_GPRSBadMs;
257 break;
258 case GMMCS_ILLEGAL_ME:
259 case MMCS_ILLEGAL_ME:
260 cme_err = CME_ERR_GPRSBadMe;
261 break;
262 case GMMCS_GPRS_NOT_ALLOWED:
263 /* No corrosponding MM cause */
264 cme_err = CME_ERR_GPRSNoService;
265 break;
266 case GMMCS_PLMN_NOT_ALLOWED:
267 case MMCS_PLMN_NOT_ALLOWED:
268 cme_err = CME_ERR_GPRSBadPlmn;
269 break;
270 case GMMCS_LA_NOT_ALLOWED:
271 case MMCS_LA_NOT_ALLOWED:
272 cme_err = CME_ERR_GPRSBadLoc;
273 break;
274 case GMMCS_ROAMING_NOT_ALLOWED:
275 case MMCS_ROAMING_NOT_ALLOWED:
276 cme_err = CME_ERR_GPRSNoRoam;
277 break;
278 case GMMCS_IMPLICIT_DETACHED:
279 /* No corrosponding MM cause */
280 cme_err = CME_ERR_GPRSUnspec;
281 break;
282 case GMMCS_IMSI_UNKNOWN:
283 case MMCS_IMSI_IN_HLR:
284 case MMCS_IMEI_NOT_ACCEPTED:
285 /* No corrosponding GMM cause */
286 case GMMCS_NO_MS_ID:
287 /* No corrosponding MM cause */
288 cme_err = CME_ERR_SimFail;
289 break;
290 case GMMCS_GSM_GPRS_NOT_ALLOWED:
291 /* No corrosponding MM cause */
292 case GMMCS_NET_FAIL:
293 case MMCS_NETWORK_FAILURE:
294 case GMMCS_MSC_TEMP_NOT_REACHABLE:
295 /* No corrosponding MM cause */
296 case GMMCS_CONGESTION:
297 case MMCS_CONGESTION:
298 cme_err = CME_ERR_NoServ;
299 break;
300 /* case GMMCS_CELL_SELECTION_FAILED: */
301 /* No corrosponding MM cause */
302 /* case GMMCS_NO_SERVICE: */
303 /* No corrosponding MM cause */
304 /* case GMMCS_LIMITED_SERVICE: */
305 /* No corrosponding MM cause */
306 /* case GMMCS_SEMANTIC_INCORRECT:
307 case MMCS_INCORRECT_MESSAGE:
308 case GMMCS_INVALID_M_INFO:
309 case MMCS_INVALID_MAND_MESSAGE:
310 case GMMCS_TYPE_INVALID:
311 case MMCS_MESSAGE_TYPE_NOT_IMPLEM:
312 case GMMCS_TYPE_INCOMPATIBLE:
313 case MMCS_MESSAGE_TYPE_INCOMPAT:
314 case GMMCS_IE_INVALID:
315 case MMCS_IE_NOT_IMPLEM:
316 case GMMCS_COND_IE_ERROR:
317 case MMCS_CONDITIONAL_IE:
318 case GMMCS_MESSAGE_INVALID:
319 case MMCS_MESSAGE_INCOMPAT:
320 case GMMCS_INT_PROTOCOL_ERROR: */
321 /* No corrosponding MM cause */
322 default:
323 cme_err = CME_ERR_Unknown;
324 }
325
326 if ( search_running EQ GMMREG_SEARCH_NOT_RUNNING )
327 {
328 /*
329 * due to implicit attach request over CGAUTO, S0, CGDATA, ATD
330 */
331 cmhGMM_inform_other_psa( 0 );
332
333 switch ( gmmEntStat.curCmd )
334 {
335 case AT_CMD_CGCLASS:
336 case AT_CMD_CGATT:
337 R_AT( RAT_CME, gmmEntStat.entOwn ) ( gmmEntStat.curCmd, cme_err );
338
339 /* log result */
340 cmh_logRslt ( gmmEntStat.entOwn, RAT_CME, gmmEntStat.curCmd, -1, -1, cme_err );
341 break;
342 }
343
344 gmmEntStat.curCmd = AT_CMD_NONE;
345 }
346
347 /*
348 * set GPRS attach state
349 */
350 switch ( detach_type )
351 {
352 case GMMREG_DT_LIMITED_SERVICE:
353 case GMMREG_DT_SIM_REMOVED:
354 cmhGMM_Set_state(AS_DETACHED);
355 break;
356 case GMMREG_DT_DISABLE_GPRS:
357 cmhGMM_Set_state(AS_SUSPENTED);
358 break;
359 case GMMREG_DT_POWER_OFF:
360 break;
361 case GMMREG_DT_GPRS:
362 case GMMREG_DT_COMB:
363 cmhGMM_Set_state(AS_DETACHED);
364 break;
365 case GMMREG_DT_IMSI:
366 break;
367 }
368
369 switch ( detach_type )
370 {
371 case GMMREG_DT_GPRS:
372 gmmShrdPrm.current_attach_type = GMMREG_AT_IMSI;
373 break;
374 case GMMREG_DT_IMSI:
375 gmmShrdPrm.current_attach_type = GMMREG_AT_GPRS;
376 break;
377 case GMMREG_DT_COMB:
378 case GMMREG_DT_POWER_OFF:
379 case GMMREG_DT_LIMITED_SERVICE:
380 case GMMREG_DT_SIM_REMOVED:
381 gmmShrdPrm.current_attach_type = ATTACH_TYPE_DETACHED;
382 break;
383 }
384 }
385
386 /*
387 +-------------------------------------------------------------------+
388 | PROJECT : GPRS (8441) MODULE : CMH_GMMR |
389 | ROUTINE : cmhGMM_Detached |
390 +-------------------------------------------------------------------+
391
392 PURPOSE : ME is detached
393
394 */
395 GLOBAL void cmhGMM_Detached ( UBYTE detach_type )
396 {
397 SHORT i;
398
399 TRACE_FUNCTION ("cmhGMM_Detached()");
400
401 /*
402 *-------------------------------------------------------------------
403 * check for command context
404 *-------------------------------------------------------------------
405 */
406 switch ( detach_type )
407 {
408 case GMMREG_DT_GPRS:
409 case GMMREG_DT_COMB:
410 for( i = 0 ; i < CMD_SRC_MAX; i++ )
411 {
412 R_AT( RAT_CGEREP, i ) ( CGEREP_EVENT_ME_DETACH, NULL );
413 R_AT( RAT_P_CGEV, i ) ( CGEREP_EVENT_ME_DETACH, NULL );
414 }
415
416 cmhGMM_Set_state(AS_DETACHED);
417 break;
418 case GMMREG_DT_POWER_OFF:
419 for( i = 0 ; i < CMD_SRC_MAX; i++ )
420 {
421 R_AT( RAT_CGEREP, i ) ( CGEREP_EVENT_ME_DETACH, NULL );
422 R_AT( RAT_P_CGEV, i ) ( CGEREP_EVENT_ME_DETACH, NULL );
423 }
424
425 cmhGMM_Set_state(AS_MOBILE_OFF);
426 break;
427 case GMMREG_DT_LIMITED_SERVICE:
428 cmhGMM_Set_state(AS_DETACHED);
429 break;
430 case GMMREG_DT_SIM_REMOVED:
431 cmhGMM_Set_state(AS_DETACHED);
432 break;
433 case GMMREG_DT_IMSI:
434 cmhGMM_Set_state(AS_ATTACHED);
435 break;
436 case GMMREG_DT_DISABLE_GPRS:
437 cmhGMM_Set_state(AS_SUSPENTED);
438 break;
439 default:
440 break;
441 }
442
443 switch ( detach_type )
444 {
445 case GMMREG_DT_IMSI:
446 gmmShrdPrm.current_attach_type = GMMREG_AT_GPRS;
447 break;
448 case GMMREG_DT_GPRS:
449 gmmShrdPrm.current_attach_type = GMMREG_AT_IMSI;
450 break;
451 case GMMREG_DT_COMB:
452 case GMMREG_DT_LIMITED_SERVICE:
453 case GMMREG_DT_SIM_REMOVED:
454 case GMMREG_DT_POWER_OFF:
455 gmmShrdPrm.current_attach_type = ATTACH_TYPE_DETACHED;
456 break;
457 }
458
459 cmhGMM_inform_other_psa( 0 );
460
461 switch( gmmEntStat.curCmd )
462 {
463 case( AT_CMD_CGCLASS ):
464 case( AT_CMD_CGATT ):
465
466 R_AT( RAT_OK, gmmEntStat.entOwn ) ( gmmEntStat.curCmd );
467
468 /* log result */
469 cmh_logRslt ( gmmEntStat.entOwn, RAT_OK, gmmEntStat.curCmd, -1, -1, -1 );
470 break;
471 }
472 gmmEntStat.curCmd = AT_CMD_NONE;
473
474 }
475
476 /*
477 +-------------------------------------------------------------------+
478 | PROJECT : GPRS (8441) MODULE : CMH_GMMR |
479 | ROUTINE : cmhGMM_NetDetach |
480 +-------------------------------------------------------------------+
481
482 PURPOSE : ME is detached by the network
483
484 */
485 GLOBAL void cmhGMM_NetDetach ( UBYTE detach_type, USHORT cause, UBYTE search_running )
486 {
487 SHORT i;
488
489 TRACE_FUNCTION ("cmhGMM_NetDetach()");
490
491 switch (detach_type)
492 {
493 case GMMREG_DT_GPRS:
494 case GMMREG_DT_COMB:
495 for( i = 0 ; i < CMD_SRC_MAX; i++ )
496 {
497 R_AT( RAT_CGEREP, i ) ( CGEREP_EVENT_NW_DETACH, NULL );
498 R_AT( RAT_P_CGEV, i ) ( CGEREP_EVENT_NW_DETACH, NULL );
499 }
500
501 case GMMREG_DT_SIM_REMOVED:
502 case GMMREG_DT_LIMITED_SERVICE:
503 cmhGMM_Set_state(AS_DETACHED);
504 break;
505 case GMMREG_DT_IMSI:
506 cmhGMM_Set_state(AS_ATTACHED);
507 break;
508 case GMMREG_DT_DISABLE_GPRS:
509 cmhGMM_Set_state(AS_SUSPENTED);
510 break;
511 case GMMREG_DT_POWER_OFF:
512 default:
513 break;
514 }
515
516 switch (detach_type)
517 {
518 case GMMREG_DT_GPRS:
519 gmmShrdPrm.current_attach_type = GMMREG_AT_IMSI;
520 break;
521 case GMMREG_DT_IMSI:
522 gmmShrdPrm.current_attach_type = GMMREG_AT_GPRS;
523 break;
524 case GMMREG_DT_COMB:
525 case GMMREG_DT_SIM_REMOVED:
526 case GMMREG_DT_LIMITED_SERVICE:
527 case GMMREG_DT_POWER_OFF:
528 gmmShrdPrm.current_attach_type = ATTACH_TYPE_DETACHED;
529 break;
530 }
531
532 }
533
534 /*
535 +-------------------------------------------------------------------+
536 | PROJECT : GPRS (8441) MODULE : CMH_GMMR |
537 | ROUTINE : cmhGMM_Plmn |
538 +-------------------------------------------------------------------+
539
540 PURPOSE : reseive a PLMN list
541
542 */
543 GLOBAL SHORT cmhGMM_Plmn ( void )
544 {
545 TRACE_FUNCTION ("cmhGMM_Plmn()");
546
547
548 return GMMH_CMD_OK;
549 }
550
551 /*
552 +-------------------------------------------------------------------+
553 | PROJECT : GPRS (8441) MODULE : CMH_GMMR |
554 | ROUTINE : cmhGMM_Suspend |
555 +-------------------------------------------------------------------+
556
557 PURPOSE : full service or limited service is available
558
559 */
560 GLOBAL SHORT cmhGMM_Suspend ( UBYTE cell_state )
561 {
562
563 TRACE_FUNCTION ("cmhGMM_Suspend()");
564
565 cmhGMM_Set_state( AS_SUSPENTED );
566
567 #if defined (SIM_TOOLKIT) AND defined (FF_SAT_E)
568
569 cmhSAT_OpChnGPRSStat(SAT_GPRS_SUSPEND, SAT_GPRS_INV_CAUSE);
570
571 #endif /* SIM_TOOLKIT AND FF_SAT_E */
572
573 return GMMH_CMD_OK;
574 }
575
576 /*
577 +-------------------------------------------------------------------+
578 | PROJECT : GPRS (8441) MODULE : CMH_GMMR |
579 | ROUTINE : cmhGMM_Resume |
580 +-------------------------------------------------------------------+
581
582 PURPOSE : GPRS full service is now available
583
584 */
585 GLOBAL SHORT cmhGMM_Resume ( void )
586 {
587
588 TRACE_FUNCTION ("cmhGMM_Resume()");
589
590 cmhGMM_Set_state( AS_ATTACHED );
591
592 #if defined (SIM_TOOLKIT) AND defined (FF_SAT_E)
593
594 cmhSAT_OpChnGPRSStat(SAT_GPRS_RESUME, SAT_GPRS_INV_CAUSE);
595
596 #endif /* SIM_TOOLKIT AND FF_SAT_E */
597
598 return GMMH_CMD_OK;
599 }
600
601 /*
602 +-------------------------------------------------------------------+
603 | PROJECT : GPRS (8441) MODULE : CMH_GMMR |
604 | ROUTINE : cmhGMM_Info |
605 +-------------------------------------------------------------------+
606
607 PURPOSE : reseive the information provided by the GMM INFORMATION message.
608
609 */
610 GLOBAL SHORT cmhGMM_Info ( void )
611 {
612 TRACE_FUNCTION ("cmhGMM_Info()");
613
614
615 return GMMH_CMD_OK;
616 }
617
618
619
620 /*
621 +-------------------------------------------------------------------+
622 | PROJECT : GSM-PS (6147) MODULE : CMH_GMMR |
623 | ROUTINE : cmhGMM_CipheringInd |
624 +-------------------------------------------------------------------+
625
626 PURPOSE : ciphering indication received
627
628 */
629
630 GLOBAL SHORT cmhGMM_CipheringInd ( UBYTE gsm_ciph, UBYTE gprs_ciph )
631 {
632 SHORT idx; /* holds index counter */
633
634 TRACE_FUNCTION ("cmhGMM_CipheringInd()");
635
636 if (simShrdPrm.ciSIMEnabled NEQ TRUE)
637 {
638 return 1;
639 }
640
641 for (idx = 0; idx < CMD_SRC_MAX; idx++)
642 {
643 /*
644 *-----------------------------------------------------------------
645 * new message indication
646 *-----------------------------------------------------------------
647 */
648 R_AT(RAT_P_CPRI,idx)(gsm_ciph, gprs_ciph);
649 }
650 return 0;
651 }
652
653
654 #endif /* GPRS */
655 /*==== EOF ========================================================*/
656