FreeCalypso > hg > fc-magnetite
comparison src/aci2/aci/psa_sats.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_SATS | |
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 signalling functions of the | |
18 | protocol stack adapter for the SIM application toolkit | |
19 | module. | |
20 +----------------------------------------------------------------------------- | |
21 */ | |
22 | |
23 #ifdef SIM_TOOLKIT | |
24 | |
25 #ifndef PSA_SATS_C | |
26 #define PSA_SATS_C | |
27 #endif | |
28 | |
29 #include "aci_all.h" | |
30 | |
31 /*==== INCLUDES ===================================================*/ | |
32 #include "aci_cmh.h" | |
33 #include "aci.h" | |
34 | |
35 #ifdef FAX_AND_DATA | |
36 #include "aci_fd.h" | |
37 #endif /* of #ifdef FAX_AND_DATA */ | |
38 | |
39 #include "psa.h" | |
40 #include "psa_cc.h" | |
41 #include "psa_sat.h" | |
42 #include "cmh.h" | |
43 #include "cmh_sat.h" | |
44 | |
45 /*==== CONSTANTS ==================================================*/ | |
46 | |
47 | |
48 /*==== TYPES ======================================================*/ | |
49 | |
50 | |
51 /*==== EXPORT =====================================================*/ | |
52 | |
53 | |
54 /*==== VARIABLES ==================================================*/ | |
55 | |
56 | |
57 /*==== FUNCTIONS ==================================================*/ | |
58 | |
59 /* | |
60 +-------------------------------------------------------------------+ | |
61 | PROJECT : GSM-PS (6147) MODULE : PSA_SATS | | |
62 | ROUTINE : psaSAT_STKBuildCmd | | |
63 +-------------------------------------------------------------------+ | |
64 | |
65 PURPOSE : build envelope of a SIM toolkit command | |
66 | |
67 */ | |
68 | |
69 GLOBAL SHORT psaSAT_STKBuildCmd ( T_stk_cmd *stk_cmd ) | |
70 { | |
71 UBYTE ccdRet; | |
72 | |
73 TRACE_FUNCTION ("psaSAT_STKBuildCmd()"); | |
74 | |
75 stk_cmd->l_cmd = MAX_STK_CMD << 3; | |
76 stk_cmd->o_cmd = 0; | |
77 | |
78 ccdRet = ccd_codeMsg (CCDENT_SAT, | |
79 UPLINK, | |
80 (T_MSGBUF *) stk_cmd, | |
81 (UBYTE *) _decodedMsg, | |
82 ENV_CMD); | |
83 | |
84 if (ccdRet NEQ ccdOK) | |
85 { | |
86 TRACE_EVENT_P1 ("CCD Coding Error: %d", ccdRet); | |
87 return -1; | |
88 } | |
89 return 0; | |
90 } | |
91 | |
92 | |
93 /* | |
94 +-------------------------------------------------------------------+ | |
95 | PROJECT : GSM-PS (6147) MODULE : PSA_SATS | | |
96 | ROUTINE : psaSAT_STKResponse | | |
97 +-------------------------------------------------------------------+ | |
98 | |
99 PURPOSE : respond to SIM toolkit command | |
100 | |
101 */ | |
102 | |
103 GLOBAL SHORT psaSAT_STKResponse ( void ) | |
104 { | |
105 T_SAT_SET_PRM * pPrmSet; /* points to used parameter set */ | |
106 | |
107 TRACE_FUNCTION ("psaSAT_STKResponse()"); | |
108 | |
109 /* | |
110 *------------------------------------------------------------------- | |
111 * create and send primitive | |
112 *------------------------------------------------------------------- | |
113 */ | |
114 { | |
115 PALLOC (sim_toolkit_res, SIM_TOOLKIT_RES); | |
116 | |
117 if(psa_IsVldOwnId(satShrdPrm.owner) AND | |
118 satShrdPrm.owner NEQ NO_VLD_OWN ) | |
119 { | |
120 pPrmSet = &satShrdPrm.setPrm[satShrdPrm.owner]; | |
121 | |
122 /* fill in primitive parameter: STK envelope */ | |
123 sim_toolkit_res -> stk_cmd.l_cmd = pPrmSet -> stkCmdLen << 3; | |
124 sim_toolkit_res -> stk_cmd.o_cmd = 0; | |
125 memcpy( sim_toolkit_res -> stk_cmd.cmd, pPrmSet -> stkCmd, | |
126 pPrmSet -> stkCmdLen ); | |
127 } | |
128 | |
129 else | |
130 { | |
131 UBYTE ccdRet; | |
132 | |
133 sim_toolkit_res -> stk_cmd.l_cmd = MAX_STK_CMD<<3; | |
134 sim_toolkit_res -> stk_cmd.o_cmd = 0; | |
135 | |
136 ccdRet = ccd_codeMsg (CCDENT_SAT, | |
137 UPLINK, | |
138 (T_MSGBUF *) &sim_toolkit_res -> stk_cmd, | |
139 (UBYTE *) _decodedMsg, | |
140 TERM_RESP); | |
141 | |
142 if( ccdRet NEQ ccdOK ) | |
143 { | |
144 TRACE_EVENT_P1("CCD Coding Error: %d",ccdRet ); | |
145 PFREE( sim_toolkit_res ); | |
146 return( -1 ); | |
147 } | |
148 | |
149 satShrdPrm.stkCmdLen = sim_toolkit_res -> stk_cmd.l_cmd; | |
150 satShrdPrm.stkCmd = sim_toolkit_res -> stk_cmd.cmd; | |
151 satShrdPrm.ntfy = USR_NTF_TRM_RSP; | |
152 | |
153 cmhSAT_STKUsrNtfy(); | |
154 } | |
155 | |
156 psaSAT_DumpCmd ( &sim_toolkit_res -> stk_cmd ); | |
157 | |
158 PSENDX (SIM, sim_toolkit_res); | |
159 } | |
160 | |
161 return 0; | |
162 } | |
163 | |
164 /* | |
165 +-------------------------------------------------------------------+ | |
166 | PROJECT : GSM-PS (6147) MODULE : PSA_SATS | | |
167 | ROUTINE : psaSAT_STKEnvelope | | |
168 +-------------------------------------------------------------------+ | |
169 | |
170 PURPOSE : send envelope of a SIM toolkit command | |
171 | |
172 */ | |
173 | |
174 GLOBAL SHORT psaSAT_STKEnvelope ( const T_stk_cmd *stk_cmd ) | |
175 { | |
176 T_SAT_SET_PRM * pPrmSet; /* points to used parameter set */ | |
177 | |
178 TRACE_FUNCTION ("psaSAT_STKEnvelope()"); | |
179 | |
180 /* | |
181 *------------------------------------------------------------------- | |
182 * create and send primitive | |
183 *------------------------------------------------------------------- | |
184 */ | |
185 { | |
186 PALLOC (sim_toolkit_req, SIM_TOOLKIT_REQ); /* T_SIM_TOOLKIT_REQ */ | |
187 | |
188 sim_toolkit_req -> source = SRC_MMI; | |
189 | |
190 if(psa_IsVldOwnId(satShrdPrm.owner) AND | |
191 satShrdPrm.owner NEQ NO_VLD_OWN ) | |
192 { | |
193 pPrmSet = &satShrdPrm.setPrm[satShrdPrm.owner]; | |
194 | |
195 /* fill in primitive parameter: STK envelope */ | |
196 sim_toolkit_req -> req_id = SRQ_MMI; | |
197 sim_toolkit_req -> stk_cmd.l_cmd = pPrmSet -> stkCmdLen << 3; | |
198 sim_toolkit_req -> stk_cmd.o_cmd = 0; | |
199 memcpy( sim_toolkit_req -> stk_cmd.cmd, pPrmSet -> stkCmd, | |
200 pPrmSet -> stkCmdLen ); | |
201 } | |
202 | |
203 else | |
204 { | |
205 /* avoid CC processing on CBCH Dwnl */ | |
206 sim_toolkit_req -> req_id = (satShrdPrm.SIMCCParm.ccAct EQ NO_CC_ACT)? | |
207 NO_VALID_SRQ: SRQ_ACI; | |
208 if (stk_cmd NEQ NULL) | |
209 { | |
210 sim_toolkit_req->stk_cmd = *stk_cmd; /* Struct copy */ | |
211 } | |
212 else | |
213 { | |
214 if (psaSAT_STKBuildCmd (&sim_toolkit_req->stk_cmd) < 0) | |
215 { | |
216 PFREE( sim_toolkit_req ); | |
217 return( -1 ); | |
218 } | |
219 } | |
220 } | |
221 | |
222 psaSAT_DumpCmd ( &sim_toolkit_req -> stk_cmd ); | |
223 | |
224 PSENDX (SIM, sim_toolkit_req); | |
225 } | |
226 | |
227 return 0; | |
228 } | |
229 | |
230 /* | |
231 +-------------------------------------------------------------------+ | |
232 | PROJECT : GSM-PS (6147) MODULE : PSA | | |
233 | ROUTINE : checkRefreshUserResp| | |
234 +-------------------------------------------------------------------+ | |
235 | |
236 PURPOSE : check whether the user has accepted the Refresh Request or Not | |
237 'p' is a pointer to the StkCmd | |
238 */ | |
239 | |
240 LOCAL BOOL checkRefreshUserResp ( UBYTE *p ) | |
241 { | |
242 const UBYTE TermRespRefreshOk [12] = | |
243 { | |
244 0x81, /* 0: command details tag */ | |
245 0x03, /* 1: command details length */ | |
246 0x00, /* 2: not used */ | |
247 0x01, /* 3: command REFRESH */ | |
248 0x00, /* 4: not used */ | |
249 0x82, /* 5: device details tag */ | |
250 0x02, /* 6: device details length */ | |
251 0x82, /* 7: source ME */ | |
252 0x81, /* 8: destination SIM */ | |
253 0x83, /* 9: result tag */ | |
254 0x00, /* 10: not used */ | |
255 0x00 /* 11: result OK */ | |
256 }; | |
257 | |
258 | |
259 TRACE_FUNCTION("checkRefreshUserResp"); | |
260 | |
261 if (!memcmp((const UBYTE*) p, TermRespRefreshOk,2)) /* Command Details Tag and Length*/ | |
262 { | |
263 if ((*(p+3) EQ TermRespRefreshOk[3]) AND /* Is this the REFRESH Command ... 'no' here would be trouble */ | |
264 (!memcmp((const UBYTE*)(p+5), TermRespRefreshOk+5, 5)) AND /* Device Details and Result Tag are correct */ | |
265 (*(p+11) EQ TermRespRefreshOk[11])) /* The result is OK */ | |
266 { | |
267 return TRUE; /* The User has accepted the Refresh Request */ | |
268 } | |
269 else | |
270 { | |
271 return FALSE; /* The User has rejected the Refresh Request */ | |
272 } | |
273 } | |
274 else | |
275 { | |
276 return FALSE; /* The User has rejected the Refresh Request */ | |
277 } | |
278 } | |
279 | |
280 | |
281 /* | |
282 +-------------------------------------------------------------------+ | |
283 | PROJECT : GSM-PS (6147) MODULE : PSA_SATS | | |
284 | ROUTINE : psaSAT_SendRefreshUserRes | | |
285 +-------------------------------------------------------------------+ | |
286 | |
287 PURPOSE : Send the User Response to a SIM Toolkit Refresh Request | |
288 | |
289 */ | |
290 | |
291 GLOBAL void psaSAT_SendRefreshUserRes( SHORT len, UBYTE *satCmd ) | |
292 { | |
293 | |
294 TRACE_FUNCTION ("psaSAT_SendRefreshUserRes()"); | |
295 | |
296 /* | |
297 *------------------------------------------------------------------- | |
298 * create and send primitive | |
299 *------------------------------------------------------------------- | |
300 */ | |
301 { | |
302 PALLOC (sim_refresh_user_res, SIM_REFRESH_USER_RES); | |
303 | |
304 /* fill in primitive parameter: STK envelope */ | |
305 sim_refresh_user_res->user_accepts = checkRefreshUserResp(satCmd); | |
306 | |
307 sim_refresh_user_res -> stk_cmd.l_cmd = len << 3; | |
308 sim_refresh_user_res -> stk_cmd.o_cmd = 0; | |
309 memcpy( sim_refresh_user_res -> stk_cmd.cmd, satCmd, len ); | |
310 | |
311 psaSAT_DumpCmd ( &sim_refresh_user_res -> stk_cmd ); | |
312 | |
313 PSENDX (SIM, sim_refresh_user_res); | |
314 } | |
315 | |
316 return; | |
317 } | |
318 | |
319 #endif /* #ifdef SIM_TOOLKIT */ | |
320 /*==== EOF ========================================================*/ | |
321 |