FreeCalypso > hg > fc-selenite
comparison src/g23m-gprs/sndcp/sndcp_pei.c @ 1:d393cd9bb723
src/g23m-*: initial import from Magnetite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 15 Jul 2018 04:40:46 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:b6a5e36de839 | 1:d393cd9bb723 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GPRS (8441) | |
4 | Modul : sndcp_pei.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 module implements the process body interface | |
18 | for the entity SNDCP | |
19 | | |
20 | Exported functions: | |
21 | | |
22 | pei_create - Create the Protocol Stack Entity | |
23 | pei_init - Initialize Protocol Stack Entity | |
24 | pei_primitive - Process Primitive | |
25 | pei_timeout - Process Timeout | |
26 | pei_exit - Close resources and terminate | |
27 | pei_run - Process Primitive | |
28 | pei_config - Dynamic Configuration | |
29 | pei_monitor - Monitoring of physical Parameters | |
30 +----------------------------------------------------------------------------- | |
31 */ | |
32 | |
33 #define SNDCP_PEI_C | |
34 | |
35 #define ENTITY_SNDCP | |
36 | |
37 /*==== INCLUDES =============================================================*/ | |
38 | |
39 #include <stddef.h> /* to get definition of offsetof(), for MAK_FUNC_S */ | |
40 #include "typedefs.h" /* to get Condat data types */ | |
41 #include "vsi.h" /* to get a lot of macros */ | |
42 #include "macdef.h" | |
43 #include "gprs.h" | |
44 #include "gsm.h" /* to get a lot of macros */ | |
45 #include "cnf_sndcp.h" /* to get cnf-definitions */ | |
46 #include "mon_sndcp.h" /* to get mon-definitions */ | |
47 #include "prim.h" /* to get the definitions of used SAP and directions */ | |
48 | |
49 #include "dti.h" /* To get dti lib */ | |
50 | |
51 #include "sndcp.h" /* to get the global entity definitions */ | |
52 | |
53 #include "ccdapi.h" /* to get ccd stuff */ | |
54 | |
55 #include "sndcp_ciaf.h" /* to get functions for service mg */ | |
56 #include "sndcp_ciap.h" /* to get primitive handling for service mg */ | |
57 #include "sndcp_cias.h" /* to get signal handling for service mg*/ | |
58 | |
59 #include "sndcp_mgf.h" /* to get functions for service mg */ | |
60 #include "sndcp_mgp.h" /* to get primitive handling for service mg */ | |
61 #include "sndcp_mgs.h" /* to get signal handling for service mg*/ | |
62 | |
63 #include "sndcp_ndf.h" /* to get functions for service nd */ | |
64 #include "sndcp_ndp.h" /* to get primitive handling for service nd */ | |
65 #include "sndcp_nds.h" /* to get signal handling for service nd */ | |
66 | |
67 #include "sndcp_nuf.h" /* to get functions for service nu */ | |
68 #include "sndcp_nup.h" /* to get primitive handling for service nu */ | |
69 #include "sndcp_nus.h" /* to get signal handling for service nu */ | |
70 | |
71 #include "sndcp_pdf.h" /* to get functions for service pd */ | |
72 #include "sndcp_pdaf.h" /* to get functions for service pda */ | |
73 | |
74 #include "sndcp_suf.h" /* to get functions for service su */ | |
75 #include "sndcp_sup.h" /* to get primitive handling for service su */ | |
76 #include "sndcp_sus.h" /* to get signal handling for service su */ | |
77 | |
78 #include "sndcp_suaf.h" /* to get functions for service sua */ | |
79 #include "sndcp_suap.h" /* to get primitive handling for service sua */ | |
80 #include "sndcp_suas.h" /* to get signal handling for service sua */ | |
81 | |
82 #include "sndcp_sdf.h" /* to get functions for service sd */ | |
83 #include "sndcp_sdp.h" /* to get primitive handling for service sd */ | |
84 #include "sndcp_sds.h" /* to get signal handling for service sd */ | |
85 | |
86 #include "sndcp_sdaf.h" /* to get functions for service sda */ | |
87 #include "sndcp_sdap.h" /* to get primitive handling for service sda */ | |
88 #include "sndcp_sdas.h" /* to get signal handling for service sda */ | |
89 | |
90 #include "sndcp_pdp.h" /* to get primitive handling for service pd */ | |
91 #include "sndcp_pds.h" /* to get signal handling for service pd */ | |
92 | |
93 #include "sndcp_pdap.h" /* to get primitive handling for service pda */ | |
94 #include "sndcp_pdas.h" /* to get signal handling for service pda */ | |
95 | |
96 #include "sndcp_f.h" | |
97 | |
98 #include <string.h> /* to get memcpy() */ | |
99 #include <stdlib.h> /* to get atoi() */ | |
100 | |
101 | |
102 | |
103 /*==== DEFINITIONS ==========================================================*/ | |
104 #define TCPIP_NAME "TCP" | |
105 /*==== TYPES ================================================================*/ | |
106 | |
107 /*==== GLOBAL VARS ==========================================================*/ | |
108 | |
109 /*==== LOCAL VARS ===========================================================*/ | |
110 | |
111 #ifdef _SNDCP_DTI_2_ | |
112 | |
113 LOCAL void sndcp_dti_dti_connect_cnf (T_DTI2_CONNECT_CNF | |
114 *dti2_connect_cnf); | |
115 LOCAL void sndcp_dti_dti_connect_ind (T_DTI2_CONNECT_IND | |
116 *dti2_connect_ind); | |
117 LOCAL void sndcp_dti_dti_disconnect_ind (T_DTI2_DISCONNECT_IND | |
118 *dti2_disconnect_ind); | |
119 LOCAL void sndcp_dti_dti_ready_ind (T_DTI2_READY_IND | |
120 *dti2_ready_ind); | |
121 LOCAL void sndcp_dti_dti_data_ind (T_DTI2_DATA_IND | |
122 *dti2_data_ind); | |
123 LOCAL void sndcp_dti_dti_getdata_req (T_DTI2_GETDATA_REQ | |
124 *dti_getdata_req); | |
125 LOCAL void sndcp_dti_dti_data_req (T_DTI2_DATA_REQ | |
126 *dti_data_req); | |
127 LOCAL void sndcp_dti_dti_connect_req (T_DTI2_CONNECT_REQ | |
128 *dti2_connect_req); | |
129 LOCAL void sndcp_dti_dti_connect_res (T_DTI2_CONNECT_RES | |
130 *dti2_connect_res); | |
131 LOCAL void sndcp_dti_dti_disconnect_req (T_DTI2_DISCONNECT_REQ | |
132 *dti2_disconnect_req); | |
133 #ifdef _SIMULATION_ | |
134 LOCAL void sndcp_dti_dti_data_test_req (T_DTI2_DATA_TEST_REQ | |
135 *dti_data_test_req); | |
136 LOCAL void sndcp_dti_dti_data_test_ind (T_DTI2_DATA_TEST_IND | |
137 *dti_data_test_ind); | |
138 #endif /*_SIMULATION_*/ | |
139 | |
140 #else /*_SNDCP_DTI_2_*/ | |
141 | |
142 LOCAL void sndcp_dti_dti_getdata_req (T_DTI_GETDATA_REQ | |
143 *dti_getdata_req); | |
144 | |
145 LOCAL void sndcp_dti_dti_data_req (T_DTI_DATA_REQ | |
146 *dti_data_req); | |
147 #ifdef _SIMULATION_ | |
148 LOCAL void sndcp_dti_dti_data_test_req (T_DTI_DATA_TEST_REQ | |
149 *dti_data_test_req); | |
150 #endif | |
151 | |
152 LOCAL void sndcp_dti_dti_ready_ind (T_DTI_READY_IND | |
153 *dti_ready_ind); | |
154 | |
155 LOCAL void sndcp_dti_dti_data_ind (T_DTI_DATA_IND | |
156 *dti_data_ind); | |
157 | |
158 #ifdef _SIMULATION_ | |
159 LOCAL void sndcp_dti_dti_data_test_ind (T_DTI_DATA_TEST_IND | |
160 *dti_data_test_ind); | |
161 #endif | |
162 #endif /* _SNDCP_DTI_2_ */ | |
163 | |
164 | |
165 static BOOL first_access = TRUE; | |
166 static T_MONITOR sndcp_mon; | |
167 | |
168 | |
169 | |
170 #ifdef TI_PS_OP_ICUT_SNDCP | |
171 | |
172 /* PDP_TBR added SNDCP terminal loopback */ | |
173 U8 SNDCP_LOOPBACK = FALSE; | |
174 | |
175 BOOL bufFull[SNDCP_NUMBER_OF_NSAPIS] = {FALSE,FALSE,FALSE,FALSE, FALSE,FALSE,FALSE,FALSE, | |
176 FALSE,FALSE,FALSE,FALSE, FALSE,FALSE,FALSE,FALSE}; | |
177 T_DTI2_DATA_IND *saveDti2_data_ind[SNDCP_NUMBER_OF_NSAPIS] = {NULL,NULL,NULL,NULL,NULL,NULL, | |
178 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; | |
179 | |
180 #endif /* TI_PS_OP_ICUT_SNDCP */ | |
181 | |
182 | |
183 | |
184 | |
185 /* | |
186 * Jumptables to primitive handler functions. One table per SAP. | |
187 * | |
188 * Use MAK_FUNC_0 for primitives which contains no SDU. | |
189 * Use MAK_FUNC_S for primitives which contains a SDU. | |
190 */ | |
191 | |
192 /* | |
193 * Function is needed for function_table[]. This declaration can be removed | |
194 * as soon as this function is no more called (i.e. all primitives are | |
195 * handled). | |
196 */ | |
197 LOCAL void primitive_not_supported (void *data); | |
198 | |
199 #ifndef SNDCP_UPM_INCLUDED | |
200 static const T_FUNC snsm_table[] = | |
201 { | |
202 MAK_FUNC_0(mg_snsm_activate_ind, SNSM_ACTIVATE_IND), /* 6700 */ | |
203 MAK_FUNC_0(mg_snsm_deactivate_ind, SNSM_DEACTIVATE_IND), /* 6701 */ | |
204 MAK_FUNC_0(mg_snsm_modify_ind, SNSM_MODIFY_IND), /* 6702 */ | |
205 MAK_FUNC_0(mg_snsm_sequence_ind, SNSM_SEQUENCE_IND) /* 6703 */ | |
206 }; | |
207 #endif | |
208 | |
209 #ifndef SNDCP_UPM_INCLUDED | |
210 static const T_FUNC sn_table[] = | |
211 { | |
212 MAK_FUNC_N(primitive_not_supported, 0), /* 2800 */ | |
213 MAK_FUNC_N(primitive_not_supported, 0), /* 2801 */ | |
214 MAK_FUNC_N(primitive_not_supported, 0), /* 2802 */ | |
215 MAK_FUNC_N(primitive_not_supported, 0), /* 2803 */ | |
216 MAK_FUNC_N(primitive_not_supported, 0), /* 2804 */ | |
217 MAK_FUNC_N(primitive_not_supported, 0), /* 2805 */ | |
218 MAK_FUNC_N(primitive_not_supported, 0), /* 2806 */ | |
219 MAK_FUNC_N(primitive_not_supported, 0) /* 2807 */ | |
220 #ifdef _SNDCP_MEAN_TRACE_ | |
221 , | |
222 MAK_FUNC_0(sndcp_sn_count_req, SN_COUNT_REQ) /* 2808 */ | |
223 #endif | |
224 , | |
225 MAK_FUNC_0(mg_sn_switch_req, SN_SWITCH_REQ) /* 2809 */ | |
226 }; | |
227 | |
228 #else /*#ifndef SNDCP_UPM_INCLUDED*/ | |
229 | |
230 static const T_FUNC sn_table[] = | |
231 { /* edge mode */ | |
232 MAK_FUNC_0(mg_snsm_activate_ind, SN_ACTIVATE_REQ), /*0x8000009E */ | |
233 MAK_FUNC_0(mg_snsm_deactivate_ind, SN_DEACTIVATE_REQ), /*0x8001009E */ | |
234 #ifdef TI_DUAL_MODE | |
235 MAK_FUNC_0(mg_get_pending_pdu_req, SN_GET_PENDING_PDU_REQ), /*0x8002009E */ | |
236 #else | |
237 MAK_FUNC_N(primitive_not_supported, SN_GET_PENDING_PDU_REQ), /* 0x8002009E */ | |
238 #endif | |
239 MAK_FUNC_0(mg_snsm_modify_ind, SN_MODIFY_REQ), /*0x8003009E */ | |
240 MAK_FUNC_0(mg_snsm_sequence_ind, SN_SEQUENCE_REQ), /*0x8004009E */ | |
241 MAK_FUNC_0(sndcp_sn_count_req, SN_COUNT_REQ), /*0x8005009E */ | |
242 MAK_FUNC_0(mg_sn_dti_req, SN_DTI_REQ) /*0x8006009E */ | |
243 | |
244 }; | |
245 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
246 | |
247 static const T_FUNC ll_table[] = | |
248 { | |
249 MAK_FUNC_0(mg_ll_reset_ind, LL_RESET_IND), /* 6200 */ | |
250 MAK_FUNC_S(mg_ll_establish_cnf, LL_ESTABLISH_CNF), /* 6201 */ | |
251 MAK_FUNC_S(mg_ll_establish_ind, LL_ESTABLISH_IND), /* 6202 */ | |
252 MAK_FUNC_0(mg_ll_release_cnf, LL_RELEASE_CNF), /* 6203 */ | |
253 MAK_FUNC_0(mg_ll_release_ind, LL_RELEASE_IND), /* 6204 */ | |
254 MAK_FUNC_S(mg_ll_xid_cnf, LL_XID_CNF), /* 6205 */ | |
255 MAK_FUNC_S(mg_ll_xid_ind, LL_XID_IND), /* 6206 */ | |
256 MAK_FUNC_0(sua_ll_ready_ind, LL_READY_IND), /* 6207 */ | |
257 MAK_FUNC_0(su_ll_unitready_ind, LL_UNITREADY_IND), /* 6208 */ | |
258 MAK_FUNC_0(sua_ll_data_cnf, LL_DATA_CNF), /* 6209 */ | |
259 MAK_FUNC_S(pda_ll_data_ind, LL_DATA_IND), /* 620A */ | |
260 MAK_FUNC_S(pd_ll_unitdata_ind, LL_UNITDATA_IND), /* 620B */ | |
261 MAK_FUNC_0(mg_ll_status_ind, LL_STATUS_IND) /* 620C */ | |
262 }; | |
263 | |
264 #ifdef _SNDCP_DTI_2_ | |
265 | |
266 /* | |
267 * Jumptable for the DTI service access point for downlink data transmission. | |
268 * Contains the processing-function addresses and opcodes of | |
269 * indication and confirm primitives. Use of DTILIB can be selected. | |
270 * | |
271 */ | |
272 | |
273 LOCAL const T_FUNC ddl_table_dti[] = { | |
274 | |
275 MAK_FUNC_0(sndcp_dti_dti_connect_ind, DTI2_CONNECT_IND), /* 7750 */ | |
276 MAK_FUNC_0(sndcp_dti_dti_connect_cnf, DTI2_CONNECT_CNF), /* 7751 */ | |
277 MAK_FUNC_0(sndcp_dti_dti_disconnect_ind, DTI2_DISCONNECT_IND), /* 7752 */ | |
278 MAK_FUNC_0(sndcp_dti_dti_ready_ind, DTI2_READY_IND), /* 7753 */ | |
279 MAK_FUNC_0(sndcp_dti_dti_data_ind, DTI2_DATA_IND) /* 7754 */ | |
280 | |
281 #if defined (_SIMULATION_) | |
282 , | |
283 MAK_FUNC_0(sndcp_dti_dti_data_test_ind, DTI2_DATA_TEST_IND) /* 7755 */ | |
284 #endif | |
285 | |
286 }; | |
287 | |
288 /* | |
289 * Jumptable for the DTI service access point for uplink data transmission. | |
290 * Contains the processing-function addresses and opcodes of | |
291 * request and response primitives. | |
292 */ | |
293 | |
294 | |
295 LOCAL const T_FUNC dul_table_dti[] = { | |
296 | |
297 MAK_FUNC_0(sndcp_dti_dti_connect_req, DTI2_CONNECT_REQ), /*0x3750*/ | |
298 MAK_FUNC_0(sndcp_dti_dti_connect_res, DTI2_CONNECT_RES), /*0x3751*/ | |
299 MAK_FUNC_0(sndcp_dti_dti_disconnect_req, DTI2_DISCONNECT_REQ), /*0x3752*/ | |
300 MAK_FUNC_0(sndcp_dti_dti_getdata_req, DTI2_GETDATA_REQ), /*0x3753*/ | |
301 MAK_FUNC_0(sndcp_dti_dti_data_req, DTI2_DATA_REQ) /*0x3754*/ | |
302 | |
303 #if defined (_SIMULATION_) | |
304 , | |
305 MAK_FUNC_0(sndcp_dti_dti_data_test_req, DTI2_DATA_TEST_REQ), /*0x3755*/ | |
306 MAK_FUNC_N(primitive_not_supported, DTI2_DUMMY_REQ) /*0x3756*/ | |
307 #endif /* _SIMULATION_ */ | |
308 }; | |
309 | |
310 #else /*_SNDCP_DTI_2_*/ | |
311 | |
312 /* | |
313 * Jumptable for the DTI service access point for uplink data transmission. | |
314 * Contains the processing-function addresses and opcodes of | |
315 * request and response primitives. | |
316 */ | |
317 | |
318 LOCAL const T_FUNC dul_table_dti[] = { | |
319 | |
320 MAK_FUNC_0(sndcp_dti_dti_getdata_req, DTI_GETDATA_REQ), | |
321 MAK_FUNC_0(sndcp_dti_dti_data_req, DTI_DATA_REQ) | |
322 | |
323 #if defined (_SIMULATION_) | |
324 , | |
325 MAK_FUNC_S(sndcp_dti_dti_data_test_req, DTI_DATA_TEST_REQ) | |
326 #endif /* _SIMULATION_ */ | |
327 }; | |
328 | |
329 | |
330 /* | |
331 * Jumptable for the DTI service access point for downlink data transmission. | |
332 * Contains the processing-function addresses and opcodes of | |
333 * indication and confirm primitives. Use of DTILIB can be selected. | |
334 * | |
335 */ | |
336 | |
337 | |
338 LOCAL const T_FUNC ddl_table_dti[] = { | |
339 | |
340 MAK_FUNC_0(sndcp_dti_dti_ready_ind, DTI_READY_IND), | |
341 MAK_FUNC_0(sndcp_dti_dti_data_ind, DTI_DATA_IND) | |
342 | |
343 #if defined (_SIMULATION_) | |
344 , | |
345 MAK_FUNC_S(sndcp_dti_dti_data_test_ind, DTI_DATA_TEST_IND) | |
346 #endif | |
347 }; | |
348 #endif /* SNDCP_DTI_2_ */ | |
349 | |
350 /*==== DIAGNOSTICS ==========================================================*/ | |
351 | |
352 /*==== END DIAGNOSTICS ======================================================*/ | |
353 | |
354 /*==== PRIVATE FUNCTIONS ====================================================*/ | |
355 | |
356 /* | |
357 +------------------------------------------------------------------------------ | |
358 | Function : primitive_not_supported | |
359 +------------------------------------------------------------------------------ | |
360 | Description : This function handles unsupported primitives. | |
361 | | |
362 | Parameters : - | |
363 | | |
364 | Return : - | |
365 | | |
366 +------------------------------------------------------------------------------ | |
367 */ | |
368 LOCAL void primitive_not_supported (void *data) | |
369 { | |
370 TRACE_FUNCTION ("primitive_not_supported"); | |
371 | |
372 PFREE (data); | |
373 } | |
374 | |
375 #ifdef _SNDCP_DTI_2_ | |
376 /* | |
377 +------------------------------------------------------------------------------ | |
378 | Function : sndcp_dti_dti_connect_cnf | |
379 +------------------------------------------------------------------------------ | |
380 | Description : This function handles primitive DTI_DTI2_CONNECT_CNF. | |
381 | | |
382 | Parameters : received primitive | |
383 | | |
384 | Return : - | |
385 | | |
386 +------------------------------------------------------------------------------ | |
387 */ | |
388 LOCAL void sndcp_dti_dti_connect_cnf (T_DTI2_CONNECT_CNF *dti2_connect_cnf) | |
389 { | |
390 TRACE_FUNCTION ("sndcp_dti_dti_connect_cnf"); | |
391 | |
392 dti_dti_connect_cnf (sndcp_data->hDTI, dti2_connect_cnf); | |
393 } | |
394 | |
395 | |
396 /* | |
397 +------------------------------------------------------------------------------ | |
398 | Function : sndcp_dti_dti_connect_ind | |
399 +------------------------------------------------------------------------------ | |
400 | Description : This function handles primitive DTI_DTI2_CONNECT_IND. | |
401 | | |
402 | Parameters : received primitive | |
403 | | |
404 | Return : - | |
405 | | |
406 +------------------------------------------------------------------------------ | |
407 */ | |
408 LOCAL void sndcp_dti_dti_connect_ind (T_DTI2_CONNECT_IND *dti2_connect_ind) | |
409 { | |
410 TRACE_FUNCTION ("sndcp_dti_dti_connect_ind"); | |
411 | |
412 dti_dti_connect_ind (sndcp_data->hDTI, dti2_connect_ind); | |
413 } | |
414 | |
415 /* | |
416 +------------------------------------------------------------------------------ | |
417 | Function : sndcp_dti_dti_disconnect_ind | |
418 +------------------------------------------------------------------------------ | |
419 | Description : This function handles primitive DTI_DTI2_DISCONNECT_IND. | |
420 | | |
421 | Parameters : received primitive | |
422 | | |
423 | Return : - | |
424 | | |
425 +------------------------------------------------------------------------------ | |
426 */ | |
427 LOCAL void sndcp_dti_dti_disconnect_ind (T_DTI2_DISCONNECT_IND *dti2_disconnect_ind) | |
428 { | |
429 TRACE_FUNCTION ("sndcp_dti_dti_disconnect_ind"); | |
430 | |
431 dti_dti_disconnect_ind (sndcp_data->hDTI, dti2_disconnect_ind); | |
432 } | |
433 | |
434 /* | |
435 +------------------------------------------------------------------------------ | |
436 | Function : sndcp_dti_dti_getdata_req | |
437 +------------------------------------------------------------------------------ | |
438 | Description : This function handles primitive DTI_DTI_GETDATA_REQ. | |
439 | | |
440 | Parameters : received primitive | |
441 | | |
442 | Return : - | |
443 | | |
444 +------------------------------------------------------------------------------ | |
445 */ | |
446 | |
447 LOCAL void sndcp_dti_dti_getdata_req (T_DTI2_GETDATA_REQ *dti2_getdata_req) | |
448 { | |
449 TRACE_FUNCTION ("sndcp_dti_dti_getdata_req"); | |
450 | |
451 dti_dti_getdata_req (sndcp_data->hDTI, dti2_getdata_req); | |
452 } | |
453 | |
454 /* | |
455 +------------------------------------------------------------------------------ | |
456 | Function : sndcp_dti_dti_data_req | |
457 +------------------------------------------------------------------------------ | |
458 | Description : This function handles primitive DTI_DTI_DATA_REQ. | |
459 | | |
460 | Parameters : received primitive | |
461 | | |
462 | Return : - | |
463 | | |
464 +------------------------------------------------------------------------------ | |
465 */ | |
466 LOCAL void sndcp_dti_dti_data_req (T_DTI2_DATA_REQ *dti2_data_req) | |
467 { | |
468 TRACE_FUNCTION ("sndcp_dti_dti_data_req"); | |
469 | |
470 dti_dti_data_req (sndcp_data->hDTI, dti2_data_req); | |
471 } | |
472 | |
473 /* | |
474 +------------------------------------------------------------------------------ | |
475 | Function : sndcp_dti_dti_data_test_req | |
476 +------------------------------------------------------------------------------ | |
477 | Description : This function handles primitive DTI_DTI_DATA_TEST_REQ. | |
478 | | |
479 | Parameters : received primitive | |
480 | | |
481 | Return : - | |
482 | | |
483 +------------------------------------------------------------------------------ | |
484 */ | |
485 #ifdef _SIMULATION_ | |
486 LOCAL void sndcp_dti_dti_data_test_req (T_DTI2_DATA_TEST_REQ | |
487 *dti2_data_test_req) | |
488 { | |
489 TRACE_FUNCTION ("sndcp_dti_dti_data_test_req"); | |
490 | |
491 dti_dti_data_test_req (sndcp_data->hDTI, dti2_data_test_req); | |
492 } | |
493 #endif | |
494 | |
495 /* | |
496 +------------------------------------------------------------------------------ | |
497 | Function : sndcp_dti_dti_data_ind | |
498 +------------------------------------------------------------------------------ | |
499 | Description : This function handles primitive DTI_DTI_DATA_IND. | |
500 | | |
501 | Parameters : received primitive | |
502 | | |
503 | Return : - | |
504 | | |
505 +------------------------------------------------------------------------------ | |
506 */ | |
507 LOCAL void sndcp_dti_dti_data_ind (T_DTI2_DATA_IND *dti2_data_ind) | |
508 { | |
509 TRACE_FUNCTION ("sndcp_dti_dti_data_ind"); | |
510 | |
511 dti_dti_data_ind (sndcp_data->hDTI, dti2_data_ind); | |
512 } | |
513 | |
514 /* | |
515 +------------------------------------------------------------------------------ | |
516 | Function : sndcp_dti_dti_ready_ind | |
517 +------------------------------------------------------------------------------ | |
518 | Description : This function handles primitive DTI_DTI_READY_IND. | |
519 | | |
520 | Parameters : received primitive | |
521 | | |
522 | Return : - | |
523 | | |
524 +------------------------------------------------------------------------------ | |
525 */ | |
526 LOCAL void sndcp_dti_dti_ready_ind (T_DTI2_READY_IND *dti2_ready_ind) | |
527 { | |
528 TRACE_FUNCTION ("sndcp_dti_dti_ready_ind"); | |
529 | |
530 dti_dti_ready_ind (sndcp_data->hDTI, dti2_ready_ind); | |
531 } | |
532 | |
533 /* | |
534 +------------------------------------------------------------------------------ | |
535 | Function : sndcp_dti_dti_data_test_ind | |
536 +------------------------------------------------------------------------------ | |
537 | Description : This function handles primitive DTI_DTI_DATA_TEST_IND. | |
538 | | |
539 | Parameters : received primitive | |
540 | | |
541 | Return : - | |
542 | | |
543 +------------------------------------------------------------------------------ | |
544 */ | |
545 #ifdef _SIMULATION_ | |
546 LOCAL void sndcp_dti_dti_data_test_ind (T_DTI2_DATA_TEST_IND *dti2_data_test_ind) | |
547 { | |
548 TRACE_FUNCTION ("sndcp_dti_dti_data_test_ind"); | |
549 | |
550 dti_dti_data_test_ind (sndcp_data->hDTI, dti2_data_test_ind); | |
551 } | |
552 #endif | |
553 | |
554 /* | |
555 +------------------------------------------------------------------------------ | |
556 | Function : sndcp_dti_dti_connect_req | |
557 +------------------------------------------------------------------------------ | |
558 | Description : This function handles primitive DTI_DTI_DATA_REQ. | |
559 | | |
560 | Parameters : received primitive | |
561 | | |
562 | Return : - | |
563 | | |
564 +------------------------------------------------------------------------------ | |
565 */ | |
566 LOCAL void sndcp_dti_dti_connect_req (T_DTI2_CONNECT_REQ *dti2_connect_req) | |
567 { | |
568 TRACE_FUNCTION ("sndcp_dti_dti_connect_req"); | |
569 | |
570 dti_dti_connect_req (sndcp_data->hDTI, dti2_connect_req); | |
571 | |
572 /* | |
573 * FreeCalypso: the following code has been #if 0'ed out because | |
574 * (a) it fails compilation in the TCS211-like environment with that | |
575 * compiler version, (b) it is broken fundamentally in that one needs | |
576 * to call strcmp() or equivalent instead of comparing a pointer | |
577 * against a string literal, and (c) we are not doing in-baseband TCP/IP | |
578 * in FreeCalypso, hence it was easier to remove this code than to | |
579 * work out the correct fix. | |
580 */ | |
581 | |
582 #if 0 | |
583 if ( sndcp_data->nsapi_neighbor_ra[sndcp_data->nsapi] EQ TCPIP_NAME) | |
584 { | |
585 mg_dti_open(sndcp_data->nsapi); | |
586 } | |
587 #endif | |
588 } | |
589 /* | |
590 +------------------------------------------------------------------------------ | |
591 | Function : sndcp_dti_dti_connect_res | |
592 +------------------------------------------------------------------------------ | |
593 | Description : This function handles primitive DTI_DTI_DATA_REQ. | |
594 | | |
595 | Parameters : received primitive | |
596 | | |
597 | Return : - | |
598 | | |
599 +------------------------------------------------------------------------------ | |
600 */ | |
601 LOCAL void sndcp_dti_dti_connect_res (T_DTI2_CONNECT_RES *dti2_connect_res) | |
602 { | |
603 TRACE_FUNCTION ("sndcp_dti_dti_connect_res"); | |
604 | |
605 dti_dti_connect_res (sndcp_data->hDTI, dti2_connect_res); | |
606 } | |
607 /* | |
608 +------------------------------------------------------------------------------ | |
609 | Function : sndcp_dti_dti_disconnect_req | |
610 +------------------------------------------------------------------------------ | |
611 | Description : This function handles primitive DTI_DTI_DATA_REQ. | |
612 | | |
613 | Parameters : received primitive | |
614 | | |
615 | Return : - | |
616 | | |
617 +------------------------------------------------------------------------------ | |
618 */ | |
619 LOCAL void sndcp_dti_dti_disconnect_req (T_DTI2_DISCONNECT_REQ *dti2_disconnect_req) | |
620 { | |
621 TRACE_FUNCTION ("sndcp_dti_dti_disconnect_req"); | |
622 | |
623 dti_dti_disconnect_req (sndcp_data->hDTI, dti2_disconnect_req); | |
624 } | |
625 | |
626 | |
627 #else /* _SNDCP_DTI_2_ */ | |
628 | |
629 /* | |
630 +------------------------------------------------------------------------------ | |
631 | Function : sndcp_dti_dti_getdata_req | |
632 +------------------------------------------------------------------------------ | |
633 | Description : This function handles primitive DTI_DTI_GETDATA_REQ. | |
634 | | |
635 | Parameters : received primitive | |
636 | | |
637 | Return : - | |
638 | | |
639 +------------------------------------------------------------------------------ | |
640 */ | |
641 | |
642 LOCAL void sndcp_dti_dti_getdata_req (T_DTI_GETDATA_REQ *dti_getdata_req) | |
643 { | |
644 TRACE_FUNCTION ("sndcp_dti_dti_getdata_req"); | |
645 | |
646 dti_dti_getdata_req (sndcp_data->hDTI, dti_getdata_req); | |
647 } | |
648 | |
649 /* | |
650 +------------------------------------------------------------------------------ | |
651 | Function : sndcp_dti_dti_data_req | |
652 +------------------------------------------------------------------------------ | |
653 | Description : This function handles primitive DTI_DTI_DATA_REQ. | |
654 | | |
655 | Parameters : received primitive | |
656 | | |
657 | Return : - | |
658 | | |
659 +------------------------------------------------------------------------------ | |
660 */ | |
661 LOCAL void sndcp_dti_dti_data_req (T_DTI_DATA_REQ *dti_data_req) | |
662 { | |
663 TRACE_FUNCTION ("sndcp_dti_dti_data_req"); | |
664 | |
665 dti_dti_data_req (sndcp_data->hDTI, dti_data_req); | |
666 } | |
667 | |
668 /* | |
669 +------------------------------------------------------------------------------ | |
670 | Function : sndcp_dti_dti_data_test_req | |
671 +------------------------------------------------------------------------------ | |
672 | Description : This function handles primitive DTI_DTI_DATA_TEST_REQ. | |
673 | | |
674 | Parameters : received primitive | |
675 | | |
676 | Return : - | |
677 | | |
678 +------------------------------------------------------------------------------ | |
679 */ | |
680 #ifdef _SIMULATION_ | |
681 LOCAL void sndcp_dti_dti_data_test_req (T_DTI_DATA_TEST_REQ | |
682 *dti_data_test_req) | |
683 { | |
684 TRACE_FUNCTION ("sndcp_dti_dti_data_test_req"); | |
685 | |
686 dti_dti_data_test_req (sndcp_data->hDTI, dti_data_test_req); | |
687 } | |
688 #endif | |
689 | |
690 /* | |
691 +------------------------------------------------------------------------------ | |
692 | Function : sndcp_dti_dti_data_ind | |
693 +------------------------------------------------------------------------------ | |
694 | Description : This function handles primitive DTI_DTI_DATA_IND. | |
695 | | |
696 | Parameters : received primitive | |
697 | | |
698 | Return : - | |
699 | | |
700 +------------------------------------------------------------------------------ | |
701 */ | |
702 LOCAL void sndcp_dti_dti_data_ind (T_DTI_DATA_IND *dti_data_ind) | |
703 { | |
704 TRACE_FUNCTION ("sndcp_dti_dti_data_ind"); | |
705 | |
706 dti_dti_data_ind (sndcp_data->hDTI, dti_data_ind); | |
707 } | |
708 | |
709 /* | |
710 +------------------------------------------------------------------------------ | |
711 | Function : sndcp_dti_dti_ready_ind | |
712 +------------------------------------------------------------------------------ | |
713 | Description : This function handles primitive DTI_DTI_READY_IND. | |
714 | | |
715 | Parameters : received primitive | |
716 | | |
717 | Return : - | |
718 | | |
719 +------------------------------------------------------------------------------ | |
720 */ | |
721 LOCAL void sndcp_dti_dti_ready_ind (T_DTI_READY_IND *dti_ready_ind) | |
722 { | |
723 TRACE_FUNCTION ("sndcp_dti_dti_ready_ind"); | |
724 | |
725 dti_dti_ready_ind (sndcp_data->hDTI, dti_ready_ind); | |
726 } | |
727 | |
728 /* | |
729 +------------------------------------------------------------------------------ | |
730 | Function : sndcp_dti_dti_data_test_ind | |
731 +------------------------------------------------------------------------------ | |
732 | Description : This function handles primitive DTI_DTI_DATA_TEST_IND. | |
733 | | |
734 | Parameters : received primitive | |
735 | | |
736 | Return : - | |
737 | | |
738 +------------------------------------------------------------------------------ | |
739 */ | |
740 #ifdef _SIMULATION_ | |
741 LOCAL void sndcp_dti_dti_data_test_ind (T_DTI_DATA_TEST_IND *dti_data_test_ind) | |
742 { | |
743 TRACE_FUNCTION ("sndcp_dti_dti_data_test_ind"); | |
744 | |
745 dti_dti_data_test_ind (sndcp_data->hDTI, dti_data_test_ind); | |
746 } | |
747 #endif | |
748 | |
749 #endif /* _SNDCP_DTI_2_ */ | |
750 | |
751 | |
752 /*==== PUBLIC FUNCTIONS =====================================================*/ | |
753 | |
754 /* | |
755 +------------------------------------------------------------------------------ | |
756 | Function : pei_primitive | |
757 +------------------------------------------------------------------------------ | |
758 | Description : This function is called by the frame when a primitive is | |
759 | received and needs to be processed. | |
760 | | |
761 | | | |
762 | MMI UPLINK | |
763 | | | |
764 | +-------------v------------+ | |
765 | | | | |
766 | | SNDCP | | |
767 | | | | |
768 | +------^------^-----^------+ | |
769 | | | | | |
770 | SM CCI LLC DOWNLINK | |
771 | | | | | |
772 | | |
773 | | |
774 | Parameters : prim - Pointer to the received primitive | |
775 | | |
776 | Return : PEI_OK - function succeeded | |
777 | PEI_ERROR - function failed | |
778 | | |
779 +------------------------------------------------------------------------------ | |
780 */ | |
781 | |
782 LOCAL SHORT pei_primitive (void * primptr) | |
783 { | |
784 TRACE_FUNCTION ("pei_primitive"); | |
785 | |
786 if (primptr NEQ NULL) | |
787 { | |
788 T_PRIM *prim = (T_PRIM *)primptr; | |
789 #ifdef SNDCP_UPM_INCLUDED | |
790 U32 opc = (prim->custom.opc); | |
791 #else | |
792 USHORT opc = (USHORT)(prim->custom.opc); | |
793 #endif | |
794 USHORT n; | |
795 const T_FUNC *table; | |
796 | |
797 /* | |
798 * This must be called for Partition Pool supervision. Will be replaced | |
799 * by another macro some time. | |
800 */ | |
801 VSI_PPM_REC (&prim->custom, __FILE__, __LINE__); | |
802 | |
803 #ifdef SNDCP_UPM_INCLUDED | |
804 PTRACE_IN (opc); | |
805 | |
806 switch (SAP_NR(opc)) | |
807 { | |
808 case SAP_NR(SN_UL): | |
809 table = sn_table; | |
810 n = TAB_SIZE (sn_table); | |
811 break; | |
812 case SAP_NR(LL_DL): | |
813 table = ll_table; | |
814 n = TAB_SIZE (ll_table); | |
815 break; | |
816 case DTI2_DL: | |
817 opc -= 0x50; | |
818 table = ddl_table_dti; | |
819 n = TAB_SIZE (ddl_table_dti); | |
820 break; | |
821 case DTI2_UL: | |
822 opc -= 0x50; | |
823 table = dul_table_dti; | |
824 n = TAB_SIZE (dul_table_dti); | |
825 break; | |
826 default: | |
827 table = NULL; | |
828 n = 0; | |
829 break; | |
830 } | |
831 #else /*#ifdef SNDCP_UPM_INCLUDED*/ | |
832 | |
833 PTRACE_IN (opc); | |
834 | |
835 switch (SAP_NR(opc)) | |
836 { | |
837 case SAP_NR(SN_UL): | |
838 table = sn_table; | |
839 n = TAB_SIZE (sn_table); | |
840 break; | |
841 case SNSM_DL: | |
842 table = snsm_table; | |
843 n = TAB_SIZE (snsm_table); | |
844 break; | |
845 case SAP_NR(LL_DL): | |
846 table = ll_table; | |
847 n = TAB_SIZE (ll_table); | |
848 break; | |
849 #ifdef _SNDCP_DTI_2_ | |
850 case DTI2_DL: | |
851 opc -= 0x50; | |
852 table = ddl_table_dti; | |
853 n = TAB_SIZE (ddl_table_dti); | |
854 break; | |
855 case DTI2_UL: | |
856 opc -= 0x50; | |
857 table = dul_table_dti; | |
858 n = TAB_SIZE (dul_table_dti); | |
859 break; | |
860 #else /* _SNDCP_DTI_2_ */ | |
861 case DTI_DL: | |
862 table = ddl_table_dti; | |
863 n = TAB_SIZE (ddl_table_dti); | |
864 break; | |
865 case DTI_UL: | |
866 table = dul_table_dti; | |
867 n = TAB_SIZE (dul_table_dti); | |
868 break; | |
869 #endif /* _SNDCP_DTI_2_ */ | |
870 default: | |
871 table = NULL; | |
872 n = 0; | |
873 break; | |
874 } | |
875 #endif | |
876 if (table != NULL) | |
877 { | |
878 #ifdef SNDCP_UPM_INCLUDED | |
879 if ((PRIM_NR(opc)) < n) | |
880 { | |
881 table += PRIM_NR(opc); | |
882 #else | |
883 if ((opc & PRM_MASK) < n) | |
884 { | |
885 table += opc & PRM_MASK; | |
886 #endif | |
887 #ifdef PALLOC_TRANSITION | |
888 P_SDU(prim) = | |
889 table->soff ? (T_sdu*) | |
890 (((char*)&prim->data) + table->soff) : 0; | |
891 #ifndef NO_COPY_ROUTING | |
892 P_LEN(prim) = table->size + sizeof (T_PRIM_HEADER); | |
893 #endif /* NO_COPY_ROUTING */ | |
894 #endif /* PALLOC_TRANSITION */ | |
895 JUMP (table->func) (P2D(prim)); | |
896 } | |
897 else | |
898 { | |
899 primitive_not_supported (P2D(prim)); | |
900 } | |
901 return PEI_OK; | |
902 } | |
903 | |
904 /* | |
905 * primitive is not a GSM primitive - forward it to the environment | |
906 */ | |
907 if (opc & SYS_MASK) | |
908 vsi_c_primitive (VSI_CALLER prim); | |
909 else | |
910 { | |
911 PFREE (P2D(prim)); | |
912 return PEI_ERROR; | |
913 } | |
914 } | |
915 return PEI_OK; | |
916 } | |
917 | |
918 | |
919 /* | |
920 +------------------------------------------------------------------------------ | |
921 | Function : pei_init | |
922 +------------------------------------------------------------------------------ | |
923 | Description : This function is called by the frame. It is used to initialise | |
924 | the entitiy. | |
925 | | |
926 | Parameters : handle - task handle | |
927 | | |
928 | Return : PEI_OK - entity initialised | |
929 | PEI_ERROR - entity not (yet) initialised | |
930 | | |
931 +------------------------------------------------------------------------------ | |
932 */ | |
933 | |
934 | |
935 LOCAL SHORT pei_init (T_HANDLE handle) | |
936 { | |
937 #ifdef FLOW_TRACE | |
938 UBYTE i = 0; | |
939 UBYTE j = 0; | |
940 UBYTE k = 0; | |
941 #endif | |
942 | |
943 TRACE_FUNCTION ("pei_init"); | |
944 | |
945 /* | |
946 * Initialize task handle | |
947 */ | |
948 SNDCP_handle = handle; | |
949 | |
950 /* | |
951 * Open communication channels | |
952 */ | |
953 if (hCommMMI < VSI_OK) | |
954 { | |
955 | |
956 #ifdef _SNDCP_DTI_2_ | |
957 if ((hCommMMI = vsi_c_open (VSI_CALLER ACI_NAME)) < VSI_OK) | |
958 return PEI_ERROR; | |
959 } | |
960 #else /* _SNDCP_DTI_2_ */ | |
961 if ((hCommMMI = vsi_c_open (VSI_CALLER MMI_NAME)) < VSI_OK) | |
962 return PEI_ERROR; | |
963 } | |
964 #endif /* _SNDCP_DTI_2_ */ | |
965 | |
966 | |
967 #ifdef SNDCP_UPM_INCLUDED | |
968 if (hCommUPM < VSI_OK) | |
969 { | |
970 if ((hCommUPM = vsi_c_open (VSI_CALLER UPM_NAME)) < VSI_OK) | |
971 return PEI_ERROR; | |
972 } | |
973 #else | |
974 if (hCommSM < VSI_OK) | |
975 { | |
976 if ((hCommSM = vsi_c_open (VSI_CALLER SM_NAME)) < VSI_OK) | |
977 return PEI_ERROR; | |
978 } | |
979 | |
980 #endif /*#ifdef SNDCP_UPM_INCLUDED*/ | |
981 | |
982 if (hCommLLC < VSI_OK) | |
983 { | |
984 if ((hCommLLC = vsi_c_open (VSI_CALLER LLC_NAME)) < VSI_OK) | |
985 return PEI_ERROR; | |
986 } | |
987 | |
988 /* | |
989 * Initialize global pointer sndcp_data. This is required to access all | |
990 * entity data. | |
991 */ | |
992 sndcp_data = &sndcp_data_base; | |
993 | |
994 | |
995 #ifdef FLOW_TRACE | |
996 for(i = 0; i < 5; i++) { | |
997 for (j = 0; j < 2; j++) { | |
998 for (k = 0; j < 2; j++) { | |
999 sndcp_trace_flow_control(i, j, k, FALSE); | |
1000 } | |
1001 } | |
1002 } | |
1003 #endif | |
1004 | |
1005 | |
1006 /* | |
1007 * Initialize global data. | |
1008 * | |
1009 * These arrays are not reset here: | |
1010 * nsapi_qos_ra, | |
1011 * nsapi_sapi_ra, | |
1012 * nsapi_prio_ra, | |
1013 * nsapi_tlli_ra, | |
1014 * | |
1015 */ | |
1016 { | |
1017 UBYTE nsapi = 0; | |
1018 UBYTE sapi_index = 0; | |
1019 for (nsapi = 0; nsapi < SNDCP_NUMBER_OF_NSAPIS; nsapi++) { | |
1020 sndcp_data->nsapi_used_ra[nsapi] = FALSE; | |
1021 sndcp_data->nsapi_ack_ra[nsapi] = FALSE; | |
1022 sndcp_data->nsapi_state_ra[nsapi] = MG_IDLE; | |
1023 | |
1024 sndcp_data->nsapi_direction_ra[nsapi] = FALSE; | |
1025 sndcp_data->nsapi_interface_ra[nsapi] = SNDCP_INTERFACE_UNACK; | |
1026 sndcp_data->nsapi_linkid_ra[nsapi] = 0; | |
1027 sndcp_data->nsapi_neighbor_ra[nsapi] = NULL; | |
1028 | |
1029 sndcp_data->cur_segment_number[nsapi] = 0; | |
1030 | |
1031 #ifdef _SNDCP_MEAN_TRACE_ | |
1032 | |
1033 sndcp_data->start_time_uplink_ack [nsapi] = 0; | |
1034 sndcp_data->start_time_uplink_unack [nsapi] = 0; | |
1035 sndcp_data->start_time_downlink_ack [nsapi] = 0; | |
1036 sndcp_data->start_time_downlink_unack [nsapi] = 0; | |
1037 | |
1038 sndcp_data->cur_time_uplink_ack [nsapi] = 0; | |
1039 sndcp_data->cur_time_uplink_unack [nsapi] = 0; | |
1040 sndcp_data->cur_time_downlink_ack [nsapi] = 0; | |
1041 sndcp_data->cur_time_downlink_unack [nsapi] = 0; | |
1042 | |
1043 sndcp_data->cur_num_uplink_ack [nsapi] = 0; | |
1044 sndcp_data->cur_num_uplink_unack [nsapi] = 0; | |
1045 sndcp_data->cur_num_downlink_ack [nsapi] = 0; | |
1046 sndcp_data->cur_num_downlink_unack [nsapi] = 0; | |
1047 | |
1048 sndcp_data->cur_pac_uplink_ack [nsapi] = 0; | |
1049 sndcp_data->cur_pac_uplink_unack [nsapi] = 0; | |
1050 sndcp_data->cur_pac_downlink_ack [nsapi] = 0; | |
1051 sndcp_data->cur_pac_downlink_unack [nsapi] = 0; | |
1052 #ifndef NCONFIG | |
1053 sndcp_data->data_count[nsapi] = 0; | |
1054 #endif | |
1055 | |
1056 | |
1057 #endif /* _SNDCP_MEAN_TRACE_ */ | |
1058 } | |
1059 for (sapi_index = 0; sapi_index < SNDCP_NUMBER_OF_SAPIS; sapi_index++) { | |
1060 sndcp_data->sapi_ack_ra[sapi_index] = FALSE; | |
1061 sndcp_data->sapi_state_ra[sapi_index] = MG_IDLE; | |
1062 } | |
1063 } | |
1064 | |
1065 sndcp_data->vj_count = 0; | |
1066 sndcp_data->always_xid = TRUE; | |
1067 | |
1068 #ifndef NCONFIG | |
1069 sndcp_data->millis = 0; | |
1070 #endif | |
1071 | |
1072 sndcp_data->trace_ip_header = FALSE; | |
1073 sndcp_data->trace_ip_datagram = FALSE; | |
1074 sndcp_data->trace_ip_bin = FALSE; | |
1075 sndcp_data->ip_filter = FALSE; | |
1076 | |
1077 sndcp_data->nsapi_rcv_rdy_b4_used=0; | |
1078 | |
1079 | |
1080 /* | |
1081 * Initialize entity data (call init function of every service) | |
1082 */ | |
1083 cia_init(); | |
1084 mg_init(); | |
1085 nd_init(); | |
1086 nu_init(); | |
1087 pd_init(); | |
1088 pda_init(); | |
1089 sd_init(); | |
1090 sda_init(); | |
1091 su_init(); | |
1092 sua_init(); | |
1093 | |
1094 sndcp_data->hDTI = | |
1095 dti_init(SNDCP_MAX_DTI_LINKS, /* U8 maximum_links */ | |
1096 SNDCP_handle, /* T_HANDLE handle, */ | |
1097 #ifdef _SNDCP_DTI_2_ | |
1098 DTI_DEFAULT_OPTIONS, /* U32 */ | |
1099 #endif /* _SNDCP_DTI_2_ */ | |
1100 sndcp_sig_callback); | |
1101 | |
1102 return (PEI_OK); | |
1103 } | |
1104 | |
1105 /* | |
1106 +------------------------------------------------------------------------------ | |
1107 | Function : pei_timeout | |
1108 +------------------------------------------------------------------------------ | |
1109 | Description : This function is called by the frame when a timer has expired. | |
1110 | | |
1111 | Parameters : index - timer index | |
1112 | | |
1113 | Return : PEI_OK - timeout processed | |
1114 | PEI_ERROR - timeout not processed | |
1115 | | |
1116 +------------------------------------------------------------------------------ | |
1117 */ | |
1118 | |
1119 LOCAL SHORT pei_timeout (USHORT index) | |
1120 { | |
1121 TRACE_FUNCTION ("pei_timeout"); | |
1122 | |
1123 /* | |
1124 * Process timeout | |
1125 */ | |
1126 if (index < TIMER_MAX) { | |
1127 mg_exp_re_est_timer((UBYTE)index); | |
1128 } else { | |
1129 TRACE_ERROR("Unknown Timeout"); | |
1130 } | |
1131 | |
1132 return PEI_OK; | |
1133 } | |
1134 | |
1135 /* | |
1136 +------------------------------------------------------------------------------ | |
1137 | Function : pei_signal | |
1138 +------------------------------------------------------------------------------ | |
1139 | Description : This function is called by the frame when a signal has been | |
1140 | received. | |
1141 | | |
1142 | Parameters : opc - signal operation code | |
1143 | *data - pointer to primitive | |
1144 | | |
1145 | Return : PEI_OK - signal processed | |
1146 | PEI_ERROR - signal not processed | |
1147 | | |
1148 +------------------------------------------------------------------------------ | |
1149 */ | |
1150 LOCAL SHORT pei_signal (ULONG opc, void *data) | |
1151 { | |
1152 TRACE_FUNCTION ("pei_signal"); | |
1153 | |
1154 /* | |
1155 * Process signal | |
1156 */ | |
1157 /* | |
1158 switch (opc) | |
1159 { | |
1160 default: | |
1161 */ | |
1162 TRACE_ERROR("Unknown Signal OPC"); | |
1163 /* | |
1164 break; | |
1165 } */ | |
1166 | |
1167 return PEI_OK; | |
1168 } | |
1169 | |
1170 /* | |
1171 +------------------------------------------------------------------------------ | |
1172 | Function : pei_exit | |
1173 +------------------------------------------------------------------------------ | |
1174 | Description : This function is called by the frame when the entity is | |
1175 | terminated. All open resources are freed. | |
1176 | | |
1177 | Parameters : - | |
1178 | | |
1179 | Return : PEI_OK - exit sucessful | |
1180 | PEI_ERROR - exit not sueccessful | |
1181 | | |
1182 +------------------------------------------------------------------------------ | |
1183 */ | |
1184 LOCAL SHORT pei_exit (void) | |
1185 { | |
1186 UBYTE nsapi = 0; | |
1187 | |
1188 TRACE_FUNCTION ("pei_exit"); | |
1189 | |
1190 /* | |
1191 * Close communication channels | |
1192 */ | |
1193 vsi_c_close (VSI_CALLER hCommMMI); | |
1194 hCommMMI = VSI_ERROR; | |
1195 | |
1196 #ifdef SNDCP_UPM_INCLUDED | |
1197 vsi_c_close (VSI_CALLER hCommUPM); | |
1198 hCommUPM = VSI_ERROR; | |
1199 #else | |
1200 vsi_c_close (VSI_CALLER hCommSM); | |
1201 hCommSM = VSI_ERROR; | |
1202 #endif | |
1203 | |
1204 vsi_c_close (VSI_CALLER hCommLLC); | |
1205 hCommLLC = VSI_ERROR; | |
1206 | |
1207 for (nsapi = 0; nsapi < SNDCP_NUMBER_OF_NSAPIS; nsapi++) { | |
1208 mg_delete_npdus(nsapi); | |
1209 } | |
1210 | |
1211 dti_deinit(sndcp_data->hDTI); | |
1212 sndcp_data->hDTI = NULL; | |
1213 | |
1214 | |
1215 return PEI_OK; | |
1216 } | |
1217 | |
1218 /* | |
1219 +------------------------------------------------------------------------------ | |
1220 | Function : pei_run | |
1221 +------------------------------------------------------------------------------ | |
1222 | Description : This function is called by the frame when entering the main | |
1223 | loop. This fucntion is only required in the active variant. | |
1224 | | |
1225 | This function is not used. | |
1226 | | |
1227 | Parameters : handle - Communication handle | |
1228 | | |
1229 | Return : PEI_OK - sucessful | |
1230 | PEI_ERROR - not successful | |
1231 | | |
1232 +------------------------------------------------------------------------------ | |
1233 */ | |
1234 LOCAL SHORT pei_run (T_HANDLE TaskHandle, T_HANDLE ComHandle ) | |
1235 { | |
1236 /* | |
1237 * !!!!! Does not compile! | |
1238 * | |
1239 T_QMSG Message; | |
1240 | |
1241 TRACE_FUNCTION ("pei_run"); | |
1242 | |
1243 if (pei_init (TaskHandle) != PEI_OK) | |
1244 return PEI_ERROR; | |
1245 | |
1246 while (!exit_flag) | |
1247 { | |
1248 vsi_c_await (VSI_CALLER ComHandle, &Message); | |
1249 switch (Message.MsgType) | |
1250 { | |
1251 case MSG_PRIMITIVE: | |
1252 pei_primitive (Message.Msg.Primitive.Prim ); | |
1253 break; | |
1254 case MSG_SIGNAL: | |
1255 pei_signal ( (USHORT)Message.Msg.Signal.SigOPC, | |
1256 Message.Msg.Signal.SigBuffer ); | |
1257 break; | |
1258 case MSG_TIMEOUT: | |
1259 pei_timeout ( (USHORT)Message.Msg.Timer.Index ); | |
1260 break; | |
1261 default: | |
1262 TRACE_ERROR("Unknown Message Type"); | |
1263 break; | |
1264 } | |
1265 } | |
1266 | |
1267 * | |
1268 * | |
1269 */ | |
1270 | |
1271 return PEI_OK; | |
1272 } | |
1273 | |
1274 /* | |
1275 +------------------------------------------------------------------------------ | |
1276 | Function : pei_config | |
1277 +------------------------------------------------------------------------------ | |
1278 | Description : This function is called by the frame when a primitive is | |
1279 | received indicating dynamic configuration. | |
1280 | | |
1281 | This function is not used in this entity. | |
1282 | | |
1283 | Parameters : handle - Communication handle | |
1284 | | |
1285 | Return : PEI_OK - sucessful | |
1286 | PEI_ERROR - not successful | |
1287 | | |
1288 +------------------------------------------------------------------------------ | |
1289 */ | |
1290 LOCAL SHORT pei_config (char *inString) | |
1291 { | |
1292 TRACE_FUNCTION ("pei_config"); | |
1293 TRACE_FUNCTION (inString); | |
1294 | |
1295 #ifndef NCONFIG | |
1296 /* | |
1297 * Parse next keyword and number of variables | |
1298 */ | |
1299 | |
1300 /*if(!strcmp(inString,"DISCARD")) {*/ | |
1301 if (inString[0] == 'D' && /* DISCARD NSAPI */ | |
1302 inString[1] == 'I' && | |
1303 inString[2] == 'S' && | |
1304 inString[3] == 'C' && | |
1305 inString[4] == 'A' && | |
1306 inString[5] == 'R' && | |
1307 inString[6] == 'D') { | |
1308 | |
1309 UBYTE nsapi = (UBYTE)atoi(&inString[8]); | |
1310 | |
1311 TRACE_EVENT_P1("Each DTI2_DATA Prim on NSAPI %d will be discarded", nsapi); | |
1312 nu_config_discard(nsapi); | |
1313 } else if (inString[0] == 'R' && /* RESUME NSAPI */ | |
1314 inString[1] == 'E' && | |
1315 inString[2] == 'S' && | |
1316 inString[3] == 'U' && | |
1317 inString[4] == 'M' && | |
1318 inString[5] == 'E') { | |
1319 | |
1320 UBYTE nsapi = (UBYTE)atoi(&inString[7]); | |
1321 TRACE_EVENT_P1 ("Each DTI2_DATA Prim on NSAPI %d will be forwarded", nsapi); | |
1322 nu_config_resume(nsapi); | |
1323 } else if (inString[0] == 'S' && | |
1324 inString[1] == 'E' && | |
1325 inString[2] == 'N' && | |
1326 inString[3] == 'D') { | |
1327 | |
1328 UBYTE nsapi = (UBYTE)atoi(&inString[4]); | |
1329 | |
1330 U32 octets = (U32)atoi(&inString[7]); | |
1331 | |
1332 nu_config_send(nsapi, octets); | |
1333 | |
1334 } else if (inString[0] == 'P' && | |
1335 inString[1] == 'R' && | |
1336 inString[2] == 'I' && | |
1337 inString[3] == 'O') { | |
1338 | |
1339 UBYTE nsapi = (UBYTE)atoi(&inString[4]); | |
1340 UBYTE prio = (UBYTE)atoi(&inString[7]); | |
1341 | |
1342 sndcp_set_nsapi_prio(nsapi, prio); | |
1343 } else if (inString[0] == 'N' && | |
1344 inString[1] == 'O' && | |
1345 inString[2] == ' ' && | |
1346 inString[3] == 'X' && | |
1347 inString[4] == 'I' && | |
1348 inString[5] == 'D') { | |
1349 | |
1350 | |
1351 sndcp_no_xid(); | |
1352 | |
1353 | |
1354 } else if (inString[0] == 'D' && | |
1355 inString[1] == 'E' && | |
1356 inString[2] == 'L' && | |
1357 inString[3] == 'A' && | |
1358 inString[4] == 'Y') { | |
1359 | |
1360 USHORT millis = (USHORT)atoi(&inString[5]); | |
1361 | |
1362 mg_config_delay(millis); | |
1363 | |
1364 } else if (inString[0] == 'T' && /* TRACE_HEADER_ON */ | |
1365 inString[1] == 'R' && | |
1366 inString[2] == 'A' && | |
1367 inString[3] == 'C' && | |
1368 inString[4] == 'E' && | |
1369 inString[5] == '_' && | |
1370 inString[6] == 'H' && | |
1371 inString[7] == 'E' && | |
1372 inString[8] == 'A' && | |
1373 inString[9] == 'D' && | |
1374 inString[10] == 'E' && | |
1375 inString[11] == 'R' && | |
1376 inString[12] == '_' && | |
1377 inString[13] == 'O' && | |
1378 inString[14] == 'N') { | |
1379 sndcp_data->trace_ip_header = TRUE; | |
1380 } else if (inString[0] == 'T' && /* TRACE_HEADER_OFF */ | |
1381 inString[1] == 'R' && | |
1382 inString[2] == 'A' && | |
1383 inString[3] == 'C' && | |
1384 inString[4] == 'E' && | |
1385 inString[5] == '_' && | |
1386 inString[6] == 'H' && | |
1387 inString[7] == 'E' && | |
1388 inString[8] == 'A' && | |
1389 inString[9] == 'D' && | |
1390 inString[10] == 'E' && | |
1391 inString[11] == 'R' && | |
1392 inString[12] == '_' && | |
1393 inString[13] == 'O' && | |
1394 inString[14] == 'F' && | |
1395 inString[15] == 'F') { | |
1396 sndcp_data->trace_ip_header = FALSE; | |
1397 }else if (inString[0] == 'T' && /* TRACE_PACKET_ON */ | |
1398 inString[1] == 'R' && | |
1399 inString[2] == 'A' && | |
1400 inString[3] == 'C' && | |
1401 inString[4] == 'E' && | |
1402 inString[5] == '_' && | |
1403 inString[6] == 'P' && | |
1404 inString[7] == 'A' && | |
1405 inString[8] == 'C' && | |
1406 inString[9] == 'K' && | |
1407 inString[10] == 'E' && | |
1408 inString[11] == 'T' && | |
1409 inString[12] == '_' && | |
1410 inString[13] == 'O' && | |
1411 inString[14] == 'N') { | |
1412 sndcp_data->trace_ip_datagram = TRUE; | |
1413 } else if (inString[0] == 'T' && /* TRACE_PACKET_OFF */ | |
1414 inString[1] == 'R' && | |
1415 inString[2] == 'A' && | |
1416 inString[3] == 'C' && | |
1417 inString[4] == 'E' && | |
1418 inString[5] == '_' && | |
1419 inString[6] == 'P' && | |
1420 inString[7] == 'A' && | |
1421 inString[8] == 'C' && | |
1422 inString[9] == 'K' && | |
1423 inString[10] == 'E' && | |
1424 inString[11] == 'T' && | |
1425 inString[12] == '_' && | |
1426 inString[13] == 'O' && | |
1427 inString[14] == 'F' && | |
1428 inString[15] == 'F') { | |
1429 sndcp_data->trace_ip_datagram = FALSE; | |
1430 | |
1431 | |
1432 | |
1433 #ifdef TI_PS_OP_ICUT_SNDCP | |
1434 /* PDP_TBR added SNDCP terminal loopback */ | |
1435 } else if ( inString[0] == 'L' && | |
1436 inString[1] == 'O' && | |
1437 inString[2] == 'O' && | |
1438 inString[3] == 'P' && | |
1439 inString[4] == 'B' && | |
1440 inString[5] == 'A' && | |
1441 inString[6] == 'C' && | |
1442 inString[7] == 'K') | |
1443 { | |
1444 SNDCP_LOOPBACK = 1; | |
1445 TRACE_EVENT("SNDCP LOOPBACK"); | |
1446 | |
1447 #endif /* TI_PS_OP_ICUT_SNDCP */ | |
1448 | |
1449 } else if (inString[0] == 'T' && /* TRACE_IP_BIN */ | |
1450 inString[1] == 'R' && | |
1451 inString[2] == 'A' && | |
1452 inString[3] == 'C' && | |
1453 inString[4] == 'E' && | |
1454 inString[5] == '_' && | |
1455 inString[6] == 'I' && | |
1456 inString[7] == 'P' && | |
1457 inString[8] == '_' && | |
1458 inString[9] == 'B' && | |
1459 inString[10] == 'I' && | |
1460 inString[11] == 'N') { | |
1461 sndcp_data->trace_ip_bin = TRUE; | |
1462 } else if (inString[0] == 'I' && /* IP_FILTER_OFF */ | |
1463 inString[1] == 'P' && | |
1464 inString[2] == '_' && | |
1465 inString[3] == 'F' && | |
1466 inString[4] == 'I' && | |
1467 inString[5] == 'L' && | |
1468 inString[6] == 'T' && | |
1469 inString[7] == 'E' && | |
1470 inString[8] == 'R' && | |
1471 inString[9] == '_' && | |
1472 inString[10] == 'O' && | |
1473 inString[11] == 'F' && | |
1474 inString[12] == 'F') { | |
1475 | |
1476 TRACE_EVENT("INFO IP FILTER: IP filter is disabled."); | |
1477 sndcp_data->ip_filter = FALSE; | |
1478 } else if (inString[0] == 'I' && /* IP_FILTER_ON */ | |
1479 inString[1] == 'P' && | |
1480 inString[2] == '_' && | |
1481 inString[3] == 'F' && | |
1482 inString[4] == 'I' && | |
1483 inString[5] == 'L' && | |
1484 inString[6] == 'T' && | |
1485 inString[7] == 'E' && | |
1486 inString[8] == 'R' && | |
1487 inString[9] == '_' && | |
1488 inString[10] == 'O' && | |
1489 inString[11] == 'N') { | |
1490 | |
1491 TRACE_EVENT("INFO IP FILTER: IP filter is enabled."); | |
1492 sndcp_data->ip_filter = TRUE; | |
1493 } else { | |
1494 TRACE_EVENT("ERROR PEI SNDCP: unknown Config Primitive!"); | |
1495 } | |
1496 | |
1497 #endif | |
1498 | |
1499 return PEI_OK; | |
1500 } | |
1501 | |
1502 /* | |
1503 +------------------------------------------------------------------------------ | |
1504 | Function : pei_monitor | |
1505 +------------------------------------------------------------------------------ | |
1506 | Description : This function is called by the frame in case sudden entity | |
1507 | specific data is requested (e.g. entity Version). | |
1508 | | |
1509 | Parameters : out_monitor - return the address of the data to be | |
1510 | monitoredCommunication handle | |
1511 | | |
1512 | Return : PEI_OK - sucessful (address in out_monitor is valid) | |
1513 | PEI_ERROR - not successful | |
1514 | | |
1515 +------------------------------------------------------------------------------ | |
1516 */ | |
1517 LOCAL SHORT pei_monitor (void ** out_monitor) | |
1518 { | |
1519 TRACE_FUNCTION ("pei_monitor"); | |
1520 | |
1521 /* | |
1522 * Version = "0.S" (S = Step). | |
1523 */ | |
1524 sndcp_mon.version = "SNDCP 0.1"; | |
1525 *out_monitor = &sndcp_mon; | |
1526 | |
1527 return PEI_OK; | |
1528 } | |
1529 | |
1530 /* | |
1531 +------------------------------------------------------------------------------ | |
1532 | Function : pei_create | |
1533 +------------------------------------------------------------------------------ | |
1534 | Description : This function is called by the frame when the process is | |
1535 | created. | |
1536 | | |
1537 | Parameters : out_name - Pointer to the buffer in which to locate | |
1538 | the name of this entity | |
1539 | | |
1540 | Return : PEI_OK - entity created successfuly | |
1541 | PEI_ERROR - entity could not be created | |
1542 | | |
1543 +------------------------------------------------------------------------------ | |
1544 */ | |
1545 GLOBAL SHORT pei_create (T_PEI_INFO **info) | |
1546 { | |
1547 static T_PEI_INFO pei_info = | |
1548 { | |
1549 "SND", /* name */ | |
1550 { /* pei-table */ | |
1551 pei_init, | |
1552 pei_exit, | |
1553 pei_primitive, | |
1554 pei_timeout, | |
1555 pei_signal, | |
1556 pei_run, | |
1557 pei_config, | |
1558 pei_monitor | |
1559 }, | |
1560 1536, /* stack size */ | |
1561 10, /* queue entries */ | |
1562 185, /* priority (1->low, 255->high) */ | |
1563 TIMER_MAX, /* number of timers */ | |
1564 0x03|PRIM_NO_SUSPEND /* flags: bit 0 active(0) body/passive(1) */ | |
1565 }; /* bit 1 com by copy(0)/reference(1) */ | |
1566 | |
1567 | |
1568 TRACE_FUNCTION ("pei_create"); | |
1569 | |
1570 /* | |
1571 * Close Resources if open | |
1572 */ | |
1573 if (first_access) | |
1574 first_access = FALSE; | |
1575 else | |
1576 pei_exit(); | |
1577 | |
1578 /* | |
1579 * Export startup configuration data | |
1580 */ | |
1581 *info = &pei_info; | |
1582 | |
1583 return PEI_OK; | |
1584 } | |
1585 | |
1586 /*==== END OF FILE ==========================================================*/ |