comparison g23m-aci/aci/cmh_gpppr.c @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
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 Point-to-Point Protocol ( PPP ).
20 +-----------------------------------------------------------------------------
21 */
22
23 #if defined (GPRS) && defined (DTI)
24
25 #ifndef CMH_GPPPR_C
26 #define CMH_GPPPR_C
27 #endif
28
29 #include "aci_all.h"
30 /*==== INCLUDES ===================================================*/
31
32 #include "dti.h" /* functionality of the dti library */
33 #include "aci_cmh.h"
34 #include "ati_cmd.h"
35 #include "aci_cmd.h"
36
37 #include "dti_conn_mng.h"
38 #include "dti_cntrl_mng.h"
39
40 #include "aci.h"
41 #include "gaci.h"
42 #include "gaci_cmh.h"
43 #include "psa.h"
44 #include "psa_gppp.h"
45 #include "psa_sm.h"
46 #include "psa_uart.h"
47
48 #include "psa_aaa.h"
49
50 #include "cmh.h"
51 #include "cmh_gppp.h"
52 #include "cmh_sm.h"
53
54 #include "sap_dti.h"
55
56 /*==== CONSTANTS ==================================================*/
57
58
59 /*==== TYPES ======================================================*/
60
61
62 /*==== EXPORT =====================================================*/
63
64
65 /*==== VARIABLES ==================================================*/
66
67 /*==== FUNCTIONS ==================================================*/
68
69 /*
70 +-------------------------------------------------------------------+
71 | PROJECT : GPRS (8441) MODULE : CMH_PPPR |
72 | STATE : finnished ROUTINE : cmhGPPP_Established |
73 +-------------------------------------------------------------------+
74
75 PURPOSE : establish a PPP link was successful
76
77 */
78 GLOBAL SHORT cmhGPPP_Established ( void )
79 {
80
81 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
82
83 TRACE_FUNCTION ("cmhGPPP_Established()");
84
85 p_pdp_context_node = pdp_context_find_node_from_cid( work_cids[cid_pointer] );
86
87 if( p_pdp_context_node )
88 {
89 switch( gpppEntStat.curCmd )
90 {
91 case( AT_CMD_CGDATA ):
92 /* no action, because the PDP context will be terminated */
93 if( get_state_working_cid() NEQ PDP_CONTEXT_STATE_ESTABLISH_3 )
94 {
95 return 0;
96 }
97 else
98 {
99 set_state_working_cid( PDP_CONTEXT_STATE_DATA_LINK );
100 /*
101 * do we need one more context activation
102 */
103 if( cmhSM_next_work_cid( AT_CMD_CGDATA ) EQ FALSE )
104 {
105 /* todo for new DTI interface - SMNEW done 06032001... */
106 R_AT( RAT_CGDATA, gpppEntStat.entOwn )( p_pdp_context_node->internal_data.link_id ); /* UACI */
107 /* PHE 201201 gpppEntStat.curCmd = AT_CMD_NONE; */
108 }
109 }
110
111 cmhSM_next_call_table_entry();
112 break;
113 }
114 }
115 else
116 {
117 TRACE_ERROR( "ERROR: PDP context not found, in function cmhGPPP_Established" );
118 }
119 return 0;
120 }
121
122
123 /*
124 +-------------------------------------------------------------------+
125 | PROJECT : GPRS (8441) MODULE : CMH_PPPR |
126 | STATE : code ROUTINE : cmhGPPP_Terminated |
127 +-------------------------------------------------------------------+
128
129 PURPOSE : PPP connection is closed
130
131 */
132 GLOBAL SHORT cmhGPPP_Terminated ( void )
133 {
134 T_ACI_CMD_SRC rat_owner;
135 UBYTE cmdBuf = gpppEntStat.curCmd, /* buffers current command */
136 cme_err = CME_ERR_Unknown; /* error number */
137 U8 cid = PDP_CONTEXT_CID_INVALID;
138 SHORT reactivation = 0,
139 rat_id = RAT_MAX;
140 USHORT nsapi_set = 0;
141 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
142 #ifdef FF_TCP_IP
143 T_DTI_ENTITY_ID peer;
144 #endif
145 UBYTE srcId = srcId_cb;
146
147 TRACE_FUNCTION ("cmhGPPP_Terminated()");
148
149 cid = gaci_get_cid_over_link_id(gaci_get_link_id_over_peer(DTI_ENTITY_PPPS));
150
151 p_pdp_context_node = pdp_context_find_node_from_cid( cid );
152
153 #ifdef FF_TCP_IP
154 peer = dti_cntrl_get_peer(DTI_ENTITY_PPPS, 0, 0);
155 if ( peer EQ DTI_ENTITY_AAA )
156 {
157 psaAAA_disconnect_ind (p_pdp_context_node->internal_data.link_id_uart);
158 }
159 #endif
160
161 if( p_pdp_context_node )
162 {
163 cid = p_pdp_context_node->cid;
164
165 /*
166 *-------------------------------------------------------------------
167 * Inform the DTI Manager about the link termination.
168 *-------------------------------------------------------------------
169 */
170 dti_cntrl_entity_disconnected( p_pdp_context_node->internal_data.link_id , DTI_ENTITY_PPPS );
171 dti_cntrl_entity_disconnected( p_pdp_context_node->internal_data.link_id_uart, DTI_ENTITY_PPPS );
172
173 switch ( get_state_over_cid( cid ) )
174 {
175 case PDP_CONTEXT_STATE_INVALID:
176 case PDP_CONTEXT_STATE_DEFINED:
177 case PDP_CONTEXT_STATE_ATTACHING:
178 case PDP_CONTEXT_STATE_ACTIVATING:
179 case PDP_CONTEXT_STATE_ACTIVATED:
180 case PDP_CONTEXT_STATE_DEACTIVATE_NORMAL:
181 TRACE_ERROR( "cmhGPPP_Terminated(): State/Event error!!!" );
182 break;
183
184 case PDP_CONTEXT_STATE_ESTABLISH_2:
185 case PDP_CONTEXT_STATE_ESTABLISH_3:
186 case PDP_CONTEXT_STATE_ACTIVATED_ESTABLISH_1:
187 set_state_over_cid( cid, PDP_CONTEXT_STATE_ABORT_ESTABLISH );
188 nsapi_set = cmhSM_Give_nsapi_set( cid );
189 dti_cntrl_set_dti_id_to_reconnect(EXTRACT_DTI_ID(p_pdp_context_node->internal_data.link_id));
190 break;
191
192 case PDP_CONTEXT_STATE_ESTABLISH_1:
193 cmhSM_contextDeactivated();
194
195 /*lint -fallthrough*/
196 case PDP_CONTEXT_STATE_ABORT_ESTABLISH:
197 set_state_over_cid( cid, PDP_CONTEXT_STATE_DEFINED );
198 /* Close the data path since this can not be done from CMH_SM (no activating/activated context) */
199 dti_cntrl_close_dpath_from_dti_id( EXTRACT_DTI_ID(p_pdp_context_node->internal_data.link_id) );
200
201 dti_cntrl_set_dti_id_to_reconnect(EXTRACT_DTI_ID(p_pdp_context_node->internal_data.link_id));
202 if(ati_user_output_cfg[srcId].CMEE_stat EQ CMEE_MOD_Disable OR isContextDeactivationRequestedByCGACT(cid))
203 rat_id = RAT_NO_CARRIER;
204 else
205 rat_id = RAT_CME;
206 break;
207
208 case PDP_CONTEXT_STATE_BREAKDOWN_LINK_NORMAL:
209 set_state_over_cid( cid, PDP_CONTEXT_STATE_DEFINED );
210 dti_cntrl_set_dti_id_to_reconnect(EXTRACT_DTI_ID(p_pdp_context_node->internal_data.link_id));
211 rat_id = RAT_NO_CARRIER;
212 break;
213
214 case PDP_CONTEXT_STATE_DATA_LINK:
215 set_state_over_cid( cid, PDP_CONTEXT_STATE_BREAKDOWN_LINK_NORMAL );
216 nsapi_set = cmhSM_Give_nsapi_set( cid );
217 dti_cntrl_set_dti_id_to_reconnect(EXTRACT_DTI_ID(p_pdp_context_node->internal_data.link_id));
218 break;
219
220 case PDP_CONTEXT_STATE_REACTIVATION_1:
221 set_state_over_cid( cid, PDP_CONTEXT_STATE_REACTIVATION_2 );
222 dti_cntrl_set_dti_id_to_reconnect(EXTRACT_DTI_ID(p_pdp_context_node->internal_data.link_id));
223 gpppEntStat.curCmd = AT_CMD_NONE;
224 /* 28592 cmhSM_connection_down(EXTRACT_DTI_ID(p_pdp_context_node->internal_data.link_id)); */
225 return 0;
226
227 case PDP_CONTEXT_STATE_REACTIVATION_2:
228 set_state_over_cid( cid, PDP_CONTEXT_STATE_DEFINED );
229 dti_cntrl_set_dti_id_to_reconnect(EXTRACT_DTI_ID(p_pdp_context_node->internal_data.link_id));
230 gpppEntStat.curCmd = AT_CMD_NONE;
231 rat_id = RAT_NO_CARRIER;
232 reactivation = 1;
233 cmhSM_connection_down(EXTRACT_DTI_ID(p_pdp_context_node->internal_data.link_id)); /* 28592 */
234 break;
235
236 } /* end switch */
237
238 }
239 else
240 {
241 TRACE_ERROR( "ERROR: PDP context not found, in function cmhGPPP_Terminated" );
242 return 0;
243 }
244
245 rat_owner = (T_ACI_CMD_SRC)get_owner_over_cid( cid );
246
247 if ( reactivation EQ 0 )
248 {
249 /* Do we need a SMREG_PDP_DEACTIVATE_REQ? */
250 if ( nsapi_set )
251 {
252 psaSM_PDP_Deactivate ( nsapi_set, PS_REL_IND_NO );
253 }
254 /*
255 *-------------------------------------------------------------------
256 * check for command context
257 *-------------------------------------------------------------------
258 */
259 switch( gpppEntStat.curCmd )
260 {
261 case( AT_CMD_CGDATA ):
262 if ( rat_owner EQ gpppEntStat.entOwn )
263 {
264 gpppEntStat.curCmd = AT_CMD_NONE;
265 }
266 /* brz: to check */
267 switch(gpppShrdPrm.ppp_cause)
268 {
269 case PPP_TERM_OK_PEER:
270 case PPP_TERM_NO_RESPONSE:
271 case PPP_TERM_LOOP_BACK:
272 case PPP_TERM_LCP_NOT_CONVERGE:
273 case PPP_TERM_IPCP_NOT_CONVERGE:
274 case PPP_TERM_IPCP_NOT_STARTED:
275 cme_err = CME_ERR_GPRSBadModClass;
276 break;
277 /* The below cause values is commented as it is not defined in the
278 * Alborg SAP Document, and because of this it is giving compilation
279 * ERROR
280 */
281 /*case SMREG_RC_USE_AUTHED_FAILED:*/
282 case PPP_TERM_USE_AUTHED_FAILED:
283 cme_err = CME_ERR_GPRSPdpAuth;
284 break;
285 default:
286 cme_err = CME_ERR_Unknown;
287 }
288 break;
289 #if 0
290 /*
291 * These cases do never happen!
292 */
293 case( AT_CMD_CGACT ):
294 case( AT_CMD_CGANS ):
295 case( AT_CMD_A ):
296 case( AT_CMD_H ):
297 break;
298 #endif
299 default:
300 switch(gpppShrdPrm.ppp_cause)
301 {
302 case CAUSE_NWSM_SERVICE_NOT_SUPPORTED:
303 cme_err = CME_ERR_GPRSSerOptNsup;
304 break;
305 case CAUSE_NWSM_SERVICE_NOT_SUBSCRIBED:
306 cme_err = CME_ERR_GPRSSerOptNsub;
307 break;
308 case CAUSE_NWSM_SERVICE_TEMP_OUT_OF_ORDER:
309 cme_err = CME_ERR_GPRSSerOptOOO;
310 break;
311 case PPP_TERM_USE_AUTHED_FAILED:
312 cme_err = CME_ERR_GPRSPdpAuth;
313 break;
314 default:
315 cme_err = CME_ERR_Unknown;
316 }
317 }
318 if ( smEntStat.entOwn EQ rat_owner )
319 {
320 switch( smEntStat.curCmd )
321 {
322 case( AT_CMD_CGDATA ):
323 case( AT_CMD_CGACT ):
324 smEntStat.curCmd = AT_CMD_NONE;
325 break;
326 }
327 }
328 }
329
330 cmhSM_connection_down(EXTRACT_DTI_ID(p_pdp_context_node->internal_data.link_id));
331
332 if( rat_id NEQ RAT_MAX )
333 {
334 gaci_RAT_caller( rat_id, cid, cmdBuf, cme_err );
335
336 if( reactivation EQ 0 )
337 {
338 work_cids[0] = PDP_CONTEXT_CID_INVALID;
339 }
340
341 cmhSM_context_reactivation();
342 cmhSM_disconnect_cid(cid, GC_TYPE_DATA_LINK);
343 }
344
345 work_cids[0] = PDP_CONTEXT_CID_INVALID;
346 cid_pointer = 0;
347 if ( smEntStat.curCmd EQ AT_CMD_CGACT )
348 {
349 smEntStat.curCmd = AT_CMD_NONE;
350 }
351 return 0;
352 }
353
354 /*
355 +-------------------------------------------------------------------+
356 | PROJECT : GPRS (8441) MODULE : CMH_PPPR |
357 | STATE : finished ROUTINE : cmhGPPP_Activated |
358 +-------------------------------------------------------------------+
359
360 PURPOSE : activate the PDP context (only in server or transparent
361 mode) and if the context is already activated then answer PPP.
362 (PPP_ACTIVATE_IND is received).
363
364
365 */
366 GLOBAL SHORT cmhGPPP_Activated ( void )
367 {
368 U8 cid = work_cids[cid_pointer];
369 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
370
371 TRACE_FUNCTION ("cmhGPPP_Activated()");
372
373 p_pdp_context_node = pdp_context_find_node_from_cid( cid );
374 if( !p_pdp_context_node )
375 {
376 TRACE_ERROR("ERROR: PDP context not found, in function cmhGPPP_Activated");
377 return -1;
378 }
379
380 /*
381 *-------------------------------------------------------------------
382 * check for command context
383 *-------------------------------------------------------------------
384 */
385 switch( gpppEntStat.curCmd )
386 {
387 case( AT_CMD_CGANS ):
388 case( AT_CMD_CGDATA ):
389 /*
390 *---------------------------------------------------------------
391 * check entity context state
392 *---------------------------------------------------------------
393 */
394 switch ( get_state_working_cid() )
395 {
396 case PDP_CONTEXT_STATE_ESTABLISH_1:
397 {
398
399 /*
400 *---------------------------------------------------------------
401 * save parameter
402 *---------------------------------------------------------------
403 */
404
405 /* Issue OMAPS00047332 : SNDCP, SM and UPM are not supporting ppp_hc and msid anymore */
406
407 smEntStat.curCmd = gpppEntStat.curCmd;
408 smShrdPrm.owner = gpppShrdPrm.owner;
409 smEntStat.entOwn = (T_ACI_CMD_SRC)smShrdPrm.owner;
410
411 /*
412 *---------------------------------------------------------------
413 * store PCO information if it's provided PPP
414 *---------------------------------------------------------------
415 */
416
417 if( (gpppShrdPrm.pdp->sdu.l_buf >> 3) > 0 )
418 {
419 cmhSM_set_PCO( cid, PCO_USER,
420 &gpppShrdPrm.pdp->sdu.buf[gpppShrdPrm.pdp->sdu.o_buf >> 3],
421 (UBYTE) (gpppShrdPrm.pdp->sdu.l_buf >> 3));
422 }
423
424 /*
425 *---------------------------------------------------------------
426 * PPP has requested context activation: Activate the context.
427 *---------------------------------------------------------------
428 */
429 cmhSM_connect_context( cid, DTI_ENTITY_PPPS );
430
431 set_state_working_cid( PDP_CONTEXT_STATE_ESTABLISH_2 );
432 }
433 break;
434
435 case PDP_CONTEXT_STATE_ACTIVATED_ESTABLISH_1:
436 {
437 /*
438 *---------------------------------------------------------------
439 * save parameter
440 *---------------------------------------------------------------
441 */
442
443 /* Issue OMAPS00047332 : SNDCP, SM and UPM are not supporting ppp_hc and msid anymore
444 So do not send ppp_hc and msid params to ppp
445 */
446 smEntStat.curCmd = gpppEntStat.curCmd;
447 smShrdPrm.owner = gpppShrdPrm.owner;
448 smEntStat.entOwn = (T_ACI_CMD_SRC)smShrdPrm.owner;
449
450 /*
451 *---------------------------------------------------------------
452 * PPP has requested context activation, but the context is
453 * already activated: Answer PPP.
454 *---------------------------------------------------------------
455 */
456 psaGPPP_PDP_Activate( &p_pdp_context_node->internal_data.pdp_address_allocated,
457 p_pdp_context_node->internal_data.network_pco.pco,
458 (UBYTE) (p_pdp_context_node->internal_data.network_pco.len),
459 (UBYTE) CID_TO_NSAPI(cid));
460
461 set_state_working_cid( PDP_CONTEXT_STATE_ESTABLISH_3 );
462 }
463 break;
464 default:
465 /* The PPP_PDP_ACTIVATE_IND might have crossed with a PPP_TERMINATE_REQ.
466 Ignore the event by returning */
467 return 0;
468 }
469
470 }
471
472 return 0;
473 }
474
475 /*
476 +-------------------------------------------------------------------+
477 | PROJECT : GPRS (8441) MODULE : CMH_PPPR |
478 | STATE : finished ROUTINE : cmhGPPP_Modified |
479 +-------------------------------------------------------------------+
480
481 PURPOSE : new negotiate header compression confirmed (only in server mode)
482
483 */
484 GLOBAL SHORT cmhGPPP_Modified ( void )
485 {
486 TRACE_FUNCTION ("cmhGPPP_Modified()");
487
488 /*
489 *---------------------------------------------------------------
490 * nothing to do
491 *---------------------------------------------------------------
492 */
493
494 return 0;
495 }
496
497 #endif /* GPRS */
498 /*==== EOF ========================================================*/
499