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