comparison src/g23m-aci/aci/ati_gprs.c @ 1:fa8dc04885d8

src/g23m-*: import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:25:50 +0000
parents
children
comparison
equal deleted inserted replaced
0:4e78acac3d88 1:fa8dc04885d8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
4 | Modul :
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 : GPRS AT Command Handler.
18 +-----------------------------------------------------------------------------
19 */
20
21 #if defined (GPRS) && defined (DTI)
22
23 #ifndef GACI_CMD_C
24 #define GACI_CMD_C
25 #endif
26
27 #undef DUMMY_ATI_STRINGS
28
29 #include "aci_all.h"
30
31 /*includes*/
32 #include "dti.h" /* functionality of the dti library */
33 #include "aci_cmh.h"
34 #include "ati_cmd.h"
35 #include "aci_io.h"
36 #include "aci_cmd.h"
37 #include "aci_lst.h"
38 #include "l4_tim.h"
39
40 #include "gdi.h"
41 #include "audio.h"
42 #include "p_sim.h"
43 #include "p_aci.h"
44 #include "aoc.h"
45 #include "aci.h"
46 #include "pcm.h"
47 #include "rx.h"
48 #include "pwr.h"
49
50 #include "dti_conn_mng.h"
51 #include "dti_cntrl_mng.h"
52
53 #include "gaci.h"
54 #include "gaci_cmh.h"
55 #include "psa.h"
56 #include "psa_sm.h"
57
58 #include "cmh.h"
59 #include "cmh_sm.h"
60
61 #include "aci_io.h"
62 #include "aci_mem.h"
63
64 #if defined(FF_WAP) OR defined (FF_GPF_TCPIP) OR defined (FF_SAT_E)
65 #include "gaci_srcc.h"
66 #include "psa_tcpip.h"
67 #include "wap_aci.h"
68 #endif /* defined(FF_WAP) OR defined (FF_GPF_TCPIP) OR defined (FF_SAT_E)*/
69
70 #include "gaci_cmd.h"
71 #include "cmh_gppp.h"
72 #include "psa_gppp.h"
73 #include "aci_prs.h"
74
75 #include "ati_int.h"
76
77 #include "dcm_f.h"
78
79 #ifdef FF_ATI_BAT
80
81 #include "typedefs.h"
82 #include "gdd.h"
83 #include "bat.h"
84
85 #include "ati_bat.h"
86
87 #endif /*FF_ATI_BAT*/
88
89 EXTERN char *cmdErrStr;
90 EXTERN T_ACI_LIST *ati_src_list;
91
92 GLOBAL T_ATI_RSLT setatPlusCGDCONT (char *cl, UBYTE srcId);
93 GLOBAL T_ATI_RSLT setatPlusCGQREQ (char *cl, UBYTE srcId);
94 GLOBAL T_ATI_RSLT setatPlusCGQMIN (char *cl, UBYTE srcId);
95 GLOBAL T_ATI_RSLT setatPlusCGATT (char *cl, UBYTE srcId);
96 GLOBAL T_ATI_RSLT setatPlusCGACT (char *cl, UBYTE srcId);
97 GLOBAL T_ATI_RSLT setatPlusCGDATA (char *cl, UBYTE srcId);
98 GLOBAL T_ATI_RSLT setatPlusCGPADDR (char *cl, UBYTE srcId);
99 GLOBAL T_ATI_RSLT setatPlusCGAUTO (char *cl, UBYTE srcId);
100 GLOBAL T_ATI_RSLT setatPlusCGANS (char *cl, UBYTE srcId);
101 GLOBAL T_ATI_RSLT setatPlusCGCLASS (char *cl, UBYTE srcId);
102 GLOBAL T_ATI_RSLT setatPlusCGEREP (char *cl, UBYTE srcId);
103 GLOBAL T_ATI_RSLT setatPlusCGREG (char *cl, UBYTE srcId);
104 GLOBAL T_ATI_RSLT setatPlusCGSMS (char *cl, UBYTE srcId);
105 GLOBAL T_ATI_RSLT setatPercentCGEREP (char *cl, UBYTE srcId);
106
107
108 GLOBAL T_ATI_RSLT queatPlusCGDCONT (char *cl, UBYTE srcId);
109 GLOBAL T_ATI_RSLT queatPlusCGQREQ (char *cl, UBYTE srcId);
110 GLOBAL T_ATI_RSLT queatPlusCGQMIN (char *cl, UBYTE srcId);
111 GLOBAL T_ATI_RSLT queatPlusCGATT (char *cl, UBYTE srcId);
112 GLOBAL T_ATI_RSLT queatPlusCGACT (char *cl, UBYTE srcId);
113 GLOBAL T_ATI_RSLT queatPlusCGAUTO (char *cl, UBYTE srcId);
114 GLOBAL T_ATI_RSLT queatPlusCGCLASS (char *cl, UBYTE srcId);
115 GLOBAL T_ATI_RSLT queatPlusCGEREP (char *cl, UBYTE srcId);
116 GLOBAL T_ATI_RSLT queatPlusCGREG (char *cl, UBYTE srcId);
117 GLOBAL T_ATI_RSLT queatPlusCGSMS (char *cl, UBYTE srcId);
118 GLOBAL T_ATI_RSLT queatPercentCGEREP (char *cl, UBYTE srcId);
119
120
121 GLOBAL T_ATI_RSLT tesatPlusCGDCONT (char *cl, UBYTE srcId);
122 GLOBAL T_ATI_RSLT tesatPlusCGPADDR (char *cl, UBYTE srcId);
123 GLOBAL T_ATI_RSLT tesatPlusCGSMS (char *cl, UBYTE srcId);
124
125 GLOBAL T_ATI_RSLT atGD (char *cl, UBYTE srcId, BOOL *gprs_command);
126
127 GLOBAL T_ATI_RSLT setatPercentCGAATT (char *cl, UBYTE srcId);
128 GLOBAL T_ATI_RSLT queatPercentCGAATT (char *cl, UBYTE srcId);
129
130 GLOBAL T_ATI_RSLT setatPercentCGREG (char *cl, UBYTE srcId);
131 GLOBAL T_ATI_RSLT queatPercentCGREG (char *cl, UBYTE srcId);
132 LOCAL T_ATI_RSLT queatPercentCGPCO (UBYTE srcId,USHORT cid);
133 GLOBAL T_ATI_RSLT setatPercentCGCLASS (CHAR *cl, UBYTE srcId);
134 GLOBAL T_ATI_RSLT queatPercentCGCLASS (CHAR *cl, UBYTE srcId);
135 #ifdef REL99
136 GLOBAL T_ATI_RSLT queatPlusCGEQREQ (char *cl, UBYTE srcId);
137 GLOBAL T_ATI_RSLT queatPlusCGEQMIN (char *cl, UBYTE srcId);
138 GLOBAL T_ATI_RSLT queatPlusCGTFT (char *cl, UBYTE srcId);
139 GLOBAL T_ATI_RSLT queatPlusCGDSCONT(char *cl, UBYTE srcId);
140 GLOBAL T_ATI_RSLT tesatPlusCGEQNEG (char *cl, UBYTE srcId);
141 GLOBAL T_ATI_RSLT tesatPlusCGCMOD (char *cl, UBYTE srcId);
142 GLOBAL T_ATI_RSLT tesatPlusCGTFT (char *cl, UBYTE srcId);
143 GLOBAL T_ATI_RSLT tesatPlusCGDSCONT(char *cl, UBYTE srcId);
144 GLOBAL T_ATI_RSLT setatPlusCGEQMIN (char *cl, UBYTE srcId);
145 GLOBAL T_ATI_RSLT setatPlusCGEQREQ (char *cl, UBYTE srcId);
146 GLOBAL T_ATI_RSLT setatPlusCGEQNEG (char *cl, UBYTE srcId);
147 GLOBAL T_ATI_RSLT setatPlusCGCMOD (char *cl, UBYTE srcId);
148 GLOBAL T_ATI_RSLT setatPlusCGTFT (char *cl, UBYTE srcId);
149 GLOBAL T_ATI_RSLT setatPlusCGDSCONT(char *cl, UBYTE srcId);
150 #endif
151
152 EXTERN char *parseDSNP_U16 (char blocks, char *p_in, U16 *p_out);
153 EXTERN char *parseIPv4Address(char *p_in, U8 * p_ip_addr, U8 * is_ip_valid);
154 EXTERN char *parseIPv6Address(char *p_in, U8 * p_ip_addr, U8 * is_ip_valid);
155
156 EXTERN T_PDP_CONTEXT_INTERNAL *p_pdp_context_list;
157
158
159 /*
160 +------------------------------------------------------------------------------------+
161 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
162 | STATE : finnished ROUTINE : gaci_ati_cmd_init_each_source |
163 +------------------------------------------------------------------------------------+
164
165 PURPOSE : initialize GACI relevant ATI parameters.
166 */
167
168 GLOBAL void gaci_ati_cmd_init_each_source( UBYTE srcId )
169 {
170 /* init +CGREG param */
171 ati_creg_init(srcId, PlusCGREG_CMD);
172
173 /* init %CGREG param */
174 ati_creg_init(srcId, PercentCGREG_CMD);
175
176 /* init %CGEREP param */
177 ati_user_output_cfg[srcId].Percent_CGEREP_stat = 0;
178 ati_user_output_cfg[srcId].CGEREP_mode = 0;
179 ati_user_output_cfg[srcId].CGEREP_bfr = 0;
180 }
181
182 /*
183 +--------------------------------------------------------------------+
184 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
185 | STATE : finnished ROUTINE : atPlusCGDCONT |
186 +--------------------------------------------------------------------+
187
188 PURPOSE : +CGDCONT command ( PDP context definition )
189 */
190
191 #define MAGIC_EMPTY_APN "\x0ff"
192
193 GLOBAL T_ATI_RSLT setatPlusCGDCONT (char *cl, UBYTE srcId)
194 {
195 T_ACI_RETURN ret = AT_FAIL;
196 U8 valid_ip;
197 U8 cid = PDP_CONTEXT_CID_OMITTED;
198 char *p_pdp_addr = NULL;
199 USHORT pdp_addr_len = 0;
200
201 T_PDP_CONTEXT pdp_context_input = { "",
202 MAGIC_EMPTY_APN,
203 NAS_is_ip_not_present, 0,
204 PDP_CONTEXT_D_COMP_OMITTED,
205 PDP_CONTEXT_H_COMP_OMITTED,
206 PDP_CONTEXT_CID_OMITTED };
207
208
209 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
210 TRACE_FUNCTION("setatPlusCGDCONT ()");
211
212 cl = parse( cl, "csslcc", &cid,
213 (LONG)MAX_PDP_CONTEXT_TYPE_LEN, &pdp_context_input.pdp_type,
214 (LONG)MAX_PDP_CONTEXT_APN_LEN, &pdp_context_input.pdp_apn,
215 &pdp_addr_len, &p_pdp_addr,
216 &pdp_context_input.d_comp,
217 &pdp_context_input.h_comp);
218
219 if (!strcmp(pdp_context_input.pdp_apn, MAGIC_EMPTY_APN))
220 {
221 /* if APN was ommitted then parse leaves the string untouched */
222 pdp_context_input.pdp_apn[0]='\0'; /* so clear the apn */
223 }
224 else if (pdp_context_input.pdp_apn[0] EQ '\0')
225 {
226 /* if entered APN was "", parse clears the buffer */
227 strcpy(pdp_context_input.pdp_apn, MAGIC_EMPTY_APN); /* fill magic empty apn */
228 }
229
230 if ( !cl )
231 {
232 cmdCmeError(CME_ERR_OpNotAllow);
233 return (ATI_FAIL);
234 }
235
236 strupper( (char*) &pdp_context_input.pdp_type);
237
238 /* Issue 27081 - GPRS context is transformed from lower cases into upper cases */
239 /* strupper( (char*) &pdp_context_input.pdp_apn ); */
240
241 if( p_pdp_addr )
242 {
243 if( pdp_addr_len >= 7 AND pdp_addr_len <= 15 )
244 {
245 p_pdp_addr = parseIPv4Address( p_pdp_addr, (U8*) &(pdp_context_input.pdp_addr.ip_address.ipv4_addr.a4), &valid_ip);
246 if (valid_ip NEQ 0)
247 {
248 pdp_context_input.pdp_addr.ctrl_ip_address = NAS_is_ipv4;
249 }
250 else
251 {
252 /* If the IP address is not valid then we should send ERROR message. */
253 cmdCmeError(CME_ERR_OpNotAllow);
254 return (ATI_FAIL);
255 }
256 }
257 else
258 {
259 if( pdp_addr_len >= 31 AND pdp_addr_len <= 63 )
260 {
261 p_pdp_addr = parseIPv6Address( p_pdp_addr, (U8*) &(pdp_context_input.pdp_addr.ip_address.ipv6_addr.a6), &valid_ip);
262 if (valid_ip NEQ 0)
263 {
264 pdp_context_input.pdp_addr.ctrl_ip_address = NAS_is_ipv6;
265 }
266 else
267 {
268 /* If the IP address is not valid then we should send ERROR message. */
269 cmdCmeError(CME_ERR_OpNotAllow);
270 return (ATI_FAIL);
271 }
272 }
273 else
274 {
275 cmdCmeError(CME_ERR_OpNotAllow);
276 return (ATI_FAIL);
277 }
278 }
279 }
280 else
281 {
282 if( pdp_addr_len NEQ 0 )
283 {
284 cmdCmeError(CME_ERR_OpNotAllow);
285 return (ATI_FAIL);
286 }
287 else
288 {
289 //if pdp_addr is omitted, ctrl must be set to not present...
290 pdp_context_input.pdp_addr.ctrl_ip_address = NAS_is_ip_not_present;
291 }
292 }
293
294 #ifdef FF_ATI_BAT
295 {
296 T_BAT_cmd_send cmd;
297 T_BAT_cmd_set_plus_cgdcont cgdcont;
298
299 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGDCONT;
300 cmd.params.ptr_set_plus_cgdcont = &cgdcont;
301
302 cgdcont.cid=(T_BAT_pdp_cid)cid;
303
304 /* currently both IPv4,IPV6 supported */
305 if (!utl_strcasecmp((const char *)pdp_context_input.pdp_type,
306 (const char *)"ip"))
307 cgdcont.pdp_type = BAT_PDP_TYPE_IPV4;
308 else if (!utl_strcasecmp((const char *)pdp_context_input.pdp_type,
309 (const char *)"ipv6"))
310 cgdcont.pdp_type = BAT_PDP_TYPE_IPV6;
311 else
312 cgdcont.pdp_type = BAT_PDP_TYPE_NOT_PRESENT;
313
314 /* apn value = "" */
315 if (!strcmp(pdp_context_input.pdp_apn, MAGIC_EMPTY_APN))
316 {
317 cgdcont.v_apn = TRUE;
318 cgdcont.c_apn = 0;
319 }
320 /* apn value omitted */
321 else if (pdp_context_input.pdp_apn[0] EQ '\0')
322 {
323 cgdcont.v_apn = FALSE;
324 }
325 /* apn with valid value (longer than 0) */
326 else
327 {
328 cgdcont.v_apn = TRUE;
329 cgdcont.c_apn = (U8)strlen(pdp_context_input.pdp_apn);
330 memcpy(cgdcont.apn,pdp_context_input.pdp_apn, cgdcont.c_apn);
331 }
332
333
334 if (pdp_addr_len)
335 {
336 cgdcont.v_pdp_addr = TRUE;
337 cgdcont.c_pdp_addr = (U8)pdp_addr_len;
338 memcpy(cgdcont.pdp_addr,p_pdp_addr,pdp_addr_len);
339 }
340 else
341 {
342 cgdcont.v_pdp_addr = FALSE;
343 cgdcont.c_pdp_addr = 0;
344 }
345
346 cgdcont.d_comp = (T_BAT_plus_cgdcont_d_comp)pdp_context_input.d_comp;
347 cgdcont.h_comp = (T_BAT_plus_cgdcont_h_comp)pdp_context_input.h_comp;
348
349 bat_send(ati_bat_get_client(srcId), &cmd);
350 src_params->curAtCmd=AT_CMD_CGDCONT;
351 return(ATI_EXCT);
352 }
353 #else
354 ret = sAT_PlusCGDCONT((T_ACI_CMD_SRC)srcId, cid, &pdp_context_input );
355 switch (ret)
356 {
357 case (AT_CMPL): /*operation completed*/
358 return (ATI_CMPL);
359 case (AT_EXCT):
360 src_params->curAtCmd = AT_CMD_CGDCONT;
361 return (ATI_EXCT);
362 default:
363 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
364 return (ATI_FAIL);
365 }
366 #endif
367 }
368
369 GLOBAL T_ATI_RSLT queatPlusCGDCONT (char *cl, UBYTE srcId)
370 {
371 #ifndef FF_ATI_BAT
372 T_ACI_RETURN ret = AT_FAIL;
373 T_PDP_CONTEXT pdp_context_array[PDP_CONTEXT_CID_MAX];
374 SHORT pdp_context_cid_array[PDP_CONTEXT_CID_MAX];
375 char pdp_addr[64];
376 char message[255];
377 int i=0;
378 #endif
379
380 TRACE_FUNCTION("queatPlusCGDCONT ()");
381
382 #ifdef FF_ATI_BAT
383 {
384 T_BAT_cmd_send cmd;
385 T_BAT_no_parameter dummy;
386
387 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CGDCONT;
388 dummy.bat_dummy = 0xFF;
389 cmd.params.ptr_que_plus_cgdcont = &dummy;
390 bat_send(ati_bat_get_client(srcId), &cmd);
391 return(ATI_EXCT);
392 }
393 #else
394
395 memset( &pdp_context_array, 0, sizeof(pdp_context_array) );
396 memset( &pdp_context_cid_array, PDP_CONTEXT_CID_OMITTED, sizeof(pdp_context_cid_array) );
397
398 ret = qAT_PlusCGDCONT((T_ACI_CMD_SRC)srcId, pdp_context_array, pdp_context_cid_array);
399
400 if (ret EQ AT_CMPL)
401 {
402 for ( i = 0; i < PDP_CONTEXT_CID_MAX AND pdp_context_cid_array[i] NEQ PDP_CONTEXT_CID_OMITTED; i++ )
403 {
404 if( pdp_context_addr_omitted(&(pdp_context_array[i].pdp_addr) ) )
405 {
406 sprintf( pdp_addr,"\"\"");
407 }
408 else
409 {
410 if( pdp_context_array[i].pdp_addr.ctrl_ip_address EQ NAS_is_ipv4 )
411 {
412 /* IP v4 address */
413 sprintf( pdp_addr, "\"%d.%d.%d.%d\"",
414 pdp_context_array[i].pdp_addr.ip_address.ipv4_addr.a4[0],
415 pdp_context_array[i].pdp_addr.ip_address.ipv4_addr.a4[1],
416 pdp_context_array[i].pdp_addr.ip_address.ipv4_addr.a4[2],
417 pdp_context_array[i].pdp_addr.ip_address.ipv4_addr.a4[3] );
418 }
419 else
420 {
421 /* IP v6 address */
422 sprintf( pdp_addr, "\"%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d\"",
423 pdp_context_array[i].pdp_addr.ip_address.ipv6_addr.a6[0],
424 pdp_context_array[i].pdp_addr.ip_address.ipv6_addr.a6[1],
425 pdp_context_array[i].pdp_addr.ip_address.ipv6_addr.a6[2],
426 pdp_context_array[i].pdp_addr.ip_address.ipv6_addr.a6[3],
427 pdp_context_array[i].pdp_addr.ip_address.ipv6_addr.a6[4],
428 pdp_context_array[i].pdp_addr.ip_address.ipv6_addr.a6[5],
429 pdp_context_array[i].pdp_addr.ip_address.ipv6_addr.a6[6],
430 pdp_context_array[i].pdp_addr.ip_address.ipv6_addr.a6[7],
431 pdp_context_array[i].pdp_addr.ip_address.ipv6_addr.a6[8],
432 pdp_context_array[i].pdp_addr.ip_address.ipv6_addr.a6[9],
433 pdp_context_array[i].pdp_addr.ip_address.ipv6_addr.a6[10],
434 pdp_context_array[i].pdp_addr.ip_address.ipv6_addr.a6[11],
435 pdp_context_array[i].pdp_addr.ip_address.ipv6_addr.a6[12],
436 pdp_context_array[i].pdp_addr.ip_address.ipv6_addr.a6[13],
437 pdp_context_array[i].pdp_addr.ip_address.ipv6_addr.a6[14],
438 pdp_context_array[i].pdp_addr.ip_address.ipv6_addr.a6[15] );
439 }
440
441 }
442
443 if( pdp_context_apn_omitted( pdp_context_array[i].pdp_apn ) )
444 {
445 sprintf( message, "+CGDCONT: %d,\"%s\",,%s,%d,%d",
446 pdp_context_cid_array[i],
447 pdp_context_array[i].pdp_type,
448 pdp_addr,
449 pdp_context_array[i].d_comp,
450 pdp_context_array[i].h_comp );
451 }
452 else if (!strcmp(pdp_context_array[i].pdp_apn, MAGIC_EMPTY_APN))
453 { /* special empty APN detected, printout "" */
454 sprintf( message, "+CGDCONT: %d,\"%s\",\"\",%s,%d,%d",
455 pdp_context_cid_array[i],
456 pdp_context_array[i].pdp_type,
457 pdp_addr,
458 pdp_context_array[i].d_comp,
459 pdp_context_array[i].h_comp );
460 }
461 else
462 {
463 sprintf( message, "+CGDCONT: %d,\"%s\",\"%s\",%s,%d,%d",
464 pdp_context_cid_array[i],
465 pdp_context_array[i].pdp_type,
466 pdp_context_array[i].pdp_apn,
467 pdp_addr,
468 pdp_context_array[i].d_comp,
469 pdp_context_array[i].h_comp );
470 }
471
472 io_sendMessage(srcId, message, ATI_NORMAL_OUTPUT);
473
474 }
475 }
476 else
477 {
478 cmdCmeError(CME_ERR_Unknown);
479 return (ATI_FAIL);
480 }
481
482 return (ATI_CMPL);
483 #endif /*FF_ATI_BAT*/
484 }
485
486
487 /*
488 +--------------------------------------------------------------------+
489 | PROJECT : MODULE : GACI_CMD |
490 | STATE : finnished ROUTINE : testatPlusCGDCONT |
491 +--------------------------------------------------------------------+
492
493 PURPOSE : +CGQREQ command (context QOS request)
494 */
495
496 GLOBAL T_ATI_RSLT tesatPlusCGDCONT (char *cl, UBYTE srcId)
497 {
498 char *me = "+CGDCONT: ";
499
500 sprintf( g_sa, "%s(1-%d),\"IP\",,,(0),(0-3)", me, PDP_CONTEXT_CID_MAX );
501 io_sendMessage( srcId, g_sa, ATI_NORMAL_OUTPUT );
502
503 sprintf( g_sa, "%s(1-%d),\"IPV6\",,,(0),(0-3)", me, PDP_CONTEXT_CID_MAX );
504 io_sendMessage( srcId, g_sa, ATI_NORMAL_OUTPUT );
505
506 /* As for EDGE we are not supporting PDP_Type as "PPP" */
507 /* sprintf( g_sa, "%s(1-%d),\"PPP\",,,(0-2),(0-3)", me, PDP_CONTEXT_CID_MAX );
508 io_sendMessage( srcId, g_sa, ATI_NORMAL_OUTPUT );*/
509
510 return (ATI_CMPL);
511 }
512
513 #ifdef REL99
514 /*
515 +--------------------------------------------------------------------+
516 | PROJECT : UMTS MODULE : ATI_GPRS |
517 | STATE : ROUTINE : atPlusCGDSCONT |
518 +--------------------------------------------------------------------+
519
520 PURPOSE : +CGDSCONT command ( secondary PDP context definition )
521 */
522
523 GLOBAL T_ATI_RSLT setatPlusCGDSCONT( char *cl, UBYTE srcId )
524 {
525
526 U8 cid = PDP_CONTEXT_CID_OMITTED;
527
528
529 T_PDP_CONTEXT pdp_context_input = { "",
530 "",
531 NAS_is_ip_not_present,0,
532 PDP_CONTEXT_D_COMP_OMITTED,
533 PDP_CONTEXT_H_COMP_OMITTED,
534 PDP_CONTEXT_CID_OMITTED };
535 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
536 TRACE_FUNCTION("setatPlusCGDSCONT ()");
537
538 cl = parse( cl, "cccc",
539 &cid,
540 &(pdp_context_input.p_cid),
541 &pdp_context_input.d_comp,
542 &pdp_context_input.h_comp);
543
544 if( !cl )
545 {
546 cmdCmeError(CME_ERR_OpNotAllow);
547 return (ATI_FAIL);
548 }
549
550 #ifdef FF_ATI_BAT
551 {
552 T_BAT_cmd_send cmd;
553 T_BAT_cmd_set_plus_cgdscont cgdscont;
554
555 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGDSCONT;
556 cmd.params.ptr_set_plus_cgdscont = &cgdscont;
557
558 cgdscont.cid=(T_BAT_pdp_cid)cid;
559 cgdscont.p_cid = (U8)pdp_context_input.p_cid;
560
561 cgdscont.d_comp = (T_BAT_plus_cgdcont_d_comp)pdp_context_input.d_comp;
562 cgdscont.h_comp = (T_BAT_plus_cgdcont_d_comp)pdp_context_input.h_comp;
563
564 bat_send(ati_bat_get_client(srcId), &cmd);
565 src_params->curAtCmd=AT_CMD_CGDSCONT;
566 return(ATI_EXCT);
567 }
568 #else
569 switch( sAT_PlusCGDSCONT(( T_ACI_CMD_SRC)srcId, cid , &pdp_context_input) )
570 {
571 case (AT_CMPL): /*operation completed*/
572 return (ATI_CMPL);
573 case (AT_EXCT):
574 // curAtCmd = AT_CMD_CGDSCONT; /*operation in progress*/
575 return (ATI_EXCT);
576 default:
577 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
578 return (ATI_FAIL);
579 }
580
581
582 #endif /* FF_ATI_BAT */
583
584 }
585
586 /*
587 +--------------------------------------------------------------------+
588 | PROJECT : UMTS MODULE : ATI_GPRS |
589 | STATE : ROUTINE : queatPlusCGDSCONT |
590 +--------------------------------------------------------------------+
591
592 PURPOSE : +CGDSCONT=? command
593 */
594
595 GLOBAL T_ATI_RSLT queatPlusCGDSCONT( char *cl, UBYTE srcId )
596 {
597 T_ACI_RETURN ret;
598 T_PDP_CONTEXT pdp_context_array[PDP_CONTEXT_CID_MAX];
599 U8 pdp_context_cid_array[PDP_CONTEXT_CID_MAX];
600 int i;
601
602 TRACE_FUNCTION("queatPlusCGDSCONT ()");
603 #ifdef FF_ATI_BAT
604 {
605 T_BAT_cmd_send cmd;
606 T_BAT_no_parameter dummy;
607
608 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGDSCONT;
609 dummy.bat_dummy = 0xFF;
610 cmd.params.ptr_set_plus_cgdscont = &dummy;
611 bat_send(ati_bat_get_client(srcId), &cmd);
612 return(ATI_EXCT);
613 }
614 #else
615
616 memset( &pdp_context_cid_array, PDP_CONTEXT_CID_OMITTED, sizeof(pdp_context_cid_array) );
617
618 ret = qAT_PlusCGDSCONT(( T_ACI_CMD_SRC)srcId, pdp_context_array, pdp_context_cid_array);
619
620 if (ret EQ AT_CMPL)
621 {
622 for ( i = 0; i < PDP_CONTEXT_CID_MAX AND pdp_context_cid_array[i] NEQ PDP_CONTEXT_CID_OMITTED; i++ )
623 {
624 sprintf( g_sa, "+CGDSCONT: %d,%d,%d,%d",
625 pdp_context_cid_array[i],
626 pdp_context_array[i].p_cid,
627 pdp_context_array[i].d_comp,
628 pdp_context_array[i].h_comp );
629
630 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
631 }
632 }
633 else
634 {
635 cmdCmeError(CME_ERR_Unknown);
636 return (ATI_FAIL);
637 }
638
639 return (ATI_CMPL);
640 #endif /* FF_ATI_BAT */
641 }
642
643 /*
644 +--------------------------------------------------------------------+
645 | PROJECT : UMTS MODULE : ATI_GPRS |
646 | STATE : ROUTINE : testatPlusCGDSCONT |
647 +--------------------------------------------------------------------+
648
649 PURPOSE : +CGDSCONT?
650 */
651
652 GLOBAL T_ATI_RSLT tesatPlusCGDSCONT( char *cl, UBYTE srcId )
653 {
654 char me[50];
655 char cid_list[PDP_CONTEXT_CID_MAX + 1];
656 BOOL active = FALSE;
657 U8 i = 0;
658 U8 cid;
659
660 cid_list[0] = 0;
661
662 me[0] = 0;
663
664 for( cid = PDP_CONTEXT_CID_MIN; cid <= PDP_CONTEXT_CID_MAX; cid++ )
665 {
666 if( tAT_PlusCGDSCONT(( T_ACI_CMD_SRC) srcId, cid, &active ) EQ AT_CMPL )
667 {
668 if( active EQ TRUE )
669 {
670 cid_list[i] = cid;
671 i++;
672 cid_list[i] = 0;
673 }
674 }
675 else
676 {
677 cmdCmeError( CME_ERR_Unknown );
678 return (ATI_FAIL);
679 }
680 }
681
682 i = 0;
683 sprintf( me, "+CGDSCONT: (1-%d),", PDP_CONTEXT_CID_MAX);
684
685 if( cid_list[i] NEQ 0 )
686 {
687 sprintf( me, "%s(%d", me, cid_list[i] );
688 i++;
689
690 while( cid_list[i] NEQ 0 )
691 {
692 sprintf( me, "%s,%d", me, cid_list[i] );
693 i++;
694 }
695 }
696
697 if( cid_list[0] NEQ 0 )
698 {
699 sprintf( me, "%s)", me );
700 }
701
702
703 /* As for EDGE we are not supporting PDP_Type as "PPP" */
704 /*sprintf( g_sa, "%s,\"PPP\",(0-1),(0-1)", me );
705 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);*/
706
707 sprintf( g_sa, "%s,\"IP\",(0),(0-1)", me );
708 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
709
710 sprintf( g_sa, "%s,\"IPV6\",(0),(0-1)", me );
711 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
712
713 return (ATI_CMPL);
714 }
715
716
717 /*
718 +--------------------------------------------------------------------+
719 | PROJECT : UMTS MODULE : ATI_GPRS |
720 | STATE : ROUTINE : atPlusCGTFT |
721 +--------------------------------------------------------------------+
722
723 PURPOSE : +CGTFT command ( Traffic Flow Template definition )
724 */
725
726 GLOBAL T_ATI_RSLT setatPlusCGTFT( char *cl, UBYTE srcId )
727 {
728 U8 cid = 0;
729 U8 protocol_or_next_header = 0;
730 U8 is_ip_valid = FALSE;
731 U16 tos_value = 0;
732 U16 tos_mask = 0;
733 U32 ipsec_spi = 0;
734 U32 flow_label = 0;
735
736 char *p_addr_n_mask_str = NULL;
737 char *p_dest_port_range_str = NULL;
738 char *p_src_port_range_str = NULL;
739 char *p_tos_mask_or_tc_mask_str = NULL;
740
741 USHORT addr_n_mask_str_len = 0;
742 USHORT dest_port_range_str_len = 0;
743 USHORT src_port_range_str_len = 0;
744 USHORT tos_mask_or_tc_mask_str_len = 0;
745 T_NAS_tft_pf tft_pf_input;
746
747 #ifdef FF_ATI_BAT
748 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
749 #endif
750
751 TRACE_FUNCTION("setatPlusCGTFT ()");
752
753 memset( &tft_pf_input, 0x00, sizeof(T_NAS_tft_pf) );
754
755 // +------------ 1: <cid>
756 // |+----------- 2: <packet filter identifier>
757 // ||+---------- 3: <evaluation precedence index>
758 // |||+--------- 4: <source address and sub met mask>
759 // ||||+-------- 5: <protocol number (IPv4) / next header (IPv6)>
760 // |||||+------- 6: <destenation port range>
761 // ||||||+------ 7: <source port range>
762 // |||||||+----- 8: <ipsec security parameter index (SPI)>
763 // ||||||||+---- 9: <type of service and mask (IPv4) / traffic class and mask (IPv6)>
764 // |||||||||+--- 10: <flow label (IPv6)>
765 // ||||||||||
766 cl = parse( cl, "ccclcllyly",
767 &cid, /* 1 */
768 &tft_pf_input.tft_pf_id, /* 2 */
769 &tft_pf_input.tft_pf_precedence, /* 3 */
770 &addr_n_mask_str_len, &p_addr_n_mask_str, /* 4 */
771 &protocol_or_next_header, /* 5 */
772 &dest_port_range_str_len, &p_dest_port_range_str, /* 6 */
773 &src_port_range_str_len, &p_src_port_range_str, /* 7 */
774 &ipsec_spi, /* 8 */
775 &tos_mask_or_tc_mask_str_len, &p_tos_mask_or_tc_mask_str, /* 9 */
776 &flow_label /* 10 */
777 );
778
779 if( !cl )
780 {
781 cmdCmeError(CME_ERR_OpNotAllow);
782 return (ATI_FAIL);
783 }
784
785 if( !p_addr_n_mask_str )
786 {
787 /* IP address and mask is omitted */
788
789 if( flow_label EQ 0 )
790 {
791 /* IP v4 type */
792 tft_pf_input.ctrl_tft_pf_entry = NAS_is_tft_pf_ipv4;
793 }
794 else
795 {
796 /* IP v6 type */
797 tft_pf_input.ctrl_tft_pf_entry = NAS_is_tft_pf_ipv6;
798 tft_pf_input.tft_pf_valid_bits |= NAS_TFT_ID_FLOW_LABEL;
799 }
800 }
801 else
802 {
803
804 if( addr_n_mask_str_len >= 15 AND addr_n_mask_str_len <= 31 )
805 {
806 // The length of the string is within the length of an IP v4 string.
807
808 if( flow_label EQ 0 )
809 {
810 tft_pf_input.ctrl_tft_pf_entry = NAS_is_tft_pf_ipv4;
811
812 // Parse IP v4 address
813 p_addr_n_mask_str = parseIPv4Address( p_addr_n_mask_str,
814 (U8*) &(tft_pf_input.tft_pf_entry.tft_pf_ipv4.tft_ipv4_src_addr_mask.tft_ipv4_addr), &is_ip_valid );
815 // Parse IP v4 sub net mask
816 p_addr_n_mask_str = parseIPv4Address( p_addr_n_mask_str,
817 (U8*) &(tft_pf_input.tft_pf_entry.tft_pf_ipv4.tft_ipv4_src_addr_mask.tft_ipv4_mask), &is_ip_valid);
818
819 tft_pf_input.tft_pf_valid_bits |= NAS_TFT_ID_IPv4_SRC_ADDR_MASK;
820 }
821 else
822 {
823 cmdCmeError(CME_ERR_OpNotAllow);
824 return (ATI_FAIL);
825 }
826 }
827 else
828 {
829 if( addr_n_mask_str_len >= 63 AND addr_n_mask_str_len <= 127 )
830 {
831 // The length of the string is within the length of an IP v6 string.
832
833 tft_pf_input.ctrl_tft_pf_entry = NAS_is_tft_pf_ipv6;
834 tft_pf_input.tft_pf_entry.tft_pf_ipv6.tft_flow_label = flow_label;
835
836 // Parse IP v6 address
837 p_addr_n_mask_str = parseIPv6Address( p_addr_n_mask_str,
838 (U8*) &(tft_pf_input.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_addr), &is_ip_valid );
839 // Parse IP v4 sub net mask
840 p_addr_n_mask_str = parseIPv6Address( p_addr_n_mask_str,
841 (U8*) &(tft_pf_input.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_mask), &is_ip_valid );
842
843 tft_pf_input.tft_pf_valid_bits |= NAS_TFT_ID_IPv6_SRC_ADDR_MASK;
844 }
845 else
846 {
847 cmdCmeError(CME_ERR_OpNotAllow);
848 return (ATI_FAIL);
849 }
850 }
851
852 if( !p_addr_n_mask_str )
853 {
854 cmdCmeError(CME_ERR_OpNotAllow);
855 return (ATI_FAIL);
856 }
857 } /* END: if( !p_addr_n_mask_str ) */
858
859 switch( tft_pf_input.ctrl_tft_pf_entry )
860 {
861 /*** IP v4 parameters */
862 case NAS_is_tft_pf_ipv4:
863 {
864 if( protocol_or_next_header )
865 {
866 tft_pf_input.tft_pf_entry.tft_pf_ipv4.tft_protocol = protocol_or_next_header;
867 tft_pf_input.tft_pf_valid_bits |= NAS_TFT_ID_PROTOCOL_OR_NEXT_HDR;
868 }
869
870 /* Type of service and mask */
871 if( p_tos_mask_or_tc_mask_str )
872 {
873 p_tos_mask_or_tc_mask_str = parseDSNP_U16( 1, p_tos_mask_or_tc_mask_str,
874 &tos_value );
875
876 tft_pf_input.tft_pf_entry.tft_pf_ipv4.tft_tos_and_mask.tos_value = (U8)tos_value;
877
878
879 p_tos_mask_or_tc_mask_str = parseDSNP_U16( 1, p_tos_mask_or_tc_mask_str,
880 &tos_mask );
881
882 tft_pf_input.tft_pf_entry.tft_pf_ipv4.tft_tos_and_mask.tos_mask = (U8)tos_mask;
883
884 tft_pf_input.tft_pf_valid_bits |= NAS_TFT_ID_TOS_AND_MASK;
885 }
886
887 /* Destenation port */
888 if( p_dest_port_range_str )
889 {
890 p_dest_port_range_str = parseDSNP_U16( 1, p_dest_port_range_str,
891 (U16*) &tft_pf_input.tft_pf_entry.tft_pf_ipv4.tft_dest_port_range.low_limit );
892 p_dest_port_range_str = parseDSNP_U16( 1, p_dest_port_range_str,
893 (U16*) &tft_pf_input.tft_pf_entry.tft_pf_ipv4.tft_dest_port_range.high_limit );
894
895 tft_pf_input.tft_pf_valid_bits |= NAS_TFT_ID_DEST_PORT_RANGE;
896 }
897
898 /* Source port */
899 if( p_src_port_range_str )
900 {
901 p_src_port_range_str = parseDSNP_U16( 1, p_src_port_range_str,
902 (U16*)&tft_pf_input.tft_pf_entry.tft_pf_ipv4.tft_src_port_range.low_limit );
903 p_src_port_range_str = parseDSNP_U16( 1, p_src_port_range_str,
904 (U16*)&tft_pf_input.tft_pf_entry.tft_pf_ipv4.tft_src_port_range.high_limit );
905
906 tft_pf_input.tft_pf_valid_bits |= NAS_TFT_ID_SRC_PORT_RANGE;
907 }
908
909 /* IPSEC security parameter spi */
910 if( ipsec_spi )
911 {
912 tft_pf_input.tft_pf_entry.tft_pf_ipv4.tft_ipsec_spi = ipsec_spi;
913 tft_pf_input.tft_pf_valid_bits |= NAS_TFT_ID_IPSEC_SPI;
914 }
915 break;
916
917 } /* END: case NAS_is_tft_pf_ipv4 */
918
919
920 /*** IP v6 parameters ***/
921 case NAS_is_tft_pf_ipv6:
922 {
923 /* Next header */
924 if ( protocol_or_next_header )
925 {
926 tft_pf_input.tft_pf_entry.tft_pf_ipv6.tft_next_hdr = protocol_or_next_header;
927 tft_pf_input.tft_pf_valid_bits |= NAS_TFT_ID_PROTOCOL_OR_NEXT_HDR;
928 }
929
930 /* Type of service and mask */
931 if ( p_tos_mask_or_tc_mask_str )
932 {
933 p_tos_mask_or_tc_mask_str = parseDSNP_U16( 1, p_tos_mask_or_tc_mask_str,
934 &tos_value );
935
936 tft_pf_input.tft_pf_entry.tft_pf_ipv6.tft_tos_and_mask.tos_value = (U8)tos_value;
937
938 p_tos_mask_or_tc_mask_str = parseDSNP_U16( 1, p_tos_mask_or_tc_mask_str,
939 &tos_mask );
940
941 tft_pf_input.tft_pf_entry.tft_pf_ipv6.tft_tos_and_mask.tos_mask = (U8)tos_mask;
942
943 tft_pf_input.tft_pf_valid_bits |= NAS_TFT_ID_TOS_AND_MASK;
944 }
945
946
947 /* Destenation port */
948 if ( p_dest_port_range_str )
949 {
950 p_dest_port_range_str = parseDSNP_U16( 1, p_dest_port_range_str,
951 (U16*)&tft_pf_input.tft_pf_entry.tft_pf_ipv6.tft_dest_port_range.low_limit );
952 p_dest_port_range_str = parseDSNP_U16( 1, p_dest_port_range_str,
953 (U16*)&tft_pf_input.tft_pf_entry.tft_pf_ipv6.tft_dest_port_range.high_limit );
954 tft_pf_input.tft_pf_valid_bits |= NAS_TFT_ID_DEST_PORT_RANGE;
955 }
956
957 /* Source port */
958 if ( p_src_port_range_str )
959 {
960 p_src_port_range_str = parseDSNP_U16( 1, p_src_port_range_str,
961 (U16*)&tft_pf_input.tft_pf_entry.tft_pf_ipv6.tft_src_port_range.low_limit );
962 p_src_port_range_str = parseDSNP_U16( 1, p_src_port_range_str,
963 (U16*)&tft_pf_input.tft_pf_entry.tft_pf_ipv6.tft_src_port_range.high_limit );
964 tft_pf_input.tft_pf_valid_bits |= NAS_TFT_ID_SRC_PORT_RANGE;
965 }
966
967 /* IPSEC security parameter spi */
968 if ( ipsec_spi )
969 {
970 tft_pf_input.tft_pf_entry.tft_pf_ipv6.tft_ipsec_spi = ipsec_spi;
971 tft_pf_input.tft_pf_valid_bits |= NAS_TFT_ID_IPSEC_SPI;
972 }
973
974 break;
975 } /* END: case NAS_is_tft_pf_ipv6 */
976
977 default:
978 {
979 cmdCmeError(CME_ERR_OpNotAllow);
980 return (ATI_FAIL);
981 }
982 } /* END: switch( tft_pf_input.ctrl_tft_pf_entry ) */
983
984 #ifdef FF_ATI_BAT
985 {
986 T_BAT_cmd_send bat_cmd;
987 T_BAT_cmd_set_plus_cgtft bat_cgtft;
988 bat_cmd.ctrl_params = BAT_CMD_SET_PLUS_CGTFT;
989 bat_cmd.params.ptr_set_plus_cgtft = &bat_cgtft;
990
991 bat_cgtft.cid = cid;
992 bat_cgtft.tft_pf_id = tft_pf_input.tft_pf_id;
993 bat_cgtft.tft_pf_precedence = tft_pf_input.tft_pf_precedence;
994 bat_cgtft.prt_num_or_nxt_hd = protocol_or_next_header;
995
996 /* addr_n_mask */
997 bat_cgtft.v_addr_n_mask = (addr_n_mask_str_len AND
998 p_addr_n_mask_str);
999
1000 if (tft_pf_input.ctrl_tft_pf_entry EQ NAS_is_tft_pf_ipv4)
1001 {
1002 bat_cgtft.c_addr_n_mask = 2 * NAS_SIZE_IPv4_ADDR;
1003 memcpy(bat_cgtft.addr_n_mask,
1004 &tft_pf_input.tft_pf_entry.tft_pf_ipv4.tft_ipv4_src_addr_mask,
1005 2 * NAS_SIZE_IPv4_ADDR);
1006
1007 /* dest_port_range */
1008 if (tft_pf_input.tft_pf_valid_bits &
1009 NAS_TFT_ID_DEST_PORT_RANGE)
1010 {
1011 bat_cgtft.v_dest_port_range = TRUE;
1012 bat_cgtft.c_dest_port_range = 2;
1013 bat_cgtft.dest_port_range[0] = tft_pf_input.tft_pf_entry.
1014 tft_pf_ipv4.tft_dest_port_range.low_limit;
1015 bat_cgtft.dest_port_range[1] = tft_pf_input.tft_pf_entry.
1016 tft_pf_ipv4.tft_dest_port_range.high_limit;
1017 }
1018
1019 /* src_port_range */
1020 if (tft_pf_input.tft_pf_valid_bits &
1021 NAS_TFT_ID_SRC_PORT_RANGE)
1022 {
1023 bat_cgtft.v_src_port_range = TRUE;
1024 bat_cgtft.c_src_port_range = 2;
1025 bat_cgtft.src_port_range[0] = tft_pf_input.tft_pf_entry.
1026 tft_pf_ipv4.tft_src_port_range.low_limit;
1027 bat_cgtft.src_port_range[1] = tft_pf_input.tft_pf_entry.
1028 tft_pf_ipv4.tft_src_port_range.high_limit;
1029 }
1030
1031 /* tos_mask_or_tc_mask */
1032 if (tft_pf_input.tft_pf_valid_bits &
1033 NAS_TFT_ID_TOS_AND_MASK)
1034 {
1035 bat_cgtft.v_tos_mask_or_tc_mask = TRUE;
1036 bat_cgtft.c_tos_mask_or_tc_mask = 2;
1037 bat_cgtft.tos_mask_or_tc_mask[0] = tft_pf_input.tft_pf_entry.
1038 tft_pf_ipv4.tft_tos_and_mask.tos_value;
1039 bat_cgtft.tos_mask_or_tc_mask[1] = tft_pf_input.tft_pf_entry.
1040 tft_pf_ipv4.tft_tos_and_mask.tos_mask;
1041 }
1042 }
1043 else if (tft_pf_input.ctrl_tft_pf_entry EQ NAS_is_tft_pf_ipv6)
1044 {
1045 bat_cgtft.c_addr_n_mask = 2 * NAS_SIZE_IPv6_ADDR;
1046 memcpy(bat_cgtft.addr_n_mask,
1047 &tft_pf_input.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask,
1048 2 * NAS_SIZE_IPv6_ADDR);
1049
1050 /* dest_port_range */
1051 if (tft_pf_input.tft_pf_valid_bits &
1052 NAS_TFT_ID_DEST_PORT_RANGE)
1053 {
1054 bat_cgtft.v_dest_port_range = TRUE;
1055 bat_cgtft.c_dest_port_range = 2;
1056 bat_cgtft.dest_port_range[0] = tft_pf_input.tft_pf_entry.
1057 tft_pf_ipv6.tft_dest_port_range.low_limit;
1058 bat_cgtft.dest_port_range[1] = tft_pf_input.tft_pf_entry.
1059 tft_pf_ipv6.tft_dest_port_range.high_limit;
1060 }
1061
1062 /* src_port_range */
1063 if (tft_pf_input.tft_pf_valid_bits &
1064 NAS_TFT_ID_SRC_PORT_RANGE)
1065 {
1066 bat_cgtft.v_src_port_range = TRUE;
1067 bat_cgtft.c_src_port_range = 2;
1068 bat_cgtft.src_port_range[0] = tft_pf_input.tft_pf_entry.
1069 tft_pf_ipv6.tft_src_port_range.low_limit;
1070 bat_cgtft.src_port_range[1] = tft_pf_input.tft_pf_entry.
1071 tft_pf_ipv6.tft_src_port_range.high_limit;
1072 }
1073
1074 /* tos_mask_or_tc_mask */
1075 if (tft_pf_input.tft_pf_valid_bits &
1076 NAS_TFT_ID_TOS_AND_MASK)
1077 {
1078 bat_cgtft.v_tos_mask_or_tc_mask = TRUE;
1079 bat_cgtft.c_tos_mask_or_tc_mask = 2;
1080 bat_cgtft.tos_mask_or_tc_mask[0] = tft_pf_input.tft_pf_entry.
1081 tft_pf_ipv6.tft_tos_and_mask.tos_value;
1082 bat_cgtft.tos_mask_or_tc_mask[1] = tft_pf_input.tft_pf_entry.
1083 tft_pf_ipv6.tft_tos_and_mask.tos_mask;
1084 }
1085
1086 }
1087
1088 /* ipsec_spi */
1089 //bat_cgtft.v_ipsec_spi = tft_pf_input.ipsec_spi_present;
1090 bat_cgtft.ipsec_spi = ipsec_spi;
1091
1092
1093 /* flow_label */
1094 bat_cgtft.flow_label = flow_label;
1095
1096 bat_send(ati_bat_get_client(srcId), &bat_cmd);
1097 src_params->curAtCmd=AT_CMD_CGTFT;
1098 return(ATI_EXCT);
1099 }
1100 #else
1101 switch( sAT_PlusCGTFT( ( T_ACI_CMD_SRC)srcId, cid , &tft_pf_input) )
1102 {
1103 case (AT_CMPL): /* Operation completed */
1104 return (ATI_CMPL);
1105 case (AT_EXCT): /* Operation in progress */
1106 // curAtCmd = AT_CMD_CGTFT;
1107 return (ATI_EXCT);
1108 default:
1109 cmdCmeError(CME_ERR_Unknown); /* Command failed */
1110 return (ATI_FAIL);
1111 }
1112
1113 #endif /* FF_ATI_BAT */
1114 }
1115
1116 /*
1117 +--------------------------------------------------------------------+
1118 | PROJECT : UMTS MODULE : ATI_GPRS |
1119 | STATE : ROUTINE : setatPlusCGTFT |
1120 +--------------------------------------------------------------------+
1121
1122 PURPOSE : +CGTFT=? command
1123 */
1124
1125 GLOBAL T_ATI_RSLT queatPlusCGTFT( char *cl, UBYTE srcId )
1126 {
1127 T_ACI_RETURN ret;
1128 U8 pdp_context_cid_array[PDP_CONTEXT_CID_MAX];
1129 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
1130 T_TFT_INTERNAL *p_tft_pf_node = NULL;
1131 int i = 0;
1132 USHORT pos = 0;
1133
1134 TRACE_FUNCTION("queatPlusCGTFT()");
1135
1136 #ifdef FF_ATI_BAT
1137 {
1138 T_BAT_cmd_send cmd;
1139 T_BAT_no_parameter dummy;
1140
1141 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGTFT;
1142 dummy.bat_dummy = 0xFF;
1143 cmd.params.ptr_set_plus_cgtft = &dummy;
1144 bat_send(ati_bat_get_client(srcId), &cmd);
1145 return(ATI_EXCT);
1146 }
1147 #else
1148
1149 memset( &pdp_context_cid_array, PDP_CONTEXT_CID_OMITTED, sizeof(pdp_context_cid_array) );
1150
1151 ret = qAT_PlusCGTFT(( T_ACI_CMD_SRC)srcId, (U8*) &pdp_context_cid_array[0]);
1152
1153 if (ret EQ AT_CMPL)
1154 {
1155 for ( i = 0; i < PDP_CONTEXT_CID_MAX AND pdp_context_cid_array[i] NEQ PDP_CONTEXT_CID_OMITTED; i++ )
1156 {
1157 p_pdp_context_node = pdp_context_find_node_from_cid( pdp_context_cid_array[i] );
1158 p_tft_pf_node = p_pdp_context_node->p_tft_pf;
1159 while( p_tft_pf_node )
1160 {
1161 switch( p_tft_pf_node->pf_attributes.ctrl_tft_pf_entry )
1162 {
1163 case NAS_is_tft_pf_ipv4:
1164 pos = sprintf( g_sa, "+CGTFT: %d,%d,%d,",
1165 pdp_context_cid_array[i],
1166 p_tft_pf_node->pf_attributes.tft_pf_id,
1167 p_tft_pf_node->pf_attributes.tft_pf_precedence);
1168
1169 if( p_tft_pf_node->pf_attributes.tft_pf_valid_bits & NAS_TFT_ID_IPv4_SRC_ADDR_MASK )
1170 {
1171 pos += sprintf( g_sa + pos , "\"%d.%d.%d.%d.%d.%d.%d.%d\",",
1172 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv4.tft_ipv4_src_addr_mask.tft_ipv4_addr[0],
1173 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv4.tft_ipv4_src_addr_mask.tft_ipv4_addr[1],
1174 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv4.tft_ipv4_src_addr_mask.tft_ipv4_addr[2],
1175 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv4.tft_ipv4_src_addr_mask.tft_ipv4_addr[3],
1176 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv4.tft_ipv4_src_addr_mask.tft_ipv4_mask[0],
1177 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv4.tft_ipv4_src_addr_mask.tft_ipv4_mask[1],
1178 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv4.tft_ipv4_src_addr_mask.tft_ipv4_mask[2],
1179 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv4.tft_ipv4_src_addr_mask.tft_ipv4_mask[3] );
1180 }
1181 else
1182 {
1183 pos += sprintf( g_sa + pos, "," );
1184 }
1185
1186 if( p_tft_pf_node->pf_attributes.tft_pf_valid_bits & NAS_TFT_ID_PROTOCOL_OR_NEXT_HDR )
1187 {
1188 pos += sprintf( g_sa + pos, "%d,",
1189 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv4.tft_protocol );
1190 }
1191 else
1192 {
1193 pos += sprintf( g_sa + pos, "," );
1194 }
1195
1196 if( p_tft_pf_node->pf_attributes.tft_pf_valid_bits & NAS_TFT_ID_DEST_PORT_RANGE )
1197 {
1198 pos += sprintf( g_sa + pos, "\"%d.%d\",",
1199 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv4.tft_dest_port_range.low_limit,
1200 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv4.tft_dest_port_range.high_limit );
1201 }
1202 else
1203 {
1204 pos += sprintf( g_sa + pos, "," );
1205 }
1206
1207 if( p_tft_pf_node->pf_attributes.tft_pf_valid_bits & NAS_TFT_ID_SRC_PORT_RANGE )
1208 {
1209 pos += sprintf( g_sa + pos, "\"%d.%d\",",
1210 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv4.tft_src_port_range.low_limit,
1211 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv4.tft_src_port_range.high_limit );
1212 }
1213 else
1214 {
1215 pos += sprintf( g_sa + pos, "," );
1216 }
1217
1218 if( p_tft_pf_node->pf_attributes.tft_pf_valid_bits & NAS_TFT_ID_IPSEC_SPI )
1219 {
1220 pos += sprintf( g_sa + pos, "%X,",
1221 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv4.tft_ipsec_spi );
1222 }
1223 else
1224 {
1225 pos += sprintf( g_sa + pos, "," );
1226 }
1227
1228 if( p_tft_pf_node->pf_attributes.tft_pf_valid_bits & NAS_TFT_ID_TOS_AND_MASK )
1229 {
1230 pos += sprintf( g_sa + pos, "\"%d.%d\",",
1231 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv4.tft_tos_and_mask.tos_value,
1232 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv4.tft_tos_and_mask.tos_mask );
1233 }
1234 else
1235 {
1236 pos += sprintf( g_sa + pos, "," );
1237 }
1238
1239 break;
1240
1241 case NAS_is_tft_pf_ipv6:
1242 pos = sprintf( g_sa, "+CGTFT: %d,%d,%d,",
1243 pdp_context_cid_array[i],
1244 p_tft_pf_node->pf_attributes.tft_pf_id,
1245 p_tft_pf_node->pf_attributes.tft_pf_precedence);
1246
1247 if( p_tft_pf_node->pf_attributes.tft_pf_valid_bits & NAS_TFT_ID_IPv6_SRC_ADDR_MASK )
1248 {
1249 pos += sprintf( g_sa + pos, "\"%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d\",",
1250 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_addr[0],
1251 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_addr[1],
1252 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_addr[2],
1253 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_addr[3],
1254 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_addr[4],
1255 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_addr[5],
1256 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_addr[6],
1257 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_addr[7],
1258 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_addr[8],
1259 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_addr[9],
1260 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_addr[10],
1261 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_addr[11],
1262 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_addr[12],
1263 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_addr[13],
1264 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_addr[14],
1265 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_addr[15],
1266
1267 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_mask[0],
1268 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_mask[1],
1269 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_mask[2],
1270 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_mask[3],
1271 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_mask[4],
1272 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_mask[5],
1273 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_mask[6],
1274 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_mask[7],
1275 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_mask[8],
1276 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_mask[9],
1277 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_mask[10],
1278 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_mask[11],
1279 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_mask[12],
1280 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_mask[13],
1281 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_mask[14],
1282 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipv6_src_addr_mask.tft_ipv6_mask[15]);
1283 }
1284 else
1285 {
1286 pos += sprintf( g_sa + pos, "," );
1287 }
1288
1289 if( p_tft_pf_node->pf_attributes.tft_pf_valid_bits & NAS_TFT_ID_PROTOCOL_OR_NEXT_HDR )
1290 {
1291 pos += sprintf( g_sa + pos, "%d,",
1292 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_next_hdr );
1293 }
1294 else
1295 {
1296 pos += sprintf( g_sa + pos, "," );
1297 }
1298
1299 if( p_tft_pf_node->pf_attributes.tft_pf_valid_bits & NAS_TFT_ID_DEST_PORT_RANGE )
1300 {
1301 pos += sprintf( g_sa + pos, "\"%d.%d\",",
1302 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_dest_port_range.low_limit,
1303 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_dest_port_range.high_limit );
1304 }
1305 else
1306 {
1307 pos += sprintf( g_sa + pos, "," );
1308 }
1309
1310 if( p_tft_pf_node->pf_attributes.tft_pf_valid_bits & NAS_TFT_ID_SRC_PORT_RANGE )
1311 {
1312 pos += sprintf( g_sa + pos, "\"%d.%d\",",
1313 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_src_port_range.low_limit,
1314 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_src_port_range.high_limit );
1315 }
1316 else
1317 {
1318 pos += sprintf( g_sa + pos, "," );
1319 }
1320
1321 if( p_tft_pf_node->pf_attributes.tft_pf_valid_bits & NAS_TFT_ID_IPSEC_SPI )
1322 {
1323 pos += sprintf( g_sa + pos, "%X,",
1324 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_ipsec_spi );
1325 }
1326 else
1327 {
1328 pos += sprintf( g_sa + pos, "," );
1329 }
1330
1331 if( p_tft_pf_node->pf_attributes.tft_pf_valid_bits & NAS_TFT_ID_TOS_AND_MASK )
1332 {
1333 pos += sprintf( g_sa + pos, "\"%d.%d\",",
1334 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_tos_and_mask.tos_value,
1335 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_tos_and_mask.tos_mask );
1336 }
1337 else
1338 {
1339 pos += sprintf( g_sa + pos, "," );
1340 }
1341
1342 if( p_tft_pf_node->pf_attributes.tft_pf_valid_bits & NAS_TFT_ID_FLOW_LABEL )
1343 {
1344 pos += sprintf( g_sa + pos, "%d",
1345 p_tft_pf_node->pf_attributes.tft_pf_entry.tft_pf_ipv6.tft_flow_label );
1346 }
1347
1348 break;
1349 }
1350
1351 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1352 p_tft_pf_node = p_tft_pf_node->p_next;
1353 }
1354
1355 }
1356 }
1357 else
1358 {
1359 cmdCmeError(CME_ERR_Unknown);
1360 return (ATI_FAIL);
1361 }
1362
1363 return (map_aci_2_ati_rslt(ret));
1364 #endif /* FF_ATI_BAT */
1365 }
1366
1367 /*
1368 +--------------------------------------------------------------------+
1369 | PROJECT : UMTS MODULE : ATI_GPRS |
1370 | STATE : ROUTINE : testatPlusCGTFT |
1371 +--------------------------------------------------------------------+
1372
1373 PURPOSE : +CGTFT?
1374 */
1375 GLOBAL T_ATI_RSLT tesatPlusCGTFT( char *cl, UBYTE srcId )
1376 {
1377 U8 pf_id_max;
1378
1379 pf_id_max = TFT_PF_ID_MAX;
1380
1381 TRACE_FUNCTION("tesatPlusCGTFT()");
1382
1383 sprintf( g_sa, "+CGTFT: <PDP_type = \"IP\">, (1-%d),(0-255),\"a1.a2.a3.a4.m1.m2.m3.m4\" (0-255),(0-255),\"f.t\" (0-65535),\"f.t\" (0-65535),(0-FFFFFFFF),\"t.m\" (0-255),(0)", pf_id_max );
1384 io_sendMessage( srcId, g_sa, ATI_NORMAL_OUTPUT);
1385
1386 sprintf( g_sa, "+CGTFT: <PDP_type = \"IPV6\">, (1-%d),(0-255),\"a1.a2...a15.m1.m2...m15\" (0-255),(0-255),\"f.t\" (0-65535),\"f.t\" (0-65535),(0-FFFFFFFF),\"t.m\" (0-255),(0-FFFF)", pf_id_max );
1387 io_sendMessage( srcId, g_sa, ATI_NORMAL_OUTPUT);
1388
1389 /* As for EDGE we are not supporting PDP_Type as "PPP" */
1390 /*sprintf( g_sa, "+CGTFT: <PDP_type = \"PPP\">, (1-%d),(0-255),\"a1.a2...a15.m1.m2...m15\" (0-255),(0-255),\"f.t\" (0-65535),\"f.t\" (0-65535),(0-FFFFFFFF),\"t.m\" (0-255),(0-FFFF)", pf_id_max );
1391 io_sendMessage( srcId, g_sa, ATI_NORMAL_OUTPUT);*/
1392
1393 return (ATI_CMPL);
1394 }
1395 #endif /* REL99 */
1396
1397 /*
1398 +--------------------------------------------------------------------+
1399 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
1400 | STATE : finnished ROUTINE : setatPlusCGQREQ |
1401 +--------------------------------------------------------------------+
1402
1403 PURPOSE : +CGQREQ command (context QOS request)
1404 */
1405
1406 GLOBAL T_ATI_RSLT setatPlusCGQREQ (char *cl, UBYTE srcId)
1407 {
1408 T_ACI_RETURN ret = AT_FAIL;
1409 T_PS_qos input_qos;
1410 U8 cid;
1411 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1412 TRACE_FUNCTION("setatPlusCGQREQ ()");
1413
1414 cid = PDP_CONTEXT_CID_OMITTED;
1415
1416 input_qos.qos_r97.delay = (U8) PDP_CONTEXT_QOS_OMITTED;
1417 input_qos.qos_r97.relclass = (U8) PDP_CONTEXT_QOS_OMITTED;
1418 input_qos.qos_r97.peak = (U8) PDP_CONTEXT_QOS_OMITTED;
1419 input_qos.qos_r97.preced = (U8) PDP_CONTEXT_QOS_OMITTED;
1420 input_qos.qos_r97.mean = (U8) PDP_CONTEXT_QOS_OMITTED;
1421
1422 cl = parse( cl,"caaaar", &cid,
1423 1L ,&input_qos.qos_r97.preced,
1424 1L ,&input_qos.qos_r97.delay,
1425 1L ,&input_qos.qos_r97.relclass,
1426 1L ,&input_qos.qos_r97.peak,
1427 &input_qos.qos_r97.mean );
1428 if ( !cl )
1429 {
1430 cmdCmeError(CME_ERR_OpNotAllow);
1431 return (ATI_FAIL);
1432 }
1433
1434 if ( input_qos.qos_r97.preced NEQ PDP_CONTEXT_QOS_OMITTED )
1435 input_qos.qos_r97.preced -= '0';
1436 if ( input_qos.qos_r97.delay NEQ PDP_CONTEXT_QOS_OMITTED )
1437 input_qos.qos_r97.delay -= '0';
1438 if ( input_qos.qos_r97.relclass NEQ PDP_CONTEXT_QOS_OMITTED )
1439 input_qos.qos_r97.relclass -= '0';
1440 if ( input_qos.qos_r97.peak NEQ PDP_CONTEXT_QOS_OMITTED )
1441 input_qos.qos_r97.peak -= '0';
1442 if ( input_qos.qos_r97.mean EQ 0xff )
1443 input_qos.qos_r97.mean = 0;
1444
1445 #ifdef FF_ATI_BAT
1446
1447 {
1448 T_BAT_cmd_send cmd;
1449 T_BAT_cmd_set_plus_cgqreq cgqreq;
1450
1451 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGQREQ;
1452 cmd.params.ptr_set_plus_cgqreq=&cgqreq;
1453
1454 cgqreq.cid=(T_BAT_pdp_cid)cid;
1455 cgqreq.precedence = (T_BAT_precedence)input_qos.qos_r97.preced;
1456 cgqreq.delay = (T_BAT_delay)input_qos.qos_r97.delay;
1457 cgqreq.reliability = (T_BAT_reliability)input_qos.qos_r97.relclass;
1458 cgqreq.peak = (T_BAT_peak)input_qos.qos_r97.peak;
1459 cgqreq.mean = (T_BAT_mean)input_qos.qos_r97.mean;
1460
1461 bat_send(ati_bat_get_client(srcId), &cmd);
1462
1463 src_params->curAtCmd=AT_CMD_CGQREQ;
1464 return(ATI_EXCT);
1465 }
1466 #else
1467 ret = sAT_PlusCGQREQ ((T_ACI_CMD_SRC)srcId, cid ,&input_qos);
1468 switch (ret)
1469 {
1470 case (AT_CMPL): /*operation completed*/
1471 return (ATI_CMPL);
1472 case (AT_EXCT):
1473 // src_params->curAtCmd = AT_CMD_CGQREQ;
1474 return (ATI_EXCT);
1475 default:
1476 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
1477 return (ATI_FAIL);
1478 }
1479 #endif
1480 }
1481
1482 /*
1483 +--------------------------------------------------------------------+
1484 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
1485 | STATE : finnished ROUTINE : queatPlusCGQREQ |
1486 +--------------------------------------------------------------------+
1487
1488 PURPOSE : Reading +CGQREQ command (context QOS request)
1489 */
1490
1491 GLOBAL T_ATI_RSLT queatPlusCGQREQ (char *cl, UBYTE srcId)
1492 {
1493 #ifndef FF_ATI_BAT
1494 T_PS_qos pdef_qos;
1495 BOOL qos_valid = FALSE;
1496 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
1497 #endif
1498
1499 TRACE_FUNCTION("queatPlusCGQREQ ()");
1500 #ifdef FF_ATI_BAT
1501 {
1502 T_BAT_cmd_send cmd;
1503 T_BAT_no_parameter dummy;
1504
1505 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CGQREQ;
1506 dummy.bat_dummy = 0xFF;
1507 cmd.params.ptr_que_plus_cgqreq = &dummy;
1508 bat_send(ati_bat_get_client(srcId), &cmd);
1509 return(ATI_EXCT);
1510 }
1511 #else
1512 p_pdp_context_node = p_pdp_context_list;
1513
1514 while( p_pdp_context_node )
1515 {
1516 if (qAT_PlusCGQREQ ((T_ACI_CMD_SRC)srcId, p_pdp_context_node->cid, &qos_valid, &pdef_qos ) EQ AT_CMPL)
1517 {
1518 if( qos_valid )
1519 {
1520 sprintf( g_sa, "+CGQREQ: %hd,%d,%d,%d,%d,%d",
1521 p_pdp_context_node->cid,
1522 pdef_qos.qos_r97.preced,
1523 pdef_qos.qos_r97.delay,
1524 pdef_qos.qos_r97.relclass,
1525 pdef_qos.qos_r97.peak,
1526 pdef_qos.qos_r97.mean );
1527
1528 io_sendMessage( srcId, g_sa, ATI_NORMAL_OUTPUT );
1529 }
1530 }
1531 else
1532 {
1533 /* AT_FAIL has been returned */
1534 cmdCmeError(CME_ERR_Unknown); /* The command is invalid for srcId */
1535 return (ATI_FAIL);
1536 }
1537
1538 p_pdp_context_node = p_pdp_context_node->p_next;
1539 }
1540
1541 return (ATI_CMPL);
1542 #endif
1543 }
1544
1545 /*
1546 +--------------------------------------------------------------------+
1547 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
1548 | STATE : finished ROUTINE : atPlusCGQMIN |
1549 +--------------------------------------------------------------------+
1550
1551 PURPOSE : +CGQMIN command (context min QOS requirement)
1552 */
1553
1554 GLOBAL T_ATI_RSLT setatPlusCGQMIN (char *cl, UBYTE srcId)
1555 {
1556 T_ACI_RETURN ret = AT_FAIL;
1557 T_PS_min_qos input_qos;
1558 U8 cid;
1559 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1560
1561 TRACE_FUNCTION("setatPlusCGQMIN ()");
1562
1563 cid = PDP_CONTEXT_CID_OMITTED;
1564
1565 input_qos.qos_r97.delay = (U8) PDP_CONTEXT_QOS_OMITTED;
1566 input_qos.qos_r97.relclass = (U8) PDP_CONTEXT_QOS_OMITTED;
1567 input_qos.qos_r97.peak = (U8) PDP_CONTEXT_QOS_OMITTED;
1568 input_qos.qos_r97.preced = (U8) PDP_CONTEXT_QOS_OMITTED;
1569 input_qos.qos_r97.mean = (U8) PDP_CONTEXT_QOS_OMITTED;
1570
1571 cl = parse( cl, "caaaar", &cid,
1572 1L, &input_qos.qos_r97.preced,
1573 1L, &input_qos.qos_r97.delay,
1574 1L, &input_qos.qos_r97.relclass,
1575 1L, &input_qos.qos_r97.peak,
1576 &input_qos.qos_r97.mean );
1577
1578 if ( !cl )
1579 {
1580 cmdCmeError(CME_ERR_OpNotAllow);
1581 return (ATI_FAIL);
1582 }
1583
1584 #ifdef FF_ATI_BAT
1585
1586 {
1587 T_BAT_cmd_send cmd;
1588 T_BAT_cmd_set_plus_cgqmin cgqmin;
1589
1590 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGQMIN;
1591 cmd.params.ptr_set_plus_cgqmin=&cgqmin;
1592
1593 cgqmin.cid=(T_BAT_pdp_cid)cid;
1594 /*
1595 if (input_qos.preced!=GPRS_QOS_OMITTED)
1596 cgqmin.precedence=(T_BAT_precedence)input_qos.preced;
1597 else
1598 cgqmin.precedence=BAT_PRECEDENCE_NOT_PRESENT;
1599
1600 if (input_qos.delay!=GPRS_QOS_OMITTED)
1601 cgqmin.delay=(T_BAT_delay)input_qos.delay;
1602 else
1603 cgqmin.delay=BAT_DELAY_NOT_PRESENT;
1604
1605 if (input_qos.relclass!=GPRS_QOS_OMITTED)
1606 cgqmin.reliability=(T_BAT_reliability)input_qos.relclass;
1607 else
1608 cgqmin.reliability=BAT_RELIABILITY_NOT_PRESENT;
1609
1610 if (input_qos.peak!=GPRS_QOS_OMITTED)
1611 cgqmin.peak=(T_BAT_peak)input_qos.peak;
1612 else
1613 cgqmin.peak=BAT_PEAK_NOT_PRESENT;
1614
1615 if (input_qos.mean)
1616 cgqmin.mean=(T_BAT_mean)input_qos.mean;
1617 else
1618 cgqmin.mean=BAT_MEAN_NOT_PRESENT;
1619 */
1620
1621 cgqmin.precedence = (T_BAT_precedence)input_qos.qos_r97.preced;
1622 cgqmin.delay = (T_BAT_delay)input_qos.qos_r97.delay;
1623 cgqmin.reliability = (T_BAT_reliability)input_qos.qos_r97.relclass;
1624 cgqmin.peak = (T_BAT_peak)input_qos.qos_r97.peak;
1625 cgqmin.mean = (T_BAT_mean)input_qos.qos_r97.mean;
1626
1627 bat_send(ati_bat_get_client(srcId), &cmd);
1628
1629 src_params->curAtCmd=AT_CMD_CGQMIN;
1630 return(ATI_EXCT);
1631 }
1632
1633 #else
1634
1635
1636 if ( input_qos.qos_r97.preced NEQ PDP_CONTEXT_QOS_OMITTED )
1637 input_qos.qos_r97.preced -= '0';
1638 if ( input_qos.qos_r97.delay NEQ PDP_CONTEXT_QOS_OMITTED )
1639 input_qos.qos_r97.delay -= '0';
1640 if ( input_qos.qos_r97.relclass NEQ PDP_CONTEXT_QOS_OMITTED )
1641 input_qos.qos_r97.relclass -= '0';
1642 if ( input_qos.qos_r97.peak NEQ PDP_CONTEXT_QOS_OMITTED )
1643 input_qos.qos_r97.peak -= '0';
1644 if ( input_qos.qos_r97.mean EQ 0xff )
1645 input_qos.qos_r97.mean = 0;
1646
1647
1648
1649 ret = sAT_PlusCGQMIN((T_ACI_CMD_SRC)srcId, cid, &input_qos );
1650 switch (ret)
1651 {
1652 case (AT_CMPL): /*operation completed*/
1653 return (ATI_CMPL);
1654 case (AT_EXCT):
1655 src_params->curAtCmd = AT_CMD_CGQMIN;
1656 return (ATI_EXCT);
1657 default:
1658 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
1659 return (ATI_FAIL);
1660 }
1661 #endif
1662 }
1663
1664 /*
1665 +--------------------------------------------------------------------+
1666 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
1667 | STATE : finished ROUTINE : queatPlusCGQMIN |
1668 +--------------------------------------------------------------------+
1669
1670 PURPOSE : Reading +CGQMIN command (context min QOS requirement)
1671 */
1672 GLOBAL T_ATI_RSLT queatPlusCGQMIN (char *cl, UBYTE srcId)
1673
1674 {
1675 #ifndef FF_ATI_BAT
1676 T_PS_qos pdef_qos;
1677 BOOL qos_valid = FALSE;
1678 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
1679
1680 #endif
1681
1682 #ifdef FF_ATI_BAT
1683 {
1684 T_BAT_cmd_send cmd;
1685 T_BAT_no_parameter dummy;
1686
1687 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CGQMIN;
1688 dummy.bat_dummy = 0xFF;
1689 cmd.params.ptr_que_plus_cgqmin = &dummy;
1690
1691 bat_send(ati_bat_get_client(srcId), &cmd);
1692
1693 return(ATI_EXCT);
1694 }
1695 #else
1696
1697 TRACE_FUNCTION("queatPlusCGQMIN ()");
1698
1699 p_pdp_context_node = p_pdp_context_list;
1700
1701 while( p_pdp_context_node )
1702 {
1703 if( qAT_PlusCGQMIN((T_ACI_CMD_SRC)srcId, p_pdp_context_node->cid, &qos_valid, &pdef_qos ) EQ AT_CMPL )
1704 {
1705 if (qos_valid)
1706 {
1707
1708 /* In the privous version of alborg code is the paramters are ommited then
1709 the code is sending ',' instead of default values. Now it changed
1710 */
1711 sprintf( g_sa, "+CGQMIN: %hd,%d,%d,%d,%d,%d",
1712 p_pdp_context_node->cid,
1713 pdef_qos.qos_r97.preced,
1714 pdef_qos.qos_r97.delay,
1715 pdef_qos.qos_r97.relclass,
1716 pdef_qos.qos_r97.peak,
1717 pdef_qos.qos_r97.mean );
1718 io_sendMessage( srcId, g_sa, ATI_NORMAL_OUTPUT );
1719 }
1720 }
1721 else
1722 {
1723 /* AT_FAIL has been returned */
1724 cmdCmeError(CME_ERR_Unknown); /* The command is invalid for srcId */
1725 return (ATI_FAIL);
1726 }
1727
1728 p_pdp_context_node = p_pdp_context_node->p_next;
1729
1730 }
1731
1732 return (ATI_CMPL);
1733 #endif
1734 }
1735
1736
1737 /*
1738 +--------------------------------------------------------------------+
1739 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
1740 | STATE : finished ROUTINE : atPlusCGATT |
1741 +--------------------------------------------------------------------+
1742
1743 PURPOSE : +CGATT command ( GPRS attach/detach )
1744 */
1745
1746 GLOBAL T_ATI_RSLT setatPlusCGATT (char *cl, UBYTE srcId)
1747 {
1748 T_ACI_RETURN ret = AT_FAIL;
1749 T_CGATT_STATE state = CGATT_STATE_OMITTED;
1750 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1751
1752 TRACE_FUNCTION("setatPlusCGATT ()");
1753
1754 cl=parse(cl,"d",&state);
1755
1756 if ( !cl )
1757 {
1758 cmdCmeError(CME_ERR_OpNotAllow);
1759 return (ATI_FAIL);
1760 }
1761 #ifdef FF_ATI_BAT
1762
1763 {
1764 T_BAT_cmd_send cmd;
1765 T_BAT_cmd_set_plus_cgatt cgatt;
1766
1767 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGATT;
1768 cmd.params.ptr_set_plus_cgatt=&cgatt;
1769
1770 /*
1771 * This relies on T_CGATT_STATE being identical to
1772 * T_BAT_plus_cgatt_state.
1773 */
1774 cgatt.state=(T_BAT_plus_cgatt_state)state;
1775
1776 bat_send(ati_bat_get_client(srcId), &cmd);
1777
1778 src_params->curAtCmd=AT_CMD_CGATT;
1779 return(ATI_EXCT);
1780 }
1781 #else
1782
1783 ret = sAT_PlusCGATT ((T_ACI_CMD_SRC)srcId, state );
1784 switch (ret)
1785 {
1786 case (AT_CMPL): /*operation completed*/
1787 return (ATI_CMPL);
1788 case (AT_EXCT):
1789 src_params->curAtCmd = AT_CMD_CGATT;
1790 return (ATI_EXCT);
1791 default:
1792 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
1793 return (ATI_FAIL);
1794 }
1795 #endif
1796 }
1797
1798 GLOBAL T_ATI_RSLT queatPlusCGATT (char *cl, UBYTE srcId)
1799 {
1800 #ifndef FF_ATI_BAT
1801 char *me="+CGATT: ";
1802 T_ACI_RETURN ret = AT_FAIL;
1803 T_CGATT_STATE state = CGATT_STATE_OMITTED;
1804 #endif
1805
1806 TRACE_FUNCTION("queatPlusCGATT ()");
1807
1808 #ifdef FF_ATI_BAT
1809 {
1810 T_BAT_cmd_send cmd;
1811 T_BAT_no_parameter dummy;
1812
1813 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CGATT;
1814 dummy.bat_dummy = 0xFF;
1815 cmd.params.ptr_que_plus_cgatt = &dummy;
1816
1817 bat_send(ati_bat_get_client(srcId), &cmd);
1818
1819 return(ATI_EXCT);
1820 }
1821 #else
1822
1823 ret = qAT_PlusCGATT((T_ACI_CMD_SRC)srcId, &state);
1824 if (ret EQ AT_CMPL)
1825 {
1826 sprintf(g_sa,"%s%d", me, state);
1827 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1828 }
1829 else
1830 {
1831 cmdCmeError(CME_ERR_Unknown);
1832 return (ATI_FAIL);
1833 }
1834
1835 return (map_aci_2_ati_rslt(ret));
1836 #endif
1837 }
1838
1839
1840 /*
1841 +--------------------------------------------------------------------+
1842 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
1843 | STATE : finished ROUTINE : atPlusCGCLASS |
1844 +--------------------------------------------------------------------+
1845
1846 PURPOSE : +CGCLASS command (GPRS class change)
1847 */
1848
1849 GLOBAL T_ATI_RSLT setatPlusCGCLASS (char *cl, UBYTE srcId)
1850 {
1851 T_ACI_RETURN ret = AT_FAIL;
1852 T_CGCLASS_CLASS m_class = CGCLASS_CLASS_OMITTED;
1853 char test_class[3]="";
1854 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1855
1856 TRACE_FUNCTION("atPlusCGCLASS ()");
1857
1858 cl = parse (cl,"s", (LONG)3, &test_class );
1859
1860 switch (*test_class)
1861 {
1862 case 'A':
1863 break;
1864 case 'B':
1865 m_class = CGCLASS_CLASS_B;
1866 break;
1867 case 'C':
1868 switch(*(test_class + 1))
1869 {
1870 case 'G':
1871 m_class = CGCLASS_CLASS_CG;
1872 break;
1873 case 'C':
1874 m_class = CGCLASS_CLASS_CC;
1875 break;
1876 default:
1877 break;
1878 }
1879 break;
1880 default:
1881 break;
1882 }
1883
1884 if ( !cl OR m_class EQ CGCLASS_CLASS_OMITTED )
1885 {
1886 cmdCmeError(CME_ERR_OpNotAllow);
1887 return (ATI_FAIL);
1888 }
1889 #ifdef FF_ATI_BAT
1890
1891 {
1892 T_BAT_cmd_send cmd;
1893 T_BAT_cmd_set_plus_cgclass cgclass;
1894
1895 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGCLASS;
1896 cmd.params.ptr_set_plus_cgclass=&cgclass;
1897
1898 /*
1899 * This relies on T_BAT_mobile_class and T_CGCLASS_CLASS
1900 * being identical.
1901 */
1902 cgclass.mobile_class=(T_BAT_mobile_class)m_class;
1903
1904 bat_send(ati_bat_get_client(srcId), &cmd);
1905
1906 src_params->curAtCmd=AT_CMD_CGCLASS;
1907 return(ATI_EXCT);
1908 }
1909
1910 #else
1911
1912 ret = sAT_PlusCGCLASS ((T_ACI_CMD_SRC)srcId, m_class );
1913 switch (ret)
1914 {
1915 case (AT_CMPL): /*operation completed*/
1916 return (ATI_CMPL);
1917 case (AT_EXCT):
1918 src_params->curAtCmd = AT_CMD_CGCLASS;
1919 return (ATI_EXCT);
1920 default:
1921 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
1922 return (ATI_FAIL);
1923 }
1924
1925 #endif /*FF_ATI_BAT*/
1926 }
1927
1928 GLOBAL T_ATI_RSLT queatPlusCGCLASS (char *cl, UBYTE srcId)
1929 {
1930 //#ifndef FF_ATI_BAT
1931 char *me="+CGCLASS: ";
1932 char *classes[] = {"A","B","CG","CC"};
1933 T_ACI_RETURN ret = AT_FAIL;
1934 T_CGCLASS_CLASS m_class = CGCLASS_CLASS_OMITTED;
1935 //#endif
1936
1937 TRACE_FUNCTION("queatPlusCGCLASS ()");
1938 #ifdef FF_ATI_BAT
1939 {
1940 T_BAT_cmd_send cmd;
1941 T_BAT_no_parameter dummy;
1942
1943 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CGCLASS;
1944 dummy.bat_dummy = 0xFF;
1945 cmd.params.ptr_que_plus_cgclass = &dummy;
1946 bat_send(ati_bat_get_client(srcId), &cmd);
1947 return(ATI_EXCT);
1948 }
1949 #else
1950
1951 ret = qAT_PlusCGCLASS((T_ACI_CMD_SRC)srcId, &m_class);
1952 if (ret EQ AT_CMPL)
1953 {
1954 sprintf(g_sa,"%s\"%s\"", me, classes[m_class]);
1955 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
1956 }
1957 else
1958 {
1959 cmdCmeError(CME_ERR_Unknown);
1960 return (ATI_FAIL);
1961 }
1962
1963 return (map_aci_2_ati_rslt(ret));
1964
1965 #endif /*FF_ATI_BAT*/
1966 }
1967
1968
1969 /*
1970 +--------------------------------------------------------------------+
1971 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
1972 | STATE : finnished ROUTINE : atPlusCGACT |
1973 +--------------------------------------------------------------------+
1974
1975 PURPOSE : +CGACT command (context activation/deactivation)
1976 */
1977
1978 GLOBAL T_ATI_RSLT setatPlusCGACT (char *cl, UBYTE srcId)
1979 {
1980 char *end;
1981 T_ACI_RETURN ret = AT_FAIL;
1982 T_CGACT_STATE state = CGACT_STATE_OMITTED;
1983 U8 count = 0;
1984 U8 cid;
1985 SHORT cid_array[PDP_CONTEXT_CID_MAX + 1];
1986 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
1987
1988 TRACE_FUNCTION("setatPlusCGACT ()");
1989
1990 end = cl;
1991
1992 if ( *cl NEQ ',' )
1993 state = (T_CGACT_STATE) strtol(cl, &end, 10);
1994
1995 while ( *end EQ ',' )
1996 {
1997 cl = end; /* advace to the next delimiter */
1998 cl ++; /* skip the delimiter */
1999 cid = PDP_CONTEXT_CID_INVALID;
2000
2001 cid = (U8) strtol (cl, &end, 10);
2002
2003 if (cid < PDP_CONTEXT_CID_MIN OR cid > PDP_CONTEXT_CID_MAX OR count > PDP_CONTEXT_CID_MAX)
2004 {
2005 cmdCmeError(CME_ERR_OpNotAllow);
2006 return (ATI_FAIL);
2007 }
2008 cid_array[count] = cid;
2009 count ++;
2010 }
2011
2012 if(count<12)
2013 {
2014 cid_array[count] = PDP_CONTEXT_CID_INVALID;
2015 }
2016 cl = end;
2017
2018 #ifdef FF_ATI_BAT
2019 {
2020 T_BAT_cmd_send cmd;
2021 T_BAT_cmd_set_plus_cgact cgact;
2022 UBYTE n;
2023
2024 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGACT;
2025 cmd.params.ptr_set_plus_cgact=&cgact;
2026
2027 /*
2028 * This relies on T_BAT_plus_cgact_state and T_CGACT_STATE
2029 * being identical.
2030 */
2031 cgact.state=(T_BAT_plus_cgact_state)state;
2032
2033 for (n=0;((n<count) AND (n<BAT_MAX_PDP_CID));n++)
2034 cgact.cid[n]=(T_BAT_pdp_cid)cid_array[n];
2035
2036 cgact.c_cid=(U8)n;
2037
2038 bat_send(ati_bat_get_client(srcId), &cmd);
2039
2040 src_params->curAtCmd=AT_CMD_CGACT;
2041 return(ATI_EXCT);
2042 }
2043
2044 #else
2045
2046 /* (De) Activate necessary contexts */
2047 ret = sAT_PlusCGACT ((T_ACI_CMD_SRC)srcId, state, cid_array );
2048 switch (ret)
2049 {
2050 case (AT_CMPL): /*operation completed*/
2051 return (ATI_CMPL);
2052 case (AT_EXCT):
2053 src_params->curAtCmd = AT_CMD_CGACT;
2054 return (ATI_EXCT);
2055 default:
2056 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
2057 return (ATI_FAIL);
2058 }
2059
2060 #endif /*FF_ATI_BAT*/
2061 }
2062
2063 GLOBAL T_ATI_RSLT queatPlusCGACT (char *cl, UBYTE srcId)
2064 {
2065 #ifndef FF_ATI_BAT
2066 char *me="+CGACT: ";
2067 T_ACI_RETURN ret = AT_FAIL;
2068 U8 count = 0;
2069 SHORT cid_array[PDP_CONTEXT_CID_MAX + 1];
2070 BOOL states[PDP_CONTEXT_CID_MAX + 1];
2071 #endif
2072
2073 TRACE_FUNCTION("queatPlusCGACT ()");
2074
2075 #ifdef FF_ATI_BAT
2076 {
2077 T_BAT_cmd_send cmd;
2078 T_BAT_no_parameter dummy;
2079
2080 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CGACT;
2081 dummy.bat_dummy = 0xFF;
2082 cmd.params.ptr_que_plus_cgact = &dummy;
2083 bat_send(ati_bat_get_client(srcId), &cmd);
2084 return(ATI_EXCT);
2085 }
2086 #else
2087
2088 ret=qAT_PlusCGACT((T_ACI_CMD_SRC)srcId, states, cid_array);
2089 if (ret EQ AT_CMPL)
2090 {
2091 for( count = 0; count < PDP_CONTEXT_CID_MAX AND cid_array[count] NEQ PDP_CONTEXT_CID_INVALID; count++ )
2092 {
2093 sprintf(g_sa,"%s%hd,%d", me, cid_array[count], states[count] EQ TRUE? 1 : 0);
2094 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
2095 }
2096 }
2097 else
2098 {
2099 cmdCmeError(CME_ERR_Unknown);
2100 return (ATI_FAIL);
2101 }
2102
2103 return (map_aci_2_ati_rslt(ret));
2104
2105 #endif /*FF_ATI_BAT*/
2106 }
2107
2108
2109 /*
2110 +--------------------------------------------------------------------+
2111 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
2112 | STATE : finnished ROUTINE : atPlusCGDATA |
2113 +--------------------------------------------------------------------+
2114
2115 PURPOSE : +CGDATA command (data connect)
2116 */
2117
2118 GLOBAL T_ATI_RSLT setatPlusCGDATA (char *cl, UBYTE srcId)
2119 {
2120 char L2P[MAX_L2P_LENGTH] = "", *end;
2121 T_ACI_RETURN ret = AT_FAIL;
2122 U8 count = 0, stop = 1;
2123 U8 cid_array[PDP_CONTEXT_CID_MAX];
2124 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
2125
2126 TRACE_FUNCTION("setatPlusCGDATA ()");
2127
2128 memset( &cid_array, PDP_CONTEXT_CID_INVALID, sizeof(cid_array) );
2129
2130 switch ( *cl )
2131 {
2132 case ',':
2133 /* the L2P is unspecified */
2134 *L2P = 0;
2135 break;
2136 case '\"':
2137 cl++;
2138 while (*cl AND stop)
2139 {
2140 if ( *cl NEQ '\"' AND count < MAX_L2P_LENGTH - 1 )
2141 {
2142 L2P[count] = *cl;
2143 count ++;
2144 cl ++;
2145 }
2146 else
2147 {
2148 L2P[count] = 0;
2149 stop = 0;
2150 }
2151 }
2152
2153 if ( *cl NEQ '\"' )
2154 { /* Bad user input, abort */
2155 cmdCmeError(CME_ERR_OpNotAllow);
2156 return (ATI_FAIL);
2157 }
2158
2159 cl++;
2160 break;
2161 case 0:
2162 break;
2163 default:
2164 /* Bad user input, abort */
2165 cmdCmeError(CME_ERR_OpNotAllow);
2166 return (ATI_FAIL);
2167 }
2168
2169 end = cl;
2170 count = 0;
2171 while ( *end EQ ',' )
2172 {
2173 cl = end;
2174 cl ++;
2175
2176 cid_array[count] = (U8) strtol (cl, &end, 10);
2177
2178 if ( count >= PDP_CONTEXT_CID_MAX )
2179 {
2180 cmdCmeError(CME_ERR_OpNotAllow);
2181 return (ATI_FAIL);
2182 }
2183 count ++;
2184 }
2185
2186 cl = end;
2187 #ifdef FF_ATI_BAT
2188
2189 {
2190 T_BAT_cmd_send cmd;
2191 T_BAT_cmd_set_plus_cgdata cgdata;
2192 UBYTE n;
2193 UBYTE len;
2194
2195 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGDATA;
2196 cmd.params.ptr_set_plus_cgdata=&cgdata;
2197
2198 cgdata.v_cid=FALSE;
2199
2200 if (count)
2201 {
2202 for (n=0;((n<count) AND (n<BAT_MAX_PDP_CID));n++)
2203 cgdata.cid[n]=(T_BAT_pdp_cid)cid_array[n];
2204
2205 cgdata.c_cid=(U8)n;
2206 cgdata.v_cid=TRUE;
2207 }
2208
2209 cgdata.v_l2p=FALSE;
2210
2211 if (L2P[0])
2212 {
2213 if ((len=strlen(L2P))<=BAT_MAX_CGDATA_L2P_LEN)
2214 {
2215 cgdata.v_l2p=TRUE;
2216 memcpy(cgdata.l2p,L2P,len);
2217 cgdata.c_l2p=len;
2218 }
2219 }
2220 bat_send(ati_bat_get_client(srcId), &cmd);
2221
2222 src_params->curAtCmd=AT_CMD_CGDATA;
2223 return(ATI_EXCT);
2224 }
2225
2226 #else
2227
2228
2229 /*
2230 * if no cid is given or if there is no matching context definition
2231 * the function sAT_PlusCGDATA will process this
2232 */
2233
2234 /* establish communication between the TE and the network */
2235 ret = sAT_PlusCGDATA ((T_ACI_CMD_SRC)srcId, L2P, cid_array );
2236 switch (ret)
2237 {
2238 case (AT_CMPL): /*operation completed*/
2239 return (ATI_CMPL);
2240 case (AT_EXCT):
2241 cmdErrStr = NULL;
2242 src_params->curAtCmd = AT_CMD_CGDATA;
2243 return (ATI_EXCT);
2244 default:
2245 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
2246 return (ATI_FAIL);
2247 }
2248 #endif /*FF_ATI_BAT*/
2249 }
2250
2251 /*
2252 +--------------------------------------------------------------------+
2253 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
2254 | STATE : code ROUTINE : atPlusCGPADDR |
2255 +--------------------------------------------------------------------+
2256
2257 PURPOSE : +CGPADDR command (show PDP addresses)
2258 active command returns a list of last used PDP addresses
2259 for specified cids. If unspecified, returns list for all
2260 defined cids.
2261 */
2262
2263 GLOBAL T_ATI_RSLT setatPlusCGPADDR (char *cl, UBYTE srcId)
2264 {
2265 char *me = "+CGPADDR: ";
2266 char *end;
2267
2268 U8 index = 0;
2269 #ifndef FF_ATI_BAT
2270 T_ACI_RETURN ret;
2271 T_NAS_ip pdp_addresses[PDP_CONTEXT_CID_MAX];
2272 #endif
2273 SHORT cid_array[PDP_CONTEXT_CID_MAX + 1];
2274
2275 TRACE_FUNCTION("setatPlusCGPADDR ()");
2276
2277 do
2278 {
2279 cid_array[index] = (U8) strtol (cl, &end, 10);
2280
2281 if (cid_array[index] EQ 0x00)
2282 cid_array[index] = PDP_CONTEXT_CID_OMITTED;
2283
2284 index++;
2285 cl = end;
2286 if ( *cl EQ ',' )
2287 cl++;
2288 }
2289 while ( *end EQ ',' );
2290
2291 cid_array[index] = PDP_CONTEXT_CID_INVALID;
2292 cl = end;
2293
2294 index = 0;
2295
2296 #ifdef FF_ATI_BAT
2297 {
2298 T_BAT_cmd_send cmd;
2299
2300 T_BAT_cmd_set_plus_cgpaddr cgpaddr;
2301 UBYTE n;
2302
2303 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGPADDR;
2304 cmd.params.ptr_set_plus_cgpaddr = &cgpaddr;
2305
2306 cgpaddr.c_cid = (U8)index;
2307
2308 if(cgpaddr.c_cid > 0)
2309 {
2310 for (n=0;((n<cgpaddr.c_cid) AND (n<BAT_MAX_PDP_CID));n++)
2311 {
2312 cgpaddr.cid[n]=(T_BAT_pdp_cid)cid_array[n];
2313 }
2314
2315 cgpaddr.c_cid=(U8)n;
2316 }
2317
2318 bat_send(ati_bat_get_client(srcId), &cmd);
2319
2320 return(ATI_EXCT);
2321 }
2322 #else
2323 /* return a list of PDP addresses for the specified context identifier */
2324 ret = sAT_PlusCGPADDR ((T_ACI_CMD_SRC)srcId, cid_array, pdp_addresses );
2325
2326 if( ret EQ AT_CMPL )
2327 {
2328 while( cid_array[index] NEQ PDP_CONTEXT_CID_INVALID )
2329 {
2330 if (index NEQ 0)
2331 {//to put a , between pdp adresses, if more than one exists.
2332 sprintf( g_sa, ",");
2333 }
2334 switch( pdp_addresses[index].ctrl_ip_address )
2335 {
2336 case NAS_is_ip_not_present:
2337 sprintf( g_sa, "%s%hd", me, cid_array[index] );
2338 break;
2339
2340 case NAS_is_ipv4:
2341 sprintf( g_sa, "%s%hd,\"%d.%d.%d.%d\"",
2342 me,
2343 cid_array[index],
2344 pdp_addresses[index].ip_address.ipv4_addr.a4[0],
2345 pdp_addresses[index].ip_address.ipv4_addr.a4[1],
2346 pdp_addresses[index].ip_address.ipv4_addr.a4[2],
2347 pdp_addresses[index].ip_address.ipv4_addr.a4[3] );
2348 break;
2349
2350 case NAS_is_ipv6:
2351 sprintf( g_sa, "%s%hd,\"%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d\"",
2352 me,
2353 cid_array[index],
2354 pdp_addresses[index].ip_address.ipv6_addr.a6[ 0],
2355 pdp_addresses[index].ip_address.ipv6_addr.a6[ 1],
2356 pdp_addresses[index].ip_address.ipv6_addr.a6[ 2],
2357 pdp_addresses[index].ip_address.ipv6_addr.a6[ 3],
2358 pdp_addresses[index].ip_address.ipv6_addr.a6[ 4],
2359 pdp_addresses[index].ip_address.ipv6_addr.a6[ 5],
2360 pdp_addresses[index].ip_address.ipv6_addr.a6[ 6],
2361 pdp_addresses[index].ip_address.ipv6_addr.a6[ 7],
2362 pdp_addresses[index].ip_address.ipv6_addr.a6[ 8],
2363 pdp_addresses[index].ip_address.ipv6_addr.a6[ 9],
2364 pdp_addresses[index].ip_address.ipv6_addr.a6[10],
2365 pdp_addresses[index].ip_address.ipv6_addr.a6[11],
2366 pdp_addresses[index].ip_address.ipv6_addr.a6[12],
2367 pdp_addresses[index].ip_address.ipv6_addr.a6[13],
2368 pdp_addresses[index].ip_address.ipv6_addr.a6[14],
2369 pdp_addresses[index].ip_address.ipv6_addr.a6[15] );
2370 break;
2371 }
2372
2373 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
2374 index ++;
2375 }
2376
2377 return (ATI_CMPL);
2378 }
2379 else
2380 {
2381 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
2382 return (ATI_FAIL);
2383 }
2384 #endif /*FF_ATI_BAT*/
2385 }
2386
2387
2388
2389
2390
2391
2392 GLOBAL T_ATI_RSLT tesatPlusCGPADDR (char *cl, UBYTE srcId)
2393 {
2394 #ifndef FF_ATI_BAT
2395 char *me="+CGPADDR: ";
2396 T_ACI_RETURN ret;
2397 U8 index = 0;
2398 U8 cid_array[PDP_CONTEXT_CID_MAX + 1];
2399 int pos = 0;
2400 #endif
2401
2402 TRACE_FUNCTION("tesatPlusCGPADDR ()");
2403 #ifdef FF_ATI_BAT
2404 {
2405 T_BAT_cmd_send cmd;
2406 T_BAT_no_parameter dummy;
2407
2408 cmd.ctrl_params = BAT_CMD_TST_PLUS_CGPADDR;
2409 dummy.bat_dummy = 0xFF;
2410 cmd.params.ptr_tst_plus_cgpaddr = &dummy;
2411 bat_send(ati_bat_get_client(srcId), &cmd);
2412 return(ATI_EXCT);
2413 }
2414 #else
2415
2416 /* return a list of defined context identifier */
2417 ret = tAT_PlusCGPADDR ((T_ACI_CMD_SRC)srcId, cid_array );
2418 switch (ret)
2419 {
2420 case (AT_CMPL): /*operation completed*/
2421 pos = sprintf(g_sa,"%s(", me);
2422 while( cid_array[index] NEQ PDP_CONTEXT_CID_INVALID )
2423 {
2424 if( index NEQ 0 )
2425 {
2426 g_sa[pos] = ','; pos++;
2427 }
2428 pos += sprintf(g_sa + pos,"%hd", cid_array[index]);
2429 index ++;
2430 }
2431
2432 g_sa[pos] = ')'; pos++;
2433 g_sa[pos] = 0;
2434 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
2435 return (ATI_CMPL);
2436
2437 default:
2438 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
2439 return (ATI_FAIL);
2440 }
2441 #endif /*FF_ATI_BAT*/
2442 }
2443
2444 /*
2445 +--------------------------------------------------------------------+
2446 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
2447 | STATE : finnished ROUTINE : atPlusCGAUTO |
2448 +--------------------------------------------------------------------+
2449
2450 PURPOSE : +CGAUTO command (auto answer/modem compatibility control)
2451 */
2452
2453 GLOBAL T_ATI_RSLT setatPlusCGAUTO (char *cl, UBYTE srcId)
2454 {
2455 T_ACI_RETURN ret = AT_FAIL;
2456 T_CGAUTO_N n = CGAUTO_N_OMITTED; /* Invalid range value to detect an empty parameter */
2457 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
2458
2459 TRACE_FUNCTION("setatPlusCGAUTO ()");
2460
2461 cl = parse (cl,"d", &n );
2462 ret = sAT_PlusCGAUTO ((T_ACI_CMD_SRC)srcId, n );
2463 switch (ret)
2464 {
2465 case (AT_CMPL): /*operation completed*/
2466 at.rngPrms.srcID_CGAUTO = srcId;
2467 return (ATI_CMPL);
2468 case (AT_EXCT):
2469 src_params->curAtCmd = AT_CMD_CGATT;
2470 at.rngPrms.srcID_CGAUTO = srcId;
2471 return (ATI_EXCT);
2472 default:
2473 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
2474 return (ATI_FAIL);
2475 }
2476 }
2477
2478 GLOBAL T_ATI_RSLT queatPlusCGAUTO (char *cl, UBYTE srcId)
2479 {
2480 char *me="+CGAUTO: ";
2481 T_ACI_RETURN ret = AT_FAIL;
2482 T_CGAUTO_N n = CGAUTO_N_OMITTED; /* Invalid range value to detect an empty parameter */
2483
2484 TRACE_FUNCTION("queatPlusCGAUTO ()");
2485
2486 ret = qAT_PlusCGAUTO((T_ACI_CMD_SRC)srcId, &n);
2487 if (ret EQ AT_CMPL)
2488 {
2489 sprintf(g_sa,"%s%hd", me, n);
2490 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
2491 }
2492 else
2493 {
2494 cmdCmeError(CME_ERR_Unknown);
2495 return (ATI_FAIL);
2496 }
2497
2498 return (map_aci_2_ati_rslt(ret));
2499 }
2500
2501 /*
2502 +--------------------------------------------------------------------+
2503 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
2504 | STATE : code ROUTINE : atPlusCGANS |
2505 +--------------------------------------------------------------------+
2506
2507 PURPOSE : +CGANS command (answer NW context req)
2508 */
2509
2510 GLOBAL T_ATI_RSLT setatPlusCGANS (char *cl, UBYTE srcId)
2511 {
2512 char L2P[MAX_L2P_LENGTH] = "";
2513 char *end;
2514 T_ACI_RETURN ret = AT_FAIL;
2515 U8 response;
2516 U8 cid = PDP_CONTEXT_CID_OMITTED;
2517 U8 count = 0;
2518 U8 stop = 1;
2519 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
2520
2521 TRACE_FUNCTION("setatPlusCGANS ()");
2522
2523 /*
2524 * Process parameters
2525 */
2526
2527 response = (U8) strtol (cl, &end, 10);
2528 cl = end;
2529
2530 if( *cl EQ ',' )
2531 {
2532 cl++;
2533 switch ( *cl )
2534 {
2535 case ',':
2536 /* the L2P is unspecified/omitted */
2537 *L2P = 0;
2538 break;
2539 case '\"':
2540 cl++;
2541 while (*cl AND stop)
2542 {
2543 if ( *cl NEQ '\"' AND count < MAX_L2P_LENGTH - 1 )
2544 {
2545 L2P[count] = *cl;
2546 count ++;
2547 cl ++;
2548 }
2549 else
2550 {
2551 L2P[count] = 0;
2552 stop = 0;
2553 }
2554 }
2555
2556 if ( *cl NEQ '\"' )
2557 { /* Bad user input, abort */
2558 cmdCmeError(CME_ERR_OpNotAllow);
2559 return (ATI_FAIL);
2560 }
2561
2562 cl++;
2563 break;
2564 default:
2565 /* Bad user input, abort */
2566 cmdCmeError(CME_ERR_OpNotAllow);
2567 return (ATI_FAIL);
2568 }
2569
2570 if( *cl EQ ',' )
2571 {
2572 cl++; /* Remove the "," and convert the cid */
2573 cid = ( U8 ) strtol( cl, &end, 10 );
2574 cl = end;
2575 }
2576 }
2577
2578 #ifdef FF_ATI_BAT
2579 {
2580 T_BAT_cmd_send cmd;
2581 T_BAT_cmd_set_plus_cgans cgans;
2582 UBYTE len;
2583
2584 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGANS;
2585 cmd.params.ptr_set_plus_cgans=&cgans;
2586
2587 cgans.cid=(T_BAT_pdp_cid)cid;
2588
2589 /*
2590 * This relies on T_BAT_plus_cgans_response and T_CGANS_RESPONSE
2591 * being identical.
2592 */
2593 cgans.response=(T_BAT_plus_cgans_response)response;
2594
2595 len=strlen(L2P);
2596
2597 cgans.v_l2p=FALSE;
2598
2599 if ((len) AND (len<=BAT_MAX_CGANS_L2P_LEN))
2600 {
2601 memcpy(cgans.l2p,L2P,len);
2602 cgans.c_l2p=(U8)len;
2603 cgans.v_l2p=TRUE;
2604 }
2605 bat_send(ati_bat_get_client(srcId), &cmd);
2606
2607 src_params->curAtCmd=AT_CMD_CGANS;
2608
2609 if ((at.rngPrms.isRng EQ TRUE) AND (at.rngPrms.mode EQ CRING_MOD_Gprs))
2610 ati_stop_ring();
2611
2612 return(ATI_EXCT);
2613 }
2614
2615 #else
2616
2617
2618 /* return a list of PDP addresses for the specified context identifier */
2619 ret = sAT_PlusCGANS ((T_ACI_CMD_SRC)srcId, response, L2P, cid );
2620 switch (ret)
2621 {
2622 case (AT_CMPL): /*operation completed*/
2623 return (ATI_CMPL);
2624
2625 case (AT_EXCT):
2626 src_params->curAtCmd = AT_CMD_CGANS;
2627 if ( at.rngPrms.isRng EQ TRUE AND
2628 at.rngPrms.mode EQ CRING_MOD_Gprs )
2629 {
2630 ati_stop_ring();
2631 }
2632 return (ATI_EXCT);
2633
2634 default:
2635 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
2636 return (ATI_FAIL);
2637 }
2638 #endif /*FF_ATI_BAT*/
2639 }
2640
2641 /*
2642 +--------------------------------------------------------------------+
2643 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
2644 | STATE : code ROUTINE : atPlusCGEREP |
2645 +--------------------------------------------------------------------+
2646
2647 PURPOSE : +CGEREP command
2648 */
2649
2650 GLOBAL T_ATI_RSLT setatPlusCGEREP (char *cl, UBYTE srcId)
2651 {
2652 T_ACI_RETURN ret;
2653 T_CGEREP_MODE mode = CGEREP_MODE_OMITTED;
2654 T_CGEREP_BFR bfr = CGEREP_BFR_OMITTED;
2655 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
2656
2657 TRACE_FUNCTION("setatPlusCGEREP ()");
2658
2659 cl=parse(cl,"dd",&mode, &bfr);
2660
2661 ret = sAT_PlusCGEREP ( (T_ACI_CMD_SRC)srcId, mode, bfr );
2662 switch (ret)
2663 {
2664 case (AT_CMPL): /*operation completed*/
2665 return (ATI_CMPL);
2666 case (AT_EXCT):
2667 src_params->curAtCmd = AT_CMD_CGEREP;
2668 return (ATI_EXCT);
2669 default:
2670 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
2671 return (ATI_FAIL);
2672 }
2673 }
2674
2675 GLOBAL T_ATI_RSLT queatPlusCGEREP (char *cl, UBYTE srcId)
2676 {
2677 char *me="+CGEREP: ";
2678 T_ACI_RETURN ret;
2679 T_CGEREP_MODE mode = CGEREP_MODE_OMITTED;
2680 T_CGEREP_BFR bfr = CGEREP_BFR_OMITTED;
2681
2682 TRACE_FUNCTION("queatPlusCGEREP ()");
2683
2684 ret=qAT_PlusCGEREP((T_ACI_CMD_SRC)srcId, &mode, &bfr);
2685 if (ret EQ AT_CMPL)
2686 {
2687 sprintf(g_sa,"%s%d,%d", me, mode, bfr);
2688 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
2689 }
2690 else
2691 {
2692 cmdCmeError(CME_ERR_Unknown);
2693 return (ATI_FAIL);
2694 }
2695
2696 return (map_aci_2_ati_rslt(ret));
2697 }
2698
2699 /*
2700 +--------------------------------------------------------------------+
2701 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
2702 | STATE : code ROUTINE : atPercentCGEREP |
2703 +--------------------------------------------------------------------+
2704
2705 PURPOSE : %CGEREP command
2706 */
2707
2708 GLOBAL T_ATI_RSLT setatPercentCGEREP (char *cl, UBYTE srcId)
2709 {
2710 TRACE_FUNCTION("setatPercentCGEREP ()");
2711
2712 switch( *cl )
2713 {
2714 case '0':
2715 ati_user_output_cfg[srcId].Percent_CGEREP_stat = 0;
2716 return (ATI_CMPL);
2717
2718 case '1':
2719 ati_user_output_cfg[srcId].Percent_CGEREP_stat = 1;
2720 return (ATI_CMPL);
2721
2722 default:
2723 cmdCmeError(CME_ERR_OpNotAllow);
2724 return (ATI_FAIL);
2725 }
2726 }
2727
2728 GLOBAL T_ATI_RSLT queatPercentCGEREP (char *cl, UBYTE srcId)
2729 {
2730 char *me="%CGEREP: ";
2731 UBYTE mode;
2732
2733 TRACE_FUNCTION("queatPercentCGEREP ()");
2734
2735 mode = ati_user_output_cfg[srcId].Percent_CGEREP_stat;
2736
2737 sprintf(g_sa,"%s%d", me, mode);
2738 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
2739
2740 return (ATI_CMPL);
2741 }
2742
2743
2744 /*
2745 +--------------------------------------------------------------------+
2746 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
2747 | STATE : code ROUTINE : setatPlusCGREG |
2748 +--------------------------------------------------------------------+
2749
2750 PURPOSE : +CGREG command
2751 */
2752
2753 GLOBAL T_ATI_RSLT setatPlusCGREG (char *cl, UBYTE srcId)
2754 {
2755 T_ATI_CREG_MOD mode=CREG_MOD_OFF;
2756
2757 TRACE_FUNCTION("setatPlusCGREG()");
2758
2759 cl=parse(cl,"d",&mode);
2760
2761 switch(mode)
2762 {
2763 case CREG_MOD_OFF:
2764 case CREG_MOD_ON:
2765 case CREG_MOD_LOC_INF_ON:
2766 /* user wants to set mode: reset CREG related ATI parameters */
2767 ati_creg_init(srcId, PlusCGREG_CMD);
2768 ati_gprs_user_output_cfg[srcId].plus_cgreg.mod_lac_cid.pres_mode = mode;
2769 return ATI_CMPL;
2770
2771 default:
2772 cmdCmeError(CME_ERR_OpNotAllow);
2773 return ATI_FAIL;
2774 }
2775 }
2776
2777 GLOBAL T_ATI_RSLT queatPlusCGREG (char *cl, UBYTE srcId)
2778 {
2779 #ifndef FF_ATI_BAT
2780 T_CGREG_STAT stat;
2781 USHORT lac, cid;
2782 T_ATI_CREG_MOD mode;
2783 short pos;
2784 #endif
2785
2786 TRACE_FUNCTION("queatPlusCGREG()");
2787
2788 #ifdef FF_ATI_BAT
2789 {
2790 T_BAT_cmd_send cmd;
2791 T_BAT_no_parameter dummy;
2792
2793 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CGREG;
2794 dummy.bat_dummy = 0xFF;
2795 cmd.params.ptr_que_plus_cgreg = &dummy;
2796 bat_send(ati_bat_get_client(srcId), &cmd);
2797 return(ATI_EXCT);
2798 }
2799 #else
2800
2801 mode = ati_gprs_user_output_cfg[srcId].plus_cgreg.mod_lac_cid.pres_mode;
2802
2803 if (qAT_PlusCGREG((T_ACI_CMD_SRC)srcId, &stat, &lac, &cid) NEQ AT_CMPL)
2804 {
2805 cmdCmeError(CME_ERR_Unknown);
2806 return ATI_FAIL;
2807 }
2808
2809 pos = sprintf(g_sa, "+CGREG: %d,%d", mode, stat);
2810
2811 if(mode EQ CREG_MOD_LOC_INF_ON)
2812 {
2813 if(stat EQ CGREG_STAT_REG_HOME OR stat EQ CGREG_STAT_REG_ROAM)
2814 sprintf(g_sa+pos, ",\"%04X\",\"%04X\"", lac, cid);
2815 }
2816
2817 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
2818 return ATI_CMPL;
2819 #endif /*FF_ATI_BAT*/
2820 }
2821
2822
2823 /*
2824 +--------------------------------------------------------------------+
2825 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
2826 | STATE : code ROUTINE : setatPercentCGREG |
2827 +--------------------------------------------------------------------+
2828
2829 PURPOSE : %CGREG command
2830 */
2831
2832 GLOBAL T_ATI_RSLT setatPercentCGREG (char *cl, UBYTE srcId)
2833 {
2834 T_ATI_CREG_MOD mode=CREG_MOD_OFF;
2835
2836 TRACE_FUNCTION("setatPercentCGREG()");
2837
2838 cl=parse(cl,"d",&mode);
2839
2840 switch(mode)
2841 {
2842 case CREG_MOD_OFF:
2843 case CREG_MOD_ON:
2844 case CREG_MOD_LOC_INF_ON:
2845 case CREG_MOD_LOC_INF_ON_CTXACT:
2846 /* user wants to set mode: reset CREG related ATI parameters */
2847 ati_creg_init(srcId, PercentCGREG_CMD);
2848 ati_gprs_user_output_cfg[srcId].percent_cgreg.mod_lac_cid.pres_mode = mode;
2849 return ATI_CMPL;
2850
2851 default:
2852 cmdCmeError(CME_ERR_OpNotAllow);
2853 return ATI_FAIL;
2854 }
2855 }
2856
2857 GLOBAL T_ATI_RSLT queatPercentCGREG (char *cl, UBYTE srcId)
2858 {
2859 #ifndef FF_ATI_BAT
2860 T_P_CGREG_STAT stat;
2861 USHORT lac, cid;
2862 T_ATI_CREG_MOD mode;
2863 SHORT pos;
2864 #endif
2865
2866 TRACE_FUNCTION("queatPercentCGREG()");
2867 #ifdef FF_ATI_BAT
2868 {
2869 T_BAT_cmd_send cmd;
2870 T_BAT_no_parameter dummy;
2871
2872 cmd.ctrl_params = BAT_CMD_QUE_PERCENT_CGREG;
2873 dummy.bat_dummy = 0xFF;
2874 cmd.params.ptr_que_plus_cgreg = &dummy;
2875
2876 bat_send(ati_bat_get_client(srcId), &cmd);
2877 return(ATI_EXCT);
2878 }
2879 #else
2880
2881 mode = ati_gprs_user_output_cfg[srcId].percent_cgreg.mod_lac_cid.pres_mode;
2882
2883 if (qAT_PercentCGREG((T_ACI_CMD_SRC)srcId, &stat, &lac, &cid) NEQ AT_CMPL)
2884 {
2885 cmdCmeError(CME_ERR_Unknown);
2886 return ATI_FAIL;
2887 }
2888
2889 pos = sprintf(g_sa,"%s: %d,%d", "%CGREG", mode, stat);
2890
2891 if (mode EQ CREG_MOD_LOC_INF_ON OR mode EQ CREG_MOD_LOC_INF_ON_CTXACT)
2892 {
2893 if (stat EQ P_CGREG_STAT_REG_HOME OR stat EQ P_CGREG_STAT_REG_ROAM)
2894 pos += sprintf(g_sa+pos, ",\"%04X\",\"%04X\"", lac, cid);
2895 else if (mode EQ CREG_MOD_LOC_INF_ON_CTXACT)
2896 pos += sprintf(g_sa+pos, ",,"); /* if CTXACT follows so lac and cid are ommitted */
2897 }
2898
2899 if (mode EQ CREG_MOD_LOC_INF_ON_CTXACT)
2900 sprintf(g_sa+pos, (cmhSM_isContextActive() ? ",1" : ",0"));
2901
2902 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
2903 return ATI_CMPL;
2904 #endif /*FF_ATI_BAT*/
2905 }
2906
2907
2908 /*
2909 +--------------------------------------------------------------------+
2910 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
2911 | STATE : code ROUTINE : atPlusCGSMS |
2912 +--------------------------------------------------------------------+
2913
2914 PURPOSE : +CGSMS command (define MO SMS behaviour)
2915 */
2916
2917 GLOBAL T_ATI_RSLT setatPlusCGSMS (char *cl, UBYTE srcId)
2918 {
2919 #ifndef FF_ATI_BAT
2920 T_ACI_RETURN ret;
2921 #endif
2922 T_CGSMS_SERVICE service = CGSMS_SERVICE_OMITTED; /* Invalid range value to detect an empty parameter */
2923 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
2924
2925 TRACE_FUNCTION("setatPlusCGSMS ()");
2926
2927 cl=parse(cl,"d",&service);
2928 #ifdef FF_ATI_BAT
2929
2930 {
2931 T_BAT_cmd_send cmd;
2932 T_BAT_cmd_set_plus_cgsms cgsms;
2933
2934 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGSMS;
2935 cmd.params.ptr_set_plus_cgsms=&cgsms;
2936
2937 /*
2938 * This relies on T_BAT_plus_cgsms_service and T_CGSMS_SERVICE
2939 * being identical.
2940 */
2941 cgsms.service=(T_BAT_plus_cgsms_service)service;
2942
2943 bat_send(ati_bat_get_client(srcId), &cmd);
2944
2945 src_params->curAtCmd=AT_CMD_CGSMS;
2946 return(ATI_EXCT);
2947 }
2948
2949 #else
2950 if( !cl )
2951 {
2952 cmdCmeError(CME_ERR_OpNotAllow);
2953 return (ATI_FAIL);
2954 }
2955
2956 ret = sAT_PlusCGSMS ( (T_ACI_CMD_SRC)srcId, service );
2957 switch (ret)
2958 {
2959 case (AT_CMPL): /*operation completed*/
2960 return (ATI_CMPL);
2961 case (AT_EXCT):
2962 src_params->curAtCmd = AT_CMD_CGSMS;
2963 return (ATI_EXCT);
2964 default:
2965 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
2966 return (ATI_FAIL);
2967 }
2968 #endif /*FF_ATI_BAT*/
2969 }
2970
2971 GLOBAL T_ATI_RSLT queatPlusCGSMS (char *cl, UBYTE srcId)
2972 {
2973 #ifndef FF_ATI_BAT
2974 char *me="+CGSMS: ";
2975 T_ACI_RETURN ret;
2976 T_CGSMS_SERVICE service = CGSMS_SERVICE_OMITTED; /* Invalid range value to detect an empty parameter */
2977 #endif
2978
2979 TRACE_FUNCTION("queatPlusCGSMS ()");
2980 #ifdef FF_ATI_BAT
2981 {
2982 T_BAT_cmd_send cmd;
2983 T_BAT_no_parameter dummy;
2984
2985 cmd.ctrl_params = BAT_CMD_QUE_PLUS_CGSMS;
2986 dummy.bat_dummy = 0xFF;
2987 cmd.params.ptr_que_plus_cgsms = &dummy;
2988 bat_send(ati_bat_get_client(srcId), &cmd);
2989 return(ATI_EXCT);
2990 }
2991 #else
2992
2993 ret = qAT_PlusCGSMS((T_ACI_CMD_SRC)srcId, &service);
2994 if (ret EQ AT_CMPL)
2995 {
2996 sprintf(g_sa,"%s%hd", me, service);
2997 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
2998 return (ATI_CMPL);
2999 }
3000 else
3001 {
3002 cmdCmeError(CME_ERR_Unknown);
3003 return (ATI_FAIL);
3004 }
3005 #endif /*FF_ATI_BAT*/
3006 }
3007
3008 GLOBAL T_ATI_RSLT tesatPlusCGSMS (char *cl, UBYTE srcId)
3009 {
3010 char *me="+CGSMS: ", list[10] = "(0-3)";
3011 T_ACI_RETURN ret;
3012 T_CGSMS_SERVICE service = CGSMS_SERVICE_OMITTED; /* Invalid range value to detect an empty parameter */
3013 SHORT service_list;
3014
3015 TRACE_FUNCTION("tesatPlusCGSMS ()");
3016
3017 ret = tAT_PlusCGSMS ( (T_ACI_CMD_SRC)srcId, &service_list );
3018 switch (ret)
3019 {
3020 case (AT_CMPL): /*operation completed*/
3021 if ( service_list NEQ 15 )
3022 {
3023 list[1] = service EQ 1 ? '0':'1';
3024 list[2] = ')';
3025 list[3] = 0;
3026 }
3027 cl++;
3028 sprintf(g_sa,"%s%s", me, list);
3029 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
3030 return (ATI_CMPL);
3031 default:
3032 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
3033 return (ATI_FAIL);
3034 }
3035 }
3036
3037 /*
3038 +--------------------------------------------------------------------+
3039 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
3040 | STATE : finnished ROUTINE : atGD |
3041 +--------------------------------------------------------------------+
3042
3043 PURPOSE : +ATD command
3044 */
3045
3046 GLOBAL T_ATI_RSLT atGD (char *cl, UBYTE srcId, BOOL *gprs_command)
3047 {
3048
3049 enum
3050 {
3051 ATD_CMD_NOT_VALID = 0,
3052 ATD_CMD_98 = 1,
3053 ATD_CMD_99 = 2
3054 } atd_cmd_type = ATD_CMD_NOT_VALID;
3055
3056
3057 U8 i = 0;
3058
3059 U8 star_count = 0;
3060
3061 char tmp_cmd[40];
3062 char *p_tmp_cmd = tmp_cmd;
3063 char c_addr[MAX_B_SUBSCR_NUM_LEN];
3064 char L2P[MAX_L2P_LENGTH];
3065 U8 cid_array[PDP_CONTEXT_CID_MAX];
3066 U8 cid_length = PDP_CONTEXT_CID_MAX + 1;
3067
3068 #if defined (FF_WAP) OR defined (FF_SAT_E)
3069 BOOL src_flag = FALSE;
3070 #endif
3071
3072 T_PDP_TYPE pdp_type = "IP";
3073 T_PDP_CONTEXT pdp_context;
3074 T_ACI_RETURN ret = AT_FAIL;
3075 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
3076
3077 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
3078
3079 TRACE_FUNCTION("atGD ()");
3080
3081 TRACE_EVENT ("ati_gprs, atGD, start");
3082 //TRACE_EVENT (cl);
3083
3084 memset( L2P, 0, sizeof( L2P ) );
3085 memset( cid_array, PDP_CONTEXT_CID_INVALID, sizeof( cid_array ) );
3086 cid_array[0] = PDP_CONTEXT_CID_OMITTED;
3087
3088 memset( tmp_cmd, 0, sizeof(tmp_cmd) );
3089
3090 #if defined (FF_WAP) OR defined (FF_SAT_E)
3091 if( (ati_is_src_type((UBYTE)srcId, ATI_SRC_TYPE_TST) EQ TRUE) OR
3092 (srcId EQ CMD_SRC_LCL) )
3093 {
3094 TRACE_EVENT ("Source Found is LOCAL");
3095 /* if call not yet marked as WAP call, mark it now */
3096 if (Wap_Call)
3097 {
3098 TRACE_EVENT ("ati_gprs, atGD, WAP Call for atd*98# OR atd*99#");
3099 src_flag = TRUE;
3100 }
3101 }
3102 #endif
3103
3104 if (cl EQ NULL)
3105 {
3106 *gprs_command = FALSE;
3107 return (ATI_FAIL);
3108 }
3109
3110 /* ignore modifier */
3111 switch ( *cl )
3112 {
3113 case 'T':
3114 case 't':
3115 case 'P':
3116 case 'p':
3117 if ( *(cl + 1) EQ '*' )
3118 {
3119 cl+=2;
3120 }
3121 else
3122 {
3123 *gprs_command = FALSE;
3124 return (ATI_FAIL);
3125 }
3126 break;
3127
3128 case '*':
3129 cl++;
3130 break;
3131
3132 default:
3133 *gprs_command = FALSE;
3134 return (ATI_FAIL);
3135 }
3136
3137 do
3138 {
3139 switch( *(cl + i) )
3140 {
3141 case '*':
3142 tmp_cmd[i] = ',';
3143 star_count++;
3144 break;
3145
3146 case '#':
3147 tmp_cmd[i] = 0;
3148 break;
3149
3150 default :
3151 tmp_cmd[i] = *(cl + i);
3152 break;
3153 }
3154
3155 i++;
3156 }
3157 while( *(cl + i) NEQ '#' AND i < 40 );
3158
3159 if( i EQ 40 )
3160 {
3161 *gprs_command = FALSE;
3162 return (ATI_FAIL);
3163 }
3164
3165
3166 if( tmp_cmd[0] EQ '9' AND
3167 tmp_cmd[1] EQ '8' )
3168 {
3169 /* Character after *98 should be * or # for GPRS; otherwise
3170 this is USSD (refer issue 16289) */
3171 if( tmp_cmd[2] NEQ ',' AND
3172 tmp_cmd[2] NEQ 0 )
3173 {
3174 *gprs_command = FALSE;
3175 return (ATI_FAIL);
3176 }
3177
3178 if ( tmp_cmd[2] NEQ 0 )
3179 p_tmp_cmd = parse( &tmp_cmd[3], "i", &cid_length, &cid_array );
3180
3181 if(p_tmp_cmd)
3182 atd_cmd_type = ATD_CMD_98;
3183 }
3184 else if( tmp_cmd[0] EQ '9' AND
3185 tmp_cmd[1] EQ '9' )
3186 {
3187 /* Character after *99 should be * or # for GPRS; otherwise
3188 this is USSD (refer issue 16289) */
3189 if( tmp_cmd[2] NEQ ',' AND
3190 tmp_cmd[2] NEQ 0 )
3191 {
3192 *gprs_command = FALSE;
3193 return (ATI_FAIL);
3194 }
3195
3196 switch( star_count )
3197 {
3198 case 1:
3199 tmp_cmd[i] = ',';
3200 tmp_cmd[i+1] = ',';
3201 tmp_cmd[i+1] = 0;
3202 break;
3203
3204 case 2:
3205 tmp_cmd[i] = ',';
3206 tmp_cmd[i+1] = 0;
3207 break;
3208 }
3209
3210 if ( tmp_cmd[2] NEQ 0 )
3211 p_tmp_cmd = parse( &tmp_cmd[3], "aai", (LONG)MAX_B_SUBSCR_NUM_LEN, c_addr,
3212 (LONG)MAX_L2P_LENGTH, L2P,
3213 &cid_length, &cid_array );
3214 if(p_tmp_cmd)
3215 atd_cmd_type = ATD_CMD_99;
3216 }
3217 else
3218 {
3219 *gprs_command = FALSE;
3220 return (ATI_FAIL);
3221 }
3222
3223
3224 switch( atd_cmd_type )
3225 {
3226 case ATD_CMD_98:
3227 {
3228 strcpy( L2P, "PPP" );
3229 strcpy( pdp_type, "IP" );
3230
3231 break;
3232 }
3233
3234 case ATD_CMD_99:
3235 {
3236 if( ! strcmp(L2P,"") )
3237 {
3238 /* L2P is omitted use PPP as L2 protocol*/
3239 strcpy( L2P, "PPP" );
3240 }
3241
3242 else if( !(strcmp(L2P, "1") AND strcmp(L2P,"PPP")) )
3243 {
3244 strcpy( L2P, "PPP" );
3245 }
3246
3247 #if defined(FF_PKTIO) OR defined(FF_TCP_IP) OR defined (FF_PSI)
3248 else if( !(strcmp(L2P, "901") AND strcmp(L2P, "M-PKT")) )
3249 {
3250 strcpy( L2P, "M-PKT" );
3251 }
3252 #endif /* FF_PKTIO or FF_TCP_IP or FF_PSI */
3253 else
3254 {
3255 cmdCmeError(CME_ERR_OpNotAllow);
3256 return (ATI_FAIL);
3257 }
3258
3259 strcpy( pdp_type, "IP" );
3260
3261 break;
3262 }
3263 }
3264
3265 if( !cl )
3266 {
3267 cmdCmeError(CME_ERR_OpNotAllow);
3268 *gprs_command = FALSE;
3269 return (ATI_FAIL);
3270 }
3271
3272 #if defined (FF_WAP) OR defined (FF_SAT_E)
3273 if (src_flag)
3274 {
3275 memset (work_cids, PDP_CONTEXT_CID_INVALID, PDP_CONTEXT_CID_MAX);
3276 cid_pointer=0;
3277 }
3278 #endif
3279 /*
3280 * If the cid is omitted a matching defined context is found or a new context is created.
3281 */
3282 if( cid_array[0] EQ PDP_CONTEXT_CID_OMITTED )
3283 {
3284 p_pdp_context_node = p_pdp_context_list;
3285 while(p_pdp_context_node AND
3286 strcmp(p_pdp_context_node->attributes.pdp_type, pdp_type) AND
3287 p_pdp_context_node->internal_data.state NEQ PDP_CONTEXT_STATE_DEFINED )
3288 {
3289 p_pdp_context_node = p_pdp_context_node->p_next;
3290 }
3291 if(p_pdp_context_node)
3292 {
3293 cid_array[0] = p_pdp_context_node->cid;
3294
3295 #if defined (FF_WAP) OR defined (FF_SAT_E)
3296 if (src_flag)
3297 {
3298 work_cids[cid_pointer] = cid_array[0];
3299 }
3300 #endif
3301 }
3302 else
3303 {
3304 cid_array[0] = pdp_context_get_free_cid();
3305
3306 memcpy( &pdp_context, &pdp_context_default.attributes, sizeof(T_PDP_CONTEXT) );
3307 memcpy( pdp_context.pdp_type, pdp_type, sizeof(T_PDP_TYPE));
3308
3309 sAT_PlusCGDCONT((T_ACI_CMD_SRC) srcId, cid_array[0], &pdp_context );
3310
3311 #if defined (FF_WAP) OR defined (FF_SAT_E)
3312 if (src_flag)
3313 {
3314 work_cids[cid_pointer] = cid_array[0];
3315 }
3316 #endif
3317 }
3318 }
3319 else
3320 {
3321 i=0;
3322 while( cid_array[i] NEQ PDP_CONTEXT_CID_INVALID )
3323 {
3324 p_pdp_context_node = pdp_context_find_node_from_cid( cid_array[i] );
3325
3326 if( p_pdp_context_node )
3327 {
3328 if( strcmp( p_pdp_context_node->attributes.pdp_type, pdp_type ) )
3329 strcpy( p_pdp_context_node->attributes.pdp_type, pdp_type );
3330
3331 #if defined (FF_WAP) OR defined (FF_SAT_E)
3332 if (src_flag)
3333 {
3334 work_cids[i] = cid_array[i];
3335 cid_pointer = i;
3336 }
3337 #endif
3338 }
3339 else
3340 {
3341 memcpy( &pdp_context, &pdp_context_default.attributes, sizeof(T_PDP_CONTEXT) );
3342 memcpy( pdp_context.pdp_type, pdp_type, sizeof(T_PDP_TYPE));
3343
3344 if( sAT_PlusCGDCONT((T_ACI_CMD_SRC) srcId, cid_array[i], &pdp_context ) EQ AT_FAIL )
3345 {
3346 *gprs_command = FALSE;
3347 return (ATI_FAIL);
3348 }
3349
3350 #if defined (FF_WAP) OR defined (FF_SAT_E)
3351 if (src_flag)
3352 {
3353 work_cids[i] = cid_array[i];
3354 cid_pointer = i;
3355 }
3356 #endif
3357 }
3358 i++;
3359 }
3360 }
3361
3362 *gprs_command = TRUE;
3363
3364 #if defined (FF_WAP) OR defined (FF_SAT_E)
3365 if (src_flag)
3366 {
3367 BYTE options;
3368 SRCC_LINK_NO link_no = SRCC_INVALID_LINK;
3369 /* process WAP over GPRS */
3370
3371 /*
3372 *-------------------------------------------------------------------
3373 * check entity status
3374 *-------------------------------------------------------------------
3375 */
3376 if( smEntStat.curCmd NEQ AT_CMD_NONE )
3377 {
3378 return( ATI_BUSY );
3379 }
3380
3381
3382 if(is_gpf_tcpip_call()) {
3383 GPF_TCPIP_STATEMENT(link_no = SRCC_TCPIP_SNDCP_LINK);
3384 }
3385 else {
3386 link_no = SRCC_IP_SNDCP_LINK;
3387 }
3388 /* check number of context */
3389 if ( TRUE NEQ srcc_reserve_sources( link_no, 1 ) )
3390 {
3391 TRACE_EVENT ("srcc_reserve_sources failed!");
3392 cmdCmeError(CME_ERR_Unknown);
3393 return ( ATI_FAIL );
3394 }
3395
3396 /* get dti id */
3397 srcc_new_count(link_no);
3398
3399 wap_dti_id = dti_cntrl_new_dti(DTI_DTI_ID_NOTPRESENT);
3400 p_pdp_context_node = pdp_context_find_node_from_cid( cid_array[0] );
3401 p_pdp_context_node->internal_data.link_id_new =
3402 dti_conn_compose_link_id (0,0, wap_dti_id, DTI_TUPLE_NO_NOTPRESENT );
3403 p_pdp_context_node->internal_data.owner = ( T_ACI_CMD_SRC)srcId;
3404
3405 TRACE_EVENT_P1 ("ati_gprs, atGD, link_id_new = %0X", p_pdp_context_node->internal_data.link_id_new);
3406
3407 /* set IP options */
3408 if(is_gpf_tcpip_call()) {
3409 options = TCPIP_ACT_OPTION_V4 | TCPIP_ACT_OPTION_TCPIP;
3410 }
3411 else {
3412 options = TCPIP_ACT_OPTION_V4 | TCPIP_ACT_OPTION_UDP;
3413 }
3414
3415 /* send request to ACI WAP to activate WAP */
3416 smShrdPrm.owner = srcId;
3417 smEntStat.entOwn = (T_ACI_CMD_SRC)smShrdPrm.owner;
3418 smEntStat.curCmd = AT_CMD_CGDATA;
3419
3420 gpppEntStat.curCmd = AT_CMD_CGDATA;
3421 gpppEntStat.entOwn = ( T_ACI_CMD_SRC)srcId;
3422 gpppShrdPrm.owner = (UBYTE) srcId;
3423
3424 if(src_params)
3425 {
3426 src_params->curAtCmd = AT_CMD_CGDATA;
3427 }
3428
3429 psaTCPIP_Activate( srcId, wap_dti_id,
3430 wapId, options, TCPIP_CONNECTION_TYPE_GPRS_WAP,
3431 cmhSM_IP_activate_cb);
3432 return (ATI_EXCT);
3433 }
3434 #endif /* of WAP OR SAT E */
3435
3436 if( cmhSM_sAT_A(( T_ACI_CMD_SRC) srcId, &ret ) EQ TRUE )
3437 {
3438 switch (ret)
3439 {
3440 case (AT_CMPL): /* Operation completed */
3441 return (ATI_CMPL);
3442
3443 case (AT_EXCT):
3444 /* curAtCmd = AT_CMD_CGANS; */
3445 return (ATI_EXCT);
3446
3447 default:
3448 cmdCmeError(CME_ERR_Unknown); /* Command failed */
3449 return (ATI_FAIL);
3450 }
3451 }
3452 else
3453 {
3454
3455 ret = sAT_PlusCGDATA ((T_ACI_CMD_SRC) srcId, L2P, cid_array );
3456 switch (ret)
3457 {
3458 case (AT_CMPL): /* Operation completed */
3459 return (ATI_CMPL);
3460
3461 case (AT_EXCT):
3462 if(src_params)
3463 {
3464 src_params->curAtCmd = AT_CMD_CGDATA;
3465 }
3466 return (ATI_EXCT);
3467
3468 case (AT_BUSY):
3469 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
3470 return (ATI_FAIL);
3471
3472 default:
3473 cmdCmeError(CME_ERR_NotPresent); /*Command failed*/
3474 return (ATI_FAIL);
3475 }
3476 }
3477 }
3478
3479
3480 /*
3481 +--------------------------------------------------------------------+
3482 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
3483 | STATE : finished ROUTINE : setatPercentCGAATT |
3484 +--------------------------------------------------------------------+
3485
3486 PURPOSE : %CGAATT command ( GPRS automatic attach mode )
3487 */
3488
3489 GLOBAL T_ATI_RSLT setatPercentCGAATT (char *cl, UBYTE srcId)
3490 {
3491
3492 T_ACI_RETURN ret = AT_FAIL;
3493 T_CGAATT_ATTACH_MODE att_m = CGAATT_ATTACH_MODE_OMITTED;
3494 T_CGAATT_DETACH_MODE det_m = CGAATT_DETACH_MODE_OMITTED;
3495
3496 TRACE_FUNCTION("setatPercentCGAATT ()");
3497
3498 cl=parse(cl,"dd",&att_m, &det_m);
3499
3500 #ifdef FF_ATI_BAT
3501 {
3502 T_BAT_cmd_send cmd;
3503 T_BAT_cmd_set_percent_cgaatt cgaatt;
3504
3505 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CGAATT;
3506 cmd.params.ptr_set_percent_cgaatt=&cgaatt;
3507
3508 /*
3509 * This relies on T_CGAATT_ATTACH_MODE and T_GGAATT_DETACH_MODE being
3510 * identical to T_BAT_percent_cgaatt_att_m and T_BAT_percent_cgaatt_det_m.
3511 */
3512 cgaatt.att_m=(T_BAT_percent_cgaatt_att_m)att_m;
3513 cgaatt.det_m=(T_BAT_percent_cgaatt_det_m)det_m;
3514
3515 bat_send(ati_bat_get_client(srcId), &cmd);
3516 return(ATI_EXCT);
3517 }
3518
3519 #else
3520
3521 if( !cl )
3522 {
3523 cmdCmeError(CME_ERR_OpNotAllow);
3524 return (ATI_FAIL);
3525 }
3526
3527 ret = sAT_PercentCGAATT ((T_ACI_CMD_SRC)srcId, att_m, det_m );
3528 switch (ret)
3529 {
3530 case (AT_CMPL): /*operation completed*/
3531 return (ATI_CMPL);
3532 case (AT_EXCT):
3533 default:
3534 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
3535 return (ATI_FAIL);
3536 }
3537 #endif /*FF_ATI_BAT*/
3538 }
3539
3540 GLOBAL T_ATI_RSLT queatPercentCGAATT (char *cl, UBYTE srcId)
3541 {
3542 #ifndef FF_ATI_BAT
3543 T_ACI_RETURN ret;
3544 T_CGAATT_ATTACH_MODE att_m = CGAATT_ATTACH_MODE_OMITTED;
3545 T_CGAATT_DETACH_MODE det_m = CGAATT_DETACH_MODE_OMITTED;
3546 #endif
3547
3548 TRACE_FUNCTION("atPercentCGAATT ()");
3549 #ifdef FF_ATI_BAT
3550 {
3551 T_BAT_cmd_send cmd;
3552 T_BAT_no_parameter dummy;
3553
3554 cmd.ctrl_params = BAT_CMD_QUE_PERCENT_CGAATT;
3555 dummy.bat_dummy = 0xFF;
3556 cmd.params.ptr_que_percent_cgaatt = &dummy;
3557 bat_send(ati_bat_get_client(srcId), &cmd);
3558 return(ATI_EXCT);
3559 }
3560 #else
3561
3562 ret = qAT_PercentCGAATT((T_ACI_CMD_SRC)srcId, &att_m, &det_m);
3563 if (ret EQ AT_CMPL)
3564 {
3565 sprintf(g_sa,"%s: %d,%d", "%CGAATT", att_m, det_m);
3566 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
3567 return (ATI_CMPL);
3568 }
3569 else
3570 {
3571 cmdCmeError(CME_ERR_Unknown);
3572 return (ATI_FAIL);
3573 }
3574 #endif /*FF_ATI_BAT*/
3575 }
3576
3577 /*
3578 +--------------------------------------------------------------------+
3579 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
3580 | STATE : finished ROUTINE : setatPercentSNCNT |
3581 +--------------------------------------------------------------------+
3582
3583 PURPOSE : %SNCNT command ( SNDCP Counter )
3584 = 0: reset SNCNT counter.
3585 ?: ask for current count.
3586 */
3587
3588 GLOBAL T_ATI_RSLT setatPercentSNCNT (CHAR *cl, UBYTE srcId)
3589 {
3590 T_ACI_RETURN ret = AT_CMPL;
3591
3592 TRACE_FUNCTION("setatPercentSNCNT ()");
3593
3594 if( *cl NEQ '0' )
3595 {
3596 cmdCmeError(CME_ERR_OpNotAllow);
3597 return (ATI_FAIL);
3598 }
3599
3600 cl++;
3601 #ifdef FF_ATI_BAT
3602
3603 {
3604 T_BAT_cmd_send cmd;
3605 T_BAT_cmd_set_percent_sncnt sncnt;
3606
3607 cmd.ctrl_params = BAT_CMD_SET_PERCENT_SNCNT;
3608 cmd.params.ptr_set_percent_sncnt=&sncnt;
3609
3610 sncnt.rst=BAT_P_SNCNT_RESET_RESET;
3611
3612 bat_send(ati_bat_get_client(srcId), &cmd);
3613 return(ATI_EXCT);
3614 }
3615
3616 #else
3617
3618 /* AT%SNCNT = 0 resets counter */
3619 ret = sAT_PercentSNCNT((T_ACI_CMD_SRC)srcId, TRUE );
3620
3621 return (map_aci_2_ati_rslt(ret));
3622 #endif /*FF_ATI_BAT*/
3623 }
3624
3625 GLOBAL T_ATI_RSLT queatPercentSNCNT (CHAR *cl, UBYTE srcId)
3626 {
3627 T_ACI_RETURN ret = AT_CMPL;
3628
3629 TRACE_FUNCTION("queatPercentSNCNT ()");
3630
3631 #ifdef FF_ATI_BAT
3632 {
3633 T_BAT_cmd_send cmd;
3634 T_BAT_no_parameter dummy;
3635
3636 cmd.ctrl_params = BAT_CMD_QUE_PERCENT_SNCNT;
3637 dummy.bat_dummy = 0xFF;
3638 cmd.params.ptr_que_percent_sncnt = &dummy;
3639 bat_send(ati_bat_get_client(srcId), &cmd);
3640 return(ATI_EXCT);
3641 }
3642 #else
3643
3644 /* AT%SNCNT? returns current counter without resetting */
3645 ret = sAT_PercentSNCNT( (T_ACI_CMD_SRC)srcId, FALSE );
3646
3647 return (map_aci_2_ati_rslt(ret));
3648 #endif /*FF_ATI_BAT*/
3649 }
3650
3651 /*
3652 +--------------------------------------------------------------------+
3653 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
3654 | STATE : finished ROUTINE : setatPercentCGMM |
3655 +--------------------------------------------------------------------+
3656
3657 PURPOSE : %CGMM command ( Configure GMM )
3658 %CGMM = cipher_on, tlli_handling
3659 */
3660
3661 GLOBAL T_ATI_RSLT setatPercentCGMM(CHAR *cl, UBYTE srcId)
3662 {
3663 T_ACI_RETURN ret = AT_CMPL;
3664 USHORT cipher_on, tlli_handling;
3665
3666 TRACE_FUNCTION("setatPercentCGMM()");
3667
3668 cl=parse(cl, "rr", &cipher_on, &tlli_handling);
3669 if(!cl)
3670 {
3671 cmdCmeError(CME_ERR_OpNotAllow);
3672 return (ATI_FAIL);
3673 }
3674 #ifdef FF_ATI_BAT
3675 {
3676 T_BAT_cmd_send cmd;
3677 T_BAT_cmd_set_percent_cgmm my_bat_set_percent_cgmm;
3678
3679 TRACE_FUNCTION("setatPercentCGMM() calls bat_send() <=== as APPLICATION");
3680
3681 memset(&my_bat_set_percent_cgmm, 0, sizeof(my_bat_set_percent_cgmm));
3682 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CGMM;
3683 cmd.params.ptr_set_percent_cgmm = &my_bat_set_percent_cgmm;
3684
3685 my_bat_set_percent_cgmm.cipher_on = cipher_on;
3686 my_bat_set_percent_cgmm.tlli_handling = tlli_handling;
3687
3688 bat_send(ati_bat_get_client(srcId), &cmd);
3689
3690 return ATI_EXCT; /* executing, because response is passed by callback function */
3691 }
3692 #else /* OLD FUNCTION BODY */
3693
3694 TRACE_FUNCTION("setatPercentCGMM()");
3695
3696 ret = sAT_PercentCGMM( (T_ACI_CMD_SRC)srcId, (UBYTE)cipher_on, (UBYTE)tlli_handling );
3697
3698 if (ret NEQ AT_CMPL)
3699 {
3700 cmdCmeError(CME_ERR_Unknown);
3701 return (ATI_FAIL);
3702 }
3703 return (ATI_CMPL);
3704 #endif /* no FF_ATI_BAT*/
3705 }
3706
3707
3708 T_ATI_RSLT setatPercentCGPCO_HEX (UBYTE srcId, USHORT cid,
3709 UBYTE *pco_hex_string, USHORT len)
3710 {
3711 UBYTE pco_len;
3712 UBYTE *pco_array;
3713
3714
3715
3716
3717 TRACE_FUNCTION("setatPercentCGPCO_HEX():");
3718 /*
3719 * The functionality of the command is changed due to the
3720 * introduction of dynamic data structures for PCO.
3721 */
3722
3723 ACI_MALLOC (pco_array, ACI_PCO_MAX_LEN + 1);
3724
3725 pco_len = (UBYTE) utl_HexStrToBin( pco_hex_string, len, pco_array, ACI_PCO_MAX_LEN + 1 );
3726
3727 if(sAT_PercentCGPCO_HEX ((T_ACI_CMD_SRC)srcId, (U8) cid, pco_array, pco_len) EQ AT_FAIL )
3728 {
3729 cmdCmeError (CME_ERR_Unknown);
3730 ACI_MFREE (pco_array);
3731 return (ATI_FAIL);
3732 }
3733
3734 ACI_MFREE (pco_array);
3735 return (ATI_CMPL);
3736
3737 }
3738
3739
3740
3741 T_ACI_RETURN setatPercentCGPCO_ASCII (UBYTE srcId, U8 cid, UBYTE *pco_ascii_string, USHORT len)
3742 {
3743 CHAR aut_prot[5];
3744 CHAR user[MAX_USER_LEN+1]; /* + '\0' */
3745 CHAR pwd[MAX_PSWD_LEN+1]; /* + '\0' */
3746 CHAR dns1[MAX_DNS_LEN];
3747 CHAR dns2[MAX_DNS_LEN];
3748 CHAR *cl;
3749
3750 TRACE_FUNCTION("setatPercentCGPCO_ASCII():");
3751
3752 /* Initialize arrays */
3753 user[0] = '\0';
3754 pwd[0] = '\0';
3755 dns1[0] = '\0';
3756 dns2[0] = '\0';
3757
3758 cl = parse ((CHAR*)pco_ascii_string, "qqqqq",
3759 sizeof (aut_prot), aut_prot,
3760 sizeof (user), user, sizeof (pwd), pwd, sizeof(dns1), dns1, sizeof(dns2), dns2);
3761
3762 if(cl EQ NULL)
3763 {
3764 cmdCmeError (CME_ERR_InvalidTxtChar);
3765 return ((T_ACI_RETURN)ATI_FAIL);
3766 }
3767 strupper (aut_prot);
3768 if (strcmp (aut_prot, "PAP"))
3769 {
3770 cmdCmeError (CME_ERR_OpNotSupp);
3771 return ((T_ACI_RETURN)ATI_FAIL);
3772 }
3773
3774 if (sAT_PercentCGPCO ((T_ACI_CMD_SRC)srcId, cid,
3775 ACI_PCO_AUTH_PROT_PAP, user, pwd, dns1, dns2) EQ AT_FAIL)
3776 {
3777 cmdCmeError (CME_ERR_Unknown);
3778 return ((T_ACI_RETURN)ATI_FAIL);
3779 }
3780
3781 return ((T_ACI_RETURN)ATI_CMPL);
3782 }
3783
3784 /*
3785 +--------------------------------------------------------------------+
3786 | PROJECT : GPRS MODULE : ATI_GPRS |
3787 | STATE : finished ROUTINE : ipaddr_to_string |
3788 +--------------------------------------------------------------------+
3789
3790 PURPOSE : print the IP address (little endian!) to the supplied string.
3791
3792 */
3793 GLOBAL void ipaddr_to_string(ULONG ipaddr, char *ipaddr_string)
3794 {
3795 UBYTE *addrbyte_p ; /* Pointer to single address bytes. */
3796
3797 if (ipaddr_string)
3798 {
3799 addrbyte_p = (UBYTE *) &ipaddr ;
3800 if (ipaddr NEQ 0)
3801 {
3802 /* This is for little endian *only*! */
3803 sprintf(ipaddr_string,"%u.%u.%u.%u",
3804 addrbyte_p[3], addrbyte_p[2], addrbyte_p[1], addrbyte_p[0]);
3805 }
3806 else
3807 {
3808 *ipaddr_string = '\0' ;
3809 }
3810 }
3811 }
3812
3813
3814 /*
3815 +--------------------------------------------------------------------+
3816 | PROJECT : GPRS MODULE : GACI_CMD |
3817 | STATE : finished ROUTINE : queatPercentCGPCO |
3818 +--------------------------------------------------------------------+
3819
3820 PURPOSE : %CGPCO command
3821 * query network pco for cid
3822 */
3823
3824 LOCAL T_ATI_RSLT queatPercentCGPCO (UBYTE srcId, USHORT cid)
3825 {
3826 char *me="%CGPCO:";
3827 ULONG gateway,dns1,dns2;
3828 char dns1_str[sizeof("255.255.255.255")];
3829 char dns2_str[sizeof("255.255.255.255")];
3830 char gatew_str[sizeof("255.255.255.255")];
3831 USHORT i; /* Counter for loop over context IDs. */
3832
3833 TRACE_FUNCTION("queatPercentCGPCO( )");
3834
3835 if( cid EQ PDP_CONTEXT_CID_OMITTED ) /* for all available cid's: recurse */
3836 {
3837 for( i=1; i<=PDP_CONTEXT_CID_MAX; i++ )
3838 {
3839 queatPercentCGPCO(srcId, i);
3840 }
3841 }
3842 else /* for a specific cid */
3843 {
3844 gateway = dns1 = dns2 = 0 ; /* Just in case... */
3845
3846 if( qAT_PercentCGPCO((T_ACI_CMD_SRC)srcId, &gateway, &dns1, &dns2, cid) EQ AT_CMPL )
3847 {
3848 ipaddr_to_string(dns1, dns1_str);
3849 ipaddr_to_string(dns2, dns2_str);
3850 ipaddr_to_string(gateway, gatew_str);
3851 sprintf( g_sa, "%s \"%s,%s,%s\",%d",
3852 me, dns1_str, dns2_str, gatew_str, cid );
3853
3854 io_sendMessage (srcId, g_sa, ATI_NORMAL_OUTPUT);
3855
3856 memset(g_sa,0,MAX_CMD_LEN);
3857 }
3858 }
3859 return (ATI_CMPL);
3860 }
3861
3862 /*
3863 +--------------------------------------------------------------------+
3864 | PROJECT : GPRS MODULE : GACI_CMD |
3865 | STATE : finished ROUTINE : setatPercentCGPCO |
3866 +--------------------------------------------------------------------+
3867
3868 PURPOSE : %CGPCO command
3869 * set the PCO for context activation
3870 */
3871
3872 GLOBAL T_ATI_RSLT setatPercentCGPCO(CHAR *cl, UBYTE srcId)
3873 {
3874 U8 cid = PDP_CONTEXT_CID_OMITTED;
3875 T_ACI_CGPCO_FORMAT format;
3876 T_ATI_RSLT ret = ATI_FAIL;
3877 CHAR *pco_string;
3878 T_ACI_CGPCO_MODE mode;
3879
3880 TRACE_FUNCTION("setatPercentCGPCO()");
3881
3882 ACI_MALLOC (pco_string, ACI_PCO_MAX_LEN * 2 + 1);
3883
3884 cl = parse(cl, "ddsr",&mode, &format, ACI_PCO_MAX_LEN * 2 + 1, pco_string, &cid);
3885 if(cl EQ NULL)
3886 {
3887 cmdCmeError (CME_ERR_OpNotAllow);
3888 ACI_MFREE (pco_string);
3889 return (ATI_FAIL);
3890 }
3891
3892 if( !((cid >= PDP_CONTEXT_CID_MIN AND cid <= PDP_CONTEXT_CID_MAX) OR cid EQ PDP_CONTEXT_CID_OMITTED) )
3893 {
3894 cmdCmeError (CME_ERR_OpNotSupp);
3895 ACI_MFREE (pco_string);
3896 return (ATI_FAIL);
3897 }
3898
3899 #ifdef FF_ATI_BAT
3900 {
3901
3902 T_BAT_cmd_send cmd;
3903 T_BAT_cmd_set_percent_cgpco cgpco;
3904 SHORT len;
3905 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CGPCO;
3906 cmd.params.ptr_set_percent_cgpco = &cgpco;
3907
3908 cgpco.cid=(T_BAT_pdp_cid)cid;
3909 cgpco.v_pco=FALSE;
3910
3911 ret=ATI_EXCT;
3912
3913 switch (mode)
3914 {
3915 case CGPCO_MODE_QUERY_PCO:
3916 cgpco.mode=BAT_P_CGPCO_MODE_QUERY_PCO;
3917 cgpco.format=(T_BAT_percent_cgpco_format)format;
3918 break;
3919
3920 case CGPCO_MODE_SET_PCO:
3921 cgpco.mode=BAT_P_CGPCO_MODE_SET_PCO;
3922 cgpco.format=(T_BAT_percent_cgpco_format)format;
3923
3924 len=strlen(pco_string);
3925
3926 if (len>BAT_MAX_CGPCO_PCO_LEN)
3927 {
3928 ret=ATI_FAIL;
3929 }
3930 else
3931 {
3932 memcpy(cgpco.pco,pco_string,len);
3933 cgpco.c_pco=(U8)len;
3934 cgpco.v_pco=TRUE;
3935 }
3936 break;
3937
3938 default:
3939 cmdCmeError(CME_ERR_OpNotSupp);
3940 ret=ATI_FAIL;
3941 break;
3942 }
3943
3944 if (ret EQ ATI_EXCT)
3945 {
3946 bat_send(ati_bat_get_client(srcId), &cmd);
3947 }
3948 } /* FF_ATI_BAT */
3949 #else
3950
3951 switch (mode)
3952 {
3953 case CGPCO_MODE_QUERY_PCO:
3954
3955 ret = queatPercentCGPCO (srcId,cid);
3956 break;
3957
3958 case CGPCO_MODE_SET_PCO:
3959 {
3960 switch (format)
3961 {
3962 case CGPCO_FORMAT_HEX:
3963 ret = (T_ATI_RSLT)setatPercentCGPCO_HEX (srcId,cid, (UBYTE*)pco_string, (USHORT)strlen (pco_string));
3964 break;
3965
3966 case CGPCO_FORMAT_ASCII:
3967 ret = (T_ATI_RSLT)setatPercentCGPCO_ASCII (srcId, cid, (UBYTE*)pco_string, (USHORT)strlen (pco_string));
3968 break;
3969
3970 default:
3971 cmdCmeError (CME_ERR_OpNotSupp);
3972 ret = ATI_FAIL;
3973 break;
3974 }
3975 }
3976 break;
3977
3978 default:
3979 cmdCmeError (CME_ERR_OpNotSupp);
3980 ret = ATI_FAIL;
3981 break;
3982 }
3983 #endif
3984
3985 ACI_MFREE (pco_string);
3986
3987 return (ret);
3988 }
3989
3990 /*
3991 +--------------------------------------------------------------------+
3992 | PROJECT : GPRS MODULE : GACI_CMD |
3993 | STATE : finished ROUTINE : setatPercentCGPPP |
3994 +--------------------------------------------------------------------+
3995
3996 PURPOSE : %CGPPP command
3997 * set PPP values in GPRS case
3998
3999 PPP_AP_NO 0x0 no authentication
4000 PPP_AP_PAP 0x1 password authentication protocol
4001 PPP_AP_CHAP 0x2 challenge handshake authentication protocol
4002 PPP_AP_AUTO 0x3 automatic authentication
4003
4004 */
4005
4006 GLOBAL T_ATI_RSLT setatPercentCGPPP (CHAR *cl, UBYTE srcId)
4007 {
4008 T_ACI_PPP_PROT protocol;
4009 T_ACI_RETURN ret = AT_FAIL;
4010
4011 TRACE_FUNCTION("setatPercentCGPPP( )");
4012
4013 cl=parse(cl,"d",&protocol);
4014 if(!cl)
4015 {
4016 cmdCmeError(CME_ERR_OpNotAllow);
4017 return (ATI_FAIL);
4018 }
4019 #ifdef FF_ATI_BAT
4020 {
4021 T_BAT_cmd_send cmd;
4022 T_BAT_cmd_set_percent_cgppp my_bat_set_percent_cgppp;
4023
4024 TRACE_FUNCTION("setatPercentCGPPP() calls bat_send() <=== as APPLICATION");
4025
4026 memset(&my_bat_set_percent_cgppp, 0, sizeof(my_bat_set_percent_cgppp));
4027 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CGPPP;
4028 cmd.params.ptr_set_percent_cgppp = &my_bat_set_percent_cgppp;
4029
4030 my_bat_set_percent_cgppp.protocol = protocol;
4031
4032 bat_send(ati_bat_get_client(srcId), &cmd);
4033
4034 return ATI_EXCT; /* executing, because response is passed by callback function */
4035 }
4036 #else /* OLD FUNCTION BODY */
4037
4038 TRACE_FUNCTION("setatPercentCGPPP( )");
4039
4040 ret = sAT_PercentCGPPP((T_ACI_CMD_SRC)srcId, protocol);
4041 if (ret EQ AT_FAIL)
4042 {
4043 cmdCmeError(CME_ERR_Unknown);
4044 return (ATI_FAIL);
4045 }
4046 return (map_aci_2_ati_rslt(ret));
4047 #endif /* no FF_ATI_BAT*/
4048 }
4049
4050 /*
4051 +--------------------------------------------------------------------+
4052 | PROJECT : GPRS MODULE : GACI_CMD |
4053 | STATE : finished ROUTINE : queatPercentCGPPP |
4054 +--------------------------------------------------------------------+
4055
4056 PURPOSE : %CGPPP command
4057 * query PPP values in GPRS case
4058
4059 PPP_AP_NO 0x0 no authentication
4060 PPP_AP_PAP 0x1 password authentication protocol
4061 PPP_AP_CHAP 0x2 challenge handshake authentication protocol
4062 PPP_AP_AUTO 0x3 automatic authentication
4063
4064 */
4065
4066 GLOBAL T_ATI_RSLT queatPercentCGPPP (CHAR *cl, UBYTE srcId)
4067 {
4068 #ifndef FF_ATI_BAT
4069 T_ACI_PPP_PROT protocol;
4070 T_ACI_RETURN ret;
4071 #endif
4072
4073 TRACE_FUNCTION("queatPercentCGPPP( )");
4074 #ifdef FF_ATI_BAT
4075 {
4076 T_BAT_cmd_send cmd;
4077 T_BAT_no_parameter dummy;
4078
4079 cmd.ctrl_params = BAT_CMD_QUE_PERCENT_CGPPP;
4080 dummy.bat_dummy = 0xFF;
4081 cmd.params.ptr_que_percent_cgppp = &dummy;
4082 bat_send(ati_bat_get_client(srcId), &cmd);
4083 return(ATI_EXCT);
4084 }
4085 #else
4086
4087 ret = qAT_PercentCGPPP((T_ACI_CMD_SRC)srcId, &protocol);
4088 if (ret EQ AT_FAIL)
4089 {
4090 cmdCmeError(CME_ERR_Unknown);
4091 return (ATI_FAIL);
4092 }
4093
4094 sprintf (g_sa, "%s: %d", "%CGPPP", protocol);
4095 io_sendMessage (srcId, g_sa, ATI_NORMAL_OUTPUT);
4096
4097 return (map_aci_2_ati_rslt(ret));
4098 #endif /*FF_ATI_BAT*/
4099 }
4100 /*
4101 +--------------------------------------------------------------------+
4102 | PROJECT : GPRS (8441) MODULE : GACI_CMD |
4103 | STATE : finished ROUTINE : atPercentCGCLASS |
4104 +--------------------------------------------------------------------+
4105
4106 PURPOSE : %CGCLASS command (GPRS class change)
4107 */
4108
4109 GLOBAL T_ATI_RSLT setatPercentCGCLASS (CHAR *cl, UBYTE srcId)
4110 {
4111 #ifndef FF_ATI_BAT
4112 T_ACI_RETURN ret;
4113 #endif
4114 char test_class[3]="";
4115 T_PERCENT_CGCLASS m_class = PERCENT_CGCLASS_OMITTED;
4116
4117 TRACE_FUNCTION("setatPercentCGCLASS ()");
4118
4119 cl = parse (cl,"s", (LONG)3, &test_class );
4120
4121 switch (*test_class)
4122 {
4123 case 'A':
4124 break;
4125 case 'B':
4126 switch(*(test_class + 1))
4127 {
4128 case 'G':
4129 m_class = PERCENT_CGCLASS_BG;
4130 break;
4131 case 'C':
4132 m_class = PERCENT_CGCLASS_BC;
4133 break;
4134 case 'X':
4135 m_class = PERCENT_CGCLASS_BX;
4136 break;
4137 case '\0':
4138 m_class = PERCENT_CGCLASS_B;
4139 break;
4140 default:
4141 break;
4142 }
4143 break;
4144 case 'C':
4145 switch(*(test_class + 1))
4146 {
4147 case 'G':
4148 m_class = PERCENT_CGCLASS_CG;
4149 break;
4150 case 'C':
4151 m_class = PERCENT_CGCLASS_CC;
4152 break;
4153 default:
4154 break;
4155 }
4156 break;
4157 default:
4158 break;
4159 }
4160
4161 if ( !cl OR m_class EQ PERCENT_CGCLASS_OMITTED )
4162 {
4163 cmdCmeError(CME_ERR_OpNotAllow);
4164 return (ATI_FAIL);
4165 }
4166 #ifdef FF_ATI_BAT
4167
4168 {
4169 T_BAT_cmd_send cmd;
4170 T_BAT_cmd_set_percent_cgclass cgclass;
4171
4172 cmd.ctrl_params = BAT_CMD_SET_PERCENT_CGCLASS;
4173 cmd.params.ptr_set_percent_cgclass=&cgclass;
4174
4175 /*
4176 * BAT and ACI versions of mobile class are different enough
4177 * to require this conversion.
4178 */
4179
4180 /*
4181 * This relies on T_BAT_p_mobile_class and T_PERCENT_CGCLASS
4182 * being identical.
4183 */
4184 cgclass.p_mobile_class=(T_BAT_p_mobile_class)m_class;
4185
4186 bat_send(ati_bat_get_client(srcId), &cmd);
4187 return(ATI_EXCT);
4188 }
4189
4190 #else
4191
4192 ret = sAT_PercentCGCLASS ( (T_ACI_CMD_SRC)srcId, m_class );
4193 if (ret EQ AT_FAIL)
4194 {
4195 cmdCmeError (CME_ERR_OpNotAllow);
4196 return (ATI_FAIL);
4197 }
4198 return (map_aci_2_ati_rslt(ret));
4199 #endif
4200 }
4201
4202 GLOBAL T_ATI_RSLT queatPercentCGCLASS (CHAR *cl, UBYTE srcId)
4203 {
4204 #ifndef FF_ATI_BAT
4205 char *classes[] = {"A","B","BG","BC","BX","CG","CC"};
4206 T_ACI_RETURN ret;
4207 T_PERCENT_CGCLASS m_class, currentClass;
4208 #endif
4209
4210 TRACE_FUNCTION("queatPercentCGCLASS ()");
4211 #ifdef FF_ATI_BAT
4212 {
4213 T_BAT_cmd_send cmd;
4214 T_BAT_no_parameter dummy;
4215
4216 cmd.ctrl_params = BAT_CMD_QUE_PERCENT_CGCLASS;
4217 dummy.bat_dummy = 0xFF;
4218 cmd.params.ptr_que_plus_cgclass = &dummy;
4219 bat_send(ati_bat_get_client(srcId), &cmd);
4220 return(ATI_EXCT);
4221 }
4222 #else
4223
4224 ret = qAT_PercentCGCLASS((T_ACI_CMD_SRC)srcId, &m_class, &currentClass);
4225 if (ret EQ AT_CMPL)
4226 {
4227 if(m_class NEQ currentClass)
4228 {
4229 sprintf(g_sa,"%s: \"%s\",\"%s\"", "%CGCLASS", classes[m_class], classes[currentClass]);
4230 }
4231 else
4232 {
4233 sprintf(g_sa,"%s: \"%s\"", "%CGCLASS", classes[m_class]);
4234 }
4235 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
4236 }
4237
4238 return (map_aci_2_ati_rslt(ret));
4239 #endif /*FF_ATI_BAT*/
4240 }
4241
4242 #ifdef REL99
4243 /*
4244 +--------------------------------------------------------------------+
4245 | PROJECT : UMTS MODULE : GACI_CMD |
4246 | STATE : devellopment ROUTINE : setatPlusCGEQREQ |
4247 +--------------------------------------------------------------------+
4248
4249 PURPOSE : +CGEQREQ command
4250 Set 3G Quality of Service Profile (Requested)
4251 */
4252 GLOBAL T_ATI_RSLT setatPlusCGEQREQ( char *cl, UBYTE srcId )
4253 {
4254 T_ACI_RETURN ret;
4255 T_PS_qos input_qos;
4256 U8 cid;
4257 #ifdef FF_ATI_BAT
4258 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
4259 #endif
4260 TRACE_FUNCTION("setatPlusCGEQREQ ()");
4261
4262 cid = PDP_CONTEXT_CID_OMITTED;
4263
4264 input_qos.qos_r99.tc = QOS_R99_TC_OMITTED;
4265 input_qos.qos_r99.order = QOS_R99_ORDER_OMITTED;
4266 input_qos.qos_r99.del_err_sdu = QOS_R99_DEL_ERR_SDU_OMITTED;
4267 input_qos.qos_r99.max_sdu = QOS_R99_MAX_SDU_OMITTED;
4268 input_qos.qos_r99.max_rate_ul = QOS_R99_MAX_BR_UL_OMITTED;
4269 input_qos.qos_r99.max_rate_dl = QOS_R99_MAX_BR_DL_OMITTED;
4270 input_qos.qos_r99.xfer_delay = QOS_R99_XFER_DELAY_OMITTED;
4271 input_qos.qos_r99.handling_pri = QOS_R99_HANDLING_PRIO_OMITTED;
4272 input_qos.qos_r99.guar_br_ul = QOS_R99_GUAR_BR_UL_OMITTED;
4273 input_qos.qos_r99.guar_br_dl = QOS_R99_GUAR_BR_DL_OMITTED;
4274 input_qos.qos_r99.ber.ratio_mant = QOS_R99_RATIO_MANT_OMITTED; /* Residual bit error ratio */
4275 input_qos.qos_r99.ber.ratio_exp = QOS_R99_RATIO_EXP_OMITTED;
4276 input_qos.qos_r99.sdu_err_ratio.ratio_mant = QOS_R99_RATIO_MANT_OMITTED;
4277 input_qos.qos_r99.sdu_err_ratio.ratio_exp = QOS_R99_RATIO_EXP_OMITTED;
4278
4279 cl = parse( cl,"ccrrrrcreecrc", &cid,
4280 &input_qos.qos_r99.tc,
4281 &input_qos.qos_r99.max_rate_ul,
4282 &input_qos.qos_r99.max_rate_dl,
4283 &input_qos.qos_r99.guar_br_ul,
4284 &input_qos.qos_r99.guar_br_dl,
4285 &input_qos.qos_r99.order,
4286 &input_qos.qos_r99.max_sdu,
4287 &input_qos.qos_r99.sdu_err_ratio,
4288 &input_qos.qos_r99.ber, /* Residual bit error ratio */
4289 &input_qos.qos_r99.del_err_sdu,
4290 &input_qos.qos_r99.xfer_delay,
4291 &input_qos.qos_r99.handling_pri );
4292 if( !cl )
4293 {
4294 cmdCmeError(CME_ERR_OpNotAllow);
4295 return (ATI_FAIL);
4296 }
4297
4298 #ifdef FF_ATI_BAT
4299 {
4300 T_BAT_cmd_send cmd;
4301 T_BAT_cmd_set_plus_cgeqreq cgeqreq;
4302 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGEQREQ;
4303 cmd.params.ptr_set_plus_cgeqreq = &cgeqreq;
4304
4305 cgeqreq.cid = cid;
4306 cgeqreq.tc = input_qos.qos_r99.tc;
4307 cgeqreq.max_rate_ul = input_qos.qos_r99.max_rate_ul;
4308 cgeqreq.max_rate_dl = input_qos.qos_r99.max_rate_dl;
4309 cgeqreq.guar_br_ul = input_qos.qos_r99.guar_br_ul;
4310 cgeqreq.guar_br_dl = input_qos.qos_r99.guar_br_dl;
4311 cgeqreq.order = input_qos.qos_r99.order;
4312 cgeqreq.max_sdu = input_qos.qos_r99.max_sdu;
4313
4314 /* sdu_err_ratio */
4315 if (input_qos.qos_r99.sdu_err_ratio.ratio_mant NEQ
4316 QOS_R99_RATIO_MANT_OMITTED)
4317 {
4318 cgeqreq.v_sdu_err_ratio = TRUE;
4319 cgeqreq.c_sdu_err_ratio = 2;
4320 cgeqreq.sdu_err_ratio[0] = input_qos.qos_r99.sdu_err_ratio.ratio_mant;
4321 if (input_qos.qos_r99.sdu_err_ratio.ratio_exp NEQ
4322 QOS_R99_RATIO_EXP_OMITTED)
4323 cgeqreq.sdu_err_ratio[1] = input_qos.qos_r99.sdu_err_ratio.ratio_exp;
4324 else
4325 cgeqreq.sdu_err_ratio[1] = 1;
4326 }
4327 else
4328 {
4329 cgeqreq.v_sdu_err_ratio = FALSE;
4330 cgeqreq.c_sdu_err_ratio = 0;
4331 }
4332
4333 /* ber */
4334 if (input_qos.qos_r99.ber.ratio_mant NEQ QOS_R99_RATIO_MANT_OMITTED)
4335 {
4336 cgeqreq.v_ber = TRUE;
4337 cgeqreq.c_ber = 2;
4338 cgeqreq.ber[0] = input_qos.qos_r99.ber.ratio_mant;
4339 if (input_qos.qos_r99.ber.ratio_exp NEQ QOS_R99_RATIO_EXP_OMITTED)
4340 cgeqreq.ber[1] = input_qos.qos_r99.ber.ratio_exp;
4341 else
4342 cgeqreq.ber[1] = 1;
4343 }
4344 else
4345 {
4346 cgeqreq.v_ber = FALSE;
4347 cgeqreq.c_ber = 0;
4348 }
4349
4350 cgeqreq.del_err_sdu = input_qos.qos_r99.del_err_sdu;
4351 cgeqreq.xfer_delay = input_qos.qos_r99.xfer_delay;
4352 cgeqreq.handling_pri = input_qos.qos_r99.handling_pri;
4353
4354 bat_send(ati_bat_get_client(srcId), &cmd);
4355 src_params->curAtCmd=AT_CMD_CGEQREQ;
4356 return(ATI_EXCT);
4357 }
4358 #else
4359 ret = (T_ACI_RETURN)sAT_PlusCGEQREQ ((T_ACI_CMD_SRC)srcId, (U8)cid ,&input_qos);
4360 switch (ret)
4361 {
4362 case (AT_CMPL): /*operation completed*/
4363 return (ATI_CMPL);
4364 case (AT_EXCT):
4365 // curAtCmd = AT_CMD_CGEQREQ;
4366 return (ATI_EXCT);
4367 default:
4368 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
4369 return (ATI_FAIL);
4370 }
4371 #endif /* FF_ATI_BAT */
4372 }
4373
4374 /*
4375 +--------------------------------------------------------------------+
4376 | PROJECT : UMTS MODULE : GACI_CMD |
4377 | STATE : devellopment ROUTINE : setatPlusCGEQMIN |
4378 +--------------------------------------------------------------------+
4379
4380 PURPOSE : +CGEQMIN command
4381 Set 3G Quality of Service Profile (Minimum)
4382 */
4383 GLOBAL T_ATI_RSLT setatPlusCGEQMIN( char *cl, UBYTE srcId )
4384 {
4385 T_ACI_RETURN ret;
4386 T_PS_qos input_qos;
4387 U8 cid;
4388 #ifdef FF_ATI_BAT
4389 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
4390 #endif
4391 TRACE_FUNCTION("setatPlusCGEQMIN ()");
4392
4393 cid = PDP_CONTEXT_CID_OMITTED;
4394
4395 input_qos.qos_r99.tc = QOS_R99_TC_OMITTED;
4396 input_qos.qos_r99.order = QOS_R99_ORDER_OMITTED;
4397 input_qos.qos_r99.del_err_sdu = QOS_R99_DEL_ERR_SDU_OMITTED;
4398 input_qos.qos_r99.max_sdu = QOS_R99_MAX_SDU_OMITTED;
4399 input_qos.qos_r99.max_rate_ul = QOS_R99_MAX_BR_UL_OMITTED;
4400 input_qos.qos_r99.max_rate_dl = QOS_R99_MAX_BR_DL_OMITTED;
4401 input_qos.qos_r99.xfer_delay = QOS_R99_XFER_DELAY_OMITTED;
4402 input_qos.qos_r99.handling_pri = QOS_R99_HANDLING_PRIO_OMITTED;
4403 input_qos.qos_r99.guar_br_ul = QOS_R99_GUAR_BR_UL_OMITTED;
4404 input_qos.qos_r99.guar_br_dl = QOS_R99_GUAR_BR_DL_OMITTED;
4405 input_qos.qos_r99.ber.ratio_mant = QOS_R99_RATIO_MANT_OMITTED; /* Residual bit error ratio */
4406 input_qos.qos_r99.ber.ratio_exp = QOS_R99_RATIO_EXP_OMITTED;
4407 input_qos.qos_r99.sdu_err_ratio.ratio_mant = QOS_R99_RATIO_MANT_OMITTED;
4408 input_qos.qos_r99.sdu_err_ratio.ratio_exp = QOS_R99_RATIO_EXP_OMITTED;
4409
4410 cl = parse( cl,"ccrrrrcreecrc", &cid,
4411 &input_qos.qos_r99.tc,
4412 &input_qos.qos_r99.max_rate_ul,
4413 &input_qos.qos_r99.max_rate_dl,
4414 &input_qos.qos_r99.guar_br_ul,
4415 &input_qos.qos_r99.guar_br_dl,
4416 &input_qos.qos_r99.order,
4417 &input_qos.qos_r99.max_sdu,
4418 &input_qos.qos_r99.sdu_err_ratio,
4419 &input_qos.qos_r99.ber, /* Residual bit error ratio */
4420 &input_qos.qos_r99.del_err_sdu,
4421 &input_qos.qos_r99.xfer_delay,
4422 &input_qos.qos_r99.handling_pri );
4423 if( !cl )
4424 {
4425 cmdCmeError(CME_ERR_OpNotAllow);
4426 return (ATI_FAIL);
4427 }
4428
4429 #ifdef FF_ATI_BAT
4430 {
4431 T_BAT_cmd_send cmd;
4432 T_BAT_cmd_set_plus_cgeqmin cgeqmin;
4433 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGEQMIN;
4434 cmd.params.ptr_set_plus_cgeqmin = &cgeqmin;
4435
4436 cgeqmin.cid = (T_BAT_pdp_cid)cid;
4437 cgeqmin.tc = input_qos.qos_r99.tc;
4438 cgeqmin.max_rate_ul = input_qos.qos_r99.max_rate_ul;
4439 cgeqmin.max_rate_dl = input_qos.qos_r99.max_rate_dl;
4440 cgeqmin.guar_br_ul = input_qos.qos_r99.guar_br_ul;
4441 cgeqmin.guar_br_dl = input_qos.qos_r99.guar_br_dl;
4442 cgeqmin.order = input_qos.qos_r99.order;
4443 cgeqmin.max_sdu = input_qos.qos_r99.max_sdu;
4444
4445 /* sdu_err_ratio */
4446 if (input_qos.qos_r99.sdu_err_ratio.ratio_mant NEQ
4447 QOS_R99_RATIO_MANT_OMITTED)
4448 {
4449 cgeqmin.v_sdu_err_ratio = TRUE;
4450 cgeqmin.c_sdu_err_ratio = 2;
4451 cgeqmin.sdu_err_ratio[0] = input_qos.qos_r99.sdu_err_ratio.ratio_mant;
4452 if (input_qos.qos_r99.sdu_err_ratio.ratio_exp NEQ
4453 QOS_R99_RATIO_EXP_OMITTED)
4454 cgeqmin.sdu_err_ratio[1] = input_qos.qos_r99.sdu_err_ratio.ratio_exp;
4455 else
4456 cgeqmin.sdu_err_ratio[1] = 1;
4457 }
4458 else
4459 {
4460 cgeqmin.v_sdu_err_ratio = FALSE;
4461 cgeqmin.c_sdu_err_ratio = 0;
4462 }
4463
4464 /* ber */
4465 if (input_qos.qos_r99.ber.ratio_mant NEQ QOS_R99_RATIO_MANT_OMITTED)
4466 {
4467 cgeqmin.v_ber = TRUE;
4468 cgeqmin.c_ber = 2;
4469 cgeqmin.ber[0] = input_qos.qos_r99.ber.ratio_mant;
4470 if (input_qos.qos_r99.ber.ratio_exp NEQ QOS_R99_RATIO_EXP_OMITTED)
4471 cgeqmin.ber[1] = input_qos.qos_r99.ber.ratio_exp;
4472 else
4473 cgeqmin.ber[1] = 1;
4474 }
4475 else
4476 {
4477 cgeqmin.v_ber = FALSE;
4478 cgeqmin.c_ber = 0;
4479 }
4480
4481 cgeqmin.del_err_sdu = input_qos.qos_r99.del_err_sdu;
4482 cgeqmin.xfer_delay = input_qos.qos_r99.xfer_delay;
4483 cgeqmin.handling_pri = input_qos.qos_r99.handling_pri;
4484
4485 bat_send(ati_bat_get_client(srcId), &cmd);
4486 src_params->curAtCmd=AT_CMD_CGEQMIN;
4487 return(ATI_EXCT);
4488 }
4489 #else
4490 ret = sAT_PlusCGEQMIN ((T_ACI_CMD_SRC)srcId, cid ,&input_qos);
4491 switch (ret)
4492 {
4493 case (AT_CMPL): /*operation completed*/
4494 return (ATI_CMPL);
4495 case (AT_EXCT):
4496 // curAtCmd = AT_CMD_CGEQMIN;
4497 return (ATI_EXCT);
4498 default:
4499 cmdCmeError(CME_ERR_Unknown); /*Command failed*/
4500 return (ATI_FAIL);
4501 }
4502 #endif /* FF_ATI_BAT */
4503
4504 }
4505
4506 /*
4507 +--------------------------------------------------------------------+
4508 | PROJECT : UMTS MODULE : ATI_GPRS |
4509 | STATE : finished ROUTINE : setatPlusCGEQNEG |
4510 +--------------------------------------------------------------------+
4511
4512 PURPOSE : Query of 3G QoS Profile (Negotiated)
4513 */
4514 GLOBAL T_ATI_RSLT setatPlusCGEQNEG (char *cl, UBYTE srcId)
4515 {
4516 char *me="+CGEQNEG: ";
4517 T_PS_qos pdef_qos;
4518 int i;
4519 BOOL qos_valid;
4520 U8 cid_array[PDP_CONTEXT_CID_MAX+1], current_cid;
4521 int no_of_cids;
4522 char *end;
4523 #ifdef FF_ATI_BAT
4524 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
4525 #endif
4526 TRACE_FUNCTION("setatPlusCGEQNEG ()");
4527
4528 /* Parse all the cids into the cid array */
4529 no_of_cids = 0;
4530
4531 --cl; /* Decreased due to no comma the first time! */
4532 do
4533 {
4534 /* Remove the "," */
4535 cl++;
4536
4537 /* Set the entry to omitted. */
4538 cid_array[no_of_cids] = PDP_CONTEXT_CID_OMITTED;
4539
4540 /* Parse the value */
4541 cid_array[no_of_cids] = ( U8 ) strtol (cl, &end, 10);
4542 cl = end;
4543
4544 if( cid_array[no_of_cids] EQ 0 )
4545 cid_array[no_of_cids] = PDP_CONTEXT_CID_OMITTED;
4546
4547 /* If a cid is omitted no cids must be specified at all. */
4548 if( cid_array[no_of_cids] EQ PDP_CONTEXT_CID_OMITTED )
4549 {
4550 if( no_of_cids NEQ 0 )
4551 {
4552 /* Don't accept omitted cids inside if not the first. (AT+CGCMOD=1,2,,3 is not allowed). */
4553 cmdCmeError(CME_ERR_OpNotSupp);
4554 return (ATI_FAIL);
4555 }
4556 /* Break the while */
4557 break;
4558 }
4559 if( (!cl) OR (cid_array[no_of_cids] < PDP_CONTEXT_CID_MIN) OR (cid_array[no_of_cids] > PDP_CONTEXT_CID_MAX) OR (no_of_cids >= PDP_CONTEXT_CID_MAX) )
4560 {
4561 cmdCmeError(CME_ERR_OpNotSupp);
4562 return(ATI_FAIL);
4563 }
4564 no_of_cids++;
4565 } while ( *cl EQ ',' );
4566 cid_array[no_of_cids] = PDP_CONTEXT_CID_OMITTED;
4567
4568 #ifdef FF_ATI_BAT
4569 {
4570 T_BAT_cmd_send cmd;
4571 T_BAT_cmd_set_plus_cgeqneg cgeqneg;
4572 UBYTE n;
4573 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGEQNEG;
4574 cmd.params.ptr_set_plus_cgeqneg=&cgeqneg;
4575
4576 for (n=0;((n<no_of_cids) AND (n<BAT_MAX_PDP_CID));n++)
4577
4578 cgeqneg.cid[n]=(T_BAT_pdp_cid)cid_array[n];
4579 bat_send(ati_bat_get_client(srcId), &cmd);
4580 src_params->curAtCmd=AT_CMD_CGEQNEG;
4581 return(ATI_EXCT);
4582 }
4583 #else
4584 /* Calculate number of cids: If the first cid is omitted it is treated as all cids. */
4585 if (cid_array[0] EQ PDP_CONTEXT_CID_OMITTED)
4586 no_of_cids = PDP_CONTEXT_CID_MAX;
4587
4588 for(i = 0; i<no_of_cids; i++)
4589 {
4590 /* If the first cid is omitted it is treated as all cids */
4591 if (cid_array[0] EQ PDP_CONTEXT_CID_OMITTED)
4592 current_cid = i+1;
4593 else
4594 current_cid = cid_array[i];
4595
4596 if (sAT_PlusCGEQNEG ((T_ACI_CMD_SRC)srcId, current_cid, &qos_valid, &pdef_qos) EQ AT_CMPL)
4597 {
4598 if (qos_valid)
4599 {
4600 /* Format the return string with the Release 99 QoS */
4601 sprintf(g_sa,"%s%hd,%d,%d,%d,%d,%d,%d,%d,%dE%d,%dE%d,%d,%d,%d", me, current_cid,
4602 pdef_qos.qos_r99.tc, /*< traffic class */
4603 pdef_qos.qos_r99.max_rate_ul, /*< max bit-rate uplink */
4604 pdef_qos.qos_r99.max_rate_dl, /*< max bit-rate downlink */
4605 pdef_qos.qos_r99.guar_br_ul, /*< guaranteed bit-rate uplink */
4606 pdef_qos.qos_r99.guar_br_dl, /*< guaranteed bit-rate downlink */
4607 pdef_qos.qos_r99.order, /*< delivery order */
4608 pdef_qos.qos_r99.max_sdu, /*< max SDU size */
4609 pdef_qos.qos_r99.sdu_err_ratio.ratio_mant, /*< SDU error ratio (format is the same as ber) */
4610 pdef_qos.qos_r99.sdu_err_ratio.ratio_exp, /*< */
4611 pdef_qos.qos_r99.ber.ratio_mant, /*< Residual bit error ratio (ratio_mant E ratio_exp */
4612 pdef_qos.qos_r99.ber.ratio_exp, /*< (Ex. 10E2) */
4613 pdef_qos.qos_r99.del_err_sdu, /*< delivery of erroneous SDU */
4614 pdef_qos.qos_r99.xfer_delay, /*< transfer delay */
4615 pdef_qos.qos_r99.handling_pri); /*< traffic handling priority */
4616
4617 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
4618 }
4619 }
4620 else
4621 {
4622 cmdCmeError(CME_ERR_Unknown); /* The command is invalid for srcId */
4623 return (ATI_FAIL);
4624 }
4625 }
4626
4627 return (ATI_CMPL);
4628 #endif /* FF_ATI_BAT */
4629 }
4630
4631 /*
4632 +--------------------------------------------------------------------+
4633 | PROJECT : UMTS MODULE : ATI_GPRS |
4634 | STATE : finished ROUTINE : setatPlusCGCMOD |
4635 +--------------------------------------------------------------------+
4636
4637 PURPOSE : Modify indicated or all contexts.
4638 */
4639 GLOBAL T_ATI_RSLT setatPlusCGCMOD (char *cl, UBYTE srcId)
4640 {
4641 U8 cid_array[PDP_CONTEXT_CID_MAX + 1];
4642 int no_of_cids;
4643 char *end;
4644 T_ACI_RETURN ret;
4645 #ifdef FF_ATI_BAT
4646 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, srcId, search_ati_src_id);
4647 #endif
4648
4649 TRACE_FUNCTION("setatPlusCGCMOD ()");
4650
4651 --cl; /* No comma the first time!!! */
4652
4653 /* Parse all the cids into the cid array */
4654 no_of_cids = 0;
4655 do
4656 {
4657 /* Remove the "," */
4658 cl++;
4659
4660 /* Set the entry to omitted. */
4661 cid_array[no_of_cids] = PDP_CONTEXT_CID_OMITTED;
4662
4663 /* Parse the value */
4664 cid_array[no_of_cids] = (U8) strtol (cl, &end, 10);
4665 cl = end;
4666
4667 if( cid_array[no_of_cids] EQ 0 )
4668 cid_array[no_of_cids] = PDP_CONTEXT_CID_OMITTED;
4669
4670 /* If a cid is omitted no cids must be specified at all. */
4671 if( cid_array[no_of_cids] EQ PDP_CONTEXT_CID_OMITTED )
4672 {
4673 if (no_of_cids NEQ 0)
4674 {
4675 /* Don't accept omitted cids inside if not the first. (AT+CGCMOD=1,2,,3 is not allowed). */
4676 cmdCmeError(CME_ERR_OpNotSupp);
4677 return (ATI_FAIL);
4678 }
4679 /* Break the while */
4680 break;
4681 }
4682 if ( (!cl) OR (cid_array[no_of_cids] < PDP_CONTEXT_CID_MIN) OR (cid_array[no_of_cids] > PDP_CONTEXT_CID_MAX) OR (no_of_cids >= PDP_CONTEXT_CID_MAX) )
4683 {
4684 cmdCmeError(CME_ERR_OpNotSupp);
4685 return (ATI_FAIL);
4686 }
4687 no_of_cids++;
4688 } while ( *cl EQ ',' );
4689 cid_array[no_of_cids] = PDP_CONTEXT_CID_INVALID;
4690
4691 #ifdef FF_ATI_BAT
4692 {
4693 T_BAT_cmd_send cmd;
4694 T_BAT_cmd_set_plus_cgcmod cgcmod;
4695 UBYTE n;
4696 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGCMOD;
4697 cmd.params.ptr_set_plus_cgcmod=&cgcmod;
4698
4699 for (n=0;((n<no_of_cids) AND (n<BAT_MAX_PDP_CID));n++)
4700 cgcmod.cid[n]=(T_BAT_pdp_cid)cid_array[n];
4701 bat_send(ati_bat_get_client(srcId), &cmd);
4702
4703 src_params->curAtCmd=AT_CMD_CGCMOD;
4704 return(ATI_EXCT);
4705 }
4706 #else
4707 ret = sAT_PlusCGCMOD ((T_ACI_CMD_SRC)srcId, cid_array);
4708 switch ( ret )
4709 {
4710 case AT_EXCT:
4711 cmdErrStr = NULL;
4712 // curAtCmd = AT_CMD_CGCMOD;
4713 return (ATI_EXCT);
4714 case AT_CMPL:
4715 /* The command can not return AT_CMPL!! This is an error! */
4716 cmdCmeError(CME_ERR_Unknown);
4717 return (ATI_FAIL);
4718 }
4719 return (map_aci_2_ati_rslt(ret));
4720 #endif /*FF_ATI_BAT */
4721 }
4722
4723 /*
4724 +--------------------------------------------------------------------+
4725 | PROJECT : UMTS MODULE : ATI_GPRS |
4726 | STATE : finished ROUTINE : queatPlusCGEQREQ |
4727 +--------------------------------------------------------------------+
4728
4729 PURPOSE : Query of 3G QoS Profile (Requested)
4730 */
4731 GLOBAL T_ATI_RSLT queatPlusCGEQREQ (char *cl, UBYTE srcId)
4732 {
4733 char *me="+CGEQREQ: ";
4734 T_PS_qos pdef_qos;
4735 U8 cid;
4736 BOOL qos_valid = FALSE;
4737
4738 TRACE_FUNCTION("queatPlusCGEQREQ ()");
4739 #ifdef FF_ATI_BAT
4740 {
4741 T_BAT_cmd_send cmd;
4742 T_BAT_no_parameter dummy;
4743
4744 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGEQREQ;
4745 dummy.bat_dummy = 0xFF;
4746 cmd.params.ptr_set_plus_cgeqreq = &dummy;
4747 bat_send(ati_bat_get_client(srcId), &cmd);
4748 return(ATI_EXCT);
4749 }
4750 #else
4751
4752 for ( cid = PDP_CONTEXT_CID_MIN; cid <= PDP_CONTEXT_CID_MAX; cid++ )
4753 {
4754 if (qAT_PlusCGEQREQ ((T_ACI_CMD_SRC)srcId, cid, &qos_valid, &pdef_qos) EQ AT_CMPL)
4755 {
4756 if (qos_valid)
4757 {
4758 /* Format the return string with the Release 99 QoS */
4759 sprintf(g_sa,"%s%hd,%d,%d,%d,%d,%d,%d,%d,\"%dE%d\",\"%dE%d\",%d,%d,%d", me, cid,
4760 pdef_qos.qos_r99.tc, /*< traffic class */
4761 pdef_qos.qos_r99.max_rate_ul, /*< max bit-rate uplink */
4762 pdef_qos.qos_r99.max_rate_dl, /*< max bit-rate downlink */
4763 pdef_qos.qos_r99.guar_br_ul, /*< guaranteed bit-rate uplink */
4764 pdef_qos.qos_r99.guar_br_dl, /*< guaranteed bit-rate downlink */
4765 pdef_qos.qos_r99.order, /*< delivery order */
4766 pdef_qos.qos_r99.max_sdu, /*< max SDU size */
4767 pdef_qos.qos_r99.sdu_err_ratio.ratio_mant, /*< SDU error ratio (format is the same as ber) */
4768 pdef_qos.qos_r99.sdu_err_ratio.ratio_exp, /*< */
4769 pdef_qos.qos_r99.ber.ratio_mant, /*< Residual bit error ratio (ratio_mant E ratio_exp */
4770 pdef_qos.qos_r99.ber.ratio_exp, /*< (Ex. 10E2) */
4771 pdef_qos.qos_r99.del_err_sdu, /*< delivery of erroneous SDU */
4772 pdef_qos.qos_r99.xfer_delay, /*< transfer delay */
4773 pdef_qos.qos_r99.handling_pri); /*< traffic handling priority */
4774
4775 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
4776 }
4777 }
4778 else
4779 {
4780 /* AT_FAIL has been returned */
4781 cmdCmeError(CME_ERR_Unknown); /* The command is invalid for srcId */
4782 return (ATI_FAIL);
4783 }
4784 }
4785 return (ATI_CMPL);
4786 #endif /* FF_ATI_BAT */
4787 }
4788
4789 /*
4790 +--------------------------------------------------------------------+
4791 | PROJECT : UMTS MODULE : ATI_GPRS |
4792 | STATE : finished ROUTINE : queatPlusCGEQMIN |
4793 +--------------------------------------------------------------------+
4794
4795 PURPOSE : Query of 3G QoS Profile (Minimum)
4796 */
4797 GLOBAL T_ATI_RSLT queatPlusCGEQMIN (char *cl, UBYTE srcId)
4798 {
4799 char *me="+CGEQMIN: ";
4800 T_PS_min_qos pdef_qos;
4801 U8 cid;
4802 BOOL qos_valid;
4803
4804 TRACE_FUNCTION("queatPlusCGEQMIN ()");
4805 #ifdef FF_ATI_BAT
4806 {
4807 T_BAT_cmd_send cmd;
4808 T_BAT_no_parameter dummy;
4809
4810 cmd.ctrl_params = BAT_CMD_SET_PLUS_CGEQMIN;
4811 dummy.bat_dummy = 0xFF;
4812 cmd.params.ptr_set_plus_cgeqmin = &dummy;
4813 bat_send(ati_bat_get_client(srcId), &cmd);
4814 return(ATI_EXCT);
4815 }
4816 #else
4817
4818 for ( cid = PDP_CONTEXT_CID_MIN; cid <= PDP_CONTEXT_CID_MAX; cid++ )
4819 {
4820 if (qAT_PlusCGEQMIN ((T_ACI_CMD_SRC)srcId, cid, &qos_valid, &pdef_qos) EQ AT_CMPL)
4821 {
4822 if (qos_valid)
4823 {
4824 /* Format the return string with the Release 99 QoS */
4825 sprintf(g_sa,"%s%hd", me, cid);
4826
4827 /* Format the return string with the Release 99 QoS */
4828 sprintf(g_sa,"%s%hd,%d,%d,%d,%d,%d,%d,%d,\"%dE%d\",\"%dE%d\",%d,%d,%d", me, cid,
4829 pdef_qos.qos_r99.tc, /*< traffic class */
4830 pdef_qos.qos_r99.max_rate_ul, /*< max bit-rate uplink */
4831 pdef_qos.qos_r99.max_rate_dl, /*< max bit-rate downlink */
4832 pdef_qos.qos_r99.guar_br_ul, /*< guaranteed bit-rate uplink */
4833 pdef_qos.qos_r99.guar_br_dl, /*< guaranteed bit-rate downlink */
4834 pdef_qos.qos_r99.order, /*< delivery order */
4835 pdef_qos.qos_r99.max_sdu, /*< max SDU size */
4836 pdef_qos.qos_r99.sdu_err_ratio.ratio_mant, /*< SDU error ratio (format is the same as ber) */
4837 pdef_qos.qos_r99.sdu_err_ratio.ratio_exp, /*< */
4838 pdef_qos.qos_r99.ber.ratio_mant, /*< Residual bit error ratio (ratio_mant E ratio_exp */
4839 pdef_qos.qos_r99.ber.ratio_exp, /*< (Ex. 10E2) */
4840 pdef_qos.qos_r99.del_err_sdu, /*< delivery of erroneous SDU */
4841 pdef_qos.qos_r99.xfer_delay, /*< transfer delay */
4842 pdef_qos.qos_r99.handling_pri); /*< traffic handling priority */
4843
4844 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
4845 }
4846 }
4847 else
4848 {
4849 /* AT_FAIL has been returned */
4850 cmdCmeError(CME_ERR_Unknown); /* The command is invalid for srcId */
4851 return (ATI_FAIL);
4852 }
4853 }
4854 return (ATI_CMPL);
4855 #endif /* FF_ATI_BAT */
4856 }
4857
4858 /*
4859 +--------------------------------------------------------------------+
4860 | PROJECT : UMTS MODULE : ATI_GPRS |
4861 | STATE : finished ROUTINE : tesatPlusCGEQNEG |
4862 +--------------------------------------------------------------------+
4863
4864 PURPOSE : Test function for 3G QoS Profile (Negotiated)
4865 Return cids for all active contexts.
4866 */
4867 GLOBAL T_ATI_RSLT tesatPlusCGEQNEG (char *cl, UBYTE srcId)
4868 {
4869 char *me="+CGEQNEG: ";
4870 BOOL context_activated, first_time = TRUE;
4871 U8 cid;
4872
4873 TRACE_FUNCTION("tesatPlusCGEQNEG ()");
4874
4875 for (cid = 1; cid<=PDP_CONTEXT_CID_MAX; cid++)
4876 {
4877 if (tAT_PlusCGEQNEG_CGCMOD ((T_ACI_CMD_SRC)srcId, cid, &context_activated) EQ AT_CMPL)
4878 {
4879 if (context_activated)
4880 {
4881 if (first_time)
4882 {
4883 /* First time: Place command name and no comma in front of cid */
4884 sprintf(g_sa,"%s%d", me, cid);
4885 first_time = FALSE;
4886 }
4887 else
4888 {
4889 /* Subsequent time: Append sa with ",<cid>" */
4890 sprintf(g_sa,"%s,%d", g_sa, cid);
4891 }
4892 }
4893 }
4894 else
4895 {
4896 /* AT_FAIL has been returned */
4897 cmdCmeError(CME_ERR_Unknown);
4898 return (ATI_FAIL);
4899 }
4900 }
4901 if (!first_time)
4902 {
4903 /* Only send something if any contexts were activated (first_time NEQ TRUE) */
4904 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
4905 }
4906
4907 return (ATI_CMPL);
4908 }
4909
4910 /*
4911 +--------------------------------------------------------------------+
4912 | PROJECT : UMTS MODULE : ATI_GPRS |
4913 | STATE : finished ROUTINE : tesatPlusCGCMOD |
4914 +--------------------------------------------------------------------+
4915
4916 PURPOSE : Test function for 3G Context Modifify command.
4917 Return cids for all active contexts.
4918 */
4919 GLOBAL T_ATI_RSLT tesatPlusCGCMOD (char *cl, UBYTE srcId)
4920 {
4921 char *me="+CGCMOD: ";
4922 BOOL context_activated, first_time = TRUE;
4923 U8 cid;
4924
4925 TRACE_FUNCTION("tesatPlusCGCMOD ()");
4926
4927 for (cid = PDP_CONTEXT_CID_MIN; cid <= PDP_CONTEXT_CID_MAX; cid++)
4928 {
4929 if (tAT_PlusCGEQNEG_CGCMOD ((T_ACI_CMD_SRC)srcId, cid, &context_activated) EQ AT_CMPL)
4930 {
4931 if (context_activated)
4932 {
4933 if (first_time)
4934 {
4935 /* First time: Place command name and no comma in front of cid */
4936 sprintf(g_sa,"%s%d", me, cid);
4937 first_time = FALSE;
4938 }
4939 else
4940 {
4941 /* Subsequent time: Append sa with ",<cid>" */
4942 sprintf(g_sa,"%s,%d", g_sa, cid);
4943 }
4944 }
4945 }
4946 else
4947 {
4948 /* AT_FAIL has been returned */
4949 cmdCmeError(CME_ERR_Unknown);
4950 return (ATI_FAIL);
4951 }
4952 }
4953 if (!first_time)
4954 {
4955 /* Only send something if any contexts were activated (first_time NEQ TRUE) */
4956 io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
4957 }
4958
4959 return (ATI_CMPL);
4960 }
4961
4962 #endif /* REL99 */
4963
4964 #endif /* GPRS */
4965