comparison src/g23m-aci/aci/aci_bat_cphs.c @ 162:53929b40109c

src/g23m-aci: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 11 Oct 2016 02:02:43 +0000
parents
children
comparison
equal deleted inserted replaced
161:4557e2a9c18e 162:53929b40109c
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 "cphs.h"
27 #include "aci_cphs.h"
28 #include "aci_cmd.h"
29
30 /*
31 * commonly used query for %CPCFU and %CPVWI
32 * %CPCFU: <status>[,<line>]
33 * %CPVWI: <status>[,<line>]
34 *
35 * status acts as a global status information for all lines.
36 * if any line is set then status is set/activated
37 * and in the line bit field you can check which one.
38 * the strange thing is that the numerical value for status
39 * is exactly complementary between %CPCFU and %CPVWI
40 * see also 8415_052.doc
41 */
42 LOCAL T_ACI_BAT_RSLT query_cphs_lines (T_ACI_DTI_PRC_PSI *src_infos_psi,
43 T_BAT_cmd_send *cmd,
44 T_CPHS_LINES lines)
45 {
46 T_ACI_BAT_RSLT ret;
47 T_ACI_RETURN (*fptr)(T_ACI_CMD_SRC srcId, U8 *cfu_set, T_CPHS_LINES line);
48 T_CPHS_LINES line = CPHS_LINE_NULL;
49 T_CPHS_LINES line_bitmask = CPHS_LINE_NULL;
50 U16 i, end;
51 U8 flag_set;
52
53 T_BAT_res_set_percent_cpvwi cpvwi;
54 T_BAT_res_set_percent_cpcfu cpcfu;
55 T_BAT_cmd_response resp;
56
57 switch (cmd->ctrl_params)
58 {
59 case (BAT_CMD_SET_PERCENT_CPCFU):
60 {
61 fptr = qAT_PercentCPCFU;
62 break;
63 }
64 case (BAT_CMD_SET_PERCENT_CPVWI):
65 {
66 fptr = qAT_PercentCPVWI;
67 break;
68 }
69 default:
70 {
71 return (ACI_BAT_FAIL);
72 }
73 }
74
75 end = 8 * sizeof(T_CPHS_LINES);
76 /* rotate over all bits */
77 for (i=0; i<end; i++)
78 {
79 line = 1 << i;
80 if (lines & line)
81 {
82 ret = (T_ACI_BAT_RSLT)fptr((T_ACI_CMD_SRC)src_infos_psi->srcId, &flag_set, line);
83
84 if(ret NEQ (T_ACI_BAT_RSLT)AT_CMPL)
85 {
86 return(ACI_BAT_FAIL);
87 }
88
89 if(flag_set EQ CPHS_FLAG_ACTIVATED)
90 {
91 line_bitmask |= line;
92 }
93 }
94 else
95 {
96 continue; /* bit not set --> do not check this line */
97 }
98 }
99
100 switch (cmd->ctrl_params)
101 {
102 case (BAT_CMD_SET_PERCENT_CPCFU):
103 {
104 cpcfu.line = (T_BAT_percent_cpcfu_line)line_bitmask;
105 cpcfu.status = (line_bitmask EQ CPHS_LINE_NULL)
106 ? BAT_P_CPCFU_STATUS_DEACTIVATE
107 : BAT_P_CPCFU_STATUS_ACTIVATED;
108 resp.ctrl_response = BAT_RES_SET_PERCENT_CPCFU;
109 resp.response.ptr_set_percent_cpcfu = &cpcfu;
110 /*
111 * according to 8415_052.doc CPCFU status: 0 Activated, 1 Deactivated,
112 * which must be an error, because on ATI the status is given as 1, when any line has been set.
113 * But the nice thing with BAT is the using of symbolic constants, where the actual numeric
114 * value for BAT_P_CPCFU_STATUS_ACTIVATED is unimportant as long as the client code uses it.
115 * If they use numerical value instead of symbolic constant, then ... we cannot help ...
116 */
117 TRACE_EVENT_P2("query_cphs_lines(): status = %i, line = 0x%02X",cpcfu.status, cpcfu.line);
118 break;
119 }
120 case (BAT_CMD_SET_PERCENT_CPVWI):
121 {
122 cpvwi.line = (T_BAT_percent_cpvwi_lines)line_bitmask;
123 cpvwi.status = (line_bitmask EQ CPHS_LINE_NULL)
124 ? BAT_P_CPVWI_FLAG_DEACTIVATED
125 : BAT_P_CPVWI_FLAG_ACTIVATED;
126 resp.ctrl_response = BAT_RES_SET_PERCENT_CPVWI;
127 resp.response.ptr_set_percent_cpvwi = &cpvwi;
128 TRACE_EVENT_P2("query_cphs_lines(): status = %i, line = 0x%02X",cpvwi.status, cpvwi.line);
129 break;
130 }
131 default:
132 {
133 return (ACI_BAT_FAIL);
134 }
135 }
136
137 aci_bat_send(src_infos_psi, &resp);
138 return (ACI_BAT_CMPL);
139 }
140
141 /*
142 +--------------------------------------------------------------------+
143 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
144 | STATE : code ROUTINE : sBAT_PercentCPHS |
145 +--------------------------------------------------------------------+
146
147 PURPOSE :
148 */
149 GLOBAL T_ACI_BAT_RSLT sBAT_PercentCPHS(T_ACI_DTI_PRC_PSI *src_infos_psi,
150 T_BAT_cmd_send *cmd)
151 {
152 T_ACI_BAT_RSLT ret;
153
154 TRACE_FUNCTION ("sBAT_PercentCPHS()");
155 ret = (T_ACI_BAT_RSLT)sAT_PercentCPHS((T_ACI_CMD_SRC)src_infos_psi->srcId,
156 (T_ACI_CPHS_INIT)cmd->params.ptr_set_percent_cphs->init_mode);
157 return(ret);
158 }
159
160 /*
161 +--------------------------------------------------------------------+
162 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
163 | STATE : code ROUTINE : qBAT_PercentCPHS |
164 +--------------------------------------------------------------------+
165
166 PURPOSE :
167 */
168 GLOBAL T_ACI_BAT_RSLT qBAT_PercentCPHS(T_ACI_DTI_PRC_PSI *src_infos_psi,
169 T_BAT_cmd_send *cmd)
170 {
171 T_ACI_BAT_RSLT ret;
172 T_BAT_cmd_response resp;
173 T_BAT_res_que_percent_cphs cphs;
174
175 TRACE_FUNCTION ("qBAT_PercentCPHS()");
176
177 resp.ctrl_response = BAT_RES_QUE_PERCENT_CPHS;
178 resp.response.ptr_que_percent_cphs = &cphs;
179
180 ret = (T_ACI_BAT_RSLT)qAT_PercentCPHS((T_ACI_CMD_SRC)src_infos_psi->srcId,(T_ACI_CPHS_INIT*)&cphs.init_mode);
181
182 aci_bat_send(src_infos_psi, &resp);
183 return(ret);
184 }
185
186 /*
187 +--------------------------------------------------------------------+
188 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
189 | STATE : code ROUTINE : sBAT_PercentCPNUMS |
190 +--------------------------------------------------------------------+
191
192 PURPOSE :
193 */
194 GLOBAL T_ACI_BAT_RSLT sBAT_PercentCPNUMS(T_ACI_DTI_PRC_PSI *src_infos_psi,
195 T_BAT_cmd_send *cmd)
196 {
197 T_ACI_BAT_RSLT ret;
198
199 TRACE_FUNCTION ("sBAT_PercentCPNUMS()");
200
201 ret = (T_ACI_BAT_RSLT)sAT_PercentCPNUMS((T_ACI_CMD_SRC)src_infos_psi->srcId,
202 cmd->params.ptr_set_percent_cpnums->element_id,
203 (U8)cmd->params.ptr_set_percent_cpnums->mode);
204 return(ret);
205 }
206
207 /*
208 +--------------------------------------------------------------------+
209 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
210 | STATE : code ROUTINE : tBAT_PercentCPNUMS |
211 +--------------------------------------------------------------------+
212
213 PURPOSE :
214 */
215 GLOBAL T_ACI_BAT_RSLT tBAT_PercentCPNUMS(T_ACI_DTI_PRC_PSI *src_infos_psi,
216 T_BAT_cmd_send *cmd)
217 {
218 return(ACI_BAT_FAIL);
219 }
220
221 /*
222 +--------------------------------------------------------------------+
223 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
224 | STATE : code ROUTINE : sBAT_PercentCPALS |
225 +--------------------------------------------------------------------+
226
227 PURPOSE :
228 */
229 GLOBAL T_ACI_BAT_RSLT sBAT_PercentCPALS(T_ACI_DTI_PRC_PSI *src_infos_psi,
230 T_BAT_cmd_send *cmd)
231 {
232 T_ACI_BAT_RSLT ret = ACI_BAT_FAIL;
233
234 TRACE_FUNCTION ("sBAT_PercentCPALS()");
235 /* adjust the left hand side
236 xxx = cmd->params.ptr_set_percent_cpals->call_id;
237 */
238 /* hmm, do not know which ACI function to call ! */
239 return(ret);
240 }
241
242 /*
243 +--------------------------------------------------------------------+
244 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
245 | STATE : code ROUTINE : qBAT_PercentCPALS |
246 +--------------------------------------------------------------------+
247
248 PURPOSE :
249 */
250 GLOBAL T_ACI_BAT_RSLT qBAT_PercentCPALS(T_ACI_DTI_PRC_PSI *src_infos_psi,
251 T_BAT_cmd_send *cmd)
252 {
253 T_ACI_BAT_RSLT ret;
254 T_BAT_cmd_response resp;
255 T_BAT_res_que_percent_cpals cpals;
256
257 T_CPHS_LINES active_line;
258 CHAR *line_desc;
259 U8 max_line_desc = 30; /* should be enough ! */
260
261 TRACE_FUNCTION ("qBAT_PercentCPALS()");
262
263 MALLOC(line_desc, max_line_desc);
264
265 resp.ctrl_response = BAT_RES_QUE_PERCENT_CPALS;
266 resp.response.ptr_que_percent_cpals = &cpals;
267
268 ret = (T_ACI_BAT_RSLT)qAT_PercentCPALS((T_ACI_CMD_SRC)src_infos_psi->srcId,
269 (U8)cpals.lines,
270 &active_line,
271 line_desc,
272 &max_line_desc);
273 MFREE(line_desc);
274
275 aci_bat_send(src_infos_psi, &resp);
276 return(ret);
277 }
278
279 /*
280 +--------------------------------------------------------------------+
281 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
282 | STATE : code ROUTINE : sBAT_PercentCPVWI |
283 +--------------------------------------------------------------------+
284
285 PURPOSE :
286 */
287 GLOBAL T_ACI_BAT_RSLT sBAT_PercentCPVWI(T_ACI_DTI_PRC_PSI *src_infos_psi,
288 T_BAT_cmd_send *cmd)
289 {
290 T_ACI_BAT_RSLT ret = ACI_BAT_FAIL;
291 T_CPHS_LINES lines = CPHS_LINE_NULL;
292
293 TRACE_FUNCTION ("sBAT_PercentCPVWI()");
294
295 /* According to 8415_52.doc the parameter line is mandatory,
296 * but implementation in ATI/ACI allows this one to be omittable.
297 * So, BAT goes with them. In case of line is omitted,
298 * set it to all possible. Else leave the bitfield as is (BAT == ACI).
299 */
300 if (cmd->params.ptr_set_percent_cpvwi->lines EQ BAT_P_CPVWI_LINES_NOT_PRESENT)
301 {
302 lines = CPHS_LINE1 + CPHS_LINE_DATA + CPHS_LINE_FAX + CPHS_LINE2;
303 }
304 else
305 {
306 lines = cmd->params.ptr_set_percent_cpvwi->lines;
307 }
308
309 if (cmd->params.ptr_set_percent_cpvwi->mode EQ BAT_P_CPVWI_MODE_QUERY)
310 {
311 ret = query_cphs_lines(src_infos_psi, cmd, lines);
312 }
313 else
314 {
315 ret = (T_ACI_BAT_RSLT)sAT_PercentCPVWI((T_ACI_CMD_SRC)src_infos_psi->srcId,
316 (U8)cmd->params.ptr_set_percent_cpvwi->mode,
317 lines);
318 }
319
320 return(ret);
321
322 }
323
324 /*
325 +--------------------------------------------------------------------+
326 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
327 | STATE : code ROUTINE : qBAT_PercentCPOPN |
328 +--------------------------------------------------------------------+
329
330 PURPOSE :
331 */
332 GLOBAL T_ACI_BAT_RSLT qBAT_PercentCPOPN(T_ACI_DTI_PRC_PSI *src_infos_psi,
333 T_BAT_cmd_send *cmd)
334 {
335 T_ACI_BAT_RSLT ret = ACI_BAT_FAIL;
336 T_BAT_cmd_response resp;
337 T_BAT_res_que_percent_cpopn cpopn;
338
339 TRACE_FUNCTION ("qBAT_PercentCPOPN()");
340
341 resp.ctrl_response = BAT_RES_QUE_PERCENT_CPOPN;
342 resp.response.ptr_que_percent_cpopn = &cpopn;
343
344 ret = (T_ACI_BAT_RSLT)qAT_PercentCPOPN((T_ACI_CMD_SRC)src_infos_psi->srcId,
345 (CHAR*)cpopn.long_name,
346 &cpopn.c_long_name,
347 (CHAR*)cpopn.short_name,
348 &cpopn.c_short_name);
349
350 aci_bat_send(src_infos_psi, &resp);
351 return(ret);
352 }
353
354 /*
355 +--------------------------------------------------------------------+
356 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
357 | STATE : code ROUTINE : sBAT_PercentCPINF |
358 +--------------------------------------------------------------------+
359
360 PURPOSE :
361 */
362 GLOBAL T_ACI_BAT_RSLT sBAT_PercentCPINF(T_ACI_DTI_PRC_PSI *src_infos_psi,
363 T_BAT_cmd_send *cmd)
364 {
365 T_ACI_BAT_RSLT ret;
366 T_BAT_cmd_set_percent_cpinf *cpinf = cmd->params.ptr_set_percent_cpinf;
367 UBYTE serv_group[CPHS_MAX_CSP];
368 UBYTE serv_len = 0;
369
370 TRACE_FUNCTION ("sBAT_PercentCPINF()");
371
372 memset(serv_group,0,sizeof(serv_group));
373
374 /* CSP exceeding maximum value display text too long */
375 if ( cpinf->c_csp > BAT_MAX_CPINF_CSP_LEN )
376 {
377 ACI_ERR_DESC(ACI_ERR_CLASS_Cme,CME_ERR_TxtToLong);
378 return(ACI_BAT_FAIL);
379 }
380
381 serv_len = utl_HexStrToBin((UBYTE*)cpinf->csp, cpinf->c_csp, serv_group, CPHS_MAX_CSP);
382
383 /* Odd length CSP or empty CSP display operation not allowed */
384 if(((serv_len % 2) NEQ 0) OR (serv_len EQ 0))
385 {
386 ACI_ERR_DESC(ACI_ERR_CLASS_Cme,CME_ERR_OpNotAllow);
387 return(ACI_BAT_FAIL);
388 }
389
390 ret = (T_ACI_BAT_RSLT)sAT_PercentCPINF( (T_ACI_CMD_SRC)src_infos_psi->srcId,
391 serv_group,
392 serv_len);
393
394 return(ret);
395 }
396 /*
397 +--------------------------------------------------------------------+
398 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
399 | STATE : code ROUTINE : qBAT_PercentCPINF |
400 +--------------------------------------------------------------------+
401
402 PURPOSE :
403 */
404 GLOBAL T_ACI_BAT_RSLT qBAT_PercentCPINF(T_ACI_DTI_PRC_PSI *src_infos_psi,
405 T_BAT_cmd_send *cmd)
406 {
407 T_ACI_RETURN ret = AT_FAIL;
408 T_BAT_cmd_response resp;
409 T_BAT_res_que_percent_cpinf cpinf;
410
411 TRACE_FUNCTION ("qBAT_PercentCPINF()");
412
413 resp.ctrl_response = BAT_RES_QUE_PERCENT_CPINF;
414 resp.response.ptr_que_percent_cpinf = &cpinf;
415
416 cpinf.phase = BAT_P_CPINF_PHASE_1;
417 cpinf.sst = 0;
418 cpinf.c_csp = BAT_MAX_CPINF_CSP_LEN;/* Since the BAT_MAX_CPINF_CSP_LEN length has been updated to 22,then there is no need of BAT_MAX_CPINF_CSP2_LEN */
419 cpinf.c_csp2 = BAT_MAX_CPINF_CSP_LEN;
420 memset(cpinf.csp, 0x00, BAT_MAX_CPINF_CSP_LEN);
421 memset(cpinf.csp2, 0x00, BAT_MAX_CPINF_CSP_LEN);
422
423 ret = (T_ACI_RETURN)qAT_PercentCPINF((T_ACI_CMD_SRC)src_infos_psi->srcId,
424 (U8*)&cpinf.phase,
425 &cpinf.sst,
426 (CHAR*)cpinf.csp,
427 (CHAR*)cpinf.csp2,
428 &cpinf.c_csp,
429 &cpinf.c_csp2);
430
431 if (ret EQ AT_CMPL)
432 {
433 aci_bat_send(src_infos_psi, &resp);
434 return (ACI_BAT_CMPL);
435 }
436
437 return (ACI_BAT_FAIL);
438 }
439
440 /*
441 +--------------------------------------------------------------------+
442 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
443 | STATE : code ROUTINE : sBAT_PercentCPMB |
444 +--------------------------------------------------------------------+
445
446 PURPOSE :
447 */
448 GLOBAL T_ACI_BAT_RSLT sBAT_PercentCPMB(T_ACI_DTI_PRC_PSI *src_infos_psi,
449 T_BAT_cmd_send *cmd)
450 {
451 T_ACI_BAT_RSLT ret;
452 T_CPHS_LINES line;
453 CHAR number[CPHS_MAX_MB_NUMBER_LEN];
454 CHAR alpha_id[CPHS_MAX_MB_ALPHA_LEN];
455 T_ACI_TOA_TON ton;
456 T_ACI_TOA_NPI npi;
457
458 TRACE_FUNCTION ("sBAT_PercentCPMB()");
459
460 /*
461 * Call the corresponding ACI function. T_ACI_BAT_RSLT is
462 * assumed to be equivalent to T_ACI_RESULT.
463 */
464 ret=(T_ACI_BAT_RSLT)qAT_PercentCPMB(
465 (T_ACI_CMD_SRC)src_infos_psi->srcId,
466 (UBYTE)cmd->params.ptr_set_percent_cpmb->record_id,
467 &line,number,&ton,&npi,alpha_id,NULL);
468
469 /*
470 * If the query completes, send the response now.
471 */
472 if (ret EQ ACI_BAT_CMPL)
473 {
474 T_BAT_cmd_response resp;
475 T_BAT_res_set_percent_cpmb cpmb_data;
476 UBYTE len;
477 T_ACI_TOA toa;
478
479 resp.ctrl_response=BAT_RES_SET_PERCENT_CPMB;
480 resp.response.ptr_set_percent_cpmb=&cpmb_data;
481
482 cpmb_data.record_id=(T_BAT_record_id)cmd->params.ptr_set_percent_cpmb->record_id;
483 cpmb_data.line=(T_BAT_percent_cpmb_line)line;
484
485 len=strlen(number);
486
487 /*
488 * This is in line with the existing ATI implementation (see
489 * setatPercentCPMB()) and is necessary to pass tests such as
490 * ACI583.
491 */
492 if (len EQ 0)
493 {
494 ACI_ERR_DESC(ACI_ERR_CLASS_Cme,CME_ERR_NotFound);
495 return(ACI_BAT_FAIL);
496 }
497
498 /*
499 * Check that the number isn't too long for the BAT message,
500 * if it is it will effectively be truncated.
501 */
502 if (len>BAT_MAX_CPMB_NUMBER_LEN)
503 len=BAT_MAX_CPMB_NUMBER_LEN;
504
505 if (len)
506 {
507 memcpy(cpmb_data.number,number,len);
508 cpmb_data.v_number=TRUE;
509 cpmb_data.c_number=(U8)len;
510 }
511 else
512 {
513 cpmb_data.v_number=FALSE;
514 }
515
516 len=strlen(alpha_id);
517
518 if (len)
519 {
520 USHORT len_cvtd_text=0;
521
522 /*
523 * Convert the data read from the SIM into the currently
524 * selected character set.
525 */
526 utl_chsetFromSim(
527 (UBYTE *)alpha_id,
528 (USHORT)len,
529 (UBYTE *)cpmb_data.alpha_id,
530 BAT_MAX_CPMB_ALPHA_ID_LEN,
531 &len_cvtd_text,
532 GSM_ALPHA_Def);
533
534 cpmb_data.v_alpha_id=TRUE;
535 cpmb_data.c_alpha_id=(U8)len_cvtd_text;
536 }
537 else
538 {
539 cpmb_data.v_alpha_id=FALSE;
540 }
541
542 /*
543 * Get the type of number and numbering plan into a T_ACI_TOA structure
544 * so that we can use toa_merge().
545 */
546 toa.ton=ton;
547 toa.npi=npi;
548
549 /*
550 * BAT stores the type of address in a single 8-bit value (it is S16 in
551 * the message only to allow for a 'not present' value of -1).
552 */
553 cpmb_data.type=(S16)toa_merge(toa);
554
555 aci_bat_send(src_infos_psi,&resp);
556 }
557
558 return(ret);
559 }
560
561
562 /*
563 +--------------------------------------------------------------------+
564 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
565 | STATE : code ROUTINE : qBAT_PercentCPMB |
566 +--------------------------------------------------------------------+
567
568 PURPOSE :
569 */
570 GLOBAL T_ACI_BAT_RSLT qBAT_PercentCPMB(T_ACI_DTI_PRC_PSI *src_infos_psi,
571 T_BAT_cmd_send *cmd)
572 {
573 T_ACI_BAT_RSLT ret;
574 UBYTE first;
575
576 TRACE_FUNCTION ("qBAT_PercentCPMB()");
577
578 /*
579 * Call the corresponding qAT function. T_ACI_BAT_RSLT is
580 * assumed to be equivalent to T_ACI_RESULT.
581 */
582 ret=(T_ACI_BAT_RSLT)qAT_PercentCPMB(
583 (T_ACI_CMD_SRC)src_infos_psi->srcId,
584 (UBYTE)ACI_NumParmNotPresent,NULL,NULL,NULL,NULL,NULL,&first);
585
586 /*
587 * If the query completes, send the response now.
588 */
589 if (ret EQ ACI_BAT_CMPL)
590 {
591 T_BAT_cmd_response resp;
592 T_BAT_res_que_percent_cpmb cpmb_data;
593
594 resp.ctrl_response=BAT_RES_QUE_PERCENT_CPMB;
595 resp.response.ptr_que_percent_cpmb=&cpmb_data;
596
597 cpmb_data.first=(U8)first;
598
599 aci_bat_send(src_infos_psi,&resp);
600 }
601
602 return(ret);
603 }
604
605
606 /*
607 +--------------------------------------------------------------------+
608 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
609 | STATE : code ROUTINE : sBAT_PercentCPMBW |
610 +--------------------------------------------------------------------+
611
612 PURPOSE :
613 */
614 GLOBAL T_ACI_BAT_RSLT sBAT_PercentCPMBW(T_ACI_DTI_PRC_PSI *src_infos_psi,
615 T_BAT_cmd_send *cmd)
616 {
617 T_ACI_BAT_RSLT ret;
618 T_BAT_cmd_set_percent_cpmbw *cpmbw = cmd->params.ptr_set_percent_cpmbw;
619 T_ACI_TOA type;
620 T_ACI_TOA *p_type;
621 CHAR number[BAT_MAX_CPMBW_NUMBER_LEN+1];
622 CHAR *p_number;
623 T_CPHS_PB_TEXT text;
624 T_CPHS_PB_TEXT *p_text;
625
626 TRACE_FUNCTION ("sBAT_PercentCPMBW()");
627
628 if (cpmbw->type EQ -1)
629 {
630 p_type=NULL;
631 }
632 else
633 {
634 p_type=&type;
635 type=toa_demerge(cpmbw->type);
636 }
637
638 if (cpmbw->v_number EQ FALSE)
639 {
640 p_number=NULL;
641 }
642 else
643 {
644 /*
645 * Mailbox number is present, so make a zero-terminated version
646 * and set a pointer to it.
647 */
648 p_number=number;
649 memset(number,0,sizeof(number));
650 memcpy(number,cpmbw->number,cpmbw->c_number);
651 }
652
653 if (cpmbw->v_text EQ FALSE)
654 {
655 p_text=NULL;
656 }
657 else
658 {
659 USHORT len;
660
661 p_text=&text;
662
663 /*
664 * Convert from the currently selected character set into the
665 * SIM format.
666 */
667 utl_chsetToSim(
668 (UBYTE *)cpmbw->text,
669 (USHORT)cpmbw->c_text,
670 (UBYTE *)text.data,
671 &len,
672 GSM_ALPHA_Def);
673
674 if (len>CPHS_MAX_MB_ALPHA_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 /*
686 * Set the length. Note that we cannot do this by passing a
687 * reference to text.len into utl_chsetToSim() because it is
688 * the wrong type.
689 */
690 text.len=(UBYTE)len;
691
692 p_text=&text;
693 }
694
695 /*
696 * Call the corresponding sAT function. T_ACI_BAT_RSLT is
697 * assumed to be equivalent to T_ACI_RESULT.
698 */
699 ret=(T_ACI_BAT_RSLT)sAT_PercentCPMBW(
700 (T_ACI_CMD_SRC)src_infos_psi->srcId,
701 (SHORT)cpmbw->record_id,
702 p_number,
703 p_type,
704 p_text);
705
706 return(ret);
707 }
708
709 /*
710 +--------------------------------------------------------------------+
711 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
712 | STATE : code ROUTINE : tBAT_PercentCPMBW |
713 +--------------------------------------------------------------------+
714
715 PURPOSE :
716 */
717 GLOBAL T_ACI_BAT_RSLT tBAT_PercentCPMBW(T_ACI_DTI_PRC_PSI *src_infos_psi,
718 T_BAT_cmd_send *cmd)
719 {
720 T_ACI_BAT_RSLT ret = ACI_BAT_FAIL;
721 SHORT first_idx = 0;
722 SHORT last_idx = 0;
723 UBYTE tlength = 0;
724 UBYTE nlength = 0;
725
726 TRACE_FUNCTION ("tBAT_PercentCPMBW()");
727
728 ret=(T_ACI_BAT_RSLT)tAT_PercentCPMBW((T_ACI_CMD_SRC)src_infos_psi->srcId,
729 &first_idx,
730 &last_idx,
731 &nlength,
732 &tlength);
733
734 if (ret EQ ACI_BAT_CMPL)
735 {
736 T_BAT_cmd_response resp;
737 T_BAT_res_tst_percent_cpmbw cpmbw_data;
738
739 resp.ctrl_response = BAT_RES_TST_PERCENT_CPMBW;
740 resp.response.ptr_tst_percent_cpmbw = &cpmbw_data;
741
742 cpmbw_data.min_rec_id = (U8)first_idx;
743 cpmbw_data.max_rec_id = (U8)last_idx;
744 cpmbw_data.nlength = nlength;
745 cpmbw_data.tlength = tlength;
746
747 /*
748 * currently c_type_range and type_range are initialized to zero
749 * TODO : %CPMBW types
750 */
751 cpmbw_data.c_type_range = 0;
752 cpmbw_data.type_range[0] = 0;
753
754 aci_bat_send(src_infos_psi,&resp);
755 }
756
757 return(ret);
758 }
759
760 /*
761 +--------------------------------------------------------------------+
762 | PROJECT : GSM-F&D (8411) MODULE : ACI_BAT |
763 | STATE : code ROUTINE : sBAT_PercentCPCFU |
764 +--------------------------------------------------------------------+
765
766 PURPOSE :
767 */
768 GLOBAL T_ACI_BAT_RSLT sBAT_PercentCPCFU(T_ACI_DTI_PRC_PSI *src_infos_psi,
769 T_BAT_cmd_send *cmd)
770 {
771 T_ACI_BAT_RSLT ret = ACI_BAT_FAIL;
772 T_CPHS_LINES lines = CPHS_LINE_NULL;
773
774 TRACE_FUNCTION ("sBAT_PercentCPCFU()");
775
776 /* According to 8415_52.doc the parameter line is mandatory,
777 * but implementation in ATI/ACI allows this one to be omittable.
778 * So, BAT goes with them. In case of line is omitted,
779 * set it to all possible. Else leave the bitfield as is (BAT == ACI).
780 */
781 if (cmd->params.ptr_set_percent_cpcfu->line EQ BAT_P_CPCFU_LINE_NOT_PRESENT)
782 {
783 lines = CPHS_LINE1 + CPHS_LINE_DATA + CPHS_LINE_FAX + CPHS_LINE2;
784 }
785 else
786 {
787 lines = cmd->params.ptr_set_percent_cpcfu->line;
788 }
789
790 if (cmd->params.ptr_set_percent_cpcfu->mode EQ BAT_P_CPCFU_MODE_QUERY)
791 {
792 ret = query_cphs_lines(src_infos_psi, cmd, lines);
793 }
794 else
795 {
796 ret = (T_ACI_BAT_RSLT)sAT_PercentCPCFU((T_ACI_CMD_SRC)src_infos_psi->srcId,
797 (U8)cmd->params.ptr_set_percent_cpcfu->mode,
798 lines);
799 }
800 return(ret);
801 }
802
803