comparison g23m/condat/ms/src/aci/cmh_sms.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
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 : This module implements the set fuinctions related to the
18 | protocol stack adapter for GPRS session management ( SM ).
19 +-----------------------------------------------------------------------------
20 */
21
22 #if defined (GPRS) && defined (DTI)
23
24 #ifndef CMH_SMS_C
25 #define CMH_SMS_C
26 #endif
27
28 #include "aci_all.h"
29
30 /*==== INCLUDES ===================================================*/
31 #include "dti.h" /* functionality of the dti library */
32 #include "aci_cmh.h"
33 #include "ati_cmd.h"
34 #include "aci_cmd.h"
35 #include "aci_io.h"
36
37 #include "dti_conn_mng.h"
38 #include "dti_cntrl_mng.h"
39
40 #include "gaci.h"
41 #include "gaci_cmh.h"
42 #include "psa.h"
43 #include "psa_sm.h"
44 #include "psa_gppp.h"
45 #include "psa_gmm.h"
46 #include "psa_tcpip.h"
47
48 #include "cmh.h"
49 #include "cmh_sm.h"
50 #include "cmh_gppp.h"
51 #include "cmh_gmm.h"
52 #include "gaci_srcc.h"
53 #include "aci_mem.h"
54 #include "phb.h"
55 #include "wap_aci.h"
56
57 /*==== CONSTANTS ==================================================*/
58
59 /*==== EXPORT =====================================================*/
60
61 /*==== VARIABLES ==================================================*/
62
63 /*==== FUNCTIONS ==================================================*/
64 LOCAL void string_to_dns(CHAR* dns, ULONG *dns_long);
65 /*
66 +--------------------------------------------------------------------+
67 | PROJECT : GSM-PS (8441) MODULE : CMH_SMS |
68 | STATE : finnished ROUTINE : sAT_PlusCGQREQ |
69 +--------------------------------------------------------------------+
70
71 PURPOSE : This is the functional counterpart to the +CGQREQ= AT
72 command which sets the requested QOS.
73 */
74 GLOBAL T_ACI_RETURN sAT_PlusCGQREQ
75 ( T_ACI_CMD_SRC srcId, SHORT cid ,T_QOS *qos)
76 {
77 T_CONTEXT_STATE c_state; /* state of context */
78
79
80 TRACE_FUNCTION ("sAT_PlusCGQREQ()");
81
82 /*
83 *-------------------------------------------------------------------
84 * check entity status
85 *-------------------------------------------------------------------
86 */
87 if( smEntStat.curCmd NEQ AT_CMD_NONE )
88
89 return( AT_BUSY );
90
91 /*
92 *-------------------------------------------------------------------
93 * check parameter
94 *-------------------------------------------------------------------
95 */
96 if ( (cid < GPRS_CID_OMITTED) || (cid >= GPRS_CID_INVALID) )
97 {
98 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
99 return AT_FAIL;
100 }
101
102 if ( qos )
103 {
104 if ( /* qos->preced < GPRS_QOS_OMITTED || */ qos->preced > 3 )
105 {
106 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
107 return( AT_FAIL );
108 }
109
110 if ( /* qos->delay < GPRS_QOS_OMITTED || */ qos->delay > 4 )
111 {
112 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
113 return( AT_FAIL );
114 }
115 if ( /* qos->relclass < GPRS_QOS_OMITTED || */ qos->relclass > 5 )
116 {
117 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
118 return( AT_FAIL );
119 }
120 if ( /* qos->peak < GPRS_QOS_OMITTED || */ qos->peak > 9 )
121 {
122 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
123 return( AT_FAIL );
124 }
125 if ( (/* qos->mean < GPRS_QOS_OMITTED || */ qos->mean > 18) && qos->mean NEQ 31 )
126 {
127 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
128 return( AT_FAIL );
129 }
130 }
131
132 /*
133 *-------------------------------------------------------------------
134 * process parameter
135 *-------------------------------------------------------------------
136 */
137 if (cid EQ GPRS_CID_OMITTED )
138 /*
139 * cid omitted: A special form of the set command that is not defined in the Spec.
140 * This set the default value of QoS.
141 */
142 {
143 cmhSM_change_def_QOS(qos);
144
145 }
146 else
147 {
148 c_state = get_state_over_cid( cid );
149
150 if ( !qos || (qos->preced EQ GPRS_QOS_OMITTED &&
151 qos->delay EQ GPRS_QOS_OMITTED &&
152 qos->relclass EQ GPRS_QOS_OMITTED &&
153 qos->peak EQ GPRS_QOS_OMITTED &&
154 qos->mean EQ GPRS_QOS_OMITTED ) )
155 { /* QoS omitted -> undefine the requested QOS */
156 if ( c_state NEQ CS_DEFINED )
157 {
158 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
159 return( AT_FAIL );
160 }
161
162 cmhSM_Set_default_QOS(cid);
163
164 }
165 else
166 { /* define the requested QOS */
167 if ( c_state NEQ CS_DEFINED )
168 {
169 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
170 return( AT_FAIL );
171 }
172
173 memcpy( &pdp_context[cid - 1].con.qos, qos, sizeof(T_QOS));
174 }
175 }
176
177 return AT_CMPL;
178 }
179
180 /*
181 +--------------------------------------------------------------------+
182 | PROJECT : GSM-PS (8441) MODULE : CMH_SMS |
183 | STATE : finnished ROUTINE : sAT_PlusCGQMIN |
184 +--------------------------------------------------------------------+
185
186 PURPOSE : This is the functional counterpart to the +CGQMIN= AT
187 command which sets the minimum acceptable QOS.
188 */
189 GLOBAL T_ACI_RETURN sAT_PlusCGQMIN
190 ( T_ACI_CMD_SRC srcId, SHORT cid ,T_QOS *qos)
191 {
192 T_CONTEXT_STATE c_state; /* state of context */
193
194 TRACE_FUNCTION ("sAT_PlusCGQMIN()");
195
196 /*
197 *-------------------------------------------------------------------
198 * check entity status
199 *-------------------------------------------------------------------
200 */
201 if( smEntStat.curCmd NEQ AT_CMD_NONE )
202
203 return( AT_BUSY );
204
205 /*
206 *-------------------------------------------------------------------
207 * check parameter
208 *-------------------------------------------------------------------
209 */
210 if ( (cid < GPRS_CID_OMITTED) || (cid >= GPRS_CID_INVALID) )
211 {
212 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
213 return AT_FAIL;
214 }
215
216 if ( qos )
217 {
218 if ( /* qos->preced < GPRS_QOS_OMITTED || */ qos->preced > 3 )
219 {
220 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
221 return( AT_FAIL );
222 }
223
224 if ( /* qos->delay < GPRS_QOS_OMITTED || */ qos->delay > 4 )
225 {
226 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
227 return( AT_FAIL );
228 }
229 if ( /* qos->relclass < GPRS_QOS_OMITTED || */ qos->relclass > 5 )
230 {
231 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
232 return( AT_FAIL );
233 }
234 if ( /* qos->peak < GPRS_QOS_OMITTED || */ qos->peak > 9 )
235 {
236 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
237 return( AT_FAIL );
238 }
239 if ( (/* qos->mean < GPRS_QOS_OMITTED || */ qos->mean > 18) && qos->mean NEQ 31 )
240 {
241 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
242 return( AT_FAIL );
243 }
244 }
245
246 /*
247 *-------------------------------------------------------------------
248 * process parameter
249 *-------------------------------------------------------------------
250 */
251 if (cid EQ GPRS_CID_OMITTED )
252 /*
253 * cid omitted: A special form of the set command that is not defined in the Spec.
254 * This set the default value of QoS.
255 */
256 {
257 cmhSM_change_def_QOS_min(qos);
258 }
259 else
260 {
261 c_state = get_state_over_cid( cid );
262
263 if ( !qos || (qos->preced EQ GPRS_QOS_OMITTED &&
264 qos->delay EQ GPRS_QOS_OMITTED &&
265 qos->relclass EQ GPRS_QOS_OMITTED &&
266 qos->peak EQ GPRS_QOS_OMITTED &&
267 qos->mean EQ GPRS_QOS_OMITTED ) )
268 { /* QoS omitted -> undefine the requested QOS */
269 if ( c_state NEQ CS_DEFINED )
270 {
271 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
272 return( AT_FAIL );
273 }
274
275 cmhSM_Set_default_QOS_min(cid);
276 }
277 else
278 { /* define the requested QOS */
279 if ( c_state NEQ CS_DEFINED )
280 {
281 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
282 return( AT_FAIL );
283 }
284
285 memcpy( &pdp_context[cid - 1].con.min_qos, qos, sizeof(T_QOS));
286 }
287
288 }
289
290 return AT_CMPL;
291 }
292
293 /*
294 +--------------------------------------------------------------------+
295 | PROJECT : GSM-PS (8441) MODULE : CMH_SMS |
296 | STATE : finnished ROUTINE : sAT_PlusCGDCONT |
297 +--------------------------------------------------------------------+
298
299 PURPOSE : This is the functional counterpart to the +CGDCONT= AT
300 command which sets the current setting for each context.
301
302 GACI Context Definition GSM - 7.60 10.2.1
303
304 Special case +CGDCONT=<n> undefines context n
305 is handled as separate function call
306
307 otherwise:
308
309 +CGDCONT=[<cid> [,<PDP_TYPE> [,<APN> [,<PDP_addr> [,<h_comp> [,<d_comp>]]]]]]
310
311 Issue of what happens if user changes data of an active context.
312
313 Take simple approach, do not renegotiate current context.
314 Undefinition is more complex, reject attempt if context is active?
315
316 Current pdp address is left alone and only reset when context is
317 explicitly undefined.
318 See GSM 7.60 10.2.7.
319
320 */
321 GLOBAL T_ACI_RETURN sAT_PlusCGDCONT ( T_ACI_CMD_SRC srcId, SHORT cid, T_GPRS_CONT_REC *inputCtxt)
322 {
323 T_CONTEXT_STATE c_state; /* state of context */
324 SHORT state = 0;
325
326 TRACE_FUNCTION ("sAT_PlusCGDCONT()");
327
328 /*
329 *-------------------------------------------------------------------
330 * check parameter
331 *-------------------------------------------------------------------
332 */
333 /* Daniel : to convert the lower-case "ip"
334 to the upper-case "IP" as a pdp type */
335 if (!strcmp(inputCtxt->pdp_type, "ip"))
336 strcpy(inputCtxt->pdp_type, "IP");
337 if ( (cid < GPRS_CID_OMITTED) || (cid >= GPRS_CID_INVALID) )
338 {
339 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
340 return AT_FAIL;
341 }
342
343 if ( inputCtxt->d_comp < CGDCONT_D_COMP_OMITTED || inputCtxt->d_comp >= CGDCONT_D_COMP_INVALID )
344 {
345 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
346 return( AT_FAIL );
347 }
348
349 /* right now data compression is not supported, remove this block if enabled in the future */
350 if ( inputCtxt->d_comp EQ CGDCONT_D_COMP_ON )
351 {
352 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
353 return( AT_FAIL );
354 }
355
356 if ( inputCtxt->h_comp < CGDCONT_H_COMP_OMITTED || inputCtxt->h_comp >= CGDCONT_H_COMP_INVALID )
357 {
358 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
359 return( AT_FAIL );
360 }
361
362 /*
363 *-------------------------------------------------------------------
364 * A special form of set command
365 *-------------------------------------------------------------------
366 */
367 if ( !(cid NEQ GPRS_CID_OMITTED &&
368 !*(inputCtxt->pdp_type) && !*(inputCtxt->apn) && !*(inputCtxt->pdp_addr) &&
369 inputCtxt->d_comp EQ CGDCONT_D_COMP_OMITTED && inputCtxt->h_comp EQ CGDCONT_H_COMP_OMITTED) )
370 {
371 /*
372 *-------------------------------------------------------------------
373 * check parameter
374 *-------------------------------------------------------------------
375 */
376 if ( !*(inputCtxt->pdp_type) && *(inputCtxt->pdp_addr) )
377 {
378 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
379 return AT_FAIL;
380 }
381
382 if ( *(inputCtxt->pdp_addr) && *(inputCtxt->pdp_type) )
383 if ( !cmhSM_pdp_addr_well_formed( cmhSM_transform_pdp_type( inputCtxt->pdp_type ), inputCtxt->pdp_addr ) )
384 {
385 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
386 return AT_FAIL;
387 }
388
389 if ( *(inputCtxt->apn) )
390 if ( !cmhSM_apn_well_formed( inputCtxt->apn ) )
391 {
392 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
393 return AT_FAIL;
394 }
395
396 /*
397 *-------------------------------------------------------------------
398 * default parameter
399 *-------------------------------------------------------------------
400 */
401 if ( inputCtxt->d_comp EQ CGDCONT_D_COMP_OMITTED )
402 inputCtxt->d_comp = CGDCONT_D_COMP_OFF;
403
404 if ( inputCtxt->h_comp EQ CGDCONT_H_COMP_OMITTED )
405 inputCtxt->h_comp = CGDCONT_H_COMP_OFF;
406
407 if ( cid EQ GPRS_CID_OMITTED )
408 {
409 do
410 {
411 c_state = get_state_over_cid( ++ cid );
412 }
413 while ( cid < GPRS_CID_INVALID && c_state NEQ CS_UNDEFINED );
414
415 if( c_state NEQ CS_UNDEFINED )
416 {
417 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
418 return( AT_FAIL );
419 }
420 }
421
422 if ( !*(inputCtxt->pdp_type) )
423 strcpy(inputCtxt->pdp_type, "IP");
424
425 state = 1;
426 }
427
428 /*
429 *-------------------------------------------------------------------
430 * process parameter
431 *-------------------------------------------------------------------
432 */
433 c_state = get_state_over_cid( cid );
434
435 switch ( state )
436 {
437
438 case 0: /* undefine a PDP context */
439 if ( c_state NEQ CS_DEFINED )
440 {
441 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow );
442 return( AT_FAIL );
443 }
444
445 set_state_over_cid( cid, CS_UNDEFINED );
446
447 break;
448 case 1: /* define a PDP context */
449 switch(c_state)
450 {
451 /* every time allowed */
452 case CS_INVALID_STATE:
453 case CS_UNDEFINED:
454 case CS_DEFINED:
455 c_state = CS_DEFINED;
456 break;
457 /* allowed during context deactivation, but
458 WITHOUT state change */
459 case CS_ABORT_ESTABLISH:
460 case CS_DEACTIVATE_NORMAL:
461 case CS_BREAKDOWN_LINK_NORMAL:
462 case CS_BREAKDOWN_LINK_ERROR:
463 case CS_CONTEXT_REACTIVATION_1:
464 case CS_CONTEXT_REACTIVATION_2:
465 break;
466 /* Not allowed during context activation or
467 for activated context */
468 case CS_ATTACHING_AFTER_UNDEF:
469 case CS_ATTACHING_AFTER_DEF:
470 case CS_ESTABLISH_1:
471 case CS_ESTABLISH_2:
472 case CS_ESTABLISH_3:
473 case CS_WAITS_FOR_ACTIVATING:
474 case CS_ACTIVATING:
475 case CS_ACTIVATED:
476 case CS_DATA_LINK:
477 default:
478 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow );
479 return( AT_FAIL );
480 }
481
482 sAT_PlusCGDCONT_exec(srcId, cid, inputCtxt);
483 set_state_over_cid( cid, c_state );
484
485 break;
486 }
487
488 return AT_CMPL;
489 }
490
491 GLOBAL void sAT_PlusCGDCONT_exec ( T_ACI_CMD_SRC srcId, SHORT cid, T_GPRS_CONT_REC *inputCtxt)
492 {
493 T_GPRS_CONT_REC *con = &pdp_context[cid - 1].con;
494
495 TRACE_FUNCTION("sAT_PlusCGDCONT_exec");
496
497 memcpy(&con->apn, &inputCtxt->apn, sizeof( T_APN ));
498 memcpy(&con->pdp_type, &inputCtxt->pdp_type, sizeof( T_PDP_TYPE ));
499 memcpy(&con->pdp_addr, &inputCtxt->pdp_addr, sizeof( T_PDP_ADDRESS ));
500 con->d_comp = inputCtxt->d_comp;
501 con->h_comp = inputCtxt->h_comp;
502
503 if ( CS_DEFINED NEQ get_state_over_cid( cid ) )
504 {
505 cmhSM_Set_default_QOS ( cid );
506 cmhSM_Set_default_QOS_min ( cid );
507 }
508
509 set_state_over_cid( cid, CS_DEFINED );
510
511 }
512
513 /*
514 +--------------------------------------------------------------------+
515 | PROJECT : GSM-PS (8441) MODULE : CMH_SMS |
516 | STATE : finnished ROUTINE : sAT_PlusCGACT |
517 +--------------------------------------------------------------------+
518
519 PURPOSE : This is the functional counterpart to the +CGACT= AT
520 command which causes the cids specified in the cids list to
521 be activated or deactivated according to state.
522
523 An empty list will cause all defined contexts to be
524 activated or deactivated. If taken literally, this means that
525 if more contexts are defined than supported, each will be
526 activated, resulting in 'no resource' errors for the late ones
527 as the GACI SEM will reject requests for more activations
528 than it can cope with.
529
530 Note that the context is/are activated, but no CONNECT is sent
531 to the TE. This is the difference between ACT and DATA commands.
532
533 SMREG activate req does not need l2p to be sent, but in this case
534 the PDP config options are undefined (see below).
535
536 How does a DATA call bind these 'orphan' connections to a TE given
537 that a cid definition is a 'template' due to its ambiguity.
538
539 Practically, the activate form of this command has little meaning in the
540 case of PPP and loopback protocols (only ones supported at present).
541
542 Simplest option at the moment is not to support the activate form until
543 a protocol type is supported can make real use of it. The deactivate form
544 is of use in switching off a Loopback connection.
545
546 If activation before protocol establishment is supported, a NULL protocol service
547 will have to be provided which supplies a default (empty?) PCO list to SMREG for
548 activation and stores the network PCO response until a CGDATA is issued, must then
549 convert the protocol into that requested by the CGDATA command.
550 For future implementation
551
552
553 Other issues for multiple context activation :
554
555 - need to add a para onto GACI activate to tell it whether
556 to do a CONNECT or an OK callback on activation.
557
558 */
559 GLOBAL T_ACI_RETURN sAT_PlusCGACT
560 ( T_ACI_CMD_SRC srcId, T_CGACT_STATE state, SHORT *cids )
561 {
562 T_CONTEXT_STATE ctx_state;
563 SHORT i = 0, j = 0;
564 int ret_val;
565 TRACE_FUNCTION ("sAT_PlusCGACT()");
566
567 /*
568 *-------------------------------------------------------------------
569 * check command source
570 *-------------------------------------------------------------------
571 */
572 if(!cmh_IsVldCmdSrc (srcId))
573 {
574 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
575 return( AT_FAIL );
576 }
577
578 /*
579 *-------------------------------------------------------------------
580 * check parameter
581 *-------------------------------------------------------------------
582 */
583 if ( (state < CGACT_STATE_OMITTED) || (state >= CGACT_STATE_INVALID) )
584 {
585 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
586 return AT_FAIL;
587 }
588
589 for (i = 0; cids[i] NEQ INVALID_CID; i++)
590 {
591 if ( (cids[i] < GPRS_CID_1 || cids[i] >= GPRS_CID_INVALID) || i >= MAX_CID_PLUS_EINS )
592 {
593 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
594 return( AT_FAIL );
595 }
596 }
597
598 /*
599 *-------------------------------------------------------------------
600 * default parameter
601 *-------------------------------------------------------------------
602 */
603 if ( state EQ CGACT_STATE_OMITTED )
604 { /* state is not optional */
605 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
606 return AT_FAIL;
607 }
608
609 /*
610 *-------------------------------------------------------------------
611 * enable +CGACT to deactivate a context during activation
612 *-------------------------------------------------------------------
613 */
614 if( CGACT_STATE_DEACTIVATED EQ state )
615 {
616 ret_val = cmhSM_deactivateContexts(srcId, cids);
617 switch(ret_val)
618 {
619 case AT_EXCT:
620 smEntStat.curCmd = AT_CMD_CGACT;
621 smEntStat.entOwn = srcId;
622 smShrdPrm.owner = (UBYTE) srcId;
623 return AT_EXCT;
624 default:
625 return ret_val;
626 }
627 }
628
629 /*
630 *-------------------------------------------------------------------
631 * check entity status
632 *-------------------------------------------------------------------
633 */
634 if( smEntStat.curCmd NEQ AT_CMD_NONE )
635 return( AT_BUSY );
636
637 if( gpppEntStat.curCmd EQ AT_CMD_CGDATA )
638 return( AT_BUSY );
639
640
641 /*
642 *-------------------------------------------------------------------
643 * process parameter
644 *-------------------------------------------------------------------
645 */
646
647 cid_pointer = 0;
648
649 if ( *cids EQ INVALID_CID ) /* all defined or activated contexts (dependent by state) */
650 {
651 for (i = 0; i < MAX_CID; i++)
652 {
653 if ( CS_DEFINED EQ get_state_over_cid((SHORT) (i + 1)) )
654 {
655 work_cids[j] = i + 1;
656 j++;
657 }
658 }
659 work_cids[j] = INVALID_CID;
660
661 if (!*work_cids)
662 return AT_CMPL;
663 }
664 else /* all declarated contexts */
665 {
666 /* copy cid list */
667 for (i = 0; cids[i] NEQ INVALID_CID; i++)
668 {
669 work_cids[i] = cids[i];
670 }
671 work_cids[i] = INVALID_CID;
672
673 for (j = 0; work_cids[j] NEQ INVALID_CID; j++)
674 {
675 ctx_state = get_state_over_cid( work_cids[j] );
676
677 if ( CS_UNDEFINED EQ ctx_state )
678 { /* context not defined */
679 sAT_PlusCGDCONT_exec (srcId, work_cids[j], &defaultCtx);
680 set_state_over_cid(work_cids[j], CS_UNDEFINED);
681 }
682 else if ( CS_DEFINED NEQ ctx_state )
683 {
684 cid_pointer = 0;
685 work_cids[0] = INVALID_CID;
686 return ( AT_FAIL );
687 }
688 }
689 }
690
691 /*
692 *-------------------------------------------------------------------
693 * check number of context
694 *-------------------------------------------------------------------
695 */
696 TRACE_EVENT("activating context!");
697 if ( TRUE NEQ srcc_reserve_sources( SRCC_NULL_SNDCP_LINK, j ) )
698 {
699 cid_pointer = 0;
700 *work_cids = 0;
701 return AT_FAIL;
702 }
703
704 smEntStat.curCmd = AT_CMD_CGACT;
705 smEntStat.entOwn = srcId;
706 smShrdPrm.owner = (UBYTE) srcId;
707
708 set_conn_param_on_all_working_cids( (UBYTE)srcId, DTI_ENTITY_NULL );
709 if (AT_FAIL EQ cmhSM_activate_context())
710 {
711 set_conn_param_on_all_working_cids( (UBYTE)srcId, DTI_ENTITY_INVALID );
712 smEntStat.curCmd = AT_CMD_NONE;
713 gpppEntStat.curCmd = AT_CMD_NONE;
714 cid_pointer = 0;
715 *work_cids = 0;
716 return AT_FAIL;
717 }
718
719 return AT_EXCT;
720 }
721
722 /*
723 +--------------------------------------------------------------------+
724 | PROJECT : GSM-PS (8441) MODULE : CMH_SMS |
725 | STATE : finnished ROUTINE : sAT_PlusCGDATA |
726 +--------------------------------------------------------------------+
727
728 PURPOSE : This is the functional counterpart to the +CGDATA= AT
729 command which establish the communication.
730 */
731 GLOBAL T_ACI_RETURN sAT_PlusCGDATA ( T_ACI_CMD_SRC srcId, char *L2P, SHORT *cids )
732 {
733 SHORT j = 0;
734 T_ACI_RETURN retCd = AT_CMPL; /* holds return code */
735 T_DTI_ENTITY_ID connectToEntity = DTI_ENTITY_INVALID;
736
737 TRACE_FUNCTION ("sAT_PlusCGDATA()");
738
739 /*
740 *-------------------------------------------------------------------
741 * check command source
742 *-------------------------------------------------------------------
743 */
744 if(!cmh_IsVldCmdSrc (srcId))
745 {
746 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
747 return( AT_FAIL );
748 }
749
750
751 /*
752 *-------------------------------------------------------------------
753 * check entity status
754 *-------------------------------------------------------------------
755 */
756 if( smEntStat.curCmd NEQ AT_CMD_NONE )
757 return( AT_BUSY );
758
759 if( gpppEntStat.curCmd NEQ AT_CMD_NONE )
760 return( AT_BUSY );
761
762 if (pb_get_fdn_mode () EQ FDN_ENABLE)
763 {
764 if (pb_check_fdn (0, (const UBYTE *)"*99#") NEQ PHB_OK)
765 {
766 TRACE_EVENT("sAT_PlusCGDATA: Entry not found in FDN, GPRS not allowed.");
767 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow);
768 return (AT_FAIL);
769 }
770 TRACE_EVENT("sAT_PlusCGDATA: Entry found in FDN, GPRS allowed.");
771 }
772
773 /*
774 *-------------------------------------------------------------------
775 * check parameter
776 *-------------------------------------------------------------------
777 */
778 /*
779 * in maximum 1 cid allowed
780 */
781 if ( GPRS_CID_OMITTED NEQ cids[0] &&
782 GPRS_CID_OMITTED NEQ cids[1] )
783 {
784 return AT_FAIL;
785 }
786
787
788 if ( L2P[0] EQ 0 )
789 strcpy (L2P, "PPP"); /* default value */
790
791 if ( !strcmp(L2P, "PPP"))
792 {
793 if ( TRUE NEQ srcc_reserve_sources( SRCC_PPPS_SNDCP_LINK, 1 ) )
794 return ( AT_FAIL );
795
796 connectToEntity = DTI_ENTITY_PPPS;
797 }
798 #if defined(FF_PKTIO) OR defined(FF_TCP_IP) OR defined(FF_PSI)
799 else if( !strcmp(L2P, "M-PKT") OR !strcmp(L2P, "M-IP"))
800 {
801 if ( TRUE NEQ srcc_reserve_sources( SRCC_PKTIO_SNDCP_LINK, 1 ) )
802 return ( AT_FAIL );
803 }
804 #endif /* FF_PKTIO OR FF_TCP_IP OR FF_PSI */
805 else
806 {
807 return ( AT_FAIL );
808 }
809
810 /*
811 *-------------------------------------------------------------------
812 * process parameter
813 *-------------------------------------------------------------------
814 */
815 j = cmhSM_define_cid_list( srcId, cids );
816
817 if ( !j )
818 return( AT_FAIL );
819
820 /*
821 *-------------------------------------------------------------------
822 * process function
823 *-------------------------------------------------------------------
824 */
825 smShrdPrm.direc = DIREC_MO;
826
827 set_conn_param_on_working_cid( (UBYTE)srcId, connectToEntity );
828
829 if( DTI_ENTITY_PPPS EQ connectToEntity )
830 {
831 retCd = cmhGMM_attach_if_necessary( srcId, AT_CMD_CGDATA );
832 gpppEntStat.curCmd = AT_CMD_CGDATA;
833 gpppEntStat.entOwn = srcId;
834 gpppShrdPrm.owner = (UBYTE) srcId;
835 }
836 else if( DTI_ENTITY_INVALID EQ connectToEntity )
837 {
838 smEntStat.curCmd = AT_CMD_CGDATA;
839 smEntStat.entOwn = srcId;
840 smShrdPrm.owner = (UBYTE) srcId;
841 }
842
843 if ( retCd EQ AT_CMPL )
844 cmhSM_data_link_context();
845 else
846 {
847 if ( retCd EQ AT_EXCT )
848 switch ( get_state_working_cid() )
849 {
850 case CS_DEFINED:
851 set_state_working_cid( CS_ATTACHING_AFTER_DEF );
852 break;
853 case CS_UNDEFINED:
854 set_state_working_cid( CS_ATTACHING_AFTER_UNDEF );
855 break;
856 }
857 else
858 {
859 smEntStat.curCmd = AT_CMD_NONE;
860 gpppEntStat.curCmd = AT_CMD_NONE;
861 return AT_FAIL;
862 }
863 }
864
865 return AT_EXCT;
866 }
867
868 /*
869 +--------------------------------------------------------------------+
870 | PROJECT : GSM-PS (8441) MODULE : CMH_SMS |
871 | STATE : finnished ROUTINE : sAT_PlusCGPADDR |
872 +--------------------------------------------------------------------+
873
874 PURPOSE : This is the functional counterpart to the +CGPADDR= AT
875 command which give the PDP address back.
876 */
877 GLOBAL T_ACI_RETURN sAT_PlusCGPADDR ( T_ACI_CMD_SRC srcId, SHORT *cids, T_PDP_ADDRESS *pdp_adress )
878 {
879 SHORT cid = 1, index = 0;
880
881 TRACE_FUNCTION ("sAT_PlusCGPADDR()");
882
883 /*
884 *-------------------------------------------------------------------
885 * check entity status
886 *-------------------------------------------------------------------
887 */
888 if( smEntStat.curCmd NEQ AT_CMD_NONE )
889 return( AT_BUSY );
890
891 /*
892 *-------------------------------------------------------------------
893 * process parameter
894 *-------------------------------------------------------------------
895 */
896 if ( *cids EQ GPRS_CID_OMITTED )
897 {
898 /*
899 * the PDP addresse for all defined contexts are returned
900 */
901 for (cid = 1; cid <= MAX_CID; cid++)
902 {
903 cids[index] = cmhSM_get_pdp_addr_for_CGPADDR( cid, pdp_adress[index] );
904 if ( cids[index] NEQ INVALID_CID )
905 index ++;
906 }
907
908 cids[index] = INVALID_CID;
909 }
910 else
911 {
912 /*
913 * the PDP addresse for all specified contexts are returned
914 */
915 while ( cids[index] NEQ GPRS_CID_OMITTED )
916 {
917 if ( cids[index] < GPRS_CID_1 || cids[index] >= GPRS_CID_INVALID )
918 return AT_FAIL;
919
920 cmhSM_get_pdp_addr_for_CGPADDR( cids[index], pdp_adress[index] );
921 index ++;
922 }
923 cids[index] = INVALID_CID;
924 }
925
926 return AT_CMPL;
927 }
928
929 /*
930 +--------------------------------------------------------------------+
931 | PROJECT : GSM-PS (8441) MODULE : CMH_SMS |
932 | STATE : finnished ROUTINE : sAT_PlusCGAUTO |
933 +--------------------------------------------------------------------+
934
935 PURPOSE : This is the functional counterpart to the +CGAUTO= AT
936 command which set the mode of automatic response to
937 network request for PDP context activation.
938 */
939 GLOBAL T_ACI_RETURN sAT_PlusCGAUTO ( T_ACI_CMD_SRC srcId, T_CGAUTO_N n )
940 {
941 TRACE_FUNCTION ("sAT_PlusCGAUTO()");
942
943 /*
944 *-------------------------------------------------------------------
945 * check entity status
946 *-------------------------------------------------------------------
947 */
948 if( smEntStat.curCmd NEQ AT_CMD_NONE )
949
950 return( AT_BUSY );
951
952 /*
953 *-------------------------------------------------------------------
954 * check parameter
955 *-------------------------------------------------------------------
956 */
957 if ( (n < CGAUTO_N_OMITTED) || (n >= CGAUTO_N_INVALID) )
958 {
959 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
960 return AT_FAIL;
961 }
962
963 /*
964 *-------------------------------------------------------------------
965 * default parameter
966 *-------------------------------------------------------------------
967 */
968 if ( n EQ CGAUTO_N_OMITTED )
969 n = CGAUTO_N_MCM_GPRS_CSC;
970
971 /*
972 *-------------------------------------------------------------------
973 * process parameter
974 *-------------------------------------------------------------------
975 */
976 automatic_response_mode = (SHORT) n;
977
978 /* the MT shall attempt to perform a GPRS attach if it is not already attached */
979 if ( n EQ 1 )
980 {
981 return sAT_PlusCGATT ( srcId, CGATT_STATE_ATTACHED );
982 }
983 return AT_CMPL;
984 }
985
986 /*
987 +--------------------------------------------------------------------+
988 | PROJECT : GSM-PS (8441) MODULE : CMH_SMS |
989 | STATE : finnished ROUTINE : sAT_PlusCGANS |
990 +--------------------------------------------------------------------+
991
992 PURPOSE : This is the functional counterpart to the +CGANS= AT
993 command to respond manual to a network request for
994 PDP context activation.
995 */
996 GLOBAL T_ACI_RETURN sAT_PlusCGANS ( T_ACI_CMD_SRC srcId, SHORT response,
997 char *l2p, SHORT cid )
998 {
999 char L2P[MAX_L2P_LENGTH];
1000 T_GPRS_CONT_REC ctx = defaultCtx;
1001 SHORT i = 0, cid_list[2] = { INVALID_CID };
1002
1003 TRACE_FUNCTION ("sAT_PlusCGANS()");
1004
1005 /*
1006 *-------------------------------------------------------------------
1007 * check entity status
1008 *-------------------------------------------------------------------
1009 */
1010 if( smEntStat.curCmd NEQ AT_CMD_NONE )
1011
1012 return( AT_BUSY );
1013
1014 /*
1015 *-------------------------------------------------------------------
1016 * check command source
1017 *-------------------------------------------------------------------
1018 */
1019 if(!cmh_IsVldCmdSrc (srcId))
1020 {
1021 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1022 return( AT_FAIL );
1023 }
1024
1025 /*
1026 *-------------------------------------------------------------------
1027 * check parameter
1028 *-------------------------------------------------------------------
1029 */
1030 if ( (response <= CGANS_RESPONSE_OMITTED) || (response >= CGANS_RESPONSE_INVALID) )
1031 {
1032 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1033 return( AT_FAIL );
1034 }
1035
1036 /*
1037 *-------------------------------------------------------------------
1038 * default parameter
1039 *-------------------------------------------------------------------
1040 */
1041 if ( response EQ CGANS_RESPONSE_OMITTED )
1042 response = CGANS_RESPONSE_REJECT;
1043
1044 /*
1045 *-------------------------------------------------------------------
1046 * check call table
1047 *-------------------------------------------------------------------
1048 */
1049 if ( gprs_ct_index EQ current_gprs_ct_index )
1050 return ( AT_FAIL );
1051
1052 /*
1053 *-------------------------------------------------------------------
1054 * process parameter
1055 *-------------------------------------------------------------------
1056 */
1057 switch ( response )
1058 {
1059 case CGANS_RESPONSE_REJECT:
1060 psaSM_PDP_No_activate(gprs_call_table[current_gprs_ct_index].sm_ind.smreg_ti, SMREG_RC_ACT_REJ_UNSPEC);
1061
1062 cmhSM_next_call_table_entry();
1063
1064 #ifdef FF_ATI
1065 io_setRngInd ( IO_RING_OFF, CRING_TYP_NotPresent, CRING_TYP_NotPresent ); /* V.24 Ring Indicator Line */
1066 #endif
1067
1068 for( i = 0; i < CMD_SRC_MAX; i++ )
1069 {
1070 R_AT( RAT_CRING_OFF, i )( 0 );
1071 }
1072 return AT_CMPL;
1073 case CGANS_RESPONSE_ACCEPT:
1074 /*
1075 *-------------------------------------------------------------------
1076 * check number of context
1077 *-------------------------------------------------------------------
1078 */
1079 if ( TRUE NEQ srcc_reserve_sources( SRCC_PPPS_SNDCP_LINK, 1 ) )
1080 return ( AT_FAIL );
1081 /*
1082 *-------------------------------------------------------------------
1083 * check the last two command arguments
1084 *-------------------------------------------------------------------
1085 */
1086 if ( !gprs_call_table[current_gprs_ct_index].L2P[0] )
1087 {
1088 if ( l2p NEQ NULL )
1089 {
1090 if ( !*l2p )
1091 strcpy(L2P, "PPP");
1092 else
1093 {
1094 strncpy(L2P, l2p, MAX_L2P_LENGTH - 1);
1095 L2P[MAX_L2P_LENGTH - 1] = 0;
1096 }
1097 }
1098 else
1099 strcpy(L2P, "PPP");
1100
1101 if ( strcmp(L2P, "PPP") )
1102 {
1103 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1104 return( AT_FAIL );
1105 }
1106
1107 cid_list[0] = cid;
1108 }
1109 else
1110 {
1111 cid_list[0] = gprs_call_table[current_gprs_ct_index].cid;
1112 }
1113
1114 if ( 1 NEQ cmhSM_define_cid_list( srcId, cid_list ))
1115 return( AT_FAIL );
1116
1117 /*
1118 *-------------------------------------------------------------------
1119 * set the actually context data
1120 *-------------------------------------------------------------------
1121 */
1122 /* ctx.qos.preced = gprs_call_table[current_gprs_ct_index].sm_ind.smreg_qos.preced;
1123 ctx.qos.delay = gprs_call_table[current_gprs_ct_index].sm_ind.smreg_qos.delay;
1124 ctx.qos.relclass = gprs_call_table[current_gprs_ct_index].sm_ind.smreg_qos.relclass;
1125 ctx.qos.peak = gprs_call_table[current_gprs_ct_index].sm_ind.smreg_qos.peak;
1126 ctx.qos.mean = gprs_call_table[current_gprs_ct_index].sm_ind.smreg_qos.mean;*/
1127
1128 strncpy(ctx.apn,
1129 (const char *) gprs_call_table[current_gprs_ct_index].sm_ind.smreg_apn.buffer,
1130 gprs_call_table[current_gprs_ct_index].sm_ind.smreg_apn.c_buffer);
1131 if ( 4 EQ gprs_call_table[current_gprs_ct_index].sm_ind.pdp_address.c_buff )
1132 sprintf(ctx.pdp_addr, "%03hd.%03hd.%03hd.%03hd",
1133 gprs_call_table[current_gprs_ct_index].sm_ind.pdp_address.buff[0],
1134 gprs_call_table[current_gprs_ct_index].sm_ind.pdp_address.buff[1],
1135 gprs_call_table[current_gprs_ct_index].sm_ind.pdp_address.buff[2],
1136 gprs_call_table[current_gprs_ct_index].sm_ind.pdp_address.buff[3]);
1137 else
1138 return( AT_FAIL );
1139
1140 switch ( gprs_call_table[current_gprs_ct_index].sm_ind.pdp_type )
1141 {
1142 case X_121:
1143 return( AT_FAIL );
1144 case IP_V_4:
1145 strcpy(ctx.pdp_type, "IP");
1146 break;
1147 case IP_V_6:
1148 return( AT_FAIL );
1149 default:
1150 return( AT_FAIL );
1151 }
1152
1153 /*
1154 *-------------------------------------------------------------------
1155 * set some parameter of the call table
1156 *-------------------------------------------------------------------
1157 */
1158 if ( !gprs_call_table[current_gprs_ct_index].L2P[0])
1159 {
1160 /*lint -e{645} */ /* L2P is initialized within the same if-construct some lines above */
1161 strcpy (gprs_call_table[current_gprs_ct_index].L2P, L2P);
1162 gprs_call_table[current_gprs_ct_index].cid = *cid_list;
1163 }
1164
1165 sAT_PlusCGDCONT_exec (srcId, *cid_list, &ctx);
1166
1167 pdp_context[*cid_list - 1].smreg_ti = gprs_call_table[current_gprs_ct_index].sm_ind.smreg_ti;
1168
1169 /*
1170 *-------------------------------------------------------------------
1171 * process function
1172 *-------------------------------------------------------------------
1173 */
1174 gpppEntStat.curCmd = AT_CMD_CGDATA;
1175 gpppEntStat.entOwn = srcId;
1176 gpppShrdPrm.owner = (UBYTE) srcId;
1177
1178 smShrdPrm.direc = DIREC_MT;
1179
1180 set_conn_param_on_working_cid( (UBYTE)srcId, DTI_ENTITY_PPPS );
1181
1182 cmhSM_data_link_context();
1183 return AT_EXCT;
1184 }
1185
1186 return AT_FAIL;
1187 }
1188
1189 GLOBAL T_ACI_RETURN sAT_PlusCGEREP ( T_ACI_CMD_SRC srcId, T_CGEREP_MODE mode, T_CGEREP_BFR bfr )
1190 {
1191
1192 TRACE_FUNCTION ("sAT_PlusCGEREP()");
1193
1194 /*
1195 *-------------------------------------------------------------------
1196 * check entity status
1197 *-------------------------------------------------------------------
1198 */
1199 if( smEntStat.curCmd NEQ AT_CMD_NONE )
1200 return( AT_BUSY );
1201
1202 /*
1203 *-------------------------------------------------------------------
1204 * check first command argument
1205 *-------------------------------------------------------------------
1206 */
1207 if ( mode < CGEREP_MODE_OMITTED || mode >= CGEREP_MODE_INVALID )
1208 {
1209 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1210 return( AT_FAIL );
1211 }
1212
1213 if ( bfr < CGEREP_BFR_OMITTED || bfr >= CGEREP_BFR_INVALID )
1214 {
1215 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1216 return( AT_FAIL );
1217 }
1218
1219 /*
1220 *-------------------------------------------------------------------
1221 * process parameter
1222 *-------------------------------------------------------------------
1223 */
1224
1225 if ( mode NEQ CGEREP_MODE_OMITTED )
1226 ati_user_output_cfg[srcId].CGEREP_mode = mode;
1227
1228 if ( bfr NEQ CGEREP_BFR_OMITTED )
1229 ati_user_output_cfg[srcId].CGEREP_bfr = bfr;
1230
1231 switch ( mode )
1232 {
1233 case CGEREP_MODE_BUFFER:
1234 case CGEREP_MODE_DICARD_RESERVED:
1235 srcId_cb = srcId;
1236 cmhSM_cgerep_buffer ( );
1237 break;
1238 case CGEREP_MODE_BUFFER_RESERVED:
1239 break;
1240 case CGEREP_MODE_INVALID:
1241 case CGEREP_MODE_OMITTED:
1242 default:
1243 break;
1244 }
1245
1246 return AT_CMPL;
1247 }
1248
1249 #ifdef DTI
1250 GLOBAL T_ACI_RETURN sAT_PlusCGSMS ( T_ACI_CMD_SRC srcId, T_CGSMS_SERVICE service )
1251 {
1252 T_ACI_RETURN retCd = AT_CMPL; /* holds return code */
1253
1254 TRACE_FUNCTION ("sAT_PlusCGSMS()");
1255
1256 /*
1257 *-------------------------------------------------------------------
1258 * check entity status
1259 *-------------------------------------------------------------------
1260 */
1261 if( smEntStat.curCmd NEQ AT_CMD_NONE )
1262
1263 return( AT_BUSY );
1264
1265 /*
1266 *-------------------------------------------------------------------
1267 * check first command argument
1268 *-------------------------------------------------------------------
1269 */
1270 if ( service < CGSMS_SERVICE_OMITTED || service >= CGSMS_SERVICE_INVALID )
1271 {
1272 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1273 return( AT_FAIL );
1274 }
1275
1276 /*
1277 *-------------------------------------------------------------------
1278 * process parameter
1279 *-------------------------------------------------------------------
1280 */
1281 if ( service EQ CGSMS_SERVICE_OMITTED )
1282 service = sm_cgsms_service;
1283
1284 if ( service NEQ sm_cgsms_service )
1285 {
1286 smEntStat.curCmd = AT_CMD_CGSMS;
1287 smEntStat.entOwn = srcId;
1288 smShrdPrm.owner = (UBYTE) srcId;
1289
1290 cmhSM_set_sms_service ( service );
1291
1292 retCd = AT_EXCT;
1293 }
1294
1295 return retCd;
1296 }
1297 #endif
1298 /*
1299 +--------------------------------------------------------------------+
1300 | PROJECT : GSM-PS (8441) MODULE : CMH_SMS |
1301 | STATE : finished ROUTINE : string_to_dns |
1302 +--------------------------------------------------------------------+
1303
1304 PURPOSE :
1305 */
1306 LOCAL void string_to_dns(CHAR* dns, ULONG *dns_long)
1307 {
1308 UBYTE dns_len = 4;
1309 CHAR dns_adrtest[3];
1310 UBYTE dns_adr [4];
1311 UBYTE i = 0;
1312
1313 memset(&dns_adrtest,0,dns_len-1);
1314 memset(&dns_adr,0,dns_len);
1315
1316 if(strlen(dns) NEQ 0)
1317 {
1318 for(i=0;i<dns_len;i++)
1319 {
1320 strncpy(dns_adrtest,dns,dns_len-1);
1321 dns_adr[i] = (UBYTE)atoi(dns_adrtest);
1322 dns = dns+dns_len;
1323 }
1324 for(i=0;i<dns_len;i++)
1325 {
1326 *dns_long= *dns_long + dns_adr[i];
1327 if (i<(dns_len-1))
1328 *dns_long = *dns_long<<8;
1329 }
1330 }
1331 }
1332
1333 /*
1334 +--------------------------------------------------------------------+
1335 | PROJECT : GSM-PS (8441) MODULE : CMH_SMS |
1336 | STATE : finished ROUTINE : sAT_PercentCGPCO |
1337 +--------------------------------------------------------------------+
1338
1339 PURPOSE : This is the functional counterpart to the ?CGPCO= AT
1340 command to set protocol configuration options for the
1341 PDP context activation.
1342 */
1343
1344 GLOBAL T_ACI_RETURN sAT_PercentCGPCO (T_ACI_CMD_SRC srcId,
1345 SHORT cid, USHORT protocol,
1346 CHAR *user, CHAR *pwd, CHAR *dns1, CHAR *dns2)
1347 {
1348 USHORT pco_len = ACI_PCO_MAX_LEN;
1349 UBYTE *pco_array;
1350 int i, ret;
1351 ULONG dns_adr1 = 0x00000000;
1352 ULONG dns_adr2 = 0x00000000;
1353
1354
1355 TRACE_FUNCTION("sAT_PercentCGPCO");
1356
1357 ACI_MALLOC (pco_array, ACI_PCO_MAX_LEN);
1358
1359 string_to_dns(dns1,&dns_adr1);
1360 string_to_dns(dns2,&dns_adr2);
1361
1362 ret = utl_create_pco (pco_array, &pco_len,
1363 ACI_PCO_CONTENTMASK_AUTH |
1364 ACI_PCO_CONTENTMASK_DNS1 |
1365 ACI_PCO_CONTENTMASK_DNS2,
1366 ACI_PCO_CONFIG_PROT_PPP,
1367 protocol, (UBYTE*)user, (UBYTE*)pwd, dns_adr1, dns_adr2);
1368 if (ret < 0)
1369 {
1370 TRACE_EVENT_P1 ("sAT_PercentCGPCO(): invalid protocol=%d", protocol);
1371 ACI_MFREE (pco_array);
1372
1373 return (AT_FAIL);
1374 }
1375 if (cid EQ 0)
1376 {
1377 for (i = 0; i < MAX_CID; i++)
1378 {
1379 pdp_context[i].user_pco.len = (UBYTE)pco_len;
1380 memcpy (pdp_context[i].user_pco.pco, pco_array, pco_len);
1381 }
1382 }
1383 else
1384 {
1385 pdp_context[cid - 1].user_pco.len = (UBYTE)pco_len;
1386 memcpy (pdp_context[cid - 1].user_pco.pco, pco_array, pco_len);
1387 }
1388
1389 ACI_MFREE (pco_array);
1390
1391 return (AT_CMPL);
1392 }
1393
1394 /*
1395 +--------------------------------------------------------------------+
1396 | PROJECT : GPRS MODULE : CMH_SMS |
1397 | STATE : finished ROUTINE : qAT_PercentCGPCO |
1398 +--------------------------------------------------------------------+
1399
1400 PURPOSE : %CGPCO command
1401 * analyze network PCO a cid
1402 */
1403
1404 GLOBAL T_ACI_RETURN qAT_PercentCGPCO ( UBYTE srcId, ULONG * gateway,
1405 ULONG * dns1,ULONG * dns2, USHORT cid)
1406 {
1407
1408 TRACE_FUNCTION("qAT_PercentCGPCO");
1409
1410 switch(pdp_context[cid - 1].state)
1411 {
1412 case CS_ACTIVATED:
1413 case CS_ESTABLISH_3:
1414 case CS_DATA_LINK:
1415 utl_analyze_pco((UBYTE*)pdp_context[cid - 1].network_pco.pco, (USHORT)pdp_context[cid - 1].network_pco.len, dns1, dns2, gateway);
1416 break;
1417 default:
1418 break;
1419 }
1420 return (AT_CMPL);
1421 }
1422
1423
1424 #endif /* GPRS */
1425 /*==== EOF ========================================================*/