comparison gsm-fw/g23m-aci/aci/cmh_smq.c @ 775:eedbf248bac0

gsm-fw/g23m-aci subtree: initial import from LoCosto source
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 12 Oct 2014 01:45:14 +0000
parents
children
comparison
equal deleted inserted replaced
774:40a721fd9854 775:eedbf248bac0
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 provides the query functions related to the
18 | protocol stack adapter for GPRS session management ( SM ).
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifdef GPRS
23 #ifndef CMH_SMQ_C
24 #define CMH_SMQ_C
25 #endif
26
27 #include "aci_all.h"
28 #include "cl_inline.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
36 #include "pcm.h"
37
38 #include "dti_conn_mng.h"
39 #include "dti_cntrl_mng.h"
40
41 #include "gaci.h"
42 #include "gaci_cmh.h"
43 #include "psa.h"
44 #include "psa_sm.h"
45
46 #include "cmh.h"
47 #include "cmh_sm.h"
48
49 #include "psa_gmm.h"
50
51
52 #include "gaci_cmh.h"
53
54 /*==== CONSTANTS ==================================================*/
55
56 /*==== EXPORT =====================================================*/
57
58 /*==== VARIABLES ==================================================*/
59 EXTERN T_PDP_CONTEXT_INTERNAL *p_pdp_context_list;
60
61 /*==== FUNCTIONS ==================================================*/
62
63 /*
64 +--------------------------------------------------------------------+
65 | PROJECT : GPRS (8441) MODULE : CMH_SMQ |
66 | STATE : finished ROUTINE : qAT_PlusCGQREQ |
67 +--------------------------------------------------------------------+
68
69 PURPOSE : This is the functional counterpart to the +CGQREG? AT
70 command and returns current settings for the specified
71 PDP context. The function is called for all cids.
72 Note: The QoS returned is always in Release 97 format.
73 RETURNS: - AT_CMPL : Completed.
74 - AT_FAIL : Command not valid for srcId.
75 UPDATES: - qos: Quality of service for cid. Not updated if cid is undefined.
76 - qos_valid: Indicates whether qos is updated not.
77 */
78 GLOBAL T_ACI_RETURN qAT_PlusCGQREQ ( T_ACI_CMD_SRC srcId, U8 cid, BOOL *qos_valid, T_PS_qos *qos)
79 {
80 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
81
82 TRACE_FUNCTION ("qAT_PlusCGQREQ()");
83
84 /*
85 *-------------------------------------------------------------------
86 * check command source - should be Serial link ?
87 *-------------------------------------------------------------------
88 */
89 if ( !cmh_IsVldCmdSrc (srcId) )
90 {
91 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
92 return( AT_FAIL );
93 }
94
95 /*
96 *-------------------------------------------------------------------
97 * fill in parameters
98 *-------------------------------------------------------------------
99 */
100 if ( pdp_context_get_state_for_cid( cid ) EQ PDP_CONTEXT_STATE_DEFINED )
101 {
102 p_pdp_context_node = pdp_context_find_node_from_cid( cid );
103 if( p_pdp_context_node )
104 {
105 if( p_pdp_context_node->ctrl_qos EQ PS_is_R97 )
106 {
107 memcpy( qos, &p_pdp_context_node->qos.qos_r97, sizeof(T_PS_qos_r97) );
108 }
109 else
110 {
111 if( !cl_qos_convert_r99_to_r97( &p_pdp_context_node->qos.qos_r99, &qos->qos_r97 ) )
112 {
113 /* Failed to convert to Release 97. Never end here !!!! */
114 return( AT_FAIL );
115 }
116 }
117 *qos_valid = TRUE;
118 }
119 else
120 {
121 TRACE_ERROR( "ERROR: PDP context not found" );
122 *qos_valid = FALSE;
123 }
124 }
125 else
126 {
127 *qos_valid = FALSE;
128 }
129
130 return( AT_CMPL );
131 }
132
133
134 /*
135 +--------------------------------------------------------------------+
136 | PROJECT : GPRS (8441) MODULE : CMH_SMQ |
137 | STATE : finished ROUTINE : qAT_PlusCGQMIN |
138 +--------------------------------------------------------------------+
139
140 PURPOSE : This is the functional counterpart to the +CGQMIN? AT
141 command and returns current settings for the specified
142 PDP context. The function is called for all cids.
143 Note: The QoS returned is always in Release 97 format.
144 RETURNS: - AT_CMPL : Completed.
145 - AT_FAIL : Command not valid for srcId.
146 UPDATES: - qos: Quality of service for cid. Not updated if cid is undefined.
147 - qos_valid: Indicates whether qos is updated not.
148 */
149 GLOBAL T_ACI_RETURN qAT_PlusCGQMIN ( T_ACI_CMD_SRC srcId, U8 cid, BOOL *qos_valid, T_PS_qos *qos)
150 {
151 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
152
153 TRACE_FUNCTION ("qAT_PlusCGQMIN()");
154
155 /*
156 *-------------------------------------------------------------------
157 * check command source - should be Serial link ?
158 *-------------------------------------------------------------------
159 */
160 if ( !cmh_IsVldCmdSrc (srcId) )
161 {
162 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
163 return( AT_FAIL );
164 }
165
166 /*
167 *-------------------------------------------------------------------
168 * fill in parameters
169 *-------------------------------------------------------------------
170 */
171 if ( pdp_context_get_state_for_cid( cid ) EQ PDP_CONTEXT_STATE_DEFINED )
172 {
173 p_pdp_context_node = pdp_context_find_node_from_cid( cid );
174
175 if( p_pdp_context_node )
176 {
177 if( p_pdp_context_node->ctrl_min_qos EQ (T_PS_ctrl_min_qos)PS_is_R97 )
178 {
179 memcpy( qos, &p_pdp_context_node->min_qos, sizeof(T_PS_qos) );
180 }
181 else
182 {
183 if( !cl_qos_convert_r99_to_r97( &p_pdp_context_node->min_qos.qos_r99, &qos->qos_r97 ) )
184 {
185 /* Failed to convert to Release 97. Never end here !!!! */
186 return( AT_FAIL );
187 }
188 }
189 *qos_valid = TRUE;
190 }
191 else
192 {
193 TRACE_ERROR( "ERROR: PDP context not found" );
194 *qos_valid = FALSE;
195 }
196
197 }
198 else
199 {
200 *qos_valid = FALSE;
201 }
202 return( AT_CMPL );
203 }
204
205 /*
206 +--------------------------------------------------------------------+
207 | PROJECT : GPRS (8441) MODULE : CMH_SMQ |
208 | STATE : finished ROUTINE : qAT_PlusCGDCONT |
209 +--------------------------------------------------------------------+
210
211 PURPOSE : This is the functional counterpart to the +CGCONT? AT
212 command which returns current settings for each defined PDP context.
213 */
214
215 GLOBAL T_ACI_RETURN qAT_PlusCGDCONT( T_ACI_CMD_SRC srcId, T_PDP_CONTEXT *p_pdp_context_array, SHORT *cid_array )
216 {
217 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
218 int i = 0;
219
220 TRACE_FUNCTION ("qAT_PlusCGDSCONT()");
221
222 /*
223 *-------------------------------------------------------------------
224 * check command source - should be Serial link ?
225 *-------------------------------------------------------------------
226 */
227 if ( !cmh_IsVldCmdSrc( srcId ) )
228 {
229 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
230 return( AT_FAIL );
231 }
232
233 /*
234 *-------------------------------------------------------------------
235 * fill in parameters
236 *-------------------------------------------------------------------
237 */
238
239 p_pdp_context_node = p_pdp_context_list;
240
241 while( p_pdp_context_node AND i < PDP_CONTEXT_CID_MAX )
242 {
243
244 if( p_pdp_context_node->type EQ PDP_CONTEXT_TYPE_PRIMARY )
245 {
246
247 memcpy( &p_pdp_context_array[i], &p_pdp_context_node->attributes, sizeof(T_PDP_CONTEXT) );
248
249 // memcpy( &p_pdp_context_array[i].pdp_type, &p_pdp_context_node->attributes.pdp_type, sizeof(T_PDP_CONTEXT_PDP_TYPE) );
250 // memcpy( &p_pdp_context_array[i].pdp_apn, &p_pdp_context_node->attributes.pdp_apn, sizeof(T_PDP_CONTEXT_APN) );
251 // memcpy( &p_pdp_context_array[i].pdp_addr, &p_pdp_context_node->attributes.pdp_addr, sizeof(T_PDP_CONTEXT_ADDR) );
252
253 cid_array[i] = p_pdp_context_node->cid;
254 i++;
255
256 }
257
258 p_pdp_context_node = p_pdp_context_node->p_next;
259
260 }
261
262 return( AT_CMPL );
263 }
264
265
266 /*
267 +--------------------------------------------------------------------+
268 | PROJECT : UMTS MODULE : CMH_SMQ |
269 | STATE : ROUTINE : qAT_PlusCGDSCONT |
270 +--------------------------------------------------------------------+
271
272 PURPOSE : This is the functional counterpart to the +CGCONT? AT
273 command which returns current settings for each defined PDP context.
274 */
275
276 GLOBAL T_ACI_RETURN qAT_PlusCGDSCONT( T_ACI_CMD_SRC srcId, T_PDP_CONTEXT *p_pdp_context_array, U8 *cid_array )
277 {
278 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
279 int i = 0;
280
281 TRACE_FUNCTION ("qAT_PlusCGDSCONT()");
282
283 /*
284 *-------------------------------------------------------------------
285 * check command source - should be Serial link ?
286 *-------------------------------------------------------------------
287 */
288 if ( !cmh_IsVldCmdSrc( srcId ) )
289 {
290 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
291 return( AT_FAIL );
292 }
293
294 /*
295 *-------------------------------------------------------------------
296 * fill in parameters
297 *-------------------------------------------------------------------
298 */
299
300 p_pdp_context_node = p_pdp_context_list;
301
302 while( p_pdp_context_node AND i < PDP_CONTEXT_CID_MAX )
303 {
304
305 if( p_pdp_context_node->type EQ PDP_CONTEXT_TYPE_SECONDARY )
306 {
307 p_pdp_context_array[i].p_cid = p_pdp_context_node->attributes.p_cid;
308 p_pdp_context_array[i].d_comp = p_pdp_context_node->attributes.d_comp;
309 p_pdp_context_array[i].h_comp = p_pdp_context_node->attributes.h_comp;
310
311 cid_array[i] = p_pdp_context_node->cid;
312 i++;
313
314 }
315
316 p_pdp_context_node = p_pdp_context_node->p_next;
317
318 }
319
320 return( AT_CMPL );
321 }
322
323 GLOBAL T_ACI_RETURN qAT_PlusCGTFT( T_ACI_CMD_SRC srcId, U8 *cid_array )
324 {
325 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
326 int i = 0;
327
328 TRACE_FUNCTION ("qAT_PlusCGTFT()");
329
330 /*
331 *-------------------------------------------------------------------
332 * check command source - should be Serial link ?
333 *-------------------------------------------------------------------
334 */
335 if ( !cmh_IsVldCmdSrc( srcId ) )
336 {
337 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
338 return( AT_FAIL );
339 }
340
341 /*
342 *-------------------------------------------------------------------
343 * fill in parameters
344 *-------------------------------------------------------------------
345 */
346
347 p_pdp_context_node = p_pdp_context_list;
348
349 while( p_pdp_context_node AND i < PDP_CONTEXT_CID_MAX )
350 {
351 if( p_pdp_context_node->p_tft_pf )
352 {
353 cid_array[i++] = p_pdp_context_node->cid;
354 }
355
356 p_pdp_context_node = p_pdp_context_node->p_next;
357
358 }
359
360 return( AT_CMPL );
361 }
362
363 /*
364 +--------------------------------------------------------------------+
365 | PROJECT : GPRS (8441) MODULE : CMH_SMQ |
366 | STATE : finished ROUTINE : qAT_PlusCGACT |
367 +--------------------------------------------------------------------+
368
369 PURPOSE : This is the functional counterpart to the +CGACT? AT
370 command which returns current activation states for all defined PDP context.
371 */
372
373 GLOBAL T_ACI_RETURN qAT_PlusCGACT ( T_ACI_CMD_SRC srcId, BOOL *states, SHORT *cid )
374 {
375 T_PDP_CONTEXT_STATE state = PDP_CONTEXT_STATE_INVALID;
376 U8 i = 0,
377 j = 0;
378
379 TRACE_FUNCTION ("qAT_PlusCGACT()");
380
381 /*
382 *-------------------------------------------------------------------
383 * check command source - should be Serial link ?
384 *-------------------------------------------------------------------
385 */
386 if ( !cmh_IsVldCmdSrc (srcId) ) {
387 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
388 return( AT_FAIL );
389 }
390
391 /*
392 *-------------------------------------------------------------------
393 * fill in parameters
394 *-------------------------------------------------------------------
395 */
396 for ( i=0; i < PDP_CONTEXT_CID_MAX; i++ )
397 {
398 state = get_state_over_cid( (U8)(i+1) );
399 /*if ( state NEQ PDP_CONTEXT_STATE_UNDEFINED AND state NEQ PDP_CONTEXT_STATE_INVALID )*/
400 if ( state NEQ PDP_CONTEXT_STATE_INVALID )
401 {
402 if ( state EQ PDP_CONTEXT_STATE_ACTIVATED OR state EQ PDP_CONTEXT_STATE_DATA_LINK )
403 states[j] = TRUE;
404 else
405 states[j] = FALSE;
406
407 cid[j] = i + 1 ;
408 j++;
409 }
410 }
411 cid [j] = PDP_CONTEXT_CID_INVALID;
412
413 return( AT_CMPL );
414 }
415
416 /*
417 +--------------------------------------------------------------------+
418 | PROJECT : GPRS (8441) MODULE : CMH_SMQ |
419 | STATE : finished ROUTINE : qAT_PlusCGAUTO |
420 +--------------------------------------------------------------------+
421
422 PURPOSE : This is the functional counterpart to the +CGAUTO? AT
423 command which returns current mode of automatic response
424 to network requests.
425 */
426
427 GLOBAL T_ACI_RETURN qAT_PlusCGAUTO ( T_ACI_CMD_SRC srcId, T_CGAUTO_N *n)
428 {
429
430 TRACE_FUNCTION ("qAT_PlusCGAUTO()");
431
432 /*
433 *-------------------------------------------------------------------
434 * check command source - should be Serial link ?
435 *-------------------------------------------------------------------
436 */
437 if ( !cmh_IsVldCmdSrc (srcId) ) {
438 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
439 return( AT_FAIL );
440 }
441
442 /*
443 *-------------------------------------------------------------------
444 * fill in parameters
445 *-------------------------------------------------------------------
446 */
447 *n = (T_CGAUTO_N) automatic_response_mode;
448
449 return( AT_CMPL );
450 }
451
452
453 GLOBAL T_ACI_RETURN qAT_PlusCGEREP ( T_ACI_CMD_SRC srcId, T_CGEREP_MODE *mode, T_CGEREP_BFR *bfr )
454 {
455
456 TRACE_FUNCTION ("qAT_PlusCGEREP()");
457
458 /*
459 *-------------------------------------------------------------------
460 * check command source - should be Serial link ?
461 *-------------------------------------------------------------------
462 */
463 if ( !cmh_IsVldCmdSrc (srcId) ) {
464 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
465 return( AT_FAIL );
466 }
467
468 /*
469 *-------------------------------------------------------------------
470 * fill in parameters
471 *-------------------------------------------------------------------
472 */
473 *mode = sm_cgerep_mode;
474 *bfr = sm_cgerep_bfr;
475
476 return( AT_CMPL );
477 }
478
479 GLOBAL T_ACI_RETURN qAT_PlusCGSMS( T_ACI_CMD_SRC srcId, T_CGSMS_SERVICE *service )
480 {
481
482 TRACE_FUNCTION ("qAT_PlusCGSMS()");
483
484 /*
485 *-------------------------------------------------------------------
486 * check command source - should be Serial link ?
487 *-------------------------------------------------------------------
488 */
489 if ( !cmh_IsVldCmdSrc (srcId) ) {
490 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
491 return( AT_FAIL );
492 }
493
494 /*
495 *-------------------------------------------------------------------
496 * fill in parameters
497 *-------------------------------------------------------------------
498 */
499 *service = sm_cgsms_service;
500
501 return( AT_CMPL );
502 }
503
504 #ifdef REL99
505 /*
506 +--------------------------------------------------------------------+
507 | PROJECT : UMTS MODULE : CMH_SMQ |
508 | STATE : finished ROUTINE : qAT_PlusCGEQREQ |
509 +--------------------------------------------------------------------+
510
511 PURPOSE : This is the functional counterpart to the +CGEQREG? AT
512 command and returns current settings for the specified
513 PDP context. The function is called for all cids.
514 Note: The QoS returned is always in Release 99 format (3GPP).
515 RETURNS: - AT_CMPL : Completed.
516 - AT_FAIL : Command not valid for srcId.
517 UPDATES: - qos: Quality of service for cid. Not updated if cid is undefined.
518 - qos_valid: Indicates whether qos is updated not.
519 */
520 GLOBAL T_ACI_RETURN qAT_PlusCGEQREQ( T_ACI_CMD_SRC srcId, U8 cid, BOOL *qos_valid, T_PS_qos *qos)
521 {
522 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
523
524 TRACE_FUNCTION ("qAT_PlusCGEQREQ()");
525
526 p_pdp_context_node = pdp_context_find_node_from_cid( cid );
527 if( !p_pdp_context_node )
528 {
529 *qos_valid = FALSE;
530 return( AT_CMPL );
531 }
532
533 /*
534 *-------------------------------------------------------------------
535 * check command source - should be Serial link ?
536 *-------------------------------------------------------------------
537 */
538 if( !cmh_IsVldCmdSrc (srcId) )
539 {
540 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
541 return( AT_FAIL );
542 }
543
544 /*
545 *-------------------------------------------------------------------
546 * fill in parameters
547 *-------------------------------------------------------------------
548 */
549 if( get_state_over_cid(cid) EQ PDP_CONTEXT_STATE_DEFINED )
550 {
551 if( p_pdp_context_node->ctrl_qos EQ PS_is_R99 )
552 {
553 memcpy( qos, &p_pdp_context_node->qos, sizeof(T_PS_qos_r99) );
554 }
555 else
556 {
557 /* The QoS is in Release 97 format and must be converted first. */
558 if( !cl_qos_convert_r97_to_r99( &p_pdp_context_node->qos.qos_r97, &(qos->qos_r99)) )
559 {
560 /* Failed to convert to Release 99. Never end here !!!! */
561 return( AT_FAIL );
562 }
563 }
564 *qos_valid = TRUE;
565 }
566 else
567 {
568 *qos_valid = FALSE;
569 }
570
571 return( AT_CMPL );
572 }
573
574 /*
575 +--------------------------------------------------------------------+
576 | PROJECT : UMTS MODULE : CMH_SMQ |
577 | STATE : finished ROUTINE : qAT_PlusCGEQMIN |
578 +--------------------------------------------------------------------+
579
580 PURPOSE : This is the functional counterpart to the +CGEQMIN? AT
581 command and returns current settings for the specified
582 PDP context. The function is called for all cids.
583 The QoS returned is always in Release 99 format (3GPP).
584 RETURNS: - AT_CMPL : Completed.
585 - AT_FAIL : Command not valid for srcId.
586 UPDATES: - qos: Quality of service for cid. Not updated if cid is undefined.
587 - qos_valid: Indicates whether qos is updated not.
588 */
589 GLOBAL T_ACI_RETURN qAT_PlusCGEQMIN( T_ACI_CMD_SRC srcId, U8 cid, BOOL *qos_valid, T_PS_min_qos *qos)
590 {
591 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
592
593 TRACE_FUNCTION ("qAT_PlusCGEQMIN()");
594
595 p_pdp_context_node = pdp_context_find_node_from_cid( cid );
596 if( !p_pdp_context_node )
597 {
598 *qos_valid = FALSE;
599 return( AT_CMPL );
600 }
601
602
603 /*
604 *-------------------------------------------------------------------
605 * check command source - should be Serial link ?
606 *-------------------------------------------------------------------
607 */
608 if ( !cmh_IsVldCmdSrc (srcId) )
609 {
610 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
611 return( AT_FAIL );
612 }
613
614 /*
615 *-------------------------------------------------------------------
616 * fill in parameters
617 *-------------------------------------------------------------------
618 */
619 if ( get_state_over_cid(cid) EQ PDP_CONTEXT_STATE_DEFINED )
620 {
621 if( p_pdp_context_node->ctrl_min_qos EQ (T_PS_ctrl_min_qos)PS_is_R99 )
622 {
623 memcpy( qos, &p_pdp_context_node->min_qos, sizeof(T_PS_qos) );
624 }
625 else
626 {
627 /* The QoS is in Release 97 format and must be converted first. */
628 if( !cl_qos_convert_r97_to_r99(&p_pdp_context_node->min_qos.qos_r97, &qos->qos_r99) )
629 {
630 /* Failed to convert to Release 99. Never end here !!!! */
631 return( AT_FAIL );
632 }
633 }
634 *qos_valid = TRUE;
635 }
636 else
637 {
638 *qos_valid = FALSE;
639 }
640
641 return( AT_CMPL );
642 }
643 #endif /* REL99 */
644
645
646 #endif /* GPRS */
647 /*==== EOF ========================================================*/