FreeCalypso > hg > fc-magnetite
comparison src/g23m-fad/rlp/rlp_kers.c @ 174:90eb61ecd093
src/g23m-fad: initial import from TCS3.2/LoCosto
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 12 Oct 2016 05:40:46 +0000 |
parents | |
children | 338bf7edbd47 |
comparison
equal
deleted
inserted
replaced
173:bf64d785238a | 174:90eb61ecd093 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : CSD (8411) | |
4 | Modul : Rlp_kers.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 defines the functions for processing | |
18 | of incomming signals for the component | |
19 | Radio Link Protocol of the base station | |
20 +----------------------------------------------------------------------------- | |
21 */ | |
22 | |
23 #ifndef RLP_KERS_C | |
24 #define RLP_KERS_C | |
25 #endif | |
26 | |
27 #define ENTITY_RLP | |
28 | |
29 /*==== INCLUDES ===================================================*/ | |
30 | |
31 #include <string.h> | |
32 #include "typedefs.h" | |
33 #include "vsi.h" | |
34 #include "macdef.h" | |
35 #include "custom.h" | |
36 #include "gsm.h" | |
37 #include "cus_rlp.h" | |
38 #include "prim.h" | |
39 #include "tok.h" | |
40 #include "rlp.h" | |
41 | |
42 /*==== CONST =======================================================*/ | |
43 | |
44 /*==== TYPES =======================================================*/ | |
45 | |
46 /*==== VAR EXPORT ==================================================*/ | |
47 | |
48 /*==== VAR LOCAL ===================================================*/ | |
49 | |
50 /*==== FUNCTIONS ===================================================*/ | |
51 | |
52 /* | |
53 +------------------------------------------------------------------------------ | |
54 | Function : sig_rcv_ker_sabm_ind | |
55 +------------------------------------------------------------------------------ | |
56 | Description :Process signal SIG_SABM_IND received from process rcv. | |
57 | | |
58 | Parameters : - | |
59 | | |
60 | | |
61 | Return : - | |
62 +------------------------------------------------------------------------------ | |
63 */ | |
64 | |
65 GLOBAL void sig_rcv_ker_sabm_ind(void) | |
66 { | |
67 TRACE_FUNCTION ("sig_rcv_ker_sabm_ind()"); | |
68 | |
69 TRACE_EVENT ("SABM rcvd"); | |
70 | |
71 switch (GET_STATE (KER)) | |
72 { | |
73 case RLP_ADM_AND_DETACHED: | |
74 rlp_data->ker.DM_State = IS_SEND; | |
75 rlp_data->ker.DM_FBit = 1; | |
76 break; | |
77 | |
78 case RLP_ADM_AND_ATTACHED: | |
79 { | |
80 PALLOC (rlp_connect_ind, RLP_CONNECT_IND); | |
81 PSENDX (L2R, rlp_connect_ind); | |
82 rlp_data->ker.DM_State = IS_IDLE; | |
83 SET_STATE (KER, RLP_PENDING_CONNECT_IND); | |
84 break; | |
85 } | |
86 | |
87 case RLP_PENDING_CONNECT_REQ: | |
88 { | |
89 PALLOC (rlp_connect_cnf, RLP_CONNECT_CNF); | |
90 | |
91 TIMERSTOP (TT_HANDLE); | |
92 | |
93 rlp_connect_cnf->ack_flg = RLP_ACK; | |
94 | |
95 PSENDX (L2R, rlp_connect_cnf); | |
96 | |
97 rlp_data->ker.UA_State = IS_SEND; | |
98 rlp_data->ker.UA_FBit = 1; | |
99 ker_init_link_vars (); | |
100 SET_STATE (KER, RLP_CONNECTION_ESTABLISHED); | |
101 break; | |
102 } | |
103 | |
104 case RLP_CONNECTION_ESTABLISHED: | |
105 case RLP_PENDING_REMAP_REQ: | |
106 case RLP_REMAP_DATA: | |
107 { | |
108 PALLOC (rlp_reset_ind, RLP_RESET_IND); | |
109 | |
110 TIMERSTOP (TT_HANDLE); | |
111 TIMERSTOP (TRCVR_HANDLE); | |
112 ker_reset_all_t_rcvs (); | |
113 | |
114 PSENDX (L2R, rlp_reset_ind); | |
115 | |
116 ker_deinit_link_vars (); | |
117 SET_STATE (KER, RLP_PENDING_RESET_IND); | |
118 break; | |
119 } | |
120 | |
121 case RLP_PENDING_RESET_REQ: | |
122 { | |
123 PALLOC (rlp_reset_cnf, RLP_RESET_CNF); | |
124 | |
125 TIMERSTOP (TT_HANDLE); | |
126 PSENDX (L2R, rlp_reset_cnf); | |
127 | |
128 rlp_data->ker.UA_State = IS_SEND; | |
129 rlp_data->ker.UA_FBit = 1; | |
130 | |
131 ker_init_link_vars (); | |
132 SET_STATE (KER, RLP_CONNECTION_ESTABLISHED); | |
133 break; | |
134 } | |
135 } | |
136 } | |
137 | |
138 /* | |
139 +------------------------------------------------------------------------------ | |
140 | Function : sig_rcv_ker_disc_ind | |
141 +------------------------------------------------------------------------------ | |
142 | Description : Process signal SIG_DISC_IND received from process rcv. | |
143 | | |
144 | Parameters : pFBit - | |
145 | | |
146 | | |
147 | Return : - | |
148 +------------------------------------------------------------------------------ | |
149 */ | |
150 | |
151 | |
152 GLOBAL void sig_rcv_ker_disc_ind(T_BIT pFBit) | |
153 { | |
154 TRACE_FUNCTION ("sig_rcv_ker_disc_ind()"); | |
155 | |
156 TRACE_EVENT ("DISC rcvd"); | |
157 | |
158 switch (GET_STATE (KER)) | |
159 { | |
160 case RLP_ADM_AND_DETACHED: | |
161 rlp_data->ker.DM_State = IS_SEND; | |
162 rlp_data->ker.DM_FBit = pFBit; | |
163 break; | |
164 | |
165 case RLP_ADM_AND_ATTACHED: | |
166 rlp_data->ker.UA_State = IS_SEND; | |
167 rlp_data->ker.UA_FBit = pFBit; | |
168 rlp_data->ker.DM_State = IS_IDLE; | |
169 break; | |
170 | |
171 case RLP_PENDING_CONNECT_REQ: | |
172 case RLP_PENDING_CONNECT_IND: | |
173 { | |
174 PALLOC (rlp_disc_ind, RLP_DISC_IND); | |
175 | |
176 TIMERSTOP (TT_HANDLE); | |
177 PSENDX (L2R, rlp_disc_ind); | |
178 | |
179 rlp_data->ker.UA_State = IS_SEND; | |
180 rlp_data->ker.UA_FBit = pFBit; | |
181 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
182 break; | |
183 } | |
184 | |
185 case RLP_CONNECTION_ESTABLISHED: | |
186 case RLP_PENDING_REMAP_REQ: | |
187 case RLP_REMAP_DATA: | |
188 { | |
189 PALLOC (rlp_disc_ind, RLP_DISC_IND); | |
190 | |
191 TIMERSTOP (TT_HANDLE); | |
192 TIMERSTOP (TRCVR_HANDLE); | |
193 ker_reset_all_t_rcvs (); | |
194 | |
195 PSENDX (L2R, rlp_disc_ind); | |
196 | |
197 rlp_data->ker.UA_State = IS_SEND; | |
198 rlp_data->ker.UA_FBit = pFBit; | |
199 ker_deinit_link_vars (); | |
200 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
201 break; | |
202 } | |
203 | |
204 case RLP_DISCONNECT_INITIATED: | |
205 { | |
206 rlp_data->ker.UA_State = IS_SEND; | |
207 rlp_data->ker.UA_FBit = pFBit; | |
208 | |
209 TIMERSTOP (TT_HANDLE); | |
210 | |
211 if (rlp_data->ker.DISC_Ind) | |
212 { | |
213 PALLOC (rlp_disc_ind, RLP_DISC_IND); | |
214 PSENDX (L2R, rlp_disc_ind); | |
215 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
216 } | |
217 else | |
218 { | |
219 PALLOC (rlp_disc_cnf, RLP_DISC_CNF); | |
220 PSENDX (L2R, rlp_disc_cnf); | |
221 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
222 } | |
223 | |
224 break; | |
225 } | |
226 | |
227 case RLP_PENDING_RESET_REQ: | |
228 { | |
229 PALLOC (rlp_disc_ind, RLP_DISC_IND); | |
230 | |
231 TIMERSTOP (TT_HANDLE); | |
232 PSENDX (L2R, rlp_disc_ind); | |
233 | |
234 rlp_data->ker.UA_State = IS_SEND; | |
235 rlp_data->ker.UA_FBit = pFBit; | |
236 | |
237 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
238 break; | |
239 } | |
240 | |
241 case RLP_PENDING_RESET_IND: | |
242 { | |
243 PALLOC (rlp_disc_ind, RLP_DISC_IND); | |
244 | |
245 PSENDX (L2R, rlp_disc_ind); | |
246 | |
247 rlp_data->ker.UA_State = IS_SEND; | |
248 rlp_data->ker.UA_FBit = pFBit; | |
249 | |
250 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
251 break; | |
252 } | |
253 } | |
254 } | |
255 | |
256 /* | |
257 +------------------------------------------------------------------------------ | |
258 | Function : sig_rcv_ker_ua_ind | |
259 +------------------------------------------------------------------------------ | |
260 | Description : Process signal SIG_UA_IND received from process rcv. | |
261 | | |
262 | Parameters : pFBit - | |
263 | | |
264 | | |
265 | Return : - | |
266 +------------------------------------------------------------------------------ | |
267 */ | |
268 | |
269 GLOBAL void sig_rcv_ker_ua_ind(T_BIT pFBit) | |
270 { | |
271 TRACE_FUNCTION ("sig_rcv_ker_ua_ind()"); | |
272 | |
273 TRACE_EVENT ("UA rcvd"); | |
274 | |
275 switch (GET_STATE (KER)) | |
276 { | |
277 case RLP_PENDING_CONNECT_REQ: | |
278 switch (rlp_data->ker.SABM_State) | |
279 { | |
280 case ISW_WAIT: | |
281 if (pFBit EQ 1) | |
282 { | |
283 PALLOC (rlp_connect_cnf, RLP_CONNECT_CNF); | |
284 TIMERSTOP (TT_HANDLE); | |
285 | |
286 rlp_connect_cnf->ack_flg = RLP_ACK; | |
287 | |
288 PSENDX (L2R, rlp_connect_cnf); | |
289 ker_init_link_vars (); | |
290 SET_STATE (KER, RLP_CONNECTION_ESTABLISHED); | |
291 } | |
292 break; | |
293 | |
294 default: | |
295 break; | |
296 } | |
297 break; | |
298 | |
299 case RLP_DISCONNECT_INITIATED: | |
300 switch (rlp_data->ker.DISC_State) | |
301 { | |
302 case ISW_WAIT: | |
303 if (pFBit EQ rlp_data->ker.DISC_PBit) | |
304 { | |
305 if (rlp_data->ker.DISC_PBit EQ 1) | |
306 rlp_data->ker.Poll_xchg = IW_IDLE; | |
307 | |
308 TIMERSTOP (TT_HANDLE); | |
309 if (rlp_data->ker.DISC_Ind) | |
310 { | |
311 PALLOC (rlp_disc_ind, RLP_DISC_IND); | |
312 PSENDX (L2R, rlp_disc_ind); | |
313 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
314 } | |
315 else | |
316 { | |
317 PALLOC (rlp_disc_cnf, RLP_DISC_CNF); | |
318 PSENDX (L2R, rlp_disc_cnf); | |
319 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
320 } | |
321 | |
322 } | |
323 break; | |
324 } | |
325 break; | |
326 | |
327 case RLP_PENDING_RESET_REQ: | |
328 switch (rlp_data->ker.SABM_State) | |
329 { | |
330 case ISW_WAIT: | |
331 if (pFBit EQ 1) | |
332 { | |
333 PALLOC (rlp_reset_cnf, RLP_RESET_CNF); | |
334 | |
335 TIMERSTOP (TT_HANDLE); | |
336 PSENDX (L2R, rlp_reset_cnf); | |
337 | |
338 ker_init_link_vars (); | |
339 SET_STATE (KER, RLP_CONNECTION_ESTABLISHED); | |
340 } | |
341 break; | |
342 } | |
343 break; | |
344 } | |
345 } | |
346 | |
347 /* | |
348 +------------------------------------------------------------------------------ | |
349 | Function : sig_rcv_ker_dm_ind | |
350 +------------------------------------------------------------------------------ | |
351 | Description : Process signal SIG_DM_IND received from process rcv. | |
352 | | |
353 | Parameters : pFBit - | |
354 | | |
355 | | |
356 | Return : - | |
357 +------------------------------------------------------------------------------ | |
358 */ | |
359 | |
360 | |
361 GLOBAL void sig_rcv_ker_dm_ind(T_BIT pFBit) | |
362 { | |
363 TRACE_FUNCTION ("sig_rcv_ker_dm_ind()"); | |
364 | |
365 TRACE_EVENT ("DM rcvd"); | |
366 | |
367 switch (GET_STATE (KER)) | |
368 { | |
369 case RLP_PENDING_CONNECT_REQ: | |
370 switch (rlp_data->ker.SABM_State) | |
371 { | |
372 case ISW_WAIT: | |
373 if (pFBit EQ 1) | |
374 { | |
375 PALLOC (rlp_connect_cnf, RLP_CONNECT_CNF); | |
376 TIMERSTOP (TT_HANDLE); | |
377 rlp_data->ker.Poll_xchg = IW_IDLE; | |
378 | |
379 rlp_connect_cnf->ack_flg = RLP_NAK; | |
380 | |
381 PSENDX (L2R, rlp_connect_cnf); | |
382 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
383 } | |
384 break; | |
385 } | |
386 break; | |
387 | |
388 case RLP_DISCONNECT_INITIATED: | |
389 switch (rlp_data->ker.DISC_State) | |
390 { | |
391 case ISW_WAIT: | |
392 if (pFBit EQ rlp_data->ker.DISC_PBit) | |
393 { | |
394 if (rlp_data->ker.DISC_PBit EQ 1) | |
395 rlp_data->ker.Poll_xchg = IW_IDLE; | |
396 | |
397 TIMERSTOP (TT_HANDLE); | |
398 | |
399 if (rlp_data->ker.DISC_Ind) | |
400 { | |
401 PALLOC (rlp_disc_ind, RLP_DISC_IND); | |
402 PSENDX (L2R, rlp_disc_ind); | |
403 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
404 } | |
405 else | |
406 { | |
407 PALLOC (rlp_disc_cnf, RLP_DISC_CNF); | |
408 PSENDX (L2R, rlp_disc_cnf); | |
409 SET_STATE (KER, RLP_ADM_AND_ATTACHED); | |
410 } | |
411 } | |
412 break; | |
413 } | |
414 break; | |
415 } | |
416 } | |
417 | |
418 /* | |
419 +------------------------------------------------------------------------------ | |
420 | Function : sig_rcv_ker_rr_ind | |
421 +------------------------------------------------------------------------------ | |
422 | Description : Process signal SIG_RR_IND received from process rcv. | |
423 | | |
424 | Parameters : cBit | |
425 | pFBit | |
426 | nr | |
427 | | |
428 | Return : - | |
429 +------------------------------------------------------------------------------ | |
430 */ | |
431 | |
432 | |
433 GLOBAL void sig_rcv_ker_rr_ind | |
434 ( | |
435 T_BIT cBit, | |
436 T_BIT pFBit, | |
437 T_FRAME_NUM nr | |
438 ) | |
439 { | |
440 | |
441 BOOL retransError; | |
442 | |
443 TRACE_FUNCTION ("sig_rcv_ker_rr_ind()"); | |
444 | |
445 switch (GET_STATE (KER)) | |
446 { | |
447 case RLP_CONNECTION_ESTABLISHED: | |
448 rlp_data->ker.SF = SF_RR; | |
449 | |
450 /* | |
451 * unsolicited F_Bit ? | |
452 */ | |
453 if (!(pFBit EQ 1 AND cBit EQ 0 AND rlp_data->ker.Poll_State NEQ ISW_WAIT)) | |
454 { | |
455 /* | |
456 * NR within range of send frames pending for acknowledgement ? | |
457 */ | |
458 if (sbm_frame_in_range (nr)) | |
459 { | |
460 ker_s_handler (cBit, pFBit, rlp_data->ker.SF, nr, &retransError); | |
461 if (retransError) | |
462 { | |
463 SET_STATE(KER, RLP_DISCONNECT_INITIATED); | |
464 TRACE_EVENT("#2"); | |
465 } | |
466 } | |
467 } | |
468 break; | |
469 } | |
470 } | |
471 | |
472 /* | |
473 +------------------------------------------------------------------------------ | |
474 | Function : sig_rcv_ker_rnr_ind | |
475 +------------------------------------------------------------------------------ | |
476 | Description : Process signal SIG_RNR_IND received from process rcv. | |
477 | | |
478 | Parameters : cBit | |
479 | pFBit | |
480 | nr | |
481 | | |
482 | Return : - | |
483 +------------------------------------------------------------------------------ | |
484 */ | |
485 | |
486 | |
487 GLOBAL void sig_rcv_ker_rnr_ind | |
488 ( | |
489 T_BIT cBit, | |
490 T_BIT pFBit, | |
491 T_FRAME_NUM nr | |
492 ) | |
493 { | |
494 BOOL retransError; | |
495 | |
496 TRACE_FUNCTION ("sig_rcv_ker_rnr_ind()"); | |
497 | |
498 switch (GET_STATE (KER)) | |
499 { | |
500 case RLP_CONNECTION_ESTABLISHED: | |
501 rlp_data->ker.SF = SF_RNR; | |
502 | |
503 /* | |
504 * unsolicited F_Bit ? | |
505 */ | |
506 if (!(pFBit EQ 1 AND cBit EQ 0 AND rlp_data->ker.Poll_State NEQ ISW_WAIT)) | |
507 { | |
508 /* | |
509 * NR within range of send frames pending | |
510 * for acknowledgement ?? | |
511 */ | |
512 if (sbm_frame_in_range (nr)) | |
513 { | |
514 ker_s_handler (cBit, pFBit, rlp_data->ker.SF, nr, &retransError); | |
515 if (retransError) | |
516 { | |
517 SET_STATE(KER, RLP_DISCONNECT_INITIATED); | |
518 TRACE_EVENT("#3"); | |
519 } | |
520 } | |
521 } | |
522 break; | |
523 } | |
524 } | |
525 | |
526 /* | |
527 +------------------------------------------------------------------------------ | |
528 | Function : sig_rcv_ker_rej_ind | |
529 +------------------------------------------------------------------------------ | |
530 | Description : Process signal SIG_REJ_IND received from process rcv. | |
531 | | |
532 | Parameters : cBit | |
533 | pFBit | |
534 | nr | |
535 | | |
536 | Return : - | |
537 +------------------------------------------------------------------------------ | |
538 */ | |
539 | |
540 | |
541 GLOBAL void sig_rcv_ker_rej_ind | |
542 ( | |
543 T_BIT cBit, | |
544 T_BIT pFBit, | |
545 T_FRAME_NUM nr | |
546 ) | |
547 { | |
548 | |
549 BOOL retransError; | |
550 | |
551 TRACE_FUNCTION ("sig_rcv_ker_rej_ind()"); | |
552 | |
553 switch (GET_STATE (KER)) | |
554 { | |
555 case RLP_CONNECTION_ESTABLISHED: | |
556 rlp_data->ker.SF = SF_REJ; | |
557 | |
558 /* | |
559 * unsolicited F_Bit ? | |
560 */ | |
561 if (!(pFBit EQ 1 AND cBit EQ 0 AND rlp_data->ker.Poll_State NEQ ISW_WAIT)) | |
562 { | |
563 /* | |
564 * NR within range of send frames pending for acknowledgement ? | |
565 */ | |
566 if (sbm_frame_in_range (nr)) | |
567 { | |
568 ker_s_handler (cBit, pFBit, rlp_data->ker.SF, nr, &retransError); | |
569 if (retransError) | |
570 { | |
571 SET_STATE(KER, RLP_DISCONNECT_INITIATED); | |
572 TRACE_EVENT("#4"); | |
573 } | |
574 } | |
575 } | |
576 break; | |
577 } | |
578 } | |
579 | |
580 /* | |
581 +------------------------------------------------------------------------------ | |
582 | Function : sig_rcv_ker_srej_ind | |
583 +------------------------------------------------------------------------------ | |
584 | Description : Process signal SIG_SREJ_IND received from process rcv. | |
585 | | |
586 | Parameters :cBit - | |
587 | pFBit - | |
588 | nr - | |
589 | | |
590 | Return : - | |
591 +------------------------------------------------------------------------------ | |
592 */ | |
593 | |
594 | |
595 GLOBAL void sig_rcv_ker_srej_ind | |
596 ( | |
597 T_BIT cBit, | |
598 T_BIT pFBit, | |
599 T_FRAME_NUM nr | |
600 ) | |
601 { | |
602 | |
603 BOOL retransError; | |
604 | |
605 TRACE_FUNCTION ("sig_rcv_ker_srej_ind()"); | |
606 | |
607 switch (GET_STATE (KER)) | |
608 { | |
609 case RLP_CONNECTION_ESTABLISHED: | |
610 rlp_data->ker.SF = SF_SREJ; | |
611 | |
612 /* | |
613 * unsolicited F_Bit ? | |
614 */ | |
615 if (!(pFBit EQ 1 AND cBit EQ 0 AND rlp_data->ker.Poll_State NEQ ISW_WAIT)) | |
616 { | |
617 /* | |
618 * NR within range of send frames pending | |
619 * for acknowledgement ?? | |
620 */ | |
621 if (sbm_frame_in_range (nr)) | |
622 { | |
623 ker_s_handler (cBit, pFBit, rlp_data->ker.SF, nr, &retransError); | |
624 if (retransError) | |
625 { | |
626 SET_STATE(KER, RLP_DISCONNECT_INITIATED); | |
627 TRACE_EVENT("#5"); | |
628 } | |
629 } | |
630 } | |
631 break; | |
632 } | |
633 } | |
634 | |
635 /* | |
636 +------------------------------------------------------------------------------ | |
637 | Function : sig_rcv_ker_rr_i_ind | |
638 +------------------------------------------------------------------------------ | |
639 | Description : Process signal SIG_RR_I_IND received from process rcv. | |
640 | | |
641 | Parameters : cBit - | |
642 | pFBit - | |
643 | nr - | |
644 | ns - | |
645 | | |
646 | Return : - | |
647 +------------------------------------------------------------------------------ | |
648 */ | |
649 | |
650 | |
651 GLOBAL void sig_rcv_ker_rr_i_ind | |
652 ( | |
653 T_BIT cBit, | |
654 T_BIT pFBit, | |
655 T_FRAME_NUM nr, | |
656 T_FRAME_NUM ns | |
657 ) | |
658 { | |
659 | |
660 BOOL retransError; | |
661 | |
662 TRACE_FUNCTION ("sig_rcv_ker_rr_i_ind()"); | |
663 | |
664 switch (GET_STATE (KER)) | |
665 { | |
666 case RLP_CONNECTION_ESTABLISHED: | |
667 rlp_data->ker.SF = SF_RR; | |
668 | |
669 /* | |
670 * unsolicited F_Bit ? | |
671 */ | |
672 if (!(pFBit EQ 1 AND cBit EQ 0 AND rlp_data->ker.Poll_State NEQ ISW_WAIT)) | |
673 { | |
674 /* | |
675 * NR within range of send frames pending | |
676 * for acknowledgement ?? | |
677 */ | |
678 if (sbm_frame_in_range (nr)) | |
679 if (!ker_i_handler (ns)) | |
680 { | |
681 ker_s_handler (cBit, pFBit, rlp_data->ker.SF, nr, &retransError); | |
682 if (retransError) | |
683 { | |
684 SET_STATE(KER, RLP_DISCONNECT_INITIATED); | |
685 TRACE_EVENT("#6"); | |
686 } | |
687 } | |
688 } | |
689 break; | |
690 } | |
691 } | |
692 | |
693 /* | |
694 +------------------------------------------------------------------------------ | |
695 | Function : sig_rcv_ker_rnr_i_ind | |
696 +------------------------------------------------------------------------------ | |
697 | Description : Process signal SIG_RNR_I_IND received from process rcv. | |
698 | | |
699 | Parameters : cBit | |
700 | pFBit | |
701 | nr | |
702 | ns | |
703 | | |
704 | Return : | |
705 +------------------------------------------------------------------------------ | |
706 */ | |
707 | |
708 | |
709 GLOBAL void sig_rcv_ker_rnr_i_ind | |
710 ( | |
711 T_BIT cBit, | |
712 T_BIT pFBit, | |
713 T_FRAME_NUM nr, | |
714 T_FRAME_NUM ns | |
715 ) | |
716 { | |
717 | |
718 BOOL retransError; | |
719 | |
720 TRACE_FUNCTION ("sig_rcv_ker_rnr_i_ind()"); | |
721 | |
722 switch (GET_STATE (KER)) | |
723 { | |
724 case RLP_CONNECTION_ESTABLISHED: | |
725 /* | |
726 * processing for state RLP_CONNECTION_ESTABLISHED | |
727 */ | |
728 rlp_data->ker.SF = SF_RNR; | |
729 | |
730 /* | |
731 * unsolicited F_Bit ? | |
732 */ | |
733 if (!(pFBit EQ 1 AND cBit EQ 0 AND rlp_data->ker.Poll_State NEQ ISW_WAIT)) | |
734 { | |
735 /* | |
736 * NR within range of send frames pending | |
737 * for acknowledgement ?? | |
738 */ | |
739 if (sbm_frame_in_range (nr)) | |
740 if (!ker_i_handler (ns)) | |
741 { | |
742 ker_s_handler (cBit, pFBit, rlp_data->ker.SF, nr, &retransError); | |
743 if (retransError) | |
744 { | |
745 SET_STATE(KER, RLP_DISCONNECT_INITIATED); | |
746 TRACE_EVENT("#7"); | |
747 } | |
748 } | |
749 } | |
750 break; | |
751 } | |
752 } | |
753 | |
754 /* | |
755 +------------------------------------------------------------------------------ | |
756 | Function : sig_rcv_ker_rej_i_ind | |
757 +------------------------------------------------------------------------------ | |
758 | Description : Process signal SIG_REJ_I_IND received from process rcv. | |
759 | | |
760 | | |
761 | Parameters : cBit - | |
762 | pFBit - | |
763 | nr - | |
764 | : ns - | |
765 | Return | |
766 +------------------------------------------------------------------------------ | |
767 */ | |
768 | |
769 | |
770 GLOBAL void sig_rcv_ker_rej_i_ind | |
771 ( | |
772 T_BIT cBit, | |
773 T_BIT pFBit, | |
774 T_FRAME_NUM nr, | |
775 T_FRAME_NUM ns | |
776 ) | |
777 { | |
778 | |
779 BOOL retransError; | |
780 | |
781 TRACE_FUNCTION ("sig_rcv_ker_rej_i_ind()"); | |
782 | |
783 switch (GET_STATE (KER)) | |
784 { | |
785 case RLP_CONNECTION_ESTABLISHED: | |
786 /* | |
787 * processing for state RLP_CONNECTION_ESTABLISHED | |
788 */ | |
789 rlp_data->ker.SF = SF_REJ; | |
790 | |
791 /* | |
792 * unsolicited F_Bit ? | |
793 */ | |
794 if (!(pFBit EQ 1 AND cBit EQ 0 AND rlp_data->ker.Poll_State NEQ ISW_WAIT)) | |
795 { | |
796 /* | |
797 * NR within range of send frames pending | |
798 * for acknowledgement ?? | |
799 */ | |
800 if (sbm_frame_in_range (nr)) | |
801 if (!ker_i_handler (ns)) | |
802 { | |
803 ker_s_handler (cBit, pFBit, rlp_data->ker.SF, nr, &retransError); | |
804 if (retransError) | |
805 { | |
806 SET_STATE(KER, RLP_DISCONNECT_INITIATED); | |
807 TRACE_EVENT("#8"); | |
808 } | |
809 } | |
810 } | |
811 break; | |
812 } | |
813 } | |
814 | |
815 /* | |
816 +------------------------------------------------------------------------------ | |
817 | Function : sig_rcv_ker_srej_i_ind | |
818 +------------------------------------------------------------------------------ | |
819 | Description : Process signal SIG_SREJ_I_IND received from process rcv. | |
820 | | |
821 | Parameters : cBit - | |
822 | pFBit - | |
823 | nr - | |
824 | ns - | |
825 | | |
826 | Return : | |
827 +------------------------------------------------------------------------------ | |
828 */ | |
829 | |
830 | |
831 GLOBAL void sig_rcv_ker_srej_i_ind | |
832 ( | |
833 T_BIT cBit, | |
834 T_BIT pFBit, | |
835 T_FRAME_NUM nr, | |
836 T_FRAME_NUM ns | |
837 ) | |
838 { | |
839 | |
840 BOOL retransError; | |
841 | |
842 TRACE_FUNCTION ("sig_rcv_ker_srej_i_ind()"); | |
843 | |
844 switch (GET_STATE (KER)) | |
845 { | |
846 case RLP_CONNECTION_ESTABLISHED: | |
847 /* | |
848 * processing for state RLP_CONNECTION_ESTABLISHED | |
849 */ | |
850 rlp_data->ker.SF = SF_SREJ; | |
851 | |
852 /* | |
853 * unsolicited F_Bit ? | |
854 */ | |
855 if (!(pFBit EQ 1 AND cBit EQ 0 AND rlp_data->ker.Poll_State NEQ ISW_WAIT)) | |
856 { | |
857 /* | |
858 * NR within range of send frames pending | |
859 * for acknowledgement ?? | |
860 */ | |
861 if (sbm_frame_in_range (nr)) | |
862 if (!ker_i_handler (ns)) | |
863 { | |
864 ker_s_handler (cBit, pFBit, rlp_data->ker.SF, nr, &retransError); | |
865 if (retransError) | |
866 { | |
867 SET_STATE(KER, RLP_DISCONNECT_INITIATED); | |
868 TRACE_EVENT("#9"); | |
869 } | |
870 } | |
871 } | |
872 break; | |
873 } | |
874 } | |
875 | |
876 /* | |
877 +------------------------------------------------------------------------------ | |
878 | Function : sig_rcv_ker_ui_ind | |
879 +------------------------------------------------------------------------------ | |
880 | Description : Process signal SIG_UI_IND received from process rcv. | |
881 | | |
882 | Parameters : cBit - | |
883 | pFBit - | |
884 | | |
885 | Return : - | |
886 +------------------------------------------------------------------------------ | |
887 */ | |
888 | |
889 | |
890 /* | |
891 +------------------------------------------------------------------------------ | |
892 | Function : sig_rcv_ker_xid_ind | |
893 +------------------------------------------------------------------------------ | |
894 | Description : Process signal SIG_XID_IND received from process rcv. | |
895 | | |
896 | Parameters : cBit | |
897 | pFBit | |
898 | | |
899 | Return : - | |
900 +------------------------------------------------------------------------------ | |
901 */ | |
902 | |
903 | |
904 GLOBAL void sig_rcv_ker_xid_ind | |
905 ( | |
906 T_BIT cBit, | |
907 T_BIT pFBit | |
908 ) | |
909 { | |
910 TRACE_FUNCTION ("sig_rcv_ker_xid_ind()"); | |
911 | |
912 switch (GET_STATE (KER)) | |
913 { | |
914 case RLP_ADM_AND_DETACHED: | |
915 /* | |
916 * processing for state RLP_ADM_AND_DETACHED | |
917 */ | |
918 | |
919 break; | |
920 | |
921 default: | |
922 /* | |
923 * processing for all other kernel states | |
924 */ | |
925 if (cBit EQ 1) | |
926 { | |
927 switch (GET_STATE(KERXID_C)) | |
928 { | |
929 case ISW_WAIT: | |
930 { | |
931 rlp_data->ker.Poll_xchg = IW_IDLE; | |
932 SET_STATE(KERXID_C, ISW_IDLE); | |
933 | |
934 /* | |
935 TIMERSTOP (rlp_data->txid_handle); | |
936 | |
937 TIMERSTART | |
938 ( | |
939 TXID, | |
940 rlp_data->ker.T1, | |
941 rlp_data->txid_handle | |
942 ); | |
943 */ | |
944 } | |
945 break; | |
946 | |
947 default: | |
948 { | |
949 PALLOC (rlp_xid_ind, RLP_XID_IND); | |
950 | |
951 ker_get_xid_data | |
952 ( | |
953 rbm_get_current_frame () + HEADER_LEN, | |
954 0, | |
955 rlp_xid_ind, | |
956 FALSE, | |
957 &rlp_data->ker.XID_R_Used_Flg | |
958 ); | |
959 | |
960 PSENDX (L2R, rlp_xid_ind); | |
961 | |
962 ker_put_xid_data | |
963 ( | |
964 rlp_data->ker.XID_R_Frame + HEADER_LEN, | |
965 0, | |
966 rlp_data->ker.XID_R_Used_Flg, | |
967 FALSE, | |
968 rlp_data->ker.Rlp_Vers, | |
969 rlp_data->ker.K_iwf_ms, | |
970 rlp_data->ker.K_ms_iwf, | |
971 rlp_data->ker.T1, | |
972 rlp_data->ker.N2, | |
973 rlp_data->ker.T2, | |
974 rlp_data->ker.Pt, | |
975 rlp_data->ker.P0, | |
976 rlp_data->ker.P1, | |
977 rlp_data->ker.P2 | |
978 ); | |
979 | |
980 rlp_data->ker.XID_R_State = IS_SEND; | |
981 | |
982 rlp_data->ker.XID_R_FBit = pFBit; | |
983 | |
984 SET_STATE(KERXID_C, ISW_IDLE); | |
985 } | |
986 break; | |
987 } | |
988 } | |
989 else | |
990 { | |
991 switch (GET_STATE(KERXID_C)) | |
992 { | |
993 case ISW_WAIT: | |
994 if (pFBit EQ 1) | |
995 { | |
996 PALLOC (rlp_xid_ind, RLP_XID_IND); | |
997 | |
998 rlp_data->ker.Poll_xchg = IW_IDLE; | |
999 | |
1000 TIMERSTOP (TXID_HANDLE); | |
1001 ker_get_xid_data | |
1002 ( | |
1003 rbm_get_current_frame () + HEADER_LEN, | |
1004 0, | |
1005 rlp_xid_ind, | |
1006 TRUE, | |
1007 &rlp_data->ker.XID_C_Used_Flg | |
1008 ); | |
1009 | |
1010 PSENDX (L2R, rlp_xid_ind); | |
1011 | |
1012 SET_STATE(KERXID_C, ISW_IDLE); | |
1013 } | |
1014 break; | |
1015 | |
1016 default: | |
1017 break; | |
1018 } | |
1019 } | |
1020 break; | |
1021 } | |
1022 } | |
1023 | |
1024 /* | |
1025 +------------------------------------------------------------------------------ | |
1026 | Function : sig_rcv_ker_test_ind | |
1027 +------------------------------------------------------------------------------ | |
1028 | Description : Process signal SIG_TEST_IND received from process rcv. | |
1029 | | |
1030 | Parameters : cBit - | |
1031 | pFBit - | |
1032 | | |
1033 | Return : - | |
1034 +------------------------------------------------------------------------------ | |
1035 */ | |
1036 | |
1037 | |
1038 GLOBAL void sig_rcv_ker_test_ind | |
1039 ( | |
1040 T_BIT cBit, | |
1041 T_BIT pFBit | |
1042 ) | |
1043 { | |
1044 TRACE_FUNCTION ("sig_rcv_ker_test_ind()"); | |
1045 | |
1046 switch (GET_STATE (KER)) | |
1047 { | |
1048 case RLP_ADM_AND_DETACHED: | |
1049 /* | |
1050 * no processing for state RLP_ADM_AND_DETACHED | |
1051 */ | |
1052 break; | |
1053 | |
1054 default: | |
1055 /* | |
1056 * processing for all other kernel states | |
1057 */ | |
1058 if (cBit EQ 1) | |
1059 { | |
1060 rlp_data->ker.TEST_R_State = IS_SEND; | |
1061 rlp_data->ker.TEST_R_FBit = pFBit; | |
1062 memcpy | |
1063 ( | |
1064 rlp_data->ker.TEST_R_Frame, | |
1065 rbm_get_current_frame (), | |
1066 rlp_data->ker.FrameSize | |
1067 ); | |
1068 } | |
1069 break; | |
1070 } | |
1071 } | |
1072 | |
1073 /* | |
1074 +------------------------------------------------------------------------------ | |
1075 | Function : sig_rcv_ker_remap_ind | |
1076 +------------------------------------------------------------------------------ | |
1077 | Description : Process signal SIG_REMAP_IND received from process rcv. | |
1078 | | |
1079 | Parameters : - | |
1080 | | |
1081 | | |
1082 | Return : - | |
1083 +------------------------------------------------------------------------------ | |
1084 */ | |
1085 | |
1086 | |
1087 GLOBAL void sig_rcv_ker_remap_ind | |
1088 ( | |
1089 void | |
1090 ) | |
1091 { | |
1092 T_RBM_FRAMEPTR remapFrame; | |
1093 | |
1094 TRACE_FUNCTION ("sig_rcv_ker_remap_ind()"); | |
1095 | |
1096 switch (GET_STATE (KER)) | |
1097 { | |
1098 case RLP_PENDING_REMAP_REQ: | |
1099 { | |
1100 PALLOC (rlp_xid_ind, RLP_XID_IND); | |
1101 | |
1102 remapFrame = rbm_get_current_frame(); | |
1103 | |
1104 rlp_data->ker.RemapNr = (*(T_RLP_FRAME_LONG *)remapFrame)[HEADER_LEN] >> 2; | |
1105 | |
1106 sbm_ack_upto_n (rlp_data->ker.RemapNr); | |
1107 | |
1108 ker_get_xid_data | |
1109 ( | |
1110 remapFrame + HEADER_LEN, | |
1111 2, | |
1112 rlp_xid_ind, | |
1113 TRUE, | |
1114 &rlp_data->ker.XID_C_Used_Flg | |
1115 ); | |
1116 | |
1117 PSENDX (L2R, rlp_xid_ind); | |
1118 | |
1119 if (!ker_send_remap_data ()) | |
1120 { | |
1121 PALLOC (rlp_remap_cnf, RLP_REMAP_CNF); | |
1122 | |
1123 sbm_reset_after_remap | |
1124 ( | |
1125 rlp_data->ker.FrameSize, | |
1126 rlp_data->ker.RemapNr | |
1127 ); | |
1128 | |
1129 PSENDX (L2R, rlp_remap_cnf); | |
1130 SET_STATE (KER, RLP_CONNECTION_ESTABLISHED); | |
1131 break; | |
1132 } | |
1133 | |
1134 SET_STATE (KER, RLP_REMAP_DATA); | |
1135 break; | |
1136 } | |
1137 | |
1138 default: | |
1139 break; | |
1140 } | |
1141 } | |
1142 | |
1143 /* | |
1144 +------------------------------------------------------------------------------ | |
1145 | Function : sig_rcv_ker_ready_ind | |
1146 +------------------------------------------------------------------------------ | |
1147 | Description : Process signal SIG_READY_IND received from process rcv. | |
1148 | | |
1149 | Parameters : - | |
1150 | | |
1151 | | |
1152 | Return : - | |
1153 +------------------------------------------------------------------------------ | |
1154 */ | |
1155 | |
1156 GLOBAL void sig_rcv_ker_ready_ind(void) | |
1157 { | |
1158 | |
1159 TRACE_FUNCTION ("sig_rcv_ker_ready_ind()"); | |
1160 | |
1161 switch (GET_STATE (KER)) | |
1162 { | |
1163 case RLP_ADM_AND_DETACHED: | |
1164 switch (rlp_data->ker.DM_State) | |
1165 { | |
1166 case IS_IDLE: | |
1167 sig_ker_snd_null_req (); | |
1168 break; | |
1169 | |
1170 case IS_SEND: | |
1171 sig_ker_snd_dm_req (rlp_data->ker.DM_FBit); | |
1172 rlp_data->ker.DM_State = IS_IDLE; | |
1173 break; | |
1174 } | |
1175 break; | |
1176 | |
1177 case RLP_ADM_AND_ATTACHED: | |
1178 if (!ker_send_txu()) | |
1179 { | |
1180 switch(rlp_data->ker.DM_State) | |
1181 { | |
1182 case IS_IDLE: | |
1183 switch (rlp_data->ker.UA_State) | |
1184 { | |
1185 case IS_IDLE: | |
1186 sig_ker_snd_null_req (); | |
1187 break; | |
1188 | |
1189 case IS_SEND: | |
1190 sig_ker_snd_ua_req (rlp_data->ker.UA_FBit); | |
1191 rlp_data->ker.UA_State = IS_IDLE; | |
1192 break; | |
1193 } | |
1194 break; | |
1195 | |
1196 case IS_SEND: | |
1197 sig_ker_snd_dm_req(rlp_data->ker.DM_FBit); | |
1198 rlp_data->ker.DM_State = IS_IDLE; | |
1199 break; | |
1200 } | |
1201 } | |
1202 break; | |
1203 | |
1204 case RLP_PENDING_CONNECT_REQ: | |
1205 if (!ker_send_txu()) | |
1206 { | |
1207 switch (rlp_data->ker.SABM_State) | |
1208 { | |
1209 case ISW_SEND: | |
1210 switch (rlp_data->ker.Poll_xchg) | |
1211 { | |
1212 case IW_IDLE: | |
1213 sig_ker_snd_sabm_req (); | |
1214 rlp_data->ker.SABM_State = ISW_WAIT; | |
1215 rlp_data->ker.SABM_Count++; | |
1216 rlp_data->ker.Poll_xchg = IW_WAIT; | |
1217 TIMERSTART(TT_HANDLE, rlp_data->ker.T1); | |
1218 break; | |
1219 | |
1220 default: | |
1221 sig_ker_snd_null_req (); | |
1222 break; | |
1223 } | |
1224 break; | |
1225 | |
1226 default: | |
1227 sig_ker_snd_null_req (); | |
1228 break; | |
1229 } | |
1230 } | |
1231 break; | |
1232 | |
1233 case RLP_PENDING_CONNECT_IND: | |
1234 if (!ker_send_txu()) | |
1235 sig_ker_snd_null_req (); | |
1236 break; | |
1237 | |
1238 case RLP_CONNECTION_ESTABLISHED: | |
1239 if (!ker_send_txu()) | |
1240 ker_send_data (); | |
1241 break; | |
1242 | |
1243 case RLP_DISCONNECT_INITIATED: | |
1244 if (!ker_send_txu()) | |
1245 { | |
1246 switch (rlp_data->ker.DISC_State) | |
1247 { | |
1248 case ISW_WAIT: | |
1249 sig_ker_snd_null_req (); | |
1250 break; | |
1251 | |
1252 default: | |
1253 if (rlp_data->ker.DISC_PBit EQ 1 AND rlp_data->ker.Poll_xchg EQ IW_WAIT) | |
1254 { | |
1255 sig_ker_snd_null_req (); | |
1256 } | |
1257 else | |
1258 { | |
1259 sig_ker_snd_disc_req (rlp_data->ker.DISC_PBit); | |
1260 if (rlp_data->ker.DISC_PBit EQ 1) | |
1261 rlp_data->ker.Poll_xchg = IW_WAIT; | |
1262 | |
1263 rlp_data->ker.DISC_State = ISW_WAIT; | |
1264 rlp_data->ker.DISC_Count++; | |
1265 TIMERSTART (TT_HANDLE, rlp_data->ker.T1); | |
1266 } | |
1267 break; | |
1268 } | |
1269 } | |
1270 break; | |
1271 | |
1272 case RLP_PENDING_RESET_REQ: | |
1273 if (!ker_send_txu()) | |
1274 { | |
1275 switch (rlp_data->ker.SABM_State) | |
1276 { | |
1277 case ISW_WAIT: | |
1278 sig_ker_snd_null_req (); | |
1279 break; | |
1280 | |
1281 case ISW_SEND: | |
1282 switch (rlp_data->ker.Poll_xchg) | |
1283 { | |
1284 case IW_IDLE: | |
1285 sig_ker_snd_sabm_req (); | |
1286 rlp_data->ker.SABM_State = ISW_WAIT; | |
1287 rlp_data->ker.SABM_Count++; | |
1288 rlp_data->ker.Poll_xchg = IW_WAIT; | |
1289 TIMERSTART (TT_HANDLE, rlp_data->ker.T1); | |
1290 break; | |
1291 | |
1292 default: | |
1293 sig_ker_snd_null_req (); | |
1294 break; | |
1295 } | |
1296 break; | |
1297 } | |
1298 } | |
1299 break; | |
1300 | |
1301 case RLP_PENDING_RESET_IND: | |
1302 if (!ker_send_txu()) | |
1303 sig_ker_snd_null_req (); | |
1304 break; | |
1305 | |
1306 case RLP_PENDING_REMAP_REQ: | |
1307 if (!ker_send_txu()) | |
1308 { | |
1309 if (rlp_data->ker.Poll_xchg EQ IW_IDLE) | |
1310 { | |
1311 TIMERSTART(TT_HANDLE, rlp_data->ker.T1 * rlp_data->ker.N2); | |
1312 rlp_data->ker.Poll_xchg = IW_WAIT; | |
1313 } | |
1314 sig_ker_snd_remap_req (&rlp_data->ker.REMAP_FrameDesc); | |
1315 } | |
1316 break; | |
1317 } | |
1318 } | |
1319 | |
1320 /* | |
1321 +--------------------------------------------------------------------+ | |
1322 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1323 | STATE : code ROUTINE : ker_interpret_rlp_frame | | |
1324 +--------------------------------------------------------------------+ | |
1325 | |
1326 PURPOSE : decodes the elements from the given RLP frame | |
1327 | |
1328 */ | |
1329 | |
1330 LOCAL void ker_interpret_rlp_frame | |
1331 ( | |
1332 T_RLP_FRAMEPTR frame, | |
1333 T_PDU_TYPE *pduType, | |
1334 T_BIT *cBit, | |
1335 T_BIT *pFBit, | |
1336 T_FRAME_NUM *nr, | |
1337 T_FRAME_NUM *ns, | |
1338 BOOL *crcOk | |
1339 ) | |
1340 { | |
1341 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1342 T_RLP_DEBUG *deb = &rlp_data->deb; | |
1343 | |
1344 deb->idx=0; | |
1345 deb->trc_buf[deb->idx++] = ((crcOk NEQ NULL) ? 'D' : 'U'); | |
1346 deb->trc_buf[deb->idx++] = ':'; | |
1347 #endif | |
1348 | |
1349 #ifdef _SIMULATION_ | |
1350 TRACE_FUNCTION ("ker_interpret_rlp_frame()"); | |
1351 #endif | |
1352 | |
1353 *cBit = (T_BIT) (frame[0] & 1); | |
1354 *ns = (T_FRAME_NUM) ((frame[0] >> 3) | ((frame[1] & 1)<<5)); | |
1355 *pFBit = (T_BIT) ((frame[1] & 2)>>1); | |
1356 | |
1357 switch (*ns) | |
1358 { | |
1359 case 62: /* S-Frame */ | |
1360 { | |
1361 T_SF sFrame; | |
1362 | |
1363 *nr = (T_FRAME_NUM) ((frame[1]>>2) & 0x3f); | |
1364 | |
1365 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1366 deb->trc_buf[deb->idx++] = 'S'; | |
1367 deb->trc_buf[deb->idx++] = 'r'; | |
1368 DEC_BYTE (*nr, &deb->trc_buf[deb->idx]); deb->idx+=3; | |
1369 deb->trc_buf[deb->idx++] = ' '; | |
1370 #endif | |
1371 | |
1372 sFrame = (T_SF) ((frame[0]>>1) & 0x03); | |
1373 | |
1374 /* | |
1375 * maybe optimize with a table!! | |
1376 */ | |
1377 switch (sFrame) | |
1378 { | |
1379 case SF_RR: | |
1380 *pduType = PDU_RR; | |
1381 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1382 memcpy(&deb->trc_buf[deb->idx], "RR ",3); | |
1383 #endif | |
1384 break; | |
1385 | |
1386 case SF_RNR: | |
1387 *pduType = PDU_RNR; | |
1388 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1389 memcpy(&deb->trc_buf[deb->idx], "RNR",3); | |
1390 #endif | |
1391 break; | |
1392 case SF_REJ: | |
1393 *pduType = PDU_REJ; | |
1394 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1395 memcpy(&deb->trc_buf[deb->idx], "REJ",3); | |
1396 #endif | |
1397 break; | |
1398 case SF_SREJ: | |
1399 *pduType = PDU_SREJ; | |
1400 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1401 memcpy(&deb->trc_buf[deb->idx], "SRJ",3); | |
1402 #endif | |
1403 break; | |
1404 default: | |
1405 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1406 memcpy(&deb->trc_buf[deb->idx], "***",3); | |
1407 #endif | |
1408 break; | |
1409 | |
1410 } | |
1411 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1412 deb->idx+=3; | |
1413 #endif | |
1414 break; | |
1415 } | |
1416 | |
1417 case 63: /* U-Frame */ | |
1418 { | |
1419 T_UF uFrame; | |
1420 uFrame = (T_UF) ((frame[1]>>2) & 0x1f); | |
1421 | |
1422 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1423 deb->trc_buf[deb->idx++] = 'U'; | |
1424 deb->trc_buf[deb->idx++] = ' '; | |
1425 #endif | |
1426 | |
1427 /* | |
1428 * maybe optimize with a table!! | |
1429 */ | |
1430 switch (uFrame) | |
1431 { | |
1432 case UF_UI: | |
1433 *pduType = PDU_UI; | |
1434 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1435 memcpy(&deb->trc_buf[deb->idx], "UI ",4); | |
1436 #endif | |
1437 break; | |
1438 | |
1439 case UF_DM: | |
1440 *pduType = PDU_DM; | |
1441 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1442 memcpy(&deb->trc_buf[deb->idx], "DM ",4); | |
1443 #endif | |
1444 break; | |
1445 | |
1446 case UF_SABM: | |
1447 *pduType = PDU_SABM; | |
1448 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1449 memcpy(&deb->trc_buf[deb->idx], "SABM",4); | |
1450 #endif | |
1451 break; | |
1452 | |
1453 case UF_DISC: | |
1454 *pduType = PDU_DISC; | |
1455 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1456 memcpy(&deb->trc_buf[deb->idx], "DISC",4); | |
1457 #endif | |
1458 break; | |
1459 | |
1460 case UF_UA: | |
1461 *pduType = PDU_UA; | |
1462 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1463 memcpy(&deb->trc_buf[deb->idx], "UA ",4); | |
1464 #endif | |
1465 break; | |
1466 | |
1467 case UF_NULL: | |
1468 *pduType = PDU_NULL; | |
1469 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1470 memcpy(&deb->trc_buf[deb->idx], "NULL",4); | |
1471 #endif | |
1472 break; | |
1473 | |
1474 case UF_XID: | |
1475 *pduType = PDU_XID; | |
1476 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1477 memcpy(&deb->trc_buf[deb->idx], "XID ",4); | |
1478 #endif | |
1479 break; | |
1480 | |
1481 case UF_TEST: | |
1482 *pduType = PDU_TEST; | |
1483 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1484 memcpy(&deb->trc_buf[deb->idx], "TEST",4); | |
1485 #endif | |
1486 break; | |
1487 | |
1488 case UF_REMAP: | |
1489 *pduType = PDU_REMAP; | |
1490 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1491 memcpy(&deb->trc_buf[deb->idx], "RMAP",4); | |
1492 #endif | |
1493 break; | |
1494 | |
1495 default: | |
1496 *pduType = PDU_INVALID; | |
1497 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1498 memcpy(&deb->trc_buf[deb->idx], "****",4); | |
1499 #endif | |
1500 break; | |
1501 } | |
1502 *nr = 0; | |
1503 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1504 deb->idx += 4; | |
1505 #endif | |
1506 break; | |
1507 } | |
1508 | |
1509 default: /* I+S-Frame */ | |
1510 { | |
1511 T_SF sFrame; | |
1512 | |
1513 *nr = (T_FRAME_NUM) ((frame[1]>>2) & 0x3f); | |
1514 | |
1515 sFrame = (T_SF) ((frame[0]>>1) & 0x03); | |
1516 | |
1517 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1518 deb->trc_buf[deb->idx++] = 'I'; | |
1519 deb->trc_buf[deb->idx++] = 'r'; | |
1520 DEC_BYTE (*nr, &deb->trc_buf[deb->idx]); deb->idx+=3; | |
1521 deb->trc_buf[deb->idx++] = 's'; | |
1522 DEC_BYTE (*ns, &deb->trc_buf[deb->idx]); deb->idx+=3; | |
1523 deb->trc_buf[deb->idx++] = ' '; | |
1524 #endif | |
1525 /* | |
1526 * maybe optimize with a table!! | |
1527 */ | |
1528 switch (sFrame) | |
1529 { | |
1530 case SF_RR: | |
1531 *pduType = PDU_RR_I; | |
1532 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1533 memcpy(&deb->trc_buf[deb->idx], "RR ",3); | |
1534 #endif | |
1535 break; | |
1536 | |
1537 case SF_RNR: | |
1538 *pduType = PDU_RNR_I; | |
1539 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1540 memcpy(&deb->trc_buf[deb->idx], "RNR",3); | |
1541 #endif | |
1542 break; | |
1543 case SF_REJ: | |
1544 *pduType = PDU_REJ_I; | |
1545 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1546 memcpy(&deb->trc_buf[deb->idx], "REJ",3); | |
1547 #endif | |
1548 break; | |
1549 case SF_SREJ: | |
1550 *pduType = PDU_SREJ_I; | |
1551 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1552 memcpy(&deb->trc_buf[deb->idx], "SRJ",3); | |
1553 #endif | |
1554 break; | |
1555 default: | |
1556 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1557 memcpy(&deb->trc_buf[deb->idx], "***",3); | |
1558 #endif | |
1559 break; | |
1560 } | |
1561 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1562 deb->idx += 3; | |
1563 #endif | |
1564 break; | |
1565 } | |
1566 } | |
1567 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1568 if ( | |
1569 (*pduType NEQ PDU_NULL) | |
1570 AND | |
1571 ( | |
1572 (crcOk EQ NULL AND rlp_data->uplink_frame_trace) | |
1573 OR | |
1574 (crcOk NEQ NULL AND rlp_data->downlink_frame_trace) | |
1575 ) | |
1576 ) | |
1577 { | |
1578 deb->trc_buf[deb->idx++] = ' '; | |
1579 deb->trc_buf[deb->idx++] = ((*cBit) ? 'C' : 'R'); | |
1580 deb->trc_buf[deb->idx++] = ((*cBit) ? 'P' : 'F'); | |
1581 deb->trc_buf[deb->idx++] = ' '; | |
1582 HEX_BYTE (frame[1], &deb->trc_buf[deb->idx]); deb->idx+=2; | |
1583 HEX_BYTE (frame[0], &deb->trc_buf[deb->idx]); deb->idx+=2; | |
1584 deb->trc_buf[deb->idx++] = ' '; | |
1585 HEX_BYTE (frame[2], &deb->trc_buf[deb->idx]); deb->idx+=2; | |
1586 HEX_BYTE (frame[3], &deb->trc_buf[deb->idx]); deb->idx+=2; | |
1587 | |
1588 deb->trc_buf[deb->idx] = '\0'; | |
1589 TRACE_EVENT (deb->trc_buf); | |
1590 } | |
1591 #endif | |
1592 /* | |
1593 * no CRC checking at this point. Checking is performed at | |
1594 * Layer 1, so only correct frames are forwared. | |
1595 */ | |
1596 #ifdef TRACE_INTERPRETED_RLP_FRAME | |
1597 if (crcOk NEQ NULL) | |
1598 #endif | |
1599 *crcOk = TRUE; | |
1600 } | |
1601 | |
1602 #ifdef _SIMULATION_ | |
1603 /* | |
1604 +--------------------------------------------------------------------+ | |
1605 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1606 | STATE : code ROUTINE : ker_get_frame_from_sdu | | |
1607 +--------------------------------------------------------------------+ | |
1608 | |
1609 PURPOSE : | |
1610 | |
1611 */ | |
1612 | |
1613 LOCAL T_RLP_FRAMEPTR ker_get_frame_from_sdu(T_sdu *sdu) | |
1614 { | |
1615 TRACE_FUNCTION ("ker_get_frame_from_sdu()"); | |
1616 | |
1617 return sdu->buf+(sdu->o_buf>>3); | |
1618 } | |
1619 #endif | |
1620 | |
1621 /* | |
1622 +--------------------------------------------------------------------+ | |
1623 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1624 | STATE : code ROUTINE : ker_analyse_prim | | |
1625 +--------------------------------------------------------------------+ | |
1626 | |
1627 PURPOSE : | |
1628 | |
1629 */ | |
1630 | |
1631 #ifdef _SIMULATION_ | |
1632 LOCAL void ker_analyse_prim(T_RA_DATA_IND *ra_data_ind) | |
1633 #else | |
1634 LOCAL void ker_analyse_prim(void) | |
1635 #endif | |
1636 { | |
1637 T_RLP_FRAMEPTR frame; | |
1638 T_PDU_TYPE pduType; | |
1639 T_BIT cBit; | |
1640 T_BIT pFBit; | |
1641 T_FRAME_NUM nr, ns; | |
1642 BOOL crcOk; | |
1643 | |
1644 TRACE_FUNCTION ("ker_analyse_prim()"); | |
1645 | |
1646 #ifdef _SIMULATION_ | |
1647 PACCESS (ra_data_ind); | |
1648 frame = ker_get_frame_from_sdu (&ra_data_ind->sdu); | |
1649 rbm_store_frame (frame); | |
1650 PFREE (ra_data_ind); | |
1651 #endif | |
1652 | |
1653 frame = rbm_get_current_frame (); | |
1654 | |
1655 /* | |
1656 TRACE_DATA_RLP_FRAME(frame); | |
1657 */ | |
1658 | |
1659 ker_interpret_rlp_frame | |
1660 ( | |
1661 frame, | |
1662 &pduType, | |
1663 &cBit, | |
1664 &pFBit, | |
1665 &nr, | |
1666 &ns, | |
1667 &crcOk | |
1668 ); | |
1669 | |
1670 sig_ker_rcv_rawdata_res | |
1671 ( | |
1672 pduType, | |
1673 cBit, | |
1674 pFBit, | |
1675 nr, | |
1676 ns, | |
1677 crcOk | |
1678 ); | |
1679 | |
1680 } | |
1681 | |
1682 /* | |
1683 +------------------------------------------------------------------------------ | |
1684 | Function : sig_rcv_ker_rawdata_ind | |
1685 +------------------------------------------------------------------------------ | |
1686 | Description : Process signal SIG_RAWDATA_IND received from process rcv. | |
1687 | | |
1688 | Parameters : ra_data_ind - | |
1689 | | |
1690 | | |
1691 | Return : - | |
1692 +------------------------------------------------------------------------------ | |
1693 */ | |
1694 | |
1695 #ifdef _SIMULATION_ | |
1696 GLOBAL void sig_rcv_ker_rawdata_ind(T_RA_DATA_IND *ra_data_ind) | |
1697 #else | |
1698 GLOBAL void sig_rcv_ker_rawdata_ind(void) | |
1699 #endif | |
1700 { | |
1701 TRACE_FUNCTION ("sig_rcv_ker_rawdata_ind()"); | |
1702 | |
1703 #ifdef _SIMULATION_ | |
1704 ker_analyse_prim(ra_data_ind); | |
1705 #else | |
1706 ker_analyse_prim(); | |
1707 #endif | |
1708 } |