comparison src/g23m-aci/aci/aci_bat_phb.c @ 1:d393cd9bb723

src/g23m-*: initial import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jul 2018 04:40:46 +0000
parents
children
comparison
equal deleted inserted replaced
0:b6a5e36de839 1:d393cd9bb723
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" /* prototypes of sAT_,qAT_,tAT_ */
24 #include "aci_bat_cmh.h" /* prototypes of sBAT_,qBAT_,tBAT_ */
25 #include "aci_bat.h"
26 #include "ati_cmd.h"
27 #include "aci_cmd.h"
28 #include "aci_mem.h" /* MAKROS ACI_MALLOC, ACI_MFREE*/
29
30
31 /*
32 +--------------------------------------------------------------------+
33 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
34 | STATE : code ROUTINE : sBAT_PercentPBCF |
35 +--------------------------------------------------------------------+
36
37 PURPOSE : Select Phonebook Configuration.
38 */
39
40 GLOBAL T_ACI_BAT_RSLT sBAT_PercentPBCF (T_ACI_DTI_PRC_PSI *src_infos_psi,
41 T_BAT_cmd_send *cmd)
42 {
43 T_ACI_BAT_RSLT ret;
44 T_ACI_PBCF_LDN ldn = PBCF_LDN_NotPresent;
45 T_ACI_PBCF_LRN lrn = PBCF_LRN_NotPresent;
46 T_ACI_PBCF_LMN lmn = PBCF_LMN_NotPresent;
47
48 TRACE_FUNCTION ("sBAT_PercentPBCF()");
49
50 ldn = (T_ACI_PBCF_LDN)cmd->params.ptr_set_percent_pbcf->ldn;
51 lrn = (T_ACI_PBCF_LRN)cmd->params.ptr_set_percent_pbcf->lrn;
52 lmn = (T_ACI_PBCF_LMN)cmd->params.ptr_set_percent_pbcf->lmn;
53
54 /*
55 * Call the corresponding sAT function. T_ACI_BAT_RSLT is
56 * assumed to be equivalent to T_ACI_RESULT.
57 */
58 /* for BAT we use the old spec, which means the third param is not supported */
59 ret = (T_ACI_BAT_RSLT)sAT_PercentPBCF((T_ACI_CMD_SRC)src_infos_psi->srcId, ldn, lrn, lmn);
60
61 return(ret);
62 }
63
64 /*
65 +--------------------------------------------------------------------+
66 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
67 | STATE : code ROUTINE : qBAT_PlusCPBS |
68 +--------------------------------------------------------------------+
69
70 PURPOSE :
71 */
72 GLOBAL T_ACI_BAT_RSLT qBAT_PercentPBCF (T_ACI_DTI_PRC_PSI *src_infos_psi,
73 T_BAT_cmd_send *cmd)
74 {
75 T_ACI_BAT_RSLT ret;
76 T_ACI_PBCF_LDN ldn = PBCF_LDN_NotPresent;
77 T_ACI_PBCF_LRN lrn = PBCF_LRN_NotPresent;
78 T_ACI_PBCF_LMN lmn = PBCF_LMN_NotPresent;
79
80 TRACE_FUNCTION ("qBAT_PercentPBCF()");
81
82 /*
83 * Call the corresponding qAT function. T_ACI_BAT_RSLT is
84 * assumed to be equivalent to T_ACI_RESULT.
85 */
86 ret=(T_ACI_BAT_RSLT)qAT_PercentPBCF((T_ACI_CMD_SRC)src_infos_psi->srcId, &ldn, &lrn, &lmn);
87
88 /*
89 * If the query completes, send the response now.
90 */
91 if (ret EQ ACI_BAT_CMPL)
92 {
93 T_BAT_cmd_response resp;
94 T_BAT_res_que_percent_pbcf pbcf_data;
95
96 resp.ctrl_response=BAT_RES_QUE_PERCENT_PBCF;
97 resp.response.ptr_que_percent_pbcf = &pbcf_data;
98
99 /*
100 * This relies on T_BAT_percent_pbcf_ldn being identical to
101 * T_ACI_PBCF_LDN and so forth for LRN and LMN.
102 */
103 pbcf_data.ldn=(T_BAT_percent_pbcf_ldn)ldn;
104 pbcf_data.lrn=(T_BAT_percent_pbcf_lrn)lrn;
105 pbcf_data.lmn=(T_BAT_percent_pbcf_lmn)lmn;
106
107 aci_bat_send(src_infos_psi,&resp);
108 }
109
110 return(ret);
111 }
112
113 /*
114 +--------------------------------------------------------------------+
115 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
116 | STATE : code ROUTINE : sBAT_PlusCPBS |
117 +--------------------------------------------------------------------+
118
119 PURPOSE : Select phonebook memory storage.
120 */
121 GLOBAL T_ACI_BAT_RSLT sBAT_PlusCPBS (T_ACI_DTI_PRC_PSI *src_infos_psi,
122 T_BAT_cmd_send *cmd)
123 {
124 T_ACI_BAT_RSLT ret;
125 T_ACI_PB_STOR stor;
126
127 TRACE_FUNCTION ("sBAT_PlusCPBS()");
128
129 /*
130 * This relies on T_BAT_storage being identical to
131 * T_ACI_PB_STOR.
132 */
133 stor=(T_ACI_PB_STOR)cmd->params.ptr_set_plus_cpbs->storage;
134
135 /*
136 * Call the corresponding sAT function. T_ACI_BAT_RSLT is
137 * assumed to be equivalent to T_ACI_RESULT.
138 */
139 /* for BAT we use the old spec, which means the third param is not supported */
140 ret=(T_ACI_BAT_RSLT)sAT_PlusCPBS((T_ACI_CMD_SRC)src_infos_psi->srcId,stor, NULL);
141
142 return(ret);
143 }
144
145 /*
146 +--------------------------------------------------------------------+
147 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
148 | STATE : code ROUTINE : qBAT_PlusCPBS |
149 +--------------------------------------------------------------------+
150
151 PURPOSE :
152 */
153 GLOBAL T_ACI_BAT_RSLT qBAT_PlusCPBS (T_ACI_DTI_PRC_PSI *src_infos_psi,
154 T_BAT_cmd_send *cmd)
155 {
156 T_ACI_BAT_RSLT ret;
157 T_ACI_PB_STOR stor;
158 SHORT used;
159 SHORT total;
160
161 TRACE_FUNCTION ("qBAT_PlusCPBS()");
162
163 /*
164 * Call the corresponding qAT function. T_ACI_BAT_RSLT is
165 * assumed to be equivalent to T_ACI_RESULT.
166 */
167 ret=(T_ACI_BAT_RSLT)qAT_PlusCPBS((T_ACI_CMD_SRC)src_infos_psi->srcId,&stor,&used,&total);
168
169 /*
170 * If the query completes, send the response now.
171 */
172 if (ret EQ ACI_BAT_CMPL)
173 {
174 T_BAT_cmd_response resp;
175 T_BAT_res_que_plus_cpbs cpbs_data;
176
177 resp.ctrl_response=BAT_RES_QUE_PLUS_CPBS;
178 resp.response.ptr_que_plus_cpbs=&cpbs_data;
179
180 /*
181 * This relies on T_BAT_storage being identical to
182 * T_ACI_PB_STOR.
183 */
184 cpbs_data.storage=(T_BAT_storage)stor;
185
186 cpbs_data.total=(S16)total;
187 cpbs_data.used=(S16)used;
188
189 aci_bat_send(src_infos_psi,&resp);
190 }
191
192 return(ret);
193 }
194
195 /*
196 +--------------------------------------------------------------------+
197 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
198 | STATE : code ROUTINE : qBAT_PercentCPBS |
199 +--------------------------------------------------------------------+
200
201 PURPOSE :
202 */
203 GLOBAL T_ACI_BAT_RSLT qBAT_PercentCPBS (T_ACI_DTI_PRC_PSI *src_infos_psi,
204 T_BAT_cmd_send *cmd)
205 {
206 T_ACI_BAT_RSLT ret;
207 T_ACI_PB_STOR stor;
208 SHORT used;
209 SHORT total;
210 SHORT first;
211 SHORT used_ext;
212 SHORT total_ext;
213
214 TRACE_FUNCTION ("qBAT_PercentCPBS()");
215
216 /*
217 * Call the corresponding qAT function. T_ACI_BAT_RSLT is
218 * assumed to be equivalent to T_ACI_RESULT.
219 */
220 ret=(T_ACI_BAT_RSLT)qAT_PercentCPBS((T_ACI_CMD_SRC)src_infos_psi->srcId,&stor,
221 &used,&total,
222 &first,
223 &used_ext, &total_ext);
224
225 /*
226 * If the query completes, send the response now.
227 */
228 if (ret EQ ACI_BAT_CMPL)
229 {
230 T_BAT_cmd_response resp;
231 T_BAT_res_que_percent_cpbs cpbs_data;
232
233 resp.ctrl_response=BAT_RES_QUE_PERCENT_CPBS;
234 resp.response.ptr_que_percent_cpbs=&cpbs_data;
235
236 /*
237 * This relies on T_BAT_storage being identical to
238 * T_ACI_PB_STOR.
239 */
240 cpbs_data.storage=(T_BAT_storage)stor;
241
242 cpbs_data.total=(S16)total;
243 cpbs_data.used=(S16)used;
244 cpbs_data.first=(S16)first;
245 cpbs_data.used_ext=(S16)used_ext;
246 cpbs_data.total_ext=(S16)total_ext;
247
248 aci_bat_send(src_infos_psi,&resp);
249 }
250
251 return(ret);
252 }
253
254 /*
255 +--------------------------------------------------------------------+
256 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
257 | STATE : code ROUTINE : sBAT_PlusCPBW |
258 +--------------------------------------------------------------------+
259
260 PURPOSE :
261 */
262 GLOBAL T_ACI_BAT_RSLT sBAT_PlusCPBW (T_ACI_DTI_PRC_PSI *src_infos_psi,
263 T_BAT_cmd_send *cmd)
264 {
265 T_ACI_BAT_RSLT ret;
266 SHORT index;
267 CHAR number[BAT_MAX_CPBW_NUMBER_LEN+1];
268 CHAR *p_number;
269 T_ACI_TOA toa;
270 T_ACI_TOA *p_toa;
271 T_ACI_PB_TEXT text;
272 T_ACI_PB_TEXT *p_text;
273 T_ACI_VP_ABS dmy_date_time;
274 T_BAT_cmd_set_plus_cpbw *cpbw;
275
276 TRACE_FUNCTION ("sBAT_PlusCPBW()");
277
278 /*
279 * Get a pointer to the CPBW structure for convenience.
280 */
281 cpbw=cmd->params.ptr_set_plus_cpbw;
282
283 index=(SHORT)cpbw->index;
284
285 if (cpbw->v_number EQ TRUE)
286 {
287 /*
288 * The idea here is to get the 'number' parameter into a
289 * null terminated string, which is what sAT_PlusCPBW() expects, but
290 * is not guaranteed by BAT.
291 */
292 memset(number,0,sizeof(number));
293 memcpy(number,cpbw->number,cpbw->c_number);
294 p_number=number;
295
296 /*
297 * BAT stores the type of address in a single value.
298 */
299 if (cpbw->type NEQ -1)
300 {
301 toa=toa_demerge(cpbw->type);
302 p_toa=&toa;
303 }
304 else
305 {
306 p_toa=NULL;
307 }
308 }
309 else
310 {
311 p_number=NULL;
312 p_toa=NULL;
313 }
314
315 /*
316 * Associated text
317 */
318 if (cpbw->v_text EQ TRUE)
319 {
320 USHORT len;
321
322 /*
323 * Convert from the currently selected character set into the
324 * SIM format.
325 */
326 utl_chsetToSim(
327 (UBYTE *)cpbw->text,
328 (USHORT)cpbw->c_text,
329 (UBYTE *)text.data,
330 &len,
331 GSM_ALPHA_Def);
332
333 /*
334 * Set the length. Note that we cannot do this by passing a
335 * reference to text.len into utl_chsetToSim() because it is
336 * the wrong type.
337 */
338 text.len=(UBYTE)len;
339
340 text.cs=CS_Sim;
341
342 p_text=&text;
343 }
344 else
345 {
346 p_text=NULL;
347 }
348
349 /*
350 * Call the corresponding sAT function. T_ACI_BAT_RSLT is
351 * assumed to be equivalent to T_ACI_RESULT.
352 */
353 ret=(T_ACI_BAT_RSLT)sAT_PlusCPBW(
354 (T_ACI_CMD_SRC)src_infos_psi->srcId,
355 index,
356 p_number,
357 p_toa,
358 p_text,
359 &dmy_date_time);
360
361 return(ret);
362 }
363
364 /*
365 +--------------------------------------------------------------------+
366 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
367 | STATE : code ROUTINE : tBAT_PlusCPBW |
368 +--------------------------------------------------------------------+
369
370 PURPOSE :
371 */
372 GLOBAL T_ACI_BAT_RSLT tBAT_PlusCPBW (T_ACI_DTI_PRC_PSI *src_infos_psi,
373 T_BAT_cmd_send *cmd)
374 {
375 T_ACI_BAT_RSLT ret;
376 SHORT first;
377 SHORT last;
378 UBYTE nlength;
379 UBYTE tlength;
380
381 TRACE_FUNCTION ("tBAT_PlusCPBW()");
382
383 /*
384 * Call the corresponding tAT function. T_ACI_BAT_RSLT is
385 * assumed to be equivalent to T_ACI_RESULT.
386 */
387 ret=(T_ACI_BAT_RSLT)tAT_PlusCPBW((T_ACI_CMD_SRC)src_infos_psi->srcId,&first,&last,&nlength,&tlength);
388
389 /*
390 * If the command completes, send the response now.
391 */
392 if (ret EQ ACI_BAT_CMPL)
393 {
394 T_BAT_cmd_response resp;
395 T_BAT_res_tst_plus_cpbw cpbw_data;
396
397 resp.ctrl_response=BAT_RES_TST_PLUS_CPBW;
398 resp.response.ptr_tst_plus_cpbw=&cpbw_data;
399
400 cpbw_data.index1=(U8)first;
401 cpbw_data.index2=(U8)last;
402 cpbw_data.nlength=(S16)nlength;
403 cpbw_data.tlength=(S16)tlength;
404 #ifdef _SIMULATION_
405 #pragma message(__TODO__"+CPBW types")
406 #endif
407 cpbw_data.c_types=0;
408 cpbw_data.types[0]=0;
409
410 aci_bat_send(src_infos_psi,&resp);
411 }
412
413 return(ret);
414 }
415
416 /*
417 +--------------------------------------------------------------------+
418 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
419 | STATE : code ROUTINE : sBAT_PlusCPBR |
420 +--------------------------------------------------------------------+
421
422 PURPOSE : Read phonebook entries. If the application wants to read
423 more than ACI_BAT_MAX_RESPONSES, then the responses are
424 sent block by block (one block = ACI_BAT_MAX_RESPONSES).
425 */
426 GLOBAL T_ACI_BAT_RSLT sBAT_PlusCPBR_CB (T_ACI_DTI_PRC_PSI *src_infos_psi)
427 {
428 T_BAT_cmd_send cmd;
429 T_BAT_cmd_set_plus_cpbr cpbr;
430
431 cmd.ctrl_params = BAT_CMD_SET_PLUS_CPBR;
432 cmd.params.ptr_set_plus_cpbr = &cpbr;
433
434 cpbr.index1 = (U8)src_infos_psi->index1;
435 cpbr.index2 = (S16)src_infos_psi->index2;
436
437 return (sBAT_PlusCPBR(src_infos_psi, &cmd));
438 }
439
440
441 GLOBAL T_ACI_BAT_RSLT sBAT_PlusCPBR (T_ACI_DTI_PRC_PSI *src_infos_psi,
442 T_BAT_cmd_send *cmd)
443 {
444 T_ACI_BAT_RSLT ret;
445 SHORT start_idx;
446 SHORT stop_idx;
447 SHORT last_idx = ACI_NumParmNotPresent;
448 T_ACI_PB_ENTR pb_lst[MAX_PB_ENTR];
449
450 TRACE_FUNCTION ("sBAT_PlusCPBR()");
451
452 /* define here the variables, which are passed as parameters to sAT_PlusCPBR */
453 start_idx = (SHORT)cmd->params.ptr_set_plus_cpbr->index1;
454 stop_idx = (SHORT)cmd->params.ptr_set_plus_cpbr->index2;
455
456 ret = (T_ACI_BAT_RSLT)sAT_PlusCPBR((T_ACI_CMD_SRC)src_infos_psi->srcId, start_idx, stop_idx, &last_idx, &pb_lst[0]);
457 if (ret EQ ACI_BAT_CMPL)
458 {
459 SHORT i;
460 T_BAT_cmd_response resp;
461 T_BAT_res_set_plus_cpbr cpbr_data;
462
463 resp.ctrl_response = BAT_RES_SET_PLUS_CPBR;
464 resp.response.ptr_set_plus_cpbr = &cpbr_data;
465
466 /*
467 * sAT_PlusCPBR() provides in pb_lst[] up to five entries (MAX_PB_ENTR)
468 */
469 for (i = 0; ((i < MAX_PB_ENTR) AND (pb_lst[i].index NEQ ACI_NumParmNotPresent)); i++)
470 {
471 USHORT len_cvtd_text=0;
472
473 cpbr_data.index = (U8)pb_lst[i].index;
474
475 cpbr_data.c_number = strlen((CHAR*)pb_lst[i].number);
476
477 cpbr_data.c_number = (cpbr_data.c_number > BAT_MAX_CPBR_NUMBER_LEN)
478 ? BAT_MAX_CPBR_NUMBER_LEN
479 : cpbr_data.c_number;
480
481 strncpy((CHAR*)cpbr_data.number, pb_lst[i].number, cpbr_data.c_number+1); /* Include null terminator for Resp_.. () */
482
483 /* BAT stores the type of address in a single 8-bit value. */
484 cpbr_data.type = toa_merge(pb_lst[i].type);
485
486 /*
487 * Convert the data read from the SIM into the currently
488 * selected character set.
489 */
490 utl_chsetFromSim(
491 (UBYTE *)pb_lst[i].text.data,
492 pb_lst[i].text.len,
493 (UBYTE *)cpbr_data.text,
494 BAT_MAX_CPBR_TEXT_LEN,
495 &len_cvtd_text,
496 GSM_ALPHA_Def);
497
498 cpbr_data.c_text=(U8)len_cvtd_text;
499
500 TRACE_EVENT_P2("sBAT_PlusCPBR(): index = %i c_text = %d", cpbr_data.index, cpbr_data.c_text);
501
502 /* vsi_t_sleep (aci_handle, 500); */
503 aci_bat_send(src_infos_psi,&resp);
504 }
505 /* remember updated start index and initial stop index for possible next block of entries to send to APP */
506 src_infos_psi->index1 = last_idx + 1;
507 src_infos_psi->index2 = stop_idx;
508 }
509 else
510 {
511 ACI_ERR_DESC(ACI_ERR_CLASS_Cme,CME_ERR_Unknown);
512 return(ACI_BAT_FAIL);
513 }
514
515 if (last_idx < stop_idx)
516 {
517 src_infos_psi->large_type = TRUE;
518 return (ACI_BAT_EXCT);
519 }
520
521 src_infos_psi->large_type = FALSE;
522 return (ACI_BAT_CMPL);
523 }
524
525 /*
526 +--------------------------------------------------------------------+
527 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
528 | STATE : code ROUTINE : tBAT_PlusCPBR |
529 +--------------------------------------------------------------------+
530
531 PURPOSE :
532 */
533
534 GLOBAL T_ACI_BAT_RSLT tBAT_PlusCPBR (T_ACI_DTI_PRC_PSI *src_infos_psi,
535 T_BAT_cmd_send *cmd)
536 {
537 T_ACI_BAT_RSLT ret=ACI_BAT_FAIL;
538 SHORT first;
539 SHORT last;
540 UBYTE nlength;
541 UBYTE tlength;
542
543 TRACE_FUNCTION ("tBAT_PlusCPBR()");
544
545 /*
546 * Call the corresponding tAT function. T_ACI_BAT_RSLT is
547 * assumed to be equivalent to T_ACI_RESULT.
548 */
549 ret=(T_ACI_BAT_RSLT)tAT_PlusCPBR((T_ACI_CMD_SRC)src_infos_psi->srcId,&first,&last,&nlength,&tlength);
550
551 /*
552 * If the command completes, send the response now.
553 */
554 if (ret EQ ACI_BAT_CMPL)
555 {
556 T_BAT_cmd_response resp;
557 T_BAT_res_tst_plus_cpbr cpbr_data;
558
559 resp.ctrl_response=BAT_RES_TST_PLUS_CPBR;
560 resp.response.ptr_tst_plus_cpbr=&cpbr_data;
561
562 cpbr_data.index_f=(U8)first;
563 cpbr_data.index_l=(U8)last;
564 cpbr_data.nlength=(S16)nlength;
565 cpbr_data.tlength=(S16)tlength;
566
567 aci_bat_send(src_infos_psi,&resp);
568 }
569
570 return(ret);
571 }
572
573 /*
574 +--------------------------------------------------------------------+
575 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
576 | STATE : code ROUTINE : sBAT_PlusCPBF |
577 +--------------------------------------------------------------------+
578
579 PURPOSE :
580 */
581 GLOBAL T_ACI_BAT_RSLT sBAT_PlusCPBF_CB (T_ACI_DTI_PRC_PSI *src_infos_psi)
582 {
583 T_BAT_cmd_send cmd;
584 T_BAT_cmd_set_plus_cpbf cpbf;
585
586 cmd.ctrl_params = BAT_CMD_SET_PLUS_CPBF;
587 cmd.params.ptr_set_plus_cpbf = &cpbf;
588
589 TRACE_FUNCTION ("sBAT_PlusCPBF_CB()");
590
591 /* restore search string if ongoing command */
592 if ( src_infos_psi->search_str_ptr NEQ NULL )
593 {
594 TRACE_EVENT("Restore search string");
595 /* index 1 stores the length of the string in the case of cpbf */
596 cpbf.c_findtext = (U8)src_infos_psi->index1;
597 memcpy(cpbf.findtext, src_infos_psi->search_str_ptr, BAT_MAX_CPBF_FIND_TEXT_LEN);
598 }
599 return (sBAT_PlusCPBF(src_infos_psi, &cmd));
600 }
601
602 GLOBAL T_ACI_BAT_RSLT sBAT_PlusCPBF (T_ACI_DTI_PRC_PSI *src_infos_psi,
603 T_BAT_cmd_send *cmd)
604 {
605 T_ACI_PB_TEXT pbtext;
606 USHORT len;
607 T_ACI_BAT_RSLT ret;
608 T_BAT_cmd_set_plus_cpbf *cpbf_cmd;
609 SHORT found = -1;
610 T_ACI_PB_ENTR pb[MAX_PB_ENTR];
611 SHORT i;
612 T_ACI_CPBF_MOD search_mode; // replaced by global var
613 T_BAT_cmd_response resp;
614 T_BAT_res_set_plus_cpbf cpbf_rsp;
615
616 TRACE_FUNCTION ("sBAT_PlusCPBF()");
617
618 resp.ctrl_response = BAT_RES_SET_PLUS_CPBF;
619 resp.response.ptr_set_plus_cpbf = &cpbf_rsp;
620
621 /*
622 * Get a pointer to the CPBF data for convenience.
623 */
624 cpbf_cmd = cmd->params.ptr_set_plus_cpbf;
625
626 /*
627 * We may have to call sAT_PlusCPBF() more than once, if there are
628 * more than MAX_PB_ENTR entries found. The search mode is used
629 * to tell the ACI whether this is a new search or a continuation of
630 * the old one.
631 * If there has been a valid string pointer saved to the search_str_ptr
632 * the seek has to be continued.
633 */
634
635 if ((src_infos_psi->search_str_ptr NEQ NULL)
636 AND (strncmp((char *)src_infos_psi->search_str_ptr, (char *)cpbf_cmd->findtext, cpbf_cmd->c_findtext) EQ 0))
637 {
638 found = src_infos_psi->index2; /* recover number found*/
639 search_mode = CPBF_MOD_NextSearch;
640 TRACE_EVENT_P1("Stored Search string: %s", src_infos_psi->search_str_ptr);
641 TRACE_EVENT_P1("Stored String length: %d", src_infos_psi->index1);
642 }
643 else
644 {
645 search_mode = CPBF_MOD_NewSearch;
646 }
647
648 /*
649 * If the search string has zero length or is larger than the ACI function
650 * can handle then there's no point continuing.
651 * In fact there should be a differentiation between UCS2 and 8bit based coding schemes.
652 * Additionally it has to be considered that the string given within the BAT command is ACSII encoded.
653 */
654 if (((ati_user_output_cfg[src_infos_psi->srcId].cscsChset EQ CSCS_CHSET_Ucs2)
655 AND ((cpbf_cmd->c_findtext>BAT_MAX_CPBF_FIND_TEXT_LEN) OR (cpbf_cmd->c_findtext<1)) )
656 OR
657 ((ati_user_output_cfg[src_infos_psi->srcId].cscsChset NEQ CSCS_CHSET_Ucs2)
658 AND ((cpbf_cmd->c_findtext>MAX_PHB_NUM_LEN) OR (cpbf_cmd->c_findtext<1)) ) )
659 {
660 ACI_ERR_DESC(ACI_ERR_CLASS_Cme,CME_ERR_Unknown);
661 return(ACI_BAT_FAIL);
662 }
663
664 TRACE_EVENT_P1("Search string: %s", cpbf_cmd->findtext);
665 TRACE_EVENT_P1("String length: %d", cpbf_cmd->c_findtext);
666
667 utl_chsetToSim(
668 (UBYTE *)cpbf_cmd->findtext,
669 (USHORT)cpbf_cmd->c_findtext,
670 (UBYTE *)pbtext.data,
671 &len,
672 GSM_ALPHA_Def);
673
674 if (len > MAX_PHB_NUM_LEN)
675 {
676 /*
677 * Shouldn't get here as that would mean that memory has been
678 * overwritten. Currently utl_chsetToSim() has no specific mechanism
679 * to prevent this.
680 */
681 ACI_ERR_DESC(ACI_ERR_CLASS_Cme,CME_ERR_TxtToLong);
682 return(ACI_BAT_FAIL);
683 }
684
685 pbtext.len = (UBYTE)len;
686 pbtext.cs = (T_ACI_CS)CS_Sim;
687
688
689 /*
690 * Call the corresponding sAT function. T_ACI_BAT_RSLT is
691 * assumed to be equivalent to T_ACI_RESULT.
692 */
693
694 TRACE_EVENT_P1("search_mode: %d", search_mode);
695 TRACE_EVENT_P1("pbtext.data: %s", pbtext.data);
696 TRACE_EVENT_P1("pbtext.len: %d", pbtext.len);
697
698
699 /* found is not overwritten in the case of NEXT_SEARCH */
700 ret=(T_ACI_BAT_RSLT)sAT_PlusCPBF(
701 (T_ACI_CMD_SRC)src_infos_psi->srcId,
702 &pbtext,
703 search_mode,
704 &found,
705 pb);
706
707 TRACE_EVENT_P1("sAT_PlusCPBF returns: %d", ret);
708 TRACE_EVENT_P1("-- found entries: %d", found);
709
710 /*
711 * If the command fails, get out now.
712 */
713 if (ret NEQ ACI_BAT_CMPL)
714 return(ret);
715
716 /*
717 * We have received a list, however the BAT response only
718 * allows for single items. So we must send each one
719 * individually.
720 */
721 for (i=0;((i<found) AND (i<MAX_PB_ENTR));i++)
722 {
723 USHORT len_cvtd_text=0;
724
725 cpbf_rsp.index=(U8)pb[i].index;
726
727 TRACE_EVENT("send the found entry");
728 strncpy((CHAR*)cpbf_rsp.number,pb[i].number,BAT_MAX_CPBF_NUMBER_LEN);
729 cpbf_rsp.c_number=strlen((CHAR*)cpbf_rsp.number);
730
731 /*
732 * BAT stores the type of address in a single 8-bit value.
733 */
734 cpbf_rsp.type=toa_merge(pb[i].type);
735
736 /*
737 * Convert the data read from the SIM into the currently
738 * selected character set.
739 */
740 utl_chsetFromSim(
741 (UBYTE *)pb[i].text.data,
742 pb[i].text.len,
743 (UBYTE *)cpbf_rsp.text,
744 BAT_MAX_CPBF_TEXT_LEN,
745 &len_cvtd_text,
746 GSM_ALPHA_Def);
747
748 cpbf_rsp.c_text=(U8)len_cvtd_text;
749
750 /* vsi_t_sleep (aci_handle, 500); */
751
752 aci_bat_send(src_infos_psi,&resp);
753 }
754
755 /*
756 * Set the search mode for the next iteration, should there be
757 * one.
758 */
759
760 if (found>MAX_PB_ENTR)
761 {
762 TRACE_EVENT("More entries found");
763 /* remember the string to search for (only necessary for first iteration)*/
764 if (search_mode EQ CPBF_MOD_NewSearch)
765 {
766 TRACE_EVENT("Store string");
767 src_infos_psi->index1 = (U16)cpbf_cmd->c_findtext; /* str length */
768 ACI_MALLOC(src_infos_psi->search_str_ptr, BAT_MAX_CPBF_FIND_TEXT_LEN);
769 memcpy(src_infos_psi->search_str_ptr, cpbf_cmd->findtext, BAT_MAX_CPBF_FIND_TEXT_LEN);
770 }
771 /* This is a multi-line response */
772 src_infos_psi->large_type = TRUE;
773 /* Save the number of found items - MAX_PB_ENTR send to user */
774 src_infos_psi->index2 = found - MAX_PB_ENTR;
775 /* Still executing */
776 ret = ACI_BAT_EXCT;
777 }
778 else /* no further entries to find */
779 {
780 TRACE_EVENT("reset search string");
781 /* reset search string info for iterations */
782 src_infos_psi->index1 = 0; /* str length reset */
783 src_infos_psi->index2 = 0; /* number found reset */
784 if (src_infos_psi->search_str_ptr NEQ NULL) /* str mem reset, if necessary */
785 {
786 ACI_MFREE(src_infos_psi->search_str_ptr);
787 src_infos_psi->search_str_ptr = NULL;
788 }
789 /* This is NO multiline response */
790 src_infos_psi->large_type = FALSE;
791 /* completed */
792 ret = ACI_BAT_CMPL;
793 }
794
795 return (ret);
796
797 }
798
799 /*
800 +--------------------------------------------------------------------+
801 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
802 | STATE : code ROUTINE : tBAT_PlusCPBF |
803 +--------------------------------------------------------------------+
804
805 PURPOSE :
806 */
807 GLOBAL T_ACI_BAT_RSLT tBAT_PlusCPBF (T_ACI_DTI_PRC_PSI *src_infos_psi,
808 T_BAT_cmd_send *cmd)
809 {
810 T_ACI_BAT_RSLT ret;
811 UBYTE nlength;
812 UBYTE tlength;
813
814 TRACE_FUNCTION ("tBAT_PlusCPBF()");
815
816 /*
817 * Call the corresponding ACI function. T_ACI_BAT_RSLT is
818 * assumed to be equivalent to T_ACI_RESULT.
819 */
820 ret=(T_ACI_BAT_RSLT)tAT_PlusCPBF((T_ACI_CMD_SRC)src_infos_psi->srcId,&nlength,&tlength);
821
822 /*
823 * If the command completes, send the response now.
824 */
825 if (ret EQ ACI_BAT_CMPL)
826 {
827 T_BAT_cmd_response resp;
828 T_BAT_res_tst_plus_cpbf cpbf_data;
829
830 resp.ctrl_response=BAT_RES_TST_PLUS_CPBF;
831 resp.response.ptr_tst_plus_cpbf=&cpbf_data;
832
833 cpbf_data.nlength=(S16)nlength;
834 cpbf_data.tlength=(S16)tlength;
835
836 aci_bat_send(src_infos_psi,&resp);
837 }
838
839 return(ret);
840 }
841
842 /*
843 +--------------------------------------------------------------------+
844 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
845 | STATE : code ROUTINE : sBAT_PlusCSVM |
846 +--------------------------------------------------------------------+
847
848 PURPOSE :
849 */
850 GLOBAL T_ACI_BAT_RSLT sBAT_PlusCSVM (T_ACI_DTI_PRC_PSI *src_infos_psi,
851 T_BAT_cmd_send *cmd)
852 {
853 T_ACI_BAT_RSLT ret;
854 T_ACI_TOA toa;
855 CHAR number[BAT_MAX_CSVM_NUMBER_LEN+1];
856 CHAR *pnumber;
857 T_ACI_CSVM_MOD mode;
858 T_BAT_cmd_set_plus_csvm *csvm;
859 UBYTE num_len;
860
861 TRACE_FUNCTION ("sBAT_PlusCSVM()");
862
863 /*
864 * Get a pointer to the BAT structure for convenience.
865 */
866 csvm=cmd->params.ptr_set_plus_csvm;
867
868 /*
869 * This assumes that T_ACI_CSVM_MOD and T_BAT_plus_csvm_mode are
870 * equivalent. They are, except that the ACI version has a
871 * NotPresent value - this is not a problem here as we are converting
872 * from BAT format to ACI format.
873 */
874 mode=(T_ACI_CSVM_MOD)csvm->mode;
875
876 if (csvm->v_number EQ TRUE)
877 {
878 /*
879 * I don't think that CSVM requires a null-terminated string, but
880 * it's best to err on the side of caution.
881 */
882 pnumber=number;
883 memset(number,0,sizeof(number));
884 memcpy(number,csvm->number,BAT_MAX_CSVM_NUMBER_LEN);
885
886 if (csvm->c_number>BAT_MAX_CSVM_NUMBER_LEN)
887 num_len=(UBYTE)BAT_MAX_CSVM_NUMBER_LEN;
888 else
889 num_len=(UBYTE)csvm->c_number;
890 }
891 else
892 {
893 pnumber=NULL;
894 num_len=0;
895 }
896
897 /*
898 * BAT stores the type of address in a single 8-bit value. We need to
899 * convert this to the ACI format.
900 */
901 toa=toa_demerge(csvm->type);
902
903 /*
904 * Call the corresponding ACI function. T_ACI_BAT_RSLT is
905 * assumed to be equivalent to T_ACI_RESULT.
906 */
907 ret=(T_ACI_BAT_RSLT)sAT_PlusCSVM((T_ACI_CMD_SRC)src_infos_psi->srcId,mode,pnumber,num_len,&toa);
908
909 return(ret);
910 }
911
912 /*
913 +--------------------------------------------------------------------+
914 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
915 | STATE : code ROUTINE : qBAT_PlusCSVM |
916 +--------------------------------------------------------------------+
917
918 PURPOSE :
919 */
920 GLOBAL T_ACI_BAT_RSLT qBAT_PlusCSVM (T_ACI_DTI_PRC_PSI *src_infos_psi,
921 T_BAT_cmd_send *cmd)
922 {
923 T_ACI_BAT_RSLT ret = ACI_BAT_FAIL;
924 T_ACI_CSVM_MOD mode;
925 CHAR number[BAT_MAX_CSVM_NUMBER_LEN+1];
926 SHORT toa_val;
927
928 TRACE_FUNCTION ("qBAT_PlusCSVM()");
929
930 /*
931 * Call the corresponding qAT function. T_ACI_BAT_RSLT is
932 * assumed to be equivalent to T_ACI_RESULT.
933 */
934 ret=(T_ACI_BAT_RSLT)qAT_PlusCSVM(
935 (T_ACI_CMD_SRC)src_infos_psi->srcId,
936 &mode,
937 number,
938 BAT_MAX_CSVM_NUMBER_LEN,
939 &toa_val);
940
941 /*
942 * If the query completes, send the response now.
943 */
944 if (ret EQ ACI_BAT_CMPL)
945 {
946 T_BAT_cmd_response resp;
947 T_BAT_res_que_plus_csvm csvm_data;
948
949 resp.ctrl_response=BAT_RES_QUE_PLUS_CSVM;
950 resp.response.ptr_que_plus_csvm=&csvm_data;
951
952 /*
953 * We can't just cast the ACI value to the BAT value as it
954 * might be CSVM_MOD_NotPresent, for which the BAT has no
955 * equivalent.
956 */
957 csvm_data.mode=(mode EQ CSVM_MOD_Enable) ? BAT_CSVM_MODE_ENABLE:BAT_CSVM_MODE_DISABLE;
958
959 /*
960 * We trust the ACI to give us a null-terminated string.
961 */
962 strcpy((CHAR*)csvm_data.number,number);
963 csvm_data.c_number=strlen((CHAR*)csvm_data.number);
964
965 /*
966 * Note that in this instance the ACI is giving us the TOA as
967 * a single number, rather than in its usual T_ACI_TOA format.
968 */
969 csvm_data.type=(U8)toa_val;
970
971 aci_bat_send(src_infos_psi,&resp);
972 }
973
974 return(ret);
975 }
976
977 /*
978 +--------------------------------------------------------------------+
979 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
980 | STATE : code ROUTINE : sBAT_PlusCLAN |
981 +--------------------------------------------------------------------+
982
983 PURPOSE :
984 */
985 GLOBAL T_ACI_BAT_RSLT sBAT_PlusCLAN (T_ACI_DTI_PRC_PSI *src_infos_psi,
986 T_BAT_cmd_send *cmd)
987 {
988 T_ACI_BAT_RSLT ret;
989 T_ACI_LAN_SUP lng;
990 CHAR str[BAT_MAX_CLAN_CODE_LEN+1];
991 USHORT i;
992
993 TRACE_FUNCTION ("sBAT_PlusCLAN()");
994
995 /*
996 * Ensure that we have a null-terminated string.
997 */
998 memset(str,0,sizeof(str));
999 memcpy(str,cmd->params.ptr_set_plus_clan->code,BAT_MAX_CLAN_CODE_LEN);
1000
1001 lng.str=NULL;
1002
1003 /*
1004 * The BAT provides the language in string form only, we must also
1005 * calculate the corresponding value. To do this we use the lookup
1006 * table "lngs".
1007 *
1008 * GSM 07.07 says that "AUTO" should be used for automatic mode, but
1009 * the (ATI) code uses "au". Here we want to accept both.
1010 */
1011 if (!strcmp(str,"AUTO"))
1012 {
1013 lng.lng=CLAN_LNG_AUT;
1014 lng.str="AUTO";
1015 }
1016 else
1017 {
1018 for (i=0;lngs[i].str;i++)
1019 {
1020 if (!strcmp(lngs[i].str,str))
1021 {
1022 lng.str=lngs[i].str;
1023 lng.lng=lngs[i].lng;
1024 break;
1025 }
1026 }
1027 }
1028
1029 if (lng.str==NULL)
1030 {
1031 /*
1032 * Can't work out the language so give up.
1033 */
1034 ACI_ERR_DESC(ACI_ERR_CLASS_Cme,CME_ERR_OpNotSupp);
1035 return(ACI_BAT_FAIL);
1036 }
1037
1038 /*
1039 * Call the corresponding ACI function. T_ACI_BAT_RSLT is
1040 * assumed to be equivalent to T_ACI_RESULT.
1041 */
1042 ret=(T_ACI_BAT_RSLT)sAT_PlusCLAN((T_ACI_CMD_SRC)src_infos_psi->srcId,&lng);
1043
1044 return(ret);
1045 }
1046
1047 /*
1048 +--------------------------------------------------------------------+
1049 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
1050 | STATE : code ROUTINE : qBAT_PlusCLAN |
1051 +--------------------------------------------------------------------+
1052
1053 PURPOSE :
1054 */
1055 GLOBAL T_ACI_BAT_RSLT qBAT_PlusCLAN (T_ACI_DTI_PRC_PSI *src_infos_psi,
1056 T_BAT_cmd_send *cmd)
1057 {
1058 T_ACI_BAT_RSLT ret;
1059 T_ACI_LAN_SUP lng;
1060 T_BAT_cmd_response resp;
1061 T_BAT_res_que_plus_clan clan_data;
1062
1063 TRACE_FUNCTION ("qBAT_PlusCLAN()");
1064
1065 resp.ctrl_response=BAT_RES_QUE_PLUS_CLAN;
1066 resp.response.ptr_que_plus_clan=&clan_data;
1067
1068 memset(&clan_data,0,sizeof(clan_data));
1069 lng.str=(CHAR *)clan_data.code;
1070
1071 /*
1072 * Call the corresponding ACI function. T_ACI_BAT_RSLT is
1073 * assumed to be equivalent to T_ACI_RESULT.
1074 * We are trusting this function not to deliver too long
1075 * a string. At the time of writing, it can only give us two
1076 * characters, which we easily have room for in the BAT
1077 * message.
1078 */
1079 ret=(T_ACI_BAT_RSLT)qAT_PlusCLAN((T_ACI_CMD_SRC)src_infos_psi->srcId,&lng);
1080
1081 /*
1082 * If the query completes, send the response now.
1083 */
1084 if (ret EQ ACI_BAT_CMPL)
1085 {
1086 clan_data.c_code=strlen(lng.str);
1087 aci_bat_send(src_infos_psi,&resp);
1088 }
1089
1090 return(ret);
1091 }
1092
1093 /*
1094 +--------------------------------------------------------------------+
1095 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
1096 | STATE : code ROUTINE : tBAT_PlusCLAN |
1097 +--------------------------------------------------------------------+
1098
1099 PURPOSE :
1100 */
1101 GLOBAL T_ACI_BAT_RSLT tBAT_PlusCLAN (T_ACI_DTI_PRC_PSI *src_infos_psi,
1102 T_BAT_cmd_send *cmd)
1103 {
1104 T_ACI_BAT_RSLT ret;
1105 T_ACI_LAN_SUP lng[MAX_LAN];
1106 SHORT last_idx;
1107
1108 TRACE_FUNCTION ("tBAT_PlusCLAN()");
1109
1110 /*
1111 * Call the corresponding ACI function. T_ACI_BAT_RSLT is
1112 * assumed to be equivalent to T_ACI_RESULT.
1113 */
1114 ret=(T_ACI_BAT_RSLT)tAT_PlusCLAN((T_ACI_CMD_SRC)src_infos_psi->srcId,&last_idx,lng);
1115
1116 /*
1117 * If the command completes, send the response now.
1118 */
1119 if (ret EQ ACI_BAT_CMPL)
1120 {
1121 USHORT i;
1122 T_BAT_cmd_response resp;
1123 T_BAT_res_tst_plus_clan clan_data;
1124
1125 resp.ctrl_response=BAT_RES_TST_PLUS_CLAN;
1126 resp.response.ptr_tst_plus_clan=&clan_data;
1127
1128 /*
1129 * We have received a list, however the BAT response only
1130 * allows for single items. So we must send each one
1131 * individually.
1132 */
1133 for (i=0;i<last_idx;i++)
1134 {
1135 clan_data.c_code=strlen(lng[i].str);
1136
1137 /*
1138 * Discard any languages for which the string is too long for
1139 * BAT (this should never happen).
1140 */
1141 if (clan_data.c_code<=BAT_MAX_CLAN_CODE_LEN)
1142 {
1143 memcpy(clan_data.code,lng[i].str,BAT_MAX_CLAN_CODE_LEN);
1144 aci_bat_send(src_infos_psi,&resp);
1145 }
1146 }
1147 }
1148
1149 return(ret);
1150 }
1151