comparison src/aci2/aci/psa_sims.c @ 3:93999a60b835

src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Sep 2016 00:29:36 +0000
parents
children
comparison
equal deleted inserted replaced
2:c41a534f33c6 3:93999a60b835
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : PSA_SIMS
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 signalling functions of the
18 | protocol stack adapter for the subscriber identity
19 | module.
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef PSA_SIMS_C
24 #define PSA_SIMS_C
25 #endif
26
27 #include "aci_all.h"
28
29 /*==== INCLUDES ===================================================*/
30 #include "aci_cmh.h"
31 #include "ati_cmd.h"
32 #include "aci_cmd.h"
33 #include "aci.h"
34 #include "psa.h"
35 #include "psa_sim.h"
36
37 #include "aci_mem.h"
38 #ifdef SIM_TOOLKIT
39 #include "psa_cc.h"
40 #include "psa_sat.h"
41 #include "ati_src_sat.h"
42 #include "psa_tcpip.h"
43 #endif/* SIM_TOOLKIT */
44
45 #ifdef DTI
46 #include "dti.h"
47 #include "dti_conn_mng.h"
48 #include "dti_cntrl_mng.h"
49 #endif
50
51 #if defined GPRS AND defined (DTI)
52 #include "gprs.h"
53 #include "gaci.h"
54 #include "gaci_cmh.h"
55 #include "gaci_srcc.h"
56 #include "psa_sm.h"
57
58 #ifdef FAX_AND_DATA
59 #include "aci_fd.h"
60 #endif /* FAX_AND_DATA */
61
62 #endif /* GPRS */
63
64 #include "cmh.h"
65
66 #if defined (GPRS) AND defined (DTI)
67 #include "cmh_sm.h"
68 #endif /* GPRS */
69
70 #include "cmh_sim.h"
71 #include "cmh_sat.h"
72
73 #include "psa_util.h"
74
75 #ifndef _SIMULATION_
76
77 /* temporary solution to get ffs.h included without GPRS to be set ! */
78 #ifdef GPRS
79 #include "ffs/ffs.h"
80 #else
81 #include "ffs/ffs.h"
82 #undef GPRS
83 #endif /* GPRS */
84 #include "ffs_coat.h"
85
86 #endif /* !_SIMULATION_ */
87
88
89 /*==== CONSTANTS ==================================================*/
90
91
92 /*==== TYPES ======================================================*/
93
94
95 /*==== EXPORT =====================================================*/
96
97
98 /*==== VARIABLES ==================================================*/
99 LOCAL BOOL Cust_Mode_Set = FALSE;
100
101 /*==== FUNCTIONS ==================================================*/
102
103 GLOBAL BOOL psaSIM_hasCustModeBeenSet(void)
104 {
105 return Cust_Mode_Set;
106 }
107
108 /*
109 +-------------------------------------------------------------------+
110 | PROJECT : GSM-PS (6147) MODULE : PSA_SIMS |
111 | ROUTINE : psaSIM_AccessSIMData |
112 +-------------------------------------------------------------------+
113
114 PURPOSE : access SIM data
115
116 */
117
118 GLOBAL SHORT psaSIM_AccessSIMData ( void )
119 {
120 SHORT aId; /* holds access id */
121
122 TRACE_FUNCTION ("psaSIM_AccessSIMData()");
123
124 /*
125 *-------------------------------------------------------------------
126 * determine access type
127 *-------------------------------------------------------------------
128 */
129 aId = simShrdPrm.aId;
130
131 switch( simShrdPrm.atb[aId].accType )
132 {
133 /*
134 *---------------------------------------------------------------
135 * read datafield
136 *---------------------------------------------------------------
137 */
138 case( ACT_RD_DAT ):
139 {
140 PALLOC (sim_read_req, SIM_READ_REQ);
141
142 /* fill in primitive parameter: read data request */
143 sim_read_req -> source = SRC_MMI;
144 sim_read_req -> datafield = simShrdPrm.atb[aId].reqDataFld;
145 sim_read_req -> offset = simShrdPrm.atb[aId].dataOff;
146 sim_read_req -> length = simShrdPrm.atb[aId].dataLen;
147 sim_read_req -> max_length = simShrdPrm.atb[aId].recMax;
148 PSENDX (SIM, sim_read_req);
149 }
150 break;
151
152 /*
153 *---------------------------------------------------------------
154 * write datafield
155 *---------------------------------------------------------------
156 */
157 case( ACT_WR_DAT ):
158 {
159 PALLOC (sim_update_req, SIM_UPDATE_REQ);
160
161 /* fill in primitive parameter: update data request */
162 sim_update_req -> source = SRC_MMI;
163 sim_update_req -> datafield = simShrdPrm.atb[aId].reqDataFld;
164 sim_update_req -> offset = simShrdPrm.atb[aId].dataOff;
165 sim_update_req -> length = simShrdPrm.atb[aId].dataLen;
166 memcpy (sim_update_req -> trans_data, simShrdPrm.atb[aId].exchData,
167 simShrdPrm.atb[aId].dataLen);
168
169 PSENDX (SIM, sim_update_req);
170 }
171 break;
172
173 /*
174 *---------------------------------------------------------------
175 * read record
176 *---------------------------------------------------------------
177 */
178 case( ACT_RD_REC ):
179 {
180 PALLOC (sim_read_record_req, SIM_READ_RECORD_REQ);
181
182 /* fill in primitive parameter: read absolute record request */
183 sim_read_record_req -> source = SRC_MMI;
184 sim_read_record_req -> datafield = simShrdPrm.atb[aId].reqDataFld;
185 sim_read_record_req -> record = simShrdPrm.atb[aId].recNr;
186 if(simShrdPrm.atb[aId].check_dataLen)
187 {
188 sim_read_record_req -> length = NOT_PRESENT_8BIT;
189 }
190 else
191 {
192 sim_read_record_req -> length = simShrdPrm.atb[aId].dataLen;
193 }
194 PSENDX (SIM, sim_read_record_req);
195 }
196 break;
197
198 /*
199 *---------------------------------------------------------------
200 * write record
201 *---------------------------------------------------------------
202 */
203 case( ACT_WR_REC ):
204 {
205 PALLOC (sim_update_record_req, SIM_UPDATE_RECORD_REQ);
206
207 /* fill in primitive parameter: update absolute record request */
208 sim_update_record_req -> source = SRC_MMI;
209 sim_update_record_req -> datafield = simShrdPrm.atb[aId].reqDataFld;
210 sim_update_record_req -> record = simShrdPrm.atb[aId].recNr;
211 sim_update_record_req -> length = simShrdPrm.atb[aId].dataLen;
212 memcpy (sim_update_record_req -> linear_data,
213 simShrdPrm.atb[aId].exchData, sim_update_record_req->length);
214
215 PSENDX (SIM, sim_update_record_req);
216 }
217 break;
218
219 /*
220 *---------------------------------------------------------------
221 * increment datafield
222 *---------------------------------------------------------------
223 */
224 case( ACT_INC_DAT ):
225 {
226 PALLOC (sim_increment_req, SIM_INCREMENT_REQ);
227
228 /* fill in primitive parameter: increment data request */
229 sim_increment_req -> source = SRC_MMI;
230 sim_increment_req -> datafield = simShrdPrm.atb[aId].reqDataFld;
231 sim_increment_req -> length = simShrdPrm.atb[aId].dataLen;
232 memcpy (sim_increment_req -> linear_data, simShrdPrm.atb[aId].exchData,
233 sim_increment_req->length);
234
235 PSENDX (SIM, sim_increment_req);
236 }
237 break;
238
239 /*
240 *---------------------------------------------------------------
241 * illegal access type
242 *---------------------------------------------------------------
243 */
244 default:
245
246 TRACE_EVENT("UNEXP ACCESS TYPE IN ATB");
247 return( -1 );
248 }
249 /*
250 *-------------------------------------------------------------------
251 * create and send primitive
252 *-------------------------------------------------------------------
253 */
254
255 return 0;
256 }
257
258 /*
259 +-------------------------------------------------------------------+
260 | PROJECT : GSM-PS (6147) MODULE : PSA_SIMS |
261 | ROUTINE : psaSIM_VerifyPIN |
262 +-------------------------------------------------------------------+
263
264 PURPOSE : verify a PIN
265
266 */
267
268 GLOBAL SHORT psaSIM_VerifyPIN ( void )
269 {
270 T_SIM_SET_PRM * pPrmSet; /* points to used parameter set */
271
272 TRACE_FUNCTION ("psaSIM_VerifyPIN()");
273
274 /*
275 *-------------------------------------------------------------------
276 * check owner id
277 *-------------------------------------------------------------------
278 */
279 if(!psa_IsVldOwnId(simShrdPrm.owner))
280
281 return( -1 );
282
283 pPrmSet = &simShrdPrm.setPrm[simShrdPrm.owner];
284
285 /*
286 *-------------------------------------------------------------------
287 * create and send primitive
288 *-------------------------------------------------------------------
289 */
290 {
291 PALLOC (sim_verify_pin_req, SIM_VERIFY_PIN_REQ);
292
293 /* fill in primitive parameter: verify PIN request */
294 sim_verify_pin_req -> source = SRC_MMI;
295 sim_verify_pin_req -> pin_id = pPrmSet -> PINType;
296 memcpy( sim_verify_pin_req -> pin, pPrmSet -> curPIN, PIN_LEN );
297
298 PSENDX (SIM, sim_verify_pin_req);
299 }
300
301 return 0;
302 }
303
304 /*
305 +-------------------------------------------------------------------+
306 | PROJECT : GSM-PS (6147) MODULE : PSA_SIMS |
307 | ROUTINE : psaSIM_ChangePIN |
308 +-------------------------------------------------------------------+
309
310 PURPOSE : change a PIN
311
312 */
313
314 GLOBAL SHORT psaSIM_ChangePIN ( void )
315 {
316 T_SIM_SET_PRM * pPrmSet; /* points to used parameter set */
317
318 TRACE_FUNCTION ("psaSIM_ChangePIN()");
319
320 /*
321 *-------------------------------------------------------------------
322 * check owner id
323 *-------------------------------------------------------------------
324 */
325 if(!psa_IsVldOwnId(simShrdPrm.owner))
326
327 return( -1 );
328
329 pPrmSet = &simShrdPrm.setPrm[simShrdPrm.owner];
330
331 /*
332 *-------------------------------------------------------------------
333 * create and send primitive
334 *-------------------------------------------------------------------
335 */
336 {
337 PALLOC (sim_change_pin_req, SIM_CHANGE_PIN_REQ);
338
339 /* fill in primitive parameter: change PIN request */
340 sim_change_pin_req -> source = SRC_MMI;
341 sim_change_pin_req -> pin_id = pPrmSet -> PINType;
342 memcpy( sim_change_pin_req -> old_pin, pPrmSet -> curPIN, PIN_LEN );
343 memcpy( sim_change_pin_req -> new_pin, pPrmSet -> newPIN, PIN_LEN );
344
345 PSENDX (SIM, sim_change_pin_req);
346 }
347
348 return 0;
349 }
350
351
352 /*
353 +-------------------------------------------------------------------+
354 | PROJECT : GSM-PS (6147) MODULE : PSA_SIMS |
355 | ROUTINE : psaSIM_DisablePIN |
356 +-------------------------------------------------------------------+
357
358 PURPOSE : disable a PIN
359
360 */
361
362 GLOBAL SHORT psaSIM_DisablePIN ( void )
363 {
364 T_SIM_SET_PRM * pPrmSet; /* points to used parameter set */
365
366 TRACE_FUNCTION ("psaSIM_DisablePIN()");
367
368 /*
369 *-------------------------------------------------------------------
370 * check owner id
371 *-------------------------------------------------------------------
372 */
373 if(!psa_IsVldOwnId(simShrdPrm.owner))
374
375 return( -1 );
376
377 pPrmSet = &simShrdPrm.setPrm[simShrdPrm.owner];
378
379 /*
380 *-------------------------------------------------------------------
381 * create and send primitive
382 *-------------------------------------------------------------------
383 */
384 {
385 PALLOC (sim_disable_pin_req, SIM_DISABLE_PIN_REQ);
386
387 /* fill in primitive parameter: disable PIN request */
388 sim_disable_pin_req -> source = SRC_MMI;
389 memcpy( sim_disable_pin_req -> pin, pPrmSet -> curPIN, PIN_LEN );
390
391 PSENDX (SIM, sim_disable_pin_req);
392 }
393
394 return 0;
395 }
396
397 /*
398 +-------------------------------------------------------------------+
399 | PROJECT : GSM-PS (6147) MODULE : PSA_SIMS |
400 | ROUTINE : psaSIM_EnablePIN |
401 +-------------------------------------------------------------------+
402
403 PURPOSE : enable a PIN
404
405 */
406
407 GLOBAL SHORT psaSIM_EnablePIN ( void )
408 {
409 T_SIM_SET_PRM * pPrmSet; /* points to used parameter set */
410
411 TRACE_FUNCTION ("psaSIM_EnablePIN()");
412
413 /*
414 *-------------------------------------------------------------------
415 * check owner id
416 *-------------------------------------------------------------------
417 */
418 if(!psa_IsVldOwnId(simShrdPrm.owner))
419
420 return( -1 );
421
422 pPrmSet = &simShrdPrm.setPrm[simShrdPrm.owner];
423
424 /*
425 *-------------------------------------------------------------------
426 * create and send primitive
427 *-------------------------------------------------------------------
428 */
429 {
430 PALLOC (sim_enable_pin_req, SIM_ENABLE_PIN_REQ);
431
432 /* fill in primitive parameter: enable PIN request */
433 sim_enable_pin_req -> source = SRC_MMI;
434 memcpy( sim_enable_pin_req -> pin, pPrmSet -> curPIN, PIN_LEN );
435
436 PSENDX (SIM, sim_enable_pin_req);
437 }
438
439 return 0;
440 }
441
442 /*
443 +-------------------------------------------------------------------+
444 | PROJECT : GSM-PS (6147) MODULE : PSA_SIMS |
445 | ROUTINE : psaSIM_UnblockCard |
446 +-------------------------------------------------------------------+
447
448 PURPOSE : unblock the card
449
450 */
451
452 GLOBAL SHORT psaSIM_UnblockCard ( void )
453 {
454 T_SIM_SET_PRM * pPrmSet; /* points to used parameter set */
455
456 TRACE_FUNCTION ("psaSIM_UnblockCard()");
457
458 /*
459 *-------------------------------------------------------------------
460 * check owner id
461 *-------------------------------------------------------------------
462 */
463 if(!psa_IsVldOwnId(simShrdPrm.owner))
464
465 return( -1 );
466
467 pPrmSet = &simShrdPrm.setPrm[simShrdPrm.owner];
468
469 /*
470 *-------------------------------------------------------------------
471 * create and send primitive
472 *-------------------------------------------------------------------
473 */
474 {
475 PALLOC (sim_unblock_req, SIM_UNBLOCK_REQ);
476
477 /* fill in primitive parameter: unblock card request */
478 sim_unblock_req -> source = SRC_MMI;
479 sim_unblock_req -> pin_id = pPrmSet -> PINType;
480 memcpy( sim_unblock_req -> pin, pPrmSet -> curPIN, PIN_LEN );
481 memcpy( sim_unblock_req -> unblock_key, pPrmSet -> unblkKey, PUK_LEN );
482
483 PSENDX (SIM, sim_unblock_req);
484 }
485
486 return 0;
487 }
488
489 /*
490 +-------------------------------------------------------------------+
491 | PROJECT : GSM-PS (6147) MODULE : PSA_SIMS |
492 | ROUTINE : psaSIM_SyncSIM |
493 +-------------------------------------------------------------------+
494
495 PURPOSE : synchronize SIM data
496
497 */
498
499 GLOBAL void psaSIM_SyncSIM ( void )
500 {
501 TRACE_FUNCTION ("psaSIM_SyncSIM()");
502
503 /* create and send primitive */
504 {
505 PALLOC (sim_sync_req, SIM_SYNC_REQ);
506
507 /* fill in primitive parameter: synchronize request */
508
509 sim_sync_req -> synccs = simShrdPrm.synCs;
510
511 PSENDX (SIM, sim_sync_req);
512 }
513 }
514
515 /*
516 +-------------------------------------------------------------------+
517 | PROJECT : GSM-PS (6147) MODULE : PSA_SIMS |
518 | ROUTINE : psaSIM_ActivateSIM |
519 +-------------------------------------------------------------------+
520
521 PURPOSE : synchronize SIM data
522
523 */
524
525 GLOBAL SHORT psaSIM_ActivateSIM ( void )
526 {
527 T_SIM_SET_PRM * pPrmSet; /* points to used parameter set */
528
529 TRACE_FUNCTION ("psaSIM_ActivateSIM()");
530
531 /*
532 *-------------------------------------------------------------------
533 * check owner id
534 *-------------------------------------------------------------------
535 */
536 if(!psa_IsVldOwnId(simShrdPrm.owner))
537 {
538 TRACE_EVENT("not a valid owner !!");
539 return( -1 );
540 }
541
542 pPrmSet = &simShrdPrm.setPrm[simShrdPrm.owner];
543
544 /*
545 *-------------------------------------------------------------------
546 * create and send primitive
547 *-------------------------------------------------------------------
548 */
549 {
550 PALLOC (sim_activate_req, SIM_ACTIVATE_REQ);
551
552 /* fill in primitive parameter: activate request */
553 sim_activate_req->proc = pPrmSet -> actProc;
554
555 /* sim toolkit profile */
556 memcpy( sim_activate_req->stk_pro_file, pPrmSet -> STKprof,
557 MAX_STK_PRF );
558 sim_activate_req->mmi_pro_file = 0xE0; /*enable all*/
559
560 if (pPrmSet -> actProc == SIM_INITIALISATION)
561 {
562 if (psaSIM_hasCustModeBeenSet() == FALSE)
563 {
564 /*
565 ** Customisation Mode is to be global, applying to ALL ACI channels
566 */
567 simShrdPrm.overall_cust_mode = pPrmSet->cust_mode;
568 Cust_Mode_Set = TRUE;
569 }
570
571 sim_activate_req->cust_mode = simShrdPrm.overall_cust_mode;
572 }
573 else
574 {
575 /*
576 ** If this isn't SIM_INITIALISATION then the cust_mode will have no relevance, but it should
577 ** still not be left uninitialised.
578 */
579 sim_activate_req->cust_mode = (psaSIM_hasCustModeBeenSet() == FALSE) ?
580 (UBYTE)CUST_NORMAL_BEHAVIOUR: simShrdPrm.overall_cust_mode;
581 }
582
583 if(sim_activate_req->proc EQ SIM_INITIALISATION)
584 {
585 sim_activate_req->v_trmst_file = 0x01;
586 TRACE_EVENT("Read Terminal Support table from FFS");
587 #ifndef _SIMULATION_
588 if(FFS_fread("/gsm/osf/ftrsprt", &sim_activate_req->trmst_file, MAX_TRMST) NEQ MAX_TRMST)
589 #endif /* _SIMULATION_ */
590 {
591 memset(&sim_activate_req->trmst_file, 0, MAX_TRMST);
592 }
593 }
594
595 PSENDX (SIM, sim_activate_req);
596 }
597
598 return 0;
599 }
600
601 /*
602 +-------------------------------------------------------------------+
603 | PROJECT : GSM-PS (6147) MODULE : PSA_SIMS |
604 | ROUTINE : psaSIM_TrnsSIMAccess |
605 +-------------------------------------------------------------------+
606
607 PURPOSE : transparent access to SIM data
608
609 */
610
611 GLOBAL SHORT psaSIM_TrnsSIMAccess ( T_SIM_TRNS_ACC_PRM * prm )
612 {
613
614 TRACE_FUNCTION ("psaSIM_TrnsSIMAccess()");
615
616 /*
617 *-------------------------------------------------------------------
618 * create and send primitive
619 *-------------------------------------------------------------------
620 */
621 {
622 PALLOC (sim_access_req, SIM_ACCESS_REQ);
623
624 /* fill in primitive parameter: SIM access request */
625 sim_access_req -> source = SRC_MMI;
626 sim_access_req -> sim_command = prm -> cmd;
627
628 if (prm->cmd NEQ SIM_TRANSP_CMD)
629 {
630 sim_access_req -> datafield = prm -> reqDataFld;
631 sim_access_req -> p1 = prm -> p1;
632 sim_access_req -> p2 = prm -> p2;
633 sim_access_req -> p3 = prm -> p3;
634 }
635
636 sim_access_req->c_trans_data = prm -> dataLen;
637 memcpy( sim_access_req -> trans_data, prm -> transData,
638 prm -> dataLen );
639
640 PSENDX (SIM, sim_access_req);
641 }
642
643 return 0;
644 }
645
646 /*
647 +-------------------------------------------------------------------+
648 | PROJECT : GSM-PS (6147) MODULE : PSA_SIMS |
649 | ROUTINE : psaSIM_Bpi_Req |
650 +-------------------------------------------------------------------+
651
652 PURPOSE : resume/suspend/connect/disconnect SAT BIP connection.
653 */
654 #if defined (FF_SAT_E) AND defined (DTI)
655 GLOBAL void psaSIM_Bip_Req ( void )
656 {
657 T_SAT_CSD_PRM * csd_prm_ptr;
658
659 TRACE_EVENT("psaSIM_Bip_Req()");
660
661 if (simShrdPrm.sim_dti_chPrm EQ NULL)
662 {
663 TRACE_ERROR ("ERROR: simShrdPrm.sim_dti_chPrm uninitalized, aborting!");
664 }
665 else
666 {
667 PALLOC(sim_bip_req,SIM_BIP_REQ);
668 memset(sim_bip_req,0,sizeof(sim_bip_req));
669
670 /* copy connection qualifier */
671 sim_bip_req->bip_conn = simShrdPrm.sim_dti_chPrm->sat_chn_prm.bipConn;
672 /* copy channel id */
673 sim_bip_req->bip_ch_id = simShrdPrm.sim_dti_chPrm->sat_chn_prm.chnId;
674 /* copy general result */
675 sim_bip_req->general_result = simShrdPrm.sim_dti_chPrm->sat_chn_prm.genRes;
676 /* copy additional result info */
677 sim_bip_req->add_info_result = simShrdPrm.sim_dti_chPrm->sat_chn_prm.addRes;
678
679 /* copy release timer to primitive, if CSD and if duration defined */
680 /* SAT_E_PATCH: Should be ported to SIM_BIP_CONFIG_REQ? */
681 if(satShrdPrm.opchType EQ B_CSD)
682 {
683 csd_prm_ptr = (T_SAT_CSD_PRM *)(satShrdPrm.opchPrm);
684 if(csd_prm_ptr NEQ NULL)
685 {
686 if(csd_prm_ptr->v_dur2)
687 {
688 switch(csd_prm_ptr->dur2.time_unit)
689 {
690 case TU_100_MSEC:
691 sim_bip_req->release_time = (U32)csd_prm_ptr->dur2.time_ivl;
692 break;
693 case TU_MIN:
694 sim_bip_req->release_time = (U32)(csd_prm_ptr->dur2.time_ivl * 600);
695 break;
696 case TU_SEC:
697 sim_bip_req->release_time = (U32)(csd_prm_ptr->dur2.time_ivl * 10);
698 break;
699 } /* end switch */
700 } /* end if */
701 } /* end if csd_prm_ptr NEQ NULL */
702 } /* end if */
703
704 /* SEND SIM_BIP_REQ */
705 PSENDX(SIM,sim_bip_req);
706 } /* end else*/
707
708 }
709
710 /*
711 +-------------------------------------------------------------------+
712 | PROJECT : GSM-PS (6147) MODULE : PSA_SIMS |
713 | ROUTINE : psaSIM_Bip_Config_Req |
714 +-------------------------------------------------------------------+
715
716 PURPOSE : sends the BIP channel parameters to SIM. The type of
717 parameters depends on the transport unit.
718 */
719
720 GLOBAL void psaSIM_Bip_Config_Req ( )
721 {
722 T_SAT_CSD_PRM * csd_prm_ptr; /* holds pointer to CSD open channel prms */
723 T_SAT_GPRS_PRM * gprs_prm_ptr; /* holds pointer to GPRS open channel prms */
724
725 /* allocate SIM_BIP_CONFIG_REQ primitive */
726 PALLOC(sim_bip_config_req,SIM_BIP_CONFIG_REQ);
727
728 TRACE_EVENT("psaSIM_Bip_Config_Req()");
729
730 /* reset values of primitive */
731 memset(sim_bip_config_req,0,sizeof(sim_bip_config_req));
732 /* check kind of bearer */
733 if(satShrdPrm.opchType EQ B_CSD)
734 {
735 /* BEARER: CSD */
736
737 /* get connection type */
738 switch(simShrdPrm.sim_dti_chPrm->sat_chn_prm.dtiUnit)
739 {
740 case DTI_ENTITY_UDP:
741 sim_bip_config_req->con_type = SIM_CON_TYPE_UDP;
742 break;
743 #ifdef UART
744 case DTI_ENTITY_TRA:
745 sim_bip_config_req->con_type = SIM_CON_TYPE_SERIAL;
746 break;
747 case DTI_ENTITY_L2R:
748 sim_bip_config_req->con_type = SIM_CON_TYPE_SERIAL;
749 break;
750 #endif
751 }
752
753 /* get addresses */
754 /* local_ip,destination_ip, destination port are only valid for UDP */
755 if(simShrdPrm.sim_dti_chPrm->sat_chn_prm.dtiUnit EQ DTI_ENTITY_UDP)
756 {
757 csd_prm_ptr = (T_SAT_CSD_PRM *)(satShrdPrm.opchPrm);
758 if(csd_prm_ptr->v_other_addr)
759 {
760 if(csd_prm_ptr->other_addr.oth_addr_type EQ IPv4)
761 {
762 if(csd_prm_ptr->other_addr.v_ipv4_addr)/* local IP address */
763 {
764 memcpy(&sim_bip_config_req->local_ip,
765 &csd_prm_ptr->other_addr.ipv4_addr,
766 sizeof(csd_prm_ptr->other_addr.ipv4_addr));
767 }
768 else /* not valid */
769 {
770 sim_bip_config_req->local_ip = SIM_IP_LOCAL_DYNAMIC;
771 }
772 }
773 else /* not supported IPv6*/
774 {
775 sim_bip_config_req->local_ip = SIM_IP_LOCAL_DYNAMIC;
776 }
777 }
778 else
779 {
780 sim_bip_config_req->local_ip = SIM_IP_LOCAL_DYNAMIC;
781 }
782
783 /* data destination address */
784 if(csd_prm_ptr->v_dda)
785 {
786 if(csd_prm_ptr->dda.oth_addr_type EQ IPv4)
787 {
788 if(csd_prm_ptr->dda.v_ipv4_addr)/* local IP address */
789 {
790 memcpy(&sim_bip_config_req->destination_ip,
791 &csd_prm_ptr->dda.ipv4_addr,
792 sizeof(csd_prm_ptr->dda.ipv4_addr));
793 }
794 }
795
796 /* SIM/ME interface transport level:destination port number for UDP */
797 if(csd_prm_ptr->v_itl)
798 {
799 sim_bip_config_req->destination_port = csd_prm_ptr->itl.port_number;
800 }
801 }
802 }
803 }
804 else if (satShrdPrm.opchType EQ B_GPRS)
805 {
806 /* BEARER: GPRS */
807 #ifdef GPRS
808 /* get connecton type */
809 switch(simShrdPrm.sim_dti_chPrm->sat_chn_prm.dtiUnit)
810 {
811 case DTI_ENTITY_UDP:
812 sim_bip_config_req->con_type = SIM_CON_TYPE_UDP;
813 break;
814 case DTI_ENTITY_SNDCP:
815 sim_bip_config_req->con_type = SIM_CON_TYPE_IP;
816 break;
817 }
818
819 /* get port and addresses */
820 gprs_prm_ptr = (T_SAT_GPRS_PRM *)(satShrdPrm.opchPrm);
821 if(gprs_prm_ptr NEQ NULL)
822 {
823 /* local_ip,destination_ip, destination port are only valid for UDP */
824 if(simShrdPrm.sim_dti_chPrm->sat_chn_prm.dtiUnit EQ DTI_ENTITY_UDP)
825 {
826 /* get local ip address */
827 if(gprs_prm_ptr->v_other_addr)
828 {
829 if(gprs_prm_ptr->other_addr.oth_addr_type EQ IPv4)
830 {
831 if(gprs_prm_ptr->other_addr.v_ipv4_addr)/* local IP address */
832 {
833 memcpy(&sim_bip_config_req->local_ip,
834 &gprs_prm_ptr->other_addr.ipv4_addr,
835 sizeof(gprs_prm_ptr->other_addr.ipv4_addr));
836 }
837 else /* not valid */
838 {
839 sim_bip_config_req->local_ip = SIM_IP_LOCAL_DYNAMIC;
840 }
841 }
842 else /* not supported IPv6*/
843 {
844 sim_bip_config_req->local_ip = SIM_IP_LOCAL_DYNAMIC;
845 }
846 }
847 else /* not valid flag for other address */
848 {
849 /*
850 * local IP4 address has been provided by Session Management; it was not provided by the OPEN CHANNEL command
851 */
852 if(tcpipShrdPrm.ipaddr)
853 {
854 sim_bip_config_req->local_ip = psaTCPIP_bytes2ipv4addr(tcpipShrdPrm.ipaddr);
855 }
856 else
857 {
858 sim_bip_config_req->local_ip = SIM_IP_LOCAL_DYNAMIC;
859 }
860 }
861
862 /* get data destination address */
863 if(gprs_prm_ptr->v_dda)
864 {
865 if(gprs_prm_ptr->dda.oth_addr_type EQ IPv4)
866 {
867 if(gprs_prm_ptr->dda.v_ipv4_addr)/* local IP address */
868 {
869 memcpy(&sim_bip_config_req->destination_ip,
870 &gprs_prm_ptr->dda.ipv4_addr,
871 sizeof(gprs_prm_ptr->dda.ipv4_addr));
872 }
873 }
874 }
875
876 /* get SIM/ME interface transport level:destination port number for UDP */
877 if(gprs_prm_ptr->v_itl)
878 {
879 sim_bip_config_req->destination_port = gprs_prm_ptr->itl.port_number;
880 }
881 }
882 }
883
884 #else /* GPRS */
885 PFREE(sim_bip_config_req);
886 TRACE_ERROR("psaSIM_Bip_Config_Req(): ERROR stack does not support GPRS");
887 #endif /* GPRS */
888 }
889 else /* BEARER: unknown */
890 {
891 TRACE_ERROR("psaSIM_Bip_Config_Req(): ERROR unkown bearer");
892 }
893 /* send primitive to SIM */
894 PSENDX(SIM,sim_bip_config_req);
895 }
896
897 /*
898 +-------------------------------------------------------------------+
899 | PROJECT : GSM-PS (6147) MODULE : PSA_SIMS |
900 | ROUTINE : psaSIM_Dti_Req |
901 +-------------------------------------------------------------------+
902
903 PURPOSE : connection SIM with UDP,TRA or L2R in context CSD
904 connection SIM with UDP or SNDCP in context GPRS
905 request by proactive SIM CARD, set feature SAT CLASS e
906 sent parameter depends on kind of connection (dtiConn)
907
908 This function sends the primitive SIM_DTI_REQ which is
909 only responsible for the establishment of the SIM DTI
910 channel!
911 */
912 GLOBAL void psaSIM_Dti_Req ( ULONG link_id )
913 {
914 #ifdef DTI
915 CHAR *p_ent_name; /* hold peer name */
916
917 TRACE_EVENT("psaSIM_Dti_Req");
918
919 if (simShrdPrm.sim_dti_chPrm EQ NULL)
920 {
921 /* when disconnecting if previos state connecting;
922 * will otherwise crash the stack in ACISAT473H */
923 TRACE_ERROR ("simShrdPrm.sim_dti_chPrm uninitalized, aborting!");
924 }
925 else
926 {
927 /* alloc primitive */
928 PALLOC(sim_dti_req,SIM_DTI_REQ);
929 /* reset values */
930 memset(sim_dti_req,0,sizeof(sim_dti_req));
931 /* copy dti connection qualifier */
932 sim_dti_req->dti_conn = simShrdPrm.sim_dti_chPrm->sat_chn_prm.dtiConn;
933 /* set dti direction */
934 sim_dti_req->dti_direction = SIM_DTI_INVERTED;
935
936 if( simShrdPrm.sim_dti_chPrm->sat_chn_prm.dtiConn EQ SIM_DTI_CONNECT )
937 {
938 /* CASE: CONNECT IMMEDIATELY */
939 /* copy link id */
940 sim_dti_req->link_id = link_id;
941
942 if(satShrdPrm.opchType EQ B_CSD)
943 {
944 /* BEARER: CSD */
945 /* copy entity_name
946 * handle different transport protocols: L2R, RA and UDP */
947 switch(simShrdPrm.sim_dti_chPrm->sat_chn_prm.dtiUnit)
948 {
949 case DTI_ENTITY_UDP:
950 p_ent_name = &UDP_NAME[0];
951 break;
952 case DTI_ENTITY_TRA:
953 p_ent_name = &TRA_NAME[0];
954 break;
955 case DTI_ENTITY_L2R:
956 p_ent_name = &L2R_NAME[0];
957 break;
958 }
959 sim_dti_req->entity_name = (ULONG)p_ent_name;
960 }
961 #ifdef GPRS
962 else if(satShrdPrm.opchType EQ B_GPRS)
963 {
964 /* BEARER: GPRS */
965 /* copy entity_name
966 * handle different transport protocols: L2R, RA and UDP */
967 switch(simShrdPrm.sim_dti_chPrm->sat_chn_prm.dtiUnit)
968 {
969 case DTI_ENTITY_UDP:
970 p_ent_name = &UDP_NAME[0];
971 break;
972 case DTI_ENTITY_SNDCP:
973 p_ent_name = &SNDCP_NAME[0];
974 break;
975 }
976 sim_dti_req->entity_name = (ULONG)p_ent_name;
977 }
978 #endif /* GPRS */
979 else
980 {
981 TRACE_EVENT("psaSIM_Dti_Req:error");
982 }
983
984 PSENDX(SIM,sim_dti_req);
985 } /* end DTI open channel */
986
987 else if ( simShrdPrm.sim_dti_chPrm->sat_chn_prm.dtiConn EQ SIM_DTI_DISCONNECT )
988 {
989 /* CASE: CLOSE DTI CHANNEL */
990 /* copy link id */
991 sim_dti_req->link_id = link_id;
992
993 PSENDX(SIM,sim_dti_req);
994 }
995
996 else if ( simShrdPrm.sim_dti_chPrm->sat_chn_prm.dtiConn EQ SIM_DTI_UNKNOWN)
997 {
998 /* no primitive has to be send, free mem */
999 PFREE(sim_dti_req);
1000
1001 /* check whether a BIP channel has to be closed */
1002 if( simShrdPrm.sim_dti_chPrm->sat_chn_prm.bipConn
1003 EQ SIM_BIP_CLOSE_CHANNEL )
1004 {
1005 /* No action has to be performed, DTI channel already disconnected by
1006 * SIM */
1007 TRACE_EVENT("psaSIM_Dti_Req: SIM-DTI channel already disconnected");
1008
1009 /* inform dti manager about successfull disconnection */
1010 /* dti_cntrl_entity_disconnected (link_id, DTI_ENTITY_SIM); */
1011
1012 TRACE_EVENT("psaSIM_Dti_Req: close open BIP channel");
1013 /* send SIM_BIP_REQ to close BIP channel */
1014 psaSIM_Bip_Req();
1015 }
1016 else
1017 {
1018 TRACE_ERROR("psaSIM_Dti_Req: ERROR: Unkown parameter combination");
1019 }
1020 }
1021 else
1022 {
1023 /* no primitive has to be send, free mem */
1024 PFREE(sim_dti_req);
1025
1026 TRACE_ERROR("psaSIM_Dti_Req: ERROR: Unkown parameter");
1027 }
1028 }
1029 #endif
1030 }
1031
1032 /*
1033 +-------------------------------------------------------------------+
1034 | PROJECT : GSM-PS (6147) MODULE : PSA_SIMS |
1035 | ROUTINE : psaSIM_SATBIPChn |
1036 +-------------------------------------------------------------------+
1037
1038 PURPOSE : connect/disconnect/suspend/resume of BIP
1039 (Bearer Independent Protocol) connection for SAT
1040 (new for SAT_E_PATCH)
1041 */
1042
1043 GLOBAL void psaSIM_SATBIPChn ( T_SIM_SAT_CHN chnInf,
1044 void (*cb)(UBYTE bipConn, UBYTE chnId))
1045 {
1046 TRACE_EVENT("psaSIM_SATBIPChn()");
1047
1048 #ifdef UART
1049
1050 /* ALLOC shared paramenters for BIP if not yet done */
1051 if(!simShrdPrm.sim_dti_chPrm)
1052 {
1053 ACI_MALLOC(simShrdPrm.sim_dti_chPrm,sizeof(T_SIM_DTI_CH_PRM));
1054 /* reset parameters */
1055 memset(simShrdPrm.sim_dti_chPrm,0,sizeof(T_SIM_DTI_CH_PRM));
1056 TRACE_EVENT("ALLOC sim_dti_chPrm");
1057 }
1058
1059 /* copy bip related parameters */
1060 simShrdPrm.sim_dti_chPrm->sat_chn_prm.bipConn = chnInf.bipConn;
1061 simShrdPrm.sim_dti_chPrm->sat_chn_prm.dtiConn = chnInf.dtiConn;
1062 simShrdPrm.sim_dti_chPrm->sat_chn_prm.chnId = chnInf.chnId;
1063 simShrdPrm.sim_dti_chPrm->sat_chn_prm.genRes = chnInf.genRes;
1064 simShrdPrm.sim_dti_chPrm->sat_chn_prm.addRes = chnInf.addRes;
1065 /* callback to process after of BIP connection request */
1066 simShrdPrm.sim_dti_chPrm->bip_cb = cb;
1067
1068 switch( chnInf.bipConn )
1069 {
1070 case SIM_BIP_CLOSE_CHANNEL:
1071
1072 if(chnInf.dtiConn EQ SIM_DTI_DISCONNECT)
1073 {
1074 cmhSAT_OpChnClose( chnInf.bipConn, 1 );
1075 }
1076 else
1077 {
1078 if (dti_cntrl_is_dti_channel_connected (DTI_ENTITY_SIM, simShrdPrm.sat_class_e_dti_id) EQ TRUE)
1079 {
1080 /* SIM entity has disconnected the dti connection via SIM_DTI_BIP_IND */
1081 if (dti_cntrl_is_dti_channel_connected (DTI_ENTITY_UDP, simShrdPrm.sat_class_e_dti_id) EQ TRUE)
1082 cmhSAT_OpChnClose( chnInf.bipConn, 1 );
1083 else
1084 dti_cntrl_close_dpath_from_dti_id(simShrdPrm.sat_class_e_dti_id);
1085 }
1086 else
1087 {
1088 /* up to now there was not a dti connection with SIM entity */
1089 psaSIM_Bip_Req();
1090 }
1091 }
1092 break;
1093 case SIM_BIP_OPEN_CHANNEL:
1094 case SIM_BIP_CHANNEL_SUSPENDED:
1095 case SIM_BIP_CHANNEL_RESUMED:
1096 psaSIM_Bip_Req();
1097 break;
1098 default:
1099 TRACE_ERROR("ERROR: psaSIM_SATBIPChn() unknown BIP status");
1100 } /* end of switch */
1101
1102 /* old behavior: test */
1103 #endif /* UART */
1104 }
1105
1106 /*
1107 +-------------------------------------------------------------------+
1108 | PROJECT : GSM-PS (6147) MODULE : PSA_SIMS |
1109 | ROUTINE : psaSIM_SATChn |
1110 +-------------------------------------------------------------------+
1111
1112 PURPOSE : start of DTI connection SIM - UDP,L2R,SNDCP,TRA for CSD
1113 /GPRS
1114
1115 SAT E Design: Now only used for SIM DTI connections to SNDCP, L2R and TRA
1116
1117 */
1118 #ifdef DTI
1119 GLOBAL void psaSIM_SATChn ( T_SIM_SAT_CHN chnInf,
1120 void (*cb)(UBYTE dtiConn, UBYTE chnId))
1121 {
1122 T_ACI_CMD_SRC sat_src_id;
1123 UBYTE dti_conn = 0;
1124
1125 #ifdef GPRS
1126 SHORT cid_array[2] = { 0,INVALID_CID };
1127 cid_array[0] = satShrdPrm.chnTb.chnRefId;
1128 #endif
1129
1130 TRACE_EVENT("psaSIM_SATChn");
1131
1132 if(!simShrdPrm.sim_dti_chPrm)
1133 {
1134 ACI_MALLOC(simShrdPrm.sim_dti_chPrm,sizeof(T_SIM_DTI_CH_PRM));
1135 TRACE_EVENT("ALLOC sim_dti_chPrm");
1136 }
1137 else /* SIM entity has sent error, disable dti connection */
1138 {
1139 dti_conn = simShrdPrm.sim_dti_chPrm->sat_chn_prm.dtiConn;
1140 }
1141
1142 memcpy(&simShrdPrm.sim_dti_chPrm->sat_chn_prm,&chnInf,sizeof(T_SIM_SAT_CHN));
1143 simShrdPrm.sim_dti_chPrm->dti_cb = cb;/* callback for results of DTI connection -> SatSource */
1144
1145 if( chnInf.dtiConn EQ SIM_DTI_CONNECT )
1146 {
1147 if((sat_src_id = psa_search_SATSrcId()) >= 0)
1148 {
1149 T_DTI_ENTITY_ID entity_list[2];
1150 entity_list[0]= DTI_ENTITY_SIM;
1151 entity_list[1]= chnInf.dtiUnit;
1152
1153 if(satShrdPrm.opchType EQ B_CSD)
1154 {/* case immediately connection of SIM entity with L2R or TRA */
1155 /* case on demand connection of SIM entity with L2R or TRA */
1156
1157 /* create a SAT class E DTI ID if not present */
1158 if ( simShrdPrm.sat_class_e_dti_id EQ DTI_DTI_ID_NOTPRESENT )
1159 {
1160 simShrdPrm.sat_class_e_dti_id = dti_cntrl_new_dti(DTI_DTI_ID_NOTPRESENT);
1161 TRACE_EVENT_P1("sat_class_e_dti_id = %d", simShrdPrm.sat_class_e_dti_id);
1162 }
1163
1164 /* establish SIM-L2R or SIM-TRA DTI connection */
1165 dti_cntrl_est_dpath( simShrdPrm.sat_class_e_dti_id,
1166 entity_list,
1167 2,
1168 APPEND,
1169 SIM_ENT_CSDconnect_dti_cb);
1170 }
1171 #ifdef GPRS
1172 else if(satShrdPrm.opchType EQ B_GPRS)
1173 {/* case immediately: open and connect bip channel with help of DTI connection between SIM entity and UDP or SNDCP */
1174 /* case on demand: connect bip channel with help of DTI connection between SIM entity and UDP or SNDCP */
1175
1176 /* create a SAT class E DTI ID if not present */
1177 if ( simShrdPrm.sat_class_e_dti_id EQ DTI_DTI_ID_NOTPRESENT )
1178 {
1179 simShrdPrm.sat_class_e_dti_id = dti_cntrl_new_dti(DTI_DTI_ID_NOTPRESENT);
1180 TRACE_EVENT_P1("sat_class_e_dti_id = %d", simShrdPrm.sat_class_e_dti_id);
1181 }
1182
1183 if(chnInf.dtiUnit NEQ DTI_ENTITY_SNDCP)
1184 {
1185 dti_cntrl_est_dpath( simShrdPrm.sat_class_e_dti_id,
1186 entity_list,
1187 2,
1188 APPEND,
1189 SIM_ENT_GPRSconnect_dti_cb);
1190 }
1191 else
1192 {
1193 if(!srcc_reserve_sources( SRCC_SIM_SNDCP_LINK, satShrdPrm.chnTb.chnRefId) OR
1194 !cmhSM_define_cid_list((T_ACI_CMD_SRC)satShrdPrm.opchAcptSrc, cid_array) )
1195
1196 {
1197 TRACE_FUNCTION("psaSIM_SATChn: Error cid list ");
1198 }
1199 else
1200 {
1201 set_conn_param_on_working_cid( (UBYTE)smEntStat.entOwn, DTI_ENTITY_SIM );
1202 cmhSM_connect_working_cid();
1203 }
1204 }
1205 }
1206 #endif
1207 }
1208 else
1209 {
1210 TRACE_ERROR("psaSIM_SATChn: fatal ERROR: SAT source id invalid!");
1211 }
1212 }
1213 }
1214 #endif /* DTI */
1215
1216 /*
1217 +-------------------------------------------------------------------+
1218 | PROJECT : GSM-PS (6147) MODULE : PSA_SIMS |
1219 | ROUTINE : psaSIM_EvDatAvail |
1220 +-------------------------------------------------------------------+
1221
1222 PURPOSE : processes the SIM_EVENTLIST_REQ primitive to SIM.
1223 MMI informs about a change of the status of the
1224 Data available event (because it is part of the SAT event list)
1225 */
1226
1227 GLOBAL void psaSIM_EvDatAvail ( BOOL evStat )
1228 {
1229 TRACE_EVENT("psaSIM_EvDatAvail");
1230 {
1231 PALLOC(sim_eventlist_req,SIM_EVENTLIST_REQ);
1232 switch(evStat)
1233 {
1234 case SIM_EVENT_DISABLE:
1235 case SIM_EVENT_ENABLE:
1236 sim_eventlist_req->event_data_avail = evStat;
1237 break;
1238 default:
1239 TRACE_EVENT("psaSIM_EvDatAvail:not valid evStat");
1240 break;
1241 }
1242 PSENDX(SIM,sim_eventlist_req);
1243 }
1244 }
1245
1246 #endif /* #ifdef FF_SAT_E */
1247
1248 #ifdef FF_DUAL_SIM
1249 /*
1250 +-------------------------------------------------------------------+
1251 | PROJECT : GSM-PS (6147) MODULE : PSA_SIMS |
1252 | ROUTINE : psaSIM_SelectSIM |
1253 +-------------------------------------------------------------------+
1254
1255 PURPOSE : processes the SIM_ACTIVATE_REQ primitive to SIM to Select the required SIM
1256 */
1257 GLOBAL SHORT psaSIM_SelectSIM ( void )
1258 {
1259 T_SIM_SET_PRM * pPrmSet; /* points to used parameter set */
1260
1261 TRACE_FUNCTION ("psaSIM_SelectSIM()");
1262
1263 /*
1264 *-------------------------------------------------------------------
1265 * check owner id
1266 *-------------------------------------------------------------------
1267 */
1268 if(!psa_IsVldOwnId(simShrdPrm.owner))
1269 {
1270 TRACE_EVENT("not a valid owner !!");
1271 return( -1 );
1272 }
1273
1274 pPrmSet = &simShrdPrm.setPrm[simShrdPrm.owner];
1275 simShrdPrm.SIM_Selection = TRUE;
1276
1277 /*
1278 *-------------------------------------------------------------------
1279 * create and send primitive
1280 *-------------------------------------------------------------------
1281 */
1282 {
1283 PALLOC (sim_activate_req, SIM_ACTIVATE_REQ);
1284
1285 sim_activate_req->proc = SIM_SELECT;
1286 sim_activate_req->sim_num = pPrmSet->SIM_Selected;
1287
1288 PSENDX (SIM, sim_activate_req);
1289 }
1290 return 0;
1291 }
1292 #endif /*FF_DUAL_SIM*/
1293
1294
1295 /*==== EOF ========================================================*/
1296