comparison src/g23m-gprs/sndcp/sndcp_cias.c @ 1:d393cd9bb723

src/g23m-*: initial import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jul 2018 04:40:46 +0000
parents
children
comparison
equal deleted inserted replaced
0:b6a5e36de839 1:d393cd9bb723
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GPRS (8441)
4 | Modul : sndcp_cias.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 | These files implement Van Jacobson Compression algorithm which is taken from
18 | University of California Berkley's Implementation.
19 |
20 |
21 | "Copyright (c)1989 Regents of the University of California.
22 | All rights reserved.Redistribution and use in source and binary forms are
23 | permitted, provided that the above copyright notice and this paragraph are
24 | duplicated in all such forms and that any documentation advertising materials,
25 | and other materials related to such distributionand use acknowledge that the
26 | software was developed by the University of California, Berkeley.
27 | The name of the University may not be used to endorse or promote products
28 | derived from this software without specific prior written permission.
29 | THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
30 | INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND
31 | FITNESS FOR A PARTICULAR PURPOSE"
32 +-----------------------------------------------------------------------------
33 | Purpose : This modul is part of the entity SNDCP and implements all
34 | functions to handles the incoming process internal signals as
35 | described in the SDL-documentation (CIA-statemachine)
36 +-----------------------------------------------------------------------------
37 */
38
39
40 #define ENTITY_SNDCP
41
42 /*==== INCLUDES =============================================================*/
43
44 #include "typedefs.h" /* to get Condat data types */
45 #include "vsi.h" /* to get a lot of macros */
46 #include "macdef.h"
47 #include "gsm.h" /* to get a lot of macros */
48 #include "prim.h" /* to get the definitions of used SAP and directions */
49
50 #include "dti.h"
51
52 #include "sndcp.h" /* to get the global entity definitions */
53 #include "sndcp_f.h" /* to get the functions to access the global arrays*/
54
55 #include <string.h> /* to get memcpy() */
56 #include "sndcp_cias.h" /* to get the signals to service cia */
57 #include "sndcp_ciap.h" /* to get primitives to service cia */
58 #include "sndcp_ciaf.h" /* to get primitives to service cia */
59 #include "sndcp_sdf.h" /* to get sd functions */
60 #include "sndcp_sdaf.h" /* to get sda functions */
61 #include "sndcp_sds.h" /* to get sd signals */
62
63 #ifdef TI_PS_FF_V42BIS
64 #include "v42b_type.h"
65 #include "v42b_dico.h"
66 #include "v42b_enc.h"
67 #include "v42b_dec.h"
68 #include "v42b_debug.h"
69 #endif /* TI_PS_FF_V42BIS */
70
71 /*==== CONST ================================================================*/
72
73 /*==== LOCAL VARS ===========================================================*/
74
75 /*==== PRIVATE FUNCTIONS ====================================================*/
76
77 /*
78 * Update connection state cs & send uncompressed packet ('uncompressed'
79 * means a regular ip/tcp packet but with the 'conversation id' we hope
80 * to use on future compressed packets in the protocol field).
81 */
82 #define UNCOMPRESSED {\
83 memcpy(cs->cs_hdr, (UBYTE*)cbuf->c_hdr, tip_hlen);\
84 ip->ip_p = cs->cs_id;\
85 sndcp_data->cia.comp.last_xmit = cs->cs_id;\
86 }
87
88
89 /*
90 +------------------------------------------------------------------------------
91 | Function : cia_vj_comp
92 +------------------------------------------------------------------------------
93 | Description : compresses the TCP/IP header of the given packet
94 | (Van Jacobson algorithm). A part of this routine has been taken
95 | from implementation of University of California, Berkeley.
96 |
97 | Parameters : com_buf - received packet, packet length, packet type
98 |
99 +------------------------------------------------------------------------------
100 */
101 #ifndef CF_FAST_EXEC
102
103 LOCAL UBYTE cia_vj_comp(struct comp_buf *cbuf)
104 {
105 struct cstate *cs = sndcp_data->cia.comp.last_cs->cs_next;
106 T_SNDCP_TCP_HEADER *oth, *oth_tmp; /* last TCP header */
107 T_SNDCP_TCP_HEADER *th; /* current TCP header */
108 T_SNDCP_IP_HEADER *ip; /* current IP header */
109 USHORT ip_hlen, tip_hlen; /* IP hdr len., TCP/IP hdr len*/
110 USHORT tmp1, tmp2; /* general purpose tempories */
111 ULONG changes = 0; /* change mask */
112 UBYTE new_seq[16]; /* changes from last to current*/
113 UBYTE *cp = new_seq;
114 UBYTE th_off, oth_off;
115 BOOL found = FALSE;
116 USHORT th_sum;
117 ULONG seq, o_seq;
118
119 ip = (T_SNDCP_IP_HEADER *)cbuf->c_hdr;
120 ip_hlen = ip->ip_vhl & HL_MASK; /* IP header length in integers */
121 th = (T_SNDCP_TCP_HEADER *)&((ULONG *)cbuf->c_hdr)[ip_hlen];
122 th_off = th->th_off >> 4;
123
124 TRACE_FUNCTION( "cia_vj_comp" );
125
126 /*
127 * Bail if this is an IP fragment or if the TCP packet isn't
128 * `compressible' (i.e., ACK isn't set or some other control bit is
129 * set). (We assume that the caller has already made sure the
130 * packet is IP proto TCP).
131 */
132 if (ip->ip_off & 0xff3f)
133 {
134 TRACE_EVENT("INFO COMP: return TYPE_IP, packet is an IP fragment");
135 return (TYPE_IP);
136 }
137
138 if ((th->th_flags & (TH_SYN|TH_FIN|TH_RST|TH_ACK)) != TH_ACK)
139 {
140 TRACE_EVENT("INFO COMP: return TYPE_IP, TH_ACK is not set");
141 return (TYPE_IP);
142 }
143 /*
144 * Packet is compressible -- we're going to send either a
145 * COMPRESSED_TCP or UNCOMPRESSED_TCP packet. Either way we need
146 * to locate (or create) the connection state. Special case the
147 * most recently used connection since it's most likely to be used
148 * again & we don't have to do any reordering if it's used.
149 */
150 oth_tmp = (T_SNDCP_TCP_HEADER *)
151 &((ULONG *)cs->cs_hdr)[cs->cs_ip->ip_vhl & HL_MASK];
152 if ((ip->ip_src != cs->cs_ip->ip_src) ||
153 (ip->ip_dst != cs->cs_ip->ip_dst) ||
154 (*(ULONG *)th != *(ULONG *)oth_tmp)){
155 /*
156 * Wasn't the first -- search for it.
157 *
158 * States are kept in a circularly linked list with
159 * last_cs pointing to the end of the list. The
160 * list is kept in lru order by moving a state to the
161 * head of the list whenever it is referenced. Since
162 * the list is short and, empirically, the connection
163 * we want is almost always near the front, we locate
164 * states via linear search. If we don't find a state
165 * for the datagram, the oldest state is (re-)used.
166 */
167 struct cstate *lcs;
168 struct cstate *lastcs = sndcp_data->cia.comp.last_cs;
169
170 do {
171 lcs = cs;
172 cs = cs->cs_next;
173 oth_tmp = (T_SNDCP_TCP_HEADER *)
174 &((ULONG *)cs->cs_hdr)[cs->cs_ip->ip_vhl & HL_MASK];
175 if ((ip->ip_src == cs->cs_ip->ip_src) &&
176 (ip->ip_dst == cs->cs_ip->ip_dst) &&
177 (*(ULONG *)th == *(ULONG *)oth_tmp)){
178 found = TRUE;
179 break;
180 }
181
182 } while (cs != lastcs);
183
184 if(found)
185 {
186 /*
187 * Found it -- move to the front on the connection list.
188 */
189 if (cs == lastcs)
190 sndcp_data->cia.comp.last_cs = lcs;
191 else {
192 lcs->cs_next = cs->cs_next;
193 cs->cs_next = lastcs->cs_next;
194 lastcs->cs_next = cs;
195 }
196 } else {
197 /*
198 * Didn't find it -- re-use oldest cstate. Send an
199 * uncompressed packet that tells the other side what
200 * connection number we're using for this conversation.
201 * Note that since the state list is circular, the oldest
202 * state points to the newest and we only need to set
203 * last_cs to update the lru linkage.
204 */
205 sndcp_data->cia.comp.last_cs = lcs;
206 tip_hlen = (ip_hlen+th_off)<<2;
207 UNCOMPRESSED;
208 return (TYPE_UNCOMPRESSED_TCP);
209 }/*if din't find*/
210 }
211
212 /*
213 * Make sure that only what we expect to change changed. The first
214 * line of the `if' checks the IP protocol version, header length &
215 * type of service. The 2nd line checks the "Don't fragment" bit.
216 * The 3rd line checks the time-to-live and protocol (the protocol
217 * check is unnecessary but costless). The 4th line checks the TCP
218 * header length. The 5th line checks IP options, if any. The 6th
219 * line checks TCP options, if any. If any of these things are
220 * different between the previous & current datagram, we send the
221 * current datagram `uncompressed'.
222 */
223 oth = (T_SNDCP_TCP_HEADER *)&((ULONG *)cs->cs_ip)[ip_hlen];
224 oth_off = oth->th_off >> 4;
225 tip_hlen = (ip_hlen+th_off)<<2;
226
227 if (((USHORT *)ip)[0] != ((USHORT *)cs->cs_ip)[0] ||
228 ((USHORT *)ip)[3] != ((USHORT *)cs->cs_ip)[3] ||
229 ((USHORT *)ip)[4] != ((USHORT *)cs->cs_ip)[4] ||
230 (th_off != oth_off) ||
231 ((ip_hlen > 5) && (memcmp(ip + 1, cs->cs_ip + 1, (ip_hlen - 5) << 2))) ||
232 ((th_off > 5) && (memcmp(th + 1, oth + 1, (th_off - 5) << 2)))) {
233
234 UNCOMPRESSED;
235 return (TYPE_UNCOMPRESSED_TCP);
236 }
237
238 /*
239 * Figure out which of the changing fields changed. The
240 * receiver expects changes in the order: urgent, window,
241 * ack, seq (the order minimizes the number of temporaries
242 * needed in this section of code).
243 */
244 if (th->th_flags & TH_URG) {
245 tmp1 = sndcp_swap2(th->th_urp);
246 if (tmp1 >= 256 || tmp1 == 0) {
247 *cp++ = 0;
248 cp[1] = (UBYTE)tmp1;
249 cp[0] = (tmp1 & 0xff00) >> 8;
250 cp += 2;
251 } else {
252 *cp++ = (UBYTE)tmp1;
253 }
254 changes |= NEW_U;
255 } else if (th->th_urp != oth->th_urp){
256 /* argh! URG not set but urp changed -- a sensible
257 * implementation should never do this but RFC793
258 * doesn't prohibit the change so we have to deal
259 * with it. */
260 UNCOMPRESSED;
261 return (TYPE_UNCOMPRESSED_TCP);
262 }
263 if ((tmp1 = sndcp_swap2(th->th_win) - sndcp_swap2(oth->th_win)) != 0) {
264 if (tmp1 >= 256) {
265 *cp++ = 0;
266 cp[1] = (UBYTE)tmp1;
267 cp[0] = (tmp1 & 0xff00) >> 8;
268 cp += 2;
269 } else {
270 *cp++ = (UBYTE)tmp1;
271 }
272 changes |= NEW_W;
273 }
274
275 if ((tmp2 = (USHORT)(sndcp_swap4(th->th_ack)-sndcp_swap4(oth->th_ack)))!=0){
276 if (tmp2 > MAX_CHANGE){
277 UNCOMPRESSED;
278 return (TYPE_UNCOMPRESSED_TCP);
279 }
280 if (tmp2 >= 256) {
281 *cp++ = 0;
282 cp[1] = (UBYTE)tmp2;
283 cp[0] = (tmp2 & 0xff00) >> 8;
284 cp += 2;
285 } else {
286 *cp++ = (UBYTE)tmp2;
287 }
288 changes |= NEW_A;
289 }
290
291 seq = sndcp_swap4(th->th_seq);
292 o_seq = sndcp_swap4(oth->th_seq);
293 if(seq < o_seq) {
294 TRACE_EVENT("WARNING COMP: seq < o_seq, return UNCOMPRESSED_TCP ");
295 UNCOMPRESSED;
296 return (TYPE_UNCOMPRESSED_TCP);
297 } else if((tmp1 = (USHORT)(seq - o_seq)) != 0) {
298 if (tmp1 > MAX_CHANGE){
299 UNCOMPRESSED;
300 return (TYPE_UNCOMPRESSED_TCP);
301 }
302 if (tmp1 >= 256) {
303 *cp++ = 0;
304 cp[1] = (UBYTE)tmp1;
305 cp[0] = (tmp1 & 0xff00) >> 8;
306 cp += 2;
307 } else {
308 *cp++ = (UBYTE)tmp1;
309 }
310 changes |= NEW_S;
311 }
312
313 /* look for special case encodings. */
314 switch (changes) {
315
316 case 0:
317 /*
318 * Nothing changed. If this packet contains data and the
319 * last one didn't, this is probably a data packet following
320 * an ack (normal on an interactive connection) and we send
321 * it compressed. Otherwise it's probably a retransmit,
322 * retransmitted ack or window probe. Send it uncompressed
323 * in case the other side missed the compressed version.
324 */
325 if ((ip->ip_len != cs->cs_ip->ip_len) &&
326 (sndcp_swap2(cs->cs_ip->ip_len) == tip_hlen))
327 break;
328
329 /* (fall through) */
330
331 case SPECIAL_I:
332 case SPECIAL_D:
333 /*
334 * actual changes match one of our special case encodings --
335 * send packet uncompressed.
336 */
337 UNCOMPRESSED;
338 return (TYPE_UNCOMPRESSED_TCP);
339
340 case NEW_S|NEW_A:
341 if ((tmp1 == tmp2) &&
342 (tmp1 == sndcp_swap2(cs->cs_ip->ip_len) - tip_hlen)) {
343 /* special case for echoed terminal traffic */
344 changes = SPECIAL_I;
345 cp = new_seq;
346 }
347 break;
348
349 case NEW_S:
350 if (tmp1 == sndcp_swap2(cs->cs_ip->ip_len) - tip_hlen) {
351 /* special case for data xfer */
352 changes = SPECIAL_D;
353 cp = new_seq;
354 }
355 break;
356 }
357
358 tmp1 = sndcp_swap2(ip->ip_id) - sndcp_swap2(cs->cs_ip->ip_id);
359 if (tmp1 != 1) {
360 if ((tmp1 >= 256) || (tmp1 == 0)) {
361 *cp++ = 0;
362 cp[1] = (UBYTE)tmp1;
363 cp[0] = (tmp1 & 0xff00) >> 8;
364 cp += 2;
365 } else {
366 *cp++ = (UBYTE)tmp1;
367 }
368 changes |= NEW_I;
369 }
370
371 if (th->th_flags & TH_PUSH)
372 changes |= TCP_PUSH_BIT;
373 /*
374 * Grab the cksum before we overwrite it below. Then update our
375 * state with this packet's header.
376 */
377 th_sum = sndcp_swap2(th->th_sum);
378 memcpy(cs->cs_ip, ip, tip_hlen);
379
380 /*
381 * We want to use the original packet as our compressed packet.
382 * (cp - new_seq) is the number of bytes we need for compressed
383 * sequence numbers. In addition we need one byte for the change
384 * mask, one for the connection id and two for the tcp checksum.
385 * So, (cp - new_seq) + 4 bytes of header are needed. hlen is how
386 * many bytes of the original packet to toss so subtract the two to
387 * get the new packet size.
388 */
389 tmp1 = cp - new_seq;
390 cp = (UBYTE *)ip;
391
392 /*
393 * we always send a "new" connection id so the receiver state
394 * stays synchronized.
395 */
396 sndcp_data->cia.comp.last_xmit = cs->cs_id;
397 tip_hlen -= tmp1 + 4;
398 cp += tip_hlen;
399 *cp++ = (UBYTE)(changes | NEW_C);
400 *cp++ = cs->cs_id;
401
402 cbuf->pack_len -= tip_hlen;
403 cbuf->hdr_len -= tip_hlen;
404 cbuf->c_hdr += tip_hlen;
405 *cp++ = th_sum >> 8;
406 *cp++ = (UBYTE)(th_sum & 0x00ff);
407 memcpy(cp, new_seq, tmp1);
408 return (TYPE_COMPRESSED_TCP);
409 }
410
411 #endif /* CF_FAST_EXEC */
412
413
414 /*
415 +------------------------------------------------------------------------------
416 | Function : cia_header_comp
417 +------------------------------------------------------------------------------
418 | Description : compresses the TCP/IP header of the given packet
419 | (Van Jacobson algorithm)
420 |
421 | Parameters : packet as desc_list, packet_type.
422 |
423 +------------------------------------------------------------------------------
424 */
425 #ifndef CF_FAST_EXEC
426
427 #ifdef _SNDCP_DTI_2_
428 GLOBAL void cia_header_comp (T_desc_list2* dest_desc_list,
429 T_desc_list2* src_desc_list,
430 UBYTE* packet_type)
431 #else /*_SNDCP_DTI_2_*/
432 GLOBAL void cia_header_comp (T_desc_list* dest_desc_list,
433 T_desc_list* src_desc_list,
434 UBYTE* packet_type)
435 #endif /*_SNDCP_DTI_2_*/
436 {
437
438 #ifdef _SNDCP_DTI_2_
439 T_desc2* src_desc = (T_desc2*)src_desc_list->first;
440 T_desc2* new_desc;
441 U8 *src_desc_buff = &src_desc->buffer[src_desc->offset];
442 #else /*_SNDCP_DTI_2_*/
443 T_desc* src_desc = (T_desc*)src_desc_list->first;
444 T_desc* new_desc;
445 U8 *src_desc_buff = &src_desc->buffer[0];
446 #endif /*_SNDCP_DTI_2_*/
447
448
449 /*
450 * A struct mbuf is used in the call cia_vj_comp because that routine
451 * needs to modify both the start address and length if the incoming
452 * packet is compressed
453 */
454
455 struct comp_buf cbuf;
456 T_SNDCP_IP_HEADER *ip;
457 T_SNDCP_TCP_HEADER *tcp;
458 USHORT hdr_len;
459 USHORT offset;
460
461 TRACE_FUNCTION( "cia_header_comp" );
462
463 if ((src_desc == NULL))
464 {
465 TRACE_EVENT("ERROR: Descriptor Pointer is a NULLPTR");
466 *packet_type = TYPE_ERROR;
467 return;
468 }
469
470 /*
471 * Verify protocol type and header length
472 */
473 ip = (T_SNDCP_IP_HEADER *)&src_desc_buff[0];
474 if((ip->ip_p == PROT_TCPIP))
475 {
476 hdr_len = (ip->ip_vhl & HL_MASK) << 2;
477 tcp = (T_SNDCP_TCP_HEADER *)&src_desc_buff[hdr_len];
478 hdr_len += (tcp->th_off >> 4) << 2;
479 if( (src_desc->len >= hdr_len) && (hdr_len >=40) ){
480 /*
481 * initialize comp_buf
482 */
483 cbuf.hdr_len = hdr_len; /* header len. passed to compr. routine*/
484 cbuf.pack_len = src_desc->len; /* descriptor length */
485 cbuf.p_type = TYPE_IP; /* set default packet type */
486 /* use temporary buffer to store TCP/IP header */
487 cbuf.c_hdr = (ULONG)&sndcp_data->cia.comp.tcpip_hdr[0];
488 memcpy((UBYTE*)cbuf.c_hdr, &src_desc_buff[0], cbuf.hdr_len);
489 /*
490 * Call VJ header compression routine
491 */
492 *packet_type = cia_vj_comp(&cbuf);
493 }
494 else
495 *packet_type = TYPE_IP;
496
497 }/* if TCP_IP_PROTOKOL */
498 else{
499 *packet_type = TYPE_IP;
500 if(src_desc->len <40)
501 TRACE_EVENT("INFO COMP: Descriptor length < 40");
502 }
503
504 switch(*packet_type)
505 {
506 /*
507 * IP packet
508 */
509 case TYPE_IP:
510 /*
511 * if acknowledged mode
512 */
513 if(src_desc_list != dest_desc_list)
514 {
515 dest_desc_list->first = src_desc_list->first;
516 dest_desc_list->list_len = src_desc_list->list_len;
517 }
518 TRACE_EVENT("INFO COMP: Header Type TYPE_IP");
519 break;
520
521 /*
522 * Uncompressed TCP/IP packet
523 */
524 case TYPE_UNCOMPRESSED_TCP:
525 /*
526 * if acknowledged mode
527 */
528 if(src_desc_list != dest_desc_list)
529 {
530 #ifdef _SNDCP_DTI_2_
531 MALLOC(new_desc, (USHORT)(sizeof(T_desc2)-1+src_desc->len));
532 #else
533 MALLOC(new_desc, (USHORT)(sizeof(T_desc)-1+src_desc->len));
534 #endif
535 /*
536 * Copy data packet to destination descriptor
537 */
538 memcpy(new_desc->buffer, src_desc_buff, src_desc->len);
539 /*
540 * store connection id
541 */
542 new_desc->buffer[PR_TYPE_POS] = ((UBYTE*)cbuf.c_hdr)[PR_TYPE_POS]
543 ;/*lint !e644 !e415 !e416 creation and access of out-of-bounds pointer*/
544 /*
545 * Build destination descriptor list
546 */
547 new_desc->next = src_desc->next;
548 new_desc->len = src_desc->len;
549 #ifdef _SNDCP_DTI_2_
550 new_desc->offset = src_desc->offset;
551 new_desc->size = src_desc->size;
552 #endif
553 dest_desc_list->first = (ULONG)new_desc;
554 dest_desc_list->list_len = src_desc_list->list_len;
555 }
556 else{
557 /*
558 * store connection id
559 */
560 src_desc_buff[PR_TYPE_POS] = ((UBYTE*)cbuf.c_hdr)[PR_TYPE_POS]
561 ;/*lint !e415 !e416 creation and access of out-of-bounds pointer */
562 }
563 TRACE_EVENT("INFO COMP: Header Type TYPE_UNCOMPRESSED_TCP");
564 break;
565
566
567 /*
568 * Compressed TCP/IP packet
569 */
570 case TYPE_COMPRESSED_TCP:
571 /* compute compressed header length */
572 offset = (USHORT)(src_desc->len - cbuf.pack_len);
573 #ifdef _SNDCP_DTI_2_
574 MALLOC(new_desc, (USHORT)(sizeof(T_desc2) - 1 + cbuf.pack_len));
575 #else
576 MALLOC(new_desc, (USHORT)(sizeof(T_desc) - 1 + cbuf.pack_len));
577 #endif
578 /*
579 * Copy compressed header to new descriptor
580 */
581 memcpy(&new_desc->buffer[0], (UBYTE*)cbuf.c_hdr, cbuf.hdr_len);
582 /*
583 * Copy payload to new descriptor
584 */
585 memcpy(&new_desc->buffer[cbuf.hdr_len],
586 &src_desc_buff[hdr_len], cbuf.pack_len-cbuf.hdr_len)
587 ;/*lint !e644 !e662 Possible creation of out-of-bounds pointer */
588 /*
589 * Build destination descriptor list
590 */
591 new_desc->next = src_desc->next;
592 new_desc->len = (USHORT)cbuf.pack_len;
593 #ifdef _SNDCP_DTI_2_
594 new_desc->offset = 0;
595 new_desc->size = (USHORT)cbuf.pack_len;
596 #endif
597 dest_desc_list->first = (ULONG)new_desc;
598 dest_desc_list->list_len = src_desc_list->list_len - offset;
599 /*
600 * if unacknowledgement mode
601 */
602 if(src_desc_list == dest_desc_list)
603 {
604 /*
605 * Free source decsriptor
606 */
607 MFREE(src_desc);
608 }
609 TRACE_EVENT("INFO COMP: Header TYPE_COMPRESSED_TCP");
610 break;
611
612 default:
613 TRACE_EVENT("Header Type: TYPE_ERROR");
614 break;
615 }
616
617 #ifdef SNDCP_TRACE_BUFFER
618 sndcp_trace_desc_list(dest_desc_list);
619 #endif /* SNDCP_TRACE_BUFFER */
620
621 } /* cia_header_comp*/
622
623 #endif /* CF_FAST_EXEC */
624
625
626 #ifndef _SNDCP_DTI_2_
627 /*
628 +------------------------------------------------------------------------------
629 | Function : cia_su_cia_comp_req
630 +------------------------------------------------------------------------------
631 | Description : Simulation for cia reaction to SIG_SU_CIA_DATA_REQ.
632 | Instead of sending the pdu to cia and then receiving
633 | 1 or more CIA_COMP_IND.
634 |
635 | Parameters :
636 |
637 +------------------------------------------------------------------------------
638 */
639 /*#if defined(CF_FAST_EXEC) || defined(_SIMULATION_) || \
640 !defined(REL99) || defined(SNDCP_2to1) */
641
642 LOCAL void cia_su_cia_comp_req (T_SN_UNITDATA_REQ* sn_unitdata_req,
643 USHORT npdu_number,
644 UBYTE nsapi,
645 UBYTE sapi,
646 UBYTE packet_type
647 )
648 {
649 BOOL ready = FALSE;
650 USHORT header_size = SN_UNITDATA_PDP_HDR_LEN_BIG;
651 /*
652 * Bit offset in destination sdu.
653 */
654 USHORT bit_offset = ENCODE_OFFSET + (USHORT)(header_size << 3);
655 /*
656 * Offset in current desc.
657 */
658 USHORT desc_offset = 0;
659 USHORT sdu_len = 0;
660 UBYTE first = SEG_POS_FIRST;
661 UBYTE segment_number = 0;
662 T_desc_list* desc_list = &sn_unitdata_req->desc_list;
663
664 TRACE_FUNCTION( "cia_su_cia_comp_req" );
665
666 while (!ready && desc_list->first != NULL) {
667 /*
668 * How long will sdu be?
669 */
670 if (desc_list->list_len + header_size >= sndcp_data->su->n201_u) {
671 sdu_len = (USHORT)(sndcp_data->su->n201_u << 3);
672 } else {
673 sdu_len = (USHORT)((desc_list->list_len + header_size) << 3);
674 }
675 {
676 PALLOC_SDU(cia_comp_ind, CCI_COMP_IND, sdu_len);
677 /*
678 * Set parameters.
679 */
680
681 cia_comp_ind->sapi = sapi;
682 /*
683 * cia_qos is not yet used, set to 0.
684 */
685 cia_comp_ind->cia_qos.delay = 0;
686 cia_comp_ind->cia_qos.relclass = 0;
687 cia_comp_ind->cia_qos.peak = 0;
688 cia_comp_ind->cia_qos.preced = 0;
689 cia_comp_ind->cia_qos.mean = 0;
690 /*
691 * Will be changed as soon as more that 1 instance of V42.bis is used.
692 */
693 cia_comp_ind->algo_type = CIA_ALGO_V42;
694 cia_comp_ind->comp_inst = CIA_COMP_INST_V42_0;
695
696 cia_comp_ind->pdu_ref.ref_nsapi = nsapi;
697 cia_comp_ind->pdu_ref.ref_npdu_num = npdu_number;
698 cia_comp_ind->pdu_ref.ref_seg_num = segment_number;
699 segment_number ++;
700 if (desc_list->list_len + header_size <= sndcp_data->su->n201_u) {
701 cia_comp_ind->seg_pos = first + SEG_POS_LAST;
702 } else {
703 cia_comp_ind->seg_pos = first;
704 }
705 cia_comp_ind->packet_type = packet_type;
706 /*
707 * Copy descriptors to cia_comp_ind->sdu.
708 */
709 while (desc_list->first != NULL) {
710 T_desc* help = (T_desc*)desc_list->first;
711 USHORT cur_len = (((T_desc*)desc_list->first)->len - desc_offset);
712 if ((cur_len << 3) <=
713 cia_comp_ind->sdu.l_buf +
714 cia_comp_ind->sdu.o_buf -
715 bit_offset) {
716
717 /*
718 * Copy current desc to sdu.
719 */
720 if (cur_len>0)
721 {
722 memcpy(&cia_comp_ind->sdu.buf[bit_offset >> 3],
723 &((T_desc*)desc_list->first)->buffer[desc_offset],
724 cur_len);
725 }
726 bit_offset += (USHORT)(cur_len << 3);
727 desc_list->list_len -= cur_len;
728
729 /*
730 * Free read desc and go to next in list.
731 */
732 desc_list->first = help->next;
733 desc_offset = 0;
734 MFREE(help);
735 help = NULL;
736 } else {
737 /*
738 * Current desc does not fit completely in sdu.
739 */
740 USHORT part_len = (USHORT)(cia_comp_ind->sdu.l_buf +
741 cia_comp_ind->sdu.o_buf -
742 bit_offset)
743 >> 3;
744 if (part_len > 0)
745 {
746 memcpy(&cia_comp_ind->sdu.buf[bit_offset >> 3],
747 &((T_desc*)desc_list->first)->buffer[desc_offset],
748 part_len);
749 desc_offset += part_len;
750 }
751 desc_list->list_len -= part_len;
752
753 header_size = SN_UNITDATA_PDP_HDR_LEN_SMALL;
754 bit_offset = ENCODE_OFFSET + (USHORT)(header_size << 3);
755
756 break;
757 }
758 } /* while (desc_list->first != NULL) { */
759 /*
760 * Instead of PSEND(SNDCP_handle, cia_comp_ind);
761 */
762 cia_cia_comp_ind(cia_comp_ind);
763 /*
764 * One segment sent, set 'first' to 'none'.
765 */
766 first = SEG_POS_NONE;
767 }
768 /*
769 * If the desc_list is empty now, leave.
770 */
771
772 if (sn_unitdata_req->desc_list.list_len == 0) {
773 PFREE(sn_unitdata_req);
774 sn_unitdata_req = NULL;
775 ready = TRUE;
776 }
777 }
778
779 } /* cia_su_cia_comp_req() */
780 /*#endif */ /* CF_FAST_EXEC || _SIMULATION_ || !REL99 || SNDCP_2to1 */
781
782 #else /* _SNDCP_DTI_2_ */
783 /*
784 +------------------------------------------------------------------------------
785 | Function : cia_su_cia_comp_req
786 +------------------------------------------------------------------------------
787 | Description : This function is used, if no data compression is used in
788 | uplink. It does only the segmentation of the incoming data.
789 |
790 | Simulation for cia reaction to SIG_SU_CIA_DATA_REQ.
791 | Instead of sending the pdu to cia and then receiving
792 | 1 or more CIA_COMP_IND.
793 |
794 | Parameters :
795 |
796 +------------------------------------------------------------------------------
797 */
798 /*#if defined(CF_FAST_EXEC) || defined(_SIMULATION_) || \
799 !defined(REL99) || defined(SNDCP_2to1) */
800
801 LOCAL void cia_su_cia_comp_req (T_SN_UNITDATA_REQ* sn_unitdata_req,
802 USHORT npdu_number,
803 UBYTE nsapi,
804 UBYTE sapi,
805 UBYTE packet_type
806 )
807 {
808 BOOL ready = FALSE;
809 U16 header_size = SN_UNITDATA_PDP_HDR_LEN_BIG;
810 U16 desc2_data_struct_offset = 0;
811 U8 first = SEG_POS_FIRST;
812 U8 segment_number = 0;
813 U32* segment_header;
814 T_desc_list2* desc_list2 = &sn_unitdata_req->desc_list2;
815 T_desc_list3 desc_list3;
816 T_desc3* desc3;
817 T_desc3* current_desc3;
818 /*
819 * Offset in current desc. Set the desc_offset to the offset of
820 * the first desc in the list that is to be read.
821 */
822 U16 desc_offset = ((T_desc2*)desc_list2->first)->offset;
823
824 TRACE_FUNCTION( "cia_su_cia_comp_req" );
825
826 while (!ready && desc_list2->first != NULL)
827 {
828 /*
829 * How long will the segment be?
830 */
831 desc_list3.first = NULL;
832 desc_list3.list_len = 0;
833 if ((desc_list2->list_len + header_size) >= sndcp_data->su->n201_u)
834 {
835 desc_list3.list_len = (USHORT)sndcp_data->su->n201_u;
836 }
837 else
838 {
839 desc_list3.list_len = (USHORT)(desc_list2->list_len + header_size);
840 }
841
842 {
843 T_CIA_COMP_IND *cia_comp_ind;
844 MALLOC(cia_comp_ind, sizeof(T_CIA_COMP_IND));
845 /*
846 * Set parameters.
847 */
848
849 cia_comp_ind->sapi = sapi;
850 /*
851 * cia_qos is not yet used, set to 0.
852 */
853 cia_comp_ind->cia_qos.delay = 0;
854 cia_comp_ind->cia_qos.relclass = 0;
855 cia_comp_ind->cia_qos.peak = 0;
856 cia_comp_ind->cia_qos.preced = 0;
857 cia_comp_ind->cia_qos.mean = 0;
858 /*
859 * Will be changed as soon as more that 1 instance of V42.bis is used.
860 */
861 cia_comp_ind->algo_type = CIA_ALGO_V42;
862 cia_comp_ind->comp_inst = CIA_COMP_INST_V42_0;
863
864 cia_comp_ind->pdu_ref.ref_nsapi = nsapi;
865 cia_comp_ind->pdu_ref.ref_npdu_num = npdu_number;
866 cia_comp_ind->pdu_ref.ref_seg_num = segment_number;
867 segment_number ++;
868
869 /* Allocate memory for SNDCP header and LLC encode offset */
870 MALLOC (segment_header, (USHORT)(ENCODE_OFFSET_BYTE + header_size));
871
872 MALLOC (desc3, (U16)(sizeof(T_desc3)));
873 /*
874 * Fill desc3 descriptor control information.
875 */
876 desc3->next = (U32)NULL;
877 desc3->len = header_size;
878 desc3->offset = ENCODE_OFFSET_BYTE;
879 desc3->buffer = (U32)segment_header;
880 desc_list3.first = (U32)desc3;
881 current_desc3 = desc3;
882
883 if (desc_list2->list_len + header_size <= sndcp_data->su->n201_u)
884 {
885 cia_comp_ind->seg_pos = first + SEG_POS_LAST;
886 } else {
887 cia_comp_ind->seg_pos = first;
888 }
889 cia_comp_ind->packet_type = packet_type;
890 cia_comp_ind->desc_list3.first = desc_list3.first;
891 cia_comp_ind->desc_list3.list_len = desc_list3.list_len;
892
893 desc_list3.list_len = 0;
894 desc_list3.list_len += desc3->len;
895 /*
896 * Copy descriptors to cia_comp_ind->desc_list3, list may have to be built.
897 */
898 while (desc_list2->first != NULL)
899 {/* This while moves data from desc2 to segment defined by desc3 descriptors*/
900 T_desc2* help = (T_desc2*)desc_list2->first;
901 U16 cur_len = (((T_desc2*)desc_list2->first)->len - desc_offset);
902 desc2_data_struct_offset = offsetof(T_desc2, buffer);
903 if (cur_len <= (sndcp_data->su->n201_u - desc_list3.list_len))
904 {/* Is there room for all the desc2 data in the current segment */
905
906 /*
907 * describe current desc2 by desc3 descriptors.
908 */
909
910 MALLOC (desc3, (USHORT)(sizeof(T_desc3)));
911 /*
912 * Fill desc3 descriptor control information.
913 */
914 desc3->next = (U32)NULL;
915 desc3->len = cur_len;
916 desc3->offset = desc_offset + desc2_data_struct_offset;
917 desc3->buffer = (U32)desc_list2->first;
918 current_desc3->next = (U32)desc3;
919 current_desc3 = desc3;
920 desc_list3.list_len += desc3->len;
921
922 /* Attach desc3 to desc2 allocation, this is always the last
923 attach on a desc2 descriptor */
924 sndcp_cl_desc2_attach(help);
925
926 desc_list2->list_len -= cur_len;
927
928 /*
929 * Free read desc and go to next in list.
930 */
931 desc_list2->first = help->next;
932 /*
933 * If another desc is present in the list to be read, then
934 * set the desc_offset to the offset of the next desc in the
935 * list that is to be read. Else set desc_offset to zero
936 */
937 if (desc_list2->first != NULL)
938 {
939 desc_offset = ((T_desc2*)desc_list2->first)->offset;
940 }
941 else
942 {
943 desc_offset = 0;
944 }
945 MFREE(help);
946 help = NULL;
947 } else {
948 /*
949 * Current desc does not fit completely in sdu.
950 */
951
952 USHORT part_len = (USHORT)(sndcp_data->su->n201_u - desc_list3.list_len);
953
954 if (part_len > 0)
955 {
956 MALLOC (desc3, (USHORT)(sizeof(T_desc3)));
957 /*
958 * Fill desc3 descriptor control information.
959 */
960 desc3->next = (ULONG)NULL;
961 desc3->len = part_len;
962 desc3->offset = desc_offset + desc2_data_struct_offset;
963 desc3->buffer = (ULONG)desc_list2->first;
964 current_desc3->next = (ULONG)desc3;
965 current_desc3 = desc3;
966 desc_list3.list_len += desc3->len;
967
968 /* Attach desc3 to desc2 allocation, this is an intermediate
969 attach on a desc2 descriptor */
970 sndcp_cl_desc2_attach(help);
971
972 desc_offset += part_len;
973 }
974 desc_list2->list_len -= part_len;
975
976 header_size = SN_UNITDATA_PDP_HDR_LEN_SMALL;
977 break;
978 }
979 } /* while (desc_list->first != NULL) { */
980
981 /*
982 * Instead of PSEND(SNDCP_handle, cia_comp_ind);
983 */
984 cia_cia_comp_ind(cia_comp_ind);
985 /*
986 * One segment sent, set 'first' to 'none'.
987 */
988 first = SEG_POS_NONE;
989 }
990 /*
991 * If the desc_list is empty now, leave.
992 */
993 if (sn_unitdata_req->desc_list2.list_len == 0) {
994
995 MFREE(sn_unitdata_req);
996 sn_unitdata_req = NULL;
997 ready = TRUE;
998 }
999 }
1000 } /* cia_su_cia_comp_req() */
1001 /*#endif */ /* CF_FAST_EXEC || _SIMULATION_ || !REL99 || SNDCP_2to1 */
1002
1003 #ifdef TI_PS_FF_V42BIS
1004 /*
1005 +------------------------------------------------------------------------------
1006 | Function : cia_su_cci_comp_req
1007 +------------------------------------------------------------------------------
1008 | Description : This function is used, if data compression is used in uplink
1009 | direction. At first it calls the data compression function with
1010 | parameters, that allow a segmentation without memcopy. Than it
1011 | does the segmentation.
1012 |
1013 | Simulation for CCI reaction to SIG_SU_CIA_DATA_REQ.
1014 | Instead of sending the pdu to CCI and then receiving
1015 | 1 or more CCI_COMP_IND.
1016 |
1017 | Parameters :
1018 |
1019 +------------------------------------------------------------------------------
1020 */
1021 /*#if defined(CF_FAST_EXEC) || defined(_SIMULATION_) || \
1022 !defined(REL99) || defined(SNDCP_2to1) */
1023
1024 LOCAL void cia_su_cci_comp_req (T_SN_UNITDATA_REQ* sn_unitdata_req,
1025 USHORT npdu_number,
1026 UBYTE nsapi,
1027 UBYTE sapi,
1028 UBYTE packet_type
1029 )
1030 {
1031 BOOL ready = FALSE;
1032 U16 header_size = SN_UNITDATA_PDP_HDR_LEN_BIG;
1033 U16 desc2_data_struct_offset = offsetof(T_desc2, buffer);
1034 U8 segment_position = SEG_POS_FIRST;
1035 U8 segment_number = 0;
1036 U32* segment_header;
1037 T_desc_list2* desc_list2 = &sn_unitdata_req->desc_list2;
1038 T_desc2* desc2;
1039 T_desc_list3 desc_list3;
1040 T_desc3* desc3;
1041 T_desc3* current_desc3;
1042
1043 U8 descs_per_seg = 5;
1044 U8 i;
1045 U16 desc_size = (sndcp_data->su->n201_u - header_size -
1046 (desc2_data_struct_offset + 1) * descs_per_seg) /
1047 descs_per_seg +
1048 desc2_data_struct_offset + 1;
1049
1050
1051
1052
1053
1054
1055 TRACE_FUNCTION( "cia_su_cci_comp_req" );
1056 TRACE_EVENT_P1("sn_unitdata_req in: %08x", sn_unitdata_req);
1057 //TRACE_EVENT_P1("PacketType: %d",packet_type);
1058
1059 /*
1060 * Reset V.42 context and call the encoder routine
1061 */
1062 //TRACE_EVENT_P1("V42 ENC: Input Uncompressed Packet, length %d", desc_list2->list_len);
1063 #ifdef SNDCP_TRACE_BUFFER
1064 //sndcp_trace_desc_list(desc_list2);
1065 #endif
1066 v42b_init(sndcp_data->cia.enc, 0, 0, 0, 0);
1067 TRACE_FUNCTION ("as reinit in uplink");
1068 /*
1069 * the function can be called with 0s as parameters, because it was initialized
1070 * befor what the function sees on the valid magic number
1071 *
1072 * the call replaces an independent reinit function
1073 */
1074 v42b_encoder(sndcp_data->cia.enc, desc_list2, NULL, desc_size);
1075 //TRACE_EVENT_P1("V42 ENC: Output Compresset Packet, length %d", desc_list2->list_len);
1076 #ifdef SNDCP_TRACE_BUFFER
1077 //sndcp_trace_desc_list(desc_list2);
1078 #endif
1079
1080
1081 desc2 = (T_desc2*)desc_list2->first;
1082
1083 while (desc2)
1084 {
1085
1086
1087
1088 desc_list3.first = (U32) NULL;
1089 desc_list3.list_len = 0;
1090
1091
1092 MALLOC(segment_header, (ENCODE_OFFSET_BYTE + header_size));
1093 MALLOC(desc3,sizeof(T_desc3));
1094
1095 desc3->next = (U32) NULL;
1096 desc3->len = header_size;
1097 desc3->offset = ENCODE_OFFSET_BYTE;
1098 desc3->buffer = (U32)segment_header;
1099
1100 desc_list3.first = (U32)desc3;
1101 desc_list3.list_len = desc3->len;
1102
1103 current_desc3 = desc3;
1104
1105 for (i = 0; (i < descs_per_seg) && desc2; i++)
1106 {
1107 MALLOC(desc3,sizeof(T_desc3));
1108
1109 desc3->next = (U32) NULL;
1110 desc3->len = desc2->len;
1111 desc3->offset = desc2->offset + desc2_data_struct_offset;
1112 desc3->buffer = (U32)desc2;
1113
1114 current_desc3->next = (U32) desc3;
1115 current_desc3 = desc3;
1116 desc_list3.list_len += desc3->len;
1117
1118 desc2 = (T_desc2*) desc2->next;
1119 }
1120 header_size = SN_UNITDATA_PDP_HDR_LEN_SMALL;
1121
1122 {
1123 T_CIA_COMP_IND *cia_comp_ind;
1124 MALLOC(cia_comp_ind, sizeof(T_CIA_COMP_IND));
1125 /*
1126 * Set parameters.
1127 */
1128
1129 cia_comp_ind->sapi = sapi;
1130 /*
1131 * cci_qos is not yet used, set to 0.
1132 */
1133 cia_comp_ind->cia_qos.delay = 0;
1134 cia_comp_ind->cia_qos.relclass = 0;
1135 cia_comp_ind->cia_qos.peak = 0;
1136 cia_comp_ind->cia_qos.preced = 0;
1137 cia_comp_ind->cia_qos.mean = 0;
1138 /*
1139 * Will be changed as soon as more that 1 instance of V42.bis is used.
1140 */
1141 cia_comp_ind->algo_type = CCI_ALGO_V42;
1142 cia_comp_ind->comp_inst = CCI_COMP_INST_V42_0;
1143
1144 cia_comp_ind->pdu_ref.ref_nsapi = nsapi;
1145 cia_comp_ind->pdu_ref.ref_npdu_num = npdu_number;
1146 cia_comp_ind->pdu_ref.ref_seg_num = segment_number;
1147 segment_number ++;
1148
1149 if (desc2 != NULL)
1150 {
1151 cia_comp_ind->seg_pos = segment_position;
1152 }
1153 else
1154 {
1155 cia_comp_ind->seg_pos = segment_position | SEG_POS_LAST;
1156 }
1157
1158 cia_comp_ind->packet_type = packet_type;
1159 cia_comp_ind->desc_list3.first = desc_list3.first;
1160 cia_comp_ind->desc_list3.list_len = desc_list3.list_len;
1161
1162 /*
1163 * Instead of PSEND(SNDCP_handle, cci_comp_ind);
1164 */
1165 cia_cia_comp_ind(cia_comp_ind);
1166 /*
1167 * One segment sent, set 'first' to 'none'.
1168 */
1169 segment_position = SEG_POS_NONE;
1170 }
1171 }
1172 /*
1173 * If the desc_list2 is empty now, leave.
1174 */
1175 TRACE_EVENT_P1("sn_unitdata_req out: %08x", sn_unitdata_req);
1176 MFREE(sn_unitdata_req);
1177 sn_unitdata_req = NULL;
1178 }
1179 /*#endif */ /* FAST_EXEC */
1180 #endif /* TI_PS_FF_V42BIS */
1181 #endif /* _SNDCP_DTI_2_ */
1182
1183 #ifdef _SNDCP_DTI_2_
1184 /*
1185 +------------------------------------------------------------------------------
1186 | Function : cia_sua_cia_comp_req
1187 +------------------------------------------------------------------------------
1188 | Description : Simulation for cia reaction to SIG_SUA_CIA_DATA_REQ.
1189 | Instead of sending the pdu to cia and then receiving
1190 | 1 or more CIA_COMP_IND.
1191 |
1192 | Parameters :
1193 |
1194 +------------------------------------------------------------------------------
1195 */
1196 #ifndef CF_FAST_EXEC
1197
1198 LOCAL void cia_sua_cia_comp_req (T_desc_list2 dest_desc_list,
1199 U8 npdu_number,
1200 U8 nsapi,
1201 U8 sapi,
1202 U8 packet_type
1203 )
1204 {
1205 BOOL ready = FALSE;
1206 U16 header_size = SN_DATA_PDP_HDR_LEN_BIG;
1207 U16 desc2_data_struct_offset = 0;
1208 U8 first = SEG_POS_FIRST;
1209 U8 segment_number = 0;
1210 U32* segment_header;
1211 T_desc_list2* desc_list2 = &dest_desc_list;
1212 T_desc_list3 desc_list3;
1213 T_desc3* desc3;
1214 T_desc3* current_desc3;
1215 USHORT list_len = desc_list2->list_len;
1216 T_desc2* help = (T_desc2*)desc_list2->first;
1217 T_desc2* delhelp = NULL;
1218
1219 /*
1220 * Offset in current descriptor Set the desc_offset to the offset of
1221 * the first desc in the list that is to be read.
1222 */
1223 U16 desc_offset = help->offset;
1224
1225 TRACE_FUNCTION( "cia_sua_cia_comp_req" );
1226
1227 while (!ready && help != NULL) {
1228 /*
1229 * How long will the segment be?
1230 */
1231 desc_list3.first = NULL;
1232 desc_list3.list_len = 0;
1233 if ((list_len + header_size) >= sndcp_data->sua->n201_i)
1234 {
1235 desc_list3.list_len = (U16)sndcp_data->sua->n201_i;
1236 }
1237 else
1238 {
1239 desc_list3.list_len = (U16)(list_len + header_size);
1240 }
1241
1242 {
1243 /*
1244 * First desc in list must be header!!!
1245 */
1246 BOOL first_part = TRUE;
1247
1248 T_CIA_COMP_IND *cia_comp_ind;
1249 MALLOC(cia_comp_ind, sizeof(T_CIA_COMP_IND));
1250 /*
1251 * Set parameters.
1252 */
1253 cia_comp_ind->sapi = sapi;
1254 /*
1255 * cia_qos is not yet used, set to 0.
1256 */
1257 cia_comp_ind->cia_qos.delay = 0;
1258 cia_comp_ind->cia_qos.relclass = 0;
1259 cia_comp_ind->cia_qos.peak = 0;
1260 cia_comp_ind->cia_qos.preced = 0;
1261 cia_comp_ind->cia_qos.mean = 0;
1262 /*
1263 * Will be changed as soon as more that 1 instance of V42.bis is used.
1264 */
1265 cia_comp_ind->algo_type = CIA_ALGO_V42;
1266 cia_comp_ind->comp_inst = CIA_COMP_INST_V42_0;
1267
1268 cia_comp_ind->pdu_ref.ref_nsapi = nsapi;
1269 cia_comp_ind->pdu_ref.ref_npdu_num = npdu_number;
1270 cia_comp_ind->pdu_ref.ref_seg_num = segment_number;
1271 segment_number ++;
1272
1273 /* Allocate memory for SNDCP header and LLC encode offset */
1274 MALLOC (segment_header, (U16)(ENCODE_OFFSET_BYTE + header_size));
1275
1276 MALLOC (desc3, (U16)(sizeof(T_desc3)));
1277 /*
1278 * Fill desc3 descriptor control information.
1279 */
1280 desc3->next = (U32)NULL;
1281 desc3->len = header_size;
1282 desc3->offset = ENCODE_OFFSET_BYTE;
1283 desc3->buffer = (U32)segment_header;
1284 desc_list3.first = (U32)desc3;
1285 current_desc3 = desc3;
1286
1287 if (list_len + header_size <= sndcp_data->sua->n201_i)
1288 {
1289 cia_comp_ind->seg_pos = first + SEG_POS_LAST;
1290 } else {
1291 cia_comp_ind->seg_pos = first;
1292 }
1293 cia_comp_ind->packet_type = packet_type;
1294 cia_comp_ind->desc_list3.first = desc_list3.first;
1295 cia_comp_ind->desc_list3.list_len = desc_list3.list_len;
1296
1297 desc_list3.list_len = 0;
1298 desc_list3.list_len += desc3->len;
1299 /*
1300 * Copy descriptors to cia_comp_ind->desc_list3, list may have to be built.
1301 */
1302 while (help != NULL)
1303 {/*
1304 * This while moves data from desc2 to segment defined
1305 * by desc3 descriptors
1306 */
1307 U16 cur_len = (help->len - desc_offset);
1308 desc2_data_struct_offset = offsetof(T_desc2, buffer);
1309 if (cur_len <= (sndcp_data->sua->n201_i - desc_list3.list_len))
1310 {/* Is there room for all the desc2 data in the current segment */
1311 /*
1312 * describe current desc2 by desc3 descriptors.
1313 */
1314 if (cur_len>0)
1315 {
1316 MALLOC (desc3, (U16)(sizeof(T_desc3)));
1317 /*
1318 * Fill desc3 descriptor control information.
1319 */
1320 desc3->next = (U32)NULL;
1321 desc3->len = cur_len;
1322 desc3->offset = desc_offset + desc2_data_struct_offset;
1323 desc3->buffer = (U32)help;
1324 current_desc3->next = (ULONG)desc3;
1325 current_desc3 = desc3;
1326 desc_list3.list_len += desc3->len;
1327
1328 /* Attach desc3 to desc2 allocation, this is always the last
1329 attach on a desc2 descriptor */
1330 sndcp_cl_desc2_attach(help);
1331
1332 }
1333 list_len -= cur_len;
1334
1335 /*
1336 * Free read desc and go to next in list.
1337 */
1338 if (help != NULL)
1339 {
1340 delhelp = help;
1341 help = (T_desc2*)help->next;
1342 }
1343 /*
1344 * If another desc is present in the list to be read, then
1345 * set the desc_offset to the offset of the next desc in the
1346 * list that is to be read. Else set desc_offset to zero
1347 */
1348 if (help != NULL)
1349 {
1350 desc_offset = help->offset;
1351 }
1352 else
1353 {
1354 desc_offset = 0;
1355 }
1356 if (delhelp != NULL &&
1357 first_part &&
1358 (packet_type == TYPE_COMPRESSED_TCP ||
1359 packet_type == TYPE_UNCOMPRESSED_TCP)) {
1360
1361 MFREE(delhelp);
1362 delhelp = NULL;
1363 first_part = FALSE;
1364 }
1365 }
1366 else
1367 {
1368 /*
1369 * Current desc does not fit completely in sdu.
1370 */
1371
1372 U16 part_len = (USHORT)(sndcp_data->sua->n201_i-desc_list3.list_len);
1373
1374 if (part_len>0)
1375 {
1376 MALLOC (desc3, (USHORT)(sizeof(T_desc3)));
1377 /*
1378 * Fill desc3 descriptor control information.
1379 */
1380 desc3->next = (ULONG)NULL;
1381 desc3->len = part_len;
1382 desc3->offset = desc_offset + desc2_data_struct_offset;
1383 desc3->buffer = (ULONG)help;
1384 current_desc3->next = (ULONG)desc3;
1385 current_desc3 = desc3;
1386 desc_list3.list_len += desc3->len;
1387
1388 /* Attach desc3 to desc2 allocation, this is an intermediate
1389 attach on a desc2 descriptor */
1390 sndcp_cl_desc2_attach(help);
1391
1392 desc_offset += part_len;
1393 }
1394 list_len -= part_len;
1395
1396 header_size = SN_DATA_PDP_HDR_LEN_SMALL;
1397 break;
1398 }
1399 }
1400 /*
1401 * Instead of PSEND(SNDCP_handle, cia_comp_ind);
1402 */
1403 cia_cia_comp_ind(cia_comp_ind);
1404 /*
1405 * One segment sent, set 'first' to 'none'.
1406 */
1407 first = SEG_POS_NONE;
1408 }
1409 /*
1410 * If the desc_list is empty now, leave.
1411 */
1412 if (list_len == 0) {
1413 ready = TRUE;
1414 }
1415 }
1416 } /* cia_sua_cia_comp_req() */
1417
1418 #endif /* CF_FAST_EXEC */
1419
1420 #else /* _SNDCP_DTI_2_ */
1421 /*
1422 +------------------------------------------------------------------------------
1423 | Function : cia_sua_cia_comp_req
1424 +------------------------------------------------------------------------------
1425 | Description : Simulation for cia reaction to SIG_SUA_CIA_DATA_REQ.
1426 | Instead of sending the pdu to cia and then receiving
1427 | 1 or more CIA_COMP_IND.
1428 |
1429 | Parameters :
1430 |
1431 +------------------------------------------------------------------------------
1432 */
1433 #ifndef CF_FAST_EXEC
1434
1435 LOCAL void cia_sua_cia_comp_req (T_desc_list dest_desc_list,
1436 UBYTE npdu_number,
1437 UBYTE nsapi,
1438 UBYTE sapi,
1439 UBYTE packet_type
1440 )
1441 {
1442 BOOL ready = FALSE;
1443 USHORT header_size = SN_DATA_PDP_HDR_LEN_BIG;
1444 USHORT bit_offset = ENCODE_OFFSET + (USHORT)(header_size << 3);
1445 USHORT desc_offset = 0;
1446 USHORT sdu_len = 0;
1447 UBYTE first = SEG_POS_FIRST;
1448 UBYTE segment_number = 0;
1449 T_desc_list* desc_list = &dest_desc_list;
1450 USHORT list_len = desc_list->list_len;
1451 T_desc* help = (T_desc*)desc_list->first;
1452 T_desc* delhelp = NULL;
1453
1454 USHORT help_buffer_offset = 0;
1455
1456 TRACE_FUNCTION( "cia_sua_cia_comp_req" );
1457
1458 while (!ready && help != NULL) {
1459 /*
1460 * How long will sdu be?
1461 */
1462 if (list_len + header_size >= sndcp_data->sua->n201_i) {
1463 sdu_len = (USHORT)(sndcp_data->sua->n201_i << 3);
1464 } else {
1465 sdu_len = (USHORT)((list_len + header_size) << 3);
1466 }
1467 {
1468 /*
1469 * First desc in list must be header!!!
1470 */
1471 BOOL first_part = TRUE;
1472
1473 PALLOC_SDU(cia_comp_ind, CCI_COMP_IND, sdu_len);
1474 /*
1475 * Set parameters.
1476 */
1477 cia_comp_ind->sapi = sapi;
1478 /*
1479 * cia_qos is not yet used, set to 0.
1480 */
1481 cia_comp_ind->cia_qos.delay = 0;
1482 cia_comp_ind->cia_qos.relclass = 0;
1483 cia_comp_ind->cia_qos.peak = 0;
1484 cia_comp_ind->cia_qos.preced = 0;
1485 cia_comp_ind->cia_qos.mean = 0;
1486 /*
1487 * Will be changed as soon as more that 1 instance of V42.bis is used.
1488 */
1489 cia_comp_ind->algo_type = CIA_ALGO_V42;
1490 cia_comp_ind->comp_inst = CIA_COMP_INST_V42_0;
1491
1492 cia_comp_ind->pdu_ref.ref_nsapi = nsapi;
1493 cia_comp_ind->pdu_ref.ref_npdu_num = npdu_number;
1494 cia_comp_ind->pdu_ref.ref_seg_num = segment_number;
1495 segment_number ++;
1496 if (list_len + header_size <= sndcp_data->sua->n201_i) {
1497 cia_comp_ind->seg_pos = first + SEG_POS_LAST;
1498 } else {
1499 cia_comp_ind->seg_pos = first;
1500 }
1501 cia_comp_ind->packet_type = packet_type;
1502 /*
1503 * Copy descriptors to cia_comp_ind->sdu.
1504 */
1505 while (help != NULL) {
1506 USHORT cur_len = (help->len - desc_offset);
1507
1508 if ((cur_len << 3) <=
1509 cia_comp_ind->sdu.l_buf +
1510 cia_comp_ind->sdu.o_buf -
1511 bit_offset) {
1512
1513 /*
1514 * Copy current desc to sdu.
1515 */
1516 if (cur_len>0)
1517 {
1518 memcpy(&cia_comp_ind->sdu.buf[bit_offset >> 3],
1519 &help->buffer[desc_offset],
1520 cur_len);
1521 }
1522 bit_offset += (USHORT)(cur_len << 3);
1523 list_len -= cur_len;
1524
1525 /*
1526 * Free read desc and go to next in list.
1527 */
1528 if (help != NULL) {
1529 delhelp = help;
1530 help = (T_desc*)help->next;
1531 }
1532 help_buffer_offset = 0;
1533 desc_offset = 0;
1534 if (delhelp != NULL &&
1535 first_part &&
1536 (packet_type == TYPE_COMPRESSED_TCP ||
1537 packet_type == TYPE_UNCOMPRESSED_TCP)) {
1538
1539 MFREE(delhelp);
1540 delhelp = NULL;
1541 first_part = FALSE;
1542 }
1543 } else {
1544 /*
1545 * Current desc does not fit completely in sdu.
1546 */
1547 desc_offset = (USHORT)(cia_comp_ind->sdu.l_buf +
1548 cia_comp_ind->sdu.o_buf -
1549 bit_offset)
1550 >> 3;
1551 if (desc_offset>0)
1552 {
1553 memcpy(&cia_comp_ind->sdu.buf[bit_offset >> 3],
1554 &help->buffer[help_buffer_offset],
1555 desc_offset);
1556 help_buffer_offset += (desc_offset);
1557 }
1558 list_len -= desc_offset;
1559
1560 header_size = SN_DATA_PDP_HDR_LEN_SMALL;
1561 bit_offset = ENCODE_OFFSET + (USHORT)(header_size << 3);
1562 break;
1563 }
1564 }
1565 /*
1566 * Instead of PSEND(SNDCP_handle, cia_comp_ind);
1567 */
1568 cia_cia_comp_ind(cia_comp_ind);
1569 /*
1570 * One segment sent, set 'first' to 'none'.
1571 */
1572 first = SEG_POS_NONE;
1573 }
1574 /*
1575 * If the desc_list is empty now, leave.
1576 */
1577 if (list_len == 0) {
1578 ready = TRUE;
1579 }
1580 }
1581
1582 } /* cia_sua_cia_comp_req() */
1583
1584 #endif /* CF_FAST_EXEC */
1585
1586 #endif /*_SNDCP_DTI_2_*/
1587
1588
1589 /*
1590 +------------------------------------------------------------------------------
1591 | Function : cia_sd_cia_decomp_req
1592 +------------------------------------------------------------------------------
1593 | Description : This Function does the defragmentation for noncompressed data.
1594 |
1595 | Simulation for cia reaction to SIG_SD_CIA_TRANSFER_REQ.
1596 | If (cur_seg_pos & SEG_POS_FIRST > 0) then a new CIA_DECOMP_IND is allocated.
1597 | T_desc is allocated with the length of the sdu included in the
1598 | ll_unitdata_ind. The sdu data is copied to the desc and the desc is added to
1599 | the currently assembled desc_list in the current CIA_DECOMP_IND.
1600 | If (cur_seg_pos & SEG_POS_LAST > 0) then a the CIA_DECOMP_IND is now complete
1601 | and is "sent to this service" by calling the cia function cia_cia_decomp_ind.
1602 |
1603 | Parameters :
1604 |
1605 +------------------------------------------------------------------------------
1606 */
1607 /*#if defined(CF_FAST_EXEC) || defined(_SIMULATION_) || \
1608 !defined(REL99) || defined(SNDCP_2to1) */
1609
1610 GLOBAL void cia_sd_cia_decomp_req(T_LL_UNITDATA_IND* ll_unitdata_ind)
1611 {
1612 USHORT length = 0;
1613 USHORT header_len = SN_UNITDATA_PDP_HDR_LEN_SMALL;
1614 USHORT sdu_index = 0;
1615 T_CIA_DECOMP_IND *cur_cia_decomp_ind;
1616 UBYTE nsapi;
1617 #ifdef _SNDCP_DTI_2_
1618 T_desc2* help = NULL;
1619 T_desc2* descriptor = NULL;
1620 #else /*_SNDCP_DTI_2_*/
1621 T_desc* help = NULL;
1622 T_desc* descriptor = NULL;
1623 #endif /*_SNDCP_DTI_2_*/
1624
1625 TRACE_FUNCTION( "cia_sd_cia_decomp_req" );
1626
1627 nsapi = (ll_unitdata_ind->sdu.buf[(ll_unitdata_ind->sdu.o_buf / 8)]) & 0xf;
1628 cur_cia_decomp_ind = sndcp_data->cia.cur_cia_decomp_ind[nsapi];
1629
1630 /*
1631 * In case of first segment allocate new N-PDU.
1632 */
1633 if ((sndcp_data->cur_seg_pos[nsapi] & SEG_POS_FIRST) > 0) {
1634 {
1635
1636 T_CIA_DECOMP_IND *cia_decomp_ind;
1637 MALLOC(cia_decomp_ind, sizeof(T_CIA_DECOMP_IND));
1638
1639 #ifdef SNDCP_TRACE_ALL
1640
1641 sndcp_data->cia.cia_decomp_ind_number[nsapi] ++;
1642 TRACE_EVENT_P1("number of cia_decomp_ind: % d",
1643 sndcp_data->cia.cia_decomp_ind_number[nsapi]);
1644 #endif /* SNDCP_TRACE_ALL */
1645
1646
1647 /*
1648 * if there is an unfinished cur_cia_decomp_ind deallocate it together
1649 * with the allocated descriptors
1650 */
1651 if (cur_cia_decomp_ind NEQ NULL)
1652 {
1653 MFREE_PRIM(cur_cia_decomp_ind);
1654 TRACE_EVENT("Deallocate unfinished cur_cia_decomp_ind");
1655 }
1656 cur_cia_decomp_ind = cia_decomp_ind;
1657 /*
1658 * Will be changed as soon as more that 1 instance of V42.bis is used.
1659 */
1660 cur_cia_decomp_ind->algo_type = CIA_ALGO_V42;
1661 cur_cia_decomp_ind->comp_inst = CIA_COMP_INST_V42_0;
1662
1663 cur_cia_decomp_ind->pdu_ref = sndcp_data->cur_pdu_ref[nsapi];
1664 cur_cia_decomp_ind->desc_list2.first = (ULONG)NULL;
1665 cur_cia_decomp_ind->desc_list2.list_len = 0;
1666
1667 header_len = SN_UNITDATA_PDP_HDR_LEN_BIG;
1668 cia_decomp_ind->pcomp =
1669 ll_unitdata_ind->sdu.buf[(ll_unitdata_ind->sdu.o_buf >> 3) + 1] & 0xf;
1670 }
1671 }
1672 /*
1673 * If big header has been received in state != RECEIVE_FIRST_SEGMENT
1674 */
1675 if (sndcp_data->big_head[nsapi]) {
1676 header_len = SN_UNITDATA_PDP_HDR_LEN_BIG;
1677 }
1678 sdu_index = (ll_unitdata_ind->sdu.o_buf >> 3) + header_len;
1679 length = (ll_unitdata_ind->sdu.l_buf >> 3) - header_len;
1680 /*
1681 * Allocate new descriptor and copy sdu data.
1682 */
1683 #ifdef _SNDCP_DTI_2_
1684 MALLOC (descriptor, (USHORT)(sizeof(T_desc2) - 1 + length));
1685 #else /*_SNDCP_DTI_2_*/
1686 MALLOC (descriptor, (USHORT)(sizeof(T_desc) - 1 + length));
1687 #endif /*_SNDCP_DTI_2_*/
1688
1689 /*
1690 * Fill descriptor control information.
1691 */
1692 descriptor->next = (ULONG)NULL;
1693 descriptor->len = length;
1694 #ifdef _SNDCP_DTI_2_
1695 descriptor->offset = 0;
1696 descriptor->size = descriptor->len;
1697 #endif
1698
1699 /*
1700 * Add length of descriptor data to list length.
1701 */
1702 cur_cia_decomp_ind->desc_list2.list_len += length;
1703
1704 /*
1705 * Copy user data from SDU to descriptor.
1706 */
1707 if (length>0)
1708 {
1709 memcpy (descriptor->buffer,
1710 &ll_unitdata_ind->sdu.buf[sdu_index],
1711 length);
1712 }
1713
1714 /*
1715 * Add desc to desc_list.
1716 */
1717 #ifdef _SNDCP_DTI_2_
1718 help = (T_desc2*)cur_cia_decomp_ind->desc_list2.first;
1719 #else /*_SNDCP_DTI_2_*/
1720 help = (T_desc*)cur_cia_decomp_ind->desc_list2.first;
1721 #endif /*_SNDCP_DTI_2_*/
1722 if (help == NULL) {
1723 cur_cia_decomp_ind->desc_list2.first = (ULONG)descriptor;
1724 } else {
1725 if (help->next == NULL) {
1726 help->next = (ULONG) descriptor;
1727 } else {
1728 while (help->next != NULL) {
1729 #ifdef _SNDCP_DTI_2_
1730 help = (T_desc2*)help->next;
1731 #else /*_SNDCP_DTI_2_*/
1732 help = (T_desc*)help->next;
1733 #endif /*_SNDCP_DTI_2_*/
1734 }
1735 help->next = (ULONG)descriptor;
1736 }
1737 }
1738
1739 /*
1740 * If this is the last segment, send it to this same service with a simulated
1741 * primitive.
1742 */
1743 if ((sndcp_data->cur_seg_pos[nsapi] & SEG_POS_LAST) > 0) {
1744 /*
1745 * By now algo_type, cia_qos and comp_inst are not evaluated.
1746 */
1747 cur_cia_decomp_ind->pdu_ref = sndcp_data->cur_pdu_ref[nsapi];
1748 cia_cia_decomp_ind(cur_cia_decomp_ind);
1749 cur_cia_decomp_ind = NULL;
1750 } else {
1751 /*
1752 * Request next segment.
1753 */
1754 sd_get_unitdata_if_nec(ll_unitdata_ind->sapi);
1755 }
1756 /*
1757 * Update global current CIA_DECOMP_IND
1758 */
1759 sndcp_data->cia.cur_cia_decomp_ind[nsapi] = cur_cia_decomp_ind;
1760 /*
1761 * Free incoming prim.
1762 */
1763 if (ll_unitdata_ind != NULL) {
1764 PFREE (ll_unitdata_ind);
1765 ll_unitdata_ind = NULL;
1766 }
1767 } /* cia_sd_cia_decomp_req() */
1768
1769 /*#endif */ /* CF_FAST_EXEC || _SIMULATION_ || !REL99 || SNDCP_2to1 */
1770
1771 #ifdef TI_PS_FF_V42BIS
1772 /*
1773 +------------------------------------------------------------------------------
1774 | Function : cia_sd_cci_decomp_req
1775 +------------------------------------------------------------------------------
1776 | Description : This function does the desegmentation and decomressoin for
1777 | compressed data.
1778 |
1779 | Simulation for CCI reaction to SIG_SD_CIA_TRANSFER_REQ.
1780 | If (cur_seg_pos & SEG_POS_FIRST > 0) then a new CCI_DECOMP_IND is allocated.
1781 | T_desc is allocated with the length of the sdu included in the
1782 | ll_unitdata_ind. The sdu data is copied to the desc and the desc is added to
1783 | the currently assembled desc_list in the current CCI_DECOMP_IND.
1784 | If (cur_seg_pos & SEG_POS_LAST > 0) then a the CCI_DECOMP_IND is now complete
1785 | and is "sent to this service" by calling the cia function cia_cci_decomp_ind.
1786 |
1787 | Parameters :
1788 |
1789 +------------------------------------------------------------------------------
1790 */
1791 /*#if defined(CF_FAST_EXEC) || defined(_SIMULATION_) || \
1792 !defined(REL99) || defined(SNDCP_2to1) */
1793
1794 LOCAL void cia_sd_cci_decomp_req (/*T_pdu_ref pdu_ref,
1795 USHORT cur_seg_pos,
1796 */T_LL_UNITDATA_IND* ll_unitdata_ind
1797 )
1798 {
1799
1800 USHORT length = 0;
1801 USHORT header_len = SN_UNITDATA_PDP_HDR_LEN_SMALL;
1802 USHORT sdu_index = 0;
1803 T_CIA_DECOMP_IND *cur_cia_decomp_ind;
1804 UBYTE nsapi;
1805 #ifdef _SNDCP_DTI_2_
1806 T_desc2* help = NULL;
1807 T_desc2* descriptor = NULL;
1808 #else /*_SNDCP_DTI_2_*/
1809 T_desc* help = NULL;
1810 T_desc* descriptor = NULL;
1811 #endif /*_SNDCP_DTI_2_*/
1812
1813 TRACE_FUNCTION( "cia_sd_cci_decomp_req" );
1814
1815 nsapi = (ll_unitdata_ind->sdu.buf[(ll_unitdata_ind->sdu.o_buf / 8)]) & 0xf;
1816 cur_cia_decomp_ind = sndcp_data->cia.cur_cia_decomp_ind[nsapi];
1817
1818 /*
1819 * In case of first segment allocate new N-PDU.
1820 */
1821 if ((sndcp_data->cur_seg_pos[nsapi] & SEG_POS_FIRST) > 0)
1822 {
1823 {
1824 T_CIA_DECOMP_IND *cia_decomp_ind;
1825 MALLOC(cia_decomp_ind, sizeof(T_CIA_DECOMP_IND));
1826
1827 #ifdef SNDCP_TRACE_ALL
1828
1829 sndcp_data->cia.cia_decomp_ind_number[nsapi] ++;
1830 TRACE_EVENT_P1("number of cia_decomp_ind: % d",
1831 sndcp_data->cia.cia_decomp_ind_number[nsapi]);
1832 #endif /* SNDCP_TRACE_ALL */
1833
1834
1835 /*
1836 * if there is an unfinished cur_cia_decomp_ind deallocate it together
1837 * with the allocated descriptors
1838 */
1839 if (cur_cia_decomp_ind NEQ NULL)
1840 {
1841 MFREE_PRIM(cur_cia_decomp_ind);
1842 TRACE_EVENT("Deallocate unfinished cur_cia_decomp_ind");
1843 }
1844 cur_cia_decomp_ind = cia_decomp_ind;
1845 /*
1846 * Will be changed as soon as more that 1 instance of V42.bis is used.
1847 */
1848 cur_cia_decomp_ind->algo_type = CIA_ALGO_V42;
1849 cur_cia_decomp_ind->comp_inst = CIA_COMP_INST_V42_0;
1850
1851 cur_cia_decomp_ind->pdu_ref = sndcp_data->cur_pdu_ref[nsapi];
1852 cur_cia_decomp_ind->desc_list2.first = (ULONG)NULL;
1853 cur_cia_decomp_ind->desc_list2.list_len = 0;
1854
1855 header_len = SN_UNITDATA_PDP_HDR_LEN_BIG;
1856 cia_decomp_ind->pcomp =
1857 ll_unitdata_ind->sdu.buf[(ll_unitdata_ind->sdu.o_buf >> 3) + 1] & 0xf;
1858 }
1859 }
1860 /*
1861 * If big header has been received in state != RECEIVE_FIRST_SEGMENT
1862 */
1863 if (sndcp_data->big_head[nsapi]) {
1864 header_len = SN_UNITDATA_PDP_HDR_LEN_BIG;
1865 }
1866 sdu_index = (ll_unitdata_ind->sdu.o_buf >> 3) + header_len;
1867 length = (ll_unitdata_ind->sdu.l_buf >> 3) - header_len;
1868 /*
1869 * Allocate new descriptor and copy sdu data.
1870 */
1871 #ifdef _SNDCP_DTI_2_
1872 MALLOC (descriptor, (USHORT)(sizeof(T_desc2) - 1 + length));
1873 #else /*_SNDCP_DTI_2_*/
1874 MALLOC (descriptor, (USHORT)(sizeof(T_desc) - 1 + length));
1875 #endif /*_SNDCP_DTI_2_*/
1876
1877 /*
1878 * Fill descriptor control information.
1879 */
1880 descriptor->next = (ULONG)NULL;
1881 descriptor->len = length;
1882 #ifdef _SNDCP_DTI_2_
1883 descriptor->offset = 0;
1884 descriptor->size = descriptor->len;
1885 #endif
1886
1887 /*
1888 * Add length of descriptor data to list length.
1889 */
1890 cur_cia_decomp_ind->desc_list2.list_len += length;
1891
1892 /*
1893 * Copy user data from SDU to descriptor.
1894 */
1895 if (length>0)
1896 {
1897 memcpy (descriptor->buffer,
1898 &ll_unitdata_ind->sdu.buf[sdu_index],
1899 length);
1900 }
1901
1902 /*
1903 * Add desc to desc_list.
1904 */
1905 #ifdef _SNDCP_DTI_2_
1906 help = (T_desc2*)cur_cia_decomp_ind->desc_list2.first;
1907 #else /*_SNDCP_DTI_2_*/
1908 help = (T_desc*)cur_cia_decomp_ind->desc_list2.first;
1909 #endif /*_SNDCP_DTI_2_*/
1910 if (help == NULL) {
1911 cur_cia_decomp_ind->desc_list2.first = (ULONG)descriptor;
1912 } else {
1913 if (help->next == NULL) {
1914 help->next = (ULONG) descriptor;
1915 } else {
1916 while (help->next != NULL) {
1917 #ifdef _SNDCP_DTI_2_
1918 help = (T_desc2*)help->next;
1919 #else /*_SNDCP_DTI_2_*/
1920 help = (T_desc*)help->next;
1921 #endif /*_SNDCP_DTI_2_*/
1922 }
1923 help->next = (ULONG)descriptor;
1924 }
1925 }
1926
1927 /*
1928 * If this is the last segment, send it to this same service with a simulated
1929 * primitive.
1930 */
1931 if ((sndcp_data->cur_seg_pos[nsapi] & SEG_POS_LAST) > 0)
1932 {
1933 T_desc_list2 desc_list2;
1934 /*
1935 * By now algo_type, cci_qos and comp_inst are not evaluated.
1936 */
1937 cur_cia_decomp_ind->pdu_ref = sndcp_data->cur_pdu_ref[nsapi];
1938
1939 desc_list2.first = cur_cia_decomp_ind->desc_list2.first;
1940 desc_list2.list_len = cur_cia_decomp_ind->desc_list2.list_len;
1941
1942 /*
1943 * Reset V.42 context and call the decoder routine.
1944 */
1945 TRACE_EVENT_P1("V42 DEC: Input Compresset Packet, length %d", desc_list2.list_len);
1946 #ifdef SNDCP_TRACE_BUFFER
1947 sndcp_trace_desc_list(&desc_list2);
1948
1949 sndcp_data->cia.trabu[0] = 0;///////////////////////////////////////////////////////////////
1950
1951 #endif
1952 v42b_init(sndcp_data->cia.dec, 0, 0, 0, 0);
1953 TRACE_EVENT ("as reinit in downlink");
1954 /*
1955 * the function can be called with 0s as parameters, because it was initialized
1956 * befor what the function sees on the valid magic number
1957 *
1958 * the call replaces an independent reinit function
1959 */
1960 v42b_decoder(sndcp_data->cia.dec, &desc_list2, NULL, 100);
1961 if (!IS_ERROR(sndcp_data->cia.dec))
1962 {
1963 TRACE_EVENT_P1("V42 DEC: Output Decompressed Packet, length %d", desc_list2.list_len);
1964 #ifdef SNDCP_TRACE_BUFFER
1965 sndcp_trace_desc_list(&desc_list2);
1966 #endif
1967
1968 cur_cia_decomp_ind->desc_list2.first = desc_list2.first;
1969 cur_cia_decomp_ind->desc_list2.list_len = desc_list2.list_len;
1970
1971 cia_cia_decomp_ind(cur_cia_decomp_ind);
1972 cur_cia_decomp_ind = NULL;
1973 }
1974 else
1975 {
1976 MFREE_PRIM (cur_cia_decomp_ind);
1977 cur_cia_decomp_ind = NULL;
1978 TRACE_EVENT("Deallocate corrupted V.42 bis packet");
1979
1980 /*
1981 * Request next segment.
1982 */
1983 sd_get_unitdata_if_nec(ll_unitdata_ind->sapi);
1984 }
1985 }
1986 else
1987 {
1988 /*
1989 * Request next segment.
1990 */
1991 sd_get_unitdata_if_nec(ll_unitdata_ind->sapi);
1992 }
1993 /*
1994 * Update global current CIA_DECOMP_IND
1995 */
1996 sndcp_data->cia.cur_cia_decomp_ind[nsapi] = cur_cia_decomp_ind;
1997 /*
1998 * Free incoming prim.
1999 */
2000 if (ll_unitdata_ind != NULL) {
2001 PFREE (ll_unitdata_ind);
2002 ll_unitdata_ind = NULL;
2003 }
2004 } /* cia_sd_cci_decomp_req_sim() */
2005
2006 /* #endif *//* CF_FAST_EXEC || _SIMULATION_ || !REL99 || SNDCP_2to1 */
2007 #endif /* TI_PS_FF_V42BIS */
2008
2009 /*
2010 +------------------------------------------------------------------------------
2011 | Function : sig_sda_cia_cia_decomp_req
2012 +------------------------------------------------------------------------------
2013 | Description : Simulation for cia reaction to SIG_SDA_CIA_TRANSFER_REQ.
2014 | If (cur_seg_pos & SEG_POS_FIRST > 0) then a new CIA_DECOMP_IND is allocated.
2015 | T_desc is allocated with the length of the sdu included in the
2016 | ll_data_ind. The sdu data is copied to the desc and the desc is added to
2017 | the currently assembled desc_list in the current CCI_DECOMP_IND.
2018 | If (cur_seg_pos & SEG_POS_LAST > 0) then a the CIA_DECOMP_IND is now complete
2019 | and is "sent to this service" by calling the cia function cia_cia_decomp_ind.
2020 |
2021 | Parameters :
2022 |
2023 +------------------------------------------------------------------------------
2024 */
2025 #ifndef CF_FAST_EXEC
2026
2027 GLOBAL void sig_sda_cia_cia_decomp_req ( T_LL_DATA_IND* ll_data_ind )
2028 {
2029 USHORT length = 0;
2030 USHORT header_len = SN_DATA_PDP_HDR_LEN_SMALL;
2031 USHORT sdu_index = 0;
2032 T_CIA_DECOMP_IND *cur_cia_decomp_ind;
2033 UBYTE nsapi = 0;
2034 #ifdef _SNDCP_DTI_2_
2035 T_desc2* help = NULL;
2036 T_desc2* local_desc = NULL;
2037 #else /*_SNDCP_DTI_2_*/
2038 T_desc* help = NULL;
2039 T_desc* local_desc = NULL;
2040 #endif /*_SNDCP_DTI_2_*/
2041
2042 TRACE_FUNCTION( "cia_sig_sda_cia_cia_decomp_req_sim" );
2043
2044 nsapi = (ll_data_ind->sdu.buf[(ll_data_ind->sdu.o_buf / 8)]) & 0xf;
2045 cur_cia_decomp_ind = sndcp_data->cia.cur_cia_decomp_ind[nsapi];
2046
2047 /*
2048 * In case of first segment allocate new N-PDU.
2049 */
2050 if ((sndcp_data->cur_seg_pos[nsapi] & SEG_POS_FIRST) > 0) {
2051
2052 T_CIA_DECOMP_IND *cia_decomp_ind;
2053 MALLOC(cia_decomp_ind, sizeof(T_CIA_DECOMP_IND));
2054
2055 #ifdef SNDCP_TRACE_ALL
2056 sndcp_data->cia.cia_decomp_ind_number[nsapi] ++;
2057 TRACE_EVENT_P1("number of cia_decomp_ind: % d",
2058 sndcp_data->cia.cia_decomp_ind_number[nsapi]);
2059 #endif
2060
2061 if (cur_cia_decomp_ind NEQ NULL)
2062 {
2063 MFREE_PRIM(cur_cia_decomp_ind);
2064 TRACE_EVENT("Deallocate unfinished cur_cia_decomp_ind");
2065 }
2066
2067 cur_cia_decomp_ind = cia_decomp_ind;
2068
2069 /*
2070 * Will be changed as soon as more that 1 instance of V42.bis is used.
2071 */
2072 cur_cia_decomp_ind->algo_type = CIA_ALGO_V42;
2073 cur_cia_decomp_ind->comp_inst = CIA_COMP_INST_V42_0;
2074
2075 cur_cia_decomp_ind->pdu_ref = sndcp_data->cur_pdu_ref[nsapi];
2076 cur_cia_decomp_ind->desc_list2.first = (ULONG)NULL;
2077 cur_cia_decomp_ind->desc_list2.list_len = 0;
2078
2079 header_len = SN_DATA_PDP_HDR_LEN_BIG;
2080 cia_decomp_ind->pcomp =
2081 ll_data_ind->sdu.buf[(ll_data_ind->sdu.o_buf >> 3) + 1] & 0xf;
2082
2083 }
2084 /*
2085 * If big header has been received in state != RECEIVE_FIRST_SEGMENT
2086 */
2087 if (sndcp_data->big_head[nsapi]) {
2088 header_len = SN_DATA_PDP_HDR_LEN_BIG;
2089 }
2090 sdu_index = (ll_data_ind->sdu.o_buf >> 3) + header_len;
2091
2092 if ((ll_data_ind->sdu.l_buf >> 3) < header_len){
2093 /*This condition is added as part of fix for GCF 46.1.2.2.3.2 failure because of wrong length*/
2094 TRACE_ERROR("SNDCP: Unexpected Length of N-PDU");
2095 PFREE (ll_data_ind);
2096 ll_data_ind = NULL;
2097 return;
2098 }else{
2099
2100 length = (ll_data_ind->sdu.l_buf >> 3) - header_len;
2101 }
2102
2103 /*
2104 * Allocate new descriptor and copy sdu data.
2105 */
2106 #ifdef _SNDCP_DTI_2_
2107 MALLOC (local_desc, (USHORT)(sizeof(T_desc2) - 1 + length));
2108 #else /*_SNDCP_DTI_2_*/
2109 MALLOC (local_desc, (USHORT)(sizeof(T_desc) - 1 + length));
2110 #endif /*_SNDCP_DTI_2_*/
2111
2112 /*
2113 * Fill descriptor control information.
2114 */
2115 local_desc->next = (ULONG)NULL;
2116 local_desc->len = length;
2117 #ifdef _SNDCP_DTI_2_
2118 local_desc->offset = 0;
2119 local_desc->size = local_desc->len;
2120 #endif
2121 /*
2122 * Add length of descriptor data to list length.
2123 */
2124 cur_cia_decomp_ind->desc_list2.list_len += length;
2125
2126 /*
2127 * Copy user data from SDU to descriptor.
2128 */
2129 if (length>0)
2130 {
2131 memcpy (local_desc->buffer, &ll_data_ind->sdu.buf[sdu_index], length);
2132 }
2133
2134 /*
2135 * Add desc to desc_list.
2136 */
2137 #ifdef _SNDCP_DTI_2_
2138 help = (T_desc2*)cur_cia_decomp_ind->desc_list2.first;
2139 #else /*_SNDCP_DTI_2_*/
2140 help = (T_desc*)cur_cia_decomp_ind->desc_list2.first;
2141 #endif /*_SNDCP_DTI_2_*/
2142 if (help == NULL) {
2143 cur_cia_decomp_ind->desc_list2.first = (ULONG)local_desc;
2144 } else {
2145 if (help->next == NULL) {
2146 help->next = (ULONG) local_desc;
2147 } else {
2148 while (help->next != NULL) {
2149 #ifdef _SNDCP_DTI_2_
2150 help = (T_desc2*)help->next;
2151 #else /*_SNDCP_DTI_2_*/
2152 help = (T_desc*)help->next;
2153 #endif /*_SNDCP_DTI_2_*/
2154 }
2155 help->next = (ULONG)local_desc;
2156 }
2157 }
2158 /*
2159 * If this is the last segment, send it to this same service with a simulated
2160 * primitive.
2161 */
2162 if ((sndcp_data->cur_seg_pos[nsapi] & SEG_POS_LAST) > 0) {
2163 /*
2164 * By now algo_type and comp_inst are not evaluated.
2165 */
2166 cur_cia_decomp_ind->pdu_ref = sndcp_data->cur_pdu_ref[nsapi];
2167 cia_cia_decomp_ind(cur_cia_decomp_ind);
2168 cur_cia_decomp_ind = NULL;
2169 /*
2170 * Reset the Current Segment Counter to zero, since we have received the
2171 * last segment
2172 */
2173 sndcp_data->cur_segment_number[nsapi] = 0;
2174 } else {
2175 /*
2176 * Check the Current Segment Number whether we have received more than
2177 * SNDCP_MAX_SEGMENT_NUMBER segments or not. If we have received more than
2178 * SNDCP_MAX_SEGMENT_NUMBER segments in a single NPDU, then we will discard
2179 * the stored segments and also the remaining segments of this NPDU, till
2180 * we receive that last segment of this NPDU.
2181 * This has been done in order to encounter the PARTITION problem which
2182 * we will face if we keep on storing the segments in SNDCP.
2183 */
2184 sndcp_data->cur_segment_number[nsapi] ++;
2185 if (sndcp_data-> cur_segment_number[nsapi] > SNDCP_MAX_SEGMENT_NUMBER)
2186 {
2187 TRACE_EVENT("Segment Number in Single NPDU exceeds max segment number");
2188
2189 /* Deleting the stored segments */
2190 sig_mg_cia_delete_npdus(nsapi);
2191
2192 /* Change the state to SDA_ACK_DISCARD */
2193 sndcp_set_nsapi_rec_state(nsapi, SDA_ACK_DISCARD);
2194 }
2195
2196 /*
2197 * Request next segment.
2198 */
2199 sda_get_data_if_nec(ll_data_ind->sapi);
2200 }
2201 /*
2202 * Update global current CIA_DECOMP_IND
2203 */
2204 sndcp_data->cia.cur_cia_decomp_ind[nsapi] = cur_cia_decomp_ind;
2205 /*
2206 * Free incoming prim.
2207 */
2208 if (ll_data_ind != NULL) {
2209 PFREE (ll_data_ind);
2210 ll_data_ind = NULL;
2211 }
2212 } /* cia_sig_sda_cia_cia_decomp_req_sim() */
2213
2214 #endif /* CF_FAST_EXEC */
2215
2216
2217 /*==== PUBLIC FUNCTIONS =====================================================*/
2218
2219 /*
2220 +------------------------------------------------------------------------------
2221 | Function : sig_mg_cia_reset_ind
2222 +------------------------------------------------------------------------------
2223 | Description : Handles the internal signal SIG_MG_CIA_RESET_IND
2224 |
2225 | Parameters :
2226 |
2227 +------------------------------------------------------------------------------
2228 */
2229 #ifndef CF_FAST_EXEC
2230
2231 GLOBAL void sig_mg_cia_reset_ind (void)
2232 {
2233 TRACE_ISIG( "sig_mg_cia_reset_ind" );
2234
2235 switch( GET_STATE(CIA) )
2236 {
2237 case CIA_DEFAULT:
2238 sndcp_reset_xid_block(&sndcp_data->cia.cur_xid_block);
2239 break;
2240 default:
2241 TRACE_ERROR( "SIG_MG_CIA_RESET_IND unexpected" );
2242 break;
2243 }
2244 } /* sig_mg_cia_reset_ind() */
2245
2246 #endif /* CF_FAST_EXEC */
2247
2248
2249 /*
2250 +------------------------------------------------------------------------------
2251 | Function : sig_su_cia_cia_comp_req
2252 +------------------------------------------------------------------------------
2253 | Description : Handles the internal signal SIG_SU_CIA_CIA_COMP_REQ
2254 | This function makes a decision whether we are using data
2255 | compression in uplink direction and calls the according
2256 | function.
2257 |
2258 | Parameters :
2259 |
2260 +------------------------------------------------------------------------------
2261 */
2262 /*#if defined(CF_FAST_EXEC) || defined(_SIMULATION_) || \
2263 defined(SNDCP_2to1) */
2264
2265 GLOBAL void sig_su_cia_cia_comp_req (T_SN_UNITDATA_REQ* sn_unitdata_req,
2266 USHORT npdu_number,
2267 UBYTE nsapi,
2268 UBYTE sapi
2269 )
2270 {
2271 U8 direction = 0;
2272 BOOL compressed = FALSE;
2273 UBYTE packet_type = TYPE_IP;
2274 TRACE_ISIG( "sig_su_cia_cia_comp_req" );
2275
2276 switch( GET_STATE(CIA) )
2277 {
2278 case CIA_DEFAULT:
2279 sndcp_is_nsapi_header_compressed(nsapi, &compressed);
2280 if (compressed) {
2281 #ifdef _SNDCP_DTI_2_
2282 cia_header_comp(&sn_unitdata_req->desc_list2,
2283 &sn_unitdata_req->desc_list2,
2284 &packet_type);
2285 #else /*_SNDCP_DTI_2_*/
2286 cia_header_comp(&sn_unitdata_req->desc_list,
2287 &sn_unitdata_req->desc_list,
2288 &packet_type);
2289 #endif /*_SNDCP_DTI_2_*/
2290 }
2291
2292 sndcp_is_nsapi_data_compressed(nsapi, &compressed);
2293 if (sndcp_data->cia.cur_xid_block.v42.is_set)
2294 {
2295 if (sndcp_data->cia.cur_xid_block.v42.p0_set)
2296 {
2297 direction = sndcp_data->cia.cur_xid_block.v42.p0;
2298 TRACE_EVENT_P1("dir: %d",direction);
2299 }
2300 }
2301 if (compressed && (direction & 0x01)) { /* datacompr. in uplink ? */
2302 #ifdef TI_PS_FF_V42BIS
2303
2304 cia_su_cci_comp_req(sn_unitdata_req,
2305 npdu_number,
2306 nsapi,
2307 sapi,
2308 packet_type);
2309
2310 #else /* !TI_PS_FF_V42BIS */
2311 TRACE_EVENT("INFO CIA: Data compression is not implemented yet!");
2312 MFREE_PRIM(sn_unitdata_req);
2313 sn_unitdata_req = NULL;
2314
2315 #endif /* TI_PS_FF_V42BIS */
2316 } else { /* if (compressed) */
2317 cia_su_cia_comp_req(sn_unitdata_req,
2318 npdu_number,
2319 nsapi,
2320 sapi,
2321 packet_type);
2322 }
2323 break;
2324 default:
2325 TRACE_ERROR( "SIG_SU_CIA_CIA_COMP_REQ unexpected" );
2326 #ifdef _SNDCP_DTI_2_
2327 MFREE_PRIM(sn_unitdata_req);
2328 #else /*_SNDCP_DTI_2_*/
2329 PFREE_DESC(sn_unitdata_req);
2330 #endif /*_SNDCP_DTI_2_*/
2331 break;
2332 }
2333 } /* sig_su_cia_cia_comp_req() */
2334
2335 /*#endif */ /* CF_FAST_EXEC || _SIMULATION_ || !REL99 || SNDCP_2to1 */
2336
2337 /*
2338 +------------------------------------------------------------------------------
2339 | Function : sig_sua_cia_cia_comp_req
2340 +------------------------------------------------------------------------------
2341 | Description : Handles the internal signal SIG_SUA_CIA_CIA_COMP_REQ
2342 |
2343 | Parameters :
2344 |
2345 +------------------------------------------------------------------------------
2346 */
2347 #ifndef CF_FAST_EXEC
2348
2349 GLOBAL void sig_sua_cia_cia_comp_req (T_SN_DATA_REQ* sn_data_req,
2350 UBYTE npdu_number,
2351 UBYTE nsapi,
2352 UBYTE sapi
2353 )
2354 {
2355 BOOL compressed = FALSE;
2356 UBYTE packet_type = TYPE_IP;
2357 /*
2358 * define desc_list for comp header. Is initialized later.
2359 */
2360 #ifdef _SNDCP_DTI_2_
2361 T_desc_list2 dest_desc_list;
2362 #else /*_SNDCP_DTI_2_*/
2363 T_desc_list dest_desc_list;
2364 #endif /*_SNDCP_DTI_2_*/
2365
2366 TRACE_ISIG( "sig_sua_cia_cia_comp_req" );
2367
2368 switch( GET_STATE(CIA) )
2369 {
2370 case CIA_DEFAULT:
2371 sndcp_is_nsapi_header_compressed(nsapi, &compressed);
2372 if (compressed) {
2373 #ifdef _SNDCP_DTI_2_
2374 cia_header_comp(&dest_desc_list,
2375 &sn_data_req->desc_list2,
2376 &packet_type);
2377 } else {
2378 dest_desc_list = sn_data_req->desc_list2;
2379 #else /*_SNDCP_DTI_2_*/
2380 cia_header_comp(&dest_desc_list,
2381 &sn_data_req->desc_list,
2382 &packet_type);
2383 } else {
2384 dest_desc_list = sn_data_req->desc_list;
2385 #endif /*_SNDCP_DTI_2_*/
2386 }
2387
2388 sndcp_is_nsapi_data_compressed(nsapi, &compressed);
2389 if (compressed) {
2390
2391 /*
2392 * The data compression routine shall be invoked here.
2393 */
2394 TRACE_EVENT("INFO CIA: Data compression is not implemented yet!");
2395 MFREE_PRIM(sn_data_req);
2396 sn_data_req = NULL;
2397
2398 } else { /* if (compressed) */
2399 cia_sua_cia_comp_req(dest_desc_list,
2400 npdu_number,
2401 nsapi,
2402 sapi,
2403 packet_type);
2404 }
2405 /*
2406 * free comp header
2407 */
2408 if (compressed && dest_desc_list.first != 0) {
2409 MFREE(dest_desc_list.first);
2410 dest_desc_list.first = 0;
2411 }
2412 break;
2413 default:
2414 TRACE_ERROR( "SIG_SUA_CIA_CIA_COMP_REQ unexpected" );
2415 #ifdef _SNDCP_DTI_2_
2416 MFREE_PRIM(sn_data_req);
2417 #else /*_SNDCP_DTI_2_*/
2418 PFREE_DESC(sn_data_req);
2419 #endif /*_SNDCP_DTI_2_*/
2420 break;
2421 }
2422 } /* sig_sua_cia_cia_comp_req() */
2423
2424 #endif /* CF_FAST_EXEC */
2425
2426
2427 /*
2428 +------------------------------------------------------------------------------
2429 | Function : sig_mg_cia_delete_npdus
2430 +------------------------------------------------------------------------------
2431 | Description : Handles the internal signal SIG_MG_CIA_DELETE_NPDUS
2432 |
2433 | Parameters : nsapi
2434 |
2435 +------------------------------------------------------------------------------
2436 */
2437 #ifndef CF_FAST_EXEC
2438
2439 GLOBAL void sig_mg_cia_delete_npdus (UBYTE nsapi)
2440 {
2441 TRACE_ISIG( "sig_mg_cia_delete_npdus" );
2442
2443 switch( GET_STATE(CIA) )
2444 {
2445 case CIA_DEFAULT:
2446 if (sndcp_data->cia.cur_cia_decomp_ind[nsapi] != NULL) {
2447 #ifdef SNDCP_TRACE_ALL
2448 sndcp_data->cia.cia_decomp_ind_number[nsapi] --;
2449 TRACE_EVENT_P1("number of cia_decomp_ind: % d",
2450 sndcp_data->cia.cia_decomp_ind_number[nsapi]);
2451 #endif /* SNDCP_TRACE_ALL */
2452 /*
2453 * Currently assembled pdu is for given nsapi.
2454 */
2455 MFREE_PRIM(sndcp_data->cia.cur_cia_decomp_ind[nsapi]);
2456 sndcp_data->cia.cur_cia_decomp_ind[nsapi] = NULL;
2457 }
2458 break;
2459 default:
2460 TRACE_ERROR( "SIG_MG_CIA_DELETE_XID unexpected" );
2461 break;
2462 }
2463 } /* SIG_MG_CIA_DELETE_NPDUS() */
2464
2465 #endif /* CF_FAST_EXEC */
2466
2467
2468 /*
2469 +------------------------------------------------------------------------------
2470 | Function : sig_mg_cia_new_xid
2471 +------------------------------------------------------------------------------
2472 | Description : Handles the internal signal SIG_MG_CIA_NEW_XID
2473 |
2474 | Parameters : new T_XID_BLOCK
2475 |
2476 +------------------------------------------------------------------------------
2477 */
2478 #ifndef CF_FAST_EXEC
2479
2480 GLOBAL void sig_mg_cia_new_xid (T_XID_BLOCK* new_xid)
2481 {
2482 #ifdef TI_PS_FF_V42BIS
2483 T_XID_BLOCK* old_xid;
2484 U8 p0 = SNDCP_V42_DEFAULT_DIRECTION;
2485 U16 p1 = SNDCP_V42_DEFAULT_P1;
2486 U8 p2 = SNDCP_V42_DEFAULT_P2;
2487
2488 old_xid = &(sndcp_data->cia.cur_xid_block);
2489 #endif
2490
2491 TRACE_ISIG( "sig_mg_cia_new_xid" );
2492
2493 switch( GET_STATE(CIA) )
2494 {
2495 case CIA_DEFAULT:
2496 if (new_xid->vj.is_set) {
2497 if (new_xid->vj.s0_m_1_set) {
2498 cia_compress_init((UBYTE)(new_xid->vj.s0_m_1));
2499 }
2500 }
2501 #ifdef TI_PS_FF_V42BIS
2502 if (new_xid->v42.is_set)
2503 {
2504 /* block is valid */
2505 if (new_xid->v42.p0_set)
2506 {
2507 p0 = new_xid->v42.p0;
2508 /* what have we to do, if p0 is not set? */
2509 }
2510 if (new_xid->v42.p1_set)
2511 {
2512 p1 = new_xid->v42.p1;
2513 /* what have we to do, if p1 is not set? */
2514 }
2515 if (new_xid->v42.p2_set)
2516 {
2517 p2 = new_xid->v42.p2;
2518 /* what have we to do, if p2 is not set? */
2519 }
2520
2521 if (new_xid->v42.nsapis_set && new_xid->v42.nsapis == 0)
2522 {
2523 /* no applicable NSAPI
2524 * turn off data compression in either direction
2525 */
2526 if (old_xid->v42.p0_set && old_xid->v42.p0 & 0x1) /* uplink */
2527 {
2528 TRACE_EVENT_P1("1 enc dico:%08x",sndcp_data->cia.enc);
2529 v42b_deinit(sndcp_data->cia.enc);
2530 MFREE(sndcp_data->cia.enc);
2531 TRACE_EVENT("uplink deinit");
2532 }
2533 if (old_xid->v42.p0_set && old_xid->v42.p0 & 0x2) /* downlink */
2534 {
2535 TRACE_EVENT_P1("1 dec dico:%08x",sndcp_data->cia.dec);
2536 v42b_deinit(sndcp_data->cia.dec);
2537 MFREE(sndcp_data->cia.dec);
2538 TRACE_EVENT("downlink deinit");
2539 }
2540 }
2541 else if (old_xid->v42.is_set)
2542 {
2543 /* currently we have a valid xid-block for data compression
2544 * we have to check the parameters
2545 */
2546
2547 /* we have to check the parameters */
2548 if (old_xid->v42.p0 != p0 ||
2549 old_xid->v42.p1 != p1 ||
2550 old_xid->v42.p2 != p2)
2551 {
2552 /* parameters have changed */
2553 if (old_xid->v42.p0_set && old_xid->v42.p0 & 0x1) /* uplink */
2554 {
2555 TRACE_EVENT_P1("2 enc dico:%08x",sndcp_data->cia.enc);
2556 v42b_deinit(sndcp_data->cia.enc);
2557 MFREE(sndcp_data->cia.enc);
2558 TRACE_EVENT("uplink deinit");
2559 }
2560 if (old_xid->v42.p0_set && old_xid->v42.p0 & 0x2) /* downlink */
2561 {
2562 TRACE_EVENT_P1("2 dec dico:%08x",sndcp_data->cia.dec);
2563 v42b_deinit(sndcp_data->cia.dec);
2564 MFREE(sndcp_data->cia.dec);
2565 TRACE_EVENT("uplink deinit");
2566 }
2567 /* we have to init with new parameters */
2568 if (p0 & 0x1)/* uplink */
2569 {
2570 TRACE_EVENT_P1("DICO_SIZE:%d",sizeof(T_V42B_DICO));
2571 MALLOC(sndcp_data->cia.enc, sizeof(T_V42B_DICO));
2572 TRACE_EVENT_P1("enc dico:%08x",sndcp_data->cia.enc);
2573 v42b_init(sndcp_data->cia.enc, p1, p2, 50, BANK_SIZE_512);
2574 TRACE_EVENT("uplink init");
2575 }
2576 if (p0 & 0x2)/* downlink */
2577 {
2578 TRACE_EVENT_P1("DICO_SIZE:%d",sizeof(T_V42B_DICO));
2579 MALLOC(sndcp_data->cia.dec, sizeof(T_V42B_DICO));
2580 v42b_init(sndcp_data->cia.dec, p1, p2, 0, BANK_SIZE_512);
2581 TRACE_EVENT_P1("dec dico:%08x",sndcp_data->cia.dec);
2582 TRACE_EVENT("downlink init");
2583 }
2584 }
2585 }
2586 else
2587 {
2588 /* currently we have no valid xid-block for data comprssion */
2589 if (p0 & 0x1)/* uplink */
2590 {
2591 TRACE_EVENT_P1("DICO_SIZE:%d",sizeof(T_V42B_DICO));
2592 MALLOC(sndcp_data->cia.enc, sizeof(T_V42B_DICO));
2593 TRACE_EVENT_P1("enc dico:%08x",sndcp_data->cia.enc);
2594 v42b_init(sndcp_data->cia.enc, p1, p2, 50, BANK_SIZE_512);
2595 TRACE_EVENT("uplink init");
2596 }
2597 if (p0 & 0x2)/* downlink */
2598 {
2599 TRACE_EVENT_P1("DICO_SIZE:%d",sizeof(T_V42B_DICO));
2600 MALLOC(sndcp_data->cia.dec, sizeof(T_V42B_DICO));
2601 TRACE_EVENT_P1("dec dico:%08x",sndcp_data->cia.dec);
2602 v42b_init(sndcp_data->cia.dec, p1, p2, 0, BANK_SIZE_512);
2603 TRACE_EVENT("downlink init");
2604 }
2605 }
2606 }
2607 else
2608 {
2609 if (old_xid->v42.is_set && old_xid->v42.nsapis_set && old_xid->v42.nsapis != 0)
2610 {
2611 /* we have no XID with V42 set */
2612 if (old_xid->v42.p0_set && old_xid->v42.p0 & 0x1) /* uplink */
2613 {
2614 TRACE_EVENT_P1("3 enc dico:%08x",sndcp_data->cia.enc);
2615 v42b_deinit(sndcp_data->cia.enc);
2616 MFREE(sndcp_data->cia.enc);
2617 TRACE_EVENT("uplink deinit");
2618 }
2619 if (old_xid->v42.p0_set && old_xid->v42.p0 & 0x2) /* downlink */
2620 {
2621 TRACE_EVENT_P1("3 dec dico:%08x",sndcp_data->cia.dec);
2622 v42b_deinit(sndcp_data->cia.dec);
2623 MFREE(sndcp_data->cia.dec);
2624 TRACE_EVENT("downlink deinit");
2625 }
2626 }
2627 }
2628 #endif /* TI_PS_FF_V42BIS */
2629 sndcp_data->cia.cur_xid_block = *new_xid;
2630 break;
2631 default:
2632 TRACE_ERROR( "SIG_MG_CIA_NEW_XID unexpected" );
2633 break;
2634 }
2635 } /* SIG_MG_CIA_NEW_XID() */
2636
2637 #endif /* CF_FAST_EXEC */
2638
2639 /*
2640 +------------------------------------------------------------------------------
2641 | Function : sig_sd_cia_cia_decomp_req
2642 +------------------------------------------------------------------------------
2643 | Description : Handles the internal signal SIG_SD_CIA_TRANSFER_REQ
2644 | This function mekes a decision whether we are using data
2645 | compression in downlink direction and calls the according
2646 | function.
2647 |
2648 | Parameters :
2649 |
2650 +------------------------------------------------------------------------------
2651 */
2652 /*#if defined(CF_FAST_EXEC) || defined(_SIMULATION_) || \
2653 defined(SNDCP_2to1) */
2654
2655 GLOBAL void sig_sd_cia_cia_decomp_req (T_LL_UNITDATA_IND* ll_unitdata_ind)/*UBYTE dcomp,
2656 T_pdu_ref pdu_ref,
2657 USHORT cur_seg_pos,
2658 T_LL_UNITDATA_IND* ll_unitdata_ind
2659 )*/
2660 {
2661 #ifdef TI_PS_FF_V42BIS
2662 U8 direction = 0;
2663 U8 nsapi;
2664 #endif /* TI_PS_FF_V42BIS */
2665 TRACE_ISIG( "sig_sd_cia_cia_decomp_req" );
2666 #ifdef TI_PS_FF_V42BIS
2667 nsapi = (ll_unitdata_ind->sdu.buf[(ll_unitdata_ind->sdu.o_buf / 8)]) & 0xf;
2668 #endif /* TI_PS_FF_V42BIS */
2669 switch( GET_STATE(CIA) )
2670 {
2671 case CIA_DEFAULT:
2672 #ifdef TI_PS_FF_V42BIS
2673 if (sndcp_data->cia.cur_xid_block.v42.is_set)
2674 {
2675 if (sndcp_data->cia.cur_xid_block.v42.p0_set)
2676 {
2677 direction = sndcp_data->cia.cur_xid_block.v42.p0;
2678 TRACE_EVENT_P1("dir: %d",direction);
2679 }
2680 }
2681 /*
2682 * Is dcomp in sdu equal to dcomp in cur_xid_block and downlink?
2683 */
2684 TRACE_EVENT_P1("our dcomp value: %d", sndcp_data->cia.cur_xid_block.v42.dcomp);
2685 TRACE_EVENT_P1("receipt dcomp value: %d", sndcp_data->cur_dcomp[nsapi]);
2686 if (sndcp_data->cur_dcomp[nsapi] == sndcp_data->cia.cur_xid_block.v42.dcomp && (direction & 0x2))
2687 {
2688 /*
2689 * Compression used
2690 */
2691 cia_sd_cci_decomp_req(/*pdu_ref, cur_seg_pos, */ll_unitdata_ind);
2692
2693 } else {
2694 /*
2695 * No compression used, request will not be sent to CCI, but handled
2696 * in cia service.
2697 */
2698 cia_sd_cia_decomp_req (/*pdu_ref, cur_seg_pos, */ll_unitdata_ind);
2699 }
2700 #else /* ! TI_PS_FF_V42BIS */
2701 cia_sd_cia_decomp_req (/*pdu_ref, cur_seg_pos, */ll_unitdata_ind);
2702 #endif /* TI_PS_FF_V42BIS */
2703
2704 break;
2705 default:
2706 TRACE_ERROR( "SIG_SD_CIA_TRANSFER_REQ unexpected" );
2707 break;
2708 }
2709 } /* sig_sd_cia_cia_decomp_req() */
2710 /*#endif */