comparison src/g23m-gprs/llc/llc_f.c @ 183:219afcfc6250

src/g23m-gprs: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 13 Oct 2016 04:24:13 +0000
parents
children
comparison
equal deleted inserted replaced
182:f02d0a0e1849 183:219afcfc6250
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
4 | Modul :
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 : Contains global functions of Logical Link Control (LLC)
18 +-----------------------------------------------------------------------------
19 */
20
21 #define LLC_F_C
22
23 #define ENTITY_LLC
24
25 /*==== INCLUDES =============================================================*/
26
27 #include "typedefs.h" /* to get Condat data types */
28 #include "vsi.h" /* to get a lot of macros */
29 #include "macdef.h"
30 #include "gprs.h"
31 #include "gsm.h" /* to get a lot of macros */
32 #include "cnf_llc.h" /* to get cnf-definitions */
33 #include "mon_llc.h" /* to get mon-definitions */
34 #include "prim.h" /* to get the definitions of used SAP and directions */
35 #include "llc.h" /* to get the global entity definitions */
36
37 #include "llc_par.h" /* to get the default values of the LLC paramters */
38 #include "llc_uf.h" /* to get the XID parameter definitions */
39
40
41 /*==== CONST ================================================================*/
42
43 /*==== LOCAL VARS ===========================================================*/
44
45 /*==== PRIVATE FUNCTIONS ====================================================*/
46
47 /*==== PUBLIC FUNCTIONS =====================================================*/
48
49
50 /*
51 +------------------------------------------------------------------------------
52 | Function : llc_init_parameters
53 +------------------------------------------------------------------------------
54 | Description : This procedure initialises the LLC layer parameters with
55 | their default values as they are defined in LLC_PAR.H.
56 |
57 | Parameters :
58 |
59 +------------------------------------------------------------------------------
60 */
61 GLOBAL void llc_init_parameters (void)
62 {
63 UBYTE incarnation;
64
65 TRACE_FUNCTION ("llc_init_parameters");
66
67 llc_data->version = LLC_VERSION_ALL_SAPIS;
68
69 llc_data->iov_ui = LLC_IOV_UI_ALL_SAPIS;
70 llc_data->iov_i_base[IMAP(LL_SAPI_3)] = LLC_IOV_I_SAPI_3;
71 llc_data->iov_i_base[IMAP(LL_SAPI_5)] = LLC_IOV_I_SAPI_5;
72 llc_data->iov_i_base[IMAP(LL_SAPI_9)] = LLC_IOV_I_SAPI_9;
73 llc_data->iov_i_base[IMAP(LL_SAPI_11)] = LLC_IOV_I_SAPI_11;
74
75 /*
76 * The LLC parameters for T200 are contained in T200 service data.
77 */
78 llc_data->t200_base[UIMAP(LL_SAPI_1)].length = LLC_T200_SAPI_1;
79 llc_data->t200_base[UIMAP(LL_SAPI_3)].length = LLC_T200_SAPI_3;
80 llc_data->t200_base[UIMAP(LL_SAPI_5)].length = LLC_T200_SAPI_5;
81 llc_data->t200_base[UIMAP(LL_SAPI_7)].length = LLC_T200_SAPI_7;
82 llc_data->t200_base[UIMAP(LL_SAPI_9)].length = LLC_T200_SAPI_9;
83 llc_data->t200_base[UIMAP(LL_SAPI_11)].length = LLC_T200_SAPI_11;
84
85 /*
86 * The LLC parameters for T201 are contained in T201 service data.
87 * T201 is being set to the same values as T200 for all SAPIs.
88 * <R.LLC.LLC_PAR.A.015>
89 */
90 llc_data->n200_base[UIMAP(LL_SAPI_1)] = LLC_N200_SAPI_1;
91 llc_data->n200_base[UIMAP(LL_SAPI_3)] = LLC_N200_SAPI_3;
92 llc_data->n200_base[UIMAP(LL_SAPI_5)] = LLC_N200_SAPI_5;
93 llc_data->n200_base[UIMAP(LL_SAPI_7)] = LLC_N200_SAPI_7;
94 llc_data->n200_base[UIMAP(LL_SAPI_9)] = LLC_N200_SAPI_9;
95 llc_data->n200_base[UIMAP(LL_SAPI_11)] = LLC_N200_SAPI_11;
96
97 llc_data->n201_u_base[UIMAP(LL_SAPI_1)] = LLC_N201_U_SAPI_1;
98 llc_data->n201_u_base[UIMAP(LL_SAPI_3)] = LLC_N201_U_SAPI_3;
99 llc_data->n201_u_base[UIMAP(LL_SAPI_5)] = LLC_N201_U_SAPI_5;
100 llc_data->n201_u_base[UIMAP(LL_SAPI_7)] = LLC_N201_U_SAPI_7;
101 llc_data->n201_u_base[UIMAP(LL_SAPI_9)] = LLC_N201_U_SAPI_9;
102 llc_data->n201_u_base[UIMAP(LL_SAPI_11)] = LLC_N201_U_SAPI_11;
103
104 llc_data->n201_i_base[IMAP(LL_SAPI_3)] = LLC_N201_I_SAPI_3;
105 llc_data->n201_i_base[IMAP(LL_SAPI_5)] = LLC_N201_I_SAPI_5;
106 llc_data->n201_i_base[IMAP(LL_SAPI_9)] = LLC_N201_I_SAPI_9;
107 llc_data->n201_i_base[IMAP(LL_SAPI_11)] = LLC_N201_I_SAPI_11;
108
109 llc_data->md_base[IMAP(LL_SAPI_3)] = LLC_MD_SAPI_3;
110 llc_data->md_base[IMAP(LL_SAPI_5)] = LLC_MD_SAPI_5;
111 llc_data->md_base[IMAP(LL_SAPI_9)] = LLC_MD_SAPI_9;
112 llc_data->md_base[IMAP(LL_SAPI_11)] = LLC_MD_SAPI_11;
113
114 llc_data->mu_base[IMAP(LL_SAPI_3)] = LLC_MU_SAPI_3;
115 llc_data->mu_base[IMAP(LL_SAPI_5)] = LLC_MU_SAPI_5;
116 llc_data->mu_base[IMAP(LL_SAPI_9)] = LLC_MU_SAPI_9;
117 llc_data->mu_base[IMAP(LL_SAPI_11)] = LLC_MU_SAPI_11;
118
119 llc_data->kd_base[IMAP(LL_SAPI_3)] = LLC_KD_SAPI_3;
120 llc_data->kd_base[IMAP(LL_SAPI_5)] = LLC_KD_SAPI_5;
121 llc_data->kd_base[IMAP(LL_SAPI_9)] = LLC_KD_SAPI_9;
122 llc_data->kd_base[IMAP(LL_SAPI_11)] = LLC_KD_SAPI_11;
123
124 llc_data->ku_base[IMAP(LL_SAPI_3)] = LLC_KU_SAPI_3;
125 llc_data->ku_base[IMAP(LL_SAPI_5)] = LLC_KU_SAPI_5;
126 llc_data->ku_base[IMAP(LL_SAPI_9)] = LLC_KU_SAPI_9;
127 llc_data->ku_base[IMAP(LL_SAPI_11)] = LLC_KU_SAPI_11;
128
129 /*
130 * Reset all OCs for unacknowledged transfer.
131 */
132 for (incarnation = 0; incarnation < MAX_SAPI_INC; incarnation++)
133 {
134 llc_data->sapi_base[incarnation].oc_ui_tx = 0L;
135 llc_data->sapi_base[incarnation].oc_ui_rx = 0L;
136 }
137
138 return;
139 } /* llc_init_parameters() */
140
141
142 /*
143 +------------------------------------------------------------------------------
144 | Function : llc_get_ffs_data
145 +------------------------------------------------------------------------------
146 | Description : Load configured LLC parameter from FFS. In case of _SIMULATION_
147 | only default values are returned.
148 |
149 | Parameters : type - XID Paramter type
150 | sapi_array_index - Array index of Sapi !!!
151 |
152 +------------------------------------------------------------------------------
153 */
154 LOCAL USHORT llc_get_ffs_data (UBYTE type, UBYTE sapi_array_index)
155 {
156
157 switch (type)
158 {
159 #ifdef _SIMULATION_
160
161 case XID_T200:
162 if (llc_data->ffs_xid.t200[sapi_array_index].valid)
163 return llc_data->ffs_xid.t200[sapi_array_index].value; /* 50 = 5 sec !!! */
164 else
165 return (USHORT)INT2XID(llc_data->t200_base[sapi_array_index].length);
166
167 case XID_N200:
168 if (llc_data->ffs_xid.n200[sapi_array_index].valid)
169 return (USHORT)llc_data->ffs_xid.n200[sapi_array_index].value;
170 else
171 return (USHORT)llc_data->n200_base[sapi_array_index];
172
173 case XID_MD:
174 if (llc_data->ffs_xid.md[sapi_array_index].valid)
175 return llc_data->ffs_xid.md[sapi_array_index].value;
176 else
177 return llc_data->md_base[sapi_array_index];
178
179 case XID_MU:
180 if (llc_data->ffs_xid.mu[sapi_array_index].valid)
181 return (USHORT)llc_data->ffs_xid.mu[sapi_array_index].value;
182 else
183 return (USHORT)llc_data->mu_base[sapi_array_index];
184
185 case XID_N201_U:
186 if (llc_data->ffs_xid.n201_u[sapi_array_index].valid)
187 return llc_data->ffs_xid.n201_u[sapi_array_index].value;
188 else
189 return llc_data->n201_u_base[sapi_array_index];
190
191 case XID_N201_I:
192 if (llc_data->ffs_xid.n201_i[sapi_array_index].valid)
193 return llc_data->ffs_xid.n201_i[sapi_array_index].value;
194 else
195 return llc_data->n201_i_base[sapi_array_index];
196
197 case XID_KD:
198 if (llc_data->ffs_xid.kd[sapi_array_index].valid)
199 return (USHORT)llc_data->ffs_xid.kd[sapi_array_index].value;
200 else
201 return (USHORT)llc_data->kd_base[sapi_array_index];
202
203 case XID_KU:
204 if (llc_data->ffs_xid.ku[sapi_array_index].valid)
205 return (USHORT)llc_data->ffs_xid.ku[sapi_array_index].value;
206 else
207 return (USHORT)llc_data->ku_base[sapi_array_index];
208
209 #else
210
211 case XID_T200: return (USHORT)INT2XID(llc_data->t200_base[sapi_array_index].length);
212 case XID_N200: return (USHORT)llc_data->n200_base[sapi_array_index];
213 /* case XID_N201_U: return (USHORT)llc_data->n201_u_base[sapi_array_index]; */
214 /* case XID_KD: return (USHORT)llc_data->kd_base[sapi_array_index]; */
215 /* case XID_KU: return (USHORT)llc_data->ku_base[sapi_array_index]; */
216 case XID_N201_I: return (USHORT)N201_I_SUPPORTED;
217 case XID_N201_U: return (USHORT)N201_U_SUPPORTED;
218 case XID_KD: return (USHORT)KD_KD_SUPPORTED;
219 case XID_KU: return (USHORT)KD_KU_SUPPORTED;
220 case XID_MD: return (USHORT)KD_MD_SUPPORTED;
221 case XID_MU: return (USHORT)KD_MU_SUPPORTED;
222
223
224 #endif /* _SIMULATION_ */
225
226 default:
227 TRACE_ERROR ("Illegal FFS parameter used");
228 return 0;
229 }
230
231 } /* llc_get_ffs_data */
232
233
234 /*
235 +------------------------------------------------------------------------------
236 | Function : llc_init_requested_xid
237 +------------------------------------------------------------------------------
238 | Description : Fill in requested XID parameters into requested_xid structure
239 |
240 | Parameters :
241 |
242 +------------------------------------------------------------------------------
243 */
244 GLOBAL void llc_init_requested_xid (void)
245 {
246 UBYTE u_inc, i_inc, sapi;
247 USHORT requested_value;
248
249 for (u_inc = 0; u_inc < ACKNOWLEDGED_INC; u_inc++)
250 {
251 llc_data->requested_l3_xid_base[u_inc].valid = FALSE;
252 }
253
254 for (sapi = LL_SAPI_1; sapi <= LL_SAPI_11; sapi += 2)
255 {
256 u_inc = UIMAP(sapi);
257
258 llc_data->u_base[u_inc].requested_xid.version.valid = FALSE;
259 llc_data->u_base[u_inc].requested_xid.iov_ui.valid = FALSE;
260 llc_data->u_base[u_inc].requested_xid.iov_i.valid = FALSE;
261 llc_data->u_base[u_inc].requested_xid.reset.valid = FALSE;
262
263 llc_data->u_base[u_inc].requested_xid.t200.valid = FALSE;
264 llc_data->u_base[u_inc].requested_xid.n200.valid = FALSE;
265 llc_data->u_base[u_inc].requested_xid.n201_u.valid = FALSE;
266 llc_data->u_base[u_inc].requested_xid.n201_i.valid = FALSE;
267 llc_data->u_base[u_inc].requested_xid.kd.valid = FALSE;
268 llc_data->u_base[u_inc].requested_xid.ku.valid = FALSE;
269 llc_data->u_base[u_inc].requested_xid.md.valid = FALSE;
270 llc_data->u_base[u_inc].requested_xid.mu.valid = FALSE;
271
272 requested_value = llc_get_ffs_data (XID_T200, u_inc);
273 if (requested_value != (USHORT)INT2XID(llc_data->t200_base[u_inc].length))
274 {
275 llc_data->u_base[u_inc].requested_xid.t200.valid = TRUE;
276 llc_data->u_base[u_inc].requested_xid.t200.value = requested_value;
277 }
278
279 requested_value = llc_get_ffs_data (XID_N200, u_inc);
280 if (requested_value != llc_data->n200_base[u_inc])
281 {
282 llc_data->u_base[u_inc].requested_xid.n200.valid = TRUE;
283 llc_data->u_base[u_inc].requested_xid.n200.value = (UBYTE)requested_value;
284 }
285
286 requested_value = llc_get_ffs_data (XID_N201_U, u_inc);
287 if (requested_value != llc_data->n201_u_base[u_inc])
288 {
289 llc_data->u_base[u_inc].requested_xid.n201_u.valid = TRUE;
290 llc_data->u_base[u_inc].requested_xid.n201_u.value = requested_value;
291 }
292
293 if ((sapi != LL_SAPI_1) && (sapi != LL_SAPI_7))
294 {
295 i_inc = (UBYTE)IMAP(sapi);
296
297 requested_value = llc_get_ffs_data (XID_N201_I, i_inc);
298 if (requested_value != llc_data->n201_i_base[i_inc])
299 {
300 llc_data->u_base[u_inc].requested_xid.n201_i.valid = TRUE;
301 llc_data->u_base[u_inc].requested_xid.n201_i.value = requested_value;
302 }
303
304 requested_value = llc_get_ffs_data (XID_MD, i_inc);
305 if (requested_value != llc_data->md_base[i_inc])
306 {
307 llc_data->u_base[u_inc].requested_xid.md.valid = TRUE;
308 llc_data->u_base[u_inc].requested_xid.md.value = requested_value;
309 }
310
311 requested_value = llc_get_ffs_data (XID_MU, i_inc);
312 if (requested_value != llc_data->mu_base[i_inc])
313 {
314 llc_data->u_base[u_inc].requested_xid.mu.valid = TRUE;
315 llc_data->u_base[u_inc].requested_xid.mu.value = requested_value;
316 }
317
318 requested_value = llc_get_ffs_data (XID_KD, i_inc);
319 if (requested_value != llc_data->kd_base[i_inc])
320 {
321 llc_data->u_base[u_inc].requested_xid.kd.valid = TRUE;
322 llc_data->u_base[u_inc].requested_xid.kd.value = (UBYTE)requested_value;
323 }
324
325 requested_value = llc_get_ffs_data (XID_KU, i_inc);
326 if (requested_value != llc_data->ku_base[i_inc])
327 {
328 llc_data->u_base[u_inc].requested_xid.ku.valid = TRUE;
329 llc_data->u_base[u_inc].requested_xid.ku.value = (UBYTE)requested_value;
330 }
331 }
332 }
333 } /* llc_init_requested_xid() */
334
335
336 /*
337 +------------------------------------------------------------------------------
338 | Function : llc_init_requested_xid_sapi
339 +------------------------------------------------------------------------------
340 | Description : Fill in requested XID parameters into requested_xid structure
341 |
342 | Parameters :
343 |
344 +------------------------------------------------------------------------------
345 */
346 GLOBAL void llc_init_requested_xid_sapi (T_SAPI sapi)
347 {
348 UBYTE u_inc, i_inc;
349 USHORT requested_value;
350
351 u_inc = UIMAP(sapi);
352
353 llc_data->u_base[u_inc].requested_xid.t200.valid = FALSE;
354 llc_data->u_base[u_inc].requested_xid.n200.valid = FALSE;
355 llc_data->u_base[u_inc].requested_xid.n201_u.valid = FALSE;
356 llc_data->u_base[u_inc].requested_xid.n201_i.valid = FALSE;
357 llc_data->u_base[u_inc].requested_xid.kd.valid = FALSE;
358 llc_data->u_base[u_inc].requested_xid.ku.valid = FALSE;
359 llc_data->u_base[u_inc].requested_xid.md.valid = FALSE;
360 llc_data->u_base[u_inc].requested_xid.mu.valid = FALSE;
361
362 requested_value = llc_get_ffs_data (XID_T200, u_inc);
363 if (requested_value != (USHORT)INT2XID(llc_data->t200_base[u_inc].length))
364 {
365 llc_data->u_base[u_inc].requested_xid.t200.valid = TRUE;
366 llc_data->u_base[u_inc].requested_xid.t200.value = requested_value;
367 }
368
369 requested_value = llc_get_ffs_data (XID_N200, u_inc);
370 if (requested_value != llc_data->n200_base[u_inc])
371 {
372 llc_data->u_base[u_inc].requested_xid.n200.valid = TRUE;
373 llc_data->u_base[u_inc].requested_xid.n200.value = (UBYTE)requested_value;
374 }
375
376 requested_value = llc_get_ffs_data (XID_N201_U, u_inc);
377 if (requested_value != llc_data->n201_u_base[u_inc])
378 {
379 llc_data->u_base[u_inc].requested_xid.n201_u.valid = TRUE;
380 llc_data->u_base[u_inc].requested_xid.n201_u.value = requested_value;
381 }
382
383 if ((sapi != LL_SAPI_1) && (sapi != LL_SAPI_7))
384 {
385 i_inc = (UBYTE)IMAP(sapi);
386
387 requested_value = llc_get_ffs_data (XID_N201_I, i_inc);
388 if (requested_value != llc_data->n201_i_base[i_inc])
389 {
390 llc_data->u_base[u_inc].requested_xid.n201_i.valid = TRUE;
391 llc_data->u_base[u_inc].requested_xid.n201_i.value = requested_value;
392 }
393
394 requested_value = llc_get_ffs_data (XID_MD, i_inc);
395 if (requested_value != llc_data->md_base[i_inc])
396 {
397 llc_data->u_base[u_inc].requested_xid.md.valid = TRUE;
398 llc_data->u_base[u_inc].requested_xid.md.value = requested_value;
399 }
400
401 requested_value = llc_get_ffs_data (XID_MU, i_inc);
402 if (requested_value != llc_data->mu_base[i_inc])
403 {
404 llc_data->u_base[u_inc].requested_xid.mu.valid = TRUE;
405 llc_data->u_base[u_inc].requested_xid.mu.value = requested_value;
406 }
407
408 requested_value = llc_get_ffs_data (XID_KD, i_inc);
409 if (requested_value != llc_data->kd_base[i_inc])
410 {
411 llc_data->u_base[u_inc].requested_xid.kd.valid = TRUE;
412 llc_data->u_base[u_inc].requested_xid.kd.value = (UBYTE)requested_value;
413 }
414
415 requested_value = llc_get_ffs_data (XID_KU, i_inc);
416 if (requested_value != llc_data->ku_base[i_inc])
417 {
418 llc_data->u_base[u_inc].requested_xid.ku.valid = TRUE;
419 llc_data->u_base[u_inc].requested_xid.ku.value = (UBYTE)requested_value;
420 }
421 }
422 } /* llc_init_requested_xid_sapi() */
423
424
425
426 /*
427 +------------------------------------------------------------------------------
428 | Function : llc_generate_input
429 +------------------------------------------------------------------------------
430 | Description : This procedure calculates the frame-dependent input for
431 | UI_FRAMES / I_FRAMES. S_FRAMES are treated like I_FRAMES.
432 | Parameter direction must be one of
433 | CCI_DIRECTION_UPLINK/DOWNLINK. The input is generated
434 | according to section A.2.1 in GSM 04.64, and written to
435 | paramete input. This procedure is called from services
436 | TX and RX.
437 |
438 | Parameters : sapi - valid SAPI number
439 | frame_type - indicates acknowledged/unacknowledged frames
440 | lfn - LLC frame number
441 | direction - CCI_DIRECTION_UPLINK/CCI_DIRECTION_DOWNLINK
442 | cipher_input - generated ciphering input
443 |
444 +------------------------------------------------------------------------------
445 */
446 GLOBAL void llc_generate_input (UBYTE sapi,
447 T_PDU_TYPE frame_type,
448 T_FRAME_NUM lfn,
449 ULONG *cipher_input,
450 ULONG oc)
451 {
452 ULONG sx;
453
454
455 TRACE_FUNCTION ("llc_generate_input");
456
457 /*
458 * According to 04.64, Annex A.2.1:
459 * SX = 2exp27 * SAPI + 2exp31
460 */
461 sx = 134217728 * sapi + 2147483648;
462
463 if ((frame_type EQ I_FRAME) OR (frame_type EQ S_FRAME))
464 {
465 /*
466 * According to 04.64, Annex A.2.1:
467 * Input = ((IOV-I + LFN + OC) modulo 2exp32
468 */
469 *cipher_input = (ULONG)(*(llc_data->iov_i) + lfn + oc);
470 }
471 else /* unacknowledged mode */
472 {
473 /*
474 * According to 04.64, Annex A.2.1:
475 * Input = ((IOV-UI XOR SX) + LFN + OC) modulo 2exp32
476 */
477 *cipher_input = (ULONG)((llc_data->iov_ui ^ sx) + lfn + oc);
478 }
479
480 return;
481 } /* llc_generate_input() */
482
483
484 /*
485 +------------------------------------------------------------------------------
486 | Function : llc_build_crc24
487 +------------------------------------------------------------------------------
488 | Description : This procedure builds a CRC24 checksum according to RFC2440,
489 | which is needed by LLC to build and check the Frame Check
490 | Sequence (FCS) which is included in each frame.
491 |
492 | Parameters : octets - a valid pointer to the frame contents
493 | len - number of valid octets
494 |
495 +------------------------------------------------------------------------------
496 */
497
498 /*
499 * Precomputed table for polynomial : 0x00ad85dd (high term in LSB)
500 * 24-bit masks are packed in 16-bits words
501 *
502 */
503
504 const USHORT a_fcs24_tab_rev_packed[384] = {
505 0x0000, 0x7600, 0xd6a7, 0x4557, 0x21f6, 0x20e2, 0x8115, 0x63b7, 0x6126, 0xc442, 0x3441, 0x9763,
506 0x0991, 0xe734, 0xe2ae, 0x4cc6, 0xb0c2, 0x14eb, 0x8884, 0xf283, 0x552f, 0xcdd3, 0xa575, 0xa36a,
507 0x1322, 0x5468, 0xbeb4, 0x5675, 0x039e, 0x48f1, 0x9237, 0x41df, 0x0935, 0xd760, 0x1629, 0xff70,
508 0x1ab3, 0xc55c, 0x8abd, 0x5fe4, 0x92aa, 0x7cf8, 0x9ba6, 0xd0eb, 0x3d3c, 0xdef1, 0x871d, 0xcb79,
509 0x2644, 0x32d0, 0x0681, 0x6313, 0x6526, 0xf0c4, 0xa751, 0x2767, 0xb100, 0xe206, 0x7091, 0x4745,
510 0x2fd5, 0xa3e4, 0x3288, 0x6a82, 0xf412, 0xc4cd, 0xaec0, 0xb653, 0x8509, 0xeb97, 0xe1a5, 0x734c,
511 0x3566, 0x10b8, 0x6e92, 0x7031, 0x474e, 0x98d7, 0xb473, 0x050f, 0xd913, 0xf124, 0x52f9, 0x2f56,
512 0x3cf7, 0x818c, 0x5a9b, 0x79a0, 0xd67a, 0xacde, 0xbde2, 0x943b, 0xed1a, 0xf8b5, 0xc3cd, 0x1b5f,
513 0x4733, 0x45fb, 0x2de0, 0x0264, 0x120d, 0xdba5, 0xc626, 0x504c, 0x9a61, 0x8371, 0x07ba, 0x6c24,
514 0x4ea2, 0xd4cf, 0x19e9, 0x0bf5, 0x8339, 0xefac, 0xcfb7, 0xc178, 0xae68, 0x8ae0, 0x968e, 0x582d,
515 0x5411, 0x6793, 0x45f3, 0x1146, 0x3065, 0xb3b6, 0xd504, 0x7224, 0xf272, 0x9053, 0x25d2, 0x0437,
516 0x5d80, 0xf6a7, 0x71fa, 0x18d7, 0xa151, 0x87bf, 0xdc95, 0xe310, 0xc67b, 0x99c2, 0xb4e6, 0x303e,
517 0x6177, 0x012b, 0xfdc6, 0x2420, 0x56dd, 0x0b83, 0xe062, 0x149c, 0x4a47, 0xa535, 0x436a, 0xbc02,
518 0x68e6, 0x901f, 0xc9cf, 0x2db1, 0xc7e9, 0x3f8a, 0xe9f3, 0x85a8, 0x7e4e, 0xaca4, 0xd25e, 0x880b,
519 0x7255, 0x2343, 0x95d5, 0x3702, 0x74b5, 0x6390, 0xf340, 0x36f4, 0x2254, 0xb617, 0x6102, 0xd411,
520 0x7bc4, 0xb277, 0xa1dc, 0x3e93, 0xe581, 0x5799, 0xfad1, 0xa7c0, 0x165d, 0xbf86, 0xf036, 0xe018,
521 0x85dd, 0xabad, 0x7b22, 0xc08a, 0xfc5b, 0x8d67, 0x04c8, 0xbe1a, 0xcca3, 0x419f, 0xe9ec, 0x3ae6,
522 0x8c4c, 0x3a99, 0x4f2b, 0xc91b, 0x6d6f, 0xb96e, 0x0d59, 0x2f2e, 0xf8aa, 0x480e, 0x78d8, 0x0eef,
523 0x96ff, 0x89c5, 0x1331, 0xd3a8, 0xde33, 0xe574, 0x17ea, 0x9c72, 0xa4b0, 0x52bd, 0xcb84, 0x52f5,
524 0x9f6e, 0x18f1, 0x2738, 0xda39, 0x4f07, 0xd17d, 0x1e7b, 0x0d46, 0x90b9, 0x5b2c, 0x5ab0, 0x66fc,
525 0xa399, 0xef7d, 0xab04, 0xe6ce, 0xb88b, 0x5d41, 0x228c, 0xfaca, 0x1c85, 0x67db, 0xad3c, 0xeac0,
526 0xaa08, 0x7e49, 0x9f0d, 0xef5f, 0x29bf, 0x6948, 0x2b1d, 0x6bfe, 0x288c, 0x6e4a, 0x3c08, 0xdec9,
527 0xb0bb, 0xcd15, 0xc317, 0xf5ec, 0x9ae3, 0x3552, 0x31ae, 0xd8a2, 0x7496, 0x74f9, 0x8f54, 0x82d3,
528 0xb92a, 0x5c21, 0xf71e, 0xfc7d, 0x0bd7, 0x015b, 0x383f, 0x4996, 0x409f, 0x7d68, 0x1e60, 0xb6da,
529 0xc2ee, 0x9856, 0x8065, 0x87b9, 0xcfa0, 0x7620, 0x43fb, 0x8de1, 0x37e4, 0x06ac, 0xda17, 0xc1a1,
530 0xcb7f, 0x0962, 0xb46c, 0x8e28, 0x5e94, 0x4229, 0x4a6a, 0x1cd5, 0x03ed, 0x0f3d, 0x4b23, 0xf5a8,
531 0xd1cc, 0xba3e, 0xe876, 0x949b, 0xedc8, 0x1e33, 0x50d9, 0xaf89, 0x5ff7, 0x158e, 0xf87f, 0xa9b2,
532 0xd85d, 0x2b0a, 0xdc7f, 0x9d0a, 0x7cfc, 0x2a3a, 0x5948, 0x3ebd, 0x6bfe, 0x1c1f, 0x694b, 0x9dbb,
533 0xe4aa, 0xdc86, 0x5043, 0xa1fd, 0x8b70, 0xa606, 0x65bf, 0xc931, 0xe7c2, 0x20e8, 0x9ec7, 0x1187,
534 0xed3b, 0x4db2, 0x644a, 0xa86c, 0x1a44, 0x920f, 0x6c2e, 0x5805, 0xd3cb, 0x2979, 0x0ff3, 0x258e,
535 0xf788, 0xfeee, 0x3850, 0xb2df, 0xa918, 0xce15, 0x769d, 0xeb59, 0x8fd1, 0x33ca, 0xbcaf, 0x7994,
536 0xfe19, 0x6fda, 0x0c59, 0xbb4e, 0x382c, 0xfa1c, 0x7f0c, 0x7a6d, 0xbbd8, 0x3a5b, 0x2d9b, 0x4d9d
537 };
538
539
540 /******************************************************************************
541 *
542 * FUNCTION NAME: f_crc24_tab
543 *
544 * The function compute the 24-bit FCS and is using table for it
545 *
546 * ARGUMENT LIST:
547 *
548 * Argument Type IO Description
549 * ------------- -------- -- ---------------------------------------------
550 * data_p T_BYTE* I Pointer on the input buffer
551 * d_length T_UINT16 I Number of bytes to process
552 * d_l_crc_init T_UINT16 I Init value of the CRC
553 *
554 * RETURN VALUE:
555 * Argument Type Description
556 * ------------- -------- ---------------------------------------------
557 * d_l_crc T_UINT32 24-bit FCS stored in a 32-bit word
558 *
559 *****************************************************************************/
560 GLOBAL ULONG llc_build_crc24 (UBYTE *d_data_p,
561 USHORT d_length)
562 {
563 /* GLOBAL VARIABLES:
564 *
565 * Variables Type IO Description
566 * ------------- -------- -- -------------------------------------------
567 * none
568 */
569
570 /* LOCAL VARIABLES:
571 *
572 * Variables Type Description
573 * ------------- ------- ----------------------------------------------
574 * d_l_crc T_UINT32 24-bit FCS stored in a 32-bit word
575 * d_l_tab_res T_UINT32 FCS mask extracted from the table
576 * d_l_tab_index T_UINT32 Index of the FCS mask into the table
577 * d_byte_msb T_UINT16 Intermediate variable used to know the position
578 * FCSof the 24-bit FCS into two 16-bits words
579 */
580 ULONG d_l_crc, d_l_tab_res, d_l_tab_index;
581 USHORT d_byte_msb;
582
583 d_l_crc = 0x00ffffff;
584
585 do
586 {
587 /* Most efficient C implementation with 32-bits tables but require more d_data rom */
588 /* d_l_crc = (d_l_crc >> 8) ^ a_fcs24_tab_rev[(d_l_crc ^ *d_data_p++) & 0xff]; */
589
590 /* Details very close to the ASM implementation */
591 d_l_tab_index = (d_l_crc ^ *d_data_p++) & 0x0ff;
592 d_l_crc >>= 8;
593
594 if(d_l_tab_index & 0x01)
595 d_byte_msb = 1;
596 else
597 d_byte_msb = 0;
598
599 d_l_tab_index *= 3;
600
601 d_l_tab_index >>= 1;
602
603 d_l_crc &= 0x0000ffff; /* Replace the code in comment below */
604
605 d_l_tab_res = a_fcs24_tab_rev_packed[d_l_tab_index];
606 d_l_tab_res |= (a_fcs24_tab_rev_packed[d_l_tab_index+1] << 16);
607
608 if(d_byte_msb == 1)
609 d_l_tab_res >>= 8;
610
611 d_l_crc ^= d_l_tab_res;
612 }
613 while (--d_length);
614
615 d_l_crc = (~d_l_crc) & 0x00ffffff;
616
617 return (d_l_crc);
618 } /* llc_build_crc24() */
619
620 /*
621 +------------------------------------------------------------------------------
622 | Function : llc_xid_value_acceptable
623 +------------------------------------------------------------------------------
624 | Description : This procedure checks if the value of the XID parameter for
625 | the given SAPI is acceptable, or not. The return value is TRUE
626 | for an accepted value, and FALSE for an unaccepted value.
627 |
628 | Parameters : sapi - SAPI number
629 | xid_parameter - XID parameter (defined in llc_uf.h)
630 | xid_value - value of XID parameter (actually UBYTE/USHORT/
631 | ULONG, depending on the parameter)
632 |
633 +------------------------------------------------------------------------------
634 */
635 GLOBAL BOOL llc_xid_value_acceptable (UBYTE sapi,
636 UBYTE xid_parameter,
637 ULONG xid_value)
638 {
639 BOOL rc;
640 UBYTE u_inc, i_inc;
641
642
643 TRACE_FUNCTION ("llc_xid_value_acceptable");
644
645 /*
646 * Preset rc in case of unknown XID parameters or unknown SAPI values.
647 */
648 rc = FALSE;
649 u_inc = UIMAP(sapi);
650 i_inc = IMAP(sapi);
651
652 /*
653 * Accept only possible (valid) values for now (defined in llc_uf.h).
654 */
655 switch (xid_parameter)
656 {
657 case XID_VERSION:
658 if (xid_value EQ LLC_VERSION_ALL_SAPIS)
659 {
660 rc = TRUE;
661 TRACE_EVENT ("Version value accepted");
662 }
663 else
664 {
665 TRACE_EVENT ("Version value NOT accepted");
666 }
667 break;
668
669 case XID_IOV_UI:
670 /*
671 * Must not be checked, ignored.
672 */
673 TRACE_EVENT ("IOV-UI values are not checked.");
674 break;
675
676 case XID_IOV_I:
677 /*
678 * Must not be checked, ignored.
679 */
680 TRACE_EVENT ("IOV-I values are not checked.");
681 break;
682
683 case XID_T200:
684 switch (sapi)
685 {
686 case LL_SAPI_1:
687 case LL_SAPI_3:
688 case LL_SAPI_5:
689 case LL_SAPI_7:
690 case LL_SAPI_9:
691 case LL_SAPI_11:
692 if ( (xid_value >= (llc_data->u_base[u_inc].requested_xid.t200.valid ?
693 llc_get_ffs_data(XID_T200, u_inc): XID_T200_MIN))
694 AND (xid_value <= XID_T200_MAX) )
695 {
696 rc = TRUE;
697 TRACE_EVENT ("T200 value accepted");
698 }
699 else
700 {
701 TRACE_EVENT ("T200 value NOT accepted");
702 }
703 break;
704 default:
705 TRACE_ERROR ("invalid SAPI value for T200");
706 break;
707 }
708 break;
709
710 case XID_N200:
711 switch (sapi)
712 {
713 case LL_SAPI_1:
714 case LL_SAPI_3:
715 case LL_SAPI_5:
716 case LL_SAPI_7:
717 case LL_SAPI_9:
718 case LL_SAPI_11:
719 if ( (xid_value >= (llc_data->u_base[u_inc].requested_xid.n200.valid ?
720 llc_get_ffs_data(XID_N200, u_inc): XID_N200_MIN))
721 AND (xid_value <= XID_N200_MAX) )
722 {
723 rc = TRUE;
724 TRACE_EVENT ("N200 value accepted");
725 }
726 else
727 {
728 TRACE_EVENT ("N200 value NOT accepted");
729 }
730 break;
731 default:
732 TRACE_ERROR ("invalid SAPI value for N200");
733 break;
734 }
735 break;
736
737 case XID_N201_U:
738 switch (sapi)
739 {
740 case LL_SAPI_1:
741 case LL_SAPI_3:
742 case LL_SAPI_5:
743 case LL_SAPI_7:
744 case LL_SAPI_9:
745 case LL_SAPI_11:
746 if ( (xid_value >= (USHORT)XID_N201_U_MIN) AND
747 (xid_value <= (llc_data->u_base[u_inc].requested_xid.n201_u.valid ?
748 llc_get_ffs_data(XID_N201_U, u_inc): XID_N201_U_MAX)) )
749 {
750 rc = TRUE;
751 TRACE_EVENT ("N201-U value accepted");
752 }
753 else
754 {
755 TRACE_EVENT ("N201-U value NOT accepted");
756 }
757 break;
758 default:
759 TRACE_ERROR ("invalid SAPI value for N201-U");
760 break;
761 }
762 break;
763
764 case XID_N201_I:
765 switch (sapi)
766 {
767 case LL_SAPI_3:
768 case LL_SAPI_5:
769 case LL_SAPI_9:
770 case LL_SAPI_11:
771 if ( (xid_value >= XID_N201_I_MIN) AND
772 (xid_value <= (llc_data->u_base[u_inc].requested_xid.n201_i.valid ?
773 llc_get_ffs_data(XID_N201_I, i_inc): XID_N201_I_MAX)) )
774 {
775 rc = TRUE;
776 TRACE_EVENT ("N201-I value accepted");
777 }
778 else
779 {
780 TRACE_EVENT ("N201-I value NOT accepted");
781 }
782 break;
783 default:
784 TRACE_ERROR ("invalid SAPI value for N201-I");
785 break;
786 }
787 break;
788
789 case XID_MD:
790 switch (sapi)
791 {
792 case LL_SAPI_3:
793 case LL_SAPI_5:
794 case LL_SAPI_9:
795 case LL_SAPI_11:
796 if ( (xid_value == XID_MD_OFF) OR ((xid_value >= XID_MD_MIN) AND
797 (xid_value <= (llc_data->u_base[u_inc].requested_xid.md.valid ?
798 llc_get_ffs_data(XID_MD, i_inc): XID_MD_MAX)) ))
799 {
800 rc = TRUE;
801 TRACE_EVENT ("mD value accepted");
802 }
803 else
804 {
805 TRACE_EVENT ("mD value NOT accepted");
806 }
807 break;
808 default:
809 TRACE_ERROR ("invalid SAPI value for mD");
810 break;
811 }
812 break;
813
814 case XID_MU:
815 switch (sapi)
816 {
817 case LL_SAPI_3:
818 case LL_SAPI_5:
819 case LL_SAPI_9:
820 case LL_SAPI_11:
821 if ( (xid_value == XID_MU_OFF) OR ((xid_value >= XID_MU_MIN) AND
822 (xid_value <= (llc_data->u_base[u_inc].requested_xid.mu.valid ?
823 llc_get_ffs_data(XID_MU, i_inc): XID_MU_MAX)) ))
824 {
825 rc = TRUE;
826 TRACE_EVENT ("mU value accepted");
827 }
828 else
829 {
830 TRACE_EVENT ("mU value NOT accepted");
831 }
832 break;
833 default:
834 TRACE_ERROR ("invalid SAPI value for mU");
835 break;
836 }
837 break;
838
839 case XID_KD:
840 switch (sapi)
841 {
842 case LL_SAPI_3:
843 case LL_SAPI_5:
844 case LL_SAPI_9:
845 case LL_SAPI_11:
846 if ( (xid_value >= XID_KD_MIN) AND
847 (xid_value <= (llc_data->u_base[u_inc].requested_xid.kd.valid ?
848 llc_get_ffs_data(XID_KD, i_inc): XID_KD_MAX)) )
849 {
850 rc = TRUE;
851 TRACE_EVENT ("kD value accepted");
852 }
853 else
854 {
855 TRACE_EVENT ("kD value NOT accepted");
856 }
857 break;
858 default:
859 TRACE_ERROR ("invalid SAPI value for kD");
860 break;
861 }
862 break;
863
864 case XID_KU:
865 switch (sapi)
866 {
867 case LL_SAPI_3:
868 case LL_SAPI_5:
869 case LL_SAPI_9:
870 case LL_SAPI_11:
871 if ( (xid_value >= XID_KU_MIN) AND
872 (xid_value <= (llc_data->u_base[u_inc].requested_xid.ku.valid ?
873 llc_get_ffs_data(XID_KU, i_inc): XID_KU_MAX)) )
874 {
875 rc = TRUE;
876 TRACE_EVENT ("kU value accepted");
877 }
878 else
879 {
880 TRACE_EVENT ("kU value NOT accepted");
881 }
882 break;
883 default:
884 TRACE_ERROR ("invalid SAPI value for kU");
885 break;
886 }
887 break;
888
889 case XID_LAYER_3:
890 /*
891 * Must not be checked, ignored.
892 */
893 TRACE_EVENT ("Layer-3 values are not checked.");
894 break;
895
896 case XID_RESET:
897 /*
898 * Must not be checked, ignored.
899 */
900 TRACE_EVENT ("Reset is not checked.");
901 break;
902
903 default:
904 TRACE_ERROR ("unknown XID parameter");
905 break;
906 }
907
908 return rc;
909 } /* llc_xid_value_acceptable() */
910
911
912 /*
913 +------------------------------------------------------------------------------
914 | Function : llc_palloc_desc
915 +------------------------------------------------------------------------------
916 | Description : This function allocates a descriptor of type T_DESC3
917 |
918 | Parameters : len - length of descriptor
919 | : offset offset of descriptor
920 |
921 | Return : poniter to T_DESC3
922 |
923 +------------------------------------------------------------------------------
924 */
925 #ifdef LL_DESC
926 GLOBAL T_desc3* llc_palloc_desc( U16 len, U16 offset)
927 {
928 T_desc3 *desc3;
929 U8 *buffer;
930
931 TRACE_FUNCTION ("llc_palloc_desc");
932
933 MALLOC (desc3, (USHORT)(sizeof(T_desc3)));
934
935 MALLOC (buffer, len + offset);
936
937 desc3->next = NULL;
938 desc3->offset = offset;
939 desc3->len = len;
940 desc3->buffer = (ULONG)buffer;
941
942 return desc3;
943 }
944
945 /*
946 +------------------------------------------------------------------------------
947 | Function : llc_cl_desc3_free
948 +------------------------------------------------------------------------------
949 | Description : Frees the descriptor connected to the desc3 descriptor. This
950 | free will when applicable cause the frame to decrease a
951 | connected counter attached to the allocation or really free
952 | the memory in case the counter is zero.
953 |
954 | Parameters : T_desc3* pointer to desc3 descriptor.
955 |
956 +------------------------------------------------------------------------------
957 */
958 GLOBAL void llc_cl_desc3_free(T_desc3* p_desc3)
959 {
960 T_desc3* help;
961 while(p_desc3)
962 {
963 help = (T_desc3*)p_desc3->next;
964 MFREE(p_desc3->buffer);
965 MFREE(p_desc3);
966 p_desc3 = help;
967 }
968 }
969 #endif /* LL_DESC */
970
971 #ifndef TI_PS_OP_CIPH_DRIVER
972 /*
973 +------------------------------------------------------------------------------
974 | Function : llc_fbs_init
975 +------------------------------------------------------------------------------
976 | Description : The function fbs_init() initializes service
977 | variablaes
978 |
979 | Parameters : void
980 |
981 +------------------------------------------------------------------------------
982 */
983 GLOBAL void llc_fbs_init ( void )
984 {
985 TRACE_FUNCTION( "llc_fbs_init" );
986 llc_data->fbs.initialized = FALSE;
987 }
988 #endif
989 /*
990 +------------------------------------------------------------------------------
991 | Function : llc_copy_ul_data_to_list
992 +------------------------------------------------------------------------------
993 | Description : The function copy_data_to_list copies the length and the pointer
994 | of the linked descriptor list to the in_data_list.
995 | It is used in uplink direction
996 |
997 | Parameters :
998 |
999 +------------------------------------------------------------------------------
1000 */
1001
1002 GLOBAL void llc_copy_ul_data_to_list
1003 (
1004 T_CCI_CIPHER_DESC_REQ *cipher_req,
1005 T_CIPH_in_data_list *in_data_list
1006 )
1007 {
1008
1009 T_desc3* cipher_desc;
1010 U16 cnt = 0;
1011 T_CIPH_in_data* in_data_array;
1012
1013
1014 /*
1015 * Count the number of descriptors in the incoming desc_list
1016 */
1017 cipher_desc = (T_desc3*)cipher_req->desc_list3.first;
1018 while (cipher_desc){
1019 cipher_desc = (T_desc3*)cipher_desc->next;
1020 cnt ++;
1021 }
1022 /*
1023 * Allocate an array for T_CIPH_in_data_list
1024 */
1025 MALLOC(in_data_array,(sizeof(T_CIPH_in_data) * cnt));
1026 in_data_list->ptr_in_data = in_data_array;
1027
1028 /*
1029 * Copy buf and len parameters from descriptors to the in_data's
1030 */
1031 cipher_desc = (T_desc3*)cipher_req->desc_list3.first;
1032 cnt = 0;
1033 while (cipher_desc)
1034 {
1035 in_data_list->ptr_in_data[cnt].buf =
1036 (U32)&((U8*)cipher_desc->buffer)[cipher_desc->offset];
1037 in_data_list->ptr_in_data[cnt].len = cipher_desc->len;
1038
1039 cipher_desc = (T_desc3*)cipher_desc->next;
1040 cnt++;
1041 }
1042 in_data_list->c_in_data = cnt;
1043
1044 } /* llc_copy_ul_data_to_list */
1045
1046 /*
1047 +------------------------------------------------------------------------------
1048 | Function : llc_copy_dl_data_to_list
1049 +------------------------------------------------------------------------------
1050 | Description : The function copy_data_to_list copies the length and the pointer
1051 | of the linked descriptor list to the in_data_list.
1052 | It is used in downlink direction
1053 |
1054 | Parameters :
1055 |
1056 +------------------------------------------------------------------------------
1057 */
1058
1059 GLOBAL void llc_copy_dl_data_to_list
1060 (
1061 T_CCI_DECIPHER_REQ *decipher_req,
1062 T_CIPH_in_data_list *in_data_list
1063 )
1064 {
1065
1066 T_desc* decipher_desc;
1067 T_CIPH_in_data* in_data_array;
1068 USHORT cnt = 0;
1069
1070 /*
1071 * Count the number of descriptors in the incoming desc_list
1072 */
1073 decipher_desc = (T_desc*)decipher_req->desc_list.first;
1074 while (decipher_desc){
1075 decipher_desc = (T_desc*)decipher_desc->next;
1076 cnt ++;
1077 }
1078
1079 /*
1080 * Allocate an array of for T_CIPH_in_data
1081 */
1082 MALLOC(in_data_array, (sizeof(T_CIPH_in_data) * cnt));
1083 in_data_list->ptr_in_data = in_data_array;
1084
1085 /*
1086 * Copy buf and len parameters from descriptors to the in_data's
1087 */
1088 decipher_desc = (T_desc*)decipher_req->desc_list.first;
1089 cnt = 0;
1090 while (decipher_desc)
1091 {
1092 in_data_list->ptr_in_data[cnt].buf = (U32)decipher_desc->buffer;
1093 in_data_list->ptr_in_data[cnt].len = decipher_desc->len;
1094
1095 decipher_desc = (T_desc*)decipher_desc->next;
1096 cnt++;
1097 }
1098 in_data_list->c_in_data = cnt;
1099
1100 } /* llc_copy_dl_data_to_list */
1101
1102 /*
1103 +------------------------------------------------------------------------------
1104 | Function : llc_fbs_enable_cci_info_trace
1105 +------------------------------------------------------------------------------
1106 | Description : The llc_fbs_enable_cci_info_trace sets the variable
1107 | llc_data->fbs.cci_info_trace to TRUE
1108 |
1109 | Parameters : void
1110 |
1111 +------------------------------------------------------------------------------
1112 */
1113 GLOBAL void llc_fbs_enable_cci_info_trace ( void )
1114 {
1115 TRACE_FUNCTION( "llc_fbs_enable_cci_info_trace" );
1116 llc_data->fbs.cci_info_trace = TRUE;
1117 }
1118
1119 #ifdef LLC_TRACE_CIPHERING
1120 /*
1121 +------------------------------------------------------------------------------
1122 | Function : llc_trace_desc_list3_content
1123 +------------------------------------------------------------------------------
1124 | Description : traces content of a desc3 descriptor list
1125 |
1126 | Parameters : desc_list3 descriptor list
1127 |
1128 +------------------------------------------------------------------------------
1129 */
1130 GLOBAL void llc_trace_desc_list3_content(T_desc_list3 desc_list3)
1131 {
1132 U16 current_pos = 0;
1133 U16 dif;
1134 U16 data_len = 0; /* The length of the data to be traced including data offset */
1135 U8* p_data = NULL; /* Pointer to byte data element */
1136 T_desc3* p_desc3 = (T_desc3*)desc_list3.first; /* Pointer to the actual desc3 descriptor element */
1137
1138 while(p_desc3 != NULL)
1139 {
1140 current_pos = p_desc3->offset;
1141 dif=0;
1142 p_data = (U8*)p_desc3->buffer;
1143 data_len = current_pos + p_desc3->len;
1144 while(current_pos < data_len)
1145 {
1146 if (current_pos +8 <= data_len)
1147 {
1148 TRACE_EVENT_P8
1149 ("%02x %02x %02x %02x %02x %02x %02x %02x",
1150 p_data[current_pos],
1151 p_data[current_pos+1],
1152 p_data[current_pos+2],
1153 p_data[current_pos+3],
1154 p_data[current_pos+4],
1155 p_data[current_pos+5],
1156 p_data[current_pos+6],
1157 p_data[current_pos+7]
1158 );
1159 current_pos += 8;
1160 }
1161 else
1162 {
1163 dif = data_len - current_pos;
1164 switch(dif)
1165 {
1166 case 1:
1167 TRACE_EVENT_P1
1168 ("%02x",
1169 p_data[current_pos]
1170 );
1171 current_pos += 1;
1172 break;
1173 case 2:
1174 TRACE_EVENT_P2
1175 ("%02x %02x",
1176 p_data[current_pos],
1177 p_data[current_pos+1]
1178 );
1179 current_pos += 2;
1180 break;
1181 case 3:
1182 TRACE_EVENT_P3
1183 ("%02x %02x %02x",
1184 p_data[current_pos],
1185 p_data[current_pos+1],
1186 p_data[current_pos+2]
1187 );
1188 current_pos += 3;
1189 break;
1190 case 4:
1191 TRACE_EVENT_P4
1192 ("%02x %02x %02x %02x",
1193 p_data[current_pos],
1194 p_data[current_pos+1],
1195 p_data[current_pos+2],
1196 p_data[current_pos+3]
1197 );
1198 current_pos += 4;
1199 break;
1200 case 5:
1201 TRACE_EVENT_P5
1202 ("%02x %02x %02x %02x %02x",
1203 p_data[current_pos],
1204 p_data[current_pos+1],
1205 p_data[current_pos+2],
1206 p_data[current_pos+3],
1207 p_data[current_pos+4]
1208 );
1209 current_pos += 5;
1210 break;
1211 case 6:
1212 TRACE_EVENT_P6
1213 ("%02x %02x %02x %02x %02x %02x",
1214 p_data[current_pos],
1215 p_data[current_pos+1],
1216 p_data[current_pos+2],
1217 p_data[current_pos+3],
1218 p_data[current_pos+4],
1219 p_data[current_pos+5]
1220 );
1221 current_pos += 6;
1222 break;
1223 case 7:
1224 TRACE_EVENT_P7
1225 ("%02x %02x %02x %02x %02x %02x %02x",
1226 p_data[current_pos],
1227 p_data[current_pos+1],
1228 p_data[current_pos+2],
1229 p_data[current_pos+3],
1230 p_data[current_pos+4],
1231 p_data[current_pos+5],
1232 p_data[current_pos+6]
1233 );
1234 current_pos += 7;
1235 break;
1236 }
1237
1238 }
1239 }
1240
1241 p_desc3 = (T_desc3*)p_desc3->next;
1242 }
1243 }
1244
1245 /*
1246 +------------------------------------------------------------------------------
1247 | Function : llc_trace_sdu
1248 +------------------------------------------------------------------------------
1249 | Description : traces content of one sdu
1250 |
1251 | Parameters : pointer to sdu
1252 |
1253 +------------------------------------------------------------------------------
1254 */
1255 GLOBAL void llc_trace_sdu(T_sdu* sdu)
1256 {
1257
1258 USHORT pos = sdu->o_buf >> 3;
1259 USHORT frame_len = (sdu->l_buf + 7) / 8;
1260
1261
1262 TRACE_FUNCTION("llc_trace_sdu");
1263
1264 while(pos < (frame_len + (sdu->o_buf >> 3)))
1265 {
1266 if (pos + 8 <= (frame_len + (sdu->o_buf >> 3))) {
1267 TRACE_EVENT_P8
1268 ("%02x %02x %02x %02x %02x %02x %02x %02x",
1269 sdu->buf[pos],
1270 sdu->buf[pos + 1],
1271 sdu->buf[pos + 2],
1272 sdu->buf[pos + 3],
1273 sdu->buf[pos + 4],
1274 sdu->buf[pos + 5],
1275 sdu->buf[pos + 6],
1276 sdu->buf[pos + 7]
1277 );
1278 pos += 8;
1279 } else if (pos + 7 <= (frame_len + (sdu->o_buf >> 3))){
1280 TRACE_EVENT_P7
1281 ("%02x %02x %02x %02x %02x %02x %02x",
1282 sdu->buf[pos],
1283 sdu->buf[pos + 1],
1284 sdu->buf[pos + 2],
1285 sdu->buf[pos + 3],
1286 sdu->buf[pos + 4],
1287 sdu->buf[pos + 5],
1288 sdu->buf[pos + 6]
1289 );
1290 pos += 7;
1291 } else if (pos + 6 <= (frame_len + (sdu->o_buf >> 3))){
1292 TRACE_EVENT_P6
1293 ("%02x %02x %02x %02x %02x %02x",
1294 sdu->buf[pos],
1295 sdu->buf[pos + 1],
1296 sdu->buf[pos + 2],
1297 sdu->buf[pos + 3],
1298 sdu->buf[pos + 4],
1299 sdu->buf[pos + 5]
1300 );
1301 pos += 6;
1302 } else if (pos + 5 <= (frame_len + (sdu->o_buf >> 3))){
1303 TRACE_EVENT_P5
1304 ("%02x %02x %02x %02x %02x",
1305 sdu->buf[pos],
1306 sdu->buf[pos + 1],
1307 sdu->buf[pos + 2],
1308 sdu->buf[pos + 3],
1309 sdu->buf[pos + 4]
1310 );
1311 pos += 5;
1312 } else if (pos + 4 <= (frame_len + (sdu->o_buf >> 3))){
1313 TRACE_EVENT_P4
1314 ("%02x %02x %02x %02x",
1315 sdu->buf[pos],
1316 sdu->buf[pos + 1],
1317 sdu->buf[pos + 2],
1318 sdu->buf[pos + 3]
1319 );
1320 pos += 4;
1321 } else if (pos + 3 <= (frame_len + (sdu->o_buf >> 3))){
1322 TRACE_EVENT_P3
1323 ("%02x %02x %02x",
1324 sdu->buf[pos],
1325 sdu->buf[pos + 1],
1326 sdu->buf[pos + 2]
1327 );
1328 pos += 3;
1329 } else if (pos + 2 <= (frame_len + (sdu->o_buf >> 3))){
1330 TRACE_EVENT_P2
1331 ("%02x %02x",
1332 sdu->buf[pos],
1333 sdu->buf[pos + 1]
1334 );
1335 pos += 2;
1336 } else if (pos + 1 <= (frame_len + (sdu->o_buf >> 3))){
1337 TRACE_EVENT_P1
1338 ("%02x",
1339 sdu->buf[pos]
1340 );
1341 pos++;
1342 }
1343
1344 }
1345 }
1346
1347 /*
1348 +------------------------------------------------------------------------------
1349 | Function : llc_trace_desc_list
1350 +------------------------------------------------------------------------------
1351 | Description : traces content of one desc_list
1352 |
1353 | Parameters : pointer to desc_list
1354 |
1355 +------------------------------------------------------------------------------
1356 */
1357 GLOBAL void llc_trace_desc_list(T_desc_list* desc_list)
1358 {
1359 USHORT frame_len = desc_list->list_len;
1360 T_desc* desc = (T_desc*)desc_list->first;
1361 USHORT list_pos = 0;
1362 USHORT desc_pos = 0;
1363
1364 TRACE_FUNCTION("llc_trace_desc_list");
1365
1366 while(list_pos < frame_len)
1367 {
1368 if (desc != NULL) {
1369 if (desc_pos >= desc->len) {
1370 desc_pos = 0;
1371 desc = (T_desc*)desc->next;
1372 }
1373 }
1374 if (desc == NULL) {
1375 return;
1376 }
1377 if (desc_pos + 8 <= desc->len) {
1378 TRACE_EVENT_P8 ("%02x %02x %02x %02x %02x %02x %02x %02x ",
1379 desc->buffer[desc_pos],
1380 desc->buffer[desc_pos + 1],
1381 desc->buffer[desc_pos + 2],
1382 desc->buffer[desc_pos + 3],
1383 desc->buffer[desc_pos + 4],
1384 desc->buffer[desc_pos + 5],
1385 desc->buffer[desc_pos + 6],
1386 desc->buffer[desc_pos + 7]
1387 );
1388 list_pos+= 8;
1389 desc_pos+= 8;
1390 } else if (desc_pos + 7 <= desc->len) {
1391 TRACE_EVENT_P7 ("%02x %02x %02x %02x %02x %02x %02x ",
1392 desc->buffer[desc_pos],
1393 desc->buffer[desc_pos + 1],
1394 desc->buffer[desc_pos + 2],
1395 desc->buffer[desc_pos + 3],
1396 desc->buffer[desc_pos + 4],
1397 desc->buffer[desc_pos + 5],
1398 desc->buffer[desc_pos + 6]
1399 );
1400 list_pos+= 7;
1401 desc_pos+= 7;
1402 } else if (desc_pos + 6 <= desc->len) {
1403 TRACE_EVENT_P6 ("%02x %02x %02x %02x %02x %02x ",
1404 desc->buffer[desc_pos],
1405 desc->buffer[desc_pos + 1],
1406 desc->buffer[desc_pos + 2],
1407 desc->buffer[desc_pos + 3],
1408 desc->buffer[desc_pos + 4],
1409 desc->buffer[desc_pos + 5]
1410 );
1411 list_pos+= 6;
1412 desc_pos+= 6;
1413 } else if (desc_pos + 5 <= desc->len) {
1414 TRACE_EVENT_P5 ("%02x %02x %02x %02x %02x ",
1415 desc->buffer[desc_pos],
1416 desc->buffer[desc_pos + 1],
1417 desc->buffer[desc_pos + 2],
1418 desc->buffer[desc_pos + 3],
1419 desc->buffer[desc_pos + 4]
1420 );
1421 list_pos+= 5;
1422 desc_pos+= 5;
1423 } else if (desc_pos + 4 <= desc->len) {
1424 TRACE_EVENT_P4 ("%02x %02x %02x %02x ",
1425 desc->buffer[desc_pos],
1426 desc->buffer[desc_pos + 1],
1427 desc->buffer[desc_pos + 2],
1428 desc->buffer[desc_pos + 3]
1429 );
1430 list_pos+= 4;
1431 desc_pos+= 4;
1432 } else if (desc_pos + 3 <= desc->len) {
1433 TRACE_EVENT_P3 ("%02x %02x %02x ",
1434 desc->buffer[desc_pos],
1435 desc->buffer[desc_pos + 1],
1436 desc->buffer[desc_pos + 2]
1437 );
1438 list_pos+= 3;
1439 desc_pos+= 3;
1440 } else if (desc_pos + 2 <= desc->len) {
1441 TRACE_EVENT_P2 ("%02x %02x ",
1442 desc->buffer[desc_pos],
1443 desc->buffer[desc_pos + 1]
1444 );
1445 list_pos+= 2;
1446 desc_pos+= 2;
1447 } else if (desc_pos + 1 <= desc->len) {
1448 TRACE_EVENT_P1 ("%02x ",
1449 desc->buffer[desc_pos]
1450 );
1451 list_pos++;
1452 desc_pos++;
1453 }
1454 } /* while(list_pos < frame_len) */
1455 }
1456 #endif /*LLC_TRACE_CIPHERING */
1457