FreeCalypso > hg > leo2moko-debug
comparison g23m/condat/ms/src/aci/psa_ssp.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 : PSA_SSP | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : This module defines the processing functions for the | |
18 | primitives send to the protocol stack adapter by | |
19 | supplementary service. | |
20 +----------------------------------------------------------------------------- | |
21 */ | |
22 | |
23 #ifndef PSA_SSP_C | |
24 #define PSA_SSP_C | |
25 #endif | |
26 | |
27 #include "aci_all.h" | |
28 | |
29 /*==== INCLUDES ===================================================*/ | |
30 #include "aci_cmh.h" | |
31 #include "ati_cmd.h" | |
32 #include "aci_cmd.h" | |
33 | |
34 #include "ksd.h" | |
35 #include "aci.h" | |
36 #include "psa.h" | |
37 #include "psa_ss.h" | |
38 | |
39 #ifdef SIM_TOOLKIT | |
40 #include "psa_cc.h" | |
41 #include "psa_sat.h" | |
42 #endif | |
43 | |
44 #include "cmh_ss.h" | |
45 #include "aci_mem.h" | |
46 | |
47 /*==== CONSTANTS ==================================================*/ | |
48 | |
49 | |
50 /*==== TYPES ======================================================*/ | |
51 | |
52 | |
53 /*==== EXPORT =====================================================*/ | |
54 | |
55 | |
56 /*==== VARIABLES ==================================================*/ | |
57 | |
58 | |
59 /*==== FUNCTIONS ==================================================*/ | |
60 | |
61 | |
62 /* | |
63 +-------------------------------------------------------------------+ | |
64 | PROJECT : GSM-PS (6147) MODULE : PSA_SSP | | |
65 | ROUTINE : psa_mnss_begin_ind | | |
66 +-------------------------------------------------------------------+ | |
67 | |
68 PURPOSE : processes the MNSS_BEGIN_IND primitive send by SS. | |
69 this indicates an incoming service transaction. | |
70 | |
71 */ | |
72 | |
73 GLOBAL const void psa_mnss_begin_ind | |
74 ( T_MNSS_BEGIN_IND *mnss_begin_ind ) | |
75 { | |
76 SHORT sId; /* holds service id */ | |
77 T_SS_SRV_TBL * pStbNtry; /* holds pointer to service table entry */ | |
78 | |
79 TRACE_FUNCTION ("psa_mnss_begin_ind()"); | |
80 | |
81 /* | |
82 *------------------------------------------------------------------- | |
83 * check for new entry in service table | |
84 *------------------------------------------------------------------- | |
85 */ | |
86 psaSS_DumpFIE ( &mnss_begin_ind -> fac_inf ); | |
87 cmhSS_sendFie( CSCN_FACILITY_DIRECTION_IN, | |
88 CSCN_FACILITY_TRANS_TYPE_BEGIN, | |
89 &mnss_begin_ind -> fac_inf); | |
90 | |
91 sId = psaSS_stbNewEntry(); | |
92 | |
93 if( sId < 0 ) | |
94 { | |
95 TRACE_EVENT ("MTS rejected due to full service table"); | |
96 | |
97 return; | |
98 } | |
99 | |
100 /* | |
101 *------------------------------------------------------------------- | |
102 * update shared parameter and notify ACI | |
103 *------------------------------------------------------------------- | |
104 */ | |
105 pStbNtry = &ssShrdPrm.stb[sId]; | |
106 | |
107 pStbNtry -> ntryUsdFlg = TRUE; | |
108 pStbNtry -> ti = mnss_begin_ind -> ti; | |
109 | |
110 pStbNtry -> srvStat = SSS_ACT; | |
111 pStbNtry -> srvType = ST_MTS; | |
112 | |
113 psaSS_chngSrvTypCnt( sId, +1 ); | |
114 | |
115 /* | |
116 *------------------------------------------------------------------- | |
117 * decode component type | |
118 *------------------------------------------------------------------- | |
119 */ | |
120 CCD_START; | |
121 { | |
122 UBYTE ccdRet; | |
123 | |
124 MCAST( com, COMPONENT ); /* T_COMPONENT *com = (T_COMPONENT *)_decodedMsg; */ | |
125 memset( com, 0, sizeof( T_COMPONENT )); | |
126 | |
127 ccdRet = ccd_decodeMsg (CCDENT_FAC, | |
128 DOWNLINK, | |
129 (T_MSGBUF *) &mnss_begin_ind -> fac_inf, | |
130 (UBYTE *) _decodedMsg, | |
131 COMPONENT); | |
132 if( ccdRet NEQ ccdOK ) | |
133 { | |
134 TRACE_EVENT_P1( "CCD Decoding Error: %d",ccdRet ); | |
135 ssShrdPrm.stb[sId].failType = SSF_CCD_DEC; | |
136 cmhSS_TransFail(sId); | |
137 } | |
138 else | |
139 { | |
140 /* use prim buffer as further decoding buffer */ | |
141 ssFIEDecodeBuf = mnss_begin_ind -> fac_inf.fac; | |
142 | |
143 if( com->v_inv_comp ) | |
144 { | |
145 T_COMPONENT *psCopyOfCom; | |
146 ACI_MALLOC( psCopyOfCom, sizeof(T_COMPONENT) ); | |
147 /* now copy the com content for second CCD process */ | |
148 memcpy( psCopyOfCom, com, sizeof(T_COMPONENT) ); | |
149 psaSS_dasmInvokeCmp( sId, &(psCopyOfCom->inv_comp) ); | |
150 ACI_MFREE(psCopyOfCom); | |
151 } | |
152 else | |
153 { | |
154 TRACE_EVENT( "WRONG COMPONENT TYPE RECEIVED" ); | |
155 } | |
156 } | |
157 } | |
158 CCD_END; | |
159 /* | |
160 *------------------------------------------------------------------- | |
161 * free primitive | |
162 *------------------------------------------------------------------- | |
163 */ | |
164 ssFIEDecodeBuf = NULL; | |
165 PFREE (mnss_begin_ind); | |
166 } | |
167 | |
168 /* | |
169 +-------------------------------------------------------------------+ | |
170 | PROJECT : GSM-PS (6147) MODULE : PSA_SSP | | |
171 | ROUTINE : psa_mnss_end_ind | | |
172 +-------------------------------------------------------------------+ | |
173 | |
174 PURPOSE : processes the MNSS_END_IND primitive send by SS. | |
175 this indicates the end of a service transaction. | |
176 | |
177 */ | |
178 | |
179 GLOBAL const void psa_mnss_end_ind( T_MNSS_END_IND *mnss_end_ind ) | |
180 { | |
181 SHORT sId; /* holds service id */ | |
182 T_SS_SRV_TBL *pStbNtry; /* holds pointer to service table entry */ | |
183 SHORT pending_sId; /* holds second id if there is one */ | |
184 BOOL error_occured = TRUE; /* only in positive case will it be set to TRUE */ | |
185 BOOL this_is_a_ussd_string; | |
186 T_ACI_RETURN ss_return; | |
187 | |
188 TRACE_FUNCTION ("psa_mnss_end_ind()"); | |
189 | |
190 /* trace facility */ | |
191 psaSS_DumpFIE ( &mnss_end_ind -> fac_inf ); | |
192 cmhSS_sendFie ( CSCN_FACILITY_DIRECTION_IN, | |
193 CSCN_FACILITY_TRANS_TYPE_END, | |
194 &mnss_end_ind -> fac_inf); | |
195 | |
196 #ifdef SIM_TOOLKIT | |
197 /* reinitalize. */ | |
198 satShrdPrm.sId_pwd_requested = NO_ENTRY; | |
199 #endif /* SIM_TOOLKIT */ | |
200 | |
201 /* find service in service table */ | |
202 sId = psaSS_stbFindTi( mnss_end_ind -> ti ); | |
203 | |
204 if( sId < 0 ) | |
205 { | |
206 /* ignore primitive, due to not found transaction identifier. */ | |
207 TRACE_EVENT ("primitive rejected due to unused ti"); | |
208 PFREE(mnss_end_ind); | |
209 return; | |
210 } | |
211 | |
212 /* update shared parameter */ | |
213 pStbNtry = &ssShrdPrm.stb[sId]; | |
214 | |
215 pStbNtry -> failType = SSF_SS_ENT; | |
216 pStbNtry -> entCs = mnss_end_ind -> cause; | |
217 | |
218 pStbNtry -> srvStat = SSS_IDL; | |
219 | |
220 psaSS_chngSrvTypCnt( sId, -1 ); | |
221 psaSS_retMOSTi( sId ); | |
222 | |
223 /****** Is this a USSD operation ? ****/ | |
224 if( ssShrdPrm.stb[sId].curCmd EQ AT_CMD_CUSD OR | |
225 ssShrdPrm.stb[sId].curCmd EQ KSD_CMD_USSD ) | |
226 { | |
227 this_is_a_ussd_string = TRUE; | |
228 } | |
229 #ifdef SIM_TOOLKIT | |
230 else if( ssShrdPrm.stb[sId].srvOwn EQ OWN_SAT AND | |
231 sId EQ satShrdPrm.SentUSSDid ) | |
232 { | |
233 /* SAT send USSD case */ | |
234 this_is_a_ussd_string = TRUE; | |
235 } | |
236 #endif /* SIM_TOOLKIT */ | |
237 else | |
238 this_is_a_ussd_string = FALSE; | |
239 /************************************/ | |
240 | |
241 | |
242 /****** check error cause ***********/ | |
243 TRACE_EVENT_P1 ("SS end indication cause: %d", mnss_end_ind -> cause); | |
244 | |
245 if( mnss_end_ind->cause EQ MNSS_CAUSE_FACILITY_REJECT ) | |
246 { | |
247 TRACE_EVENT("Facility has been rejected"); | |
248 | |
249 /* check for protocol incompatibility for USSD */ | |
250 if( this_is_a_ussd_string AND | |
251 psaSS_asmUSSDProt1(sId) ) | |
252 { | |
253 /* facility with Protocole 1 format has been sent: wait for answer */ | |
254 } | |
255 else | |
256 { | |
257 cmhSS_TransFail(sId); | |
258 } | |
259 PFREE (mnss_end_ind); | |
260 return; | |
261 } | |
262 /************************************/ | |
263 | |
264 #ifdef SIM_TOOLKIT | |
265 /* if SIM TOOLKIT and empty facility send send error to SAT | |
266 (but should have checked USSD compatibility BEFORE) */ | |
267 if( (ssShrdPrm.stb[sId].srvOwn EQ OWN_SAT) AND | |
268 (mnss_end_ind -> fac_inf.l_fac EQ 0) ) | |
269 { | |
270 cmhSS_TransFail(sId); | |
271 PFREE (mnss_end_ind); | |
272 return; | |
273 } | |
274 #endif /* SIM_TOOLKIT */ | |
275 | |
276 | |
277 /*************************/ | |
278 /* decode component type */ | |
279 CCD_START; | |
280 { | |
281 UBYTE ccdRet; | |
282 T_COMPONENT *psCopyOfCom; | |
283 BOOL is_critical_warning = FALSE; | |
284 | |
285 MCAST( com, COMPONENT ); /* T_COMPONENT *com = (T_COMPONENT *)_decodedMsg; */ | |
286 memset( com, 0, sizeof( T_COMPONENT )); | |
287 | |
288 | |
289 ccdRet = ccd_decodeMsg (CCDENT_FAC, | |
290 DOWNLINK, | |
291 (T_MSGBUF *) &mnss_end_ind -> fac_inf, | |
292 (UBYTE *) _decodedMsg, | |
293 COMPONENT); | |
294 if( ccdRet NEQ ccdOK ) | |
295 { | |
296 if (ccdRet EQ ccdWarning) | |
297 { | |
298 UBYTE ccd_err; | |
299 USHORT parlist [6]; | |
300 | |
301 ccd_err = ccd_getFirstError (CCDENT_SS, parlist); | |
302 | |
303 do | |
304 { | |
305 switch (ccd_err) | |
306 { | |
307 case ERR_LEN_MISMATCH: /* recoverable warnings */ | |
308 break; | |
309 default: | |
310 is_critical_warning = TRUE; /* critical warning */ | |
311 } | |
312 ccd_err = ccd_getNextError (CCDENT_SS, parlist); | |
313 }while (ccd_err NEQ ERR_NO_MORE_ERROR); | |
314 } | |
315 | |
316 if((ccdRet EQ ccdError) OR is_critical_warning) | |
317 { | |
318 TRACE_EVENT_P1("CCD Decoding Error: %d", ccdRet); | |
319 ssShrdPrm.stb[sId].failType = SSF_CCD_DEC; | |
320 cmhSS_TransFail(sId); | |
321 CCD_END; | |
322 PFREE (mnss_end_ind); | |
323 return; | |
324 } | |
325 } | |
326 | |
327 /* use prim buffer as further decoding buffer */ | |
328 ssFIEDecodeBuf = mnss_end_ind -> fac_inf.fac; | |
329 | |
330 ACI_MALLOC( psCopyOfCom, sizeof(T_COMPONENT) ); | |
331 /* now copy the com content for second CCD process */ | |
332 memcpy( psCopyOfCom, com, sizeof(T_COMPONENT) ); | |
333 | |
334 #ifdef SIM_TOOLKIT | |
335 if( ssShrdPrm.stb[sId].srvOwn EQ OWN_SAT ) | |
336 { | |
337 ss_return = psaSAT_ss_end_ind( sId, psCopyOfCom, mnss_end_ind, this_is_a_ussd_string ); | |
338 } | |
339 else | |
340 #endif /* SIM_TOOLKIT */ | |
341 { | |
342 ss_return = psaSS_ss_end_ind( sId, psCopyOfCom, this_is_a_ussd_string ); | |
343 } | |
344 | |
345 ACI_MFREE(psCopyOfCom); | |
346 | |
347 switch(ss_return) | |
348 { | |
349 case(AT_CMPL): | |
350 /* facility with Protocole 1 format has been sent: wait for answer */ | |
351 CCD_END; | |
352 PFREE (mnss_end_ind); | |
353 return; | |
354 | |
355 case(AT_EXCT): | |
356 /* if more than one transactions were intended, send next one */ | |
357 if ( ssShrdPrm.mltyTrnFlg ) | |
358 { | |
359 /* no error occured, then send next one */ | |
360 pending_sId = psaSS_GetPendingTrn( ); | |
361 /* unsent id flag */ | |
362 ssShrdPrm.mltyTrnFlg &= ~( 1u << pending_sId ); | |
363 /* send pending primitive */ | |
364 PSENDX (SS, ssShrdPrm.stb[pending_sId].save_prim ); | |
365 } | |
366 break; | |
367 | |
368 default: | |
369 cmhSS_TransFail(sId); | |
370 break; | |
371 } | |
372 } | |
373 CCD_END; | |
374 PFREE (mnss_end_ind); | |
375 } | |
376 | |
377 /* | |
378 +-------------------------------------------------------------------+ | |
379 | PROJECT : GSM-PS (6147) MODULE : PSA_SSP | | |
380 | ROUTINE : psa_mnss_facility_ind | | |
381 +-------------------------------------------------------------------+ | |
382 | |
383 PURPOSE : processes the MNSS_FACILITY_IND primitive send by SS. | |
384 this indicates the receiving of a facility information | |
385 element. | |
386 | |
387 */ | |
388 | |
389 GLOBAL const void psa_mnss_facility_ind | |
390 ( T_MNSS_FACILITY_IND *mnss_facility_ind ) | |
391 { | |
392 SHORT sId; /* holds call id */ | |
393 T_SS_SRV_TBL * pStbNtry; /* holds pointer to service table entry */ | |
394 | |
395 TRACE_FUNCTION ("psa_mnss_facility_ind()"); | |
396 | |
397 /* | |
398 *------------------------------------------------------------------- | |
399 * find call in call table | |
400 *------------------------------------------------------------------- | |
401 */ | |
402 psaSS_DumpFIE ( &mnss_facility_ind -> fac_inf ); | |
403 cmhSS_sendFie ( CSCN_FACILITY_DIRECTION_IN, | |
404 CSCN_FACILITY_TRANS_TYPE, | |
405 &mnss_facility_ind -> fac_inf); | |
406 | |
407 sId = psaSS_stbFindTi( mnss_facility_ind -> ti ); | |
408 | |
409 if( sId < 0 ) | |
410 { | |
411 /* | |
412 * ignore primitive, due to not found transaction identifier. | |
413 */ | |
414 TRACE_EVENT ("primitive rejected due to unused ti"); | |
415 PFREE(mnss_facility_ind); | |
416 return; | |
417 } | |
418 | |
419 /* | |
420 *------------------------------------------------------------------- | |
421 * update shared parameter and notify ACI | |
422 *------------------------------------------------------------------- | |
423 */ | |
424 pStbNtry = &ssShrdPrm.stb[sId]; | |
425 | |
426 /* | |
427 *------------------------------------------------------------------- | |
428 * decode component type | |
429 *------------------------------------------------------------------- | |
430 */ | |
431 CCD_START; | |
432 { | |
433 UBYTE ccdRet; | |
434 | |
435 MCAST( com, COMPONENT ); /* T_COMPONENT *com = (T_COMPONENT *)_decodedMsg; */ | |
436 memset( com, 0, sizeof( T_COMPONENT )); | |
437 | |
438 ccdRet = ccd_decodeMsg (CCDENT_FAC, | |
439 DOWNLINK, | |
440 (T_MSGBUF *) &mnss_facility_ind -> fac_inf, | |
441 (UBYTE *) _decodedMsg, | |
442 COMPONENT); | |
443 if( ccdRet NEQ ccdOK ) | |
444 { | |
445 TRACE_EVENT_P1( "CCD Decoding Error: %d",ccdRet ); | |
446 ssShrdPrm.stb[sId].failType = SSF_CCD_DEC; | |
447 cmhSS_TransFail(sId); | |
448 } | |
449 else | |
450 { | |
451 T_COMPONENT *psCopyOfCom; | |
452 ACI_MALLOC( psCopyOfCom, sizeof(T_COMPONENT) ); | |
453 /* now copy the com content for second CCD process */ | |
454 memcpy( psCopyOfCom, com, sizeof(T_COMPONENT) ); | |
455 | |
456 /* use prim buffer as further decoding buffer */ | |
457 ssFIEDecodeBuf = mnss_facility_ind -> fac_inf.fac; | |
458 | |
459 if( com->v_inv_comp) | |
460 { | |
461 psaSS_dasmInvokeCmp( sId, &(psCopyOfCom->inv_comp) ); | |
462 } | |
463 else if (com->v_res_comp) | |
464 { | |
465 psaSS_dasmResultCmp( sId, &(psCopyOfCom->res_comp) ); | |
466 } | |
467 else | |
468 { | |
469 TRACE_EVENT( "WRONG COMPONENT TYPE RECEIVED" ); | |
470 } | |
471 | |
472 ACI_MFREE(psCopyOfCom); | |
473 } | |
474 } | |
475 CCD_END; | |
476 /* | |
477 *------------------------------------------------------------------- | |
478 * free the primitive buffer | |
479 *------------------------------------------------------------------- | |
480 */ | |
481 PFREE (mnss_facility_ind); | |
482 } | |
483 | |
484 | |
485 /*==== EOF =========================================================*/ |