comparison g23m/condat/ms/src/aci/cmh_satf.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_SATF
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 global functions of the command
18 | handler.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifdef SIM_TOOLKIT
23
24 #ifndef CMH_SATF_C
25 #define CMH_SATF_C
26 #endif
27
28 #define _PACK_DEF_ALPHA /* apply packing for GSM Default Alphabet */
29
30 #include "aci_all.h"
31 /*==== INCLUDES ===================================================*/
32 #ifdef DTI
33 #include "dti.h"
34 #endif /* DTI */
35
36 #include "pcm.h"
37
38 #include "aci.h"
39 #include "aci_cmh.h"
40 #include "ati_cmd.h"
41 #include "aci_mem.h"
42
43 #include "ati_src_sat.h"
44
45 #ifdef FAX_AND_DATA
46 #include "aci_fd.h"
47 #endif /* FAX_AND_DATA */
48
49 #include "phb.h"
50 #include "ksd.h"
51 #include "aoc.h"
52
53 #include "psa.h"
54 #include "psa_cc.h"
55 #include "psa_sat.h"
56 #include "psa_sim.h"
57 #include "psa_sms.h"
58 #include "psa_ss.h"
59 #include "psa_util.h"
60 #include "psa_mm.h"
61
62 #include "cmh.h"
63 #include "cmh_ss.h"
64 #include "cmh_cc.h"
65 #include "cmh_phb.h"
66
67 #ifdef DTI
68 #include "dti_conn_mng.h"
69 #include "dti_cntrl_mng.h"
70 #endif /* DTI */
71
72 #include "cmh_sim.h"
73 #include "cmh_sat.h"
74 #include "cmh_sms.h"
75
76 /* #include "cmh_sat.h" */
77
78 #if defined (GPRS) AND defined (DTI)
79 #include "gaci.h"
80 #include "gaci_cmh.h"
81 #include "gaci_srcc.h"
82 #include "psa_gmm.h"
83 #include "psa_sm.h"
84 #include "cmh_sm.h"
85 #endif
86
87
88 #if defined (FAX_AND_DATA) AND defined (DTI)
89 #include "psa_ra.h"
90 #include "cmh_ra.h"
91 #include "psa_l2r.h"
92 #include "cmh_l2r.h"
93 #endif /* FAX_AND_DATA */
94
95 #ifdef CO_UDP_IP
96 #include "wap_aci.h"
97 #include "psa_tcpip.h"
98 #endif /* CO_UDP_IP */
99 #include "rtcdrv.h"
100
101 /*==== CONSTANTS ==================================================*/
102 #define MAX_CBM_REMEMBERED 9
103
104 /*==== TYPES ======================================================*/
105 typedef struct
106 {
107 U16 msgIdent;
108 U16 msgCode;
109 U8 updtNum;
110 U8 pageNum;
111 } T_SAT_CBM_SEND;
112
113
114 /*==== EXPORT =====================================================*/
115 LOCAL void cmhSAT_CBMInitList();
116
117 /*==== VARIABLES ==================================================*/
118 T_SAT_CBM_SEND *CBMsend = NULL;
119
120 EXTERN T_ACI_CUSCFG_PARAMS cuscfgParams;
121
122
123 /*==== FUNCTIONS ==================================================*/
124
125 /*
126 +-------------------------------------------------------------------+
127 | PROJECT : GSM-PS (6147) MODULE : SAT |
128 | ROUTINE : cmhSAT_GetCmdPrfLocation |
129 +-------------------------------------------------------------------+
130
131 PURPOSE : This function will return TRUE if the Command has been found and
132 FALSE if the Command or the Qualifier is unknown.
133 The byte location and Mask for the given Stk Cmd are returned in the passed paramters,
134 a return value of TRUE with Byte Number of 0xFF and Mask of 0xFF indicates an
135 END_OF_SESSION, which isn't in the Profile
136 */
137
138 LOCAL BOOL cmhSAT_GetCmdPrfLocation (U8 cmd_typ, U8 cmd_qual, U8 *prf_byte_no, U8 *byte_mask)
139 {
140 /*
141 ** Initialise the byte and Mask settings to 0xFF
142 */
143 *prf_byte_no = 0xFF;
144 *byte_mask = 0xFF;
145
146 switch (cmd_typ)
147 {
148 case SAT_CMD_REFRESH:
149 *prf_byte_no = 2;
150 *byte_mask = SAT_TP3_REFRESH;
151 break;
152
153 case SAT_CMD_MORE_TIME:
154 *prf_byte_no = 2;
155 *byte_mask = SAT_TP3_MORE_TIME;
156 break;
157
158 case SAT_CMD_POLL_INTERVAL:
159 *prf_byte_no = 2;
160 *byte_mask = SAT_TP3_POLL_ITV;
161 break;
162
163 case SAT_CMD_POLL_OFF:
164 *prf_byte_no = 2;
165 *byte_mask = SAT_TP3_POLL_OFF;
166 break;
167
168 case SAT_CMD_EVENT_LIST:
169 *prf_byte_no = 4;
170 *byte_mask = SAT_TP5_EVENT_LIST;
171 break;
172
173 case SAT_CMD_SETUP_CALL:
174 *prf_byte_no = 3;
175 *byte_mask = SAT_TP4_SETUP_CALL;
176 break;
177
178 case SAT_CMD_SEND_SS:
179 *prf_byte_no = 3;
180 *byte_mask = SAT_TP4_SEND_SS;
181 break;
182
183 case SAT_CMD_SEND_USSD:
184 *prf_byte_no = 3;
185 *byte_mask = SAT_TP4_SEND_USSD;
186 break;
187
188 case SAT_CMD_SEND_SMS:
189 *prf_byte_no = 3;
190 *byte_mask = SAT_TP4_SEND_SMS;
191 break;
192
193 case SAT_CMD_SEND_DTMF:
194 *prf_byte_no = 8;
195 *byte_mask = SAT_TP9_DTMF_CMD;
196 break;
197
198 case SAT_CMD_LAUNCH_BROWSER:
199 *prf_byte_no = 8;
200 *byte_mask = SAT_TP9_LAUNCH_BROWSER;
201 break;
202
203 case SAT_CMD_PLAY_TONE:
204 *prf_byte_no = 2;
205 *byte_mask = SAT_TP3_PLAY_TONE;
206 break;
207
208 case SAT_CMD_DISPLAY_TEXT:
209 *prf_byte_no = 2;
210 *byte_mask = SAT_TP3_DSPL_TXT;
211 break;
212
213 case SAT_CMD_GET_INKEY:
214 *prf_byte_no = 2;
215 *byte_mask = SAT_TP3_GET_INKEY;
216 break;
217
218 case SAT_CMD_GET_INPUT:
219 *prf_byte_no = 2;
220 *byte_mask = SAT_TP3_GET_INPUT;
221 break;
222
223 case SAT_CMD_SEL_ITEM:
224 *prf_byte_no = 3;
225 *byte_mask = SAT_TP4_SEL_ITEM;
226 break;
227
228 case SAT_CMD_SETUP_MENU:
229 *prf_byte_no = 3;
230 *byte_mask = SAT_TP4_SETUP_MENU;
231 break;
232
233 case SAT_CMD_PROV_LOC_INFO:
234 /*
235 ** Depends on which type of Local Info is requested
236 */
237 switch (cmd_qual)
238 {
239 case 0:
240 case 1:
241 *prf_byte_no = 3;
242 *byte_mask = SAT_TP4_PLI_PLMN_IMEI;
243 break;
244
245 case 2:
246 *prf_byte_no = 3;
247 *byte_mask = SAT_TP4_PLI_NMR;
248 break;
249
250 case 3:
251 *prf_byte_no = 7;
252 *byte_mask = SAT_TP8_PLI_DTT;
253 break;
254
255 case 4:
256 *prf_byte_no = 8;
257 *byte_mask = SAT_TP9_PLI_LANG;
258 break;
259
260 case 5:
261 *prf_byte_no = 8;
262 *byte_mask = SAT_TP9_PLI_TIMING_ADV;
263 break;
264
265 default:
266 return (FALSE); /* Command Not recognised */
267 }
268 break;
269
270 case SAT_CMD_TIMER_MNG:
271 *prf_byte_no = 7;
272 *byte_mask = SAT_TP8_TMNG_ST | SAT_TP8_TMNG_VAL;
273 break;
274
275 case SAT_CMD_IDLE_TEXT:
276 *prf_byte_no = 7;
277 *byte_mask = SAT_TP8_IDLE_TXT;
278 break;
279
280 case SAT_CMD_RUN_AT:
281 *prf_byte_no = 7;
282 *byte_mask = SAT_TP8_AT_CMD;
283 break;
284
285 case SAT_CMD_OPEN_CHANNEL:
286 *prf_byte_no = 11;
287 *byte_mask = SAT_TP12_OPEN_CHANNEL;
288 break;
289
290 case SAT_CMD_CLOSE_CHANNEL:
291 *prf_byte_no = 11;
292 *byte_mask = SAT_TP12_CLOSE_CHANNEL;
293 break;
294
295 case SAT_CMD_RECEIVE_DATA:
296 *prf_byte_no = 11;
297 *byte_mask = SAT_TP12_RECEIVE_DATA;
298 break;
299
300 case SAT_CMD_SEND_DATA:
301 *prf_byte_no = 11;
302 *byte_mask = SAT_TP12_SEND_DATA;
303 break;
304
305 case SAT_CMD_GET_CHANNEL_STATUS:
306 *prf_byte_no = 11;
307 *byte_mask = SAT_TP12_GET_CHANNEL_STAT;
308 break;
309
310 case SAT_CMD_END_SESSION:
311 /*
312 ** Do nothing - The command should be handled by the MMI,
313 ** but there is no entry in the terminal profile
314 */
315 break;
316
317 default:
318 return (FALSE); /* Command Not recognised */
319 }
320
321 return (TRUE);
322 }
323
324 /*
325 +-------------------------------------------------------------------+
326 | PROJECT : GSM-PS (6147) MODULE : SAT |
327 | ROUTINE : cmhSAT_IsStkCmdForMmi |
328 +-------------------------------------------------------------------+
329
330 PURPOSE : This function will check whether the command should be set to the MMI
331 and if so will trigger a SATI indication
332
333 */
334
335 GLOBAL BOOL cmhSAT_IsStkCmdForMmi (U8 cmd_typ, U8 cmd_qual)
336 {
337 BOOL is_handled = FALSE;
338 U8 prf_byte_no;
339 U8 byte_mask;
340 int idx;
341
342 /*
343 ** End of Session is handled by the
344 */
345 if (cmd_typ EQ SAT_CMD_END_SESSION)
346 {
347 is_handled = TRUE;
348 }
349 else
350 {
351 /*
352 ** Convert the command type into a Stk Profile Byte Number and Offset
353 */
354 if (cmhSAT_GetCmdPrfLocation(cmd_typ, cmd_qual, &prf_byte_no, &byte_mask))
355 {
356 /*
357 ** For each Attached Service
358 */
359 for (idx = 0; idx < CMD_SRC_MAX AND (is_handled EQ FALSE); idx++)
360 {
361 /*
362 ** if the Command is handled
363 */
364 if (simShrdPrm.setPrm[idx].STKprof[prf_byte_no] & byte_mask)
365 {
366 /*
367 ** Set a handled flag to TRUE
368 */
369 is_handled = TRUE;
370 }
371 }
372 }
373 }
374
375 /*
376 ** if the Command is handled
377 */
378 if (is_handled)
379 {
380 /*
381 ** Send the SATI indication
382 */
383 cmhSAT_STKCmdInd();
384 }
385
386 /*
387 ** return the value of the handled flag
388 */
389 return (is_handled);
390 }
391
392 /*
393 +-------------------------------------------------------------------+
394 | PROJECT : GSM-PS (6147) MODULE : SAT |
395 | ROUTINE : cmhSAT_CalCntrlBySIM |
396 +-------------------------------------------------------------------+
397
398 PURPOSE : If call control by SIM is activated and allocated, the
399 parameters for the call found in the call table are
400 packed into a SIM envelope command and send to the SIM
401 for checking.
402
403 */
404
405 GLOBAL T_ACI_RETURN cmhSAT_CalCntrlBySIM ( SHORT cId )
406 {
407 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[cId];
408
409 TRACE_FUNCTION("cmhSAT_CalCntrlBySIM()");
410
411 /*
412 *-------------------------------------------------------------------
413 * check if Call Control is disabled (Cust1 Customisation)
414 *-------------------------------------------------------------------
415 */
416 if(simShrdPrm.setPrm[ctb->calOwn].sat_cc_mode EQ SATCC_CONTROL_BY_SIM_INACTIVE)
417 {
418 simShrdPrm.setPrm[ctb->calOwn].sat_cc_mode = SATCC_CONTROL_BY_SIM_ACTIVE;
419 return( AT_CMPL );
420 }
421
422 /*
423 *-------------------------------------------------------------------
424 * check if service is activated and allocated
425 *-------------------------------------------------------------------
426 */
427 if( ! psaSIM_ChkSIMSrvSup( SRV_CalCntrl )) return( AT_CMPL );
428
429 /*
430 *-------------------------------------------------------------------
431 * check if Call Control customization is enabled... if yes return AT_CMPL
432 *-------------------------------------------------------------------
433 */
434
435 if(cuscfgParams.MO_Call_Control_SIM EQ CUSCFG_STAT_Enabled)
436 {
437 return( AT_CMPL );
438 }
439
440 /*
441 *-------------------------------------------------------------------
442 * check if a call control request is in progress
443 *-------------------------------------------------------------------
444 */
445 if( satShrdPrm.SIMCCParm.busy EQ TRUE ) return( AT_BUSY );
446
447 /*
448 *-------------------------------------------------------------------
449 * get bearer capability parameter for data calls
450 *-------------------------------------------------------------------
451 */
452 /* capability configuration parameters */
453 if( ctb->BC[0].bearer_serv NEQ BEARER_SERV_NOT_PRES AND
454 ctb->BC[0].bearer_serv NEQ BEARER_SERV_SPEECH AND
455 ctb->BC[0].bearer_serv NEQ BEARER_SERV_AUX_SPEECH )
456 {
457 /* CCP not supported yet */
458 /* satShrdPrm.capParm.cId = cId; */
459 /* psaCC_BCapCode( BCRI_SAT, cId, 0 ); */
460 }
461
462 if( ctb->BC[1].bearer_serv NEQ BEARER_SERV_NOT_PRES AND
463 ctb->BC[1].bearer_serv NEQ BEARER_SERV_SPEECH AND
464 ctb->BC[1].bearer_serv NEQ BEARER_SERV_AUX_SPEECH )
465 {
466 /* CCP not supported yet */
467 /* satShrdPrm.capParm.cId = cId; */
468 /* psaCC_BCapCode( BCRI_SAT, cId, 1 ); */
469 }
470
471 /*
472 *-------------------------------------------------------------------
473 * build envelope call control command
474 *-------------------------------------------------------------------
475 */
476 CCD_START;
477 psaSAT_BuildEnvCC ( cId, NULL, NULL, NULL );
478
479 satShrdPrm.SIMCCParm.cId = cId;
480 satShrdPrm.SIMCCParm.ccAct = CC_ACT_CAL;
481 satShrdPrm.SIMCCParm.owner = ctb->calOwn;
482 satShrdPrm.SIMCCParm.busy = TRUE;
483
484 satShrdPrm.owner = /*ctb->calOwn;*/ NO_VLD_OWN;
485
486 if( psaSAT_STKEnvelope (NULL) < 0 ) /* envelope STK command */
487 {
488 TRACE_EVENT( "FATAL RETURN SAT in send env" );
489 CCD_END;
490 return( AT_FAIL );
491 }
492
493 CCD_END;
494 return (AT_EXCT);
495
496 }
497
498 /*
499 +-------------------------------------------------------------------+
500 | PROJECT : GSM-PS (6147) MODULE : SAT |
501 | ROUTINE : cmhSAT_SSCntrlBySIM |
502 +-------------------------------------------------------------------+
503
504 PURPOSE : If call control by SIM is activated and allocated, the
505 the passed supplementary service control string is
506 packed into a SIM envelope command and send to the SIM
507 for checking.
508
509 */
510
511 GLOBAL T_ACI_RETURN cmhSAT_SSCntrlBySIM ( T_CLPTY_PRM *cldPty, UBYTE own )
512 {
513 TRACE_FUNCTION("cmhSAT_SSCntrlBySIM()");
514
515 /*
516 *-------------------------------------------------------------------
517 * check if Call Control is disabled (Cust1 Customisation)
518 *-------------------------------------------------------------------
519 */
520 if(simShrdPrm.setPrm[own].sat_cc_mode EQ SATCC_CONTROL_BY_SIM_INACTIVE)
521 {
522 simShrdPrm.setPrm[own].sat_cc_mode = SATCC_CONTROL_BY_SIM_ACTIVE;
523 return( AT_CMPL );
524 }
525
526 /*
527 *-------------------------------------------------------------------
528 * check if service is activated and allocated
529 *-------------------------------------------------------------------
530 */
531 if( ! psaSIM_ChkSIMSrvSup( SRV_CalCntrl )) return( AT_CMPL );
532
533 /*
534 *-------------------------------------------------------------------
535 * check if Call Control customization is enabled... if yes return AT_CMPL
536 *-------------------------------------------------------------------
537 */
538
539 if(cuscfgParams.MO_SS_Control_SIM EQ CUSCFG_STAT_Enabled)
540 {
541 return( AT_CMPL );
542 }
543
544 /*
545 *-------------------------------------------------------------------
546 * check if a call control request is in progress
547 *-------------------------------------------------------------------
548 */
549 if( satShrdPrm.SIMCCParm.busy EQ TRUE ) return( AT_BUSY );
550
551 /*
552 *-------------------------------------------------------------------
553 * build envelope call control command
554 *-------------------------------------------------------------------
555 */
556 CCD_START;
557 psaSAT_BuildEnvCC ( NO_ENTRY, cldPty, NULL, NULL );
558
559 if( cldPty NEQ NULL )
560 satShrdPrm.SIMCCParm.ccAct = CC_ACT_SS;
561
562 satShrdPrm.SIMCCParm.owner = own;
563 satShrdPrm.SIMCCParm.busy = TRUE;
564
565 satShrdPrm.owner = NO_VLD_OWN;
566
567 if( psaSAT_STKEnvelope (NULL) < 0 ) /* envelope STK command */
568 {
569 TRACE_EVENT( "FATAL RETURN SAT in send env" );
570 CCD_END;
571 return( AT_FAIL );
572 }
573
574 CCD_END;
575
576 /*
577 *-------------------------------------------------------------------
578 * save SS string
579 *-------------------------------------------------------------------
580 */
581
582 if( cldPty NEQ NULL )
583 memcpy(&satPndSetup.clpty, cldPty, sizeof(T_CLPTY_PRM));
584
585 return (AT_EXCT);
586
587 }
588
589 /*
590 +-------------------------------------------------------------------+
591 | PROJECT : GSM-PS (6147) MODULE : SAT |
592 | ROUTINE : cmhSAT_USSDCntrlBySIM |
593 +-------------------------------------------------------------------+
594
595 PURPOSE : If call control by SIM is activated and allocated, the
596 the passed supplementary service control string is
597 packed into a SIM envelope command and send to the SIM
598 for checking.
599
600 */
601
602 GLOBAL T_ACI_RETURN cmhSAT_USSDCntrlBySIM ( T_sat_ussd *ussd, UBYTE own )
603 {
604 TRACE_FUNCTION("cmhSAT_USSDCntrlBySIM()");
605
606 /*
607 *-------------------------------------------------------------------
608 * check if Call Control is disabled (Cust1 Customisation)
609 *-------------------------------------------------------------------
610 */
611 if(simShrdPrm.setPrm[own].sat_cc_mode EQ SATCC_CONTROL_BY_SIM_INACTIVE)
612 {
613 simShrdPrm.setPrm[own].sat_cc_mode = SATCC_CONTROL_BY_SIM_ACTIVE;
614 return( AT_CMPL );
615 }
616
617 /*
618 *-------------------------------------------------------------------
619 * check if service is activated and allocated
620 *-------------------------------------------------------------------
621 */
622 if( ! psaSIM_ChkSIMSrvSup( SRV_CalCntrl )) return( AT_CMPL );
623
624 /*
625 *-------------------------------------------------------------------
626 * check if Call Control customization is enabled... if yes return AT_CMPL
627 *-------------------------------------------------------------------
628 */
629
630 if(cuscfgParams.MO_USSD_Control_SIM EQ CUSCFG_STAT_Enabled)
631 {
632 return( AT_CMPL );
633 }
634
635 /*
636 *-------------------------------------------------------------------
637 * check if a call control request is in progress
638 *-------------------------------------------------------------------
639 */
640 if( satShrdPrm.SIMCCParm.busy EQ TRUE ) return( AT_BUSY );
641
642 /*
643 *-------------------------------------------------------------------
644 * save SS string
645 *-------------------------------------------------------------------
646 */
647 if( ussd )
648 {
649 satPndSetup.ussd_str.dcs = ussd->dcs;
650 satPndSetup.ussd_str.c_ussd_str = ussd->c_ussd_str;
651 memcpy( satPndSetup.ussd_str.ussd_str, ussd->ussd_str, satPndSetup.ussd_str.c_ussd_str);
652 /* we have to move the ussd_str pointer since it still points to _decodedMsg
653 and would be overwritten by the first memset in psaSAT_BuildEnvCC */
654 ussd->ussd_str = satPndSetup.ussd_str.ussd_str;
655 }
656
657 /*
658 *-------------------------------------------------------------------
659 * build envelope call control command
660 *-------------------------------------------------------------------
661 */
662 CCD_START;
663 psaSAT_BuildEnvCC ( NO_ENTRY, NULL, ussd, NULL );
664
665 if( ussd )
666 satShrdPrm.SIMCCParm.ccAct = CC_ACT_USSD;
667
668 satShrdPrm.SIMCCParm.owner = own;
669 satShrdPrm.SIMCCParm.busy = TRUE;
670
671 satShrdPrm.owner = NO_VLD_OWN;
672
673 if( psaSAT_STKEnvelope (NULL) < 0 ) /* envelope STK command */
674 {
675 TRACE_EVENT( "FATAL RETURN SAT in send env" );
676 CCD_END;
677 return( AT_FAIL );
678 }
679
680 CCD_END;
681
682
683 return (AT_EXCT);
684
685 }
686
687
688 /*
689 +-------------------------------------------------------------------+
690 | PROJECT : GSM-PS (6147) MODULE : SAT |
691 | ROUTINE : cmhSAT_CBMInitList |
692 +-------------------------------------------------------------------+
693
694 PURPOSE : Allocates and initializes CBM list.
695 */
696
697 LOCAL void cmhSAT_CBMInitList()
698 {
699 TRACE_FUNCTION("cmhSAT_CBMInitList()");
700
701 if ( CBMsend EQ NULL )
702 {
703 ACI_MALLOC(CBMsend, sizeof(T_SAT_CBM_SEND) * MAX_CBM_REMEMBERED);
704 }
705 memset( CBMsend, NOT_PRESENT_8BIT,
706 sizeof(T_SAT_CBM_SEND) * MAX_CBM_REMEMBERED );
707 }
708
709
710 /*
711 +-------------------------------------------------------------------+
712 | PROJECT : GSM-PS (6147) MODULE : SAT |
713 | ROUTINE : cmhSAT_CBMDestroyList |
714 +-------------------------------------------------------------------+
715
716 PURPOSE : Frees memory of CBM list and sets list pointer to NULL.
717 */
718
719 GLOBAL void cmhSAT_CBMDestroyList()
720 {
721 TRACE_FUNCTION("cmhSAT_CBMDestroyList()");
722
723 if ( CBMsend NEQ NULL )
724 {
725 ACI_MFREE( CBMsend );
726 CBMsend = NULL;
727 }
728 }
729
730
731 /*
732 +-------------------------------------------------------------------+
733 | PROJECT : GSM-PS (6147) MODULE : SAT |
734 | ROUTINE : cmhSAT_CBMAddToList |
735 +-------------------------------------------------------------------+
736
737 PURPOSE : Adds new CBM Identifiers to end of CBM list
738 */
739
740 LOCAL void cmhSAT_CBMAddToList( UBYTE pos,
741 U16 msgIdent,
742 U16 msgCode,
743 UBYTE updtNum,
744 UBYTE pageNum )
745 {
746 TRACE_FUNCTION("cmhSAT_CBMAddToList()");
747
748 if ( pos >= MAX_CBM_REMEMBERED )
749 {
750 /* remove oldest:
751 move all entries one entry to the beginning of the list */
752 memcpy( CBMsend, CBMsend + 1,
753 (MAX_CBM_REMEMBERED - 1) * sizeof(T_SAT_CBM_SEND));
754 pos = MAX_CBM_REMEMBERED - 1;
755 }
756
757 CBMsend[pos].msgIdent = msgIdent;
758 CBMsend[pos].msgCode = msgCode;
759 CBMsend[pos].updtNum = updtNum;
760 CBMsend[pos].pageNum = pageNum;
761 }
762
763
764 /*
765 +-------------------------------------------------------------------+
766 | PROJECT : GSM-PS (6147) MODULE : SAT |
767 | ROUTINE : cmhSAT_CBMUpdateList |
768 +-------------------------------------------------------------------+
769
770 PURPOSE : Moves last updated CBM to end of the CBM list
771 */
772
773 LOCAL void cmhSAT_CBMUpdateList( UBYTE pos )
774 {
775 T_SAT_CBM_SEND curCBM;
776
777 TRACE_FUNCTION("cmhSAT_CBMUpdateList()");
778
779 /* save data of current CBM */
780 memcpy( &curCBM, CBMsend + pos, sizeof(T_SAT_CBM_SEND) );
781
782 /* move all entries, starting after the current entry, one entry to
783 the beginning of the list */
784 memcpy( CBMsend + pos, CBMsend + pos+1,
785 ( MAX_CBM_REMEMBERED - (pos+1)) * sizeof(T_SAT_CBM_SEND) );
786
787 /* copy current CBM at last used position */
788 while ( (pos < MAX_CBM_REMEMBERED-1) AND
789 (CBMsend[pos].msgIdent NEQ NOT_PRESENT_16BIT) )
790 {
791 pos++;
792 }
793 memcpy( CBMsend + pos, &curCBM, sizeof(T_SAT_CBM_SEND) );
794
795 }
796
797
798 /*
799 +-------------------------------------------------------------------+
800 | PROJECT : GSM-PS (6147) MODULE : SAT |
801 | ROUTINE : cmhSAT_CBMExtractData |
802 +-------------------------------------------------------------------+
803
804 PURPOSE : Extracts MessageCode, Messag Identifier, Update number,
805 Page number and total numbers of pages from the CBM.
806 */
807
808 LOCAL void cmhSAT_CBMExtractData( UBYTE* cbMsg,
809 U16* msgIdent,
810 U16* msgCode,
811 UBYTE* updtNum,
812 UBYTE* pageNum,
813 UBYTE* pageTotal )
814 {
815 UBYTE cnvrt[2];
816
817 TRACE_FUNCTION("cmhSAT_CBMExtractData()");
818
819 /* extract message identifiers:
820 cbMsg is not yet enveloped for SAT, so that Bytes 3 - 4 includes
821 the message identifiers.
822 */
823 memcpy(cnvrt+1, &cbMsg[2], 1);
824 memcpy(cnvrt, &cbMsg[3], 1);
825 memcpy(msgIdent, cnvrt, 2);
826
827 /* decode serial number:
828 cbMsg is not yet enveloped for SAT, so that cbMsg starts
829 with the serial number.
830 update number:
831 The serial number includes the message code in bits 0 - 5 of the
832 first Byte and in bits 4 -7 in the second Byte.
833 */
834 memcpy(cnvrt+1, &cbMsg[0], 1);
835 memcpy(cnvrt, &cbMsg[1], 1);
836 memcpy(msgCode, cnvrt, 2);
837 *msgCode = ( *msgCode >> 4 ) & 1023;
838
839 /*
840 update number:
841 The second Byte of the serial number includes the
842 update number in bits 0 - 3.
843 the bitwise AND operation with 15 will set bits 4 - 7 to zero.
844 */
845 *updtNum = cbMsg[1] & 15;
846
847 /* extract page parameter:
848 cbMsg is not yet enveloped for SAT, so that the sixth Byte is
849 the page parameter.
850 It includes the total number of pages in bits 0 - 3.
851 The bitwise AND operation with 15 will set bits 4 - 7 to zero.
852 The current page number is in bits 4 - 7.
853 To get the current page number the bits have to be shifted
854 4 positions to the right.
855 */
856 *pageTotal = cbMsg[5] & 15;
857 *pageNum = cbMsg[5] >> 4;
858 }
859
860
861 /*
862 +-------------------------------------------------------------------+
863 | PROJECT : GSM-PS (6147) MODULE : SAT |
864 | ROUTINE : cmhSAT_CBMIsNewMsg |
865 +-------------------------------------------------------------------+
866
867 PURPOSE : Checks if CBM is a new CBM or if it already has been
868 send to SIM. The Identifiers of already received CBMs
869 are stored in a list.
870 RETURNS: TRUE, if it is new and shall be send to SIM now.
871 FALSE, if it already has been send to SIM.
872 */
873
874 LOCAL BOOL cmhSAT_CBMIsNewMsg( UBYTE* cbMsg )
875 {
876
877 U16 msgIdent;
878 U16 msgCode;
879 U8 updtNum;
880 U8 pageTotal;
881 U8 pageNum;
882 UBYTE i;
883
884
885 TRACE_FUNCTION("cmhSAT_CBMIsNewMsg()");
886
887 if ( CBMsend EQ NULL )
888 {
889 cmhSAT_CBMInitList();
890 }
891
892 /*----------------------------------------------------------------
893 * extract CBM identifiers
894 *----------------------------------------------------------------*/
895
896 cmhSAT_CBMExtractData( cbMsg, &msgIdent, &msgCode, &updtNum,
897 &pageNum, &pageTotal );
898
899 /*----------------------------------------------------------------
900 * check if message has already been send to SIM
901 *----------------------------------------------------------------*/
902
903 /* search for message identifiers in CB Messages already send to SIM */
904 for ( i = 0;
905 (i < MAX_CBM_REMEMBERED) AND (CBMsend[i].msgCode NEQ NOT_PRESENT_16BIT);
906 i++ )
907 {
908 if ( (msgIdent EQ CBMsend[i].msgIdent) AND
909 (msgCode EQ CBMsend[i].msgCode) )
910 {
911
912 /* if update number has changed, CBM shall be send to SIM */
913 /* 23.041 9.4.1.2.1:
914 Any Update Number eight or less higher (modulo 16)
915 than the last received Update Number will be considered more recent,
916 and shall be treated as a new CBS message,
917 provided the mobile has not been switched off. */
918
919 U8 delta;
920
921 delta = (updtNum - CBMsend[i].updtNum) % 16; /* force explicit negative carry! */
922 if (delta > 0 AND delta <= 8)
923 {
924 /* for the next check: set update number to new update number
925 and reset page number for new update */
926 CBMsend[i].updtNum = updtNum;
927 CBMsend[i].pageNum = 0;
928 cmhSAT_CBMUpdateList( i );
929
930 return TRUE;
931 }
932
933
934 /* check if message contains more than one page */
935 if ( pageTotal > 1 )
936 {
937 /* check if page is send to SIM */
938 if ( pageNum > CBMsend[i].pageNum )
939 {
940 /* mark page now as send for next CBM */
941 CBMsend[i].pageNum = pageNum;
942 cmhSAT_CBMUpdateList( i );
943
944 /* page is not yet send to SIM */
945 return TRUE;
946 }
947 }
948
949 /* CBM is not new */
950 return FALSE;
951 }
952 }
953
954 /*----------------------------------------------------------------
955 * mark CBM as send to SIM: insert into list
956 *---------------------------------------------------------------*/
957
958 cmhSAT_CBMAddToList( i, msgIdent, msgCode, updtNum, pageNum );
959
960 return TRUE;
961 }
962
963 /*
964 +-------------------------------------------------------------------+
965 | PROJECT : GSM-PS (6147) MODULE : SAT |
966 | ROUTINE : cmhSAT_verifyNewLocInfo |
967 +-------------------------------------------------------------------+
968
969 PURPOSE : This function verifies the current MM PLMN information
970 with the one already stored by SAT and indicates TRUE if
971 the information has changed
972
973 */
974 LOCAL BOOL cmhSAT_verifyNewLocInfo ()
975 {
976 if (satShrdPrm.locInfo.regStatus EQ mmShrdPrm.regStat)
977 {
978 /* If registration status is full service, check to proceed
979 if the location information has changed*/
980 if (satShrdPrm.locInfo.regStatus EQ RS_FULL_SRV)
981 {
982 if( memcmp (mmShrdPrm.usedPLMN.mcc, satShrdPrm.locInfo.currPLMN.mcc, SIZE_MCC) EQ 0
983 AND memcmp (mmShrdPrm.usedPLMN.mnc, satShrdPrm.locInfo.currPLMN.mnc, SIZE_MNC) EQ 0
984 AND mmShrdPrm.lac EQ satShrdPrm.locInfo.lac AND mmShrdPrm.cid EQ satShrdPrm.locInfo.cid)
985 {
986 return FALSE;
987 }
988 }
989 }
990
991 satShrdPrm.locInfo.regStatus = mmShrdPrm.regStat;
992
993 /* The other information is updated only if ME is in full service mode */
994 if (satShrdPrm.locInfo.regStatus EQ RS_FULL_SRV)
995 {
996 satShrdPrm.locInfo.cid = mmShrdPrm.cid;
997 satShrdPrm.locInfo.lac = mmShrdPrm.lac;
998 satShrdPrm.locInfo.currPLMN.v_plmn = mmShrdPrm.usedPLMN.v_plmn;
999 memcpy(satShrdPrm.locInfo.currPLMN.mcc, mmShrdPrm.usedPLMN.mcc, SIZE_MCC);
1000 memcpy(satShrdPrm.locInfo.currPLMN.mnc, mmShrdPrm.usedPLMN.mnc, SIZE_MNC);
1001 }
1002
1003 return TRUE;
1004 }
1005
1006
1007 /*
1008 +-------------------------------------------------------------------+
1009 | PROJECT : GSM-PS (6147) MODULE : SAT |
1010 | ROUTINE : cmhSAT_DatDwnLdCB |
1011 +-------------------------------------------------------------------+
1012
1013 PURPOSE : This function supports the data download to SIM via cell
1014 broadcast messages.
1015
1016 */
1017
1018 GLOBAL T_ACI_RETURN cmhSAT_DatDwnLdCB ( UBYTE* cbMsg, SHORT cbLen )
1019 {
1020
1021 TRACE_FUNCTION("cmhSAT_DatDwnLdCB()");
1022
1023 /*
1024 *-------------------------------------------------------------------
1025 * build envelope
1026 *-------------------------------------------------------------------
1027 */
1028 CCD_START;
1029 psaSAT_BuildEnvCB ( cbMsg, cbLen );
1030
1031 satShrdPrm.owner = NO_VLD_OWN;
1032
1033 /* only if CBM is not yet send to SIM, CBM shall be send to SIM */
1034 if ( cmhSAT_CBMIsNewMsg( cbMsg ) )
1035 {
1036 if( psaSAT_STKEnvelope (NULL) < 0 ) /* envelope STK command */
1037 {
1038 TRACE_EVENT( "FATAL RETURN SAT in send env" );
1039 CCD_END;
1040 return( AT_FAIL );
1041 }
1042 }
1043
1044 CCD_END;
1045
1046 return( AT_CMPL );
1047
1048 }
1049
1050 /*
1051 +-------------------------------------------------------------------+
1052 | PROJECT : GSM-PS (6147) MODULE : SAT |
1053 | ROUTINE : cmhSAT_MoSmCntr |
1054 +-------------------------------------------------------------------+
1055
1056 PURPOSE : This function supports the MO SM control.
1057
1058 */
1059
1060 GLOBAL T_ACI_RETURN cmhSAT_MoSmCntr ( T_rp_addr sc_addr,
1061 T_tp_da dest_addr,
1062 UBYTE own)
1063 {
1064
1065 TRACE_FUNCTION("cmhSAT_MoSmCntr()");
1066
1067 /*
1068 *-------------------------------------------------------------------
1069 * check if Call Control customization is enabled... if yes return AT_CMPL
1070 *-------------------------------------------------------------------
1071 */
1072
1073 if(cuscfgParams.MO_SM_Control_SIM EQ CUSCFG_STAT_Enabled)
1074 {
1075 return( AT_CMPL );
1076 }
1077
1078
1079 /*
1080 *-------------------------------------------------------------------
1081 * check if a call control request is in progress
1082 *-------------------------------------------------------------------
1083 */
1084 if( satShrdPrm.SIMCCParm.busy EQ TRUE ) return( AT_BUSY );
1085
1086
1087 /*
1088 *-------------------------------------------------------------------
1089 * build envelope
1090 *-------------------------------------------------------------------
1091 */
1092 CCD_START;
1093 psaSAT_BuildEnvMoSmCntr ( sc_addr, dest_addr );
1094
1095 satShrdPrm.SIMCCParm.ccAct = SMC_ACT_MO;
1096 satShrdPrm.SIMCCParm.owner = own;
1097 satShrdPrm.SIMCCParm.busy = TRUE;
1098
1099 satShrdPrm.owner = NO_VLD_OWN;
1100
1101 if( psaSAT_STKEnvelope (NULL) < 0 ) /* envelope STK command */
1102 {
1103 TRACE_EVENT( "FATAL RETURN SAT in send env" );
1104 CCD_END;
1105 return( AT_FAIL );
1106 }
1107
1108 CCD_END;
1109 return( AT_EXCT );
1110
1111 }
1112
1113 /*
1114 +-------------------------------------------------------------------+
1115 | PROJECT : GSM-PS (6147) MODULE : SAT |
1116 | ROUTINE : cmhSAT_EventDwn |
1117 +-------------------------------------------------------------------+
1118
1119 PURPOSE : This function supports Event download.
1120
1121 */
1122
1123 GLOBAL T_ACI_RETURN cmhSAT_EventDwn ( UBYTE event, SHORT callId , T_CC_INITIATER actionSrc )
1124 {
1125
1126 TRACE_FUNCTION("cmhSAT_EventDwn()");
1127
1128 /* If the event is Location info download, event download is sent only
1129 if the location information has changed or has been updated */
1130 if (event EQ EVENT_LOC_STATUS AND !cmhSAT_verifyNewLocInfo ())
1131 {
1132 TRACE_EVENT("No update for SIM app");
1133 return AT_CMPL;
1134 }
1135
1136
1137 /*
1138 *-------------------------------------------------------------------
1139 * build envelope
1140 *-------------------------------------------------------------------
1141 */
1142 CCD_START;
1143
1144 /* if events were queued, send them */
1145 if (satShrdPrm.event.c_queued)
1146 {
1147 do
1148 {
1149 T_SAT_QUEUE *p_queue;
1150
1151 satShrdPrm.event.c_queued--;
1152 p_queue = &satShrdPrm.event.queued[satShrdPrm.event.c_queued];
1153
1154 satShrdPrm.owner = p_queue->owner;
1155 if (psaSAT_STKEnvelope(p_queue->stk_cmd) < 0) /* envelope STK command */
1156 {
1157 /* ignore event if error */
1158 TRACE_EVENT( "FATAL RETURN SAT in send env" );
1159 }
1160 p_queue->stk_cmd = NULL;
1161 }
1162 while (satShrdPrm.event.c_queued);
1163 }
1164 else
1165 {
1166 if (!psaSAT_BuildEnvEventDwn ( event , callId, actionSrc ))
1167 {
1168 CCD_END;
1169 return AT_BUSY;
1170 }
1171
1172 /*satShrdPrm.SIMCCParm.busy = TRUE;*/
1173
1174 satShrdPrm.owner = NO_VLD_OWN;
1175
1176 if( psaSAT_STKEnvelope (NULL) < 0 ) /* envelope STK command */
1177 {
1178 TRACE_EVENT( "FATAL RETURN SAT in send env" );
1179 CCD_END;
1180 return( AT_FAIL );
1181 }
1182 }
1183
1184 CCD_END;
1185 return( AT_CMPL );
1186
1187 }
1188
1189 /*
1190 +-------------------------------------------------------------------+
1191 | PROJECT : MODULE : SAT |
1192 | ROUTINE : cmhSAT_LaunchBrowser |
1193 +-------------------------------------------------------------------+
1194
1195 PURPOSE :
1196
1197 */
1198 GLOBAL BOOL cmhSAT_launchBrowser (T_LAUNCH_BROWSER* launchBrowser)
1199 {
1200 T_ACI_SAT_TERM_RESP resp_data;
1201
1202 /* check for busy SS condition */
1203 if (psaSS_stbFindActSrv (NO_ENTRY) NEQ NO_ENTRY)
1204 {
1205 /* respond with "error, ME currently unable to process command" */
1206 resp_data.add_content = ADD_ME_SS_BUSY;
1207 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
1208 return( FALSE ); /* unused */
1209 }
1210
1211 #if defined(MFW) AND defined(FF_WAP)
1212 rAT_PercentSATBROW (launchBrowser); /* Info 718: Symbol undeclared, assumed to return int */
1213 return( TRUE ); /* unused */
1214 #else
1215 cmhSAT_STKCmdInd();
1216 return( FALSE ); /* unused */
1217 #endif
1218
1219 }
1220
1221
1222 /*
1223 +-------------------------------------------------------------------+
1224 | PROJECT : GSM-PS (6147) MODULE : SAT |
1225 | ROUTINE : cmhSAT_provLocalInfo |
1226 +-------------------------------------------------------------------+
1227
1228 PURPOSE : This function supports Provide Local Information for
1229 Date, time and time zone.
1230
1231 */
1232 GLOBAL BOOL cmhSAT_provLocalInfo ()
1233 {
1234 T_ACI_SAT_TERM_RESP resp_data;
1235 rtc_time_type rtc_time;
1236
1237 CHAR* ef = EF_CLNG_ID;
1238 pcm_FileInfo_Type fileInfo;
1239 EF_CLNG lng;
1240
1241 char *auptr="au";
1242
1243 TRACE_FUNCTION("cmhSAT_provLocalInfo()");
1244
1245 psaSAT_InitTrmResp( &resp_data );
1246
1247 #ifndef _SIMULATION_
1248 /* if no service is currently available */
1249 if ((mmShrdPrm.regStat EQ RS_NO_SRV) OR (mmShrdPrm.regStat EQ NO_VLD_RS))
1250 {
1251 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
1252 return(FALSE);
1253 }
1254 #endif
1255
1256 if (satShrdPrm.cmdDet.cmdQlf NEQ QLF_PLOI_DTT AND (satShrdPrm.cmdDet.cmdQlf NEQ QLF_PLOI_LANG_SET))
1257 {
1258 return (FALSE);
1259 }
1260
1261 if (satShrdPrm.cmdDet.cmdQlf EQ QLF_PLOI_DTT)
1262 {
1263 if ( rtc_read_time ( &rtc_time ) EQ TRUE )
1264 {
1265 int i = 0;
1266 UBYTE hex2bcd;
1267
1268 resp_data.dtt_buf[0] = rtc_time.year;
1269 resp_data.dtt_buf[1] = rtc_time.month;
1270 resp_data.dtt_buf[2] = rtc_time.day;
1271 resp_data.dtt_buf[3] = rtc_time.hour;
1272 resp_data.dtt_buf[4] = rtc_time.minute;
1273 resp_data.dtt_buf[5] = rtc_time.second;
1274 while(i<TIME_STAMP_LENGTH)
1275 {
1276 hex2bcd = 0;
1277 hex2bcd = hex2bcd + resp_data.dtt_buf[i] / 0x0A;
1278 hex2bcd = hex2bcd << 4;
1279 hex2bcd = hex2bcd + resp_data.dtt_buf[i] % 0x0A;
1280 resp_data.dtt_buf[i] = ((hex2bcd & 0x0F) << 4) + ((hex2bcd & 0xF0) >> 4);
1281 i++;
1282 }
1283 #ifdef _SIMULATION_
1284 memset(resp_data.dtt_buf, 0xA0, 6);
1285 #endif /* _SIMULATION_ */
1286
1287 resp_data.dtt_buf[6] = mmShrdPrm.tz;
1288
1289 if (mmShrdPrm.regStat EQ RS_LMTD_SRV)
1290 {
1291 psaSAT_SendTrmResp( RSLT_PERF_LIM_SRV, &resp_data );
1292 }
1293 else
1294 {
1295 psaSAT_SendTrmResp( RSLT_PERF_SUCCESS, &resp_data );
1296 }
1297 }
1298 else
1299 {
1300 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
1301 return (FALSE);
1302 }
1303 }
1304 else /* Expecting LS Qualifier */
1305 {
1306 if (pcm_GetFileInfo ( ( UBYTE* ) ef, &fileInfo) NEQ PCM_OK)
1307 {
1308 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
1309 return (FALSE);
1310 }
1311 else
1312 {
1313 if (pcm_ReadFile( (UBYTE*)ef,
1314 fileInfo.FileSize,
1315 (UBYTE*) &lng,
1316 &fileInfo.Version) EQ PCM_OK )
1317 {
1318
1319 /*-------------------------------------------------------------------
1320 * Read EF ELP or LP from the sim if Automatic language is selected
1321 *-------------------------------------------------------------------
1322 */
1323
1324 if (!memcmp(lng.data, auptr, CLAN_CODE_LEN))
1325 {
1326 if (cmhSIM_ReqLanguagePrf() EQ FALSE)
1327 {
1328 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
1329 return (FALSE);
1330 }
1331 }
1332 else
1333 {
1334 memcpy(&resp_data.lang, &lng.data[0], CLAN_CODE_LEN);
1335
1336 #ifdef _SIMULATION_
1337 memset(resp_data.lang, 0xA0, 2);
1338 #endif
1339 psaSAT_SendTrmResp( RSLT_PERF_SUCCESS, &resp_data );
1340 }
1341
1342 }
1343 else
1344 {
1345 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
1346 return (FALSE);
1347 }
1348 }
1349 }
1350 return(TRUE);
1351 }
1352
1353
1354 /*
1355 +-------------------------------------------------------------------+
1356 | PROJECT : GSM-PS (6147) MODULE : SAT |
1357 | ROUTINE : cmhSAT_setupCall |
1358 +-------------------------------------------------------------------+
1359
1360 PURPOSE :
1361
1362 */
1363
1364 GLOBAL BOOL cmhSAT_setupCall ( T_SETUP_CALL * cal )
1365 {
1366 T_CC_CALL_TBL *ctb; /* pointer to call table associated with cId */
1367 T_ACI_RETURN retVal; /* holds return value */
1368 SHORT cId; /* holds call id */
1369 UBYTE idx; /* holds index */
1370 T_ACI_SAT_TERM_RESP resp_data;
1371 #ifdef FF_SAT_E
1372 T_ACI_SATA_ADD addPrm;
1373 #endif /* FF_SAT_E */
1374
1375 psaSAT_InitTrmResp( &resp_data );
1376
1377 TRACE_FUNCTION("cmhSAT_setupCall()");
1378
1379 /*
1380 *-------------------------------------------------------------------
1381 * get call table entry
1382 *-------------------------------------------------------------------
1383 */
1384 cId = psaCC_ctbNewEntry();
1385
1386 if( cId EQ NO_ENTRY )
1387 {
1388 /* send SAT response */
1389 resp_data.add_content = ADD_NO_CAUSE;
1390 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
1391 return( FALSE ); /* primitive not needed anymore */
1392 }
1393
1394 ctb = ccShrdPrm.ctb[cId];
1395
1396 /*
1397 *-------------------------------------------------------------------
1398 * build setup parameters
1399 *-------------------------------------------------------------------
1400 */
1401 /* check dial number */
1402 if( !cal->v_addr )
1403 {
1404 /* respond with "error, required values are missing" */
1405 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
1406 psaCC_FreeCtbNtry (cId);
1407 return( FALSE );
1408 }
1409
1410 cmhSAT_fillSetupPrm ( cId, /* cId is valid */
1411 ((cal->v_addr)?&cal->addr:NULL),
1412 ((cal->v_subaddr)?&cal->subaddr:NULL));
1413
1414 /* check aoc condition */
1415 if ((ctb->prio EQ PRIO_NORM_CALL) AND
1416 (aoc_check_moc() EQ FALSE))
1417 /*
1418 * check ACM exceeds ACMmax
1419 * for non-emergency calls
1420 */
1421 {
1422 resp_data.add_content = ADD_NO_CAUSE;
1423 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
1424 psaCC_FreeCtbNtry (cId);
1425 return( FALSE );
1426 }
1427
1428 /* declare the owner and status of the call */
1429 ctb->calOwn = OWN_SAT;
1430 ctb->calStat = CS_SAT_REQ;
1431 ctb->curCmd = AT_CMD_D;
1432 ctb->SATinv = TRUE;
1433
1434 /* bearer capabilities */
1435 if ( cal->v_cap_cnf_parms EQ 0 )
1436 {
1437 /*
1438 * no bearer capabilities => set to speech
1439 * this function was called for a SIM_TOOLKIT_IND
1440 */
1441 cmhSAT_fillSetupBC ( cId, BEARER_SERV_SPEECH, BEARER_SERV_NOT_PRES );
1442 }
1443 else
1444 {
1445 /* future to consider the bearer capabilities */
1446 cmhSAT_fillSetupBC ( cId, BEARER_SERV_SPEECH, BEARER_SERV_NOT_PRES );
1447
1448 /* CCP not supported yet */
1449 /*
1450 cmhSAT_ChckRedial(cId, cal->v_dur, &cal->dur);
1451
1452 satShrdPrm.ntfy = USR_NTF_SETUP_CAL;
1453 satShrdPrm.capParm.cId = cId;
1454 satShrdPrm.capParm.cntxt = CTX_SAT_SETUP;
1455
1456 if( psaCC_BCapDecode( BCRI_SAT, cal->cap_cnf_parms.l_cap_cnf_parms>>3,
1457 cal->cap_cnf_parms.b_cap_cnf_parms ) < 0 )
1458 {
1459 psaSAT_SendTrmResp( RSLT_ME_CAP, 0, NULL, NULL, NULL );
1460 psaCC_FreeCtbNtry (cId);
1461 return( FALSE );
1462 }
1463 else
1464 {
1465 return( TRUE );
1466 }
1467 */
1468 }
1469
1470 /*
1471 *-------------------------------------------------------------------
1472 * check for emergency call
1473 *-------------------------------------------------------------------
1474 */
1475 if( ctb->prio EQ PRIO_EMERG_CALL )
1476 {
1477 if (simShrdPrm.overall_cust_mode EQ (UBYTE)CUST_MODE_BEHAVIOUR_1)
1478 {
1479 /*
1480 * Clear the call table entry as it will be re-created when the MMI
1481 * requests the emergency call setup
1482 */
1483 psaCC_FreeCtbNtry (cId);
1484
1485 /*
1486 ** Send the original Setup Call Request to the MMI in a %SATI indication
1487 */
1488 cmhSAT_Cust1StkCmdInd();
1489 }
1490 else
1491 {
1492 /* alert user */
1493 for( idx = 0; idx < CMD_SRC_MAX; idx++ )
1494 {
1495
1496 #ifdef FF_SAT_E
1497 addPrm.chnType = SATA_CT_VOICE;
1498 addPrm.chnEst = SATA_EST_IM;
1499
1500 R_AT( RAT_SATA, idx )( cId+1,
1501 cmhSAT_ChckRedial(cId, cal->v_dur, &cal->dur),
1502 &addPrm);
1503 #else /* FF_SAT_E */
1504 R_AT( RAT_SATA, idx )( cId+1,
1505 cmhSAT_ChckRedial(cId, cal->v_dur, &cal->dur));
1506 #endif /* FF_SAT_E */
1507 }
1508 }
1509
1510 satShrdPrm.ntfy = USR_NTF_SETUP_CAL;
1511 return( TRUE );
1512 }
1513
1514 /*
1515 *-------------------------------------------------------------------
1516 * check for call control by SIM
1517 *-------------------------------------------------------------------
1518 */
1519
1520 retVal = cmhSAT_CalCntrlBySIM( cId );
1521
1522
1523 switch( retVal )
1524 {
1525 case( AT_EXCT ):
1526 satShrdPrm.ntfy = USR_NTF_SETUP_CAL;
1527 return( TRUE );
1528
1529 case( AT_BUSY ):
1530 /* respond with "Interaction with call control by SIM, temporary" */
1531 psaSAT_SendTrmResp( RSLT_CC_SIM_TMP, &resp_data );
1532 psaCC_FreeCtbNtry (cId);
1533 return( FALSE );
1534
1535 case( AT_FAIL ):
1536 /* respond with "Interaction with call control by SIM, permanent" */
1537 resp_data.add_content = ADD_NO_CAUSE;
1538 psaSAT_SendTrmResp( RSLT_CC_SIM_PRM, &resp_data );
1539 psaCC_FreeCtbNtry (cId);
1540 return( FALSE );
1541
1542 case( AT_CMPL):
1543 TRACE_EVENT_P1("Restoring the Cid = %d",cId);
1544 satShrdPrm.SIMCCParm.cId = cId;
1545 break;
1546 }
1547
1548 /*
1549 *-------------------------------------------------------------------
1550 * alert user if command details are supported
1551 *-------------------------------------------------------------------
1552 */
1553 if (simShrdPrm.overall_cust_mode EQ (UBYTE)CUST_MODE_BEHAVIOUR_1)
1554 {
1555 /*
1556 * Clear the call table entry as it will be re-created when the MMI
1557 * requests the emergency call setup
1558 */
1559 psaCC_FreeCtbNtry (cId);
1560
1561 /*
1562 ** Send the original Setup Call Request to the MMI in a %SATI indication
1563 */
1564 cmhSAT_Cust1StkCmdInd();
1565
1566 satShrdPrm.ntfy = USR_NTF_SETUP_CAL;
1567 return( TRUE );
1568 }
1569 else if( cmhSAT_ChckCmdDet() )
1570 {
1571 for( idx = 0; idx < CMD_SRC_MAX; idx++ )
1572 {
1573
1574 /*
1575 ** If cust_mode is not NORMAL_BEHAVIOUR, then don't do anything yet, because the
1576 ** %SATI indication will be sent later in the process
1577 */
1578 if (simShrdPrm.overall_cust_mode EQ (UBYTE)CUST_NORMAL_BEHAVIOUR)
1579 {
1580 #ifdef FF_SAT_E
1581 addPrm.chnType = SATA_CT_VOICE;
1582 addPrm.chnEst = SATA_EST_IM;
1583
1584 R_AT( RAT_SATA, idx )( cId+1,
1585 cmhSAT_ChckRedial(cId, cal->v_dur, &cal->dur),
1586 &addPrm);
1587 #else /* FF_SAT_E */
1588 R_AT( RAT_SATA, idx )( cId+1,
1589 cmhSAT_ChckRedial(cId, cal->v_dur, &cal->dur));
1590 #endif /* FF_SAT_E */
1591
1592 }
1593 }
1594
1595 satShrdPrm.ntfy = USR_NTF_SETUP_CAL;
1596 return( TRUE );
1597 }
1598
1599 psaCC_FreeCtbNtry (cId);
1600 return( FALSE );
1601 }
1602
1603 /*
1604 +-------------------------------------------------------------------+
1605 | PROJECT : GSM-PS (6147) MODULE : SAT |
1606 | ROUTINE : cmhSAT_sendSS |
1607 +-------------------------------------------------------------------+
1608
1609 PURPOSE : This function starts a SS transaction initiated by SAT.
1610 If the request is going to be processed, the function
1611 returns TRUE.
1612
1613 */
1614
1615 GLOBAL BOOL cmhSAT_sendSS ( T_SEND_SS * ss )
1616 {
1617 T_ACI_RETURN retVal; /* holds return value */
1618 T_ACI_D_CLIR_OVRD dummy2; /* dummy value */
1619 T_ACI_D_TOC dummy1; /* dummy value */
1620 T_ACI_SAT_TERM_RESP resp_data;
1621
1622 psaSAT_InitTrmResp( &resp_data );
1623
1624 TRACE_FUNCTION("cmhSAT_sendSS()");
1625
1626 /*
1627 *-------------------------------------------------------------------
1628 * build SS string
1629 *-------------------------------------------------------------------
1630 */
1631 if( !ss->v_ss_string )
1632 {
1633 /* respond with "error, required values are missing" */
1634 psaSAT_SendTrmResp( RSLT_UNKN_DATA, &resp_data );
1635 return( FALSE );
1636 }
1637
1638 if ( !ss->ss_string.c_ss_ctrl_string )
1639 {
1640 psaSAT_SendTrmResp(RSLT_ERR_REQ_VAL, &resp_data );
1641 return( FALSE );
1642 }
1643
1644
1645 cmhCC_init_cldPty( &satPndSetup.clpty );
1646
1647 utl_BCD2DialStr( ss->ss_string.ss_ctrl_string, satPndSetup.clpty.num,
1648 (UBYTE)MINIMUM(ss->ss_string.c_ss_ctrl_string,
1649 MAX_DIAL_LEN-1));
1650
1651 satPndSetup.clpty.ton = ss->ss_string.noa;
1652 satPndSetup.clpty.npi = ss->ss_string.npi;
1653
1654 /*
1655 *-------------------------------------------------------------------
1656 * check for call control by SIM
1657 *-------------------------------------------------------------------
1658 */
1659 retVal = cmhSAT_SSCntrlBySIM( &satPndSetup.clpty, OWN_SAT );
1660
1661 switch( retVal )
1662 {
1663 case( AT_EXCT ):
1664 satShrdPrm.ntfy = USR_NTF_SEND_SS;
1665 return( TRUE );
1666
1667 case( AT_BUSY ):
1668 /* respond with "Interaction with call control by SIM, temporary" */
1669 psaSAT_SendTrmResp( RSLT_CC_SIM_TMP, &resp_data );
1670 return( FALSE );
1671
1672 case( AT_FAIL ):
1673 /* respond with "Interaction with call control by SIM, permanent" */
1674 resp_data.add_content = ADD_NO_CAUSE;
1675 psaSAT_SendTrmResp( RSLT_CC_SIM_PRM, &resp_data );
1676 return( FALSE );
1677 }
1678
1679 /*
1680 *-------------------------------------------------------------------
1681 * check for busy SS condition
1682 *-------------------------------------------------------------------
1683 */
1684 if( psaSS_stbFindActSrv( NO_ENTRY ) NEQ NO_ENTRY )
1685 {
1686 /* respond with "error, ME currently unable to process command" */
1687 resp_data.add_content = ADD_ME_SS_BUSY;
1688 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
1689 return( FALSE );
1690 }
1691
1692 if (simShrdPrm.overall_cust_mode EQ (UBYTE)CUST_MODE_BEHAVIOUR_1)
1693 {
1694 /*
1695 ** Send the original SendSS Request to the MMI in a %SATI indication
1696 */
1697 cmhSAT_Cust1StkCmdInd();
1698
1699 satShrdPrm.ntfy = USR_NTF_SEND_SS;
1700 return( TRUE );
1701 }
1702
1703 /*
1704 *-------------------------------------------------------------------
1705 * decode and send SS string
1706 *-------------------------------------------------------------------
1707 */
1708 retVal = cmhCC_chkKeySeq ( OWN_SAT,
1709 &satPndSetup.clpty,
1710 &dummy1,
1711 &dummy2,
1712 CC_SIM_NO );
1713 if( retVal NEQ AT_EXCT )
1714 {
1715 /* respond with "error, beyond ME capabilities" */
1716 psaSAT_SendTrmResp( RSLT_ME_CAP, &resp_data );
1717 return( FALSE );
1718 }
1719
1720 satShrdPrm.ntfy = USR_NTF_SEND_SS;
1721 return( TRUE );
1722
1723 }
1724
1725 /*
1726 +-------------------------------------------------------------------+
1727 | PROJECT : GSM-PS (6147) MODULE : SAT |
1728 | ROUTINE : cmhSAT_sendUSSD |
1729 +-------------------------------------------------------------------+
1730
1731 PURPOSE : This function starts a USSD transaction initiated by SAT.
1732 If the request is going to be processed, the function
1733 returns TRUE.
1734
1735 */
1736
1737 GLOBAL BOOL cmhSAT_sendUSSD ( T_SEND_USSD * ussd )
1738 {
1739 T_ACI_RETURN retVal; /* holds return value */
1740 SHORT sId; /* holds service id */
1741 T_ACI_SAT_TERM_RESP resp_data;
1742 T_sat_ussd SATCC_ussd; /* to hold USSD string in case of SAT Control */
1743
1744 psaSAT_InitTrmResp( &resp_data );
1745
1746 TRACE_FUNCTION("cmhSAT_sendUSSD()");
1747
1748 /*
1749 *-------------------------------------------------------------------
1750 * build SS string
1751 *-------------------------------------------------------------------
1752 */
1753 if( !ussd->v_ussd_string )
1754 {
1755 /* respond with "error, required values are missing" */
1756 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
1757 return( FALSE );
1758 }
1759
1760 /*
1761 *-------------------------------------------------------------------
1762 * check for call control by SIM
1763 *-------------------------------------------------------------------
1764 */
1765 if ( psaSIM_ChkSIMSrvSup(SRV_USSDsupportInCC) )
1766 {
1767 SATCC_ussd.dcs = ussd->ussd_string.dcs;
1768 SATCC_ussd.c_ussd_str = ussd->ussd_string.c_ussd_str;
1769 SATCC_ussd.ussd_str = ussd->ussd_string.ussd_str;
1770
1771 retVal = cmhSAT_USSDCntrlBySIM( &SATCC_ussd, OWN_SAT );
1772
1773 switch( retVal )
1774 {
1775 case( AT_EXCT ):
1776 satShrdPrm.ntfy = USR_NTF_SEND_USSD;
1777 return( TRUE );
1778
1779 case( AT_BUSY ):
1780 /* respond with "Interaction with call control by SIM, temporary" */
1781 psaSAT_SendTrmResp( RSLT_CC_SIM_TMP, &resp_data );
1782 return( FALSE );
1783
1784 case( AT_FAIL ):
1785 /* respond with "Interaction with call control by SIM, permanent" */
1786 resp_data.add_content = ADD_NO_CAUSE;
1787 psaSAT_SendTrmResp( RSLT_CC_SIM_PRM, &resp_data );
1788 return( FALSE );
1789 }
1790 }
1791
1792 /***********************************************************
1793 check if a SS or a USSD transaction is already in process
1794 ***********************************************************/
1795
1796 sId = psaSS_stbFindActSrv( NO_ENTRY );
1797
1798 if( sId NEQ NO_ENTRY )
1799 {
1800 if (ssShrdPrm.stb[sId].curCmd EQ KSD_CMD_USSD
1801 OR ssShrdPrm.stb[sId].curCmd EQ AT_CMD_CUSD)
1802 resp_data.add_content = ADD_ME_USSD_BUSY;
1803 else
1804 resp_data.add_content = ADD_ME_SS_BUSY;
1805
1806 resp_data.addLen = 1;
1807
1808 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
1809 return( FALSE );
1810 }
1811
1812 if (simShrdPrm.overall_cust_mode EQ (UBYTE)CUST_MODE_BEHAVIOUR_1)
1813 {
1814 /*
1815 ** Send the original SendSS Request to the MMI in a %SATI indication
1816 */
1817 cmhSAT_Cust1StkCmdInd();
1818
1819 satShrdPrm.ntfy = USR_NTF_SEND_USSD;
1820 return( TRUE );
1821 }
1822
1823
1824 /* get new service table entry */
1825 sId = psaSS_stbNewEntry();
1826 if( sId EQ NO_ENTRY )
1827 {
1828 resp_data.add_content = ADD_ME_USSD_BUSY;
1829 resp_data.addLen = 1;
1830 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
1831 return( FALSE );
1832 }
1833
1834 CCD_START;
1835
1836 /* TLU: save DCS for USSD v1 */
1837 ssShrdPrm.ussdDcs = ussd->ussd_string.dcs;
1838
1839 /* set data coding scheme */
1840 /* patch !!!!! CLB 11/12/01 */
1841 if( (UBYTE)ussd->ussd_string.dcs EQ 0x40 )
1842 {
1843 /* 0x40 means basically default alphabet...
1844 yet some asian networks dont seem to accept it (although using it
1845 in their own STK !!!) */
1846 ussd->ussd_string.dcs = 0x0F;
1847 }
1848 /*********************************/
1849
1850 psaSS_asmProcUSSDReq( (UBYTE)ussd->ussd_string.dcs,
1851 ussd->ussd_string.ussd_str,
1852 ussd->ussd_string.c_ussd_str );
1853
1854 /* start new transaction */
1855 ssShrdPrm.stb[sId].ntryUsdFlg = TRUE;
1856 ssShrdPrm.stb[sId].curCmd = AT_CMD_NONE;
1857 ssShrdPrm.stb[sId].srvOwn = OWN_SAT;
1858
1859 /* save ussd string for possible version 1 retry */
1860 /* if( cmhSMS_getAlphabetCb( (UBYTE)dcs ) EQ 0 ) NOT SURE ABOUT THAT !!!! clb */
1861 {
1862 if( ussd->ussd_string.c_ussd_str <= MAX_USSD_STRING )
1863 {
1864 ssShrdPrm.ussdLen = ussd->ussd_string.c_ussd_str;
1865 memcpy( ssShrdPrm.ussdBuf,
1866 ussd->ussd_string.ussd_str,
1867 ussd->ussd_string.c_ussd_str );
1868 }
1869 }
1870
1871 satShrdPrm.SentUSSDid = sId; /* save for response message */
1872
1873 psaSS_NewTrns(sId);
1874
1875 CCD_END;
1876
1877 return( TRUE );
1878
1879 }
1880
1881 /*
1882 +-------------------------------------------------------------------+
1883 | PROJECT : GSM-PS (6147) MODULE : SAT |
1884 | ROUTINE : cmhSAT_sendDTMF |
1885 +-------------------------------------------------------------------+
1886
1887 PURPOSE : This function sends a DTMF sequence to the network.
1888
1889 */
1890
1891 LOCAL BOOL cmhSAT_initDTMF ( T_SEND_DTMF *dtmf )
1892 {
1893 SHORT cId; /* holds call id */
1894 T_ACI_SAT_TERM_RESP resp_data;
1895 CHAR num[MAX_CC_CALLED_NUMBER];
1896 UBYTE i;
1897 USHORT length;
1898
1899
1900 TRACE_FUNCTION("cmhSAT_initDTMF()");
1901
1902 psaSAT_InitTrmResp( &resp_data );
1903
1904 cId = cmhCC_find_call_for_DTMF( );
1905 if (cId EQ NO_ENTRY)
1906 {
1907 /* respond with "error, no speech call in process" */
1908 resp_data.add_content = ADD_ME_NO_SPCH_CALL;
1909 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
1910 return( FALSE );
1911 }
1912
1913 /* check arguments */
1914 if( dtmf AND !dtmf->v_dtmf_string )
1915 {
1916 /* respond with "error, required values are missing" */
1917 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
1918 return( FALSE );
1919 }
1920 else
1921 {
1922 length = MINIMUM((dtmf ? dtmf->dtmf_string.c_bcdDigit : 0), MAX_CC_CALLED_NUMBER);
1923 if (dtmf NEQ NULL)
1924 {
1925 for(i=0; i<length; i++)
1926 {
1927 num[i] = cmhPHB_convertBCD2char(dtmf->dtmf_string.bcdDigit[i]);
1928 }
1929 }
1930 else
1931 num[0] = '\0';
1932
1933 cmhCC_chkDTMFDig( num,
1934 cId,
1935 length,
1936 FALSE );
1937
1938 ccShrdPrm.dtmf.cId = cId; /* Update the global parameter with cId */
1939 psaCC_ctb(cId)->dtmfCmd = AT_CMD_NONE ;
1940 psaCC_ctb(cId)->dtmfSrc = OWN_SAT; /* wait for confirmation */
1941 return TRUE;
1942 }
1943 }
1944
1945
1946 GLOBAL BOOL cmhSAT_sendDTMF ( T_SEND_DTMF *dtmf )
1947 {
1948 SHORT cId; /* holds call id */
1949 T_ACI_SAT_TERM_RESP resp_data;
1950 BOOL param_ok;
1951
1952 TRACE_FUNCTION("cmhSAT_sendDTMF()");
1953
1954 psaSAT_InitTrmResp( &resp_data );
1955
1956 /* if no proceeding yet, check for a voice call */
1957 if( ccShrdPrm.dtmf.cId NEQ NO_ENTRY )
1958 {
1959 cId = ccShrdPrm.dtmf.cId;
1960 if (ccShrdPrm.ctb[cId] EQ NULL OR
1961 psaCC_ctb(cId)->dtmfSrc NEQ OWN_SAT )
1962 {
1963 /* respond with "error, busy on DTMF" */
1964 /* resp_data.add_content = ADD_ME_DTMF_BUSY; */
1965 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
1966 return( FALSE );
1967 }
1968 }
1969 else
1970 {
1971 /* initialize DTMF related parameters */
1972 if (!cmhSAT_initDTMF( dtmf ))
1973 return (FALSE);
1974 cId = ccShrdPrm.dtmf.cId;
1975 }
1976
1977 /* send DTMF */
1978 param_ok = cmhCC_SendDTMFdig ( AT_CMD_NONE, cId,
1979 ccShrdPrm.dtmf.dig[ccShrdPrm.dtmf.cur],
1980 DTMF_MOD_AUTO);
1981 ccShrdPrm.dtmf.cur++;
1982
1983 if( !param_ok )
1984 {
1985 /* respond with "value not recognized" */
1986 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
1987 return( FALSE );
1988 }
1989 return( TRUE );
1990 }
1991
1992 /*
1993 +-------------------------------------------------------------------+
1994 | PROJECT : GSM-PS (6147) MODULE : SAT |
1995 | ROUTINE : cmhSAT_runAt |
1996 +-------------------------------------------------------------------+
1997
1998 PURPOSE : This function performs run at command for SAT.
1999 */
2000
2001 GLOBAL BOOL cmhSAT_runAt ( T_RUN_AT *run_at)
2002 {
2003 T_ACI_SAT_TERM_RESP resp_data;
2004
2005 psaSAT_InitTrmResp( &resp_data );
2006
2007 TRACE_FUNCTION("cmhSAT_runAt()");
2008
2009 if(!run_at->v_at_string)
2010 {
2011 /* respond with "error, required values are missing" */
2012 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
2013 return(FALSE);
2014 }
2015
2016 #ifdef FF_ATI
2017 if( sat_src_proc_chars (run_at->at_string) EQ FALSE )
2018 {
2019 return(FALSE);
2020 }
2021 #endif /* FF_ATI */
2022
2023 return(TRUE);
2024 }
2025
2026 /*
2027 +-------------------------------------------------------------------+
2028 | PROJECT : GSM-PS (6147) MODULE : SAT |
2029 | ROUTINE : cmhSAT_setupEvent_Test |
2030 +-------------------------------------------------------------------+
2031
2032 PURPOSE : This function updates the event list to be whatched for SAT.
2033 */
2034
2035 GLOBAL BOOL cmhSAT_setupEvent_Test ( T_SETUP_EVENT *set_event,
2036 BOOL *aci_events_only )
2037 {
2038 SHORT i;
2039 BOOL mt_done = FALSE;
2040 BOOL conn_done = FALSE;
2041 BOOL disc_done = FALSE;
2042 BOOL loc_done = FALSE;
2043 #ifdef FF_SAT_E
2044 BOOL dat_avail = FALSE;
2045 BOOL chn_stat = FALSE;
2046 #endif /* FF_SAT_E */
2047 BOOL list_in_process;
2048
2049 /* ACI-SPR-18200: temporary event list, not processed by ACI */
2050 UBYTE tmpEventList[MAX_EVENT_LIST_LEN];
2051 UBYTE tmpEventListLen = 0;
2052
2053 TRACE_FUNCTION("cmhSAT_setupEvent_Test()");
2054
2055 if (set_event -> v_ev_list EQ TRUE)
2056 {
2057
2058
2059 /* erase previous list if received list is empty */
2060 if (set_event -> ev_list.c_event EQ 0L)
2061 {
2062 satShrdPrm.event.list = 0L;
2063 return TRUE;
2064 }
2065
2066 /* test events whether they are supported by ACI or not...
2067 Moreover, every event shall take place only once in the list */
2068 /* supported by ACI:
2069 EVENT_MT_CALL
2070 EVENT_CALL_CONN
2071 EVENT_CALL_DISC
2072 EVENT_LOC_STATUS
2073 EVENT_DATA_AVAIL (SAT E)
2074 EVENT_CHAN_STAT (SAT E) */
2075
2076 list_in_process = ( satShrdPrm.event.temp_list & 0x8000 ) > 0;
2077
2078 if ( list_in_process )
2079 {
2080 /*means a setup_event_list is already currently in process */
2081 return FALSE; /* TR(30) is sent by calling function */
2082 }
2083
2084 for (i=0;i<set_event -> ev_list.c_event;i++)
2085 {
2086 switch( set_event -> ev_list.event[i] )
2087 {
2088 case( EVENT_MT_CALL ):
2089 if (! mt_done )
2090 {
2091 mt_done = TRUE;
2092 }
2093 else
2094 {
2095 satShrdPrm.event.temp_list = 0L;
2096 return FALSE;
2097 }
2098 break;
2099
2100 case( EVENT_CALL_CONN ):
2101 if (! conn_done )
2102 {
2103 conn_done = TRUE;
2104 }
2105 else
2106 {
2107 satShrdPrm.event.temp_list = 0L;
2108 return FALSE;
2109 }
2110 break;
2111
2112 case( EVENT_CALL_DISC ):
2113 if (! disc_done )
2114 {
2115 disc_done = TRUE;
2116 }
2117 else
2118 {
2119 satShrdPrm.event.temp_list = 0L;
2120 return FALSE;
2121 }
2122 break;
2123
2124 case( EVENT_LOC_STATUS ):
2125 if (! loc_done )
2126 {
2127 loc_done = TRUE;
2128 }
2129 else
2130 {
2131 satShrdPrm.event.temp_list = 0L;
2132 return FALSE;
2133 }
2134 break;
2135
2136 #ifdef FF_SAT_E
2137 case( EVENT_DATA_AVAIL ):
2138 if (! dat_avail )
2139 {
2140 dat_avail = TRUE;
2141 }
2142 else
2143 {
2144 satShrdPrm.event.temp_list = 0L;
2145 return FALSE;
2146 }
2147 break;
2148
2149 case( EVENT_CHAN_STAT ):
2150 if (! chn_stat )
2151 {
2152 chn_stat = TRUE;
2153 }
2154 else
2155 {
2156 satShrdPrm.event.temp_list = 0L;
2157 return FALSE;
2158 }
2159 break;
2160 #endif /* FF_SAT_E */
2161
2162 default:
2163 satShrdPrm.event.temp_list |= (0x01 << set_event->ev_list.event[i]);
2164 /* so that the corresponding bit won't actually be set in temp_list */
2165 /* ACI-SPR-18200: add to local temp event list */
2166 tmpEventList[tmpEventListLen] = set_event->ev_list.event[i];
2167 tmpEventListLen++;
2168 break;
2169 }
2170 satShrdPrm.event.temp_list |= (0x01 << set_event->ev_list.event[i]);
2171 }
2172 }
2173 else
2174 {
2175 satShrdPrm.event.temp_list = 0L;
2176 return FALSE;
2177 }
2178
2179 satShrdPrm.event.temp_list |= 0x8000; /* to flag that a list is in process */
2180
2181 /* ACI-SPR-18200: Modify the SAT cmd send to MMI */
2182 if ( cmhSAT_copyUnprocEvents ( tmpEventList,
2183 tmpEventListLen,
2184 set_event->ev_list.c_event ) )
2185 {
2186 *aci_events_only = FALSE;
2187 }
2188 else
2189 {
2190 *aci_events_only = TRUE;
2191 }
2192
2193 return TRUE;
2194 }
2195
2196 /*
2197 +-------------------------------------------------------------------+
2198 | PROJECT : GSM-PS (6147) MODULE : SAT |
2199 | ROUTINE : cmhSAT_copyUnprocEvents |
2200 +-------------------------------------------------------------------+
2201
2202 PURPOSE : Modify the event list that will be send to MMI.
2203 Insert the events that could not be processed by ACI.
2204 Returning TRUE means: Forward the current SAT command
2205 to MMI for further analysis.
2206 */
2207
2208 GLOBAL BOOL cmhSAT_copyUnprocEvents ( UBYTE* eventList,
2209 UBYTE eventListLen,
2210 UBYTE oldEventListLen)
2211 {
2212 USHORT totalLen;
2213 UBYTE lenDiff;
2214 UBYTE i;
2215 UBYTE j;
2216 UBYTE shift = 0; /* Holds the shift value */
2217
2218 TRACE_FUNCTION("cmhSAT_copyUnprocEvents()");
2219
2220 /* No modification needed, all events processed in ACI */
2221 if ( (eventListLen EQ 0) AND (oldEventListLen NEQ 0) )
2222 {
2223 return FALSE;
2224 }
2225 /* No modifiction necessary, all events are forwarded */
2226 else if ( eventListLen EQ oldEventListLen )
2227 {
2228 return TRUE;
2229 }
2230 else
2231 {
2232 /* modify SAT event list string */
2233 /* calculate difference between new and old length of event list */
2234 lenDiff = oldEventListLen - eventListLen;
2235
2236 /* modify the total length, always second (and third) byte
2237 Note: This is the only length that is critical, if the length
2238 decrement changes the total len from 2 to 1 byte representation
2239 the whole array has to be shifted one position at the end of
2240 modification. */
2241 if ( satShrdPrm.stkCmd[1] EQ 0x81 )
2242 {
2243 if ( (satShrdPrm.stkCmd[2] > 0x7F) AND
2244 ((satShrdPrm.stkCmd[2] - lenDiff) <= 0x7F )) /* mod changes repres.*/
2245 {
2246 /* forces a shift at the end of modification */
2247 shift = 1;
2248 }
2249 satShrdPrm.stkCmd[2] = satShrdPrm.stkCmd[2] - lenDiff;
2250 i = 3;
2251 }
2252 else
2253 {
2254 satShrdPrm.stkCmd[1] = satShrdPrm.stkCmd[1] - lenDiff;
2255 i = 2;
2256 }
2257
2258 /* go to index of SET UP EVENT LIST TAG */
2259 while( i < satShrdPrm.stkCmdLen )
2260 {
2261 /* Is tag set up event list TAG */
2262 if ( satShrdPrm.stkCmd[i] NEQ 0x99 )
2263 {
2264 /* go LENGTH steps ahead */
2265 /* jump over the VALUE field to the next TAG */
2266 if ( satShrdPrm.stkCmd[i+1] EQ 0x81 ) /* 2 byte length representation */
2267 {
2268 i = i + ( satShrdPrm.stkCmd[i+2] + 3 );
2269 }
2270 else
2271 {
2272 i = i + ( satShrdPrm.stkCmd[i+1] + 2 );
2273 }
2274 }
2275 else
2276 {
2277 /* found index */
2278 break;
2279 }
2280 }
2281
2282 /* insert new events and decrease length */
2283 if ( (i < satShrdPrm.stkCmdLen) AND
2284 (satShrdPrm.stkCmd[i] EQ 0x99) )
2285 {
2286 /* set index to LENGTH */
2287 i++;
2288 /* decrease length */
2289 if ( satShrdPrm.stkCmd[i] EQ 0x81 ) /* 2 byte length representation */
2290 {
2291 if ( satShrdPrm.stkCmd[i+1] - lenDiff <= 0x7F ) /*repres. changes to 1*/
2292 {
2293 satShrdPrm.stkCmd[i] = satShrdPrm.stkCmd[i+1] - lenDiff;
2294 /* set index just one byte ahead to overwrite second length byte */
2295 i++;
2296 }
2297 else
2298 {
2299 satShrdPrm.stkCmd[i+1] = satShrdPrm.stkCmd[i+1] - lenDiff;
2300 /* set index to value */
2301 i+=2;
2302 }
2303 }
2304 else /* just change the length */
2305 {
2306 satShrdPrm.stkCmd[i] = satShrdPrm.stkCmd[i] - lenDiff;
2307 /* set index to VALUE */
2308 i++;
2309 }
2310 /* write out events that have to be forwarded to MMI */
2311 for( j = 0; j < eventListLen; j++)
2312 {
2313 satShrdPrm.stkCmd[i+j] = eventList[j];
2314 }
2315
2316 /* set index to end */
2317 i = i + j;
2318 /* clear rest of array */
2319 if ( i < satShrdPrm.stkCmdLen )
2320 {
2321 while ( i < satShrdPrm.stkCmdLen )
2322 {
2323 satShrdPrm.stkCmd[i] = 0xFF;
2324 i++;
2325 }
2326 }
2327
2328 }
2329 else
2330 {
2331 TRACE_EVENT("ERROR: Could not find SET UP EVENT LIST TAG");
2332 /* reset temp list to force error response */
2333 satShrdPrm.event.temp_list = 0L;
2334 return FALSE;
2335 }
2336
2337 /* if shift is needed */
2338 /* set index to first byte of total length */
2339 i = 2;
2340 if ( shift )
2341 {
2342 for ( i = 2; i < (satShrdPrm.stkCmdLen - 1); i++ )
2343 {
2344 satShrdPrm.stkCmd[i] = satShrdPrm.stkCmd[i+1];
2345 }
2346 }
2347
2348 /* decrease the total length */
2349 totalLen = satShrdPrm.stkCmdLen - (lenDiff*8);
2350 satShrdPrm.stkCmdLen = totalLen;
2351
2352 return TRUE;
2353 }
2354 }
2355
2356 /*
2357 +-------------------------------------------------------------------+
2358 | PROJECT : GSM-PS (6147) MODULE : SAT |
2359 | ROUTINE : cmhSAT_setupEvent_Perform|
2360 +-------------------------------------------------------------------+
2361
2362 PURPOSE : This function updates the event list to be whatched for SAT.
2363 */
2364
2365 GLOBAL void cmhSAT_setupEvent_Perform ( void )
2366 {
2367 TRACE_FUNCTION("cmhSAT_setupEvent_Perform()");
2368
2369 /* update list */
2370 satShrdPrm.event.list = satShrdPrm.event.temp_list;
2371
2372 satShrdPrm.event.temp_list = 0L; /* reinitialize for next setup list */
2373
2374 #if defined (FF_SAT_E) AND defined (DTI)
2375 /* inform SIM about a possible DATA AVAIL event */
2376 psaSIM_EvDatAvail(psaSAT_ChkEventList( EVENT_DATA_AVAIL ));
2377 #endif /* FF_SAT_E */
2378
2379 /*psaSAT_SendTrmResp( RSLT_PERF_SUCCESS, 0, NULL, NULL );
2380 not needed... what comes from MMI is sent to SAT */
2381 }
2382 /*
2383 +-------------------------------------------------------------------+
2384 | PROJECT : GSM-PS (6147) MODULE : SAT |
2385 | ROUTINE : cmhSAT_UserRejCall |
2386 +-------------------------------------------------------------------+
2387
2388 PURPOSE : This function sends a terminal response, indicating that
2389 the user has not accept the SAT call.
2390
2391 */
2392
2393 GLOBAL void cmhSAT_UserRejCall ( UBYTE calStat )
2394 {
2395 T_ACI_SAT_TERM_RESP resp_data;
2396
2397 TRACE_FUNCTION("cmhSAT_UserRejCall()");
2398
2399 psaSAT_InitTrmResp( &resp_data );
2400
2401 #ifdef FF_SAT_E
2402 if( calStat EQ CS_SAT_CSD_REQ )
2403
2404 resp_data.chnStat = TRUE;
2405 #endif /* FF_SAT_E */
2406
2407 psaSAT_SendTrmResp( RSLT_USR_REJ, &resp_data );
2408
2409 #ifdef FF_SAT_E
2410 if( calStat EQ CS_SAT_CSD_REQ )
2411 {
2412 cmhSAT_cleanupOpChnPrms();
2413 }
2414 #endif /* FF_SAT_E */
2415 }
2416
2417 /*
2418 +-------------------------------------------------------------------+
2419 | PROJECT : GSM-PS (6147) MODULE : SAT |
2420 | ROUTINE : cmhSAT_UserRejCntxt |
2421 +-------------------------------------------------------------------+
2422
2423 PURPOSE : This function sends a terminal response, indicating that
2424 the user has not accepted the SAT GPRS context.
2425
2426 */
2427
2428 #if defined (GPRS) && defined (FF_SAT_E)
2429 GLOBAL void cmhSAT_UserRejCntxt( void )
2430 {
2431 T_ACI_SAT_TERM_RESP resp_data;
2432
2433 TRACE_FUNCTION("cmhSAT_UserRejCntxt()");
2434
2435 psaSAT_InitTrmResp( &resp_data );
2436 resp_data.chnStat = TRUE;
2437
2438 psaSAT_SendTrmResp( RSLT_USR_REJ, &resp_data );
2439
2440 cmhSAT_cleanupOpChnPrms();
2441
2442 }
2443 #endif /* GPRS && SAT E */
2444
2445 /*
2446 +-------------------------------------------------------------------+
2447 | PROJECT : GSM-PS (6147) MODULE : SAT |
2448 | ROUTINE : cmhSAT_CallCncted |
2449 +-------------------------------------------------------------------+
2450
2451 PURPOSE : This function sends a terminal response, indicating that
2452 the SAT call was connected.
2453
2454 */
2455
2456 GLOBAL void cmhSAT_CallCncted ( void )
2457 {
2458 T_ACI_SAT_TERM_RESP resp_data;
2459
2460 TRACE_FUNCTION("cmhSAT_CallCncted()");
2461
2462 psaSAT_InitTrmResp( &resp_data );
2463 psaSAT_SendTrmResp( RSLT_PERF_SUCCESS, &resp_data );
2464 }
2465
2466 /*
2467 +-------------------------------------------------------------------+
2468 | PROJECT : GSM-PS (6147) MODULE : SAT |
2469 | ROUTINE : cmhSAT_NtwErr |
2470 +-------------------------------------------------------------------+
2471
2472 PURPOSE : This function sends a terminal response, indicating that
2473 the SAT call was not connected due to a network problem.
2474 The function will return TRUE if it is OK to send a AT
2475 result code. If a result code should be suppressed, the
2476 function will return FALSE.
2477
2478 */
2479
2480 GLOBAL UBYTE cmhSAT_NtwErr ( UBYTE cs )
2481 {
2482
2483 T_ACI_SAT_TERM_RESP resp_data;
2484 #if defined (FF_SAT_E) AND defined (DTI)
2485 T_SIM_SAT_CHN chnInf;
2486 #endif
2487 UBYTE ret = TRUE;
2488
2489 TRACE_FUNCTION("cmhSAT_NtwErr()");
2490
2491 psaSAT_InitTrmResp( &resp_data );
2492
2493 resp_data.add_content = cs;
2494
2495 #if defined (FF_SAT_E) AND defined (DTI)
2496 /* in case of a SEND DATA command, close the channel. Terminal response
2497 will be sent by SIM entity */
2498 if( satShrdPrm.chnTb.chnUsdFlg AND
2499 satShrdPrm.cmdDet.cmdType EQ SAT_CMD_SEND_DATA)
2500 {
2501 chnInf.dtiConn = SIM_DTI_UNKNOWN;
2502 chnInf.bipConn = SIM_BIP_CLOSE_CHANNEL;
2503 chnInf.chnId = CHANNEL_ID_1;
2504 chnInf.genRes = RSLT_NTW_UNAB_PROC;
2505 chnInf.addRes = cs;
2506
2507 psaSIM_SATBIPChn( chnInf, cmhSAT_OpChnClose );
2508 ret = FALSE;
2509 }
2510 /* otherwise send a terminal response */
2511 else
2512 {
2513 if( satShrdPrm.opchStat EQ OPCH_EST_REQ AND
2514 satShrdPrm.opchType EQ B_CSD )
2515 {
2516 resp_data.chnStat = TRUE;
2517 }
2518 #endif /* FF_SAT_E */
2519
2520 psaSAT_SendTrmResp( RSLT_NTW_UNAB_PROC, &resp_data );
2521
2522 #if defined (FF_SAT_E) AND defined (DTI)
2523 }
2524
2525 if( satShrdPrm.opchStat EQ OPCH_EST_REQ AND
2526 satShrdPrm.opchType EQ B_CSD )
2527 {
2528 satShrdPrm.chnTb.chnUsdFlg = FALSE;
2529 cmhSAT_cleanupOpChnPrms();
2530 }
2531 #endif /* FF_SAT_E */
2532
2533 return ret;
2534 }
2535
2536 /*
2537 +-------------------------------------------------------------------+
2538 | PROJECT : GSM-PS (6147) MODULE : SAT |
2539 | ROUTINE : cmhSAT_UserClear |
2540 +-------------------------------------------------------------------+
2541
2542 PURPOSE : This function sends a terminal response, indicating that
2543 the SAT call was not connected due to a user clearance.
2544
2545 */
2546
2547 GLOBAL void cmhSAT_UserClear ( void )
2548 {
2549 T_ACI_SAT_TERM_RESP resp_data;
2550 #if defined (FF_SAT_E) AND defined (DTI)
2551 T_SIM_SAT_CHN chnInf;
2552 #endif /* FF_SAT_E */
2553
2554 TRACE_FUNCTION("cmhSAT_UserClear()");
2555
2556 psaSAT_InitTrmResp( &resp_data );
2557
2558 #if defined (FF_SAT_E) AND defined (DTI)
2559 /* in case of a SEND DATA command, close the channel. Terminal response
2560 will be sent by SIM entity */
2561 if( satShrdPrm.chnTb.chnUsdFlg AND
2562 satShrdPrm.cmdDet.cmdType EQ SAT_CMD_SEND_DATA)
2563 {
2564 chnInf.bipConn = SIM_BIP_CLOSE_CHANNEL;
2565 chnInf.dtiConn = SIM_DTI_UNKNOWN;
2566 chnInf.chnId = CHANNEL_ID_1;
2567 chnInf.genRes = RSLT_USR_CLR_DWN;
2568 chnInf.addRes = ADD_NO_CAUSE;
2569
2570 psaSIM_SATBIPChn( chnInf, cmhSAT_OpChnClose );
2571 }
2572 /* otherwise send a terminal response */
2573 else
2574 {
2575 if( satShrdPrm.opchStat EQ OPCH_EST_REQ AND
2576 satShrdPrm.opchType EQ B_CSD )
2577 {
2578 resp_data.chnStat = TRUE;
2579 }
2580 #endif /* FF_SAT_E */
2581 psaSAT_SendTrmResp( RSLT_USR_CLR_DWN, &resp_data );
2582
2583 #if defined (FF_SAT_E) AND defined (DTI)
2584 }
2585
2586 if( satShrdPrm.opchStat EQ OPCH_EST_REQ AND
2587 satShrdPrm.opchType EQ B_CSD )
2588 {
2589 satShrdPrm.chnTb.chnUsdFlg = FALSE;
2590 cmhSAT_cleanupOpChnPrms();
2591 }
2592 #endif /* FF_SAT_E */
2593 }
2594
2595 /*
2596 +-------------------------------------------------------------------+
2597 | PROJECT : GSM-PS (6147) MODULE : SAT |
2598 | ROUTINE : cmhSAT_UserAcptCall |
2599 +-------------------------------------------------------------------+
2600
2601 PURPOSE : This function performs the user acceptance of the pending
2602 SAT call. If command details do not allow the operation,
2603 the function returns FALSE.
2604
2605 */
2606
2607 GLOBAL BOOL cmhSAT_UserAcptCall ( SHORT acptId, UBYTE srcId )
2608 {
2609 T_CC_CMD_PRM * pCCCmdPrm; /* points to CC command parameters */
2610 SHORT actId; /* holds id of active call */
2611 UBYTE ctbIdx; /* holds call table index */
2612 BOOL found_call=FALSE;
2613
2614 #if defined (FAX_AND_DATA) AND defined (FF_SAT_E)
2615 T_SIM_SAT_CHN chnInf;
2616 #endif
2617
2618 TRACE_FUNCTION("cmhSAT_UserAcptCall()");
2619
2620 pCCCmdPrm = &cmhPrm[srcId].ccCmdPrm;
2621
2622 pCCCmdPrm -> mltyCncFlg = 0;
2623 pCCCmdPrm -> mltyDscFlg = 0;
2624
2625 psaCC_ctb(acptId)->curCmd = AT_CMD_A;
2626 psaCC_ctb(acptId)->curSrc = srcId;
2627
2628 /*
2629 *-------------------------------------------------------------------
2630 * perform according to command details for SETUP CALL command
2631 *-------------------------------------------------------------------
2632 */
2633 if (psaCC_ctb(acptId)->calStat EQ CS_SAT_REQ)
2634 {
2635 if( !cmhSAT_ChckCmdDet() )
2636 {
2637 psaCC_FreeCtbNtry (acptId);
2638 return( FALSE );
2639 }
2640
2641 switch( satShrdPrm.cmdDet.cmdQlf )
2642 {
2643 case( QLF_CALL_HOLD ):
2644 case( QLF_CALL_HOLD_RDL ):
2645
2646 actId = psaCC_ctbFindCall( NO_VLD_OWN, CS_ACT, NO_VLD_CT );
2647
2648 if( actId NEQ NO_ENTRY )
2649 {
2650 psaCC_ctb(actId)->SATinv = TRUE;
2651
2652 cmhCC_HoldCall(actId, psaCC_ctb(acptId)->curSrc, AT_CMD_A);
2653
2654 if( psaCC_ctb(actId)->mptyStat NEQ CS_ACT )
2655 {
2656 /* do not start building sat call, has to wait for answer for holding */
2657 return( TRUE );
2658 }
2659 }
2660 break;
2661
2662 case( QLF_CALL_DISC ):
2663 case( QLF_CALL_DISC_RDL ):
2664
2665 for( ctbIdx = 0; ctbIdx < MAX_CALL_NR; ctbIdx++ )
2666 {
2667 T_CC_CALL_TBL *ctbx = ccShrdPrm.ctb[ctbIdx];
2668
2669 if (ctbx NEQ NULL AND
2670 ctbIdx NEQ acptId )
2671 {
2672 cmhCC_flagCall( ctbIdx, &(pCCCmdPrm -> mltyDscFlg));
2673 ctbx->nrmCs = MNCC_CAUSE_CALL_CLEAR;
2674 ctbx->curCmd = AT_CMD_H;
2675 ctbx->curSrc = psaCC_ctb(acptId)->curSrc;
2676 ctbx->SATinv = TRUE;
2677 psaCC_ClearCall (ctbIdx);
2678 found_call = TRUE;
2679 }
2680 }
2681
2682 if (found_call)
2683 {
2684 /* do not start building sat call, has to wait for answer for clearing */
2685 return( TRUE );
2686 }
2687 break;
2688 }
2689 }
2690
2691 /*
2692 *-------------------------------------------------------------------
2693 * perform according to command details for OPEN CHANNEL command
2694 *-------------------------------------------------------------------
2695 */
2696 #if defined (FAX_AND_DATA) AND defined (FF_SAT_E) AND defined (DTI)
2697
2698 if( psaCC_ctb(acptId)->calStat EQ CS_SAT_CSD_REQ )
2699 {
2700
2701 /* reset own to SAT */
2702 psaCC_ctb(acptId)->calOwn = OWN_SAT;
2703
2704 /* store current command source */
2705 satShrdPrm.opchAcptSrc = srcId;
2706
2707 if( satShrdPrm.opchPrm AND
2708 ((T_SAT_CSD_PRM*)satShrdPrm.opchPrm)->v_itl AND
2709 ((T_SAT_CSD_PRM*)satShrdPrm.opchPrm)->itl.trans_prot_type EQ UDP )
2710 {
2711 satShrdPrm.chnTb.chnTPL = ((T_SAT_CSD_PRM*)satShrdPrm.opchPrm)->itl.trans_prot_type;
2712 }
2713 else
2714 {
2715 satShrdPrm.chnTb.chnTPL = TPL_NONE;
2716 }
2717
2718 /* check for on-demand channel establishment */
2719 if(!(satShrdPrm.cmdDet.cmdQlf & QLF_OPCH_IMMDT_LINK_EST))
2720 {
2721 /* CASE: ON DEMAND */
2722 /* set open channel status */
2723 satShrdPrm.opchStat = OPCH_ON_DMND;
2724 }
2725 else /* immediately channel establishment */
2726 {
2727 /* CASE: IMMEDIATELY */
2728 /* check temporary problems */
2729 if( cmhSAT_OpChnChkTmpProblem() )
2730 {
2731 psaCC_FreeCtbNtry (acptId);
2732 satShrdPrm.chnTb.chnUsdFlg = FALSE;
2733
2734 return( FALSE );
2735 }
2736
2737 /* set open channel status */
2738 satShrdPrm.opchStat = OPCH_EST_REQ;
2739
2740 #ifdef DTI
2741 #ifdef CO_UDP_IP
2742 if( satShrdPrm.chnTb.chnTPL EQ UDP )
2743 {
2744 /* enable establishment of UDP data chain */
2745 sAT_PercentWAP ( psaCC_ctb(acptId)->curSrc , 1 );
2746
2747 /* setup PPP parameters */
2748 cmhSAT_OpChnSetPPP( B_CSD );
2749 }
2750 #endif /* CO_UDP_IP */
2751 #endif /* DTI */
2752 }
2753
2754 /* Establish BIP channel for immediate and on demand */
2755 chnInf.bipConn = SIM_BIP_OPEN_CHANNEL;
2756 chnInf.dtiConn = SIM_DTI_UNKNOWN;
2757 chnInf.chnId = CHANNEL_ID_1;
2758 chnInf.genRes = RSLT_PERF_SUCCESS;
2759 chnInf.addRes = ADD_NO_CAUSE;
2760
2761 /* SAT_E_PATCH: send SIM_BIP_REQ to open BIP channel */
2762 psaSIM_SATBIPChn( chnInf, cmhSAT_OpBIPChnOpen);
2763
2764 return (TRUE);
2765 }
2766 #endif /* FAX_AND_DATA AND FF_SAT_E */
2767
2768 /* finally set up call */
2769 cmhCC_flagCall( acptId, &(pCCCmdPrm->mltyCncFlg));
2770 cmhCC_NewCall(acptId, srcId, AT_CMD_A);
2771 return( TRUE );
2772 }
2773
2774 /*
2775 +-------------------------------------------------------------------+
2776 | PROJECT : GSM-PS (6147) MODULE : SAT |
2777 | ROUTINE : cmhSAT_UserAcptCntxt |
2778 +-------------------------------------------------------------------+
2779
2780 PURPOSE : This function performs the user acceptance of the pending
2781 SAT GPRS context. If conditions occur, which prevent the
2782 establishment of the context, the function returns FALSE.
2783
2784 */
2785
2786 #if defined (GPRS) AND defined (FF_SAT_E) AND defined (DTI)
2787 GLOBAL BOOL cmhSAT_UserAcptCntxt( UBYTE srcId )
2788 {
2789 T_SIM_SAT_CHN chnInf; /* holds channel information */
2790 SHORT cid_array[2] = { 0,INVALID_CID };
2791
2792 TRACE_FUNCTION("cmhSAT_UserAcptCntxt()");
2793
2794 /* store current command source */
2795 satShrdPrm.opchAcptSrc = srcId;
2796 cid_array[0] = satShrdPrm.chnTb.chnRefId;
2797
2798 if( satShrdPrm.opchPrm AND
2799 ((T_SAT_GPRS_PRM*)satShrdPrm.opchPrm)->v_itl AND
2800 ((T_SAT_GPRS_PRM*)satShrdPrm.opchPrm)->itl.trans_prot_type EQ UDP )
2801 {
2802 satShrdPrm.chnTb.chnTPL = ((T_SAT_GPRS_PRM*)satShrdPrm.opchPrm)->itl.trans_prot_type;
2803 }
2804 else
2805 {
2806 satShrdPrm.chnTb.chnTPL = TPL_NONE;
2807 }
2808
2809
2810 /* check for on-demand channel establishment */
2811 if(!(satShrdPrm.cmdDet.cmdQlf & QLF_OPCH_IMMDT_LINK_EST))
2812 {
2813 /* CASE: ON DEMAND */
2814
2815 /* set open channel status */
2816 satShrdPrm.opchStat = OPCH_ON_DMND;
2817 }
2818 else
2819 {
2820 /* CASE: IMMEDIATELY */
2821
2822 /* check temporary problems */
2823 if( cmhSAT_OpChnChkTmpProblem() )
2824 {
2825 /* any reset of cid parameters should be placed here, if necessary */
2826 return( FALSE );
2827 }
2828
2829 /* set open channel status */
2830 satShrdPrm.opchStat = OPCH_EST_REQ;
2831 }
2832 /*
2833 * The activation of the GPRS context is triggered by cmhSAT_OpBIPChnOpen(),
2834 * a function processing the SIM_BIP_CNF. In the new design the BIP channel
2835 * has to be established before the bearer is started (see also
2836 * cmhSAT_UserAcptCall() for CSD case)
2837 */
2838
2839 /* Establish BIP channel for immediate and on demand */
2840 chnInf.bipConn = SIM_BIP_OPEN_CHANNEL;
2841 chnInf.dtiConn = SIM_DTI_UNKNOWN;
2842 chnInf.chnId = CHANNEL_ID_1;
2843 chnInf.genRes = RSLT_PERF_SUCCESS;
2844 chnInf.addRes = ADD_NO_CAUSE;
2845
2846 /* SAT_E_PATCH: send SIM_BIP_REQ to open BIP channel */
2847 psaSIM_SATBIPChn( chnInf, cmhSAT_OpBIPChnOpen);
2848
2849 return ( TRUE );
2850 }
2851 #endif /* GPRS AND FF_SAT_E */
2852 /*
2853 +-------------------------------------------------------------------+
2854 | PROJECT : GSM-PS (6147) MODULE : SAT |
2855 | ROUTINE : cmhSAT_ChckRedial |
2856 +-------------------------------------------------------------------+
2857
2858 PURPOSE : This function checks the redialling conditions and setup
2859 the appropriate parameters.
2860
2861 */
2862
2863 GLOBAL LONG cmhSAT_ChckRedial ( SHORT cId, UBYTE v_dur, T_dur * dur )
2864 {
2865 TRACE_FUNCTION("cmhSAT_ChckRedial()");
2866
2867 satShrdPrm.dur = -1;
2868
2869 /*
2870 *-------------------------------------------------------------------
2871 * check command qualifier for redialling
2872 *-------------------------------------------------------------------
2873 */
2874 #ifdef FF_SAT_E
2875 /* in case of SETUP CALL command */
2876 if( satShrdPrm.cmdDet.cmdType EQ SAT_CMD_SETUP_CALL )
2877 #endif /* FF_SAT_E */
2878 {
2879 switch( satShrdPrm.cmdDet.cmdQlf )
2880 {
2881 case( QLF_CALL_IDLE_RDL ):
2882 case( QLF_CALL_HOLD_RDL ):
2883 case( QLF_CALL_DISC_RDL ):
2884
2885 break;
2886
2887 default:
2888
2889 return( ACI_NumParmNotPresent );
2890 }
2891 }
2892
2893 #ifdef FF_SAT_E
2894 /* in case of OPEN CHANNEL command */
2895 if( satShrdPrm.cmdDet.cmdType EQ SAT_CMD_OPEN_CHANNEL )
2896 {
2897 if(!(satShrdPrm.cmdDet.cmdQlf & QLF_OPCH_AUTO_RECONNECT))
2898
2899 return( ACI_NumParmNotPresent );
2900 }
2901 #endif /* FF_SAT_E */
2902
2903 /* calculate redial timeout */
2904 psaCC_ctb(cId)->SATinv |= SAT_REDIAL;
2905
2906 if( v_dur )
2907 {
2908 switch( dur->time_unit )
2909 {
2910 /* scale to ms */
2911 case( TU_MIN ):
2912 satShrdPrm.dur = dur->time_ivl*60000;
2913 break;
2914 case( TU_SEC ):
2915 satShrdPrm.dur = dur->time_ivl*1000;
2916 break;
2917 case( TU_100_MSEC ):
2918 satShrdPrm.dur = dur->time_ivl*100;
2919 break;
2920 default:
2921 satShrdPrm.dur = -1;
2922 }
2923 }
2924
2925
2926 return((satShrdPrm.dur EQ -1)?ACI_NumParmNotPresent:satShrdPrm.dur);
2927 }
2928
2929 /*
2930 +-------------------------------------------------------------------+
2931 | PROJECT : GSM-PS (6147) MODULE : SAT |
2932 | ROUTINE : cmhSAT_StartPendingCall |
2933 +-------------------------------------------------------------------+
2934
2935 PURPOSE : This function performs the actual start of the pending
2936 SAT call.
2937 */
2938
2939 GLOBAL BOOL cmhSAT_StartPendingCall ( void )
2940 {
2941 T_CC_CMD_PRM * pCCCmdPrm; /* points to CC command parameters */
2942 SHORT satId; /* id of sat pending call */
2943 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
2944 T_ACI_CLOG cmdLog; /* holds logging info */
2945 #endif
2946
2947 TRACE_FUNCTION("cmhSAT_StartPendingCall()");
2948
2949 satId = psaCC_ctbFindCall( NO_VLD_OWN, CS_SAT_REQ, NO_VLD_CT );
2950
2951 if (satId EQ NO_ENTRY)
2952 return FALSE;
2953
2954 pCCCmdPrm = &cmhPrm[psaCC_ctb(satId)->curSrc].ccCmdPrm;
2955 TRACE_EVENT_P1("psaCC_ctb(cId)->curCmd: %d", psaCC_ctb(satId)->curCmd);
2956
2957 cmhCC_flagCall( satId, &(pCCCmdPrm -> mltyCncFlg));
2958 psaCC_NewCall(satId);
2959
2960 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
2961 cmdLog.atCmd = AT_CMD_A;
2962 cmdLog.cmdType = CLOG_TYPE_Set;
2963 cmdLog.retCode = AT_EXCT;
2964 cmdLog.sId = ACI_NumParmNotPresent;
2965 cmdLog.cmdPrm.sA.srcId = psaCC_ctb(satId)->curSrc;
2966 cmdLog.cId = satId+1;
2967 rAT_PercentCLOG( &cmdLog );
2968 #endif
2969
2970 return TRUE;
2971 }
2972
2973 /*
2974 +-------------------------------------------------------------------+
2975 | PROJECT : GSM-PS (6147) MODULE : SAT |
2976 | ROUTINE : cmhSAT_ChckCmdDet |
2977 +-------------------------------------------------------------------+
2978
2979 PURPOSE : This function checks the command details against the
2980 current ME status. If the mobile status does not interfere
2981 with the command details, the function returns TRUE.
2982
2983 */
2984
2985 GLOBAL BOOL cmhSAT_ChckCmdDet ( void )
2986 {
2987 SHORT ctbIdx; /* holds call table index */
2988 SHORT actId = NO_ENTRY; /* identifier for active call */
2989 SHORT hldId = NO_ENTRY; /* identifier for held call */
2990 SHORT cId = satShrdPrm.SIMCCParm.cId; /* holds setup call id */
2991 T_ACI_SAT_TERM_RESP resp_data;
2992
2993 TRACE_FUNCTION("cmhSAT_ChckCmdDet()");
2994
2995 if (!psaCC_ctbIsValid (cId))
2996 {
2997 TRACE_ERROR ("Call table entry disappeared");
2998 return FALSE;
2999 }
3000
3001 /*
3002 * From here it is guaranteed that cId describes an existing (non-NULL)
3003 * call table entry.
3004 */
3005
3006 psaSAT_InitTrmResp( &resp_data );
3007 /*
3008 *-------------------------------------------------------------------
3009 * scan call table
3010 *-------------------------------------------------------------------
3011 */
3012 for( ctbIdx = 0; ctbIdx < MAX_CALL_NR; ctbIdx++ )
3013 {
3014 if (ccShrdPrm.ctb[ctbIdx] NEQ NULL)
3015 {
3016 switch( psaCC_ctb(ctbIdx)->calStat )
3017 {
3018 case( CS_ACT ):
3019 case( CS_ACT_REQ ):
3020 case( CS_MDF_REQ ):
3021
3022 actId = ctbIdx;
3023 break;
3024
3025 case( CS_HLD ):
3026 case( CS_HLD_REQ ):
3027
3028 hldId = ctbIdx;
3029 break;
3030 }
3031 }
3032 }
3033
3034 /*
3035 *-------------------------------------------------------------------
3036 * check command qualifier against ME status
3037 *-------------------------------------------------------------------
3038 */
3039 switch( satShrdPrm.cmdDet.cmdQlf )
3040 {
3041 case( QLF_CALL_IDLE ):
3042 case( QLF_CALL_IDLE_RDL ):
3043
3044 if( actId NEQ NO_ENTRY OR hldId NEQ NO_ENTRY )
3045 {
3046 resp_data.add_content = ADD_ME_CALL_BUSY;
3047 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
3048 /* clear call ID */
3049 psaCC_retMOCTi(psaCC_ctb(cId)->ti);
3050 psaCC_chngCalTypCnt(cId, -1);
3051 psaCC_FreeCtbNtry (cId);
3052
3053 TRACE_EVENT("cmhSAT_ChckCmdDet(): CALL_BUSY, RSLT_ME_UNAB_PROC");
3054 return( FALSE );
3055 }
3056 break;
3057
3058 case( QLF_CALL_HOLD ):
3059 case( QLF_CALL_HOLD_RDL ):
3060
3061 if( ( hldId NEQ NO_ENTRY AND actId NEQ NO_ENTRY ) OR
3062 ( actId NEQ NO_ENTRY AND
3063 psaCC_ctb(actId)->prio EQ PRIO_NORM_CALL AND
3064 cmhCC_getcalltype(actId) NEQ VOICE_CALL ) )
3065 {
3066 psaSAT_SendTrmResp( RSLT_ME_CAP, &resp_data );
3067 TRACE_EVENT("cmhSAT_ChckCmdDet(): RSLT_ME_CAP");
3068 return( FALSE );
3069 }
3070 break;
3071
3072 case( QLF_CALL_DISC ):
3073 case( QLF_CALL_DISC_RDL ):
3074
3075 break;
3076 }
3077
3078 return( TRUE );
3079 }
3080
3081 /*
3082 +-------------------------------------------------------------------+
3083 | PROJECT : GSM-PS (6147) MODULE : SAT |
3084 | ROUTINE : cmhSAT_fillSetupBC |
3085 +-------------------------------------------------------------------+
3086
3087 PURPOSE : This function fills the call table bentry with the
3088 necessary bearer service setup parameters.
3089
3090 */
3091
3092 GLOBAL void cmhSAT_fillSetupBC ( SHORT cId,
3093 UBYTE bearer_serv_1,
3094 UBYTE bearer_serv_2 )
3095 {
3096 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[cId];
3097
3098 TRACE_FUNCTION ("cmhSAT_fillSetupBC()");
3099
3100 /*
3101 *-----------------------------------------------------------------
3102 * bearer service
3103 *-----------------------------------------------------------------
3104 */
3105 if ( bearer_serv_1 EQ BEARER_SERV_NOT_PRES )
3106 {
3107 ctb->BC[0].rate = UR_NOT_PRES;
3108 ctb->BC[0].bearer_serv = BEARER_SERV_SPEECH;
3109 ctb->BC[0].conn_elem = CONN_ELEM_NOT_PRES;
3110 }
3111 else
3112 {
3113 ctb->BC[0].rate = UR_NOT_PRES;
3114 ctb->BC[0].bearer_serv = (bearer_serv_1 EQ BEARER_SERV_SPEECH) ?
3115 cmhCC_set_speech_serv (&cmhPrm[CMD_SRC_LCL].ccCmdPrm) : bearer_serv_1;
3116 ctb->BC[0].conn_elem = CONN_ELEM_NOT_PRES;
3117 }
3118 if ( bearer_serv_2 EQ BEARER_SERV_NOT_PRES )
3119 {
3120 ctb->BC[1].rate = UR_NOT_PRES;
3121 ctb->BC[1].bearer_serv = BEARER_SERV_NOT_PRES;
3122 ctb->BC[1].conn_elem = CONN_ELEM_NOT_PRES;
3123 }
3124 else
3125 {
3126 ctb->BC[1].rate = UR_NOT_PRES;
3127 ctb->BC[1].bearer_serv = (bearer_serv_2 EQ BEARER_SERV_SPEECH) ?
3128 cmhCC_set_speech_serv (&cmhPrm[CMD_SRC_LCL].ccCmdPrm) : bearer_serv_2;
3129 ctb->BC[1].conn_elem = CONN_ELEM_NOT_PRES;
3130 }
3131 }
3132
3133
3134 /*
3135 +-------------------------------------------------------------------+
3136 | PROJECT : GSM-PS (6147) MODULE : SAT |
3137 | ROUTINE : cmhSAT_convertBCDNum |
3138 +-------------------------------------------------------------------+
3139
3140 PURPOSE : This function converts the BCD number to an ascii char
3141 string
3142
3143 */
3144 LOCAL void cmhSAT_convertBCDNum(U8 *bcdNum, U16 len, CHAR *bcdChar)
3145 {
3146 int i;
3147
3148 TRACE_FUNCTION("cmhSAT_convertBCDNum");
3149
3150 memset(bcdChar, 0, MAX_PARTY_NUM_SAT);
3151
3152 for ( i=0; i < len; i++)
3153 {
3154 bcdChar[i] = bcdNum[i] + '0';
3155 }
3156
3157 }
3158
3159 /*
3160 +-------------------------------------------------------------------+
3161 | PROJECT : GSM-PS (6147) MODULE : SAT |
3162 | ROUTINE : cmhSAT_fillSetupPrm |
3163 +-------------------------------------------------------------------+
3164
3165 PURPOSE : This function fills the call table entry with the
3166 necessary SAT setup parameters.
3167
3168 */
3169
3170 GLOBAL void cmhSAT_fillSetupPrm ( SHORT cId,
3171 T_addr *adr,
3172 T_subaddr *sub )
3173 {
3174 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[cId];
3175 UBYTE i;
3176 USHORT dummy=0, length;
3177 CHAR *buf_4_dtmf;
3178 BOOL end_of_dial_string = FALSE;
3179 CHAR *number_buffer;
3180
3181 TRACE_FUNCTION ("cmhSAT_fillSetupPrm()");
3182
3183 ACI_MALLOC(number_buffer, MAX_PARTY_NUM_SAT);
3184 ACI_MALLOC(buf_4_dtmf, MAX_CC_CALLED_NUMBER+1);
3185
3186 /* called address */
3187 if( adr NEQ NULL )
3188 {
3189 /* check for emergency call code 112 */
3190 if( adr -> c_bcdDigit > 0 AND
3191 adr -> bcdDigit[adr -> c_bcdDigit-1] EQ 0x0f )
3192 {
3193 adr -> c_bcdDigit -= 1;
3194 }
3195
3196 cmhSAT_convertBCDNum(adr->bcdDigit, adr->c_bcdDigit, number_buffer);
3197
3198 /* Only use 112 as an Emmergency Call on STK */
3199 if (!strcmp(number_buffer,"112"))
3200 {
3201 ctb->prio = PRIO_EMERG_CALL;
3202 TRACE_EVENT("EMERGENCY CALL");
3203 }
3204 else
3205 ctb->prio = PRIO_NORM_CALL;
3206
3207 /* Check for DTMF tones within dial string */
3208 length = MINIMUM(adr->c_bcdDigit, MAX_CC_CALLED_NUMBER);
3209 for(i=0; i<length; i++)
3210 {
3211 /* convert address: PHB compliant */
3212 buf_4_dtmf[i] = cmhPHB_convertBCD2char( adr->bcdDigit[i] );
3213 if(buf_4_dtmf[i] EQ PHB_DTMF_SEP)
3214 {
3215 /* DTMF separator */
3216 if(!end_of_dial_string)
3217 {
3218 adr-> c_bcdDigit = i; /* split number from DTMF tones */
3219 end_of_dial_string = TRUE;
3220 }
3221 }
3222 }
3223
3224 buf_4_dtmf[length] = '\0';
3225 cmhCC_chkDTMFDig ( buf_4_dtmf, cId, dummy, TRUE );
3226
3227 /* set address */
3228 ctb->cldPty.ton = adr -> noa;
3229 ctb->cldPty.npi = adr -> npi;
3230
3231 ctb->cldPty.c_called_num = MINIMUM( MAX_SMS_ADDR_DIG, adr -> c_bcdDigit ); /* why MAX_SMS_ADDR_DIG ??? */
3232 if (ctb->cldPty.called_num NEQ NULL)
3233 {
3234 ACI_MFREE (ctb->cldPty.called_num);
3235 ctb->cldPty.called_num = NULL;
3236 }
3237 if (ctb->cldPty.c_called_num NEQ 0)
3238 {
3239 ACI_MALLOC (ctb->cldPty.called_num, ctb->cldPty.c_called_num);
3240 memcpy( ctb->cldPty.called_num,
3241 adr -> bcdDigit,
3242 ctb->cldPty.c_called_num );
3243 }
3244
3245 psaCC_phbSrchNum( cId, CT_MOC ); /* get alpha identifier */
3246
3247 }
3248
3249 /*
3250 *-----------------------------------------------------------------
3251 * called subaddress
3252 *-----------------------------------------------------------------
3253 */
3254 if( sub NEQ NULL )
3255 {
3256 if( sub -> c_bcdDigit > 0 AND
3257 sub -> bcdDigit[sub -> c_bcdDigit-1] EQ 0x0f )
3258
3259 sub -> c_bcdDigit -= 1;
3260
3261 ctb->cldPtySub.c_subaddr =
3262 MINIMUM( SUB_LENGTH, sub -> c_bcdDigit );
3263
3264 memcpy( ctb->cldPtySub.subaddr, sub -> bcdDigit,
3265 ctb->cldPtySub.c_subaddr );
3266
3267 ctb->cldPtySub.tos = sub -> tos;
3268
3269 ctb->cldPtySub.odd_even = sub -> oei;
3270 }
3271 else /* subaddress not found */
3272 {
3273 ctb->cldPtySub.tos = TOS_NOT_PRES;
3274 ctb->cldPtySub.odd_even = OE_EVEN;
3275 ctb->cldPtySub.c_subaddr = 0;
3276 }
3277
3278 /*
3279 *-----------------------------------------------------------------
3280 * clir
3281 *-----------------------------------------------------------------
3282 */
3283 ctb->CLIRsup = NOT_PRESENT_8BIT;
3284 ctb->rptInd = RI_NOT_PRES;
3285
3286 ACI_MFREE(number_buffer);
3287 ACI_MFREE(buf_4_dtmf);
3288 }
3289
3290 /*
3291 +-------------------------------------------------------------------+
3292 | PROJECT : GSM-PS (6147) MODULE : SAT |
3293 | ROUTINE : cmhSAT_chkDTMF |
3294 +-------------------------------------------------------------------+
3295
3296 PURPOSE : This function extracs DTMF digit from the dial string and
3297 store them in a buffer.
3298 */
3299 #if 0
3300 GLOBAL void cmhSAT_chkDTMF ( SHORT cId, T_addr* adr )
3301 {
3302 UBYTE cnt = 0;
3303 UBYTE dtmf = 0;
3304 USHORT len = adr->c_bcdDigit;
3305
3306 /* reset dtmf parameters */
3307 satDtmfBuf.cId = -1;
3308 satDtmfBuf.cnt = 0;
3309 satDtmfBuf.cur = 0;
3310
3311 /* search first occurrence of dtmf digit */
3312 while( adr->bcdDigit[cnt] NEQ 0x0C AND cnt < len ) cnt++;
3313
3314 /* if none return */
3315 if( cnt EQ adr->c_bcdDigit ) return;
3316
3317 /* adjust num digit count */
3318 adr->c_bcdDigit = cnt;
3319
3320 /* convert to IA5 */
3321 while( cnt < len AND dtmf < MAX_DTMF_DIG )
3322 {
3323 satDtmfBuf.dig[dtmf] = cmhPHB_convertBCD2char( adr->bcdDigit[cnt] );
3324
3325 cnt++;
3326 if( satDtmfBuf.dig[dtmf] NEQ '\0' )
3327 {
3328 dtmf++; /* else erase it: that was an invalid parameter */
3329 }
3330 }
3331
3332 /* update dtmf parameter */
3333 satDtmfBuf.cnt = dtmf+1;
3334 satDtmfBuf.cur = 0;
3335 satDtmfBuf.cId = cId;
3336 }
3337 #endif /* 0 */
3338 /*
3339 +-------------------------------------------------------------------+
3340 | PROJECT : GSM-PS (6147) MODULE : SAT |
3341 | ROUTINE : cmhSAT_ResCapCode |
3342 +-------------------------------------------------------------------+
3343
3344 PURPOSE : This function proceeds after the reception of a capability
3345 configuration parameter coding.
3346 */
3347
3348 GLOBAL void cmhSAT_ResCapCode ( USHORT cause, T_bcconf* bc )
3349 {
3350 SHORT cId; /* holds call id */
3351 UBYTE cmdBuf; /* buffers command */
3352 UBYTE srcBuf; /* buffers command source */
3353
3354 cId = satShrdPrm.capParm.cId;
3355
3356 if (!psaCC_ctbIsValid (cId))
3357 {
3358 TRACE_ERROR ("Call table entry disappeared");
3359 return;
3360 }
3361
3362 switch( cause )
3363 {
3364 case( MNCC_CAUSE_SUCCESS ):
3365
3366 /*
3367 *-------------------------------------------------------------------
3368 * build envelope call control command
3369 *-------------------------------------------------------------------
3370 */
3371 CCD_START;
3372 psaSAT_BuildEnvCC ( cId, NULL, NULL, bc );
3373
3374 satShrdPrm.SIMCCParm.cId = cId;
3375 satShrdPrm.SIMCCParm.ccAct = CC_ACT_CAL;
3376 satShrdPrm.SIMCCParm.owner = psaCC_ctb(cId)->calOwn;
3377 satShrdPrm.SIMCCParm.busy = TRUE;
3378
3379 satShrdPrm.owner = NO_VLD_OWN;
3380
3381 psaSAT_STKEnvelope (NULL);
3382
3383 CCD_END;
3384 break;
3385
3386 case( MNCC_CAUSE_MS_INCOMPAT_DEST ):
3387 default:
3388
3389 /*
3390 *-------------------------------------------------------------------
3391 * inform MMI about unsuccessful call setup
3392 *-------------------------------------------------------------------
3393 */
3394 /* at the moment only user caps need to be coded */
3395 cmhCC_PrepareCmdEnd (cId, &cmdBuf, &srcBuf);
3396 psaCC_FreeCtbNtry (cId);
3397
3398 R_AT( RAT_CME, srcBuf ) ( cmdBuf, CME_ERR_NotPresent );
3399
3400 /* log result */
3401 cmh_logRslt ( srcBuf, RAT_CME, cmdBuf,
3402 -1, -1, CME_ERR_NotPresent );
3403 break;
3404 }
3405 }
3406
3407 /*
3408 +-------------------------------------------------------------------+
3409 | PROJECT : GSM-PS (6147) MODULE : SAT |
3410 | ROUTINE : cmhSAT_ResCapDecode |
3411 +-------------------------------------------------------------------+
3412
3413 PURPOSE : This function proceeds after the reception of a capability
3414 configuration parameter decoding.
3415 */
3416
3417 GLOBAL void cmhSAT_ResCapDecode ( USHORT cause, T_bcpara* bc )
3418 {
3419 T_CC_CALL_TBL *ctb; /* Pointer to call table */
3420 unsigned bci; /* Bearer capability index */
3421 SHORT cId; /* holds call id */
3422 UBYTE ownNotSAT; /* flags that the owner is not SAT */
3423 UBYTE cmdBuf; /* buffers command */
3424 UBYTE srcBuf; /* buffers command */
3425 UBYTE idx; /* holds index */
3426 T_ACI_RETURN retVal; /* holds return value */
3427 T_ACI_SAT_TERM_RESP resp_data;
3428 #ifdef FF_SAT_E
3429 T_ACI_SATA_ADD addPrm;
3430 #endif /* FF_SAT_E */
3431
3432 cId = satShrdPrm.capParm.cId;
3433
3434 if (!psaCC_ctbIsValid (cId))
3435 {
3436 TRACE_ERROR ("Call table entry disappeared");
3437 return;
3438 }
3439
3440 ctb = ccShrdPrm.ctb[cId];
3441
3442 psaSAT_InitTrmResp( &resp_data );
3443
3444 ownNotSAT = ctb->calOwn NEQ OWN_SAT;
3445
3446 switch( cause )
3447 {
3448 case( MNCC_CAUSE_SUCCESS ):
3449
3450 if( ownNotSAT )
3451 {
3452 for (bci = 0; bci < 2; bci++)
3453 {
3454 if (ctb->BC[bci].bearer_serv NEQ BEARER_SERV_NOT_PRES AND
3455 ctb->BC[bci].bearer_serv NEQ BEARER_SERV_SPEECH AND
3456 ctb->BC[bci].bearer_serv NEQ BEARER_SERV_AUX_SPEECH )
3457 {
3458 ctb->BC[bci] = *bc;
3459 }
3460 }
3461 }
3462 else
3463 {
3464 ctb->BC[0] = *bc;
3465 }
3466
3467 /* check capability context */
3468 switch( satShrdPrm.capParm.cntxt )
3469 {
3470 case( CTX_SAT_SETUP ):
3471
3472 /* check for call control by SIM */
3473 retVal = cmhSAT_CalCntrlBySIM( cId );
3474
3475 switch( retVal )
3476 {
3477 case( AT_EXCT ):
3478 break;
3479
3480 case( AT_BUSY ):
3481 /* respond with "Interaction with call control by SIM, temporary" */
3482 psaSAT_SendTrmResp( RSLT_CC_SIM_TMP, &resp_data );
3483 psaCC_FreeCtbNtry (cId);
3484 break;
3485
3486 case( AT_FAIL ):
3487 /* respond with "Interaction with call control by SIM, permanent" */
3488 resp_data.add_content = ADD_NO_CAUSE;
3489 psaSAT_SendTrmResp( RSLT_CC_SIM_PRM, &resp_data );
3490 psaCC_FreeCtbNtry (cId);
3491 break;
3492 }
3493
3494 /* alert user if command details are supported */
3495 if( cmhSAT_ChckCmdDet() )
3496 {
3497 for( idx = 0; idx < CMD_SRC_MAX; idx++ )
3498 {
3499 #ifdef FF_SAT_E
3500 addPrm.chnType = SATA_CT_VOICE;
3501 addPrm.chnEst = SATA_EST_IM;
3502
3503 R_AT( RAT_SATA, idx )( cId+1, satShrdPrm.dur, &addPrm );
3504 #else /* FF_SAT_E */
3505 R_AT( RAT_SATA, idx )( cId+1, satShrdPrm.dur);
3506 #endif /* FF_SAT_E */
3507 }
3508 }
3509 else
3510
3511 psaCC_FreeCtbNtry (cId);
3512
3513 break;
3514
3515 case( CTX_CC_RESULT ):
3516
3517 cmhSAT_SetupCalAfterCCRes ( ownNotSAT, cId, satShrdPrm.capParm.CCres );
3518 break;
3519 }
3520 break;
3521
3522 case( MNCC_CAUSE_MS_INCOMPAT_DEST ):
3523 default:
3524
3525 /*
3526 *-------------------------------------------------------------------
3527 * inform about unsuccessful call setup
3528 *-------------------------------------------------------------------
3529 */
3530 /* setup initiated by user */
3531 if( ownNotSAT )
3532 {
3533 cmhCC_PrepareCmdEnd (cId, &cmdBuf, &srcBuf);
3534 psaCC_FreeCtbNtry (cId);
3535
3536 R_AT( RAT_CME, srcBuf ) ( cmdBuf, CME_ERR_NotPresent );
3537
3538 /* log result */
3539 cmh_logRslt ( srcBuf, RAT_CME, cmdBuf,
3540 -1, -1, CME_ERR_NotPresent );
3541 }
3542 /* setup initiated by SAT */
3543 else
3544 {
3545 /* send SAT response */
3546 resp_data.resCC = (satShrdPrm.capParm.cntxt EQ CTX_CC_RESULT)?
3547 &satShrdPrm.capParm.CCres: NULL;
3548
3549 psaSAT_SendTrmResp( RSLT_ME_CAP, &resp_data );
3550 }
3551 break;
3552 }
3553 }
3554
3555 /*
3556 +-------------------------------------------------------------------+
3557 | PROJECT : GSM-PS (6147) MODULE : SAT |
3558 | ROUTINE : cmhSAT_SetupCalAfterCCRes|
3559 +-------------------------------------------------------------------+
3560
3561 PURPOSE : This function proceeds with call setup after call control
3562 by SIM result.
3563 */
3564
3565 GLOBAL BOOL cmhSAT_SetupCalAfterCCRes ( UBYTE ownNotSAT, SHORT cId,
3566 UBYTE CCres)
3567 {
3568 SHORT actId; /* holds active call id */
3569 UBYTE cmdBuf; /* buffers command */
3570 UBYTE srcBuf; /* buffers command source */
3571 UBYTE idx; /* holds list index */
3572 T_ACI_SAT_TERM_RESP resp_data;
3573 #ifdef FF_SAT_E
3574 T_ACI_SATA_ADD addPrm;
3575 #endif /* FF_SAT_E */
3576
3577 psaSAT_InitTrmResp( &resp_data );
3578
3579 /*
3580 *------------------------------------------------------------
3581 * perform call setup initiated by user
3582 *------------------------------------------------------------
3583 */
3584 if( ownNotSAT )
3585 {
3586 /* check for an active call */
3587 actId = psaCC_ctbFindCall( NO_VLD_OWN, CS_ACT, NO_VLD_CT );
3588
3589 if( actId NEQ NO_ENTRY )
3590 {
3591 /* put active on hold if possible */
3592 if( psaCC_ctb(actId)->prio EQ PRIO_NORM_CALL AND
3593 cmhCC_getcalltype(cId) EQ VOICE_CALL )
3594 {
3595 cmhCC_HoldCall(actId, psaCC_ctb(cId)->curSrc, AT_CMD_D);
3596 }
3597 /* reject call setup */
3598 else
3599 {
3600 cmhCC_PrepareCmdEnd (cId, &cmdBuf, &srcBuf);;
3601 psaCC_FreeCtbNtry (cId);
3602
3603 R_AT( RAT_CME, srcBuf ) ( cmdBuf, CME_ERR_NotPresent );
3604
3605 /* log result */
3606 cmh_logRslt ( srcBuf, RAT_CME, cmdBuf,
3607 -1, -1, CME_ERR_NotPresent );
3608 return( FALSE );
3609 }
3610 }
3611
3612 /* finally set up call */
3613 cmhCC_flagCall( cId,
3614 &(cmhPrm[psaCC_ctb(cId)->calOwn].ccCmdPrm.mltyCncFlg));
3615
3616 psaCC_NewCall(cId);
3617
3618 return( FALSE );
3619 }
3620
3621 /*
3622 *------------------------------------------------------------
3623 * perform call setup initiated by SAT
3624 *------------------------------------------------------------
3625 */
3626 else
3627 {
3628 /* alert user if command details are supported */
3629 if( cmhSAT_ChckCmdDet() )
3630 {
3631 /* check aoc condition */
3632 if ((psaCC_ctb(cId)->prio EQ PRIO_NORM_CALL) AND
3633 (aoc_check_moc() EQ FALSE))
3634 /*
3635 * check ACM exceeds ACMmax
3636 * for non-emergency calls
3637 */
3638 {
3639 resp_data.add_content = ADD_NO_CAUSE;
3640 resp_data.resCC = (CCres EQ CCR_ALLW_WITH_MDFY)? &CCres: NULL;
3641
3642 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data);
3643 psaCC_FreeCtbNtry (cId);
3644 return( FALSE );
3645 }
3646
3647 for( idx = 0; idx < CMD_SRC_MAX; idx++ )
3648 {
3649 #ifdef FF_SAT_E
3650 addPrm.chnType = SATA_CT_VOICE;
3651 addPrm.chnEst = SATA_EST_IM;
3652
3653 R_AT( RAT_SATA, idx )( cId+1, satShrdPrm.dur, &addPrm );
3654 #else /* FF_SAT_E */
3655 R_AT( RAT_SATA, idx )( cId+1, satShrdPrm.dur );
3656 #endif /* FF_SAT_E */
3657 }
3658
3659 satShrdPrm.ntfy = USR_NTF_SETUP_CAL;
3660
3661 return( TRUE );
3662 }
3663 return( FALSE);
3664 }
3665 }
3666
3667 /*
3668 +-------------------------------------------------------------------+
3669 | PROJECT : GSM-PS (6147) MODULE : SAT |
3670 | ROUTINE : cmhSAT_sendSM |
3671 +-------------------------------------------------------------------+
3672
3673 PURPOSE : This function sends a Short Message requested by SAT.
3674 If the request is going to be processed, the function
3675 returns TRUE.
3676
3677 */
3678
3679 GLOBAL BOOL cmhSAT_sendSM ( T_SEND_SM * sm )
3680 {
3681 T_ACI_RETURN retVal; /* holds return value */
3682 UBYTE fo, mn;
3683 USHORT oct_nr;
3684
3685 USHORT sca_addr_len; /* length of service center address */
3686 T_SMS_SET_PRM * pSMSSetPrm; /* points to SMS parameter set */
3687 T_ACI_SM_DATA pdu;
3688
3689 UBYTE packed_data[MAX_SM_LEN];
3690 UBYTE header_len;
3691 UBYTE dcs, *p_dcs;
3692 UBYTE udl, *p_udl;
3693 UBYTE oct_udl;
3694
3695 UBYTE *sm_cont; /* pointer to the current position in the pdu */
3696 T_ACI_SAT_TERM_RESP resp_data;
3697
3698 TRACE_FUNCTION("cmhSAT_sendSM()");
3699
3700 psaSAT_InitTrmResp( &resp_data );
3701 pdu.len = 0;
3702
3703 pSMSSetPrm = smsShrdPrm.pSetPrm[OWN_SAT];
3704
3705 /*
3706 *-------------------------------------------------------------------
3707 * check presence of SMS TPDU
3708 *-------------------------------------------------------------------
3709 */
3710 if (!sm->v_smpdu)
3711 {
3712 /* respond with "error, required values are missing" */
3713 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
3714 return( FALSE );
3715 }
3716 /*
3717 *-------------------------------------------------------------------
3718 * get SCA
3719 *-------------------------------------------------------------------
3720 */
3721 if (sm->v_addr AND sm->addr.c_bcdDigit > 0)
3722 {
3723 if (sm->addr.c_bcdDigit >= MAX_SMS_NUM_LEN)
3724 {
3725 TRACE_EVENT("cmhSAT_sendSM: ERROR SMSC address to long");
3726 /* SCA number too long */
3727 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
3728 return( FALSE );
3729 }
3730
3731 /* copy the sca into the pdu */
3732 sca_addr_len = CodeRPAddress(pdu.data,
3733 (UBYTE)sm->addr.c_bcdDigit,
3734 sm->addr.noa,
3735 sm->addr.npi,
3736 sm->addr.bcdDigit);
3737
3738 }
3739 else
3740 {
3741 /* ACI-SPR-16431: changes */
3742 if ( psaSIM_ChkSIMSrvSup( SRV_SMS_Parms ) ) /* verify that SMSP is provided */
3743 {
3744 if ( pSMSSetPrm -> sca.c_num > 0 ) /* verify that SMSP contains address */
3745 {
3746 /* ready to copy the sca into the pdu */
3747 sca_addr_len = CodeRPAddress(pdu.data,
3748 pSMSSetPrm -> sca.c_num,
3749 pSMSSetPrm -> sca.ton,
3750 pSMSSetPrm -> sca.npi,
3751 pSMSSetPrm -> sca.num);
3752 }
3753 else
3754 {
3755 /* ERROR: SMSP address EMPTY */
3756 TRACE_EVENT("cmhSAT_sendSM: ERROR: SMSP address EMPTY");
3757 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data ); /* TR(20) */
3758 return( FALSE );
3759 }
3760 }
3761 else
3762 {
3763 /* ERROR: SMSP NOT available */
3764 TRACE_EVENT("cmhSAT_sendSM: ERROR: SMSP NOT available");
3765 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data ); /* TR(20) */
3766 return( FALSE );
3767 }
3768 }
3769
3770 /*
3771 *-------------------------------------------------------------------
3772 * check and evaluate SMS TPDU
3773 *-------------------------------------------------------------------
3774 */
3775 if (sm->smpdu.c_tpdu_data > 0)
3776 {
3777 fo = sm->smpdu.tpdu_data[0]; /* first octet with Message Type */
3778 switch (fo & TP_MTI_MASK)
3779 {
3780 case TP_MTI_SMS_SUBMIT:
3781 if (sm->smpdu.c_tpdu_data < 7)
3782 {
3783 /* not the minimum length for TP-SUBMIT */
3784 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
3785 return( FALSE );
3786 }
3787 if (sm->smpdu.tpdu_data[2] >= MAX_SMS_NUM_LEN)
3788 {
3789 /* destination number too long */
3790 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
3791 return( FALSE );
3792 }
3793
3794 /* oct_nr is the number of bytes in address value */
3795 oct_nr = (USHORT)((sm->smpdu.tpdu_data[2] + 1) / 2);
3796 if ((oct_nr + 7) > (USHORT)sm->smpdu.c_tpdu_data)
3797 {
3798 /* number length inconsistent with overall length for TP-SUBMIT */
3799 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
3800 return( FALSE );
3801 }
3802
3803 /* sm_cont points now to TP-DCS */
3804 sm_cont = &sm->smpdu.tpdu_data[4 + oct_nr + 1];
3805 p_dcs = &pdu.data[sca_addr_len+4 + oct_nr + 1];
3806
3807 /* sm_cont points now to TP-VP */
3808 dcs = *sm_cont++;
3809
3810
3811 switch (fo & TP_VPF_MASK)
3812 {
3813 case TP_VPF_NOT_PRESENT:
3814 default:
3815 /* oct_nr is length of TP-UD */
3816 oct_nr = (USHORT)sm->smpdu.c_tpdu_data - oct_nr - 7;
3817 break;
3818
3819 case TP_VPF_RELATIVE:
3820 if ((oct_nr + 8) > (USHORT)sm->smpdu.c_tpdu_data)
3821 {
3822 /* not the required length for TP-SUBMIT with VP-RELATIVE */
3823 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
3824 return( FALSE );
3825 }
3826 /* sm_cont points now to TP-UDL */
3827 sm_cont++;
3828
3829 /* oct_nr is length of TP-UD */
3830 oct_nr = (USHORT)sm->smpdu.c_tpdu_data - oct_nr - 8;
3831 break;
3832
3833 case TP_VPF_ABSOLUTE:
3834 case TP_VPF_ENHANCED: /* treat as VP-ABSOLUTE */
3835 if ((oct_nr + 14) > (USHORT)sm->smpdu.c_tpdu_data)
3836 {
3837 /* not the required length for TP-SUBMIT with VP-ABSOLUTE */
3838 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
3839 return( FALSE );
3840 }
3841
3842 /* sm_cont points now to TP-UDL */
3843 sm_cont += 7;
3844
3845 /* oct_nr is length of TP-UD */
3846 oct_nr = (USHORT)sm->smpdu.c_tpdu_data - oct_nr - 14;
3847 break;
3848 }
3849
3850
3851 header_len = sm->smpdu.c_tpdu_data - oct_nr;
3852 p_udl = &pdu.data[sca_addr_len + header_len - 1];
3853
3854
3855 switch (cmhSMS_getAlphabetPp (dcs))
3856 {
3857 default: /* 7 bit default aphabet */
3858 if (*sm_cont > 160)
3859 {
3860 /* SM length inconsistent */
3861 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
3862 return( FALSE );
3863 }
3864 #ifdef _PACK_DEF_ALPHA
3865 /* packing required */
3866 if (satShrdPrm.cmdDet.cmdQlf EQ QLF_SMS_PACK AND
3867 (USHORT)*sm_cont EQ oct_nr) /* check if packing is valid at all
3868 (so *sm_cont must be equal of remaining bytes)
3869 otherwise do not repack the data since it seems that
3870 data has already been packed.
3871 This is CQ18268/MOBil57469 */
3872 {
3873 /* length in septets, sm_cont points now to TP-UD */
3874 udl = *sm_cont++;
3875
3876 /* oct_udl is the length of packed data in octets */
3877 oct_udl = utl_cvt8To7 (sm_cont, udl, packed_data, 0);
3878
3879 /* copy the header into the pdu */
3880 memcpy(&pdu.data[sca_addr_len], sm->smpdu.tpdu_data,
3881 header_len);
3882
3883 /* copy the packed user data into the pdu */
3884 memcpy (&pdu.data[sca_addr_len+header_len], packed_data, oct_udl);
3885
3886 pdu.len = sca_addr_len+header_len+oct_udl;
3887
3888 retVal = sAT_PlusCMGSPdu (OWN_SAT, &pdu);
3889 switch (retVal)
3890 {
3891 case AT_CMPL:
3892 psaSAT_SendTrmResp( RSLT_PERF_SUCCESS, &resp_data );
3893 return TRUE;
3894
3895 case AT_BUSY:
3896 mn = ADD_NO_CAUSE;
3897 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
3898 return( FALSE );
3899
3900 case AT_FAIL:
3901 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
3902 return( FALSE );
3903 }
3904 return TRUE;
3905 } /* if (satShrdPrm.cmdDet.cmdQlf EQ QLF_SMS_PACK) */
3906 else
3907 #endif /* _PACK_DEF_ALPHA: ignore PACKING REQUIRED for GSM default
3908 alphabet, when not set */
3909 {
3910 /* packing not required */
3911 udl = *sm_cont;
3912 oct_udl = ((*sm_cont + 1)*7)/8;
3913 }
3914 break;
3915
3916
3917 case 1: /* 8 bit data */
3918 if (satShrdPrm.cmdDet.cmdQlf EQ QLF_SMS_PACK
3919 AND ((dcs & 0xE0) NEQ 0x20))
3920 { /* packing only, when text is uncompressed */
3921 if ((USHORT)*sm_cont > oct_nr OR *sm_cont > 160)
3922 {
3923 /* SM length inconsistent */
3924 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
3925 return( FALSE );
3926 }
3927 if ((dcs & 0xC0) EQ 0)
3928 dcs &= 0xF3; /* adjust coding group 00xx */
3929 else if ((dcs & 0xF0) EQ 0xF0)
3930 dcs &= 0xFB; /* adjust coding group 1111 */
3931
3932 /* length in septets, sm_cont points now to TP-UD */
3933 udl = *sm_cont++;
3934
3935 /* oct_udl is the length of packed data in octets */
3936 oct_udl = utl_cvt8To7 (sm_cont, udl, packed_data, 0);
3937
3938 /* copy the header into the pdu */
3939 memcpy(&pdu.data[sca_addr_len], sm->smpdu.tpdu_data,
3940 header_len);
3941
3942 /* copy the dcs into the pdu */
3943 *p_dcs = dcs;
3944
3945 /* copy the packed user data into the pdu */
3946 memcpy (&pdu.data[sca_addr_len+header_len], packed_data, oct_udl);
3947
3948 pdu.len = sca_addr_len+header_len+oct_udl;
3949
3950 retVal = sAT_PlusCMGSPdu (OWN_SAT, &pdu);
3951 switch (retVal)
3952 {
3953 case AT_CMPL:
3954 psaSAT_SendTrmResp( RSLT_PERF_SUCCESS, &resp_data );
3955 return TRUE;
3956
3957 case AT_BUSY:
3958 mn = ADD_NO_CAUSE;
3959 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
3960 return( FALSE );
3961
3962 case AT_FAIL:
3963 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
3964 return( FALSE );
3965 }
3966 return TRUE;
3967 }
3968 /* sandip CQ - 18269
3969 * To take care of a case where Command qualifier == 0x00( packing not required )
3970 * DCS == 0x04( 8 -bit packing )
3971 * TPDU length >140
3972 */
3973
3974 /*
3975 else if((satShrdPrm.cmdDet.cmdQlf EQ QLF_SMS_NO_PACK) && (oct_nr > 140))
3976 {
3977 psaSAT_SendTrmResp(RSLT_UNKN_DATA,&resp_data);
3978 return(FALSE);
3979 }*/
3980 else
3981 {
3982 if(oct_nr > 140)
3983 {
3984 psaSAT_SendTrmResp(RSLT_UNKN_DATA,&resp_data);
3985 return(FALSE);
3986 }
3987 /* packing not required */
3988 udl = *sm_cont;
3989 oct_udl = *sm_cont;
3990 }
3991 break;
3992
3993 case 2: /* UCS2 */
3994 /*
3995 * Special consideration: are octets (incorrect) or UCS2
3996 * characters (correct) counted by SAT?
3997 */
3998 if ((USHORT)*sm_cont EQ oct_nr)
3999 oct_udl = *sm_cont++; /* assume octet count */
4000 else
4001 oct_udl= *sm_cont++ * 2; /* assume character count */
4002 udl = oct_udl;
4003 break;
4004 } /* switch (cmhSMS_getAlphabetPp (dcs)) */
4005
4006
4007 if ((USHORT)oct_udl > oct_nr OR oct_udl > MAX_SM_LEN)
4008 {
4009 /* SM length inconsistent */
4010 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
4011 return( FALSE );
4012 }
4013
4014 /* copy the tpdu data into the pdu */
4015 memcpy(&pdu.data[sca_addr_len], sm->smpdu.tpdu_data, sm->smpdu.c_tpdu_data);
4016
4017 /* copy the udl into the pdu */
4018 *p_udl = udl;
4019
4020 pdu.len = sca_addr_len + sm->smpdu.c_tpdu_data;
4021
4022 retVal = sAT_PlusCMGSPdu (OWN_SAT, &pdu);
4023 switch (retVal)
4024 {
4025 case AT_CMPL:
4026 psaSAT_SendTrmResp( RSLT_PERF_SUCCESS, &resp_data );
4027 return TRUE;
4028
4029 case AT_BUSY:
4030 mn = ADD_NO_CAUSE;
4031 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
4032 return( FALSE );
4033
4034 case AT_FAIL:
4035 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
4036 return( FALSE );
4037 } /* end switch (retVal) */
4038 return TRUE;
4039
4040
4041 case TP_MTI_SMS_COMMAND:
4042 if (sm->smpdu.c_tpdu_data < 8)
4043 {
4044 /* not the minimum length for TP-COMMAND */
4045 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
4046 return( FALSE );
4047 }
4048 if (sm->smpdu.tpdu_data[5] >= MAX_SMS_NUM_LEN)
4049 {
4050 /* destination number too long */
4051 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
4052 return( FALSE );
4053 }
4054 oct_nr = (USHORT)((sm->smpdu.tpdu_data[5] + 1) / 2);
4055 if ((oct_nr + 8) > (USHORT)sm->smpdu.c_tpdu_data)
4056 {
4057 /* number length inconsistent with overall length for TP-SUBMIT */
4058 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
4059 return( FALSE );
4060 }
4061
4062 /*
4063 ** If the MMI is a Cust1 Application
4064 */
4065 if (simShrdPrm.overall_cust_mode EQ (UBYTE)CUST_MODE_BEHAVIOUR_1)
4066 {
4067 /*
4068 ** Having performed some checks,
4069 ** don't send the primitve, but pass the entire command to the MMI for processing.
4070 ** NOTE: An SMS Command is not passed to the SIM for MO SMS Control By SIM
4071 **
4072 ** Ensure that the SMS parameters are reset, so that the SMS Entity is freed to
4073 ** process the command later.
4074 */
4075 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
4076 smsShrdPrm.smsEntStat.entOwn = smsShrdPrm.owner = CMD_SRC_NONE;
4077
4078 cmhSAT_Cust1StkCmdInd();
4079 return TRUE;
4080 }
4081
4082 memcpy(&pdu.data[sca_addr_len], sm->smpdu.tpdu_data, sm->smpdu.c_tpdu_data);
4083 retVal = sAT_PlusCMGCPdu (OWN_SAT, &pdu);
4084 switch (retVal)
4085 {
4086 case AT_CMPL:
4087 psaSAT_SendTrmResp( RSLT_PERF_SUCCESS, &resp_data );
4088 return TRUE;
4089
4090 case AT_BUSY:
4091 mn = ADD_NO_CAUSE;
4092 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
4093 return( FALSE );
4094
4095 case AT_FAIL:
4096 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
4097 return( FALSE );
4098 }
4099 return TRUE;
4100
4101 default:
4102 /* invalid message type */
4103 psaSAT_SendTrmResp( RSLT_UNKN_DATA, &resp_data );
4104 return( FALSE );
4105 } /* end switch (fo & TP_MTI_MASK) */
4106 }
4107 else /* if (sm->smpdu.c_tpdu_data > 0) */
4108 {
4109 /* respond with "error, required values are missing" */
4110 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
4111 return( FALSE );
4112 }
4113 }
4114
4115 /*
4116 +-------------------------------------------------------------------+
4117 | PROJECT : GSM-PS (6147) MODULE : CMH |
4118 | ROUTINE : cmhSAT_CheckSetEventResp|
4119 +-------------------------------------------------------------------+
4120
4121 PURPOSE : check for an answer to a setup event list. function
4122 returns TRUE if caller has to forward the checked
4123 SAT response
4124 */
4125
4126 GLOBAL BOOL cmhSAT_CheckSetEventResp ( void )
4127 {
4128 BOOL list_in_process;
4129 const UBYTE TermRespSetEventOk [12] =
4130 {
4131 0x81, /* command details tag */
4132 0x03, /* command details length */
4133 0x13, /* command number */
4134 0x05, /* command SETUP EVENT LIST */
4135 0x00, /* not used */
4136 0x82, /* device details tag */
4137 0x02, /* device details length */
4138 0x82, /* source ME */
4139 0x81, /* destination SIM */
4140 0x83, /* result tag */
4141 0x01, /* result length */
4142 0x00 /* result OK */
4143 };
4144 const UBYTE TermRespSetEvent [4] =
4145 {
4146 0x81, /* command details tag */
4147 0x03, /* command details length */
4148 0x13, /* command number */
4149 0x05, /* command SETUP EVENT LIST */
4150 };
4151 UBYTE *p;
4152
4153 T_ACI_SAT_TERM_RESP resp_data;
4154
4155 TRACE_FUNCTION("cmhSAT_CheckSetEventResp");
4156
4157 psaSAT_InitTrmResp( &resp_data );
4158
4159 list_in_process = ( satShrdPrm.event.temp_list & 0x8000 ) > 0L;
4160
4161 if ( list_in_process )
4162 {
4163
4164 p = (satShrdPrm.setPrm[satShrdPrm.owner].stkCmd);
4165
4166 if ((!memcmp((const UBYTE*) p, TermRespSetEvent,2)) AND (p[3] EQ TermRespSetEvent[3])) /* TRUE means: answer to a SETUP EVENT Command */
4167 {
4168 if (!memcmp((const UBYTE*) p+3, TermRespSetEventOk+3, 9)) /* TRUE means: answer ok */
4169 {
4170 cmhSAT_setupEvent_Perform(); /* accept list */
4171 TRACE_EVENT("New Download Event List accepted ");
4172 return TRUE; /* caller has to send/forward TR */
4173 }
4174 else
4175 {
4176 /* MMI couldn't perform the list: ACI doesn't perform it and returns
4177 Beyond Mobile Capabilities */
4178 psaSAT_SendTrmResp( RSLT_ME_CAP, &resp_data );
4179 TRACE_EVENT("New Download Event List refused by MMI");
4180 satShrdPrm.event.temp_list = 0L; /* reinitialize for next setup list */
4181 return FALSE; /* caller hasn't to send TR, already sent! */
4182 }
4183 }
4184 else
4185 {
4186 return TRUE; /* caller has to send/forward TR */
4187 }
4188 }
4189 return TRUE; /* caller has to send/forward TR */
4190 }
4191
4192 /* SAT CLASS E FUNCTIONS START */
4193 #ifdef FF_SAT_E
4194
4195 /*
4196 +-------------------------------------------------------------------+
4197 | PROJECT : GSM-PS (6147) MODULE : SAT |
4198 | ROUTINE : cmhSAT_CloseChannel |
4199 +-------------------------------------------------------------------+
4200
4201 PURPOSE : This function handles the request by SAT to close a
4202 desired channel. If the request is going to be processed,
4203 the function returns TRUE.
4204
4205 */
4206
4207 GLOBAL BOOL cmhSAT_CloseChannel ( void )
4208 {
4209 T_SIM_SAT_CHN chnInf;
4210
4211 TRACE_FUNCTION("cmhSAT_CloseChannel()");
4212
4213 /*
4214 *-------------------------------------------------------------------
4215 * notify about SAT command
4216 *-------------------------------------------------------------------
4217 */
4218 cmhSAT_STKUsrNtfy();
4219
4220 /*
4221 *-------------------------------------------------------------------
4222 * check channel status
4223 *-------------------------------------------------------------------
4224 */
4225 if( satShrdPrm.chnTb.chnUsdFlg )
4226 {
4227 chnInf.bipConn = SIM_BIP_UNKNOWN;
4228 chnInf.dtiConn = SIM_DTI_UNKNOWN;
4229
4230 if( satShrdPrm.chnTb.lnkStat EQ SIM_LINK_OPEN )
4231 {
4232 chnInf.bipConn = SIM_BIP_CLOSE_CHANNEL;
4233
4234 }
4235 if( satShrdPrm.chnTb.lnkStat EQ SIM_LINK_CNCT )
4236 {
4237 chnInf.bipConn = SIM_BIP_CLOSE_CHANNEL;
4238 chnInf.dtiConn = SIM_DTI_DISCONNECT;
4239 }
4240
4241 satShrdPrm.opchStat = OPCH_CLS_REQ;
4242
4243 if( chnInf.bipConn )
4244 {
4245 #ifdef DTI
4246
4247 chnInf.chnId = CHANNEL_ID_1;
4248 chnInf.genRes = RSLT_PERF_SUCCESS;
4249 chnInf.addRes = ADD_NO_CAUSE;
4250
4251 psaSIM_SATBIPChn( chnInf, NULL /*cmhSAT_OpChnClose*/);
4252 #endif /* DTI */
4253 }
4254 else
4255 {
4256 cmhSAT_OpChnClose( SIM_BIP_CLOSE_CHANNEL, 1 );
4257 }
4258 }
4259
4260 return TRUE;
4261 }
4262
4263 /*
4264 +-------------------------------------------------------------------+
4265 | PROJECT : GSM-PS (6147) MODULE : SAT |
4266 | ROUTINE : cmhSAT_SendData |
4267 +-------------------------------------------------------------------+
4268
4269 PURPOSE : This function handles the request by SAT to open a
4270 desired channel immediately. If the request is going to
4271 be processed, the function returns TRUE.
4272
4273 */
4274
4275 GLOBAL BOOL cmhSAT_SendData ( void )
4276 {
4277 TRACE_FUNCTION("cmhSAT_SendData()");
4278
4279 /*
4280 *-------------------------------------------------------------------
4281 * notify about SAT command
4282 *-------------------------------------------------------------------
4283 */
4284 cmhSAT_STKUsrNtfy();
4285
4286 /*
4287 *-------------------------------------------------------------------
4288 * check if on demand channel activation has to be performed
4289 *-------------------------------------------------------------------
4290 */
4291 if( satShrdPrm.opchStat EQ OPCH_ON_DMND AND
4292 satShrdPrm.chnTb.lnkStat EQ SIM_LINK_OPEN AND
4293 satShrdPrm.cmdDet.cmdQlf & QLF_OPCH_IMMDT_LINK_EST )
4294 {
4295 satShrdPrm.opchStat = OPCH_EST_REQ;
4296
4297 /*
4298 *-------------------------------------------------------------------
4299 * for a CSD channel
4300 *-------------------------------------------------------------------
4301 */
4302 if( satShrdPrm.opchType EQ B_CSD )
4303 {
4304 if (!psaCC_ctbIsValid (satShrdPrm.chnTb.chnRefId))
4305 {
4306 TRACE_ERROR ("Call table entry disappeared");
4307 satShrdPrm.chnTb.chnUsdFlg = FALSE;
4308
4309 return ( FALSE );
4310 }
4311
4312 /* check temporary problems */
4313 if( cmhSAT_OpChnChkTmpProblem() )
4314 {
4315 /* remove call table entry */
4316 psaCC_FreeCtbNtry (satShrdPrm.chnTb.chnRefId);
4317 satShrdPrm.chnTb.chnUsdFlg = FALSE;
4318
4319 return( FALSE );
4320 }
4321 #ifdef DTI
4322 #ifdef CO_UDP_IP
4323 if( satShrdPrm.chnTb.chnTPL EQ UDP )
4324 {
4325 /* enable establishment of UDP data chain */
4326 sAT_PercentWAP ( psaCC_ctb(satShrdPrm.chnTb.chnRefId)->curSrc , 1 );
4327
4328 /* setup PPP parameters */
4329 cmhSAT_OpChnSetPPP( satShrdPrm.opchType );
4330 }
4331 #endif /* CO_UDP_IP */
4332 #endif /* DTI */
4333
4334 /* set up call */
4335 cmhPrm[satShrdPrm.opchAcptSrc].ccCmdPrm.mltyCncFlg = 0;
4336
4337 cmhCC_flagCall( satShrdPrm.chnTb.chnRefId, &cmhPrm[satShrdPrm.opchAcptSrc].
4338 ccCmdPrm.mltyCncFlg);
4339 /* ccShrdPrm.ctb[satShrdPrm.chnTb.chnRefId].curCmd = AT_CMD_A; */
4340 /* ccShrdPrm.ctb[satShrdPrm.chnTb.chnRefId].curSrc = satShrdPrm.opchAcptSrc; */
4341 /* psaCC_NewCall ( satShrdPrm.chnTb.chnRefId ); */
4342 cmhCC_NewCall( satShrdPrm.chnTb.chnRefId,
4343 satShrdPrm.opchAcptSrc,
4344 AT_CMD_A);
4345 return( TRUE );
4346 }
4347 /*
4348 *-------------------------------------------------------------------
4349 * for a GPRS channel
4350 *-------------------------------------------------------------------
4351 */
4352 #if defined (GPRS) AND defined (DTI)
4353 else if( satShrdPrm.opchType EQ B_GPRS )
4354 {
4355 SHORT cid_array[2] = { 0,INVALID_CID };
4356 cid_array[0] = satShrdPrm.chnTb.chnRefId;
4357
4358 /* check temporary problems */
4359 if( cmhSAT_OpChnChkTmpProblem() )
4360 {
4361 /* any reset of cid parameters should be placed here,
4362 * if necessary
4363 */
4364 return( FALSE );
4365 }
4366
4367 #ifdef DTI
4368 #ifdef CO_UDP_IP
4369 /* activate the context with UDP */
4370 if( satShrdPrm.chnTb.chnTPL EQ UDP )
4371 {
4372 /* enable establishment of UDP data chain */
4373 sAT_PercentWAP ( satShrdPrm.opchAcptSrc , 1 );
4374
4375 /* setup PPP parameters */
4376 cmhSAT_OpChnSetPPP( B_GPRS );
4377
4378 /* activate context with UDP */
4379 cmhSAT_OpChnUDPActivateGprs();
4380 }
4381 else
4382 #endif /* CO_UDP_IP */
4383 #endif /* DTI */
4384
4385 /* activate context with no transport layer */
4386 if( sAT_PlusCGACT( satShrdPrm.opchAcptSrc, CGACT_STATE_ACTIVATED, cid_array )
4387 NEQ AT_EXCT )
4388
4389 return( FALSE );
4390
4391 satShrdPrm.opchStat = OPCH_EST_REQ;
4392
4393 return( TRUE );
4394 }
4395 #endif /* GPRS */
4396 /*
4397 *-------------------------------------------------------------------
4398 * invalid channel
4399 *-------------------------------------------------------------------
4400 */
4401 else
4402 {
4403 T_ACI_SAT_TERM_RESP resp_data;
4404
4405 TRACE_ERROR("invalid channel found, on demand est. failed");
4406
4407 psaSAT_InitTrmResp( &resp_data );
4408 resp_data.add_content = ADD_NO_CAUSE;
4409
4410 cmhSAT_OpChnFailed( RSLT_ME_UNAB_PROC, &resp_data );
4411
4412 cmhSAT_cleanupOpChnPrms();
4413
4414 }
4415 }
4416
4417 return FALSE;
4418 }
4419
4420 /*
4421 +-------------------------------------------------------------------+
4422 | PROJECT : GSM-PS (6147) MODULE : SAT |
4423 | ROUTINE : cmhSAT_GetChannelStatus |
4424 +-------------------------------------------------------------------+
4425
4426 PURPOSE : This function handles the request by SAT to return the
4427 current status of all channels. If the request is going
4428 to be processed, the function returns TRUE.
4429
4430 */
4431
4432 GLOBAL BOOL cmhSAT_GetChannelStatus ( void )
4433 {
4434 T_ACI_SAT_TERM_RESP resp_data;
4435
4436 psaSAT_InitTrmResp( &resp_data );
4437
4438
4439 TRACE_FUNCTION("cmhSAT_GetChannelStatus()");
4440
4441 /*
4442 *-------------------------------------------------------------------
4443 * notify about SAT command
4444 *-------------------------------------------------------------------
4445 */
4446 cmhSAT_STKUsrNtfy();
4447
4448 /*
4449 *-------------------------------------------------------------------
4450 * return channel status
4451 *-------------------------------------------------------------------
4452 */
4453 resp_data.chnStat = TRUE;
4454
4455 psaSAT_SendTrmResp( RSLT_PERF_SUCCESS, &resp_data );
4456
4457 return FALSE;
4458 }
4459
4460 /*
4461 +-------------------------------------------------------------------+
4462 | PROJECT : GSM-PS (6147) MODULE : SAT |
4463 | ROUTINE : cmhSAT_OpenChannelReq |
4464 +-------------------------------------------------------------------+
4465
4466 PURPOSE : This function handles the request by SAT to open a channel.
4467 If the request is going to be processed, the function
4468 returns TRUE.
4469
4470 */
4471
4472 GLOBAL BOOL cmhSAT_OpenChannelReq ( T_OPEN_CHANNEL *opchCmd )
4473 {
4474 #ifdef FAX_AND_DATA
4475 T_ACI_RETURN retVal; /* holds return value */
4476 #endif /* FAX_AND_DATA */
4477 SHORT cId; /* holds call id / context id */
4478 T_ACI_SAT_TERM_RESP resp_data; /* holds terminal response parms */
4479
4480 psaSAT_InitTrmResp( &resp_data );
4481
4482
4483 TRACE_FUNCTION("cmhSAT_OpenChannelReq()");
4484
4485 /*
4486 *-------------------------------------------------------------------
4487 * check for basic reasons to reject the command
4488 *-------------------------------------------------------------------
4489 */
4490 resp_data.chnStat = TRUE;
4491
4492 /* ME is busy with another open channel command */
4493 if( satShrdPrm.opchStat NEQ OPCH_IDLE )
4494 {
4495 TRACE_EVENT("SAT OPCH FAIL, busy with other command");
4496 resp_data.add_content = ADD_NO_CAUSE;
4497 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
4498 return( FALSE );
4499 }
4500
4501 /* is there a IPv6 address given ?*/
4502 if((opchCmd->v_other_addr AND opchCmd->other_addr.v_ipv6_addr) OR
4503 (opchCmd->v_data_dest_addr AND opchCmd->data_dest_addr.v_ipv6_addr))
4504 {
4505 TRACE_EVENT("SAT OPCH FAIL, IPv6 not supported");
4506 psaSAT_SendTrmResp( RSLT_ME_CAP, &resp_data );
4507 return( FALSE );
4508 }
4509
4510 /* is TCP requested */
4511 if( opchCmd->v_if_transp_lev AND
4512 opchCmd->if_transp_lev.trans_prot_type EQ TCP )
4513 {
4514 TRACE_EVENT("SAT OPCH FAIL, TCP not supported");
4515 psaSAT_SendTrmResp( RSLT_ME_CAP, &resp_data );
4516 return( FALSE );
4517 }
4518
4519 /* check UDP restrictions, WAP is a synonym for UDP */
4520 if( opchCmd->v_if_transp_lev AND
4521 opchCmd->if_transp_lev.trans_prot_type EQ UDP )
4522 {
4523 #if !defined (CO_UDP_IP)
4524 /* is UDP requested, but WAP not set ?*/
4525 TRACE_EVENT("SAT OPCH FAIL, UDP not supported");
4526 resp_data.add_content = ADD_BIP_SIME_ITL_NAVAIL;
4527 psaSAT_SendTrmResp( RSLT_BEARIND_PERR, &resp_data );
4528 return( FALSE );
4529 #endif /* WAP */
4530
4531 /* no destination address given */
4532 if( !opchCmd->v_data_dest_addr )
4533 {
4534 TRACE_EVENT("SAT OPCH FAIL, no destination address given");
4535 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
4536 return( FALSE );
4537 }
4538 }
4539
4540 /* requested buffer size not available */
4541 if( opchCmd->v_buffer_size AND
4542 opchCmd->buffer_size > SIM_CLASS_E_BUFFER_SIZE )
4543 {
4544 TRACE_EVENT("SAT OPCH FAIL, buffer size not available");
4545 resp_data.add_content = ADD_BIP_BUF_SIZ_NAVAIL;
4546 psaSAT_SendTrmResp( RSLT_BEARIND_PERR, &resp_data );
4547 return( FALSE );
4548 }
4549
4550 /**** is CSD channel requested, but not supported ? ****/
4551 #ifndef FAX_AND_DATA
4552 if( opchCmd->v_addr )
4553 {
4554 /* CSD call not supported by ME */
4555 TRACE_EVENT("SAT OPCH FAIL, CSD not supported");
4556 psaSAT_SendTrmResp( RSLT_ME_CAP, &resp_data );
4557 return( FALSE );
4558 }
4559 #endif /* FAX_AND_DATA */
4560
4561 /**** is GPRS channel requested, but not supported ? ****/
4562 #ifndef GPRS
4563 if( !opchCmd->v_addr AND opchCmd->v_bear_desc )
4564 {
4565 /* GPRS call not supported by ME */
4566 TRACE_EVENT("SAT OPCH FAIL, GPRS not supported");
4567 psaSAT_SendTrmResp( RSLT_ME_CAP, &resp_data );
4568 return( FALSE );
4569 }
4570 #endif /* GPRS */
4571
4572
4573 /*
4574 *-------------------------------------------------------------------
4575 * store channel parameters
4576 *-------------------------------------------------------------------
4577 */
4578
4579 /*
4580 *-------------------------------------------------------------------
4581 * for a CSD channel use the call table
4582 *-------------------------------------------------------------------
4583 */
4584 #ifdef FAX_AND_DATA
4585
4586 if( opchCmd->v_addr )
4587 {
4588 T_CC_CALL_TBL *ctb;
4589
4590 /* get call table entry */
4591 cId = psaCC_ctbNewEntry();
4592
4593 if( cId EQ NO_ENTRY )
4594 {
4595 /* send SAT response */
4596 TRACE_EVENT("SAT OPCH FAIL, call table full");
4597 resp_data.add_content = ADD_NO_CAUSE;
4598 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
4599 return( FALSE ); /* primitive not needed anymore */
4600 }
4601
4602 ctb = ccShrdPrm.ctb[cId];
4603
4604 /* build setup parameters */
4605 cmhSAT_fillSetupPrm ( cId,
4606 &opchCmd->addr,
4607 ((opchCmd->v_subaddr)?&opchCmd->subaddr:NULL));
4608
4609 /* check aoc condition */
4610 if ((ctb->prio EQ PRIO_NORM_CALL) AND
4611 (aoc_check_moc() EQ FALSE))
4612 /*
4613 * check ACM exceeds ACMmax
4614 * for non-emergency calls
4615 */
4616 {
4617 TRACE_EVENT("SAT OPCH FAIL, ACM exceeds");
4618 resp_data.add_content = ADD_NO_CAUSE;
4619 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
4620 psaCC_FreeCtbNtry (cId);
4621 return( FALSE );
4622 }
4623
4624 /* bearer capabilities */
4625 ctb->rptInd = RI_NOT_PRES;
4626
4627 if( opchCmd->bear_desc.v_csd_bear_prm )
4628 {
4629 UBYTE selVal;
4630
4631 /* check and set speed parameter */
4632 selVal = cmhCC_SelRate(opchCmd->bear_desc.csd_bear_prm.csd_speed);
4633
4634 if( selVal EQ UR_NOT_PRES )
4635 {
4636 TRACE_EVENT("SAT OPCH FAIL, user rate not supported");
4637 psaSAT_SendTrmResp( RSLT_ME_CAP, &resp_data );
4638 psaCC_FreeCtbNtry (cId);
4639 return( FALSE );
4640 }
4641
4642 ctb->BC[0].rate = selVal;
4643
4644 /* check and set name parameter */
4645 selVal = cmhCC_SelServ(opchCmd->bear_desc.csd_bear_prm.csd_name);
4646
4647 if( selVal EQ BEARER_SERV_NOT_PRES )
4648 {
4649 TRACE_EVENT("SAT OPCH FAIL, user service not supported");
4650 psaSAT_SendTrmResp( RSLT_ME_CAP, &resp_data );
4651 psaCC_FreeCtbNtry (cId);
4652 return( FALSE );
4653 }
4654
4655 ctb->BC[0].bearer_serv = selVal;
4656
4657 /* check and set ce parameter */
4658 selVal = cmhCC_SelCE(opchCmd->bear_desc.csd_bear_prm.csd_ce);
4659
4660 if( selVal EQ CONN_ELEM_NOT_PRES )
4661 {
4662 TRACE_EVENT("SAT OPCH FAIL, ce not supported");
4663 psaSAT_SendTrmResp( RSLT_ME_CAP, &resp_data );
4664 psaCC_FreeCtbNtry (cId);
4665 return( FALSE );
4666 }
4667
4668 ctb->BC[0].conn_elem = selVal;
4669
4670 ctb->BC[0].modem_type = cmhCC_SelMT(opchCmd->bear_desc.
4671 csd_bear_prm.csd_speed);
4672 }
4673
4674 else if ( opchCmd->bear_desc.bear_type EQ BT_DEFAULT )
4675 {
4676 /* default settings for CSD channel */
4677 ctb->BC[0].rate = UR_9_6_KBIT;
4678 ctb->BC[0].bearer_serv = BEARER_SERV_ASYNC;
4679 ctb->BC[0].conn_elem = CONN_ELEM_NON_TRANS;
4680 ctb->BC[0].modem_type = MT_V32;
4681
4682 /* store default settings in opchCmd, will be used for term response later on */
4683 opchCmd->bear_desc.csd_bear_prm.csd_speed = BS_SPEED_9600_V32;
4684 opchCmd->bear_desc.csd_bear_prm.csd_name = CBST_NAM_Asynch;
4685 opchCmd->bear_desc.csd_bear_prm.csd_ce = CBST_CE_NonTransparent;
4686 }
4687
4688 else /* invalid bearer setting for CSD */
4689 {
4690 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
4691 psaCC_FreeCtbNtry (cId);
4692 return( FALSE );
4693 }
4694
4695 ctb->BC[0].stop_bits = STOP_1_BIT;
4696 ctb->BC[0].data_bits = DATA_8_BIT;
4697 ctb->BC[0].parity = PARITY_NONE;
4698
4699 ctb->BC[1].rate = UR_NOT_PRES;
4700 ctb->BC[1].bearer_serv = BEARER_SERV_NOT_PRES;
4701 ctb->BC[1].conn_elem = CONN_ELEM_NOT_PRES;
4702
4703 /* declare the owner and status of the call */
4704 ctb->calOwn = OWN_SAT;
4705 ctb->calStat = CS_SAT_CSD_REQ;
4706 ctb->curCmd = AT_CMD_D;
4707 ctb->SATinv = TRUE;
4708
4709 /* fill in channel table */
4710 satShrdPrm.chnTb.chnUsdFlg = TRUE;
4711 satShrdPrm.chnTb.chnRefId = cId;
4712 satShrdPrm.chnTb.chnType = B_CSD;
4713 satShrdPrm.chnTb.lnkStat = SIM_NO_LINK;
4714
4715 /* store bearer parameters for later use */
4716 cmhSAT_storeCSDPrms (opchCmd);
4717
4718 /* check for call control by SIM */
4719 retVal = cmhSAT_CalCntrlBySIM( cId );
4720
4721 switch( retVal )
4722 {
4723 case( AT_BUSY ):
4724 /* respond with "Interaction with call control by SIM, temporary" */
4725 TRACE_EVENT("SAT OPCH FAIL, CC by SIM busy");
4726 psaSAT_SendTrmResp( RSLT_CC_SIM_TMP, &resp_data );
4727 cmhSAT_cleanupOpChnPrms();
4728 psaCC_FreeCtbNtry (cId);
4729 return( FALSE );
4730
4731 case( AT_FAIL ):
4732 /* respond with "Interaction with call control by SIM, permanent" */
4733 TRACE_EVENT("SAT OPCH FAIL, CC by SIM failure");
4734 resp_data.add_content = ADD_NO_CAUSE;
4735 psaSAT_SendTrmResp( RSLT_CC_SIM_PRM, &resp_data );
4736 cmhSAT_cleanupOpChnPrms();
4737 psaCC_FreeCtbNtry (cId);
4738 return( FALSE );
4739
4740 case( AT_EXCT ):
4741 /* wait for SIM result */
4742 satShrdPrm.ntfy = USR_NTF_SETUP_CAL;
4743 satShrdPrm.opchStat = OPCH_CCSIM_REQ;
4744 break;
4745 }
4746
4747
4748 /* if call control check is performed, return here */
4749 if( satShrdPrm.opchStat EQ OPCH_CCSIM_REQ ) return( TRUE );
4750 }
4751 else
4752 #endif /* FAX_AND_DATA */
4753
4754 /*
4755 *-------------------------------------------------------------------
4756 * for a GPRS channel use a context id in GACI
4757 *-------------------------------------------------------------------
4758 */
4759 #if defined (GPRS) AND defined (DTI)
4760
4761 if( opchCmd->v_bear_desc )
4762 {
4763 T_GPRS_CONT_REC cntxt;
4764
4765 /* get context id */
4766 cId = psaSAT_gprsFindFreeCntxt();
4767
4768 if( cId EQ NO_ENTRY )
4769 {
4770 /* send SAT response */
4771 TRACE_EVENT("SAT OPCH FAIL, no free context");
4772 resp_data.add_content = ADD_NO_CAUSE;
4773 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
4774 return( FALSE ); /* primitive not needed anymore */
4775 }
4776
4777 /* bearer capabilities */
4778 if( opchCmd->bear_desc.v_gprs_bear_prm )
4779 {
4780 /* only PDP type IP is supported */
4781 if( opchCmd->bear_desc.gprs_bear_prm.gprs_pdp_type NEQ PDP_TYPE_IP )
4782 {
4783 TRACE_EVENT("SAT OPCH FAIL, PDP type diff from IP");
4784 psaSAT_SendTrmResp( RSLT_ME_CAP, &resp_data );
4785 return( FALSE );
4786 }
4787
4788 cntxt.qos.preced = opchCmd->bear_desc.gprs_bear_prm.gprs_prec;
4789 cntxt.qos.delay = opchCmd->bear_desc.gprs_bear_prm.gprs_delay;
4790 cntxt.qos.relclass = opchCmd->bear_desc.gprs_bear_prm.gprs_rely;
4791 cntxt.qos.peak = opchCmd->bear_desc.gprs_bear_prm.gprs_peak;
4792 cntxt.qos.mean = opchCmd->bear_desc.gprs_bear_prm.gprs_mean;
4793 }
4794
4795 else if ( opchCmd->bear_desc.bear_type EQ BT_DEFAULT )
4796 {
4797 /* default settings for GPRS channel = as subscribed */
4798 cntxt.qos.preced = 0;
4799 cntxt.qos.delay = 0;
4800 cntxt.qos.relclass = 0;
4801 cntxt.qos.peak = 0;
4802 cntxt.qos.mean = 0;
4803
4804 /* store default settings in opchCmd, will be used for term response later on */
4805 opchCmd->bear_desc.gprs_bear_prm.gprs_prec = 0;
4806 opchCmd->bear_desc.gprs_bear_prm.gprs_delay = 0;
4807 opchCmd->bear_desc.gprs_bear_prm.gprs_rely = 0;
4808 opchCmd->bear_desc.gprs_bear_prm.gprs_peak = 0;
4809 opchCmd->bear_desc.gprs_bear_prm.gprs_mean = 0;
4810 opchCmd->bear_desc.gprs_bear_prm.gprs_pdp_type = PDP_TYPE_IP;
4811 }
4812 else /* invalid bearer setting for GPRS */
4813 {
4814 TRACE_EVENT("SAT OPCH FAIL, invalid GPRS bearer settings");
4815 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
4816 return( FALSE );
4817 }
4818
4819 /* if an APN is given */
4820 if( opchCmd->v_nan_buf AND opchCmd->nan_buf.c_n_acc_name )
4821 {
4822 cmhSAT_cnvrtAPN2NetworkAdr((UBYTE *)opchCmd->nan_buf.n_acc_name,
4823 (UBYTE) opchCmd->nan_buf.c_n_acc_name,
4824 (UBYTE *)cntxt.apn );
4825 }
4826 else /* use default */
4827 {
4828 cntxt.apn[0] = 0;
4829 }
4830
4831 /* if a local address is given */
4832 if( opchCmd->v_other_addr AND opchCmd->other_addr.v_ipv4_addr )
4833 {
4834 cmhSM_ip_to_pdp_address( opchCmd->other_addr.ipv4_addr,
4835 cntxt.pdp_addr );
4836 }
4837 else /* use default, dynamic address */
4838 {
4839 cntxt.pdp_addr[0] = 0;
4840 }
4841
4842 cntxt.d_comp = CGDCONT_D_COMP_OMITTED;
4843 cntxt.h_comp = CGDCONT_H_COMP_OMITTED;
4844 strncpy( cntxt.pdp_type, "IP", sizeof( T_PDP_TYPE ));
4845
4846
4847 if( sAT_PlusCGDCONT ( CMD_SRC_NONE, cId, &cntxt) NEQ AT_CMPL )
4848 {
4849 TRACE_EVENT("SAT OPCH FAIL, invalid CGDCONT parms");
4850 psaSAT_SendTrmResp( RSLT_ME_CAP, &resp_data );
4851 return( FALSE ); /* primitive not needed anymore */
4852 }
4853
4854 if( sAT_PlusCGQREQ( CMD_SRC_NONE, cId, &cntxt.qos) NEQ AT_CMPL )
4855 {
4856 TRACE_EVENT("SAT OPCH FAIL, invalid CGQREQ parms");
4857 psaSAT_SendTrmResp( RSLT_ME_CAP, &resp_data );
4858 return( FALSE ); /* primitive not needed anymore */
4859 }
4860
4861 /* fill in channel table */
4862 satShrdPrm.chnTb.chnUsdFlg = TRUE;
4863 satShrdPrm.chnTb.chnRefId = cId;
4864 satShrdPrm.chnTb.chnType = B_GPRS;
4865 satShrdPrm.chnTb.lnkStat = SIM_NO_LINK;
4866
4867 /* store bearer parameters for later use */
4868 cmhSAT_storeGPRSPrms (opchCmd);
4869 }
4870 else
4871
4872 #endif /* GPRS */
4873
4874 /*
4875 *-------------------------------------------------------------------
4876 * undefined channel
4877 *-------------------------------------------------------------------
4878 */
4879 {
4880 /* respond with "error, required values are missing" */
4881 TRACE_EVENT("SAT OPCH FAIL, requires values missing");
4882 psaSAT_SendTrmResp( RSLT_ERR_REQ_VAL, &resp_data );
4883 return( FALSE );
4884 }
4885
4886
4887 /*
4888 *-------------------------------------------------------------------
4889 * request for user confirmation
4890 *-------------------------------------------------------------------
4891 */
4892 cmhSAT_OpChnAlert( cId );
4893
4894 return( TRUE );
4895
4896 }
4897
4898 /*
4899 +-------------------------------------------------------------------+
4900 | PROJECT : GSM-PS (6147) MODULE : SAT |
4901 | ROUTINE : cmhSAT_storeCSDPrms |
4902 +-------------------------------------------------------------------+
4903
4904 PURPOSE : This function stores the CSD open channel parameters for
4905 later use.
4906
4907 */
4908
4909 GLOBAL void cmhSAT_storeCSDPrms ( T_OPEN_CHANNEL * opchCmd )
4910 {
4911 T_SAT_CSD_PRM *p;
4912
4913 TRACE_FUNCTION("cmhSAT_storeCSDPrms()");
4914
4915 ACI_MALLOC(satShrdPrm.opchPrm, sizeof(T_SAT_CSD_PRM));
4916 TRACE_EVENT("ALLOC opchPrm");
4917 memset(satShrdPrm.opchPrm, 0, sizeof(T_SAT_CSD_PRM));
4918
4919 p = (T_SAT_CSD_PRM*)satShrdPrm.opchPrm;
4920
4921 if(opchCmd->bear_desc.bear_type EQ BT_DEFAULT)
4922 p->def_bear_prm = TRUE;
4923
4924 p->csd_bear_prm = opchCmd->bear_desc.csd_bear_prm;
4925
4926 if(opchCmd->v_dur)
4927 {
4928 p->v_dur = TRUE;
4929 p->dur = opchCmd->dur;
4930 }
4931
4932 if(opchCmd->v_dur2)
4933 {
4934 p->v_dur2 = TRUE;
4935 p->dur2 = opchCmd->dur2;
4936 }
4937
4938 if(opchCmd->v_other_addr)
4939 {
4940 p->v_other_addr = TRUE;
4941 p->other_addr = opchCmd->other_addr;
4942 }
4943
4944 if(opchCmd->v_text)
4945 {
4946 p->v_log = TRUE;
4947 p->log = opchCmd->text;
4948 }
4949
4950 if(opchCmd->v_text2)
4951 {
4952 p->v_pwd = TRUE;
4953 p->pwd = opchCmd->text2;
4954 }
4955
4956 if(opchCmd->v_if_transp_lev)
4957 {
4958 p->v_itl = TRUE;
4959 p->itl = opchCmd->if_transp_lev;
4960 }
4961
4962 if(opchCmd->v_data_dest_addr)
4963 {
4964 p->v_dda = TRUE;
4965 p->dda = opchCmd->data_dest_addr;
4966 }
4967
4968 satShrdPrm.opchType = B_CSD;
4969 }
4970
4971 /*
4972 +-------------------------------------------------------------------+
4973 | PROJECT : GSM-PS (6147) MODULE : SAT |
4974 | ROUTINE : cmhSAT_storeGPRSPrms |
4975 +-------------------------------------------------------------------+
4976
4977 PURPOSE : This function stores the CSD open channel parameters for
4978 later use.
4979
4980 */
4981
4982 GLOBAL void cmhSAT_storeGPRSPrms ( T_OPEN_CHANNEL * opchCmd )
4983 {
4984 T_SAT_GPRS_PRM *p;
4985
4986 TRACE_FUNCTION("cmhSAT_storeGPRSPrms()");
4987
4988 ACI_MALLOC(satShrdPrm.opchPrm, sizeof(T_SAT_GPRS_PRM));
4989 TRACE_EVENT("ALLOC opchPrm");
4990 memset(satShrdPrm.opchPrm, 0, sizeof(T_SAT_GPRS_PRM));
4991
4992 p = (T_SAT_GPRS_PRM*)satShrdPrm.opchPrm;
4993
4994 if(opchCmd->bear_desc.bear_type EQ BT_DEFAULT)
4995 p->def_bear_prm = TRUE;
4996
4997 p->gprs_bear_prm = opchCmd->bear_desc.gprs_bear_prm;
4998
4999 if(opchCmd->v_nan_buf)
5000 {
5001 p->v_apn = TRUE;
5002 p->c_apn = opchCmd->nan_buf.c_n_acc_name;
5003 memcpy(p->apn, opchCmd->nan_buf.n_acc_name, opchCmd->nan_buf.c_n_acc_name);
5004 }
5005
5006 if(opchCmd->v_other_addr)
5007 {
5008 p->v_other_addr = TRUE;
5009 p->other_addr = opchCmd->other_addr;
5010 }
5011
5012 if(opchCmd->v_if_transp_lev)
5013 {
5014 p->v_itl = TRUE;
5015 p->itl = opchCmd->if_transp_lev;
5016 }
5017
5018 if(opchCmd->v_data_dest_addr)
5019 {
5020 p->v_dda = TRUE;
5021 p->dda = opchCmd->data_dest_addr;
5022 }
5023
5024 satShrdPrm.opchType = B_GPRS;
5025 }
5026
5027 /*
5028 +-------------------------------------------------------------------+
5029 | PROJECT : GSM-PS (6147) MODULE : SAT |
5030 | ROUTINE : cmhSAT_cleanupOpChnPrms |
5031 +-------------------------------------------------------------------+
5032
5033 PURPOSE : This function cleans the Op channel parameters
5034
5035 */
5036
5037 GLOBAL void cmhSAT_cleanupOpChnPrms ( void )
5038 {
5039 TRACE_FUNCTION("cmhSAT_cleanupOpChnPrms()");
5040
5041 if( satShrdPrm.opchPrm )
5042 {
5043 ACI_MFREE(satShrdPrm.opchPrm);
5044 satShrdPrm.opchPrm = NULL;
5045 TRACE_EVENT("FREE opchPrm");
5046 }
5047
5048 satShrdPrm.opchPrmMdf = FALSE;
5049 satShrdPrm.opchCCMdfy = FALSE;
5050 satShrdPrm.opchStat = OPCH_IDLE;
5051 satShrdPrm.opchType = 0;
5052 satShrdPrm.gprsNtwCs = 0;
5053
5054 }
5055
5056 /*
5057 +--------------------------------------------------------------------+
5058 | PROJECT : GSM-PS (6147) MODULE : SAT |
5059 | ROUTINE : cmhSAT_OpChnResetCnctFalg|
5060 +--------------------------------------------------------------------+
5061
5062 PURPOSE : This function cleans the Op channel parameters
5063
5064 */
5065
5066 GLOBAL void cmhSAT_OpChnResetCnctFlag ( void )
5067 {
5068 TRACE_FUNCTION("cmhSAT_cleanupOpChnWAP()");
5069 #ifdef CO_UDP_IP
5070 /* If transport layer is UDP, reset wap_call flag */
5071 if( satShrdPrm.chnTb.chnTPL EQ UDP )
5072 {
5073 sAT_PercentWAP ( CMD_SRC_NONE, 0 );
5074 }
5075 #endif /* CO_UDP_IP */
5076 }
5077
5078 /*
5079 +-------------------------------------------------------------------+
5080 | PROJECT : GSM-PS (6147) MODULE : SAT |
5081 | ROUTINE : cmhSAT_OpChnFailed |
5082 +-------------------------------------------------------------------+
5083
5084 PURPOSE : Indication that an open channel command has failed due to
5085 a reason indicated by cause and add_cause. If the failure
5086 occured in context with the OPEN CHANNEL command, a terminal
5087 response will be sent and parameters will be cleaned up.
5088 If the failure was in context with a SEND DATA command, the
5089 SIM BIP channel will be closed and parameters will be cleared
5090 up. If the failure was unexpected, a channel status event
5091 message will be sent, if enabled.
5092
5093 */
5094
5095 GLOBAL void cmhSAT_OpChnFailed( UBYTE cause, T_ACI_SAT_TERM_RESP *resp_data )
5096 {
5097 T_SIM_SAT_CHN chnInf;
5098
5099 TRACE_FUNCTION("cmhSAT_OpChnFailed()");
5100
5101 /* command context is OPEN CHANNEL */
5102 if((satShrdPrm.opchStat EQ OPCH_EST_REQ OR
5103 satShrdPrm.opchStat EQ OPCH_CCSIM_REQ OR
5104 satShrdPrm.opchStat EQ OPCH_WAIT_CNF) AND
5105 satShrdPrm.cmdDet.cmdType EQ SAT_CMD_OPEN_CHANNEL )
5106 {
5107 resp_data->chnStat = TRUE;
5108 psaSAT_SendTrmResp( cause, resp_data );
5109
5110 if(!(satShrdPrm.opchStat EQ OPCH_WAIT_CNF))
5111 {
5112 R_AT( RAT_CME, satShrdPrm.opchAcptSrc ) ( AT_CMD_A, CME_ERR_NotPresent );
5113
5114 /* log result */
5115 cmh_logRslt ( satShrdPrm.opchAcptSrc, RAT_CME, AT_CMD_A,
5116 -1, -1, CME_ERR_NotPresent );
5117 }
5118 cmhSAT_cleanupOpChnPrms();
5119 }
5120
5121 /* command context is SEND DATA */
5122 else if( satShrdPrm.opchStat EQ OPCH_EST_REQ AND
5123 satShrdPrm.cmdDet.cmdType EQ SAT_CMD_SEND_DATA )
5124 {
5125 if( satShrdPrm.chnTb.lnkStat EQ SIM_LINK_OPEN )
5126 {
5127 /* check if user has cleared down the call */
5128 if( satShrdPrm.chnTb.chnType EQ B_CSD AND
5129 (!psaCC_ctbIsValid (satShrdPrm.chnTb.chnRefId) OR
5130 psaCC_ctb(satShrdPrm.chnTb.chnRefId)->curCmd EQ AT_CMD_H OR
5131 psaCC_ctb(satShrdPrm.chnTb.chnRefId)->curCmd EQ AT_CMD_CHUP))
5132 {
5133 cause = RSLT_USR_CLR_DWN;
5134 }
5135 #ifdef DTI
5136 chnInf.bipConn = SIM_BIP_CLOSE_CHANNEL;
5137 chnInf.dtiConn = SIM_DTI_UNKNOWN;
5138 chnInf.chnId = CHANNEL_ID_1;
5139 chnInf.genRes = cause;
5140 chnInf.addRes = resp_data->add_content;
5141
5142 psaSIM_SATBIPChn( chnInf, cmhSAT_OpChnClose );
5143 #endif /* DTI */
5144 }
5145 }
5146 /* unsolicited problem */
5147 else if( satShrdPrm.opchStat EQ OPCH_IDLE )
5148 {
5149 chnInf.bipConn = SIM_BIP_UNKNOWN;
5150 chnInf.dtiConn = SIM_DTI_UNKNOWN;
5151
5152 if( satShrdPrm.chnTb.lnkStat EQ SIM_LINK_OPEN )
5153 {
5154 chnInf.bipConn = SIM_BIP_CLOSE_CHANNEL;
5155 }
5156 if( satShrdPrm.chnTb.lnkStat EQ SIM_LINK_CNCT )
5157 {
5158 chnInf.bipConn = SIM_BIP_CLOSE_CHANNEL;
5159 chnInf.dtiConn = SIM_DTI_DISCONNECT;
5160 }
5161 #ifdef DTI
5162 if( chnInf.bipConn )
5163 {
5164 chnInf.chnId = CHANNEL_ID_1;
5165 chnInf.genRes = RSLT_BEARIND_PERR;
5166 chnInf.addRes = ADD_BIP_CHAN_CLOSD;
5167
5168 psaSIM_SATBIPChn( chnInf, cmhSAT_OpChnClose );
5169
5170 cmhSAT_OpChnStatEvnt();
5171 }
5172 #endif /* DTI */
5173 }
5174 }
5175
5176 /*
5177 +-------------------------------------------------------------------+
5178 | PROJECT : GSM-PS (6147) MODULE : SAT |
5179 | ROUTINE : cmhSAT_OpChnAlert |
5180 +-------------------------------------------------------------------+
5181
5182 PURPOSE : This function alerts the user about a pending SAT open
5183 channel command, which is ready for execution.
5184
5185 */
5186
5187 GLOBAL void cmhSAT_OpChnAlert( SHORT cId )
5188
5189 {
5190 UBYTE idx;
5191 ULONG rdl = ACI_NumParmNotPresent;
5192 T_ACI_SATA_ADD addPrm;
5193
5194 if( satShrdPrm.opchType EQ B_CSD )
5195 {
5196 rdl = cmhSAT_ChckRedial(cId, ((T_SAT_CSD_PRM*)satShrdPrm.opchPrm)->v_dur,
5197 &(((T_SAT_CSD_PRM*)satShrdPrm.opchPrm)->dur));
5198
5199 addPrm.chnType = SATA_CT_CSD;
5200 cId += 1;
5201 }
5202 else if ( satShrdPrm.opchType EQ B_GPRS )
5203
5204 addPrm.chnType = SATA_CT_GPRS;
5205
5206 addPrm.chnEst = ( satShrdPrm.cmdDet.cmdQlf & QLF_OPCH_IMMDT_LINK_EST )?
5207 SATA_EST_IM:SATA_EST_OD;
5208
5209 for( idx = 0; idx < CMD_SRC_MAX; idx++ )
5210 {
5211 R_AT( RAT_SATA, idx )( cId, rdl, &addPrm );
5212 }
5213
5214 satShrdPrm.ntfy = USR_NTF_SETUP_CAL;
5215 satShrdPrm.opchStat = OPCH_WAIT_CNF;
5216 }
5217
5218 /*
5219 +-------------------------------------------------------------------+
5220 | PROJECT : GSM-PS (6147) MODULE : SAT |
5221 | ROUTINE : cmhSAT_OpChnChkTmpProblem|
5222 +-------------------------------------------------------------------+
5223
5224 PURPOSE : This function checks for a temporary situation, which
5225 prevents the open channel command to be completed. If such
5226 a condition exists, the open channel command will be aborted
5227 with a suitable terminal response and the function returns
5228 TRUE
5229
5230 */
5231
5232 GLOBAL BOOL cmhSAT_OpChnChkTmpProblem( void )
5233
5234 {
5235 T_ACI_SAT_TERM_RESP resp_data; /* holds terminal response parms */
5236 SHORT actId = NO_ENTRY;
5237 BOOL cleanup = FALSE;
5238
5239 psaSAT_InitTrmResp( &resp_data );
5240
5241
5242 TRACE_FUNCTION("cmhSAT_OpChnChkTmpProblem()");
5243
5244 /*
5245 *-------------------------------------------------------------------
5246 * check channel type independent conditions
5247 *-------------------------------------------------------------------
5248 */
5249 #ifdef CO_UDP_IP
5250 /* check for a busy UDP situation, WAP is a synonym for UDP */
5251 if( satShrdPrm.chnTb.chnTPL EQ UDP AND
5252 Wap_Call )
5253 {
5254 TRACE_EVENT("SAT OPCH FAIL, UDP is busy");
5255 resp_data.add_content = ADD_NO_CAUSE;
5256 cmhSAT_OpChnFailed( RSLT_ME_UNAB_PROC, &resp_data );
5257 cleanup = TRUE;
5258 }
5259 /*
5260 *-------------------------------------------------------------------
5261 * check CSD channel conditions
5262 *-------------------------------------------------------------------
5263 */
5264 else
5265 #endif /* CO_UDP_IP */
5266
5267 if( satShrdPrm.opchType EQ B_CSD )
5268 {
5269 /* check for busy SS condition */
5270 if( psaSS_stbFindActSrv( NO_ENTRY ) NEQ NO_ENTRY )
5271 {
5272 /* send SAT response */
5273 TRACE_EVENT("SAT OPCH FAIL, SS busy");
5274 resp_data.add_content = ADD_ME_SS_BUSY;
5275 cmhSAT_OpChnFailed( RSLT_ME_UNAB_PROC, &resp_data );
5276
5277 cleanup = TRUE;
5278 }
5279
5280 /* check for busy call condition */
5281 else if( psaSAT_ctbFindActCall() NEQ NO_ENTRY )
5282 {
5283 /* send SAT response */
5284 TRACE_EVENT("SAT OPCH FAIL, busy on call");
5285 resp_data.add_content = ADD_ME_CALL_BUSY;
5286 cmhSAT_OpChnFailed( RSLT_ME_UNAB_PROC, &resp_data );
5287
5288 cleanup = TRUE;
5289 }
5290 #if defined (GPRS) AND defined (DTI)
5291 /* CSD channel, but class CG */
5292 else if( gmmShrdPrm.mobile_class EQ GMMREG_CLASS_CG )
5293 {
5294 /* send SAT response */
5295 TRACE_EVENT("SAT OPCH FAIL, no channel avail");
5296 resp_data.add_content = ADD_BIP_NO_CHAN_AVAIL;
5297 cmhSAT_OpChnFailed( RSLT_BEARIND_PERR, &resp_data );
5298
5299 cleanup = TRUE;
5300 }
5301 #endif /* GPRS */
5302
5303 }
5304
5305 /*
5306 *-------------------------------------------------------------------
5307 * check GPRS channel conditions
5308 *-------------------------------------------------------------------
5309 */
5310 #if defined (GPRS) AND defined (DTI)
5311 else if( satShrdPrm.opchType EQ B_GPRS )
5312 {
5313 /* GPRS channel, class B */
5314 if( gmmShrdPrm.mobile_class EQ GMMREG_CLASS_BC OR
5315 gmmShrdPrm.mobile_class EQ GMMREG_CLASS_BG )
5316 {
5317 if( psaSS_stbFindActSrv( NO_ENTRY ) NEQ NO_ENTRY )
5318 {
5319 /* send SAT response */
5320 TRACE_EVENT("SAT OPCH FAIL, SS busy");
5321 resp_data.add_content = ADD_ME_SS_BUSY;
5322 cmhSAT_OpChnFailed( RSLT_ME_UNAB_PROC, &resp_data );
5323
5324 cleanup = TRUE;
5325 }
5326
5327 /* check for busy call condition */
5328 else if( psaSAT_ctbFindActCall() NEQ NO_ENTRY )
5329 {
5330 /* send SAT response */
5331 TRACE_EVENT("SAT OPCH FAIL, busy on call");
5332 resp_data.add_content = ADD_ME_CALL_BUSY;
5333 cmhSAT_OpChnFailed( RSLT_ME_UNAB_PROC, &resp_data );
5334
5335 cleanup = TRUE;
5336 }
5337 }
5338
5339 /* GPRS channel, but class CC */
5340 else if( gmmShrdPrm.mobile_class EQ GMMREG_CLASS_CC )
5341 {
5342 /* send SAT response */
5343 TRACE_EVENT("SAT OPCH FAIL, no channel avail");
5344 resp_data.add_content = ADD_BIP_NO_CHAN_AVAIL;
5345 cmhSAT_OpChnFailed( RSLT_BEARIND_PERR, &resp_data );
5346
5347 cleanup = TRUE;
5348 }
5349
5350 /* no channel left for GPRS */
5351 else if( psaSAT_gprsFindFreeCntxt() EQ NO_ENTRY )
5352 {
5353 /* send SAT response */
5354 TRACE_EVENT("SAT OPCH FAIL, no channel avail");
5355 resp_data.add_content = ADD_BIP_NO_CHAN_AVAIL;
5356 cmhSAT_OpChnFailed( RSLT_BEARIND_PERR, &resp_data );
5357
5358 cleanup = TRUE;
5359 }
5360
5361 /* check SM entity status */
5362 else if( smEntStat.entOwn NEQ OWN_NONE OR
5363 smEntStat.curCmd NEQ AT_CMD_NONE )
5364 {
5365 /* send SAT response */
5366 TRACE_EVENT("SAT OPCH FAIL, SM entity busy");
5367 resp_data.add_content = ADD_NO_CAUSE;
5368 cmhSAT_OpChnFailed( RSLT_ME_UNAB_PROC, &resp_data );
5369
5370 cleanup = TRUE;
5371 }
5372 }
5373 #endif /* GPRS */
5374
5375 /*
5376 *-------------------------------------------------------------------
5377 * cleanup if necessary
5378 *-------------------------------------------------------------------
5379 */
5380 if( cleanup )
5381 {
5382 if( satShrdPrm.opchType EQ B_CSD )
5383 {
5384 /* free ctb entry */
5385 psaCC_FreeCtbNtry (satShrdPrm.chnTb.chnRefId);
5386 }
5387
5388 cmhSAT_cleanupOpChnPrms();
5389
5390 return ( TRUE );
5391 }
5392
5393 return( FALSE );
5394 }
5395
5396
5397 /*
5398 +-------------------------------------------------------------------+
5399 | PROJECT : GSM-PS (6147) MODULE : SAT |
5400 | ROUTINE : cmhSAT_OpChnUDPActiveCsd|
5401 +-------------------------------------------------------------------+
5402
5403 PURPOSE : This callback function will be called when the UDP stack
5404 is active
5405
5406 */
5407
5408 GLOBAL void cmhSAT_OpChnUDPActiveCsd(T_ACI_RETURN result)
5409 {
5410 T_ACI_SAT_TERM_RESP resp_data; /* holds terminal response parms */
5411
5412 TRACE_FUNCTION("cmhSAT_OpChnUDPActiveCsd()");
5413
5414 /* Ensure we never dereference NULL in the CC call table */
5415 if (!psaCC_ctbIsValid (tcpipShrdPrm.wap_call_id))
5416 {
5417 TRACE_ERROR ("Call table entry disappeared");
5418 ccShrdPrm.datStat = DS_IDL ;
5419 psaSAT_InitTrmResp( &resp_data );
5420 resp_data.add_content = ADD_NO_CAUSE;
5421
5422 cmhSAT_OpChnFailed( RSLT_ME_UNAB_PROC, &resp_data );
5423 return;
5424 }
5425
5426 /*
5427 * activate RA connection: in case of failure clear call !
5428 */
5429 ccShrdPrm.datStat = DS_ACT_REQ;
5430
5431 if(cmhRA_Activate(psaCC_ctb(tcpipShrdPrm.wap_call_id)->curSrc,
5432 psaCC_ctb(tcpipShrdPrm.wap_call_id)->curCmd,
5433 tcpipShrdPrm.wap_call_id)
5434 NEQ AT_EXCT)
5435 {
5436 TRACE_EVENT("RA ACTIVATION FAILURE -> DISC CALL");
5437 ccShrdPrm.datStat = DS_IDL ;
5438 psaCC_ctb(tcpipShrdPrm.wap_call_id)->nrmCs = MNCC_CAUSE_CALL_CLEAR;
5439 psaCC_ClearCall (tcpipShrdPrm.wap_call_id);
5440
5441
5442 psaSAT_InitTrmResp( &resp_data );
5443 resp_data.add_content = ADD_NO_CAUSE;
5444
5445 cmhSAT_OpChnFailed( RSLT_ME_UNAB_PROC, &resp_data );
5446 }
5447 }
5448
5449
5450 /*
5451 +-------------------------------------------------------------------+
5452 | PROJECT : GSM-PS (6147) MODULE : SAT |
5453 | ROUTINE : cmhSAT_OpChnUDPConfCsd |
5454 +-------------------------------------------------------------------+
5455
5456 PURPOSE : This callback function will be called when the UDP stack
5457 is configured
5458
5459 */
5460 GLOBAL void cmhSAT_OpChnUDPConfCsd(T_ACI_RETURN result)
5461 {
5462
5463 TRACE_FUNCTION("cmhSAT_OpChnUDPConfCsd()");
5464 /*
5465 * send the SIM_BIP_CONFIG_REQ primitive providing details of the connection
5466 * to SIM
5467 */
5468 psaSIM_Bip_Config_Req();
5469 }
5470
5471 /*
5472 +-------------------------------------------------------------------+
5473 | PROJECT : GSM-PS (6147) MODULE : SAT |
5474 | ROUTINE : cmhSAT_OpChnUDPDeactCsd |
5475 +-------------------------------------------------------------------+
5476
5477 PURPOSE : This callback function will be called when the UDP stack
5478 is deactive
5479
5480 */
5481
5482 GLOBAL void cmhSAT_OpChnUDPDeactCsd(T_ACI_RETURN result)
5483 {
5484 T_ACI_SAT_TERM_RESP resp_data; /* holds terminal response parms */
5485
5486 TRACE_FUNCTION("cmhSAT_OpChnUDPDeactCsd()");
5487
5488 psaSAT_InitTrmResp( &resp_data );
5489
5490 /*
5491 *-------------------------------------------------------------------
5492 * check if deactivation was intended
5493 *-------------------------------------------------------------------
5494 */
5495 if( satShrdPrm.opchStat EQ OPCH_CLS_REQ )
5496 {
5497 /* nothing to do here anymore */
5498 }
5499
5500 /*
5501 *-------------------------------------------------------------------
5502 * deactivation during an establish request
5503 *-------------------------------------------------------------------
5504 */
5505 else if( satShrdPrm.opchStat EQ OPCH_EST_REQ )
5506 {
5507 if (cmhL2R_Deactivate() NEQ AT_EXCT)
5508 {
5509 TRACE_EVENT("L2R DEACTIVATION FAILURE ");
5510 if (psaCC_ctbIsValid (tcpipShrdPrm.wap_call_id))
5511 {
5512 psaCC_ctb(tcpipShrdPrm.wap_call_id)->nrmCs = MNCC_CAUSE_CALL_CLEAR;
5513 psaCC_ClearCall(tcpipShrdPrm.wap_call_id);
5514 }
5515 }
5516
5517 resp_data.add_content = ADD_NO_CAUSE;
5518
5519 cmhSAT_OpChnFailed( RSLT_ME_UNAB_PROC, &resp_data );
5520
5521 }
5522 }
5523 /*
5524 +-------------------------------------------------------------------+
5525 | PROJECT : GSM-PS (6147) MODULE : SAT |
5526 | ROUTINE : cmhSAT_OpBIPChnOpen |
5527 +-------------------------------------------------------------------+
5528
5529 PURPOSE : This callback function will be called when the SIM entity
5530 has tried to open a BIP channel
5531
5532 */
5533
5534 GLOBAL void cmhSAT_OpBIPChnOpen( UBYTE bipConn, UBYTE chnId )
5535 {
5536 T_CC_CMD_PRM * pCCCmdPrm; /* points to CC command parameters */
5537 T_ACI_SAT_TERM_RESP resp_data; /* holds terminal response parms */
5538 UBYTE srcId; /* holds source ID */
5539 UBYTE cause;
5540 SHORT cId; /* holds caller ID for pending CSD call (case immediately) */
5541 #ifdef GPRS
5542 SHORT cid_array[2] = { 0,INVALID_CID }; /* holds cids for GPRS context */
5543 #endif /* GPRS */
5544
5545 TRACE_FUNCTION("cmhSAT_OpBIPChnOpen()");
5546
5547 /* get source id */
5548 srcId = satShrdPrm.opchAcptSrc;
5549
5550 psaSAT_InitTrmResp( &resp_data );
5551
5552 /* send TR in the case of on demand establishment */
5553 if( satShrdPrm.opchStat EQ OPCH_ON_DMND )
5554 {
5555 /* CASE: ON DEMAND */
5556
5557 /* check if opening has been successful */
5558 if( bipConn & SIM_BIP_OPEN_CHANNEL )
5559 {
5560 /* BEARER: GPRS OR CSD */
5561
5562 /* set link state to OPEN */
5563 satShrdPrm.chnTb.lnkStat = SIM_LINK_OPEN;
5564
5565 resp_data.chnStat = TRUE;
5566 resp_data.bearDesc = TRUE;
5567 resp_data.bufSize = TRUE;
5568 cause = (satShrdPrm.opchCCMdfy)?RSLT_PERF_MDFY_SIM:RSLT_PERF_SUCCESS;
5569
5570 psaSAT_SendTrmResp( cause, &resp_data );
5571
5572 R_AT( RAT_OK, satShrdPrm.opchAcptSrc ) ( AT_CMD_A );
5573
5574 /* log result */
5575 cmh_logRslt ( satShrdPrm.opchAcptSrc, RAT_OK, AT_CMD_A, -1, -1, -1 );
5576 }
5577 /* unsuccessful channel opening */
5578 else
5579 {
5580 /* BEARER: GPRS OR CSD */
5581
5582 TRACE_ERROR("cmhSAT_OpChnOpen: ERROR: OPEN BIP CHANNEL unsuccessful");
5583
5584 resp_data.add_content = ADD_BIP_NO_CHAN_AVAIL;
5585 cause = RSLT_BEARIND_PERR;
5586
5587 cmhSAT_cleanupOpChnPrms();
5588
5589 psaSAT_SendTrmResp( cause, &resp_data );
5590
5591 R_AT( RAT_CME, satShrdPrm.opchAcptSrc ) ( AT_CMD_A, CME_ERR_NotPresent );
5592
5593 /* log result */
5594 cmh_logRslt ( satShrdPrm.opchAcptSrc, RAT_CME, AT_CMD_A,
5595 -1, -1, CME_ERR_NotPresent );
5596 }
5597
5598 }
5599 else if ( satShrdPrm.opchStat EQ OPCH_EST_REQ )
5600 {
5601 /* CASE: IMMEDIATELY */
5602 /* Check whether OPEN BIP CHANNEL successful */
5603 if( bipConn & SIM_BIP_OPEN_CHANNEL )
5604 {
5605
5606 /* set link state to OPEN, since the BIP and DTI establishment has split
5607 * this state is alse used for "immediately" OPEN CHANNEL command */
5608 satShrdPrm.chnTb.lnkStat = SIM_LINK_OPEN;
5609
5610 /* check for BEARER */
5611 if (satShrdPrm.opchType EQ B_CSD)
5612 {
5613 /* BEARER: CSD */
5614 /* proceed to set up bearer for CSD */
5615
5616 /* get SAT call cId */
5617 cId = psaCC_ctbFindCall( OWN_SAT, CS_SAT_CSD_REQ, NO_VLD_CT );
5618
5619 /* check if a call has been found */
5620 if ( cId NEQ (-1))
5621 {
5622 pCCCmdPrm = &cmhPrm[srcId].ccCmdPrm;
5623
5624 if( satShrdPrm.chnTb.chnTPL EQ UDP )
5625 {
5626 /* TRANSPORT LAYER: UDP */
5627
5628 /* enable establishment of UDP data chain */
5629 sAT_PercentWAP ( psaCC_ctb(cId)->curSrc , 1 );
5630
5631 /* setup PPP parameters */
5632 cmhSAT_OpChnSetPPP( B_CSD );
5633 }
5634 /* finally set up call */
5635 cmhCC_flagCall( cId, &(pCCCmdPrm->mltyCncFlg));
5636 cmhCC_NewCall(cId, srcId, AT_CMD_A);
5637 }
5638 else
5639 {
5640 TRACE_FUNCTION("cmhSAT_OpChnOpen: No CSD call pending");
5641 }
5642 }
5643 #if defined (GPRS) AND defined (DTI)
5644 else if (satShrdPrm.opchType EQ B_GPRS)
5645 {
5646 /* BEARER: GPRS */
5647
5648 /* copy channel reference ID */
5649 cid_array[0] = satShrdPrm.chnTb.chnRefId;
5650
5651 if( satShrdPrm.chnTb.chnTPL EQ UDP )
5652 {
5653 /* TRANSPORT LAYER: UDP */
5654
5655 /* enable establishment of UDP data chain */
5656 sAT_PercentWAP ( srcId , 1 );
5657
5658 /* setup PPP parameters */
5659 cmhSAT_OpChnSetPPP( B_GPRS );
5660
5661 /* activate context with UDP */
5662 cmhSAT_OpChnUDPActivateGprs();
5663 }
5664 else
5665 {
5666 /* NO TRANSPORT LAYER: SNDCP only */
5667
5668 /* activate context with no transport layer */
5669 if( sAT_PlusCGACT( srcId, CGACT_STATE_ACTIVATED, cid_array ) NEQ AT_EXCT )
5670 {
5671 /* activate context command could not proccessed */
5672 /* throw error */
5673 TRACE_ERROR("cmhSAT_OpChnOpen: ERROR: activate context with no TRL failed");
5674 R_AT( RAT_CME, satShrdPrm.opchAcptSrc ) ( AT_CMD_A, CME_ERR_NoConnect );
5675 }
5676 }
5677 } /* end bearer B_GPRS */
5678 #endif /* GPRS AND DTI */
5679 }
5680 else /* OPEN BIP CHANNEL unsuccessful */
5681 {
5682 /* CASE: ON DEMAND and IMMEDIATELY */
5683 /* BEARER: CSD and GPRS */
5684
5685 TRACE_ERROR("cmhSAT_OpChnOpen: ERROR: OPEN BIP CHANNEL unsuccessful");
5686
5687 resp_data.add_content = ADD_BIP_NO_CHAN_AVAIL;
5688 cause = RSLT_BEARIND_PERR;
5689
5690 /* store current status of BIP channel */
5691 simShrdPrm.sim_dti_chPrm->sat_chn_prm.bipConn = SIM_BIP_CLOSE_CHANNEL;
5692
5693 cmhSAT_cleanupOpChnPrms();
5694
5695 psaSAT_SendTrmResp( cause, &resp_data );
5696
5697 R_AT( RAT_CME, satShrdPrm.opchAcptSrc ) ( AT_CMD_A, CME_ERR_NotPresent );
5698
5699 /* log result */
5700 cmh_logRslt ( satShrdPrm.opchAcptSrc, RAT_CME, AT_CMD_A,
5701 -1, -1, CME_ERR_NotPresent );
5702 }
5703 } /* end if ( satShrdPrm.opchStat EQ OPCH_EST_REQ ) */
5704 }
5705
5706
5707 /*
5708 +-------------------------------------------------------------------+
5709 | PROJECT : GSM-PS (6147) MODULE : SAT |
5710 | ROUTINE : cmhSAT_OpChnCnct |
5711 +-------------------------------------------------------------------+
5712
5713 PURPOSE : This callback function will be called when the SIM entity
5714 has tried to connect a DTI channel
5715
5716 */
5717
5718 GLOBAL void cmhSAT_OpChnCnct( UBYTE dtiConn, UBYTE chnId )
5719 {
5720 #ifdef DTI
5721 T_SIM_SAT_CHN chnInf;
5722
5723 TRACE_FUNCTION("cmhSAT_OpChnCnct()");
5724
5725 /* connection was successful */
5726 if( dtiConn & SIM_DTI_CONNECT )
5727 {
5728 satShrdPrm.chnTb.lnkStat = SIM_LINK_CNCT;
5729 TRACE_EVENT("cmhSAT_OpChnCnct: SIM-DTI connection successful");
5730 }
5731 else
5732 {
5733 /* unsuccessful connection */
5734 TRACE_EVENT("cmhSAT_OpChnCnct: ERROR: SIM-DTI connection unsuccessful!");
5735
5736 /* if the channel is still open */
5737
5738 /* SAT E patch: Since this information isn't available from incoming
5739 * SIM_DTI_CNF look into the shrd parameters whether there has been a
5740 * already BIP channel established within this channel connection */
5741 /* former checked: dtiConn & SIM_BIP_OPEN_CHANNEL*/
5742 if( (satShrdPrm.chnTb.lnkStat EQ SIM_LINK_OPEN) )
5743 {
5744 /* check for SEND DATA/OPEN CHANNEL command context */
5745 if( satShrdPrm.opchStat EQ OPCH_EST_REQ AND
5746 (satShrdPrm.cmdDet.cmdType EQ SAT_CMD_OPEN_CHANNEL OR
5747 satShrdPrm.cmdDet.cmdType EQ SAT_CMD_SEND_DATA))
5748 {
5749 chnInf.bipConn = SIM_BIP_CLOSE_CHANNEL;
5750 chnInf.dtiConn = SIM_DTI_UNKNOWN;
5751 chnInf.chnId = CHANNEL_ID_1;
5752 chnInf.genRes = RSLT_BEARIND_PERR;
5753 chnInf.addRes = ADD_BIP_NO_CHAN_AVAIL;
5754
5755 psaSIM_SATBIPChn( chnInf, cmhSAT_OpChnClose );
5756 }
5757
5758 satShrdPrm.chnTb.lnkStat = SIM_LINK_OPEN;
5759 }
5760 /* if bearer is still in use */
5761 else if ( satShrdPrm.chnTb.chnUsdFlg )
5762 {
5763 /* if a CSD is still in progress */
5764 if( satShrdPrm.chnTb.chnType EQ B_CSD )
5765 {
5766 SHORT dummy;
5767
5768 cmhCC_ClearCall( satShrdPrm.chnTb.chnRefId,
5769 MNCC_CAUSE_CALL_CLEAR,
5770 satShrdPrm.opchAcptSrc,
5771 AT_CMD_NONE,
5772 &dummy);
5773 }
5774
5775 #ifdef GPRS
5776 /* if a GPRS context is still in progress */
5777 if( satShrdPrm.chnTb.chnType EQ B_GPRS )
5778 {
5779 SHORT cid_array[2] = { 0,INVALID_CID };
5780 cid_array[0] = satShrdPrm.chnTb.chnRefId;
5781
5782 sAT_PlusCGACT( satShrdPrm.opchAcptSrc,
5783 CGACT_STATE_DEACTIVATED, cid_array );
5784 }
5785 #endif /* GPRS */
5786 }
5787 }
5788 #endif /* DTI */
5789 }
5790
5791 /*
5792 +-------------------------------------------------------------------+
5793 | PROJECT : GSM-PS (6147) MODULE : SAT |
5794 | ROUTINE : cmhSAT_OpChnClose |
5795 +-------------------------------------------------------------------+
5796
5797 PURPOSE : This callback function will be called when the SIM entity
5798 has tried to close a channel
5799
5800 */
5801
5802 GLOBAL void cmhSAT_OpChnClose( UBYTE bipConn, UBYTE chnId )
5803 {
5804 T_ACI_SAT_TERM_RESP resp_data; /* holds terminal response parms */
5805
5806 TRACE_FUNCTION("cmhSAT_OpChnClose()");
5807
5808
5809 /* channel closed */
5810 if( bipConn & SIM_BIP_CLOSE_CHANNEL )
5811 {
5812 satShrdPrm.chnTb.lnkStat = SIM_NO_LINK;
5813
5814 psaSAT_InitTrmResp( &resp_data );
5815
5816 /* check for OPEN CHANNEL command context, immediate channel */
5817 if( satShrdPrm.opchStat EQ OPCH_EST_REQ AND
5818 satShrdPrm.cmdDet.cmdType EQ SAT_CMD_OPEN_CHANNEL )
5819 {
5820 resp_data.add_content = ADD_BIP_NO_CHAN_AVAIL;
5821 resp_data.chnStat = TRUE;
5822
5823 cmhSAT_OpChnFailed(RSLT_BEARIND_PERR, &resp_data);
5824 cmhSAT_cleanupOpChnPrms();
5825
5826 }
5827
5828 /* check for SEND DATA command context, on-demand channel */
5829 else if( satShrdPrm.opchStat EQ OPCH_EST_REQ AND
5830 satShrdPrm.cmdDet.cmdType EQ SAT_CMD_SEND_DATA )
5831 {
5832 cmhSAT_cleanupOpChnPrms();
5833 }
5834
5835 /* check for intented channel closing */
5836 else if( satShrdPrm.opchStat EQ OPCH_CLS_REQ AND
5837 satShrdPrm.cmdDet.cmdType EQ SAT_CMD_CLOSE_CHANNEL)
5838 {
5839 resp_data.chnStat = TRUE;
5840 psaSAT_SendTrmResp( RSLT_PERF_SUCCESS, &resp_data );
5841 if ( dti_cntrl_is_dti_channel_connected (DTI_ENTITY_UDP, simShrdPrm.sat_class_e_dti_id)
5842 #ifdef GPRS
5843 OR dti_cntrl_is_dti_channel_connected (DTI_ENTITY_SNDCP, simShrdPrm.sat_class_e_dti_id)
5844 #endif /* GPRS */
5845 )
5846 {
5847 cmhSAT_cleanupOpChnPrms();
5848 }
5849 else /* L2R or TRA - dti channel has to be closed explicitly */
5850 {
5851 /* close existing DTI channel first */
5852 dti_cntrl_close_dpath_from_dti_id(simShrdPrm.sat_class_e_dti_id);
5853 cmhSAT_cleanupOpChnPrms();
5854 }
5855 }
5856
5857
5858 /* if bearer is still in use */
5859 if( satShrdPrm.chnTb.chnUsdFlg )
5860 {
5861 /* if a CSD is still in progress */
5862 if( satShrdPrm.chnTb.chnType EQ B_CSD )
5863 {
5864 SHORT dummy;
5865
5866 cmhCC_ClearCall( satShrdPrm.chnTb.chnRefId,
5867 MNCC_CAUSE_CALL_CLEAR,
5868 satShrdPrm.opchAcptSrc,
5869 AT_CMD_NONE,
5870 &dummy);
5871 }
5872 #if defined (GPRS) AND defined (DTI)
5873 /* if a GPRS context is still in progress */
5874 if( satShrdPrm.chnTb.chnType EQ B_GPRS )
5875 {
5876 SHORT cid_array[2] = { 0,INVALID_CID };
5877 cid_array[0] = satShrdPrm.chnTb.chnRefId;
5878
5879 sAT_PlusCGACT( satShrdPrm.opchAcptSrc,
5880 CGACT_STATE_DEACTIVATED, cid_array );
5881 }
5882 #endif /* GPRS */
5883 }
5884 }
5885 }
5886
5887 /*
5888 +-------------------------------------------------------------------+
5889 | PROJECT : GSM-PS (6147) MODULE : SAT |
5890 | ROUTINE : cmhSAT_OpChnCSDDown |
5891 +-------------------------------------------------------------------+
5892
5893 PURPOSE : This function is used to indictate that the CSD data
5894 connection is down.
5895
5896 */
5897
5898 GLOBAL void cmhSAT_OpChnCSDDown( SHORT cId, UBYTE tpl )
5899 {
5900 T_ACI_SAT_TERM_RESP resp_data; /* holds terminal response parms */
5901
5902 TRACE_FUNCTION("cmhSAT_OpChnCSDDown()");
5903
5904 psaSAT_InitTrmResp( &resp_data );
5905 resp_data.add_content = ADD_NO_CAUSE;
5906
5907 if( satShrdPrm.chnTb.chnUsdFlg AND
5908 satShrdPrm.chnTb.chnType EQ B_CSD AND
5909 (satShrdPrm.chnTb.chnTPL EQ tpl OR tpl EQ TPL_DONT_CARE) AND
5910 satShrdPrm.chnTb.chnRefId EQ cId )
5911 {
5912
5913 /* If transport layer is UDP, reset wap_call flag */
5914 if( satShrdPrm.chnTb.chnTPL EQ UDP )
5915 {
5916 sAT_PercentWAP ( CMD_SRC_NONE, 0 );
5917
5918 /* clear parameters of dti connection */
5919 }
5920
5921 if(simShrdPrm.sat_class_e_dti_id NEQ DTI_DTI_ID_NOTPRESENT)
5922 {
5923 dti_cntrl_erase_entry(simShrdPrm.sat_class_e_dti_id);
5924 dti_cntrl_clear_conn_parms(simShrdPrm.sat_class_e_dti_id);
5925 simShrdPrm.sat_class_e_dti_id = DTI_DTI_ID_NOTPRESENT;
5926 TRACE_EVENT("sat_class_e_dti_id reset");
5927 }
5928
5929 cmhSAT_OpChnFailed( RSLT_ME_UNAB_PROC, &resp_data );
5930 }
5931 }
5932
5933 /*
5934 +-------------------------------------------------------------------+
5935 | PROJECT : GSM-PS (6147) MODULE : SAT |
5936 | ROUTINE : cmhSAT_OpChnGPRSDeact |
5937 +-------------------------------------------------------------------+
5938
5939 PURPOSE : This function is used to indictate that the CSD data
5940 connection is down.
5941
5942 */
5943 #ifdef GPRS
5944 GLOBAL void cmhSAT_OpChnGPRSDeact( void )
5945 {
5946
5947 SHORT cid;
5948 TRACE_FUNCTION("cmhSAT_OpChnGPRSDeact()");
5949
5950 cid = gaci_get_cid_over_dti_id(wap_dti_id);
5951
5952 /* If transport layer is UDP, reset wap_call flag */
5953 if( satShrdPrm.chnTb.chnTPL EQ UDP )
5954 {
5955 cmhSM_disconnect_cid(cid, GC_TYPE_WAP );
5956 sAT_PercentWAP ( CMD_SRC_NONE, 0 );
5957 if(work_cids[cid_pointer] EQ cid)
5958 {
5959 smEntStat.curCmd = AT_CMD_NONE;
5960 *work_cids = 0;
5961 cid_pointer = 0;
5962 }
5963 }
5964
5965 /* clear parameters of dti connection */
5966 if(simShrdPrm.sat_class_e_dti_id NEQ DTI_DTI_ID_NOTPRESENT)
5967 {
5968 dti_cntrl_erase_entry(simShrdPrm.sat_class_e_dti_id);
5969 dti_cntrl_clear_conn_parms(simShrdPrm.sat_class_e_dti_id);
5970 simShrdPrm.sat_class_e_dti_id = DTI_DTI_ID_NOTPRESENT;
5971 TRACE_EVENT("sat_class_e_dti_id reset");
5972 }
5973
5974 }
5975 #endif /* GPRS */
5976 /*
5977 +-------------------------------------------------------------------+
5978 | PROJECT : GSM-PS (6147) MODULE : SAT |
5979 | ROUTINE : cmhSAT_OpChnSIMFail |
5980 +-------------------------------------------------------------------+
5981
5982 PURPOSE : This callback function will be called when the SIM entity
5983 has reported a failure
5984
5985 */
5986
5987 GLOBAL void cmhSAT_OpChnSIMFail( UBYTE dtiConn, UBYTE bipConn, UBYTE chnId )
5988 {
5989 #ifdef DTI
5990 T_SIM_SAT_CHN chnInf;
5991
5992 TRACE_FUNCTION("cmhSAT_OpChnSIMFail()");
5993
5994 /* if the channel is still open */
5995 if( bipConn & SIM_BIP_OPEN_CHANNEL )
5996 {
5997 chnInf.bipConn = SIM_BIP_CLOSE_CHANNEL;
5998 chnInf.dtiConn = SIM_DTI_UNKNOWN;
5999 chnInf.chnId = CHANNEL_ID_1;
6000 chnInf.genRes = RSLT_BEARIND_PERR;
6001 chnInf.addRes = ADD_BIP_NO_CHAN_AVAIL;
6002
6003 psaSIM_SATBIPChn( chnInf, cmhSAT_OpChnClose );
6004
6005 satShrdPrm.chnTb.lnkStat = SIM_LINK_OPEN;
6006 }
6007 /* if bearer is still in use */
6008 else if ( satShrdPrm.chnTb.chnUsdFlg )
6009 {
6010 /* if a CSD is still in progress */
6011 if( satShrdPrm.chnTb.chnType EQ B_CSD )
6012 {
6013 SHORT dummy;
6014
6015 cmhCC_ClearCall( satShrdPrm.chnTb.chnRefId,
6016 MNCC_CAUSE_CALL_CLEAR,
6017 satShrdPrm.opchAcptSrc,
6018 AT_CMD_NONE,
6019 &dummy);
6020 }
6021
6022 #ifdef GPRS
6023 /* if a GPRS context is still in progress */
6024 if( satShrdPrm.chnTb.chnType EQ B_GPRS )
6025 {
6026 SHORT cid_array[2] = { 0,INVALID_CID };
6027 cid_array[0] = satShrdPrm.chnTb.chnRefId;
6028
6029 sAT_PlusCGACT( satShrdPrm.opchAcptSrc,
6030 CGACT_STATE_DEACTIVATED, cid_array );
6031 }
6032 #endif /* GPRS */
6033 }
6034 #endif /* DTI */
6035 }
6036
6037 /*
6038 +-------------------------------------------------------------------+
6039 | PROJECT : GSM-PS (6147) MODULE : SAT |
6040 | ROUTINE : cmhSAT_OpChnChckCSD |
6041 +-------------------------------------------------------------------+
6042
6043 PURPOSE : This function is used to check if an open channel command
6044 for CSD with the given TPL is pending
6045
6046 */
6047
6048 GLOBAL BOOL cmhSAT_OpChnChckCSD( UBYTE tpl )
6049 {
6050
6051 /* in case of a SAT channel establishment */
6052 if( satShrdPrm.opchStat EQ OPCH_EST_REQ AND
6053 satShrdPrm.chnTb.chnTPL EQ tpl AND
6054 satShrdPrm.opchType EQ B_CSD )
6055 {
6056 return( TRUE );
6057 }
6058
6059 return( FALSE );
6060 }
6061
6062 /*
6063 +-------------------------------------------------------------------+
6064 | PROJECT : GSM-PS (6147) MODULE : SAT |
6065 | ROUTINE : cmhSAT_OpChnSIMCnctReq |
6066 +-------------------------------------------------------------------+
6067
6068 PURPOSE : This function is used to request a connection between SIM
6069 and the specified unit
6070 */
6071
6072 GLOBAL void cmhSAT_OpChnSIMCnctReq(UBYTE unit)
6073 {
6074 #ifdef DTI
6075 T_SIM_SAT_CHN chnInf;
6076
6077 TRACE_FUNCTION("cmhSAT_OpChnSIMCnctReq()");
6078
6079 if( satShrdPrm.opchStat EQ OPCH_EST_REQ )
6080 {
6081 /* DTI CHANNEL ESTABLISHMENT requested */
6082
6083 /* check for modification of bearer parameters */
6084 cmhSAT_OpChnChckBear();
6085
6086 /* setup channel info for PSA */
6087 chnInf.dtiUnit = unit;
6088 chnInf.chnId = CHANNEL_ID_1;
6089 chnInf.dtiConn = 0;
6090 chnInf.dtiConn = SIM_DTI_CONNECT;
6091
6092 if ( unit NEQ DTI_ENTITY_UDP )
6093 {
6094 /* init DTI channel for SIM -> SNDCP, L2R and TRA */
6095 psaSIM_SATChn( chnInf, cmhSAT_OpChnCnct );
6096 }
6097 else
6098 {
6099 /* prepare parameters for SIM -> UDP connection */
6100 /* copy settings into shrd prms */
6101 memcpy(&simShrdPrm.sim_dti_chPrm->sat_chn_prm,&chnInf,sizeof(T_SIM_SAT_CHN));
6102 /* callback for results of DTI connection has to be cmhSAT_OpChnCnct */
6103 simShrdPrm.sim_dti_chPrm->dti_cb = cmhSAT_OpChnCnct;
6104 }
6105 }
6106 #endif /* DTI */
6107 }
6108
6109 /*
6110 +-------------------------------------------------------------------+
6111 | PROJECT : GSM-PS (6147) MODULE : SAT |
6112 | ROUTINE : cmhSAT_OpChnChckBear |
6113 +-------------------------------------------------------------------+
6114
6115 PURPOSE : This function is used to check whether the bearer parameters
6116 differ from the orignal settings by the SAT command.
6117 If so, the new parameters will overwrite the settings in
6118 opchPrm and the opchPrmMdf will be set to TRUE.
6119
6120 */
6121
6122 GLOBAL void cmhSAT_OpChnChckBear(void)
6123 {
6124 UBYTE mt;
6125
6126 TRACE_FUNCTION("cmhSAT_OpChnChckBear()");
6127
6128 satShrdPrm.opchPrmMdf = FALSE;
6129
6130 /*
6131 *-------------------------------------------------------------------
6132 * for CSD bearer parameters
6133 *-------------------------------------------------------------------
6134 */
6135 if( satShrdPrm.chnTb.chnType EQ B_CSD )
6136 {
6137 T_CC_CALL_TBL * pCtbNtry;
6138 UBYTE cmdSpeed;
6139 UBYTE cmdName;
6140 UBYTE cmdCE;
6141 T_SAT_CSD_PRM *p = (T_SAT_CSD_PRM*)satShrdPrm.opchPrm;
6142
6143 if (!psaCC_ctbIsValid (satShrdPrm.chnTb.chnRefId))
6144 {
6145 /* Avoid to dereference NULL */
6146 TRACE_ERROR ("Call table entry disappeared");
6147 return;
6148 }
6149
6150 pCtbNtry = ccShrdPrm.ctb[satShrdPrm.chnTb.chnRefId];
6151
6152 if( !p->def_bear_prm )
6153 {
6154 cmdSpeed = cmhCC_SelRate(p->csd_bear_prm.csd_speed);
6155 cmdName = cmhCC_SelServ(p->csd_bear_prm.csd_name);
6156 cmdCE = cmhCC_SelCE (p->csd_bear_prm.csd_ce);
6157
6158 if((cmdSpeed NEQ pCtbNtry->BC[0].rate) OR
6159 (cmdName NEQ pCtbNtry->BC[0].bearer_serv) OR
6160 (cmdCE NEQ pCtbNtry->BC[0].conn_elem ))
6161 {
6162 satShrdPrm.opchPrmMdf = TRUE;
6163 }
6164 }
6165
6166 /* update bearer parms with current values */
6167 p->csd_bear_prm.csd_speed = (UBYTE)cmhCC_GetDataRate(&pCtbNtry->BC[0]);
6168 mt = pCtbNtry->BC[0].modem_type;
6169
6170 switch( pCtbNtry->BC[0].rate )
6171 {
6172 case( UR_0_3_KBIT ):
6173 if( mt EQ MT_V21 ) p->csd_bear_prm.csd_speed = BS_SPEED_300_V21;
6174 break;
6175 case( UR_1_2_KBIT ):
6176 if ( mt EQ MT_V22 ) p->csd_bear_prm.csd_speed = BS_SPEED_1200_V22;
6177 else if ( mt EQ MT_V23 ) p->csd_bear_prm.csd_speed = BS_SPEED_1200_75_V23;
6178 else if ( mt EQ MT_NONE ) p->csd_bear_prm.csd_speed = BS_SPEED_1200_V110;
6179 break;
6180 case( UR_2_4_KBIT ):
6181 if ( mt EQ MT_V22_BIS ) p->csd_bear_prm.csd_speed = BS_SPEED_2400_V22bis;
6182 else if ( mt EQ MT_V26_TER ) p->csd_bear_prm.csd_speed = BS_SPEED_2400_V26ter;
6183 else if ( mt EQ MT_NONE ) p->csd_bear_prm.csd_speed = BS_SPEED_2400_V110;
6184 break;
6185 case( UR_4_8_KBIT ):
6186 if ( mt EQ MT_V32 ) p->csd_bear_prm.csd_speed = BS_SPEED_4800_V32;
6187 else if ( mt EQ MT_NONE ) p->csd_bear_prm.csd_speed = BS_SPEED_4800_V110;
6188 break;
6189 case( UR_9_6_KBIT ):
6190 if ( mt EQ MT_V32 ) p->csd_bear_prm.csd_speed = BS_SPEED_9600_V32;
6191 else if ( mt EQ MT_V34 ) p->csd_bear_prm.csd_speed = BS_SPEED_9600_V34;
6192 else if ( mt EQ MT_NONE ) p->csd_bear_prm.csd_speed = BS_SPEED_9600_V110;
6193 break;
6194 case( UR_14_4_KBIT ):
6195 if ( mt EQ MT_V34 ) p->csd_bear_prm.csd_speed = BS_SPEED_14400_V34;
6196 else if ( mt EQ MT_NONE ) p->csd_bear_prm.csd_speed = BS_SPEED_14400_V110;
6197 break;
6198 default:
6199 break; /* leave it the way it is */
6200 }
6201
6202 switch( pCtbNtry->BC[0].bearer_serv )
6203 {
6204 case( BEARER_SERV_ASYNC ):
6205 p->csd_bear_prm.csd_name = CBST_NAM_Asynch; break;
6206
6207 case( BEARER_SERV_SYNC ):
6208 p->csd_bear_prm.csd_name = CBST_NAM_Synch; break;
6209
6210 default: break; /* leave it the way it is */
6211 }
6212
6213 switch( pCtbNtry->BC[0].conn_elem )
6214 {
6215 case( CONN_ELEM_TRANS ):
6216 p->csd_bear_prm.csd_ce = CBST_CE_Transparent; break;
6217
6218 case( CONN_ELEM_NON_TRANS ):
6219 p->csd_bear_prm.csd_ce = CBST_CE_NonTransparent; break;
6220
6221 default: break; /* leave it the way it is */
6222 }
6223 }
6224 /*
6225 *-------------------------------------------------------------------
6226 * for GPRS bearer parameters
6227 *-------------------------------------------------------------------
6228 */
6229 #ifdef GPRS
6230 if( satShrdPrm.chnTb.chnType EQ B_GPRS )
6231 {
6232 T_QOS* curQOS;
6233 T_SAT_GPRS_PRM *p = (T_SAT_GPRS_PRM*)satShrdPrm.opchPrm;
6234
6235 curQOS = cmhSM_getCurQOS( satShrdPrm.chnTb.chnRefId );
6236
6237 if( !p->def_bear_prm )
6238 {
6239 if((curQOS->preced NEQ p->gprs_bear_prm.gprs_prec) OR
6240 (curQOS->delay NEQ p->gprs_bear_prm.gprs_delay) OR
6241 (curQOS->relclass NEQ p->gprs_bear_prm.gprs_rely ) OR
6242 (curQOS->peak NEQ p->gprs_bear_prm.gprs_peak ) OR
6243 (curQOS->mean NEQ p->gprs_bear_prm.gprs_mean ) )
6244 {
6245 satShrdPrm.opchPrmMdf = TRUE;
6246 }
6247 }
6248 /* update bearer parms with current values */
6249 p->gprs_bear_prm.gprs_prec = curQOS->preced;
6250 p->gprs_bear_prm.gprs_delay = curQOS->delay;
6251 p->gprs_bear_prm.gprs_rely = curQOS->relclass;
6252 p->gprs_bear_prm.gprs_peak = curQOS->peak;
6253 p->gprs_bear_prm.gprs_mean = curQOS->mean;
6254 }
6255 #endif /* GPRS */
6256 }
6257 #ifdef DTI
6258 /*
6259 +-------------------------------------------------------------------+
6260 | PROJECT : GSM-PS (6147) MODULE : SAT |
6261 | ROUTINE : cmhSAT_OpChnSetPPP |
6262 +-------------------------------------------------------------------+
6263
6264 PURPOSE : This function is used to set up PPP parameters.
6265
6266 */
6267
6268 GLOBAL void cmhSAT_OpChnSetPPP(UBYTE chnType)
6269 {
6270
6271 CHAR log[PPP_LOGIN_NAME_LENGTH+1]; /* holds login name */
6272 CHAR pwd[PPP_LOGIN_NAME_LENGTH+1]; /* holds password */
6273
6274 T_SAT_CSD_PRM *p = (T_SAT_CSD_PRM*)satShrdPrm.opchPrm;
6275
6276 TRACE_FUNCTION("cmhSAT_OpChnSetPPP()");
6277
6278 log[0] = 0; /* empty login name */
6279 pwd[0] = 0; /* empty user name */
6280
6281 if( chnType EQ B_CSD )
6282 {
6283 /* set login name and password, if available */
6284 if(p->v_log AND p->log.c_text_str)
6285 {
6286 strncpy(pwd,(const CHAR *)p->log.text_str,MINIMUM(p->log.c_text_str, PPP_LOGIN_NAME_LENGTH));
6287 log[MINIMUM(p->log.c_text_str, PPP_LOGIN_NAME_LENGTH)] ='\0';
6288 }
6289
6290 if(p->v_pwd AND p->pwd.c_text_str)
6291 {
6292 strncpy(pwd,(const CHAR *)p->pwd.text_str,MINIMUM(p->pwd.c_text_str, PPP_LOGIN_NAME_LENGTH));
6293 pwd[MINIMUM(p->pwd.c_text_str, PPP_LOGIN_NAME_LENGTH)] ='\0';
6294 }
6295 }
6296
6297 sAT_PercentPPP( satShrdPrm.opchAcptSrc, A_PAP, log, pwd, USE_NO_PPP_FOR_AAA );
6298 }
6299 #endif /* DTI */
6300
6301 /*
6302 +-------------------------------------------------------------------+
6303 | PROJECT : GSM-PS (6147) MODULE : SAT |
6304 | ROUTINE : cmhSAT_OpChnStatEvnt |
6305 +-------------------------------------------------------------------+
6306
6307 PURPOSE : This function is used to send a channel status event if
6308 enabled by SAT
6309
6310 */
6311
6312 GLOBAL void cmhSAT_OpChnStatEvnt( void )
6313 {
6314
6315 TRACE_FUNCTION("cmhSAT_OpChnStatEvnt()");
6316
6317 if( psaSAT_ChkEventList( EVENT_CHAN_STAT ) )
6318 {
6319 cmhSAT_EventDwn( EVENT_CHAN_STAT, -1, NEAR_END );
6320 }
6321
6322 }
6323
6324 /*
6325 +-------------------------------------------------------------------+
6326 | PROJECT : GSM-PS (6147) MODULE : SAT |
6327 | ROUTINE : cmhSAT_OpChnGPRSPend |
6328 +-------------------------------------------------------------------+
6329
6330 PURPOSE : This function is used to check for a pending GPRS open
6331 channel command.
6332
6333 */
6334 #ifdef GPRS
6335 GLOBAL BOOL cmhSAT_OpChnGPRSPend( SHORT cid, UBYTE opchStat )
6336 {
6337 if( satShrdPrm.chnTb.chnUsdFlg AND
6338 satShrdPrm.chnTb.chnType EQ B_GPRS AND
6339 (opchStat EQ OPCH_NONE OR opchStat EQ satShrdPrm.opchStat)AND
6340 (cid EQ INVALID_CID OR cid EQ satShrdPrm.chnTb.chnRefId))
6341
6342 return( TRUE );
6343
6344 else
6345
6346 return( FALSE );
6347 }
6348 #endif /* GPRS */
6349
6350 /*
6351 +-------------------------------------------------------------------+
6352 | PROJECT : GSM-PS (6147) MODULE : SAT |
6353 | ROUTINE : cmhSAT_OpChnUDPActivateGprs |
6354 +-------------------------------------------------------------------+
6355
6356 PURPOSE : This function is used to activate the UDP data chain and
6357 GPRS context.
6358
6359 */
6360 #if defined (GPRS) AND defined (DTI)
6361 GLOBAL void cmhSAT_OpChnUDPActivateGprs( void )
6362 {
6363 SHORT cid_array[2] = { 0,INVALID_CID };
6364 T_ACI_SAT_TERM_RESP resp_data;
6365
6366 TRACE_FUNCTION("cmhSAT_OpChnUDPActivateGprs()");
6367
6368 cid_array[0] = satShrdPrm.chnTb.chnRefId;
6369
6370 /* final check of context id and link status */
6371 if(!cmhSM_define_cid_list((T_ACI_CMD_SRC)satShrdPrm.opchAcptSrc, cid_array ) OR
6372 !srcc_reserve_sources( SRCC_IP_SNDCP_LINK, satShrdPrm.chnTb.chnRefId))
6373 {
6374 psaSAT_InitTrmResp( &resp_data );
6375 resp_data.add_content = ADD_BIP_NO_CHAN_AVAIL;
6376 cmhSAT_OpChnFailed( RSLT_BEARIND_PERR, &resp_data );
6377 }
6378
6379 srcc_new_count(SRCC_IP_SNDCP_LINK);
6380
6381 /* create a SAT class E DTI ID if not present */
6382 if ( simShrdPrm.sat_class_e_dti_id EQ DTI_DTI_ID_NOTPRESENT )
6383 {
6384 simShrdPrm.sat_class_e_dti_id = dti_cntrl_new_dti(DTI_DTI_ID_NOTPRESENT);
6385 TRACE_EVENT_P1("sat_class_e_dti_id = %d", simShrdPrm.sat_class_e_dti_id);
6386 }
6387
6388 /* get dti id for SNDCP/IP link */
6389 pdp_context[satShrdPrm.chnTb.chnRefId-1].link_id_new =
6390 dti_conn_compose_link_id (0,0, simShrdPrm.sat_class_e_dti_id, DTI_TUPLE_NO_NOTPRESENT);
6391
6392 /* send request to ACI WAP to activate WAP */
6393 smEntStat.entOwn = smShrdPrm.owner = satShrdPrm.opchAcptSrc;
6394 smEntStat.curCmd = AT_CMD_CGACT;
6395
6396 psaTCPIP_Activate( satShrdPrm.opchAcptSrc,
6397 simShrdPrm.sat_class_e_dti_id,
6398 0, TCPIP_ACT_OPTION_V4 | TCPIP_ACT_OPTION_UDP,
6399 TCPIP_CONNECTION_TYPE_GPRS_WAP,
6400 cmhSM_IP_activate_cb);
6401
6402 }
6403 #endif /* GPRS */
6404
6405 /*
6406 +-------------------------------------------------------------------+
6407 | PROJECT : GSM-PS (6147) MODULE : SAT |
6408 | ROUTINE : cmhSAT_OpChnUDPConfGprs |
6409 +-------------------------------------------------------------------+
6410
6411 PURPOSE : This callback function will be called when the UDP stack
6412 is configured
6413
6414 */
6415
6416 #if defined(GPRS)
6417 GLOBAL void cmhSAT_OpChnUDPConfGprs(void)
6418 {
6419
6420 TRACE_FUNCTION("cmhSAT_OpChnUDPConfGprs()");
6421 /*
6422 * send the SIM_BIP_CONFIG_REQ primitive providing details of the connection
6423 * to SIM
6424 */
6425 psaSIM_Bip_Config_Req();
6426
6427 }
6428 #endif /* GPRS */
6429
6430 /*
6431 +-------------------------------------------------------------------+
6432 | PROJECT : GSM-PS (6147) MODULE : SAT |
6433 | ROUTINE : cmhSAT_OpChnUDPDeactGprs|
6434 +-------------------------------------------------------------------+
6435
6436 PURPOSE : This callback function will be called when the UDP stack
6437 is deactive
6438
6439 */
6440
6441 #if defined(GPRS)
6442 GLOBAL void cmhSAT_OpChnUDPDeactGprs(void)
6443 {
6444 T_ACI_SAT_TERM_RESP resp_data; /* holds terminal response parms */
6445 UBYTE cause;
6446
6447 TRACE_FUNCTION("cmhSAT_OpChnUDPDeactGprs()");
6448
6449 psaSAT_InitTrmResp( &resp_data );
6450
6451 /*
6452 *-------------------------------------------------------------------
6453 * check if deactivation was intended
6454 *-------------------------------------------------------------------
6455 */
6456 if( satShrdPrm.opchStat EQ OPCH_CLS_REQ )
6457 {
6458 /* nothing to do here anymore */
6459 }
6460
6461 /*
6462 *-------------------------------------------------------------------
6463 * deactivation during an establish request
6464 *-------------------------------------------------------------------
6465 */
6466 else if( satShrdPrm.opchStat EQ OPCH_EST_REQ )
6467 {
6468 if( satShrdPrm.gprsNtwCs )
6469 {
6470 resp_data.add_content = satShrdPrm.gprsNtwCs | 0x80;
6471
6472 cause = RSLT_NTW_UNAB_PROC;
6473 }
6474 else
6475 {
6476 resp_data.add_content = ADD_NO_CAUSE;
6477 cause = RSLT_ME_UNAB_PROC;
6478 }
6479
6480 cmhSAT_OpChnFailed( cause, &resp_data );
6481 }
6482 }
6483 #endif /* GPRS */
6484
6485 /*
6486 +-------------------------------------------------------------------+
6487 | PROJECT : GPRS (8441) MODULE : CMH_SMF |
6488 | STATE : finished ROUTINE : cmhSAT_OpChnGPRSStat |
6489 +-------------------------------------------------------------------+
6490
6491 PURPOSE : This function will be called if the status of the requested
6492 GPRS context has changed.
6493
6494 */
6495 #if defined (GPRS) AND defined (DTI)
6496 GLOBAL void cmhSAT_OpChnGPRSStat(T_SAT_GPRS_CB_STAT stat, UBYTE cause)
6497 {
6498 T_ACI_SAT_TERM_RESP resp_data; /* holds terminal response parms */
6499 T_SIM_SAT_CHN chnInf;
6500
6501 TRACE_FUNCTION ("cmhSAT_OpChnGPRSStat()");
6502
6503 if( cause ) satShrdPrm.gprsNtwCs = cause;
6504
6505 /* in case of UDP, we will wait for the UDP status */
6506 if( satShrdPrm.chnTb.chnTPL EQ UDP AND
6507 stat NEQ SAT_GPRS_SUSPEND AND
6508 stat NEQ SAT_GPRS_RESUME)
6509
6510 return;
6511
6512 psaSAT_InitTrmResp( &resp_data );
6513
6514 /*
6515 *-------------------------------------------------------------------
6516 * during a close channel request
6517 *-------------------------------------------------------------------
6518 */
6519 if( satShrdPrm.opchStat EQ OPCH_CLS_REQ )
6520 {
6521 /* nothing to do here anymore */
6522 }
6523
6524 /*
6525 *-------------------------------------------------------------------
6526 * during an open channel establish request
6527 *-------------------------------------------------------------------
6528 */
6529 else if( satShrdPrm.opchStat EQ OPCH_EST_REQ )
6530 {
6531 switch ( stat )
6532 {
6533 case( SAT_GPRS_DEACT ):
6534 case( SAT_GPRS_ATT_FAILED ):
6535 case( SAT_GPRS_ACT_FAILED ):
6536
6537 if( satShrdPrm.gprsNtwCs )
6538 {
6539 resp_data.add_content = satShrdPrm.gprsNtwCs | 0x80;
6540
6541 cause = RSLT_NTW_UNAB_PROC;
6542 }
6543 else
6544 {
6545 resp_data.add_content = ADD_NO_CAUSE;
6546 cause = RSLT_ME_UNAB_PROC;
6547 }
6548
6549 cmhSAT_OpChnFailed( cause, &resp_data );
6550 break;
6551
6552 case( SAT_GPRS_SUSPEND ):
6553
6554 if( psaSS_stbFindActSrv( NO_ENTRY ) NEQ NO_ENTRY )
6555 {
6556 TRACE_EVENT("SAT GPRS channel suspend, SS busy");
6557 resp_data.add_content = ADD_ME_SS_BUSY;
6558 }
6559
6560 /* check for busy call condition */
6561 else if( psaSAT_ctbFindActCall() NEQ NO_ENTRY )
6562 {
6563 TRACE_EVENT("SAT GPRS channel suspend, busy on call");
6564 resp_data.add_content = ADD_ME_CALL_BUSY;
6565 }
6566
6567 cmhSAT_OpChnFailed( RSLT_ME_UNAB_PROC, &resp_data );
6568 break;
6569
6570 case( SAT_GPRS_ACT ):
6571
6572 cmhSAT_OpChnSIMCnctReq( DTI_ENTITY_SNDCP );
6573 break;
6574
6575 default:
6576
6577 break;
6578 }
6579 }
6580 /*
6581 *-------------------------------------------------------------------
6582 * expected status change
6583 *-------------------------------------------------------------------
6584 */
6585 else
6586 {
6587 switch ( stat )
6588 {
6589 case( SAT_GPRS_DEACT ):
6590 case( SAT_GPRS_ATT_FAILED ):
6591 case( SAT_GPRS_ACT_FAILED ):
6592
6593 resp_data.add_content = ADD_BIP_CHAN_CLOSD;
6594 cmhSAT_OpChnFailed( RSLT_BEARIND_PERR, &resp_data );
6595 break;
6596
6597 case( SAT_GPRS_SUSPEND ):
6598
6599 chnInf.addRes = ADD_NO_CAUSE;
6600
6601 if( satShrdPrm.chnTb.lnkStat EQ SIM_LINK_OPEN OR
6602 satShrdPrm.chnTb.lnkStat EQ SIM_LINK_CNCT )
6603 {
6604 if( psaSS_stbFindActSrv( NO_ENTRY ) NEQ NO_ENTRY )
6605 {
6606 TRACE_EVENT("SAT GPRS channel suspend, SS busy");
6607 chnInf.addRes = ADD_ME_SS_BUSY;
6608 }
6609
6610 /* check for busy call condition */
6611 else if( psaSAT_ctbFindActCall() NEQ NO_ENTRY )
6612 {
6613 TRACE_EVENT("SAT GPRS channel suspend, busy on call");
6614 chnInf.addRes = ADD_ME_CALL_BUSY;
6615 }
6616
6617 /* setup channel info for PSA */
6618 chnInf.chnId = CHANNEL_ID_1;
6619 chnInf.genRes = RSLT_ME_UNAB_PROC;
6620 chnInf.bipConn = SIM_BIP_CHANNEL_SUSPENDED;
6621 chnInf.dtiConn = SIM_DTI_UNKNOWN;
6622
6623 psaSIM_SATBIPChn( chnInf, NULL );
6624 }
6625 break;
6626
6627 case( SAT_GPRS_RESUME ):
6628
6629 if( satShrdPrm.chnTb.lnkStat EQ SIM_LINK_OPEN OR
6630 satShrdPrm.chnTb.lnkStat EQ SIM_LINK_CNCT )
6631 {
6632 /* setup channel info for PSA */
6633 chnInf.chnId = CHANNEL_ID_1;
6634 chnInf.genRes = RSLT_PERF_SUCCESS;
6635 chnInf.addRes = ADD_NO_CAUSE;
6636 chnInf.bipConn = SIM_BIP_CHANNEL_RESUMED;
6637 chnInf.dtiConn = SIM_DTI_UNKNOWN;
6638
6639 psaSIM_SATBIPChn( chnInf, NULL );
6640 }
6641 break;
6642
6643 case( SAT_GPRS_ACT ):
6644 default:
6645
6646 break;
6647 }
6648 }
6649
6650 }
6651 #endif /* GPRS */
6652 /*
6653 +-------------------------------------------------------------------+
6654 | PROJECT : GPRS (8441) MODULE : CMH_SMF |
6655 | STATE : finished ROUTINE : cmhSAT_cnvrtAPN2NetworkAdr|
6656 +-------------------------------------------------------------------+
6657
6658 PURPOSE : converts a APN with a given length into a null terminated
6659 domain name
6660
6661 */
6662
6663 #ifdef GPRS
6664 GLOBAL void cmhSAT_cnvrtAPN2NetworkAdr( UBYTE *apn, UBYTE c_apn, UBYTE *dom_name )
6665 {
6666 UBYTE lblLen;
6667 UBYTE apnIdx = 0;
6668 UBYTE dnIdx = 0;
6669
6670 TRACE_FUNCTION ("cmhSAT_cnvrtAPN2NetworkAdr()");
6671
6672 while( apnIdx < c_apn )
6673 {
6674 lblLen = apn[apnIdx++];
6675
6676 memcpy( &dom_name[dnIdx], &apn[apnIdx], lblLen );
6677
6678 dnIdx += lblLen;
6679 apnIdx += lblLen;
6680
6681 dom_name[dnIdx++] = '.';
6682 }
6683
6684 dom_name[dnIdx-1] = 0;
6685 }
6686 #endif /* GPRS */
6687
6688 #endif /* FF_SAT_E */
6689
6690 #endif /* SIM_TOOLKIT */
6691 /*==== EOF ========================================================*/