FreeCalypso > hg > leo2moko-debug
comparison g23m/condat/ms/src/aci/cmh_gpppr.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : | |
4 | Modul : | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : This module 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 | |
68 /*==== FUNCTIONS ==================================================*/ | |
69 | |
70 /* | |
71 +-------------------------------------------------------------------+ | |
72 | PROJECT : GPRS (8441) MODULE : CMH_PPPR | | |
73 | STATE : finnished ROUTINE : cmhGPPP_Established | | |
74 +-------------------------------------------------------------------+ | |
75 | |
76 PURPOSE : establish a PPP link was successful | |
77 | |
78 */ | |
79 GLOBAL SHORT cmhGPPP_Established ( void ) | |
80 { | |
81 | |
82 TRACE_FUNCTION ("cmhGPPP_Established()"); | |
83 | |
84 switch( gpppEntStat.curCmd ) | |
85 { | |
86 case( AT_CMD_CGDATA ): | |
87 /* no action, because the PDP context will be terminated */ | |
88 if ( CS_ESTABLISH_3 NEQ get_state_working_cid() ) | |
89 return 0; | |
90 | |
91 if ( gpppShrdPrm.ppp_hc NEQ gpppShrdPrm.est.ppp_hc || | |
92 gpppShrdPrm.msid NEQ gpppShrdPrm.est.msid ) | |
93 { | |
94 /* | |
95 * the PC won' t header compression now | |
96 */ | |
97 | |
98 /* brz: to check */ | |
99 | |
100 } | |
101 /* else*/ | |
102 { | |
103 set_state_working_cid( CS_DATA_LINK ); | |
104 /* | |
105 * do we need one more context activation | |
106 */ | |
107 if ( FALSE EQ cmhSM_next_work_cid( AT_CMD_CGDATA ) ) | |
108 { | |
109 R_AT( RAT_CGDATA, pdp_context[work_cids[cid_pointer] - 1].owner ) | |
110 (pdp_context[work_cids[cid_pointer] - 1].link_id_sn); | |
111 } | |
112 } | |
113 cmhSM_next_call_table_entry(); | |
114 break; | |
115 } | |
116 return 0; | |
117 } | |
118 | |
119 | |
120 /* | |
121 +-------------------------------------------------------------------+ | |
122 | PROJECT : GPRS (8441) MODULE : CMH_PPPR | | |
123 | STATE : code ROUTINE : cmhGPPP_Terminated | | |
124 +-------------------------------------------------------------------+ | |
125 | |
126 PURPOSE : PPP connection is closed | |
127 | |
128 */ | |
129 GLOBAL SHORT cmhGPPP_Terminated ( void ) | |
130 { | |
131 T_ACI_CMD_SRC rat_owner; | |
132 UBYTE cmdBuf = gpppEntStat.curCmd,/* buffers current command */ | |
133 cme_err = CME_ERR_Unknown; /* error number */ | |
134 T_DTI_CONN_LINK_ID dti_id_sn; | |
135 SHORT cid, /* is the PDP context activated */ | |
136 reactivation = 0, | |
137 rat_id = RAT_MAX; | |
138 USHORT nsapi_set = 0; | |
139 #ifdef FF_TCP_IP | |
140 T_DTI_ENTITY_ID peer; | |
141 #endif | |
142 UBYTE srcId = srcId_cb; | |
143 | |
144 TRACE_FUNCTION ("cmhGPPP_Terminated()"); | |
145 | |
146 | |
147 cid = gaci_get_cid_over_link_id(gaci_get_link_id_over_peer(DTI_ENTITY_PPPS)); | |
148 | |
149 dti_id_sn = cmhSM_get_link_id_SNDCP_peer( cid, SNDCP_PEER_NORMAL ); | |
150 | |
151 #ifdef FF_TCP_IP | |
152 peer = dti_cntrl_get_peer(DTI_ENTITY_PPPS, 0, 0); | |
153 if ( peer EQ DTI_ENTITY_AAA ) | |
154 { | |
155 psaAAA_disconnect_ind (pdp_context[cid - 1].link_id_uart); | |
156 } | |
157 #endif | |
158 | |
159 switch ( get_state_over_cid( cid ) ) | |
160 { | |
161 case CS_UNDEFINED: | |
162 case CS_DEFINED: | |
163 case CS_WAITS_FOR_ACTIVATING: | |
164 case CS_ACTIVATING: | |
165 case CS_ACTIVATED: | |
166 case CS_DEACTIVATE_NORMAL: | |
167 break; | |
168 case CS_ESTABLISH_2: | |
169 case CS_ESTABLISH_3: | |
170 set_state_over_cid( cid, CS_ABORT_ESTABLISH ); | |
171 nsapi_set = cmhSM_Give_nsapi_set( cid ); | |
172 dti_cntrl_entity_disconnected( dti_id_sn , DTI_ENTITY_PPPS ); | |
173 dti_cntrl_set_dti_id_to_reconnect(EXTRACT_DTI_ID(dti_id_sn)); | |
174 dti_cntrl_entity_disconnected( pdp_context[cid - 1].link_id_uart, DTI_ENTITY_PPPS ); | |
175 break; | |
176 case CS_ESTABLISH_1: | |
177 cmhSM_contextDeactivated(); | |
178 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_SNDCP ); | |
179 /*lint -fallthrough*/ | |
180 case CS_ABORT_ESTABLISH: | |
181 case CS_BREAKDOWN_LINK_ERROR: | |
182 set_state_over_cid( cid, CS_DEFINED ); | |
183 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_PPPS ); | |
184 dti_cntrl_set_dti_id_to_reconnect(EXTRACT_DTI_ID(dti_id_sn)); | |
185 dti_cntrl_entity_disconnected( pdp_context[cid - 1].link_id_uart, DTI_ENTITY_PPPS ); | |
186 if(ati_user_output_cfg[srcId].CMEE_stat EQ CMEE_MOD_Disable OR isContextDeactivationRequestedByCGACT(cid)) | |
187 rat_id = RAT_NO_CARRIER; | |
188 else | |
189 rat_id = RAT_CME; | |
190 break; | |
191 case CS_BREAKDOWN_LINK_NORMAL: | |
192 set_state_over_cid( cid, CS_DEFINED ); | |
193 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_PPPS ); | |
194 dti_cntrl_set_dti_id_to_reconnect(EXTRACT_DTI_ID(dti_id_sn)); | |
195 dti_cntrl_entity_disconnected( pdp_context[cid - 1].link_id_uart, DTI_ENTITY_PPPS ); | |
196 rat_id = RAT_NO_CARRIER; | |
197 break; | |
198 case CS_DATA_LINK: | |
199 set_state_over_cid( cid, CS_BREAKDOWN_LINK_NORMAL ); | |
200 nsapi_set = cmhSM_Give_nsapi_set( cid ); | |
201 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_PPPS ); | |
202 dti_cntrl_set_dti_id_to_reconnect(EXTRACT_DTI_ID(dti_id_sn)); | |
203 dti_cntrl_entity_disconnected( pdp_context[cid - 1].link_id_uart, DTI_ENTITY_PPPS ); | |
204 break; | |
205 case CS_CONTEXT_REACTIVATION_1: | |
206 set_state_over_cid(cid, CS_CONTEXT_REACTIVATION_2); | |
207 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_PPPS ); | |
208 dti_cntrl_set_dti_id_to_reconnect(EXTRACT_DTI_ID(dti_id_sn)); | |
209 dti_cntrl_entity_disconnected( pdp_context[cid - 1].link_id_uart, DTI_ENTITY_PPPS ); | |
210 gpppEntStat.curCmd = AT_CMD_NONE; | |
211 cmhSM_connection_down((UBYTE)EXTRACT_DTI_ID(dti_id_sn)); | |
212 return 0; | |
213 case CS_CONTEXT_REACTIVATION_2: | |
214 set_state_over_cid(cid, CS_DEFINED); | |
215 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_PPPS ); | |
216 dti_cntrl_set_dti_id_to_reconnect(EXTRACT_DTI_ID(dti_id_sn)); | |
217 dti_cntrl_entity_disconnected( pdp_context[cid - 1].link_id_uart, DTI_ENTITY_PPPS ); | |
218 gpppEntStat.curCmd = AT_CMD_NONE; | |
219 rat_id = RAT_NO_CARRIER; | |
220 reactivation = 1; | |
221 break; | |
222 } | |
223 | |
224 rat_owner = get_owner_over_cid(cid); | |
225 | |
226 if ( reactivation EQ 0 ) | |
227 { | |
228 /* Do we need a SMREG_PDP_DEACTIVATE_REQ? */ | |
229 if ( nsapi_set ) | |
230 { | |
231 psaSM_PDP_Deactivate ( nsapi_set, SMREG_NONLOCAL); | |
232 } | |
233 /* | |
234 *------------------------------------------------------------------- | |
235 * check for command context | |
236 *------------------------------------------------------------------- | |
237 */ | |
238 switch( gpppEntStat.curCmd ) | |
239 { | |
240 case( AT_CMD_CGDATA ): | |
241 if ( rat_owner EQ gpppEntStat.entOwn ) | |
242 { | |
243 gpppEntStat.curCmd = AT_CMD_NONE; | |
244 } | |
245 /* brz: to check */ | |
246 switch(gpppShrdPrm.ppp_cause) | |
247 { | |
248 case PPP_TERM_OK_PEER: | |
249 case PPP_TERM_NO_RESPONSE: | |
250 case PPP_TERM_LOOP_BACK: | |
251 case PPP_TERM_LCP_NOT_CONVERGE: | |
252 case PPP_TERM_IPCP_NOT_CONVERGE: | |
253 case PPP_TERM_IPCP_NOT_STARTED: | |
254 cme_err = CME_ERR_GPRSBadModClass; | |
255 break; | |
256 case SMREG_RC_USE_AUTHED_FAILED: | |
257 case PPP_TERM_USE_AUTHED_FAILED: | |
258 cme_err = CME_ERR_GPRSPdpAuth; | |
259 break; | |
260 default: | |
261 cme_err = CME_ERR_Unknown; | |
262 } | |
263 break; | |
264 #if 0 | |
265 /* | |
266 * These cases do never happen! | |
267 */ | |
268 case( AT_CMD_CGACT ): | |
269 case( AT_CMD_CGANS ): | |
270 case( AT_CMD_A ): | |
271 case( AT_CMD_H ): | |
272 break; | |
273 #endif | |
274 default: | |
275 switch(gpppShrdPrm.ppp_cause) | |
276 { | |
277 case SMREG_RC_SERV_OPT_NOT_SUPP: | |
278 cme_err = CME_ERR_GPRSSerOptNsup; | |
279 break; | |
280 case SMREG_RC_SERV_OPT_NOT_SUBS: | |
281 cme_err = CME_ERR_GPRSSerOptNsub; | |
282 break; | |
283 case SMREG_RC_SERV_OPT_TEMP_OOO: | |
284 cme_err = CME_ERR_GPRSSerOptOOO; | |
285 break; | |
286 case PPP_TERM_USE_AUTHED_FAILED: | |
287 case SMREG_RC_USE_AUTHED_FAILED: | |
288 cme_err = CME_ERR_GPRSPdpAuth; | |
289 break; | |
290 default: | |
291 cme_err = CME_ERR_Unknown; | |
292 } | |
293 } | |
294 if ( smEntStat.entOwn EQ rat_owner ) | |
295 { | |
296 switch( smEntStat.curCmd ) | |
297 { | |
298 case( AT_CMD_CGDATA ): | |
299 case( AT_CMD_CGACT ): | |
300 smEntStat.curCmd = AT_CMD_NONE; | |
301 break; | |
302 } | |
303 } | |
304 } | |
305 | |
306 cmhSM_connection_down((UBYTE)EXTRACT_DTI_ID(dti_id_sn)); | |
307 | |
308 if ( rat_id NEQ RAT_MAX ) | |
309 { | |
310 gaci_RAT_caller ( rat_id, cid, cmdBuf, cme_err ); | |
311 | |
312 cid_pointer = 0; | |
313 *work_cids = 0; | |
314 | |
315 cmhSM_context_reactivation(); | |
316 cmhSM_disconnect_cid(cid, GC_TYPE_DATA_LINK); | |
317 } | |
318 | |
319 return 0; | |
320 } | |
321 | |
322 /* | |
323 +-------------------------------------------------------------------+ | |
324 | PROJECT : GPRS (8441) MODULE : CMH_PPPR | | |
325 | STATE : finished ROUTINE : cmhGPPP_Activated | | |
326 +-------------------------------------------------------------------+ | |
327 | |
328 PURPOSE : activate the PDP context (only in server mode) | |
329 | |
330 */ | |
331 GLOBAL SHORT cmhGPPP_Activated ( void ) | |
332 { | |
333 SHORT cid = work_cids[0]; | |
334 | |
335 TRACE_FUNCTION ("cmhGPPP_Activated()"); | |
336 | |
337 /* | |
338 *------------------------------------------------------------------- | |
339 * check for command context | |
340 *------------------------------------------------------------------- | |
341 */ | |
342 switch( gpppEntStat.curCmd ) | |
343 { | |
344 case( AT_CMD_CGANS ): | |
345 case( AT_CMD_CGDATA ): | |
346 /* | |
347 *--------------------------------------------------------------- | |
348 * check entity status and context state | |
349 *--------------------------------------------------------------- | |
350 */ | |
351 if ( CS_ESTABLISH_1 NEQ get_state_working_cid() ) | |
352 return 0; | |
353 | |
354 /* | |
355 *--------------------------------------------------------------- | |
356 * save parameter | |
357 *--------------------------------------------------------------- | |
358 */ | |
359 gpppShrdPrm.ppp_hc = gpppShrdPrm.pdp->ppp_hc; | |
360 gpppShrdPrm.msid = gpppShrdPrm.pdp->msid; | |
361 | |
362 cmhSM_set_PCO( cid, PCO_USER, | |
363 &gpppShrdPrm.pdp->sdu.buf[gpppShrdPrm.pdp->sdu.o_buf >> 3], | |
364 (UBYTE) (gpppShrdPrm.pdp->sdu.l_buf >> 3)); | |
365 | |
366 /* | |
367 *--------------------------------------------------------------- | |
368 * process parameter | |
369 *--------------------------------------------------------------- | |
370 */ | |
371 smEntStat.curCmd = gpppEntStat.curCmd; | |
372 smShrdPrm.owner = gpppShrdPrm.owner; | |
373 smEntStat.entOwn = smShrdPrm.owner; | |
374 | |
375 cmhSM_connect_context ( cid, DTI_ENTITY_PPPS, | |
376 gpppShrdPrm.ppp_hc, gpppShrdPrm.msid); | |
377 | |
378 set_state_working_cid( CS_ESTABLISH_2 ); | |
379 break; | |
380 default: | |
381 return -1; | |
382 } | |
383 | |
384 return 0; | |
385 } | |
386 | |
387 /* | |
388 +-------------------------------------------------------------------+ | |
389 | PROJECT : GPRS (8441) MODULE : CMH_PPPR | | |
390 | STATE : finished ROUTINE : cmhGPPP_Modified | | |
391 +-------------------------------------------------------------------+ | |
392 | |
393 PURPOSE : new negotiate header compression confirmed (only in server mode) | |
394 | |
395 */ | |
396 GLOBAL SHORT cmhGPPP_Modified ( void ) | |
397 { | |
398 TRACE_FUNCTION ("cmhGPPP_Modified()"); | |
399 | |
400 /* | |
401 *--------------------------------------------------------------- | |
402 * nothing to do | |
403 *--------------------------------------------------------------- | |
404 */ | |
405 | |
406 return 0; | |
407 } | |
408 | |
409 #endif /* GPRS */ | |
410 /*==== EOF ========================================================*/ | |
411 |