comparison gsm-fw/g23m-aci/aci/cmh_smr.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 defines the functions which are responsible
18 | for the responses of the protocol stack adapter for
19 | GPRS session management ( SM ).
20 +-----------------------------------------------------------------------------
21 */
22
23 #if defined (GPRS) && defined (DTI)
24
25 #ifndef CMH_SMR_C
26 #define CMH_SMR_C
27 #endif
28
29 #include "aci_all.h"
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
37 #include "aci.h"
38
39 #include "dti_conn_mng.h"
40 #include "dti_cntrl_mng.h"
41
42 #include "gaci.h"
43 #include "gaci_cmh.h"
44 #include "psa.h"
45 #include "psa_sm.h"
46 #include "psa_gppp.h"
47 #include "psa_gmm.h"
48 #include "psa_sim.h"
49
50 #include "cmh.h"
51 #include "cmh_sm.h"
52 #include "cmh_gmm.h"
53 #include "cmh_gppp.h"
54 #include "gaci_srcc.h"
55 #include "dti.h" /* functionality of the dti library */
56
57 #include "psa_uart.h"
58
59 #if defined (CO_UDP_IP) OR defined (FF_GPF_TCPIP)
60 #include "wap_aci.h"
61 #include "psa_tcpip.h"
62 #include "psa_cc.h"
63 #include "cmh_cc.h"
64 #include "psa_sat.h"
65 #include "cmh_sat.h"
66
67 #include "dcm_f.h"
68 #endif /* (CO_UDP_IP) OR defined (FF_GPF_TCPIP) */
69 #include "aci_lst.h"
70 #include "ati_int.h"
71
72 /*==== CONSTANTS ==================================================*/
73
74 /*==== TYPES ======================================================*/
75
76 /*==== EXPORT =====================================================*/
77
78 /*==== VARIABLES ==================================================*/
79 EXTERN T_PDP_CONTEXT_INTERNAL *p_pdp_context_list;
80
81 /*==== FUNCTIONS ==================================================*/
82
83 static void dumpContextInfo(U8 cid)
84 {
85 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
86
87 p_pdp_context_node = pdp_context_find_node_from_cid( cid );
88
89 if( ! p_pdp_context_node )
90 return;
91
92 TRACE_EVENT_P2("ERROR in context state: cid %d, state %d",
93 cid, p_pdp_context_node->internal_data.state);
94 TRACE_EVENT_P3("dump: nsapi %d, srcID %d, connected entity %d",
95 CID_TO_NSAPI( cid ), p_pdp_context_node->internal_data.owner,
96 p_pdp_context_node->internal_data.entity_id);
97 if(smEntStat.curCmd NEQ AT_CMD_NONE)
98 {
99 TRACE_EVENT_P1("dump running command: %d", smEntStat.curCmd);
100 }
101 TRACE_EVENT_P3("dump link_ids: new %d sn %d uart %d",
102 p_pdp_context_node->internal_data.link_id_new, p_pdp_context_node->internal_data.link_id,
103 p_pdp_context_node->internal_data.link_id_uart);
104 }
105
106 #if defined (CO_UDP_IP) OR defined (FF_GPF_TCPIP)
107 static BOOL is_ip_dti_id(T_DTI_ENTITY_ID dti_id)
108 {
109 if(is_gpf_tcpip_call()) {
110 GPF_TCPIP_STATEMENT(return dti_id EQ DTI_ENTITY_TCPIP);
111 }
112 else {
113 return dti_id EQ DTI_ENTITY_IP;
114 }
115 }
116 #endif
117
118 static void get_dns_address(char* dns1, char *dns2, UBYTE *pco, UBYTE len)
119 {
120 ULONG tmp_dns1, tmp_dns2, gateway;
121 utl_analyze_pco(pco,len, &tmp_dns1, &tmp_dns2, &gateway);
122
123 sprintf(dns1, "%03u.%03u.%03u.%03u", (tmp_dns1 & 0xff000000) >> 24,
124 (tmp_dns1 & 0x00ff0000) >> 16,
125 (tmp_dns1 & 0x0000ff00) >> 8 ,
126 (tmp_dns1 & 0x000000ff) );
127 sprintf(dns2, "%03u.%03u.%03u.%03u", (tmp_dns2 & 0xff000000) >> 24,
128 (tmp_dns2 & 0x00ff0000) >> 16,
129 (tmp_dns2 & 0x0000ff00) >> 8 ,
130 (tmp_dns2 & 0x000000ff) );
131 }
132
133 /*
134 +-------------------------------------------------------------------+
135 | PROJECT : GPRS (8441) MODULE : CMH_SMR |
136 | STATE : finished ROUTINE : cmhSM_Activated |
137 +-------------------------------------------------------------------+
138
139 PURPOSE : confirms a successful context activation
140
141 */
142 GLOBAL SHORT cmhSM_Activated ( T_SMREG_PDP_ACTIVATE_CNF *pdp_cnf )
143 {
144 char dns1[16], dns2[16];
145 U8 cid = work_cids[cid_pointer];
146 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
147 T_ACI_AT_CMD curCmd = smEntStat.curCmd;
148 T_CGEREP_EVENT_REP_PARAM event;
149 int i = 0;
150
151 TRACE_FUNCTION ("cmhSM_Activated()");
152
153 p_pdp_context_node = pdp_context_find_node_from_cid( cid );
154 if( !p_pdp_context_node )
155 {
156 TRACE_ERROR( "ERROR: PDP context not found, in function cmhSM_Activated" );
157 return -1;
158 }
159
160 /*
161 *-------------------------------------------------------------------
162 * check for command context
163 *-------------------------------------------------------------------
164 */
165 switch( get_state_working_cid() )
166 {
167 case( PDP_CONTEXT_STATE_ACTIVATING ):
168
169 R_AT( RAT_CGACT, smEntStat.entOwn )( 0 );
170
171 set_state_working_cid( PDP_CONTEXT_STATE_ACTIVATED );
172
173 /* Storing of Dynamic address sent in SMREG_PDP_ACTIVATE_CNF message is missing in
174 Alborg code.
175 */
176 p_pdp_context_node->internal_data.pdp_address_allocated.ctrl_ip_address = pdp_cnf->ctrl_ip_address;
177
178 if ( p_pdp_context_node->internal_data.pdp_address_allocated.ctrl_ip_address )
179 {
180 if ( p_pdp_context_node->internal_data.pdp_address_allocated.ctrl_ip_address EQ NAS_is_ipv4 )
181 {
182 memcpy( p_pdp_context_node->internal_data.pdp_address_allocated.ip_address.ipv4_addr.a4, &pdp_cnf->ip_address.ipv4_addr.a4, NAS_SIZE_IPv4_ADDR );
183 TRACE_EVENT_P1("PDP Address: %s", p_pdp_context_node->internal_data.pdp_address_allocated.ip_address.ipv4_addr.a4);
184 }
185 else
186 {
187 memcpy( p_pdp_context_node->internal_data.pdp_address_allocated.ip_address.ipv6_addr.a6, &pdp_cnf->ip_address.ipv6_addr.a6, NAS_SIZE_IPv6_ADDR );
188 TRACE_EVENT_P1("PDP Address: %s", p_pdp_context_node->internal_data.pdp_address_allocated.ip_address.ipv6_addr.a6);
189 }
190 }
191 else
192 {
193 if ( p_pdp_context_node->attributes.pdp_addr.ctrl_ip_address EQ NAS_is_ipv4 )
194 {
195 memcpy( p_pdp_context_node->internal_data.pdp_address_allocated.ip_address.ipv4_addr.a4, &p_pdp_context_node->attributes.pdp_addr.ip_address.ipv4_addr.a4, NAS_SIZE_IPv4_ADDR );
196 p_pdp_context_node->internal_data.pdp_address_allocated.ctrl_ip_address = p_pdp_context_node->attributes.pdp_addr.ctrl_ip_address;
197 TRACE_EVENT_P1("PDP Address: %s", p_pdp_context_node->internal_data.pdp_address_allocated.ip_address.ipv4_addr.a4);
198 }
199 else if ( p_pdp_context_node->attributes.pdp_addr.ctrl_ip_address EQ NAS_is_ipv6 )
200 {
201 memcpy( p_pdp_context_node->internal_data.pdp_address_allocated.ip_address.ipv6_addr.a6, &p_pdp_context_node->attributes.pdp_addr.ip_address.ipv6_addr.a6, NAS_SIZE_IPv6_ADDR );
202 p_pdp_context_node->internal_data.pdp_address_allocated.ctrl_ip_address = p_pdp_context_node->attributes.pdp_addr.ctrl_ip_address;
203 TRACE_EVENT_P1("PDP Address: %s", p_pdp_context_node->internal_data.pdp_address_allocated.ip_address.ipv6_addr.a6);
204 }
205 else
206 {
207 TRACE_ERROR( "ERROR: NO IP Address Assigned, In PDP_CONTEXT_STATE_ACTIVATING State" );
208 }
209 }
210
211 cmhSM_set_PCO( cid,
212 PCO_NETWORK,
213 &smShrdPrm.pdp_cnf->sdu.buf[smShrdPrm.pdp_cnf->sdu.o_buf >> 3],
214 (UBYTE) (smShrdPrm.pdp_cnf->sdu.l_buf >> 3));
215
216 get_dns_address(dns1, dns2,
217 p_pdp_context_node->internal_data.network_pco.pco,
218 p_pdp_context_node->internal_data.network_pco.len);
219
220 TRACE_EVENT_P2("DNS1: %s, DNS2: %s", dns1, dns2);
221
222 #if defined (CO_UDP_IP) OR defined (FF_GPF_TCPIP)
223 /* if WAP/TCPIP over GPRS is in progress, request WAP configuration */
224 if ( is_ip_dti_id(p_pdp_context_node->internal_data.entity_id) )
225 {
226 char c_ip_address[16];
227 UBYTE* ip_address;
228
229 ip_address = p_pdp_context_node->internal_data.pdp_address_allocated.ip_address.ipv4_addr.a4;
230 sprintf (c_ip_address, "%03u.%03u.%03u.%03u", ip_address[0],
231 ip_address[1],
232 ip_address[2],
233 ip_address[3] );
234
235 psaTCPIP_Configure(NULL, (UBYTE*) c_ip_address,
236 NULL, (UBYTE*)dns1, (UBYTE*)dns2, 1500,
237 cmhSM_IP_activate_cb );
238 }
239 #endif /* (CO_UDP_IP) OR defined (FF_GPF_TCPIP) */
240
241 /*
242 * do we need one more context activation
243 */
244 if( FALSE EQ cmhSM_next_work_cid( curCmd ) )
245 {
246 if( AT_CMD_CGACT EQ curCmd)
247 {
248 gaci_RAT_caller ( RAT_OK, cid, (UBYTE) curCmd, 0 );
249
250 /* log result */
251 cmh_logRslt ( p_pdp_context_node->internal_data.owner, RAT_OK, curCmd, -1, BS_SPEED_NotPresent,CME_ERR_NotPresent);
252 #if defined (FF_WAP) OR defined (FF_SAT_E)
253 if (Wap_Call)
254 {
255 gpppEntStat.curCmd = AT_CMD_NONE;
256 }
257 #endif /* WAP OR SAT E */
258 }
259 }
260
261 break;
262
263 case( PDP_CONTEXT_STATE_ESTABLISH_2 ):
264 /*
265 *---------------------------------------------------------------
266 * inform PPP
267 *---------------------------------------------------------------
268 */
269 cmhSM_set_PCO( cid ,
270 PCO_NETWORK,
271 &smShrdPrm.pdp_cnf->sdu.buf[smShrdPrm.pdp_cnf->sdu.o_buf >> 3],
272 (UBYTE) (smShrdPrm.pdp_cnf->sdu.l_buf >> 3));
273
274 /* Storing of Dynamic address sent in SMREG_PDP_ACTIVATE_CNF message is missing in
275 Alborg code.
276 */
277 p_pdp_context_node->internal_data.pdp_address_allocated.ctrl_ip_address = smShrdPrm.pdp_cnf->ctrl_ip_address;
278
279 if ( p_pdp_context_node->internal_data.pdp_address_allocated.ctrl_ip_address )
280 {
281 if ( p_pdp_context_node->internal_data.pdp_address_allocated.ctrl_ip_address EQ NAS_is_ipv4 )
282 {
283 memcpy( p_pdp_context_node->internal_data.pdp_address_allocated.ip_address.ipv4_addr.a4, &smShrdPrm.pdp_cnf->ip_address.ipv4_addr.a4, NAS_SIZE_IPv4_ADDR );
284 }
285 else
286 {
287 memcpy( p_pdp_context_node->internal_data.pdp_address_allocated.ip_address.ipv6_addr.a6, &smShrdPrm.pdp_cnf->ip_address.ipv6_addr.a6, NAS_SIZE_IPv6_ADDR );
288 }
289 }
290 else
291 {
292 if ( p_pdp_context_node->attributes.pdp_addr.ctrl_ip_address EQ NAS_is_ipv4 )
293 {
294 memcpy( p_pdp_context_node->internal_data.pdp_address_allocated.ip_address.ipv4_addr.a4, &p_pdp_context_node->attributes.pdp_addr.ip_address.ipv4_addr.a4, NAS_SIZE_IPv4_ADDR );
295 p_pdp_context_node->internal_data.pdp_address_allocated.ctrl_ip_address = p_pdp_context_node->attributes.pdp_addr.ctrl_ip_address;
296 }
297 else if ( p_pdp_context_node->attributes.pdp_addr.ctrl_ip_address EQ NAS_is_ipv6 )
298 {
299 memcpy( p_pdp_context_node->internal_data.pdp_address_allocated.ip_address.ipv6_addr.a6, &p_pdp_context_node->attributes.pdp_addr.ip_address.ipv6_addr.a6, NAS_SIZE_IPv6_ADDR );
300 p_pdp_context_node->internal_data.pdp_address_allocated.ctrl_ip_address = p_pdp_context_node->attributes.pdp_addr.ctrl_ip_address;
301 }
302 else
303 {
304 TRACE_ERROR( "ERROR: NO IP Address Assigned, In PDP_CONTEXT_STATE_ESTABLISH_2" );
305 }
306 }
307
308 psaGPPP_PDP_Activate( &p_pdp_context_node->internal_data.pdp_address_allocated,
309 &smShrdPrm.pdp_cnf->sdu.buf[smShrdPrm.pdp_cnf->sdu.o_buf >> 3],
310 (UBYTE) (smShrdPrm.pdp_cnf->sdu.l_buf >> 3),
311 (UBYTE) CID_TO_NSAPI( cid ) );
312
313 set_state_working_cid( PDP_CONTEXT_STATE_ESTABLISH_3 );
314
315 break;
316
317 default:
318 return -1;
319 }
320
321 /*
322 * %CGEV - GPRS event reporting
323 */
324
325 strcpy( event.act.pdp_type, p_pdp_context_node->attributes.pdp_type );
326 memcpy(&(event.act.pdp_addr), &(p_pdp_context_node->internal_data.pdp_address_allocated), sizeof(T_NAS_ip));
327
328 event.act.cid = cid;
329
330 if( smShrdPrm.direc EQ CGEREP_EVENT_ME_ACT )
331 {
332 for( i = 0; i < CMD_SRC_MAX; i++ )
333 {
334 R_AT( RAT_P_CGEV, (T_ACI_CMD_SRC)i ) ( CGEREP_EVENT_ME_ACT, &event );
335 }
336 }
337 else
338 {
339 for( i = 0; i < CMD_SRC_MAX; i++ )
340 {
341 R_AT( RAT_P_CGEV, (T_ACI_CMD_SRC)i ) ( CGEREP_EVENT_NW_ACT, &event );
342 }
343 }
344
345 return 0;
346 }
347
348 /*
349 +-------------------------------------------------------------------+
350 | PROJECT : GPRS (8441) MODULE : CMH_SMR |
351 | STATE : finished ROUTINE : |
352 +-------------------------------------------------------------------+
353
354 PURPOSE :
355
356 */
357
358 LOCAL void cp_pdp_rej_prim( T_SMREG_PDP_ACTIVATE_REJ * pdp_activate_rej,
359 T_PPP_PDP_ACTIVATE_REJ *activate_result )
360 {
361
362 }
363
364 /*
365 +-------------------------------------------------------------------+
366 | PROJECT : GPRS (8441) MODULE : CMH_SMR |
367 | STATE : finished ROUTINE : cmhSM_NoActivate |
368 +-------------------------------------------------------------------+
369
370 PURPOSE : indicates a context activation failed
371
372 */
373 GLOBAL SHORT cmhSM_NoActivate ( void )
374 {
375 T_CGEREP_EVENT_REP_PARAM event;
376 T_PDP_CONTEXT_STATE state;
377 T_DTI_CONN_LINK_ID link_id;
378 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
379 int i = 0;
380
381 TRACE_FUNCTION ("cmhSM_NoActivate()");
382 /*
383 *-------------------------------------------------------------------
384 * Set error cause for SIM owner
385 *-------------------------------------------------------------------
386 */
387 #ifdef FF_SAT_E
388 gaci_SAT_err((UBYTE)smShrdPrm.pdp_rej->ps_cause.value.nwsm_cause);
389 #endif /* FF_SAT_E */
390 /*
391 *-------------------------------------------------------------------
392 * check for command context
393 *-------------------------------------------------------------------
394 */
395
396 p_pdp_context_node = pdp_context_find_node_from_cid( NSAPI_TO_CID( smShrdPrm.pdp_rej->nsapi ) );
397 if (!p_pdp_context_node )
398 {
399 return -1;
400 }
401
402 state = get_state_over_cid(p_pdp_context_node->cid);
403
404 switch( state )
405 {
406 case PDP_CONTEXT_STATE_INVALID:
407 case PDP_CONTEXT_STATE_DEFINED:
408 case PDP_CONTEXT_STATE_ATTACHING:
409 case PDP_CONTEXT_STATE_ESTABLISH_1:
410 case PDP_CONTEXT_STATE_ESTABLISH_3:
411 case PDP_CONTEXT_STATE_ACTIVATED:
412 case PDP_CONTEXT_STATE_ACTIVATED_ESTABLISH_1:
413 case PDP_CONTEXT_STATE_ACTIVATED_MODIFYING:
414 case PDP_CONTEXT_STATE_DATA_LINK:
415 case PDP_CONTEXT_STATE_DATA_LINK_MODIFYING:
416 case PDP_CONTEXT_STATE_DEACTIVATE_NORMAL:
417 case PDP_CONTEXT_STATE_REACTIVATION_1:
418 case PDP_CONTEXT_STATE_REACTIVATION_2:
419 case PDP_CONTEXT_STATE_BREAKDOWN_LINK_NORMAL:
420 dumpContextInfo(work_cids[cid_pointer]);
421 TRACE_ERROR("cmhSM_NoActivate(): State/Event error!!!");
422 return 0;
423
424 case PDP_CONTEXT_STATE_ACTIVATING:
425 /*Instead of: link_id = cmhSM_get_link_id_SNDCP_peer(work_cids[cid_pointer], SNDCP_PEER_NORMAL);*/
426 link_id = p_pdp_context_node->internal_data.link_id;
427
428 switch(p_pdp_context_node->internal_data.entity_id)
429 {
430 case DTI_ENTITY_PKTIO:
431 case DTI_ENTITY_PSI:
432 set_state_working_cid( PDP_CONTEXT_STATE_DEACTIVATE_NORMAL );
433 dti_cntrl_close_dpath_from_dti_id (EXTRACT_DTI_ID(link_id));
434 // gaci_RAT_caller(RAT_NO_CARRIER, work_cids[cid_pointer], AT_CMD_CGDATA, 0);
435 break;
436
437 #if defined (CO_UDP_IP) OR defined (FF_GPF_TCPIP)
438 case DTI_ENTITY_IP:
439 GPF_TCPIP_STATEMENT(case DTI_ENTITY_TCPIP:)
440 set_state_working_cid( PDP_CONTEXT_STATE_DEACTIVATE_NORMAL );
441 dti_cntrl_close_dpath_from_dti_id (EXTRACT_DTI_ID(link_id));
442 /* tell WAP ACI that contextactivation was rejected */
443 psaTCPIP_Deactivate(cmhSM_IP_activate_cb);
444 dti_cntrl_entity_disconnected( link_id, DTI_ENTITY_SNDCP );
445 break;
446 #endif /* WAP OR FF_SAT_E OR FF_GPF_TCPIP */
447 default:
448 /* in this case is SMREG_PDP_ACTIVATE_REJ the same as SMREG_DEACTIVATE_CNF */
449
450 /* set parameter for SMREG_DEACTIVATE_CNF */
451 smShrdPrm.nsapi_set = 1 << smShrdPrm.pdp_rej->nsapi;
452 cmhSM_Deactivated(); /* SMREG_DEACTIVATE_CNF */
453
454 /* the last expected primitive from SM */
455 smEntStat.curCmd = AT_CMD_NONE;
456 return 0;
457 }
458
459 /*
460 * GPRS event reporting
461 */
462 strcpy( event.act.pdp_type, p_pdp_context_node->attributes.pdp_type );
463 memcpy(&(event.act.pdp_addr), &(p_pdp_context_node->attributes.pdp_addr), sizeof(T_NAS_ip));
464 event.act.cid = work_cids[cid_pointer];
465 for( i = 0; i < CMD_SRC_MAX; i++ )
466 {
467 R_AT( RAT_CGEREP, (T_ACI_CMD_SRC)i ) ( CGEREP_EVENT_ME_DEACT, &event );
468 R_AT( RAT_P_CGEV, (T_ACI_CMD_SRC)i ) ( CGEREP_EVENT_ME_DEACT, &event );
469 }
470
471 cmhSM_contextDeactivated();
472 break;
473
474 case PDP_CONTEXT_STATE_ESTABLISH_2:
475 case PDP_CONTEXT_STATE_ABORT_ESTABLISH:
476 /* in this case is SMREG_PDP_ACTIVATE_REJ the same as SMREG_DEACTIVATE_CNF */
477
478 /* set parameter for SMREG_DEACTIVATE_CNF */
479 smShrdPrm.nsapi_set = 1 << CID_TO_NSAPI( p_pdp_context_node->cid );
480
481 cmhSM_Deactivated(); /* SMREG_DEACTIVATE_CNF */
482
483 /* the last expected primitive from SM */
484 smEntStat.curCmd = AT_CMD_NONE;
485
486 if( state NEQ PDP_CONTEXT_STATE_ESTABLISH_2 )
487 {
488 return 0;
489 }
490
491 /*
492 *---------------------------------------------------------------
493 * inform PPP
494 *---------------------------------------------------------------
495 */
496 {
497 PALLOC( act_rej_temp, PPP_PDP_ACTIVATE_REJ ); /* ppass */
498 gpppShrdPrm.setPrm[gpppEntStat.entOwn].pdp_rej = act_rej_temp;
499 act_rej_temp->ppp_cause = smShrdPrm.pdp_rej->ps_cause.value.ppp_cause;
500 }
501
502 if( psaGPPP_PDP_Reject() < 0 )
503 {
504 TRACE_EVENT( "FATAL RETURN psaPPP_PDP_Reject in +CGDATA" );
505 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
506 return -1 ;
507 }
508
509 set_state_over_cid( p_pdp_context_node->cid, PDP_CONTEXT_STATE_ABORT_ESTABLISH );
510 break;
511
512 default:
513 return -1;
514 }
515
516 return 0;
517 }
518
519 /*
520 +-------------------------------------------------------------------+
521 | PROJECT : GPRS (8441) MODULE : CMH_SMR |
522 | STATE : finished ROUTINE : cmhSM_NetActivate |
523 +-------------------------------------------------------------------+
524
525 PURPOSE : indicates a network asked for a PDP context activation
526
527 */
528 GLOBAL void cmhSM_NetActivate ( void )
529 {
530 T_CGEREP_EVENT_REP_PARAM event;
531 U8 i = 0; /* holds index counter */
532 U8 context_reactivation = 0;
533 U8 cid;
534
535 TRACE_FUNCTION ("cmhSM_NetActivate()");
536
537 /*
538 * in first only one requested context activation is provided
539 * and the request will be rejected if an other context will be
540 * activated
541 */
542
543 /*
544 * it's no check to CC neccesary, because this is no class A mobile
545 */
546
547 if( cmhSM_is_smreg_ti_used( smShrdPrm.act_ind.ti, &cid ) EQ TRUE )
548 context_reactivation = 1;
549
550 /*
551 * no PDP context is during the setup
552 */
553 if ( work_cids[cid_pointer] EQ PDP_CONTEXT_CID_INVALID AND
554 gprs_ct_index < MAX_GPRS_CALL_TABLE_ENTRIES
555 AND
556 ( TRUE EQ srcc_reserve_sources( SRCC_PPPS_SNDCP_LINK, 1 ) OR
557 context_reactivation EQ 1)
558 )
559
560
561 {
562 /*
563 *-------------------------------------------------------------------
564 * ring for call, if no call is in use
565 *-------------------------------------------------------------------
566 */
567
568 #ifdef AT_INTERPRETER
569 /* V.24 Ring Indicator Line */
570 /* io_setRngInd ( IO_RS_ON, CRING_TYP_NotPresent, CRING_TYP_NotPresent dummy parameters here, need real ones when used); */
571 #endif
572
573 /* fill gprs call table */
574 memcpy(&gprs_call_table[gprs_ct_index].sm_ind, &smShrdPrm.act_ind, sizeof(T_SMREG_PDP_ACTIVATE_IND));
575
576 /* no context reactivation */
577 if ( context_reactivation NEQ 1 )
578 {
579 gprs_call_table[gprs_ct_index].reactivation = GCTT_NORMAL;
580 *gprs_call_table[gprs_ct_index].L2P = 0;
581 gprs_call_table[gprs_ct_index].cid = PDP_CONTEXT_CID_INVALID;
582 gprs_ct_index++;
583
584 for( i = 0 ; i < CMD_SRC_MAX; i++ )
585 {
586 R_AT( RAT_CRING, (T_ACI_CMD_SRC)i ) ( CRING_MOD_Gprs, CRING_SERV_TYP_GPRS, CRING_SERV_TYP_NotPresent );
587 }
588 }
589 else
590 { /* context reactivation */
591 gprs_call_table[gprs_ct_index].reactivation = GCTT_REACTIVATION ;
592 strcpy(gprs_call_table[gprs_ct_index].L2P, "PPP");
593 gprs_call_table[gprs_ct_index].cid = cid;
594 gprs_ct_index++;
595 }
596
597 }
598 else
599 /*
600 * one or more PDP contexts are during the setup
601 */
602 {
603 psaSM_PDP_No_activate(smShrdPrm.act_ind.ti, CAUSE_NWSM_INSUFFICIENT_RESOURCES);
604
605 /*
606 * GPRS event reporting
607 */
608 cmhSM_pdp_typ_to_string(smShrdPrm.act_ind.pdp_type, event.reject.pdp_type);
609
610 event.reject.pdp_addr.ctrl_ip_address = smShrdPrm.act_ind.ctrl_ip_address;
611
612 if (event.reject.pdp_addr.ctrl_ip_address EQ NAS_is_ipv4)
613 {
614 memcpy( &event.reject.pdp_addr.ip_address.ipv4_addr, &smShrdPrm.act_ind.ip_address.ipv4_addr.a4, NAS_SIZE_IPv4_ADDR );
615 }
616 else
617 {
618 memcpy( &event.reject.pdp_addr.ip_address.ipv6_addr, &smShrdPrm.act_ind.ip_address.ipv6_addr.a6, NAS_SIZE_IPv6_ADDR );
619 }
620
621 for( i = 0; i < CMD_SRC_MAX; i++ )
622 {
623 R_AT( RAT_CGEREP, (T_ACI_CMD_SRC)i ) ( CGEREP_EVENT_REJECT, &event );
624 R_AT( RAT_P_CGEV, (T_ACI_CMD_SRC)i ) ( CGEREP_EVENT_REJECT, &event );
625 }
626
627 }
628 }
629
630 /*
631 +-------------------------------------------------------------------+
632 | PROJECT : GPRS (8441) MODULE : CMH_SMR |
633 | STATE : finnished ROUTINE : cmhSM_Deactivated |
634 +-------------------------------------------------------------------+
635
636 PURPOSE : confirms a successful PDP context deactivation
637
638 */
639
640 GLOBAL void cmhSM_Deactivated ( void )
641 {
642 T_CGEREP_EVENT_REP_PARAM event;
643 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
644 T_PDP_CONTEXT_STATE state;
645
646 U8 cid;
647 SHORT i,
648 reactivation = 0,
649 rat_id = RAT_MAX;
650 UBYTE cme_err = CME_ERR_GPRSUnspec, /* error number */
651 cmdBuf = smEntStat.curCmd; /* buffers current command */
652 U16 nsapi_set_to_free = smShrdPrm.nsapi_set;
653 T_DTI_CONN_LINK_ID dti_link_id;
654 UBYTE srcId = srcId_cb;
655
656 TRACE_FUNCTION ("cmhSM_Deactivated()");
657
658 /*
659 *-------------------------------------------------------------------
660 * check for command context
661 *-------------------------------------------------------------------
662 */
663
664 /* 28592 cmhSM_context_deactivated(smShrdPrm.nsapi_set); */
665
666 while((state = get_state_over_nsapi_set( &smShrdPrm.nsapi_set, &cid )) AND state NEQ PDP_CONTEXT_STATE_INVALID )
667 {
668 p_pdp_context_node = pdp_context_find_node_from_cid( cid );
669 if( !p_pdp_context_node )
670 {
671 TRACE_ERROR( "ERROR: PDP context not found, in function cmhSM_Deactivated" );
672 return;
673 }
674
675 dti_link_id = p_pdp_context_node->internal_data.link_id;
676
677 switch ( state )
678 {
679 case PDP_CONTEXT_STATE_INVALID:
680 case PDP_CONTEXT_STATE_DEFINED:
681 case PDP_CONTEXT_STATE_ATTACHING:
682 case PDP_CONTEXT_STATE_ESTABLISH_1:
683 case PDP_CONTEXT_STATE_ESTABLISH_3:
684 case PDP_CONTEXT_STATE_ACTIVATED:
685 case PDP_CONTEXT_STATE_ACTIVATED_ESTABLISH_1:
686 case PDP_CONTEXT_STATE_ACTIVATED_MODIFYING:
687 case PDP_CONTEXT_STATE_DATA_LINK:
688 case PDP_CONTEXT_STATE_DATA_LINK_MODIFYING:
689 default:
690 dumpContextInfo(cid);
691 continue;
692
693 case PDP_CONTEXT_STATE_ESTABLISH_2:
694
695 set_state_over_cid ( cid, PDP_CONTEXT_STATE_ABORT_ESTABLISH );
696 //asdf dti_cntrl_close_dpath_from_dti_id (EXTRACT_DTI_ID(dti_link_id));
697
698 break;
699
700 case PDP_CONTEXT_STATE_ABORT_ESTABLISH:
701 TRACE_EVENT("state: PDP_CONTEXT_STATE_ABORT_ESTABLISH");
702 set_state_over_cid ( cid, PDP_CONTEXT_STATE_DEFINED );
703 dti_cntrl_close_dpath_from_dti_id (EXTRACT_DTI_ID(dti_link_id));
704 cmhSM_disconnect_cid(cid, GC_TYPE_DATA_LINK);
705
706 if(ati_user_output_cfg[srcId].CMEE_stat EQ CMEE_MOD_Disable)
707 rat_id = RAT_NO_CARRIER;
708 else
709 rat_id = RAT_CME;
710 break;
711
712 case PDP_CONTEXT_STATE_BREAKDOWN_LINK_NORMAL:
713 TRACE_EVENT("state: CS_BREAKDOWN_LINK_NORMAL");
714 set_state_over_cid ( cid, PDP_CONTEXT_STATE_DEFINED );
715 dti_cntrl_close_dpath_from_dti_id (EXTRACT_DTI_ID(dti_link_id));
716 cmhSM_disconnect_cid(cid, GC_TYPE_DATA_LINK);
717 rat_id = RAT_NO_CARRIER;
718 break;
719
720 case PDP_CONTEXT_STATE_DEACTIVATE_NORMAL:
721 TRACE_EVENT("state: PDP_CONTEXT_DEACTIVATE_NORMAL") ;
722 set_state_over_cid ( cid, PDP_CONTEXT_STATE_DEFINED );
723
724 #if defined(FF_PKTIO) OR defined(FF_TCP_IP)
725 if( p_pdp_context_node->internal_data.entity_id EQ DTI_ENTITY_PKTIO )
726 {
727 /* Issue OMAPS00072119: For PKTIO, delete the SNDCP counter */
728 cmhSM_disconnect_cid(cid, GC_TYPE_NULL);
729 }
730 #endif
731
732 #if defined (CO_UDP_IP) OR defined (FF_GPF_TCPIP)
733 if ( is_ip_dti_id(p_pdp_context_node->internal_data.entity_id) )
734 if( Wap_Call )
735 {
736 /* tell WAP ACI that contextactivation was rejected */
737 psaTCPIP_Deactivate(cmhSM_IP_activate_cb);
738 }
739 #else /* (CO_UDP_IP) OR defined (FF_GPF_TCPIP) */
740 rat_id = RAT_NO_CARRIER;
741 #endif
742 break;
743
744 case PDP_CONTEXT_STATE_ACTIVATING:
745 TRACE_EVENT("state: PDP_CONTEXT_STATE_ACTIVATING");
746 set_state_over_cid ( cid, PDP_CONTEXT_STATE_DEFINED );
747
748 /* 18th April 2005. As till this date we are not handiling the correct
749 cause value between ACI and SM. As we are not mapping the cause values
750 sent by SM enity to ACI. This is creating problem to display wrong ERROR
751 values .*/
752
753 cme_err = cmhSM_mapSM2ACI_Cause(smShrdPrm.pdp_rej->ps_cause.value.nwsm_cause);
754 rat_id = RAT_CME;
755 break;
756
757 case PDP_CONTEXT_STATE_REACTIVATION_1:
758 TRACE_EVENT("state: PDP_CONTEXT_STATE_REACTIVATION_1");
759 set_state_over_cid ( cid, PDP_CONTEXT_STATE_REACTIVATION_2 );
760 dti_cntrl_close_dpath_from_dti_id (EXTRACT_DTI_ID(dti_link_id));
761 smEntStat.curCmd = AT_CMD_NONE;
762 nsapi_set_to_free &= ~( 1U << CID_TO_NSAPI(cid) ); /* 28592 */
763 continue;
764
765 case PDP_CONTEXT_STATE_REACTIVATION_2:
766 TRACE_EVENT("state: PDP_CONTEXT_STATE_REACTIVATION_2");
767 set_state_over_cid ( cid, PDP_CONTEXT_STATE_DEFINED );
768 dti_cntrl_close_dpath_from_dti_id (EXTRACT_DTI_ID(dti_link_id));
769 cmhSM_disconnect_cid(cid, GC_TYPE_DATA_LINK);
770 smEntStat.curCmd = AT_CMD_NONE;
771 rat_id = RAT_NO_CARRIER;
772 reactivation = 1;
773 break;
774 }
775
776 if ( reactivation EQ 0 )
777 {
778 switch( smEntStat.curCmd )
779 {
780 case( AT_CMD_CGDATA ):
781 case( AT_CMD_CGACT ):
782 TRACE_EVENT_P2("cmhSM_Deactivated: smEntStat.entOwn: Source = %d and GPRS related AT Command is smEntStat.curCmd: = %d", smEntStat.entOwn, smEntStat.curCmd );
783 cmhSM_clear_work_cids(cid);
784 break;
785 default:
786 TRACE_EVENT_P1("cmhSM_Deactivated: Current AT Command is smEntStat.curCmd: = %d", smEntStat.curCmd);
787 break;
788 }
789 }
790
791 strcpy( event.act.pdp_type, p_pdp_context_node->attributes.pdp_type );
792 memcpy(&(event.act.pdp_addr), &(p_pdp_context_node->internal_data.pdp_address_allocated), sizeof(T_NAS_ip));
793
794 event.act.cid = cid;
795 for( i = 0; i < CMD_SRC_MAX; i++ )
796 {
797 R_AT( RAT_CGEREP, (T_ACI_CMD_SRC)i ) ( CGEREP_EVENT_ME_DEACT, &event );
798 R_AT( RAT_P_CGEV, (T_ACI_CMD_SRC)i ) ( CGEREP_EVENT_ME_DEACT, &event );
799 }
800
801 if ( rat_id NEQ RAT_MAX )
802 {
803 gaci_RAT_caller ( rat_id, cid, cmdBuf, cme_err );
804
805 rat_id = RAT_MAX;
806
807 cmhSM_clear_work_cids(cid);
808 cmhSM_context_reactivation();
809 }
810 }
811
812 cmhSM_context_deactivated(nsapi_set_to_free); /* 28592 */
813 cmhSM_contextDeactivated();
814 }
815
816 /*
817 +-------------------------------------------------------------------+
818 | PROJECT : GPRS (8441) MODULE : CMH_SMR |
819 | STATE : finnished ROUTINE : cmhSM_NetDeactivate |
820 +-------------------------------------------------------------------+
821
822 PURPOSE : indicates a PDP context deactivation
823
824 */
825 GLOBAL void cmhSM_NetDeactivate ( void )
826 {
827 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
828 T_PDP_CONTEXT_INTERNAL *p_prev_pdp_context_node = NULL;
829 T_CGEREP_EVENT_REP_PARAM event;
830 T_PDP_CONTEXT_STATE state;
831 U8 cid;
832 SHORT i = 0,
833 inform_ppp = 1,
834 rat_id = RAT_MAX;
835 UBYTE cme_err = CME_ERR_Unknown, /* error number */
836 cmdBuf = AT_CMD_NONE; /* buffers current command */
837 T_DTI_CONN_LINK_ID dti_link_id;
838
839 USHORT temp_nsapiSet = smShrdPrm.nsapi_set;
840 UBYTE srcId = srcId_cb;
841
842
843 TRACE_FUNCTION ("cmhSM_NetDeactivate()");
844
845 /* 28592 cmhSM_context_deactivated(smShrdPrm.nsapi_set); */
846
847 while( (smShrdPrm.nsapi_set) AND (PDP_CONTEXT_STATE_INVALID NEQ (state = get_state_over_nsapi_set( &smShrdPrm.nsapi_set, &cid )) ))
848 {
849
850 p_pdp_context_node = pdp_context_find_node_from_cid( cid );
851 if( !p_pdp_context_node )
852 {
853 TRACE_ERROR( "ERROR: PDP context not found, in function cmhSM_NetDeactivate" );
854 continue; /* Try the next... */
855 }
856
857 dti_link_id = p_pdp_context_node->internal_data.link_id;
858
859 switch ( state )
860 {
861 case PDP_CONTEXT_STATE_INVALID:
862 case PDP_CONTEXT_STATE_DEFINED:
863 case PDP_CONTEXT_STATE_ESTABLISH_1:
864 case PDP_CONTEXT_STATE_ATTACHING:
865 TRACE_EVENT("PDP context state ignored, continue");
866 continue;
867
868 case PDP_CONTEXT_STATE_ESTABLISH_2:
869 case PDP_CONTEXT_STATE_ESTABLISH_3:
870 case PDP_CONTEXT_STATE_ACTIVATED_ESTABLISH_1:
871 set_state_over_cid ( cid, PDP_CONTEXT_STATE_ABORT_ESTABLISH );
872 dti_cntrl_close_dpath_from_dti_id (EXTRACT_DTI_ID(dti_link_id));
873 break;
874
875 case PDP_CONTEXT_STATE_ABORT_ESTABLISH:
876 set_state_over_cid ( cid, PDP_CONTEXT_STATE_DEFINED );
877 dti_cntrl_close_dpath_from_dti_id (EXTRACT_DTI_ID(dti_link_id));
878 cmhSM_disconnect_cid(cid, GC_TYPE_DATA_LINK);
879 inform_ppp = 0;
880 if(ati_user_output_cfg[srcId].CMEE_stat EQ CMEE_MOD_Disable)
881 rat_id = RAT_NO_CARRIER;
882 else
883 rat_id = RAT_CME;
884 break;
885
886 case PDP_CONTEXT_STATE_BREAKDOWN_LINK_NORMAL:
887 set_state_over_cid ( cid, PDP_CONTEXT_STATE_DEFINED );
888 dti_cntrl_close_dpath_from_dti_id (EXTRACT_DTI_ID(dti_link_id));
889 cmhSM_disconnect_cid(cid, GC_TYPE_DATA_LINK);
890 rat_id = RAT_NO_CARRIER;
891 inform_ppp = 0;
892 break;
893
894 #ifdef REL99
895 case PDP_CONTEXT_STATE_DATA_LINK_MODIFYING:
896 /* Reject +CGCMOD command if executing. Network context deactivation has higher priority. */
897 if (smEntStat.curCmd EQ AT_CMD_CGCMOD)
898 {
899 /* Answer the executing source not the data source for cid */
900 R_AT( RAT_CME, smEntStat.entOwn ) ( smEntStat.curCmd, CME_ERR_GPRSUnspec );
901 /* Remove command */
902 smEntStat.curCmd = AT_CMD_NONE;
903 cid_pointer = 0;
904 work_cids[0] = PDP_CONTEXT_CID_OMITTED;
905 }
906 #endif
907 /* Fall through */
908 case PDP_CONTEXT_STATE_DATA_LINK:
909 set_state_over_cid ( cid, PDP_CONTEXT_STATE_BREAKDOWN_LINK_NORMAL );
910 dti_cntrl_close_dpath_from_dti_id (EXTRACT_DTI_ID(dti_link_id));
911 break;
912 #ifdef REL99
913 case PDP_CONTEXT_STATE_ACTIVATED_MODIFYING:
914 /* Reject +CGCMOD command if executing. Network context deactivation has higher priority. */
915 if (smEntStat.curCmd EQ AT_CMD_CGCMOD)
916 {
917 /* Answer the executing source not the data source for cid */
918 R_AT( RAT_CME, smEntStat.entOwn ) ( smEntStat.curCmd, CME_ERR_GPRSUnspec );
919 /* Remove command */
920 smEntStat.curCmd = AT_CMD_NONE;
921 cid_pointer = 0;
922 work_cids[0] = PDP_CONTEXT_CID_INVALID;
923 }
924 /* Fall through */
925 #endif
926 case PDP_CONTEXT_STATE_ACTIVATED:
927 p_prev_pdp_context_node = pdp_context_find_node_from_cid( cid );
928 inform_ppp = 0;
929
930 /* Issue OMAPS00062126: new case of connection failed, AT+CGDATA return ERROR */
931 if( (state EQ PDP_CONTEXT_STATE_ACTIVATED) AND
932 (p_prev_pdp_context_node->internal_data.entity_id EQ DTI_ENTITY_PKTIO) )
933 {
934 TRACE_EVENT("Free the DTI Links for PKTIO Entity after AT+CFUN=0");
935 dti_cntrl_close_dpath_from_dti_id (EXTRACT_DTI_ID(p_prev_pdp_context_node->internal_data.link_id));
936 }
937
938 set_state_over_cid ( cid, PDP_CONTEXT_STATE_DEFINED );
939
940 #if defined (CO_UDP_IP) OR defined (FF_GPF_TCPIP)
941 if ( is_ip_dti_id(p_pdp_context_node->internal_data.entity_id) )
942 {
943 if ( p_prev_pdp_context_node->internal_data.entity_id EQ DTI_ENTITY_IP )
944 {
945 /* tell WAP ACI that contextactivation was rejected */
946 psaTCPIP_Deactivate(cmhSM_IP_activate_cb);
947 dti_cntrl_close_dpath_from_dti_id (EXTRACT_DTI_ID(dti_link_id));
948 }
949 }
950 else
951 #endif /* WAP OR SAT E */
952 {
953 cmhSM_disconnect_cid(cid, GC_TYPE_NULL);
954 }
955 rat_id = RAT_NO_CARRIER;
956
957 break;
958
959 case PDP_CONTEXT_STATE_DEACTIVATE_NORMAL:
960 p_prev_pdp_context_node = pdp_context_find_node_from_cid( cid );
961 set_state_over_cid ( cid, PDP_CONTEXT_STATE_DEFINED );
962
963 #if defined (FF_WAP) OR defined (FF_SAT_E)
964 inform_ppp = 0;
965 if ( p_prev_pdp_context_node->internal_data.entity_id EQ DTI_ENTITY_IP )
966 {
967 /* tell WAP ACI that contextactivation was rejected */
968 dti_cntrl_close_dpath_from_dti_id (EXTRACT_DTI_ID(dti_link_id));
969 psaTCPIP_Deactivate(cmhSM_IP_activate_cb);
970 }
971 else
972 #endif /* WAP OR SAT E */
973 {
974 cmhSM_disconnect_cid(cid, GC_TYPE_NULL);
975 }
976 rat_id = RAT_NO_CARRIER; /* it required ?!! */
977 break;
978
979 case PDP_CONTEXT_STATE_ACTIVATING:
980 p_prev_pdp_context_node = pdp_context_find_node_from_cid( cid );
981 inform_ppp = 0;
982 set_state_over_cid ( cid, PDP_CONTEXT_STATE_DEFINED );
983
984 #if defined (FF_WAP) OR defined (FF_SAT_E)
985 if ( p_prev_pdp_context_node->internal_data.entity_id EQ DTI_ENTITY_IP )
986 {
987 /* tell WAP ACI that contextactivation was rejected */
988 psaTCPIP_Deactivate(cmhSM_IP_activate_cb);
989 dti_cntrl_close_dpath_from_dti_id (EXTRACT_DTI_ID(dti_link_id));
990 }
991 #endif /* WAP OR SAT E */
992 rat_id = RAT_CME;
993 break;
994
995 case PDP_CONTEXT_STATE_REACTIVATION_1:
996 set_state_over_cid(cid, PDP_CONTEXT_STATE_REACTIVATION_2);
997 cmhSM_stop_context_reactivation();
998 temp_nsapiSet &= ~( 1U << CID_TO_NSAPI(cid) ); /* 28592 */
999 continue;
1000
1001 case PDP_CONTEXT_STATE_REACTIVATION_2:
1002 set_state_over_cid ( cid, PDP_CONTEXT_STATE_DEFINED );
1003 cmhSM_stop_context_reactivation();
1004 rat_id = RAT_NO_CARRIER;
1005 inform_ppp = 0;
1006 break;
1007 }
1008
1009 if ( inform_ppp )
1010 {
1011 /*
1012 *---------------------------------------------------------------
1013 * inform PPP
1014 *---------------------------------------------------------------
1015 */
1016 psaGPPP_Terminate( PPP_LOWER_LAYER_UP );
1017 }
1018
1019 switch( smEntStat.curCmd )
1020 {
1021 case( AT_CMD_CGDATA ):
1022 case( AT_CMD_CGACT ):
1023 TRACE_EVENT_P2("cmhSM_NetDeactivate: smEntStat.entOwn: Source = %d and GPRS related AT Command is smEntStat.curCmd: = %d", smEntStat.entOwn, smEntStat.curCmd );
1024 cmhSM_clear_work_cids(cid);
1025 break;
1026 default:
1027 TRACE_EVENT_P1("cmhSM_NetDeactivate: Current AT Command is smEntStat.curCmd: = %d", smEntStat.curCmd);
1028 break;
1029 }
1030
1031 /*
1032 * GPRS event reporting
1033 */
1034 strcpy( event.act.pdp_type, p_pdp_context_node->attributes.pdp_type );
1035 memcpy(&(event.act.pdp_addr), &(p_pdp_context_node->internal_data.pdp_address_allocated), sizeof(T_NAS_ip));
1036 event.act.cid = cid;
1037 for( i = 0; i < CMD_SRC_MAX; i++ )
1038 {
1039 R_AT( RAT_CGEREP, (T_ACI_CMD_SRC)i ) ( CGEREP_EVENT_NW_DEACT, &event );
1040 R_AT( RAT_P_CGEV, (T_ACI_CMD_SRC)i ) ( CGEREP_EVENT_NW_DEACT, &event );
1041 }
1042
1043 if ( rat_id NEQ RAT_MAX )
1044 {
1045
1046 /* Below code will decide whether to send NO CARRIER OR NOT
1047 depeding on the context flags and source's
1048 */
1049
1050 if ( !( gmmShrdPrm.gprs_call_killer EQ p_pdp_context_node->internal_data.owner ) )
1051 {
1052 gaci_RAT_caller ( rat_id, cid, cmdBuf, cme_err );
1053 }
1054
1055 gmmShrdPrm.gprs_call_killer = (UBYTE)CMD_SRC_NONE;
1056
1057 cmhSM_clear_work_cids(cid);
1058 rat_id = RAT_MAX;
1059 }
1060 }
1061
1062 cmhSM_context_deactivated(temp_nsapiSet);
1063 cmhSM_contextDeactivated();
1064 /* inform SAT if needed */
1065 #if defined (FF_SAT_E)
1066 cmhSAT_OpChnGPRSDeact();
1067 #endif
1068 }
1069
1070 /*
1071 +-------------------------------------------------------------------+
1072 | PROJECT : GPRS (8441) MODULE : CMH_SMR |
1073 | STATE : finnished ROUTINE : cmhSM_NetModify |
1074 +-------------------------------------------------------------------+
1075
1076 PURPOSE : indicates a network initiated PDP context modification
1077
1078 */
1079 GLOBAL void cmhSM_NetModify( T_SMREG_PDP_MODIFY_IND *smreg_pdp_modify_ind )
1080 {
1081 U8 cid = 0;
1082 U8 i = 0;
1083 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
1084
1085 TRACE_FUNCTION ("cmhSM_NetModify()");
1086
1087 if( get_state_over_cid( NSAPI_TO_CID( smreg_pdp_modify_ind->nsapi ) ) NEQ PDP_CONTEXT_STATE_INVALID )
1088 {
1089 p_pdp_context_node = pdp_context_find_node_from_cid( NSAPI_TO_CID( smreg_pdp_modify_ind->nsapi ) );
1090 cid = p_pdp_context_node->cid;
1091 if( p_pdp_context_node )
1092 {
1093 /* Store the QoS indicated by the network */
1094 p_pdp_context_node->ctrl_neg_qos = smreg_pdp_modify_ind->ctrl_qos;
1095 switch( smreg_pdp_modify_ind->ctrl_qos )
1096 {
1097 case PS_is_R97:
1098 memcpy( &p_pdp_context_node->neg_qos.qos_r97, &smreg_pdp_modify_ind->qos.qos_r97, sizeof(T_PS_qos_r97) );
1099 break;
1100 case PS_is_R99:
1101 memcpy( &p_pdp_context_node->neg_qos.qos_r99, &smreg_pdp_modify_ind->qos.qos_r99, sizeof(T_PS_qos_r99) );
1102 break;
1103 default:
1104 TRACE_ERROR( "QoS type indicated by NW not supported" );
1105 }
1106
1107 /* inform all sources */
1108 for( i = 0 ; i < CMD_SRC_MAX; i++ )
1109 {
1110 switch( p_pdp_context_node->ctrl_neg_qos )
1111 {
1112 case PS_is_R97:
1113 R_AT( RAT_QOS_MOD,(T_ACI_CMD_SRC) i ) ( cid, p_pdp_context_node->neg_qos.qos_r97 ); /* the macro must be updated, QoS type changed !!! */
1114 break;
1115 case PS_is_R99:
1116 R_AT( RAT_QOS_MOD,(T_ACI_CMD_SRC) i ) ( cid, p_pdp_context_node->neg_qos.qos_r99 ); /* the macro must be updated, QoS type changed !!! */
1117 break;
1118 }
1119 }
1120
1121 }
1122 else
1123 {
1124 TRACE_ERROR( "PDP context not found, in function cmhSM_NetModify" );
1125 }
1126 }
1127 else
1128 {
1129 TRACE_ERROR( "PDP context for the given nsapi is in the wrong state" );
1130 }
1131
1132 }
1133
1134
1135 /*
1136 +-------------------------------------------------------------------+
1137 | PROJECT : GPRS (8441) MODULE : CMH_SMR |
1138 | STATE : finnished ROUTINE : cmhSM_Modified |
1139 +-------------------------------------------------------------------+
1140
1141 PURPOSE : indicates that the MT initiated PDP context modification
1142 was successful. Continue to modify the rest of the contexts
1143 until the work_cids list is empty.
1144
1145 */
1146 #ifdef REL99
1147 GLOBAL SHORT cmhSM_Modified( T_SMREG_PDP_MODIFY_CNF *smreg_pdp_modify_cnf )
1148 {
1149
1150 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
1151
1152 TRACE_FUNCTION ("cmhSM_Modified()");
1153
1154 if ( NSAPI_TO_CID( smreg_pdp_modify_cnf->nsapi ) NEQ work_cids[cid_pointer])
1155 {
1156 /* Wrong nsapi received from SM */
1157 TRACE_ERROR("WRONG NSAPI. Ignored.");
1158 return -1;
1159 }
1160
1161 p_pdp_context_node = pdp_context_find_node_from_cid( work_cids[cid_pointer] );
1162
1163 if( p_pdp_context_node EQ NULL )
1164 {
1165 TRACE_ERROR ("PDP context not found");
1166 return -1;
1167 }
1168
1169 /* This context was successful modified: Change state back. */
1170 switch( get_state_working_cid() )
1171 {
1172 case PDP_CONTEXT_STATE_ACTIVATED_MODIFYING:
1173 set_state_working_cid( PDP_CONTEXT_STATE_ACTIVATED );
1174 break;
1175
1176 case PDP_CONTEXT_STATE_DATA_LINK_MODIFYING:
1177 set_state_working_cid( PDP_CONTEXT_STATE_DATA_LINK );
1178 break;
1179
1180 default:
1181 /* Error handling */
1182 TRACE_ERROR("WRONG STATE for context.");
1183 /* Reject command if possible */
1184 if (smEntStat.curCmd EQ AT_CMD_CGCMOD)
1185 {
1186 R_AT( RAT_CME, smEntStat.entOwn ) ( smEntStat.curCmd, CME_ERR_GPRSUnspec );
1187 smEntStat.curCmd = AT_CMD_NONE;
1188 cid_pointer = 0;
1189 work_cids[0] = PDP_CONTEXT_CID_INVALID;
1190 }
1191 else
1192 {
1193 TRACE_ERROR("SMREG_PDP_MODIFY_CNF received but +CGCMOD not executed");
1194 }
1195 return -1;
1196 }
1197
1198
1199
1200 cid_pointer ++; // This might be wrong
1201
1202
1203 /* Investigate if more contexts to modify */
1204 if( (cid_pointer EQ PDP_CONTEXT_CID_MAX) OR (work_cids[cid_pointer] EQ PDP_CONTEXT_CID_INVALID) )
1205 {
1206 /* No more contexts to modify. All context modification were successful. */
1207
1208 switch( smEntStat.curCmd )
1209 {
1210 case AT_CMD_CGACT:
1211 {
1212 R_AT( RAT_CGACT, smEntStat.entOwn )(0);
1213 break;
1214 }
1215 case AT_CMD_CGCMOD:
1216 {
1217 R_AT( RAT_CGCMOD, smEntStat.entOwn )();
1218 break;
1219 }
1220 }
1221
1222 R_AT( RAT_OK, smEntStat.entOwn ) ( smEntStat.curCmd );
1223 smEntStat.curCmd = AT_CMD_NONE;
1224 cid_pointer = 0;
1225 work_cids[0] = PDP_CONTEXT_CID_INVALID;
1226
1227 }
1228 else
1229 {
1230 /* More contexts to modify */
1231 switch (get_state_over_cid(work_cids[cid_pointer]))
1232 {
1233 case PDP_CONTEXT_STATE_ACTIVATED:
1234 set_state_over_cid(work_cids[cid_pointer], PDP_CONTEXT_STATE_ACTIVATED_MODIFYING);
1235 /* Send next modify request */
1236 psaSM_PDP_Modify();
1237 break;
1238
1239 case PDP_CONTEXT_STATE_DATA_LINK:
1240 set_state_over_cid(work_cids[cid_pointer], PDP_CONTEXT_STATE_DATA_LINK_MODIFYING);
1241 /* Send next modify request */
1242 psaSM_PDP_Modify();
1243 break;
1244
1245 default:
1246 {
1247 /* The state has changed probably due to network deactivation. The command fails. */
1248 R_AT( RAT_CME, smEntStat.entOwn ) ( smEntStat.curCmd, CME_ERR_GPRSUnspec );
1249 smEntStat.curCmd = AT_CMD_NONE;
1250 cid_pointer = 0;
1251 work_cids[0] = PDP_CONTEXT_CID_INVALID;
1252 }
1253 }
1254 }
1255 return 0;
1256 }
1257 #endif
1258
1259
1260
1261 /*
1262 +-------------------------------------------------------------------+
1263 | PROJECT : GPRS (8441) MODULE : CMH_SMR |
1264 | STATE : finnished ROUTINE : cmhSM_NoModify |
1265 +-------------------------------------------------------------------+
1266
1267 PURPOSE : indicates that the MT initiated PDP context modification
1268 failed.
1269 RETURN : Callback with CME ERROR or just ERROR.
1270 */
1271 #ifdef REL99
1272 GLOBAL SHORT cmhSM_NoModify( T_SMREG_PDP_MODIFY_REJ *smreg_pdp_modify_rej )
1273 {
1274 SHORT result = 0;
1275
1276
1277 TRACE_FUNCTION ("cmhSM_NoModify()");
1278
1279 if (smreg_pdp_modify_rej EQ NULL)
1280 return -1;
1281
1282 switch( smEntStat.curCmd )
1283 {
1284 case AT_CMD_CGCMOD:
1285 {
1286 /* Reset state to the previous. */
1287 switch( get_state_working_cid() )
1288 {
1289 case PDP_CONTEXT_STATE_ACTIVATED_MODIFYING:
1290 set_state_working_cid( PDP_CONTEXT_STATE_ACTIVATED );
1291 break;
1292
1293 case PDP_CONTEXT_STATE_DATA_LINK_MODIFYING:
1294 set_state_working_cid( PDP_CONTEXT_STATE_DATA_LINK );
1295 break;
1296
1297 default:
1298 TRACE_FUNCTION("State for modified context has been changed (Network deactivation?).");
1299 }
1300
1301 /* Reject the +CGCMOD command */
1302 R_AT( RAT_CME, smEntStat.entOwn ) ( smEntStat.curCmd, CME_ERR_GPRSUnspec );
1303 smEntStat.curCmd = AT_CMD_NONE;
1304 cid_pointer = 0;
1305 work_cids[0] = PDP_CONTEXT_CID_INVALID;
1306 break;
1307 }
1308
1309 default:
1310 {
1311 result = -1;
1312 break;
1313 }
1314 } /* End switch( smEntStat.curCm ) */
1315
1316 return result;
1317
1318 }
1319
1320 #endif
1321
1322 /*
1323 +-------------------------------------------------------------------+
1324 | PROJECT : UMTS MODULE : CMH_SMR |
1325 | STATE : ROUTINE : cmhSM_ActivatedSecondary |
1326 +-------------------------------------------------------------------+
1327
1328 PURPOSE : confirms a successful secondary context activation
1329
1330 */
1331 #ifdef REL99
1332 GLOBAL SHORT cmhSM_ActivatedSecondary( T_SMREG_PDP_ACTIVATE_SEC_CNF *p_smreg_pdp_activate_sec_cnf )
1333 {
1334 U8 cid = work_cids[cid_pointer];
1335 T_PDP_CONTEXT_INTERNAL *p_pdp_context_sec_node = NULL;
1336
1337 TRACE_FUNCTION ("cmhSM_ActivatedSecondary()");
1338
1339 /*
1340 * Find the secondary PDP context
1341 */
1342 p_pdp_context_sec_node = pdp_context_find_node_from_cid( cid );
1343 if( !p_pdp_context_sec_node )
1344 {
1345 TRACE_ERROR( "ERROR: PDP context not found, in function cmhSM_ActivatedSecondary" );
1346 return -1;
1347 }
1348
1349 /*
1350 *-------------------------------------------------------------------
1351 * check for command context
1352 *-------------------------------------------------------------------
1353 */
1354 switch( smEntStat.curCmd )
1355 {
1356 case( AT_CMD_CGACT ):
1357 TRACE_EVENT("CGACT is current command");
1358 if( get_state_working_cid() NEQ PDP_CONTEXT_STATE_ACTIVATING )
1359 {
1360 /*
1361 * no action
1362 */
1363
1364 return 0;
1365 }
1366 R_AT( RAT_CGACT, smEntStat.entOwn )(p_pdp_context_sec_node->internal_data.link_id);
1367
1368 set_state_working_cid( PDP_CONTEXT_STATE_ACTIVATED );
1369
1370 /*
1371 * do we need one more context activation
1372 */
1373
1374 if( cmhSM_next_work_cid( AT_CMD_CGACT ) EQ FALSE )
1375 {
1376 R_AT( RAT_OK, smEntStat.entOwn ) ( smEntStat.curCmd );
1377
1378 /* log result */
1379 cmh_logRslt ( smEntStat.entOwn, RAT_OK, smEntStat.curCmd, -1, BS_SPEED_NotPresent,CME_ERR_NotPresent);
1380
1381 smEntStat.curCmd = AT_CMD_NONE;
1382 }
1383
1384
1385 break;
1386
1387 case( AT_CMD_CGDATA ):
1388 TRACE_EVENT("CGDATA is current command");
1389 if( get_state_working_cid() NEQ PDP_CONTEXT_STATE_ESTABLISH_2 )
1390 {
1391 /*
1392 * no action
1393 */
1394 return 0;
1395 }
1396
1397 /*
1398 *---------------------------------------------------------------
1399 * inform PPP
1400 *---------------------------------------------------------------
1401 */
1402 psaGPPP_PDP_Activate( &p_pdp_context_sec_node->internal_data.pdp_address_allocated,
1403 p_pdp_context_sec_node->internal_data.user_pco.pco,
1404 p_pdp_context_sec_node->internal_data.user_pco.len,
1405 (U8)CID_TO_NSAPI( p_pdp_context_sec_node->cid ) );
1406
1407 set_state_working_cid( PDP_CONTEXT_STATE_ESTABLISH_3 );
1408
1409 break;
1410
1411 default:
1412 TRACE_EVENT("current command not detected!");
1413 return -1;
1414 }
1415
1416 TRACE_EVENT_P2( "cmhSM_Activated, dti_entity_connected, dti_it = %d, cid_ptr = %d",
1417 p_pdp_context_sec_node->internal_data.link_id, cid_pointer );
1418 dti_cntrl_entity_connected(p_pdp_context_sec_node->internal_data.link_id, DTI_ENTITY_SNDCP, DTI_OK);
1419
1420 return 0;
1421 }
1422 #endif /* REL99 */
1423
1424
1425 #ifdef REL99
1426 GLOBAL SHORT cmhSM_NoActivateSecondary( T_SMREG_PDP_ACTIVATE_SEC_REJ *p_smreg_pdp_activate_sec_rej )
1427 {
1428 short res = 0;
1429
1430 TRACE_FUNCTION( "cmhSM_NoActivateSecondary" );
1431 TRACE_EVENT( "This funciton is not implemented!" );
1432
1433 return res;
1434 }
1435 #endif /* REL99 */
1436 GLOBAL BOOL PKTIO_UPM_connect_dti_cb(UBYTE dti_id, T_DTI_CONN_STATE result_type)
1437 {
1438 U8 cid;
1439 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
1440
1441 TRACE_FUNCTION("PKTIO_UPM_connect_dti_cb");
1442
1443 switch( result_type)
1444 {
1445 case DTI_CONN_STATE_DISCONNECTING:
1446 cid = (U8)gaci_get_cid_over_dti_id(dti_id);
1447 p_pdp_context_node = pdp_context_find_node_from_cid(cid);
1448
1449 if( (INVALID_CID NEQ cid ) AND
1450 ( PDP_CONTEXT_STATE_ACTIVATING EQ get_state_over_cid(cid)) AND
1451 (( DTI_ENTITY_PKTIO EQ p_pdp_context_node->internal_data.entity_id) OR
1452 (DTI_ENTITY_AAA EQ p_pdp_context_node->internal_data.entity_id)))
1453 {
1454 cmhSM_deactivateAContext(CMD_SRC_NONE, cid);
1455 set_state_over_cid( cid, PDP_CONTEXT_STATE_DEACTIVATE_NORMAL);
1456 }
1457 break;
1458 case DTI_CONN_STATE_DISCONNECTED:
1459 case DTI_CONN_STATE_CONNECTING:
1460 case DTI_CONN_STATE_CONNECTED:
1461 break;
1462 case DTI_CONN_STATE_ERROR:
1463 /* connection not possible: disconnect SNDCP */
1464 dti_cntrl_close_dpath_from_dti_id( dti_id );
1465 break;
1466 case DTI_CONN_STATE_UNKNOWN:
1467 default:
1468 TRACE_EVENT("PKTIO_UPM_connect_dti_cb call with not awaited value");
1469 break;
1470 }
1471 return TRUE;
1472 }
1473
1474
1475 #endif /* GPRS */
1476 /*==== EOF ========================================================*/