FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/g23m-aci/aci/psa_sats.c @ 775:eedbf248bac0
gsm-fw/g23m-aci subtree: initial import from LoCosto source
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 12 Oct 2014 01:45:14 +0000 |
parents | |
children | 4c476f4254c4 |
comparison
equal
deleted
inserted
replaced
774:40a721fd9854 | 775:eedbf248bac0 |
---|---|
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((T_OWN)satShrdPrm.owner) AND | |
118 satShrdPrm.owner NEQ OWN_SRC_INV ) | |
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((T_OWN)satShrdPrm.owner) AND | |
191 satShrdPrm.owner NEQ OWN_SRC_INV ) | |
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 /* If ccAct is valid then set the req_id to SRQ_ACI to process the same | |
206 in the confirmation. Otherwise set the req_id to NO_VALID_SRQ */ | |
207 if (satShrdPrm.SIMCCParm.ccAct NEQ NO_CC_ACT) | |
208 { | |
209 if (satShrdPrm.Cbch_EvtDnl) /* Will be TRUE for CBCH and Event Downlaod */ | |
210 { | |
211 sim_toolkit_req->req_id = NO_VALID_SRQ; | |
212 } | |
213 else | |
214 { | |
215 sim_toolkit_req->req_id = SRQ_ACI; | |
216 } | |
217 } | |
218 else | |
219 { | |
220 sim_toolkit_req->req_id = NO_VALID_SRQ; | |
221 } | |
222 if (stk_cmd NEQ NULL) | |
223 { | |
224 sim_toolkit_req->stk_cmd = *stk_cmd; /* Struct copy */ | |
225 } | |
226 else | |
227 { | |
228 if (psaSAT_STKBuildCmd (&sim_toolkit_req->stk_cmd) < 0) | |
229 { | |
230 PFREE( sim_toolkit_req ); | |
231 return( -1 ); | |
232 } | |
233 } | |
234 } | |
235 | |
236 psaSAT_DumpCmd ( &sim_toolkit_req -> stk_cmd ); | |
237 | |
238 PSENDX (SIM, sim_toolkit_req); | |
239 } | |
240 | |
241 return 0; | |
242 } | |
243 | |
244 /* | |
245 +-------------------------------------------------------------------+ | |
246 | PROJECT : GSM-PS (6147) MODULE : PSA | | |
247 | ROUTINE : checkRefreshUserResp| | |
248 +-------------------------------------------------------------------+ | |
249 | |
250 PURPOSE : check whether the user has accepted the Refresh Request or Not | |
251 'p' is a pointer to the StkCmd | |
252 */ | |
253 | |
254 LOCAL BOOL checkRefreshUserResp ( UBYTE *p ) | |
255 { | |
256 const UBYTE TermRespRefreshOk [12] = | |
257 { | |
258 0x81, /* 0: command details tag */ | |
259 0x03, /* 1: command details length */ | |
260 0x00, /* 2: not used */ | |
261 0x01, /* 3: command REFRESH */ | |
262 0x00, /* 4: not used */ | |
263 0x82, /* 5: device details tag */ | |
264 0x02, /* 6: device details length */ | |
265 0x82, /* 7: source ME */ | |
266 0x81, /* 8: destination SIM */ | |
267 0x83, /* 9: result tag */ | |
268 0x00, /* 10: not used */ | |
269 0x00 /* 11: result OK */ | |
270 }; | |
271 | |
272 | |
273 TRACE_FUNCTION("checkRefreshUserResp"); | |
274 | |
275 if (!memcmp((const UBYTE*) p, TermRespRefreshOk,2)) /* Command Details Tag and Length*/ | |
276 { | |
277 if ((*(p+3) EQ TermRespRefreshOk[3]) AND /* Is this the REFRESH Command ... 'no' here would be trouble */ | |
278 (!memcmp((const UBYTE*)(p+5), TermRespRefreshOk+5, 5)) AND /* Device Details and Result Tag are correct */ | |
279 (*(p+11) EQ TermRespRefreshOk[11])) /* The result is OK */ | |
280 { | |
281 return TRUE; /* The User has accepted the Refresh Request */ | |
282 } | |
283 else | |
284 { | |
285 return FALSE; /* The User has rejected the Refresh Request */ | |
286 } | |
287 } | |
288 else | |
289 { | |
290 return FALSE; /* The User has rejected the Refresh Request */ | |
291 } | |
292 } | |
293 | |
294 #ifdef TI_PS_FF_AT_P_CMD_CUST | |
295 /* | |
296 +-------------------------------------------------------------------+ | |
297 | PROJECT : GSM-PS (6147) MODULE : PSA_SATS | | |
298 | ROUTINE : psaSAT_SendRefreshUserRes | | |
299 +-------------------------------------------------------------------+ | |
300 | |
301 PURPOSE : Send the User Response to a SIM Toolkit Refresh Request | |
302 | |
303 */ | |
304 | |
305 GLOBAL void psaSAT_SendRefreshUserRes( SHORT len, UBYTE *satCmd ) | |
306 { | |
307 | |
308 TRACE_FUNCTION ("psaSAT_SendRefreshUserRes()"); | |
309 | |
310 /* | |
311 *------------------------------------------------------------------- | |
312 * create and send primitive | |
313 *------------------------------------------------------------------- | |
314 */ | |
315 { | |
316 PALLOC (sim_refresh_user_res, SIM_REFRESH_USER_RES); | |
317 | |
318 /* fill in primitive parameter: STK envelope */ | |
319 sim_refresh_user_res->user_accepts = checkRefreshUserResp(satCmd); | |
320 | |
321 sim_refresh_user_res -> stk_cmd.l_cmd = len << 3; | |
322 sim_refresh_user_res -> stk_cmd.o_cmd = 0; | |
323 memcpy( sim_refresh_user_res -> stk_cmd.cmd, satCmd, len ); | |
324 | |
325 psaSAT_DumpCmd ( &sim_refresh_user_res -> stk_cmd ); | |
326 | |
327 PSENDX (SIM, sim_refresh_user_res); | |
328 } | |
329 | |
330 return; | |
331 } | |
332 #endif /* TI_PS_FF_AT_P_CMD_CUST */ | |
333 #endif /* #ifdef SIM_TOOLKIT */ | |
334 /*==== EOF ========================================================*/ | |
335 |