FreeCalypso > hg > fc-magnetite
comparison src/aci2/aci/psa_ssf.c @ 3:93999a60b835
src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 26 Sep 2016 00:29:36 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:c41a534f33c6 | 3:93999a60b835 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GSM-PS (6147) | |
4 | Modul : PSA_SSF | |
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 functions for the protocol | |
18 | stack adapter for supplementary services. | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 #ifndef PSA_SSF_C | |
23 #define PSA_SSF_C | |
24 #endif | |
25 | |
26 #include "aci_all.h" | |
27 | |
28 #undef TRACING | |
29 | |
30 /*==== INCLUDES ===================================================*/ | |
31 #include "aci_cmh.h" | |
32 #include "ati_cmd.h" | |
33 #include "aci_cmd.h" | |
34 | |
35 #include "ksd.h" | |
36 #include "aci.h" | |
37 #include "psa.h" | |
38 #include "psa_ss.h" | |
39 #include "psa_util.h" | |
40 #include "cmh_ss.h" | |
41 | |
42 /*==== CONSTANTS ==================================================*/ | |
43 #define MAX_MOSTI_NR (7) /* max number of ti's for MOS */ | |
44 | |
45 #define MAX_ITM (5) /* max number of items per line */ | |
46 #define ITM_WDT (14) /* item width in chars */ | |
47 #define HDR_WDT (10) /* header width in chars */ | |
48 | |
49 /*==== TYPES ======================================================*/ | |
50 | |
51 | |
52 /*==== EXPORT =====================================================*/ | |
53 | |
54 /*==== VARIABLES ==================================================*/ | |
55 LOCAL UBYTE tiPool = 0xFF; /* holds pool of transaction identifiers */ | |
56 | |
57 /*==== FUNCTIONS ==================================================*/ | |
58 | |
59 /* | |
60 +-------------------------------------------------------------------+ | |
61 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
62 | ROUTINE : psaSS_asmEmptyRslt | | |
63 +-------------------------------------------------------------------+ | |
64 | |
65 PURPOSE : assemble an empty return result facility information | |
66 element. | |
67 | |
68 */ | |
69 | |
70 GLOBAL void psaSS_asmEmptyRslt ( void ) | |
71 { | |
72 TRACE_FUNCTION("psaSS_asmEmptyRslt"); | |
73 | |
74 memset( &ssFIECodeBuf, 0, sizeof( ssFIECodeBuf )); | |
75 | |
76 ssFIECodeBuf.l_buf = 8; | |
77 | |
78 ssShrdPrm.cmpType = CT_RET_RSLT; | |
79 } | |
80 | |
81 /* | |
82 +-------------------------------------------------------------------+ | |
83 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
84 | ROUTINE : psaSS_asmErrorRslt | | |
85 +-------------------------------------------------------------------+ | |
86 | |
87 PURPOSE : assemble an return error facility information | |
88 element. | |
89 | |
90 */ | |
91 | |
92 GLOBAL void psaSS_asmErrorRslt ( SHORT sId, UBYTE err ) | |
93 { | |
94 TRACE_FUNCTION("psaSS_asmErrorRslt"); | |
95 | |
96 ssShrdPrm.stb[sId].failType = SSF_SS_ERR; | |
97 ssShrdPrm.stb[sId].errCd = err; | |
98 ssShrdPrm.cmpType = CT_RET_ERR; | |
99 } | |
100 | |
101 /* | |
102 +-------------------------------------------------------------------+ | |
103 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
104 | ROUTINE : psaSS_asmInterrogateSS | | |
105 +-------------------------------------------------------------------+ | |
106 | |
107 PURPOSE : assemble the interrogate SS facility information element. | |
108 | |
109 */ | |
110 | |
111 GLOBAL void psaSS_asmInterrogateSS ( UBYTE ssCode, | |
112 UBYTE bscSrvType, | |
113 UBYTE bscSrv ) | |
114 { | |
115 MCAST( irgtSS, INTERROGATE_SS_INV ); | |
116 | |
117 TRACE_FUNCTION("psaSS_asmInterrogateSS"); | |
118 | |
119 memset( irgtSS, 0, sizeof( T_INTERROGATE_SS_INV )); | |
120 | |
121 /* set basic settings */ | |
122 irgtSS->msg_type = INTERROGATE_SS_INV; | |
123 irgtSS->v_ssForBS = TRUE; | |
124 | |
125 /* set service code */ | |
126 irgtSS->ssForBS.v_ssCode = TRUE; | |
127 irgtSS->ssForBS.ssCode = ssCode; | |
128 | |
129 /* set basic service type */ | |
130 switch( bscSrvType ) | |
131 { | |
132 case( BS_BEAR_SRV ): | |
133 | |
134 irgtSS->ssForBS.basicService.v_bearerService = TRUE; | |
135 irgtSS->ssForBS.basicService.bearerService = bscSrv; | |
136 break; | |
137 | |
138 case( BS_TELE_SRV ): | |
139 | |
140 irgtSS->ssForBS.basicService.v_teleservice = TRUE; | |
141 irgtSS->ssForBS.basicService.teleservice = bscSrv; | |
142 break; | |
143 | |
144 default: | |
145 irgtSS->ssForBS.basicService.v_bearerService = FALSE; | |
146 irgtSS->ssForBS.basicService.v_teleservice = FALSE; | |
147 } | |
148 | |
149 memset( &ssFIECodeBuf, 0, sizeof( ssFIECodeBuf )); | |
150 ssFIECodeBuf.l_buf = MAX_FIE_CODE_BUF_LEN<<3; | |
151 ccd_codeMsg (CCDENT_FAC, UPLINK, | |
152 (T_MSGBUF *)&ssFIECodeBuf, _decodedMsg, | |
153 NOT_PRESENT_8BIT); | |
154 | |
155 ssShrdPrm.cmpType = CT_INV; | |
156 } | |
157 | |
158 /* | |
159 +-------------------------------------------------------------------+ | |
160 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
161 | ROUTINE : psaSS_asmRegisterSS | | |
162 +-------------------------------------------------------------------+ | |
163 | |
164 PURPOSE : assemble the register SS facility information element. | |
165 | |
166 */ | |
167 | |
168 GLOBAL void psaSS_asmRegisterSS ( UBYTE ssCode, UBYTE bscSrvType, | |
169 UBYTE bscSrv, UBYTE ton, UBYTE npi, | |
170 UBYTE *num, UBYTE tos, UBYTE oe, | |
171 UBYTE *sub, UBYTE time ) | |
172 { | |
173 MCAST( regSS, REGISTER_SS_INV ); | |
174 | |
175 TRACE_FUNCTION("psaSS_asmRegisterSS"); | |
176 | |
177 memset( regSS, 0, sizeof( T_REGISTER_SS_INV )); | |
178 | |
179 /* set basic settings */ | |
180 regSS->msg_type = REGISTER_SS_INV; | |
181 regSS->v_registerSSArg = TRUE; | |
182 | |
183 /* set service code */ | |
184 regSS->registerSSArg.v_ssCode = TRUE; | |
185 regSS->registerSSArg.ssCode = ssCode; | |
186 | |
187 /* set basic service type */ | |
188 switch( bscSrvType ) | |
189 { | |
190 case( BS_BEAR_SRV ): | |
191 | |
192 regSS->registerSSArg.basicService.v_bearerService = TRUE; | |
193 regSS->registerSSArg.basicService.bearerService = bscSrv; | |
194 break; | |
195 | |
196 case( BS_TELE_SRV ): | |
197 | |
198 regSS->registerSSArg.basicService.v_teleservice = TRUE; | |
199 regSS->registerSSArg.basicService.teleservice = bscSrv; | |
200 break; | |
201 } | |
202 | |
203 /* set forwarded to number */ | |
204 if( num NEQ NULL ) | |
205 { | |
206 regSS->registerSSArg.v_forwardedToNumber = TRUE; | |
207 regSS->registerSSArg.forwardedToNumber.c_bcdDigit | |
208 = (UBYTE)utl_dialStr2BCD((char *) num, | |
209 regSS->registerSSArg.forwardedToNumber.bcdDigit, | |
210 MAX_PARTY_NUM); | |
211 | |
212 if(ton NEQ TON_NOT_PRES AND | |
213 npi NEQ NPI_NOT_PRES) | |
214 { | |
215 regSS->registerSSArg.forwardedToNumber.v_noa = TRUE; | |
216 regSS->registerSSArg.forwardedToNumber.noa = ton; | |
217 | |
218 regSS->registerSSArg.forwardedToNumber.v_npi = TRUE; | |
219 regSS->registerSSArg.forwardedToNumber.npi = npi; | |
220 } | |
221 } | |
222 | |
223 /* set forwarded to subaddress */ | |
224 if( sub NEQ NULL ) | |
225 { | |
226 regSS->registerSSArg.v_forwardedToSubaddress = TRUE; | |
227 regSS->registerSSArg.forwardedToSubaddress.c_bcdDigit | |
228 = (UBYTE)utl_dialStr2BCD((char *) sub, | |
229 regSS->registerSSArg.forwardedToSubaddress.bcdDigit, | |
230 MAX_SUBADDR_NUM); | |
231 | |
232 regSS->registerSSArg.forwardedToSubaddress.v_tos = TRUE; | |
233 regSS->registerSSArg.forwardedToSubaddress.tos = tos; | |
234 | |
235 regSS->registerSSArg.forwardedToSubaddress.v_oei = TRUE; | |
236 regSS->registerSSArg.forwardedToSubaddress.oei = oe; | |
237 } | |
238 | |
239 /* set no reply timer */ | |
240 if( ssCode EQ SS_CD_CFNRY AND time NEQ KSD_TIME_NONE ) | |
241 { | |
242 regSS->registerSSArg.v_noReplyConditionTime = TRUE; | |
243 regSS->registerSSArg.noReplyConditionTime = time; | |
244 } | |
245 | |
246 memset( &ssFIECodeBuf, 0, sizeof( ssFIECodeBuf )); | |
247 ssFIECodeBuf.l_buf = MAX_FIE_CODE_BUF_LEN<<3; | |
248 ccd_codeMsg (CCDENT_FAC, UPLINK, | |
249 (T_MSGBUF *)&ssFIECodeBuf, _decodedMsg, | |
250 NOT_PRESENT_8BIT); | |
251 | |
252 ssShrdPrm.cmpType = CT_INV; | |
253 } | |
254 | |
255 /* | |
256 +-------------------------------------------------------------------+ | |
257 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
258 | ROUTINE : psaSS_asmEraseSS | | |
259 +-------------------------------------------------------------------+ | |
260 | |
261 PURPOSE : assemble the erase SS facility information element. | |
262 | |
263 */ | |
264 | |
265 GLOBAL void psaSS_asmEraseSS ( UBYTE ssCode, UBYTE bscSrvType, | |
266 UBYTE bscSrv ) | |
267 { | |
268 MCAST( ersSS, ERASE_SS_INV ); | |
269 | |
270 TRACE_FUNCTION("psaSS_asmEraseSS"); | |
271 | |
272 memset( ersSS, 0, sizeof( T_ERASE_SS_INV )); | |
273 | |
274 /* set basic settings */ | |
275 ersSS->msg_type = ERASE_SS_INV; | |
276 ersSS->v_ssForBS = TRUE; | |
277 | |
278 /* set service code */ | |
279 ersSS->ssForBS.v_ssCode = TRUE; | |
280 ersSS->ssForBS.ssCode = ssCode; | |
281 | |
282 /* set basic service type */ | |
283 switch( bscSrvType ) | |
284 { | |
285 case( BS_BEAR_SRV ): | |
286 | |
287 ersSS->ssForBS.basicService.v_bearerService = TRUE; | |
288 ersSS->ssForBS.basicService.bearerService = bscSrv; | |
289 break; | |
290 | |
291 case( BS_TELE_SRV ): | |
292 | |
293 ersSS->ssForBS.basicService.v_teleservice = TRUE; | |
294 ersSS->ssForBS.basicService.teleservice = bscSrv; | |
295 break; | |
296 } | |
297 | |
298 memset( &ssFIECodeBuf, 0, sizeof( ssFIECodeBuf )); | |
299 ssFIECodeBuf.l_buf = MAX_FIE_CODE_BUF_LEN<<3; | |
300 ccd_codeMsg (CCDENT_FAC, UPLINK, | |
301 (T_MSGBUF *)&ssFIECodeBuf, _decodedMsg, | |
302 NOT_PRESENT_8BIT); | |
303 | |
304 ssShrdPrm.cmpType = CT_INV; | |
305 | |
306 } | |
307 | |
308 /* | |
309 +-------------------------------------------------------------------+ | |
310 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
311 | ROUTINE : psaSS_asmActivateSS | | |
312 +-------------------------------------------------------------------+ | |
313 | |
314 PURPOSE : assemble the interrogate SS facility information element. | |
315 | |
316 */ | |
317 | |
318 GLOBAL void psaSS_asmActivateSS ( UBYTE ssCode, UBYTE bscSrvType, | |
319 UBYTE bscSrv ) | |
320 { | |
321 MCAST( actSS, ACTIVATE_SS_INV ); | |
322 | |
323 TRACE_FUNCTION("psaSS_asmActivateSS"); | |
324 | |
325 memset( actSS, 0, sizeof( T_ACTIVATE_SS_INV )); | |
326 | |
327 /* set basic settings */ | |
328 actSS->msg_type = ACTIVATE_SS_INV; | |
329 actSS->v_ssForBS = TRUE; | |
330 | |
331 /* set service code */ | |
332 actSS->ssForBS.v_ssCode = TRUE; | |
333 actSS->ssForBS.ssCode = ssCode; | |
334 | |
335 /* set basic service type */ | |
336 switch( bscSrvType ) | |
337 { | |
338 case( BS_BEAR_SRV ): | |
339 | |
340 actSS->ssForBS.basicService.v_bearerService = TRUE; | |
341 actSS->ssForBS.basicService.bearerService = bscSrv; | |
342 break; | |
343 | |
344 case( BS_TELE_SRV ): | |
345 | |
346 actSS->ssForBS.basicService.v_teleservice = TRUE; | |
347 actSS->ssForBS.basicService.teleservice = bscSrv; | |
348 break; | |
349 } | |
350 | |
351 memset( &ssFIECodeBuf, 0, sizeof( ssFIECodeBuf )); | |
352 ssFIECodeBuf.l_buf = MAX_FIE_CODE_BUF_LEN<<3; | |
353 ccd_codeMsg (CCDENT_FAC, UPLINK, | |
354 (T_MSGBUF *)&ssFIECodeBuf, _decodedMsg, | |
355 NOT_PRESENT_8BIT); | |
356 | |
357 ssShrdPrm.cmpType = CT_INV; | |
358 | |
359 } | |
360 | |
361 /* | |
362 +-------------------------------------------------------------------+ | |
363 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
364 | ROUTINE : psaSS_asmDeactivateSS | | |
365 +-------------------------------------------------------------------+ | |
366 | |
367 PURPOSE : assemble the deactivate SS facility information element. | |
368 | |
369 */ | |
370 | |
371 GLOBAL void psaSS_asmDeactivateSS ( UBYTE ssCode, UBYTE bscSrvType, | |
372 UBYTE bscSrv ) | |
373 { | |
374 MCAST( deactSS, DEACTIVATE_SS_INV ); | |
375 | |
376 TRACE_FUNCTION("psaSS_asmDeactivateSS"); | |
377 | |
378 memset( deactSS, 0, sizeof( T_DEACTIVATE_SS_INV )); | |
379 | |
380 /* set basic settings */ | |
381 deactSS->msg_type = DEACTIVATE_SS_INV; | |
382 deactSS->v_ssForBS = TRUE; | |
383 | |
384 /* set service code */ | |
385 deactSS->ssForBS.v_ssCode = TRUE; | |
386 deactSS->ssForBS.ssCode = ssCode; | |
387 | |
388 /* set basic service type */ | |
389 switch( bscSrvType ) | |
390 { | |
391 case( BS_BEAR_SRV ): | |
392 | |
393 deactSS->ssForBS.basicService.v_bearerService = TRUE; | |
394 deactSS->ssForBS.basicService.bearerService = bscSrv; | |
395 break; | |
396 | |
397 case( BS_TELE_SRV ): | |
398 | |
399 deactSS->ssForBS.basicService.v_teleservice = TRUE; | |
400 deactSS->ssForBS.basicService.teleservice = bscSrv; | |
401 break; | |
402 } | |
403 | |
404 memset( &ssFIECodeBuf, 0, sizeof( ssFIECodeBuf )); | |
405 ssFIECodeBuf.l_buf = MAX_FIE_CODE_BUF_LEN<<3; | |
406 ccd_codeMsg (CCDENT_FAC, UPLINK, | |
407 (T_MSGBUF *)&ssFIECodeBuf, _decodedMsg, | |
408 NOT_PRESENT_8BIT); | |
409 | |
410 ssShrdPrm.cmpType = CT_INV; | |
411 | |
412 } | |
413 | |
414 /* | |
415 +-------------------------------------------------------------------+ | |
416 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
417 | ROUTINE : psaSS_asmRegisterPWD | | |
418 +-------------------------------------------------------------------+ | |
419 | |
420 PURPOSE : assemble the register password facility information | |
421 element. | |
422 | |
423 */ | |
424 | |
425 GLOBAL void psaSS_asmRegisterPWD ( UBYTE ssCode ) | |
426 { | |
427 MCAST( regPWD, REGISTER_PWD_INV ); | |
428 | |
429 TRACE_FUNCTION("psaSS_asmRegisterPWD"); | |
430 | |
431 memset( regPWD, 0, sizeof( T_REGISTER_PWD_INV )); | |
432 | |
433 /* set service code */ | |
434 regPWD->v_ssCode = TRUE; | |
435 regPWD->ssCode = ssCode; | |
436 regPWD->msg_type = REGISTER_PWD_INV; | |
437 | |
438 memset( &ssFIECodeBuf, 0, sizeof( ssFIECodeBuf )); | |
439 ssFIECodeBuf.l_buf = MAX_FIE_CODE_BUF_LEN<<3; | |
440 ccd_codeMsg (CCDENT_FAC, UPLINK, | |
441 (T_MSGBUF *)&ssFIECodeBuf, _decodedMsg, | |
442 NOT_PRESENT_8BIT); | |
443 | |
444 ssShrdPrm.cmpType = CT_INV; | |
445 | |
446 } | |
447 | |
448 /* | |
449 +-------------------------------------------------------------------+ | |
450 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
451 | ROUTINE : psaSS_asmVerifyPWD | | |
452 +-------------------------------------------------------------------+ | |
453 | |
454 PURPOSE : assemble the verify password facility information | |
455 element. | |
456 | |
457 */ | |
458 | |
459 GLOBAL void psaSS_asmVerifyPWD ( UBYTE *pwd ) | |
460 { | |
461 MCAST( vrfPWD, GET_PWD_RES ); | |
462 | |
463 TRACE_FUNCTION("psaSS_asmVerifyPWD"); | |
464 | |
465 memset( vrfPWD, 0, sizeof( T_GET_PWD_RES )); | |
466 | |
467 /* set service code */ | |
468 vrfPWD->v_currPassword = TRUE; | |
469 vrfPWD->msg_type = GET_PWD_RES; | |
470 | |
471 strncpy( (char *) vrfPWD->currPassword.digit, (char *) pwd, MAX_PWD_NUM ); | |
472 | |
473 memset( &ssFIECodeBuf, 0, sizeof( ssFIECodeBuf )); | |
474 ssFIECodeBuf.l_buf = MAX_FIE_CODE_BUF_LEN<<3; | |
475 ccd_codeMsg (CCDENT_FAC, UPLINK, | |
476 (T_MSGBUF *)&ssFIECodeBuf, _decodedMsg, | |
477 NOT_PRESENT_8BIT); | |
478 | |
479 ssShrdPrm.cmpType = CT_RET_RSLT; | |
480 | |
481 } | |
482 | |
483 /* | |
484 +-------------------------------------------------------------------+ | |
485 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
486 | ROUTINE : psaSS_asmProcUSSDReq | | |
487 +-------------------------------------------------------------------+ | |
488 | |
489 PURPOSE : assemble the process USSD request facility information | |
490 element. | |
491 | |
492 */ | |
493 | |
494 GLOBAL void psaSS_asmProcUSSDReq ( UBYTE dcs, UBYTE *ussd, UBYTE len ) | |
495 { | |
496 /* UBYTE cmpLen;*/ | |
497 | |
498 MCAST( ussdReq, PROCESS_USSD_REQ_INV ); | |
499 | |
500 TRACE_FUNCTION("psaSS_asmProcUSSDReq"); | |
501 | |
502 memset( ussdReq, 0, sizeof( T_PROCESS_USSD_REQ_INV )); | |
503 | |
504 /* set service code */ | |
505 ussdReq->v_ussdArg = TRUE; | |
506 ussdReq->msg_type = PROCESS_USSD_REQ_INV; | |
507 | |
508 /* set data coding scheme */ | |
509 ussdReq->ussdArg.v_ussdDataCodingScheme = TRUE; | |
510 ussdReq->ussdArg.ussdDataCodingScheme = dcs; | |
511 | |
512 /* set ussd response string */ | |
513 /* if( utl_getAlphabetCb( dcs ) EQ 0 ) *//* 7bit alphabet */ | |
514 /* cmpLen = utl_cvt8To7( ussd, (UBYTE)MINIMUM( MAX_USSD_STRING, len), | |
515 ussdReq->ussdArg.ussdString.b_ussdString, 0 ); | |
516 else*/ | |
517 { | |
518 /* cmpLen = len;*/ | |
519 memcpy( ussdReq->ussdArg.ussdString.b_ussdString, ussd, | |
520 MINIMUM( MAX_USSD_STRING, len)); | |
521 } | |
522 | |
523 ussdReq->ussdArg.v_ussdString = TRUE; | |
524 ussdReq->ussdArg.ussdString.o_ussdString = 0; | |
525 ussdReq->ussdArg.ussdString.l_ussdString = len<<3; /*cmpLen<<3;*/ | |
526 | |
527 memset( &ssFIECodeBuf, 0, sizeof( ssFIECodeBuf )); | |
528 ssFIECodeBuf.l_buf = MAX_FIE_CODE_BUF_LEN<<3; | |
529 ccd_codeMsg (CCDENT_FAC, UPLINK, | |
530 (T_MSGBUF *)&ssFIECodeBuf, _decodedMsg, | |
531 NOT_PRESENT_8BIT); | |
532 | |
533 ssShrdPrm.cmpType = CT_INV; | |
534 } | |
535 | |
536 /* | |
537 +-------------------------------------------------------------------+ | |
538 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
539 | ROUTINE : psaSS_asmCnfUSSDReq | | |
540 +-------------------------------------------------------------------+ | |
541 | |
542 PURPOSE : assemble the confirm USSD request facility information | |
543 element. | |
544 */ | |
545 | |
546 GLOBAL void psaSS_asmCnfUSSDReq ( UBYTE dcs, UBYTE *ussd, UBYTE len ) | |
547 { | |
548 UBYTE cmpLen; | |
549 UBYTE src_len; | |
550 | |
551 MCAST( ussdReq, USSD_REQ_RES ); | |
552 | |
553 TRACE_FUNCTION("psaSS_asmCnfUSSDReq"); | |
554 | |
555 memset( ussdReq, 0, sizeof( T_USSD_REQ_RES )); | |
556 | |
557 /* set service code */ | |
558 ussdReq->v_ussdRes = TRUE; | |
559 ussdReq->msg_type = USSD_REQ_RES; | |
560 | |
561 /* set data coding scheme */ | |
562 ussdReq->ussdRes.v_ussdDataCodingScheme = TRUE; | |
563 ussdReq->ussdRes.ussdDataCodingScheme = dcs; | |
564 | |
565 /* set ussd response string */ | |
566 if( utl_getAlphabetCb( dcs ) EQ 0 ) /* 7bit alphabet */ | |
567 { | |
568 src_len = (UBYTE)MINIMUM( MAX_USSD_STRING, len); | |
569 cmpLen = utl_cvt8To7( ussd, src_len, | |
570 ussdReq->ussdRes.ussdString.b_ussdString, 0 ); | |
571 /* According to spec 23.038 section 6.1.2.3 for USSD packing, for bytes end with | |
572 * (8*n)-1 i.e where n is 1,2,3....i.e byte 7, 15, 23 ... to be padded | |
573 * with carriage return <CR>(0xD) | |
574 */ | |
575 if ((src_len+1)%8 EQ 0) | |
576 { | |
577 ussdReq->ussdRes.ussdString.b_ussdString[cmpLen-1] |= (0xD << 1); | |
578 } | |
579 } | |
580 else | |
581 { | |
582 cmpLen = len; | |
583 memcpy( ussdReq->ussdRes.ussdString.b_ussdString, ussd, | |
584 MINIMUM( MAX_USSD_STRING, len)); | |
585 } | |
586 | |
587 ussdReq->ussdRes.v_ussdString = TRUE; | |
588 ussdReq->ussdRes.ussdString.o_ussdString = 0; | |
589 ussdReq->ussdRes.ussdString.l_ussdString = cmpLen<<3; | |
590 | |
591 memset( &ssFIECodeBuf, 0, sizeof( ssFIECodeBuf )); | |
592 ssFIECodeBuf.l_buf = MAX_FIE_CODE_BUF_LEN<<3; | |
593 ccd_codeMsg (CCDENT_FAC, UPLINK, | |
594 (T_MSGBUF *)&ssFIECodeBuf, _decodedMsg, | |
595 NOT_PRESENT_8BIT); | |
596 | |
597 ssShrdPrm.cmpType = CT_RET_RSLT; | |
598 } | |
599 | |
600 /* | |
601 +-------------------------------------------------------------------+ | |
602 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
603 | ROUTINE : psaSS_USSDProt1 | | |
604 +-------------------------------------------------------------------+ | |
605 | |
606 PURPOSE : send USSD according to protocol version 1. | |
607 */ | |
608 | |
609 GLOBAL BOOL psaSS_asmUSSDProt1 ( SHORT sId ) | |
610 { | |
611 UBYTE ussdBuf8Bit[MAX_USSD_STRING]; /* buffers 8 bit ussd string */ | |
612 USHORT ussdLen8Bit; | |
613 | |
614 TRACE_FUNCTION("psaSS_asmUSSDProt1"); | |
615 | |
616 if( ssShrdPrm.ussdLen AND | |
617 ssShrdPrm.stb[sId].SSver NEQ NOT_PRESENT_8BIT ) | |
618 { | |
619 MCAST( ussdData, PROCESS_USSD_INV ); | |
620 | |
621 memset( ussdData, 0, sizeof( T_PROCESS_USSD_INV )); | |
622 | |
623 /* set service code */ | |
624 ussdData->v_ssUserData = TRUE; | |
625 ussdData->msg_type = PROCESS_USSD_INV; | |
626 | |
627 /* GSM data must be 8-bit coded */ | |
628 if (ssShrdPrm.ussdDcs EQ 0x0F) | |
629 { | |
630 ussdLen8Bit = utl_cvt7To8 (ssShrdPrm.ussdBuf, ssShrdPrm.ussdLen, ussdBuf8Bit, 0); | |
631 } | |
632 else | |
633 { | |
634 memcpy ( ussdBuf8Bit, ssShrdPrm.ussdBuf, ssShrdPrm.ussdLen); | |
635 ussdLen8Bit = ssShrdPrm.ussdLen; | |
636 } | |
637 | |
638 /* set ussd data string, if convertible */ | |
639 if( !utl_cvtGsmIra ( ussdBuf8Bit, | |
640 ussdLen8Bit, | |
641 ussdData->ssUserData.b_ssUserData, | |
642 MAX_USSD_DATA, | |
643 CSCS_DIR_GsmToIra ) ) | |
644 { | |
645 return( FALSE ); | |
646 } | |
647 | |
648 ussdData->ssUserData.o_ssUserData = 0; | |
649 ussdData->ssUserData.l_ssUserData = ssShrdPrm.ussdLen<<3; | |
650 | |
651 memset( &ssFIECodeBuf, 0, sizeof( ssFIECodeBuf )); | |
652 ssFIECodeBuf.l_buf = MAX_FIE_CODE_BUF_LEN<<3; | |
653 ccd_codeMsg (CCDENT_FAC, UPLINK, | |
654 (T_MSGBUF *)&ssFIECodeBuf, _decodedMsg, | |
655 NOT_PRESENT_8BIT); | |
656 | |
657 ssShrdPrm.cmpType = CT_INV; | |
658 | |
659 /* skip SS version indicator */ | |
660 ssShrdPrm.stb[sId].SSver = NOT_PRESENT_8BIT; | |
661 | |
662 /* repeat USSD string */ | |
663 psaSS_NewTrns(sId); | |
664 | |
665 return( TRUE ); | |
666 } | |
667 | |
668 return( FALSE ); | |
669 } | |
670 | |
671 | |
672 /* | |
673 +-------------------------------------------------------------------+ | |
674 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
675 | ROUTINE : psaSS_asmDeactivateCCBS | | |
676 +-------------------------------------------------------------------+ | |
677 | |
678 PURPOSE : assemble the deactivate CCBS facility information | |
679 element. | |
680 | |
681 */ | |
682 | |
683 GLOBAL void psaSS_asmDeactivateCCBS ( UBYTE idx ) | |
684 { | |
685 MCAST( ersCCBS, ERASE_CC_ENTRY_INV ); | |
686 | |
687 TRACE_FUNCTION("psaSS_asmDeactivateCCBS"); | |
688 | |
689 memset( ersCCBS, 0, sizeof( T_ERASE_CC_ENTRY_INV )); | |
690 | |
691 /* set service code */ | |
692 ersCCBS->v_eraseCCEntryArg = TRUE; | |
693 ersCCBS->msg_type = ERASE_CC_ENTRY_INV; | |
694 | |
695 ersCCBS->eraseCCEntryArg.v_ssCode = TRUE; | |
696 ersCCBS->eraseCCEntryArg.ssCode = SS_CD_CCBS; | |
697 | |
698 if( idx NEQ KSD_IDX_NONE ) | |
699 { | |
700 ersCCBS->eraseCCEntryArg.v_ccbsIndex = TRUE; | |
701 ersCCBS->eraseCCEntryArg.ccbsIndex = idx; | |
702 } | |
703 | |
704 memset( &ssFIECodeBuf, 0, sizeof( ssFIECodeBuf )); | |
705 ssFIECodeBuf.l_buf = MAX_FIE_CODE_BUF_LEN<<3; | |
706 ccd_codeMsg (CCDENT_FAC, UPLINK, | |
707 (T_MSGBUF *)&ssFIECodeBuf, _decodedMsg, | |
708 NOT_PRESENT_8BIT); | |
709 | |
710 ssShrdPrm.cmpType = CT_INV; | |
711 } | |
712 | |
713 /* | |
714 +-------------------------------------------------------------------+ | |
715 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
716 | ROUTINE : psaSS_dasmInvokeCmp | | |
717 +-------------------------------------------------------------------+ | |
718 | |
719 PURPOSE : disassemble the result component. | |
720 */ | |
721 | |
722 GLOBAL void psaSS_dasmInvokeCmp ( SHORT sId, T_inv_comp *invCmp ) | |
723 { | |
724 USHORT ivId; /* holds invoke Id */ | |
725 UBYTE opCode; /* holds operation code */ | |
726 | |
727 TRACE_FUNCTION("psaSS_dasmInvokeCmp"); | |
728 | |
729 if( invCmp -> v_inv_id ) | |
730 ivId = invCmp -> inv_id; | |
731 else | |
732 ivId = NOT_PRESENT_16BIT; | |
733 | |
734 if( invCmp -> v_op_code ) | |
735 opCode = invCmp -> op_code; | |
736 else | |
737 opCode = NOT_PRESENT_8BIT; | |
738 | |
739 /* store op code and invoke id for result */ | |
740 ssShrdPrm.stb[sId].iId = (UBYTE)ivId; | |
741 ssShrdPrm.stb[sId].opCode = opCode; | |
742 | |
743 if( invCmp -> params.l_params ) | |
744 { | |
745 UBYTE ccdRet; | |
746 | |
747 memcpy( ssFIEDecodeBuf, &invCmp -> params, FACILITY_LEN ); | |
748 | |
749 ccdRet = ccd_decodeMsg (CCDENT_FAC, | |
750 DOWNLINK, | |
751 (T_MSGBUF *) ssFIEDecodeBuf, | |
752 (UBYTE *) _decodedMsg, | |
753 opCode); | |
754 | |
755 if( ccdRet NEQ ccdOK ) | |
756 { | |
757 TRACE_EVENT_P1("CCD Decoding Error: %d",ccdRet ); | |
758 ssShrdPrm.stb[sId].failType = SSF_CCD_DEC; | |
759 cmhSS_TransFail(sId); | |
760 } | |
761 } | |
762 else | |
763 memset( ssFIEDecodeBuf, 0, FACILITY_LEN ); /* put all valid flags to FALSE */ | |
764 | |
765 switch( opCode ) | |
766 { | |
767 case( OPC_GET_PASSWORD ): | |
768 { | |
769 MCAST( getPWD, GET_PWD_INV ); | |
770 | |
771 cmhSS_getPassword( sId, getPWD ); | |
772 } | |
773 break; | |
774 | |
775 case( OPC_UNSTRUCT_SS_NOTIFY ): | |
776 { | |
777 MCAST( ussdNtfy, USSD_NOTIFY_INV ); | |
778 | |
779 cmhSS_USSDNotify( sId, ussdNtfy ); | |
780 } | |
781 break; | |
782 | |
783 case( OPC_UNSTRUCT_SS_REQ ): | |
784 { | |
785 MCAST( ussdReq, USSD_REQ_INV ); | |
786 | |
787 cmhSS_USSDRequest( sId, ussdReq ); | |
788 } | |
789 break; | |
790 | |
791 case( OPC_FWD_CHECK_SS_IND ): | |
792 { | |
793 cmhSS_FwdChckSS( sId ); | |
794 } | |
795 break; | |
796 } | |
797 } | |
798 | |
799 /* | |
800 +-------------------------------------------------------------------+ | |
801 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
802 | ROUTINE : psaSS_dasmResultCmp | | |
803 +-------------------------------------------------------------------+ | |
804 | |
805 PURPOSE : disassemble the result component. | |
806 */ | |
807 | |
808 GLOBAL void psaSS_dasmResultCmp ( SHORT sId, T_res_comp *resCmp ) | |
809 { | |
810 UBYTE opCode; /* holds operation code */ | |
811 | |
812 TRACE_FUNCTION("psaSS_dasmResultCmp"); | |
813 | |
814 /* get operation code of the result */ | |
815 if( resCmp -> v_sequence AND | |
816 resCmp -> sequence.v_op_code ) | |
817 { | |
818 opCode = resCmp -> sequence.op_code; | |
819 } | |
820 else | |
821 opCode = ssShrdPrm.stb[sId].opCode; | |
822 | |
823 /* decode additional parameters of result */ | |
824 if( resCmp -> v_sequence AND | |
825 resCmp -> sequence.params.l_params ) | |
826 { | |
827 UBYTE ccdRet; | |
828 | |
829 memcpy( ssFIEDecodeBuf, &resCmp -> sequence.params, FACILITY_LEN); | |
830 | |
831 ccdRet = ccd_decodeMsg (CCDENT_FAC, | |
832 DOWNLINK, | |
833 (T_MSGBUF *) ssFIEDecodeBuf, | |
834 (UBYTE *) _decodedMsg, | |
835 opCode); | |
836 | |
837 if( ccdRet NEQ ccdOK ) | |
838 { | |
839 CHAR buf[25]; | |
840 sprintf( buf, "CCD Decoding Error: %d",ccdRet ); | |
841 TRACE_EVENT( buf ); | |
842 cmhSS_SSResultFailure( sId ); | |
843 return; | |
844 } | |
845 } | |
846 | |
847 /* determine to which operation the result belongs to */ | |
848 switch( opCode ) | |
849 { | |
850 case( OPC_REGISTER_SS ): | |
851 { | |
852 MCAST( regSS, REGISTER_SS_RES ); | |
853 | |
854 cmhSS_SSRegistrated( sId, regSS ); | |
855 } | |
856 break; | |
857 | |
858 case( OPC_ERASE_SS ): | |
859 { | |
860 MCAST( ersSS, ERASE_SS_RES ); | |
861 | |
862 cmhSS_SSErased( sId, ersSS ); | |
863 } | |
864 break; | |
865 | |
866 case( OPC_ACTIVATE_SS ): | |
867 { | |
868 MCAST( actSS, ACTIVATE_SS_RES ); | |
869 | |
870 if( !(resCmp -> v_sequence) OR !(resCmp -> sequence.params.l_params) ) | |
871 { | |
872 memset(actSS, 0, sizeof(T_ACTIVATE_SS_RES)); | |
873 } | |
874 cmhSS_SSActivated( sId, actSS ); | |
875 } | |
876 break; | |
877 | |
878 case( OPC_DEACTIVATE_SS ): | |
879 { | |
880 MCAST( deactSS, DEACTIVATE_SS_RES ); | |
881 | |
882 cmhSS_SSDeactivated( sId, deactSS ); | |
883 } | |
884 break; | |
885 | |
886 case( OPC_INTERROGATE_SS ): | |
887 { | |
888 MCAST( irgtSS, INTERROGATE_SS_RES ); | |
889 | |
890 cmhSS_SSInterrogated( sId, irgtSS ); | |
891 } | |
892 break; | |
893 | |
894 case( OPC_REGISTER_PASSWORD ): | |
895 { | |
896 MCAST( regPWD, REGISTER_PWD_RES ); | |
897 | |
898 cmhSS_SSPWDRegistrated( sId, regPWD ); | |
899 } | |
900 break; | |
901 | |
902 case( OPC_PROC_UNSTRUCT_SS_DATA ): | |
903 { | |
904 MCAST( prcUSSDDat, PROCESS_USSD_RES ); | |
905 | |
906 cmhSS_USSDDatProcessed( sId, prcUSSDDat ); | |
907 } | |
908 break; | |
909 | |
910 case( OPC_PROC_UNSTRUCT_SS_REQ ): | |
911 { | |
912 MCAST( prcUSSDReq, PROCESS_USSD_REQ_RES ); | |
913 | |
914 cmhSS_USSDReqProcessed( sId, prcUSSDReq ); | |
915 } | |
916 break; | |
917 | |
918 case( OPC_ERASE_CC_ENTRY ): | |
919 { | |
920 MCAST( ersCCNtry, ERASE_CC_ENTRY_RES ); | |
921 | |
922 cmhSS_CCNtryErased( sId, ersCCNtry ); | |
923 } | |
924 break; | |
925 } | |
926 } | |
927 | |
928 /* | |
929 +-------------------------------------------------------------------+ | |
930 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
931 | ROUTINE : psaSS_dasmErrorCmp | | |
932 +-------------------------------------------------------------------+ | |
933 | |
934 PURPOSE : disassemble the error component. | |
935 */ | |
936 | |
937 GLOBAL T_ACI_RETURN psaSS_dasmErrorCmp ( SHORT sId, T_err_comp *errCmp, BOOL is_fac_ussd ) | |
938 { | |
939 TRACE_EVENT_P1("psaSS_dasmErrorCmp: errCmp: %02x",errCmp -> err_code); | |
940 | |
941 if( errCmp -> v_err_code ) | |
942 { | |
943 ssShrdPrm.stb[sId].failType = SSF_SS_ERR; | |
944 ssShrdPrm.stb[sId].errCd = errCmp -> err_code; | |
945 | |
946 | |
947 switch(errCmp -> err_code) | |
948 { | |
949 case ERR_PWD_REG_FAIL: | |
950 if( errCmp -> v_params AND errCmp -> params.l_params ) | |
951 { | |
952 T_PW_REGISTRATION_FAILURE_ERR *pwRegFail; | |
953 | |
954 pwRegFail = (T_PW_REGISTRATION_FAILURE_ERR *)errCmp -> params.b_params; | |
955 | |
956 TRACE_EVENT_P1("VGK:Error reported %d", errCmp -> err_code); | |
957 TRACE_EVENT_P1("VGK:Error params %d", pwRegFail->pwRegistrationFailureCause); | |
958 | |
959 if (pwRegFail->v_pwRegistrationFailureCause) | |
960 ssShrdPrm.stb[sId].errPrms = pwRegFail->pwRegistrationFailureCause; | |
961 } | |
962 break; | |
963 | |
964 default: | |
965 break; | |
966 } | |
967 | |
968 /* check for protocol incompatibility for USSD */ | |
969 if( is_fac_ussd AND | |
970 errCmp -> err_code EQ ERR_FAC_NOT_SUPPORTED ) | |
971 { | |
972 if( psaSS_asmUSSDProt1(sId) ) | |
973 { | |
974 return( AT_CMPL ); | |
975 } | |
976 } | |
977 | |
978 } | |
979 return( AT_FAIL ); | |
980 } | |
981 | |
982 /* | |
983 +-------------------------------------------------------------------+ | |
984 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
985 | ROUTINE : psaSS_dasmRejectCmp | | |
986 +-------------------------------------------------------------------+ | |
987 | |
988 PURPOSE : disassemble the error component. | |
989 */ | |
990 | |
991 GLOBAL T_ACI_RETURN psaSS_dasmRejectCmp ( SHORT sId, T_rej_comp *rejCmp, BOOL is_fac_ussd ) | |
992 { | |
993 TRACE_FUNCTION("psaSS_dasmRejectCmp"); | |
994 | |
995 if( rejCmp -> v_gen_problem ) | |
996 { | |
997 ssShrdPrm.stb[sId].failType = SSF_GEN_PRB; | |
998 ssShrdPrm.stb[sId].rejPrb = rejCmp -> gen_problem; | |
999 } | |
1000 | |
1001 else if( rejCmp -> v_inv_problem ) | |
1002 { | |
1003 ssShrdPrm.stb[sId].failType = SSF_INV_PRB; | |
1004 ssShrdPrm.stb[sId].rejPrb = rejCmp -> inv_problem; | |
1005 | |
1006 /* check for protocol incompatibility for USSD */ | |
1007 if( is_fac_ussd AND | |
1008 rejCmp -> inv_problem EQ INV_PROB_UNRECOG_OP ) | |
1009 { | |
1010 if( psaSS_asmUSSDProt1(sId) ) | |
1011 { | |
1012 return( AT_CMPL ); | |
1013 } | |
1014 } | |
1015 } | |
1016 | |
1017 else if( rejCmp -> v_res_problem ) | |
1018 { | |
1019 ssShrdPrm.stb[sId].failType = SSF_RSL_PRB; | |
1020 ssShrdPrm.stb[sId].rejPrb = rejCmp -> res_problem; | |
1021 } | |
1022 | |
1023 else if( rejCmp -> v_err_problem ) | |
1024 { | |
1025 ssShrdPrm.stb[sId].failType = SSF_ERR_PRB; | |
1026 ssShrdPrm.stb[sId].rejPrb = rejCmp -> err_problem; | |
1027 } | |
1028 return( AT_FAIL ); | |
1029 } | |
1030 | |
1031 /* | |
1032 +-------------------------------------------------------------------+ | |
1033 | PROJECT : GSM-PS (6147) MODULE : PSA_SATF | | |
1034 | ROUTINE : psaSAT_ss_end_ind | | |
1035 +-------------------------------------------------------------------+ | |
1036 | |
1037 PURPOSE : handles responses to user after a SS. | |
1038 is_fac_ussd TRUE if facility is a USSD | |
1039 */ | |
1040 | |
1041 GLOBAL T_ACI_RETURN psaSS_ss_end_ind ( SHORT sId, T_COMPONENT *com, BOOL is_fac_ussd ) | |
1042 { | |
1043 if( com->v_res_comp ) | |
1044 { | |
1045 psaSS_dasmResultCmp( sId, &com->res_comp ); | |
1046 return( AT_EXCT ); | |
1047 } | |
1048 | |
1049 if( com->v_err_comp ) | |
1050 { | |
1051 return(psaSS_dasmErrorCmp( sId, &com->err_comp, is_fac_ussd )); | |
1052 } | |
1053 | |
1054 if( com->v_rej_comp ) | |
1055 { | |
1056 return(psaSS_dasmRejectCmp( sId, &com->rej_comp, is_fac_ussd )); | |
1057 } | |
1058 | |
1059 TRACE_EVENT( "WRONG COMPONENT TYPE RECEIVED" ); | |
1060 return(AT_FAIL); | |
1061 } | |
1062 | |
1063 /* | |
1064 +-------------------------------------------------------------------+ | |
1065 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
1066 | ROUTINE : psaSS_stbNewEntry | | |
1067 +-------------------------------------------------------------------+ | |
1068 | |
1069 PURPOSE : returns the service table index for a free entry to be | |
1070 used, otherwise the function returns -1 to indicate that | |
1071 no entry is free. | |
1072 */ | |
1073 | |
1074 GLOBAL SHORT psaSS_stbNewEntry ( void ) | |
1075 { | |
1076 SHORT stbIdx; /* holds service table index */ | |
1077 | |
1078 for( stbIdx = 0; stbIdx < MAX_SS_NR; stbIdx++ ) | |
1079 { | |
1080 if( (ssShrdPrm.stb[stbIdx].ntryUsdFlg EQ FALSE) OR | |
1081 (ssShrdPrm.stb[stbIdx].srvStat EQ SSS_IDL) ) | |
1082 { | |
1083 psaSS_InitStbNtry( stbIdx ); | |
1084 | |
1085 return( stbIdx ); | |
1086 } | |
1087 } | |
1088 | |
1089 return( -1 ); | |
1090 } | |
1091 | |
1092 /* | |
1093 +-------------------------------------------------------------------+ | |
1094 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
1095 | ROUTINE : psaSS_stbFindTi | | |
1096 +-------------------------------------------------------------------+ | |
1097 | |
1098 PURPOSE : returns the service table index for the entry that holds | |
1099 service parameters for the passed transaction identifier. | |
1100 Returning -1 indicates that the passed ti was not found. | |
1101 */ | |
1102 | |
1103 GLOBAL SHORT psaSS_stbFindTi ( UBYTE ti2Find ) | |
1104 { | |
1105 SHORT stbIdx; /* holds service table index */ | |
1106 | |
1107 for( stbIdx = 0; stbIdx < MAX_SS_NR; stbIdx++ ) | |
1108 { | |
1109 if( ssShrdPrm.stb[stbIdx].ti EQ ti2Find ) | |
1110 | |
1111 return( stbIdx ); | |
1112 } | |
1113 | |
1114 return( -1 ); | |
1115 } | |
1116 | |
1117 /* | |
1118 +-------------------------------------------------------------------+ | |
1119 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
1120 | ROUTINE : psaSS_stbFindInvId | | |
1121 +-------------------------------------------------------------------+ | |
1122 | |
1123 PURPOSE : returns the service table index for the entry that holds | |
1124 service parameters for the passed invoke id. | |
1125 Returning -1 indicates that the passed ti was not found. | |
1126 */ | |
1127 | |
1128 GLOBAL SHORT psaSS_stbFindInvId ( UBYTE iId2Find ) | |
1129 { | |
1130 SHORT stbIdx; /* holds service table index */ | |
1131 | |
1132 for( stbIdx = 0; stbIdx < MAX_SS_NR; stbIdx++ ) | |
1133 { | |
1134 if( ssShrdPrm.stb[stbIdx].ntryUsdFlg EQ TRUE AND | |
1135 ssShrdPrm.stb[stbIdx].iId EQ iId2Find ) | |
1136 | |
1137 return( stbIdx ); | |
1138 } | |
1139 | |
1140 return( -1 ); | |
1141 } | |
1142 | |
1143 /* | |
1144 +-------------------------------------------------------------------+ | |
1145 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
1146 | ROUTINE : psaSS_chgSrvTypCnt | | |
1147 +-------------------------------------------------------------------+ | |
1148 | |
1149 PURPOSE : this function modifies the service type counter (MOS/MTS) | |
1150 defined by the passed service id by the passed delta value. | |
1151 */ | |
1152 | |
1153 GLOBAL void psaSS_chngSrvTypCnt ( SHORT sId, SHORT dlt ) | |
1154 { | |
1155 | |
1156 switch( ssShrdPrm.stb[sId].srvType ) | |
1157 { | |
1158 case( ST_MOS ): | |
1159 | |
1160 ssShrdPrm.nrOfMOS += dlt; | |
1161 | |
1162 if( ssShrdPrm.nrOfMOS < 0 ) ssShrdPrm.nrOfMOS = 0; | |
1163 | |
1164 break; | |
1165 | |
1166 case( ST_MTS ): | |
1167 | |
1168 ssShrdPrm.nrOfMTS += dlt; | |
1169 | |
1170 if( ssShrdPrm.nrOfMTS < 0 ) ssShrdPrm.nrOfMTS = 0; | |
1171 | |
1172 break; | |
1173 | |
1174 default: | |
1175 | |
1176 TRACE_EVENT( "UNEXP SERVICE TYPE IN STB" ); | |
1177 } | |
1178 } | |
1179 | |
1180 /* | |
1181 +-------------------------------------------------------------------+ | |
1182 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
1183 | ROUTINE : psaSS_getMOSTi | | |
1184 +-------------------------------------------------------------------+ | |
1185 | |
1186 PURPOSE : this function selects a ti out of a pool of valid ti's | |
1187 and inserts it into the passed service table entry. if no | |
1188 ti is available the function returns -1. | |
1189 a bit of the pool stands for a valid ti. | |
1190 0 indicates a used ti, 1 indicates a free ti. | |
1191 */ | |
1192 | |
1193 GLOBAL SHORT psaSS_getMOSTi( SHORT sId ) | |
1194 { | |
1195 UBYTE idx; /* holds pool idx */ | |
1196 | |
1197 for( idx = 0; idx < MAX_MOSTI_NR; idx++ ) | |
1198 { | |
1199 if( tiPool & (1u << idx) ) | |
1200 { | |
1201 tiPool &= ~(1u << idx); | |
1202 ssShrdPrm.stb[sId].ti = idx; | |
1203 return( 0 ); | |
1204 } | |
1205 } | |
1206 return( -1 ); | |
1207 } | |
1208 | |
1209 /* | |
1210 +-------------------------------------------------------------------+ | |
1211 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
1212 | ROUTINE : psaSS_retMOSTi | | |
1213 +-------------------------------------------------------------------+ | |
1214 | |
1215 PURPOSE : this function returns a used ti to the ti pool if the | |
1216 call was a MOS. the ti is free for the next MOS | |
1217 afterwards. | |
1218 a bit of the pool stands for a valid ti. | |
1219 0 indicates a used ti, 1 indicates a free ti. | |
1220 */ | |
1221 | |
1222 GLOBAL void psaSS_retMOSTi( SHORT sId ) | |
1223 { | |
1224 if( ssShrdPrm.stb[sId].srvType EQ ST_MOS ) | |
1225 | |
1226 if( ssShrdPrm.stb[sId].ti < MAX_MOSTI_NR ) | |
1227 | |
1228 tiPool |= (0x01 << ssShrdPrm.stb[sId].ti); | |
1229 } | |
1230 | |
1231 /* | |
1232 +-------------------------------------------------------------------+ | |
1233 | PROJECT : GSM-PS (6147) MODULE : PSA_SS | | |
1234 | ROUTINE : psaSS_InitStbNtry | | |
1235 +-------------------------------------------------------------------+ | |
1236 | |
1237 PURPOSE : initialize the indexed service table entry. | |
1238 | |
1239 */ | |
1240 | |
1241 GLOBAL void psaSS_InitStbNtry ( SHORT idx ) | |
1242 { | |
1243 | |
1244 /* | |
1245 *------------------------------------------------------------------- | |
1246 * initialize call table entry | |
1247 *------------------------------------------------------------------- | |
1248 */ | |
1249 ssShrdPrm.stb[idx].ntryUsdFlg = FALSE; | |
1250 ssShrdPrm.stb[idx].ti = NO_ENTRY; | |
1251 ssShrdPrm.stb[idx].iId = 0; | |
1252 ssShrdPrm.stb[idx].srvStat = NO_VLD_SSS; | |
1253 ssShrdPrm.stb[idx].srvType = NO_VLD_ST; | |
1254 ssShrdPrm.stb[idx].orgOPC = NOT_PRESENT_8BIT; | |
1255 ssShrdPrm.stb[idx].opCode = NOT_PRESENT_8BIT; | |
1256 ssShrdPrm.stb[idx].ssCode = NOT_PRESENT_8BIT; | |
1257 ssShrdPrm.stb[idx].ussdReqFlg = FALSE; | |
1258 ssShrdPrm.stb[idx].failType = NO_VLD_SSF; | |
1259 ssShrdPrm.stb[idx].entCs = NOT_PRESENT_16BIT; | |
1260 ssShrdPrm.stb[idx].rejPrb = NOT_PRESENT_8BIT; | |
1261 ssShrdPrm.stb[idx].errCd = NOT_PRESENT_8BIT; | |
1262 ssShrdPrm.stb[idx].errPrms = NOT_PRESENT_8BIT; | |
1263 ssShrdPrm.stb[idx].curCmd = AT_CMD_NONE; | |
1264 ssShrdPrm.stb[idx].srvOwn = OWN_NONE; | |
1265 ssShrdPrm.stb[idx].SSver = DEF_SS_VER; | |
1266 ssShrdPrm.stb[idx].ussd_operation = FALSE; | |
1267 } | |
1268 | |
1269 /* | |
1270 +-------------------------------------------------------------------+ | |
1271 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
1272 | ROUTINE : psaSS_stbFindUssdReq | | |
1273 +-------------------------------------------------------------------+ | |
1274 | |
1275 PURPOSE : returns the service table index for the entry that has a | |
1276 USSD request pending. | |
1277 Returning -1 indicates that no such service was found. | |
1278 */ | |
1279 | |
1280 GLOBAL SHORT psaSS_stbFindUssdReq ( void ) | |
1281 { | |
1282 SHORT stbIdx; /* holds call table index */ | |
1283 | |
1284 for( stbIdx = 0; stbIdx < MAX_SS_NR; stbIdx++ ) | |
1285 { | |
1286 if( ssShrdPrm.stb[stbIdx].ntryUsdFlg EQ TRUE AND | |
1287 ssShrdPrm.stb[stbIdx].ussdReqFlg EQ TRUE AND | |
1288 ssShrdPrm.stb[stbIdx].srvStat EQ SSS_ACT ) | |
1289 { | |
1290 return( stbIdx ); | |
1291 } | |
1292 } | |
1293 | |
1294 return( -1 ); | |
1295 } | |
1296 | |
1297 /* | |
1298 +-------------------------------------------------------------------+ | |
1299 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
1300 | ROUTINE : psaSS_stbFindActSrv | | |
1301 +-------------------------------------------------------------------+ | |
1302 | |
1303 PURPOSE : returns the service table index for the first entry that | |
1304 holds an active service which is not the passed index. | |
1305 Returning -1 indicates that no active service was found. | |
1306 */ | |
1307 | |
1308 GLOBAL SHORT psaSS_stbFindActSrv ( SHORT sId ) | |
1309 { | |
1310 SHORT stbIdx; /* holds call table index */ | |
1311 | |
1312 for( stbIdx = 0; stbIdx < MAX_SS_NR; stbIdx++ ) | |
1313 { | |
1314 if( ssShrdPrm.stb[stbIdx].ntryUsdFlg EQ TRUE AND | |
1315 ssShrdPrm.stb[stbIdx].srvStat EQ SSS_ACT ) | |
1316 { | |
1317 if( stbIdx NEQ sId ) | |
1318 | |
1319 return( stbIdx ); | |
1320 } | |
1321 } | |
1322 | |
1323 return( -1 ); | |
1324 } | |
1325 | |
1326 /* | |
1327 +-------------------------------------------------------------------+ | |
1328 | PROJECT : GSM-PS (6147) MODULE : PSA_SS | | |
1329 | ROUTINE : psaSS_Init | | |
1330 +-------------------------------------------------------------------+ | |
1331 | |
1332 PURPOSE : initialize the protocol stack adapter for SS. | |
1333 | |
1334 */ | |
1335 | |
1336 GLOBAL void psaSS_Init ( void ) | |
1337 { | |
1338 UBYTE stbIdx; /* holds index to service table */ | |
1339 | |
1340 /* | |
1341 *------------------------------------------------------------------- | |
1342 * initialize service table | |
1343 *------------------------------------------------------------------- | |
1344 */ | |
1345 for( stbIdx = 0; stbIdx < MAX_SS_NR; stbIdx++ ) | |
1346 { | |
1347 psaSS_InitStbNtry( stbIdx ); | |
1348 } | |
1349 | |
1350 /* | |
1351 *------------------------------------------------------------------- | |
1352 * initialize shared parameter | |
1353 *------------------------------------------------------------------- | |
1354 */ | |
1355 ssShrdPrm.nrOfMOS = 0; | |
1356 ssShrdPrm.nrOfMTS = 0; | |
1357 ssShrdPrm.iIdNxt = 0; | |
1358 } | |
1359 | |
1360 /* | |
1361 +-------------------------------------------------------------------+ | |
1362 | PROJECT : GSM-PS (6147) MODULE : PSA_SS | | |
1363 | ROUTINE : psaSS_DumpFIE | | |
1364 +-------------------------------------------------------------------+ | |
1365 | |
1366 PURPOSE : Dump facility information element to debug output. | |
1367 | |
1368 */ | |
1369 | |
1370 GLOBAL void psaSS_DumpFIE ( T_fac_inf * fie ) | |
1371 { | |
1372 | |
1373 CHAR strBuf[40+1]; /* holds string buffer */ | |
1374 UBYTE idx, cnt, mcnt; /* buffer index */ | |
1375 CHAR *pDest; /* points to destination */ | |
1376 | |
1377 /* | |
1378 *------------------------------------------------------------------- | |
1379 * format FIE | |
1380 *------------------------------------------------------------------- | |
1381 */ | |
1382 TRACE_EVENT( "FIE SENT/RECEIVED:" ); | |
1383 | |
1384 mcnt = fie->l_fac >> 3; | |
1385 | |
1386 if( mcnt EQ 0 ) | |
1387 { | |
1388 TRACE_EVENT("Empty Facility"); | |
1389 return; | |
1390 } | |
1391 | |
1392 for( cnt = 0; cnt < mcnt; cnt+=idx ) | |
1393 { | |
1394 pDest = strBuf; | |
1395 | |
1396 for( idx = 0; idx < 20 AND idx+cnt < mcnt; idx++ ) | |
1397 { | |
1398 pDest += sprintf( pDest, "%02X", (UBYTE)fie->fac[idx+cnt] ); | |
1399 } | |
1400 | |
1401 *pDest = 0x0; | |
1402 | |
1403 TRACE_EVENT( strBuf ); | |
1404 } | |
1405 } | |
1406 | |
1407 /* | |
1408 +-------------------------------------------------------------------+ | |
1409 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
1410 | ROUTINE : psaSS_stbDump | | |
1411 +-------------------------------------------------------------------+ | |
1412 | |
1413 PURPOSE : this function dumps the service table to the debug output. | |
1414 */ | |
1415 | |
1416 GLOBAL void psaSS_stbDump ( void ) | |
1417 { | |
1418 #ifdef TRACING | |
1419 | |
1420 SHORT stbIdx; /* holds service table index */ | |
1421 char lnBuf[HDR_WDT+(MAX_ITM*ITM_WDT)+1]; /* holds buffer for output line */ | |
1422 char verBuf[VERSION_LEN+1]; /* holds buffer for SS version */ | |
1423 SHORT itmIdx; /* holds items per line index */ | |
1424 SHORT chrNr; /* holds number of processed chars */ | |
1425 | |
1426 for( stbIdx = 0; stbIdx < MAX_SS_NR; stbIdx+=MAX_ITM ) | |
1427 { | |
1428 /* --- service id ----------------------------------------------------------*/ | |
1429 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, " srv id"); | |
1430 | |
1431 for( itmIdx = 0; (itmIdx<MAX_ITM)AND(itmIdx+stbIdx<MAX_SS_NR); itmIdx++ ) | |
1432 { | |
1433 chrNr += sprintf( lnBuf+chrNr, "%*d", ITM_WDT, stbIdx + itmIdx ); | |
1434 } | |
1435 TRACE_EVENT( lnBuf ); | |
1436 | |
1437 /* --- entry used flag -----------------------------------------------------*/ | |
1438 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, "entry used" ); | |
1439 | |
1440 for( itmIdx = 0; (itmIdx<MAX_ITM)AND(itmIdx<MAX_SS_NR); itmIdx++ ) | |
1441 { | |
1442 chrNr += sprintf( lnBuf+chrNr, "%*hd", ITM_WDT, | |
1443 ssShrdPrm.stb[stbIdx+itmIdx].ntryUsdFlg ); | |
1444 } | |
1445 TRACE_EVENT( lnBuf ); | |
1446 | |
1447 /* --- transaction identifier ----------------------------------------------*/ | |
1448 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, " ti" ); | |
1449 | |
1450 for( itmIdx = 0; (itmIdx<MAX_ITM)AND(itmIdx<MAX_SS_NR); itmIdx++ ) | |
1451 { | |
1452 chrNr += sprintf( lnBuf+chrNr, "%*hd", ITM_WDT, | |
1453 ssShrdPrm.stb[stbIdx+itmIdx].ti ); | |
1454 } | |
1455 TRACE_EVENT( lnBuf ); | |
1456 | |
1457 /* --- service status ------------------------------------------------------*/ | |
1458 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, "srv status" ); | |
1459 | |
1460 for( itmIdx = 0; (itmIdx<MAX_ITM)AND(itmIdx<MAX_SS_NR); itmIdx++ ) | |
1461 { | |
1462 chrNr += sprintf( lnBuf+chrNr, "%*hd", ITM_WDT, | |
1463 ssShrdPrm.stb[stbIdx+itmIdx].srvStat ); | |
1464 } | |
1465 TRACE_EVENT( lnBuf ); | |
1466 | |
1467 /* --- service type --------------------------------------------------------*/ | |
1468 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, " srv type" ); | |
1469 | |
1470 for( itmIdx = 0; (itmIdx<MAX_ITM)AND(itmIdx<MAX_SS_NR); itmIdx++ ) | |
1471 { | |
1472 chrNr += sprintf( lnBuf+chrNr, "%*hd", ITM_WDT, | |
1473 ssShrdPrm.stb[stbIdx+itmIdx].srvType ); | |
1474 } | |
1475 TRACE_EVENT( lnBuf ); | |
1476 | |
1477 /* --- SS version ----------------------------------------------------------*/ | |
1478 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, "SS version" ); | |
1479 | |
1480 for( itmIdx = 0; (itmIdx<MAX_ITM)AND(itmIdx<MAX_SS_NR); itmIdx++ ) | |
1481 { | |
1482 chrNr += sprintf( lnBuf+chrNr, "%*d", ITM_WDT, | |
1483 ssShrdPrm.stb[stbIdx+itmIdx].SSver ); | |
1484 } | |
1485 TRACE_EVENT( lnBuf ); | |
1486 | |
1487 /* --- failure type ------------------------------------------------------*/ | |
1488 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, "fail. type" ); | |
1489 | |
1490 for( itmIdx = 0; (itmIdx<MAX_ITM)AND(itmIdx<MAX_SS_NR); itmIdx++ ) | |
1491 { | |
1492 chrNr += sprintf( lnBuf+chrNr, "%*d", ITM_WDT, | |
1493 ssShrdPrm.stb[stbIdx+itmIdx].failType ); | |
1494 } | |
1495 TRACE_EVENT( lnBuf ); | |
1496 | |
1497 /* --- entity cause ------------------------------------------------------*/ | |
1498 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, "ent. cause" ); | |
1499 | |
1500 for( itmIdx = 0; (itmIdx<MAX_ITM)AND(itmIdx<MAX_SS_NR); itmIdx++ ) | |
1501 { | |
1502 chrNr += sprintf( lnBuf+chrNr, "%*d", ITM_WDT, | |
1503 ssShrdPrm.stb[stbIdx+itmIdx].entCs ); | |
1504 } | |
1505 TRACE_EVENT( lnBuf ); | |
1506 | |
1507 /* --- reject problem ----------------------------------------------------*/ | |
1508 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, " rej. prob" ); | |
1509 | |
1510 for( itmIdx = 0; (itmIdx<MAX_ITM)AND(itmIdx<MAX_SS_NR); itmIdx++ ) | |
1511 { | |
1512 chrNr += sprintf( lnBuf+chrNr, "%*hd", ITM_WDT, | |
1513 ssShrdPrm.stb[stbIdx+itmIdx].rejPrb ); | |
1514 } | |
1515 TRACE_EVENT( lnBuf ); | |
1516 | |
1517 /* --- error code ----------------------------------------------------*/ | |
1518 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, " err. code" ); | |
1519 | |
1520 for( itmIdx = 0; (itmIdx<MAX_ITM)AND(itmIdx<MAX_SS_NR); itmIdx++ ) | |
1521 { | |
1522 chrNr += sprintf( lnBuf+chrNr, "%*hd", ITM_WDT, | |
1523 ssShrdPrm.stb[stbIdx+itmIdx].errCd ); | |
1524 } | |
1525 TRACE_EVENT( lnBuf ); | |
1526 | |
1527 } | |
1528 | |
1529 #endif /* of #ifdef TRACING */ | |
1530 } | |
1531 | |
1532 /* | |
1533 +-------------------------------------------------------------------+ | |
1534 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF | | |
1535 | ROUTINE : psaSS_shrPrmDump | | |
1536 +-------------------------------------------------------------------+ | |
1537 | |
1538 PURPOSE : this function dumps the shared parameter to the debug | |
1539 output. | |
1540 */ | |
1541 | |
1542 GLOBAL void psaSS_shrPrmDump ( void ) | |
1543 { | |
1544 #ifdef TRACING | |
1545 | |
1546 char lnBuf[80]; /* holds buffer for output line */ | |
1547 SHORT chrNr; /* holds number of processed chars */ | |
1548 | |
1549 /* --- nr of MOSs -----------------------------------------------*/ | |
1550 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, "nr. of MOS" ); | |
1551 chrNr += sprintf( lnBuf+chrNr, "%*d", ITM_WDT, | |
1552 ssShrdPrm.nrOfMOS ); | |
1553 TRACE_EVENT( lnBuf ); | |
1554 | |
1555 /* --- nr of MTSs -----------------------------------------------*/ | |
1556 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, "nr. of MTS" ); | |
1557 chrNr += sprintf( lnBuf+chrNr, "%*d", ITM_WDT, | |
1558 ssShrdPrm.nrOfMTS ); | |
1559 TRACE_EVENT( lnBuf ); | |
1560 | |
1561 #endif /* of #ifdef TRACING */ | |
1562 } | |
1563 | |
1564 /* | |
1565 +-------------------------------------------------------------------+ | |
1566 | PROJECT : GSM-PS (6147) MODULE : CMH_F | | |
1567 | ROUTINE : psaSS_GetPendingTrn | | |
1568 +-------------------------------------------------------------------+ | |
1569 | |
1570 PURPOSE : Find Id of a pending call for multy-transaction operation | |
1571 | |
1572 */ | |
1573 | |
1574 GLOBAL SHORT psaSS_GetPendingTrn ( void ) | |
1575 { | |
1576 SHORT bit_len; | |
1577 SHORT i; | |
1578 | |
1579 bit_len = 8 * sizeof(ssShrdPrm.mltyTrnFlg); | |
1580 for (i = 0; i < bit_len; i++) | |
1581 { | |
1582 if ( ssShrdPrm.mltyTrnFlg & ( 0x1 << i ) ) | |
1583 return i; | |
1584 } | |
1585 | |
1586 return -1; | |
1587 } | |
1588 | |
1589 GLOBAL void psaSS_KillAllPendingTrn ( void ) /* sId: main transaction: not to be killed */ | |
1590 { | |
1591 SHORT pending_idx; | |
1592 | |
1593 TRACE_FUNCTION("psaSS_KillAllPendingTrn( )"); | |
1594 | |
1595 while ( ssShrdPrm.mltyTrnFlg ) | |
1596 { | |
1597 pending_idx = psaSS_GetPendingTrn( ); | |
1598 ssShrdPrm.mltyTrnFlg &= ~( 1u << pending_idx ); /* unsent id flag */ | |
1599 | |
1600 ssShrdPrm.stb[ pending_idx ].ntryUsdFlg = FALSE; /* free entry in ss table */ | |
1601 ssShrdPrm.stb[ pending_idx ].srvStat = NO_VLD_SSS; /* not sure if it's necessary...? */ | |
1602 | |
1603 PFREE( ssShrdPrm.stb[pending_idx].save_prim ); /* free pending primitive */ | |
1604 } | |
1605 } | |
1606 | |
1607 /*==== EOF ========================================================*/ | |
1608 |