FreeCalypso > hg > tcs211-fcmodem
comparison g23m/condat/ms/src/aci/cmh_smr.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 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 #include "aci.h" | |
37 | |
38 #include "dti_conn_mng.h" | |
39 #include "dti_cntrl_mng.h" | |
40 | |
41 #include "gaci.h" | |
42 #include "gaci_cmh.h" | |
43 #include "psa.h" | |
44 #include "psa_sm.h" | |
45 #include "psa_gppp.h" | |
46 | |
47 #include "cmh.h" | |
48 #include "cmh_sm.h" | |
49 #include "cmh_gppp.h" | |
50 #include "gaci_srcc.h" | |
51 #include "psa_uart.h" | |
52 | |
53 #if defined (CO_UDP_IP) || defined (FF_GPF_TCPIP) | |
54 #include "wap_aci.h" | |
55 #include "psa_tcpip.h" | |
56 | |
57 #include "psa_cc.h" | |
58 #include "cmh_cc.h" | |
59 #include "psa_sat.h" | |
60 #include "cmh_sat.h" | |
61 | |
62 #include "dcm_f.h" | |
63 #endif /* (CO_UDP_IP) || defined (FF_GPF_TCPIP) */ | |
64 | |
65 /*==== CONSTANTS ==================================================*/ | |
66 | |
67 | |
68 /*==== TYPES ======================================================*/ | |
69 | |
70 | |
71 /*==== EXPORT =====================================================*/ | |
72 | |
73 /*==== VARIABLES ==================================================*/ | |
74 | |
75 /*==== FUNCTIONS ==================================================*/ | |
76 | |
77 | |
78 static void dumpContextInfo(SHORT cid) | |
79 { | |
80 TRACE_EVENT_P2("ERROR in context state: cid %d, state %d", | |
81 cid, pdp_context[cid-1].state); | |
82 TRACE_EVENT_P3("dump: nsapi %d, srcID %d, connected entity %d", | |
83 pdp_context[cid-1].nsapi, pdp_context[cid-1].owner, | |
84 pdp_context[cid-1].entity_id); | |
85 if(smEntStat.curCmd NEQ AT_CMD_NONE) | |
86 { | |
87 TRACE_EVENT_P1("dump running command: %d", smEntStat.curCmd); | |
88 } | |
89 TRACE_EVENT_P3("dump link_ids: new %d sn %d uart %d", | |
90 pdp_context[cid-1].link_id_new, pdp_context[cid-1].link_id_sn, | |
91 pdp_context[cid-1].link_id_uart); | |
92 } | |
93 | |
94 #if defined (CO_UDP_IP) || defined (FF_GPF_TCPIP) | |
95 static BOOL is_ip_dti_id(T_DTI_ENTITY_ID dti_id) | |
96 { | |
97 if(is_gpf_tcpip_call()) { | |
98 GPF_TCPIP_STATEMENT(return dti_id EQ DTI_ENTITY_TCPIP); | |
99 } | |
100 else { | |
101 return dti_id EQ DTI_ENTITY_IP; | |
102 } | |
103 } | |
104 #endif | |
105 | |
106 static void get_dns_address(char* dns1, char *dns2, UBYTE *pco, UBYTE len) | |
107 { | |
108 ULONG tmp_dns1, tmp_dns2, gateway; | |
109 utl_analyze_pco(pco,len, &tmp_dns1, &tmp_dns2, &gateway); | |
110 | |
111 sprintf(dns1, "%03u.%03u.%03u.%03u", (tmp_dns1 & 0xff000000) >> 24, | |
112 (tmp_dns1 & 0x00ff0000) >> 16, | |
113 (tmp_dns1 & 0x0000ff00) >> 8 , | |
114 (tmp_dns1 & 0x000000ff) ); | |
115 sprintf(dns2, "%03u.%03u.%03u.%03u", (tmp_dns2 & 0xff000000) >> 24, | |
116 (tmp_dns2 & 0x00ff0000) >> 16, | |
117 (tmp_dns2 & 0x0000ff00) >> 8 , | |
118 (tmp_dns2 & 0x000000ff) ); | |
119 } | |
120 | |
121 /* | |
122 +-------------------------------------------------------------------+ | |
123 | PROJECT : GPRS (8441) MODULE : CMH_SMR | | |
124 | STATE : finished ROUTINE : cmhSM_Activated | | |
125 +-------------------------------------------------------------------+ | |
126 | |
127 PURPOSE : confirms a successful context activation | |
128 | |
129 */ | |
130 GLOBAL SHORT cmhSM_Activated ( T_SMREG_PDP_ACTIVATE_CNF *pdp_cnf ) | |
131 { | |
132 T_CGEREP_EVENT_REP_PARAM event; | |
133 char dns1[16], dns2[16]; | |
134 SHORT _cid = work_cids[cid_pointer] - 1; | |
135 T_ACI_AT_CMD curCmd = smEntStat.curCmd; | |
136 UBYTE ip[4]; | |
137 int i = 0; | |
138 | |
139 TRACE_FUNCTION ("cmhSM_Activated()"); | |
140 | |
141 /* | |
142 *------------------------------------------------------------------- | |
143 * check for command context | |
144 *------------------------------------------------------------------- | |
145 */ | |
146 switch( get_state_working_cid() ) | |
147 { | |
148 case( CS_ACTIVATING ): | |
149 | |
150 R_AT( RAT_CGACT, smEntStat.entOwn )(pdp_context[_cid].link_id_new); | |
151 | |
152 set_state_working_cid( CS_ACTIVATED ); | |
153 | |
154 dti_cntrl_entity_connected( pdp_context[_cid].link_id_new, DTI_ENTITY_SNDCP, DTI_OK ); | |
155 pdp_context[_cid].link_id_sn = pdp_context[_cid].link_id_new; | |
156 pdp_context[_cid].link_id_new = DTI_LINK_ID_NOTPRESENT; | |
157 | |
158 sprintf(pdp_context[_cid].allocated_pdp_addr, "%03hd.%03hd.%03hd.%03hd", | |
159 pdp_cnf->pdp_address.buff[0], | |
160 pdp_cnf->pdp_address.buff[1], | |
161 pdp_cnf->pdp_address.buff[2], | |
162 pdp_cnf->pdp_address.buff[3] ); | |
163 | |
164 cmhSM_set_PCO((SHORT)(_cid + 1), PCO_NETWORK, | |
165 &pdp_cnf->sdu.buf[pdp_cnf->sdu.o_buf >> 3], | |
166 (UBYTE) (pdp_cnf->sdu.l_buf >> 3)); | |
167 | |
168 get_dns_address(dns1, dns2, | |
169 (UBYTE*)pdp_context[_cid].network_pco.pco, | |
170 pdp_context[_cid].network_pco.len); | |
171 | |
172 TRACE_EVENT_P3("PDP Address: %s, DNS1: %s, DNS2: %s", | |
173 pdp_context[_cid].allocated_pdp_addr,dns1,dns2); | |
174 | |
175 #if defined (CO_UDP_IP) || defined (FF_GPF_TCPIP) | |
176 /* if WAP/TCPIP over GPRS is in progress, request WAP configuration */ | |
177 if ( is_ip_dti_id(pdp_context[_cid].entity_id) ) | |
178 { | |
179 psaTCPIP_Configure(NULL, pdp_context[_cid].allocated_pdp_addr, | |
180 NULL, (UBYTE*)dns1, (UBYTE*)dns2, 1500, | |
181 cmhSM_IP_activate_cb ); | |
182 } | |
183 #endif /* (CO_UDP_IP) || defined (FF_GPF_TCPIP) */ | |
184 | |
185 /* | |
186 * do we need one more context activation | |
187 */ | |
188 if ( FALSE EQ cmhSM_next_work_cid( curCmd ) ) | |
189 { | |
190 if( AT_CMD_CGACT EQ curCmd) | |
191 { | |
192 gaci_RAT_caller ( RAT_OK, (SHORT) (_cid + 1), (UBYTE) curCmd, 0 ); | |
193 | |
194 /* log result */ | |
195 cmh_logRslt ( pdp_context[_cid].owner, RAT_OK, curCmd, -1, -1, -1 ); | |
196 } | |
197 } | |
198 break; | |
199 | |
200 case( CS_ESTABLISH_2 ): | |
201 /* | |
202 *--------------------------------------------------------------- | |
203 * inform PPP | |
204 *--------------------------------------------------------------- | |
205 */ | |
206 cmhSM_set_PCO((SHORT)(_cid + 1), PCO_NETWORK, | |
207 &pdp_cnf->sdu.buf[pdp_cnf->sdu.o_buf >> 3], | |
208 (UBYTE) (pdp_cnf->sdu.l_buf >> 3)); | |
209 | |
210 sprintf(pdp_context[_cid].allocated_pdp_addr, "%03hd.%03hd.%03hd.%03hd", | |
211 pdp_cnf->pdp_address.buff[0], | |
212 pdp_cnf->pdp_address.buff[1], | |
213 pdp_cnf->pdp_address.buff[2], | |
214 pdp_cnf->pdp_address.buff[3] ); | |
215 | |
216 cmhSM_pdp_address_to_ip(&pdp_context[_cid].allocated_pdp_addr, ip); | |
217 | |
218 psaGPPP_PDP_Activate(pdp_cnf->ppp_hc, pdp_cnf->msid, ip, | |
219 &pdp_cnf->sdu.buf[pdp_cnf->sdu.o_buf >> 3], | |
220 (UBYTE) (pdp_cnf->sdu.l_buf >> 3)); | |
221 | |
222 set_state_working_cid( CS_ESTABLISH_3 ); | |
223 | |
224 dti_cntrl_entity_connected( pdp_context[_cid].link_id_new, DTI_ENTITY_SNDCP, DTI_OK ); | |
225 | |
226 pdp_context[_cid].link_id_sn = pdp_context[_cid].link_id_new; | |
227 pdp_context[_cid].link_id_new = DTI_LINK_ID_NOTPRESENT; | |
228 | |
229 break; | |
230 | |
231 default: | |
232 return -1; | |
233 } | |
234 | |
235 /* | |
236 * %CGEV - GPRS event reporting | |
237 */ | |
238 strcpy(event.act.pdp_type, pdp_context[_cid].con.pdp_type); | |
239 strcpy(event.act.pdp_addr, pdp_context[_cid].allocated_pdp_addr); | |
240 event.act.cid = _cid + 1; | |
241 | |
242 if (smShrdPrm.direc == DIREC_MO) | |
243 { | |
244 for( i = 0; i < CMD_SRC_MAX; i++ ) | |
245 { | |
246 R_AT( RAT_P_CGEV, i ) ( CGEREP_EVENT_ME_ACT, &event ); | |
247 } | |
248 } | |
249 else | |
250 { | |
251 for( i = 0; i < CMD_SRC_MAX; i++ ) | |
252 { | |
253 R_AT( RAT_P_CGEV, i ) ( CGEREP_EVENT_NW_ACT, &event ); | |
254 } | |
255 } | |
256 | |
257 return 0; | |
258 } | |
259 | |
260 /* | |
261 +-------------------------------------------------------------------+ | |
262 | PROJECT : GPRS (8441) MODULE : CMH_SMR | | |
263 | STATE : finished ROUTINE : | | |
264 +-------------------------------------------------------------------+ | |
265 | |
266 PURPOSE : | |
267 | |
268 */ | |
269 | |
270 LOCAL void cp_pdp_rej_prim(T_SMREG_PDP_ACTIVATE_REJ * pdp_activate_rej, | |
271 T_PPP_PDP_ACTIVATE_REJ *activate_result) | |
272 { | |
273 | |
274 activate_result->ppp_cause = pdp_activate_rej->smreg_cause; | |
275 | |
276 } | |
277 | |
278 /* | |
279 +-------------------------------------------------------------------+ | |
280 | PROJECT : GPRS (8441) MODULE : CMH_SMR | | |
281 | STATE : finished ROUTINE : cmhSM_NoActivate | | |
282 +-------------------------------------------------------------------+ | |
283 | |
284 PURPOSE : indicates a context activation failed | |
285 | |
286 */ | |
287 GLOBAL SHORT cmhSM_NoActivate ( void ) | |
288 { | |
289 T_CGEREP_EVENT_REP_PARAM event; | |
290 T_CONTEXT_STATE state; | |
291 T_DTI_CONN_LINK_ID link_id; | |
292 int i = 0; | |
293 | |
294 TRACE_FUNCTION ("cmhSM_NoActivate()"); | |
295 /* | |
296 *------------------------------------------------------------------- | |
297 * Set error cause for SIM owner | |
298 *------------------------------------------------------------------- | |
299 */ | |
300 #ifdef FF_SAT_E | |
301 gaci_SAT_err(smShrdPrm.pdp_rej->smreg_cause); | |
302 #endif /* FF_SAT_E */ | |
303 /* | |
304 *------------------------------------------------------------------- | |
305 * check for command context | |
306 *------------------------------------------------------------------- | |
307 */ | |
308 switch( state = get_state_working_cid() ) | |
309 { | |
310 case CS_UNDEFINED: | |
311 case CS_DEFINED: | |
312 case CS_ESTABLISH_1: | |
313 case CS_ESTABLISH_3: | |
314 case CS_ACTIVATED: | |
315 case CS_WAITS_FOR_ACTIVATING: | |
316 case CS_DATA_LINK: | |
317 case CS_DEACTIVATE_NORMAL: | |
318 case CS_CONTEXT_REACTIVATION_1: | |
319 case CS_CONTEXT_REACTIVATION_2: | |
320 case CS_BREAKDOWN_LINK_ERROR: | |
321 case CS_BREAKDOWN_LINK_NORMAL: | |
322 dumpContextInfo(work_cids[cid_pointer]); | |
323 return 0; | |
324 case CS_ACTIVATING: | |
325 link_id = cmhSM_get_link_id_SNDCP_peer(work_cids[cid_pointer], SNDCP_PEER_NORMAL); | |
326 | |
327 switch(pdp_context[work_cids[cid_pointer] - 1].entity_id) | |
328 { | |
329 case DTI_ENTITY_PKTIO: | |
330 case DTI_ENTITY_PSI: | |
331 set_state_working_cid( CS_DEACTIVATE_NORMAL); | |
332 dti_cntrl_close_dpath_from_dti_id (EXTRACT_DTI_ID(link_id)); | |
333 /* gaci_RAT_caller(RAT_NO_CARRIER, work_cids[cid_pointer], AT_CMD_CGDATA, 0); */ | |
334 break; | |
335 #if defined (CO_UDP_IP) OR defined (FF_GPF_TCPIP) | |
336 case DTI_ENTITY_IP: | |
337 GPF_TCPIP_STATEMENT(case DTI_ENTITY_TCPIP:) | |
338 set_state_working_cid( CS_DEFINED); | |
339 dti_cntrl_close_dpath_from_dti_id (EXTRACT_DTI_ID(link_id)); | |
340 /* tell WAP ACI that contextactivation was rejected */ | |
341 psaTCPIP_Deactivate(cmhSM_IP_activate_cb); | |
342 dti_cntrl_entity_disconnected( link_id, DTI_ENTITY_SNDCP ); | |
343 break; | |
344 #endif /* WAP OR FF_SAT_E OR FF_GPF_TCPIP */ | |
345 default: | |
346 /* in this case is SMREG_PDP_ACTIVATE_REJ the same as SMREG_DEACTIVATE_CNF */ | |
347 | |
348 /* set parameter for SMREG_DEACTIVATE_CNF */ | |
349 smShrdPrm.nsapi_set = 1 << smShrdPrm.pdp_rej->smreg_nsapi; | |
350 cmhSM_Deactivated(); /* SMREG_DEACTIVATE_CNF */ | |
351 | |
352 /* the last expected primitive from SM */ | |
353 smEntStat.curCmd = AT_CMD_NONE; | |
354 return 0; | |
355 } | |
356 | |
357 /* | |
358 * GPRS event reporting | |
359 */ | |
360 strcpy(event.act.pdp_type, pdp_context[work_cids[cid_pointer] - 1].con.pdp_type); | |
361 strcpy(event.act.pdp_addr, pdp_context[work_cids[cid_pointer] - 1].allocated_pdp_addr); | |
362 event.act.cid = work_cids[cid_pointer]; | |
363 for( i = 0; i < CMD_SRC_MAX; i++ ) | |
364 { | |
365 R_AT( RAT_CGEREP, i ) ( CGEREP_EVENT_ME_DEACT, &event ); | |
366 R_AT( RAT_P_CGEV, i ) ( CGEREP_EVENT_ME_DEACT, &event ); | |
367 } | |
368 | |
369 cmhSM_GiveNSapiFree(work_cids[cid_pointer]); | |
370 cmhSM_contextDeactivated(); | |
371 break; | |
372 case CS_ESTABLISH_2: | |
373 case CS_ABORT_ESTABLISH: | |
374 /* in this case is SMREG_PDP_ACTIVATE_REJ the same as SMREG_DEACTIVATE_CNF */ | |
375 | |
376 /* set parameter for SMREG_DEACTIVATE_CNF */ | |
377 smShrdPrm.nsapi_set = 1 << smShrdPrm.pdp_rej->smreg_nsapi; | |
378 | |
379 cmhSM_Deactivated(); /* SMREG_DEACTIVATE_CNF */ | |
380 | |
381 /* the last expected primitive from SM */ | |
382 smEntStat.curCmd = AT_CMD_NONE; | |
383 | |
384 if ( state NEQ CS_ESTABLISH_2) | |
385 { | |
386 return 0; | |
387 } | |
388 | |
389 /* | |
390 *--------------------------------------------------------------- | |
391 * inform PPP | |
392 *--------------------------------------------------------------- | |
393 */ | |
394 { | |
395 PALLOC(act_rej_temp,PPP_PDP_ACTIVATE_REJ); /* ppass*/ | |
396 cp_pdp_rej_prim(smShrdPrm.pdp_rej,act_rej_temp); | |
397 gpppShrdPrm.setPrm[gpppEntStat.entOwn].pdp_rej = act_rej_temp; | |
398 } | |
399 | |
400 if( psaGPPP_PDP_Reject() < 0 ) | |
401 { | |
402 TRACE_EVENT( "FATAL RETURN psaPPP_PDP_Reject in +CGDATA" ); | |
403 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal ); | |
404 return -1 ; | |
405 } | |
406 | |
407 set_state_working_cid( CS_ABORT_ESTABLISH ); | |
408 break; | |
409 default: | |
410 return -1; | |
411 } | |
412 | |
413 return 0; | |
414 } | |
415 | |
416 /* | |
417 +-------------------------------------------------------------------+ | |
418 | PROJECT : GPRS (8441) MODULE : CMH_SMR | | |
419 | STATE : finished ROUTINE : cmhSM_NetActivate | | |
420 +-------------------------------------------------------------------+ | |
421 | |
422 PURPOSE : indicates a network asked for a PDP context activation | |
423 | |
424 */ | |
425 GLOBAL void cmhSM_NetActivate ( void ) | |
426 { | |
427 T_CGEREP_EVENT_REP_PARAM event; | |
428 SHORT i = 0, /* holds index counter */ | |
429 context_reactivation = 0, cid; | |
430 | |
431 TRACE_FUNCTION ("cmhSM_NetActivate()"); | |
432 | |
433 /* | |
434 * in first only one requested context activation is provided | |
435 * and the request will be rejected if an other context will be | |
436 * activated | |
437 */ | |
438 | |
439 /* | |
440 * it's no check to CC neccesary, because this is no class A mobile | |
441 */ | |
442 | |
443 if ( TRUE EQ cmhSM_is_smreg_ti_used( smShrdPrm.act_ind.smreg_ti, &cid ) ) | |
444 context_reactivation = 1; | |
445 | |
446 /* | |
447 * no PDP context is during the setup | |
448 */ | |
449 if ( work_cids[cid_pointer] EQ INVALID_CID && | |
450 gprs_ct_index < MAX_GPRS_CALL_TABLE_ENTRIES && | |
451 ( TRUE EQ srcc_reserve_sources( SRCC_PPPS_SNDCP_LINK, 1 ) || | |
452 context_reactivation EQ 1) ) | |
453 { | |
454 /* | |
455 *------------------------------------------------------------------- | |
456 * ring for call, if no call is in use | |
457 *------------------------------------------------------------------- | |
458 */ | |
459 | |
460 #ifdef AT_INTERPRETER | |
461 /* V.24 Ring Indicator Line */ | |
462 /* io_setRngInd ( IO_RS_ON, CRING_TYP_NotPresent, CRING_TYP_NotPresent dummy parameters here, need real ones when used); */ | |
463 #endif | |
464 | |
465 /* fill gprs call table */ | |
466 memcpy(&gprs_call_table[gprs_ct_index].sm_ind, &smShrdPrm.act_ind, sizeof(T_SMREG_PDP_ACTIVATE_IND)); | |
467 | |
468 /* no context reactivation */ | |
469 if ( context_reactivation NEQ 1 ) | |
470 { | |
471 gprs_call_table[gprs_ct_index].reactivation = GCTT_NORMAL; | |
472 *gprs_call_table[gprs_ct_index].L2P = 0; | |
473 gprs_call_table[gprs_ct_index].cid = INVALID_CID; | |
474 gprs_ct_index++; | |
475 | |
476 for( i = 0 ; i < CMD_SRC_MAX; i++ ) | |
477 { | |
478 R_AT( RAT_CRING, i ) ( CRING_MOD_Gprs, CRING_TYP_GPRS, CRING_TYP_NotPresent ); | |
479 } | |
480 } | |
481 else | |
482 { /* context reactivation */ | |
483 gprs_call_table[gprs_ct_index].reactivation = GCTT_REACTIVATION ; | |
484 strcpy(gprs_call_table[gprs_ct_index].L2P, "PPP"); | |
485 gprs_call_table[gprs_ct_index].cid = cid; | |
486 gprs_ct_index++; | |
487 } | |
488 | |
489 } | |
490 else | |
491 /* | |
492 * one or more PDP contexts are during the setup | |
493 */ | |
494 { | |
495 psaSM_PDP_No_activate(smShrdPrm.act_ind.smreg_ti, SMREG_RC_INSUF_RES); | |
496 | |
497 /* | |
498 * GPRS event reporting | |
499 */ | |
500 cmhSM_pdp_typ_to_string(smShrdPrm.act_ind.pdp_type, event.reject.pdp_type); | |
501 memcpy(&event.reject.pdp_addr, | |
502 &smShrdPrm.act_ind.pdp_address.buff, | |
503 smShrdPrm.act_ind.pdp_address.c_buff); | |
504 for( i = 0; i < CMD_SRC_MAX; i++ ) | |
505 { | |
506 R_AT( RAT_CGEREP, i ) ( CGEREP_EVENT_REJECT, &event ); | |
507 R_AT( RAT_P_CGEV, i ) ( CGEREP_EVENT_REJECT, &event ); | |
508 } | |
509 } | |
510 } | |
511 | |
512 /* | |
513 +-------------------------------------------------------------------+ | |
514 | PROJECT : GPRS (8441) MODULE : CMH_SMR | | |
515 | STATE : finnished ROUTINE : cmhSM_Deactivated | | |
516 +-------------------------------------------------------------------+ | |
517 | |
518 PURPOSE : confirms a successful PDP context deactivation | |
519 | |
520 */ | |
521 GLOBAL void cmhSM_Deactivated ( void ) | |
522 { | |
523 T_CGEREP_EVENT_REP_PARAM event; | |
524 T_CONTEXT_STATE state; | |
525 SHORT cid, | |
526 i, | |
527 reactivation = 0, | |
528 rat_id = RAT_MAX; | |
529 UBYTE cme_err = CME_ERR_GPRSUnspec, /* error number */ | |
530 cmdBuf = smEntStat.curCmd; /* buffers current command */ | |
531 USHORT temp_nsapiSet = smShrdPrm.nsapi_set; | |
532 T_DTI_CONN_LINK_ID dti_id_sn; | |
533 UBYTE srcId = srcId_cb; | |
534 | |
535 TRACE_FUNCTION ("cmhSM_Deactivated()"); | |
536 | |
537 /* | |
538 *------------------------------------------------------------------- | |
539 * check for command context | |
540 *------------------------------------------------------------------- | |
541 */ | |
542 | |
543 while ( CS_INVALID_STATE NEQ (state = get_state_over_nsapi_set( &smShrdPrm.nsapi_set, &cid )) ) | |
544 { | |
545 dti_id_sn = cmhSM_get_link_id_SNDCP_peer( cid, SNDCP_PEER_NORMAL ); | |
546 | |
547 switch ( state ) | |
548 { | |
549 case CS_UNDEFINED: | |
550 case CS_DEFINED: | |
551 case CS_WAITS_FOR_ACTIVATING: | |
552 case CS_ESTABLISH_1: | |
553 case CS_ESTABLISH_3: | |
554 case CS_ACTIVATED: | |
555 case CS_DATA_LINK: | |
556 default: | |
557 dumpContextInfo(cid); | |
558 continue; | |
559 case CS_ESTABLISH_2: | |
560 set_state_over_cid ( cid, CS_ABORT_ESTABLISH ); | |
561 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_SNDCP ); | |
562 break; | |
563 case CS_ABORT_ESTABLISH: | |
564 case CS_BREAKDOWN_LINK_ERROR: | |
565 TRACE_EVENT("state: CS_BREAKDOWN_LINK_ERROR"); | |
566 set_state_over_cid ( cid, CS_DEFINED ); | |
567 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_SNDCP ); | |
568 cmhSM_disconnect_cid(cid, GC_TYPE_DATA_LINK); | |
569 if(ati_user_output_cfg[srcId].CMEE_stat EQ CMEE_MOD_Disable) | |
570 rat_id = RAT_NO_CARRIER; | |
571 else | |
572 rat_id = RAT_CME; | |
573 break; | |
574 case CS_BREAKDOWN_LINK_NORMAL: | |
575 TRACE_EVENT("state: CS_BREAKDOWN_LINK_NORMAL"); | |
576 set_state_over_cid ( cid, CS_DEFINED ); | |
577 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_SNDCP ); | |
578 cmhSM_disconnect_cid(cid, GC_TYPE_DATA_LINK); | |
579 rat_id = RAT_NO_CARRIER; | |
580 break; | |
581 case CS_DEACTIVATE_NORMAL: | |
582 TRACE_EVENT("state: CS_DEACTIVATE_NORMAL") ; | |
583 set_state_over_cid ( cid, CS_DEFINED ); | |
584 #if defined (CO_UDP_IP) || defined (FF_GPF_TCPIP) | |
585 if ( is_ip_dti_id(pdp_context[cid-1].entity_id) ) | |
586 { | |
587 /* tell WAP ACI that contextactivation was rejected */ | |
588 psaTCPIP_Deactivate(cmhSM_IP_activate_cb); | |
589 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_SNDCP ); | |
590 } | |
591 else | |
592 #endif /* CO_UDP_IP || FF_GPF_TCPIP */ | |
593 { | |
594 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_SNDCP ); | |
595 cmhSM_disconnect_cid(cid, GC_TYPE_NULL); | |
596 } | |
597 break; | |
598 case CS_ACTIVATING: | |
599 TRACE_EVENT("state: CS_ACTIVATING"); | |
600 set_state_over_cid ( cid, CS_DEFINED ); | |
601 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_SNDCP ); | |
602 if(pdp_context[cid - 1].entity_id EQ DTI_ENTITY_NULL) | |
603 { | |
604 rat_id = RAT_CME; | |
605 } | |
606 cmhSM_disconnect_cid(cid, GC_TYPE_NULL); | |
607 break; | |
608 case CS_CONTEXT_REACTIVATION_1: | |
609 TRACE_EVENT("state: CD_CONTEXT_REACTIVATION_1"); | |
610 set_state_over_cid(cid, CS_CONTEXT_REACTIVATION_2); | |
611 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_SNDCP ); | |
612 smEntStat.curCmd = AT_CMD_NONE; | |
613 cmhSM_GiveNSapiFree(cid); | |
614 continue; | |
615 case CS_CONTEXT_REACTIVATION_2: | |
616 TRACE_EVENT("state: CD_CONTEXT_REACTIVATION_2"); | |
617 set_state_over_cid ( cid, CS_DEFINED ); | |
618 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_SNDCP ); | |
619 cmhSM_disconnect_cid(cid, GC_TYPE_DATA_LINK); | |
620 smEntStat.curCmd = AT_CMD_NONE; | |
621 rat_id = RAT_NO_CARRIER; | |
622 reactivation = 1; | |
623 break; | |
624 } | |
625 | |
626 if ( reactivation EQ 0 ) | |
627 { | |
628 if ( smEntStat.entOwn EQ get_owner_over_cid(cid) ) | |
629 switch( smEntStat.curCmd ) | |
630 { | |
631 case( AT_CMD_CGDATA ): | |
632 case( AT_CMD_CGACT ): | |
633 smEntStat.curCmd = AT_CMD_NONE; | |
634 cid_pointer = 0; | |
635 *work_cids = 0; | |
636 } | |
637 } | |
638 | |
639 /* | |
640 * GPRS event reporting | |
641 */ | |
642 strcpy(event.act.pdp_type, pdp_context[cid - 1].con.pdp_type); | |
643 strcpy(event.act.pdp_addr, pdp_context[cid - 1].allocated_pdp_addr); | |
644 event.act.cid = cid; | |
645 for( i = 0; i < CMD_SRC_MAX; i++ ) | |
646 { | |
647 R_AT( RAT_CGEREP, i ) ( CGEREP_EVENT_ME_DEACT, &event ); | |
648 R_AT( RAT_P_CGEV, i ) ( CGEREP_EVENT_ME_DEACT, &event ); | |
649 } | |
650 | |
651 cmhSM_GiveNSapiFree(cid); | |
652 | |
653 if ( rat_id NEQ RAT_MAX ) | |
654 { | |
655 gaci_RAT_caller ( rat_id, cid, cmdBuf, cme_err ); | |
656 | |
657 rat_id = RAT_MAX; | |
658 cid_pointer = 0; | |
659 *work_cids = 0; | |
660 | |
661 cmhSM_context_reactivation(); | |
662 } | |
663 } | |
664 | |
665 cmhSM_context_deactivated(temp_nsapiSet); | |
666 cmhSM_contextDeactivated(); | |
667 } | |
668 | |
669 /* | |
670 +-------------------------------------------------------------------+ | |
671 | PROJECT : GPRS (8441) MODULE : CMH_SMR | | |
672 | STATE : finnished ROUTINE : cmhSM_NetDeactivate | | |
673 +-------------------------------------------------------------------+ | |
674 | |
675 PURPOSE : indicates a PDP context deactivation | |
676 | |
677 */ | |
678 GLOBAL void cmhSM_NetDeactivate ( void ) | |
679 { | |
680 T_CGEREP_EVENT_REP_PARAM event; | |
681 T_CONTEXT_STATE state; | |
682 SHORT cid, | |
683 i = 0, | |
684 inform_ppp = 1, | |
685 rat_id = RAT_MAX; | |
686 UBYTE cme_err = CME_ERR_Unknown, /* error number */ | |
687 cmdBuf = AT_CMD_NONE; /* buffers current command */ | |
688 USHORT temp_nsapiSet = smShrdPrm.nsapi_set; | |
689 T_DTI_CONN_LINK_ID dti_id_sn; | |
690 UBYTE srcId = srcId_cb; | |
691 | |
692 TRACE_FUNCTION ("cmhSM_NetDeactivate()"); | |
693 | |
694 while ( CS_INVALID_STATE NEQ (state = get_state_over_nsapi_set( &smShrdPrm.nsapi_set, &cid )) ) | |
695 { | |
696 dti_id_sn = cmhSM_get_link_id_SNDCP_peer( cid, SNDCP_PEER_NORMAL ); | |
697 | |
698 switch ( state ) | |
699 { | |
700 case CS_UNDEFINED: | |
701 case CS_DEFINED: | |
702 case CS_ESTABLISH_1: | |
703 case CS_WAITS_FOR_ACTIVATING: | |
704 continue; | |
705 case CS_ESTABLISH_2: | |
706 case CS_ESTABLISH_3: | |
707 set_state_over_cid( cid, CS_ABORT_ESTABLISH ); | |
708 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_SNDCP ); | |
709 break; | |
710 case CS_ABORT_ESTABLISH: | |
711 set_state_over_cid( cid, CS_DEFINED ); | |
712 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_SNDCP ); | |
713 cmhSM_disconnect_cid(cid, GC_TYPE_DATA_LINK); | |
714 inform_ppp = 0; | |
715 if(ati_user_output_cfg[srcId].CMEE_stat EQ CMEE_MOD_Disable) | |
716 rat_id = RAT_NO_CARRIER; | |
717 else | |
718 rat_id = RAT_CME; | |
719 break; | |
720 case CS_BREAKDOWN_LINK_ERROR: | |
721 set_state_over_cid( cid, CS_DEFINED ); | |
722 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_SNDCP ); | |
723 cmhSM_disconnect_cid(cid, GC_TYPE_DATA_LINK); | |
724 if(ati_user_output_cfg[srcId].CMEE_stat EQ CMEE_MOD_Disable) | |
725 rat_id = RAT_NO_CARRIER; | |
726 else | |
727 rat_id = RAT_CME; | |
728 inform_ppp = 0; | |
729 break; | |
730 case CS_BREAKDOWN_LINK_NORMAL: | |
731 set_state_over_cid( cid, CS_DEFINED ); | |
732 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_SNDCP ); | |
733 cmhSM_disconnect_cid(cid, GC_TYPE_DATA_LINK); | |
734 rat_id = RAT_NO_CARRIER; | |
735 inform_ppp = 0; | |
736 break; | |
737 case CS_DATA_LINK: | |
738 set_state_over_cid( cid, CS_BREAKDOWN_LINK_NORMAL ); | |
739 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_SNDCP ); | |
740 break; | |
741 case CS_ACTIVATED: | |
742 inform_ppp = 0; | |
743 set_state_over_cid( cid, CS_DEFINED ); | |
744 #if defined (CO_UDP_IP) || defined (FF_GPF_TCPIP) | |
745 if ( is_ip_dti_id(pdp_context[cid-1].entity_id) ) | |
746 { | |
747 /* tell WAP ACI that contextactivation was rejected */ | |
748 psaTCPIP_Deactivate(cmhSM_IP_activate_cb); | |
749 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_SNDCP ); | |
750 } | |
751 else | |
752 #endif /* CO_UDP_IP || FF_GPF_TCPIP */ | |
753 { | |
754 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_SNDCP ); | |
755 cmhSM_disconnect_cid(cid, GC_TYPE_NULL); | |
756 } | |
757 break; | |
758 case CS_DEACTIVATE_NORMAL: | |
759 inform_ppp = 0; | |
760 set_state_over_cid( cid, CS_DEFINED ); | |
761 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_SNDCP ); | |
762 #if defined (CO_UDP_IP) || defined (FF_GPF_TCPIP) | |
763 if ( is_ip_dti_id(pdp_context[cid-1].entity_id) ) | |
764 { | |
765 /* tell WAP ACI that contextactivation was rejected */ | |
766 psaTCPIP_Deactivate(cmhSM_IP_activate_cb); | |
767 } | |
768 else | |
769 #endif /* CO_UDP_IP || FF_GPF_TCPIP */ | |
770 { | |
771 cmhSM_disconnect_cid(cid, GC_TYPE_NULL); | |
772 } | |
773 break; | |
774 case CS_ACTIVATING: | |
775 inform_ppp = 0; | |
776 set_state_over_cid( cid, CS_DEFINED ); | |
777 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_SNDCP ); | |
778 #if defined (CO_UDP_IP) || defined (FF_GPF_TCPIP) | |
779 if ( is_ip_dti_id(pdp_context[cid-1].entity_id) ) | |
780 { | |
781 /* tell WAP ACI that contextactivation was rejected */ | |
782 psaTCPIP_Deactivate(cmhSM_IP_activate_cb); | |
783 } | |
784 else | |
785 #endif /* CO_UDP_IP OR FF_GPF_TCPIP */ | |
786 { | |
787 cmhSM_disconnect_cid(cid, GC_TYPE_NULL); | |
788 } | |
789 if(pdp_context[cid - 1].entity_id EQ DTI_ENTITY_NULL) | |
790 { | |
791 rat_id = RAT_CME; | |
792 } | |
793 break; | |
794 case CS_CONTEXT_REACTIVATION_1: | |
795 set_state_over_cid(cid, CS_CONTEXT_REACTIVATION_2); | |
796 cmhSM_stop_context_reactivation(); | |
797 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_SNDCP ); | |
798 cmhSM_GiveNSapiFree(cid); | |
799 continue; | |
800 case CS_CONTEXT_REACTIVATION_2: | |
801 set_state_over_cid( cid, CS_DEFINED ); | |
802 cmhSM_stop_context_reactivation(); | |
803 dti_cntrl_entity_disconnected( dti_id_sn, DTI_ENTITY_SNDCP ); | |
804 rat_id = RAT_NO_CARRIER; | |
805 inform_ppp = 0; | |
806 break; | |
807 } | |
808 | |
809 if ( inform_ppp ) | |
810 { | |
811 /* | |
812 *--------------------------------------------------------------- | |
813 * inform PPP | |
814 *--------------------------------------------------------------- | |
815 */ | |
816 psaGPPP_Terminate( PPP_LOWER_LAYER_UP ); | |
817 } | |
818 | |
819 if ( smEntStat.entOwn EQ get_owner_over_cid(cid) ) | |
820 switch( smEntStat.curCmd ) | |
821 { | |
822 case( AT_CMD_CGDATA ): | |
823 case( AT_CMD_CGACT ): | |
824 smEntStat.curCmd = AT_CMD_NONE; | |
825 cid_pointer = 0; | |
826 *work_cids = 0; | |
827 } | |
828 | |
829 /* | |
830 * GPRS event reporting | |
831 */ | |
832 strcpy(event.act.pdp_type, pdp_context[cid - 1].con.pdp_type); | |
833 strcpy(event.act.pdp_addr, pdp_context[cid - 1].allocated_pdp_addr); | |
834 event.act.cid = cid; | |
835 for( i = 0; i < CMD_SRC_MAX; i++ ) | |
836 { | |
837 R_AT( RAT_CGEREP, i ) ( CGEREP_EVENT_NW_DEACT, &event ); | |
838 R_AT( RAT_P_CGEV, i ) ( CGEREP_EVENT_NW_DEACT, &event ); | |
839 } | |
840 | |
841 cmhSM_GiveNSapiFree (cid); | |
842 | |
843 if ( rat_id NEQ RAT_MAX ) | |
844 { | |
845 gaci_RAT_caller ( rat_id, cid, cmdBuf, cme_err ); | |
846 | |
847 cid_pointer = 0; | |
848 *work_cids = 0; | |
849 rat_id = RAT_MAX; | |
850 } | |
851 } | |
852 | |
853 cmhSM_context_deactivated(temp_nsapiSet); | |
854 cmhSM_contextDeactivated(); | |
855 | |
856 /* inform SAT if needed */ | |
857 #if defined (FF_SAT_E) | |
858 cmhSAT_OpChnGPRSDeact(); | |
859 #endif | |
860 | |
861 } | |
862 | |
863 /* | |
864 +-------------------------------------------------------------------+ | |
865 | PROJECT : GPRS (8441) MODULE : CMH_SMR | | |
866 | STATE : finnished ROUTINE : cmhSM_NetModify | | |
867 +-------------------------------------------------------------------+ | |
868 | |
869 PURPOSE : indicates a network initiated PDP context modification | |
870 | |
871 */ | |
872 GLOBAL void cmhSM_NetModify ( USHORT nsapi_set, T_smreg_qos *smreg_qos ) | |
873 { | |
874 SHORT cid, i = 0; | |
875 | |
876 TRACE_FUNCTION ("cmhSM_NetModify()"); | |
877 | |
878 while ( CS_INVALID_STATE NEQ get_state_over_nsapi_set( &nsapi_set, &cid ) ) | |
879 { | |
880 pdp_context[cid - 1].qos.preced = smreg_qos->preced; | |
881 pdp_context[cid - 1].qos.delay = smreg_qos->delay; | |
882 pdp_context[cid - 1].qos.relclass = smreg_qos->relclass; | |
883 pdp_context[cid - 1].qos.peak = smreg_qos->peak; | |
884 pdp_context[cid - 1].qos.mean = smreg_qos->mean; | |
885 | |
886 for( i = 0 ; i < CMD_SRC_MAX; i++ ) | |
887 { | |
888 R_AT( RAT_QOS_MOD, i ) ( cid, smreg_qos ); | |
889 } | |
890 } | |
891 } | |
892 | |
893 #endif /* GPRS */ | |
894 /*==== EOF ========================================================*/ | |
895 |