comparison g23m/condat/ms/src/aci/cmh_mmr.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 : GSM-PS (6147)
4 | Modul : CMH_MMR
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 | mobility management.
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef CMH_MMR_C
24 #define CMH_MMR_C
25 #endif
26
27 #include "aci_all.h"
28
29 /*==== INCLUDES ===================================================*/
30
31 #include "aci_cmh.h"
32 #include "ati_cmd.h"
33 #include "aci_cmd.h"
34 #include "aci_mem.h"
35
36 #ifdef FAX_AND_DATA
37 #include "aci_fd.h"
38 #endif /* of #ifdef FAX_AND_DATA */
39
40 #include "aci.h"
41 #include "psa.h"
42 #include "psa_mm.h"
43 #include "psa_sim.h"
44 #include "cmh.h"
45 #include "cmh_mm.h"
46
47 #ifdef DTI
48 #include "dti.h" /* functionality of the dti library */
49 #include "dti_conn_mng.h"
50 #include "dti_cntrl_mng.h"
51 #endif
52
53 #include "cmh_sim.h"
54
55 #ifdef GPRS
56 #include "gaci.h"
57 #include "gaci_cmh.h"
58 #include "psa_gmm.h"
59 #include "cmh_gmm.h"
60 #endif
61
62 /*==== CONSTANTS ==================================================*/
63
64
65 /*==== TYPES ======================================================*/
66
67
68 /*==== EXPORT =====================================================*/
69
70
71 /*==== VARIABLES ==================================================*/
72
73 /*==== FUNCTIONS ==================================================*/
74
75
76 /*
77 +-------------------------------------------------------------------+
78 | PROJECT : GSM-PS (6147) MODULE : CMH_MMR |
79 | ROUTINE : cmhMM_Registered |
80 +-------------------------------------------------------------------+
81
82 PURPOSE : ME is registered to the network
83
84 */
85
86 GLOBAL SHORT cmhMM_Registered ( void )
87 {
88 SHORT mncCur, mccCur; /* holds mnc and mcc of current PLMN */
89 UBYTE cmdBuf; /* buffers current command */
90
91 TRACE_FUNCTION ("cmhMM_Registered()");
92
93 /*
94 *-------------------------------------------------------------------
95 * check for command context
96 *-------------------------------------------------------------------
97 */
98 switch( mmEntStat.curCmd )
99 {
100 case( AT_CMD_NONE ):
101 case( AT_CMD_COPS ):
102 case (AT_CMD_P_COPS):
103 case( AT_CMD_NRG ):
104
105 /* check for home PLMN or roaming */
106 if( mmShrdPrm.usedPLMN.v_plmn EQ VLD_PLMN )
107 {
108 cmhMM_CnvrtPLMN2INT( mmShrdPrm.usedPLMN.mcc,
109 mmShrdPrm.usedPLMN.mnc,
110 &mccCur, &mncCur );
111
112 /* Store the new PLMN and the IMSI in the FFS */
113 if (!cmhMM_OperatorStoreInFFS(mmShrdPrm.usedPLMN.mcc,
114 mmShrdPrm.usedPLMN.mnc,
115 simShrdPrm.imsi.field))
116 TRACE_EVENT("Could not write PLMN and IMSI in FFS");
117
118
119 if( cmhSIM_plmn_is_hplmn (mccCur, mncCur))
120 {
121 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_Reg);
122 }
123 else
124 {
125 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_Roam);
126 }
127 }
128
129 if( mmEntStat.curCmd NEQ AT_CMD_NONE )
130 {
131 #if defined (GPRS) AND defined (DTI)
132 psaG_MM_CMD_SET_REGMD ( mmShrdPrm.regMode ); /* restore former registration mode*/
133 #else
134 /* restore former registration mode */
135 psaMM_SetRegMode ( mmShrdPrm.regMode );
136 #endif
137
138 cmdBuf = mmEntStat.curCmd;
139 mmEntStat.curCmd = AT_CMD_NONE;
140
141 R_AT( RAT_OK, mmEntStat.entOwn )
142 ( cmdBuf );
143
144 /* log result */
145 cmh_logRslt ( mmEntStat.entOwn, RAT_OK, cmdBuf, -1, -1, -1 );
146 }
147
148
149
150 break;
151 }
152
153 return 0;
154 }
155
156 /*
157 +-------------------------------------------------------------------+
158 | PROJECT : GSM-PS (6147) MODULE : CMH_MMR |
159 | ROUTINE : cmhMM_Deregistered |
160 +-------------------------------------------------------------------+
161
162 PURPOSE : ME is deregistered from network
163
164 */
165
166 GLOBAL SHORT cmhMM_Deregistered ( void )
167 {
168 T_ACI_RETURN ret;
169
170 TRACE_FUNCTION ("cmhMM_Deregistered()");
171
172 /*
173 *-------------------------------------------------------------------
174 * check for command context
175 *-------------------------------------------------------------------
176 */
177 switch( mmEntStat.curCmd )
178 {
179 case( AT_CMD_NONE ):
180 /*
181 *----------------------------------------------------------------
182 * process event if no command was invoked
183 *----------------------------------------------------------------
184 */
185 switch( mmShrdPrm.deregCs )
186 {
187 case( NREG_LIMITED_SERVICE ):
188 case( NREG_NO_SERVICE ):
189
190 if (mmShrdPrm.regModeAutoBack)
191 {
192 /*
193 * Fallback to automatic mode is allowed, fallback.
194 * If MM is not in full service and the registration mode
195 * is switched from manual to automatic,
196 * MM starts a network search immediately.
197 */
198 mmShrdPrm.regModeBeforeAbort = mmShrdPrm.regMode;
199 mmShrdPrm.regMode = MODE_AUTO;
200 mmShrdPrm.regModeAutoBack = FALSE;
201 #if defined (GPRS) AND defined (DTI)
202 psaG_MM_CMD_SET_REGMD ( MODE_AUTO );
203 #else
204 psaMM_SetRegMode (MODE_AUTO);
205 #endif
206 }
207
208 cmhMM_Ntfy_NtwRegistrationStatus(cmhMM_GetNregCREGStat());
209 break;
210 }
211 break;
212
213 case( AT_CMD_CFUN ):
214 /*
215 *----------------------------------------------------------------
216 * process event for +CFUN command
217 *----------------------------------------------------------------
218 */
219 mmEntStat.curCmd = AT_CMD_NONE;
220
221 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_NoSearch);
222
223 if (simEntStat.curCmd NEQ AT_CMD_CFUN) /* Has SIM already finished flushing of LDN entries? */
224 {
225 R_AT( RAT_OK, mmEntStat.entOwn )
226 ( AT_CMD_CFUN );
227
228 /* log result */
229 cmh_logRslt ( mmEntStat.entOwn, RAT_OK, AT_CMD_CFUN, -1, -1, -1 );
230 }
231
232 break;
233
234 case( AT_CMD_BAND ):
235 /*
236 *----------------------------------------------------------------
237 * process event for %BAND command
238 *----------------------------------------------------------------
239 */
240 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_NoSearch);
241
242 /* switch back to full functionnality */
243 ret = sAT_PlusCFUN( mmEntStat.entOwn,
244 CFUN_FUN_Full,
245 CFUN_RST_NotPresent );
246
247
248 /* SPR#919 - SH - fix advised by CLB */
249 mmEntStat.curCmd = AT_CMD_NONE;
250 simEntStat.curCmd = AT_CMD_NONE;
251 /* end SH */
252
253 if( ret EQ AT_CMPL )
254 {
255 R_AT( RAT_OK, mmEntStat.entOwn )
256 (AT_CMD_BAND);
257 }
258 else
259 {
260 TRACE_EVENT_P1
261 ("Fatal Error in sAT_PlusCFUN switching on !!!, ret_type: %d", ret);
262 R_AT( RAT_CME, mmEntStat.entOwn )
263 ( AT_CMD_BAND, CME_ERR_Unknown );
264
265 }
266 /*SPR#919 - SH - fix advised by CLB
267 mmEntStat.curCmd = AT_CMD_NONE;
268 simEntStat.curCmd = AT_CMD_NONE;
269 */
270 break;
271
272 case( AT_CMD_COPS ):
273 case( AT_CMD_P_COPS):
274 /*
275 *----------------------------------------------------------------
276 * process event for +COPS command
277 *----------------------------------------------------------------
278 */
279 switch( mmShrdPrm.COPSmode )
280 {
281 case( COPS_MOD_Auto ):
282 case( COPS_MOD_Man ):
283
284 mmEntStat.curCmd = AT_CMD_NONE;
285
286 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_Denied);
287
288 #if defined (GPRS) AND defined (DTI)
289 psaG_MM_CMD_SET_REGMD ( mmShrdPrm.regMode ); /* restore former registration mode*/
290 #else
291 /* restore former registration mode */
292 psaMM_SetRegMode ( mmShrdPrm.regMode);
293 #endif
294
295 R_AT( RAT_CME, mmEntStat.entOwn )
296 ( mmEntStat.curCmd, cmhMM_GetNregCMEStat() );
297
298 /* log result */
299 cmh_logRslt ( mmEntStat.entOwn, RAT_CME, AT_CMD_COPS, -1, -1,
300 cmhMM_GetNregCMEStat() );
301 break;
302
303 case( COPS_MOD_Dereg ):
304
305 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_NoSearch);
306
307 R_AT( RAT_OK, mmEntStat.entOwn )
308 ( mmEntStat.curCmd );
309
310 /* log result */
311 cmh_logRslt ( mmEntStat.entOwn, RAT_OK, mmEntStat.curCmd, -1, -1, -1 );
312
313 mmEntStat.curCmd = AT_CMD_NONE;
314 break;
315
316 case( COPS_MOD_SetOnly ):
317
318 cmhMM_Ntfy_NtwRegistrationStatus(cmhMM_GetNregCREGStat());
319 break;
320
321 case( COPS_MOD_Both ):
322
323 if (mmShrdPrm.regModeAutoBack)
324 {
325 /*
326 * Tried register to network in manual mode. Attempt failed.
327 * Now trying to register into network in automatic mode.
328 */
329 mmShrdPrm.regModeBeforeAbort = mmShrdPrm.regMode;
330 mmShrdPrm.regMode = MODE_AUTO;
331 mmShrdPrm.regModeAutoBack = FALSE;
332
333 #if defined (GPRS) AND defined (DTI)
334 if( psaG_MM_CMD_REG ( ) < 0 ) /* register to network */
335 #else
336 if( psaMM_Registrate () < 0 ) /* register to network */
337 #endif
338 {
339 TRACE_EVENT( "FATAL RETURN psaMM_Registrate in +COPS" );
340
341 R_AT( RAT_CME, mmEntStat.entOwn )
342 ( mmEntStat.curCmd, cmhMM_GetNregCMEStat());
343
344 /* log result */
345 cmh_logRslt ( mmEntStat.entOwn, RAT_CME, mmEntStat.curCmd, -1, -1,
346 cmhMM_GetNregCMEStat() );
347
348 mmEntStat.curCmd = AT_CMD_NONE;
349 }
350 }
351 else
352 {
353 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_Denied);
354
355 #if defined (GPRS) AND defined (DTI)
356 psaG_MM_CMD_SET_REGMD ( mmShrdPrm.regMode ); /* restore former registration mode*/
357 #else
358 /* restore former registration mode or set new one */
359 psaMM_SetRegMode ( mmShrdPrm.regMode );
360 #endif
361
362 R_AT( RAT_CME, mmEntStat.entOwn )
363 ( mmEntStat.curCmd, cmhMM_GetNregCMEStat() );
364
365 /* log result */
366 cmh_logRslt ( mmEntStat.entOwn, RAT_CME, mmEntStat.curCmd, -1, -1,
367 cmhMM_GetNregCMEStat() );
368
369 mmEntStat.curCmd = AT_CMD_NONE;
370 }
371 break;
372 }
373 break;
374
375 case( AT_CMD_NRG ):
376 /*
377 *----------------------------------------------------------------
378 * process event for %NRG command
379 *----------------------------------------------------------------
380 */
381 switch( cmhPrm[mmEntStat.entOwn].mmCmdPrm.NRGsrvMode )
382 {
383 case( NRG_SVMD_Full ):
384
385 switch( cmhPrm[mmEntStat.entOwn].mmCmdPrm.NRGregMode )
386 {
387 case( NRG_RGMD_Auto ):
388 case( NRG_RGMD_Manual ):
389
390 mmEntStat.curCmd = AT_CMD_NONE;
391
392 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_Denied);
393
394 #if defined (GPRS) AND defined (DTI)
395 psaG_MM_CMD_SET_REGMD ( mmShrdPrm.regMode ); /* restore former registration mode*/
396 #else
397 /* restore former registration mode */
398 psaMM_SetRegMode ( mmShrdPrm.regMode );
399 #endif
400
401 R_AT( RAT_CME, mmEntStat.entOwn )
402 ( AT_CMD_NRG, cmhMM_GetNregCMEStat());
403
404 /* log result */
405 cmh_logRslt ( mmEntStat.entOwn, RAT_CME, AT_CMD_NRG, -1, -1,
406 cmhMM_GetNregCMEStat() );
407 break;
408
409 case( NRG_RGMD_Both ):
410 if (mmShrdPrm.regModeAutoBack)
411 {
412 /*
413 * Tried register to network in manual mode. Attempt failed.
414 * Now trying to register into network in automatic mode.
415 */
416 mmShrdPrm.regModeBeforeAbort = mmShrdPrm.regMode;
417 mmShrdPrm.regMode = MODE_AUTO;
418 mmShrdPrm.regModeAutoBack = FALSE;
419
420 #if defined (GPRS) AND defined (DTI)
421 if( psaG_MM_CMD_REG ( ) < 0 ) /* register to network */
422 #else
423 if( psaMM_Registrate () < 0 ) /* register to network */
424 #endif
425 {
426 mmEntStat.curCmd = AT_CMD_NONE;
427 TRACE_EVENT( "FATAL RETURN psaMM_Registrate in %NRG" );
428
429 R_AT( RAT_CME, mmEntStat.entOwn )
430 ( AT_CMD_NRG, cmhMM_GetNregCMEStat());
431
432 /* log result */
433 cmh_logRslt ( mmEntStat.entOwn, RAT_CME, AT_CMD_NRG, -1, -1,
434 cmhMM_GetNregCMEStat() );
435 }
436 }
437 else
438 {
439 mmEntStat.curCmd = AT_CMD_NONE;
440
441 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_Denied);
442
443 /* If fallback to automatic mode is allowed, fall back */
444 if (mmShrdPrm.regModeAutoBack)
445 {
446 mmShrdPrm.regModeBeforeAbort = mmShrdPrm.regMode;
447 mmShrdPrm.regModeAutoBack = FALSE;
448 mmShrdPrm.regMode = MODE_AUTO;
449 }
450
451 #if defined (GPRS) AND defined (DTI)
452 psaG_MM_CMD_SET_REGMD ( mmShrdPrm.regMode ); /* restore former registration mode*/
453 #else
454 /* restore former registration mode or set new one */
455 psaMM_SetRegMode ( mmShrdPrm.regMode );
456 #endif
457
458 R_AT( RAT_CME, mmEntStat.entOwn )
459 ( AT_CMD_NRG, cmhMM_GetNregCMEStat() );
460
461 /* log result */
462 cmh_logRslt ( mmEntStat.entOwn, RAT_CME, AT_CMD_NRG, -1, -1,
463 cmhMM_GetNregCMEStat() );
464 }
465 break;
466 }
467 break;
468
469 case( NRG_SVMD_Limited ):
470
471 /* pending registration request */
472 if( regReqPnd EQ TRUE )
473 {
474 mmShrdPrm.regMode = MODE_AUTO;
475
476 #if defined (GPRS) AND defined (DTI)
477 (void)psaG_MM_CMD_REG (); /* register to network */
478 #else
479 (void)psaMM_Registrate (); /* register to network */
480 #endif
481
482 regReqPnd = FALSE;
483 break;
484 }
485
486 if( mmShrdPrm.regStat EQ RS_LMTD_SRV )
487 {
488 mmEntStat.curCmd = AT_CMD_NONE;
489
490 cmhMM_Ntfy_NtwRegistrationStatus(cmhMM_GetNregCREGStat());
491
492 R_AT( RAT_OK, mmEntStat.entOwn )
493 ( AT_CMD_NRG );
494
495 /* log result */
496 cmh_logRslt ( mmEntStat.entOwn, RAT_OK, AT_CMD_NRG, -1, -1, -1 );
497 }
498 else
499 {
500 mmEntStat.curCmd = AT_CMD_NONE;
501
502 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_Denied);
503
504 #if defined (GPRS) AND defined (DTI)
505 psaG_MM_CMD_SET_REGMD ( mmShrdPrm.regMode ); /* restore former registration mode*/
506 #else
507 /* restore former registration mode */
508 psaMM_SetRegMode ( mmShrdPrm.regMode );
509 #endif
510
511 R_AT( RAT_CME, mmEntStat.entOwn )
512 ( AT_CMD_NRG, cmhMM_GetNregCMEStat() );
513
514 /* log result */
515 cmh_logRslt ( mmEntStat.entOwn, RAT_CME, AT_CMD_NRG, -1, -1,
516 cmhMM_GetNregCMEStat() );
517 }
518 break;
519
520 case( NRG_SVMD_NoSrv ):
521
522 mmEntStat.curCmd = AT_CMD_NONE;
523
524 cmhMM_Ntfy_NtwRegistrationStatus(CREG_STAT_NoSearch);
525
526 R_AT( RAT_OK, mmEntStat.entOwn )
527 ( AT_CMD_NRG );
528
529 /* log result */
530 cmh_logRslt ( mmEntStat.entOwn, RAT_OK, AT_CMD_NRG, -1, -1, -1 );
531 break;
532
533 case( NRG_SVMD_SetRegModeOnly ):
534
535 cmhMM_Ntfy_NtwRegistrationStatus(cmhMM_GetNregCREGStat());
536 break;
537
538 }
539 break;
540 }
541
542 return 0;
543 }
544
545 /*
546 +-------------------------------------------------------------------+
547 | PROJECT : GSM-PS (6147) MODULE : CMH_MMR |
548 | ROUTINE : cmhMM_NetworkLst |
549 +-------------------------------------------------------------------+
550
551 PURPOSE : List of networks available
552
553 */
554
555 GLOBAL SHORT cmhMM_NetworkLst ( void )
556 {
557 /*
558 * We need a structure which has to fit into one not too big partition.
559 * sizeof (T_OP_NAME) = 36 (35 characters plus one alignment byte)
560 * with MAX_LONG_OPER_LEN = 26 and MAX_SHRT_OPER_LEN = 9
561 * => sizeof (T_OP_NAME) * MAX_OPER = 432
562 * => This fits into one of the 432er partitions of which we have some.
563 */
564 typedef struct
565 {
566 char longNamBuf[MAX_LONG_OPER_LEN]; /* buffer long name */
567 char shrtNamBuf[MAX_SHRT_OPER_LEN]; /* buffer short name*/
568 } T_OP_NAME;
569
570 T_OP_NAME * op_name = NULL; /* Holds operator names */
571 T_OPER_ENTRY plmnDesc; /* PLMN description */
572 T_ACI_COPS_OPDESC * operLst = NULL; /* operator list T_ACI_COPS_LST */
573 SHORT lstIdx; /* holds list idx */
574 SHORT mcc, mnc; /* holds converted mnc and mcc */
575 BOOL found; /* Result of cmhMM_FindXXX() */
576 T_ACI_AT_CMD bufCmd;
577
578 TRACE_FUNCTION ("cmhMM_NetworkLst()");
579
580 /*
581 *-------------------------------------------------------------------
582 * check for command context
583 *-------------------------------------------------------------------
584 */
585 switch( mmEntStat.curCmd )
586 {
587 case( AT_CMD_COPS ):
588 case (AT_CMD_P_COPS):
589
590 ACI_MALLOC (op_name, sizeof (T_OP_NAME) * MAX_OPER);
591 ACI_MALLOC (operLst, sizeof (T_ACI_COPS_OPDESC) * MAX_OPER);
592
593 /*
594 *---------------------------------------------------------------
595 * for every entry of the PLMN list
596 *---------------------------------------------------------------
597 */
598 for( lstIdx = 0; lstIdx < MAX_OPER AND lstIdx < MAX_PLMN_ID; lstIdx++ )
599 {
600 /*
601 *-------------------------------------------------------------
602 * if last entry of PLMN list, close oper list and return
603 *-------------------------------------------------------------
604 */
605 if( mmShrdPrm.PLMNLst[lstIdx].v_plmn EQ INVLD_PLMN )
606 {
607 operLst[lstIdx].status = COPS_STAT_NotPresent;
608 operLst[lstIdx].longOper = NULL;
609 operLst[lstIdx].shortOper = NULL;
610 operLst[lstIdx].numOper[0]= '\0';
611 break;
612 }
613
614 /*
615 *-------------------------------------------------------------
616 * find PLMN description
617 *-------------------------------------------------------------
618 */
619 cmhMM_CnvrtPLMN2INT( mmShrdPrm.PLMNLst[lstIdx].mcc,
620 mmShrdPrm.PLMNLst[lstIdx].mnc,
621 &mcc, &mnc );
622
623 found = cmhMM_FindPLMN (&plmnDesc, mcc, mnc, mmShrdPrm.LACLst[lstIdx], TRUE);
624
625 if (!found) /* no description found */
626 {
627 operLst[lstIdx].longOper = "";
628 operLst[lstIdx].shortOper = "";
629 }
630 else
631 {
632 /* Copy strings into dynamic buffer so that they don't get lost */
633 memcpy (op_name[lstIdx].longNamBuf, plmnDesc.longName, MAX_LONG_OPER_LEN);
634 memcpy (op_name[lstIdx].shrtNamBuf, plmnDesc.shrtName, MAX_SHRT_OPER_LEN);
635
636 /* EONS PLMN name conding scheme and source flag */
637 operLst[lstIdx].pnn = plmnDesc.pnn;
638 operLst[lstIdx].longOper = op_name[lstIdx].longNamBuf;
639 operLst[lstIdx].long_len = plmnDesc.long_len;
640 operLst[lstIdx].long_ext_dcs = plmnDesc.long_ext_dcs;
641 operLst[lstIdx].shortOper = op_name[lstIdx].shrtNamBuf;
642 operLst[lstIdx].shrt_len = plmnDesc.shrt_len;
643 operLst[lstIdx].shrt_ext_dcs = plmnDesc.shrt_ext_dcs;
644 }
645
646 /*
647 *-------------------------------------------------------------
648 * build numeric representation
649 *-------------------------------------------------------------
650 */
651 if ((mnc & 0x00F) EQ 0x00F)
652 sprintf (operLst[lstIdx].numOper, "%03X%02X", mcc, (mnc & 0xFF0) >> 4);
653 else
654 sprintf (operLst[lstIdx].numOper, "%03X%03X", mcc, mnc);
655
656 /*
657 *-------------------------------------------------------------
658 * set PLMN status
659 *-------------------------------------------------------------
660 */
661 if (mmShrdPrm.PLMNLst[lstIdx].v_plmn EQ mmShrdPrm.usedPLMN.v_plmn AND
662 memcmp (mmShrdPrm.PLMNLst[lstIdx].mcc,
663 mmShrdPrm.usedPLMN.mcc,
664 SIZE_MCC) EQ 0 AND
665 memcmp (mmShrdPrm.PLMNLst[lstIdx].mnc,
666 mmShrdPrm.usedPLMN.mnc, SIZE_MNC) EQ 0)
667 {
668 operLst[lstIdx].status = COPS_STAT_Current;
669 }
670 else
671 {
672 switch( mmShrdPrm.FRBLst[lstIdx] )
673 {
674 case( FORB_PLMN_NOT_INCLUDED ):
675 operLst[lstIdx].status = COPS_STAT_Available;
676 break;
677 case( 1 /*FORB_PLMN_INCLUDED*/ ):
678 operLst[lstIdx].status = COPS_STAT_Forbidden;
679 break;
680 default:
681 operLst[lstIdx].status = COPS_STAT_Unknown;
682 break;
683 }
684 }
685 }
686
687 #if defined (GPRS) AND defined (DTI)
688 psaG_MM_CMD_SET_REGMD ( mmShrdPrm.regMode ); /* restore former registration mode*/
689 #else
690 /* restore former registration mode */
691 psaMM_SetRegMode ( mmShrdPrm.regMode );
692 #endif
693 bufCmd = mmEntStat.curCmd;
694 mmEntStat.curCmd = AT_CMD_NONE;
695 if(bufCmd EQ AT_CMD_COPS)
696 {
697 R_AT( RAT_COPS, mmEntStat.entOwn )
698 ( --lstIdx, &operLst[0]);
699 }
700 else
701 {
702 R_AT( RAT_P_COPS, mmEntStat.entOwn )
703 ( --lstIdx, &operLst[0]);
704 }
705 R_AT( RAT_OK, mmEntStat.entOwn )
706 ( mmEntStat.curCmd );
707
708 /* log result */
709 cmh_logRslt ( mmEntStat.entOwn, RAT_OK, mmEntStat.curCmd , -1, -1, -1 );
710
711 ACI_MFREE (op_name);
712 ACI_MFREE (operLst);
713
714 break;
715 }
716
717 return 0;
718 }
719
720 /*
721 +-------------------------------------------------------------------+
722 | PROJECT : GSM-PS (6147) MODULE : CMH_MMR |
723 | ROUTINE : cmhMM_SelNetwork |
724 +-------------------------------------------------------------------+
725
726 PURPOSE : Select a network
727
728 */
729
730 GLOBAL SHORT cmhMM_SelNetwork ( void )
731 {
732 TRACE_FUNCTION ("cmhMM_SelNetwork()");
733
734 switch( mmEntStat.curCmd )
735 {
736 case( AT_CMD_COPS ):
737
738 #if defined (GPRS) AND defined (DTI)
739 psaG_MM_CMD_SET_REGMD ( mmShrdPrm.regMode ); /* restore former registration mode*/
740 #else
741 /* restore former registration mode */
742 psaMM_SetRegMode ( mmShrdPrm.regMode );
743 #endif
744
745 /* If the SIM is not inserted or if the SIM requires a PIN, more meaningful error
746 * codes are returned*/
747 if ( (cmhSIM_GetSIMError(mmEntStat.entOwn, mmEntStat.curCmd)) NEQ AT_CMPL)
748 {
749 R_AT( RAT_CME, mmEntStat.entOwn ) ( mmEntStat.curCmd , CME_ERR_NotPresent);
750 }
751
752 /* log result */
753 cmh_logRslt ( mmEntStat.entOwn, RAT_CME, mmEntStat.curCmd , -1, -1, CME_ERR_NotPresent );
754
755 mmEntStat.curCmd = AT_CMD_NONE;
756
757 break;
758 }
759
760 return 0;
761 }
762
763
764 /*
765 +-------------------------------------------------------------------+
766 | PROJECT : GSM-PS (6147) MODULE : CMH_MMR |
767 | ROUTINE : cmhMM_CipheringInd |
768 +-------------------------------------------------------------------+
769
770 PURPOSE : ciphering indication received
771
772 */
773
774 GLOBAL SHORT cmhMM_CipheringInd ( UBYTE ciph )
775 {
776 SHORT idx; /* holds index counter */
777
778 TRACE_FUNCTION ("cmhMM_CipheringInd()");
779
780 if (simShrdPrm.ciSIMEnabled NEQ TRUE)
781 {
782 return 1;
783 }
784
785 for (idx = 0; idx < CMD_SRC_MAX; idx++)
786 {
787 /*
788 *-----------------------------------------------------------------
789 * new message indication
790 *-----------------------------------------------------------------
791 */
792 #ifndef GPRS
793 #define CIPH_NA 2
794 #endif
795 R_AT(RAT_P_CPRI,idx) ( ciph, CIPH_NA );
796 }
797 return 0;
798 }
799
800
801 /*==== EOF ========================================================*/
802