comparison gsm-fw/g23m-aci/aci/psa_ssp.c @ 775:eedbf248bac0

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