FreeCalypso > hg > fc-magnetite
comparison src/g23m-gprs/sndcp/sndcp_sdf.c @ 183:219afcfc6250
src/g23m-gprs: initial import from TCS3.2/LoCosto
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 13 Oct 2016 04:24:13 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
182:f02d0a0e1849 | 183:219afcfc6250 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GPRS (8441) | |
4 | Modul : sndcp_sdf.c | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : This modul is part of the entity SNDCP and implements all | |
18 | procedures and functions as described in the | |
19 | SDL-documentation (SD-statemachine) | |
20 +----------------------------------------------------------------------------- | |
21 */ | |
22 | |
23 | |
24 #define ENTITY_SNDCP | |
25 | |
26 /*==== INCLUDES =============================================================*/ | |
27 | |
28 #include "typedefs.h" /* to get Condat data types */ | |
29 #include "vsi.h" /* to get a lot of macros */ | |
30 #include "macdef.h" | |
31 #include "prim.h" /* to get the definitions of used SAP and directions */ | |
32 | |
33 #include "dti.h" | |
34 | |
35 #include "sndcp.h" /* to get the global entity definitions */ | |
36 #include "sndcp_f.h" /* to get the functions to access the global arrays*/ | |
37 | |
38 #include "sndcp_cias.h" /* to get the signals to service cia */ | |
39 #include "sndcp_sdf.h" /* to get functions in sd */ | |
40 #include "sndcp_pds.h" /* to get the sigbnals to service pd.*/ | |
41 | |
42 | |
43 | |
44 | |
45 /*==== CONST ================================================================*/ | |
46 | |
47 /*==== LOCAL VARS ===========================================================*/ | |
48 | |
49 /*==== PRIVATE FUNCTIONS ====================================================*/ | |
50 | |
51 LOCAL UBYTE sd_get_dcomp (T_LL_UNITDATA_IND* ll_unitdata_ind); | |
52 | |
53 /* | |
54 +------------------------------------------------------------------------------ | |
55 | Function : sd_get_dcomp | |
56 +------------------------------------------------------------------------------ | |
57 | Description : E X T R A convenience function, not in SDL. | |
58 | Returns the DCOMP value in the sdu of the given primitive. | |
59 | | |
60 | Parameters : ll_unitdata_ind T_LL_UNITDATA_IND* | |
61 | | |
62 +------------------------------------------------------------------------------ | |
63 */ | |
64 LOCAL UBYTE sd_get_dcomp (T_LL_UNITDATA_IND* ll_unitdata_ind) | |
65 { | |
66 return (ll_unitdata_ind->sdu.buf[ll_unitdata_ind->sdu.o_buf / 8 + 1] & 0xf0) >> 4 ; | |
67 | |
68 } /* sd_get_dcomp() */ | |
69 | |
70 /* | |
71 +------------------------------------------------------------------------------ | |
72 | Function : sd_get_npdu_num | |
73 +------------------------------------------------------------------------------ | |
74 | Description : E X T R A convenience function, not in SDL. | |
75 | Gets the N-PDU number from the segment header. | |
76 | | |
77 | Parameters : ll_unitdata_ind T_LL_UNITDATA_IND*, npdu_num* | |
78 | | |
79 +------------------------------------------------------------------------------ | |
80 */ | |
81 LOCAL void sd_get_npdu_num (T_LL_UNITDATA_IND* ll_unitdata_ind, USHORT* npdu_num) | |
82 { | |
83 USHORT msn_off = 1; | |
84 USHORT lsb_off = 2; | |
85 UBYTE msn = 0; | |
86 UBYTE lsb = 0; | |
87 | |
88 if (sd_f_bit(ll_unitdata_ind)) { | |
89 msn_off = 2; | |
90 lsb_off = 3; | |
91 } | |
92 | |
93 msn = | |
94 ll_unitdata_ind->sdu.buf[(ll_unitdata_ind->sdu.o_buf / 8) + msn_off]; | |
95 lsb = | |
96 ll_unitdata_ind->sdu.buf[(ll_unitdata_ind->sdu.o_buf / 8) + lsb_off]; | |
97 | |
98 *npdu_num = ((msn & 0xf) << 8) + lsb; | |
99 } /* sd_get_npdu_num() */ | |
100 | |
101 /* | |
102 +------------------------------------------------------------------------------ | |
103 | Function : sd_get_nsapi | |
104 +------------------------------------------------------------------------------ | |
105 | Description : E X T R A convenience function, not in SDL. | |
106 | Gets the NSAPI from the segment header. | |
107 | | |
108 | Parameters : ll_unitdata_ind T_LL_UNITDATA_IND*, nsapi* | |
109 | | |
110 +------------------------------------------------------------------------------ | |
111 */ | |
112 GLOBAL void sd_get_nsapi (T_LL_UNITDATA_IND* ll_unitdata_ind, UBYTE* nsapi) | |
113 { | |
114 /* | |
115 * The nsapi number in the sn-pdu header is the least sig half first octet. | |
116 */ | |
117 UBYTE first = ll_unitdata_ind->sdu.buf[(ll_unitdata_ind->sdu.o_buf / 8)]; | |
118 | |
119 *nsapi = first & 0xf; | |
120 } /* sd_get_nsapi() */ | |
121 | |
122 | |
123 /*==== PUBLIC FUNCTIONS =====================================================*/ | |
124 | |
125 | |
126 /* | |
127 +------------------------------------------------------------------------------ | |
128 | Function : sd_is_seg_valid | |
129 +------------------------------------------------------------------------------ | |
130 | Description : According to GSM 4.65, 6.9 unacknowledged segments for NSAPIs | |
131 | in acknowledged mode and vice versa and also segments for not | |
132 | activated NSAPIs shall be discarded without further error | |
133 | notification. | |
134 | | |
135 | Parameters : nsapi, sapi, BOOL ack, BOOL* valid | |
136 | | |
137 +------------------------------------------------------------------------------ | |
138 */ | |
139 GLOBAL void sd_is_seg_valid(T_LL_UNITDATA_IND* ll_unitdata_ind, | |
140 BOOL* valid) | |
141 { | |
142 UBYTE nsapi = 0; | |
143 UBYTE sapi = 0; | |
144 /* | |
145 * Is the affected NSAPI using acknowledged LLC mode? | |
146 */ | |
147 BOOL ack = TRUE; | |
148 /* | |
149 * Is the NSAPI used at all? | |
150 */ | |
151 BOOL used = FALSE; | |
152 | |
153 TRACE_FUNCTION( "sd_is_seg_valid" ); | |
154 | |
155 *valid = TRUE; | |
156 /* | |
157 * Get the affected nsapi from primitive. | |
158 */ | |
159 sd_get_nsapi(ll_unitdata_ind, &nsapi); | |
160 /* | |
161 * If the NSAPI is not used, leave. | |
162 */ | |
163 sndcp_is_nsapi_used(nsapi, &used); | |
164 if (!used) { | |
165 *valid = FALSE; | |
166 return; | |
167 } | |
168 /* | |
169 * To which sapi is the given nsapi mapped? | |
170 */ | |
171 sndcp_get_nsapi_sapi(nsapi, &sapi); | |
172 /* | |
173 * If the sapi in the primitive is the wrong one, leave. | |
174 */ | |
175 if (sapi != ll_unitdata_ind->sapi) { | |
176 *valid = FALSE; | |
177 return; | |
178 } | |
179 /* | |
180 * If the nsapi normally uses acknowledged LLC mode, leave. | |
181 * Note: if 'ack' is true the NSAPI is in acknowledged | |
182 * mode normally and the 'sd' service is the wrong one | |
183 * anyway, but it was chosen because of the unack primitive. | |
184 */ | |
185 sndcp_get_nsapi_ack(nsapi, &ack); | |
186 if (ack) { | |
187 *valid = FALSE; | |
188 return; | |
189 } | |
190 | |
191 } /* sd_is_seg_valid() */ | |
192 | |
193 | |
194 | |
195 /* | |
196 +------------------------------------------------------------------------------ | |
197 | Function : sd_delete_cur_sn_unitdata_ind | |
198 +------------------------------------------------------------------------------ | |
199 | Description : The descriptor list in service variable cur_sn_unitdata_ind is | |
200 | deleted recursively, then the primitive is freed with PFREE | |
201 | macro. | |
202 | | |
203 | Parameters : | |
204 | | |
205 +------------------------------------------------------------------------------ | |
206 */ | |
207 GLOBAL void sd_delete_cur_sn_unitdata_ind (U8 nsapi) | |
208 { | |
209 TRACE_FUNCTION( "sd_delete_cur_sn_unitdata_ind" ); | |
210 | |
211 if (sndcp_data->sd->cur_sn_unitdata_ind[nsapi] != NULL) { | |
212 #ifdef _SNDCP_DTI_2_ | |
213 MFREE_PRIM(sndcp_data->sd->cur_sn_unitdata_ind[nsapi]); | |
214 #else /*_SNDCP_DTI_2_*/ | |
215 PFREE_DESC(sndcp_data->sd->cur_sn_unitdata_ind[nsapi]); | |
216 #endif /*_SNDCP_DTI_2_*/ | |
217 sndcp_data->sd->cur_sn_unitdata_ind[nsapi] = NULL; | |
218 } | |
219 } /* sd_delete_cur_sn_unitdata_ind(void) */ | |
220 | |
221 | |
222 /* | |
223 +------------------------------------------------------------------------------ | |
224 | Function : sd_f_bit | |
225 +------------------------------------------------------------------------------ | |
226 | Description : E X T R A convenience function, not in SDL. | |
227 | Returns TRUE if the f bit in the given sdu is set to 1, else | |
228 | FALSE. | |
229 | | |
230 | Parameters : ll_unitdata_ind T_LL_UNITDATA_IND* | |
231 | | |
232 +------------------------------------------------------------------------------ | |
233 */ | |
234 GLOBAL BOOL sd_f_bit (T_LL_UNITDATA_IND* ll_unitdata_ind) | |
235 { | |
236 UBYTE f_b = ll_unitdata_ind->sdu.buf[ll_unitdata_ind->sdu.o_buf / 8] & 0x40; | |
237 | |
238 TRACE_FUNCTION( "sd_f_bit" ); | |
239 | |
240 return (f_b > 0); | |
241 | |
242 } /* sd_f_bit() */ | |
243 | |
244 | |
245 | |
246 | |
247 /* | |
248 +------------------------------------------------------------------------------ | |
249 | Function : sd_get_pcomp | |
250 +------------------------------------------------------------------------------ | |
251 | Description : E X T R A convenience function, not in SDL. | |
252 | Returns the PCOMP value in the sdu of the given primitive. | |
253 | | |
254 | Parameters : ll_unitdata_ind T_LL_UNITDATA_IND* | |
255 | | |
256 +------------------------------------------------------------------------------ | |
257 */ | |
258 GLOBAL UBYTE sd_get_pcomp (T_LL_UNITDATA_IND* ll_unitdata_ind) | |
259 { | |
260 return ll_unitdata_ind->sdu.buf[ll_unitdata_ind->sdu.o_buf / 8 + 1] & 0xf; | |
261 | |
262 } /* sd_get_pcomp() */ | |
263 | |
264 | |
265 | |
266 /* | |
267 +------------------------------------------------------------------------------ | |
268 | Function : sd_get_unitdata_if_nec | |
269 +------------------------------------------------------------------------------ | |
270 | Description : This function sends a SIG_SD_PD_GETUNITDATA_REQ to the affected | |
271 | SAPI | |
272 | if necessary (service variable llc_may_send was set to FALSE) | |
273 | and sets llc_may_send to TRUE or does nothing (service | |
274 | variable llc_may_send already was set to TRUE). | |
275 | | |
276 | Parameters : FPAR IN sapi UBYTE the number of the affected SAPI | |
277 | | |
278 +------------------------------------------------------------------------------ | |
279 */ | |
280 GLOBAL void sd_get_unitdata_if_nec (UBYTE sapi) | |
281 { | |
282 UBYTE sapi_index = 0; | |
283 | |
284 TRACE_FUNCTION( "sd_get_unitdata_if_nec" ); | |
285 | |
286 #ifdef SNDCP_TRACE_ALL | |
287 if (sndcp_data->sd->llc_may_send) { | |
288 TRACE_EVENT("llc_may_send TRUE"); | |
289 } else { | |
290 TRACE_EVENT("llc_may_send FALSE"); | |
291 } | |
292 #endif | |
293 | |
294 /* | |
295 * set service instance according to sapi in signal | |
296 */ | |
297 sndcp_get_sapi_index(sapi, &sapi_index); | |
298 sndcp_data->sd = & sndcp_data->sd_base[sapi_index]; | |
299 if (sndcp_data->sd->llc_may_send == FALSE) { | |
300 sig_sd_pd_getunitdata_req(sapi); | |
301 /* | |
302 * Mark this LLC SAPI as pending. | |
303 */ | |
304 sndcp_data->sd->llc_may_send = TRUE; | |
305 } | |
306 | |
307 } /* sd_get_unitdata_if_nec() */ | |
308 | |
309 | |
310 | |
311 /* | |
312 +------------------------------------------------------------------------------ | |
313 | Function : sd_init | |
314 +------------------------------------------------------------------------------ | |
315 | Description : Initialize the entity instance. | |
316 | | |
317 | Parameters : | |
318 | | |
319 +------------------------------------------------------------------------------ | |
320 */ | |
321 GLOBAL void sd_init (void) | |
322 { | |
323 TRACE_FUNCTION( "sd_init" ); | |
324 | |
325 sndcp_data->sd = & sndcp_data->sd_base[0]; | |
326 INIT_STATE(SD_0, SD_DEFAULT); | |
327 #ifdef SNDCP_2to1 | |
328 sndcp_data->sd->sapi = PS_SAPI_3; | |
329 #else | |
330 sndcp_data->sd->sapi = LL_SAPI_3; | |
331 #endif /*SNDCP_2to1*/ | |
332 sndcp_data->sd = & sndcp_data->sd_base[1]; | |
333 INIT_STATE(SD_1, SD_DEFAULT); | |
334 #ifdef SNDCP_2to1 | |
335 sndcp_data->sd->sapi = PS_SAPI_5; | |
336 #else | |
337 sndcp_data->sd->sapi = LL_SAPI_5; | |
338 #endif /*SNDCP_2to1*/ | |
339 | |
340 sndcp_data->sd = & sndcp_data->sd_base[2]; | |
341 INIT_STATE(SD_2, SD_DEFAULT); | |
342 #ifdef SNDCP_2to1 | |
343 sndcp_data->sd->sapi = PS_SAPI_9; | |
344 #else | |
345 sndcp_data->sd->sapi = LL_SAPI_9; | |
346 #endif /*SNDCP_2to1*/ | |
347 | |
348 sndcp_data->sd = & sndcp_data->sd_base[3]; | |
349 INIT_STATE(SD_3, SD_DEFAULT); | |
350 #ifdef SNDCP_2to1 | |
351 sndcp_data->sd->sapi = PS_SAPI_11; | |
352 #else | |
353 sndcp_data->sd->sapi = LL_SAPI_11; | |
354 #endif /*SNDCP_2to1*/ | |
355 | |
356 { | |
357 UBYTE sapi_index = 0; | |
358 | |
359 for (sapi_index = 0; sapi_index < SNDCP_NUMBER_OF_SAPIS; sapi_index++) { | |
360 UBYTE nsapi = 0; | |
361 | |
362 sndcp_data->sd = & sndcp_data->sd_base[sapi_index]; | |
363 for (nsapi = 0; nsapi < SNDCP_NUMBER_OF_NSAPIS; nsapi++) { | |
364 sd_set_nsapi_rec(nsapi, FALSE); | |
365 sndcp_set_nsapi_rec_state(nsapi, SD_UNACK_DISCARD); | |
366 sndcp_data->sd->cur_sn_unitdata_ind[nsapi] = NULL; | |
367 } | |
368 sndcp_data->sd->llc_may_send = FALSE; | |
369 } | |
370 } | |
371 | |
372 | |
373 } /* sd_init() */ | |
374 | |
375 /* | |
376 +------------------------------------------------------------------------------ | |
377 | Function : sd_is_nsapi_rec | |
378 +------------------------------------------------------------------------------ | |
379 | Description : Returns TRUE if the given nsapi is receptive, else | |
380 | FALSE. | |
381 | | |
382 | Parameters : nsapi, BOOL* b | |
383 | | |
384 +------------------------------------------------------------------------------ | |
385 */ | |
386 GLOBAL void sd_is_nsapi_rec (UBYTE nsapi, BOOL* b) | |
387 { | |
388 *b = sndcp_data->sd->nsapi_rec_ra[nsapi]; | |
389 } /* sd_is_nsapi_rec() */ | |
390 | |
391 | |
392 /* | |
393 +------------------------------------------------------------------------------ | |
394 | Function : sd_m_bit | |
395 +------------------------------------------------------------------------------ | |
396 | Description : E X T R A convenience function, not in SDL. | |
397 | Returns TRUE if the m bit in the given sdu is set to 1, else | |
398 | FALSE. | |
399 | | |
400 | Parameters : ll_unitdata_ind T_LL_UNITDATA_IND* | |
401 | | |
402 +------------------------------------------------------------------------------ | |
403 */ | |
404 GLOBAL BOOL sd_m_bit (T_LL_UNITDATA_IND* ll_unitdata_ind) | |
405 { | |
406 UBYTE m_b; | |
407 | |
408 TRACE_FUNCTION( "sd_m_bit" ); | |
409 | |
410 m_b = ll_unitdata_ind->sdu.buf[ll_unitdata_ind->sdu.o_buf / 8] & 0x10; | |
411 return (m_b > 0); | |
412 | |
413 } /* sd_m_bit() */ | |
414 | |
415 | |
416 | |
417 /* | |
418 +------------------------------------------------------------------------------ | |
419 | Function : sd_set_nsapi_rec | |
420 +------------------------------------------------------------------------------ | |
421 | Description : Sets the given nsapi_rec_ra element to the given BOOL. | |
422 | | |
423 | Parameters : nsapi, BOOL b | |
424 | | |
425 +------------------------------------------------------------------------------ | |
426 */ | |
427 GLOBAL void sd_set_nsapi_rec (UBYTE nsapi, BOOL b) | |
428 { | |
429 sndcp_data->sd->nsapi_rec_ra[nsapi] = b; | |
430 } /* sd_set_nsapi_rec */ | |
431 | |
432 | |
433 /* | |
434 +------------------------------------------------------------------------------ | |
435 | Function : sd_un_d_f0_m0 | |
436 +------------------------------------------------------------------------------ | |
437 | Description : E X T R A convenience function, not in SDL. | |
438 | Represents the label UN_D_F0_M0 in SDL. | |
439 | | |
440 | Parameters : ll_unitdata_ind T_LL_UNITDATA_IND* | |
441 | | |
442 +------------------------------------------------------------------------------ | |
443 */ | |
444 GLOBAL void sd_un_d_f0_m0 (T_LL_UNITDATA_IND* ll_unitdata_ind) | |
445 { | |
446 UBYTE nsapi = 0; | |
447 sd_get_unitdata_if_nec(ll_unitdata_ind->sapi); | |
448 PFREE(ll_unitdata_ind); | |
449 | |
450 sd_get_nsapi(ll_unitdata_ind, &nsapi); | |
451 sndcp_set_nsapi_rec_state(nsapi, SD_UNACK_RECEIVE_FIRST_SEGMENT); | |
452 } /* sd_un_d_f0_m0() */ | |
453 | |
454 /* | |
455 +------------------------------------------------------------------------------ | |
456 | Function : sd_un_d_f0_m1 | |
457 +------------------------------------------------------------------------------ | |
458 | Description : E X T R A convenience function, not in SDL. | |
459 | Represents the label UN_D_F0_M1 in SDL. | |
460 | | |
461 | Parameters : ll_unitdata_ind T_LL_UNITDATA_IND* | |
462 | | |
463 +------------------------------------------------------------------------------ | |
464 */ | |
465 GLOBAL void sd_un_d_f0_m1 (T_LL_UNITDATA_IND* ll_unitdata_ind) | |
466 { | |
467 if (ll_unitdata_ind != NULL) { | |
468 sd_get_unitdata_if_nec(ll_unitdata_ind->sapi); | |
469 PFREE(ll_unitdata_ind); | |
470 } | |
471 } /* sd_un_d_f0_m1() */ | |
472 | |
473 /* | |
474 +------------------------------------------------------------------------------ | |
475 | Function : sd_un_d_f1_m0 | |
476 +------------------------------------------------------------------------------ | |
477 | Description : E X T R A convenience function, not in SDL. | |
478 | Represents the label UN_D_F1_M0 in SDL. | |
479 | | |
480 | Parameters : ll_unitdata_ind T_LL_UNITDATA_IND* | |
481 | | |
482 +------------------------------------------------------------------------------ | |
483 */ | |
484 GLOBAL void sd_un_d_f1_m0 (T_LL_UNITDATA_IND* ll_unitdata_ind) | |
485 { | |
486 UBYTE nsapi = 0; | |
487 | |
488 sd_get_nsapi(ll_unitdata_ind, &nsapi); | |
489 | |
490 if (ll_unitdata_ind != NULL) { | |
491 sd_get_unitdata_if_nec(ll_unitdata_ind->sapi); | |
492 PFREE(ll_unitdata_ind); | |
493 } | |
494 | |
495 sndcp_set_nsapi_rec_state(nsapi, SD_UNACK_RECEIVE_FIRST_SEGMENT); | |
496 | |
497 } /* sd_un_d_f1_m0() */ | |
498 | |
499 /* | |
500 +------------------------------------------------------------------------------ | |
501 | Function : sd_un_d_f1_m1 | |
502 +------------------------------------------------------------------------------ | |
503 | Description : E X T R A convenience function, not in SDL. | |
504 | Represents the label UN_D_F1_M1 in SDL. | |
505 | | |
506 | Parameters : ll_unitdata_ind T_LL_UNITDATA_IND* | |
507 | | |
508 +------------------------------------------------------------------------------ | |
509 */ | |
510 GLOBAL void sd_un_d_f1_m1 (T_LL_UNITDATA_IND* ll_unitdata_ind) | |
511 { | |
512 if (ll_unitdata_ind != NULL) { | |
513 sd_get_unitdata_if_nec(ll_unitdata_ind->sapi); | |
514 PFREE(ll_unitdata_ind); | |
515 } | |
516 } /* sd_un_d_f1_m1() */ | |
517 | |
518 | |
519 | |
520 /* | |
521 +------------------------------------------------------------------------------ | |
522 | Function : sd_un_f_f0_m0 | |
523 +------------------------------------------------------------------------------ | |
524 | Description : E X T R A convenience function, not in SDL. | |
525 | Represents the label UN_F_F0_M0 in SDL. | |
526 | | |
527 | Parameters : ll_unitdata_ind T_LL_UNITDATA_IND* | |
528 | | |
529 +------------------------------------------------------------------------------ | |
530 */ | |
531 GLOBAL void sd_un_f_f0_m0 (T_LL_UNITDATA_IND* ll_unitdata_ind) | |
532 { | |
533 if (ll_unitdata_ind != NULL) { | |
534 sd_get_unitdata_if_nec(ll_unitdata_ind->sapi); | |
535 PFREE(ll_unitdata_ind); | |
536 } | |
537 } /* sd_un_f_f0_m0() */ | |
538 | |
539 /* | |
540 +------------------------------------------------------------------------------ | |
541 | Function : sd_un_f_f0_m1 | |
542 +------------------------------------------------------------------------------ | |
543 | Description : E X T R A convenience function, not in SDL. | |
544 | Represents the label UN_F_F0_M1 in SDL. | |
545 | | |
546 | Parameters : ll_unitdata_ind T_LL_UNITDATA_IND* | |
547 | | |
548 +------------------------------------------------------------------------------ | |
549 */ | |
550 GLOBAL void sd_un_f_f0_m1 (T_LL_UNITDATA_IND* ll_unitdata_ind) | |
551 { | |
552 UBYTE nsapi = 0; | |
553 | |
554 sd_get_nsapi(ll_unitdata_ind, &nsapi); | |
555 | |
556 if (ll_unitdata_ind != NULL) { | |
557 sd_get_unitdata_if_nec(ll_unitdata_ind->sapi); | |
558 PFREE(ll_unitdata_ind); | |
559 } | |
560 | |
561 sndcp_set_nsapi_rec_state(nsapi, SD_UNACK_DISCARD); | |
562 | |
563 } /* sd_un_f_f0_m1() */ | |
564 | |
565 | |
566 | |
567 /* | |
568 +------------------------------------------------------------------------------ | |
569 | Function : sd_un_f_f1_m0 | |
570 +------------------------------------------------------------------------------ | |
571 | Description : E X T R A convenience function, not in SDL. | |
572 | Represents the label UN_F_F1_M0 in SDL. | |
573 | | |
574 | Parameters : ll_unitdata_ind T_LL_UNITDATA_IND* | |
575 | | |
576 +------------------------------------------------------------------------------ | |
577 */ | |
578 GLOBAL void sd_un_f_f1_m0 (T_LL_UNITDATA_IND* ll_unitdata_ind) | |
579 { | |
580 sndcp_set_unack_transfer_params(ll_unitdata_ind); | |
581 sig_sd_cia_cia_decomp_req(ll_unitdata_ind); | |
582 } /* sd_un_f_f1_m0() */ | |
583 | |
584 /* | |
585 +------------------------------------------------------------------------------ | |
586 | Function : sd_un_f_f1_m1 | |
587 +------------------------------------------------------------------------------ | |
588 | Description : E X T R A convenience function, not in SDL. | |
589 | Represents the label UN_F_F1_M1 in SDL. | |
590 | | |
591 | Parameters : ll_unitdata_ind T_LL_UNITDATA_IND* | |
592 | | |
593 +------------------------------------------------------------------------------ | |
594 */ | |
595 GLOBAL void sd_un_f_f1_m1 (T_LL_UNITDATA_IND* ll_unitdata_ind) | |
596 { | |
597 UBYTE nsapi = 0; | |
598 sndcp_set_unack_transfer_params(ll_unitdata_ind); | |
599 sig_sd_cia_cia_decomp_req(ll_unitdata_ind); | |
600 | |
601 sd_get_nsapi(ll_unitdata_ind, &nsapi); | |
602 sndcp_set_nsapi_rec_state(nsapi, SD_UNACK_RECEIVE_SUBSEQUENT_SEGMENT); | |
603 | |
604 } /* sd_un_f_f1_m1() */ | |
605 | |
606 | |
607 /* | |
608 +------------------------------------------------------------------------------ | |
609 | Function : sd_un_s_f0_m0 | |
610 +------------------------------------------------------------------------------ | |
611 | Description : E X T R A convenience function, not in SDL. | |
612 | Represents the label UN_S_F0_M0 in SDL. | |
613 | | |
614 | Parameters : ll_unitdata_ind T_LL_UNITDATA_IND* | |
615 | | |
616 +------------------------------------------------------------------------------ | |
617 */ | |
618 GLOBAL void sd_un_s_f0_m0 (T_LL_UNITDATA_IND* ll_unitdata_ind) | |
619 { | |
620 | |
621 USHORT npdu_num = 0; | |
622 UBYTE nsapi = 0; | |
623 | |
624 /* | |
625 * Does the received segment have the current npdu number? | |
626 */ | |
627 sd_get_npdu_num(ll_unitdata_ind, &npdu_num); | |
628 sd_get_nsapi(ll_unitdata_ind, &nsapi); | |
629 sndcp_data->cur_seg_pos[nsapi] = SEG_POS_LAST; | |
630 sndcp_set_nsapi_rec_state(nsapi, SD_UNACK_RECEIVE_FIRST_SEGMENT); | |
631 if (npdu_num == | |
632 sndcp_data->cur_pdu_ref[nsapi].ref_npdu_num) { | |
633 sig_sd_cia_cia_decomp_req(ll_unitdata_ind); | |
634 } else { | |
635 sd_delete_cur_sn_unitdata_ind(nsapi); | |
636 if (ll_unitdata_ind != NULL) { | |
637 sd_get_unitdata_if_nec(ll_unitdata_ind->sapi); | |
638 PFREE(ll_unitdata_ind); | |
639 } | |
640 } | |
641 | |
642 } /* sd_un_s_f0_m0() */ | |
643 | |
644 | |
645 /* | |
646 +------------------------------------------------------------------------------ | |
647 | Function : sd_un_s_f0_m1 | |
648 +------------------------------------------------------------------------------ | |
649 | Description : E X T R A convenience function, not in SDL. | |
650 | Represents the label UN_S_F0_M1 in SDL. | |
651 | | |
652 | Parameters : ll_unitdata_ind T_LL_UNITDATA_IND* | |
653 | | |
654 +------------------------------------------------------------------------------ | |
655 */ | |
656 GLOBAL void sd_un_s_f0_m1 (T_LL_UNITDATA_IND* ll_unitdata_ind) | |
657 { | |
658 USHORT npdu_num = 0; | |
659 UBYTE nsapi = 0; | |
660 | |
661 /* | |
662 * Does the received segment have the current npdu number? | |
663 */ | |
664 sd_get_npdu_num(ll_unitdata_ind, &npdu_num); | |
665 sd_get_nsapi(ll_unitdata_ind, &nsapi); | |
666 if (npdu_num == | |
667 sndcp_data->cur_pdu_ref[nsapi].ref_npdu_num) { | |
668 | |
669 sndcp_data->cur_seg_pos[nsapi] = SEG_POS_NONE; | |
670 sndcp_set_nsapi_rec_state(nsapi, SD_UNACK_RECEIVE_SUBSEQUENT_SEGMENT); | |
671 sig_sd_cia_cia_decomp_req(ll_unitdata_ind); | |
672 } else { | |
673 sd_delete_cur_sn_unitdata_ind(nsapi); | |
674 if (ll_unitdata_ind != NULL) { | |
675 sd_get_unitdata_if_nec(ll_unitdata_ind->sapi); | |
676 PFREE(ll_unitdata_ind); | |
677 } | |
678 sndcp_set_nsapi_rec_state(nsapi, SD_UNACK_RECEIVE_FIRST_SEGMENT); | |
679 } | |
680 | |
681 } /* sd_un_s_f0_m1() */ | |
682 | |
683 /* | |
684 +------------------------------------------------------------------------------ | |
685 | Function : sd_un_s_f1_m1 | |
686 +------------------------------------------------------------------------------ | |
687 | Description : E X T R A convenience function, not in SDL. | |
688 | Represents the label UN_S_F1_M1 in SDL. | |
689 | | |
690 | Parameters : ll_unitdata_ind T_LL_UNITDATA_IND* | |
691 | | |
692 +------------------------------------------------------------------------------ | |
693 */ | |
694 GLOBAL void sd_un_s_f1_m1 (T_LL_UNITDATA_IND* ll_unitdata_ind) | |
695 { | |
696 USHORT npdu_num = 0; | |
697 UBYTE nsapi = 0; | |
698 | |
699 /* | |
700 * Get NSAPI | |
701 */ | |
702 sd_get_nsapi(ll_unitdata_ind, &nsapi); | |
703 /* | |
704 * Does the received segment have the current npdu number? | |
705 */ | |
706 sd_get_npdu_num(ll_unitdata_ind, &npdu_num); | |
707 if (npdu_num == | |
708 sndcp_data->cur_pdu_ref[nsapi].ref_npdu_num) { | |
709 | |
710 /* | |
711 * Are PCOMP and DCOMP value the same as in the first segment? | |
712 */ | |
713 UBYTE prim_dcomp = 0; | |
714 UBYTE prim_pcomp = 0; | |
715 | |
716 prim_dcomp = sd_get_dcomp(ll_unitdata_ind); | |
717 prim_pcomp = sd_get_pcomp(ll_unitdata_ind); | |
718 if (prim_dcomp == sndcp_data->cur_dcomp[nsapi] && | |
719 prim_pcomp == sndcp_data->cur_pcomp[nsapi]) { | |
720 | |
721 sndcp_data->big_head[nsapi] = TRUE; | |
722 sd_un_s_f0_m1(ll_unitdata_ind); | |
723 } else { | |
724 sd_delete_cur_sn_unitdata_ind(nsapi); | |
725 if (ll_unitdata_ind != NULL) { | |
726 sd_get_unitdata_if_nec(ll_unitdata_ind->sapi); | |
727 PFREE(ll_unitdata_ind); | |
728 } | |
729 sndcp_set_nsapi_rec_state(nsapi, SD_UNACK_DISCARD); | |
730 } | |
731 | |
732 } else { | |
733 sd_delete_cur_sn_unitdata_ind(nsapi); | |
734 sd_un_f_f1_m1(ll_unitdata_ind); | |
735 } | |
736 | |
737 } /* sd_un_s_f1_m1() */ | |
738 | |
739 /* | |
740 +------------------------------------------------------------------------------ | |
741 | Function : sd_un_s_f1_m0 | |
742 +------------------------------------------------------------------------------ | |
743 | Description : E X T R A convenience function, not in SDL. | |
744 | Represents the label UN_S_F1_M1 in SDL. | |
745 | | |
746 | Parameters : ll_unitdata_ind T_LL_UNITDATA_IND* | |
747 | | |
748 +------------------------------------------------------------------------------ | |
749 */ | |
750 GLOBAL void sd_un_s_f1_m0 (T_LL_UNITDATA_IND* ll_unitdata_ind) | |
751 { | |
752 USHORT npdu_num = 0; | |
753 UBYTE nsapi = 0; | |
754 | |
755 /* | |
756 * Get NSAPI | |
757 */ | |
758 sd_get_nsapi(ll_unitdata_ind, &nsapi); | |
759 /* | |
760 * Does the received segment have the current npdu number? | |
761 */ | |
762 sd_get_npdu_num(ll_unitdata_ind, &npdu_num); | |
763 if (npdu_num == | |
764 sndcp_data->cur_pdu_ref[nsapi].ref_npdu_num) { | |
765 | |
766 /* | |
767 * Are PCOMP and DCOMP value the same as in the first segment? | |
768 */ | |
769 UBYTE prim_dcomp = 0; | |
770 UBYTE prim_pcomp = 0; | |
771 | |
772 prim_dcomp = sd_get_dcomp(ll_unitdata_ind); | |
773 prim_pcomp = sd_get_pcomp(ll_unitdata_ind); | |
774 if (prim_dcomp == sndcp_data->cur_dcomp[nsapi] && | |
775 prim_pcomp == sndcp_data->cur_pcomp[nsapi]) { | |
776 sndcp_data->big_head[nsapi] = TRUE; | |
777 sd_un_s_f0_m0(ll_unitdata_ind); | |
778 } else { | |
779 sd_delete_cur_sn_unitdata_ind(nsapi); | |
780 if (ll_unitdata_ind != NULL) { | |
781 sd_get_unitdata_if_nec(ll_unitdata_ind->sapi); | |
782 PFREE(ll_unitdata_ind); | |
783 } | |
784 sndcp_set_nsapi_rec_state(nsapi, SD_UNACK_RECEIVE_FIRST_SEGMENT); | |
785 } | |
786 | |
787 } else { | |
788 | |
789 sndcp_data->cur_seg_pos[nsapi] = SEG_POS_LAST + SEG_POS_FIRST; | |
790 sd_delete_cur_sn_unitdata_ind(nsapi); | |
791 sd_un_f_f1_m0(ll_unitdata_ind); | |
792 | |
793 } | |
794 | |
795 } /* sd_un_s_f1_m0() */ |