FreeCalypso > hg > freecalypso-citrine
comparison g23m-aci/aci/dti_cntrl_mng.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 | Project : ... | |
4 | Modul : dti_cntrl_mng.c | |
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 modul ... | |
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 DTI_CNTRL_MNG_C | |
29 #define DTI_CNTRL_MNG_C | |
30 #endif | |
31 | |
32 #ifdef MFW | |
33 #define ENTITY_MFW | |
34 #else | |
35 #ifdef SMI | |
36 #define ENTITY_SMI | |
37 #else | |
38 #define ENTITY_ACI | |
39 #endif | |
40 #endif | |
41 | |
42 #define ACI_MEMBER | |
43 | |
44 #include "aci_all.h" | |
45 | |
46 #include "dti.h" /* functionality of the dti library */ | |
47 #include "aci.h" | |
48 #include "aci_cmh.h" | |
49 #include "ati_cmd.h" | |
50 #include "aci_io.h" | |
51 | |
52 #include "aci_cmh.h" | |
53 #include "aci_mem.h" | |
54 #include "aci_lst.h" | |
55 | |
56 #include "dti_conn_mng.h" | |
57 #include "cmh_dti.h" | |
58 | |
59 #ifdef FAX_AND_DATA | |
60 #include "aci_fd.h" | |
61 #include "psa.h" | |
62 #include "psa_l2r.h" | |
63 #include "cmh.h" | |
64 #include "cmh_ra.h" | |
65 #include "cmh_l2r.h" | |
66 | |
67 #ifdef FF_FAX | |
68 #include "psa_t30.h" | |
69 #include "psa_tra.h" | |
70 #endif | |
71 | |
72 #else | |
73 | |
74 #include "psa.h" | |
75 #include "cmh.h" | |
76 | |
77 #endif /* #ifdef FAX_AND_DATA */ | |
78 | |
79 #include "psa_aaa.h" | |
80 | |
81 #if defined (GPRS) AND defined (UART) | |
82 #include "gaci.h" | |
83 #include "gaci_cmh.h" | |
84 #include "pcm.h" | |
85 #include "psa_gmm.h" | |
86 #include "cmh_gmm.h" | |
87 #include "psa_sm.h" | |
88 #include "cmh_sm.h" | |
89 #include "psa_gppp.h" | |
90 #include "cmh_gppp.h" | |
91 #ifdef FF_PKTIO | |
92 #include "psa_pktio.h" | |
93 #endif | |
94 #include "psa_upm.h" | |
95 #include "psa_snd.h" | |
96 #endif /* GPRS */ | |
97 | |
98 #if defined (FF_WAP) AND defined (GPRS) || defined (FF_SAT_E) | |
99 #include "gaci.h" | |
100 #include "gaci_cmh.h" | |
101 #include "psa_sm.h" | |
102 #include "cmh_sm.h" | |
103 #endif | |
104 | |
105 #if defined (FF_WAP) || defined (FF_PPP) || defined (FF_GPF_TCPIP) || defined (FF_SAT_E) | |
106 #include "psa_ppp_w.h" | |
107 #include "wap_aci.h" | |
108 #endif /* WAP or FF_PPP */ | |
109 | |
110 #ifdef UART | |
111 #include "dti_cntrl_mng.h" | |
112 #include "psa_uart.h" | |
113 #include "ati_src_uart.h" | |
114 #endif | |
115 #ifdef FF_PSI | |
116 #include "psa_psi.h" | |
117 #endif | |
118 #include "sap_dti.h" | |
119 | |
120 #ifdef SIM_TOOLKIT | |
121 #include "psa.h" | |
122 #include "psa_sim.h" | |
123 #endif | |
124 | |
125 extern void psaTCPIP_Dti_Req(T_DTI_CONN_LINK_ID dti_id, | |
126 UBYTE peer_to_connect_to, UBYTE dti_conn); | |
127 /* | |
128 * list for devices maintained by DTI Control Manager | |
129 */ | |
130 LOCAL T_ACI_LIST *dti_cntrl_list = NULL; | |
131 /* static pointer to manage output of dti_cntrl_list elements */ | |
132 static const T_ACI_LIST *dti_cntrl_dev_ptr = NULL; | |
133 /* | |
134 * a customer can install up to 3 own entities involved in data transmission | |
135 * every customer entity has its own call back function, noted in this array | |
136 */ | |
137 LOCAL T_DTI_CNTRL_REGISTERED_EXT_CB reg_ext_cb[DTI_MAX_EXT_CB] = | |
138 { | |
139 {DTI_ENTITY_INVALID, NULL}, | |
140 {DTI_ENTITY_INVALID, NULL}, | |
141 {DTI_ENTITY_INVALID, NULL} | |
142 }; | |
143 | |
144 | |
145 /* | |
146 * reuse of the global variable g_cur_cap due to the fact that the | |
147 * function dti_cntrl_est_dpath_indirect() is (always) called with the | |
148 * SPLIT mode, which means that there is the calling of | |
149 * dti_cntrl_entity_disconnected() which causes to reset the current | |
150 * capability and then there is the calling of dti_cntrl_entity_connected() | |
151 * and here we need the capability given in dti_cntrl_est_dpath_indirect() | |
152 */ | |
153 UBYTE g_cur_cap; | |
154 | |
155 /* bit set for DTI ID which should be reconnected to ACI */ | |
156 ULONG dti_cntrl_reconnect_to_aci; | |
157 | |
158 /*********************** LOCAL FUNCTIONS *****************************/ | |
159 | |
160 /* | |
161 +--------------------------------------------------------------------+ | |
162 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
163 | STATE : code ROUTINE : dti_cntrl_search_dev_id | | |
164 +--------------------------------------------------------------------+ | |
165 | |
166 PURPOSE : help function for | |
167 find_element_by_tupel (dti_cntrl_list, dev_id, dev_no, sub_no, dti_cntrl_search_dev_id); | |
168 */ | |
169 LOCAL BOOL dti_cntrl_search_dev_id (T_DTI_ENTITY_ID dev_id, UBYTE dev_no, UBYTE sub_no, void *elem) | |
170 { | |
171 T_DTI_CNTRL *compared = (T_DTI_CNTRL *)elem; | |
172 | |
173 if (compared NEQ NULL) | |
174 if (compared->dev_id EQ dev_id) | |
175 if (compared->dev_no EQ dev_no) | |
176 if (compared->sub_no EQ sub_no | |
177 #ifdef _SIMULATION_ | |
178 | |
179 OR 0 EQ sub_no AND 255 EQ compared->sub_no | |
180 | |
181 #endif | |
182 ) | |
183 return (TRUE); | |
184 return (FALSE); | |
185 } | |
186 | |
187 /* | |
188 +--------------------------------------------------------------------+ | |
189 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
190 | STATE : code ROUTINE : find_element_by_tupel | | |
191 +--------------------------------------------------------------------+ | |
192 | |
193 PURPOSE : find element in dti_cntrl_list | |
194 */ | |
195 typedef BOOL T_LIST_HELP_FCT (T_DTI_ENTITY_ID criterium1, UBYTE criterium2, UBYTE criterium3, void *elem); | |
196 | |
197 LOCAL void *find_element_by_tupel (T_ACI_LIST *search_list, | |
198 T_DTI_ENTITY_ID criterium1, | |
199 UBYTE criterium2, | |
200 UBYTE criterium3, | |
201 T_LIST_HELP_FCT test_criterium) | |
202 { | |
203 T_ACI_LIST *current = NULL; | |
204 | |
205 if ((search_list EQ NULL) OR (search_list->msg EQ NULL)) | |
206 { | |
207 return (NULL); | |
208 } | |
209 | |
210 current = search_list; | |
211 | |
212 do | |
213 { | |
214 if (current->msg NEQ NULL) | |
215 { | |
216 if (test_criterium (criterium1, criterium2, criterium3, current->msg)) | |
217 { | |
218 return (current->msg); | |
219 } | |
220 else | |
221 { | |
222 current = current->next; | |
223 } | |
224 } | |
225 }while (current NEQ NULL); | |
226 | |
227 return (NULL); | |
228 } | |
229 | |
230 /* | |
231 +--------------------------------------------------------------------+ | |
232 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
233 | STATE : code ROUTINE : dti_cntrl_call_reg_fct | | |
234 +--------------------------------------------------------------------+ | |
235 | |
236 PURPOSE : this function is called by dti_cntrl_maintain_entity(), | |
237 which is a call back function used by the DTI Connection | |
238 Manager, in such a case, where a customer installed its | |
239 own entity involved during data transmission | |
240 */ | |
241 LOCAL BOOL dti_cntrl_call_reg_fct( T_DTI_ENTITY_ID entity_id, | |
242 T_DTI_CONN_LINK_ID link_id, | |
243 T_DTI_ENTITY_ID peer_entity_id, | |
244 UBYTE dti_conn ) | |
245 { | |
246 UBYTE i = 0; | |
247 | |
248 TRACE_FUNCTION("dti_cntrl_call_reg_fct()"); | |
249 | |
250 for (i=0; i<DTI_MAX_EXT_CB; ++i) | |
251 { | |
252 if (reg_ext_cb[i].ent_id EQ entity_id) | |
253 { | |
254 if (reg_ext_cb[i].fct) | |
255 { | |
256 return (reg_ext_cb[i].fct(link_id, peer_entity_id, dti_conn)); | |
257 } | |
258 } | |
259 } | |
260 return (FALSE); | |
261 } | |
262 | |
263 /* | |
264 +------------------------------------------------------------------------------+ | |
265 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
266 | STATE : code ROUTINE : dti_cntrl_set_redirection | | |
267 +------------------------------------------------------------------------------+ | |
268 | |
269 PURPOSE : sub function of dti_cntrl_set_redirect_from_src and | |
270 dti_cntrl_set_redirect_from_device | |
271 */ | |
272 LOCAL BOOL dti_cntrl_set_redirection (T_DTI_CNTRL *dti_cntrl_dev, | |
273 T_DTI_CNTRL *indirect_dev, | |
274 UBYTE mode, | |
275 UBYTE capability, | |
276 UBYTE cid) | |
277 { | |
278 TRACE_FUNCTION("dti_cntrl_set_redirection()"); | |
279 | |
280 switch (capability) | |
281 { | |
282 case (DTI_CPBLTY_PKT): | |
283 { | |
284 if (mode EQ DTI_MODE_DELETE) | |
285 { | |
286 dti_cntrl_dev->redirect_info.tbl->pkt_redirect[cid].mode = DTI_MODE_NIL; | |
287 dti_cntrl_dev->redirect_info.tbl->pkt_redirect[cid].redirection = NULL; | |
288 } | |
289 else | |
290 { | |
291 dti_cntrl_dev->redirect_info.tbl->pkt_redirect[cid].mode = mode; | |
292 dti_cntrl_dev->redirect_info.tbl->pkt_redirect[cid].redirection = indirect_dev; | |
293 } | |
294 break; | |
295 } | |
296 case (DTI_CPBLTY_SER): | |
297 { | |
298 if (mode EQ DTI_MODE_DELETE) | |
299 { | |
300 dti_cntrl_dev->redirect_info.tbl->ser_redirect[cid].mode = DTI_MODE_NIL; | |
301 dti_cntrl_dev->redirect_info.tbl->ser_redirect[cid].redirection = NULL; | |
302 } | |
303 else | |
304 { | |
305 dti_cntrl_dev->redirect_info.tbl->ser_redirect[cid].mode = mode; | |
306 dti_cntrl_dev->redirect_info.tbl->ser_redirect[cid].redirection = indirect_dev; | |
307 } | |
308 break; | |
309 } | |
310 default: | |
311 { | |
312 TRACE_EVENT("given capability is not SER or PKT"); | |
313 return (FALSE); | |
314 } | |
315 } | |
316 return (TRUE); | |
317 } | |
318 | |
319 /* | |
320 +------------------------------------------------------------------------------+ | |
321 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
322 | STATE : code ROUTINE : dti_cntrl_get_redirection | | |
323 +------------------------------------------------------------------------------+ | |
324 | |
325 PURPOSE : sub function of dti_cntrl_get_first_redirection and | |
326 dti_cntrl_get_next_redirection | |
327 */ | |
328 LOCAL BOOL dti_cntrl_get_redirection (T_DTI_CNTRL *dti_cntrl_dev, | |
329 T_DTI_CNTRL *indirection, /* out parameter */ | |
330 UBYTE cid, | |
331 UBYTE capability) | |
332 { | |
333 UBYTE mode = DTI_MODE_NIL; /* remember temporary */ | |
334 | |
335 TRACE_FUNCTION("dti_cntrl_get_redirection()"); | |
336 | |
337 switch (capability) | |
338 { | |
339 case (DTI_CPBLTY_PKT): | |
340 { | |
341 for (cid += 1; cid<DTI_MAX_REDIRECTIONS; cid++) /* watch the start value */ | |
342 { | |
343 if (dti_cntrl_dev->redirect_info.tbl->pkt_redirect[cid].redirection) | |
344 { | |
345 mode = dti_cntrl_dev->redirect_info.tbl->pkt_redirect[cid].mode; | |
346 /* | |
347 * set the pointer to the redirected device for packet data transmission | |
348 */ | |
349 dti_cntrl_dev = dti_cntrl_dev->redirect_info.tbl->pkt_redirect[cid].redirection; | |
350 break; | |
351 } | |
352 } | |
353 break; | |
354 } | |
355 case (DTI_CPBLTY_SER): | |
356 { | |
357 for (cid += 1; cid<DTI_MAX_REDIRECTIONS; cid++) /* watch the start value */ | |
358 { | |
359 if (dti_cntrl_dev->redirect_info.tbl->ser_redirect[cid].redirection) | |
360 { | |
361 mode = dti_cntrl_dev->redirect_info.tbl->ser_redirect[cid].mode; | |
362 /* | |
363 * set the pointer to the redirected device for serial data transmission | |
364 */ | |
365 dti_cntrl_dev = dti_cntrl_dev->redirect_info.tbl->ser_redirect[cid].redirection; | |
366 break; | |
367 } | |
368 } | |
369 break; | |
370 } | |
371 default: | |
372 { | |
373 TRACE_EVENT("given capability is not SER or PKT"); | |
374 indirection = NULL; /* make it invalid */ | |
375 return (FALSE); | |
376 } | |
377 } | |
378 | |
379 if (cid >= DTI_MAX_REDIRECTIONS) | |
380 { | |
381 indirection = NULL; /* there is no further redirection */ | |
382 } | |
383 else | |
384 { | |
385 /* | |
386 * fill the out parameter | |
387 */ | |
388 indirection->dev_id = dti_cntrl_dev->dev_id; | |
389 indirection->dev_no = dti_cntrl_dev->dev_no; | |
390 indirection->sub_no = dti_cntrl_dev->sub_no; | |
391 indirection->capability = dti_cntrl_dev->capability; | |
392 indirection->src_id = dti_cntrl_dev->src_id; | |
393 indirection->dti_id = dti_cntrl_dev->dti_id; | |
394 indirection->port_number = dti_cntrl_dev->port_number; | |
395 indirection->cur_cap = dti_cntrl_dev->cur_cap; | |
396 indirection->driver_id = dti_cntrl_dev->driver_id; | |
397 indirection->dio_ctrl_id = dti_cntrl_dev->dio_ctrl_id; | |
398 /* | |
399 * ! important ! with >>DTI_DEV_I_AM_THE_ONE<< we indicate that the | |
400 * redirect_info is now _actually_ the info about this device | |
401 */ | |
402 indirection->redirect_info.info.cid = cid; | |
403 indirection->redirect_info.info.mode = mode; | |
404 indirection->redirect_info.info.capability = capability; | |
405 indirection->redirect_info.info.direction = DTI_DEV_I_AM_THE_ONE; | |
406 } | |
407 return (TRUE); | |
408 } | |
409 | |
410 /* | |
411 +------------------------------------------------------------------------------+ | |
412 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
413 | STATE : code ROUTINE : dti_cntrl_get_info | | |
414 +------------------------------------------------------------------------------+ | |
415 | |
416 PURPOSE : sub function of the three functions | |
417 dti_cntrl_get_info_from_src_id | |
418 dti_cntrl_get_info_from_dti_id | |
419 dti_cntrl_get_info_from_dev_id | |
420 */ | |
421 LOCAL BOOL dti_cntrl_get_info (T_DTI_CNTRL *info, /* out parameter */ | |
422 T_DTI_CNTRL *dti_cntrl_dev) | |
423 { | |
424 UBYTE i = 0; | |
425 | |
426 TRACE_FUNCTION("dti_cntrl_get_info()"); | |
427 | |
428 info->dev_id = dti_cntrl_dev->dev_id; | |
429 info->dev_no = dti_cntrl_dev->dev_no; | |
430 info->sub_no = dti_cntrl_dev->sub_no; | |
431 info->capability = dti_cntrl_dev->capability; | |
432 info->src_id = dti_cntrl_dev->src_id; | |
433 info->dti_id = dti_cntrl_dev->dti_id; | |
434 info->port_number = dti_cntrl_dev->port_number; | |
435 info->cur_cap = dti_cntrl_dev->cur_cap; | |
436 info->driver_id = dti_cntrl_dev->driver_id; | |
437 info->dio_ctrl_id = dti_cntrl_dev->dio_ctrl_id; | |
438 /* | |
439 * init a possible indirection info with default values ( all 0xFF ) | |
440 */ | |
441 info->redirect_info.info.cid = DTI_CID_NOTPRESENT; | |
442 info->redirect_info.info.mode = DTI_MODE_NIL; | |
443 info->redirect_info.info.capability = DTI_CPBLTY_NO; | |
444 info->redirect_info.info.direction = DTI_DIRECTION_NOTPRESENT; | |
445 /* | |
446 * search, whether there is a redirection, start with packet device | |
447 */ | |
448 for (i=0; i<DTI_MAX_REDIRECTIONS; i++) | |
449 { | |
450 if (dti_cntrl_dev->redirect_info.tbl->pkt_redirect[i].redirection) | |
451 { | |
452 break; | |
453 } | |
454 } | |
455 if (i < DTI_MAX_REDIRECTIONS) | |
456 { | |
457 info->redirect_info.info.cid = i; | |
458 info->redirect_info.info.mode = dti_cntrl_dev->redirect_info.tbl->pkt_redirect[i].mode; | |
459 info->redirect_info.info.capability = DTI_CPBLTY_PKT; | |
460 info->redirect_info.info.direction = DTI_DEV_IS_REDIRECTED; | |
461 } | |
462 /* | |
463 * there is no redirection to a packet device, so search for redirection to a serial device | |
464 */ | |
465 for (i=0; i<DTI_MAX_REDIRECTIONS; i++) | |
466 { | |
467 if (dti_cntrl_dev->redirect_info.tbl->ser_redirect[i].redirection) | |
468 { | |
469 break; | |
470 } | |
471 } | |
472 if (i < DTI_MAX_REDIRECTIONS) | |
473 { | |
474 info->redirect_info.info.cid = i; | |
475 info->redirect_info.info.mode = dti_cntrl_dev->redirect_info.tbl->ser_redirect[i].mode; | |
476 info->redirect_info.info.capability = DTI_CPBLTY_SER; | |
477 info->redirect_info.info.direction = DTI_DEV_IS_REDIRECTED; | |
478 } | |
479 return (TRUE); | |
480 } | |
481 | |
482 | |
483 /* | |
484 +------------------------------------------------------------------------------+ | |
485 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
486 | STATE : code ROUTINE : dti_cntrl_maintain_entity_connect | | |
487 +------------------------------------------------------------------------------+ | |
488 | |
489 PURPOSE : sub function of dti_cntrl_maintain_entity, called when the DTI | |
490 Connection Manager wants to connect entites for data transmission | |
491 | |
492 */ | |
493 LOCAL BOOL dti_cntrl_maintain_entity_connect ( T_DTI_CONN_LINK_ID link_id, | |
494 T_DTI_ENTITY_ID cur_ent_id, | |
495 T_DTI_ENTITY_ID peer_ent_id, | |
496 UBYTE dti_conn) | |
497 { | |
498 TRACE_FUNCTION("dti_cntrl_maintain_entity_connect()"); | |
499 | |
500 #ifdef FF_TCP_IP | |
501 /* If the peer entity is AAA, delay the connect request until AAA has | |
502 * responded to the AAA_DTI_IND. ati_src_riv_dti_rsp() calls | |
503 * dti_cntrl_connect_after_aaa_dti_rsp(), which in turn calls this function, | |
504 * on receiving the response. */ | |
505 { | |
506 if (peer_ent_id EQ DTI_ENTITY_AAA) | |
507 { | |
508 T_DTI_CNTRL *dti_cntrl_dev; /* Information about DTI link. */ | |
509 UBYTE dti_id ; /* DTI id of this connection. */ | |
510 | |
511 dti_id = EXTRACT_DTI_ID(link_id) ; | |
512 dti_cntrl_dev = (T_DTI_CNTRL *) find_element (dti_cntrl_list, dti_id, | |
513 dti_cntrl_search_dti_id) ; | |
514 if (!dti_cntrl_dev->had_aaa_dti_rsp) | |
515 { | |
516 dti_cntrl_dev->save_link_id = link_id ; | |
517 dti_cntrl_dev->save_cur_ent_id = cur_ent_id ; | |
518 dti_cntrl_dev->save_dti_conn = dti_conn ; | |
519 return TRUE ; | |
520 } | |
521 dti_cntrl_dev->had_aaa_dti_rsp = FALSE; | |
522 | |
523 } | |
524 } | |
525 #endif /* FF_TCP_IP */ | |
526 | |
527 switch ( cur_ent_id ) | |
528 { | |
529 case DTI_ENTITY_ACI: /* entity ACI */ | |
530 /* handle ACI as independent entity */ | |
531 psaACI_Dti_Req(link_id, peer_ent_id, ACI_CONNECT_DTI); | |
532 break; | |
533 | |
534 case DTI_ENTITY_UART: /* entity UART */ | |
535 psaUART_SetDTIReq (link_id, peer_ent_id); | |
536 break; | |
537 | |
538 #ifdef FF_TRACE_OVER_MTST | |
539 case DTI_ENTITY_MTST: /* for traces */ | |
540 psaMTST_Switch_Trace (link_id, peer_ent_id, TRUE); | |
541 break; | |
542 #endif | |
543 | |
544 #ifdef FAX_AND_DATA | |
545 case DTI_ENTITY_TRA: | |
546 psaTRA_Dti_Req( link_id, TRA_CONNECT_DTI, (UBYTE)peer_ent_id ); | |
547 break; | |
548 | |
549 case DTI_ENTITY_L2R: | |
550 psaL2R_Enable (link_id, (UBYTE)peer_ent_id); | |
551 break; | |
552 | |
553 #ifdef FF_FAX | |
554 case DTI_ENTITY_T30: | |
555 psaT30_Dti_Req( link_id, T30_CONNECT_DTI ); | |
556 break; | |
557 #endif | |
558 | |
559 #ifdef BT_ADAPTER | |
560 case DTI_ENTITY_BLUETOOTH: | |
561 psaBTI_Dti_Req( link_id, peer_ent_id, BTI_CONNECT_DTI ); | |
562 break; | |
563 #endif /* BT_ADAPTER */ | |
564 | |
565 #endif /* FAX_AND_DATA */ | |
566 | |
567 #ifdef GPRS | |
568 case DTI_ENTITY_PPPS: | |
569 psaGPPPS_Dti_Req(link_id, (UBYTE) peer_ent_id); /* rather use dti_id instead of link_id ???? */ | |
570 break; | |
571 #ifdef FF_PKTIO | |
572 case DTI_ENTITY_PKTIO: | |
573 psaPKT_Dti_Req((ULONG)link_id, (UBYTE)peer_ent_id, PKT_CONNECT_DTI); | |
574 break; | |
575 #endif /* FF_PKTIO */ | |
576 case DTI_ENTITY_SNDCP: | |
577 psa_sn_dti_req( link_id, peer_ent_id, NAS_CONNECT_DTI ); | |
578 break; | |
579 #endif /* GPRS */ | |
580 #ifdef FF_PSI | |
581 case DTI_ENTITY_PSI: | |
582 psaPSI_Dti_Req((ULONG)link_id, (UBYTE)peer_ent_id, PSI_CONNECT_DTI); | |
583 break; | |
584 #endif /*FF_PSI*/ | |
585 case DTI_ENTITY_NULL: | |
586 dti_cntrl_entity_connected (link_id, DTI_ENTITY_NULL, DTI_OK); | |
587 break; | |
588 | |
589 #if defined (FF_WAP) || defined (FF_PPP) || defined (FF_GPF_TCPIP) || defined (FF_SAT_E) | |
590 case DTI_ENTITY_PPPC: | |
591 psaPPP_Establish(link_id, (UBYTE) peer_ent_id); | |
592 break; | |
593 #endif /* WAP or FF_PPP or SAT E */ | |
594 #ifdef CO_UDP_IP | |
595 case DTI_ENTITY_IP: | |
596 psaIPA_Dti_Req(link_id, (UBYTE) peer_ent_id, IPA_CONNECT_DTI); | |
597 break; | |
598 | |
599 case DTI_ENTITY_UDP: | |
600 psaUDPA_Dti_Req(link_id, (UBYTE) peer_ent_id, UDPA_CONNECT_DTI); | |
601 break; | |
602 | |
603 #ifdef FF_WAP | |
604 case DTI_ENTITY_WAP: | |
605 psaWAP_Dti_Req(link_id, (UBYTE) peer_ent_id, WAP_CONNECT_DTI); | |
606 break; | |
607 #endif /* WAP */ | |
608 | |
609 #endif /* WAP || SAT E */ | |
610 | |
611 #ifdef FF_GPF_TCPIP | |
612 case DTI_ENTITY_TCPIP: | |
613 psaTCPIP_Dti_Req(link_id, (UBYTE) peer_ent_id, TCPIP_CONNECT_DTI); | |
614 break; | |
615 #endif | |
616 | |
617 #ifdef FF_TCP_IP | |
618 case DTI_ENTITY_AAA: /* entity AAA */ | |
619 psaAAA_dti_ind (link_id, peer_ent_id); | |
620 break; | |
621 #endif | |
622 | |
623 #ifdef FF_SAT_E | |
624 /* SAT class e */ | |
625 case DTI_ENTITY_SIM: | |
626 /* init connection SIM--PEER */ | |
627 /* open DTI connection */ | |
628 psaSIM_Dti_Req(link_id); | |
629 break; | |
630 #endif | |
631 | |
632 default: | |
633 /* search for registered connect function */ | |
634 return dti_cntrl_call_reg_fct(cur_ent_id, link_id, peer_ent_id, dti_conn); | |
635 } | |
636 return (TRUE); | |
637 } | |
638 | |
639 #ifdef FF_TCP_IP | |
640 EXTERN void dti_cntrl_connect_after_aaa_dti_rsp(UBYTE dti_id) | |
641 { | |
642 /* If the peer entity is AAA, the connect request has been delayed, until | |
643 * AAA has responded to the AAA_DTI_IND. ati_src_riv_dti_rsp() calls this | |
644 * function on receiving this response. */ | |
645 | |
646 T_DTI_CNTRL *dti_cntrl_dev ; /* Information about DTI link. */ | |
647 | |
648 TRACE_FUNCTION("dti_cntrl_connect_after_aaa_dti_rsp()"); | |
649 dti_cntrl_dev = (T_DTI_CNTRL *) find_element (dti_cntrl_list, dti_id, | |
650 dti_cntrl_search_dti_id) ; | |
651 dti_cntrl_dev->had_aaa_dti_rsp = TRUE ; | |
652 dti_cntrl_maintain_entity_connect(dti_cntrl_dev->save_link_id, | |
653 dti_cntrl_dev->save_cur_ent_id, | |
654 DTI_ENTITY_AAA, | |
655 dti_cntrl_dev->save_dti_conn) ; | |
656 } | |
657 #endif /* FF_TCP_IP */ | |
658 | |
659 /* | |
660 +---------------------------------------------------------------------------------+ | |
661 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
662 | STATE : code ROUTINE : dti_cntrl_maintain_entity_disconnect | | |
663 +---------------------------------------------------------------------------------+ | |
664 | |
665 PURPOSE : sub function of dti_cntrl_maintain_entity, called when the DTI | |
666 Connection Manager wants to disconnect entites after data transmission | |
667 */ | |
668 LOCAL BOOL dti_cntrl_maintain_entity_disconnect ( T_DTI_CONN_LINK_ID link_id, | |
669 T_DTI_ENTITY_ID cur_ent_id, | |
670 T_DTI_ENTITY_ID peer_ent_id, | |
671 UBYTE dti_conn) | |
672 { | |
673 TRACE_FUNCTION("dti_cntrl_maintain_entity_disconnect()"); | |
674 switch( cur_ent_id ) | |
675 { | |
676 case DTI_ENTITY_ACI: | |
677 psaACI_Dti_Req (link_id, peer_ent_id, ACI_DISCONNECT_DTI); | |
678 break; | |
679 | |
680 case DTI_ENTITY_UART: | |
681 /* for UART, we have to wait for UART_DTI_IND | |
682 * sent when UART recognizes it's dti connection has been | |
683 * closed down. | |
684 * It would be nice to just send UART_DTI_REQ | |
685 * here in order to make handling of the UART entity | |
686 * more similar to the other entities.. | |
687 */ | |
688 break; | |
689 | |
690 #ifdef FF_TRACE_OVER_MTST | |
691 case DTI_ENTITY_MTST: /* for traces */ | |
692 if (psaMTST_Switch_Trace (link_id, peer_ent_id, FALSE) EQ PEI_ERROR) | |
693 { | |
694 return (FALSE); | |
695 } | |
696 break; | |
697 #endif | |
698 | |
699 #ifdef FAX_AND_DATA | |
700 case DTI_ENTITY_TRA: | |
701 psaTRA_Dti_Req (link_id, TRA_DISCONNECT_DTI, (UBYTE)peer_ent_id); | |
702 break; | |
703 | |
704 #ifdef FF_FAX | |
705 case DTI_ENTITY_T30: | |
706 psaT30_Dti_Req (link_id, T30_DISCONNECT_DTI); | |
707 break; | |
708 #endif | |
709 | |
710 case DTI_ENTITY_L2R: | |
711 /* in the case of disconnecting L2R, | |
712 it has to be DEACTIVATED */ | |
713 psaL2R_Deactivate(); | |
714 break; | |
715 | |
716 #ifdef BT_ADAPTER | |
717 case DTI_ENTITY_BLUETOOTH: | |
718 psaBTI_Dti_Req(link_id, peer_ent_id, BTI_DISCONNECT_DTI); | |
719 break; | |
720 #endif /* BT_ADAPTER */ | |
721 | |
722 #endif /* FAX_AND_DATA */ | |
723 | |
724 #ifdef GPRS | |
725 case DTI_ENTITY_PPPS: | |
726 /* Do nothing. Termination of PPP is done by the CMH_SM or CMH_GPPP */ | |
727 break; | |
728 | |
729 case DTI_ENTITY_SNDCP: | |
730 psa_sn_dti_req( link_id, peer_ent_id, NAS_DISCONNECT_DTI ); | |
731 break; | |
732 #ifdef FF_PKTIO | |
733 case DTI_ENTITY_PKTIO: | |
734 psaPKT_Dti_Req((ULONG)link_id, (UBYTE)peer_ent_id, PKT_DISCONNECT_DTI); | |
735 break; | |
736 #endif /* FF_PKTIO */ | |
737 #endif /* GPRS */ | |
738 | |
739 #ifdef FF_PSI | |
740 case DTI_ENTITY_PSI: | |
741 psaPSI_Dti_Req((ULONG)link_id, (UBYTE)peer_ent_id, PSI_DISCONNECT_DTI); | |
742 break; | |
743 #endif /*FF_PSI*/ | |
744 | |
745 #ifdef CO_UDP_IP | |
746 case DTI_ENTITY_IP: | |
747 psaIPA_Dti_Req(link_id, (UBYTE)peer_ent_id, IPA_DISCONNECT_DTI); | |
748 break; | |
749 | |
750 case DTI_ENTITY_UDP: | |
751 /* for UDP, we have to wait for UDPA_DTI_IND(DISCONNECT) which is | |
752 * sent when UDP recognizes it's dti connection has been | |
753 * closed down | |
754 */ | |
755 break; | |
756 #endif /* CO_UDP_IP */ | |
757 | |
758 #ifdef FF_WAP | |
759 case DTI_ENTITY_WAP: | |
760 psaWAP_Dti_Req(link_id, (UBYTE) peer_ent_id, WAP_DISCONNECT_DTI); | |
761 break; | |
762 #endif /* WAP */ | |
763 | |
764 #ifdef FF_GPF_TCPIP | |
765 case DTI_ENTITY_TCPIP: | |
766 /* for TCP/IP, we have to wait for TCPIP_DTI_IND(DISCONNECT) which is | |
767 * sent when TCP/IP recognizes its DTI connection has been closed down */ | |
768 psaTCPIP_Dti_Req(link_id, (UBYTE) peer_ent_id, TCPIP_DISCONNECT_DTI); | |
769 break; | |
770 #endif /* FF_GPF_TCPIP */ | |
771 | |
772 #ifdef FF_TCP_IP | |
773 case DTI_ENTITY_AAA: /* entity AAA */ | |
774 psaAAA_disconnect_ind (link_id); | |
775 break; | |
776 #endif | |
777 #ifdef FF_PPP | |
778 case DTI_ENTITY_PPPC: | |
779 psaPPP_Terminate(UP); | |
780 break; | |
781 #endif | |
782 | |
783 #ifdef FF_SAT_E | |
784 /* SAT class e */ | |
785 case DTI_ENTITY_SIM: | |
786 psaSIM_Dti_Req(link_id); | |
787 break; | |
788 #endif | |
789 | |
790 default: | |
791 /* search for registered connect function */ | |
792 return dti_cntrl_call_reg_fct(cur_ent_id, link_id, peer_ent_id, dti_conn); | |
793 } | |
794 | |
795 return (TRUE); | |
796 } | |
797 | |
798 /* | |
799 +----------------------------------------------------------------------+ | |
800 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
801 | STATE : code ROUTINE : dti_cntrl_maintain_entity | | |
802 +----------------------------------------------------------------------+ | |
803 | |
804 PURPOSE : this function is used by the DTI Connection Manager as a | |
805 call back function for connecting/disconnecting. | |
806 The registeration of dti_cntrl_maintain_entity in the | |
807 DTI Connection Manager takes place with: | |
808 dti_conn_init (dti_cntrl_maintain_entity); | |
809 */ | |
810 LOCAL BOOL dti_cntrl_maintain_entity ( T_DTI_CONN_LINK_ID link_id, | |
811 T_DTI_ENTITY_ID cur_ent_id, | |
812 T_DTI_ENTITY_ID peer_ent_id, | |
813 UBYTE dti_conn) | |
814 { | |
815 TRACE_FUNCTION("dti_cntrl_maintain_entity()"); | |
816 | |
817 if (dti_conn EQ DTI_CONNECT) | |
818 { | |
819 return (dti_cntrl_maintain_entity_connect (link_id, cur_ent_id, peer_ent_id, dti_conn)); | |
820 } | |
821 else /* DTI_DISCONNECT */ | |
822 { | |
823 return (dti_cntrl_maintain_entity_disconnect (link_id, cur_ent_id, peer_ent_id, dti_conn)); | |
824 } | |
825 } | |
826 /********************** GLOBAL FUNCTIONS *****************************/ | |
827 | |
828 /* | |
829 +--------------------------------------------------------------------+ | |
830 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
831 | STATE : code ROUTINE : dti_cntrl_search_src_id | | |
832 +--------------------------------------------------------------------+ | |
833 | |
834 PURPOSE : help function for | |
835 find_element (dti_cntrl_list, dti_id, dti_cntrl_search_src_id); | |
836 */ | |
837 GLOBAL BOOL dti_cntrl_search_src_id (UBYTE src_id, void *elem) | |
838 { | |
839 T_DTI_CNTRL *compared = (T_DTI_CNTRL *)elem; | |
840 | |
841 if (compared NEQ NULL) | |
842 if (compared->src_id EQ src_id) | |
843 return (TRUE); | |
844 return (FALSE); | |
845 } | |
846 | |
847 /* | |
848 +--------------------------------------------------------------------+ | |
849 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
850 | STATE : code ROUTINE : dti_cntrl_search_dti_id | | |
851 +--------------------------------------------------------------------+ | |
852 | |
853 PURPOSE : help function for | |
854 find_element (dti_cntrl_list, dti_id, dti_cntrl_search_dti_id); | |
855 */ | |
856 GLOBAL BOOL dti_cntrl_search_dti_id (UBYTE dti_id, void *elem) | |
857 { | |
858 T_DTI_CNTRL *compared = (T_DTI_CNTRL *)elem; | |
859 | |
860 if (compared NEQ NULL) | |
861 if (compared->dti_id EQ dti_id) | |
862 return (TRUE); | |
863 return (FALSE); | |
864 } | |
865 | |
866 /* | |
867 +--------------------------------------------------------------------+ | |
868 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
869 | STATE : code ROUTINE : dti_cntrl_init | | |
870 +--------------------------------------------------------------------+ | |
871 | |
872 PURPOSE : create the global defined dti_cntrl_list and | |
873 register dti_cntrl_maintain_entity as call back | |
874 */ | |
875 GLOBAL void dti_cntrl_init (void) | |
876 { | |
877 UBYTE i; | |
878 | |
879 TRACE_FUNCTION("dti_cntrl_init()"); | |
880 | |
881 for (i=0; i<MAX_DTI_CONN_LINK_IDS; i++) | |
882 { | |
883 dti_aci_data_base[i].link_id = DTI_LINK_ID_NOTPRESENT; | |
884 dti_aci_data_base[i].dev_no1 = DTI_DEV_NO_NOTPRESENT; | |
885 dti_aci_data_base[i].dev_no2 = DTI_DEV_NO_NOTPRESENT; | |
886 dti_aci_data_base[i].ent_id1 = DTI_ENTITY_INVALID; | |
887 dti_aci_data_base[i].ent_id2 = DTI_ENTITY_INVALID; | |
888 dti_aci_data_base[i].sub_no1 = DTI_SUB_NO_NOTPRESENT; | |
889 dti_aci_data_base[i].sub_no2 = DTI_SUB_NO_NOTPRESENT; | |
890 } | |
891 | |
892 dti_cntrl_reconnect_to_aci = 0; | |
893 | |
894 dti_cntrl_list = new_list (); | |
895 | |
896 dti_conn_init (dti_cntrl_maintain_entity); | |
897 } | |
898 | |
899 /* | |
900 +--------------------------------------------------------------------+ | |
901 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
902 | STATE : code ROUTINE : dti_cntrl_new_dti | | |
903 +--------------------------------------------------------------------+ | |
904 | |
905 PURPOSE : | |
906 | |
907 */ | |
908 GLOBAL UBYTE dti_cntrl_new_dti (UBYTE dti_id) | |
909 { | |
910 | |
911 TRACE_FUNCTION("dti_cntrl_new_dti()"); | |
912 | |
913 /* call DTI connection manager function to get a DTI ID */ | |
914 if ((dti_id = dti_conn_new(dti_id)) EQ DTI_DTI_ID_NOTPRESENT) | |
915 { | |
916 TRACE_EVENT("couldn't create new dti_id"); | |
917 return (FALSE); | |
918 } | |
919 | |
920 return (dti_id); | |
921 } | |
922 | |
923 /* | |
924 +--------------------------------------------------------------------+ | |
925 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
926 | STATE : code ROUTINE : dti_cntrl_new_device | | |
927 +--------------------------------------------------------------------+ | |
928 | |
929 PURPOSE : a PSA wants to set up a device. | |
930 in case of ATI_RIV called this function, then port_num | |
931 is meaningful number, else port_num = NO_PORT_NUMBER. | |
932 we keep the port number here to frees ATI-RIV from | |
933 maintaining its own redundant list. | |
934 */ | |
935 GLOBAL BOOL dti_cntrl_new_device (UBYTE src_id, | |
936 UBYTE dev_id, | |
937 UBYTE dev_no, | |
938 UBYTE sub_no, | |
939 UBYTE port_num, | |
940 UBYTE capability, | |
941 UBYTE driver_id, | |
942 UBYTE dio_ctrl_id) | |
943 { | |
944 UBYTE dti_id = DTI_DTI_ID_NOTPRESENT; | |
945 T_DTI_CNTRL *dti_cntrl_dev = NULL; | |
946 USHORT i = 0; | |
947 | |
948 TRACE_FUNCTION("dti_cntrl_new_device()"); | |
949 | |
950 /* call DTI connection manager function to get a DTI ID */ | |
951 if ((dti_id = dti_conn_new(DTI_DTI_ID_NOTPRESENT)) EQ DTI_DTI_ID_NOTPRESENT) | |
952 { | |
953 TRACE_EVENT("couldn't create new dti_id"); | |
954 return (FALSE); | |
955 } | |
956 | |
957 ACI_MALLOC (dti_cntrl_dev, sizeof (T_DTI_CNTRL)); | |
958 ACI_MALLOC (dti_cntrl_dev->redirect_info.tbl, sizeof (T_DTI_CNTRL_REDIRECT_INTERN)); | |
959 | |
960 dti_cntrl_dev->dev_id = (T_DTI_ENTITY_ID)dev_id; | |
961 dti_cntrl_dev->dev_no = dev_no; | |
962 dti_cntrl_dev->sub_no = sub_no; /* multiplexed sub channels */ | |
963 dti_cntrl_dev->capability = capability; /* what the device is capable to */ | |
964 dti_cntrl_dev->src_id = src_id; | |
965 dti_cntrl_dev->dti_id = dti_id; | |
966 dti_cntrl_dev->port_number = port_num; | |
967 dti_cntrl_dev->driver_id = driver_id; | |
968 dti_cntrl_dev->dio_ctrl_id = dio_ctrl_id; | |
969 | |
970 #ifdef FF_TCP_IP | |
971 dti_cntrl_dev->had_aaa_dti_rsp = FALSE ; | |
972 dti_cntrl_dev->save_link_id = 0 ; | |
973 dti_cntrl_dev->save_cur_ent_id = 0 ; | |
974 dti_cntrl_dev->save_dti_conn = 0 ; | |
975 #endif /* FF_TCP_IP */ | |
976 | |
977 if ((src_id NEQ DTI_SRC_ID_NOTPRESENT) AND (src_id <= CMD_SRC_MAX)) | |
978 { | |
979 dti_cntrl_dev->cur_cap = DTI_CPBLTY_CMD; /* has been called by an AT src, so at least CMD capability */ | |
980 } | |
981 else | |
982 { | |
983 dti_cntrl_dev->cur_cap = DTI_CPBLTY_NO; /* has not been called by an AT src and there is no connection yet */ | |
984 } | |
985 | |
986 for (i=0; i<DTI_MAX_REDIRECTIONS; ++i) | |
987 { | |
988 dti_cntrl_dev->redirect_info.tbl->ser_redirect[i].mode = DTI_MODE_PERM; | |
989 dti_cntrl_dev->redirect_info.tbl->ser_redirect[i].redirection = NULL; | |
990 dti_cntrl_dev->redirect_info.tbl->pkt_redirect[i].mode = DTI_MODE_PERM; | |
991 dti_cntrl_dev->redirect_info.tbl->pkt_redirect[i].redirection = NULL; | |
992 } | |
993 | |
994 return (insert_list (dti_cntrl_list, dti_cntrl_dev)); | |
995 } | |
996 | |
997 /* | |
998 +--------------------------------------------------------------------+ | |
999 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1000 | STATE : code ROUTINE : dti_cntrl_new_device | | |
1001 +--------------------------------------------------------------------+ | |
1002 | |
1003 PURPOSE : change the sub channel number (for multiplexer) | |
1004 */ | |
1005 GLOBAL void dti_cntrl_change_sub_no (UBYTE src_id, | |
1006 UBYTE sub_no) | |
1007 { | |
1008 T_DTI_CNTRL *dti_cntrl_dev = (T_DTI_CNTRL *)find_element (dti_cntrl_list, src_id, dti_cntrl_search_src_id); | |
1009 | |
1010 TRACE_FUNCTION("dti_cntrl_change_sub_no()"); | |
1011 | |
1012 if (dti_cntrl_dev NEQ NULL) | |
1013 { | |
1014 dti_cntrl_dev->sub_no = sub_no; /* multiplexed sub channels */ | |
1015 } | |
1016 else | |
1017 { | |
1018 TRACE_EVENT_P1("no registered device found for src_id=%u", src_id); | |
1019 } | |
1020 } | |
1021 | |
1022 /* | |
1023 +--------------------------------------------------------------------+ | |
1024 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1025 | STATE : code ROUTINE : dti_cntrl_est_dpath | | |
1026 +--------------------------------------------------------------------+ | |
1027 | |
1028 PURPOSE : establish a data connection path directly | |
1029 | |
1030 */ | |
1031 GLOBAL BOOL dti_cntrl_est_dpath ( UBYTE dti_id, | |
1032 T_DTI_ENTITY_ID *entity_list, | |
1033 UBYTE num_entities, | |
1034 T_DTI_CONN_MODE mode, /* split/append */ | |
1035 T_DTI_CONN_CB *cb) | |
1036 { | |
1037 TRACE_FUNCTION("dti_cntrl_est_dpath()"); | |
1038 | |
1039 return (dti_conn_est_dpath (dti_id, entity_list, num_entities, mode, cb)); | |
1040 } | |
1041 | |
1042 /* | |
1043 +-------------------------------------------------------------------------+ | |
1044 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1045 | STATE : code ROUTINE : dti_cntrl_est_dpath_indirect | | |
1046 +-------------------------------------------------------------------------+ | |
1047 | |
1048 PURPOSE : establish a data connection path, for which a redirection has been set up. | |
1049 a redirection relates to a serial or packet device indicated by capability. | |
1050 with the cid we find in ser_redirect[cid] respectively pkt_redirect[cid] | |
1051 the pointer to the redirected device maintenance in dti_cntrl_list, from | |
1052 which we get the dti_id to pass it to the DTI Connection Manager. | |
1053 */ | |
1054 GLOBAL BOOL dti_cntrl_est_dpath_indirect (UBYTE src_id, | |
1055 T_DTI_ENTITY_ID *entity_list, | |
1056 UBYTE num_entities, | |
1057 T_DTI_CONN_MODE mode, /* split/append */ | |
1058 T_DTI_CONN_CB *cb, | |
1059 UBYTE capability, | |
1060 UBYTE cid) | |
1061 { | |
1062 T_DTI_CNTRL *dti_cntrl_dev = (T_DTI_CNTRL *)find_element (dti_cntrl_list, src_id, dti_cntrl_search_src_id); | |
1063 T_DTI_CNTRL *indirect_dev = NULL; /* the pointer to the redirected device maintenance */ | |
1064 UBYTE dti_id = DTI_DTI_ID_NOTPRESENT; | |
1065 UBYTE mode_once_perm = DTI_MODE_NIL; | |
1066 T_DTI_ENTITY_ID *new_entity_list; | |
1067 BOOL ret_value; | |
1068 | |
1069 /* for tracing of establishing of CMD channels for dual port version */ | |
1070 #ifdef RMV_15_04_03 | |
1071 extern CHAR gob_tst_buf[]; | |
1072 #endif | |
1073 | |
1074 TRACE_FUNCTION("dti_cntrl_est_dpath_indirect()"); | |
1075 | |
1076 if (dti_cntrl_dev EQ NULL) | |
1077 { | |
1078 TRACE_EVENT_P1("[ERR]Device with src_id=%d was not registered", src_id); | |
1079 return FALSE; | |
1080 } | |
1081 | |
1082 ACI_MALLOC(new_entity_list, sizeof(T_DTI_ENTITY_ID)*(num_entities+1) ); | |
1083 memcpy(&new_entity_list[1], entity_list, sizeof(T_DTI_ENTITY_ID)*num_entities); | |
1084 | |
1085 if (cid EQ DTI_CID_NOTPRESENT) | |
1086 { | |
1087 cid = 0; | |
1088 } | |
1089 | |
1090 /* | |
1091 * requested capability for data transmission can be SER ,PKT or CMD | |
1092 */ | |
1093 switch (capability) | |
1094 { | |
1095 case (DTI_CPBLTY_PKT): | |
1096 { | |
1097 mode_once_perm = dti_cntrl_dev->redirect_info.tbl->pkt_redirect[cid].mode; | |
1098 indirect_dev = dti_cntrl_dev->redirect_info.tbl->pkt_redirect[cid].redirection; | |
1099 | |
1100 /* | |
1101 * if there is no redirection for the given cid (so it is a GPRS call) | |
1102 * then look in the "redirection for all cids" entry | |
1103 */ | |
1104 if ((indirect_dev EQ NULL) AND (cid NEQ 0)) | |
1105 { | |
1106 mode_once_perm = dti_cntrl_dev->redirect_info.tbl->pkt_redirect[0].mode; | |
1107 indirect_dev = dti_cntrl_dev->redirect_info.tbl->pkt_redirect[0].redirection; | |
1108 } | |
1109 | |
1110 if(indirect_dev NEQ NULL) | |
1111 { | |
1112 indirect_dev->cur_cap = DTI_CPBLTY_PKT; | |
1113 } | |
1114 break; | |
1115 } | |
1116 case (DTI_CPBLTY_SER): | |
1117 { | |
1118 mode_once_perm = dti_cntrl_dev->redirect_info.tbl->ser_redirect[cid].mode; | |
1119 indirect_dev = dti_cntrl_dev->redirect_info.tbl->ser_redirect[cid].redirection; | |
1120 | |
1121 /* | |
1122 * if there is no redirection for the given cid (so it is a GPRS call) | |
1123 * then look in the "redirection for all cids" entry | |
1124 */ | |
1125 if ((indirect_dev EQ NULL) AND (cid NEQ 0)) | |
1126 { | |
1127 mode_once_perm = dti_cntrl_dev->redirect_info.tbl->ser_redirect[0].mode; | |
1128 indirect_dev = dti_cntrl_dev->redirect_info.tbl->ser_redirect[0].redirection; | |
1129 #ifdef RMV_15_04_03 | |
1130 TRACE_EVENT("redirection used"); | |
1131 TRACE_EVENT_P1("cid: %d", cid); | |
1132 #endif | |
1133 } | |
1134 | |
1135 if(indirect_dev NEQ NULL) | |
1136 { | |
1137 indirect_dev->cur_cap = DTI_CPBLTY_SER; | |
1138 } | |
1139 break; | |
1140 } | |
1141 case (DTI_CPBLTY_CMD): | |
1142 dti_cntrl_dev->cur_cap = DTI_CPBLTY_CMD; | |
1143 break; | |
1144 default: | |
1145 { | |
1146 return (FALSE); | |
1147 } | |
1148 } | |
1149 | |
1150 if (indirect_dev EQ NULL) | |
1151 { | |
1152 /* verify that the device is able to work in the requested capability */ | |
1153 if ((BITFIELD_CHECK (capability, dti_cntrl_dev->capability)) EQ FALSE) | |
1154 { | |
1155 return (FALSE); | |
1156 } | |
1157 | |
1158 dti_id = dti_cntrl_dev->dti_id; | |
1159 new_entity_list[0] = dti_cntrl_dev->dev_id; | |
1160 } | |
1161 else | |
1162 { | |
1163 /* verify that the device is able to work in the requested capability */ | |
1164 if ((BITFIELD_CHECK (capability, indirect_dev->capability)) EQ FALSE) | |
1165 { | |
1166 return (FALSE); | |
1167 } | |
1168 | |
1169 dti_id = indirect_dev->dti_id; | |
1170 new_entity_list[0] = indirect_dev->dev_id; | |
1171 if (mode_once_perm EQ DTI_MODE_ONCE) | |
1172 { | |
1173 /* the redirected data transmission connection is not permanent, | |
1174 * so remove the pointer to the redirected device maintenance */ | |
1175 indirect_dev = NULL; | |
1176 } | |
1177 } | |
1178 | |
1179 num_entities++; | |
1180 /* | |
1181 * remember capability, we need it again in dti_cntrl_entity_connected() | |
1182 */ | |
1183 g_cur_cap = capability; | |
1184 | |
1185 /* for tracing of establishing of CMD channels for dual port version */ | |
1186 #ifdef RMV_15_04_03 | |
1187 TRACE_EVENT_P1("num_entities: %d", num_entities); | |
1188 TRACE_EVENT_P1("g_cur_cap: %d", g_cur_cap); | |
1189 TRACE_EVENT_P1("new_entity_list[0]: %d", new_entity_list[0]); | |
1190 TRACE_EVENT_P1("new_entity_list[1]: %d", new_entity_list[1]); | |
1191 TRACE_EVENT_P1("new_entity_list[2]: %d", new_entity_list[2]); | |
1192 TRACE_EVENT_P1("dti_cntrl_dev->dti_id: %d", dti_cntrl_dev->dti_id); | |
1193 if (indirect_dev) | |
1194 { | |
1195 TRACE_EVENT_P1("indirect_dev->dti_id: %d", indirect_dev->dti_id); | |
1196 } | |
1197 | |
1198 TRACE_EVENT(gob_tst_buf); | |
1199 #endif | |
1200 | |
1201 /* clear reconnect flag for the new connction */ | |
1202 dti_cntrl_clear_dti_id_to_reconnect(dti_id); | |
1203 | |
1204 ret_value = dti_conn_est_dpath (dti_id, new_entity_list, num_entities, mode, cb); | |
1205 | |
1206 ACI_MFREE(new_entity_list); | |
1207 return ret_value; | |
1208 } | |
1209 | |
1210 /* | |
1211 +------------------------------------------------------------------------+ | |
1212 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1213 | STATE : code ROUTINE : dti_cntrl_is_dti_channel_connected | | |
1214 +------------------------------------------------------------------------+ | |
1215 | |
1216 PURPOSE : | |
1217 | |
1218 */ | |
1219 GLOBAL BOOL dti_cntrl_is_dti_channel_connected (T_DTI_ENTITY_ID ent_id, UBYTE dti_id) | |
1220 { | |
1221 TRACE_FUNCTION("dti_cntrl_is_dti_channel_connected()"); | |
1222 | |
1223 return (dti_conn_is_dti_channel_connected (ent_id, dti_id)); | |
1224 } | |
1225 | |
1226 /* | |
1227 +--------------------------------------------------------------------------+ | |
1228 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1229 | STATE : code ROUTINE : dti_cntrl_is_dti_channel_disconnected | | |
1230 +--------------------------------------------------------------------------+ | |
1231 | |
1232 PURPOSE : | |
1233 | |
1234 */ | |
1235 GLOBAL BOOL dti_cntrl_is_dti_channel_disconnected (UBYTE dti_id) | |
1236 { | |
1237 TRACE_FUNCTION("dti_cntrl_is_dti_channel_disconnected()"); | |
1238 | |
1239 return (dti_conn_is_dti_channel_disconnected (dti_id)); | |
1240 } | |
1241 /* | |
1242 +------------------------------------------------------------------------+ | |
1243 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1244 | STATE : code ROUTINE : dti_cntrl_close_dpath_from_src_id | | |
1245 +------------------------------------------------------------------------+ | |
1246 | |
1247 PURPOSE : | |
1248 | |
1249 */ | |
1250 GLOBAL BOOL dti_cntrl_close_dpath_from_src_id (UBYTE src_id) | |
1251 { | |
1252 T_DTI_CNTRL *dti_cntrl_dev = (T_DTI_CNTRL *)find_element (dti_cntrl_list, src_id, dti_cntrl_search_src_id); | |
1253 | |
1254 TRACE_FUNCTION("dti_cntrl_close_dpath_from_src_id()"); | |
1255 | |
1256 return (dti_conn_close_dpath (dti_cntrl_dev->dti_id)); | |
1257 } | |
1258 | |
1259 /* | |
1260 +------------------------------------------------------------------------+ | |
1261 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1262 | STATE : code ROUTINE : dti_cntrl_close_dpath_from_dti_id | | |
1263 +------------------------------------------------------------------------+ | |
1264 | |
1265 PURPOSE : | |
1266 | |
1267 */ | |
1268 GLOBAL BOOL dti_cntrl_close_dpath_from_dti_id (UBYTE dti_id) | |
1269 { | |
1270 TRACE_FUNCTION("dti_cntrl_close_dpath_from_dti_id()"); | |
1271 | |
1272 return (dti_conn_close_dpath (dti_id)); | |
1273 } | |
1274 | |
1275 /* | |
1276 +----------------------------------------------------------------------------+ | |
1277 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1278 | STATE : code ROUTINE : dti_cntrl_get_info_from_src_id | | |
1279 +----------------------------------------------------------------------------+ | |
1280 | |
1281 PURPOSE : | |
1282 | |
1283 */ | |
1284 GLOBAL BOOL dti_cntrl_get_info_from_src_id (UBYTE src_id, | |
1285 T_DTI_CNTRL *info) /* out parameter */ | |
1286 { | |
1287 T_DTI_CNTRL *dti_cntrl_dev = (T_DTI_CNTRL *)find_element (dti_cntrl_list, src_id, dti_cntrl_search_src_id); | |
1288 | |
1289 TRACE_FUNCTION("dti_cntrl_get_info_from_src_id()"); | |
1290 | |
1291 if (dti_cntrl_dev) | |
1292 { | |
1293 return (dti_cntrl_get_info (info, dti_cntrl_dev)); | |
1294 } | |
1295 return (FALSE); | |
1296 } | |
1297 /* | |
1298 +----------------------------------------------------------------------------+ | |
1299 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1300 | STATE : code ROUTINE : dti_cntrl_get_info_from_dti_id | | |
1301 +----------------------------------------------------------------------------+ | |
1302 | |
1303 PURPOSE : | |
1304 | |
1305 */ | |
1306 GLOBAL BOOL dti_cntrl_get_info_from_dti_id (UBYTE dti_id, | |
1307 T_DTI_CNTRL *info) /* out parameter */ | |
1308 { | |
1309 T_DTI_CNTRL *dti_cntrl_dev = (T_DTI_CNTRL *)find_element (dti_cntrl_list, dti_id, dti_cntrl_search_dti_id); | |
1310 | |
1311 TRACE_FUNCTION("dti_cntrl_get_info_from_dti_id()"); | |
1312 | |
1313 if (dti_cntrl_dev) | |
1314 { | |
1315 return (dti_cntrl_get_info (info, dti_cntrl_dev)); | |
1316 } | |
1317 return (FALSE); | |
1318 } | |
1319 | |
1320 /* | |
1321 +----------------------------------------------------------------------------+ | |
1322 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1323 | STATE : code ROUTINE : dti_cntrl_get_info_from_dev_id | | |
1324 +----------------------------------------------------------------------------+ | |
1325 | |
1326 PURPOSE : | |
1327 | |
1328 */ | |
1329 GLOBAL BOOL dti_cntrl_get_info_from_dev_id (T_DTI_ENTITY_ID dev_id, | |
1330 UBYTE dev_no, | |
1331 UBYTE sub_no, | |
1332 T_DTI_CNTRL *info) /* out parameter */ | |
1333 { | |
1334 T_DTI_CNTRL *dti_cntrl_dev = (T_DTI_CNTRL *)find_element_by_tupel (dti_cntrl_list, | |
1335 dev_id, | |
1336 dev_no, | |
1337 sub_no, | |
1338 dti_cntrl_search_dev_id); | |
1339 TRACE_FUNCTION("dti_cntrl_info_from_dev_id()"); | |
1340 | |
1341 if (dti_cntrl_dev) | |
1342 { | |
1343 return (dti_cntrl_get_info (info, dti_cntrl_dev)); | |
1344 } | |
1345 return (FALSE); | |
1346 } | |
1347 | |
1348 /* | |
1349 +-----------------------------------------------------------------------------+ | |
1350 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1351 | STATE : code ROUTINE : dti_cntrl_set_redirect_from_src | | |
1352 +-----------------------------------------------------------------------------+ | |
1353 | |
1354 PURPOSE : | |
1355 | |
1356 */ | |
1357 GLOBAL BOOL dti_cntrl_set_redirect_from_src (UBYTE src_id, | |
1358 UBYTE mode, | |
1359 T_DTI_ENTITY_ID dst_dev_id, | |
1360 UBYTE dst_dev_no, | |
1361 UBYTE dst_sub_no, | |
1362 UBYTE capability, | |
1363 UBYTE cid) | |
1364 { | |
1365 T_DTI_CNTRL *dti_cntrl_dev = (T_DTI_CNTRL *)find_element (dti_cntrl_list, src_id, dti_cntrl_search_src_id); | |
1366 T_DTI_CNTRL *indirect_dev = (T_DTI_CNTRL *)find_element_by_tupel (dti_cntrl_list, | |
1367 dst_dev_id, | |
1368 dst_dev_no, | |
1369 dst_sub_no, | |
1370 dti_cntrl_search_dev_id); | |
1371 | |
1372 TRACE_FUNCTION("dti_cntrl_set_redirect_from_src()"); | |
1373 | |
1374 if (dti_cntrl_dev AND indirect_dev) | |
1375 { | |
1376 return (dti_cntrl_set_redirection (dti_cntrl_dev, indirect_dev, mode, capability, cid)); | |
1377 } | |
1378 | |
1379 if (dti_cntrl_dev EQ 0) | |
1380 { | |
1381 TRACE_EVENT_P1("dti_cntrl_set_redirect_from_src():[ERR] no list element for src_id=%d", src_id); | |
1382 } | |
1383 if (indirect_dev EQ 0) | |
1384 { | |
1385 TRACE_EVENT_P3("dti_cntrl_set_redirect_from_src():[ERR] no list element for dev_id=%d, dev_no=%d, sub_no=%d", dst_dev_id, | |
1386 dst_dev_no, | |
1387 dst_sub_no); | |
1388 } | |
1389 return (FALSE); | |
1390 } | |
1391 | |
1392 /* | |
1393 +--------------------------------------------------------------------------------+ | |
1394 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1395 | STATE : code ROUTINE : dti_cntrl_set_redirect_from_device | | |
1396 +--------------------------------------------------------------------------------+ | |
1397 | |
1398 PURPOSE : | |
1399 | |
1400 */ | |
1401 GLOBAL BOOL dti_cntrl_set_redirect_from_device (UBYTE mode, | |
1402 T_DTI_ENTITY_ID dst_dev_id, | |
1403 UBYTE dst_dev_no, | |
1404 UBYTE dst_sub_no, | |
1405 T_DTI_ENTITY_ID src_dev_id, | |
1406 UBYTE src_dev_no, | |
1407 UBYTE src_sub_no, | |
1408 UBYTE capability, | |
1409 UBYTE cid) | |
1410 { | |
1411 T_DTI_CNTRL *source_dev = (T_DTI_CNTRL *)find_element_by_tupel (dti_cntrl_list, | |
1412 src_dev_id, | |
1413 src_dev_no, | |
1414 src_sub_no, | |
1415 dti_cntrl_search_dev_id); | |
1416 T_DTI_CNTRL *destination_dev = (T_DTI_CNTRL *)find_element_by_tupel (dti_cntrl_list, | |
1417 dst_dev_id, | |
1418 dst_dev_no, | |
1419 dst_sub_no, | |
1420 dti_cntrl_search_dev_id); | |
1421 | |
1422 TRACE_FUNCTION("dti_cntrl_set_redirect_from_device()"); | |
1423 | |
1424 if (source_dev AND destination_dev) | |
1425 { | |
1426 if ((BITFIELD_CHECK (source_dev->capability, DTI_CPBLTY_CMD)) EQ FALSE) | |
1427 { | |
1428 TRACE_EVENT("source device has no command capability !"); | |
1429 return (FALSE); | |
1430 } | |
1431 | |
1432 return (dti_cntrl_set_redirection (source_dev, destination_dev, mode, capability, cid)); | |
1433 } | |
1434 return (FALSE); | |
1435 } | |
1436 | |
1437 /* | |
1438 +-----------------------------------------------------------------------------+ | |
1439 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1440 | STATE : code ROUTINE : dti_cntrl_get_first_device | | |
1441 +-----------------------------------------------------------------------------+ | |
1442 | |
1443 PURPOSE : this function is used in conjunction with | |
1444 1:AT%DATA where all devices | |
1445 and their possible redirections for data transmission have to | |
1446 be listed. so start with the first element of dti_cntrl_list | |
1447 2.AT%DINF where all devices have to be listed, start with first element | |
1448 */ | |
1449 GLOBAL BOOL dti_cntrl_get_first_device (T_DTI_CNTRL *info) /* out parameter */ | |
1450 { | |
1451 T_DTI_CNTRL *dti_cntrl_dev; | |
1452 | |
1453 TRACE_FUNCTION("dti_cntrl_get_first_device()"); | |
1454 | |
1455 dti_cntrl_dev_ptr = dti_cntrl_list; | |
1456 dti_cntrl_dev = (T_DTI_CNTRL *)(dti_cntrl_dev_ptr->msg); | |
1457 | |
1458 if (dti_cntrl_dev) | |
1459 { | |
1460 return (dti_cntrl_get_info (info, dti_cntrl_dev)); | |
1461 } | |
1462 return (FALSE); | |
1463 } | |
1464 | |
1465 /* | |
1466 +-----------------------------------------------------------------------------+ | |
1467 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1468 | STATE : code ROUTINE : dti_cntrl_get_next_device | | |
1469 +-----------------------------------------------------------------------------+ | |
1470 | |
1471 PURPOSE : this function is used in conjunction with AT%DINF where all devices have | |
1472 to be listed, give next element | |
1473 */ | |
1474 GLOBAL BOOL dti_cntrl_get_next_device (T_DTI_CNTRL *info) /* out parameter */ | |
1475 { | |
1476 T_DTI_CNTRL *dti_cntrl_dev; | |
1477 | |
1478 TRACE_FUNCTION("dti_cntrl_get_next_device()"); | |
1479 | |
1480 if(dti_cntrl_dev_ptr->next NEQ NULL) | |
1481 { | |
1482 dti_cntrl_dev_ptr = dti_cntrl_dev_ptr->next; | |
1483 dti_cntrl_dev = (T_DTI_CNTRL *)(dti_cntrl_dev_ptr->msg); | |
1484 | |
1485 if (dti_cntrl_dev) | |
1486 { | |
1487 return (dti_cntrl_get_info (info, dti_cntrl_dev)); | |
1488 } | |
1489 } | |
1490 else | |
1491 dti_cntrl_dev_ptr = NULL; | |
1492 return (FALSE); | |
1493 } | |
1494 | |
1495 /* | |
1496 +-----------------------------------------------------------------------------+ | |
1497 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1498 | STATE : code ROUTINE : dti_cntrl_get_first_redirection | | |
1499 +-----------------------------------------------------------------------------+ | |
1500 | |
1501 PURPOSE : to the given src_id and capability (SER/PKT) find the first | |
1502 redirection. | |
1503 */ | |
1504 GLOBAL BOOL dti_cntrl_get_first_redirection (UBYTE src_id, | |
1505 UBYTE capability, | |
1506 T_DTI_CNTRL *redirection) /* out parameter */ | |
1507 { | |
1508 T_DTI_CNTRL *dti_cntrl_dev = (T_DTI_CNTRL *)find_element (dti_cntrl_list, src_id, dti_cntrl_search_src_id); | |
1509 | |
1510 TRACE_FUNCTION("dti_cntrl_get_first_redirection()"); | |
1511 | |
1512 /* | |
1513 * for the cid we set here -1, because the sub function will first increase it by one | |
1514 * so we access ser_redirect[0] respectively pkt_redirect[0] | |
1515 */ | |
1516 return (dti_cntrl_get_redirection (dti_cntrl_dev, redirection, 0xFF, capability)); | |
1517 } | |
1518 | |
1519 /* | |
1520 +----------------------------------------------------------------------------+ | |
1521 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1522 | STATE : code ROUTINE : dti_cntrl_get_next_redirection | | |
1523 +----------------------------------------------------------------------------+ | |
1524 | |
1525 PURPOSE : to the given src_id and capability (SER/PKT) find the next | |
1526 redirection >>after<< the given cid. | |
1527 */ | |
1528 GLOBAL BOOL dti_cntrl_get_next_redirection (UBYTE src_id, | |
1529 UBYTE cid, | |
1530 UBYTE capability, | |
1531 T_DTI_CNTRL *redirection) /* out parameter */ | |
1532 { | |
1533 T_DTI_CNTRL *dti_cntrl_dev = (T_DTI_CNTRL *)find_element (dti_cntrl_list, src_id, dti_cntrl_search_src_id); | |
1534 | |
1535 TRACE_FUNCTION("dti_cntrl_get_next_redirection()"); | |
1536 | |
1537 return (dti_cntrl_get_redirection (dti_cntrl_dev, redirection, cid, capability)); | |
1538 } | |
1539 | |
1540 /* | |
1541 +-------------------------------------------------------------------------+ | |
1542 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1543 | STATE : code ROUTINE : dti_cntrl_entity_connected | | |
1544 +-------------------------------------------------------------------------+ | |
1545 | |
1546 PURPOSE : | |
1547 | |
1548 */ | |
1549 GLOBAL void dti_cntrl_entity_connected (ULONG link_id, | |
1550 T_DTI_ENTITY_ID entity_id, | |
1551 T_DTI_CONN_RESULT result) | |
1552 { | |
1553 UBYTE dti_id = EXTRACT_DTI_ID(link_id); | |
1554 T_DTI_CNTRL *dti_cntrl_dev = (T_DTI_CNTRL *)find_element (dti_cntrl_list, dti_id, dti_cntrl_search_dti_id); | |
1555 | |
1556 TRACE_FUNCTION("dti_cntrl_entity_connected()"); | |
1557 | |
1558 if (dti_cntrl_dev AND (result EQ DTI_ERROR)) | |
1559 { | |
1560 dti_cntrl_dev->cur_cap = DTI_CPBLTY_NO; /* reset current capability */ | |
1561 } | |
1562 | |
1563 /* call DTI Connection Mng function */ | |
1564 dti_conn_entity_connected (link_id, entity_id, result); | |
1565 | |
1566 /* set current capability if DTI channel is connected */ | |
1567 if (dti_cntrl_dev AND (dti_conn_is_dti_channel_connected(entity_id, dti_id) EQ TRUE)) | |
1568 { | |
1569 dti_cntrl_dev->cur_cap = g_cur_cap; | |
1570 } | |
1571 } | |
1572 /* | |
1573 +----------------------------------------------------------------------------+ | |
1574 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1575 | STATE : code ROUTINE : dti_cntrl_entity_disconnected | | |
1576 +----------------------------------------------------------------------------+ | |
1577 | |
1578 PURPOSE : | |
1579 | |
1580 */ | |
1581 GLOBAL void dti_cntrl_entity_disconnected (ULONG link_id, | |
1582 T_DTI_ENTITY_ID entity_id) | |
1583 { | |
1584 UBYTE dti_id = EXTRACT_DTI_ID(link_id); | |
1585 T_DTI_CNTRL *dti_cntrl_dev = (T_DTI_CNTRL *)find_element (dti_cntrl_list, dti_id, dti_cntrl_search_dti_id); | |
1586 | |
1587 TRACE_FUNCTION("dti_cntrl_entity_disconnected()"); | |
1588 | |
1589 if (dti_cntrl_dev) | |
1590 { | |
1591 dti_cntrl_dev->cur_cap = DTI_CPBLTY_NO; /* reset current capability */ | |
1592 } | |
1593 | |
1594 /* call DTI Connection Mng function */ | |
1595 dti_conn_entity_disconnected( link_id, entity_id ); | |
1596 } | |
1597 | |
1598 /* | |
1599 +--------------------------------------------------------------------+ | |
1600 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1601 | STATE : code ROUTINE : dti_cntrl_erase_entry | | |
1602 +--------------------------------------------------------------------+ | |
1603 | |
1604 PURPOSE : This function removes a registered device from | |
1605 DTI Cntrl Mng list and removes its DTI ID from the list of | |
1606 DTI Conn Mng. | |
1607 | |
1608 */ | |
1609 GLOBAL void dti_cntrl_erase_entry (UBYTE dti_id) | |
1610 { | |
1611 T_DTI_CNTRL *dti_cntrl_dev = NULL; | |
1612 | |
1613 TRACE_FUNCTION("dti_cntrl_erase_entry()"); | |
1614 | |
1615 dti_cntrl_dev = remove_element (dti_cntrl_list, dti_id, dti_cntrl_search_dti_id); | |
1616 | |
1617 if (dti_cntrl_dev EQ NULL) | |
1618 { | |
1619 TRACE_EVENT_P1("Device with DTI ID %d was not registered", dti_id); | |
1620 } | |
1621 else | |
1622 { | |
1623 /* | |
1624 * redirect_info is a union, where we use the union element tbl, | |
1625 * which is a pointer to an allocated structure | |
1626 * of type T_DTI_CNTRL_REDIRECT_INTERN | |
1627 */ | |
1628 if (dti_cntrl_dev->redirect_info.tbl NEQ NULL) | |
1629 { | |
1630 ACI_MFREE (dti_cntrl_dev->redirect_info.tbl); | |
1631 dti_cntrl_dev->redirect_info.tbl = NULL; | |
1632 } | |
1633 ACI_MFREE (dti_cntrl_dev); | |
1634 } | |
1635 | |
1636 /* call DTI connection manager function */ | |
1637 dti_conn_erase_entry(dti_id); | |
1638 | |
1639 } | |
1640 | |
1641 /* | |
1642 +--------------------------------------------------------------------+ | |
1643 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1644 | STATE : code ROUTINE : dti_cntrl_reg_new_fct | | |
1645 +--------------------------------------------------------------------+ | |
1646 | |
1647 PURPOSE : register an call back function, which is used when a | |
1648 customer/external has its own entity involved during | |
1649 a data transmission. | |
1650 The registered function is called by dti_cntrl_maintain_entity() | |
1651 only, where dti_cntrl_maintain_entity() itself is a | |
1652 call back function used by the DTI Connection Manager | |
1653 */ | |
1654 GLOBAL BOOL dti_cntrl_reg_new_fct (T_DTI_ENTITY_ID entity_id, | |
1655 T_DTI_EXT_CB *fct) | |
1656 { | |
1657 UBYTE i = 0; | |
1658 | |
1659 TRACE_FUNCTION("dti_cntrl_reg_new_fct()"); | |
1660 | |
1661 if (entity_id <= DTI_ENTITY_MAX) | |
1662 { | |
1663 TRACE_EVENT("ENTITY ID already in use"); | |
1664 return (FALSE); | |
1665 } | |
1666 | |
1667 for (i=0; i<DTI_MAX_EXT_CB; i++) | |
1668 { | |
1669 if (reg_ext_cb[i].ent_id EQ DTI_ENTITY_INVALID) | |
1670 { | |
1671 reg_ext_cb[i].ent_id = entity_id; | |
1672 reg_ext_cb[i].fct = fct; | |
1673 return (TRUE); | |
1674 } | |
1675 } | |
1676 return (FALSE); | |
1677 } | |
1678 | |
1679 /* | |
1680 * special temporary stuff | |
1681 */ | |
1682 | |
1683 /* | |
1684 +--------------------------------------------------------------------+ | |
1685 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1686 | STATE : code ROUTINE : dti_cntrl_get_link_id() | | |
1687 +--------------------------------------------------------------------+ | |
1688 | |
1689 PURPOSE : | |
1690 | |
1691 */ | |
1692 GLOBAL T_DTI_CONN_LINK_ID dti_cntrl_get_link_id( T_DTI_ENTITY_ID ent_id, | |
1693 UBYTE dev_no, | |
1694 UBYTE sub_no) | |
1695 { | |
1696 UBYTE i; | |
1697 | |
1698 TRACE_FUNCTION("dti_cntrl_get_link_id()"); | |
1699 | |
1700 for (i=0; i<MAX_DTI_CONN_LINK_IDS; i++) | |
1701 { | |
1702 if ( ((dti_aci_data_base[i].ent_id1 EQ ent_id) | |
1703 AND (dti_aci_data_base[i].dev_no1 EQ dev_no) | |
1704 AND (dti_aci_data_base[i].sub_no1 EQ sub_no)) | |
1705 OR | |
1706 ((dti_aci_data_base[i].ent_id2 EQ ent_id) | |
1707 AND (dti_aci_data_base[i].dev_no2 EQ dev_no) | |
1708 AND (dti_aci_data_base[i].sub_no2 EQ sub_no)) ) | |
1709 return (dti_aci_data_base[i].link_id); | |
1710 } | |
1711 | |
1712 TRACE_EVENT("link_id not found"); | |
1713 return DTI_LINK_ID_NOTPRESENT; | |
1714 } | |
1715 | |
1716 | |
1717 /* | |
1718 +--------------------------------------------------------------------+ | |
1719 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1720 | STATE : code ROUTINE : dti_cntrl_get_peer_() | | |
1721 +--------------------------------------------------------------------+ | |
1722 | |
1723 PURPOSE : | |
1724 | |
1725 */ | |
1726 GLOBAL T_DTI_ENTITY_ID dti_cntrl_get_peer( T_DTI_ENTITY_ID ent_id, | |
1727 UBYTE dev_no, | |
1728 UBYTE sub_no) | |
1729 { | |
1730 UBYTE i; | |
1731 | |
1732 TRACE_FUNCTION("dti_cntrl_get_peer()"); | |
1733 | |
1734 for (i=0; i<MAX_DTI_CONN_LINK_IDS; i++) | |
1735 { | |
1736 if ((dti_aci_data_base[i].ent_id1 EQ ent_id) | |
1737 AND (dti_aci_data_base[i].dev_no1 EQ dev_no) | |
1738 AND (dti_aci_data_base[i].sub_no1 EQ sub_no)) | |
1739 { | |
1740 return dti_aci_data_base[i].ent_id2; | |
1741 } | |
1742 if ((dti_aci_data_base[i].ent_id2 EQ ent_id) | |
1743 AND (dti_aci_data_base[i].dev_no2 EQ dev_no) | |
1744 AND (dti_aci_data_base[i].sub_no2 EQ sub_no)) | |
1745 { | |
1746 return dti_aci_data_base[i].ent_id1; | |
1747 } | |
1748 } | |
1749 | |
1750 TRACE_EVENT("peer entity not found"); | |
1751 return DTI_ENTITY_INVALID; | |
1752 } | |
1753 | |
1754 /* | |
1755 +--------------------------------------------------------------------+ | |
1756 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1757 | STATE : code ROUTINE : dti_cntrl_set_conn_parms() | | |
1758 +--------------------------------------------------------------------+ | |
1759 | |
1760 PURPOSE : | |
1761 | |
1762 */ | |
1763 GLOBAL BOOL dti_cntrl_set_conn_parms( T_DTI_CONN_LINK_ID link_id, | |
1764 T_DTI_ENTITY_ID ent_id, | |
1765 UBYTE dev_no, | |
1766 UBYTE sub_no ) | |
1767 { | |
1768 UBYTE i; | |
1769 | |
1770 TRACE_FUNCTION("dti_cntrl_set_conn_parms()"); | |
1771 | |
1772 for (i=0; i<MAX_DTI_CONN_LINK_IDS; i++) | |
1773 { | |
1774 if (dti_aci_data_base[i].link_id EQ DTI_LINK_ID_NOTPRESENT) | |
1775 { | |
1776 dti_aci_data_base[i].link_id = link_id; | |
1777 | |
1778 dti_aci_data_base[i].ent_id1 = ent_id; | |
1779 dti_aci_data_base[i].dev_no1 = dev_no; | |
1780 dti_aci_data_base[i].sub_no1 = sub_no; | |
1781 | |
1782 return TRUE; | |
1783 } | |
1784 else if (dti_aci_data_base[i].link_id EQ link_id) | |
1785 { | |
1786 dti_aci_data_base[i].ent_id2 = ent_id; | |
1787 dti_aci_data_base[i].dev_no2 = dev_no; | |
1788 dti_aci_data_base[i].sub_no2 = sub_no; | |
1789 | |
1790 return TRUE; | |
1791 } | |
1792 } | |
1793 | |
1794 return FALSE; | |
1795 } | |
1796 | |
1797 /* | |
1798 +--------------------------------------------------------------------+ | |
1799 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1800 | STATE : code ROUTINE : dti_cntrl_clear_conn_parms | | |
1801 +--------------------------------------------------------------------+ | |
1802 | |
1803 PURPOSE : | |
1804 | |
1805 */ | |
1806 GLOBAL void dti_cntrl_clear_conn_parms( UBYTE dti_id ) | |
1807 { | |
1808 UBYTE i; | |
1809 | |
1810 TRACE_FUNCTION("dti_cntrl_clear_conn_parms()"); | |
1811 | |
1812 for (i=0; i<MAX_DTI_CONN_LINK_IDS; i++) | |
1813 { | |
1814 if (EXTRACT_DTI_ID(dti_aci_data_base[i].link_id) EQ dti_id) | |
1815 { | |
1816 dti_aci_data_base[i].link_id = DTI_LINK_ID_NOTPRESENT; | |
1817 dti_aci_data_base[i].dev_no1 = DTI_DEV_NO_NOTPRESENT; | |
1818 dti_aci_data_base[i].dev_no2 = DTI_DEV_NO_NOTPRESENT; | |
1819 dti_aci_data_base[i].ent_id1 = DTI_ENTITY_INVALID; | |
1820 dti_aci_data_base[i].ent_id2 = DTI_ENTITY_INVALID; | |
1821 dti_aci_data_base[i].sub_no1 = DTI_SUB_NO_NOTPRESENT; | |
1822 dti_aci_data_base[i].sub_no2 = DTI_SUB_NO_NOTPRESENT; | |
1823 } | |
1824 } | |
1825 } | |
1826 | |
1827 /* | |
1828 +---------------------------------------------------------------------+ | |
1829 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1830 | STATE : code ROUTINE : dti_cntrl_close_all_connections | | |
1831 +---------------------------------------------------------------------+ | |
1832 | |
1833 PURPOSE : | |
1834 | |
1835 */ | |
1836 GLOBAL void dti_cntrl_close_all_connections() | |
1837 { | |
1838 T_DTI_CNTRL *dti_cntrl_dev; | |
1839 USHORT dti_cntrl_list_num = 0; | |
1840 USHORT i = 0; | |
1841 USHORT k = 0; | |
1842 | |
1843 TRACE_FUNCTION("dti_cntrl_close_all_connections()"); | |
1844 | |
1845 dti_cntrl_list_num = get_list_count (dti_cntrl_list); | |
1846 /* | |
1847 * we clear the list from head to tail | |
1848 */ | |
1849 while (i <= dti_cntrl_list_num) | |
1850 { | |
1851 dti_cntrl_dev = (T_DTI_CNTRL *)remove_first_element (dti_cntrl_list); | |
1852 | |
1853 if (dti_cntrl_dev) | |
1854 { | |
1855 for (k=0; k<DTI_MAX_REDIRECTIONS; ++k) | |
1856 { | |
1857 dti_cntrl_dev->redirect_info.tbl->ser_redirect[k].redirection = NULL; | |
1858 dti_cntrl_dev->redirect_info.tbl->pkt_redirect[k].redirection = NULL; | |
1859 } | |
1860 | |
1861 ACI_MFREE (dti_cntrl_dev->redirect_info.tbl); | |
1862 ACI_MFREE (dti_cntrl_dev); | |
1863 } | |
1864 ++i; | |
1865 } | |
1866 | |
1867 dti_conn_close_all_connections(); | |
1868 } | |
1869 | |
1870 /* | |
1871 +----------------------------------------------------------------------+ | |
1872 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1873 | STATE : code ROUTINE : dti_cntrl_set_dti_id_to_reconnect| | |
1874 +----------------------------------------------------------------------+ | |
1875 | |
1876 PURPOSE : This function sets a flag that means that if this DTI | |
1877 connection is completely disconnected then reconnect the | |
1878 registered device to ACI. | |
1879 */ | |
1880 GLOBAL void dti_cntrl_set_dti_id_to_reconnect(UBYTE dti_id) | |
1881 { | |
1882 ULONG tmp_bit_field = 0x01 << (dti_id); | |
1883 | |
1884 TRACE_FUNCTION("dti_cntrl_set_dti_id_to_reconnect()"); | |
1885 | |
1886 BITFIELD_SET(dti_cntrl_reconnect_to_aci, tmp_bit_field); | |
1887 } | |
1888 | |
1889 /* | |
1890 +------------------------------------------------------------------------+ | |
1891 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1892 | STATE : code ROUTINE : dti_cntrl_clear_dti_id_to_reconnect| | |
1893 +------------------------------------------------------------------------+ | |
1894 | |
1895 PURPOSE : Clears the 'Reconnect-to-ACI' flag. | |
1896 | |
1897 */ | |
1898 GLOBAL void dti_cntrl_clear_dti_id_to_reconnect(UBYTE dti_id) | |
1899 { | |
1900 ULONG tmp_bit_field = 0x01 << (dti_id); | |
1901 | |
1902 TRACE_FUNCTION("dti_cntrl_clear_dti_id_to_reconnect()"); | |
1903 | |
1904 BITFIELD_CLEAR(dti_cntrl_reconnect_to_aci, tmp_bit_field); | |
1905 } | |
1906 | |
1907 /* | |
1908 +------------------------------------------------------------------------+ | |
1909 | PROJECT : GSM-F&D (8411) MODULE : DTI_CNTRL | | |
1910 | STATE : code ROUTINE : dti_cntrl_is_dti_id_to_reconnect | | |
1911 +------------------------------------------------------------------------+ | |
1912 | |
1913 PURPOSE : Queries the 'Reconnect-to-ACI' flag. | |
1914 | |
1915 */ | |
1916 GLOBAL BOOL dti_cntrl_is_dti_id_to_reconnect(UBYTE dti_id) | |
1917 { | |
1918 ULONG tmp_bit_field = 0x01 << (dti_id); | |
1919 | |
1920 TRACE_FUNCTION("dti_cntrl_is_dti_id_to_reconnect()"); | |
1921 | |
1922 if (BITFIELD_CHECK(dti_cntrl_reconnect_to_aci, tmp_bit_field)) | |
1923 { | |
1924 TRACE_EVENT_P1("dti_id=%d must be reconnected", dti_id); | |
1925 return TRUE; | |
1926 } | |
1927 else | |
1928 { | |
1929 return FALSE; | |
1930 } | |
1931 } | |
1932 | |
1933 #endif /* DTI */ |