FreeCalypso > hg > leo2moko-debug
comparison g23m/condat/ms/src/aci/cmh_dti.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 | 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 > MAX_CID) | |
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 | |
245 *cid = tmp_param->redirect_info.info.cid; | |
246 *mode = tmp_param->redirect_info.info.mode; | |
247 } | |
248 | |
249 | |
250 /* | |
251 +-------------------------------------------------------------------+ | |
252 | PROJECT : GPRS (8441) MODULE : CMH_DTI | | |
253 | STATE : finished ROUTINE : qAT_PercentDATA | | |
254 +-------------------------------------------------------------------+ | |
255 | |
256 PURPOSE : query data flow | |
257 | |
258 */ | |
259 GLOBAL T_ACI_RETURN qAT_PercentDATA (T_ACI_CMD_SRC srcId, | |
260 UBYTE *mode, | |
261 UBYTE *cid, | |
262 T_DINF_PARAM *des_param, | |
263 T_DINF_PARAM *src_param) | |
264 { | |
265 static BOOL first_query = TRUE; | |
266 | |
267 T_DTI_CNTRL tmp_param; /* the DTI Controller will put all neccessarly pieces of information in this structure */ | |
268 | |
269 TRACE_FUNCTION ("qAT_PercentDATA ()"); | |
270 | |
271 if (dti_cntrl_get_info_from_src_id ((UBYTE)srcId, &tmp_param)) | |
272 { | |
273 /* | |
274 * at first save the parameter of the source, because we use tmp_param for the destination as well | |
275 */ | |
276 src_param->dev_id = tmp_param.dev_id; | |
277 src_param->dev_no = tmp_param.dev_no; | |
278 src_param->sub_no = tmp_param.sub_no; | |
279 | |
280 if (first_query) | |
281 { | |
282 if (tmp_param.redirect_info.info.direction EQ DTI_DIRECTION_NOTPRESENT) | |
283 { | |
284 first_query = TRUE; /* reset for later new query */ | |
285 des_param->dev_id = NOT_PRESENT_8BIT; /* to indicate no redirection at all */ | |
286 return (AT_FAIL); /* no error, but there is no redirection at all */ | |
287 } | |
288 first_query = FALSE; | |
289 /* | |
290 * the very first query, start with redirection we got from dti_cntrl_get_info_from_src_id() | |
291 */ | |
292 if (dti_cntrl_get_first_redirection ((UBYTE)srcId, tmp_param.redirect_info.info.capability, &tmp_param)) | |
293 { | |
294 percentDATA_assign (mode, cid, des_param, &tmp_param); | |
295 return (AT_CMPL); | |
296 } | |
297 } | |
298 else | |
299 { | |
300 if (dti_cntrl_get_next_redirection ((UBYTE)srcId, *cid, src_param->capability, &tmp_param)) | |
301 { | |
302 percentDATA_assign (mode, cid, des_param, &tmp_param); | |
303 return (AT_CMPL); | |
304 } | |
305 else | |
306 { | |
307 first_query = TRUE; /* reset for later new query */ | |
308 des_param->capability = DEV_CPBLTY_NONE; /* sentinel */ | |
309 return (AT_FAIL); /* no error, but there is no further redirection */ | |
310 } | |
311 } | |
312 } | |
313 else | |
314 { | |
315 TRACE_EVENT_P1("[ERR] sAT_PercentDINF(): no info to srcId %d !", srcId); | |
316 ACI_ERR_DESC (ACI_ERR_CLASS_Ext, EXT_ERR_Parameter); | |
317 return (AT_FAIL); | |
318 } | |
319 TRACE_EVENT_P1("[ERR] sAT_PercentDINF(): Unknown", srcId); | |
320 ACI_ERR_DESC (ACI_ERR_CLASS_Ext, EXT_ERR_Unknown); | |
321 return (AT_FAIL); | |
322 | |
323 } | |
324 | |
325 | |
326 /* | |
327 +-------------------------------------------------------------------+ | |
328 | PROJECT : GPRS (8441) MODULE : CMH_DTI | | |
329 | STATE : finished ROUTINE : dinf_assign | | |
330 +-------------------------------------------------------------------+ | |
331 | |
332 PURPOSE : help function for sAT_PercentDINF | |
333 | |
334 */ | |
335 LOCAL void dinf_assign (T_DINF_PARAM *device_param, T_DTI_CNTRL *tmp_param) | |
336 { | |
337 device_param->dev_id = tmp_param->dev_id; | |
338 device_param->dev_no = tmp_param->dev_no; | |
339 device_param->sub_no = tmp_param->sub_no; | |
340 device_param->capability = tmp_param->capability; | |
341 device_param->cur_cap = tmp_param->cur_cap; | |
342 device_param->src_id = tmp_param->src_id; | |
343 } | |
344 | |
345 /* | |
346 +-------------------------------------------------------------------+ | |
347 | PROJECT : GPRS (8441) MODULE : CMH_DTI | | |
348 | STATE : finished ROUTINE : sAT_PercentDINF | | |
349 +-------------------------------------------------------------------+ | |
350 | |
351 PURPOSE : list all available data and ATI channels and their capabilities | |
352 | |
353 */ | |
354 | |
355 GLOBAL T_ACI_RETURN sAT_PercentDINF( T_ACI_CMD_SRC srcId, /* UBYTE src_id passed by setatPercentDINF ! */ | |
356 UBYTE mode, | |
357 T_DINF_PARAM *device_param) | |
358 { | |
359 static BOOL first_device = TRUE; | |
360 T_DTI_CNTRL tmp_param; | |
361 | |
362 TRACE_FUNCTION ("sAT_PercentDINF()"); | |
363 | |
364 switch (mode) | |
365 { | |
366 case (SHOW_CURR_CHAN_INF): | |
367 { | |
368 if (dti_cntrl_get_info_from_src_id ((UBYTE)srcId, &tmp_param)) | |
369 { | |
370 dinf_assign (device_param, &tmp_param); | |
371 return (AT_CMPL); | |
372 } | |
373 else | |
374 { | |
375 TRACE_EVENT_P1("[ERR] sAT_PercentDINF(): no info to srcId %d !", srcId); | |
376 break; | |
377 } | |
378 } | |
379 case (SHOW_ALL_CHAN_INF): | |
380 { | |
381 if (first_device) | |
382 { | |
383 first_device = FALSE; | |
384 | |
385 if (dti_cntrl_get_first_device (&tmp_param)) | |
386 { | |
387 dinf_assign (device_param, &tmp_param); | |
388 return (AT_CMPL); | |
389 } | |
390 else | |
391 { | |
392 TRACE_EVENT("[ERR] sAT_PercentDINF(): there is no device listed at all, so watch dti_cntrl_list !"); | |
393 break; | |
394 } | |
395 } | |
396 else | |
397 { | |
398 if (dti_cntrl_get_next_device (&tmp_param)) | |
399 { | |
400 dinf_assign (device_param, &tmp_param); | |
401 return (AT_CMPL); | |
402 } | |
403 else | |
404 { | |
405 first_device = TRUE; /* important to reset for a later new AT%DINF */ | |
406 | |
407 device_param->capability = DEV_CPBLTY_NONE; /* this is the sentinel, that there are no further devices */ | |
408 return (AT_FAIL); /* it is not an error, but the end of AT%DINF */ | |
409 } | |
410 } | |
411 } | |
412 default: | |
413 { | |
414 TRACE_EVENT("[ERR] sAT_PercentDINF(): unknown mode"); | |
415 break; | |
416 } | |
417 } | |
418 | |
419 ACI_ERR_DESC (ACI_ERR_CLASS_Ext, EXT_ERR_Parameter); | |
420 return (AT_FAIL); | |
421 } | |
422 | |
423 | |
424 | |
425 #endif /* DTI */ | |
426 | |
427 /*==== EOF ========================================================*/ |