comparison src/g23m-aci/aci/psa_gpppf.c @ 162:53929b40109c

src/g23m-aci: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 11 Oct 2016 02:02:43 +0000
parents
children
comparison
equal deleted inserted replaced
161:4557e2a9c18e 162:53929b40109c
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 GLOBAL void cmhGPPP_send_establish_request ( UBYTE peer, UBYTE prot );
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_SRC_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) CMD_SRC_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 UBYTE GPPS_First_Stored_Peer = 0; // HHV: Bad hack due to two DTI links in one prim!
113 GLOBAL void psaGPPPS_Dti_Req( T_DTI_CONN_LINK_ID link_id, UBYTE peer )
114 {
115 T_PDP_CONTEXT_INTERNAL *p_pdp_context_node = NULL;
116 TRACE_FUNCTION("psaGPPPS_Dti_Req()");
117
118 p_pdp_context_node = pdp_context_find_node_from_cid( work_cids[0]);
119
120 switch ( peer )
121 {
122 #ifdef BT_ADAPTER
123 case DTI_ENTITY_BLUETOOTH:
124 p_pdp_context_node->internal_data.link_id_uart = link_id;
125 dti_cntrl_set_conn_parms(link_id, DTI_ENTITY_BLUETOOTH, 0, 0);
126 dti_cntrl_set_conn_parms(link_id, DTI_ENTITY_PPPS, 0, 0);
127 if (GPPS_First_Stored_Peer)
128 {
129 io_setDCD (p_pdp_context_node->internal_data.owner, IO_DCD_ON);
130 cmhGPPP_send_establish_request(GPPS_First_Stored_Peer, DTI_ENTITY_BLUETOOTH);
131 GPPS_First_Stored_Peer = 0;
132 }
133 else
134 {
135 GPPS_First_Stored_Peer = DTI_ENTITY_BLUETOOTH;
136 }
137 break;
138
139 #endif /* BT_ADAPTER */
140 case DTI_ENTITY_UART:
141 p_pdp_context_node->internal_data.link_id_uart = link_id;
142 dti_cntrl_set_conn_parms(link_id, DTI_ENTITY_UART, 0, 0);
143 dti_cntrl_set_conn_parms(link_id, DTI_ENTITY_PPPS, 0, 0);
144 if (GPPS_First_Stored_Peer)
145 {
146 io_setDCD (p_pdp_context_node->internal_data.owner, IO_DCD_ON);
147 cmhGPPP_send_establish_request(GPPS_First_Stored_Peer, DTI_ENTITY_UART);
148 GPPS_First_Stored_Peer = 0;
149 }
150 else
151 {
152 GPPS_First_Stored_Peer = DTI_ENTITY_UART;
153 }
154 break;
155 #if 0
156 /* For the 3G protocol stack PPP can not have UPM as peer as all data goes through SNDCP! */
157 case DTI_ENTITY_UPM:
158 p_pdp_context_node->internal_data.link_id = link_id;
159 dti_cntrl_set_conn_parms(link_id, DTI_ENTITY_UPM, 0, 0);
160 dti_cntrl_set_conn_parms(link_id, DTI_ENTITY_PPPS, 0, 0);
161 if (GPPS_First_Stored_Peer)
162 {
163 T_DTI_ENTITY_ID other_peer = dti_cntrl_get_peer(DTI_ENTITY_PPPS, 0, 0);
164 if(DTI_ENTITY_UART EQ other_peer)
165 {
166 io_setDCD (p_pdp_context_node->internal_data.owner, IO_DCD_ON);
167 }
168 cmhGPPP_send_establish_request(GPPS_First_Stored_Peer, DTI_ENTITY_UPM);
169 GPPS_First_Stored_Peer = 0;
170 }
171 else
172 {
173 GPPS_First_Stored_Peer = DTI_ENTITY_UPM;
174 }
175 break;
176 #endif /* 0 */
177 #ifdef FF_PSI
178 case DTI_ENTITY_PSI:
179 p_pdp_context_node->internal_data.link_id_uart = link_id;
180 dti_cntrl_set_conn_parms(link_id, DTI_ENTITY_PSI, 0, 0);
181 dti_cntrl_set_conn_parms(link_id, DTI_ENTITY_PPPS, 0, 0);
182 if (GPPS_First_Stored_Peer)
183 {
184 io_setDCD (p_pdp_context_node->internal_data.owner, IO_DCD_ON);
185 cmhGPPP_send_establish_request(GPPS_First_Stored_Peer, DTI_ENTITY_PSI);
186 }
187 else
188 {
189 GPPS_First_Stored_Peer = DTI_ENTITY_PSI;
190 }
191 break;
192 #endif /*FF_PSI*/
193 case DTI_ENTITY_AAA:
194 p_pdp_context_node->internal_data.link_id_uart = link_id;
195 dti_cntrl_set_conn_parms(link_id, DTI_ENTITY_AAA, 0, 0);
196 dti_cntrl_set_conn_parms(link_id, DTI_ENTITY_PPPS, 0, 0);
197 if (GPPS_First_Stored_Peer)
198 {
199 cmhGPPP_send_establish_request(GPPS_First_Stored_Peer, DTI_ENTITY_AAA);
200 GPPS_First_Stored_Peer = 0;
201 }
202 else
203 {
204 GPPS_First_Stored_Peer = DTI_ENTITY_AAA;
205 }
206 break;
207
208 case DTI_ENTITY_SNDCP:
209 p_pdp_context_node->internal_data.link_id = link_id;
210 dti_cntrl_set_conn_parms(link_id, DTI_ENTITY_SNDCP, 0, 0);
211 dti_cntrl_set_conn_parms(link_id, DTI_ENTITY_PPPS, 0, 0);
212
213 if (GPPS_First_Stored_Peer)
214 {
215 T_DTI_ENTITY_ID other_peer = dti_cntrl_get_peer(DTI_ENTITY_PPPS, 0, 0);
216 if(DTI_ENTITY_UART EQ other_peer)
217 {
218 io_setDCD (p_pdp_context_node->internal_data.owner, IO_DCD_ON);
219 }
220 cmhGPPP_send_establish_request(GPPS_First_Stored_Peer, DTI_ENTITY_SNDCP);
221 GPPS_First_Stored_Peer = 0;
222 }
223 else
224 {
225 GPPS_First_Stored_Peer = DTI_ENTITY_SNDCP;
226 }
227 break;
228 }
229 }
230
231 /*
232 +-------------------------------------------------------------------------+
233 | PROJECT : GSM-F&D (8411) MODULE : PSA_PPPF |
234 | STATE : code ROUTINE : PPP_UART_connect_dti_cb |
235 +-------------------------------------------------------------------------+
236
237 PURPOSE : Callback for DTI connection between PPP Server and UART.
238
239 */
240 GLOBAL BOOL PPP_UART_connect_dti_cb(UBYTE dti_id, T_DTI_CONN_STATE result_type)
241 {
242 TRACE_FUNCTION("PPP_UART_connect_dti_cb");
243
244 switch( result_type)
245 {
246 case DTI_CONN_STATE_DISCONNECTING:
247 break;
248 case DTI_CONN_STATE_DISCONNECTED:
249 dti_cntrl_clear_conn_parms(dti_id);
250 if (dti_cntrl_is_dti_id_to_reconnect(dti_id))
251 {
252 T_DTI_ENTITY_ID entity_list[] = {DTI_ENTITY_ACI};
253 T_DTI_CNTRL info;
254
255 if (dti_cntrl_get_info_from_dti_id( dti_id, &info) EQ FALSE)
256 {
257 TRACE_EVENT_P1("cannot find info for dti_id=%d", dti_id);
258 return FALSE;
259 }
260
261 if (info.dev_id EQ DTI_ENTITY_UART)
262 {
263 io_setDCD ((T_ACI_CMD_SRC)info.src_id, IO_DCD_OFF);
264
265 dti_cntrl_clear_dti_id_to_reconnect(dti_id);
266 dti_cntrl_est_dpath_indirect ( info.src_id,
267 entity_list,
268 1,
269 SPLIT,
270 atiUART_dti_cb,
271 DTI_CPBLTY_CMD,
272 DTI_CID_NOTPRESENT);
273 }
274 #ifdef FF_PSI
275 else if (info.dev_id EQ DTI_ENTITY_PSI)
276 {
277 io_setDCD ((T_ACI_CMD_SRC)info.src_id, IO_DCD_OFF);
278
279 dti_cntrl_clear_dti_id_to_reconnect(dti_id);
280 dti_cntrl_est_dpath_indirect ( info.src_id,
281 entity_list,
282 1,
283 SPLIT,
284 atiPSI_dti_cb,
285 DTI_CPBLTY_CMD,
286 DTI_CID_NOTPRESENT);
287 }
288 #endif /*FF_PSI*/
289 else
290 return FALSE;
291 }
292 break;
293
294 case DTI_CONN_STATE_CONNECTING:
295 break;
296 case DTI_CONN_STATE_CONNECTED:
297 break;
298
299 case DTI_CONN_STATE_ERROR:
300 /* connection not possible: disconnect PPP */
301 dti_cntrl_close_dpath_from_dti_id(dti_id);
302 break;
303 case DTI_CONN_STATE_UNKNOWN:
304 default:
305 TRACE_EVENT("PPP_UART_connect_dti_cb call with not awaited value");
306 break;
307 }
308 return TRUE;
309 }
310
311 #if 0
312 /*
313 +-------------------------------------------------------------------+
314 | PROJECT : GSM-PS (6147) MODULE : PSA_PPPF |
315 | ROUTINE : psaGPPP_shrPrmDump |
316 +-------------------------------------------------------------------+
317
318 PURPOSE : this function dumps the shared parameter to the debug
319 output.
320 */
321
322 GLOBAL void psaGPPP_shrPrmDump ( void )
323 {
324 #ifdef TRACING
325
326 char lnBuf [80]; /* holds buffer for output line */
327 char mccBuf[SIZE_MCC + 1]; /* MCC converted to printable C-string */
328 char mncBuf[SIZE_MNC + 1]; /* MNC converted to printable C-string */
329 SHORT chrNr; /* holds number of processed chars */
330 SHORT cnt; /* holds a counter */
331
332 /* --- PLMN list ------------------------------------------------*/
333 for( cnt = 0; cnt<MAX_PLMN_ID AND
334 mmShrdPrm.PLMNLst[cnt].v_plmn NEQ INVLD_PLMN; cnt++ )
335 {
336 chrNr = sprintf( lnBuf, "%*.*s[%2d]", HDR_WDT, HDR_WDT, " PLMN list",cnt );
337 utl_BCD2String (mccBuf, mmShrdPrm.PLMNLst[cnt].mcc, SIZE_MCC);
338 utl_BCD2String (mncBuf, mmShrdPrm.PLMNLst[cnt].mnc, SIZE_MNC);
339 chrNr += sprintf( lnBuf+chrNr, "%*s %*s",
340 ITM_WDT/2, ITM_WDT/2, mccBuf, mncBuf);
341 TRACE_EVENT( lnBuf );
342 }
343
344 /* --- used PLMN ------------------------------------------------*/
345 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, " used PLMN" );
346 if( mmShrdPrm.usedPLMN.v_plmn EQ VLD_PLMN )
347 {
348 utl_BCD2String (mccBuf, mmShrdPrm.usedPLMN.mcc, SIZE_MCC);
349 utl_BCD2String (mncBuf, mmShrdPrm.usedPLMN.mnc, SIZE_MNC);
350 chrNr += sprintf( lnBuf+chrNr, "%*s %*s",
351 ITM_WDT/2, ITM_WDT/2, mccBuf, mncBuf);
352 }
353 else
354 {
355 chrNr += sprintf( lnBuf+chrNr, "%*s", ITM_WDT, "none" );
356 }
357 TRACE_EVENT( lnBuf );
358
359 /* --- registration mode ----------------------------------------*/
360 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, "rgstr mode" );
361 chrNr += sprintf( lnBuf+chrNr, "%*hd", ITM_WDT,
362 mmShrdPrm.setPrm[0].regMode );
363 TRACE_EVENT( lnBuf );
364
365 /* --- registration status --------------------------------------*/
366 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, "rgstr stat" );
367 chrNr += sprintf( lnBuf+chrNr, "%*hd", ITM_WDT,
368 mmShrdPrm.regStat );
369 TRACE_EVENT( lnBuf );
370
371 /* --- search result --------------------------------------------*/
372 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, " srch rslt" );
373 chrNr += sprintf( lnBuf+chrNr, "%*hd", ITM_WDT,
374 mmShrdPrm.srchRslt );
375 TRACE_EVENT( lnBuf );
376
377 /* --- de-registration cause ------------------------------------*/
378 chrNr = sprintf( lnBuf, "%*.*s", HDR_WDT, HDR_WDT, "dereg caus" );
379 chrNr += sprintf( lnBuf+chrNr, "%*X", ITM_WDT,
380 mmShrdPrm.deregCs );
381 TRACE_EVENT( lnBuf );
382
383 #endif /* of #ifdef TRACING */
384 }
385 #endif /* #if 0 */
386
387 #endif /* GPRS */
388 /*==== EOF ========================================================*/
389