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