comparison g23m-aci/aci/cmh_dti.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 | File: cmh_dti.c
4 +------------------------------------------------------------------------------
5 | Copyright Condat AG 1999-2000, Berlin
6 | All rights reserved.
7 |
8 | This file is confidential and a trade secret of Condat AG.
9 | The receipt of or possession of this file does not convey
10 | any rights to reproduce or disclose its contents or to
11 | manufacture, use, or sell anything it may describe, in
12 | whole, or in part, without the specific written consent of
13 | Condat AG.
14 +------------------------------------------------------------------------------
15 | Purpose: This module provides the set functions related to the
16 | DTI managment.
17 | $Identity:$
18 +------------------------------------------------------------------------------
19 */
20
21 #include "config.h"
22 #include "fixedconf.h"
23 #include "condat-features.h"
24 #include "aci_conf.h"
25
26 #ifdef DTI
27
28 #ifndef CMH_DTI_C
29 #define CMH_DTI_C
30 #endif
31
32 #include "aci_all.h"
33 /*==== INCLUDES ===================================================*/
34 #include "dti.h" /* functionality of the dti library */
35 #include "aci_cmh.h"
36 #ifdef GPRS
37 #include "gaci_cmh.h"
38 #endif
39 #include "ati_cmd.h"
40 #include "psa.h"
41 #include "cmh.h"
42 #include "cmh_dti.h"
43 #include "dti_conn_mng.h"
44 #include "dti_cntrl_mng.h"
45
46 /*==== CONSTANTS ==================================================*/
47
48 /*==== EXPORT =====================================================*/
49
50 /*==== VARIABLES ==================================================*/
51
52 /*==== FUNCTIONS ==================================================*/
53
54 /*
55 * for the device names see "AT commands for Packet IO.doc"
56 * a device name has (almost) nothing to do with entity names defined in custom.h !
57 */
58 LOCAL T_DTI_ENTITY_ID map_name_2_id (char *dev_name)
59 {
60 if ((strcmp (dev_name,"UART")) EQ 0)
61 {
62 return (DTI_ENTITY_UART);
63 }
64 else if ((strcmp (dev_name,"RIV")) EQ 0)
65 {
66 return (DTI_ENTITY_AAA);
67 }
68 else if ((strcmp (dev_name,"PSI")) EQ 0)
69 {
70 return (DTI_ENTITY_PSI);
71 }
72 #ifdef GPRS
73 else if ((strcmp (dev_name,"PKTIO")) EQ 0)
74 {
75 return (DTI_ENTITY_PKTIO);
76 }
77 #endif
78 else
79 {
80 TRACE_EVENT_P1 ("sAT_PercentDATA(): non valid device name %s", dev_name);
81 return (DTI_ENTITY_INVALID);
82 }
83 }
84
85
86 /*
87 +-------------------------------------------------------------------+
88 | PROJECT : GPRS (8441) MODULE : CMH_DTI |
89 | STATE : finished ROUTINE : sAT_PercentDATA |
90 +-------------------------------------------------------------------+
91
92 PURPOSE : set data flow, means to split the data channel (destination)
93 from the AT cmd channel (source)
94 */
95 GLOBAL T_ACI_RETURN sAT_PercentDATA (T_ACI_CMD_SRC srcId,
96 UBYTE redir_mode, /* delete,once,permanent */
97 CHAR *des_devname,
98 UBYTE des_devno,
99 UBYTE des_subno,
100 CHAR *dev_cap,
101 CHAR *src_devname,
102 UBYTE src_devno,
103 UBYTE src_subno,
104 UBYTE pdp_cid)
105 {
106 const CHAR *del = ",";
107 CHAR *s = NULL;
108 UBYTE capability = 0x00; /* DTI_CPBLTY_NO */
109 BOOL rv = FALSE;
110 T_ACI_REDIR_MODE mode = (T_ACI_REDIR_MODE)redir_mode;
111 T_DTI_ENTITY_ID des_dev_id = DTI_ENTITY_INVALID;
112 T_DTI_ENTITY_ID src_dev_id = DTI_ENTITY_INVALID;
113
114 /* for tracing of establishing of CMD channels for dual port version */
115 #ifdef RMV_15_04_03
116 extern CHAR gob_tst_buf[];
117 sprintf(gob_tst_buf+strlen(gob_tst_buf), "spd ");
118 #endif
119
120 TRACE_FUNCTION ("sAT_PercentDATA ()");
121
122 for (s = strtok(dev_cap, del); s; s = strtok(NULL, del))
123 {
124 if ((strcmp (s,"CMD")) EQ 0)
125 {
126 capability = capability | 0x01; /* DTI_CPBLTY_CMD */
127 }
128 else if ((strcmp (s,"PKT")) EQ 0)
129 {
130 capability = capability | 0x02; /* DTI_CPBLTY_PKT */
131 }
132 else if ((strcmp (s,"SER")) EQ 0)
133 {
134 capability = capability | 0x04; /* DTI_CPBLTY_SER */
135 }
136 else
137 {
138 TRACE_EVENT_P1 ("sAT_PercentDATA(): non valid capability %s",s);
139 return (AT_FAIL);
140 }
141 }
142
143 #ifdef GPRS
144 if (pdp_cid > PDP_CONTEXT_CID_MAX )
145 {
146 TRACE_EVENT_P1 ("sAT_PercentDATA(): non valid cid %d", pdp_cid);
147 return (AT_FAIL);
148 }
149 #else
150 if (pdp_cid > 0)
151 {
152 TRACE_EVENT_P1 ("sAT_PercentDATA(): for GSM cid must be 0, but is %d", pdp_cid);
153 return (AT_FAIL);
154 }
155 #endif
156
157 if (mode > REDIR_ALWAYS)
158 {
159 TRACE_EVENT_P1 ("sAT_PercentDATA(): non valid redirection mode %d", mode);
160 return (AT_FAIL);
161 }
162
163 des_dev_id = map_name_2_id (des_devname);
164
165 if ((des_dev_id NEQ DTI_ENTITY_UART)
166 AND (des_dev_id NEQ DTI_ENTITY_PSI)
167 #ifdef GPRS
168 AND (des_dev_id NEQ DTI_ENTITY_PKTIO)
169 #endif
170 AND (des_dev_id NEQ DTI_ENTITY_AAA))
171 {
172 TRACE_EVENT_P1 ("sAT_PercentDATA(): non valid destination device name %s",des_devname);
173 return (AT_FAIL);
174 }
175
176 if (strlen (src_devname))
177 {
178 /*
179 * special case, where three different devices are involved
180 * a device with the srcId (has an AT cmd channel)
181 * wants to redirect a second device (src_dev) to a third device (des_dev) at data transmission
182 */
183 src_dev_id = map_name_2_id (src_devname);
184
185 if ((src_dev_id NEQ DTI_ENTITY_INVALID)
186 AND (src_dev_id EQ des_dev_id)
187 AND (src_devno EQ des_devno)
188 AND (src_subno EQ des_subno))
189 {
190 TRACE_EVENT_P1 ("sAT_PercentDATA(): non valid source device name %s",src_devname);
191 return (AT_FAIL);
192 }
193
194 rv = dti_cntrl_set_redirect_from_device ((UBYTE)mode,
195 des_dev_id,
196 des_devno,
197 des_subno,
198 src_dev_id,
199 src_devno,
200 src_subno,
201 capability,
202 pdp_cid);
203 }
204 else
205 {
206 /*
207 * device with the srcId (AT cmd channel) itself wants to be redirected for data transmission
208 */
209 rv = dti_cntrl_set_redirect_from_src ((UBYTE)srcId,
210 (UBYTE)mode,
211 des_dev_id,
212 des_devno,
213 des_subno,
214 capability,
215 pdp_cid);
216 }
217
218
219 if (rv EQ TRUE)
220 {
221 return (AT_CMPL);
222 }
223 else
224 {
225 return (AT_FAIL);
226 }
227 }
228
229
230 /*
231 +-------------------------------------------------------------------+
232 | PROJECT : GPRS (8441) MODULE : CMH_DTI |
233 | STATE : finished ROUTINE : dinf_assign |
234 +-------------------------------------------------------------------+
235
236 PURPOSE : help function for qAT_PercentDATA
237
238 */
239 LOCAL void percentDATA_assign (UBYTE* mode,
240 UBYTE *cid,
241 T_DINF_PARAM *des_param,
242 T_DTI_CNTRL *tmp_param)
243
244 {
245 des_param->dev_id = tmp_param->dev_id;
246 des_param->dev_no = tmp_param->dev_no;
247 des_param->sub_no = tmp_param->sub_no;
248 des_param->capability = tmp_param->redirect_info.info.capability;
249 des_param->driver_id = tmp_param->driver_id;
250 des_param->dio_ctrl_id = tmp_param->dio_ctrl_id;
251
252 *cid = tmp_param->redirect_info.info.cid;
253 *mode = tmp_param->redirect_info.info.mode;
254 }
255
256
257 /*
258 +-------------------------------------------------------------------+
259 | PROJECT : GPRS (8441) MODULE : CMH_DTI |
260 | STATE : finished ROUTINE : qAT_PercentDATA |
261 +-------------------------------------------------------------------+
262
263 PURPOSE : query data flow
264
265 */
266 GLOBAL T_ACI_RETURN qAT_PercentDATA (T_ACI_CMD_SRC srcId,
267 UBYTE *mode,
268 UBYTE *cid,
269 T_DINF_PARAM *des_param,
270 T_DINF_PARAM *src_param)
271 {
272 static BOOL first_query = TRUE;
273
274 T_DTI_CNTRL tmp_param; /* the DTI Controller will put all neccessarly pieces of information in this structure */
275
276 TRACE_FUNCTION ("qAT_PercentDATA ()");
277
278 if (dti_cntrl_get_info_from_src_id ((UBYTE)srcId, &tmp_param))
279 {
280 /*
281 * at first save the parameter of the source, because we use tmp_param for the destination as well
282 */
283 src_param->dev_id = tmp_param.dev_id;
284 src_param->dev_no = tmp_param.dev_no;
285 src_param->sub_no = tmp_param.sub_no;
286
287 src_param-> driver_id = tmp_param. driver_id;
288 src_param-> dio_ctrl_id = tmp_param. dio_ctrl_id;
289
290 if (first_query)
291 {
292 if (tmp_param.redirect_info.info.direction EQ DTI_DIRECTION_NOTPRESENT)
293 {
294 first_query = TRUE; /* reset for later new query */
295 des_param->dev_id = NOT_PRESENT_8BIT; /* to indicate no redirection at all */
296 return (AT_FAIL); /* no error, but there is no redirection at all */
297 }
298 first_query = FALSE;
299 /*
300 * the very first query, start with redirection we got from dti_cntrl_get_info_from_src_id()
301 */
302 if (dti_cntrl_get_first_redirection ((UBYTE)srcId, tmp_param.redirect_info.info.capability, &tmp_param))
303 {
304 percentDATA_assign (mode, cid, des_param, &tmp_param);
305 return (AT_CMPL);
306 }
307 }
308 else
309 {
310 if (dti_cntrl_get_next_redirection ((UBYTE)srcId, *cid, src_param->capability, &tmp_param))
311 {
312 percentDATA_assign (mode, cid, des_param, &tmp_param);
313 return (AT_CMPL);
314 }
315 else
316 {
317 first_query = TRUE; /* reset for later new query */
318 des_param->capability = DEV_CPBLTY_NONE; /* sentinel */
319 return (AT_FAIL); /* no error, but there is no further redirection */
320 }
321 }
322 }
323 else
324 {
325 TRACE_EVENT_P1("[ERR] sAT_PercentDINF(): no info to srcId %d !", srcId);
326 ACI_ERR_DESC (ACI_ERR_CLASS_Ext, EXT_ERR_Parameter);
327 return (AT_FAIL);
328 }
329 TRACE_EVENT_P1("[ERR] sAT_PercentDINF(): Unknown", srcId);
330 ACI_ERR_DESC (ACI_ERR_CLASS_Ext, EXT_ERR_Unknown);
331 return (AT_FAIL);
332
333 }
334
335
336 /*
337 +-------------------------------------------------------------------+
338 | PROJECT : GPRS (8441) MODULE : CMH_DTI |
339 | STATE : finished ROUTINE : dinf_assign |
340 +-------------------------------------------------------------------+
341
342 PURPOSE : help function for sAT_PercentDINF
343
344 */
345 LOCAL void dinf_assign (T_DINF_PARAM *device_param, T_DTI_CNTRL *tmp_param)
346 {
347 device_param->dev_id = tmp_param->dev_id;
348 device_param->dev_no = tmp_param->dev_no;
349 device_param->sub_no = tmp_param->sub_no;
350 device_param->capability = tmp_param->capability;
351 device_param->cur_cap = tmp_param->cur_cap;
352 device_param->src_id = tmp_param->src_id;
353 device_param->driver_id = tmp_param->driver_id;
354 device_param->dio_ctrl_id = tmp_param->dio_ctrl_id;
355 }
356
357 /*
358 +-------------------------------------------------------------------+
359 | PROJECT : GPRS (8441) MODULE : CMH_DTI |
360 | STATE : finished ROUTINE : sAT_PercentDINF |
361 +-------------------------------------------------------------------+
362
363 PURPOSE : list all available data and ATI channels and their capabilities
364
365 */
366
367 GLOBAL T_ACI_RETURN sAT_PercentDINF( T_ACI_CMD_SRC srcId, /* UBYTE src_id passed by setatPercentDINF ! */
368 UBYTE mode,
369 T_DINF_PARAM *device_param)
370 {
371 static BOOL first_device = TRUE;
372 T_DTI_CNTRL tmp_param;
373
374 TRACE_FUNCTION ("sAT_PercentDINF()");
375
376 switch (mode)
377 {
378 case (SHOW_CURR_CHAN_INF):
379 {
380 if (dti_cntrl_get_info_from_src_id ((UBYTE)srcId, &tmp_param))
381 {
382 dinf_assign (device_param, &tmp_param);
383 return (AT_CMPL);
384 }
385 else
386 {
387 TRACE_EVENT_P1("[ERR] sAT_PercentDINF(): no info to srcId %d !", srcId);
388 break;
389 }
390 }
391 case (SHOW_ALL_CHAN_INF):
392 {
393 if (first_device)
394 {
395 first_device = FALSE;
396
397 if (dti_cntrl_get_first_device (&tmp_param))
398 {
399 dinf_assign (device_param, &tmp_param);
400 return (AT_CMPL);
401 }
402 else
403 {
404 TRACE_EVENT("[ERR] sAT_PercentDINF(): there is no device listed at all, so watch dti_cntrl_list !");
405 break;
406 }
407 }
408 else
409 {
410 if (dti_cntrl_get_next_device (&tmp_param))
411 {
412 dinf_assign (device_param, &tmp_param);
413 return (AT_CMPL);
414 }
415 else
416 {
417 first_device = TRUE; /* important to reset for a later new AT%DINF */
418
419 device_param->capability = DEV_CPBLTY_NONE; /* this is the sentinel, that there are no further devices */
420 return (AT_FAIL); /* it is not an error, but the end of AT%DINF */
421 }
422 }
423 }
424 default:
425 {
426 TRACE_EVENT("[ERR] sAT_PercentDINF(): unknown mode");
427 break;
428 }
429 }
430
431 ACI_ERR_DESC (ACI_ERR_CLASS_Ext, EXT_ERR_Parameter);
432 return (AT_FAIL);
433 }
434
435
436
437 #endif /* DTI */
438
439 /*==== EOF ========================================================*/