FreeCalypso > hg > tcs211-l1-reconst
comparison g23m/condat/ms/src/aci/psa_gpppf.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 for the protocol | |
18 | stack adapter for GPRS Point-to-Point Protocol ( PPP ). | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 #if defined (GPRS) && defined (DTI) | |
23 | |
24 #ifndef PSA_GPPPF_C | |
25 #define PSA_GPPPF_C | |
26 #endif | |
27 | |
28 #include "aci_all.h" | |
29 | |
30 #undef TRACING | |
31 /*==== INCLUDES ===================================================*/ | |
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 #include "aci.h" | |
37 #include "psa.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 "cmh.h" | |
45 #include "cmh_sm.h" | |
46 | |
47 #include "psa_gppp.h" | |
48 #include "aci_io.h" | |
49 | |
50 #include "psa_uart.h" | |
51 #include "sap_dti.h" | |
52 #ifdef FF_PSI | |
53 #include "psa_psi.h" | |
54 #include "cmh_psi.h" | |
55 #include "ati_src_psi.h" | |
56 #endif /*FF_PSI*/ | |
57 | |
58 /*==== CONSTANTS ==================================================*/ | |
59 /*#define ITM_WDT (14)*/ /* item width in chars */ | |
60 /*#define HDR_WDT (10)*/ /* header width in chars */ | |
61 | |
62 /*==== TYPES ======================================================*/ | |
63 | |
64 | |
65 /*==== EXPORT =====================================================*/ | |
66 | |
67 | |
68 /*==== VARIABLES ==================================================*/ | |
69 | |
70 /*==== FUNCTIONS ==================================================*/ | |
71 EXTERN void cmhGPPP_send_establish_request( UBYTE peer ); | |
72 | |
73 /* | |
74 +-------------------------------------------------------------------+ | |
75 | PROJECT : GPRS (8441) MODULE : PSA_PPPF | | |
76 | STATE : code ROUTINE : psaGPPP_Init | | |
77 +-------------------------------------------------------------------+ | |
78 | |
79 PURPOSE : initialize the protocol stack adapter for PPP. | |
80 | |
81 */ | |
82 | |
83 /* MACRO: initializer for set parameter */ | |
84 #ifdef INIT_SET_PARM | |
85 #undef INIT_SET_PARM | |
86 #endif | |
87 | |
88 #define INIT_SET_PARM( dest, def )\ | |
89 for( LpCnt = 0; LpCnt < OWN_MAX; LpCnt++ )\ | |
90 gpppShrdPrm.setPrm[LpCnt].dest = def | |
91 | |
92 GLOBAL void psaGPPP_Init ( UBYTE accm, UBYTE restart_timer, | |
93 UBYTE max_configure, UBYTE max_terminate, UBYTE max_failure ) | |
94 { | |
95 | |
96 /* | |
97 *------------------------------------------------------------------- | |
98 * set default parms | |
99 *------------------------------------------------------------------- | |
100 */ | |
101 gpppShrdPrm.owner = (UBYTE) OWN_NONE; | |
102 gpppShrdPrm.ppp_authentication_protocol = PPP_AP_AUTO; | |
103 | |
104 gpppShrdPrm.accm = accm; | |
105 gpppShrdPrm.restart_timer = restart_timer; | |
106 gpppShrdPrm.max_configure = max_configure; | |
107 gpppShrdPrm.max_terminate = max_terminate; | |
108 gpppShrdPrm.max_failure = max_failure; | |
109 | |
110 } | |
111 | |
112 GLOBAL void psaGPPPS_Dti_Req( T_DTI_CONN_LINK_ID link_id, UBYTE peer ) | |
113 { | |
114 | |
115 TRACE_FUNCTION("psaGPPPS_Dti_Req()"); | |
116 | |
117 switch ( peer ) | |
118 { | |
119 #ifdef BT_ADAPTER | |
120 case DTI_ENTITY_BLUETOOTH: | |
121 #endif /* BT_ADAPTER */ | |
122 case DTI_ENTITY_UART: | |
123 pdp_context[work_cids[0] - 1].link_id_uart = link_id; | |
124 dti_cntrl_set_conn_parms(link_id, DTI_ENTITY_UART, 0, 0); | |
125 dti_cntrl_set_conn_parms(link_id, DTI_ENTITY_PPPS, 0, 0); | |
126 if(DTI_TUPLE_NO_NOTPRESENT NEQ EXTRACT_TUPLE_NO(pdp_context[work_cids[0] - 1].link_id_new)) | |
127 { | |
128 io_setDCD (pdp_context[work_cids[0] - 1].owner, IO_DCD_ON); | |
129 cmhGPPP_send_establish_request(peer); | |
130 } | |
131 break; | |
132 #ifdef FF_PSI | |
133 case DTI_ENTITY_PSI: | |
134 pdp_context[work_cids[0] - 1].link_id_uart = link_id; | |
135 dti_cntrl_set_conn_parms(link_id, DTI_ENTITY_PSI, 0, 0); | |
136 dti_cntrl_set_conn_parms(link_id, DTI_ENTITY_PPPS, 0, 0); | |
137 if(DTI_TUPLE_NO_NOTPRESENT NEQ EXTRACT_TUPLE_NO(pdp_context[work_cids[0] - 1].link_id_new)) | |
138 { | |
139 io_setDCD (pdp_context[work_cids[0] - 1].owner, IO_DCD_ON); | |
140 cmhGPPP_send_establish_request(peer); | |
141 } | |
142 break; | |
143 #endif /*FF_PSI*/ | |
144 case DTI_ENTITY_AAA: | |
145 pdp_context[work_cids[0] - 1].link_id_uart = link_id; | |
146 dti_cntrl_set_conn_parms(link_id, DTI_ENTITY_AAA, 0, 0); | |
147 dti_cntrl_set_conn_parms(link_id, DTI_ENTITY_PPPS, 0, 0); | |
148 if(DTI_TUPLE_NO_NOTPRESENT NEQ EXTRACT_TUPLE_NO(pdp_context[work_cids[0] - 1].link_id_new)) | |
149 { | |
150 cmhGPPP_send_establish_request(peer); | |
151 } | |
152 break; | |
153 case DTI_ENTITY_SNDCP: | |
154 pdp_context[work_cids[0] - 1].link_id_new = link_id; | |
155 if(DTI_TUPLE_NO_NOTPRESENT NEQ EXTRACT_TUPLE_NO(pdp_context[work_cids[0] - 1].link_id_uart)) | |
156 { | |
157 T_DTI_ENTITY_ID other_peer = dti_cntrl_get_peer(DTI_ENTITY_PPPS, 0, 0); | |
158 if(DTI_ENTITY_UART EQ other_peer OR DTI_ENTITY_PSI EQ other_peer) | |
159 { | |
160 io_setDCD (pdp_context[work_cids[0] - 1].owner, IO_DCD_ON); | |
161 } | |
162 cmhGPPP_send_establish_request(other_peer); | |
163 } | |
164 break; | |
165 } | |
166 } | |
167 | |
168 /* | |
169 +-------------------------------------------------------------------------+ | |
170 | PROJECT : GSM-F&D (8411) MODULE : PSA_PPPF | | |
171 | STATE : code ROUTINE : PPP_UART_connect_dti_cb | | |
172 +-------------------------------------------------------------------------+ | |
173 | |
174 PURPOSE : Callback for DTI connection between PPP Server and UART. | |
175 | |
176 */ | |
177 GLOBAL BOOL PPP_UART_connect_dti_cb(UBYTE dti_id, T_DTI_CONN_STATE result_type) | |
178 { | |
179 TRACE_FUNCTION("PPP_UART_connect_dti_cb"); | |
180 | |
181 switch( result_type) | |
182 { | |
183 case DTI_CONN_STATE_DISCONNECTING: | |
184 break; | |
185 case DTI_CONN_STATE_DISCONNECTED: | |
186 dti_cntrl_clear_conn_parms(dti_id); | |
187 if (dti_cntrl_is_dti_id_to_reconnect(dti_id)) | |
188 { | |
189 T_DTI_ENTITY_ID entity_list[] = {DTI_ENTITY_ACI}; | |
190 T_DTI_CNTRL info; | |
191 | |
192 if (dti_cntrl_get_info_from_dti_id( dti_id, &info) EQ FALSE) | |
193 { | |
194 TRACE_EVENT_P1("cannot find info for dti_id=%d", dti_id); | |
195 return FALSE; | |
196 } | |
197 | |
198 if (info.dev_id EQ DTI_ENTITY_UART) | |
199 { | |
200 io_setDCD (info.src_id, IO_DCD_OFF); | |
201 | |
202 dti_cntrl_clear_dti_id_to_reconnect(dti_id); | |
203 dti_cntrl_est_dpath_indirect ( info.src_id, | |
204 entity_list, | |
205 1, | |
206 SPLIT, | |
207 atiUART_dti_cb, | |
208 DTI_CPBLTY_CMD, | |
209 DTI_CID_NOTPRESENT); | |
210 } | |
211 #ifdef FF_PSI | |
212 else if (info.dev_id EQ DTI_ENTITY_PSI) | |
213 { | |
214 io_setDCD (info.src_id, IO_DCD_OFF); | |
215 | |
216 dti_cntrl_clear_dti_id_to_reconnect(dti_id); | |
217 dti_cntrl_est_dpath_indirect ( info.src_id, | |
218 entity_list, | |
219 1, | |
220 SPLIT, | |
221 atiPSI_dti_cb, | |
222 DTI_CPBLTY_CMD, | |
223 DTI_CID_NOTPRESENT); | |
224 } | |
225 #endif /*FF_PSI*/ | |
226 else | |
227 return FALSE; | |
228 } | |
229 break; | |
230 | |
231 case DTI_CONN_STATE_CONNECTING: | |
232 break; | |
233 case DTI_CONN_STATE_CONNECTED: | |
234 break; | |
235 | |
236 case DTI_CONN_STATE_ERROR: | |
237 /* connection not possible: disconnect PPP */ | |
238 dti_cntrl_close_dpath_from_dti_id(dti_id); | |
239 break; | |
240 case DTI_CONN_STATE_UNKNOWN: | |
241 default: | |
242 TRACE_EVENT("PPP_UART_connect_dti_cb call with not awaited value"); | |
243 break; | |
244 } | |
245 return TRUE; | |
246 } | |
247 | |
248 /* | |
249 +--------------------------------------------------------------------------+ | |
250 | PROJECT : GSM-F&D (8411) MODULE : PSA_PPPF | | |
251 | STATE : code ROUTINE : PPP_SNDCP_connect_dti_cb | | |
252 +--------------------------------------------------------------------------+ | |
253 | |
254 PURPOSE : Callback for connection between PPP Server and SNDCP. | |
255 | |
256 */ | |
257 GLOBAL BOOL PPP_SNDCP_connect_dti_cb(UBYTE dti_id, T_DTI_CONN_STATE result_type) | |
258 { | |
259 TRACE_FUNCTION("PPP_SNDCP_connect_dti_cb"); | |
260 | |
261 switch( result_type) | |
262 { | |
263 case DTI_CONN_STATE_DISCONNECTING: | |
264 case DTI_CONN_STATE_DISCONNECTED: | |
265 case DTI_CONN_STATE_CONNECTING: | |
266 case DTI_CONN_STATE_CONNECTED: | |
267 break; | |
268 case DTI_CONN_STATE_ERROR: | |
269 /* connection not possible: disconnect SNDCP */ | |
270 dti_cntrl_close_dpath_from_dti_id( dti_id ); | |
271 break; | |
272 case DTI_CONN_STATE_UNKNOWN: | |
273 default: | |
274 TRACE_EVENT("PPP_SNDCP_connect_dti_cb call with not awaited value"); | |
275 break; | |
276 } | |
277 return TRUE; | |
278 } | |
279 | |
280 #if 0 | |
281 /* | |
282 +-------------------------------------------------------------------+ | |
283 | PROJECT : GSM-PS (6147) MODULE : PSA_PPPF | | |
284 | ROUTINE : psaGPPP_shrPrmDump | | |
285 +-------------------------------------------------------------------+ | |
286 | |
287 PURPOSE : this function dumps the shared parameter to the debug | |
288 output. | |
289 */ | |
290 | |
291 GLOBAL void psaGPPP_shrPrmDump ( void ) | |
292 { | |
293 #ifdef TRACING | |
294 | |
295 char lnBuf [80]; /* holds buffer for output line */ | |
296 char mccBuf[SIZE_MCC + 1]; /* MCC converted to printable C-string */ | |
297 char mncBuf[SIZE_MNC + 1]; /* MNC converted to printable C-string */ | |
298 SHORT chrNr; /* holds number of processed chars */ | |
299 SHORT cnt; /* holds a counter */ | |
300 | |
301 /* --- PLMN list ------------------------------------------------*/ | |
302 for( cnt = 0; cnt<MAX_PLMN_ID AND | |
303 mmShrdPrm.PLMNLst[cnt].v_plmn NEQ INVLD_PLMN; cnt++ ) | |
304 { | |
305 chrNr = sprintf( lnBuf, "%*.*s[%2d]", HDR_WDT, HDR_WDT, " PLMN list",cnt ); | |
306 utl_BCD2String (mccBuf, mmShrdPrm.PLMNLst[cnt].mcc, SIZE_MCC); | |
307 utl_BCD2String (mncBuf, mmShrdPrm.PLMNLst[cnt].mnc, SIZE_MNC); | |
308 chrNr += sprintf( lnBuf+chrNr, "%*s %*s", | |
309 ITM_WDT/2, ITM_WDT/2, mccBuf, mncBuf); | |
310 TRACE_EVENT( lnBuf ); | |
311 } | |
312 | |
313 /* --- used PLMN ------------------------------------------------*/ | |
314 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, " used PLMN" ); | |
315 if( mmShrdPrm.usedPLMN.v_plmn EQ VLD_PLMN ) | |
316 { | |
317 utl_BCD2String (mccBuf, mmShrdPrm.usedPLMN.mcc, SIZE_MCC); | |
318 utl_BCD2String (mncBuf, mmShrdPrm.usedPLMN.mnc, SIZE_MNC); | |
319 chrNr += sprintf( lnBuf+chrNr, "%*s %*s", | |
320 ITM_WDT/2, ITM_WDT/2, mccBuf, mncBuf); | |
321 } | |
322 else | |
323 { | |
324 chrNr += sprintf( lnBuf+chrNr, "%*s", ITM_WDT, "none" ); | |
325 } | |
326 TRACE_EVENT( lnBuf ); | |
327 | |
328 /* --- registration mode ----------------------------------------*/ | |
329 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, "rgstr mode" ); | |
330 chrNr += sprintf( lnBuf+chrNr, "%*hd", ITM_WDT, | |
331 mmShrdPrm.setPrm[0].regMode ); | |
332 TRACE_EVENT( lnBuf ); | |
333 | |
334 /* --- registration status --------------------------------------*/ | |
335 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, "rgstr stat" ); | |
336 chrNr += sprintf( lnBuf+chrNr, "%*hd", ITM_WDT, | |
337 mmShrdPrm.regStat ); | |
338 TRACE_EVENT( lnBuf ); | |
339 | |
340 /* --- search result --------------------------------------------*/ | |
341 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, " srch rslt" ); | |
342 chrNr += sprintf( lnBuf+chrNr, "%*hd", ITM_WDT, | |
343 mmShrdPrm.srchRslt ); | |
344 TRACE_EVENT( lnBuf ); | |
345 | |
346 /* --- de-registration cause ------------------------------------*/ | |
347 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, "dereg caus" ); | |
348 chrNr += sprintf( lnBuf+chrNr, "%*X", ITM_WDT, | |
349 mmShrdPrm.deregCs ); | |
350 TRACE_EVENT( lnBuf ); | |
351 | |
352 #endif /* of #ifdef TRACING */ | |
353 } | |
354 #endif /* #if 0 */ | |
355 | |
356 #endif /* GPRS */ | |
357 /*==== EOF ========================================================*/ | |
358 |