comparison g23m-aci/aci/psa_ssp.c @ 0:75a11d740a02

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