comparison src/aci2/aci/aci_bat_ss.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-F&D (8411)
4 | Modul : ACI_BAT
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 BAT wrapper modul is ...
18 |
19 +-----------------------------------------------------------------------------
20 */
21
22 #include "aci_all.h" /* includes prim.h, which includes p_bat.h */
23 #include "aci_cmh.h"
24 #include "ati_cmd.h"
25 #include "aci_cmd.h" /* prototypes of helper functions */
26 #include "psa.h"
27 #include "cmh.h"
28 #include "aci_bat_cmh.h" /* prototypes of sBAT_,qBAT_,tBAT_ */
29 #include "aci_bat.h"
30 #include "aci_bat_err.h" /*prototypes of err functions for BAT*/
31
32
33 /*
34 +--------------------------------------------------------------------+
35 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
36 | STATE : code ROUTINE : sBAT_PlusCTFR |
37 +--------------------------------------------------------------------+
38
39 PURPOSE :
40 */
41 GLOBAL T_ACI_BAT_RSLT sBAT_PlusCTFR (T_ACI_DTI_PRC_PSI *src_infos_psi,
42 T_BAT_cmd_send *cmd)
43 {
44 T_ACI_BAT_RSLT ret = ACI_BAT_FAIL;
45 T_ACI_TOA type;
46 T_ACI_TOA *p_type;
47 T_ACI_TOS satype;
48 T_ACI_TOS *p_satype;
49 //CHAR *subadr = subBuf;
50 char subBuf[MAX_SUBADDR_LEN]={0};
51 char* p_subBuf;
52 SHORT toa_oct = 0;
53 SHORT tos_oct = 0;
54 CHAR numBuf[MAX_B_SUBSCR_NUM_LEN];
55
56 TRACE_FUNCTION ("sBAT_PlusCTFR()");
57
58 p_type = &type;
59 p_satype = &satype;
60 p_subBuf = subBuf;
61 memset( numBuf, 0, sizeof(numBuf));
62
63 memcpy(numBuf,cmd->params.ptr_set_plus_ctfr->number,cmd->params.ptr_set_plus_ctfr->c_number);
64
65 if ( cmd->params.ptr_set_plus_ctfr->type EQ BAT_PARAMETER_NOT_PRESENT )
66 {
67 p_type = NULL;
68 }
69 else
70 {
71 toa_oct = cmd->params.ptr_set_plus_ctfr->type;
72 }
73 if ( cmd->params.ptr_set_plus_ctfr->satype EQ BAT_PARAMETER_NOT_PRESENT )
74 {
75 p_satype = NULL;
76 }
77 else
78 {
79 tos_oct = cmd->params.ptr_set_plus_ctfr->satype;
80 }
81 /* Type Of Address present */
82 type = toa_demerge (toa_oct);
83 if (type.ton < 0 OR type.npi < 0)
84 {
85 ACI_ERR_DESC(ACI_ERR_CLASS_Cme,CME_ERR_OpNotAllow);
86 return (ACI_BAT_FAIL);
87 }
88 satype = tos_demerge (tos_oct);
89 if (satype.tos < 0 OR satype.oe < 0)
90 {
91 ACI_ERR_DESC(ACI_ERR_CLASS_Cme,CME_ERR_OpNotAllow);
92 return (ACI_BAT_FAIL);
93 }
94
95 if(cmd->params.ptr_set_plus_ctfr->v_subaddr)
96 {
97 memcpy(subBuf,cmd->params.ptr_set_plus_ctfr->subaddr,cmd->params.ptr_set_plus_ctfr->c_subaddr);
98 }
99 else
100 {
101 p_subBuf = NULL;
102 }
103 ret = sAT_PlusCTFR (src_infos_psi->srcId, numBuf, p_type, p_subBuf, p_satype);
104 return(ret);
105 }
106
107 /*
108 +--------------------------------------------------------------------+
109 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
110 | STATE : code ROUTINE : sBAT_PlusCCFC |
111 +--------------------------------------------------------------------+
112
113 PURPOSE :
114 */
115 GLOBAL T_ACI_BAT_RSLT sBAT_PlusCCFC (T_ACI_DTI_PRC_PSI *src_infos_psi,
116 T_BAT_cmd_send *cmd)
117 {
118 T_ACI_BAT_RSLT ret = ACI_BAT_FAIL;
119 T_BAT_plus_ccfc_reason reason;
120 T_BAT_plus_ccfc_mode mode;
121 T_ACI_TOA type;
122 T_ACI_TOA *p_type;
123 T_ACI_TOS satype;
124 T_ACI_TOS *p_satype;
125 T_BAT_plus_ccfc_bearer_class class_type=BAT_CCFC_CLASS_NOT_PRESENT;
126 //CHAR *subadr = subBuf;
127 char subBuf[MAX_SUBADDR_LEN]={0};
128 char* p_subBuf;
129 T_BAT_plus_ccfc_time time=BAT_CCFC_TIME_NOT_PRESENT;
130 SHORT toa_oct=0;
131 SHORT tos_oct=0;
132 CHAR numBuf[MAX_B_SUBSCR_NUM_LEN];
133 CHAR* p_numBuf;
134
135 TRACE_FUNCTION ("sBAT_PlusCCFC()");
136
137 p_type=&type;
138 p_satype=&satype;
139 p_subBuf = subBuf;
140 p_numBuf = numBuf;
141 memset( numBuf, 0, sizeof(numBuf));
142
143 reason = cmd->params.ptr_set_plus_ccfc->reason;
144 mode = cmd->params.ptr_set_plus_ccfc->mode;
145 toa_oct = cmd->params.ptr_set_plus_ccfc->type;
146 tos_oct = cmd->params.ptr_set_plus_ccfc->satype;
147 class_type = cmd->params.ptr_set_plus_ccfc->bearer_class;
148 time = cmd->params.ptr_set_plus_ccfc->time;
149
150 if (mode EQ BAT_CCFC_MODE_QUERY) /*query mode*/
151 {
152 ret = qAT_PlusCCFC(src_infos_psi->srcId,reason,class_type);
153 switch (ret)
154 {
155 case AT_EXCT:
156 case ATI_BUSY:
157 case ATI_FAIL:
158 {
159 return ret;
160 }
161 default:
162 {
163 return (ACI_BAT_FAIL);
164 }
165 }
166 }
167 if(cmd->params.ptr_set_plus_ccfc->v_subaddr)
168 {
169 memcpy(subBuf,cmd->params.ptr_set_plus_ccfc->subaddr,cmd->params.ptr_set_plus_ccfc->c_subaddr);
170 }
171 else
172 {
173 p_subBuf = NULL;
174 }
175
176 if ( cmd->params.ptr_set_plus_ccfc->type EQ BAT_PARAMETER_NOT_PRESENT )
177 {
178 p_type = NULL;
179 }
180 else
181 {
182 toa_oct = cmd->params.ptr_set_plus_ccfc->type;
183 }
184
185 if ( cmd->params.ptr_set_plus_ccfc->satype EQ BAT_PARAMETER_NOT_PRESENT )
186 {
187 p_satype = NULL;
188 }
189 else
190 {
191 tos_oct = cmd->params.ptr_set_plus_ccfc->satype;
192 }
193 /* Type Of Address present */
194 type = toa_demerge (toa_oct);
195 if (type.ton < 0 OR type.npi < 0)
196 {
197 ACI_ERR_DESC(ACI_ERR_CLASS_Cme,CME_ERR_OpNotAllow);
198 return (ACI_BAT_FAIL);
199 }
200
201 satype = tos_demerge (tos_oct);
202 if (satype.tos < 0 OR satype.oe < 0)
203 {
204 ACI_ERR_DESC(ACI_ERR_CLASS_Cme,CME_ERR_OpNotAllow);
205 return (ACI_BAT_FAIL);
206 }
207
208 if(cmd->params.ptr_set_plus_ccfc->v_number)
209 {
210 memcpy(numBuf,cmd->params.ptr_set_plus_ccfc->number,cmd->params.ptr_set_plus_ccfc->c_number);
211 }
212 else
213 {
214 p_numBuf = NULL;
215 }
216 ret = sAT_PlusCCFC(src_infos_psi->srcId,reason,mode,p_numBuf,p_type,class_type,p_subBuf,p_satype,time);
217 return(ret);
218 }
219
220 /*
221 +--------------------------------------------------------------------+
222 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
223 | STATE : code ROUTINE : sBAT_PlusCLCK |
224 +--------------------------------------------------------------------+
225
226 PURPOSE :
227 */
228 GLOBAL T_ACI_BAT_RSLT sBAT_PlusCLCK (T_ACI_DTI_PRC_PSI *src_infos_psi,
229 T_BAT_cmd_send *cmd)
230 {
231 T_ACI_BAT_RSLT ret = ACI_BAT_FAIL;
232 T_BAT_plus_clck_fac fac_num;
233 T_BAT_plus_clck_mode mod;
234 T_BAT_bearer_class class_type = BAT_CLASS_NOT_PRESENT;
235 T_BAT_cmd_response resp;
236 T_ACI_CLSSTAT clsStat;
237 char passwd[MAX_PWD_LENGTH]={0};
238
239 TRACE_FUNCTION ("sBAT_PlusCLCK()");
240
241 fac_num = cmd->params.ptr_set_plus_clck->fac;
242 mod = cmd->params.ptr_set_plus_clck->mode;
243 class_type = cmd->params.ptr_set_plus_clck->bearer_class;
244
245
246 if (mod EQ BAT_CLCK_MODE_QUERY) /*query mode*/
247 {
248 T_BAT_res_set_plus_clck clck;
249 ret=qAT_PlusCLCK(src_infos_psi->srcId,fac_num,class_type,&clsStat);
250 resp.ctrl_response = BAT_RES_SET_PLUS_CLCK;
251 resp.response.ptr_set_plus_clck = &clck;
252 resp.response.ptr_set_plus_clck->status = BAT_CLCK_STATUS_NOT_ACTIVE ;
253 resp.response.ptr_set_plus_clck->bearer_class = BAT_CLASS_NOT_PRESENT;
254
255 if(ret EQ AT_CMPL)
256 {
257 switch(clsStat.status)
258 {
259 case STATUS_Active:
260 resp.response.ptr_set_plus_clck->status = BAT_CLCK_STATUS_ACTIVE;
261 break;
262 case STATUS_NotActive:
263 resp.response.ptr_set_plus_clck->status = BAT_CLCK_STATUS_NOT_ACTIVE;
264 break;
265 }
266
267 if(clsStat.class_type NEQ CLASS_NotPresent)
268 {
269 resp.response.ptr_set_plus_clck->bearer_class = clsStat.class_type;
270 }
271 aci_bat_send(src_infos_psi , &resp);
272 return (ACI_BAT_CMPL);
273 }
274 }
275 else /*set mode*/
276 {
277 if(cmd->params.ptr_set_plus_clck->v_passwd)
278 {
279 memcpy(passwd,cmd->params.ptr_set_plus_clck->passwd,cmd->params.ptr_set_plus_clck->c_passwd);
280 }
281 ret = sAT_PlusCLCK(src_infos_psi->srcId,fac_num,mod,passwd,class_type);
282 }
283
284 switch(ret)
285 {
286 case AT_EXCT:
287 case AT_FAIL:
288 {
289 break;
290 }
291 case(AT_BUSY):
292 {
293 TRACE_EVENT("sBAT_PlusCLCK(): ME is busy");
294 break;
295 }
296 }
297 return(ret);
298 }
299
300 /*
301 +--------------------------------------------------------------------+
302 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
303 | STATE : code ROUTINE : sBAT_PlusCPWD |
304 +--------------------------------------------------------------------+
305
306 PURPOSE :
307 */
308 GLOBAL T_ACI_BAT_RSLT sBAT_PlusCPWD (T_ACI_DTI_PRC_PSI *src_infos_psi,
309 T_BAT_cmd_send *cmd)
310 {
311 T_ACI_BAT_RSLT ret = ACI_BAT_FAIL;
312 T_BAT_plus_cpwd_fac fac_num;
313 CHAR oldpwd[MAX_PWD_LENGTH]={0};
314 CHAR newpwd[MAX_PWD_LENGTH]={0};
315
316 TRACE_FUNCTION ("sBAT_PlusCPWD()");
317
318 fac_num = cmd->params.ptr_set_plus_cpwd->fac;
319 memcpy(oldpwd, cmd->params.ptr_set_plus_cpwd->oldpwd,cmd->params.ptr_set_plus_cpwd->c_oldpwd);
320 memcpy(newpwd, cmd->params.ptr_set_plus_cpwd->newpwd,cmd->params.ptr_set_plus_cpwd->c_newpwd);
321 ret = sAT_PlusCPWD(src_infos_psi->srcId,fac_num,oldpwd,newpwd);
322 return(ret);
323 }
324
325 /*
326 +--------------------------------------------------------------------+
327 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
328 | STATE : code ROUTINE : sBAT_PlusCUSD |
329 +--------------------------------------------------------------------+
330
331 PURPOSE :
332 */
333 GLOBAL T_ACI_BAT_RSLT sBAT_PlusCUSD (T_ACI_DTI_PRC_PSI *src_infos_psi,
334 T_BAT_cmd_send *cmd)
335 {
336 T_ACI_BAT_RSLT ret;
337 T_ACI_USSD_DATA ussd;
338 T_ACI_USSD_DATA *ussd_ptr;
339 T_BAT_cmd_set_plus_cusd *cusd;
340
341 TRACE_FUNCTION ("sBAT_PlusCUSD()");
342
343 /*
344 * Get a pointer to the BAT structure for convenience.
345 */
346 cusd=cmd->params.ptr_set_plus_cusd;
347
348 ussd_ptr=NULL;
349
350 if (cusd->v_str)
351 {
352 USHORT len;
353
354 utl_ussdDtaFromTe (
355 (UBYTE*)cusd->str,
356 cusd->c_str,
357 (UBYTE*)ussd.data,
358 &len,
359 (UBYTE)cusd->dcs);
360
361 if (len>MAX_USSD_LEN)
362 {
363 /*
364 * The USSD string is too big for the ACI structure. This should
365 * not happen, and if it does means that we have overwritten
366 * memory.
367 */
368 ACI_ERR_DESC(ACI_ERR_CLASS_Cme,CME_ERR_TxtToLong);
369 return(ACI_BAT_FAIL);
370 }
371
372 ussd.len=(UBYTE)len;
373 ussd_ptr=&ussd;
374 }
375
376 /*
377 * Call the corresponding sAT function. T_ACI_BAT_RSLT is
378 * assumed to be equivalent to T_ACI_RESULT.
379 */
380 ret=(T_ACI_BAT_RSLT)sAT_PlusCUSD(
381 src_infos_psi->srcId,
382 ussd_ptr,
383 (SHORT)cusd->dcs);
384
385 return(ret);
386 }
387