comparison src/g23m-gprs/sndcp/sndcp_f.c @ 1:fa8dc04885d8

src/g23m-*: import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:25:50 +0000
parents
children
comparison
equal deleted inserted replaced
0:4e78acac3d88 1:fa8dc04885d8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GPRS (8441)
4 | Modul : sndcp_f.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 : Contains global functions of SNDCP
18 +-----------------------------------------------------------------------------
19 */
20
21 #define ENTITY_SNDCP
22
23 /*==== INCLUDES =============================================================*/
24
25 #include "typedefs.h" /* to get Condat data types */
26 #include "vsi.h" /* to get a lot of macros */
27 #include "gsm.h" /* to get a lot of macros */
28 #include "prim.h" /* to get the definitions of used SAP and directions */
29 #include "macdef.h"
30
31 #include "dti.h"
32 #include "sndcp.h" /* to get the global entity definitions */
33 #include "sndcp_f.h" /* to get the functions to access the global arrays*/
34
35 #include "sndcp_nup.h" /* to get nu functions that will be called from
36 sndcp_sig_callback() */
37 #include "sndcp_ndp.h" /* to get nu functions that will be called from
38 sndcp_sig_callback() */
39
40
41 #include <string.h> /* to get memcpy() */
42
43
44 /*==== CONST ================================================================*/
45
46 #ifdef SNDCP_TRACE_IP_DATAGRAM
47 #ifndef CF_FAST_EXEC
48 static U8 bin_trace_ip_buf[1500];
49 #endif /* CF_FAST_EXEC */
50 #endif
51 /*==== LOCAL VARS ===========================================================*/
52
53
54
55
56 #ifdef TI_PS_OP_ICUT_SNDCP
57
58 /* PDP_TBR add SNDCP terminal loopback capability */
59 extern U8 SNDCP_LOOPBACK;
60 extern BOOL bufFull[SNDCP_NUMBER_OF_NSAPIS];
61 extern T_DTI2_DATA_IND *saveDti2_data_ind[SNDCP_NUMBER_OF_NSAPIS] ;
62
63 #endif /* TI_PS_OP_ICUT_SNDCP */
64
65
66
67
68
69 /*==== PRIVATE FUNCTIONS ====================================================*/
70
71 /*==== PUBLIC FUNCTIONS =====================================================*/
72
73
74 /*
75 +------------------------------------------------------------------------------
76 | Function : sndcp_get_nsapi_ack
77 +------------------------------------------------------------------------------
78 | Description : gets nsapi_ack_ra[nsapi]
79 |
80 | Parameters : UBYTE nsapi, BOOL* ack
81 |
82 +------------------------------------------------------------------------------
83 */
84 #ifndef CF_FAST_EXEC
85
86 GLOBAL void sndcp_get_nsapi_ack(UBYTE nsapi,
87 BOOL* ack)
88 {
89 TRACE_FUNCTION("sndcp_get_nsapi_ack");
90 {
91 *ack = sndcp_data->nsapi_ack_ra[nsapi];
92 }
93 }
94
95 #endif /* CF_FAST_EXEC */
96
97 #ifdef _SNDCP_DTI_2_
98 /*
99 +------------------------------------------------------------------------------
100 | Function : sndcp_get_nsapi_direction
101 +------------------------------------------------------------------------------
102 | Description : gets nsapi_ack_direction[nsapi]
103 | Values: HOME or NEIGHBOR from dti.h.
104 |
105 | Parameters : UBYTE nsapi, BOOL* direction
106 |
107 +------------------------------------------------------------------------------
108 */
109 #ifndef CF_FAST_EXEC
110
111 GLOBAL void sndcp_get_nsapi_direction(UBYTE nsapi,
112 U8* direction)
113 {
114 TRACE_FUNCTION("sndcp_get_nsapi_direction");
115 {
116 *direction = (U8)sndcp_data->nsapi_direction_ra[nsapi];
117 }
118 }
119
120 #endif /* CF_FAST_EXEC */
121
122 /*
123 +------------------------------------------------------------------------------
124 | Function : sndcp_get_nsapi_interface
125 +------------------------------------------------------------------------------
126 | Description : gets nsapi_interface_ra[nsapi]
127 |
128 | Parameters : UBYTE nsapi, U8 interface
129 |
130 +------------------------------------------------------------------------------
131 */
132 #ifndef CF_FAST_EXEC
133
134 GLOBAL void sndcp_get_nsapi_interface(UBYTE nsapi,
135 U8* interfac)
136 {
137 TRACE_FUNCTION("sndcp_get_nsapi_interface");
138 {
139 *interfac = sndcp_data->nsapi_interface_ra[nsapi];
140 }
141 }
142
143 #endif /* CF_FAST_EXEC */
144
145 /*
146 +------------------------------------------------------------------------------
147 | Function : sndcp_get_nsapi_linkid
148 +------------------------------------------------------------------------------
149 | Description : gets nsapi_linkid_ra[nsapi]
150 |
151 | Parameters : UBYTE nsapi, ULONG* linkid
152 |
153 +------------------------------------------------------------------------------
154 */
155 #ifndef CF_FAST_EXEC
156
157 GLOBAL void sndcp_get_nsapi_linkid(UBYTE nsapi,
158 ULONG* linkid)
159 {
160 TRACE_FUNCTION("sndcp_get_nsapi_linkid");
161 {
162 *linkid = sndcp_data->nsapi_linkid_ra[nsapi];
163 }
164 }
165
166 #endif /* CF_FAST_EXEC */
167
168 /*
169 +------------------------------------------------------------------------------
170 | Function : sndcp_get_nsapi_neighbor
171 +------------------------------------------------------------------------------
172 | Description : gets nsapi_neighbor_ra[nsapi]
173 |
174 | Parameters : UBYTE nsapi, UBYTE** neighbor
175 |
176 +------------------------------------------------------------------------------
177 */
178 #ifndef CF_FAST_EXEC
179
180 GLOBAL void sndcp_get_nsapi_neighbor(UBYTE nsapi,
181 UBYTE** neighbor)
182 {
183 TRACE_FUNCTION("sndcp_get_nsapi_neighbor");
184 {
185 *neighbor = sndcp_data->nsapi_neighbor_ra[nsapi];
186 }
187 }
188 #endif /* CF_FAST_EXEC */
189
190 #else /*_SNDCP_DTI_2_*/
191 /*
192 +------------------------------------------------------------------------------
193 | Function : sndcp_get_nsapi_direction
194 +------------------------------------------------------------------------------
195 | Description : gets nsapi_ack_direction[nsapi]
196 | Values: HOME or NEIGHBOR from dti.h.
197 |
198 | Parameters : UBYTE nsapi, BOOL* direction
199 |
200 +------------------------------------------------------------------------------
201 */
202 #ifndef CF_FAST_EXEC
203
204 GLOBAL void sndcp_get_nsapi_direction(UBYTE nsapi,
205 BOOL* direction)
206 {
207 TRACE_FUNCTION("sndcp_get_nsapi_direction");
208 {
209 *direction = sndcp_data->nsapi_direction_ra[nsapi];
210 }
211 }
212
213 #endif /* CF_FAST_EXEC */
214
215 /*
216 +------------------------------------------------------------------------------
217 | Function : sndcp_get_nsapi_interface
218 +------------------------------------------------------------------------------
219 | Description : gets nsapi_interface_ra[nsapi]
220 |
221 | Parameters : UBYTE nsapi, U8 interface
222 |
223 +------------------------------------------------------------------------------
224 */
225 #ifndef CF_FAST_EXEC
226
227 GLOBAL void sndcp_get_nsapi_interface(UBYTE nsapi,
228 U8* interfac)
229 {
230 TRACE_FUNCTION("sndcp_get_nsapi_interface");
231 {
232 *interfac = sndcp_data->nsapi_interface_ra[nsapi];
233 }
234 }
235
236 #endif /* CF_FAST_EXEC */
237
238 /*
239 +------------------------------------------------------------------------------
240 | Function : sndcp_get_nsapi_linkid
241 +------------------------------------------------------------------------------
242 | Description : gets nsapi_linkid_ra[nsapi]
243 |
244 | Parameters : UBYTE nsapi, ULONG* linkid
245 |
246 +------------------------------------------------------------------------------
247 */
248 #ifndef CF_FAST_EXEC
249
250 GLOBAL void sndcp_get_nsapi_linkid(UBYTE nsapi,
251 ULONG* linkid)
252 {
253 TRACE_FUNCTION("sndcp_get_nsapi_linkid");
254 {
255 *linkid = sndcp_data->nsapi_linkid_ra[nsapi];
256 }
257 }
258
259 #endif /* CF_FAST_EXEC */
260
261 /*
262 +------------------------------------------------------------------------------
263 | Function : sndcp_get_nsapi_neighbor
264 +------------------------------------------------------------------------------
265 | Description : gets nsapi_neighbor_ra[nsapi]
266 |
267 | Parameters : UBYTE nsapi, UBYTE** neighbor
268 |
269 +------------------------------------------------------------------------------
270 */
271 #ifndef CF_FAST_EXEC
272
273 GLOBAL void sndcp_get_nsapi_neighbor(UBYTE nsapi,
274 UBYTE** neighbor)
275 {
276 TRACE_FUNCTION("sndcp_get_nsapi_neighbor");
277 {
278 *neighbor = sndcp_data->nsapi_neighbor_ra[nsapi];
279 }
280 }
281
282 #endif /* CF_FAST_EXEC */
283
284 #endif /*_SNDCP_DTI_2_*/
285
286 /*
287 +------------------------------------------------------------------------------
288 | Function : sndcp_get_sapi_ack
289 +------------------------------------------------------------------------------
290 | Description : gets sapi_ack_ra["index of sapi"]
291 |
292 | Parameters : UBYTE sapi, BOOL* ack
293 |
294 +------------------------------------------------------------------------------
295 */
296 #ifndef CF_FAST_EXEC
297
298 GLOBAL void sndcp_get_sapi_ack(UBYTE sapi,
299 BOOL* ack)
300 {
301 TRACE_FUNCTION("sndcp_get_sapi_ack");
302 {
303 UBYTE sapi_index = 0;
304
305 sndcp_get_sapi_index(sapi, &sapi_index);
306 *ack = sndcp_data->sapi_ack_ra[sapi_index];
307 }
308 }
309
310 #endif /* CF_FAST_EXEC */
311
312 /*
313 +------------------------------------------------------------------------------
314 | Function : sndcp_get_sapi_stat
315 +------------------------------------------------------------------------------
316 | Description : gets sapi_state_ra[sapi]
317 |
318 | Parameters : UBYTE sapi, UBYTE* stat
319 |
320 +------------------------------------------------------------------------------
321 */
322 #ifndef CF_FAST_EXEC
323
324 GLOBAL void sndcp_get_sapi_state(UBYTE sapi,
325 USHORT* stat)
326 {
327 TRACE_FUNCTION("sndcp_get_sapi_state");
328 {
329 UBYTE sapi_index = 0;
330
331 sndcp_get_sapi_index(sapi, &sapi_index);
332 *stat = sndcp_data->sapi_state_ra[sapi_index];
333 }
334 }
335
336 #endif /* CF_FAST_EXEC */
337
338 /*
339 +------------------------------------------------------------------------------
340 | Function : sndcp_get_sapi_index
341 +------------------------------------------------------------------------------
342 | Description : gets the index (0, 1, 2, 3) for the given sapi (3, 5, 9, 11).
343 | This function is used when a sapi number serves as a key for one of the 4
344 | possible instances of services su and sd.
345 |
346 | Parameters : UBYTE sapi, UBYTE* index
347 |
348 +------------------------------------------------------------------------------
349 */
350 /*#if defined(CF_FAST_EXEC) || defined(_SIMULATION_) || \
351 defined(SNDCP_2to1) */
352
353 GLOBAL void sndcp_get_sapi_index(UBYTE sapi,
354 UBYTE* index)
355 {
356 TRACE_FUNCTION("sndcp_get_sapi_index");
357 {
358 if (sapi == 3) {
359 *index = 0;
360 } else if (sapi == 5) {
361 *index = 1;
362 } else if (sapi == 9) {
363 *index = 2;
364 } else if (sapi == 11) {
365 *index = 3;
366 }
367 }
368 }
369
370 /*#endif */ /* CF_FAST_EXEC || _SIMULATION_ || !REL99 || SNDCP_2to1 */
371
372 /*
373 +------------------------------------------------------------------------------
374 | Function : sndcp_get_nsapi_prio
375 +------------------------------------------------------------------------------
376 | Description : sets prio to nsapi_prio_ra[nsapi]
377 |
378 | Parameters : UBYTE nsapi, UBYTE* prio
379 |
380 +------------------------------------------------------------------------------
381 */
382 #ifndef CF_FAST_EXEC
383
384 GLOBAL void sndcp_get_nsapi_prio(UBYTE nsapi,
385 UBYTE* prio)
386 {
387 TRACE_FUNCTION("sndcp_get_nsapi_prio");
388 {
389 *prio = sndcp_data->nsapi_prio_ra[nsapi];
390 }
391 }
392
393 #endif /* CF_FAST_EXEC */
394
395 #ifdef REL99
396 /*
397 +------------------------------------------------------------------------------
398 | Function : sndcp_get_nsapi_pktflowid
399 +------------------------------------------------------------------------------
400 | Description : gets packet flow id form nsapi_pktflowid_ra[nsapi]
401 |
402 | Parameters : UBYTE nsapi, UBYTE* pkt_flow_id
403 |
404 +------------------------------------------------------------------------------
405 */
406 #ifndef CF_FAST_EXEC
407
408 GLOBAL void sndcp_get_nsapi_pktflowid(U8 nsapi, U16* pkt_flow_id)
409
410 {
411 TRACE_FUNCTION("sndcp_get_nsapi_pktflowid");
412 {
413 *pkt_flow_id = sndcp_data->nsapi_pktflowid_ra[nsapi];
414 }
415 }
416
417 #endif /* CF_FAST_EXEC */
418
419 #endif /*REL99*/
420
421 /*
422 +------------------------------------------------------------------------------
423 | Function : sndcp_get_nsapi_qos
424 +------------------------------------------------------------------------------
425 | Description : gets nsapi_qos_ra[nsapi]
426 |
427 | Parameters : UBYTE nsapi, T_snsm_qos* qos
428 |
429 +------------------------------------------------------------------------------
430 */
431 #ifndef CF_FAST_EXEC
432
433 GLOBAL void sndcp_get_nsapi_qos(UBYTE nsapi,
434 T_snsm_qos* qos)
435 {
436 TRACE_FUNCTION("sndcp_get_nsapi_qos");
437 {
438 qos->delay = sndcp_data->nsapi_qos_ra[nsapi].delay;
439 qos->relclass = sndcp_data->nsapi_qos_ra[nsapi].relclass;
440 qos->peak = sndcp_data->nsapi_qos_ra[nsapi].peak;
441 qos->preced = sndcp_data->nsapi_qos_ra[nsapi].preced;
442 qos->mean = sndcp_data->nsapi_qos_ra[nsapi].mean;
443 }
444 }
445
446 #endif /* CF_FAST_EXEC */
447
448 /*
449 +------------------------------------------------------------------------------
450 | Function : sndcp_get_nsapi_sapi
451 +------------------------------------------------------------------------------
452 | Description : gets nsapi_sapi_ra[nsapi]
453 |
454 | Parameters : UBYTE nsapi, UBYTE* sapi
455 |
456 +------------------------------------------------------------------------------
457 */
458 #ifndef CF_FAST_EXEC
459
460 GLOBAL void sndcp_get_nsapi_sapi(UBYTE nsapi,
461 UBYTE* sapi)
462 {
463 TRACE_FUNCTION("sndcp_get_nsapi_sapi");
464 {
465 *sapi = sndcp_data->nsapi_sapi_ra[nsapi];
466 }
467 }
468
469 #endif /* CF_FAST_EXEC */
470
471 /*
472 +------------------------------------------------------------------------------
473 | Function : sndcp_get_nsapi_state
474 +------------------------------------------------------------------------------
475 | Description : gets nsapi_state_ra[nsapi]
476 |
477 | Parameters : UBYTE nsapi, USHORT* state
478 |
479 +------------------------------------------------------------------------------
480 */
481 #ifndef CF_FAST_EXEC
482
483 GLOBAL void sndcp_get_nsapi_state(UBYTE nsapi,
484 USHORT* state)
485 {
486 TRACE_FUNCTION("sndcp_get_nsapi_state");
487 {
488 *state = sndcp_data->nsapi_state_ra[nsapi];
489 }
490 }
491
492 #endif /* CF_FAST_EXEC */
493
494 /*
495 +------------------------------------------------------------------------------
496 | Function : sndcp_is_nsapi_data_compressed
497 +------------------------------------------------------------------------------
498 | Description : If nsapi uses data compression then compressed is set to TRUE,
499 | else to FALSE.
500 |
501 | Parameters : UBYTE nsapi, BOOL* compressed
502 |
503 +------------------------------------------------------------------------------
504 */
505 #ifndef CF_FAST_EXEC
506
507 GLOBAL void sndcp_is_nsapi_data_compressed(UBYTE nsapi,
508 BOOL* compressed)
509 {
510 USHORT nsapis = sndcp_data->cia.cur_xid_block.v42.nsapis;
511
512 TRACE_FUNCTION("sndcp_is_nsapi_data_compressed");
513
514 *compressed = (nsapis & (1 << nsapi)) > 0;
515
516 }
517
518 #endif /* CF_FAST_EXEC */
519
520 /*
521 +------------------------------------------------------------------------------
522 | Function : sndcp_is_nsapi_used
523 +------------------------------------------------------------------------------
524 | Description : sets b to TRUE if the nsapi is already in use, otherwise to
525 | FALSE
526 |
527 | Parameters : UBYTE nsapi, BOOL* b
528 |
529 +------------------------------------------------------------------------------
530 */
531 /*#if defined(CF_FAST_EXEC) || defined(_SIMULATION_) || \
532 defined (SNDCP_2to1) */
533
534 GLOBAL void sndcp_is_nsapi_used(UBYTE nsapi,
535 BOOL* b)
536 {
537 TRACE_FUNCTION("sndcp_is_nsapi_used");
538 {
539 *b = sndcp_data->nsapi_used_ra[nsapi];
540 }
541 }
542
543 /*#endif */ /* CF_FAST_EXEC || _SIMULATION_ || !REL99 || SNDCP_2to1 */
544
545 /*
546 +------------------------------------------------------------------------------
547 | Function : sndcp_is_nsapi_header_compressed
548 +------------------------------------------------------------------------------
549 | Description : If nsapi uses header compression then compressed is set to TRUE,
550 | else to FALSE.
551 |
552 | Parameters : UBYTE nsapi, BOOL* compressed
553 |
554 +------------------------------------------------------------------------------
555 */
556 #ifndef CF_FAST_EXEC
557
558 GLOBAL void sndcp_is_nsapi_header_compressed(UBYTE nsapi,
559 BOOL* compressed)
560 {
561 USHORT nsapis = sndcp_data->cia.cur_xid_block.vj.nsapis;
562
563 TRACE_FUNCTION("sndcp_is_nsapi_header_compressed");
564
565 *compressed = ((nsapis & (1 << nsapi)) > 0) &&
566 sndcp_data->cia.cur_xid_block.vj.is_set;
567
568 }
569
570 #endif /* CF_FAST_EXEC */
571
572 /*
573 +------------------------------------------------------------------------------
574 | Function : sndcp_mean_trace
575 +------------------------------------------------------------------------------
576 | Description : traces the mean thruput for given
577 |
578 | Parameters : nsapi, direction, ack_mode
579 |
580 +------------------------------------------------------------------------------
581 */
582 #ifndef CF_FAST_EXEC
583
584 GLOBAL void sndcp_mean_trace(UBYTE nsapi,
585 UBYTE direction,
586 UBYTE ack_mode,
587 USHORT len)
588 {
589 T_TIME* start_time_ra = NULL;
590 T_TIME* cur_time_ra = NULL;
591 ULONG* cur_num_ra = NULL;
592 ULONG* cur_pac_ra = NULL;
593
594 TRACE_FUNCTION("sndcp_mean_trace");
595
596 if (direction == SNDCP_MEAN_UP) {
597 if (ack_mode == SNDCP_MEAN_ACK) {
598 start_time_ra = sndcp_data->start_time_uplink_ack;
599 cur_time_ra = sndcp_data->cur_time_uplink_ack;
600 cur_num_ra = sndcp_data->cur_num_uplink_ack;
601 cur_pac_ra = sndcp_data->cur_pac_uplink_ack;
602 } else {
603 start_time_ra = sndcp_data->start_time_uplink_unack;
604 cur_time_ra = sndcp_data->cur_time_uplink_unack;
605 cur_num_ra = sndcp_data->cur_num_uplink_unack;
606 cur_pac_ra = sndcp_data->cur_pac_uplink_unack;
607 }
608 } else {
609 if (ack_mode == SNDCP_MEAN_ACK) {
610 start_time_ra = sndcp_data->start_time_downlink_ack;
611 cur_time_ra = sndcp_data->cur_time_downlink_ack;
612 cur_num_ra = sndcp_data->cur_num_downlink_ack;
613 cur_pac_ra = sndcp_data->cur_pac_downlink_ack;
614 } else {
615 start_time_ra = sndcp_data->start_time_downlink_ack;
616 cur_time_ra = sndcp_data->cur_time_downlink_ack;
617 cur_num_ra = sndcp_data->cur_num_downlink_unack;
618 cur_pac_ra = sndcp_data->cur_pac_downlink_unack;
619 }
620 }
621
622 /*
623 * Increment number of packets.
624 */
625 cur_pac_ra[nsapi] ++;
626
627
628 if (start_time_ra[nsapi] == 0) {
629 vsi_t_time(VSI_CALLER &start_time_ra[nsapi]);
630 cur_num_ra[nsapi] += len;
631 } else {
632
633 ULONG mean = 0;
634 ULONG delta_millis = 0;
635
636 vsi_t_time(VSI_CALLER &cur_time_ra[nsapi]);
637 cur_num_ra[nsapi] += len;
638
639 delta_millis = cur_time_ra[nsapi] -
640 start_time_ra[nsapi];
641 if (direction == SNDCP_MEAN_UP) {
642 if (delta_millis > 0) {
643 mean = (cur_num_ra[nsapi] * 1000) / delta_millis;
644 TRACE_EVENT_P4(
645 "nsapi %d up. %d octets in %d ms. %d octets per sec.",
646 nsapi,
647 cur_num_ra[nsapi],
648 delta_millis,
649 mean
650 );
651 } else {
652 TRACE_EVENT_P3(
653 "nsapi %d up. %d octets in %d ms.",
654 nsapi,
655 cur_num_ra[nsapi],
656 delta_millis
657 );
658 }
659
660 } else { /* not (direction == SNDCP_MEAN_UP) */
661 if (delta_millis > 0) {
662 mean = (cur_num_ra[nsapi] * 1000) / delta_millis;
663 TRACE_EVENT_P4(
664 "nsapi %d down. %d octets in %d ms. %d octets per sec.",
665 nsapi,
666 cur_num_ra[nsapi],
667 delta_millis,
668 mean
669 );
670 } else {
671 TRACE_EVENT_P3(
672 "nsapi %d down. %d octets in %d ms.",
673 nsapi,
674 cur_num_ra[nsapi],
675 delta_millis
676 );
677 }
678 } /* not (direction == SNDCP_MEAN_UP) */
679
680 }
681
682 }
683
684 #endif /* CF_FAST_EXEC */
685
686
687 /*
688 +------------------------------------------------------------------------------
689 | Function : sndcp_reset_xid_block
690 +------------------------------------------------------------------------------
691 | Description : Resets the given T_XID_BLOCK to default values.
692 |
693 | Parameters : T_XID_BLOCK* xid_block
694 |
695 +------------------------------------------------------------------------------
696 */
697 #ifndef CF_FAST_EXEC
698
699 GLOBAL void sndcp_reset_xid_block (T_XID_BLOCK* xid_block)
700 {
701 TRACE_FUNCTION( "sndcp_reset_xid_block" );
702
703 /*
704 * Reset all flags for optional compression field parameters.
705 */
706 xid_block->version_set = FALSE;
707 xid_block->v42.is_set = FALSE;
708 xid_block->vj.is_set = FALSE;
709
710 xid_block->v42.nsapis_set = FALSE;
711 xid_block->v42.p0_set = FALSE;
712 xid_block->v42.p1_set = FALSE;
713 xid_block->v42.p2_set = FALSE;
714 xid_block->vj.nsapis_set = FALSE;
715 xid_block->vj.s0_m_1_set = FALSE;
716 /*
717 * Set fields to default values.
718 */
719 xid_block->v42.nsapis = SNDCP_NSAPIS_DEFAULT;
720 xid_block->v42.p0 = SNDCP_V42_DEFAULT_DIRECTION;
721 xid_block->v42.p1 = SNDCP_V42_DEFAULT_P1;
722 xid_block->v42.p2 = SNDCP_V42_DEFAULT_P2;
723
724 xid_block->vj.nsapis = SNDCP_NSAPIS_DEFAULT;
725 xid_block->vj.s0_m_1 = SNDCP_VJ_DEFAULT_S0_M_1;
726
727
728 } /* sndcp_reset_xid_block() */
729
730 #endif /* CF_FAST_EXEC */
731
732 #ifdef _SIMULATION_
733 /*
734 +------------------------------------------------------------------------------
735 | Function : sndcp_sdu_to_desc_list
736 +------------------------------------------------------------------------------
737 | Description : copies the given sdu to the given desc_list
738 |
739 | Parameters : T_sdu* sdu,
740 | T_desc_list* desc_list
741 |
742 +------------------------------------------------------------------------------
743 */
744 #ifdef _SNDCP_DTI_2_
745 GLOBAL void sndcp_sdu_to_desc_list(T_sdu* sdu, T_desc_list2* desc_list) {
746 T_desc2 *desc = NULL;
747 T_desc2 *last_desc = NULL;
748 #else /*_SNDCP_DTI_2_*/
749 GLOBAL void sndcp_sdu_to_desc_list(T_sdu* sdu, T_desc_list* desc_list) {
750 T_desc *desc = NULL;
751 T_desc *last_desc = NULL;
752 #endif /*_SNDCP_DTI_2_*/
753 USHORT sdu_index;
754 USHORT length;
755
756
757 /*
758 * Begin at the first relevant octet.
759 */
760 sdu_index = sdu->o_buf/8;
761
762 /*
763 * Initialise descriptor list length.
764 */
765 desc_list->list_len = 0;
766
767
768 /*
769 * Copy complete SDU to descriptor list using descriptors of max. 10 bytes.
770 */
771 while (sdu_index < sdu->l_buf / 8)
772 {
773 /*
774 * Calculate length of descriptor data (= length of remaining sdu buffer
775 * with a maximum of 10)
776 */
777 length = (sdu_index + 10 < sdu->l_buf / 8) ?
778 10 : (sdu->l_buf / 8 - sdu_index);
779
780 /*
781 * Allocate the necessary size for the data descriptor. The size is
782 * calculated as follows:
783 * - take the size of a descriptor structure
784 * - subtract one because of the array buffer[1] to get the size of
785 * descriptor control information
786 * - add number of octets of descriptor data
787 */
788 #ifdef _SNDCP_DTI_2_
789 MALLOC (desc, (USHORT)(sizeof(T_desc2) - 1 + length));
790 #else /*_SNDCP_DTI_2_*/
791 MALLOC (desc, (USHORT)(sizeof(T_desc) - 1 + length));
792 #endif /*_SNDCP_DTI_2_*/
793 /*
794 * Fill descriptor control information.
795 */
796 desc->next = (ULONG)NULL;
797 desc->len = length;
798 #ifdef _SNDCP_DTI_2_
799 desc->offset = 0;
800 desc->size = desc->len;
801 #endif
802 /*
803 * Add length of descriptor data to list length.
804 */
805 desc_list->list_len += length;
806
807 /*
808 * Copy user data from SDU to descriptor.
809 */
810 if (length>0)
811 {
812 memcpy (desc->buffer, &sdu->buf[sdu_index], length);
813 }
814 sdu_index += length;
815
816 if (last_desc)
817 {
818 /*
819 * Add this descriptor (not the first) to the descriptor list.
820 */
821 last_desc->next = (ULONG)desc;
822 }
823 else
824 {
825 /*
826 * Insert first descriptor in descriptor list.
827 */
828 desc_list->first = (ULONG)desc;
829 }
830
831 /*
832 * Store this descriptor for later use.
833 */
834 last_desc = desc;
835 }
836
837 }
838 #endif /* _SIMULATION_ */
839
840
841
842 /*
843 +------------------------------------------------------------------------------
844 | Function : sndcp_set_nsapi_ack
845 +------------------------------------------------------------------------------
846 | Description : sets nsapi_ack_ra[nsapi] to ack
847 |
848 | Parameters : UBYTE nsapi, BOOL ack
849 |
850 +------------------------------------------------------------------------------
851 */
852 #ifndef CF_FAST_EXEC
853
854 GLOBAL void sndcp_set_nsapi_ack(UBYTE nsapi,
855 BOOL ack)
856 {
857 TRACE_FUNCTION(" sndcp_set_nsapi_ack ");
858 {
859 sndcp_data->nsapi_ack_ra[nsapi] = ack;
860 }
861 }
862
863 #endif /* CF_FAST_EXEC */
864
865 /*
866 +------------------------------------------------------------------------------
867 | Function : sndcp_set_nsapi_direction
868 +------------------------------------------------------------------------------
869 | Description : sets nsapi_direction_ra[nsapi] to direction
870 |
871 | Parameters : UBYTE nsapi, BOOL direction
872 |
873 +------------------------------------------------------------------------------
874 */
875 #ifndef CF_FAST_EXEC
876
877 GLOBAL void sndcp_set_nsapi_direction(UBYTE nsapi,
878 BOOL direction)
879 {
880 TRACE_FUNCTION(" sndcp_set_nsapi_direction ");
881 #ifdef _SNDCP_DTI_2_
882 if (direction == DTI_CHANNEL_TO_LOWER_LAYER) {
883 sndcp_data->nsapi_direction_ra[nsapi] = DTI_CHANNEL_TO_LOWER_LAYER;
884 } else {
885 sndcp_data->nsapi_direction_ra[nsapi] = DTI_CHANNEL_TO_HIGHER_LAYER;
886 #else /*_SNDCP_DTI_2_*/
887 if (direction == SN_HOME) {
888 sndcp_data->nsapi_direction_ra[nsapi] = HOME;
889 } else {
890 sndcp_data->nsapi_direction_ra[nsapi] = NEIGHBOR;
891 #endif /*_SNDCP_DTI_2_*/
892 }
893 }
894
895 #endif /* CF_FAST_EXEC */
896
897 /*
898 +------------------------------------------------------------------------------
899 | Function : sndcp_set_nsapi_interface
900 +------------------------------------------------------------------------------
901 | Description : sets nsapi_interface_ra[nsapi] to interfac
902 |
903 | Parameters : UBYTE nsapi, U8 interfac
904 |
905 +------------------------------------------------------------------------------
906 */
907 #ifndef CF_FAST_EXEC
908
909 GLOBAL void sndcp_set_nsapi_interface(UBYTE nsapi,
910 U8 interfac)
911 {
912 TRACE_FUNCTION(" sndcp_set_nsapi_interface ");
913 {
914 sndcp_data->nsapi_interface_ra[nsapi] = interfac;
915 }
916 }
917
918 #endif /* CF_FAST_EXEC */
919
920 /*
921 +------------------------------------------------------------------------------
922 | Function : sndcp_set_nsapi_linkid
923 +------------------------------------------------------------------------------
924 | Description : sets nsapi_linkid_ra[nsapi] to linkid
925 |
926 | Parameters : UBYTE nsapi, U32 linkid
927 |
928 +------------------------------------------------------------------------------
929 */
930 #ifndef CF_FAST_EXEC
931
932 GLOBAL void sndcp_set_nsapi_linkid(UBYTE nsapi,
933 U32 linkid)
934 {
935 TRACE_FUNCTION(" sndcp_set_nsapi_linkid ");
936 {
937 sndcp_data->nsapi_linkid_ra[nsapi] = linkid;
938 }
939 }
940
941 #endif /* CF_FAST_EXEC */
942
943 /*
944 +------------------------------------------------------------------------------
945 | Function : sndcp_set_nsapi_neighbor
946 +------------------------------------------------------------------------------
947 | Description : sets nsapi_neighbor_ra[nsapi] to neighbor
948 |
949 | Parameters : UBYTE nsapi, U8* neighbor
950 |
951 +------------------------------------------------------------------------------
952 */
953 #ifndef CF_FAST_EXEC
954
955 GLOBAL void sndcp_set_nsapi_neighbor(UBYTE nsapi,
956 U8* neighbor)
957 {
958 TRACE_FUNCTION(" sndcp_set_nsapi_neighbor ");
959 {
960 sndcp_data->nsapi_neighbor_ra[nsapi] = neighbor;
961 }
962 }
963
964 #endif /* CF_FAST_EXEC */
965
966 /*
967 +------------------------------------------------------------------------------
968 | Function : sndcp_no_xid
969 +------------------------------------------------------------------------------
970 | Description : XID negotiation during each context (default in our
971 | implementation) is switched off.
972 |
973 | Parameters :
974 |
975 +------------------------------------------------------------------------------
976 */
977 #ifndef CF_FAST_EXEC
978
979 GLOBAL void sndcp_no_xid(void)
980 {
981 TRACE_FUNCTION("sndcp_no_xid");
982 {
983 sndcp_data->always_xid = FALSE;
984 }
985 }
986
987 #endif /* CF_FAST_EXEC */
988
989 /*
990 +------------------------------------------------------------------------------
991 | Function : sndcp_set_nsapi_prio
992 +------------------------------------------------------------------------------
993 | Description : sets nsapi_prio_ra[nsapi] to prio - 1:
994 | SNSM prio val is mapped to LL prio val, which is the internal
995 | representation.
996 |
997 | Parameters : UBYTE nsapi, UBYTE prio
998 |
999 +------------------------------------------------------------------------------
1000 */
1001 #ifndef CF_FAST_EXEC
1002
1003 GLOBAL void sndcp_set_nsapi_prio(UBYTE nsapi,
1004 UBYTE prio)
1005 {
1006 TRACE_FUNCTION("sndcp_set_nsapi_prio");
1007 {
1008 sndcp_data->nsapi_prio_ra[nsapi] = prio - 1;
1009 }
1010 }
1011
1012 #endif /* CF_FAST_EXEC */
1013
1014 #ifdef REL99
1015 /*
1016 +------------------------------------------------------------------------------
1017 | Function : sndcp_set_nsapi_pktflowid
1018 +------------------------------------------------------------------------------
1019 | Description : sets pktflowid_ra[nsapi] to packet_flow_identifier:
1020 | SNSM packet flow identifier is mapped to LL pkt_flow_id, which is the internal
1021 | representation.
1022 |
1023 | Parameters : UBYTE nsapi, UBYTE packet_flow_identifier
1024 |
1025 +------------------------------------------------------------------------------
1026 */
1027 #ifndef CF_FAST_EXEC
1028
1029 GLOBAL void sndcp_set_nsapi_pktflowid(UBYTE nsapi,
1030 U16 packet_flow_identifier)
1031 {
1032 TRACE_FUNCTION("sndcp_set_nsapi_pktflowid");
1033 {
1034 sndcp_data->nsapi_pktflowid_ra[nsapi] = packet_flow_identifier;
1035 }
1036 }
1037 #endif /* CF_FAST_EXEC */
1038
1039 #endif /*REL99*/
1040
1041 /*
1042 +------------------------------------------------------------------------------
1043 | Function : sndcp_set_nsapi_qos
1044 +------------------------------------------------------------------------------
1045 | Description : sets nsapi_qos_ra[nsapi] to qos
1046 |
1047 | Parameters : UBYTE nsapi, T_snsm_qos qos
1048 |
1049 +------------------------------------------------------------------------------
1050 */
1051 #ifndef CF_FAST_EXEC
1052
1053 GLOBAL void sndcp_set_nsapi_qos(UBYTE nsapi,
1054 T_snsm_qos qos)
1055 {
1056 TRACE_FUNCTION("sndcp_set_nsapi_qos");
1057 {
1058 sndcp_data->nsapi_qos_ra[nsapi].delay = qos.delay;
1059 sndcp_data->nsapi_qos_ra[nsapi].relclass = qos.relclass;
1060 sndcp_data->nsapi_qos_ra[nsapi].peak = qos.peak;
1061 sndcp_data->nsapi_qos_ra[nsapi].preced = qos.preced;
1062 sndcp_data->nsapi_qos_ra[nsapi].mean = qos.mean;
1063 }
1064 }
1065
1066 #endif /* CF_FAST_EXEC */
1067
1068 /*
1069 +------------------------------------------------------------------------------
1070 | Function : sndcp_set_nsapi_sapi
1071 +------------------------------------------------------------------------------
1072 | Description : sets nsapi_sapi_ra[nsapi] to sapi
1073 |
1074 | Parameters : UBYTE nsapi, UBYTE sapi
1075 |
1076 +------------------------------------------------------------------------------
1077 */
1078 #ifndef CF_FAST_EXEC
1079
1080 GLOBAL void sndcp_set_nsapi_sapi(UBYTE nsapi,
1081 UBYTE sapi)
1082 {
1083 TRACE_FUNCTION("sndcp_set_nsapi_sapi");
1084 {
1085 sndcp_data->nsapi_sapi_ra[nsapi] = sapi;
1086 }
1087 }
1088
1089 #endif /* CF_FAST_EXEC */
1090
1091 /*
1092 +------------------------------------------------------------------------------
1093 | Function : sndcp_set_nsapi_state
1094 +------------------------------------------------------------------------------
1095 | Description : adds stat to nsapi_state_ra[nsapi]
1096 |
1097 | Parameters : UBYTE nsapi, UBYTE stat
1098 |
1099 +------------------------------------------------------------------------------
1100 */
1101 #ifndef CF_FAST_EXEC
1102 GLOBAL void sndcp_set_nsapi_state(UBYTE nsapi,
1103 USHORT stat)
1104 {
1105 TRACE_FUNCTION("sndcp_set_nsapi_state");
1106 {
1107 sndcp_data->nsapi_state_ra[nsapi] |= stat;
1108 }
1109 }
1110
1111 #endif /* CF_FAST_EXEC */
1112
1113
1114 /*
1115 +------------------------------------------------------------------------------
1116 | Function : sndcp_ip_packet_filter
1117 +------------------------------------------------------------------------------
1118 | Description : The function filters TCP and UDP packets on certain ports
1119 |
1120 | Parameters : T_desc_list2 *desc_list, BOOL *discard
1121 |
1122 +------------------------------------------------------------------------------
1123 */
1124 #ifdef _SNDCP_DTI_2_
1125 LOCAL void sndcp_ip_packet_filter(T_desc_list2 *desc_list, BOOL *discard)
1126 {
1127 T_desc2 *desc = (T_desc2 *)desc_list->first;
1128 UBYTE *pack_hdr = &desc->buffer[desc->offset];
1129 UBYTE *tcp_hdr = NULL,
1130 *udp_hdr = NULL;
1131 USHORT offset = 0;
1132 USHORT src_port = 0;
1133 USHORT dest_port = 0;
1134
1135 TRACE_FUNCTION("sndcp_ip_packet_filter");
1136
1137 if(desc_list == NULL || desc_list->first == NULL || desc_list->list_len == 0){
1138 *discard = TRUE; /* discard packet */
1139 return;
1140 }
1141
1142 offset = (pack_hdr[0] & 0x0f) * 4; /* IP header length in bytes*/
1143 /* Verify, that the desc has a proper length */
1144 if(desc->len < (offset + 4)){
1145 return;
1146 }
1147
1148 switch(pack_hdr[9]){
1149 /* ICMP Protocol */
1150 case 1:
1151 *discard = FALSE; /* don't discard ICMP packets */
1152 /* TRACE_EVENT("INFO IP FILTER: ICMP packet is sent"); */
1153 return;
1154 /* TCP Protocol */
1155 case 6:
1156 tcp_hdr = &pack_hdr[offset];
1157 src_port |= tcp_hdr[0] << 8;
1158 src_port |= tcp_hdr[1];
1159 dest_port |= tcp_hdr[2] << 8;
1160 dest_port |= tcp_hdr[3];
1161 if(src_port == 42 || /* Host Name Server */
1162 dest_port == 42 ||
1163 src_port == 111 || /* Remote Procedure Call */
1164 dest_port == 111 ||
1165 ((src_port > 134) && (src_port < 140)) || /* NetBIOS */
1166 ((dest_port > 134) && (dest_port < 140)) || /* NetBIOS */
1167 src_port == 445 || /* Microsoft-DS */
1168 dest_port == 445 ||
1169 src_port == 1025 || /* network blackjack */
1170 dest_port == 1025 ||
1171 src_port == 1196 || /* listener RFS */
1172 dest_port == 1196 ||
1173 src_port == 1433 || /* Microsoft-SQL-Server */
1174 dest_port == 1433 ||
1175 src_port == 1434 || /* Microsoft-SQL-Monitor */
1176 dest_port == 1434
1177 ){
1178 *discard = TRUE; /* discard this TCP packet */
1179 /*TRACE_EVENT_P2("INFO IP FILTER: TCP packet on dest_port %d, src_port %d is discarded",
1180 dest_port, src_port);*/
1181 } else {
1182 *discard = FALSE; /* dont't discard this TCP packet */
1183 /*TRACE_EVENT_P2("INFO IP FILTER: TCP packet on dest_port %d, src_port %d is sent",
1184 dest_port, src_port);*/
1185 }
1186 return;
1187 /* UDP Protocol */
1188 case 17:
1189 udp_hdr = &pack_hdr[offset];
1190 src_port |= udp_hdr[0] << 8;
1191 src_port |= udp_hdr[1];
1192 dest_port |= udp_hdr[2] << 8;
1193 dest_port |= udp_hdr[3];
1194 if(src_port == 42 || /* Host Name Server */
1195 dest_port == 42 ||
1196 src_port == 67 || /* DHCP BOOTP Protocol Server */
1197 dest_port == 67 ||
1198 src_port == 68 || /* DHCP BOOTP Protocol Client */
1199 dest_port == 68 ||
1200 src_port == 69 || /* Trivial FTP */
1201 dest_port == 69 ||
1202 src_port == 111 || /* Remote Procedure Call */
1203 dest_port == 111 ||
1204 src_port == 135 || /* NetBIOS & co */
1205 dest_port == 135 ||
1206 src_port == 137 || /* NetBIOS & co*/
1207 dest_port == 137 ||
1208 src_port == 138 || /* NetBIOS & co*/
1209 dest_port == 138 ||
1210 src_port == 139 || /* NetBIOS & co*/
1211 dest_port == 139 ||
1212 src_port == 389 || /* LDAP */
1213 dest_port == 389 ||
1214 src_port == 445 || /* Microsoft-DS */
1215 dest_port == 445 ||
1216 src_port == 1023 || /* network blackjack & co */
1217 dest_port == 1023 ||
1218 src_port == 1026 || /* network blackjack & co */
1219 dest_port == 1026 ||
1220 src_port == 1027 || /* network blackjack & co */
1221 dest_port == 1027 ||
1222 src_port == 1028 || /* network blackjack & co */
1223 dest_port == 1028 ||
1224 src_port == 1029 || /* network blackjack & co */
1225 dest_port == 1029
1226 ){
1227 *discard = TRUE; /* discard this UDP packet */
1228 /*TRACE_EVENT_P2("INFO IP FILTER: UDP packet on dest_port %d, src_port %d is discarded",
1229 dest_port, src_port);*/
1230 } else {
1231 *discard = FALSE; /* dont't discard this UDP packet */
1232 /*TRACE_EVENT_P2("INFO IP FILTER: UDP packet on dest_port %d, src_port %d is sent",
1233 dest_port, src_port);*/
1234 }
1235 return;
1236 default:
1237 *discard = TRUE; /* discard all other packets */
1238 TRACE_EVENT_P1("INFO IP FILTER: protocol type %d is discarded", pack_hdr[9]);
1239 return;
1240 }
1241 }
1242 #endif /* _SNDCP_DTI_2_ */
1243
1244 /*
1245 +------------------------------------------------------------------------------
1246 | Function : sndcp_sig_callback
1247 +------------------------------------------------------------------------------
1248 | Description : callback function for dti lib.
1249 |
1250 | Parameters :
1251 |
1252 +------------------------------------------------------------------------------
1253 */
1254 #ifdef _SNDCP_DTI_2_
1255 #ifndef CF_FAST_EXEC
1256
1257 GLOBAL void sndcp_sig_callback(U8 instance,
1258 U8 interfac,
1259 U8 channel,
1260 U8 reason,
1261 T_DTI2_DATA_IND *dti2_data_ind)
1262 {
1263 T_SN_DATA_REQ* sn_data_req = NULL;
1264 T_SN_UNITDATA_REQ* sn_unitdata_req = NULL;
1265 BOOL ack = FALSE;
1266
1267 TRACE_FUNCTION("sndcp_sig_callback");
1268
1269
1270 switch(reason)
1271 {
1272 case DTI_REASON_CONNECTION_OPENED:
1273 /*
1274 * set rx and tx state machine of the given interface to idle state
1275 */
1276 /*
1277 * The nsapi is given here with the parameter 'channel'.
1278 */
1279 nu_connection_state(channel, TRUE);
1280 break;
1281 case DTI_REASON_CONNECTION_CLOSED:
1282 /*
1283 * set the given interface to closed state
1284 */
1285 break;
1286 case DTI_REASON_DATA_RECEIVED:
1287 /*
1288 * process received data
1289 */
1290 /*
1291 * Trace p_id.
1292 */
1293
1294
1295
1296 #ifdef TI_PS_OP_ICUT_SNDCP
1297
1298 /* PDP_TBR added SNDCP terminal loopback */
1299 if ( SNDCP_LOOPBACK == 1)
1300 {
1301 if (bufFull[channel] == FALSE)
1302 {
1303 TRACE_EVENT_P1("LOOPBACK len=%d", dti2_data_ind->desc_list2.list_len);
1304
1305 dti_send_data(sndcp_data->hDTI,
1306 instance, // U8 instance,
1307 SNDCP_INTERFACE_UNACK, // U8 interface,
1308 channel,// U8 channel,
1309 dti2_data_ind // T_DTI2_DATA_IND *dti_data_ind)
1310 );
1311 }
1312 else
1313 {
1314 saveDti2_data_ind[channel] = dti2_data_ind;
1315 }
1316 return;
1317 }
1318
1319
1320
1321 #endif /* TI_PS_OP_ICUT_SNDCP */
1322
1323
1324
1325
1326
1327 #ifdef SNDCP_TRACE_ALL
1328 switch (dti2_data_ind->parameters.p_id) {
1329 case DTI_PID_IP:
1330 TRACE_EVENT_P2("dti2_data_ind->parameters.p_id: %02x (%s)",
1331 dti2_data_ind->parameters.p_id,
1332 "DTI_PID_IP");
1333 break;
1334 case DTI_PID_CTCP:
1335 TRACE_EVENT_P2("dti2_data_ind->parameters.p_id: %02x (%s)",
1336 dti2_data_ind->parameters.p_id,
1337 "DTI_PID_CTCP");
1338 break;
1339 case DTI_PID_UTCP:
1340 TRACE_EVENT_P2("dti2_data_ind->parameters.p_id: %02x (%s)",
1341 dti2_data_ind->parameters.p_id,
1342 "DTI_PID_UTCP");
1343 break;
1344 case DTI_PID_UOS:
1345 TRACE_EVENT_P2("dti2_data_ind->parameters.p_id: %02x (%s)",
1346 dti2_data_ind->parameters.p_id,
1347 "DTI_PID_UOS");
1348 break;
1349 default:
1350 TRACE_EVENT_P2("dti2_data_ind->parameters.p_id: %02x (%s)",
1351 dti2_data_ind->parameters.p_id,
1352 "unknown");
1353
1354
1355 }
1356 #endif /* SNDCP_TRACE_ALL */
1357 /*
1358 * Discard DTI primitive if the config prim "DISCARD" was received
1359 */
1360 sndcp_data->nu = &sndcp_data->nu_base[channel];
1361 if(sndcp_data->nu->discard){
1362 TRACE_EVENT_P1("INFO DISCARD: UL packet with length %d is discarded",
1363 dti2_data_ind->desc_list2.list_len );
1364 sndcp_data->nu->discarded_data += dti2_data_ind->desc_list2.list_len;
1365 PFREE_DESC2(dti2_data_ind);
1366 dti2_data_ind = NULL;
1367 break;
1368 }
1369 /*
1370 * If the IP filter is enabled (config prim "IP_FILTER_ON" was received),
1371 * filter the packets.
1372 */
1373 if(sndcp_data->ip_filter){
1374 BOOL discard;
1375 /* Statistics Trace */
1376 TRACE_EVENT_P3("INFO NSAPI[%d]: sent bytes: %d, discarded bytes: %d",
1377 channel, sndcp_data->nu->sent_data, sndcp_data->nu->discarded_data);
1378 sndcp_ip_packet_filter(&dti2_data_ind->desc_list2, &discard);
1379 if(discard){
1380 sndcp_data->nu->discarded_data += dti2_data_ind->desc_list2.list_len;
1381 PFREE_DESC2(dti2_data_ind);
1382 dti2_data_ind = NULL;
1383 break;
1384 } else {
1385 sndcp_data->nu->sent_data += dti2_data_ind->desc_list2.list_len;
1386 }
1387 }
1388 /*
1389 * Copy dti_data_ind to sn_[unit]data_ind and enter nu service the
1390 * old way.
1391 */
1392 sndcp_get_nsapi_ack(channel, &ack);
1393 if (ack) {
1394 /*
1395 * Allocate a "normal" SN_DATA_REQ primitive and copy the data
1396 * of the test primitive to that one
1397 */
1398 MALLOC(sn_data_req, sizeof(T_SN_DATA_REQ));
1399 sn_data_req->nsapi = channel;
1400 sn_data_req->p_id = dti2_data_ind->parameters.p_id;
1401 sn_data_req->desc_list2 = dti2_data_ind->desc_list2;
1402
1403 /*
1404 * Free the received dti primitive.
1405 */
1406 PFREE (dti2_data_ind);
1407 dti2_data_ind = NULL;
1408
1409 nu_sn_data_req(sn_data_req);
1410
1411 } else {
1412 /*
1413 * Allocate a "normal" SN_UNITDATA_REQ primitive and copy the data
1414 * of the test primitive to that one
1415 */
1416 MALLOC(sn_unitdata_req, sizeof(T_SN_UNITDATA_REQ));
1417
1418 sn_unitdata_req->nsapi = channel;
1419 sn_unitdata_req->p_id = dti2_data_ind->parameters.p_id;
1420 sn_unitdata_req->desc_list2 = dti2_data_ind->desc_list2;
1421
1422 /*
1423 * Free the received dti 2 primitive.
1424 */
1425 PFREE (dti2_data_ind);
1426 dti2_data_ind = NULL;
1427
1428 nu_sn_unitdata_req(sn_unitdata_req);
1429
1430 }
1431
1432 break;
1433 case DTI_REASON_TX_BUFFER_FULL:
1434 /*
1435 * set tx state machine of the given interface to TX_IDLE state
1436 */
1437
1438
1439
1440 #ifdef TI_PS_OP_ICUT_SNDCP
1441
1442 /* PDP_TBR added SNDCP terminal loopback */
1443 if (SNDCP_LOOPBACK == 1)
1444 {
1445 dti_stop(sndcp_data->hDTI,
1446 instance,
1447 interfac,
1448 channel);
1449 bufFull[channel] = TRUE;
1450 TRACE_EVENT("SNDCP BUFFER IS FULL");
1451 }
1452
1453 #endif /* TI_PS_OP_ICUT_SNDCP */
1454
1455
1456
1457 /*
1458 * Will be ignored.
1459 */
1460 break;
1461 case DTI_REASON_TX_BUFFER_READY:
1462 /*
1463 * set tx state machine of the given interface to TX_READY state
1464 */
1465
1466
1467
1468
1469 #ifdef TI_PS_OP_ICUT_SNDCP
1470 /* PDP_TBR added SNDCP terminal loopback */
1471 if ( SNDCP_LOOPBACK == 1)
1472 {
1473 dti_start(sndcp_data->hDTI,
1474 instance,
1475 interfac,
1476 channel);
1477 bufFull[channel] = FALSE;
1478 TRACE_ERROR("SNDCP BUFFER IS READY");
1479 if (saveDti2_data_ind[channel] != NULL)
1480 {
1481 TRACE_EVENT_P1("LOOPBACK len=%d", dti2_data_ind->desc_list2.list_len);
1482
1483 dti_send_data(sndcp_data->hDTI,
1484 instance, // U8 instance,
1485 SNDCP_INTERFACE_UNACK, // U8 interface,
1486 channel,// U8 channel,
1487 saveDti2_data_ind[channel] // T_DTI2_DATA_IND *dti_data_ind)
1488 );
1489 saveDti2_data_ind[channel] = NULL;
1490
1491 }
1492 break;
1493 }
1494 #endif /* TI_PS_OP_ICUT_SNDCP */
1495
1496
1497
1498
1499 /*
1500 * Reaction will be like reaction to SN_GET[UNIT]DATA_REQ.
1501 */
1502 nd_dti_buffer_ready(channel);
1503 break;
1504 default:
1505 TRACE_ERROR("sndcp_sig_callback called with undefined reason");
1506 }
1507 }
1508
1509 #endif /* CF_FAST_EXEC */
1510
1511
1512 #else /*_SNDCP_DTI_2_*/
1513
1514 #ifndef CF_FAST_EXEC
1515
1516 GLOBAL void sndcp_sig_callback(U8 instance,
1517 U8 interfac,
1518 U8 channel,
1519 U8 reason,
1520 T_DTI_DATA_IND *dti_data_ind)
1521 {
1522 TRACE_FUNCTION("sndcp_sig_callback");
1523
1524 switch(reason)
1525 {
1526 case DTI_REASON_CONNECTION_OPENED:
1527 /*
1528 * set rx and tx state machine of the given interface to idle state
1529 */
1530 /*
1531 * The nsapi is given here with the parameter 'channel'.
1532 */
1533 nu_connection_state(channel, TRUE);
1534 break;
1535 case DTI_REASON_CONNECTION_CLOSED:
1536 /*
1537 * set the given interface to closed state
1538 */
1539 break;
1540 case DTI_REASON_DATA_RECEIVED:
1541 /*
1542 * process received data
1543 */
1544 /*
1545 * Trace p_id.
1546 */
1547 #ifdef SNDCP_TRACE_ALL
1548 switch (dti_data_ind->p_id) {
1549 case DTI_PID_IP:
1550 TRACE_EVENT_P2("dti_data_ind->p_id: %02x (%s)",
1551 dti_data_ind->p_id,
1552 "DTI_PID_IP");
1553 break;
1554 case DTI_PID_CTCP:
1555 TRACE_EVENT_P2("dti_data_ind->p_id: %02x (%s)",
1556 dti_data_ind->p_id,
1557 "DTI_PID_CTCP");
1558 break;
1559 case DTI_PID_UTCP:
1560 TRACE_EVENT_P2("dti_data_ind->p_id: %02x (%s)",
1561 dti_data_ind->p_id,
1562 "DTI_PID_UTCP");
1563 break;
1564 case DTI_PID_FRAME:
1565 TRACE_EVENT_P2("dti_data_ind->p_id: %02x (%s)",
1566 dti_data_ind->p_id,
1567 "DTI_PID_FRAME");
1568 break;
1569 default:
1570 TRACE_EVENT_P2("dti_data_ind->p_id: %02x (%s)",
1571 dti_data_ind->p_id,
1572 "unknown");
1573
1574
1575 }
1576 #endif /* SNDCP_TRACE_ALL */
1577 /*
1578 * Copy dti_data_ind to sn_[unit]data_ind and enter nu service the
1579 * old way.
1580 */
1581 if (interfac == SNDCP_INTERFACE_ACK) {
1582 /*
1583 * Allocate a "normal" SN_DATA_REQ primitive and copy the data
1584 * of the test primitive to that one
1585 */
1586 PALLOC_DESC (sn_data_req, SN_DATA_REQ);
1587
1588 sn_data_req->nsapi = channel;
1589 sn_data_req->p_id = dti_data_ind->p_id;
1590 sn_data_req->desc_list = dti_data_ind->desc_list;
1591
1592 /*
1593 * Free the received dti primitive.
1594 */
1595 PFREE (dti_data_ind);
1596 dti_data_ind = NULL;
1597
1598 nu_sn_data_req(sn_data_req);
1599
1600 } else {
1601 /*
1602 * Allocate a "normal" SN_UNITDATA_REQ primitive and copy the data
1603 * of the test primitive to that one
1604 */
1605 PALLOC_DESC (sn_unitdata_req, SN_UNITDATA_REQ);
1606
1607 sn_unitdata_req->nsapi = channel;
1608 sn_unitdata_req->p_id = dti_data_ind->p_id;
1609 sn_unitdata_req->desc_list = dti_data_ind->desc_list;
1610
1611 /*
1612 * Free the received test primitive.
1613 */
1614 PFREE (dti_data_ind);
1615 dti_data_ind = NULL;
1616
1617 nu_sn_unitdata_req(sn_unitdata_req);
1618
1619 }
1620
1621 break;
1622 case DTI_REASON_TX_BUFFER_FULL:
1623 /*
1624 * set tx state machine of the given interface to TX_IDLE state
1625 */
1626 /*
1627 * Will be ignored.
1628 */
1629 break;
1630 case DTI_REASON_TX_BUFFER_READY:
1631 /*
1632 * set tx state machine of the given interface to TX_READY state
1633 */
1634 /*
1635 * Reaction will be like reaction to SN_GET[UNIT]DATA_REQ.
1636 */
1637 nd_dti_buffer_ready(channel);
1638 break;
1639 default:
1640 TRACE_ERROR("sndcp_sig_callback called with undefined reason");
1641 }
1642 }
1643 #endif /* CF_FAST_EXEC */
1644
1645 #endif /*_SNDCP_DTI_2_*/
1646
1647 /*
1648 +------------------------------------------------------------------------------
1649 | Function : sndcp_unset_nsapi_state
1650 +------------------------------------------------------------------------------
1651 | Description : subtracts stat from nsapi_state_ra[nsapi]
1652 |
1653 | Parameters : UBYTE nsapi, UBYTE stat
1654 |
1655 +------------------------------------------------------------------------------
1656 */
1657 #ifndef CF_FAST_EXEC
1658
1659 GLOBAL void sndcp_unset_nsapi_state(UBYTE nsapi,
1660 USHORT stat)
1661 {
1662 TRACE_FUNCTION("sndcp_unset_nsapi_state");
1663 {
1664 sndcp_data->nsapi_state_ra[nsapi] &= ~ stat;
1665 }
1666 }
1667
1668 #endif /* CF_FAST_EXEC */
1669
1670 /*
1671 +------------------------------------------------------------------------------
1672 | Function : sndcp_set_nsapi_used
1673 +------------------------------------------------------------------------------
1674 | Description : sets nsapi_used_ra[nsapi] to b
1675 |
1676 | Parameters : UBYTE nsapi, BOOL b
1677 |
1678 +------------------------------------------------------------------------------
1679 */
1680 #ifndef CF_FAST_EXEC
1681
1682 GLOBAL void sndcp_set_nsapi_used(UBYTE nsapi,
1683 BOOL b)
1684 {
1685 TRACE_FUNCTION("sndcp_set_nsapi_used");
1686 {
1687 sndcp_data->nsapi_used_ra[nsapi] = b;
1688 }
1689 }
1690
1691 #endif /* CF_FAST_EXEC */
1692
1693 /*
1694 +------------------------------------------------------------------------------
1695 | Function : sndcp_set_sapi_ack
1696 +------------------------------------------------------------------------------
1697 | Description : sets sapi_ack_ra[sapi] to ack
1698 |
1699 | Parameters : UBYTE sapi, BOOL ack
1700 |
1701 +------------------------------------------------------------------------------
1702 */
1703 #ifndef CF_FAST_EXEC
1704
1705 GLOBAL void sndcp_set_sapi_ack(UBYTE sapi,
1706 BOOL ack)
1707 {
1708 TRACE_FUNCTION(" sndcp_set_sapi_ack ");
1709 {
1710 UBYTE sapi_index = 0;
1711
1712 sndcp_get_sapi_index(sapi, &sapi_index);
1713 sndcp_data->sapi_ack_ra[sapi_index] = ack;
1714 }
1715 }
1716
1717 #endif /* CF_FAST_EXEC */
1718
1719 /*
1720 +------------------------------------------------------------------------------
1721 | Function : sndcp_snsm_qos_to_ll_qos
1722 +------------------------------------------------------------------------------
1723 | Description : transfers an snsm_qos to an ll_qos
1724 |
1725 | Parameters : T_snsm_qos, T_ll_qos*
1726 |
1727 +------------------------------------------------------------------------------
1728 */
1729 #ifndef CF_FAST_EXEC
1730
1731 GLOBAL void sndcp_snsm_qos_to_ll_qos(T_snsm_qos snsm_qos,
1732 T_ll_qos* ll_qos)
1733 {
1734 TRACE_FUNCTION("sndcp_snsm_qos_to_ll_qos");
1735 {
1736 ll_qos->delay = snsm_qos.delay;
1737 ll_qos->relclass = snsm_qos.relclass;
1738 ll_qos->peak = snsm_qos.peak;
1739 ll_qos->preced = snsm_qos.preced;
1740 ll_qos->mean = snsm_qos.mean;
1741 }
1742 }
1743
1744 #endif /* CF_FAST_EXEC */
1745
1746 /*
1747 +------------------------------------------------------------------------------
1748 | Function : sndcp_set_sapi_state
1749 +------------------------------------------------------------------------------
1750 | Description : adds stat to sapi_state_ra[sapi] bitwise
1751 |
1752 | Parameters : UBYTE sapi, UBYTE stat
1753 |
1754 +------------------------------------------------------------------------------
1755 */
1756 #ifndef CF_FAST_EXEC
1757
1758 GLOBAL void sndcp_set_sapi_state(UBYTE sapi,
1759 USHORT stat)
1760 {
1761 TRACE_FUNCTION(" sndcp_set_sapi_state ");
1762 {
1763 UBYTE sapi_index = 0;
1764 sndcp_get_sapi_index(sapi, &sapi_index);
1765 sndcp_data->sapi_state_ra[sapi_index] |= stat;
1766 }
1767 }
1768
1769 #endif /* CF_FAST_EXEC */
1770
1771 /*
1772 +------------------------------------------------------------------------------
1773 | Function : sndcp_unset_sapi_state
1774 +------------------------------------------------------------------------------
1775 | Description : subtracts stat from sapi_state_ra[sapi] bitwise
1776 |
1777 | Parameters : UBYTE sapi, UBYTE stat
1778 |
1779 +------------------------------------------------------------------------------
1780 */
1781 #ifndef CF_FAST_EXEC
1782
1783 GLOBAL void sndcp_unset_sapi_state(UBYTE sapi,
1784 USHORT stat)
1785 {
1786 TRACE_FUNCTION(" sndcp_unset_sapi_state ");
1787 {
1788 UBYTE sapi_index = 0;
1789 sndcp_get_sapi_index(sapi, &sapi_index);
1790 sndcp_data->sapi_state_ra[sapi_index] &= ~ stat;
1791 }
1792 }
1793
1794 #endif /* CF_FAST_EXEC */
1795
1796 #ifdef FLOW_TRACE
1797 /*
1798 +------------------------------------------------------------------------------
1799 | Function : sndcp_trace_flow_control
1800 +------------------------------------------------------------------------------
1801 | Description : traces flow control
1802 |
1803 | Parameters : UBYTE entity, UBYTE uplink, UBYTE sent, BOOL close
1804 |
1805 +------------------------------------------------------------------------------
1806 */
1807 /*
1808 * 0 GRR
1809 * 1 LLC
1810 * 2 SNDCP
1811 * 3 PPP
1812 * 4 UART
1813 */
1814
1815 /*
1816 #define FLOW_TRACE_GRR 0
1817 #define FLOW_TRACE_LLC 1
1818 #define FLOW_TRACE_SNDCP 2
1819 #define FLOW_TRACE_PPP 3
1820 #define FLOW_TRACE_UART 4
1821
1822 direction of data transfer
1823
1824 #define FLOW_TRACE_UP 0
1825 #define FLOW_TRACE_DOWN 1
1826
1827 is sap sitting on top of entity or is lower entity sap used?
1828
1829 #define FLOW_TRACE_TOP 0
1830 #define FLOW_TRACE_BOTTOM 1
1831 */
1832
1833
1834 #ifndef CF_FAST_EXEC
1835
1836 GLOBAL void sndcp_trace_flow_control(UBYTE entity, UBYTE transfer, UBYTE position, BOOL opened)
1837 {
1838 TRACE_FUNCTION(" sndcp_trace_flow_control ");
1839 #ifdef SNDCP_TRACE_ALL
1840 TRACE_EVENT_P4("sndcp_trace_flow_control[%d][%d][%d] = %d",
1841 entity,
1842 transfer,
1843 position,
1844 opened);
1845 #endif
1846 {
1847 sndcp_data->flow_control_ra[entity][transfer][position] = opened;
1848 }
1849 }
1850
1851 #endif /* CF_FAST_EXEC */
1852
1853 #endif /* FLOW_TRACE */
1854
1855
1856 #ifdef _SNDCP_DTI_2_
1857
1858 #ifdef SNDCP_TRACE_ALL
1859
1860 /*
1861 +------------------------------------------------------------------------------
1862 | Function : sndcp_trace_desc_list3_content
1863 +------------------------------------------------------------------------------
1864 | Description : traces content of a desc3 descriptor list
1865 |
1866 | Parameters : desc_list3 descriptor list
1867 |
1868 +------------------------------------------------------------------------------
1869 */
1870 #ifndef CF_FAST_EXEC
1871
1872 GLOBAL void sndcp_trace_desc_list3_content(T_desc_list3 desc_list3)
1873 {
1874 U16 current_pos = 0; /* */
1875 U16 data_len = 0; /* The length of the data to be traced including data offset */
1876 U8* p_data = NULL; /* Pointer to byte data element */
1877 T_desc3* p_desc3 = (T_desc3*)desc_list3.first; /* Pointer to the actual desc3 descriptor element */
1878
1879 while(p_desc3 != NULL)
1880 {
1881 current_pos = p_desc3->offset; /* In case it is the sndcp header allocation, ENCODE_OFFSET has been considered*/
1882 p_data = (U8*)p_desc3->buffer;
1883 data_len = current_pos + p_desc3->len; /* p_desc3->len is the total allocation length for sndcp header description */
1884 while(current_pos <= data_len)
1885 {
1886 TRACE_EVENT_P1
1887 ("%02x",
1888 p_data[current_pos]
1889 );
1890 current_pos ++;
1891 }
1892
1893 p_desc3 = (T_desc3*)p_desc3->next;
1894 }
1895 }
1896
1897 #endif /* CF_FAST_EXEC */
1898
1899 #endif /* SNDCP_TRACE_ALL */
1900
1901 /*
1902 +------------------------------------------------------------------------------
1903 | Function : sndcp_cl_desc2_attach
1904 +------------------------------------------------------------------------------
1905 | Description : This function attaches a decriptor list to already allocated
1906 | memory. There is no return value. In case an attempt is made
1907 | to attach to freed or invalid memory, then the FRAME generates
1908 | a trace SYSTEM ERROR. This function does not allocate any new
1909 | memory.
1910 |
1911 | Parameters : T_desc2* pointer to desc2 descriptor.
1912 |
1913 +------------------------------------------------------------------------------
1914 */
1915 #ifndef CF_FAST_EXEC
1916
1917 void sndcp_cl_desc2_attach(T_desc2* p_desc2)
1918 {
1919
1920 MATTACH(p_desc2);
1921
1922 }
1923
1924 #endif /* CF_FAST_EXEC */
1925 /*
1926 +------------------------------------------------------------------------------
1927 | Function : sndcp_cl_desc3_free
1928 +------------------------------------------------------------------------------
1929 | Description : Frees the descriptor connected to the desc3 descriptor. This
1930 | free will when applicable cause the frame to decrease a
1931 | connected counter attached to the allocation or really free
1932 | the memory in case the counter is zero.
1933 |
1934 | Parameters : T_desc3* pointer to desc3 descriptor.
1935 |
1936 +------------------------------------------------------------------------------
1937 */
1938 #ifndef CF_FAST_EXEC
1939
1940 void sndcp_cl_desc3_free(T_desc3* p_desc3)
1941 {
1942
1943 MFREE(p_desc3->buffer);
1944 p_desc3->buffer = NULL;
1945 }
1946
1947 #endif /* CF_FAST_EXEC */
1948
1949 #endif /* _SNDCP_DTI_2_ */
1950
1951
1952 #ifdef SNDCP_TRACE_ALL
1953
1954 /*
1955 +------------------------------------------------------------------------------
1956 | Function : sndcp_trace_sdu
1957 +------------------------------------------------------------------------------
1958 | Description : traces content of one sdu
1959 |
1960 | Parameters : pointer to sdu
1961 |
1962 +------------------------------------------------------------------------------
1963 */
1964 #ifndef CF_FAST_EXEC
1965
1966 GLOBAL void sndcp_trace_sdu(T_sdu* sdu)
1967 {
1968
1969 USHORT pos = sdu->o_buf >> 3;
1970 USHORT frame_len = (sdu->l_buf + 7) / 8;
1971
1972
1973 TRACE_FUNCTION("sndcp_trace_sdu");
1974
1975 while(pos < (frame_len + (sdu->o_buf >> 3)))
1976 {
1977 if (pos + 8 <= (frame_len + (sdu->o_buf >> 3))) {
1978 TRACE_EVENT_P8
1979 ("%02x %02x %02x %02x %02x %02x %02x %02x",
1980 sdu->buf[pos],
1981 sdu->buf[pos + 1],
1982 sdu->buf[pos + 2],
1983 sdu->buf[pos + 3],
1984 sdu->buf[pos + 4],
1985 sdu->buf[pos + 5],
1986 sdu->buf[pos + 6],
1987 sdu->buf[pos + 7]
1988 );
1989 pos += 8;
1990 } else if (pos + 7 <= (frame_len + (sdu->o_buf >> 3))){
1991 TRACE_EVENT_P7
1992 ("%02x %02x %02x %02x %02x %02x %02x",
1993 sdu->buf[pos],
1994 sdu->buf[pos + 1],
1995 sdu->buf[pos + 2],
1996 sdu->buf[pos + 3],
1997 sdu->buf[pos + 4],
1998 sdu->buf[pos + 5],
1999 sdu->buf[pos + 6]
2000 );
2001 pos += 7;
2002 } else if (pos + 6 <= (frame_len + (sdu->o_buf >> 3))){
2003 TRACE_EVENT_P6
2004 ("%02x %02x %02x %02x %02x %02x",
2005 sdu->buf[pos],
2006 sdu->buf[pos + 1],
2007 sdu->buf[pos + 2],
2008 sdu->buf[pos + 3],
2009 sdu->buf[pos + 4],
2010 sdu->buf[pos + 5]
2011 );
2012 pos += 6;
2013 } else if (pos + 5 <= (frame_len + (sdu->o_buf >> 3))){
2014 TRACE_EVENT_P5
2015 ("%02x %02x %02x %02x %02x",
2016 sdu->buf[pos],
2017 sdu->buf[pos + 1],
2018 sdu->buf[pos + 2],
2019 sdu->buf[pos + 3],
2020 sdu->buf[pos + 4]
2021 );
2022 pos += 5;
2023 } else if (pos + 4 <= (frame_len + (sdu->o_buf >> 3))){
2024 TRACE_EVENT_P4
2025 ("%02x %02x %02x %02x",
2026 sdu->buf[pos],
2027 sdu->buf[pos + 1],
2028 sdu->buf[pos + 2],
2029 sdu->buf[pos + 3]
2030 );
2031 pos += 4;
2032 } else if (pos + 3 <= (frame_len + (sdu->o_buf >> 3))){
2033 TRACE_EVENT_P3
2034 ("%02x %02x %02x",
2035 sdu->buf[pos],
2036 sdu->buf[pos + 1],
2037 sdu->buf[pos + 2]
2038 );
2039 pos += 3;
2040 } else if (pos + 2 <= (frame_len + (sdu->o_buf >> 3))){
2041 TRACE_EVENT_P2
2042 ("%02x %02x",
2043 sdu->buf[pos],
2044 sdu->buf[pos + 1]
2045 );
2046 pos += 2;
2047 } else if (pos + 1 <= (frame_len + (sdu->o_buf >> 3))){
2048 TRACE_EVENT_P1
2049 ("%02x",
2050 sdu->buf[pos]
2051 );
2052 pos++;
2053 }
2054
2055 }
2056 }
2057
2058 #endif /* CF_FAST_EXEC */
2059
2060
2061 #endif /* SNDCP_TRACE_ALL */
2062
2063 #ifdef SNDCP_TRACE_BUFFER
2064
2065 /*
2066 +------------------------------------------------------------------------------
2067 | Function : sndcp_trace_desc_list
2068 +------------------------------------------------------------------------------
2069 | Description : traces content of one desc_list
2070 |
2071 | Parameters : pointer to desc_list
2072 |
2073 +------------------------------------------------------------------------------
2074 */
2075 #ifndef CF_FAST_EXEC
2076
2077 #ifdef _SNDCP_DTI_2_
2078 GLOBAL void sndcp_trace_desc_list(T_desc_list2* desc_list)
2079 {
2080 #else /*_SNDCP_DTI_2_*/
2081 GLOBAL void sndcp_trace_desc_list(T_desc_list* desc_list)
2082 {
2083 #endif /*_SNDCP_DTI_2_*/
2084 USHORT frame_len = desc_list->list_len;
2085 #ifdef _SNDCP_DTI_2_
2086 T_desc2* desc = (T_desc2*)desc_list->first;
2087 USHORT desc_pos = desc->offset;
2088 USHORT desc_end = desc->len + desc->offset;
2089 #else /*_SNDCP_DTI_2_*/
2090 T_desc* desc = (T_desc*)desc_list->first;
2091 USHORT desc_pos = 0;
2092 USHORT desc_end = desc->len;
2093 #endif /*_SNDCP_DTI_2_*/
2094 USHORT list_pos = 0;
2095
2096 TRACE_FUNCTION("sndcp_trace_desc_list");
2097
2098 while(list_pos < frame_len)
2099 {
2100 if (desc != NULL) {
2101 if (desc_pos >= desc_end) {
2102 #ifdef _SNDCP_DTI_2_
2103 desc = (T_desc2*)desc->next;
2104 desc_pos = desc->offset;
2105 desc_end = desc->len + desc->offset;
2106 #else /*_SNDCP_DTI_2_*/
2107 desc = (T_desc*)desc->next;
2108 desc_pos = 0;
2109 desc_end = desc->len;
2110 #endif /*_SNDCP_DTI_2_*/
2111 }
2112 }
2113 if (desc == NULL) {
2114 return;
2115 }
2116 if (desc_pos + 8 <= desc_end) {
2117 TRACE_EVENT_P8 ("%02x %02x %02x %02x %02x %02x %02x %02x ",
2118 desc->buffer[desc_pos],
2119 desc->buffer[desc_pos + 1],
2120 desc->buffer[desc_pos + 2],
2121 desc->buffer[desc_pos + 3],
2122 desc->buffer[desc_pos + 4],
2123 desc->buffer[desc_pos + 5],
2124 desc->buffer[desc_pos + 6],
2125 desc->buffer[desc_pos + 7]
2126 );
2127 list_pos+= 8;
2128 desc_pos+= 8;
2129 } else if (desc_pos + 7 <= desc_end) {
2130 TRACE_EVENT_P7 ("%02x %02x %02x %02x %02x %02x %02x ",
2131 desc->buffer[desc_pos],
2132 desc->buffer[desc_pos + 1],
2133 desc->buffer[desc_pos + 2],
2134 desc->buffer[desc_pos + 3],
2135 desc->buffer[desc_pos + 4],
2136 desc->buffer[desc_pos + 5],
2137 desc->buffer[desc_pos + 6]
2138 );
2139 list_pos+= 7;
2140 desc_pos+= 7;
2141 } else if (desc_pos + 6 <= desc_end) {
2142 TRACE_EVENT_P6 ("%02x %02x %02x %02x %02x %02x ",
2143 desc->buffer[desc_pos],
2144 desc->buffer[desc_pos + 1],
2145 desc->buffer[desc_pos + 2],
2146 desc->buffer[desc_pos + 3],
2147 desc->buffer[desc_pos + 4],
2148 desc->buffer[desc_pos + 5]
2149 );
2150 list_pos+= 6;
2151 desc_pos+= 6;
2152 } else if (desc_pos + 5 <= desc_end) {
2153 TRACE_EVENT_P5 ("%02x %02x %02x %02x %02x ",
2154 desc->buffer[desc_pos],
2155 desc->buffer[desc_pos + 1],
2156 desc->buffer[desc_pos + 2],
2157 desc->buffer[desc_pos + 3],
2158 desc->buffer[desc_pos + 4]
2159 );
2160 list_pos+= 5;
2161 desc_pos+= 5;
2162 } else if (desc_pos + 4 <= desc_end) {
2163 TRACE_EVENT_P4 ("%02x %02x %02x %02x ",
2164 desc->buffer[desc_pos],
2165 desc->buffer[desc_pos + 1],
2166 desc->buffer[desc_pos + 2],
2167 desc->buffer[desc_pos + 3]
2168 );
2169 list_pos+= 4;
2170 desc_pos+= 4;
2171 } else if (desc_pos + 3 <= desc_end) {
2172 TRACE_EVENT_P3 ("%02x %02x %02x ",
2173 desc->buffer[desc_pos],
2174 desc->buffer[desc_pos + 1],
2175 desc->buffer[desc_pos + 2]
2176 );
2177 list_pos+= 3;
2178 desc_pos+= 3;
2179 } else if (desc_pos + 2 <= desc_end) {
2180 TRACE_EVENT_P2 ("%02x %02x ",
2181 desc->buffer[desc_pos],
2182 desc->buffer[desc_pos + 1]
2183 );
2184 list_pos+= 2;
2185 desc_pos+= 2;
2186 } else if (desc_pos + 1 <= desc_end) {
2187 TRACE_EVENT_P1 ("%02x ",
2188 desc->buffer[desc_pos]
2189 );
2190 list_pos++;
2191 desc_pos++;
2192 }
2193
2194 /* break tracing if payload shall not be traced*/
2195 if(!sndcp_data->trace_ip_datagram && (list_pos >= 40))
2196 break;
2197
2198 } /* while(list_pos < frame_len) */
2199
2200 }
2201
2202 #endif /* CF_FAST_EXEC */
2203
2204 #endif /* SNDCP_TRACE_BUFFER */
2205
2206
2207
2208 #ifdef _SNDCP_MEAN_TRACE_
2209 /*
2210 +------------------------------------------------------------------------------
2211 | Function : sndcp_sn_count_req
2212 +------------------------------------------------------------------------------
2213 | Description : reaction to prim SN_COUNT_REQ
2214 |
2215 | Parameters : primitive payload
2216 |
2217 +------------------------------------------------------------------------------
2218 */
2219 #ifndef CF_FAST_EXEC
2220
2221 GLOBAL void sndcp_sn_count_req(T_SN_COUNT_REQ* sn_count_req)
2222 {
2223 TRACE_FUNCTION("sndcp_sn_count_req");
2224
2225 {
2226 BOOL ack = FALSE;
2227 PALLOC(sn_count_cnf, SN_COUNT_CNF);
2228
2229 sn_count_cnf->nsapi = sn_count_req->nsapi;
2230
2231 sndcp_get_nsapi_ack(sn_count_req->nsapi, &ack);
2232 if (ack) {
2233 sn_count_cnf->octets_uplink =
2234 sndcp_data->cur_num_uplink_ack[sn_count_req->nsapi];
2235 sn_count_cnf->octets_downlink =
2236 sndcp_data->cur_num_downlink_ack[sn_count_req->nsapi];
2237
2238 sn_count_cnf->packets_uplink =
2239 sndcp_data->cur_pac_uplink_ack[sn_count_req->nsapi];
2240 sn_count_cnf->packets_downlink =
2241 sndcp_data->cur_pac_downlink_ack[sn_count_req->nsapi];
2242
2243 #ifdef SNDCP_UPM_INCLUDED
2244 if (sn_count_req->reset == NAS_RESET_YES) {
2245 #else
2246 if (sn_count_req->reset == SN_RESET_YES) {
2247 #endif /*SNDCP_UPM_INCLUDED*/
2248 sndcp_data->cur_num_uplink_ack[sn_count_req->nsapi] = 0;
2249 sndcp_data->cur_num_downlink_ack[sn_count_req->nsapi] = 0;
2250 sndcp_data->cur_pac_uplink_ack[sn_count_req->nsapi] = 0;
2251 sndcp_data->cur_pac_downlink_ack[sn_count_req->nsapi] = 0;
2252 }
2253
2254 } else {
2255
2256 sn_count_cnf->octets_uplink =
2257 sndcp_data->cur_num_uplink_unack[sn_count_req->nsapi];
2258 sn_count_cnf->octets_downlink =
2259 sndcp_data->cur_num_downlink_unack[sn_count_req->nsapi];
2260
2261 sn_count_cnf->packets_uplink =
2262 sndcp_data->cur_pac_uplink_unack[sn_count_req->nsapi];
2263 sn_count_cnf->packets_downlink =
2264 sndcp_data->cur_pac_downlink_unack[sn_count_req->nsapi];
2265
2266 #ifdef SNDCP_UPM_INCLUDED
2267 if (sn_count_req->reset == NAS_RESET_YES) {
2268 #else
2269 if (sn_count_req->reset == SN_RESET_YES) {
2270 #endif /*SNDCP_UPM_INCLUDED*/
2271 sndcp_data->cur_num_uplink_unack[sn_count_req->nsapi] = 0;
2272 sndcp_data->cur_num_downlink_unack[sn_count_req->nsapi] = 0;
2273 sndcp_data->cur_pac_uplink_unack[sn_count_req->nsapi] = 0;
2274 sndcp_data->cur_pac_downlink_unack[sn_count_req->nsapi] = 0;
2275 }
2276 }
2277
2278 #ifdef SNDCP_UPM_INCLUDED
2279 PSEND(hCommUPM, sn_count_cnf); /*count_cnf goes via UPM*/
2280 #else
2281 PSEND(hCommMMI, sn_count_cnf);
2282 #endif /*SNDCP_UPM_INCLUDED*/
2283
2284 }
2285
2286 PFREE(sn_count_req);
2287 }
2288
2289 #endif /* CF_FAST_EXEC */
2290
2291 #endif /*_SNDCP_MEAN_TRACE */
2292
2293 #ifdef SNDCP_TRACE_IP_DATAGRAM
2294
2295 /*
2296 +------------------------------------------------------------------------------
2297 | Function : sndcp_trace_ip_datagram
2298 +------------------------------------------------------------------------------
2299 | Description : traces content of one desc_list
2300 |
2301 | Parameters : pointer to desc_list
2302 |
2303 +------------------------------------------------------------------------------
2304 */
2305 #ifndef CF_FAST_EXEC
2306
2307 #ifdef _SNDCP_DTI_2_
2308 GLOBAL void sndcp_trace_ip_datagram(T_desc_list2* desc_list)
2309 {
2310 #else /*_SNDCP_DTI_2_*/
2311 GLOBAL void sndcp_trace_ip_datagram(T_desc_list* desc_list)
2312 {
2313 #endif /*_SNDCP_DTI_2_*/
2314 USHORT frame_len = desc_list->list_len;
2315 #ifdef _SNDCP_DTI_2_
2316 T_desc2* desc = (T_desc2*)desc_list->first;
2317 USHORT desc_pos = desc->offset;
2318 USHORT desc_end = desc->len + desc->offset;
2319 #else /*_SNDCP_DTI_2_*/
2320 T_desc* desc = (T_desc*)desc_list->first;
2321 USHORT desc_pos = 0;
2322 USHORT desc_end = desc->len;
2323 #endif /*_SNDCP_DTI_2_*/
2324 USHORT list_pos = 0;
2325 UBYTE *pack_hdr, *ip_hdr;
2326 USHORT t_length = 0;
2327 USHORT length = 0;
2328 USHORT pid = 0;
2329 USHORT f_offset = 0;
2330 USHORT h_checksum = 0;
2331 USHORT src_port = 0;
2332 USHORT dest_port = 0;
2333 ULONG seq_num = 0;
2334 ULONG ack_num = 0;
2335 USHORT window = 0;
2336 USHORT checksum = 0;
2337 USHORT urg_ptr = 0;
2338 USHORT ip_hlen = 0; /* IP header length */
2339 USHORT tcp_hlen = 0; /* TCP header length */
2340 UBYTE tmp_flag = 0;
2341 UBYTE type = 0;
2342 UBYTE code = 0;
2343 /*TRACE_FUNCTION("sndcp_trace_ip_datagram");*/
2344
2345 if(!sndcp_data->trace_ip_datagram && !sndcp_data->trace_ip_header){
2346 return;
2347 }
2348
2349 while(list_pos < frame_len)
2350 {
2351 if (desc != NULL) {
2352 if (desc_pos >= desc_end) {
2353 #ifdef _SNDCP_DTI_2_
2354 desc = (T_desc2*)desc->next;
2355 desc_pos = desc->offset;
2356 desc_end = desc->len + desc->offset;
2357 #else /*_SNDCP_DTI_2_*/
2358 desc = (T_desc*)desc->next;
2359 desc_pos = 0;
2360 desc_end = desc->len;
2361 #endif /*_SNDCP_DTI_2_*/
2362 if (desc == NULL) {
2363 break;
2364 }
2365 }
2366 } else {
2367 return;
2368 }
2369 if((list_pos == 0) || (list_pos >= t_length))
2370 {
2371 ip_hdr = &desc->buffer[desc_pos];
2372 if((ip_hdr[9] != 1) && (ip_hdr[9] != 6) && (ip_hdr[9] != 17)) {
2373 TRACE_EVENT_P1("INFO TRACE: Tracing of protocol type %d not supported",
2374 ip_hdr[9]);
2375 return;
2376 }
2377
2378 /* Trace IP Header */
2379 ip_hlen = (ip_hdr[0] & 0x0F) << 2;
2380 if ((desc_pos + ip_hlen) <= desc_end){
2381 TRACE_EVENT("IP Header");
2382 TRACE_EVENT_P1(" Protocol Version: %d",
2383 ((ip_hdr[0] & 0xF0) >> 4));
2384 TRACE_EVENT_P1(" Header Length: %d", (ip_hlen >> 2));
2385 TRACE_EVENT_P1(" Type Of Service: %d", ip_hdr[1]);
2386 t_length |= ip_hdr[2] << 8;
2387 t_length |= ip_hdr[3];
2388 TRACE_EVENT_P1(" Total Length: %d", t_length);
2389 pid |= ip_hdr[4] << 8;
2390 pid |= ip_hdr[5];
2391 TRACE_EVENT_P1(" Packet ID: %d", pid);
2392 TRACE_EVENT_P2(" MF|DF: %d|%d",
2393 (ip_hdr[6] & 0x20) >> 5,
2394 (ip_hdr[6] & 0x40) >> 6);
2395 f_offset |= (ip_hdr[6] & 0x1F) << 8;
2396 f_offset |= ip_hdr[7];
2397 TRACE_EVENT_P1(" Fragment offset: %d", f_offset);
2398 TRACE_EVENT_P1(" Time To Live: %d", ip_hdr[8]);
2399 if(ip_hdr[9] == 17) {
2400 TRACE_EVENT_P1(" Protocol: UDP(%d)",
2401 ip_hdr[9]);
2402 } else if (ip_hdr[9] == 6) {
2403 TRACE_EVENT_P1(" Protocol: TCP(%d)",
2404 ip_hdr[9]);
2405 } else {
2406 TRACE_EVENT_P1(" Protocol: %d",
2407 ip_hdr[9]);
2408 }
2409 h_checksum |= ip_hdr[10] << 8;
2410 h_checksum |= ip_hdr[11];
2411 TRACE_EVENT_P1(" Header Checksum: %d", h_checksum);
2412 TRACE_EVENT_P4(" Source Address: %d.%d.%d.%d",
2413 ip_hdr[12], ip_hdr[13],
2414 ip_hdr[14], ip_hdr[15]);
2415 TRACE_EVENT_P4(" Destination Address: %d.%d.%d.%d",
2416 ip_hdr[16], ip_hdr[17],
2417 ip_hdr[18], ip_hdr[19]);
2418 list_pos+= ip_hlen;
2419 desc_pos+= ip_hlen;
2420 }
2421 /* Trace TCP Header */
2422 if((ip_hdr[9] == 6) && ((desc_pos + 20) <= desc_end))
2423 {
2424 TRACE_EVENT("TCP Header");
2425 pack_hdr = &ip_hdr[ip_hlen];
2426 tcp_hlen = (pack_hdr[12] & 0xF0) >> 2; /* the same as (x>>4)*4 */
2427 src_port |= pack_hdr[0] << 8;
2428 src_port |= pack_hdr[1];
2429 TRACE_EVENT_P1(" Source Port: %d", src_port);
2430 dest_port |= pack_hdr[2] << 8;
2431 dest_port |= pack_hdr[3];
2432 TRACE_EVENT_P1(" Destination Port: %d", dest_port);
2433 seq_num |= pack_hdr[4] << 24;
2434 seq_num |= pack_hdr[5] << 16;
2435 seq_num |= pack_hdr[6] << 8;
2436 seq_num |= pack_hdr[7];
2437 TRACE_EVENT_P1(" Sequence Number: %u", seq_num);
2438 ack_num |= pack_hdr[8] << 24;
2439 ack_num |= pack_hdr[9] << 16;
2440 ack_num |= pack_hdr[10] << 8;
2441 ack_num |= pack_hdr[11];
2442 TRACE_EVENT_P1(" Acknowledgment Number: %u", ack_num);
2443 TRACE_EVENT_P1(" Data Offset: %d", (tcp_hlen >> 2));
2444 TRACE_EVENT_P6(" URG|ACK|PSH|RST|SYN|FIN: %d|%d|%d|%d|%d|%d",
2445 (pack_hdr[13] & 0x20) >> 5,
2446 (pack_hdr[13] & 0x10) >> 4,
2447 (pack_hdr[13] & 0x08) >> 3,
2448 (pack_hdr[13] & 0x04) >> 2,
2449 (pack_hdr[13] & 0x02) >> 1,
2450 (pack_hdr[13] & 0x01) );
2451 window |= pack_hdr[14] << 8;
2452 window |= pack_hdr[15];
2453 TRACE_EVENT_P1(" Window Size: %d", window);
2454 checksum |= pack_hdr[16] << 8;
2455 checksum |= pack_hdr[17];
2456 TRACE_EVENT_P1(" Checksum: %d", checksum);
2457 urg_ptr |= pack_hdr[18] << 8;
2458 urg_ptr |= pack_hdr[19];
2459 TRACE_EVENT_P1(" Ungent Pointer: 0x%04x", urg_ptr);
2460 list_pos+= tcp_hlen;
2461 desc_pos+= tcp_hlen;
2462 }
2463 /* Trace UDP Header */
2464 else if((ip_hdr[9] == 17) && ((desc_pos + 8) <= desc_end))
2465 {
2466 TRACE_EVENT("UDP Header");
2467 pack_hdr = &ip_hdr[ip_hlen];
2468 src_port |= pack_hdr[0] << 8;
2469 src_port |= pack_hdr[1];
2470 TRACE_EVENT_P1(" Source Port: %d", src_port);
2471 dest_port |= pack_hdr[2] << 8;
2472 dest_port |= pack_hdr[3];
2473 TRACE_EVENT_P1(" Destination Port: %d", dest_port);
2474 length |= pack_hdr[4] << 8;
2475 length |= pack_hdr[5];
2476 TRACE_EVENT_P1(" Length: %d", length);
2477 checksum |= pack_hdr[6] << 8;
2478 checksum |= pack_hdr[7];
2479 TRACE_EVENT_P1(" Checksum: %d", checksum);
2480 list_pos+= 8;
2481 desc_pos+= 8;
2482 }
2483 /* Trace ICMP Header */
2484 else if((ip_hdr[9] == 1) && ((desc_pos + 8) <= desc_end))
2485 {
2486 TRACE_EVENT("ICMP Header");
2487 pack_hdr = &ip_hdr[ip_hlen];
2488 type = pack_hdr[0];
2489 TRACE_EVENT_P1(" Message Type: %d", type);
2490 code = pack_hdr[1];
2491 TRACE_EVENT_P1(" Message Code: %d", code);
2492 checksum |= pack_hdr[2] << 8;
2493 checksum |= pack_hdr[3];
2494 TRACE_EVENT_P1(" Checksum: %d", checksum);
2495 list_pos+= 8;
2496 desc_pos+= 8;
2497 }
2498 }/* if((list_pos == 0) || (list_pos >= t_length)) */
2499 /* Shall payload be traced? */
2500 if(!sndcp_data->trace_ip_datagram){
2501 break;
2502 }
2503 /* Trace Payload */
2504 if(!tmp_flag && (desc_pos < frame_len)){
2505 TRACE_EVENT("Payload");
2506 tmp_flag = 1;
2507 }
2508 /*lint -e661 -e662 possible access/creation of out-of-bounds pointer*/
2509 if (desc_pos + 16 <= desc_end) {
2510 TRACE_EVENT_P16 (" %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x ",
2511 desc->buffer[desc_pos+0], desc->buffer[desc_pos+1], desc->buffer[desc_pos+2],
2512 desc->buffer[desc_pos+3], desc->buffer[desc_pos+4], desc->buffer[desc_pos+5],
2513 desc->buffer[desc_pos+6], desc->buffer[desc_pos+7], desc->buffer[desc_pos+8],
2514 desc->buffer[desc_pos+9], desc->buffer[desc_pos+10], desc->buffer[desc_pos+11],
2515 desc->buffer[desc_pos+12], desc->buffer[desc_pos+13], desc->buffer[desc_pos+14],
2516 desc->buffer[desc_pos+15]);
2517 list_pos+= 16;
2518 desc_pos+= 16;
2519 } else if (desc_pos + 14 <= desc_end) {
2520 TRACE_EVENT_P14 (" %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
2521 desc->buffer[desc_pos+0], desc->buffer[desc_pos+1], desc->buffer[desc_pos+2],
2522 desc->buffer[desc_pos+3], desc->buffer[desc_pos+4], desc->buffer[desc_pos+5],
2523 desc->buffer[desc_pos+6], desc->buffer[desc_pos+7], desc->buffer[desc_pos+8],
2524 desc->buffer[desc_pos+9], desc->buffer[desc_pos+10], desc->buffer[desc_pos+11],
2525 desc->buffer[desc_pos+12], desc->buffer[desc_pos+13]);
2526 list_pos+= 14;
2527 desc_pos+= 14;
2528 } else if (desc_pos + 12 <= desc_end) {
2529 TRACE_EVENT_P12(" %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x ",
2530 desc->buffer[desc_pos+0], desc->buffer[desc_pos+1], desc->buffer[desc_pos+2],
2531 desc->buffer[desc_pos+3], desc->buffer[desc_pos+4], desc->buffer[desc_pos+5],
2532 desc->buffer[desc_pos+6], desc->buffer[desc_pos+7], desc->buffer[desc_pos+8],
2533 desc->buffer[desc_pos+9], desc->buffer[desc_pos+10], desc->buffer[desc_pos+11]);
2534 list_pos+= 12;
2535 desc_pos+= 12;
2536 } else if (desc_pos + 10 <= desc_end) {
2537 TRACE_EVENT_P10(" %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
2538 desc->buffer[desc_pos+0], desc->buffer[desc_pos+1], desc->buffer[desc_pos+2],
2539 desc->buffer[desc_pos+3], desc->buffer[desc_pos+4], desc->buffer[desc_pos+5],
2540 desc->buffer[desc_pos+6], desc->buffer[desc_pos+7], desc->buffer[desc_pos+8],
2541 desc->buffer[desc_pos+9]);
2542 list_pos+= 10;
2543 desc_pos+= 10;
2544 } else if (desc_pos + 8 <= desc_end) {
2545 TRACE_EVENT_P8 (" %02x %02x %02x %02x %02x %02x %02x %02x ",
2546 desc->buffer[desc_pos+0], desc->buffer[desc_pos+1], desc->buffer[desc_pos+2],
2547 desc->buffer[desc_pos+3], desc->buffer[desc_pos+4], desc->buffer[desc_pos+5],
2548 desc->buffer[desc_pos+6], desc->buffer[desc_pos+7]);
2549 list_pos+= 8;
2550 desc_pos+= 8;
2551 } else if (desc_pos + 7 <= desc_end) {
2552 TRACE_EVENT_P7 (" %02x %02x %02x %02x %02x %02x %02x ",
2553 desc->buffer[desc_pos+0], desc->buffer[desc_pos+1], desc->buffer[desc_pos+2],
2554 desc->buffer[desc_pos+3], desc->buffer[desc_pos+4], desc->buffer[desc_pos+5],
2555 desc->buffer[desc_pos+6]);
2556 list_pos+= 7;
2557 desc_pos+= 7;
2558 } else if (desc_pos + 6 <= desc_end) {
2559 TRACE_EVENT_P6 (" %02x %02x %02x %02x %02x %02x ",
2560 desc->buffer[desc_pos+0], desc->buffer[desc_pos+1], desc->buffer[desc_pos+2],
2561 desc->buffer[desc_pos+3], desc->buffer[desc_pos+4], desc->buffer[desc_pos+5]);
2562 list_pos+= 6;
2563 desc_pos+= 6;
2564 } else if (desc_pos + 5 <= desc_end) {
2565 TRACE_EVENT_P5 (" %02x %02x %02x %02x %02x ",
2566 desc->buffer[desc_pos+0], desc->buffer[desc_pos+1], desc->buffer[desc_pos+2],
2567 desc->buffer[desc_pos+3], desc->buffer[desc_pos+4]);
2568 list_pos+= 5;
2569 desc_pos+= 5;
2570 } else if (desc_pos + 4 <= desc_end) {
2571 TRACE_EVENT_P4 (" %02x %02x %02x %02x ",
2572 desc->buffer[desc_pos+0], desc->buffer[desc_pos+1],
2573 desc->buffer[desc_pos+2], desc->buffer[desc_pos+3]);
2574 list_pos+= 4;
2575 desc_pos+= 4;
2576 } else if (desc_pos + 3 <= desc_end) {
2577 TRACE_EVENT_P3 (" %02x %02x %02x ",
2578 desc->buffer[desc_pos+0], desc->buffer[desc_pos+1],
2579 desc->buffer[desc_pos+2]);
2580 list_pos+= 3;
2581 desc_pos+= 3;
2582 } else if (desc_pos + 2 <= desc_end) {
2583 TRACE_EVENT_P2 (" %02x %02x ",
2584 desc->buffer[desc_pos+0], desc->buffer[desc_pos+1]);
2585 list_pos+= 2;
2586 desc_pos+= 2;
2587 } else if (desc_pos + 1 <= desc_end) {
2588 TRACE_EVENT_P1 (" %02x ", desc->buffer[desc_pos+0]);
2589 list_pos++;
2590 desc_pos++;
2591 }
2592 } /* while(list_pos < frame_len) */
2593 /*lint -e661 -e662 possible access/creation of out-of-bounds pointer*/
2594 }
2595 /*
2596 +------------------------------------------------------------------------------
2597 | Function : sndcp_bin_trace_ip
2598 +------------------------------------------------------------------------------
2599 | Description : traces content of one desc_list using TRACE_IP macro
2600 |
2601 | Parameters : pointer to desc_list
2602 | direction: SNDCP_UL_PACKET (0x1)
2603 | SNDCP_DL_PACKET (0x2)
2604 |
2605 +------------------------------------------------------------------------------
2606 */
2607 #ifdef _SNDCP_DTI_2_
2608 GLOBAL void sndcp_bin_trace_ip(T_desc_list2* desc_list, U8 direction)
2609 {
2610 #else /*_SNDCP_DTI_2_*/
2611 GLOBAL void sndcp_bin_trace_ip(T_desc_list* desc_list, U8 direction)
2612 {
2613 #endif /*_SNDCP_DTI_2_*/
2614 USHORT frame_len = desc_list->list_len;
2615 #ifdef _SNDCP_DTI_2_
2616 T_desc2* desc = (T_desc2*)desc_list->first;
2617 #else /*_SNDCP_DTI_2_*/
2618 T_desc* desc = (T_desc*)desc_list->first;
2619 #endif /*_SNDCP_DTI_2_*/
2620
2621 U16 pid = 0;
2622 U16 pos = 0;
2623
2624 TRACE_FUNCTION("sndcp_bin_trace_ip");
2625
2626 if(frame_len > 1500){
2627 TRACE_EVENT("TRACE IP ERROR: IP packet too long.");
2628 return;
2629 }
2630
2631 while(desc != NULL)
2632 {
2633 #ifdef _SNDCP_DTI_2_
2634 memcpy(&bin_trace_ip_buf[pos], (U8*)&desc->buffer[desc->offset], desc->len );
2635 pos += desc->len;
2636 desc = (T_desc2*)desc->next;
2637 #else /*_SNDCP_DTI_2_*/
2638 memcpy(&bin_trace_ip_buf[pos], (U8*)&desc->buffer[0], desc->len );
2639 pos += desc->len;
2640 desc = (T_desc*)desc->next;
2641 #endif /*_SNDCP_DTI_2_*/
2642 }
2643
2644 #ifdef TRACE_IP
2645 if(direction == SNDCP_DL_PACKET){
2646 TRACE_IP(SNDCP_handle, SNDCP_handle, DOWNLINK_OPC, \
2647 (U8*)&bin_trace_ip_buf[0], frame_len);
2648 pid = bin_trace_ip_buf[5] | (bin_trace_ip_buf[4] << 8);
2649 TRACE_EVENT_P1("TRACE IP INFO: Downlink IP Packet, ID: %d", pid);
2650 } else if (direction == SNDCP_UL_PACKET){
2651 TRACE_IP(SNDCP_handle, SNDCP_handle, UPLINK_OPC, \
2652 (U8*)&bin_trace_ip_buf[0], frame_len);
2653 pid = bin_trace_ip_buf[5] | (bin_trace_ip_buf[4] << 8);
2654 TRACE_EVENT_P1("TRACE IP INFO: Uplink IP Packet, ID: %d", pid);
2655 } else {
2656 TRACE_EVENT("TRACE IP ERROR: unknown transfer direction.");
2657 }
2658 #else /*TRACE_IP*/
2659 TRACE_EVENT("SNDCP WARNING: TRACE_IP macro not defined");
2660 #endif /*TRACE_IP*/
2661 }
2662
2663
2664 /*
2665 +------------------------------------------------------------------------------
2666 | Function : sndcp_default_ip_trace
2667 +------------------------------------------------------------------------------
2668 | Description : traces TCP, UDP or ICMP header
2669 |
2670 | Parameters : pointer to desc_list
2671 | direction: SNDCP_UL_PACKET (0x1)
2672 | SNDCP_DL_PACKET (0x2)
2673 |
2674 +------------------------------------------------------------------------------
2675 */
2676 #ifdef _SNDCP_DTI_2_
2677 GLOBAL void sndcp_default_ip_trace(T_desc_list2 *desc_list, U8 direction)
2678 #else
2679 GLOBAL void sndcp_default_ip_trace(T_desc_list *desc_list, U8 direction)
2680 #endif
2681 {
2682 #ifdef _SNDCP_DTI_2_
2683 T_desc2 *desc = (T_desc2 *)desc_list->first;
2684 U8 *ip_hdr = &desc->buffer[desc->offset];
2685 #else
2686 T_desc *desc = (T_desc *)desc_list->first;
2687 U8 *ip_hdr = &desc->buffer[0];
2688 #endif
2689 U8 *pk_hdr = NULL;
2690 U16 ip_len = 0;
2691 U16 icmp_seq = 0;
2692 U32 seq_num = 0,
2693 ack_num = 0;
2694 U16 t_length = 0;
2695 U16 pid = 0;
2696 U8 type, code;
2697 U16 win_size = 0;
2698
2699 TRACE_FUNCTION("sndcp_default_ip_trace");
2700
2701 if(desc_list == NULL || desc_list->first == NULL || desc_list->list_len == 0){
2702 return;
2703 }
2704
2705 ip_len = (ip_hdr[0] & 0x0f) * 4; /* IP header length in bytes*/
2706 if(desc->len < ip_len){
2707 TRACE_EVENT("IP TRACE: can not trace ip header, desc too small");
2708 return;
2709 }
2710
2711 pk_hdr = &ip_hdr[ip_len]; /* Pointer to the header on top of IP hdr */
2712 t_length |= ip_hdr[2] << 8; /* Total packet length */
2713 t_length |= ip_hdr[3];
2714 pid |= ip_hdr[4] << 8; /* Unequal packet ID */
2715 pid |= ip_hdr[5];
2716
2717 switch(ip_hdr[9]){
2718 /* ICMP Protocol */
2719 case 1:
2720 if(desc->len < (ip_len + 8)){
2721 TRACE_EVENT("IP TRACE: can not trace icmp header, desc to small");
2722 return;
2723 }
2724 /* Trace ICMP Header */
2725 type = pk_hdr[0];
2726 if(type == 8 || type == 0){
2727 icmp_seq |= pk_hdr[6];
2728 icmp_seq |= pk_hdr[7] << 8;
2729 TRACE_EVENT_P4("ICMP Echo: type %d, len %d, pid %d, icmp_seq %d",
2730 type, t_length, pid, icmp_seq);
2731 } else {
2732 code = pk_hdr[1];
2733 TRACE_EVENT_P5("ICMP Packet: dir %d, len %d, pid %d, type: %d, code: %d",
2734 direction, t_length, pid, type, code);
2735 }
2736 break;
2737 /* TCP Protocol */
2738 case 6:
2739 if(desc->len < (ip_len + 20)){
2740 TRACE_EVENT("IP TRACE: can not trace tcp header, desc to small");
2741 return;
2742 }
2743 seq_num |= pk_hdr[4] << 24;
2744 seq_num |= pk_hdr[5] << 16;
2745 seq_num |= pk_hdr[6] << 8;
2746 seq_num |= pk_hdr[7];
2747 ack_num |= pk_hdr[8] << 24;
2748 ack_num |= pk_hdr[9] << 16;
2749 ack_num |= pk_hdr[10] << 8;
2750 ack_num |= pk_hdr[11];
2751 win_size |= pk_hdr[14] << 8;
2752 win_size |= pk_hdr[15];
2753
2754 TRACE_EVENT_P14("TCP Packet: dir %d, len %d, pid %d, seq_num %u, ack_num %u, src_ip %d.%d.%d.%d, dst_ip %d.%d.%d.%d, win_size %d",
2755 direction, t_length, pid, seq_num, ack_num,
2756 ip_hdr[12], ip_hdr[13], ip_hdr[14], ip_hdr[15],
2757 ip_hdr[16], ip_hdr[17], ip_hdr[18], ip_hdr[19], win_size);
2758 break;
2759 /* UDP Protocol */
2760 case 17:
2761 if(desc->len < (ip_len + 8)){
2762 TRACE_EVENT("IP TRACE: can not trace udp header, desc to small");
2763 return;
2764 }
2765 TRACE_EVENT_P3("UDP Packet: dir %d, len %d, pid %d",
2766 direction, t_length, pid);
2767 break;
2768 default:
2769 TRACE_EVENT_P1("INFO TRACE: Tracing of protocol type %d not supported",
2770 ip_hdr[9]);
2771 break;
2772 }
2773
2774 return;
2775 }
2776
2777 #endif /* CF_FAST_EXEC */
2778 #endif /* SNDCP_TRACE_IP_DATAGRAM */
2779
2780 /*
2781 +------------------------------------------------------------------------------
2782 | Function : sndcp_swap2
2783 +------------------------------------------------------------------------------
2784 | Description : This routine converts (2 byte) short n from network byte order
2785 | to host byte order.
2786 |
2787 | Parameters : USHORT n
2788 |
2789 +------------------------------------------------------------------------------
2790 */
2791 #ifndef CF_FAST_EXEC
2792
2793 GLOBAL USHORT sndcp_swap2(USHORT n)
2794 {
2795 USHORT tmp = n;
2796 return n = (((tmp & 0xff00) >> 8) | ((tmp & 0x00ff) << 8) );
2797 }
2798
2799 #endif /* CF_FAST_EXEC */
2800
2801 /*
2802 +------------------------------------------------------------------------------
2803 | Function : sndcp_swap4
2804 +------------------------------------------------------------------------------
2805 | Description : This routine converts (4 byte) long n from network byte order
2806 | to host byte order.
2807 |
2808 | Parameters : ULONG n
2809 |
2810 +------------------------------------------------------------------------------
2811 */
2812
2813 #ifndef CF_FAST_EXEC
2814
2815 GLOBAL ULONG sndcp_swap4(ULONG n) {
2816 ULONG tmp = n;
2817 return n = ((tmp & 0xff000000) >> 24) | ((tmp & 0x00ff0000) >> 8 ) |
2818 ((tmp & 0x0000ff00) << 8 ) | ((tmp & 0x000000ff) << 24);
2819 }
2820
2821 #endif /* CF_FAST_EXEC */
2822 /*
2823 +------------------------------------------------------------------------------
2824 | Function : sndcp_get_nsapi_rec_state
2825 +------------------------------------------------------------------------------
2826 | Description : The function returns the receiving state for given NSAPI
2827 |
2828 | Parameters : IN : nsapi
2829 | OUT : state
2830 |
2831 +------------------------------------------------------------------------------
2832 */
2833 #ifndef CF_FAST_EXEC
2834 GLOBAL U8 sndcp_get_nsapi_rec_state (U8 nsapi)
2835 {
2836 TRACE_FUNCTION( "sndcp_get_nsapi_rec_state" );
2837
2838 return sndcp_data->rec_states[nsapi];
2839
2840 } /* sndcp_get_nsapi_rec_state() */
2841 #endif /* CF_FAST_EXEC */
2842
2843 /*
2844 +------------------------------------------------------------------------------
2845 | Function : sndcp_set_nsapi_rec_state
2846 +------------------------------------------------------------------------------
2847 | Description : The function sets the receiving state for given NSAPI
2848 |
2849 | Parameters : IN : nsapi
2850 | IN : state
2851 |
2852 +------------------------------------------------------------------------------
2853 */
2854 #ifndef CF_FAST_EXEC
2855 GLOBAL void sndcp_set_nsapi_rec_state (U8 nsapi, U8 state)
2856 {
2857 TRACE_FUNCTION( "sndcp_set_nsapi_rec_state" );
2858
2859 sndcp_data->rec_states[nsapi] = state;
2860
2861 } /* sndcp_set_nsapi_rec_state() */
2862 #endif /* CF_FAST_EXEC */
2863
2864 /*
2865 +------------------------------------------------------------------------------
2866 | Function : sndcp_get_npdu_num
2867 +------------------------------------------------------------------------------
2868 | Description : E X T R A convenience function, not in SDL.
2869 | Gets the N-PDU number from the segment header.
2870 |
2871 | Parameters : ll_unitdata_ind T_LL_UNITDATA_IND*, npdu_num*
2872 |
2873 +------------------------------------------------------------------------------
2874 */
2875 #ifndef CF_FAST_EXEC
2876 LOCAL void sndcp_get_npdu_num (T_LL_UNITDATA_IND* ll_unitdata_ind, USHORT* npdu_num)
2877 {
2878 USHORT msn_off = 1;
2879 USHORT lsb_off = 2;
2880 UBYTE msn = 0;
2881 UBYTE lsb = 0;
2882
2883 if ((ll_unitdata_ind->sdu.buf[ll_unitdata_ind->sdu.o_buf / 8]) & 0x40) {
2884 msn_off = 2;
2885 lsb_off = 3;
2886 }
2887
2888 msn =
2889 ll_unitdata_ind->sdu.buf[(ll_unitdata_ind->sdu.o_buf / 8) + msn_off];
2890 lsb =
2891 ll_unitdata_ind->sdu.buf[(ll_unitdata_ind->sdu.o_buf / 8) + lsb_off];
2892
2893 *npdu_num = ((msn & 0xf) << 8) + lsb;
2894 } /* sndcp_get_npdu_num() */
2895 #endif /* CF_FAST_EXEC */
2896
2897 /*
2898 +------------------------------------------------------------------------------
2899 | Function : sndcp_get_seg_num
2900 +------------------------------------------------------------------------------
2901 | Description : E X T R A convenience function, not in SDL.
2902 | Gets the NSAPI from the segment header.
2903 |
2904 | Parameters : ll_unitdata_ind T_LL_UNITDATA_IND*, seg_num*
2905 |
2906 +------------------------------------------------------------------------------
2907 */
2908 #ifndef CF_FAST_EXEC
2909 LOCAL void sndcp_get_seg_num (T_LL_UNITDATA_IND* ll_unitdata_ind, UBYTE* seg_num)
2910 {
2911 *seg_num = (ll_unitdata_ind->sdu.buf[(ll_unitdata_ind->sdu.o_buf / 8) + 2] >> 4);
2912 } /* sd_get_seg_num() */
2913 #endif /* CF_FAST_EXEC */
2914
2915 /*
2916 +------------------------------------------------------------------------------
2917 | Function : sndcp_set_unack_transfer_params
2918 +------------------------------------------------------------------------------
2919 | Description : There is one N-PDU, whose segments are sent to CIA one by one,
2920 | and that is expected reassembled and decompressed back from CIA. Some
2921 | informations are only given in the first segment.
2922 | This procedure stores the needed elements in service variables that can
2923 | be read before sending a SIG_SD_CIA_TRANSFER_REQ.
2924 |
2925 | Parameters : ll_unitdata_req*
2926 | Pre : Correct instance of sd service must be activated.
2927 |
2928 +------------------------------------------------------------------------------
2929 */
2930 #ifndef CF_FAST_EXEC
2931 GLOBAL void sndcp_set_unack_transfer_params (T_LL_UNITDATA_IND* ll_unitdata_ind)
2932 {
2933
2934 UBYTE nsapi =
2935 (ll_unitdata_ind->sdu.buf[(ll_unitdata_ind->sdu.o_buf / 8)]) & 0xf;
2936
2937 /*
2938 * The dcomp value in the first segment of the currently reassembled N-PDU.
2939 */
2940 sndcp_data->cur_dcomp[nsapi] =
2941 (ll_unitdata_ind->sdu.buf[ll_unitdata_ind->sdu.o_buf / 8 + 1] & 0xf0) >> 4 ;
2942 /*
2943 * The pcomp value in the first segment of the currently reassembled N-PDU.
2944 */
2945 sndcp_data->cur_pcomp[nsapi] =
2946 (ll_unitdata_ind->sdu.buf[ll_unitdata_ind->sdu.o_buf / 8 + 1]) & 0xf;
2947 /*
2948 * Reference to N-PDU.
2949 */
2950 sndcp_data->cur_pdu_ref[nsapi].ref_nsapi = nsapi;
2951 sndcp_get_npdu_num(ll_unitdata_ind, &sndcp_data->cur_pdu_ref[nsapi].ref_npdu_num);
2952 sndcp_get_seg_num(ll_unitdata_ind, &sndcp_data->cur_pdu_ref[nsapi].ref_seg_num);
2953 /*
2954 * First and/or last segment?
2955 */
2956 sndcp_data->cur_seg_pos[nsapi] = 0;
2957 /*
2958 * if f bit is set
2959 */
2960 if ((ll_unitdata_ind->sdu.buf[ll_unitdata_ind->sdu.o_buf / 8] & 0x40)) {
2961 sndcp_data->cur_seg_pos[nsapi] += SEG_POS_FIRST;
2962 }
2963 /*
2964 * if m bit is not set
2965 */
2966 if (!(ll_unitdata_ind->sdu.buf[ll_unitdata_ind->sdu.o_buf / 8] & 0x10)) {
2967 sndcp_data->cur_seg_pos[nsapi] += SEG_POS_LAST;
2968 }
2969 } /* sndcp_set_unack_transfer_params() */
2970 #endif /* CF_FAST_EXEC */
2971
2972 /*
2973 +------------------------------------------------------------------------------
2974 | Function : sndcp_set_ack_transfer_params
2975 +------------------------------------------------------------------------------
2976 | Description : There is one N-PDU, whose segments are sent to CIA one by one,
2977 | and that is expected reassembled and decompressed back from CIA. Some
2978 | informations are only given in the first segment.
2979 | This procedure stores the needed elements in service variables that can
2980 | be read before sending a SIG_SDA_CIA_TRANSFER_REQ.
2981 |
2982 | Parameters : ll_data_ind*
2983 | Pre : Correct instance of sda service must be activated.
2984 |
2985 +------------------------------------------------------------------------------
2986 */
2987 #ifndef CF_FAST_EXEC
2988 GLOBAL void sndcp_set_ack_transfer_params (T_LL_DATA_IND* ll_data_ind)
2989 {
2990 UBYTE nsapi = (ll_data_ind->sdu.buf[(ll_data_ind->sdu.o_buf / 8)]) & 0xf;
2991
2992 /*
2993 * The dcomp value in the first segment of the currently reassembled N-PDU.
2994 */
2995 sndcp_data->cur_dcomp[nsapi] =
2996 (ll_data_ind->sdu.buf[ll_data_ind->sdu.o_buf / 8 + 1] & 0xf0) >> 4 ;
2997 /*
2998 * The pcomp value in the first segment of the currently reassembled N-PDU.
2999 */
3000 sndcp_data->cur_pcomp[nsapi] =
3001 ll_data_ind->sdu.buf[ll_data_ind->sdu.o_buf / 8 + 1] & 0xf;
3002 /*
3003 * Reference to N-PDU.
3004 */
3005 sndcp_data->cur_pdu_ref[nsapi].ref_nsapi = nsapi;
3006 sndcp_data->cur_pdu_ref[nsapi].ref_npdu_num =
3007 ll_data_ind->sdu.buf[(ll_data_ind->sdu.o_buf >> 3) + 2];
3008
3009
3010 /*
3011 * First and/or last segment?
3012 */
3013 sndcp_data->cur_seg_pos[nsapi] = 0;
3014 /*
3015 * if f bit is set
3016 */
3017 if ((ll_data_ind->sdu.buf[ll_data_ind->sdu.o_buf / 8]) & 0x40) {
3018 sndcp_data->cur_seg_pos[nsapi] += SEG_POS_FIRST;
3019 }
3020 /*
3021 * if m bit is not set
3022 */
3023 if (!((ll_data_ind->sdu.buf[ll_data_ind->sdu.o_buf / 8]) & 0x10)) {
3024 sndcp_data->cur_seg_pos[nsapi] += SEG_POS_LAST;
3025 }
3026 } /* sndcp_set_ack_transfer_params() */
3027 #endif /* CF_FAST_EXEC */