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

src/g23m-aci: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 11 Oct 2016 02:02:43 +0000
parents
children
comparison
equal deleted inserted replaced
161:4557e2a9c18e 162:53929b40109c
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
4 | Modul : J:\g23m-aci\aci\gaci.c
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 :
18 +-----------------------------------------------------------------------------
19 */
20 #if defined (GPRS) && defined (DTI)
21
22 #ifndef GACI_C
23 #define GACI_C
24 #endif
25
26 #include "aci_all.h"
27 /*==== INCLUDES ===================================================*/
28 #include "dti.h" /* functionality of the dti library */
29 #include "aci_cmh.h"
30 #include "ati_cmd.h"
31 #include "aci_cmd.h"
32
33 #include "dti_conn_mng.h"
34
35 #include "gaci.h"
36 #include "gaci_cmh.h"
37 #include "psa.h"
38 #include "psa_sm.h"
39 #include "psa_gppp.h"
40 #include "psa_gmm.h"
41
42 #include "cmh.h"
43 #ifdef SIM_TOOLKIT
44 #include "psa_cc.h"
45 #include "psa_sat.h"
46 #include "cmh_sat.h"
47 #endif /* SIM_TOOLKIT */
48 #include "cmh_sm.h"
49 #include "cmh_gppp.h"
50 #include "cmh_gmm.h"
51 #include "gaci_srcc.h"
52
53 #include "aci_mem.h"
54
55 /*==== CONSTANTS ==================================================*/
56 static T_ACI_CMD_SRC _ATZ_srcId;
57
58 #ifdef FF_SAT_E
59 static USHORT SAT_error_cause = SAT_GPRS_INV_CAUSE;
60 #endif /* FF_SAT_E */
61
62 /*==== EXPORT =====================================================*/
63 GLOBAL T_ACI_CMD_SRC cmhSM_getSrcIdOfRunningCGACTDeactivation(U8 cid);
64
65 /*==== VARIABLES ==================================================*/
66 T_PDP_CONTEXT_INTERNAL *p_pdp_context_list;
67
68
69 /*==== PROTOTYPES =================================================*/
70 GLOBAL T_PDP_CONTEXT_INTERNAL *pdp_context_create_node( U8 cid );
71 GLOBAL int pdp_context_remove_node( U8 cid );
72 GLOBAL T_PDP_CONTEXT_INTERNAL *pdp_context_find_node_from_cid( U8 cid );
73 GLOBAL T_PDP_CONTEXT_INTERNAL *pdp_context_find_node_from_dti_id( U8 dti_id );
74 GLOBAL T_PDP_CONTEXT_INTERNAL *pdp_context_find_last_node ( void );
75 #ifdef REL99
76 GLOBAL T_TFT_INTERNAL *pdp_context_add_tft_pf ( U8 cid, U8 tft_pf_id );
77 GLOBAL BOOL pdp_context_del_tft_pf ( U8 cid, U8 tft_pf_id );
78 GLOBAL T_TFT_INTERNAL *pdp_context_find_tft_pf ( U8 cid, U8 tft_pf_id );
79 GLOBAL U8 pdp_context_get_no_of_tft_pfs( U8 cid );
80 GLOBAL void pdp_context_clear_tft_active_list( U8 cid );
81 //GLOBAL T_TFT_MODIFICATION pdp_context_compare_tft ( U8 cid );
82 //GLOBAL T_TFT_MODIFICATION pdp_context_get_modification_action( U8 cid );
83 #endif /* REL99 */
84 GLOBAL U8 pdp_context_check_if_nodes_exists( U8 *cid_array );
85 GLOBAL U8 pdp_context_validate_pdp_type ( U8 *cid_array, T_PDP_TYPE pdp_type );
86 /*=================================================================*/
87
88
89
90 /*
91 +----------------------------------------------------------------------+
92 | PROJECT : MODULE : gaci |
93 | ROUTINE : |
94 +----------------------------------------------------------------------+
95
96 PURPOSE :
97 */
98
99 GLOBAL void gaci_init ( void )
100 {
101 /* Init of intern variable */
102 _ATZ_srcId = CMD_SRC_NONE;
103
104 /* GPRS Init */
105 gpppEntStat.curCmd = AT_CMD_NONE;
106 gpppEntStat.entOwn = CMD_SRC_NONE;
107
108 cmhGMM_Init();
109 cmhSM_Init();
110
111 srcc_init();
112
113 gaci_reset();
114 }
115
116 GLOBAL void gaci_reset( void )
117 {
118 cmhSM_Reset();
119 }
120
121 GLOBAL void gaci_ATZ_reset( void )
122 {
123 cmhSM_ResetNonWorkingContexts();
124 }
125
126 GLOBAL void gaci_finit ( void )
127 {
128 /* here will be a functionality */
129 }
130
131 EXTERN T_ACI_RETURN sGsmAT_Z ( T_ACI_CMD_SRC srcId );
132
133 GLOBAL T_ACI_RETURN sGprsAT_Z ( T_ACI_CMD_SRC srcId )
134 {
135 SHORT cid_array[1] = { PDP_CONTEXT_CID_INVALID };
136
137 /*
138 *-------------------------------------------------------------------
139 * rejects waiting network requests for PDP context activation
140 *-------------------------------------------------------------------
141 */
142 if ( ( at.rngPrms.isRng EQ TRUE ) AND ( at.rngPrms.mode EQ CRING_MOD_Gprs) ) /* GPRS call */
143 {
144 /*
145 * brz patch: In the case of context reactivation over SMREG_PDP_ACTIVATE_IND with an used ti
146 * the GPRS ATZ command doesn't do anything!
147 *
148 * Why? Because the Windows Dial-Up Networking client send every time an ATZ after termination
149 * of the connection and with this a context reactivation was impossible.
150 */
151 if ( gprs_call_table[current_gprs_ct_index].reactivation EQ GCTT_NORMAL )
152 {
153 sAT_PlusCGANS(srcId, CGANS_RESPONSE_REJECT, NULL, PDP_CONTEXT_CID_OMITTED );
154 }
155 else
156 { /* Reactivation: stop GPRS ATZ */
157 return sGsmAT_Z ( srcId );
158 }
159 }
160 if ( AT_EXCT EQ sAT_PlusCGACT ( srcId, CGACT_STATE_DEACTIVATED, cid_array ))
161 {
162 _ATZ_srcId = srcId; /* hold source Id */
163 return( AT_EXCT );
164 }
165
166 srcId_cb = srcId;
167 gaci_ATZ_reset();
168 return sGsmAT_Z ( srcId );
169 }
170
171 LOCAL void endOfGprsAT_Z ( void )
172 {
173 srcId_cb = _ATZ_srcId;
174 gaci_ATZ_reset();
175 if ( AT_CMPL EQ sGsmAT_Z ( _ATZ_srcId ) )
176 {
177 R_AT( RAT_OK, _ATZ_srcId ) ( AT_CMD_Z );
178
179 /* log result */
180 cmh_logRslt ( _ATZ_srcId,
181 RAT_OK, AT_CMD_Z, -1, BS_SPEED_NotPresent, CME_ERR_NotPresent );
182 }
183
184 _ATZ_srcId = CMD_SRC_NONE;
185 }
186
187 GLOBAL BOOL gaci_isATZcmd ( void )
188 {
189 if ( _ATZ_srcId NEQ CMD_SRC_NONE )
190 {
191 endOfGprsAT_Z();
192 return TRUE;
193 }
194
195 return FALSE;
196 }
197
198 /*
199 +----------------------------------------------------------------------+
200 | PROJECT : UMTS MODULE : gaci |
201 | ROUTINE : gaci_get_cid_over_dti_id |
202 +----------------------------------------------------------------------+
203
204 PURPOSE :
205
206 */
207 GLOBAL SHORT gaci_get_cid_over_dti_id( UBYTE dti_id )
208 {
209 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
210
211 p_pdp_context_node = p_pdp_context_list;
212 while( p_pdp_context_node )
213 {
214 /* Check for the link_id_new also because it will be filled for TCPIP call */
215 if ( dti_id EQ EXTRACT_DTI_ID(p_pdp_context_node->internal_data.link_id) OR
216 dti_id EQ EXTRACT_DTI_ID(p_pdp_context_node->internal_data.link_id_uart) OR
217 dti_id EQ EXTRACT_DTI_ID(p_pdp_context_node->internal_data.link_id_new))
218
219 return p_pdp_context_node->cid;
220
221 p_pdp_context_node = p_pdp_context_node->p_next;
222 }
223
224 return PDP_CONTEXT_CID_INVALID;
225 }
226
227
228 GLOBAL SHORT gaci_get_cid_over_link_id ( T_DTI_CONN_LINK_ID link_id )
229 {
230 return gaci_get_cid_over_dti_id((UBYTE)EXTRACT_DTI_ID(link_id));
231 }
232
233
234
235 /*
236 +----------------------------------------------------------------------+
237 | PROJECT : - MODULE : gaci |
238 | ROUTINE : gaci_get_link_id_over_peer |
239 +----------------------------------------------------------------------+
240
241 PURPOSE : */
242
243 /*
244 * Assumption: there is only one connection between UPM and the peer
245 */
246 GLOBAL T_DTI_CONN_LINK_ID gaci_get_link_id_over_peer ( T_DTI_ENTITY_ID entity_id )
247 {
248 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
249
250 p_pdp_context_node = p_pdp_context_list;
251
252 while( p_pdp_context_node )
253 {
254 if( p_pdp_context_node->internal_data.entity_id EQ entity_id AND
255 p_pdp_context_node->internal_data.link_id NEQ DTI_LINK_ID_NOTPRESENT )
256 {
257 return p_pdp_context_node->internal_data.link_id;
258 }
259
260 p_pdp_context_node = p_pdp_context_node->p_next;
261 }
262 return DTI_LINK_ID_NOTPRESENT;
263 }
264
265
266
267 #ifdef FF_SAT_E
268 GLOBAL void gaci_SAT_err(USHORT cause)
269 {
270 SAT_error_cause = cause;
271 }
272 #endif /* FF_SAT_E */
273
274 GLOBAL void gaci_RAT_caller ( SHORT rat_id, SHORT cid, UBYTE cmdBuf, UBYTE cme_err )
275 {
276 T_ACI_CMD_SRC rat_owner = (T_ACI_CMD_SRC)get_owner_over_cid( (U8)cid );
277
278 TRACE_FUNCTION("gaci_RAT_caller()");
279
280 #ifdef FF_SAT_E
281 if ( !cmhSAT_OpChnGPRSPend( cid, OPCH_NONE ))
282 #endif /* FF_SAT_E */
283 {
284 switch ( rat_id )
285 {
286 case RAT_OK:
287 R_AT( RAT_OK, rat_owner ) ( cmdBuf );
288 break;
289 case RAT_CME:
290 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, cme_err ); /* align aciErrDesc to cme_err */
291 R_AT( RAT_CME, rat_owner ) ( cmdBuf, cme_err );
292 /* log result */
293 cmh_logRslt ( (T_ACI_CMD_SRC) rat_owner, RAT_CME, (T_ACI_AT_CMD) cmdBuf,
294 -1, BS_SPEED_NotPresent, (T_ACI_CME_ERR)cme_err );
295 break;
296 case RAT_NO_CARRIER:
297 if (!(cmhSM_getSrcIdOfRunningCGACTDeactivation((U8)cid) EQ rat_owner))
298 {
299 R_AT( RAT_NO_CARRIER, rat_owner ) ( cmdBuf, 0 );
300 }
301 /* log result */
302 cmh_logRslt ( (T_ACI_CMD_SRC) rat_owner, RAT_NO_CARRIER, (T_ACI_AT_CMD)cmdBuf,
303 (SHORT) 0, BS_SPEED_NotPresent,CME_ERR_NotPresent );
304 break;
305 }
306 }
307 #ifdef FF_SAT_E
308 else
309 {
310 /*
311 * SIM callback for SAT-class CE
312 */
313 switch ( rat_id )
314 {
315 case RAT_OK:
316 /* connection deactivated */
317 cmhSAT_OpChnGPRSStat(SAT_GPRS_ACT, SAT_GPRS_INV_CAUSE); /* no cause given by primitive */
318 break;
319 case RAT_CME:
320 if ( cmdBuf EQ AT_CMD_CGDATA )
321 { /*
322 * Attach before ATD (UPM <-> IP <-> UDP <-> SIM) fails
323 */
324 cmhSAT_OpChnGPRSStat(SAT_GPRS_ATT_FAILED, (UBYTE)SAT_error_cause);
325 }
326 else
327 { /* activate connection UPM <-> SIM fails */
328 cmhSAT_OpChnGPRSStat(SAT_GPRS_ACT_FAILED, (UBYTE)SAT_error_cause);
329 }
330 break;
331 case RAT_NO_CARRIER:
332 /* activate connection UPM <-> IP <-> UDP <-> SIM fails */
333 cmhSAT_OpChnGPRSStat(SAT_GPRS_ACT_FAILED, (UBYTE)SAT_error_cause);
334 break;
335 }
336 }
337 #endif /* FF_SAT_E */
338 }
339
340
341 /*
342 +----------------------------------------------------------------------------+
343 | PROJECT : UMTS MODULE : gaci |
344 | ROUTINE : pdp_context_create_node |
345 +----------------------------------------------------------------------------+
346
347 PURPOSE :
348
349 */
350 GLOBAL T_PDP_CONTEXT_INTERNAL *pdp_context_create_node( U8 cid )
351 {
352 T_PDP_CONTEXT_INTERNAL *p_new_pdp_context_node = NULL;
353 T_PDP_CONTEXT_INTERNAL *p_last_pdp_context_node = NULL;
354
355 TRACE_FUNCTION("pdp_context_create_node()");
356
357 if( !pdp_context_find_node_from_cid( cid ) )
358 {
359 /* No PDP context exist with same <cid> */
360 p_last_pdp_context_node = pdp_context_find_last_node();
361
362 if( p_last_pdp_context_node )
363 {
364 ACI_MALLOC( p_new_pdp_context_node, sizeof(T_PDP_CONTEXT_INTERNAL) );
365
366 if( p_new_pdp_context_node )
367 {
368 memset(p_new_pdp_context_node, 0x00, sizeof(T_PDP_CONTEXT_INTERNAL) );
369
370 p_new_pdp_context_node->cid = cid;
371 p_new_pdp_context_node->p_next = NULL;
372 p_new_pdp_context_node->tft_changed = FALSE;
373
374 /* As alborg code doesn't work on SN_SWITCH_REQ, they don't set the
375 values of link_id to 0xFF. But this is required in Berlin code.
376 */
377
378 p_new_pdp_context_node->internal_data.link_id = DTI_LINK_ID_NOTPRESENT;
379 /*p_new_pdp_context_node->internal_data.link_id_new = DTI_LINK_ID_NOTPRESENT;*/
380 p_new_pdp_context_node->internal_data.link_id_uart = DTI_LINK_ID_NOTPRESENT;
381
382 if( p_last_pdp_context_node EQ (T_PDP_CONTEXT_INTERNAL*) &p_pdp_context_list )
383 p_pdp_context_list = p_new_pdp_context_node;
384 else
385 p_last_pdp_context_node->p_next = p_new_pdp_context_node;
386
387 }
388 }
389 }
390
391 return p_new_pdp_context_node;
392
393 }
394
395
396 /*
397 +----------------------------------------------------------------------------+
398 | PROJECT : UMTS MODULE : gaci |
399 | ROUTINE : pdp_context_remove_node |
400 +----------------------------------------------------------------------------+
401
402 PURPOSE :
403
404 */
405 GLOBAL int pdp_context_remove_node( U8 cid )
406 {
407 SHORT result = 0;
408 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
409 T_PDP_CONTEXT_INTERNAL *p_old_pdp_context_node = NULL;
410
411 if( p_pdp_context_list )
412 {
413 if( p_pdp_context_list->cid NEQ cid )
414 {
415 p_pdp_context_node = p_pdp_context_list;
416
417 /* find PDP context node for given <cid> */
418
419 while( p_pdp_context_node->p_next AND p_pdp_context_node->p_next->cid NEQ cid )
420 {
421 p_pdp_context_node = p_pdp_context_node->p_next;
422 }
423
424 if( p_pdp_context_node->p_next->cid EQ cid )
425 {
426 p_old_pdp_context_node = p_pdp_context_node->p_next;
427 p_pdp_context_node->p_next = p_pdp_context_node->p_next->p_next;
428 ACI_MFREE( p_old_pdp_context_node );
429 result = cid;
430 }
431 }
432 else
433 {
434 p_old_pdp_context_node = p_pdp_context_list;
435
436 if( p_pdp_context_list->p_next )
437 {
438
439 p_pdp_context_list = p_pdp_context_list->p_next;
440 }
441 else
442 {
443 p_pdp_context_list = NULL;
444 }
445
446 ACI_MFREE( p_old_pdp_context_node );
447 }
448 result = cid;
449 }
450
451 return result;
452
453 }
454
455
456 /*
457 +----------------------------------------------------------------------------+
458 | PROJECT : UMTS MODULE : gaci |
459 | ROUTINE : pdp_context_find_node_from_cid |
460 +----------------------------------------------------------------------------+
461
462 PURPOSE :
463
464 */
465 GLOBAL T_PDP_CONTEXT_INTERNAL *pdp_context_find_node_from_cid( U8 cid )
466 {
467
468 T_PDP_CONTEXT_INTERNAL *p_found_pdp_context_node = NULL;
469 T_PDP_CONTEXT_INTERNAL *p_temp_pdp_context_node = NULL;
470
471 TRACE_EVENT("pdp_context_find_node_from_cid()");
472 if( p_pdp_context_list )
473 {
474 if( p_pdp_context_list->cid EQ cid )
475 {
476 p_found_pdp_context_node = p_pdp_context_list;
477 }
478 else
479 {
480 p_temp_pdp_context_node = p_pdp_context_list->p_next;
481
482 while( p_temp_pdp_context_node AND !p_found_pdp_context_node )
483 {
484 if( p_temp_pdp_context_node->cid EQ cid )
485 p_found_pdp_context_node = p_temp_pdp_context_node;
486 else
487 p_temp_pdp_context_node = p_temp_pdp_context_node->p_next;
488 }
489 }
490 }
491
492 return p_found_pdp_context_node;
493
494 }
495
496
497 /*
498 +----------------------------------------------------------------------------+
499 | PROJECT : UMTS MODULE : gaci |
500 | ROUTINE : pdp_context_find_node_from_dti_id |
501 +----------------------------------------------------------------------------+
502
503 PURPOSE :
504
505 */
506 GLOBAL T_PDP_CONTEXT_INTERNAL *pdp_context_find_node_from_dti_id( U8 dti_id )
507 {
508 T_PDP_CONTEXT_INTERNAL *p_found_pdp_context_node = NULL;
509
510 p_found_pdp_context_node = p_pdp_context_list;
511
512 while (p_found_pdp_context_node)
513 {
514 if( ( EXTRACT_DTI_ID(p_found_pdp_context_node->internal_data.link_id) EQ dti_id ) OR
515 ( EXTRACT_DTI_ID(p_found_pdp_context_node->internal_data.link_id_uart) EQ dti_id ) )
516 {
517 return (p_found_pdp_context_node);
518 }
519 p_found_pdp_context_node = p_found_pdp_context_node->p_next;
520 }
521
522 return NULL;
523 }
524
525
526 /*
527 +-------------------------------------------------------------------------------+
528 | PROJECT : UMTS MODULE : gaci |
529 | ROUTINE : pdp_context_find_node_from_smreg_ti |
530 +-------------------------------------------------------------------------------+
531
532 PURPOSE :
533
534 */
535 GLOBAL T_PDP_CONTEXT_INTERNAL *pdp_context_find_node_from_smreg_ti( U8 smreg_ti )
536 {
537 T_PDP_CONTEXT_INTERNAL *p_found_pdp_context_node = NULL;
538 T_PDP_CONTEXT_INTERNAL *p_temp_pdp_context_node = NULL;
539
540 if( p_pdp_context_list )
541 {
542 if( p_pdp_context_list->internal_data.smreg_ti EQ smreg_ti )
543 {
544 p_found_pdp_context_node = p_pdp_context_list;
545 }
546 else
547 {
548 p_temp_pdp_context_node = p_pdp_context_list->p_next;
549
550 while( p_temp_pdp_context_node AND !p_found_pdp_context_node )
551 {
552 if( p_temp_pdp_context_node->internal_data.smreg_ti EQ smreg_ti )
553 p_found_pdp_context_node = p_temp_pdp_context_node;
554 else
555 p_temp_pdp_context_node = p_temp_pdp_context_node->p_next;
556 }
557 }
558 }
559
560 return p_found_pdp_context_node;
561
562 }
563
564
565 /*
566 +----------------------------------------------------------------------------+
567 | PROJECT : UMTS MODULE : gaci |
568 | ROUTINE : pdp_context_find_last_node |
569 +----------------------------------------------------------------------------+
570
571 PURPOSE :
572
573 */
574 GLOBAL T_PDP_CONTEXT_INTERNAL *pdp_context_find_last_node( void )
575 {
576
577 T_PDP_CONTEXT_INTERNAL *p_last_pdp_context_node = NULL;
578
579 if( p_pdp_context_list )
580 {
581 if( !p_pdp_context_list->p_next )
582 {
583 p_last_pdp_context_node = p_pdp_context_list;
584 }
585 else
586 {
587 p_last_pdp_context_node = p_pdp_context_list;
588
589 while( p_last_pdp_context_node->p_next )
590 {
591 p_last_pdp_context_node = p_last_pdp_context_node->p_next;
592
593 if( !p_last_pdp_context_node )
594 break;
595 }
596 }
597 }
598 else
599 {
600 p_last_pdp_context_node = (T_PDP_CONTEXT_INTERNAL*) &p_pdp_context_list;
601 }
602
603 return p_last_pdp_context_node;
604
605 }
606
607 /*
608 +----------------------------------------------------------------------------+
609 | PROJECT : UMTS MODULE : gaci |
610 | ROUTINE : pdp_context_find_matching_node |
611 +----------------------------------------------------------------------------+
612
613 PURPOSE :
614
615 */
616 GLOBAL T_PDP_CONTEXT_INTERNAL *pdp_context_find_matching_node( T_SMREG_VAL_pdp_type smreg_pdp_type, T_NAS_ctrl_ip_address ctrl_ip_addr, T_NAS_ip_address *ip_addr )
617 {
618
619 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
620 T_PDP_TYPE pdp_type;
621 BOOL match = FALSE;
622
623
624 switch( smreg_pdp_type )
625 {
626 case SMREG_PDP_PPP:
627 strcpy( pdp_type, "PPP");
628 break;
629
630 case SMREG_PDP_IPV4:
631 strcpy( pdp_type, "IP");
632 break;
633
634 case SMREG_PDP_IPV6:
635 strcpy( pdp_type, "IPV6");
636 break;
637
638 default:
639 return NULL;
640 }
641
642 p_pdp_context_node = p_pdp_context_list;
643
644 while( p_pdp_context_node AND match EQ FALSE)
645 {
646 if( !strcmp(p_pdp_context_node->attributes.pdp_type, pdp_type) )
647 {
648 if( p_pdp_context_node->attributes.pdp_addr.ctrl_ip_address EQ ctrl_ip_addr )
649 {
650 switch( ctrl_ip_addr )
651 {
652 case NAS_is_ipv4:
653 {
654 if( !memcmp( &ip_addr->ipv4_addr,
655 &p_pdp_context_node->attributes.pdp_addr.ip_address.ipv4_addr,
656 NAS_SIZE_IPv4_ADDR ) )
657
658 {
659 match = TRUE;
660 }
661 break;
662 }
663
664 case NAS_is_ipv6:
665 {
666 if( !memcmp( &ip_addr->ipv6_addr,
667 &p_pdp_context_node->attributes.pdp_addr.ip_address.ipv6_addr,
668 NAS_SIZE_IPv6_ADDR ) )
669
670 {
671 match = TRUE;
672 }
673 break;
674 }
675 }
676
677 }
678
679 }
680
681 if( match EQ TRUE )
682 {
683 break;
684 }
685 else
686 {
687 p_pdp_context_node = p_pdp_context_node->p_next;
688 }
689
690 }
691
692 return p_pdp_context_node;
693
694 }
695
696
697
698 GLOBAL U8 pdp_context_get_free_cid( void )
699 {
700 #if (PDP_CONTEXT_CID_MAX > 15)
701 #error "Size of used_cid_list must be changed to fit the value of PDP_CONTEXT_CID_MAX"
702 #else
703 U16 used_cid_list = 0;
704 #endif
705
706 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
707 U8 free_cid = 0;
708
709 p_pdp_context_node = p_pdp_context_list;
710
711 while( p_pdp_context_node )
712 {
713 used_cid_list |= ( 0x0001 << (p_pdp_context_node->cid - 1) );
714 p_pdp_context_node = p_pdp_context_node->p_next;
715 }
716
717 while( ( 0x0001 & (used_cid_list >> free_cid)) AND free_cid <= PDP_CONTEXT_CID_MAX )
718 {
719 free_cid++;
720 }
721
722 free_cid++;
723
724 if( free_cid > PDP_CONTEXT_CID_MAX )
725 free_cid = PDP_CONTEXT_CID_INVALID;
726
727 return free_cid;
728 }
729
730
731
732 /*
733 +----------------------------------------------------------------------------+
734 | PROJECT : UMTS MODULE : gaci |
735 | ROUTINE : pdp_context_add_pf |
736 +----------------------------------------------------------------------------+
737
738 PURPOSE :
739
740 */
741 GLOBAL T_TFT_INTERNAL *pdp_context_add_tft_pf( U8 cid, U8 tft_pf_id )
742 {
743 T_TFT_INTERNAL *p_tft_pf_node_tmp_1 = NULL; /* TFT_PF_NODE n - 1 */
744 T_TFT_INTERNAL *p_tft_pf_node_tmp_0 = NULL; /* TFT_PF_NODE n */
745
746 T_TFT_INTERNAL *p_tft_pf_node_new = NULL; /* TFT_PF_NODE new */
747
748 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
749
750 p_pdp_context_node = pdp_context_find_node_from_cid( cid );
751
752 if( p_pdp_context_node )
753 {
754 p_tft_pf_node_new = pdp_context_find_tft_pf( cid, tft_pf_id );
755
756 if( ! p_tft_pf_node_new )
757 {
758 ACI_MALLOC( p_tft_pf_node_new, sizeof(T_TFT_INTERNAL));
759 if( p_tft_pf_node_new )
760 {
761 p_tft_pf_node_new->pf_attributes.tft_pf_id = tft_pf_id;
762 p_tft_pf_node_new->p_next = NULL;
763
764
765 if( p_pdp_context_node->p_tft_pf )
766 {
767 if( p_pdp_context_node->p_tft_pf->pf_attributes.tft_pf_id > tft_pf_id )
768 {
769 p_tft_pf_node_new->p_next = p_pdp_context_node->p_tft_pf;
770 p_pdp_context_node->p_tft_pf = p_tft_pf_node_new;
771 }
772 else
773 {
774 if( p_pdp_context_node->p_tft_pf->p_next )
775 {
776 p_tft_pf_node_tmp_1 = p_pdp_context_node->p_tft_pf;
777 p_tft_pf_node_tmp_0 = p_pdp_context_node->p_tft_pf->p_next;
778
779 while( p_tft_pf_node_tmp_0 )
780 {
781 if( p_tft_pf_node_tmp_0->pf_attributes.tft_pf_id > tft_pf_id )
782 {
783 p_tft_pf_node_new->p_next = p_tft_pf_node_tmp_0;
784 p_tft_pf_node_tmp_1->p_next = p_tft_pf_node_new;
785 break;
786 }
787 else
788 {
789 p_tft_pf_node_tmp_1 = p_tft_pf_node_tmp_0;
790 p_tft_pf_node_tmp_0 = p_tft_pf_node_tmp_0->p_next;
791 }
792 }
793 p_tft_pf_node_tmp_1->p_next = p_tft_pf_node_new;
794 }
795 else
796 {
797 p_pdp_context_node->p_tft_pf->p_next = p_tft_pf_node_new;
798 }
799 }
800 }
801 else
802 {
803 p_pdp_context_node->p_tft_pf = p_tft_pf_node_new;
804 }
805 }
806 }
807 else
808 {
809 TRACE_ERROR( "ERROR: TFT PF with same PF_ID exist" );
810 p_tft_pf_node_new = NULL;
811 }
812
813 }
814 else
815 {
816 TRACE_ERROR( "ERROR: PDP context not found, in function pdp_context_add_tft_pf");
817 }
818
819 return p_tft_pf_node_new;
820
821 }
822
823
824 /*
825 +----------------------------------------------------------------------------+
826 | PROJECT : UMTS MODULE : gaci |
827 | ROUTINE : pdp_context_del_pf |
828 +----------------------------------------------------------------------------+
829
830 PURPOSE : Delete the specified packet filter from a TFT.
831
832 */
833 GLOBAL BOOL pdp_context_del_tft_pf( U8 cid, U8 tft_pf_id )
834 {
835 BOOL result = FALSE;
836 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
837 T_TFT_INTERNAL *p_tft_pf_node = NULL;
838 T_TFT_INTERNAL *p_tft_pf_node_old = NULL;
839
840 p_pdp_context_node = pdp_context_find_node_from_cid( cid );
841
842 if( p_pdp_context_node AND p_pdp_context_node->p_tft_pf )
843 {
844 if( p_pdp_context_node->p_tft_pf->pf_attributes.tft_pf_id NEQ tft_pf_id )
845 {
846 p_tft_pf_node = p_pdp_context_node->p_tft_pf;
847
848 while( p_tft_pf_node->p_next AND p_tft_pf_node->p_next->pf_attributes.tft_pf_id NEQ tft_pf_id )
849 {
850 p_tft_pf_node = p_tft_pf_node->p_next;
851 }
852
853 if( p_tft_pf_node->p_next->pf_attributes.tft_pf_id EQ tft_pf_id )
854 {
855 p_tft_pf_node_old = p_tft_pf_node->p_next;
856 p_tft_pf_node->p_next = p_tft_pf_node->p_next->p_next;
857 ACI_MFREE( p_tft_pf_node_old );
858 result = TRUE;
859 }
860 else
861 {
862 TRACE_EVENT( "ERROR: PF not found for given PDP cid, in function pdp_context_del_tft_pf" );
863 }
864 }
865 else
866 {
867 p_tft_pf_node_old = p_pdp_context_node->p_tft_pf;
868
869 if( p_pdp_context_node->p_tft_pf->p_next )
870 {
871 p_pdp_context_node->p_tft_pf = p_pdp_context_node->p_tft_pf->p_next;
872 }
873 else
874 {
875 p_pdp_context_node->p_tft_pf = NULL;
876 }
877
878 ACI_MFREE( p_tft_pf_node_old );
879 result = TRUE;
880 }
881 }
882 else
883 {
884 TRACE_EVENT( "ERROR: in function pdp_context_del_tft_pf" );
885 }
886
887 return result;
888
889 }
890
891
892 /*
893 +----------------------------------------------------------------------------+
894 | PROJECT : UMTS MODULE : gaci |
895 | ROUTINE : pdp_context_del_tft |
896 +----------------------------------------------------------------------------+
897
898 PURPOSE : Delete all packet filters for an entire TFT.
899
900 */
901 GLOBAL BOOL pdp_context_del_tft( U8 cid )
902 {
903 BOOL result = TRUE;
904 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
905
906 p_pdp_context_node = pdp_context_find_node_from_cid( cid );
907 if( p_pdp_context_node )
908 {
909 while( p_pdp_context_node->p_tft_pf )
910 {
911 if( !pdp_context_del_tft_pf( cid, p_pdp_context_node->p_tft_pf->pf_attributes.tft_pf_id ) )
912 {
913 result = FALSE;
914 break;
915 }
916 }
917 }
918 else
919 {
920 result = FALSE;
921 }
922
923 return result;
924 }
925
926
927 /*
928 +----------------------------------------------------------------------------+
929 | PROJECT : UMTS MODULE : gaci |
930 | ROUTINE : pdp_context_find_tft_pf |
931 +----------------------------------------------------------------------------+
932
933 PURPOSE : Find the specified packet flter in a TFT and return the pointer.
934
935 */
936 GLOBAL T_TFT_INTERNAL *pdp_context_find_tft_pf( U8 cid, U8 tft_pf_id )
937 {
938 T_TFT_INTERNAL *p_tft_pf_node = NULL;
939 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
940
941 p_pdp_context_node = pdp_context_find_node_from_cid( cid );
942
943 if( p_pdp_context_node )
944 {
945
946 if( p_pdp_context_node->p_tft_pf )
947 {
948 p_tft_pf_node = p_pdp_context_node->p_tft_pf;
949 }
950
951 if( p_tft_pf_node )
952 {
953 while( p_tft_pf_node->pf_attributes.tft_pf_id NEQ tft_pf_id AND p_tft_pf_node->p_next )
954 {
955 p_tft_pf_node = p_tft_pf_node->p_next;
956 }
957
958 if( p_tft_pf_node->pf_attributes.tft_pf_id NEQ tft_pf_id )
959 {
960 p_tft_pf_node = NULL;
961 }
962
963 }
964
965 }
966
967 return p_tft_pf_node;
968
969 }
970
971
972 /*
973 +----------------------------------------------------------------------------+
974 | PROJECT : UMTS MODULE : gaci |
975 | ROUTINE : pdp_context_find_tft_pf |
976 +----------------------------------------------------------------------------+
977
978 PURPOSE : return the number of defined packet filters in a TFT.
979
980 */
981 GLOBAL U8 pdp_context_get_no_of_tft_pfs( U8 cid )
982 {
983 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
984 T_TFT_INTERNAL *p_tft_pf_node = NULL;
985 U8 pf_count = 0;
986
987 p_pdp_context_node = pdp_context_find_node_from_cid( cid );
988
989 if( p_pdp_context_node )
990 {
991 p_tft_pf_node = p_pdp_context_node->p_tft_pf;
992 while( p_tft_pf_node )
993 {
994 pf_count++;
995 p_tft_pf_node = p_tft_pf_node->p_next;
996 }
997 }
998
999 return pf_count;
1000
1001 }
1002
1003
1004 /*
1005 +-------------------------------------------------------------------------------+
1006 | PROJECT : MODULE : gaci |
1007 | ROUTINE : pdp_context_check_if_nodes_exists |
1008 +-------------------------------------------------------------------------------+
1009
1010 PURPOSE : Check if the PDP contexts specified in the cid_array are defined.
1011 The function will return 0 if all specified PDP contexts are defind
1012 othervise the first undefined cid in the cid_array is returned.
1013 */
1014 GLOBAL U8 pdp_context_check_if_nodes_exists( U8 *cid_array )
1015 {
1016 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
1017 U8 i = 0;
1018 U8 result = 0;
1019
1020 while( (cid_array[i] NEQ PDP_CONTEXT_CID_OMITTED) AND (i < PDP_CONTEXT_CID_MAX) )
1021 {
1022 p_pdp_context_node = pdp_context_find_node_from_cid( cid_array[i] );
1023 if( p_pdp_context_node )
1024 {
1025 i++;
1026 }
1027 else
1028 {
1029 result = cid_array[i];
1030 break;
1031 }
1032 }
1033
1034 return result;
1035 }
1036
1037
1038 /*
1039 +-------------------------------------------------------------------------------+
1040 | PROJECT : MODULE : gaci |
1041 | ROUTINE : pdp_context_check_if_nodes_exists |
1042 +-------------------------------------------------------------------------------+
1043
1044 PURPOSE : Check if the pdp_type matches the specified PDP contexts in the cid_array.
1045 The function will return 0 if all specified PDP contexts matches
1046 othervise the first unmatched PDP context in the cid_array is returned.
1047 */
1048 GLOBAL U8 pdp_context_validate_pdp_type( U8 *cid_array, T_PDP_TYPE pdp_type )
1049 {
1050 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
1051 U8 i = 0;
1052 U8 result = 0;
1053
1054 while( (cid_array[i] NEQ PDP_CONTEXT_CID_OMITTED) AND (i < PDP_CONTEXT_CID_MAX) )
1055 {
1056 p_pdp_context_node = pdp_context_find_node_from_cid( cid_array[i] );
1057 if( p_pdp_context_node )
1058 {
1059 if( strcmp(p_pdp_context_node->attributes.pdp_type, pdp_type) )
1060 {
1061 result = cid_array[i];
1062 break;
1063 }
1064 i++;
1065 }
1066 else
1067 {
1068
1069 result = cid_array[i];
1070 break;
1071 }
1072 }
1073
1074 return result;
1075 }
1076
1077
1078 #endif /* GPRS */