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